Repository navigation
fix(auth): PasskeyLoginButton must surface error when desktop IPC bridge is missing - #1004
Conversation
…issing Adds two failing cases that assert PasskeyLoginButton surfaces an "update the desktop app" error and posts nothing to the server when isDesktopPlatform() is true but window.electron.auth.openExternal is unavailable. Pre-fix the component silently falls through to the web ceremony, which PR #1003 will now reject at the server with a 400 — regressing sign-in for older Electron bridges. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ign-in Gates the entire sign-in path on isDesktopPlatform() first. When the Electron build lacks window.electron.auth.openExternal — older bridges, partial preload, broken IPC — the component now surfaces a clear "update the desktop app" toast and returns early instead of silently falling through to the web ceremony. Closes a regression that PR #1003 introduces: once the server rejects platform=desktop without desktopExchange, the previous silent fallthrough would hard-400 any user on an older desktop bridge. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 3 minutes and 57 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Sister PR to #1003. Fixes a client-side regression that #1003 would otherwise introduce: after #1003 tightens
POST /api/auth/passkey/authenticateto rejectplatform: 'desktop'withoutdesktopExchange: true, any Electron build whose preload lackswindow.electron.auth.openExternalwill hard-400 on passkey sign-in, becausePasskeyLoginButtoncurrently silently falls through to the web ceremony when the IPC bridge is unavailable.The fix lives entirely on the client. The server guard added in #1003 is correct and stays as-is; the legacy raw-token server branch is NOT restored.
Prior fallthrough site —
apps/web/src/components/auth/PasskeyLoginButton.tsx:54(pre-fix):Invariant
The client must never POST
platform: 'desktop'to/api/auth/passkey/authenticateunless it is also usingdesktopExchange: truevia the external-browser ceremony path. If the IPC bridge that enables the external-browser path is unavailable, the client must surface a clear error to the user — not silently fall through to a code path that will be rejected by the server.The fix
handleLogininPasskeyLoginButton.tsxnow gates onisDesktopPlatform()first, before readingcsrfTokenor callingstartAuthentication. Inside the desktop branch:window.electron?.auth?.openExternalis missing → toast"Your desktop app needs to be updated to sign in with a passkey. Please update the app and try again."and return early. No network call is made.Web path is untouched.
Commits
83dadc4a— test(auth): red — PasskeyLoginButton must error when desktop bridge missing0c4da27b— fix(auth): PasskeyLoginButton requires openExternal IPC for desktop sign-inTwo failing test cases were added to
PasskeyLoginButton.desktop.test.tsx:window.electronabsent → assertstoast.errormatches/desktop app/i, nofetchto any/api/auth/passkey/authenticate*, andstartAuthenticationnot called.window.electron.auth = {}(bridge exists butopenExternalmissing) → same assertions.Both failed against the pre-fix component and pass after.
Relationship to #1003
This PR is intended to ship together with #1003 in the same release. Default is to land them as two separate PRs; the orchestrator can fold this into #1003 if that's cleaner.
Test plan
PasskeyLoginButton.desktop.test.tsxgreen after fixpnpm --filter web exec vitest run src/components/auth— 24/24 passingpnpm --filter web typecheck— cleanpnpm --filter web lint— no new warnings (pre-existing CalendarView warnings only)pnpm --filter web build— clean🤖 Generated with Claude Code