import { Repository } from 'typeorm'; import { BaseVerificationToken, BaseUser } from '../entities'; import { EmailProvider } from '../interfaces/provider.interface'; import { StorageAdapter } from '../interfaces/storage-adapter.interface'; import { NAuthConfig } from '../interfaces/config.interface'; import { ClientInfoService } from './client-info.service'; import { InternalAuthAuditService as AuthAuditService } from './auth-audit.service'; import { NAuthLogger } from '../utils/nauth-logger'; import { HookRegistryService } from './hook-registry.service'; import { SendVerificationEmailDTO, SendVerificationEmailResponseDTO, VerifyEmailWithCodeDTO, VerifyEmailWithTokenDTO, ResendVerificationEmailDTO, ResendVerificationEmailResponseDTO, VerifyEmailResponseDTO } from '../dto/verify-email.dto'; /** * Email Verification Service * * Handles email verification workflow: * - Generate verification codes * - Send verification emails * - Verify codes with token generation * - Resend with rate limiting * * Supports both code-based (6-digit OTP) and link-based verification. */ export declare class EmailVerificationService { private readonly verificationTokenRepo; private readonly userRepo; private readonly emailProvider; private readonly storageAdapter; private readonly config; private readonly clientInfoService; private readonly logger; private readonly hookRegistry; private readonly auditService?; constructor(verificationTokenRepo: Repository, userRepo: Repository, emailProvider: EmailProvider, storageAdapter: StorageAdapter, config: NAuthConfig, clientInfoService: ClientInfoService, logger: NAuthLogger, hookRegistry: HookRegistryService, auditService?: AuthAuditService | undefined); /** * Send verification email to user * Generates a new verification code and sends it via email * * @param dto - Request DTO containing sub, baseUrl, and skipAlreadyVerifiedCheck * @returns Response DTO with verification token ID */ sendVerificationEmail(dto: SendVerificationEmailDTO): Promise; /** * Send MFA email code (for Email MFA challenge during login) * Generates a new verification code and sends it via email using the mfaEmailCode template * * @param dto - Request DTO containing sub and skipAlreadyVerifiedCheck * @returns Response DTO with verification token ID */ sendMFAEmailCode(dto: SendVerificationEmailDTO): Promise; /** * Verify email with code (6-digit OTP) * Marks email as verified and activates user account * * @param dto - Request DTO containing email and code * @returns Response DTO with success message */ verifyEmailWithCode(dto: VerifyEmailWithCodeDTO): Promise; /** * Verify email with link token * Marks email as verified and activates user account * * @param dto - Request DTO containing token * @returns Response DTO with success message */ verifyEmailWithToken(dto: VerifyEmailWithTokenDTO): Promise; /** * Resend verification email * Supports both sub and email-based resend * * @param dto - Request DTO containing sub or email, and optional baseUrl * @returns Response DTO with verification token ID */ resendVerificationEmail(dto: ResendVerificationEmailDTO): Promise; private resendVerificationEmailBySub; private resendVerificationEmailByEmail; /** * Generate 6-digit verification code * @returns 6-digit numeric code */ private generateCode; /** * Generate secure random token * @returns Random token (32 bytes, hex encoded) */ private generateToken; /** * Hash token with SHA-256 * @param token - Plain token * @returns Hashed token */ private hashToken; /** * Build verification link with session token and code * Preserves existing query parameters and hash fragments * * @param baseUrl - Base URL provided by consumer app * @param sessionToken - Challenge session token (UUID) to include in link * @param code - Verification code to append * @returns Full verification link with session and code query params * * @example * ```typescript * const link = this.buildVerificationLink('https://app.com/verify', 'uuid-session-token', '456789'); * // https://app.com/verify?session=uuid-session-token&code=456789 * * const link2 = this.buildVerificationLink('https://app.com/verify?from=email#section', 'uuid-token', '456789'); * // https://app.com/verify?from=email&session=uuid-token&code=456789#section * ``` */ private buildVerificationLink; } //# sourceMappingURL=email-verification.service.d.ts.map