@camstack/addon-export-alexa 1.2.180 → 1.2.181
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 +72 -9
- package/dist/export-alexa.addon.mjs +72 -9
- 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.181] - 2026-11-03
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Fixes the Alexa account-link migration that failed with 'tokens.find is not a function' and could delete the old link settings without a verified copy; a retry now repairs a partial link record
|
|
15
|
+
|
|
10
16
|
## [1.2.180] - 2026-11-03
|
|
11
17
|
|
|
12
18
|
### Changed
|
|
@@ -6016,7 +6016,7 @@ var ZodIssueCode = {
|
|
|
6016
6016
|
var ZodFirstPartyTypeKind;
|
|
6017
6017
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6018
6018
|
//#endregion
|
|
6019
|
-
//#region ../types/dist/sleep-
|
|
6019
|
+
//#region ../types/dist/sleep-DV4qxEyD.mjs
|
|
6020
6020
|
/**
|
|
6021
6021
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6022
6022
|
* window to float samples (D455).
|
|
@@ -8153,6 +8153,10 @@ var BaseAddon = class {
|
|
|
8153
8153
|
const stored = keychain ? await this.readAddonStoreWithRetry() : {};
|
|
8154
8154
|
const patch = {};
|
|
8155
8155
|
for (const key of keys) {
|
|
8156
|
+
if (tree.get(key)?.kind === "array") {
|
|
8157
|
+
patch[key] = [];
|
|
8158
|
+
continue;
|
|
8159
|
+
}
|
|
8156
8160
|
const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
|
|
8157
8161
|
patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
|
|
8158
8162
|
}
|
|
@@ -101965,8 +101969,17 @@ async function moveLedgersToLinks(ports) {
|
|
|
101965
101969
|
linkedAccounts,
|
|
101966
101970
|
tokens
|
|
101967
101971
|
});
|
|
101968
|
-
|
|
101969
|
-
|
|
101972
|
+
let held = await ports.readLinks();
|
|
101973
|
+
const matches = (record) => record !== null && canonical(record.linkedAccounts) === canonical(linkedAccounts) && canonical(record.tokens) === canonical(tokens);
|
|
101974
|
+
if (put === "exists" && !matches(held) && isCoveredBy(held, linkedAccounts, tokens)) {
|
|
101975
|
+
await ports.replaceLinks({
|
|
101976
|
+
name: LINKS_NAME,
|
|
101977
|
+
linkedAccounts,
|
|
101978
|
+
tokens
|
|
101979
|
+
});
|
|
101980
|
+
held = await ports.readLinks();
|
|
101981
|
+
}
|
|
101982
|
+
if (!matches(held)) {
|
|
101970
101983
|
ports.warn("Alexa migration: the skill-links record does not hold what the settings carried; the legacy ledgers are kept");
|
|
101971
101984
|
if (put === "created") throw new Error("the Alexa link record does not match the legacy settings; nothing was cleared");
|
|
101972
101985
|
return {
|
|
@@ -101982,10 +101995,32 @@ async function moveLedgersToLinks(ports) {
|
|
|
101982
101995
|
accounts: linkedAccounts.length
|
|
101983
101996
|
}
|
|
101984
101997
|
} : {
|
|
101985
|
-
outcome: "
|
|
101986
|
-
summary: {
|
|
101998
|
+
outcome: "done",
|
|
101999
|
+
summary: {
|
|
102000
|
+
moved: true,
|
|
102001
|
+
repaired: true,
|
|
102002
|
+
accounts: linkedAccounts.length
|
|
102003
|
+
}
|
|
101987
102004
|
};
|
|
101988
102005
|
}
|
|
102006
|
+
/**
|
|
102007
|
+
* The record carries this migration's own name and every account and grant it holds is also in
|
|
102008
|
+
* the settings: rewriting it loses nothing and touches nothing an operator named.
|
|
102009
|
+
*/
|
|
102010
|
+
function isCoveredBy(held, linkedAccounts, tokens) {
|
|
102011
|
+
if (held === null || held.name !== LINKS_NAME) return false;
|
|
102012
|
+
const accounts = new Set(linkedAccounts.map((a) => a.userId));
|
|
102013
|
+
const grants = new Set(tokens.map((t) => t.userId));
|
|
102014
|
+
return held.linkedAccounts.every((a) => accounts.has(a.userId)) && held.tokens.every((t) => grants.has(t.userId));
|
|
102015
|
+
}
|
|
102016
|
+
/**
|
|
102017
|
+
* A ledger key the drop may judge: absent, a list, or the leftover of a credential clear
|
|
102018
|
+
* (`{ $secretClear: true }`, stored where a list belongs by an older build). Anything else is
|
|
102019
|
+
* not understood, so nothing is deleted on its account.
|
|
102020
|
+
*/
|
|
102021
|
+
function isLedgerShape(value) {
|
|
102022
|
+
return value === void 0 || Array.isArray(value) || isSecretClear(value);
|
|
102023
|
+
}
|
|
101989
102024
|
/** Whether a stored token entry still carries a credential: text, or a keychain marker. */
|
|
101990
102025
|
function carriesCredential(entry) {
|
|
101991
102026
|
if (typeof entry !== "object" || entry === null) return false;
|
|
@@ -102013,11 +102048,17 @@ async function planDropMovedSettings(ports) {
|
|
|
102013
102048
|
if (ledgerKeys.length > 0) {
|
|
102014
102049
|
const links = await ports.readLinks();
|
|
102015
102050
|
if (links === null) return refuse("no Alexa link record exists");
|
|
102016
|
-
|
|
102017
|
-
|
|
102051
|
+
if (!isLedgerShape(stored["linkedAccounts"])) return refuse("the old linkedAccounts setting is not a list the migration understands");
|
|
102052
|
+
if (!isLedgerShape(stored["tokens"])) return refuse("the old tokens setting is not a list the migration understands");
|
|
102018
102053
|
const legacyTokens = stored["tokens"];
|
|
102019
102054
|
if (Array.isArray(legacyTokens) && legacyTokens.some(carriesCredential)) return refuse("the old settings still carry Amazon push credentials");
|
|
102020
|
-
|
|
102055
|
+
const heldAccounts = new Map(links.linkedAccounts.map((a) => [a.userId, a]));
|
|
102056
|
+
const heldTokens = new Set(links.tokens.map((t) => t.userId));
|
|
102057
|
+
for (const account of accountsOf(stored["linkedAccounts"])) {
|
|
102058
|
+
const held = heldAccounts.get(account.userId);
|
|
102059
|
+
if (held === void 0) return refuse(`the record lacks the account ${account.userId}`);
|
|
102060
|
+
if (canonical(held) !== canonical(account)) return refuse(`the record holds the account ${account.userId} differently`);
|
|
102061
|
+
}
|
|
102021
102062
|
for (const token of tokensOf(stored["tokens"])) if (!heldTokens.has(token.userId)) return refuse(`the record lacks the grant ${token.userId}`);
|
|
102022
102063
|
}
|
|
102023
102064
|
const present = [...skillKeys, ...ledgerKeys];
|
|
@@ -103499,15 +103540,31 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103499
103540
|
/** The keychain refused the link credentials: the ledger is read-only until it answers (D49). */
|
|
103500
103541
|
linksLocked = false;
|
|
103501
103542
|
/**
|
|
103543
|
+
* The legacy ledger keys as lists. A store written by an older build may hold something that
|
|
103544
|
+
* is not a list there (a clear instruction stored as the value); the page and the gateway read
|
|
103545
|
+
* a list or nothing.
|
|
103546
|
+
*/
|
|
103547
|
+
legacyLedgers() {
|
|
103548
|
+
return {
|
|
103549
|
+
linkedAccounts: Array.isArray(this.config.linkedAccounts) ? this.config.linkedAccounts : [],
|
|
103550
|
+
tokens: Array.isArray(this.config.tokens) ? this.config.tokens : []
|
|
103551
|
+
};
|
|
103552
|
+
}
|
|
103553
|
+
/**
|
|
103502
103554
|
* The settings as the addon reads them: the records where they exist, the legacy keys until
|
|
103503
103555
|
* the migrations have moved them.
|
|
103504
103556
|
*/
|
|
103505
103557
|
get view() {
|
|
103506
103558
|
const skill = this.skillRow;
|
|
103507
103559
|
const links = this.linksRow;
|
|
103508
|
-
|
|
103560
|
+
const legacy = this.legacyLedgers();
|
|
103561
|
+
if (skill === null && links === null) return {
|
|
103562
|
+
...this.config,
|
|
103563
|
+
...legacy
|
|
103564
|
+
};
|
|
103509
103565
|
return {
|
|
103510
103566
|
...this.config,
|
|
103567
|
+
...legacy,
|
|
103511
103568
|
...skill === null ? {} : {
|
|
103512
103569
|
skillMode: skill.skillMode,
|
|
103513
103570
|
region: skill.region,
|
|
@@ -104471,6 +104528,12 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
104471
104528
|
},
|
|
104472
104529
|
putSkill: (body) => putOnce(skills, body),
|
|
104473
104530
|
putLinks: (body) => putOnce(links, body),
|
|
104531
|
+
replaceLinks: async (body) => {
|
|
104532
|
+
await links.put({
|
|
104533
|
+
id: ALEXA_INSTANCE_ID,
|
|
104534
|
+
data: body
|
|
104535
|
+
});
|
|
104536
|
+
},
|
|
104474
104537
|
readLinks: async () => (await links.getResolved("export-alexa"))?.data ?? null,
|
|
104475
104538
|
hasSkill: async () => await skills.get(ALEXA_INSTANCE_ID) !== null,
|
|
104476
104539
|
clearOldTokenSecrets: async () => {
|
|
@@ -5987,7 +5987,7 @@ var ZodIssueCode = {
|
|
|
5987
5987
|
var ZodFirstPartyTypeKind;
|
|
5988
5988
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5989
5989
|
//#endregion
|
|
5990
|
-
//#region ../types/dist/sleep-
|
|
5990
|
+
//#region ../types/dist/sleep-DV4qxEyD.mjs
|
|
5991
5991
|
/**
|
|
5992
5992
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5993
5993
|
* window to float samples (D455).
|
|
@@ -8124,6 +8124,10 @@ var BaseAddon = class {
|
|
|
8124
8124
|
const stored = keychain ? await this.readAddonStoreWithRetry() : {};
|
|
8125
8125
|
const patch = {};
|
|
8126
8126
|
for (const key of keys) {
|
|
8127
|
+
if (tree.get(key)?.kind === "array") {
|
|
8128
|
+
patch[key] = [];
|
|
8129
|
+
continue;
|
|
8130
|
+
}
|
|
8127
8131
|
const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
|
|
8128
8132
|
patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
|
|
8129
8133
|
}
|
|
@@ -101936,8 +101940,17 @@ async function moveLedgersToLinks(ports) {
|
|
|
101936
101940
|
linkedAccounts,
|
|
101937
101941
|
tokens
|
|
101938
101942
|
});
|
|
101939
|
-
|
|
101940
|
-
|
|
101943
|
+
let held = await ports.readLinks();
|
|
101944
|
+
const matches = (record) => record !== null && canonical(record.linkedAccounts) === canonical(linkedAccounts) && canonical(record.tokens) === canonical(tokens);
|
|
101945
|
+
if (put === "exists" && !matches(held) && isCoveredBy(held, linkedAccounts, tokens)) {
|
|
101946
|
+
await ports.replaceLinks({
|
|
101947
|
+
name: LINKS_NAME,
|
|
101948
|
+
linkedAccounts,
|
|
101949
|
+
tokens
|
|
101950
|
+
});
|
|
101951
|
+
held = await ports.readLinks();
|
|
101952
|
+
}
|
|
101953
|
+
if (!matches(held)) {
|
|
101941
101954
|
ports.warn("Alexa migration: the skill-links record does not hold what the settings carried; the legacy ledgers are kept");
|
|
101942
101955
|
if (put === "created") throw new Error("the Alexa link record does not match the legacy settings; nothing was cleared");
|
|
101943
101956
|
return {
|
|
@@ -101953,10 +101966,32 @@ async function moveLedgersToLinks(ports) {
|
|
|
101953
101966
|
accounts: linkedAccounts.length
|
|
101954
101967
|
}
|
|
101955
101968
|
} : {
|
|
101956
|
-
outcome: "
|
|
101957
|
-
summary: {
|
|
101969
|
+
outcome: "done",
|
|
101970
|
+
summary: {
|
|
101971
|
+
moved: true,
|
|
101972
|
+
repaired: true,
|
|
101973
|
+
accounts: linkedAccounts.length
|
|
101974
|
+
}
|
|
101958
101975
|
};
|
|
101959
101976
|
}
|
|
101977
|
+
/**
|
|
101978
|
+
* The record carries this migration's own name and every account and grant it holds is also in
|
|
101979
|
+
* the settings: rewriting it loses nothing and touches nothing an operator named.
|
|
101980
|
+
*/
|
|
101981
|
+
function isCoveredBy(held, linkedAccounts, tokens) {
|
|
101982
|
+
if (held === null || held.name !== LINKS_NAME) return false;
|
|
101983
|
+
const accounts = new Set(linkedAccounts.map((a) => a.userId));
|
|
101984
|
+
const grants = new Set(tokens.map((t) => t.userId));
|
|
101985
|
+
return held.linkedAccounts.every((a) => accounts.has(a.userId)) && held.tokens.every((t) => grants.has(t.userId));
|
|
101986
|
+
}
|
|
101987
|
+
/**
|
|
101988
|
+
* A ledger key the drop may judge: absent, a list, or the leftover of a credential clear
|
|
101989
|
+
* (`{ $secretClear: true }`, stored where a list belongs by an older build). Anything else is
|
|
101990
|
+
* not understood, so nothing is deleted on its account.
|
|
101991
|
+
*/
|
|
101992
|
+
function isLedgerShape(value) {
|
|
101993
|
+
return value === void 0 || Array.isArray(value) || isSecretClear(value);
|
|
101994
|
+
}
|
|
101960
101995
|
/** Whether a stored token entry still carries a credential: text, or a keychain marker. */
|
|
101961
101996
|
function carriesCredential(entry) {
|
|
101962
101997
|
if (typeof entry !== "object" || entry === null) return false;
|
|
@@ -101984,11 +102019,17 @@ async function planDropMovedSettings(ports) {
|
|
|
101984
102019
|
if (ledgerKeys.length > 0) {
|
|
101985
102020
|
const links = await ports.readLinks();
|
|
101986
102021
|
if (links === null) return refuse("no Alexa link record exists");
|
|
101987
|
-
|
|
101988
|
-
|
|
102022
|
+
if (!isLedgerShape(stored["linkedAccounts"])) return refuse("the old linkedAccounts setting is not a list the migration understands");
|
|
102023
|
+
if (!isLedgerShape(stored["tokens"])) return refuse("the old tokens setting is not a list the migration understands");
|
|
101989
102024
|
const legacyTokens = stored["tokens"];
|
|
101990
102025
|
if (Array.isArray(legacyTokens) && legacyTokens.some(carriesCredential)) return refuse("the old settings still carry Amazon push credentials");
|
|
101991
|
-
|
|
102026
|
+
const heldAccounts = new Map(links.linkedAccounts.map((a) => [a.userId, a]));
|
|
102027
|
+
const heldTokens = new Set(links.tokens.map((t) => t.userId));
|
|
102028
|
+
for (const account of accountsOf(stored["linkedAccounts"])) {
|
|
102029
|
+
const held = heldAccounts.get(account.userId);
|
|
102030
|
+
if (held === void 0) return refuse(`the record lacks the account ${account.userId}`);
|
|
102031
|
+
if (canonical(held) !== canonical(account)) return refuse(`the record holds the account ${account.userId} differently`);
|
|
102032
|
+
}
|
|
101992
102033
|
for (const token of tokensOf(stored["tokens"])) if (!heldTokens.has(token.userId)) return refuse(`the record lacks the grant ${token.userId}`);
|
|
101993
102034
|
}
|
|
101994
102035
|
const present = [...skillKeys, ...ledgerKeys];
|
|
@@ -103470,15 +103511,31 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103470
103511
|
/** The keychain refused the link credentials: the ledger is read-only until it answers (D49). */
|
|
103471
103512
|
linksLocked = false;
|
|
103472
103513
|
/**
|
|
103514
|
+
* The legacy ledger keys as lists. A store written by an older build may hold something that
|
|
103515
|
+
* is not a list there (a clear instruction stored as the value); the page and the gateway read
|
|
103516
|
+
* a list or nothing.
|
|
103517
|
+
*/
|
|
103518
|
+
legacyLedgers() {
|
|
103519
|
+
return {
|
|
103520
|
+
linkedAccounts: Array.isArray(this.config.linkedAccounts) ? this.config.linkedAccounts : [],
|
|
103521
|
+
tokens: Array.isArray(this.config.tokens) ? this.config.tokens : []
|
|
103522
|
+
};
|
|
103523
|
+
}
|
|
103524
|
+
/**
|
|
103473
103525
|
* The settings as the addon reads them: the records where they exist, the legacy keys until
|
|
103474
103526
|
* the migrations have moved them.
|
|
103475
103527
|
*/
|
|
103476
103528
|
get view() {
|
|
103477
103529
|
const skill = this.skillRow;
|
|
103478
103530
|
const links = this.linksRow;
|
|
103479
|
-
|
|
103531
|
+
const legacy = this.legacyLedgers();
|
|
103532
|
+
if (skill === null && links === null) return {
|
|
103533
|
+
...this.config,
|
|
103534
|
+
...legacy
|
|
103535
|
+
};
|
|
103480
103536
|
return {
|
|
103481
103537
|
...this.config,
|
|
103538
|
+
...legacy,
|
|
103482
103539
|
...skill === null ? {} : {
|
|
103483
103540
|
skillMode: skill.skillMode,
|
|
103484
103541
|
region: skill.region,
|
|
@@ -104442,6 +104499,12 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
104442
104499
|
},
|
|
104443
104500
|
putSkill: (body) => putOnce(skills, body),
|
|
104444
104501
|
putLinks: (body) => putOnce(links, body),
|
|
104502
|
+
replaceLinks: async (body) => {
|
|
104503
|
+
await links.put({
|
|
104504
|
+
id: ALEXA_INSTANCE_ID,
|
|
104505
|
+
data: body
|
|
104506
|
+
});
|
|
104507
|
+
},
|
|
104445
104508
|
readLinks: async () => (await links.getResolved("export-alexa"))?.data ?? null,
|
|
104446
104509
|
hasSkill: async () => await skills.get(ALEXA_INSTANCE_ID) !== null,
|
|
104447
104510
|
clearOldTokenSecrets: async () => {
|
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.181",
|
|
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.748"
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
"files": [
|