@sinch/functions-runtime 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -890,7 +890,11 @@ function createLenientJsonParser(options = {}) {
890
890
  return function lenientJsonParser(req, res, next) {
891
891
  if (req.body && typeof req.body === "object" && !Buffer.isBuffer(req.body)) {
892
892
  if (!req._keysTransformed) {
893
- req.body = transformKeys(req.body, opts.camelCase);
893
+ const VOICE_EVENTS = ["ice", "ace", "pie", "dice", "notify"];
894
+ const isVoice = req.body.event && VOICE_EVENTS.includes(req.body.event);
895
+ if (isVoice) {
896
+ req.body = transformKeys(req.body, opts.camelCase);
897
+ }
894
898
  req._keysTransformed = true;
895
899
  }
896
900
  return next();
@@ -908,8 +912,10 @@ function createLenientJsonParser(options = {}) {
908
912
  }
909
913
  try {
910
914
  let parsed = parseJson(raw, opts.allowJson5);
911
- const isWebhookPath = req.path.startsWith("/webhook");
912
- if (!isWebhookPath) {
915
+ const VOICE_EVENTS = ["ice", "ace", "pie", "dice", "notify"];
916
+ const evt = parsed && typeof parsed === "object" && "event" in parsed ? parsed.event : null;
917
+ const isVoice = typeof evt === "string" && VOICE_EVENTS.includes(evt);
918
+ if (isVoice) {
913
919
  parsed = transformKeys(parsed, opts.camelCase);
914
920
  }
915
921
  req._keysTransformed = true;