如何在Twilio Functions中安全地存储电话号码?

时间:2019-06-16 02:59:54

标签: twilio-functions

我正在使用Twilio函数。我想知道功能代码中存储的电话号码是否安全?

我使用的代码类似于此处的代码:https://support.twilio.com/hc/en-us/articles/223180548-How-Can-I-Stop-Receiving-or-Block-Incoming-Phone-Calls-#blacklistNumbers

基本上,它会拒绝您选择的黑名单上的数字。黑名单位于函数的代码本身中。

也许这已经安全了。原谅我的误会。

上述代码:

exports.handler = function(context, event, callback) {
  // Listing all the blocked phone numbers, at the moment "+1(212)555-1234" and "+1(702)555-6789"
  let blacklist = event.blacklist || [ "+12125551234", "+17025556789" ];

  let twiml = new Twilio.twiml.VoiceResponse();
  let blocked = true;
  if (blacklist.length > 0) {
    if (blacklist.indexOf(event.From) === -1) {
      blocked = false;
    }
  }
  if (blocked) {
    twiml.reject();
  }
  else {
    // if the caller's number is not blocked, redirecting to another TwiML which includes instructions for what to do
    twiml.redirect("https://demo.twilio.com/docs/voice.xml");
  }
  callback(null, twiml);
};

1 个答案:

答案 0 :(得分:0)

Heyooo。 Twilio开发人员布道者在这里。 ?

我认为您不必担心这些号码的安全性。但是,您可以怎么做才能将黑名单添加到function configuration instead。这样,您就不必在想要向黑名单中添加新号码时更改功能代码。

Function configuration in twilio

下面的这些值将在传递给函数的上下文对象中提供。

Blacklist as function parameter

exports.handler = async function(context, event, callback) {
  console.log(context.BLACKLIST); // 1212...
}