Skip to content

Commit

Permalink
Document alternate interface to validateWebhook()
Browse files Browse the repository at this point in the history
Fixes #261
  • Loading branch information
aron committed Jul 5, 2024
1 parent 8d8e599 commit ba5614e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit ba5614e

Please # to comment.