replicate-javascript
replicate-javascript copied to clipboard
Document how to validate webhooks if your app is not using Request™
From @aron in https://github.com/replicate/replicate-javascript/pull/259#discussion_r1599131203
We should cover what to do if your environment doesn't support
Request, in which case you pass through the parts manually:
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
};
const webhookIsValid = await validateWebhook(requestData, secret);
FYI - The supported / expected argument types are documented here:
https://github.com/replicate/replicate-javascript/blob/70ca64a472fd729c7a8688050c2b4e97a3228bed/lib/util.js#L3-L31
Thanks for your help with this, @aron 😄