@bymax-one/nest-auth 1.4.17 → 1.4.18

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.
@@ -5679,6 +5679,41 @@ declare class AuthRateLimitGuard implements CanActivate {
5679
5679
  private clientIp;
5680
5680
  }
5681
5681
 
5682
+ /**
5683
+ * Answers `415` for a request carrying a `Content-Encoding` other than `identity`.
5684
+ *
5685
+ * @remarks
5686
+ * Whether a compressed request body is decompressed is the host's body parser's decision, not the
5687
+ * library's: Express's default inflates `gzip`, `deflate` and `br`, a host that sets
5688
+ * `inflate: false` refuses them, and a framework that does not decode accepts nothing. The
5689
+ * contract the library shares with its sibling is the stricter one, and a library that relies on
5690
+ * host configuration for it holds that contract only where the host happened to set it. So the
5691
+ * refusal is made here, before any handler.
5692
+ *
5693
+ * Auth payloads are a few hundred bytes and browsers do not compress request bodies, so nothing
5694
+ * legitimate is lost. The parser has already decompressed the body by the time a guard runs, and
5695
+ * its size limit counts decompressed bytes, so the work this guard declines to do is bounded by
5696
+ * that limit either way; the refusal is for the contract, with the parser-level `inflate: false`
5697
+ * refusing earlier on a host that sets it.
5698
+ *
5699
+ * The answer is an `HttpException` whose body already is the library's error envelope. The
5700
+ * optional `AuthExceptionFilter` passes such a body through untouched and, without it, Nest
5701
+ * serialises the same object, so the response is identical either way. It is not an
5702
+ * `AuthException` because the status of `auth.validation` in the error catalog is `400`, one
5703
+ * status per code.
5704
+ */
5705
+ declare class RequestEncodingGuard implements CanActivate {
5706
+ private readonly reflector;
5707
+ constructor(reflector: Reflector);
5708
+ /**
5709
+ * @param context - The execution context of the request.
5710
+ * @returns `true` when the route does not check, the request declares no encoding or only
5711
+ * `identity`, or the route checks only requests with a body and this one has none.
5712
+ * @throws {@link HttpException} `415` in the `auth.validation` envelope otherwise.
5713
+ */
5714
+ canActivate(context: ExecutionContext): boolean;
5715
+ }
5716
+
5682
5717
  /**
5683
5718
  * Blocks a cross-site request that would otherwise be authenticated by the browser's ambient
5684
5719
  * session cookie.
@@ -6307,6 +6342,33 @@ declare const IS_PUBLIC_KEY: unique symbol;
6307
6342
  */
6308
6343
  declare const Public: () => MethodDecorator & ClassDecorator;
6309
6344
 
6345
+ /**
6346
+ * How a route treats a request whose `Content-Encoding` is not `identity`.
6347
+ *
6348
+ * - `'unchecked'`: never refused. The routes that take no JSON body to decode (refresh, logout,
6349
+ * revoke-all, a ticket request) and that the shared contract leaves unchecked.
6350
+ * - `'when-body'`: refused only when the request carries a body. The MFA setup routes take an
6351
+ * optional body, and an empty one takes the default.
6352
+ *
6353
+ * A route with no policy is strict: every non-`identity` encoding is refused, so a route added
6354
+ * later is checked unless someone says it should not be.
6355
+ */
6356
+ type RequestEncodingPolicy = 'unchecked' | 'when-body';
6357
+ /**
6358
+ * Sets how strictly {@link RequestEncodingGuard} checks the route's `Content-Encoding`.
6359
+ *
6360
+ * @param policy - See {@link RequestEncodingPolicy}.
6361
+ * @returns A method decorator.
6362
+ *
6363
+ * @example
6364
+ * ```typescript
6365
+ * @RequestEncoding('unchecked')
6366
+ * @Post('refresh')
6367
+ * refresh() { ... }
6368
+ * ```
6369
+ */
6370
+ declare const RequestEncoding: (policy: RequestEncodingPolicy) => MethodDecorator;
6371
+
6310
6372
  /**
6311
6373
  * Metadata key used by {@link RolesGuard} to read the required roles for a route.
6312
6374
  *
@@ -8327,6 +8389,37 @@ declare class AuthService {
8327
8389
  * matched the presented refresh token (already logged out, or expired).
8328
8390
  */
