@camstack/addon-import-alexa 0.2.158 → 0.2.159

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 (20) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/{MotionZonesSettings-Z-NRG681.mjs → MotionZonesSettings-DGPV-8dv.mjs} +2 -2
  3. package/dist/{PrivacyMaskSettings-DiS2hPpi.mjs → PrivacyMaskSettings-Cn85uMbr.mjs} +4 -4
  4. package/dist/{SceneMonitorEditor-BYYK_XwY.mjs → SceneMonitorEditor-gIlEt9fl.mjs} +3 -3
  5. package/dist/_stub.js +9 -9
  6. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_import_alexa_page-B4G6E4Vs.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_import_alexa_page-n3jAYuIE.mjs} +3 -3
  7. package/dist/{_virtual_mf___mfe_internal__addon_import_alexa_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-DCV5s91A.mjs → _virtual_mf___mfe_internal__addon_import_alexa_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-BwgFX4MI.mjs} +1 -1
  8. package/dist/addon.js +602 -97
  9. package/dist/addon.mjs +602 -97
  10. package/dist/{hostInit-DWBMKrvf.mjs → hostInit-CGhFmOcB.mjs} +2 -2
  11. package/dist/{player-overlays-5MrLqX2i.mjs → player-overlays-BHCfJpas.mjs} +1 -1
  12. package/dist/remoteEntry.js +1 -1
  13. package/dist/{responsive-CsfyZVWS.mjs → responsive-Dclc7CfC.mjs} +1 -1
  14. package/dist/{scene-monitor-copy-DOuMmSwJ.mjs → scene-monitor-copy-BcAIeCGo.mjs} +1 -1
  15. package/dist/{square-BGn7yRva.mjs → square-LLOXavH6.mjs} +1 -1
  16. package/dist/{trash-2-BiBTPv8Y.mjs → trash-2-P7HFzsfr.mjs} +1 -1
  17. package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_import_alexa_page__remoteEntry_js-BniKFfAU.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_import_alexa_page__remoteEntry_js-C0zVjr31.mjs} +1 -1
  18. package/i18n/en.json +9 -2
  19. package/i18n/it.json +9 -2
  20. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -989,7 +989,7 @@ var propertyKeyTypes = /* @__PURE__*/ new Set([
989
989
  "number",
990
990
  "symbol"
991
991
  ]);
