Documentation navigation
← Back to Jupiter Auth

WebAuthn

Register and authenticate WebAuthn credentials with the browser credential APIs.

Register a credential

The WebAuthn wrapper performs factor enrollment, browser credential creation, challenge handling, serialization, and server verification.

const { data, error } =  await client.auth.mfa.webauthn.register({    friendlyName: 'MacBook Touch ID',    webauthn: {      rpId: window.location.hostname,      rpOrigins: [window.location.origin]    }  })

The WebAuthn wrapper is marked experimental in the current Auth package.

Authenticate a credential

authenticate requests a browser credential for an existing WebAuthn factor and verifies it with Jupiter Auth.

const { data, error } =  await client.auth.mfa.webauthn.authenticate({    factorId,    webauthn: {      rpId: window.location.hostname,      rpOrigins: [window.location.origin]    }  })

Lower-level WebAuthn methods

Use enroll, challenge, and verify when the application needs to control each WebAuthn ceremony step directly. register combines enrollment, browser credential creation, challenge handling, and verification. authenticate combines the authentication challenge, browser credential request, and verification.

const enrollment =  await client.auth.mfa.webauthn.enroll({    friendlyName: 'Security key'  }) if (enrollment.error) {  throw enrollment.error} const challenge =  await client.auth.mfa.webauthn.challenge({    factorId: enrollment.data.id,    webauthn: {      rpId: window.location.hostname,      rpOrigins: [window.location.origin]    }  }) if (challenge.error) {  throw challenge.error} const result =  await client.auth.mfa.webauthn.verify(challenge.data)