@bymax-one/nest-auth 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/server/index.cjs +680 -331
- package/dist/server/index.d.cts +93 -4
- package/dist/server/index.d.ts +93 -4
- package/dist/server/index.mjs +680 -332
- package/package.json +1 -1
package/dist/server/index.d.cts
CHANGED
|
@@ -1959,6 +1959,19 @@ interface IAuthHooks {
|
|
|
1959
1959
|
* @param context - Request metadata (IP, user agent, sanitized headers).
|
|
1960
1960
|
*/
|
|
1961
1961
|
afterMfaDisabled?(user: SafeAuthUser, context: HookContext): Promise<void> | void;
|
|
1962
|
+
/**
|
|
1963
|
+
* Called after MFA recovery codes have been successfully regenerated.
|
|
1964
|
+
*
|
|
1965
|
+
* Use this hook to send a security alert reminding the user to store the new
|
|
1966
|
+
* codes safely, append an audit-log entry, or propagate the rotation to
|
|
1967
|
+
* downstream systems. The plain-text codes themselves are NOT passed to the
|
|
1968
|
+
* hook — they are only delivered to the requesting client.
|
|
1969
|
+
*
|
|
1970
|
+
* @param user - The user whose recovery codes were regenerated
|
|
1971
|
+
* (credential fields omitted).
|
|
1972
|
+
* @param context - Request metadata (IP, user agent, sanitized headers).
|
|
1973
|
+
*/
|
|
1974
|
+
afterMfaRecoveryCodesRegenerated?(user: SafeAuthUser, context: HookContext): Promise<void> | void;
|
|
1962
1975
|
/**
|
|
1963
1976
|
* Called when a successful login originates from a new device or location.
|
|
1964
1977
|
*
|
|
@@ -3572,6 +3585,34 @@ declare class MfaDisableDto {
|
|
|
3572
3585
|
code: string;
|
|
3573
3586
|
}
|
|
3574
3587
|
|
|
3588
|
+
/**
|
|
3589
|
+
* Data Transfer Object for the MFA recovery code regeneration endpoint.
|
|
3590
|
+
*
|
|
3591
|
+
* Submitted when an MFA-enabled user wants to rotate their recovery codes
|
|
3592
|
+
* (e.g. after suspecting they have been written down somewhere insecure, or
|
|
3593
|
+
* after consuming several entries from the original list). The endpoint
|
|
3594
|
+
* requires a valid TOTP code from the user's authenticator app to confirm
|
|
3595
|
+
* the action.
|
|
3596
|
+
*
|
|
3597
|
+
* @remarks
|
|
3598
|
+
* **TOTP codes only** — recovery codes are intentionally not accepted as
|
|
3599
|
+
* the proof factor here. If a user has lost access to their authenticator
|
|
3600
|
+
* and is relying on recovery codes, the safe path is to disable MFA and
|
|
3601
|
+
* re-enrol (which forces a fresh secret AND a fresh recovery code set),
|
|
3602
|
+
* not to silently rotate recovery codes using one of the codes the user
|
|
3603
|
+
* may already have leaked.
|
|
3604
|
+
*/
|
|
3605
|
+
declare class MfaRegenerateRecoveryCodesDto {
|
|
3606
|
+
/**
|
|
3607
|
+
* The 6-digit TOTP code generated by the user's authenticator app.
|
|
3608
|
+
*
|
|
3609
|
+
* Must be exactly 6 decimal digits. Recovery codes are not accepted by design.
|
|
3610
|
+
* Alphabetic characters, spaces, or other symbols are rejected before reaching
|
|
3611
|
+
* the service layer.
|
|
3612
|
+
*/
|
|
3613
|
+
code: string;
|
|
3614
|
+
}
|
|
3615
|
+
|
|
3575
3616
|
/**
|
|
3576
3617
|
* Data Transfer Object for the MFA TOTP verification step during setup.
|
|
3577
3618
|
*
|
|
@@ -4665,7 +4706,7 @@ declare class MfaService {
|
|
|
4665
4706
|
*/
|
|
4666
4707
|
private platformUserAsSafeUser;
|
|
4667
4708
|
/**
|
|
4668
|
-
* Initiates the MFA setup flow for a dashboard user.
|
|
4709
|
+
* Initiates the MFA setup flow for a dashboard user or platform administrator.
|
|
4669
4710
|
*
|
|
4670
4711
|
* Generates a TOTP secret and 8 recovery codes, stores them temporarily in
|
|
4671
4712
|
* Redis (10 minutes), and returns the data needed to display the QR code and
|
|
@@ -4676,10 +4717,15 @@ declare class MfaService {
|
|
|
4676
4717
|
* requests cannot generate different secrets.
|
|
4677
4718
|
*
|
|
4678
4719
|
* @param userId - Internal ID of the user enabling MFA.
|
|
4720
|
+
* @param context - Which repository to use: `'dashboard'` (default) or `'platform'`.
|
|
4679
4721
|
* @returns Setup result containing the secret, QR URI, and plain recovery codes.
|
|
4680
4722
|
* @throws `MFA_ALREADY_ENABLED` if MFA is already active on the account.
|
|
4723
|
+
* @throws `MFA_NOT_ENABLED` if `context === 'platform'` and the platform user
|
|
4724
|
+
* repository was not configured at module registration. The error code is
|
|
4725
|
+
* reused (rather than introducing a new one) because the consumer-facing
|
|
4726
|
+
* meaning is the same: "platform MFA cannot operate".
|
|
4681
4727
|
*/
|
|
4682
|
-
setup(userId: string): Promise<MfaSetupResult>;
|
|
4728
|
+
setup(userId: string, context?: 'dashboard' | 'platform'): Promise<MfaSetupResult>;
|
|
4683
4729
|
/**
|
|
4684
4730
|
* Verifies the first TOTP code from the user's authenticator app and permanently
|
|
4685
4731
|
* enables MFA on the account.
|
|
@@ -4693,10 +4739,13 @@ declare class MfaService {
|
|
|
4693
4739
|
* @param code - 6-digit TOTP code from the authenticator app.
|
|
4694
4740
|
* @param ip - Client IP address (forwarded to hooks).
|
|
4695
4741
|
* @param userAgent - User-Agent header (forwarded to hooks).
|
|
4742
|
+
* @param context - Which repository to use: `'dashboard'` (default) or `'platform'`.
|
|
4696
4743
|
* @throws `MFA_SETUP_REQUIRED` if no pending setup data is found in Redis.
|
|
4697
4744
|
* @throws `MFA_INVALID_CODE` if the submitted TOTP code is invalid.
|
|
4745
|
+
* @throws `MFA_NOT_ENABLED` if `context === 'platform'` and the platform user
|
|
4746
|
+
* repository was not configured at module registration.
|
|
4698
4747
|
*/
|
|
4699
|
-
verifyAndEnable(userId: string, code: string, ip: string, userAgent: string): Promise<void>;
|
|
4748
|
+
verifyAndEnable(userId: string, code: string, ip: string, userAgent: string, context?: 'dashboard' | 'platform'): Promise<void>;
|
|
4700
4749
|
/**
|
|
4701
4750
|
* Validates a TOTP or recovery code and exchanges the MFA temp token for full
|
|
4702
4751
|
* access tokens.
|
|
@@ -4740,6 +4789,46 @@ declare class MfaService {
|
|
|
4740
4789
|
* @throws `MFA_INVALID_CODE` if the submitted TOTP code is incorrect.
|
|
4741
4790
|
*/
|
|
4742
4791
|
disable(userId: string, code: string, ip: string, userAgent: string, context?: 'dashboard' | 'platform'): Promise<void>;
|
|
4792
|
+
/**
|
|
4793
|
+
* Regenerates the user's MFA recovery codes after verifying a current TOTP code.
|
|
4794
|
+
*
|
|
4795
|
+
* Mirrors {@link disable} in its security posture: only TOTP codes are accepted
|
|
4796
|
+
* (recovery codes cannot rotate themselves by design), the brute-force counter
|
|
4797
|
+
* is checked, and the regeneration is fired against the correct repository for
|
|
4798
|
+
* the supplied `context`. The TOTP secret on the user record is unchanged — only
|
|
4799
|
+
* the recovery code list is replaced.
|
|
4800
|
+
*
|
|
4801
|
+
* Returns the plain-text codes once. They are NOT persisted in plain form; only
|
|
4802
|
+
* scrypt hashes go into the database. The caller is responsible for showing the
|
|
4803
|
+
* codes to the user exactly once and warning them to save them safely.
|
|
4804
|
+
*
|
|
4805
|
+
* @remarks
|
|
4806
|
+
* **Sessions are intentionally NOT invalidated after this call.** Unlike
|
|
4807
|
+
* {@link verifyAndEnable} (which flips `mfaEnabled` from `false` to `true`) and
|
|
4808
|
+
* {@link disable} (which flips it back to `false`), this method does not change
|
|
4809
|
+
* the verification credential — the TOTP secret stays the same and existing
|
|
4810
|
+
* `mfaVerified: true` access tokens remain valid. Invalidating sessions here
|
|
4811
|
+
* would force a redundant re-auth on every recovery-code rotation, which is a
|
|
4812
|
+
* routine hygiene action a user might perform several times over the lifetime
|
|
4813
|
+
* of an account.
|
|
4814
|
+
*
|
|
4815
|
+
* @param userId - Internal ID of the user rotating recovery codes.
|
|
4816
|
+
* @param totpCode - 6-digit TOTP code from the authenticator app.
|
|
4817
|
+
* @param ip - Client IP address (forwarded to hooks).
|
|
4818
|
+
* @param userAgent - User-Agent header (forwarded to hooks).
|
|
4819
|
+
* @param context - Which repository to use: `'dashboard'` (default) or `'platform'`.
|
|
4820
|
+
* @throws `TOKEN_INVALID` if the user is not found or `mfaSecret` is missing
|
|
4821
|
+
* when `mfaEnabled` is `true` (database inconsistency).
|
|
4822
|
+
* @throws `MFA_NOT_ENABLED` if MFA is not currently active, or if
|
|
4823
|
+
* `context === 'platform'` and the platform user repository was not
|
|
4824
|
+
* configured at module registration.
|
|
4825
|
+
* @throws `ACCOUNT_LOCKED` if the brute-force threshold has been reached.
|
|
4826
|
+
* @throws `MFA_INVALID_CODE` if the submitted TOTP code is incorrect.
|
|
4827
|
+
* @returns The freshly generated plain-text recovery codes, one-time display.
|
|
4828
|
+
*/
|
|
4829
|
+
regenerateRecoveryCodes(userId: string, totpCode: string, ip: string, userAgent: string, context?: 'dashboard' | 'platform'): Promise<{
|
|
4830
|
+
recoveryCodes: string[];
|
|
4831
|
+
}>;
|
|
4743
4832
|
/**
|
|
4744
4833
|
* Verifies a TOTP code and enforces anti-replay within the validation window.
|
|
4745
4834
|
*
|
|
@@ -5142,4 +5231,4 @@ declare function sleep(ms: number): Promise<void>;
|
|
|
5142
5231
|
*/
|
|
5143
5232
|
declare function hasRole(userRole: string, requiredRole: string, hierarchy: Record<string, string[]>): boolean;
|
|
5144
5233
|
|
|
5145
|
-
export { AUTH_ERROR_CODES, AUTH_ERROR_MESSAGES, AUTH_THROTTLE_CONFIGS, AcceptInvitationDto, type SessionInfo as ActiveSessionInfo, type AuthErrorCode, AuthException, type AuthModuleAsyncOptions, type AuthPlatformUser, type AuthResult, AuthService, type AuthUser, type AuthenticatedRequest, BYMAX_AUTH_EMAIL_PROVIDER, BYMAX_AUTH_HOOKS, BYMAX_AUTH_OPTIONS, BYMAX_AUTH_PLATFORM_USER_REPOSITORY, BYMAX_AUTH_REDIS_CLIENT, BYMAX_AUTH_USER_REPOSITORY, type BeforeRegisterResult, BymaxAuthModule, type BymaxAuthModuleOptions, CreateInvitationDto, type CreateUserData, type CreateWithOAuthData, CurrentUser, type DashboardJwtPayload, ForgotPasswordDto, type HookContext, type IAuthHooks, type IEmailProvider, type IPlatformUserRepository, IS_PUBLIC_KEY, type IUserRepository, type InviteData, JwtAuthGuard, JwtPlatformGuard, LoginDto, MfaChallengeDto, type MfaChallengeResult, MfaDisableDto, MfaRequiredGuard, MfaService, type MfaSetupResult, type MfaTempPayload, MfaVerifyDto, NoOpAuthHooks, NoOpEmailProvider, type OAuthLoginResult, type OAuthProfile, type OAuthProviderPlugin, OAuthService, OptionalAuthGuard, OtpService, PLATFORM_ROLES_KEY, PasswordResetService, type PlatformAuthResult, type PlatformAuthenticatedRequest, type PlatformJwtPayload, PlatformLoginDto, PlatformRoles, PlatformRolesGuard, Public, ROLES_KEY, RegisterDto, ResendOtpDto, ResendVerificationDto, ResetPasswordDto, type ResolvedOptions, Roles, RolesGuard, type RotatedTokenResult, SKIP_MFA_KEY, type SafeAuthPlatformUser, type SafeAuthUser, SelfOrAdminGuard, type SessionInfo$1 as SessionInfo, SessionService, SkipMfa, type UpdateMfaData, type UpdatePlatformMfaData, UserStatusGuard, VerifyEmailDto, VerifyOtpDto, WsJwtGuard, decrypt, encrypt, generateSecureToken, hasRole, hmacSha256, sanitizeHeaders, sha256, sleep, timingSafeCompare };
|
|
5234
|
+
export { AUTH_ERROR_CODES, AUTH_ERROR_MESSAGES, AUTH_THROTTLE_CONFIGS, AcceptInvitationDto, type SessionInfo as ActiveSessionInfo, type AuthErrorCode, AuthException, type AuthModuleAsyncOptions, type AuthPlatformUser, type AuthResult, AuthService, type AuthUser, type AuthenticatedRequest, BYMAX_AUTH_EMAIL_PROVIDER, BYMAX_AUTH_HOOKS, BYMAX_AUTH_OPTIONS, BYMAX_AUTH_PLATFORM_USER_REPOSITORY, BYMAX_AUTH_REDIS_CLIENT, BYMAX_AUTH_USER_REPOSITORY, type BeforeRegisterResult, BymaxAuthModule, type BymaxAuthModuleOptions, CreateInvitationDto, type CreateUserData, type CreateWithOAuthData, CurrentUser, type DashboardJwtPayload, ForgotPasswordDto, type HookContext, type IAuthHooks, type IEmailProvider, type IPlatformUserRepository, IS_PUBLIC_KEY, type IUserRepository, type InviteData, JwtAuthGuard, JwtPlatformGuard, LoginDto, MfaChallengeDto, type MfaChallengeResult, MfaDisableDto, MfaRegenerateRecoveryCodesDto, MfaRequiredGuard, MfaService, type MfaSetupResult, type MfaTempPayload, MfaVerifyDto, NoOpAuthHooks, NoOpEmailProvider, type OAuthLoginResult, type OAuthProfile, type OAuthProviderPlugin, OAuthService, OptionalAuthGuard, OtpService, PLATFORM_ROLES_KEY, PasswordResetService, type PlatformAuthResult, type PlatformAuthenticatedRequest, type PlatformJwtPayload, PlatformLoginDto, PlatformRoles, PlatformRolesGuard, Public, ROLES_KEY, RegisterDto, ResendOtpDto, ResendVerificationDto, ResetPasswordDto, type ResolvedOptions, Roles, RolesGuard, type RotatedTokenResult, SKIP_MFA_KEY, type SafeAuthPlatformUser, type SafeAuthUser, SelfOrAdminGuard, type SessionInfo$1 as SessionInfo, SessionService, SkipMfa, type UpdateMfaData, type UpdatePlatformMfaData, UserStatusGuard, VerifyEmailDto, VerifyOtpDto, WsJwtGuard, decrypt, encrypt, generateSecureToken, hasRole, hmacSha256, sanitizeHeaders, sha256, sleep, timingSafeCompare };
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1959,6 +1959,19 @@ interface IAuthHooks {
|
|
|
1959
1959
|
* @param context - Request metadata (IP, user agent, sanitized headers).
|
|
1960
1960
|
*/
|
|
1961
1961
|
afterMfaDisabled?(user: SafeAuthUser, context: HookContext): Promise<void> | void;
|
|
1962
|
+
/**
|
|
1963
|
+
* Called after MFA recovery codes have been successfully regenerated.
|
|
1964
|
+
*
|
|
1965
|
+
* Use this hook to send a security alert reminding the user to store the new
|
|
1966
|
+
* codes safely, append an audit-log entry, or propagate the rotation to
|
|
1967
|
+
* downstream systems. The plain-text codes themselves are NOT passed to the
|
|
1968
|
+
* hook — they are only delivered to the requesting client.
|
|
1969
|
+
*
|
|
1970
|
+
* @param user - The user whose recovery codes were regenerated
|
|
1971
|
+
* (credential fields omitted).
|
|
1972
|
+
* @param context - Request metadata (IP, user agent, sanitized headers).
|
|
1973
|
+
*/
|
|
1974
|
+
afterMfaRecoveryCodesRegenerated?(user: SafeAuthUser, context: HookContext): Promise<void> | void;
|
|
1962
1975
|
/**
|
|
1963
1976
|
* Called when a successful login originates from a new device or location.
|
|
1964
1977
|
*
|
|
@@ -3572,6 +3585,34 @@ declare class MfaDisableDto {
|
|
|
3572
3585
|
code: string;
|
|
3573
3586
|
}
|
|
3574
3587
|
|
|
3588
|
+
/**
|
|
3589
|
+
* Data Transfer Object for the MFA recovery code regeneration endpoint.
|
|
3590
|
+
*
|
|
3591
|
+
* Submitted when an MFA-enabled user wants to rotate their recovery codes
|
|
3592
|
+
* (e.g. after suspecting they have been written down somewhere insecure, or
|
|
3593
|
+
* after consuming several entries from the original list). The endpoint
|
|
3594
|
+
* requires a valid TOTP code from the user's authenticator app to confirm
|
|
3595
|
+
* the action.
|
|
3596
|
+
*
|
|
3597
|
+
* @remarks
|
|
3598
|
+
* **TOTP codes only** — recovery codes are intentionally not accepted as
|
|
3599
|
+
* the proof factor here. If a user has lost access to their authenticator
|
|
3600
|
+
* and is relying on recovery codes, the safe path is to disable MFA and
|
|
3601
|
+
* re-enrol (which forces a fresh secret AND a fresh recovery code set),
|
|
3602
|
+
* not to silently rotate recovery codes using one of the codes the user
|
|
3603
|
+
* may already have leaked.
|
|
3604
|
+
*/
|
|
3605
|
+
declare class MfaRegenerateRecoveryCodesDto {
|
|
3606
|
+
/**
|
|
3607
|
+
* The 6-digit TOTP code generated by the user's authenticator app.
|
|
3608
|
+
*
|
|
3609
|
+
* Must be exactly 6 decimal digits. Recovery codes are not accepted by design.
|
|
3610
|
+
* Alphabetic characters, spaces, or other symbols are rejected before reaching
|
|
3611
|
+
* the service layer.
|
|
3612
|
+
*/
|
|
3613
|
+
code: string;
|
|
3614
|
+
}
|
|
3615
|
+
|
|
3575
3616
|
/**
|
|
3576
3617
|
* Data Transfer Object for the MFA TOTP verification step during setup.
|
|
3577
3618
|
*
|
|
@@ -4665,7 +4706,7 @@ declare class MfaService {
|
|
|
4665
4706
|
*/
|
|
4666
4707
|
private platformUserAsSafeUser;
|
|
4667
4708
|
/**
|
|
4668
|
-
* Initiates the MFA setup flow for a dashboard user.
|
|
4709
|
+
* Initiates the MFA setup flow for a dashboard user or platform administrator.
|
|
4669
4710
|
*
|
|
4670
4711
|
* Generates a TOTP secret and 8 recovery codes, stores them temporarily in
|
|
4671
4712
|
* Redis (10 minutes), and returns the data needed to display the QR code and
|
|
@@ -4676,10 +4717,15 @@ declare class MfaService {
|
|
|
4676
4717
|
* requests cannot generate different secrets.
|
|
4677
4718
|
*
|
|
4678
4719
|
* @param userId - Internal ID of the user enabling MFA.
|
|
4720
|
+
* @param context - Which repository to use: `'dashboard'` (default) or `'platform'`.
|
|
4679
4721
|
* @returns Setup result containing the secret, QR URI, and plain recovery codes.
|
|
4680
4722
|
* @throws `MFA_ALREADY_ENABLED` if MFA is already active on the account.
|
|
4723
|
+
* @throws `MFA_NOT_ENABLED` if `context === 'platform'` and the platform user
|
|
4724
|
+
* repository was not configured at module registration. The error code is
|
|
4725
|
+
* reused (rather than introducing a new one) because the consumer-facing
|
|
4726
|
+
* meaning is the same: "platform MFA cannot operate".
|
|
4681
4727
|
*/
|
|
4682
|
-
setup(userId: string): Promise<MfaSetupResult>;
|
|
4728
|
+
setup(userId: string, context?: 'dashboard' | 'platform'): Promise<MfaSetupResult>;
|
|
4683
4729
|
/**
|
|
4684
4730
|
* Verifies the first TOTP code from the user's authenticator app and permanently
|
|
4685
4731
|
* enables MFA on the account.
|
|
@@ -4693,10 +4739,13 @@ declare class MfaService {
|
|
|
4693
4739
|
* @param code - 6-digit TOTP code from the authenticator app.
|
|
4694
4740
|
* @param ip - Client IP address (forwarded to hooks).
|
|
4695
4741
|
* @param userAgent - User-Agent header (forwarded to hooks).
|
|
4742
|
+
* @param context - Which repository to use: `'dashboard'` (default) or `'platform'`.
|
|
4696
4743
|
* @throws `MFA_SETUP_REQUIRED` if no pending setup data is found in Redis.
|
|
4697
4744
|
* @throws `MFA_INVALID_CODE` if the submitted TOTP code is invalid.
|
|
4745
|
+
* @throws `MFA_NOT_ENABLED` if `context === 'platform'` and the platform user
|
|
4746
|
+
* repository was not configured at module registration.
|
|
4698
4747
|
*/
|
|
4699
|
-
verifyAndEnable(userId: string, code: string, ip: string, userAgent: string): Promise<void>;
|
|
4748
|
+
verifyAndEnable(userId: string, code: string, ip: string, userAgent: string, context?: 'dashboard' | 'platform'): Promise<void>;
|
|
4700
4749
|
/**
|
|
4701
4750
|
* Validates a TOTP or recovery code and exchanges the MFA temp token for full
|
|
4702
4751
|
* access tokens.
|
|
@@ -4740,6 +4789,46 @@ declare class MfaService {
|
|
|
4740
4789
|
* @throws `MFA_INVALID_CODE` if the submitted TOTP code is incorrect.
|
|
4741
4790
|
*/
|
|
4742
4791
|
disable(userId: string, code: string, ip: string, userAgent: string, context?: 'dashboard' | 'platform'): Promise<void>;
|
|
4792
|
+
/**
|
|
4793
|
+
* Regenerates the user's MFA recovery codes after verifying a current TOTP code.
|
|
4794
|
+
*
|
|
4795
|
+
* Mirrors {@link disable} in its security posture: only TOTP codes are accepted
|
|
4796
|
+
* (recovery codes cannot rotate themselves by design), the brute-force counter
|
|
4797
|
+
* is checked, and the regeneration is fired against the correct repository for
|
|
4798
|
+
* the supplied `context`. The TOTP secret on the user record is unchanged — only
|
|
4799
|
+
* the recovery code list is replaced.
|
|
4800
|
+
*
|
|
4801
|
+
* Returns the plain-text codes once. They are NOT persisted in plain form; only
|
|
4802
|
+
* scrypt hashes go into the database. The caller is responsible for showing the
|
|
4803
|
+
* codes to the user exactly once and warning them to save them safely.
|
|
4804
|
+
*
|
|
4805
|
+
* @remarks
|
|
4806
|
+
* **Sessions are intentionally NOT invalidated after this call.** Unlike
|
|
4807
|
+
* {@link verifyAndEnable} (which flips `mfaEnabled` from `false` to `true`) and
|
|
4808
|
+
* {@link disable} (which flips it back to `false`), this method does not change
|
|
4809
|
+
* the verification credential — the TOTP secret stays the same and existing
|
|
4810
|
+
* `mfaVerified: true` access tokens remain valid. Invalidating sessions here
|
|
4811
|
+
* would force a redundant re-auth on every recovery-code rotation, which is a
|
|
4812
|
+
* routine hygiene action a user might perform several times over the lifetime
|
|
4813
|
+
* of an account.
|
|
4814
|
+
*
|
|
4815
|
+
* @param userId - Internal ID of the user rotating recovery codes.
|
|
4816
|
+
* @param totpCode - 6-digit TOTP code from the authenticator app.
|
|
4817
|
+
* @param ip - Client IP address (forwarded to hooks).
|
|
4818
|
+
* @param userAgent - User-Agent header (forwarded to hooks).
|
|
4819
|
+
* @param context - Which repository to use: `'dashboard'` (default) or `'platform'`.
|
|
4820
|
+
* @throws `TOKEN_INVALID` if the user is not found or `mfaSecret` is missing
|
|
4821
|
+
* when `mfaEnabled` is `true` (database inconsistency).
|
|
4822
|
+
* @throws `MFA_NOT_ENABLED` if MFA is not currently active, or if
|
|
4823
|
+
* `context === 'platform'` and the platform user repository was not
|
|
4824
|
+
* configured at module registration.
|
|
4825
|
+
* @throws `ACCOUNT_LOCKED` if the brute-force threshold has been reached.
|
|
4826
|
+
* @throws `MFA_INVALID_CODE` if the submitted TOTP code is incorrect.
|
|
4827
|
+
* @returns The freshly generated plain-text recovery codes, one-time display.
|
|
4828
|
+
*/
|
|
4829
|
+
regenerateRecoveryCodes(userId: string, totpCode: string, ip: string, userAgent: string, context?: 'dashboard' | 'platform'): Promise<{
|
|
4830
|
+
recoveryCodes: string[];
|
|
4831
|
+
}>;
|
|
4743
4832
|
/**
|
|
4744
4833
|
* Verifies a TOTP code and enforces anti-replay within the validation window.
|
|
4745
4834
|
*
|
|
@@ -5142,4 +5231,4 @@ declare function sleep(ms: number): Promise<void>;
|
|
|
5142
5231
|
*/
|
|
5143
5232
|
declare function hasRole(userRole: string, requiredRole: string, hierarchy: Record<string, string[]>): boolean;
|
|
5144
5233
|
|
|
5145
|
-
export { AUTH_ERROR_CODES, AUTH_ERROR_MESSAGES, AUTH_THROTTLE_CONFIGS, AcceptInvitationDto, type SessionInfo as ActiveSessionInfo, type AuthErrorCode, AuthException, type AuthModuleAsyncOptions, type AuthPlatformUser, type AuthResult, AuthService, type AuthUser, type AuthenticatedRequest, BYMAX_AUTH_EMAIL_PROVIDER, BYMAX_AUTH_HOOKS, BYMAX_AUTH_OPTIONS, BYMAX_AUTH_PLATFORM_USER_REPOSITORY, BYMAX_AUTH_REDIS_CLIENT, BYMAX_AUTH_USER_REPOSITORY, type BeforeRegisterResult, BymaxAuthModule, type BymaxAuthModuleOptions, CreateInvitationDto, type CreateUserData, type CreateWithOAuthData, CurrentUser, type DashboardJwtPayload, ForgotPasswordDto, type HookContext, type IAuthHooks, type IEmailProvider, type IPlatformUserRepository, IS_PUBLIC_KEY, type IUserRepository, type InviteData, JwtAuthGuard, JwtPlatformGuard, LoginDto, MfaChallengeDto, type MfaChallengeResult, MfaDisableDto, MfaRequiredGuard, MfaService, type MfaSetupResult, type MfaTempPayload, MfaVerifyDto, NoOpAuthHooks, NoOpEmailProvider, type OAuthLoginResult, type OAuthProfile, type OAuthProviderPlugin, OAuthService, OptionalAuthGuard, OtpService, PLATFORM_ROLES_KEY, PasswordResetService, type PlatformAuthResult, type PlatformAuthenticatedRequest, type PlatformJwtPayload, PlatformLoginDto, PlatformRoles, PlatformRolesGuard, Public, ROLES_KEY, RegisterDto, ResendOtpDto, ResendVerificationDto, ResetPasswordDto, type ResolvedOptions, Roles, RolesGuard, type RotatedTokenResult, SKIP_MFA_KEY, type SafeAuthPlatformUser, type SafeAuthUser, SelfOrAdminGuard, type SessionInfo$1 as SessionInfo, SessionService, SkipMfa, type UpdateMfaData, type UpdatePlatformMfaData, UserStatusGuard, VerifyEmailDto, VerifyOtpDto, WsJwtGuard, decrypt, encrypt, generateSecureToken, hasRole, hmacSha256, sanitizeHeaders, sha256, sleep, timingSafeCompare };
|
|
5234
|
+
export { AUTH_ERROR_CODES, AUTH_ERROR_MESSAGES, AUTH_THROTTLE_CONFIGS, AcceptInvitationDto, type SessionInfo as ActiveSessionInfo, type AuthErrorCode, AuthException, type AuthModuleAsyncOptions, type AuthPlatformUser, type AuthResult, AuthService, type AuthUser, type AuthenticatedRequest, BYMAX_AUTH_EMAIL_PROVIDER, BYMAX_AUTH_HOOKS, BYMAX_AUTH_OPTIONS, BYMAX_AUTH_PLATFORM_USER_REPOSITORY, BYMAX_AUTH_REDIS_CLIENT, BYMAX_AUTH_USER_REPOSITORY, type BeforeRegisterResult, BymaxAuthModule, type BymaxAuthModuleOptions, CreateInvitationDto, type CreateUserData, type CreateWithOAuthData, CurrentUser, type DashboardJwtPayload, ForgotPasswordDto, type HookContext, type IAuthHooks, type IEmailProvider, type IPlatformUserRepository, IS_PUBLIC_KEY, type IUserRepository, type InviteData, JwtAuthGuard, JwtPlatformGuard, LoginDto, MfaChallengeDto, type MfaChallengeResult, MfaDisableDto, MfaRegenerateRecoveryCodesDto, MfaRequiredGuard, MfaService, type MfaSetupResult, type MfaTempPayload, MfaVerifyDto, NoOpAuthHooks, NoOpEmailProvider, type OAuthLoginResult, type OAuthProfile, type OAuthProviderPlugin, OAuthService, OptionalAuthGuard, OtpService, PLATFORM_ROLES_KEY, PasswordResetService, type PlatformAuthResult, type PlatformAuthenticatedRequest, type PlatformJwtPayload, PlatformLoginDto, PlatformRoles, PlatformRolesGuard, Public, ROLES_KEY, RegisterDto, ResendOtpDto, ResendVerificationDto, ResetPasswordDto, type ResolvedOptions, Roles, RolesGuard, type RotatedTokenResult, SKIP_MFA_KEY, type SafeAuthPlatformUser, type SafeAuthUser, SelfOrAdminGuard, type SessionInfo$1 as SessionInfo, SessionService, SkipMfa, type UpdateMfaData, type UpdatePlatformMfaData, UserStatusGuard, VerifyEmailDto, VerifyOtpDto, WsJwtGuard, decrypt, encrypt, generateSecureToken, hasRole, hmacSha256, sanitizeHeaders, sha256, sleep, timingSafeCompare };
|