WebAuthnCeremony.deferred
Works like WebAuthnCeremony.server, but answers a sign-up as soon as the passkey is created. It sends POST {url}/register in the background and retries requests that fail in transit. The account address comes from the passkey's public key, so the app gets the same address either way.
A sign-in with a passkey the webAuthn adapter already knows works the same way. It answers once the passkey's signature checks out against the stored public key, and sends POST {url}/login in the background.
Usage
import { WebAuthnCeremony } from 'accounts'
const ceremony = WebAuthnCeremony.deferred({ url: 'https://example.com/webauthn' })Trade-offs
- The server session exists only once the server has stored the passkey, so a server request the app sends right after sign-up may not be signed in yet. The
webAuthnadapter makes sign-ins, sign-ups and sign-outs wait for it, for up to 10 seconds. A registration still running after that is cancelled, so it can't replace the session that follows. - If the server refuses the sign-up while the page is open, the adapter removes the account and keeps its public key on the device. A later sign-in with the passkey restores the account if the server did store it.
- If the server refuses a deferred sign-in (it doesn't know the passkey, the signature fails, or a hook denies it with 401 or 403), the ceremony ends the session in place, and the adapter removes the account (an
accountsChangedevent), as for a refused sign-up. - If a deferred sign-in's outcome stays unknown (every attempt failed in transit, a retry found its challenge consumed, or the server failed for another reason, such as an expired challenge), the ceremony ends the session in place, retrying the logout until it succeeds, and the adapter keeps the account. A later sign-in issues a new session.
- A refusal that arrives after the page closed goes unnoticed. Use this ceremony where the page outlives the request and every server request waits for it, such as an embedded iframe.
Parameters
credentials
- Type:
RequestCredentials - Default:
"same-origin"
Credential mode for ceremony requests.
url
- Type:
string - Required
Base URL of the WebAuthn handler (e.g. "https://example.com/webauthn").