Set up an HMAC-SHA1 header with the attached script as the input, and your Twilio secret as the key like this:
The script will calculate a correct signature for any request you throw at it.
| // https://www.twilio.com/docs/api/security | |
| function evaluate(context) { | |
| const request = context.getCurrentRequest(); | |
| const body = request.getUrlEncodedBody(); | |
| return request.url + | |
| Object.keys(body) | |
| .map((key) => key + body[key]) | |
| .sort() | |
| .join(''); | |
| } |