diff --git a/lib/util.js b/lib/util.js index b4483ae..a36c480 100644 --- a/lib/util.js +++ b/lib/util.js @@ -35,9 +35,15 @@ async function validateWebhook(requestData, secret) { const signingSecret = secret || requestData.secret; if (requestData && requestData.headers && requestData.body) { - id = requestData.headers.get("webhook-id"); - timestamp = requestData.headers.get("webhook-timestamp"); - signature = requestData.headers.get("webhook-signature"); + id = + requestData.headers["webhook-id"] || + requestData.headers.get?.("webhook-id"); + timestamp = + requestData.headers["webhook-timestamp"] || + requestData.headers.get?.("webhook-timestamp"); + signature = + requestData.headers["webhook-signature"] || + requestData.headers.get?.("webhook-signature"); body = requestData.body; } @@ -49,6 +55,8 @@ async function validateWebhook(requestData, secret) { } } else if (isTypedArray(body)) { body = await new Blob([body]).text(); + } else if (typeof body === "object") { + body = JSON.stringify(body); } else if (typeof body !== "string") { throw new Error("Invalid body type"); }