@bymax-one/nest-auth 1.4.19 → 1.4.21

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.
@@ -1969,7 +1969,6 @@ var REFRESH_PREFIXES = {
1969
1969
  grace: "rp",
1970
1970
  consumed: "cf",
1971
1971
  family: "fam",
1972
- index: "sess",
1973
1972
  detail: "sd"
1974
1973
  },
1975
1974
  platform: {
@@ -1977,7 +1976,6 @@ var REFRESH_PREFIXES = {
1977
1976
  grace: "prp",
1978
1977
  consumed: "pcf",
1979
1978
  family: "pfam",
1980
- index: "psess",
1981
1979
  detail: "psd"
1982
1980
  }
1983
1981
  };
@@ -4657,7 +4655,7 @@ var MAX_SCRYPT_PARAMETER = 255;
4657
4655
  var MIN_KEY_LEN = 10;
4658
4656
  var MAX_KEY_LEN = 64;
4659
4657
  function toPhcB64(value) {
4660
- return value.toString("base64").replace(/=+$/, "");
4658
+ return value.toString("base64").replaceAll("=", "");
4661
4659
  }
4662
4660
  __name(toPhcB64, "toPhcB64");
4663
4661
  function fromPhcB64(value) {
@@ -9972,6 +9970,130 @@ _ts_decorate36([
9972
9970
  classValidator.IsNotEmpty(),
9973
9971
  _ts_metadata35("design:type", String)
9974
9972
  ], MfaVerifyDto.prototype, "code", void 0);
9973
+ function _ts_decorate37(decorators, target, key, desc) {
9974
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9975
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
9976
+ r = Reflect.decorate(decorators, target, key, desc);
9977
+ } else {
9978
+ for (var i = decorators.length - 1; i >= 0; i--) {
9979
+ if (d = decorators[i]) {
9980
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9981
+ }
9982
+ }
9983
+ }
9984
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
9985
+ }
9986
+ __name(_ts_decorate37, "_ts_decorate");
9987
+ function _ts_metadata36(metadataKey, metadataValue) {
9988
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
9989
+ return Reflect.metadata(metadataKey, metadataValue);
9990
+ }
9991
+ }
9992
+ __name(_ts_metadata36, "_ts_metadata");
9993
+ function _ts_param21(paramIndex, decorator) {
9994
+ return function(target, key) {
9995
+ decorator(target, key, paramIndex);
9996
+ };
9997
+ }
9998
+ __name(_ts_param21, "_ts_param");
9999
+ var MfaFlowLockoutService = class {
10000
+ static {
10001
+ __name(this, "MfaFlowLockoutService");
10002
+ }
10003
+ options;
10004
+ bruteForce;
10005
+ constructor(options, bruteForce) {
10006
+ this.options = options;
10007
+ this.bruteForce = bruteForce;
10008
+ }
10009
+ /**
10010
+ * The tenant-scoped brute-force identifier for one MFA flow, and the plane-only one that pods on
10011
+ * an older version count under. The two are equal on the platform plane, where the subject
10012
+ * carries no tenant, and distinct on the dashboard plane, where it does.
10013
+ *
10014
+ * A rolling upgrade runs old and new code against one Redis at once: on the dashboard plane an
10015
+ * old pod counts a failure under `{flow}:{plane}:{userId}` while a new pod counts it under
10016
+ * `{flow}:{userSubject}`, and either alone leaves a hole: a lockout an old pod filled would not
10017
+ * stop a new pod, and a success on one would not clear the other. So every read consults both
10018
+ * and every write touches both, and the two move as one; the plane-only arm can be dropped once
10019
+ * no pod writes it. On the platform plane the two ids are identical, so the plane-only arm is
10020
+ * skipped: operating it would be the same key a second time, double-counting a failure and
10021
+ * locking a platform admin out at half the threshold. `{flow}` (`challenge` / `disable` /
10022
+ * `reauth`) keeps the three counters isolated from each other.
10023
+ */
10024
+ counterIds(flow, context, userId, tenantId) {
10025
+ return {
10026
+ legacy: hmacSha256(`${flow}:${context}:${userId}`, this.options.hmacKey),
10027
+ scoped: hmacSha256(`${flow}:${userSubject(context, userId, tenantId)}`, this.options.hmacKey)
10028
+ };
10029
+ }
10030
+ /**
10031
+ * Locked out when EITHER the legacy or the tenant-scoped counter has reached the threshold, so
10032
+ * neither a lockout an old pod recorded nor one a new pod recorded can be bypassed mid-migration.
10033
+ */
10034
+ async isLockedOut(flow, context, userId, tenantId) {
10035
+ const { legacy, scoped } = this.counterIds(flow, context, userId, tenantId);
10036
+ if (await this.bruteForce.isLockedOut(scoped)) return true;
10037
+ return legacy !== scoped ? this.bruteForce.isLockedOut(legacy) : false;
10038
+ }
10039
+ /**
10040
+ * Records the failure under both counters so the budget an attacker spends is seen by old and
10041
+ * new code alike — but under the scoped id ONCE when the two coincide (platform plane).
10042
+ */
10043
+ async recordFailure(flow, context, userId, tenantId) {
10044
+ const { legacy, scoped } = this.counterIds(flow, context, userId, tenantId);
10045
+ await this.bruteForce.recordFailure(scoped);
10046
+ if (legacy !== scoped) await this.bruteForce.recordFailure(legacy);
10047
+ }
10048
+ /**
10049
+ * Clears both counters on success — resetting only one would leave the other to lock a
10050
+ * legitimately authenticated user out on the next attempt — collapsing to one when they coincide.
10051
+ */
10052
+ async reset(flow, context, userId, tenantId) {
10053
+ const { legacy, scoped } = this.counterIds(flow, context, userId, tenantId);
10054
+ await this.bruteForce.resetFailures(scoped);
10055
+ if (legacy !== scoped) await this.bruteForce.resetFailures(legacy);
10056
+ }
10057
+ };
10058
+ MfaFlowLockoutService = _ts_decorate37([
10059
+ common.Injectable(),
10060
+ _ts_param21(0, common.Inject(BYMAX_AUTH_OPTIONS)),
10061
+ _ts_param21(1, common.Inject(exports.BruteForceService)),
10062
+ _ts_metadata36("design:type", Function),
10063
+ _ts_metadata36("design:paramtypes", [
10064
+ typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
10065
+ typeof exports.BruteForceService === "undefined" ? Object : exports.BruteForceService
10066
+ ])
10067
+ ], MfaFlowLockoutService);
10068
+
10069
+ // src/server/utils/mfa-plane-tenant.ts
10070
+ var PLANE_TENANT_MESSAGE = "tenantId must be a non-empty value on the dashboard plane and absent on the platform plane";
10071
+ function assertDashboardTenant(tenantId) {
10072
+ if (tenantId === void 0 || tenantId === "") {
10073
+ throw new AuthException(AUTH_ERROR_CODES.VALIDATION, [
10074
+ {
10075
+ field: "tenantId",
10076
+ message: PLANE_TENANT_MESSAGE
10077
+ }
10078
+ ]);
10079
+ }
10080
+ }
10081
+ __name(assertDashboardTenant, "assertDashboardTenant");
10082
+ function assertPlaneTenant(context, tenantId) {
10083
+ if (context === "dashboard") {
10084
+ assertDashboardTenant(tenantId);
10085
+ return;
10086
+ }
10087
+ if (tenantId !== void 0) {
10088
+ throw new AuthException(AUTH_ERROR_CODES.VALIDATION, [
10089
+ {
10090
+ field: "tenantId",
10091
+ message: PLANE_TENANT_MESSAGE
10092
+ }
10093
+ ]);
10094
+ }
10095
+ }
10096
+ __name(assertPlaneTenant, "assertPlaneTenant");
9975
10097
  var IV_LENGTH = 12;
9976
10098
  var AUTH_TAG_BYTE_LENGTH = 16;
