@camstack/addon-import-alexa 0.2.151 → 0.2.153

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.
Files changed (17) hide show
  1. package/dist/{MotionZonesSettings-Dxo0EAzN.mjs → MotionZonesSettings-BAg3ARov.mjs} +2 -2
  2. package/dist/{PrivacyMaskSettings-DwWxpZrj.mjs → PrivacyMaskSettings-C0cYJFNC.mjs} +4 -4
  3. package/dist/{SceneMonitorEditor-CC0dk5TR.mjs → SceneMonitorEditor-3Nx49OE2.mjs} +3 -3
  4. package/dist/_stub.js +9 -9
  5. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_import_alexa_page-CcQjQJmj.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_import_alexa_page-Yxzd8sJD.mjs} +2 -2
  6. package/dist/{_virtual_mf___mfe_internal__addon_import_alexa_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-Msberbw_.mjs → _virtual_mf___mfe_internal__addon_import_alexa_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-BU5ExEvB.mjs} +1 -1
  7. package/dist/addon.js +234 -40
  8. package/dist/addon.mjs +234 -40
  9. package/dist/{hostInit-CRUwUtSm.mjs → hostInit-U2MikdrL.mjs} +1 -1
  10. package/dist/{player-overlays-DNpsEqAe.mjs → player-overlays-COWyo9kN.mjs} +1 -1
  11. package/dist/remoteEntry.js +1 -1
  12. package/dist/{responsive-B82v3AbM.mjs → responsive-CLpz8rKp.mjs} +1 -1
  13. package/dist/{scene-monitor-copy-CPnjwzw6.mjs → scene-monitor-copy-BLy8yxxd.mjs} +1 -1
  14. package/dist/{square-YTl_L1_3.mjs → square-YnF15tkM.mjs} +1 -1
  15. package/dist/{trash-2-DCHugLVt.mjs → trash-2-dnzK3zvI.mjs} +1 -1
  16. package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_import_alexa_page__remoteEntry_js-DMdgQOgz.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_import_alexa_page__remoteEntry_js-OqMWqeF3.mjs} +1 -1
  17. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -1819,7 +1819,7 @@ var Doc = class {
1819
1819
  };
1820
1820
  //#endregion
1821
1821
  //#region ../../node_modules/zod/v4/core/versions.js
1822
- var version = {
1822
+ var version$1 = {
1823
1823
  major: 4,
1824
1824
  minor: 4,
1825
1825
  patch: 3
@@ -1831,7 +1831,7 @@ var $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1831
1831
  inst ?? (inst = {});
1832
1832
  inst._zod.def = def;
1833
1833
  inst._zod.bag = inst._zod.bag || {};
1834
- inst._zod.version = version;
1834
+ inst._zod.version = version$1;
1835
1835
  const checks = [...inst._zod.def.checks ?? []];
1836
1836
  if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
1837
1837
  for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
@@ -17611,7 +17611,22 @@ var BrokerProviderInfoSchema = object({
17611
17611
  */
17612
17612
  interactiveConnectPath: string().min(1).optional(),
17613
17613
  /** Relative hub path to disconnect the linked account (same popup pattern). */
17614
- interactiveDisconnectPath: string().min(1).optional()
17614
+ interactiveDisconnectPath: string().min(1).optional(),
17615
+ /**
17616
+ * The kind signs in through a server-held interactive session instead of
17617
+ * (or before) typed credentials. `basePath` is a hub-relative route set
17618
+ * served by the owning addon (`/addon/<id>/...`) speaking the sign-in
17619
+ * contract: `POST {basePath}/start` (body: the form's settings) answers
17620
+ * `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
17621
+ * `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
17622
+ * 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
17623
+ * (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
17624
+ * existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
17625
+ * (`{ sessionId }`) drops the session. The dialog that edits a broker
17626
+ * offers it as the default path; the fields the session fills are
17627
+ * marked `filledBySignIn` in the kind's settings schema.
17628
+ */
17629
+ signIn: object({ basePath: string().min(1) }).optional()
17615
17630
  }))
17616
17631
  });
