Repository: svix/svix-webhooks (language: rust)

Issue:
JavaScript Library: Verify that the payload is a string (rather than an object)
The function just stringifies objects as `[object Object]` which is obviously not correct, and it's easy to miss/get wrong.


Discussion / hints:

Fix patch:
diff --git a/javascript/src/index.ts b/javascript/src/index.ts
index 6b93adddc..69f5213a8 100644
--- a/javascript/src/index.ts
+++ b/javascript/src/index.ts
@@ -768,6 +768,10 @@ export class Webhook {
       | WebhookUnbrandedRequiredHeaders
       | Record<string, string>
   ): unknown {
+    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 headers: Record<string, string> = {};
     for (const key of Object.keys(headers_)) {
       headers[key.toLowerCase()] = (headers_ as Record<string, string>)[key];


Test patch: