From ba5614ed263808046db9101d7e150cc9388a92d4 Mon Sep 17 00:00:00 2001 From: Aron Carroll Date: Fri, 5 Jul 2024 16:45:38 +0100 Subject: [PATCH] Document alternate interface to `validateWebhook()` Fixes #261 --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 0f26281..401bfad 100644 --- a/README.md +++ b/README.md @@ -210,6 +210,19 @@ export async function POST(request) { } ``` +If your environment doesn't support `Request` objects, you can pass the required information to `validateWebhook` directly: + +```js +const requestData = { + id: "123", // the `Webhook-Id` header + timestamp: "0123456", // the `Webhook-Timestamp` header + signature: "xyz", // the `Webhook-Signature` header + body: "{...}", // the request body as a string, ArrayBuffer or ReadableStream + secret: "shhh", // the webhook secret, obtained from the `replicate.webhooks.defaul.secret` endpoint +}; +const webhookIsValid = await validateWebhook(requestData); +``` + ## TypeScript The `Replicate` constructor and all `replicate.*` methods are fully typed.