Skip to content

fix(vue,svelte,angular): route recovery sessions to factor enrolment - #252

Merged
Bccorb merged 2 commits into
mainfrom
fix/recovery-session-routing
Nov 21, 2026
Merged

Bccorb merged 2 commits into
mainfrom
fix/recovery-session-routing

Conversation

@Bccorb

@Bccorb Bccorb commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Closes #242 (M18, part of fells-code/seamless-auth-api#603).

Problem

Only the React login screen sent a recovery session to passkey enrolment. The Vue, Svelte and Angular login screens let it sit on the sign-in form, and their requireAuth guards tested only isAuthenticated, so a recovered account reached protected routes with a restricted session that only the server's enrollment_required stopped. Angular also had no redeemRecoveryCode or completeAccountRecovery on its service, so calling the client directly skipped the session refresh and recoverySession never turned true.

Changes

  • Login screens (Vue SaLogin, Svelte Login.svelte, Angular SaLogin): when recoverySession is true, on mount or once a refresh turns the session into one, they navigate to the bundled register-passkey screen through the package's own screen navigation, matching packages/react/src/views/Login.tsx.
  • requireAuth guards: a recovery session is redirected to factor enrolment before any role check. The target is the new enrollmentPath config option (default /register-passkey, alongside loginPath), overridable per guard with enrollmentRedirectTo. When the route being guarded is already the enrolment target the guard admits the session, so guarding the enrolment route itself does not loop. Angular reads the target from the router state for canActivate and from the URL segments for canMatch.
  • Angular service: redeemRecoveryCode and completeAccountRecovery wrap the session actions, which refresh the session afterwards like Vue and Svelte.
  • READMEs list enrollmentPath, enrollmentRedirectTo and the new Angular actions.

Decisions

  • The guard redirect is a behaviour change for apps that relied on recovery sessions passing requireAuth, so the changeset is minor for @seamless-auth/vue, @seamless-auth/svelte and @seamless-auth/angular.
  • The guard sends only to one enrolment path. The bundled screens are not mounted behind requireAuth, so a recovery session can still reach register-authenticator from the passkey screen. An app that guards both enrolment screens can point enrollmentRedirectTo at whichever it wants.
  • Screens navigate with the existing toScreen helpers rather than a history replace, so no navigator interface changes (Svelte's AuthNavigator is implementable by applications).

Tests

  • Guards (each package): a recovery session is sent to enrolment on plain and role-gated routes, a guarded enrolment route admits it, and enrollmentRedirectTo / enrollmentPath are honoured (Angular covers canMatch too).
  • Login screens (each package): a recovery session goes straight to register-passkey, and so does a session that becomes one after refreshSession.
  • Angular service: both new wrappers refresh the session and set recoverySession.
  • The new redirect tests fail with the source changes reverted.

npm run typecheck, npm run lint, npm run format:check and npm test (Jest and the Svelte Vitest suite) pass.

A recovery session can do nothing but enroll a new factor, but only the
React login screen sent it there. The Vue, Svelte and Angular login
screens now go straight to register-passkey for a recovery session, and
their requireAuth guards redirect it to the new enrollmentPath config
option (default /register-passkey) before any role check. The
enrollmentRedirectTo guard option overrides it per route, and a guard on
the enrolment route itself admits the session instead of looping.

Angular's SeamlessAuth service gains redeemRecoveryCode and
completeAccountRecovery, which refresh the session afterwards as the
other frameworks do.

Closes #242
@Bccorb
Bccorb merged commit 1b355d5 into main Nov 21, 2026
5 checks passed
@Bccorb
Bccorb deleted the fix/recovery-session-routing branch November 21, 2026 05:04
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.

fix(vue,svelte,angular): route recovery sessions to factor enrolment

1 participant