/** * Hook Registry Service * * Central registry for managing and executing lifecycle hooks. * Provides a provider-based approach to extending authentication flows. * * @remarks * Hooks are registered after NAuth initialization when dependencies are ready. * This follows the same pattern as MFA and Social providers. * * @packageDocumentation */ import { IPreSignupHookProvider, IPostSignupHookProvider, SignupMetadata, PreSignupHookData, IOnboardingCompletedHook, OnboardingCompletedMetadata, IUserProfileUpdatedHook, UserProfileUpdatedMetadata, IPasswordChangedHook, PasswordChangedMetadata, IMFADeviceRemovedHook, MFADeviceRemovedMetadata, IAdaptiveMFARiskDetectedHook, AdaptiveMFARiskDetectedMetadata, IAccountStatusChangedHook, AccountStatusChangedMetadata, IEmailChangedHook, EmailChangedMetadata, IAccountLockedHook, AccountLockedMetadata, ISessionsRevokedHook, SessionsRevokedMetadata, IMFAFirstEnabledHook, MFAFirstEnabledMetadata, IMFAMethodAddedHook, MFAMethodAddedMetadata } from '../interfaces/hooks.interface'; import { IUser } from '../interfaces/entities.interface'; import { LoggerProvider } from '../interfaces/logger.interface'; /** * Hook Registry Service * * Manages registration and execution of lifecycle hooks for authentication flows. */ export declare class HookRegistryService { private readonly logger?; private readonly preSignupHooks; private readonly postSignupHooks; private readonly onboardingCompletedHooks; private readonly userProfileUpdatedHooks; private readonly passwordChangedHooks; private readonly mfaDeviceRemovedHooks; private readonly adaptiveMFARiskDetectedHooks; private readonly accountStatusChangedHooks; private readonly emailChangedHooks; private readonly accountLockedHooks; private readonly sessionsRevokedHooks; private readonly mfaFirstEnabledHooks; private readonly mfaMethodAddedHooks; constructor(logger?: LoggerProvider | undefined); /** * Register a pre-signup hook provider * * Hooks are executed in registration order. * First hook to throw PRESIGNUP_FAILED will block signup. * * @param provider - Pre-signup hook provider instance */ registerPreSignup(provider: IPreSignupHookProvider): void; /** * Register a post-signup hook provider * * Hooks are executed in registration order. * Hook errors are logged but do not block signup (non-blocking). * * @param provider - Post-signup hook provider instance */ registerPostSignup(provider: IPostSignupHookProvider): void; /** * Register an onboarding completed hook * * Hooks are executed in registration order. * Hook errors are logged but do not block user flows (non-blocking). * * @param provider - Onboarding completed hook instance */ registerOnboardingCompleted(provider: IOnboardingCompletedHook): void; /** * Register a user profile updated hook * * Hooks are executed in registration order. * Hook errors are logged but do not block profile updates (non-blocking). * * @param provider - User profile updated hook instance */ registerUserProfileUpdated(provider: IUserProfileUpdatedHook): void; /** * Register a password changed hook * * Hooks are executed in registration order. * Hook errors are logged but do not block password changes (non-blocking). * * @param provider - Password changed hook instance */ registerPasswordChanged(provider: IPasswordChangedHook): void; /** * Register an MFA device removed hook * * Hooks are executed in registration order. * Hook errors are logged but do not block device removal (non-blocking). * * @param provider - MFA device removed hook instance */ registerMFADeviceRemoved(provider: IMFADeviceRemovedHook): void; /** * Register an adaptive MFA risk detected hook * * Hooks are executed in registration order. * Hook errors are logged but do not block authentication (non-blocking). * * @param provider - Adaptive MFA risk detected hook instance */ registerAdaptiveMFARiskDetected(provider: IAdaptiveMFARiskDetectedHook): void; /** * Register an account status changed hook * * Hooks are executed in registration order. * Hook errors are logged but do not block status changes (non-blocking). * * @param provider - Account status changed hook instance */ registerAccountStatusChanged(provider: IAccountStatusChangedHook): void; /** * Register an email changed hook * * Hooks are executed in registration order. * Hook errors are logged but do not block email changes (non-blocking). * * @param provider - Email changed hook instance */ registerEmailChanged(provider: IEmailChangedHook): void; /** * Register an account locked hook * * Hooks are executed in registration order. * Hook errors are logged but do not block lockout (non-blocking). * * @param provider - Account locked hook instance */ registerAccountLocked(provider: IAccountLockedHook): void; /** * Register a sessions revoked hook * * Hooks are executed in registration order. * Hook errors are logged but do not block session revocation (non-blocking). * * @param provider - Sessions revoked hook instance */ registerSessionsRevoked(provider: ISessionsRevokedHook): void; /** * Register an MFA first enabled hook * * Hooks are executed in registration order. * Hook errors are logged but do not block MFA enrollment (non-blocking). * * @param provider - MFA first enabled hook instance */ registerMFAFirstEnabled(provider: IMFAFirstEnabledHook): void; /** * Register an MFA method added hook * * Hooks are executed in registration order. * Hook errors are logged but do not block MFA enrollment (non-blocking). * * @param provider - MFA method added hook instance */ registerMFAMethodAdded(provider: IMFAMethodAddedHook): void; /** * Execute all registered pre-signup hooks * * Hooks are executed sequentially in registration order. * First hook to throw PRESIGNUP_FAILED will stop execution and block signup. * * @param data - SignupDTO for password signup, OAuthUserProfile for social signup * @param signupType - Type of signup ('password' or 'social') * @param provider - Social provider name (only for social signups, e.g., 'google', 'apple', 'facebook') * @param adminSignup - true for admin signups, false for regular signups * @throws {NAuthException} with PRESIGNUP_FAILED if any hook blocks signup * * @internal * @remarks This method is called internally by AuthService and BaseSocialAuthProviderService */ executePreSignup(data: PreSignupHookData, signupType: 'password' | 'social', provider?: string, adminSignup?: boolean): Promise; /** * Execute all registered post-signup hooks * * Hooks are executed sequentially in registration order. * Hook errors are logged but do not stop execution (non-blocking). * * @param user - Created user entity (IUser interface) * @param metadata - Signup metadata providing context about the signup event * * @internal * @remarks This method is called internally by AuthService and BaseSocialAuthProviderService */ executePostSignup(user: IUser, metadata?: SignupMetadata): Promise; /** * Execute all registered onboarding completed hooks * * Hooks are executed sequentially in registration order. * Hook errors are logged but do not stop execution (non-blocking). * * @param user - User entity (IUser interface) * @param metadata - Completion metadata (verification method, source, timestamp) * * @internal * @remarks This method is called internally by AuthService, EmailVerificationService, and PhoneVerificationService */ executeOnboardingCompleted(user: IUser, metadata: OnboardingCompletedMetadata): Promise; /** * Execute all registered user profile updated hooks * * Hooks are executed sequentially in registration order. * Hook errors are logged but do not stop execution (non-blocking). * * @param metadata - Profile update context with user, changed fields, and update source * * @internal * @remarks This method is called internally by AuthService, EmailVerificationService, and PhoneVerificationService */ executeUserProfileUpdated(metadata: UserProfileUpdatedMetadata): Promise; /** * Execute all registered password changed hooks * * Hooks are executed sequentially in registration order. * Hook errors are logged but do not stop execution (non-blocking). * * @param metadata - Password change context with user and change details * * @internal * @remarks This method is called internally by AuthServiceInternalHelpers */ executePasswordChanged(metadata: PasswordChangedMetadata): Promise; /** * Execute all registered MFA device removed hooks * * Hooks are executed sequentially in registration order. * Hook errors are logged but do not stop execution (non-blocking). * * @param metadata - Device removal context with user and device details * * @internal * @remarks This method is called internally by UserService and MFAService */ executeMFADeviceRemoved(metadata: MFADeviceRemovedMetadata): Promise; /** * Execute all registered adaptive MFA risk detected hooks * * Hooks are executed sequentially in registration order. * Hook errors are logged but do not stop execution (non-blocking). * * @param metadata - Risk evaluation context with user and risk details * * @internal * @remarks This method is called internally by AdaptiveMFADecisionService */ executeAdaptiveMFARiskDetected(metadata: AdaptiveMFARiskDetectedMetadata): Promise; /** * Execute all registered account status changed hooks * * Hooks are executed sequentially in registration order. * Hook errors are logged but do not stop execution (non-blocking). * * @param metadata - Status change context with user and change details * * @internal * @remarks This method is called internally by UserService */ executeAccountStatusChanged(metadata: AccountStatusChangedMetadata): Promise; /** * Execute all registered email changed hooks * * Hooks are executed sequentially in registration order. * Hook errors are logged but do not stop execution (non-blocking). * * @param metadata - Email change context with old and new addresses * * @internal * @remarks This method is called internally by UserService */ executeEmailChanged(metadata: EmailChangedMetadata): Promise; /** * Execute all registered account locked hooks * * Hooks are executed sequentially in registration order. * Hook errors are logged but do not stop execution (non-blocking). * * @param metadata - Lockout context with user and lock details * * @internal * @remarks This method is called internally by AuthServiceInternalHelpers */ executeAccountLocked(metadata: AccountLockedMetadata): Promise; /** * Execute all registered sessions revoked hooks * * Hooks are executed sequentially in registration order. * Hook errors are logged but do not stop execution (non-blocking). * * @param metadata - Revocation context with user and session details * * @internal * @remarks This method is called internally by SessionService */ executeSessionsRevoked(metadata: SessionsRevokedMetadata): Promise; /** * Execute all registered MFA first enabled hooks * * Hooks are executed sequentially in registration order. * Hook errors are logged but do not stop execution (non-blocking). * * @param metadata - MFA enrollment context with user and device details * * @internal * @remarks This method is called internally by BaseMFAProviderService */ executeMFAFirstEnabled(metadata: MFAFirstEnabledMetadata): Promise; /** * Execute all registered MFA method added hooks * * Hooks are executed sequentially in registration order. * Hook errors are logged but do not stop execution (non-blocking). * * @param metadata - MFA method addition context * * @internal * @remarks This method is called internally by BaseMFAProviderService */ executeMFAMethodAdded(metadata: MFAMethodAddedMetadata): Promise; } //# sourceMappingURL=hook-registry.service.d.ts.map