@bymax-one/nest-auth 1.2.0 → 1.3.1

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.
@@ -3,7 +3,7 @@ import { JwtService, JwtModule } from '@nestjs/jwt';
3
3
  import { randomInt, scrypt as scrypt$1, randomBytes, timingSafeEqual, randomUUID, createHash, createHmac, createCipheriv, createDecipheriv } from 'crypto';
4
4
  import { Throttle } from '@nestjs/throttler';
5
5
  import { Transform } from 'class-transformer';
6
- import { IsEmail, MaxLength, IsString, MinLength, IsNotEmpty, Matches, Length, IsOptional, ValidateIf } from 'class-validator';
6
+ import { IsEmail, MaxLength, IsString, MinLength, IsOptional, IsNotEmpty, Matches, Length, ValidateIf } from 'class-validator';
7
7
  import { Reflector } from '@nestjs/core';
8
8
  import { isIPv6 } from 'net';
9
9
  import { promisify } from 'util';
@@ -1184,6 +1184,7 @@ _ts_decorate([
1184
1184
  _ts_metadata("design:type", String)
1185
1185
  ], LoginDto.prototype, "password", void 0);
1186
1186
  _ts_decorate([
1187
+ IsOptional(),
1187
1188
  IsString(),
1188
1189
  IsNotEmpty(),
1189
1190
  MaxLength(128),
@@ -1265,6 +1266,7 @@ _ts_decorate2([
1265
1266
  _ts_metadata2("design:type", String)
1266
1267
  ], RegisterDto.prototype, "name", void 0);
1267
1268
  _ts_decorate2([
1269
+ IsOptional(),
1268
1270
  IsString(),
1269
1271
  IsNotEmpty(),
1270
1272
  MaxLength(128),
@@ -1305,6 +1307,7 @@ _ts_decorate3([
1305
1307
  _ts_metadata3("design:type", String)
1306
1308
  ], ResendVerificationDto.prototype, "email", void 0);
1307
1309
  _ts_decorate3([
1310
+ IsOptional(),
1308
1311
  IsString(),
1309
1312
  IsNotEmpty(),
1310
1313
  MaxLength(128),
@@ -1356,6 +1359,7 @@ _ts_decorate4([
1356
1359
  _ts_metadata4("design:type", String)
1357
1360
  ], VerifyEmailDto.prototype, "otp", void 0);
1358
1361
  _ts_decorate4([
1362
+ IsOptional(),
1359
1363
  IsString(),
1360
1364
  IsNotEmpty(),
1361
1365
  MaxLength(128),
@@ -2682,6 +2686,100 @@ AuthRateLimitGuard = _ts_decorate6([
2682
2686
  typeof AuthRedisService === "undefined" ? Object : AuthRedisService
2683
2687
  ])
2684
2688
  ], AuthRateLimitGuard);
2689
+
2690
+ // src/server/utils/assert-not-blocked.ts
2691
+ var BLOCKED_STATUS_CODES = /* @__PURE__ */ new Map([
2692
+ [
2693
+ "banned",
2694
+ AUTH_ERROR_CODES.ACCOUNT_BANNED
2695
+ ],
2696
+ [
2697
+ "suspended",
2698
+ AUTH_ERROR_CODES.ACCOUNT_SUSPENDED
2699
+ ],
2700
+ [
2701
+ "pending",
2702
+ AUTH_ERROR_CODES.PENDING_APPROVAL
2703
+ ],
2704
+ [
2705
+ "pending_approval",
2706
+ AUTH_ERROR_CODES.PENDING_APPROVAL
2707
+ ]
2708
+ ]);
2709
+ function assertNotBlocked(status, blockedStatuses) {
2710
+ const canonical = status.toLowerCase();
2711
+ if (!blockedStatuses.some((blocked) => blocked.toLowerCase() === canonical)) {
2712
+ return;
2713
+ }
2714
+ throw new AuthException(BLOCKED_STATUS_CODES.get(canonical) ?? AUTH_ERROR_CODES.ACCOUNT_INACTIVE, 403);
2715
+ }
2716
+ __name(assertNotBlocked, "assertNotBlocked");
2717
+
2718
+ // src/server/utils/stamped-epoch.ts
2719
+ function readStampedEpoch(payload) {
2720
+ const { epoch } = payload;
2721
+ return typeof epoch === "number" && Number.isInteger(epoch) ? Math.max(0, epoch) : 0;
2722
+ }
2723
+ __name(readStampedEpoch, "readStampedEpoch");
2724
+
2725
+ // src/server/utils/sanitize-headers.ts
2726
+ var BLOCKED_HEADERS = /* @__PURE__ */ new Set([
2727
+ "authorization",
2728
+ "cookie",
2729
+ "proxy-authorization",
2730
+ "www-authenticate",
2731
+ // Stryker disable next-line StringLiteral: 'x-api-key' is also matched by SENSITIVE_HEADER_PATTERN (ends with -key), so removing it from the Set does not change the filter result
2732
+ "x-api-key",
2733
+ // Stryker disable next-line StringLiteral: 'x-auth-token' is also matched by SENSITIVE_HEADER_PATTERN (ends with -token), so removing it from the Set does not change the filter result
2734
+ "x-auth-token",
2735
+ // Stryker disable next-line StringLiteral: 'x-csrf-token' is also matched by SENSITIVE_HEADER_PATTERN (ends with -token), so removing it from the Set does not change the filter result
2736
+ "x-csrf-token",
2737
+ "x-session-id",
2738
+ "x-forwarded-for",
2739
+ "x-forwarded-host",
2740
+ "x-real-ip",
2741
+ "x-original-forwarded-for",
2742
+ "cf-connecting-ip",
2743
+ "true-client-ip",
2744
+ "x-cluster-client-ip"
2745
+ ]);
2746
+ var SENSITIVE_HEADER_PATTERN = /^x-.*-(token|secret|key|password|credential|auth|bearer|signature|hmac)$/i;
2747
+ function sanitizeHeaders(headers) {
2748
+ return Object.fromEntries(Object.entries(headers).map(([key, value]) => [
2749
+ key.toLowerCase(),
2750
+ value
2751
+ ]).filter(([key]) => !BLOCKED_HEADERS.has(key) && !SENSITIVE_HEADER_PATTERN.test(key)));
2752
+ }
2753
+ __name(sanitizeHeaders, "sanitizeHeaders");
2754
+ function createEmptyHookContext() {
2755
+ return {
2756
+ ip: "",
2757
+ userAgent: "",
2758
+ sanitizedHeaders: {}
2759
+ };
2760
+ }
2761
+ __name(createEmptyHookContext, "createEmptyHookContext");
2762
+
2763
+ // src/server/utils/sleep.ts
2764
+ var MAX_SLEEP_MS = 1e4;
2765
+ function sleep(ms) {
2766
+ const clamped = Math.min(Math.max(0, ms), MAX_SLEEP_MS);
2767
+ return new Promise((resolve) => {
2768
+ setTimeout(resolve, clamped);
2769
+ });
2770
+ }
2771
+ __name(sleep, "sleep");
2772
+
2773
+ // src/server/utils/roles.util.ts
2774
+ function hasRole(userRole, requiredRole, hierarchy) {
2775
+ if (userRole === requiredRole) return true;
2776
+ if (!Object.hasOwn(hierarchy, userRole)) return false;
2777
+ const inherited = hierarchy[userRole];
2778
+ return inherited !== void 0 && inherited.includes(requiredRole);
2779
+ }
2780
+ __name(hasRole, "hasRole");
2781
+
2782
+ // src/server/services/auth-revocation.service.ts
2685
2783
  function _ts_decorate7(decorators, target, key, desc) {
2686
2784
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2687
2785
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -2699,6 +2797,58 @@ function _ts_param3(paramIndex, decorator) {
2699
2797
  };
2700
2798
  }
2701
2799
  __name(_ts_param3, "_ts_param");
2800
+ var AuthRevocationService = class {
2801
+ static {
2802
+ __name(this, "AuthRevocationService");
2803
+ }
2804
+ redis;
2805
+ /**
2806
+ * @param redis - The auth module's Redis service, holding both revocation channels.
2807
+ */
2808
+ constructor(redis) {
2809
+ this.redis = redis;
2810
+ }
2811
+ /**
2812
+ * Whether a verified access token has been revoked.
2813
+ *
2814
+ * @param payload - The verified token's `jti`, `sub` and stamped `epoch`.
2815
+ * @param kind - Which plane the token belongs to; selects the epoch namespace, defaulting to the
2816
+ * dashboard plane an ordinary user token uses. The per-token blacklist is shared across planes.
2817
+ * @returns `true` when the token is on the blacklist or predates the user's current epoch.
2818
+ */
2819
+ async isAccessTokenRevoked(payload, kind = "dashboard") {
2820
+ if (await this.redis.get(`rv:${payload.jti}`) !== null) {
2821
+ return true;
2822
+ }
2823
+ const epoch = await this.redis.getUserTokenEpoch(payload.sub, kind);
2824
+ return readStampedEpoch(payload) < epoch;
2825
+ }
2826
+ };
2827
+ AuthRevocationService = _ts_decorate7([
2828
+ Injectable(),
2829
+ _ts_param3(0, Inject(AuthRedisService)),
2830
+ _ts_metadata7("design:type", Function),
2831
+ _ts_metadata7("design:paramtypes", [
2832
+ typeof AuthRedisService === "undefined" ? Object : AuthRedisService
2833
+ ])
2834
+ ], AuthRevocationService);
2835
+ function _ts_decorate8(decorators, target, key, desc) {
2836
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2837
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2838
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2839
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2840
+ }
2841
+ __name(_ts_decorate8, "_ts_decorate");
2842
+ function _ts_metadata8(k, v) {
2843
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2844
+ }
2845
+ __name(_ts_metadata8, "_ts_metadata");
2846
+ function _ts_param4(paramIndex, decorator) {
2847
+ return function(target, key) {
2848
+ decorator(target, key, paramIndex);
2849
+ };
2850
+ }
2851
+ __name(_ts_param4, "_ts_param");
2702
2852
  var HOSTNAME_RE = /^[a-z0-9.-]+$/i;
2703
2853
  var TokenDeliveryService = class {
2704
2854
  static {
@@ -2987,107 +3137,15 @@ var TokenDeliveryService = class {
2987
3137
  return typeof value === "string" ? value : void 0;
2988
3138
  }
2989
3139
  };
2990
- TokenDeliveryService = _ts_decorate7([
3140
+ TokenDeliveryService = _ts_decorate8([
2991
3141
  Injectable(),
2992
- _ts_param3(0, Inject(BYMAX_AUTH_OPTIONS)),
2993
- _ts_metadata7("design:type", Function),
2994
- _ts_metadata7("design:paramtypes", [
3142
+ _ts_param4(0, Inject(BYMAX_AUTH_OPTIONS)),
3143
+ _ts_metadata8("design:type", Function),
3144
+ _ts_metadata8("design:paramtypes", [
2995
3145
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
2996
3146
  ])
2997
3147
  ], TokenDeliveryService);
2998
3148
 
2999
- // src/server/utils/assert-not-blocked.ts
3000
- var BLOCKED_STATUS_CODES = /* @__PURE__ */ new Map([
3001
- [
3002
- "banned",
3003
- AUTH_ERROR_CODES.ACCOUNT_BANNED
3004
- ],
3005
- [
3006
- "suspended",
3007
- AUTH_ERROR_CODES.ACCOUNT_SUSPENDED
3008
- ],
3009
- [
3010
- "pending",
3011
- AUTH_ERROR_CODES.PENDING_APPROVAL
3012
- ],
3013
- [
3014
- "pending_approval",
3015
- AUTH_ERROR_CODES.PENDING_APPROVAL
3016
- ]
3017
- ]);
3018
- function assertNotBlocked(status, blockedStatuses) {
3019
- const canonical = status.toLowerCase();
3020
- if (!blockedStatuses.some((blocked) => blocked.toLowerCase() === canonical)) {
3021
- return;
3022
- }
3023
- throw new AuthException(BLOCKED_STATUS_CODES.get(canonical) ?? AUTH_ERROR_CODES.ACCOUNT_INACTIVE, 403);
3024
- }
3025
- __name(assertNotBlocked, "assertNotBlocked");
3026
-
3027
- // src/server/utils/stamped-epoch.ts
3028
- function readStampedEpoch(payload) {
3029
- const { epoch } = payload;
3030
- return typeof epoch === "number" && Number.isInteger(epoch) ? Math.max(0, epoch) : 0;
3031
- }
3032
- __name(readStampedEpoch, "readStampedEpoch");
3033
-
3034
- // src/server/utils/sanitize-headers.ts
3035
- var BLOCKED_HEADERS = /* @__PURE__ */ new Set([
3036
- "authorization",
3037
- "cookie",
3038
- "proxy-authorization",
3039
- "www-authenticate",
3040
- // Stryker disable next-line StringLiteral: 'x-api-key' is also matched by SENSITIVE_HEADER_PATTERN (ends with -key), so removing it from the Set does not change the filter result
3041
- "x-api-key",
3042
- // Stryker disable next-line StringLiteral: 'x-auth-token' is also matched by SENSITIVE_HEADER_PATTERN (ends with -token), so removing it from the Set does not change the filter result
3043
- "x-auth-token",
3044
- // Stryker disable next-line StringLiteral: 'x-csrf-token' is also matched by SENSITIVE_HEADER_PATTERN (ends with -token), so removing it from the Set does not change the filter result
3045
- "x-csrf-token",
3046
- "x-session-id",
3047
- "x-forwarded-for",
3048
- "x-forwarded-host",
3049
- "x-real-ip",
3050
- "x-original-forwarded-for",
3051
- "cf-connecting-ip",
3052
- "true-client-ip",
3053
- "x-cluster-client-ip"
3054
- ]);
3055
- var SENSITIVE_HEADER_PATTERN = /^x-.*-(token|secret|key|password|credential|auth|bearer|signature|hmac)$/i;
3056
- function sanitizeHeaders(headers) {
3057
- return Object.fromEntries(Object.entries(headers).map(([key, value]) => [
3058
- key.toLowerCase(),
3059
- value
3060
- ]).filter(([key]) => !BLOCKED_HEADERS.has(key) && !SENSITIVE_HEADER_PATTERN.test(key)));
3061
- }
3062
- __name(sanitizeHeaders, "sanitizeHeaders");
3063
- function createEmptyHookContext() {
3064
- return {
3065
- ip: "",
3066
- userAgent: "",
3067
- sanitizedHeaders: {}
3068
- };
3069
- }
3070
- __name(createEmptyHookContext, "createEmptyHookContext");
3071
-
3072
- // src/server/utils/sleep.ts
3073
- var MAX_SLEEP_MS = 1e4;
3074
- function sleep(ms) {
3075
- const clamped = Math.min(Math.max(0, ms), MAX_SLEEP_MS);
3076
- return new Promise((resolve) => {
3077
- setTimeout(resolve, clamped);
3078
- });
3079
- }
3080
- __name(sleep, "sleep");
3081
-
3082
- // src/server/utils/roles.util.ts
3083
- function hasRole(userRole, requiredRole, hierarchy) {
3084
- if (userRole === requiredRole) return true;
3085
- if (!Object.hasOwn(hierarchy, userRole)) return false;
3086
- const inherited = hierarchy[userRole];
3087
- return inherited !== void 0 && inherited.includes(requiredRole);
3088
- }
3089
- __name(hasRole, "hasRole");
3090
-
3091
3149
  // src/server/utils/verify-with-rotation.ts
3092
3150
  function verifyWithRotation(jwtService, options, token, { ignoreExpiration = false } = {}) {
3093
3151
  const algorithms = [
@@ -3141,36 +3199,36 @@ function assertValidSub(sub) {
3141
3199
  __name(assertValidSub, "assertValidSub");
3142
3200
 
3143
3201
  // src/server/guards/jwt-auth.guard.ts
3144
- function _ts_decorate8(decorators, target, key, desc) {
3202
+ function _ts_decorate9(decorators, target, key, desc) {
3145
3203
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3146
3204
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3147
3205
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3148
3206
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3149
3207
  }
3150
- __name(_ts_decorate8, "_ts_decorate");
3151
- function _ts_metadata8(k, v) {
3208
+ __name(_ts_decorate9, "_ts_decorate");
3209
+ function _ts_metadata9(k, v) {
3152
3210
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3153
3211
  }
3154
- __name(_ts_metadata8, "_ts_metadata");
3155
- function _ts_param4(paramIndex, decorator) {
3212
+ __name(_ts_metadata9, "_ts_metadata");
3213
+ function _ts_param5(paramIndex, decorator) {
3156
3214
  return function(target, key) {
3157
3215
  decorator(target, key, paramIndex);
3158
3216
  };
3159
3217
  }
3160
- __name(_ts_param4, "_ts_param");
3218
+ __name(_ts_param5, "_ts_param");
3161
3219
  var JwtAuthGuard = class {
3162
3220
  static {
3163
3221
  __name(this, "JwtAuthGuard");
3164
3222
  }
3165
3223
  jwtService;
3166
3224
  tokenDelivery;
3167
- redis;
3225
+ revocation;
3168
3226
  reflector;
3169
3227
  options;
3170
- constructor(jwtService, tokenDelivery, redis, reflector, options) {
3228
+ constructor(jwtService, tokenDelivery, revocation, reflector, options) {
3171
3229
  this.jwtService = jwtService;
3172
3230
  this.tokenDelivery = tokenDelivery;
3173
- this.redis = redis;
3231
+ this.revocation = revocation;
3174
3232
  this.reflector = reflector;
3175
3233
  this.options = options;
3176
3234
  }
@@ -3194,51 +3252,46 @@ var JwtAuthGuard = class {
3194
3252
  assertValidJti(payload.jti);
3195
3253
  assertValidSub(payload.sub);
3196
3254
  assertTokenType(payload, "dashboard");
3197
- const revoked = await this.redis.get(`rv:${payload.jti}`);
3198
- if (revoked !== null) {
3199
- throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
3200
- }
3201
- const epoch = await this.redis.getUserTokenEpoch(payload.sub);
3202
- if (readStampedEpoch(payload) < epoch) {
3255
+ if (await this.revocation.isAccessTokenRevoked(payload)) {
3203
3256
  throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
3204
3257
  }
3205
3258
  request.user = payload;
3206
3259
  return true;
3207
3260
  }
3208
3261
  };
3209
- JwtAuthGuard = _ts_decorate8([
3262
+ JwtAuthGuard = _ts_decorate9([
3210
3263
  Injectable(),
3211
- _ts_param4(0, Inject(JwtService)),
3212
- _ts_param4(1, Inject(TokenDeliveryService)),
3213
- _ts_param4(2, Inject(AuthRedisService)),
3214
- _ts_param4(3, Inject(Reflector)),
3215
- _ts_param4(4, Inject(BYMAX_AUTH_OPTIONS)),
3216
- _ts_metadata8("design:type", Function),
3217
- _ts_metadata8("design:paramtypes", [
3264
+ _ts_param5(0, Inject(JwtService)),
3265
+ _ts_param5(1, Inject(TokenDeliveryService)),
3266
+ _ts_param5(2, Inject(AuthRevocationService)),
3267
+ _ts_param5(3, Inject(Reflector)),
3268
+ _ts_param5(4, Inject(BYMAX_AUTH_OPTIONS)),
3269
+ _ts_metadata9("design:type", Function),
3270
+ _ts_metadata9("design:paramtypes", [
3218
3271
  typeof JwtService === "undefined" ? Object : JwtService,
3219
3272
  typeof TokenDeliveryService === "undefined" ? Object : TokenDeliveryService,
3220
- typeof AuthRedisService === "undefined" ? Object : AuthRedisService,
3273
+ typeof AuthRevocationService === "undefined" ? Object : AuthRevocationService,
3221
3274
  typeof Reflector === "undefined" ? Object : Reflector,
3222
3275
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
3223
3276
  ])
3224
3277
  ], JwtAuthGuard);
3225
- function _ts_decorate9(decorators, target, key, desc) {
3278
+ function _ts_decorate10(decorators, target, key, desc) {
3226
3279
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3227
3280
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3228
3281
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3229
3282
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3230
3283
  }
3231
- __name(_ts_decorate9, "_ts_decorate");
3232
- function _ts_metadata9(k, v) {
3233
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3284
+ __name(_ts_decorate10, "_ts_decorate");
3285
+ function _ts_metadata10(k, v) {
3286
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3234
3287
  }
3235
- __name(_ts_metadata9, "_ts_metadata");
3236
- function _ts_param5(paramIndex, decorator) {
3288
+ __name(_ts_metadata10, "_ts_metadata");
3289
+ function _ts_param6(paramIndex, decorator) {
3237
3290
  return function(target, key) {
3238
3291
  decorator(target, key, paramIndex);
3239
3292
  };
3240
3293
  }
3241
- __name(_ts_param5, "_ts_param");
3294
+ __name(_ts_param6, "_ts_param");
3242
3295
  var SAFE_METHODS = /* @__PURE__ */ new Set([
3243
3296
  "GET",
3244
3297
  "HEAD",
@@ -3276,31 +3329,31 @@ var TrustedOriginGuard = class {
3276
3329
  return true;
3277
3330
  }
3278
3331
  };
3279
- TrustedOriginGuard = _ts_decorate9([
3332
+ TrustedOriginGuard = _ts_decorate10([
3280
3333
  Injectable(),
3281
- _ts_param5(0, Inject(BYMAX_AUTH_OPTIONS)),
3282
- _ts_metadata9("design:type", Function),
3283
- _ts_metadata9("design:paramtypes", [
3334
+ _ts_param6(0, Inject(BYMAX_AUTH_OPTIONS)),
3335
+ _ts_metadata10("design:type", Function),
3336
+ _ts_metadata10("design:paramtypes", [
3284
3337
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
3285
3338
  ])
3286
3339
  ], TrustedOriginGuard);
3287
- function _ts_decorate10(decorators, target, key, desc) {
3340
+ function _ts_decorate11(decorators, target, key, desc) {
3288
3341
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3289
3342
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3290
3343
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3291
3344
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3292
3345
  }
3293
- __name(_ts_decorate10, "_ts_decorate");
3294
- function _ts_metadata10(k, v) {
3346
+ __name(_ts_decorate11, "_ts_decorate");
3347
+ function _ts_metadata11(k, v) {
3295
3348
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3296
3349
  }
3297
- __name(_ts_metadata10, "_ts_metadata");
3298
- function _ts_param6(paramIndex, decorator) {
3350
+ __name(_ts_metadata11, "_ts_metadata");
3351
+ function _ts_param7(paramIndex, decorator) {
3299
3352
  return function(target, key) {
3300
3353
  decorator(target, key, paramIndex);
3301
3354
  };
3302
3355
  }
3303
- __name(_ts_param6, "_ts_param");
3356
+ __name(_ts_param7, "_ts_param");
3304
3357
  var UserStatusGuard = class {
3305
3358
  static {
3306
3359
  __name(this, "UserStatusGuard");
@@ -3333,25 +3386,25 @@ var UserStatusGuard = class {
3333
3386
  return true;
3334
3387
  }
3335
3388
  };
3336
- UserStatusGuard = _ts_decorate10([
3389
+ UserStatusGuard = _ts_decorate11([
3337
3390
  Injectable(),
3338
- _ts_param6(0, Inject(AuthRedisService)),
3339
- _ts_param6(1, Inject(BYMAX_AUTH_USER_REPOSITORY)),
3340
- _ts_param6(2, Inject(BYMAX_AUTH_OPTIONS)),
3341
- _ts_metadata10("design:type", Function),
3342
- _ts_metadata10("design:paramtypes", [
3391
+ _ts_param7(0, Inject(AuthRedisService)),
3392
+ _ts_param7(1, Inject(BYMAX_AUTH_USER_REPOSITORY)),
3393
+ _ts_param7(2, Inject(BYMAX_AUTH_OPTIONS)),
3394
+ _ts_metadata11("design:type", Function),
3395
+ _ts_metadata11("design:paramtypes", [
3343
3396
  typeof AuthRedisService === "undefined" ? Object : AuthRedisService,
3344
3397
  typeof IUserRepository === "undefined" ? Object : IUserRepository,
3345
3398
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
3346
3399
  ])
3347
3400
  ], UserStatusGuard);
3348
- function _ts_decorate11(decorators, target, key, desc) {
3401
+ function _ts_decorate12(decorators, target, key, desc) {
3349
3402
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3350
3403
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3351
3404
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3352
3405
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3353
3406
  }
3354
- __name(_ts_decorate11, "_ts_decorate");
3407
+ __name(_ts_decorate12, "_ts_decorate");
3355
3408
  var NoStoreInterceptor = class {
3356
3409
  static {
3357
3410
  __name(this, "NoStoreInterceptor");
@@ -3366,7 +3419,7 @@ var NoStoreInterceptor = class {
3366
3419
  return next.handle();
3367
3420
  }
3368
3421
  };
3369
- NoStoreInterceptor = _ts_decorate11([
3422
+ NoStoreInterceptor = _ts_decorate12([
3370
3423
  Injectable()
3371
3424
  ], NoStoreInterceptor);
3372
3425
  function flattenValidationErrors(errors, parentPath = "") {
@@ -3395,23 +3448,23 @@ function createAuthValidationPipe(options = {}) {
3395
3448
  });
3396
3449
  }
3397
3450
  __name(createAuthValidationPipe, "createAuthValidationPipe");
3398
- function _ts_decorate12(decorators, target, key, desc) {
3451
+ function _ts_decorate13(decorators, target, key, desc) {
3399
3452
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3400
3453
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3401
3454
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3402
3455
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3403
3456
  }
3404
- __name(_ts_decorate12, "_ts_decorate");
3405
- function _ts_metadata11(k, v) {
3457
+ __name(_ts_decorate13, "_ts_decorate");
3458
+ function _ts_metadata12(k, v) {
3406
3459
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3407
3460
  }
3408
- __name(_ts_metadata11, "_ts_metadata");
3409
- function _ts_param7(paramIndex, decorator) {
3461
+ __name(_ts_metadata12, "_ts_metadata");
3462
+ function _ts_param8(paramIndex, decorator) {
3410
3463
  return function(target, key) {
3411
3464
  decorator(target, key, paramIndex);
3412
3465
  };
3413
3466
  }
3414
- __name(_ts_param7, "_ts_param");
3467
+ __name(_ts_param8, "_ts_param");
3415
3468
  var LOCKOUT_PREFIX = "lf:";
3416
3469
  var MAX_IDENTIFIER_LENGTH = 512;
3417
3470
  var BruteForceService = class _BruteForceService {
@@ -3501,33 +3554,33 @@ var BruteForceService = class _BruteForceService {
3501
3554
  }
3502
3555
  }
3503
3556
  };
3504
- BruteForceService = _ts_decorate12([
3557
+ BruteForceService = _ts_decorate13([
3505
3558
  Injectable(),
3506
- _ts_param7(0, Inject(AuthRedisService)),
3507
- _ts_param7(1, Inject(BYMAX_AUTH_OPTIONS)),
3508
- _ts_metadata11("design:type", Function),
3509
- _ts_metadata11("design:paramtypes", [
3559
+ _ts_param8(0, Inject(AuthRedisService)),
3560
+ _ts_param8(1, Inject(BYMAX_AUTH_OPTIONS)),
3561
+ _ts_metadata12("design:type", Function),
3562
+ _ts_metadata12("design:paramtypes", [
3510
3563
  typeof AuthRedisService === "undefined" ? Object : AuthRedisService,
3511
3564
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
3512
3565
  ])
3513
3566
  ], BruteForceService);
3514
- function _ts_decorate13(decorators, target, key, desc) {
3567
+ function _ts_decorate14(decorators, target, key, desc) {
3515
3568
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3516
3569
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3517
3570
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3518
3571
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3519
3572
  }
3520
- __name(_ts_decorate13, "_ts_decorate");
3521
- function _ts_metadata12(k, v) {
3573
+ __name(_ts_decorate14, "_ts_decorate");
3574
+ function _ts_metadata13(k, v) {
3522
3575
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3523
3576
  }
3524
- __name(_ts_metadata12, "_ts_metadata");
3525
- function _ts_param8(paramIndex, decorator) {
3577
+ __name(_ts_metadata13, "_ts_metadata");
3578
+ function _ts_param9(paramIndex, decorator) {
3526
3579
  return function(target, key) {
3527
3580
  decorator(target, key, paramIndex);
3528
3581
  };
3529
3582
  }
3530
- __name(_ts_param8, "_ts_param");
3583
+ __name(_ts_param9, "_ts_param");
3531
3584
  var MAX_ATTEMPTS = 5;
3532
3585
  var MIN_VERIFY_MS = 100;
3533
3586
  var OTP_STORE_LUA = `
@@ -3664,31 +3717,31 @@ var OtpService = class {
3664
3717
  await sleep(Math.max(0, MIN_VERIFY_MS - (Date.now() - start)));
3665
3718
  }
3666
3719
  };
3667
- OtpService = _ts_decorate13([
3720
+ OtpService = _ts_decorate14([
3668
3721
  Injectable(),
3669
- _ts_param8(0, Inject(AuthRedisService)),
3670
- _ts_metadata12("design:type", Function),
3671
- _ts_metadata12("design:paramtypes", [
3722
+ _ts_param9(0, Inject(AuthRedisService)),
3723
+ _ts_metadata13("design:type", Function),
3724
+ _ts_metadata13("design:paramtypes", [
3672
3725
  typeof AuthRedisService === "undefined" ? Object : AuthRedisService
3673
3726
  ])
3674
3727
  ], OtpService);
3675
- function _ts_decorate14(decorators, target, key, desc) {
3728
+ function _ts_decorate15(decorators, target, key, desc) {
3676
3729
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3677
3730
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3678
3731
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3679
3732
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3680
3733
  }
3681
- __name(_ts_decorate14, "_ts_decorate");
3682
- function _ts_metadata13(k, v) {
3734
+ __name(_ts_decorate15, "_ts_decorate");
3735
+ function _ts_metadata14(k, v) {
3683
3736
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3684
3737
  }
3685
- __name(_ts_metadata13, "_ts_metadata");
3686
- function _ts_param9(paramIndex, decorator) {
3738
+ __name(_ts_metadata14, "_ts_metadata");
3739
+ function _ts_param10(paramIndex, decorator) {
3687
3740
  return function(target, key) {
3688
3741
  decorator(target, key, paramIndex);
3689
3742
  };
3690
3743
  }
3691
- __name(_ts_param9, "_ts_param");
3744
+ __name(_ts_param10, "_ts_param");
3692
3745
  var scrypt = promisify(scrypt$1);
3693
3746
  var SCRYPT_KEY_LEN = 64;
3694
3747
  var SALT_BYTES = 16;
@@ -3972,33 +4025,33 @@ var PasswordService = class _PasswordService {
3972
4025
  return timingSafeEqual(candidate, DUMMY_EXPECTED);
3973
4026
  }
3974
4027
  };
3975
- PasswordService = _ts_decorate14([
4028
+ PasswordService = _ts_decorate15([
3976
4029
  Injectable(),
3977
- _ts_param9(0, Inject(BYMAX_AUTH_OPTIONS)),
3978
- _ts_param9(1, Inject(BYMAX_AUTH_BREACH_CHECKER)),
3979
- _ts_metadata13("design:type", Function),
3980
- _ts_metadata13("design:paramtypes", [
4030
+ _ts_param10(0, Inject(BYMAX_AUTH_OPTIONS)),
4031
+ _ts_param10(1, Inject(BYMAX_AUTH_BREACH_CHECKER)),
4032
+ _ts_metadata14("design:type", Function),
4033
+ _ts_metadata14("design:paramtypes", [
3981
4034
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
3982
4035
  typeof IPasswordBreachChecker === "undefined" ? Object : IPasswordBreachChecker
3983
4036
  ])
3984
4037
  ], PasswordService);
3985
- function _ts_decorate15(decorators, target, key, desc) {
4038
+ function _ts_decorate16(decorators, target, key, desc) {
3986
4039
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3987
4040
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3988
4041
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3989
4042
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3990
4043
  }
3991
- __name(_ts_decorate15, "_ts_decorate");
3992
- function _ts_metadata14(k, v) {
4044
+ __name(_ts_decorate16, "_ts_decorate");
4045
+ function _ts_metadata15(k, v) {
3993
4046
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3994
4047
  }
3995
- __name(_ts_metadata14, "_ts_metadata");
3996
- function _ts_param10(paramIndex, decorator) {
4048
+ __name(_ts_metadata15, "_ts_metadata");
4049
+ function _ts_param11(paramIndex, decorator) {
3997
4050
  return function(target, key) {
3998
4051
  decorator(target, key, paramIndex);
3999
4052
  };
4000
4053
  }
4001
- __name(_ts_param10, "_ts_param");
4054
+ __name(_ts_param11, "_ts_param");
4002
4055
  var MAX_IP_LENGTH = 45;
4003
4056
  var SESSION_HASH_RE = /^[a-f0-9]{64}$/;
4004
4057
  var REVOKE_SESSION_LUA = `
@@ -4504,15 +4557,15 @@ var SessionService = class _SessionService {
4504
4557
  }
4505
4558
  }
4506
4559
  };
4507
- SessionService = _ts_decorate15([
4560
+ SessionService = _ts_decorate16([
4508
4561
  Injectable(),
4509
- _ts_param10(0, Inject(BYMAX_AUTH_OPTIONS)),
4510
- _ts_param10(1, Inject(BYMAX_AUTH_USER_REPOSITORY)),
4511
- _ts_param10(2, Inject(BYMAX_AUTH_HOOKS)),
4512
- _ts_param10(2, Optional()),
4513
- _ts_param10(3, Inject(AuthRedisService)),
4514
- _ts_metadata14("design:type", Function),
4515
- _ts_metadata14("design:paramtypes", [
4562
+ _ts_param11(0, Inject(BYMAX_AUTH_OPTIONS)),
4563
+ _ts_param11(1, Inject(BYMAX_AUTH_USER_REPOSITORY)),
4564
+ _ts_param11(2, Inject(BYMAX_AUTH_HOOKS)),
4565
+ _ts_param11(2, Optional()),
4566
+ _ts_param11(3, Inject(AuthRedisService)),
4567
+ _ts_metadata15("design:type", Function),
4568
+ _ts_metadata15("design:paramtypes", [
4516
4569
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
4517
4570
  typeof IUserRepository === "undefined" ? Object : IUserRepository,
4518
4571
  Object,
@@ -4535,23 +4588,23 @@ function logSafe(value) {
4535
4588
  __name(logSafe, "logSafe");
4536
4589
 
4537
4590
  // src/server/services/token-manager.service.ts
4538
- function _ts_decorate16(decorators, target, key, desc) {
4591
+ function _ts_decorate17(decorators, target, key, desc) {
4539
4592
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4540
4593
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4541
4594
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4542
4595
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4543
4596
  }
4544
- __name(_ts_decorate16, "_ts_decorate");
4545
- function _ts_metadata15(k, v) {
4597
+ __name(_ts_decorate17, "_ts_decorate");
4598
+ function _ts_metadata16(k, v) {
4546
4599
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4547
4600
  }
4548
- __name(_ts_metadata15, "_ts_metadata");
4549
- function _ts_param11(paramIndex, decorator) {
4601
+ __name(_ts_metadata16, "_ts_metadata");
4602
+ function _ts_param12(paramIndex, decorator) {
4550
4603
  return function(target, key) {
4551
4604
  decorator(target, key, paramIndex);
4552
4605
  };
4553
4606
  }
4554
- __name(_ts_param11, "_ts_param");
4607
+ __name(_ts_param12, "_ts_param");
4555
4608
  var MFA_TEMP_TOKEN_TTL_SECONDS = 300;
4556
4609
  var MAX_SESSION_FIELD_LENGTH = 45;
4557
4610
  var TokenManagerService = class _TokenManagerService {
@@ -5347,15 +5400,15 @@ var TokenManagerService = class _TokenManagerService {
5347
5400
  return await this.redis.del(`mfa:${sha256(jti)}`);
5348
5401
  }
5349
5402
  };
5350
- TokenManagerService = _ts_decorate16([
5403
+ TokenManagerService = _ts_decorate17([
5351
5404
  Injectable(),
5352
- _ts_param11(0, Inject(JwtService)),
5353
- _ts_param11(1, Inject(BYMAX_AUTH_OPTIONS)),
5354
- _ts_param11(2, Inject(AuthRedisService)),
5355
- _ts_param11(3, Inject(BYMAX_AUTH_HOOKS)),
5356
- _ts_param11(3, Optional()),
5357
- _ts_metadata15("design:type", Function),
5358
- _ts_metadata15("design:paramtypes", [
5405
+ _ts_param12(0, Inject(JwtService)),
5406
+ _ts_param12(1, Inject(BYMAX_AUTH_OPTIONS)),
5407
+ _ts_param12(2, Inject(AuthRedisService)),
5408
+ _ts_param12(3, Inject(BYMAX_AUTH_HOOKS)),
5409
+ _ts_param12(3, Optional()),
5410
+ _ts_metadata16("design:type", Function),
5411
+ _ts_metadata16("design:paramtypes", [
5359
5412
  typeof JwtService === "undefined" ? Object : JwtService,
5360
5413
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
5361
5414
  typeof AuthRedisService === "undefined" ? Object : AuthRedisService,
@@ -5376,12 +5429,18 @@ function normalizeEmail(email) {
5376
5429
  return email.trim().toLowerCase();
5377
5430
  }
5378
5431
  __name(normalizeEmail, "normalizeEmail");
5379
-
5380
- // src/server/utils/resolve-tenant-id.ts
5381
5432
  async function resolveTenantId(dtoTenantId, req, resolver) {
5382
5433
  if (resolver) {
5383
5434
  return await resolver(req);
5384
5435
  }
5436
+ if (dtoTenantId === void 0 || dtoTenantId === null) {
5437
+ throw new AuthException(AUTH_ERROR_CODES.VALIDATION, HttpStatus.BAD_REQUEST, [
5438
+ {
5439
+ field: "tenantId",
5440
+ message: "tenantId is required unless the deployment configures tenantIdResolver"
5441
+ }
5442
+ ]);
5443
+ }
5385
5444
  return dtoTenantId;
5386
5445
  }
5387
5446
  __name(resolveTenantId, "resolveTenantId");
@@ -5394,23 +5453,23 @@ function tenantScoped(user, tenantId) {
5394
5453
  __name(tenantScoped, "tenantScoped");
5395
5454
 
5396
5455
  // src/server/services/auth.service.ts
5397
- function _ts_decorate17(decorators, target, key, desc) {
5456
+ function _ts_decorate18(decorators, target, key, desc) {
5398
5457
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5399
5458
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5400
5459
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5401
5460
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5402
5461
  }
5403
- __name(_ts_decorate17, "_ts_decorate");
5404
- function _ts_metadata16(k, v) {
5462
+ __name(_ts_decorate18, "_ts_decorate");
5463
+ function _ts_metadata17(k, v) {
5405
5464
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
5406
5465
  }
5407
- __name(_ts_metadata16, "_ts_metadata");
5408
- function _ts_param12(paramIndex, decorator) {
5466
+ __name(_ts_metadata17, "_ts_metadata");
5467
+ function _ts_param13(paramIndex, decorator) {
5409
5468
  return function(target, key) {
5410
5469
  decorator(target, key, paramIndex);
5411
5470
  };
5412
5471
  }
5413
- __name(_ts_param12, "_ts_param");
5472
+ __name(_ts_param13, "_ts_param");
5414
5473
  var ANTI_ENUM_MIN_MS = 300;
5415
5474
  var AuthService = class _AuthService {
5416
5475
  static {
@@ -6139,27 +6198,27 @@ var AuthService = class _AuthService {
6139
6198
  const ttl = this.options.emailVerification.otpTtlSeconds;
6140
6199
  const otp = this.otpService.generate(length);
6141
6200
  await this.otpService.store("email_verification", identifier, otp, ttl);
6142
- void this.emailProvider.sendEmailVerificationOtp(email, otp).catch((err) => {
6201
+ void this.emailProvider.sendEmailVerificationOtp(tenantId, email, otp).catch((err) => {
6143
6202
  this.logger.error(`sendEmailVerificationOtp failed for user ${userId}`, err);
6144
6203
  });
6145
6204
  }
6146
6205
  };
6147
- AuthService = _ts_decorate17([
6206
+ AuthService = _ts_decorate18([
6148
6207
  Injectable(),
6149
- _ts_param12(0, Inject(BYMAX_AUTH_OPTIONS)),
6150
- _ts_param12(1, Inject(BYMAX_AUTH_USER_REPOSITORY)),
6151
- _ts_param12(2, Inject(BYMAX_AUTH_EMAIL_PROVIDER)),
6152
- _ts_param12(2, Optional()),
6153
- _ts_param12(3, Inject(BYMAX_AUTH_HOOKS)),
6154
- _ts_param12(3, Optional()),
6155
- _ts_param12(4, Inject(PasswordService)),
6156
- _ts_param12(5, Inject(TokenManagerService)),
6157
- _ts_param12(6, Inject(BruteForceService)),
6158
- _ts_param12(7, Inject(AuthRedisService)),
6159
- _ts_param12(8, Inject(OtpService)),
6160
- _ts_param12(9, Inject(SessionService)),
6161
- _ts_metadata16("design:type", Function),
6162
- _ts_metadata16("design:paramtypes", [
6208
+ _ts_param13(0, Inject(BYMAX_AUTH_OPTIONS)),
6209
+ _ts_param13(1, Inject(BYMAX_AUTH_USER_REPOSITORY)),
6210
+ _ts_param13(2, Inject(BYMAX_AUTH_EMAIL_PROVIDER)),
6211
+ _ts_param13(2, Optional()),
6212
+ _ts_param13(3, Inject(BYMAX_AUTH_HOOKS)),
6213
+ _ts_param13(3, Optional()),
6214
+ _ts_param13(4, Inject(PasswordService)),
6215
+ _ts_param13(5, Inject(TokenManagerService)),
6216
+ _ts_param13(6, Inject(BruteForceService)),
6217
+ _ts_param13(7, Inject(AuthRedisService)),
6218
+ _ts_param13(8, Inject(OtpService)),
6219
+ _ts_param13(9, Inject(SessionService)),
6220
+ _ts_metadata17("design:type", Function),
6221
+ _ts_metadata17("design:paramtypes", [
6163
6222
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
6164
6223
  typeof IUserRepository === "undefined" ? Object : IUserRepository,
6165
6224
  Object,
@@ -6182,23 +6241,23 @@ __name(toSafeUser2, "toSafeUser");
6182
6241
  var WS_TICKET_TTL_SECONDS = 30;
6183
6242
 
6184
6243
  // src/server/services/ws-ticket.service.ts
6185
- function _ts_decorate18(decorators, target, key, desc) {
6244
+ function _ts_decorate19(decorators, target, key, desc) {
6186
6245
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6187
6246
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
6188
6247
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6189
6248
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6190
6249
  }
6191
- __name(_ts_decorate18, "_ts_decorate");
6192
- function _ts_metadata17(k, v) {
6250
+ __name(_ts_decorate19, "_ts_decorate");
6251
+ function _ts_metadata18(k, v) {
6193
6252
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
6194
6253
  }
6195
- __name(_ts_metadata17, "_ts_metadata");
6196
- function _ts_param13(paramIndex, decorator) {
6254
+ __name(_ts_metadata18, "_ts_metadata");
6255
+ function _ts_param14(paramIndex, decorator) {
6197
6256
  return function(target, key) {
6198
6257
  decorator(target, key, paramIndex);
6199
6258
  };
6200
6259
  }
6201
- __name(_ts_param13, "_ts_param");
6260
+ __name(_ts_param14, "_ts_param");
6202
6261
  var WsTicketService = class _WsTicketService {
6203
6262
  static {
6204
6263
  __name(this, "WsTicketService");
@@ -6266,13 +6325,13 @@ var WsTicketService = class _WsTicketService {
6266
6325
  return snapshot;
6267
6326
  }
6268
6327
  };
6269
- WsTicketService = _ts_decorate18([
6328
+ WsTicketService = _ts_decorate19([
6270
6329
  Injectable(),
6271
- _ts_param13(0, Inject(AuthRedisService)),
6272
- _ts_param13(1, Inject(BYMAX_AUTH_OPTIONS)),
6273
- _ts_param13(2, Inject(BYMAX_AUTH_USER_REPOSITORY)),
6274
- _ts_metadata17("design:type", Function),
6275
- _ts_metadata17("design:paramtypes", [
6330
+ _ts_param14(0, Inject(AuthRedisService)),
6331
+ _ts_param14(1, Inject(BYMAX_AUTH_OPTIONS)),
6332
+ _ts_param14(2, Inject(BYMAX_AUTH_USER_REPOSITORY)),
6333
+ _ts_metadata18("design:type", Function),
6334
+ _ts_metadata18("design:paramtypes", [
6276
6335
  typeof AuthRedisService === "undefined" ? Object : AuthRedisService,
6277
6336
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
6278
6337
  typeof IUserRepository === "undefined" ? Object : IUserRepository
@@ -6280,23 +6339,23 @@ WsTicketService = _ts_decorate18([
6280
6339
  ], WsTicketService);
6281
6340
 
6282
6341
  // src/server/controllers/auth.controller.ts
6283
- function _ts_decorate19(decorators, target, key, desc) {
6342
+ function _ts_decorate20(decorators, target, key, desc) {
6284
6343
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6285
6344
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
6286
6345
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6287
6346
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6288
6347
  }
6289
- __name(_ts_decorate19, "_ts_decorate");
6290
- function _ts_metadata18(k, v) {
6348
+ __name(_ts_decorate20, "_ts_decorate");
6349
+ function _ts_metadata19(k, v) {
6291
6350
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
6292
6351
  }
6293
- __name(_ts_metadata18, "_ts_metadata");
6294
- function _ts_param14(paramIndex, decorator) {
6352
+ __name(_ts_metadata19, "_ts_metadata");
6353
+ function _ts_param15(paramIndex, decorator) {
6295
6354
  return function(target, key) {
6296
6355
  decorator(target, key, paramIndex);
6297
6356
  };
6298
6357
  }
6299
- __name(_ts_param14, "_ts_param");
6358
+ __name(_ts_param15, "_ts_param");
6300
6359
  function isMfaChallenge(result) {
6301
6360
  return "mfaRequired" in result && result.mfaRequired === true;
6302
6361
  }
@@ -6438,156 +6497,156 @@ var AuthController = class {
6438
6497
  await this.authService.resendVerificationEmail(dto.tenantId, dto.email, req);
6439
6498
  }
6440
6499
  };
6441
- _ts_decorate19([
6500
+ _ts_decorate20([
6442
6501
  Public(),
6443
6502
  Throttle(AUTH_THROTTLE_CONFIGS.register),
6444
6503
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.register),
6445
6504
  Post("register"),
6446
- _ts_param14(0, Body()),
6447
- _ts_param14(1, Req()),
6448
- _ts_param14(2, Res({
6505
+ _ts_param15(0, Body()),
6506
+ _ts_param15(1, Req()),
6507
+ _ts_param15(2, Res({
6449
6508
  passthrough: true
6450
6509
  })),
6451
- _ts_metadata18("design:type", Function),
6452
- _ts_metadata18("design:paramtypes", [
6510
+ _ts_metadata19("design:type", Function),
6511
+ _ts_metadata19("design:paramtypes", [
6453
6512
  typeof RegisterDto === "undefined" ? Object : RegisterDto,
6454
6513
  typeof Request === "undefined" ? Object : Request,
6455
6514
  typeof Response === "undefined" ? Object : Response
6456
6515
  ]),
6457
- _ts_metadata18("design:returntype", Promise)
6516
+ _ts_metadata19("design:returntype", Promise)
6458
6517
  ], AuthController.prototype, "register", null);
6459
- _ts_decorate19([
6518
+ _ts_decorate20([
6460
6519
  Public(),
6461
6520
  Throttle(AUTH_THROTTLE_CONFIGS.login),
6462
6521
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.login),
6463
6522
  HttpCode(HttpStatus.OK),
6464
6523
  Post("login"),
6465
- _ts_param14(0, Body()),
6466
- _ts_param14(1, Req()),
6467
- _ts_param14(2, Res({
6524
+ _ts_param15(0, Body()),
6525
+ _ts_param15(1, Req()),
6526
+ _ts_param15(2, Res({
6468
6527
  passthrough: true
6469
6528
  })),
6470
- _ts_metadata18("design:type", Function),
6471
- _ts_metadata18("design:paramtypes", [
6529
+ _ts_metadata19("design:type", Function),
6530
+ _ts_metadata19("design:paramtypes", [
6472
6531
  typeof LoginDto === "undefined" ? Object : LoginDto,
6473
6532
  typeof Request === "undefined" ? Object : Request,
6474
6533
  typeof Response === "undefined" ? Object : Response
6475
6534
  ]),
6476
- _ts_metadata18("design:returntype", Promise)
6535
+ _ts_metadata19("design:returntype", Promise)
6477
6536
  ], AuthController.prototype, "login", null);
6478
- _ts_decorate19([
6537
+ _ts_decorate20([
6479
6538
  Public(),
6480
6539
  Throttle(AUTH_THROTTLE_CONFIGS.logout),
6481
6540
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.logout),
6482
6541
  HttpCode(HttpStatus.NO_CONTENT),
6483
6542
  Post("logout"),
6484
- _ts_param14(0, Req()),
6485
- _ts_param14(1, Res({
6543
+ _ts_param15(0, Req()),
6544
+ _ts_param15(1, Res({
6486
6545
  passthrough: true
6487
6546
  })),
6488
- _ts_metadata18("design:type", Function),
6489
- _ts_metadata18("design:paramtypes", [
6547
+ _ts_metadata19("design:type", Function),
6548
+ _ts_metadata19("design:paramtypes", [
6490
6549
  typeof Request === "undefined" ? Object : Request,
6491
6550
  typeof Response === "undefined" ? Object : Response
6492
6551
  ]),
6493
- _ts_metadata18("design:returntype", Promise)
6552
+ _ts_metadata19("design:returntype", Promise)
6494
6553
  ], AuthController.prototype, "logout", null);
6495
- _ts_decorate19([
6554
+ _ts_decorate20([
6496
6555
  Public(),
6497
6556
  Throttle(AUTH_THROTTLE_CONFIGS.refresh),
6498
6557
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.refresh),
6499
6558
  HttpCode(HttpStatus.OK),
6500
6559
  Post("refresh"),
6501
- _ts_param14(0, Req()),
6502
- _ts_param14(1, Res({
6560
+ _ts_param15(0, Req()),
6561
+ _ts_param15(1, Res({
6503
6562
  passthrough: true
6504
6563
  })),
6505
- _ts_metadata18("design:type", Function),
6506
- _ts_metadata18("design:paramtypes", [
6564
+ _ts_metadata19("design:type", Function),
6565
+ _ts_metadata19("design:paramtypes", [
6507
6566
  typeof Request === "undefined" ? Object : Request,
6508
6567
  typeof Response === "undefined" ? Object : Response
6509
6568
  ]),
6510
- _ts_metadata18("design:returntype", Promise)
6569
+ _ts_metadata19("design:returntype", Promise)
6511
6570
  ], AuthController.prototype, "refresh", null);
6512
- _ts_decorate19([
6571
+ _ts_decorate20([
6513
6572
  UseGuards(JwtAuthGuard),
6514
6573
  Get("me"),
6515
- _ts_param14(0, CurrentUser()),
6516
- _ts_metadata18("design:type", Function),
6517
- _ts_metadata18("design:paramtypes", [
6574
+ _ts_param15(0, CurrentUser()),
6575
+ _ts_metadata19("design:type", Function),
6576
+ _ts_metadata19("design:paramtypes", [
6518
6577
  typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload
6519
6578
  ]),
6520
- _ts_metadata18("design:returntype", Promise)
6579
+ _ts_metadata19("design:returntype", Promise)
6521
6580
  ], AuthController.prototype, "me", null);
6522
- _ts_decorate19([
6581
+ _ts_decorate20([
6523
6582
  UseGuards(JwtAuthGuard, UserStatusGuard),
6524
6583
  Throttle(AUTH_THROTTLE_CONFIGS.wsTicket),
6525
6584
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.wsTicket),
6526
6585
  Post("ws-ticket"),
6527
6586
  HttpCode(HttpStatus.OK),
6528
- _ts_param14(0, CurrentUser()),
6529
- _ts_metadata18("design:type", Function),
6530
- _ts_metadata18("design:paramtypes", [
6587
+ _ts_param15(0, CurrentUser()),
6588
+ _ts_metadata19("design:type", Function),
6589
+ _ts_metadata19("design:paramtypes", [
6531
6590
  typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload
6532
6591
  ]),
6533
- _ts_metadata18("design:returntype", Promise)
6592
+ _ts_metadata19("design:returntype", Promise)
6534
6593
  ], AuthController.prototype, "wsTicket", null);
6535
- _ts_decorate19([
6594
+ _ts_decorate20([
6536
6595
  Public(),
6537
6596
  Throttle(AUTH_THROTTLE_CONFIGS.verifyEmail),
6538
6597
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.verifyEmail),
6539
6598
  HttpCode(HttpStatus.NO_CONTENT),
6540
6599
  Post("verify-email"),
6541
- _ts_param14(0, Body()),
6542
- _ts_param14(1, Req()),
6543
- _ts_metadata18("design:type", Function),
6544
- _ts_metadata18("design:paramtypes", [
6600
+ _ts_param15(0, Body()),
6601
+ _ts_param15(1, Req()),
6602
+ _ts_metadata19("design:type", Function),
6603
+ _ts_metadata19("design:paramtypes", [
6545
6604
  typeof VerifyEmailDto === "undefined" ? Object : VerifyEmailDto,
6546
6605
  typeof Request === "undefined" ? Object : Request
6547
6606
  ]),
6548
- _ts_metadata18("design:returntype", Promise)
6607
+ _ts_metadata19("design:returntype", Promise)
6549
6608
  ], AuthController.prototype, "verifyEmail", null);
6550
- _ts_decorate19([
6609
+ _ts_decorate20([
6551
6610
  Public(),
6552
6611
  Throttle(AUTH_THROTTLE_CONFIGS.resendVerification),
6553
6612
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.resendVerification),
6554
6613
  HttpCode(HttpStatus.NO_CONTENT),
6555
6614
  Post("resend-verification"),
6556
- _ts_param14(0, Body()),
6557
- _ts_param14(1, Req()),
6558
- _ts_metadata18("design:type", Function),
6559
- _ts_metadata18("design:paramtypes", [
6615
+ _ts_param15(0, Body()),
6616
+ _ts_param15(1, Req()),
6617
+ _ts_metadata19("design:type", Function),
6618
+ _ts_metadata19("design:paramtypes", [
6560
6619
  typeof ResendVerificationDto === "undefined" ? Object : ResendVerificationDto,
6561
6620
  typeof Request === "undefined" ? Object : Request
6562
6621
  ]),
6563
- _ts_metadata18("design:returntype", Promise)
6622
+ _ts_metadata19("design:returntype", Promise)
6564
6623
  ], AuthController.prototype, "resendVerification", null);
6565
- AuthController = _ts_decorate19([
6624
+ AuthController = _ts_decorate20([
6566
6625
  UseInterceptors(NoStoreInterceptor),
6567
6626
  Controller(),
6568
6627
  UseGuards(TrustedOriginGuard, AuthRateLimitGuard),
6569
6628
  UsePipes(createAuthValidationPipe()),
6570
- _ts_param14(0, Inject(AuthService)),
6571
- _ts_param14(1, Inject(TokenDeliveryService)),
6572
- _ts_param14(2, Inject(WsTicketService)),
6573
- _ts_metadata18("design:type", Function),
6574
- _ts_metadata18("design:paramtypes", [
6629
+ _ts_param15(0, Inject(AuthService)),
6630
+ _ts_param15(1, Inject(TokenDeliveryService)),
6631
+ _ts_param15(2, Inject(WsTicketService)),
6632
+ _ts_metadata19("design:type", Function),
6633
+ _ts_metadata19("design:paramtypes", [
6575
6634
  typeof AuthService === "undefined" ? Object : AuthService,
6576
6635
  typeof TokenDeliveryService === "undefined" ? Object : TokenDeliveryService,
6577
6636
  typeof WsTicketService === "undefined" ? Object : WsTicketService
6578
6637
  ])
6579
6638
  ], AuthController);
6580
- function _ts_decorate20(decorators, target, key, desc) {
6639
+ function _ts_decorate21(decorators, target, key, desc) {
6581
6640
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6582
6641
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
6583
6642
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6584
6643
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6585
6644
  }
6586
- __name(_ts_decorate20, "_ts_decorate");
6587
- function _ts_metadata19(k, v) {
6645
+ __name(_ts_decorate21, "_ts_decorate");
6646
+ function _ts_metadata20(k, v) {
6588
6647
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
6589
6648
  }
6590
- __name(_ts_metadata19, "_ts_metadata");
6649
+ __name(_ts_metadata20, "_ts_metadata");
6591
6650
  var ChangeEmailDto = class {
6592
6651
  static {
6593
6652
  __name(this, "ChangeEmailDto");
@@ -6607,30 +6666,30 @@ var ChangeEmailDto = class {
6607
6666
  */
6608
6667
  currentPassword;
6609
6668
  };
6610
- _ts_decorate20([
6669
+ _ts_decorate21([
6611
6670
  Transform(({ value }) => typeof value === "string" ? value.trim().toLowerCase() : value),
6612
6671
  IsEmail(),
6613
6672
  IsNotEmpty(),
6614
6673
  MaxLength(255),
6615
- _ts_metadata19("design:type", String)
6674
+ _ts_metadata20("design:type", String)
6616
6675
  ], ChangeEmailDto.prototype, "newEmail", void 0);
6617
- _ts_decorate20([
6676
+ _ts_decorate21([
6618
6677
  IsString(),
6619
6678
  MinLength(1),
6620
6679
  MaxLength(128),
6621
- _ts_metadata19("design:type", String)
6680
+ _ts_metadata20("design:type", String)
6622
6681
  ], ChangeEmailDto.prototype, "currentPassword", void 0);
6623
- function _ts_decorate21(decorators, target, key, desc) {
6682
+ function _ts_decorate22(decorators, target, key, desc) {
6624
6683
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6625
6684
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
6626
6685
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6627
6686
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6628
6687
  }
6629
- __name(_ts_decorate21, "_ts_decorate");
6630
- function _ts_metadata20(k, v) {
6688
+ __name(_ts_decorate22, "_ts_decorate");
6689
+ function _ts_metadata21(k, v) {
6631
6690
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
6632
6691
  }
6633
- __name(_ts_metadata20, "_ts_metadata");
6692
+ __name(_ts_metadata21, "_ts_metadata");
6634
6693
  var ConfirmEmailChangeDto = class {
6635
6694
  static {
6636
6695
  __name(this, "ConfirmEmailChangeDto");
@@ -6643,29 +6702,29 @@ var ConfirmEmailChangeDto = class {
6643
6702
  */
6644
6703
  token;
6645
6704
  };
6646
- _ts_decorate21([
6705
+ _ts_decorate22([
6647
6706
  IsString(),
6648
6707
  IsNotEmpty(),
6649
6708
  Length(64, 64),
6650
- _ts_metadata20("design:type", String)
6709
+ _ts_metadata21("design:type", String)
6651
6710
  ], ConfirmEmailChangeDto.prototype, "token", void 0);
6652
- function _ts_decorate22(decorators, target, key, desc) {
6711
+ function _ts_decorate23(decorators, target, key, desc) {
6653
6712
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6654
6713
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
6655
6714
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6656
6715
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6657
6716
  }
6658
- __name(_ts_decorate22, "_ts_decorate");
6659
- function _ts_metadata21(k, v) {
6717
+ __name(_ts_decorate23, "_ts_decorate");
6718
+ function _ts_metadata22(k, v) {
6660
6719
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
6661
6720
  }
6662
- __name(_ts_metadata21, "_ts_metadata");
6663
- function _ts_param15(paramIndex, decorator) {
6721
+ __name(_ts_metadata22, "_ts_metadata");
6722
+ function _ts_param16(paramIndex, decorator) {
6664
6723
  return function(target, key) {
6665
6724
  decorator(target, key, paramIndex);
6666
6725
  };
6667
6726
  }
6668
- __name(_ts_param15, "_ts_param");
6727
+ __name(_ts_param16, "_ts_param");
6669
6728
  var EMAIL_CHANGE_TOKEN_BYTES = 32;
6670
6729
  function isEmailChangeContext(value) {
6671
6730
  if (typeof value !== "object" || value === null) return false;
@@ -6755,7 +6814,7 @@ var EmailChangeService = class _EmailChangeService {
6755
6814
  passwordFingerprint: sha256(user.passwordHash)
6756
6815
  };
6757
6816
  await this.redis.set(`ec:${sha256(rawToken)}`, JSON.stringify(context), this.options.emailChange.tokenTtlSeconds);
6758
- await this.emailProvider.sendEmailChangeVerification?.(newEmail, rawToken);
6817
+ await this.emailProvider.sendEmailChangeVerification?.(user.tenantId, newEmail, rawToken);
6759
6818
  this.logger.log(`requestChange: verification sent userId=${userId} newEmail=${maskEmail(newEmail)}`);
6760
6819
  }
6761
6820
  // ---------------------------------------------------------------------------
@@ -6789,7 +6848,7 @@ var EmailChangeService = class _EmailChangeService {
6789
6848
  const oldEmail = user.email;
6790
6849
  await this.userRepo.updateEmail(context.userId, context.newEmail);
6791
6850
  this.logger.log(`confirmChange: address changed userId=${context.userId} from=${maskEmail(oldEmail)} to=${maskEmail(context.newEmail)}`);
6792
- await this.notifyOldAddress(oldEmail, context.newEmail);
6851
+ await this.notifyOldAddress(user.tenantId, oldEmail, context.newEmail);
6793
6852
  }
6794
6853
  // ---------------------------------------------------------------------------
6795
6854
  // Private helpers
@@ -6869,25 +6928,25 @@ var EmailChangeService = class _EmailChangeService {
6869
6928
  * @param oldEmail - The address the account is leaving.
6870
6929
  * @param newEmail - The address it moved to.
6871
6930
  */
6872
- async notifyOldAddress(oldEmail, newEmail) {
6931
+ async notifyOldAddress(tenantId, oldEmail, newEmail) {
6873
6932
  if (!this.emailProvider.sendEmailChangedNotification) return;
6874
6933
  try {
6875
- await this.emailProvider.sendEmailChangedNotification(oldEmail, newEmail);
6934
+ await this.emailProvider.sendEmailChangedNotification(tenantId, oldEmail, newEmail);
6876
6935
  } catch (err) {
6877
6936
  this.logger.error("confirmChange: notification to the previous address failed", err);
6878
6937
  }
6879
6938
  }
6880
6939
  };
6881
- EmailChangeService = _ts_decorate22([
6940
+ EmailChangeService = _ts_decorate23([
6882
6941
  Injectable(),
6883
- _ts_param15(0, Inject(BYMAX_AUTH_OPTIONS)),
6884
- _ts_param15(1, Inject(BYMAX_AUTH_USER_REPOSITORY)),
6885
- _ts_param15(2, Inject(BYMAX_AUTH_EMAIL_PROVIDER)),
6886
- _ts_param15(3, Inject(PasswordService)),
6887
- _ts_param15(4, Inject(AuthRedisService)),
6888
- _ts_param15(5, Inject(BruteForceService)),
6889
- _ts_metadata21("design:type", Function),
6890
- _ts_metadata21("design:paramtypes", [
6942
+ _ts_param16(0, Inject(BYMAX_AUTH_OPTIONS)),
6943
+ _ts_param16(1, Inject(BYMAX_AUTH_USER_REPOSITORY)),
6944
+ _ts_param16(2, Inject(BYMAX_AUTH_EMAIL_PROVIDER)),
6945
+ _ts_param16(3, Inject(PasswordService)),
6946
+ _ts_param16(4, Inject(AuthRedisService)),
6947
+ _ts_param16(5, Inject(BruteForceService)),
6948
+ _ts_metadata22("design:type", Function),
6949
+ _ts_metadata22("design:paramtypes", [
6891
6950
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
6892
6951
  typeof IUserRepository === "undefined" ? Object : IUserRepository,
6893
6952
  typeof IEmailProvider === "undefined" ? Object : IEmailProvider,
@@ -6898,23 +6957,23 @@ EmailChangeService = _ts_decorate22([
6898
6957
  ], EmailChangeService);
6899
6958
 
6900
6959
  // src/server/controllers/email-change.controller.ts
6901
- function _ts_decorate23(decorators, target, key, desc) {
6960
+ function _ts_decorate24(decorators, target, key, desc) {
6902
6961
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6903
6962
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
6904
6963
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6905
6964
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6906
6965
  }
6907
- __name(_ts_decorate23, "_ts_decorate");
6908
- function _ts_metadata22(k, v) {
6966
+ __name(_ts_decorate24, "_ts_decorate");
6967
+ function _ts_metadata23(k, v) {
6909
6968
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
6910
6969
  }
6911
- __name(_ts_metadata22, "_ts_metadata");
6912
- function _ts_param16(paramIndex, decorator) {
6970
+ __name(_ts_metadata23, "_ts_metadata");
6971
+ function _ts_param17(paramIndex, decorator) {
6913
6972
  return function(target, key) {
6914
6973
  decorator(target, key, paramIndex);
6915
6974
  };
6916
6975
  }
6917
- __name(_ts_param16, "_ts_param");
6976
+ __name(_ts_param17, "_ts_param");
6918
6977
  var EmailChangeController = class {
6919
6978
  static {
6920
6979
  __name(this, "EmailChangeController");
@@ -6961,56 +7020,56 @@ var EmailChangeController = class {
6961
7020
  await this.emailChangeService.confirmChange(dto);
6962
7021
  }
6963
7022
  };
6964
- _ts_decorate23([
7023
+ _ts_decorate24([
6965
7024
  UseGuards(JwtAuthGuard, UserStatusGuard),
6966
7025
  Throttle(AUTH_THROTTLE_CONFIGS.emailChangeRequest),
6967
7026
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.emailChangeRequest),
6968
7027
  HttpCode(HttpStatus.NO_CONTENT),
6969
7028
  Post("change"),
6970
- _ts_param16(0, Body()),
6971
- _ts_param16(1, CurrentUser()),
6972
- _ts_metadata22("design:type", Function),
6973
- _ts_metadata22("design:paramtypes", [
7029
+ _ts_param17(0, Body()),
7030
+ _ts_param17(1, CurrentUser()),
7031
+ _ts_metadata23("design:type", Function),
7032
+ _ts_metadata23("design:paramtypes", [
6974
7033
  typeof ChangeEmailDto === "undefined" ? Object : ChangeEmailDto,
6975
7034
  typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload
6976
7035
  ]),
6977
- _ts_metadata22("design:returntype", Promise)
7036
+ _ts_metadata23("design:returntype", Promise)
6978
7037
  ], EmailChangeController.prototype, "requestChange", null);
6979
- _ts_decorate23([
7038
+ _ts_decorate24([
6980
7039
  Public(),
6981
7040
  Throttle(AUTH_THROTTLE_CONFIGS.emailChangeConfirm),
6982
7041
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.emailChangeConfirm),
6983
7042
  HttpCode(HttpStatus.NO_CONTENT),
6984
7043
  Post("change/confirm"),
6985
- _ts_param16(0, Body()),
6986
- _ts_metadata22("design:type", Function),
6987
- _ts_metadata22("design:paramtypes", [
7044
+ _ts_param17(0, Body()),
7045
+ _ts_metadata23("design:type", Function),
7046
+ _ts_metadata23("design:paramtypes", [
6988
7047
  typeof ConfirmEmailChangeDto === "undefined" ? Object : ConfirmEmailChangeDto
6989
7048
  ]),
6990
- _ts_metadata22("design:returntype", Promise)
7049
+ _ts_metadata23("design:returntype", Promise)
6991
7050
  ], EmailChangeController.prototype, "confirmChange", null);
6992
- EmailChangeController = _ts_decorate23([
7051
+ EmailChangeController = _ts_decorate24([
6993
7052
  UseInterceptors(NoStoreInterceptor),
6994
7053
  Controller("email"),
6995
7054
  UseGuards(TrustedOriginGuard, AuthRateLimitGuard),
6996
7055
  UsePipes(createAuthValidationPipe()),
6997
- _ts_param16(0, Inject(EmailChangeService)),
6998
- _ts_metadata22("design:type", Function),
6999
- _ts_metadata22("design:paramtypes", [
7056
+ _ts_param17(0, Inject(EmailChangeService)),
7057
+ _ts_metadata23("design:type", Function),
7058
+ _ts_metadata23("design:paramtypes", [
7000
7059
  typeof EmailChangeService === "undefined" ? Object : EmailChangeService
7001
7060
  ])
7002
7061
  ], EmailChangeController);
7003
- function _ts_decorate24(decorators, target, key, desc) {
7062
+ function _ts_decorate25(decorators, target, key, desc) {
7004
7063
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7005
7064
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7006
7065
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
7007
7066
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7008
7067
  }
7009
- __name(_ts_decorate24, "_ts_decorate");
7010
- function _ts_metadata23(k, v) {
7068
+ __name(_ts_decorate25, "_ts_decorate");
7069
+ function _ts_metadata24(k, v) {
7011
7070
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
7012
7071
  }
7013
- __name(_ts_metadata23, "_ts_metadata");
7072
+ __name(_ts_metadata24, "_ts_metadata");
7014
7073
  var AcceptInvitationDto = class {
7015
7074
  static {
7016
7075
  __name(this, "AcceptInvitationDto");
@@ -7048,34 +7107,34 @@ var AcceptInvitationDto = class {
7048
7107
  */
7049
7108
  password;
7050
7109
  };
7051
- _ts_decorate24([
7110
+ _ts_decorate25([
7052
7111
  IsString(),
7053
7112
  IsNotEmpty(),
7054
7113
  Length(64, 64),
7055
- _ts_metadata23("design:type", String)
7114
+ _ts_metadata24("design:type", String)
7056
7115
  ], AcceptInvitationDto.prototype, "token", void 0);
7057
- _ts_decorate24([
7116
+ _ts_decorate25([
7058
7117
  IsString(),
7059
7118
  IsNotEmpty(),
7060
7119
  Length(2, 100),
7061
- _ts_metadata23("design:type", String)
7120
+ _ts_metadata24("design:type", String)
7062
7121
  ], AcceptInvitationDto.prototype, "name", void 0);
7063
- _ts_decorate24([
7122
+ _ts_decorate25([
7064
7123
  IsString(),
7065
7124
  Length(8, 128),
7066
- _ts_metadata23("design:type", String)
7125
+ _ts_metadata24("design:type", String)
7067
7126
  ], AcceptInvitationDto.prototype, "password", void 0);
7068
- function _ts_decorate25(decorators, target, key, desc) {
7127
+ function _ts_decorate26(decorators, target, key, desc) {
7069
7128
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7070
7129
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7071
7130
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
7072
7131
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7073
7132
  }
7074
- __name(_ts_decorate25, "_ts_decorate");
7075
- function _ts_metadata24(k, v) {
7133
+ __name(_ts_decorate26, "_ts_decorate");
7134
+ function _ts_metadata25(k, v) {
7076
7135
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
7077
7136
  }
7078
- __name(_ts_metadata24, "_ts_metadata");
7137
+ __name(_ts_metadata25, "_ts_metadata");
7079
7138
  var CreateInvitationDto = class {
7080
7139
  static {
7081
7140
  __name(this, "CreateInvitationDto");
@@ -7106,37 +7165,37 @@ var CreateInvitationDto = class {
7106
7165
  */
7107
7166
  tenantName;
7108
7167
  };
7109
- _ts_decorate25([
7168
+ _ts_decorate26([
7110
7169
  Transform(({ value }) => typeof value === "string" ? value.trim().toLowerCase() : value),
7111
7170
  IsEmail(),
7112
7171
  IsNotEmpty(),
7113
7172
  MaxLength(255),
7114
- _ts_metadata24("design:type", String)
7173
+ _ts_metadata25("design:type", String)
7115
7174
  ], CreateInvitationDto.prototype, "email", void 0);
7116
- _ts_decorate25([
7175
+ _ts_decorate26([
7117
7176
  IsString(),
7118
7177
  IsNotEmpty(),
7119
7178
  MaxLength(64),
7120
- _ts_metadata24("design:type", String)
7179
+ _ts_metadata25("design:type", String)
7121
7180
  ], CreateInvitationDto.prototype, "role", void 0);
7122
- _ts_decorate25([
7181
+ _ts_decorate26([
7123
7182
  IsOptional(),
7124
7183
  IsString(),
7125
7184
  IsNotEmpty(),
7126
7185
  MaxLength(128),
7127
- _ts_metadata24("design:type", String)
7186
+ _ts_metadata25("design:type", String)
7128
7187
  ], CreateInvitationDto.prototype, "tenantName", void 0);
7129
- function _ts_decorate26(decorators, target, key, desc) {
7188
+ function _ts_decorate27(decorators, target, key, desc) {
7130
7189
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7131
7190
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7132
7191
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
7133
7192
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7134
7193
  }
7135
- __name(_ts_decorate26, "_ts_decorate");
7136
- function _ts_metadata25(k, v) {
7194
+ __name(_ts_decorate27, "_ts_decorate");
7195
+ function _ts_metadata26(k, v) {
7137
7196
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
7138
7197
  }
7139
- __name(_ts_metadata25, "_ts_metadata");
7198
+ __name(_ts_metadata26, "_ts_metadata");
7140
7199
  var RevokeInvitationDto = class {
7141
7200
  static {
7142
7201
  __name(this, "RevokeInvitationDto");
@@ -7148,30 +7207,30 @@ var RevokeInvitationDto = class {
7148
7207
  */
7149
7208
  email;
7150
7209
  };
7151
- _ts_decorate26([
7210
+ _ts_decorate27([
7152
7211
  Transform(({ value }) => typeof value === "string" ? value.trim().toLowerCase() : value),
7153
7212
  IsEmail(),
7154
7213
  IsNotEmpty(),
7155
7214
  MaxLength(255),
7156
- _ts_metadata25("design:type", String)
7215
+ _ts_metadata26("design:type", String)
7157
7216
  ], RevokeInvitationDto.prototype, "email", void 0);
7158
- function _ts_decorate27(decorators, target, key, desc) {
7217
+ function _ts_decorate28(decorators, target, key, desc) {
7159
7218
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7160
7219
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7161
7220
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
7162
7221
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7163
7222
  }
7164
- __name(_ts_decorate27, "_ts_decorate");
7165
- function _ts_metadata26(k, v) {
7223
+ __name(_ts_decorate28, "_ts_decorate");
7224
+ function _ts_metadata27(k, v) {
7166
7225
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
7167
7226
  }
7168
- __name(_ts_metadata26, "_ts_metadata");
7169
- function _ts_param17(paramIndex, decorator) {
7227
+ __name(_ts_metadata27, "_ts_metadata");
7228
+ function _ts_param18(paramIndex, decorator) {
7170
7229
  return function(target, key) {
7171
7230
  decorator(target, key, paramIndex);
7172
7231
  };
7173
7232
  }
7174
- __name(_ts_param17, "_ts_param");
7233
+ __name(_ts_param18, "_ts_param");
7175
7234
  function isStoredInvitation(value) {
7176
7235
  if (typeof value !== "object" || value === null) return false;
7177
7236
  const v = value;
@@ -7262,7 +7321,7 @@ var InvitationService = class _InvitationService {
7262
7321
  await this.redis.set(tokenKey, JSON.stringify(stored), ttl);
7263
7322
  const displayTenantName = tenantName ?? tenantId;
7264
7323
  const expiresAt = new Date(Date.now() + ttl * 1e3);
7265
- await this.emailProvider.sendInvitation(normalizedEmail, {
7324
+ await this.emailProvider.sendInvitation(tenantId, normalizedEmail, {
7266
7325
  inviterName: inviter.name,
7267
7326
  tenantName: displayTenantName,
7268
7327
  inviteToken: rawToken,
@@ -7598,18 +7657,18 @@ var InvitationService = class _InvitationService {
7598
7657
  return result;
7599
7658
  }
7600
7659
  };
7601
- InvitationService = _ts_decorate27([
7660
+ InvitationService = _ts_decorate28([
7602
7661
  Injectable(),
7603
- _ts_param17(0, Inject(BYMAX_AUTH_USER_REPOSITORY)),
7604
- _ts_param17(1, Inject(BYMAX_AUTH_EMAIL_PROVIDER)),
7605
- _ts_param17(2, Inject(BYMAX_AUTH_HOOKS)),
7606
- _ts_param17(3, Inject(AuthRedisService)),
7607
- _ts_param17(4, Inject(PasswordService)),
7608
- _ts_param17(5, Inject(SessionService)),
7609
- _ts_param17(6, Inject(TokenManagerService)),
7610
- _ts_param17(7, Inject(BYMAX_AUTH_OPTIONS)),
7611
- _ts_metadata26("design:type", Function),
7612
- _ts_metadata26("design:paramtypes", [
7662
+ _ts_param18(0, Inject(BYMAX_AUTH_USER_REPOSITORY)),
7663
+ _ts_param18(1, Inject(BYMAX_AUTH_EMAIL_PROVIDER)),
7664
+ _ts_param18(2, Inject(BYMAX_AUTH_HOOKS)),
7665
+ _ts_param18(3, Inject(AuthRedisService)),
7666
+ _ts_param18(4, Inject(PasswordService)),
7667
+ _ts_param18(5, Inject(SessionService)),
7668
+ _ts_param18(6, Inject(TokenManagerService)),
7669
+ _ts_param18(7, Inject(BYMAX_AUTH_OPTIONS)),
7670
+ _ts_metadata27("design:type", Function),
7671
+ _ts_metadata27("design:paramtypes", [
7613
7672
  typeof IUserRepository === "undefined" ? Object : IUserRepository,
7614
7673
  typeof IEmailProvider === "undefined" ? Object : IEmailProvider,
7615
7674
  typeof IAuthHooks === "undefined" ? Object : IAuthHooks,
@@ -7622,23 +7681,23 @@ InvitationService = _ts_decorate27([
7622
7681
  ], InvitationService);
7623
7682
 
7624
7683
  // src/server/controllers/invitation.controller.ts
7625
- function _ts_decorate28(decorators, target, key, desc) {
7684
+ function _ts_decorate29(decorators, target, key, desc) {
7626
7685
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7627
7686
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7628
7687
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
7629
7688
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7630
7689
  }
7631
- __name(_ts_decorate28, "_ts_decorate");
7632
- function _ts_metadata27(k, v) {
7690
+ __name(_ts_decorate29, "_ts_decorate");
7691
+ function _ts_metadata28(k, v) {
7633
7692
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
7634
7693
  }
7635
- __name(_ts_metadata27, "_ts_metadata");
7636
- function _ts_param18(paramIndex, decorator) {
7694
+ __name(_ts_metadata28, "_ts_metadata");
7695
+ function _ts_param19(paramIndex, decorator) {
7637
7696
  return function(target, key) {
7638
7697
  decorator(target, key, paramIndex);
7639
7698
  };
7640
7699
  }
7641
- __name(_ts_param18, "_ts_param");
7700
+ __name(_ts_param19, "_ts_param");
7642
7701
  var InvitationController = class {
7643
7702
  static {
7644
7703
  __name(this, "InvitationController");
@@ -7714,64 +7773,64 @@ var InvitationController = class {
7714
7773
  return this.tokenDelivery.deliverAuthResponse(res, result, req);
7715
7774
  }
7716
7775
  };
7717
- _ts_decorate28([
7776
+ _ts_decorate29([
7718
7777
  UseGuards(JwtAuthGuard, UserStatusGuard),
7719
7778
  Throttle(AUTH_THROTTLE_CONFIGS.invitationCreate),
7720
7779
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.invitationCreate),
7721
7780
  HttpCode(HttpStatus.NO_CONTENT),
7722
7781
  Post(),
7723
- _ts_param18(0, Body()),
7724
- _ts_param18(1, CurrentUser()),
7725
- _ts_metadata27("design:type", Function),
7726
- _ts_metadata27("design:paramtypes", [
7782
+ _ts_param19(0, Body()),
7783
+ _ts_param19(1, CurrentUser()),
7784
+ _ts_metadata28("design:type", Function),
7785
+ _ts_metadata28("design:paramtypes", [
7727
7786
  typeof CreateInvitationDto === "undefined" ? Object : CreateInvitationDto,
7728
7787
  typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload
7729
7788
  ]),
7730
- _ts_metadata27("design:returntype", Promise)
7789
+ _ts_metadata28("design:returntype", Promise)
7731
7790
  ], InvitationController.prototype, "invite", null);
7732
- _ts_decorate28([
7791
+ _ts_decorate29([
7733
7792
  UseGuards(JwtAuthGuard, UserStatusGuard),
7734
7793
  Throttle(AUTH_THROTTLE_CONFIGS.invitationRevoke),
7735
7794
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.invitationRevoke),
7736
7795
  HttpCode(HttpStatus.NO_CONTENT),
7737
7796
  Post("revoke"),
7738
- _ts_param18(0, Body()),
7739
- _ts_param18(1, CurrentUser()),
7740
- _ts_metadata27("design:type", Function),
7741
- _ts_metadata27("design:paramtypes", [
7797
+ _ts_param19(0, Body()),
7798
+ _ts_param19(1, CurrentUser()),
7799
+ _ts_metadata28("design:type", Function),
7800
+ _ts_metadata28("design:paramtypes", [
7742
7801
  typeof RevokeInvitationDto === "undefined" ? Object : RevokeInvitationDto,
7743
7802
  typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload
7744
7803
  ]),
7745
- _ts_metadata27("design:returntype", Promise)
7804
+ _ts_metadata28("design:returntype", Promise)
7746
7805
  ], InvitationController.prototype, "revoke", null);
7747
- _ts_decorate28([
7806
+ _ts_decorate29([
7748
7807
  Public(),
7749
7808
  Throttle(AUTH_THROTTLE_CONFIGS.invitationAccept),
7750
7809
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.invitationAccept),
7751
7810
  HttpCode(HttpStatus.CREATED),
7752
7811
  Post("accept"),
7753
- _ts_param18(0, Body()),
7754
- _ts_param18(1, Req()),
7755
- _ts_param18(2, Res({
7812
+ _ts_param19(0, Body()),
7813
+ _ts_param19(1, Req()),
7814
+ _ts_param19(2, Res({
7756
7815
  passthrough: true
7757
7816
  })),
7758
- _ts_metadata27("design:type", Function),
7759
- _ts_metadata27("design:paramtypes", [
7817
+ _ts_metadata28("design:type", Function),
7818
+ _ts_metadata28("design:paramtypes", [
7760
7819
  typeof AcceptInvitationDto === "undefined" ? Object : AcceptInvitationDto,
7761
7820
  typeof Request === "undefined" ? Object : Request,
7762
7821
  typeof Response === "undefined" ? Object : Response
7763
7822
  ]),
7764
- _ts_metadata27("design:returntype", Promise)
7823
+ _ts_metadata28("design:returntype", Promise)
7765
7824
  ], InvitationController.prototype, "accept", null);
7766
- InvitationController = _ts_decorate28([
7825
+ InvitationController = _ts_decorate29([
7767
7826
  UseInterceptors(NoStoreInterceptor),
7768
7827
  Controller("invitations"),
7769
7828
  UseGuards(TrustedOriginGuard, AuthRateLimitGuard),
7770
7829
  UsePipes(createAuthValidationPipe()),
7771
- _ts_param18(0, Inject(InvitationService)),
7772
- _ts_param18(1, Inject(TokenDeliveryService)),
7773
- _ts_metadata27("design:type", Function),
7774
- _ts_metadata27("design:paramtypes", [
7830
+ _ts_param19(0, Inject(InvitationService)),
7831
+ _ts_param19(1, Inject(TokenDeliveryService)),
7832
+ _ts_metadata28("design:type", Function),
7833
+ _ts_metadata28("design:paramtypes", [
7775
7834
  typeof InvitationService === "undefined" ? Object : InvitationService,
7776
7835
  typeof TokenDeliveryService === "undefined" ? Object : TokenDeliveryService
7777
7836
  ])
@@ -7782,17 +7841,17 @@ var MFA_TEMP_COOKIE_NAME = "mfa_temp_token";
7782
7841
  var MFA_TEMP_COOKIE_MAX_AGE_SECONDS = 300;
7783
7842
  var SKIP_MFA_KEY = /* @__PURE__ */ Symbol("skipMfa");
7784
7843
  var SkipMfa = /* @__PURE__ */ __name(() => SetMetadata(SKIP_MFA_KEY, true), "SkipMfa");
7785
- function _ts_decorate29(decorators, target, key, desc) {
7844
+ function _ts_decorate30(decorators, target, key, desc) {
7786
7845
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7787
7846
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7788
7847
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
7789
7848
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7790
7849
  }
7791
- __name(_ts_decorate29, "_ts_decorate");
7792
- function _ts_metadata28(k, v) {
7850
+ __name(_ts_decorate30, "_ts_decorate");
7851
+ function _ts_metadata29(k, v) {
7793
7852
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
7794
7853
  }
7795
- __name(_ts_metadata28, "_ts_metadata");
7854
+ __name(_ts_metadata29, "_ts_metadata");
7796
7855
  var MfaChallengeDto = class {
7797
7856
  static {
7798
7857
  __name(this, "MfaChallengeDto");
@@ -7828,33 +7887,33 @@ var MfaChallengeDto = class {
7828
7887
  */
7829
7888
  code;
7830
7889
  };
7831
- _ts_decorate29([
7890
+ _ts_decorate30([
7832
7891
  IsOptional(),
7833
7892
  IsString(),
7834
7893
  IsNotEmpty(),
7835
7894
  MaxLength(512),
7836
- _ts_metadata28("design:type", String)
7895
+ _ts_metadata29("design:type", String)
7837
7896
  ], MfaChallengeDto.prototype, "mfaTempToken", void 0);
7838
- _ts_decorate29([
7897
+ _ts_decorate30([
7839
7898
  Matches(/^(\d{6}|[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4})$/, {
7840
7899
  message: "code must be a 6-digit TOTP code or a recovery code in XXXX-XXXX-XXXX-XXXX-XXXX-XXXX format"
7841
7900
  }),
7842
7901
  IsString(),
7843
7902
  IsNotEmpty(),
7844
7903
  MaxLength(29),
7845
- _ts_metadata28("design:type", String)
7904
+ _ts_metadata29("design:type", String)
7846
7905
  ], MfaChallengeDto.prototype, "code", void 0);
7847
- function _ts_decorate30(decorators, target, key, desc) {
7906
+ function _ts_decorate31(decorators, target, key, desc) {
7848
7907
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7849
7908
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7850
7909
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
7851
7910
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7852
7911
  }
7853
- __name(_ts_decorate30, "_ts_decorate");
7854
- function _ts_metadata29(k, v) {
7912
+ __name(_ts_decorate31, "_ts_decorate");
7913
+ function _ts_metadata30(k, v) {
7855
7914
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
7856
7915
  }
7857
- __name(_ts_metadata29, "_ts_metadata");
7916
+ __name(_ts_metadata30, "_ts_metadata");
7858
7917
  var MfaDisableDto = class {
7859
7918
  static {
7860
7919
  __name(this, "MfaDisableDto");
@@ -7868,26 +7927,26 @@ var MfaDisableDto = class {
7868
7927
  */
7869
7928
  code;
7870
7929
  };
7871
- _ts_decorate30([
7930
+ _ts_decorate31([
7872
7931
  MaxLength(6),
7873
7932
  Matches(/^\d{6}$/, {
7874
7933
  message: "code must be exactly 6 digits"
7875
7934
  }),
7876
7935
  IsString(),
7877
7936
  IsNotEmpty(),
7878
- _ts_metadata29("design:type", String)
7937
+ _ts_metadata30("design:type", String)
7879
7938
  ], MfaDisableDto.prototype, "code", void 0);
7880
- function _ts_decorate31(decorators, target, key, desc) {
7939
+ function _ts_decorate32(decorators, target, key, desc) {
7881
7940
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7882
7941
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7883
7942
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
7884
7943
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7885
7944
  }
7886
- __name(_ts_decorate31, "_ts_decorate");
7887
- function _ts_metadata30(k, v) {
7945
+ __name(_ts_decorate32, "_ts_decorate");
7946
+ function _ts_metadata31(k, v) {
7888
7947
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
7889
7948
  }
7890
- __name(_ts_metadata30, "_ts_metadata");
7949
+ __name(_ts_metadata31, "_ts_metadata");
7891
7950
  var MfaRegenerateRecoveryCodesDto = class {
7892
7951
  static {
7893
7952
  __name(this, "MfaRegenerateRecoveryCodesDto");
@@ -7901,26 +7960,26 @@ var MfaRegenerateRecoveryCodesDto = class {
7901
7960
  */
7902
7961
  code;
7903
7962
  };
7904
- _ts_decorate31([
7963
+ _ts_decorate32([
7905
7964
  MaxLength(6),
7906
7965
  Matches(/^\d{6}$/, {
7907
7966
  message: "code must be exactly 6 digits"
7908
7967
  }),
7909
7968
  IsString(),
7910
7969
  IsNotEmpty(),
7911
- _ts_metadata30("design:type", String)
7970
+ _ts_metadata31("design:type", String)
7912
7971
  ], MfaRegenerateRecoveryCodesDto.prototype, "code", void 0);
7913
- function _ts_decorate32(decorators, target, key, desc) {
7972
+ function _ts_decorate33(decorators, target, key, desc) {
7914
7973
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7915
7974
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7916
7975
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
7917
7976
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7918
7977
  }
7919
- __name(_ts_decorate32, "_ts_decorate");
7920
- function _ts_metadata31(k, v) {
7978
+ __name(_ts_decorate33, "_ts_decorate");
7979
+ function _ts_metadata32(k, v) {
7921
7980
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
7922
7981
  }
7923
- __name(_ts_metadata31, "_ts_metadata");
7982
+ __name(_ts_metadata32, "_ts_metadata");
7924
7983
  var MfaSetupDto = class {
7925
7984
  static {
7926
7985
  __name(this, "MfaSetupDto");
@@ -7944,24 +8003,24 @@ var MfaSetupDto = class {
7944
8003
  */
7945
8004
  password;
7946
8005
  };
7947
- _ts_decorate32([
8006
+ _ts_decorate33([
7948
8007
  IsOptional(),
7949
8008
  IsString(),
7950
8009
  MinLength(1),
7951
8010
  MaxLength(128),
7952
- _ts_metadata31("design:type", String)
8011
+ _ts_metadata32("design:type", String)
7953
8012
  ], MfaSetupDto.prototype, "password", void 0);
7954
- function _ts_decorate33(decorators, target, key, desc) {
8013
+ function _ts_decorate34(decorators, target, key, desc) {
7955
8014
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7956
8015
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7957
8016
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
7958
8017
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7959
8018
  }
7960
- __name(_ts_decorate33, "_ts_decorate");
7961
- function _ts_metadata32(k, v) {
8019
+ __name(_ts_decorate34, "_ts_decorate");
8020
+ function _ts_metadata33(k, v) {
7962
8021
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
7963
8022
  }
7964
- __name(_ts_metadata32, "_ts_metadata");
8023
+ __name(_ts_metadata33, "_ts_metadata");
7965
8024
  var MfaVerifyDto = class {
7966
8025
  static {
7967
8026
  __name(this, "MfaVerifyDto");
@@ -7974,14 +8033,14 @@ var MfaVerifyDto = class {
7974
8033
  */
7975
8034
  code;
7976
8035
  };
7977
- _ts_decorate33([
8036
+ _ts_decorate34([
7978
8037
  MaxLength(6),
7979
8038
  Matches(/^\d{6}$/, {
7980
8039
  message: "code must be exactly 6 digits"
7981
8040
  }),
7982
8041
  IsString(),
7983
8042
  IsNotEmpty(),
7984
- _ts_metadata32("design:type", String)
8043
+ _ts_metadata33("design:type", String)
7985
8044
  ], MfaVerifyDto.prototype, "code", void 0);
7986
8045
  var IV_LENGTH = 12;
7987
8046
  var AUTH_TAG_BYTE_LENGTH = 16;
@@ -8033,23 +8092,28 @@ function decrypt(ciphertext, keyBase64) {
8033
8092
  __name(decrypt, "decrypt");
8034
8093
 
8035
8094
  // src/server/services/mfa.service.ts
8036
- function _ts_decorate34(decorators, target, key, desc) {
8095
+ function _ts_decorate35(decorators, target, key, desc) {
8037
8096
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
8038
8097
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
8039
8098
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
8040
8099
  return c > 3 && r && Object.defineProperty(target, key, r), r;
8041
8100
  }
8042
- __name(_ts_decorate34, "_ts_decorate");
8043
- function _ts_metadata33(k, v) {
8101
+ __name(_ts_decorate35, "_ts_decorate");
8102
+ function _ts_metadata34(k, v) {
8044
8103
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
8045
8104
  }
8046
- __name(_ts_metadata33, "_ts_metadata");
8047
- function _ts_param19(paramIndex, decorator) {
8105
+ __name(_ts_metadata34, "_ts_metadata");
8106
+ function _ts_param20(paramIndex, decorator) {
8048
8107
  return function(target, key) {
8049
8108
  decorator(target, key, paramIndex);
8050
8109
  };
8051
8110
  }
8052
- __name(_ts_param19, "_ts_param");
8111
+ __name(_ts_param20, "_ts_param");
8112
+ var PLATFORM_EMAIL_TENANT = "platform";
8113
+ function emailTenantOf(user) {
8114
+ return "tenantId" in user ? user.tenantId : PLATFORM_EMAIL_TENANT;
8115
+ }
8116
+ __name(emailTenantOf, "emailTenantOf");
8053
8117
  var MFA_SETUP_TTL_SECONDS = 600;
8054
8118
  var RECOVERY_CODE_CLAIM_TTL_SECONDS = 300;
8055
8119
  function totpAntiReplayTtlSeconds(window) {
@@ -8561,7 +8625,7 @@ var MfaService = class _MfaService {
8561
8625
  await this.redis.invalidateUserSessions(userId, context);
8562
8626
  await this.redis.bumpUserTokenEpoch(userId, context);
8563
8627
  this.logger.log(`verifyAndEnable: MFA enabled userId=${userId} context=${context}`);
8564
- await this.emailProvider.sendMfaEnabledNotification(user.email);
8628
+ await this.emailProvider.sendMfaEnabledNotification(emailTenantOf(user), user.email);
8565
8629
  if (this.hooks.afterMfaEnabled) {
8566
8630
  const safeUser = context === "platform" ? this.platformUserAsSafeUser(user) : this.toSafeUser(user);
8567
8631
  void Promise.resolve(this.hooks.afterMfaEnabled(safeUser, {
@@ -8738,7 +8802,7 @@ var MfaService = class _MfaService {
8738
8802
  await this.redis.invalidateUserSessions(userId, context);
8739
8803
  await this.redis.bumpUserTokenEpoch(userId, context);
8740
8804
  this.logger.log(`disable: MFA disabled userId=${userId} context=${context}`);
8741
- await this.emailProvider.sendMfaDisabledNotification(user.email);
8805
+ await this.emailProvider.sendMfaDisabledNotification(emailTenantOf(user), user.email);
8742
8806
  const safeUser = context === "platform" ? this.platformUserAsSafeUser(user) : this.toSafeUser(user);
8743
8807
  if (this.hooks.afterMfaDisabled) {
8744
8808
  void Promise.resolve(this.hooks.afterMfaDisabled(safeUser, {
@@ -8804,7 +8868,7 @@ var MfaService = class _MfaService {
8804
8868
  await this.redis.invalidateUserSessions(userId, context);
8805
8869
  await this.redis.bumpUserTokenEpoch(userId, context);
8806
8870
  this.logger.warn(`resetMfa: MFA removed administratively userId=${userId} context=${context}`);
8807
- await this.emailProvider.sendMfaDisabledNotification(user.email);
8871
+ await this.emailProvider.sendMfaDisabledNotification(emailTenantOf(user), user.email);
8808
8872
  const safeUser = context === "platform" ? this.platformUserAsSafeUser(user) : this.toSafeUser(user);
8809
8873
  if (this.hooks.afterMfaDisabled) {
8810
8874
  void Promise.resolve(this.hooks.afterMfaDisabled(safeUser, {
@@ -9013,21 +9077,21 @@ var MfaService = class _MfaService {
9013
9077
  return admin;
9014
9078
  }
9015
9079
  };
9016
- MfaService = _ts_decorate34([
9080
+ MfaService = _ts_decorate35([
9017
9081
  Injectable(),
9018
- _ts_param19(0, Inject(BYMAX_AUTH_OPTIONS)),
9019
- _ts_param19(1, Inject(BYMAX_AUTH_USER_REPOSITORY)),
9020
- _ts_param19(2, Optional()),
9021
- _ts_param19(2, Inject(BYMAX_AUTH_PLATFORM_USER_REPOSITORY)),
9022
- _ts_param19(3, Inject(AuthRedisService)),
9023
- _ts_param19(4, Inject(TokenManagerService)),
9024
- _ts_param19(5, Inject(BruteForceService)),
9025
- _ts_param19(6, Inject(PasswordService)),
9026
- _ts_param19(7, Inject(SessionService)),
9027
- _ts_param19(8, Inject(BYMAX_AUTH_EMAIL_PROVIDER)),
9028
- _ts_param19(9, Inject(BYMAX_AUTH_HOOKS)),
9029
- _ts_metadata33("design:type", Function),
9030
- _ts_metadata33("design:paramtypes", [
9082
+ _ts_param20(0, Inject(BYMAX_AUTH_OPTIONS)),
9083
+ _ts_param20(1, Inject(BYMAX_AUTH_USER_REPOSITORY)),
9084
+ _ts_param20(2, Optional()),
9085
+ _ts_param20(2, Inject(BYMAX_AUTH_PLATFORM_USER_REPOSITORY)),
9086
+ _ts_param20(3, Inject(AuthRedisService)),
9087
+ _ts_param20(4, Inject(TokenManagerService)),
9088
+ _ts_param20(5, Inject(BruteForceService)),
9089
+ _ts_param20(6, Inject(PasswordService)),
9090
+ _ts_param20(7, Inject(SessionService)),
9091
+ _ts_param20(8, Inject(BYMAX_AUTH_EMAIL_PROVIDER)),
9092
+ _ts_param20(9, Inject(BYMAX_AUTH_HOOKS)),
9093
+ _ts_metadata34("design:type", Function),
9094
+ _ts_metadata34("design:paramtypes", [
9031
9095
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
9032
9096
  typeof IUserRepository === "undefined" ? Object : IUserRepository,
9033
9097
  Object,
@@ -9042,23 +9106,23 @@ MfaService = _ts_decorate34([
9042
9106
  ], MfaService);
9043
9107
 
9044
9108
  // src/server/controllers/mfa.controller.ts
9045
- function _ts_decorate35(decorators, target, key, desc) {
9109
+ function _ts_decorate36(decorators, target, key, desc) {
9046
9110
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9047
9111
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
9048
9112
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9049
9113
  return c > 3 && r && Object.defineProperty(target, key, r), r;
9050
9114
  }
9051
- __name(_ts_decorate35, "_ts_decorate");
9052
- function _ts_metadata34(k, v) {
9115
+ __name(_ts_decorate36, "_ts_decorate");
9116
+ function _ts_metadata35(k, v) {
9053
9117
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9054
9118
  }
9055
- __name(_ts_metadata34, "_ts_metadata");
9056
- function _ts_param20(paramIndex, decorator) {
9119
+ __name(_ts_metadata35, "_ts_metadata");
9120
+ function _ts_param21(paramIndex, decorator) {
9057
9121
  return function(target, key) {
9058
9122
  decorator(target, key, paramIndex);
9059
9123
  };
9060
9124
  }
9061
- __name(_ts_param20, "_ts_param");
9125
+ __name(_ts_param21, "_ts_param");
9062
9126
  function isPlatformResult(result) {
9063
9127
  return "admin" in result;
9064
9128
  }
@@ -9247,120 +9311,120 @@ var MfaController = class {
9247
9311
  return this.mfaService.regenerateRecoveryCodes(user.sub, dto.code, ip, userAgent, "dashboard");
9248
9312
  }
9249
9313
  };
9250
- _ts_decorate35([
9314
+ _ts_decorate36([
9251
9315
  UseGuards(JwtAuthGuard),
9252
9316
  Throttle(AUTH_THROTTLE_CONFIGS.mfaSetup),
9253
9317
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaSetup),
9254
9318
  Post("setup"),
9255
- _ts_param20(0, CurrentUser()),
9256
- _ts_param20(1, Body()),
9257
- _ts_metadata34("design:type", Function),
9258
- _ts_metadata34("design:paramtypes", [
9319
+ _ts_param21(0, CurrentUser()),
9320
+ _ts_param21(1, Body()),
9321
+ _ts_metadata35("design:type", Function),
9322
+ _ts_metadata35("design:paramtypes", [
9259
9323
  typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
9260
9324
  typeof MfaSetupDto === "undefined" ? Object : MfaSetupDto
9261
9325
  ]),
9262
- _ts_metadata34("design:returntype", Promise)
9326
+ _ts_metadata35("design:returntype", Promise)
9263
9327
  ], MfaController.prototype, "setup", null);
9264
- _ts_decorate35([
9328
+ _ts_decorate36([
9265
9329
  UseGuards(JwtAuthGuard),
9266
9330
  Throttle(AUTH_THROTTLE_CONFIGS.mfaVerifyEnable),
9267
9331
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaVerifyEnable),
9268
9332
  HttpCode(HttpStatus.NO_CONTENT),
9269
9333
  Post("verify-enable"),
9270
- _ts_param20(0, CurrentUser()),
9271
- _ts_param20(1, Body()),
9272
- _ts_param20(2, Req()),
9273
- _ts_metadata34("design:type", Function),
9274
- _ts_metadata34("design:paramtypes", [
9334
+ _ts_param21(0, CurrentUser()),
9335
+ _ts_param21(1, Body()),
9336
+ _ts_param21(2, Req()),
9337
+ _ts_metadata35("design:type", Function),
9338
+ _ts_metadata35("design:paramtypes", [
9275
9339
  typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
9276
9340
  typeof MfaVerifyDto === "undefined" ? Object : MfaVerifyDto,
9277
9341
  typeof Request === "undefined" ? Object : Request
9278
9342
  ]),
9279
- _ts_metadata34("design:returntype", Promise)
9343
+ _ts_metadata35("design:returntype", Promise)
9280
9344
  ], MfaController.prototype, "verifyEnable", null);
9281
- _ts_decorate35([
9345
+ _ts_decorate36([
9282
9346
  Public(),
9283
9347
  SkipMfa(),
9284
9348
  Throttle(AUTH_THROTTLE_CONFIGS.mfaChallenge),
9285
9349
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaChallenge),
9286
9350
  HttpCode(HttpStatus.OK),
9287
9351
  Post("challenge"),
9288
- _ts_param20(0, Body()),
9289
- _ts_param20(1, Req()),
9290
- _ts_param20(2, Res({
9352
+ _ts_param21(0, Body()),
9353
+ _ts_param21(1, Req()),
9354
+ _ts_param21(2, Res({
9291
9355
  passthrough: true
9292
9356
  })),
9293
- _ts_metadata34("design:type", Function),
9294
- _ts_metadata34("design:paramtypes", [
9357
+ _ts_metadata35("design:type", Function),
9358
+ _ts_metadata35("design:paramtypes", [
9295
9359
  typeof MfaChallengeDto === "undefined" ? Object : MfaChallengeDto,
9296
9360
  typeof Request === "undefined" ? Object : Request,
9297
9361
  typeof Response === "undefined" ? Object : Response
9298
9362
  ]),
9299
- _ts_metadata34("design:returntype", Promise)
9363
+ _ts_metadata35("design:returntype", Promise)
9300
9364
  ], MfaController.prototype, "challenge", null);
9301
- _ts_decorate35([
9365
+ _ts_decorate36([
9302
9366
  UseGuards(JwtAuthGuard),
9303
9367
  Throttle(AUTH_THROTTLE_CONFIGS.mfaDisable),
9304
9368
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaDisable),
9305
9369
  HttpCode(HttpStatus.NO_CONTENT),
9306
9370
  Post("disable"),
9307
- _ts_param20(0, CurrentUser()),
9308
- _ts_param20(1, Body()),
9309
- _ts_param20(2, Req()),
9310
- _ts_metadata34("design:type", Function),
9311
- _ts_metadata34("design:paramtypes", [
9371
+ _ts_param21(0, CurrentUser()),
9372
+ _ts_param21(1, Body()),
9373
+ _ts_param21(2, Req()),
9374
+ _ts_metadata35("design:type", Function),
9375
+ _ts_metadata35("design:paramtypes", [
9312
9376
  typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
9313
9377
  typeof MfaDisableDto === "undefined" ? Object : MfaDisableDto,
9314
9378
  typeof Request === "undefined" ? Object : Request
9315
9379
  ]),
9316
- _ts_metadata34("design:returntype", Promise)
9380
+ _ts_metadata35("design:returntype", Promise)
9317
9381
  ], MfaController.prototype, "disable", null);
9318
- _ts_decorate35([
9382
+ _ts_decorate36([
9319
9383
  UseGuards(JwtAuthGuard),
9320
9384
  Throttle(AUTH_THROTTLE_CONFIGS.mfaDisable),
9321
9385
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaDisable),
9322
9386
  HttpCode(HttpStatus.OK),
9323
9387
  Post("recovery-codes"),
9324
- _ts_param20(0, CurrentUser()),
9325
- _ts_param20(1, Body()),
9326
- _ts_param20(2, Req()),
9327
- _ts_metadata34("design:type", Function),
9328
- _ts_metadata34("design:paramtypes", [
9388
+ _ts_param21(0, CurrentUser()),
9389
+ _ts_param21(1, Body()),
9390
+ _ts_param21(2, Req()),
9391
+ _ts_metadata35("design:type", Function),
9392
+ _ts_metadata35("design:paramtypes", [
9329
9393
  typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
9330
9394
  typeof MfaRegenerateRecoveryCodesDto === "undefined" ? Object : MfaRegenerateRecoveryCodesDto,
9331
9395
  typeof Request === "undefined" ? Object : Request
9332
9396
  ]),
9333
- _ts_metadata34("design:returntype", Promise)
9397
+ _ts_metadata35("design:returntype", Promise)
9334
9398
  ], MfaController.prototype, "regenerateRecoveryCodes", null);
9335
- MfaController = _ts_decorate35([
9399
+ MfaController = _ts_decorate36([
9336
9400
  UseInterceptors(NoStoreInterceptor),
9337
9401
  Controller("mfa"),
9338
9402
  UseGuards(TrustedOriginGuard, AuthRateLimitGuard),
9339
9403
  UsePipes(createAuthValidationPipe({
9340
9404
  forbidUnknownValues: true
9341
9405
  })),
9342
- _ts_param20(0, Inject(MfaService)),
9343
- _ts_param20(1, Inject(TokenDeliveryService)),
9344
- _ts_param20(2, Inject(BYMAX_AUTH_OPTIONS)),
9345
- _ts_metadata34("design:type", Function),
9346
- _ts_metadata34("design:paramtypes", [
9406
+ _ts_param21(0, Inject(MfaService)),
9407
+ _ts_param21(1, Inject(TokenDeliveryService)),
9408
+ _ts_param21(2, Inject(BYMAX_AUTH_OPTIONS)),
9409
+ _ts_metadata35("design:type", Function),
9410
+ _ts_metadata35("design:paramtypes", [
9347
9411
  typeof MfaService === "undefined" ? Object : MfaService,
9348
9412
  typeof TokenDeliveryService === "undefined" ? Object : TokenDeliveryService,
9349
9413
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
9350
9414
  ])
9351
9415
  ], MfaController);
9352
9416
  var Authenticated = /* @__PURE__ */ __name(() => SetMetadata(IS_PUBLIC_KEY, false), "Authenticated");
9353
- function _ts_decorate36(decorators, target, key, desc) {
9417
+ function _ts_decorate37(decorators, target, key, desc) {
9354
9418
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9355
9419
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
9356
9420
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9357
9421
  return c > 3 && r && Object.defineProperty(target, key, r), r;
9358
9422
  }
9359
- __name(_ts_decorate36, "_ts_decorate");
9360
- function _ts_metadata35(k, v) {
9423
+ __name(_ts_decorate37, "_ts_decorate");
9424
+ function _ts_metadata36(k, v) {
9361
9425
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9362
9426
  }
9363
- __name(_ts_metadata35, "_ts_metadata");
9427
+ __name(_ts_metadata36, "_ts_metadata");
9364
9428
  var ChangePasswordDto = class {
9365
9429
  static {
9366
9430
  __name(this, "ChangePasswordDto");
@@ -9393,29 +9457,29 @@ var ChangePasswordDto = class {
9393
9457
  */
9394
9458
  newPassword;
9395
9459
  };
9396
- _ts_decorate36([
9460
+ _ts_decorate37([
9397
9461
  IsString(),
9398
9462
  MinLength(1),
9399
9463
  MaxLength(128),
9400
- _ts_metadata35("design:type", String)
9464
+ _ts_metadata36("design:type", String)
9401
9465
  ], ChangePasswordDto.prototype, "currentPassword", void 0);
9402
- _ts_decorate36([
9466
+ _ts_decorate37([
9403
9467
  IsString(),
9404
9468
  MinLength(8),
9405
9469
  MaxLength(128),
9406
- _ts_metadata35("design:type", String)
9470
+ _ts_metadata36("design:type", String)
9407
9471
  ], ChangePasswordDto.prototype, "newPassword", void 0);
9408
- function _ts_decorate37(decorators, target, key, desc) {
9472
+ function _ts_decorate38(decorators, target, key, desc) {
9409
9473
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9410
9474
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
9411
9475
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9412
9476
  return c > 3 && r && Object.defineProperty(target, key, r), r;
9413
9477
  }
9414
- __name(_ts_decorate37, "_ts_decorate");
9415
- function _ts_metadata36(k, v) {
9478
+ __name(_ts_decorate38, "_ts_decorate");
9479
+ function _ts_metadata37(k, v) {
9416
9480
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9417
9481
  }
9418
- __name(_ts_metadata36, "_ts_metadata");
9482
+ __name(_ts_metadata37, "_ts_metadata");
9419
9483
  var ForgotPasswordDto = class {
9420
9484
  static {
9421
9485
  __name(this, "ForgotPasswordDto");
@@ -9431,32 +9495,33 @@ var ForgotPasswordDto = class {
9431
9495
  */
9432
9496
  tenantId;
9433
9497
  };
9434
- _ts_decorate37([
9498
+ _ts_decorate38([
9435
9499
  Transform(({ value }) => typeof value === "string" ? value.trim().toLowerCase() : value),
9436
9500
  IsEmail(),
9437
9501
  MaxLength(255),
9438
- _ts_metadata36("design:type", String)
9502
+ _ts_metadata37("design:type", String)
9439
9503
  ], ForgotPasswordDto.prototype, "email", void 0);
9440
- _ts_decorate37([
9504
+ _ts_decorate38([
9505
+ IsOptional(),
9441
9506
  IsString(),
9442
9507
  IsNotEmpty(),
9443
9508
  MaxLength(128),
9444
9509
  Matches(NO_CONTROL_CHARACTERS, {
9445
9510
  message: "tenantId must not contain control characters"
9446
9511
  }),
9447
- _ts_metadata36("design:type", String)
9512
+ _ts_metadata37("design:type", String)
9448
9513
  ], ForgotPasswordDto.prototype, "tenantId", void 0);
9449
- function _ts_decorate38(decorators, target, key, desc) {
9514
+ function _ts_decorate39(decorators, target, key, desc) {
9450
9515
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9451
9516
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
9452
9517
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9453
9518
  return c > 3 && r && Object.defineProperty(target, key, r), r;
9454
9519
  }
9455
- __name(_ts_decorate38, "_ts_decorate");
9456
- function _ts_metadata37(k, v) {
9520
+ __name(_ts_decorate39, "_ts_decorate");
9521
+ function _ts_metadata38(k, v) {
9457
9522
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9458
9523
  }
9459
- __name(_ts_metadata37, "_ts_metadata");
9524
+ __name(_ts_metadata38, "_ts_metadata");
9460
9525
  var ResendOtpDto = class {
9461
9526
  static {
9462
9527
  __name(this, "ResendOtpDto");
@@ -9471,32 +9536,33 @@ var ResendOtpDto = class {
9471
9536
  */
9472
9537
  tenantId;
9473
9538
  };
9474
- _ts_decorate38([
9539
+ _ts_decorate39([
9475
9540
  Transform(({ value }) => typeof value === "string" ? value.trim().toLowerCase() : value),
9476
9541
  IsEmail(),
9477
9542
  MaxLength(255),
9478
- _ts_metadata37("design:type", String)
9543
+ _ts_metadata38("design:type", String)
9479
9544
  ], ResendOtpDto.prototype, "email", void 0);
9480
- _ts_decorate38([
9545
+ _ts_decorate39([
9546
+ IsOptional(),
9481
9547
  IsString(),
9482
9548
  IsNotEmpty(),
9483
9549
  MaxLength(128),
9484
9550
  Matches(NO_CONTROL_CHARACTERS, {
9485
9551
  message: "tenantId must not contain control characters"
9486
9552
  }),
9487
- _ts_metadata37("design:type", String)
9553
+ _ts_metadata38("design:type", String)
9488
9554
  ], ResendOtpDto.prototype, "tenantId", void 0);
9489
- function _ts_decorate39(decorators, target, key, desc) {
9555
+ function _ts_decorate40(decorators, target, key, desc) {
9490
9556
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9491
9557
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
9492
9558
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9493
9559
  return c > 3 && r && Object.defineProperty(target, key, r), r;
9494
9560
  }
9495
- __name(_ts_decorate39, "_ts_decorate");
9496
- function _ts_metadata38(k, v) {
9561
+ __name(_ts_decorate40, "_ts_decorate");
9562
+ function _ts_metadata39(k, v) {
9497
9563
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9498
9564
  }
9499
- __name(_ts_metadata38, "_ts_metadata");
9565
+ __name(_ts_metadata39, "_ts_metadata");
9500
9566
  var ResetPasswordDto = class {
9501
9567
  static {
9502
9568
  __name(this, "ResetPasswordDto");
@@ -9543,57 +9609,58 @@ var ResetPasswordDto = class {
9543
9609
  */
9544
9610
  tenantId;
9545
9611
  };
9546
- _ts_decorate39([
9612
+ _ts_decorate40([
9547
9613
  Transform(({ value }) => typeof value === "string" ? value.trim().toLowerCase() : value),
9548
9614
  IsEmail(),
9549
9615
  MaxLength(255),
9550
- _ts_metadata38("design:type", String)
9616
+ _ts_metadata39("design:type", String)
9551
9617
  ], ResetPasswordDto.prototype, "email", void 0);
9552
- _ts_decorate39([
9618
+ _ts_decorate40([
9553
9619
  IsString(),
9554
9620
  MinLength(8),
9555
9621
  MaxLength(128),
9556
- _ts_metadata38("design:type", String)
9622
+ _ts_metadata39("design:type", String)
9557
9623
  ], ResetPasswordDto.prototype, "newPassword", void 0);
9558
- _ts_decorate39([
9624
+ _ts_decorate40([
9559
9625
  IsOptional(),
9560
9626
  IsString(),
9561
9627
  IsNotEmpty(),
9562
9628
  MaxLength(2048),
9563
- _ts_metadata38("design:type", String)
9629
+ _ts_metadata39("design:type", String)
9564
9630
  ], ResetPasswordDto.prototype, "token", void 0);
9565
- _ts_decorate39([
9631
+ _ts_decorate40([
9566
9632
  IsOptional(),
9567
9633
  IsString(),
9568
9634
  Length(4, 8),
9569
- _ts_metadata38("design:type", String)
9635
+ _ts_metadata39("design:type", String)
9570
9636
  ], ResetPasswordDto.prototype, "otp", void 0);
9571
- _ts_decorate39([
9637
+ _ts_decorate40([
9572
9638
  IsOptional(),
9573
9639
  IsString(),
9574
9640
  Length(64, 64),
9575
- _ts_metadata38("design:type", String)
9641
+ _ts_metadata39("design:type", String)
9576
9642
  ], ResetPasswordDto.prototype, "verifiedToken", void 0);
9577
- _ts_decorate39([
9643
+ _ts_decorate40([
9644
+ IsOptional(),
9578
9645
  IsString(),
9579
9646
  IsNotEmpty(),
9580
9647
  MaxLength(128),
9581
9648
  Matches(NO_CONTROL_CHARACTERS, {
9582
9649
  message: "tenantId must not contain control characters"
9583
9650
  }),
9584
- _ts_metadata38("design:type", String)
9651
+ _ts_metadata39("design:type", String)
9585
9652
  ], ResetPasswordDto.prototype, "tenantId", void 0);
9586
- function _ts_decorate40(decorators, target, key, desc) {
9653
+ function _ts_decorate41(decorators, target, key, desc) {
9587
9654
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9588
9655
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
9589
9656
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9590
9657
  return c > 3 && r && Object.defineProperty(target, key, r), r;
9591
9658
  }
9592
- __name(_ts_decorate40, "_ts_decorate");
9593
- function _ts_metadata39(k, v) {
9659
+ __name(_ts_decorate41, "_ts_decorate");
9660
+ function _ts_metadata40(k, v) {
9594
9661
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9595
9662
  }
9596
- __name(_ts_metadata39, "_ts_metadata");
9663
+ __name(_ts_metadata40, "_ts_metadata");
9597
9664
  var VerifyOtpDto = class {
9598
9665
  static {
9599
9666
  __name(this, "VerifyOtpDto");
@@ -9615,43 +9682,44 @@ var VerifyOtpDto = class {
9615
9682
  */
9616
9683
  tenantId;
9617
9684
  };
9618
- _ts_decorate40([
9685
+ _ts_decorate41([
9619
9686
  Transform(({ value }) => typeof value === "string" ? value.trim().toLowerCase() : value),
9620
9687
  IsEmail(),
9621
9688
  MaxLength(255),
9622
- _ts_metadata39("design:type", String)
9689
+ _ts_metadata40("design:type", String)
9623
9690
  ], VerifyOtpDto.prototype, "email", void 0);
9624
- _ts_decorate40([
9691
+ _ts_decorate41([
9625
9692
  IsString(),
9626
9693
  Length(4, 8),
9627
- _ts_metadata39("design:type", String)
9694
+ _ts_metadata40("design:type", String)
9628
9695
  ], VerifyOtpDto.prototype, "otp", void 0);
9629
- _ts_decorate40([
9696
+ _ts_decorate41([
9697
+ IsOptional(),
9630
9698
  IsString(),
9631
9699
  IsNotEmpty(),
9632
9700
  MaxLength(128),
9633
9701
  Matches(NO_CONTROL_CHARACTERS, {
9634
9702
  message: "tenantId must not contain control characters"
9635
9703
  }),
9636
- _ts_metadata39("design:type", String)
9704
+ _ts_metadata40("design:type", String)
9637
9705
  ], VerifyOtpDto.prototype, "tenantId", void 0);
9638
- function _ts_decorate41(decorators, target, key, desc) {
9706
+ function _ts_decorate42(decorators, target, key, desc) {
9639
9707
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9640
9708
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
9641
9709
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9642
9710
  return c > 3 && r && Object.defineProperty(target, key, r), r;
9643
9711
  }
9644
- __name(_ts_decorate41, "_ts_decorate");
9645
- function _ts_metadata40(k, v) {
9712
+ __name(_ts_decorate42, "_ts_decorate");
9713
+ function _ts_metadata41(k, v) {
9646
9714
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9647
9715
  }
9648
- __name(_ts_metadata40, "_ts_metadata");
9649
- function _ts_param21(paramIndex, decorator) {
9716
+ __name(_ts_metadata41, "_ts_metadata");
9717
+ function _ts_param22(paramIndex, decorator) {
9650
9718
  return function(target, key) {
9651
9719
  decorator(target, key, paramIndex);
9652
9720
  };
9653
9721
  }
9654
- __name(_ts_param21, "_ts_param");
9722
+ __name(_ts_param22, "_ts_param");
9655
9723
  var ANTI_ENUM_MIN_MS2 = 300;
9656
9724
  var VERIFIED_TOKEN_TTL_SECONDS = 300;
9657
9725
  var PASSWORD_RESET_PURPOSE = "password_reset";
@@ -9712,20 +9780,20 @@ var PasswordResetService = class _PasswordResetService {
9712
9780
  email: normalizeEmail(dto.email)
9713
9781
  };
9714
9782
  const start = Date.now();
9715
- const cooldownKey = `resend:${PASSWORD_RESET_PURPOSE}:${this.otpIdentifier(dto.tenantId, dto.email)}`;
9783
+ const cooldownKey = `resend:${PASSWORD_RESET_PURPOSE}:${this.otpIdentifier(tenantId, dto.email)}`;
9716
9784
  const wasSet = await this.redis.setnx(cooldownKey, RESEND_COOLDOWN_SECONDS);
9717
9785
  if (!wasSet) {
9718
9786
  await sleep(Math.max(0, ANTI_ENUM_MIN_MS2 - (Date.now() - start)));
9719
9787
  return;
9720
9788
  }
9721
9789
  try {
9722
- const user = tenantScoped(await this.userRepo.findByEmail(dto.email, dto.tenantId), dto.tenantId);
9790
+ const user = tenantScoped(await this.userRepo.findByEmail(dto.email, tenantId), tenantId);
9723
9791
  if (user && !this.isBlocked(user.status)) {
9724
9792
  const { method } = this.options.passwordReset;
9725
9793
  if (method === "otp") {
9726
- await this.sendOtp(dto.email, dto.tenantId, user.id);
9794
+ await this.sendOtp(dto.email, tenantId, user.id);
9727
9795
  } else {
9728
- await this.sendToken(dto.email, dto.tenantId, user.id);
9796
+ await this.sendToken(dto.email, tenantId, user.id);
9729
9797
  }
9730
9798
  }
9731
9799
  } catch (err) {
@@ -9775,18 +9843,18 @@ var PasswordResetService = class _PasswordResetService {
9775
9843
  if (!dto.token) {
9776
9844
  throw new AuthException(AUTH_ERROR_CODES.PASSWORD_RESET_TOKEN_INVALID);
9777
9845
  }
9778
- await this.resetWithToken(dto.email, dto.tenantId, dto.token, dto.newPassword);
9846
+ await this.resetWithToken(dto.email, tenantId, dto.token, dto.newPassword);
9779
9847
  return;
9780
9848
  }
9781
9849
  if (dto.token) {
9782
9850
  throw new AuthException(AUTH_ERROR_CODES.PASSWORD_RESET_TOKEN_INVALID);
9783
9851
  }
9784
9852
  if (dto.verifiedToken) {
9785
- await this.resetWithVerifiedToken(dto.email, dto.tenantId, dto.verifiedToken, dto.newPassword);
9853
+ await this.resetWithVerifiedToken(dto.email, tenantId, dto.verifiedToken, dto.newPassword);
9786
9854
  return;
9787
9855
  }
9788
9856
  if (dto.otp) {
9789
- await this.resetWithOtp(dto.email, dto.tenantId, dto.otp, dto.newPassword);
9857
+ await this.resetWithOtp(dto.email, tenantId, dto.otp, dto.newPassword);
9790
9858
  return;
9791
9859
  }
9792
9860
  throw new AuthException(AUTH_ERROR_CODES.PASSWORD_RESET_TOKEN_INVALID);
@@ -9815,9 +9883,9 @@ var PasswordResetService = class _PasswordResetService {
9815
9883
  tenantId,
9816
9884
  email: normalizeEmail(dto.email)
9817
9885
  };
9818
- const identifier = this.otpIdentifier(dto.tenantId, dto.email);
9886
+ const identifier = this.otpIdentifier(tenantId, dto.email);
9819
9887
  await this.otpService.verify(PASSWORD_RESET_PURPOSE, identifier, dto.otp);
9820
- const user = tenantScoped(await this.userRepo.findByEmail(dto.email, dto.tenantId), dto.tenantId);
9888
+ const user = tenantScoped(await this.userRepo.findByEmail(dto.email, tenantId), tenantId);
9821
9889
  if (!user) {
9822
9890
  throw new AuthException(AUTH_ERROR_CODES.PASSWORD_RESET_TOKEN_INVALID);
9823
9891
  }
@@ -9825,7 +9893,7 @@ var PasswordResetService = class _PasswordResetService {
9825
9893
  const context = {
9826
9894
  userId: user.id,
9827
9895
  email: dto.email,
9828
- tenantId: dto.tenantId,
9896
+ tenantId,
9829
9897
  passwordFingerprint: await this.passwordFingerprintOf(user.id)
9830
9898
  };
9831
9899
  await this.redis.set(`pw_vtok:${sha256(rawVerifiedToken)}`, JSON.stringify(context), VERIFIED_TOKEN_TTL_SECONDS);
@@ -9850,7 +9918,7 @@ var PasswordResetService = class _PasswordResetService {
9850
9918
  email: normalizeEmail(dto.email)
9851
9919
  };
9852
9920
  const start = Date.now();
9853
- const identifier = this.otpIdentifier(dto.tenantId, dto.email);
9921
+ const identifier = this.otpIdentifier(tenantId, dto.email);
9854
9922
  const cooldownKey = `resend:${PASSWORD_RESET_PURPOSE}:${identifier}`;
9855
9923
  const wasSet = await this.redis.setnx(cooldownKey, RESEND_COOLDOWN_SECONDS);
9856
9924
  if (!wasSet) {
@@ -9858,9 +9926,9 @@ var PasswordResetService = class _PasswordResetService {
9858
9926
  return;
9859
9927
  }
9860
9928
  try {
9861
- const user = tenantScoped(await this.userRepo.findByEmail(dto.email, dto.tenantId), dto.tenantId);
9929
+ const user = tenantScoped(await this.userRepo.findByEmail(dto.email, tenantId), tenantId);
9862
9930
  if (user && !this.isBlocked(user.status)) {
9863
- await this.sendOtp(dto.email, dto.tenantId, user.id);
9931
+ await this.sendOtp(dto.email, tenantId, user.id);
9864
9932
  }
9865
9933
  } catch (err) {
9866
9934
  this.logger.error("resendOtp: unexpected error", err);
@@ -10013,7 +10081,7 @@ var PasswordResetService = class _PasswordResetService {
10013
10081
  async notifyPasswordChanged(user) {
10014
10082
  const send = this.emailProvider?.sendPasswordChangedNotification;
10015
10083
  if (send === void 0) return;
10016
- void Promise.resolve(send.call(this.emailProvider, user.email)).catch((err) => {
10084
+ void Promise.resolve(send.call(this.emailProvider, user.tenantId, user.email)).catch((err) => {
10017
10085
  this.logger.error("notifyPasswordChanged: delivery failed", err);
10018
10086
  });
10019
10087
  }
@@ -10084,7 +10152,7 @@ var PasswordResetService = class _PasswordResetService {
10084
10152
  passwordFingerprint: await this.passwordFingerprintOf(userId)
10085
10153
  };
10086
10154
  await this.redis.set(tokenKey, JSON.stringify(context), this.options.passwordReset.tokenTtlSeconds);
10087
- void Promise.resolve(this.emailProvider.sendPasswordResetToken(email, rawToken)).catch((err) => {
10155
+ void Promise.resolve(this.emailProvider.sendPasswordResetToken(tenantId, email, rawToken)).catch((err) => {
10088
10156
  this.logger.error(`sendPasswordResetToken failed for user ${userId}`, err);
10089
10157
  void this.redis.del(tokenKey).catch((delErr) => {
10090
10158
  this.logger.error(`pw_reset rollback delete failed for user ${userId}`, delErr);
@@ -10104,7 +10172,7 @@ var PasswordResetService = class _PasswordResetService {
10104
10172
  const identifier = this.otpIdentifier(tenantId, email);
10105
10173
  const otp = this.otpService.generate(otpLength);
10106
10174
  await this.otpService.store(PASSWORD_RESET_PURPOSE, identifier, otp, otpTtlSeconds);
10107
- void Promise.resolve(this.emailProvider.sendPasswordResetOtp(email, otp)).catch((err) => {
10175
+ void Promise.resolve(this.emailProvider.sendPasswordResetOtp(tenantId, email, otp)).catch((err) => {
10108
10176
  this.logger.error(`sendPasswordResetOtp failed for user ${userId}`, err);
10109
10177
  });
10110
10178
  }
@@ -10164,21 +10232,21 @@ var PasswordResetService = class _PasswordResetService {
10164
10232
  };
10165
10233
  }
10166
10234
  };
10167
- PasswordResetService = _ts_decorate41([
10235
+ PasswordResetService = _ts_decorate42([
10168
10236
  Injectable(),
10169
- _ts_param21(0, Inject(BYMAX_AUTH_OPTIONS)),
10170
- _ts_param21(1, Inject(BYMAX_AUTH_USER_REPOSITORY)),
10171
- _ts_param21(2, Inject(BYMAX_AUTH_EMAIL_PROVIDER)),
10172
- _ts_param21(2, Optional()),
10173
- _ts_param21(3, Inject(BYMAX_AUTH_HOOKS)),
10174
- _ts_param21(3, Optional()),
10175
- _ts_param21(4, Inject(OtpService)),
10176
- _ts_param21(5, Inject(PasswordService)),
10177
- _ts_param21(6, Inject(AuthRedisService)),
10178
- _ts_param21(7, Inject(SessionService)),
10179
- _ts_param21(8, Inject(BruteForceService)),
10180
- _ts_metadata40("design:type", Function),
10181
- _ts_metadata40("design:paramtypes", [
10237
+ _ts_param22(0, Inject(BYMAX_AUTH_OPTIONS)),
10238
+ _ts_param22(1, Inject(BYMAX_AUTH_USER_REPOSITORY)),
10239
+ _ts_param22(2, Inject(BYMAX_AUTH_EMAIL_PROVIDER)),
10240
+ _ts_param22(2, Optional()),
10241
+ _ts_param22(3, Inject(BYMAX_AUTH_HOOKS)),
10242
+ _ts_param22(3, Optional()),
10243
+ _ts_param22(4, Inject(OtpService)),
10244
+ _ts_param22(5, Inject(PasswordService)),
10245
+ _ts_param22(6, Inject(AuthRedisService)),
10246
+ _ts_param22(7, Inject(SessionService)),
10247
+ _ts_param22(8, Inject(BruteForceService)),
10248
+ _ts_metadata41("design:type", Function),
10249
+ _ts_metadata41("design:paramtypes", [
10182
10250
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
10183
10251
  typeof IUserRepository === "undefined" ? Object : IUserRepository,
10184
10252
  Object,
@@ -10197,23 +10265,23 @@ function toSafeUser3(user) {
10197
10265
  __name(toSafeUser3, "toSafeUser");
10198
10266
 
10199
10267
  // src/server/controllers/password-reset.controller.ts
10200
- function _ts_decorate42(decorators, target, key, desc) {
10268
+ function _ts_decorate43(decorators, target, key, desc) {
10201
10269
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10202
10270
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10203
10271
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10204
10272
  return c > 3 && r && Object.defineProperty(target, key, r), r;
10205
10273
  }
10206
- __name(_ts_decorate42, "_ts_decorate");
10207
- function _ts_metadata41(k, v) {
10274
+ __name(_ts_decorate43, "_ts_decorate");
10275
+ function _ts_metadata42(k, v) {
10208
10276
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10209
10277
  }
10210
- __name(_ts_metadata41, "_ts_metadata");
10211
- function _ts_param22(paramIndex, decorator) {
10278
+ __name(_ts_metadata42, "_ts_metadata");
10279
+ function _ts_param23(paramIndex, decorator) {
10212
10280
  return function(target, key) {
10213
10281
  decorator(target, key, paramIndex);
10214
10282
  };
10215
10283
  }
10216
- __name(_ts_param22, "_ts_param");
10284
+ __name(_ts_param23, "_ts_param");
10217
10285
  var PasswordResetController = class {
10218
10286
  static {
10219
10287
  __name(this, "PasswordResetController");
@@ -10324,105 +10392,105 @@ var PasswordResetController = class {
10324
10392
  await this.passwordResetService.resendOtp(dto, req);
10325
10393
  }
10326
10394
  };
10327
- _ts_decorate42([
10395
+ _ts_decorate43([
10328
10396
  Throttle(AUTH_THROTTLE_CONFIGS.forgotPassword),
10329
10397
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.forgotPassword),
10330
10398
  HttpCode(HttpStatus.OK),
10331
10399
  Post("forgot-password"),
10332
- _ts_param22(0, Body()),
10333
- _ts_param22(1, Req()),
10334
- _ts_metadata41("design:type", Function),
10335
- _ts_metadata41("design:paramtypes", [
10400
+ _ts_param23(0, Body()),
10401
+ _ts_param23(1, Req()),
10402
+ _ts_metadata42("design:type", Function),
10403
+ _ts_metadata42("design:paramtypes", [
10336
10404
  typeof ForgotPasswordDto === "undefined" ? Object : ForgotPasswordDto,
10337
10405
  typeof Request === "undefined" ? Object : Request
10338
10406
  ]),
10339
- _ts_metadata41("design:returntype", Promise)
10407
+ _ts_metadata42("design:returntype", Promise)
10340
10408
  ], PasswordResetController.prototype, "forgotPassword", null);
10341
- _ts_decorate42([
10409
+ _ts_decorate43([
10342
10410
  Throttle(AUTH_THROTTLE_CONFIGS.resetPassword),
10343
10411
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.resetPassword),
10344
10412
  HttpCode(HttpStatus.NO_CONTENT),
10345
10413
  Post("reset-password"),
10346
- _ts_param22(0, Body()),
10347
- _ts_param22(1, Req()),
10348
- _ts_metadata41("design:type", Function),
10349
- _ts_metadata41("design:paramtypes", [
10414
+ _ts_param23(0, Body()),
10415
+ _ts_param23(1, Req()),
10416
+ _ts_metadata42("design:type", Function),
10417
+ _ts_metadata42("design:paramtypes", [
10350
10418
  typeof ResetPasswordDto === "undefined" ? Object : ResetPasswordDto,
10351
10419
  typeof Request === "undefined" ? Object : Request
10352
10420
  ]),
10353
- _ts_metadata41("design:returntype", Promise)
10421
+ _ts_metadata42("design:returntype", Promise)
10354
10422
  ], PasswordResetController.prototype, "resetPassword", null);
10355
- _ts_decorate42([
10423
+ _ts_decorate43([
10356
10424
  Authenticated(),
10357
10425
  UseGuards(JwtAuthGuard, UserStatusGuard),
10358
10426
  Throttle(AUTH_THROTTLE_CONFIGS.changePassword),
10359
10427
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.changePassword),
10360
10428
  HttpCode(HttpStatus.NO_CONTENT),
10361
10429
  Post("change"),
10362
- _ts_param22(0, CurrentUser()),
10363
- _ts_param22(1, Body()),
10364
- _ts_param22(2, Req()),
10365
- _ts_metadata41("design:type", Function),
10366
- _ts_metadata41("design:paramtypes", [
10430
+ _ts_param23(0, CurrentUser()),
10431
+ _ts_param23(1, Body()),
10432
+ _ts_param23(2, Req()),
10433
+ _ts_metadata42("design:type", Function),
10434
+ _ts_metadata42("design:paramtypes", [
10367
10435
  typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
10368
10436
  typeof ChangePasswordDto === "undefined" ? Object : ChangePasswordDto,
10369
10437
  typeof Request === "undefined" ? Object : Request
10370
10438
  ]),
10371
- _ts_metadata41("design:returntype", Promise)
10439
+ _ts_metadata42("design:returntype", Promise)
10372
10440
  ], PasswordResetController.prototype, "changePassword", null);
10373
- _ts_decorate42([
10441
+ _ts_decorate43([
10374
10442
  Throttle(AUTH_THROTTLE_CONFIGS.verifyOtp),
10375
10443
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.verifyOtp),
10376
10444
  HttpCode(HttpStatus.OK),
10377
10445
  Post("verify-otp"),
10378
- _ts_param22(0, Body()),
10379
- _ts_param22(1, Req()),
10380
- _ts_metadata41("design:type", Function),
10381
- _ts_metadata41("design:paramtypes", [
10446
+ _ts_param23(0, Body()),
10447
+ _ts_param23(1, Req()),
10448
+ _ts_metadata42("design:type", Function),
10449
+ _ts_metadata42("design:paramtypes", [
10382
10450
  typeof VerifyOtpDto === "undefined" ? Object : VerifyOtpDto,
10383
10451
  typeof Request === "undefined" ? Object : Request
10384
10452
  ]),
10385
- _ts_metadata41("design:returntype", Promise)
10453
+ _ts_metadata42("design:returntype", Promise)
10386
10454
  ], PasswordResetController.prototype, "verifyOtp", null);
10387
- _ts_decorate42([
10455
+ _ts_decorate43([
10388
10456
  Throttle(AUTH_THROTTLE_CONFIGS.resendPasswordOtp),
10389
10457
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.resendPasswordOtp),
10390
10458
  HttpCode(HttpStatus.OK),
10391
10459
  Post("resend-otp"),
10392
- _ts_param22(0, Body()),
10393
- _ts_param22(1, Req()),
10394
- _ts_metadata41("design:type", Function),
10395
- _ts_metadata41("design:paramtypes", [
10460
+ _ts_param23(0, Body()),
10461
+ _ts_param23(1, Req()),
10462
+ _ts_metadata42("design:type", Function),
10463
+ _ts_metadata42("design:paramtypes", [
10396
10464
  typeof ResendOtpDto === "undefined" ? Object : ResendOtpDto,
10397
10465
  typeof Request === "undefined" ? Object : Request
10398
10466
  ]),
10399
- _ts_metadata41("design:returntype", Promise)
10467
+ _ts_metadata42("design:returntype", Promise)
10400
10468
  ], PasswordResetController.prototype, "resendOtp", null);
10401
- PasswordResetController = _ts_decorate42([
10469
+ PasswordResetController = _ts_decorate43([
10402
10470
  Public(),
10403
10471
  UseInterceptors(NoStoreInterceptor),
10404
10472
  Controller("password"),
10405
10473
  UseGuards(TrustedOriginGuard, AuthRateLimitGuard),
10406
10474
  UsePipes(createAuthValidationPipe()),
10407
- _ts_param22(0, Inject(PasswordResetService)),
10408
- _ts_param22(1, Inject(TokenDeliveryService)),
10409
- _ts_metadata41("design:type", Function),
10410
- _ts_metadata41("design:paramtypes", [
10475
+ _ts_param23(0, Inject(PasswordResetService)),
10476
+ _ts_param23(1, Inject(TokenDeliveryService)),
10477
+ _ts_metadata42("design:type", Function),
10478
+ _ts_metadata42("design:paramtypes", [
10411
10479
  typeof PasswordResetService === "undefined" ? Object : PasswordResetService,
10412
10480
  typeof TokenDeliveryService === "undefined" ? Object : TokenDeliveryService
10413
10481
  ])
10414
10482
  ], PasswordResetController);
10415
- function _ts_decorate43(decorators, target, key, desc) {
10483
+ function _ts_decorate44(decorators, target, key, desc) {
10416
10484
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10417
10485
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10418
10486
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10419
10487
  return c > 3 && r && Object.defineProperty(target, key, r), r;
10420
10488
  }
10421
- __name(_ts_decorate43, "_ts_decorate");
10422
- function _ts_metadata42(k, v) {
10489
+ __name(_ts_decorate44, "_ts_decorate");
10490
+ function _ts_metadata43(k, v) {
10423
10491
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10424
10492
  }
10425
- __name(_ts_metadata42, "_ts_metadata");
10493
+ __name(_ts_metadata43, "_ts_metadata");
10426
10494
  var PlatformLoginDto = class {
10427
10495
  static {
10428
10496
  __name(this, "PlatformLoginDto");
@@ -10450,14 +10518,14 @@ var PlatformLoginDto = class {
10450
10518
  */
10451
10519
  password;
10452
10520
  };
10453
- _ts_decorate43([
10521
+ _ts_decorate44([
10454
10522
  Transform(({ value }) => typeof value === "string" ? value.trim().toLowerCase() : value),
10455
10523
  IsEmail(),
10456
10524
  IsNotEmpty(),
10457
10525
  MaxLength(255),
10458
- _ts_metadata42("design:type", String)
10526
+ _ts_metadata43("design:type", String)
10459
10527
  ], PlatformLoginDto.prototype, "email", void 0);
10460
- _ts_decorate43([
10528
+ _ts_decorate44([
10461
10529
  IsString(),
10462
10530
  IsNotEmpty(),
10463
10531
  Matches(/\S/, {
@@ -10465,38 +10533,38 @@ _ts_decorate43([
10465
10533
  }),
10466
10534
  MinLength(1),
10467
10535
  MaxLength(128),
10468
- _ts_metadata42("design:type", String)
10536
+ _ts_metadata43("design:type", String)
10469
10537
  ], PlatformLoginDto.prototype, "password", void 0);
10470
- function _ts_decorate44(decorators, target, key, desc) {
10538
+ function _ts_decorate45(decorators, target, key, desc) {
10471
10539
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10472
10540
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10473
10541
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10474
10542
  return c > 3 && r && Object.defineProperty(target, key, r), r;
10475
10543
  }
10476
- __name(_ts_decorate44, "_ts_decorate");
10477
- function _ts_metadata43(k, v) {
10544
+ __name(_ts_decorate45, "_ts_decorate");
10545
+ function _ts_metadata44(k, v) {
10478
10546
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10479
10547
  }
10480
- __name(_ts_metadata43, "_ts_metadata");
10481
- function _ts_param23(paramIndex, decorator) {
10548
+ __name(_ts_metadata44, "_ts_metadata");
10549
+ function _ts_param24(paramIndex, decorator) {
10482
10550
  return function(target, key) {
10483
10551
  decorator(target, key, paramIndex);
10484
10552
  };
10485
10553
  }
10486
- __name(_ts_param23, "_ts_param");
10554
+ __name(_ts_param24, "_ts_param");
10487
10555
  var JwtPlatformGuard = class {
10488
10556
  static {
10489
10557
  __name(this, "JwtPlatformGuard");
10490
10558
  }
10491
10559
  jwtService;
10492
10560
  tokenDelivery;
10493
- redis;
10561
+ revocation;
10494
10562
  reflector;
10495
10563
  options;
10496
- constructor(jwtService, tokenDelivery, redis, reflector, options) {
10564
+ constructor(jwtService, tokenDelivery, revocation, reflector, options) {
10497
10565
  this.jwtService = jwtService;
10498
10566
  this.tokenDelivery = tokenDelivery;
10499
- this.redis = redis;
10567
+ this.revocation = revocation;
10500
10568
  this.reflector = reflector;
10501
10569
  this.options = options;
10502
10570
  }
@@ -10522,51 +10590,46 @@ var JwtPlatformGuard = class {
10522
10590
  if (payload.type !== "platform") {
10523
10591
  throw new AuthException(AUTH_ERROR_CODES.PLATFORM_AUTH_REQUIRED);
10524
10592
  }
10525
- const revoked = await this.redis.get(`rv:${payload.jti}`);
10526
- if (revoked !== null) {
10527
- throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
10528
- }
10529
- const epoch = await this.redis.getUserTokenEpoch(payload.sub, "platform");
10530
- if (readStampedEpoch(payload) < epoch) {
10593
+ if (await this.revocation.isAccessTokenRevoked(payload, "platform")) {
10531
10594
  throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
10532
10595
  }
10533
10596
  request.user = payload;
10534
10597
  return true;
10535
10598
  }
10536
10599
  };
10537
- JwtPlatformGuard = _ts_decorate44([
10600
+ JwtPlatformGuard = _ts_decorate45([
10538
10601
  Injectable(),
10539
- _ts_param23(0, Inject(JwtService)),
10540
- _ts_param23(1, Inject(TokenDeliveryService)),
10541
- _ts_param23(2, Inject(AuthRedisService)),
10542
- _ts_param23(3, Inject(Reflector)),
10543
- _ts_param23(4, Inject(BYMAX_AUTH_OPTIONS)),
10544
- _ts_metadata43("design:type", Function),
10545
- _ts_metadata43("design:paramtypes", [
10602
+ _ts_param24(0, Inject(JwtService)),
10603
+ _ts_param24(1, Inject(TokenDeliveryService)),
10604
+ _ts_param24(2, Inject(AuthRevocationService)),
10605
+ _ts_param24(3, Inject(Reflector)),
10606
+ _ts_param24(4, Inject(BYMAX_AUTH_OPTIONS)),
10607
+ _ts_metadata44("design:type", Function),
10608
+ _ts_metadata44("design:paramtypes", [
10546
10609
  typeof JwtService === "undefined" ? Object : JwtService,
10547
10610
  typeof TokenDeliveryService === "undefined" ? Object : TokenDeliveryService,
10548
- typeof AuthRedisService === "undefined" ? Object : AuthRedisService,
10611
+ typeof AuthRevocationService === "undefined" ? Object : AuthRevocationService,
10549
10612
  typeof Reflector === "undefined" ? Object : Reflector,
10550
10613
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
10551
10614
  ])
10552
10615
  ], JwtPlatformGuard);
10553
- function _ts_decorate45(decorators, target, key, desc) {
10616
+ function _ts_decorate46(decorators, target, key, desc) {
10554
10617
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10555
10618
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10556
10619
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10557
10620
  return c > 3 && r && Object.defineProperty(target, key, r), r;
10558
10621
  }
10559
- __name(_ts_decorate45, "_ts_decorate");
10560
- function _ts_metadata44(k, v) {
10622
+ __name(_ts_decorate46, "_ts_decorate");
10623
+ function _ts_metadata45(k, v) {
10561
10624
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10562
10625
  }
10563
- __name(_ts_metadata44, "_ts_metadata");
10564
- function _ts_param24(paramIndex, decorator) {
10626
+ __name(_ts_metadata45, "_ts_metadata");
10627
+ function _ts_param25(paramIndex, decorator) {
10565
10628
  return function(target, key) {
10566
10629
  decorator(target, key, paramIndex);
10567
10630
  };
10568
10631
  }
10569
- __name(_ts_param24, "_ts_param");
10632
+ __name(_ts_param25, "_ts_param");
10570
10633
  var PlatformAuthService = class _PlatformAuthService {
10571
10634
  static {
10572
10635
  __name(this, "PlatformAuthService");
@@ -10788,16 +10851,16 @@ var PlatformAuthService = class _PlatformAuthService {
10788
10851
  await this.redis.bumpUserTokenEpoch(userId, "platform");
10789
10852
  }
10790
10853
  };
10791
- PlatformAuthService = _ts_decorate45([
10854
+ PlatformAuthService = _ts_decorate46([
10792
10855
  Injectable(),
10793
- _ts_param24(0, Inject(BYMAX_AUTH_PLATFORM_USER_REPOSITORY)),
10794
- _ts_param24(1, Inject(PasswordService)),
10795
- _ts_param24(2, Inject(TokenManagerService)),
10796
- _ts_param24(3, Inject(BruteForceService)),
10797
- _ts_param24(4, Inject(AuthRedisService)),
10798
- _ts_param24(5, Inject(BYMAX_AUTH_OPTIONS)),
10799
- _ts_metadata44("design:type", Function),
10800
- _ts_metadata44("design:paramtypes", [
10856
+ _ts_param25(0, Inject(BYMAX_AUTH_PLATFORM_USER_REPOSITORY)),
10857
+ _ts_param25(1, Inject(PasswordService)),
10858
+ _ts_param25(2, Inject(TokenManagerService)),
10859
+ _ts_param25(3, Inject(BruteForceService)),
10860
+ _ts_param25(4, Inject(AuthRedisService)),
10861
+ _ts_param25(5, Inject(BYMAX_AUTH_OPTIONS)),
10862
+ _ts_metadata45("design:type", Function),
10863
+ _ts_metadata45("design:paramtypes", [
10801
10864
  typeof IPlatformUserRepository === "undefined" ? Object : IPlatformUserRepository,
10802
10865
  typeof PasswordService === "undefined" ? Object : PasswordService,
10803
10866
  typeof TokenManagerService === "undefined" ? Object : TokenManagerService,
@@ -10808,23 +10871,23 @@ PlatformAuthService = _ts_decorate45([
10808
10871
  ], PlatformAuthService);
10809
10872
 
10810
10873
  // src/server/controllers/platform-auth.controller.ts
10811
- function _ts_decorate46(decorators, target, key, desc) {
10874
+ function _ts_decorate47(decorators, target, key, desc) {
10812
10875
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10813
10876
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10814
10877
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10815
10878
  return c > 3 && r && Object.defineProperty(target, key, r), r;
10816
10879
  }
10817
- __name(_ts_decorate46, "_ts_decorate");
10818
- function _ts_metadata45(k, v) {
10880
+ __name(_ts_decorate47, "_ts_decorate");
10881
+ function _ts_metadata46(k, v) {
10819
10882
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10820
10883
  }
10821
- __name(_ts_metadata45, "_ts_metadata");
10822
- function _ts_param25(paramIndex, decorator) {
10884
+ __name(_ts_metadata46, "_ts_metadata");
10885
+ function _ts_param26(paramIndex, decorator) {
10823
10886
  return function(target, key) {
10824
10887
  decorator(target, key, paramIndex);
10825
10888
  };
10826
10889
  }
10827
- __name(_ts_param25, "_ts_param");
10890
+ __name(_ts_param26, "_ts_param");
10828
10891
  function isPlatformResult2(result) {
10829
10892
  return "admin" in result;
10830
10893
  }
@@ -10984,117 +11047,117 @@ var PlatformAuthController = class {
10984
11047
  await this.platformAuthService.revokeAllPlatformSessions(user.sub);
10985
11048
  }
10986
11049
  };
10987
- _ts_decorate46([
11050
+ _ts_decorate47([
10988
11051
  Public(),
10989
11052
  Throttle(AUTH_THROTTLE_CONFIGS.platformLogin),
10990
11053
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.platformLogin),
10991
11054
  HttpCode(HttpStatus.OK),
10992
11055
  Post("login"),
10993
- _ts_param25(0, Body()),
10994
- _ts_param25(1, Req()),
10995
- _ts_metadata45("design:type", Function),
10996
- _ts_metadata45("design:paramtypes", [
11056
+ _ts_param26(0, Body()),
11057
+ _ts_param26(1, Req()),
11058
+ _ts_metadata46("design:type", Function),
11059
+ _ts_metadata46("design:paramtypes", [
10997
11060
  typeof PlatformLoginDto === "undefined" ? Object : PlatformLoginDto,
10998
11061
  typeof Request === "undefined" ? Object : Request
10999
11062
  ]),
11000
- _ts_metadata45("design:returntype", Promise)
11063
+ _ts_metadata46("design:returntype", Promise)
11001
11064
  ], PlatformAuthController.prototype, "login", null);
11002
- _ts_decorate46([
11065
+ _ts_decorate47([
11003
11066
  Public(),
11004
11067
  Throttle(AUTH_THROTTLE_CONFIGS.mfaChallenge),
11005
11068
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaChallenge),
11006
11069
  HttpCode(HttpStatus.OK),
11007
11070
  Post("mfa/challenge"),
11008
- _ts_param25(0, Body()),
11009
- _ts_param25(1, Req()),
11010
- _ts_metadata45("design:type", Function),
11011
- _ts_metadata45("design:paramtypes", [
11071
+ _ts_param26(0, Body()),
11072
+ _ts_param26(1, Req()),
11073
+ _ts_metadata46("design:type", Function),
11074
+ _ts_metadata46("design:paramtypes", [
11012
11075
  typeof MfaChallengeDto === "undefined" ? Object : MfaChallengeDto,
11013
11076
  typeof Request === "undefined" ? Object : Request
11014
11077
  ]),
11015
- _ts_metadata45("design:returntype", Promise)
11078
+ _ts_metadata46("design:returntype", Promise)
11016
11079
  ], PlatformAuthController.prototype, "mfaChallenge", null);
11017
- _ts_decorate46([
11080
+ _ts_decorate47([
11018
11081
  UseGuards(JwtPlatformGuard),
11019
11082
  Get("me"),
11020
- _ts_param25(0, CurrentUser()),
11021
- _ts_metadata45("design:type", Function),
11022
- _ts_metadata45("design:paramtypes", [
11083
+ _ts_param26(0, CurrentUser()),
11084
+ _ts_metadata46("design:type", Function),
11085
+ _ts_metadata46("design:paramtypes", [
11023
11086
  typeof PlatformJwtPayload === "undefined" ? Object : PlatformJwtPayload
11024
11087
  ]),
11025
- _ts_metadata45("design:returntype", Promise)
11088
+ _ts_metadata46("design:returntype", Promise)
11026
11089
  ], PlatformAuthController.prototype, "me", null);
11027
- _ts_decorate46([
11090
+ _ts_decorate47([
11028
11091
  Public(),
11029
11092
  Throttle(AUTH_THROTTLE_CONFIGS.logout),
11030
11093
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.logout),
11031
11094
  HttpCode(HttpStatus.NO_CONTENT),
11032
11095
  Post("logout"),
11033
- _ts_param25(0, Req()),
11034
- _ts_metadata45("design:type", Function),
11035
- _ts_metadata45("design:paramtypes", [
11096
+ _ts_param26(0, Req()),
11097
+ _ts_metadata46("design:type", Function),
11098
+ _ts_metadata46("design:paramtypes", [
11036
11099
  typeof Request === "undefined" ? Object : Request
11037
11100
  ]),
11038
- _ts_metadata45("design:returntype", Promise)
11101
+ _ts_metadata46("design:returntype", Promise)
11039
11102
  ], PlatformAuthController.prototype, "logout", null);
11040
- _ts_decorate46([
11103
+ _ts_decorate47([
11041
11104
  Public(),
11042
11105
  Throttle(AUTH_THROTTLE_CONFIGS.refresh),
11043
11106
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.refresh),
11044
11107
  HttpCode(HttpStatus.OK),
11045
11108
  Post("refresh"),
11046
- _ts_param25(0, Req()),
11047
- _ts_metadata45("design:type", Function),
11048
- _ts_metadata45("design:paramtypes", [
11109
+ _ts_param26(0, Req()),
11110
+ _ts_metadata46("design:type", Function),
11111
+ _ts_metadata46("design:paramtypes", [
11049
11112
  typeof Request === "undefined" ? Object : Request
11050
11113
  ]),
11051
- _ts_metadata45("design:returntype", Promise)
11114
+ _ts_metadata46("design:returntype", Promise)
11052
11115
  ], PlatformAuthController.prototype, "refresh", null);
11053
- _ts_decorate46([
11116
+ _ts_decorate47([
11054
11117
  UseGuards(JwtPlatformGuard),
11055
11118
  Throttle(AUTH_THROTTLE_CONFIGS.revokeAllSessions),
11056
11119
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.revokeAllSessions),
11057
11120
  HttpCode(HttpStatus.NO_CONTENT),
11058
11121
  Delete("sessions"),
11059
- _ts_param25(0, CurrentUser()),
11060
- _ts_metadata45("design:type", Function),
11061
- _ts_metadata45("design:paramtypes", [
11122
+ _ts_param26(0, CurrentUser()),
11123
+ _ts_metadata46("design:type", Function),
11124
+ _ts_metadata46("design:paramtypes", [
11062
11125
  typeof PlatformJwtPayload === "undefined" ? Object : PlatformJwtPayload
11063
11126
  ]),
11064
- _ts_metadata45("design:returntype", Promise)
11127
+ _ts_metadata46("design:returntype", Promise)
11065
11128
  ], PlatformAuthController.prototype, "revokeSessions", null);
11066
- PlatformAuthController = _ts_decorate46([
11129
+ PlatformAuthController = _ts_decorate47([
11067
11130
  UseInterceptors(NoStoreInterceptor),
11068
11131
  Controller("platform"),
11069
11132
  UseGuards(TrustedOriginGuard, AuthRateLimitGuard),
11070
11133
  UsePipes(createAuthValidationPipe()),
11071
- _ts_param25(0, Inject(PlatformAuthService)),
11072
- _ts_param25(1, Inject(MfaService)),
11073
- _ts_param25(2, Inject(TokenDeliveryService)),
11074
- _ts_metadata45("design:type", Function),
11075
- _ts_metadata45("design:paramtypes", [
11134
+ _ts_param26(0, Inject(PlatformAuthService)),
11135
+ _ts_param26(1, Inject(MfaService)),
11136
+ _ts_param26(2, Inject(TokenDeliveryService)),
11137
+ _ts_metadata46("design:type", Function),
11138
+ _ts_metadata46("design:paramtypes", [
11076
11139
  typeof PlatformAuthService === "undefined" ? Object : PlatformAuthService,
11077
11140
  typeof MfaService === "undefined" ? Object : MfaService,
11078
11141
  typeof TokenDeliveryService === "undefined" ? Object : TokenDeliveryService
11079
11142
  ])
11080
11143
  ], PlatformAuthController);
11081
- function _ts_decorate47(decorators, target, key, desc) {
11144
+ function _ts_decorate48(decorators, target, key, desc) {
11082
11145
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11083
11146
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11084
11147
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11085
11148
  return c > 3 && r && Object.defineProperty(target, key, r), r;
11086
11149
  }
11087
- __name(_ts_decorate47, "_ts_decorate");
11088
- function _ts_metadata46(k, v) {
11150
+ __name(_ts_decorate48, "_ts_decorate");
11151
+ function _ts_metadata47(k, v) {
11089
11152
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
11090
11153
  }
11091
- __name(_ts_metadata46, "_ts_metadata");
11092
- function _ts_param26(paramIndex, decorator) {
11154
+ __name(_ts_metadata47, "_ts_metadata");
11155
+ function _ts_param27(paramIndex, decorator) {
11093
11156
  return function(target, key) {
11094
11157
  decorator(target, key, paramIndex);
11095
11158
  };
11096
11159
  }
11097
- __name(_ts_param26, "_ts_param");
11160
+ __name(_ts_param27, "_ts_param");
11098
11161
  var PlatformMfaController = class {
11099
11162
  static {
11100
11163
  __name(this, "PlatformMfaController");
@@ -11173,101 +11236,101 @@ var PlatformMfaController = class {
11173
11236
  return this.mfaService.regenerateRecoveryCodes(user.sub, dto.code, ip, userAgent, "platform");
11174
11237
  }
11175
11238
  };
11176
- _ts_decorate47([
11239
+ _ts_decorate48([
11177
11240
  UseGuards(JwtPlatformGuard),
11178
11241
  Throttle(AUTH_THROTTLE_CONFIGS.mfaSetup),
11179
11242
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaSetup),
11180
11243
  Post("setup"),
11181
- _ts_param26(0, CurrentUser()),
11182
- _ts_param26(1, Body()),
11183
- _ts_metadata46("design:type", Function),
11184
- _ts_metadata46("design:paramtypes", [
11244
+ _ts_param27(0, CurrentUser()),
11245
+ _ts_param27(1, Body()),
11246
+ _ts_metadata47("design:type", Function),
11247
+ _ts_metadata47("design:paramtypes", [
11185
11248
  typeof PlatformJwtPayload === "undefined" ? Object : PlatformJwtPayload,
11186
11249
  typeof MfaSetupDto === "undefined" ? Object : MfaSetupDto
11187
11250
  ]),
11188
- _ts_metadata46("design:returntype", Promise)
11251
+ _ts_metadata47("design:returntype", Promise)
11189
11252
  ], PlatformMfaController.prototype, "setup", null);
11190
- _ts_decorate47([
11253
+ _ts_decorate48([
11191
11254
  UseGuards(JwtPlatformGuard),
11192
11255
  Throttle(AUTH_THROTTLE_CONFIGS.mfaVerifyEnable),
11193
11256
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaVerifyEnable),
11194
11257
  HttpCode(HttpStatus.NO_CONTENT),
11195
11258
  Post("verify-enable"),
11196
- _ts_param26(0, CurrentUser()),
11197
- _ts_param26(1, Body()),
11198
- _ts_param26(2, Req()),
11199
- _ts_metadata46("design:type", Function),
11200
- _ts_metadata46("design:paramtypes", [
11259
+ _ts_param27(0, CurrentUser()),
11260
+ _ts_param27(1, Body()),
11261
+ _ts_param27(2, Req()),
11262
+ _ts_metadata47("design:type", Function),
11263
+ _ts_metadata47("design:paramtypes", [
11201
11264
  typeof PlatformJwtPayload === "undefined" ? Object : PlatformJwtPayload,
11202
11265
  typeof MfaVerifyDto === "undefined" ? Object : MfaVerifyDto,
11203
11266
  typeof Request === "undefined" ? Object : Request
11204
11267
  ]),
11205
- _ts_metadata46("design:returntype", Promise)
11268
+ _ts_metadata47("design:returntype", Promise)
11206
11269
  ], PlatformMfaController.prototype, "verifyEnable", null);
11207
- _ts_decorate47([
11270
+ _ts_decorate48([
11208
11271
  UseGuards(JwtPlatformGuard),
11209
11272
  Throttle(AUTH_THROTTLE_CONFIGS.mfaDisable),
11210
11273
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaDisable),
11211
11274
  HttpCode(HttpStatus.NO_CONTENT),
11212
11275
  Post("disable"),
11213
- _ts_param26(0, CurrentUser()),
11214
- _ts_param26(1, Body()),
11215
- _ts_param26(2, Req()),
11216
- _ts_metadata46("design:type", Function),
11217
- _ts_metadata46("design:paramtypes", [
11276
+ _ts_param27(0, CurrentUser()),
11277
+ _ts_param27(1, Body()),
11278
+ _ts_param27(2, Req()),
11279
+ _ts_metadata47("design:type", Function),
11280
+ _ts_metadata47("design:paramtypes", [
11218
11281
  typeof PlatformJwtPayload === "undefined" ? Object : PlatformJwtPayload,
11219
11282
  typeof MfaDisableDto === "undefined" ? Object : MfaDisableDto,
11220
11283
  typeof Request === "undefined" ? Object : Request
11221
11284
  ]),
11222
- _ts_metadata46("design:returntype", Promise)
11285
+ _ts_metadata47("design:returntype", Promise)
11223
11286
  ], PlatformMfaController.prototype, "disable", null);
11224
- _ts_decorate47([
11287
+ _ts_decorate48([
11225
11288
  UseGuards(JwtPlatformGuard),
11226
11289
  Throttle(AUTH_THROTTLE_CONFIGS.mfaDisable),
11227
11290
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaDisable),
11228
11291
  HttpCode(HttpStatus.OK),
11229
11292
  Post("recovery-codes"),
11230
- _ts_param26(0, CurrentUser()),
11231
- _ts_param26(1, Body()),
11232
- _ts_param26(2, Req()),
11233
- _ts_metadata46("design:type", Function),
11234
- _ts_metadata46("design:paramtypes", [
11293
+ _ts_param27(0, CurrentUser()),
11294
+ _ts_param27(1, Body()),
11295
+ _ts_param27(2, Req()),
11296
+ _ts_metadata47("design:type", Function),
11297
+ _ts_metadata47("design:paramtypes", [
11235
11298
  typeof PlatformJwtPayload === "undefined" ? Object : PlatformJwtPayload,
11236
11299
  typeof MfaRegenerateRecoveryCodesDto === "undefined" ? Object : MfaRegenerateRecoveryCodesDto,
11237
11300
  typeof Request === "undefined" ? Object : Request
11238
11301
  ]),
11239
- _ts_metadata46("design:returntype", Promise)
11302
+ _ts_metadata47("design:returntype", Promise)
11240
11303
  ], PlatformMfaController.prototype, "regenerateRecoveryCodes", null);
11241
- PlatformMfaController = _ts_decorate47([
11304
+ PlatformMfaController = _ts_decorate48([
11242
11305
  UseInterceptors(NoStoreInterceptor),
11243
11306
  Controller("platform/mfa"),
11244
11307
  UseGuards(TrustedOriginGuard, AuthRateLimitGuard),
11245
11308
  UsePipes(createAuthValidationPipe({
11246
11309
  forbidUnknownValues: true
11247
11310
  })),
11248
- _ts_param26(0, Inject(MfaService)),
11249
- _ts_metadata46("design:type", Function),
11250
- _ts_metadata46("design:paramtypes", [
11311
+ _ts_param27(0, Inject(MfaService)),
11312
+ _ts_metadata47("design:type", Function),
11313
+ _ts_metadata47("design:paramtypes", [
11251
11314
  typeof MfaService === "undefined" ? Object : MfaService
11252
11315
  ])
11253
11316
  ], PlatformMfaController);
11254
- function _ts_decorate48(decorators, target, key, desc) {
11317
+ function _ts_decorate49(decorators, target, key, desc) {
11255
11318
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11256
11319
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11257
11320
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11258
11321
  return c > 3 && r && Object.defineProperty(target, key, r), r;
11259
11322
  }
11260
- __name(_ts_decorate48, "_ts_decorate");
11261
- function _ts_metadata47(k, v) {
11323
+ __name(_ts_decorate49, "_ts_decorate");
11324
+ function _ts_metadata48(k, v) {
11262
11325
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
11263
11326
  }
11264
- __name(_ts_metadata47, "_ts_metadata");
11265
- function _ts_param27(paramIndex, decorator) {
11327
+ __name(_ts_metadata48, "_ts_metadata");
11328
+ function _ts_param28(paramIndex, decorator) {
11266
11329
  return function(target, key) {
11267
11330
  decorator(target, key, paramIndex);
11268
11331
  };
11269
11332
  }
11270
- __name(_ts_param27, "_ts_param");
11333
+ __name(_ts_param28, "_ts_param");
11271
11334
  var SessionController = class {
11272
11335
  static {
11273
11336
  __name(this, "SessionController");
@@ -11343,77 +11406,77 @@ var SessionController = class {
11343
11406
  await this.sessionService.revokeOtherSession(user.sub, id);
11344
11407
  }
11345
11408
  };
11346
- _ts_decorate48([
11409
+ _ts_decorate49([
11347
11410
  Throttle(AUTH_THROTTLE_CONFIGS.listSessions),
11348
11411
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.listSessions),
11349
11412
  Get(),
11350
- _ts_param27(0, CurrentUser()),
11351
- _ts_param27(1, Req()),
11352
- _ts_metadata47("design:type", Function),
11353
- _ts_metadata47("design:paramtypes", [
11413
+ _ts_param28(0, CurrentUser()),
11414
+ _ts_param28(1, Req()),
11415
+ _ts_metadata48("design:type", Function),
11416
+ _ts_metadata48("design:paramtypes", [
11354
11417
  typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
11355
11418
  typeof Request === "undefined" ? Object : Request
11356
11419
  ]),
11357
- _ts_metadata47("design:returntype", Promise)
11420
+ _ts_metadata48("design:returntype", Promise)
11358
11421
  ], SessionController.prototype, "listSessions", null);
11359
- _ts_decorate48([
11422
+ _ts_decorate49([
11360
11423
  Throttle(AUTH_THROTTLE_CONFIGS.revokeAllSessions),
11361
11424
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.revokeAllSessions),
11362
11425
  HttpCode(HttpStatus.NO_CONTENT),
11363
11426
  Delete("all"),
11364
- _ts_param27(0, CurrentUser()),
11365
- _ts_param27(1, Req()),
11366
- _ts_metadata47("design:type", Function),
11367
- _ts_metadata47("design:paramtypes", [
11427
+ _ts_param28(0, CurrentUser()),
11428
+ _ts_param28(1, Req()),
11429
+ _ts_metadata48("design:type", Function),
11430
+ _ts_metadata48("design:paramtypes", [
11368
11431
  typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
11369
11432
  typeof Request === "undefined" ? Object : Request
11370
11433
  ]),
11371
- _ts_metadata47("design:returntype", Promise)
11434
+ _ts_metadata48("design:returntype", Promise)
11372
11435
  ], SessionController.prototype, "revokeAllSessions", null);
11373
- _ts_decorate48([
11436
+ _ts_decorate49([
11374
11437
  Throttle(AUTH_THROTTLE_CONFIGS.revokeSession),
11375
11438
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.revokeSession),
11376
11439
  HttpCode(HttpStatus.NO_CONTENT),
11377
11440
  Delete(":id"),
11378
- _ts_param27(0, CurrentUser()),
11379
- _ts_param27(1, Param("id")),
11380
- _ts_metadata47("design:type", Function),
11381
- _ts_metadata47("design:paramtypes", [
11441
+ _ts_param28(0, CurrentUser()),
11442
+ _ts_param28(1, Param("id")),
11443
+ _ts_metadata48("design:type", Function),
11444
+ _ts_metadata48("design:paramtypes", [
11382
11445
  typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
11383
11446
  String
11384
11447
  ]),
11385
- _ts_metadata47("design:returntype", Promise)
11448
+ _ts_metadata48("design:returntype", Promise)
11386
11449
  ], SessionController.prototype, "revokeSession", null);
11387
- SessionController = _ts_decorate48([
11450
+ SessionController = _ts_decorate49([
11388
11451
  UseInterceptors(NoStoreInterceptor),
11389
11452
  Controller("sessions"),
11390
11453
  UseGuards(TrustedOriginGuard, AuthRateLimitGuard, JwtAuthGuard, UserStatusGuard),
11391
11454
  UsePipes(createAuthValidationPipe()),
11392
- _ts_param27(0, Inject(SessionService)),
11393
- _ts_param27(1, Inject(TokenDeliveryService)),
11394
- _ts_metadata47("design:type", Function),
11395
- _ts_metadata47("design:paramtypes", [
11455
+ _ts_param28(0, Inject(SessionService)),
11456
+ _ts_param28(1, Inject(TokenDeliveryService)),
11457
+ _ts_metadata48("design:type", Function),
11458
+ _ts_metadata48("design:paramtypes", [
11396
11459
  typeof SessionService === "undefined" ? Object : SessionService,
11397
11460
  typeof TokenDeliveryService === "undefined" ? Object : TokenDeliveryService
11398
11461
  ])
11399
11462
  ], SessionController);
11400
- function _ts_decorate49(decorators, target, key, desc) {
11463
+ function _ts_decorate50(decorators, target, key, desc) {
11401
11464
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11402
11465
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11403
11466
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11404
11467
  return c > 3 && r && Object.defineProperty(target, key, r), r;
11405
11468
  }
11406
- __name(_ts_decorate49, "_ts_decorate");
11407
- function _ts_metadata48(k, v) {
11469
+ __name(_ts_decorate50, "_ts_decorate");
11470
+ function _ts_metadata49(k, v) {
11408
11471
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
11409
11472
  }
11410
- __name(_ts_metadata48, "_ts_metadata");
11411
- function _ts_param28(paramIndex, decorator) {
11473
+ __name(_ts_metadata49, "_ts_metadata");
11474
+ function _ts_param29(paramIndex, decorator) {
11412
11475
  return function(target, key) {
11413
11476
  decorator(target, key, paramIndex);
11414
11477
  };
11415
11478
  }
11416
- __name(_ts_param28, "_ts_param");
11479
+ __name(_ts_param29, "_ts_param");
11417
11480
  var MfaRequiredGuard = class {
11418
11481
  static {
11419
11482
  __name(this, "MfaRequiredGuard");
@@ -11440,11 +11503,11 @@ var MfaRequiredGuard = class {
11440
11503
  return true;
11441
11504
  }
11442
11505
  };
11443
- MfaRequiredGuard = _ts_decorate49([
11506
+ MfaRequiredGuard = _ts_decorate50([
11444
11507
  Injectable(),
11445
- _ts_param28(0, Inject(Reflector)),
11446
- _ts_metadata48("design:type", Function),
11447
- _ts_metadata48("design:paramtypes", [
11508
+ _ts_param29(0, Inject(Reflector)),
11509
+ _ts_metadata49("design:type", Function),
11510
+ _ts_metadata49("design:paramtypes", [
11448
11511
  typeof Reflector === "undefined" ? Object : Reflector
11449
11512
  ])
11450
11513
  ], MfaRequiredGuard);
@@ -11452,23 +11515,23 @@ var PLATFORM_ROLES_KEY = /* @__PURE__ */ Symbol("platformRoles");
11452
11515
  var PlatformRoles = /* @__PURE__ */ __name((...roles) => SetMetadata(PLATFORM_ROLES_KEY, roles), "PlatformRoles");
11453
11516
 
11454
11517
  // src/server/guards/platform-roles.guard.ts
11455
- function _ts_decorate50(decorators, target, key, desc) {
11518
+ function _ts_decorate51(decorators, target, key, desc) {
11456
11519
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11457
11520
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11458
11521
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11459
11522
  return c > 3 && r && Object.defineProperty(target, key, r), r;
11460
- }
11461
- __name(_ts_decorate50, "_ts_decorate");
11462
- function _ts_metadata49(k, v) {
11523
+ }
11524
+ __name(_ts_decorate51, "_ts_decorate");
11525
+ function _ts_metadata50(k, v) {
11463
11526
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
11464
11527
  }
11465
- __name(_ts_metadata49, "_ts_metadata");
11466
- function _ts_param29(paramIndex, decorator) {
11528
+ __name(_ts_metadata50, "_ts_metadata");
11529
+ function _ts_param30(paramIndex, decorator) {
11467
11530
  return function(target, key) {
11468
11531
  decorator(target, key, paramIndex);
11469
11532
  };
11470
11533
  }
11471
- __name(_ts_param29, "_ts_param");
11534
+ __name(_ts_param30, "_ts_param");
11472
11535
  var PlatformRolesGuard = class {
11473
11536
  static {
11474
11537
  __name(this, "PlatformRolesGuard");
@@ -11502,12 +11565,12 @@ var PlatformRolesGuard = class {
11502
11565
  return true;
11503
11566
  }
11504
11567
  };
11505
- PlatformRolesGuard = _ts_decorate50([
11568
+ PlatformRolesGuard = _ts_decorate51([
11506
11569
  Injectable(),
11507
- _ts_param29(0, Inject(Reflector)),
11508
- _ts_param29(1, Inject(BYMAX_AUTH_OPTIONS)),
11509
- _ts_metadata49("design:type", Function),
11510
- _ts_metadata49("design:paramtypes", [
11570
+ _ts_param30(0, Inject(Reflector)),
11571
+ _ts_param30(1, Inject(BYMAX_AUTH_OPTIONS)),
11572
+ _ts_metadata50("design:type", Function),
11573
+ _ts_metadata50("design:paramtypes", [
11511
11574
  typeof Reflector === "undefined" ? Object : Reflector,
11512
11575
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
11513
11576
  ])
@@ -11516,23 +11579,23 @@ var ROLES_KEY = "roles";
11516
11579
  var Roles = /* @__PURE__ */ __name((...roles) => SetMetadata(ROLES_KEY, roles), "Roles");
11517
11580
 
11518
11581
  // src/server/guards/roles.guard.ts
11519
- function _ts_decorate51(decorators, target, key, desc) {
11582
+ function _ts_decorate52(decorators, target, key, desc) {
11520
11583
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11521
11584
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11522
11585
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11523
11586
  return c > 3 && r && Object.defineProperty(target, key, r), r;
11524
11587
  }
11525
- __name(_ts_decorate51, "_ts_decorate");
11526
- function _ts_metadata50(k, v) {
11588
+ __name(_ts_decorate52, "_ts_decorate");
11589
+ function _ts_metadata51(k, v) {
11527
11590
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
11528
11591
  }
11529
- __name(_ts_metadata50, "_ts_metadata");
11530
- function _ts_param30(paramIndex, decorator) {
11592
+ __name(_ts_metadata51, "_ts_metadata");
11593
+ function _ts_param31(paramIndex, decorator) {
11531
11594
  return function(target, key) {
11532
11595
  decorator(target, key, paramIndex);
11533
11596
  };
11534
11597
  }
11535
- __name(_ts_param30, "_ts_param");
11598
+ __name(_ts_param31, "_ts_param");
11536
11599
  var RolesGuard = class {
11537
11600
  static {
11538
11601
  __name(this, "RolesGuard");
@@ -11562,23 +11625,23 @@ var RolesGuard = class {
11562
11625
  return true;
11563
11626
  }
11564
11627
  };
11565
- RolesGuard = _ts_decorate51([
11628
+ RolesGuard = _ts_decorate52([
11566
11629
  Injectable(),
11567
- _ts_param30(0, Inject(Reflector)),
11568
- _ts_param30(1, Inject(BYMAX_AUTH_OPTIONS)),
11569
- _ts_metadata50("design:type", Function),
11570
- _ts_metadata50("design:paramtypes", [
11630
+ _ts_param31(0, Inject(Reflector)),
11631
+ _ts_param31(1, Inject(BYMAX_AUTH_OPTIONS)),
11632
+ _ts_metadata51("design:type", Function),
11633
+ _ts_metadata51("design:paramtypes", [
11571
11634
  typeof Reflector === "undefined" ? Object : Reflector,
11572
11635
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
11573
11636
  ])
11574
11637
  ], RolesGuard);
11575
- function _ts_decorate52(decorators, target, key, desc) {
11638
+ function _ts_decorate53(decorators, target, key, desc) {
11576
11639
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11577
11640
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11578
11641
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11579
11642
  return c > 3 && r && Object.defineProperty(target, key, r), r;
11580
11643
  }
11581
- __name(_ts_decorate52, "_ts_decorate");
11644
+ __name(_ts_decorate53, "_ts_decorate");
11582
11645
  var NoOpAuthHooks = class {
11583
11646
  static {
11584
11647
  __name(this, "NoOpAuthHooks");
@@ -11621,7 +11684,7 @@ var NoOpAuthHooks = class {
11621
11684
  };
11622
11685
  }
11623
11686
  };
11624
- NoOpAuthHooks = _ts_decorate52([
11687
+ NoOpAuthHooks = _ts_decorate53([
11625
11688
  Injectable()
11626
11689
  ], NoOpAuthHooks);
11627
11690
 
@@ -11634,23 +11697,23 @@ var OAUTH_STATE_COOKIE_SAME_SITE = "lax";
11634
11697
  var OAUTH_STATE_COOKIE_MAX_AGE_SECONDS = 600;
11635
11698
 
11636
11699
  // src/server/oauth/oauth.service.ts
11637
- function _ts_decorate53(decorators, target, key, desc) {
11700
+ function _ts_decorate54(decorators, target, key, desc) {
11638
11701
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11639
11702
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11640
11703
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11641
11704
  return c > 3 && r && Object.defineProperty(target, key, r), r;
11642
11705
  }
11643
- __name(_ts_decorate53, "_ts_decorate");
11644
- function _ts_metadata51(k, v) {
11706
+ __name(_ts_decorate54, "_ts_decorate");
11707
+ function _ts_metadata52(k, v) {
11645
11708
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
11646
11709
  }
11647
- __name(_ts_metadata51, "_ts_metadata");
11648
- function _ts_param31(paramIndex, decorator) {
11710
+ __name(_ts_metadata52, "_ts_metadata");
11711
+ function _ts_param32(paramIndex, decorator) {
11649
11712
  return function(target, key) {
11650
11713
  decorator(target, key, paramIndex);
11651
11714
  };
11652
11715
  }
11653
- __name(_ts_param31, "_ts_param");
11716
+ __name(_ts_param32, "_ts_param");
11654
11717
  var OAUTH_STATE_TTL_SECONDS = 600;
11655
11718
  function isStoredOAuthState(value) {
11656
11719
  if (typeof value !== "object" || value === null) return false;
@@ -11910,18 +11973,18 @@ var OAuthService = class _OAuthService {
11910
11973
  return plugin;
11911
11974
  }
11912
11975
  };
11913
- OAuthService = _ts_decorate53([
11976
+ OAuthService = _ts_decorate54([
11914
11977
  Injectable(),
11915
- _ts_param31(0, Inject(OAUTH_PLUGINS)),
11916
- _ts_param31(1, Inject(BYMAX_AUTH_USER_REPOSITORY)),
11917
- _ts_param31(2, Inject(BYMAX_AUTH_HOOKS)),
11918
- _ts_param31(2, Optional()),
11919
- _ts_param31(3, Inject(AuthRedisService)),
11920
- _ts_param31(4, Inject(TokenManagerService)),
11921
- _ts_param31(5, Inject(SessionService)),
11922
- _ts_param31(6, Inject(BYMAX_AUTH_OPTIONS)),
11923
- _ts_metadata51("design:type", Function),
11924
- _ts_metadata51("design:paramtypes", [
11978
+ _ts_param32(0, Inject(OAUTH_PLUGINS)),
11979
+ _ts_param32(1, Inject(BYMAX_AUTH_USER_REPOSITORY)),
11980
+ _ts_param32(2, Inject(BYMAX_AUTH_HOOKS)),
11981
+ _ts_param32(2, Optional()),
11982
+ _ts_param32(3, Inject(AuthRedisService)),
11983
+ _ts_param32(4, Inject(TokenManagerService)),
11984
+ _ts_param32(5, Inject(SessionService)),
11985
+ _ts_param32(6, Inject(BYMAX_AUTH_OPTIONS)),
11986
+ _ts_metadata52("design:type", Function),
11987
+ _ts_metadata52("design:paramtypes", [
11925
11988
  Array,
11926
11989
  typeof IUserRepository === "undefined" ? Object : IUserRepository,
11927
11990
  Object,
@@ -11931,17 +11994,17 @@ OAuthService = _ts_decorate53([
11931
11994
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
11932
11995
  ])
11933
11996
  ], OAuthService);
11934
- function _ts_decorate54(decorators, target, key, desc) {
11997
+ function _ts_decorate55(decorators, target, key, desc) {
11935
11998
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11936
11999
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11937
12000
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11938
12001
  return c > 3 && r && Object.defineProperty(target, key, r), r;
11939
12002
  }
11940
- __name(_ts_decorate54, "_ts_decorate");
11941
- function _ts_metadata52(k, v) {
12003
+ __name(_ts_decorate55, "_ts_decorate");
12004
+ function _ts_metadata53(k, v) {
11942
12005
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
11943
12006
  }
11944
- __name(_ts_metadata52, "_ts_metadata");
12007
+ __name(_ts_metadata53, "_ts_metadata");
11945
12008
  var OAuthCallbackQueryDto = class {
11946
12009
  static {
11947
12010
  __name(this, "OAuthCallbackQueryDto");
@@ -12021,78 +12084,78 @@ var OAuthCallbackQueryDto = class {
12021
12084
  */
12022
12085
  hd;
12023
12086
  };
12024
- _ts_decorate54([
12087
+ _ts_decorate55([
12025
12088
  ValidateIf((query) => query.error === void 0),
12026
12089
  IsString(),
12027
12090
  IsNotEmpty(),
12028
12091
  MaxLength(2048),
12029
- _ts_metadata52("design:type", String)
12092
+ _ts_metadata53("design:type", String)
12030
12093
  ], OAuthCallbackQueryDto.prototype, "code", void 0);
12031
- _ts_decorate54([
12094
+ _ts_decorate55([
12032
12095
  IsOptional(),
12033
12096
  IsString(),
12034
12097
  MaxLength(128),
12035
- _ts_metadata52("design:type", String)
12098
+ _ts_metadata53("design:type", String)
12036
12099
  ], OAuthCallbackQueryDto.prototype, "error", void 0);
12037
- _ts_decorate54([
12100
+ _ts_decorate55([
12038
12101
  IsOptional(),
12039
12102
  IsString(),
12040
12103
  MaxLength(512),
12041
- _ts_metadata52("design:type", String)
12104
+ _ts_metadata53("design:type", String)
12042
12105
  ], OAuthCallbackQueryDto.prototype, "error_description", void 0);
12043
- _ts_decorate54([
12106
+ _ts_decorate55([
12044
12107
  IsOptional(),
12045
12108
  IsString(),
12046
12109
  MaxLength(512),
12047
- _ts_metadata52("design:type", String)
12110
+ _ts_metadata53("design:type", String)
12048
12111
  ], OAuthCallbackQueryDto.prototype, "error_uri", void 0);
12049
- _ts_decorate54([
12112
+ _ts_decorate55([
12050
12113
  IsString(),
12051
12114
  IsNotEmpty(),
12052
12115
  MaxLength(128),
12053
- _ts_metadata52("design:type", String)
12116
+ _ts_metadata53("design:type", String)
12054
12117
  ], OAuthCallbackQueryDto.prototype, "state", void 0);
12055
- _ts_decorate54([
12118
+ _ts_decorate55([
12056
12119
  IsOptional(),
12057
12120
  IsString(),
12058
12121
  MaxLength(512),
12059
- _ts_metadata52("design:type", String)
12122
+ _ts_metadata53("design:type", String)
12060
12123
  ], OAuthCallbackQueryDto.prototype, "iss", void 0);
12061
- _ts_decorate54([
12124
+ _ts_decorate55([
12062
12125
  IsOptional(),
12063
12126
  IsString(),
12064
12127
  MaxLength(2048),
12065
- _ts_metadata52("design:type", String)
12128
+ _ts_metadata53("design:type", String)
12066
12129
  ], OAuthCallbackQueryDto.prototype, "scope", void 0);
12067
- _ts_decorate54([
12130
+ _ts_decorate55([
12068
12131
  IsOptional(),
12069
12132
  IsString(),
12070
12133
  MaxLength(16),
12071
- _ts_metadata52("design:type", String)
12134
+ _ts_metadata53("design:type", String)
12072
12135
  ], OAuthCallbackQueryDto.prototype, "authuser", void 0);
12073
- _ts_decorate54([
12136
+ _ts_decorate55([
12074
12137
  IsOptional(),
12075
12138
  IsString(),
12076
12139
  MaxLength(64),
12077
- _ts_metadata52("design:type", String)
12140
+ _ts_metadata53("design:type", String)
12078
12141
  ], OAuthCallbackQueryDto.prototype, "prompt", void 0);
12079
- _ts_decorate54([
12142
+ _ts_decorate55([
12080
12143
  IsOptional(),
12081
12144
  IsString(),
12082
12145
  MaxLength(253),
12083
- _ts_metadata52("design:type", String)
12146
+ _ts_metadata53("design:type", String)
12084
12147
  ], OAuthCallbackQueryDto.prototype, "hd", void 0);
12085
- function _ts_decorate55(decorators, target, key, desc) {
12148
+ function _ts_decorate56(decorators, target, key, desc) {
12086
12149
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12087
12150
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
12088
12151
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
12089
12152
  return c > 3 && r && Object.defineProperty(target, key, r), r;
12090
12153
  }
12091
- __name(_ts_decorate55, "_ts_decorate");
12092
- function _ts_metadata53(k, v) {
12154
+ __name(_ts_decorate56, "_ts_decorate");
12155
+ function _ts_metadata54(k, v) {
12093
12156
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
12094
12157
  }
12095
- __name(_ts_metadata53, "_ts_metadata");
12158
+ __name(_ts_metadata54, "_ts_metadata");
12096
12159
  var OAuthInitiateQueryDto = class {
12097
12160
  static {
12098
12161
  __name(this, "OAuthInitiateQueryDto");
@@ -12109,34 +12172,35 @@ var OAuthInitiateQueryDto = class {
12109
12172
  */
12110
12173
  tenantId;
12111
12174
  };
12112
- _ts_decorate55([
12175
+ _ts_decorate56([
12176
+ IsOptional(),
12113
12177
  IsString(),
12114
12178
  IsNotEmpty(),
12115
12179
  MaxLength(128),
12116
12180
  Matches(NO_CONTROL_CHARACTERS, {
12117
12181
  message: "tenantId must not contain control characters"
12118
12182
  }),
12119
- _ts_metadata53("design:type", String)
12183
+ _ts_metadata54("design:type", String)
12120
12184
  ], OAuthInitiateQueryDto.prototype, "tenantId", void 0);
12121
12185
 
12122
12186
  // src/server/oauth/oauth.controller.ts
12123
- function _ts_decorate56(decorators, target, key, desc) {
12187
+ function _ts_decorate57(decorators, target, key, desc) {
12124
12188
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12125
12189
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
12126
12190
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
12127
12191
  return c > 3 && r && Object.defineProperty(target, key, r), r;
12128
12192
  }
12129
- __name(_ts_decorate56, "_ts_decorate");
12130
- function _ts_metadata54(k, v) {
12193
+ __name(_ts_decorate57, "_ts_decorate");
12194
+ function _ts_metadata55(k, v) {
12131
12195
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
12132
12196
  }
12133
- __name(_ts_metadata54, "_ts_metadata");
12134
- function _ts_param32(paramIndex, decorator) {
12197
+ __name(_ts_metadata55, "_ts_metadata");
12198
+ function _ts_param33(paramIndex, decorator) {
12135
12199
  return function(target, key) {
12136
12200
  decorator(target, key, paramIndex);
12137
12201
  };
12138
12202
  }
12139
- __name(_ts_param32, "_ts_param");
12203
+ __name(_ts_param33, "_ts_param");
12140
12204
  function isOAuthMfaChallenge(result) {
12141
12205
  return "mfaRequired" in result && result.mfaRequired === true;
12142
12206
  }
@@ -12354,46 +12418,46 @@ var OAuthController = class _OAuthController {
12354
12418
  });
12355
12419
  }
12356
12420
  };
12357
- _ts_decorate56([
12421
+ _ts_decorate57([
12358
12422
  Throttle(AUTH_THROTTLE_CONFIGS.oauthInitiate),
12359
12423
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.oauthInitiate),
12360
12424
  Get(":provider"),
12361
- _ts_param32(0, Param("provider")),
12362
- _ts_param32(1, Query()),
12363
- _ts_param32(2, Req()),
12364
- _ts_param32(3, Res({
12425
+ _ts_param33(0, Param("provider")),
12426
+ _ts_param33(1, Query()),
12427
+ _ts_param33(2, Req()),
12428
+ _ts_param33(3, Res({
12365
12429
  passthrough: true
12366
12430
  })),
12367
- _ts_metadata54("design:type", Function),
12368
- _ts_metadata54("design:paramtypes", [
12431
+ _ts_metadata55("design:type", Function),
12432
+ _ts_metadata55("design:paramtypes", [
12369
12433
  String,
12370
12434
  typeof OAuthInitiateQueryDto === "undefined" ? Object : OAuthInitiateQueryDto,
12371
12435
  typeof Request === "undefined" ? Object : Request,
12372
12436
  typeof Response === "undefined" ? Object : Response
12373
12437
  ]),
12374
- _ts_metadata54("design:returntype", Promise)
12438
+ _ts_metadata55("design:returntype", Promise)
12375
12439
  ], OAuthController.prototype, "initiate", null);
12376
- _ts_decorate56([
12440
+ _ts_decorate57([
12377
12441
  Throttle(AUTH_THROTTLE_CONFIGS.oauthCallback),
12378
12442
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.oauthCallback),
12379
12443
  HttpCode(HttpStatus.OK),
12380
12444
  Get(":provider/callback"),
12381
- _ts_param32(0, Param("provider")),
12382
- _ts_param32(1, Query()),
12383
- _ts_param32(2, Req()),
12384
- _ts_param32(3, Res({
12445
+ _ts_param33(0, Param("provider")),
12446
+ _ts_param33(1, Query()),
12447
+ _ts_param33(2, Req()),
12448
+ _ts_param33(3, Res({
12385
12449
  passthrough: true
12386
12450
  })),
12387
- _ts_metadata54("design:type", Function),
12388
- _ts_metadata54("design:paramtypes", [
12451
+ _ts_metadata55("design:type", Function),
12452
+ _ts_metadata55("design:paramtypes", [
12389
12453
  String,
12390
12454
  typeof OAuthCallbackQueryDto === "undefined" ? Object : OAuthCallbackQueryDto,
12391
12455
  typeof Request === "undefined" ? Object : Request,
12392
12456
  typeof Response === "undefined" ? Object : Response
12393
12457
  ]),
12394
- _ts_metadata54("design:returntype", Promise)
12458
+ _ts_metadata55("design:returntype", Promise)
12395
12459
  ], OAuthController.prototype, "callback", null);
12396
- OAuthController = _ts_decorate56([
12460
+ OAuthController = _ts_decorate57([
12397
12461
  Public(),
12398
12462
  SkipMfa(),
12399
12463
  UseInterceptors(NoStoreInterceptor),
@@ -12402,11 +12466,11 @@ OAuthController = _ts_decorate56([
12402
12466
  UsePipes(createAuthValidationPipe({
12403
12467
  forbidUnknownValues: true
12404
12468
  })),
12405
- _ts_param32(0, Inject(OAuthService)),
12406
- _ts_param32(1, Inject(TokenDeliveryService)),
12407
- _ts_param32(2, Inject(BYMAX_AUTH_OPTIONS)),
12408
- _ts_metadata54("design:type", Function),
12409
- _ts_metadata54("design:paramtypes", [
12469
+ _ts_param33(0, Inject(OAuthService)),
12470
+ _ts_param33(1, Inject(TokenDeliveryService)),
12471
+ _ts_param33(2, Inject(BYMAX_AUTH_OPTIONS)),
12472
+ _ts_metadata55("design:type", Function),
12473
+ _ts_metadata55("design:paramtypes", [
12410
12474
  typeof OAuthService === "undefined" ? Object : OAuthService,
12411
12475
  typeof TokenDeliveryService === "undefined" ? Object : TokenDeliveryService,
12412
12476
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
@@ -12545,13 +12609,13 @@ var GoogleOAuthPlugin = class {
12545
12609
  };
12546
12610
 
12547
12611
  // src/server/oauth/oauth.module.ts
12548
- function _ts_decorate57(decorators, target, key, desc) {
12612
+ function _ts_decorate58(decorators, target, key, desc) {
12549
12613
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12550
12614
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
12551
12615
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
12552
12616
  return c > 3 && r && Object.defineProperty(target, key, r), r;
12553
12617
  }
12554
- __name(_ts_decorate57, "_ts_decorate");
12618
+ __name(_ts_decorate58, "_ts_decorate");
12555
12619
  function buildOAuthPlugins(options) {
12556
12620
  const plugins = [];
12557
12621
  if (options.oauth?.google) {
@@ -12621,26 +12685,26 @@ var OAuthModule = class _OAuthModule {
12621
12685
  };
12622
12686
  }
12623
12687
  };
12624
- OAuthModule = _ts_decorate57([
12688
+ OAuthModule = _ts_decorate58([
12625
12689
  Module({})
12626
12690
  ], OAuthModule);
12627
- function _ts_decorate58(decorators, target, key, desc) {
12691
+ function _ts_decorate59(decorators, target, key, desc) {
12628
12692
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12629
12693
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
12630
12694
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
12631
12695
  return c > 3 && r && Object.defineProperty(target, key, r), r;
12632
12696
  }
12633
- __name(_ts_decorate58, "_ts_decorate");
12634
- function _ts_metadata55(k, v) {
12697
+ __name(_ts_decorate59, "_ts_decorate");
12698
+ function _ts_metadata56(k, v) {
12635
12699
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
12636
12700
  }
12637
- __name(_ts_metadata55, "_ts_metadata");
12638
- function _ts_param33(paramIndex, decorator) {
12701
+ __name(_ts_metadata56, "_ts_metadata");
12702
+ function _ts_param34(paramIndex, decorator) {
12639
12703
  return function(target, key) {
12640
12704
  decorator(target, key, paramIndex);
12641
12705
  };
12642
12706
  }
12643
- __name(_ts_param33, "_ts_param");
12707
+ __name(_ts_param34, "_ts_param");
12644
12708
  var COMMON_BASE_WORDS = [
12645
12709
  // The perennial top of every published list.
12646
12710
  "password",
@@ -12946,68 +13010,68 @@ var CommonPasswordChecker = class {
12946
13010
  return false;
12947
13011
  }
12948
13012
  };
12949
- CommonPasswordChecker = _ts_decorate58([
13013
+ CommonPasswordChecker = _ts_decorate59([
12950
13014
  Injectable(),
12951
- _ts_param33(0, Inject(BYMAX_AUTH_OPTIONS)),
12952
- _ts_param33(0, Optional()),
12953
- _ts_metadata55("design:type", Function),
12954
- _ts_metadata55("design:paramtypes", [
13015
+ _ts_param34(0, Inject(BYMAX_AUTH_OPTIONS)),
13016
+ _ts_param34(0, Optional()),
13017
+ _ts_metadata56("design:type", Function),
13018
+ _ts_metadata56("design:paramtypes", [
12955
13019
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
12956
13020
  ])
12957
13021
  ], CommonPasswordChecker);
12958
- function _ts_decorate59(decorators, target, key, desc) {
13022
+ function _ts_decorate60(decorators, target, key, desc) {
12959
13023
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12960
13024
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
12961
13025
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
12962
13026
  return c > 3 && r && Object.defineProperty(target, key, r), r;
12963
13027
  }
12964
- __name(_ts_decorate59, "_ts_decorate");
13028
+ __name(_ts_decorate60, "_ts_decorate");
12965
13029
  var NoOpEmailProvider = class _NoOpEmailProvider {
12966
13030
  static {
12967
13031
  __name(this, "NoOpEmailProvider");
12968
13032
  }
12969
13033
  logger = new Logger(_NoOpEmailProvider.name);
12970
13034
  /** @inheritdoc */
12971
- async sendPasswordResetToken(email, _token, _locale) {
13035
+ async sendPasswordResetToken(_tenantId, email, _token, _locale) {
12972
13036
  this.logger.log(`sendPasswordResetToken \u2192 ${maskEmail(email)} (no-op)`);
12973
13037
  }
12974
13038
  /** @inheritdoc */
12975
- async sendPasswordResetOtp(email, _otp, _locale) {
13039
+ async sendPasswordResetOtp(_tenantId, email, _otp, _locale) {
12976
13040
  this.logger.log(`sendPasswordResetOtp \u2192 ${maskEmail(email)} (no-op)`);
12977
13041
  }
12978
13042
  /** @inheritdoc */
12979
- async sendEmailVerificationOtp(email, _otp, _locale) {
13043
+ async sendEmailVerificationOtp(_tenantId, email, _otp, _locale) {
12980
13044
  this.logger.log(`sendEmailVerificationOtp \u2192 ${maskEmail(email)} (no-op)`);
12981
13045
  }
12982
13046
  /** @inheritdoc */
12983
- async sendMfaEnabledNotification(email, _locale) {
13047
+ async sendMfaEnabledNotification(_tenantId, email, _locale) {
12984
13048
  this.logger.log(`sendMfaEnabledNotification \u2192 ${maskEmail(email)} (no-op)`);
12985
13049
  }
12986
13050
  /** @inheritdoc */
12987
- async sendMfaDisabledNotification(email, _locale) {
13051
+ async sendMfaDisabledNotification(_tenantId, email, _locale) {
12988
13052
  this.logger.log(`sendMfaDisabledNotification \u2192 ${maskEmail(email)} (no-op)`);
12989
13053
  }
12990
13054
  /** @inheritdoc */
12991
- async sendNewSessionAlert(email, _sessionInfo, _locale) {
13055
+ async sendNewSessionAlert(_tenantId, email, _sessionInfo, _locale) {
12992
13056
  this.logger.log(`sendNewSessionAlert \u2192 ${maskEmail(email)} (no-op)`);
12993
13057
  }
12994
13058
  /** @inheritdoc */
12995
- async sendInvitation(email, _inviteData, _locale) {
13059
+ async sendInvitation(_tenantId, email, _inviteData, _locale) {
12996
13060
  this.logger.log(`sendInvitation \u2192 ${maskEmail(email)} (no-op)`);
12997
13061
  }
12998
13062
  };
12999
- NoOpEmailProvider = _ts_decorate59([
13063
+ NoOpEmailProvider = _ts_decorate60([
13000
13064
  Injectable()
13001
13065
  ], NoOpEmailProvider);
13002
13066
 
13003
13067
  // src/server/bymax-auth.module.ts
13004
- function _ts_decorate60(decorators, target, key, desc) {
13068
+ function _ts_decorate61(decorators, target, key, desc) {
13005
13069
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
13006
13070
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
13007
13071
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
13008
13072
  return c > 3 && r && Object.defineProperty(target, key, r), r;
13009
13073
  }
13010
- __name(_ts_decorate60, "_ts_decorate");
13074
+ __name(_ts_decorate61, "_ts_decorate");
13011
13075
  function hasProviderToken(providers, token) {
13012
13076
  return providers.some((p) => {
13013
13077
  if (typeof p === "function") return false;
@@ -13191,6 +13255,7 @@ var BymaxAuthModule = class _BymaxAuthModule {
13191
13255
  // BYMAX_AUTH_REDIS_CLIENT and BYMAX_AUTH_OPTIONS provided via extraProviders
13192
13256
  // are visible in the same module scope.
13193
13257
  AuthRedisService,
13258
+ AuthRevocationService,
13194
13259
  PasswordService,
13195
13260
  TokenManagerService,
13196
13261
  TokenDeliveryService,
@@ -13278,6 +13343,10 @@ var BymaxAuthModule = class _BymaxAuthModule {
13278
13343
  // NestJS auto-registers @UseGuards() guards as local providers in the controller's
13279
13344
  // module; all constructor deps must be resolvable from that module's context.
13280
13345
  AuthRedisService,
13346
+ // Export AuthRevocationService for the same @UseGuards() reason — the exported guards now
13347
+ // depend on it — and so a host bridging a realtime transport can inject it and consult
13348
+ // both revocation channels rather than granting a stream that outlives a logout.
13349
+ AuthRevocationService,
13281
13350
  // Same reason, for the two exported guards whose remaining constructor deps are not
13282
13351
  // covered by the entries above. Exporting the guard class is necessary but not
13283
13352
  // sufficient: because @UseGuards() re-instantiates the guard in the *consumer's*
@@ -13302,20 +13371,229 @@ var BymaxAuthModule = class _BymaxAuthModule {
13302
13371
  };
13303
13372
  }
13304
13373
  };
13305
- BymaxAuthModule = _ts_decorate60([
13374
+ BymaxAuthModule = _ts_decorate61([
13306
13375
  Module({})
13307
13376
  ], BymaxAuthModule);
13308
- function _ts_decorate61(decorators, target, key, desc) {
13377
+ var CODE_VALIDITY_TEXT = "It expires shortly, so use it soon.";
13378
+ var UNEXPECTED_CHANGE_TEXT = "If this was not you, secure your account immediately: change your password and sign out of every session.";
13379
+ var DEFAULT_MESSAGES = {
13380
+ passwordResetToken: /* @__PURE__ */ __name(({ token }) => ({
13381
+ subject: "Reset your password",
13382
+ text: `Use this token to reset your password: ${token}
13383
+
13384
+ ${CODE_VALIDITY_TEXT}
13385
+
13386
+ If you did not ask to reset your password, ignore this message and nothing will change.`
13387
+ }), "passwordResetToken"),
13388
+ passwordResetOtp: /* @__PURE__ */ __name(({ otp }) => ({
13389
+ subject: "Your password reset code",
13390
+ text: `Your password reset code is ${otp}.
13391
+
13392
+ ${CODE_VALIDITY_TEXT}
13393
+
13394
+ If you did not ask to reset your password, ignore this message and nothing will change.`
13395
+ }), "passwordResetOtp"),
13396
+ emailVerificationOtp: /* @__PURE__ */ __name(({ otp }) => ({
13397
+ subject: "Verify your email address",
13398
+ text: `Your verification code is ${otp}.
13399
+
13400
+ ${CODE_VALIDITY_TEXT}
13401
+
13402
+ If you did not create an account, ignore this message.`
13403
+ }), "emailVerificationOtp"),
13404
+ passwordChanged: /* @__PURE__ */ __name(() => ({
13405
+ subject: "Your password was changed",
13406
+ text: `The password on your account was changed.
13407
+
13408
+ ${UNEXPECTED_CHANGE_TEXT}`
13409
+ }), "passwordChanged"),
13410
+ emailChangeVerification: /* @__PURE__ */ __name(({ token }) => ({
13411
+ subject: "Confirm your new email address",
13412
+ text: `Your confirmation code is ${token}.
13413
+
13414
+ ${CODE_VALIDITY_TEXT}
13415
+
13416
+ If you did not ask to change your email address, ignore this message.`
13417
+ }), "emailChangeVerification"),
13418
+ emailChanged: /* @__PURE__ */ __name(({ newEmail }) => ({
13419
+ subject: "Your email address was changed",
13420
+ text: `The email address on your account was changed to ${newEmail}, and this address no longer signs in to it.
13421
+
13422
+ ${UNEXPECTED_CHANGE_TEXT}`
13423
+ }), "emailChanged"),
13424
+ mfaEnabled: /* @__PURE__ */ __name(() => ({
13425
+ subject: "Two-factor authentication is on",
13426
+ text: `Two-factor authentication was enabled on your account.
13427
+
13428
+ ${UNEXPECTED_CHANGE_TEXT}`
13429
+ }), "mfaEnabled"),
13430
+ mfaDisabled: /* @__PURE__ */ __name(() => ({
13431
+ subject: "Two-factor authentication is off",
13432
+ text: `Two-factor authentication was disabled on your account.
13433
+
13434
+ ${UNEXPECTED_CHANGE_TEXT}`
13435
+ }), "mfaDisabled"),
13436
+ newSessionAlert: /* @__PURE__ */ __name(({ sessionInfo }) => ({
13437
+ subject: "New sign-in to your account",
13438
+ text: `A new session was started on your account.
13439
+
13440
+ Device: ${sessionInfo.device}
13441
+ IP: ${sessionInfo.ip}
13442
+ Session: ${sessionInfo.sessionHash}
13443
+
13444
+ ${UNEXPECTED_CHANGE_TEXT}`
13445
+ }), "newSessionAlert"),
13446
+ invitation: /* @__PURE__ */ __name(({ invite }) => ({
13447
+ subject: `${invite.inviterName} invited you to ${invite.tenantName}`,
13448
+ text: `${invite.inviterName} invited you to join ${invite.tenantName}.
13449
+
13450
+ Use this token to accept: ${invite.inviteToken}
13451
+
13452
+ It expires on ${invite.expiresAt.toISOString()}.
13453
+
13454
+ If you were not expecting this invitation, ignore this message.`
13455
+ }), "invitation")
13456
+ };
13457
+ function escapeHtml(value) {
13458
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
13459
+ }
13460
+ __name(escapeHtml, "escapeHtml");
13461
+ function toHtml(text) {
13462
+ return text.split("\n\n").map((paragraph) => `<p>${escapeHtml(paragraph).replace(/\n/g, "<br>")}</p>`).join("\n");
13463
+ }
13464
+ __name(toHtml, "toHtml");
13465
+ function sanitizeSubject(subject) {
13466
+ return subject.replace(/[\r\n]+/g, " ");
13467
+ }
13468
+ __name(sanitizeSubject, "sanitizeSubject");
13469
+ var DefaultAuthEmailProvider = class _DefaultAuthEmailProvider {
13470
+ static {
13471
+ __name(this, "DefaultAuthEmailProvider");
13472
+ }
13473
+ sink;
13474
+ /** Records a delivery this provider swallowed, so a silent channel is still visible somewhere. */
13475
+ logger = new Logger(_DefaultAuthEmailProvider.name);
13476
+ /** The copy in effect: the defaults, with any provided overrides layered on top. */
13477
+ messages;
13478
+ /** Whether a rejected send is re-thrown after logging; `false` (swallow) unless asked otherwise. */
13479
+ rethrowOnError;
13480
+ /**
13481
+ * @param sink - The delivery channel to send through.
13482
+ * @param options - Optional copy overrides and delivery-error policy.
13483
+ */
13484
+ constructor(sink, options) {
13485
+ this.sink = sink;
13486
+ this.messages = {
13487
+ ...DEFAULT_MESSAGES,
13488
+ ...options?.messages
13489
+ };
13490
+ this.rethrowOnError = options?.onDeliveryError === "rethrow";
13491
+ }
13492
+ /** @inheritdoc */
13493
+ async sendPasswordResetToken(tenantId, email, token, locale) {
13494
+ await this.deliver(tenantId, email, this.messages.passwordResetToken({
13495
+ token,
13496
+ locale
13497
+ }));
13498
+ }
13499
+ /** @inheritdoc */
13500
+ async sendPasswordResetOtp(tenantId, email, otp, locale) {
13501
+ await this.deliver(tenantId, email, this.messages.passwordResetOtp({
13502
+ otp,
13503
+ locale
13504
+ }));
13505
+ }
13506
+ /** @inheritdoc */
13507
+ async sendEmailVerificationOtp(tenantId, email, otp, locale) {
13508
+ await this.deliver(tenantId, email, this.messages.emailVerificationOtp({
13509
+ otp,
13510
+ locale
13511
+ }));
13512
+ }
13513
+ /** @inheritdoc */
13514
+ async sendPasswordChangedNotification(tenantId, email, locale) {
13515
+ await this.deliver(tenantId, email, this.messages.passwordChanged({
13516
+ locale
13517
+ }));
13518
+ }
13519
+ /** @inheritdoc */
13520
+ async sendEmailChangeVerification(tenantId, newEmail, token, locale) {
13521
+ await this.deliver(tenantId, newEmail, this.messages.emailChangeVerification({
13522
+ token,
13523
+ locale
13524
+ }));
13525
+ }
13526
+ /** @inheritdoc */
13527
+ async sendEmailChangedNotification(tenantId, oldEmail, newEmail, locale) {
13528
+ await this.deliver(tenantId, oldEmail, this.messages.emailChanged({
13529
+ oldEmail,
13530
+ newEmail,
13531
+ locale
13532
+ }));
13533
+ }
13534
+ /** @inheritdoc */
13535
+ async sendMfaEnabledNotification(tenantId, email, locale) {
13536
+ await this.deliver(tenantId, email, this.messages.mfaEnabled({
13537
+ locale
13538
+ }));
13539
+ }
13540
+ /** @inheritdoc */
13541
+ async sendMfaDisabledNotification(tenantId, email, locale) {
13542
+ await this.deliver(tenantId, email, this.messages.mfaDisabled({
13543
+ locale
13544
+ }));
13545
+ }
13546
+ /** @inheritdoc */
13547
+ async sendNewSessionAlert(tenantId, email, sessionInfo, locale) {
13548
+ await this.deliver(tenantId, email, this.messages.newSessionAlert({
13549
+ sessionInfo,
13550
+ locale
13551
+ }));
13552
+ }
13553
+ /** @inheritdoc */
13554
+ async sendInvitation(tenantId, email, inviteData, locale) {
13555
+ await this.deliver(tenantId, email, this.messages.invitation({
13556
+ invite: inviteData,
13557
+ locale
13558
+ }));
13559
+ }
13560
+ /**
13561
+ * Renders the body to HTML (unless the message already carries its own), hands the message to the
13562
+ * channel, and swallows any delivery error.
13563
+ *
13564
+ * @param tenantId - Tenant the message is attributed to.
13565
+ * @param to - Recipient address.
13566
+ * @param message - The rendered subject and body, and optionally its own HTML.
13567
+ */
13568
+ async deliver(tenantId, to, message) {
13569
+ const subject = sanitizeSubject(message.subject);
13570
+ try {
13571
+ await this.sink.send({
13572
+ tenantId,
13573
+ to,
13574
+ subject,
13575
+ html: message.html ?? toHtml(message.text),
13576
+ text: message.text
13577
+ });
13578
+ } catch (error) {
13579
+ this.logger.error(`delivery failed for "${subject}"`, error);
13580
+ if (this.rethrowOnError) {
13581
+ throw error;
13582
+ }
13583
+ }
13584
+ }
13585
+ };
13586
+ function _ts_decorate62(decorators, target, key, desc) {
13309
13587
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
13310
13588
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
13311
13589
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
13312
13590
  return c > 3 && r && Object.defineProperty(target, key, r), r;
13313
13591
  }
13314
- __name(_ts_decorate61, "_ts_decorate");
13315
- function _ts_metadata56(k, v) {
13592
+ __name(_ts_decorate62, "_ts_decorate");
13593
+ function _ts_metadata57(k, v) {
13316
13594
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
13317
13595
  }
13318
- __name(_ts_metadata56, "_ts_metadata");
13596
+ __name(_ts_metadata57, "_ts_metadata");
13319
13597
  var HIBP_RANGE_URL = "https://api.pwnedpasswords.com/range/";
13320
13598
  var PREFIX_LENGTH = 5;
13321
13599
  var DEFAULT_TIMEOUT_MS = 1500;
@@ -13372,10 +13650,10 @@ var HibpBreachChecker = class _HibpBreachChecker {
13372
13650
  }
13373
13651
  }
13374
13652
  };
13375
- HibpBreachChecker = _ts_decorate61([
13653
+ HibpBreachChecker = _ts_decorate62([
13376
13654
  Injectable(),
13377
- _ts_metadata56("design:type", Function),
13378
- _ts_metadata56("design:paramtypes", [
13655
+ _ts_metadata57("design:type", Function),
13656
+ _ts_metadata57("design:paramtypes", [
13379
13657
  Number
13380
13658
  ])
13381
13659
  ], HibpBreachChecker);
@@ -13388,16 +13666,16 @@ var AllowAllBreachChecker = class {
13388
13666
  return false;
13389
13667
  }
13390
13668
  };
13391
- AllowAllBreachChecker = _ts_decorate61([
13669
+ AllowAllBreachChecker = _ts_decorate62([
13392
13670
  Injectable()
13393
13671
  ], AllowAllBreachChecker);
13394
- function _ts_decorate62(decorators, target, key, desc) {
13672
+ function _ts_decorate63(decorators, target, key, desc) {
13395
13673
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
13396
13674
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
13397
13675
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
13398
13676
  return c > 3 && r && Object.defineProperty(target, key, r), r;
13399
13677
  }
13400
- __name(_ts_decorate62, "_ts_decorate");
13678
+ __name(_ts_decorate63, "_ts_decorate");
13401
13679
  var OptionalAuthGuard = class extends JwtAuthGuard {
13402
13680
  static {
13403
13681
  __name(this, "OptionalAuthGuard");
@@ -13412,26 +13690,26 @@ var OptionalAuthGuard = class extends JwtAuthGuard {
13412
13690
  return super.canActivate(context);
13413
13691
  }
13414
13692
  };
13415
- OptionalAuthGuard = _ts_decorate62([
13693
+ OptionalAuthGuard = _ts_decorate63([
13416
13694
  Injectable()
13417
13695
  ], OptionalAuthGuard);
13418
- function _ts_decorate63(decorators, target, key, desc) {
13696
+ function _ts_decorate64(decorators, target, key, desc) {
13419
13697
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
13420
13698
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
13421
13699
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
13422
13700
  return c > 3 && r && Object.defineProperty(target, key, r), r;
13423
13701
  }
13424
- __name(_ts_decorate63, "_ts_decorate");
13425
- function _ts_metadata57(k, v) {
13702
+ __name(_ts_decorate64, "_ts_decorate");
13703
+ function _ts_metadata58(k, v) {
13426
13704
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
13427
13705
  }
13428
- __name(_ts_metadata57, "_ts_metadata");
13429
- function _ts_param34(paramIndex, decorator) {
13706
+ __name(_ts_metadata58, "_ts_metadata");
13707
+ function _ts_param35(paramIndex, decorator) {
13430
13708
  return function(target, key) {
13431
13709
  decorator(target, key, paramIndex);
13432
13710
  };
13433
13711
  }
13434
- __name(_ts_param34, "_ts_param");
13712
+ __name(_ts_param35, "_ts_param");
13435
13713
  var SelfOrAdminGuard = class {
13436
13714
  static {
13437
13715
  __name(this, "SelfOrAdminGuard");
@@ -13461,11 +13739,11 @@ var SelfOrAdminGuard = class {
13461
13739
  throw new AuthException(AUTH_ERROR_CODES.INSUFFICIENT_ROLE, HttpStatus.FORBIDDEN);
13462
13740
  }
13463
13741
  };
13464
- SelfOrAdminGuard = _ts_decorate63([
13742
+ SelfOrAdminGuard = _ts_decorate64([
13465
13743
  Injectable(),
13466
- _ts_param34(0, Inject(BYMAX_AUTH_OPTIONS)),
13467
- _ts_metadata57("design:type", Function),
13468
- _ts_metadata57("design:paramtypes", [
13744
+ _ts_param35(0, Inject(BYMAX_AUTH_OPTIONS)),
13745
+ _ts_metadata58("design:type", Function),
13746
+ _ts_metadata58("design:paramtypes", [
13469
13747
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
13470
13748
  ])
13471
13749
  ], SelfOrAdminGuard);
@@ -13478,34 +13756,34 @@ function isHexLooking(value) {
13478
13756
  return value.length === 64 && /^[a-fA-F0-9]{64}$/.test(value);
13479
13757
  }
13480
13758
  __name(isHexLooking, "isHexLooking");
13481
- function _ts_decorate64(decorators, target, key, desc) {
13759
+ function _ts_decorate65(decorators, target, key, desc) {
13482
13760
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
13483
13761
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
13484
13762
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
13485
13763
  return c > 3 && r && Object.defineProperty(target, key, r), r;
13486
13764
  }
13487
- __name(_ts_decorate64, "_ts_decorate");
13488
- function _ts_metadata58(k, v) {
13765
+ __name(_ts_decorate65, "_ts_decorate");
13766
+ function _ts_metadata59(k, v) {
13489
13767
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
13490
13768
  }
13491
- __name(_ts_metadata58, "_ts_metadata");
13492
- function _ts_param35(paramIndex, decorator) {
13769
+ __name(_ts_metadata59, "_ts_metadata");
13770
+ function _ts_param36(paramIndex, decorator) {
13493
13771
  return function(target, key) {
13494
13772
  decorator(target, key, paramIndex);
13495
13773
  };
13496
13774
  }
13497
- __name(_ts_param35, "_ts_param");
13775
+ __name(_ts_param36, "_ts_param");
13498
13776
  var WsJwtGuard = class {
13499
13777
  static {
13500
13778
  __name(this, "WsJwtGuard");
13501
13779
  }
13502
13780
  jwtService;
13503
- redis;
13781
+ revocation;
13504
13782
  wsTickets;
13505
13783
  options;
13506
- constructor(jwtService, redis, wsTickets, options) {
13784
+ constructor(jwtService, revocation, wsTickets, options) {
13507
13785
  this.jwtService = jwtService;
13508
- this.redis = redis;
13786
+ this.revocation = revocation;
13509
13787
  this.wsTickets = wsTickets;
13510
13788
  this.options = options;
13511
13789
  }
@@ -13544,29 +13822,24 @@ var WsJwtGuard = class {
13544
13822
  throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
13545
13823
  }
13546
13824
  assertTokenType(payload, "dashboard");
13547
- const revoked = await this.redis.get(`rv:${payload.jti}`);
13548
- if (revoked !== null) {
13549
- throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
13550
- }
13551
13825
  assertValidSub(payload.sub);
13552
- const epoch = await this.redis.getUserTokenEpoch(payload.sub);
13553
- if (readStampedEpoch(payload) < epoch) {
13826
+ if (await this.revocation.isAccessTokenRevoked(payload)) {
13554
13827
  throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
13555
13828
  }
13556
13829
  client.data.user = payload;
13557
13830
  return true;
13558
13831
  }
13559
13832
  };
13560
- WsJwtGuard = _ts_decorate64([
13833
+ WsJwtGuard = _ts_decorate65([
13561
13834
  Injectable(),
13562
- _ts_param35(0, Inject(JwtService)),
13563
- _ts_param35(1, Inject(AuthRedisService)),
13564
- _ts_param35(2, Inject(WsTicketService)),
13565
- _ts_param35(3, Inject(BYMAX_AUTH_OPTIONS)),
13566
- _ts_metadata58("design:type", Function),
13567
- _ts_metadata58("design:paramtypes", [
13835
+ _ts_param36(0, Inject(JwtService)),
13836
+ _ts_param36(1, Inject(AuthRevocationService)),
13837
+ _ts_param36(2, Inject(WsTicketService)),
13838
+ _ts_param36(3, Inject(BYMAX_AUTH_OPTIONS)),
13839
+ _ts_metadata59("design:type", Function),
13840
+ _ts_metadata59("design:paramtypes", [
13568
13841
  typeof JwtService === "undefined" ? Object : JwtService,
13569
- typeof AuthRedisService === "undefined" ? Object : AuthRedisService,
13842
+ typeof AuthRevocationService === "undefined" ? Object : AuthRevocationService,
13570
13843
  typeof WsTicketService === "undefined" ? Object : WsTicketService,
13571
13844
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
13572
13845
  ])
@@ -13597,13 +13870,13 @@ function readUpgradeTicket(client) {
13597
13870
  return all.length === 1 && all[0] !== "" ? all[0] : void 0;
13598
13871
  }
13599
13872
  __name(readUpgradeTicket, "readUpgradeTicket");
13600
- function _ts_decorate65(decorators, target, key, desc) {
13873
+ function _ts_decorate66(decorators, target, key, desc) {
13601
13874
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
13602
13875
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
13603
13876
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
13604
13877
  return c > 3 && r && Object.defineProperty(target, key, r), r;
13605
13878
  }
13606
- __name(_ts_decorate65, "_ts_decorate");
13879
+ __name(_ts_decorate66, "_ts_decorate");
13607
13880
  function isAuthEnvelope(body) {
13608
13881
  if (typeof body !== "object" || body === null) return false;
13609
13882
  const error = body.error;
@@ -13655,8 +13928,8 @@ var AuthExceptionFilter = class _AuthExceptionFilter {
13655
13928
  });
13656
13929
  }
13657
13930
  };
13658
- AuthExceptionFilter = _ts_decorate65([
13931
+ AuthExceptionFilter = _ts_decorate66([
13659
13932
  Catch()
13660
13933
  ], AuthExceptionFilter);
13661
13934
 
13662
- export { AUTH_ERROR_CODES, AUTH_ERROR_MESSAGES, AUTH_THROTTLE_CONFIGS, AcceptInvitationDto, AllowAllBreachChecker, AuthException, AuthExceptionFilter, AuthRateLimit, AuthRateLimitGuard, AuthService, Authenticated, 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, CurrentUser, 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, SessionService, SkipMfa, TokenDeliveryService, TrustedOriginGuard, UserStatusGuard, VerifyEmailDto, VerifyOtpDto, WS_TICKET_TTL_SECONDS, WsJwtGuard, WsTicketService, createAuthValidationPipe, decrypt, encrypt, generateSecureToken, hasRole, hmacSha256, reduceToBaseWord, sanitizeHeaders, sha256, sleep, timingSafeCompare };
13935
+ export { AUTH_ERROR_CODES, AUTH_ERROR_MESSAGES, AUTH_THROTTLE_CONFIGS, AcceptInvitationDto, AllowAllBreachChecker, AuthException, AuthExceptionFilter, AuthRateLimit, AuthRateLimitGuard, AuthRevocationService, AuthService, Authenticated, 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, 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, SessionService, SkipMfa, TokenDeliveryService, TrustedOriginGuard, UserStatusGuard, VerifyEmailDto, VerifyOtpDto, WS_TICKET_TTL_SECONDS, WsJwtGuard, WsTicketService, createAuthValidationPipe, decrypt, encrypt, generateSecureToken, hasRole, hmacSha256, reduceToBaseWord, sanitizeHeaders, sha256, sleep, timingSafeCompare };