@camstack/server 1.2.790 → 1.2.791
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 +7 -0
- package/dist/api/trpc/device-config-secret-redaction.js +14 -1
- package/dist/api/trpc/generated-cap-routers.js +24 -0
- package/dist/api/trpc/localized-schema-paths.js +1 -0
- package/dist/core/addon/addon-settings-provider.js +57 -0
- package/package.json +16 -23
- package/system/dist/addon-runner.js +22 -0
- package/system/dist/addon-runner.mjs +22 -0
- package/system/dist/{agent-https-ByceQLwr.mjs → agent-https-BmVaVskH.mjs} +1 -1
- package/system/dist/{agent-https-BmXXKQAA.js → agent-https-DOs15BCJ.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 +1 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/system/dist/builtins/autotrack/autotrack.addon.d.ts +7 -7
- package/system/dist/builtins/autotrack/index.js +15 -8
- package/system/dist/builtins/autotrack/index.mjs +15 -8
- 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/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 +3 -3
- package/system/dist/builtins/composer/composer.addon.mjs +3 -3
- 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.js +3 -3
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
- package/system/dist/builtins/device-history/device-history.addon.js +2 -2
- package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
- 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 +1 -1
- package/system/dist/builtins/loki-logging/index.mjs +1 -1
- 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.d.ts +4 -10
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +16 -9
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +16 -9
- 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/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 +3 -3
- 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-BHj1fNYC.js → capture-engine-BVpkq9Mv.js} +1 -1
- package/system/dist/{capture-engine-D9n4KDaN.mjs → capture-engine-D-oUDtX5.mjs} +1 -1
- package/system/dist/{composition-sources-wI4qWTz2.mjs → composition-sources-Br7JhpbD.mjs} +1 -1
- package/system/dist/{composition-sources-BGgIuuvd.js → composition-sources-DKCbVA67.js} +1 -1
- package/system/dist/{constants-DHqkxbYk.mjs → constants-Bl0Qxbek.mjs} +1 -1
- package/system/dist/{constants-DNdriMRD.js → constants-CJVY-mUq.js} +1 -1
- package/system/dist/{device-ca-gr5eE3h5.mjs → device-ca-BeDGy8NK.mjs} +1 -1
- package/system/dist/{device-ca-C2RzT1VT.js → device-ca-i8EbKp3q.js} +1 -1
- package/system/dist/{dist-BUoL5bbr.mjs → dist-CPUbgRkb.mjs} +280 -8
- package/system/dist/{dist-DV0V3JiE.js → dist-Ddkk4Dqq.js} +280 -8
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-mdns-ciao-DoSb8dwB.mjs → hub-mdns-ciao-DgF4SifE.mjs} +2 -2
- package/system/dist/{hub-mdns-ciao-Be5PGXW6.js → hub-mdns-ciao-lHRHbXqV.js} +2 -2
- package/system/dist/index.js +8 -8
- package/system/dist/index.mjs +8 -8
- package/system/dist/kernel/transport/child-cap-protocol.d.ts +1 -1
- package/system/dist/{legacy-integration-rows-door-DRC0xn6k.mjs → legacy-integration-rows-door-9JSt493H.mjs} +1 -1
- package/system/dist/{legacy-integration-rows-door-D5s8oM7e.js → legacy-integration-rows-door-n9GIUxgq.js} +1 -1
- package/system/dist/{restore-archive-Dh4gfCRY.js → restore-archive-BDvLSZtj.js} +1 -1
- package/system/dist/{restore-archive-DH3P9j-V.mjs → restore-archive-Dh3XnCR1.mjs} +1 -1
- package/system/dist/{wal-maintenance-BWfH3Lov.mjs → wal-maintenance-BQJAmAwS.mjs} +0 -0
- package/system/dist/{wal-maintenance-DgN_WD5T.js → wal-maintenance-CWlz_qRq.js} +0 -0
- package/system/package.json +1 -1
|
@@ -3,11 +3,11 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-Ddkk4Dqq.js");
|
|
7
7
|
const require_safe_buffer$1 = require("../../safe-buffer-D3aoa-7X.js");
|
|
8
8
|
const require_x509_es = require("../../x509.es-WtnRNyYS.js");
|
|
9
|
-
const require_agent_https = require("../../agent-https-
|
|
10
|
-
const require_constants$8 = require("../../constants-
|
|
9
|
+
const require_agent_https = require("../../agent-https-DOs15BCJ.js");
|
|
10
|
+
const require_constants$8 = require("../../constants-CJVY-mUq.js");
|
|
11
11
|
const require_src$1 = require("../../src-CnAqG6EF.js");
|
|
12
12
|
let zod = require("zod");
|
|
13
13
|
let node_crypto = require("node:crypto");
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { a as __toCommonJS, i as __require, n as __esmMin, o as __toESM, r as __exportAll, t as __commonJSMin } from "../../chunk-CNf5ZN-e.mjs";
|
|
2
|
-
import { $t as ServerNameSchema, Bo as BaseAddon, Ms as customAction, Oa as shortHostname, Oc as errMsg, Ps as defineCustomActions, Ws as hydrateSchema } from "../../dist-
|
|
2
|
+
import { $t as ServerNameSchema, Bo as BaseAddon, Ms as customAction, Oa as shortHostname, Oc as errMsg, Ps as defineCustomActions, Ws as hydrateSchema } from "../../dist-CPUbgRkb.mjs";
|
|
3
3
|
import { t as require_safe_buffer } from "../../safe-buffer-B1OjL1I9.mjs";
|
|
4
4
|
import { C as backdatedNotBefore, S as withUtcTimeEncoding, a as KeyUsageFlags, c as Pkcs10CertificateRequest, d as SubjectKeyIdentifierExtension, f as X509Certificate$1, l as Pkcs10CertificateRequestGenerator, m as cryptoProvider, n as BasicConstraintsExtension, o as KeyUsagesExtension, p as X509CertificateGenerator, r as ExtendedKeyUsageExtension, s as PemConverter, t as AuthorityKeyIdentifierExtension } from "../../x509.es-BRiJgOvu.mjs";
|
|
5
|
-
import { B as setProcessAgentHttpsNames, I as AGENT_HTTPS_NAMES_COLLECTION, L as AGENT_HTTPS_NAMES_COLUMNS, M as isLocalOnlyHostname, R as AgentHttpsNames, V as systemConfigRecordKinds, u as isPrivateAddress, z as getProcessAgentHttpsNames } from "../../agent-https-
|
|
6
|
-
import { a as MESH_CA_KEY_REF, c as SERVER_AUTH_OID, i as MESH_CA_FIELD, n as DEFAULT_HUB_TLS_TCP_PORT, o as MESH_CA_SETTINGS_KEY, r as MESH_CA_COMMON_NAME, s as MESH_CA_VALIDITY_DAYS, t as CLIENT_AUTH_OID } from "../../constants-
|
|
5
|
+
import { B as setProcessAgentHttpsNames, I as AGENT_HTTPS_NAMES_COLLECTION, L as AGENT_HTTPS_NAMES_COLUMNS, M as isLocalOnlyHostname, R as AgentHttpsNames, V as systemConfigRecordKinds, u as isPrivateAddress, z as getProcessAgentHttpsNames } from "../../agent-https-BmVaVskH.mjs";
|
|
6
|
+
import { a as MESH_CA_KEY_REF, c as SERVER_AUTH_OID, i as MESH_CA_FIELD, n as DEFAULT_HUB_TLS_TCP_PORT, o as MESH_CA_SETTINGS_KEY, r as MESH_CA_COMMON_NAME, s as MESH_CA_VALIDITY_DAYS, t as CLIENT_AUTH_OID } from "../../constants-Bl0Qxbek.mjs";
|
|
7
7
|
import { t as require_src } from "../../src-hG4grMU4.mjs";
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
import { X509Certificate, createHash, createPrivateKey, randomBytes, randomInt, sign, timingSafeEqual, verify, webcrypto } from "node:crypto";
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-Ddkk4Dqq.js");
|
|
7
7
|
const require_formatter = require("../../formatter-xbxeV4GD.js");
|
|
8
8
|
const require_log_file_read_protocol = require("../../log-file-read-protocol-DSV_vQRb.js");
|
|
9
9
|
let node_path = require("node:path");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Bo as BaseAddon, Ns as defineAddonMigrations, pi as logDestinationCapability, qi as preconditionOf } from "../../dist-
|
|
1
|
+
import { Bo as BaseAddon, Ns as defineAddonMigrations, pi as logDestinationCapability, qi as preconditionOf } from "../../dist-CPUbgRkb.mjs";
|
|
2
2
|
import { t as formatLogLine } from "../../formatter-DkYZ4LXp.mjs";
|
|
3
3
|
import { a as LogFileIndexStore, i as serveRead, n as isFromReader, t as CancelBook } from "../../log-file-read-protocol-hTaAsYlX.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_dist = require("./dist-
|
|
1
|
+
const require_dist = require("./dist-Ddkk4Dqq.js");
|
|
2
2
|
//#region src/builtins/device-history/store/series-registry.ts
|
|
3
3
|
function subjectIdOf(subject) {
|
|
4
4
|
return subject.kind === "device" ? `d:${subject.deviceId}` : `n:${subject.nodeId}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Dc as DeviceType, Hs as historyItemFieldPath, Yo as HISTORY_DEFAULT_MIN_INTERVAL_MS } from "./dist-
|
|
1
|
+
import { Dc as DeviceType, Hs as historyItemFieldPath, Yo as HISTORY_DEFAULT_MIN_INTERVAL_MS } from "./dist-CPUbgRkb.mjs";
|
|
2
2
|
//#region src/builtins/device-history/store/series-registry.ts
|
|
3
3
|
function subjectIdOf(subject) {
|
|
4
4
|
return subject.kind === "device" ? `d:${subject.deviceId}` : `n:${subject.nodeId}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Oc as errMsg, So as compositionSourceKey } from "./dist-
|
|
1
|
+
import { Oc as errMsg, So as compositionSourceKey } from "./dist-CPUbgRkb.mjs";
|
|
2
2
|
//#region src/builtins/shared/device-state-changed.ts
|
|
3
3
|
/** Structural narrowing helper for untrusted bus payloads. */
|
|
4
4
|
function isRecord(value) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** `secret://system/global/meshCaKey` — EC P-256 PKCS#8 PEM of the hub mesh CA. */
|
|
2
|
-
var MESH_CA_KEY_REF = require("./dist-
|
|
2
|
+
var MESH_CA_KEY_REF = require("./dist-Ddkk4Dqq.js").buildSecretRef({
|
|
3
3
|
owner: "system",
|
|
4
4
|
scope: { kind: "global" },
|
|
5
5
|
fieldPath: "meshCaKey"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Es as buildSecretRef, G as DEVICE_SAN_USER_PREFIX, W as DEVICE_SAN_CREDENTIAL_PREFIX } from "./dist-
|
|
1
|
+
import { Es as buildSecretRef, G as DEVICE_SAN_USER_PREFIX, W as DEVICE_SAN_CREDENTIAL_PREFIX } from "./dist-CPUbgRkb.mjs";
|
|
2
2
|
import { C as backdatedNotBefore, S as withUtcTimeEncoding, a as KeyUsageFlags, d as SubjectKeyIdentifierExtension, f as X509Certificate$1, m as cryptoProvider, n as BasicConstraintsExtension, o as KeyUsagesExtension, p as X509CertificateGenerator, r as ExtendedKeyUsageExtension, s as PemConverter, t as AuthorityKeyIdentifierExtension, u as SubjectAlternativeNameExtension } from "./x509.es-BRiJgOvu.mjs";
|
|
3
3
|
import { X509Certificate, createPublicKey, randomBytes, verify, webcrypto } from "node:crypto";
|
|
4
4
|
//#region src/auth/jwt-signing-key.ts
|
|
@@ -1188,7 +1188,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
|
1188
1188
|
return DeviceRole;
|
|
1189
1189
|
}({});
|
|
1190
1190
|
//#endregion
|
|
1191
|
-
//#region ../types/dist/sleep-
|
|
1191
|
+
//#region ../types/dist/sleep-CQP-REJp.mjs
|
|
1192
1192
|
/**
|
|
1193
1193
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
1194
1194
|
* window to float samples (D455).
|
|
@@ -1600,6 +1600,59 @@ var WELL_KNOWN_TAB_MAP = Object.fromEntries([
|
|
|
1600
1600
|
function isValuelessField(field) {
|
|
1601
1601
|
return field.type === "separator" || field.type === "info" || field.type === "qr-code" || field.type === "button" || field.type === "object-array" || field.type === "widget" || field.type === "addon-action-button" || field.type === "device-action-button" || field.type === "account-sign-in" || field.type === "secret-presence";
|
|
1602
1602
|
}
|
|
1603
|
+
/**
|
|
1604
|
+
* Base collector: flatten a hydrated `ConfigUISchemaWithValues` into
|
|
1605
|
+
* `key → { value, default }`, recursing through `group` and `sub-tabs`
|
|
1606
|
+
* layout fields. Keeping `value` and `default` SEPARATE (rather than
|
|
1607
|
+
* pre-resolving) lets callers both read the effective value AND detect
|
|
1608
|
+
* overrides (`value` differs from `default`). Structural over `unknown`;
|
|
1609
|
+
* malformed input yields an empty map, never throws.
|
|
1610
|
+
*/
|
|
1611
|
+
function collectHydratedFieldEntries(schema) {
|
|
1612
|
+
const out = /* @__PURE__ */ new Map();
|
|
1613
|
+
if (typeof schema !== "object" || schema === null) return out;
|
|
1614
|
+
const sections = schema.sections;
|
|
1615
|
+
if (!Array.isArray(sections)) return out;
|
|
1616
|
+
for (const section of sections) if (typeof section === "object" && section !== null) collectFieldEntriesInto(section.fields, out);
|
|
1617
|
+
return out;
|
|
1618
|
+
}
|
|
1619
|
+
/** Recursive field walker for {@link collectHydratedFieldEntries}. */
|
|
1620
|
+
function collectFieldEntriesInto(fields, into) {
|
|
1621
|
+
if (!Array.isArray(fields)) return;
|
|
1622
|
+
for (const field of fields) {
|
|
1623
|
+
if (typeof field !== "object" || field === null) continue;
|
|
1624
|
+
const type = field.type;
|
|
1625
|
+
if (type === "group") {
|
|
1626
|
+
collectFieldEntriesInto(field.fields, into);
|
|
1627
|
+
continue;
|
|
1628
|
+
}
|
|
1629
|
+
if (type === "sub-tabs") {
|
|
1630
|
+
const tabs = field.tabs;
|
|
1631
|
+
if (Array.isArray(tabs)) {
|
|
1632
|
+
for (const tab of tabs) if (typeof tab === "object" && tab !== null) collectFieldEntriesInto(tab.fields, into);
|
|
1633
|
+
}
|
|
1634
|
+
continue;
|
|
1635
|
+
}
|
|
1636
|
+
const key = field.key;
|
|
1637
|
+
if (typeof key !== "string" || key.length === 0) continue;
|
|
1638
|
+
if (!("value" in field)) continue;
|
|
1639
|
+
into.set(key, {
|
|
1640
|
+
value: field.value,
|
|
1641
|
+
default: field.default
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
/**
|
|
1646
|
+
* Flatten a hydrated settings payload into `key → EFFECTIVE value`
|
|
1647
|
+
* (`value ?? default`). The read-side inverse of `hydrateSchema` for the
|
|
1648
|
+
* common "just give me the resolved values" case. Built on
|
|
1649
|
+
* {@link collectHydratedFieldEntries}.
|
|
1650
|
+
*/
|
|
1651
|
+
function collectHydratedFieldValues(schema) {
|
|
1652
|
+
const out = /* @__PURE__ */ new Map();
|
|
1653
|
+
for (const [key, entry] of collectHydratedFieldEntries(schema)) out.set(key, entry.value ?? entry.default);
|
|
1654
|
+
return out;
|
|
1655
|
+
}
|
|
1603
1656
|
function hydrateSchema(schema, values, options = {}) {
|
|
1604
1657
|
return {
|
|
1605
1658
|
...schema.tabs ? { tabs: [...schema.tabs] } : {},
|
|
@@ -2953,6 +3006,21 @@ function nodeIdOfScopedKey(key) {
|
|
|
2953
3006
|
const nodeId = key.slice(at + 1);
|
|
2954
3007
|
return nodeId === "" ? null : nodeId;
|
|
2955
3008
|
}
|
|
3009
|
+
/** The one refusal of a key a scope did not declare. */
|
|
3010
|
+
function assertDeclaredKeys(keys, declared) {
|
|
3011
|
+
const undeclared = keys.filter((key) => !declared.has(key));
|
|
3012
|
+
if (undeclared.length > 0) throw new Error(`scoped settings: [${undeclared.join(", ")}] not declared for this scope (declared: [${[...declared].join(", ")}])`);
|
|
3013
|
+
}
|
|
3014
|
+
/** Build the handle over an addon's scoped read, write and unset. */
|
|
3015
|
+
function createScopedSettings(deps) {
|
|
3016
|
+
return {
|
|
3017
|
+
async get() {
|
|
3018
|
+
return deps.schema.parse(await deps.read());
|
|
3019
|
+
},
|
|
3020
|
+
patch: (patch) => deps.write(Object.fromEntries(Object.entries(patch))),
|
|
3021
|
+
unset: (keys) => deps.unset(keys)
|
|
3022
|
+
};
|
|
3023
|
+
}
|
|
2956
3024
|
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
2957
3025
|
var KeychainWriteRefusedError = class extends Error {
|
|
2958
3026
|
fieldPath;
|
|
@@ -3528,7 +3596,16 @@ function createHandle(raw, opts) {
|
|
|
3528
3596
|
return blob;
|
|
3529
3597
|
}
|
|
3530
3598
|
},
|
|
3531
|
-
writeAddonStore: writeAddon
|
|
3599
|
+
writeAddonStore: writeAddon,
|
|
3600
|
+
removeClearedKeys: (keys) => serialize("addon", async () => {
|
|
3601
|
+
const stored = await readStoredAddonBlob(raw);
|
|
3602
|
+
index.seen("addon", stored);
|
|
3603
|
+
const removable = keys.filter((key) => collectSecretMarkerRefs(stored[key]).length === 0);
|
|
3604
|
+
if (removable.length === 0) return;
|
|
3605
|
+
const patch = Object.fromEntries(removable.map((key) => [key, void 0]));
|
|
3606
|
+
await raw.writeAddonStore(patch);
|
|
3607
|
+
index.wrote("addon", patch);
|
|
3608
|
+
})
|
|
3532
3609
|
};
|
|
3533
3610
|
}
|
|
3534
3611
|
/** The context the addon sees, plus the private raw view and write outcome. */
|
|
@@ -4086,6 +4163,151 @@ var BaseAddon = class {
|
|
|
4086
4163
|
}
|
|
4087
4164
|
}
|
|
4088
4165
|
/**
|
|
4166
|
+
* Hook: values layered over the stored ones when the FORM of one scope is served
|
|
4167
|
+
* ({@link getScopedSettings}) — a preview that derives dependent options without writing.
|
|
4168
|
+
* Never applied to {@link ScopedSettings.get} or to a write. `null` ⇒ no overlay.
|
|
4169
|
+
*/
|
|
4170
|
+
async scopedSettingsOverlay(_scope, _cap, _nodeId) {
|
|
4171
|
+
return null;
|
|
4172
|
+
}
|
|
4173
|
+
/**
|
|
4174
|
+
* Hook: a write of one scope changed stored values (not called when the store reports no change,
|
|
4175
|
+
* e.g. the write-back of a stored secret). `keys` are the bare field keys of the write, node keys included.
|
|
4176
|
+
*/
|
|
4177
|
+
async onScopedSettingsChanged(_scope, _cap, _keys) {}
|
|
4178
|
+
/** Typed handle over the CLUSTER settings `cap` declares (`clusterSettingsSchema`). */
|
|
4179
|
+
clusterSettings(cap, schema) {
|
|
4180
|
+
return this.scopedHandle("cluster", cap, schema);
|
|
4181
|
+
}
|
|
4182
|
+
/** Typed handle over the fleet defaults of the per-device settings `cap` declares. */
|
|
4183
|
+
deviceDefaults(cap, schema) {
|
|
4184
|
+
return this.scopedHandle("device-defaults", cap, schema);
|
|
4185
|
+
}
|
|
4186
|
+
/**
|
|
4187
|
+
* Typed handle over the settings `cap` owns PER NODE. `nodeId` omitted ⇒ the local node. A node
|
|
4188
|
+
* with no row yields the schema defaults — never a bare-key fallback.
|
|
4189
|
+
*/
|
|
4190
|
+
nodeSettings(cap, schema, nodeId) {
|
|
4191
|
+
return this.scopedHandle("node", cap, schema, nodeId);
|
|
4192
|
+
}
|
|
4193
|
+
/**
|
|
4194
|
+
* {@link state} for a value that is kept per node: stored under `<key>@<nodeId>`, and the
|
|
4195
|
+
* settings store carries `nodeId` in the row data (D986 §1), so a forgotten node's rows go in one
|
|
4196
|
+
* central delete. `nodeId` omitted ⇒ the local node.
|
|
4197
|
+
*/
|
|
4198
|
+
nodeState(key, schema, fallback, nodeId) {
|
|
4199
|
+
this._declaredStateKeys.add(key);
|
|
4200
|
+
return createDurableState({
|
|
4201
|
+
key: nodeScopedKey(key, nodeId ?? this._ctx?.kernel?.localNodeId ?? ""),
|
|
4202
|
+
schema,
|
|
4203
|
+
fallback,
|
|
4204
|
+
read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
|
|
4205
|
+
write: async (patch) => {
|
|
4206
|
+
await this._ctx?.settings?.writeAddonStore(patch);
|
|
4207
|
+
},
|
|
4208
|
+
onParseError: (k, e) => this._ctx?.logger?.warn?.(`durable-state: stored "${k}" failed validation — using fallback`, { meta: {
|
|
4209
|
+
addonId: this._ctx?.id,
|
|
4210
|
+
key: k,
|
|
4211
|
+
error: String(e)
|
|
4212
|
+
} })
|
|
4213
|
+
});
|
|
4214
|
+
}
|
|
4215
|
+
/** The loaded schema `cap` declares for `scope`, or `null`. */
|
|
4216
|
+
async declaredScopedSchema(scope, cap) {
|
|
4217
|
+
await this.loadScopedSchemas(cap);
|
|
4218
|
+
return this.loadedScopedSchemas(cap).find((entry) => entry.scope === scope)?.schema ?? null;
|
|
4219
|
+
}
|
|
4220
|
+
async requireScopedSchema(scope, cap) {
|
|
4221
|
+
const schema = await this.declaredScopedSchema(scope, cap);
|
|
4222
|
+
if (schema === null) throw new Error(`${this.constructor.name}: cap "${cap}" declares no ${scope} settings`);
|
|
4223
|
+
return schema;
|
|
4224
|
+
}
|
|
4225
|
+
scopedKeys(schema) {
|
|
4226
|
+
return new Set(schema.sections.flatMap((section) => collectValueFieldKeys(section.fields)));
|
|
4227
|
+
}
|
|
4228
|
+
/** `store` narrowed to the keys `schema` declares. */
|
|
4229
|
+
narrowToScope(store, schema) {
|
|
4230
|
+
const keys = this.scopedKeys(schema);
|
|
4231
|
+
return Object.fromEntries(Object.entries(store).filter(([key]) => keys.has(key)));
|
|
4232
|
+
}
|
|
4233
|
+
scopedHandle(scope, cap, schema, nodeId) {
|
|
4234
|
+
return createScopedSettings({
|
|
4235
|
+
schema,
|
|
4236
|
+
read: async () => {
|
|
4237
|
+
const declared = await this.requireScopedSchema(scope, cap);
|
|
4238
|
+
const stored = this.narrowToScope(await this.resolveGlobalStore(nodeId, cap), declared);
|
|
4239
|
+
const effective = collectHydratedFieldValues(hydrateSchema(declared, stored));
|
|
4240
|
+
return {
|
|
4241
|
+
...Object.fromEntries([...effective].filter(([, value]) => value !== void 0)),
|
|
4242
|
+
...stored
|
|
4243
|
+
};
|
|
4244
|
+
},
|
|
4245
|
+
write: (patch) => this.writeScoped(scope, cap, patch, nodeId),
|
|
4246
|
+
unset: (keys) => this.unsetScoped(scope, cap, keys, nodeId)
|
|
4247
|
+
});
|
|
4248
|
+
}
|
|
4249
|
+
/** The one write path of the scoped API: declared keys only, then the global patch. */
|
|
4250
|
+
async writeScoped(scope, cap, patch, nodeId) {
|
|
4251
|
+
assertDeclaredKeys(Object.keys(patch), this.scopedKeys(await this.requireScopedSchema(scope, cap)));
|
|
4252
|
+
if (await this.applyGlobalPatch(patch, scope === "node" ? nodeId : void 0, cap)) await this.onScopedSettingsChanged(scope, cap, Object.keys(patch));
|
|
4253
|
+
}
|
|
4254
|
+
/**
|
|
4255
|
+
* Remove declared keys of one scope. A secret goes through {@link clearSecrets} — its keychain
|
|
4256
|
+
* value is released exactly as there — and the emptied row is then removed; every other key is
|
|
4257
|
+
* removed by an `undefined` patch (which a secret transform would read as "keep").
|
|
4258
|
+
*/
|
|
4259
|
+
async unsetScoped(scope, cap, keys, nodeId) {
|
|
4260
|
+
assertDeclaredKeys(keys, this.scopedKeys(await this.requireScopedSchema(scope, cap)));
|
|
4261
|
+
const target = scope === "node" ? nodeId : void 0;
|
|
4262
|
+
const tree = this.addonSecretTree();
|
|
4263
|
+
const secretKeys = keys.filter((key) => tree.has(key));
|
|
4264
|
+
const plainKeys = keys.filter((key) => !tree.has(key));
|
|
4265
|
+
let changed = false;
|
|
4266
|
+
if (plainKeys.length > 0) {
|
|
4267
|
+
const patch = Object.fromEntries(plainKeys.map((key) => [key, void 0]));
|
|
4268
|
+
changed = await this.applyGlobalPatch(patch, target, cap) || changed;
|
|
4269
|
+
}
|
|
4270
|
+
if (secretKeys.length > 0) {
|
|
4271
|
+
await this.clearSecretKeys(secretKeys, target, cap);
|
|
4272
|
+
const node = normalizeNodeId(target ?? this._ctx?.kernel?.localNodeId);
|
|
4273
|
+
const rows = secretKeys.map((key) => scope === "node" ? nodeScopedKey(key, node) : key);
|
|
4274
|
+
if (this._secretSettings !== null) await this._secretSettings.removeClearedKeys(rows);
|
|
4275
|
+
else await this._ctx?.settings?.writeAddonStore(Object.fromEntries(rows.map((row) => [row, void 0])));
|
|
4276
|
+
changed = true;
|
|
4277
|
+
}
|
|
4278
|
+
if (changed) await this.onScopedSettingsChanged(scope, cap, [...keys]);
|
|
4279
|
+
}
|
|
4280
|
+
/**
|
|
4281
|
+
* The hydrated form of one scope of one capability's settings (any
|
|
4282
|
+
* {@link scopedSettingsOverlay} applied), or `null` when the capability declares nothing there.
|
|
4283
|
+
*/
|
|
4284
|
+
async getScopedSettings(scope, cap, nodeId) {
|
|
4285
|
+
const schema = await this.declaredScopedSchema(scope, cap);
|
|
4286
|
+
if (schema === null) return null;
|
|
4287
|
+
const stored = this.narrowToScope(await this.readRawProjectedStore(nodeId, cap), schema);
|
|
4288
|
+
const overlay = await this.scopedSettingsOverlay(scope, cap, nodeId);
|
|
4289
|
+
return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(stored, overlay) : stored, { inlineSecretsAsViews: true });
|
|
4290
|
+
}
|
|
4291
|
+
/** The OPERATOR's write of declared keys of one scope (D787 secret semantics). */
|
|
4292
|
+
async updateScopedSettings(scope, cap, patch, nodeId) {
|
|
4293
|
+
this._operatorWriteDepth++;
|
|
4294
|
+
try {
|
|
4295
|
+
await this.writeScoped(scope, cap, patch, nodeId);
|
|
4296
|
+
} finally {
|
|
4297
|
+
this._operatorWriteDepth--;
|
|
4298
|
+
}
|
|
4299
|
+
}
|
|
4300
|
+
/**
|
|
4301
|
+
* The effective values (`stored ?? default`) of one scope, a secret as its `set` view — never
|
|
4302
|
+
* its value. `null` when the capability declares nothing for the scope.
|
|
4303
|
+
*/
|
|
4304
|
+
async readScopedValues(scope, cap, nodeId) {
|
|
4305
|
+
const schema = await this.declaredScopedSchema(scope, cap);
|
|
4306
|
+
if (schema === null) return null;
|
|
4307
|
+
const form = hydrateSchema(schema, this.narrowToScope(await this.readRawProjectedStore(nodeId, cap), schema), { inlineSecretsAsViews: true });
|
|
4308
|
+
return Object.fromEntries([...collectHydratedFieldValues(form)].filter(([, value]) => value !== void 0));
|
|
4309
|
+
}
|
|
4310
|
+
/**
|
|
4089
4311
|
* What the create wizard and the integration edit page render for one instance: the addon's
|
|
4090
4312
|
* per-instance schema when it declares one, else its global schema (what they always showed).
|
|
4091
4313
|
*/
|
|
@@ -4237,6 +4459,9 @@ var BaseAddon = class {
|
|
|
4237
4459
|
* a keychain (an older kernel) it writes `''`, as such code always did.
|
|
4238
4460
|
*/
|
|
4239
4461
|
async clearSecrets(keys, nodeId) {
|
|
4462
|
+
await this.clearSecretKeys(keys, nodeId);
|
|
4463
|
+
}
|
|
4464
|
+
async clearSecretKeys(keys, nodeId, cap) {
|
|
4240
4465
|
const tree = this.addonSecretTree();
|
|
4241
4466
|
const keychain = this._ctx?.secrets !== void 0;
|
|
4242
4467
|
const stored = keychain ? await this.readAddonStoreWithRetry() : {};
|
|
@@ -4249,25 +4474,27 @@ var BaseAddon = class {
|
|
|
4249
4474
|
const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
|
|
4250
4475
|
patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
|
|
4251
4476
|
}
|
|
4252
|
-
await this.applyGlobalPatch(patch, nodeId);
|
|
4477
|
+
await this.applyGlobalPatch(patch, nodeId, cap);
|
|
4253
4478
|
}
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4479
|
+
/** Resolves `true` when the write changed stored values. */
|
|
4480
|
+
async applyGlobalPatch(barePatch, nodeId, cap) {
|
|
4481
|
+
await this.loadScopedSchemas(cap);
|
|
4482
|
+
const keys = this.perNodeKeys(cap);
|
|
4257
4483
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
4258
4484
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
4259
4485
|
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
4260
4486
|
const handle = this._secretSettings;
|
|
4261
4487
|
if (handle !== null) {
|
|
4262
4488
|
const { changed } = await handle.writeAddonStore(scoped);
|
|
4263
|
-
if (!changed) return;
|
|
4489
|
+
if (!changed) return false;
|
|
4264
4490
|
} else await this._ctx?.settings?.writeAddonStore(scoped);
|
|
4265
|
-
if (target !== localNode) return;
|
|
4491
|
+
if (target !== localNode) return true;
|
|
4266
4492
|
await this.resolveConfig();
|
|
4267
4493
|
await this.onConfigChanged();
|
|
4268
4494
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
4269
4495
|
const legacy = this.globalSettingsSchema();
|
|
4270
4496
|
this.maybeAutoRestart(Object.keys(barePatch), [...legacy === null ? [] : [legacy], ...this.loadedScopedSchemas().map((entry) => entry.schema)]);
|
|
4497
|
+
return true;
|
|
4271
4498
|
}
|
|
4272
4499
|
/**
|
|
4273
4500
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -45475,6 +45702,8 @@ var SettingsSchemaWithValuesSchema = z.object({
|
|
|
45475
45702
|
});
|
|
45476
45703
|
/** Patch object — keys are field names, values are the new field values. */
|
|
45477
45704
|
var SettingsPatchSchema = z.record(z.string(), z.unknown());
|
|
45705
|
+
/** The scope of a scoped-settings call (D986): where the capability declared the values. */
|
|
45706
|
+
var ScopedSettingsScopeSchema = z.enum(SCOPED_SETTINGS_SCOPES);
|
|
45478
45707
|
/** Standard success response for update operations. */
|
|
45479
45708
|
var SettingsUpdateResultSchema = z.object({ success: z.literal(true) });
|
|
45480
45709
|
/**
|
|
@@ -45523,6 +45752,28 @@ var addonSettingsCapability = {
|
|
|
45523
45752
|
kind: "mutation",
|
|
45524
45753
|
auth: "admin"
|
|
45525
45754
|
}),
|
|
45755
|
+
getScopedSettings: method(z.object({
|
|
45756
|
+
addonId: z.string(),
|
|
45757
|
+
cap: z.string(),
|
|
45758
|
+
scope: ScopedSettingsScopeSchema,
|
|
45759
|
+
nodeId: z.string().optional()
|
|
45760
|
+
}), SettingsSchemaWithValuesSchema.nullable()),
|
|
45761
|
+
updateScopedSettings: method(z.object({
|
|
45762
|
+
addonId: z.string(),
|
|
45763
|
+
cap: z.string(),
|
|
45764
|
+
scope: ScopedSettingsScopeSchema,
|
|
45765
|
+
nodeId: z.string().optional(),
|
|
45766
|
+
patch: SettingsPatchSchema
|
|
45767
|
+
}), SettingsUpdateResultSchema, {
|
|
45768
|
+
kind: "mutation",
|
|
45769
|
+
auth: "admin"
|
|
45770
|
+
}),
|
|
45771
|
+
readScopedValues: method(z.object({
|
|
45772
|
+
addonId: z.string(),
|
|
45773
|
+
cap: z.string(),
|
|
45774
|
+
scope: ScopedSettingsScopeSchema,
|
|
45775
|
+
nodeId: z.string().optional()
|
|
45776
|
+
}), z.record(z.string(), z.unknown()).nullable()),
|
|
45526
45777
|
getIntegrationSettings: method(z.object({
|
|
45527
45778
|
addonId: z.string(),
|
|
45528
45779
|
nodeId: z.string().optional()
|
|
@@ -96167,6 +96418,20 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
96167
96418
|
access: "view",
|
|
96168
96419
|
role: "admin"
|
|
96169
96420
|
},
|
|
96421
|
+
"addonSettings.getScopedSettings": {
|
|
96422
|
+
capName: "addon-settings",
|
|
96423
|
+
capScope: "system",
|
|
96424
|
+
addonId: null,
|
|
96425
|
+
access: "view",
|
|
96426
|
+
role: "admin"
|
|
96427
|
+
},
|
|
96428
|
+
"addonSettings.readScopedValues": {
|
|
96429
|
+
capName: "addon-settings",
|
|
96430
|
+
capScope: "system",
|
|
96431
|
+
addonId: null,
|
|
96432
|
+
access: "view",
|
|
96433
|
+
role: "admin"
|
|
96434
|
+
},
|
|
96170
96435
|
"addonSettings.unsetStoredSettingsKeys": {
|
|
96171
96436
|
capName: "addon-settings",
|
|
96172
96437
|
capScope: "system",
|
|
@@ -96188,6 +96453,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
96188
96453
|
access: "create",
|
|
96189
96454
|
role: "admin"
|
|
96190
96455
|
},
|
|
96456
|
+
"addonSettings.updateScopedSettings": {
|
|
96457
|
+
capName: "addon-settings",
|
|
96458
|
+
capScope: "system",
|
|
96459
|
+
addonId: null,
|
|
96460
|
+
access: "create",
|
|
96461
|
+
role: "admin"
|
|
96462
|
+
},
|
|
96191
96463
|
"addonWidgets.listWidgets": {
|
|
96192
96464
|
capName: "addon-widgets",
|
|
96193
96465
|
capScope: "system",
|