@web-ts-toolkit/access-router 0.70.0 → 0.71.0
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/README.md +28 -1
- package/advanced.d.mts +37 -37
- package/advanced.d.ts +37 -37
- package/advanced.js +96 -47
- package/advanced.mjs +90 -41
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.js +120 -62
- package/index.mjs +112 -54
- package/package.json +3 -3
- package/{parsers-DcYjda98.d.mts → parsers-BXwV3svU.d.mts} +10 -1
- package/{parsers-DcYjda98.d.ts → parsers-BXwV3svU.d.ts} +10 -1
package/advanced.js
CHANGED
|
@@ -130,14 +130,14 @@ var import_mongoose4 = __toESM(require("mongoose"));
|
|
|
130
130
|
|
|
131
131
|
// src/validation/public-admission.ts
|
|
132
132
|
var import_express_json_router2 = __toESM(require("@web-ts-toolkit/express-json-router"));
|
|
133
|
-
var
|
|
133
|
+
var import_node_util7 = require("util");
|
|
134
134
|
var import_utils2 = require("@web-ts-toolkit/utils");
|
|
135
135
|
|
|
136
136
|
// src/acl/output-work-ledger.ts
|
|
137
|
-
var
|
|
137
|
+
var import_node_async_hooks2 = require("async_hooks");
|
|
138
138
|
|
|
139
139
|
// src/acl/authorization-snapshot.ts
|
|
140
|
-
var
|
|
140
|
+
var import_node_util5 = require("util");
|
|
141
141
|
var import_mongoose2 = require("mongoose");
|
|
142
142
|
var import_express_json_router = __toESM(require("@web-ts-toolkit/express-json-router"));
|
|
143
143
|
|
|
@@ -873,7 +873,67 @@ function materializeTrustedOutputValue(value, path, budget, policy, depth = 0, p
|
|
|
873
873
|
}
|
|
874
874
|
}
|
|
875
875
|
|
|
876
|
+
// src/logger-default.ts
|
|
877
|
+
var import_node_util4 = __toESM(require("util"));
|
|
878
|
+
var import_winston = require("winston");
|
|
879
|
+
var colorizer = import_winston.format.colorize();
|
|
880
|
+
var defaultLogLevel = process.env.WTT_LOG_LEVEL || "silent";
|
|
881
|
+
var inspectValue = (value) => {
|
|
882
|
+
return typeof value === "string" ? value : import_node_util4.default.inspect(value, { depth: 5, colors: false });
|
|
883
|
+
};
|
|
884
|
+
var defaultLogger = (0, import_winston.createLogger)({
|
|
885
|
+
level: defaultLogLevel,
|
|
886
|
+
format: import_winston.format.combine(
|
|
887
|
+
import_winston.format.errors({ stack: true }),
|
|
888
|
+
import_winston.format.splat(),
|
|
889
|
+
import_winston.format.label({ label: "[WTT]" }),
|
|
890
|
+
import_winston.format.timestamp(),
|
|
891
|
+
import_winston.format.printf(({ level, label, message, timestamp, stack, ...meta }) => {
|
|
892
|
+
const formattedLabel = colorizer.colorize(level, String(label));
|
|
893
|
+
const formattedLevel = colorizer.colorize(level, `[${String(level).toUpperCase()}]`);
|
|
894
|
+
const formattedMessage = colorizer.colorize(level, inspectValue(stack ?? message));
|
|
895
|
+
const formattedMeta = Object.keys(meta).length > 0 ? ` ${inspectValue(meta)}` : "";
|
|
896
|
+
return `${formattedLabel} ${timestamp} ${formattedLevel} ${formattedMessage}${formattedMeta}`;
|
|
897
|
+
})
|
|
898
|
+
),
|
|
899
|
+
transports: [new import_winston.transports.Console()]
|
|
900
|
+
});
|
|
901
|
+
|
|
902
|
+
// src/runtime-context.ts
|
|
903
|
+
var import_node_async_hooks = require("async_hooks");
|
|
904
|
+
var runtimeStorage = new import_node_async_hooks.AsyncLocalStorage();
|
|
905
|
+
function getActiveRuntime() {
|
|
906
|
+
return runtimeStorage.getStore() ?? null;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
// src/acl/proxy-diagnostics.ts
|
|
910
|
+
var fallbackMode;
|
|
911
|
+
var fallbackLogger;
|
|
912
|
+
var syncProxySnapshotDiagnostics = (mode, logger) => {
|
|
913
|
+
fallbackMode = mode;
|
|
914
|
+
fallbackLogger = logger;
|
|
915
|
+
};
|
|
916
|
+
var normalizeMode = (mode) => mode === "warn" || mode === "silent" ? mode : "error";
|
|
917
|
+
var readProxySnapshotDiagnostics = (runtime) => {
|
|
918
|
+
if (runtime)
|
|
919
|
+
return {
|
|
920
|
+
mode: normalizeMode(runtime.getGlobalOption("authorizationSnapshotProxyLog")),
|
|
921
|
+
logger: runtime.getGlobalOption("logger")
|
|
922
|
+
};
|
|
923
|
+
return { mode: normalizeMode(fallbackMode), logger: fallbackLogger };
|
|
924
|
+
};
|
|
925
|
+
|
|
876
926
|
// src/acl/authorization-snapshot.ts
|
|
927
|
+
function logProxySnapshotRejection(path, error) {
|
|
928
|
+
try {
|
|
929
|
+
const { mode, logger } = readProxySnapshotDiagnostics(getActiveRuntime());
|
|
930
|
+
if (mode === "silent") return;
|
|
931
|
+
const message = `[access-router] Authorization snapshot rejected a Proxy at ${path}`;
|
|
932
|
+
const target = logger?.[mode] ?? defaultLogger[mode];
|
|
933
|
+
target.call(logger ?? defaultLogger, message, error);
|
|
934
|
+
} catch {
|
|
935
|
+
}
|
|
936
|
+
}
|
|
877
937
|
var ServiceAuthorizationError = class extends import_express_json_router.default.clientErrors.BadRequestError {
|
|
878
938
|
constructor(detail) {
|
|
879
939
|
const errors = [{ detail: `Service authorization: ${detail}` }];
|
|
@@ -903,6 +963,7 @@ function authorizationRecord(value, label) {
|
|
|
903
963
|
function copyAuthorizationValue(value, configuration = false) {
|
|
904
964
|
const active = /* @__PURE__ */ new WeakSet();
|
|
905
965
|
const budget = createTrustedOutputBudget();
|
|
966
|
+
const pathFrames = [];
|
|
906
967
|
function copy(input, depth) {
|
|
907
968
|
visitTrustedOutput(budget, depth);
|
|
908
969
|
if (typeof input === "function") {
|
|
@@ -914,9 +975,9 @@ function copyAuthorizationValue(value, configuration = false) {
|
|
|
914
975
|
if (typeof input === "string") prepareTrustedOutputPayload(budget, input);
|
|
915
976
|
return input;
|
|
916
977
|
}
|
|
917
|
-
if (
|
|
978
|
+
if (import_node_util5.types.isProxy(input)) {
|
|
918
979
|
const error = new ServiceAuthorizationError("proxy snapshot input");
|
|
919
|
-
|
|
980
|
+
logProxySnapshotRejection(`$${pathFrames.join("")}`, error);
|
|
920
981
|
throw error;
|
|
921
982
|
}
|
|
922
983
|
const ownedCatalog = configuration === true ? readOwnedAuthorizationCatalogWork(input) : void 0;
|
|
@@ -959,13 +1020,24 @@ function copyAuthorizationValue(value, configuration = false) {
|
|
|
959
1020
|
}
|
|
960
1021
|
if (configuration && input instanceof Map) {
|
|
961
1022
|
const result2 = /* @__PURE__ */ new Map();
|
|
962
|
-
for (const [key, entry] of Map.prototype.entries.call(input))
|
|
963
|
-
|
|
1023
|
+
for (const [key, entry] of Map.prototype.entries.call(input)) {
|
|
1024
|
+
pathFrames.push(".<map-key>");
|
|
1025
|
+
const mappedKey = copy(key, depth + 1);
|
|
1026
|
+
pathFrames.pop();
|
|
1027
|
+
pathFrames.push(".<map-value>");
|
|
1028
|
+
const mappedEntry = copy(entry, depth + 1);
|
|
1029
|
+
pathFrames.pop();
|
|
1030
|
+
result2.set(mappedKey, mappedEntry);
|
|
1031
|
+
}
|
|
964
1032
|
return result2;
|
|
965
1033
|
}
|
|
966
1034
|
if (configuration && input instanceof Set) {
|
|
967
1035
|
const result2 = /* @__PURE__ */ new Set();
|
|
968
|
-
for (const entry of Set.prototype.values.call(input))
|
|
1036
|
+
for (const entry of Set.prototype.values.call(input)) {
|
|
1037
|
+
pathFrames.push(".<set-entry>");
|
|
1038
|
+
result2.add(copy(entry, depth + 1));
|
|
1039
|
+
pathFrames.pop();
|
|
1040
|
+
}
|
|
969
1041
|
return result2;
|
|
970
1042
|
}
|
|
971
1043
|
const array = Array.isArray(input);
|
|
@@ -981,7 +1053,9 @@ function copyAuthorizationValue(value, configuration = false) {
|
|
|
981
1053
|
const descriptor = Object.getOwnPropertyDescriptor(input, key);
|
|
982
1054
|
if (!("value" in descriptor) || !descriptor.enumerable && configuration !== "document")
|
|
983
1055
|
authorizationError("accessor/non-enumerable input");
|
|
1056
|
+
pathFrames.push(array ? `[${key}]` : `.${key}`);
|
|
984
1057
|
const value2 = copy(descriptor.value, depth + 1);
|
|
1058
|
+
pathFrames.pop();
|
|
985
1059
|
if (array || definedProperty && Object.getPrototypeOf(result) !== Object.prototype || key in result) {
|
|
986
1060
|
definedProperty = true;
|
|
987
1061
|
Object.defineProperty(result, key, {
|
|
@@ -1002,7 +1076,7 @@ function copyAuthorizationValue(value, configuration = false) {
|
|
|
1002
1076
|
}
|
|
1003
1077
|
|
|
1004
1078
|
// src/acl/output-work-ledger.ts
|
|
1005
|
-
var preparation = new
|
|
1079
|
+
var preparation = new import_node_async_hooks2.AsyncLocalStorage();
|
|
1006
1080
|
function currentOutputWorkLedger() {
|
|
1007
1081
|
return preparation.getStore();
|
|
1008
1082
|
}
|
|
@@ -1046,7 +1120,7 @@ function prepareOutputWorkString(parts, separator = ".", ledger = currentOutputW
|
|
|
1046
1120
|
}
|
|
1047
1121
|
|
|
1048
1122
|
// src/acl/authorization-modes.ts
|
|
1049
|
-
var
|
|
1123
|
+
var import_node_util6 = require("util");
|
|
1050
1124
|
var retiredAuthorizationOptions = [
|
|
1051
1125
|
"unsafeSkipListDocumentSnapshotChecks",
|
|
1052
1126
|
"unsafeSkipReadDocumentSnapshotChecks",
|
|
@@ -1095,7 +1169,7 @@ function assertAuthorizationModeKey(key, model) {
|
|
|
1095
1169
|
function admitControlPrototypes(value, reject) {
|
|
1096
1170
|
const owners = [];
|
|
1097
1171
|
for (let owner = value; owner; owner = Object.getPrototypeOf(owner)) {
|
|
1098
|
-
if (
|
|
1172
|
+
if (import_node_util6.types.isProxy(owner)) reject("Proxy control/configuration prototype is unsupported");
|
|
1099
1173
|
if (owners.length > 100) reject("Control/configuration prototype depth exceeded");
|
|
1100
1174
|
owners.push(owner);
|
|
1101
1175
|
}
|
|
@@ -1228,7 +1302,7 @@ function walkControlAdmission(input, kind, check, reject) {
|
|
|
1228
1302
|
const { value, kind: slot, path, depth } = pending.pop();
|
|
1229
1303
|
if (!value || typeof value !== "object" && typeof value !== "function") continue;
|
|
1230
1304
|
if (typeof value === "function" && (slot === "policy" || slot === "data")) continue;
|
|
1231
|
-
if (
|
|
1305
|
+
if (import_node_util7.types.isProxy(value)) reject(`unsupported proxy in control admission: ${path}`);
|
|
1232
1306
|
const owners = admitControlPrototypes(value, reject);
|
|
1233
1307
|
const kinds = seen.get(value) ?? /* @__PURE__ */ new Set();
|
|
1234
1308
|
if (kinds.has(slot)) continue;
|
|
@@ -1802,32 +1876,6 @@ var OpenApiRegistry = class {
|
|
|
1802
1876
|
}
|
|
1803
1877
|
};
|
|
1804
1878
|
|
|
1805
|
-
// src/logger-default.ts
|
|
1806
|
-
var import_node_util7 = __toESM(require("util"));
|
|
1807
|
-
var import_winston = require("winston");
|
|
1808
|
-
var colorizer = import_winston.format.colorize();
|
|
1809
|
-
var defaultLogLevel = process.env.WTT_LOG_LEVEL || "silent";
|
|
1810
|
-
var inspectValue = (value) => {
|
|
1811
|
-
return typeof value === "string" ? value : import_node_util7.default.inspect(value, { depth: 5, colors: false });
|
|
1812
|
-
};
|
|
1813
|
-
var defaultLogger = (0, import_winston.createLogger)({
|
|
1814
|
-
level: defaultLogLevel,
|
|
1815
|
-
format: import_winston.format.combine(
|
|
1816
|
-
import_winston.format.errors({ stack: true }),
|
|
1817
|
-
import_winston.format.splat(),
|
|
1818
|
-
import_winston.format.label({ label: "[WTT]" }),
|
|
1819
|
-
import_winston.format.timestamp(),
|
|
1820
|
-
import_winston.format.printf(({ level, label, message, timestamp, stack, ...meta }) => {
|
|
1821
|
-
const formattedLabel = colorizer.colorize(level, String(label));
|
|
1822
|
-
const formattedLevel = colorizer.colorize(level, `[${String(level).toUpperCase()}]`);
|
|
1823
|
-
const formattedMessage = colorizer.colorize(level, inspectValue(stack ?? message));
|
|
1824
|
-
const formattedMeta = Object.keys(meta).length > 0 ? ` ${inspectValue(meta)}` : "";
|
|
1825
|
-
return `${formattedLabel} ${timestamp} ${formattedLevel} ${formattedMessage}${formattedMeta}`;
|
|
1826
|
-
})
|
|
1827
|
-
),
|
|
1828
|
-
transports: [new import_winston.transports.Console()]
|
|
1829
|
-
});
|
|
1830
|
-
|
|
1831
1879
|
// src/options/manager.ts
|
|
1832
1880
|
var import_utils8 = require("@web-ts-toolkit/utils");
|
|
1833
1881
|
var toPath = (key) => {
|
|
@@ -2521,15 +2569,6 @@ var import_utils13 = require("@web-ts-toolkit/utils");
|
|
|
2521
2569
|
|
|
2522
2570
|
// src/acl/populate-target-configuration.ts
|
|
2523
2571
|
var import_utils12 = require("@web-ts-toolkit/utils");
|
|
2524
|
-
|
|
2525
|
-
// src/runtime-context.ts
|
|
2526
|
-
var import_node_async_hooks2 = require("async_hooks");
|
|
2527
|
-
var runtimeStorage = new import_node_async_hooks2.AsyncLocalStorage();
|
|
2528
|
-
function getActiveRuntime() {
|
|
2529
|
-
return runtimeStorage.getStore() ?? null;
|
|
2530
|
-
}
|
|
2531
|
-
|
|
2532
|
-
// src/acl/populate-target-configuration.ts
|
|
2533
2572
|
function capturePopulateTargetConfiguration(runtime, modelName, source, proposedOptions, defaults2 = runtime.getDefaultModelOptions()) {
|
|
2534
2573
|
const label = `Populate target "${modelName}" for ${source}`;
|
|
2535
2574
|
if (!proposedOptions && !runtime.hasModel(modelName))
|
|
@@ -3249,6 +3288,13 @@ var AccessRuntime = class {
|
|
|
3249
3288
|
this.allowGlobalModelLookup = options.allowGlobalModelLookup ?? false;
|
|
3250
3289
|
ensureMongooseJsonSchemaInitialized();
|
|
3251
3290
|
}
|
|
3291
|
+
syncProxySnapshotDiagnosticsState() {
|
|
3292
|
+
if (this !== defaultRuntime) return;
|
|
3293
|
+
syncProxySnapshotDiagnostics(
|
|
3294
|
+
this.globalOptions.get("authorizationSnapshotProxyLog"),
|
|
3295
|
+
this.globalOptions.get("logger")
|
|
3296
|
+
);
|
|
3297
|
+
}
|
|
3252
3298
|
registerModelInstance(modelName, model) {
|
|
3253
3299
|
if (!modelName || typeof modelName !== "string") {
|
|
3254
3300
|
throw new TypeError(`registerModelInstance: modelName must be a non-empty string, received ${typeof modelName}`);
|
|
@@ -3385,6 +3431,7 @@ var AccessRuntime = class {
|
|
|
3385
3431
|
assertNoServerModelControls(options, reject, "data-options");
|
|
3386
3432
|
}
|
|
3387
3433
|
this.globalOptions.restore(snapshot.globalOptions);
|
|
3434
|
+
this.syncProxySnapshotDiagnosticsState();
|
|
3388
3435
|
this.defaultModelOptions.restore(snapshot.defaultModelOptions);
|
|
3389
3436
|
for (const name of Object.keys(this.modelOptionOverrides)) delete this.modelOptionOverrides[name];
|
|
3390
3437
|
for (const [name, options] of Object.entries(snapshot.modelOptionOverrides)) {
|
|
@@ -3449,6 +3496,7 @@ var AccessRuntime = class {
|
|
|
3449
3496
|
});
|
|
3450
3497
|
for (const key of populatePolicyKeys) if (key in options) assertNoGlobalPopulatePolicy(key);
|
|
3451
3498
|
this.globalOptions.assign({ ...options });
|
|
3499
|
+
this.syncProxySnapshotDiagnosticsState();
|
|
3452
3500
|
}
|
|
3453
3501
|
setGlobalOption(key, value) {
|
|
3454
3502
|
assertAuthorizationModeKey(key, false);
|
|
@@ -3459,6 +3507,7 @@ var AccessRuntime = class {
|
|
|
3459
3507
|
throw new TypeError(detail);
|
|
3460
3508
|
});
|
|
3461
3509
|
this.globalOptions.set(key, value);
|
|
3510
|
+
this.syncProxySnapshotDiagnosticsState();
|
|
3462
3511
|
}
|
|
3463
3512
|
getGlobalOptions() {
|
|
3464
3513
|
return this.globalOptions.fetch();
|
package/advanced.mjs
CHANGED
|
@@ -52,7 +52,7 @@ import { types as types6 } from "util";
|
|
|
52
52
|
import { isPlainObject } from "@web-ts-toolkit/utils";
|
|
53
53
|
|
|
54
54
|
// src/acl/output-work-ledger.ts
|
|
55
|
-
import { AsyncLocalStorage } from "async_hooks";
|
|
55
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
56
56
|
|
|
57
57
|
// src/acl/authorization-snapshot.ts
|
|
58
58
|
import { types as types4 } from "util";
|
|
@@ -791,7 +791,67 @@ function materializeTrustedOutputValue(value, path, budget, policy, depth = 0, p
|
|
|
791
791
|
}
|
|
792
792
|
}
|
|
793
793
|
|
|
794
|
+
// src/logger-default.ts
|
|
795
|
+
import util from "util";
|
|
796
|
+
import { createLogger, format, transports } from "winston";
|
|
797
|
+
var colorizer = format.colorize();
|
|
798
|
+
var defaultLogLevel = process.env.WTT_LOG_LEVEL || "silent";
|
|
799
|
+
var inspectValue = (value) => {
|
|
800
|
+
return typeof value === "string" ? value : util.inspect(value, { depth: 5, colors: false });
|
|
801
|
+
};
|
|
802
|
+
var defaultLogger = createLogger({
|
|
803
|
+
level: defaultLogLevel,
|
|
804
|
+
format: format.combine(
|
|
805
|
+
format.errors({ stack: true }),
|
|
806
|
+
format.splat(),
|
|
807
|
+
format.label({ label: "[WTT]" }),
|
|
808
|
+
format.timestamp(),
|
|
809
|
+
format.printf(({ level, label, message, timestamp, stack, ...meta }) => {
|
|
810
|
+
const formattedLabel = colorizer.colorize(level, String(label));
|
|
811
|
+
const formattedLevel = colorizer.colorize(level, `[${String(level).toUpperCase()}]`);
|
|
812
|
+
const formattedMessage = colorizer.colorize(level, inspectValue(stack ?? message));
|
|
813
|
+
const formattedMeta = Object.keys(meta).length > 0 ? ` ${inspectValue(meta)}` : "";
|
|
814
|
+
return `${formattedLabel} ${timestamp} ${formattedLevel} ${formattedMessage}${formattedMeta}`;
|
|
815
|
+
})
|
|
816
|
+
),
|
|
817
|
+
transports: [new transports.Console()]
|
|
818
|
+
});
|
|
819
|
+
|
|
820
|
+
// src/runtime-context.ts
|
|
821
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
822
|
+
var runtimeStorage = new AsyncLocalStorage();
|
|
823
|
+
function getActiveRuntime() {
|
|
824
|
+
return runtimeStorage.getStore() ?? null;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
// src/acl/proxy-diagnostics.ts
|
|
828
|
+
var fallbackMode;
|
|
829
|
+
var fallbackLogger;
|
|
830
|
+
var syncProxySnapshotDiagnostics = (mode, logger) => {
|
|
831
|
+
fallbackMode = mode;
|
|
832
|
+
fallbackLogger = logger;
|
|
833
|
+
};
|
|
834
|
+
var normalizeMode = (mode) => mode === "warn" || mode === "silent" ? mode : "error";
|
|
835
|
+
var readProxySnapshotDiagnostics = (runtime) => {
|
|
836
|
+
if (runtime)
|
|
837
|
+
return {
|
|
838
|
+
mode: normalizeMode(runtime.getGlobalOption("authorizationSnapshotProxyLog")),
|
|
839
|
+
logger: runtime.getGlobalOption("logger")
|
|
840
|
+
};
|
|
841
|
+
return { mode: normalizeMode(fallbackMode), logger: fallbackLogger };
|
|
842
|
+
};
|
|
843
|
+
|
|
794
844
|
// src/acl/authorization-snapshot.ts
|
|
845
|
+
function logProxySnapshotRejection(path, error) {
|
|
846
|
+
try {
|
|
847
|
+
const { mode, logger } = readProxySnapshotDiagnostics(getActiveRuntime());
|
|
848
|
+
if (mode === "silent") return;
|
|
849
|
+
const message = `[access-router] Authorization snapshot rejected a Proxy at ${path}`;
|
|
850
|
+
const target = logger?.[mode] ?? defaultLogger[mode];
|
|
851
|
+
target.call(logger ?? defaultLogger, message, error);
|
|
852
|
+
} catch {
|
|
853
|
+
}
|
|
854
|
+
}
|
|
795
855
|
var ServiceAuthorizationError = class extends JsonRouter.clientErrors.BadRequestError {
|
|
796
856
|
constructor(detail) {
|
|
797
857
|
const errors = [{ detail: `Service authorization: ${detail}` }];
|
|
@@ -821,6 +881,7 @@ function authorizationRecord(value, label) {
|
|
|
821
881
|
function copyAuthorizationValue(value, configuration = false) {
|
|
822
882
|
const active = /* @__PURE__ */ new WeakSet();
|
|
823
883
|
const budget = createTrustedOutputBudget();
|
|
884
|
+
const pathFrames = [];
|
|
824
885
|
function copy(input, depth) {
|
|
825
886
|
visitTrustedOutput(budget, depth);
|
|
826
887
|
if (typeof input === "function") {
|
|
@@ -834,7 +895,7 @@ function copyAuthorizationValue(value, configuration = false) {
|
|
|
834
895
|
}
|
|
835
896
|
if (types4.isProxy(input)) {
|
|
836
897
|
const error = new ServiceAuthorizationError("proxy snapshot input");
|
|
837
|
-
|
|
898
|
+
logProxySnapshotRejection(`$${pathFrames.join("")}`, error);
|
|
838
899
|
throw error;
|
|
839
900
|
}
|
|
840
901
|
const ownedCatalog = configuration === true ? readOwnedAuthorizationCatalogWork(input) : void 0;
|
|
@@ -877,13 +938,24 @@ function copyAuthorizationValue(value, configuration = false) {
|
|
|
877
938
|
}
|
|
878
939
|
if (configuration && input instanceof Map) {
|
|
879
940
|
const result2 = /* @__PURE__ */ new Map();
|
|
880
|
-
for (const [key, entry] of Map.prototype.entries.call(input))
|
|
881
|
-
|
|
941
|
+
for (const [key, entry] of Map.prototype.entries.call(input)) {
|
|
942
|
+
pathFrames.push(".<map-key>");
|
|
943
|
+
const mappedKey = copy(key, depth + 1);
|
|
944
|
+
pathFrames.pop();
|
|
945
|
+
pathFrames.push(".<map-value>");
|
|
946
|
+
const mappedEntry = copy(entry, depth + 1);
|
|
947
|
+
pathFrames.pop();
|
|
948
|
+
result2.set(mappedKey, mappedEntry);
|
|
949
|
+
}
|
|
882
950
|
return result2;
|
|
883
951
|
}
|
|
884
952
|
if (configuration && input instanceof Set) {
|
|
885
953
|
const result2 = /* @__PURE__ */ new Set();
|
|
886
|
-
for (const entry of Set.prototype.values.call(input))
|
|
954
|
+
for (const entry of Set.prototype.values.call(input)) {
|
|
955
|
+
pathFrames.push(".<set-entry>");
|
|
956
|
+
result2.add(copy(entry, depth + 1));
|
|
957
|
+
pathFrames.pop();
|
|
958
|
+
}
|
|
887
959
|
return result2;
|
|
888
960
|
}
|
|
889
961
|
const array = Array.isArray(input);
|
|
@@ -899,7 +971,9 @@ function copyAuthorizationValue(value, configuration = false) {
|
|
|
899
971
|
const descriptor = Object.getOwnPropertyDescriptor(input, key);
|
|
900
972
|
if (!("value" in descriptor) || !descriptor.enumerable && configuration !== "document")
|
|
901
973
|
authorizationError("accessor/non-enumerable input");
|
|
974
|
+
pathFrames.push(array ? `[${key}]` : `.${key}`);
|
|
902
975
|
const value2 = copy(descriptor.value, depth + 1);
|
|
976
|
+
pathFrames.pop();
|
|
903
977
|
if (array || definedProperty && Object.getPrototypeOf(result) !== Object.prototype || key in result) {
|
|
904
978
|
definedProperty = true;
|
|
905
979
|
Object.defineProperty(result, key, {
|
|
@@ -920,7 +994,7 @@ function copyAuthorizationValue(value, configuration = false) {
|
|
|
920
994
|
}
|
|
921
995
|
|
|
922
996
|
// src/acl/output-work-ledger.ts
|
|
923
|
-
var preparation = new
|
|
997
|
+
var preparation = new AsyncLocalStorage2();
|
|
924
998
|
function currentOutputWorkLedger() {
|
|
925
999
|
return preparation.getStore();
|
|
926
1000
|
}
|
|
@@ -1733,32 +1807,6 @@ var OpenApiRegistry = class {
|
|
|
1733
1807
|
}
|
|
1734
1808
|
};
|
|
1735
1809
|
|
|
1736
|
-
// src/logger-default.ts
|
|
1737
|
-
import util from "util";
|
|
1738
|
-
import { createLogger, format, transports } from "winston";
|
|
1739
|
-
var colorizer = format.colorize();
|
|
1740
|
-
var defaultLogLevel = process.env.WTT_LOG_LEVEL || "silent";
|
|
1741
|
-
var inspectValue = (value) => {
|
|
1742
|
-
return typeof value === "string" ? value : util.inspect(value, { depth: 5, colors: false });
|
|
1743
|
-
};
|
|
1744
|
-
var defaultLogger = createLogger({
|
|
1745
|
-
level: defaultLogLevel,
|
|
1746
|
-
format: format.combine(
|
|
1747
|
-
format.errors({ stack: true }),
|
|
1748
|
-
format.splat(),
|
|
1749
|
-
format.label({ label: "[WTT]" }),
|
|
1750
|
-
format.timestamp(),
|
|
1751
|
-
format.printf(({ level, label, message, timestamp, stack, ...meta }) => {
|
|
1752
|
-
const formattedLabel = colorizer.colorize(level, String(label));
|
|
1753
|
-
const formattedLevel = colorizer.colorize(level, `[${String(level).toUpperCase()}]`);
|
|
1754
|
-
const formattedMessage = colorizer.colorize(level, inspectValue(stack ?? message));
|
|
1755
|
-
const formattedMeta = Object.keys(meta).length > 0 ? ` ${inspectValue(meta)}` : "";
|
|
1756
|
-
return `${formattedLabel} ${timestamp} ${formattedLevel} ${formattedMessage}${formattedMeta}`;
|
|
1757
|
-
})
|
|
1758
|
-
),
|
|
1759
|
-
transports: [new transports.Console()]
|
|
1760
|
-
});
|
|
1761
|
-
|
|
1762
1810
|
// src/options/manager.ts
|
|
1763
1811
|
import { assign, get as get2, isPlainObject as isPlainObject8, set } from "@web-ts-toolkit/utils";
|
|
1764
1812
|
var toPath = (key) => {
|
|
@@ -2452,15 +2500,6 @@ import { get as get3, isPlainObject as isPlainObject12 } from "@web-ts-toolkit/u
|
|
|
2452
2500
|
|
|
2453
2501
|
// src/acl/populate-target-configuration.ts
|
|
2454
2502
|
import { isPlainObject as isPlainObject11 } from "@web-ts-toolkit/utils";
|
|
2455
|
-
|
|
2456
|
-
// src/runtime-context.ts
|
|
2457
|
-
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
2458
|
-
var runtimeStorage = new AsyncLocalStorage2();
|
|
2459
|
-
function getActiveRuntime() {
|
|
2460
|
-
return runtimeStorage.getStore() ?? null;
|
|
2461
|
-
}
|
|
2462
|
-
|
|
2463
|
-
// src/acl/populate-target-configuration.ts
|
|
2464
2503
|
function capturePopulateTargetConfiguration(runtime, modelName, source, proposedOptions, defaults2 = runtime.getDefaultModelOptions()) {
|
|
2465
2504
|
const label = `Populate target "${modelName}" for ${source}`;
|
|
2466
2505
|
if (!proposedOptions && !runtime.hasModel(modelName))
|
|
@@ -3180,6 +3219,13 @@ var AccessRuntime = class {
|
|
|
3180
3219
|
this.allowGlobalModelLookup = options.allowGlobalModelLookup ?? false;
|
|
3181
3220
|
ensureMongooseJsonSchemaInitialized();
|
|
3182
3221
|
}
|
|
3222
|
+
syncProxySnapshotDiagnosticsState() {
|
|
3223
|
+
if (this !== defaultRuntime) return;
|
|
3224
|
+
syncProxySnapshotDiagnostics(
|
|
3225
|
+
this.globalOptions.get("authorizationSnapshotProxyLog"),
|
|
3226
|
+
this.globalOptions.get("logger")
|
|
3227
|
+
);
|
|
3228
|
+
}
|
|
3183
3229
|
registerModelInstance(modelName, model) {
|
|
3184
3230
|
if (!modelName || typeof modelName !== "string") {
|
|
3185
3231
|
throw new TypeError(`registerModelInstance: modelName must be a non-empty string, received ${typeof modelName}`);
|
|
@@ -3316,6 +3362,7 @@ var AccessRuntime = class {
|
|
|
3316
3362
|
assertNoServerModelControls(options, reject, "data-options");
|
|
3317
3363
|
}
|
|
3318
3364
|
this.globalOptions.restore(snapshot.globalOptions);
|
|
3365
|
+
this.syncProxySnapshotDiagnosticsState();
|
|
3319
3366
|
this.defaultModelOptions.restore(snapshot.defaultModelOptions);
|
|
3320
3367
|
for (const name of Object.keys(this.modelOptionOverrides)) delete this.modelOptionOverrides[name];
|
|
3321
3368
|
for (const [name, options] of Object.entries(snapshot.modelOptionOverrides)) {
|
|
@@ -3380,6 +3427,7 @@ var AccessRuntime = class {
|
|
|
3380
3427
|
});
|
|
3381
3428
|
for (const key of populatePolicyKeys) if (key in options) assertNoGlobalPopulatePolicy(key);
|
|
3382
3429
|
this.globalOptions.assign({ ...options });
|
|
3430
|
+
this.syncProxySnapshotDiagnosticsState();
|
|
3383
3431
|
}
|
|
3384
3432
|
setGlobalOption(key, value) {
|
|
3385
3433
|
assertAuthorizationModeKey(key, false);
|
|
@@ -3390,6 +3438,7 @@ var AccessRuntime = class {
|
|
|
3390
3438
|
throw new TypeError(detail);
|
|
3391
3439
|
});
|
|
3392
3440
|
this.globalOptions.set(key, value);
|
|
3441
|
+
this.syncProxySnapshotDiagnosticsState();
|
|
3393
3442
|
}
|
|
3394
3443
|
getGlobalOptions() {
|
|
3395
3444
|
return this.globalOptions.fetch();
|
package/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import mongoose__default, { Schema } from 'mongoose';
|
|
2
2
|
import { Response, NextFunction, RequestHandler, Router } from 'express';
|
|
3
|
-
import { A as AccessRouterBaseRequest,
|
|
4
|
-
export {
|
|
3
|
+
import { A as AccessRouterBaseRequest, av as GuardHook, b2 as ModelRequest, e4 as AccessRuntime, a0 as DataRouterOptions, _ as DataRequest, e5 as DataService, ac as ExtendedDataRouterOptions, bn as OperationAccessSetter, aj as Filter, bE as Projection, cK as Sort, bA as Populate, b3 as ModelRouterOptions, e6 as Service, e7 as PublicService, be as ModelVirtualRecordAccess, b8 as ModelVirtualDescriptor, ba as ModelVirtualGetter, bb as ModelVirtualLeaf, ae as ExtendedModelRouterOptions, aQ as ModelDocPermissionsDefinition, dH as Validation, cv as RootRouterOptions, e8 as OpenApiRouterOptions, e9 as OpenApiRegistryOptions, ea as OpenApiRouteDescriptor, eb as OpenApiDocumentOptions, ec as OpenApiParameter, ed as OpenApiSchema, ee as OpenApiResponses, at as GlobalOptions, a4 as DefaultModelRouterOptions, ad as ExtendedDefaultModelRouterOptions } from './parsers-BXwV3svU.mjs';
|
|
4
|
+
export { ef as AccessRouterPermissionMap, eg as AccessRouterPermissions, c as AccessRouterRequest, d as AccessRouterRequestExtensions, l as AjvErrorObjectLike, n as AjvValidatorLike, o as AllowedOutputFieldOptions, p as ArkTypeErrorsLike, q as ArkTypeLike, s as AuthorizationMode, u as AuthorizedListResult, v as AuthorizedSingleResult, J as CreateAuthorization, P as DataFieldOptions, a9 as DocumentGrants, af as FieldAuthorization, ag as FieldOperationAccess, ah as FieldPermissionHook, ai as FieldValidation, al as FilteredOutput, au as GlobalPermissionValue, aw as HydrationMode, az as InputFieldAuthorization, aA as InputFieldPath, aB as IoTsContextEntryLike, aC as IoTsDecodeErrorLike, aD as IoTsDecoderLike, aE as JoiSchemaLike, aF as JoiValidationErrorDetailLike, aL as MaybePromise, aM as ModelBaseFilterHook, aO as ModelDeleteHook, aP as ModelDocPermissionsAccessRecord, aR as ModelDocPermissionsDescriptor, aS as ModelDocPermissionsHook, aU as ModelDocumentHook, aV as ModelHook, aX as ModelHydrationOptions, aY as ModelIdentifierHook, aZ as ModelListHook, a_ as ModelOutputContext, a$ as ModelOutputHook, b0 as ModelOutputListHook, b1 as ModelOverrideFilterHook, b4 as ModelValidateHook, b5 as ModelVirtualAccess, b6 as ModelVirtualAccessRecord, b7 as ModelVirtualContext, b9 as ModelVirtualDoc, bc as ModelVirtualPopulateDependency, bd as ModelVirtualPopulateInputs, bf as ModelVirtuals, bg as MutationAuthorization, bh as NewArgs, bi as NewOptions, eh as OpenApiMethod, bj as OperationAccess, bk as OperationAccessContext, bl as OperationAccessPaths, bm as OperationAccessRule, bo as OperationAccessVariants, bp as OperationAuthorization, bq as OutputAuthorization, br as OutputFieldOptions, bs as OutputFieldPath, bt as OutputPlanningOptions, bw as PairedRouteAccess, bz as PermissionSchema, ei as Permissions, bC as PopulatePlanningOptions, bQ as PublicSubdocumentCreateOptions, bR as PublicSubdocumentListOptions, bS as PublicSubdocumentMutationOptions, bT as PublicSubdocumentReadOptions, bZ as RelatedAuthorization, b$ as RequestSchemaAdapter, c0 as RequestSchemaFailure, c1 as RequestSchemaIssue, c2 as RequestSchemaLike, c3 as RequestSchemaOptions, c4 as RequestSchemaResult, c5 as RequestSchemaSuccess, c6 as RequestSchemaValidator, cy as RouteBaseAccess, cz as RouteGuardAccess, cA as RouteVariant, cB as RowAuthorization, cF as ServiceAuthorization, cG as ServiceOutputContext, cH as ServiceOutputDecorator, cM as StandardSchemaFailure, cN as StandardSchemaInferOutput, cO as StandardSchemaIssue, cP as StandardSchemaPathSegment, cQ as StandardSchemaResult, cR as StandardSchemaSuccess, cS as StandardSchemaV1, cV as SubOperationAccess, cZ as SubRouteGuardOptions, d0 as SubdocumentCreateAuthorization, d2 as SubdocumentCreateOptions, d3 as SubdocumentCreateVisibilityAuthorization, d4 as SubdocumentDeleteAuthorization, d5 as SubdocumentDeleteOptions, d6 as SubdocumentGateAuthorization, d8 as SubdocumentInputAuthorization, d9 as SubdocumentListOptions, da as SubdocumentModel, db as SubdocumentMutationAuthorization, dc as SubdocumentName, dd as SubdocumentOutputAuthorization, dg as SubdocumentReadAuthorization, dh as SubdocumentReadOptions, dj as SubdocumentUpdateOptions, dk as SubdocumentVirtuals, dl as SubdocumentVisibilityAuthorization, dm as SuperstructFailureLike, dn as SuperstructValidateLike, dB as ValibotIssueLike, dC as ValibotPathItemLike, dD as ValibotSafeParseLike, dE as ValibotSafeParseResult, dJ as VineValidationErrorLike, dK as VineValidationMessageLike, dL as VineValidatorLike, dM as VirtualSubModel, dN as WithVirtuals, dO as YupSchemaLike, dP as YupValidationErrorLike, ej as defaultRuntime, dQ as defineRequestSchema, dR as fromAjv, dS as fromArkType, dT as fromIoTs, dU as fromJoi, dV as fromStandardSchema, dW as fromSuperstruct, dX as fromValibot, dY as fromVine, dZ as fromYup, d_ as fromZod } from './parsers-BXwV3svU.mjs';
|
|
5
5
|
import JsonRouter from '@web-ts-toolkit/express-json-router';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'node:buffer';
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import mongoose__default, { Schema } from 'mongoose';
|
|
2
2
|
import { Response, NextFunction, RequestHandler, Router } from 'express';
|
|
3
|
-
import { A as AccessRouterBaseRequest,
|
|
4
|
-
export {
|
|
3
|
+
import { A as AccessRouterBaseRequest, av as GuardHook, b2 as ModelRequest, e4 as AccessRuntime, a0 as DataRouterOptions, _ as DataRequest, e5 as DataService, ac as ExtendedDataRouterOptions, bn as OperationAccessSetter, aj as Filter, bE as Projection, cK as Sort, bA as Populate, b3 as ModelRouterOptions, e6 as Service, e7 as PublicService, be as ModelVirtualRecordAccess, b8 as ModelVirtualDescriptor, ba as ModelVirtualGetter, bb as ModelVirtualLeaf, ae as ExtendedModelRouterOptions, aQ as ModelDocPermissionsDefinition, dH as Validation, cv as RootRouterOptions, e8 as OpenApiRouterOptions, e9 as OpenApiRegistryOptions, ea as OpenApiRouteDescriptor, eb as OpenApiDocumentOptions, ec as OpenApiParameter, ed as OpenApiSchema, ee as OpenApiResponses, at as GlobalOptions, a4 as DefaultModelRouterOptions, ad as ExtendedDefaultModelRouterOptions } from './parsers-BXwV3svU.js';
|
|
4
|
+
export { ef as AccessRouterPermissionMap, eg as AccessRouterPermissions, c as AccessRouterRequest, d as AccessRouterRequestExtensions, l as AjvErrorObjectLike, n as AjvValidatorLike, o as AllowedOutputFieldOptions, p as ArkTypeErrorsLike, q as ArkTypeLike, s as AuthorizationMode, u as AuthorizedListResult, v as AuthorizedSingleResult, J as CreateAuthorization, P as DataFieldOptions, a9 as DocumentGrants, af as FieldAuthorization, ag as FieldOperationAccess, ah as FieldPermissionHook, ai as FieldValidation, al as FilteredOutput, au as GlobalPermissionValue, aw as HydrationMode, az as InputFieldAuthorization, aA as InputFieldPath, aB as IoTsContextEntryLike, aC as IoTsDecodeErrorLike, aD as IoTsDecoderLike, aE as JoiSchemaLike, aF as JoiValidationErrorDetailLike, aL as MaybePromise, aM as ModelBaseFilterHook, aO as ModelDeleteHook, aP as ModelDocPermissionsAccessRecord, aR as ModelDocPermissionsDescriptor, aS as ModelDocPermissionsHook, aU as ModelDocumentHook, aV as ModelHook, aX as ModelHydrationOptions, aY as ModelIdentifierHook, aZ as ModelListHook, a_ as ModelOutputContext, a$ as ModelOutputHook, b0 as ModelOutputListHook, b1 as ModelOverrideFilterHook, b4 as ModelValidateHook, b5 as ModelVirtualAccess, b6 as ModelVirtualAccessRecord, b7 as ModelVirtualContext, b9 as ModelVirtualDoc, bc as ModelVirtualPopulateDependency, bd as ModelVirtualPopulateInputs, bf as ModelVirtuals, bg as MutationAuthorization, bh as NewArgs, bi as NewOptions, eh as OpenApiMethod, bj as OperationAccess, bk as OperationAccessContext, bl as OperationAccessPaths, bm as OperationAccessRule, bo as OperationAccessVariants, bp as OperationAuthorization, bq as OutputAuthorization, br as OutputFieldOptions, bs as OutputFieldPath, bt as OutputPlanningOptions, bw as PairedRouteAccess, bz as PermissionSchema, ei as Permissions, bC as PopulatePlanningOptions, bQ as PublicSubdocumentCreateOptions, bR as PublicSubdocumentListOptions, bS as PublicSubdocumentMutationOptions, bT as PublicSubdocumentReadOptions, bZ as RelatedAuthorization, b$ as RequestSchemaAdapter, c0 as RequestSchemaFailure, c1 as RequestSchemaIssue, c2 as RequestSchemaLike, c3 as RequestSchemaOptions, c4 as RequestSchemaResult, c5 as RequestSchemaSuccess, c6 as RequestSchemaValidator, cy as RouteBaseAccess, cz as RouteGuardAccess, cA as RouteVariant, cB as RowAuthorization, cF as ServiceAuthorization, cG as ServiceOutputContext, cH as ServiceOutputDecorator, cM as StandardSchemaFailure, cN as StandardSchemaInferOutput, cO as StandardSchemaIssue, cP as StandardSchemaPathSegment, cQ as StandardSchemaResult, cR as StandardSchemaSuccess, cS as StandardSchemaV1, cV as SubOperationAccess, cZ as SubRouteGuardOptions, d0 as SubdocumentCreateAuthorization, d2 as SubdocumentCreateOptions, d3 as SubdocumentCreateVisibilityAuthorization, d4 as SubdocumentDeleteAuthorization, d5 as SubdocumentDeleteOptions, d6 as SubdocumentGateAuthorization, d8 as SubdocumentInputAuthorization, d9 as SubdocumentListOptions, da as SubdocumentModel, db as SubdocumentMutationAuthorization, dc as SubdocumentName, dd as SubdocumentOutputAuthorization, dg as SubdocumentReadAuthorization, dh as SubdocumentReadOptions, dj as SubdocumentUpdateOptions, dk as SubdocumentVirtuals, dl as SubdocumentVisibilityAuthorization, dm as SuperstructFailureLike, dn as SuperstructValidateLike, dB as ValibotIssueLike, dC as ValibotPathItemLike, dD as ValibotSafeParseLike, dE as ValibotSafeParseResult, dJ as VineValidationErrorLike, dK as VineValidationMessageLike, dL as VineValidatorLike, dM as VirtualSubModel, dN as WithVirtuals, dO as YupSchemaLike, dP as YupValidationErrorLike, ej as defaultRuntime, dQ as defineRequestSchema, dR as fromAjv, dS as fromArkType, dT as fromIoTs, dU as fromJoi, dV as fromStandardSchema, dW as fromSuperstruct, dX as fromValibot, dY as fromVine, dZ as fromYup, d_ as fromZod } from './parsers-BXwV3svU.js';
|
|
5
5
|
import JsonRouter from '@web-ts-toolkit/express-json-router';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'node:buffer';
|