@bymax-one/nest-auth 1.5.2 → 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 +134 -1
- package/README.md +209 -1112
- 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 +482 -207
- package/dist/server/index.d.cts +617 -471
- package/dist/server/index.d.ts +617 -471
- package/dist/server/index.mjs +471 -208
- 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.`);
|
|
@@ -892,7 +1002,7 @@ function validatePreviousSecrets(jwt) {
|
|
|
892
1002
|
if (typeof secret !== "string") {
|
|
893
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.`);
|
|
894
1004
|
}
|
|
895
|
-
validateSecretStrength(secret,
|
|
1005
|
+
validateSecretStrength(secret, `jwt.previousSecrets[${index}]`);
|
|
896
1006
|
if (seen.has(secret)) {
|
|
897
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.`);
|
|
898
1008
|
}
|
|
@@ -8945,6 +9055,14 @@ _ts_decorate24([
|
|
|
8945
9055
|
classValidator.Length(64, 64),
|
|
8946
9056
|
_ts_metadata23("design:type", String)
|
|
8947
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
|
|
8948
9066
|
function _ts_decorate25(decorators, target, key, desc) {
|
|
8949
9067
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8950
9068
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -9041,7 +9159,7 @@ exports.EmailChangeService = class _EmailChangeService {
|
|
|
9041
9159
|
if (!user?.passwordHash) {
|
|
9042
9160
|
throw new AuthException(AUTH_ERROR_CODES.INVALID_CREDENTIALS);
|
|
9043
9161
|
}
|
|
9044
|
-
const bfIdentifier =
|
|
9162
|
+
const bfIdentifier = reproofCounterId("email-change", userId, tenantId, this.options.hmacKey);
|
|
9045
9163
|
if (await this.bruteForce.isLockedOut(bfIdentifier)) {
|
|
9046
9164
|
this.logger.warn(`requestChange: account locked userId=${logSafe(userId)}`);
|
|
9047
9165
|
throw new AuthException(AUTH_ERROR_CODES.ACCOUNT_LOCKED);
|
|
@@ -10490,52 +10608,26 @@ var MfaFlowLockoutService = class {
|
|
|
10490
10608
|
this.bruteForce = bruteForce;
|
|
10491
10609
|
}
|
|
10492
10610
|
/**
|
|
10493
|
-
* The
|
|
10494
|
-
*
|
|
10495
|
-
*
|
|
10496
|
-
*
|
|
10497
|
-
*
|
|
10498
|
-
* old pod counts a failure under `{flow}:{plane}:{userId}` while a new pod counts it under
|
|
10499
|
-
* `{flow}:{userSubject}`, and either alone leaves a hole: a lockout an old pod filled would not
|
|
10500
|
-
* stop a new pod, and a success on one would not clear the other. So every read consults both
|
|
10501
|
-
* and every write touches both, and the two move as one; the plane-only arm can be dropped once
|
|
10502
|
-
* no pod writes it. On the platform plane the two ids are identical, so the plane-only arm is
|
|
10503
|
-
* skipped: operating it would be the same key a second time, double-counting a failure and
|
|
10504
|
-
* locking a platform admin out at half the threshold. `{flow}` (`challenge` / `disable` /
|
|
10505
|
-
* `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.
|
|
10506
10616
|
*/
|
|
10507
|
-
|
|
10508
|
-
return {
|
|
10509
|
-
legacy: hmacSha256(`${flow}:${context}:${userId}`, this.options.hmacKey),
|
|
10510
|
-
scoped: hmacSha256(`${flow}:${userSubject(context, userId, tenantId)}`, this.options.hmacKey)
|
|
10511
|
-
};
|
|
10617
|
+
counterId(flow, context, userId, tenantId) {
|
|
10618
|
+
return hmacSha256(`${flow}:${userSubject(context, userId, tenantId)}`, this.options.hmacKey);
|
|
10512
10619
|
}
|
|
10513
|
-
/**
|
|
10514
|
-
* Locked out when EITHER the legacy or the tenant-scoped counter has reached the threshold, so
|
|
10515
|
-
* neither a lockout an old pod recorded nor one a new pod recorded can be bypassed mid-migration.
|
|
10516
|
-
*/
|
|
10620
|
+
/** Whether the account's counter for this flow has reached the lockout threshold. */
|
|
10517
10621
|
async isLockedOut(flow, context, userId, tenantId) {
|
|
10518
|
-
|
|
10519
|
-
if (await this.bruteForce.isLockedOut(scoped)) return true;
|
|
10520
|
-
return legacy !== scoped ? this.bruteForce.isLockedOut(legacy) : false;
|
|
10622
|
+
return this.bruteForce.isLockedOut(this.counterId(flow, context, userId, tenantId));
|
|
10521
10623
|
}
|
|
10522
|
-
/**
|
|
10523
|
-
* Records the failure under both counters so the budget an attacker spends is seen by old and
|
|
10524
|
-
* new code alike — but under the scoped id ONCE when the two coincide (platform plane).
|
|
10525
|
-
*/
|
|
10624
|
+
/** Records a failed attempt against the account's counter for this flow. */
|
|
10526
10625
|
async recordFailure(flow, context, userId, tenantId) {
|
|
10527
|
-
|
|
10528
|
-
await this.bruteForce.recordFailure(scoped);
|
|
10529
|
-
if (legacy !== scoped) await this.bruteForce.recordFailure(legacy);
|
|
10626
|
+
await this.bruteForce.recordFailure(this.counterId(flow, context, userId, tenantId));
|
|
10530
10627
|
}
|
|
10531
|
-
/**
|
|
10532
|
-
* Clears both counters on success — resetting only one would leave the other to lock a
|
|
10533
|
-
* legitimately authenticated user out on the next attempt — collapsing to one when they coincide.
|
|
10534
|
-
*/
|
|
10628
|
+
/** Clears the account's counter for this flow, on a success. */
|
|
10535
10629
|
async reset(flow, context, userId, tenantId) {
|
|
10536
|
-
|
|
10537
|
-
await this.bruteForce.resetFailures(scoped);
|
|
10538
|
-
if (legacy !== scoped) await this.bruteForce.resetFailures(legacy);
|
|
10630
|
+
await this.bruteForce.resetFailures(this.counterId(flow, context, userId, tenantId));
|
|
10539
10631
|
}
|
|
10540
10632
|
};
|
|
10541
10633
|
MfaFlowLockoutService = _ts_decorate37([
|
|
@@ -10792,19 +10884,9 @@ var MfaRecordService = class {
|
|
|
10792
10884
|
* @throws {@link AuthException} `MFA_STATE_CONFLICT` when another transition holds the lock.
|
|
10793
10885
|
*/
|
|
10794
10886
|
async transition(context, userId, tenantId, mutate) {
|
|
10795
|
-
const
|
|
10796
|
-
const legacyLockKey = `mfalock:${hmacSha256(`${context}:${userId}`, this.options.hmacKey)}`;
|
|
10797
|
-
const acquireLegacy = legacyLockKey !== scopedLockKey;
|
|
10887
|
+
const lockKey = `mfalock:${hmacSha256(userSubject(context, userId, tenantId), this.options.hmacKey)}`;
|
|
10798
10888
|
const lockToken = crypto.randomBytes(16).toString("hex");
|
|
10799
|
-
if (!await this.redis.setIfAbsent(
|
|
10800
|
-
throw new AuthException(AUTH_ERROR_CODES.MFA_STATE_CONFLICT);
|
|
10801
|
-
}
|
|
10802
|
-
if (acquireLegacy && !await this.redis.setIfAbsent(legacyLockKey, lockToken, MFA_TRANSITION_LOCK_TTL_SECONDS)) {
|
|
10803
|
-
await this.redis.eval(RELEASE_LOCK_LUA, [
|
|
10804
|
-
scopedLockKey
|
|
10805
|
-
], [
|
|
10806
|
-
lockToken
|
|
10807
|
-
]);
|
|
10889
|
+
if (!await this.redis.setIfAbsent(lockKey, lockToken, MFA_TRANSITION_LOCK_TTL_SECONDS)) {
|
|
10808
10890
|
throw new AuthException(AUTH_ERROR_CODES.MFA_STATE_CONFLICT);
|
|
10809
10891
|
}
|
|
10810
10892
|
try {
|
|
@@ -10829,17 +10911,10 @@ var MfaRecordService = class {
|
|
|
10829
10911
|
return true;
|
|
10830
10912
|
} finally {
|
|
10831
10913
|
await this.redis.eval(RELEASE_LOCK_LUA, [
|
|
10832
|
-
|
|
10914
|
+
lockKey
|
|
10833
10915
|
], [
|
|
10834
10916
|
lockToken
|
|
10835
10917
|
]);
|
|
10836
|
-
if (acquireLegacy) {
|
|
10837
|
-
await this.redis.eval(RELEASE_LOCK_LUA, [
|
|
10838
|
-
legacyLockKey
|
|
10839
|
-
], [
|
|
10840
|
-
lockToken
|
|
10841
|
-
]);
|
|
10842
|
-
}
|
|
10843
10918
|
}
|
|
10844
10919
|
}
|
|
10845
10920
|
/**
|
|
@@ -10881,21 +10956,13 @@ var MfaRecordService = class {
|
|
|
10881
10956
|
* both the subject and the code value prevents code disclosure in Redis and cross-user,
|
|
10882
10957
|
* cross-tenant and cross-plane replay alike.
|
|
10883
10958
|
*
|
|
10884
|
-
* A second marker under the plane-only preimage `{context}:{userId}:{code}` is written and
|
|
10885
|
-
* required alongside it; see the call site for why both must be fresh while pods of two
|
|
10886
|
-
* versions are live.
|
|
10887
|
-
*
|
|
10888
10959
|
* @returns `true` if the code is valid and has not been replayed, `false` otherwise.
|
|
10889
10960
|
*/
|
|
10890
10961
|
async verifyTotpWithAntiReplay(context, userId, secretBase32, code, window, tenantId) {
|
|
10891
10962
|
if (!verifyTotp(secretBase32, code, window)) return false;
|
|
10892
10963
|
const ttl = totpAntiReplayTtlSeconds(window);
|
|
10893
|
-
const
|
|
10894
|
-
|
|
10895
|
-
const scopedIsNew = await this.redis.setnx(scopedReplayKey, ttl);
|
|
10896
|
-
if (scopedReplayKey === legacyReplayKey) return scopedIsNew;
|
|
10897
|
-
const legacyIsNew = await this.redis.setnx(legacyReplayKey, ttl);
|
|
10898
|
-
return scopedIsNew && legacyIsNew;
|
|
10964
|
+
const replayKey = `tu:${hmacSha256(`${userSubject(context, userId, tenantId)}:${code}`, this.options.hmacKey)}`;
|
|
10965
|
+
return await this.redis.setnx(replayKey, ttl);
|
|
10899
10966
|
}
|
|
10900
10967
|
/**
|
|
10901
10968
|
* Fetches a user from the correct repository based on the MFA context, and refuses one whose
|
|
@@ -13320,7 +13387,7 @@ exports.PasswordResetService = class _PasswordResetService {
|
|
|
13320
13387
|
if (!user?.passwordHash) {
|
|
13321
13388
|
throw new AuthException(AUTH_ERROR_CODES.INVALID_CREDENTIALS);
|
|
13322
13389
|
}
|
|
13323
|
-
const bfIdentifier =
|
|
13390
|
+
const bfIdentifier = reproofCounterId("change-password", userId, tenantId, this.options.hmacKey);
|
|
13324
13391
|
if (await this.bruteForce.isLockedOut(bfIdentifier)) {
|
|
13325
13392
|
this.logger.warn(`changePassword: account locked userId=${logSafe(userId)}`);
|
|
13326
13393
|
throw new AuthException(AUTH_ERROR_CODES.ACCOUNT_LOCKED);
|
|
@@ -15205,7 +15272,8 @@ var WorkspacePageQueryDto = class {
|
|
|
15205
15272
|
/**
|
|
15206
15273
|
* The `nextCursor` of the previous page; absent for the first page.
|
|
15207
15274
|
*
|
|
15208
|
-
*
|
|
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.
|
|
15209
15277
|
*/
|
|
15210
15278
|
cursor;
|
|
15211
15279
|
/**
|
|
@@ -15219,7 +15287,7 @@ _ts_decorate62([
|
|
|
15219
15287
|
classValidator.IsOptional(),
|
|
15220
15288
|
classValidator.IsString(),
|
|
15221
15289
|
classValidator.IsNotEmpty(),
|
|
15222
|
-
classValidator.MaxLength(
|
|
15290
|
+
classValidator.MaxLength(WORKSPACE_CURSOR_MAX_LENGTH),
|
|
15223
15291
|
classValidator.Matches(NO_CONTROL_CHARACTERS, {
|
|
15224
15292
|
message: "cursor must not contain control characters"
|
|
15225
15293
|
}),
|
|
@@ -15289,8 +15357,8 @@ function membershipCacheKeyBase(tenantId, workspaceId, userId, hmacKey) {
|
|
|
15289
15357
|
__name(membershipCacheKeyBase, "membershipCacheKeyBase");
|
|
15290
15358
|
|
|
15291
15359
|
// src/server/utils/resolve-request-workspace.ts
|
|
15292
|
-
var
|
|
15293
|
-
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`;
|
|
15294
15362
|
function invalidWorkspaceId(message) {
|
|
15295
15363
|
throw new AuthException(AUTH_ERROR_CODES.VALIDATION, [
|
|
15296
15364
|
{
|
|
@@ -15301,7 +15369,7 @@ function invalidWorkspaceId(message) {
|
|
|
15301
15369
|
}
|
|
15302
15370
|
__name(invalidWorkspaceId, "invalidWorkspaceId");
|
|
15303
15371
|
function assertWorkspaceId(value) {
|
|
15304
|
-
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)) {
|
|
15305
15373
|
return invalidWorkspaceId(WORKSPACE_ID_RULE);
|
|
15306
15374
|
}
|
|
15307
15375
|
return value;
|
|
@@ -20211,6 +20279,32 @@ function isStoredOAuthState(value) {
|
|
|
20211
20279
|
}
|
|
20212
20280
|
__name(isStoredOAuthState, "isStoredOAuthState");
|
|
20213
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
|
+
|
|
20214
20308
|
// src/server/constants/oauth-state-cookie.ts
|
|
20215
20309
|
var OAUTH_STATE_COOKIE_NAME = "oauth_state";
|
|
20216
20310
|
var OAUTH_STATE_COOKIE_SAME_SITE = "lax";
|
|
@@ -20573,12 +20667,15 @@ exports.OAuthService = class _OAuthService {
|
|
|
20573
20667
|
* @param code - The authorization code.
|
|
20574
20668
|
* @param codeVerifier - The PKCE verifier stored with the state.
|
|
20575
20669
|
* @returns The normalized profile.
|
|
20576
|
-
* @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.
|
|
20577
20672
|
*/
|
|
20578
20673
|
async fetchProfile(plugin, provider, code, codeVerifier) {
|
|
20579
20674
|
try {
|
|
20580
|
-
|
|
20581
|
-
|
|
20675
|
+
return await withDeadline(async () => {
|
|
20676
|
+
const tokenResponse = await plugin.exchangeCode(code, codeVerifier);
|
|
20677
|
+
return await plugin.fetchProfile(tokenResponse.access_token);
|
|
20678
|
+
}, pluginDeadlineMs(plugin));
|
|
20582
20679
|
} catch (err) {
|
|
20583
20680
|
this.logger.error(`OAuth plugin '${provider}' failed during code exchange or profile fetch: ` + describeChannelStatus(err));
|
|
20584
20681
|
throw new AuthException(AUTH_ERROR_CODES.OAUTH_FAILED);
|
|
@@ -21298,6 +21395,11 @@ var GoogleOAuthPlugin = class {
|
|
|
21298
21395
|
}
|
|
21299
21396
|
/** Stable provider identifier used as a route segment and storage key. */
|
|
21300
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;
|
|
21301
21403
|
clientId;
|
|
21302
21404
|
/** The Google client secret, withheld from serialization. */
|
|
21303
21405
|
#clientSecret;
|
|
@@ -22191,7 +22293,7 @@ var REQUEST_SCHEMAS = {
|
|
|
22191
22293
|
"cursor": {
|
|
22192
22294
|
"type": "string",
|
|
22193
22295
|
"pattern": "^[^\\u0000-\\u001F\\u007F-\\u009F]+$",
|
|
22194
|
-
"maxLength":
|
|
22296
|
+
"maxLength": 4096,
|
|
22195
22297
|
"minLength": 1
|
|
22196
22298
|
},
|
|
22197
22299
|
"limit": {
|
|
@@ -23137,6 +23239,164 @@ exports.NoOpEmailProvider = class _NoOpEmailProvider {
|
|
|
23137
23239
|
exports.NoOpEmailProvider = _ts_decorate97([
|
|
23138
23240
|
common.Injectable()
|
|
23139
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);
|
|
23140
23400
|
|
|
23141
23401
|
// src/server/services/api-key-clock.ts
|
|
23142
23402
|
var SystemApiKeyClock = class {
|
|
@@ -23148,7 +23408,7 @@ var SystemApiKeyClock = class {
|
|
|
23148
23408
|
return /* @__PURE__ */ new Date();
|
|
23149
23409
|
}
|
|
23150
23410
|
};
|
|
23151
|
-
function
|
|
23411
|
+
function _ts_decorate99(decorators, target, key, desc) {
|
|
23152
23412
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
23153
23413
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
23154
23414
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -23161,19 +23421,19 @@ function _ts_decorate98(decorators, target, key, desc) {
|
|
|
23161
23421
|
}
|
|
23162
23422
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23163
23423
|
}
|
|
23164
|
-
__name(
|
|
23165
|
-
function
|
|
23424
|
+
__name(_ts_decorate99, "_ts_decorate");
|
|
23425
|
+
function _ts_metadata95(metadataKey, metadataValue) {
|
|
23166
23426
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
23167
23427
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
23168
23428
|
}
|
|
23169
23429
|
}
|
|
23170
|
-
__name(
|
|
23171
|
-
function
|
|
23430
|
+
__name(_ts_metadata95, "_ts_metadata");
|
|
23431
|
+
function _ts_param60(paramIndex, decorator) {
|
|
23172
23432
|
return function(target, key) {
|
|
23173
23433
|
decorator(target, key, paramIndex);
|
|
23174
23434
|
};
|
|
23175
23435
|
}
|
|
23176
|
-
__name(
|
|
23436
|
+
__name(_ts_param60, "_ts_param");
|
|
23177
23437
|
var ApiKeyScopeAuditService = class {
|
|
23178
23438
|
static {
|
|
23179
23439
|
__name(this, "ApiKeyScopeAuditService");
|
|
@@ -23216,21 +23476,21 @@ var ApiKeyScopeAuditService = class {
|
|
|
23216
23476
|
}
|
|
23217
23477
|
}
|
|
23218
23478
|
};
|
|
23219
|
-
ApiKeyScopeAuditService =
|
|
23479
|
+
ApiKeyScopeAuditService = _ts_decorate99([
|
|
23220
23480
|
common.Injectable(),
|
|
23221
|
-
|
|
23222
|
-
|
|
23223
|
-
|
|
23224
|
-
|
|
23225
|
-
|
|
23226
|
-
|
|
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", [
|
|
23227
23487
|
typeof core.DiscoveryService === "undefined" ? Object : core.DiscoveryService,
|
|
23228
23488
|
typeof core.MetadataScanner === "undefined" ? Object : core.MetadataScanner,
|
|
23229
23489
|
typeof core.Reflector === "undefined" ? Object : core.Reflector,
|
|
23230
23490
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
|
|
23231
23491
|
])
|
|
23232
23492
|
], ApiKeyScopeAuditService);
|
|
23233
|
-
function
|
|
23493
|
+
function _ts_decorate100(decorators, target, key, desc) {
|
|
23234
23494
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
23235
23495
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
23236
23496
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -23243,19 +23503,19 @@ function _ts_decorate99(decorators, target, key, desc) {
|
|
|
23243
23503
|
}
|
|
23244
23504
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23245
23505
|
}
|
|
23246
|
-
__name(
|
|
23247
|
-
function
|
|
23506
|
+
__name(_ts_decorate100, "_ts_decorate");
|
|
23507
|
+
function _ts_metadata96(metadataKey, metadataValue) {
|
|
23248
23508
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
23249
23509
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
23250
23510
|
}
|
|
23251
23511
|
}
|
|
23252
|
-
__name(
|
|
23253
|
-
function
|
|
23512
|
+
__name(_ts_metadata96, "_ts_metadata");
|
|
23513
|
+
function _ts_param61(paramIndex, decorator) {
|
|
23254
23514
|
return function(target, key) {
|
|
23255
23515
|
decorator(target, key, paramIndex);
|
|
23256
23516
|
};
|
|
23257
23517
|
}
|
|
23258
|
-
__name(
|
|
23518
|
+
__name(_ts_param61, "_ts_param");
|
|
23259
23519
|
var API_KEY_MAX_LABEL_LENGTH = 128;
|
|
23260
23520
|
var API_KEY_MAX_OVERLAP_SECONDS = 2592e3;
|
|
23261
23521
|
var CONTROL_CHARACTERS = /[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/u;
|
|
@@ -23393,13 +23653,13 @@ exports.ApiKeyService = class ApiKeyService {
|
|
|
23393
23653
|
return value;
|
|
23394
23654
|
}
|
|
23395
23655
|
};
|
|
23396
|
-
exports.ApiKeyService =
|
|
23656
|
+
exports.ApiKeyService = _ts_decorate100([
|
|
23397
23657
|
common.Injectable(),
|
|
23398
|
-
|
|
23399
|
-
|
|
23400
|
-
|
|
23401
|
-
|
|
23402
|
-
|
|
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", [
|
|
23403
23663
|
typeof IApiKeyRepository === "undefined" ? Object : IApiKeyRepository,
|
|
23404
23664
|
typeof ApiKeyClock === "undefined" ? Object : ApiKeyClock,
|
|
23405
23665
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
|
|
@@ -23481,7 +23741,7 @@ async function assertTenantBinding(options, handshake, tenantId) {
|
|
|
23481
23741
|
__name(assertTenantBinding, "assertTenantBinding");
|
|
23482
23742
|
|
|
23483
23743
|
// src/server/services/auth-token-verifier.service.ts
|
|
23484
|
-
function
|
|
23744
|
+
function _ts_decorate101(decorators, target, key, desc) {
|
|
23485
23745
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
23486
23746
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
23487
23747
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -23494,19 +23754,19 @@ function _ts_decorate100(decorators, target, key, desc) {
|
|
|
23494
23754
|
}
|
|
23495
23755
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23496
23756
|
}
|
|
23497
|
-
__name(
|
|
23498
|
-
function
|
|
23757
|
+
__name(_ts_decorate101, "_ts_decorate");
|
|
23758
|
+
function _ts_metadata97(metadataKey, metadataValue) {
|
|
23499
23759
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
23500
23760
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
23501
23761
|
}
|
|
23502
23762
|
}
|
|
23503
|
-
__name(
|
|
23504
|
-
function
|
|
23763
|
+
__name(_ts_metadata97, "_ts_metadata");
|
|
23764
|
+
function _ts_param62(paramIndex, decorator) {
|
|
23505
23765
|
return function(target, key) {
|
|
23506
23766
|
decorator(target, key, paramIndex);
|
|
23507
23767
|
};
|
|
23508
23768
|
}
|
|
23509
|
-
__name(
|
|
23769
|
+
__name(_ts_param62, "_ts_param");
|
|
23510
23770
|
exports.AuthTokenVerifierService = class _AuthTokenVerifierService {
|
|
23511
23771
|
static {
|
|
23512
23772
|
__name(this, "AuthTokenVerifierService");
|
|
@@ -23586,11 +23846,14 @@ exports.AuthTokenVerifierService = class _AuthTokenVerifierService {
|
|
|
23586
23846
|
};
|
|
23587
23847
|
}
|
|
23588
23848
|
/**
|
|
23589
|
-
* The function that admits a caller to a workspace
|
|
23590
|
-
*
|
|
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.
|
|
23591
23854
|
*
|
|
23592
|
-
*
|
|
23593
|
-
* 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.
|
|
23594
23857
|
*/
|
|
23595
23858
|
workspaceResolver(plane) {
|
|
23596
23859
|
if (plane !== "dashboard") {
|
|
@@ -23600,7 +23863,12 @@ exports.AuthTokenVerifierService = class _AuthTokenVerifierService {
|
|
|
23600
23863
|
const group = this.options.workspaces;
|
|
23601
23864
|
const denied = this.deniedEvents;
|
|
23602
23865
|
if (access === null || group === void 0) {
|
|
23603
|
-
|
|
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
|
+
]));
|
|
23604
23872
|
}
|
|
23605
23873
|
return async (payload, check) => {
|
|
23606
23874
|
const workspaceId = assertWorkspaceId(check.workspaceId);
|
|
@@ -23708,18 +23976,18 @@ exports.AuthTokenVerifierService = class _AuthTokenVerifierService {
|
|
|
23708
23976
|
}
|
|
23709
23977
|
}
|
|
23710
23978
|
};
|
|
23711
|
-
exports.AuthTokenVerifierService =
|
|
23979
|
+
exports.AuthTokenVerifierService = _ts_decorate101([
|
|
23712
23980
|
common.Injectable(),
|
|
23713
|
-
|
|
23714
|
-
|
|
23715
|
-
|
|
23716
|
-
|
|
23717
|
-
|
|
23718
|
-
|
|
23719
|
-
|
|
23720
|
-
|
|
23721
|
-
|
|
23722
|
-
|
|
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", [
|
|
23723
23991
|
typeof jwt.JwtService === "undefined" ? Object : jwt.JwtService,
|
|
23724
23992
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
|
|
23725
23993
|
typeof exports.AuthRevocationService === "undefined" ? Object : exports.AuthRevocationService,
|
|
@@ -23730,7 +23998,7 @@ exports.AuthTokenVerifierService = _ts_decorate100([
|
|
|
23730
23998
|
], exports.AuthTokenVerifierService);
|
|
23731
23999
|
|
|
23732
24000
|
// src/server/bymax-auth.module.ts
|
|
23733
|
-
function
|
|
24001
|
+
function _ts_decorate102(decorators, target, key, desc) {
|
|
23734
24002
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
23735
24003
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
23736
24004
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -23743,7 +24011,7 @@ function _ts_decorate101(decorators, target, key, desc) {
|
|
|
23743
24011
|
}
|
|
23744
24012
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23745
24013
|
}
|
|
23746
|
-
__name(
|
|
24014
|
+
__name(_ts_decorate102, "_ts_decorate");
|
|
23747
24015
|
function hasProviderToken(providers, token) {
|
|
23748
24016
|
return providers.some((p) => {
|
|
23749
24017
|
if (typeof p === "function") return false;
|
|
@@ -24015,10 +24283,10 @@ exports.BymaxAuthModule = class _BymaxAuthModule {
|
|
|
24015
24283
|
...breachCheckerProviders,
|
|
24016
24284
|
...hooksProviders,
|
|
24017
24285
|
// Core services.
|
|
24018
|
-
// AuthRedisService is registered directly (not via AuthRedisModule) so that
|
|
24019
|
-
//
|
|
24020
|
-
// 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.
|
|
24021
24288
|
AuthRedisService,
|
|
24289
|
+
RedisReadinessService,
|
|
24022
24290
|
exports.AuthRevocationService,
|
|
24023
24291
|
exports.AccountStatusService,
|
|
24024
24292
|
exports.AuthTokenVerifierService,
|
|
@@ -24133,9 +24401,9 @@ exports.BymaxAuthModule = class _BymaxAuthModule {
|
|
|
24133
24401
|
// exported for the same @UseGuards() reason as the entries around it: the guard is
|
|
24134
24402
|
// re-instantiated in the consumer's injector, where an unexported dep fails their boot.
|
|
24135
24403
|
exports.AccountStatusService,
|
|
24136
|
-
// AuthTokenVerifierService is
|
|
24137
|
-
//
|
|
24138
|
-
//
|
|
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.
|
|
24139
24407
|
exports.AuthTokenVerifierService,
|
|
24140
24408
|
// Same reason, for the two exported guards whose remaining constructor deps are not
|
|
24141
24409
|
// covered by the entries above. Exporting the guard class is necessary but not
|
|
@@ -24144,7 +24412,7 @@ exports.BymaxAuthModule = class _BymaxAuthModule {
|
|
|
24144
24412
|
// UnknownDependenciesException even though the guard itself is exported.
|
|
24145
24413
|
//
|
|
24146
24414
|
// UserStatusGuard -> AccountStatusService
|
|
24147
|
-
// WsJwtGuard -> WsTicketService
|
|
24415
|
+
// WsJwtGuard -> AuthTokenVerifierService, WsTicketService
|
|
24148
24416
|
//
|
|
24149
24417
|
// Only the DIRECT dependency needs exporting. An exported provider arrives already
|
|
24150
24418
|
// instantiated, so the consumer's injector binds that instance and never re-resolves its
|
|
@@ -24188,7 +24456,7 @@ exports.BymaxAuthModule = class _BymaxAuthModule {
|
|
|
24188
24456
|
};
|
|
24189
24457
|
}
|
|
24190
24458
|
};
|
|
24191
|
-
exports.BymaxAuthModule =
|
|
24459
|
+
exports.BymaxAuthModule = _ts_decorate102([
|
|
24192
24460
|
common.Module({})
|
|
24193
24461
|
], exports.BymaxAuthModule);
|
|
24194
24462
|
|
|
@@ -24563,7 +24831,7 @@ var DefaultAuthEmailProvider = class _DefaultAuthEmailProvider {
|
|
|
24563
24831
|
}
|
|
24564
24832
|
}
|
|
24565
24833
|
};
|
|
24566
|
-
function
|
|
24834
|
+
function _ts_decorate103(decorators, target, key, desc) {
|
|
24567
24835
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24568
24836
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
24569
24837
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -24576,13 +24844,13 @@ function _ts_decorate102(decorators, target, key, desc) {
|
|
|
24576
24844
|
}
|
|
24577
24845
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
24578
24846
|
}
|
|
24579
|
-
__name(
|
|
24580
|
-
function
|
|
24847
|
+
__name(_ts_decorate103, "_ts_decorate");
|
|
24848
|
+
function _ts_metadata98(metadataKey, metadataValue) {
|
|
24581
24849
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
24582
24850
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
24583
24851
|
}
|
|
24584
24852
|
}
|
|
24585
|
-
__name(
|
|
24853
|
+
__name(_ts_metadata98, "_ts_metadata");
|
|
24586
24854
|
var HIBP_RANGE_URL = "https://api.pwnedpasswords.com/range/";
|
|
24587
24855
|
var PREFIX_LENGTH = 5;
|
|
24588
24856
|
var DEFAULT_TIMEOUT_MS = 1500;
|
|
@@ -24639,10 +24907,10 @@ exports.HibpBreachChecker = class _HibpBreachChecker {
|
|
|
24639
24907
|
}
|
|
24640
24908
|
}
|
|
24641
24909
|
};
|
|
24642
|
-
exports.HibpBreachChecker =
|
|
24910
|
+
exports.HibpBreachChecker = _ts_decorate103([
|
|
24643
24911
|
common.Injectable(),
|
|
24644
|
-
|
|
24645
|
-
|
|
24912
|
+
_ts_metadata98("design:type", Function),
|
|
24913
|
+
_ts_metadata98("design:paramtypes", [
|
|
24646
24914
|
Number
|
|
24647
24915
|
])
|
|
24648
24916
|
], exports.HibpBreachChecker);
|
|
@@ -24655,10 +24923,10 @@ exports.AllowAllBreachChecker = class AllowAllBreachChecker {
|
|
|
24655
24923
|
return false;
|
|
24656
24924
|
}
|
|
24657
24925
|
};
|
|
24658
|
-
exports.AllowAllBreachChecker =
|
|
24926
|
+
exports.AllowAllBreachChecker = _ts_decorate103([
|
|
24659
24927
|
common.Injectable()
|
|
24660
24928
|
], exports.AllowAllBreachChecker);
|
|
24661
|
-
function
|
|
24929
|
+
function _ts_decorate104(decorators, target, key, desc) {
|
|
24662
24930
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24663
24931
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
24664
24932
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -24671,7 +24939,7 @@ function _ts_decorate103(decorators, target, key, desc) {
|
|
|
24671
24939
|
}
|
|
24672
24940
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
24673
24941
|
}
|
|
24674
|
-
__name(
|
|
24942
|
+
__name(_ts_decorate104, "_ts_decorate");
|
|
24675
24943
|
exports.OptionalAuthGuard = class OptionalAuthGuard extends exports.JwtAuthGuard {
|
|
24676
24944
|
static {
|
|
24677
24945
|
__name(this, "OptionalAuthGuard");
|
|
@@ -24686,10 +24954,10 @@ exports.OptionalAuthGuard = class OptionalAuthGuard extends exports.JwtAuthGuard
|
|
|
24686
24954
|
return super.canActivate(context);
|
|
24687
24955
|
}
|
|
24688
24956
|
};
|
|
24689
|
-
exports.OptionalAuthGuard =
|
|
24957
|
+
exports.OptionalAuthGuard = _ts_decorate104([
|
|
24690
24958
|
common.Injectable()
|
|
24691
24959
|
], exports.OptionalAuthGuard);
|
|
24692
|
-
function
|
|
24960
|
+
function _ts_decorate105(decorators, target, key, desc) {
|
|
24693
24961
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24694
24962
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
24695
24963
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -24702,19 +24970,19 @@ function _ts_decorate104(decorators, target, key, desc) {
|
|
|
24702
24970
|
}
|
|
24703
24971
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
24704
24972
|
}
|
|
24705
|
-
__name(
|
|
24706
|
-
function
|
|
24973
|
+
__name(_ts_decorate105, "_ts_decorate");
|
|
24974
|
+
function _ts_metadata99(metadataKey, metadataValue) {
|
|
24707
24975
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
24708
24976
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
24709
24977
|
}
|
|
24710
24978
|
}
|
|
24711
|
-
__name(
|
|
24712
|
-
function
|
|
24979
|
+
__name(_ts_metadata99, "_ts_metadata");
|
|
24980
|
+
function _ts_param63(paramIndex, decorator) {
|
|
24713
24981
|
return function(target, key) {
|
|
24714
24982
|
decorator(target, key, paramIndex);
|
|
24715
24983
|
};
|
|
24716
24984
|
}
|
|
24717
|
-
__name(
|
|
24985
|
+
__name(_ts_param63, "_ts_param");
|
|
24718
24986
|
exports.SelfOrAdminGuard = class SelfOrAdminGuard {
|
|
24719
24987
|
static {
|
|
24720
24988
|
__name(this, "SelfOrAdminGuard");
|
|
@@ -24750,11 +25018,11 @@ exports.SelfOrAdminGuard = class SelfOrAdminGuard {
|
|
|
24750
25018
|
throw new AuthException(AUTH_ERROR_CODES.INSUFFICIENT_ROLE);
|
|
24751
25019
|
}
|
|
24752
25020
|
};
|
|
24753
|
-
exports.SelfOrAdminGuard =
|
|
25021
|
+
exports.SelfOrAdminGuard = _ts_decorate105([
|
|
24754
25022
|
common.Injectable(),
|
|
24755
|
-
|
|
24756
|
-
|
|
24757
|
-
|
|
25023
|
+
_ts_param63(0, common.Inject(BYMAX_AUTH_OPTIONS)),
|
|
25024
|
+
_ts_metadata99("design:type", Function),
|
|
25025
|
+
_ts_metadata99("design:paramtypes", [
|
|
24758
25026
|
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
|
|
24759
25027
|
])
|
|
24760
25028
|
], exports.SelfOrAdminGuard);
|
|
@@ -24776,7 +25044,7 @@ function isHexLooking(value) {
|
|
|
24776
25044
|
return value.length === 64 && /^[a-fA-F0-9]{64}$/.test(value);
|
|
24777
25045
|
}
|
|
24778
25046
|
__name(isHexLooking, "isHexLooking");
|
|
24779
|
-
function
|
|
25047
|
+
function _ts_decorate106(decorators, target, key, desc) {
|
|
24780
25048
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24781
25049
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
24782
25050
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -24789,32 +25057,32 @@ function _ts_decorate105(decorators, target, key, desc) {
|
|
|
24789
25057
|
}
|
|
24790
25058
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
24791
25059
|
}
|
|
24792
|
-
__name(
|
|
24793
|
-
function
|
|
25060
|
+
__name(_ts_decorate106, "_ts_decorate");
|
|
25061
|
+
function _ts_metadata100(metadataKey, metadataValue) {
|
|
24794
25062
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
24795
25063
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
24796
25064
|
}
|
|
24797
25065
|
}
|
|
24798
|
-
__name(
|
|
24799
|
-
function
|
|
25066
|
+
__name(_ts_metadata100, "_ts_metadata");
|
|
25067
|
+
function _ts_param64(paramIndex, decorator) {
|
|
24800
25068
|
return function(target, key) {
|
|
24801
25069
|
decorator(target, key, paramIndex);
|
|
24802
25070
|
};
|
|
24803
25071
|
}
|
|
24804
|
-
__name(
|
|
25072
|
+
__name(_ts_param64, "_ts_param");
|
|
24805
25073
|
exports.WsJwtGuard = class WsJwtGuard {
|
|
24806
25074
|
static {
|
|
24807
25075
|
__name(this, "WsJwtGuard");
|
|
24808
25076
|
}
|
|
24809
|
-
|
|
24810
|
-
revocation;
|
|
25077
|
+
verifier;
|
|
24811
25078
|
wsTickets;
|
|
24812
25079
|
options;
|
|
24813
|
-
|
|
24814
|
-
|
|
24815
|
-
this.
|
|
25080
|
+
reflector;
|
|
25081
|
+
constructor(verifier, wsTickets, options, reflector) {
|
|
25082
|
+
this.verifier = verifier;
|
|
24816
25083
|
this.wsTickets = wsTickets;
|
|
24817
25084
|
this.options = options;
|
|
25085
|
+
this.reflector = reflector;
|
|
24818
25086
|
}
|
|
24819
25087
|
/**
|
|
24820
25088
|
* Verifies that `@nestjs/websockets` is installed and throws a descriptive
|
|
@@ -24846,37 +25114,32 @@ exports.WsJwtGuard = class WsJwtGuard {
|
|
|
24846
25114
|
if (!token) {
|
|
24847
25115
|
throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
|
|
24848
25116
|
}
|
|
24849
|
-
|
|
24850
|
-
|
|
24851
|
-
|
|
24852
|
-
|
|
24853
|
-
|
|
24854
|
-
|
|
24855
|
-
|
|
24856
|
-
|
|
24857
|
-
|
|
24858
|
-
|
|
24859
|
-
|
|
24860
|
-
if (await this.revocation.isAccessTokenRevoked(payload)) {
|
|
24861
|
-
throw new AuthException(AUTH_ERROR_CODES.TOKEN_INVALID);
|
|
24862
|
-
}
|
|
24863
|
-
await assertTenantBinding(this.options, bindingInput(handshake), payload.tenantId);
|
|
24864
|
-
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;
|
|
24865
25128
|
return true;
|
|
24866
25129
|
}
|
|
24867
25130
|
};
|
|
24868
|
-
exports.WsJwtGuard =
|
|
25131
|
+
exports.WsJwtGuard = _ts_decorate106([
|
|
24869
25132
|
common.Injectable(),
|
|
24870
|
-
|
|
24871
|
-
|
|
24872
|
-
|
|
24873
|
-
|
|
24874
|
-
|
|
24875
|
-
|
|
24876
|
-
typeof
|
|
24877
|
-
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,
|
|
24878
25140
|
typeof exports.WsTicketService === "undefined" ? Object : exports.WsTicketService,
|
|
24879
|
-
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions
|
|
25141
|
+
typeof ResolvedOptions === "undefined" ? Object : ResolvedOptions,
|
|
25142
|
+
typeof core.Reflector === "undefined" ? Object : core.Reflector
|
|
24880
25143
|
])
|
|
24881
25144
|
], exports.WsJwtGuard);
|
|
24882
25145
|
function assertDashboardSnapshot(snapshot) {
|
|
@@ -24912,7 +25175,7 @@ function bindingInput(handshake) {
|
|
|
24912
25175
|
};
|
|
24913
25176
|
}
|
|
24914
25177
|
__name(bindingInput, "bindingInput");
|
|
24915
|
-
function
|
|
25178
|
+
function _ts_decorate107(decorators, target, key, desc) {
|
|
24916
25179
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24917
25180
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
24918
25181
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -24925,7 +25188,7 @@ function _ts_decorate106(decorators, target, key, desc) {
|
|
|
24925
25188
|
}
|
|
24926
25189
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
24927
25190
|
}
|
|
24928
|
-
__name(
|
|
25191
|
+
__name(_ts_decorate107, "_ts_decorate");
|
|
24929
25192
|
function isAuthEnvelope(body) {
|
|
24930
25193
|
if (typeof body !== "object" || body === null) return false;
|
|
24931
25194
|
const error = body.error;
|
|
@@ -25044,10 +25307,10 @@ exports.AuthExceptionFilter = class _AuthExceptionFilter {
|
|
|
25044
25307
|
});
|
|
25045
25308
|
}
|
|
25046
25309
|
};
|
|
25047
|
-
exports.AuthExceptionFilter =
|
|
25310
|
+
exports.AuthExceptionFilter = _ts_decorate107([
|
|
25048
25311
|
common.Catch()
|
|
25049
25312
|
], exports.AuthExceptionFilter);
|
|
25050
|
-
function
|
|
25313
|
+
function _ts_decorate108(decorators, target, key, desc) {
|
|
25051
25314
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
25052
25315
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
25053
25316
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -25060,7 +25323,7 @@ function _ts_decorate107(decorators, target, key, desc) {
|
|
|
25060
25323
|
}
|
|
25061
25324
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
25062
25325
|
}
|
|
25063
|
-
__name(
|
|
25326
|
+
__name(_ts_decorate108, "_ts_decorate");
|
|
25064
25327
|
function isEmittingClient(client) {
|
|
25065
25328
|
return typeof client?.emit === "function";
|
|
25066
25329
|
}
|
|
@@ -25104,7 +25367,7 @@ exports.WsAuthExceptionFilter = class _WsAuthExceptionFilter {
|
|
|
25104
25367
|
this.logger.error(`refused a request on a client this filter cannot answer: ${describeChannelStatus(exception)}`);
|
|
25105
25368
|
}
|
|
25106
25369
|
};
|
|
25107
|
-
exports.WsAuthExceptionFilter =
|
|
25370
|
+
exports.WsAuthExceptionFilter = _ts_decorate108([
|
|
25108
25371
|
common.Catch(AuthException)
|
|
25109
25372
|
], exports.WsAuthExceptionFilter);
|
|
25110
25373
|
var ServiceKey = /* @__PURE__ */ __name((...scopes) => common.applyDecorators(common.SetMetadata(IS_PUBLIC_KEY, true), ApiKeyScopes(...scopes), common.UseGuards(exports.ApiKeyGuard)), "ServiceKey");
|
|
@@ -25118,7 +25381,7 @@ var CurrentWsWorkspace = common.createParamDecorator((_data, context) => {
|
|
|
25118
25381
|
});
|
|
25119
25382
|
|
|
25120
25383
|
// src/server/utils/workspace-scoped.ts
|
|
25121
|
-
var
|
|
25384
|
+
var UNPAIRED_SURROGATE2 = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;
|
|
25122
25385
|
function workspaceScopedName(tenantId, workspaceId, ...parts) {
|
|
25123
25386
|
const pieces = [
|
|
25124
25387
|
tenantId,
|
|
@@ -25130,7 +25393,7 @@ function workspaceScopedName(tenantId, workspaceId, ...parts) {
|
|
|
25130
25393
|
}
|
|
25131
25394
|
__name(workspaceScopedName, "workspaceScopedName");
|
|
25132
25395
|
function decodeWorkspaceScopedName(name) {
|
|
25133
|
-
if (
|
|
25396
|
+
if (UNPAIRED_SURROGATE2.test(name)) throw malformed(name);
|
|
25134
25397
|
const bytes = Buffer.from(name, "utf8");
|
|
25135
25398
|
const pieces = [];
|
|
25136
25399
|
let at = 0;
|
|
@@ -25171,7 +25434,7 @@ function assertPiece(piece, index) {
|
|
|
25171
25434
|
if (hasControl(piece)) {
|
|
25172
25435
|
throw new TypeError(`${label} must not contain a control character`);
|
|
25173
25436
|
}
|
|
25174
|
-
if (
|
|
25437
|
+
if (UNPAIRED_SURROGATE2.test(piece)) throw new TypeError(`${label} must be well-formed Unicode`);
|
|
25175
25438
|
}
|
|
25176
25439
|
__name(assertPiece, "assertPiece");
|
|
25177
25440
|
function malformed(name) {
|
|
@@ -25197,6 +25460,7 @@ exports.AUTH_EMAIL_KINDS = AUTH_EMAIL_KINDS;
|
|
|
25197
25460
|
exports.AUTH_ERROR_CODES = AUTH_ERROR_CODES;
|
|
25198
25461
|
exports.AUTH_ERROR_MESSAGES = AUTH_ERROR_MESSAGES;
|
|
25199
25462
|
exports.AUTH_ERROR_STATUS = AUTH_ERROR_STATUS;
|
|
25463
|
+
exports.AUTH_SECRET_MIN_LENGTH = AUTH_SECRET_MIN_LENGTH;
|
|
25200
25464
|
exports.AUTH_SECURITY_SCHEMES = AUTH_SECURITY_SCHEMES;
|
|
25201
25465
|
exports.AUTH_THROTTLE_CONFIGS = AUTH_THROTTLE_CONFIGS;
|
|
25202
25466
|
exports.AcceptInvitationDto = AcceptInvitationDto;
|
|
@@ -25247,21 +25511,30 @@ exports.ServiceKey = ServiceKey;
|
|
|
25247
25511
|
exports.SkipMfa = SkipMfa;
|
|
25248
25512
|
exports.VerifyEmailDto = VerifyEmailDto;
|
|
25249
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;
|
|
25250
25518
|
exports.WORKSPACE_PERMISSION_KEY = WORKSPACE_PERMISSION_KEY;
|
|
25251
25519
|
exports.WORKSPACE_ROLES_KEY = WORKSPACE_ROLES_KEY;
|
|
25252
25520
|
exports.WS_TICKET_TTL_SECONDS = WS_TICKET_TTL_SECONDS;
|
|
25253
25521
|
exports.WorkspacePermission = WorkspacePermission;
|
|
25254
25522
|
exports.WorkspaceRoles = WorkspaceRoles;
|
|
25523
|
+
exports.assertWorkspaceId = assertWorkspaceId;
|
|
25255
25524
|
exports.authDocumentSecurity = authDocumentSecurity;
|
|
25256
25525
|
exports.createAuthValidationPipe = createAuthValidationPipe;
|
|
25526
|
+
exports.decodeWorkspaceCursor = decodeWorkspaceCursor;
|
|
25257
25527
|
exports.decodeWorkspaceScopedName = decodeWorkspaceScopedName;
|
|
25258
25528
|
exports.decrypt = decrypt;
|
|
25259
25529
|
exports.describeChannelStatus = describeChannelStatus;
|
|
25260
25530
|
exports.describeError = describeError;
|
|
25531
|
+
exports.encodeWorkspaceCursor = encodeWorkspaceCursor;
|
|
25261
25532
|
exports.encrypt = encrypt;
|
|
25262
25533
|
exports.generateSecureToken = generateSecureToken;
|
|
25263
25534
|
exports.hasRole = hasRole;
|
|
25264
25535
|
exports.hmacSha256 = hmacSha256;
|
|
25536
|
+
exports.isWorkspaceOwnerRole = isWorkspaceOwnerRole;
|
|
25537
|
+
exports.readWorkspacePosition = readWorkspacePosition;
|
|
25265
25538
|
exports.redactSecrets = redactSecrets;
|
|
25266
25539
|
exports.reduceToBaseWord = reduceToBaseWord;
|
|
25267
25540
|
exports.sanitizeHeaders = sanitizeHeaders;
|
|
@@ -25269,4 +25542,6 @@ exports.sha256 = sha256;
|
|
|
25269
25542
|
exports.sleep = sleep;
|
|
25270
25543
|
exports.stampJobContext = stampJobContext;
|
|
25271
25544
|
exports.timingSafeCompare = timingSafeCompare;
|
|
25545
|
+
exports.workspacePositionOf = workspacePositionOf;
|
|
25546
|
+
exports.workspaceQueryKey = workspaceQueryKey;
|
|
25272
25547
|
exports.workspaceScopedName = workspaceScopedName;
|