@bymax-one/nest-auth 1.4.20 → 1.4.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +65 -1
- package/README.md +9 -8
- package/dist/server/index.cjs +1826 -1282
- package/dist/server/index.d.cts +532 -198
- package/dist/server/index.d.ts +532 -198
- package/dist/server/index.mjs +1827 -1283
- package/package.json +1 -1
package/dist/server/index.cjs
CHANGED
|
@@ -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").
|
|
4658
|
+
return value.toString("base64").replaceAll("=", "");
|
|
4661
4659
|
}
|
|
4662
4660
|
__name(toPhcB64, "toPhcB64");
|
|
4663
4661
|
function fromPhcB64(value) {
|
|
@@ -9972,6 +9970,133 @@ _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-log-context.ts
|
|
10070
|
+
var MFA_LOG_CONTEXT = "MfaService";
|
|
10071
|
+
|
|
10072
|
+
// src/server/utils/mfa-plane-tenant.ts
|
|
10073
|
+
var PLANE_TENANT_MESSAGE = "tenantId must be a non-empty value on the dashboard plane and absent on the platform plane";
|
|
10074
|
+
function assertDashboardTenant(tenantId) {
|
|
10075
|
+
if (tenantId === void 0 || tenantId === "") {
|
|
10076
|
+
throw new AuthException(AUTH_ERROR_CODES.VALIDATION, [
|
|
10077
|
+
{
|
|
10078
|
+
field: "tenantId",
|
|
10079
|
+
message: PLANE_TENANT_MESSAGE
|
|
10080
|
+
}
|
|
10081
|
+
]);
|
|
10082
|
+
}
|
|
10083
|
+
}
|
|
10084
|
+
__name(assertDashboardTenant, "assertDashboardTenant");
|
|
10085
|
+
function assertPlaneTenant(context, tenantId) {
|
|
10086
|
+
if (context === "dashboard") {
|
|
10087
|
+
assertDashboardTenant(tenantId);
|
|
10088
|
+
return;
|
|
10089
|
+
}
|
|
10090
|
+
if (tenantId !== void 0) {
|
|
10091
|
+
throw new AuthException(AUTH_ERROR_CODES.VALIDATION, [
|
|
10092
|
+
{
|
|
10093
|
+
field: "tenantId",
|
|
10094
|
+
message: PLANE_TENANT_MESSAGE
|
|
10095
|
+
}
|
|
10096
|
+
]);
|
|
10097
|
+
}
|
|
10098
|
+
}
|
|
10099
|
+
__name(assertPlaneTenant, "assertPlaneTenant");
|
|
9975
10100
|
var IV_LENGTH = 12;
|
|
9976
10101
|
var AUTH_TAG_BYTE_LENGTH = 16;
|
|
9977
10102
|
function encrypt(plaintext, keyBase64) {
|
|
@@ -10020,71 +10145,6 @@ function decrypt(ciphertext, keyBase64) {
|
|
|
10020
10145
|
]).toString("utf8");
|
|
10021
10146
|
}
|
|
10022
10147
|
__name(decrypt, "decrypt");
|
|
10023
|
-
function digestRecoveryCode(code, hmacKey) {
|
|
10024
|
-
return hmacSha256(code, hmacKey);
|
|
10025
|
-
}
|
|
10026
|
-
__name(digestRecoveryCode, "digestRecoveryCode");
|
|
10027
|
-
function generateRecoveryCodes(count, hmacKey) {
|
|
10028
|
-
const plainCodes = [];
|
|
10029
|
-
const hashedCodes = [];
|
|
10030
|
-
for (let i = 0; i < count; i++) {
|
|
10031
|
-
const hex = crypto.randomBytes(12).toString("hex");
|
|
10032
|
-
const groups = [];
|
|
10033
|
-
for (let offset = 0; offset < hex.length; offset += 4) {
|
|
10034
|
-
groups.push(hex.slice(offset, offset + 4));
|
|
10035
|
-
}
|
|
10036
|
-
const code = groups.join("-").toUpperCase();
|
|
10037
|
-
plainCodes.push(code);
|
|
10038
|
-
hashedCodes.push(digestRecoveryCode(code, hmacKey));
|
|
10039
|
-
}
|
|
10040
|
-
return {
|
|
10041
|
-
plainCodes,
|
|
10042
|
-
hashedCodes
|
|
10043
|
-
};
|
|
10044
|
-
}
|
|
10045
|
-
__name(generateRecoveryCodes, "generateRecoveryCodes");
|
|
10046
|
-
async function verifyRecoveryCode(code, hashedCodes, hmacKey, previousHmacKeys) {
|
|
10047
|
-
const candidates = [
|
|
10048
|
-
digestRecoveryCode(code, hmacKey),
|
|
10049
|
-
...previousHmacKeys.map((key) => hmacSha256(code, key))
|
|
10050
|
-
];
|
|
10051
|
-
const macMatches = [];
|
|
10052
|
-
for (const hashedCode of hashedCodes) {
|
|
10053
|
-
const hit = candidates.reduce((found, candidate) => timingSafeCompare(candidate, hashedCode) || found, false);
|
|
10054
|
-
macMatches.push(hit);
|
|
10055
|
-
}
|
|
10056
|
-
return macMatches.reduce((found, hit, index) => found === -1 && hit ? index : found, -1);
|
|
10057
|
-
}
|
|
10058
|
-
__name(verifyRecoveryCode, "verifyRecoveryCode");
|
|
10059
|
-
|
|
10060
|
-
// src/server/utils/mfa-safe-user.ts
|
|
10061
|
-
function toSafeUser3(user) {
|
|
10062
|
-
const { passwordHash: _ph, mfaSecret: _ms, mfaRecoveryCodes: _mrc, ...safe } = user;
|
|
10063
|
-
return safe;
|
|
10064
|
-
}
|
|
10065
|
-
__name(toSafeUser3, "toSafeUser");
|
|
10066
|
-
function toSafePlatformUser(admin) {
|
|
10067
|
-
const { passwordHash: _ph, mfaSecret: _ms, mfaRecoveryCodes: _mrc, ...safe } = admin;
|
|
10068
|
-
return safe;
|
|
10069
|
-
}
|
|
10070
|
-
__name(toSafePlatformUser, "toSafePlatformUser");
|
|
10071
|
-
function platformUserAsSafeUser(admin) {
|
|
10072
|
-
const safe = toSafePlatformUser(admin);
|
|
10073
|
-
return {
|
|
10074
|
-
...safe,
|
|
10075
|
-
tenantId: "",
|
|
10076
|
-
emailVerified: true
|
|
10077
|
-
};
|
|
10078
|
-
}
|
|
10079
|
-
__name(platformUserAsSafeUser, "platformUserAsSafeUser");
|
|
10080
|
-
function committedSafeUser(context, user, mfaEnabled) {
|
|
10081
|
-
const committed = {
|
|
10082
|
-
...user,
|
|
10083
|
-
mfaEnabled
|
|
10084
|
-
};
|
|
10085
|
-
return context === "platform" ? platformUserAsSafeUser(committed) : toSafeUser3(committed);
|
|
10086
|
-
}
|
|
10087
|
-
__name(committedSafeUser, "committedSafeUser");
|
|
10088
10148
|
|
|
10089
10149
|
// src/server/utils/mfa-secret-cipher.ts
|
|
10090
10150
|
function holdsSecret(stored, secretBase32, keys) {
|
|
@@ -10125,57 +10185,8 @@ function decryptWithRotation(encrypted, keys) {
|
|
|
10125
10185
|
}
|
|
10126
10186
|
__name(decryptWithRotation, "decryptWithRotation");
|
|
10127
10187
|
|
|
10128
|
-
// src/server/
|
|
10129
|
-
function
|
|
10130
|
-
if (value === null) return false;
|
|
10131
|
-
if (typeof value !== "object") return false;
|
|
10132
|
-
const v = value;
|
|
10133
|
-
return typeof v["encryptedSecret"] === "string" && typeof v["encryptedPlainCodes"] === "string" && Array.isArray(v["hashedCodes"]) && v["hashedCodes"].every((code) => typeof code === "string");
|
|
10134
|
-
}
|
|
10135
|
-
__name(isMfaSetupData, "isMfaSetupData");
|
|
10136
|
-
function parseSetupData(raw, userId, logger) {
|
|
10137
|
-
let parsed;
|
|
10138
|
-
try {
|
|
10139
|
-
parsed = JSON.parse(raw);
|
|
10140
|
-
} catch {
|
|
10141
|
-
logger.warn(`parseSetupData: pending-setup payload is not valid JSON userId=${logSafe(userId)}`);
|
|
10142
|
-
throw new AuthException(AUTH_ERROR_CODES.MFA_SETUP_REQUIRED);
|
|
10143
|
-
}
|
|
10144
|
-
if (!isMfaSetupData(parsed)) {
|
|
10145
|
-
throw new AuthException(AUTH_ERROR_CODES.MFA_SETUP_REQUIRED);
|
|
10146
|
-
}
|
|
10147
|
-
return parsed;
|
|
10148
|
-
}
|
|
10149
|
-
__name(parseSetupData, "parseSetupData");
|
|
10150
|
-
function parsePlainRecoveryCodes(raw, userId, logger) {
|
|
10151
|
-
let parsed;
|
|
10152
|
-
try {
|
|
10153
|
-
parsed = JSON.parse(raw);
|
|
10154
|
-
} catch {
|
|
10155
|
-
logger.warn(`parsePlainRecoveryCodes: decrypted payload is not valid JSON userId=${logSafe(userId)}`);
|
|
10156
|
-
throw new AuthException(AUTH_ERROR_CODES.MFA_SETUP_REQUIRED);
|
|
10157
|
-
}
|
|
10158
|
-
if (!Array.isArray(parsed) || parsed.some((code) => typeof code !== "string")) {
|
|
10159
|
-
throw new AuthException(AUTH_ERROR_CODES.MFA_SETUP_REQUIRED);
|
|
10160
|
-
}
|
|
10161
|
-
return parsed;
|
|
10162
|
-
}
|
|
10163
|
-
__name(parsePlainRecoveryCodes, "parsePlainRecoveryCodes");
|
|
10164
|
-
|
|
10165
|
-
// src/server/utils/run-detached.ts
|
|
10166
|
-
function runDetached(logger, run, failure) {
|
|
10167
|
-
try {
|
|
10168
|
-
void Promise.resolve(run()).catch((err) => {
|
|
10169
|
-
logger.error(`${failure}: ${describeChannelStatus(err)}`);
|
|
10170
|
-
});
|
|
10171
|
-
} catch (err) {
|
|
10172
|
-
logger.error(`${failure}: ${describeChannelStatus(err)}`);
|
|
10173
|
-
}
|
|
10174
|
-
}
|
|
10175
|
-
__name(runDetached, "runDetached");
|
|
10176
|
-
|
|
10177
|
-
// src/server/services/mfa.service.ts
|
|
10178
|
-
function _ts_decorate37(decorators, target, key, desc) {
|
|
10188
|
+
// src/server/services/mfa-record.service.ts
|
|
10189
|
+
function _ts_decorate38(decorators, target, key, desc) {
|
|
10179
10190
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10180
10191
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
10181
10192
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -10188,25 +10199,19 @@ function _ts_decorate37(decorators, target, key, desc) {
|
|
|
10188
10199
|
}
|
|
10189
10200
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10190
10201
|
}
|
|
10191
|
-
__name(
|
|
10192
|
-
function
|
|
10202
|
+
__name(_ts_decorate38, "_ts_decorate");
|
|
10203
|
+
function _ts_metadata37(metadataKey, metadataValue) {
|
|
10193
10204
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
10194
10205
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
10195
10206
|
}
|
|
10196
10207
|
}
|
|
10197
|
-
__name(
|
|
10198
|
-
function
|
|
10208
|
+
__name(_ts_metadata37, "_ts_metadata");
|
|
10209
|
+
function _ts_param22(paramIndex, decorator) {
|
|
10199
10210
|
return function(target, key) {
|
|
10200
10211
|
decorator(target, key, paramIndex);
|
|
10201
10212
|
};
|
|
10202
10213
|
}
|
|
10203
|
-
__name(
|
|
10204
|
-
var PLATFORM_EMAIL_TENANT = "platform";
|
|
10205
|
-
function emailTenantOf(user) {
|
|
10206
|
-
return "tenantId" in user ? user.tenantId : PLATFORM_EMAIL_TENANT;
|
|
10207
|
-
}
|
|
10208
|
-
__name(emailTenantOf, "emailTenantOf");
|
|
10209
|
-
var MFA_SETUP_TTL_SECONDS = 600;
|
|
10214
|
+
__name(_ts_param22, "_ts_param");
|
|
10210
10215
|
var RECOVERY_CODE_CLAIM_TTL_SECONDS = 300;
|
|
10211
10216
|
function totpAntiReplayTtlSeconds(window) {
|
|
10212
10217
|
const effective = Math.min(Math.max(window, 0), MAX_VERIFY_WINDOW);
|
|
@@ -10218,51 +10223,21 @@ var RELEASE_LOCK_LUA = `if redis.call('GET', KEYS[1]) == ARGV[1] then
|
|
|
10218
10223
|
return redis.call('DEL', KEYS[1])
|
|
10219
10224
|
end
|
|
10220
10225
|
return 0`;
|
|
10221
|
-
var
|
|
10222
|
-
var PLANE_TENANT_MESSAGE = "tenantId must be a non-empty value on the dashboard plane and absent on the platform plane";
|
|
10223
|
-
exports.MfaService = class _MfaService {
|
|
10226
|
+
var MfaRecordService = class {
|
|
10224
10227
|
static {
|
|
10225
|
-
__name(this, "
|
|
10228
|
+
__name(this, "MfaRecordService");
|
|
10226
10229
|
}
|
|
10227
10230
|
options;
|
|
10228
10231
|
userRepo;
|
|
10229
10232
|
platformUserRepo;
|
|
10230
10233
|
redis;
|
|
10231
|
-
|
|
10232
|
-
|
|
10233
|
-
passwordService;
|
|
10234
|
-
sessionService;
|
|
10235
|
-
emailProvider;
|
|
10236
|
-
hooks;
|
|
10237
|
-
logger = new common.Logger(_MfaService.name);
|
|
10238
|
-
constructor(options, userRepo, platformUserRepo, redis, tokenManager, bruteForce, passwordService, sessionService, emailProvider, hooks) {
|
|
10234
|
+
logger = new common.Logger(MFA_LOG_CONTEXT);
|
|
10235
|
+
constructor(options, userRepo, platformUserRepo, redis) {
|
|
10239
10236
|
this.options = options;
|
|
10240
10237
|
this.userRepo = userRepo;
|
|
10241
10238
|
this.platformUserRepo = platformUserRepo;
|
|
10242
10239
|
this.redis = redis;
|
|
10243
|
-
this.tokenManager = tokenManager;
|
|
10244
|
-
this.bruteForce = bruteForce;
|
|
10245
|
-
this.passwordService = passwordService;
|
|
10246
|
-
this.sessionService = sessionService;
|
|
10247
|
-
this.emailProvider = emailProvider;
|
|
10248
|
-
this.hooks = hooks;
|
|
10249
10240
|
}
|
|
10250
|
-
// ---------------------------------------------------------------------------
|
|
10251
|
-
// Private accessor — options.mfa is guaranteed non-null when service is active
|
|
10252
|
-
// ---------------------------------------------------------------------------
|
|
10253
|
-
/**
|
|
10254
|
-
* Returns the resolved MFA configuration. `options.mfa` is always present when `MfaService` is registered.
|
|
10255
|
-
*
|
|
10256
|
-
* `options.mfa` is always present when `MfaService` is registered — the module
|
|
10257
|
-
* only registers the service when `mfa` is configured. The single suppression
|
|
10258
|
-
* here eliminates repetitive `!` assertions throughout the class.
|
|
10259
|
-
*/
|
|
10260
|
-
get mfaOptions() {
|
|
10261
|
-
return this.options.mfa;
|
|
10262
|
-
}
|
|
10263
|
-
// ---------------------------------------------------------------------------
|
|
10264
|
-
// Private crypto helpers
|
|
10265
|
-
// ---------------------------------------------------------------------------
|
|
10266
10241
|
/**
|
|
10267
10242
|
* Store the TOTP secret re-encrypted under the current key.
|
|
10268
10243
|
*
|
|
@@ -10280,14 +10255,15 @@ exports.MfaService = class _MfaService {
|
|
|
10280
10255
|
* @param context - Which identity plane the account belongs to.
|
|
10281
10256
|
* @param secretBase32 - The decrypted secret.
|
|
10282
10257
|
* @param tenantId - The tenant the account belongs to, so the write is scoped like the read.
|
|
10258
|
+
* @param keys - The secret-cipher keys; the secret is written under the current one.
|
|
10283
10259
|
*/
|
|
10284
|
-
async reencryptSecret(userId, context, secretBase32, tenantId) {
|
|
10260
|
+
async reencryptSecret(userId, context, secretBase32, tenantId, keys) {
|
|
10285
10261
|
try {
|
|
10286
|
-
await this.
|
|
10287
|
-
if (!current.mfaEnabled || !holdsSecret(current.mfaSecret, secretBase32,
|
|
10262
|
+
await this.transition(context, userId, tenantId, (current) => {
|
|
10263
|
+
if (!current.mfaEnabled || !holdsSecret(current.mfaSecret, secretBase32, keys)) return null;
|
|
10288
10264
|
return {
|
|
10289
10265
|
mfaEnabled: true,
|
|
10290
|
-
mfaSecret: encryptMfaSecret(secretBase32,
|
|
10266
|
+
mfaSecret: encryptMfaSecret(secretBase32, keys),
|
|
10291
10267
|
mfaRecoveryCodes: current.mfaRecoveryCodes ?? []
|
|
10292
10268
|
};
|
|
10293
10269
|
});
|
|
@@ -10332,7 +10308,7 @@ exports.MfaService = class _MfaService {
|
|
|
10332
10308
|
* @returns `true` when a write happened, `false` when `mutate` abandoned the transition.
|
|
10333
10309
|
* @throws {@link AuthException} `MFA_STATE_CONFLICT` when another transition holds the lock.
|
|
10334
10310
|
*/
|
|
10335
|
-
async
|
|
10311
|
+
async transition(context, userId, tenantId, mutate) {
|
|
10336
10312
|
const scopedLockKey = `mfalock:${hmacSha256(userSubject(context, userId, tenantId), this.options.hmacKey)}`;
|
|
10337
10313
|
const legacyLockKey = `mfalock:${hmacSha256(`${context}:${userId}`, this.options.hmacKey)}`;
|
|
10338
10314
|
const acquireLegacy = legacyLockKey !== scopedLockKey;
|
|
@@ -10349,7 +10325,7 @@ exports.MfaService = class _MfaService {
|
|
|
10349
10325
|
throw new AuthException(AUTH_ERROR_CODES.MFA_STATE_CONFLICT);
|
|
10350
10326
|
}
|
|
10351
10327
|
try {
|
|
10352
|
-
const current = await this.
|
|
10328
|
+
const current = await this.loadAccount(context, userId, tenantId);
|
|
10353
10329
|
const update = mutate(current);
|
|
10354
10330
|
if (update === null) return false;
|
|
10355
10331
|
const write = {
|
|
@@ -10360,7 +10336,7 @@ exports.MfaService = class _MfaService {
|
|
|
10360
10336
|
if (context === "platform" && this.platformUserRepo) {
|
|
10361
10337
|
await this.platformUserRepo.updateMfa(userId, write);
|
|
10362
10338
|
} else {
|
|
10363
|
-
|
|
10339
|
+
assertDashboardTenant(tenantId);
|
|
10364
10340
|
await this.userRepo.updateMfa({
|
|
10365
10341
|
id: userId,
|
|
10366
10342
|
tenantId,
|
|
@@ -10413,265 +10389,427 @@ exports.MfaService = class _MfaService {
|
|
|
10413
10389
|
const claimKey = `rcu:${hmacSha256(`${userSubject(context, userId, tenantId)}:${code}`, this.options.hmacKey)}`;
|
|
10414
10390
|
return await this.redis.setnx(claimKey, RECOVERY_CODE_CLAIM_TTL_SECONDS);
|
|
10415
10391
|
}
|
|
10416
|
-
// ---------------------------------------------------------------------------
|
|
10417
|
-
// setup — TOTP secret generation, idempotent key reservation, recovery codes
|
|
10418
|
-
// ---------------------------------------------------------------------------
|
|
10419
10392
|
/**
|
|
10420
|
-
*
|
|
10393
|
+
* Verifies a TOTP code and enforces anti-replay within the validation window.
|
|
10421
10394
|
*
|
|
10422
|
-
*
|
|
10423
|
-
*
|
|
10424
|
-
*
|
|
10395
|
+
* Stores a Redis key `tu:{hmac}` where `hmac = hmacSha256("{userSubject}:{code}", hmacKey)` —
|
|
10396
|
+
* so the marker is scoped to the plane and, on the dashboard plane, to the tenant. A second
|
|
10397
|
+
* submission of the same code within the TTL is rejected as a replay. Binding the marker to
|
|
10398
|
+
* both the subject and the code value prevents code disclosure in Redis and cross-user,
|
|
10399
|
+
* cross-tenant and cross-plane replay alike.
|
|
10425
10400
|
*
|
|
10426
|
-
*
|
|
10427
|
-
*
|
|
10428
|
-
*
|
|
10401
|
+
* A second marker under the plane-only preimage `{context}:{userId}:{code}` is written and
|
|
10402
|
+
* required alongside it; see the call site for why both must be fresh while pods of two
|
|
10403
|
+
* versions are live.
|
|
10429
10404
|
*
|
|
10430
|
-
* @
|
|
10431
|
-
* @param context - Which repository to use: `'dashboard'` (default) or `'platform'`.
|
|
10432
|
-
* @returns Setup result containing the secret, QR URI, and plain recovery codes.
|
|
10433
|
-
* @throws `MFA_ALREADY_ENABLED` if MFA is already active on the account.
|
|
10434
|
-
* @throws `MFA_NOT_ENABLED` if `context === 'platform'` and the platform user
|
|
10435
|
-
* repository was not configured at module registration. The error code is
|
|
10436
|
-
* reused (rather than introducing a new one) because the consumer-facing
|
|
10437
|
-
* meaning is the same: "platform MFA cannot operate".
|
|
10405
|
+
* @returns `true` if the code is valid and has not been replayed, `false` otherwise.
|
|
10438
10406
|
*/
|
|
10439
|
-
async
|
|
10440
|
-
|
|
10441
|
-
|
|
10407
|
+
async verifyTotpWithAntiReplay(context, userId, secretBase32, code, window, tenantId) {
|
|
10408
|
+
if (!verifyTotp(secretBase32, code, window)) return false;
|
|
10409
|
+
const ttl = totpAntiReplayTtlSeconds(window);
|
|
10410
|
+
const scopedReplayKey = `tu:${hmacSha256(`${userSubject(context, userId, tenantId)}:${code}`, this.options.hmacKey)}`;
|
|
10411
|
+
const legacyReplayKey = `tu:${hmacSha256(`${context}:${userId}:${code}`, this.options.hmacKey)}`;
|
|
10412
|
+
const scopedIsNew = await this.redis.setnx(scopedReplayKey, ttl);
|
|
10413
|
+
if (scopedReplayKey === legacyReplayKey) return scopedIsNew;
|
|
10414
|
+
const legacyIsNew = await this.redis.setnx(legacyReplayKey, ttl);
|
|
10415
|
+
return scopedIsNew && legacyIsNew;
|
|
10416
|
+
}
|
|
10417
|
+
/**
|
|
10418
|
+
* Fetches a user from the correct repository based on the MFA context, and refuses one whose
|
|
10419
|
+
* account is blocked.
|
|
10420
|
+
*
|
|
10421
|
+
* The status gate lives here rather than in each caller because every entry point that
|
|
10422
|
+
* reaches this method changes or spends an authentication factor, and every one of them
|
|
10423
|
+
* must refuse a suspended or banned account. A gate in `challenge` alone would leave `setup`,
|
|
10424
|
+
* `verifyAndEnable`, `disable` and `regenerateRecoveryCodes` open: an operator who suspended a
|
|
10425
|
+
* compromised account would buy nothing against an attacker still holding an unexpired access
|
|
10426
|
+
* token, who could turn the second factor off — or enrol their own authenticator over it — for
|
|
10427
|
+
* the token's remaining lifetime. Nothing else covers that window: no status change bumps the
|
|
10428
|
+
* token epoch, so the per-request check is the only defence, and neither MFA controller
|
|
10429
|
+
* composes `UserStatusGuard` (the platform plane has no status guard at all). Every other
|
|
10430
|
+
* authority-bearing route in the library does gate on status; changing an authentication
|
|
10431
|
+
* factor is at least as privileged as minting an invitation.
|
|
10432
|
+
*
|
|
10433
|
+
* Gating the fetch rather than the callers is deliberate: a method added later inherits the
|
|
10434
|
+
* check instead of having to remember it.
|
|
10435
|
+
*
|
|
10436
|
+
* @param context - Which identity plane the caller is acting on.
|
|
10437
|
+
* @param userId - The subject taken from the verified token.
|
|
10438
|
+
* @param tenantId - The tenant the caller was authenticated in, on the dashboard plane;
|
|
10439
|
+
* absent on the platform plane, whose admins belong to none.
|
|
10440
|
+
* @returns The account record, guaranteed to be in good standing.
|
|
10441
|
+
* @throws `TOKEN_INVALID` if the user is not found.
|
|
10442
|
+
* @throws {@link AuthException} the status error when the account is blocked.
|
|
10443
|
+
*/
|
|
10444
|
+
async loadAccount(context, userId, tenantId) {
|
|
10445
|
+
if (context === "dashboard") {
|
|
10446
|
+
assertDashboardTenant(tenantId);
|
|
10447
|
+
const user = await this.userRepo.findById({
|
|
10448
|
+
id: userId,
|
|
10449
|
+
tenantId
|
|
10450
|
+
});
|
|
10451
|
+
if (!user) throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
|
|
10452
|
+
assertNotBlocked(user.status, this.options.blockedStatuses);
|
|
10453
|
+
return user;
|
|
10454
|
+
}
|
|
10455
|
+
if (!this.platformUserRepo) {
|
|
10456
|
+
throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
|
|
10457
|
+
}
|
|
10458
|
+
const admin = await this.platformUserRepo.findById(userId);
|
|
10459
|
+
if (!admin) throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
|
|
10460
|
+
assertNotBlocked(admin.status, this.options.blockedStatuses);
|
|
10461
|
+
return admin;
|
|
10462
|
+
}
|
|
10463
|
+
};
|
|
10464
|
+
MfaRecordService = _ts_decorate38([
|
|
10465
|
+
common.Injectable(),
|
|
10466
|
+
_ts_param22(0, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
10467
|
+
_ts_param22(1, common.Inject(BYMAX_AUTH_USER_REPOSITORY)),
|
|
10468
|
+
_ts_param22(2, common.Optional()),
|
|
10469
|
+
_ts_param22(2, common.Inject(BYMAX_AUTH_PLATFORM_USER_REPOSITORY)),
|
|
10470
|
+
_ts_param22(3, common.Inject(AuthRedisService)),
|
|
10471
|
+
_ts_metadata37("design:type", Function),
|
|
10472
|
+
_ts_metadata37("design:paramtypes", [
|
|
10473
|
+
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
|
|
10474
|
+
typeof IUserRepository === "undefined" ? Object : IUserRepository,
|
|
10475
|
+
Object,
|
|
10476
|
+
typeof AuthRedisService === "undefined" ? Object : AuthRedisService
|
|
10477
|
+
])
|
|
10478
|
+
], MfaRecordService);
|
|
10479
|
+
var DEFAULT_RECOVERY_CODE_COUNT = 8;
|
|
10480
|
+
function digestRecoveryCode(code, hmacKey) {
|
|
10481
|
+
return hmacSha256(code, hmacKey);
|
|
10482
|
+
}
|
|
10483
|
+
__name(digestRecoveryCode, "digestRecoveryCode");
|
|
10484
|
+
function generateRecoveryCodes(count, hmacKey) {
|
|
10485
|
+
const plainCodes = [];
|
|
10486
|
+
const hashedCodes = [];
|
|
10487
|
+
for (let i = 0; i < count; i++) {
|
|
10488
|
+
const hex = crypto.randomBytes(12).toString("hex");
|
|
10489
|
+
const groups = [];
|
|
10490
|
+
for (let offset = 0; offset < hex.length; offset += 4) {
|
|
10491
|
+
groups.push(hex.slice(offset, offset + 4));
|
|
10492
|
+
}
|
|
10493
|
+
const code = groups.join("-").toUpperCase();
|
|
10494
|
+
plainCodes.push(code);
|
|
10495
|
+
hashedCodes.push(digestRecoveryCode(code, hmacKey));
|
|
10496
|
+
}
|
|
10497
|
+
return {
|
|
10498
|
+
plainCodes,
|
|
10499
|
+
hashedCodes
|
|
10500
|
+
};
|
|
10501
|
+
}
|
|
10502
|
+
__name(generateRecoveryCodes, "generateRecoveryCodes");
|
|
10503
|
+
async function verifyRecoveryCode(code, hashedCodes, hmacKey, previousHmacKeys) {
|
|
10504
|
+
const candidates = [
|
|
10505
|
+
digestRecoveryCode(code, hmacKey),
|
|
10506
|
+
...previousHmacKeys.map((key) => hmacSha256(code, key))
|
|
10507
|
+
];
|
|
10508
|
+
const macMatches = [];
|
|
10509
|
+
for (const hashedCode of hashedCodes) {
|
|
10510
|
+
const hit = candidates.reduce((found, candidate) => timingSafeCompare(candidate, hashedCode) || found, false);
|
|
10511
|
+
macMatches.push(hit);
|
|
10512
|
+
}
|
|
10513
|
+
return macMatches.reduce((found, hit, index) => found === -1 && hit ? index : found, -1);
|
|
10514
|
+
}
|
|
10515
|
+
__name(verifyRecoveryCode, "verifyRecoveryCode");
|
|
10516
|
+
|
|
10517
|
+
// src/server/utils/mfa-safe-user.ts
|
|
10518
|
+
function toSafeUser3(user) {
|
|
10519
|
+
const { passwordHash: _ph, mfaSecret: _ms, mfaRecoveryCodes: _mrc, ...safe } = user;
|
|
10520
|
+
return safe;
|
|
10521
|
+
}
|
|
10522
|
+
__name(toSafeUser3, "toSafeUser");
|
|
10523
|
+
function toSafePlatformUser(admin) {
|
|
10524
|
+
const { passwordHash: _ph, mfaSecret: _ms, mfaRecoveryCodes: _mrc, ...safe } = admin;
|
|
10525
|
+
return safe;
|
|
10526
|
+
}
|
|
10527
|
+
__name(toSafePlatformUser, "toSafePlatformUser");
|
|
10528
|
+
function platformUserAsSafeUser(admin) {
|
|
10529
|
+
const safe = toSafePlatformUser(admin);
|
|
10530
|
+
return {
|
|
10531
|
+
...safe,
|
|
10532
|
+
tenantId: "",
|
|
10533
|
+
emailVerified: true
|
|
10534
|
+
};
|
|
10535
|
+
}
|
|
10536
|
+
__name(platformUserAsSafeUser, "platformUserAsSafeUser");
|
|
10537
|
+
function committedSafeUser(context, user, mfaEnabled) {
|
|
10538
|
+
const committed = {
|
|
10539
|
+
...user,
|
|
10540
|
+
mfaEnabled
|
|
10541
|
+
};
|
|
10542
|
+
return context === "platform" ? platformUserAsSafeUser(committed) : toSafeUser3(committed);
|
|
10543
|
+
}
|
|
10544
|
+
__name(committedSafeUser, "committedSafeUser");
|
|
10545
|
+
|
|
10546
|
+
// src/server/utils/run-detached.ts
|
|
10547
|
+
function runDetached(logger, run, failure) {
|
|
10548
|
+
try {
|
|
10549
|
+
void Promise.resolve(run()).catch((err) => {
|
|
10550
|
+
logger.error(`${failure}: ${describeChannelStatus(err)}`);
|
|
10551
|
+
});
|
|
10552
|
+
} catch (err) {
|
|
10553
|
+
logger.error(`${failure}: ${describeChannelStatus(err)}`);
|
|
10554
|
+
}
|
|
10555
|
+
}
|
|
10556
|
+
__name(runDetached, "runDetached");
|
|
10557
|
+
|
|
10558
|
+
// src/server/services/mfa-challenge.service.ts
|
|
10559
|
+
function _ts_decorate39(decorators, target, key, desc) {
|
|
10560
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10561
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
10562
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
10563
|
+
} else {
|
|
10564
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
10565
|
+
if (d = decorators[i]) {
|
|
10566
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10567
|
+
}
|
|
10568
|
+
}
|
|
10569
|
+
}
|
|
10570
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10571
|
+
}
|
|
10572
|
+
__name(_ts_decorate39, "_ts_decorate");
|
|
10573
|
+
function _ts_metadata38(metadataKey, metadataValue) {
|
|
10574
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
10575
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
10576
|
+
}
|
|
10577
|
+
}
|
|
10578
|
+
__name(_ts_metadata38, "_ts_metadata");
|
|
10579
|
+
function _ts_param23(paramIndex, decorator) {
|
|
10580
|
+
return function(target, key) {
|
|
10581
|
+
decorator(target, key, paramIndex);
|
|
10582
|
+
};
|
|
10583
|
+
}
|
|
10584
|
+
__name(_ts_param23, "_ts_param");
|
|
10585
|
+
function spliceSpentCode(current, existingCodes, recoveryIndex, opened, mfa) {
|
|
10586
|
+
if (!current.mfaEnabled) return null;
|
|
10587
|
+
if (!holdsSecret(current.mfaSecret, opened.secret, mfa)) return null;
|
|
10588
|
+
const currentCodes = current.mfaRecoveryCodes ?? [];
|
|
10589
|
+
const spentDigest = existingCodes[recoveryIndex] ?? "";
|
|
10590
|
+
const liveIndex = currentCodes.indexOf(spentDigest);
|
|
10591
|
+
if (liveIndex < 0) return null;
|
|
10592
|
+
const updatedCodes = [
|
|
10593
|
+
...currentCodes
|
|
10594
|
+
];
|
|
10595
|
+
updatedCodes.splice(liveIndex, 1);
|
|
10596
|
+
return {
|
|
10597
|
+
mfaEnabled: true,
|
|
10598
|
+
mfaSecret: opened.stale ? encryptMfaSecret(opened.secret, mfa) : current.mfaSecret,
|
|
10599
|
+
mfaRecoveryCodes: updatedCodes
|
|
10600
|
+
};
|
|
10601
|
+
}
|
|
10602
|
+
__name(spliceSpentCode, "spliceSpentCode");
|
|
10603
|
+
var MfaChallengeService = class {
|
|
10604
|
+
static {
|
|
10605
|
+
__name(this, "MfaChallengeService");
|
|
10606
|
+
}
|
|
10607
|
+
options;
|
|
10608
|
+
userRepo;
|
|
10609
|
+
platformUserRepo;
|
|
10610
|
+
tokenManager;
|
|
10611
|
+
flowLockout;
|
|
10612
|
+
records;
|
|
10613
|
+
sessionService;
|
|
10614
|
+
hooks;
|
|
10615
|
+
logger = new common.Logger(MFA_LOG_CONTEXT);
|
|
10616
|
+
constructor(options, userRepo, platformUserRepo, tokenManager, flowLockout, records, sessionService, hooks) {
|
|
10617
|
+
this.options = options;
|
|
10618
|
+
this.userRepo = userRepo;
|
|
10619
|
+
this.platformUserRepo = platformUserRepo;
|
|
10620
|
+
this.tokenManager = tokenManager;
|
|
10621
|
+
this.flowLockout = flowLockout;
|
|
10622
|
+
this.records = records;
|
|
10623
|
+
this.sessionService = sessionService;
|
|
10624
|
+
this.hooks = hooks;
|
|
10625
|
+
}
|
|
10626
|
+
/**
|
|
10627
|
+
* Validates a TOTP or recovery code and exchanges the MFA temp token for full
|
|
10628
|
+
* access tokens.
|
|
10629
|
+
*
|
|
10630
|
+
* Handles both `'dashboard'` and `'platform'` contexts. Applies brute-force
|
|
10631
|
+
* protection per-user. TOTP codes include anti-replay protection via a short-lived
|
|
10632
|
+
* Redis key keyed on an HMAC of the code and user ID.
|
|
10633
|
+
*
|
|
10634
|
+
* The order is part of the contract: the temp token is verified but NOT consumed until the code
|
|
10635
|
+
* passes, so a mistyped digit is retryable (`MFA_INVALID_CODE`) rather than a dead end
|
|
10636
|
+
* (`MFA_TEMP_TOKEN_INVALID`); the lockout counter caps how many wrong codes one token can try;
|
|
10637
|
+
* and the consume must win before a session is issued.
|
|
10638
|
+
*
|
|
10639
|
+
* @param mfaTempToken - Short-lived MFA challenge JWT issued at login.
|
|
10640
|
+
* @param code - 6-digit TOTP code or `dddd-dddd-dddd` recovery code.
|
|
10641
|
+
* @param ip - Client IP address for session audit.
|
|
10642
|
+
* @param userAgent - User-Agent header for session description.
|
|
10643
|
+
* @param mfa - The resolved MFA configuration (cipher keys and TOTP window).
|
|
10644
|
+
* @returns `AuthResult` for dashboard context, `PlatformAuthResult` for platform context.
|
|
10645
|
+
* @throws `MFA_TEMP_TOKEN_INVALID` if the token is invalid or already consumed.
|
|
10646
|
+
* @throws `ACCOUNT_LOCKED` if the brute-force threshold has been reached.
|
|
10647
|
+
* @throws `MFA_INVALID_CODE` if the submitted code is incorrect.
|
|
10648
|
+
*/
|
|
10649
|
+
async challenge(mfaTempToken, code, ip, userAgent, mfa) {
|
|
10650
|
+
const { userId, context, tenantId, jti: tempTokenJti } = await this.tokenManager.verifyMfaTempToken(mfaTempToken);
|
|
10651
|
+
const scope = {
|
|
10652
|
+
userId,
|
|
10653
|
+
context,
|
|
10654
|
+
tenantId
|
|
10655
|
+
};
|
|
10656
|
+
await this.assertNotLocked(scope);
|
|
10657
|
+
const user = await this.records.loadAccount(context, userId, tenantId);
|
|
10658
|
+
if (!user.mfaEnabled || !user.mfaSecret) {
|
|
10442
10659
|
throw new AuthException(AUTH_ERROR_CODES.MFA_NOT_ENABLED);
|
|
10443
10660
|
}
|
|
10444
|
-
const
|
|
10445
|
-
|
|
10446
|
-
await this.
|
|
10447
|
-
|
|
10448
|
-
|
|
10449
|
-
|
|
10450
|
-
|
|
10451
|
-
|
|
10452
|
-
|
|
10453
|
-
|
|
10454
|
-
|
|
10661
|
+
const opened = decryptWithRotation(user.mfaSecret, mfa);
|
|
10662
|
+
const { valid, recoveryIndex } = await this.checkCode(user, scope, opened.secret, code, mfa);
|
|
10663
|
+
if (!valid) await this.refuseWrongCode(scope);
|
|
10664
|
+
await this.flowLockout.reset("challenge", context, userId, tenantId);
|
|
10665
|
+
if (!await this.tokenManager.consumeMfaTempToken(tempTokenJti)) {
|
|
10666
|
+
throw new AuthException(AUTH_ERROR_CODES.MFA_TEMP_TOKEN_INVALID);
|
|
10667
|
+
}
|
|
10668
|
+
await this.settleRecovery(user, scope, opened, recoveryIndex, mfa);
|
|
10669
|
+
this.logger.log(`challenge: MFA challenge passed userId=${logSafe(userId)} context=${context}`);
|
|
10670
|
+
return context === "dashboard" ? this.issueDashboardSession(user, userId, ip, userAgent) : this.issuePlatformSession(user, userId, ip, userAgent);
|
|
10671
|
+
}
|
|
10672
|
+
/**
|
|
10673
|
+
* Refuses a challenge for an account at its failure ceiling.
|
|
10674
|
+
*
|
|
10675
|
+
* The 'challenge' counter is namespaced away from 'disable', so a pre-auth attacker holding only
|
|
10676
|
+
* a temp token cannot lock the user out of `disable()`, and away from the other identity plane,
|
|
10677
|
+
* whose id space may collide.
|
|
10678
|
+
*
|
|
10679
|
+
* @param scope - The plane, account and tenant the challenge belongs to.
|
|
10680
|
+
* @throws {@link AuthException} `ACCOUNT_LOCKED` at the ceiling.
|
|
10681
|
+
*/
|
|
10682
|
+
async assertNotLocked(scope) {
|
|
10683
|
+
const { userId, context, tenantId } = scope;
|
|
10684
|
+
if (await this.flowLockout.isLockedOut("challenge", context, userId, tenantId)) {
|
|
10685
|
+
this.logger.warn(`challenge: account locked userId=${logSafe(userId)}`);
|
|
10686
|
+
throw new AuthException(AUTH_ERROR_CODES.ACCOUNT_LOCKED);
|
|
10687
|
+
}
|
|
10688
|
+
}
|
|
10689
|
+
/**
|
|
10690
|
+
* Counts a wrong code and refuses it. The temp token stays alive: the user can retry under it
|
|
10691
|
+
* until the lockout surfaces `ACCOUNT_LOCKED`.
|
|
10692
|
+
*
|
|
10693
|
+
* @param scope - The plane, account and tenant the challenge belongs to.
|
|
10694
|
+
* @throws {@link AuthException} `MFA_INVALID_CODE`, always.
|
|
10695
|
+
*/
|
|
10696
|
+
async refuseWrongCode(scope) {
|
|
10697
|
+
const { userId, context, tenantId } = scope;
|
|
10698
|
+
await this.flowLockout.recordFailure("challenge", context, userId, tenantId);
|
|
10699
|
+
this.logger.warn(`challenge: invalid MFA code userId=${logSafe(userId)} context=${context}`);
|
|
10700
|
+
throw new AuthException(AUTH_ERROR_CODES.MFA_INVALID_CODE);
|
|
10701
|
+
}
|
|
10702
|
+
/**
|
|
10703
|
+
* Validates the submitted code against the account: a six-digit TOTP code with anti-replay, or a
|
|
10704
|
+
* recovery code compared in constant time and then claimed for exactly one challenge.
|
|
10705
|
+
*
|
|
10706
|
+
* @param user - The account, holding the stored recovery-code digests.
|
|
10707
|
+
* @param scope - The plane, account and tenant the challenge belongs to.
|
|
10708
|
+
* @param secretBase32 - The decrypted TOTP secret.
|
|
10709
|
+
* @param code - The submitted code.
|
|
10710
|
+
* @param mfa - The resolved MFA configuration.
|
|
10711
|
+
* @returns Whether the code is valid, and the index of the matched recovery digest (`-1` for
|
|
10712
|
+
* TOTP and for a recovery code that matched nothing).
|
|
10713
|
+
*/
|
|
10714
|
+
async checkCode(user, scope, secretBase32, code, mfa) {
|
|
10715
|
+
const { userId, context, tenantId } = scope;
|
|
10716
|
+
if (/^\d{6}$/.test(code)) {
|
|
10717
|
+
const valid2 = await this.records.verifyTotpWithAntiReplay(context, userId, secretBase32, code, mfa.totpWindow, tenantId);
|
|
10455
10718
|
return {
|
|
10456
|
-
|
|
10457
|
-
|
|
10458
|
-
recoveryCodes: existingCodes
|
|
10719
|
+
valid: valid2,
|
|
10720
|
+
recoveryIndex: -1
|
|
10459
10721
|
};
|
|
10460
10722
|
}
|
|
10461
|
-
const
|
|
10462
|
-
const
|
|
10463
|
-
const
|
|
10464
|
-
const { plainCodes, hashedCodes } = generateRecoveryCodes(recoveryCount, this.options.hmacKey);
|
|
10465
|
-
const encryptedPlainCodes = encrypt(JSON.stringify(plainCodes), this.mfaOptions.encryptionKey);
|
|
10466
|
-
const setupData = {
|
|
10467
|
-
encryptedSecret,
|
|
10468
|
-
hashedCodes,
|
|
10469
|
-
encryptedPlainCodes
|
|
10470
|
-
};
|
|
10471
|
-
const payload = JSON.stringify(setupData);
|
|
10472
|
-
const wasSet = await this.redis.setIfAbsent(setupKey, payload, MFA_SETUP_TTL_SECONDS);
|
|
10473
|
-
if (!wasSet) {
|
|
10474
|
-
const existing = await this.redis.get(setupKey);
|
|
10475
|
-
if (existing !== null) {
|
|
10476
|
-
const data = parseSetupData(existing, userId, this.logger);
|
|
10477
|
-
const existingSecret = decryptMfaSecret(data.encryptedSecret, this.mfaOptions);
|
|
10478
|
-
const decryptedCodesJson = decryptMfaSecret(data.encryptedPlainCodes, this.mfaOptions);
|
|
10479
|
-
const existingCodes = parsePlainRecoveryCodes(decryptedCodesJson, userId, this.logger);
|
|
10480
|
-
const qrCodeUri2 = buildTotpUri(existingSecret, user.email, this.mfaOptions.issuer);
|
|
10481
|
-
return {
|
|
10482
|
-
secret: existingSecret,
|
|
10483
|
-
qrCodeUri: qrCodeUri2,
|
|
10484
|
-
recoveryCodes: existingCodes
|
|
10485
|
-
};
|
|
10486
|
-
}
|
|
10487
|
-
await this.redis.set(setupKey, payload, MFA_SETUP_TTL_SECONDS);
|
|
10488
|
-
}
|
|
10489
|
-
const qrCodeUri = buildTotpUri(secretBase32, user.email, this.mfaOptions.issuer);
|
|
10490
|
-
this.logger.log(`setup: MFA setup initiated userId=${logSafe(userId)} context=${context}`);
|
|
10723
|
+
const recoveryCodes = user.mfaRecoveryCodes ?? [];
|
|
10724
|
+
const recoveryIndex = await verifyRecoveryCode(code, recoveryCodes, this.options.hmacKey, this.options.previousHmacKeys);
|
|
10725
|
+
const valid = recoveryIndex >= 0 && await this.records.claimRecoveryCode(context, userId, code, tenantId);
|
|
10491
10726
|
return {
|
|
10492
|
-
|
|
10493
|
-
|
|
10494
|
-
recoveryCodes: plainCodes
|
|
10727
|
+
valid,
|
|
10728
|
+
recoveryIndex
|
|
10495
10729
|
};
|
|
10496
10730
|
}
|
|
10497
|
-
// ---------------------------------------------------------------------------
|
|
10498
|
-
// verifyAndEnable — first-time TOTP validation and permanent MFA activation
|
|
10499
|
-
// ---------------------------------------------------------------------------
|
|
10500
10731
|
/**
|
|
10501
|
-
*
|
|
10502
|
-
* enables MFA on the account.
|
|
10732
|
+
* Spends the recovery code a challenge used, or migrates the secret to the current key.
|
|
10503
10733
|
*
|
|
10504
|
-
*
|
|
10505
|
-
*
|
|
10506
|
-
*
|
|
10507
|
-
*
|
|
10734
|
+
* A recovery challenge removes the matched digest in a serialized transition, spliced against
|
|
10735
|
+
* the record as it stands INSIDE the lock rather than the copy read earlier: splicing the stale
|
|
10736
|
+
* copy would roll a concurrent `regenerateRecoveryCodes` back wholesale and undo a completed
|
|
10737
|
+
* `disable` — see `MfaRecordService.transition`. A TOTP challenge writes nothing on its own, so
|
|
10738
|
+
* a secret that opened under a retired key is re-encrypted by a detached write: the challenge
|
|
10739
|
+
* has already succeeded and the retired key still opens the secret, so a failure costs the
|
|
10740
|
+
* migration and nothing else.
|
|
10508
10741
|
*
|
|
10509
|
-
* @param
|
|
10510
|
-
* @param
|
|
10511
|
-
* @param
|
|
10512
|
-
* @param
|
|
10513
|
-
* @param
|
|
10514
|
-
* @throws {@link AuthException} MFA_ALREADY_ENABLED when MFA is already active on the account.
|
|
10515
|
-
* @throws `MFA_SETUP_REQUIRED` if no pending setup data is found in Redis.
|
|
10516
|
-
* @throws `MFA_INVALID_CODE` if the submitted TOTP code is invalid.
|
|
10517
|
-
* @throws `MFA_NOT_ENABLED` if `context === 'platform'` and the platform user
|
|
10518
|
-
* repository was not configured at module registration.
|
|
10742
|
+
* @param user - The account as read at the start of the challenge.
|
|
10743
|
+
* @param scope - The plane, account and tenant the challenge belongs to.
|
|
10744
|
+
* @param opened - The decrypted secret, and whether it opened under a retired key.
|
|
10745
|
+
* @param recoveryIndex - Index of the spent recovery digest, or `-1` after a TOTP challenge.
|
|
10746
|
+
* @param mfa - The resolved MFA configuration.
|
|
10519
10747
|
*/
|
|
10520
|
-
async
|
|
10521
|
-
|
|
10522
|
-
if (
|
|
10523
|
-
|
|
10524
|
-
|
|
10525
|
-
|
|
10526
|
-
|
|
10527
|
-
const setupKey = `mfa_setup:${hmacSha256(userSubject(context, userId, tenantId), this.options.hmacKey)}`;
|
|
10528
|
-
const raw = await this.redis.get(setupKey);
|
|
10529
|
-
if (raw === null) throw new AuthException(AUTH_ERROR_CODES.MFA_SETUP_REQUIRED);
|
|
10530
|
-
const data = parseSetupData(raw, userId, this.logger);
|
|
10531
|
-
const secretBase32 = decryptMfaSecret(data.encryptedSecret, this.mfaOptions);
|
|
10532
|
-
const totpWindow = this.mfaOptions.totpWindow;
|
|
10533
|
-
const codeValid = await this.verifyTotpWithAntiReplay(context, userId, secretBase32, code, totpWindow, tenantId);
|
|
10534
|
-
if (!codeValid) {
|
|
10535
|
-
this.logger.warn(`verifyAndEnable: invalid TOTP code userId=${logSafe(userId)}`);
|
|
10536
|
-
throw new AuthException(AUTH_ERROR_CODES.MFA_INVALID_CODE);
|
|
10748
|
+
async settleRecovery(user, scope, opened, recoveryIndex, mfa) {
|
|
10749
|
+
const { userId, context, tenantId } = scope;
|
|
10750
|
+
if (recoveryIndex < 0) {
|
|
10751
|
+
if (opened.stale) {
|
|
10752
|
+
void this.records.reencryptSecret(userId, context, opened.secret, tenantId, mfa);
|
|
10753
|
+
}
|
|
10754
|
+
return;
|
|
10537
10755
|
}
|
|
10538
|
-
const
|
|
10539
|
-
|
|
10540
|
-
|
|
10541
|
-
|
|
10756
|
+
const existingCodes = user.mfaRecoveryCodes ?? /* istanbul ignore next -- verifyRecoveryCode returns ≥0 only after iterating a non-null array */
|
|
10757
|
+
// Stryker disable next-line ArrayDeclaration: unreachable — this branch is only taken
|
|
10758
|
+
// when `verifyRecoveryCode` matched a code inside an array it had to iterate first.
|
|
10759
|
+
[];
|
|
10760
|
+
await this.records.transition(context, userId, tenantId, (current) => spliceSpentCode(current, existingCodes, recoveryIndex, opened, mfa));
|
|
10761
|
+
}
|
|
10762
|
+
/**
|
|
10763
|
+
* Issues the dashboard session for a challenge that passed.
|
|
10764
|
+
*
|
|
10765
|
+
* @param user - The dashboard account.
|
|
10766
|
+
* @param userId - The account id from the temp token, for the hook context.
|
|
10767
|
+
* @param ip - Client IP address for session audit.
|
|
10768
|
+
* @param userAgent - User-Agent header for session description.
|
|
10769
|
+
* @returns The dashboard auth result.
|
|
10770
|
+
*/
|
|
10771
|
+
async issueDashboardSession(user, userId, ip, userAgent) {
|
|
10772
|
+
const safeUser = toSafeUser3(user);
|
|
10773
|
+
const result = await this.tokenManager.issueTokens(safeUser, ip, userAgent, {
|
|
10774
|
+
mfaVerified: true
|
|
10775
|
+
});
|
|
10776
|
+
if (this.options.sessions.enabled) {
|
|
10777
|
+
await this.sessionService.createSession({
|
|
10778
|
+
userId: safeUser.id,
|
|
10779
|
+
tenantId: safeUser.tenantId,
|
|
10780
|
+
rawRefreshToken: result.rawRefreshToken,
|
|
10781
|
+
ip,
|
|
10782
|
+
userAgent
|
|
10783
|
+
});
|
|
10542
10784
|
}
|
|
10543
|
-
|
|
10544
|
-
|
|
10545
|
-
|
|
10546
|
-
|
|
10547
|
-
|
|
10548
|
-
|
|
10549
|
-
|
|
10550
|
-
|
|
10551
|
-
this.notify("verifyAndEnable", userId, user, (provider, tenant, email) => provider.sendMfaEnabledNotification(tenant, email));
|
|
10552
|
-
if (this.hooks.afterMfaEnabled) {
|
|
10553
|
-
const safeUser = committedSafeUser(context, user, true);
|
|
10554
|
-
void Promise.resolve(this.hooks.afterMfaEnabled(safeUser, {
|
|
10555
|
-
// The plane, because the tenant cannot carry it: a platform admin is rendered with the
|
|
10556
|
-
// sentinel `tenantId: ''` while a platform token has no tenant claim at all.
|
|
10557
|
-
plane: context,
|
|
10785
|
+
runDetached(this.logger, () => this.userRepo.updateLastLogin({
|
|
10786
|
+
id: safeUser.id,
|
|
10787
|
+
tenantId: safeUser.tenantId
|
|
10788
|
+
}), "challenge: updateLastLogin failed");
|
|
10789
|
+
if (this.hooks.afterLogin) {
|
|
10790
|
+
const afterLogin = this.hooks.afterLogin.bind(this.hooks);
|
|
10791
|
+
runDetached(this.logger, () => afterLogin(safeUser, {
|
|
10792
|
+
plane: "dashboard",
|
|
10558
10793
|
userId,
|
|
10559
10794
|
ip,
|
|
10560
10795
|
userAgent,
|
|
10561
10796
|
sanitizedHeaders: {}
|
|
10562
|
-
})
|
|
10797
|
+
}), "challenge: afterLogin hook threw");
|
|
10563
10798
|
}
|
|
10799
|
+
return result;
|
|
10564
10800
|
}
|
|
10565
|
-
// ---------------------------------------------------------------------------
|
|
10566
|
-
// challenge — MFA temp token exchange for full auth tokens (TOTP or recovery code)
|
|
10567
|
-
// ---------------------------------------------------------------------------
|
|
10568
10801
|
/**
|
|
10569
|
-
*
|
|
10570
|
-
*
|
|
10571
|
-
*
|
|
10572
|
-
* Handles both `'dashboard'` and `'platform'` contexts. Applies brute-force
|
|
10573
|
-
* protection per-user. TOTP codes include anti-replay protection via a short-lived
|
|
10574
|
-
* Redis key keyed on an HMAC of the code and user ID.
|
|
10802
|
+
* Issues the platform session for a challenge that passed, reusing the account already fetched
|
|
10803
|
+
* to avoid a TOCTOU double-read. The platform repository's presence was validated by
|
|
10804
|
+
* `MfaRecordService.loadAccount`, so the cast below is safe.
|
|
10575
10805
|
*
|
|
10576
|
-
* @param
|
|
10577
|
-
* @param
|
|
10806
|
+
* @param platformUser - The platform administrator.
|
|
10807
|
+
* @param userId - The account id from the temp token, for the hook context.
|
|
10578
10808
|
* @param ip - Client IP address for session audit.
|
|
10579
10809
|
* @param userAgent - User-Agent header for session description.
|
|
10580
|
-
* @returns
|
|
10581
|
-
* @throws `MFA_TEMP_TOKEN_INVALID` if the token is invalid or already consumed.
|
|
10582
|
-
* @throws `ACCOUNT_LOCKED` if the brute-force threshold has been reached.
|
|
10583
|
-
* @throws `MFA_INVALID_CODE` if the submitted code is incorrect.
|
|
10810
|
+
* @returns The platform auth result.
|
|
10584
10811
|
*/
|
|
10585
|
-
async
|
|
10586
|
-
const { userId, context, tenantId, jti: tempTokenJti } = await this.tokenManager.verifyMfaTempToken(mfaTempToken);
|
|
10587
|
-
if (await this.isMfaFlowLockedOut("challenge", context, userId, tenantId)) {
|
|
10588
|
-
this.logger.warn(`challenge: account locked userId=${logSafe(userId)}`);
|
|
10589
|
-
throw new AuthException(AUTH_ERROR_CODES.ACCOUNT_LOCKED);
|
|
10590
|
-
}
|
|
10591
|
-
const user = await this.fetchUserForContext(context, userId, tenantId);
|
|
10592
|
-
if (!user.mfaEnabled || !user.mfaSecret) {
|
|
10593
|
-
throw new AuthException(AUTH_ERROR_CODES.MFA_NOT_ENABLED);
|
|
10594
|
-
}
|
|
10595
|
-
const { secret: secretBase32, stale: encryptedUnderRetiredKey } = decryptWithRotation(user.mfaSecret, this.mfaOptions);
|
|
10596
|
-
const isTotpCode = /^\d{6}$/.test(code);
|
|
10597
|
-
const totpWindow = this.mfaOptions.totpWindow;
|
|
10598
|
-
let codeValid = false;
|
|
10599
|
-
let usedRecoveryIndex = -1;
|
|
10600
|
-
if (isTotpCode) {
|
|
10601
|
-
codeValid = await this.verifyTotpWithAntiReplay(context, userId, secretBase32, code, totpWindow, tenantId);
|
|
10602
|
-
} else {
|
|
10603
|
-
const recoveryCodes = user.mfaRecoveryCodes ?? [];
|
|
10604
|
-
usedRecoveryIndex = await verifyRecoveryCode(code, recoveryCodes, this.options.hmacKey, this.options.previousHmacKeys);
|
|
10605
|
-
codeValid = usedRecoveryIndex >= 0 && await this.claimRecoveryCode(context, userId, code, tenantId);
|
|
10606
|
-
}
|
|
10607
|
-
if (!codeValid) {
|
|
10608
|
-
await this.recordMfaFlowFailure("challenge", context, userId, tenantId);
|
|
10609
|
-
this.logger.warn(`challenge: invalid MFA code userId=${logSafe(userId)} context=${context}`);
|
|
10610
|
-
throw new AuthException(AUTH_ERROR_CODES.MFA_INVALID_CODE);
|
|
10611
|
-
}
|
|
10612
|
-
await this.resetMfaFlowFailures("challenge", context, userId, tenantId);
|
|
10613
|
-
if (!await this.tokenManager.consumeMfaTempToken(tempTokenJti)) {
|
|
10614
|
-
throw new AuthException(AUTH_ERROR_CODES.MFA_TEMP_TOKEN_INVALID);
|
|
10615
|
-
}
|
|
10616
|
-
if (usedRecoveryIndex >= 0) {
|
|
10617
|
-
const existingCodes = user.mfaRecoveryCodes ?? /* istanbul ignore next -- verifyRecoveryCode returns ≥0 only after iterating a non-null array */
|
|
10618
|
-
// Stryker disable next-line ArrayDeclaration: unreachable — this branch is only taken
|
|
10619
|
-
// when `verifyRecoveryCode` matched a code inside an array it had to iterate first.
|
|
10620
|
-
[];
|
|
10621
|
-
await this.transitionMfaRecord(context, userId, tenantId, (current) => {
|
|
10622
|
-
if (!current.mfaEnabled) return null;
|
|
10623
|
-
if (!holdsSecret(current.mfaSecret, secretBase32, this.mfaOptions)) return null;
|
|
10624
|
-
const currentCodes = current.mfaRecoveryCodes ?? [];
|
|
10625
|
-
const spentDigest = existingCodes[usedRecoveryIndex] ?? "";
|
|
10626
|
-
const liveIndex = currentCodes.indexOf(spentDigest);
|
|
10627
|
-
if (liveIndex < 0) return null;
|
|
10628
|
-
const updatedCodes = [
|
|
10629
|
-
...currentCodes
|
|
10630
|
-
];
|
|
10631
|
-
updatedCodes.splice(liveIndex, 1);
|
|
10632
|
-
return {
|
|
10633
|
-
mfaEnabled: true,
|
|
10634
|
-
// Re-encrypted here when the secret opened under a retired key: the write is
|
|
10635
|
-
// already happening, so the rotation drains for free.
|
|
10636
|
-
mfaSecret: encryptedUnderRetiredKey ? encryptMfaSecret(secretBase32, this.mfaOptions) : current.mfaSecret,
|
|
10637
|
-
mfaRecoveryCodes: updatedCodes
|
|
10638
|
-
};
|
|
10639
|
-
});
|
|
10640
|
-
} else if (encryptedUnderRetiredKey) {
|
|
10641
|
-
void this.reencryptSecret(userId, context, secretBase32, tenantId);
|
|
10642
|
-
}
|
|
10643
|
-
this.logger.log(`challenge: MFA challenge passed userId=${logSafe(userId)} context=${context}`);
|
|
10644
|
-
if (context === "dashboard") {
|
|
10645
|
-
const safeUser = toSafeUser3(user);
|
|
10646
|
-
const result2 = await this.tokenManager.issueTokens(safeUser, ip, userAgent, {
|
|
10647
|
-
mfaVerified: true
|
|
10648
|
-
});
|
|
10649
|
-
if (this.options.sessions.enabled) {
|
|
10650
|
-
await this.sessionService.createSession({
|
|
10651
|
-
userId: safeUser.id,
|
|
10652
|
-
tenantId: safeUser.tenantId,
|
|
10653
|
-
rawRefreshToken: result2.rawRefreshToken,
|
|
10654
|
-
ip,
|
|
10655
|
-
userAgent
|
|
10656
|
-
});
|
|
10657
|
-
}
|
|
10658
|
-
runDetached(this.logger, () => this.userRepo.updateLastLogin({
|
|
10659
|
-
id: safeUser.id,
|
|
10660
|
-
tenantId: safeUser.tenantId
|
|
10661
|
-
}), "challenge: updateLastLogin failed");
|
|
10662
|
-
if (this.hooks.afterLogin) {
|
|
10663
|
-
const afterLogin = this.hooks.afterLogin.bind(this.hooks);
|
|
10664
|
-
runDetached(this.logger, () => afterLogin(safeUser, {
|
|
10665
|
-
plane: "dashboard",
|
|
10666
|
-
userId,
|
|
10667
|
-
ip,
|
|
10668
|
-
userAgent,
|
|
10669
|
-
sanitizedHeaders: {}
|
|
10670
|
-
}), "challenge: afterLogin hook threw");
|
|
10671
|
-
}
|
|
10672
|
-
return result2;
|
|
10673
|
-
}
|
|
10674
|
-
const platformUser = user;
|
|
10812
|
+
async issuePlatformSession(platformUser, userId, ip, userAgent) {
|
|
10675
10813
|
const result = await this.tokenManager.issuePlatformTokens(toSafePlatformUser(platformUser), ip, userAgent, {
|
|
10676
10814
|
mfaVerified: true
|
|
10677
10815
|
});
|
|
@@ -10692,7 +10830,7 @@ exports.MfaService = class _MfaService {
|
|
|
10692
10830
|
* The challenge for an entry point that serves the platform plane only.
|
|
10693
10831
|
*
|
|
10694
10832
|
* Reads the plane from the temp token first and refuses a dashboard token with
|
|
10695
|
-
* `PLATFORM_AUTH_REQUIRED` before anything is spent. {@link
|
|
10833
|
+
* `PLATFORM_AUTH_REQUIRED` before anything is spent. {@link MfaChallengeService.challenge} consumes the
|
|
10696
10834
|
* token, burns the TOTP code, stores a session, stamps the last login and fires the hooks, so
|
|
10697
10835
|
* refusing after it leaves an orphan session nobody holds a token for. The first verification only
|
|
10698
10836
|
* reads: it touches neither the brute-force counter nor the TOTP anti-replay key. The challenge
|
|
@@ -10702,26 +10840,119 @@ exports.MfaService = class _MfaService {
|
|
|
10702
10840
|
* @param code - 6-digit TOTP code or `dddd-dddd-dddd` recovery code.
|
|
10703
10841
|
* @param ip - Client IP address for session audit.
|
|
10704
10842
|
* @param userAgent - User-Agent header for session description.
|
|
10843
|
+
* @param mfa - The resolved MFA configuration (cipher keys and TOTP window).
|
|
10705
10844
|
* @returns The platform auth result.
|
|
10706
10845
|
* @throws `PLATFORM_AUTH_REQUIRED` if the token is for the dashboard plane.
|
|
10707
10846
|
* @throws `MFA_TEMP_TOKEN_INVALID` if the token is invalid or already consumed.
|
|
10708
10847
|
* @throws `ACCOUNT_LOCKED` if the brute-force threshold has been reached.
|
|
10709
10848
|
* @throws `MFA_INVALID_CODE` if the submitted code is incorrect.
|
|
10710
10849
|
*/
|
|
10711
|
-
async challengePlatformOnly(mfaTempToken, code, ip, userAgent) {
|
|
10850
|
+
async challengePlatformOnly(mfaTempToken, code, ip, userAgent, mfa) {
|
|
10712
10851
|
const { context } = await this.tokenManager.verifyMfaTempToken(mfaTempToken);
|
|
10713
10852
|
if (context !== "platform") {
|
|
10714
10853
|
throw new AuthException(AUTH_ERROR_CODES.PLATFORM_AUTH_REQUIRED);
|
|
10715
10854
|
}
|
|
10716
|
-
const result = await this.challenge(mfaTempToken, code, ip, userAgent);
|
|
10855
|
+
const result = await this.challenge(mfaTempToken, code, ip, userAgent, mfa);
|
|
10717
10856
|
if (!("admin" in result)) {
|
|
10718
10857
|
throw new AuthException(AUTH_ERROR_CODES.PLATFORM_AUTH_REQUIRED);
|
|
10719
10858
|
}
|
|
10720
10859
|
return result;
|
|
10721
10860
|
}
|
|
10722
|
-
|
|
10723
|
-
|
|
10724
|
-
|
|
10861
|
+
};
|
|
10862
|
+
MfaChallengeService = _ts_decorate39([
|
|
10863
|
+
common.Injectable(),
|
|
10864
|
+
_ts_param23(0, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
10865
|
+
_ts_param23(1, common.Inject(BYMAX_AUTH_USER_REPOSITORY)),
|
|
10866
|
+
_ts_param23(2, common.Optional()),
|
|
10867
|
+
_ts_param23(2, common.Inject(BYMAX_AUTH_PLATFORM_USER_REPOSITORY)),
|
|
10868
|
+
_ts_param23(3, common.Inject(TokenManagerService)),
|
|
10869
|
+
_ts_param23(4, common.Inject(MfaFlowLockoutService)),
|
|
10870
|
+
_ts_param23(5, common.Inject(MfaRecordService)),
|
|
10871
|
+
_ts_param23(6, common.Inject(exports.SessionService)),
|
|
10872
|
+
_ts_param23(7, common.Inject(BYMAX_AUTH_HOOKS)),
|
|
10873
|
+
_ts_metadata38("design:type", Function),
|
|
10874
|
+
_ts_metadata38("design:paramtypes", [
|
|
10875
|
+
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
|
|
10876
|
+
typeof IUserRepository === "undefined" ? Object : IUserRepository,
|
|
10877
|
+
Object,
|
|
10878
|
+
typeof TokenManagerService === "undefined" ? Object : TokenManagerService,
|
|
10879
|
+
typeof MfaFlowLockoutService === "undefined" ? Object : MfaFlowLockoutService,
|
|
10880
|
+
typeof MfaRecordService === "undefined" ? Object : MfaRecordService,
|
|
10881
|
+
typeof exports.SessionService === "undefined" ? Object : exports.SessionService,
|
|
10882
|
+
typeof IAuthHooks === "undefined" ? Object : IAuthHooks
|
|
10883
|
+
])
|
|
10884
|
+
], MfaChallengeService);
|
|
10885
|
+
|
|
10886
|
+
// src/server/utils/mfa-notify.ts
|
|
10887
|
+
var PLATFORM_EMAIL_TENANT = "platform";
|
|
10888
|
+
function emailTenantOf(user) {
|
|
10889
|
+
return "tenantId" in user ? user.tenantId : PLATFORM_EMAIL_TENANT;
|
|
10890
|
+
}
|
|
10891
|
+
__name(emailTenantOf, "emailTenantOf");
|
|
10892
|
+
function notifyMfaChange(logger, emailProvider, origin, userId, user, send) {
|
|
10893
|
+
const tenantId = emailTenantOf(user);
|
|
10894
|
+
const email = user.email;
|
|
10895
|
+
const withheld = [
|
|
10896
|
+
email
|
|
10897
|
+
];
|
|
10898
|
+
void (async () => {
|
|
10899
|
+
try {
|
|
10900
|
+
await send(emailProvider, tenantId, email);
|
|
10901
|
+
} catch (err) {
|
|
10902
|
+
logger.error(safeLogLine(`${origin}: MFA notice delivery failed for user ${logSafe(userId)}: ` + describeChannelStatus(err), withheld));
|
|
10903
|
+
}
|
|
10904
|
+
})();
|
|
10905
|
+
}
|
|
10906
|
+
__name(notifyMfaChange, "notifyMfaChange");
|
|
10907
|
+
|
|
10908
|
+
// src/server/services/mfa-management.service.ts
|
|
10909
|
+
function _ts_decorate40(decorators, target, key, desc) {
|
|
10910
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10911
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
10912
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
10913
|
+
} else {
|
|
10914
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
10915
|
+
if (d = decorators[i]) {
|
|
10916
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10917
|
+
}
|
|
10918
|
+
}
|
|
10919
|
+
}
|
|
10920
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10921
|
+
}
|
|
10922
|
+
__name(_ts_decorate40, "_ts_decorate");
|
|
10923
|
+
function _ts_metadata39(metadataKey, metadataValue) {
|
|
10924
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
10925
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
10926
|
+
}
|
|
10927
|
+
}
|
|
10928
|
+
__name(_ts_metadata39, "_ts_metadata");
|
|
10929
|
+
function _ts_param24(paramIndex, decorator) {
|
|
10930
|
+
return function(target, key) {
|
|
10931
|
+
decorator(target, key, paramIndex);
|
|
10932
|
+
};
|
|
10933
|
+
}
|
|
10934
|
+
__name(_ts_param24, "_ts_param");
|
|
10935
|
+
var MfaManagementService = class {
|
|
10936
|
+
static {
|
|
10937
|
+
__name(this, "MfaManagementService");
|
|
10938
|
+
}
|
|
10939
|
+
options;
|
|
10940
|
+
platformUserRepo;
|
|
10941
|
+
redis;
|
|
10942
|
+
flowLockout;
|
|
10943
|
+
records;
|
|
10944
|
+
emailProvider;
|
|
10945
|
+
hooks;
|
|
10946
|
+
logger = new common.Logger(MFA_LOG_CONTEXT);
|
|
10947
|
+
constructor(options, platformUserRepo, redis, flowLockout, records, emailProvider, hooks) {
|
|
10948
|
+
this.options = options;
|
|
10949
|
+
this.platformUserRepo = platformUserRepo;
|
|
10950
|
+
this.redis = redis;
|
|
10951
|
+
this.flowLockout = flowLockout;
|
|
10952
|
+
this.records = records;
|
|
10953
|
+
this.emailProvider = emailProvider;
|
|
10954
|
+
this.hooks = hooks;
|
|
10955
|
+
}
|
|
10725
10956
|
/**
|
|
10726
10957
|
* Disables MFA on a user's account after verifying a current TOTP code.
|
|
10727
10958
|
*
|
|
@@ -10740,55 +10971,29 @@ exports.MfaService = class _MfaService {
|
|
|
10740
10971
|
* @param code - 6-digit TOTP code from the authenticator app.
|
|
10741
10972
|
* @param ip - Client IP address (forwarded to hooks).
|
|
10742
10973
|
* @param userAgent - User-Agent header (forwarded to hooks).
|
|
10743
|
-
* @param context - Which repository to use: `'dashboard'`
|
|
10974
|
+
* @param context - Which repository to use: `'dashboard'` or `'platform'`.
|
|
10975
|
+
* @param tenantId - The tenant on the dashboard plane; absent on the platform plane.
|
|
10976
|
+
* @param mfa - The resolved MFA configuration (cipher keys and TOTP window).
|
|
10744
10977
|
* @throws `TOKEN_INVALID` if the user is not found.
|
|
10745
10978
|
* @throws `MFA_NOT_ENABLED` if MFA is not currently active.
|
|
10746
10979
|
* @throws `ACCOUNT_LOCKED` if the brute-force threshold has been reached.
|
|
10747
10980
|
* @throws `MFA_INVALID_CODE` if the submitted TOTP code is incorrect.
|
|
10748
10981
|
*/
|
|
10749
|
-
async disable(userId, code, ip, userAgent, context
|
|
10750
|
-
|
|
10751
|
-
const
|
|
10982
|
+
async disable(userId, code, ip, userAgent, context, tenantId, mfa) {
|
|
10983
|
+
assertPlaneTenant(context, tenantId);
|
|
10984
|
+
const scope = {
|
|
10985
|
+
userId,
|
|
10986
|
+
context,
|
|
10987
|
+
tenantId
|
|
10988
|
+
};
|
|
10989
|
+
const user = await this.records.loadAccount(context, userId, tenantId);
|
|
10752
10990
|
if (!user.mfaEnabled) throw new AuthException(AUTH_ERROR_CODES.MFA_NOT_ENABLED);
|
|
10753
|
-
|
|
10754
|
-
|
|
10755
|
-
throw new AuthException(AUTH_ERROR_CODES.ACCOUNT_LOCKED);
|
|
10756
|
-
}
|
|
10757
|
-
if (!user.mfaSecret) {
|
|
10758
|
-
throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
|
|
10759
|
-
}
|
|
10760
|
-
const secretBase32 = decryptMfaSecret(user.mfaSecret, this.mfaOptions);
|
|
10761
|
-
const totpWindow = this.mfaOptions.totpWindow;
|
|
10762
|
-
const codeValid = await this.verifyTotpWithAntiReplay(context, userId, secretBase32, code, totpWindow, tenantId);
|
|
10763
|
-
if (!codeValid) {
|
|
10764
|
-
await this.recordMfaFlowFailure("disable", context, userId, tenantId);
|
|
10765
|
-
this.logger.warn(`disable: invalid MFA code userId=${logSafe(userId)} context=${context}`);
|
|
10766
|
-
throw new AuthException(AUTH_ERROR_CODES.MFA_INVALID_CODE);
|
|
10767
|
-
}
|
|
10768
|
-
await this.resetMfaFlowFailures("disable", context, userId, tenantId);
|
|
10769
|
-
await this.transitionMfaRecord(context, userId, tenantId, () => ({
|
|
10770
|
-
mfaEnabled: false,
|
|
10771
|
-
mfaSecret: null,
|
|
10772
|
-
mfaRecoveryCodes: null
|
|
10773
|
-
}));
|
|
10774
|
-
await this.redis.invalidateUserSessions(userId, tenantId, context);
|
|
10775
|
-
await this.redis.bumpUserTokenEpoch(userId, tenantId, context);
|
|
10991
|
+
await this.spendTotpAttempt("disable", scope, user, code, mfa);
|
|
10992
|
+
await this.clearFactor(scope);
|
|
10776
10993
|
this.logger.log(`disable: MFA disabled userId=${logSafe(userId)} context=${context}`);
|
|
10777
|
-
this.
|
|
10778
|
-
|
|
10779
|
-
if (this.hooks.afterMfaDisabled) {
|
|
10780
|
-
void Promise.resolve(this.hooks.afterMfaDisabled(safeUser, {
|
|
10781
|
-
plane: context,
|
|
10782
|
-
userId,
|
|
10783
|
-
ip,
|
|
10784
|
-
userAgent,
|
|
10785
|
-
sanitizedHeaders: {}
|
|
10786
|
-
})).catch(() => void 0);
|
|
10787
|
-
}
|
|
10994
|
+
this.notifyDisabled("disable", scope, user);
|
|
10995
|
+
this.fireDisabledHook(scope, user, ip, userAgent);
|
|
10788
10996
|
}
|
|
10789
|
-
// ---------------------------------------------------------------------------
|
|
10790
|
-
// resetMfa() — administrative removal of a second factor
|
|
10791
|
-
// ---------------------------------------------------------------------------
|
|
10792
10997
|
/**
|
|
10793
10998
|
* Removes a user's second factor without their TOTP code, for a support desk facing a user
|
|
10794
10999
|
* who has lost their authenticator AND their recovery codes.
|
|
@@ -10800,8 +11005,8 @@ exports.MfaService = class _MfaService {
|
|
|
10800
11005
|
*
|
|
10801
11006
|
* **Authorising the caller is the consumer's job.** The library deliberately ships no route
|
|
10802
11007
|
* for this, the same decision and for the same reason as {@link AuthService.unlockAccount}:
|
|
10803
|
-
* who may reset whom is a question only the host application can answer, and
|
|
10804
|
-
* this library
|
|
11008
|
+
* who may reset whom is a question only the host application can answer, and every route
|
|
11009
|
+
* this library ships is scoped to the caller's own account.
|
|
10805
11010
|
*
|
|
10806
11011
|
* Idempotent: resetting an account that has no second factor is a no-op, so a support desk
|
|
10807
11012
|
* retrying does not get an error for a job already done.
|
|
@@ -10823,42 +11028,28 @@ exports.MfaService = class _MfaService {
|
|
|
10823
11028
|
* not initiate.
|
|
10824
11029
|
*
|
|
10825
11030
|
* @param userId - Internal ID of the user whose second factor is being removed.
|
|
10826
|
-
* @param context - Which identity plane the user belongs to: `'dashboard'`
|
|
10827
|
-
*
|
|
11031
|
+
* @param context - Which identity plane the user belongs to: `'dashboard'` or `'platform'`.
|
|
11032
|
+
* Must match the plane the account lives in, or the lookup misses.
|
|
11033
|
+
* @param tenantId - The tenant on the dashboard plane; absent on the platform plane.
|
|
10828
11034
|
* @throws `TOKEN_INVALID` if no user with that ID exists in the given plane.
|
|
10829
11035
|
*/
|
|
10830
|
-
async resetMfa(userId, context
|
|
10831
|
-
|
|
10832
|
-
const
|
|
11036
|
+
async resetMfa(userId, context, tenantId) {
|
|
11037
|
+
assertPlaneTenant(context, tenantId);
|
|
11038
|
+
const scope = {
|
|
11039
|
+
userId,
|
|
11040
|
+
context,
|
|
11041
|
+
tenantId
|
|
11042
|
+
};
|
|
11043
|
+
const user = await this.records.loadAccount(context, userId, tenantId);
|
|
10833
11044
|
if (!user.mfaEnabled) {
|
|
10834
11045
|
this.logger.log(`resetMfa: no second factor to remove userId=${logSafe(userId)} context=${context}`);
|
|
10835
11046
|
return;
|
|
10836
11047
|
}
|
|
10837
|
-
await this.
|
|
10838
|
-
mfaEnabled: false,
|
|
10839
|
-
mfaSecret: null,
|
|
10840
|
-
mfaRecoveryCodes: null
|
|
10841
|
-
}));
|
|
10842
|
-
await this.redis.invalidateUserSessions(userId, tenantId, context);
|
|
10843
|
-
await this.redis.bumpUserTokenEpoch(userId, tenantId, context);
|
|
11048
|
+
await this.clearFactor(scope);
|
|
10844
11049
|
this.logger.warn(`resetMfa: MFA removed administratively userId=${logSafe(userId)} context=${context}`);
|
|
10845
|
-
this.
|
|
10846
|
-
|
|
10847
|
-
if (this.hooks.afterMfaDisabled) {
|
|
10848
|
-
void Promise.resolve(this.hooks.afterMfaDisabled(safeUser, {
|
|
10849
|
-
plane: context,
|
|
10850
|
-
userId,
|
|
10851
|
-
// No request context: this call does not come from one. Empty rather than invented,
|
|
10852
|
-
// so a consumer logging the hook cannot mistake a placeholder for a real address.
|
|
10853
|
-
ip: "",
|
|
10854
|
-
userAgent: "",
|
|
10855
|
-
sanitizedHeaders: {}
|
|
10856
|
-
})).catch(() => void 0);
|
|
10857
|
-
}
|
|
11050
|
+
this.notifyDisabled("resetMfa", scope, user);
|
|
11051
|
+
this.fireDisabledHook(scope, user, "", "");
|
|
10858
11052
|
}
|
|
10859
|
-
// ---------------------------------------------------------------------------
|
|
10860
|
-
// regenerateRecoveryCodes — rotate the recovery code set for an MFA-enabled user
|
|
10861
|
-
// ---------------------------------------------------------------------------
|
|
10862
11053
|
/**
|
|
10863
11054
|
* Regenerates the user's MFA recovery codes after verifying a current TOTP code.
|
|
10864
11055
|
*
|
|
@@ -10868,14 +11059,21 @@ exports.MfaService = class _MfaService {
|
|
|
10868
11059
|
* the supplied `context`. The TOTP secret on the user record is unchanged — only
|
|
10869
11060
|
* the recovery code list is replaced.
|
|
10870
11061
|
*
|
|
11062
|
+
* The order is deliberate and differs from the challenge: the account is read and the enrolment
|
|
11063
|
+
* checked BEFORE the lockout. The challenge runs its brute-force check first because it is a
|
|
11064
|
+
* PUBLIC endpoint, where an attacker who knows a userId could otherwise force a database read
|
|
11065
|
+
* per request. This and `disable` sit behind a JWT guard that binds the caller to a userId, so
|
|
11066
|
+
* the counter exists to throttle repeated TOTP guesses by the legitimate user, or by someone
|
|
11067
|
+
* holding their access token, and a read per request from an authenticated session is
|
|
11068
|
+
* acceptable for that threat model. Do not reorder it to match the challenge.
|
|
11069
|
+
*
|
|
10871
11070
|
* Returns the plain-text codes once. They are NOT persisted in plain form; only a
|
|
10872
11071
|
* keyed HMAC-SHA-256 of each goes into the database. The caller is responsible for showing the
|
|
10873
11072
|
* codes to the user exactly once and warning them to save them safely.
|
|
10874
11073
|
*
|
|
10875
11074
|
* @remarks
|
|
10876
11075
|
* **Sessions are intentionally NOT invalidated after this call.** Unlike
|
|
10877
|
-
* {@link
|
|
10878
|
-
* {@link disable} (which flips it back to `false`), this method does not change
|
|
11076
|
+
* {@link disable}, which flips `mfaEnabled` back to `false`, this method does not change
|
|
10879
11077
|
* the verification credential — the TOTP secret stays the same and existing
|
|
10880
11078
|
* `mfaVerified: true` access tokens remain valid. Invalidating sessions here
|
|
10881
11079
|
* would force a redundant re-auth on every recovery-code rotation, which is a
|
|
@@ -10886,7 +11084,9 @@ exports.MfaService = class _MfaService {
|
|
|
10886
11084
|
* @param totpCode - 6-digit TOTP code from the authenticator app.
|
|
10887
11085
|
* @param ip - Client IP address (forwarded to hooks).
|
|
10888
11086
|
* @param userAgent - User-Agent header (forwarded to hooks).
|
|
10889
|
-
* @param context - Which repository to use: `'dashboard'`
|
|
11087
|
+
* @param context - Which repository to use: `'dashboard'` or `'platform'`.
|
|
11088
|
+
* @param tenantId - The tenant on the dashboard plane; absent on the platform plane.
|
|
11089
|
+
* @param mfa - The resolved MFA configuration (cipher keys, TOTP window, code count).
|
|
10890
11090
|
* @throws `TOKEN_INVALID` if the user is not found or `mfaSecret` is missing
|
|
10891
11091
|
* when `mfaEnabled` is `true` (database inconsistency).
|
|
10892
11092
|
* @throws `MFA_NOT_ENABLED` if MFA is not currently active, or if
|
|
@@ -10896,32 +11096,22 @@ exports.MfaService = class _MfaService {
|
|
|
10896
11096
|
* @throws `MFA_INVALID_CODE` if the submitted TOTP code is incorrect.
|
|
10897
11097
|
* @returns The freshly generated plain-text recovery codes, one-time display.
|
|
10898
11098
|
*/
|
|
10899
|
-
async regenerateRecoveryCodes(userId, totpCode, ip, userAgent, context
|
|
10900
|
-
|
|
11099
|
+
async regenerateRecoveryCodes(userId, totpCode, ip, userAgent, context, tenantId, mfa) {
|
|
11100
|
+
assertPlaneTenant(context, tenantId);
|
|
10901
11101
|
if (context === "platform" && !this.platformUserRepo) {
|
|
10902
11102
|
throw new AuthException(AUTH_ERROR_CODES.MFA_NOT_ENABLED);
|
|
10903
11103
|
}
|
|
10904
|
-
const
|
|
11104
|
+
const scope = {
|
|
11105
|
+
userId,
|
|
11106
|
+
context,
|
|
11107
|
+
tenantId
|
|
11108
|
+
};
|
|
11109
|
+
const user = await this.records.loadAccount(context, userId, tenantId);
|
|
10905
11110
|
if (!user.mfaEnabled) throw new AuthException(AUTH_ERROR_CODES.MFA_NOT_ENABLED);
|
|
10906
|
-
|
|
10907
|
-
|
|
10908
|
-
throw new AuthException(AUTH_ERROR_CODES.ACCOUNT_LOCKED);
|
|
10909
|
-
}
|
|
10910
|
-
if (!user.mfaSecret) {
|
|
10911
|
-
throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
|
|
10912
|
-
}
|
|
10913
|
-
const secretBase32 = decryptMfaSecret(user.mfaSecret, this.mfaOptions);
|
|
10914
|
-
const totpWindow = this.mfaOptions.totpWindow;
|
|
10915
|
-
const codeValid = await this.verifyTotpWithAntiReplay(context, userId, secretBase32, totpCode, totpWindow, tenantId);
|
|
10916
|
-
if (!codeValid) {
|
|
10917
|
-
await this.recordMfaFlowFailure("disable", context, userId, tenantId);
|
|
10918
|
-
this.logger.warn(`regenerateRecoveryCodes: invalid MFA code userId=${logSafe(userId)} context=${context}`);
|
|
10919
|
-
throw new AuthException(AUTH_ERROR_CODES.MFA_INVALID_CODE);
|
|
10920
|
-
}
|
|
10921
|
-
await this.resetMfaFlowFailures("disable", context, userId, tenantId);
|
|
10922
|
-
const recoveryCount = this.mfaOptions.recoveryCodeCount ?? DEFAULT_RECOVERY_CODE_COUNT;
|
|
11111
|
+
await this.spendTotpAttempt("regenerateRecoveryCodes", scope, user, totpCode, mfa);
|
|
11112
|
+
const recoveryCount = mfa.recoveryCodeCount ?? DEFAULT_RECOVERY_CODE_COUNT;
|
|
10923
11113
|
const { plainCodes, hashedCodes } = generateRecoveryCodes(recoveryCount, this.options.hmacKey);
|
|
10924
|
-
const replaced = await this.
|
|
11114
|
+
const replaced = await this.records.transition(context, userId, tenantId, (current) => {
|
|
10925
11115
|
if (!current.mfaEnabled) return null;
|
|
10926
11116
|
return {
|
|
10927
11117
|
mfaEnabled: true,
|
|
@@ -10931,56 +11121,189 @@ exports.MfaService = class _MfaService {
|
|
|
10931
11121
|
});
|
|
10932
11122
|
if (!replaced) throw new AuthException(AUTH_ERROR_CODES.MFA_NOT_ENABLED);
|
|
10933
11123
|
this.logger.log(`regenerateRecoveryCodes: recovery codes regenerated userId=${logSafe(userId)} context=${context}`);
|
|
10934
|
-
|
|
10935
|
-
|
|
10936
|
-
|
|
10937
|
-
|
|
10938
|
-
|
|
11124
|
+
this.fireRegeneratedHook(scope, user, ip, userAgent);
|
|
11125
|
+
return {
|
|
11126
|
+
recoveryCodes: plainCodes
|
|
11127
|
+
};
|
|
11128
|
+
}
|
|
11129
|
+
/**
|
|
11130
|
+
* Checks the lockout, then verifies a TOTP code for an authenticated MFA change, counting a
|
|
11131
|
+
* wrong code and clearing the counter on a right one.
|
|
11132
|
+
*
|
|
11133
|
+
* The 'disable' counter is namespaced away from 'challenge', so a pre-auth attacker holding only
|
|
11134
|
+
* a temp token cannot exhaust the threshold and block the authenticated user's own changes.
|
|
11135
|
+
*
|
|
11136
|
+
* @param origin - The calling flow, for the log lines.
|
|
11137
|
+
* @param scope - The plane, account and tenant the change applies to.
|
|
11138
|
+
* @param user - The account, holding the encrypted secret.
|
|
11139
|
+
* @param code - The submitted TOTP code.
|
|
11140
|
+
* @param mfa - The resolved MFA configuration.
|
|
11141
|
+
* @throws {@link AuthException} `ACCOUNT_LOCKED` at the ceiling, `TOKEN_INVALID` when the secret
|
|
11142
|
+
* is absent on an enabled account (a database inconsistency), `MFA_INVALID_CODE` on a wrong
|
|
11143
|
+
* code.
|
|
11144
|
+
*/
|
|
11145
|
+
async spendTotpAttempt(origin, scope, user, code, mfa) {
|
|
11146
|
+
const { userId, context, tenantId } = scope;
|
|
11147
|
+
if (await this.flowLockout.isLockedOut("disable", context, userId, tenantId)) {
|
|
11148
|
+
this.logger.warn(`${origin}: account locked userId=${logSafe(userId)} context=${context}`);
|
|
11149
|
+
throw new AuthException(AUTH_ERROR_CODES.ACCOUNT_LOCKED);
|
|
11150
|
+
}
|
|
11151
|
+
if (!user.mfaSecret) {
|
|
11152
|
+
throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
|
|
11153
|
+
}
|
|
11154
|
+
const valid = await this.records.verifyTotpWithAntiReplay(context, userId, decryptMfaSecret(user.mfaSecret, mfa), code, mfa.totpWindow, tenantId);
|
|
11155
|
+
if (!valid) {
|
|
11156
|
+
await this.flowLockout.recordFailure("disable", context, userId, tenantId);
|
|
11157
|
+
this.logger.warn(`${origin}: invalid MFA code userId=${logSafe(userId)} context=${context}`);
|
|
11158
|
+
throw new AuthException(AUTH_ERROR_CODES.MFA_INVALID_CODE);
|
|
11159
|
+
}
|
|
11160
|
+
await this.flowLockout.reset("disable", context, userId, tenantId);
|
|
11161
|
+
}
|
|
11162
|
+
/**
|
|
11163
|
+
* Clears the MFA record and revokes everything issued under it.
|
|
11164
|
+
*
|
|
11165
|
+
* Serialized against every other MFA transition, so a challenge that read the record a moment
|
|
11166
|
+
* earlier cannot splice `mfaEnabled: true` and the old secret back on top of this. Sessions are
|
|
11167
|
+
* invalidated and the token epoch advances so outstanding access tokens die with the factor: an
|
|
11168
|
+
* auth-state change revokes everything issued under the previous state, in both directions, the
|
|
11169
|
+
* same rule the password-reset flow applies. Scoped to the caller's own identity plane.
|
|
11170
|
+
*
|
|
11171
|
+
* @param scope - The plane, account and tenant to clear.
|
|
11172
|
+
*/
|
|
11173
|
+
async clearFactor(scope) {
|
|
11174
|
+
const { userId, context, tenantId } = scope;
|
|
11175
|
+
await this.records.transition(context, userId, tenantId, () => ({
|
|
11176
|
+
mfaEnabled: false,
|
|
11177
|
+
mfaSecret: null,
|
|
11178
|
+
mfaRecoveryCodes: null
|
|
11179
|
+
}));
|
|
11180
|
+
await this.redis.invalidateUserSessions(userId, tenantId, context);
|
|
11181
|
+
await this.redis.bumpUserTokenEpoch(userId, tenantId, context);
|
|
11182
|
+
}
|
|
11183
|
+
/**
|
|
11184
|
+
* Tells the account holder their second factor was turned off.
|
|
11185
|
+
*
|
|
11186
|
+
* @param origin - The calling flow, for the log line.
|
|
11187
|
+
* @param scope - The plane, account and tenant that changed.
|
|
11188
|
+
* @param user - The account, read for its address.
|
|
11189
|
+
*/
|
|
11190
|
+
notifyDisabled(origin, scope, user) {
|
|
11191
|
+
notifyMfaChange(this.logger, this.emailProvider, origin, scope.userId, user, (provider, tenant, email) => provider.sendMfaDisabledNotification(tenant, email));
|
|
11192
|
+
}
|
|
11193
|
+
/**
|
|
11194
|
+
* Fires the `afterMfaDisabled` hook, fire-and-forget: its failure must not undo a completed
|
|
11195
|
+
* removal.
|
|
11196
|
+
*
|
|
11197
|
+
* @param scope - The plane, account and tenant that changed.
|
|
11198
|
+
* @param user - The account as read before the change.
|
|
11199
|
+
* @param ip - Client IP address, or empty for an administrative call.
|
|
11200
|
+
* @param userAgent - User-Agent header, or empty for an administrative call.
|
|
11201
|
+
*/
|
|
11202
|
+
fireDisabledHook(scope, user, ip, userAgent) {
|
|
11203
|
+
const safeUser = committedSafeUser(scope.context, user, false);
|
|
11204
|
+
if (this.hooks.afterMfaDisabled) {
|
|
11205
|
+
void Promise.resolve(this.hooks.afterMfaDisabled(safeUser, {
|
|
11206
|
+
plane: scope.context,
|
|
11207
|
+
userId: scope.userId,
|
|
10939
11208
|
ip,
|
|
10940
11209
|
userAgent,
|
|
10941
11210
|
sanitizedHeaders: {}
|
|
10942
11211
|
})).catch(() => void 0);
|
|
10943
11212
|
}
|
|
10944
|
-
return {
|
|
10945
|
-
recoveryCodes: plainCodes
|
|
10946
|
-
};
|
|
10947
11213
|
}
|
|
10948
|
-
// ---------------------------------------------------------------------------
|
|
10949
|
-
// Private helpers
|
|
10950
|
-
// ---------------------------------------------------------------------------
|
|
10951
11214
|
/**
|
|
10952
|
-
*
|
|
10953
|
-
*
|
|
10954
|
-
* Stores a Redis key `tu:{hmac}` where `hmac = hmacSha256("{userSubject}:{code}", hmacKey)` —
|
|
10955
|
-
* so the marker is scoped to the plane and, on the dashboard plane, to the tenant. A second
|
|
10956
|
-
* submission of the same code within the TTL is rejected as a replay. Binding the marker to
|
|
10957
|
-
* both the subject and the code value prevents code disclosure in Redis and cross-user,
|
|
10958
|
-
* cross-tenant and cross-plane replay alike.
|
|
10959
|
-
*
|
|
10960
|
-
* A second marker under the pre-scoping preimage `{context}:{userId}:{code}` is written and
|
|
10961
|
-
* required alongside it; see the call site for why both must be fresh during a rolling upgrade.
|
|
11215
|
+
* Fires the `afterMfaRecoveryCodesRegenerated` hook, fire-and-forget: its failure must not undo
|
|
11216
|
+
* a completed regeneration.
|
|
10962
11217
|
*
|
|
10963
|
-
* @
|
|
11218
|
+
* @param scope - The plane, account and tenant that changed.
|
|
11219
|
+
* @param user - The account as read before the change.
|
|
11220
|
+
* @param ip - Client IP address.
|
|
11221
|
+
* @param userAgent - User-Agent header.
|
|
10964
11222
|
*/
|
|
10965
|
-
|
|
10966
|
-
if (
|
|
10967
|
-
|
|
10968
|
-
|
|
10969
|
-
|
|
10970
|
-
|
|
10971
|
-
|
|
10972
|
-
|
|
10973
|
-
|
|
11223
|
+
fireRegeneratedHook(scope, user, ip, userAgent) {
|
|
11224
|
+
if (this.hooks.afterMfaRecoveryCodesRegenerated) {
|
|
11225
|
+
const safeUser = scope.context === "platform" ? platformUserAsSafeUser(user) : toSafeUser3(user);
|
|
11226
|
+
void Promise.resolve(this.hooks.afterMfaRecoveryCodesRegenerated(safeUser, {
|
|
11227
|
+
plane: scope.context,
|
|
11228
|
+
userId: scope.userId,
|
|
11229
|
+
ip,
|
|
11230
|
+
userAgent,
|
|
11231
|
+
sanitizedHeaders: {}
|
|
11232
|
+
})).catch(() => void 0);
|
|
11233
|
+
}
|
|
11234
|
+
}
|
|
11235
|
+
};
|
|
11236
|
+
MfaManagementService = _ts_decorate40([
|
|
11237
|
+
common.Injectable(),
|
|
11238
|
+
_ts_param24(0, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
11239
|
+
_ts_param24(1, common.Optional()),
|
|
11240
|
+
_ts_param24(1, common.Inject(BYMAX_AUTH_PLATFORM_USER_REPOSITORY)),
|
|
11241
|
+
_ts_param24(2, common.Inject(AuthRedisService)),
|
|
11242
|
+
_ts_param24(3, common.Inject(MfaFlowLockoutService)),
|
|
11243
|
+
_ts_param24(4, common.Inject(MfaRecordService)),
|
|
11244
|
+
_ts_param24(5, common.Inject(BYMAX_AUTH_EMAIL_PROVIDER)),
|
|
11245
|
+
_ts_param24(6, common.Inject(BYMAX_AUTH_HOOKS)),
|
|
11246
|
+
_ts_metadata39("design:type", Function),
|
|
11247
|
+
_ts_metadata39("design:paramtypes", [
|
|
11248
|
+
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
|
|
11249
|
+
Object,
|
|
11250
|
+
typeof AuthRedisService === "undefined" ? Object : AuthRedisService,
|
|
11251
|
+
typeof MfaFlowLockoutService === "undefined" ? Object : MfaFlowLockoutService,
|
|
11252
|
+
typeof MfaRecordService === "undefined" ? Object : MfaRecordService,
|
|
11253
|
+
typeof IEmailProvider === "undefined" ? Object : IEmailProvider,
|
|
11254
|
+
typeof IAuthHooks === "undefined" ? Object : IAuthHooks
|
|
11255
|
+
])
|
|
11256
|
+
], MfaManagementService);
|
|
11257
|
+
function _ts_decorate41(decorators, target, key, desc) {
|
|
11258
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11259
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
11260
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
11261
|
+
} else {
|
|
11262
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
11263
|
+
if (d = decorators[i]) {
|
|
11264
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
11265
|
+
}
|
|
11266
|
+
}
|
|
11267
|
+
}
|
|
11268
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11269
|
+
}
|
|
11270
|
+
__name(_ts_decorate41, "_ts_decorate");
|
|
11271
|
+
function _ts_metadata40(metadataKey, metadataValue) {
|
|
11272
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
11273
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
11274
|
+
}
|
|
11275
|
+
}
|
|
11276
|
+
__name(_ts_metadata40, "_ts_metadata");
|
|
11277
|
+
function _ts_param25(paramIndex, decorator) {
|
|
11278
|
+
return function(target, key) {
|
|
11279
|
+
decorator(target, key, paramIndex);
|
|
11280
|
+
};
|
|
11281
|
+
}
|
|
11282
|
+
__name(_ts_param25, "_ts_param");
|
|
11283
|
+
exports.ReauthenticationService = class ReauthenticationService {
|
|
11284
|
+
static {
|
|
11285
|
+
__name(this, "ReauthenticationService");
|
|
11286
|
+
}
|
|
11287
|
+
options;
|
|
11288
|
+
redis;
|
|
11289
|
+
passwordService;
|
|
11290
|
+
lockout;
|
|
11291
|
+
logger = new common.Logger(MFA_LOG_CONTEXT);
|
|
11292
|
+
constructor(options, redis, passwordService, lockout) {
|
|
11293
|
+
this.options = options;
|
|
11294
|
+
this.redis = redis;
|
|
11295
|
+
this.passwordService = passwordService;
|
|
11296
|
+
this.lockout = lockout;
|
|
10974
11297
|
}
|
|
10975
11298
|
/**
|
|
10976
11299
|
* Requires the caller to re-prove the account password before a factor is changed.
|
|
10977
11300
|
*
|
|
10978
11301
|
* Counted like a login, and for the same reason. `login` refuses an account after N wrong
|
|
10979
|
-
* passwords
|
|
10980
|
-
* holding a stolen access token but not the password could guess it here
|
|
10981
|
-
*
|
|
10982
|
-
*
|
|
10983
|
-
* address.
|
|
11302
|
+
* passwords, and this door asks for the same secret, so it carries the same lockout: without
|
|
11303
|
+
* one, a caller holding a stolen access token but not the password could guess it here
|
|
11304
|
+
* indefinitely, bounded only by the per-route IP limit, which a distributed caller sidesteps.
|
|
11305
|
+
* Winning the guess buys the whole account: enrol a factor, change the password, move the
|
|
11306
|
+
* address.
|
|
10984
11307
|
*
|
|
10985
11308
|
* The identifier is namespaced by flow and by plane. Sharing one counter with `login` would
|
|
10986
11309
|
* let an authenticated caller lock the owner out of their own sign-in, and sharing it across
|
|
@@ -10994,7 +11317,7 @@ exports.MfaService = class _MfaService {
|
|
|
10994
11317
|
* @throws {@link AuthException} `ACCOUNT_LOCKED` once the failure budget for this flow is
|
|
10995
11318
|
* spent, or `INVALID_CREDENTIALS` when the account has a password and the submitted one is
|
|
10996
11319
|
* absent or wrong. The latter is deliberately the same code a failed login returns: an
|
|
10997
|
-
* attacker holding a stolen token learns nothing from it
|
|
11320
|
+
* attacker holding a stolen token learns nothing from it that a failed login does not tell them.
|
|
10998
11321
|
*/
|
|
10999
11322
|
async assertReauthenticated(context, userId, passwordHash, password, tenantId) {
|
|
11000
11323
|
if (passwordHash === null) {
|
|
@@ -11005,226 +11328,428 @@ exports.MfaService = class _MfaService {
|
|
|
11005
11328
|
}
|
|
11006
11329
|
return;
|
|
11007
11330
|
}
|
|
11008
|
-
if (await this.
|
|
11331
|
+
if (await this.lockout.isLockedOut("reauth", context, userId, tenantId)) {
|
|
11009
11332
|
this.logger.warn(`reauthenticate: account locked userId=${logSafe(userId)} context=${context}`);
|
|
11010
11333
|
throw new AuthException(AUTH_ERROR_CODES.ACCOUNT_LOCKED);
|
|
11011
11334
|
}
|
|
11012
11335
|
const supplied = password ?? "";
|
|
11013
11336
|
const matches = await this.passwordService.compare(supplied, passwordHash);
|
|
11014
11337
|
if (!matches) {
|
|
11015
|
-
await this.
|
|
11338
|
+
await this.lockout.recordFailure("reauth", context, userId, tenantId);
|
|
11016
11339
|
throw new AuthException(AUTH_ERROR_CODES.INVALID_CREDENTIALS);
|
|
11017
11340
|
}
|
|
11018
|
-
await this.
|
|
11341
|
+
await this.lockout.reset("reauth", context, userId, tenantId);
|
|
11342
|
+
}
|
|
11343
|
+
};
|
|
11344
|
+
exports.ReauthenticationService = _ts_decorate41([
|
|
11345
|
+
common.Injectable(),
|
|
11346
|
+
_ts_param25(0, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
11347
|
+
_ts_param25(1, common.Inject(AuthRedisService)),
|
|
11348
|
+
_ts_param25(2, common.Inject(PasswordService)),
|
|
11349
|
+
_ts_param25(3, common.Inject(MfaFlowLockoutService)),
|
|
11350
|
+
_ts_metadata40("design:type", Function),
|
|
11351
|
+
_ts_metadata40("design:paramtypes", [
|
|
11352
|
+
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
|
|
11353
|
+
typeof AuthRedisService === "undefined" ? Object : AuthRedisService,
|
|
11354
|
+
typeof PasswordService === "undefined" ? Object : PasswordService,
|
|
11355
|
+
typeof MfaFlowLockoutService === "undefined" ? Object : MfaFlowLockoutService
|
|
11356
|
+
])
|
|
11357
|
+
], exports.ReauthenticationService);
|
|
11358
|
+
|
|
11359
|
+
// src/server/utils/mfa-setup-data.ts
|
|
11360
|
+
function isMfaSetupData(value) {
|
|
11361
|
+
if (value === null) return false;
|
|
11362
|
+
if (typeof value !== "object") return false;
|
|
11363
|
+
const v = value;
|
|
11364
|
+
return typeof v["encryptedSecret"] === "string" && typeof v["encryptedPlainCodes"] === "string" && Array.isArray(v["hashedCodes"]) && v["hashedCodes"].every((code) => typeof code === "string");
|
|
11365
|
+
}
|
|
11366
|
+
__name(isMfaSetupData, "isMfaSetupData");
|
|
11367
|
+
function parseSetupData(raw, userId, logger) {
|
|
11368
|
+
let parsed;
|
|
11369
|
+
try {
|
|
11370
|
+
parsed = JSON.parse(raw);
|
|
11371
|
+
} catch {
|
|
11372
|
+
logger.warn(`parseSetupData: pending-setup payload is not valid JSON userId=${logSafe(userId)}`);
|
|
11373
|
+
throw new AuthException(AUTH_ERROR_CODES.MFA_SETUP_REQUIRED);
|
|
11374
|
+
}
|
|
11375
|
+
if (!isMfaSetupData(parsed)) {
|
|
11376
|
+
throw new AuthException(AUTH_ERROR_CODES.MFA_SETUP_REQUIRED);
|
|
11377
|
+
}
|
|
11378
|
+
return parsed;
|
|
11379
|
+
}
|
|
11380
|
+
__name(parseSetupData, "parseSetupData");
|
|
11381
|
+
function parsePlainRecoveryCodes(raw, userId, logger) {
|
|
11382
|
+
let parsed;
|
|
11383
|
+
try {
|
|
11384
|
+
parsed = JSON.parse(raw);
|
|
11385
|
+
} catch {
|
|
11386
|
+
logger.warn(`parsePlainRecoveryCodes: decrypted payload is not valid JSON userId=${logSafe(userId)}`);
|
|
11387
|
+
throw new AuthException(AUTH_ERROR_CODES.MFA_SETUP_REQUIRED);
|
|
11388
|
+
}
|
|
11389
|
+
if (!Array.isArray(parsed) || parsed.some((code) => typeof code !== "string")) {
|
|
11390
|
+
throw new AuthException(AUTH_ERROR_CODES.MFA_SETUP_REQUIRED);
|
|
11391
|
+
}
|
|
11392
|
+
return parsed;
|
|
11393
|
+
}
|
|
11394
|
+
__name(parsePlainRecoveryCodes, "parsePlainRecoveryCodes");
|
|
11395
|
+
|
|
11396
|
+
// src/server/services/mfa.service.ts
|
|
11397
|
+
function _ts_decorate42(decorators, target, key, desc) {
|
|
11398
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11399
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
11400
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
11401
|
+
} else {
|
|
11402
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
11403
|
+
if (d = decorators[i]) {
|
|
11404
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
11405
|
+
}
|
|
11406
|
+
}
|
|
11407
|
+
}
|
|
11408
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11409
|
+
}
|
|
11410
|
+
__name(_ts_decorate42, "_ts_decorate");
|
|
11411
|
+
function _ts_metadata41(metadataKey, metadataValue) {
|
|
11412
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
11413
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
11414
|
+
}
|
|
11415
|
+
}
|
|
11416
|
+
__name(_ts_metadata41, "_ts_metadata");
|
|
11417
|
+
function _ts_param26(paramIndex, decorator) {
|
|
11418
|
+
return function(target, key) {
|
|
11419
|
+
decorator(target, key, paramIndex);
|
|
11420
|
+
};
|
|
11421
|
+
}
|
|
11422
|
+
__name(_ts_param26, "_ts_param");
|
|
11423
|
+
var MFA_SETUP_TTL_SECONDS = 600;
|
|
11424
|
+
exports.MfaService = class _MfaService {
|
|
11425
|
+
static {
|
|
11426
|
+
__name(this, "MfaService");
|
|
11427
|
+
}
|
|
11428
|
+
options;
|
|
11429
|
+
userRepo;
|
|
11430
|
+
platformUserRepo;
|
|
11431
|
+
redis;
|
|
11432
|
+
tokenManager;
|
|
11433
|
+
records;
|
|
11434
|
+
challengeFlow;
|
|
11435
|
+
management;
|
|
11436
|
+
flowLockout;
|
|
11437
|
+
reauthentication;
|
|
11438
|
+
sessionService;
|
|
11439
|
+
emailProvider;
|
|
11440
|
+
hooks;
|
|
11441
|
+
logger = new common.Logger(_MfaService.name);
|
|
11442
|
+
constructor(options, userRepo, platformUserRepo, redis, tokenManager, records, challengeFlow, management, flowLockout, reauthentication, sessionService, emailProvider, hooks) {
|
|
11443
|
+
this.options = options;
|
|
11444
|
+
this.userRepo = userRepo;
|
|
11445
|
+
this.platformUserRepo = platformUserRepo;
|
|
11446
|
+
this.redis = redis;
|
|
11447
|
+
this.tokenManager = tokenManager;
|
|
11448
|
+
this.records = records;
|
|
11449
|
+
this.challengeFlow = challengeFlow;
|
|
11450
|
+
this.management = management;
|
|
11451
|
+
this.flowLockout = flowLockout;
|
|
11452
|
+
this.reauthentication = reauthentication;
|
|
11453
|
+
this.sessionService = sessionService;
|
|
11454
|
+
this.emailProvider = emailProvider;
|
|
11455
|
+
this.hooks = hooks;
|
|
11456
|
+
}
|
|
11457
|
+
// ---------------------------------------------------------------------------
|
|
11458
|
+
// Private accessor — options.mfa is guaranteed non-null when service is active
|
|
11459
|
+
// ---------------------------------------------------------------------------
|
|
11460
|
+
/**
|
|
11461
|
+
* Returns the resolved MFA configuration. `options.mfa` is always present when `MfaService` is registered.
|
|
11462
|
+
*
|
|
11463
|
+
* `options.mfa` is always present when `MfaService` is registered — the module
|
|
11464
|
+
* only registers the service when `mfa` is configured. The single suppression
|
|
11465
|
+
* here eliminates repetitive `!` assertions throughout the class.
|
|
11466
|
+
*/
|
|
11467
|
+
get mfaOptions() {
|
|
11468
|
+
return this.options.mfa;
|
|
11019
11469
|
}
|
|
11470
|
+
// ---------------------------------------------------------------------------
|
|
11471
|
+
// Private crypto helpers
|
|
11472
|
+
// ---------------------------------------------------------------------------
|
|
11473
|
+
// ---------------------------------------------------------------------------
|
|
11474
|
+
// setup — TOTP secret generation, idempotent key reservation, recovery codes
|
|
11475
|
+
// ---------------------------------------------------------------------------
|
|
11020
11476
|
/**
|
|
11021
|
-
*
|
|
11477
|
+
* Initiates the MFA setup flow for a dashboard user or platform administrator.
|
|
11478
|
+
*
|
|
11479
|
+
* Generates a TOTP secret and 8 recovery codes, stores them temporarily in
|
|
11480
|
+
* Redis (10 minutes), and returns the data needed to display the QR code and
|
|
11481
|
+
* recovery codes to the user.
|
|
11022
11482
|
*
|
|
11023
|
-
*
|
|
11024
|
-
*
|
|
11025
|
-
*
|
|
11026
|
-
* MFA flows sits under a `context === 'dashboard'` branch where a `void` guard run earlier in
|
|
11027
|
-
* the caller has narrowed nothing. Without this the branch had to pass `string | undefined`
|
|
11028
|
-
* into a `string` parameter, which is precisely the tenant-blind read the guard exists to stop.
|
|
11483
|
+
* Idempotent: concurrent or repeated calls within the TTL window all receive the
|
|
11484
|
+
* same secret and codes. An atomic SET-NX is used so that two simultaneous setup
|
|
11485
|
+
* requests cannot generate different secrets.
|
|
11029
11486
|
*
|
|
11030
|
-
* @param
|
|
11031
|
-
* @
|
|
11487
|
+
* @param userId - Internal ID of the user enabling MFA.
|
|
11488
|
+
* @param context - Which repository to use: `'dashboard'` (default) or `'platform'`.
|
|
11489
|
+
* @returns Setup result containing the secret, QR URI, and plain recovery codes.
|
|
11490
|
+
* @throws `MFA_ALREADY_ENABLED` if MFA is already active on the account.
|
|
11491
|
+
* @throws `MFA_NOT_ENABLED` if `context === 'platform'` and the platform user
|
|
11492
|
+
* repository was not configured at module registration. The error code is
|
|
11493
|
+
* reused (rather than introducing a new one) because the consumer-facing
|
|
11494
|
+
* meaning is the same: "platform MFA cannot operate".
|
|
11032
11495
|
*/
|
|
11033
|
-
|
|
11034
|
-
|
|
11035
|
-
|
|
11036
|
-
|
|
11037
|
-
|
|
11038
|
-
|
|
11039
|
-
|
|
11040
|
-
|
|
11496
|
+
async setup(userId, context = "dashboard", password, tenantId) {
|
|
11497
|
+
assertPlaneTenant(context, tenantId);
|
|
11498
|
+
if (context === "platform" && !this.platformUserRepo) {
|
|
11499
|
+
throw new AuthException(AUTH_ERROR_CODES.MFA_NOT_ENABLED);
|
|
11500
|
+
}
|
|
11501
|
+
const user = await this.records.loadAccount(context, userId, tenantId);
|
|
11502
|
+
if (user.mfaEnabled) throw new AuthException(AUTH_ERROR_CODES.MFA_ALREADY_ENABLED);
|
|
11503
|
+
await this.reauthentication.assertReauthenticated(context, userId, user.passwordHash, password, tenantId);
|
|
11504
|
+
const setupKey = `mfa_setup:${hmacSha256(userSubject(context, userId, tenantId), this.options.hmacKey)}`;
|
|
11505
|
+
const existingFast = await this.redis.get(setupKey);
|
|
11506
|
+
if (existingFast !== null) {
|
|
11507
|
+
const data = parseSetupData(existingFast, userId, this.logger);
|
|
11508
|
+
const existingSecret = decryptMfaSecret(data.encryptedSecret, this.mfaOptions);
|
|
11509
|
+
const decryptedCodesJson = decryptMfaSecret(data.encryptedPlainCodes, this.mfaOptions);
|
|
11510
|
+
const existingCodes = parsePlainRecoveryCodes(decryptedCodesJson, userId, this.logger);
|
|
11511
|
+
const qrCodeUri2 = buildTotpUri(existingSecret, user.email, this.mfaOptions.issuer);
|
|
11512
|
+
return {
|
|
11513
|
+
secret: existingSecret,
|
|
11514
|
+
qrCodeUri: qrCodeUri2,
|
|
11515
|
+
recoveryCodes: existingCodes
|
|
11516
|
+
};
|
|
11517
|
+
}
|
|
11518
|
+
const { base32: secretBase32 } = generateTotpSecret();
|
|
11519
|
+
const encryptedSecret = encryptMfaSecret(secretBase32, this.mfaOptions);
|
|
11520
|
+
const recoveryCount = this.mfaOptions.recoveryCodeCount ?? DEFAULT_RECOVERY_CODE_COUNT;
|
|
11521
|
+
const { plainCodes, hashedCodes } = generateRecoveryCodes(recoveryCount, this.options.hmacKey);
|
|
11522
|
+
const encryptedPlainCodes = encrypt(JSON.stringify(plainCodes), this.mfaOptions.encryptionKey);
|
|
11523
|
+
const setupData = {
|
|
11524
|
+
encryptedSecret,
|
|
11525
|
+
hashedCodes,
|
|
11526
|
+
encryptedPlainCodes
|
|
11527
|
+
};
|
|
11528
|
+
const payload = JSON.stringify(setupData);
|
|
11529
|
+
const wasSet = await this.redis.setIfAbsent(setupKey, payload, MFA_SETUP_TTL_SECONDS);
|
|
11530
|
+
if (!wasSet) {
|
|
11531
|
+
const existing = await this.redis.get(setupKey);
|
|
11532
|
+
if (existing !== null) {
|
|
11533
|
+
const data = parseSetupData(existing, userId, this.logger);
|
|
11534
|
+
const existingSecret = decryptMfaSecret(data.encryptedSecret, this.mfaOptions);
|
|
11535
|
+
const decryptedCodesJson = decryptMfaSecret(data.encryptedPlainCodes, this.mfaOptions);
|
|
11536
|
+
const existingCodes = parsePlainRecoveryCodes(decryptedCodesJson, userId, this.logger);
|
|
11537
|
+
const qrCodeUri2 = buildTotpUri(existingSecret, user.email, this.mfaOptions.issuer);
|
|
11538
|
+
return {
|
|
11539
|
+
secret: existingSecret,
|
|
11540
|
+
qrCodeUri: qrCodeUri2,
|
|
11541
|
+
recoveryCodes: existingCodes
|
|
11542
|
+
};
|
|
11543
|
+
}
|
|
11544
|
+
await this.redis.set(setupKey, payload, MFA_SETUP_TTL_SECONDS);
|
|
11041
11545
|
}
|
|
11546
|
+
const qrCodeUri = buildTotpUri(secretBase32, user.email, this.mfaOptions.issuer);
|
|
11547
|
+
this.logger.log(`setup: MFA setup initiated userId=${logSafe(userId)} context=${context}`);
|
|
11548
|
+
return {
|
|
11549
|
+
secret: secretBase32,
|
|
11550
|
+
qrCodeUri,
|
|
11551
|
+
recoveryCodes: plainCodes
|
|
11552
|
+
};
|
|
11042
11553
|
}
|
|
11554
|
+
// ---------------------------------------------------------------------------
|
|
11555
|
+
// verifyAndEnable — first-time TOTP validation and permanent MFA activation
|
|
11556
|
+
// ---------------------------------------------------------------------------
|
|
11043
11557
|
/**
|
|
11044
|
-
*
|
|
11558
|
+
* Verifies the first TOTP code from the user's authenticator app and permanently
|
|
11559
|
+
* enables MFA on the account.
|
|
11045
11560
|
*
|
|
11046
|
-
*
|
|
11047
|
-
*
|
|
11048
|
-
*
|
|
11049
|
-
*
|
|
11050
|
-
* and key derivation. Refuse it here, naming the field, rather than let it degrade to the
|
|
11051
|
-
* pre-tenant behaviour, which is exactly the fallback an attacker would aim for.
|
|
11561
|
+
* After enabling, all existing refresh sessions are atomically invalidated to
|
|
11562
|
+
* force re-authentication through the MFA challenge endpoint. Active access tokens
|
|
11563
|
+
* (up to `accessExpiresIn`, default 15 min) remain valid — they are not
|
|
11564
|
+
* blacklisted since the library does not track JTIs server-side.
|
|
11052
11565
|
*
|
|
11053
|
-
* @param
|
|
11054
|
-
* @param
|
|
11055
|
-
* @
|
|
11056
|
-
*
|
|
11566
|
+
* @param userId - Internal ID of the user completing MFA setup.
|
|
11567
|
+
* @param code - 6-digit TOTP code from the authenticator app.
|
|
11568
|
+
* @param ip - Client IP address (forwarded to hooks).
|
|
11569
|
+
* @param userAgent - User-Agent header (forwarded to hooks).
|
|
11570
|
+
* @param context - Which repository to use: `'dashboard'` (default) or `'platform'`.
|
|
11571
|
+
* @throws {@link AuthException} MFA_ALREADY_ENABLED when MFA is already active on the account.
|
|
11572
|
+
* @throws `MFA_SETUP_REQUIRED` if no pending setup data is found in Redis.
|
|
11573
|
+
* @throws `MFA_INVALID_CODE` if the submitted TOTP code is invalid.
|
|
11574
|
+
* @throws `MFA_NOT_ENABLED` if `context === 'platform'` and the platform user
|
|
11575
|
+
* repository was not configured at module registration.
|
|
11057
11576
|
*/
|
|
11058
|
-
|
|
11059
|
-
|
|
11060
|
-
|
|
11061
|
-
|
|
11577
|
+
async verifyAndEnable(userId, code, ip, userAgent, context = "dashboard", tenantId) {
|
|
11578
|
+
assertPlaneTenant(context, tenantId);
|
|
11579
|
+
if (context === "platform" && !this.platformUserRepo) {
|
|
11580
|
+
throw new AuthException(AUTH_ERROR_CODES.MFA_NOT_ENABLED);
|
|
11062
11581
|
}
|
|
11063
|
-
|
|
11064
|
-
|
|
11065
|
-
|
|
11066
|
-
|
|
11067
|
-
|
|
11068
|
-
|
|
11069
|
-
|
|
11582
|
+
const user = await this.records.loadAccount(context, userId, tenantId);
|
|
11583
|
+
if (user.mfaEnabled) throw new AuthException(AUTH_ERROR_CODES.MFA_ALREADY_ENABLED);
|
|
11584
|
+
const setupKey = `mfa_setup:${hmacSha256(userSubject(context, userId, tenantId), this.options.hmacKey)}`;
|
|
11585
|
+
const raw = await this.redis.get(setupKey);
|
|
11586
|
+
if (raw === null) throw new AuthException(AUTH_ERROR_CODES.MFA_SETUP_REQUIRED);
|
|
11587
|
+
const data = parseSetupData(raw, userId, this.logger);
|
|
11588
|
+
const secretBase32 = decryptMfaSecret(data.encryptedSecret, this.mfaOptions);
|
|
11589
|
+
const totpWindow = this.mfaOptions.totpWindow;
|
|
11590
|
+
const codeValid = await this.records.verifyTotpWithAntiReplay(context, userId, secretBase32, code, totpWindow, tenantId);
|
|
11591
|
+
if (!codeValid) {
|
|
11592
|
+
this.logger.warn(`verifyAndEnable: invalid TOTP code userId=${logSafe(userId)}`);
|
|
11593
|
+
throw new AuthException(AUTH_ERROR_CODES.MFA_INVALID_CODE);
|
|
11594
|
+
}
|
|
11595
|
+
const consumed = await this.redis.getdel(setupKey);
|
|
11596
|
+
if (consumed === null) {
|
|
11597
|
+
this.logger.warn(`verifyAndEnable: setup key consumed by concurrent request userId=${logSafe(userId)}`);
|
|
11598
|
+
throw new AuthException(AUTH_ERROR_CODES.MFA_SETUP_REQUIRED);
|
|
11599
|
+
}
|
|
11600
|
+
await this.records.transition(context, userId, tenantId, () => ({
|
|
11601
|
+
mfaEnabled: true,
|
|
11602
|
+
mfaSecret: data.encryptedSecret,
|
|
11603
|
+
mfaRecoveryCodes: data.hashedCodes
|
|
11604
|
+
}));
|
|
11605
|
+
await this.redis.invalidateUserSessions(userId, tenantId, context);
|
|
11606
|
+
await this.redis.bumpUserTokenEpoch(userId, tenantId, context);
|
|
11607
|
+
this.logger.log(`verifyAndEnable: MFA enabled userId=${logSafe(userId)} context=${context}`);
|
|
11608
|
+
notifyMfaChange(this.logger, this.emailProvider, "verifyAndEnable", userId, user, (provider, tenant, email) => provider.sendMfaEnabledNotification(tenant, email));
|
|
11609
|
+
if (this.hooks.afterMfaEnabled) {
|
|
11610
|
+
const safeUser = committedSafeUser(context, user, true);
|
|
11611
|
+
void Promise.resolve(this.hooks.afterMfaEnabled(safeUser, {
|
|
11612
|
+
// The plane, because the tenant cannot carry it: a platform admin is rendered with the
|
|
11613
|
+
// sentinel `tenantId: ''` while a platform token has no tenant claim at all.
|
|
11614
|
+
plane: context,
|
|
11615
|
+
userId,
|
|
11616
|
+
ip,
|
|
11617
|
+
userAgent,
|
|
11618
|
+
sanitizedHeaders: {}
|
|
11619
|
+
})).catch(() => void 0);
|
|
11070
11620
|
}
|
|
11071
11621
|
}
|
|
11622
|
+
// ---------------------------------------------------------------------------
|
|
11623
|
+
// challenge — MFA temp token exchange for full auth tokens (TOTP or recovery code)
|
|
11624
|
+
// ---------------------------------------------------------------------------
|
|
11072
11625
|
/**
|
|
11073
|
-
*
|
|
11074
|
-
*
|
|
11075
|
-
* on the dashboard plane, where it now does.
|
|
11626
|
+
* Validates a TOTP or recovery code and exchanges the MFA temp token for full
|
|
11627
|
+
* access tokens.
|
|
11076
11628
|
*
|
|
11077
|
-
*
|
|
11078
|
-
*
|
|
11079
|
-
*
|
|
11080
|
-
*
|
|
11081
|
-
*
|
|
11082
|
-
*
|
|
11083
|
-
*
|
|
11084
|
-
*
|
|
11085
|
-
*
|
|
11086
|
-
|
|
11087
|
-
|
|
11088
|
-
return {
|
|
11089
|
-
legacy: hmacSha256(`${flow}:${context}:${userId}`, this.options.hmacKey),
|
|
11090
|
-
scoped: hmacSha256(`${flow}:${userSubject(context, userId, tenantId)}`, this.options.hmacKey)
|
|
11091
|
-
};
|
|
11092
|
-
}
|
|
11093
|
-
/**
|
|
11094
|
-
* Locked out when EITHER the legacy or the tenant-scoped counter has reached the threshold, so
|
|
11095
|
-
* neither a lockout an old pod recorded nor one a new pod recorded can be bypassed mid-migration.
|
|
11629
|
+
* Handles both `'dashboard'` and `'platform'` contexts; the flow lives in
|
|
11630
|
+
* {@link MfaChallengeService.challenge}.
|
|
11631
|
+
*
|
|
11632
|
+
* @param mfaTempToken - Short-lived MFA challenge JWT issued at login.
|
|
11633
|
+
* @param code - 6-digit TOTP code or `dddd-dddd-dddd` recovery code.
|
|
11634
|
+
* @param ip - Client IP address for session audit.
|
|
11635
|
+
* @param userAgent - User-Agent header for session description.
|
|
11636
|
+
* @returns `AuthResult` for dashboard context, `PlatformAuthResult` for platform context.
|
|
11637
|
+
* @throws `MFA_TEMP_TOKEN_INVALID` if the token is invalid or already consumed.
|
|
11638
|
+
* @throws `ACCOUNT_LOCKED` if the brute-force threshold has been reached.
|
|
11639
|
+
* @throws `MFA_INVALID_CODE` if the submitted code is incorrect.
|
|
11096
11640
|
*/
|
|
11097
|
-
async
|
|
11098
|
-
|
|
11099
|
-
if (await this.bruteForce.isLockedOut(scoped)) return true;
|
|
11100
|
-
return legacy !== scoped ? this.bruteForce.isLockedOut(legacy) : false;
|
|
11641
|
+
async challenge(mfaTempToken, code, ip, userAgent) {
|
|
11642
|
+
return this.challengeFlow.challenge(mfaTempToken, code, ip, userAgent, this.mfaOptions);
|
|
11101
11643
|
}
|
|
11102
11644
|
/**
|
|
11103
|
-
*
|
|
11104
|
-
*
|
|
11645
|
+
* The challenge for an entry point that serves the platform plane only: a dashboard token is
|
|
11646
|
+
* refused with `PLATFORM_AUTH_REQUIRED` before anything is spent. See
|
|
11647
|
+
* {@link MfaChallengeService.challengePlatformOnly}.
|
|
11648
|
+
*
|
|
11649
|
+
* @param mfaTempToken - Short-lived MFA challenge JWT issued at platform login.
|
|
11650
|
+
* @param code - 6-digit TOTP code or `dddd-dddd-dddd` recovery code.
|
|
11651
|
+
* @param ip - Client IP address for session audit.
|
|
11652
|
+
* @param userAgent - User-Agent header for session description.
|
|
11653
|
+
* @returns The platform auth result.
|
|
11654
|
+
* @throws `PLATFORM_AUTH_REQUIRED` if the token is for the dashboard plane.
|
|
11655
|
+
* @throws `MFA_TEMP_TOKEN_INVALID` if the token is invalid or already consumed.
|
|
11656
|
+
* @throws `ACCOUNT_LOCKED` if the brute-force threshold has been reached.
|
|
11657
|
+
* @throws `MFA_INVALID_CODE` if the submitted code is incorrect.
|
|
11105
11658
|
*/
|
|
11106
|
-
async
|
|
11107
|
-
|
|
11108
|
-
await this.bruteForce.recordFailure(scoped);
|
|
11109
|
-
if (legacy !== scoped) await this.bruteForce.recordFailure(legacy);
|
|
11659
|
+
async challengePlatformOnly(mfaTempToken, code, ip, userAgent) {
|
|
11660
|
+
return this.challengeFlow.challengePlatformOnly(mfaTempToken, code, ip, userAgent, this.mfaOptions);
|
|
11110
11661
|
}
|
|
11662
|
+
// ---------------------------------------------------------------------------
|
|
11663
|
+
// disable, resetMfa, regenerateRecoveryCodes — changes to an existing enrolment
|
|
11664
|
+
// ---------------------------------------------------------------------------
|
|
11111
11665
|
/**
|
|
11112
|
-
*
|
|
11113
|
-
*
|
|
11666
|
+
* Disables MFA on a user's account after verifying a current TOTP code.
|
|
11667
|
+
*
|
|
11668
|
+
* Only TOTP codes are accepted — recovery codes cannot disable MFA by design. The flow lives in
|
|
11669
|
+
* {@link MfaManagementService.disable}.
|
|
11670
|
+
*
|
|
11671
|
+
* @param userId - Internal ID of the user disabling MFA.
|
|
11672
|
+
* @param code - 6-digit TOTP code from the authenticator app.
|
|
11673
|
+
* @param ip - Client IP address (forwarded to hooks).
|
|
11674
|
+
* @param userAgent - User-Agent header (forwarded to hooks).
|
|
11675
|
+
* @param context - Which repository to use: `'dashboard'` (default) or `'platform'`.
|
|
11676
|
+
* @param tenantId - The tenant on the dashboard plane; absent on the platform plane.
|
|
11677
|
+
* @throws `TOKEN_INVALID` if the user is not found.
|
|
11678
|
+
* @throws `MFA_NOT_ENABLED` if MFA is not currently active.
|
|
11679
|
+
* @throws `ACCOUNT_LOCKED` if the brute-force threshold has been reached.
|
|
11680
|
+
* @throws `MFA_INVALID_CODE` if the submitted TOTP code is incorrect.
|
|
11114
11681
|
*/
|
|
11115
|
-
async
|
|
11116
|
-
|
|
11117
|
-
await this.bruteForce.resetFailures(scoped);
|
|
11118
|
-
if (legacy !== scoped) await this.bruteForce.resetFailures(legacy);
|
|
11682
|
+
async disable(userId, code, ip, userAgent, context = "dashboard", tenantId) {
|
|
11683
|
+
return this.management.disable(userId, code, ip, userAgent, context, tenantId, this.mfaOptions);
|
|
11119
11684
|
}
|
|
11120
11685
|
/**
|
|
11121
|
-
*
|
|
11122
|
-
*
|
|
11123
|
-
* **Not awaited, and that is the fix, not a shortcut.** These three sends used to be awaited
|
|
11124
|
-
* with no `catch`, so a rejected delivery travelled out of the service to `AuthExceptionFilter`
|
|
11125
|
-
* — which answered the caller with an error for an operation that had ALREADY completed. By
|
|
11126
|
-
* that point the secret is written, the sessions are invalidated and the token epoch is bumped;
|
|
11127
|
-
* the user's second factor is on, and telling them it failed is how they end up locked out of
|
|
11128
|
-
* an account they just secured. `PasswordResetService.notifyPasswordChanged` had reached the
|
|
11129
|
-
* same conclusion for the same reason.
|
|
11686
|
+
* Removes a user's second factor without their TOTP code, for a support desk facing a user who
|
|
11687
|
+
* has lost their authenticator AND their recovery codes.
|
|
11130
11688
|
*
|
|
11131
|
-
*
|
|
11132
|
-
*
|
|
11133
|
-
* rejected`) — no quoted body required, which makes it the likeliest exposure of the set.
|
|
11134
|
-
* `describeChannelStatus` publishes nothing the channel wrote, and nothing parsed off it either,
|
|
11135
|
-
* so no part of that name comes through. `withheld` covers the fields this line composes rather than the error, and
|
|
11136
|
-
* `safeLogLine` checks the seam the template opens between them.
|
|
11689
|
+
* Authorising the caller is the consumer's job: the library ships no route for this. The flow
|
|
11690
|
+
* lives in {@link MfaManagementService.resetMfa}. Idempotent.
|
|
11137
11691
|
*
|
|
11138
|
-
* @param
|
|
11139
|
-
* @param
|
|
11140
|
-
*
|
|
11141
|
-
* @param
|
|
11692
|
+
* @param userId - Internal ID of the user whose second factor is being removed.
|
|
11693
|
+
* @param context - Which identity plane the user belongs to: `'dashboard'` (default) or
|
|
11694
|
+
* `'platform'`. Must match the plane the account lives in, or the lookup misses.
|
|
11695
|
+
* @param tenantId - The tenant on the dashboard plane; absent on the platform plane.
|
|
11696
|
+
* @throws `TOKEN_INVALID` if no user with that ID exists in the given plane.
|
|
11142
11697
|
*/
|
|
11143
|
-
|
|
11144
|
-
|
|
11145
|
-
const tenantId = emailTenantOf(user);
|
|
11146
|
-
const email = user.email;
|
|
11147
|
-
const withheld = [
|
|
11148
|
-
email
|
|
11149
|
-
];
|
|
11150
|
-
void (async () => {
|
|
11151
|
-
try {
|
|
11152
|
-
await send(provider, tenantId, email);
|
|
11153
|
-
} catch (err) {
|
|
11154
|
-
this.logger.error(safeLogLine(`${origin}: MFA notice delivery failed for user ${logSafe(userId)}: ` + describeChannelStatus(err), withheld));
|
|
11155
|
-
}
|
|
11156
|
-
})();
|
|
11698
|
+
async resetMfa(userId, context = "dashboard", tenantId) {
|
|
11699
|
+
return this.management.resetMfa(userId, context, tenantId);
|
|
11157
11700
|
}
|
|
11158
11701
|
/**
|
|
11159
|
-
*
|
|
11160
|
-
*
|
|
11161
|
-
*
|
|
11162
|
-
* The status gate lives here rather than in each caller because every entry point that
|
|
11163
|
-
* reaches this method changes or spends an authentication factor, and every one of them
|
|
11164
|
-
* must refuse a suspended or banned account. It used to live in `challenge` alone, so
|
|
11165
|
-
* `setup`, `verifyAndEnable`, `disable` and `regenerateRecoveryCodes` had no gate at all:
|
|
11166
|
-
* an operator who suspended a compromised account bought nothing against an attacker still
|
|
11167
|
-
* holding an unexpired access token, who could turn the second factor off — or enrol their
|
|
11168
|
-
* own authenticator over it — for the token's remaining lifetime. Nothing else covers that
|
|
11169
|
-
* window: no status change bumps the token epoch, so the per-request check is the only
|
|
11170
|
-
* defence, and neither MFA controller composes `UserStatusGuard` (the platform plane has no
|
|
11171
|
-
* status guard at all). Every other authority-bearing route in the library does gate on
|
|
11172
|
-
* status; changing an authentication factor is at least as privileged as minting an
|
|
11173
|
-
* invitation.
|
|
11174
|
-
*
|
|
11175
|
-
* Gating the fetch rather than the callers is deliberate: a method added later inherits the
|
|
11176
|
-
* check instead of having to remember it.
|
|
11702
|
+
* Regenerates the user's MFA recovery codes after verifying a current TOTP code. Sessions are
|
|
11703
|
+
* intentionally NOT invalidated: the TOTP secret is unchanged. The flow lives in
|
|
11704
|
+
* {@link MfaManagementService.regenerateRecoveryCodes}.
|
|
11177
11705
|
*
|
|
11178
|
-
* @param
|
|
11179
|
-
* @param
|
|
11180
|
-
* @param
|
|
11181
|
-
*
|
|
11182
|
-
* @
|
|
11183
|
-
* @
|
|
11184
|
-
* @throws
|
|
11706
|
+
* @param userId - Internal ID of the user rotating recovery codes.
|
|
11707
|
+
* @param totpCode - 6-digit TOTP code from the authenticator app.
|
|
11708
|
+
* @param ip - Client IP address (forwarded to hooks).
|
|
11709
|
+
* @param userAgent - User-Agent header (forwarded to hooks).
|
|
11710
|
+
* @param context - Which repository to use: `'dashboard'` (default) or `'platform'`.
|
|
11711
|
+
* @param tenantId - The tenant on the dashboard plane; absent on the platform plane.
|
|
11712
|
+
* @throws `TOKEN_INVALID` if the user is not found or `mfaSecret` is missing
|
|
11713
|
+
* when `mfaEnabled` is `true` (database inconsistency).
|
|
11714
|
+
* @throws `MFA_NOT_ENABLED` if MFA is not currently active, or if
|
|
11715
|
+
* `context === 'platform'` and the platform user repository was not
|
|
11716
|
+
* configured at module registration.
|
|
11717
|
+
* @throws `ACCOUNT_LOCKED` if the brute-force threshold has been reached.
|
|
11718
|
+
* @throws `MFA_INVALID_CODE` if the submitted TOTP code is incorrect.
|
|
11719
|
+
* @returns The freshly generated plain-text recovery codes, one-time display.
|
|
11185
11720
|
*/
|
|
11186
|
-
async
|
|
11187
|
-
|
|
11188
|
-
this.assertDashboardTenant(tenantId);
|
|
11189
|
-
const user = await this.userRepo.findById({
|
|
11190
|
-
id: userId,
|
|
11191
|
-
tenantId
|
|
11192
|
-
});
|
|
11193
|
-
if (!user) throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
|
|
11194
|
-
assertNotBlocked(user.status, this.options.blockedStatuses);
|
|
11195
|
-
return user;
|
|
11196
|
-
}
|
|
11197
|
-
if (!this.platformUserRepo) {
|
|
11198
|
-
throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
|
|
11199
|
-
}
|
|
11200
|
-
const admin = await this.platformUserRepo.findById(userId);
|
|
11201
|
-
if (!admin) throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
|
|
11202
|
-
assertNotBlocked(admin.status, this.options.blockedStatuses);
|
|
11203
|
-
return admin;
|
|
11721
|
+
async regenerateRecoveryCodes(userId, totpCode, ip, userAgent, context = "dashboard", tenantId) {
|
|
11722
|
+
return this.management.regenerateRecoveryCodes(userId, totpCode, ip, userAgent, context, tenantId, this.mfaOptions);
|
|
11204
11723
|
}
|
|
11205
11724
|
};
|
|
11206
|
-
exports.MfaService =
|
|
11725
|
+
exports.MfaService = _ts_decorate42([
|
|
11207
11726
|
common.Injectable(),
|
|
11208
|
-
|
|
11209
|
-
|
|
11210
|
-
|
|
11211
|
-
|
|
11212
|
-
|
|
11213
|
-
|
|
11214
|
-
|
|
11215
|
-
|
|
11216
|
-
|
|
11217
|
-
|
|
11218
|
-
|
|
11219
|
-
|
|
11220
|
-
|
|
11727
|
+
_ts_param26(0, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
11728
|
+
_ts_param26(1, common.Inject(BYMAX_AUTH_USER_REPOSITORY)),
|
|
11729
|
+
_ts_param26(2, common.Optional()),
|
|
11730
|
+
_ts_param26(2, common.Inject(BYMAX_AUTH_PLATFORM_USER_REPOSITORY)),
|
|
11731
|
+
_ts_param26(3, common.Inject(AuthRedisService)),
|
|
11732
|
+
_ts_param26(4, common.Inject(TokenManagerService)),
|
|
11733
|
+
_ts_param26(5, common.Inject(MfaRecordService)),
|
|
11734
|
+
_ts_param26(6, common.Inject(MfaChallengeService)),
|
|
11735
|
+
_ts_param26(7, common.Inject(MfaManagementService)),
|
|
11736
|
+
_ts_param26(8, common.Inject(MfaFlowLockoutService)),
|
|
11737
|
+
_ts_param26(9, common.Inject(exports.ReauthenticationService)),
|
|
11738
|
+
_ts_param26(10, common.Inject(exports.SessionService)),
|
|
11739
|
+
_ts_param26(11, common.Inject(BYMAX_AUTH_EMAIL_PROVIDER)),
|
|
11740
|
+
_ts_param26(12, common.Inject(BYMAX_AUTH_HOOKS)),
|
|
11741
|
+
_ts_metadata41("design:type", Function),
|
|
11742
|
+
_ts_metadata41("design:paramtypes", [
|
|
11221
11743
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
|
|
11222
11744
|
typeof IUserRepository === "undefined" ? Object : IUserRepository,
|
|
11223
11745
|
Object,
|
|
11224
11746
|
typeof AuthRedisService === "undefined" ? Object : AuthRedisService,
|
|
11225
11747
|
typeof TokenManagerService === "undefined" ? Object : TokenManagerService,
|
|
11226
|
-
typeof
|
|
11227
|
-
typeof
|
|
11748
|
+
typeof MfaRecordService === "undefined" ? Object : MfaRecordService,
|
|
11749
|
+
typeof MfaChallengeService === "undefined" ? Object : MfaChallengeService,
|
|
11750
|
+
typeof MfaManagementService === "undefined" ? Object : MfaManagementService,
|
|
11751
|
+
typeof MfaFlowLockoutService === "undefined" ? Object : MfaFlowLockoutService,
|
|
11752
|
+
typeof exports.ReauthenticationService === "undefined" ? Object : exports.ReauthenticationService,
|
|
11228
11753
|
typeof exports.SessionService === "undefined" ? Object : exports.SessionService,
|
|
11229
11754
|
typeof IEmailProvider === "undefined" ? Object : IEmailProvider,
|
|
11230
11755
|
typeof IAuthHooks === "undefined" ? Object : IAuthHooks
|
|
@@ -11232,7 +11757,7 @@ exports.MfaService = _ts_decorate37([
|
|
|
11232
11757
|
], exports.MfaService);
|
|
11233
11758
|
|
|
11234
11759
|
// src/server/controllers/mfa.controller.ts
|
|
11235
|
-
function
|
|
11760
|
+
function _ts_decorate43(decorators, target, key, desc) {
|
|
11236
11761
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11237
11762
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
11238
11763
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -11245,19 +11770,19 @@ function _ts_decorate38(decorators, target, key, desc) {
|
|
|
11245
11770
|
}
|
|
11246
11771
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11247
11772
|
}
|
|
11248
|
-
__name(
|
|
11249
|
-
function
|
|
11773
|
+
__name(_ts_decorate43, "_ts_decorate");
|
|
11774
|
+
function _ts_metadata42(metadataKey, metadataValue) {
|
|
11250
11775
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
11251
11776
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
11252
11777
|
}
|
|
11253
11778
|
}
|
|
11254
|
-
__name(
|
|
11255
|
-
function
|
|
11779
|
+
__name(_ts_metadata42, "_ts_metadata");
|
|
11780
|
+
function _ts_param27(paramIndex, decorator) {
|
|
11256
11781
|
return function(target, key) {
|
|
11257
11782
|
decorator(target, key, paramIndex);
|
|
11258
11783
|
};
|
|
11259
11784
|
}
|
|
11260
|
-
__name(
|
|
11785
|
+
__name(_ts_param27, "_ts_param");
|
|
11261
11786
|
function isPlatformResult(result) {
|
|
11262
11787
|
return "admin" in result;
|
|
11263
11788
|
}
|
|
@@ -11446,111 +11971,111 @@ var MfaController = class {
|
|
|
11446
11971
|
return this.mfaService.regenerateRecoveryCodes(user.sub, dto.code, ip, userAgent, "dashboard", user.tenantId);
|
|
11447
11972
|
}
|
|
11448
11973
|
};
|
|
11449
|
-
|
|
11974
|
+
_ts_decorate43([
|
|
11450
11975
|
common.UseGuards(exports.JwtAuthGuard, exports.UserStatusGuard),
|
|
11451
11976
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.mfaSetup),
|
|
11452
11977
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaSetup),
|
|
11453
11978
|
RequestEncoding("when-body"),
|
|
11454
11979
|
common.Post("setup"),
|
|
11455
|
-
|
|
11456
|
-
|
|
11457
|
-
|
|
11458
|
-
|
|
11980
|
+
_ts_param27(0, CurrentUser()),
|
|
11981
|
+
_ts_param27(1, common.Body()),
|
|
11982
|
+
_ts_metadata42("design:type", Function),
|
|
11983
|
+
_ts_metadata42("design:paramtypes", [
|
|
11459
11984
|
typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
|
|
11460
11985
|
typeof MfaSetupDto === "undefined" ? Object : MfaSetupDto
|
|
11461
11986
|
]),
|
|
11462
|
-
|
|
11987
|
+
_ts_metadata42("design:returntype", Promise)
|
|
11463
11988
|
], MfaController.prototype, "setup", null);
|
|
11464
|
-
|
|
11989
|
+
_ts_decorate43([
|
|
11465
11990
|
common.UseGuards(exports.JwtAuthGuard, exports.UserStatusGuard),
|
|
11466
11991
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.mfaVerifyEnable),
|
|
11467
11992
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaVerifyEnable),
|
|
11468
11993
|
common.HttpCode(common.HttpStatus.NO_CONTENT),
|
|
11469
11994
|
common.Post("verify-enable"),
|
|
11470
|
-
|
|
11471
|
-
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
|
|
11995
|
+
_ts_param27(0, CurrentUser()),
|
|
11996
|
+
_ts_param27(1, common.Body()),
|
|
11997
|
+
_ts_param27(2, common.Req()),
|
|
11998
|
+
_ts_metadata42("design:type", Function),
|
|
11999
|
+
_ts_metadata42("design:paramtypes", [
|
|
11475
12000
|
typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
|
|
11476
12001
|
typeof MfaVerifyDto === "undefined" ? Object : MfaVerifyDto,
|
|
11477
12002
|
typeof Request === "undefined" ? Object : Request
|
|
11478
12003
|
]),
|
|
11479
|
-
|
|
12004
|
+
_ts_metadata42("design:returntype", Promise)
|
|
11480
12005
|
], MfaController.prototype, "verifyEnable", null);
|
|
11481
|
-
|
|
12006
|
+
_ts_decorate43([
|
|
11482
12007
|
Public(),
|
|
11483
12008
|
SkipMfa(),
|
|
11484
12009
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.mfaChallenge),
|
|
11485
12010
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaChallenge),
|
|
11486
12011
|
common.HttpCode(common.HttpStatus.OK),
|
|
11487
12012
|
common.Post("challenge"),
|
|
11488
|
-
|
|
11489
|
-
|
|
11490
|
-
|
|
12013
|
+
_ts_param27(0, common.Body()),
|
|
12014
|
+
_ts_param27(1, common.Req()),
|
|
12015
|
+
_ts_param27(2, common.Res({
|
|
11491
12016
|
passthrough: true
|
|
11492
12017
|
})),
|
|
11493
|
-
|
|
11494
|
-
|
|
12018
|
+
_ts_metadata42("design:type", Function),
|
|
12019
|
+
_ts_metadata42("design:paramtypes", [
|
|
11495
12020
|
typeof MfaChallengeDto === "undefined" ? Object : MfaChallengeDto,
|
|
11496
12021
|
typeof Request === "undefined" ? Object : Request,
|
|
11497
12022
|
typeof Response === "undefined" ? Object : Response
|
|
11498
12023
|
]),
|
|
11499
|
-
|
|
12024
|
+
_ts_metadata42("design:returntype", Promise)
|
|
11500
12025
|
], MfaController.prototype, "challenge", null);
|
|
11501
|
-
|
|
12026
|
+
_ts_decorate43([
|
|
11502
12027
|
common.UseGuards(exports.JwtAuthGuard, exports.UserStatusGuard),
|
|
11503
12028
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.mfaDisable),
|
|
11504
12029
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaDisable),
|
|
11505
12030
|
common.HttpCode(common.HttpStatus.NO_CONTENT),
|
|
11506
12031
|
common.Post("disable"),
|
|
11507
|
-
|
|
11508
|
-
|
|
11509
|
-
|
|
11510
|
-
|
|
11511
|
-
|
|
12032
|
+
_ts_param27(0, CurrentUser()),
|
|
12033
|
+
_ts_param27(1, common.Body()),
|
|
12034
|
+
_ts_param27(2, common.Req()),
|
|
12035
|
+
_ts_metadata42("design:type", Function),
|
|
12036
|
+
_ts_metadata42("design:paramtypes", [
|
|
11512
12037
|
typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
|
|
11513
12038
|
typeof MfaDisableDto === "undefined" ? Object : MfaDisableDto,
|
|
11514
12039
|
typeof Request === "undefined" ? Object : Request
|
|
11515
12040
|
]),
|
|
11516
|
-
|
|
12041
|
+
_ts_metadata42("design:returntype", Promise)
|
|
11517
12042
|
], MfaController.prototype, "disable", null);
|
|
11518
|
-
|
|
12043
|
+
_ts_decorate43([
|
|
11519
12044
|
common.UseGuards(exports.JwtAuthGuard, exports.UserStatusGuard),
|
|
11520
12045
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.mfaDisable),
|
|
11521
12046
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaDisable),
|
|
11522
12047
|
common.HttpCode(common.HttpStatus.OK),
|
|
11523
12048
|
common.Post("recovery-codes"),
|
|
11524
|
-
|
|
11525
|
-
|
|
11526
|
-
|
|
11527
|
-
|
|
11528
|
-
|
|
12049
|
+
_ts_param27(0, CurrentUser()),
|
|
12050
|
+
_ts_param27(1, common.Body()),
|
|
12051
|
+
_ts_param27(2, common.Req()),
|
|
12052
|
+
_ts_metadata42("design:type", Function),
|
|
12053
|
+
_ts_metadata42("design:paramtypes", [
|
|
11529
12054
|
typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
|
|
11530
12055
|
typeof MfaRegenerateRecoveryCodesDto === "undefined" ? Object : MfaRegenerateRecoveryCodesDto,
|
|
11531
12056
|
typeof Request === "undefined" ? Object : Request
|
|
11532
12057
|
]),
|
|
11533
|
-
|
|
12058
|
+
_ts_metadata42("design:returntype", Promise)
|
|
11534
12059
|
], MfaController.prototype, "regenerateRecoveryCodes", null);
|
|
11535
|
-
MfaController =
|
|
12060
|
+
MfaController = _ts_decorate43([
|
|
11536
12061
|
common.UseInterceptors(NoStoreInterceptor),
|
|
11537
12062
|
common.Controller("mfa"),
|
|
11538
12063
|
common.UseGuards(exports.RequestEncodingGuard, exports.TrustedOriginGuard, exports.AuthRateLimitGuard),
|
|
11539
12064
|
common.UsePipes(createAuthValidationPipe({
|
|
11540
12065
|
forbidUnknownValues: true
|
|
11541
12066
|
})),
|
|
11542
|
-
|
|
11543
|
-
|
|
11544
|
-
|
|
11545
|
-
|
|
11546
|
-
|
|
12067
|
+
_ts_param27(0, common.Inject(exports.MfaService)),
|
|
12068
|
+
_ts_param27(1, common.Inject(exports.TokenDeliveryService)),
|
|
12069
|
+
_ts_param27(2, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
12070
|
+
_ts_metadata42("design:type", Function),
|
|
12071
|
+
_ts_metadata42("design:paramtypes", [
|
|
11547
12072
|
typeof exports.MfaService === "undefined" ? Object : exports.MfaService,
|
|
11548
12073
|
typeof exports.TokenDeliveryService === "undefined" ? Object : exports.TokenDeliveryService,
|
|
11549
12074
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
|
|
11550
12075
|
])
|
|
11551
12076
|
], MfaController);
|
|
11552
12077
|
var Authenticated = /* @__PURE__ */ __name(() => common.SetMetadata(IS_PUBLIC_KEY, false), "Authenticated");
|
|
11553
|
-
function
|
|
12078
|
+
function _ts_decorate44(decorators, target, key, desc) {
|
|
11554
12079
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11555
12080
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
11556
12081
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -11563,13 +12088,13 @@ function _ts_decorate39(decorators, target, key, desc) {
|
|
|
11563
12088
|
}
|
|
11564
12089
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11565
12090
|
}
|
|
11566
|
-
__name(
|
|
11567
|
-
function
|
|
12091
|
+
__name(_ts_decorate44, "_ts_decorate");
|
|
12092
|
+
function _ts_metadata43(metadataKey, metadataValue) {
|
|
11568
12093
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
11569
12094
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
11570
12095
|
}
|
|
11571
12096
|
}
|
|
11572
|
-
__name(
|
|
12097
|
+
__name(_ts_metadata43, "_ts_metadata");
|
|
11573
12098
|
var ChangePasswordDto = class {
|
|
11574
12099
|
static {
|
|
11575
12100
|
__name(this, "ChangePasswordDto");
|
|
@@ -11622,26 +12147,26 @@ var ChangePasswordDto = class {
|
|
|
11622
12147
|
*/
|
|
11623
12148
|
refreshToken;
|
|
11624
12149
|
};
|
|
11625
|
-
|
|
12150
|
+
_ts_decorate44([
|
|
11626
12151
|
classValidator.IsString(),
|
|
11627
12152
|
classValidator.MinLength(1),
|
|
11628
12153
|
classValidator.MaxLength(128),
|
|
11629
|
-
|
|
12154
|
+
_ts_metadata43("design:type", String)
|
|
11630
12155
|
], ChangePasswordDto.prototype, "currentPassword", void 0);
|
|
11631
|
-
|
|
12156
|
+
_ts_decorate44([
|
|
11632
12157
|
classValidator.IsString(),
|
|
11633
12158
|
classValidator.MinLength(8),
|
|
11634
12159
|
classValidator.MaxLength(128),
|
|
11635
|
-
|
|
12160
|
+
_ts_metadata43("design:type", String)
|
|
11636
12161
|
], ChangePasswordDto.prototype, "newPassword", void 0);
|
|
11637
|
-
|
|
12162
|
+
_ts_decorate44([
|
|
11638
12163
|
classValidator.IsOptional(),
|
|
11639
12164
|
classValidator.IsString(),
|
|
11640
12165
|
classValidator.IsNotEmpty(),
|
|
11641
12166
|
classValidator.MaxLength(2048),
|
|
11642
|
-
|
|
12167
|
+
_ts_metadata43("design:type", String)
|
|
11643
12168
|
], ChangePasswordDto.prototype, "refreshToken", void 0);
|
|
11644
|
-
function
|
|
12169
|
+
function _ts_decorate45(decorators, target, key, desc) {
|
|
11645
12170
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11646
12171
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
11647
12172
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -11654,13 +12179,13 @@ function _ts_decorate40(decorators, target, key, desc) {
|
|
|
11654
12179
|
}
|
|
11655
12180
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11656
12181
|
}
|
|
11657
|
-
__name(
|
|
11658
|
-
function
|
|
12182
|
+
__name(_ts_decorate45, "_ts_decorate");
|
|
12183
|
+
function _ts_metadata44(metadataKey, metadataValue) {
|
|
11659
12184
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
11660
12185
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
11661
12186
|
}
|
|
11662
12187
|
}
|
|
11663
|
-
__name(
|
|
12188
|
+
__name(_ts_metadata44, "_ts_metadata");
|
|
11664
12189
|
var ForgotPasswordDto = class {
|
|
11665
12190
|
static {
|
|
11666
12191
|
__name(this, "ForgotPasswordDto");
|
|
@@ -11676,13 +12201,13 @@ var ForgotPasswordDto = class {
|
|
|
11676
12201
|
*/
|
|
11677
12202
|
tenantId;
|
|
11678
12203
|
};
|
|
11679
|
-
|
|
12204
|
+
_ts_decorate45([
|
|
11680
12205
|
classTransformer.Transform(({ value }) => typeof value === "string" ? value.trim().toLowerCase() : value),
|
|
11681
12206
|
classValidator.IsEmail(),
|
|
11682
12207
|
classValidator.MaxLength(255),
|
|
11683
|
-
|
|
12208
|
+
_ts_metadata44("design:type", String)
|
|
11684
12209
|
], ForgotPasswordDto.prototype, "email", void 0);
|
|
11685
|
-
|
|
12210
|
+
_ts_decorate45([
|
|
11686
12211
|
classValidator.IsOptional(),
|
|
11687
12212
|
classValidator.IsString(),
|
|
11688
12213
|
classValidator.IsNotEmpty(),
|
|
@@ -11690,9 +12215,9 @@ _ts_decorate40([
|
|
|
11690
12215
|
classValidator.Matches(NO_CONTROL_CHARACTERS, {
|
|
11691
12216
|
message: "tenantId must not contain control characters"
|
|
11692
12217
|
}),
|
|
11693
|
-
|
|
12218
|
+
_ts_metadata44("design:type", String)
|
|
11694
12219
|
], ForgotPasswordDto.prototype, "tenantId", void 0);
|
|
11695
|
-
function
|
|
12220
|
+
function _ts_decorate46(decorators, target, key, desc) {
|
|
11696
12221
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11697
12222
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
11698
12223
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -11704,14 +12229,14 @@ function _ts_decorate41(decorators, target, key, desc) {
|
|
|
11704
12229
|
}
|
|
11705
12230
|
}
|
|
11706
12231
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11707
|
-
}
|
|
11708
|
-
__name(
|
|
11709
|
-
function
|
|
12232
|
+
}
|
|
12233
|
+
__name(_ts_decorate46, "_ts_decorate");
|
|
12234
|
+
function _ts_metadata45(metadataKey, metadataValue) {
|
|
11710
12235
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
11711
12236
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
11712
12237
|
}
|
|
11713
12238
|
}
|
|
11714
|
-
__name(
|
|
12239
|
+
__name(_ts_metadata45, "_ts_metadata");
|
|
11715
12240
|
var ResendOtpDto = class {
|
|
11716
12241
|
static {
|
|
11717
12242
|
__name(this, "ResendOtpDto");
|
|
@@ -11726,13 +12251,13 @@ var ResendOtpDto = class {
|
|
|
11726
12251
|
*/
|
|
11727
12252
|
tenantId;
|
|
11728
12253
|
};
|
|
11729
|
-
|
|
12254
|
+
_ts_decorate46([
|
|
11730
12255
|
classTransformer.Transform(({ value }) => typeof value === "string" ? value.trim().toLowerCase() : value),
|
|
11731
12256
|
classValidator.IsEmail(),
|
|
11732
12257
|
classValidator.MaxLength(255),
|
|
11733
|
-
|
|
12258
|
+
_ts_metadata45("design:type", String)
|
|
11734
12259
|
], ResendOtpDto.prototype, "email", void 0);
|
|
11735
|
-
|
|
12260
|
+
_ts_decorate46([
|
|
11736
12261
|
classValidator.IsOptional(),
|
|
11737
12262
|
classValidator.IsString(),
|
|
11738
12263
|
classValidator.IsNotEmpty(),
|
|
@@ -11740,9 +12265,9 @@ _ts_decorate41([
|
|
|
11740
12265
|
classValidator.Matches(NO_CONTROL_CHARACTERS, {
|
|
11741
12266
|
message: "tenantId must not contain control characters"
|
|
11742
12267
|
}),
|
|
11743
|
-
|
|
12268
|
+
_ts_metadata45("design:type", String)
|
|
11744
12269
|
], ResendOtpDto.prototype, "tenantId", void 0);
|
|
11745
|
-
function
|
|
12270
|
+
function _ts_decorate47(decorators, target, key, desc) {
|
|
11746
12271
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11747
12272
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
11748
12273
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -11755,13 +12280,13 @@ function _ts_decorate42(decorators, target, key, desc) {
|
|
|
11755
12280
|
}
|
|
11756
12281
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11757
12282
|
}
|
|
11758
|
-
__name(
|
|
11759
|
-
function
|
|
12283
|
+
__name(_ts_decorate47, "_ts_decorate");
|
|
12284
|
+
function _ts_metadata46(metadataKey, metadataValue) {
|
|
11760
12285
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
11761
12286
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
11762
12287
|
}
|
|
11763
12288
|
}
|
|
11764
|
-
__name(
|
|
12289
|
+
__name(_ts_metadata46, "_ts_metadata");
|
|
11765
12290
|
var ResetPasswordDto = class {
|
|
11766
12291
|
static {
|
|
11767
12292
|
__name(this, "ResetPasswordDto");
|
|
@@ -11808,38 +12333,38 @@ var ResetPasswordDto = class {
|
|
|
11808
12333
|
*/
|
|
11809
12334
|
tenantId;
|
|
11810
12335
|
};
|
|
11811
|
-
|
|
12336
|
+
_ts_decorate47([
|
|
11812
12337
|
classTransformer.Transform(({ value }) => typeof value === "string" ? value.trim().toLowerCase() : value),
|
|
11813
12338
|
classValidator.IsEmail(),
|
|
11814
12339
|
classValidator.MaxLength(255),
|
|
11815
|
-
|
|
12340
|
+
_ts_metadata46("design:type", String)
|
|
11816
12341
|
], ResetPasswordDto.prototype, "email", void 0);
|
|
11817
|
-
|
|
12342
|
+
_ts_decorate47([
|
|
11818
12343
|
classValidator.IsString(),
|
|
11819
12344
|
classValidator.MinLength(8),
|
|
11820
12345
|
classValidator.MaxLength(128),
|
|
11821
|
-
|
|
12346
|
+
_ts_metadata46("design:type", String)
|
|
11822
12347
|
], ResetPasswordDto.prototype, "newPassword", void 0);
|
|
11823
|
-
|
|
12348
|
+
_ts_decorate47([
|
|
11824
12349
|
classValidator.IsOptional(),
|
|
11825
12350
|
classValidator.IsString(),
|
|
11826
12351
|
classValidator.IsNotEmpty(),
|
|
11827
12352
|
classValidator.MaxLength(2048),
|
|
11828
|
-
|
|
12353
|
+
_ts_metadata46("design:type", String)
|
|
11829
12354
|
], ResetPasswordDto.prototype, "token", void 0);
|
|
11830
|
-
|
|
12355
|
+
_ts_decorate47([
|
|
11831
12356
|
classValidator.IsOptional(),
|
|
11832
12357
|
classValidator.IsString(),
|
|
11833
12358
|
classValidator.Length(4, 8),
|
|
11834
|
-
|
|
12359
|
+
_ts_metadata46("design:type", String)
|
|
11835
12360
|
], ResetPasswordDto.prototype, "otp", void 0);
|
|
11836
|
-
|
|
12361
|
+
_ts_decorate47([
|
|
11837
12362
|
classValidator.IsOptional(),
|
|
11838
12363
|
classValidator.IsString(),
|
|
11839
12364
|
classValidator.Length(64, 64),
|
|
11840
|
-
|
|
12365
|
+
_ts_metadata46("design:type", String)
|
|
11841
12366
|
], ResetPasswordDto.prototype, "verifiedToken", void 0);
|
|
11842
|
-
|
|
12367
|
+
_ts_decorate47([
|
|
11843
12368
|
classValidator.IsOptional(),
|
|
11844
12369
|
classValidator.IsString(),
|
|
11845
12370
|
classValidator.IsNotEmpty(),
|
|
@@ -11847,9 +12372,9 @@ _ts_decorate42([
|
|
|
11847
12372
|
classValidator.Matches(NO_CONTROL_CHARACTERS, {
|
|
11848
12373
|
message: "tenantId must not contain control characters"
|
|
11849
12374
|
}),
|
|
11850
|
-
|
|
12375
|
+
_ts_metadata46("design:type", String)
|
|
11851
12376
|
], ResetPasswordDto.prototype, "tenantId", void 0);
|
|
11852
|
-
function
|
|
12377
|
+
function _ts_decorate48(decorators, target, key, desc) {
|
|
11853
12378
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11854
12379
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
11855
12380
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -11862,13 +12387,13 @@ function _ts_decorate43(decorators, target, key, desc) {
|
|
|
11862
12387
|
}
|
|
11863
12388
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11864
12389
|
}
|
|
11865
|
-
__name(
|
|
11866
|
-
function
|
|
12390
|
+
__name(_ts_decorate48, "_ts_decorate");
|
|
12391
|
+
function _ts_metadata47(metadataKey, metadataValue) {
|
|
11867
12392
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
11868
12393
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
11869
12394
|
}
|
|
11870
12395
|
}
|
|
11871
|
-
__name(
|
|
12396
|
+
__name(_ts_metadata47, "_ts_metadata");
|
|
11872
12397
|
var VerifyOtpDto = class {
|
|
11873
12398
|
static {
|
|
11874
12399
|
__name(this, "VerifyOtpDto");
|
|
@@ -11890,18 +12415,18 @@ var VerifyOtpDto = class {
|
|
|
11890
12415
|
*/
|
|
11891
12416
|
tenantId;
|
|
11892
12417
|
};
|
|
11893
|
-
|
|
12418
|
+
_ts_decorate48([
|
|
11894
12419
|
classTransformer.Transform(({ value }) => typeof value === "string" ? value.trim().toLowerCase() : value),
|
|
11895
12420
|
classValidator.IsEmail(),
|
|
11896
12421
|
classValidator.MaxLength(255),
|
|
11897
|
-
|
|
12422
|
+
_ts_metadata47("design:type", String)
|
|
11898
12423
|
], VerifyOtpDto.prototype, "email", void 0);
|
|
11899
|
-
|
|
12424
|
+
_ts_decorate48([
|
|
11900
12425
|
classValidator.IsString(),
|
|
11901
12426
|
classValidator.Length(4, 8),
|
|
11902
|
-
|
|
12427
|
+
_ts_metadata47("design:type", String)
|
|
11903
12428
|
], VerifyOtpDto.prototype, "otp", void 0);
|
|
11904
|
-
|
|
12429
|
+
_ts_decorate48([
|
|
11905
12430
|
classValidator.IsOptional(),
|
|
11906
12431
|
classValidator.IsString(),
|
|
11907
12432
|
classValidator.IsNotEmpty(),
|
|
@@ -11909,7 +12434,7 @@ _ts_decorate43([
|
|
|
11909
12434
|
classValidator.Matches(NO_CONTROL_CHARACTERS, {
|
|
11910
12435
|
message: "tenantId must not contain control characters"
|
|
11911
12436
|
}),
|
|
11912
|
-
|
|
12437
|
+
_ts_metadata47("design:type", String)
|
|
11913
12438
|
], VerifyOtpDto.prototype, "tenantId", void 0);
|
|
11914
12439
|
|
|
11915
12440
|
// src/server/utils/answer-reset-request.ts
|
|
@@ -11956,7 +12481,7 @@ async function answerResetRequest(deps, request) {
|
|
|
11956
12481
|
__name(answerResetRequest, "answerResetRequest");
|
|
11957
12482
|
|
|
11958
12483
|
// src/server/services/password-reset.service.ts
|
|
11959
|
-
function
|
|
12484
|
+
function _ts_decorate49(decorators, target, key, desc) {
|
|
11960
12485
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11961
12486
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
11962
12487
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -11969,19 +12494,19 @@ function _ts_decorate44(decorators, target, key, desc) {
|
|
|
11969
12494
|
}
|
|
11970
12495
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11971
12496
|
}
|
|
11972
|
-
__name(
|
|
11973
|
-
function
|
|
12497
|
+
__name(_ts_decorate49, "_ts_decorate");
|
|
12498
|
+
function _ts_metadata48(metadataKey, metadataValue) {
|
|
11974
12499
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
11975
12500
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
11976
12501
|
}
|
|
11977
12502
|
}
|
|
11978
|
-
__name(
|
|
11979
|
-
function
|
|
12503
|
+
__name(_ts_metadata48, "_ts_metadata");
|
|
12504
|
+
function _ts_param28(paramIndex, decorator) {
|
|
11980
12505
|
return function(target, key) {
|
|
11981
12506
|
decorator(target, key, paramIndex);
|
|
11982
12507
|
};
|
|
11983
12508
|
}
|
|
11984
|
-
__name(
|
|
12509
|
+
__name(_ts_param28, "_ts_param");
|
|
11985
12510
|
var ANTI_ENUM_MIN_MS2 = 300;
|
|
11986
12511
|
var VERIFIED_TOKEN_TTL_SECONDS = 300;
|
|
11987
12512
|
var PASSWORD_RESET_PURPOSE = "password_reset";
|
|
@@ -12575,21 +13100,21 @@ exports.PasswordResetService = class _PasswordResetService {
|
|
|
12575
13100
|
};
|
|
12576
13101
|
}
|
|
12577
13102
|
};
|
|
12578
|
-
exports.PasswordResetService =
|
|
13103
|
+
exports.PasswordResetService = _ts_decorate49([
|
|
12579
13104
|
common.Injectable(),
|
|
12580
|
-
|
|
12581
|
-
|
|
12582
|
-
|
|
12583
|
-
|
|
12584
|
-
|
|
12585
|
-
|
|
12586
|
-
|
|
12587
|
-
|
|
12588
|
-
|
|
12589
|
-
|
|
12590
|
-
|
|
12591
|
-
|
|
12592
|
-
|
|
13105
|
+
_ts_param28(0, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
13106
|
+
_ts_param28(1, common.Inject(BYMAX_AUTH_USER_REPOSITORY)),
|
|
13107
|
+
_ts_param28(2, common.Inject(BYMAX_AUTH_EMAIL_PROVIDER)),
|
|
13108
|
+
_ts_param28(2, common.Optional()),
|
|
13109
|
+
_ts_param28(3, common.Inject(BYMAX_AUTH_HOOKS)),
|
|
13110
|
+
_ts_param28(3, common.Optional()),
|
|
13111
|
+
_ts_param28(4, common.Inject(exports.OtpService)),
|
|
13112
|
+
_ts_param28(5, common.Inject(PasswordService)),
|
|
13113
|
+
_ts_param28(6, common.Inject(AuthRedisService)),
|
|
13114
|
+
_ts_param28(7, common.Inject(exports.SessionService)),
|
|
13115
|
+
_ts_param28(8, common.Inject(exports.BruteForceService)),
|
|
13116
|
+
_ts_metadata48("design:type", Function),
|
|
13117
|
+
_ts_metadata48("design:paramtypes", [
|
|
12593
13118
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
|
|
12594
13119
|
typeof IUserRepository === "undefined" ? Object : IUserRepository,
|
|
12595
13120
|
Object,
|
|
@@ -12608,7 +13133,7 @@ function toSafeUser4(user) {
|
|
|
12608
13133
|
__name(toSafeUser4, "toSafeUser");
|
|
12609
13134
|
|
|
12610
13135
|
// src/server/controllers/password-reset.controller.ts
|
|
12611
|
-
function
|
|
13136
|
+
function _ts_decorate50(decorators, target, key, desc) {
|
|
12612
13137
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12613
13138
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
12614
13139
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -12621,19 +13146,19 @@ function _ts_decorate45(decorators, target, key, desc) {
|
|
|
12621
13146
|
}
|
|
12622
13147
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
12623
13148
|
}
|
|
12624
|
-
__name(
|
|
12625
|
-
function
|
|
13149
|
+
__name(_ts_decorate50, "_ts_decorate");
|
|
13150
|
+
function _ts_metadata49(metadataKey, metadataValue) {
|
|
12626
13151
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
12627
13152
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
12628
13153
|
}
|
|
12629
13154
|
}
|
|
12630
|
-
__name(
|
|
12631
|
-
function
|
|
13155
|
+
__name(_ts_metadata49, "_ts_metadata");
|
|
13156
|
+
function _ts_param29(paramIndex, decorator) {
|
|
12632
13157
|
return function(target, key) {
|
|
12633
13158
|
decorator(target, key, paramIndex);
|
|
12634
13159
|
};
|
|
12635
13160
|
}
|
|
12636
|
-
__name(
|
|
13161
|
+
__name(_ts_param29, "_ts_param");
|
|
12637
13162
|
var PasswordResetController = class {
|
|
12638
13163
|
static {
|
|
12639
13164
|
__name(this, "PasswordResetController");
|
|
@@ -12752,95 +13277,95 @@ var PasswordResetController = class {
|
|
|
12752
13277
|
return {};
|
|
12753
13278
|
}
|
|
12754
13279
|
};
|
|
12755
|
-
|
|
13280
|
+
_ts_decorate50([
|
|
12756
13281
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.forgotPassword),
|
|
12757
13282
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.forgotPassword),
|
|
12758
13283
|
common.HttpCode(common.HttpStatus.OK),
|
|
12759
13284
|
common.Post("forgot-password"),
|
|
12760
|
-
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
|
|
13285
|
+
_ts_param29(0, common.Body()),
|
|
13286
|
+
_ts_param29(1, common.Req()),
|
|
13287
|
+
_ts_metadata49("design:type", Function),
|
|
13288
|
+
_ts_metadata49("design:paramtypes", [
|
|
12764
13289
|
typeof ForgotPasswordDto === "undefined" ? Object : ForgotPasswordDto,
|
|
12765
13290
|
typeof Request === "undefined" ? Object : Request
|
|
12766
13291
|
]),
|
|
12767
|
-
|
|
13292
|
+
_ts_metadata49("design:returntype", Promise)
|
|
12768
13293
|
], PasswordResetController.prototype, "forgotPassword", null);
|
|
12769
|
-
|
|
13294
|
+
_ts_decorate50([
|
|
12770
13295
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.resetPassword),
|
|
12771
13296
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.resetPassword),
|
|
12772
13297
|
common.HttpCode(common.HttpStatus.NO_CONTENT),
|
|
12773
13298
|
common.Post("reset-password"),
|
|
12774
|
-
|
|
12775
|
-
|
|
12776
|
-
|
|
12777
|
-
|
|
13299
|
+
_ts_param29(0, common.Body()),
|
|
13300
|
+
_ts_param29(1, common.Req()),
|
|
13301
|
+
_ts_metadata49("design:type", Function),
|
|
13302
|
+
_ts_metadata49("design:paramtypes", [
|
|
12778
13303
|
typeof ResetPasswordDto === "undefined" ? Object : ResetPasswordDto,
|
|
12779
13304
|
typeof Request === "undefined" ? Object : Request
|
|
12780
13305
|
]),
|
|
12781
|
-
|
|
13306
|
+
_ts_metadata49("design:returntype", Promise)
|
|
12782
13307
|
], PasswordResetController.prototype, "resetPassword", null);
|
|
12783
|
-
|
|
13308
|
+
_ts_decorate50([
|
|
12784
13309
|
Authenticated(),
|
|
12785
13310
|
common.UseGuards(exports.JwtAuthGuard, exports.UserStatusGuard),
|
|
12786
13311
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.changePassword),
|
|
12787
13312
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.changePassword),
|
|
12788
13313
|
common.HttpCode(common.HttpStatus.NO_CONTENT),
|
|
12789
13314
|
common.Post("change"),
|
|
12790
|
-
|
|
12791
|
-
|
|
12792
|
-
|
|
12793
|
-
|
|
12794
|
-
|
|
13315
|
+
_ts_param29(0, CurrentUser()),
|
|
13316
|
+
_ts_param29(1, common.Body()),
|
|
13317
|
+
_ts_param29(2, common.Req()),
|
|
13318
|
+
_ts_metadata49("design:type", Function),
|
|
13319
|
+
_ts_metadata49("design:paramtypes", [
|
|
12795
13320
|
typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
|
|
12796
13321
|
typeof ChangePasswordDto === "undefined" ? Object : ChangePasswordDto,
|
|
12797
13322
|
typeof Request === "undefined" ? Object : Request
|
|
12798
13323
|
]),
|
|
12799
|
-
|
|
13324
|
+
_ts_metadata49("design:returntype", Promise)
|
|
12800
13325
|
], PasswordResetController.prototype, "changePassword", null);
|
|
12801
|
-
|
|
13326
|
+
_ts_decorate50([
|
|
12802
13327
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.verifyOtp),
|
|
12803
13328
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.verifyOtp),
|
|
12804
13329
|
common.HttpCode(common.HttpStatus.OK),
|
|
12805
13330
|
common.Post("verify-otp"),
|
|
12806
|
-
|
|
12807
|
-
|
|
12808
|
-
|
|
12809
|
-
|
|
13331
|
+
_ts_param29(0, common.Body()),
|
|
13332
|
+
_ts_param29(1, common.Req()),
|
|
13333
|
+
_ts_metadata49("design:type", Function),
|
|
13334
|
+
_ts_metadata49("design:paramtypes", [
|
|
12810
13335
|
typeof VerifyOtpDto === "undefined" ? Object : VerifyOtpDto,
|
|
12811
13336
|
typeof Request === "undefined" ? Object : Request
|
|
12812
13337
|
]),
|
|
12813
|
-
|
|
13338
|
+
_ts_metadata49("design:returntype", Promise)
|
|
12814
13339
|
], PasswordResetController.prototype, "verifyOtp", null);
|
|
12815
|
-
|
|
13340
|
+
_ts_decorate50([
|
|
12816
13341
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.resendPasswordOtp),
|
|
12817
13342
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.resendPasswordOtp),
|
|
12818
13343
|
common.HttpCode(common.HttpStatus.OK),
|
|
12819
13344
|
common.Post("resend-otp"),
|
|
12820
|
-
|
|
12821
|
-
|
|
12822
|
-
|
|
12823
|
-
|
|
13345
|
+
_ts_param29(0, common.Body()),
|
|
13346
|
+
_ts_param29(1, common.Req()),
|
|
13347
|
+
_ts_metadata49("design:type", Function),
|
|
13348
|
+
_ts_metadata49("design:paramtypes", [
|
|
12824
13349
|
typeof ResendOtpDto === "undefined" ? Object : ResendOtpDto,
|
|
12825
13350
|
typeof Request === "undefined" ? Object : Request
|
|
12826
13351
|
]),
|
|
12827
|
-
|
|
13352
|
+
_ts_metadata49("design:returntype", Promise)
|
|
12828
13353
|
], PasswordResetController.prototype, "resendOtp", null);
|
|
12829
|
-
PasswordResetController =
|
|
13354
|
+
PasswordResetController = _ts_decorate50([
|
|
12830
13355
|
Public(),
|
|
12831
13356
|
common.UseInterceptors(NoStoreInterceptor),
|
|
12832
13357
|
common.Controller("password"),
|
|
12833
13358
|
common.UseGuards(exports.RequestEncodingGuard, exports.TrustedOriginGuard, exports.AuthRateLimitGuard),
|
|
12834
13359
|
common.UsePipes(createAuthValidationPipe()),
|
|
12835
|
-
|
|
12836
|
-
|
|
12837
|
-
|
|
12838
|
-
|
|
13360
|
+
_ts_param29(0, common.Inject(exports.PasswordResetService)),
|
|
13361
|
+
_ts_param29(1, common.Inject(exports.TokenDeliveryService)),
|
|
13362
|
+
_ts_metadata49("design:type", Function),
|
|
13363
|
+
_ts_metadata49("design:paramtypes", [
|
|
12839
13364
|
typeof exports.PasswordResetService === "undefined" ? Object : exports.PasswordResetService,
|
|
12840
13365
|
typeof exports.TokenDeliveryService === "undefined" ? Object : exports.TokenDeliveryService
|
|
12841
13366
|
])
|
|
12842
13367
|
], PasswordResetController);
|
|
12843
|
-
function
|
|
13368
|
+
function _ts_decorate51(decorators, target, key, desc) {
|
|
12844
13369
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12845
13370
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
12846
13371
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -12853,13 +13378,13 @@ function _ts_decorate46(decorators, target, key, desc) {
|
|
|
12853
13378
|
}
|
|
12854
13379
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
12855
13380
|
}
|
|
12856
|
-
__name(
|
|
12857
|
-
function
|
|
13381
|
+
__name(_ts_decorate51, "_ts_decorate");
|
|
13382
|
+
function _ts_metadata50(metadataKey, metadataValue) {
|
|
12858
13383
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
12859
13384
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
12860
13385
|
}
|
|
12861
13386
|
}
|
|
12862
|
-
__name(
|
|
13387
|
+
__name(_ts_metadata50, "_ts_metadata");
|
|
12863
13388
|
var PlatformLoginDto = class {
|
|
12864
13389
|
static {
|
|
12865
13390
|
__name(this, "PlatformLoginDto");
|
|
@@ -12887,14 +13412,14 @@ var PlatformLoginDto = class {
|
|
|
12887
13412
|
*/
|
|
12888
13413
|
password;
|
|
12889
13414
|
};
|
|
12890
|
-
|
|
13415
|
+
_ts_decorate51([
|
|
12891
13416
|
classTransformer.Transform(({ value }) => typeof value === "string" ? value.trim().toLowerCase() : value),
|
|
12892
13417
|
classValidator.IsEmail(),
|
|
12893
13418
|
classValidator.IsNotEmpty(),
|
|
12894
13419
|
classValidator.MaxLength(255),
|
|
12895
|
-
|
|
13420
|
+
_ts_metadata50("design:type", String)
|
|
12896
13421
|
], PlatformLoginDto.prototype, "email", void 0);
|
|
12897
|
-
|
|
13422
|
+
_ts_decorate51([
|
|
12898
13423
|
classValidator.IsString(),
|
|
12899
13424
|
classValidator.IsNotEmpty(),
|
|
12900
13425
|
classValidator.Matches(/\S/, {
|
|
@@ -12902,9 +13427,9 @@ _ts_decorate46([
|
|
|
12902
13427
|
}),
|
|
12903
13428
|
classValidator.MinLength(1),
|
|
12904
13429
|
classValidator.MaxLength(128),
|
|
12905
|
-
|
|
13430
|
+
_ts_metadata50("design:type", String)
|
|
12906
13431
|
], PlatformLoginDto.prototype, "password", void 0);
|
|
12907
|
-
function
|
|
13432
|
+
function _ts_decorate52(decorators, target, key, desc) {
|
|
12908
13433
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12909
13434
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
12910
13435
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -12917,19 +13442,19 @@ function _ts_decorate47(decorators, target, key, desc) {
|
|
|
12917
13442
|
}
|
|
12918
13443
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
12919
13444
|
}
|
|
12920
|
-
__name(
|
|
12921
|
-
function
|
|
13445
|
+
__name(_ts_decorate52, "_ts_decorate");
|
|
13446
|
+
function _ts_metadata51(metadataKey, metadataValue) {
|
|
12922
13447
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
12923
13448
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
12924
13449
|
}
|
|
12925
13450
|
}
|
|
12926
|
-
__name(
|
|
12927
|
-
function
|
|
13451
|
+
__name(_ts_metadata51, "_ts_metadata");
|
|
13452
|
+
function _ts_param30(paramIndex, decorator) {
|
|
12928
13453
|
return function(target, key) {
|
|
12929
13454
|
decorator(target, key, paramIndex);
|
|
12930
13455
|
};
|
|
12931
13456
|
}
|
|
12932
|
-
__name(
|
|
13457
|
+
__name(_ts_param30, "_ts_param");
|
|
12933
13458
|
exports.JwtPlatformGuard = class JwtPlatformGuard {
|
|
12934
13459
|
static {
|
|
12935
13460
|
__name(this, "JwtPlatformGuard");
|
|
@@ -12975,15 +13500,15 @@ exports.JwtPlatformGuard = class JwtPlatformGuard {
|
|
|
12975
13500
|
return true;
|
|
12976
13501
|
}
|
|
12977
13502
|
};
|
|
12978
|
-
exports.JwtPlatformGuard =
|
|
13503
|
+
exports.JwtPlatformGuard = _ts_decorate52([
|
|
12979
13504
|
common.Injectable(),
|
|
12980
|
-
|
|
12981
|
-
|
|
12982
|
-
|
|
12983
|
-
|
|
12984
|
-
|
|
12985
|
-
|
|
12986
|
-
|
|
13505
|
+
_ts_param30(0, common.Inject(jwt.JwtService)),
|
|
13506
|
+
_ts_param30(1, common.Inject(exports.TokenDeliveryService)),
|
|
13507
|
+
_ts_param30(2, common.Inject(exports.AuthRevocationService)),
|
|
13508
|
+
_ts_param30(3, common.Inject(core.Reflector)),
|
|
13509
|
+
_ts_param30(4, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
13510
|
+
_ts_metadata51("design:type", Function),
|
|
13511
|
+
_ts_metadata51("design:paramtypes", [
|
|
12987
13512
|
typeof jwt.JwtService === "undefined" ? Object : jwt.JwtService,
|
|
12988
13513
|
typeof exports.TokenDeliveryService === "undefined" ? Object : exports.TokenDeliveryService,
|
|
12989
13514
|
typeof exports.AuthRevocationService === "undefined" ? Object : exports.AuthRevocationService,
|
|
@@ -12991,7 +13516,7 @@ exports.JwtPlatformGuard = _ts_decorate47([
|
|
|
12991
13516
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
|
|
12992
13517
|
])
|
|
12993
13518
|
], exports.JwtPlatformGuard);
|
|
12994
|
-
function
|
|
13519
|
+
function _ts_decorate53(decorators, target, key, desc) {
|
|
12995
13520
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12996
13521
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
12997
13522
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -13004,19 +13529,19 @@ function _ts_decorate48(decorators, target, key, desc) {
|
|
|
13004
13529
|
}
|
|
13005
13530
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
13006
13531
|
}
|
|
13007
|
-
__name(
|
|
13008
|
-
function
|
|
13532
|
+
__name(_ts_decorate53, "_ts_decorate");
|
|
13533
|
+
function _ts_metadata52(metadataKey, metadataValue) {
|
|
13009
13534
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
13010
13535
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
13011
13536
|
}
|
|
13012
13537
|
}
|
|
13013
|
-
__name(
|
|
13014
|
-
function
|
|
13538
|
+
__name(_ts_metadata52, "_ts_metadata");
|
|
13539
|
+
function _ts_param31(paramIndex, decorator) {
|
|
13015
13540
|
return function(target, key) {
|
|
13016
13541
|
decorator(target, key, paramIndex);
|
|
13017
13542
|
};
|
|
13018
13543
|
}
|
|
13019
|
-
__name(
|
|
13544
|
+
__name(_ts_param31, "_ts_param");
|
|
13020
13545
|
exports.PlatformAuthService = class _PlatformAuthService {
|
|
13021
13546
|
static {
|
|
13022
13547
|
__name(this, "PlatformAuthService");
|
|
@@ -13309,18 +13834,18 @@ exports.PlatformAuthService = class _PlatformAuthService {
|
|
|
13309
13834
|
await this.redis.bumpUserTokenEpoch(userId, void 0, "platform");
|
|
13310
13835
|
}
|
|
13311
13836
|
};
|
|
13312
|
-
exports.PlatformAuthService =
|
|
13837
|
+
exports.PlatformAuthService = _ts_decorate53([
|
|
13313
13838
|
common.Injectable(),
|
|
13314
|
-
|
|
13315
|
-
|
|
13316
|
-
|
|
13317
|
-
|
|
13318
|
-
|
|
13319
|
-
|
|
13320
|
-
|
|
13321
|
-
|
|
13322
|
-
|
|
13323
|
-
|
|
13839
|
+
_ts_param31(0, common.Inject(BYMAX_AUTH_PLATFORM_USER_REPOSITORY)),
|
|
13840
|
+
_ts_param31(1, common.Inject(PasswordService)),
|
|
13841
|
+
_ts_param31(2, common.Inject(TokenManagerService)),
|
|
13842
|
+
_ts_param31(3, common.Inject(exports.BruteForceService)),
|
|
13843
|
+
_ts_param31(4, common.Inject(AuthRedisService)),
|
|
13844
|
+
_ts_param31(5, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
13845
|
+
_ts_param31(6, common.Inject(BYMAX_AUTH_HOOKS)),
|
|
13846
|
+
_ts_param31(6, common.Optional()),
|
|
13847
|
+
_ts_metadata52("design:type", Function),
|
|
13848
|
+
_ts_metadata52("design:paramtypes", [
|
|
13324
13849
|
typeof IPlatformUserRepository === "undefined" ? Object : IPlatformUserRepository,
|
|
13325
13850
|
typeof PasswordService === "undefined" ? Object : PasswordService,
|
|
13326
13851
|
typeof TokenManagerService === "undefined" ? Object : TokenManagerService,
|
|
@@ -13332,7 +13857,7 @@ exports.PlatformAuthService = _ts_decorate48([
|
|
|
13332
13857
|
], exports.PlatformAuthService);
|
|
13333
13858
|
|
|
13334
13859
|
// src/server/controllers/platform-auth.controller.ts
|
|
13335
|
-
function
|
|
13860
|
+
function _ts_decorate54(decorators, target, key, desc) {
|
|
13336
13861
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
13337
13862
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
13338
13863
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -13345,19 +13870,19 @@ function _ts_decorate49(decorators, target, key, desc) {
|
|
|
13345
13870
|
}
|
|
13346
13871
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
13347
13872
|
}
|
|
13348
|
-
__name(
|
|
13349
|
-
function
|
|
13873
|
+
__name(_ts_decorate54, "_ts_decorate");
|
|
13874
|
+
function _ts_metadata53(metadataKey, metadataValue) {
|
|
13350
13875
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
13351
13876
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
13352
13877
|
}
|
|
13353
13878
|
}
|
|
13354
|
-
__name(
|
|
13355
|
-
function
|
|
13879
|
+
__name(_ts_metadata53, "_ts_metadata");
|
|
13880
|
+
function _ts_param32(paramIndex, decorator) {
|
|
13356
13881
|
return function(target, key) {
|
|
13357
13882
|
decorator(target, key, paramIndex);
|
|
13358
13883
|
};
|
|
13359
13884
|
}
|
|
13360
|
-
__name(
|
|
13885
|
+
__name(_ts_param32, "_ts_param");
|
|
13361
13886
|
function isMfaChallenge2(result) {
|
|
13362
13887
|
return "mfaRequired" in result && result.mfaRequired === true;
|
|
13363
13888
|
}
|
|
@@ -13503,103 +14028,103 @@ var PlatformAuthController = class {
|
|
|
13503
14028
|
await this.platformAuthService.revokeAllPlatformSessions(user.sub);
|
|
13504
14029
|
}
|
|
13505
14030
|
};
|
|
13506
|
-
|
|
14031
|
+
_ts_decorate54([
|
|
13507
14032
|
Public(),
|
|
13508
14033
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.platformLogin),
|
|
13509
14034
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.platformLogin),
|
|
13510
14035
|
common.HttpCode(common.HttpStatus.OK),
|
|
13511
14036
|
common.Post("login"),
|
|
13512
|
-
|
|
13513
|
-
|
|
13514
|
-
|
|
13515
|
-
|
|
14037
|
+
_ts_param32(0, common.Body()),
|
|
14038
|
+
_ts_param32(1, common.Req()),
|
|
14039
|
+
_ts_metadata53("design:type", Function),
|
|
14040
|
+
_ts_metadata53("design:paramtypes", [
|
|
13516
14041
|
typeof PlatformLoginDto === "undefined" ? Object : PlatformLoginDto,
|
|
13517
14042
|
typeof Request === "undefined" ? Object : Request
|
|
13518
14043
|
]),
|
|
13519
|
-
|
|
14044
|
+
_ts_metadata53("design:returntype", Promise)
|
|
13520
14045
|
], PlatformAuthController.prototype, "login", null);
|
|
13521
|
-
|
|
14046
|
+
_ts_decorate54([
|
|
13522
14047
|
Public(),
|
|
13523
14048
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.mfaChallenge),
|
|
13524
14049
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaChallenge),
|
|
13525
14050
|
common.HttpCode(common.HttpStatus.OK),
|
|
13526
14051
|
common.Post("mfa/challenge"),
|
|
13527
|
-
|
|
13528
|
-
|
|
13529
|
-
|
|
13530
|
-
|
|
14052
|
+
_ts_param32(0, common.Body()),
|
|
14053
|
+
_ts_param32(1, common.Req()),
|
|
14054
|
+
_ts_metadata53("design:type", Function),
|
|
14055
|
+
_ts_metadata53("design:paramtypes", [
|
|
13531
14056
|
typeof MfaChallengeDto === "undefined" ? Object : MfaChallengeDto,
|
|
13532
14057
|
typeof Request === "undefined" ? Object : Request
|
|
13533
14058
|
]),
|
|
13534
|
-
|
|
14059
|
+
_ts_metadata53("design:returntype", Promise)
|
|
13535
14060
|
], PlatformAuthController.prototype, "mfaChallenge", null);
|
|
13536
|
-
|
|
14061
|
+
_ts_decorate54([
|
|
13537
14062
|
common.UseGuards(exports.JwtPlatformGuard),
|
|
13538
14063
|
common.Get("me"),
|
|
13539
|
-
|
|
13540
|
-
|
|
13541
|
-
|
|
14064
|
+
_ts_param32(0, CurrentUser()),
|
|
14065
|
+
_ts_metadata53("design:type", Function),
|
|
14066
|
+
_ts_metadata53("design:paramtypes", [
|
|
13542
14067
|
typeof PlatformJwtPayload === "undefined" ? Object : PlatformJwtPayload
|
|
13543
14068
|
]),
|
|
13544
|
-
|
|
14069
|
+
_ts_metadata53("design:returntype", Promise)
|
|
13545
14070
|
], PlatformAuthController.prototype, "me", null);
|
|
13546
|
-
|
|
14071
|
+
_ts_decorate54([
|
|
13547
14072
|
Public(),
|
|
13548
14073
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.logout),
|
|
13549
14074
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.logout),
|
|
13550
14075
|
common.HttpCode(common.HttpStatus.NO_CONTENT),
|
|
13551
14076
|
RequestEncoding("unchecked"),
|
|
13552
14077
|
common.Post("logout"),
|
|
13553
|
-
|
|
13554
|
-
|
|
13555
|
-
|
|
14078
|
+
_ts_param32(0, common.Req()),
|
|
14079
|
+
_ts_metadata53("design:type", Function),
|
|
14080
|
+
_ts_metadata53("design:paramtypes", [
|
|
13556
14081
|
typeof Request === "undefined" ? Object : Request
|
|
13557
14082
|
]),
|
|
13558
|
-
|
|
14083
|
+
_ts_metadata53("design:returntype", Promise)
|
|
13559
14084
|
], PlatformAuthController.prototype, "logout", null);
|
|
13560
|
-
|
|
14085
|
+
_ts_decorate54([
|
|
13561
14086
|
Public(),
|
|
13562
14087
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.refresh),
|
|
13563
14088
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.refresh),
|
|
13564
14089
|
common.HttpCode(common.HttpStatus.OK),
|
|
13565
14090
|
RequestEncoding("unchecked"),
|
|
13566
14091
|
common.Post("refresh"),
|
|
13567
|
-
|
|
13568
|
-
|
|
13569
|
-
|
|
14092
|
+
_ts_param32(0, common.Req()),
|
|
14093
|
+
_ts_metadata53("design:type", Function),
|
|
14094
|
+
_ts_metadata53("design:paramtypes", [
|
|
13570
14095
|
typeof Request === "undefined" ? Object : Request
|
|
13571
14096
|
]),
|
|
13572
|
-
|
|
14097
|
+
_ts_metadata53("design:returntype", Promise)
|
|
13573
14098
|
], PlatformAuthController.prototype, "refresh", null);
|
|
13574
|
-
|
|
14099
|
+
_ts_decorate54([
|
|
13575
14100
|
common.UseGuards(exports.JwtPlatformGuard),
|
|
13576
14101
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.revokeAllSessions),
|
|
13577
14102
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.revokeAllSessions),
|
|
13578
14103
|
common.HttpCode(common.HttpStatus.NO_CONTENT),
|
|
13579
14104
|
common.Delete("sessions"),
|
|
13580
|
-
|
|
13581
|
-
|
|
13582
|
-
|
|
14105
|
+
_ts_param32(0, CurrentUser()),
|
|
14106
|
+
_ts_metadata53("design:type", Function),
|
|
14107
|
+
_ts_metadata53("design:paramtypes", [
|
|
13583
14108
|
typeof PlatformJwtPayload === "undefined" ? Object : PlatformJwtPayload
|
|
13584
14109
|
]),
|
|
13585
|
-
|
|
14110
|
+
_ts_metadata53("design:returntype", Promise)
|
|
13586
14111
|
], PlatformAuthController.prototype, "revokeSessions", null);
|
|
13587
|
-
PlatformAuthController =
|
|
14112
|
+
PlatformAuthController = _ts_decorate54([
|
|
13588
14113
|
common.UseInterceptors(NoStoreInterceptor),
|
|
13589
14114
|
common.Controller("platform"),
|
|
13590
14115
|
common.UseGuards(exports.RequestEncodingGuard, exports.TrustedOriginGuard, exports.AuthRateLimitGuard),
|
|
13591
14116
|
common.UsePipes(createAuthValidationPipe()),
|
|
13592
|
-
|
|
13593
|
-
|
|
13594
|
-
|
|
13595
|
-
|
|
13596
|
-
|
|
14117
|
+
_ts_param32(0, common.Inject(exports.PlatformAuthService)),
|
|
14118
|
+
_ts_param32(1, common.Inject(exports.MfaService)),
|
|
14119
|
+
_ts_param32(2, common.Inject(exports.TokenDeliveryService)),
|
|
14120
|
+
_ts_metadata53("design:type", Function),
|
|
14121
|
+
_ts_metadata53("design:paramtypes", [
|
|
13597
14122
|
typeof exports.PlatformAuthService === "undefined" ? Object : exports.PlatformAuthService,
|
|
13598
14123
|
typeof exports.MfaService === "undefined" ? Object : exports.MfaService,
|
|
13599
14124
|
typeof exports.TokenDeliveryService === "undefined" ? Object : exports.TokenDeliveryService
|
|
13600
14125
|
])
|
|
13601
14126
|
], PlatformAuthController);
|
|
13602
|
-
function
|
|
14127
|
+
function _ts_decorate55(decorators, target, key, desc) {
|
|
13603
14128
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
13604
14129
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
13605
14130
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -13612,19 +14137,19 @@ function _ts_decorate50(decorators, target, key, desc) {
|
|
|
13612
14137
|
}
|
|
13613
14138
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
13614
14139
|
}
|
|
13615
|
-
__name(
|
|
13616
|
-
function
|
|
14140
|
+
__name(_ts_decorate55, "_ts_decorate");
|
|
14141
|
+
function _ts_metadata54(metadataKey, metadataValue) {
|
|
13617
14142
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
13618
14143
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
13619
14144
|
}
|
|
13620
14145
|
}
|
|
13621
|
-
__name(
|
|
13622
|
-
function
|
|
14146
|
+
__name(_ts_metadata54, "_ts_metadata");
|
|
14147
|
+
function _ts_param33(paramIndex, decorator) {
|
|
13623
14148
|
return function(target, key) {
|
|
13624
14149
|
decorator(target, key, paramIndex);
|
|
13625
14150
|
};
|
|
13626
14151
|
}
|
|
13627
|
-
__name(
|
|
14152
|
+
__name(_ts_param33, "_ts_param");
|
|
13628
14153
|
var PlatformMfaController = class {
|
|
13629
14154
|
static {
|
|
13630
14155
|
__name(this, "PlatformMfaController");
|
|
@@ -13703,86 +14228,86 @@ var PlatformMfaController = class {
|
|
|
13703
14228
|
return this.mfaService.regenerateRecoveryCodes(user.sub, dto.code, ip, userAgent, "platform");
|
|
13704
14229
|
}
|
|
13705
14230
|
};
|
|
13706
|
-
|
|
14231
|
+
_ts_decorate55([
|
|
13707
14232
|
common.UseGuards(exports.JwtPlatformGuard),
|
|
13708
14233
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.mfaSetup),
|
|
13709
14234
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaSetup),
|
|
13710
14235
|
RequestEncoding("when-body"),
|
|
13711
14236
|
common.Post("setup"),
|
|
13712
|
-
|
|
13713
|
-
|
|
13714
|
-
|
|
13715
|
-
|
|
14237
|
+
_ts_param33(0, CurrentUser()),
|
|
14238
|
+
_ts_param33(1, common.Body()),
|
|
14239
|
+
_ts_metadata54("design:type", Function),
|
|
14240
|
+
_ts_metadata54("design:paramtypes", [
|
|
13716
14241
|
typeof PlatformJwtPayload === "undefined" ? Object : PlatformJwtPayload,
|
|
13717
14242
|
typeof MfaSetupDto === "undefined" ? Object : MfaSetupDto
|
|
13718
14243
|
]),
|
|
13719
|
-
|
|
14244
|
+
_ts_metadata54("design:returntype", Promise)
|
|
13720
14245
|
], PlatformMfaController.prototype, "setup", null);
|
|
13721
|
-
|
|
14246
|
+
_ts_decorate55([
|
|
13722
14247
|
common.UseGuards(exports.JwtPlatformGuard),
|
|
13723
14248
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.mfaVerifyEnable),
|
|
13724
14249
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaVerifyEnable),
|
|
13725
14250
|
common.HttpCode(common.HttpStatus.NO_CONTENT),
|
|
13726
14251
|
common.Post("verify-enable"),
|
|
13727
|
-
|
|
13728
|
-
|
|
13729
|
-
|
|
13730
|
-
|
|
13731
|
-
|
|
14252
|
+
_ts_param33(0, CurrentUser()),
|
|
14253
|
+
_ts_param33(1, common.Body()),
|
|
14254
|
+
_ts_param33(2, common.Req()),
|
|
14255
|
+
_ts_metadata54("design:type", Function),
|
|
14256
|
+
_ts_metadata54("design:paramtypes", [
|
|
13732
14257
|
typeof PlatformJwtPayload === "undefined" ? Object : PlatformJwtPayload,
|
|
13733
14258
|
typeof MfaVerifyDto === "undefined" ? Object : MfaVerifyDto,
|
|
13734
14259
|
typeof Request === "undefined" ? Object : Request
|
|
13735
14260
|
]),
|
|
13736
|
-
|
|
14261
|
+
_ts_metadata54("design:returntype", Promise)
|
|
13737
14262
|
], PlatformMfaController.prototype, "verifyEnable", null);
|
|
13738
|
-
|
|
14263
|
+
_ts_decorate55([
|
|
13739
14264
|
common.UseGuards(exports.JwtPlatformGuard),
|
|
13740
14265
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.mfaDisable),
|
|
13741
14266
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaDisable),
|
|
13742
14267
|
common.HttpCode(common.HttpStatus.NO_CONTENT),
|
|
13743
14268
|
common.Post("disable"),
|
|
13744
|
-
|
|
13745
|
-
|
|
13746
|
-
|
|
13747
|
-
|
|
13748
|
-
|
|
14269
|
+
_ts_param33(0, CurrentUser()),
|
|
14270
|
+
_ts_param33(1, common.Body()),
|
|
14271
|
+
_ts_param33(2, common.Req()),
|
|
14272
|
+
_ts_metadata54("design:type", Function),
|
|
14273
|
+
_ts_metadata54("design:paramtypes", [
|
|
13749
14274
|
typeof PlatformJwtPayload === "undefined" ? Object : PlatformJwtPayload,
|
|
13750
14275
|
typeof MfaDisableDto === "undefined" ? Object : MfaDisableDto,
|
|
13751
14276
|
typeof Request === "undefined" ? Object : Request
|
|
13752
14277
|
]),
|
|
13753
|
-
|
|
14278
|
+
_ts_metadata54("design:returntype", Promise)
|
|
13754
14279
|
], PlatformMfaController.prototype, "disable", null);
|
|
13755
|
-
|
|
14280
|
+
_ts_decorate55([
|
|
13756
14281
|
common.UseGuards(exports.JwtPlatformGuard),
|
|
13757
14282
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.mfaDisable),
|
|
13758
14283
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.mfaDisable),
|
|
13759
14284
|
common.HttpCode(common.HttpStatus.OK),
|
|
13760
14285
|
common.Post("recovery-codes"),
|
|
13761
|
-
|
|
13762
|
-
|
|
13763
|
-
|
|
13764
|
-
|
|
13765
|
-
|
|
14286
|
+
_ts_param33(0, CurrentUser()),
|
|
14287
|
+
_ts_param33(1, common.Body()),
|
|
14288
|
+
_ts_param33(2, common.Req()),
|
|
14289
|
+
_ts_metadata54("design:type", Function),
|
|
14290
|
+
_ts_metadata54("design:paramtypes", [
|
|
13766
14291
|
typeof PlatformJwtPayload === "undefined" ? Object : PlatformJwtPayload,
|
|
13767
14292
|
typeof MfaRegenerateRecoveryCodesDto === "undefined" ? Object : MfaRegenerateRecoveryCodesDto,
|
|
13768
14293
|
typeof Request === "undefined" ? Object : Request
|
|
13769
14294
|
]),
|
|
13770
|
-
|
|
14295
|
+
_ts_metadata54("design:returntype", Promise)
|
|
13771
14296
|
], PlatformMfaController.prototype, "regenerateRecoveryCodes", null);
|
|
13772
|
-
PlatformMfaController =
|
|
14297
|
+
PlatformMfaController = _ts_decorate55([
|
|
13773
14298
|
common.UseInterceptors(NoStoreInterceptor),
|
|
13774
14299
|
common.Controller("platform/mfa"),
|
|
13775
14300
|
common.UseGuards(exports.RequestEncodingGuard, exports.TrustedOriginGuard, exports.AuthRateLimitGuard),
|
|
13776
14301
|
common.UsePipes(createAuthValidationPipe({
|
|
13777
14302
|
forbidUnknownValues: true
|
|
13778
14303
|
})),
|
|
13779
|
-
|
|
13780
|
-
|
|
13781
|
-
|
|
14304
|
+
_ts_param33(0, common.Inject(exports.MfaService)),
|
|
14305
|
+
_ts_metadata54("design:type", Function),
|
|
14306
|
+
_ts_metadata54("design:paramtypes", [
|
|
13782
14307
|
typeof exports.MfaService === "undefined" ? Object : exports.MfaService
|
|
13783
14308
|
])
|
|
13784
14309
|
], PlatformMfaController);
|
|
13785
|
-
function
|
|
14310
|
+
function _ts_decorate56(decorators, target, key, desc) {
|
|
13786
14311
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
13787
14312
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
13788
14313
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -13795,19 +14320,19 @@ function _ts_decorate51(decorators, target, key, desc) {
|
|
|
13795
14320
|
}
|
|
13796
14321
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
13797
14322
|
}
|
|
13798
|
-
__name(
|
|
13799
|
-
function
|
|
14323
|
+
__name(_ts_decorate56, "_ts_decorate");
|
|
14324
|
+
function _ts_metadata55(metadataKey, metadataValue) {
|
|
13800
14325
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
13801
14326
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
13802
14327
|
}
|
|
13803
14328
|
}
|
|
13804
|
-
__name(
|
|
13805
|
-
function
|
|
14329
|
+
__name(_ts_metadata55, "_ts_metadata");
|
|
14330
|
+
function _ts_param34(paramIndex, decorator) {
|
|
13806
14331
|
return function(target, key) {
|
|
13807
14332
|
decorator(target, key, paramIndex);
|
|
13808
14333
|
};
|
|
13809
14334
|
}
|
|
13810
|
-
__name(
|
|
14335
|
+
__name(_ts_param34, "_ts_param");
|
|
13811
14336
|
var SessionController = class {
|
|
13812
14337
|
static {
|
|
13813
14338
|
__name(this, "SessionController");
|
|
@@ -13907,64 +14432,64 @@ var SessionController = class {
|
|
|
13907
14432
|
});
|
|
13908
14433
|
}
|
|
13909
14434
|
};
|
|
13910
|
-
|
|
14435
|
+
_ts_decorate56([
|
|
13911
14436
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.listSessions),
|
|
13912
14437
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.listSessions),
|
|
13913
14438
|
common.Get(),
|
|
13914
|
-
|
|
13915
|
-
|
|
13916
|
-
|
|
13917
|
-
|
|
14439
|
+
_ts_param34(0, CurrentUser()),
|
|
14440
|
+
_ts_param34(1, common.Req()),
|
|
14441
|
+
_ts_metadata55("design:type", Function),
|
|
14442
|
+
_ts_metadata55("design:paramtypes", [
|
|
13918
14443
|
typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
|
|
13919
14444
|
typeof Request === "undefined" ? Object : Request
|
|
13920
14445
|
]),
|
|
13921
|
-
|
|
14446
|
+
_ts_metadata55("design:returntype", Promise)
|
|
13922
14447
|
], SessionController.prototype, "listSessions", null);
|
|
13923
|
-
|
|
14448
|
+
_ts_decorate56([
|
|
13924
14449
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.revokeAllSessions),
|
|
13925
14450
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.revokeAllSessions),
|
|
13926
14451
|
common.HttpCode(common.HttpStatus.NO_CONTENT),
|
|
13927
14452
|
RequestEncoding("unchecked"),
|
|
13928
14453
|
common.Post("revoke-all"),
|
|
13929
|
-
|
|
13930
|
-
|
|
13931
|
-
|
|
13932
|
-
|
|
14454
|
+
_ts_param34(0, CurrentUser()),
|
|
14455
|
+
_ts_param34(1, common.Req()),
|
|
14456
|
+
_ts_metadata55("design:type", Function),
|
|
14457
|
+
_ts_metadata55("design:paramtypes", [
|
|
13933
14458
|
typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
|
|
13934
14459
|
typeof Request === "undefined" ? Object : Request
|
|
13935
14460
|
]),
|
|
13936
|
-
|
|
14461
|
+
_ts_metadata55("design:returntype", Promise)
|
|
13937
14462
|
], SessionController.prototype, "revokeAllSessions", null);
|
|
13938
|
-
|
|
14463
|
+
_ts_decorate56([
|
|
13939
14464
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.revokeSession),
|
|
13940
14465
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.revokeSession),
|
|
13941
14466
|
common.HttpCode(common.HttpStatus.NO_CONTENT),
|
|
13942
14467
|
common.Delete(":id"),
|
|
13943
|
-
|
|
13944
|
-
|
|
13945
|
-
|
|
13946
|
-
|
|
14468
|
+
_ts_param34(0, CurrentUser()),
|
|
14469
|
+
_ts_param34(1, common.Param("id")),
|
|
14470
|
+
_ts_metadata55("design:type", Function),
|
|
14471
|
+
_ts_metadata55("design:paramtypes", [
|
|
13947
14472
|
typeof DashboardJwtPayload === "undefined" ? Object : DashboardJwtPayload,
|
|
13948
14473
|
String
|
|
13949
14474
|
]),
|
|
13950
|
-
|
|
14475
|
+
_ts_metadata55("design:returntype", Promise)
|
|
13951
14476
|
], SessionController.prototype, "revokeSession", null);
|
|
13952
|
-
SessionController =
|
|
14477
|
+
SessionController = _ts_decorate56([
|
|
13953
14478
|
common.UseInterceptors(NoStoreInterceptor),
|
|
13954
14479
|
common.Controller("sessions"),
|
|
13955
14480
|
common.UseGuards(exports.RequestEncodingGuard, exports.TrustedOriginGuard, exports.AuthRateLimitGuard, exports.JwtAuthGuard, exports.UserStatusGuard),
|
|
13956
14481
|
common.UsePipes(createAuthValidationPipe()),
|
|
13957
|
-
|
|
13958
|
-
|
|
13959
|
-
|
|
13960
|
-
|
|
14482
|
+
_ts_param34(0, common.Inject(exports.SessionService)),
|
|
14483
|
+
_ts_param34(1, common.Inject(exports.TokenDeliveryService)),
|
|
14484
|
+
_ts_metadata55("design:type", Function),
|
|
14485
|
+
_ts_metadata55("design:paramtypes", [
|
|
13961
14486
|
typeof exports.SessionService === "undefined" ? Object : exports.SessionService,
|
|
13962
14487
|
typeof exports.TokenDeliveryService === "undefined" ? Object : exports.TokenDeliveryService
|
|
13963
14488
|
])
|
|
13964
14489
|
], SessionController);
|
|
13965
14490
|
var API_KEY_SCOPES_KEY = /* @__PURE__ */ Symbol("bymax:apiKeyScopes");
|
|
13966
14491
|
var ApiKeyScopes = /* @__PURE__ */ __name((...scopes) => common.SetMetadata(API_KEY_SCOPES_KEY, scopes), "ApiKeyScopes");
|
|
13967
|
-
function
|
|
14492
|
+
function _ts_decorate57(decorators, target, key, desc) {
|
|
13968
14493
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
13969
14494
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
13970
14495
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -13977,19 +14502,19 @@ function _ts_decorate52(decorators, target, key, desc) {
|
|
|
13977
14502
|
}
|
|
13978
14503
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
13979
14504
|
}
|
|
13980
|
-
__name(
|
|
13981
|
-
function
|
|
14505
|
+
__name(_ts_decorate57, "_ts_decorate");
|
|
14506
|
+
function _ts_metadata56(metadataKey, metadataValue) {
|
|
13982
14507
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
13983
14508
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
13984
14509
|
}
|
|
13985
14510
|
}
|
|
13986
|
-
__name(
|
|
13987
|
-
function
|
|
14511
|
+
__name(_ts_metadata56, "_ts_metadata");
|
|
14512
|
+
function _ts_param35(paramIndex, decorator) {
|
|
13988
14513
|
return function(target, key) {
|
|
13989
14514
|
decorator(target, key, paramIndex);
|
|
13990
14515
|
};
|
|
13991
14516
|
}
|
|
13992
|
-
__name(
|
|
14517
|
+
__name(_ts_param35, "_ts_param");
|
|
13993
14518
|
var ApiKeyLastUsedService = class _ApiKeyLastUsedService {
|
|
13994
14519
|
static {
|
|
13995
14520
|
__name(this, "ApiKeyLastUsedService");
|
|
@@ -14050,12 +14575,12 @@ var ApiKeyLastUsedService = class _ApiKeyLastUsedService {
|
|
|
14050
14575
|
await this.flush();
|
|
14051
14576
|
}
|
|
14052
14577
|
};
|
|
14053
|
-
ApiKeyLastUsedService =
|
|
14578
|
+
ApiKeyLastUsedService = _ts_decorate57([
|
|
14054
14579
|
common.Injectable(),
|
|
14055
|
-
|
|
14056
|
-
|
|
14057
|
-
|
|
14058
|
-
|
|
14580
|
+
_ts_param35(0, common.Inject(BYMAX_AUTH_API_KEY_REPOSITORY)),
|
|
14581
|
+
_ts_param35(1, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
14582
|
+
_ts_metadata56("design:type", Function),
|
|
14583
|
+
_ts_metadata56("design:paramtypes", [
|
|
14059
14584
|
typeof IApiKeyRepository === "undefined" ? Object : IApiKeyRepository,
|
|
14060
14585
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
|
|
14061
14586
|
])
|
|
@@ -14104,7 +14629,7 @@ function digestsMatch(computed, stored) {
|
|
|
14104
14629
|
__name(digestsMatch, "digestsMatch");
|
|
14105
14630
|
|
|
14106
14631
|
// src/server/services/api-key-verifier.service.ts
|
|
14107
|
-
function
|
|
14632
|
+
function _ts_decorate58(decorators, target, key, desc) {
|
|
14108
14633
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
14109
14634
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
14110
14635
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -14117,19 +14642,19 @@ function _ts_decorate53(decorators, target, key, desc) {
|
|
|
14117
14642
|
}
|
|
14118
14643
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14119
14644
|
}
|
|
14120
|
-
__name(
|
|
14121
|
-
function
|
|
14645
|
+
__name(_ts_decorate58, "_ts_decorate");
|
|
14646
|
+
function _ts_metadata57(metadataKey, metadataValue) {
|
|
14122
14647
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
14123
14648
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
14124
14649
|
}
|
|
14125
14650
|
}
|
|
14126
|
-
__name(
|
|
14127
|
-
function
|
|
14651
|
+
__name(_ts_metadata57, "_ts_metadata");
|
|
14652
|
+
function _ts_param36(paramIndex, decorator) {
|
|
14128
14653
|
return function(target, key) {
|
|
14129
14654
|
decorator(target, key, paramIndex);
|
|
14130
14655
|
};
|
|
14131
14656
|
}
|
|
14132
|
-
__name(
|
|
14657
|
+
__name(_ts_param36, "_ts_param");
|
|
14133
14658
|
var ApiKeyVerifierService = class {
|
|
14134
14659
|
static {
|
|
14135
14660
|
__name(this, "ApiKeyVerifierService");
|
|
@@ -14189,14 +14714,14 @@ var ApiKeyVerifierService = class {
|
|
|
14189
14714
|
return null;
|
|
14190
14715
|
}
|
|
14191
14716
|
};
|
|
14192
|
-
ApiKeyVerifierService =
|
|
14717
|
+
ApiKeyVerifierService = _ts_decorate58([
|
|
14193
14718
|
common.Injectable(),
|
|
14194
|
-
|
|
14195
|
-
|
|
14196
|
-
|
|
14197
|
-
|
|
14198
|
-
|
|
14199
|
-
|
|
14719
|
+
_ts_param36(0, common.Inject(BYMAX_AUTH_API_KEY_REPOSITORY)),
|
|
14720
|
+
_ts_param36(1, common.Inject(BYMAX_AUTH_API_KEY_CLOCK)),
|
|
14721
|
+
_ts_param36(2, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
14722
|
+
_ts_param36(3, common.Inject(ApiKeyLastUsedService)),
|
|
14723
|
+
_ts_metadata57("design:type", Function),
|
|
14724
|
+
_ts_metadata57("design:paramtypes", [
|
|
14200
14725
|
typeof IApiKeyRepository === "undefined" ? Object : IApiKeyRepository,
|
|
14201
14726
|
typeof ApiKeyClock === "undefined" ? Object : ApiKeyClock,
|
|
14202
14727
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
|
|
@@ -14205,7 +14730,7 @@ ApiKeyVerifierService = _ts_decorate53([
|
|
|
14205
14730
|
], ApiKeyVerifierService);
|
|
14206
14731
|
|
|
14207
14732
|
// src/server/guards/api-key.guard.ts
|
|
14208
|
-
function
|
|
14733
|
+
function _ts_decorate59(decorators, target, key, desc) {
|
|
14209
14734
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
14210
14735
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
14211
14736
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -14218,19 +14743,19 @@ function _ts_decorate54(decorators, target, key, desc) {
|
|
|
14218
14743
|
}
|
|
14219
14744
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14220
14745
|
}
|
|
14221
|
-
__name(
|
|
14222
|
-
function
|
|
14746
|
+
__name(_ts_decorate59, "_ts_decorate");
|
|
14747
|
+
function _ts_metadata58(metadataKey, metadataValue) {
|
|
14223
14748
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
14224
14749
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
14225
14750
|
}
|
|
14226
14751
|
}
|
|
14227
|
-
__name(
|
|
14228
|
-
function
|
|
14752
|
+
__name(_ts_metadata58, "_ts_metadata");
|
|
14753
|
+
function _ts_param37(paramIndex, decorator) {
|
|
14229
14754
|
return function(target, key) {
|
|
14230
14755
|
decorator(target, key, paramIndex);
|
|
14231
14756
|
};
|
|
14232
14757
|
}
|
|
14233
|
-
__name(
|
|
14758
|
+
__name(_ts_param37, "_ts_param");
|
|
14234
14759
|
exports.ApiKeyGuard = class _ApiKeyGuard {
|
|
14235
14760
|
static {
|
|
14236
14761
|
__name(this, "ApiKeyGuard");
|
|
@@ -14370,15 +14895,15 @@ exports.ApiKeyGuard = class _ApiKeyGuard {
|
|
|
14370
14895
|
};
|
|
14371
14896
|
}
|
|
14372
14897
|
};
|
|
14373
|
-
exports.ApiKeyGuard =
|
|
14898
|
+
exports.ApiKeyGuard = _ts_decorate59([
|
|
14374
14899
|
common.Injectable(),
|
|
14375
|
-
|
|
14376
|
-
|
|
14377
|
-
|
|
14378
|
-
|
|
14379
|
-
|
|
14380
|
-
|
|
14381
|
-
|
|
14900
|
+
_ts_param37(0, common.Inject(core.Reflector)),
|
|
14901
|
+
_ts_param37(1, common.Inject(ApiKeyVerifierService)),
|
|
14902
|
+
_ts_param37(2, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
14903
|
+
_ts_param37(3, common.Inject(BYMAX_AUTH_HOOKS)),
|
|
14904
|
+
_ts_param37(3, common.Optional()),
|
|
14905
|
+
_ts_metadata58("design:type", Function),
|
|
14906
|
+
_ts_metadata58("design:paramtypes", [
|
|
14382
14907
|
typeof core.Reflector === "undefined" ? Object : core.Reflector,
|
|
14383
14908
|
typeof ApiKeyVerifierService === "undefined" ? Object : ApiKeyVerifierService,
|
|
14384
14909
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
|
|
@@ -14390,7 +14915,7 @@ function routePattern(request) {
|
|
|
14390
14915
|
return typeof path === "string" ? path : "";
|
|
14391
14916
|
}
|
|
14392
14917
|
__name(routePattern, "routePattern");
|
|
14393
|
-
function
|
|
14918
|
+
function _ts_decorate60(decorators, target, key, desc) {
|
|
14394
14919
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
14395
14920
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
14396
14921
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -14403,19 +14928,19 @@ function _ts_decorate55(decorators, target, key, desc) {
|
|
|
14403
14928
|
}
|
|
14404
14929
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14405
14930
|
}
|
|
14406
|
-
__name(
|
|
14407
|
-
function
|
|
14931
|
+
__name(_ts_decorate60, "_ts_decorate");
|
|
14932
|
+
function _ts_metadata59(metadataKey, metadataValue) {
|
|
14408
14933
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
14409
14934
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
14410
14935
|
}
|
|
14411
14936
|
}
|
|
14412
|
-
__name(
|
|
14413
|
-
function
|
|
14937
|
+
__name(_ts_metadata59, "_ts_metadata");
|
|
14938
|
+
function _ts_param38(paramIndex, decorator) {
|
|
14414
14939
|
return function(target, key) {
|
|
14415
14940
|
decorator(target, key, paramIndex);
|
|
14416
14941
|
};
|
|
14417
14942
|
}
|
|
14418
|
-
__name(
|
|
14943
|
+
__name(_ts_param38, "_ts_param");
|
|
14419
14944
|
exports.MfaRequiredGuard = class MfaRequiredGuard {
|
|
14420
14945
|
static {
|
|
14421
14946
|
__name(this, "MfaRequiredGuard");
|
|
@@ -14442,11 +14967,11 @@ exports.MfaRequiredGuard = class MfaRequiredGuard {
|
|
|
14442
14967
|
return true;
|
|
14443
14968
|
}
|
|
14444
14969
|
};
|
|
14445
|
-
exports.MfaRequiredGuard =
|
|
14970
|
+
exports.MfaRequiredGuard = _ts_decorate60([
|
|
14446
14971
|
common.Injectable(),
|
|
14447
|
-
|
|
14448
|
-
|
|
14449
|
-
|
|
14972
|
+
_ts_param38(0, common.Inject(core.Reflector)),
|
|
14973
|
+
_ts_metadata59("design:type", Function),
|
|
14974
|
+
_ts_metadata59("design:paramtypes", [
|
|
14450
14975
|
typeof core.Reflector === "undefined" ? Object : core.Reflector
|
|
14451
14976
|
])
|
|
14452
14977
|
], exports.MfaRequiredGuard);
|
|
@@ -14454,7 +14979,7 @@ var PLATFORM_ROLES_KEY = /* @__PURE__ */ Symbol("platformRoles");
|
|
|
14454
14979
|
var PlatformRoles = /* @__PURE__ */ __name((...roles) => common.SetMetadata(PLATFORM_ROLES_KEY, roles), "PlatformRoles");
|
|
14455
14980
|
|
|
14456
14981
|
// src/server/guards/platform-roles.guard.ts
|
|
14457
|
-
function
|
|
14982
|
+
function _ts_decorate61(decorators, target, key, desc) {
|
|
14458
14983
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
14459
14984
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
14460
14985
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -14467,19 +14992,19 @@ function _ts_decorate56(decorators, target, key, desc) {
|
|
|
14467
14992
|
}
|
|
14468
14993
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14469
14994
|
}
|
|
14470
|
-
__name(
|
|
14471
|
-
function
|
|
14995
|
+
__name(_ts_decorate61, "_ts_decorate");
|
|
14996
|
+
function _ts_metadata60(metadataKey, metadataValue) {
|
|
14472
14997
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
14473
14998
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
14474
14999
|
}
|
|
14475
15000
|
}
|
|
14476
|
-
__name(
|
|
14477
|
-
function
|
|
15001
|
+
__name(_ts_metadata60, "_ts_metadata");
|
|
15002
|
+
function _ts_param39(paramIndex, decorator) {
|
|
14478
15003
|
return function(target, key) {
|
|
14479
15004
|
decorator(target, key, paramIndex);
|
|
14480
15005
|
};
|
|
14481
15006
|
}
|
|
14482
|
-
__name(
|
|
15007
|
+
__name(_ts_param39, "_ts_param");
|
|
14483
15008
|
exports.PlatformRolesGuard = class PlatformRolesGuard {
|
|
14484
15009
|
static {
|
|
14485
15010
|
__name(this, "PlatformRolesGuard");
|
|
@@ -14513,12 +15038,12 @@ exports.PlatformRolesGuard = class PlatformRolesGuard {
|
|
|
14513
15038
|
return true;
|
|
14514
15039
|
}
|
|
14515
15040
|
};
|
|
14516
|
-
exports.PlatformRolesGuard =
|
|
15041
|
+
exports.PlatformRolesGuard = _ts_decorate61([
|
|
14517
15042
|
common.Injectable(),
|
|
14518
|
-
|
|
14519
|
-
|
|
14520
|
-
|
|
14521
|
-
|
|
15043
|
+
_ts_param39(0, common.Inject(core.Reflector)),
|
|
15044
|
+
_ts_param39(1, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
15045
|
+
_ts_metadata60("design:type", Function),
|
|
15046
|
+
_ts_metadata60("design:paramtypes", [
|
|
14522
15047
|
typeof core.Reflector === "undefined" ? Object : core.Reflector,
|
|
14523
15048
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
|
|
14524
15049
|
])
|
|
@@ -14527,7 +15052,7 @@ var ROLES_KEY = "roles";
|
|
|
14527
15052
|
var Roles = /* @__PURE__ */ __name((...roles) => common.SetMetadata(ROLES_KEY, roles), "Roles");
|
|
14528
15053
|
|
|
14529
15054
|
// src/server/guards/roles.guard.ts
|
|
14530
|
-
function
|
|
15055
|
+
function _ts_decorate62(decorators, target, key, desc) {
|
|
14531
15056
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
14532
15057
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
14533
15058
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -14540,19 +15065,19 @@ function _ts_decorate57(decorators, target, key, desc) {
|
|
|
14540
15065
|
}
|
|
14541
15066
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14542
15067
|
}
|
|
14543
|
-
__name(
|
|
14544
|
-
function
|
|
15068
|
+
__name(_ts_decorate62, "_ts_decorate");
|
|
15069
|
+
function _ts_metadata61(metadataKey, metadataValue) {
|
|
14545
15070
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
14546
15071
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
14547
15072
|
}
|
|
14548
15073
|
}
|
|
14549
|
-
__name(
|
|
14550
|
-
function
|
|
15074
|
+
__name(_ts_metadata61, "_ts_metadata");
|
|
15075
|
+
function _ts_param40(paramIndex, decorator) {
|
|
14551
15076
|
return function(target, key) {
|
|
14552
15077
|
decorator(target, key, paramIndex);
|
|
14553
15078
|
};
|
|
14554
15079
|
}
|
|
14555
|
-
__name(
|
|
15080
|
+
__name(_ts_param40, "_ts_param");
|
|
14556
15081
|
exports.RolesGuard = class RolesGuard {
|
|
14557
15082
|
static {
|
|
14558
15083
|
__name(this, "RolesGuard");
|
|
@@ -14582,17 +15107,17 @@ exports.RolesGuard = class RolesGuard {
|
|
|
14582
15107
|
return true;
|
|
14583
15108
|
}
|
|
14584
15109
|
};
|
|
14585
|
-
exports.RolesGuard =
|
|
15110
|
+
exports.RolesGuard = _ts_decorate62([
|
|
14586
15111
|
common.Injectable(),
|
|
14587
|
-
|
|
14588
|
-
|
|
14589
|
-
|
|
14590
|
-
|
|
15112
|
+
_ts_param40(0, common.Inject(core.Reflector)),
|
|
15113
|
+
_ts_param40(1, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
15114
|
+
_ts_metadata61("design:type", Function),
|
|
15115
|
+
_ts_metadata61("design:paramtypes", [
|
|
14591
15116
|
typeof core.Reflector === "undefined" ? Object : core.Reflector,
|
|
14592
15117
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
|
|
14593
15118
|
])
|
|
14594
15119
|
], exports.RolesGuard);
|
|
14595
|
-
function
|
|
15120
|
+
function _ts_decorate63(decorators, target, key, desc) {
|
|
14596
15121
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
14597
15122
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
14598
15123
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -14605,7 +15130,7 @@ function _ts_decorate58(decorators, target, key, desc) {
|
|
|
14605
15130
|
}
|
|
14606
15131
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14607
15132
|
}
|
|
14608
|
-
__name(
|
|
15133
|
+
__name(_ts_decorate63, "_ts_decorate");
|
|
14609
15134
|
exports.NoOpAuthHooks = class NoOpAuthHooks {
|
|
14610
15135
|
static {
|
|
14611
15136
|
__name(this, "NoOpAuthHooks");
|
|
@@ -14654,7 +15179,7 @@ exports.NoOpAuthHooks = class NoOpAuthHooks {
|
|
|
14654
15179
|
};
|
|
14655
15180
|
}
|
|
14656
15181
|
};
|
|
14657
|
-
exports.NoOpAuthHooks =
|
|
15182
|
+
exports.NoOpAuthHooks = _ts_decorate63([
|
|
14658
15183
|
common.Injectable()
|
|
14659
15184
|
], exports.NoOpAuthHooks);
|
|
14660
15185
|
|
|
@@ -14667,7 +15192,7 @@ var OAUTH_STATE_COOKIE_SAME_SITE = "lax";
|
|
|
14667
15192
|
var OAUTH_STATE_COOKIE_MAX_AGE_SECONDS = 600;
|
|
14668
15193
|
|
|
14669
15194
|
// src/server/oauth/oauth.service.ts
|
|
14670
|
-
function
|
|
15195
|
+
function _ts_decorate64(decorators, target, key, desc) {
|
|
14671
15196
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
14672
15197
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
14673
15198
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -14680,19 +15205,19 @@ function _ts_decorate59(decorators, target, key, desc) {
|
|
|
14680
15205
|
}
|
|
14681
15206
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14682
15207
|
}
|
|
14683
|
-
__name(
|
|
14684
|
-
function
|
|
15208
|
+
__name(_ts_decorate64, "_ts_decorate");
|
|
15209
|
+
function _ts_metadata62(metadataKey, metadataValue) {
|
|
14685
15210
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
14686
15211
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
14687
15212
|
}
|
|
14688
15213
|
}
|
|
14689
|
-
__name(
|
|
14690
|
-
function
|
|
15214
|
+
__name(_ts_metadata62, "_ts_metadata");
|
|
15215
|
+
function _ts_param41(paramIndex, decorator) {
|
|
14691
15216
|
return function(target, key) {
|
|
14692
15217
|
decorator(target, key, paramIndex);
|
|
14693
15218
|
};
|
|
14694
15219
|
}
|
|
14695
|
-
__name(
|
|
15220
|
+
__name(_ts_param41, "_ts_param");
|
|
14696
15221
|
var OAUTH_STATE_TTL_SECONDS = 600;
|
|
14697
15222
|
function isStoredOAuthState(value) {
|
|
14698
15223
|
if (typeof value !== "object" || value === null) return false;
|
|
@@ -14986,18 +15511,18 @@ exports.OAuthService = class _OAuthService {
|
|
|
14986
15511
|
return plugin;
|
|
14987
15512
|
}
|
|
14988
15513
|
};
|
|
14989
|
-
exports.OAuthService =
|
|
15514
|
+
exports.OAuthService = _ts_decorate64([
|
|
14990
15515
|
common.Injectable(),
|
|
14991
|
-
|
|
14992
|
-
|
|
14993
|
-
|
|
14994
|
-
|
|
14995
|
-
|
|
14996
|
-
|
|
14997
|
-
|
|
14998
|
-
|
|
14999
|
-
|
|
15000
|
-
|
|
15516
|
+
_ts_param41(0, common.Inject(OAUTH_PLUGINS)),
|
|
15517
|
+
_ts_param41(1, common.Inject(BYMAX_AUTH_USER_REPOSITORY)),
|
|
15518
|
+
_ts_param41(2, common.Inject(BYMAX_AUTH_HOOKS)),
|
|
15519
|
+
_ts_param41(2, common.Optional()),
|
|
15520
|
+
_ts_param41(3, common.Inject(AuthRedisService)),
|
|
15521
|
+
_ts_param41(4, common.Inject(TokenManagerService)),
|
|
15522
|
+
_ts_param41(5, common.Inject(exports.SessionService)),
|
|
15523
|
+
_ts_param41(6, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
15524
|
+
_ts_metadata62("design:type", Function),
|
|
15525
|
+
_ts_metadata62("design:paramtypes", [
|
|
15001
15526
|
Array,
|
|
15002
15527
|
typeof IUserRepository === "undefined" ? Object : IUserRepository,
|
|
15003
15528
|
Object,
|
|
@@ -15007,7 +15532,7 @@ exports.OAuthService = _ts_decorate59([
|
|
|
15007
15532
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
|
|
15008
15533
|
])
|
|
15009
15534
|
], exports.OAuthService);
|
|
15010
|
-
function
|
|
15535
|
+
function _ts_decorate65(decorators, target, key, desc) {
|
|
15011
15536
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15012
15537
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
15013
15538
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -15020,13 +15545,13 @@ function _ts_decorate60(decorators, target, key, desc) {
|
|
|
15020
15545
|
}
|
|
15021
15546
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
15022
15547
|
}
|
|
15023
|
-
__name(
|
|
15024
|
-
function
|
|
15548
|
+
__name(_ts_decorate65, "_ts_decorate");
|
|
15549
|
+
function _ts_metadata63(metadataKey, metadataValue) {
|
|
15025
15550
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
15026
15551
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
15027
15552
|
}
|
|
15028
15553
|
}
|
|
15029
|
-
__name(
|
|
15554
|
+
__name(_ts_metadata63, "_ts_metadata");
|
|
15030
15555
|
var OAuthCallbackQueryDto = class {
|
|
15031
15556
|
static {
|
|
15032
15557
|
__name(this, "OAuthCallbackQueryDto");
|
|
@@ -15125,69 +15650,69 @@ var OAuthCallbackQueryDto = class {
|
|
|
15125
15650
|
*/
|
|
15126
15651
|
hd;
|
|
15127
15652
|
};
|
|
15128
|
-
|
|
15653
|
+
_ts_decorate65([
|
|
15129
15654
|
classValidator.ValidateIf((query) => query.error === void 0 || query.error === null),
|
|
15130
15655
|
classValidator.IsOptional(),
|
|
15131
15656
|
classValidator.IsString(),
|
|
15132
15657
|
classValidator.IsNotEmpty(),
|
|
15133
15658
|
classValidator.MaxLength(2048),
|
|
15134
|
-
|
|
15659
|
+
_ts_metadata63("design:type", String)
|
|
15135
15660
|
], OAuthCallbackQueryDto.prototype, "code", void 0);
|
|
15136
|
-
|
|
15661
|
+
_ts_decorate65([
|
|
15137
15662
|
classValidator.IsOptional(),
|
|
15138
15663
|
classValidator.IsString(),
|
|
15139
15664
|
classValidator.MaxLength(128),
|
|
15140
|
-
|
|
15665
|
+
_ts_metadata63("design:type", String)
|
|
15141
15666
|
], OAuthCallbackQueryDto.prototype, "error", void 0);
|
|
15142
|
-
|
|
15667
|
+
_ts_decorate65([
|
|
15143
15668
|
classValidator.IsOptional(),
|
|
15144
15669
|
classValidator.IsString(),
|
|
15145
15670
|
classValidator.MaxLength(512),
|
|
15146
|
-
|
|
15671
|
+
_ts_metadata63("design:type", String)
|
|
15147
15672
|
], OAuthCallbackQueryDto.prototype, "error_description", void 0);
|
|
15148
|
-
|
|
15673
|
+
_ts_decorate65([
|
|
15149
15674
|
classValidator.IsOptional(),
|
|
15150
15675
|
classValidator.IsString(),
|
|
15151
15676
|
classValidator.MaxLength(512),
|
|
15152
|
-
|
|
15677
|
+
_ts_metadata63("design:type", String)
|
|
15153
15678
|
], OAuthCallbackQueryDto.prototype, "error_uri", void 0);
|
|
15154
|
-
|
|
15679
|
+
_ts_decorate65([
|
|
15155
15680
|
classValidator.IsString(),
|
|
15156
15681
|
classValidator.IsNotEmpty(),
|
|
15157
15682
|
classValidator.MaxLength(128),
|
|
15158
|
-
|
|
15683
|
+
_ts_metadata63("design:type", String)
|
|
15159
15684
|
], OAuthCallbackQueryDto.prototype, "state", void 0);
|
|
15160
|
-
|
|
15685
|
+
_ts_decorate65([
|
|
15161
15686
|
classValidator.IsOptional(),
|
|
15162
15687
|
classValidator.IsString(),
|
|
15163
15688
|
classValidator.MaxLength(512),
|
|
15164
|
-
|
|
15689
|
+
_ts_metadata63("design:type", String)
|
|
15165
15690
|
], OAuthCallbackQueryDto.prototype, "iss", void 0);
|
|
15166
|
-
|
|
15691
|
+
_ts_decorate65([
|
|
15167
15692
|
classValidator.IsOptional(),
|
|
15168
15693
|
classValidator.IsString(),
|
|
15169
15694
|
classValidator.MaxLength(2048),
|
|
15170
|
-
|
|
15695
|
+
_ts_metadata63("design:type", String)
|
|
15171
15696
|
], OAuthCallbackQueryDto.prototype, "scope", void 0);
|
|
15172
|
-
|
|
15697
|
+
_ts_decorate65([
|
|
15173
15698
|
classValidator.IsOptional(),
|
|
15174
15699
|
classValidator.IsString(),
|
|
15175
15700
|
classValidator.MaxLength(16),
|
|
15176
|
-
|
|
15701
|
+
_ts_metadata63("design:type", String)
|
|
15177
15702
|
], OAuthCallbackQueryDto.prototype, "authuser", void 0);
|
|
15178
|
-
|
|
15703
|
+
_ts_decorate65([
|
|
15179
15704
|
classValidator.IsOptional(),
|
|
15180
15705
|
classValidator.IsString(),
|
|
15181
15706
|
classValidator.MaxLength(64),
|
|
15182
|
-
|
|
15707
|
+
_ts_metadata63("design:type", String)
|
|
15183
15708
|
], OAuthCallbackQueryDto.prototype, "prompt", void 0);
|
|
15184
|
-
|
|
15709
|
+
_ts_decorate65([
|
|
15185
15710
|
classValidator.IsOptional(),
|
|
15186
15711
|
classValidator.IsString(),
|
|
15187
15712
|
classValidator.MaxLength(253),
|
|
15188
|
-
|
|
15713
|
+
_ts_metadata63("design:type", String)
|
|
15189
15714
|
], OAuthCallbackQueryDto.prototype, "hd", void 0);
|
|
15190
|
-
function
|
|
15715
|
+
function _ts_decorate66(decorators, target, key, desc) {
|
|
15191
15716
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15192
15717
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
15193
15718
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -15200,13 +15725,13 @@ function _ts_decorate61(decorators, target, key, desc) {
|
|
|
15200
15725
|
}
|
|
15201
15726
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
15202
15727
|
}
|
|
15203
|
-
__name(
|
|
15204
|
-
function
|
|
15728
|
+
__name(_ts_decorate66, "_ts_decorate");
|
|
15729
|
+
function _ts_metadata64(metadataKey, metadataValue) {
|
|
15205
15730
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
15206
15731
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
15207
15732
|
}
|
|
15208
15733
|
}
|
|
15209
|
-
__name(
|
|
15734
|
+
__name(_ts_metadata64, "_ts_metadata");
|
|
15210
15735
|
var OAuthInitiateQueryDto = class {
|
|
15211
15736
|
static {
|
|
15212
15737
|
__name(this, "OAuthInitiateQueryDto");
|
|
@@ -15223,7 +15748,7 @@ var OAuthInitiateQueryDto = class {
|
|
|
15223
15748
|
*/
|
|
15224
15749
|
tenantId;
|
|
15225
15750
|
};
|
|
15226
|
-
|
|
15751
|
+
_ts_decorate66([
|
|
15227
15752
|
classValidator.IsOptional(),
|
|
15228
15753
|
classValidator.IsString(),
|
|
15229
15754
|
classValidator.IsNotEmpty(),
|
|
@@ -15231,11 +15756,11 @@ _ts_decorate61([
|
|
|
15231
15756
|
classValidator.Matches(NO_CONTROL_CHARACTERS, {
|
|
15232
15757
|
message: "tenantId must not contain control characters"
|
|
15233
15758
|
}),
|
|
15234
|
-
|
|
15759
|
+
_ts_metadata64("design:type", String)
|
|
15235
15760
|
], OAuthInitiateQueryDto.prototype, "tenantId", void 0);
|
|
15236
15761
|
|
|
15237
15762
|
// src/server/oauth/oauth.controller.ts
|
|
15238
|
-
function
|
|
15763
|
+
function _ts_decorate67(decorators, target, key, desc) {
|
|
15239
15764
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15240
15765
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
15241
15766
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -15248,19 +15773,19 @@ function _ts_decorate62(decorators, target, key, desc) {
|
|
|
15248
15773
|
}
|
|
15249
15774
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
15250
15775
|
}
|
|
15251
|
-
__name(
|
|
15252
|
-
function
|
|
15776
|
+
__name(_ts_decorate67, "_ts_decorate");
|
|
15777
|
+
function _ts_metadata65(metadataKey, metadataValue) {
|
|
15253
15778
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
15254
15779
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
15255
15780
|
}
|
|
15256
15781
|
}
|
|
15257
|
-
__name(
|
|
15258
|
-
function
|
|
15782
|
+
__name(_ts_metadata65, "_ts_metadata");
|
|
15783
|
+
function _ts_param42(paramIndex, decorator) {
|
|
15259
15784
|
return function(target, key) {
|
|
15260
15785
|
decorator(target, key, paramIndex);
|
|
15261
15786
|
};
|
|
15262
15787
|
}
|
|
15263
|
-
__name(
|
|
15788
|
+
__name(_ts_param42, "_ts_param");
|
|
15264
15789
|
function isOAuthMfaChallenge(result) {
|
|
15265
15790
|
return "mfaRequired" in result && result.mfaRequired === true;
|
|
15266
15791
|
}
|
|
@@ -15478,46 +16003,46 @@ var OAuthController = class _OAuthController {
|
|
|
15478
16003
|
});
|
|
15479
16004
|
}
|
|
15480
16005
|
};
|
|
15481
|
-
|
|
16006
|
+
_ts_decorate67([
|
|
15482
16007
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.oauthInitiate),
|
|
15483
16008
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.oauthInitiate),
|
|
15484
16009
|
common.Get(":provider"),
|
|
15485
|
-
|
|
15486
|
-
|
|
15487
|
-
|
|
15488
|
-
|
|
16010
|
+
_ts_param42(0, common.Param("provider")),
|
|
16011
|
+
_ts_param42(1, common.Query()),
|
|
16012
|
+
_ts_param42(2, common.Req()),
|
|
16013
|
+
_ts_param42(3, common.Res({
|
|
15489
16014
|
passthrough: true
|
|
15490
16015
|
})),
|
|
15491
|
-
|
|
15492
|
-
|
|
16016
|
+
_ts_metadata65("design:type", Function),
|
|
16017
|
+
_ts_metadata65("design:paramtypes", [
|
|
15493
16018
|
String,
|
|
15494
16019
|
typeof OAuthInitiateQueryDto === "undefined" ? Object : OAuthInitiateQueryDto,
|
|
15495
16020
|
typeof Request === "undefined" ? Object : Request,
|
|
15496
16021
|
typeof Response === "undefined" ? Object : Response
|
|
15497
16022
|
]),
|
|
15498
|
-
|
|
16023
|
+
_ts_metadata65("design:returntype", Promise)
|
|
15499
16024
|
], OAuthController.prototype, "initiate", null);
|
|
15500
|
-
|
|
16025
|
+
_ts_decorate67([
|
|
15501
16026
|
throttler.Throttle(AUTH_THROTTLE_CONFIGS.oauthCallback),
|
|
15502
16027
|
AuthRateLimit(AUTH_THROTTLE_CONFIGS.oauthCallback),
|
|
15503
16028
|
common.HttpCode(common.HttpStatus.OK),
|
|
15504
16029
|
common.Get(":provider/callback"),
|
|
15505
|
-
|
|
15506
|
-
|
|
15507
|
-
|
|
15508
|
-
|
|
16030
|
+
_ts_param42(0, common.Param("provider")),
|
|
16031
|
+
_ts_param42(1, common.Query()),
|
|
16032
|
+
_ts_param42(2, common.Req()),
|
|
16033
|
+
_ts_param42(3, common.Res({
|
|
15509
16034
|
passthrough: true
|
|
15510
16035
|
})),
|
|
15511
|
-
|
|
15512
|
-
|
|
16036
|
+
_ts_metadata65("design:type", Function),
|
|
16037
|
+
_ts_metadata65("design:paramtypes", [
|
|
15513
16038
|
String,
|
|
15514
16039
|
typeof OAuthCallbackQueryDto === "undefined" ? Object : OAuthCallbackQueryDto,
|
|
15515
16040
|
typeof Request === "undefined" ? Object : Request,
|
|
15516
16041
|
typeof Response === "undefined" ? Object : Response
|
|
15517
16042
|
]),
|
|
15518
|
-
|
|
16043
|
+
_ts_metadata65("design:returntype", Promise)
|
|
15519
16044
|
], OAuthController.prototype, "callback", null);
|
|
15520
|
-
OAuthController =
|
|
16045
|
+
OAuthController = _ts_decorate67([
|
|
15521
16046
|
Public(),
|
|
15522
16047
|
SkipMfa(),
|
|
15523
16048
|
common.UseInterceptors(NoStoreInterceptor),
|
|
@@ -15526,11 +16051,11 @@ OAuthController = _ts_decorate62([
|
|
|
15526
16051
|
common.UsePipes(createAuthValidationPipe({
|
|
15527
16052
|
forbidUnknownValues: true
|
|
15528
16053
|
})),
|
|
15529
|
-
|
|
15530
|
-
|
|
15531
|
-
|
|
15532
|
-
|
|
15533
|
-
|
|
16054
|
+
_ts_param42(0, common.Inject(exports.OAuthService)),
|
|
16055
|
+
_ts_param42(1, common.Inject(exports.TokenDeliveryService)),
|
|
16056
|
+
_ts_param42(2, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
16057
|
+
_ts_metadata65("design:type", Function),
|
|
16058
|
+
_ts_metadata65("design:paramtypes", [
|
|
15534
16059
|
typeof exports.OAuthService === "undefined" ? Object : exports.OAuthService,
|
|
15535
16060
|
typeof exports.TokenDeliveryService === "undefined" ? Object : exports.TokenDeliveryService,
|
|
15536
16061
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
|
|
@@ -15669,7 +16194,7 @@ var GoogleOAuthPlugin = class {
|
|
|
15669
16194
|
};
|
|
15670
16195
|
|
|
15671
16196
|
// src/server/oauth/oauth.module.ts
|
|
15672
|
-
function
|
|
16197
|
+
function _ts_decorate68(decorators, target, key, desc) {
|
|
15673
16198
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15674
16199
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
15675
16200
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -15682,7 +16207,7 @@ function _ts_decorate63(decorators, target, key, desc) {
|
|
|
15682
16207
|
}
|
|
15683
16208
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
15684
16209
|
}
|
|
15685
|
-
__name(
|
|
16210
|
+
__name(_ts_decorate68, "_ts_decorate");
|
|
15686
16211
|
function buildOAuthPlugins(options) {
|
|
15687
16212
|
const plugins = [];
|
|
15688
16213
|
if (options.oauth?.google) {
|
|
@@ -15752,7 +16277,7 @@ var OAuthModule = class _OAuthModule {
|
|
|
15752
16277
|
};
|
|
15753
16278
|
}
|
|
15754
16279
|
};
|
|
15755
|
-
OAuthModule =
|
|
16280
|
+
OAuthModule = _ts_decorate68([
|
|
15756
16281
|
common.Module({})
|
|
15757
16282
|
], OAuthModule);
|
|
15758
16283
|
|
|
@@ -16647,7 +17172,7 @@ function schemesFor(options, registered, cookieDelivery, bearerDelivery) {
|
|
|
16647
17172
|
__name(schemesFor, "schemesFor");
|
|
16648
17173
|
|
|
16649
17174
|
// src/server/openapi/auth-openapi.contributor.ts
|
|
16650
|
-
function
|
|
17175
|
+
function _ts_decorate69(decorators, target, key, desc) {
|
|
16651
17176
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
16652
17177
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
16653
17178
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -16660,19 +17185,19 @@ function _ts_decorate64(decorators, target, key, desc) {
|
|
|
16660
17185
|
}
|
|
16661
17186
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
16662
17187
|
}
|
|
16663
|
-
__name(
|
|
16664
|
-
function
|
|
17188
|
+
__name(_ts_decorate69, "_ts_decorate");
|
|
17189
|
+
function _ts_metadata66(metadataKey, metadataValue) {
|
|
16665
17190
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
16666
17191
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
16667
17192
|
}
|
|
16668
17193
|
}
|
|
16669
|
-
__name(
|
|
16670
|
-
function
|
|
17194
|
+
__name(_ts_metadata66, "_ts_metadata");
|
|
17195
|
+
function _ts_param43(paramIndex, decorator) {
|
|
16671
17196
|
return function(target, key) {
|
|
16672
17197
|
decorator(target, key, paramIndex);
|
|
16673
17198
|
};
|
|
16674
17199
|
}
|
|
16675
|
-
__name(
|
|
17200
|
+
__name(_ts_param43, "_ts_param");
|
|
16676
17201
|
var AuthOpenApiContributor = class {
|
|
16677
17202
|
static {
|
|
16678
17203
|
__name(this, "AuthOpenApiContributor");
|
|
@@ -16692,18 +17217,18 @@ var AuthOpenApiContributor = class {
|
|
|
16692
17217
|
return buildAuthOpenApiFragment(this.options, this.registered);
|
|
16693
17218
|
}
|
|
16694
17219
|
};
|
|
16695
|
-
AuthOpenApiContributor =
|
|
17220
|
+
AuthOpenApiContributor = _ts_decorate69([
|
|
16696
17221
|
common.Injectable(),
|
|
16697
17222
|
common.SetMetadata(OPENAPI_CONTRIBUTOR_METADATA, true),
|
|
16698
|
-
|
|
16699
|
-
|
|
16700
|
-
|
|
16701
|
-
|
|
17223
|
+
_ts_param43(0, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
17224
|
+
_ts_param43(1, common.Inject(BYMAX_AUTH_REGISTERED_CONTROLLERS)),
|
|
17225
|
+
_ts_metadata66("design:type", Function),
|
|
17226
|
+
_ts_metadata66("design:paramtypes", [
|
|
16702
17227
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
|
|
16703
17228
|
typeof RegisteredControllers === "undefined" ? Object : RegisteredControllers
|
|
16704
17229
|
])
|
|
16705
17230
|
], AuthOpenApiContributor);
|
|
16706
|
-
function
|
|
17231
|
+
function _ts_decorate70(decorators, target, key, desc) {
|
|
16707
17232
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
16708
17233
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
16709
17234
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -16716,19 +17241,19 @@ function _ts_decorate65(decorators, target, key, desc) {
|
|
|
16716
17241
|
}
|
|
16717
17242
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
16718
17243
|
}
|
|
16719
|
-
__name(
|
|
16720
|
-
function
|
|
17244
|
+
__name(_ts_decorate70, "_ts_decorate");
|
|
17245
|
+
function _ts_metadata67(metadataKey, metadataValue) {
|
|
16721
17246
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
16722
17247
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
16723
17248
|
}
|
|
16724
17249
|
}
|
|
16725
|
-
__name(
|
|
16726
|
-
function
|
|
17250
|
+
__name(_ts_metadata67, "_ts_metadata");
|
|
17251
|
+
function _ts_param44(paramIndex, decorator) {
|
|
16727
17252
|
return function(target, key) {
|
|
16728
17253
|
decorator(target, key, paramIndex);
|
|
16729
17254
|
};
|
|
16730
17255
|
}
|
|
16731
|
-
__name(
|
|
17256
|
+
__name(_ts_param44, "_ts_param");
|
|
16732
17257
|
var COMMON_BASE_WORDS = [
|
|
16733
17258
|
// The perennial top of every published list.
|
|
16734
17259
|
"password",
|
|
@@ -17034,16 +17559,16 @@ exports.CommonPasswordChecker = class CommonPasswordChecker {
|
|
|
17034
17559
|
return false;
|
|
17035
17560
|
}
|
|
17036
17561
|
};
|
|
17037
|
-
exports.CommonPasswordChecker =
|
|
17562
|
+
exports.CommonPasswordChecker = _ts_decorate70([
|
|
17038
17563
|
common.Injectable(),
|
|
17039
|
-
|
|
17040
|
-
|
|
17041
|
-
|
|
17042
|
-
|
|
17564
|
+
_ts_param44(0, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
17565
|
+
_ts_param44(0, common.Optional()),
|
|
17566
|
+
_ts_metadata67("design:type", Function),
|
|
17567
|
+
_ts_metadata67("design:paramtypes", [
|
|
17043
17568
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
|
|
17044
17569
|
])
|
|
17045
17570
|
], exports.CommonPasswordChecker);
|
|
17046
|
-
function
|
|
17571
|
+
function _ts_decorate71(decorators, target, key, desc) {
|
|
17047
17572
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
17048
17573
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
17049
17574
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -17056,7 +17581,7 @@ function _ts_decorate66(decorators, target, key, desc) {
|
|
|
17056
17581
|
}
|
|
17057
17582
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
17058
17583
|
}
|
|
17059
|
-
__name(
|
|
17584
|
+
__name(_ts_decorate71, "_ts_decorate");
|
|
17060
17585
|
exports.NoOpEmailProvider = class _NoOpEmailProvider {
|
|
17061
17586
|
static {
|
|
17062
17587
|
__name(this, "NoOpEmailProvider");
|
|
@@ -17091,7 +17616,7 @@ exports.NoOpEmailProvider = class _NoOpEmailProvider {
|
|
|
17091
17616
|
this.logger.log(`sendInvitation \u2192 ${maskEmail(email)} (no-op)`);
|
|
17092
17617
|
}
|
|
17093
17618
|
};
|
|
17094
|
-
exports.NoOpEmailProvider =
|
|
17619
|
+
exports.NoOpEmailProvider = _ts_decorate71([
|
|
17095
17620
|
common.Injectable()
|
|
17096
17621
|
], exports.NoOpEmailProvider);
|
|
17097
17622
|
|
|
@@ -17105,7 +17630,7 @@ var SystemApiKeyClock = class {
|
|
|
17105
17630
|
return /* @__PURE__ */ new Date();
|
|
17106
17631
|
}
|
|
17107
17632
|
};
|
|
17108
|
-
function
|
|
17633
|
+
function _ts_decorate72(decorators, target, key, desc) {
|
|
17109
17634
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
17110
17635
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
17111
17636
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -17118,19 +17643,19 @@ function _ts_decorate67(decorators, target, key, desc) {
|
|
|
17118
17643
|
}
|
|
17119
17644
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
17120
17645
|
}
|
|
17121
|
-
__name(
|
|
17122
|
-
function
|
|
17646
|
+
__name(_ts_decorate72, "_ts_decorate");
|
|
17647
|
+
function _ts_metadata68(metadataKey, metadataValue) {
|
|
17123
17648
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
17124
17649
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
17125
17650
|
}
|
|
17126
17651
|
}
|
|
17127
|
-
__name(
|
|
17128
|
-
function
|
|
17652
|
+
__name(_ts_metadata68, "_ts_metadata");
|
|
17653
|
+
function _ts_param45(paramIndex, decorator) {
|
|
17129
17654
|
return function(target, key) {
|
|
17130
17655
|
decorator(target, key, paramIndex);
|
|
17131
17656
|
};
|
|
17132
17657
|
}
|
|
17133
|
-
__name(
|
|
17658
|
+
__name(_ts_param45, "_ts_param");
|
|
17134
17659
|
var ApiKeyScopeAuditService = class {
|
|
17135
17660
|
static {
|
|
17136
17661
|
__name(this, "ApiKeyScopeAuditService");
|
|
@@ -17173,21 +17698,21 @@ var ApiKeyScopeAuditService = class {
|
|
|
17173
17698
|
}
|
|
17174
17699
|
}
|
|
17175
17700
|
};
|
|
17176
|
-
ApiKeyScopeAuditService =
|
|
17701
|
+
ApiKeyScopeAuditService = _ts_decorate72([
|
|
17177
17702
|
common.Injectable(),
|
|
17178
|
-
|
|
17179
|
-
|
|
17180
|
-
|
|
17181
|
-
|
|
17182
|
-
|
|
17183
|
-
|
|
17703
|
+
_ts_param45(0, common.Inject(core.DiscoveryService)),
|
|
17704
|
+
_ts_param45(1, common.Inject(core.MetadataScanner)),
|
|
17705
|
+
_ts_param45(2, common.Inject(core.Reflector)),
|
|
17706
|
+
_ts_param45(3, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
17707
|
+
_ts_metadata68("design:type", Function),
|
|
17708
|
+
_ts_metadata68("design:paramtypes", [
|
|
17184
17709
|
typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
|
|
17185
17710
|
typeof core.MetadataScanner === "undefined" ? Object : core.MetadataScanner,
|
|
17186
17711
|
typeof core.Reflector === "undefined" ? Object : core.Reflector,
|
|
17187
17712
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
|
|
17188
17713
|
])
|
|
17189
17714
|
], ApiKeyScopeAuditService);
|
|
17190
|
-
function
|
|
17715
|
+
function _ts_decorate73(decorators, target, key, desc) {
|
|
17191
17716
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
17192
17717
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
17193
17718
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -17200,19 +17725,19 @@ function _ts_decorate68(decorators, target, key, desc) {
|
|
|
17200
17725
|
}
|
|
17201
17726
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
17202
17727
|
}
|
|
17203
|
-
__name(
|
|
17204
|
-
function
|
|
17728
|
+
__name(_ts_decorate73, "_ts_decorate");
|
|
17729
|
+
function _ts_metadata69(metadataKey, metadataValue) {
|
|
17205
17730
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
17206
17731
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
17207
17732
|
}
|
|
17208
17733
|
}
|
|
17209
|
-
__name(
|
|
17210
|
-
function
|
|
17734
|
+
__name(_ts_metadata69, "_ts_metadata");
|
|
17735
|
+
function _ts_param46(paramIndex, decorator) {
|
|
17211
17736
|
return function(target, key) {
|
|
17212
17737
|
decorator(target, key, paramIndex);
|
|
17213
17738
|
};
|
|
17214
17739
|
}
|
|
17215
|
-
__name(
|
|
17740
|
+
__name(_ts_param46, "_ts_param");
|
|
17216
17741
|
var API_KEY_MAX_LABEL_LENGTH = 128;
|
|
17217
17742
|
var API_KEY_MAX_OVERLAP_SECONDS = 2592e3;
|
|
17218
17743
|
var CONTROL_CHARACTERS = /[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/u;
|
|
@@ -17273,6 +17798,11 @@ exports.ApiKeyService = class ApiKeyService {
|
|
|
17273
17798
|
* The new key is issued first and the old one retired second, so a failure between the two
|
|
17274
17799
|
* leaves both valid — the safe direction — rather than neither.
|
|
17275
17800
|
*
|
|
17801
|
+
* With an overlap the old key's deadline is lowered through the repository's optional
|
|
17802
|
+
* `limitExpiry`, an atomic minimum, so concurrent rotations of one key cannot push a shorter
|
|
17803
|
+
* deadline back. A repository without it gets a read followed by `setExpiry`, which two
|
|
17804
|
+
* rotations of the same key can interleave; such a host must serialize rotation per key.
|
|
17805
|
+
*
|
|
17276
17806
|
* @param id - The active key to replace.
|
|
17277
17807
|
* @param input - The overlap and an optional expiry for the new key.
|
|
17278
17808
|
* @returns The new key, plaintext once.
|
|
@@ -17302,11 +17832,15 @@ exports.ApiKeyService = class ApiKeyService {
|
|
|
17302
17832
|
await this.repository.markRevoked(old.id, now);
|
|
17303
17833
|
} else {
|
|
17304
17834
|
const retireAt = new Date(now.getTime() + overlap * 1e3);
|
|
17305
|
-
|
|
17306
|
-
|
|
17307
|
-
|
|
17308
|
-
|
|
17309
|
-
|
|
17835
|
+
if (this.repository.limitExpiry !== void 0) {
|
|
17836
|
+
await this.repository.limitExpiry(old.id, retireAt);
|
|
17837
|
+
} else {
|
|
17838
|
+
const sooner = (
|
|
17839
|
+
// Stryker disable next-line EqualityOperator: at equal instants both arms yield a Date of the same time, so `<` and `<=` store the same expiry
|
|
17840
|
+
old.expiresAt !== null && old.expiresAt.getTime() < retireAt.getTime() ? old.expiresAt : retireAt
|
|
17841
|
+
);
|
|
17842
|
+
await this.repository.setExpiry(old.id, sooner);
|
|
17843
|
+
}
|
|
17310
17844
|
}
|
|
17311
17845
|
return issued;
|
|
17312
17846
|
}
|
|
@@ -17341,13 +17875,13 @@ exports.ApiKeyService = class ApiKeyService {
|
|
|
17341
17875
|
return value;
|
|
17342
17876
|
}
|
|
17343
17877
|
};
|
|
17344
|
-
exports.ApiKeyService =
|
|
17878
|
+
exports.ApiKeyService = _ts_decorate73([
|
|
17345
17879
|
common.Injectable(),
|
|
17346
|
-
|
|
17347
|
-
|
|
17348
|
-
|
|
17349
|
-
|
|
17350
|
-
|
|
17880
|
+
_ts_param46(0, common.Inject(BYMAX_AUTH_API_KEY_REPOSITORY)),
|
|
17881
|
+
_ts_param46(1, common.Inject(BYMAX_AUTH_API_KEY_CLOCK)),
|
|
17882
|
+
_ts_param46(2, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
17883
|
+
_ts_metadata69("design:type", Function),
|
|
17884
|
+
_ts_metadata69("design:paramtypes", [
|
|
17351
17885
|
typeof IApiKeyRepository === "undefined" ? Object : IApiKeyRepository,
|
|
17352
17886
|
typeof ApiKeyClock === "undefined" ? Object : ApiKeyClock,
|
|
17353
17887
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
|
|
@@ -17429,7 +17963,7 @@ async function assertTenantBinding(options, handshake, tenantId) {
|
|
|
17429
17963
|
__name(assertTenantBinding, "assertTenantBinding");
|
|
17430
17964
|
|
|
17431
17965
|
// src/server/services/auth-token-verifier.service.ts
|
|
17432
|
-
function
|
|
17966
|
+
function _ts_decorate74(decorators, target, key, desc) {
|
|
17433
17967
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
17434
17968
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
17435
17969
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -17442,19 +17976,19 @@ function _ts_decorate69(decorators, target, key, desc) {
|
|
|
17442
17976
|
}
|
|
17443
17977
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
17444
17978
|
}
|
|
17445
|
-
__name(
|
|
17446
|
-
function
|
|
17979
|
+
__name(_ts_decorate74, "_ts_decorate");
|
|
17980
|
+
function _ts_metadata70(metadataKey, metadataValue) {
|
|
17447
17981
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
17448
17982
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
17449
17983
|
}
|
|
17450
17984
|
}
|
|
17451
|
-
__name(
|
|
17452
|
-
function
|
|
17985
|
+
__name(_ts_metadata70, "_ts_metadata");
|
|
17986
|
+
function _ts_param47(paramIndex, decorator) {
|
|
17453
17987
|
return function(target, key) {
|
|
17454
17988
|
decorator(target, key, paramIndex);
|
|
17455
17989
|
};
|
|
17456
17990
|
}
|
|
17457
|
-
__name(
|
|
17991
|
+
__name(_ts_param47, "_ts_param");
|
|
17458
17992
|
exports.AuthTokenVerifierService = class _AuthTokenVerifierService {
|
|
17459
17993
|
static {
|
|
17460
17994
|
__name(this, "AuthTokenVerifierService");
|
|
@@ -17638,14 +18172,14 @@ exports.AuthTokenVerifierService = class _AuthTokenVerifierService {
|
|
|
17638
18172
|
}
|
|
17639
18173
|
}
|
|
17640
18174
|
};
|
|
17641
|
-
exports.AuthTokenVerifierService =
|
|
18175
|
+
exports.AuthTokenVerifierService = _ts_decorate74([
|
|
17642
18176
|
common.Injectable(),
|
|
17643
|
-
|
|
17644
|
-
|
|
17645
|
-
|
|
17646
|
-
|
|
17647
|
-
|
|
17648
|
-
|
|
18177
|
+
_ts_param47(0, common.Inject(jwt.JwtService)),
|
|
18178
|
+
_ts_param47(1, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
18179
|
+
_ts_param47(2, common.Inject(exports.AuthRevocationService)),
|
|
18180
|
+
_ts_param47(3, common.Inject(exports.AccountStatusService)),
|
|
18181
|
+
_ts_metadata70("design:type", Function),
|
|
18182
|
+
_ts_metadata70("design:paramtypes", [
|
|
17649
18183
|
typeof jwt.JwtService === "undefined" ? Object : jwt.JwtService,
|
|
17650
18184
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
|
|
17651
18185
|
typeof exports.AuthRevocationService === "undefined" ? Object : exports.AuthRevocationService,
|
|
@@ -17654,7 +18188,7 @@ exports.AuthTokenVerifierService = _ts_decorate69([
|
|
|
17654
18188
|
], exports.AuthTokenVerifierService);
|
|
17655
18189
|
|
|
17656
18190
|
// src/server/bymax-auth.module.ts
|
|
17657
|
-
function
|
|
18191
|
+
function _ts_decorate75(decorators, target, key, desc) {
|
|
17658
18192
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
17659
18193
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
17660
18194
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -17667,7 +18201,7 @@ function _ts_decorate70(decorators, target, key, desc) {
|
|
|
17667
18201
|
}
|
|
17668
18202
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
17669
18203
|
}
|
|
17670
|
-
__name(
|
|
18204
|
+
__name(_ts_decorate75, "_ts_decorate");
|
|
17671
18205
|
function hasProviderToken(providers, token) {
|
|
17672
18206
|
return providers.some((p) => {
|
|
17673
18207
|
if (typeof p === "function") return false;
|
|
@@ -17918,6 +18452,13 @@ exports.BymaxAuthModule = class _BymaxAuthModule {
|
|
|
17918
18452
|
exports.TokenDeliveryService,
|
|
17919
18453
|
exports.WsTicketService,
|
|
17920
18454
|
exports.BruteForceService,
|
|
18455
|
+
// Registered unconditionally: it depends only on services that are always present, and
|
|
18456
|
+
// it is the one place a caller re-proves the password before a sensitive change.
|
|
18457
|
+
MfaFlowLockoutService,
|
|
18458
|
+
MfaRecordService,
|
|
18459
|
+
MfaChallengeService,
|
|
18460
|
+
MfaManagementService,
|
|
18461
|
+
exports.ReauthenticationService,
|
|
17921
18462
|
exports.OtpService,
|
|
17922
18463
|
// SessionService is always registered (not gated on includeSessions) because
|
|
17923
18464
|
// AuthService.login() and AuthService.refresh() call session methods. Registering
|
|
@@ -17971,6 +18512,9 @@ exports.BymaxAuthModule = class _BymaxAuthModule {
|
|
|
17971
18512
|
// Host-app modules that extend the auth flow (e.g. custom logout logic) can
|
|
17972
18513
|
// inject SessionService without re-registering it.
|
|
17973
18514
|
exports.SessionService,
|
|
18515
|
+
// Export ReauthenticationService so a host module can guard its own destructive routes
|
|
18516
|
+
// with the same password check and lockout counter the library uses.
|
|
18517
|
+
exports.ReauthenticationService,
|
|
17974
18518
|
// Export MFA components when enabled — allows host-app modules to inject
|
|
17975
18519
|
// MfaService and apply MfaRequiredGuard without re-registering them.
|
|
17976
18520
|
// Spreads mfaProviders directly so providers and exports always stay in sync.
|
|
@@ -18059,7 +18603,7 @@ exports.BymaxAuthModule = class _BymaxAuthModule {
|
|
|
18059
18603
|
};
|
|
18060
18604
|
}
|
|
18061
18605
|
};
|
|
18062
|
-
exports.BymaxAuthModule =
|
|
18606
|
+
exports.BymaxAuthModule = _ts_decorate75([
|
|
18063
18607
|
common.Module({})
|
|
18064
18608
|
], exports.BymaxAuthModule);
|
|
18065
18609
|
|
|
@@ -18387,7 +18931,7 @@ var DefaultAuthEmailProvider = class _DefaultAuthEmailProvider {
|
|
|
18387
18931
|
}
|
|
18388
18932
|
}
|
|
18389
18933
|
};
|
|
18390
|
-
function
|
|
18934
|
+
function _ts_decorate76(decorators, target, key, desc) {
|
|
18391
18935
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
18392
18936
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
18393
18937
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -18400,13 +18944,13 @@ function _ts_decorate71(decorators, target, key, desc) {
|
|
|
18400
18944
|
}
|
|
18401
18945
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18402
18946
|
}
|
|
18403
|
-
__name(
|
|
18404
|
-
function
|
|
18947
|
+
__name(_ts_decorate76, "_ts_decorate");
|
|
18948
|
+
function _ts_metadata71(metadataKey, metadataValue) {
|
|
18405
18949
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
18406
18950
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
18407
18951
|
}
|
|
18408
18952
|
}
|
|
18409
|
-
__name(
|
|
18953
|
+
__name(_ts_metadata71, "_ts_metadata");
|
|
18410
18954
|
var HIBP_RANGE_URL = "https://api.pwnedpasswords.com/range/";
|
|
18411
18955
|
var PREFIX_LENGTH = 5;
|
|
18412
18956
|
var DEFAULT_TIMEOUT_MS = 1500;
|
|
@@ -18463,10 +19007,10 @@ exports.HibpBreachChecker = class _HibpBreachChecker {
|
|
|
18463
19007
|
}
|
|
18464
19008
|
}
|
|
18465
19009
|
};
|
|
18466
|
-
exports.HibpBreachChecker =
|
|
19010
|
+
exports.HibpBreachChecker = _ts_decorate76([
|
|
18467
19011
|
common.Injectable(),
|
|
18468
|
-
|
|
18469
|
-
|
|
19012
|
+
_ts_metadata71("design:type", Function),
|
|
19013
|
+
_ts_metadata71("design:paramtypes", [
|
|
18470
19014
|
Number
|
|
18471
19015
|
])
|
|
18472
19016
|
], exports.HibpBreachChecker);
|
|
@@ -18479,10 +19023,10 @@ exports.AllowAllBreachChecker = class AllowAllBreachChecker {
|
|
|
18479
19023
|
return false;
|
|
18480
19024
|
}
|
|
18481
19025
|
};
|
|
18482
|
-
exports.AllowAllBreachChecker =
|
|
19026
|
+
exports.AllowAllBreachChecker = _ts_decorate76([
|
|
18483
19027
|
common.Injectable()
|
|
18484
19028
|
], exports.AllowAllBreachChecker);
|
|
18485
|
-
function
|
|
19029
|
+
function _ts_decorate77(decorators, target, key, desc) {
|
|
18486
19030
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
18487
19031
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
18488
19032
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -18495,7 +19039,7 @@ function _ts_decorate72(decorators, target, key, desc) {
|
|
|
18495
19039
|
}
|
|
18496
19040
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18497
19041
|
}
|
|
18498
|
-
__name(
|
|
19042
|
+
__name(_ts_decorate77, "_ts_decorate");
|
|
18499
19043
|
exports.OptionalAuthGuard = class OptionalAuthGuard extends exports.JwtAuthGuard {
|
|
18500
19044
|
static {
|
|
18501
19045
|
__name(this, "OptionalAuthGuard");
|
|
@@ -18510,10 +19054,10 @@ exports.OptionalAuthGuard = class OptionalAuthGuard extends exports.JwtAuthGuard
|
|
|
18510
19054
|
return super.canActivate(context);
|
|
18511
19055
|
}
|
|
18512
19056
|
};
|
|
18513
|
-
exports.OptionalAuthGuard =
|
|
19057
|
+
exports.OptionalAuthGuard = _ts_decorate77([
|
|
18514
19058
|
common.Injectable()
|
|
18515
19059
|
], exports.OptionalAuthGuard);
|
|
18516
|
-
function
|
|
19060
|
+
function _ts_decorate78(decorators, target, key, desc) {
|
|
18517
19061
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
18518
19062
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
18519
19063
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -18526,19 +19070,19 @@ function _ts_decorate73(decorators, target, key, desc) {
|
|
|
18526
19070
|
}
|
|
18527
19071
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18528
19072
|
}
|
|
18529
|
-
__name(
|
|
18530
|
-
function
|
|
19073
|
+
__name(_ts_decorate78, "_ts_decorate");
|
|
19074
|
+
function _ts_metadata72(metadataKey, metadataValue) {
|
|
18531
19075
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
18532
19076
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
18533
19077
|
}
|
|
18534
19078
|
}
|
|
18535
|
-
__name(
|
|
18536
|
-
function
|
|
19079
|
+
__name(_ts_metadata72, "_ts_metadata");
|
|
19080
|
+
function _ts_param48(paramIndex, decorator) {
|
|
18537
19081
|
return function(target, key) {
|
|
18538
19082
|
decorator(target, key, paramIndex);
|
|
18539
19083
|
};
|
|
18540
19084
|
}
|
|
18541
|
-
__name(
|
|
19085
|
+
__name(_ts_param48, "_ts_param");
|
|
18542
19086
|
exports.SelfOrAdminGuard = class SelfOrAdminGuard {
|
|
18543
19087
|
static {
|
|
18544
19088
|
__name(this, "SelfOrAdminGuard");
|
|
@@ -18574,11 +19118,11 @@ exports.SelfOrAdminGuard = class SelfOrAdminGuard {
|
|
|
18574
19118
|
throw new AuthException(AUTH_ERROR_CODES.INSUFFICIENT_ROLE);
|
|
18575
19119
|
}
|
|
18576
19120
|
};
|
|
18577
|
-
exports.SelfOrAdminGuard =
|
|
19121
|
+
exports.SelfOrAdminGuard = _ts_decorate78([
|
|
18578
19122
|
common.Injectable(),
|
|
18579
|
-
|
|
18580
|
-
|
|
18581
|
-
|
|
19123
|
+
_ts_param48(0, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
19124
|
+
_ts_metadata72("design:type", Function),
|
|
19125
|
+
_ts_metadata72("design:paramtypes", [
|
|
18582
19126
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
|
|
18583
19127
|
])
|
|
18584
19128
|
], exports.SelfOrAdminGuard);
|
|
@@ -18600,7 +19144,7 @@ function isHexLooking(value) {
|
|
|
18600
19144
|
return value.length === 64 && /^[a-fA-F0-9]{64}$/.test(value);
|
|
18601
19145
|
}
|
|
18602
19146
|
__name(isHexLooking, "isHexLooking");
|
|
18603
|
-
function
|
|
19147
|
+
function _ts_decorate79(decorators, target, key, desc) {
|
|
18604
19148
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
18605
19149
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
18606
19150
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -18613,19 +19157,19 @@ function _ts_decorate74(decorators, target, key, desc) {
|
|
|
18613
19157
|
}
|
|
18614
19158
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18615
19159
|
}
|
|
18616
|
-
__name(
|
|
18617
|
-
function
|
|
19160
|
+
__name(_ts_decorate79, "_ts_decorate");
|
|
19161
|
+
function _ts_metadata73(metadataKey, metadataValue) {
|
|
18618
19162
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
18619
19163
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
18620
19164
|
}
|
|
18621
19165
|
}
|
|
18622
|
-
__name(
|
|
18623
|
-
function
|
|
19166
|
+
__name(_ts_metadata73, "_ts_metadata");
|
|
19167
|
+
function _ts_param49(paramIndex, decorator) {
|
|
18624
19168
|
return function(target, key) {
|
|
18625
19169
|
decorator(target, key, paramIndex);
|
|
18626
19170
|
};
|
|
18627
19171
|
}
|
|
18628
|
-
__name(
|
|
19172
|
+
__name(_ts_param49, "_ts_param");
|
|
18629
19173
|
exports.WsJwtGuard = class WsJwtGuard {
|
|
18630
19174
|
static {
|
|
18631
19175
|
__name(this, "WsJwtGuard");
|
|
@@ -18689,14 +19233,14 @@ exports.WsJwtGuard = class WsJwtGuard {
|
|
|
18689
19233
|
return true;
|
|
18690
19234
|
}
|
|
18691
19235
|
};
|
|
18692
|
-
exports.WsJwtGuard =
|
|
19236
|
+
exports.WsJwtGuard = _ts_decorate79([
|
|
18693
19237
|
common.Injectable(),
|
|
18694
|
-
|
|
18695
|
-
|
|
18696
|
-
|
|
18697
|
-
|
|
18698
|
-
|
|
18699
|
-
|
|
19238
|
+
_ts_param49(0, common.Inject(jwt.JwtService)),
|
|
19239
|
+
_ts_param49(1, common.Inject(exports.AuthRevocationService)),
|
|
19240
|
+
_ts_param49(2, common.Inject(exports.WsTicketService)),
|
|
19241
|
+
_ts_param49(3, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
19242
|
+
_ts_metadata73("design:type", Function),
|
|
19243
|
+
_ts_metadata73("design:paramtypes", [
|
|
18700
19244
|
typeof jwt.JwtService === "undefined" ? Object : jwt.JwtService,
|
|
18701
19245
|
typeof exports.AuthRevocationService === "undefined" ? Object : exports.AuthRevocationService,
|
|
18702
19246
|
typeof exports.WsTicketService === "undefined" ? Object : exports.WsTicketService,
|
|
@@ -18736,7 +19280,7 @@ function bindingInput(handshake) {
|
|
|
18736
19280
|
};
|
|
18737
19281
|
}
|
|
18738
19282
|
__name(bindingInput, "bindingInput");
|
|
18739
|
-
function
|
|
19283
|
+
function _ts_decorate80(decorators, target, key, desc) {
|
|
18740
19284
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
18741
19285
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
18742
19286
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -18749,7 +19293,7 @@ function _ts_decorate75(decorators, target, key, desc) {
|
|
|
18749
19293
|
}
|
|
18750
19294
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18751
19295
|
}
|
|
18752
|
-
__name(
|
|
19296
|
+
__name(_ts_decorate80, "_ts_decorate");
|
|
18753
19297
|
function isAuthEnvelope(body) {
|
|
18754
19298
|
if (typeof body !== "object" || body === null) return false;
|
|
18755
19299
|
const error = body.error;
|
|
@@ -18868,10 +19412,10 @@ exports.AuthExceptionFilter = class _AuthExceptionFilter {
|
|
|
18868
19412
|
});
|
|
18869
19413
|
}
|
|
18870
19414
|
};
|
|
18871
|
-
exports.AuthExceptionFilter =
|
|
19415
|
+
exports.AuthExceptionFilter = _ts_decorate80([
|
|
18872
19416
|
common.Catch()
|
|
18873
19417
|
], exports.AuthExceptionFilter);
|
|
18874
|
-
function
|
|
19418
|
+
function _ts_decorate81(decorators, target, key, desc) {
|
|
18875
19419
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
18876
19420
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
18877
19421
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -18884,7 +19428,7 @@ function _ts_decorate76(decorators, target, key, desc) {
|
|
|
18884
19428
|
}
|
|
18885
19429
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18886
19430
|
}
|
|
18887
|
-
__name(
|
|
19431
|
+
__name(_ts_decorate81, "_ts_decorate");
|
|
18888
19432
|
function isEmittingClient(client) {
|
|
18889
19433
|
return typeof client?.emit === "function";
|
|
18890
19434
|
}
|
|
@@ -18928,7 +19472,7 @@ exports.WsAuthExceptionFilter = class _WsAuthExceptionFilter {
|
|
|
18928
19472
|
this.logger.error(`refused a request on a client this filter cannot answer: ${describeChannelStatus(exception)}`);
|
|
18929
19473
|
}
|
|
18930
19474
|
};
|
|
18931
|
-
exports.WsAuthExceptionFilter =
|
|
19475
|
+
exports.WsAuthExceptionFilter = _ts_decorate81([
|
|
18932
19476
|
common.Catch(AuthException)
|
|
18933
19477
|
], exports.WsAuthExceptionFilter);
|
|
18934
19478
|
var ServiceKey = /* @__PURE__ */ __name((...scopes) => common.applyDecorators(common.SetMetadata(IS_PUBLIC_KEY, true), ApiKeyScopes(...scopes), common.UseGuards(exports.ApiKeyGuard)), "ServiceKey");
|