WebAuthn API
On this page
This feature requires at least a Licensed Community plan as of version 1.52.0.
The Retrieve a Passkey API doesn't require a license.
1.41.0
This page contains all of the APIs for managing WebAuthn passkeysA credential that replaces a password with a key pair stored on the user's device. Passkeys use the WebAuthn standard., sometimes referred to as credentials, and starting and completing WebAuthn ceremonies.
WebAuthn JavaScript API Binary Format#
The WebAuthn JavaScript API navigator.credentials.create() and navigator.credentials.get() expect to receive fields containing binary data on the options object as a JavaScript ArrayBuffer. The same functions return binary fields as ArrayBuffers. To prevent encoding issues on the FusionAuth API, these fields are passed over the network as base64url-encoded strings.
After you receive options from the FusionAuth API, convert select fields on the options JSON object from base64url-encoded strings to ArrayBuffers. Then pass the options object to the WebAuthn JavaScript API. Likewise, certain fields on WebAuthn JavaScript API responses must be converted from ArrayBuffers to base64url-encoded strings before calling FusionAuth's APIs to complete the ceremony.
Converting base64url-encoded String to ArrayBuffer#
The Start a WebAuthn Passkey Registration and Start a WebAuthn Passkey Assertion or Authentication responses contain an options JSON object. Convert base64url-encoded strings in options to ArrayBuffers before you pass options to the WebAuthn JavaScript API. The FusionAuth hosted pages will perform this conversion as necessary. If you need to perform this conversion yourself, you can use the following JavaScript function.
function base64URLToBuffer(base64URL) {
const base64 = base64URL.replace(/-/g, '+').replace(/_/g, '/');
const padLen = (4 - (base64.length % 4)) % 4;
return Uint8Array.from(atob(base64.padEnd(base64.length + padLen, '=')), c => c.charCodeAt(0));
}Fields that require this conversion are documented in the Start a WebAuthn Passkey Registration and Start a WebAuthn Passkey Assertion or Authentication response sections.
Converting ArrayBuffer to base64url-encoded String#
Responses from the WebAuthn JavaScript APIs contain ArrayBuffers. Convert the ArrayBuffers to base64url-encoded strings before you send the responses to FusionAuth's Complete a WebAuthn Passkey Registration, Complete a WebAuthn Passkey Authentication, or Complete a WebAuthn Passkey Assertion APIs. The FusionAuth hosted pages will perform this conversion as necessary. If you need to perform this conversion yourself, you can use the following JavaScript function.
function bufferToBase64URL(buffer) {
const bytes = new Uint8Array(buffer);
let string = '';
bytes.forEach(b => string += String.fromCharCode(b));
const base64 = btoa(string);
return base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
}Fields that require this conversion are documented in the Complete a WebAuthn Passkey Registration, Complete a WebAuthn Passkey Authentication, and Complete a WebAuthn Passkey Assertion request sections.
Retrieve a Passkey
API documentation for the FusionAuth Retrieve a Passkey API.
Delete a Passkey
API documentation for the FusionAuth Delete a Passkey API.
Import Passkeys
API documentation for the FusionAuth Import Passkeys API.
Start a WebAuthn Passkey Registration
API documentation for the FusionAuth Start a WebAuthn Passkey Registration API.
Complete a WebAuthn Passkey Registration
API documentation for the FusionAuth Complete a WebAuthn Passkey Registration API.
Start a WebAuthn Passkey Assertion or Authentication
API documentation for the FusionAuth Start a WebAuthn Passkey Assertion or Authentication API.
Complete a WebAuthn Passkey Authentication
API documentation for the FusionAuth Complete a WebAuthn Passkey Authentication API.
Complete a WebAuthn Passkey Assertion
API documentation for the FusionAuth Complete a WebAuthn Passkey Assertion API.
Related
API documentation for the FusionAuth Complete a WebAuthn Passkey Assertion API.
API documentation for the FusionAuth Complete a WebAuthn Passkey Authentication API.
API documentation for the FusionAuth Complete a WebAuthn Passkey Registration API.
API documentation for the FusionAuth Delete a Passkey API.