Passkeys
A first factor with nothing to phish
A passkey is a key pair bound to your origin. The private half never leaves the user's device, there is no shared secret to breach, and it cannot be handed to a convincing lookalike site — the browser refuses to use it on the wrong origin. BillDog implements the standard WebAuthn ceremonies with server-issued challenges.
Registering one
The user must already be signed in — a passkey is added to an existing account, not used to create one.
const { credentialId } = await auth.registerPasskey('MacBook Pro');The label is for the user's own account screen, so they can tell two devices apart later. Registering runs the full ceremony: the server issues a challenge, the browser prompts for Face ID, Touch ID, Windows Hello or a security key, and the resulting public key is stored against the user.
It works on hosted sign-in too, where this code holds no token
httpOnly cookie the page’s JavaScript cannot read. The SDK sends both register calls with no refresh_token at all and the edge supplies the cookie, so the ceremony completes without the long-lived credential ever being in JavaScript — which is the whole point of running sign-in on your hostname. Signing in with a passkey carries no token on either leg and never will: the assertion is what establishes who the caller is, and whoever last used this browser is not necessarily them.Passkeys already on an account are not listed and cannot be removed through this SDK. The endpoint has four actions — the two register legs and the two sign-in legs — and none of them enumerates or deletes, so a list here would be invented rather than read.
Signing in
const result = await auth.signInWithPasskey();
// The same three-state answer every sign-in method returns: check this
// BEFORE reading result.session, which is null while a factor is owed.
if (result.mfaRequired) {
const done = await auth.attempt({
strategy: 'totp', // or 'backup_code'
code: authenticatorCode,
mfaToken: result.mfaToken, // no identifier — the token names the account
});
use(done.session);
} else {
use(result.session);
}One call, no identifier needed — the browser offers the user whichever passkeys it holds for your origin. This is a complete first factor, so on an account with no second factor enrolled the answer carries the session and mfaRequired is false. It returns the same AttemptResult as attempt rather than a bare session, so that a server which does answer a passkey with a challenge surfaces here instead of being applied as a null session.
It throws when the environment cannot support it
BillDogAuthError with code unsupported where the browser exposes none. Feature-detect before offering the button, so you are not showing an affordance that cannot work — WebAuthn also needs a secure context, which is why a passkey button that works in production does nothing over plain http in development.A ceremony the user walks away from is an ordinary outcome, not a failure worth showing. Where the browser answers a dismissed prompt with no credential the SDK raises
cancelled; where it rejects instead — most browsers raise a NotAllowedError DOMException, which is also what a timeout looks like — that error reaches you unwrapped. Handle both quietly.On native platforms
iOS and Android expose BillDogPasskeys alongside the auth module, and the React Native, Expo and Flutter bridges expose passkeysAvailable(), registerPasskey() and signInWithPasskey().
Android needs two dependencies you add yourself
compileOnly, on purpose: the auth module is pulled in by both suite aggregates, so declaring them normally would add both libraries to every app using any part of BillDog, including apps that never sign anyone in. Passkeys are opt-in, so their dependencies are too. Add them to your own build.gradle:implementation("androidx.credentials:credentials:1.2.2")
implementation("androidx.credentials:credentials-play-services-auth:1.2.2")passkeysAvailable() reports whether that happened — a typed answer naming the fix, rather than a crash when somebody taps "sign in".Practical advice
- Offer passkeys in addition to another method, not instead of one. A user who loses every device holding a passkey needs some other way in.
- Prompt to register after a successful sign-in, not during sign-up — people say no to a system prompt they did not expect.
- Label every passkey at registration. It is the only chance — nothing in the API reads the label back, so an unlabelled credential is one nobody can ever identify.
- A passkey is bound to your origin. Moving your sign-in page to a different domain invalidates every passkey registered on the old one.
Was this page helpful?
Or rate this page: