@bymax-one/nest-auth 1.4.15 → 1.4.16

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.
@@ -1476,8 +1476,12 @@ interface AuthModuleAsyncOptions {
1476
1476
  /**
1477
1477
  * Factory function that produces `BymaxAuthModuleOptions`.
1478
1478
  * Receives injected dependencies as arguments.
1479
+ *
1480
+ * The parameters are typed `never[]` so a factory may declare the types of what it injects,
1481
+ * `(config: ConfigService) => ...`: Nest supplies the values, and their types are the
1482
+ * consumer's declaration. A factory written with `...args: unknown[]` is accepted too.
1479
1483
  */
1480
- useFactory: (...args: unknown[]) => BymaxAuthModuleOptions | Promise<BymaxAuthModuleOptions>;
1484
+ useFactory: (...args: never[]) => BymaxAuthModuleOptions | Promise<BymaxAuthModuleOptions>;
1481
1485
  /** Injection tokens or providers to inject into `useFactory`. */
1482
1486
  inject?: (InjectionToken | OptionalFactoryDependency)[];
1483
1487
  /** Additional providers available within the async options scope. */
@@ -5360,7 +5364,15 @@ declare class TokenDeliveryService {
5360
5364
  private readCookie;
5361
5365
  /** Reads the access token from the Authorization Bearer header. */
5362
5366
  private readBearerHeader;
5363
- /** Reads the refresh token from the request body field. */
5367
+ /**
5368
+ * Reads the refresh token from the request body field.
5369
+ *
5370
+ * An omitted field and JSON `null` both mean "no token". Any other value that is not a string
5371
+ * of 1 to {@link REFRESH_TOKEN_MAX_LENGTH} characters is a malformed request, not a missing
5372
+ * token, and is refused before any caller acts on it.
5373
+ *
5374
+ * @throws {@link AuthException} `VALIDATION` when the field is present and malformed.
5375
+ */
5364
5376
  private readBodyRefresh;
5365
5377
  }
5366
5378
 
@@ -7327,6 +7339,15 @@ interface RevokeSessionParams {
7327
7339
  /** SHA-256 hash of the session being revoked. */
7328
7340
  sessionHash: string;
7329
7341
  }
7342
+ /** Names the session {@link SessionService.assertLiveSession} checks. See {@link CreateSessionParams}. */
7343
+ interface LiveSessionParams {
7344
+ /** Internal user ID that must own the session. */
7345
+ userId: string;
7346
+ /** Tenant that user belongs to; scopes the session index. */
7347
+ tenantId: string;
7348
+ /** SHA-256 hash of the session that must be live. */
7349
+ sessionHash: string;
7350
+ }
7330
7351
  /** Everything {@link SessionService.revokeAllExceptCurrent} needs. See {@link CreateSessionParams}. */
7331
7352
  interface RevokeAllExceptCurrentParams {
7332
7353
  /** Internal user ID whose other sessions are ending. */
@@ -7408,18 +7429,29 @@ declare class SessionService {
7408
7429
  *
7409
7430
  * Reads all `rt:`-prefixed members from `sess:{userId}`, fetches the
7410
7431
  * corresponding `sd:{hash}` detail records, and marks the caller's own
7411
- * session via `isCurrent`. A member whose detail record is missing, unreadable
7412
- * or malformed is excluded from the result, and removed from the SET
7413
- * asynchronously (fire-and-forget) only if its `rt:` key is also gone — see
7414
- * {@link AuthRedisService.pruneDeadMembers} for why the detail record alone
7415
- * does not settle it.
7432
+ * session via `isCurrent`. A member whose detail record is missing or malformed
7433
+ * is excluded from the result. A member whose record cannot be read at all is not
7434
+ * left out quietly: the call rejects, because a session missing from the list is
7435
+ * one the caller cannot revoke. Either way the member is offered to a
7436
+ * fire-and-forget prune that removes it from the SET only if its `rt:` key is
7437
+ * also gone — see {@link AuthRedisService.pruneDeadMembers} for why the detail
7438
+ * record alone does not settle it.
7416
7439
  *
7417
7440
  * Results are sorted by `createdAt` descending (newest session first).
7418
7441
  *
7419
7442
  * @param params - See {@link ListSessionsParams}.
7420
7443
  * @returns Array of {@link SessionInfo} sorted newest-first.
7444
+ * @throws The store's error when a session's detail record cannot be read.
7421
7445
  */
7422
7446
  listSessions({ userId, tenantId, currentSessionHash }: ListSessionsParams): Promise<SessionInfo[]>;
7447
+ /**
7448
+ * Reads one index member's session detail and shapes it for the listing.
7449
+ *
7450
+ * @param member - The `rt:{hash}` index member.
7451
+ * @param currentSessionHash - Hash of the caller's own refresh token, when it sent one.
7452
+ * @returns The session, or why this member is not one: a data state or a read fault.
7453
+ */
7454
+ private readSession;
7423
7455
  /**
7424
7456
  * Revokes a single session belonging to the specified user.
7425
7457
  *
@@ -7458,12 +7490,25 @@ declare class SessionService {
7458
7490
  * @throws {@link AuthException} `SESSION_NOT_FOUND` when the session is not owned by the user.
7459
7491
  */
7460
7492
  revokeOtherSession({ userId, tenantId, sessionHash }: RevokeSessionParams): Promise<void>;
7493
+ /**
7494
+ * Refuses a session hash that names no live session of this user.
7495
+ *
7496
+ * For an operation that keeps one session and ends the rest and so has to be told which one,
7497
+ * checked before it changes anything. The membership test is the same one
7498
+ * {@link revokeAllExceptCurrent} applies.
7499
+ *
7500
+ * @param params - See {@link LiveSessionParams}.
7501
+ * @throws {@link AuthException} `SESSION_NOT_FOUND` when the hash is not a live session.
7502
+ */
7503
+ assertLiveSession({ userId, tenantId, sessionHash }: LiveSessionParams): Promise<void>;
7461
7504
  /**
7462
7505
  * Revokes all sessions for a user except the caller's current session.
7463
7506
  *
7464
7507
  * Reads all `rt:`-prefixed members from `sess:{userId}` and calls
7465
7508
  * {@link revokeSession} for each session whose hash differs from
7466
- * `currentSessionHash`. The current session is always preserved.
7509
+ * `currentSessionHash`. The current session is always preserved, and it has to exist: a hash
7510
+ * that names no live session of this user is refused before anything is revoked, since keeping
7511
+ * nothing would revoke every session the account has, the caller's own included.
7467
7512
  *
7468
7513
  * The user's token epoch is advanced as part of this, which is what makes the revocation
7469
7514
  * take effect *now* rather than whenever each device's access token happens to expire.
@@ -7482,6 +7527,8 @@ declare class SessionService {
7482
7527
  *
7483
7528
  * @param userId - Internal user ID whose other sessions are being revoked.
7484
7529
  * @param currentSessionHash - SHA-256 hash of the session to preserve.
7530
+ * @throws {@link AuthException} `SESSION_NOT_FOUND` when `currentSessionHash` names no live
7531
+ * session of this user.
7485
7532
  * @throws {unknown} Propagates any error thrown by `revokeSession` — including
7486
7533
  * {@link AuthException} with various codes, Redis errors, or other runtime errors.
7487
7534
  */
@@ -7537,6 +7584,12 @@ declare class SessionService {
7537
7584
  * @throws {@link AuthException} `VALIDATION` when the value is not 64 lowercase hex characters.
7538
7585
  */
7539
7586
  private assertValidSessionHash;
7587
+ /**
7588
+ * Throws unless `members` holds a live refresh session with this hash.
7589
+ *
7590
+ * @throws {@link AuthException} `SESSION_NOT_FOUND`.
7591
+ */
7592
+ private requireLiveMember;
7540
7593
  /**
7541
7594
  * The Redis key of this user's session index.
7542
7595
  *
@@ -9726,6 +9779,20 @@ declare class PasswordResetService {
9726
9779
  * the configured breach checker.
9727
9780
  */
9728
9781
  changePassword(userId: string, tenantId: string, dto: ChangePasswordDto, currentRefreshToken?: string): Promise<void>;
9782
+ /** Refuses a presented refresh token that names no live session of the account. */
9783
+ private requireLiveCurrentSession;
9784
+ /**
9785
+ * Ends every session but the caller's, once the new password is already written.
9786
+ *
9787
+ * With no presented token there is no session to spare and every session ends. A token that was
9788
+ * live when it was checked can rotate away while the new password is hashed, and then there is
9789
+ * no current session left to keep either: every session ends, so the cleanup that makes the
9790
+ * change safe is never aborted by the session it was told to spare. Any other failure of the
9791
+ * sweep propagates.
9792
+ */
9793
+ private endOtherSessions;
9794
+ /** Ends every session the account has and advances its token epoch. */
9795
+ private endAllSessions;
9729
9796
  /**
9730
9797
  * Sends the "your password changed" notice, fire-and-forget.
9731
9798
  *
@@ -10972,4 +11039,5 @@ declare class ApiKeyService {
10972
11039
  private validatedExpiry;
10973
11040
  }
10974
11041
 
10975
- export { API_KEY_MAX_LABEL_LENGTH, API_KEY_MAX_OVERLAP_SECONDS, AUTH_EMAIL_KINDS, AUTH_ERROR_CODES, AUTH_ERROR_MESSAGES, AUTH_ERROR_STATUS, AUTH_SECURITY_SCHEMES, AUTH_THROTTLE_CONFIGS, AcceptInvitationDto, AccountStatusService, AllowAllBreachChecker, type ApiKeyAccessEvent, type ApiKeyClock, type ApiKeyDenyReason, ApiKeyGuard, type ApiKeyPrincipal, ApiKeyScopes, ApiKeyService, type AuthApiKey, type AuthApiKeySummary, type AuthDocumentSecurityParams, type AuthEmailCatalogue, type AuthEmailContext, type AuthEmailKind, type AuthEmailMessage, type AuthEmailSink, type AuthErrorCode, AuthException, AuthExceptionFilter, type AuthFieldError, type AuthGuardFamily, type AuthModuleAsyncOptions, type AuthPlane, type AuthPlatformUser, AuthRateLimit, AuthRateLimitGuard, type AuthRateLimitWindow, type AuthResult, AuthRevocationService, AuthService, AuthTokenVerifierService, type AuthUser, Authenticated, type AuthenticatedRequest, BYMAX_AUTH_API_KEY_CLOCK, BYMAX_AUTH_API_KEY_REPOSITORY, BYMAX_AUTH_BREACH_CHECKER, BYMAX_AUTH_EMAIL_PROVIDER, BYMAX_AUTH_HOOKS, BYMAX_AUTH_OPTIONS, BYMAX_AUTH_PLATFORM_USER_REPOSITORY, BYMAX_AUTH_REDIS_CLIENT, BYMAX_AUTH_USER_REPOSITORY, type BearerAuthResponse, type BeforeRegisterResult, type BothAuthResponse, BruteForceService, BymaxAuthModule, type BymaxAuthModuleOptions, type BymaxAuthRateLimitOptions, ChangePasswordDto, type ClientIpSource, CommonPasswordChecker, type CookieAuthResponse, CreateInvitationDto, type CreateSessionParams, type CreateUserData, type CreateWithOAuthData, CurrentApiKey, CurrentUser, type DashboardJwtPayload, DefaultAuthEmailProvider, type DefaultAuthEmailProviderOptions, type DeliveryErrorPolicy, type DeliveryErrorPolicyMap, EmailChangeService, type FindUserByEmailParams, type FindUserByOAuthIdParams, ForgotPasswordDto, HibpBreachChecker, type HookContext, type IApiKeyRepository, type IAuthHooks, type IEmailProvider, type IPasswordBreachChecker, type IPlatformUserRepository, IS_PUBLIC_KEY, type IUserRepository, InvitationService, type InviteData, type IssueApiKeyInput, type IssuedApiKey, JwtAuthGuard, JwtPlatformGuard, type LinkOAuthParams, type ListSessionsParams, LoginDto, MfaChallengeDto, type MfaChallengeResult, MfaDisableDto, MfaRegenerateRecoveryCodesDto, MfaRequiredGuard, MfaService, type MfaSetupResult, type MfaTempPayload, MfaVerifyDto, NoOpAuthHooks, NoOpEmailProvider, type OAuthLoginResult, type OAuthMfaChallengeResult, type OAuthProfile, type OAuthProviderPlugin, OAuthService, type OpenApiSecurityRequirement, OptionalAuthGuard, OtpService, PLATFORM_ROLES_KEY, PasswordResetService, type PlatformAuthResult, PlatformAuthService, type PlatformAuthenticatedRequest, type PlatformBearerAuthResponse, type PlatformJwtPayload, PlatformLoginDto, PlatformRoles, PlatformRolesGuard, Public, ROLES_KEY, RegisterDto, ResendOtpDto, ResendVerificationDto, ResetPasswordDto, type ResolvedOptions, type RevocableTokenPayload, type RevokeAllExceptCurrentParams, type RevokeAllSessionsParams, type RevokeSessionParams, Roles, RolesGuard, type RotateApiKeyInput, type RotatedTokenResult, SKIP_MFA_KEY, type SafeAuthPlatformUser, type SafeAuthUser, SelfOrAdminGuard, ServiceKey, type SessionAlertInfo, type SessionInfo, SessionService, SkipMfa, type TenantResolverRequest, type TenantScopedUserRef, TokenDeliveryService, TrustedOriginGuard, type UpdateEmailParams, type UpdateEmailVerifiedParams, type UpdateMfaData, type UpdateMfaParams, type UpdatePasswordParams, type UpdatePlatformMfaData, type UpdateStatusParams, UserStatusGuard, type VerifiedAccessToken, type VerifyAccessTokenOptions, VerifyEmailDto, VerifyOtpDto, WS_TICKET_TTL_SECONDS, WsAuthExceptionFilter, WsJwtGuard, WsTicketService, type WsTicketSnapshot, authDocumentSecurity, createAuthValidationPipe, decrypt, describeChannelStatus, describeError, encrypt, generateSecureToken, hasRole, hmacSha256, redactSecrets, reduceToBaseWord, sanitizeHeaders, sha256, sleep, timingSafeCompare };
11042
+ export { API_KEY_MAX_LABEL_LENGTH, API_KEY_MAX_OVERLAP_SECONDS, AUTH_EMAIL_KINDS, AUTH_ERROR_CODES, AUTH_ERROR_MESSAGES, AUTH_ERROR_STATUS, AUTH_SECURITY_SCHEMES, AUTH_THROTTLE_CONFIGS, AcceptInvitationDto, AccountStatusService, AllowAllBreachChecker, ApiKeyGuard, ApiKeyScopes, ApiKeyService, AuthException, AuthExceptionFilter, AuthRateLimit, AuthRateLimitGuard, AuthRevocationService, AuthService, AuthTokenVerifierService, Authenticated, BYMAX_AUTH_API_KEY_CLOCK, BYMAX_AUTH_API_KEY_REPOSITORY, BYMAX_AUTH_BREACH_CHECKER, BYMAX_AUTH_EMAIL_PROVIDER, BYMAX_AUTH_HOOKS, BYMAX_AUTH_OPTIONS, BYMAX_AUTH_PLATFORM_USER_REPOSITORY, BYMAX_AUTH_REDIS_CLIENT, BYMAX_AUTH_USER_REPOSITORY, BruteForceService, BymaxAuthModule, ChangePasswordDto, CommonPasswordChecker, CreateInvitationDto, CurrentApiKey, CurrentUser, DefaultAuthEmailProvider, EmailChangeService, ForgotPasswordDto, HibpBreachChecker, IS_PUBLIC_KEY, InvitationService, JwtAuthGuard, JwtPlatformGuard, LoginDto, MfaChallengeDto, MfaDisableDto, MfaRegenerateRecoveryCodesDto, MfaRequiredGuard, MfaService, MfaVerifyDto, NoOpAuthHooks, NoOpEmailProvider, OAuthService, OptionalAuthGuard, OtpService, PLATFORM_ROLES_KEY, PasswordResetService, PlatformAuthService, PlatformLoginDto, PlatformRoles, PlatformRolesGuard, Public, ROLES_KEY, RegisterDto, ResendOtpDto, ResendVerificationDto, ResetPasswordDto, Roles, RolesGuard, SKIP_MFA_KEY, SelfOrAdminGuard, ServiceKey, SessionService, SkipMfa, TokenDeliveryService, TrustedOriginGuard, UserStatusGuard, VerifyEmailDto, VerifyOtpDto, WS_TICKET_TTL_SECONDS, WsAuthExceptionFilter, WsJwtGuard, WsTicketService, authDocumentSecurity, createAuthValidationPipe, decrypt, describeChannelStatus, describeError, encrypt, generateSecureToken, hasRole, hmacSha256, redactSecrets, reduceToBaseWord, sanitizeHeaders, sha256, sleep, timingSafeCompare };
11043
+ export type { ApiKeyAccessEvent, ApiKeyClock, ApiKeyDenyReason, ApiKeyPrincipal, AuthApiKey, AuthApiKeySummary, AuthDocumentSecurityParams, AuthEmailCatalogue, AuthEmailContext, AuthEmailKind, AuthEmailMessage, AuthEmailSink, AuthErrorCode, AuthFieldError, AuthGuardFamily, AuthModuleAsyncOptions, AuthPlane, AuthPlatformUser, AuthRateLimitWindow, AuthResult, AuthUser, AuthenticatedRequest, BearerAuthResponse, BeforeRegisterResult, BothAuthResponse, BymaxAuthModuleOptions, BymaxAuthRateLimitOptions, ClientIpSource, CookieAuthResponse, CreateSessionParams, CreateUserData, CreateWithOAuthData, DashboardJwtPayload, DefaultAuthEmailProviderOptions, DeliveryErrorPolicy, DeliveryErrorPolicyMap, FindUserByEmailParams, FindUserByOAuthIdParams, HookContext, IApiKeyRepository, IAuthHooks, IEmailProvider, IPasswordBreachChecker, IPlatformUserRepository, IUserRepository, InviteData, IssueApiKeyInput, IssuedApiKey, LinkOAuthParams, ListSessionsParams, LiveSessionParams, MfaChallengeResult, MfaSetupResult, MfaTempPayload, OAuthLoginResult, OAuthMfaChallengeResult, OAuthProfile, OAuthProviderPlugin, OpenApiSecurityRequirement, PlatformAuthResult, PlatformAuthenticatedRequest, PlatformBearerAuthResponse, PlatformJwtPayload, ResolvedOptions, RevocableTokenPayload, RevokeAllExceptCurrentParams, RevokeAllSessionsParams, RevokeSessionParams, RotateApiKeyInput, RotatedTokenResult, SafeAuthPlatformUser, SafeAuthUser, SessionAlertInfo, SessionInfo, TenantResolverRequest, TenantScopedUserRef, UpdateEmailParams, UpdateEmailVerifiedParams, UpdateMfaData, UpdateMfaParams, UpdatePasswordParams, UpdatePlatformMfaData, UpdateStatusParams, VerifiedAccessToken, VerifyAccessTokenOptions, WsTicketSnapshot };
@@ -1476,8 +1476,12 @@ interface AuthModuleAsyncOptions {
1476
1476
  /**
1477
1477
  * Factory function that produces `BymaxAuthModuleOptions`.
1478
1478
  * Receives injected dependencies as arguments.
1479
+ *
1480
+ * The parameters are typed `never[]` so a factory may declare the types of what it injects,
1481
+ * `(config: ConfigService) => ...`: Nest supplies the values, and their types are the
1482
+ * consumer's declaration. A factory written with `...args: unknown[]` is accepted too.
1479
1483
  */
1480
- useFactory: (...args: unknown[]) => BymaxAuthModuleOptions | Promise<BymaxAuthModuleOptions>;
1484
+ useFactory: (...args: never[]) => BymaxAuthModuleOptions | Promise<BymaxAuthModuleOptions>;
1481
1485
  /** Injection tokens or providers to inject into `useFactory`. */
1482
1486
  inject?: (InjectionToken | OptionalFactoryDependency)[];
1483
1487
  /** Additional providers available within the async options scope. */
@@ -5360,7 +5364,15 @@ declare class TokenDeliveryService {
5360
5364
  private readCookie;
5361
5365
  /** Reads the access token from the Authorization Bearer header. */
5362
5366
  private readBearerHeader;
5363
- /** Reads the refresh token from the request body field. */
5367
+ /**
5368
+ * Reads the refresh token from the request body field.
5369
+ *
5370
+ * An omitted field and JSON `null` both mean "no token". Any other value that is not a string
5371
+ * of 1 to {@link REFRESH_TOKEN_MAX_LENGTH} characters is a malformed request, not a missing
5372
+ * token, and is refused before any caller acts on it.
5373
+ *
5374
+ * @throws {@link AuthException} `VALIDATION` when the field is present and malformed.
5375
+ */
5364
5376
  private readBodyRefresh;
5365
5377
  }
5366
5378
 
@@ -7327,6 +7339,15 @@ interface RevokeSessionParams {
7327
7339
  /** SHA-256 hash of the session being revoked. */
7328
7340
  sessionHash: string;
7329
7341
  }
7342
+ /** Names the session {@link SessionService.assertLiveSession} checks. See {@link CreateSessionParams}. */
7343
+ interface LiveSessionParams {
7344
+ /** Internal user ID that must own the session. */
7345
+ userId: string;
7346
+ /** Tenant that user belongs to; scopes the session index. */
7347
+ tenantId: string;
7348
+ /** SHA-256 hash of the session that must be live. */
7349
+ sessionHash: string;
7350
+ }
7330
7351
  /** Everything {@link SessionService.revokeAllExceptCurrent} needs. See {@link CreateSessionParams}. */
7331
7352
  interface RevokeAllExceptCurrentParams {
7332
7353
  /** Internal user ID whose other sessions are ending. */
@@ -7408,18 +7429,29 @@ declare class SessionService {
7408
7429
  *
7409
7430
  * Reads all `rt:`-prefixed members from `sess:{userId}`, fetches the
7410
7431
  * corresponding `sd:{hash}` detail records, and marks the caller's own
7411
- * session via `isCurrent`. A member whose detail record is missing, unreadable
7412
- * or malformed is excluded from the result, and removed from the SET
7413
- * asynchronously (fire-and-forget) only if its `rt:` key is also gone — see
7414
- * {@link AuthRedisService.pruneDeadMembers} for why the detail record alone
7415
- * does not settle it.
7432
+ * session via `isCurrent`. A member whose detail record is missing or malformed
7433
+ * is excluded from the result. A member whose record cannot be read at all is not
7434
+ * left out quietly: the call rejects, because a session missing from the list is
7435
+ * one the caller cannot revoke. Either way the member is offered to a
7436
+ * fire-and-forget prune that removes it from the SET only if its `rt:` key is
7437
+ * also gone — see {@link AuthRedisService.pruneDeadMembers} for why the detail
7438
+ * record alone does not settle it.
7416
7439
  *
7417
7440
  * Results are sorted by `createdAt` descending (newest session first).
7418
7441
  *
7419
7442
  * @param params - See {@link ListSessionsParams}.
7420
7443
  * @returns Array of {@link SessionInfo} sorted newest-first.
7444
+ * @throws The store's error when a session's detail record cannot be read.
7421
7445
  */
7422
7446
  listSessions({ userId, tenantId, currentSessionHash }: ListSessionsParams): Promise<SessionInfo[]>;
7447
+ /**
7448
+ * Reads one index member's session detail and shapes it for the listing.
7449
+ *
7450
+ * @param member - The `rt:{hash}` index member.
7451
+ * @param currentSessionHash - Hash of the caller's own refresh token, when it sent one.
7452
+ * @returns The session, or why this member is not one: a data state or a read fault.
7453
+ */
7454
+ private readSession;
7423
7455
  /**
7424
7456
  * Revokes a single session belonging to the specified user.
7425
7457
  *
@@ -7458,12 +7490,25 @@ declare class SessionService {
7458
7490
  * @throws {@link AuthException} `SESSION_NOT_FOUND` when the session is not owned by the user.
7459
7491
  */
7460
7492
  revokeOtherSession({ userId, tenantId, sessionHash }: RevokeSessionParams): Promise<void>;
7493
+ /**
7494
+ * Refuses a session hash that names no live session of this user.
7495
+ *
7496
+ * For an operation that keeps one session and ends the rest and so has to be told which one,
7497
+ * checked before it changes anything. The membership test is the same one
7498
+ * {@link revokeAllExceptCurrent} applies.
7499
+ *
7500
+ * @param params - See {@link LiveSessionParams}.
7501
+ * @throws {@link AuthException} `SESSION_NOT_FOUND` when the hash is not a live session.
7502
+ */
7503
+ assertLiveSession({ userId, tenantId, sessionHash }: LiveSessionParams): Promise<void>;
7461
7504
  /**
7462
7505
  * Revokes all sessions for a user except the caller's current session.
7463
7506
  *
7464
7507
  * Reads all `rt:`-prefixed members from `sess:{userId}` and calls
7465
7508
  * {@link revokeSession} for each session whose hash differs from
7466
- * `currentSessionHash`. The current session is always preserved.
7509
+ * `currentSessionHash`. The current session is always preserved, and it has to exist: a hash
7510
+ * that names no live session of this user is refused before anything is revoked, since keeping
7511
+ * nothing would revoke every session the account has, the caller's own included.
7467
7512
  *
7468
7513
  * The user's token epoch is advanced as part of this, which is what makes the revocation
7469
7514
  * take effect *now* rather than whenever each device's access token happens to expire.
@@ -7482,6 +7527,8 @@ declare class SessionService {
7482
7527
  *
7483
7528
  * @param userId - Internal user ID whose other sessions are being revoked.
7484
7529
  * @param currentSessionHash - SHA-256 hash of the session to preserve.
7530
+ * @throws {@link AuthException} `SESSION_NOT_FOUND` when `currentSessionHash` names no live
7531
+ * session of this user.
7485
7532
  * @throws {unknown} Propagates any error thrown by `revokeSession` — including
7486
7533
  * {@link AuthException} with various codes, Redis errors, or other runtime errors.
7487
7534
  */
@@ -7537,6 +7584,12 @@ declare class SessionService {
7537
7584
  * @throws {@link AuthException} `VALIDATION` when the value is not 64 lowercase hex characters.
7538
7585
  */
7539
7586
  private assertValidSessionHash;
7587
+ /**
7588
+ * Throws unless `members` holds a live refresh session with this hash.
7589
+ *
7590
+ * @throws {@link AuthException} `SESSION_NOT_FOUND`.
7591
+ */
7592
+ private requireLiveMember;
7540
7593
  /**
7541
7594
  * The Redis key of this user's session index.
7542
7595
  *
@@ -9726,6 +9779,20 @@ declare class PasswordResetService {
9726
9779
  * the configured breach checker.
9727
9780
  */
9728
9781
  changePassword(userId: string, tenantId: string, dto: ChangePasswordDto, currentRefreshToken?: string): Promise<void>;
9782
+ /** Refuses a presented refresh token that names no live session of the account. */
9783
+ private requireLiveCurrentSession;
9784
+ /**
9785
+ * Ends every session but the caller's, once the new password is already written.
9786
+ *
9787
+ * With no presented token there is no session to spare and every session ends. A token that was
9788
+ * live when it was checked can rotate away while the new password is hashed, and then there is
9789
+ * no current session left to keep either: every session ends, so the cleanup that makes the
9790
+ * change safe is never aborted by the session it was told to spare. Any other failure of the
9791
+ * sweep propagates.
9792
+ */
9793
+ private endOtherSessions;
9794
+ /** Ends every session the account has and advances its token epoch. */
9795
+ private endAllSessions;
9729
9796
  /**
9730
9797
  * Sends the "your password changed" notice, fire-and-forget.
9731
9798
  *
@@ -10972,4 +11039,5 @@ declare class ApiKeyService {
10972
11039
  private validatedExpiry;
10973
11040
  }
10974
11041
 
10975
- export { API_KEY_MAX_LABEL_LENGTH, API_KEY_MAX_OVERLAP_SECONDS, AUTH_EMAIL_KINDS, AUTH_ERROR_CODES, AUTH_ERROR_MESSAGES, AUTH_ERROR_STATUS, AUTH_SECURITY_SCHEMES, AUTH_THROTTLE_CONFIGS, AcceptInvitationDto, AccountStatusService, AllowAllBreachChecker, type ApiKeyAccessEvent, type ApiKeyClock, type ApiKeyDenyReason, ApiKeyGuard, type ApiKeyPrincipal, ApiKeyScopes, ApiKeyService, type AuthApiKey, type AuthApiKeySummary, type AuthDocumentSecurityParams, type AuthEmailCatalogue, type AuthEmailContext, type AuthEmailKind, type AuthEmailMessage, type AuthEmailSink, type AuthErrorCode, AuthException, AuthExceptionFilter, type AuthFieldError, type AuthGuardFamily, type AuthModuleAsyncOptions, type AuthPlane, type AuthPlatformUser, AuthRateLimit, AuthRateLimitGuard, type AuthRateLimitWindow, type AuthResult, AuthRevocationService, AuthService, AuthTokenVerifierService, type AuthUser, Authenticated, type AuthenticatedRequest, BYMAX_AUTH_API_KEY_CLOCK, BYMAX_AUTH_API_KEY_REPOSITORY, BYMAX_AUTH_BREACH_CHECKER, BYMAX_AUTH_EMAIL_PROVIDER, BYMAX_AUTH_HOOKS, BYMAX_AUTH_OPTIONS, BYMAX_AUTH_PLATFORM_USER_REPOSITORY, BYMAX_AUTH_REDIS_CLIENT, BYMAX_AUTH_USER_REPOSITORY, type BearerAuthResponse, type BeforeRegisterResult, type BothAuthResponse, BruteForceService, BymaxAuthModule, type BymaxAuthModuleOptions, type BymaxAuthRateLimitOptions, ChangePasswordDto, type ClientIpSource, CommonPasswordChecker, type CookieAuthResponse, CreateInvitationDto, type CreateSessionParams, type CreateUserData, type CreateWithOAuthData, CurrentApiKey, CurrentUser, type DashboardJwtPayload, DefaultAuthEmailProvider, type DefaultAuthEmailProviderOptions, type DeliveryErrorPolicy, type DeliveryErrorPolicyMap, EmailChangeService, type FindUserByEmailParams, type FindUserByOAuthIdParams, ForgotPasswordDto, HibpBreachChecker, type HookContext, type IApiKeyRepository, type IAuthHooks, type IEmailProvider, type IPasswordBreachChecker, type IPlatformUserRepository, IS_PUBLIC_KEY, type IUserRepository, InvitationService, type InviteData, type IssueApiKeyInput, type IssuedApiKey, JwtAuthGuard, JwtPlatformGuard, type LinkOAuthParams, type ListSessionsParams, LoginDto, MfaChallengeDto, type MfaChallengeResult, MfaDisableDto, MfaRegenerateRecoveryCodesDto, MfaRequiredGuard, MfaService, type MfaSetupResult, type MfaTempPayload, MfaVerifyDto, NoOpAuthHooks, NoOpEmailProvider, type OAuthLoginResult, type OAuthMfaChallengeResult, type OAuthProfile, type OAuthProviderPlugin, OAuthService, type OpenApiSecurityRequirement, OptionalAuthGuard, OtpService, PLATFORM_ROLES_KEY, PasswordResetService, type PlatformAuthResult, PlatformAuthService, type PlatformAuthenticatedRequest, type PlatformBearerAuthResponse, type PlatformJwtPayload, PlatformLoginDto, PlatformRoles, PlatformRolesGuard, Public, ROLES_KEY, RegisterDto, ResendOtpDto, ResendVerificationDto, ResetPasswordDto, type ResolvedOptions, type RevocableTokenPayload, type RevokeAllExceptCurrentParams, type RevokeAllSessionsParams, type RevokeSessionParams, Roles, RolesGuard, type RotateApiKeyInput, type RotatedTokenResult, SKIP_MFA_KEY, type SafeAuthPlatformUser, type SafeAuthUser, SelfOrAdminGuard, ServiceKey, type SessionAlertInfo, type SessionInfo, SessionService, SkipMfa, type TenantResolverRequest, type TenantScopedUserRef, TokenDeliveryService, TrustedOriginGuard, type UpdateEmailParams, type UpdateEmailVerifiedParams, type UpdateMfaData, type UpdateMfaParams, type UpdatePasswordParams, type UpdatePlatformMfaData, type UpdateStatusParams, UserStatusGuard, type VerifiedAccessToken, type VerifyAccessTokenOptions, VerifyEmailDto, VerifyOtpDto, WS_TICKET_TTL_SECONDS, WsAuthExceptionFilter, WsJwtGuard, WsTicketService, type WsTicketSnapshot, authDocumentSecurity, createAuthValidationPipe, decrypt, describeChannelStatus, describeError, encrypt, generateSecureToken, hasRole, hmacSha256, redactSecrets, reduceToBaseWord, sanitizeHeaders, sha256, sleep, timingSafeCompare };
11042
+ export { API_KEY_MAX_LABEL_LENGTH, API_KEY_MAX_OVERLAP_SECONDS, AUTH_EMAIL_KINDS, AUTH_ERROR_CODES, AUTH_ERROR_MESSAGES, AUTH_ERROR_STATUS, AUTH_SECURITY_SCHEMES, AUTH_THROTTLE_CONFIGS, AcceptInvitationDto, AccountStatusService, AllowAllBreachChecker, ApiKeyGuard, ApiKeyScopes, ApiKeyService, AuthException, AuthExceptionFilter, AuthRateLimit, AuthRateLimitGuard, AuthRevocationService, AuthService, AuthTokenVerifierService, Authenticated, BYMAX_AUTH_API_KEY_CLOCK, BYMAX_AUTH_API_KEY_REPOSITORY, BYMAX_AUTH_BREACH_CHECKER, BYMAX_AUTH_EMAIL_PROVIDER, BYMAX_AUTH_HOOKS, BYMAX_AUTH_OPTIONS, BYMAX_AUTH_PLATFORM_USER_REPOSITORY, BYMAX_AUTH_REDIS_CLIENT, BYMAX_AUTH_USER_REPOSITORY, BruteForceService, BymaxAuthModule, ChangePasswordDto, CommonPasswordChecker, CreateInvitationDto, CurrentApiKey, CurrentUser, DefaultAuthEmailProvider, EmailChangeService, ForgotPasswordDto, HibpBreachChecker, IS_PUBLIC_KEY, InvitationService, JwtAuthGuard, JwtPlatformGuard, LoginDto, MfaChallengeDto, MfaDisableDto, MfaRegenerateRecoveryCodesDto, MfaRequiredGuard, MfaService, MfaVerifyDto, NoOpAuthHooks, NoOpEmailProvider, OAuthService, OptionalAuthGuard, OtpService, PLATFORM_ROLES_KEY, PasswordResetService, PlatformAuthService, PlatformLoginDto, PlatformRoles, PlatformRolesGuard, Public, ROLES_KEY, RegisterDto, ResendOtpDto, ResendVerificationDto, ResetPasswordDto, Roles, RolesGuard, SKIP_MFA_KEY, SelfOrAdminGuard, ServiceKey, SessionService, SkipMfa, TokenDeliveryService, TrustedOriginGuard, UserStatusGuard, VerifyEmailDto, VerifyOtpDto, WS_TICKET_TTL_SECONDS, WsAuthExceptionFilter, WsJwtGuard, WsTicketService, authDocumentSecurity, createAuthValidationPipe, decrypt, describeChannelStatus, describeError, encrypt, generateSecureToken, hasRole, hmacSha256, redactSecrets, reduceToBaseWord, sanitizeHeaders, sha256, sleep, timingSafeCompare };
11043
+ export type { ApiKeyAccessEvent, ApiKeyClock, ApiKeyDenyReason, ApiKeyPrincipal, AuthApiKey, AuthApiKeySummary, AuthDocumentSecurityParams, AuthEmailCatalogue, AuthEmailContext, AuthEmailKind, AuthEmailMessage, AuthEmailSink, AuthErrorCode, AuthFieldError, AuthGuardFamily, AuthModuleAsyncOptions, AuthPlane, AuthPlatformUser, AuthRateLimitWindow, AuthResult, AuthUser, AuthenticatedRequest, BearerAuthResponse, BeforeRegisterResult, BothAuthResponse, BymaxAuthModuleOptions, BymaxAuthRateLimitOptions, ClientIpSource, CookieAuthResponse, CreateSessionParams, CreateUserData, CreateWithOAuthData, DashboardJwtPayload, DefaultAuthEmailProviderOptions, DeliveryErrorPolicy, DeliveryErrorPolicyMap, FindUserByEmailParams, FindUserByOAuthIdParams, HookContext, IApiKeyRepository, IAuthHooks, IEmailProvider, IPasswordBreachChecker, IPlatformUserRepository, IUserRepository, InviteData, IssueApiKeyInput, IssuedApiKey, LinkOAuthParams, ListSessionsParams, LiveSessionParams, MfaChallengeResult, MfaSetupResult, MfaTempPayload, OAuthLoginResult, OAuthMfaChallengeResult, OAuthProfile, OAuthProviderPlugin, OpenApiSecurityRequirement, PlatformAuthResult, PlatformAuthenticatedRequest, PlatformBearerAuthResponse, PlatformJwtPayload, ResolvedOptions, RevocableTokenPayload, RevokeAllExceptCurrentParams, RevokeAllSessionsParams, RevokeSessionParams, RotateApiKeyInput, RotatedTokenResult, SafeAuthPlatformUser, SafeAuthUser, SessionAlertInfo, SessionInfo, TenantResolverRequest, TenantScopedUserRef, UpdateEmailParams, UpdateEmailVerifiedParams, UpdateMfaData, UpdateMfaParams, UpdatePasswordParams, UpdatePlatformMfaData, UpdateStatusParams, VerifiedAccessToken, VerifyAccessTokenOptions, WsTicketSnapshot };