@auth0/auth0-acul-js - v0.1.0-beta.5
    Preparing search index...

    Class ResetPasswordMfaWebAuthnRoamingChallenge

    ResetPasswordMfaWebAuthnRoamingChallenge

    Hierarchy

    • BaseContext
      • ResetPasswordMfaWebAuthnRoamingChallenge

    Implements

    Index

    Constructors

    Properties

    Holds the specific screen data and properties for this screen,

    (for the WebAuthn challenge) and showRememberDevice.

    screenIdentifier: string = ScreenIds.RESET_PASSWORD_MFA_WEBAUTHN_ROAMING_CHALLENGE

    The unique identifier for this screen, used for internal SDK logic and telemetry.

    Methods

    • Reports a client-side WebAuthn API error (from navigator.credentials.get()) to Auth0. This method is intended to be called when useSecurityKey (or a direct call to navigator.credentials.get()) fails due to a standard WebAuthn API error (e.g., NotAllowedError if the user cancels, NotFoundError, SecurityError, timeout). It submits the error details with action: "showError::{errorDetailsJsonString}" and an empty response.

      Parameters

      Returns Promise<void>

      A promise that resolves when the error report is successfully submitted. Auth0 may re-render the page with specific error messages in this.transaction.errors or redirect.

      Throws an error if the form submission itself fails (e.g., network error, invalid state).

      // In your UI, after catching an error from `sdk.useSecurityKey()` or `navigator.credentials.get()`:
      if (webAuthnError instanceof DOMException) {
      await sdk.showError({
      error: { name: webAuthnError.name, message: webAuthnError.message },
      rememberDevice: userWantsToRemember // if applicable
      });
      }
    • Initiates the WebAuthn security key challenge. This method internally calls navigator.credentials.get() using the challenge options provided in this.screen.publicKey. If the user successfully authenticates with their security key, the resulting PublicKeyCredential is stringified and submitted to Auth0 with action: "default".

      Parameters

      • Optionaloptions: Classes.ResetPasswordMfaWebAuthnRoamingChallengeUseSecurityKeyOptions

        Optional parameters for the operation. This can include rememberDevice (if this.screen.showRememberDevice is true) and any other custom key-value pairs to be sent in the form submission. The response field (the WebAuthn credential) is handled internally by this method.

      Returns Promise<void>

      A promise that resolves when the verification attempt is submitted. A successful operation usually results in Auth0 redirecting the user.

      Throws an error if this.screen.publicKey is missing (indicating missing challenge options), if getPasskeyCredentials (which wraps navigator.credentials.get()) fails (e.g., user cancellation, no authenticator found, hardware error), or if the final form submission to Auth0 fails. It is crucial to catch errors from this method. WebAuthn API errors (like NotAllowedError) should be reported using showError.

      // In your UI component for the reset-password-mfa-webauthn-roaming-challenge screen:
      const sdk = new ResetPasswordMfaWebAuthnRoamingChallenge();

      async function handleSecurityKeyAuth() {
      try {
      const userWantsToRemember = document.getElementById('remember-device-checkbox')?.checked || false;
      await sdk.useSecurityKey({ rememberDevice: sdk.screen.showRememberDevice && userWantsToRemember });
      // On success, Auth0 typically handles redirection.
      } catch (err) {
      console.error("Security key authentication failed:", err);
      // If it's a WebAuthn API error, report it to Auth0
      if (err.name && err.message) { // Basic check for DOMException-like error
      try {
      await sdk.showError({ error: { name: err.name, message: err.message } });
      } catch (reportError) {
      console.error("Failed to report WebAuthn error:", reportError);
      }
      }
      // Update UI to inform the user, e.g., "Security key verification failed. Please try again."
      // Also check `sdk.transaction.errors` if the page might have reloaded with an error message from the server.
      }
      }