@camstack/addon-export-alexa 1.2.187 → 1.2.188
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 +6 -0
- package/dist/export-alexa.addon.js +304 -21
- package/dist/export-alexa.addon.mjs +304 -21
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.2.188] - 2026-11-07
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Internal: its stored state is now read and written through the typed state API under the same storage key; nothing changes for the operator.
|
|
15
|
+
|
|
10
16
|
## [1.2.187] - 2026-11-07
|
|
11
17
|
|
|
12
18
|
### Changed
|
|
@@ -6033,7 +6033,7 @@ var ZodIssueCode = {
|
|
|
6033
6033
|
var ZodFirstPartyTypeKind;
|
|
6034
6034
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6035
6035
|
//#endregion
|
|
6036
|
-
//#region ../types/dist/sleep-
|
|
6036
|
+
//#region ../types/dist/sleep-CQP-REJp.mjs
|
|
6037
6037
|
/**
|
|
6038
6038
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6039
6039
|
* window to float samples (D455).
|
|
@@ -6397,6 +6397,59 @@ Object.fromEntries([
|
|
|
6397
6397
|
function isValuelessField(field) {
|
|
6398
6398
|
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";
|
|
6399
6399
|
}
|
|
6400
|
+
/**
|
|
6401
|
+
* Base collector: flatten a hydrated `ConfigUISchemaWithValues` into
|
|
6402
|
+
* `key → { value, default }`, recursing through `group` and `sub-tabs`
|
|
6403
|
+
* layout fields. Keeping `value` and `default` SEPARATE (rather than
|
|
6404
|
+
* pre-resolving) lets callers both read the effective value AND detect
|
|
6405
|
+
* overrides (`value` differs from `default`). Structural over `unknown`;
|
|
6406
|
+
* malformed input yields an empty map, never throws.
|
|
6407
|
+
*/
|
|
6408
|
+
function collectHydratedFieldEntries(schema) {
|
|
6409
|
+
const out = /* @__PURE__ */ new Map();
|
|
6410
|
+
if (typeof schema !== "object" || schema === null) return out;
|
|
6411
|
+
const sections = schema.sections;
|
|
6412
|
+
if (!Array.isArray(sections)) return out;
|
|
6413
|
+
for (const section of sections) if (typeof section === "object" && section !== null) collectFieldEntriesInto(section.fields, out);
|
|
6414
|
+
return out;
|
|
6415
|
+
}
|
|
6416
|
+
/** Recursive field walker for {@link collectHydratedFieldEntries}. */
|
|
6417
|
+
function collectFieldEntriesInto(fields, into) {
|
|
6418
|
+
if (!Array.isArray(fields)) return;
|
|
6419
|
+
for (const field of fields) {
|
|
6420
|
+
if (typeof field !== "object" || field === null) continue;
|
|
6421
|
+
const type = field.type;
|
|
6422
|
+
if (type === "group") {
|
|
6423
|
+
collectFieldEntriesInto(field.fields, into);
|
|
6424
|
+
continue;
|
|
6425
|
+
}
|
|
6426
|
+
if (type === "sub-tabs") {
|
|
6427
|
+
const tabs = field.tabs;
|
|
6428
|
+
if (Array.isArray(tabs)) {
|
|
6429
|
+
for (const tab of tabs) if (typeof tab === "object" && tab !== null) collectFieldEntriesInto(tab.fields, into);
|
|
6430
|
+
}
|
|
6431
|
+
continue;
|
|
6432
|
+
}
|
|
6433
|
+
const key = field.key;
|
|
6434
|
+
if (typeof key !== "string" || key.length === 0) continue;
|
|
6435
|
+
if (!("value" in field)) continue;
|
|
6436
|
+
into.set(key, {
|
|
6437
|
+
value: field.value,
|
|
6438
|
+
default: field.default
|
|
6439
|
+
});
|
|
6440
|
+
}
|
|
6441
|
+
}
|
|
6442
|
+
/**
|
|
6443
|
+
* Flatten a hydrated settings payload into `key → EFFECTIVE value`
|
|
6444
|
+
* (`value ?? default`). The read-side inverse of `hydrateSchema` for the
|
|
6445
|
+
* common "just give me the resolved values" case. Built on
|
|
6446
|
+
* {@link collectHydratedFieldEntries}.
|
|
6447
|
+
*/
|
|
6448
|
+
function collectHydratedFieldValues(schema) {
|
|
6449
|
+
const out = /* @__PURE__ */ new Map();
|
|
6450
|
+
for (const [key, entry] of collectHydratedFieldEntries(schema)) out.set(key, entry.value ?? entry.default);
|
|
6451
|
+
return out;
|
|
6452
|
+
}
|
|
6400
6453
|
function hydrateSchema(schema, values, options = {}) {
|
|
6401
6454
|
return {
|
|
6402
6455
|
...schema.tabs ? { tabs: [...schema.tabs] } : {},
|
|
@@ -7620,6 +7673,21 @@ var SCOPED_SETTINGS_SCOPES = [
|
|
|
7620
7673
|
"device-defaults",
|
|
7621
7674
|
"node"
|
|
7622
7675
|
];
|
|
7676
|
+
/** The one refusal of a key a scope did not declare. */
|
|
7677
|
+
function assertDeclaredKeys(keys, declared) {
|
|
7678
|
+
const undeclared = keys.filter((key) => !declared.has(key));
|
|
7679
|
+
if (undeclared.length > 0) throw new Error(`scoped settings: [${undeclared.join(", ")}] not declared for this scope (declared: [${[...declared].join(", ")}])`);
|
|
7680
|
+
}
|
|
7681
|
+
/** Build the handle over an addon's scoped read, write and unset. */
|
|
7682
|
+
function createScopedSettings(deps) {
|
|
7683
|
+
return {
|
|
7684
|
+
async get() {
|
|
7685
|
+
return deps.schema.parse(await deps.read());
|
|
7686
|
+
},
|
|
7687
|
+
patch: (patch) => deps.write(Object.fromEntries(Object.entries(patch))),
|
|
7688
|
+
unset: (keys) => deps.unset(keys)
|
|
7689
|
+
};
|
|
7690
|
+
}
|
|
7623
7691
|
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
7624
7692
|
var KeychainWriteRefusedError = class extends Error {
|
|
7625
7693
|
fieldPath;
|
|
@@ -8195,7 +8263,16 @@ function createHandle(raw, opts) {
|
|
|
8195
8263
|
return blob;
|
|
8196
8264
|
}
|
|
8197
8265
|
},
|
|
8198
|
-
writeAddonStore: writeAddon
|
|
8266
|
+
writeAddonStore: writeAddon,
|
|
8267
|
+
removeClearedKeys: (keys) => serialize("addon", async () => {
|
|
8268
|
+
const stored = await readStoredAddonBlob(raw);
|
|
8269
|
+
index.seen("addon", stored);
|
|
8270
|
+
const removable = keys.filter((key) => collectSecretMarkerRefs(stored[key]).length === 0);
|
|
8271
|
+
if (removable.length === 0) return;
|
|
8272
|
+
const patch = Object.fromEntries(removable.map((key) => [key, void 0]));
|
|
8273
|
+
await raw.writeAddonStore(patch);
|
|
8274
|
+
index.wrote("addon", patch);
|
|
8275
|
+
})
|
|
8199
8276
|
};
|
|
8200
8277
|
}
|
|
8201
8278
|
/** The context the addon sees, plus the private raw view and write outcome. */
|
|
@@ -8740,6 +8817,151 @@ var BaseAddon = class {
|
|
|
8740
8817
|
}
|
|
8741
8818
|
}
|
|
8742
8819
|
/**
|
|
8820
|
+
* Hook: values layered over the stored ones when the FORM of one scope is served
|
|
8821
|
+
* ({@link getScopedSettings}) — a preview that derives dependent options without writing.
|
|
8822
|
+
* Never applied to {@link ScopedSettings.get} or to a write. `null` ⇒ no overlay.
|
|
8823
|
+
*/
|
|
8824
|
+
async scopedSettingsOverlay(_scope, _cap, _nodeId) {
|
|
8825
|
+
return null;
|
|
8826
|
+
}
|
|
8827
|
+
/**
|
|
8828
|
+
* Hook: a write of one scope changed stored values (not called when the store reports no change,
|
|
8829
|
+
* e.g. the write-back of a stored secret). `keys` are the bare field keys of the write, node keys included.
|
|
8830
|
+
*/
|
|
8831
|
+
async onScopedSettingsChanged(_scope, _cap, _keys) {}
|
|
8832
|
+
/** Typed handle over the CLUSTER settings `cap` declares (`clusterSettingsSchema`). */
|
|
8833
|
+
clusterSettings(cap, schema) {
|
|
8834
|
+
return this.scopedHandle("cluster", cap, schema);
|
|
8835
|
+
}
|
|
8836
|
+
/** Typed handle over the fleet defaults of the per-device settings `cap` declares. */
|
|
8837
|
+
deviceDefaults(cap, schema) {
|
|
8838
|
+
return this.scopedHandle("device-defaults", cap, schema);
|
|
8839
|
+
}
|
|
8840
|
+
/**
|
|
8841
|
+
* Typed handle over the settings `cap` owns PER NODE. `nodeId` omitted ⇒ the local node. A node
|
|
8842
|
+
* with no row yields the schema defaults — never a bare-key fallback.
|
|
8843
|
+
*/
|
|
8844
|
+
nodeSettings(cap, schema, nodeId) {
|
|
8845
|
+
return this.scopedHandle("node", cap, schema, nodeId);
|
|
8846
|
+
}
|
|
8847
|
+
/**
|
|
8848
|
+
* {@link state} for a value that is kept per node: stored under `<key>@<nodeId>`, and the
|
|
8849
|
+
* settings store carries `nodeId` in the row data (D986 §1), so a forgotten node's rows go in one
|
|
8850
|
+
* central delete. `nodeId` omitted ⇒ the local node.
|
|
8851
|
+
*/
|
|
8852
|
+
nodeState(key, schema, fallback, nodeId) {
|
|
8853
|
+
this._declaredStateKeys.add(key);
|
|
8854
|
+
return createDurableState({
|
|
8855
|
+
key: nodeScopedKey(key, nodeId ?? this._ctx?.kernel?.localNodeId ?? ""),
|
|
8856
|
+
schema,
|
|
8857
|
+
fallback,
|
|
8858
|
+
read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
|
|
8859
|
+
write: async (patch) => {
|
|
8860
|
+
await this._ctx?.settings?.writeAddonStore(patch);
|
|
8861
|
+
},
|
|
8862
|
+
onParseError: (k, e) => this._ctx?.logger?.warn?.(`durable-state: stored "${k}" failed validation — using fallback`, { meta: {
|
|
8863
|
+
addonId: this._ctx?.id,
|
|
8864
|
+
key: k,
|
|
8865
|
+
error: String(e)
|
|
8866
|
+
} })
|
|
8867
|
+
});
|
|
8868
|
+
}
|
|
8869
|
+
/** The loaded schema `cap` declares for `scope`, or `null`. */
|
|
8870
|
+
async declaredScopedSchema(scope, cap) {
|
|
8871
|
+
await this.loadScopedSchemas(cap);
|
|
8872
|
+
return this.loadedScopedSchemas(cap).find((entry) => entry.scope === scope)?.schema ?? null;
|
|
8873
|
+
}
|
|
8874
|
+
async requireScopedSchema(scope, cap) {
|
|
8875
|
+
const schema = await this.declaredScopedSchema(scope, cap);
|
|
8876
|
+
if (schema === null) throw new Error(`${this.constructor.name}: cap "${cap}" declares no ${scope} settings`);
|
|
8877
|
+
return schema;
|
|
8878
|
+
}
|
|
8879
|
+
scopedKeys(schema) {
|
|
8880
|
+
return new Set(schema.sections.flatMap((section) => collectValueFieldKeys(section.fields)));
|
|
8881
|
+
}
|
|
8882
|
+
/** `store` narrowed to the keys `schema` declares. */
|
|
8883
|
+
narrowToScope(store, schema) {
|
|
8884
|
+
const keys = this.scopedKeys(schema);
|
|
8885
|
+
return Object.fromEntries(Object.entries(store).filter(([key]) => keys.has(key)));
|
|
8886
|
+
}
|
|
8887
|
+
scopedHandle(scope, cap, schema, nodeId) {
|
|
8888
|
+
return createScopedSettings({
|
|
8889
|
+
schema,
|
|
8890
|
+
read: async () => {
|
|
8891
|
+
const declared = await this.requireScopedSchema(scope, cap);
|
|
8892
|
+
const stored = this.narrowToScope(await this.resolveGlobalStore(nodeId, cap), declared);
|
|
8893
|
+
const effective = collectHydratedFieldValues(hydrateSchema(declared, stored));
|
|
8894
|
+
return {
|
|
8895
|
+
...Object.fromEntries([...effective].filter(([, value]) => value !== void 0)),
|
|
8896
|
+
...stored
|
|
8897
|
+
};
|
|
8898
|
+
},
|
|
8899
|
+
write: (patch) => this.writeScoped(scope, cap, patch, nodeId),
|
|
8900
|
+
unset: (keys) => this.unsetScoped(scope, cap, keys, nodeId)
|
|
8901
|
+
});
|
|
8902
|
+
}
|
|
8903
|
+
/** The one write path of the scoped API: declared keys only, then the global patch. */
|
|
8904
|
+
async writeScoped(scope, cap, patch, nodeId) {
|
|
8905
|
+
assertDeclaredKeys(Object.keys(patch), this.scopedKeys(await this.requireScopedSchema(scope, cap)));
|
|
8906
|
+
if (await this.applyGlobalPatch(patch, scope === "node" ? nodeId : void 0, cap)) await this.onScopedSettingsChanged(scope, cap, Object.keys(patch));
|
|
8907
|
+
}
|
|
8908
|
+
/**
|
|
8909
|
+
* Remove declared keys of one scope. A secret goes through {@link clearSecrets} — its keychain
|
|
8910
|
+
* value is released exactly as there — and the emptied row is then removed; every other key is
|
|
8911
|
+
* removed by an `undefined` patch (which a secret transform would read as "keep").
|
|
8912
|
+
*/
|
|
8913
|
+
async unsetScoped(scope, cap, keys, nodeId) {
|
|
8914
|
+
assertDeclaredKeys(keys, this.scopedKeys(await this.requireScopedSchema(scope, cap)));
|
|
8915
|
+
const target = scope === "node" ? nodeId : void 0;
|
|
8916
|
+
const tree = this.addonSecretTree();
|
|
8917
|
+
const secretKeys = keys.filter((key) => tree.has(key));
|
|
8918
|
+
const plainKeys = keys.filter((key) => !tree.has(key));
|
|
8919
|
+
let changed = false;
|
|
8920
|
+
if (plainKeys.length > 0) {
|
|
8921
|
+
const patch = Object.fromEntries(plainKeys.map((key) => [key, void 0]));
|
|
8922
|
+
changed = await this.applyGlobalPatch(patch, target, cap) || changed;
|
|
8923
|
+
}
|
|
8924
|
+
if (secretKeys.length > 0) {
|
|
8925
|
+
await this.clearSecretKeys(secretKeys, target, cap);
|
|
8926
|
+
const node = normalizeNodeId(target ?? this._ctx?.kernel?.localNodeId);
|
|
8927
|
+
const rows = secretKeys.map((key) => scope === "node" ? nodeScopedKey(key, node) : key);
|
|
8928
|
+
if (this._secretSettings !== null) await this._secretSettings.removeClearedKeys(rows);
|
|
8929
|
+
else await this._ctx?.settings?.writeAddonStore(Object.fromEntries(rows.map((row) => [row, void 0])));
|
|
8930
|
+
changed = true;
|
|
8931
|
+
}
|
|
8932
|
+
if (changed) await this.onScopedSettingsChanged(scope, cap, [...keys]);
|
|
8933
|
+
}
|
|
8934
|
+
/**
|
|
8935
|
+
* The hydrated form of one scope of one capability's settings (any
|
|
8936
|
+
* {@link scopedSettingsOverlay} applied), or `null` when the capability declares nothing there.
|
|
8937
|
+
*/
|
|
8938
|
+
async getScopedSettings(scope, cap, nodeId) {
|
|
8939
|
+
const schema = await this.declaredScopedSchema(scope, cap);
|
|
8940
|
+
if (schema === null) return null;
|
|
8941
|
+
const stored = this.narrowToScope(await this.readRawProjectedStore(nodeId, cap), schema);
|
|
8942
|
+
const overlay = await this.scopedSettingsOverlay(scope, cap, nodeId);
|
|
8943
|
+
return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(stored, overlay) : stored, { inlineSecretsAsViews: true });
|
|
8944
|
+
}
|
|
8945
|
+
/** The OPERATOR's write of declared keys of one scope (D787 secret semantics). */
|
|
8946
|
+
async updateScopedSettings(scope, cap, patch, nodeId) {
|
|
8947
|
+
this._operatorWriteDepth++;
|
|
8948
|
+
try {
|
|
8949
|
+
await this.writeScoped(scope, cap, patch, nodeId);
|
|
8950
|
+
} finally {
|
|
8951
|
+
this._operatorWriteDepth--;
|
|
8952
|
+
}
|
|
8953
|
+
}
|
|
8954
|
+
/**
|
|
8955
|
+
* The effective values (`stored ?? default`) of one scope, a secret as its `set` view — never
|
|
8956
|
+
* its value. `null` when the capability declares nothing for the scope.
|
|
8957
|
+
*/
|
|
8958
|
+
async readScopedValues(scope, cap, nodeId) {
|
|
8959
|
+
const schema = await this.declaredScopedSchema(scope, cap);
|
|
8960
|
+
if (schema === null) return null;
|
|
8961
|
+
const form = hydrateSchema(schema, this.narrowToScope(await this.readRawProjectedStore(nodeId, cap), schema), { inlineSecretsAsViews: true });
|
|
8962
|
+
return Object.fromEntries([...collectHydratedFieldValues(form)].filter(([, value]) => value !== void 0));
|
|
8963
|
+
}
|
|
8964
|
+
/**
|
|
8743
8965
|
* What the create wizard and the integration edit page render for one instance: the addon's
|
|
8744
8966
|
* per-instance schema when it declares one, else its global schema (what they always showed).
|
|
8745
8967
|
*/
|
|
@@ -8891,6 +9113,9 @@ var BaseAddon = class {
|
|
|
8891
9113
|
* a keychain (an older kernel) it writes `''`, as such code always did.
|
|
8892
9114
|
*/
|
|
8893
9115
|
async clearSecrets(keys, nodeId) {
|
|
9116
|
+
await this.clearSecretKeys(keys, nodeId);
|
|
9117
|
+
}
|
|
9118
|
+
async clearSecretKeys(keys, nodeId, cap) {
|
|
8894
9119
|
const tree = this.addonSecretTree();
|
|
8895
9120
|
const keychain = this._ctx?.secrets !== void 0;
|
|
8896
9121
|
const stored = keychain ? await this.readAddonStoreWithRetry() : {};
|
|
@@ -8903,25 +9128,27 @@ var BaseAddon = class {
|
|
|
8903
9128
|
const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
|
|
8904
9129
|
patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
|
|
8905
9130
|
}
|
|
8906
|
-
await this.applyGlobalPatch(patch, nodeId);
|
|
9131
|
+
await this.applyGlobalPatch(patch, nodeId, cap);
|
|
8907
9132
|
}
|
|
8908
|
-
|
|
8909
|
-
|
|
8910
|
-
|
|
9133
|
+
/** Resolves `true` when the write changed stored values. */
|
|
9134
|
+
async applyGlobalPatch(barePatch, nodeId, cap) {
|
|
9135
|
+
await this.loadScopedSchemas(cap);
|
|
9136
|
+
const keys = this.perNodeKeys(cap);
|
|
8911
9137
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
8912
9138
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
8913
9139
|
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
8914
9140
|
const handle = this._secretSettings;
|
|
8915
9141
|
if (handle !== null) {
|
|
8916
9142
|
const { changed } = await handle.writeAddonStore(scoped);
|
|
8917
|
-
if (!changed) return;
|
|
9143
|
+
if (!changed) return false;
|
|
8918
9144
|
} else await this._ctx?.settings?.writeAddonStore(scoped);
|
|
8919
|
-
if (target !== localNode) return;
|
|
9145
|
+
if (target !== localNode) return true;
|
|
8920
9146
|
await this.resolveConfig();
|
|
8921
9147
|
await this.onConfigChanged();
|
|
8922
9148
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
8923
9149
|
const legacy = this.globalSettingsSchema();
|
|
8924
9150
|
this.maybeAutoRestart(Object.keys(barePatch), [...legacy === null ? [] : [legacy], ...this.loadedScopedSchemas().map((entry) => entry.schema)]);
|
|
9151
|
+
return true;
|
|
8925
9152
|
}
|
|
8926
9153
|
/**
|
|
8927
9154
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -45140,6 +45367,8 @@ var SettingsSchemaWithValuesSchema = object({
|
|
|
45140
45367
|
});
|
|
45141
45368
|
/** Patch object — keys are field names, values are the new field values. */
|
|
45142
45369
|
var SettingsPatchSchema = record(string(), unknown());
|
|
45370
|
+
/** The scope of a scoped-settings call (D986): where the capability declared the values. */
|
|
45371
|
+
var ScopedSettingsScopeSchema = _enum(SCOPED_SETTINGS_SCOPES);
|
|
45143
45372
|
/** Standard success response for update operations. */
|
|
45144
45373
|
var SettingsUpdateResultSchema = object({ success: literal(true) });
|
|
45145
45374
|
method(object({
|
|
@@ -45155,6 +45384,25 @@ method(object({
|
|
|
45155
45384
|
kind: "mutation",
|
|
45156
45385
|
auth: "admin"
|
|
45157
45386
|
}), method(object({
|
|
45387
|
+
addonId: string(),
|
|
45388
|
+
cap: string(),
|
|
45389
|
+
scope: ScopedSettingsScopeSchema,
|
|
45390
|
+
nodeId: string().optional()
|
|
45391
|
+
}), SettingsSchemaWithValuesSchema.nullable()), method(object({
|
|
45392
|
+
addonId: string(),
|
|
45393
|
+
cap: string(),
|
|
45394
|
+
scope: ScopedSettingsScopeSchema,
|
|
45395
|
+
nodeId: string().optional(),
|
|
45396
|
+
patch: SettingsPatchSchema
|
|
45397
|
+
}), SettingsUpdateResultSchema, {
|
|
45398
|
+
kind: "mutation",
|
|
45399
|
+
auth: "admin"
|
|
45400
|
+
}), method(object({
|
|
45401
|
+
addonId: string(),
|
|
45402
|
+
cap: string(),
|
|
45403
|
+
scope: ScopedSettingsScopeSchema,
|
|
45404
|
+
nodeId: string().optional()
|
|
45405
|
+
}), record(string(), unknown()).nullable()), method(object({
|
|
45158
45406
|
addonId: string(),
|
|
45159
45407
|
nodeId: string().optional()
|
|
45160
45408
|
}), SettingsSchemaWithValuesSchema.nullable()), method(object({
|
|
@@ -77149,6 +77397,20 @@ Object.freeze({
|
|
|
77149
77397
|
access: "view",
|
|
77150
77398
|
role: "admin"
|
|
77151
77399
|
},
|
|
77400
|
+
"addonSettings.getScopedSettings": {
|
|
77401
|
+
capName: "addon-settings",
|
|
77402
|
+
capScope: "system",
|
|
77403
|
+
addonId: null,
|
|
77404
|
+
access: "view",
|
|
77405
|
+
role: "admin"
|
|
77406
|
+
},
|
|
77407
|
+
"addonSettings.readScopedValues": {
|
|
77408
|
+
capName: "addon-settings",
|
|
77409
|
+
capScope: "system",
|
|
77410
|
+
addonId: null,
|
|
77411
|
+
access: "view",
|
|
77412
|
+
role: "admin"
|
|
77413
|
+
},
|
|
77152
77414
|
"addonSettings.unsetStoredSettingsKeys": {
|
|
77153
77415
|
capName: "addon-settings",
|
|
77154
77416
|
capScope: "system",
|
|
@@ -77170,6 +77432,13 @@ Object.freeze({
|
|
|
77170
77432
|
access: "create",
|
|
77171
77433
|
role: "admin"
|
|
77172
77434
|
},
|
|
77435
|
+
"addonSettings.updateScopedSettings": {
|
|
77436
|
+
capName: "addon-settings",
|
|
77437
|
+
capScope: "system",
|
|
77438
|
+
addonId: null,
|
|
77439
|
+
access: "create",
|
|
77440
|
+
role: "admin"
|
|
77441
|
+
},
|
|
77173
77442
|
"addonWidgets.listWidgets": {
|
|
77174
77443
|
capName: "addon-widgets",
|
|
77175
77444
|
capScope: "system",
|
|
@@ -105512,6 +105781,11 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
105512
105781
|
"tokens[userId].refreshToken",
|
|
105513
105782
|
"tokens[userId].brokerCredential"
|
|
105514
105783
|
];
|
|
105784
|
+
/** The hidden HMAC key of snapshot URLs (store key `snapshotSigningKey`, a keychain secret). */
|
|
105785
|
+
snapshotSigningKeyState = this.state("snapshotSigningKey", string(), "");
|
|
105786
|
+
/** The legacy ledger keys, until the migrations have moved them to the `skill-links` record. */
|
|
105787
|
+
legacyLinkedAccounts = this.state("linkedAccounts", array(LinkedAccountSchema), []);
|
|
105788
|
+
legacyTokens = this.state("tokens", array(LwaTokenEntrySchema), []);
|
|
105515
105789
|
snapshotStore = new SnapshotStore(() => this.config.snapshotSigningKey);
|
|
105516
105790
|
publicEndpoint = createPublicEndpointReader(() => this.ctx.api.localNetwork.getAddresses.query());
|
|
105517
105791
|
accessGateRef = null;
|
|
@@ -105556,18 +105830,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
105556
105830
|
accessGate: this.requireGate(),
|
|
105557
105831
|
settings: () => this.config,
|
|
105558
105832
|
handles: this.requireHandles(),
|
|
105559
|
-
legacyLedger: (instanceId) => instanceId === "export-alexa" ?
|
|
105560
|
-
read: () => ({
|
|
105561
|
-
linkedAccounts: this.config.linkedAccounts,
|
|
105562
|
-
tokens: this.config.tokens
|
|
105563
|
-
}),
|
|
105564
|
-
write: async (patch) => {
|
|
105565
|
-
await this.updateGlobalSettings({
|
|
105566
|
-
...patch.linkedAccounts === void 0 ? {} : { linkedAccounts: patch.linkedAccounts },
|
|
105567
|
-
...patch.tokens === void 0 ? {} : { tokens: patch.tokens }
|
|
105568
|
-
});
|
|
105569
|
-
}
|
|
105570
|
-
} : null,
|
|
105833
|
+
legacyLedger: (instanceId) => instanceId === "export-alexa" ? this.legacyLedgerPort() : null,
|
|
105571
105834
|
linkedUserIdsElsewhere: async (instanceId) => {
|
|
105572
105835
|
const users = /* @__PURE__ */ new Set();
|
|
105573
105836
|
for (const [id, runtime] of this.runtimes) {
|
|
@@ -105583,6 +105846,26 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
105583
105846
|
}
|
|
105584
105847
|
};
|
|
105585
105848
|
}
|
|
105849
|
+
/** The legacy ledger keys of the addon store, read from `config` and written through `state()`. */
|
|
105850
|
+
legacyLedgerPort() {
|
|
105851
|
+
return {
|
|
105852
|
+
read: () => ({
|
|
105853
|
+
linkedAccounts: this.config.linkedAccounts,
|
|
105854
|
+
tokens: this.config.tokens
|
|
105855
|
+
}),
|
|
105856
|
+
write: async (patch) => {
|
|
105857
|
+
if (patch.linkedAccounts !== void 0) await this.legacyLinkedAccounts.set([...patch.linkedAccounts]);
|
|
105858
|
+
if (patch.tokens !== void 0) await this.legacyTokens.set([...patch.tokens]);
|
|
105859
|
+
await this.resolveConfig();
|
|
105860
|
+
}
|
|
105861
|
+
};
|
|
105862
|
+
}
|
|
105863
|
+
/** The snapshot URL signing key (R2): generated once, hidden, rotated by nothing. */
|
|
105864
|
+
async ensureSnapshotSigningKey() {
|
|
105865
|
+
if (this.config.snapshotSigningKey) return;
|
|
105866
|
+
await this.snapshotSigningKeyState.set(generateIngressToken());
|
|
105867
|
+
await this.resolveConfig();
|
|
105868
|
+
}
|
|
105586
105869
|
async onInitialize() {
|
|
105587
105870
|
const records = this.ctx.records;
|
|
105588
105871
|
if (records === void 0) throw new Error("export-alexa needs ctx.records — check execution.placement (hub-only)");
|
|
@@ -105632,7 +105915,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
105632
105915
|
onChanged: (id, change) => this.onInstanceChanged(id, change)
|
|
105633
105916
|
});
|
|
105634
105917
|
await this.runMigrations(defineAddonMigrations(ADDON_MIGRATIONS, this.migrationPorts()));
|
|
105635
|
-
|
|
105918
|
+
await this.ensureSnapshotSigningKey();
|
|
105636
105919
|
if (this.config.lwaClientSecret) {
|
|
105637
105920
|
await this.clearSecrets(["lwaClientSecret"]);
|
|
105638
105921
|
this.ctx.logger.warn("export-alexa: removed a stored LWA client secret — the hub no longer uses one; your skill Lambda holds it (D753)");
|
|
@@ -6004,7 +6004,7 @@ var ZodIssueCode = {
|
|
|
6004
6004
|
var ZodFirstPartyTypeKind;
|
|
6005
6005
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6006
6006
|
//#endregion
|
|
6007
|
-
//#region ../types/dist/sleep-
|
|
6007
|
+
//#region ../types/dist/sleep-CQP-REJp.mjs
|
|
6008
6008
|
/**
|
|
6009
6009
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6010
6010
|
* window to float samples (D455).
|
|
@@ -6368,6 +6368,59 @@ Object.fromEntries([
|
|
|
6368
6368
|
function isValuelessField(field) {
|
|
6369
6369
|
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";
|
|
6370
6370
|
}
|
|
6371
|
+
/**
|
|
6372
|
+
* Base collector: flatten a hydrated `ConfigUISchemaWithValues` into
|
|
6373
|
+
* `key → { value, default }`, recursing through `group` and `sub-tabs`
|
|
6374
|
+
* layout fields. Keeping `value` and `default` SEPARATE (rather than
|
|
6375
|
+
* pre-resolving) lets callers both read the effective value AND detect
|
|
6376
|
+
* overrides (`value` differs from `default`). Structural over `unknown`;
|
|
6377
|
+
* malformed input yields an empty map, never throws.
|
|
6378
|
+
*/
|
|
6379
|
+
function collectHydratedFieldEntries(schema) {
|
|
6380
|
+
const out = /* @__PURE__ */ new Map();
|
|
6381
|
+
if (typeof schema !== "object" || schema === null) return out;
|
|
6382
|
+
const sections = schema.sections;
|
|
6383
|
+
if (!Array.isArray(sections)) return out;
|
|
6384
|
+
for (const section of sections) if (typeof section === "object" && section !== null) collectFieldEntriesInto(section.fields, out);
|
|
6385
|
+
return out;
|
|
6386
|
+
}
|
|
6387
|
+
/** Recursive field walker for {@link collectHydratedFieldEntries}. */
|
|
6388
|
+
function collectFieldEntriesInto(fields, into) {
|
|
6389
|
+
if (!Array.isArray(fields)) return;
|
|
6390
|
+
for (const field of fields) {
|
|
6391
|
+
if (typeof field !== "object" || field === null) continue;
|
|
6392
|
+
const type = field.type;
|
|
6393
|
+
if (type === "group") {
|
|
6394
|
+
collectFieldEntriesInto(field.fields, into);
|
|
6395
|
+
continue;
|
|
6396
|
+
}
|
|
6397
|
+
if (type === "sub-tabs") {
|
|
6398
|
+
const tabs = field.tabs;
|
|
6399
|
+
if (Array.isArray(tabs)) {
|
|
6400
|
+
for (const tab of tabs) if (typeof tab === "object" && tab !== null) collectFieldEntriesInto(tab.fields, into);
|
|
6401
|
+
}
|
|
6402
|
+
continue;
|
|
6403
|
+
}
|
|
6404
|
+
const key = field.key;
|
|
6405
|
+
if (typeof key !== "string" || key.length === 0) continue;
|
|
6406
|
+
if (!("value" in field)) continue;
|
|
6407
|
+
into.set(key, {
|
|
6408
|
+
value: field.value,
|
|
6409
|
+
default: field.default
|
|
6410
|
+
});
|
|
6411
|
+
}
|
|
6412
|
+
}
|
|
6413
|
+
/**
|
|
6414
|
+
* Flatten a hydrated settings payload into `key → EFFECTIVE value`
|
|
6415
|
+
* (`value ?? default`). The read-side inverse of `hydrateSchema` for the
|
|
6416
|
+
* common "just give me the resolved values" case. Built on
|
|
6417
|
+
* {@link collectHydratedFieldEntries}.
|
|
6418
|
+
*/
|
|
6419
|
+
function collectHydratedFieldValues(schema) {
|
|
6420
|
+
const out = /* @__PURE__ */ new Map();
|
|
6421
|
+
for (const [key, entry] of collectHydratedFieldEntries(schema)) out.set(key, entry.value ?? entry.default);
|
|
6422
|
+
return out;
|
|
6423
|
+
}
|
|
6371
6424
|
function hydrateSchema(schema, values, options = {}) {
|
|
6372
6425
|
return {
|
|
6373
6426
|
...schema.tabs ? { tabs: [...schema.tabs] } : {},
|
|
@@ -7591,6 +7644,21 @@ var SCOPED_SETTINGS_SCOPES = [
|
|
|
7591
7644
|
"device-defaults",
|
|
7592
7645
|
"node"
|
|
7593
7646
|
];
|
|
7647
|
+
/** The one refusal of a key a scope did not declare. */
|
|
7648
|
+
function assertDeclaredKeys(keys, declared) {
|
|
7649
|
+
const undeclared = keys.filter((key) => !declared.has(key));
|
|
7650
|
+
if (undeclared.length > 0) throw new Error(`scoped settings: [${undeclared.join(", ")}] not declared for this scope (declared: [${[...declared].join(", ")}])`);
|
|
7651
|
+
}
|
|
7652
|
+
/** Build the handle over an addon's scoped read, write and unset. */
|
|
7653
|
+
function createScopedSettings(deps) {
|
|
7654
|
+
return {
|
|
7655
|
+
async get() {
|
|
7656
|
+
return deps.schema.parse(await deps.read());
|
|
7657
|
+
},
|
|
7658
|
+
patch: (patch) => deps.write(Object.fromEntries(Object.entries(patch))),
|
|
7659
|
+
unset: (keys) => deps.unset(keys)
|
|
7660
|
+
};
|
|
7661
|
+
}
|
|
7594
7662
|
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
7595
7663
|
var KeychainWriteRefusedError = class extends Error {
|
|
7596
7664
|
fieldPath;
|
|
@@ -8166,7 +8234,16 @@ function createHandle(raw, opts) {
|
|
|
8166
8234
|
return blob;
|
|
8167
8235
|
}
|
|
8168
8236
|
},
|
|
8169
|
-
writeAddonStore: writeAddon
|
|
8237
|
+
writeAddonStore: writeAddon,
|
|
8238
|
+
removeClearedKeys: (keys) => serialize("addon", async () => {
|
|
8239
|
+
const stored = await readStoredAddonBlob(raw);
|
|
8240
|
+
index.seen("addon", stored);
|
|
8241
|
+
const removable = keys.filter((key) => collectSecretMarkerRefs(stored[key]).length === 0);
|
|
8242
|
+
if (removable.length === 0) return;
|
|
8243
|
+
const patch = Object.fromEntries(removable.map((key) => [key, void 0]));
|
|
8244
|
+
await raw.writeAddonStore(patch);
|
|
8245
|
+
index.wrote("addon", patch);
|
|
8246
|
+
})
|
|
8170
8247
|
};
|
|
8171
8248
|
}
|
|
8172
8249
|
/** The context the addon sees, plus the private raw view and write outcome. */
|
|
@@ -8711,6 +8788,151 @@ var BaseAddon = class {
|
|
|
8711
8788
|
}
|
|
8712
8789
|
}
|
|
8713
8790
|
/**
|
|
8791
|
+
* Hook: values layered over the stored ones when the FORM of one scope is served
|
|
8792
|
+
* ({@link getScopedSettings}) — a preview that derives dependent options without writing.
|
|
8793
|
+
* Never applied to {@link ScopedSettings.get} or to a write. `null` ⇒ no overlay.
|
|
8794
|
+
*/
|
|
8795
|
+
async scopedSettingsOverlay(_scope, _cap, _nodeId) {
|
|
8796
|
+
return null;
|
|
8797
|
+
}
|
|
8798
|
+
/**
|
|
8799
|
+
* Hook: a write of one scope changed stored values (not called when the store reports no change,
|
|
8800
|
+
* e.g. the write-back of a stored secret). `keys` are the bare field keys of the write, node keys included.
|
|
8801
|
+
*/
|
|
8802
|
+
async onScopedSettingsChanged(_scope, _cap, _keys) {}
|
|
8803
|
+
/** Typed handle over the CLUSTER settings `cap` declares (`clusterSettingsSchema`). */
|
|
8804
|
+
clusterSettings(cap, schema) {
|
|
8805
|
+
return this.scopedHandle("cluster", cap, schema);
|
|
8806
|
+
}
|
|
8807
|
+
/** Typed handle over the fleet defaults of the per-device settings `cap` declares. */
|
|
8808
|
+
deviceDefaults(cap, schema) {
|
|
8809
|
+
return this.scopedHandle("device-defaults", cap, schema);
|
|
8810
|
+
}
|
|
8811
|
+
/**
|
|
8812
|
+
* Typed handle over the settings `cap` owns PER NODE. `nodeId` omitted ⇒ the local node. A node
|
|
8813
|
+
* with no row yields the schema defaults — never a bare-key fallback.
|
|
8814
|
+
*/
|
|
8815
|
+
nodeSettings(cap, schema, nodeId) {
|
|
8816
|
+
return this.scopedHandle("node", cap, schema, nodeId);
|
|
8817
|
+
}
|
|
8818
|
+
/**
|
|
8819
|
+
* {@link state} for a value that is kept per node: stored under `<key>@<nodeId>`, and the
|
|
8820
|
+
* settings store carries `nodeId` in the row data (D986 §1), so a forgotten node's rows go in one
|
|
8821
|
+
* central delete. `nodeId` omitted ⇒ the local node.
|
|
8822
|
+
*/
|
|
8823
|
+
nodeState(key, schema, fallback, nodeId) {
|
|
8824
|
+
this._declaredStateKeys.add(key);
|
|
8825
|
+
return createDurableState({
|
|
8826
|
+
key: nodeScopedKey(key, nodeId ?? this._ctx?.kernel?.localNodeId ?? ""),
|
|
8827
|
+
schema,
|
|
8828
|
+
fallback,
|
|
8829
|
+
read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
|
|
8830
|
+
write: async (patch) => {
|
|
8831
|
+
await this._ctx?.settings?.writeAddonStore(patch);
|
|
8832
|
+
},
|
|
8833
|
+
onParseError: (k, e) => this._ctx?.logger?.warn?.(`durable-state: stored "${k}" failed validation — using fallback`, { meta: {
|
|
8834
|
+
addonId: this._ctx?.id,
|
|
8835
|
+
key: k,
|
|
8836
|
+
error: String(e)
|
|
8837
|
+
} })
|
|
8838
|
+
});
|
|
8839
|
+
}
|
|
8840
|
+
/** The loaded schema `cap` declares for `scope`, or `null`. */
|
|
8841
|
+
async declaredScopedSchema(scope, cap) {
|
|
8842
|
+
await this.loadScopedSchemas(cap);
|
|
8843
|
+
return this.loadedScopedSchemas(cap).find((entry) => entry.scope === scope)?.schema ?? null;
|
|
8844
|
+
}
|
|
8845
|
+
async requireScopedSchema(scope, cap) {
|
|
8846
|
+
const schema = await this.declaredScopedSchema(scope, cap);
|
|
8847
|
+
if (schema === null) throw new Error(`${this.constructor.name}: cap "${cap}" declares no ${scope} settings`);
|
|
8848
|
+
return schema;
|
|
8849
|
+
}
|
|
8850
|
+
scopedKeys(schema) {
|
|
8851
|
+
return new Set(schema.sections.flatMap((section) => collectValueFieldKeys(section.fields)));
|
|
8852
|
+
}
|
|
8853
|
+
/** `store` narrowed to the keys `schema` declares. */
|
|
8854
|
+
narrowToScope(store, schema) {
|
|
8855
|
+
const keys = this.scopedKeys(schema);
|
|
8856
|
+
return Object.fromEntries(Object.entries(store).filter(([key]) => keys.has(key)));
|
|
8857
|
+
}
|
|
8858
|
+
scopedHandle(scope, cap, schema, nodeId) {
|
|
8859
|
+
return createScopedSettings({
|
|
8860
|
+
schema,
|
|
8861
|
+
read: async () => {
|
|
8862
|
+
const declared = await this.requireScopedSchema(scope, cap);
|
|
8863
|
+
const stored = this.narrowToScope(await this.resolveGlobalStore(nodeId, cap), declared);
|
|
8864
|
+
const effective = collectHydratedFieldValues(hydrateSchema(declared, stored));
|
|
8865
|
+
return {
|
|
8866
|
+
...Object.fromEntries([...effective].filter(([, value]) => value !== void 0)),
|
|
8867
|
+
...stored
|
|
8868
|
+
};
|
|
8869
|
+
},
|
|
8870
|
+
write: (patch) => this.writeScoped(scope, cap, patch, nodeId),
|
|
8871
|
+
unset: (keys) => this.unsetScoped(scope, cap, keys, nodeId)
|
|
8872
|
+
});
|
|
8873
|
+
}
|
|
8874
|
+
/** The one write path of the scoped API: declared keys only, then the global patch. */
|
|
8875
|
+
async writeScoped(scope, cap, patch, nodeId) {
|
|
8876
|
+
assertDeclaredKeys(Object.keys(patch), this.scopedKeys(await this.requireScopedSchema(scope, cap)));
|
|
8877
|
+
if (await this.applyGlobalPatch(patch, scope === "node" ? nodeId : void 0, cap)) await this.onScopedSettingsChanged(scope, cap, Object.keys(patch));
|
|
8878
|
+
}
|
|
8879
|
+
/**
|
|
8880
|
+
* Remove declared keys of one scope. A secret goes through {@link clearSecrets} — its keychain
|
|
8881
|
+
* value is released exactly as there — and the emptied row is then removed; every other key is
|
|
8882
|
+
* removed by an `undefined` patch (which a secret transform would read as "keep").
|
|
8883
|
+
*/
|
|
8884
|
+
async unsetScoped(scope, cap, keys, nodeId) {
|
|
8885
|
+
assertDeclaredKeys(keys, this.scopedKeys(await this.requireScopedSchema(scope, cap)));
|
|
8886
|
+
const target = scope === "node" ? nodeId : void 0;
|
|
8887
|
+
const tree = this.addonSecretTree();
|
|
8888
|
+
const secretKeys = keys.filter((key) => tree.has(key));
|
|
8889
|
+
const plainKeys = keys.filter((key) => !tree.has(key));
|
|
8890
|
+
let changed = false;
|
|
8891
|
+
if (plainKeys.length > 0) {
|
|
8892
|
+
const patch = Object.fromEntries(plainKeys.map((key) => [key, void 0]));
|
|
8893
|
+
changed = await this.applyGlobalPatch(patch, target, cap) || changed;
|
|
8894
|
+
}
|
|
8895
|
+
if (secretKeys.length > 0) {
|
|
8896
|
+
await this.clearSecretKeys(secretKeys, target, cap);
|
|
8897
|
+
const node = normalizeNodeId(target ?? this._ctx?.kernel?.localNodeId);
|
|
8898
|
+
const rows = secretKeys.map((key) => scope === "node" ? nodeScopedKey(key, node) : key);
|
|
8899
|
+
if (this._secretSettings !== null) await this._secretSettings.removeClearedKeys(rows);
|
|
8900
|
+
else await this._ctx?.settings?.writeAddonStore(Object.fromEntries(rows.map((row) => [row, void 0])));
|
|
8901
|
+
changed = true;
|
|
8902
|
+
}
|
|
8903
|
+
if (changed) await this.onScopedSettingsChanged(scope, cap, [...keys]);
|
|
8904
|
+
}
|
|
8905
|
+
/**
|
|
8906
|
+
* The hydrated form of one scope of one capability's settings (any
|
|
8907
|
+
* {@link scopedSettingsOverlay} applied), or `null` when the capability declares nothing there.
|
|
8908
|
+
*/
|
|
8909
|
+
async getScopedSettings(scope, cap, nodeId) {
|
|
8910
|
+
const schema = await this.declaredScopedSchema(scope, cap);
|
|
8911
|
+
if (schema === null) return null;
|
|
8912
|
+
const stored = this.narrowToScope(await this.readRawProjectedStore(nodeId, cap), schema);
|
|
8913
|
+
const overlay = await this.scopedSettingsOverlay(scope, cap, nodeId);
|
|
8914
|
+
return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(stored, overlay) : stored, { inlineSecretsAsViews: true });
|
|
8915
|
+
}
|
|
8916
|
+
/** The OPERATOR's write of declared keys of one scope (D787 secret semantics). */
|
|
8917
|
+
async updateScopedSettings(scope, cap, patch, nodeId) {
|
|
8918
|
+
this._operatorWriteDepth++;
|
|
8919
|
+
try {
|
|
8920
|
+
await this.writeScoped(scope, cap, patch, nodeId);
|
|
8921
|
+
} finally {
|
|
8922
|
+
this._operatorWriteDepth--;
|
|
8923
|
+
}
|
|
8924
|
+
}
|
|
8925
|
+
/**
|
|
8926
|
+
* The effective values (`stored ?? default`) of one scope, a secret as its `set` view — never
|
|
8927
|
+
* its value. `null` when the capability declares nothing for the scope.
|
|
8928
|
+
*/
|
|
8929
|
+
async readScopedValues(scope, cap, nodeId) {
|
|
8930
|
+
const schema = await this.declaredScopedSchema(scope, cap);
|
|
8931
|
+
if (schema === null) return null;
|
|
8932
|
+
const form = hydrateSchema(schema, this.narrowToScope(await this.readRawProjectedStore(nodeId, cap), schema), { inlineSecretsAsViews: true });
|
|
8933
|
+
return Object.fromEntries([...collectHydratedFieldValues(form)].filter(([, value]) => value !== void 0));
|
|
8934
|
+
}
|
|
8935
|
+
/**
|
|
8714
8936
|
* What the create wizard and the integration edit page render for one instance: the addon's
|
|
8715
8937
|
* per-instance schema when it declares one, else its global schema (what they always showed).
|
|
8716
8938
|
*/
|
|
@@ -8862,6 +9084,9 @@ var BaseAddon = class {
|
|
|
8862
9084
|
* a keychain (an older kernel) it writes `''`, as such code always did.
|
|
8863
9085
|
*/
|
|
8864
9086
|
async clearSecrets(keys, nodeId) {
|
|
9087
|
+
await this.clearSecretKeys(keys, nodeId);
|
|
9088
|
+
}
|
|
9089
|
+
async clearSecretKeys(keys, nodeId, cap) {
|
|
8865
9090
|
const tree = this.addonSecretTree();
|
|
8866
9091
|
const keychain = this._ctx?.secrets !== void 0;
|
|
8867
9092
|
const stored = keychain ? await this.readAddonStoreWithRetry() : {};
|
|
@@ -8874,25 +9099,27 @@ var BaseAddon = class {
|
|
|
8874
9099
|
const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
|
|
8875
9100
|
patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
|
|
8876
9101
|
}
|
|
8877
|
-
await this.applyGlobalPatch(patch, nodeId);
|
|
9102
|
+
await this.applyGlobalPatch(patch, nodeId, cap);
|
|
8878
9103
|
}
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
9104
|
+
/** Resolves `true` when the write changed stored values. */
|
|
9105
|
+
async applyGlobalPatch(barePatch, nodeId, cap) {
|
|
9106
|
+
await this.loadScopedSchemas(cap);
|
|
9107
|
+
const keys = this.perNodeKeys(cap);
|
|
8882
9108
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
8883
9109
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
8884
9110
|
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
8885
9111
|
const handle = this._secretSettings;
|
|
8886
9112
|
if (handle !== null) {
|
|
8887
9113
|
const { changed } = await handle.writeAddonStore(scoped);
|
|
8888
|
-
if (!changed) return;
|
|
9114
|
+
if (!changed) return false;
|
|
8889
9115
|
} else await this._ctx?.settings?.writeAddonStore(scoped);
|
|
8890
|
-
if (target !== localNode) return;
|
|
9116
|
+
if (target !== localNode) return true;
|
|
8891
9117
|
await this.resolveConfig();
|
|
8892
9118
|
await this.onConfigChanged();
|
|
8893
9119
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
8894
9120
|
const legacy = this.globalSettingsSchema();
|
|
8895
9121
|
this.maybeAutoRestart(Object.keys(barePatch), [...legacy === null ? [] : [legacy], ...this.loadedScopedSchemas().map((entry) => entry.schema)]);
|
|
9122
|
+
return true;
|
|
8896
9123
|
}
|
|
8897
9124
|
/**
|
|
8898
9125
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -45111,6 +45338,8 @@ var SettingsSchemaWithValuesSchema = object({
|
|
|
45111
45338
|
});
|
|
45112
45339
|
/** Patch object — keys are field names, values are the new field values. */
|
|
45113
45340
|
var SettingsPatchSchema = record(string(), unknown());
|
|
45341
|
+
/** The scope of a scoped-settings call (D986): where the capability declared the values. */
|
|
45342
|
+
var ScopedSettingsScopeSchema = _enum(SCOPED_SETTINGS_SCOPES);
|
|
45114
45343
|
/** Standard success response for update operations. */
|
|
45115
45344
|
var SettingsUpdateResultSchema = object({ success: literal(true) });
|
|
45116
45345
|
method(object({
|
|
@@ -45126,6 +45355,25 @@ method(object({
|
|
|
45126
45355
|
kind: "mutation",
|
|
45127
45356
|
auth: "admin"
|
|
45128
45357
|
}), method(object({
|
|
45358
|
+
addonId: string(),
|
|
45359
|
+
cap: string(),
|
|
45360
|
+
scope: ScopedSettingsScopeSchema,
|
|
45361
|
+
nodeId: string().optional()
|
|
45362
|
+
}), SettingsSchemaWithValuesSchema.nullable()), method(object({
|
|
45363
|
+
addonId: string(),
|
|
45364
|
+
cap: string(),
|
|
45365
|
+
scope: ScopedSettingsScopeSchema,
|
|
45366
|
+
nodeId: string().optional(),
|
|
45367
|
+
patch: SettingsPatchSchema
|
|
45368
|
+
}), SettingsUpdateResultSchema, {
|
|
45369
|
+
kind: "mutation",
|
|
45370
|
+
auth: "admin"
|
|
45371
|
+
}), method(object({
|
|
45372
|
+
addonId: string(),
|
|
45373
|
+
cap: string(),
|
|
45374
|
+
scope: ScopedSettingsScopeSchema,
|
|
45375
|
+
nodeId: string().optional()
|
|
45376
|
+
}), record(string(), unknown()).nullable()), method(object({
|
|
45129
45377
|
addonId: string(),
|
|
45130
45378
|
nodeId: string().optional()
|
|
45131
45379
|
}), SettingsSchemaWithValuesSchema.nullable()), method(object({
|
|
@@ -77120,6 +77368,20 @@ Object.freeze({
|
|
|
77120
77368
|
access: "view",
|
|
77121
77369
|
role: "admin"
|
|
77122
77370
|
},
|
|
77371
|
+
"addonSettings.getScopedSettings": {
|
|
77372
|
+
capName: "addon-settings",
|
|
77373
|
+
capScope: "system",
|
|
77374
|
+
addonId: null,
|
|
77375
|
+
access: "view",
|
|
77376
|
+
role: "admin"
|
|
77377
|
+
},
|
|
77378
|
+
"addonSettings.readScopedValues": {
|
|
77379
|
+
capName: "addon-settings",
|
|
77380
|
+
capScope: "system",
|
|
77381
|
+
addonId: null,
|
|
77382
|
+
access: "view",
|
|
77383
|
+
role: "admin"
|
|
77384
|
+
},
|
|
77123
77385
|
"addonSettings.unsetStoredSettingsKeys": {
|
|
77124
77386
|
capName: "addon-settings",
|
|
77125
77387
|
capScope: "system",
|
|
@@ -77141,6 +77403,13 @@ Object.freeze({
|
|
|
77141
77403
|
access: "create",
|
|
77142
77404
|
role: "admin"
|
|
77143
77405
|
},
|
|
77406
|
+
"addonSettings.updateScopedSettings": {
|
|
77407
|
+
capName: "addon-settings",
|
|
77408
|
+
capScope: "system",
|
|
77409
|
+
addonId: null,
|
|
77410
|
+
access: "create",
|
|
77411
|
+
role: "admin"
|
|
77412
|
+
},
|
|
77144
77413
|
"addonWidgets.listWidgets": {
|
|
77145
77414
|
capName: "addon-widgets",
|
|
77146
77415
|
capScope: "system",
|
|
@@ -105483,6 +105752,11 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
105483
105752
|
"tokens[userId].refreshToken",
|
|
105484
105753
|
"tokens[userId].brokerCredential"
|
|
105485
105754
|
];
|
|
105755
|
+
/** The hidden HMAC key of snapshot URLs (store key `snapshotSigningKey`, a keychain secret). */
|
|
105756
|
+
snapshotSigningKeyState = this.state("snapshotSigningKey", string(), "");
|
|
105757
|
+
/** The legacy ledger keys, until the migrations have moved them to the `skill-links` record. */
|
|
105758
|
+
legacyLinkedAccounts = this.state("linkedAccounts", array(LinkedAccountSchema), []);
|
|
105759
|
+
legacyTokens = this.state("tokens", array(LwaTokenEntrySchema), []);
|
|
105486
105760
|
snapshotStore = new SnapshotStore(() => this.config.snapshotSigningKey);
|
|
105487
105761
|
publicEndpoint = createPublicEndpointReader(() => this.ctx.api.localNetwork.getAddresses.query());
|
|
105488
105762
|
accessGateRef = null;
|
|
@@ -105527,18 +105801,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
105527
105801
|
accessGate: this.requireGate(),
|
|
105528
105802
|
settings: () => this.config,
|
|
105529
105803
|
handles: this.requireHandles(),
|
|
105530
|
-
legacyLedger: (instanceId) => instanceId === "export-alexa" ?
|
|
105531
|
-
read: () => ({
|
|
105532
|
-
linkedAccounts: this.config.linkedAccounts,
|
|
105533
|
-
tokens: this.config.tokens
|
|
105534
|
-
}),
|
|
105535
|
-
write: async (patch) => {
|
|
105536
|
-
await this.updateGlobalSettings({
|
|
105537
|
-
...patch.linkedAccounts === void 0 ? {} : { linkedAccounts: patch.linkedAccounts },
|
|
105538
|
-
...patch.tokens === void 0 ? {} : { tokens: patch.tokens }
|
|
105539
|
-
});
|
|
105540
|
-
}
|
|
105541
|
-
} : null,
|
|
105804
|
+
legacyLedger: (instanceId) => instanceId === "export-alexa" ? this.legacyLedgerPort() : null,
|
|
105542
105805
|
linkedUserIdsElsewhere: async (instanceId) => {
|
|
105543
105806
|
const users = /* @__PURE__ */ new Set();
|
|
105544
105807
|
for (const [id, runtime] of this.runtimes) {
|
|
@@ -105554,6 +105817,26 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
105554
105817
|
}
|
|
105555
105818
|
};
|
|
105556
105819
|
}
|
|
105820
|
+
/** The legacy ledger keys of the addon store, read from `config` and written through `state()`. */
|
|
105821
|
+
legacyLedgerPort() {
|
|
105822
|
+
return {
|
|
105823
|
+
read: () => ({
|
|
105824
|
+
linkedAccounts: this.config.linkedAccounts,
|
|
105825
|
+
tokens: this.config.tokens
|
|
105826
|
+
}),
|
|
105827
|
+
write: async (patch) => {
|
|
105828
|
+
if (patch.linkedAccounts !== void 0) await this.legacyLinkedAccounts.set([...patch.linkedAccounts]);
|
|
105829
|
+
if (patch.tokens !== void 0) await this.legacyTokens.set([...patch.tokens]);
|
|
105830
|
+
await this.resolveConfig();
|
|
105831
|
+
}
|
|
105832
|
+
};
|
|
105833
|
+
}
|
|
105834
|
+
/** The snapshot URL signing key (R2): generated once, hidden, rotated by nothing. */
|
|
105835
|
+
async ensureSnapshotSigningKey() {
|
|
105836
|
+
if (this.config.snapshotSigningKey) return;
|
|
105837
|
+
await this.snapshotSigningKeyState.set(generateIngressToken());
|
|
105838
|
+
await this.resolveConfig();
|
|
105839
|
+
}
|
|
105557
105840
|
async onInitialize() {
|
|
105558
105841
|
const records = this.ctx.records;
|
|
105559
105842
|
if (records === void 0) throw new Error("export-alexa needs ctx.records — check execution.placement (hub-only)");
|
|
@@ -105603,7 +105886,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
105603
105886
|
onChanged: (id, change) => this.onInstanceChanged(id, change)
|
|
105604
105887
|
});
|
|
105605
105888
|
await this.runMigrations(defineAddonMigrations(ADDON_MIGRATIONS, this.migrationPorts()));
|
|
105606
|
-
|
|
105889
|
+
await this.ensureSnapshotSigningKey();
|
|
105607
105890
|
if (this.config.lwaClientSecret) {
|
|
105608
105891
|
await this.clearSecrets(["lwaClientSecret"]);
|
|
105609
105892
|
this.ctx.logger.warn("export-alexa: removed a stored LWA client secret — the hub no longer uses one; your skill Lambda holds it (D753)");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-export-alexa",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.188",
|
|
4
4
|
"description": "Alexa Smart Home Skill export — hub-side OAuth provider + directive handler. The companion AWS Lambda forwards Alexa directives to this addon's /addon/export-alexa/directive endpoint.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
}
|
|
60
60
|
],
|
|
61
61
|
"requires": {
|
|
62
|
-
"server": ">=1.2.
|
|
62
|
+
"server": ">=1.2.791"
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
"files": [
|