8329
8391
  logout(accessToken: string, rawRefreshToken: string): Promise<string>;
8392
+ /**
8393
+ * The access-token blacklist write for a logout, or none when there is nothing to revoke.
8394
+ *
8395
+ * Verifies signature and algorithm but not expiry: an expired token is the normal case here, a
8396
+ * forged one must not blacklist an id it does not own. Only the verification is tolerant.
8397
+ *
8398
+ * @param accessToken - Raw access token; absent, malformed or expired yields no write.
8399
+ * @returns The writes to hand to `settleWrites`.
8400
+ */
8401
+ private blacklistWrites;
8402
+ /**
8403
+ * Cleans up the session's metadata through `SessionService.revokeSession()`.
8404
+ *
8405
+ * It performs an atomic SISMEMBER ownership check before deleting `sd:{hash}` and SREMing from
8406
+ * `sess:{userId}`. The `rt:{hash}` DEL already ran — revokeSession's internal DEL is a no-op
8407
+ * (Redis DEL is idempotent when the key is absent). SESSION_NOT_FOUND means the session was
8408
+ * evicted, already revoked, or the refresh token does not belong to this user — in all cases
8409
+ * authentication is already invalidated.
8410
+ *
8411
+ * The tenant is REQUIRED to name the index, and it comes off the record rather than from the
8412
+ * caller. A record without one is a pre-upgrade write: the contract lists `tenantId` among the
8413
+ * refresh session's fields, so a live record always has it. Skipping the call is the honest end
8414
+ * for one that does not — `rt:{hash}` is already deleted, so the session is dead either way, and
8415
+ * guessing a tenant would name an index belonging to nobody while reading like a revocation that
8416
+ * happened.
8417
+ *
8418
+ * @param userId - The owner, empty when none is known.
8419
+ * @param tenantId - The owner's tenant, absent when the record carried none.
8420
+ * @param sessionHash - The SHA-256 of the raw refresh token.
8421
+ */
8422
+ private revokeSessionMetadata;
8330
8423
  /**
8331
8424
  * Announces a completed logout, the only hook `AuthService.logout` emits.
8332
8425
  *
@@ -8858,10 +8951,16 @@ declare class MfaService {
8858
8951
  * Detached from the challenge it follows: the user is already authenticated and the retired
8859
8952
  * key still opens the secret, so a failure here costs the migration and nothing else.
8860
8953
  *
8954
+ * The write replaces the whole MFA record, so it runs as a serialized transition and lands only
8955
+ * on a record that still holds this secret. One that no longer does was disabled or re-enrolled
8956
+ * since, and writing the re-encrypted old secret over it would restore a factor the user removed
8957
+ * and unspend the recovery codes they replaced. The comparison is on the decrypted secret, not
8958
+ * the ciphertext: a sibling challenge that only re-encrypted the same secret changes the
8959
+ * ciphertext and nothing else, and must not be mistaken for a re-enrolment.
8960
+ *
8861
8961
  * @param userId - The account whose stored secret is being re-encrypted.
8862
8962
  * @param context - Which identity plane the account belongs to.
8863
8963
  * @param secretBase32 - The decrypted secret.
8864
- * @param recoveryCodes - The stored recovery digests, written back unchanged.
8865
8964
  * @param tenantId - The tenant the account belongs to, so the write is scoped like the read.
8866
8965
  */
8867
8966
  private reencryptSecret;
