replicate-javascript icon indicating copy to clipboard operation
replicate-javascript copied to clipboard

Document how to validate webhooks if your app is not using Request™

Open zeke opened this issue 1 month ago • 1 comments

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);

zeke avatar May 14 '24 23:05 zeke