import { IUser } from '../interfaces/entities.interface'; import { NAuthConfig } from '../interfaces/config.interface'; import { TrustedDeviceService } from './trusted-device.service'; import { AdaptiveMFADecisionService } from './adaptive-mfa-decision.service'; import { ClientInfoService } from './client-info.service'; import { NAuthLogger } from '../utils/nauth-logger'; import { AuthFlowContext } from './auth-flow-state-machine.types'; /** * Authentication Flow Context Builder * * Pre-computes all derived values needed for state machine rule evaluation. * This optimization ensures values are calculated once at the beginning of the flow, * rather than repeatedly during rule evaluation. * * @example * ```typescript * const context = await contextBuilder.build({ * user, * config, * authMethod: 'password', * deviceToken: 'abc123' * }); * ``` */ export declare class AuthFlowContextBuilder { private readonly trustedDeviceService?; private readonly adaptiveMFADecisionService?; private readonly logger?; constructor(trustedDeviceService?: TrustedDeviceService | undefined, adaptiveMFADecisionService?: AdaptiveMFADecisionService | undefined, _clientInfoService?: ClientInfoService, // Reserved for future use (not stored as property) logger?: NAuthLogger | undefined); /** * Build authentication flow context with pre-computed values * * @param params - Context parameters * @param params.user - User attempting authentication * @param params.config - Authentication configuration * @param params.authMethod - Authentication method ('password' or 'social') * @param params.authProvider - Social auth provider name (e.g., 'google', 'apple') * @param params.deviceToken - Device token for trusted device check * @param params.skipMFAVerification - Skip MFA verification flag * @returns Authentication flow context with computed values * * @example * ```typescript * const context = await contextBuilder.build({ * user, * config, * authMethod: 'password', * deviceToken: 'abc123' * }); * ``` */ build(params: { user: IUser; config: NAuthConfig; authMethod?: 'password' | 'social'; authProvider?: string; deviceToken?: string; skipMFAVerification?: boolean; }): Promise; /** * Check if email verification is required * * @param user - User to check * @param config - Auth configuration * @param authMethod - Authentication method * @returns True if email verification is required */ private isEmailVerificationRequired; /** * Check if phone verification is required * * @param user - User to check * @param config - Auth configuration * @param authMethod - Authentication method * @returns True if phone verification is required */ private isPhoneVerificationRequired; /** * Check if phone collection is needed * * Phone collection is the step where we ask users to provide their phone number. * This should NOT be triggered if: * - User already has a verified phone (e.g., from prior signup or account linking) * - Phone verification is not required by config * * **Bug Fix (2025-12-08):** * Previously didn't check `isPhoneVerified`, causing social login users with * verified phones to be asked for phone collection again after account linking. * * @param user - User to check * @param config - Auth configuration * @param _authMethod - Authentication method (unused, kept for API consistency) * @returns True if phone collection is needed */ private isPhoneCollectionNeeded; /** * Check if user is exempt from MFA * * @param user - User to check * @returns True if user is exempt from MFA */ private checkMFAExempt; /** * Check if MFA setup is required * * @param user - User to check * @param config - Auth configuration * @param authMethod - Authentication method * @returns True if MFA setup is required */ private isMFASetupRequired; /** * Check if device is trusted * * @param user - User to check * @param deviceToken - Device token * @param config - Auth configuration * @returns True if device is trusted */ private checkDeviceTrust; /** * Calculate grace period status * * @param user - User to check * @param config - Auth configuration * @returns Grace period status */ private calculateGracePeriod; /** * Check if user is blocked * * @param user - User to check * @returns Block status */ private checkBlocked; /** * Check if MFA verification is required * * @param user - User to check * @param config - Auth configuration * @param authMethod - Authentication method * @param deviceToken - Device token * @param isDeviceTrusted - Whether device is trusted * @param skipMFAVerification - Skip MFA verification flag * @returns MFA verification requirement and risk data */ private checkMFAVerification; } //# sourceMappingURL=auth-flow-context-builder.service.d.ts.map