From 01ce6207a6970bff8e7d1ea68cbeb18db318141e Mon Sep 17 00:00:00 2001 From: Dom Webber Date: Thu, 5 Dec 2024 13:29:06 +0000 Subject: [PATCH 1/2] Resolve ESLint warning regarding text encoding identifier case --- src/Webhook/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Webhook/index.ts b/src/Webhook/index.ts index ce42278..8f98acc 100644 --- a/src/Webhook/index.ts +++ b/src/Webhook/index.ts @@ -215,7 +215,7 @@ export default class Webhook { // See: https://developers.facebook.com/docs/messenger-platform/webhooks#validate-payloads const getCalculatedSignature = (alg: string) => (appSecret: string) => createHmac(alg, appSecret) - .update(bodyString, "utf-8") + .update(bodyString, "utf8") .digest("hex"); const checkSignature = (alg: string, signature: string) => { From 726a015698a9fe236bedfda48a9bbe57c4149d7b Mon Sep 17 00:00:00 2001 From: Dom Webber Date: Thu, 5 Dec 2024 13:29:25 +0000 Subject: [PATCH 2/2] Apply formatting --- src/Webhook/index.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Webhook/index.ts b/src/Webhook/index.ts index 8f98acc..dab5d87 100644 --- a/src/Webhook/index.ts +++ b/src/Webhook/index.ts @@ -214,9 +214,7 @@ export default class Webhook { // See: https://github.com/WhatsApp/WhatsApp-Nodejs-SDK/blob/58ca3d5fceea604e18393734578d9a7944a37b15/src/utils.ts#L77-L82 // See: https://developers.facebook.com/docs/messenger-platform/webhooks#validate-payloads const getCalculatedSignature = (alg: string) => (appSecret: string) => - createHmac(alg, appSecret) - .update(bodyString, "utf8") - .digest("hex"); + createHmac(alg, appSecret).update(bodyString, "utf8").digest("hex"); const checkSignature = (alg: string, signature: string) => { const signatureCalculator = getCalculatedSignature(alg);