Skip to content

Commit 6b45d60

Browse files
committed
[javascript] Remove Buffer usage
1 parent 805a2f8 commit 6b45d60

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

javascript/src/index.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ export class Webhook {
804804
}
805805

806806
public verify(
807-
payload: string | Buffer,
807+
payload: string,
808808
headers_:
809809
| WebhookRequiredHeaders
810810
| WebhookUnbrandedRequiredHeaders
@@ -850,13 +850,9 @@ export class Webhook {
850850
throw new WebhookVerificationError("No matching signature found");
851851
}
852852

853-
public sign(msgId: string, timestamp: Date, payload: string | Buffer): string {
854-
if (typeof payload === "string") {
855-
// Do nothing, already a string
856-
} else if (payload.constructor.name === "Buffer") {
857-
payload = payload.toString();
858-
} else {
859-
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.");
853+
public sign(msgId: string, timestamp: Date, payload: string): string {
854+
if (typeof payload !== "string") {
855+
throw new Error("Expected payload to be of type string. Please refer to https://docs.svix.com/receiving/verifying-payloads/how for more information.");
860856
}
861857

862858
const encoder = new TextEncoder();

0 commit comments

Comments
 (0)