@bymax-one/nest-auth 1.5.13 → 1.5.15
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 +51 -1
- package/dist/server/index.cjs +366 -100
- package/dist/server/index.d.cts +1 -10
- package/dist/server/index.d.ts +1 -10
- package/dist/server/index.mjs +366 -100
- package/package.json +3 -3
package/dist/server/index.mjs
CHANGED
|
@@ -52,6 +52,17 @@ function assertArray(label, value) {
|
|
|
52
52
|
throw new Error(`[BymaxAuthModule] ${label} must be an array (received ${describeReceived(value)}).`);
|
|
53
53
|
}
|
|
54
54
|
__name(assertArray, "assertArray");
|
|
55
|
+
function assertKnownChildren(label, children, declared) {
|
|
56
|
+
children.forEach((child, position) => {
|
|
57
|
+
if (typeof child !== "string") {
|
|
58
|
+
throw new Error(`[BymaxAuthModule] ${label} must name roles as strings (received ${describeReceived(child)} at position ${position}).`);
|
|
59
|
+
}
|
|
60
|
+
if (!declared.has(child)) {
|
|
61
|
+
throw new Error(`[BymaxAuthModule] ${label} references unknown role '${child}'. All roles referenced as children must be declared as keys in the hierarchy.`);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
__name(assertKnownChildren, "assertKnownChildren");
|
|
55
66
|
|
|
56
67
|
// src/server/config/enum-boolean-options.ts
|
|
57
68
|
var BOOLEAN_OPTIONS = [
|
|
@@ -101,8 +112,8 @@ var ENUM_OPTIONS = {
|
|
|
101
112
|
"otp"
|
|
102
113
|
]
|
|
103
114
|
};
|
|
104
|
-
function readPath(
|
|
105
|
-
let node =
|
|
115
|
+
function readPath(root2, path) {
|
|
116
|
+
let node = root2;
|
|
106
117
|
for (const step of path.split(".")) {
|
|
107
118
|
if (typeof node !== "object" || node === null) return void 0;
|
|
108
119
|
node = Reflect.get(node, step);
|
|
@@ -578,6 +589,25 @@ function durationToSeconds(value) {
|
|
|
578
589
|
return amount * seconds;
|
|
579
590
|
}
|
|
580
591
|
__name(durationToSeconds, "durationToSeconds");
|
|
592
|
+
|
|
593
|
+
// src/server/config/no-inherited-keys.ts
|
|
594
|
+
var MAX_DEPTH = 4;
|
|
595
|
+
function isPlain(value) {
|
|
596
|
+
if (typeof value !== "object" || value === null) return false;
|
|
597
|
+
const prototype = Object.getPrototypeOf(value);
|
|
598
|
+
return prototype === null || Object.getPrototypeOf(prototype) === null;
|
|
599
|
+
}
|
|
600
|
+
__name(isPlain, "isPlain");
|
|
601
|
+
function withoutInheritedKeys(value, depth = 0) {
|
|
602
|
+
if (depth >= MAX_DEPTH || !isPlain(value)) return value;
|
|
603
|
+
const copy = /* @__PURE__ */ Object.create(null);
|
|
604
|
+
for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(value))) {
|
|
605
|
+
if ("value" in descriptor) descriptor.value = withoutInheritedKeys(descriptor.value, depth + 1);
|
|
606
|
+
Object.defineProperty(copy, key, descriptor);
|
|
607
|
+
}
|
|
608
|
+
return copy;
|
|
609
|
+
}
|
|
610
|
+
__name(withoutInheritedKeys, "withoutInheritedKeys");
|
|
581
611
|
var TOTP_STEP_SECONDS = 30;
|
|
582
612
|
var TOTP_DIGITS = 6;
|
|
583
613
|
var BASE32_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
@@ -831,10 +861,14 @@ var OBJECT_GROUPS = [
|
|
|
831
861
|
"oauth",
|
|
832
862
|
"roles",
|
|
833
863
|
"workspaces",
|
|
834
|
-
"workspaces.roles"
|
|
864
|
+
"workspaces.roles",
|
|
865
|
+
"workspaces.permissions",
|
|
866
|
+
"jwt",
|
|
867
|
+
"mfa",
|
|
868
|
+
"apiKeys"
|
|
835
869
|
];
|
|
836
|
-
function readPath2(
|
|
837
|
-
let node =
|
|
870
|
+
function readPath2(root2, path) {
|
|
871
|
+
let node = root2;
|
|
838
872
|
for (const step of path.split(".")) {
|
|
839
873
|
if (Object(node) !== node) return void 0;
|
|
840
874
|
node = Reflect.get(node, step);
|
|
@@ -868,6 +902,16 @@ function validateTextOptions(userOptions) {
|
|
|
868
902
|
}
|
|
869
903
|
__name(validateTextOptions, "validateTextOptions");
|
|
870
904
|
|
|
905
|
+
// src/server/utils/own-or-class.ts
|
|
906
|
+
function readOwnOrClass(group, key) {
|
|
907
|
+
for (let holder = group; holder !== null; holder = Object.getPrototypeOf(holder)) {
|
|
908
|
+
if (!Object.hasOwn(holder, key)) continue;
|
|
909
|
+
return holder !== group && Object.getPrototypeOf(holder) === null ? void 0 : Reflect.get(group, key);
|
|
910
|
+
}
|
|
911
|
+
return Reflect.get(group, key);
|
|
912
|
+
}
|
|
913
|
+
__name(readOwnOrClass, "readOwnOrClass");
|
|
914
|
+
|
|
871
915
|
// src/server/config/unset-options.ts
|
|
872
916
|
var TOP_KEYS = {
|
|
873
917
|
identifierKey: true,
|
|
@@ -1032,6 +1076,12 @@ var WORKSPACE_SUBGROUP_KEYS = {
|
|
|
1032
1076
|
roles: [
|
|
1033
1077
|
"hierarchy",
|
|
1034
1078
|
"ownerRole"
|
|
1079
|
+
],
|
|
1080
|
+
permissions: [
|
|
1081
|
+
"manageWorkspace",
|
|
1082
|
+
"deleteWorkspace",
|
|
1083
|
+
"manageMembers",
|
|
1084
|
+
"viewMembers"
|
|
1035
1085
|
]
|
|
1036
1086
|
};
|
|
1037
1087
|
function isObjectGroup(value) {
|
|
@@ -1039,24 +1089,24 @@ function isObjectGroup(value) {
|
|
|
1039
1089
|
}
|
|
1040
1090
|
__name(isObjectGroup, "isObjectGroup");
|
|
1041
1091
|
function readSetKeys(group, keys) {
|
|
1042
|
-
const out =
|
|
1092
|
+
const out = /* @__PURE__ */ Object.create(null);
|
|
1043
1093
|
for (const key of /* @__PURE__ */ new Set([
|
|
1044
1094
|
...keys,
|
|
1045
1095
|
...Object.keys(group)
|
|
1046
1096
|
])) {
|
|
1047
|
-
const entry =
|
|
1097
|
+
const entry = readOwnOrClass(group, key);
|
|
1048
1098
|
if (entry !== void 0 && entry !== null) out[key] = entry;
|
|
1049
1099
|
}
|
|
1050
1100
|
return out;
|
|
1051
1101
|
}
|
|
1052
1102
|
__name(readSetKeys, "readSetKeys");
|
|
1053
1103
|
function readKeptKeys(group, keys) {
|
|
1054
|
-
const out =
|
|
1104
|
+
const out = /* @__PURE__ */ Object.create(null);
|
|
1055
1105
|
for (const key of /* @__PURE__ */ new Set([
|
|
1056
1106
|
...keys,
|
|
1057
1107
|
...Object.keys(group)
|
|
1058
1108
|
])) {
|
|
1059
|
-
const entry =
|
|
1109
|
+
const entry = readOwnOrClass(group, key);
|
|
1060
1110
|
if (entry !== void 0 || Object.hasOwn(group, key)) out[key] = entry;
|
|
1061
1111
|
}
|
|
1062
1112
|
return out;
|
|
@@ -1081,7 +1131,7 @@ function dropUnset(options) {
|
|
|
1081
1131
|
if (name === "workspaces") {
|
|
1082
1132
|
for (const [sub, subKeys] of Object.entries(WORKSPACE_SUBGROUP_KEYS)) {
|
|
1083
1133
|
const inner = group[sub];
|
|
1084
|
-
if (isObjectGroup(inner)) group[sub] = (sub === "
|
|
1134
|
+
if (isObjectGroup(inner)) group[sub] = (sub === "accessDeniedEvents" ? readSetKeys : readKeptKeys)(inner, subKeys);
|
|
1085
1135
|
}
|
|
1086
1136
|
}
|
|
1087
1137
|
copy[name] = group;
|
|
@@ -1092,12 +1142,12 @@ function dropUnset(options) {
|
|
|
1092
1142
|
}
|
|
1093
1143
|
const oauth = copy["oauth"];
|
|
1094
1144
|
if (isObjectGroup(oauth)) {
|
|
1095
|
-
const google =
|
|
1145
|
+
const google = readOwnOrClass(oauth, "google");
|
|
1096
1146
|
if (isObjectGroup(google)) {
|
|
1097
1147
|
Reflect.set(oauth, "google", readKeptKeys(google, Object.keys(OAUTH_GOOGLE_KEYS)));
|
|
1098
1148
|
}
|
|
1099
1149
|
}
|
|
1100
|
-
return Object.assign(
|
|
1150
|
+
return Object.assign(/* @__PURE__ */ Object.create(null), copy);
|
|
1101
1151
|
}
|
|
1102
1152
|
__name(dropUnset, "dropUnset");
|
|
1103
1153
|
|
|
@@ -1105,7 +1155,7 @@ __name(dropUnset, "dropUnset");
|
|
|
1105
1155
|
function readOptions(given) {
|
|
1106
1156
|
const options = dropUnset(given);
|
|
1107
1157
|
validateTextOptions(options);
|
|
1108
|
-
return
|
|
1158
|
+
return pinCopied(options);
|
|
1109
1159
|
}
|
|
1110
1160
|
__name(readOptions, "readOptions");
|
|
1111
1161
|
function copyHierarchy(held) {
|
|
@@ -1118,39 +1168,110 @@ function copyHierarchy(held) {
|
|
|
1118
1168
|
]));
|
|
1119
1169
|
}
|
|
1120
1170
|
__name(copyHierarchy, "copyHierarchy");
|
|
1121
|
-
function
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
roles: pinIn(roles, [
|
|
1171
|
+
function copyList(held) {
|
|
1172
|
+
return Array.isArray(held) ? [
|
|
1173
|
+
...held
|
|
1174
|
+
] : held;
|
|
1175
|
+
}
|
|
1176
|
+
__name(copyList, "copyList");
|
|
1177
|
+
var COPIED = [
|
|
1178
|
+
{
|
|
1179
|
+
path: [
|
|
1180
|
+
"roles"
|
|
1181
|
+
],
|
|
1182
|
+
keys: [
|
|
1134
1183
|
"hierarchy",
|
|
1135
1184
|
"platformHierarchy"
|
|
1136
|
-
]
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1185
|
+
],
|
|
1186
|
+
copy: copyHierarchy
|
|
1187
|
+
},
|
|
1188
|
+
{
|
|
1189
|
+
path: [
|
|
1190
|
+
"workspaces",
|
|
1191
|
+
"roles"
|
|
1192
|
+
],
|
|
1193
|
+
keys: [
|
|
1194
|
+
"hierarchy"
|
|
1195
|
+
],
|
|
1196
|
+
copy: copyHierarchy
|
|
1197
|
+
},
|
|
1198
|
+
{
|
|
1199
|
+
path: [
|
|
1200
|
+
"workspaces",
|
|
1201
|
+
"permissions"
|
|
1202
|
+
],
|
|
1203
|
+
keys: [
|
|
1204
|
+
"manageWorkspace",
|
|
1205
|
+
"deleteWorkspace",
|
|
1206
|
+
"manageMembers",
|
|
1207
|
+
"viewMembers"
|
|
1208
|
+
],
|
|
1209
|
+
copy: copyList
|
|
1210
|
+
},
|
|
1211
|
+
{
|
|
1212
|
+
path: [
|
|
1213
|
+
"jwt"
|
|
1214
|
+
],
|
|
1215
|
+
keys: [
|
|
1216
|
+
"previousSecrets"
|
|
1217
|
+
],
|
|
1218
|
+
copy: copyList
|
|
1219
|
+
},
|
|
1220
|
+
{
|
|
1221
|
+
path: [
|
|
1222
|
+
"mfa"
|
|
1223
|
+
],
|
|
1224
|
+
keys: [
|
|
1225
|
+
"previousEncryptionKeys"
|
|
1226
|
+
],
|
|
1227
|
+
copy: copyList
|
|
1228
|
+
},
|
|
1229
|
+
{
|
|
1230
|
+
path: [
|
|
1231
|
+
"apiKeys"
|
|
1232
|
+
],
|
|
1233
|
+
keys: [
|
|
1234
|
+
"scopes"
|
|
1235
|
+
],
|
|
1236
|
+
copy: copyList
|
|
1237
|
+
}
|
|
1238
|
+
];
|
|
1239
|
+
function pinCopied(options) {
|
|
1240
|
+
for (const { path, keys, copy } of COPIED) {
|
|
1241
|
+
let group = options;
|
|
1242
|
+
for (const step of path) group = Object(group) === group ? group[step] : void 0;
|
|
1243
|
+
if (Object(group) !== group) continue;
|
|
1244
|
+
const plain = group;
|
|
1245
|
+
for (const key of keys) if (plain[key] !== void 0) plain[key] = copy(plain[key]);
|
|
1246
|
+
}
|
|
1247
|
+
return options;
|
|
1146
1248
|
}
|
|
1147
|
-
__name(
|
|
1249
|
+
__name(pinCopied, "pinCopied");
|
|
1148
1250
|
function validateOptionValues(userOptions) {
|
|
1149
1251
|
validateNumericOptions(userOptions);
|
|
1150
1252
|
validateEnumAndBooleanOptions(userOptions);
|
|
1151
1253
|
}
|
|
1152
1254
|
__name(validateOptionValues, "validateOptionValues");
|
|
1153
1255
|
|
|
1256
|
+
// src/server/config/platform-options.ts
|
|
1257
|
+
function validatePlatformAdmin(platform, roles) {
|
|
1258
|
+
if (!platform?.enabled) return;
|
|
1259
|
+
const hierarchy = roles.platformHierarchy;
|
|
1260
|
+
if (!hierarchy) {
|
|
1261
|
+
throw new Error(`[BymaxAuthModule] roles.platformHierarchy is required when platform.enabled is true. Define the platform role hierarchy (e.g. { SUPER_ADMIN: ['SUPPORT'], SUPPORT: [] }).`);
|
|
1262
|
+
}
|
|
1263
|
+
assertObject("roles.platformHierarchy", hierarchy);
|
|
1264
|
+
const names = new Set(Object.keys(hierarchy));
|
|
1265
|
+
if (names.size === 0) {
|
|
1266
|
+
throw new Error(`[BymaxAuthModule] roles.platformHierarchy must not be an empty object. Define at least one role (e.g. { SUPER_ADMIN: [] }).`);
|
|
1267
|
+
}
|
|
1268
|
+
for (const [role, children] of Object.entries(hierarchy)) {
|
|
1269
|
+
assertArray(`roles.platformHierarchy['${role}']`, children);
|
|
1270
|
+
assertKnownChildren(`roles.platformHierarchy['${role}']`, children, names);
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
__name(validatePlatformAdmin, "validatePlatformAdmin");
|
|
1274
|
+
|
|
1154
1275
|
// src/server/constants/workspace-roles.ts
|
|
1155
1276
|
var ANY_WORKSPACE_MEMBER = /* @__PURE__ */ Symbol("ANY_WORKSPACE_MEMBER");
|
|
1156
1277
|
|
|
@@ -1494,7 +1615,7 @@ function resolveOptions(given) {
|
|
|
1494
1615
|
validateTrustedOrigins(userOptions);
|
|
1495
1616
|
validateAccessLifetimeAgainstEpochRetention(userOptions.jwt);
|
|
1496
1617
|
const { mfa: _mfa, identifierKey: _identifierKey, workspaces: _workspaces, ...userOptionsWithoutMfa } = userOptions;
|
|
1497
|
-
const resolved = {
|
|
1618
|
+
const resolved = withoutInheritedKeys({
|
|
1498
1619
|
...userOptionsWithoutMfa,
|
|
1499
1620
|
jwt: {
|
|
1500
1621
|
...DEFAULT_OPTIONS.jwt,
|
|
@@ -1588,7 +1709,7 @@ function resolveOptions(given) {
|
|
|
1588
1709
|
...userOptions.mfa
|
|
1589
1710
|
}
|
|
1590
1711
|
}
|
|
1591
|
-
};
|
|
1712
|
+
});
|
|
1592
1713
|
withholdSecrets(resolved);
|
|
1593
1714
|
return resolved;
|
|
1594
1715
|
}
|
|
@@ -1745,20 +1866,10 @@ function validateRolesHierarchy(roles) {
|
|
|
1745
1866
|
const allRoles = new Set(Object.keys(roles.hierarchy));
|
|
1746
1867
|
for (const [role, children] of Object.entries(roles.hierarchy)) {
|
|
1747
1868
|
assertArray(`roles.hierarchy['${role}']`, children);
|
|
1748
|
-
|
|
1749
|
-
if (!allRoles.has(child)) {
|
|
1750
|
-
throw new Error(`[BymaxAuthModule] roles.hierarchy['${role}'] references unknown role '${child}'. All roles referenced as children must be declared as keys in the hierarchy.`);
|
|
1751
|
-
}
|
|
1752
|
-
}
|
|
1869
|
+
assertKnownChildren(`roles.hierarchy['${role}']`, children, allRoles);
|
|
1753
1870
|
}
|
|
1754
1871
|
}
|
|
1755
1872
|
__name(validateRolesHierarchy, "validateRolesHierarchy");
|
|
1756
|
-
function validatePlatformAdmin(platform, roles) {
|
|
1757
|
-
if (platform?.enabled && !roles.platformHierarchy) {
|
|
1758
|
-
throw new Error(`[BymaxAuthModule] roles.platformHierarchy is required when platform.enabled is true. Define the platform role hierarchy (e.g. { SUPER_ADMIN: ['SUPPORT'], SUPPORT: [] }).`);
|
|
1759
|
-
}
|
|
1760
|
-
}
|
|
1761
|
-
__name(validatePlatformAdmin, "validatePlatformAdmin");
|
|
1762
1873
|
function assertIntegralScryptParameter(name, value) {
|
|
1763
1874
|
if (value === void 0 || Number.isInteger(value)) return;
|
|
1764
1875
|
throw new Error(`[BymaxAuthModule] password.${name} must be an integer (received ${describeReceived(value)}). Node's crypto.scrypt rejects a non-integral cost parameter, and it does so on the first derivation \u2014 which is the first login after deploy, not at startup.`);
|
|
@@ -5090,6 +5201,142 @@ AuthRevocationService = _ts_decorate7([
|
|
|
5090
5201
|
typeof AuthRedisService === "undefined" ? Object : AuthRedisService
|
|
5091
5202
|
])
|
|
5092
5203
|
], AuthRevocationService);
|
|
5204
|
+
|
|
5205
|
+
// src/server/utils/object-prototype-guard.ts
|
|
5206
|
+
var STANDARD = [
|
|
5207
|
+
"constructor",
|
|
5208
|
+
"__defineGetter__",
|
|
5209
|
+
"__defineSetter__",
|
|
5210
|
+
"hasOwnProperty",
|
|
5211
|
+
"__lookupGetter__",
|
|
5212
|
+
"__lookupSetter__",
|
|
5213
|
+
"isPrototypeOf",
|
|
5214
|
+
"propertyIsEnumerable",
|
|
5215
|
+
"toString",
|
|
5216
|
+
"valueOf",
|
|
5217
|
+
"__proto__",
|
|
5218
|
+
"toLocaleString"
|
|
5219
|
+
];
|
|
5220
|
+
var ownKeys = Reflect.ownKeys;
|
|
5221
|
+
var hasOwn = Object.hasOwn;
|
|
5222
|
+
var getDescriptor = Object.getOwnPropertyDescriptor;
|
|
5223
|
+
var root = Object.prototype;
|
|
5224
|
+
function describe2(name) {
|
|
5225
|
+
const descriptor = getDescriptor(root, name);
|
|
5226
|
+
if (descriptor === void 0) return void 0;
|
|
5227
|
+
const field = /* @__PURE__ */ __name((key) => hasOwn(descriptor, key) ? descriptor[key] : void 0, "field");
|
|
5228
|
+
return Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
5229
|
+
value: field("value"),
|
|
5230
|
+
get: field("get"),
|
|
5231
|
+
set: field("set"),
|
|
5232
|
+
enumerable: field("enumerable") === true
|
|
5233
|
+
});
|
|
5234
|
+
}
|
|
5235
|
+
__name(describe2, "describe");
|
|
5236
|
+
var BASELINE = new Map(STANDARD.map((name) => [
|
|
5237
|
+
name,
|
|
5238
|
+
describe2(name)
|
|
5239
|
+
]));
|
|
5240
|
+
function isStandardKind(name, descriptor) {
|
|
5241
|
+
if (name === "__proto__" && descriptor === void 0) return true;
|
|
5242
|
+
if (descriptor === void 0 || descriptor.enumerable) return false;
|
|
5243
|
+
return name === "__proto__" ? typeof descriptor.get === "function" && typeof descriptor.set === "function" : typeof descriptor.value === "function";
|
|
5244
|
+
}
|
|
5245
|
+
__name(isStandardKind, "isStandardKind");
|
|
5246
|
+
var LOADED_STANDARD = STANDARD.every((name) => isStandardKind(name, BASELINE.get(name)));
|
|
5247
|
+
function same(left, right) {
|
|
5248
|
+
return left !== void 0 && right !== void 0 && left.value === right.value && left.get === right.get && left.set === right.set && left.enumerable === right.enumerable;
|
|
5249
|
+
}
|
|
5250
|
+
__name(same, "same");
|
|
5251
|
+
function plantedOnRoot() {
|
|
5252
|
+
let count = LOADED_STANDARD ? 0 : 1;
|
|
5253
|
+
for (const key of ownKeys(root)) if (typeof key === "string" && !same(describe2(key), BASELINE.get(key))) count += 1;
|
|
5254
|
+
for (const name of STANDARD) if (describe2(name) === void 0 && BASELINE.get(name) !== void 0) count += 1;
|
|
5255
|
+
return count;
|
|
5256
|
+
}
|
|
5257
|
+
__name(plantedOnRoot, "plantedOnRoot");
|
|
5258
|
+
function assertRootIsStandard() {
|
|
5259
|
+
const planted = plantedOnRoot();
|
|
5260
|
+
if (planted > 0) throw new AuthException(AUTH_ERROR_CODES.INTERNAL, void 0, {
|
|
5261
|
+
cause: new Error(`Object.prototype holds ${planted} entries that are not the runtime's own`)
|
|
5262
|
+
});
|
|
5263
|
+
}
|
|
5264
|
+
__name(assertRootIsStandard, "assertRootIsStandard");
|
|
5265
|
+
function assertRootIsStandardAtBoot() {
|
|
5266
|
+
const planted = plantedOnRoot();
|
|
5267
|
+
if (planted > 0) throw new Error(`[BymaxAuthModule] Object.prototype holds ${planted} entries that are not the runtime's own; the module does not start while a key is planted there.`);
|
|
5268
|
+
}
|
|
5269
|
+
__name(assertRootIsStandardAtBoot, "assertRootIsStandardAtBoot");
|
|
5270
|
+
|
|
5271
|
+
// src/server/utils/dependency-options.ts
|
|
5272
|
+
var JWT_MODULE_SHADOWS = Object.freeze({
|
|
5273
|
+
secretOrPrivateKey: void 0,
|
|
5274
|
+
secretOrKeyProvider: void 0,
|
|
5275
|
+
publicKey: void 0,
|
|
5276
|
+
privateKey: void 0,
|
|
5277
|
+
verifyOptions: void 0
|
|
5278
|
+
});
|
|
5279
|
+
var JWT_VERIFY_SHADOWS = Object.freeze({
|
|
5280
|
+
complete: false,
|
|
5281
|
+
clockTimestamp: void 0,
|
|
5282
|
+
clockTolerance: void 0,
|
|
5283
|
+
ignoreNotBefore: false,
|
|
5284
|
+
maxAge: void 0,
|
|
5285
|
+
nonce: void 0,
|
|
5286
|
+
subject: void 0,
|
|
5287
|
+
jwtid: void 0,
|
|
5288
|
+
allowInvalidAsymmetricKeyTypes: false
|
|
5289
|
+
});
|
|
5290
|
+
var JWT_SIGN_SHADOWS = Object.freeze({
|
|
5291
|
+
noTimestamp: false,
|
|
5292
|
+
mutatePayload: false,
|
|
5293
|
+
header: Object.freeze({}),
|
|
5294
|
+
// Stryker disable next-line StringLiteral: an empty encoding falls back to utf8 in `jsonwebtoken` and in `jws`, so the emptied value signs the same bytes as the shadow
|
|
5295
|
+
encoding: "utf8",
|
|
5296
|
+
allowInsecureKeySizes: false,
|
|
5297
|
+
allowInvalidAsymmetricKeyTypes: false
|
|
5298
|
+
});
|
|
5299
|
+
var SCRYPT_SHADOWS = Object.freeze({
|
|
5300
|
+
cost: void 0,
|
|
5301
|
+
blockSize: void 0,
|
|
5302
|
+
parallelization: void 0
|
|
5303
|
+
});
|
|
5304
|
+
var COOKIE_SHADOWS = Object.freeze(Object.assign({}, {
|
|
5305
|
+
domain: void 0,
|
|
5306
|
+
expires: void 0,
|
|
5307
|
+
encode: void 0,
|
|
5308
|
+
partitioned: false,
|
|
5309
|
+
priority: void 0,
|
|
5310
|
+
signed: false
|
|
5311
|
+
}));
|
|
5312
|
+
function jwtModuleOptions(secret) {
|
|
5313
|
+
return Object.assign(
|
|
5314
|
+
// Stryker disable next-line ObjectLiteral: jsonwebtoken defaults to HS256 and every sign call names its own algorithm, so the emptied `signOptions` signs identically
|
|
5315
|
+
{
|
|
5316
|
+
secret,
|
|
5317
|
+
signOptions: {
|
|
5318
|
+
algorithm: "HS256"
|
|
5319
|
+
}
|
|
5320
|
+
},
|
|
5321
|
+
JWT_MODULE_SHADOWS
|
|
5322
|
+
);
|
|
5323
|
+
}
|
|
5324
|
+
__name(jwtModuleOptions, "jwtModuleOptions");
|
|
5325
|
+
function jwtSignOptions(chosen) {
|
|
5326
|
+
assertRootIsStandard();
|
|
5327
|
+
return Object.assign({}, JWT_SIGN_SHADOWS, chosen);
|
|
5328
|
+
}
|
|
5329
|
+
__name(jwtSignOptions, "jwtSignOptions");
|
|
5330
|
+
function cookieOptions(chosen = {}) {
|
|
5331
|
+
assertRootIsStandard();
|
|
5332
|
+
return {
|
|
5333
|
+
...COOKIE_SHADOWS,
|
|
5334
|
+
...chosen
|
|
5335
|
+
};
|
|
5336
|
+
}
|
|
5337
|
+
__name(cookieOptions, "cookieOptions");
|
|
5338
|
+
|
|
5339
|
+
// src/server/services/token-delivery.service.ts
|
|
5093
5340
|
function _ts_decorate8(decorators, target, key, desc) {
|
|
5094
5341
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5095
5342
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -5407,12 +5654,12 @@ var TokenDeliveryService = class {
|
|
|
5407
5654
|
}
|
|
5408
5655
|
/** Returns base Set-Cookie options for auth cookies, optionally scoped to a domain. */
|
|
5409
5656
|
baseCookieOptions(domain) {
|
|
5410
|
-
return {
|
|
5657
|
+
return cookieOptions({
|
|
5411
5658
|
sameSite: this.options.cookies.sameSite,
|
|
5412
5659
|
...domain ? {
|
|
5413
5660
|
domain
|
|
5414
5661
|
} : {}
|
|
5415
|
-
};
|
|
5662
|
+
});
|
|
5416
5663
|
}
|
|
5417
5664
|
/** Reads the value of the cookie identified by `name` from the request. */
|
|
5418
5665
|
readCookie(req, name) {
|
|
@@ -5485,11 +5732,13 @@ function signerOf(options) {
|
|
|
5485
5732
|
}
|
|
5486
5733
|
__name(signerOf, "signerOf");
|
|
5487
5734
|
function verifyWithRotation(jwtService, options, token, { ignoreExpiration = false } = {}) {
|
|
5735
|
+
assertRootIsStandard();
|
|
5488
5736
|
const algorithms = [
|
|
5489
5737
|
options.jwt.algorithm
|
|
5490
5738
|
];
|
|
5491
5739
|
const { issuer, audience, secret } = options.jwt;
|
|
5492
5740
|
const base = {
|
|
5741
|
+
...JWT_VERIFY_SHADOWS,
|
|
5493
5742
|
algorithms,
|
|
5494
5743
|
ignoreExpiration,
|
|
5495
5744
|
issuer,
|
|
@@ -6700,12 +6949,13 @@ function _ts_param11(paramIndex, decorator) {
|
|
|
6700
6949
|
}
|
|
6701
6950
|
__name(_ts_param11, "_ts_param");
|
|
6702
6951
|
async function releasingCooldownOnFailure(redis, logger, cooldownKey, work) {
|
|
6952
|
+
const release = /* @__PURE__ */ __name(() => redis.del(cooldownKey).then(() => void 0, (err) => {
|
|
6953
|
+
logStore(logger, "AUTH_STORE_FAILED", "resend_cooldown_release", err);
|
|
6954
|
+
}), "release");
|
|
6703
6955
|
try {
|
|
6704
|
-
|
|
6956
|
+
if (await work() === false) await release();
|
|
6705
6957
|
} catch (error) {
|
|
6706
|
-
await
|
|
6707
|
-
logStore(logger, "AUTH_STORE_FAILED", "resend_cooldown_release", err);
|
|
6708
|
-
});
|
|
6958
|
+
await release();
|
|
6709
6959
|
throw error;
|
|
6710
6960
|
}
|
|
6711
6961
|
}
|
|
@@ -7107,8 +7357,10 @@ var PasswordService = class _PasswordService {
|
|
|
7107
7357
|
}
|
|
7108
7358
|
}
|
|
7109
7359
|
async hash(plain) {
|
|
7360
|
+
assertRootIsStandard();
|
|
7110
7361
|
const salt = randomBytes(SALT_BYTES);
|
|
7111
7362
|
const derived = await scrypt(plain, salt, SCRYPT_KEY_LEN, {
|
|
7363
|
+
...SCRYPT_SHADOWS,
|
|
7112
7364
|
N: this.N,
|
|
7113
7365
|
r: this.r,
|
|
7114
7366
|
p: this.p,
|
|
@@ -7146,10 +7398,12 @@ var PasswordService = class _PasswordService {
|
|
|
7146
7398
|
* without revealing the reason (invalid hash vs. wrong password).
|
|
7147
7399
|
*/
|
|
7148
7400
|
async compare(plain, hash) {
|
|
7401
|
+
assertRootIsStandard();
|
|
7149
7402
|
const parsed = parseStoredHash(hash);
|
|
7150
7403
|
if (parsed === null) return false;
|
|
7151
7404
|
const { N, r, p } = parsed;
|
|
7152
7405
|
const candidate = await scrypt(plain, parsed.salt, parsed.derived.length, {
|
|
7406
|
+
...SCRYPT_SHADOWS,
|
|
7153
7407
|
N,
|
|
7154
7408
|
r,
|
|
7155
7409
|
p,
|
|
@@ -7196,7 +7450,9 @@ var PasswordService = class _PasswordService {
|
|
|
7196
7450
|
* password request already costs; pair it with route-level rate limiting.
|
|
7197
7451
|
*/
|
|
7198
7452
|
async compareDummy(plain) {
|
|
7453
|
+
assertRootIsStandard();
|
|
7199
7454
|
const candidate = await scrypt(plain, DUMMY_SALT, SCRYPT_KEY_LEN, {
|
|
7455
|
+
...SCRYPT_SHADOWS,
|
|
7200
7456
|
N: this.N,
|
|
7201
7457
|
r: this.r,
|
|
7202
7458
|
p: this.p,
|
|
@@ -7220,8 +7476,8 @@ PasswordService = _ts_decorate20([
|
|
|
7220
7476
|
var RECORD_CONTRACTS = {
|
|
7221
7477
|
workspace: {
|
|
7222
7478
|
fields: {
|
|
7223
|
-
id: "
|
|
7224
|
-
tenantId: "
|
|
7479
|
+
id: "id",
|
|
7480
|
+
tenantId: "tenant",
|
|
7225
7481
|
name: "~string",
|
|
7226
7482
|
status: "string",
|
|
7227
7483
|
createdAt: "~date",
|
|
@@ -7231,9 +7487,9 @@ var RECORD_CONTRACTS = {
|
|
|
7231
7487
|
},
|
|
7232
7488
|
membership: {
|
|
7233
7489
|
fields: {
|
|
7234
|
-
tenantId: "
|
|
7235
|
-
workspaceId: "
|
|
7236
|
-
userId: "
|
|
7490
|
+
tenantId: "tenant",
|
|
7491
|
+
workspaceId: "id",
|
|
7492
|
+
userId: "id",
|
|
7237
7493
|
role: "string",
|
|
7238
7494
|
status: "string",
|
|
7239
7495
|
invitedByUserId: "~id",
|
|
@@ -7244,13 +7500,13 @@ var RECORD_CONTRACTS = {
|
|
|
7244
7500
|
},
|
|
7245
7501
|
user: {
|
|
7246
7502
|
fields: {
|
|
7247
|
-
id: "
|
|
7503
|
+
id: "id",
|
|
7248
7504
|
email: "~string",
|
|
7249
7505
|
name: "~string",
|
|
7250
7506
|
passwordHash: "string|null",
|
|
7251
7507
|
role: "string",
|
|
7252
7508
|
status: "string",
|
|
7253
|
-
tenantId: "
|
|
7509
|
+
tenantId: "tenant",
|
|
7254
7510
|
emailVerified: "boolean",
|
|
7255
7511
|
mfaEnabled: "boolean",
|
|
7256
7512
|
mfaSecret: "string?",
|
|
@@ -7264,7 +7520,7 @@ var RECORD_CONTRACTS = {
|
|
|
7264
7520
|
},
|
|
7265
7521
|
platformUser: {
|
|
7266
7522
|
fields: {
|
|
7267
|
-
id: "
|
|
7523
|
+
id: "id",
|
|
7268
7524
|
email: "~string",
|
|
7269
7525
|
name: "~string",
|
|
7270
7526
|
passwordHash: "string",
|
|
@@ -7282,7 +7538,7 @@ var RECORD_CONTRACTS = {
|
|
|
7282
7538
|
},
|
|
7283
7539
|
apiKey: {
|
|
7284
7540
|
fields: {
|
|
7285
|
-
id: "
|
|
7541
|
+
id: "id",
|
|
7286
7542
|
label: "~string",
|
|
7287
7543
|
digest: "string",
|
|
7288
7544
|
scopes: "strings",
|
|
@@ -7295,7 +7551,7 @@ var RECORD_CONTRACTS = {
|
|
|
7295
7551
|
},
|
|
7296
7552
|
removedMembership: {
|
|
7297
7553
|
fields: {
|
|
7298
|
-
workspaceId: "
|
|
7554
|
+
workspaceId: "id",
|
|
7299
7555
|
role: "string"
|
|
7300
7556
|
},
|
|
7301
7557
|
nested: {}
|
|
@@ -7538,12 +7794,29 @@ function copyStrings(value, read) {
|
|
|
7538
7794
|
return copy;
|
|
7539
7795
|
}
|
|
7540
7796
|
__name(copyStrings, "copyStrings");
|
|
7797
|
+
var BUILT_IN_VALUES = [
|
|
7798
|
+
Date,
|
|
7799
|
+
RegExp,
|
|
7800
|
+
Error,
|
|
7801
|
+
DataView,
|
|
7802
|
+
URL,
|
|
7803
|
+
Intl.Locale,
|
|
7804
|
+
Object.getPrototypeOf(Uint8Array)
|
|
7805
|
+
];
|
|
7806
|
+
function isBuiltInValue(value) {
|
|
7807
|
+
return types.isDate(value) || types.isRegExp(value) || types.isNativeError(value) || types.isArrayBufferView(value) || BUILT_IN_VALUES.some((kind) => value instanceof kind);
|
|
7808
|
+
}
|
|
7809
|
+
__name(isBuiltInValue, "isBuiltInValue");
|
|
7810
|
+
var NOT_AN_ID_TEXT = /* @__PURE__ */ new Set([
|
|
7811
|
+
"undefined",
|
|
7812
|
+
"null"
|
|
7813
|
+
]);
|
|
7541
7814
|
function readId(value) {
|
|
7542
|
-
if (typeof value === "string") return accept(value !== "", value);
|
|
7543
7815
|
if (typeof value === "number") return accept(Number.isSafeInteger(value), String(value));
|
|
7544
|
-
if (
|
|
7545
|
-
const
|
|
7546
|
-
|
|
7816
|
+
if (typeof value !== "string" && (!isHostInstance(value) || isBuiltInValue(value))) throw new Error(WRONG_KIND);
|
|
7817
|
+
const text = String(value);
|
|
7818
|
+
const printed = typeof value !== "string";
|
|
7819
|
+
return accept(text.trim() !== "" && !NOT_AN_ID_TEXT.has(text) && !(printed && text.startsWith("[object ")), text);
|
|
7547
7820
|
}
|
|
7548
7821
|
__name(readId, "readId");
|
|
7549
7822
|
function readInforming(value) {
|
|
@@ -7562,6 +7835,8 @@ __name(readInformingDate, "readInformingDate");
|
|
|
7562
7835
|
var READERS = {
|
|
7563
7836
|
boolean: /* @__PURE__ */ __name((value) => accept(typeof value === "boolean", value), "boolean"),
|
|
7564
7837
|
string: /* @__PURE__ */ __name((value) => accept(typeof value === "string", value), "string"),
|
|
7838
|
+
tenant: /* @__PURE__ */ __name((value) => accept(typeof value === "string" && value.trim() !== "", value), "tenant"),
|
|
7839
|
+
id: readId,
|
|
7565
7840
|
number: /* @__PURE__ */ __name((value) => accept(Number.isFinite(value), value), "number"),
|
|
7566
7841
|
date: copyDate,
|
|
7567
7842
|
strings: copyStrings,
|
|
@@ -7593,7 +7868,7 @@ function readScalar(value, spec, run) {
|
|
|
7593
7868
|
}
|
|
7594
7869
|
__name(readScalar, "readScalar");
|
|
7595
7870
|
function copyRecord(value, contract, run) {
|
|
7596
|
-
const copy =
|
|
7871
|
+
const copy = /* @__PURE__ */ Object.create(null);
|
|
7597
7872
|
rememberUnder(run, value, contract, copy);
|
|
7598
7873
|
ENTITIES.set(copy, value);
|
|
7599
7874
|
const source = value;
|
|
@@ -7607,7 +7882,7 @@ function copyRecord(value, contract, run) {
|
|
|
7607
7882
|
const own = new Set(keys);
|
|
7608
7883
|
for (const [field, spec] of Object.entries(contract.fields)) {
|
|
7609
7884
|
const { base, nullable, optional } = parseSpec(spec);
|
|
7610
|
-
const held = source
|
|
7885
|
+
const held = readOwnOrClass(source, field);
|
|
7611
7886
|
if (held === void 0) {
|
|
7612
7887
|
if (optional) continue;
|
|
7613
7888
|
throw new Error(ABSENT);
|
|
@@ -8646,22 +8921,13 @@ var TokenManagerService = class _TokenManagerService {
|
|
|
8646
8921
|
jti
|
|
8647
8922
|
}, this.accessSignOptions());
|
|
8648
8923
|
}
|
|
8649
|
-
/**
|
|
8650
|
-
* Builds JwtSignOptions from resolved configuration.
|
|
8651
|
-
*
|
|
8652
|
-
* The double-cast through `unknown` is required because:
|
|
8653
|
-
* 1. `@nestjs/jwt` types `expiresIn` as the branded `StringValue` from `ms`
|
|
8654
|
-
* (not a plain `string`), and
|
|
8655
|
-
* 2. `exactOptionalPropertyTypes` rejects `string | undefined` as the value
|
|
8656
|
-
* type of an optional property typed as `StringValue`.
|
|
8657
|
-
* At runtime the value is always a valid `ms` string — the cast is safe.
|
|
8658
|
-
*/
|
|
8924
|
+
/** The options of an access-token `sign` call: the resolved configuration, over a neutral value for every option the library does not choose. */
|
|
8659
8925
|
accessSignOptions() {
|
|
8660
|
-
return {
|
|
8926
|
+
return jwtSignOptions({
|
|
8661
8927
|
expiresIn: this.options.jwt.accessExpiresIn,
|
|
8662
8928
|
...signerOf(this.options),
|
|
8663
8929
|
...this.issuerAudience()
|
|
8664
|
-
};
|
|
8930
|
+
});
|
|
8665
8931
|
}
|
|
8666
8932
|
/**
|
|
8667
8933
|
* The `iss`/`aud` pair to stamp and to require, or nothing when the deployment configured
|
|
@@ -9443,14 +9709,14 @@ var TokenManagerService = class _TokenManagerService {
|
|
|
9443
9709
|
// the claim's own documentation for what it was surviving.
|
|
9444
9710
|
epoch: await this.redis.getUserTokenEpoch(userId, tenantId, context)
|
|
9445
9711
|
};
|
|
9446
|
-
const token = this.jwtService.sign(payload, {
|
|
9712
|
+
const token = this.jwtService.sign(payload, jwtSignOptions({
|
|
9447
9713
|
expiresIn: `${MFA_TEMP_TOKEN_TTL_SECONDS}s`,
|
|
9448
9714
|
...signerOf(this.options),
|
|
9449
9715
|
// The challenge token is stamped and checked like every other: it grants no resource
|
|
9450
9716
|
// access on its own, but it is still a token this backend minted, and a verifier that
|
|
9451
9717
|
// exempted one shape would be a verifier an attacker aims at.
|
|
9452
9718
|
...this.issuerAudience()
|
|
9453
|
-
});
|
|
9719
|
+
}));
|
|
9454
9720
|
await this.redis.set(`mfa:${sha256(jti)}`, userId, MFA_TEMP_TOKEN_TTL_SECONDS);
|
|
9455
9721
|
return token;
|
|
9456
9722
|
}
|
|
@@ -10475,7 +10741,7 @@ var AuthService = class _AuthService {
|
|
|
10475
10741
|
email,
|
|
10476
10742
|
tenantId
|
|
10477
10743
|
}), tenantId);
|
|
10478
|
-
|
|
10744
|
+
return user && !user.emailVerified ? this.sendVerificationOtp(tenantId, email) : void 0;
|
|
10479
10745
|
});
|
|
10480
10746
|
await sleep(Math.max(0, ANTI_ENUM_MIN_MS - (Date.now() - start)));
|
|
10481
10747
|
}
|
|
@@ -10726,12 +10992,12 @@ var AuthService = class _AuthService {
|
|
|
10726
10992
|
logEvent(this.logger, "AUTH_PROVIDER_MISSING", {
|
|
10727
10993
|
flow: "email_verification_otp"
|
|
10728
10994
|
});
|
|
10729
|
-
return;
|
|
10995
|
+
return true;
|
|
10730
10996
|
}
|
|
10731
10997
|
const identifier = this.otpIdentifier(tenantId, email);
|
|
10732
10998
|
const otp = this.otpService.generate(6);
|
|
10733
10999
|
const { otpTtlSeconds: ttl } = this.options.emailVerification;
|
|
10734
|
-
if (!await storeVerificationCode(this.otpService, this.logger, identifier, otp, ttl)) return;
|
|
11000
|
+
if (!await storeVerificationCode(this.otpService, this.logger, identifier, otp, ttl)) return false;
|
|
10735
11001
|
const provider = this.emailProvider;
|
|
10736
11002
|
void (async () => {
|
|
10737
11003
|
try {
|
|
@@ -10740,6 +11006,7 @@ var AuthService = class _AuthService {
|
|
|
10740
11006
|
logDelivery(this.logger, "email_verification_otp", err);
|
|
10741
11007
|
}
|
|
10742
11008
|
})();
|
|
11009
|
+
return true;
|
|
10743
11010
|
}
|
|
10744
11011
|
};
|
|
10745
11012
|
AuthService = _ts_decorate23([
|
|
@@ -14810,6 +15077,7 @@ var MfaController = class {
|
|
|
14810
15077
|
*/
|
|
14811
15078
|
clearMfaTempCookie(res) {
|
|
14812
15079
|
res.clearCookie(MFA_TEMP_COOKIE_NAME, {
|
|
15080
|
+
...cookieOptions(),
|
|
14813
15081
|
path: this.options.cookies.mfaTempCookiePath,
|
|
14814
15082
|
httpOnly: true,
|
|
14815
15083
|
secure: this.options.secureCookies,
|
|
@@ -18107,7 +18375,7 @@ var WorkspaceAccessService = class _WorkspaceAccessService {
|
|
|
18107
18375
|
if (membership?.status !== "active" || workspace === null) return {
|
|
18108
18376
|
kind: "denied"
|
|
18109
18377
|
};
|
|
18110
|
-
if (workspace.tenantId !== ref.tenantId || membership.tenantId !== ref.tenantId) return {
|
|
18378
|
+
if (workspace.tenantId !== ref.tenantId || membership.tenantId !== ref.tenantId || workspace.id !== ref.workspaceId || membership.workspaceId !== ref.workspaceId || membership.userId !== ref.userId) return {
|
|
18111
18379
|
kind: "denied"
|
|
18112
18380
|
};
|
|
18113
18381
|
const member = {
|
|
@@ -22928,6 +23196,7 @@ var OAuthService = class _OAuthService {
|
|
|
22928
23196
|
*/
|
|
22929
23197
|
bindToBrowser(res, state) {
|
|
22930
23198
|
res.cookie(OAUTH_STATE_COOKIE_NAME, state, {
|
|
23199
|
+
...cookieOptions(),
|
|
22931
23200
|
httpOnly: true,
|
|
22932
23201
|
secure: this.options.secureCookies,
|
|
22933
23202
|
sameSite: OAUTH_STATE_COOKIE_SAME_SITE,
|
|
@@ -23807,6 +24076,7 @@ var OAuthController = class _OAuthController {
|
|
|
23807
24076
|
*/
|
|
23808
24077
|
clearOAuthStateCookie(res) {
|
|
23809
24078
|
res.clearCookie(OAUTH_STATE_COOKIE_NAME, {
|
|
24079
|
+
...cookieOptions(),
|
|
23810
24080
|
httpOnly: true,
|
|
23811
24081
|
secure: this.options.secureCookies,
|
|
23812
24082
|
sameSite: OAUTH_STATE_COOKIE_SAME_SITE,
|
|
@@ -23831,6 +24101,7 @@ var OAuthController = class _OAuthController {
|
|
|
23831
24101
|
*/
|
|
23832
24102
|
setMfaTempCookie(res, mfaTempToken) {
|
|
23833
24103
|
res.cookie(MFA_TEMP_COOKIE_NAME, mfaTempToken, {
|
|
24104
|
+
...cookieOptions(),
|
|
23834
24105
|
httpOnly: true,
|
|
23835
24106
|
secure: this.options.secureCookies,
|
|
23836
24107
|
sameSite: this.options.cookies.sameSite,
|
|
@@ -25231,7 +25502,7 @@ function buildAuthOpenApiFragment(options, registered) {
|
|
|
25231
25502
|
for (const [controller, handlers] of Object.entries(OPERATIONS)) {
|
|
25232
25503
|
if (!registered[controller]) continue;
|
|
25233
25504
|
for (const [handler, credential] of Object.entries(handlers)) {
|
|
25234
|
-
const described =
|
|
25505
|
+
const described = describe3(credential, cookieDelivery, bearerDelivery);
|
|
25235
25506
|
const note = OPERATION_DESCRIPTIONS.get(handler);
|
|
25236
25507
|
operations[handler] = note === void 0 ? described : {
|
|
25237
25508
|
...described,
|
|
@@ -25249,7 +25520,7 @@ function buildAuthOpenApiFragment(options, registered) {
|
|
|
25249
25520
|
};
|
|
25250
25521
|
}
|
|
25251
25522
|
__name(buildAuthOpenApiFragment, "buildAuthOpenApiFragment");
|
|
25252
|
-
function
|
|
25523
|
+
function describe3(credential, cookieDelivery, bearerDelivery) {
|
|
25253
25524
|
switch (credential) {
|
|
25254
25525
|
case "none":
|
|
25255
25526
|
return {
|
|
@@ -25319,7 +25590,7 @@ function describe2(credential, cookieDelivery, bearerDelivery) {
|
|
|
25319
25590
|
};
|
|
25320
25591
|
}
|
|
25321
25592
|
}
|
|
25322
|
-
__name(
|
|
25593
|
+
__name(describe3, "describe");
|
|
25323
25594
|
function describeTwoCredentials(credential, cookieDelivery, bearerDelivery) {
|
|
25324
25595
|
const required = {
|
|
25325
25596
|
access: credential !== "optionalAccessAndRefresh",
|
|
@@ -26708,6 +26979,7 @@ var BymaxAuthModule = class _BymaxAuthModule {
|
|
|
26708
26979
|
if (hostHasKey(userOptions, "controllers")) {
|
|
26709
26980
|
throw new Error("[BymaxAuthModule] `controllers` must be passed to registerAsync() itself, not returned from useFactory \u2014 the module is assembled before the factory runs, so flags returned here are ignored and the endpoints are never registered.");
|
|
26710
26981
|
}
|
|
26982
|
+
assertRootIsStandardAtBoot();
|
|
26711
26983
|
const resolved = readHostOptions(() => resolveOptions(userOptions));
|
|
26712
26984
|
if (includeMfa && resolved.mfa === void 0) {
|
|
26713
26985
|
throw new Error("[BymaxAuthModule] controllers.mfa: true requires the mfa group (encryptionKey and issuer) to be configured in the useFactory return value.");
|
|
@@ -26866,13 +27138,7 @@ var BymaxAuthModule = class _BymaxAuthModule {
|
|
|
26866
27138
|
imports: options.imports ?? [],
|
|
26867
27139
|
useFactory: /* @__PURE__ */ __name(async (...args) => {
|
|
26868
27140
|
const { value: userOptions } = await callFactory(options.useFactory, args);
|
|
26869
|
-
return
|
|
26870
|
-
secret: readHostOptions(() => userOptions.jwt.secret),
|
|
26871
|
-
// Stryker disable next-line ObjectLiteral: jsonwebtoken defaults to HS256 and TokenManagerService overrides signOptions per call, so the emptied `signOptions` produces identical signing
|
|
26872
|
-
signOptions: {
|
|
26873
|
-
algorithm: "HS256"
|
|
26874
|
-
}
|
|
26875
|
-
};
|
|
27141
|
+
return jwtModuleOptions(readHostOptions(() => userOptions.jwt.secret));
|
|
26876
27142
|
}, "useFactory"),
|
|
26877
27143
|
inject: options.inject ?? []
|
|
26878
27144
|
})
|