feat(webauthn): passkey autofill (conditional mediation) support#43
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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?)—optsnow accepts{ mediation, signal }, threaded intonavigator.credentials.get(). Backward compatible.loginWithPasskeyAutofill(): Promise<ApiResponse<AuthToken>>— starts a conditional-mediation ceremony with a managedAbortController; 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 modalloginWithPasskey()(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
cancelPasskeyAutofillis 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-reactwill consume this to addautocomplete="username webauthn"on the login email field and start autofill on mount — that PR depends on releasing this SDK version and bumping the dependency.