9977
10099
  function encrypt(plaintext, keyBase64) {
@@ -10021,20 +10143,47 @@ function decrypt(ciphertext, keyBase64) {
10021
10143
  }
10022
10144
  __name(decrypt, "decrypt");
10023
10145
 
10024
- // src/server/utils/run-detached.ts
10025
- function runDetached(logger, run, failure) {
10146
+ // src/server/utils/mfa-secret-cipher.ts
10147
+ function holdsSecret(stored, secretBase32, keys) {
10148
+ if (!stored) return false;
10026
10149
  try {
10027
- void Promise.resolve(run()).catch((err) => {
10028
- logger.error(`${failure}: ${describeChannelStatus(err)}`);
10029
- });
10030
- } catch (err) {
10031
- logger.error(`${failure}: ${describeChannelStatus(err)}`);
10150
+ return timingSafeCompare(decryptWithRotation(stored, keys).secret, secretBase32);
10151
+ } catch {
10152
+ return false;
10032
10153
  }
10033
10154
  }
10034
- __name(runDetached, "runDetached");
10155
+ __name(holdsSecret, "holdsSecret");
10156
+ function encryptMfaSecret(secret, keys) {
10157
+ return encrypt(secret, keys.encryptionKey);
10158
+ }
10159
+ __name(encryptMfaSecret, "encryptMfaSecret");
10160
+ function decryptMfaSecret(encrypted, keys) {
10161
+ return decryptWithRotation(encrypted, keys).secret;
10162
+ }
10163
+ __name(decryptMfaSecret, "decryptMfaSecret");
10164
+ function decryptWithRotation(encrypted, keys) {
10165
+ try {
10166
+ return {
10167
+ secret: decrypt(encrypted, keys.encryptionKey),
10168
+ stale: false
10169
+ };
10170
+ } catch {
10171
+ for (const key of keys.previousEncryptionKeys ?? []) {
10172
+ try {
10173
+ return {
10174
+ secret: decrypt(encrypted, key),
10175
+ stale: true
10176
+ };
10177
+ } catch {
10178
+ }
10179
+ }
10180
+ throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
10181
+ }
10182
+ }
10183
+ __name(decryptWithRotation, "decryptWithRotation");
10035
10184
 
10036
- // src/server/services/mfa.service.ts
10037
- function _ts_decorate37(decorators, target, key, desc) {
10185
+ // src/server/services/mfa-record.service.ts
10186
+ function _ts_decorate38(decorators, target, key, desc) {
10038
10187
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10039
10188
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
10040
10189
  r = Reflect.decorate(decorators, target, key, desc);
@@ -10047,25 +10196,19 @@ function _ts_decorate37(decorators, target, key, desc) {
10047
10196
  }
10048
10197
  return c > 3 && r && Object.defineProperty(target, key, r), r;
10049
10198
  }
10050
- __name(_ts_decorate37, "_ts_decorate");
10051
- function _ts_metadata36(metadataKey, metadataValue) {
10199
+ __name(_ts_decorate38, "_ts_decorate");
10200
+ function _ts_metadata37(metadataKey, metadataValue) {
10052
10201
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
10053
10202
  return Reflect.metadata(metadataKey, metadataValue);
10054
10203
  }
10055
10204
  }
10056
- __name(_ts_metadata36, "_ts_metadata");
10057
- function _ts_param21(paramIndex, decorator) {
10205
+ __name(_ts_metadata37, "_ts_metadata");
10206
+ function _ts_param22(paramIndex, decorator) {
10058
10207
  return function(target, key) {
10059
10208
  decorator(target, key, paramIndex);
10060
10209
  };
10061
10210
  }
10062
- __name(_ts_param21, "_ts_param");
10063
- var PLATFORM_EMAIL_TENANT = "platform";
10064
- function emailTenantOf(user) {
10065
- return "tenantId" in user ? user.tenantId : PLATFORM_EMAIL_TENANT;
10066
- }
10067
- __name(emailTenantOf, "emailTenantOf");
10068
- var MFA_SETUP_TTL_SECONDS = 600;
10211
+ __name(_ts_param22, "_ts_param");
10069
10212
  var RECOVERY_CODE_CLAIM_TTL_SECONDS = 300;
10070
10213
  function totpAntiReplayTtlSeconds(window) {
10071
10214
  const effective = Math.min(Math.max(window, 0), MAX_VERIFY_WINDOW);
@@ -10077,58 +10220,21 @@ var RELEASE_LOCK_LUA = `if redis.call('GET', KEYS[1]) == ARGV[1] then
10077
10220
  return redis.call('DEL', KEYS[1])
10078
10221
  end
10079
10222
  return 0`;
10080
- var DEFAULT_RECOVERY_CODE_COUNT = 8;
10081
- function isMfaSetupData(value) {
10082
- if (value === null) return false;
10083
- if (typeof value !== "object") return false;
10084
- const v = value;
10085
- return typeof v["encryptedSecret"] === "string" && typeof v["encryptedPlainCodes"] === "string" && Array.isArray(v["hashedCodes"]) && v["hashedCodes"].every((code) => typeof code === "string");
10086
- }
10087
- __name(isMfaSetupData, "isMfaSetupData");
10088
- var PLANE_TENANT_MESSAGE = "tenantId must be a non-empty value on the dashboard plane and absent on the platform plane";
10089
- exports.MfaService = class _MfaService {
10223
+ var MfaRecordService = class _MfaRecordService {
10090
10224
  static {
10091
- __name(this, "MfaService");
10225
+ __name(this, "MfaRecordService");
10092
10226
  }
10093
10227
  options;
10094
10228
  userRepo;
10095
10229
  platformUserRepo;
10096
10230
  redis;
10097
- tokenManager;
10098
- bruteForce;
10099
- passwordService;
10100
- sessionService;
10101
- emailProvider;
10102
- hooks;
10103
- logger = new common.Logger(_MfaService.name);
10104
- constructor(options, userRepo, platformUserRepo, redis, tokenManager, bruteForce, passwordService, sessionService, emailProvider, hooks) {
10231
+ logger = new common.Logger(_MfaRecordService.name);
10232
+ constructor(options, userRepo, platformUserRepo, redis) {
10105
10233
  this.options = options;
10106
10234
  this.userRepo = userRepo;
10107
10235
  this.platformUserRepo = platformUserRepo;
10108
10236
  this.redis = redis;
10109
- this.tokenManager = tokenManager;
10110
- this.bruteForce = bruteForce;
10111
- this.passwordService = passwordService;
10112
- this.sessionService = sessionService;
10113
- this.emailProvider = emailProvider;
10114
- this.hooks = hooks;
10115
10237
  }
10116
- // ---------------------------------------------------------------------------
10117
- // Private accessor — options.mfa is guaranteed non-null when service is active
10118
- // ---------------------------------------------------------------------------
10119
- /**
10120
- * Returns the resolved MFA configuration. `options.mfa` is always present when `MfaService` is registered.
10121
- *
10122
- * `options.mfa` is always present when `MfaService` is registered — the module
10123
- * only registers the service when `mfa` is configured. The single suppression
10124
- * here eliminates repetitive `!` assertions throughout the class.
10125
- */
10126
- get mfaOptions() {
10127
- return this.options.mfa;
10128
- }
10129
- // ---------------------------------------------------------------------------
10130
- // Private crypto helpers
10131
- // ---------------------------------------------------------------------------
10132
10238
  /**
10133
10239
  * Store the TOTP secret re-encrypted under the current key.
10134
10240
  *
@@ -10146,14 +10252,15 @@ exports.MfaService = class _MfaService {
10146
10252
  * @param context - Which identity plane the account belongs to.
10147
10253
  * @param secretBase32 - The decrypted secret.
10148
10254
  * @param tenantId - The tenant the account belongs to, so the write is scoped like the read.
10255
+ * @param keys - The secret-cipher keys; the secret is written under the current one.
10149
10256
  */
10150
- async reencryptSecret(userId, context, secretBase32, tenantId) {
10257
+ async reencryptSecret(userId, context, secretBase32, tenantId, keys) {
10151
10258
  try {
10152
- await this.transitionMfaRecord(context, userId, tenantId, (current) => {
10153
- if (!current.mfaEnabled || !this.holdsSecret(current.mfaSecret, secretBase32)) return null;
10259
+ await this.transition(context, userId, tenantId, (current) => {
10260
+ if (!current.mfaEnabled || !holdsSecret(current.mfaSecret, secretBase32, keys)) return null;
10154
10261
  return {
10155
10262
  mfaEnabled: true,
10156
- mfaSecret: this.encryptSecret(secretBase32),
10263
+ mfaSecret: encryptMfaSecret(secretBase32, keys),
10157
10264
  mfaRecoveryCodes: current.mfaRecoveryCodes ?? []
10158
10265
  };
10159
10266
  });
@@ -10198,7 +10305,7 @@ exports.MfaService = class _MfaService {
10198
10305
  * @returns `true` when a write happened, `false` when `mutate` abandoned the transition.
10199
10306
  * @throws {@link AuthException} `MFA_STATE_CONFLICT` when another transition holds the lock.
10200
10307
  */
10201
- async transitionMfaRecord(context, userId, tenantId, mutate) {
10308
+ async transition(context, userId, tenantId, mutate) {
10202
10309
  const scopedLockKey = `mfalock:${hmacSha256(userSubject(context, userId, tenantId), this.options.hmacKey)}`;
10203
10310
  const legacyLockKey = `mfalock:${hmacSha256(`${context}:${userId}`, this.options.hmacKey)}`;
10204
10311
  const acquireLegacy = legacyLockKey !== scopedLockKey;
@@ -10215,7 +10322,7 @@ exports.MfaService = class _MfaService {
10215
10322
  throw new AuthException(AUTH_ERROR_CODES.MFA_STATE_CONFLICT);
10216
10323
  }
10217
10324
  try {
10218
- const current = await this.fetchUserForContext(context, userId, tenantId);
10325
+ const current = await this.loadAccount(context, userId, tenantId);
10219
10326
  const update = mutate(current);
10220
10327
  if (update === null) return false;
10221
10328
  const write = {
@@ -10226,7 +10333,7 @@ exports.MfaService = class _MfaService {
10226
10333
  if (context === "platform" && this.platformUserRepo) {
10227
10334
  await this.platformUserRepo.updateMfa(userId, write);
10228
10335
  } else {
10229
- this.assertDashboardTenant(tenantId);
10336
+ assertDashboardTenant(tenantId);
10230
10337
  await this.userRepo.updateMfa({
10231
10338
  id: userId,
10232
10339
  tenantId,
@@ -10250,180 +10357,6 @@ exports.MfaService = class _MfaService {
10250
10357
  }
10251
10358
  }
10252
10359
  /**
10253
- * Whether `stored` decrypts, under the current or a retired key, to `secretBase32`.
10254
- *
10255
- * Compares plaintext, so a record that was only re-encrypted still matches and one holding a
10256
- * different secret does not. A ciphertext no key opens does not match either.
10257
- */
10258
- holdsSecret(stored, secretBase32) {
10259
- if (!stored) return false;
10260
- try {
10261
- return timingSafeCompare(this.decryptWithRotation(stored).secret, secretBase32);
10262
- } catch {
10263
- return false;
10264
- }
10265
- }
10266
- /**
10267
- * Encrypts a TOTP secret for storage in the database using AES-256-GCM.
10268
- */
10269
- encryptSecret(secret) {
10270
- return encrypt(secret, this.mfaOptions.encryptionKey);
10271
- }
10272
- /**
10273
- * Decrypts a stored TOTP secret, falling back to keys retired by a rotation.
10274
- *
10275
- * The ciphertext records no key identifier, so without the retired keys, changing
10276
- * `mfa.encryptionKey` makes every stored secret undecryptable — every enrolled user's
10277
- * authenticator stops matching at once, with no way back. AES-GCM authenticates, so a wrong
10278
- * key fails unambiguously rather than returning garbage; trying them in order is safe.
10279
- *
10280
- * Re-throws any decryption failure as an opaque `TOKEN_INVALID` to prevent
10281
- * error-type oracle attacks (callers cannot distinguish format vs. tamper errors).
10282
- */
10283
- decryptSecret(encrypted) {
10284
- return this.decryptWithRotation(encrypted).secret;
10285
- }
10286
- /**
10287
- * Decrypt under the current key, then under each retired one.
10288
- *
10289
- * @param encrypted - The stored ciphertext.
10290
- * @returns The plaintext and whether a retired key produced it — the signal that the record
10291
- * should be re-encrypted under the current key.
10292
- * @throws {@link AuthException} `TOKEN_INVALID` when no key decrypts it.
10293
- */
10294
- decryptWithRotation(encrypted) {
10295
- try {
10296
- return {
10297
- secret: decrypt(encrypted, this.mfaOptions.encryptionKey),
10298
- stale: false
10299
- };
10300
- } catch {
10301
- for (const key of this.mfaOptions.previousEncryptionKeys ?? []) {
10302
- try {
10303
- return {
10304
- secret: decrypt(encrypted, key),
10305
- stale: true
10306
- };
10307
- } catch {
10308
- }
10309
- }
10310
- throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
10311
- }
10312
- }
10313
- /**
10314
- * Safely parses a Redis-stored {@link MfaSetupData} JSON payload.
10315
- *
10316
- * A corrupted or tampered Redis value would otherwise raise an unhandled
10317
- * `SyntaxError` from the service boundary (uncaught 500). We translate the
10318
- * failure into an opaque `MFA_SETUP_REQUIRED`, which mirrors the response
10319
- * the caller would receive if the key were absent — preventing an attacker
10320
- * with Redis write access from distinguishing "no setup pending" from
10321
- * "setup payload corrupted".
10322
- */
10323
- parseSetupData(raw, userId) {
10324
- let parsed;
10325
- try {
10326
- parsed = JSON.parse(raw);
10327
- } catch {
10328
- this.logger.warn(`parseSetupData: pending-setup payload is not valid JSON userId=${logSafe(userId)}`);
10329
- throw new AuthException(AUTH_ERROR_CODES.MFA_SETUP_REQUIRED);
10330
- }
10331
- if (!isMfaSetupData(parsed)) {
10332
- throw new AuthException(AUTH_ERROR_CODES.MFA_SETUP_REQUIRED);
10333
- }
10334
- return parsed;
10335
- }
10336
- /**
10337
- * Safely parses the AES-decrypted JSON array of plain-text recovery codes.
10338
- *
10339
- * A decrypted value that fails JSON parsing indicates either a downgrade of
10340
- * the stored payload (highly unlikely, since AES-GCM authenticates the
10341
- * ciphertext) or an internal bug. Both cases are surfaced opaquely as
10342
- * `MFA_SETUP_REQUIRED` so callers do not learn structural details of the
10343
- * encrypted payload.
10344
- */
10345
- parsePlainRecoveryCodes(raw, userId) {
10346
- let parsed;
10347
- try {
10348
- parsed = JSON.parse(raw);
10349
- } catch {
10350
- this.logger.warn(`parsePlainRecoveryCodes: decrypted payload is not valid JSON userId=${logSafe(userId)}`);
10351
- throw new AuthException(AUTH_ERROR_CODES.MFA_SETUP_REQUIRED);
10352
- }
10353
- if (!Array.isArray(parsed) || parsed.some((code) => typeof code !== "string")) {
10354
- throw new AuthException(AUTH_ERROR_CODES.MFA_SETUP_REQUIRED);
10355
- }
10356
- return parsed;
10357
- }
10358
- /**
10359
- * Generates `count` recovery codes in `XXXX-XXXX-XXXX-XXXX-XXXX-XXXX` format
10360
- * (96 bits of entropy per code, hex-encoded).
10361
- *
10362
- * Returns both the plain-text (shown once to the user) and scrypt-hashed
10363
- * versions (stored in the database).
10364
- *
10365
- * @remarks
10366
- * Each code carries 96 bits of entropy (12 random bytes → 24 hex chars grouped
10367
- * as 6 × 4). This is well above the NIST SP 800-63B recommendation for
10368
- * offline-resistant credentials. The previous 12-digit decimal format offered
10369
- * ~40 bits, which relied entirely on the scrypt hash for offline resistance —
10370
- * any database leak would have put the raw codes within offline reach.
10371
- */
10372
- hashRecoveryCodes(count) {
10373
- const plainCodes = [];
10374
- const hashedCodes = [];
10375
- for (let i = 0; i < count; i++) {
10376
- const hex = crypto.randomBytes(12).toString("hex");
10377
- const groups = [];
10378
- for (let offset = 0; offset < hex.length; offset += 4) {
10379
- groups.push(hex.slice(offset, offset + 4));
10380
- }
10381
- const code = groups.join("-").toUpperCase();
10382
- plainCodes.push(code);
10383
- hashedCodes.push(this.digestRecoveryCode(code));
10384
- }
10385
- return {
10386
- plainCodes,
10387
- hashedCodes
10388
- };
10389
- }
10390
- /**
10391
- * Derives the stored digest for a recovery code: a keyed HMAC-SHA-256, hex encoded.
10392
- *
10393
- * A recovery code is 96 bits of CSPRNG output, not a human-chosen password, so a
10394
- * memory-hard KDF buys nothing against it — there is no dictionary to walk and brute
10395
- * forcing 2^96 is out of reach whatever the hash costs. What the KDF did buy was an
10396
- * attacker-reachable CPU amplifier: a challenge submitting a wrong recovery code scanned
10397
- * every stored digest, so one request cost as many scrypt derivations as the user had
10398
- * codes. The keyed MAC is the right primitive here — the secret key is what stops an
10399
- * offline attacker precomputing digests from a leaked table, and it costs microseconds.
10400
- */
10401
- digestRecoveryCode(code) {
10402
- return hmacSha256(code, this.options.hmacKey);
10403
- }
10404
- /**
10405
- * Compares a submitted recovery code against every stored digest.
10406
- *
10407
- * One storage format only: a keyed MAC over the code. Every digest is compared in constant
10408
- * time and the scan always runs to completion — including the step that picks the winner out
10409
- * of the recorded results — so neither the position of a match nor the number of codes still
10410
- * unused is observable in the response time.
10411
- *
10412
- * @returns Index of the first matching digest, or `-1` if none match.
10413
- */
10414
- async verifyRecoveryCode(code, hashedCodes) {
10415
- const candidates = [
10416
- this.digestRecoveryCode(code),
10417
- ...this.options.previousHmacKeys.map((key) => hmacSha256(code, key))
10418
- ];
10419
- const macMatches = [];
10420
- for (const hashedCode of hashedCodes) {
10421
- const hit = candidates.reduce((found, candidate) => timingSafeCompare(candidate, hashedCode) || found, false);
10422
- macMatches.push(hit);
10423
- }
10424
- return macMatches.reduce((found, hit, index) => found === -1 && hit ? index : found, -1);
10425
- }
10426
- /**
10427
10360
  * Claims a matched recovery code for exactly one challenge.
10428
10361
  *
10429
10362
  * Consuming a code is a read-modify-write against the consumer's repository: the challenge
@@ -10454,60 +10387,388 @@ exports.MfaService = class _MfaService {
10454
10387
  return await this.redis.setnx(claimKey, RECOVERY_CODE_CLAIM_TTL_SECONDS);
10455
10388
  }
10456
10389
  /**
10457
- * Returns a `SafeAuthUser` projection of a dashboard user, stripping credentials
10458
- * and MFA secret fields before passing to hooks or email providers.
10390
+ * Verifies a TOTP code and enforces anti-replay within the validation window.
10391
+ *
10392
+ * Stores a Redis key `tu:{hmac}` where `hmac = hmacSha256("{userSubject}:{code}", hmacKey)` —
10393
+ * so the marker is scoped to the plane and, on the dashboard plane, to the tenant. A second
10394
+ * submission of the same code within the TTL is rejected as a replay. Binding the marker to
10395
+ * both the subject and the code value prevents code disclosure in Redis and cross-user,
10396
+ * cross-tenant and cross-plane replay alike.
10397
+ *
10398
+ * A second marker under the plane-only preimage `{context}:{userId}:{code}` is written and
10399
+ * required alongside it; see the call site for why both must be fresh while pods of two
10400
+ * versions are live.
10401
+ *
10402
+ * @returns `true` if the code is valid and has not been replayed, `false` otherwise.
10459
10403
  */
10460
- toSafeUser(user) {
10461
- const { passwordHash: _ph, mfaSecret: _ms, mfaRecoveryCodes: _mrc, ...safe } = user;
10462
- return safe;
10404
+ async verifyTotpWithAntiReplay(context, userId, secretBase32, code, window, tenantId) {
10405
+ if (!verifyTotp(secretBase32, code, window)) return false;
10406
+ const ttl = totpAntiReplayTtlSeconds(window);
10407
+ const scopedReplayKey = `tu:${hmacSha256(`${userSubject(context, userId, tenantId)}:${code}`, this.options.hmacKey)}`;
10408
+ const legacyReplayKey = `tu:${hmacSha256(`${context}:${userId}:${code}`, this.options.hmacKey)}`;
10409
+ const scopedIsNew = await this.redis.setnx(scopedReplayKey, ttl);
10410
+ if (scopedReplayKey === legacyReplayKey) return scopedIsNew;
10411
+ const legacyIsNew = await this.redis.setnx(legacyReplayKey, ttl);
10412
+ return scopedIsNew && legacyIsNew;
10463
10413
  }
10464
10414
  /**
10465
- * Returns a `SafeAuthPlatformUser` projection of a platform admin, stripping
10466
- * credentials and MFA secret fields.
10415
+ * Fetches a user from the correct repository based on the MFA context, and refuses one whose
10416
+ * account is blocked.
10417
+ *
10418
+ * The status gate lives here rather than in each caller because every entry point that
10419
+ * reaches this method changes or spends an authentication factor, and every one of them
10420
+ * must refuse a suspended or banned account. A gate in `challenge` alone would leave `setup`,
10421
+ * `verifyAndEnable`, `disable` and `regenerateRecoveryCodes` open: an operator who suspended a
10422
+ * compromised account would buy nothing against an attacker still holding an unexpired access
10423
+ * token, who could turn the second factor off — or enrol their own authenticator over it — for
10424
+ * the token's remaining lifetime. Nothing else covers that window: no status change bumps the
10425
+ * token epoch, so the per-request check is the only defence, and neither MFA controller
10426
+ * composes `UserStatusGuard` (the platform plane has no status guard at all). Every other
10427
+ * authority-bearing route in the library does gate on status; changing an authentication
10428
+ * factor is at least as privileged as minting an invitation.
10429
+ *
10430
+ * Gating the fetch rather than the callers is deliberate: a method added later inherits the
10431
+ * check instead of having to remember it.
10432
+ *
10433
+ * @param context - Which identity plane the caller is acting on.
10434
+ * @param userId - The subject taken from the verified token.
10435
+ * @param tenantId - The tenant the caller was authenticated in, on the dashboard plane;
10436
+ * absent on the platform plane, whose admins belong to none.
10437
+ * @returns The account record, guaranteed to be in good standing.
10438
+ * @throws `TOKEN_INVALID` if the user is not found.
10439
+ * @throws {@link AuthException} the status error when the account is blocked.
10467
10440
  */
10468
- toSafePlatformUser(admin) {
10469
- const { passwordHash: _ph, mfaSecret: _ms, mfaRecoveryCodes: _mrc, ...safe } = admin;
10470
- return safe;
10441
+ async loadAccount(context, userId, tenantId) {
10442
+ if (context === "dashboard") {
10443
+ assertDashboardTenant(tenantId);
10444
+ const user = await this.userRepo.findById({
10445
+ id: userId,
10446
+ tenantId
10447
+ });
10448
+ if (!user) throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
10449
+ assertNotBlocked(user.status, this.options.blockedStatuses);
10450
+ return user;
10451
+ }
10452
+ if (!this.platformUserRepo) {
10453
+ throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
10454
+ }
10455
+ const admin = await this.platformUserRepo.findById(userId);
10456
+ if (!admin) throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
10457
+ assertNotBlocked(admin.status, this.options.blockedStatuses);
10458
+ return admin;
10459
+ }
10460
+ };
10461
+ MfaRecordService = _ts_decorate38([
10462
+ common.Injectable(),
10463
+ _ts_param22(0, common.Inject(BYMAX_AUTH_OPTIONS)),
10464
+ _ts_param22(1, common.Inject(BYMAX_AUTH_USER_REPOSITORY)),
10465
+ _ts_param22(2, common.Optional()),
10466
+ _ts_param22(2, common.Inject(BYMAX_AUTH_PLATFORM_USER_REPOSITORY)),
10467
+ _ts_param22(3, common.Inject(AuthRedisService)),
10468
+ _ts_metadata37("design:type", Function),
10469
+ _ts_metadata37("design:paramtypes", [
10470
+ typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
10471
+ typeof IUserRepository === "undefined" ? Object : IUserRepository,
10472
+ Object,
10473
+ typeof AuthRedisService === "undefined" ? Object : AuthRedisService
10474
+ ])
10475
+ ], MfaRecordService);
10476
+ function _ts_decorate39(decorators, target, key, desc) {
10477
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10478
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
10479
+ r = Reflect.decorate(decorators, target, key, desc);
10480
+ } else {
10481
+ for (var i = decorators.length - 1; i >= 0; i--) {
10482
+ if (d = decorators[i]) {
10483
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10484
+ }
10485
+ }
10486
+ }
10487
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10488
+ }
10489
+ __name(_ts_decorate39, "_ts_decorate");
10490
+ function _ts_metadata38(metadataKey, metadataValue) {
10491
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
10492
+ return Reflect.metadata(metadataKey, metadataValue);
10493
+ }
10494
+ }
10495
+ __name(_ts_metadata38, "_ts_metadata");
10496
+ function _ts_param23(paramIndex, decorator) {
10497
+ return function(target, key) {
10498
+ decorator(target, key, paramIndex);
10499
+ };
10500
+ }
10501
+ __name(_ts_param23, "_ts_param");
10502
+ exports.ReauthenticationService = class _ReauthenticationService {
10503
+ static {
10504
+ __name(this, "ReauthenticationService");
10505
+ }
10506
+ options;
10507
+ redis;
10508
+ passwordService;
10509
+ lockout;
10510
+ logger = new common.Logger(_ReauthenticationService.name);
10511
+ constructor(options, redis, passwordService, lockout) {
10512
+ this.options = options;
10513
+ this.redis = redis;
10514
+ this.passwordService = passwordService;
10515
+ this.lockout = lockout;
10471
10516
  }
10472
10517
  /**
10473
- * Constructs a `SafeAuthUser`-compatible object from a `SafeAuthPlatformUser` so
10474
- * that it can be passed to hooks typed for `SafeAuthUser`.
10518
+ * Requires the caller to re-prove the account password before a factor is changed.
10475
10519
  *
10476
- * Platform admins have no `tenantId` or `emailVerified` fields. These are filled
10477
- * with sentinel values (`''` and `true` respectively) since platform admins are
10478
- * provisioned directly and do not participate in the tenant/email-verification flow.
10520
+ * Counted like a login, and for the same reason. `login` refuses an account after N wrong
10521
+ * passwords, and this door asks for the same secret, so it carries the same lockout: without
10522
+ * one, a caller holding a stolen access token but not the password could guess it here
10523
+ * indefinitely, bounded only by the per-route IP limit, which a distributed caller sidesteps.
10524
+ * Winning the guess buys the whole account: enrol a factor, change the password, move the
10525
+ * address.
10526
+ *
10527
+ * The identifier is namespaced by flow and by plane. Sharing one counter with `login` would
10528
+ * let an authenticated caller lock the owner out of their own sign-in, and sharing it across
10529
+ * planes would let a dashboard user and a platform admin holding the same id exhaust each
10530
+ * other's budget — the same two reasons the challenge and disable counters are split.
10531
+ *
10532
+ * @param context - The authentication plane, part of the counter's key.
10533
+ * @param userId - The account being changed, part of the counter's key.
10534
+ * @param passwordHash - The account's stored hash, or `null` for an OAuth-only account.
10535
+ * @param password - The password the caller submitted, if any.
10536
+ * @throws {@link AuthException} `ACCOUNT_LOCKED` once the failure budget for this flow is
10537
+ * spent, or `INVALID_CREDENTIALS` when the account has a password and the submitted one is
10538
+ * absent or wrong. The latter is deliberately the same code a failed login returns: an
10539
+ * attacker holding a stolen token learns nothing from it that a failed login does not tell them.
10479
10540
  */
10480
- platformUserAsSafeUser(admin) {
10481
- const safe = this.toSafePlatformUser(admin);
10482
- return {
10483
- ...safe,
10484
- tenantId: "",
10485
- emailVerified: true
10486
- };
10541
+ async assertReauthenticated(context, userId, passwordHash, password, tenantId) {
10542
+ if (passwordHash === null) {
10543
+ const recent = await this.redis.get(recentAuthKey(context, userId, this.options.hmacKey, tenantId));
10544
+ if (recent === null) {
10545
+ this.logger.warn(`reauthenticate: no recent authentication userId=${logSafe(userId)} context=${context}`);
10546
+ throw new AuthException(AUTH_ERROR_CODES.REAUTHENTICATION_REQUIRED);
10547
+ }
10548
+ return;
10549
+ }
10550
+ if (await this.lockout.isLockedOut("reauth", context, userId, tenantId)) {
10551
+ this.logger.warn(`reauthenticate: account locked userId=${logSafe(userId)} context=${context}`);
10552
+ throw new AuthException(AUTH_ERROR_CODES.ACCOUNT_LOCKED);
10553
+ }
10554
+ const supplied = password ?? "";
10555
+ const matches = await this.passwordService.compare(supplied, passwordHash);
10556
+ if (!matches) {
10557
+ await this.lockout.recordFailure("reauth", context, userId, tenantId);
10558
+ throw new AuthException(AUTH_ERROR_CODES.INVALID_CREDENTIALS);
10559
+ }
10560
+ await this.lockout.reset("reauth", context, userId, tenantId);
10561
+ }
10562
+ };
10563
+ exports.ReauthenticationService = _ts_decorate39([
10564
+ common.Injectable(),
10565
+ _ts_param23(0, common.Inject(BYMAX_AUTH_OPTIONS)),
10566
+ _ts_param23(1, common.Inject(AuthRedisService)),
10567
+ _ts_param23(2, common.Inject(PasswordService)),
10568
+ _ts_param23(3, common.Inject(MfaFlowLockoutService)),
10569
+ _ts_metadata38("design:type", Function),
10570
+ _ts_metadata38("design:paramtypes", [
10571
+ typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
10572
+ typeof AuthRedisService === "undefined" ? Object : AuthRedisService,
10573
+ typeof PasswordService === "undefined" ? Object : PasswordService,
10574
+ typeof MfaFlowLockoutService === "undefined" ? Object : MfaFlowLockoutService
10575
+ ])
10576
+ ], exports.ReauthenticationService);
10577
+ function digestRecoveryCode(code, hmacKey) {
10578
+ return hmacSha256(code, hmacKey);
10579
+ }
10580
+ __name(digestRecoveryCode, "digestRecoveryCode");
10581
+ function generateRecoveryCodes(count, hmacKey) {
10582
+ const plainCodes = [];
10583
+ const hashedCodes = [];
10584
+ for (let i = 0; i < count; i++) {
10585
+ const hex = crypto.randomBytes(12).toString("hex");
10586
+ const groups = [];
10587
+ for (let offset = 0; offset < hex.length; offset += 4) {
10588
+ groups.push(hex.slice(offset, offset + 4));
10589
+ }
10590
+ const code = groups.join("-").toUpperCase();
10591
+ plainCodes.push(code);
10592
+ hashedCodes.push(digestRecoveryCode(code, hmacKey));
10593
+ }
10594
+ return {
10595
+ plainCodes,
10596
+ hashedCodes
10597
+ };
10598
+ }
10599
+ __name(generateRecoveryCodes, "generateRecoveryCodes");
10600
+ async function verifyRecoveryCode(code, hashedCodes, hmacKey, previousHmacKeys) {
10601
+ const candidates = [
10602
+ digestRecoveryCode(code, hmacKey),
10603
+ ...previousHmacKeys.map((key) => hmacSha256(code, key))
10604
+ ];
10605
+ const macMatches = [];
10606
+ for (const hashedCode of hashedCodes) {
10607
+ const hit = candidates.reduce((found, candidate) => timingSafeCompare(candidate, hashedCode) || found, false);
10608
+ macMatches.push(hit);
10609
+ }
10610
+ return macMatches.reduce((found, hit, index) => found === -1 && hit ? index : found, -1);
10611
+ }
10612
+ __name(verifyRecoveryCode, "verifyRecoveryCode");
10613
+
10614
+ // src/server/utils/mfa-safe-user.ts
10615
+ function toSafeUser3(user) {
10616
+ const { passwordHash: _ph, mfaSecret: _ms, mfaRecoveryCodes: _mrc, ...safe } = user;
10617
+ return safe;
10618
+ }
10619
+ __name(toSafeUser3, "toSafeUser");
10620
+ function toSafePlatformUser(admin) {
10621
+ const { passwordHash: _ph, mfaSecret: _ms, mfaRecoveryCodes: _mrc, ...safe } = admin;
10622
+ return safe;
10623
+ }
10624
+ __name(toSafePlatformUser, "toSafePlatformUser");
10625
+ function platformUserAsSafeUser(admin) {
10626
+ const safe = toSafePlatformUser(admin);
10627
+ return {
10628
+ ...safe,
10629
+ tenantId: "",
10630
+ emailVerified: true
10631
+ };
10632
+ }
10633
+ __name(platformUserAsSafeUser, "platformUserAsSafeUser");
10634
+ function committedSafeUser(context, user, mfaEnabled) {
10635
+ const committed = {
10636
+ ...user,
10637
+ mfaEnabled
10638
+ };
10639
+ return context === "platform" ? platformUserAsSafeUser(committed) : toSafeUser3(committed);
10640
+ }
10641
+ __name(committedSafeUser, "committedSafeUser");
10642
+
10643
+ // src/server/utils/mfa-setup-data.ts
10644
+ function isMfaSetupData(value) {
10645
+ if (value === null) return false;
10646
+ if (typeof value !== "object") return false;
10647
+ const v = value;
10648
+ return typeof v["encryptedSecret"] === "string" && typeof v["encryptedPlainCodes"] === "string" && Array.isArray(v["hashedCodes"]) && v["hashedCodes"].every((code) => typeof code === "string");
10649
+ }
10650
+ __name(isMfaSetupData, "isMfaSetupData");
10651
+ function parseSetupData(raw, userId, logger) {
10652
+ let parsed;
10653
+ try {
10654
+ parsed = JSON.parse(raw);
10655
+ } catch {
10656
+ logger.warn(`parseSetupData: pending-setup payload is not valid JSON userId=${logSafe(userId)}`);
10657
+ throw new AuthException(AUTH_ERROR_CODES.MFA_SETUP_REQUIRED);
10658
+ }
10659
+ if (!isMfaSetupData(parsed)) {
10660
+ throw new AuthException(AUTH_ERROR_CODES.MFA_SETUP_REQUIRED);
10487
10661
  }
10662
+ return parsed;
10663
+ }
10664
+ __name(parseSetupData, "parseSetupData");
10665
+ function parsePlainRecoveryCodes(raw, userId, logger) {
10666
+ let parsed;
10667
+ try {
10668
+ parsed = JSON.parse(raw);
10669
+ } catch {
10670
+ logger.warn(`parsePlainRecoveryCodes: decrypted payload is not valid JSON userId=${logSafe(userId)}`);
10671
+ throw new AuthException(AUTH_ERROR_CODES.MFA_SETUP_REQUIRED);
10672
+ }
10673
+ if (!Array.isArray(parsed) || parsed.some((code) => typeof code !== "string")) {
10674
+ throw new AuthException(AUTH_ERROR_CODES.MFA_SETUP_REQUIRED);
10675
+ }
10676
+ return parsed;
10677
+ }
10678
+ __name(parsePlainRecoveryCodes, "parsePlainRecoveryCodes");
10679
+
10680
+ // src/server/utils/run-detached.ts
10681
+ function runDetached(logger, run, failure) {
10682
+ try {
10683
+ void Promise.resolve(run()).catch((err) => {
10684
+ logger.error(`${failure}: ${describeChannelStatus(err)}`);
10685
+ });
10686
+ } catch (err) {
10687
+ logger.error(`${failure}: ${describeChannelStatus(err)}`);
10688
+ }
10689
+ }
10690
+ __name(runDetached, "runDetached");
10691
+
10692
+ // src/server/services/mfa.service.ts
10693
+ function _ts_decorate40(decorators, target, key, desc) {
10694
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10695
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
10696
+ r = Reflect.decorate(decorators, target, key, desc);
10697
+ } else {
10698
+ for (var i = decorators.length - 1; i >= 0; i--) {
10699
+ if (d = decorators[i]) {
10700
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10701
+ }
10702
+ }
10703
+ }
10704
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10705
+ }
10706
+ __name(_ts_decorate40, "_ts_decorate");
10707
+ function _ts_metadata39(metadataKey, metadataValue) {
10708
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
10709
+ return Reflect.metadata(metadataKey, metadataValue);
10710
+ }
10711
+ }
10712
+ __name(_ts_metadata39, "_ts_metadata");
10713
+ function _ts_param24(paramIndex, decorator) {
10714
+ return function(target, key) {
10715
+ decorator(target, key, paramIndex);
10716
+ };
10717
+ }
10718
+ __name(_ts_param24, "_ts_param");
10719
+ var PLATFORM_EMAIL_TENANT = "platform";
10720
+ function emailTenantOf(user) {
10721
+ return "tenantId" in user ? user.tenantId : PLATFORM_EMAIL_TENANT;
10722
+ }
10723
+ __name(emailTenantOf, "emailTenantOf");
10724
+ var MFA_SETUP_TTL_SECONDS = 600;
10725
+ var DEFAULT_RECOVERY_CODE_COUNT = 8;
10726
+ exports.MfaService = class _MfaService {
10727
+ static {
10728
+ __name(this, "MfaService");
10729
+ }
10730
+ options;
10731
+ userRepo;
10732
+ platformUserRepo;
10733
+ redis;
10734
+ tokenManager;
10735
+ records;
10736
+ flowLockout;
10737
+ reauthentication;
10738
+ sessionService;
10739
+ emailProvider;
10740
+ hooks;
10741
+ logger = new common.Logger(_MfaService.name);
10742
+ constructor(options, userRepo, platformUserRepo, redis, tokenManager, records, flowLockout, reauthentication, sessionService, emailProvider, hooks) {
10743
+ this.options = options;
10744
+ this.userRepo = userRepo;
10745
+ this.platformUserRepo = platformUserRepo;
10746
+ this.redis = redis;
10747
+ this.tokenManager = tokenManager;
10748
+ this.records = records;
10749
+ this.flowLockout = flowLockout;
10750
+ this.reauthentication = reauthentication;
10751
+ this.sessionService = sessionService;
10752
+ this.emailProvider = emailProvider;
10753
+ this.hooks = hooks;
10754
+ }
10755
+ // ---------------------------------------------------------------------------
10756
+ // Private accessor — options.mfa is guaranteed non-null when service is active
10757
+ // ---------------------------------------------------------------------------
10488
10758
  /**
10489
- * The account a hook is handed after an MFA transition, projected from the state the transition
10490
- * wrote.
10491
- *
10492
- * The record in hand was read before the transition, so its `mfaEnabled` still describes the
10493
- * state the transition replaced; the hooks run after the write and must be told what it
10494
- * produced. Only the flag is overridden. The secret and recovery-code fields are stripped by
10495
- * the same projections every other hook payload uses, and the repository's own record is not
10496
- * modified.
10759
+ * Returns the resolved MFA configuration. `options.mfa` is always present when `MfaService` is registered.
10497
10760
  *
10498
- * @param context - The identity plane the account belongs to.
10499
- * @param user - The record read before the transition.
10500
- * @param mfaEnabled - Whether the transition left the second factor enabled.
10501
- * @returns The projection for the plane, with `mfaEnabled` as written.
10761
+ * `options.mfa` is always present when `MfaService` is registered — the module
10762
+ * only registers the service when `mfa` is configured. The single suppression
10763
+ * here eliminates repetitive `!` assertions throughout the class.
10502
10764
  */
10503
- committedSafeUser(context, user, mfaEnabled) {
10504
- const committed = {
10505
- ...user,
10506
- mfaEnabled
10507
- };
10508
- return context === "platform" ? this.platformUserAsSafeUser(committed) : this.toSafeUser(committed);
10765
+ get mfaOptions() {
10766
+ return this.options.mfa;
10509
10767
  }
10510
10768
  // ---------------------------------------------------------------------------
10769
+ // Private crypto helpers
10770
+ // ---------------------------------------------------------------------------
10771
+ // ---------------------------------------------------------------------------
10511
10772
  // setup — TOTP secret generation, idempotent key reservation, recovery codes
10512
10773
  // ---------------------------------------------------------------------------
10513
10774
  /**
@@ -10531,20 +10792,20 @@ exports.MfaService = class _MfaService {
10531
10792
  * meaning is the same: "platform MFA cannot operate".
10532
10793
  */
10533
10794
  async setup(userId, context = "dashboard", password, tenantId) {
10534
- this.assertPlaneTenant(context, tenantId);
10795
+ assertPlaneTenant(context, tenantId);
10535
10796
  if (context === "platform" && !this.platformUserRepo) {
10536
10797
  throw new AuthException(AUTH_ERROR_CODES.MFA_NOT_ENABLED);
10537
10798
  }
10538
- const user = await this.fetchUserForContext(context, userId, tenantId);
10799
+ const user = await this.records.loadAccount(context, userId, tenantId);
10539
10800
  if (user.mfaEnabled) throw new AuthException(AUTH_ERROR_CODES.MFA_ALREADY_ENABLED);
10540
- await this.assertReauthenticated(context, userId, user.passwordHash, password, tenantId);
10801
+ await this.reauthentication.assertReauthenticated(context, userId, user.passwordHash, password, tenantId);
10541
10802
  const setupKey = `mfa_setup:${hmacSha256(userSubject(context, userId, tenantId), this.options.hmacKey)}`;
10542
10803
  const existingFast = await this.redis.get(setupKey);
10543
10804
  if (existingFast !== null) {
10544
- const data = this.parseSetupData(existingFast, userId);
10545
- const existingSecret = this.decryptSecret(data.encryptedSecret);
10546
- const decryptedCodesJson = this.decryptSecret(data.encryptedPlainCodes);
10547
- const existingCodes = this.parsePlainRecoveryCodes(decryptedCodesJson, userId);
10805
+ const data = parseSetupData(existingFast, userId, this.logger);
10806
+ const existingSecret = decryptMfaSecret(data.encryptedSecret, this.mfaOptions);
10807
+ const decryptedCodesJson = decryptMfaSecret(data.encryptedPlainCodes, this.mfaOptions);
10808
+ const existingCodes = parsePlainRecoveryCodes(decryptedCodesJson, userId, this.logger);
10548
10809
  const qrCodeUri2 = buildTotpUri(existingSecret, user.email, this.mfaOptions.issuer);
10549
10810
  return {
10550
10811
  secret: existingSecret,
@@ -10553,9 +10814,9 @@ exports.MfaService = class _MfaService {
10553
10814
  };
10554
10815
  }
10555
10816
  const { base32: secretBase32 } = generateTotpSecret();
10556
- const encryptedSecret = this.encryptSecret(secretBase32);
10817
+ const encryptedSecret = encryptMfaSecret(secretBase32, this.mfaOptions);
10557
10818
  const recoveryCount = this.mfaOptions.recoveryCodeCount ?? DEFAULT_RECOVERY_CODE_COUNT;
10558
- const { plainCodes, hashedCodes } = this.hashRecoveryCodes(recoveryCount);
10819
+ const { plainCodes, hashedCodes } = generateRecoveryCodes(recoveryCount, this.options.hmacKey);
10559
10820
  const encryptedPlainCodes = encrypt(JSON.stringify(plainCodes), this.mfaOptions.encryptionKey);
10560
10821
  const setupData = {
10561
10822
  encryptedSecret,
@@ -10567,10 +10828,10 @@ exports.MfaService = class _MfaService {
10567
10828
  if (!wasSet) {
10568
10829
  const existing = await this.redis.get(setupKey);
10569
10830
  if (existing !== null) {
10570
- const data = this.parseSetupData(existing, userId);
10571
- const existingSecret = this.decryptSecret(data.encryptedSecret);
10572
- const decryptedCodesJson = this.decryptSecret(data.encryptedPlainCodes);
10573
- const existingCodes = this.parsePlainRecoveryCodes(decryptedCodesJson, userId);
10831
+ const data = parseSetupData(existing, userId, this.logger);
10832
+ const existingSecret = decryptMfaSecret(data.encryptedSecret, this.mfaOptions);
10833
+ const decryptedCodesJson = decryptMfaSecret(data.encryptedPlainCodes, this.mfaOptions);
10834
+ const existingCodes = parsePlainRecoveryCodes(decryptedCodesJson, userId, this.logger);
10574
10835
  const qrCodeUri2 = buildTotpUri(existingSecret, user.email, this.mfaOptions.issuer);
10575
10836
  return {
10576
10837
  secret: existingSecret,
@@ -10612,19 +10873,19 @@ exports.MfaService = class _MfaService {
10612
10873
  * repository was not configured at module registration.
10613
10874
  */
10614
10875
  async verifyAndEnable(userId, code, ip, userAgent, context = "dashboard", tenantId) {
10615
- this.assertPlaneTenant(context, tenantId);
10876
+ assertPlaneTenant(context, tenantId);
10616
10877
  if (context === "platform" && !this.platformUserRepo) {
10617
10878
  throw new AuthException(AUTH_ERROR_CODES.MFA_NOT_ENABLED);
10618
10879
  }
10619
- const user = await this.fetchUserForContext(context, userId, tenantId);
10880
+ const user = await this.records.loadAccount(context, userId, tenantId);
10620
10881
  if (user.mfaEnabled) throw new AuthException(AUTH_ERROR_CODES.MFA_ALREADY_ENABLED);
10621
10882
  const setupKey = `mfa_setup:${hmacSha256(userSubject(context, userId, tenantId), this.options.hmacKey)}`;
10622
10883
  const raw = await this.redis.get(setupKey);
10623
10884
  if (raw === null) throw new AuthException(AUTH_ERROR_CODES.MFA_SETUP_REQUIRED);
10624
- const data = this.parseSetupData(raw, userId);
10625
- const secretBase32 = this.decryptSecret(data.encryptedSecret);
10885
+ const data = parseSetupData(raw, userId, this.logger);
10886
+ const secretBase32 = decryptMfaSecret(data.encryptedSecret, this.mfaOptions);
10626
10887
  const totpWindow = this.mfaOptions.totpWindow;
10627
- const codeValid = await this.verifyTotpWithAntiReplay(context, userId, secretBase32, code, totpWindow, tenantId);
10888
+ const codeValid = await this.records.verifyTotpWithAntiReplay(context, userId, secretBase32, code, totpWindow, tenantId);
10628
10889
  if (!codeValid) {
10629
10890
  this.logger.warn(`verifyAndEnable: invalid TOTP code userId=${logSafe(userId)}`);
10630
10891
  throw new AuthException(AUTH_ERROR_CODES.MFA_INVALID_CODE);
@@ -10634,7 +10895,7 @@ exports.MfaService = class _MfaService {
10634
10895
  this.logger.warn(`verifyAndEnable: setup key consumed by concurrent request userId=${logSafe(userId)}`);
10635
10896
  throw new AuthException(AUTH_ERROR_CODES.MFA_SETUP_REQUIRED);
10636
10897
  }
10637
- await this.transitionMfaRecord(context, userId, tenantId, () => ({
10898
+ await this.records.transition(context, userId, tenantId, () => ({
10638
10899
  mfaEnabled: true,
10639
10900
  mfaSecret: data.encryptedSecret,
10640
10901
  mfaRecoveryCodes: data.hashedCodes
@@ -10644,7 +10905,7 @@ exports.MfaService = class _MfaService {
10644
10905
  this.logger.log(`verifyAndEnable: MFA enabled userId=${logSafe(userId)} context=${context}`);
10645
10906
  this.notify("verifyAndEnable", userId, user, (provider, tenant, email) => provider.sendMfaEnabledNotification(tenant, email));
10646
10907
  if (this.hooks.afterMfaEnabled) {
10647
- const safeUser = this.committedSafeUser(context, user, true);
10908
+ const safeUser = committedSafeUser(context, user, true);
10648
10909
  void Promise.resolve(this.hooks.afterMfaEnabled(safeUser, {
10649
10910
  // The plane, because the tenant cannot carry it: a platform admin is rendered with the
10650
10911
  // sentinel `tenantId: ''` while a platform token has no tenant claim at all.
@@ -10678,32 +10939,32 @@ exports.MfaService = class _MfaService {
10678
10939
  */
10679
10940
  async challenge(mfaTempToken, code, ip, userAgent) {
10680
10941
  const { userId, context, tenantId, jti: tempTokenJti } = await this.tokenManager.verifyMfaTempToken(mfaTempToken);
10681
- if (await this.isMfaFlowLockedOut("challenge", context, userId, tenantId)) {
10942
+ if (await this.flowLockout.isLockedOut("challenge", context, userId, tenantId)) {
10682
10943
  this.logger.warn(`challenge: account locked userId=${logSafe(userId)}`);
10683
10944
  throw new AuthException(AUTH_ERROR_CODES.ACCOUNT_LOCKED);
10684
10945
  }
10685
- const user = await this.fetchUserForContext(context, userId, tenantId);
10946
+ const user = await this.records.loadAccount(context, userId, tenantId);
10686
10947
  if (!user.mfaEnabled || !user.mfaSecret) {
10687
10948
  throw new AuthException(AUTH_ERROR_CODES.MFA_NOT_ENABLED);
10688
10949
  }
10689
- const { secret: secretBase32, stale: encryptedUnderRetiredKey } = this.decryptWithRotation(user.mfaSecret);
10950
+ const { secret: secretBase32, stale: encryptedUnderRetiredKey } = decryptWithRotation(user.mfaSecret, this.mfaOptions);
10690
10951
  const isTotpCode = /^\d{6}$/.test(code);
10691
10952
  const totpWindow = this.mfaOptions.totpWindow;
10692
10953
  let codeValid = false;
10693
10954
  let usedRecoveryIndex = -1;
10694
10955
  if (isTotpCode) {
10695
- codeValid = await this.verifyTotpWithAntiReplay(context, userId, secretBase32, code, totpWindow, tenantId);
10956
+ codeValid = await this.records.verifyTotpWithAntiReplay(context, userId, secretBase32, code, totpWindow, tenantId);
10696
10957
  } else {
10697
10958
  const recoveryCodes = user.mfaRecoveryCodes ?? [];
10698
- usedRecoveryIndex = await this.verifyRecoveryCode(code, recoveryCodes);
10699
- codeValid = usedRecoveryIndex >= 0 && await this.claimRecoveryCode(context, userId, code, tenantId);
10959
+ usedRecoveryIndex = await verifyRecoveryCode(code, recoveryCodes, this.options.hmacKey, this.options.previousHmacKeys);
10960
+ codeValid = usedRecoveryIndex >= 0 && await this.records.claimRecoveryCode(context, userId, code, tenantId);
10700
10961
  }
10701
10962
  if (!codeValid) {
10702
- await this.recordMfaFlowFailure("challenge", context, userId, tenantId);
10963
+ await this.flowLockout.recordFailure("challenge", context, userId, tenantId);
10703
10964
  this.logger.warn(`challenge: invalid MFA code userId=${logSafe(userId)} context=${context}`);
10704
10965
  throw new AuthException(AUTH_ERROR_CODES.MFA_INVALID_CODE);
10705
10966
  }
10706
- await this.resetMfaFlowFailures("challenge", context, userId, tenantId);
10967
+ await this.flowLockout.reset("challenge", context, userId, tenantId);
10707
10968
  if (!await this.tokenManager.consumeMfaTempToken(tempTokenJti)) {
10708
10969
  throw new AuthException(AUTH_ERROR_CODES.MFA_TEMP_TOKEN_INVALID);
10709
10970
  }
@@ -10712,9 +10973,9 @@ exports.MfaService = class _MfaService {
10712
10973
  // Stryker disable next-line ArrayDeclaration: unreachable — this branch is only taken
10713
10974
  // when `verifyRecoveryCode` matched a code inside an array it had to iterate first.
10714
10975
  [];
10715
- await this.transitionMfaRecord(context, userId, tenantId, (current) => {
10976
+ await this.records.transition(context, userId, tenantId, (current) => {
10716
10977
  if (!current.mfaEnabled) return null;
10717
- if (!this.holdsSecret(current.mfaSecret, secretBase32)) return null;
10978
+ if (!holdsSecret(current.mfaSecret, secretBase32, this.mfaOptions)) return null;
10718
10979
  const currentCodes = current.mfaRecoveryCodes ?? [];
10719
10980
  const spentDigest = existingCodes[usedRecoveryIndex] ?? "";
10720
10981
  const liveIndex = currentCodes.indexOf(spentDigest);
@@ -10727,16 +10988,16 @@ exports.MfaService = class _MfaService {
10727
10988
  mfaEnabled: true,
10728
10989
  // Re-encrypted here when the secret opened under a retired key: the write is
10729
10990
  // already happening, so the rotation drains for free.
10730
- mfaSecret: encryptedUnderRetiredKey ? this.encryptSecret(secretBase32) : current.mfaSecret,
10991
+ mfaSecret: encryptedUnderRetiredKey ? encryptMfaSecret(secretBase32, this.mfaOptions) : current.mfaSecret,
10731
10992
  mfaRecoveryCodes: updatedCodes
10732
10993
  };
10733
10994
  });
10734
10995
  } else if (encryptedUnderRetiredKey) {
10735
- void this.reencryptSecret(userId, context, secretBase32, tenantId);
10996
+ void this.records.reencryptSecret(userId, context, secretBase32, tenantId, this.mfaOptions);
10736
10997
  }
10737
10998
  this.logger.log(`challenge: MFA challenge passed userId=${logSafe(userId)} context=${context}`);
10738
10999
  if (context === "dashboard") {
10739
- const safeUser = this.toSafeUser(user);
11000
+ const safeUser = toSafeUser3(user);
10740
11001
  const result2 = await this.tokenManager.issueTokens(safeUser, ip, userAgent, {
10741
11002
  mfaVerified: true
10742
11003
  });
@@ -10766,13 +11027,13 @@ exports.MfaService = class _MfaService {
10766
11027
  return result2;
10767
11028
  }
10768
11029
  const platformUser = user;
10769
- const result = await this.tokenManager.issuePlatformTokens(this.toSafePlatformUser(platformUser), ip, userAgent, {
11030
+ const result = await this.tokenManager.issuePlatformTokens(toSafePlatformUser(platformUser), ip, userAgent, {
10770
11031
  mfaVerified: true
10771
11032
  });
10772
11033
  runDetached(this.logger, () => this.platformUserRepo.updateLastLogin(platformUser.id), "challenge: platform updateLastLogin failed");
10773
11034
  if (this.hooks.afterLogin) {
10774
11035
  const afterLogin = this.hooks.afterLogin.bind(this.hooks);
10775
- runDetached(this.logger, () => afterLogin(this.platformUserAsSafeUser(platformUser), {
11036
+ runDetached(this.logger, () => afterLogin(platformUserAsSafeUser(platformUser), {
10776
11037
  plane: "platform",
10777
11038
  userId,
10778
11039
  ip,
@@ -10841,26 +11102,26 @@ exports.MfaService = class _MfaService {
10841
11102
  * @throws `MFA_INVALID_CODE` if the submitted TOTP code is incorrect.
10842
11103
  */
10843
11104
  async disable(userId, code, ip, userAgent, context = "dashboard", tenantId) {
10844
- this.assertPlaneTenant(context, tenantId);
10845
- const user = await this.fetchUserForContext(context, userId, tenantId);
11105
+ assertPlaneTenant(context, tenantId);
11106
+ const user = await this.records.loadAccount(context, userId, tenantId);
10846
11107
  if (!user.mfaEnabled) throw new AuthException(AUTH_ERROR_CODES.MFA_NOT_ENABLED);
10847
- if (await this.isMfaFlowLockedOut("disable", context, userId, tenantId)) {
11108
+ if (await this.flowLockout.isLockedOut("disable", context, userId, tenantId)) {
10848
11109
  this.logger.warn(`disable: account locked userId=${logSafe(userId)} context=${context}`);
10849
11110
  throw new AuthException(AUTH_ERROR_CODES.ACCOUNT_LOCKED);
10850
11111
  }
10851
11112
  if (!user.mfaSecret) {
10852
11113
  throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
10853
11114
  }
10854
- const secretBase32 = this.decryptSecret(user.mfaSecret);
11115
+ const secretBase32 = decryptMfaSecret(user.mfaSecret, this.mfaOptions);
10855
11116
  const totpWindow = this.mfaOptions.totpWindow;
10856
- const codeValid = await this.verifyTotpWithAntiReplay(context, userId, secretBase32, code, totpWindow, tenantId);
11117
+ const codeValid = await this.records.verifyTotpWithAntiReplay(context, userId, secretBase32, code, totpWindow, tenantId);
10857
11118
  if (!codeValid) {
10858
- await this.recordMfaFlowFailure("disable", context, userId, tenantId);
11119
+ await this.flowLockout.recordFailure("disable", context, userId, tenantId);
10859
11120
  this.logger.warn(`disable: invalid MFA code userId=${logSafe(userId)} context=${context}`);
10860
11121
  throw new AuthException(AUTH_ERROR_CODES.MFA_INVALID_CODE);
10861
11122
  }
10862
- await this.resetMfaFlowFailures("disable", context, userId, tenantId);
10863
- await this.transitionMfaRecord(context, userId, tenantId, () => ({
11123
+ await this.flowLockout.reset("disable", context, userId, tenantId);
11124
+ await this.records.transition(context, userId, tenantId, () => ({
10864
11125
  mfaEnabled: false,
10865
11126
  mfaSecret: null,
10866
11127
  mfaRecoveryCodes: null
@@ -10869,7 +11130,7 @@ exports.MfaService = class _MfaService {
10869
11130
  await this.redis.bumpUserTokenEpoch(userId, tenantId, context);
10870
11131
  this.logger.log(`disable: MFA disabled userId=${logSafe(userId)} context=${context}`);
10871
11132
  this.notify("disable", userId, user, (provider, tenant, email) => provider.sendMfaDisabledNotification(tenant, email));
10872
- const safeUser = this.committedSafeUser(context, user, false);
11133
+ const safeUser = committedSafeUser(context, user, false);
10873
11134
  if (this.hooks.afterMfaDisabled) {
10874
11135
  void Promise.resolve(this.hooks.afterMfaDisabled(safeUser, {
10875
11136
  plane: context,
@@ -10922,13 +11183,13 @@ exports.MfaService = class _MfaService {
10922
11183
  * @throws `TOKEN_INVALID` if no user with that ID exists in the given plane.
10923
11184
  */
10924
11185
  async resetMfa(userId, context = "dashboard", tenantId) {
10925
- this.assertPlaneTenant(context, tenantId);
10926
- const user = await this.fetchUserForContext(context, userId, tenantId);
11186
+ assertPlaneTenant(context, tenantId);
11187
+ const user = await this.records.loadAccount(context, userId, tenantId);
10927
11188
  if (!user.mfaEnabled) {
10928
11189
  this.logger.log(`resetMfa: no second factor to remove userId=${logSafe(userId)} context=${context}`);
10929
11190
  return;
10930
11191
  }
10931
- await this.transitionMfaRecord(context, userId, tenantId, () => ({
11192
+ await this.records.transition(context, userId, tenantId, () => ({
10932
11193
  mfaEnabled: false,
10933
11194
  mfaSecret: null,
10934
11195
  mfaRecoveryCodes: null
@@ -10937,7 +11198,7 @@ exports.MfaService = class _MfaService {
10937
11198
  await this.redis.bumpUserTokenEpoch(userId, tenantId, context);
10938
11199
  this.logger.warn(`resetMfa: MFA removed administratively userId=${logSafe(userId)} context=${context}`);
10939
11200
  this.notify("resetMfa", userId, user, (provider, tenant, email) => provider.sendMfaDisabledNotification(tenant, email));
10940
- const safeUser = this.committedSafeUser(context, user, false);
11201
+ const safeUser = committedSafeUser(context, user, false);
10941
11202
  if (this.hooks.afterMfaDisabled) {
10942
11203
  void Promise.resolve(this.hooks.afterMfaDisabled(safeUser, {
10943
11204
  plane: context,
@@ -10991,31 +11252,31 @@ exports.MfaService = class _MfaService {
10991
11252
  * @returns The freshly generated plain-text recovery codes, one-time display.
10992
11253
  */
10993
11254
  async regenerateRecoveryCodes(userId, totpCode, ip, userAgent, context = "dashboard", tenantId) {
10994
- this.assertPlaneTenant(context, tenantId);
11255
+ assertPlaneTenant(context, tenantId);
10995
11256
  if (context === "platform" && !this.platformUserRepo) {
10996
11257
  throw new AuthException(AUTH_ERROR_CODES.MFA_NOT_ENABLED);
10997
11258
  }
10998
- const user = await this.fetchUserForContext(context, userId, tenantId);
11259
+ const user = await this.records.loadAccount(context, userId, tenantId);
10999
11260
  if (!user.mfaEnabled) throw new AuthException(AUTH_ERROR_CODES.MFA_NOT_ENABLED);
11000
- if (await this.isMfaFlowLockedOut("disable", context, userId, tenantId)) {
11261
+ if (await this.flowLockout.isLockedOut("disable", context, userId, tenantId)) {
11001
11262
  this.logger.warn(`regenerateRecoveryCodes: account locked userId=${logSafe(userId)} context=${context}`);
11002
11263
  throw new AuthException(AUTH_ERROR_CODES.ACCOUNT_LOCKED);
11003
11264
  }
11004
11265
  if (!user.mfaSecret) {
11005
11266
  throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
11006
11267
  }
11007
- const secretBase32 = this.decryptSecret(user.mfaSecret);
11268
+ const secretBase32 = decryptMfaSecret(user.mfaSecret, this.mfaOptions);
11008
11269
  const totpWindow = this.mfaOptions.totpWindow;
11009
- const codeValid = await this.verifyTotpWithAntiReplay(context, userId, secretBase32, totpCode, totpWindow, tenantId);
11270
+ const codeValid = await this.records.verifyTotpWithAntiReplay(context, userId, secretBase32, totpCode, totpWindow, tenantId);
11010
11271
  if (!codeValid) {
11011
- await this.recordMfaFlowFailure("disable", context, userId, tenantId);
11272
+ await this.flowLockout.recordFailure("disable", context, userId, tenantId);
11012
11273
  this.logger.warn(`regenerateRecoveryCodes: invalid MFA code userId=${logSafe(userId)} context=${context}`);
11013
11274
  throw new AuthException(AUTH_ERROR_CODES.MFA_INVALID_CODE);
11014
11275
  }
11015
- await this.resetMfaFlowFailures("disable", context, userId, tenantId);
11276
+ await this.flowLockout.reset("disable", context, userId, tenantId);
11016
11277
  const recoveryCount = this.mfaOptions.recoveryCodeCount ?? DEFAULT_RECOVERY_CODE_COUNT;
11017
- const { plainCodes, hashedCodes } = this.hashRecoveryCodes(recoveryCount);
11018
- const replaced = await this.transitionMfaRecord(context, userId, tenantId, (current) => {
11278
+ const { plainCodes, hashedCodes } = generateRecoveryCodes(recoveryCount, this.options.hmacKey);
11279
+ const replaced = await this.records.transition(context, userId, tenantId, (current) => {
11019
11280
  if (!current.mfaEnabled) return null;
11020
11281
  return {
11021
11282
  mfaEnabled: true,
@@ -11026,7 +11287,7 @@ exports.MfaService = class _MfaService {
11026
11287
  if (!replaced) throw new AuthException(AUTH_ERROR_CODES.MFA_NOT_ENABLED);
11027
11288
  this.logger.log(`regenerateRecoveryCodes: recovery codes regenerated userId=${logSafe(userId)} context=${context}`);
11028
11289
  if (this.hooks.afterMfaRecoveryCodesRegenerated) {
11029
- const safeUser = context === "platform" ? this.platformUserAsSafeUser(user) : this.toSafeUser(user);
11290
+ const safeUser = context === "platform" ? platformUserAsSafeUser(user) : toSafeUser3(user);
11030
11291
  void Promise.resolve(this.hooks.afterMfaRecoveryCodesRegenerated(safeUser, {
11031
11292
  plane: context,
11032
11293
  userId,
@@ -11043,175 +11304,6 @@ exports.MfaService = class _MfaService {
11043
11304
  // Private helpers
11044
11305
  // ---------------------------------------------------------------------------
11045
11306
  /**
11046
- * Verifies a TOTP code and enforces anti-replay within the validation window.
11047
- *
11048
- * Stores a Redis key `tu:{hmac}` where `hmac = hmacSha256("{userSubject}:{code}", hmacKey)` —
11049
- * so the marker is scoped to the plane and, on the dashboard plane, to the tenant. A second
11050
- * submission of the same code within the TTL is rejected as a replay. Binding the marker to
11051
- * both the subject and the code value prevents code disclosure in Redis and cross-user,
11052
- * cross-tenant and cross-plane replay alike.
11053
- *
11054
- * A second marker under the pre-scoping preimage `{context}:{userId}:{code}` is written and
11055
- * required alongside it; see the call site for why both must be fresh during a rolling upgrade.
11056
- *
11057
- * @returns `true` if the code is valid and has not been replayed, `false` otherwise.
11058
- */
11059
- async verifyTotpWithAntiReplay(context, userId, secretBase32, code, window, tenantId) {
11060
- if (!verifyTotp(secretBase32, code, window)) return false;
11061
- const ttl = totpAntiReplayTtlSeconds(window);
11062
- const scopedReplayKey = `tu:${hmacSha256(`${userSubject(context, userId, tenantId)}:${code}`, this.options.hmacKey)}`;
11063
- const legacyReplayKey = `tu:${hmacSha256(`${context}:${userId}:${code}`, this.options.hmacKey)}`;
11064
- const scopedIsNew = await this.redis.setnx(scopedReplayKey, ttl);
11065
- if (scopedReplayKey === legacyReplayKey) return scopedIsNew;
11066
- const legacyIsNew = await this.redis.setnx(legacyReplayKey, ttl);
11067
- return scopedIsNew && legacyIsNew;
11068
- }
11069
- /**
11070
- * Requires the caller to re-prove the account password before a factor is changed.
11071
- *
11072
- * Counted like a login, and for the same reason. `login` refuses an account after N wrong
11073
- * passwords; this door asks for the same secret and used to refuse nothing, so a caller
11074
- * holding a stolen access token but not the password could guess it here indefinitely. The
11075
- * only control left was the per-route IP limit, which a distributed caller sidesteps — and
11076
- * winning the guess buys the whole account: enrol a factor, change the password, move the
11077
- * address. A door that takes the password has to carry the password's lockout.
11078
- *
11079
- * The identifier is namespaced by flow and by plane. Sharing one counter with `login` would
11080
- * let an authenticated caller lock the owner out of their own sign-in, and sharing it across
11081
- * planes would let a dashboard user and a platform admin holding the same id exhaust each
11082
- * other's budget — the same two reasons the challenge and disable counters are split.
11083
- *
11084
- * @param context - The authentication plane, part of the counter's key.
11085
- * @param userId - The account being changed, part of the counter's key.
11086
- * @param passwordHash - The account's stored hash, or `null` for an OAuth-only account.
11087
- * @param password - The password the caller submitted, if any.
11088
- * @throws {@link AuthException} `ACCOUNT_LOCKED` once the failure budget for this flow is
11089
- * spent, or `INVALID_CREDENTIALS` when the account has a password and the submitted one is
11090
- * absent or wrong. The latter is deliberately the same code a failed login returns: an
11091
- * attacker holding a stolen token learns nothing from it beyond what they already knew.
11092
- */
11093
- async assertReauthenticated(context, userId, passwordHash, password, tenantId) {
11094
- if (passwordHash === null) {
11095
- const recent = await this.redis.get(recentAuthKey(context, userId, this.options.hmacKey, tenantId));
11096
- if (recent === null) {
11097
- this.logger.warn(`reauthenticate: no recent authentication userId=${logSafe(userId)} context=${context}`);
11098
- throw new AuthException(AUTH_ERROR_CODES.REAUTHENTICATION_REQUIRED);
11099
- }
11100
- return;
11101
- }
11102
- if (await this.isMfaFlowLockedOut("reauth", context, userId, tenantId)) {
11103
- this.logger.warn(`reauthenticate: account locked userId=${logSafe(userId)} context=${context}`);
11104
- throw new AuthException(AUTH_ERROR_CODES.ACCOUNT_LOCKED);
11105
- }
11106
- const supplied = password ?? "";
11107
- const matches = await this.passwordService.compare(supplied, passwordHash);
11108
- if (!matches) {
11109
- await this.recordMfaFlowFailure("reauth", context, userId, tenantId);
11110
- throw new AuthException(AUTH_ERROR_CODES.INVALID_CREDENTIALS);
11111
- }
11112
- await this.resetMfaFlowFailures("reauth", context, userId, tenantId);
11113
- }
11114
- /**
11115
- * Asserts a dashboard-plane call carries a tenant, narrowing it to `string` for the caller.
11116
- *
11117
- * This is the dashboard half of {@link assertPlaneTenant}, split out for one reason: an
11118
- * assertion signature is the only way to state "past this point the tenant is present" to the
11119
- * type system. `IUserRepository.findById` requires the tenant, and the account read behind the
11120
- * MFA flows sits under a `context === 'dashboard'` branch where a `void` guard run earlier in
11121
- * the caller has narrowed nothing. Without this the branch had to pass `string | undefined`
11122
- * into a `string` parameter, which is precisely the tenant-blind read the guard exists to stop.
11123
- *
11124
- * @param tenantId - The tenant supplied by the caller, if any.
11125
- * @throws {@link AuthException} `VALIDATION` (400) when it is missing or blank.
11126
- */
11127
- assertDashboardTenant(tenantId) {
11128
- if (tenantId === void 0 || tenantId === "") {
11129
- throw new AuthException(AUTH_ERROR_CODES.VALIDATION, [
11130
- {
11131
- field: "tenantId",
11132
- message: PLANE_TENANT_MESSAGE
11133
- }
11134
- ]);
11135
- }
11136
- }
11137
- /**
11138
- * A dashboard MFA flow MUST carry the tenant it was authenticated in; a platform flow MUST NOT.
11139
- *
11140
- * The controller sources the tenant from the verified JWT, which always carries a validated
11141
- * `tenantId`, so this never trips through the HTTP surface. It guards the OTHER caller:
11142
- * `MfaService` is a public API, and a host wiring it directly — or a future SSO path — could hand
11143
- * a dashboard `userId` with no tenant, which would silently reach the tenant-blind account read
11144
- * and key derivation. Refuse it here, naming the field, rather than let it degrade to the
11145
- * pre-tenant behaviour, which is exactly the fallback an attacker would aim for.
11146
- *
11147
- * @param context - The identity plane the call is on.
11148
- * @param tenantId - The tenant supplied by the caller, if any.
11149
- * @throws {@link AuthException} `VALIDATION` (400) when a dashboard call omits the tenant, or a
11150
- * platform call supplies one.
11151
- */
11152
- assertPlaneTenant(context, tenantId) {
11153
- if (context === "dashboard") {
11154
- this.assertDashboardTenant(tenantId);
11155
- return;
11156
- }
11157
- if (tenantId !== void 0) {
11158
- throw new AuthException(AUTH_ERROR_CODES.VALIDATION, [
11159
- {
11160
- field: "tenantId",
11161
- message: PLANE_TENANT_MESSAGE
11162
- }
11163
- ]);
11164
- }
11165
- }
11166
- /**
11167
- * The tenant-scoped brute-force identifier for one MFA flow, and the legacy plane-only one it
11168
- * replaces — equal on the platform plane, where the subject never carried a tenant, and distinct
11169
- * on the dashboard plane, where it now does.
11170
- *
11171
- * A rolling upgrade runs old and new code against one Redis at once: on the dashboard plane an
11172
- * old pod counts a failure under `{flow}:{plane}:{userId}` while a new pod counts it under
11173
- * `{flow}:{userSubject}`, and either alone leaves a hole — a lockout an old pod filled would not
11174
- * stop a new pod, and a success on one would not clear the other. For one release every read
11175
- * consults both and every write touches both, so the two move as one; a later release drops the
11176
- * legacy arm. On the platform plane the two ids are identical (no tenant ever entered the
11177
- * subject), so the legacy arm is skipped — operating it would just be the same key a second time,
11178
- * double-counting a failure and locking a platform admin out at half the threshold. `{flow}`
11179
- * (`challenge` / `disable` / `reauth`) keeps the three counters isolated, exactly as before.
11180
- */
11181
- mfaFlowCounterIds(flow, context, userId, tenantId) {
11182
- return {
11183
- legacy: hmacSha256(`${flow}:${context}:${userId}`, this.options.hmacKey),
11184
- scoped: hmacSha256(`${flow}:${userSubject(context, userId, tenantId)}`, this.options.hmacKey)
11185
- };
11186
- }
11187
- /**
11188
- * Locked out when EITHER the legacy or the tenant-scoped counter has reached the threshold, so
11189
- * neither a lockout an old pod recorded nor one a new pod recorded can be bypassed mid-migration.
11190
- */
11191
- async isMfaFlowLockedOut(flow, context, userId, tenantId) {
11192
- const { legacy, scoped } = this.mfaFlowCounterIds(flow, context, userId, tenantId);
11193
- if (await this.bruteForce.isLockedOut(scoped)) return true;
11194
- return legacy !== scoped ? this.bruteForce.isLockedOut(legacy) : false;
11195
- }
11196
- /**
11197
- * Records the failure under both counters so the budget an attacker spends is seen by old and
11198
- * new code alike — but under the scoped id ONCE when the two coincide (platform plane).
11199
- */
11200
- async recordMfaFlowFailure(flow, context, userId, tenantId) {
11201
- const { legacy, scoped } = this.mfaFlowCounterIds(flow, context, userId, tenantId);
11202
- await this.bruteForce.recordFailure(scoped);
11203
- if (legacy !== scoped) await this.bruteForce.recordFailure(legacy);
11204
- }
11205
- /**
11206
- * Clears both counters on success — resetting only one would leave the other to lock a
11207
- * legitimately authenticated user out on the next attempt — collapsing to one when they coincide.
11208
- */
11209
- async resetMfaFlowFailures(flow, context, userId, tenantId) {
11210
- const { legacy, scoped } = this.mfaFlowCounterIds(flow, context, userId, tenantId);
11211
- await this.bruteForce.resetFailures(scoped);
11212
- if (legacy !== scoped) await this.bruteForce.resetFailures(legacy);
11213
- }
11214
- /**
11215
11307
  * Sends an MFA state-change notice, fire-and-forget, with the recipient kept out of the log.
11216
11308
  *
11217
11309
  * **Not awaited, and that is the fix, not a shortcut.** These three sends used to be awaited
@@ -11249,76 +11341,31 @@ exports.MfaService = class _MfaService {
11249
11341
  }
11250
11342
  })();
11251
11343
  }
11252
- /**
11253
- * Fetches a user from the correct repository based on the MFA context, and refuses one whose
11254
- * account is blocked.
11255
- *
11256
- * The status gate lives here rather than in each caller because every entry point that
11257
- * reaches this method changes or spends an authentication factor, and every one of them
11258
- * must refuse a suspended or banned account. It used to live in `challenge` alone, so
11259
- * `setup`, `verifyAndEnable`, `disable` and `regenerateRecoveryCodes` had no gate at all:
11260
- * an operator who suspended a compromised account bought nothing against an attacker still
11261
- * holding an unexpired access token, who could turn the second factor off — or enrol their
11262
- * own authenticator over it — for the token's remaining lifetime. Nothing else covers that
11263
- * window: no status change bumps the token epoch, so the per-request check is the only
11264
- * defence, and neither MFA controller composes `UserStatusGuard` (the platform plane has no
11265
- * status guard at all). Every other authority-bearing route in the library does gate on
11266
- * status; changing an authentication factor is at least as privileged as minting an
11267
- * invitation.
11268
- *
11269
- * Gating the fetch rather than the callers is deliberate: a method added later inherits the
11270
- * check instead of having to remember it.
11271
- *
11272
- * @param context - Which identity plane the caller is acting on.
11273
- * @param userId - The subject taken from the verified token.
11274
- * @param tenantId - The tenant the caller was authenticated in, on the dashboard plane;
11275
- * absent on the platform plane, whose admins belong to none.
11276
- * @returns The account record, guaranteed to be in good standing.
11277
- * @throws `TOKEN_INVALID` if the user is not found.
11278
- * @throws {@link AuthException} the status error when the account is blocked.
11279
- */
11280
- async fetchUserForContext(context, userId, tenantId) {
11281
- if (context === "dashboard") {
11282
- this.assertDashboardTenant(tenantId);
11283
- const user = await this.userRepo.findById({
11284
- id: userId,
11285
- tenantId
11286
- });
11287
- if (!user) throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
11288
- assertNotBlocked(user.status, this.options.blockedStatuses);
11289
- return user;
11290
- }
11291
- if (!this.platformUserRepo) {
11292
- throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
11293
- }
11294
- const admin = await this.platformUserRepo.findById(userId);
11295
- if (!admin) throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
11296
- assertNotBlocked(admin.status, this.options.blockedStatuses);
11297
- return admin;
11298
- }
11299
11344
  };
11300
- exports.MfaService = _ts_decorate37([
11345
+ exports.MfaService = _ts_decorate40([
11301
11346
  common.Injectable(),
11302
- _ts_param21(0, common.Inject(BYMAX_AUTH_OPTIONS)),
11303
- _ts_param21(1, common.Inject(BYMAX_AUTH_USER_REPOSITORY)),
11304
- _ts_param21(2, common.Optional()),
11305
- _ts_param21(2, common.Inject(BYMAX_AUTH_PLATFORM_USER_REPOSITORY)),
11306
- _ts_param21(3, common.Inject(AuthRedisService)),
11307
- _ts_param21(4, common.Inject(TokenManagerService)),
11308
- _ts_param21(5, common.Inject(exports.BruteForceService)),
11309
- _ts_param21(6, common.Inject(PasswordService)),
11310
- _ts_param21(7, common.Inject(exports.SessionService)),
11311
- _ts_param21(8, common.Inject(BYMAX_AUTH_EMAIL_PROVIDER)),
11312
- _ts_param21(9, common.Inject(BYMAX_AUTH_HOOKS)),
11313
- _ts_metadata36("design:type", Function),
11314
- _ts_metadata36("design:paramtypes", [
11347
+ _ts_param24(0, common.Inject(BYMAX_AUTH_OPTIONS)),
11348
+ _ts_param24(1, common.Inject(BYMAX_AUTH_USER_REPOSITORY)),
11349
+ _ts_param24(2, common.Optional()),
11350
+ _ts_param24(2, common.Inject(BYMAX_AUTH_PLATFORM_USER_REPOSITORY)),
11351
+ _ts_param24(3, common.Inject(AuthRedisService)),
11352
+ _ts_param24(4, common.Inject(TokenManagerService)),
11353
+ _ts_param24(5, common.Inject(MfaRecordService)),
11354
+ _ts_param24(6, common.Inject(MfaFlowLockoutService)),
11355
+ _ts_param24(7, common.Inject(exports.ReauthenticationService)),
11356
+ _ts_param24(8, common.Inject(exports.SessionService)),
11357
+ _ts_param24(9, common.Inject(BYMAX_AUTH_EMAIL_PROVIDER)),
11358
+ _ts_param24(10, common.Inject(BYMAX_AUTH_HOOKS)),
11359
+ _ts_metadata39("design:type", Function),
11360
+ _ts_metadata39("design:paramtypes", [
11315
11361
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
11316
11362
  typeof IUserRepository === "undefined" ? Object : IUserRepository,
11317
11363
  Object,
11318
11364
  typeof AuthRedisService === "undefined" ? Object : AuthRedisService,
11319
11365
  typeof TokenManagerService === "undefined" ? Object : TokenManagerService,
11320
- typeof exports.BruteForceService === "undefined" ? Object : exports.BruteForceService,
11321
- typeof PasswordService === "undefined" ? Object : PasswordService,
11366
+ typeof MfaRecordService === "undefined" ? Object : MfaRecordService,
11367
+ typeof MfaFlowLockoutService === "undefined" ? Object : MfaFlowLockoutService,
11368
+ typeof exports.ReauthenticationService === "undefined" ? Object : exports.ReauthenticationService,
11322
11369
  typeof exports.SessionService === "undefined" ? Object : exports.SessionService,
11323
11370
  typeof IEmailProvider === "undefined" ? Object : IEmailProvider,
11324
11371
  typeof IAuthHooks === "undefined" ? Object : IAuthHooks
@@ -11326,7 +11373,7 @@ exports.MfaService = _ts_decorate37([
11326
11373
  ], exports.MfaService);
11327
11374
 
11328
11375
  // src/server/controllers/mfa.controller.ts
11329
- function _ts_decorate38(decorators, target, key, desc) {
11376
+ function _ts_decorate41(decorators, target, key, desc) {
11330
11377
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11331
11378
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
11332
11379
  r = Reflect.decorate(decorators, target, key, desc);
@@ -11339,19 +11386,19 @@ function _ts_decorate38(decorators, target, key, desc) {
11339
11386
  }
11340
11387
  return c > 3 && r && Object.defineProperty(target, key, r), r;
11341
11388
  }
11342
- __name(_ts_decorate38, "_ts_decorate");
11343
- function _ts_metadata37(metadataKey, metadataValue) {
11389
+ __name(_ts_decorate41, "_ts_decorate");
11390
+ function _ts_metadata40(metadataKey, metadataValue) {
11344
11391
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
11345
11392
  return Reflect.metadata(metadataKey, metadataValue);
11346
11393
  }
11347
11394
  }
11348
- __name(_ts_metadata37, "_ts_metadata");
11349
- function _ts_param22(paramIndex, decorator) {
11395
+ __name(_ts_metadata40, "_ts_metadata");
11396
+ function _ts_param25(paramIndex, decorator) {
11350
11397
  return function(target, key) {
11351
11398
  decorator(target, key, paramIndex);
11352
11399
  };
11353
11400
  }
11354
- __name(_ts_param22, "_ts_param");
11401
+ __name(_ts_param25, "_ts_param");
11355
11402
  function isPlatformResult(result) {
11356
11403
  return "admin" in result;
11357
11404
  }
@@ -11540,111 +11587,111 @@ var MfaController = class {
11540
11587
  return this.mfaService.regenerateRecoveryCodes(user.sub, dto.code, ip, userAgent, "dashboard", user.tenantId);
11541
11588
  }
11542
11589
  };
11543
- _ts_decorate38([
11590
+ _ts_decorate41([
11544
11591
  common.UseGuards(exports.JwtAuthGuard, exports.UserStatusGuard),
11545
11592
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.mfaSetup),
11546
11593
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaSetup),
11547
11594
  RequestEncoding("when-body"),
11548
11595
  common.Post("setup"),
11549
- _ts_param22(0, CurrentUser()),
11550
- _ts_param22(1, common.Body()),
11551
- _ts_metadata37("design:type", Function),
11552
- _ts_metadata37("design:paramtypes", [
11596
+ _ts_param25(0, CurrentUser()),
11597
+ _ts_param25(1, common.Body()),
11598
+ _ts_metadata40("design:type", Function),
11599
+ _ts_metadata40("design:paramtypes", [
11553
11600
  typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
11554
11601
  typeof MfaSetupDto === "undefined" ? Object : MfaSetupDto
11555
11602
  ]),
11556
- _ts_metadata37("design:returntype", Promise)
11603
+ _ts_metadata40("design:returntype", Promise)
11557
11604
  ], MfaController.prototype, "setup", null);
11558
- _ts_decorate38([
11605
+ _ts_decorate41([
11559
11606
  common.UseGuards(exports.JwtAuthGuard, exports.UserStatusGuard),
11560
11607
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.mfaVerifyEnable),
11561
11608
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaVerifyEnable),
11562
11609
  common.HttpCode(common.HttpStatus.NO_CONTENT),
11563
11610
  common.Post("verify-enable"),
11564
- _ts_param22(0, CurrentUser()),
11565
- _ts_param22(1, common.Body()),
11566
- _ts_param22(2, common.Req()),
11567
- _ts_metadata37("design:type", Function),
11568
- _ts_metadata37("design:paramtypes", [
11611
+ _ts_param25(0, CurrentUser()),
11612
+ _ts_param25(1, common.Body()),
11613
+ _ts_param25(2, common.Req()),
11614
+ _ts_metadata40("design:type", Function),
11615
+ _ts_metadata40("design:paramtypes", [
11569
11616
  typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
11570
11617
  typeof MfaVerifyDto === "undefined" ? Object : MfaVerifyDto,
11571
11618
  typeof Request === "undefined" ? Object : Request
11572
11619
  ]),
11573
- _ts_metadata37("design:returntype", Promise)
11620
+ _ts_metadata40("design:returntype", Promise)
11574
11621
  ], MfaController.prototype, "verifyEnable", null);
11575
- _ts_decorate38([
11622
+ _ts_decorate41([
11576
11623
  Public(),
11577
11624
  SkipMfa(),
11578
11625
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.mfaChallenge),
11579
11626
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaChallenge),
11580
11627
  common.HttpCode(common.HttpStatus.OK),
11581
11628
  common.Post("challenge"),
11582
- _ts_param22(0, common.Body()),
11583
- _ts_param22(1, common.Req()),
11584
- _ts_param22(2, common.Res({
11629
+ _ts_param25(0, common.Body()),
11630
+ _ts_param25(1, common.Req()),
11631
+ _ts_param25(2, common.Res({
11585
11632
  passthrough: true
11586
11633
  })),
11587
- _ts_metadata37("design:type", Function),
11588
- _ts_metadata37("design:paramtypes", [
11634
+ _ts_metadata40("design:type", Function),
11635
+ _ts_metadata40("design:paramtypes", [
11589
11636
  typeof MfaChallengeDto === "undefined" ? Object : MfaChallengeDto,
11590
11637
  typeof Request === "undefined" ? Object : Request,
11591
11638
  typeof Response === "undefined" ? Object : Response
11592
11639
  ]),
11593
- _ts_metadata37("design:returntype", Promise)
11640
+ _ts_metadata40("design:returntype", Promise)
11594
11641
  ], MfaController.prototype, "challenge", null);
11595
- _ts_decorate38([
11642
+ _ts_decorate41([
11596
11643
  common.UseGuards(exports.JwtAuthGuard, exports.UserStatusGuard),
11597
11644
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.mfaDisable),
11598
11645
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaDisable),
11599
11646
  common.HttpCode(common.HttpStatus.NO_CONTENT),
11600
11647
  common.Post("disable"),
11601
- _ts_param22(0, CurrentUser()),
11602
- _ts_param22(1, common.Body()),
11603
- _ts_param22(2, common.Req()),
11604
- _ts_metadata37("design:type", Function),
11605
- _ts_metadata37("design:paramtypes", [
11648
+ _ts_param25(0, CurrentUser()),
11649
+ _ts_param25(1, common.Body()),
11650
+ _ts_param25(2, common.Req()),
11651
+ _ts_metadata40("design:type", Function),
11652
+ _ts_metadata40("design:paramtypes", [
11606
11653
  typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
11607
11654
  typeof MfaDisableDto === "undefined" ? Object : MfaDisableDto,
11608
11655
  typeof Request === "undefined" ? Object : Request
11609
11656
  ]),
11610
- _ts_metadata37("design:returntype", Promise)
11657
+ _ts_metadata40("design:returntype", Promise)
11611
11658
  ], MfaController.prototype, "disable", null);
11612
- _ts_decorate38([
11659
+ _ts_decorate41([
11613
11660
  common.UseGuards(exports.JwtAuthGuard, exports.UserStatusGuard),
11614
11661
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.mfaDisable),
11615
11662
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaDisable),
11616
11663
  common.HttpCode(common.HttpStatus.OK),
11617
11664
  common.Post("recovery-codes"),
11618
- _ts_param22(0, CurrentUser()),
11619
- _ts_param22(1, common.Body()),
11620
- _ts_param22(2, common.Req()),
11621
- _ts_metadata37("design:type", Function),
11622
- _ts_metadata37("design:paramtypes", [
11665
+ _ts_param25(0, CurrentUser()),
11666
+ _ts_param25(1, common.Body()),
11667
+ _ts_param25(2, common.Req()),
11668
+ _ts_metadata40("design:type", Function),
11669
+ _ts_metadata40("design:paramtypes", [
11623
11670
  typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
11624
11671
  typeof MfaRegenerateRecoveryCodesDto === "undefined" ? Object : MfaRegenerateRecoveryCodesDto,
11625
11672
  typeof Request === "undefined" ? Object : Request
11626
11673
  ]),
11627
- _ts_metadata37("design:returntype", Promise)
11674
+ _ts_metadata40("design:returntype", Promise)
11628
11675
  ], MfaController.prototype, "regenerateRecoveryCodes", null);
11629
- MfaController = _ts_decorate38([
11676
+ MfaController = _ts_decorate41([
11630
11677
  common.UseInterceptors(NoStoreInterceptor),
11631
11678
  common.Controller("mfa"),
11632
11679
  common.UseGuards(exports.RequestEncodingGuard, exports.TrustedOriginGuard, exports.AuthRateLimitGuard),
11633
11680
  common.UsePipes(createAuthValidationPipe({
11634
11681
  forbidUnknownValues: true
11635
11682
  })),
11636
- _ts_param22(0, common.Inject(exports.MfaService)),
11637
- _ts_param22(1, common.Inject(exports.TokenDeliveryService)),
11638
- _ts_param22(2, common.Inject(BYMAX_AUTH_OPTIONS)),
11639
- _ts_metadata37("design:type", Function),
11640
- _ts_metadata37("design:paramtypes", [
11683
+ _ts_param25(0, common.Inject(exports.MfaService)),
11684
+ _ts_param25(1, common.Inject(exports.TokenDeliveryService)),
11685
+ _ts_param25(2, common.Inject(BYMAX_AUTH_OPTIONS)),
11686
+ _ts_metadata40("design:type", Function),
11687
+ _ts_metadata40("design:paramtypes", [
11641
11688
  typeof exports.MfaService === "undefined" ? Object : exports.MfaService,
11642
11689
  typeof exports.TokenDeliveryService === "undefined" ? Object : exports.TokenDeliveryService,
11643
11690
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
11644
11691
  ])
11645
11692
  ], MfaController);
11646
11693
  var Authenticated = /* @__PURE__ */ __name(() => common.SetMetadata(IS_PUBLIC_KEY, false), "Authenticated");
11647
- function _ts_decorate39(decorators, target, key, desc) {
11694
+ function _ts_decorate42(decorators, target, key, desc) {
11648
11695
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11649
11696
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
11650
11697
  r = Reflect.decorate(decorators, target, key, desc);
@@ -11657,13 +11704,13 @@ function _ts_decorate39(decorators, target, key, desc) {
11657
11704
  }
11658
11705
  return c > 3 && r && Object.defineProperty(target, key, r), r;
11659
11706
  }
11660
- __name(_ts_decorate39, "_ts_decorate");
11661
- function _ts_metadata38(metadataKey, metadataValue) {
11707
+ __name(_ts_decorate42, "_ts_decorate");
11708
+ function _ts_metadata41(metadataKey, metadataValue) {
11662
11709
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
11663
11710
  return Reflect.metadata(metadataKey, metadataValue);
11664
11711
  }
11665
11712
  }
11666
- __name(_ts_metadata38, "_ts_metadata");
11713
+ __name(_ts_metadata41, "_ts_metadata");
11667
11714
  var ChangePasswordDto = class {
11668
11715
  static {
11669
11716
  __name(this, "ChangePasswordDto");
@@ -11716,26 +11763,26 @@ var ChangePasswordDto = class {
11716
11763
  */
11717
11764
  refreshToken;
11718
11765
  };
11719
- _ts_decorate39([
11766
+ _ts_decorate42([
11720
11767
  classValidator.IsString(),
11721
11768
  classValidator.MinLength(1),
11722
11769
  classValidator.MaxLength(128),
11723
- _ts_metadata38("design:type", String)
11770
+ _ts_metadata41("design:type", String)
11724
11771
  ], ChangePasswordDto.prototype, "currentPassword", void 0);
11725
- _ts_decorate39([
11772
+ _ts_decorate42([
11726
11773
  classValidator.IsString(),
11727
11774
  classValidator.MinLength(8),
11728
11775
  classValidator.MaxLength(128),
11729
- _ts_metadata38("design:type", String)
11776
+ _ts_metadata41("design:type", String)
11730
11777
  ], ChangePasswordDto.prototype, "newPassword", void 0);
11731
- _ts_decorate39([
11778
+ _ts_decorate42([
11732
11779
  classValidator.IsOptional(),
11733
11780
  classValidator.IsString(),
11734
11781
  classValidator.IsNotEmpty(),
11735
11782
  classValidator.MaxLength(2048),
11736
- _ts_metadata38("design:type", String)
11783
+ _ts_metadata41("design:type", String)
11737
11784
  ], ChangePasswordDto.prototype, "refreshToken", void 0);
11738
- function _ts_decorate40(decorators, target, key, desc) {
11785
+ function _ts_decorate43(decorators, target, key, desc) {
11739
11786
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11740
11787
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
11741
11788
  r = Reflect.decorate(decorators, target, key, desc);
@@ -11748,13 +11795,13 @@ function _ts_decorate40(decorators, target, key, desc) {
11748
11795
  }
11749
11796
  return c > 3 && r && Object.defineProperty(target, key, r), r;
11750
11797
  }
11751
- __name(_ts_decorate40, "_ts_decorate");
11752
- function _ts_metadata39(metadataKey, metadataValue) {
11798
+ __name(_ts_decorate43, "_ts_decorate");
11799
+ function _ts_metadata42(metadataKey, metadataValue) {
11753
11800
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
11754
11801
  return Reflect.metadata(metadataKey, metadataValue);
11755
11802
  }
11756
11803
  }
11757
- __name(_ts_metadata39, "_ts_metadata");
11804
+ __name(_ts_metadata42, "_ts_metadata");
11758
11805
  var ForgotPasswordDto = class {
11759
11806
  static {
11760
11807
  __name(this, "ForgotPasswordDto");
@@ -11770,13 +11817,13 @@ var ForgotPasswordDto = class {
11770
11817
  */
11771
11818
  tenantId;
11772
11819
  };
11773
- _ts_decorate40([
11820
+ _ts_decorate43([
11774
11821
  classTransformer.Transform(({ value }) => typeof value === "string" ? value.trim().toLowerCase() : value),
11775
11822
  classValidator.IsEmail(),
11776
11823
  classValidator.MaxLength(255),
11777
- _ts_metadata39("design:type", String)
11824
+ _ts_metadata42("design:type", String)
11778
11825
  ], ForgotPasswordDto.prototype, "email", void 0);
11779
- _ts_decorate40([
11826
+ _ts_decorate43([
11780
11827
  classValidator.IsOptional(),
11781
11828
  classValidator.IsString(),
11782
11829
  classValidator.IsNotEmpty(),
@@ -11784,9 +11831,9 @@ _ts_decorate40([
11784
11831
  classValidator.Matches(NO_CONTROL_CHARACTERS, {
11785
11832
  message: "tenantId must not contain control characters"
11786
11833
  }),
11787
- _ts_metadata39("design:type", String)
11834
+ _ts_metadata42("design:type", String)
11788
11835
  ], ForgotPasswordDto.prototype, "tenantId", void 0);
11789
- function _ts_decorate41(decorators, target, key, desc) {
11836
+ function _ts_decorate44(decorators, target, key, desc) {
11790
11837
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11791
11838
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
11792
11839
  r = Reflect.decorate(decorators, target, key, desc);
@@ -11799,13 +11846,13 @@ function _ts_decorate41(decorators, target, key, desc) {
11799
11846
  }
11800
11847
  return c > 3 && r && Object.defineProperty(target, key, r), r;
11801
11848
  }
11802
- __name(_ts_decorate41, "_ts_decorate");
11803
- function _ts_metadata40(metadataKey, metadataValue) {
11849
+ __name(_ts_decorate44, "_ts_decorate");
11850
+ function _ts_metadata43(metadataKey, metadataValue) {
11804
11851
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
11805
11852
  return Reflect.metadata(metadataKey, metadataValue);
11806
11853
  }
11807
11854
  }
11808
- __name(_ts_metadata40, "_ts_metadata");
11855
+ __name(_ts_metadata43, "_ts_metadata");
11809
11856
  var ResendOtpDto = class {
11810
11857
  static {
11811
11858
  __name(this, "ResendOtpDto");
@@ -11820,13 +11867,13 @@ var ResendOtpDto = class {
11820
11867
  */
11821
11868
  tenantId;
11822
11869
  };
11823
- _ts_decorate41([
11870
+ _ts_decorate44([
11824
11871
  classTransformer.Transform(({ value }) => typeof value === "string" ? value.trim().toLowerCase() : value),
11825
11872
  classValidator.IsEmail(),
11826
11873
  classValidator.MaxLength(255),
11827
- _ts_metadata40("design:type", String)
11874
+ _ts_metadata43("design:type", String)
11828
11875
  ], ResendOtpDto.prototype, "email", void 0);
11829
- _ts_decorate41([
11876
+ _ts_decorate44([
11830
11877
  classValidator.IsOptional(),
11831
11878
  classValidator.IsString(),
11832
11879
  classValidator.IsNotEmpty(),
@@ -11834,9 +11881,9 @@ _ts_decorate41([
11834
11881
  classValidator.Matches(NO_CONTROL_CHARACTERS, {
11835
11882
  message: "tenantId must not contain control characters"
11836
11883
  }),
11837
- _ts_metadata40("design:type", String)
11884
+ _ts_metadata43("design:type", String)
11838
11885
  ], ResendOtpDto.prototype, "tenantId", void 0);
11839
- function _ts_decorate42(decorators, target, key, desc) {
11886
+ function _ts_decorate45(decorators, target, key, desc) {
11840
11887
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11841
11888
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
11842
11889
  r = Reflect.decorate(decorators, target, key, desc);
@@ -11849,13 +11896,13 @@ function _ts_decorate42(decorators, target, key, desc) {
11849
11896
  }
11850
11897
  return c > 3 && r && Object.defineProperty(target, key, r), r;
11851
11898
  }
11852
- __name(_ts_decorate42, "_ts_decorate");
11853
- function _ts_metadata41(metadataKey, metadataValue) {
11899
+ __name(_ts_decorate45, "_ts_decorate");
11900
+ function _ts_metadata44(metadataKey, metadataValue) {
11854
11901
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
11855
11902
  return Reflect.metadata(metadataKey, metadataValue);
11856
11903
  }
11857
11904
  }
11858
- __name(_ts_metadata41, "_ts_metadata");
11905
+ __name(_ts_metadata44, "_ts_metadata");
11859
11906
  var ResetPasswordDto = class {
11860
11907
  static {
11861
11908
  __name(this, "ResetPasswordDto");
@@ -11902,38 +11949,38 @@ var ResetPasswordDto = class {
11902
11949
  */
11903
11950
  tenantId;
11904
11951
  };
11905
- _ts_decorate42([
11952
+ _ts_decorate45([
11906
11953
  classTransformer.Transform(({ value }) => typeof value === "string" ? value.trim().toLowerCase() : value),
11907
11954
  classValidator.IsEmail(),
11908
11955
  classValidator.MaxLength(255),
11909
- _ts_metadata41("design:type", String)
11956
+ _ts_metadata44("design:type", String)
11910
11957
  ], ResetPasswordDto.prototype, "email", void 0);
11911
- _ts_decorate42([
11958
+ _ts_decorate45([
11912
11959
  classValidator.IsString(),
11913
11960
  classValidator.MinLength(8),
11914
11961
  classValidator.MaxLength(128),
11915
- _ts_metadata41("design:type", String)
11962
+ _ts_metadata44("design:type", String)
11916
11963
  ], ResetPasswordDto.prototype, "newPassword", void 0);
11917
- _ts_decorate42([
11964
+ _ts_decorate45([
11918
11965
  classValidator.IsOptional(),
11919
11966
  classValidator.IsString(),
11920
11967
  classValidator.IsNotEmpty(),
11921
11968
  classValidator.MaxLength(2048),
11922
- _ts_metadata41("design:type", String)
11969
+ _ts_metadata44("design:type", String)
11923
11970
  ], ResetPasswordDto.prototype, "token", void 0);
11924
- _ts_decorate42([
11971
+ _ts_decorate45([
11925
11972
  classValidator.IsOptional(),
11926
11973
  classValidator.IsString(),
11927
11974
  classValidator.Length(4, 8),
11928
- _ts_metadata41("design:type", String)
11975
+ _ts_metadata44("design:type", String)
11929
11976
  ], ResetPasswordDto.prototype, "otp", void 0);
11930
- _ts_decorate42([
11977
+ _ts_decorate45([
11931
11978
  classValidator.IsOptional(),
11932
11979
  classValidator.IsString(),
11933
11980
  classValidator.Length(64, 64),
11934
- _ts_metadata41("design:type", String)
11981
+ _ts_metadata44("design:type", String)
11935
11982
  ], ResetPasswordDto.prototype, "verifiedToken", void 0);
11936
- _ts_decorate42([
11983
+ _ts_decorate45([
11937
11984
  classValidator.IsOptional(),
11938
11985
  classValidator.IsString(),
11939
11986
  classValidator.IsNotEmpty(),
@@ -11941,9 +11988,9 @@ _ts_decorate42([
11941
11988
  classValidator.Matches(NO_CONTROL_CHARACTERS, {
11942
11989
  message: "tenantId must not contain control characters"
11943
11990
  }),
11944
- _ts_metadata41("design:type", String)
11991
+ _ts_metadata44("design:type", String)
11945
11992
  ], ResetPasswordDto.prototype, "tenantId", void 0);
11946
- function _ts_decorate43(decorators, target, key, desc) {
11993
+ function _ts_decorate46(decorators, target, key, desc) {
11947
11994
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11948
11995
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
11949
11996
  r = Reflect.decorate(decorators, target, key, desc);
@@ -11956,13 +12003,13 @@ function _ts_decorate43(decorators, target, key, desc) {
11956
12003
  }
11957
12004
  return c > 3 && r && Object.defineProperty(target, key, r), r;
11958
12005
  }
11959
- __name(_ts_decorate43, "_ts_decorate");
11960
- function _ts_metadata42(metadataKey, metadataValue) {
12006
+ __name(_ts_decorate46, "_ts_decorate");
12007
+ function _ts_metadata45(metadataKey, metadataValue) {
11961
12008
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
11962
12009
  return Reflect.metadata(metadataKey, metadataValue);
11963
12010
  }
11964
12011
  }
11965
- __name(_ts_metadata42, "_ts_metadata");
12012
+ __name(_ts_metadata45, "_ts_metadata");
11966
12013
  var VerifyOtpDto = class {
11967
12014
  static {
11968
12015
  __name(this, "VerifyOtpDto");
@@ -11984,18 +12031,18 @@ var VerifyOtpDto = class {
11984
12031
  */
11985
12032
  tenantId;
11986
12033
  };
11987
- _ts_decorate43([
12034
+ _ts_decorate46([
11988
12035
  classTransformer.Transform(({ value }) => typeof value === "string" ? value.trim().toLowerCase() : value),
11989
12036
  classValidator.IsEmail(),
11990
12037
  classValidator.MaxLength(255),
11991
- _ts_metadata42("design:type", String)
12038
+ _ts_metadata45("design:type", String)
11992
12039
  ], VerifyOtpDto.prototype, "email", void 0);
11993
- _ts_decorate43([
12040
+ _ts_decorate46([
11994
12041
  classValidator.IsString(),
11995
12042
  classValidator.Length(4, 8),
11996
- _ts_metadata42("design:type", String)
12043
+ _ts_metadata45("design:type", String)
11997
12044
  ], VerifyOtpDto.prototype, "otp", void 0);
11998
- _ts_decorate43([
12045
+ _ts_decorate46([
11999
12046
  classValidator.IsOptional(),
12000
12047
  classValidator.IsString(),
12001
12048
  classValidator.IsNotEmpty(),
@@ -12003,7 +12050,7 @@ _ts_decorate43([
12003
12050
  classValidator.Matches(NO_CONTROL_CHARACTERS, {
12004
12051
  message: "tenantId must not contain control characters"
12005
12052
  }),
12006
- _ts_metadata42("design:type", String)
12053
+ _ts_metadata45("design:type", String)
12007
12054
  ], VerifyOtpDto.prototype, "tenantId", void 0);
12008
12055
 
12009
12056
  // src/server/utils/answer-reset-request.ts
@@ -12050,7 +12097,7 @@ async function answerResetRequest(deps, request) {
12050
12097
  __name(answerResetRequest, "answerResetRequest");
12051
12098
 
12052
12099
  // src/server/services/password-reset.service.ts
12053
- function _ts_decorate44(decorators, target, key, desc) {
12100
+ function _ts_decorate47(decorators, target, key, desc) {
12054
12101
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12055
12102
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
12056
12103
  r = Reflect.decorate(decorators, target, key, desc);
@@ -12063,19 +12110,19 @@ function _ts_decorate44(decorators, target, key, desc) {
12063
12110
  }
12064
12111
  return c > 3 && r && Object.defineProperty(target, key, r), r;
12065
12112
  }
12066
- __name(_ts_decorate44, "_ts_decorate");
12067
- function _ts_metadata43(metadataKey, metadataValue) {
12113
+ __name(_ts_decorate47, "_ts_decorate");
12114
+ function _ts_metadata46(metadataKey, metadataValue) {
12068
12115
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
12069
12116
  return Reflect.metadata(metadataKey, metadataValue);
12070
12117
  }
12071
12118
  }
12072
- __name(_ts_metadata43, "_ts_metadata");
12073
- function _ts_param23(paramIndex, decorator) {
12119
+ __name(_ts_metadata46, "_ts_metadata");
12120
+ function _ts_param26(paramIndex, decorator) {
12074
12121
  return function(target, key) {
12075
12122
  decorator(target, key, paramIndex);
12076
12123
  };
12077
12124
  }
12078
- __name(_ts_param23, "_ts_param");
12125
+ __name(_ts_param26, "_ts_param");
12079
12126
  var ANTI_ENUM_MIN_MS2 = 300;
12080
12127
  var VERIFIED_TOKEN_TTL_SECONDS = 300;
12081
12128
  var PASSWORD_RESET_PURPOSE = "password_reset";
@@ -12541,7 +12588,7 @@ exports.PasswordResetService = class _PasswordResetService {
12541
12588
  if (user) {
12542
12589
  await this.notifyPasswordChanged(user);
12543
12590
  if (this.hooks?.afterPasswordReset) {
12544
- void Promise.resolve(this.hooks.afterPasswordReset(toSafeUser3(user), {
12591
+ void Promise.resolve(this.hooks.afterPasswordReset(toSafeUser4(user), {
12545
12592
  ...createEmptyHookContext(),
12546
12593
  plane: "dashboard"
12547
12594
  })).catch((err) => {
@@ -12669,21 +12716,21 @@ exports.PasswordResetService = class _PasswordResetService {
12669
12716
  };
12670
12717
  }
12671
12718
  };
12672
- exports.PasswordResetService = _ts_decorate44([
12719
+ exports.PasswordResetService = _ts_decorate47([
12673
12720
  common.Injectable(),
12674
- _ts_param23(0, common.Inject(BYMAX_AUTH_OPTIONS)),
12675
- _ts_param23(1, common.Inject(BYMAX_AUTH_USER_REPOSITORY)),
12676
- _ts_param23(2, common.Inject(BYMAX_AUTH_EMAIL_PROVIDER)),
12677
- _ts_param23(2, common.Optional()),
12678
- _ts_param23(3, common.Inject(BYMAX_AUTH_HOOKS)),
12679
- _ts_param23(3, common.Optional()),
12680
- _ts_param23(4, common.Inject(exports.OtpService)),
12681
- _ts_param23(5, common.Inject(PasswordService)),
12682
- _ts_param23(6, common.Inject(AuthRedisService)),
12683
- _ts_param23(7, common.Inject(exports.SessionService)),
12684
- _ts_param23(8, common.Inject(exports.BruteForceService)),
12685
- _ts_metadata43("design:type", Function),
12686
- _ts_metadata43("design:paramtypes", [
12721
+ _ts_param26(0, common.Inject(BYMAX_AUTH_OPTIONS)),
12722
+ _ts_param26(1, common.Inject(BYMAX_AUTH_USER_REPOSITORY)),
12723
+ _ts_param26(2, common.Inject(BYMAX_AUTH_EMAIL_PROVIDER)),
12724
+ _ts_param26(2, common.Optional()),
12725
+ _ts_param26(3, common.Inject(BYMAX_AUTH_HOOKS)),
12726
+ _ts_param26(3, common.Optional()),
12727
+ _ts_param26(4, common.Inject(exports.OtpService)),
12728
+ _ts_param26(5, common.Inject(PasswordService)),
12729
+ _ts_param26(6, common.Inject(AuthRedisService)),
12730
+ _ts_param26(7, common.Inject(exports.SessionService)),
12731
+ _ts_param26(8, common.Inject(exports.BruteForceService)),
12732
+ _ts_metadata46("design:type", Function),
12733
+ _ts_metadata46("design:paramtypes", [
12687
12734
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
12688
12735
  typeof IUserRepository === "undefined" ? Object : IUserRepository,
12689
12736
  Object,
@@ -12695,14 +12742,14 @@ exports.PasswordResetService = _ts_decorate44([
12695
12742
  typeof exports.BruteForceService === "undefined" ? Object : exports.BruteForceService
12696
12743
  ])
12697
12744
  ], exports.PasswordResetService);
12698
- function toSafeUser3(user) {
12745
+ function toSafeUser4(user) {
12699
12746
  const { passwordHash: _passwordHash, mfaSecret: _mfaSecret, mfaRecoveryCodes: _mfaRecoveryCodes, ...safe } = user;
12700
12747
  return safe;
12701
12748
  }
12702
- __name(toSafeUser3, "toSafeUser");
12749
+ __name(toSafeUser4, "toSafeUser");
12703
12750
 
12704
12751
  // src/server/controllers/password-reset.controller.ts
12705
- function _ts_decorate45(decorators, target, key, desc) {
12752
+ function _ts_decorate48(decorators, target, key, desc) {
12706
12753
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12707
12754
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
12708
12755
  r = Reflect.decorate(decorators, target, key, desc);
@@ -12715,19 +12762,19 @@ function _ts_decorate45(decorators, target, key, desc) {
12715
12762
  }
12716
12763
  return c > 3 && r && Object.defineProperty(target, key, r), r;
12717
12764
  }
12718
- __name(_ts_decorate45, "_ts_decorate");
12719
- function _ts_metadata44(metadataKey, metadataValue) {
12765
+ __name(_ts_decorate48, "_ts_decorate");
12766
+ function _ts_metadata47(metadataKey, metadataValue) {
12720
12767
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
12721
12768
  return Reflect.metadata(metadataKey, metadataValue);
12722
12769
  }
12723
12770
  }
12724
- __name(_ts_metadata44, "_ts_metadata");
12725
- function _ts_param24(paramIndex, decorator) {
12771
+ __name(_ts_metadata47, "_ts_metadata");
12772
+ function _ts_param27(paramIndex, decorator) {
12726
12773
  return function(target, key) {
12727
12774
  decorator(target, key, paramIndex);
12728
12775
  };
12729
12776
  }
12730
- __name(_ts_param24, "_ts_param");
12777
+ __name(_ts_param27, "_ts_param");
12731
12778
  var PasswordResetController = class {
12732
12779
  static {
12733
12780
  __name(this, "PasswordResetController");
@@ -12846,95 +12893,95 @@ var PasswordResetController = class {
12846
12893
  return {};
12847
12894
  }
12848
12895
  };
12849
- _ts_decorate45([
12896
+ _ts_decorate48([
12850
12897
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.forgotPassword),
12851
12898
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.forgotPassword),
12852
12899
  common.HttpCode(common.HttpStatus.OK),
12853
12900
  common.Post("forgot-password"),
12854
- _ts_param24(0, common.Body()),
12855
- _ts_param24(1, common.Req()),
12856
- _ts_metadata44("design:type", Function),
12857
- _ts_metadata44("design:paramtypes", [
12901
+ _ts_param27(0, common.Body()),
12902
+ _ts_param27(1, common.Req()),
12903
+ _ts_metadata47("design:type", Function),
12904
+ _ts_metadata47("design:paramtypes", [
12858
12905
  typeof ForgotPasswordDto === "undefined" ? Object : ForgotPasswordDto,
12859
12906
  typeof Request === "undefined" ? Object : Request
12860
12907
  ]),
12861
- _ts_metadata44("design:returntype", Promise)
12908
+ _ts_metadata47("design:returntype", Promise)
12862
12909
  ], PasswordResetController.prototype, "forgotPassword", null);
12863
- _ts_decorate45([
12910
+ _ts_decorate48([
12864
12911
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.resetPassword),
12865
12912
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.resetPassword),
12866
12913
  common.HttpCode(common.HttpStatus.NO_CONTENT),
12867
12914
  common.Post("reset-password"),
12868
- _ts_param24(0, common.Body()),
12869
- _ts_param24(1, common.Req()),
12870
- _ts_metadata44("design:type", Function),
12871
- _ts_metadata44("design:paramtypes", [
12915
+ _ts_param27(0, common.Body()),
12916
+ _ts_param27(1, common.Req()),
12917
+ _ts_metadata47("design:type", Function),
12918
+ _ts_metadata47("design:paramtypes", [
12872
12919
  typeof ResetPasswordDto === "undefined" ? Object : ResetPasswordDto,
12873
12920
  typeof Request === "undefined" ? Object : Request
12874
12921
  ]),
12875
- _ts_metadata44("design:returntype", Promise)
12922
+ _ts_metadata47("design:returntype", Promise)
12876
12923
  ], PasswordResetController.prototype, "resetPassword", null);
12877
- _ts_decorate45([
12924
+ _ts_decorate48([
12878
12925
  Authenticated(),
12879
12926
  common.UseGuards(exports.JwtAuthGuard, exports.UserStatusGuard),
12880
12927
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.changePassword),
12881
12928
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.changePassword),
12882
12929
  common.HttpCode(common.HttpStatus.NO_CONTENT),
12883
12930
  common.Post("change"),
12884
- _ts_param24(0, CurrentUser()),
12885
- _ts_param24(1, common.Body()),
12886
- _ts_param24(2, common.Req()),
12887
- _ts_metadata44("design:type", Function),
12888
- _ts_metadata44("design:paramtypes", [
12931
+ _ts_param27(0, CurrentUser()),
12932
+ _ts_param27(1, common.Body()),
12933
+ _ts_param27(2, common.Req()),
12934
+ _ts_metadata47("design:type", Function),
12935
+ _ts_metadata47("design:paramtypes", [
12889
12936
  typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
12890
12937
  typeof ChangePasswordDto === "undefined" ? Object : ChangePasswordDto,
12891
12938
  typeof Request === "undefined" ? Object : Request
12892
12939
  ]),
12893
- _ts_metadata44("design:returntype", Promise)
12940
+ _ts_metadata47("design:returntype", Promise)
12894
12941
  ], PasswordResetController.prototype, "changePassword", null);
12895
- _ts_decorate45([
12942
+ _ts_decorate48([
12896
12943
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.verifyOtp),
12897
12944
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.verifyOtp),
12898
12945
  common.HttpCode(common.HttpStatus.OK),
12899
12946
  common.Post("verify-otp"),
12900
- _ts_param24(0, common.Body()),
12901
- _ts_param24(1, common.Req()),
12902
- _ts_metadata44("design:type", Function),
12903
- _ts_metadata44("design:paramtypes", [
12947
+ _ts_param27(0, common.Body()),
12948
+ _ts_param27(1, common.Req()),
12949
+ _ts_metadata47("design:type", Function),
12950
+ _ts_metadata47("design:paramtypes", [
12904
12951
  typeof VerifyOtpDto === "undefined" ? Object : VerifyOtpDto,
12905
12952
  typeof Request === "undefined" ? Object : Request
12906
12953
  ]),
12907
- _ts_metadata44("design:returntype", Promise)
12954
+ _ts_metadata47("design:returntype", Promise)
12908
12955
  ], PasswordResetController.prototype, "verifyOtp", null);
12909
- _ts_decorate45([
12956
+ _ts_decorate48([
12910
12957
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.resendPasswordOtp),
12911
12958
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.resendPasswordOtp),
12912
12959
  common.HttpCode(common.HttpStatus.OK),
12913
12960
  common.Post("resend-otp"),
12914
- _ts_param24(0, common.Body()),
12915
- _ts_param24(1, common.Req()),
12916
- _ts_metadata44("design:type", Function),
12917
- _ts_metadata44("design:paramtypes", [
12961
+ _ts_param27(0, common.Body()),
12962
+ _ts_param27(1, common.Req()),
12963
+ _ts_metadata47("design:type", Function),
12964
+ _ts_metadata47("design:paramtypes", [
12918
12965
  typeof ResendOtpDto === "undefined" ? Object : ResendOtpDto,
12919
12966
  typeof Request === "undefined" ? Object : Request
12920
12967
  ]),
12921
- _ts_metadata44("design:returntype", Promise)
12968
+ _ts_metadata47("design:returntype", Promise)
12922
12969
  ], PasswordResetController.prototype, "resendOtp", null);
12923
- PasswordResetController = _ts_decorate45([
12970
+ PasswordResetController = _ts_decorate48([
12924
12971
  Public(),
12925
12972
  common.UseInterceptors(NoStoreInterceptor),
12926
12973
  common.Controller("password"),
12927
12974
  common.UseGuards(exports.RequestEncodingGuard, exports.TrustedOriginGuard, exports.AuthRateLimitGuard),
12928
12975
  common.UsePipes(createAuthValidationPipe()),
12929
- _ts_param24(0, common.Inject(exports.PasswordResetService)),
12930
- _ts_param24(1, common.Inject(exports.TokenDeliveryService)),
12931
- _ts_metadata44("design:type", Function),
12932
- _ts_metadata44("design:paramtypes", [
12976
+ _ts_param27(0, common.Inject(exports.PasswordResetService)),
12977
+ _ts_param27(1, common.Inject(exports.TokenDeliveryService)),
12978
+ _ts_metadata47("design:type", Function),
12979
+ _ts_metadata47("design:paramtypes", [
12933
12980
  typeof exports.PasswordResetService === "undefined" ? Object : exports.PasswordResetService,
12934
12981
  typeof exports.TokenDeliveryService === "undefined" ? Object : exports.TokenDeliveryService
12935
12982
  ])
12936
12983
  ], PasswordResetController);
12937
- function _ts_decorate46(decorators, target, key, desc) {
12984
+ function _ts_decorate49(decorators, target, key, desc) {
12938
12985
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12939
12986
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
12940
12987
  r = Reflect.decorate(decorators, target, key, desc);
@@ -12947,13 +12994,13 @@ function _ts_decorate46(decorators, target, key, desc) {
12947
12994
  }
12948
12995
  return c > 3 && r && Object.defineProperty(target, key, r), r;
12949
12996
  }
12950
- __name(_ts_decorate46, "_ts_decorate");
12951
- function _ts_metadata45(metadataKey, metadataValue) {
12997
+ __name(_ts_decorate49, "_ts_decorate");
12998
+ function _ts_metadata48(metadataKey, metadataValue) {
12952
12999
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
12953
13000
  return Reflect.metadata(metadataKey, metadataValue);
12954
13001
  }
12955
13002
  }
12956
- __name(_ts_metadata45, "_ts_metadata");
13003
+ __name(_ts_metadata48, "_ts_metadata");
12957
13004
  var PlatformLoginDto = class {
12958
13005
  static {
12959
13006
  __name(this, "PlatformLoginDto");
@@ -12981,14 +13028,14 @@ var PlatformLoginDto = class {
12981
13028
  */
12982
13029
  password;
12983
13030
  };
12984
- _ts_decorate46([
13031
+ _ts_decorate49([
12985
13032
  classTransformer.Transform(({ value }) => typeof value === "string" ? value.trim().toLowerCase() : value),
12986
13033
  classValidator.IsEmail(),
12987
13034
  classValidator.IsNotEmpty(),
12988
13035
  classValidator.MaxLength(255),
12989
- _ts_metadata45("design:type", String)
13036
+ _ts_metadata48("design:type", String)
12990
13037
  ], PlatformLoginDto.prototype, "email", void 0);
12991
- _ts_decorate46([
13038
+ _ts_decorate49([
12992
13039
  classValidator.IsString(),
12993
13040
  classValidator.IsNotEmpty(),
12994
13041
  classValidator.Matches(/\S/, {
@@ -12996,9 +13043,9 @@ _ts_decorate46([
12996
13043
  }),
12997
13044
  classValidator.MinLength(1),
12998
13045
  classValidator.MaxLength(128),
12999
- _ts_metadata45("design:type", String)
13046
+ _ts_metadata48("design:type", String)
13000
13047
  ], PlatformLoginDto.prototype, "password", void 0);
13001
- function _ts_decorate47(decorators, target, key, desc) {
13048
+ function _ts_decorate50(decorators, target, key, desc) {
13002
13049
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
13003
13050
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
13004
13051
  r = Reflect.decorate(decorators, target, key, desc);
@@ -13011,19 +13058,19 @@ function _ts_decorate47(decorators, target, key, desc) {
13011
13058
  }
13012
13059
  return c > 3 && r && Object.defineProperty(target, key, r), r;
13013
13060
  }
13014
- __name(_ts_decorate47, "_ts_decorate");
13015
- function _ts_metadata46(metadataKey, metadataValue) {
13061
+ __name(_ts_decorate50, "_ts_decorate");
13062
+ function _ts_metadata49(metadataKey, metadataValue) {
13016
13063
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
13017
13064
  return Reflect.metadata(metadataKey, metadataValue);
13018
13065
  }
13019
13066
  }
13020
- __name(_ts_metadata46, "_ts_metadata");
13021
- function _ts_param25(paramIndex, decorator) {
13067
+ __name(_ts_metadata49, "_ts_metadata");
13068
+ function _ts_param28(paramIndex, decorator) {
13022
13069
  return function(target, key) {
13023
13070
  decorator(target, key, paramIndex);
13024
13071
  };
13025
13072
  }
13026
- __name(_ts_param25, "_ts_param");
13073
+ __name(_ts_param28, "_ts_param");
13027
13074
  exports.JwtPlatformGuard = class JwtPlatformGuard {
13028
13075
  static {
13029
13076
  __name(this, "JwtPlatformGuard");
@@ -13069,15 +13116,15 @@ exports.JwtPlatformGuard = class JwtPlatformGuard {
13069
13116
  return true;
13070
13117
  }
13071
13118
  };
13072
- exports.JwtPlatformGuard = _ts_decorate47([
13119
+ exports.JwtPlatformGuard = _ts_decorate50([
13073
13120
  common.Injectable(),
13074
- _ts_param25(0, common.Inject(jwt.JwtService)),
13075
- _ts_param25(1, common.Inject(exports.TokenDeliveryService)),
13076
- _ts_param25(2, common.Inject(exports.AuthRevocationService)),
13077
- _ts_param25(3, common.Inject(core.Reflector)),
13078
- _ts_param25(4, common.Inject(BYMAX_AUTH_OPTIONS)),
13079
- _ts_metadata46("design:type", Function),
13080
- _ts_metadata46("design:paramtypes", [
13121
+ _ts_param28(0, common.Inject(jwt.JwtService)),
13122
+ _ts_param28(1, common.Inject(exports.TokenDeliveryService)),
13123
+ _ts_param28(2, common.Inject(exports.AuthRevocationService)),
13124
+ _ts_param28(3, common.Inject(core.Reflector)),
13125
+ _ts_param28(4, common.Inject(BYMAX_AUTH_OPTIONS)),
13126
+ _ts_metadata49("design:type", Function),
13127
+ _ts_metadata49("design:paramtypes", [
13081
13128
  typeof jwt.JwtService === "undefined" ? Object : jwt.JwtService,
13082
13129
  typeof exports.TokenDeliveryService === "undefined" ? Object : exports.TokenDeliveryService,
13083
13130
  typeof exports.AuthRevocationService === "undefined" ? Object : exports.AuthRevocationService,
@@ -13085,7 +13132,7 @@ exports.JwtPlatformGuard = _ts_decorate47([
13085
13132
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
13086
13133
  ])
13087
13134
  ], exports.JwtPlatformGuard);
13088
- function _ts_decorate48(decorators, target, key, desc) {
13135
+ function _ts_decorate51(decorators, target, key, desc) {
13089
13136
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
13090
13137
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
13091
13138
  r = Reflect.decorate(decorators, target, key, desc);
@@ -13098,19 +13145,19 @@ function _ts_decorate48(decorators, target, key, desc) {
13098
13145
  }
13099
13146
  return c > 3 && r && Object.defineProperty(target, key, r), r;
13100
13147
  }
13101
- __name(_ts_decorate48, "_ts_decorate");
13102
- function _ts_metadata47(metadataKey, metadataValue) {
13148
+ __name(_ts_decorate51, "_ts_decorate");
13149
+ function _ts_metadata50(metadataKey, metadataValue) {
13103
13150
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
13104
13151
  return Reflect.metadata(metadataKey, metadataValue);
13105
13152
  }
13106
13153
  }
13107
- __name(_ts_metadata47, "_ts_metadata");
13108
- function _ts_param26(paramIndex, decorator) {
13154
+ __name(_ts_metadata50, "_ts_metadata");
13155
+ function _ts_param29(paramIndex, decorator) {
13109
13156
  return function(target, key) {
13110
13157
  decorator(target, key, paramIndex);
13111
13158
  };
13112
13159
  }
13113
- __name(_ts_param26, "_ts_param");
13160
+ __name(_ts_param29, "_ts_param");
13114
13161
  exports.PlatformAuthService = class _PlatformAuthService {
13115
13162
  static {
13116
13163
  __name(this, "PlatformAuthService");
@@ -13403,18 +13450,18 @@ exports.PlatformAuthService = class _PlatformAuthService {
13403
13450
  await this.redis.bumpUserTokenEpoch(userId, void 0, "platform");
13404
13451
  }
13405
13452
  };
13406
- exports.PlatformAuthService = _ts_decorate48([
13453
+ exports.PlatformAuthService = _ts_decorate51([
13407
13454
  common.Injectable(),
13408
- _ts_param26(0, common.Inject(BYMAX_AUTH_PLATFORM_USER_REPOSITORY)),
13409
- _ts_param26(1, common.Inject(PasswordService)),
13410
- _ts_param26(2, common.Inject(TokenManagerService)),
13411
- _ts_param26(3, common.Inject(exports.BruteForceService)),
13412
- _ts_param26(4, common.Inject(AuthRedisService)),
13413
- _ts_param26(5, common.Inject(BYMAX_AUTH_OPTIONS)),
13414
- _ts_param26(6, common.Inject(BYMAX_AUTH_HOOKS)),
13415
- _ts_param26(6, common.Optional()),
13416
- _ts_metadata47("design:type", Function),
13417
- _ts_metadata47("design:paramtypes", [
13455
+ _ts_param29(0, common.Inject(BYMAX_AUTH_PLATFORM_USER_REPOSITORY)),
13456
+ _ts_param29(1, common.Inject(PasswordService)),
13457
+ _ts_param29(2, common.Inject(TokenManagerService)),
13458
+ _ts_param29(3, common.Inject(exports.BruteForceService)),
13459
+ _ts_param29(4, common.Inject(AuthRedisService)),
13460
+ _ts_param29(5, common.Inject(BYMAX_AUTH_OPTIONS)),
13461
+ _ts_param29(6, common.Inject(BYMAX_AUTH_HOOKS)),
13462
+ _ts_param29(6, common.Optional()),
13463
+ _ts_metadata50("design:type", Function),
13464
+ _ts_metadata50("design:paramtypes", [
13418
13465
  typeof IPlatformUserRepository === "undefined" ? Object : IPlatformUserRepository,
13419
13466
  typeof PasswordService === "undefined" ? Object : PasswordService,
13420
13467
  typeof TokenManagerService === "undefined" ? Object : TokenManagerService,
@@ -13426,7 +13473,7 @@ exports.PlatformAuthService = _ts_decorate48([
13426
13473
  ], exports.PlatformAuthService);
13427
13474
 
13428
13475
  // src/server/controllers/platform-auth.controller.ts
13429
- function _ts_decorate49(decorators, target, key, desc) {
13476
+ function _ts_decorate52(decorators, target, key, desc) {
13430
13477
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
13431
13478
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
13432
13479
  r = Reflect.decorate(decorators, target, key, desc);
@@ -13439,19 +13486,19 @@ function _ts_decorate49(decorators, target, key, desc) {
13439
13486
  }
13440
13487
  return c > 3 && r && Object.defineProperty(target, key, r), r;
13441
13488
  }
13442
- __name(_ts_decorate49, "_ts_decorate");
13443
- function _ts_metadata48(metadataKey, metadataValue) {
13489
+ __name(_ts_decorate52, "_ts_decorate");
13490
+ function _ts_metadata51(metadataKey, metadataValue) {
13444
13491
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
13445
13492
  return Reflect.metadata(metadataKey, metadataValue);
13446
13493
  }
13447
13494
  }
13448
- __name(_ts_metadata48, "_ts_metadata");
13449
- function _ts_param27(paramIndex, decorator) {
13495
+ __name(_ts_metadata51, "_ts_metadata");
13496
+ function _ts_param30(paramIndex, decorator) {
13450
13497
  return function(target, key) {
13451
13498
  decorator(target, key, paramIndex);
13452
13499
  };
13453
13500
  }
13454
- __name(_ts_param27, "_ts_param");
13501
+ __name(_ts_param30, "_ts_param");
13455
13502
  function isMfaChallenge2(result) {
13456
13503
  return "mfaRequired" in result && result.mfaRequired === true;
13457
13504
  }
@@ -13597,103 +13644,103 @@ var PlatformAuthController = class {
13597
13644
  await this.platformAuthService.revokeAllPlatformSessions(user.sub);
13598
13645
  }
13599
13646
  };
13600
- _ts_decorate49([
13647
+ _ts_decorate52([
13601
13648
  Public(),
13602
13649
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.platformLogin),
13603
13650
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.platformLogin),
13604
13651
  common.HttpCode(common.HttpStatus.OK),
13605
13652
  common.Post("login"),
13606
- _ts_param27(0, common.Body()),
13607
- _ts_param27(1, common.Req()),
13608
- _ts_metadata48("design:type", Function),
13609
- _ts_metadata48("design:paramtypes", [
13653
+ _ts_param30(0, common.Body()),
13654
+ _ts_param30(1, common.Req()),
13655
+ _ts_metadata51("design:type", Function),
13656
+ _ts_metadata51("design:paramtypes", [
13610
13657
  typeof PlatformLoginDto === "undefined" ? Object : PlatformLoginDto,
13611
13658
  typeof Request === "undefined" ? Object : Request
13612
13659
  ]),
13613
- _ts_metadata48("design:returntype", Promise)
13660
+ _ts_metadata51("design:returntype", Promise)
13614
13661
  ], PlatformAuthController.prototype, "login", null);
13615
- _ts_decorate49([
13662
+ _ts_decorate52([
13616
13663
  Public(),
13617
13664
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.mfaChallenge),
13618
13665
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaChallenge),
13619
13666
  common.HttpCode(common.HttpStatus.OK),
13620
13667
  common.Post("mfa/challenge"),
13621
- _ts_param27(0, common.Body()),
13622
- _ts_param27(1, common.Req()),
13623
- _ts_metadata48("design:type", Function),
13624
- _ts_metadata48("design:paramtypes", [
13668
+ _ts_param30(0, common.Body()),
13669
+ _ts_param30(1, common.Req()),
13670
+ _ts_metadata51("design:type", Function),
13671
+ _ts_metadata51("design:paramtypes", [
13625
13672
  typeof MfaChallengeDto === "undefined" ? Object : MfaChallengeDto,
13626
13673
  typeof Request === "undefined" ? Object : Request
13627
13674
  ]),
13628
- _ts_metadata48("design:returntype", Promise)
13675
+ _ts_metadata51("design:returntype", Promise)
13629
13676
  ], PlatformAuthController.prototype, "mfaChallenge", null);
13630
- _ts_decorate49([
13677
+ _ts_decorate52([
13631
13678
  common.UseGuards(exports.JwtPlatformGuard),
13632
13679
  common.Get("me"),
13633
- _ts_param27(0, CurrentUser()),
13634
- _ts_metadata48("design:type", Function),
13635
- _ts_metadata48("design:paramtypes", [
13680
+ _ts_param30(0, CurrentUser()),
13681
+ _ts_metadata51("design:type", Function),
13682
+ _ts_metadata51("design:paramtypes", [
13636
13683
  typeof PlatformJwtPayload === "undefined" ? Object : PlatformJwtPayload
13637
13684
  ]),
13638
- _ts_metadata48("design:returntype", Promise)
13685
+ _ts_metadata51("design:returntype", Promise)
13639
13686
  ], PlatformAuthController.prototype, "me", null);
13640
- _ts_decorate49([
13687
+ _ts_decorate52([
13641
13688
  Public(),
13642
13689
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.logout),
13643
13690
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.logout),
13644
13691
  common.HttpCode(common.HttpStatus.NO_CONTENT),
13645
13692
  RequestEncoding("unchecked"),
13646
13693
  common.Post("logout"),
13647
- _ts_param27(0, common.Req()),
13648
- _ts_metadata48("design:type", Function),
13649
- _ts_metadata48("design:paramtypes", [
13694
+ _ts_param30(0, common.Req()),
13695
+ _ts_metadata51("design:type", Function),
13696
+ _ts_metadata51("design:paramtypes", [
13650
13697
  typeof Request === "undefined" ? Object : Request
13651
13698
  ]),
13652
- _ts_metadata48("design:returntype", Promise)
13699
+ _ts_metadata51("design:returntype", Promise)
13653
13700
  ], PlatformAuthController.prototype, "logout", null);
13654
- _ts_decorate49([
13701
+ _ts_decorate52([
13655
13702
  Public(),
13656
13703
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.refresh),
13657
13704
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.refresh),
13658
13705
  common.HttpCode(common.HttpStatus.OK),
13659
13706
  RequestEncoding("unchecked"),
13660
13707
  common.Post("refresh"),
13661
- _ts_param27(0, common.Req()),
13662
- _ts_metadata48("design:type", Function),
13663
- _ts_metadata48("design:paramtypes", [
13708
+ _ts_param30(0, common.Req()),
13709
+ _ts_metadata51("design:type", Function),
13710
+ _ts_metadata51("design:paramtypes", [
13664
13711
  typeof Request === "undefined" ? Object : Request
13665
13712
  ]),
13666
- _ts_metadata48("design:returntype", Promise)
13713
+ _ts_metadata51("design:returntype", Promise)
13667
13714
  ], PlatformAuthController.prototype, "refresh", null);
13668
- _ts_decorate49([
13715
+ _ts_decorate52([
13669
13716
  common.UseGuards(exports.JwtPlatformGuard),
13670
13717
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.revokeAllSessions),
13671
13718
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.revokeAllSessions),
13672
13719
  common.HttpCode(common.HttpStatus.NO_CONTENT),
13673
13720
  common.Delete("sessions"),
13674
- _ts_param27(0, CurrentUser()),
13675
- _ts_metadata48("design:type", Function),
13676
- _ts_metadata48("design:paramtypes", [
13721
+ _ts_param30(0, CurrentUser()),
13722
+ _ts_metadata51("design:type", Function),
13723
+ _ts_metadata51("design:paramtypes", [
13677
13724
  typeof PlatformJwtPayload === "undefined" ? Object : PlatformJwtPayload
13678
13725
  ]),
13679
- _ts_metadata48("design:returntype", Promise)
13726
+ _ts_metadata51("design:returntype", Promise)
13680
13727
  ], PlatformAuthController.prototype, "revokeSessions", null);
13681
- PlatformAuthController = _ts_decorate49([
13728
+ PlatformAuthController = _ts_decorate52([
13682
13729
  common.UseInterceptors(NoStoreInterceptor),
13683
13730
  common.Controller("platform"),
13684
13731
  common.UseGuards(exports.RequestEncodingGuard, exports.TrustedOriginGuard, exports.AuthRateLimitGuard),
13685
13732
  common.UsePipes(createAuthValidationPipe()),
13686
- _ts_param27(0, common.Inject(exports.PlatformAuthService)),
13687
- _ts_param27(1, common.Inject(exports.MfaService)),
13688
- _ts_param27(2, common.Inject(exports.TokenDeliveryService)),
13689
- _ts_metadata48("design:type", Function),
13690
- _ts_metadata48("design:paramtypes", [
13733
+ _ts_param30(0, common.Inject(exports.PlatformAuthService)),
13734
+ _ts_param30(1, common.Inject(exports.MfaService)),
13735
+ _ts_param30(2, common.Inject(exports.TokenDeliveryService)),
13736
+ _ts_metadata51("design:type", Function),
13737
+ _ts_metadata51("design:paramtypes", [
13691
13738
  typeof exports.PlatformAuthService === "undefined" ? Object : exports.PlatformAuthService,
13692
13739
  typeof exports.MfaService === "undefined" ? Object : exports.MfaService,
13693
13740
  typeof exports.TokenDeliveryService === "undefined" ? Object : exports.TokenDeliveryService
13694
13741
  ])
13695
13742
  ], PlatformAuthController);
13696
- function _ts_decorate50(decorators, target, key, desc) {
13743
+ function _ts_decorate53(decorators, target, key, desc) {
13697
13744
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
13698
13745
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
13699
13746
  r = Reflect.decorate(decorators, target, key, desc);
@@ -13706,19 +13753,19 @@ function _ts_decorate50(decorators, target, key, desc) {
13706
13753
  }
13707
13754
  return c > 3 && r && Object.defineProperty(target, key, r), r;
13708
13755
  }
13709
- __name(_ts_decorate50, "_ts_decorate");
13710
- function _ts_metadata49(metadataKey, metadataValue) {
13756
+ __name(_ts_decorate53, "_ts_decorate");
13757
+ function _ts_metadata52(metadataKey, metadataValue) {
13711
13758
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
13712
13759
  return Reflect.metadata(metadataKey, metadataValue);
13713
13760
  }
13714
13761
  }
13715
- __name(_ts_metadata49, "_ts_metadata");
13716
- function _ts_param28(paramIndex, decorator) {
13762
+ __name(_ts_metadata52, "_ts_metadata");
13763
+ function _ts_param31(paramIndex, decorator) {
13717
13764
  return function(target, key) {
13718
13765
  decorator(target, key, paramIndex);
13719
13766
  };
13720
13767
  }
13721
- __name(_ts_param28, "_ts_param");
13768
+ __name(_ts_param31, "_ts_param");
13722
13769
  var PlatformMfaController = class {
13723
13770
  static {
13724
13771
  __name(this, "PlatformMfaController");
@@ -13797,86 +13844,86 @@ var PlatformMfaController = class {
13797
13844
  return this.mfaService.regenerateRecoveryCodes(user.sub, dto.code, ip, userAgent, "platform");
13798
13845
  }
13799
13846
  };
13800
- _ts_decorate50([
13847
+ _ts_decorate53([
13801
13848
  common.UseGuards(exports.JwtPlatformGuard),
13802
13849
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.mfaSetup),
13803
13850
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaSetup),
13804
13851
  RequestEncoding("when-body"),
13805
13852
  common.Post("setup"),
13806
- _ts_param28(0, CurrentUser()),
13807
- _ts_param28(1, common.Body()),
13808
- _ts_metadata49("design:type", Function),
13809
- _ts_metadata49("design:paramtypes", [
13853
+ _ts_param31(0, CurrentUser()),
13854
+ _ts_param31(1, common.Body()),
13855
+ _ts_metadata52("design:type", Function),
13856
+ _ts_metadata52("design:paramtypes", [
13810
13857
  typeof PlatformJwtPayload === "undefined" ? Object : PlatformJwtPayload,
13811
13858
  typeof MfaSetupDto === "undefined" ? Object : MfaSetupDto
13812
13859
  ]),
13813
- _ts_metadata49("design:returntype", Promise)
13860
+ _ts_metadata52("design:returntype", Promise)
13814
13861
  ], PlatformMfaController.prototype, "setup", null);
13815
- _ts_decorate50([
13862
+ _ts_decorate53([
13816
13863
  common.UseGuards(exports.JwtPlatformGuard),
13817
13864
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.mfaVerifyEnable),
13818
13865
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaVerifyEnable),
13819
13866
  common.HttpCode(common.HttpStatus.NO_CONTENT),
13820
13867
  common.Post("verify-enable"),
13821
- _ts_param28(0, CurrentUser()),
13822
- _ts_param28(1, common.Body()),
13823
- _ts_param28(2, common.Req()),
13824
- _ts_metadata49("design:type", Function),
13825
- _ts_metadata49("design:paramtypes", [
13868
+ _ts_param31(0, CurrentUser()),
13869
+ _ts_param31(1, common.Body()),
13870
+ _ts_param31(2, common.Req()),
13871
+ _ts_metadata52("design:type", Function),
13872
+ _ts_metadata52("design:paramtypes", [
13826
13873
  typeof PlatformJwtPayload === "undefined" ? Object : PlatformJwtPayload,
13827
13874
  typeof MfaVerifyDto === "undefined" ? Object : MfaVerifyDto,
13828
13875
  typeof Request === "undefined" ? Object : Request
13829
13876
  ]),
13830
- _ts_metadata49("design:returntype", Promise)
13877
+ _ts_metadata52("design:returntype", Promise)
13831
13878
  ], PlatformMfaController.prototype, "verifyEnable", null);
13832
- _ts_decorate50([
13879
+ _ts_decorate53([
13833
13880
  common.UseGuards(exports.JwtPlatformGuard),
13834
13881
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.mfaDisable),
13835
13882
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaDisable),
13836
13883
  common.HttpCode(common.HttpStatus.NO_CONTENT),
13837
13884
  common.Post("disable"),
13838
- _ts_param28(0, CurrentUser()),
13839
- _ts_param28(1, common.Body()),
13840
- _ts_param28(2, common.Req()),
13841
- _ts_metadata49("design:type", Function),
13842
- _ts_metadata49("design:paramtypes", [
13885
+ _ts_param31(0, CurrentUser()),
13886
+ _ts_param31(1, common.Body()),
13887
+ _ts_param31(2, common.Req()),
13888
+ _ts_metadata52("design:type", Function),
13889
+ _ts_metadata52("design:paramtypes", [
13843
13890
  typeof PlatformJwtPayload === "undefined" ? Object : PlatformJwtPayload,
13844
13891
  typeof MfaDisableDto === "undefined" ? Object : MfaDisableDto,
13845
13892
  typeof Request === "undefined" ? Object : Request
13846
13893
  ]),
13847
- _ts_metadata49("design:returntype", Promise)
13894
+ _ts_metadata52("design:returntype", Promise)
13848
13895
  ], PlatformMfaController.prototype, "disable", null);
13849
- _ts_decorate50([
13896
+ _ts_decorate53([
13850
13897
  common.UseGuards(exports.JwtPlatformGuard),
13851
13898
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.mfaDisable),
13852
13899
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaDisable),
13853
13900
  common.HttpCode(common.HttpStatus.OK),
13854
13901
  common.Post("recovery-codes"),
13855
- _ts_param28(0, CurrentUser()),
13856
- _ts_param28(1, common.Body()),
13857
- _ts_param28(2, common.Req()),
13858
- _ts_metadata49("design:type", Function),
13859
- _ts_metadata49("design:paramtypes", [
13902
+ _ts_param31(0, CurrentUser()),
13903
+ _ts_param31(1, common.Body()),
13904
+ _ts_param31(2, common.Req()),
13905
+ _ts_metadata52("design:type", Function),
13906
+ _ts_metadata52("design:paramtypes", [
13860
13907
  typeof PlatformJwtPayload === "undefined" ? Object : PlatformJwtPayload,
13861
13908
  typeof MfaRegenerateRecoveryCodesDto === "undefined" ? Object : MfaRegenerateRecoveryCodesDto,
13862
13909
  typeof Request === "undefined" ? Object : Request
13863
13910
  ]),
13864
- _ts_metadata49("design:returntype", Promise)
13911
+ _ts_metadata52("design:returntype", Promise)
13865
13912
  ], PlatformMfaController.prototype, "regenerateRecoveryCodes", null);
13866
- PlatformMfaController = _ts_decorate50([
13913
+ PlatformMfaController = _ts_decorate53([
13867
13914
  common.UseInterceptors(NoStoreInterceptor),
13868
13915
  common.Controller("platform/mfa"),
13869
13916
  common.UseGuards(exports.RequestEncodingGuard, exports.TrustedOriginGuard, exports.AuthRateLimitGuard),
13870
13917
  common.UsePipes(createAuthValidationPipe({
13871
13918
  forbidUnknownValues: true
13872
13919
  })),
13873
- _ts_param28(0, common.Inject(exports.MfaService)),
13874
- _ts_metadata49("design:type", Function),
13875
- _ts_metadata49("design:paramtypes", [
13920
+ _ts_param31(0, common.Inject(exports.MfaService)),
13921
+ _ts_metadata52("design:type", Function),
13922
+ _ts_metadata52("design:paramtypes", [
13876
13923
  typeof exports.MfaService === "undefined" ? Object : exports.MfaService
13877
13924
  ])
13878
13925
  ], PlatformMfaController);
13879
- function _ts_decorate51(decorators, target, key, desc) {
13926
+ function _ts_decorate54(decorators, target, key, desc) {
13880
13927
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
13881
13928
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
13882
13929
  r = Reflect.decorate(decorators, target, key, desc);
@@ -13889,19 +13936,19 @@ function _ts_decorate51(decorators, target, key, desc) {
13889
13936
  }
13890
13937
  return c > 3 && r && Object.defineProperty(target, key, r), r;
13891
13938
  }
13892
- __name(_ts_decorate51, "_ts_decorate");
13893
- function _ts_metadata50(metadataKey, metadataValue) {
13939
+ __name(_ts_decorate54, "_ts_decorate");
13940
+ function _ts_metadata53(metadataKey, metadataValue) {
13894
13941
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
13895
13942
  return Reflect.metadata(metadataKey, metadataValue);
13896
13943
  }
13897
13944
  }
13898
- __name(_ts_metadata50, "_ts_metadata");
13899
- function _ts_param29(paramIndex, decorator) {
13945
+ __name(_ts_metadata53, "_ts_metadata");
13946
+ function _ts_param32(paramIndex, decorator) {
13900
13947
  return function(target, key) {
13901
13948
  decorator(target, key, paramIndex);
13902
13949
  };
13903
13950
  }
13904
- __name(_ts_param29, "_ts_param");
13951
+ __name(_ts_param32, "_ts_param");
13905
13952
  var SessionController = class {
13906
13953
  static {
13907
13954
  __name(this, "SessionController");
@@ -14001,64 +14048,64 @@ var SessionController = class {
14001
14048
  });
14002
14049
  }
14003
14050
  };
14004
- _ts_decorate51([
14051
+ _ts_decorate54([
14005
14052
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.listSessions),
14006
14053
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.listSessions),
14007
14054
  common.Get(),
14008
- _ts_param29(0, CurrentUser()),
14009
- _ts_param29(1, common.Req()),
14010
- _ts_metadata50("design:type", Function),
14011
- _ts_metadata50("design:paramtypes", [
14055
+ _ts_param32(0, CurrentUser()),
14056
+ _ts_param32(1, common.Req()),
14057
+ _ts_metadata53("design:type", Function),
14058
+ _ts_metadata53("design:paramtypes", [
14012
14059
  typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
14013
14060
  typeof Request === "undefined" ? Object : Request
14014
14061
  ]),
14015
- _ts_metadata50("design:returntype", Promise)
14062
+ _ts_metadata53("design:returntype", Promise)
14016
14063
  ], SessionController.prototype, "listSessions", null);
14017
- _ts_decorate51([
14064
+ _ts_decorate54([
14018
14065
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.revokeAllSessions),
14019
14066
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.revokeAllSessions),
14020
14067
  common.HttpCode(common.HttpStatus.NO_CONTENT),
14021
14068
  RequestEncoding("unchecked"),
14022
14069
  common.Post("revoke-all"),
14023
- _ts_param29(0, CurrentUser()),
14024
- _ts_param29(1, common.Req()),
14025
- _ts_metadata50("design:type", Function),
14026
- _ts_metadata50("design:paramtypes", [
14070
+ _ts_param32(0, CurrentUser()),
14071
+ _ts_param32(1, common.Req()),
14072
+ _ts_metadata53("design:type", Function),
14073
+ _ts_metadata53("design:paramtypes", [
14027
14074
  typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
14028
14075
  typeof Request === "undefined" ? Object : Request
14029
14076
  ]),
14030
- _ts_metadata50("design:returntype", Promise)
14077
+ _ts_metadata53("design:returntype", Promise)
14031
14078
  ], SessionController.prototype, "revokeAllSessions", null);
14032
- _ts_decorate51([
14079
+ _ts_decorate54([
14033
14080
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.revokeSession),
14034
14081
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.revokeSession),
14035
14082
  common.HttpCode(common.HttpStatus.NO_CONTENT),
14036
14083
  common.Delete(":id"),
14037
- _ts_param29(0, CurrentUser()),
14038
- _ts_param29(1, common.Param("id")),
14039
- _ts_metadata50("design:type", Function),
14040
- _ts_metadata50("design:paramtypes", [
14084
+ _ts_param32(0, CurrentUser()),
14085
+ _ts_param32(1, common.Param("id")),
14086
+ _ts_metadata53("design:type", Function),
14087
+ _ts_metadata53("design:paramtypes", [
14041
14088
  typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
14042
14089
  String
14043
14090
  ]),
14044
- _ts_metadata50("design:returntype", Promise)
14091
+ _ts_metadata53("design:returntype", Promise)
14045
14092
  ], SessionController.prototype, "revokeSession", null);
14046
- SessionController = _ts_decorate51([
14093
+ SessionController = _ts_decorate54([
14047
14094
  common.UseInterceptors(NoStoreInterceptor),
14048
14095
  common.Controller("sessions"),
14049
14096
  common.UseGuards(exports.RequestEncodingGuard, exports.TrustedOriginGuard, exports.AuthRateLimitGuard, exports.JwtAuthGuard, exports.UserStatusGuard),
14050
14097
  common.UsePipes(createAuthValidationPipe()),
14051
- _ts_param29(0, common.Inject(exports.SessionService)),
14052
- _ts_param29(1, common.Inject(exports.TokenDeliveryService)),
14053
- _ts_metadata50("design:type", Function),
14054
- _ts_metadata50("design:paramtypes", [
14098
+ _ts_param32(0, common.Inject(exports.SessionService)),
14099
+ _ts_param32(1, common.Inject(exports.TokenDeliveryService)),
14100
+ _ts_metadata53("design:type", Function),
14101
+ _ts_metadata53("design:paramtypes", [
14055
14102
  typeof exports.SessionService === "undefined" ? Object : exports.SessionService,
14056
14103
  typeof exports.TokenDeliveryService === "undefined" ? Object : exports.TokenDeliveryService
14057
14104
  ])
14058
14105
  ], SessionController);
14059
14106
  var API_KEY_SCOPES_KEY = /* @__PURE__ */ Symbol("bymax:apiKeyScopes");
14060
14107
  var ApiKeyScopes = /* @__PURE__ */ __name((...scopes) => common.SetMetadata(API_KEY_SCOPES_KEY, scopes), "ApiKeyScopes");
14061
- function _ts_decorate52(decorators, target, key, desc) {
14108
+ function _ts_decorate55(decorators, target, key, desc) {
14062
14109
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
14063
14110
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
14064
14111
  r = Reflect.decorate(decorators, target, key, desc);
@@ -14071,19 +14118,19 @@ function _ts_decorate52(decorators, target, key, desc) {
14071
14118
  }
14072
14119
  return c > 3 && r && Object.defineProperty(target, key, r), r;
14073
14120
  }
14074
- __name(_ts_decorate52, "_ts_decorate");
14075
- function _ts_metadata51(metadataKey, metadataValue) {
14121
+ __name(_ts_decorate55, "_ts_decorate");
14122
+ function _ts_metadata54(metadataKey, metadataValue) {
14076
14123
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
14077
14124
  return Reflect.metadata(metadataKey, metadataValue);
14078
14125
  }
14079
14126
  }
14080
- __name(_ts_metadata51, "_ts_metadata");
14081
- function _ts_param30(paramIndex, decorator) {
14127
+ __name(_ts_metadata54, "_ts_metadata");
14128
+ function _ts_param33(paramIndex, decorator) {
14082
14129
  return function(target, key) {
14083
14130
  decorator(target, key, paramIndex);
14084
14131
  };
14085
14132
  }
14086
- __name(_ts_param30, "_ts_param");
14133
+ __name(_ts_param33, "_ts_param");
14087
14134
  var ApiKeyLastUsedService = class _ApiKeyLastUsedService {
14088
14135
  static {
14089
14136
  __name(this, "ApiKeyLastUsedService");
@@ -14144,12 +14191,12 @@ var ApiKeyLastUsedService = class _ApiKeyLastUsedService {
14144
14191
  await this.flush();
14145
14192
  }
14146
14193
  };
14147
- ApiKeyLastUsedService = _ts_decorate52([
14194
+ ApiKeyLastUsedService = _ts_decorate55([
14148
14195
  common.Injectable(),
14149
- _ts_param30(0, common.Inject(BYMAX_AUTH_API_KEY_REPOSITORY)),
14150
- _ts_param30(1, common.Inject(BYMAX_AUTH_OPTIONS)),
14151
- _ts_metadata51("design:type", Function),
14152
- _ts_metadata51("design:paramtypes", [
14196
+ _ts_param33(0, common.Inject(BYMAX_AUTH_API_KEY_REPOSITORY)),
14197
+ _ts_param33(1, common.Inject(BYMAX_AUTH_OPTIONS)),
14198
+ _ts_metadata54("design:type", Function),
14199
+ _ts_metadata54("design:paramtypes", [
14153
14200
  typeof IApiKeyRepository === "undefined" ? Object : IApiKeyRepository,
14154
14201
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
14155
14202
  ])
@@ -14198,7 +14245,7 @@ function digestsMatch(computed, stored) {
14198
14245
  __name(digestsMatch, "digestsMatch");
14199
14246
 
14200
14247
  // src/server/services/api-key-verifier.service.ts
14201
- function _ts_decorate53(decorators, target, key, desc) {
14248
+ function _ts_decorate56(decorators, target, key, desc) {
14202
14249
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
14203
14250
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
14204
14251
  r = Reflect.decorate(decorators, target, key, desc);
@@ -14211,19 +14258,19 @@ function _ts_decorate53(decorators, target, key, desc) {
14211
14258
  }
14212
14259
  return c > 3 && r && Object.defineProperty(target, key, r), r;
14213
14260
  }
14214
- __name(_ts_decorate53, "_ts_decorate");
14215
- function _ts_metadata52(metadataKey, metadataValue) {
14261
+ __name(_ts_decorate56, "_ts_decorate");
14262
+ function _ts_metadata55(metadataKey, metadataValue) {
14216
14263
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
14217
14264
  return Reflect.metadata(metadataKey, metadataValue);
14218
14265
  }
14219
14266
  }
14220
- __name(_ts_metadata52, "_ts_metadata");
14221
- function _ts_param31(paramIndex, decorator) {
14267
+ __name(_ts_metadata55, "_ts_metadata");
14268
+ function _ts_param34(paramIndex, decorator) {
14222
14269
  return function(target, key) {
14223
14270
  decorator(target, key, paramIndex);
14224
14271
  };
14225
14272
  }
14226
- __name(_ts_param31, "_ts_param");
14273
+ __name(_ts_param34, "_ts_param");
14227
14274
  var ApiKeyVerifierService = class {
14228
14275
  static {
14229
14276
  __name(this, "ApiKeyVerifierService");
@@ -14283,14 +14330,14 @@ var ApiKeyVerifierService = class {
14283
14330
  return null;
14284
14331
  }
14285
14332
  };
14286
- ApiKeyVerifierService = _ts_decorate53([
14287
- common.Injectable(),
14288
- _ts_param31(0, common.Inject(BYMAX_AUTH_API_KEY_REPOSITORY)),
14289
- _ts_param31(1, common.Inject(BYMAX_AUTH_API_KEY_CLOCK)),
14290
- _ts_param31(2, common.Inject(BYMAX_AUTH_OPTIONS)),
14291
- _ts_param31(3, common.Inject(ApiKeyLastUsedService)),
14292
- _ts_metadata52("design:type", Function),
14293
- _ts_metadata52("design:paramtypes", [
14333
+ ApiKeyVerifierService = _ts_decorate56([
14334
+ common.Injectable(),
14335
+ _ts_param34(0, common.Inject(BYMAX_AUTH_API_KEY_REPOSITORY)),
14336
+ _ts_param34(1, common.Inject(BYMAX_AUTH_API_KEY_CLOCK)),
14337
+ _ts_param34(2, common.Inject(BYMAX_AUTH_OPTIONS)),
14338
+ _ts_param34(3, common.Inject(ApiKeyLastUsedService)),
14339
+ _ts_metadata55("design:type", Function),
14340
+ _ts_metadata55("design:paramtypes", [
14294
14341
  typeof IApiKeyRepository === "undefined" ? Object : IApiKeyRepository,
14295
14342
  typeof ApiKeyClock === "undefined" ? Object : ApiKeyClock,
14296
14343
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
@@ -14299,7 +14346,7 @@ ApiKeyVerifierService = _ts_decorate53([
14299
14346
  ], ApiKeyVerifierService);
14300
14347
 
14301
14348
  // src/server/guards/api-key.guard.ts
14302
- function _ts_decorate54(decorators, target, key, desc) {
14349
+ function _ts_decorate57(decorators, target, key, desc) {
14303
14350
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
14304
14351
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
14305
14352
  r = Reflect.decorate(decorators, target, key, desc);
@@ -14312,19 +14359,19 @@ function _ts_decorate54(decorators, target, key, desc) {
14312
14359
  }
14313
14360
  return c > 3 && r && Object.defineProperty(target, key, r), r;
14314
14361
  }
14315
- __name(_ts_decorate54, "_ts_decorate");
14316
- function _ts_metadata53(metadataKey, metadataValue) {
14362
+ __name(_ts_decorate57, "_ts_decorate");
14363
+ function _ts_metadata56(metadataKey, metadataValue) {
14317
14364
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
14318
14365
  return Reflect.metadata(metadataKey, metadataValue);
14319
14366
  }
14320
14367
  }
14321
- __name(_ts_metadata53, "_ts_metadata");
14322
- function _ts_param32(paramIndex, decorator) {
14368
+ __name(_ts_metadata56, "_ts_metadata");
14369
+ function _ts_param35(paramIndex, decorator) {
14323
14370
  return function(target, key) {
14324
14371
  decorator(target, key, paramIndex);
14325
14372
  };
14326
14373
  }
14327
- __name(_ts_param32, "_ts_param");
14374
+ __name(_ts_param35, "_ts_param");
14328
14375
  exports.ApiKeyGuard = class _ApiKeyGuard {
14329
14376
  static {
14330
14377
  __name(this, "ApiKeyGuard");
@@ -14464,15 +14511,15 @@ exports.ApiKeyGuard = class _ApiKeyGuard {
14464
14511
  };
14465
14512
  }
14466
14513
  };
14467
- exports.ApiKeyGuard = _ts_decorate54([
14514
+ exports.ApiKeyGuard = _ts_decorate57([
14468
14515
  common.Injectable(),
14469
- _ts_param32(0, common.Inject(core.Reflector)),
14470
- _ts_param32(1, common.Inject(ApiKeyVerifierService)),
14471
- _ts_param32(2, common.Inject(BYMAX_AUTH_OPTIONS)),
14472
- _ts_param32(3, common.Inject(BYMAX_AUTH_HOOKS)),
14473
- _ts_param32(3, common.Optional()),
14474
- _ts_metadata53("design:type", Function),
14475
- _ts_metadata53("design:paramtypes", [
14516
+ _ts_param35(0, common.Inject(core.Reflector)),
14517
+ _ts_param35(1, common.Inject(ApiKeyVerifierService)),
14518
+ _ts_param35(2, common.Inject(BYMAX_AUTH_OPTIONS)),
14519
+ _ts_param35(3, common.Inject(BYMAX_AUTH_HOOKS)),
14520
+ _ts_param35(3, common.Optional()),
14521
+ _ts_metadata56("design:type", Function),
14522
+ _ts_metadata56("design:paramtypes", [
14476
14523
  typeof core.Reflector === "undefined" ? Object : core.Reflector,
14477
14524
  typeof ApiKeyVerifierService === "undefined" ? Object : ApiKeyVerifierService,
14478
14525
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
@@ -14484,7 +14531,7 @@ function routePattern(request) {
14484
14531
  return typeof path === "string" ? path : "";
14485
14532
  }
14486
14533
  __name(routePattern, "routePattern");
14487
- function _ts_decorate55(decorators, target, key, desc) {
14534
+ function _ts_decorate58(decorators, target, key, desc) {
14488
14535
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
14489
14536
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
14490
14537
  r = Reflect.decorate(decorators, target, key, desc);
@@ -14497,19 +14544,19 @@ function _ts_decorate55(decorators, target, key, desc) {
14497
14544
  }
14498
14545
  return c > 3 && r && Object.defineProperty(target, key, r), r;
14499
14546
  }
14500
- __name(_ts_decorate55, "_ts_decorate");
14501
- function _ts_metadata54(metadataKey, metadataValue) {
14547
+ __name(_ts_decorate58, "_ts_decorate");
14548
+ function _ts_metadata57(metadataKey, metadataValue) {
14502
14549
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
14503
14550
  return Reflect.metadata(metadataKey, metadataValue);
14504
14551
  }
14505
14552
  }
14506
- __name(_ts_metadata54, "_ts_metadata");
14507
- function _ts_param33(paramIndex, decorator) {
14553
+ __name(_ts_metadata57, "_ts_metadata");
14554
+ function _ts_param36(paramIndex, decorator) {
14508
14555
  return function(target, key) {
14509
14556
  decorator(target, key, paramIndex);
14510
14557
  };
14511
14558
  }
14512
- __name(_ts_param33, "_ts_param");
14559
+ __name(_ts_param36, "_ts_param");
14513
14560
  exports.MfaRequiredGuard = class MfaRequiredGuard {
14514
14561
  static {
14515
14562
  __name(this, "MfaRequiredGuard");
@@ -14536,11 +14583,11 @@ exports.MfaRequiredGuard = class MfaRequiredGuard {
14536
14583
  return true;
14537
14584
  }
14538
14585
  };
14539
- exports.MfaRequiredGuard = _ts_decorate55([
14586
+ exports.MfaRequiredGuard = _ts_decorate58([
14540
14587
  common.Injectable(),
14541
- _ts_param33(0, common.Inject(core.Reflector)),
14542
- _ts_metadata54("design:type", Function),
14543
- _ts_metadata54("design:paramtypes", [
14588
+ _ts_param36(0, common.Inject(core.Reflector)),
14589
+ _ts_metadata57("design:type", Function),
14590
+ _ts_metadata57("design:paramtypes", [
14544
14591
  typeof core.Reflector === "undefined" ? Object : core.Reflector
14545
14592
  ])
14546
14593
  ], exports.MfaRequiredGuard);
@@ -14548,7 +14595,7 @@ var PLATFORM_ROLES_KEY = /* @__PURE__ */ Symbol("platformRoles");
14548
14595
  var PlatformRoles = /* @__PURE__ */ __name((...roles) => common.SetMetadata(PLATFORM_ROLES_KEY, roles), "PlatformRoles");
14549
14596
 
14550
14597
  // src/server/guards/platform-roles.guard.ts
14551
- function _ts_decorate56(decorators, target, key, desc) {
14598
+ function _ts_decorate59(decorators, target, key, desc) {
14552
14599
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
14553
14600
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
14554
14601
  r = Reflect.decorate(decorators, target, key, desc);
@@ -14561,19 +14608,19 @@ function _ts_decorate56(decorators, target, key, desc) {
14561
14608
  }
14562
14609
  return c > 3 && r && Object.defineProperty(target, key, r), r;
14563
14610
  }
14564
- __name(_ts_decorate56, "_ts_decorate");
14565
- function _ts_metadata55(metadataKey, metadataValue) {
14611
+ __name(_ts_decorate59, "_ts_decorate");
14612
+ function _ts_metadata58(metadataKey, metadataValue) {
14566
14613
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
14567
14614
  return Reflect.metadata(metadataKey, metadataValue);
14568
14615
  }
14569
14616
  }
14570
- __name(_ts_metadata55, "_ts_metadata");
14571
- function _ts_param34(paramIndex, decorator) {
14617
+ __name(_ts_metadata58, "_ts_metadata");
14618
+ function _ts_param37(paramIndex, decorator) {
14572
14619
  return function(target, key) {
14573
14620
  decorator(target, key, paramIndex);
14574
14621
  };
14575
14622
  }
14576
- __name(_ts_param34, "_ts_param");
14623
+ __name(_ts_param37, "_ts_param");
14577
14624
  exports.PlatformRolesGuard = class PlatformRolesGuard {
14578
14625
  static {
14579
14626
  __name(this, "PlatformRolesGuard");
@@ -14607,12 +14654,12 @@ exports.PlatformRolesGuard = class PlatformRolesGuard {
14607
14654
  return true;
14608
14655
  }
14609
14656
  };
14610
- exports.PlatformRolesGuard = _ts_decorate56([
14657
+ exports.PlatformRolesGuard = _ts_decorate59([
14611
14658
  common.Injectable(),
14612
- _ts_param34(0, common.Inject(core.Reflector)),
14613
- _ts_param34(1, common.Inject(BYMAX_AUTH_OPTIONS)),
14614
- _ts_metadata55("design:type", Function),
14615
- _ts_metadata55("design:paramtypes", [
14659
+ _ts_param37(0, common.Inject(core.Reflector)),
14660
+ _ts_param37(1, common.Inject(BYMAX_AUTH_OPTIONS)),
14661
+ _ts_metadata58("design:type", Function),
14662
+ _ts_metadata58("design:paramtypes", [
14616
14663
  typeof core.Reflector === "undefined" ? Object : core.Reflector,
14617
14664
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
14618
14665
  ])
@@ -14621,7 +14668,7 @@ var ROLES_KEY = "roles";
14621
14668
  var Roles = /* @__PURE__ */ __name((...roles) => common.SetMetadata(ROLES_KEY, roles), "Roles");
14622
14669
 
14623
14670
  // src/server/guards/roles.guard.ts
14624
- function _ts_decorate57(decorators, target, key, desc) {
14671
+ function _ts_decorate60(decorators, target, key, desc) {
14625
14672
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
14626
14673
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
14627
14674
  r = Reflect.decorate(decorators, target, key, desc);
@@ -14634,19 +14681,19 @@ function _ts_decorate57(decorators, target, key, desc) {
14634
14681
  }
14635
14682
  return c > 3 && r && Object.defineProperty(target, key, r), r;
14636
14683
  }
14637
- __name(_ts_decorate57, "_ts_decorate");
14638
- function _ts_metadata56(metadataKey, metadataValue) {
14684
+ __name(_ts_decorate60, "_ts_decorate");
14685
+ function _ts_metadata59(metadataKey, metadataValue) {
14639
14686
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
14640
14687
  return Reflect.metadata(metadataKey, metadataValue);
14641
14688
  }
14642
14689
  }
14643
- __name(_ts_metadata56, "_ts_metadata");
14644
- function _ts_param35(paramIndex, decorator) {
14690
+ __name(_ts_metadata59, "_ts_metadata");
14691
+ function _ts_param38(paramIndex, decorator) {
14645
14692
  return function(target, key) {
14646
14693
  decorator(target, key, paramIndex);
14647
14694
  };
14648
14695
  }
14649
- __name(_ts_param35, "_ts_param");
14696
+ __name(_ts_param38, "_ts_param");
14650
14697
  exports.RolesGuard = class RolesGuard {
14651
14698
  static {
14652
14699
  __name(this, "RolesGuard");
@@ -14676,17 +14723,17 @@ exports.RolesGuard = class RolesGuard {
14676
14723
  return true;
14677
14724
  }
14678
14725
  };
14679
- exports.RolesGuard = _ts_decorate57([
14726
+ exports.RolesGuard = _ts_decorate60([
14680
14727
  common.Injectable(),
14681
- _ts_param35(0, common.Inject(core.Reflector)),
14682
- _ts_param35(1, common.Inject(BYMAX_AUTH_OPTIONS)),
14683
- _ts_metadata56("design:type", Function),
14684
- _ts_metadata56("design:paramtypes", [
14728
+ _ts_param38(0, common.Inject(core.Reflector)),
14729
+ _ts_param38(1, common.Inject(BYMAX_AUTH_OPTIONS)),
14730
+ _ts_metadata59("design:type", Function),
14731
+ _ts_metadata59("design:paramtypes", [
14685
14732
  typeof core.Reflector === "undefined" ? Object : core.Reflector,
14686
14733
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
14687
14734
  ])
14688
14735
  ], exports.RolesGuard);
14689
- function _ts_decorate58(decorators, target, key, desc) {
14736
+ function _ts_decorate61(decorators, target, key, desc) {
14690
14737
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
14691
14738
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
14692
14739
  r = Reflect.decorate(decorators, target, key, desc);
@@ -14699,7 +14746,7 @@ function _ts_decorate58(decorators, target, key, desc) {
14699
14746
  }
14700
14747
  return c > 3 && r && Object.defineProperty(target, key, r), r;
14701
14748
  }
14702
- __name(_ts_decorate58, "_ts_decorate");
14749
+ __name(_ts_decorate61, "_ts_decorate");
14703
14750
  exports.NoOpAuthHooks = class NoOpAuthHooks {
14704
14751
  static {
14705
14752
  __name(this, "NoOpAuthHooks");
@@ -14748,7 +14795,7 @@ exports.NoOpAuthHooks = class NoOpAuthHooks {
14748
14795
  };
14749
14796
  }
14750
14797
  };
14751
- exports.NoOpAuthHooks = _ts_decorate58([
14798
+ exports.NoOpAuthHooks = _ts_decorate61([
14752
14799
  common.Injectable()
14753
14800
  ], exports.NoOpAuthHooks);
14754
14801
 
@@ -14761,7 +14808,7 @@ var OAUTH_STATE_COOKIE_SAME_SITE = "lax";
14761
14808
  var OAUTH_STATE_COOKIE_MAX_AGE_SECONDS = 600;
14762
14809
 
14763
14810
  // src/server/oauth/oauth.service.ts
14764
- function _ts_decorate59(decorators, target, key, desc) {
14811
+ function _ts_decorate62(decorators, target, key, desc) {
14765
14812
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
14766
14813
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
14767
14814
  r = Reflect.decorate(decorators, target, key, desc);
@@ -14774,19 +14821,19 @@ function _ts_decorate59(decorators, target, key, desc) {
14774
14821
  }
14775
14822
  return c > 3 && r && Object.defineProperty(target, key, r), r;
14776
14823
  }
14777
- __name(_ts_decorate59, "_ts_decorate");
14778
- function _ts_metadata57(metadataKey, metadataValue) {
14824
+ __name(_ts_decorate62, "_ts_decorate");
14825
+ function _ts_metadata60(metadataKey, metadataValue) {
14779
14826
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
14780
14827
  return Reflect.metadata(metadataKey, metadataValue);
14781
14828
  }
14782
14829
  }
14783
- __name(_ts_metadata57, "_ts_metadata");
14784
- function _ts_param36(paramIndex, decorator) {
14830
+ __name(_ts_metadata60, "_ts_metadata");
14831
+ function _ts_param39(paramIndex, decorator) {
14785
14832
  return function(target, key) {
14786
14833
  decorator(target, key, paramIndex);
14787
14834
  };
14788
14835
  }
14789
- __name(_ts_param36, "_ts_param");
14836
+ __name(_ts_param39, "_ts_param");
14790
14837
  var OAUTH_STATE_TTL_SECONDS = 600;
14791
14838
  function isStoredOAuthState(value) {
14792
14839
  if (typeof value !== "object" || value === null) return false;
@@ -14801,11 +14848,11 @@ function base64url(input) {
14801
14848
  return input.toString("base64url");
14802
14849
  }
14803
14850
  __name(base64url, "base64url");
14804
- function toSafeUser4(user) {
14851
+ function toSafeUser5(user) {
14805
14852
  const { passwordHash: _ph, mfaSecret: _ms, mfaRecoveryCodes: _mrc, ...safe } = user;
14806
14853
  return safe;
14807
14854
  }
14808
- __name(toSafeUser4, "toSafeUser");
14855
+ __name(toSafeUser5, "toSafeUser");
14809
14856
  exports.OAuthService = class _OAuthService {
14810
14857
  static {
14811
14858
  __name(this, "OAuthService");
@@ -14954,7 +15001,7 @@ exports.OAuthService = class _OAuthService {
14954
15001
  providerId: profile.providerId,
14955
15002
  tenantId
14956
15003
  });
14957
- const existingUser = existingAuthUser ? toSafeUser4(existingAuthUser) : null;
15004
+ const existingUser = existingAuthUser ? toSafeUser5(existingAuthUser) : null;
14958
15005
  const hookContext = {
14959
15006
  plane: "dashboard",
14960
15007
  tenantId,
@@ -15029,7 +15076,7 @@ exports.OAuthService = class _OAuthService {
15029
15076
  mfaTempToken
15030
15077
  };
15031
15078
  }
15032
- const safeUser = toSafeUser4(authUser);
15079
+ const safeUser = toSafeUser5(authUser);
15033
15080
  const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent);
15034
15081
  if (this.options.sessions.enabled) {
15035
15082
  await this.sessionService.createSession({
@@ -15080,18 +15127,18 @@ exports.OAuthService = class _OAuthService {
15080
15127
  return plugin;
15081
15128
  }
15082
15129
  };
15083
- exports.OAuthService = _ts_decorate59([
15130
+ exports.OAuthService = _ts_decorate62([
15084
15131
  common.Injectable(),
15085
- _ts_param36(0, common.Inject(OAUTH_PLUGINS)),
15086
- _ts_param36(1, common.Inject(BYMAX_AUTH_USER_REPOSITORY)),
15087
- _ts_param36(2, common.Inject(BYMAX_AUTH_HOOKS)),
15088
- _ts_param36(2, common.Optional()),
15089
- _ts_param36(3, common.Inject(AuthRedisService)),
15090
- _ts_param36(4, common.Inject(TokenManagerService)),
15091
- _ts_param36(5, common.Inject(exports.SessionService)),
15092
- _ts_param36(6, common.Inject(BYMAX_AUTH_OPTIONS)),
15093
- _ts_metadata57("design:type", Function),
15094
- _ts_metadata57("design:paramtypes", [
15132
+ _ts_param39(0, common.Inject(OAUTH_PLUGINS)),
15133
+ _ts_param39(1, common.Inject(BYMAX_AUTH_USER_REPOSITORY)),
15134
+ _ts_param39(2, common.Inject(BYMAX_AUTH_HOOKS)),
15135
+ _ts_param39(2, common.Optional()),
15136
+ _ts_param39(3, common.Inject(AuthRedisService)),
15137
+ _ts_param39(4, common.Inject(TokenManagerService)),
15138
+ _ts_param39(5, common.Inject(exports.SessionService)),
15139
+ _ts_param39(6, common.Inject(BYMAX_AUTH_OPTIONS)),
15140
+ _ts_metadata60("design:type", Function),
15141
+ _ts_metadata60("design:paramtypes", [
15095
15142
  Array,
15096
15143
  typeof IUserRepository === "undefined" ? Object : IUserRepository,
15097
15144
  Object,
@@ -15101,7 +15148,7 @@ exports.OAuthService = _ts_decorate59([
15101
15148
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
15102
15149
  ])
15103
15150
  ], exports.OAuthService);
15104
- function _ts_decorate60(decorators, target, key, desc) {
15151
+ function _ts_decorate63(decorators, target, key, desc) {
15105
15152
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
15106
15153
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
15107
15154
  r = Reflect.decorate(decorators, target, key, desc);
@@ -15114,13 +15161,13 @@ function _ts_decorate60(decorators, target, key, desc) {
15114
15161
  }
15115
15162
  return c > 3 && r && Object.defineProperty(target, key, r), r;
15116
15163
  }
15117
- __name(_ts_decorate60, "_ts_decorate");
15118
- function _ts_metadata58(metadataKey, metadataValue) {
15164
+ __name(_ts_decorate63, "_ts_decorate");
15165
+ function _ts_metadata61(metadataKey, metadataValue) {
15119
15166
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
15120
15167
  return Reflect.metadata(metadataKey, metadataValue);
15121
15168
  }
15122
15169
  }
15123
- __name(_ts_metadata58, "_ts_metadata");
15170
+ __name(_ts_metadata61, "_ts_metadata");
15124
15171
  var OAuthCallbackQueryDto = class {
15125
15172
  static {
15126
15173
  __name(this, "OAuthCallbackQueryDto");
@@ -15219,69 +15266,69 @@ var OAuthCallbackQueryDto = class {
15219
15266
  */
15220
15267
  hd;
15221
15268
  };
15222
- _ts_decorate60([
15269
+ _ts_decorate63([
15223
15270
  classValidator.ValidateIf((query) => query.error === void 0 || query.error === null),
15224
15271
  classValidator.IsOptional(),
15225
15272
  classValidator.IsString(),
15226
15273
  classValidator.IsNotEmpty(),
15227
15274
  classValidator.MaxLength(2048),
15228
- _ts_metadata58("design:type", String)
15275
+ _ts_metadata61("design:type", String)
15229
15276
  ], OAuthCallbackQueryDto.prototype, "code", void 0);
15230
- _ts_decorate60([
15277
+ _ts_decorate63([
15231
15278
  classValidator.IsOptional(),
15232
15279
  classValidator.IsString(),
15233
15280
  classValidator.MaxLength(128),
15234
- _ts_metadata58("design:type", String)
15281
+ _ts_metadata61("design:type", String)
15235
15282
  ], OAuthCallbackQueryDto.prototype, "error", void 0);
15236
- _ts_decorate60([
15283
+ _ts_decorate63([
15237
15284
  classValidator.IsOptional(),
15238
15285
  classValidator.IsString(),
15239
15286
  classValidator.MaxLength(512),
15240
- _ts_metadata58("design:type", String)
15287
+ _ts_metadata61("design:type", String)
15241
15288
  ], OAuthCallbackQueryDto.prototype, "error_description", void 0);
15242
- _ts_decorate60([
15289
+ _ts_decorate63([
15243
15290
  classValidator.IsOptional(),
15244
15291
  classValidator.IsString(),
15245
15292
  classValidator.MaxLength(512),
15246
- _ts_metadata58("design:type", String)
15293
+ _ts_metadata61("design:type", String)
15247
15294
  ], OAuthCallbackQueryDto.prototype, "error_uri", void 0);
15248
- _ts_decorate60([
15295
+ _ts_decorate63([
15249
15296
  classValidator.IsString(),
15250
15297
  classValidator.IsNotEmpty(),
15251
15298
  classValidator.MaxLength(128),
15252
- _ts_metadata58("design:type", String)
15299
+ _ts_metadata61("design:type", String)
15253
15300
  ], OAuthCallbackQueryDto.prototype, "state", void 0);
15254
- _ts_decorate60([
15301
+ _ts_decorate63([
15255
15302
  classValidator.IsOptional(),
15256
15303
  classValidator.IsString(),
15257
15304
  classValidator.MaxLength(512),
15258
- _ts_metadata58("design:type", String)
15305
+ _ts_metadata61("design:type", String)
15259
15306
  ], OAuthCallbackQueryDto.prototype, "iss", void 0);
15260
- _ts_decorate60([
15307
+ _ts_decorate63([
15261
15308
  classValidator.IsOptional(),
15262
15309
  classValidator.IsString(),
15263
15310
  classValidator.MaxLength(2048),
15264
- _ts_metadata58("design:type", String)
15311
+ _ts_metadata61("design:type", String)
15265
15312
  ], OAuthCallbackQueryDto.prototype, "scope", void 0);
15266
- _ts_decorate60([
15313
+ _ts_decorate63([
15267
15314
  classValidator.IsOptional(),
15268
15315
  classValidator.IsString(),
15269
15316
  classValidator.MaxLength(16),
15270
- _ts_metadata58("design:type", String)
15317
+ _ts_metadata61("design:type", String)
15271
15318
  ], OAuthCallbackQueryDto.prototype, "authuser", void 0);
15272
- _ts_decorate60([
15319
+ _ts_decorate63([
15273
15320
  classValidator.IsOptional(),
15274
15321
  classValidator.IsString(),
15275
15322
  classValidator.MaxLength(64),
15276
- _ts_metadata58("design:type", String)
15323
+ _ts_metadata61("design:type", String)
15277
15324
  ], OAuthCallbackQueryDto.prototype, "prompt", void 0);
15278
- _ts_decorate60([
15325
+ _ts_decorate63([
15279
15326
  classValidator.IsOptional(),
15280
15327
  classValidator.IsString(),
15281
15328
  classValidator.MaxLength(253),
15282
- _ts_metadata58("design:type", String)
15329
+ _ts_metadata61("design:type", String)
15283
15330
  ], OAuthCallbackQueryDto.prototype, "hd", void 0);
15284
- function _ts_decorate61(decorators, target, key, desc) {
15331
+ function _ts_decorate64(decorators, target, key, desc) {
15285
15332
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
15286
15333
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
15287
15334
  r = Reflect.decorate(decorators, target, key, desc);
@@ -15294,13 +15341,13 @@ function _ts_decorate61(decorators, target, key, desc) {
15294
15341
  }
15295
15342
  return c > 3 && r && Object.defineProperty(target, key, r), r;
15296
15343
  }
15297
- __name(_ts_decorate61, "_ts_decorate");
15298
- function _ts_metadata59(metadataKey, metadataValue) {
15344
+ __name(_ts_decorate64, "_ts_decorate");
15345
+ function _ts_metadata62(metadataKey, metadataValue) {
15299
15346
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
15300
15347
  return Reflect.metadata(metadataKey, metadataValue);
15301
15348
  }
15302
15349
  }
15303
- __name(_ts_metadata59, "_ts_metadata");
15350
+ __name(_ts_metadata62, "_ts_metadata");
15304
15351
  var OAuthInitiateQueryDto = class {
15305
15352
  static {
15306
15353
  __name(this, "OAuthInitiateQueryDto");
@@ -15317,7 +15364,7 @@ var OAuthInitiateQueryDto = class {
15317
15364
  */
15318
15365
  tenantId;
15319
15366
  };
15320
- _ts_decorate61([
15367
+ _ts_decorate64([
15321
15368
  classValidator.IsOptional(),
15322
15369
  classValidator.IsString(),
15323
15370
  classValidator.IsNotEmpty(),
@@ -15325,11 +15372,11 @@ _ts_decorate61([
15325
15372
  classValidator.Matches(NO_CONTROL_CHARACTERS, {
15326
15373
  message: "tenantId must not contain control characters"
15327
15374
  }),
15328
- _ts_metadata59("design:type", String)
15375
+ _ts_metadata62("design:type", String)
15329
15376
  ], OAuthInitiateQueryDto.prototype, "tenantId", void 0);
15330
15377
 
15331
15378
  // src/server/oauth/oauth.controller.ts
15332
- function _ts_decorate62(decorators, target, key, desc) {
15379
+ function _ts_decorate65(decorators, target, key, desc) {
15333
15380
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
15334
15381
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
15335
15382
  r = Reflect.decorate(decorators, target, key, desc);
@@ -15342,19 +15389,19 @@ function _ts_decorate62(decorators, target, key, desc) {
15342
15389
  }
15343
15390
  return c > 3 && r && Object.defineProperty(target, key, r), r;
15344
15391
  }
15345
- __name(_ts_decorate62, "_ts_decorate");
15346
- function _ts_metadata60(metadataKey, metadataValue) {
15392
+ __name(_ts_decorate65, "_ts_decorate");
15393
+ function _ts_metadata63(metadataKey, metadataValue) {
15347
15394
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
15348
15395
  return Reflect.metadata(metadataKey, metadataValue);
15349
15396
  }
15350
15397
  }
15351
- __name(_ts_metadata60, "_ts_metadata");
15352
- function _ts_param37(paramIndex, decorator) {
15398
+ __name(_ts_metadata63, "_ts_metadata");
15399
+ function _ts_param40(paramIndex, decorator) {
15353
15400
  return function(target, key) {
15354
15401
  decorator(target, key, paramIndex);
15355
15402
  };
15356
15403
  }
15357
- __name(_ts_param37, "_ts_param");
15404
+ __name(_ts_param40, "_ts_param");
15358
15405
  function isOAuthMfaChallenge(result) {
15359
15406
  return "mfaRequired" in result && result.mfaRequired === true;
15360
15407
  }
@@ -15572,46 +15619,46 @@ var OAuthController = class _OAuthController {
15572
15619
  });
15573
15620
  }
15574
15621
  };
15575
- _ts_decorate62([
15622
+ _ts_decorate65([
15576
15623
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.oauthInitiate),
15577
15624
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.oauthInitiate),
15578
15625
  common.Get(":provider"),
15579
- _ts_param37(0, common.Param("provider")),
15580
- _ts_param37(1, common.Query()),
15581
- _ts_param37(2, common.Req()),
15582
- _ts_param37(3, common.Res({
15626
+ _ts_param40(0, common.Param("provider")),
15627
+ _ts_param40(1, common.Query()),
15628
+ _ts_param40(2, common.Req()),
15629
+ _ts_param40(3, common.Res({
15583
15630
  passthrough: true
15584
15631
  })),
15585
- _ts_metadata60("design:type", Function),
15586
- _ts_metadata60("design:paramtypes", [
15632
+ _ts_metadata63("design:type", Function),
15633
+ _ts_metadata63("design:paramtypes", [
15587
15634
  String,
15588
15635
  typeof OAuthInitiateQueryDto === "undefined" ? Object : OAuthInitiateQueryDto,
15589
15636
  typeof Request === "undefined" ? Object : Request,
15590
15637
  typeof Response === "undefined" ? Object : Response
15591
15638
  ]),
15592
- _ts_metadata60("design:returntype", Promise)
15639
+ _ts_metadata63("design:returntype", Promise)
15593
15640
  ], OAuthController.prototype, "initiate", null);
15594
- _ts_decorate62([
15641
+ _ts_decorate65([
15595
15642
  throttler.Throttle(AUTH_THROTTLE_CONFIGS.oauthCallback),
15596
15643
  AuthRateLimit(AUTH_THROTTLE_CONFIGS.oauthCallback),
15597
15644
  common.HttpCode(common.HttpStatus.OK),
15598
15645
  common.Get(":provider/callback"),
15599
- _ts_param37(0, common.Param("provider")),
15600
- _ts_param37(1, common.Query()),
15601
- _ts_param37(2, common.Req()),
15602
- _ts_param37(3, common.Res({
15646
+ _ts_param40(0, common.Param("provider")),
15647
+ _ts_param40(1, common.Query()),
15648
+ _ts_param40(2, common.Req()),
15649
+ _ts_param40(3, common.Res({
15603
15650
  passthrough: true
15604
15651
  })),
15605
- _ts_metadata60("design:type", Function),
15606
- _ts_metadata60("design:paramtypes", [
15652
+ _ts_metadata63("design:type", Function),
15653
+ _ts_metadata63("design:paramtypes", [
15607
15654
  String,
15608
15655
  typeof OAuthCallbackQueryDto === "undefined" ? Object : OAuthCallbackQueryDto,
15609
15656
  typeof Request === "undefined" ? Object : Request,
15610
15657
  typeof Response === "undefined" ? Object : Response
15611
15658
  ]),
15612
- _ts_metadata60("design:returntype", Promise)
15659
+ _ts_metadata63("design:returntype", Promise)
15613
15660
  ], OAuthController.prototype, "callback", null);
15614
- OAuthController = _ts_decorate62([
15661
+ OAuthController = _ts_decorate65([
15615
15662
  Public(),
15616
15663
  SkipMfa(),
15617
15664
  common.UseInterceptors(NoStoreInterceptor),
@@ -15620,11 +15667,11 @@ OAuthController = _ts_decorate62([
15620
15667
  common.UsePipes(createAuthValidationPipe({
15621
15668
  forbidUnknownValues: true
15622
15669
  })),
15623
- _ts_param37(0, common.Inject(exports.OAuthService)),
15624
- _ts_param37(1, common.Inject(exports.TokenDeliveryService)),
15625
- _ts_param37(2, common.Inject(BYMAX_AUTH_OPTIONS)),
15626
- _ts_metadata60("design:type", Function),
15627
- _ts_metadata60("design:paramtypes", [
15670
+ _ts_param40(0, common.Inject(exports.OAuthService)),
15671
+ _ts_param40(1, common.Inject(exports.TokenDeliveryService)),
15672
+ _ts_param40(2, common.Inject(BYMAX_AUTH_OPTIONS)),
15673
+ _ts_metadata63("design:type", Function),
15674
+ _ts_metadata63("design:paramtypes", [
15628
15675
  typeof exports.OAuthService === "undefined" ? Object : exports.OAuthService,
15629
15676
  typeof exports.TokenDeliveryService === "undefined" ? Object : exports.TokenDeliveryService,
15630
15677
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
@@ -15763,7 +15810,7 @@ var GoogleOAuthPlugin = class {
15763
15810
  };
15764
15811
 
15765
15812
  // src/server/oauth/oauth.module.ts
15766
- function _ts_decorate63(decorators, target, key, desc) {
15813
+ function _ts_decorate66(decorators, target, key, desc) {
15767
15814
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
15768
15815
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
15769
15816
  r = Reflect.decorate(decorators, target, key, desc);
@@ -15776,7 +15823,7 @@ function _ts_decorate63(decorators, target, key, desc) {
15776
15823
  }
15777
15824
  return c > 3 && r && Object.defineProperty(target, key, r), r;
15778
15825
  }
15779
- __name(_ts_decorate63, "_ts_decorate");
15826
+ __name(_ts_decorate66, "_ts_decorate");
15780
15827
  function buildOAuthPlugins(options) {
15781
15828
  const plugins = [];
15782
15829
  if (options.oauth?.google) {
@@ -15846,7 +15893,7 @@ var OAuthModule = class _OAuthModule {
15846
15893
  };
15847
15894
  }
15848
15895
  };
15849
- OAuthModule = _ts_decorate63([
15896
+ OAuthModule = _ts_decorate66([
15850
15897
  common.Module({})
15851
15898
  ], OAuthModule);
15852
15899
 
@@ -16741,7 +16788,7 @@ function schemesFor(options, registered, cookieDelivery, bearerDelivery) {
16741
16788
  __name(schemesFor, "schemesFor");
16742
16789
 
16743
16790
  // src/server/openapi/auth-openapi.contributor.ts
16744
- function _ts_decorate64(decorators, target, key, desc) {
16791
+ function _ts_decorate67(decorators, target, key, desc) {
16745
16792
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16746
16793
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
16747
16794
  r = Reflect.decorate(decorators, target, key, desc);
@@ -16754,19 +16801,19 @@ function _ts_decorate64(decorators, target, key, desc) {
16754
16801
  }
16755
16802
  return c > 3 && r && Object.defineProperty(target, key, r), r;
16756
16803
  }
16757
- __name(_ts_decorate64, "_ts_decorate");
16758
- function _ts_metadata61(metadataKey, metadataValue) {
16804
+ __name(_ts_decorate67, "_ts_decorate");
16805
+ function _ts_metadata64(metadataKey, metadataValue) {
16759
16806
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
16760
16807
  return Reflect.metadata(metadataKey, metadataValue);
16761
16808
  }
16762
16809
  }
16763
- __name(_ts_metadata61, "_ts_metadata");
16764
- function _ts_param38(paramIndex, decorator) {
16810
+ __name(_ts_metadata64, "_ts_metadata");
16811
+ function _ts_param41(paramIndex, decorator) {
16765
16812
  return function(target, key) {
16766
16813
  decorator(target, key, paramIndex);
16767
16814
  };
16768
16815
  }
16769
- __name(_ts_param38, "_ts_param");
16816
+ __name(_ts_param41, "_ts_param");
16770
16817
  var AuthOpenApiContributor = class {
16771
16818
  static {
16772
16819
  __name(this, "AuthOpenApiContributor");
@@ -16786,18 +16833,18 @@ var AuthOpenApiContributor = class {
16786
16833
  return buildAuthOpenApiFragment(this.options, this.registered);
16787
16834
  }
16788
16835
  };
16789
- AuthOpenApiContributor = _ts_decorate64([
16836
+ AuthOpenApiContributor = _ts_decorate67([
16790
16837
  common.Injectable(),
16791
16838
  common.SetMetadata(OPENAPI_CONTRIBUTOR_METADATA, true),
16792
- _ts_param38(0, common.Inject(BYMAX_AUTH_OPTIONS)),
16793
- _ts_param38(1, common.Inject(BYMAX_AUTH_REGISTERED_CONTROLLERS)),
16794
- _ts_metadata61("design:type", Function),
16795
- _ts_metadata61("design:paramtypes", [
16839
+ _ts_param41(0, common.Inject(BYMAX_AUTH_OPTIONS)),
16840
+ _ts_param41(1, common.Inject(BYMAX_AUTH_REGISTERED_CONTROLLERS)),
16841
+ _ts_metadata64("design:type", Function),
16842
+ _ts_metadata64("design:paramtypes", [
16796
16843
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
16797
16844
  typeof RegisteredControllers === "undefined" ? Object : RegisteredControllers
16798
16845
  ])
16799
16846
  ], AuthOpenApiContributor);
16800
- function _ts_decorate65(decorators, target, key, desc) {
16847
+ function _ts_decorate68(decorators, target, key, desc) {
16801
16848
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16802
16849
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
16803
16850
  r = Reflect.decorate(decorators, target, key, desc);
@@ -16810,19 +16857,19 @@ function _ts_decorate65(decorators, target, key, desc) {
16810
16857
  }
16811
16858
  return c > 3 && r && Object.defineProperty(target, key, r), r;
16812
16859
  }
16813
- __name(_ts_decorate65, "_ts_decorate");
16814
- function _ts_metadata62(metadataKey, metadataValue) {
16860
+ __name(_ts_decorate68, "_ts_decorate");
16861
+ function _ts_metadata65(metadataKey, metadataValue) {
16815
16862
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
16816
16863
  return Reflect.metadata(metadataKey, metadataValue);
16817
16864
  }
16818
16865
  }
16819
- __name(_ts_metadata62, "_ts_metadata");
16820
- function _ts_param39(paramIndex, decorator) {
16866
+ __name(_ts_metadata65, "_ts_metadata");
16867
+ function _ts_param42(paramIndex, decorator) {
16821
16868
  return function(target, key) {
16822
16869
  decorator(target, key, paramIndex);
16823
16870
  };
16824
16871
  }
16825
- __name(_ts_param39, "_ts_param");
16872
+ __name(_ts_param42, "_ts_param");
16826
16873
  var COMMON_BASE_WORDS = [
16827
16874
  // The perennial top of every published list.
16828
16875
  "password",
@@ -17128,16 +17175,16 @@ exports.CommonPasswordChecker = class CommonPasswordChecker {
17128
17175
  return false;
17129
17176
  }
17130
17177
  };
17131
- exports.CommonPasswordChecker = _ts_decorate65([
17178
+ exports.CommonPasswordChecker = _ts_decorate68([
17132
17179
  common.Injectable(),
17133
- _ts_param39(0, common.Inject(BYMAX_AUTH_OPTIONS)),
17134
- _ts_param39(0, common.Optional()),
17135
- _ts_metadata62("design:type", Function),
17136
- _ts_metadata62("design:paramtypes", [
17180
+ _ts_param42(0, common.Inject(BYMAX_AUTH_OPTIONS)),
17181
+ _ts_param42(0, common.Optional()),
17182
+ _ts_metadata65("design:type", Function),
17183
+ _ts_metadata65("design:paramtypes", [
17137
17184
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
17138
17185
  ])
17139
17186
  ], exports.CommonPasswordChecker);
17140
- function _ts_decorate66(decorators, target, key, desc) {
17187
+ function _ts_decorate69(decorators, target, key, desc) {
17141
17188
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
17142
17189
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
17143
17190
  r = Reflect.decorate(decorators, target, key, desc);
@@ -17150,7 +17197,7 @@ function _ts_decorate66(decorators, target, key, desc) {
17150
17197
  }
17151
17198
  return c > 3 && r && Object.defineProperty(target, key, r), r;
17152
17199
  }
17153
- __name(_ts_decorate66, "_ts_decorate");
17200
+ __name(_ts_decorate69, "_ts_decorate");
17154
17201
  exports.NoOpEmailProvider = class _NoOpEmailProvider {
17155
17202
  static {
17156
17203
  __name(this, "NoOpEmailProvider");
@@ -17185,7 +17232,7 @@ exports.NoOpEmailProvider = class _NoOpEmailProvider {
17185
17232
  this.logger.log(`sendInvitation \u2192 ${maskEmail(email)} (no-op)`);
17186
17233
  }
17187
17234
  };
17188
- exports.NoOpEmailProvider = _ts_decorate66([
17235
+ exports.NoOpEmailProvider = _ts_decorate69([
17189
17236
  common.Injectable()
17190
17237
  ], exports.NoOpEmailProvider);
17191
17238
 
@@ -17199,7 +17246,7 @@ var SystemApiKeyClock = class {
17199
17246
  return /* @__PURE__ */ new Date();
17200
17247
  }
17201
17248
  };
17202
- function _ts_decorate67(decorators, target, key, desc) {
17249
+ function _ts_decorate70(decorators, target, key, desc) {
17203
17250
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
17204
17251
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
17205
17252
  r = Reflect.decorate(decorators, target, key, desc);
@@ -17212,19 +17259,19 @@ function _ts_decorate67(decorators, target, key, desc) {
17212
17259
  }
17213
17260
  return c > 3 && r && Object.defineProperty(target, key, r), r;
17214
17261
  }
17215
- __name(_ts_decorate67, "_ts_decorate");
17216
- function _ts_metadata63(metadataKey, metadataValue) {
17262
+ __name(_ts_decorate70, "_ts_decorate");
17263
+ function _ts_metadata66(metadataKey, metadataValue) {
17217
17264
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
17218
17265
  return Reflect.metadata(metadataKey, metadataValue);
17219
17266
  }
17220
17267
  }
17221
- __name(_ts_metadata63, "_ts_metadata");
17222
- function _ts_param40(paramIndex, decorator) {
17268
+ __name(_ts_metadata66, "_ts_metadata");
17269
+ function _ts_param43(paramIndex, decorator) {
17223
17270
  return function(target, key) {
17224
17271
  decorator(target, key, paramIndex);
17225
17272
  };
17226
17273
  }
17227
- __name(_ts_param40, "_ts_param");
17274
+ __name(_ts_param43, "_ts_param");
17228
17275
  var ApiKeyScopeAuditService = class {
17229
17276
  static {
17230
17277
  __name(this, "ApiKeyScopeAuditService");
@@ -17267,21 +17314,21 @@ var ApiKeyScopeAuditService = class {
17267
17314
  }
17268
17315
  }
17269
17316
  };
17270
- ApiKeyScopeAuditService = _ts_decorate67([
17317
+ ApiKeyScopeAuditService = _ts_decorate70([
17271
17318
  common.Injectable(),
17272
- _ts_param40(0, common.Inject(core.DiscoveryService)),
17273
- _ts_param40(1, common.Inject(core.MetadataScanner)),
17274
- _ts_param40(2, common.Inject(core.Reflector)),
17275
- _ts_param40(3, common.Inject(BYMAX_AUTH_OPTIONS)),
17276
- _ts_metadata63("design:type", Function),
17277
- _ts_metadata63("design:paramtypes", [
17319
+ _ts_param43(0, common.Inject(core.DiscoveryService)),
17320
+ _ts_param43(1, common.Inject(core.MetadataScanner)),
17321
+ _ts_param43(2, common.Inject(core.Reflector)),
17322
+ _ts_param43(3, common.Inject(BYMAX_AUTH_OPTIONS)),
17323
+ _ts_metadata66("design:type", Function),
17324
+ _ts_metadata66("design:paramtypes", [
17278
17325
  typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
17279
17326
  typeof core.MetadataScanner === "undefined" ? Object : core.MetadataScanner,
17280
17327
  typeof core.Reflector === "undefined" ? Object : core.Reflector,
17281
17328
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
17282
17329
  ])
17283
17330
  ], ApiKeyScopeAuditService);
17284
- function _ts_decorate68(decorators, target, key, desc) {
17331
+ function _ts_decorate71(decorators, target, key, desc) {
17285
17332
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
17286
17333
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
17287
17334
  r = Reflect.decorate(decorators, target, key, desc);
@@ -17294,19 +17341,19 @@ function _ts_decorate68(decorators, target, key, desc) {
17294
17341
  }
17295
17342
  return c > 3 && r && Object.defineProperty(target, key, r), r;
17296
17343
  }
17297
- __name(_ts_decorate68, "_ts_decorate");
17298
- function _ts_metadata64(metadataKey, metadataValue) {
17344
+ __name(_ts_decorate71, "_ts_decorate");
17345
+ function _ts_metadata67(metadataKey, metadataValue) {
17299
17346
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
17300
17347
  return Reflect.metadata(metadataKey, metadataValue);
17301
17348
  }
17302
17349
  }
17303
- __name(_ts_metadata64, "_ts_metadata");
17304
- function _ts_param41(paramIndex, decorator) {
17350
+ __name(_ts_metadata67, "_ts_metadata");
17351
+ function _ts_param44(paramIndex, decorator) {
17305
17352
  return function(target, key) {
17306
17353
  decorator(target, key, paramIndex);
17307
17354
  };
17308
17355
  }
17309
- __name(_ts_param41, "_ts_param");
17356
+ __name(_ts_param44, "_ts_param");
17310
17357
  var API_KEY_MAX_LABEL_LENGTH = 128;
17311
17358
  var API_KEY_MAX_OVERLAP_SECONDS = 2592e3;
17312
17359
  var CONTROL_CHARACTERS = /[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/u;
@@ -17367,6 +17414,11 @@ exports.ApiKeyService = class ApiKeyService {
17367
17414
  * The new key is issued first and the old one retired second, so a failure between the two
17368
17415
  * leaves both valid — the safe direction — rather than neither.
17369
17416
  *
17417
+ * With an overlap the old key's deadline is lowered through the repository's optional
17418
+ * `limitExpiry`, an atomic minimum, so concurrent rotations of one key cannot push a shorter
17419
+ * deadline back. A repository without it gets a read followed by `setExpiry`, which two
17420
+ * rotations of the same key can interleave; such a host must serialize rotation per key.
17421
+ *
17370
17422
  * @param id - The active key to replace.
17371
17423
  * @param input - The overlap and an optional expiry for the new key.
17372
17424
  * @returns The new key, plaintext once.
@@ -17396,11 +17448,15 @@ exports.ApiKeyService = class ApiKeyService {
17396
17448
  await this.repository.markRevoked(old.id, now);
17397
17449
  } else {
17398
17450
  const retireAt = new Date(now.getTime() + overlap * 1e3);
17399
- const sooner = (
17400
- // Stryker disable next-line EqualityOperator: at equal instants both arms yield a Date of the same time, so `<` and `<=` store the same expiry
17401
- old.expiresAt !== null && old.expiresAt.getTime() < retireAt.getTime() ? old.expiresAt : retireAt
17402
- );
17403
- await this.repository.setExpiry(old.id, sooner);
17451
+ if (this.repository.limitExpiry !== void 0) {
17452
+ await this.repository.limitExpiry(old.id, retireAt);
17453
+ } else {
17454
+ const sooner = (
17455
+ // Stryker disable next-line EqualityOperator: at equal instants both arms yield a Date of the same time, so `<` and `<=` store the same expiry
17456
+ old.expiresAt !== null && old.expiresAt.getTime() < retireAt.getTime() ? old.expiresAt : retireAt
17457
+ );
17458
+ await this.repository.setExpiry(old.id, sooner);
17459
+ }
17404
17460
  }
17405
17461
  return issued;
17406
17462
  }
@@ -17435,13 +17491,13 @@ exports.ApiKeyService = class ApiKeyService {
17435
17491
  return value;
17436
17492
  }
17437
17493
  };
17438
- exports.ApiKeyService = _ts_decorate68([
17494
+ exports.ApiKeyService = _ts_decorate71([
17439
17495
  common.Injectable(),
17440
- _ts_param41(0, common.Inject(BYMAX_AUTH_API_KEY_REPOSITORY)),
17441
- _ts_param41(1, common.Inject(BYMAX_AUTH_API_KEY_CLOCK)),
17442
- _ts_param41(2, common.Inject(BYMAX_AUTH_OPTIONS)),
17443
- _ts_metadata64("design:type", Function),
17444
- _ts_metadata64("design:paramtypes", [
17496
+ _ts_param44(0, common.Inject(BYMAX_AUTH_API_KEY_REPOSITORY)),
17497
+ _ts_param44(1, common.Inject(BYMAX_AUTH_API_KEY_CLOCK)),
17498
+ _ts_param44(2, common.Inject(BYMAX_AUTH_OPTIONS)),
17499
+ _ts_metadata67("design:type", Function),
17500
+ _ts_metadata67("design:paramtypes", [
17445
17501
  typeof IApiKeyRepository === "undefined" ? Object : IApiKeyRepository,
17446
17502
  typeof ApiKeyClock === "undefined" ? Object : ApiKeyClock,
17447
17503
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
@@ -17523,7 +17579,7 @@ async function assertTenantBinding(options, handshake, tenantId) {
17523
17579
  __name(assertTenantBinding, "assertTenantBinding");
17524
17580
 
17525
17581
  // src/server/services/auth-token-verifier.service.ts
17526
- function _ts_decorate69(decorators, target, key, desc) {
17582
+ function _ts_decorate72(decorators, target, key, desc) {
17527
17583
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
17528
17584
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
17529
17585
  r = Reflect.decorate(decorators, target, key, desc);
@@ -17536,19 +17592,19 @@ function _ts_decorate69(decorators, target, key, desc) {
17536
17592
  }
17537
17593
  return c > 3 && r && Object.defineProperty(target, key, r), r;
17538
17594
  }
17539
- __name(_ts_decorate69, "_ts_decorate");
17540
- function _ts_metadata65(metadataKey, metadataValue) {
17595
+ __name(_ts_decorate72, "_ts_decorate");
17596
+ function _ts_metadata68(metadataKey, metadataValue) {
17541
17597
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
17542
17598
  return Reflect.metadata(metadataKey, metadataValue);
17543
17599
  }
17544
17600
  }
17545
- __name(_ts_metadata65, "_ts_metadata");
17546
- function _ts_param42(paramIndex, decorator) {
17601
+ __name(_ts_metadata68, "_ts_metadata");
17602
+ function _ts_param45(paramIndex, decorator) {
17547
17603
  return function(target, key) {
17548
17604
  decorator(target, key, paramIndex);
17549
17605
  };
17550
17606
  }
17551
- __name(_ts_param42, "_ts_param");
17607
+ __name(_ts_param45, "_ts_param");
17552
17608
  exports.AuthTokenVerifierService = class _AuthTokenVerifierService {
17553
17609
  static {
17554
17610
  __name(this, "AuthTokenVerifierService");
@@ -17732,14 +17788,14 @@ exports.AuthTokenVerifierService = class _AuthTokenVerifierService {
17732
17788
  }
17733
17789
  }
17734
17790
  };
17735
- exports.AuthTokenVerifierService = _ts_decorate69([
17791
+ exports.AuthTokenVerifierService = _ts_decorate72([
17736
17792
  common.Injectable(),
17737
- _ts_param42(0, common.Inject(jwt.JwtService)),
17738
- _ts_param42(1, common.Inject(BYMAX_AUTH_OPTIONS)),
17739
- _ts_param42(2, common.Inject(exports.AuthRevocationService)),
17740
- _ts_param42(3, common.Inject(exports.AccountStatusService)),
17741
- _ts_metadata65("design:type", Function),
17742
- _ts_metadata65("design:paramtypes", [
17793
+ _ts_param45(0, common.Inject(jwt.JwtService)),
17794
+ _ts_param45(1, common.Inject(BYMAX_AUTH_OPTIONS)),
17795
+ _ts_param45(2, common.Inject(exports.AuthRevocationService)),
17796
+ _ts_param45(3, common.Inject(exports.AccountStatusService)),
17797
+ _ts_metadata68("design:type", Function),
17798
+ _ts_metadata68("design:paramtypes", [
17743
17799
  typeof jwt.JwtService === "undefined" ? Object : jwt.JwtService,
17744
17800
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
17745
17801
  typeof exports.AuthRevocationService === "undefined" ? Object : exports.AuthRevocationService,
@@ -17748,7 +17804,7 @@ exports.AuthTokenVerifierService = _ts_decorate69([
17748
17804
  ], exports.AuthTokenVerifierService);
17749
17805
 
17750
17806
  // src/server/bymax-auth.module.ts
17751
- function _ts_decorate70(decorators, target, key, desc) {
17807
+ function _ts_decorate73(decorators, target, key, desc) {
17752
17808
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
17753
17809
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
17754
17810
  r = Reflect.decorate(decorators, target, key, desc);
@@ -17761,7 +17817,7 @@ function _ts_decorate70(decorators, target, key, desc) {
17761
17817
  }
17762
17818
  return c > 3 && r && Object.defineProperty(target, key, r), r;
17763
17819
  }
17764
- __name(_ts_decorate70, "_ts_decorate");
17820
+ __name(_ts_decorate73, "_ts_decorate");
17765
17821
  function hasProviderToken(providers, token) {
17766
17822
  return providers.some((p) => {
17767
17823
  if (typeof p === "function") return false;
@@ -18012,6 +18068,11 @@ exports.BymaxAuthModule = class _BymaxAuthModule {
18012
18068
  exports.TokenDeliveryService,
18013
18069
  exports.WsTicketService,
18014
18070
  exports.BruteForceService,
18071
+ // Registered unconditionally: it depends only on services that are always present, and
18072
+ // it is the one place a caller re-proves the password before a sensitive change.
18073
+ MfaFlowLockoutService,
18074
+ MfaRecordService,
18075
+ exports.ReauthenticationService,
18015
18076
  exports.OtpService,
18016
18077
  // SessionService is always registered (not gated on includeSessions) because
18017
18078
  // AuthService.login() and AuthService.refresh() call session methods. Registering
@@ -18065,6 +18126,9 @@ exports.BymaxAuthModule = class _BymaxAuthModule {
18065
18126
  // Host-app modules that extend the auth flow (e.g. custom logout logic) can
18066
18127
  // inject SessionService without re-registering it.
18067
18128
  exports.SessionService,
18129
+ // Export ReauthenticationService so a host module can guard its own destructive routes
18130
+ // with the same password check and lockout counter the library uses.
18131
+ exports.ReauthenticationService,
18068
18132
  // Export MFA components when enabled — allows host-app modules to inject
18069
18133
  // MfaService and apply MfaRequiredGuard without re-registering them.
18070
18134
  // Spreads mfaProviders directly so providers and exports always stay in sync.
@@ -18153,7 +18217,7 @@ exports.BymaxAuthModule = class _BymaxAuthModule {
18153
18217
  };
18154
18218
  }
18155
18219
  };
18156
- exports.BymaxAuthModule = _ts_decorate70([
18220
+ exports.BymaxAuthModule = _ts_decorate73([
18157
18221
  common.Module({})
18158
18222
  ], exports.BymaxAuthModule);
18159
18223
 
@@ -18481,7 +18545,7 @@ var DefaultAuthEmailProvider = class _DefaultAuthEmailProvider {
18481
18545
  }
18482
18546
  }
18483
18547
  };
18484
- function _ts_decorate71(decorators, target, key, desc) {
18548
+ function _ts_decorate74(decorators, target, key, desc) {
18485
18549
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
18486
18550
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
18487
18551
  r = Reflect.decorate(decorators, target, key, desc);
@@ -18494,13 +18558,13 @@ function _ts_decorate71(decorators, target, key, desc) {
18494
18558
  }
18495
18559
  return c > 3 && r && Object.defineProperty(target, key, r), r;
18496
18560
  }
18497
- __name(_ts_decorate71, "_ts_decorate");
18498
- function _ts_metadata66(metadataKey, metadataValue) {
18561
+ __name(_ts_decorate74, "_ts_decorate");
18562
+ function _ts_metadata69(metadataKey, metadataValue) {
18499
18563
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
18500
18564
  return Reflect.metadata(metadataKey, metadataValue);
18501
18565
  }
18502
18566
  }
18503
- __name(_ts_metadata66, "_ts_metadata");
18567
+ __name(_ts_metadata69, "_ts_metadata");
18504
18568
  var HIBP_RANGE_URL = "https://api.pwnedpasswords.com/range/";
18505
18569
  var PREFIX_LENGTH = 5;
18506
18570
  var DEFAULT_TIMEOUT_MS = 1500;
@@ -18557,10 +18621,10 @@ exports.HibpBreachChecker = class _HibpBreachChecker {
18557
18621
  }
18558
18622
  }
18559
18623
  };
18560
- exports.HibpBreachChecker = _ts_decorate71([
18624
+ exports.HibpBreachChecker = _ts_decorate74([
18561
18625
  common.Injectable(),
18562
- _ts_metadata66("design:type", Function),
18563
- _ts_metadata66("design:paramtypes", [
18626
+ _ts_metadata69("design:type", Function),
18627
+ _ts_metadata69("design:paramtypes", [
18564
18628
  Number
18565
18629
  ])
18566
18630
  ], exports.HibpBreachChecker);
@@ -18573,10 +18637,10 @@ exports.AllowAllBreachChecker = class AllowAllBreachChecker {
18573
18637
  return false;
18574
18638
  }
18575
18639
  };
18576
- exports.AllowAllBreachChecker = _ts_decorate71([
18640
+ exports.AllowAllBreachChecker = _ts_decorate74([
18577
18641
  common.Injectable()
18578
18642
  ], exports.AllowAllBreachChecker);
18579
- function _ts_decorate72(decorators, target, key, desc) {
18643
+ function _ts_decorate75(decorators, target, key, desc) {
18580
18644
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
18581
18645
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
18582
18646
  r = Reflect.decorate(decorators, target, key, desc);
@@ -18589,7 +18653,7 @@ function _ts_decorate72(decorators, target, key, desc) {
18589
18653
  }
18590
18654
  return c > 3 && r && Object.defineProperty(target, key, r), r;
18591
18655
  }
18592
- __name(_ts_decorate72, "_ts_decorate");
18656
+ __name(_ts_decorate75, "_ts_decorate");
18593
18657
  exports.OptionalAuthGuard = class OptionalAuthGuard extends exports.JwtAuthGuard {
18594
18658
  static {
18595
18659
  __name(this, "OptionalAuthGuard");
@@ -18604,10 +18668,10 @@ exports.OptionalAuthGuard = class OptionalAuthGuard extends exports.JwtAuthGuard
18604
18668
  return super.canActivate(context);
18605
18669
  }
18606
18670
  };
18607
- exports.OptionalAuthGuard = _ts_decorate72([
18671
+ exports.OptionalAuthGuard = _ts_decorate75([
18608
18672
  common.Injectable()
18609
18673
  ], exports.OptionalAuthGuard);
18610
- function _ts_decorate73(decorators, target, key, desc) {
18674
+ function _ts_decorate76(decorators, target, key, desc) {
18611
18675
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
18612
18676
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
18613
18677
  r = Reflect.decorate(decorators, target, key, desc);
@@ -18620,19 +18684,19 @@ function _ts_decorate73(decorators, target, key, desc) {
18620
18684
  }
18621
18685
  return c > 3 && r && Object.defineProperty(target, key, r), r;
18622
18686
  }
18623
- __name(_ts_decorate73, "_ts_decorate");
18624
- function _ts_metadata67(metadataKey, metadataValue) {
18687
+ __name(_ts_decorate76, "_ts_decorate");
18688
+ function _ts_metadata70(metadataKey, metadataValue) {
18625
18689
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
18626
18690
  return Reflect.metadata(metadataKey, metadataValue);
18627
18691
  }
18628
18692
  }
18629
- __name(_ts_metadata67, "_ts_metadata");
18630
- function _ts_param43(paramIndex, decorator) {
18693
+ __name(_ts_metadata70, "_ts_metadata");
18694
+ function _ts_param46(paramIndex, decorator) {
18631
18695
  return function(target, key) {
18632
18696
  decorator(target, key, paramIndex);
18633
18697
  };
18634
18698
  }
18635
- __name(_ts_param43, "_ts_param");
18699
+ __name(_ts_param46, "_ts_param");
18636
18700
  exports.SelfOrAdminGuard = class SelfOrAdminGuard {
18637
18701
  static {
18638
18702
  __name(this, "SelfOrAdminGuard");
@@ -18646,6 +18710,9 @@ exports.SelfOrAdminGuard = class SelfOrAdminGuard {
18646
18710
  if (request.user == null) {
18647
18711
  throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
18648
18712
  }
18713
+ if (!capturesOnlyTokenTenant(request.params, request.user.tenantId)) {
18714
+ throw new AuthException(AUTH_ERROR_CODES.INSUFFICIENT_ROLE);
18715
+ }
18649
18716
  const rawParam = request.params["userId"] ?? request.params["id"];
18650
18717
  if (rawParam === void 0) {
18651
18718
  throw new AuthException(AUTH_ERROR_CODES.INSUFFICIENT_ROLE);
@@ -18654,6 +18721,9 @@ exports.SelfOrAdminGuard = class SelfOrAdminGuard {
18654
18721
  if (paramValue === void 0) {
18655
18722
  throw new AuthException(AUTH_ERROR_CODES.INSUFFICIENT_ROLE);
18656
18723
  }
18724
+ if (paramValue === "" || paramValue.includes("/")) {
18725
+ throw new AuthException(AUTH_ERROR_CODES.INSUFFICIENT_ROLE);
18726
+ }
18657
18727
  if (isHexLooking(paramValue) && !STRICT_SHA256_RE.test(paramValue)) {
18658
18728
  throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
18659
18729
  }
@@ -18662,14 +18732,23 @@ exports.SelfOrAdminGuard = class SelfOrAdminGuard {
18662
18732
  throw new AuthException(AUTH_ERROR_CODES.INSUFFICIENT_ROLE);
18663
18733
  }
18664
18734
  };
18665
- exports.SelfOrAdminGuard = _ts_decorate73([
18735
+ exports.SelfOrAdminGuard = _ts_decorate76([
18666
18736
  common.Injectable(),
18667
- _ts_param43(0, common.Inject(BYMAX_AUTH_OPTIONS)),
18668
- _ts_metadata67("design:type", Function),
18669
- _ts_metadata67("design:paramtypes", [
18737
+ _ts_param46(0, common.Inject(BYMAX_AUTH_OPTIONS)),
18738
+ _ts_metadata70("design:type", Function),
18739
+ _ts_metadata70("design:paramtypes", [
18670
18740
  typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
18671
18741
  ])
18672
18742
  ], exports.SelfOrAdminGuard);
18743
+ function capturesOnlyTokenTenant(params, tokenTenant) {
18744
+ const captures = [
18745
+ params.tenantId,
18746
+ params.tenant_id,
18747
+ params.tenant
18748
+ ];
18749
+ return captures.every((captured) => captured === void 0 || captured !== "" && captured === tokenTenant);
18750
+ }
18751
+ __name(capturesOnlyTokenTenant, "capturesOnlyTokenTenant");
18673
18752
  var STRICT_SHA256_RE = /^[a-f0-9]{64}$/;
18674
18753
  function resolveParamString(param) {
18675
18754
  return typeof param === "string" ? param : void 0;
@@ -18679,7 +18758,7 @@ function isHexLooking(value) {
18679
18758
  return value.length === 64 && /^[a-fA-F0-9]{64}$/.test(value);
18680
18759
  }
18681
18760
  __name(isHexLooking, "isHexLooking");
18682
- function _ts_decorate74(decorators, target, key, desc) {
18761
+ function _ts_decorate77(decorators, target, key, desc) {
18683
18762
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
18684
18763
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
18685
18764
  r = Reflect.decorate(decorators, target, key, desc);
@@ -18692,19 +18771,19 @@ function _ts_decorate74(decorators, target, key, desc) {
18692
18771
  }
18693
18772
  return c > 3 && r && Object.defineProperty(target, key, r), r;
18694
18773
  }
18695
- __name(_ts_decorate74, "_ts_decorate");
18696
- function _ts_metadata68(metadataKey, metadataValue) {
18774
+ __name(_ts_decorate77, "_ts_decorate");
18775
+ function _ts_metadata71(metadataKey, metadataValue) {
18697
18776
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
18698
18777
  return Reflect.metadata(metadataKey, metadataValue);
18699
18778
  }
18700
18779
  }
18701
- __name(_ts_metadata68, "_ts_metadata");
18702
- function _ts_param44(paramIndex, decorator) {
18780
+ __name(_ts_metadata71, "_ts_metadata");
18781
+ function _ts_param47(paramIndex, decorator) {
18703
18782
  return function(target, key) {
18704
18783
  decorator(target, key, paramIndex);
18705
18784
  };
18706
18785
  }
18707
- __name(_ts_param44, "_ts_param");
18786
+ __name(_ts_param47, "_ts_param");
18708
18787
  exports.WsJwtGuard = class WsJwtGuard {
18709
18788
  static {
18710
18789
  __name(this, "WsJwtGuard");
@@ -18768,14 +18847,14 @@ exports.WsJwtGuard = class WsJwtGuard {
18768
18847
  return true;
18769
18848
  }
18770
18849
  };
18771
- exports.WsJwtGuard = _ts_decorate74([
18850
+ exports.WsJwtGuard = _ts_decorate77([
18772
18851
  common.Injectable(),
18773
- _ts_param44(0, common.Inject(jwt.JwtService)),
18774
- _ts_param44(1, common.Inject(exports.AuthRevocationService)),
18775
- _ts_param44(2, common.Inject(exports.WsTicketService)),
18776
- _ts_param44(3, common.Inject(BYMAX_AUTH_OPTIONS)),
18777
- _ts_metadata68("design:type", Function),
18778
- _ts_metadata68("design:paramtypes", [
18852
+ _ts_param47(0, common.Inject(jwt.JwtService)),
18853
+ _ts_param47(1, common.Inject(exports.AuthRevocationService)),
18854
+ _ts_param47(2, common.Inject(exports.WsTicketService)),
18855
+ _ts_param47(3, common.Inject(BYMAX_AUTH_OPTIONS)),
18856
+ _ts_metadata71("design:type", Function),
18857
+ _ts_metadata71("design:paramtypes", [
18779
18858
  typeof jwt.JwtService === "undefined" ? Object : jwt.JwtService,
18780
18859
  typeof exports.AuthRevocationService === "undefined" ? Object : exports.AuthRevocationService,
18781
18860
  typeof exports.WsTicketService === "undefined" ? Object : exports.WsTicketService,
@@ -18815,7 +18894,7 @@ function bindingInput(handshake) {
18815
18894
  };
18816
18895
  }
18817
18896
  __name(bindingInput, "bindingInput");
18818
- function _ts_decorate75(decorators, target, key, desc) {
18897
+ function _ts_decorate78(decorators, target, key, desc) {
18819
18898
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
18820
18899
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
18821
18900
  r = Reflect.decorate(decorators, target, key, desc);
@@ -18828,7 +18907,7 @@ function _ts_decorate75(decorators, target, key, desc) {
18828
18907
  }
18829
18908
  return c > 3 && r && Object.defineProperty(target, key, r), r;
18830
18909
  }
18831
- __name(_ts_decorate75, "_ts_decorate");
18910
+ __name(_ts_decorate78, "_ts_decorate");
18832
18911
  function isAuthEnvelope(body) {
18833
18912
  if (typeof body !== "object" || body === null) return false;
18834
18913
  const error = body.error;
@@ -18947,10 +19026,10 @@ exports.AuthExceptionFilter = class _AuthExceptionFilter {
18947
19026
  });
18948
19027
  }
18949
19028
  };
18950
- exports.AuthExceptionFilter = _ts_decorate75([
19029
+ exports.AuthExceptionFilter = _ts_decorate78([
18951
19030
  common.Catch()
18952
19031
  ], exports.AuthExceptionFilter);
18953
- function _ts_decorate76(decorators, target, key, desc) {
19032
+ function _ts_decorate79(decorators, target, key, desc) {
18954
19033
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
18955
19034
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
18956
19035
  r = Reflect.decorate(decorators, target, key, desc);
@@ -18963,7 +19042,7 @@ function _ts_decorate76(decorators, target, key, desc) {
18963
19042
  }
18964
19043
  return c > 3 && r && Object.defineProperty(target, key, r), r;
18965
19044
  }
18966
- __name(_ts_decorate76, "_ts_decorate");
19045
+ __name(_ts_decorate79, "_ts_decorate");
18967
19046
  function isEmittingClient(client) {
18968
19047
  return typeof client?.emit === "function";
18969
19048
  }
@@ -19007,7 +19086,7 @@ exports.WsAuthExceptionFilter = class _WsAuthExceptionFilter {
19007
19086
  this.logger.error(`refused a request on a client this filter cannot answer: ${describeChannelStatus(exception)}`);
19008
19087
  }
19009
19088
  };
19010
- exports.WsAuthExceptionFilter = _ts_decorate76([
19089
+ exports.WsAuthExceptionFilter = _ts_decorate79([
19011
19090
  common.Catch(AuthException)
19012
19091
  ], exports.WsAuthExceptionFilter);
19013
19092
  var ServiceKey = /* @__PURE__ */ __name((...scopes) => common.applyDecorators(common.SetMetadata(IS_PUBLIC_KEY, true), ApiKeyScopes(...scopes), common.UseGuards(exports.ApiKeyGuard)), "ServiceKey");