@linxin666/dsh-remote-bridge 0.4.18 → 0.4.19

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/README.i18n.yaml CHANGED
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # node scripts/verify-docs.mjs --write <dir>
5
- README.md: 9d734cffc206d476df5b975eebbd3077d21a039b
6
- README.zh.md: 6b9152398c4640b44f3933d5a0ce85038cd58b8c
5
+ README.md: c79335f04f0a4ca6e5f8c6f1f7c6d021e8cd287c
6
+ README.zh.md: 72978fa555530778b8afa214285045751dcf978c
package/README.md CHANGED
@@ -5,7 +5,7 @@ English | [中文](README.zh.md)
5
5
  <p align="center">
6
6
  <img src="https://img.shields.io/npm/v/@linxin666/dsh-remote-bridge?style=flat-square" alt="Version">
7
7
  &nbsp;
8
- <img src="https://img.shields.io/badge/DSH-%3E%3D0.2.2--rc.2-4c6ef5?style=flat-square&amp;labelColor=454a54" alt="DSH">
8
+ <img src="https://img.shields.io/badge/DSH-%3E%3D0.2.2--rc.3-4c6ef5?style=flat-square&amp;labelColor=454a54" alt="DSH">
9
9
  &nbsp;
10
10
  <img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License">
11
11
  </p>
@@ -254,7 +254,7 @@ The security model enforces strict whitelisting across all external ingress path
254
254
  - **Tunnel target is the ingress gate, not the webServer**: cloudflared quick and named tunnels target the dynamic loopback port bound by `ingress-gate`, never the harness `webServer` port. A request routed through the tunnel cannot reach webServer routes, internal APIs, or other plugins.
255
255
  - **Relay registration and public exposure**: the relay registration row only writes the quick tunnel URL, which points to the ingress gate, so the public internet still only sees /ios/v1. When the plan is quick and the tunnel is running, the gate URL is announced to the relay Worker (proxying the stable subdomain to this machine; endpoints and suffix are determined by configuration, defaulting to `<id>.dsh-market.com`); plugin disposal clears local references without withdrawing the row. QR public address selection is decided by `livePublicOriginOf`: bridge or named leases prioritize the stable subdomain; quick leases fall back to the tunnel running URL while registration is unconfirmed; no lease uses the tunnel URL; none returns no address. Fallbacks then check `DSH_REMOTE_PUBLIC_BASE_URL`, and the LAN fallback provides an address only when the LAN forwarder is actually listening using its snapshot's bound address and port (never guessing the first IP in the address list, returning no address when stopped; the disk registry row fallback has been completely removed, eliminating the last data dependency on legacy data files).
256
256
  - **LAN forwarder target is the ingress gate**: the LAN forwarder listens on the machine's LAN IPv4 address and re-issues traffic exclusively to the `ingress-gate` port, so local network reachability is also constrained strictly to `/ios/v1`.