992
- function escapeRegex(str) {
992
+ function escapeRegex$1(str) {
993
993
  return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
994
994
  }
995
995
  function clone(inst, def, params) {
@@ -1719,7 +1719,7 @@ var $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (inst,
1719
1719
  });
1720
1720
  var $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
1721
1721
  $ZodCheck.init(inst, def);
1722
- const escapedRegex = escapeRegex(def.includes);
1722
+ const escapedRegex = escapeRegex$1(def.includes);
1723
1723
  const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
1724
1724
  def.pattern = pattern;
1725
1725
  inst._zod.onattach.push((inst) => {
@@ -1742,7 +1742,7 @@ var $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, d
1742
1742
  });
1743
1743
  var $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (inst, def) => {
1744
1744
  $ZodCheck.init(inst, def);
1745
- const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
1745
+ const pattern = new RegExp(`^${escapeRegex$1(def.prefix)}.*`);
1746
1746
  def.pattern ?? (def.pattern = pattern);
1747
1747
  inst._zod.onattach.push((inst) => {
1748
1748
  const bag = inst._zod.bag;
@@ -1764,7 +1764,7 @@ var $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (ins
1764
1764
  });
1765
1765
  var $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst, def) => {
1766
1766
  $ZodCheck.init(inst, def);
1767
- const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
1767
+ const pattern = new RegExp(`.*${escapeRegex$1(def.suffix)}$`);
1768
1768
  def.pattern ?? (def.pattern = pattern);
1769
1769
  inst._zod.onattach.push((inst) => {
1770
1770
  const bag = inst._zod.bag;
@@ -3000,7 +3000,7 @@ var $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
3000
3000
  const values = getEnumValues(def.entries);
3001
3001
  const valuesSet = new Set(values);
3002
3002
  inst._zod.values = valuesSet;
3003
- inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
3003
+ inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex$1(o) : o.toString()).join("|")})$`);
3004
3004
  inst._zod.parse = (payload, _ctx) => {
3005
3005
  const input = payload.value;
3006
3006
  if (valuesSet.has(input)) return payload;
@@ -3018,7 +3018,7 @@ var $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def) => {
3018
3018
  if (def.values.length === 0) throw new Error("Cannot create literal schema with no valid values");
3019
3019
  const values = new Set(def.values);
3020
3020
  inst._zod.values = values;
3021
- inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
3021
+ inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex$1(o) : o ? escapeRegex$1(o.toString()) : String(o)).join("|")})$`);
3022
3022
  inst._zod.parse = (payload, _ctx) => {
3023
3023
  const input = payload.value;
3024
3024
  if (values.has(input)) return payload;
@@ -90636,6 +90636,448 @@ DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
90636
90636
  DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
90637
90637
  DEFAULT_NATIVE_LEASE_SETTINGS.sceneBudgetMb;
90638
90638
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
90639
+ /**
90640
+ * Where an OAuth round-trip ends: the admin-ui completion route
90641
+ * (`/sso-complete`, the page every popup sign-in already lands on), with the
90642
+ * OUTCOME in the URL fragment.
90643
+ *
90644
+ * The outcome is a status plus a reason CODE from a closed list. It never
90645
+ * carries a token, a code, a client secret or a free-form error message: the
90646
+ * page words each code itself, and an unknown code reads as `unknown` rather
90647
+ * than being echoed. Fragment only, so nothing here reaches a server log.
90648
+ *
90649
+ * Pure and browser-safe.
90650
+ */
90651
+ /** The admin-ui route the hub's OAuth completions land on (relative to its mount). */
90652
+ var OAUTH_LANDING_PATH = "/sso-complete";
90653
+ /**
90654
+ * The landing URL for `outcome`. `origin` is the hub address the flow already
90655
+ * runs on (from the `local-network` palette role, never a literal); `null`
90656
+ * gives a hub-relative URL.
90657
+ */
90658
+ function oauthLandingUrl(origin, outcome) {
90659
+ const params = new URLSearchParams({
90660
+ return: "oauth",
90661
+ status: outcome.status
90662
+ });
90663
+ if (outcome.addonId !== void 0) params.set("addon", outcome.addonId);
90664
+ if (outcome.brokerId !== void 0) params.set("broker", outcome.brokerId);
90665
+ if (outcome.integration !== void 0) params.set("integration", outcome.integration);
90666
+ if (outcome.status === "error") params.set("reason", outcome.reason ?? "unknown");
90667
+ if (outcome.action === "disconnect") params.set("action", "disconnect");
90668
+ return `${origin === null ? "" : origin.replace(/\/+$/, "")}${OAUTH_LANDING_PATH}#${params.toString()}`;
90669
+ }
90670
+ var LOOPBACK_HOSTS = new Set([
90671
+ "127.0.0.1",
90672
+ "localhost",
90673
+ "[::1]"
90674
+ ]);
90675
+ function hostWithoutPort(host) {
90676
+ if (host.startsWith("[")) return host.slice(0, host.indexOf("]") + 1);
90677
+ const colon = host.indexOf(":");
90678
+ return colon === -1 ? host : host.slice(0, colon);
90679
+ }
90680
+ function isLoopbackHost(host) {
90681
+ return LOOPBACK_HOSTS.has(hostWithoutPort(host.toLowerCase()));
90682
+ }
90683
+ /** An allow-list entry is valid when it is a bare host[:port] and `http` only targets loopback. */
90684
+ function isValidUpstream(upstream) {
90685
+ if (upstream.host.length === 0 || !/^[a-z0-9.[\]:-]+$/.test(upstream.host)) return false;
90686
+ return upstream.scheme === "https" || isLoopbackHost(upstream.host);
90687
+ }
90688
+ function findUpstream(route, host) {
90689
+ const wanted = host.toLowerCase();
90690
+ return route.upstreams.find((upstream) => upstream.host === wanted);
90691
+ }
90692
+ /** `<basePath>/<host><pathname><search>` — what the browser is sent to. */
90693
+ function proxyPathFor(route, host, pathname, search = "") {
90694
+ return `${route.basePath}/${host}${pathname.startsWith("/") ? pathname : `/${pathname}`}${search}`;
90695
+ }
90696
+ /** Split `/<attemptId>/<host>/<rest…>[?query]` (the data-plane view of a request). */
90697
+ function parseProxyPath(rawUrl) {
90698
+ const queryAt = rawUrl.indexOf("?");
90699
+ const path = queryAt === -1 ? rawUrl : rawUrl.slice(0, queryAt);
90700
+ const search = queryAt === -1 ? "" : rawUrl.slice(queryAt);
90701
+ const match = /^\/([A-Za-z0-9_-]{8,128})\/([^/]+)(\/.*)?$/.exec(path);
90702
+ if (match === null) return null;
90703
+ const attemptId = match[1];
90704
+ const host = match[2];
90705
+ if (attemptId === void 0 || host === void 0) return null;
90706
+ return {
90707
+ attemptId,
90708
+ host: host.toLowerCase(),
90709
+ pathname: match[3] ?? "/",
90710
+ search
90711
+ };
90712
+ }
90713
+ /** The vendor URL a proxied request targets, or null when the host would not stay `host`. */
90714
+ function upstreamUrlFor(upstream, parsed) {
90715
+ try {
90716
+ const url = new URL(`${upstream.scheme}://${upstream.host}${parsed.pathname}${parsed.search}`);
90717
+ return url.host.toLowerCase() === upstream.host ? url : null;
90718
+ } catch {
90719
+ return null;
90720
+ }
90721
+ }
90722
+ function escapeRegex(value) {
90723
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
90724
+ }
90725
+ /** A Location (or any URL value) to a vendor host becomes a proxy path; anything else is unchanged. */
90726
+ function rewriteLocation(location, currentUpstream, route) {
90727
+ let resolved;
90728
+ try {
90729
+ resolved = new URL(location, `${currentUpstream.scheme}://${currentUpstream.host}/`);
90730
+ } catch {
90731
+ return location;
90732
+ }
90733
+ if (resolved.protocol !== "https:" && resolved.protocol !== "http:") return location;
90734
+ const target = findUpstream(route, resolved.host);
90735
+ if (target === void 0) return location;
90736
+ return `${proxyPathFor(route, target.host, resolved.pathname, resolved.search)}${resolved.hash}`;
90737
+ }
90738
+ /** Characters that may precede a URL that STARTS a value (never `=`, `?`, `&`, `%3D`). */
90739
+ var VALUE_START = String.raw`(?<=^|["'(\s>,\[{])`;
90740
+ /**
90741
+ * Rewrite vendor URLs in a text body: absolute (`https://host/…`), protocol-relative
90742
+ * (`//host/…`) and JSON-escaped (`https:\/\/host\/…`) when they start a value; and, in
90743
+ * HTML/CSS, root-relative references (`href="/x"`, `url(/x)`) which would otherwise
90744
+ * escape the proxy mount and land on the hub.
90745
+ */
90746
+ function rewriteBody(body, kind, currentUpstream, route) {
90747
+ let out = body;
90748
+ for (const upstream of route.upstreams) {
90749
+ const host = escapeRegex(upstream.host);
90750
+ const plain = new RegExp(`${VALUE_START}(?:https?:)?//${host}(?=[/"'?#\\s)\\]},<]|$)`, "g");
90751
+ out = out.replace(plain, `${route.basePath}/${upstream.host}`);
90752
+ const escapedBase = `${route.basePath}/${upstream.host}`.replace(/\//g, "\\/");
90753
+ const escaped = new RegExp(`${VALUE_START}(?:https?:)?\\\\/\\\\/${host}(?=\\\\/|["'?#\\s)\\]},<]|$)`, "g");
90754
+ out = out.replace(escaped, escapedBase);
90755
+ }
90756
+ const current = `${route.basePath}/${currentUpstream.host}/`;
90757
+ const notMounted = `(?!/)(?!${escapeRegex(route.basePath.slice(1))}/)`;
90758
+ if (kind === "html") {
90759
+ const attribute = String.raw`(\b(?:href|src|action|formaction|poster|data-href|data-src)\s*=\s*["'])/`;
90760
+ out = out.replace(new RegExp(`${attribute}${notMounted}`, "gi"), `$1${current}`);
90761
+ }
90762
+ if (kind === "html" || kind === "css") {
90763
+ const cssUrl = String.raw`(url\(\s*["']?)/`;
90764
+ out = out.replace(new RegExp(`${cssUrl}${notMounted}`, "gi"), `$1${current}`);
90765
+ }
90766
+ return out;
90767
+ }
90768
+ /**
90769
+ * A vendor `Set-Cookie` for the browser: no `Domain` (the cookie belongs to the hub
90770
+ * origin), `Path` narrowed to this attempt's prefix, `Secure` kept (the hub is HTTPS).
90771
+ */
90772
+ function rewriteSetCookie(cookie, route) {
90773
+ const kept = cookie.split(";").map((part) => part.trim()).filter((part, index) => {
90774
+ if (index === 0) return true;
90775
+ const name = part.split("=")[0]?.trim().toLowerCase() ?? "";
90776
+ return name !== "domain" && name !== "path";
90777
+ });
90778
+ kept.push(`Path=${route.basePath}/`);
90779
+ return kept.join("; ");
90780
+ }
90781
+ /**
90782
+ * A browser `Referer` that points into this proxy, turned back into the vendor URL it
90783
+ * stands for. A Referer that is not ours is dropped (null): it names the hub.
90784
+ */
90785
+ function rewriteReferer(referer, route) {
90786
+ let url;
90787
+ try {
90788
+ url = new URL(referer, "http://hub.invalid");
90789
+ } catch {
90790
+ return null;
90791
+ }
90792
+ if (!url.pathname.startsWith(`${route.basePath}/`)) return null;
90793
+ const rest = /^\/([^/]+)(\/.*)?$/.exec(url.pathname.slice(route.basePath.length));
90794
+ const host = rest?.[1]?.toLowerCase();
90795
+ if (host === void 0) return null;
90796
+ const upstream = findUpstream(route, host);
90797
+ if (upstream === void 0) return null;
90798
+ return `${upstream.scheme}://${upstream.host}${rest?.[2] ?? "/"}${url.search}`;
90799
+ }
90800
+ /** Cookies the browser holds for the hub itself must never reach a vendor. */
90801
+ function filterForwardedCookies(cookieHeader) {
90802
+ return cookieHeader.split(";").map((part) => part.trim()).filter((part) => part.length > 0 && !part.toLowerCase().startsWith("camstack_")).join("; ");
90803
+ }
90804
+ var MAX_REQUEST_BODY_BYTES = 2 * 1024 * 1024;
90805
+ var MAX_TEXT_BODY_BYTES = 4 * 1024 * 1024;
90806
+ /** Request headers that are never forwarded to the vendor. */
90807
+ var DROP_REQUEST_HEADERS = new Set([
90808
+ "host",
90809
+ "connection",
90810
+ "keep-alive",
90811
+ "proxy-authorization",
90812
+ "proxy-connection",
90813
+ "te",
90814
+ "trailer",
90815
+ "transfer-encoding",
90816
+ "upgrade",
90817
+ "content-length",
90818
+ "accept-encoding",
90819
+ "authorization",
90820
+ "cookie",
90821
+ "origin",
90822
+ "referer",
90823
+ "x-camstack-dataplane-secret",
90824
+ "x-forwarded-for",
90825
+ "x-forwarded-host",
90826
+ "x-forwarded-proto",
90827
+ "x-forwarded-prefix",
90828
+ "x-real-ip",
90829
+ "forwarded"
90830
+ ]);
90831
+ /**
90832
+ * Response headers dropped: framing/CSP/HSTS that break a page under another origin, and
90833
+ * the ones that no longer describe the (decoded, possibly rewritten) body.
90834
+ */
90835
+ var DROP_RESPONSE_HEADERS = new Set([
90836
+ "content-security-policy",
90837
+ "content-security-policy-report-only",
90838
+ "x-frame-options",
90839
+ "strict-transport-security",
90840
+ "public-key-pins",
90841
+ "report-to",
90842
+ "nel",
90843
+ "content-encoding",
90844
+ "content-length",
90845
+ "transfer-encoding",
90846
+ "connection",
90847
+ "keep-alive",
90848
+ "set-cookie",
90849
+ "location"
90850
+ ]);
90851
+ function bodyKindOf(contentType) {
90852
+ const type = contentType.toLowerCase();
90853
+ if (type.includes("text/html") || type.includes("application/xhtml")) return "html";
90854
+ if (type.includes("text/css")) return "css";
90855
+ if (type.startsWith("text/") || type.includes("javascript") || type.includes("json") || type.includes("xml")) return "other";
90856
+ return null;
90857
+ }
90858
+ function firstHeader(value) {
90859
+ return Array.isArray(value) ? value[0] : value;
90860
+ }
90861
+ async function readRequestBody(req) {
90862
+ const chunks = [];
90863
+ let size = 0;
90864
+ for await (const chunk of req) {
90865
+ const buf = typeof chunk === "string" ? Buffer.from(chunk) : Buffer.from(chunk);
90866
+ size += buf.length;
90867
+ if (size > MAX_REQUEST_BODY_BYTES) return "too-large";
90868
+ chunks.push(buf);
90869
+ }
90870
+ return Buffer.concat(chunks);
90871
+ }
90872
+ function sendPlain(res, status, text) {
90873
+ res.writeHead(status, {
90874
+ "content-type": "text/plain; charset=utf-8",
90875
+ "cache-control": "no-store"
90876
+ });
90877
+ res.end(text);
90878
+ }
90879
+ var VendorLoginProxy = class {
90880
+ #addonId;
90881
+ #prefix;
90882
+ #logger;
90883
+ #now;
90884
+ #fetch;
90885
+ #attempts = /* @__PURE__ */ new Map();
90886
+ constructor(options) {
90887
+ this.#addonId = options.addonId;
90888
+ this.#prefix = options.prefix;
90889
+ this.#logger = options.logger;
90890
+ this.#now = options.now ?? (() => Date.now());
90891
+ this.#fetch = options.fetchFn ?? globalThis.fetch.bind(globalThis);
90892
+ }
90893
+ /** The `DataPlaneHandler` to pass to `ctx.dataPlane.serve({ prefix, access: 'admin', … })`. */
90894
+ handler = (req, res) => this.#handle(req, res);
90895
+ /** Register an attempt. A one-shot capability: refused hosts are rejected up front. */
90896
+ open(spec) {
90897
+ for (const upstream of spec.upstreams) if (!isValidUpstream(upstream)) throw new Error(`vendor login proxy: upstream ${upstream.host} is not allowed`);
90898
+ this.#attempts.set(spec.attemptId, {
90899
+ expiresAtMs: spec.expiresAtMs,
90900
+ upstreams: spec.upstreams,
90901
+ evaluate: async (view) => {
90902
+ const verdict = await spec.terminal(view);
90903
+ if (verdict.kind === "continue") return verdict;
90904
+ return {
90905
+ kind: "done",
90906
+ landing: await spec.onDone(verdict.payload)
90907
+ };
90908
+ }
90909
+ });
90910
+ }
90911
+ close(attemptId) {
90912
+ this.#attempts.delete(attemptId);
90913
+ }
90914
+ isOpen(attemptId) {
90915
+ const attempt = this.#attempts.get(attemptId);
90916
+ return attempt !== void 0 && this.#now() <= attempt.expiresAtMs;
90917
+ }
90918
+ /**
90919
+ * The hub-relative path that opens `vendorUrl` through the proxy for this attempt:
90920
+ * the URL the browser is sent to. Null when the host is not in the attempt's list.
90921
+ */
90922
+ entryPath(attemptId, vendorUrl) {
90923
+ const attempt = this.#attempts.get(attemptId);
90924
+ if (attempt === void 0) return null;
90925
+ const url = new URL(vendorUrl);
90926
+ if (findUpstream({
90927
+ basePath: "",
90928
+ upstreams: attempt.upstreams
90929
+ }, url.host) === void 0) return null;
90930
+ return `/addon/${this.#addonId}/${this.#prefix}/${attemptId}/${url.host}${url.pathname}${url.search}`;
90931
+ }
90932
+ #routeFor(attemptId, attempt, forwardedPrefix) {
90933
+ return {
90934
+ basePath: `${forwardedPrefix}/addon/${this.#addonId}/${this.#prefix}/${attemptId}`,
90935
+ upstreams: attempt.upstreams
90936
+ };
90937
+ }
90938
+ async #handle(req, res) {
90939
+ try {
90940
+ await this.#serve(req, res);
90941
+ } catch (err) {
90942
+ this.#logger.warn("vendor login proxy: request failed", { meta: {
90943
+ addonId: this.#addonId,
90944
+ error: err instanceof Error ? err.name : "unknown"
90945
+ } });
90946
+ if (!res.headersSent) sendPlain(res, 502, "The sign-in page could not be reached.");
90947
+ else res.end();
90948
+ }
90949
+ }
90950
+ async #serve(req, res) {
90951
+ const parsed = parseProxyPath(req.url ?? "/");
90952
+ if (parsed === null) {
90953
+ sendPlain(res, 404, "Not found");
90954
+ return;
90955
+ }
90956
+ const forwardedPrefix = (firstHeader(req.headers["x-forwarded-prefix"]) ?? "").replace(/\/+$/, "");
90957
+ const attempt = this.#attempts.get(parsed.attemptId);
90958
+ if (attempt === void 0 || this.#now() > attempt.expiresAtMs) {
90959
+ if (attempt !== void 0) this.#attempts.delete(parsed.attemptId);
90960
+ this.#logger.info("vendor login proxy: attempt refused", { meta: {
90961
+ addonId: this.#addonId,
90962
+ reason: attempt === void 0 ? "missing" : "expired"
90963
+ } });
90964
+ this.#redirect(res, forwardedPrefix, {
90965
+ status: "error",
90966
+ addonId: this.#addonId,
90967
+ reason: "invalid_state"
90968
+ });
90969
+ return;
90970
+ }
90971
+ const route = this.#routeFor(parsed.attemptId, attempt, forwardedPrefix);
90972
+ const upstream = findUpstream(route, parsed.host);
90973
+ const target = upstream === void 0 ? null : upstreamUrlFor(upstream, parsed);
90974
+ if (upstream === void 0 || target === null) {
90975
+ this.#logger.warn("vendor login proxy: host refused", { meta: {
90976
+ addonId: this.#addonId,
90977
+ host: parsed.host
90978
+ } });
90979
+ sendPlain(res, 404, "Not found");
90980
+ return;
90981
+ }
90982
+ const method = (req.method ?? "GET").toUpperCase();
90983
+ let body;
90984
+ if (method !== "GET" && method !== "HEAD") {
90985
+ const read = await readRequestBody(req);
90986
+ if (read === "too-large") {
90987
+ sendPlain(res, 413, "Request too large");
90988
+ return;
90989
+ }
90990
+ body = read;
90991
+ }
90992
+ const headers = this.#requestHeaders(req, route, upstream);
90993
+ const upstreamRes = await this.#fetch(target, {
90994
+ method,
90995
+ headers,
90996
+ redirect: "manual",
90997
+ ...body !== void 0 && body.length > 0 ? { body: new Uint8Array(body) } : {}
90998
+ });
90999
+ const location = upstreamRes.headers.get("location");
91000
+ const setCookies = upstreamRes.headers.getSetCookie();
91001
+ const kind = bodyKindOf(upstreamRes.headers.get("content-type") ?? "");
91002
+ const declaredLength = Number(upstreamRes.headers.get("content-length") ?? "0");
91003
+ const text = kind !== null && !(declaredLength > MAX_TEXT_BODY_BYTES) && method !== "HEAD" ? await upstreamRes.text() : null;
91004
+ this.#logger.debug("vendor login proxy: upstream answered", { meta: {
91005
+ addonId: this.#addonId,
91006
+ host: upstream.host,
91007
+ status: upstreamRes.status,
91008
+ method
91009
+ } });
91010
+ const settled = await attempt.evaluate({
91011
+ status: upstreamRes.status,
91012
+ url: target.toString(),
91013
+ location,
91014
+ setCookies,
91015
+ bodyText: text
91016
+ });
91017
+ if (settled.kind === "done") {
91018
+ this.#attempts.delete(parsed.attemptId);
91019
+ this.#logger.info("vendor login proxy: sign-in finished", { meta: {
91020
+ addonId: this.#addonId,
91021
+ status: settled.landing.status
91022
+ } });
91023
+ this.#redirect(res, forwardedPrefix, settled.landing);
91024
+ return;
91025
+ }
91026
+ const out = {};
91027
+ upstreamRes.headers.forEach((value, name) => {
91028
+ if (!DROP_RESPONSE_HEADERS.has(name.toLowerCase())) out[name] = value;
91029
+ });
91030
+ if (setCookies.length > 0) out["set-cookie"] = setCookies.map((c) => rewriteSetCookie(c, route));
91031
+ if (location !== null) out["location"] = rewriteLocation(location, upstream, route);
91032
+ out["cache-control"] = "no-store";
91033
+ if (text !== null && kind !== null) {
91034
+ const rewritten = rewriteBody(text, kind, upstream, route);
91035
+ res.writeHead(upstreamRes.status, out);
91036
+ res.end(rewritten);
91037
+ return;
91038
+ }
91039
+ res.writeHead(upstreamRes.status, out);
91040
+ await this.#pipeBody(upstreamRes, res);
91041
+ }
91042
+ #requestHeaders(req, route, upstream) {
91043
+ const headers = {};
91044
+ for (const [name, value] of Object.entries(req.headers)) {
91045
+ const lower = name.toLowerCase();
91046
+ if (DROP_REQUEST_HEADERS.has(lower) || value === void 0) continue;
91047
+ headers[lower] = Array.isArray(value) ? value.join(", ") : value;
91048
+ }
91049
+ const cookie = filterForwardedCookies(firstHeader(req.headers["cookie"]) ?? "");
91050
+ if (cookie.length > 0) headers["cookie"] = cookie;
91051
+ if (req.headers["origin"] !== void 0) headers["origin"] = `${upstream.scheme}://${upstream.host}`;
91052
+ const referer = firstHeader(req.headers["referer"]);
91053
+ if (referer !== void 0) {
91054
+ const back = rewriteReferer(referer, route);
91055
+ if (back !== null) headers["referer"] = back;
91056
+ }
91057
+ return headers;
91058
+ }
91059
+ async #pipeBody(upstreamRes, res) {
91060
+ if (upstreamRes.body === null) {
91061
+ res.end();
91062
+ return;
91063
+ }
91064
+ for await (const chunk of upstreamRes.body) {
91065
+ if (!res.write(chunk)) await new Promise((resolve) => {
91066
+ res.once("drain", resolve);
91067
+ res.once("close", resolve);
91068
+ });
91069
+ if (res.destroyed) return;
91070
+ }
91071
+ res.end();
91072
+ }
91073
+ #redirect(res, forwardedPrefix, outcome) {
91074
+ res.writeHead(302, {
91075
+ location: `${forwardedPrefix}${oauthLandingUrl(null, outcome)}`,
91076
+ "cache-control": "no-store"
91077
+ });
91078
+ res.end();
91079
+ }
91080
+ };
90639
91081
  var MB = 1024 * 1024;
