Skip to content
LogoLogo

WebAuthnCeremony.server

Creates a server-backed ceremony that delegates to a remote WebAuthn server handler. All challenge generation, verification, and credential storage happen server-side.

The client fetch()s four POST endpoints derived from the base url:

  • POST {url}/register/options — called by getRegistrationOptions.
  • POST {url}/register — called by verifyRegistration.
  • POST {url}/login/options — called by getAuthenticationOptions.
  • POST {url}/login — called by verifyAuthentication.

Usage

import { WebAuthnCeremony } from 'accounts'
 
const ceremony = WebAuthnCeremony.server({ url: 'https://example.com/webauthn' })

Parameters

url

  • Type: string
  • Required

Base URL of the WebAuthn handler (e.g. "https://example.com/webauthn").

Prefetching challenges

Each ceremony normally starts with a request for its options, and the server stores the challenge before it answers. Call prefetch ahead of time (e.g. when the sign-in screen loads) to fetch one login and one registration challenge in advance:

import { WebAuthnCeremony } from 'accounts'
 
const ceremony = WebAuthnCeremony.server({ url: 'https://example.com/webauthn' })
 
ceremony.prefetch?.()

The next getAuthenticationOptions or getRegistrationOptions then builds its options from a prefetched challenge, without a request (or waits for one still in flight), and the ceremony fetches the next challenge in the background. A registration challenge is issued without a name, so verifyRegistration sends the name the options were built with along with the credential. The server binds a random userId to it, so a registration that passes its own userId still requests its own options. The server sends its challenge TTL with each challenge, and a prefetched challenge is used until a minute (or a fifth of a shorter TTL) before it expires. A server that sends no TTL predates prefetching, so its challenges aren't prefetched.

Each prefetched challenge is one write to the server's challenge store, so call prefetch only where a sign-in is likely.