Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@wobsoriano
Copy link
Member

@wobsoriano wobsoriano commented Apr 14, 2025

Description

Recently, we added a way to simplify webhook verification across our SDKs. While this works for all SDKs that provides a standard web Request, there are still users who use Next.js Pages Router or frameworks like tRPC that use Node's IncomingMessage instead of web Request. This PR adds support for webhook verification with these frameworks by accepting a RequestLike request, accepting both standard web Request and Node Request.

Resolves ECO-571

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@vercel
Copy link

vercel bot commented Apr 14, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 14, 2025 7:41pm

@changeset-bot
Copy link

changeset-bot bot commented Apr 14, 2025

🦋 Changeset detected

Latest commit: e6a0538

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clerk/nextjs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@wobsoriano
Copy link
Member Author

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @wobsoriano - the snapshot version command generated the following package versions:

Package Version
@clerk/agent-toolkit 0.0.22-snapshot.v20250414153812
@clerk/astro 2.6.4-snapshot.v20250414153812
@clerk/backend 1.28.0-snapshot.v20250414153812
@clerk/chrome-extension 2.2.29-snapshot.v20250414153812
@clerk/clerk-js 5.61.0-snapshot.v20250414153812
@clerk/elements 0.23.14-snapshot.v20250414153812
@clerk/clerk-expo 2.9.12-snapshot.v20250414153812
@clerk/expo-passkeys 0.2.6-snapshot.v20250414153812
@clerk/express 1.4.5-snapshot.v20250414153812
@clerk/fastify 2.2.5-snapshot.v20250414153812
@clerk/localizations 3.13.10-snapshot.v20250414153812
@clerk/nextjs 6.15.0-snapshot.v20250414153812
@clerk/nuxt 1.5.5-snapshot.v20250414153812
@clerk/clerk-react 5.28.0-snapshot.v20250414153812
@clerk/react-router 1.2.5-snapshot.v20250414153812
@clerk/remix 4.5.17-snapshot.v20250414153812
@clerk/shared 3.7.0-snapshot.v20250414153812
@clerk/tanstack-react-start 0.13.5-snapshot.v20250414153812
@clerk/testing 1.4.39-snapshot.v20250414153812
@clerk/themes 2.2.32-snapshot.v20250414153812
@clerk/types 4.54.0-snapshot.v20250414153812
@clerk/vue 1.6.1-snapshot.v20250414153812

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/agent-toolkit

npm i @clerk/[email protected] --save-exact

@clerk/astro

npm i @clerk/[email protected] --save-exact

@clerk/backend

npm i @clerk/[email protected] --save-exact

@clerk/chrome-extension

npm i @clerk/[email protected] --save-exact

@clerk/clerk-js

npm i @clerk/[email protected] --save-exact

@clerk/elements

npm i @clerk/[email protected] --save-exact

@clerk/clerk-expo

npm i @clerk/[email protected] --save-exact

@clerk/expo-passkeys

npm i @clerk/[email protected] --save-exact

@clerk/express

npm i @clerk/[email protected] --save-exact

@clerk/fastify

npm i @clerk/[email protected] --save-exact

@clerk/localizations

npm i @clerk/[email protected] --save-exact

@clerk/nextjs

npm i @clerk/[email protected] --save-exact

@clerk/nuxt

npm i @clerk/[email protected] --save-exact

@clerk/clerk-react

npm i @clerk/[email protected] --save-exact

@clerk/react-router

npm i @clerk/[email protected] --save-exact

@clerk/remix

npm i @clerk/[email protected] --save-exact

@clerk/shared

npm i @clerk/[email protected] --save-exact

@clerk/tanstack-react-start

npm i @clerk/[email protected] --save-exact

@clerk/testing

npm i @clerk/[email protected] --save-exact

@clerk/themes

npm i @clerk/[email protected] --save-exact

@clerk/types

npm i @clerk/[email protected] --save-exact

@clerk/vue

npm i @clerk/[email protected] --save-exact

Comment on lines +50 to +57
export async function verifyWebhook(request: RequestLike, options?: VerifyWebhookOptions) {
if (isNextRequest(request) || isRequestWebAPI(request)) {
return verifyWebhookBase(request, options);
}

const webRequest = nextApiRequestToWebRequest(request);
return verifyWebhookBase(webRequest, options);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

For standard web Request, it uses the default verifyWebhook provided by the backend SDK. For NextApiRequest type, we're converting it to a Request before verifying

@wobsoriano wobsoriano marked this pull request as ready for review April 14, 2025 19:41
Copy link
Member

@tmilewski tmilewski left a comment

Choose a reason for hiding this comment

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

🚀

@wobsoriano wobsoriano merged commit 01f501d into main Apr 14, 2025
30 checks passed
@wobsoriano wobsoriano deleted the rob/eco-571-widen-type-support-for-nextjs-verifywebhook-request-param-by branch April 14, 2025 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants