import { JsonApiService } from "../../../core/jsonapi/services/jsonapi.service"; import { TotpAuthenticatorRepository } from "../repositories/totp-authenticator.repository"; import { TotpEncryptionService } from "./totp-encryption.service"; export interface TotpSetupResponse { authenticatorId: string; secret: string; qrCodeUri: string; qrCodeDataUrl: string; } export interface TotpAuthenticatorInfo { id: string; name: string; verified: boolean; lastUsedAt?: Date; createdAt: Date; } /** * TOTP Service * * Manages TOTP (Time-based One-Time Password) authenticators for two-factor authentication. * Provides secret generation, QR code creation, code verification, and authenticator management. */ export declare class TotpService { private readonly jsonApiService; private readonly totpAuthenticatorRepository; private readonly totpEncryptionService; private readonly logger; private readonly issuer; private readonly algorithm; private readonly digits; private readonly period; constructor(jsonApiService: JsonApiService, totpAuthenticatorRepository: TotpAuthenticatorRepository, totpEncryptionService: TotpEncryptionService); /** * Generate a new TOTP secret and return setup information. * * @param params.userId - The user's ID * @param params.name - A friendly name for this authenticator (e.g., "Google Authenticator") * @param params.accountName - The account name to display in authenticator apps (typically email) * @returns JSON:API response with setup info (QR code, secret) */ generateSecret(params: { userId: string; name: string; accountName: string; }): Promise; /** * Generate QR code URI for an existing authenticator. * Only works for unverified authenticators. * * @param params.authenticatorId - The authenticator ID * @param params.accountName - The account name for the QR code * @returns QR code URI and data URL */ generateQRCodeUri(params: { authenticatorId: string; accountName: string; }): Promise<{ qrCodeUri: string; qrCodeDataUrl: string; }>; /** * Verify a TOTP code against an authenticator. * * @param params.authenticatorId - The authenticator ID * @param params.code - The 6-digit TOTP code * @returns true if the code is valid */ verifyCode(params: { authenticatorId: string; code: string; }): Promise; /** * Verify a TOTP code for any verified authenticator belonging to a user. * * @param params.userId - The user's ID * @param params.code - The 6-digit TOTP code * @returns The authenticator ID if verification succeeds, null otherwise */ verifyCodeForUser(params: { userId: string; code: string; }): Promise; /** * Add (verify) an authenticator by validating a TOTP code. * This marks the authenticator as verified and ready for use. * * @param params.authenticatorId - The authenticator ID from generateSecret * @param params.code - The 6-digit TOTP code from the authenticator app * @returns JSON:API response with verified authenticator, or null if verification failed */ addAuthenticator(params: { authenticatorId: string; code: string; }): Promise; /** * Remove an authenticator. * * @param params.authenticatorId - The authenticator ID to remove */ removeAuthenticator(params: { authenticatorId: string; }): Promise; /** * List all authenticators for a user. * * @param params.userId - The user's ID * @param params.verifiedOnly - If true, only return verified authenticators * @returns JSON:API response with list of authenticators */ listAuthenticators(params: { userId: string; verifiedOnly?: boolean; }): Promise; /** * Check if a user has any verified TOTP authenticators. * * @param params.userId - The user's ID * @returns true if the user has at least one verified authenticator */ hasVerifiedAuthenticator(params: { userId: string; }): Promise; /** * Delete an unverified authenticator (cleanup for abandoned setup). * * @param params.authenticatorId - The authenticator ID */ deleteUnverifiedAuthenticator(params: { authenticatorId: string; }): Promise; } //# sourceMappingURL=totp.service.d.ts.map