feat(clerk-js): Add debugLogger for session token swap detection#7945
feat(clerk-js): Add debugLogger for session token swap detection#7945brkalow merged 3 commits intorelease/core-2from
Conversation
…ection Add debug logging to detect server-side token swaps in multi-session scenarios: - Session.ts: Check if returned token's sid matches requested session - AuthCookieService.ts: Log multi-session cookie updates and token fetch errors - clerk.ts: Log session state before unauthenticated flow
🦋 Changeset detectedLatest commit: 2774a75 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
Description
Add debug logging to detect server-side token swaps in multi-session scenarios (e.g., regular session + impersonation session with actor token). BAPI's refresh endpoint could return a token for a different session than the one requested — these logs give client-side visibility to detect this.
Logging added:
sidclaim matches the requesting session ID — logs a warning on mismatch (the token swap signal)sessions.length > 1), 4xx token fetch errors with error code, and degraded status with error namehandleUnauthenticatedtriggersPrivacy considerations:
sess_xxx), booleans, counts, and error codes/names — no tokens, URLs, PII, or raw error messagesdebugLoggerpatterns (same fields logged in tokenCache.ts, AuthCookieService.ts, etc.)Checklist
pnpm buildruns as expected.pnpm testruns as expected.Type of change