@camstack/server 1.2.809 → 1.2.811
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 +17 -0
- package/dist/api/trpc/cap-router-runtime.js +3 -0
- package/dist/api/trpc/generated-cap-mounts.js +3 -1
- package/dist/api/trpc/generated-cap-routers.js +1869 -1789
- package/dist/core/addon/hub-addon-api.js +8 -1
- package/dist/core/moleculer/moleculer.service.js +3 -0
- package/package.json +10 -8
- package/system/dist/addon-runner.js +4 -1
- package/system/dist/addon-runner.mjs +5 -2
- package/system/dist/{agent-https-DS4b0ucn.mjs → agent-https-CyEBY3RB.mjs} +1 -1
- package/system/dist/{agent-https-CuChFRA2.js → agent-https-a3mE4PW4.js} +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/alerts/alerts.addon.js +3 -101
- package/system/dist/builtins/alerts/alerts.addon.mjs +40 -134
- package/system/dist/builtins/autotrack/index.js +1 -1
- package/system/dist/builtins/autotrack/index.mjs +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
- package/system/dist/builtins/backup-orchestrator/destination-policy.d.ts +1 -1
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +1 -1
- package/system/dist/builtins/camera-grid/index.mjs +1 -1
- package/system/dist/builtins/composer/composer.addon.js +6 -5
- package/system/dist/builtins/composer/composer.addon.mjs +6 -5
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.d.ts +2 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +358 -32
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +361 -35
- package/system/dist/builtins/core-blocks/hero-layout-service.d.ts +42 -0
- package/system/dist/builtins/core-blocks/remote-call-redirect.d.ts +1 -1
- package/system/dist/builtins/core-blocks/remote-service.d.ts +38 -0
- package/system/dist/builtins/device-history/device-history.addon.d.ts +5 -0
- package/system/dist/builtins/device-history/device-history.addon.js +357 -18
- package/system/dist/builtins/device-history/device-history.addon.mjs +357 -18
- package/system/dist/builtins/device-history/retention/retention.d.ts +14 -1
- package/system/dist/builtins/device-history/transitions/device-transitions-record-kinds.d.ts +14 -0
- package/system/dist/builtins/device-history/transitions/transitions-service.d.ts +80 -0
- package/system/dist/builtins/device-manager/device-manager.addon.d.ts +2 -0
- package/system/dist/builtins/device-manager/device-manager.addon.js +712 -18
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +780 -95
- package/system/dist/builtins/device-manager/device-state-mirror.d.ts +7 -0
- package/system/dist/builtins/device-manager/transitions/command-args.d.ts +4 -0
- package/system/dist/builtins/device-manager/transitions/transition-correlator.d.ts +68 -0
- package/system/dist/builtins/device-manager/transitions/transitions-sender.d.ts +37 -0
- package/system/dist/builtins/device-manager/transitions/transitions-wiring.d.ts +25 -0
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +4 -4
- package/system/dist/builtins/keychain/index.mjs +4 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
- package/system/dist/builtins/local-network/local-network.addon.js +2 -2
- package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
- package/system/dist/builtins/loki-logging/index.js +8 -2
- package/system/dist/builtins/loki-logging/index.mjs +8 -2
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +1 -1
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +1 -1
- package/system/dist/builtins/snapshot/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
- package/system/dist/builtins/storage-orchestrator/location-store.d.ts +0 -6
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/system-config/system-config.addon.js +3 -3
- package/system/dist/builtins/system-config/system-config.addon.mjs +7 -7
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{capture-engine-Byc5Fkp0.js → capture-engine-BO9mSlY-.js} +1 -1
- package/system/dist/{capture-engine-CnVIcnyN.mjs → capture-engine-ByF-6AFH.mjs} +1 -1
- package/system/dist/{composition-sources-BhM6G9QT.mjs → composition-sources-AziMFo7T.mjs} +1 -1
- package/system/dist/{composition-sources-BxK6ttP9.js → composition-sources-BMJUPUh2.js} +1 -1
- package/system/dist/{constants-Bf1PEHRU.mjs → constants-CTikgsC_.mjs} +1 -1
- package/system/dist/{constants--xo6Q-KA.js → constants-CjRlgRlu.js} +1 -1
- package/system/dist/{device-ca-Do0-HV_h.mjs → device-ca-CNRlFqFC.mjs} +1 -1
- package/system/dist/{device-ca-Uq5KGFSq.js → device-ca-Dxl6kVcJ.js} +1 -1
- package/system/dist/{dist-CogtCQxu.mjs → dist-BPq13Y8j.mjs} +17544 -15612
- package/system/dist/{dist-2SHQaxaS.js → dist-CkJnelZr.js} +17615 -15617
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-mdns-ciao-aFHCKrif.mjs → hub-mdns-ciao-CrjItezp.mjs} +2 -2
- package/system/dist/{hub-mdns-ciao-DqPrLiYH.js → hub-mdns-ciao-Cx6yJBl9.js} +2 -2
- package/system/dist/index.js +67 -75
- package/system/dist/index.mjs +53 -68
- package/system/dist/kernel/cap-router-builder.d.ts +9 -0
- package/system/dist/kernel/command-observation.d.ts +76 -0
- package/system/dist/kernel/index.d.ts +2 -0
- package/system/dist/kernel/transport/child-cap-protocol.d.ts +10 -1
- package/system/dist/kernel/transport/local-child-registry.d.ts +15 -0
- package/system/dist/{legacy-integration-rows-door-Bz8rivxI.js → legacy-integration-rows-door-CKM-LxvL.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-CiuxDLoc.mjs → legacy-integration-rows-door-Dxcqwc-w.mjs} +1 -1
- package/system/dist/log-redactor-BhIEMaG9.js +149 -0
- package/system/dist/log-redactor-XLDrPzOi.mjs +120 -0
- package/system/dist/logging/log-redactor.d.ts +2 -0
- package/system/dist/{restore-archive-PlBC2NwT.mjs → restore-archive-BFA-hEhX.mjs} +5 -5
- package/system/dist/{restore-archive-D-3wmHDq.js → restore-archive-BQWOdGAB.js} +1 -1
- package/system/dist/{retention-BNONb5X_.js → retention-BcOSL6b9.js} +33 -2
- package/system/dist/{retention-B9l9TnGE.mjs → retention-CUOVI1p7.mjs} +33 -2
- package/system/dist/{wal-maintenance-BTR55y--.js → wal-maintenance-CiCgL4Hp.js} +0 -0
- package/system/dist/{wal-maintenance-jrhYTCn2.mjs → wal-maintenance-zJ4-ORo6.mjs} +0 -0
- package/system/package.json +7 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
let _camstack_types_addon = require("@camstack/types/addon");
|
|
2
|
+
//#region src/logging/log-redactor.ts
|
|
3
|
+
var REDACTED = "***";
|
|
4
|
+
/** Credential-named keys. Substring, case-insensitive; only STRING values are replaced. */
|
|
5
|
+
var SECRET_KEY_SUBSTRINGS = [
|
|
6
|
+
"password",
|
|
7
|
+
"passwd",
|
|
8
|
+
"secret",
|
|
9
|
+
"token",
|
|
10
|
+
"apikey",
|
|
11
|
+
"api_key",
|
|
12
|
+
"authkey",
|
|
13
|
+
"auth_key",
|
|
14
|
+
"privatekey",
|
|
15
|
+
"private_key",
|
|
16
|
+
"passphrase",
|
|
17
|
+
"credential",
|
|
18
|
+
"cookie"
|
|
19
|
+
];
|
|
20
|
+
/** True when a meta key names a credential. */
|
|
21
|
+
function isCredentialKeyName(key) {
|
|
22
|
+
const lower = key.toLowerCase();
|
|
23
|
+
return SECRET_KEY_SUBSTRINGS.some((needle) => lower.includes(needle));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Words that name a credential only as the LAST word of a key (`pin`, `adminPin`,
|
|
27
|
+
* `otp`, `apiKey`, `code`). Not part of the log net above: an error `code`
|
|
28
|
+
* is a string in most log meta, and `keyFrame` is not a key. Used where an
|
|
29
|
+
* argument bag is stored (D1022), where a wrongly hidden value costs less than
|
|
30
|
+
* a leaked code.
|
|
31
|
+
*/
|
|
32
|
+
var SECRET_LAST_WORDS = new Set([
|
|
33
|
+
"pin",
|
|
34
|
+
"pincode",
|
|
35
|
+
"passcode",
|
|
36
|
+
"otp",
|
|
37
|
+
"code",
|
|
38
|
+
"key"
|
|
39
|
+
]);
|
|
40
|
+
/** The last camelCase / snake_case / kebab-case word of a key, lowercased. */
|
|
41
|
+
function lastWord(key) {
|
|
42
|
+
const words = key.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_-]+/);
|
|
43
|
+
return (words[words.length - 1] ?? "").toLowerCase();
|
|
44
|
+
}
|
|
45
|
+
/** True for a credential-named key, or one whose last word is a code, pin, otp or key. */
|
|
46
|
+
function isSecretArgumentKey(key) {
|
|
47
|
+
return isCredentialKeyName(key) || SECRET_LAST_WORDS.has(lastWord(key));
|
|
48
|
+
}
|
|
49
|
+
var URL_IN_TEXT = /\b[a-z][a-z0-9+.-]*:\/\/[^\s"'<>`]+/gi;
|
|
50
|
+
/** A root-relative path WITH a query, as request logs print it. */
|
|
51
|
+
var RELATIVE_URL_IN_TEXT = /(^|[\s"'(=])(\/[^\s"'<>`?]*\?[^\s"'<>`]+)/g;
|
|
52
|
+
var CREDENTIAL_FLAG = /(--(?:token|auth-?key|password|passwd|pass|secret|api-?key|access-?token|refresh-?token)(?:=|\s+))(\S+)/gi;
|
|
53
|
+
/** Redact one free-form string. */
|
|
54
|
+
function redactLogText(text) {
|
|
55
|
+
let out = (0, _camstack_types_addon.scrubKnownSecrets)(text);
|
|
56
|
+
if (out.includes("://")) out = out.replace(URL_IN_TEXT, (url) => (0, _camstack_types_addon.maskUrlCredentials)(url));
|
|
57
|
+
if (out.includes("/") && out.includes("?") && out.includes("=")) out = out.replace(RELATIVE_URL_IN_TEXT, (_m, lead, path) => `${lead}${(0, _camstack_types_addon.maskUrlCredentials)(path)}`);
|
|
58
|
+
if (out.includes("--")) out = out.replace(CREDENTIAL_FLAG, (_m, flag, value) => value.startsWith("‹secret:") ? `${flag}${value}` : `${flag}${REDACTED}`);
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
/** Bounds on the meta walk — a log line is not a place to traverse a graph. */
|
|
62
|
+
var MAX_DEPTH = 8;
|
|
63
|
+
var MAX_NODES = 2e3;
|
|
64
|
+
/**
|
|
65
|
+
* Redact a value, returning the SAME reference when nothing in it changed —
|
|
66
|
+
* most lines carry clean meta, and copying every one would put an allocation
|
|
67
|
+
* per log line on hub-main's event loop.
|
|
68
|
+
*/
|
|
69
|
+
function redactValue(value, depth, budget, seen) {
|
|
70
|
+
if (budget.nodes++ > MAX_NODES) return value;
|
|
71
|
+
if (typeof value === "string") return redactLogText(value);
|
|
72
|
+
if (value === null || typeof value !== "object") return value;
|
|
73
|
+
if (depth >= MAX_DEPTH || seen.has(value)) return value;
|
|
74
|
+
if (value instanceof Error) {
|
|
75
|
+
const message = redactLogText(value.message);
|
|
76
|
+
return message === value.message ? value : message;
|
|
77
|
+
}
|
|
78
|
+
if (value instanceof Date || ArrayBuffer.isView(value) || value instanceof ArrayBuffer) return value;
|
|
79
|
+
seen.add(value);
|
|
80
|
+
if (Array.isArray(value)) {
|
|
81
|
+
let copy = null;
|
|
82
|
+
for (let i = 0; i < value.length; i++) {
|
|
83
|
+
const item = value[i];
|
|
84
|
+
const next = redactValue(item, depth + 1, budget, seen);
|
|
85
|
+
if (next !== item) {
|
|
86
|
+
copy ??= [...value];
|
|
87
|
+
copy[i] = next;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return copy ?? value;
|
|
91
|
+
}
|
|
92
|
+
let copy = null;
|
|
93
|
+
for (const [key, child] of Object.entries(value)) {
|
|
94
|
+
const next = typeof child === "string" && child.length > 0 && isCredentialKeyName(key) ? REDACTED : redactValue(child, depth + 1, budget, seen);
|
|
95
|
+
if (next !== child) {
|
|
96
|
+
copy ??= { ...value };
|
|
97
|
+
copy[key] = next;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return copy ?? value;
|
|
101
|
+
}
|
|
102
|
+
/** Redact a `meta` record; the same object back when it was already clean. */
|
|
103
|
+
function redactLogMeta(meta) {
|
|
104
|
+
const out = redactValue(meta, 0, { nodes: 0 }, /* @__PURE__ */ new WeakSet());
|
|
105
|
+
if (out === meta) return meta;
|
|
106
|
+
return out !== null && typeof out === "object" && !Array.isArray(out) ? Object.fromEntries(Object.entries(out)) : meta;
|
|
107
|
+
}
|
|
108
|
+
/** Redact a whole entry: message and meta. Tags are identifiers, left alone. */
|
|
109
|
+
function redactLogEntry(entry) {
|
|
110
|
+
const message = redactLogText(entry.message);
|
|
111
|
+
const meta = entry.meta !== void 0 ? redactLogMeta(entry.meta) : void 0;
|
|
112
|
+
if (message === entry.message && meta === entry.meta) return entry;
|
|
113
|
+
return {
|
|
114
|
+
...entry,
|
|
115
|
+
message,
|
|
116
|
+
...meta !== void 0 ? { meta } : {}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
Object.defineProperty(exports, "isCredentialKeyName", {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function() {
|
|
123
|
+
return isCredentialKeyName;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
Object.defineProperty(exports, "isSecretArgumentKey", {
|
|
127
|
+
enumerable: true,
|
|
128
|
+
get: function() {
|
|
129
|
+
return isSecretArgumentKey;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
Object.defineProperty(exports, "redactLogEntry", {
|
|
133
|
+
enumerable: true,
|
|
134
|
+
get: function() {
|
|
135
|
+
return redactLogEntry;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
Object.defineProperty(exports, "redactLogMeta", {
|
|
139
|
+
enumerable: true,
|
|
140
|
+
get: function() {
|
|
141
|
+
return redactLogMeta;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
Object.defineProperty(exports, "redactLogText", {
|
|
145
|
+
enumerable: true,
|
|
146
|
+
get: function() {
|
|
147
|
+
return redactLogText;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { maskUrlCredentials, scrubKnownSecrets } from "@camstack/types/addon";
|
|
2
|
+
//#region src/logging/log-redactor.ts
|
|
3
|
+
var REDACTED = "***";
|
|
4
|
+
/** Credential-named keys. Substring, case-insensitive; only STRING values are replaced. */
|
|
5
|
+
var SECRET_KEY_SUBSTRINGS = [
|
|
6
|
+
"password",
|
|
7
|
+
"passwd",
|
|
8
|
+
"secret",
|
|
9
|
+
"token",
|
|
10
|
+
"apikey",
|
|
11
|
+
"api_key",
|
|
12
|
+
"authkey",
|
|
13
|
+
"auth_key",
|
|
14
|
+
"privatekey",
|
|
15
|
+
"private_key",
|
|
16
|
+
"passphrase",
|
|
17
|
+
"credential",
|
|
18
|
+
"cookie"
|
|
19
|
+
];
|
|
20
|
+
/** True when a meta key names a credential. */
|
|
21
|
+
function isCredentialKeyName(key) {
|
|
22
|
+
const lower = key.toLowerCase();
|
|
23
|
+
return SECRET_KEY_SUBSTRINGS.some((needle) => lower.includes(needle));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Words that name a credential only as the LAST word of a key (`pin`, `adminPin`,
|
|
27
|
+
* `otp`, `apiKey`, `code`). Not part of the log net above: an error `code`
|
|
28
|
+
* is a string in most log meta, and `keyFrame` is not a key. Used where an
|
|
29
|
+
* argument bag is stored (D1022), where a wrongly hidden value costs less than
|
|
30
|
+
* a leaked code.
|
|
31
|
+
*/
|
|
32
|
+
var SECRET_LAST_WORDS = new Set([
|
|
33
|
+
"pin",
|
|
34
|
+
"pincode",
|
|
35
|
+
"passcode",
|
|
36
|
+
"otp",
|
|
37
|
+
"code",
|
|
38
|
+
"key"
|
|
39
|
+
]);
|
|
40
|
+
/** The last camelCase / snake_case / kebab-case word of a key, lowercased. */
|
|
41
|
+
function lastWord(key) {
|
|
42
|
+
const words = key.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_-]+/);
|
|
43
|
+
return (words[words.length - 1] ?? "").toLowerCase();
|
|
44
|
+
}
|
|
45
|
+
/** True for a credential-named key, or one whose last word is a code, pin, otp or key. */
|
|
46
|
+
function isSecretArgumentKey(key) {
|
|
47
|
+
return isCredentialKeyName(key) || SECRET_LAST_WORDS.has(lastWord(key));
|
|
48
|
+
}
|
|
49
|
+
var URL_IN_TEXT = /\b[a-z][a-z0-9+.-]*:\/\/[^\s"'<>`]+/gi;
|
|
50
|
+
/** A root-relative path WITH a query, as request logs print it. */
|
|
51
|
+
var RELATIVE_URL_IN_TEXT = /(^|[\s"'(=])(\/[^\s"'<>`?]*\?[^\s"'<>`]+)/g;
|
|
52
|
+
var CREDENTIAL_FLAG = /(--(?:token|auth-?key|password|passwd|pass|secret|api-?key|access-?token|refresh-?token)(?:=|\s+))(\S+)/gi;
|
|
53
|
+
/** Redact one free-form string. */
|
|
54
|
+
function redactLogText(text) {
|
|
55
|
+
let out = scrubKnownSecrets(text);
|
|
56
|
+
if (out.includes("://")) out = out.replace(URL_IN_TEXT, (url) => maskUrlCredentials(url));
|
|
57
|
+
if (out.includes("/") && out.includes("?") && out.includes("=")) out = out.replace(RELATIVE_URL_IN_TEXT, (_m, lead, path) => `${lead}${maskUrlCredentials(path)}`);
|
|
58
|
+
if (out.includes("--")) out = out.replace(CREDENTIAL_FLAG, (_m, flag, value) => value.startsWith("‹secret:") ? `${flag}${value}` : `${flag}${REDACTED}`);
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
/** Bounds on the meta walk — a log line is not a place to traverse a graph. */
|
|
62
|
+
var MAX_DEPTH = 8;
|
|
63
|
+
var MAX_NODES = 2e3;
|
|
64
|
+
/**
|
|
65
|
+
* Redact a value, returning the SAME reference when nothing in it changed —
|
|
66
|
+
* most lines carry clean meta, and copying every one would put an allocation
|
|
67
|
+
* per log line on hub-main's event loop.
|
|
68
|
+
*/
|
|
69
|
+
function redactValue(value, depth, budget, seen) {
|
|
70
|
+
if (budget.nodes++ > MAX_NODES) return value;
|
|
71
|
+
if (typeof value === "string") return redactLogText(value);
|
|
72
|
+
if (value === null || typeof value !== "object") return value;
|
|
73
|
+
if (depth >= MAX_DEPTH || seen.has(value)) return value;
|
|
74
|
+
if (value instanceof Error) {
|
|
75
|
+
const message = redactLogText(value.message);
|
|
76
|
+
return message === value.message ? value : message;
|
|
77
|
+
}
|
|
78
|
+
if (value instanceof Date || ArrayBuffer.isView(value) || value instanceof ArrayBuffer) return value;
|
|
79
|
+
seen.add(value);
|
|
80
|
+
if (Array.isArray(value)) {
|
|
81
|
+
let copy = null;
|
|
82
|
+
for (let i = 0; i < value.length; i++) {
|
|
83
|
+
const item = value[i];
|
|
84
|
+
const next = redactValue(item, depth + 1, budget, seen);
|
|
85
|
+
if (next !== item) {
|
|
86
|
+
copy ??= [...value];
|
|
87
|
+
copy[i] = next;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return copy ?? value;
|
|
91
|
+
}
|
|
92
|
+
let copy = null;
|
|
93
|
+
for (const [key, child] of Object.entries(value)) {
|
|
94
|
+
const next = typeof child === "string" && child.length > 0 && isCredentialKeyName(key) ? REDACTED : redactValue(child, depth + 1, budget, seen);
|
|
95
|
+
if (next !== child) {
|
|
96
|
+
copy ??= { ...value };
|
|
97
|
+
copy[key] = next;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return copy ?? value;
|
|
101
|
+
}
|
|
102
|
+
/** Redact a `meta` record; the same object back when it was already clean. */
|
|
103
|
+
function redactLogMeta(meta) {
|
|
104
|
+
const out = redactValue(meta, 0, { nodes: 0 }, /* @__PURE__ */ new WeakSet());
|
|
105
|
+
if (out === meta) return meta;
|
|
106
|
+
return out !== null && typeof out === "object" && !Array.isArray(out) ? Object.fromEntries(Object.entries(out)) : meta;
|
|
107
|
+
}
|
|
108
|
+
/** Redact a whole entry: message and meta. Tags are identifiers, left alone. */
|
|
109
|
+
function redactLogEntry(entry) {
|
|
110
|
+
const message = redactLogText(entry.message);
|
|
111
|
+
const meta = entry.meta !== void 0 ? redactLogMeta(entry.meta) : void 0;
|
|
112
|
+
if (message === entry.message && meta === entry.meta) return entry;
|
|
113
|
+
return {
|
|
114
|
+
...entry,
|
|
115
|
+
message,
|
|
116
|
+
...meta !== void 0 ? { meta } : {}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
export { redactLogText as a, redactLogMeta as i, isSecretArgumentKey as n, redactLogEntry as r, isCredentialKeyName as t };
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
import type { LogEntry } from "@camstack/types";
|
|
23
23
|
/** True when a meta key names a credential. */
|
|
24
24
|
export declare function isCredentialKeyName(key: string): boolean;
|
|
25
|
+
/** True for a credential-named key, or one whose last word is a code, pin, otp or key. */
|
|
26
|
+
export declare function isSecretArgumentKey(key: string): boolean;
|
|
25
27
|
/** Redact one free-form string. */
|
|
26
28
|
export declare function redactLogText(text: string): string;
|
|
27
29
|
/** Redact a `meta` record; the same object back when it was already clean. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { P as DATABASE_SNAPSHOT_SUFFIX, Zs as defineRecordKinds, q as DataStoreDatabaseSchema } from "./dist-BPq13Y8j.mjs";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { createCipheriv, createDecipheriv, createHash, createPrivateKey, createPublicKey, diffieHellman, generateKeyPairSync, hkdfSync, randomBytes } from "node:crypto";
|
|
4
4
|
import { Buffer as Buffer$1 } from "buffer";
|
|
@@ -9,7 +9,7 @@ import path, { basename, join, posix, win32 } from "node:path";
|
|
|
9
9
|
import * as fsp from "node:fs/promises";
|
|
10
10
|
import jn from "node:fs/promises";
|
|
11
11
|
import { EventEmitter } from "node:events";
|
|
12
|
-
import
|
|
12
|
+
import As, { Transform } from "node:stream";
|
|
13
13
|
import { StringDecoder } from "node:string_decoder";
|
|
14
14
|
import fs$1 from "fs";
|
|
15
15
|
import path$1, { dirname as dirname$1, parse } from "path";
|
|
@@ -477,7 +477,7 @@ var Br = (s, t) => {
|
|
|
477
477
|
var xs = typeof process == "object" && process ? process : {
|
|
478
478
|
stdout: null,
|
|
479
479
|
stderr: null
|
|
480
|
-
}, zr = (s) => !!s && typeof s == "object" && (s instanceof A || s instanceof
|
|
480
|
+
}, zr = (s) => !!s && typeof s == "object" && (s instanceof A || s instanceof As || Ur(s) || Hr(s)), Ur = (s) => !!s && typeof s == "object" && s instanceof EventEmitter && typeof s.pipe == "function" && s.pipe !== As.Writable.prototype.pipe, Hr = (s) => !!s && typeof s == "object" && s instanceof EventEmitter && typeof s.write == "function" && typeof s.end == "function", q = Symbol("EOF"), Q = Symbol("maybeEmitEnd"), rt = Symbol("emittedEnd"), Le = Symbol("emittingEnd"), qt = Symbol("emittedError"), Ne = Symbol("closed"), Ls = Symbol("read"), De = Symbol("flush"), Ns = Symbol("flushChunk"), z$1 = Symbol("encoding"), Mt = Symbol("decoder"), g = Symbol("flowing"), Qt = Symbol("paused"), Bt = Symbol("resume"), b = Symbol("buffer"), D = Symbol("pipes"), _ = Symbol("bufferLength"), gi = Symbol("bufferPush"), Ae = Symbol("bufferShift"), L = Symbol("objectMode"), w = Symbol("destroyed"), bi = Symbol("error"), _i = Symbol("emitData"), Ds = Symbol("emitEnd"), Oi = Symbol("emitEnd2"), Z = Symbol("async"), Ti = Symbol("abort"), Ie = Symbol("aborted"), Jt = Symbol("signal"), Rt = Symbol("dataListeners"), F = Symbol("discarded"), jt = (s) => Promise.resolve().then(s), Wr = (s) => s(), Gr = (s) => s === "end" || s === "finish" || s === "prefinish", Zr = (s) => s instanceof ArrayBuffer || !!s && typeof s == "object" && s.constructor && s.constructor.name === "ArrayBuffer" && s.byteLength >= 0, Yr = (s) => !Buffer.isBuffer(s) && ArrayBuffer.isView(s), Fe = class {
|
|
481
481
|
src;
|
|
482
482
|
dest;
|
|
483
483
|
opts;
|
|
@@ -1268,7 +1268,7 @@ var tn = Buffer$1.concat, Bs = Object.getOwnPropertyDescriptor(Buffer$1, "concat
|
|
|
1268
1268
|
}
|
|
1269
1269
|
}
|
|
1270
1270
|
};
|
|
1271
|
-
var Pe
|
|
1271
|
+
var Pe = class extends Be {
|
|
1272
1272
|
#t;
|
|
1273
1273
|
constructor(t) {
|
|
1274
1274
|
super(t, "Gzip"), this.#t = t && !!t.portable;
|
|
@@ -2428,7 +2428,7 @@ var mi = class {
|
|
|
2428
2428
|
constructor(t = {}) {
|
|
2429
2429
|
if (super(), this.opt = t, this.file = t.file || "", this.cwd = t.cwd || process.cwd(), this.maxReadSize = t.maxReadSize, this.preservePaths = !!t.preservePaths, this.strict = !!t.strict, this.noPax = !!t.noPax, this.prefix = f(t.prefix || ""), this.linkCache = t.linkCache || /* @__PURE__ */ new Map(), this.statCache = t.statCache || /* @__PURE__ */ new Map(), this.readdirCache = t.readdirCache || /* @__PURE__ */ new Map(), this.onWriteEntry = t.onWriteEntry, this[di] = fe, typeof t.onwarn == "function" && this.on("warn", t.onwarn), this.portable = !!t.portable, t.gzip || t.brotli || t.zstd) {
|
|
2430
2430
|
if ((t.gzip ? 1 : 0) + (t.brotli ? 1 : 0) + (t.zstd ? 1 : 0) > 1) throw new TypeError("gzip, brotli, zstd are mutually exclusive");
|
|
2431
|
-
if (t.gzip && (typeof t.gzip != "object" && (t.gzip = {}), this.portable && (t.gzip.portable = !0), this.zip = new Pe
|
|
2431
|
+
if (t.gzip && (typeof t.gzip != "object" && (t.gzip = {}), this.portable && (t.gzip.portable = !0), this.zip = new Pe(t.gzip)), t.brotli && (typeof t.brotli != "object" && (t.brotli = {}), this.zip = new He(t.brotli)), t.zstd && (typeof t.zstd != "object" && (t.zstd = {}), this.zip = new Ze(t.zstd)), !this.zip) throw new Error("impossible");
|
|
2432
2432
|
let e = this.zip;
|
|
2433
2433
|
e.on("data", (i) => super.write(i)), e.on("end", () => super.end()), e.on("drain", () => this[ls]()), this.on("resume", () => e.resume());
|
|
2434
2434
|
} else this.on("drain", this[ls]);
|
|
@@ -94,8 +94,13 @@ var DEFAULT_RETENTION = {
|
|
|
94
94
|
rawDays: 7,
|
|
95
95
|
fiveMinuteDays: 30,
|
|
96
96
|
hourDays: 365,
|
|
97
|
-
dayDays: null
|
|
97
|
+
dayDays: null,
|
|
98
|
+
transitionDays: 365
|
|
98
99
|
};
|
|
100
|
+
/** Rows of the transition ledger strictly older than this are deleted; the row AT it is kept. */
|
|
101
|
+
function transitionCutoff(policy, now) {
|
|
102
|
+
return now - policy.transitionDays * DAY_MS;
|
|
103
|
+
}
|
|
99
104
|
/** Cutoff per tier: rows strictly older are deleted. `null` = keep forever. */
|
|
100
105
|
function retentionCutoffs(policy, now) {
|
|
101
106
|
return {
|
|
@@ -130,13 +135,20 @@ var BUCKET_LEAD_MS = 2 * DAY_MS;
|
|
|
130
135
|
/** The short tiers hold nothing older than this unless the operator configured more. */
|
|
131
136
|
var SHORT_TIER_LOOKBACK_MS = 400 * DAY_MS;
|
|
132
137
|
var yieldToEventLoop = () => new Promise((resolve) => setImmediate(resolve));
|
|
138
|
+
/** The cutoff of the transition ledger moves a day before it is swept again. */
|
|
139
|
+
var TRANSITION_STEP_MS = DAY_MS;
|
|
133
140
|
var RetentionJob = class {
|
|
134
141
|
deps;
|
|
135
142
|
appliedUpTo = /* @__PURE__ */ new Map();
|
|
136
143
|
running = null;
|
|
144
|
+
transitions = null;
|
|
137
145
|
constructor(deps) {
|
|
138
146
|
this.deps = deps;
|
|
139
147
|
}
|
|
148
|
+
/** The ledger opens after the history runtime does; the pass sweeps it from then on. */
|
|
149
|
+
attachTransitions(sweeper) {
|
|
150
|
+
this.transitions = sweeper;
|
|
151
|
+
}
|
|
140
152
|
run(policy, now) {
|
|
141
153
|
if (this.running !== null) return this.running;
|
|
142
154
|
const run = this.doRun(policy, now).finally(() => {
|
|
@@ -164,12 +176,31 @@ var RetentionJob = class {
|
|
|
164
176
|
}
|
|
165
177
|
}
|
|
166
178
|
await this.purgeDeparted(now);
|
|
179
|
+
await this.sweepTransitions(policy, now);
|
|
167
180
|
counters.retentionLastRunAt = now;
|
|
168
181
|
} catch (err) {
|
|
169
182
|
logger.warn("device-history: retention pass failed — retried at the next run", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
170
183
|
}
|
|
171
184
|
}
|
|
172
|
-
/**
|
|
185
|
+
/** The fifth step: the transition ledger, under its own failure so the tiers never wait on it. */
|
|
186
|
+
async sweepTransitions(policy, now) {
|
|
187
|
+
const sweeper = this.transitions;
|
|
188
|
+
if (sweeper === null) return;
|
|
189
|
+
const cutoff = transitionCutoff(policy, now);
|
|
190
|
+
const applied = this.appliedUpTo.get("transitions");
|
|
191
|
+
if (applied !== void 0 && cutoff - applied < TRANSITION_STEP_MS) return;
|
|
192
|
+
try {
|
|
193
|
+
const deleted = await sweeper.sweep(cutoff);
|
|
194
|
+
this.appliedUpTo.set("transitions", cutoff);
|
|
195
|
+
if (deleted > 0) this.deps.logger.info("device-history: pruned device transitions past retention", { meta: {
|
|
196
|
+
deleted,
|
|
197
|
+
cutoff,
|
|
198
|
+
transitionDays: policy.transitionDays
|
|
199
|
+
} });
|
|
200
|
+
} catch (err) {
|
|
201
|
+
this.deps.logger.warn("device-history: transition retention failed — retried at the next run", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
202
|
+
}
|
|
203
|
+
}
|
|
173
204
|
/** Drop the visit markers of a purged series. */
|
|
174
205
|
forgetSeries(seriesId) {
|
|
175
206
|
for (const tier of TIERS) this.appliedUpTo.delete(`${tier}:${seriesId}`);
|
|
@@ -94,8 +94,13 @@ var DEFAULT_RETENTION = {
|
|
|
94
94
|
rawDays: 7,
|
|
95
95
|
fiveMinuteDays: 30,
|
|
96
96
|
hourDays: 365,
|
|
97
|
-
dayDays: null
|
|
97
|
+
dayDays: null,
|
|
98
|
+
transitionDays: 365
|
|
98
99
|
};
|
|
100
|
+
/** Rows of the transition ledger strictly older than this are deleted; the row AT it is kept. */
|
|
101
|
+
function transitionCutoff(policy, now) {
|
|
102
|
+
return now - policy.transitionDays * DAY_MS;
|
|
103
|
+
}
|
|
99
104
|
/** Cutoff per tier: rows strictly older are deleted. `null` = keep forever. */
|
|
100
105
|
function retentionCutoffs(policy, now) {
|
|
101
106
|
return {
|
|
@@ -130,13 +135,20 @@ var BUCKET_LEAD_MS = 2 * DAY_MS;
|
|
|
130
135
|
/** The short tiers hold nothing older than this unless the operator configured more. */
|
|
131
136
|
var SHORT_TIER_LOOKBACK_MS = 400 * DAY_MS;
|
|
132
137
|
var yieldToEventLoop = () => new Promise((resolve) => setImmediate(resolve));
|
|
138
|
+
/** The cutoff of the transition ledger moves a day before it is swept again. */
|
|
139
|
+
var TRANSITION_STEP_MS = DAY_MS;
|
|
133
140
|
var RetentionJob = class {
|
|
134
141
|
deps;
|
|
135
142
|
appliedUpTo = /* @__PURE__ */ new Map();
|
|
136
143
|
running = null;
|
|
144
|
+
transitions = null;
|
|
137
145
|
constructor(deps) {
|
|
138
146
|
this.deps = deps;
|
|
139
147
|
}
|
|
148
|
+
/** The ledger opens after the history runtime does; the pass sweeps it from then on. */
|
|
149
|
+
attachTransitions(sweeper) {
|
|
150
|
+
this.transitions = sweeper;
|
|
151
|
+
}
|
|
140
152
|
run(policy, now) {
|
|
141
153
|
if (this.running !== null) return this.running;
|
|
142
154
|
const run = this.doRun(policy, now).finally(() => {
|
|
@@ -164,12 +176,31 @@ var RetentionJob = class {
|
|
|
164
176
|
}
|
|
165
177
|
}
|
|
166
178
|
await this.purgeDeparted(now);
|
|
179
|
+
await this.sweepTransitions(policy, now);
|
|
167
180
|
counters.retentionLastRunAt = now;
|
|
168
181
|
} catch (err) {
|
|
169
182
|
logger.warn("device-history: retention pass failed — retried at the next run", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
170
183
|
}
|
|
171
184
|
}
|
|
172
|
-
/**
|
|
185
|
+
/** The fifth step: the transition ledger, under its own failure so the tiers never wait on it. */
|
|
186
|
+
async sweepTransitions(policy, now) {
|
|
187
|
+
const sweeper = this.transitions;
|
|
188
|
+
if (sweeper === null) return;
|
|
189
|
+
const cutoff = transitionCutoff(policy, now);
|
|
190
|
+
const applied = this.appliedUpTo.get("transitions");
|
|
191
|
+
if (applied !== void 0 && cutoff - applied < TRANSITION_STEP_MS) return;
|
|
192
|
+
try {
|
|
193
|
+
const deleted = await sweeper.sweep(cutoff);
|
|
194
|
+
this.appliedUpTo.set("transitions", cutoff);
|
|
195
|
+
if (deleted > 0) this.deps.logger.info("device-history: pruned device transitions past retention", { meta: {
|
|
196
|
+
deleted,
|
|
197
|
+
cutoff,
|
|
198
|
+
transitionDays: policy.transitionDays
|
|
199
|
+
} });
|
|
200
|
+
} catch (err) {
|
|
201
|
+
this.deps.logger.warn("device-history: transition retention failed — retried at the next run", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
202
|
+
}
|
|
203
|
+
}
|
|
173
204
|
/** Drop the visit markers of a purged series. */
|
|
174
205
|
forgetSeries(seriesId) {
|
|
175
206
|
for (const tier of TIERS) this.appliedUpTo.delete(`${tier}:${seriesId}`);
|
|
Binary file
|
|
Binary file
|
package/system/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/server",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.811",
|
|
4
4
|
"description": "CamStack builtins — shipped inside @camstack/server (generated, do not edit)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"camstack": {
|
|
@@ -238,6 +238,9 @@
|
|
|
238
238
|
},
|
|
239
239
|
{
|
|
240
240
|
"name": "device-runs"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"name": "device-transitions"
|
|
241
244
|
}
|
|
242
245
|
]
|
|
243
246
|
},
|
|
@@ -468,6 +471,9 @@
|
|
|
468
471
|
{
|
|
469
472
|
"name": "remote"
|
|
470
473
|
},
|
|
474
|
+
{
|
|
475
|
+
"name": "hero-layout"
|
|
476
|
+
},
|
|
471
477
|
{
|
|
472
478
|
"name": "remote-layout-components"
|
|
473
479
|
},
|