# passkey

Passkeys (WebAuthn), checked on the back end: a way in that is both
factors, and a second factor after a password. The page's half is built
into Mote (`passkey.create`, `passkey.get`). The whole of it is
[docs/second-factor.md](../../docs/second-factor.md#passkeys).

```text
use "pkg:passkey/passkey.mote"

button "Sign in with a passkey" press=passkeySignIn
button "Add a passkey" press=passkeyAdd
```

Settings, each optional: `PASSKEY_RP_ID`, `PASSKEY_ORIGINS`, `PASSKEY_NAME`.

What the program may say, each a fn with a default
([docs](../../docs/second-factor.md#what-a-program-may-say-of-its-passkeys)):

```text
fn passkeyMax(user: string): number = 2            // at most two an account (default: any number)
fn passkeyPrf(): bool = true                       // each is asked for a PRF output; the back end keeps the salts
fn passkeyAttestation(): string = "direct"         // asked for, checked and kept (default "none")
fn passkeyRoots(aaguid: string): string[] = []     // the roots trusted for that make and model: PEM, or folders
fn passkeyMay(about: PasskeyAbout): bool = true    // by AAGUID, UV, backup, attestation (about.attested), the account's others
```

Covered: registration and assertion (ES256, RS256, EdDSA), discoverable
sign-in, counters, the user handle, a second factor, taking one away; a
limit of passkeys an account; each passkey's AAGUID and whether it may be
backed up, kept and shown (`passkeyList()`, `passkeysOf(user)`); the PRF
extension (CTAP2 hmac-secret), its salt kept per passkey and its output
the page's alone, also with no back end at all
([docs](../../docs/second-factor.md#a-key-from-a-passkey-the-prf-extension)).
Attestation, asked for, is checked: each format's statement (`packed`,
`tpm`, `android-key`, `fido-u2f`, `apple`, `none`) and its chain up to the
roots the program names (`attest.mote`); the FIDO Metadata Service's list
is read by `metadata.mote` (`passkeyMdsLoad`, `passkeyMdsRoots`), checked up
to the root the program pins
([docs](../../docs/second-factor.md#attestation-checked)). Left out:
revocation of attestation certificates, conditional mediation (autofill), the hybrid flow's own settings (a phone
by QR is the browser's), large blobs and the other extensions. Tested with
`tests/all.sh real_passkey real_passkey_prf real_attest`, by a pretend
authenticator, by Chrome's virtual ones (with the PRF, and with
attestation), and against real authenticators' published attestations;
no phone or security key has been tried here.
