Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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");
}
Expand Down