Skip to content
Get startedGetting started →

createPasskeyWithPrfOutput

Creates a discoverable, user-verified passkey with the WebAuthn PRF extension enabled and returns its PRF output. It runs one creation ceremony and shows one user-verification prompt; when the authenticator does not evaluate the PRF at create time, it runs getPasskeyPrfOutput with the same salt, which shows a second.

import { createPasskeyWithPrfOutput } from "@category-labs/mera";
const { credentialId, prfSalt, prfOutput } = await createPasskeyWithPrfOutput({
rp: { id: "account.example.com", name: "Example" },
user: { name: "account@example.com", displayName: "Example account" },
});

options is a CreatePasskeyWithPrfOutputOptions.

  • Type: PublicKeyCredentialRpEntity & { id: string }
  • Required, including rp.id

Relying party identity, passed to WebAuthn. rp.id lets the fallback ceremony target the same relying party.

  • Type: string
  • Required

User name displayed or stored by the authenticator.

  • Type: string
  • Required

Human-readable display name for the authenticator UI.

  • Type: Uint8Array
  • Optional; a fresh 32-byte random handle is generated per call when omitted

User handle stored with the discoverable credential. Must be 1 to 64 bytes when provided (WebAuthn’s user-handle limit).

  • Type: Uint8Array
  • Optional; defaults to mera’s fixed salt

32-byte PRF salt evaluated during creation or by the fallback assertion. An explicit value supports custom PRF namespaces.

  • Type: number
  • Optional; browser defaults apply when omitted

WebAuthn timeout in milliseconds, applied to each ceremony.

Promise<CreatePasskeyWithPrfOutputResult>. Credential metadata (credentialId, transports when reported) plus the 32-byte prfSalt that was evaluated and the 32-byte prfOutput.

  • PRF_UNAVAILABLE: the authenticator did not enable PRF, or did not return PRF output on the fallback ceremony.
  • INPUT_INVALID: an explicit prfSalt is not 32 bytes, or the provided user.id length is outside 1 to 64 bytes.
  • CRYPTO_UNAVAILABLE: the page is not in a secure context, or the runtime lacks Web Crypto.
  • PASSKEY_OPERATION_FAILED: WebAuthn is unavailable, cancelled, or returns an unexpected credential.

The credential is requested with fixed parameters: ES256 or RS256 key types, attestation "none" (no statement about the authenticator’s make is requested), a required resident key, and required user verification. Resident key is the WebAuthn term for a discoverable credential. The user-verification requirement is not configurable (Passkeys and the PRF extension explains the mechanism).

WebAuthn challenges are generated internally.

Any failure after the creation ceremony completes leaves the passkey on the authenticator: it appears in the authenticator’s passkey list, but the thrown error does not carry its metadata.