257
- - **Relay bridge connector whitelist**: the Durable Object multiplexer in `relay-bridge-connector.ts` applies the same whitelist. Non-`/ios/v1` HTTP streams receive `404 {"error":"not-found"}`, and non-whitelisted WebSocket upgrades return `ws-fail 404 {"error":"not-found"}`, establishing no upstream connection.
257
+ - **Relay bridge connector whitelist**: the Durable Object multiplexer in `relay-bridge-connector.ts` applies the same whitelist. Non-`/ios/v1` HTTP streams receive `404 {"error":"not-found"}`, and non-whitelisted WebSocket upgrades return `ws-fail 404 {"error":"not-found"}`, establishing no upstream connection. A whitelisted stream drops the caller's `accept-encoding` and asks the loopback host for `identity`, so the only compression a bridged response meets is the edge's own: a body compressed at this end arrives at the edge already opaque, the edge compresses it once more, and the caller then decodes one of two layers (issue #2052).
258
258
  - **Historical spelling retention and coexistence caveat**: the registry directory `$DSH_HOME/remote-web-ui-registry/` and state file `remote-web-ui-relay-bridge.json` intentionally retain their historical names so existing profiles maintain identity continuity and previously paired devices keep their credentials across upgrades. **Known risk and coexistence caveat**: never enable relay concurrently on both this plugin and the deprecated `dsh-remote-web-ui` in the same profile — both share the same identity file per profile; mounting the bridge with `relay=false` withdraws the registration row and releases the lease for that shared identity, breaking the legacy plugin's active relay, while running both with relay enabled causes bridge connectors to compete over the same Durable Object connection (or quick tunnel registrations to overwrite each other). This cleanup behavior is intentional.
259
259
  - **No browser pairing surface**: this package does not include browser pairing cookie gates, `/api/pair` endpoints, `/remote` proxy routes, or mobile web touch CSS adaptation layers.
260
260
 
package/README.zh.md CHANGED
@@ -5,7 +5,7 @@
5
5
  <p align="center">
6
6
  <img src="https://img.shields.io/npm/v/@linxin666/dsh-remote-bridge?style=flat-square" alt="Version">
7
7
  &nbsp;
8
- <img src="https://img.shields.io/badge/DSH-%3E%3D0.2.2--rc.2-4c6ef5?style=flat-square&amp;labelColor=454a54" alt="DSH">
8
+ <img src="https://img.shields.io/badge/DSH-%3E%3D0.2.2--rc.3-4c6ef5?style=flat-square&amp;labelColor=454a54" alt="DSH">
9
9
  &nbsp;
10
10
  <img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License">
11
11
  </p>
@@ -251,7 +251,7 @@ curl -s http://127.0.0.1:3080/remote-bridge/pair/token
251
251
  - **隧道的目标是入站网关而非 webServer 端口**:cloudflared 快速隧道与命名隧道的目标均指向 `ingress-gate` 的动态回环端口,绝不直连 `webServer` 端口。外界经隧道传入的请求无法触达 webServer 路由、内部 API 或其他插件。
252
252
  - **中继注册行与公网暴露面**:中继注册行只写入快速隧道的 URL,也就是入站闸门,公网因此只看得见 /ios/v1。计划为 quick 且隧道 running 时把闸门 URL 注册给中继 Worker(代理稳定子域名到本机,端点与后缀由配置决定、缺省为 `<id>.dsh-market.com`);卸载时只清本地引用不撤行。二维码公网地址由 `livePublicOriginOf` 裁定:bridge 或 named 租约优先稳定子域名;quick 租约在注册未成功时退回隧道 running URL;无租约用隧道 URL;皆无则无地址。其后退回 `DSH_REMOTE_PUBLIC_BASE_URL`,局域网兜底仅当局域网转发器真的在监听时才按实际绑定的 address 与 port 给出(不猜地址列表首项,转发器停止即无兜底;已彻底移除磁盘 registry 行作为兜底地址,消除了对老插件数据文件的最后一处依赖)。
253
253
  - **局域网转发器的目标同样是入站网关**:局域网转发器监听本机局域网 IPv4 地址,并将请求严格转发至 `ingress-gate` 端口,因此局域网入口的暴露面同样仅有 `/ios/v1`。
254
- - **中继桥会合点白名单**:`relay-bridge-connector.ts` 对 Durable Object 汇聚的入站流执行完全相同的白名单检查,非 `/ios/v1` 的 HTTP 流直接应答 `404 {"error":"not-found"}`,非白名单 WebSocket 升级直接回复 `ws-fail 404 {"error":"not-found"}`,两条路都不建立上游连接。
254
+ - **中继桥会合点白名单**:`relay-bridge-connector.ts` 对 Durable Object 汇聚的入站流执行完全相同的白名单检查,非 `/ios/v1` 的 HTTP 流直接应答 `404 {"error":"not-found"}`,非白名单 WebSocket 升级直接回复 `ws-fail 404 {"error":"not-found"}`,两条路都不建立上游连接。通过白名单的流会丢弃调用方的 `accept-encoding`、改向回环宿主索取 `identity`,于是桥接响应遇到的压缩只可能来自边缘自己:在这一端压缩过的 body 到边缘时已经不可读,边缘再压一层,调用方就只解开了两层中的一层(issue #2052)。
255
255
  - **身份目录沿用历史拼写与并存禁忌**:中继身份目录 `$DSH_HOME/remote-web-ui-registry/` 与状态文件 `remote-web-ui-relay-bridge.json` 有意沿用历史拼写,确保既有 profile 保持身份连续性,已配对设备升级后无需重新配对。**已知风险与并存禁忌**:同一 profile 切勿同时启用本插件与已弃用的 `dsh-remote-web-ui` 的中继——两者按 profile 共用同一份身份文件;若新桥以 `relay=false` 挂载,会撤销该身份下的注册行并释放租约,从而打断老插件正在使用的公网中继;若两侧 relay 同时开启,bridge 传输下两个连接器会拿同一凭据竞争同一个 Durable Object 连接互相顶掉,quick 传输下后注册者覆盖前者。该收尾行为是有意设计的。
256
256
  - **本插件不含浏览器配对面**:本包不包含配对 cookie 门控、`/api/pair` 路由族、`/remote` 代理通道以及手机浏览器竖屏触控适配层。
257
257
 
package/lib/index.js CHANGED
@@ -11914,11 +11914,12 @@ function makePairTokenRoute(deps) {
11914
11914
  return {
11915
11915
  kind: "exact",
11916
11916
  path: PAIR_TOKEN_PATH,
11917
+ auth: "anonymous",
11917
11918
  handler: makePairTokenHandler(deps)
11918
11919
  };
11919
11920
  }
11920
11921
  //#endregion
11921
- //#region ../../node_modules/.pnpm/@deepseek-ai+dsh-typert-protocol@0.2.2-rc.2_@deepseek-ai+cordis@4.1.0/node_modules/@deepseek-ai/dsh-typert-protocol/lib/index.js
11922
+ //#region ../../node_modules/.pnpm/@deepseek-ai+dsh-typert-protocol@0.2.2-rc.3_@deepseek-ai+cordis@4.1.0/node_modules/@deepseek-ai/dsh-typert-protocol/lib/index.js
11922
11923
  /** The one Remote failure class shared by owners, the Gateway, and consumers. */
11923
11924
  /**
11924
11925
  * One Remote call failure: a real Error carrying its stable code and typed
@@ -12100,7 +12101,7 @@ function validateName(subject, value) {
12100
12101
  if (!isTypertRemoteSegment(value)) throw new TypeError(`typert-protocol: ${subject} must contain only RPC endpoint segment characters`);
12101
12102
  }
12102
12103
  //#endregion
12103
- //#region ../../node_modules/.pnpm/@deepseek-ai+dsh-util-values@0.2.2-rc.2_@deepseek-ai+cordis@4.1.0/node_modules/@deepseek-ai/dsh-util-values/lib/index.js
12104
+ //#region ../../node_modules/.pnpm/@deepseek-ai+dsh-util-values@0.2.2-rc.3_@deepseek-ai+cordis@4.1.0/node_modules/@deepseek-ai/dsh-util-values/lib/index.js
12104
12105
  /**
12105
12106
  * Lazily scanned view of one JSON object's top-level fields, built from text
12106
12107
  * that may still be streaming or from an already parsed object. Nothing is
@@ -13806,11 +13807,11 @@ defineMethod("transform", [
13806
13807
  "preserve"
13807
13808
  ], ({ inner }, isInner) => inner.toString(isInner));
13808
13809
  //#endregion
13809
- //#region ../../node_modules/.pnpm/@deepseek-ai+dsh-timeout@0.2.2-rc.2_@deepseek-ai+cordis@4.1.0/node_modules/@deepseek-ai/dsh-timeout/lib/index.js
13810
+ //#region ../../node_modules/.pnpm/@deepseek-ai+dsh-timeout@0.2.2-rc.3_@deepseek-ai+cordis@4.1.0/node_modules/@deepseek-ai/dsh-timeout/lib/index.js
13810
13811
  /** Largest delay Node schedules without clamping it to one millisecond. */
13811
13812
  const MAX_TIMER_DELAY_MS = 2147483647;
13812
13813
  //#endregion
13813
- //#region ../../node_modules/.pnpm/@deepseek-ai+dsh-error@0.2.2-rc.2_@deepseek-ai+cordis@4.1.0/node_modules/@deepseek-ai/dsh-error/lib/index.js
13814
+ //#region ../../node_modules/.pnpm/@deepseek-ai+dsh-error@0.2.2-rc.3_@deepseek-ai+cordis@4.1.0/node_modules/@deepseek-ai/dsh-error/lib/index.js
13814
13815
  /**
13815
13816
  * Harness error base with a stable machine-routable code and chained cause.
13816
13817
  * Package errors extend it so tool results and replay can retain failure class.
@@ -13832,7 +13833,7 @@ var HarnessError = class extends Error {
13832
13833
  }
13833
13834
  };
13834
13835
  //#endregion
13835
- //#region ../../node_modules/.pnpm/@deepseek-ai+dsh-llm@0.2.2-rc.2_@deepseek-ai+cordis@4.1.0_@deepseek-ai+dsh-error@0.2.2-rc.2_@deepseek-ai+cordis@4.1.0_/node_modules/@deepseek-ai/dsh-llm/lib/index.js
13836
+ //#region ../../node_modules/.pnpm/@deepseek-ai+dsh-llm@0.2.2-rc.3_@deepseek-ai+cordis@4.1.0_@deepseek-ai+dsh-error@0.2.2-rc.3_@deepseek-ai+cordis@4.1.0_/node_modules/@deepseek-ai/dsh-llm/lib/index.js
13836
13837
  /**
13837
13838
  * Detach and deep-freeze a message whose identity already exists.
13838
13839
  * @param message - complete message, including its stable identity.
@@ -15101,7 +15102,7 @@ function detachDirectoryEntry(entry) {
15101
15102
  };
15102
15103
  }
15103
15104
  //#endregion
15104
- //#region ../../node_modules/.pnpm/@deepseek-ai+dsh-tools@0.2.2-rc.2_@deepseek-ai+cordis@4.1.0_@deepseek-ai+dsh-agent@0.2._d54d331d737d4347e4d7b0f13cb396ba/node_modules/@deepseek-ai/dsh-tools/lib/shared-DGx6D7zk.js
15105
+ //#region ../../node_modules/.pnpm/@deepseek-ai+dsh-tools@0.2.2-rc.3_c6df380a2007cdef080fa53578fb6f5f/node_modules/@deepseek-ai/dsh-tools/lib/shared-DGx6D7zk.js
15105
15106
  /** The selected provider is missing or unloaded; another provider must not take its calls. */
15106
15107
  var ToolExecutorUnavailableError = class extends HarnessError {
15107
15108
  constructor() {
@@ -15638,7 +15639,7 @@ var ToolActivationError = class extends HarnessError {
15638
15639
  }
15639
15640
  };
15640
15641
  //#endregion
15641
- //#region ../../node_modules/.pnpm/@deepseek-ai+dsh-scope@0.2.2-rc.2_@deepseek-ai+cordis@4.1.0/node_modules/@deepseek-ai/dsh-scope/lib/index.js
15642
+ //#region ../../node_modules/.pnpm/@deepseek-ai+dsh-scope@0.2.2-rc.3_@deepseek-ai+cordis@4.1.0/node_modules/@deepseek-ai/dsh-scope/lib/index.js
15642
15643
  /**
15643
15644
  * Shared insertion-ordered storage and effect ownership for scope-aware registries.
15644
15645
  *
@@ -15891,7 +15892,7 @@ function scopeOf(ctx) {
15891
15892
  return ctx[kScope];
15892
15893
  }
15893
15894
  //#endregion
15894
- //#region ../../node_modules/.pnpm/@deepseek-ai+dsh-tools@0.2.2-rc.2_@deepseek-ai+cordis@4.1.0_@deepseek-ai+dsh-agent@0.2._d54d331d737d4347e4d7b0f13cb396ba/node_modules/@deepseek-ai/dsh-tools/lib/index.js
15895
+ //#region ../../node_modules/.pnpm/@deepseek-ai+dsh-tools@0.2.2-rc.3_c6df380a2007cdef080fa53578fb6f5f/node_modules/@deepseek-ai/dsh-tools/lib/index.js
15895
15896
  /** Unified JSON-value schema DSL, inference, compilation, and tool definition helpers. @module dsh-tools/schema */
15896
15897
  const ANNOTATION_KEYS = [
15897
15898
  "description",
@@ -28438,7 +28439,7 @@ var require_negotiator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
28438
28439
  Negotiator.prototype.preferredMediaTypes = Negotiator.prototype.mediaTypes;
28439
28440
  }));
28440
28441
  //#endregion
28441
- //#region ../../node_modules/.pnpm/@deepseek-ai+dsh-host-webserver@0.2.2-rc.2_@deepseek-ai+cordis@4.1.0_supports-color@7.2.0/node_modules/@deepseek-ai/dsh-host-webserver/lib/index.js
28442
+ //#region ../../node_modules/.pnpm/@deepseek-ai+dsh-host-webserver@0.2.2-rc.3_@deepseek-ai+cordis@4.1.0_supports-color@7.2.0/node_modules/@deepseek-ai/dsh-host-webserver/lib/index.js
28442
28443
  var lib_exports = /* @__PURE__ */ __exportAll({
28443
28444
  WebServer: () => WebServer,
28444
28445
  bindUrlHost: () => bindUrlHost,
@@ -31125,17 +31126,36 @@ function bridgeUpstreamHost(frameHost, hostname) {
31125
31126
  if (typeof frameHost === "string" && frameHost !== "") return frameHost;
31126
31127
  return hostname;
31127
31128
  }
31129
+ /** The header the connector answers with its own choice, not the phone's. */
31130
+ const UPSTREAM_ENCODING_HEADER = "accept-encoding";
31131
+ /**
31132
+ * The one wire encoding this transport asks its upstream for. The edge is the
31133
+ * only thing allowed to compress a bridged body: a body the origin compressed
31134
+ * and this socket carries verbatim arrives at the edge already opaque, and the
31135
+ * edge compresses it once more -- the phone then decodes one of two layers and
31136
+ * renders mojibake (issue #2052, the residual of #2030). Asking for `identity`
31137
+ * makes the question moot at this hop: the bytes handed on are plain by
31138
+ * construction, and `market/worker/src/relay-encoding.js` states them as such.
31139
+ */
31140
+ const UPSTREAM_ENCODING = "identity";
31128
31141
  /**
31129
31142
  * The upstream headers of one bridged request: the phone's own, minus the hops
31130
31143
  * this transport owns, with the public `Host` put back explicitly.
31144
+ *
31145
+ * The phone's `accept-encoding` is dropped: what the phone can decode is a fact
31146
+ * about the edge hop, not about the loopback hop this connector owns, and
31147
+ * forwarding it is what let a compressed body enter a socket whose far end
31148
+ * re-compresses unconditionally.
31131
31149
  */
31132
31150
  function bridgeUpstreamHeaders(frameHeaders, host) {
31133
31151
  const headers = {};
31134
31152
  for (const [name, value] of headerPairs(frameHeaders)) {
31135
- if (BRIDGE_HOP_BY_HOP.has(name.toLowerCase())) continue;
31153
+ const lowered = name.toLowerCase();
31154
+ if (BRIDGE_HOP_BY_HOP.has(lowered) || lowered === UPSTREAM_ENCODING_HEADER) continue;
31136
31155
  headers[name] = value;
31137
31156
  }
31138
31157
  headers.host = host;
31158
+ headers[UPSTREAM_ENCODING_HEADER] = UPSTREAM_ENCODING;
31139
31159
  return headers;
31140
31160
  }
31141
31161
  /** The headers of the bridge socket's own upgrade. */
@@ -35026,10 +35046,12 @@ function applyImpl(ctx, config) {
35026
35046
  */
35027
35047
  const lanOrigin = () => lanOriginOf(liveIngress.forward?.());
35028
35048
  ctx.effect(() => {
35029
- const disposeUpgrade = ctx.webServer.registerUpgrade({
35049
+ const upgradeRoute = {
35030
35050
  path: WS_PATH,
35051
+ auth: "anonymous",
35031
35052
  handler: makeUpgradeHandler(hub, roster, log)
35032
- });
35053
+ };
35054
+ const disposeUpgrade = ctx.webServer.registerUpgrade(upgradeRoute);
35033
35055
  const disposeRoute = ctx.webServer.register(makePairTokenRoute({
35034
35056
  pairing,
35035
35057
  log,
@@ -76,6 +76,11 @@ export declare function bridgeUpstreamHost(frameHost: unknown, hostname: string)
76
76
  /**
77
77
  * The upstream headers of one bridged request: the phone's own, minus the hops
78
78
  * this transport owns, with the public `Host` put back explicitly.
79
+ *
80
+ * The phone's `accept-encoding` is dropped: what the phone can decode is a fact
81
+ * about the edge hop, not about the loopback hop this connector owns, and
82
+ * forwarding it is what let a compressed body enter a socket whose far end
83
+ * re-compresses unconditionally.
79
84
  */
80
85
  export declare function bridgeUpstreamHeaders(frameHeaders: unknown, host: string): Record<string, string>;
81
86
  /** The headers of the bridge socket's own upgrade. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linxin666/dsh-remote-bridge",
3
3
  "description": "DSH remote bridge: the host half serves protocol v1 over one exact /ios/v1 WebSocket route — session roster, history baseline, prompting, live turn increments with tool activity, interrupt, and in-process agent approval — to a device paired by a one-shot bootstrap token and a P-256 challenge-response, with the token endpoint admitted only from this machine; the browser half adds one sidebar-foot panel that shows that same one-shot token as a QR symbol and draws an interactive card inside the tool row without answering it, and adds no wire surface",
4
- "version": "0.4.18",
4
+ "version": "0.4.19",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",
7
7
  "engines": {
@@ -37,7 +37,7 @@
37
37
  "license": "Apache-2.0",
38
38
  "dsh": {
39
39
  "engines": {
40
- "dsh": ">=0.2.2-rc.2"
40
+ "dsh": ">=0.2.2-rc.3"
41
41
  },
42
42
  "bundle": {
43
43
  "patch": "./cordis.patch.yml"
@@ -57,23 +57,23 @@
57
57
  "yaml": "^2.8.2"
58
58
  },
59
59
  "peerDependencies": {
60
- "@deepseek-ai/dsh": ">=0.2.2-rc.2",
60
+ "@deepseek-ai/dsh": ">=0.2.2-rc.3",
61
61
  "react": "^18.2.0",
62
62
  "react-dom": "^18.2.0"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@deepseek-ai/cordis": "^4.1.0",
66
- "@deepseek-ai/dsh-api-gateway": "^0.2.2-rc.2",
67
- "@deepseek-ai/dsh-client-locale": "^0.2.2-rc.2",
68
- "@deepseek-ai/dsh-client-ui-primitives": "^0.2.2-rc.2",
69
- "@deepseek-ai/dsh-client-ui-renderer": "^0.2.2-rc.2",
70
- "@deepseek-ai/dsh-client-ui-sidebar": "^0.2.2-rc.2",
71
- "@deepseek-ai/dsh-client-ui-slots": "^0.2.2-rc.2",
72
- "@deepseek-ai/dsh-host-webserver": "^0.2.2-rc.2",
73
- "@deepseek-ai/dsh-session": "^0.2.2-rc.2",
74
- "@deepseek-ai/dsh-tools": "^0.2.2-rc.2",
75
- "@deepseek-ai/dsh-typert-protocol": "^0.2.2-rc.2",
76
- "@deepseek-ai/dsh-user-approval": "^0.2.2-rc.2",
66
+ "@deepseek-ai/dsh-api-gateway": "^0.2.2-rc.3",
67
+ "@deepseek-ai/dsh-client-locale": "^0.2.2-rc.3",
68
+ "@deepseek-ai/dsh-client-ui-primitives": "^0.2.2-rc.3",
69
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.2.2-rc.3",
70
+ "@deepseek-ai/dsh-client-ui-sidebar": "^0.2.2-rc.3",
71
+ "@deepseek-ai/dsh-client-ui-slots": "^0.2.2-rc.3",
72
+ "@deepseek-ai/dsh-host-webserver": "^0.2.2-rc.3",
73
+ "@deepseek-ai/dsh-session": "^0.2.2-rc.3",
74
+ "@deepseek-ai/dsh-tools": "^0.2.2-rc.3",
75
+ "@deepseek-ai/dsh-typert-protocol": "^0.2.2-rc.3",
76
+ "@deepseek-ai/dsh-user-approval": "^0.2.2-rc.3",
77
77
  "@testing-library/dom": "^10.4.1",
78
78
  "@testing-library/react": "^16.3.2",
79
79
  "@types/node": "^22.20.0",
@@ -133,17 +133,37 @@ export function bridgeUpstreamHost(frameHost: unknown, hostname: string): string
133
133
  return hostname
134
134
  }
135
135
 
136
+ /** The header the connector answers with its own choice, not the phone's. */
137
+ const UPSTREAM_ENCODING_HEADER = 'accept-encoding'
138
+ /**
139
+ * The one wire encoding this transport asks its upstream for. The edge is the
140
+ * only thing allowed to compress a bridged body: a body the origin compressed
141
+ * and this socket carries verbatim arrives at the edge already opaque, and the
142
+ * edge compresses it once more -- the phone then decodes one of two layers and
143
+ * renders mojibake (issue #2052, the residual of #2030). Asking for `identity`
144
+ * makes the question moot at this hop: the bytes handed on are plain by
145
+ * construction, and `market/worker/src/relay-encoding.js` states them as such.
146
+ */
147
+ const UPSTREAM_ENCODING = 'identity'
148
+
136
149
  /**
137
150
  * The upstream headers of one bridged request: the phone's own, minus the hops
138
151
  * this transport owns, with the public `Host` put back explicitly.
152
+ *
153
+ * The phone's `accept-encoding` is dropped: what the phone can decode is a fact
154
+ * about the edge hop, not about the loopback hop this connector owns, and
155
+ * forwarding it is what let a compressed body enter a socket whose far end
156
+ * re-compresses unconditionally.
139
157
  */
140
158
  export function bridgeUpstreamHeaders(frameHeaders: unknown, host: string): Record<string, string> {
141
159
  const headers: Record<string, string> = {}
142
160
  for (const [name, value] of headerPairs(frameHeaders)) {
143
- if (BRIDGE_HOP_BY_HOP.has(name.toLowerCase())) continue
161
+ const lowered = name.toLowerCase()
162
+ if (BRIDGE_HOP_BY_HOP.has(lowered) || lowered === UPSTREAM_ENCODING_HEADER) continue
144
163
  headers[name] = value
145
164
  }
146
165
  headers.host = host
166
+ headers[UPSTREAM_ENCODING_HEADER] = UPSTREAM_ENCODING
147
167
  return headers
148
168
  }
149
169
 
@@ -140,7 +140,17 @@ export function makePairTokenHandler(deps: PairTokenRouteDeps): WebRoute['handle
140
140
  }
141
141
  }
142
142
 
143
+ type AuthAwareWebRoute = WebRoute & { readonly auth?: 'anonymous' | 'required' | 'deny' }
144
+
143
145
  /** The route as the host web server takes it: one exact path, no trailing slash. */
144
146
  export function makePairTokenRoute(deps: PairTokenRouteDeps): WebRoute {
145
- return { kind: 'exact', path: PAIR_TOKEN_PATH, handler: makePairTokenHandler(deps) }
147
+ // This endpoint runs its own strict loopback-and-Host trust fence (plus pair-token
148
+ // semantics) without requiring a desktop browser session cookie.
149
+ const route: AuthAwareWebRoute = {
150
+ kind: 'exact',
151
+ path: PAIR_TOKEN_PATH,
152
+ auth: 'anonymous',
153
+ handler: makePairTokenHandler(deps),
154
+ }
155
+ return route
146
156
  }
package/src/index.ts CHANGED
@@ -1668,10 +1668,16 @@ function applyImpl(ctx: Context, config?: unknown): void {
1668
1668
  const lanOrigin = (): { address: string; port: number } | undefined => lanOriginOf(liveIngress.forward?.())
1669
1669
 
1670
1670
  ctx.effect(() => {
1671
- const disposeUpgrade = ctx.webServer.registerUpgrade({
1671
+ const upgradeRoute: Parameters<typeof ctx.webServer.registerUpgrade>[0] & {
1672
+ readonly auth?: 'anonymous' | 'required' | 'deny'
1673
+ } = {
1672
1674
  path: WS_PATH,
1675
+ // Protocol v1 accepts unauthenticated connections in UNPAIRED state and restricts
1676
+ // them to hello / pair.begin / pair.finish until device-token verification succeeds.
1677
+ auth: 'anonymous',
1673
1678
  handler: makeUpgradeHandler(hub, roster, log),
1674
- })
1679
+ }
1680
+ const disposeUpgrade = ctx.webServer.registerUpgrade(upgradeRoute)
1675
1681
  const disposeRoute = ctx.webServer.register(makePairTokenRoute({
1676
1682
  pairing,
1677
1683
  log,