lib/webhooks/webhooks.js
function getExpectedTwilioSignature(authToken, url, params) {
  if (url.indexOf('bodySHA256') != -1) params = {};
  var data = Object.keys(params)
    .sort()
    .reduce((acc, key) => acc + key + params[key], url);
  
  return crypto
    .createHmac('sha1', authToken)
    .update(Buffer.from(data, 'utf-8'))
    .digest('base64');
}
function getExpectedTwilioSignature(authToken, url, params) {
  if (url.indexOf('bodySHA256') != -1) params = {};
  var data = Object.keys(params)
    .sort()
    .reduce((acc, key) => acc + key + params[key], url);
  
  return crypto
    .createHmac('sha1', authToken)
    .update(Buffer.from(data, 'utf-8'))
    .digest('base64');
}
function getExpectedTwilioSignature ( authToken , url , params ) { if ( url . indexOf ( 'bodySHA256' ) != - 1 ) params = { } ; var data = Object . keys ( params ) . sort ( ) . reduce ( ( acc , key ) => acc + key + params [ key ] , url ) ; return crypto . createHmac ( 'sha1' , authToken ) . update ( Buffer . from ( data , 'utf-8' ) ) . digest ( 'base64' ) ; }
Utility function to get the expected signature for a given request

@param {string} authToken - The auth token, as seen in the Twilio portal
@param {string} url - The full URL (with query string) you configured to handle this request
@param {object} params - the parameters sent with this request
@returns {string} - signature
Utility function to get the expected signature for a given request