import { type AuthenticationResponseJSON, type PublicKeyCredentialCreationOptionsJSON, type PublicKeyCredentialRequestOptionsJSON, type RegistrationResponseJSON } from "@simplewebauthn/server"; import { JsonApiService } from "../../../core/jsonapi/services/jsonapi.service"; import { PasskeyRepository } from "../repositories/passkey.repository"; import { PendingTwoFactorRepository } from "../repositories/pending-two-factor.repository"; export interface PasskeyRegistrationOptions { pendingId: string; options: PublicKeyCredentialCreationOptionsJSON; } export interface PasskeyAuthenticationOptions { pendingId: string; options: PublicKeyCredentialRequestOptionsJSON; } export interface PasskeyInfo { id: string; name: string; backedUp: boolean; lastUsedAt?: Date; createdAt: Date; } /** * Passkey Service * * Manages WebAuthn passkey registration and authentication for two-factor authentication. * Provides passkey enrollment, verification, and management capabilities. */ export declare class PasskeyService { private readonly jsonApiService; private readonly passkeyRepository; private readonly pendingTwoFactorRepository; private readonly challengeTtlSeconds; constructor(jsonApiService: JsonApiService, passkeyRepository: PasskeyRepository, pendingTwoFactorRepository: PendingTwoFactorRepository); /** * Get WebAuthn Relying Party configuration from environment. */ private getRpConfig; /** * Generate registration options for creating a new passkey. * * @param params.userId - The user's ID * @param params.userName - The user's email or username * @param params.userDisplayName - The user's display name * @returns JSON:API response with registration options */ generateRegistrationOptions(params: { userId: string; userName: string; userDisplayName: string; }): Promise; /** * Verify a passkey registration response and create the passkey. * * @param params.pendingId - The pending challenge ID from generateRegistrationOptions * @param params.name - A friendly name for this passkey * @param params.response - The WebAuthn credential response from the client * @returns JSON:API response with the created passkey */ verifyRegistration(params: { pendingId: string; name: string; response: RegistrationResponseJSON; }): Promise; /** * Generate authentication options for passkey sign-in. * * @param params.userId - The user's ID * @returns JSON:API response with authentication options */ generateAuthenticationOptions(params: { userId: string; }): Promise; /** * Verify a passkey authentication response. * * @param params.pendingId - The pending challenge ID from generateAuthenticationOptions * @param params.response - The WebAuthn assertion response from the client * @returns The passkey ID if verification succeeds */ verifyAuthentication(params: { pendingId: string; response: AuthenticationResponseJSON; }): Promise; /** * List all passkeys for a user. * * @param params.userId - The user's ID * @returns JSON:API response with list of passkeys */ listPasskeys(params: { userId: string; }): Promise; /** * Remove a passkey. * * @param params.passkeyId - The passkey ID to remove */ removePasskey(params: { passkeyId: string; }): Promise; /** * Rename a passkey. * * @param params.passkeyId - The passkey ID to rename * @param params.name - The new name for the passkey */ renamePasskey(params: { passkeyId: string; name: string; }): Promise; /** * Check if a user has any registered passkeys. * * @param params.userId - The user's ID * @returns true if the user has at least one passkey */ hasPasskeys(params: { userId: string; }): Promise; /** * Parse transports JSON string into array. */ private parseTransports; /** * Convert Uint8Array to base64url string. */ private uint8ArrayToBase64Url; /** * Convert base64url string to Uint8Array. * The type assertion ensures compatibility with @simplewebauthn's expected types. */ private base64UrlToUint8Array; } //# sourceMappingURL=passkey.service.d.ts.map