@@ -8903,6 +9002,13 @@ declare class MfaService {
8903
9002
  * @throws {@link AuthException} `MFA_STATE_CONFLICT` when another transition holds the lock.
8904
9003
  */
8905
9004
  private transitionMfaRecord;
9005
+ /**
9006
+ * Whether `stored` decrypts, under the current or a retired key, to `secretBase32`.
9007
+ *
9008
+ * Compares plaintext, so a record that was only re-encrypted still matches and one holding a
9009
+ * different secret does not. A ciphertext no key opens does not match either.
9010
+ */
9011
+ private holdsSecret;
8906
9012
  /**
8907
9013
  * Encrypts a TOTP secret for storage in the database using AES-256-GCM.
8908
9014
  */
@@ -9967,6 +10073,18 @@ declare class PlatformAuthService {
9967
10073
  * @param rawRefreshToken - The raw opaque platform refresh token.
9968
10074
  */
9969
10075
  logout(accessToken: string, rawRefreshToken: string): Promise<string>;
10076
+ /**
10077
+ * The access-token blacklist write for a platform logout, or none when there is nothing to
10078
+ * revoke.
10079
+ *
10080
+ * Verifies signature and algorithm but not expiry: an expired token is the normal case here, a
10081
+ * forged one must not be able to blacklist an id it does not own. Only the verification is
10082
+ * tolerant: a token nobody can verify has nothing to blacklist, but a refused write is not.
10083
+ *
10084
+ * @param accessToken - Raw platform access token; absent, malformed or expired yields no write.
10085
+ * @returns The writes to hand to `settleWrites`.
10086
+ */
10087
+ private blacklistWrites;
9970
10088
  /**
9971
10089
  * Announces a completed platform logout, the only hook `PlatformAuthService` emits.
9972
10090
  *
@@ -11087,5 +11205,5 @@ declare class ApiKeyService {
11087
11205
  private validatedExpiry;
11088
11206
  }
11089
11207
 
11090
- 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 };
11091
- 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 };
11208
+ 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, RequestEncoding, RequestEncodingGuard, 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 };
11209
+ 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, RequestEncodingPolicy, ResolvedOptions, RevocableTokenPayload, RevokeAllExceptCurrentParams, RevokeAllSessionsParams, RevokeSessionParams, RotateApiKeyInput, RotatedTokenResult, SafeAuthPlatformUser, SafeAuthUser, SessionAlertInfo, SessionInfo, TenantResolverRequest, TenantScopedUserRef, UpdateEmailParams, UpdateEmailVerifiedParams, UpdateMfaData, UpdateMfaParams, UpdatePasswordParams, UpdatePlatformMfaData, UpdateStatusParams, VerifiedAccessToken, VerifyAccessTokenOptions, WsTicketSnapshot };
@@ -5679,6 +5679,41 @@ declare class AuthRateLimitGuard implements CanActivate {
5679
5679
  private clientIp;
5680
5680
  }
5681
5681
 
5682
+ /**
5683
+ * Answers `415` for a request carrying a `Content-Encoding` other than `identity`.
5684
+ *
5685
+ * @remarks
5686
+ * Whether a compressed request body is decompressed is the host's body parser's decision, not the
5687
+ * library's: Express's default inflates `gzip`, `deflate` and `br`, a host that sets
5688
+ * `inflate: false` refuses them, and a framework that does not decode accepts nothing. The
5689
+ * contract the library shares with its sibling is the stricter one, and a library that relies on
5690
+ * host configuration for it holds that contract only where the host happened to set it. So the
5691
+ * refusal is made here, before any handler.
5692
+ *
5693
+ * Auth payloads are a few hundred bytes and browsers do not compress request bodies, so nothing
5694
+ * legitimate is lost. The parser has already decompressed the body by the time a guard runs, and
5695
+ * its size limit counts decompressed bytes, so the work this guard declines to do is bounded by
5696
+ * that limit either way; the refusal is for the contract, with the parser-level `inflate: false`
5697
+ * refusing earlier on a host that sets it.
5698
+ *
5699
+ * The answer is an `HttpException` whose body already is the library's error envelope. The
5700
+ * optional `AuthExceptionFilter` passes such a body through untouched and, without it, Nest
5701
+ * serialises the same object, so the response is identical either way. It is not an
5702
+ * `AuthException` because the status of `auth.validation` in the error catalog is `400`, one
5703
+ * status per code.
5704
+ */
5705
+ declare class RequestEncodingGuard implements CanActivate {
5706
+ private readonly reflector;
5707
+ constructor(reflector: Reflector);
5708
+ /**
5709
+ * @param context - The execution context of the request.
5710
+ * @returns `true` when the route does not check, the request declares no encoding or only
5711
+ * `identity`, or the route checks only requests with a body and this one has none.
5712
+ * @throws {@link HttpException} `415` in the `auth.validation` envelope otherwise.
5713
+ */
5714
+ canActivate(context: ExecutionContext): boolean;
5715
+ }
5716
+
5682
5717
  /**
5683
5718
  * Blocks a cross-site request that would otherwise be authenticated by the browser's ambient
5684
5719
  * session cookie.
@@ -6307,6 +6342,33 @@ declare const IS_PUBLIC_KEY: unique symbol;
6307
6342
  */
6308
6343
  declare const Public: () => MethodDecorator & ClassDecorator;
6309
6344
 
6345
+ /**
6346
+ * How a route treats a request whose `Content-Encoding` is not `identity`.
6347
+ *
6348
+ * - `'unchecked'`: never refused. The routes that take no JSON body to decode (refresh, logout,
6349
+ * revoke-all, a ticket request) and that the shared contract leaves unchecked.
6350
+ * - `'when-body'`: refused only when the request carries a body. The MFA setup routes take an
6351
+ * optional body, and an empty one takes the default.
6352
+ *
6353
+ * A route with no policy is strict: every non-`identity` encoding is refused, so a route added
6354
+ * later is checked unless someone says it should not be.
6355
+ */
6356
+ type RequestEncodingPolicy = 'unchecked' | 'when-body';
6357
+ /**
6358
+ * Sets how strictly {@link RequestEncodingGuard} checks the route's `Content-Encoding`.
6359
+ *
6360
+ * @param policy - See {@link RequestEncodingPolicy}.
6361
+ * @returns A method decorator.
6362
+ *
6363
+ * @example
6364
+ * ```typescript
6365
+ * @RequestEncoding('unchecked')
6366
+ * @Post('refresh')
6367
+ * refresh() { ... }
6368
+ * ```
6369
+ */
6370
+ declare const RequestEncoding: (policy: RequestEncodingPolicy) => MethodDecorator;
6371
+
6310
6372
  /**
6311
6373
  * Metadata key used by {@link RolesGuard} to read the required roles for a route.
6312
6374
  *
@@ -8327,6 +8389,37 @@ declare class AuthService {
8327
8389
  * matched the presented refresh token (already logged out, or expired).
8328
8390
  */
8329
8391
  logout(accessToken: string, rawRefreshToken: string): Promise<string>;
8392
+ /**
8393
+ * The access-token blacklist write for a logout, or none when there is nothing to revoke.
8394
+ *
8395
+ * Verifies signature and algorithm but not expiry: an expired token is the normal case here, a
8396
+ * forged one must not blacklist an id it does not own. Only the verification is tolerant.
8397
+ *
8398
+ * @param accessToken - Raw access token; absent, malformed or expired yields no write.
8399
+ * @returns The writes to hand to `settleWrites`.
8400
+ */
8401
+ private blacklistWrites;
8402
+ /**
8403
+ * Cleans up the session's metadata through `SessionService.revokeSession()`.
8404
+ *
8405
+ * It performs an atomic SISMEMBER ownership check before deleting `sd:{hash}` and SREMing from
8406
+ * `sess:{userId}`. The `rt:{hash}` DEL already ran — revokeSession's internal DEL is a no-op
8407
+ * (Redis DEL is idempotent when the key is absent). SESSION_NOT_FOUND means the session was
8408
+ * evicted, already revoked, or the refresh token does not belong to this user — in all cases
8409
+ * authentication is already invalidated.
8410
+ *
8411
+ * The tenant is REQUIRED to name the index, and it comes off the record rather than from the
8412
+ * caller. A record without one is a pre-upgrade write: the contract lists `tenantId` among the
8413
+ * refresh session's fields, so a live record always has it. Skipping the call is the honest end
8414
+ * for one that does not — `rt:{hash}` is already deleted, so the session is dead either way, and
8415
+ * guessing a tenant would name an index belonging to nobody while reading like a revocation that
8416
+ * happened.
8417
+ *
8418
+ * @param userId - The owner, empty when none is known.
8419
+ * @param tenantId - The owner's tenant, absent when the record carried none.
8420
+ * @param sessionHash - The SHA-256 of the raw refresh token.
8421
+ */
8422
+ private revokeSessionMetadata;
8330
8423
  /**
8331
8424
  * Announces a completed logout, the only hook `AuthService.logout` emits.
8332
8425
  *
@@ -8858,10 +8951,16 @@ declare class MfaService {
8858
8951
  * Detached from the challenge it follows: the user is already authenticated and the retired
8859
8952
  * key still opens the secret, so a failure here costs the migration and nothing else.
8860
8953
  *
8954
+ * The write replaces the whole MFA record, so it runs as a serialized transition and lands only
8955
+ * on a record that still holds this secret. One that no longer does was disabled or re-enrolled
8956
+ * since, and writing the re-encrypted old secret over it would restore a factor the user removed
8957
+ * and unspend the recovery codes they replaced. The comparison is on the decrypted secret, not
8958
+ * the ciphertext: a sibling challenge that only re-encrypted the same secret changes the
8959
+ * ciphertext and nothing else, and must not be mistaken for a re-enrolment.
8960
+ *
8861
8961
  * @param userId - The account whose stored secret is being re-encrypted.
8862
8962
  * @param context - Which identity plane the account belongs to.
8863
8963
  * @param secretBase32 - The decrypted secret.
8864
- * @param recoveryCodes - The stored recovery digests, written back unchanged.
8865
8964
  * @param tenantId - The tenant the account belongs to, so the write is scoped like the read.
8866
8965
  */
8867
8966
  private reencryptSecret;
@@ -8903,6 +9002,13 @@ declare class MfaService {
8903
9002
  * @throws {@link AuthException} `MFA_STATE_CONFLICT` when another transition holds the lock.
8904
9003
  */
8905
9004
  private transitionMfaRecord;
9005
+ /**
9006
+ * Whether `stored` decrypts, under the current or a retired key, to `secretBase32`.
9007
+ *
9008
+ * Compares plaintext, so a record that was only re-encrypted still matches and one holding a
9009
+ * different secret does not. A ciphertext no key opens does not match either.
9010
+ */
9011
+ private holdsSecret;
8906
9012
  /**
8907
9013
  * Encrypts a TOTP secret for storage in the database using AES-256-GCM.
8908
9014
  */
@@ -9967,6 +10073,18 @@ declare class PlatformAuthService {
9967
10073
  * @param rawRefreshToken - The raw opaque platform refresh token.
9968
10074
  */
9969
10075
  logout(accessToken: string, rawRefreshToken: string): Promise<string>;
10076
+ /**
10077
+ * The access-token blacklist write for a platform logout, or none when there is nothing to
10078
+ * revoke.
10079
+ *
10080
+ * Verifies signature and algorithm but not expiry: an expired token is the normal case here, a
10081
+ * forged one must not be able to blacklist an id it does not own. Only the verification is
10082
+ * tolerant: a token nobody can verify has nothing to blacklist, but a refused write is not.
10083
+ *
10084
+ * @param accessToken - Raw platform access token; absent, malformed or expired yields no write.
10085
+ * @returns The writes to hand to `settleWrites`.
10086
+ */
10087
+ private blacklistWrites;
9970
10088
  /**
9971
10089
  * Announces a completed platform logout, the only hook `PlatformAuthService` emits.
9972
10090
  *
@@ -11087,5 +11205,5 @@ declare class ApiKeyService {
11087
11205
  private validatedExpiry;
11088
11206
  }
11089
11207
 
11090
- 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 };
11091
- 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 };
11208
+ 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, RequestEncoding, RequestEncodingGuard, 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 };
11209
+ 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, RequestEncodingPolicy, ResolvedOptions, RevocableTokenPayload, RevokeAllExceptCurrentParams, RevokeAllSessionsParams, RevokeSessionParams, RotateApiKeyInput, RotatedTokenResult, SafeAuthPlatformUser, SafeAuthUser, SessionAlertInfo, SessionInfo, TenantResolverRequest, TenantScopedUserRef, UpdateEmailParams, UpdateEmailVerifiedParams, UpdateMfaData, UpdateMfaParams, UpdatePasswordParams, UpdatePlatformMfaData, UpdateStatusParams, VerifiedAccessToken, VerifyAccessTokenOptions, WsTicketSnapshot };