90640
91082
  1024 * MB, 3072 * MB;
90641
91083
  //#endregion
@@ -90687,18 +91129,12 @@ var AlexaBrokerEntrySchema = object({
90687
91129
  });
90688
91130
  /**
90689
91131
  * Interactive proxy-login settings (addon-global, not per-broker). alexa-remote2
90690
- * spins a local reverse-proxy to Amazon's login page on `proxyHost:proxyPort`;
90691
- * the operator opens that URL and logs in. `proxyHost` MUST be the host:port the
90692
- * operator's browser uses (alexa-cookie2 rewrites Amazon URLs to absolute
90693
- * `http://<proxyHost>:<proxyPort>/...`), so it is a directly-reachable host —
90694
- * the hub's LAN IP/hostname — NOT behind the hub's HTTPS data-plane mount.
90695
- * Empty `proxyHost` ⇒ the first LAN address of the hub's `appConnections`
90696
- * role (local-network palette) at login-start time.
91132
+ * spins a local reverse-proxy to Amazon's login page on `127.0.0.1:proxyPort`; the
91133
+ * operator never reaches it directly — the hub's login proxy (D955) opens it at
91134
+ * `/addon/import-alexa/login/…` under the hub's own HTTPS origin. The port only has to
91135
+ * be free on the hub's loopback.
90697
91136
  */
