@linxin666/dsh-remote-bridge 0.4.14 → 0.4.15
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 +2 -2
- package/README.md +5 -5
- package/README.zh.md +5 -5
- package/lib/client.js +55 -26
- package/lib/client.js.map +1 -1
- package/lib/index.js +2758 -5317
- package/lib/types/client/PairPanel.d.ts +6 -1
- package/lib/types/client/locales.d.ts +10 -5
- package/lib/types/client/pair-token.d.ts +7 -0
- package/lib/types/core/pair-address.d.ts +25 -0
- package/package.json +16 -16
- package/src/client/PairEntry.tsx +1 -0
- package/src/client/PairPanel.tsx +23 -5
- package/src/client/locales.ts +12 -6
- package/src/client/pair-token.ts +17 -2
- package/src/core/pair-address.ts +50 -0
- package/src/host/routes.ts +12 -5
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:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: ce70588a1ac33a05084dd22daaf15f62be8d0f62
|
|
6
|
+
README.zh.md: 8bad871cc6d2021b108e1d07807caaa6daa59f12
|
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
|
|
|
8
|
-
<img src="https://img.shields.io/badge/DSH-%3E%3D0.2.
|
|
8
|
+
<img src="https://img.shields.io/badge/DSH-%3E%3D0.2.2--rc.1-4c6ef5?style=flat-square&labelColor=454a54" alt="DSH">
|
|
9
9
|
|
|
10
10
|
<img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License">
|
|
11
11
|
</p>
|
|
@@ -183,7 +183,7 @@ The device token rides the WebSocket upgrade as `Authorization: Bearer <deviceTo
|
|
|
183
183
|
|
|
184
184
|
The pairing entry is a QR code icon at the bottom of the sidebar, with the accessible label "Pair an iPhone". Clicking it opens the pairing panel. The panel is strictly available on localhost: its token route `GET /remote-bridge/pair/token` is guarded by a two-condition loopback gate where both the socket address and the `Host` header must name this machine (remote or tunneled requests return 403).
|
|
185
185
|
|
|
186
|
-
The pairing code is single-use and valid for 30 seconds (`BOOTSTRAP_TOKEN_TTL_MS = 30_000`), consumed immediately upon the first `pair.begin`; clicking "New code" in the panel voids the previous code and mints a fresh one. There is no "Stop" button and no action to revoke all connected devices. The link is printed to the host log,
|
|
186
|
+
The pairing code is single-use and valid for 30 seconds (`BOOTSTRAP_TOKEN_TTL_MS = 30_000`), consumed immediately upon the first `pair.begin`; clicking "New code" in the panel voids the previous code and mints a fresh one. There is no "Stop" button and no action to revoke all connected devices. The machine-local link is printed to the host log as `pair a device with <ws link>`, and that line is followed only by the kind of phone-facing address: `(phone: lan)` when the host calls the origin a LAN address or the literal itself answers only inside the network this page is already on, `(phone: public)` in every other case, and no suffix when the host found no address at all. The code itself renders in the pairing panel for scanning.
|
|
187
187
|
|
|
188
188
|
```sh
|
|
189
189
|
curl -s http://127.0.0.1:3080/remote-bridge/pair/token
|
|
@@ -198,7 +198,7 @@ When this machine can determine a public or LAN origin — from live relay lease
|
|
|
198
198
|
"expiresAt": 1760000030000,
|
|
199
199
|
"url": "ws://127.0.0.1:3080/ios/v1?token=...",
|
|
200
200
|
"origin": "wss://<id>.dsh-market.com",
|
|
201
|
-
"originSource": "
|
|
201
|
+
"originSource": "realtime",
|
|
202
202
|
"pairingUrl": "wss://<id>.dsh-market.com/ios/v1?token=..."
|
|
203
203
|
}
|
|
204
204
|
```
|
|
@@ -283,7 +283,7 @@ The panel has one job — put the live one-time code in front of the operator, i
|
|
|
283
283
|
- **Header and subtitle set the scope.** Title "iOS app pairing"; subtitle "Scan the QR code with the iOS app (beta) to connect an iPhone to this computer. The code is shown only on this machine.", stating the target and security boundary.
|
|
284
284
|
- **The QR symbol is the code.** It encodes either the bare 43-character base64url token or, when the host can name its own public origin, the `{token,url}` document one scan turns into a fully configured iPhone. A URL the host did not vouch for would let the app's own parser rewrite its origin onto this machine's loopback address, which is precisely the address an iPhone cannot reach. The encoded string is mirrored once, as the `data-dsh-qr-value` attribute on the symbol's part, so a UI check can compare it without decoding anything; it is never rendered as text.
|
|
285
285
|
- **One status line under the symbol.** A live code counts its 30 s window down beside a progress bar; an expired code states the expiry in the same fixed box, so only the sentence changes.
|
|
286
|
-
- **One address line.**
|
|
286
|
+
- **One address line.** A located origin is stated as a kind rather than printed: "The QR code carries the public address: the iPhone connects to this computer as soon as it scans". The one-time code burns 30 seconds after it appears, while a durable public hostname, once rendered as text, outlives every screenshot it appears in; the symbol already carries the address the phone needs, and Copy hands over the same `{token,url}` string either way. A LAN literal is not that fact, and the line names it — "The QR code points at the LAN address {origin}: the iPhone must be on the same network" — when the host calls the origin a LAN address or when the literal itself answers only inside the network this page is already on. With no located address the line says outright "No public address found: set the connection address in the app to your public relay first, then scan. {host} (this page) is reachable only from this machine."
|
|
287
287
|
- **One single-use note.** The code is single-use: pairing spends it, and a new code voids the previous one.
|
|
288
288
|
- **One action row.** Copy puts the very string the symbol encodes on the clipboard, and **New code** mints a fresh token and voids the previous one; both are one library control at one size, so their states never diverge. Once the code expires, mint-again is the only way back to a scannable symbol: copy is disabled and the symbol is dimmed in place instead of resized or removed.
|
|
289
289
|
- **One beta entry.** Provides "[The iOS app is in beta. Come talk to us on Discord](https://discord.gg/nBy28kjun)", clickable across the entire line.
|
|
@@ -346,7 +346,7 @@ The bridge is mounted like any other host plugin row. It carries no user-facing
|
|
|
346
346
|
|
|
347
347
|
- **Pairing is a full-control credential.** A paired device reaches the harness in-process: sessions, prompts, approvals. Only pair devices you control, and revoke by removing the roster row and restarting the host.
|
|
348
348
|
- **In-process calls speak for the owner, only behind this bridge's own gate.** Since DSH 0.2.1 the harness gateway requires every call to name the peer it speaks for, and the bridge answers with one in-process owner peer (`{kind:'owner'}`) that it mints itself at mount and attaches to every gateway call. That claim is safe because it is exercised only after the bridge's own pairing check — an unpaired connection is refused before any gateway call exists — and no field of a protocol frame can set a principal: a client that names one in its payload is ignored. The peer takes no forwarded-event interactions, so it never receives forwarded Host events either.
|
|
349
|
-
- **The token endpoint is loopback-only, on two conditions.** The socket address must be loopback and the `Host` header must name this machine. A tunneled request is terminated by the tunnel client on this same host, so the socket address alone reads `127.0.0.1` for a request the whole internet can reach, while the relay and a plain tunnel rewrite `Host` to the public name; failing either condition is a 403. The token is memory-only, expires in 30 s, is spent by one `pair.begin`, and the
|
|
349
|
+
- **The token endpoint is loopback-only, on two conditions.** The socket address must be loopback and the `Host` header must name this machine. A tunneled request is terminated by the tunnel client on this same host, so the socket address alone reads `127.0.0.1` for a request the whole internet can reach, while the relay and a plain tunnel rewrite `Host` to the public name; failing either condition is a 403. The token is memory-only, expires in 30 s, is spent by one `pair.begin`, and the machine-local link is written to the host log — treat that log line as a live secret. The phone's side of that line is the kind of address alone (`(phone: public)` or `(phone: lan)`, no suffix when there is none): this pairing line is the one an operator pastes elsewhere, and a public hostname or a LAN literal in it would outlive the code it belongs to.
|
|
350
350
|
- **The pairing panel renders a live secret and nothing more.** It reads the same loopback-gated route over a same-origin request, so it is reachable exactly where the `curl` form is, and nowhere else. It cannot mint a device token, spend one, list the roster or revoke a device: `pair.begin` stays the phone's call, and revocation stays a roster edit plus a host restart. The QR carries either the bare token or the host's own `{token,url}` answer, so the page's `127.0.0.1` origin is never handed to the phone.
|
|
351
351
|
- **An unpaired connection has a three-method whitelist.** `hello`, `pair.begin` and `pair.finish`; every other method answers `unpaired` before dispatch, so no session, approval or roster surface is reachable without a device token.
|
|
352
352
|
- **Device tokens are stored as hashes only.** The roster keeps the public key and its SHA-256 fingerprint, never the token, so the file is not a credential store. A lost, rotated or rejected token means pairing again — a routine flow, not an exception path (a fresh bootstrap link, or a re-scan of the desktop pairing flow), and it never requires editing the roster by hand.
|
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
|
|
|
8
|
-
<img src="https://img.shields.io/badge/DSH-%3E%3D0.2.
|
|
8
|
+
<img src="https://img.shields.io/badge/DSH-%3E%3D0.2.2--rc.1-4c6ef5?style=flat-square&labelColor=454a54" alt="DSH">
|
|
9
9
|
|
|
10
10
|
<img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License">
|
|
11
11
|
</p>
|
|
@@ -180,7 +180,7 @@ fork 的方法同样什么都不解释。`session.fork` 把 `sessionId` 与客
|
|
|
180
180
|
|
|
181
181
|
配对入口位于侧栏底部的二维码图标,按钮的 aria-label 为「配对 iPhone」。点击后打开配对面板。该面板只在本机可用:令牌路由 `GET /remote-bridge/pair/token` 受回环门控保护,来源地址与 `Host` header 必须均为本机(非本机或经隧道访问一律返回 403)。
|
|
182
182
|
|
|
183
|
-
配对码一次性有效且具备 30 秒时效(`BOOTSTRAP_TOKEN_TTL_MS = 30_000`),被首次 `pair.begin`
|
|
183
|
+
配对码一次性有效且具备 30 秒时效(`BOOTSTRAP_TOKEN_TTL_MS = 30_000`),被首次 `pair.begin` 用掉即失效;在面板中点击「重新取码」会使上一张配对码作废并生成新码。面板中没有「停止」按钮,也没有「吊销所有已连接设备」的操作。本机链接会以 `pair a device with <ws 链接>` 打印到宿主日志,而这一行后面只跟手机侧地址的种类:宿主把这个 origin 叫作局域网地址、或者该字面量本身就只在当前网络内可达时是 `(phone: lan)`,其余情形是 `(phone: public)`,一个地址都没有时不带后缀。配对码本身则渲染在配对面板中供扫码。
|
|
184
184
|
|
|
185
185
|
```sh
|
|
186
186
|
curl -s http://127.0.0.1:3080/remote-bridge/pair/token
|
|
@@ -195,7 +195,7 @@ curl -s http://127.0.0.1:3080/remote-bridge/pair/token
|
|
|
195
195
|
"expiresAt": 1760000030000,
|
|
196
196
|
"url": "ws://127.0.0.1:3080/ios/v1?token=...",
|
|
197
197
|
"origin": "wss://<id>.dsh-market.com",
|
|
198
|
-
"originSource": "
|
|
198
|
+
"originSource": "realtime",
|
|
199
199
|
"pairingUrl": "wss://<id>.dsh-market.com/ios/v1?token=..."
|
|
200
200
|
}
|
|
201
201
|
```
|
|
@@ -280,7 +280,7 @@ curl -s http://127.0.0.1:3080/remote-bridge/pair/token
|
|
|
280
280
|
- **卡头与副标题说明目标。** 标题为「iOS App 配对」,副标题「用 iOS App(内测)扫描二维码,把 iPhone 连到这台电脑上。配对码只在本机显示。」,说明操作对象与安全边界。
|
|
281
281
|
- **二维码本身就是那个码。** 它要么装 43 个 base64url 字符的裸 token,要么在宿主说得出自己公网地址时装 `{token,url}` 文档,扫一次就把 iPhone 配好。若放一个宿主没背书过的 URL,App 端的解析器会顺手把 origin 改写成这台机器的 loopback 地址,而那恰恰是 iPhone 够不到的地址。编码串只在二维码部件的 `data-dsh-qr-value` 属性里留一份镜像,供 UI 检查不必解码就比对;它从不以文字形式渲染。
|
|
282
282
|
- **二维码下方只有一条状态行。** 活着的码在进度条旁倒数那 30 秒;过期的码在同一个固定高度里直说过期,变的只有那句话。
|
|
283
|
-
- **一条地址说明。**
|
|
283
|
+
- **一条地址说明。** 定位到的公网地址只交代种类,不写成文字:「二维码已包含公网地址,扫码后 iPhone 自动连上这台电脑」。一次性配对码 30 秒即焚,而持久公网主机名一旦以文字渲染,会比它出现的每张截图活得久;二维码本身已带手机需要的地址,「复制配对码」交出的仍是同一个 `{token,url}` 串。局域网字面量不属于这一类事实:当宿主把这个 origin 叫作局域网地址,或者该字面量本身就只在当前网络内可达时,这一行都点名它——「二维码指向局域网地址 {origin},iPhone 需与本机在同一网络」。定位不到地址时,它直说「没有找到公网地址:先在 App 里把连接地址填成你的公网中继,再扫码。本页的 {host} 只有本机能连。」。
|
|
284
284
|
- **一条一次性说明。** 配对码一次性有效:iPhone 一开始配对就作废,重新取码也会作废上一张。
|
|
285
285
|
- **一行动作。** 复制把二维码里那个字符串原样放进剪贴板,「重新取码」签发新 token 并作废上一张;两者都是同一个库控件、同一个尺寸,交互态不会各走一套。码一旦过期,回到可扫状态的唯一路径就是重新取码:复制被禁用,二维码原地降级变暗,而不是缩小或被移除。
|
|
286
286
|
- **一行内测入口。** 提供「[iOS App 还在内测,欢迎来 Discord 交流](https://discord.gg/nBy28kjun)」,整行可点击打开。
|
|
@@ -343,7 +343,7 @@ dsh plugin --profile web add link:$(pwd)/packages/dsh-remote-bridge
|
|
|
343
343
|
|
|
344
344
|
- **配对即完全控制凭据。** 已配对设备在同一进程内触达宿主:会话、发言、审批。只配对你掌控的设备,吊销方式是移除名册那一行并重启宿主。
|
|
345
345
|
- **进程内调用以 owner 身份发言,且只在桥自己的门禁之后。** 自 DSH 0.2.1 起,宿主网关要求每次调用都指明代表谁发言,桥的回答是自己在挂载时铸造的一个进程内 owner peer(`{kind:'owner'}`),挂到每一次网关调用上。这个声明之所以安全,是因为它只在桥自己的配对检查之后才会被用到——未配对连接在任何网关调用存在之前即被拒——且协议帧的任何字段都不能设定 principal:客户端在载荷里自报的身份会被忽略。该 peer 不接收转发事件交互,因此它也永远收不到宿主转发事件。
|
|
346
|
-
- **token 端点仅 loopback 可达,且看两个条件。** 来源地址必须是 loopback,且 `Host` header 必须写本机。经隧道的请求由本机的隧道客户端终结,所以对一条全互联网可达的请求,来源地址也读作 `127.0.0.1`;而中继与普通隧道都会把 `Host` 改写成公网名。任一条件不成立即 403。token 只存内存、30 秒过期、被一次 `pair.begin`
|
|
346
|
+
- **token 端点仅 loopback 可达,且看两个条件。** 来源地址必须是 loopback,且 `Host` header 必须写本机。经隧道的请求由本机的隧道客户端终结,所以对一条全互联网可达的请求,来源地址也读作 `127.0.0.1`;而中继与普通隧道都会把 `Host` 改写成公网名。任一条件不成立即 403。token 只存内存、30 秒过期、被一次 `pair.begin` 用掉即焚,本机链接还会写进宿主日志——把那一行日志当作活着的密钥。那一行里手机侧只有地址种类(`(phone: public)` 或 `(phone: lan)`,没有地址时不带后缀):这一行配对日志正是操作者会粘贴到别处的那一行,公网主机名或局域网字面量写在里面,就会比它对应的配对码活得更久。
|
|
347
347
|
- **配对面板渲染的是一份活密钥,也仅止于此。** 它用同源请求读同一条仅 loopback 门禁的路由,所以在 `curl` 够得到的地方它才够得到,别处都不行。它不能签发设备令牌、不能消耗配对码、不能列名册、不能吊销设备:`pair.begin` 始终是手机那一侧的动作,吊销始终是改名册加重启宿主。二维码里装的是裸 token 或宿主自己那份 `{token,url}` 应答,因此本页的 `127.0.0.1` origin 永远不会被交给手机。
|
|
348
348
|
- **未配对连接只有三个方法的白名单。** `hello`、`pair.begin`、`pair.finish`;其余方法在分发前即回 `unpaired`,因此没有设备令牌就够不到会话面、审批面与名册面。
|
|
349
349
|
- **设备令牌只存哈希。** 名册保留公钥及其 SHA-256 指纹,从不存令牌本身,所以该文件不是凭据库。令牌丢失、轮换或被拒的处置就是重新配对——这是常规流程而非异常路径(重新签发一条 bootstrap 链接,或在桌面配对流程里重扫),且从不需要手工改名册。
|
package/lib/client.js
CHANGED
|
@@ -1211,6 +1211,36 @@ window.__ModuleLoader__.load({
|
|
|
1211
1211
|
});
|
|
1212
1212
|
QRCodeSVG.displayName = "QRCodeSVG";
|
|
1213
1213
|
//#endregion
|
|
1214
|
+
//#region src/core/pair-address.ts
|
|
1215
|
+
/**
|
|
1216
|
+
* Hosts a phone can only reach from the same network: the private IPv4 ranges,
|
|
1217
|
+
* the unspecified address, and the IPv6 loopback, unique-local and link-local
|
|
1218
|
+
* prefixes. IPv4-mapped IPv6 and anything else this does not place stays public,
|
|
1219
|
+
* because the failure this predicate may never have is printing a name the host
|
|
1220
|
+
* did not vouch for.
|
|
1221
|
+
*/
|
|
1222
|
+
const LAN_HOST_RE = /^(?:localhost|0\.0\.0\.0|(?:(?:10|127)(?:\.\d{1,3}){3}|192\.168(?:\.\d{1,3}){2}|172\.(?:1[6-9]|2\d|3[01])(?:\.\d{1,3}){2}|169\.254(?:\.\d{1,3}){2})|\[(?:::1|f[cd][0-9a-f]{2}:|fe[89ab][0-9a-f]:)[0-9a-f:]*\])$/i;
|
|
1223
|
+
/** The hostname a URL carries, or null when the value is not a URL at all. */
|
|
1224
|
+
function hostnameOf(origin) {
|
|
1225
|
+
try {
|
|
1226
|
+
return new URL(origin).hostname;
|
|
1227
|
+
} catch {
|
|
1228
|
+
return null;
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
/**
|
|
1232
|
+
* Whether a located origin answers only inside this network.
|
|
1233
|
+
* @param origin - the located origin, or null when there is none.
|
|
1234
|
+
* @param source - where the host said that origin came from.
|
|
1235
|
+
* @returns true when a phone must be on the same network to dial it.
|
|
1236
|
+
*/
|
|
1237
|
+
function isLanOrigin(origin, source) {
|
|
1238
|
+
if (source === "lan") return true;
|
|
1239
|
+
if (origin === null) return false;
|
|
1240
|
+
const host = hostnameOf(origin);
|
|
1241
|
+
return host !== null && LAN_HOST_RE.test(host);
|
|
1242
|
+
}
|
|
1243
|
+
//#endregion
|
|
1214
1244
|
//#region src/client/semantic.ts
|
|
1215
1245
|
/**
|
|
1216
1246
|
* Semantic attribute values for the protocol v1 pairing panel (contract:
|
|
@@ -1269,8 +1299,8 @@ window.__ModuleLoader__.load({
|
|
|
1269
1299
|
//#region src/client/PairPanel.tsx
|
|
1270
1300
|
/**
|
|
1271
1301
|
* The protocol v1 pairing panel: the QR symbol, the countdown with its expiry
|
|
1272
|
-
* state, the
|
|
1273
|
-
* keep a fresh code on screen.
|
|
1302
|
+
* state, the line that says which kind of address the code carries, and the two
|
|
1303
|
+
* actions that keep a fresh code on screen.
|
|
1274
1304
|
*
|
|
1275
1305
|
* The shell is the official headless `Modal` and every action is the official
|
|
1276
1306
|
* `Button`, so the overlay, the mask, the card, the focus trap, the Escape
|
|
@@ -1326,6 +1356,7 @@ window.__ModuleLoader__.load({
|
|
|
1326
1356
|
const canCopy = !expired && payload !== "";
|
|
1327
1357
|
const primaryLabel = state.kind === "failed" || state.kind === "unreachable" ? t("action.retry") : t("pair.refresh");
|
|
1328
1358
|
const located = ready && state.pairingUrl !== null;
|
|
1359
|
+
const onLan = located && isLanOrigin(state.origin, state.originSource);
|
|
1329
1360
|
(0, react.useLayoutEffect)(() => {
|
|
1330
1361
|
const element = panel.current;
|
|
1331
1362
|
if (element === null) return;
|
|
@@ -1452,7 +1483,11 @@ window.__ModuleLoader__.load({
|
|
|
1452
1483
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
1453
1484
|
className: panel_module_css_default.address,
|
|
1454
1485
|
"data-tone": located ? "plain" : "warning",
|
|
1455
|
-
children: [
|
|
1486
|
+
children: [
|
|
1487
|
+
ready && located && !onLan && t("origin.public"),
|
|
1488
|
+
ready && onLan && t("origin.lan", { origin: state.origin ?? "" }),
|
|
1489
|
+
ready && !located && t("origin.missing", { host })
|
|
1490
|
+
]
|
|
1456
1491
|
}),
|
|
1457
1492
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1458
1493
|
className: panel_module_css_default.hint,
|
|
@@ -1574,6 +1609,7 @@ window.__ModuleLoader__.load({
|
|
|
1574
1609
|
issuedAt,
|
|
1575
1610
|
expiresAt: outcome.expiresAt,
|
|
1576
1611
|
origin: outcome.origin,
|
|
1612
|
+
originSource: outcome.originSource,
|
|
1577
1613
|
pairingUrl: outcome.pairingUrl
|
|
1578
1614
|
};
|
|
1579
1615
|
case "forbidden": return { kind: "forbidden" };
|
|
@@ -1678,22 +1714,6 @@ window.__ModuleLoader__.load({
|
|
|
1678
1714
|
}
|
|
1679
1715
|
//#endregion
|
|
1680
1716
|
//#region src/client/pair-token.ts
|
|
1681
|
-
/**
|
|
1682
|
-
* The panel's one wire call: read the one-shot bootstrap token from this
|
|
1683
|
-
* package's own Host route.
|
|
1684
|
-
*
|
|
1685
|
-
* The route is same-origin and document-relative (the GUI is served with
|
|
1686
|
-
* `<base href="./">`, so a sub-path deployment resolves it against its entry
|
|
1687
|
-
* directory instead of escaping to the origin root — the same rule
|
|
1688
|
-
* `dsh-remote-web-ui`'s pair API follows). It is NOT consumed here: the panel
|
|
1689
|
-
* only displays the secret, and the phone spends it in `pair.begin`, so a
|
|
1690
|
-
* mis-click on "new code" voids a token without ever pairing a device.
|
|
1691
|
-
*
|
|
1692
|
-
* `403` is a fact, not an error: the loopback gate in `core/loopback.ts`
|
|
1693
|
-
* refuses any page whose socket or `Host` is not this machine, which is exactly
|
|
1694
|
-
* the case the panel must name out loud.
|
|
1695
|
-
* @module dsh-remote-bridge/client/pair-token
|
|
1696
|
-
*/
|
|
1697
1717
|
/** Document-relative form of the Host route, for a page served under any base. */
|
|
1698
1718
|
const PAIR_TOKEN_URL = "/remote-bridge/pair/token".replace(/^\/+/, "");
|
|
1699
1719
|
/** Read a string field, treating a missing, mistyped or empty value as absent. */
|
|
@@ -1751,12 +1771,15 @@ window.__ModuleLoader__.load({
|
|
|
1751
1771
|
};
|
|
1752
1772
|
const origin = stringOrNull(body.origin);
|
|
1753
1773
|
const candidate = stringOrNull(body.pairingUrl);
|
|
1774
|
+
const pairingUrl = candidate !== null && /^wss?:\/\/\S+$/.test(candidate) ? candidate : null;
|
|
1775
|
+
const source = body.originSource;
|
|
1754
1776
|
return {
|
|
1755
1777
|
kind: "ok",
|
|
1756
1778
|
token,
|
|
1757
1779
|
expiresAt,
|
|
1758
1780
|
origin,
|
|
1759
|
-
|
|
1781
|
+
originSource: source === "realtime" || source === "env" || source === "lan" ? source : null,
|
|
1782
|
+
pairingUrl
|
|
1760
1783
|
};
|
|
1761
1784
|
}
|
|
1762
1785
|
//#endregion
|
|
@@ -2248,11 +2271,15 @@ window.__ModuleLoader__.load({
|
|
|
2248
2271
|
*
|
|
2249
2272
|
* The panel has one job — put the live one-shot code in front of the operator as
|
|
2250
2273
|
* a QR symbol — so its copy carries what to do with the symbol, how long it
|
|
2251
|
-
* lives,
|
|
2274
|
+
* lives, what kind of address the phone will dial, why the code is single-use,
|
|
2252
2275
|
* and that the app is still in testing: the reader is told what they are joining
|
|
2253
|
-
* and where to ask about it. No key
|
|
2254
|
-
*
|
|
2255
|
-
*
|
|
2276
|
+
* and where to ask about it. No key renders the public origin: the symbol
|
|
2277
|
+
* already carries it, and a durable public hostname printed as text would
|
|
2278
|
+
* outlive every screenshot it appears in. A LAN literal is not that fact — it
|
|
2279
|
+
* answers only inside the network this page is already on — so the LAN line
|
|
2280
|
+
* keeps naming it. No key states how the host finds either address, and no key
|
|
2281
|
+
* names the wire protocol: both are implementation facts the reader cannot act
|
|
2282
|
+
* on.
|
|
2256
2283
|
*
|
|
2257
2284
|
* The card's keys say only what the transcript row can act on: whether the page
|
|
2258
2285
|
* is still waiting for the operator, that it is over, that this desktop renders
|
|
@@ -2270,7 +2297,8 @@ window.__ModuleLoader__.load({
|
|
|
2270
2297
|
"pair.expired": "配对码已过期",
|
|
2271
2298
|
"pair.refresh": "重新取码",
|
|
2272
2299
|
"pair.usedHint": "配对码一次性有效:iPhone 一开始配对就作废,重新取码也会作废上一张。",
|
|
2273
|
-
"origin.
|
|
2300
|
+
"origin.public": "二维码已包含公网地址,扫码后 iPhone 自动连上这台电脑",
|
|
2301
|
+
"origin.lan": "二维码指向局域网地址 {origin},iPhone 需与本机在同一网络",
|
|
2274
2302
|
"origin.missing": "没有找到公网地址:先在 App 里把连接地址填成你的公网中继,再扫码。本页的 {host} 只有本机能连。",
|
|
2275
2303
|
"community.invite": "iOS App 还在内测,欢迎来 Discord 交流",
|
|
2276
2304
|
"forbidden.title": "这个页面不是从本机打开的",
|
|
@@ -2303,7 +2331,8 @@ window.__ModuleLoader__.load({
|
|
|
2303
2331
|
"pair.expired": "The pairing code expired",
|
|
2304
2332
|
"pair.refresh": "New code",
|
|
2305
2333
|
"pair.usedHint": "The code is single-use: pairing spends it, and a new code voids the previous one.",
|
|
2306
|
-
"origin.
|
|
2334
|
+
"origin.public": "The QR code carries the public address: the iPhone connects to this computer as soon as it scans",
|
|
2335
|
+
"origin.lan": "The QR code points at the LAN address {origin}: the iPhone must be on the same network",
|
|
2307
2336
|
"origin.missing": "No public address found: set the connection address in the app to your public relay first, then scan. {host} (this page) is reachable only from this machine.",
|
|
2308
2337
|
"community.invite": "The iOS app is in beta. Come talk to us on Discord",
|
|
2309
2338
|
"forbidden.title": "This page is not open on this machine",
|