Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: document validateWebhook #259

Merged
merged 2 commits into from
May 14, 2024
Merged

docs: document validateWebhook #259

merged 2 commits into from
May 14, 2024

Conversation

zeke
Copy link
Member

@zeke zeke commented May 13, 2024

Resolves #195

@zeke zeke requested review from mattt, aron and a team May 13, 2024 18:07
Copy link
Contributor

@aron aron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, one minor comment to also document the fallback arguments for when the environment doesn't support the Request API.


return NextResponse.json({ detail: "Webhook is valid" }, { status: 200 });
}
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good point. I opened an issue to follow up on that: #261

@zeke zeke changed the title document validateWebhook docs: document validateWebhook May 14, 2024
@zeke zeke merged commit 70ca64a into main May 14, 2024
18 checks passed
@zeke zeke deleted the document-validateWebhook branch May 14, 2024 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

document how to use (and validate) webhooks
2 participants