90698
- var alexaProxyLoginSchema = object({
90699
- proxyHost: string().default("").describe("Host/IP the browser uses to reach the login proxy (blank = the hub LAN address)"),
90700
- proxyPort: preprocess((v) => v === "" || v === null ? void 0 : v, number().int().min(1).max(65535).default(3456)).describe("Port the local Amazon-login proxy listens on (must be reachable)")
90701
- });
91137
+ var alexaProxyLoginSchema = object({ proxyPort: preprocess((v) => v === "" || v === null ? void 0 : v, number().int().min(1).max(65535).default(3456)).describe("Loopback port the local Amazon-login proxy listens on (never exposed)") });
90702
91138
  /**
90703
91139
  * Echo speech settings. Speech signs in as an import broker, so the targets
90704
91140
  * are what lives here. `email`, `password`, `region` and `session` are the OLD
@@ -90745,10 +91181,7 @@ function readSpeakSettings(config) {
90745
91181
  /** Top-level addon config — broker entries + the proxy-login settings. */
90746
91182
  var alexaAddonConfigSchema = object({
90747
91183
  brokers: array(AlexaBrokerEntrySchema).default([]),
90748
- proxyLogin: alexaProxyLoginSchema.default({
90749
- proxyHost: "",
90750
- proxyPort: 3456
90751
- }),
91184
+ proxyLogin: alexaProxyLoginSchema.default({ proxyPort: 3456 }),
90752
91185
  speak: alexaSpeakSettingsSchema.default({
90753
91186
  email: "",
90754
91187
  password: "",
@@ -132304,6 +132737,31 @@ var ALEXA_API_USER_AGENT_POSTFIX = `AlexaRemote/${{
132304
132737
  //#endregion
132305
132738
  //#region src/alexa-proxy-login.ts
132306
132739
  /**
132740
+ * INTERACTIVE Amazon login via `alexa-remote2`'s built-in proxy auth mode, behind the
132741
+ * hub's vendor login proxy (D955).
132742
+ *
132743
+ * alexa-remote2 (through `alexa-cookie2`) spins a local Express reverse-proxy to
132744
+ * Amazon's real login page and captures the resulting cookie + the richer
132745
+ * `cookieData` registration blob (it embeds the refresh token, so the session can
132746
+ * auto-refresh forever). That listener is bound to LOOPBACK only
132747
+ * (`proxyOwnIp` = `proxyListenBind` = 127.0.0.1): nothing outside this process's host can
132748
+ * reach it. The operator's browser reaches it through the hub's data plane instead
132749
+ * (`VendorLoginProxy`, `/addon/<id>/login/<attempt>/127.0.0.1:<port>/…`), which is
132750
+ * HTTPS under the same origin as the admin page. alexa-cookie2 keeps doing the Amazon
132751
+ * specific work (login cookies, device registration, the `/ax/claim` and CSRF steps)
132752
+ * and the hub proxy only rewrites the loopback-origin URLs it emits into the mount.
132753
+ *
132754
+ * Why not the second proxy replacing alexa-cookie2's: the capture needs the PKCE
132755
+ * verifier, the device id, the initial cookies and the app registration alexa-cookie2
132756
+ * already performs; re-implementing them would add JS-built-URL failure modes.
132757
+ *
132758
+ * The captured `cookieData` is handed to {@link AlexaProxyLoginSessionOptions.onCookie}
132759
+ * — the addon persists it on the broker entry, exactly where a pasted cookie
132760
+ * goes, so the rest of the addon (broker / poll / adoption) is unchanged.
132761
+ */
132762
+ /** The only address the alexa-cookie2 listener binds and advertises. */
132763
+ var ALEXA_PROXY_LOOPBACK_HOST = "127.0.0.1";
132764
+ /**
132307
132765
  * A single interactive proxy-login attempt. One instance = one Amazon login.
132308
132766
  * Construct → {@link start} → poll {@link getStatus} → on `captured` the
132309
132767
  * `onCookie` callback has fired with the blob → {@link dispose}.
@@ -132317,13 +132775,37 @@ var AlexaProxyLoginSession = class {
132317
132775
  #startedAt = Date.now();
132318
132776
  #capturedAt = null;
132319
132777
  #captured = false;
132778
+ #waiters = /* @__PURE__ */ new Set();
132320
132779
  constructor(opts) {
132321
132780
  this.#opts = opts;
132322
132781
  this.#logger = opts.logger;
132323
132782
  }
132324
- /** `http://<proxyOwnIp>:<proxyPort>/` — what the operator opens. */
132783
+ /** What the operator opens: the hub-relative entry of the login proxy. */
132325
132784
  get loginUrl() {
132326
- return `http://${this.#opts.proxyOwnIp}:${this.#opts.proxyPort}/`;
132785
+ return this.#opts.loginUrl;
132786
+ }
132787
+ /** `host:port` of the loopback listener — the one upstream the hub proxy may reach. */
132788
+ get upstreamHost() {
132789
+ return `${ALEXA_PROXY_LOOPBACK_HOST}:${this.#opts.proxyPort}`;
132790
+ }
132791
+ /**
132792
+ * Resolves true once the cookie material is in hand, false after `timeoutMs`.
132793
+ * The Amazon page ends on `/cookie-success` BEFORE alexa-cookie2 finished registering
132794
+ * the app, so the hub waits here before it sends the browser to the result page.
132795
+ */
132796
+ whenCaptured(timeoutMs) {
132797
+ if (this.#captured) return Promise.resolve(true);
132798
+ return new Promise((resolve) => {
132799
+ const timer = setTimeout(() => {
132800
+ this.#waiters.delete(settle);
132801
+ resolve(false);
132802
+ }, timeoutMs);
132803
+ const settle = () => {
132804
+ clearTimeout(timer);
132805
+ resolve(true);
132806
+ };
132807
+ this.#waiters.add(settle);
132808
+ });
132327
132809
  }
132328
132810
  getStatus() {
132329
132811
  return {
@@ -132355,7 +132837,8 @@ var AlexaProxyLoginSession = class {
132355
132837
  remote.on("cookie", () => this.#onCookieEvent(remote));
132356
132838
  remote.init({
132357
132839
  proxyOnly: true,
132358
- proxyOwnIp: this.#opts.proxyOwnIp,
132840
+ proxyOwnIp: ALEXA_PROXY_LOOPBACK_HOST,
132841
+ proxyListenBind: ALEXA_PROXY_LOOPBACK_HOST,
132359
132842
  proxyPort: this.#opts.proxyPort,
132360
132843
  proxyLogLevel: "warn",
132361
132844
  amazonPage,
@@ -132401,6 +132884,8 @@ var AlexaProxyLoginSession = class {
132401
132884
  this.#captured = true;
132402
132885
  this.#capturedAt = Date.now();
132403
132886
  this.#phase = "captured";
132887
+ for (const settle of this.#waiters) settle();
132888
+ this.#waiters.clear();
132404
132889
  this.#logger.info("alexa proxy-login: cookie captured", { meta: { sessionId: this.#opts.sessionId } });
132405
132890
  try {
132406
132891
  this.#opts.onCookie(this.#opts.sessionId, {
@@ -132421,10 +132906,7 @@ var AlexaProxyLoginSession = class {
132421
132906
  if (isProxyReadyError(err)) {
132422
132907
  if (this.#phase === "starting") {
132423
132908
  this.#phase = "awaiting-login";
132424
- this.#logger.info("alexa proxy-login: proxy ready — awaiting Amazon login", { meta: {
132425
- sessionId: this.#opts.sessionId,
132426
- loginUrl: this.loginUrl
132427
- } });
132909
+ this.#logger.info("alexa proxy-login: proxy ready — awaiting Amazon login", { meta: { sessionId: this.#opts.sessionId } });
132428
132910
  }
132429
132911
  return;
132430
132912
  }
@@ -132482,62 +132964,44 @@ function isStringOrObject(value) {
132482
132964
  return typeof value === "string" || typeof value === "object" && value !== null;
132483
132965
  }
132484
132966
  //#endregion
132485
- //#region src/alexa-proxy-host.ts
132486
- /** Typed refusal: names WHY no proxy host could be chosen. */
132487
- var AlexaProxyHostError = class extends Error {
132488
- reason;
132489
- constructor(reason, message, options) {
132490
- super(message, options);
132491
- this.name = "AlexaProxyHostError";
132492
- this.reason = reason;
132493
- }
132494
- };
132495
- var PRIVATE_IPV4 = /^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.|169\.254\.)/;
132496
- var IPV4_LITERAL = /^\d{1,3}(\.\d{1,3}){3}$/;
132497
- /** A host a browser on the hub's network reaches directly: private IPv4, `.local`, or a bare name. */
132498
- function isLanHost(host) {
132499
- if (host.length === 0) return false;
132500
- if (IPV4_LITERAL.test(host)) return PRIVATE_IPV4.test(host);
132501
- if (host.includes(":")) return false;
132502
- return host.endsWith(".local") || !host.includes(".");
132503
- }
132504
- function lanHostOf(address) {
132967
+ //#region src/alexa-proxy-login-manager.ts
132968
+ /** The data-plane prefix the hub login proxy is served on. */
132969
+ var ALEXA_LOGIN_PROXY_PREFIX = "login";
132970
+ /** The addon id the result page names to return to. */
132971
+ var ADDON_ID = "import-alexa";
132972
+ /** An attempt lives as long as a sign-in attempt does elsewhere (10 min). */
132973
+ var ATTEMPT_TTL_MS = 600 * 1e3;
132974
+ /** How long the browser waits on the Amazon page for alexa-cookie2 to finish registering. */
132975
+ var CAPTURE_WAIT_MS = 6e4;
132976
+ /**
132977
+ * Terminal condition: alexa-cookie2 turns Amazon's final redirect into a 302 to its own
132978
+ * `/cookie-success` page once it holds the login cookie. Matching on the path of the raw
132979
+ * `Location` keeps this independent of the page's HTML.
132980
+ */
132981
+ function cookieSuccessTerminal(view) {
132982
+ if (view.location === null) return { kind: "continue" };
132505
132983
  try {
132506
- const host = new URL(address).hostname;
132507
- return isLanHost(host) && host !== "localhost" ? host : null;
132984
+ return new URL(view.location, `http://127.0.0.1`).pathname === "/cookie-success" ? {
132985
+ kind: "done",
132986
+ payload: true
132987
+ } : { kind: "continue" };
132508
132988
  } catch {
132509
- return null;
132510
- }
132511
- }
132512
- async function resolveProxyHost(input) {
132513
- const override = input.override.trim();
132514
- if (override.length > 0) return override;
132515
- let addresses;
132516
- try {
132517
- addresses = await input.readAppConnections();
132518
- } catch (err) {
132519
- input.logger.warn("alexa proxy-login: hub addresses unavailable from local-network", { meta: { error: errMsg(err) } });
132520
- throw new AlexaProxyHostError("palette-unavailable", "alexa proxy-login: the hub address list is unavailable — set proxyHost in settings", { cause: err });
132989
+ return { kind: "continue" };
132521
132990
  }
132522
- for (const address of addresses) {
132523
- const host = lanHostOf(address);
132524
- if (host !== null) return host;
132525
- }
132526
- input.logger.warn("alexa proxy-login: no LAN address among the hub appConnections", { meta: { addresses: [...addresses] } });
132527
- throw new AlexaProxyHostError("no-lan-address", "alexa proxy-login: the hub has no LAN address the browser can open directly — set proxyHost in settings");
132528
132991
  }
132529
- //#endregion
132530
- //#region src/alexa-proxy-login-manager.ts
132531
132992
  var AlexaProxyLoginManager = class {
132532
132993
  #logger;
132533
132994
  #getProxyConfig;
132534
- #getAppConnectionAddresses;
132995
+ #getLoginProxy;
132996
+ #captureWaitMs;
132535
132997
  #session = null;
132536
132998
  #captured = /* @__PURE__ */ new Map();
132999
+ #attemptCloser = null;
132537
133000
  constructor(deps) {
132538
133001
  this.#logger = deps.logger;
132539
133002
  this.#getProxyConfig = deps.getProxyConfig;
132540
- this.#getAppConnectionAddresses = deps.getAppConnectionAddresses;
133003
+ this.#getLoginProxy = deps.getLoginProxy;
133004
+ this.#captureWaitMs = deps.captureWaitMs ?? CAPTURE_WAIT_MS;
132541
133005
  }
132542
133006
  /**
132543
133007
  * Start a fresh proxy-login. Cancels any in-flight session first (single
@@ -132545,18 +133009,41 @@ var AlexaProxyLoginManager = class {
132545
133009
  */
132546
133010
  async start(amazonDomain) {
132547
133011
  await this.cancelActive();
132548
- const { proxyHost, proxyPort } = this.#getProxyConfig();
132549
- const host = await resolveProxyHost({
132550
- override: proxyHost,
132551
- readAppConnections: this.#getAppConnectionAddresses,
132552
- logger: this.#logger
132553
- });
133012
+ const loginProxy = this.#getLoginProxy();
133013
+ if (loginProxy === null) throw new Error("alexa proxy-login: the hub login proxy is not available on this hub");
133014
+ const { proxyPort } = this.#getProxyConfig();
133015
+ const upstreamHost = `${ALEXA_PROXY_LOOPBACK_HOST}:${proxyPort}`;
132554
133016
  const sessionId = randomBytes(9).toString("base64url");
133017
+ loginProxy.open({
133018
+ attemptId: sessionId,
133019
+ expiresAtMs: Date.now() + ATTEMPT_TTL_MS,
133020
+ upstreams: [{
133021
+ host: upstreamHost,
133022
+ scheme: "http"
133023
+ }],
133024
+ terminal: cookieSuccessTerminal,
133025
+ onDone: async () => {
133026
+ return await this.#session?.whenCaptured(this.#captureWaitMs) === true ? {
133027
+ status: "success",
133028
+ addonId: ADDON_ID
133029
+ } : {
133030
+ status: "error",
133031
+ addonId: ADDON_ID,
133032
+ reason: "exchange_failed"
133033
+ };
133034
+ }
133035
+ });
133036
+ const loginUrl = loginProxy.entryPath(sessionId, `http://${upstreamHost}/`);
133037
+ if (loginUrl === null) {
133038
+ loginProxy.close(sessionId);
133039
+ throw new Error("alexa proxy-login: the hub login proxy refused the login address");
133040
+ }
133041
+ this.#attemptCloser = () => loginProxy.close(sessionId);
132555
133042
  const session = new AlexaProxyLoginSession({
132556
133043
  sessionId,
132557
133044
  amazonDomain,
132558
- proxyOwnIp: host,
132559
133045
  proxyPort,
133046
+ loginUrl,
132560
133047
  logger: this.#logger,
132561
133048
  onCookie: (id, captured) => {
132562
133049
  this.#captured.set(id, captured);
@@ -132567,6 +133054,7 @@ var AlexaProxyLoginManager = class {
132567
133054
  await session.start();
132568
133055
  } catch (err) {
132569
133056
  this.#session = null;
133057
+ this.#closeAttempt();
132570
133058
  await session.dispose();
132571
133059
  throw new Error(`alexa proxy-login: failed to start proxy — ${errMsg(err)}`, { cause: err });
132572
133060
  }
@@ -132600,10 +133088,16 @@ var AlexaProxyLoginManager = class {
132600
133088
  await this.cancelActive();
132601
133089
  this.#captured.delete(sessionId);
132602
133090
  }
133091
+ #closeAttempt() {
133092
+ const close = this.#attemptCloser;
133093
+ this.#attemptCloser = null;
133094
+ close?.();
133095
+ }
132603
133096
  /** Cancel + dispose whatever session is currently active. */
132604
133097
  async cancelActive() {
132605
133098
  const session = this.#session;
132606
133099
  this.#session = null;
133100
+ this.#closeAttempt();
132607
133101
  if (session === null) return;
132608
133102
  try {
132609
133103
  await session.cancel();
@@ -136218,10 +136712,7 @@ var SPEAK_PAGE = {
136218
136712
  /** Default config — a fresh install starts with no accounts. */
136219
136713
  var DEFAULTS = {
136220
136714
  brokers: [],
136221
- proxyLogin: {
136222
- proxyHost: "",
136223
- proxyPort: 3456
136224
- },
136715
+ proxyLogin: { proxyPort: 3456 },
136225
136716
  speak: {
136226
136717
  email: "",
136227
136718
  password: "",
@@ -136267,6 +136758,8 @@ var AlexaImportAddon = class extends BaseDeviceProvider {
136267
136758
  deviceClasses = Object.fromEntries(ALEXA_DEVICE_TYPES.map((t) => [t, AlexaDevice]));
136268
136759
  registry = null;
136269
136760
  proxyLogin = null;
136761
+ loginPlane = null;
136762
+ loginProxy = null;
136270
136763
  brokerStore = null;
136271
136764
  activeBrokers = [];
136272
136765
  speak = null;
@@ -136306,16 +136799,13 @@ var AlexaImportAddon = class extends BaseDeviceProvider {
136306
136799
  });
136307
136800
  alexaCommands.setDispatcher((brokerId, command) => this.requireRegistry().sendCommand(brokerId, command));
136308
136801
  await this.registry.restore(this.activeBrokers);
136802
+ await this.serveLoginProxy();
136309
136803
  this.proxyLogin = new AlexaProxyLoginManager({
136310
136804
  logger: this.ctx.logger,
136311
136805
  getProxyConfig: () => {
136312
- const cfg = alexaProxyLoginSchema.parse(this.config.proxyLogin ?? {});
136313
- return {
136314
- proxyHost: cfg.proxyHost,
136315
- proxyPort: cfg.proxyPort
136316
- };
136806
+ return { proxyPort: alexaProxyLoginSchema.parse(this.config.proxyLogin ?? {}).proxyPort };
136317
136807
  },
136318
- getAppConnectionAddresses: async () => (await this.ctx.api.localNetwork.getAddresses.query()).roles.appConnections.resolved
136808
+ getLoginProxy: () => this.loginProxy
136319
136809
  });
136320
136810
  this.ctx.logger.info("Alexa: import addon initialised", { meta: { brokerCount: this.activeBrokers.length } });
136321
136811
  await this.reconcileIntegrationsToBrokers();
@@ -136447,6 +136937,24 @@ var AlexaImportAddon = class extends BaseDeviceProvider {
136447
136937
  }
136448
136938
  this.speak?.brokersChanged();
136449
136939
  }
136940
+ /** The hub's HTTPS face for the Amazon login (D955): admin session only. */
136941
+ async serveLoginProxy() {
136942
+ const proxy = new VendorLoginProxy({
136943
+ addonId: this.ctx.id,
136944
+ prefix: ALEXA_LOGIN_PROXY_PREFIX,
136945
+ logger: this.ctx.logger
136946
+ });
136947
+ try {
136948
+ this.loginPlane = await this.ctx.dataPlane?.serve({
136949
+ prefix: "login",
136950
+ access: "admin",
136951
+ handler: proxy.handler
136952
+ }) ?? null;
136953
+ if (this.loginPlane !== null) this.loginProxy = proxy;
136954
+ } catch (err) {
136955
+ this.ctx.logger.warn("Alexa: login proxy failed to serve — interactive sign-in is unavailable", { meta: { error: errMsg(err) } });
136956
+ }
136957
+ }
136450
136958
  async onShutdown() {
136451
136959
  this.speak?.stop();
136452
136960
  this.speak = null;
@@ -136457,6 +136965,9 @@ var AlexaImportAddon = class extends BaseDeviceProvider {
136457
136965
  this.ctx.logger.warn("Alexa: proxy-login dispose error", { meta: { error: errMsg(err) } });
136458
136966
  }
136459
136967
  this.proxyLogin = null;
136968
+ await this.loginPlane?.dispose().catch(() => void 0);
136969
+ this.loginPlane = null;
136970
+ this.loginProxy = null;
136460
136971
  try {
136461
136972
  await this.registry?.shutdown();
136462
136973
  } catch (err) {
@@ -136702,19 +137213,13 @@ var AlexaImportAddon = class extends BaseDeviceProvider {
136702
137213
  id: "alexa-proxy-login",
136703
137214
  title: "Interactive login (proxy)",
136704
137215
  titleKey: "import-alexa:globalSettings.s_alexa-proxy-login.title",
136705
- description: "The \"Login to Amazon\" button in onboarding opens a local proxy that captures the cookie after you complete the real Amazon login (incl. 2FA). Because Amazon URLs are rewritten to this exact host:port, it must be a directly-reachable address — leave the host blank to auto-detect the server IP, and make sure the port is reachable from the browser you log in from.",
137216
+ description: "The \"Sign in\" button in onboarding opens the real Amazon login page through this hub (same address and HTTPS as this page) and captures the cookie after you complete it (incl. 2FA). The port below is only used on the hub itself and is never exposed.",
136706
137217
  descriptionKey: "import-alexa:globalSettings.s_alexa-proxy-login.description",
136707
137218
  columns: 2,
136708
137219
  fields: [{
136709
- type: "text",
136710
- key: "proxyLogin.proxyHost",
136711
- label: "Login proxy host/IP (blank = auto-detect)",
136712
- labelKey: "import-alexa:globalSettings.s_alexa-proxy-login.proxyLogin_proxyHost.label",
136713
- placeholder: "auto-detect"
136714
- }, {
136715
137220
  type: "number",
136716
137221
  key: "proxyLogin.proxyPort",
136717
- label: "Login proxy port",
137222
+ label: "Internal login port (loopback)",
136718
137223
  labelKey: "import-alexa:globalSettings.s_alexa-proxy-login.proxyLogin_proxyPort.label",
136719
137224
  min: 1,
136720
137225
  max: 65535,