Skip to content

Passkey registration

The registration section of the quickstart guide covers the basics, so we’ll focus on some more advanced aspects of passkey registration here.

Dont assume the device support passkeys, test for passkey support.

frontend/register.ts
import { isPasskeySupport } from "@passlock/client";
if (!isPasskeySupport()) {
throw new Error("Bad news...")
}

Enforce local user verification by passing the userVerification option.

frontend/register.ts
// discouraged, preferred (default) or required
const userVerification = "required" as const;
const result = await registerPasskey({ tenancyId, userVerification });

Use the excludeCredentials property to prevent the user registering duplicate passkeys.

frontend/register.ts
import { registerPasskey } from '@passlock/client';
// from your backend database
const excludeCredentials = [existingPasskeyId];
const result = await registerPasskey({ excludeCredentials, ... });

Attestation is an advanced concept which essentially allows you to obtain information about the authenticator (device) generating the passkey. If you want to restrict users to a list of approved platforms, attestation can be used for this.