Skip to content

fix: read the magic link code from the fragment with the SDK's verify helpers - #175

Open
Bccorb wants to merge 1 commit into
mainfrom
fix/magic-link-m6-flow
Open

Bccorb wants to merge 1 commit into
mainfrom
fix/magic-link-m6-flow

Conversation

@Bccorb

@Bccorb Bccorb commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Moves the starters to the held magic link flow from fells-code/seamless-auth-api#614 (M6): the emailed link is /verify-magiclink?token=T#code=C, GET /magic-link/verify/:token always answers 409 with sameDevice and never signs in, and POST .../confirm requires { code }.

Changes

  • SDK versions. @seamless-auth/react 0.21.0 (react-vite, react-oauth, nextjs), @seamless-auth/angular 0.6.0, @seamless-auth/vue 0.5.0, @seamless-auth/svelte 0.5.0, @seamless-auth/nextjs 0.11.0 and @seamless-auth/react-native 0.6.0, the latest on npm. Lockfiles regenerated. The bundled verify screens in these releases strip the link from the address bar, confirm on their own when sameDevice is set, and send the code when the reader approves another device.
  • Next.js verify page. VerifyMagicLink.tsx is rebuilt on takeMagicLinkParams, verifyMagicLinkSignIn, finishMagicLinkSignIn, confirmMagicLinkSignIn and magicLinkConfirmationPrompt from @seamless-auth/client, now a direct dependency at ^0.11.0 because @seamless-auth/react does not re-export them. The page no longer reads searchParams, since the code lives in the fragment, which only the browser sees. The link is read once into a ref and verified once, so the Strict Mode remount neither finds a stripped address nor spends the link twice. The old authorizedFetch fallback for SDKs without confirmMagicLink is gone. The button names and headings are unchanged. Against an older API that sends no code, the helpers still sign in on the verify call.
  • Tests. VerifyMagicLink.test.tsx runs the real client helpers against a mocked client. It covers: same-device confirm with the fragment code, once under Strict Mode; the address being stripped while other parameters are kept; an older API signing in on verify; the requesting tab collecting the session; a failed link; and the other-device prompt, approve, failure and decline paths.
  • redirectUri. No starter passes a redirectUri or magicLinkRedirectUri, so every link goes to the API default, <frontend_url>/verify-magiclink. Every web starter that offers magic links serves that exact path: the bundled routes in React, Angular and Vue, SvelteKit's src/routes/verify-magiclink, and the Next.js page. react-oauth offers no magic link. Expo only polls /magic-link/check.
  • Next.js AGENTS.md and the Expo README describe the new flow.
  • Changeset: patch. Generated projects keep working against older auth APIs.

Checks run locally

  • npm run check passes in react-vite, react-oauth, angular, vue, svelte, nextjs and expo.
  • npm run build passes in all seven.
  • npm run validate and the root format:check pass.

Outside this repo

The seamless-cli harness specs verify/harness/{react,nextjs}/magicLinkLogin.spec.ts open /verify-magiclink?token=... without the fragment and assert that every verify request succeeds. Under the new API the verify call always answers 409 and the confirm needs the code. So those specs have to open the captured magicLinkUrl, which keeps the #code=, and allow the 409. The Next.js capture route already stores the full URL.

… helpers

Moves the web, fullstack and mobile starters to the SDK releases for the held magic
link flow, and rebuilds the Next.js verify page on takeMagicLinkParams and
verifyMagicLinkSignIn.
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.

1 participant