Socket
Socket
Sign inDemoInstall

twilio

Package Overview
Dependencies
Maintainers
1
Versions
301
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

twilio - npm Package Compare versions

Comparing version 0.7.0 to 0.7.1

examples/example.js

32

lib/index.js

@@ -9,4 +9,6 @@ /**

var RestClient = require('./RestClient');
var crypto = require('crypto'),
RestClient = require('./RestClient');
//Shorthand to automatically create a RestClient
function initializer(sid,tkn) {

@@ -16,2 +18,3 @@ return new RestClient(sid, tkn);

//Main functional components of the Twilio module
initializer.RestClient = RestClient;

@@ -21,3 +24,30 @@ initializer.Capability = require('./Capability');

/**
Utility function to validate an incoming request is indeed from Twilio
@param {string} authToken - The auth token, as seen in the Twilio portal
@param {string} twilioHeader - The value of the X-Twilio-Signature header from the request
@param {string} url - The full URL (with query string) you configured to handle this request
@param {object} params - the parameters sent with this request
*/
initializer.validateRequest = function(authToken, twilioHeader, url, params) {
Object.keys(params).sort().forEach(function(key, i) {
url = url + key + params[key];
});
return twilioHeader === crypto.createHmac('sha1', authToken).update(url).digest('Base64');
};
/**
Utility function to validate an incoming request is indeed from Twilio (for use with express).
adapted from https://github.com/crabasa/twiliosig
@param {object} request - An expressjs request object (http://expressjs.com/api.html#req.params)
@param {string} authToken - The auth token, as seen in the Twilio portal
*/
initializer.validateExpressRequest = function(request, authToken) {
var url = request.protocol + '://' + request.headers.host + request.url;
return initializer.validateRequest(authToken, request.header('X-Twilio-Signature'), url, request.body);
};
//public module interface is a function, which passes through to RestClient constructor
module.exports = initializer;

2

package.json
{
"name":"twilio",
"description":"A Twilio helper library",
"version":"0.7.0",
"version":"0.7.1",
"author":"Kevin Whinnery <kevin.whinnery@gmail.com>",

@@ -6,0 +6,0 @@ "contributors":[

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc