@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.
@@ -116,7 +116,11 @@ function createLenientJsonParser(options = {}) {
116
116
  return function lenientJsonParser(req, res, next) {
117
117
  if (req.body && typeof req.body === "object" && !Buffer.isBuffer(req.body)) {
118
118
  if (!req._keysTransformed) {
119
- req.body = transformKeys(req.body, opts.camelCase);
119
+ const VOICE_EVENTS = ["ice", "ace", "pie", "dice", "notify"];
120
+ const isVoice = req.body.event && VOICE_EVENTS.includes(req.body.event);
121
+ if (isVoice) {
122
+ req.body = transformKeys(req.body, opts.camelCase);
123
+ }
120
124
  req._keysTransformed = true;
121
125
  }
122
126
  return next();
@@ -134,8 +138,10 @@ function createLenientJsonParser(options = {}) {
134
138
  }
135
139
  try {
136
140
  let parsed = parseJson(raw, opts.allowJson5);
137
- const isWebhookPath = req.path.startsWith("/webhook");
138
- if (!isWebhookPath) {
141
+ const VOICE_EVENTS = ["ice", "ace", "pie", "dice", "notify"];
142
+ const evt = parsed && typeof parsed === "object" && "event" in parsed ? parsed.event : null;
143
+ const isVoice = typeof evt === "string" && VOICE_EVENTS.includes(evt);
144
+ if (isVoice) {
139
145
  parsed = transformKeys(parsed, opts.camelCase);
140
146
  }
141
147
  req._keysTransformed = true;