Repository navigation
Description
Context
LoginScreen (packages/ui-react/src/components/connectivity/login-screen.tsx:71-111) asks /auth/methods which methods are available. When the server reports passkey: true, password: false, it sets passwordAvailable to false (line 84). That removes the password field, the only input with autoComplete="current-password webauthn" (packages/ui-react/src/components/connectivity/login-form.tsx:76-90). The effect then starts the conditional-UI ceremony anyway (lines 89-105).
loginWithPasskey (packages/ui-react/src/lib/passkeys.ts:35-48) first calls api.passkeyLoginOptions(). Only after that does @simplewebauthn/browser 13.x startAuthentication look for input[autocomplete$='webauthn']. Finding none, it throws Error('No <input> with "webauthn" as the only or last value in its autocomplete attribute was detected'). That error is not a user cancel, so line 103 logs console.warn("[passkeys] conditional UI failed:", …).
Every load of a passkey-only login screen therefore:
- spends one token of the login-options budget, 10 per IP per minute (
OPTIONS_RATE_LIMIT,packages/ui-server/src/middleware/passkeys.ts:77, consumed at line 322). Reloading a few times locks the explicit "Sign in with a passkey" button out with a 429. - leaves an unused authentication challenge in the capped pending store (
putChallenge,packages/ui-server/src/middleware/passkeys.ts:129-139, called at line 334). - logs a warning to the console.
Guide security/passkey-authentication: conditional mediation is for offering passkeys "natively when users focus on sign-in fields". With no field there is nothing to attach the suggestion to.
Scope
- Start the conditional-UI ceremony only when the login form renders an input whose
autocompleteincludeswebauthn. Today that input exists exactly whenmethods.passwordis true. Gate on that beforeapi.passkeyLoginOptions()is called. - Leave the explicit passkey button flow (
onPasskeyClick, lines 130-146) unchanged.
Out of scope
- Replacing
@simplewebauthn/browseror re-arming after a cancel. That is ui-react: passkey ceremonies use native WebAuthn JSON APIs with an owned abort signal instead of @simplewebauthn/browser #2556, which must keep this gate. - Adding an input to the passkey-only screen to host autofill.
- Changing the options rate limit, the challenge TTL or the store cap on the server.
Acceptance criteria
- With
/auth/methodsreturning{ password: false, passkey: true }, loading the login screen makes noPOST /api/auth/passkey/login-optionsrequest and logs no[passkeys]console warning. - With
{ password: true, passkey: true }, conditional UI still starts: exactly one login-options request on load, and the password field's autofill offers the passkey. - The "Sign in with a passkey" button still completes sign-in on a passkey-only deployment.
- A test with a stub API that counts
passkeyLoginOptionscalls fails on the tree before the change (count 1 on passkey-only) and passes after (count 0). - A real-Chrome runtime test (Playwright plus the CDP
WebAuthn.addVirtualAuthenticatorvirtual authenticator, followingpackages/ui-react/tests/auth-expiry-runtime.test.ts) proves the first three criteria against real ui-server routes. The PR records a mutation: remove the gate, watch the passkey-only case fail on the request-count assertion, restore.
Verification
bun run test packages/ui-react/tests/passkey-login-runtime.test.ts # new; BRAIN_REQUIRE_CHROME=1 in CI
bun run test
bun run typecheck
bun run lintContract impact
- This touches the integration contract, so it needs the
contractlabel, aCONTRACT:commit prefix, and the doc updated in the same commit. - This changes a published package's behaviour, so it needs a changeset.
None for the contract: no route, field or exported signature changes.
Activity
schlessera commentedon Nov 17, 2026
Claimed for implementation. Claim token:
claim-f25aa04e. Branch:fix/2555-passkey-conditional-gate.Collisions: closure reports only, no PR edits login-screen.tsx or passkeys.ts. #2556 (unclaimed) must keep this gate.
test(ui-react): prove the passkey autofill sign-in and inventory the …
fix(ui-react): start passkey autofill only beside a password field (#…
schlessera commentedon Nov 17, 2026
Delivered in #4183 (squash 2158875).
LoginScreennow starts conditional UI only when the methods report a password, and so only when thewebauthnautofill field renders. A passkey-only screen spends no login-options token, leaves no challenge and logs no warning, and its "Sign in with a passkey" button works as before. A render test counts the login-options calls. A real-Chrome runtime test with a CDP virtual authenticator (packages/ui-react/tests/passkey-login-runtime.test.ts) proves the passkey-only case and the button sign-in. It also proves that beside a password field, the field's autofill signs in with the passkey after one login-options request. The PR records the gate mutation failing on the request-count assertion. #2556 must keep this gate.