Identity
Represents a stored biometric identity. This object is returned byenroll() and getIdentity().
Fields
Hex-encoded 256-bit (64 character) cryptographic public key.This key is deterministically derived from the biometric credential and serves as the user’s identity. It can be used for:
- Generating authentication tokens
- Encrypting/decrypting user data
- Verifying identity across sessions
Hex-encoded WebAuthn credential ID (rawId).This unique identifier represents the specific biometric credential created during enrollment. It is required for authentication and is used in the WebAuthn
allowCredentials parameter.Length varies by authenticator but typically 32-64 bytes (64-128 hex characters).16-character device fingerprint.A deterministic identifier derived from browser and system characteristics:
- User agent string
- Language preference
- Screen dimensions
- Timezone
Unix timestamp in milliseconds when enrollment occurred.Example:
1709856234567 represents March 7, 2024 at 10:43:54.567 PM UTCKey derivation method used during enrollment.
'prf'(Preferred): Uses the WebAuthn PRF (Pseudo-Random Function) extension. Provides stronger security guarantees and is the modern standard.'rawid'(Fallback): Uses HKDF key derivation from the credential’s rawId. Used when the platform authenticator doesn’t support PRF.
Example
AuthenticationResult
Returned by theauthenticate() method upon successful authentication.
Fields
Authentication verification status.Always
true when the method returns successfully. If authentication fails, the method throws an error instead of returning false.Hex-encoded public key re-derived from the biometric credential.This should match the
publicKey stored during enrollment. Use this key to:- Generate session tokens
- Verify the user’s identity
- Decrypt user-specific data
Key derivation method used during this authentication.Should match the
method field from the stored Identity object. Indicates whether PRF or rawId-HKDF was used to re-derive the public key.Example
Constructor Options
Configuration options for creating a newBioKeyClient instance.
Fields
Relying Party identifier (domain name).Must be a valid domain that matches or is a registrable suffix of the current page’s origin. Examples:
"example.com"- root domain"auth.example.com"- subdomain"localhost"- local development
Human-readable application name.Displayed to users during biometric prompts. Should clearly identify your application. Examples:
"My Application""Acme Corp Portal""SecureAuth"
Optional backend API base URL.When provided, enables server-backed authentication with these endpoints:
POST {serverUrl}/enroll- Register credentialsGET {serverUrl}/challenge- Fetch authentication challengesPOST {serverUrl}/verify- Verify authentication results
null for client-only authentication without a backend.Example
Error Types
BioKeyClient methods throw standard JavaScriptError objects with descriptive messages.
Common Error Messages
Thrown by:
authenticate()Cause: Called authenticate() before enroll(), or identity was cleared.Solution: Check getIdentity() before authenticating, or prompt user to enroll.Thrown by:
authenticate()Cause: Re-derived PRF key doesn’t match stored public key. May indicate:- Tampering with stored identity
- Corrupted localStorage data
- Different biometric used
Thrown by:
authenticate()Cause: Re-derived rawId-HKDF key doesn’t match stored public key (V1 fallback method).Solution: Same as PRF key mismatch - clear and re-enroll.Thrown by:
authenticate() via _serverVerify()Cause: Backend server returned verified: false. Reasons may include:- Expired challenge
- User not registered on server
- Invalid signature
Thrown by:
authenticate() via _serverVerify()Cause: Public key returned by server doesn’t match client’s expected key.Solution: Indicates desynchronization between client and server. Re-enroll to sync.WebAuthn Errors
The browser may also throw WebAuthn-specific errors:NotAllowedError: User cancelled the biometric promptNotSupportedError: WebAuthn not supported by browserSecurityError: Operation not allowed (wrong domain, insecure context)InvalidStateError: Credential already exists (during enrollment)