From 6b45d60c9c6781c55dd5774f60e9afda022aa09a Mon Sep 17 00:00:00 2001 From: arjunyel Date: Tue, 23 Jan 2024 15:22:46 -0600 Subject: [PATCH] [javascript] Remove Buffer usage --- javascript/src/index.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/javascript/src/index.ts b/javascript/src/index.ts index d1fec9029..1b80e453c 100644 --- a/javascript/src/index.ts +++ b/javascript/src/index.ts @@ -804,7 +804,7 @@ export class Webhook { } public verify( - payload: string | Buffer, + payload: string, headers_: | WebhookRequiredHeaders | WebhookUnbrandedRequiredHeaders @@ -850,13 +850,9 @@ export class Webhook { throw new WebhookVerificationError("No matching signature found"); } - public sign(msgId: string, timestamp: Date, payload: string | Buffer): string { - if (typeof payload === "string") { - // Do nothing, already a string - } else if (payload.constructor.name === "Buffer") { - payload = payload.toString(); - } else { - throw new Error("Expected payload to be of type string or Buffer. Please refer to https://docs.svix.com/receiving/verifying-payloads/how for more information."); + public sign(msgId: string, timestamp: Date, payload: string): string { + if (typeof payload !== "string") { + throw new Error("Expected payload to be of type string. Please refer to https://docs.svix.com/receiving/verifying-payloads/how for more information."); } const encoder = new TextEncoder();