Skip to content

feat(webauthn): passkey autofill (conditional mediation) support#43

Merged
lakhansamani merged 1 commit into
mainfrom
feat/passkey-conditional-ui
Jul 12, 2026
Merged

feat(webauthn): passkey autofill (conditional mediation) support#43
lakhansamani merged 1 commit into
mainfrom
feat/passkey-conditional-ui

Conversation

@lakhansamani

Copy link
Copy Markdown
Contributor

Adds the SDK capability for passkey autofill (WebAuthn conditional mediation) so a login form can surface discoverable passkeys inline in the username field's autofill dropdown — the smoother alternative to the explicit "Sign in with a passkey" button.

API

  • isConditionalMediationAvailable(): Promise<boolean> — feature-detect.
  • loginWithPasskey(email?, opts?)opts now accepts { mediation, signal }, threaded into navigator.credentials.get(). Backward compatible.
  • loginWithPasskeyAutofill(): Promise<ApiResponse<AuthToken>> — starts a conditional-mediation ceremony with a managed AbortController; resolves only when the user picks a passkey (fire on mount, ignore abort errors).
  • cancelPasskeyAutofill(): void — abort a pending autofill (e.g. on unmount).

Coordination

The browser allows only one outstanding navigator.credentials.get(). A modal loginWithPasskey() (the explicit button) aborts any pending autofill first, so the two flows coexist without "a request is already pending" errors. Coordination lives in the SDK so UI callers don't have to manage it.

Tests

Added coverage for the guard path (autofill fails cleanly with no network call when conditional mediation is unavailable) and that cancelPasskeyAutofill is safe with nothing in flight. Full browser ceremony is exercised live, consistent with the existing webauthn tests. Build + DTS typecheck + eslint clean.

Follow-up

authorizer-react will consume this to add autocomplete="username webauthn" on the login email field and start autofill on mount — that PR depends on releasing this SDK version and bumping the dependency.

Adds the SDK capability for "passkey autofill" so a login form can offer
discoverable passkeys inline in the username field instead of only via the
explicit "Sign in with a passkey" button.

- isConditionalMediationAvailable(): feature-detect conditional mediation.
- loginWithPasskey(email, opts): accepts { mediation, signal } and threads
  them into navigator.credentials.get().
- loginWithPasskeyAutofill(): starts a conditional-mediation ceremony with a
  managed AbortController; resolves only when the user picks a passkey.
- cancelPasskeyAutofill(): aborts a pending autofill (e.g. on unmount).

A modal loginWithPasskey() aborts any pending autofill first, since the
browser allows only one outstanding credential request.
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