UNPKG

@passageidentity/passage-flex-js

Version:

Passkey Flex for Web - Add native passkey authentication to your own client-side JavaScript authentication flows with Passage by 1Password.

96 lines (90 loc) 3.46 kB
/** * Passage Authentication API * Passage\'s authentication API to enable passwordless authentication. * * The version of the OpenAPI document: 1 * Contact: support@passage.id * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ /** * selects the type of authentication that will be used in this WebAuthN flow request * @export * @enum {string} */ declare enum AuthenticatorAttachment_2 { Platform = "platform", CrossPlatform = "cross-platform", Any = "any" } declare interface IPasskeyAuthenticateOptions { transactionId?: string; isConditionalMediation?: boolean; } /** * The PassageFlex class used to interact with Passkey Flex APIs, including the Passkey class to register and authenticate with Passkeys. * To initialize a Passage Flex instance, invoke it with your Passage appId. * * @example * ``` * import PassageFlex from '@passageidentity/passage-flex-js'; * const passageFlex = new Passage(appId); * ``` */ export declare class PassageFlex { passkey: Passkey; /** * Creates a new instance of the PassageFlex class * @param appId The ID of the Passkey Flex application */ constructor(appId: string); } declare class Passkey { private registerApi; private authenticateApi; /** * Creates a new Passkey instance * @param baseUrl The base URL for Passkey Flex API requests */ constructor(appId: string); /** * Register a passkey via webauthn * @param {string?} transactionId The transactionId generated by Passage * @return {Promise<string>} A nonce that can be used to verify and exchange for an auth token */ register(transactionId: string, options?: PasskeyCreationOptions): Promise<string>; /** * Authenticate with a passkey via webauthn * @param {IPasskeyAuthenticateOptions?} options Optional Webauthn authentication options. Set isConditionalMediation to true for passkey autofill * @return {Promise<string>} A nonce that can be used to verify and exchange for an auth token */ authenticate(options?: IPasskeyAuthenticateOptions): Promise<string>; /** * Check if a passkey can be registered in the current browser * @return {Promise<string>} A promise that resolves to a boolean */ canRegisterPasskey(): Promise<boolean>; /** * Check if a passkey can be used to authenticate in the current browser * @return {Promise<string>} A promise that resolves to a boolean */ canAuthenticateWithPasskey(): Promise<boolean>; /** * Check if a passkey autofill is available the current browser * @return {Promise<string>} A promise that resolves to a boolean */ canUseConditionalMediation(): Promise<boolean>; /** * Retrieves the AbortController instance used for aborting webauthn ceremony requests * If the AbortController instance does not exist, it creates a new one and stores it in the global scope * @returns The AbortController instance */ private _getAbortController; } declare interface PasskeyCreationOptions { /** authenticatorAttachment controls what kind of passkey the browser prompts the user to create */ authenticatorAttachment?: AuthenticatorAttachment_2; } export { }