@camstack/server 1.2.927 → 1.2.929
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 +12 -0
- package/package.json +11 -14
- package/system/dist/addon-id-CVg1_r5E.mjs +39 -0
- package/system/dist/addon-id-Di0lNJ89.js +50 -0
- package/system/dist/addon-pages.cap-Df9FQwN1.js +49 -0
- package/system/dist/addon-pages.cap-DksUlE8j.mjs +44 -0
- package/system/dist/addon-settings.cap-3-TIIMq_.mjs +592 -0
- package/system/dist/addon-settings.cap-DAiE0Nb0.js +651 -0
- package/system/dist/addon-widgets.cap-C4jxflbF.js +200 -0
- package/system/dist/addon-widgets.cap-D9m48X78.mjs +183 -0
- package/system/dist/base-addon-DD5dIfcZ.js +4624 -0
- package/system/dist/base-addon-Md14i7pe.mjs +4505 -0
- package/system/dist/base-device-2sL1DMm1.js +1103 -0
- package/system/dist/base-device-IuM1AwXZ.mjs +1098 -0
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +8 -6
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +3 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +8 -6
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +3 -1
- package/system/dist/builtins/alerts/alerts.addon.js +113 -56
- package/system/dist/builtins/alerts/alerts.addon.mjs +58 -1
- package/system/dist/builtins/autotrack/index.js +21 -17
- package/system/dist/builtins/autotrack/index.mjs +5 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +14 -11
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +5 -2
- package/system/dist/builtins/calendars/calendars.addon.js +8 -6
- package/system/dist/builtins/calendars/calendars.addon.mjs +3 -1
- package/system/dist/builtins/camera-grid/index.js +615 -58
- package/system/dist/builtins/camera-grid/index.mjs +558 -1
- package/system/dist/builtins/composer/composer.addon.js +788 -209
- package/system/dist/builtins/composer/composer.addon.mjs +583 -4
- package/system/dist/builtins/console-logging/index.js +4 -3
- package/system/dist/builtins/console-logging/index.mjs +2 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +7887 -381
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +7511 -5
- package/system/dist/builtins/core-notifier/core-notifier.addon.js +731 -21
- package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +711 -1
- package/system/dist/builtins/device-history/device-history.addon.js +110 -31
- package/system/dist/builtins/device-history/device-history.addon.mjs +81 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +12806 -227
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +12583 -5
- package/system/dist/builtins/hub-forwarder/index.js +4 -3
- package/system/dist/builtins/hub-forwarder/index.mjs +2 -1
- package/system/dist/builtins/keychain/index.js +31 -28
- package/system/dist/builtins/keychain/index.mjs +7 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +15 -12
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +4 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +140 -39
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +103 -3
- package/system/dist/builtins/local-network/local-network.addon.js +43 -39
- package/system/dist/builtins/local-network/local-network.addon.mjs +7 -3
- package/system/dist/builtins/loki-logging/index.js +23 -17
- package/system/dist/builtins/loki-logging/index.mjs +7 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +156 -15
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +142 -1
- package/system/dist/builtins/platform-probe/index.js +25 -23
- package/system/dist/builtins/platform-probe/index.mjs +4 -2
- package/system/dist/builtins/record-entries/index.js +9 -7
- package/system/dist/builtins/record-entries/index.mjs +3 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +4 -4
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +97 -44
- package/system/dist/builtins/snapshot/index.mjs +54 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +5 -4
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +2 -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 +87 -61
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +29 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +81 -72
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +10 -1
- package/system/dist/builtins/system-config/system-config.addon.js +17 -14
- package/system/dist/builtins/system-config/system-config.addon.mjs +6 -3
- package/system/dist/builtins/winston-logging/index.js +7 -5
- package/system/dist/builtins/winston-logging/index.mjs +3 -1
- package/system/dist/calendars.cap-CaFlShS9.js +155 -0
- package/system/dist/calendars.cap-_C4eD4fi.mjs +138 -0
- package/system/dist/camstack-error-DJ-TUAi1.js +23 -0
- package/system/dist/camstack-error-viZYfcj9.mjs +18 -0
- package/system/dist/cap-call-context-Bd76CbOW.js +95 -0
- package/system/dist/cap-call-context-DNwdgGSQ.mjs +78 -0
- package/system/dist/capability-definition-C2rJdVeX.mjs +177 -0
- package/system/dist/capability-definition-HCmTem8c.js +242 -0
- package/system/dist/{capture-engine-BcuwOSXv.js → capture-engine-DZ0LIUqA.js} +5 -4
- package/system/dist/{capture-engine-Bz7eXFjT.mjs → capture-engine-DiwbjoWp.mjs} +2 -1
- package/system/dist/command-origin-claim-Cief660O.js +35 -0
- package/system/dist/command-origin-claim-D1Wy7Qld.mjs +24 -0
- package/system/dist/composition-sources-Caqv7O7z.mjs +391 -0
- package/system/dist/composition-sources-CgnHjm8Q.js +408 -0
- package/system/dist/{constants-D2etJ02O.js → constants-Ba3FTIHl.js} +1 -1
- package/system/dist/constants-C860Y6U4.js +26 -0
- package/system/dist/{constants-BcUTQd1M.mjs → constants-DB4piTD5.mjs} +1 -1
- package/system/dist/constants-DCLpoF4L.mjs +21 -0
- package/system/dist/coral-accelerators-7o8hqvcN.js +564 -0
- package/system/dist/coral-accelerators-BKcXP59c.mjs +521 -0
- package/system/dist/core-blocks.cap-C6iKAZ-x.mjs +17986 -0
- package/system/dist/core-blocks.cap-LEMqVwxO.js +18705 -0
- package/system/dist/custom-actions-BFUSalC9.mjs +25 -0
- package/system/dist/custom-actions-D92NRi2c.js +36 -0
- package/system/dist/database-snapshot.cap-DF38e-0P.js +162 -0
- package/system/dist/database-snapshot.cap-dhrc9xnY.mjs +133 -0
- package/system/dist/declared-device-BWphj9WE.js +303 -0
- package/system/dist/declared-device-CKERA1Hi.mjs +286 -0
- package/system/dist/{device-ca-ExMN3xW3.mjs → device-ca-BLM6fccc.mjs} +2 -1
- package/system/dist/{device-ca-CU8zh9Pi.js → device-ca-C5kJE6mL.js} +7 -6
- package/system/dist/device-certificate-Cddm4Idn.mjs +91 -0
- package/system/dist/device-certificate-CguVACQO.js +162 -0
- package/system/dist/device-identifiers-BQg9EQi1.js +600 -0
- package/system/dist/device-identifiers-iSuQCKmK.mjs +529 -0
- package/system/dist/device-kind-BJ2pfsjw.mjs +78 -0
- package/system/dist/device-kind-CsSiv_YF.js +101 -0
- package/system/dist/device-manager.cap-2abwVLCM.js +2874 -0
- package/system/dist/device-manager.cap-CFZSPfUh.mjs +2749 -0
- package/system/dist/device-provider.cap-3Uvk6f5-.mjs +331 -0
- package/system/dist/device-provider.cap-D7TV2kVH.js +366 -0
- package/system/dist/{device-row-store-CeW_GWh9.mjs → device-row-store-YF3jtmkk.mjs} +4 -1
- package/system/dist/{device-row-store-BMIR-n3m.js → device-row-store-doTfMOqn.js} +12 -9
- package/system/dist/device-transitions.cap-B5w5PYU_.js +860 -0
- package/system/dist/device-transitions.cap-DojcwEuX.mjs +819 -0
- package/system/dist/device-type-CbQsnFdC.js +477 -0
- package/system/dist/device-type-DgEvK3ch.mjs +454 -0
- package/system/dist/entry-kind-D9MuVJCK.mjs +44 -0
- package/system/dist/entry-kind-cq90c--V.js +55 -0
- package/system/dist/error.cap-CSM_SRfR.mjs +3423 -0
- package/system/dist/error.cap-DBhgPeWK.js +3848 -0
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/history-catalog-BKRarIL_.js +831 -0
- package/system/dist/history-catalog-BwTeQ4Mr.mjs +802 -0
- package/system/dist/{hub-identity-Csxx2Q8k.js → hub-identity-BMdR3Mw9.js} +2 -2
- package/system/dist/{hub-identity-BBXzP6Ve.mjs → hub-identity-DjMN9Ac2.mjs} +1 -1
- package/system/dist/{hub-mdns-ciao-By5577HM.js → hub-mdns-ciao--0v1TKME.js} +5 -5
- package/system/dist/{hub-mdns-ciao-DG17NbGU.mjs → hub-mdns-ciao-DBrtHOcc.mjs} +2 -2
- package/system/dist/index.js +763 -151
- package/system/dist/index.mjs +624 -12
- package/system/dist/integration-instances.cap-Cl9O-k4h.mjs +538 -0
- package/system/dist/integration-instances.cap-dJIxg2_s.js +549 -0
- package/system/dist/keychain-admin.cap-Db_oFX4H.js +425 -0
- package/system/dist/keychain-admin.cap-GtM7gVGG.mjs +396 -0
- package/system/dist/l10n-Bu6aUvSY.mjs +10 -0
- package/system/dist/l10n-CGMvp7NF.js +15 -0
- package/system/dist/labels-DX5S8deC.js +81 -0
- package/system/dist/labels-DsBcU7md.mjs +64 -0
- package/system/dist/{legacy-integration-rows-door-CVwOo5aq.js → legacy-integration-rows-door-B1nzxxr5.js} +2 -2
- package/system/dist/{legacy-integration-rows-door-D9tQOUzh.mjs → legacy-integration-rows-door-nTvo_6jQ.mjs} +1 -1
- package/system/dist/log-destination.cap-CxZzAVaR.mjs +143 -0
- package/system/dist/log-destination.cap-DELPJkZ0.js +148 -0
- package/system/dist/low-power-sleep.cap-7lfVU41N.js +103 -0
- package/system/dist/low-power-sleep.cap-tGPmaZ_V.mjs +92 -0
- package/system/dist/mask-shape-Ci8Co9w0.mjs +57 -0
- package/system/dist/mask-shape-CmPA2fst.js +92 -0
- package/system/dist/metrics-provider.cap-BNmcHDkQ.mjs +405 -0
- package/system/dist/metrics-provider.cap-BcmQUt6l.js +410 -0
- package/system/dist/migration-BMjgkyG2.js +380 -0
- package/system/dist/migration-DRJAtdy7.mjs +321 -0
- package/system/dist/network-access.cap-B5TWLDCC.js +1099 -0
- package/system/dist/network-access.cap-BJnGbE6n.mjs +1004 -0
- package/system/dist/notification-rules.cap-B__YBgnG.js +3422 -0
- package/system/dist/notification-rules.cap-D9ArZlwx.mjs +3357 -0
- package/system/dist/ops-log-CB4pIdqi.mjs +64 -0
- package/system/dist/ops-log-pxt9176Z.js +81 -0
- package/system/dist/pinned-binary-BOhOSNff.js +28 -0
- package/system/dist/pinned-binary-CrIRAi4G.mjs +23 -0
- package/system/dist/platform-probe.cap-1WrMhWHx.js +250 -0
- package/system/dist/platform-probe.cap-BFeqFLtQ.mjs +233 -0
- package/system/dist/prefix-walk-B4b2-9aK.mjs +790 -0
- package/system/dist/prefix-walk-DC0ljmbB.js +843 -0
- package/system/dist/ptz-autotrack.cap-BW7w0zHD.js +229 -0
- package/system/dist/ptz-autotrack.cap-DT2GypXw.mjs +224 -0
- package/system/dist/quantity-D3g5SxsZ.mjs +114 -0
- package/system/dist/quantity-lY1KiTSZ.js +143 -0
- package/system/dist/raw-secret-migration-DxuBFtvi.js +50 -0
- package/system/dist/raw-secret-migration-iv88mLoc.mjs +39 -0
- package/system/dist/record-entries.cap-sMUhTvTU.mjs +75 -0
- package/system/dist/record-entries.cap-ti1C046R.js +80 -0
- package/system/dist/record-kind-DoBfYHCs.js +203 -0
- package/system/dist/record-kind-ub6NXqfh.mjs +162 -0
- package/system/dist/recording-archive.cap-7OrIn9e5.mjs +1299 -0
- package/system/dist/recording-archive.cap-D7bo-QSM.js +1328 -0
- package/system/dist/records.cap-ClcWV64i.js +329 -0
- package/system/dist/records.cap-CwLT2ByG.mjs +294 -0
- package/system/dist/relocate-CdVQAk-w.js +804 -0
- package/system/dist/relocate-CoZZTui1.mjs +661 -0
- package/system/dist/rename-composition-block-7WIICIDq.mjs +33525 -0
- package/system/dist/rename-composition-block-CcWLwVhG.js +34692 -0
- package/system/dist/{restore-archive-kwtBd00M.mjs → restore-archive-CjAyKpgX.mjs} +3 -1
- package/system/dist/{restore-archive-CIFvqOze.js → restore-archive-CkTkv3Ss.js} +6 -4
- package/system/dist/scoped-settings-CylSSq_8.js +955 -0
- package/system/dist/scoped-settings-DVWUIP7Z.mjs +650 -0
- package/system/dist/server-name-BIhLuHvX.mjs +35 -0
- package/system/dist/server-name-OALNvpqC.js +52 -0
- package/system/dist/settings-store.cap-Ci4F2zul.mjs +569 -0
- package/system/dist/settings-store.cap-wlJhCspr.js +640 -0
- package/system/dist/snapshot.cap-3suPdBHV.js +250 -0
- package/system/dist/snapshot.cap-Bs8Oyaqh.mjs +245 -0
- package/system/dist/source-info-DGB7SdB_.mjs +190 -0
- package/system/dist/source-info-DtWf4k2j.js +225 -0
- package/system/dist/storage-admin.cap-BSv1NjKJ.mjs +883 -0
- package/system/dist/storage-admin.cap-he0OqvVM.js +906 -0
- package/system/dist/storage-location-CBT8GCD6.mjs +163 -0
- package/system/dist/storage-location-CTweDMZf.js +198 -0
- package/system/dist/storage-location-mode-B21UVRRX.mjs +167 -0
- package/system/dist/storage-location-mode-CS4sMzo-.js +232 -0
- package/system/dist/storage-migration.cap-CyyATY_p.js +330 -0
- package/system/dist/storage-migration.cap-D7QqGobp.mjs +313 -0
- package/system/dist/storage-occupancy.cap-2rmnS58Z.js +622 -0
- package/system/dist/storage-occupancy.cap-CqBztTl9.mjs +611 -0
- package/system/dist/storage-provider.cap-Bw0CfxVc.js +213 -0
- package/system/dist/storage-provider.cap-CMeck2w4.mjs +202 -0
- package/system/dist/stream-catalog.cap-Bp7SkgIf.mjs +6560 -0
- package/system/dist/stream-catalog.cap-D3uwePiA.js +6763 -0
- package/system/dist/streaming-shared-B8cXatuU.mjs +431 -0
- package/system/dist/streaming-shared-DQwFZOSi.js +526 -0
- package/system/dist/system-reasons-Be_k1W8g.js +25 -0
- package/system/dist/system-reasons-CYj4qwyS.mjs +20 -0
- package/system/dist/tag-BxLazvVb.js +2138 -0
- package/system/dist/tag-uZBAq6ox.mjs +2073 -0
- package/system/dist/user-management.cap-B9QDu8NE.js +825 -0
- package/system/dist/user-management.cap-DBIi77sB.mjs +766 -0
- package/system/dist/vector-store.cap-DnyfrYDn.js +330 -0
- package/system/dist/vector-store.cap-h2GHWQ1t.mjs +319 -0
- package/system/dist/{wal-maintenance-CTrCPzds.mjs → wal-maintenance-BG01rOn9.mjs} +0 -0
- package/system/dist/{wal-maintenance-dq7T3quB.js → wal-maintenance-DyrebYKF.js} +0 -0
- package/system/dist/zod-secret-DS7mj1bk.js +78 -0
- package/system/dist/zod-secret-zY4nM61M.mjs +73 -0
- package/system/package.json +1 -1
- package/system/dist/composition-sources-BI614LJx.mjs +0 -141
- package/system/dist/composition-sources-v_kkb8A9.js +0 -152
- package/system/dist/coral-accelerators-BSVsBVzt.js +0 -250
- package/system/dist/coral-accelerators-DBlgWB8k.mjs +0 -231
- package/system/dist/dist-BCHMSqzc.mjs +0 -143467
- package/system/dist/dist-BZfvhfS1.js +0 -146970
- package/system/dist/prefix-walk-DAOBSyH1.mjs +0 -88
- package/system/dist/prefix-walk-Dv6MLZlM.js +0 -99
- package/system/dist/rename-composition-block-C9HuBrKS.js +0 -112
- package/system/dist/rename-composition-block-DtaYmYAR.mjs +0 -101
|
@@ -0,0 +1,650 @@
|
|
|
1
|
+
//#region ../types/dist/esm/utils/err-msg.mjs
|
|
2
|
+
/**
|
|
3
|
+
import { errMsg } from '@camstack/types'
|
|
4
|
+
* Extract a human-readable message from an unknown error value.
|
|
5
|
+
* Replaces the ubiquitous `errMsg(err)` pattern.
|
|
6
|
+
*/
|
|
7
|
+
function errMsg(err) {
|
|
8
|
+
if (err instanceof Error) return err.message;
|
|
9
|
+
if (typeof err === "string") return err;
|
|
10
|
+
return String(err);
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region ../types/dist/esm/interfaces/config-ui-secrets.mjs
|
|
14
|
+
/**
|
|
15
|
+
* The value a redacted secret is replaced with on every read surface.
|
|
16
|
+
*
|
|
17
|
+
* It is also the WRITE-BACK token: a save that sends this value
|
|
18
|
+
* back for a key means "keep what is stored", which is what lets an operator
|
|
19
|
+
* rename a location without retyping its password. A literal an operator could
|
|
20
|
+
* plausibly choose as a real password would turn that convenience into a way
|
|
21
|
+
* to lock yourself out, hence the sentinel shape.
|
|
22
|
+
*/
|
|
23
|
+
var REDACTED_SECRET = "__camstack_redacted__";
|
|
24
|
+
/** Is this field's stored value a credential? */
|
|
25
|
+
function isSecretConfigField(field) {
|
|
26
|
+
if (field.type === "password") return true;
|
|
27
|
+
return "secret" in field && field.secret === true;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
|
|
31
|
+
* by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
|
|
32
|
+
*/
|
|
33
|
+
function isKeychainStoredField(field) {
|
|
34
|
+
if (!isSecretConfigField(field)) return false;
|
|
35
|
+
if (field.type === "textarea" && field.isJson === true) return false;
|
|
36
|
+
return !("storage" in field && field.storage === "inline");
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Every config key in `schema` whose value is a secret, including keys nested
|
|
40
|
+
* inside `group` / `sub-tabs` containers.
|
|
41
|
+
*/
|
|
42
|
+
function collectSecretConfigKeys(schema) {
|
|
43
|
+
const keys = /* @__PURE__ */ new Set();
|
|
44
|
+
for (const section of sectionsOf(schema)) for (const field of fieldsOf(section)) walkField(field, keys);
|
|
45
|
+
return keys;
|
|
46
|
+
}
|
|
47
|
+
function isRecord$2(value) {
|
|
48
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
49
|
+
}
|
|
50
|
+
function sectionsOf(schema) {
|
|
51
|
+
if (!isRecord$2(schema)) return [];
|
|
52
|
+
const sections = schema["sections"];
|
|
53
|
+
return Array.isArray(sections) ? sections : [];
|
|
54
|
+
}
|
|
55
|
+
function fieldsOf(node) {
|
|
56
|
+
if (!isRecord$2(node)) return [];
|
|
57
|
+
const fields = node["fields"];
|
|
58
|
+
return Array.isArray(fields) ? fields : [];
|
|
59
|
+
}
|
|
60
|
+
function walkField(field, out) {
|
|
61
|
+
if (!isRecord$2(field)) return;
|
|
62
|
+
const type = field["type"];
|
|
63
|
+
const key = field["key"];
|
|
64
|
+
if ((type === "password" || field["secret"] === true) && typeof key === "string" && key.length > 0) out.add(key);
|
|
65
|
+
if (type === "group") {
|
|
66
|
+
for (const child of fieldsOf(field)) walkField(child, out);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (type === "sub-tabs") {
|
|
70
|
+
const tabs = field["tabs"];
|
|
71
|
+
if (!Array.isArray(tabs)) return;
|
|
72
|
+
for (const tab of tabs) for (const child of fieldsOf(tab)) walkField(child, out);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region ../types/dist/esm/keychain/secret-marker.mjs
|
|
77
|
+
/**
|
|
78
|
+
* What a settings blob holds where a secret used to be.
|
|
79
|
+
*
|
|
80
|
+
* A keychain-stored field never holds its value. It holds a self-describing
|
|
81
|
+
* MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
|
|
82
|
+
* code can mistake it for a credential and no form can send it to a camera as
|
|
83
|
+
* a password. The empty state is `null` / absent, never `''`.
|
|
84
|
+
*
|
|
85
|
+
* The same shapes travel to and from the admin UI:
|
|
86
|
+
*
|
|
87
|
+
* - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
|
|
88
|
+
* (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
|
|
89
|
+
* value is set, never the value.
|
|
90
|
+
* - write: an untouched field submits the view back unchanged (KEEP); a typed
|
|
91
|
+
* value is a plain non-empty string (CHANGE); the Clear button submits
|
|
92
|
+
* {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
|
|
93
|
+
* are KEEP — an empty string is what a defaults-fallback pushes back, and
|
|
94
|
+
* treating it as "clear" is how a save destroyed a stored credential before.
|
|
95
|
+
*
|
|
96
|
+
* Pure and browser-safe.
|
|
97
|
+
*/
|
|
98
|
+
var SECRET_CLEAR = { $secretClear: true };
|
|
99
|
+
/** The `'***'` token D634 redaction writes for non-admins. */
|
|
100
|
+
var LEGACY_DEVICE_REDACTION = "***";
|
|
101
|
+
function isRecord$1(value) {
|
|
102
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
103
|
+
}
|
|
104
|
+
function makeSecretMarker(ref) {
|
|
105
|
+
return {
|
|
106
|
+
$secret: ref,
|
|
107
|
+
v: 1
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/** A stored marker: an object whose `$secret` is a non-empty string. */
|
|
111
|
+
function isSecretMarker(value) {
|
|
112
|
+
if (!isRecord$1(value)) return false;
|
|
113
|
+
const ref = value["$secret"];
|
|
114
|
+
return typeof ref === "string" && ref.length > 0;
|
|
115
|
+
}
|
|
116
|
+
/** Anything carrying a `$secret` key — a stored marker or a UI view of one. */
|
|
117
|
+
function isSecretMarkerLike(value) {
|
|
118
|
+
return isRecord$1(value) && Object.prototype.hasOwnProperty.call(value, "$secret");
|
|
119
|
+
}
|
|
120
|
+
function isSecretClear(value) {
|
|
121
|
+
return isRecord$1(value) && value["$secretClear"] === true;
|
|
122
|
+
}
|
|
123
|
+
function isSecretFieldView(value) {
|
|
124
|
+
return isRecord$1(value) && value["set"] === true && isSecretMarkerLike(value);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The UI view of a stored secret field value: a marker becomes "set", inline
|
|
128
|
+
* plaintext becomes "set (inline)", nothing becomes `null`. A value never
|
|
129
|
+
* survives this function.
|
|
130
|
+
*/
|
|
131
|
+
function toSecretFieldView(stored) {
|
|
132
|
+
if (isSecretMarker(stored)) return {
|
|
133
|
+
$secret: stored.$secret,
|
|
134
|
+
v: 1,
|
|
135
|
+
set: true
|
|
136
|
+
};
|
|
137
|
+
if (typeof stored === "string" && stored.length > 0) return {
|
|
138
|
+
$secret: null,
|
|
139
|
+
v: 1,
|
|
140
|
+
set: true,
|
|
141
|
+
inline: true
|
|
142
|
+
};
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Classify an incoming value for a secret path. Only a non-empty string that is
|
|
147
|
+
* not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
|
|
148
|
+
* Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
|
|
149
|
+
* `undefined`, a redaction token, a non-string — keeps what is stored.
|
|
150
|
+
*/
|
|
151
|
+
function classifySecretWrite(incoming) {
|
|
152
|
+
if (isSecretClear(incoming)) return { kind: "clear" };
|
|
153
|
+
if (typeof incoming !== "string") return { kind: "keep" };
|
|
154
|
+
if (incoming.length === 0) return { kind: "keep" };
|
|
155
|
+
if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
|
|
156
|
+
return {
|
|
157
|
+
kind: "set",
|
|
158
|
+
value: incoming
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region ../types/dist/esm/records/errors.mjs
|
|
163
|
+
var PREFIX = "records/";
|
|
164
|
+
/**
|
|
165
|
+
* Cross-realm brand. An addon bundles its own copy of this module (D15) while
|
|
166
|
+
* `ctx.records` is the HOST's door, so an error thrown by the host is an
|
|
167
|
+
* instance of the host's classes, not of the addon's. The brand plus the code
|
|
168
|
+
* make `instanceof` answer by identity of the failure, not of the copy.
|
|
169
|
+
*/
|
|
170
|
+
var RECORDS_ERROR_BRAND = /* @__PURE__ */ Symbol.for("camstack.records-error");
|
|
171
|
+
function carriesBrand(value) {
|
|
172
|
+
return typeof value === "object" && value !== null && Reflect.get(value, RECORDS_ERROR_BRAND) === true;
|
|
173
|
+
}
|
|
174
|
+
/** The base of every records failure. `detail` is the human part of the message. */
|
|
175
|
+
var RecordsError = class extends Error {
|
|
176
|
+
/** The code a subclass stands for; the base stands for every code. */
|
|
177
|
+
static code = void 0;
|
|
178
|
+
/**
|
|
179
|
+
* `instanceof` across copies of this module: any branded error is a
|
|
180
|
+
* `RecordsError`, and is an instance of a subclass only when its code is the
|
|
181
|
+
* subclass's code. Same-copy answers are unchanged.
|
|
182
|
+
*/
|
|
183
|
+
static [Symbol.hasInstance](value) {
|
|
184
|
+
if (Function.prototype[Symbol.hasInstance].call(this, value)) return true;
|
|
185
|
+
if (!carriesBrand(value)) return false;
|
|
186
|
+
return this.code === void 0 || value.code === this.code;
|
|
187
|
+
}
|
|
188
|
+
code;
|
|
189
|
+
detail;
|
|
190
|
+
[RECORDS_ERROR_BRAND] = true;
|
|
191
|
+
constructor(code, detail) {
|
|
192
|
+
super(`${PREFIX}${code}: ${detail}`);
|
|
193
|
+
this.name = "RecordsError";
|
|
194
|
+
this.code = code;
|
|
195
|
+
this.detail = detail;
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
199
|
+
var RevConflictError = class RevConflictError extends RecordsError {
|
|
200
|
+
static code = "rev-conflict";
|
|
201
|
+
constructor(detail) {
|
|
202
|
+
super(RevConflictError.code, detail);
|
|
203
|
+
this.name = "RevConflictError";
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
/** `data` exceeds the kind's `maxDataBytes`. Bytes are never record fields (D613). */
|
|
207
|
+
var RecordTooLargeError = class RecordTooLargeError extends RecordsError {
|
|
208
|
+
static code = "too-large";
|
|
209
|
+
constructor(detail) {
|
|
210
|
+
super(RecordTooLargeError.code, detail);
|
|
211
|
+
this.name = "RecordTooLargeError";
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
/** A filter, order or aggregate names a field no declared index serves. */
|
|
215
|
+
var UnindexedFilterError = class UnindexedFilterError extends RecordsError {
|
|
216
|
+
static code = "unindexed-filter";
|
|
217
|
+
constructor(detail) {
|
|
218
|
+
super(UnindexedFilterError.code, detail);
|
|
219
|
+
this.name = "UnindexedFilterError";
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
/** A bulk delete with no predicate at all. */
|
|
223
|
+
var FilterRequiredError = class FilterRequiredError extends RecordsError {
|
|
224
|
+
static code = "filter-required";
|
|
225
|
+
constructor(detail) {
|
|
226
|
+
super(FilterRequiredError.code, detail);
|
|
227
|
+
this.name = "FilterRequiredError";
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
/** The caller declared no such kind (another addon's kind is indistinguishable from none). */
|
|
231
|
+
var UnknownRecordKindError = class UnknownRecordKindError extends RecordsError {
|
|
232
|
+
static code = "unknown-kind";
|
|
233
|
+
constructor(detail) {
|
|
234
|
+
super(UnknownRecordKindError.code, detail);
|
|
235
|
+
this.name = "UnknownRecordKindError";
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
var RecordNotFoundError = class RecordNotFoundError extends RecordsError {
|
|
239
|
+
static code = "not-found";
|
|
240
|
+
constructor(detail) {
|
|
241
|
+
super(RecordNotFoundError.code, detail);
|
|
242
|
+
this.name = "RecordNotFoundError";
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
/** A unique index refused the write. */
|
|
246
|
+
var RecordUniqueViolationError = class RecordUniqueViolationError extends RecordsError {
|
|
247
|
+
static code = "unique-violation";
|
|
248
|
+
constructor(detail) {
|
|
249
|
+
super(RecordUniqueViolationError.code, detail);
|
|
250
|
+
this.name = "RecordUniqueViolationError";
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
/** A secret field held a plain string where only a keychain marker may be stored. */
|
|
254
|
+
var PlaintextSecretError = class PlaintextSecretError extends RecordsError {
|
|
255
|
+
static code = "plaintext-secret";
|
|
256
|
+
constructor(detail) {
|
|
257
|
+
super(PlaintextSecretError.code, detail);
|
|
258
|
+
this.name = "PlaintextSecretError";
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
/** A marker whose ref is not the row's own (the D878 rule). */
|
|
262
|
+
var ForeignSecretMarkerError = class ForeignSecretMarkerError extends RecordsError {
|
|
263
|
+
static code = "foreign-marker";
|
|
264
|
+
constructor(detail) {
|
|
265
|
+
super(ForeignSecretMarkerError.code, detail);
|
|
266
|
+
this.name = "ForeignSecretMarkerError";
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
270
|
+
var RecordSecretUnavailableError = class RecordSecretUnavailableError extends RecordsError {
|
|
271
|
+
static code = "secret-unavailable";
|
|
272
|
+
constructor(detail) {
|
|
273
|
+
super(RecordSecretUnavailableError.code, detail);
|
|
274
|
+
this.name = "RecordSecretUnavailableError";
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
var InvalidRecordError = class InvalidRecordError extends RecordsError {
|
|
278
|
+
static code = "invalid-record";
|
|
279
|
+
constructor(detail) {
|
|
280
|
+
super(InvalidRecordError.code, detail);
|
|
281
|
+
this.name = "InvalidRecordError";
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
285
|
+
var DeclarationRefusedError = class DeclarationRefusedError extends RecordsError {
|
|
286
|
+
static code = "declaration-refused";
|
|
287
|
+
constructor(detail) {
|
|
288
|
+
super(DeclarationRefusedError.code, detail);
|
|
289
|
+
this.name = "DeclarationRefusedError";
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
var NoCallerError = class NoCallerError extends RecordsError {
|
|
293
|
+
static code = "no-caller";
|
|
294
|
+
constructor(detail) {
|
|
295
|
+
super(NoCallerError.code, detail);
|
|
296
|
+
this.name = "NoCallerError";
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
var BatchTooLargeError = class BatchTooLargeError extends RecordsError {
|
|
300
|
+
static code = "batch-too-large";
|
|
301
|
+
constructor(detail) {
|
|
302
|
+
super(BatchTooLargeError.code, detail);
|
|
303
|
+
this.name = "BatchTooLargeError";
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* A `transact` the engine refuses before touching a row: an op on a kind the
|
|
308
|
+
* caller did not declare in ONE file and ONE `transactFamily`. The detail names
|
|
309
|
+
* which rule (`cross-file`, `cross-family`, `no-family`); it is never a silent split.
|
|
310
|
+
*/
|
|
311
|
+
var TransactRefusedError = class TransactRefusedError extends RecordsError {
|
|
312
|
+
static code = "transact-refused";
|
|
313
|
+
constructor(detail) {
|
|
314
|
+
super(TransactRefusedError.code, detail);
|
|
315
|
+
this.name = "TransactRefusedError";
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
//#endregion
|
|
319
|
+
//#region ../types/dist/esm/keychain/secret-ref.mjs
|
|
320
|
+
/**
|
|
321
|
+
* The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
|
|
322
|
+
*
|
|
323
|
+
* A ref is DETERMINISTIC from where the value lives — the owner addon, the
|
|
324
|
+
* scope (global, one node, one device, one integration, one row of a business
|
|
325
|
+
* collection) and the field path inside that scope — so saving the same field
|
|
326
|
+
* twice updates the same ref, and the ref itself says which settings blob
|
|
327
|
+
* points at it. It is also the AAD of the value's ciphertext: a ciphertext
|
|
328
|
+
* copied onto another ref does not decrypt.
|
|
329
|
+
*
|
|
330
|
+
* Array items are addressed by ITEM ID, never by index
|
|
331
|
+
* (`providers[authentik].clientSecret`), so reordering a list keeps every ref.
|
|
332
|
+
*
|
|
333
|
+
* Pure and browser-safe: no node builtins, no I/O.
|
|
334
|
+
*/
|
|
335
|
+
/** The URI scheme of every keychain ref. */
|
|
336
|
+
var SECRET_REF_SCHEME = "secret://";
|
|
337
|
+
var GLOBAL_SCOPE = { kind: "global" };
|
|
338
|
+
/** The scope every addon-wide (not per-node, not per-device) setting lives in. */
|
|
339
|
+
function globalSecretScope() {
|
|
340
|
+
return GLOBAL_SCOPE;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* An addon id as a ref owner. A hub in-process builtin's context id is
|
|
344
|
+
* `addon:<id>`; the owner of its secrets is `<id>`, exactly as for the same
|
|
345
|
+
* addon running forked.
|
|
346
|
+
*/
|
|
347
|
+
function normalizeSecretOwner(addonId) {
|
|
348
|
+
return addonId.startsWith("addon:") ? addonId.slice(6) : addonId;
|
|
349
|
+
}
|
|
350
|
+
function encodeSegment(value) {
|
|
351
|
+
return encodeURIComponent(value);
|
|
352
|
+
}
|
|
353
|
+
function decodeSegment(value) {
|
|
354
|
+
try {
|
|
355
|
+
return decodeURIComponent(value);
|
|
356
|
+
} catch {
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
/** The scope as it appears inside a ref (`global`, `node/<id>`, …). */
|
|
361
|
+
function formatSecretScope(scope) {
|
|
362
|
+
switch (scope.kind) {
|
|
363
|
+
case "global": return "global";
|
|
364
|
+
case "node": return `node/${encodeSegment(scope.nodeId)}`;
|
|
365
|
+
case "device": return `device/${scope.deviceId}`;
|
|
366
|
+
case "integration": return `integration/${encodeSegment(scope.integrationId)}`;
|
|
367
|
+
case "row": return `row/${encodeSegment(scope.collection)}/${encodeSegment(scope.rowId)}`;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* The field path of a value inside an array item, addressed by the item's id:
|
|
372
|
+
* `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
|
|
373
|
+
* `providers[authentik].clientSecret`.
|
|
374
|
+
*/
|
|
375
|
+
function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
|
|
376
|
+
return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
|
|
377
|
+
}
|
|
378
|
+
/** Build a ref. Throws on an empty owner or field path — both are bugs. */
|
|
379
|
+
function buildSecretRef(parts) {
|
|
380
|
+
const owner = normalizeSecretOwner(parts.owner);
|
|
381
|
+
if (owner.length === 0) throw new Error("buildSecretRef: owner is empty");
|
|
382
|
+
if (parts.fieldPath.length === 0) throw new Error("buildSecretRef: fieldPath is empty");
|
|
383
|
+
return `${SECRET_REF_SCHEME}${encodeSegment(owner)}/${formatSecretScope(parts.scope)}/${parts.fieldPath}`;
|
|
384
|
+
}
|
|
385
|
+
function parseScope(segments) {
|
|
386
|
+
switch (segments[0]) {
|
|
387
|
+
case "global": return {
|
|
388
|
+
scope: GLOBAL_SCOPE,
|
|
389
|
+
used: 1
|
|
390
|
+
};
|
|
391
|
+
case "node": {
|
|
392
|
+
const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
|
|
393
|
+
return nodeId === null || nodeId.length === 0 ? null : {
|
|
394
|
+
scope: {
|
|
395
|
+
kind: "node",
|
|
396
|
+
nodeId
|
|
397
|
+
},
|
|
398
|
+
used: 2
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
case "device": {
|
|
402
|
+
const raw = segments[1];
|
|
403
|
+
if (raw === void 0 || !/^\d+$/.test(raw)) return null;
|
|
404
|
+
return {
|
|
405
|
+
scope: {
|
|
406
|
+
kind: "device",
|
|
407
|
+
deviceId: Number(raw)
|
|
408
|
+
},
|
|
409
|
+
used: 2
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
case "integration": {
|
|
413
|
+
const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
|
|
414
|
+
return id === null || id.length === 0 ? null : {
|
|
415
|
+
scope: {
|
|
416
|
+
kind: "integration",
|
|
417
|
+
integrationId: id
|
|
418
|
+
},
|
|
419
|
+
used: 2
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
case "row": {
|
|
423
|
+
const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
|
|
424
|
+
const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
|
|
425
|
+
if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
|
|
426
|
+
return {
|
|
427
|
+
scope: {
|
|
428
|
+
kind: "row",
|
|
429
|
+
collection,
|
|
430
|
+
rowId
|
|
431
|
+
},
|
|
432
|
+
used: 3
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
default: return null;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
/** Take a ref apart; `null` when it is not a well-formed ref. */
|
|
439
|
+
function parseSecretRef(ref) {
|
|
440
|
+
if (!ref.startsWith("secret://")) return null;
|
|
441
|
+
const segments = ref.slice(9).split("/");
|
|
442
|
+
const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
|
|
443
|
+
if (owner === null || owner.length === 0) return null;
|
|
444
|
+
const parsed = parseScope(segments.slice(1));
|
|
445
|
+
if (parsed === null) return null;
|
|
446
|
+
const fieldPath = segments.slice(1 + parsed.used).join("/");
|
|
447
|
+
if (fieldPath.length === 0) return null;
|
|
448
|
+
return {
|
|
449
|
+
owner,
|
|
450
|
+
scope: parsed.scope,
|
|
451
|
+
fieldPath
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
//#endregion
|
|
455
|
+
//#region ../types/dist/esm/records/constants.mjs
|
|
456
|
+
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
457
|
+
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
458
|
+
var RECORD_DATABASES = ["settings", "events"];
|
|
459
|
+
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
460
|
+
var RECORD_CLASSES = [
|
|
461
|
+
"config",
|
|
462
|
+
"ledger",
|
|
463
|
+
"audit",
|
|
464
|
+
"mirror",
|
|
465
|
+
"ephemeral"
|
|
466
|
+
];
|
|
467
|
+
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
468
|
+
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
469
|
+
var RECORD_BATCH_MAX = 1e3;
|
|
470
|
+
var RECORD_BATCH_MAX_BYTES = 4 * 1024 * 1024;
|
|
471
|
+
var RECORD_QUERY_MAX = 1e3;
|
|
472
|
+
/** Rows one DELETE statement removes before the serving thread yields. */
|
|
473
|
+
var RECORD_DELETE_BATCH = 5e3;
|
|
474
|
+
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
475
|
+
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
476
|
+
/** The engine's TTL sweep cadence. */
|
|
477
|
+
var RECORD_SWEEP_INTERVAL_MS = 10 * 6e4;
|
|
478
|
+
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
479
|
+
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
480
|
+
//#endregion
|
|
481
|
+
//#region ../types/dist/esm/records/secret-paths.mjs
|
|
482
|
+
/**
|
|
483
|
+
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
484
|
+
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
485
|
+
* (`auth.accessToken`, `headers[].value`).
|
|
486
|
+
*
|
|
487
|
+
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
488
|
+
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
489
|
+
* key releases exactly that key's secret.
|
|
490
|
+
*
|
|
491
|
+
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
492
|
+
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
493
|
+
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
494
|
+
* leaf names its element: `headers[X-Api].value`.
|
|
495
|
+
*
|
|
496
|
+
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
497
|
+
*/
|
|
498
|
+
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
499
|
+
function parseSecretPath(path) {
|
|
500
|
+
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
501
|
+
return path.split(".").map((raw) => {
|
|
502
|
+
const each = raw.endsWith("[]");
|
|
503
|
+
const map = raw.endsWith("{}");
|
|
504
|
+
const key = each || map ? raw.slice(0, -2) : raw;
|
|
505
|
+
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
506
|
+
return {
|
|
507
|
+
key,
|
|
508
|
+
each,
|
|
509
|
+
map
|
|
510
|
+
};
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
514
|
+
function secretArrayPrefixes(path) {
|
|
515
|
+
const segments = parseSecretPath(path);
|
|
516
|
+
const prefixes = [];
|
|
517
|
+
const walked = [];
|
|
518
|
+
for (const segment of segments) {
|
|
519
|
+
walked.push(segment.key);
|
|
520
|
+
if (segment.each) prefixes.push(walked.join("."));
|
|
521
|
+
}
|
|
522
|
+
return prefixes;
|
|
523
|
+
}
|
|
524
|
+
function isRecord(value) {
|
|
525
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
526
|
+
}
|
|
527
|
+
function elementId(element, idKey, declared, prefix) {
|
|
528
|
+
const id = isRecord(element) ? element[idKey] : void 0;
|
|
529
|
+
if (typeof id !== "string" || id.length === 0) throw new InvalidRecordError(`"${declared}": every element of "${prefix}" needs a non-empty string "${idKey}" to carry a secret`);
|
|
530
|
+
return id;
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
534
|
+
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
535
|
+
* result is a new body, `data` is untouched.
|
|
536
|
+
*/
|
|
537
|
+
var REMOVE_LEAF = /* @__PURE__ */ Symbol("remove-leaf");
|
|
538
|
+
function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
|
|
539
|
+
if (!isRecord(node)) return node;
|
|
540
|
+
const segment = segments[index];
|
|
541
|
+
if (segment === void 0) return node;
|
|
542
|
+
if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
|
|
543
|
+
const child = node[segment.key];
|
|
544
|
+
const keys = [...walkedKeys, segment.key];
|
|
545
|
+
const last = index === segments.length - 1;
|
|
546
|
+
if (segment.each) {
|
|
547
|
+
if (!Array.isArray(child)) return node;
|
|
548
|
+
const prefix = keys.join(".");
|
|
549
|
+
const idKey = arrayKeys[prefix];
|
|
550
|
+
if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
|
|
551
|
+
const mapped = child.map((element) => {
|
|
552
|
+
const id = elementId(element, idKey, declared, prefix);
|
|
553
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
|
|
554
|
+
return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
|
|
555
|
+
});
|
|
556
|
+
return {
|
|
557
|
+
...node,
|
|
558
|
+
[segment.key]: mapped
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
if (segment.map) {
|
|
562
|
+
if (!isRecord(child)) return node;
|
|
563
|
+
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
564
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
565
|
+
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
566
|
+
return [mapKey, visit({
|
|
567
|
+
declared,
|
|
568
|
+
concrete,
|
|
569
|
+
value
|
|
570
|
+
})];
|
|
571
|
+
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
572
|
+
return {
|
|
573
|
+
...node,
|
|
574
|
+
[segment.key]: Object.fromEntries(kept)
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
578
|
+
if (last) {
|
|
579
|
+
const replacement = visit({
|
|
580
|
+
declared,
|
|
581
|
+
concrete,
|
|
582
|
+
value: child
|
|
583
|
+
});
|
|
584
|
+
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
585
|
+
return {
|
|
586
|
+
...node,
|
|
587
|
+
[segment.key]: replacement
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
return {
|
|
591
|
+
...node,
|
|
592
|
+
[segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
596
|
+
function mapSecretLeaves(data, paths, arrayKeys, visit) {
|
|
597
|
+
let current = data;
|
|
598
|
+
for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
|
|
599
|
+
return current;
|
|
600
|
+
}
|
|
601
|
+
/** Every present secret leaf, read-only. */
|
|
602
|
+
function collectSecretLeaves(data, paths, arrayKeys) {
|
|
603
|
+
const found = [];
|
|
604
|
+
mapSecretLeaves(data, paths, arrayKeys, (leaf) => {
|
|
605
|
+
found.push(leaf);
|
|
606
|
+
return leaf.value;
|
|
607
|
+
});
|
|
608
|
+
return found;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* The keychain collection name a kind's secrets live under. Prefixed so a
|
|
612
|
+
* record's refs never collide with the refs a legacy collection of the same name
|
|
613
|
+
* already holds during an adoption.
|
|
614
|
+
*/
|
|
615
|
+
function recordSecretCollection(kind) {
|
|
616
|
+
return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
|
|
617
|
+
}
|
|
618
|
+
/** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
|
|
619
|
+
function recordSecretRef(owner, kind, rowId, concretePath) {
|
|
620
|
+
return buildSecretRef({
|
|
621
|
+
owner,
|
|
622
|
+
scope: {
|
|
623
|
+
kind: "row",
|
|
624
|
+
collection: recordSecretCollection(kind),
|
|
625
|
+
rowId
|
|
626
|
+
},
|
|
627
|
+
fieldPath: concretePath
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
//#endregion
|
|
631
|
+
//#region ../types/dist/esm/addon/scoped-settings.mjs
|
|
632
|
+
/** Every scope, in the order the guard and the docs list them. */
|
|
633
|
+
var SCOPED_SETTINGS_SCOPES = [
|
|
634
|
+
"cluster",
|
|
635
|
+
"device-defaults",
|
|
636
|
+
"node"
|
|
637
|
+
];
|
|
638
|
+
/**
|
|
639
|
+
* The node id a node-scoped KEY carries: the part after the `@`. `null` for a key with no `@`
|
|
640
|
+
* (a cluster or fleet-default key) or an empty node id. A schema key never contains `@`
|
|
641
|
+
* (guard `check-scoped-settings-declared`), so the first `@` is the separator.
|
|
642
|
+
*/
|
|
643
|
+
function nodeIdOfScopedKey(key) {
|
|
644
|
+
const at = key.indexOf("@");
|
|
645
|
+
if (at <= 0) return null;
|
|
646
|
+
const nodeId = key.slice(at + 1);
|
|
647
|
+
return nodeId === "" ? null : nodeId;
|
|
648
|
+
}
|
|
649
|
+
//#endregion
|
|
650
|
+
export { NoCallerError as A, SECRET_CLEAR as B, normalizeSecretOwner as C, FilterRequiredError as D, DeclarationRefusedError as E, RecordUniqueViolationError as F, isSecretMarkerLike as G, isSecretClear as H, RevConflictError as I, REDACTED_SECRET as J, makeSecretMarker as K, TransactRefusedError as L, RecordNotFoundError as M, RecordSecretUnavailableError as N, ForeignSecretMarkerError as O, RecordTooLargeError as P, UnindexedFilterError as R, globalSecretScope as S, BatchTooLargeError as T, isSecretFieldView as U, classifySecretWrite as V, isSecretMarker as W, isKeychainStoredField as X, collectSecretConfigKeys as Y, errMsg as Z, RECORD_SETTINGS_MAX_ROWS as _, mapSecretLeaves as a, buildSecretRef as b, RECORD_BATCH_MAX as c, RECORD_DATABASES as d, RECORD_DEFAULT_MAX_DATA_BYTES as f, RECORD_SECRET_COLLECTION_PREFIX as g, RECORD_QUERY_MAX as h, collectSecretLeaves as i, PlaintextSecretError as j, InvalidRecordError as k, RECORD_BATCH_MAX_BYTES as l, RECORD_MAX_DATA_BYTES as m, nodeIdOfScopedKey as n, recordSecretRef as o, RECORD_DELETE_BATCH as p, toSecretFieldView as q, REMOVE_LEAF as r, secretArrayPrefixes as s, SCOPED_SETTINGS_SCOPES as t, RECORD_CLASSES as u, RECORD_SWEEP_INTERVAL_MS as v, parseSecretRef as w, formatSecretScope as x, arrayItemFieldPath as y, UnknownRecordKindError as z };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region ../types/dist/esm/system/server-name.mjs
|
|
3
|
+
/** C0 controls, DEL and the C1 range: none of them belongs in a name. */
|
|
4
|
+
function hasControlCharacter(value) {
|
|
5
|
+
for (const char of value) {
|
|
6
|
+
const code = char.codePointAt(0) ?? 0;
|
|
7
|
+
if (code <= 31 || code >= 127 && code <= 159) return true;
|
|
8
|
+
}
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
/** A name an operator may save: trimmed, 1-48 characters, no control characters. */
|
|
12
|
+
var ServerNameSchema = /* @__PURE__ */ z.string().transform((value) => value.trim()).pipe(/* @__PURE__ */ z.string().min(1, "The server name cannot be empty").max(48, `The server name is at most 48 characters`).refine((value) => !hasControlCharacter(value), { message: "The server name cannot contain control characters" }));
|
|
13
|
+
/** What every reader gets: the name to show, and whether the hub chose it itself. */
|
|
14
|
+
var ServerNameInfoSchema = /* @__PURE__ */ z.object({
|
|
15
|
+
name: /* @__PURE__ */ z.string(),
|
|
16
|
+
/** `true` when nobody named the hub: `name` is the machine hostname. */
|
|
17
|
+
isDefault: /* @__PURE__ */ z.boolean()
|
|
18
|
+
});
|
|
19
|
+
/** What an unset name shows when the hostname says nothing about the hub. */
|
|
20
|
+
var SERVER_NAME_FALLBACK = "CamStack";
|
|
21
|
+
/** A container id: Docker's default hostname (12 hex chars, or the full 64). */
|
|
22
|
+
var CONTAINER_ID_PATTERN = /^(?:[0-9a-f]{12}|[0-9a-f]{64})$/;
|
|
23
|
+
/**
|
|
24
|
+
* The hostname without its domain (`nas.lan.example` becomes `nas`). A hostname
|
|
25
|
+
* that names nothing (empty, `localhost`, a container id) yields
|
|
26
|
+
* {@link SERVER_NAME_FALLBACK}.
|
|
27
|
+
*/
|
|
28
|
+
function shortHostname(hostname) {
|
|
29
|
+
const first = hostname.trim().split(".")[0] ?? "";
|
|
30
|
+
if (first.length === 0 || first.toLowerCase() === "localhost") return SERVER_NAME_FALLBACK;
|
|
31
|
+
if (CONTAINER_ID_PATTERN.test(first)) return SERVER_NAME_FALLBACK;
|
|
32
|
+
return first;
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { ServerNameSchema as n, shortHostname as r, ServerNameInfoSchema as t };
|