@bymax-one/nest-auth 1.5.1 → 1.5.3
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 +178 -1
- package/README.md +225 -1115
- package/dist/nextjs/index.cjs +30 -9
- package/dist/nextjs/index.d.cts +58 -6
- package/dist/nextjs/index.d.ts +58 -6
- package/dist/nextjs/index.mjs +30 -9
- package/dist/server/index.cjs +590 -234
- package/dist/server/index.d.cts +1311 -1153
- package/dist/server/index.d.ts +1311 -1153
- package/dist/server/index.mjs +579 -235
- package/package.json +1 -1
package/dist/server/index.cjs
CHANGED
|
@@ -194,12 +194,13 @@ function shannonEntropy(value) {
|
|
|
194
194
|
}, 0);
|
|
195
195
|
}
|
|
196
196
|
__name(shannonEntropy, "shannonEntropy");
|
|
197
|
+
var AUTH_SECRET_MIN_LENGTH = 32;
|
|
197
198
|
function validateSecretStrength(secret, name) {
|
|
198
199
|
if (!secret) {
|
|
199
200
|
throw new Error(`[BymaxAuthModule] ${name} is required and must not be empty. Generate a secure secret with: node -e "console.log(require('node:crypto').randomBytes(32).toString('base64'))"`);
|
|
200
201
|
}
|
|
201
|
-
if (secret.length <
|
|
202
|
-
throw new Error(`[BymaxAuthModule] ${name} must be at least
|
|
202
|
+
if (secret.length < AUTH_SECRET_MIN_LENGTH) {
|
|
203
|
+
throw new Error(`[BymaxAuthModule] ${name} must be at least ${AUTH_SECRET_MIN_LENGTH} characters long. Generate a secure secret with: node -e "console.log(require('node:crypto').randomBytes(32).toString('base64'))"`);
|
|
203
204
|
}
|
|
204
205
|
const entropy = shannonEntropy(secret);
|
|
205
206
|
if (entropy < 3.5) {
|
|
@@ -367,6 +368,112 @@ __name(durationToSeconds, "durationToSeconds");
|
|
|
367
368
|
// src/server/constants/workspace-roles.ts
|
|
368
369
|
var ANY_WORKSPACE_MEMBER = /* @__PURE__ */ Symbol("ANY_WORKSPACE_MEMBER");
|
|
369
370
|
|
|
371
|
+
// src/server/utils/workspace-cursor.ts
|
|
372
|
+
var WORKSPACE_CURSOR_MAX_LENGTH = 4096;
|
|
373
|
+
var WORKSPACE_CURSOR_PART_MAX_LENGTH = 128;
|
|
374
|
+
var WORKSPACE_OWNER_ROLE_MAX_LENGTH = 32;
|
|
375
|
+
var INSTANT_LENGTH = 24;
|
|
376
|
+
var UNPAIRED_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;
|
|
377
|
+
function hasControlCharacter(text) {
|
|
378
|
+
for (const character of text) {
|
|
379
|
+
if (character <= "" || character >= "\x7F" && character <= "\x9F") return true;
|
|
380
|
+
}
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
__name(hasControlCharacter, "hasControlCharacter");
|
|
384
|
+
function isWorkspaceOwnerRole(role) {
|
|
385
|
+
const length = Array.from(role).length;
|
|
386
|
+
return length >= 1 && length <= WORKSPACE_OWNER_ROLE_MAX_LENGTH && !hasControlCharacter(role) && !UNPAIRED_SURROGATE.test(role);
|
|
387
|
+
}
|
|
388
|
+
__name(isWorkspaceOwnerRole, "isWorkspaceOwnerRole");
|
|
389
|
+
function workspaceQueryKey(...parts) {
|
|
390
|
+
return JSON.stringify(parts);
|
|
391
|
+
}
|
|
392
|
+
__name(workspaceQueryKey, "workspaceQueryKey");
|
|
393
|
+
function workspacePositionOf(at, id) {
|
|
394
|
+
return at.toISOString() + id;
|
|
395
|
+
}
|
|
396
|
+
__name(workspacePositionOf, "workspacePositionOf");
|
|
397
|
+
function readWorkspacePosition(position) {
|
|
398
|
+
const instant = position.slice(0, INSTANT_LENGTH);
|
|
399
|
+
const at = new Date(instant);
|
|
400
|
+
if (Number.isNaN(at.getTime()) || at.toISOString() !== instant) return void 0;
|
|
401
|
+
return {
|
|
402
|
+
at,
|
|
403
|
+
id: position.slice(INSTANT_LENGTH)
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
__name(readWorkspacePosition, "readWorkspacePosition");
|
|
407
|
+
function describeOverflow(query, position) {
|
|
408
|
+
const part = keyParts(query).find(({ length }) => length > WORKSPACE_CURSOR_PART_MAX_LENGTH);
|
|
409
|
+
if (part !== void 0) {
|
|
410
|
+
return `query key part ${part.index} is ${part.length} code points, over ${WORKSPACE_CURSOR_PART_MAX_LENGTH}`;
|
|
411
|
+
}
|
|
412
|
+
return `the query key is ${query.length} characters and the position ${position.length}`;
|
|
413
|
+
}
|
|
414
|
+
__name(describeOverflow, "describeOverflow");
|
|
415
|
+
function whyUnreadable(position) {
|
|
416
|
+
if (readWorkspacePosition(position) === void 0) {
|
|
417
|
+
return "it is not a canonical instant followed by an id";
|
|
418
|
+
}
|
|
419
|
+
const id = position.slice(INSTANT_LENGTH);
|
|
420
|
+
if (id === "") return "its id is empty";
|
|
421
|
+
const length = Array.from(id).length;
|
|
422
|
+
if (length > WORKSPACE_CURSOR_PART_MAX_LENGTH) {
|
|
423
|
+
return `position id is ${length} code points, over ${WORKSPACE_CURSOR_PART_MAX_LENGTH}`;
|
|
424
|
+
}
|
|
425
|
+
if (hasControlCharacter(id) || UNPAIRED_SURROGATE.test(id)) {
|
|
426
|
+
return "its id holds a control character or an unpaired surrogate";
|
|
427
|
+
}
|
|
428
|
+
return void 0;
|
|
429
|
+
}
|
|
430
|
+
__name(whyUnreadable, "whyUnreadable");
|
|
431
|
+
function keyParts(query) {
|
|
432
|
+
try {
|
|
433
|
+
const parsed = JSON.parse(query);
|
|
434
|
+
if (!Array.isArray(parsed)) return [];
|
|
435
|
+
return parsed.map((part, index) => ({
|
|
436
|
+
index: index + 1,
|
|
437
|
+
length: typeof part === "string" ? Array.from(part).length : 0
|
|
438
|
+
}));
|
|
439
|
+
} catch {
|
|
440
|
+
return [];
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
__name(keyParts, "keyParts");
|
|
444
|
+
function encodeWorkspaceCursor(query, position) {
|
|
445
|
+
const reason = whyUnreadable(position);
|
|
446
|
+
if (reason !== void 0) {
|
|
447
|
+
throw new RangeError(`workspace cursor position is refused because ${reason}: the decoder reads it as the first page, so the cursor could never be followed`);
|
|
448
|
+
}
|
|
449
|
+
const cursor = Buffer.from(JSON.stringify([
|
|
450
|
+
query,
|
|
451
|
+
position
|
|
452
|
+
])).toString("base64url");
|
|
453
|
+
if (cursor.length > WORKSPACE_CURSOR_MAX_LENGTH) {
|
|
454
|
+
throw new RangeError(`workspace cursor is ${cursor.length} characters, over the ${WORKSPACE_CURSOR_MAX_LENGTH} maximum: ${describeOverflow(query, position)}`);
|
|
455
|
+
}
|
|
456
|
+
return cursor;
|
|
457
|
+
}
|
|
458
|
+
__name(encodeWorkspaceCursor, "encodeWorkspaceCursor");
|
|
459
|
+
function decodeWorkspaceCursor(cursor, query) {
|
|
460
|
+
if (typeof cursor !== "string" || cursor.length > WORKSPACE_CURSOR_MAX_LENGTH) return void 0;
|
|
461
|
+
try {
|
|
462
|
+
const parsed = JSON.parse(Buffer.from(cursor, "base64url").toString("utf8"));
|
|
463
|
+
if (!Array.isArray(parsed) || parsed.length !== 2) return void 0;
|
|
464
|
+
const [issuedFor, position] = parsed;
|
|
465
|
+
if (issuedFor !== query || typeof position !== "string") return void 0;
|
|
466
|
+
if (whyUnreadable(position) !== void 0) return void 0;
|
|
467
|
+
return Buffer.from(JSON.stringify([
|
|
468
|
+
query,
|
|
469
|
+
position
|
|
470
|
+
])).toString("base64url") === cursor ? position : void 0;
|
|
471
|
+
} catch {
|
|
472
|
+
return void 0;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
__name(decodeWorkspaceCursor, "decodeWorkspaceCursor");
|
|
476
|
+
|
|
370
477
|
// src/server/config/workspace-options.ts
|
|
371
478
|
var WORKSPACE_INVITATION_MAX_TTL_SECONDS = 2592e3;
|
|
372
479
|
var WORKSPACE_MEMBERSHIP_CACHE_MAX_TTL_SECONDS = 3600;
|
|
@@ -392,6 +499,9 @@ function validateWorkspaceRoles(roles) {
|
|
|
392
499
|
if (typeof ownerRole !== "string" || !names.has(ownerRole)) {
|
|
393
500
|
throw new Error(`[BymaxAuthModule] workspaces.roles.ownerRole must be a role of the hierarchy.`);
|
|
394
501
|
}
|
|
502
|
+
if (!isWorkspaceOwnerRole(ownerRole)) {
|
|
503
|
+
throw new Error(`[BymaxAuthModule] workspaces.roles.ownerRole '${ownerRole}' must be 1 to ${WORKSPACE_OWNER_ROLE_MAX_LENGTH} code points of well-formed text with no control character (the role is part of a paging cursor).`);
|
|
504
|
+
}
|
|
395
505
|
for (const [role, included] of Object.entries(hierarchy)) {
|
|
396
506
|
if (role !== ownerRole && included.includes(ownerRole)) {
|
|
397
507
|
throw new Error(`[BymaxAuthModule] workspaces.roles.hierarchy: '${role}' must not include the owner role '${ownerRole}'. A role that includes the owner holds every owner permission.`);
|
|
@@ -459,6 +569,41 @@ function resolveRegistration(userOptions) {
|
|
|
459
569
|
return mode;
|
|
460
570
|
}
|
|
461
571
|
__name(resolveRegistration, "resolveRegistration");
|
|
572
|
+
function assertInvitationControllers(resolved, workspaceController, tenantController) {
|
|
573
|
+
const workspacesEnabled = resolved.workspaces !== void 0;
|
|
574
|
+
if (workspaceController && !workspacesEnabled) {
|
|
575
|
+
throw new Error("[BymaxAuthModule] controllers.workspaceInvitations: true requires workspaces.enabled: true and both workspace repository providers in extraProviders.");
|
|
576
|
+
}
|
|
577
|
+
if (resolved.registration !== "invitation-only") return;
|
|
578
|
+
const workspacePath = missingPieces([
|
|
579
|
+
[
|
|
580
|
+
"workspaces.enabled",
|
|
581
|
+
workspacesEnabled
|
|
582
|
+
],
|
|
583
|
+
[
|
|
584
|
+
"controllers.workspaceInvitations",
|
|
585
|
+
workspaceController
|
|
586
|
+
]
|
|
587
|
+
]);
|
|
588
|
+
const tenantPath = missingPieces([
|
|
589
|
+
[
|
|
590
|
+
"invitations.enabled",
|
|
591
|
+
resolved.invitations.enabled
|
|
592
|
+
],
|
|
593
|
+
[
|
|
594
|
+
"controllers.invitations",
|
|
595
|
+
tenantController
|
|
596
|
+
]
|
|
597
|
+
]);
|
|
598
|
+
if (workspacePath.length > 0 && tenantPath.length > 0) {
|
|
599
|
+
throw new Error(`[BymaxAuthModule] registration: 'invitation-only' leaves no way to create an account. Enable one invitation path: workspaces (missing: ${workspacePath.join(", ")}) or tenant invitations (missing: ${tenantPath.join(", ")}).`);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
__name(assertInvitationControllers, "assertInvitationControllers");
|
|
603
|
+
function missingPieces(pieces) {
|
|
604
|
+
return pieces.filter(([, on]) => !on).map(([name]) => name);
|
|
605
|
+
}
|
|
606
|
+
__name(missingPieces, "missingPieces");
|
|
462
607
|
function resolveWorkspaceOptions(userOptions) {
|
|
463
608
|
const group = userOptions.workspaces;
|
|
464
609
|
if (group?.enabled !== true) return void 0;
|
|
@@ -857,7 +1002,7 @@ function validatePreviousSecrets(jwt) {
|
|
|
857
1002
|
if (typeof secret !== "string") {
|
|
858
1003
|
throw new Error(`[BymaxAuthModule] jwt.previousSecrets[${index}] must be a string. Every entry still verifies tokens, so each is held to the same rules as jwt.secret.`);
|
|
859
1004
|
}
|
|
860
|
-
validateSecretStrength(secret,
|
|
1005
|
+
validateSecretStrength(secret, `jwt.previousSecrets[${index}]`);
|
|
861
1006
|
if (seen.has(secret)) {
|
|
862
1007
|
throw new Error(`[BymaxAuthModule] jwt.previousSecrets[${index}] repeats jwt.secret or an earlier entry. A retired secret equal to the current one means the rotation did not happen, and a configuration that reads as rotated while nothing changed is worse than one that never claimed to.`);
|
|
863
1008
|
}
|
|
@@ -8910,6 +9055,14 @@ _ts_decorate24([
|
|
|
8910
9055
|
classValidator.Length(64, 64),
|
|
8911
9056
|
_ts_metadata23("design:type", String)
|
|
8912
9057
|
], ConfirmEmailChangeDto.prototype, "token", void 0);
|
|
9058
|
+
|
|
9059
|
+
// src/server/constants/reproof-counter.ts
|
|
9060
|
+
function reproofCounterId(flow, userId, tenantId, hmacKey) {
|
|
9061
|
+
return hmacSha256(`reauth:${flow}:${userSubject("dashboard", userId, tenantId)}`, hmacKey);
|
|
9062
|
+
}
|
|
9063
|
+
__name(reproofCounterId, "reproofCounterId");
|
|
9064
|
+
|
|
9065
|
+
// src/server/services/email-change.service.ts
|
|
8913
9066
|
function _ts_decorate25(decorators, target, key, desc) {
|
|
8914
9067
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8915
9068
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -9006,7 +9159,7 @@ exports.EmailChangeService = class _EmailChangeService {
|
|
|
9006
9159
|
if (!user?.passwordHash) {
|
|
9007
9160
|
throw new AuthException(AUTH_ERROR_CODES.INVALID_CREDENTIALS);
|
|
9008
9161
|
}
|
|
9009
|
-
const bfIdentifier =
|
|
9162
|
+
const bfIdentifier = reproofCounterId("email-change", userId, tenantId, this.options.hmacKey);
|
|
9010
9163
|
if (await this.bruteForce.isLockedOut(bfIdentifier)) {
|
|
9011
9164
|
this.logger.warn(`requestChange: account locked userId=${logSafe(userId)}`);
|
|
9012
9165
|
throw new AuthException(AUTH_ERROR_CODES.ACCOUNT_LOCKED);
|
|
@@ -10455,52 +10608,26 @@ var MfaFlowLockoutService = class {
|
|
|
10455
10608
|
this.bruteForce = bruteForce;
|
|
10456
10609
|
}
|
|
10457
10610
|
/**
|
|
10458
|
-
* The
|
|
10459
|
-
*
|
|
10460
|
-
*
|
|
10461
|
-
*
|
|
10462
|
-
*
|
|
10463
|
-
* old pod counts a failure under `{flow}:{plane}:{userId}` while a new pod counts it under
|
|
10464
|
-
* `{flow}:{userSubject}`, and either alone leaves a hole: a lockout an old pod filled would not
|
|
10465
|
-
* stop a new pod, and a success on one would not clear the other. So every read consults both
|
|
10466
|
-
* and every write touches both, and the two move as one; the plane-only arm can be dropped once
|
|
10467
|
-
* no pod writes it. On the platform plane the two ids are identical, so the plane-only arm is
|
|
10468
|
-
* skipped: operating it would be the same key a second time, double-counting a failure and
|
|
10469
|
-
* locking a platform admin out at half the threshold. `{flow}` (`challenge` / `disable` /
|
|
10470
|
-
* `reauth`) keeps the three counters isolated from each other.
|
|
10611
|
+
* The brute-force identifier for one MFA flow: the flow and the account's length-prefixed subject,
|
|
10612
|
+
* which carries the tenant on the dashboard plane. Two tenants' user `1` therefore count under
|
|
10613
|
+
* different identifiers, so one tenant's failures can neither lock the other's account out nor be
|
|
10614
|
+
* cleared by it. `{flow}` (`challenge` / `disable` / `reauth`) keeps the three counters isolated
|
|
10615
|
+
* from each other.
|
|
10471
10616
|
*/
|
|
10472
|
-
|
|
10473
|
-
return {
|
|
10474
|
-
legacy: hmacSha256(`${flow}:${context}:${userId}`, this.options.hmacKey),
|
|
10475
|
-
scoped: hmacSha256(`${flow}:${userSubject(context, userId, tenantId)}`, this.options.hmacKey)
|
|
10476
|
-
};
|
|
10617
|
+
counterId(flow, context, userId, tenantId) {
|
|
10618
|
+
return hmacSha256(`${flow}:${userSubject(context, userId, tenantId)}`, this.options.hmacKey);
|
|
10477
10619
|
}
|
|
10478
|
-
/**
|
|
10479
|
-
* Locked out when EITHER the legacy or the tenant-scoped counter has reached the threshold, so
|
|
10480
|
-
* neither a lockout an old pod recorded nor one a new pod recorded can be bypassed mid-migration.
|
|
10481
|
-
*/
|
|
10620
|
+
/** Whether the account's counter for this flow has reached the lockout threshold. */
|
|
10482
10621
|
async isLockedOut(flow, context, userId, tenantId) {
|
|
10483
|
-
|
|
10484
|
-
if (await this.bruteForce.isLockedOut(scoped)) return true;
|
|
10485
|
-
return legacy !== scoped ? this.bruteForce.isLockedOut(legacy) : false;
|
|
10622
|
+
return this.bruteForce.isLockedOut(this.counterId(flow, context, userId, tenantId));
|
|
10486
10623
|
}
|
|
10487
|
-
/**
|
|
10488
|
-
* Records the failure under both counters so the budget an attacker spends is seen by old and
|
|
10489
|
-
* new code alike — but under the scoped id ONCE when the two coincide (platform plane).
|
|
10490
|
-
*/
|
|
10624
|
+
/** Records a failed attempt against the account's counter for this flow. */
|
|
10491
10625
|
async recordFailure(flow, context, userId, tenantId) {
|
|
10492
|
-
|
|
10493
|
-
await this.bruteForce.recordFailure(scoped);
|
|
10494
|
-
if (legacy !== scoped) await this.bruteForce.recordFailure(legacy);
|
|
10626
|
+
await this.bruteForce.recordFailure(this.counterId(flow, context, userId, tenantId));
|
|
10495
10627
|
}
|
|
10496
|
-
/**
|
|
10497
|
-
* Clears both counters on success — resetting only one would leave the other to lock a
|
|
10498
|
-
* legitimately authenticated user out on the next attempt — collapsing to one when they coincide.
|
|
10499
|
-
*/
|
|
10628
|
+
/** Clears the account's counter for this flow, on a success. */
|
|
10500
10629
|
async reset(flow, context, userId, tenantId) {
|
|
10501
|
-
|
|
10502
|
-
await this.bruteForce.resetFailures(scoped);
|
|
10503
|
-
if (legacy !== scoped) await this.bruteForce.resetFailures(legacy);
|
|
10630
|
+
await this.bruteForce.resetFailures(this.counterId(flow, context, userId, tenantId));
|
|
10504
10631
|
}
|
|
10505
10632
|
};
|
|
10506
10633
|
MfaFlowLockoutService = _ts_decorate37([
|
|
@@ -10757,19 +10884,9 @@ var MfaRecordService = class {
|
|
|
10757
10884
|
* @throws {@link AuthException} `MFA_STATE_CONFLICT` when another transition holds the lock.
|
|
10758
10885
|
*/
|
|
10759
10886
|
async transition(context, userId, tenantId, mutate) {
|
|
10760
|
-
const
|
|
10761
|
-
const legacyLockKey = `mfalock:${hmacSha256(`${context}:${userId}`, this.options.hmacKey)}`;
|
|
10762
|
-
const acquireLegacy = legacyLockKey !== scopedLockKey;
|
|
10887
|
+
const lockKey = `mfalock:${hmacSha256(userSubject(context, userId, tenantId), this.options.hmacKey)}`;
|
|
10763
10888
|
const lockToken = crypto.randomBytes(16).toString("hex");
|
|
10764
|
-
if (!await this.redis.setIfAbsent(
|
|
10765
|
-
throw new AuthException(AUTH_ERROR_CODES.MFA_STATE_CONFLICT);
|
|
10766
|
-
}
|
|
10767
|
-
if (acquireLegacy && !await this.redis.setIfAbsent(legacyLockKey, lockToken, MFA_TRANSITION_LOCK_TTL_SECONDS)) {
|
|
10768
|
-
await this.redis.eval(RELEASE_LOCK_LUA, [
|
|
10769
|
-
scopedLockKey
|
|
10770
|
-
], [
|
|
10771
|
-
lockToken
|
|
10772
|
-
]);
|
|
10889
|
+
if (!await this.redis.setIfAbsent(lockKey, lockToken, MFA_TRANSITION_LOCK_TTL_SECONDS)) {
|
|
10773
10890
|
throw new AuthException(AUTH_ERROR_CODES.MFA_STATE_CONFLICT);
|
|
10774
10891
|
}
|
|
10775
10892
|
try {
|
|
@@ -10794,17 +10911,10 @@ var MfaRecordService = class {
|
|
|
10794
10911
|
return true;
|
|
10795
10912
|
} finally {
|
|
10796
10913
|
await this.redis.eval(RELEASE_LOCK_LUA, [
|
|
10797
|
-
|
|
10914
|
+
lockKey
|
|
10798
10915
|
], [
|
|
10799
10916
|
lockToken
|
|
10800
10917
|
]);
|
|
10801
|
-
if (acquireLegacy) {
|
|
10802
|
-
await this.redis.eval(RELEASE_LOCK_LUA, [
|
|
10803
|
-
legacyLockKey
|
|
10804
|
-
], [
|
|
10805
|
-
lockToken
|
|
10806
|
-
]);
|
|
10807
|
-
}
|
|
10808
10918
|
}
|
|
10809
10919
|
}
|
|
10810
10920
|
/**
|
|
@@ -10846,21 +10956,13 @@ var MfaRecordService = class {
|
|
|
10846
10956
|
* both the subject and the code value prevents code disclosure in Redis and cross-user,
|
|
10847
10957
|
* cross-tenant and cross-plane replay alike.
|
|
10848
10958
|
*
|
|
10849
|
-
* A second marker under the plane-only preimage `{context}:{userId}:{code}` is written and
|
|
10850
|
-
* required alongside it; see the call site for why both must be fresh while pods of two
|
|
10851
|
-
* versions are live.
|
|
10852
|
-
*
|
|
10853
10959
|
* @returns `true` if the code is valid and has not been replayed, `false` otherwise.
|
|
10854
10960
|
*/
|
|
10855
10961
|
async verifyTotpWithAntiReplay(context, userId, secretBase32, code, window, tenantId) {
|
|
10856
10962
|
if (!verifyTotp(secretBase32, code, window)) return false;
|
|
10857
10963
|
const ttl = totpAntiReplayTtlSeconds(window);
|
|
10858
|
-
const
|
|
10859
|
-
|
|
10860
|
-
const scopedIsNew = await this.redis.setnx(scopedReplayKey, ttl);
|
|
10861
|
-
if (scopedReplayKey === legacyReplayKey) return scopedIsNew;
|
|
10862
|
-
const legacyIsNew = await this.redis.setnx(legacyReplayKey, ttl);
|
|
10863
|
-
return scopedIsNew && legacyIsNew;
|
|
10964
|
+
const replayKey = `tu:${hmacSha256(`${userSubject(context, userId, tenantId)}:${code}`, this.options.hmacKey)}`;
|
|
10965
|
+
return await this.redis.setnx(replayKey, ttl);
|
|
10864
10966
|
}
|
|
10865
10967
|
/**
|
|
10866
10968
|
* Fetches a user from the correct repository based on the MFA context, and refuses one whose
|
|
@@ -13285,7 +13387,7 @@ exports.PasswordResetService = class _PasswordResetService {
|
|
|
13285
13387
|
if (!user?.passwordHash) {
|
|
13286
13388
|
throw new AuthException(AUTH_ERROR_CODES.INVALID_CREDENTIALS);
|
|
13287
13389
|
}
|
|
13288
|
-
const bfIdentifier =
|
|
13390
|
+
const bfIdentifier = reproofCounterId("change-password", userId, tenantId, this.options.hmacKey);
|
|
13289
13391
|
if (await this.bruteForce.isLockedOut(bfIdentifier)) {
|
|
13290
13392
|
this.logger.warn(`changePassword: account locked userId=${logSafe(userId)}`);
|
|
13291
13393
|
throw new AuthException(AUTH_ERROR_CODES.ACCOUNT_LOCKED);
|
|
@@ -15170,7 +15272,8 @@ var WorkspacePageQueryDto = class {
|
|
|
15170
15272
|
/**
|
|
15171
15273
|
* The `nextCursor` of the previous page; absent for the first page.
|
|
15172
15274
|
*
|
|
15173
|
-
*
|
|
15275
|
+
* The length bound is the one the cursor codec reads, so a cursor the library issues is always one
|
|
15276
|
+
* this accepts, and an oversized value stays away from the repository.
|
|
15174
15277
|
*/
|
|
15175
15278
|
cursor;
|
|
15176
15279
|
/**
|
|
@@ -15184,7 +15287,7 @@ _ts_decorate62([
|
|
|
15184
15287
|
classValidator.IsOptional(),
|
|
15185
15288
|
classValidator.IsString(),
|
|
15186
15289
|
classValidator.IsNotEmpty(),
|
|
15187
|
-
classValidator.MaxLength(
|
|
15290
|
+
classValidator.MaxLength(WORKSPACE_CURSOR_MAX_LENGTH),
|
|
15188
15291
|
classValidator.Matches(NO_CONTROL_CHARACTERS, {
|
|
15189
15292
|
message: "cursor must not contain control characters"
|
|
15190
15293
|
}),
|
|
@@ -15254,8 +15357,8 @@ function membershipCacheKeyBase(tenantId, workspaceId, userId, hmacKey) {
|
|
|
15254
15357
|
__name(membershipCacheKeyBase, "membershipCacheKeyBase");
|
|
15255
15358
|
|
|
15256
15359
|
// src/server/utils/resolve-request-workspace.ts
|
|
15257
|
-
var
|
|
15258
|
-
var WORKSPACE_ID_RULE = `workspaceId must be 1 to ${
|
|
15360
|
+
var WORKSPACE_ID_MAX_LENGTH = 128;
|
|
15361
|
+
var WORKSPACE_ID_RULE = `workspaceId must be 1 to ${WORKSPACE_ID_MAX_LENGTH} code points, not blank, with no control characters`;
|
|
15259
15362
|
function invalidWorkspaceId(message) {
|
|
15260
15363
|
throw new AuthException(AUTH_ERROR_CODES.VALIDATION, [
|
|
15261
15364
|
{
|
|
@@ -15266,7 +15369,7 @@ function invalidWorkspaceId(message) {
|
|
|
15266
15369
|
}
|
|
15267
15370
|
__name(invalidWorkspaceId, "invalidWorkspaceId");
|
|
15268
15371
|
function assertWorkspaceId(value) {
|
|
15269
|
-
if (typeof value !== "string" || value.trim() === "" || exceedsCodePoints(value,
|
|
15372
|
+
if (typeof value !== "string" || value.trim() === "" || exceedsCodePoints(value, WORKSPACE_ID_MAX_LENGTH) || !NO_CONTROL_CHARACTERS.test(value)) {
|
|
15270
15373
|
return invalidWorkspaceId(WORKSPACE_ID_RULE);
|
|
15271
15374
|
}
|
|
15272
15375
|
return value;
|
|
@@ -17604,7 +17707,8 @@ exports.WorkspaceInvitationService = class WorkspaceInvitationService {
|
|
|
17604
17707
|
role: record.role,
|
|
17605
17708
|
inviteToken: token,
|
|
17606
17709
|
expiresAt: new Date(Date.parse(record.createdAt) + ttl * 1e3),
|
|
17607
|
-
accountExists
|
|
17710
|
+
accountExists,
|
|
17711
|
+
kind: record.kind
|
|
17608
17712
|
});
|
|
17609
17713
|
} catch (err) {
|
|
17610
17714
|
throw new Error(describeChannelStatus(err));
|
|
@@ -20175,6 +20279,32 @@ function isStoredOAuthState(value) {
|
|
|
20175
20279
|
}
|
|
20176
20280
|
__name(isStoredOAuthState, "isStoredOAuthState");
|
|
20177
20281
|
|
|
20282
|
+
// src/server/oauth/plugin-deadline.ts
|
|
20283
|
+
var OAUTH_PLUGIN_DEFAULT_TIMEOUT_MS = 1e4;
|
|
20284
|
+
var OAUTH_PLUGIN_MAX_TIMEOUT_MS = 12e4;
|
|
20285
|
+
function pluginDeadlineMs(plugin) {
|
|
20286
|
+
const { timeoutMs } = plugin;
|
|
20287
|
+
return typeof timeoutMs === "number" && Number.isInteger(timeoutMs) && timeoutMs >= 1 && timeoutMs <= OAUTH_PLUGIN_MAX_TIMEOUT_MS ? timeoutMs : OAUTH_PLUGIN_DEFAULT_TIMEOUT_MS;
|
|
20288
|
+
}
|
|
20289
|
+
__name(pluginDeadlineMs, "pluginDeadlineMs");
|
|
20290
|
+
async function withDeadline(work, ms) {
|
|
20291
|
+
let timer;
|
|
20292
|
+
const expiry = new Promise((_resolve, reject) => {
|
|
20293
|
+
timer = setTimeout(() => {
|
|
20294
|
+
reject(new Error(`the plugin did not answer within ${ms} ms`));
|
|
20295
|
+
}, ms);
|
|
20296
|
+
});
|
|
20297
|
+
try {
|
|
20298
|
+
return await Promise.race([
|
|
20299
|
+
work(),
|
|
20300
|
+
expiry
|
|
20301
|
+
]);
|
|
20302
|
+
} finally {
|
|
20303
|
+
clearTimeout(timer);
|
|
20304
|
+
}
|
|
20305
|
+
}
|
|
20306
|
+
__name(withDeadline, "withDeadline");
|
|
20307
|
+
|
|
20178
20308
|
// src/server/constants/oauth-state-cookie.ts
|
|
20179
20309
|
var OAUTH_STATE_COOKIE_NAME = "oauth_state";
|
|
20180
20310
|
var OAUTH_STATE_COOKIE_SAME_SITE = "lax";
|
|
@@ -20537,12 +20667,15 @@ exports.OAuthService = class _OAuthService {
|
|
|
20537
20667
|
* @param code - The authorization code.
|
|
20538
20668
|
* @param codeVerifier - The PKCE verifier stored with the state.
|
|
20539
20669
|
* @returns The normalized profile.
|
|
20540
|
-
* @throws `AuthException(OAUTH_FAILED)` when the exchange or the fetch fails
|
|
20670
|
+
* @throws `AuthException(OAUTH_FAILED)` when the exchange or the fetch fails, or the plugin's
|
|
20671
|
+
* deadline passes first.
|
|
20541
20672
|
*/
|
|
20542
20673
|
async fetchProfile(plugin, provider, code, codeVerifier) {
|
|
20543
20674
|
try {
|
|
20544
|
-
|
|
20545
|
-
|
|
20675
|
+
return await withDeadline(async () => {
|
|
20676
|
+
const tokenResponse = await plugin.exchangeCode(code, codeVerifier);
|
|
20677
|
+
return await plugin.fetchProfile(tokenResponse.access_token);
|
|
20678
|
+
}, pluginDeadlineMs(plugin));
|
|
20546
20679
|
} catch (err) {
|
|
20547
20680
|
this.logger.error(`OAuth plugin '${provider}' failed during code exchange or profile fetch: ` + describeChannelStatus(err));
|
|
20548
20681
|
throw new AuthException(AUTH_ERROR_CODES.OAUTH_FAILED);
|
|
@@ -21262,6 +21395,11 @@ var GoogleOAuthPlugin = class {
|
|
|
21262
21395
|
}
|
|
21263
21396
|
/** Stable provider identifier used as a route segment and storage key. */
|
|
21264
21397
|
name = "google";
|
|
21398
|
+
/**
|
|
21399
|
+
* The library's deadline for the two requests together: each is bounded at 10 s by its own abort
|
|
21400
|
+
* signal, so the pair is 20 s and the library never cuts in before the plugin's own bound.
|
|
21401
|
+
*/
|
|
21402
|
+
timeoutMs = 2e4;
|
|
21265
21403
|
clientId;
|
|
21266
21404
|
/** The Google client secret, withheld from serialization. */
|
|
21267
21405
|
#clientSecret;
|
|
@@ -22155,7 +22293,7 @@ var REQUEST_SCHEMAS = {
|
|
|
22155
22293
|
"cursor": {
|
|
22156
22294
|
"type": "string",
|
|
22157
22295
|
"pattern": "^[^\\u0000-\\u001F\\u007F-\\u009F]+$",
|
|
22158
|
-
"maxLength":
|
|
22296
|
+
"maxLength": 4096,
|
|
22159
22297
|
"minLength": 1
|
|
22160
22298
|
},
|
|
22161
22299
|
"limit": {
|
|
@@ -23101,6 +23239,164 @@ exports.NoOpEmailProvider = class _NoOpEmailProvider {
|
|
|
23101
23239
|
exports.NoOpEmailProvider = _ts_decorate97([
|
|
23102
23240
|
common.Injectable()
|
|
23103
23241
|
], exports.NoOpEmailProvider);
|
|
23242
|
+
function _ts_decorate98(decorators, target, key, desc) {
|
|
23243
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
23244
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
23245
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
23246
|
+
} else {
|
|
23247
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
23248
|
+
if (d = decorators[i]) {
|
|
23249
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
23250
|
+
}
|
|
23251
|
+
}
|
|
23252
|
+
}
|
|
23253
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23254
|
+
}
|
|
23255
|
+
__name(_ts_decorate98, "_ts_decorate");
|
|
23256
|
+
function _ts_metadata94(metadataKey, metadataValue) {
|
|
23257
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
23258
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
23259
|
+
}
|
|
23260
|
+
}
|
|
23261
|
+
__name(_ts_metadata94, "_ts_metadata");
|
|
23262
|
+
function _ts_param59(paramIndex, decorator) {
|
|
23263
|
+
return function(target, key) {
|
|
23264
|
+
decorator(target, key, paramIndex);
|
|
23265
|
+
};
|
|
23266
|
+
}
|
|
23267
|
+
__name(_ts_param59, "_ts_param");
|
|
23268
|
+
var STARTUP_PING_TIMEOUT_MS = 5e3;
|
|
23269
|
+
var STARTUP_PING_RETRY_MS = 250;
|
|
23270
|
+
var CONNECTING_STATES = [
|
|
23271
|
+
"connecting",
|
|
23272
|
+
"connect",
|
|
23273
|
+
"reconnecting"
|
|
23274
|
+
];
|
|
23275
|
+
function commandTimeoutOf(client) {
|
|
23276
|
+
const options = client.options;
|
|
23277
|
+
if (typeof options !== "object" || options === null) return void 0;
|
|
23278
|
+
const own = options.commandTimeout;
|
|
23279
|
+
const nested = options.redisOptions?.commandTimeout;
|
|
23280
|
+
const found = typeof own === "number" ? own : nested;
|
|
23281
|
+
return typeof found === "number" ? found : void 0;
|
|
23282
|
+
}
|
|
23283
|
+
__name(commandTimeoutOf, "commandTimeoutOf");
|
|
23284
|
+
function addressOf(client) {
|
|
23285
|
+
const options = client.options;
|
|
23286
|
+
if (options?.path != null || options?.sentinels != null) return void 0;
|
|
23287
|
+
const host = options?.host;
|
|
23288
|
+
const port = options?.port;
|
|
23289
|
+
if (typeof host !== "string" || typeof port !== "number") return void 0;
|
|
23290
|
+
if (!/^[A-Za-z0-9._:%-]+$/.test(host)) return void 0;
|
|
23291
|
+
return host.includes(":") ? `[${host}]:${port}` : `${host}:${port}`;
|
|
23292
|
+
}
|
|
23293
|
+
__name(addressOf, "addressOf");
|
|
23294
|
+
function pause(ms) {
|
|
23295
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
23296
|
+
}
|
|
23297
|
+
__name(pause, "pause");
|
|
23298
|
+
var RedisReadinessService = class _RedisReadinessService {
|
|
23299
|
+
static {
|
|
23300
|
+
__name(this, "RedisReadinessService");
|
|
23301
|
+
}
|
|
23302
|
+
redis;
|
|
23303
|
+
logger = new common.Logger(_RedisReadinessService.name);
|
|
23304
|
+
constructor(redis) {
|
|
23305
|
+
this.redis = redis;
|
|
23306
|
+
}
|
|
23307
|
+
/**
|
|
23308
|
+
* Waits for a client that is on its way to `ready`, and refuses one that has ended. A client in
|
|
23309
|
+
* any other state is left to the command, which is what starts a lazy connection.
|
|
23310
|
+
*
|
|
23311
|
+
* @param timeoutMs - The time left in the budget.
|
|
23312
|
+
* @throws {Error} When the client ends, or does not become ready in time.
|
|
23313
|
+
*/
|
|
23314
|
+
whenReachable(timeoutMs) {
|
|
23315
|
+
const { status } = this.redis;
|
|
23316
|
+
if (status === "end") {
|
|
23317
|
+
return Promise.reject(new Error("the client is closed"));
|
|
23318
|
+
}
|
|
23319
|
+
if (!CONNECTING_STATES.includes(status)) return Promise.resolve();
|
|
23320
|
+
return new Promise((resolve, reject) => {
|
|
23321
|
+
const settle = /* @__PURE__ */ __name((done) => {
|
|
23322
|
+
clearTimeout(timer);
|
|
23323
|
+
this.redis.off("ready", onReady);
|
|
23324
|
+
this.redis.off("end", onEnd);
|
|
23325
|
+
done();
|
|
23326
|
+
}, "settle");
|
|
23327
|
+
const onReady = /* @__PURE__ */ __name(() => {
|
|
23328
|
+
settle(resolve);
|
|
23329
|
+
}, "onReady");
|
|
23330
|
+
const onEnd = /* @__PURE__ */ __name(() => {
|
|
23331
|
+
settle(() => {
|
|
23332
|
+
reject(new Error("the client gave up connecting"));
|
|
23333
|
+
});
|
|
23334
|
+
}, "onEnd");
|
|
23335
|
+
const timer = setTimeout(() => {
|
|
23336
|
+
settle(() => {
|
|
23337
|
+
reject(new Error("the client did not become ready"));
|
|
23338
|
+
});
|
|
23339
|
+
}, timeoutMs);
|
|
23340
|
+
this.redis.once("ready", onReady);
|
|
23341
|
+
this.redis.once("end", onEnd);
|
|
23342
|
+
});
|
|
23343
|
+
}
|
|
23344
|
+
/**
|
|
23345
|
+
* One PING attempt: waits for the client if it is connecting, then sends the command.
|
|
23346
|
+
*
|
|
23347
|
+
* @param timeoutMs - The time left in the budget; the attempt gives up when it runs out.
|
|
23348
|
+
* @throws {Error} When the client is closed, the command fails or the time runs out.
|
|
23349
|
+
*/
|
|
23350
|
+
async attempt(timeoutMs) {
|
|
23351
|
+
let timer;
|
|
23352
|
+
const expiry = new Promise((_resolve, reject) => {
|
|
23353
|
+
timer = setTimeout(() => {
|
|
23354
|
+
reject(new Error("the PING did not complete in time"));
|
|
23355
|
+
}, timeoutMs);
|
|
23356
|
+
});
|
|
23357
|
+
try {
|
|
23358
|
+
await Promise.race([
|
|
23359
|
+
this.whenReachable(timeoutMs).then(() => this.redis.ping()),
|
|
23360
|
+
expiry
|
|
23361
|
+
]);
|
|
23362
|
+
} finally {
|
|
23363
|
+
clearTimeout(timer);
|
|
23364
|
+
}
|
|
23365
|
+
}
|
|
23366
|
+
/**
|
|
23367
|
+
* @throws {Error} When the client cannot PING, or Redis does not answer within the budget. The
|
|
23368
|
+
* message names the address from the client's own `host` and `port` and never repeats what
|
|
23369
|
+
* ioredis raised, which can quote a connection string.
|
|
23370
|
+
*/
|
|
23371
|
+
async onApplicationBootstrap() {
|
|
23372
|
+
if (commandTimeoutOf(this.redis) === void 0) {
|
|
23373
|
+
this.logger.warn("The Redis client has no commandTimeout, so a slow or unreachable Redis holds each request until ioredis gives up. Set commandTimeout, a small maxRetriesPerRequest and a bounded retryStrategy on the client you provide as BYMAX_AUTH_REDIS_CLIENT.");
|
|
23374
|
+
}
|
|
23375
|
+
if (typeof this.redis.ping !== "function") {
|
|
23376
|
+
throw new Error("[BymaxAuthModule] BYMAX_AUTH_REDIS_CLIENT must be an ioredis client.");
|
|
23377
|
+
}
|
|
23378
|
+
const budgetEnd = Date.now() + STARTUP_PING_TIMEOUT_MS;
|
|
23379
|
+
for (; ; ) {
|
|
23380
|
+
try {
|
|
23381
|
+
await this.attempt(Math.max(budgetEnd - Date.now(), 1));
|
|
23382
|
+
return;
|
|
23383
|
+
} catch {
|
|
23384
|
+
if (this.redis.status === "end" || budgetEnd - Date.now() <= STARTUP_PING_RETRY_MS) break;
|
|
23385
|
+
await pause(STARTUP_PING_RETRY_MS);
|
|
23386
|
+
}
|
|
23387
|
+
}
|
|
23388
|
+
const address = addressOf(this.redis);
|
|
23389
|
+
throw new Error(`[BymaxAuthModule] Redis${address === void 0 ? "" : ` at ${address}`} did not answer PING within ${STARTUP_PING_TIMEOUT_MS} ms at startup. Check the address, the credentials and the network.`);
|
|
23390
|
+
}
|
|
23391
|
+
};
|
|
23392
|
+
RedisReadinessService = _ts_decorate98([
|
|
23393
|
+
common.Injectable(),
|
|
23394
|
+
_ts_param59(0, common.Inject(BYMAX_AUTH_REDIS_CLIENT)),
|
|
23395
|
+
_ts_metadata94("design:type", Function),
|
|
23396
|
+
_ts_metadata94("design:paramtypes", [
|
|
23397
|
+
typeof Redis === "undefined" ? Object : Redis
|
|
23398
|
+
])
|
|
23399
|
+
], RedisReadinessService);
|
|
23104
23400
|
|
|
23105
23401
|
// src/server/services/api-key-clock.ts
|
|
23106
23402
|
var SystemApiKeyClock = class {
|
|
@@ -23112,7 +23408,7 @@ var SystemApiKeyClock = class {
|
|
|
23112
23408
|
return /* @__PURE__ */ new Date();
|
|
23113
23409
|
}
|
|
23114
23410
|
};
|
|
23115
|
-
function
|
|
23411
|
+
function _ts_decorate99(decorators, target, key, desc) {
|
|
23116
23412
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
23117
23413
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
23118
23414
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -23125,19 +23421,19 @@ function _ts_decorate98(decorators, target, key, desc) {
|
|
|
23125
23421
|
}
|
|
23126
23422
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23127
23423
|
}
|
|
23128
|
-
__name(
|
|
23129
|
-
function
|
|
23424
|
+
__name(_ts_decorate99, "_ts_decorate");
|
|
23425
|
+
function _ts_metadata95(metadataKey, metadataValue) {
|
|
23130
23426
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
23131
23427
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
23132
23428
|
}
|
|
23133
23429
|
}
|
|
23134
|
-
__name(
|
|
23135
|
-
function
|
|
23430
|
+
__name(_ts_metadata95, "_ts_metadata");
|
|
23431
|
+
function _ts_param60(paramIndex, decorator) {
|
|
23136
23432
|
return function(target, key) {
|
|
23137
23433
|
decorator(target, key, paramIndex);
|
|
23138
23434
|
};
|
|
23139
23435
|
}
|
|
23140
|
-
__name(
|
|
23436
|
+
__name(_ts_param60, "_ts_param");
|
|
23141
23437
|
var ApiKeyScopeAuditService = class {
|
|
23142
23438
|
static {
|
|
23143
23439
|
__name(this, "ApiKeyScopeAuditService");
|
|
@@ -23180,21 +23476,21 @@ var ApiKeyScopeAuditService = class {
|
|
|
23180
23476
|
}
|
|
23181
23477
|
}
|
|
23182
23478
|
};
|
|
23183
|
-
ApiKeyScopeAuditService =
|
|
23479
|
+
ApiKeyScopeAuditService = _ts_decorate99([
|
|
23184
23480
|
common.Injectable(),
|
|
23185
|
-
|
|
23186
|
-
|
|
23187
|
-
|
|
23188
|
-
|
|
23189
|
-
|
|
23190
|
-
|
|
23481
|
+
_ts_param60(0, common.Inject(core.DiscoveryService)),
|
|
23482
|
+
_ts_param60(1, common.Inject(core.MetadataScanner)),
|
|
23483
|
+
_ts_param60(2, common.Inject(core.Reflector)),
|
|
23484
|
+
_ts_param60(3, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
23485
|
+
_ts_metadata95("design:type", Function),
|
|
23486
|
+
_ts_metadata95("design:paramtypes", [
|
|
23191
23487
|
typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
|
|
23192
23488
|
typeof core.MetadataScanner === "undefined" ? Object : core.MetadataScanner,
|
|
23193
23489
|
typeof core.Reflector === "undefined" ? Object : core.Reflector,
|
|
23194
23490
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
|
|
23195
23491
|
])
|
|
23196
23492
|
], ApiKeyScopeAuditService);
|
|
23197
|
-
function
|
|
23493
|
+
function _ts_decorate100(decorators, target, key, desc) {
|
|
23198
23494
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
23199
23495
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
23200
23496
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -23207,19 +23503,19 @@ function _ts_decorate99(decorators, target, key, desc) {
|
|
|
23207
23503
|
}
|
|
23208
23504
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23209
23505
|
}
|
|
23210
|
-
__name(
|
|
23211
|
-
function
|
|
23506
|
+
__name(_ts_decorate100, "_ts_decorate");
|
|
23507
|
+
function _ts_metadata96(metadataKey, metadataValue) {
|
|
23212
23508
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
23213
23509
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
23214
23510
|
}
|
|
23215
23511
|
}
|
|
23216
|
-
__name(
|
|
23217
|
-
function
|
|
23512
|
+
__name(_ts_metadata96, "_ts_metadata");
|
|
23513
|
+
function _ts_param61(paramIndex, decorator) {
|
|
23218
23514
|
return function(target, key) {
|
|
23219
23515
|
decorator(target, key, paramIndex);
|
|
23220
23516
|
};
|
|
23221
23517
|
}
|
|
23222
|
-
__name(
|
|
23518
|
+
__name(_ts_param61, "_ts_param");
|
|
23223
23519
|
var API_KEY_MAX_LABEL_LENGTH = 128;
|
|
23224
23520
|
var API_KEY_MAX_OVERLAP_SECONDS = 2592e3;
|
|
23225
23521
|
var CONTROL_CHARACTERS = /[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/u;
|
|
@@ -23357,13 +23653,13 @@ exports.ApiKeyService = class ApiKeyService {
|
|
|
23357
23653
|
return value;
|
|
23358
23654
|
}
|
|
23359
23655
|
};
|
|
23360
|
-
exports.ApiKeyService =
|
|
23656
|
+
exports.ApiKeyService = _ts_decorate100([
|
|
23361
23657
|
common.Injectable(),
|
|
23362
|
-
|
|
23363
|
-
|
|
23364
|
-
|
|
23365
|
-
|
|
23366
|
-
|
|
23658
|
+
_ts_param61(0, common.Inject(BYMAX_AUTH_API_KEY_REPOSITORY)),
|
|
23659
|
+
_ts_param61(1, common.Inject(BYMAX_AUTH_API_KEY_CLOCK)),
|
|
23660
|
+
_ts_param61(2, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
23661
|
+
_ts_metadata96("design:type", Function),
|
|
23662
|
+
_ts_metadata96("design:paramtypes", [
|
|
23367
23663
|
typeof IApiKeyRepository === "undefined" ? Object : IApiKeyRepository,
|
|
23368
23664
|
typeof ApiKeyClock === "undefined" ? Object : ApiKeyClock,
|
|
23369
23665
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
|
|
@@ -23445,7 +23741,7 @@ async function assertTenantBinding(options, handshake, tenantId) {
|
|
|
23445
23741
|
__name(assertTenantBinding, "assertTenantBinding");
|
|
23446
23742
|
|
|
23447
23743
|
// src/server/services/auth-token-verifier.service.ts
|
|
23448
|
-
function
|
|
23744
|
+
function _ts_decorate101(decorators, target, key, desc) {
|
|
23449
23745
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
23450
23746
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
23451
23747
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -23458,19 +23754,19 @@ function _ts_decorate100(decorators, target, key, desc) {
|
|
|
23458
23754
|
}
|
|
23459
23755
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23460
23756
|
}
|
|
23461
|
-
__name(
|
|
23462
|
-
function
|
|
23757
|
+
__name(_ts_decorate101, "_ts_decorate");
|
|
23758
|
+
function _ts_metadata97(metadataKey, metadataValue) {
|
|
23463
23759
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
23464
23760
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
23465
23761
|
}
|
|
23466
23762
|
}
|
|
23467
|
-
__name(
|
|
23468
|
-
function
|
|
23763
|
+
__name(_ts_metadata97, "_ts_metadata");
|
|
23764
|
+
function _ts_param62(paramIndex, decorator) {
|
|
23469
23765
|
return function(target, key) {
|
|
23470
23766
|
decorator(target, key, paramIndex);
|
|
23471
23767
|
};
|
|
23472
23768
|
}
|
|
23473
|
-
__name(
|
|
23769
|
+
__name(_ts_param62, "_ts_param");
|
|
23474
23770
|
exports.AuthTokenVerifierService = class _AuthTokenVerifierService {
|
|
23475
23771
|
static {
|
|
23476
23772
|
__name(this, "AuthTokenVerifierService");
|
|
@@ -23550,11 +23846,14 @@ exports.AuthTokenVerifierService = class _AuthTokenVerifierService {
|
|
|
23550
23846
|
};
|
|
23551
23847
|
}
|
|
23552
23848
|
/**
|
|
23553
|
-
* The function that admits a caller to a workspace
|
|
23554
|
-
*
|
|
23849
|
+
* The function that admits a caller to a workspace. On a plane with no workspaces that is a
|
|
23850
|
+
* `TypeError` raised at once, a programmer's error. On a deployment that has not enabled them the
|
|
23851
|
+
* function is returned and refuses with the `auth.validation` error naming `workspaceId` when it is
|
|
23852
|
+
* called, which is after the token has been verified: the id came from a client, and an anonymous
|
|
23853
|
+
* caller must get `TOKEN_INVALID`, not a description of the deployment.
|
|
23555
23854
|
*
|
|
23556
|
-
*
|
|
23557
|
-
* for a malformed id and then the guard's refusals.
|
|
23855
|
+
* Otherwise the returned function admits the caller as `WorkspaceGuard` would a route, with
|
|
23856
|
+
* `auth.validation` for a malformed id and then the guard's refusals.
|
|
23558
23857
|
*/
|
|
23559
23858
|
workspaceResolver(plane) {
|
|
23560
23859
|
if (plane !== "dashboard") {
|
|
@@ -23564,7 +23863,12 @@ exports.AuthTokenVerifierService = class _AuthTokenVerifierService {
|
|
|
23564
23863
|
const group = this.options.workspaces;
|
|
23565
23864
|
const denied = this.deniedEvents;
|
|
23566
23865
|
if (access === null || group === void 0) {
|
|
23567
|
-
|
|
23866
|
+
return () => Promise.reject(new AuthException(AUTH_ERROR_CODES.VALIDATION, [
|
|
23867
|
+
{
|
|
23868
|
+
field: "workspaceId",
|
|
23869
|
+
message: "workspaceId is not accepted: workspaces are not enabled for this deployment"
|
|
23870
|
+
}
|
|
23871
|
+
]));
|
|
23568
23872
|
}
|
|
23569
23873
|
return async (payload, check) => {
|
|
23570
23874
|
const workspaceId = assertWorkspaceId(check.workspaceId);
|
|
@@ -23672,18 +23976,18 @@ exports.AuthTokenVerifierService = class _AuthTokenVerifierService {
|
|
|
23672
23976
|
}
|
|
23673
23977
|
}
|
|
23674
23978
|
};
|
|
23675
|
-
exports.AuthTokenVerifierService =
|
|
23979
|
+
exports.AuthTokenVerifierService = _ts_decorate101([
|
|
23676
23980
|
common.Injectable(),
|
|
23677
|
-
|
|
23678
|
-
|
|
23679
|
-
|
|
23680
|
-
|
|
23681
|
-
|
|
23682
|
-
|
|
23683
|
-
|
|
23684
|
-
|
|
23685
|
-
|
|
23686
|
-
|
|
23981
|
+
_ts_param62(0, common.Inject(jwt.JwtService)),
|
|
23982
|
+
_ts_param62(1, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
23983
|
+
_ts_param62(2, common.Inject(exports.AuthRevocationService)),
|
|
23984
|
+
_ts_param62(3, common.Inject(exports.AccountStatusService)),
|
|
23985
|
+
_ts_param62(4, common.Inject(exports.WorkspaceAccessService)),
|
|
23986
|
+
_ts_param62(4, common.Optional()),
|
|
23987
|
+
_ts_param62(5, common.Inject(WorkspaceDeniedEventsService)),
|
|
23988
|
+
_ts_param62(5, common.Optional()),
|
|
23989
|
+
_ts_metadata97("design:type", Function),
|
|
23990
|
+
_ts_metadata97("design:paramtypes", [
|
|
23687
23991
|
typeof jwt.JwtService === "undefined" ? Object : jwt.JwtService,
|
|
23688
23992
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
|
|
23689
23993
|
typeof exports.AuthRevocationService === "undefined" ? Object : exports.AuthRevocationService,
|
|
@@ -23694,7 +23998,7 @@ exports.AuthTokenVerifierService = _ts_decorate100([
|
|
|
23694
23998
|
], exports.AuthTokenVerifierService);
|
|
23695
23999
|
|
|
23696
24000
|
// src/server/bymax-auth.module.ts
|
|
23697
|
-
function
|
|
24001
|
+
function _ts_decorate102(decorators, target, key, desc) {
|
|
23698
24002
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
23699
24003
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
23700
24004
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -23707,7 +24011,7 @@ function _ts_decorate101(decorators, target, key, desc) {
|
|
|
23707
24011
|
}
|
|
23708
24012
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23709
24013
|
}
|
|
23710
|
-
__name(
|
|
24014
|
+
__name(_ts_decorate102, "_ts_decorate");
|
|
23711
24015
|
function hasProviderToken(providers, token) {
|
|
23712
24016
|
return providers.some((p) => {
|
|
23713
24017
|
if (typeof p === "function") return false;
|
|
@@ -23805,9 +24109,7 @@ exports.BymaxAuthModule = class _BymaxAuthModule {
|
|
|
23805
24109
|
if (includeWorkspaceController && resolved.workspaces === void 0) {
|
|
23806
24110
|
throw new Error("[BymaxAuthModule] controllers.workspaces: true requires workspaces.enabled: true and both workspace repository providers in extraProviders.");
|
|
23807
24111
|
}
|
|
23808
|
-
|
|
23809
|
-
throw new Error("[BymaxAuthModule] controllers.workspaceInvitations: true requires workspaces.enabled: true and both workspace repository providers in extraProviders.");
|
|
23810
|
-
}
|
|
24112
|
+
assertInvitationControllers(resolved, includeWorkspaceInvitations, includeInvitations);
|
|
23811
24113
|
if (resolved.apiKeys.auditMode === "required" && cannotAuditApiKeys(extraProviders)) {
|
|
23812
24114
|
throw new Error("[BymaxAuthModule] apiKeys.auditMode: 'required' needs an onApiKeyRequest hook, and the BYMAX_AUTH_HOOKS provider has none. Implement it, or use auditMode: 'best-effort'.");
|
|
23813
24115
|
}
|
|
@@ -23981,10 +24283,10 @@ exports.BymaxAuthModule = class _BymaxAuthModule {
|
|
|
23981
24283
|
...breachCheckerProviders,
|
|
23982
24284
|
...hooksProviders,
|
|
23983
24285
|
// Core services.
|
|
23984
|
-
// AuthRedisService is registered directly (not via AuthRedisModule) so that
|
|
23985
|
-
//
|
|
23986
|
-
// are visible in the same module scope.
|
|
24286
|
+
// AuthRedisService is registered directly (not via AuthRedisModule) so that the client and
|
|
24287
|
+
// the options provided via extraProviders are visible in the same module scope.
|
|
23987
24288
|
AuthRedisService,
|
|
24289
|
+
RedisReadinessService,
|
|
23988
24290
|
exports.AuthRevocationService,
|
|
23989
24291
|
exports.AccountStatusService,
|
|
23990
24292
|
exports.AuthTokenVerifierService,
|
|
@@ -24099,9 +24401,9 @@ exports.BymaxAuthModule = class _BymaxAuthModule {
|
|
|
24099
24401
|
// exported for the same @UseGuards() reason as the entries around it: the guard is
|
|
24100
24402
|
// re-instantiated in the consumer's injector, where an unexported dep fails their boot.
|
|
24101
24403
|
exports.AccountStatusService,
|
|
24102
|
-
// AuthTokenVerifierService is
|
|
24103
|
-
//
|
|
24104
|
-
//
|
|
24404
|
+
// AuthTokenVerifierService is the one call that establishes everything a guarded route
|
|
24405
|
+
// establishes, which is what a long-lived transport needs and cannot assemble from the
|
|
24406
|
+
// exported parts alone. `WsJwtGuard` depends on it, and a host may call it directly.
|
|
24105
24407
|
exports.AuthTokenVerifierService,
|
|
24106
24408
|
// Same reason, for the two exported guards whose remaining constructor deps are not
|
|
24107
24409
|
// covered by the entries above. Exporting the guard class is necessary but not
|
|
@@ -24110,7 +24412,7 @@ exports.BymaxAuthModule = class _BymaxAuthModule {
|
|
|
24110
24412
|
// UnknownDependenciesException even though the guard itself is exported.
|
|
24111
24413
|
//
|
|
24112
24414
|
// UserStatusGuard -> AccountStatusService
|
|
24113
|
-
// WsJwtGuard -> WsTicketService
|
|
24415
|
+
// WsJwtGuard -> AuthTokenVerifierService, WsTicketService
|
|
24114
24416
|
//
|
|
24115
24417
|
// Only the DIRECT dependency needs exporting. An exported provider arrives already
|
|
24116
24418
|
// instantiated, so the consumer's injector binds that instance and never re-resolves its
|
|
@@ -24154,7 +24456,7 @@ exports.BymaxAuthModule = class _BymaxAuthModule {
|
|
|
24154
24456
|
};
|
|
24155
24457
|
}
|
|
24156
24458
|
};
|
|
24157
|
-
exports.BymaxAuthModule =
|
|
24459
|
+
exports.BymaxAuthModule = _ts_decorate102([
|
|
24158
24460
|
common.Module({})
|
|
24159
24461
|
], exports.BymaxAuthModule);
|
|
24160
24462
|
|
|
@@ -24184,29 +24486,39 @@ function authDocumentSecurity({ guard, tokenDelivery }) {
|
|
|
24184
24486
|
return Object.freeze(schemes.map(requirementFor));
|
|
24185
24487
|
}
|
|
24186
24488
|
__name(authDocumentSecurity, "authDocumentSecurity");
|
|
24187
|
-
|
|
24188
|
-
|
|
24189
|
-
"passwordResetOtp",
|
|
24190
|
-
"emailVerificationOtp",
|
|
24191
|
-
"passwordChanged",
|
|
24192
|
-
"emailChangeVerification",
|
|
24193
|
-
"emailChanged",
|
|
24194
|
-
"mfaEnabled",
|
|
24195
|
-
"mfaDisabled",
|
|
24196
|
-
"newSessionAlert",
|
|
24197
|
-
"invitation"
|
|
24198
|
-
];
|
|
24199
|
-
Object.freeze(AUTH_EMAIL_KINDS);
|
|
24200
|
-
var CREDENTIAL_BEARING_KINDS = /* @__PURE__ */ new Set([
|
|
24201
|
-
"passwordResetToken",
|
|
24202
|
-
"passwordResetOtp",
|
|
24203
|
-
"emailVerificationOtp",
|
|
24204
|
-
"emailChangeVerification",
|
|
24205
|
-
"invitation"
|
|
24206
|
-
]);
|
|
24207
|
-
var KNOWN_EMAIL_KINDS = new Set(AUTH_EMAIL_KINDS);
|
|
24489
|
+
|
|
24490
|
+
// src/server/providers/default-auth-email.messages.ts
|
|
24208
24491
|
var CODE_VALIDITY_TEXT = "It expires shortly, so use it soon.";
|
|
24209
24492
|
var UNEXPECTED_CHANGE_TEXT = "If this was not you, secure your account immediately: change your password and sign out of every session.";
|
|
24493
|
+
function hasInviter(invite) {
|
|
24494
|
+
return invite.inviterName.trim() !== "";
|
|
24495
|
+
}
|
|
24496
|
+
__name(hasInviter, "hasInviter");
|
|
24497
|
+
function workspaceInvitationSubject(invite) {
|
|
24498
|
+
if (invite.kind === "member") {
|
|
24499
|
+
return `${invite.inviterName} invited you to ${invite.workspaceName}`;
|
|
24500
|
+
}
|
|
24501
|
+
return hasInviter(invite) ? `${invite.inviterName} invited you to set up ${invite.workspaceName}` : `You have been invited to set up ${invite.workspaceName}`;
|
|
24502
|
+
}
|
|
24503
|
+
__name(workspaceInvitationSubject, "workspaceInvitationSubject");
|
|
24504
|
+
function workspaceInvitationOpening(invite) {
|
|
24505
|
+
if (invite.kind === "member") {
|
|
24506
|
+
return `${invite.inviterName} invited you to the workspace ${invite.workspaceName} as ${invite.role}.`;
|
|
24507
|
+
}
|
|
24508
|
+
const subject = hasInviter(invite) ? `${invite.inviterName} invited you` : "You have been invited";
|
|
24509
|
+
return `${subject} to set up the workspace ${invite.workspaceName} as its owner.`;
|
|
24510
|
+
}
|
|
24511
|
+
__name(workspaceInvitationOpening, "workspaceInvitationOpening");
|
|
24512
|
+
function workspaceInvitationText(invite) {
|
|
24513
|
+
const step = invite.accountExists ? "Sign in" : "Create your account";
|
|
24514
|
+
return [
|
|
24515
|
+
workspaceInvitationOpening(invite),
|
|
24516
|
+
`${step} and use this token to accept: ${invite.inviteToken}`,
|
|
24517
|
+
`It expires on ${invite.expiresAt.toISOString()}.`,
|
|
24518
|
+
"If you were not expecting this invitation, ignore this message."
|
|
24519
|
+
].join("\n\n");
|
|
24520
|
+
}
|
|
24521
|
+
__name(workspaceInvitationText, "workspaceInvitationText");
|
|
24210
24522
|
var DEFAULT_MESSAGES = {
|
|
24211
24523
|
passwordResetToken: /* @__PURE__ */ __name(({ token }) => ({
|
|
24212
24524
|
subject: "Reset your password",
|
|
@@ -24283,8 +24595,37 @@ Use this token to accept: ${invite.inviteToken}
|
|
|
24283
24595
|
It expires on ${invite.expiresAt.toISOString()}.
|
|
24284
24596
|
|
|
24285
24597
|
If you were not expecting this invitation, ignore this message.`
|
|
24286
|
-
}), "invitation")
|
|
24598
|
+
}), "invitation"),
|
|
24599
|
+
workspaceInvitation: /* @__PURE__ */ __name(({ invite }) => ({
|
|
24600
|
+
subject: workspaceInvitationSubject(invite),
|
|
24601
|
+
text: workspaceInvitationText(invite)
|
|
24602
|
+
}), "workspaceInvitation")
|
|
24287
24603
|
};
|
|
24604
|
+
|
|
24605
|
+
// src/server/providers/default-auth-email.provider.ts
|
|
24606
|
+
var AUTH_EMAIL_KINDS = [
|
|
24607
|
+
"passwordResetToken",
|
|
24608
|
+
"passwordResetOtp",
|
|
24609
|
+
"emailVerificationOtp",
|
|
24610
|
+
"passwordChanged",
|
|
24611
|
+
"emailChangeVerification",
|
|
24612
|
+
"emailChanged",
|
|
24613
|
+
"mfaEnabled",
|
|
24614
|
+
"mfaDisabled",
|
|
24615
|
+
"newSessionAlert",
|
|
24616
|
+
"invitation",
|
|
24617
|
+
"workspaceInvitation"
|
|
24618
|
+
];
|
|
24619
|
+
Object.freeze(AUTH_EMAIL_KINDS);
|
|
24620
|
+
var CREDENTIAL_BEARING_KINDS = /* @__PURE__ */ new Set([
|
|
24621
|
+
"passwordResetToken",
|
|
24622
|
+
"passwordResetOtp",
|
|
24623
|
+
"emailVerificationOtp",
|
|
24624
|
+
"emailChangeVerification",
|
|
24625
|
+
"invitation",
|
|
24626
|
+
"workspaceInvitation"
|
|
24627
|
+
]);
|
|
24628
|
+
var KNOWN_EMAIL_KINDS = new Set(AUTH_EMAIL_KINDS);
|
|
24288
24629
|
function escapeHtml(value) {
|
|
24289
24630
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
24290
24631
|
}
|
|
@@ -24311,7 +24652,7 @@ var DefaultAuthEmailProvider = class _DefaultAuthEmailProvider {
|
|
|
24311
24652
|
*
|
|
24312
24653
|
* A `Map`, not the plain object the option accepts. An object lookup walks the prototype chain,
|
|
24313
24654
|
* so `policy['toString']` answers with a function rather than `undefined` — unreachable here,
|
|
24314
|
-
* because the key is a closed union of
|
|
24655
|
+
* because the key is a closed union of literals this file writes, but "the key cannot be
|
|
24315
24656
|
* dangerous" is a property of today's call sites and not of the lookup. A `Map` has no prototype
|
|
24316
24657
|
* chain to walk, which makes it a property of the data structure instead.
|
|
24317
24658
|
*/
|
|
@@ -24437,6 +24778,14 @@ var DefaultAuthEmailProvider = class _DefaultAuthEmailProvider {
|
|
|
24437
24778
|
locale
|
|
24438
24779
|
}), "invitation");
|
|
24439
24780
|
}
|
|
24781
|
+
async sendWorkspaceInvitation(tenantId, email, data, locale) {
|
|
24782
|
+
await this.deliver(tenantId, email, this.messages.workspaceInvitation({
|
|
24783
|
+
tenantId,
|
|
24784
|
+
email,
|
|
24785
|
+
invite: data,
|
|
24786
|
+
locale
|
|
24787
|
+
}), "workspaceInvitation");
|
|
24788
|
+
}
|
|
24440
24789
|
/**
|
|
24441
24790
|
* Renders the body to HTML (unless the message already carries its own), hands the message to the
|
|
24442
24791
|
* channel, and swallows any delivery error.
|
|
@@ -24482,7 +24831,7 @@ var DefaultAuthEmailProvider = class _DefaultAuthEmailProvider {
|
|
|
24482
24831
|
}
|
|
24483
24832
|
}
|
|
24484
24833
|
};
|
|
24485
|
-
function
|
|
24834
|
+
function _ts_decorate103(decorators, target, key, desc) {
|
|
24486
24835
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24487
24836
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
24488
24837
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -24495,13 +24844,13 @@ function _ts_decorate102(decorators, target, key, desc) {
|
|
|
24495
24844
|
}
|
|
24496
24845
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
24497
24846
|
}
|
|
24498
|
-
__name(
|
|
24499
|
-
function
|
|
24847
|
+
__name(_ts_decorate103, "_ts_decorate");
|
|
24848
|
+
function _ts_metadata98(metadataKey, metadataValue) {
|
|
24500
24849
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
24501
24850
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
24502
24851
|
}
|
|
24503
24852
|
}
|
|
24504
|
-
__name(
|
|
24853
|
+
__name(_ts_metadata98, "_ts_metadata");
|
|
24505
24854
|
var HIBP_RANGE_URL = "https://api.pwnedpasswords.com/range/";
|
|
24506
24855
|
var PREFIX_LENGTH = 5;
|
|
24507
24856
|
var DEFAULT_TIMEOUT_MS = 1500;
|
|
@@ -24558,10 +24907,10 @@ exports.HibpBreachChecker = class _HibpBreachChecker {
|
|
|
24558
24907
|
}
|
|
24559
24908
|
}
|
|
24560
24909
|
};
|
|
24561
|
-
exports.HibpBreachChecker =
|
|
24910
|
+
exports.HibpBreachChecker = _ts_decorate103([
|
|
24562
24911
|
common.Injectable(),
|
|
24563
|
-
|
|
24564
|
-
|
|
24912
|
+
_ts_metadata98("design:type", Function),
|
|
24913
|
+
_ts_metadata98("design:paramtypes", [
|
|
24565
24914
|
Number
|
|
24566
24915
|
])
|
|
24567
24916
|
], exports.HibpBreachChecker);
|
|
@@ -24574,10 +24923,10 @@ exports.AllowAllBreachChecker = class AllowAllBreachChecker {
|
|
|
24574
24923
|
return false;
|
|
24575
24924
|
}
|
|
24576
24925
|
};
|
|
24577
|
-
exports.AllowAllBreachChecker =
|
|
24926
|
+
exports.AllowAllBreachChecker = _ts_decorate103([
|
|
24578
24927
|
common.Injectable()
|
|
24579
24928
|
], exports.AllowAllBreachChecker);
|
|
24580
|
-
function
|
|
24929
|
+
function _ts_decorate104(decorators, target, key, desc) {
|
|
24581
24930
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24582
24931
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
24583
24932
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -24590,7 +24939,7 @@ function _ts_decorate103(decorators, target, key, desc) {
|
|
|
24590
24939
|
}
|
|
24591
24940
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
24592
24941
|
}
|
|
24593
|
-
__name(
|
|
24942
|
+
__name(_ts_decorate104, "_ts_decorate");
|
|
24594
24943
|
exports.OptionalAuthGuard = class OptionalAuthGuard extends exports.JwtAuthGuard {
|
|
24595
24944
|
static {
|
|
24596
24945
|
__name(this, "OptionalAuthGuard");
|
|
@@ -24605,10 +24954,10 @@ exports.OptionalAuthGuard = class OptionalAuthGuard extends exports.JwtAuthGuard
|
|
|
24605
24954
|
return super.canActivate(context);
|
|
24606
24955
|
}
|
|
24607
24956
|
};
|
|
24608
|
-
exports.OptionalAuthGuard =
|
|
24957
|
+
exports.OptionalAuthGuard = _ts_decorate104([
|
|
24609
24958
|
common.Injectable()
|
|
24610
24959
|
], exports.OptionalAuthGuard);
|
|
24611
|
-
function
|
|
24960
|
+
function _ts_decorate105(decorators, target, key, desc) {
|
|
24612
24961
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24613
24962
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
24614
24963
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -24621,19 +24970,19 @@ function _ts_decorate104(decorators, target, key, desc) {
|
|
|
24621
24970
|
}
|
|
24622
24971
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
24623
24972
|
}
|
|
24624
|
-
__name(
|
|
24625
|
-
function
|
|
24973
|
+
__name(_ts_decorate105, "_ts_decorate");
|
|
24974
|
+
function _ts_metadata99(metadataKey, metadataValue) {
|
|
24626
24975
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
24627
24976
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
24628
24977
|
}
|
|
24629
24978
|
}
|
|
24630
|
-
__name(
|
|
24631
|
-
function
|
|
24979
|
+
__name(_ts_metadata99, "_ts_metadata");
|
|
24980
|
+
function _ts_param63(paramIndex, decorator) {
|
|
24632
24981
|
return function(target, key) {
|
|
24633
24982
|
decorator(target, key, paramIndex);
|
|
24634
24983
|
};
|
|
24635
24984
|
}
|
|
24636
|
-
__name(
|
|
24985
|
+
__name(_ts_param63, "_ts_param");
|
|
24637
24986
|
exports.SelfOrAdminGuard = class SelfOrAdminGuard {
|
|
24638
24987
|
static {
|
|
24639
24988
|
__name(this, "SelfOrAdminGuard");
|
|
@@ -24669,11 +25018,11 @@ exports.SelfOrAdminGuard = class SelfOrAdminGuard {
|
|
|
24669
25018
|
throw new AuthException(AUTH_ERROR_CODES.INSUFFICIENT_ROLE);
|
|
24670
25019
|
}
|
|
24671
25020
|
};
|
|
24672
|
-
exports.SelfOrAdminGuard =
|
|
25021
|
+
exports.SelfOrAdminGuard = _ts_decorate105([
|
|
24673
25022
|
common.Injectable(),
|
|
24674
|
-
|
|
24675
|
-
|
|
24676
|
-
|
|
25023
|
+
_ts_param63(0, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
25024
|
+
_ts_metadata99("design:type", Function),
|
|
25025
|
+
_ts_metadata99("design:paramtypes", [
|
|
24677
25026
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
|
|
24678
25027
|
])
|
|
24679
25028
|
], exports.SelfOrAdminGuard);
|
|
@@ -24695,7 +25044,7 @@ function isHexLooking(value) {
|
|
|
24695
25044
|
return value.length === 64 && /^[a-fA-F0-9]{64}$/.test(value);
|
|
24696
25045
|
}
|
|
24697
25046
|
__name(isHexLooking, "isHexLooking");
|
|
24698
|
-
function
|
|
25047
|
+
function _ts_decorate106(decorators, target, key, desc) {
|
|
24699
25048
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24700
25049
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
24701
25050
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -24708,32 +25057,32 @@ function _ts_decorate105(decorators, target, key, desc) {
|
|
|
24708
25057
|
}
|
|
24709
25058
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
24710
25059
|
}
|
|
24711
|
-
__name(
|
|
24712
|
-
function
|
|
25060
|
+
__name(_ts_decorate106, "_ts_decorate");
|
|
25061
|
+
function _ts_metadata100(metadataKey, metadataValue) {
|
|
24713
25062
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
24714
25063
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
24715
25064
|
}
|
|
24716
25065
|
}
|
|
24717
|
-
__name(
|
|
24718
|
-
function
|
|
25066
|
+
__name(_ts_metadata100, "_ts_metadata");
|
|
25067
|
+
function _ts_param64(paramIndex, decorator) {
|
|
24719
25068
|
return function(target, key) {
|
|
24720
25069
|
decorator(target, key, paramIndex);
|
|
24721
25070
|
};
|
|
24722
25071
|
}
|
|
24723
|
-
__name(
|
|
25072
|
+
__name(_ts_param64, "_ts_param");
|
|
24724
25073
|
exports.WsJwtGuard = class WsJwtGuard {
|
|
24725
25074
|
static {
|
|
24726
25075
|
__name(this, "WsJwtGuard");
|
|
24727
25076
|
}
|
|
24728
|
-
|
|
24729
|
-
revocation;
|
|
25077
|
+
verifier;
|
|
24730
25078
|
wsTickets;
|
|
24731
25079
|
options;
|
|
24732
|
-
|
|
24733
|
-
|
|
24734
|
-
this.
|
|
25080
|
+
reflector;
|
|
25081
|
+
constructor(verifier, wsTickets, options, reflector) {
|
|
25082
|
+
this.verifier = verifier;
|
|
24735
25083
|
this.wsTickets = wsTickets;
|
|
24736
25084
|
this.options = options;
|
|
25085
|
+
this.reflector = reflector;
|
|
24737
25086
|
}
|
|
24738
25087
|
/**
|
|
24739
25088
|
* Verifies that `@nestjs/websockets` is installed and throws a descriptive
|
|
@@ -24765,37 +25114,32 @@ exports.WsJwtGuard = class WsJwtGuard {
|
|
|
24765
25114
|
if (!token) {
|
|
24766
25115
|
throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
|
|
24767
25116
|
}
|
|
24768
|
-
|
|
24769
|
-
|
|
24770
|
-
|
|
24771
|
-
|
|
24772
|
-
|
|
24773
|
-
|
|
24774
|
-
|
|
24775
|
-
|
|
24776
|
-
|
|
24777
|
-
|
|
24778
|
-
|
|
24779
|
-
if (await this.revocation.isAccessTokenRevoked(payload)) {
|
|
24780
|
-
throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
|
|
24781
|
-
}
|
|
24782
|
-
await assertTenantBinding(this.options, bindingInput(handshake), payload.tenantId);
|
|
24783
|
-
client.data.user = payload;
|
|
25117
|
+
const skipMfa = this.reflector.getAllAndOverride(SKIP_MFA_KEY, [
|
|
25118
|
+
context.getHandler(),
|
|
25119
|
+
context.getClass()
|
|
25120
|
+
]) === true;
|
|
25121
|
+
const verified = await this.verifier.verifyAccessToken(token, {
|
|
25122
|
+
plane: "dashboard",
|
|
25123
|
+
requireMfa: !skipMfa,
|
|
25124
|
+
checkStatus: true,
|
|
25125
|
+
request: bindingInput(handshake)
|
|
25126
|
+
});
|
|
25127
|
+
client.data.user = verified.payload;
|
|
24784
25128
|
return true;
|
|
24785
25129
|
}
|
|
24786
25130
|
};
|
|
24787
|
-
exports.WsJwtGuard =
|
|
25131
|
+
exports.WsJwtGuard = _ts_decorate106([
|
|
24788
25132
|
common.Injectable(),
|
|
24789
|
-
|
|
24790
|
-
|
|
24791
|
-
|
|
24792
|
-
|
|
24793
|
-
|
|
24794
|
-
|
|
24795
|
-
typeof
|
|
24796
|
-
typeof exports.AuthRevocationService === "undefined" ? Object : exports.AuthRevocationService,
|
|
25133
|
+
_ts_param64(0, common.Inject(exports.AuthTokenVerifierService)),
|
|
25134
|
+
_ts_param64(1, common.Inject(exports.WsTicketService)),
|
|
25135
|
+
_ts_param64(2, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
25136
|
+
_ts_param64(3, common.Inject(core.Reflector)),
|
|
25137
|
+
_ts_metadata100("design:type", Function),
|
|
25138
|
+
_ts_metadata100("design:paramtypes", [
|
|
25139
|
+
typeof exports.AuthTokenVerifierService === "undefined" ? Object : exports.AuthTokenVerifierService,
|
|
24797
25140
|
typeof exports.WsTicketService === "undefined" ? Object : exports.WsTicketService,
|
|
24798
|
-
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
|
|
25141
|
+
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
|
|
25142
|
+
typeof core.Reflector === "undefined" ? Object : core.Reflector
|
|
24799
25143
|
])
|
|
24800
25144
|
], exports.WsJwtGuard);
|
|
24801
25145
|
function assertDashboardSnapshot(snapshot) {
|
|
@@ -24831,7 +25175,7 @@ function bindingInput(handshake) {
|
|
|
24831
25175
|
};
|
|
24832
25176
|
}
|
|
24833
25177
|
__name(bindingInput, "bindingInput");
|
|
24834
|
-
function
|
|
25178
|
+
function _ts_decorate107(decorators, target, key, desc) {
|
|
24835
25179
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24836
25180
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
24837
25181
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -24844,7 +25188,7 @@ function _ts_decorate106(decorators, target, key, desc) {
|
|
|
24844
25188
|
}
|
|
24845
25189
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
24846
25190
|
}
|
|
24847
|
-
__name(
|
|
25191
|
+
__name(_ts_decorate107, "_ts_decorate");
|
|
24848
25192
|
function isAuthEnvelope(body) {
|
|
24849
25193
|
if (typeof body !== "object" || body === null) return false;
|
|
24850
25194
|
const error = body.error;
|
|
@@ -24963,10 +25307,10 @@ exports.AuthExceptionFilter = class _AuthExceptionFilter {
|
|
|
24963
25307
|
});
|
|
24964
25308
|
}
|
|
24965
25309
|
};
|
|
24966
|
-
exports.AuthExceptionFilter =
|
|
25310
|
+
exports.AuthExceptionFilter = _ts_decorate107([
|
|
24967
25311
|
common.Catch()
|
|
24968
25312
|
], exports.AuthExceptionFilter);
|
|
24969
|
-
function
|
|
25313
|
+
function _ts_decorate108(decorators, target, key, desc) {
|
|
24970
25314
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24971
25315
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
24972
25316
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -24979,7 +25323,7 @@ function _ts_decorate107(decorators, target, key, desc) {
|
|
|
24979
25323
|
}
|
|
24980
25324
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
24981
25325
|
}
|
|
24982
|
-
__name(
|
|
25326
|
+
__name(_ts_decorate108, "_ts_decorate");
|
|
24983
25327
|
function isEmittingClient(client) {
|
|
24984
25328
|
return typeof client?.emit === "function";
|
|
24985
25329
|
}
|
|
@@ -25023,7 +25367,7 @@ exports.WsAuthExceptionFilter = class _WsAuthExceptionFilter {
|
|
|
25023
25367
|
this.logger.error(`refused a request on a client this filter cannot answer: ${describeChannelStatus(exception)}`);
|
|
25024
25368
|
}
|
|
25025
25369
|
};
|
|
25026
|
-
exports.WsAuthExceptionFilter =
|
|
25370
|
+
exports.WsAuthExceptionFilter = _ts_decorate108([
|
|
25027
25371
|
common.Catch(AuthException)
|
|
25028
25372
|
], exports.WsAuthExceptionFilter);
|
|
25029
25373
|
var ServiceKey = /* @__PURE__ */ __name((...scopes) => common.applyDecorators(common.SetMetadata(IS_PUBLIC_KEY, true), ApiKeyScopes(...scopes), common.UseGuards(exports.ApiKeyGuard)), "ServiceKey");
|
|
@@ -25037,7 +25381,7 @@ var CurrentWsWorkspace = common.createParamDecorator((_data, context) => {
|
|
|
25037
25381
|
});
|
|
25038
25382
|
|
|
25039
25383
|
// src/server/utils/workspace-scoped.ts
|
|
25040
|
-
var
|
|
25384
|
+
var UNPAIRED_SURROGATE2 = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;
|
|
25041
25385
|
function workspaceScopedName(tenantId, workspaceId, ...parts) {
|
|
25042
25386
|
const pieces = [
|
|
25043
25387
|
tenantId,
|
|
@@ -25049,7 +25393,7 @@ function workspaceScopedName(tenantId, workspaceId, ...parts) {
|
|
|
25049
25393
|
}
|
|
25050
25394
|
__name(workspaceScopedName, "workspaceScopedName");
|
|
25051
25395
|
function decodeWorkspaceScopedName(name) {
|
|
25052
|
-
if (
|
|
25396
|
+
if (UNPAIRED_SURROGATE2.test(name)) throw malformed(name);
|
|
25053
25397
|
const bytes = Buffer.from(name, "utf8");
|
|
25054
25398
|
const pieces = [];
|
|
25055
25399
|
let at = 0;
|
|
@@ -25090,7 +25434,7 @@ function assertPiece(piece, index) {
|
|
|
25090
25434
|
if (hasControl(piece)) {
|
|
25091
25435
|
throw new TypeError(`${label} must not contain a control character`);
|
|
25092
25436
|
}
|
|
25093
|
-
if (
|
|
25437
|
+
if (UNPAIRED_SURROGATE2.test(piece)) throw new TypeError(`${label} must be well-formed Unicode`);
|
|
25094
25438
|
}
|
|
25095
25439
|
__name(assertPiece, "assertPiece");
|
|
25096
25440
|
function malformed(name) {
|
|
@@ -25116,6 +25460,7 @@ exports.AUTH_EMAIL_KINDS = AUTH_EMAIL_KINDS;
|
|
|
25116
25460
|
exports.AUTH_ERROR_CODES = AUTH_ERROR_CODES;
|
|
25117
25461
|
exports.AUTH_ERROR_MESSAGES = AUTH_ERROR_MESSAGES;
|
|
25118
25462
|
exports.AUTH_ERROR_STATUS = AUTH_ERROR_STATUS;
|
|
25463
|
+
exports.AUTH_SECRET_MIN_LENGTH = AUTH_SECRET_MIN_LENGTH;
|
|
25119
25464
|
exports.AUTH_SECURITY_SCHEMES = AUTH_SECURITY_SCHEMES;
|
|
25120
25465
|
exports.AUTH_THROTTLE_CONFIGS = AUTH_THROTTLE_CONFIGS;
|
|
25121
25466
|
exports.AcceptInvitationDto = AcceptInvitationDto;
|
|
@@ -25166,21 +25511,30 @@ exports.ServiceKey = ServiceKey;
|
|
|
25166
25511
|
exports.SkipMfa = SkipMfa;
|
|
25167
25512
|
exports.VerifyEmailDto = VerifyEmailDto;
|
|
25168
25513
|
exports.VerifyOtpDto = VerifyOtpDto;
|
|
25514
|
+
exports.WORKSPACE_CURSOR_MAX_LENGTH = WORKSPACE_CURSOR_MAX_LENGTH;
|
|
25515
|
+
exports.WORKSPACE_CURSOR_PART_MAX_LENGTH = WORKSPACE_CURSOR_PART_MAX_LENGTH;
|
|
25516
|
+
exports.WORKSPACE_ID_MAX_LENGTH = WORKSPACE_ID_MAX_LENGTH;
|
|
25517
|
+
exports.WORKSPACE_OWNER_ROLE_MAX_LENGTH = WORKSPACE_OWNER_ROLE_MAX_LENGTH;
|
|
25169
25518
|
exports.WORKSPACE_PERMISSION_KEY = WORKSPACE_PERMISSION_KEY;
|
|
25170
25519
|
exports.WORKSPACE_ROLES_KEY = WORKSPACE_ROLES_KEY;
|
|
25171
25520
|
exports.WS_TICKET_TTL_SECONDS = WS_TICKET_TTL_SECONDS;
|
|
25172
25521
|
exports.WorkspacePermission = WorkspacePermission;
|
|
25173
25522
|
exports.WorkspaceRoles = WorkspaceRoles;
|
|
25523
|
+
exports.assertWorkspaceId = assertWorkspaceId;
|
|
25174
25524
|
exports.authDocumentSecurity = authDocumentSecurity;
|
|
25175
25525
|
exports.createAuthValidationPipe = createAuthValidationPipe;
|
|
25526
|
+
exports.decodeWorkspaceCursor = decodeWorkspaceCursor;
|
|
25176
25527
|
exports.decodeWorkspaceScopedName = decodeWorkspaceScopedName;
|
|
25177
25528
|
exports.decrypt = decrypt;
|
|
25178
25529
|
exports.describeChannelStatus = describeChannelStatus;
|
|
25179
25530
|
exports.describeError = describeError;
|
|
25531
|
+
exports.encodeWorkspaceCursor = encodeWorkspaceCursor;
|
|
25180
25532
|
exports.encrypt = encrypt;
|
|
25181
25533
|
exports.generateSecureToken = generateSecureToken;
|
|
25182
25534
|
exports.hasRole = hasRole;
|
|
25183
25535
|
exports.hmacSha256 = hmacSha256;
|
|
25536
|
+
exports.isWorkspaceOwnerRole = isWorkspaceOwnerRole;
|
|
25537
|
+
exports.readWorkspacePosition = readWorkspacePosition;
|
|
25184
25538
|
exports.redactSecrets = redactSecrets;
|
|
25185
25539
|
exports.reduceToBaseWord = reduceToBaseWord;
|
|
25186
25540
|
exports.sanitizeHeaders = sanitizeHeaders;
|
|
@@ -25188,4 +25542,6 @@ exports.sha256 = sha256;
|
|
|
25188
25542
|
exports.sleep = sleep;
|
|
25189
25543
|
exports.stampJobContext = stampJobContext;
|
|
25190
25544
|
exports.timingSafeCompare = timingSafeCompare;
|
|
25545
|
+
exports.workspacePositionOf = workspacePositionOf;
|
|
25546
|
+
exports.workspaceQueryKey = workspaceQueryKey;
|
|
25191
25547
|
exports.workspaceScopedName = workspaceScopedName;
|