17617
17632
  var ListInputSchema = object({
@@ -58051,7 +58066,8 @@ var BATTERY_DEVICE_TYPES = [
58051
58066
  DeviceType.Switch,
58052
58067
  DeviceType.PetFeeder,
58053
58068
  DeviceType.Container,
58054
- DeviceType.Thermostat
58069
+ DeviceType.Thermostat,
58070
+ DeviceType.EventEmitter
58055
58071
  ];
58056
58072
  /** Generic Customize target for the percentage reading (D936). */
58057
58073
  var batteryCustomize = {
@@ -64902,9 +64918,9 @@ var PowerMeterStatusSchema = object({
64902
64918
  /** Cumulative energy in kilowatt-hours since the meter was reset. */
64903
64919
  kwhTotal: number().optional().meta(readingMeta("energy", { label: "Energy" })),
64904
64920
  /** Voltage in volts. */
64905
- volts: number().optional().meta(readingMeta("voltage")),
64921
+ volts: number().optional().meta(readingMeta("voltage", { label: "Voltage" })),
64906
64922
  /** Current in amperes. */
64907
- amps: number().optional().meta(readingMeta("current")),
64923
+ amps: number().optional().meta(readingMeta("current", { label: "Current" })),
64908
64924
  /** Apparent power in volt-amperes. */
64909
64925
  va: number().optional().meta(readingMeta("apparent-power")),
64910
64926
  /** Power factor (0..1) if reported. */
@@ -64912,17 +64928,74 @@ var PowerMeterStatusSchema = object({
64912
64928
  /** Ms epoch when the slice was last updated. */
64913
64929
  lastFetchedAt: number()
64914
64930
  });
64931
+ /**
64932
+ * Loads that draw metered mains power (D951). The reading is a feature of the
64933
+ * device itself — a plug, a lamp, a fan, an air conditioner, a boiler, a
64934
+ * vacuum dock — not a separate sensor beside it. A `Sensor` stays: a clamp
64935
+ * meter or a standalone energy monitor IS the device. Cover, lock, valve,
64936
+ * camera and the like are left out: their draw is not what anyone meters.
64937
+ */
64938
+ var POWER_METER_DEVICE_TYPES = [
64939
+ DeviceType.Sensor,
64940
+ DeviceType.Switch,
64941
+ DeviceType.Light,
64942
+ DeviceType.Fan,
64943
+ DeviceType.Climate,
64944
+ DeviceType.Thermostat,
64945
+ DeviceType.Humidifier,
64946
+ DeviceType.WaterHeater,
64947
+ DeviceType.MediaPlayer,
64948
+ DeviceType.Washer,
64949
+ DeviceType.Dryer,
64950
+ DeviceType.Dishwasher,
64951
+ DeviceType.Vacuum,
64952
+ DeviceType.LawnMower,
64953
+ DeviceType.PetFeeder
64954
+ ];
64955
+ /** Everything but a bare `Sensor`: a sensor that takes its reading from another sensor adds nothing. */
64956
+ var POWER_METER_CUSTOMIZE_DEVICE_TYPES = POWER_METER_DEVICE_TYPES.filter((type) => type !== DeviceType.Sensor);
64957
+ /** One scalar target per reading; each is sourced from a device of its own (D951). */
64958
+ function powerTarget(id, unit) {
64959
+ return {
64960
+ id,
64961
+ cardinality: "scalar",
64962
+ vocabulary: {
64963
+ cap: "power-meter",
64964
+ stateField: id
64965
+ },
64966
+ deviceTypes: POWER_METER_CUSTOMIZE_DEVICE_TYPES,
64967
+ apply: "add",
64968
+ path: id,
64969
+ sources: [{
64970
+ kind: "numeric",
64971
+ requiredUnit: unit,
64972
+ transforms: [{ kind: "identity" }]
64973
+ }],
64974
+ companions: [{
64975
+ kind: "clock",
64976
+ path: "lastFetchedAt",
64977
+ when: "always"
64978
+ }],
64979
+ sourceReport: { status: "assignment-status" },
64980
+ advancedExpression: true
64981
+ };
64982
+ }
64983
+ /** "Power and energy" extension: watts, energy, voltage and current from other devices (D951). */
64984
+ var powerMeterCustomize = {
64985
+ version: 1,
64986
+ targets: [
64987
+ powerTarget("watts", "W"),
64988
+ powerTarget("kwhTotal", "kWh"),
64989
+ powerTarget("volts", "V"),
64990
+ powerTarget("amps", "A")
64991
+ ]
64992
+ };
64915
64993
  var powerMeterCapability = {
64916
64994
  name: "power-meter",
64917
64995
  scope: "device",
64918
64996
  deviceNative: true,
64919
64997
  mode: "singleton",
64920
- deviceTypes: [
64921
- DeviceType.Sensor,
64922
- DeviceType.Washer,
64923
- DeviceType.Dryer,
64924
- DeviceType.Dishwasher
64925
- ],
64998
+ deviceTypes: POWER_METER_DEVICE_TYPES,
64926
64999
  methods: {},
64927
65000
  status: {
64928
65001
  schema: PowerMeterStatusSchema,
@@ -64979,7 +65052,8 @@ var powerMeterCapability = {
64979
65052
  } },
64980
65053
  /** Clock fields: written, but excluded from the compare that decides
64981
65054
  * whether persisting is worth a SQLite commit. */
64982
- volatileStateFields: ["lastFetchedAt"]
65055
+ volatileStateFields: ["lastFetchedAt"],
65056
+ customize: powerMeterCustomize
64983
65057
  };
64984
65058
  /**
64985
65059
  * Presence cap. Models HA `person.*` and `device_tracker.*` entities
@@ -70367,7 +70441,7 @@ method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" })
70367
70441
  });
70368
70442
  DeviceFeature.FanSpeed, DeviceFeature.FanPreset, DeviceFeature.FanDirection, DeviceFeature.FanOscillating, DeviceFeature.CoverPositionable, DeviceFeature.CoverTilt, DeviceFeature.ValvePositionable, DeviceFeature.MediaPlayerVolume, DeviceFeature.ClimateFanMode;
70369
70443
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
70370
- DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Thermostat, DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Camera, DeviceType.Camera, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer, DeviceType.WaterHeater, DeviceType.Humidifier, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.PetFeeder;
70444
+ DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Thermostat, DeviceType.EventEmitter, DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Camera, DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer, DeviceType.WaterHeater, DeviceType.Humidifier, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.PetFeeder;
70371
70445
  String.raw`rose\(active(\d+), changed(\d+), (\d+(?:\.\d+)?)\)`;
70372
70446
  DeviceRole.BinarySensor, DeviceRole.MotionSensor;
70373
70447
  new Set(CAP_NAMES);
@@ -90090,37 +90164,78 @@ function toRecord(value) {
90090
90164
  function settingsToAlexaConnection(settings) {
90091
90165
  return alexaConnectionSchema.parse(toRecord(settings));
90092
90166
  }
90167
+ /**
90168
+ * Allowlist of real Amazon regional domains that alexa-remote2 is known to
90169
+ * support. An enum (not a free-form string) keeps the value from ever naming an
90170
+ * arbitrary host: alexa-remote2 uses it as a raw domain suffix.
90171
+ */
90172
+ var AMAZON_DOMAINS = [
90173
+ "amazon.com",
90174
+ "amazon.it",
90175
+ "amazon.de",
90176
+ "amazon.co.uk",
90177
+ "amazon.fr",
90178
+ "amazon.es",
90179
+ "amazon.ca",
90180
+ "amazon.com.au",
90181
+ "amazon.co.jp",
90182
+ "amazon.in",
90183
+ "amazon.com.br",
90184
+ "amazon.com.mx"
90185
+ ];
90186
+ /** The country each domain serves; the first match for a country prefills the form. */
90187
+ var AMAZON_DOMAIN_BY_COUNTRY = {
90188
+ US: "amazon.com",
90189
+ IT: "amazon.it",
90190
+ DE: "amazon.de",
90191
+ AT: "amazon.de",
90192
+ GB: "amazon.co.uk",
90193
+ FR: "amazon.fr",
90194
+ ES: "amazon.es",
90195
+ CA: "amazon.ca",
90196
+ AU: "amazon.com.au",
90197
+ JP: "amazon.co.jp",
90198
+ IN: "amazon.in",
90199
+ BR: "amazon.com.br",
90200
+ MX: "amazon.com.mx"
90201
+ };
90093
90202
  /** Hand-written connection form for the broker/integration creation UI. */
90094
90203
  function buildConnectionFormSchema() {
90095
90204
  return { sections: [{
90096
90205
  id: "alexa-account",
90097
90206
  title: "Amazon Alexa account",
90098
90207
  titleKey: "import-alexa:connection.s_alexa-account.title",
90099
- description: "Link an Amazon account via the unofficial Alexa client. Supply a captured cookie OR a refresh token. NOTE: this is an unofficial integration — Amazon can change or break it without notice, and it may violate Amazon ToS. State is polled, not pushed.",
90208
+ description: "Sign in with your Amazon account to link it. This is an unofficial integration: Amazon can change or break it without notice, and it may violate Amazon ToS. State is polled, not pushed.",
90100
90209
  descriptionKey: "import-alexa:connection.s_alexa-account.description",
90101
90210
  columns: 1,
90102
90211
  fields: [
90103
90212
  {
90104
- type: "text",
90213
+ type: "select",
90105
90214
  key: "amazonDomain",
90106
90215
  label: "Amazon domain (region)",
90107
90216
  labelKey: "import-alexa:connection.s_alexa-account.amazonDomain.label",
90108
- placeholder: "amazon.com",
90109
- default: "amazon.com"
90217
+ options: AMAZON_DOMAINS.map((value) => ({
90218
+ value,
90219
+ label: value
90220
+ })),
90221
+ default: "amazon.com",
90222
+ defaultByCountry: AMAZON_DOMAIN_BY_COUNTRY
90110
90223
  },
90111
90224
  {
90112
90225
  type: "password",
90113
90226
  key: "cookie",
90114
- label: "Cookie blob (from proxy login)",
90227
+ label: "Cookie blob (filled by the sign-in)",
90115
90228
  labelKey: "import-alexa:connection.s_alexa-account.cookie.label",
90116
- showToggle: true
90229
+ showToggle: true,
90230
+ filledBySignIn: true
90117
90231
  },
90118
90232
  {
90119
90233
  type: "password",
90120
90234
  key: "refreshToken",
90121
- label: "Refresh token (alternative to cookie)",
90235
+ label: "Refresh token (alternative to the sign-in)",
90122
90236
  labelKey: "import-alexa:connection.s_alexa-account.refreshToken.label",
90123
- showToggle: true
90237
+ showToggle: true,
90238
+ filledBySignIn: true
90124
90239
  },
90125
90240
  {
90126
90241
  type: "number",
@@ -128719,7 +128834,7 @@ var require_alexa_cookie = /* @__PURE__ */ __commonJSMin(((exports, module) => {
128719
128834
  module.exports = AlexaCookie();
128720
128835
  }));
128721
128836
  //#endregion
128722
- //#region src/alexa-proxy-login.ts
128837
+ //#region ../../node_modules/alexa-remote2/package.json
128723
128838
  var import_alexa_remote = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
128724
128839
  var https = require("https");
128725
128840
  var querystring = require("querystring");
@@ -131337,6 +131452,76 @@ var import_alexa_remote = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin
131337
131452
  };
131338
131453
  module.exports = AlexaRemote;
131339
131454
  })))());
131455
+ //#endregion
131456
+ //#region src/alexa-api-user-agent.ts
131457
+ /**
131458
+ * The `apiUserAgentPostfix` handed to every `alexa-remote2` `init`.
131459
+ *
131460
+ * Left unset, the library computes it with
131461
+ * `require(path.join(__dirname, 'package.json'))`. Bundled into `dist/addon.js`
131462
+ * that resolves to the addon's own `dist/`, where no `package.json` exists, and
131463
+ * `init` throws "Cannot find module …/dist/package.json". Setting it here keeps
131464
+ * the library's own value (`AlexaRemote/<version>`), read at build time.
131465
+ */
131466
+ var ALEXA_API_USER_AGENT_POSTFIX = `AlexaRemote/${{
131467
+ name: "alexa-remote2",
131468
+ version: "8.0.4",
131469
+ description: "Remote Control for amazon echo devices",
131470
+ author: {
131471
+ "name": "Apollon77",
131472
+ "email": "iobroker@fischer-ka.de"
131473
+ },
131474
+ contributors: [
131475
+ {
131476
+ "name": "soef",
131477
+ "email": "soef@gmx.net"
131478
+ },
131479
+ {
131480
+ "name": "Apollon77",
131481
+ "email": "iobroker@fischer-ka.de"
131482
+ },
131483
+ {
131484
+ "name": "bbindreiter",
131485
+ "email": "bernd.bindreiter@gmail.com"
131486
+ }
131487
+ ],
131488
+ homepage: "https://github.com/Apollon77/alexa-remote",
131489
+ license: "MIT",
131490
+ keywords: [
131491
+ "alexa",
131492
+ "echo",
131493
+ "alexa remote",
131494
+ "layla.amazon.de"
131495
+ ],
131496
+ dependencies: {
131497
+ "alexa-cookie2": "^5.0.3",
131498
+ "https": "^1.0.0",
131499
+ "querystring": "^0.2.1",
131500
+ "ws": "^8.18.3",
131501
+ "extend": "^3.0.2",
131502
+ "uuid": "^11.1.0"
131503
+ },
131504
+ devDependencies: {
131505
+ "@alcalzone/release-script": "^5.0.0",
131506
+ "@alcalzone/release-script-plugin-license": "^4.0.0",
131507
+ "eslint": "^8.57.1"
131508
+ },
131509
+ scripts: {
131510
+ "test": "node node_modules/mocha/bin/mocha",
131511
+ "release": "release-script"
131512
+ },
131513
+ repository: {
131514
+ "type": "git",
131515
+ "url": "git+https://github.com/Apollon77/alexa-remote.git"
131516
+ },
131517
+ bugs: { "url": "https://github.com/Apollon77/alexa-remote/issues" },
131518
+ engines: { "node": ">=16.0.0" },
131519
+ types: "alexa-remote.d.ts",
131520
+ main: "alexa-remote.js",
131521
+ readmeFilename: "readme.md"
131522
+ }.version}`;
131523
+ //#endregion
131524
+ //#region src/alexa-proxy-login.ts
131340
131525
  /**
131341
131526
  * A single interactive proxy-login attempt. One instance = one Amazon login.
131342
131527
  * Construct → {@link start} → poll {@link getStatus} → on `captured` the
@@ -131393,6 +131578,7 @@ var AlexaProxyLoginSession = class {
131393
131578
  proxyPort: this.#opts.proxyPort,
131394
131579
  proxyLogLevel: "warn",
131395
131580
  amazonPage,
131581
+ apiUserAgentPostfix: ALEXA_API_USER_AGENT_POSTFIX,
131396
131582
  logger: (...args) => {
131397
131583
  const line = args.map(String).join(" ");
131398
131584
  if (SECRET_LINE_RE.test(line)) return;
@@ -131611,20 +131797,25 @@ function capturedToCookieString(captured) {
131611
131797
  }
131612
131798
  //#endregion
131613
131799
  //#region src/alexa-login-routes.ts
131614
- var StartBodySchema = object({ amazonDomain: _enum([
131615
- "amazon.com",
131616
- "amazon.it",
131617
- "amazon.de",
131618
- "amazon.co.uk",
131619
- "amazon.fr",
131620
- "amazon.es",
131621
- "amazon.ca",
131622
- "amazon.com.au",
131623
- "amazon.co.jp",
131624
- "amazon.in",
131625
- "amazon.com.br",
131626
- "amazon.com.mx"
131627
- ]).default("amazon.com") });
131800
+ /**
131801
+ * `addon-routes` control plane that drives the INTERACTIVE Amazon login from the
131802
+ * broker dialog (the kind's `signIn` contract). All routes are `admin` — they start a proxy server and
131803
+ * mutate broker credentials, so they require an admin session/scoped token (the
131804
+ * hub enforces this BEFORE the handler runs; see `main.ts` `/addon/:addonId/*`).
131805
+ *
131806
+ * Public URLs (hub reachable as `https://<hub>`):
131807
+ * POST /addon/import-alexa/login/start { amazonDomain } → { sessionId, loginUrl }
131808
+ * GET /addon/import-alexa/login/status?sessionId=… → AlexaProxyLoginStatus (no secrets)
131809
+ * POST /addon/import-alexa/login/commit { sessionId, name, brokerId? } → { brokerId }
131810
+ * POST /addon/import-alexa/login/cancel { sessionId } → { ok: true }
131811
+ *
131812
+ * The wizard flow: POST /login/start → render a "Login to Amazon" button linking
131813
+ * to `loginUrl` (opened in a new tab) → poll /login/status until
131814
+ * `phase === 'captured'` → POST /login/commit to persist the cookie onto a new
131815
+ * or existing broker → proceed to device discovery/adoption.
131816
+ */
131817
+ /** The broker dialog posts the whole form; only the region matters here (other keys are ignored). */
131818
+ var StartBodySchema = object({ amazonDomain: _enum(AMAZON_DOMAINS).default("amazon.com") });
131628
131819
  var StatusQuerySchema = object({ sessionId: string().min(1) });
131629
131820
  var CommitBodySchema = object({
131630
131821
  sessionId: string().min(1),
@@ -132107,12 +132298,14 @@ var AlexaRemoteClient = class {
132107
132298
  if (persisted !== null) return {
132108
132299
  cookie: persisted.cookieData,
132109
132300
  proxyOnly: false,
132110
- amazonPage
132301
+ amazonPage,
132302
+ apiUserAgentPostfix: ALEXA_API_USER_AGENT_POSTFIX
132111
132303
  };
132112
132304
  if (creds.cookie !== void 0 && creds.cookie.length > 0) return {
132113
132305
  cookie: parseCookieMaterial(creds.cookie),
132114
132306
  proxyOnly: false,
132115
- amazonPage
132307
+ amazonPage,
132308
+ apiUserAgentPostfix: ALEXA_API_USER_AGENT_POSTFIX
132116
132309
  };
132117
132310
  if (creds.refreshToken !== void 0 && creds.refreshToken.length > 0) throw new AlexaAuthError("a bare refresh token is not sufficient — supply the full cookie / cookieData blob captured by the alexa-remote2 proxy login (it embeds the refresh token)");
132118
132311
  throw new AlexaAuthError("no cookie or cookieData blob configured for this account");
@@ -132728,7 +132921,8 @@ function buildAlexaBrokerProvider(deps) {
132728
132921
  addonId: ownerAddonId,
132729
132922
  kinds: [{
132730
132923
  kind: ALEXA_KIND,
132731
- label: "Alexa Import"
132924
+ label: "Alexa Import",
132925
+ signIn: { basePath: "/addon/import-alexa/login" }
132732
132926
  }]
132733
132927
  }],
132734
132928
  add: async ({ kind, name, settings }) => {