UNPKG

ndwallet-core

Version:

Core cryptographic library for NDWallet browser environments

63 lines (62 loc) 2.66 kB
import { PublicKeyCredentialCreationOptionsJSON, PublicKeyCredentialRequestOptionsJSON, RegistrationResponseJSON, AuthenticationResponseJSON } from "@simplewebauthn/types"; import { startRegistration as startWebAuthnRegistration, startAuthentication as startWebAuthnAuthentication } from '@simplewebauthn/browser'; /** * Interface for WebAuthn PRF extension input */ export interface PrfExtensionInput { eval: { first: Uint8Array; }; } declare module '@simplewebauthn/types' { interface AuthenticationExtensionsClientInputs { prf?: PrfExtensionInput; } interface ClientExtensionResults { prf?: { results?: { first?: Uint8Array; }; }; } interface AuthenticationExtensionsClientOutputs { prf?: { results?: { first?: Uint8Array; }; }; } } /** * Dynamically load browser dependencies */ export declare function loadBrowserDependencies(): Promise<{ startRegistration: typeof startWebAuthnRegistration; startAuthentication: typeof startWebAuthnAuthentication; }>; /** * Check if the WebAuthn PRF extension is supported by the browser * @returns Promise resolving to a boolean indicating if PRF is supported */ export declare function isPrfExtensionSupported(): Promise<boolean>; /** * Generate WebAuthn registration options with PRF extension * @param baseOptions - Base registration options from the server * @param salt - Salt for PRF extension (optional, will generate if not provided) * @returns Modified options with PRF extension */ export declare function addPrfExtensionToRegistrationOptions(baseOptions: PublicKeyCredentialCreationOptionsJSON, salt?: Uint8Array): PublicKeyCredentialCreationOptionsJSON; /** * Generate WebAuthn authentication options with PRF extension * @param baseOptions - Base authentication options from the server * @param salt - Salt for PRF extension (must be the same as used during registration) * @returns Modified options with PRF extension */ export declare function addPrfExtensionToAuthenticationOptions(baseOptions: PublicKeyCredentialRequestOptionsJSON, salt: Uint8Array): PublicKeyCredentialRequestOptionsJSON; /** * Derive a master key using the WebAuthn PRF extension * @param response - WebAuthn response from registration or authentication * @returns Promise resolving to a CryptoKey that can be used for key derivation * @throws {Error} If PRF extension is not supported or response is invalid */ export declare function deriveMasterKeyFromPrf(response: RegistrationResponseJSON | AuthenticationResponseJSON): Promise<CryptoKey>;