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