WebAuthn HTML TypeScript #passkeys #webauthn #autofill #ux

Passkeys Conditional UI & Password Manager Autofill Hygiene

Implement WebAuthn Conditional Mediation (autocomplete='username webauthn'), accessible labels, and >=16px mobile inputs without breaking 1Password or iCloud Keychain.

View /llms.txt View /llms-full.txt

Why This Matters

Broken <form> markup breaks password managers (1Password, Bitwarden, iCloud Keychain) and prevents Passkeys Conditional UI from appearing in the browser autofill sheet — causing higher bounce rates and credential-stuffing exposure.

Hardening Checklist for AI Agents

  1. Use real <form> with <input type="email"> and <input type="password"> — avoid <div>-only forms or type="text" password fields.
  2. Add autocomplete="username webauthn" on the primary email/username input so browsers trigger Passkey Conditional UI immediately on focus.
  3. Add autocomplete="current-password" on login password inputs and autocomplete="new-password" on signup/reset forms.
  4. Always pair inputs with explicit <label for="..."> (never rely on placeholder alone).
  5. Prevent mobile iOS zoom traps: set input font size >= 16px and never use user-scalable=no or maximum-scale=1 in <meta name="viewport">.
  6. Check PublicKeyCredential.isConditionalMediationAvailable() before starting a background navigator.credentials.get({ mediation: "conditional", ... }) call with an AbortController.

Reference Login Markup & Conditional UI Script

<meta name="viewport" content="width=device-width, initial-scale=1">

<form action="/login" method="post">
  <label for="email">Work email</label>
  <input
    id="email"
    name="email"
    type="email"
    autocomplete="username webauthn"
    required
    style="font-size: 1rem;"
  >

  <label for="password">Password</label>
  <input
    id="password"
    name="password"
    type="password"
    autocomplete="current-password"
    required
    style="font-size: 1rem;"
  >

  <button type="submit">Sign in</button>
</form>

<script>
async function initConditionalPasskey(publicKeyOptions) {
  if (
    window.PublicKeyCredential &&
    typeof PublicKeyCredential.isConditionalMediationAvailable === "function" &&
    (await PublicKeyCredential.isConditionalMediationAvailable())
  ) {
    const controller = new AbortController();
    const credential = await navigator.credentials.get({
      mediation: "conditional",
      signal: controller.signal,
      publicKey: publicKeyOptions,
    });
    // Submit assertion to /api/auth/passkey/verify
    return credential;
  }
}
</script>

Verification Steps

View raw SKILL.md markdown
## Why This Matters

Broken `<form>` markup breaks password managers (`1Password`, `Bitwarden`, `iCloud Keychain`) and prevents Passkeys Conditional UI from appearing in the browser autofill sheet — causing higher bounce rates and credential-stuffing exposure.

## Hardening Checklist for AI Agents

1. **Use real `<form>` with `<input type="email">` and `<input type="password">`** — avoid `<div>`-only forms or `type="text"` password fields.
2. **Add `autocomplete="username webauthn"`** on the primary email/username input so browsers trigger Passkey Conditional UI immediately on focus.
3. **Add `autocomplete="current-password"`** on login password inputs and `autocomplete="new-password"` on signup/reset forms.
4. **Always pair inputs with explicit `<label for="...">`** (never rely on `placeholder` alone).
5. **Prevent mobile iOS zoom traps:** set input font size `>= 16px` and never use `user-scalable=no` or `maximum-scale=1` in `<meta name="viewport">`.
6. **Check `PublicKeyCredential.isConditionalMediationAvailable()`** before starting a background `navigator.credentials.get({ mediation: "conditional", ... })` call with an `AbortController`.

## Reference Login Markup & Conditional UI Script

```html
<meta name="viewport" content="width=device-width, initial-scale=1">

<form action="/login" method="post">
  <label for="email">Work email</label>
  <input
    id="email"
    name="email"
    type="email"
    autocomplete="username webauthn"
    required
    style="font-size: 1rem;"
  >

  <label for="password">Password</label>
  <input
    id="password"
    name="password"
    type="password"
    autocomplete="current-password"
    required
    style="font-size: 1rem;"
  >

  <button type="submit">Sign in</button>
</form>

<script>
async function initConditionalPasskey(publicKeyOptions) {
  if (
    window.PublicKeyCredential &&
    typeof PublicKeyCredential.isConditionalMediationAvailable === "function" &&
    (await PublicKeyCredential.isConditionalMediationAvailable())
  ) {
    const controller = new AbortController();
    const credential = await navigator.credentials.get({
      mediation: "conditional",
      signal: controller.signal,
      publicKey: publicKeyOptions,
    });
    // Submit assertion to /api/auth/passkey/verify
    return credential;
  }
}
</script>
```

## Verification Steps

- Focus the email field in Chrome/Safari with a saved passkey and confirm the passkey prompt appears inside the autofill dropdown.
- Verify Lighthouse / LoginPage.org Stage 1 scan gives full Passkeys (`7/7`), Password Manager (`7/7`), and Mobile UX (`6/6`) scores.