chore(fastify): Use runtime keys for auth client and add enableHandshake option#8560
chore(fastify): Use runtime keys for auth client and add enableHandshake option#8560jescalan wants to merge 13 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
🦋 Changeset detectedLatest commit: a4ef868 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
!snapshot |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR refactors Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
This comment has been minimized.
This comment has been minimized.
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
71d3ff7 to
25efe99
Compare
|
Done — I pulled in the changes from #8563 in commits 19f3473, 0cc1e3c, and 60312d1, and added a follow-up fix for the React Router CI type error in 9243a0a. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
!snapshot |
|
!snapshot |
|
!snapshot |
|
Hey @wobsoriano - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/astro@3.2.4-snapshot.v20260515233846 --save-exact
npm i @clerk/backend@3.4.9-snapshot.v20260515233846 --save-exact
npm i @clerk/chrome-extension@3.1.26-snapshot.v20260515233846 --save-exact
npm i @clerk/clerk-js@6.11.1-snapshot.v20260515233846 --save-exact
npm i @clerk/dev-cli@0.1.1-snapshot.v20260515233846 --save-exact
npm i @clerk/expo@3.2.12-snapshot.v20260515233846 --save-exact
npm i @clerk/expo-passkeys@1.0.25-snapshot.v20260515233846 --save-exact
npm i @clerk/express@2.1.17-snapshot.v20260515233846 --save-exact
npm i @clerk/fastify@3.1.27-snapshot.v20260515233846 --save-exact
npm i @clerk/hono@0.1.27-snapshot.v20260515233846 --save-exact
npm i @clerk/localizations@4.6.4-snapshot.v20260515233846 --save-exact
npm i @clerk/msw@0.0.25-snapshot.v20260515233846 --save-exact
npm i @clerk/nextjs@7.3.5-snapshot.v20260515233846 --save-exact
npm i @clerk/nuxt@2.4.4-snapshot.v20260515233846 --save-exact
npm i @clerk/react@6.6.4-snapshot.v20260515233846 --save-exact
npm i @clerk/react-router@3.2.5-snapshot.v20260515233846 --save-exact
npm i @clerk/shared@4.12.0-snapshot.v20260515233846 --save-exact
npm i @clerk/tanstack-react-start@1.2.5-snapshot.v20260515233846 --save-exact
npm i @clerk/testing@2.0.29-snapshot.v20260515233846 --save-exact
npm i @clerk/ui@1.11.0-snapshot.v20260515233846 --save-exact
npm i @clerk/upgrade@2.0.3-snapshot.v20260515233846 --save-exact
npm i @clerk/vue@2.2.4-snapshot.v20260515233846 --save-exact |
Summary
authenticateRequestContext
Forced handshake nonce transport stores a short
__clerk_handshake_nonceinstead of the large__clerk_handshakepayload. Server SDKs then need to exchange that nonce through the Backend API client attached toauthenticateRequest.Several framework wrappers passed runtime
secretKey/publishableKeyintoauthenticateRequest, but constructed the request client from environment defaults or earlier unresolved options. That means apps loading keys asynchronously and passing them into middleware could authenticate some paths with the runtime key while nonce payload exchange still used a client created without that key.Hono and Next.js already build the client from runtime options, so no patch was needed there.
Performance
This patch avoids adding a new per-request client construction path in the common static-key cases:
clerkPlugin()registers middleware.clerkMiddleware()is created for static options. The callback form can still create a middleware/client per request, but that was already how callback options worked.createClerkClient()itself does not perform network I/O; it builds the Backend API resource client,authenticateRequestclosure, and telemetry collector. The nonce exchange network call only happens whenauthenticateRequestreaches forced handshake nonce handling.Testing
pnpm -C packages/fastify exec vitest run src/__tests__/withClerkMiddleware.test.tspnpm -C packages/express exec vitest run src/__tests__/clerkMiddleware.test.ts -t "builds a per-middleware ClerkClient with runtime keys"pnpm -C packages/react-router exec vitest run src/server/__tests__/clerkMiddleware.test.tspnpm -C packages/nuxt exec vitest run src/runtime/server/__tests__/clerkClient.test.tspnpm -C packages/astro exec vitest run src/server/__tests__/clerk-client.test.tspnpm -C packages/tanstack-react-start exec vitest run src/server/__tests__/clerkClient.test.tspnpm -C packages/fastify buildpnpm -C packages/express buildpnpm -C packages/fastify lint(passes with existing no-misused-promises warnings)pnpm -C packages/express lint(passes with existing no-misused-promises warnings)pnpm -C packages/astro lint(passes with existing warnings)git diff --checkNotes
getAutoProxyUrlFromEnvironment is not a function.@clerk/react/@clerk/vueexports or declarations). Their JS builds reached the compile stage before those existing declaration/linkage failures.