@auth0/auth0-spa-js
Version:
Auth0 SDK for Single Page Applications using Authorization Code Grant Flow with PKCE
59 lines (58 loc) • 2.66 kB
TypeScript
import type { Auth0Client } from '../Auth0Client';
import type { TokenEndpointResponse } from '../global';
import type { PasskeySignupOptions, PasskeyLoginOptions } from './types';
import type { PasskeyClient } from '@auth0/auth0-auth-js';
/**
* Client for Auth0 Passkey operations.
*
* Provides 2 public methods:
* - `signup` — Register a new user with a passkey (full flow: challenge → WebAuthn → token exchange)
* - `login` — Sign in with a passkey (full flow: challenge → WebAuthn → token exchange)
*
* @example
* ```typescript
* // Signup — single call handles everything
* const tokens = await auth0.passkey.signup({ email: 'user@example.com' });
*
* // Login — single call handles everything
* const tokens = await auth0.passkey.login();
* ```
*/
export declare class PasskeyApiClient {
#private;
/**
* @internal
* Do not instantiate directly. Use Auth0Client.passkey instead.
*/
constructor(passkeyClient: PasskeyClient, auth0Client: Auth0Client);
/**
* Register a new user with a passkey.
*
* Handles the full flow: requests a signup challenge, triggers the browser
* WebAuthn credential creation ceremony, serializes the result, and exchanges
* it for tokens.
*
* @param options - Passkey signup options (user identifier, optional scope/audience)
* @returns A promise that resolves to the token endpoint response containing access/ID tokens
* @throws {PasskeyError} If WebAuthn is not supported in the browser
* @throws {PasskeyRegisterError} If the challenge request fails
* @throws {GenericError} If the token exchange fails
* @throws {PasskeyError} If the user cancels the WebAuthn prompt
*/
signup(options: PasskeySignupOptions): Promise<TokenEndpointResponse>;
/**
* Sign in with an existing passkey.
*
* Handles the full flow: requests a login challenge, triggers the browser
* WebAuthn assertion ceremony, serializes the result, and exchanges it
* for tokens.
*
* @param options - Optional passkey login options (optional scope/audience/realm/organization)
* @returns A promise that resolves to the token endpoint response containing access/ID tokens
* @throws {PasskeyError} If WebAuthn is not supported in the browser
* @throws {PasskeyChallengeError} If the challenge request fails
* @throws {GenericError} If the token exchange fails
* @throws {PasskeyError} If the user cancels the WebAuthn prompt
*/
login(options?: PasskeyLoginOptions): Promise<TokenEndpointResponse>;
}