import { default as HiddenValueCallback } from '../fr-auth/callbacks/hidden-value-callback'; import { default as MetadataCallback } from '../fr-auth/callbacks/metadata-callback'; import { default as FRStep } from '../fr-auth/fr-step'; import { WebAuthnOutcome, WebAuthnOutcomeType, WebAuthnStepType } from './enums'; import { AttestationType, RelyingParty, WebAuthnAuthenticationMetadata, WebAuthnCallbacks, WebAuthnRegistrationMetadata } from './interfaces'; import { default as TextOutputCallback } from '../fr-auth/callbacks/text-output-callback'; type OutcomeWithName = Name extends infer P extends string ? `${ClientId}::${Attestation}::${PubKeyCred['id']}${P extends '' ? '' : `::${P}`}` : never; declare global { interface Window { PingWebAuthnAbortController: AbortController; } } /** * Utility for integrating a web browser's WebAuthn API. * * Example: * * ```js * // Determine if a step is a WebAuthn step * const stepType = FRWebAuthn.getWebAuthnStepType(step); * if (stepType === WebAuthnStepType.Registration) { * // Register a new device * await FRWebAuthn.register(step); * } else if (stepType === WebAuthnStepType.Authentication) { * // Authenticate with a registered device * await FRWebAuthn.authenticate(step); * } * ``` * * Conditional mediation (Autofill) Support: * * ```js * // Check if browser supports conditional mediation * const supportsConditionalUI = await FRWebAuthn.isConditionalUISupported(); * * if (supportsConditionalUI) { * // The authenticate() method automatically handles conditional mediation * // when the server indicates support via conditionalWebAuthn: true * // in the metadata. No additional code changes needed. * await FRWebAuthn.authenticate(step); * * // For conditional mediation to work in the browser, add autocomplete="webauthn" * // to your username input field: * // * } * ``` */ declare abstract class FRWebAuthn { /** * Determines if the given step is a WebAuthn step. * * @param step The step to evaluate * @return A WebAuthnStepType value */ static getWebAuthnStepType(step: FRStep): WebAuthnStepType; /** * Checks if the browser supports WebAuthn. * * @return boolean indicating if WebAuthn is available */ static isWebAuthnSupported(): boolean; /** * Checks if the browser supports conditional mediation (autofill) for WebAuthn. * * @return Promise indicating if conditional mediation is available */ static isConditionalMediationSupported(): Promise; /** * Populates the step with the necessary authentication outcome. * Automatically handles conditional mediation if indicated by the server metadata. * * @param step The step that contains WebAuthn authentication data * @param optionsTransformer Augments the derived options with custom behaviour * @return The populated step */ static authenticate(step: FRStep, optionsTransformer?: (options: CredentialRequestOptions) => CredentialRequestOptions): Promise; /** * Populates the step with the necessary registration outcome. * * @param step The step that contains WebAuthn registration data * @return The populated step */ static register(step: FRStep, deviceName?: T): Promise; /** * Returns an object containing the two WebAuthn callbacks. * * @param step The step that contains WebAuthn callbacks * @return The WebAuthn callbacks */ static getCallbacks(step: FRStep): WebAuthnCallbacks; /** * Returns the WebAuthn metadata callback containing data to pass to the browser * Web Authentication API. * * @param step The step that contains WebAuthn callbacks * @return The metadata callback */ static getMetadataCallback(step: FRStep): MetadataCallback | undefined; /** * Returns the WebAuthn hidden value callback where the outcome should be populated. * * @param step The step that contains WebAuthn callbacks * @return The hidden value callback */ static getOutcomeCallback(step: FRStep): HiddenValueCallback | undefined; /** * Returns the WebAuthn metadata callback containing data to pass to the browser * Web Authentication API. * * @param step The step that contains WebAuthn callbacks * @return The metadata callback */ static getTextOutputCallback(step: FRStep): TextOutputCallback | undefined; /** * Retrieves the credential from the browser Web Authentication API. * * @param options The options associated with the request * @return The credential */ static getAuthenticationCredential(options: CredentialRequestOptions): Promise; /** * Converts an authentication credential into the outcome expected by OpenAM. * * @param credential The credential to convert * @return The outcome string */ static getAuthenticationOutcome(credential: PublicKeyCredential | null): OutcomeWithName | OutcomeWithName; /** * Retrieves the credential from the browser Web Authentication API. * * @param options The public key options associated with the request * @return The credential */ static getRegistrationCredential(options: PublicKeyCredentialCreationOptions): Promise; /** * Converts a registration credential into the outcome expected by OpenAM. * * @param credential The credential to convert * @return The outcome string */ static getRegistrationOutcome(credential: PublicKeyCredential | null): OutcomeWithName; /** * Converts authentication tree metadata into options required by the browser * Web Authentication API. * * @param metadata The metadata provided in the authentication tree MetadataCallback * @return The Web Authentication API request options */ static createAuthenticationPublicKey(metadata: WebAuthnAuthenticationMetadata): PublicKeyCredentialRequestOptions; /** * Converts authentication tree metadata into options required by the browser * Web Authentication API. * * @param metadata The metadata provided in the authentication tree MetadataCallback * @return The Web Authentication API request options */ static createRegistrationPublicKey(metadata: WebAuthnRegistrationMetadata): PublicKeyCredentialCreationOptions; private static createAbortController; private static extractMetadata; } export default FRWebAuthn; export type { RelyingParty, WebAuthnAuthenticationMetadata, WebAuthnCallbacks, WebAuthnRegistrationMetadata, }; export { WebAuthnOutcome, WebAuthnOutcomeType, WebAuthnStepType }; //# sourceMappingURL=index.d.ts.map