add support for rasa verb, and support for providing multiple webhook secrets

This commit is contained in:
Dave Horton
2021-09-02 12:43:10 -04:00
parent 525496e18c
commit 09294dee97
3 changed files with 34 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
{
"sip_decline": {
"sip:decline": {
"properties": {
"status": "number",
"reason": "string",
@@ -124,6 +124,10 @@
"credentials": "object|string",
"project": "string",
"environment": "string",
"region": {
"type": "string",
"enum": ["europe-west1", "europe-west2", "australia-southeast1", "asia-northeast1"]
},
"lang": "string",
"actionHook": "object|string",
"eventHook": "object|string",
@@ -166,17 +170,14 @@
"passDtmf": "boolean",
"actionHook": "object|string",
"eventHook": "object|string",
"prompt": {
"type": "string",
"enum": ["lex", "tts"]
},
"noInputTimeout": "number",
"tts": "#synthesizer"
},
"required": [
"botId",
"botAlias",
"region"
"region",
"credentials"
]
},
"listen": {
@@ -205,7 +206,9 @@
},
"message": {
"properties": {
"provider": "string",
"carrier": "string",
"account_sid": "string",
"message_sid": "string",
"to": "string",
"from": "string",
"text": "string",
@@ -225,6 +228,19 @@
"length"
]
},
"rasa": {
"properties": {
"url": "string",
"recognizer": "#recognizer",
"tts": "#synthesizer",
"prompt": "string",
"actionHook": "object|string",
"eventHook": "object|string"
},
"required": [
"url"
]
},
"redirect": {
"properties": {
"actionHook": "object|string"
@@ -233,7 +249,7 @@
"actionHook"
]
},
"rest_dial": {
"rest:dial": {
"properties": {
"account_sid": "string",
"application_sid": "string",

View File

@@ -99,10 +99,15 @@ class WebhookResponse {
if (!details.signatures.length) {
throw new Error('no signatures found');
}
const expectedSignature = computeSignature(req.body, details.timestamp, secret);
const signatureFound = details.signatures.filter(
secureCompare.bind(null, expectedSignature)
).length > 0;
const secrets = Array.isArray(secret) ? secret : [secret];
let signatureFound = false;
for (const secret of secrets) {
const expectedSignature = computeSignature(req.body, details.timestamp, secret);
signatureFound = details.signatures.filter(
secureCompare.bind(null, expectedSignature)
).length > 0;
if (signatureFound) break;
}
if (!signatureFound) {
throw new Error('No matching signatures found');
}

View File

@@ -1,6 +1,6 @@
{
"name": "@jambonz/node-client",
"version": "0.2.4",
"version": "0.2.5",
"description": "",
"main": "lib/index.js",
"scripts": {