dsh-notify-me 1.14.5 → 1.14.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/README.en.md +7 -4
- package/README.md +7 -4
- package/lib/client.js +26 -4
- package/lib/index.js +39 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to **dsh-notify-me** are documented here.
|
|
4
4
|
|
|
5
|
+
## [1.14.7] — 2026-10-27
|
|
6
|
+
|
|
7
|
+
### 修复
|
|
8
|
+
|
|
9
|
+
- **「恢复默认设置」写不进去时也会说了**:`resetConfig()` 以前把 `localStorage.removeItem` 的失败吞掉,设置页照样提示「已恢复默认设置」,刷新之后旧配置又回来。现在它和保存走同一条 `configWriteFailed`,`debug().configStored` 为假、页面上写明「设置没能保存」。
|
|
10
|
+
|
|
11
|
+
### 文档
|
|
12
|
+
|
|
13
|
+
- README 中英:提醒渠道补上 Linux;外部推送写明关掉转发会取消已排队的重试、服务码非成功值记失败、2xx 但不是该服务的 JSON 记「已送出不可确认」;控制台示例补 `hostEnv` 与 `debug()` 的 `raiseChannel` / `raiseLast` / `configStored`。
|
|
14
|
+
- 致谢新增 unnamed42([#21](https://github.com/chromoany/dsh-notify-me/issues/21) / [#22](https://github.com/chromoany/dsh-notify-me/pull/22):Linux 上 `dsh://open` 抬窗失效的报障与补丁)。11 张贡献者头像统一成同一套 48×48 圆形遮罩,`dunxuan`、`Donald-Yip` 之前分别是方形和自带 alpha。
|
|
15
|
+
- `docs/listing.md` 版本口径同步到 1.14.7。
|
|
16
|
+
|
|
17
|
+
### 测试
|
|
18
|
+
|
|
19
|
+
- `storageFailureFeedback()` 现在也覆盖写失败后的 `resetConfig()`:`configStored` 仍为假,提示行还在。
|
|
20
|
+
|
|
21
|
+
## [1.14.6] — 2026-10-27
|
|
22
|
+
|
|
23
|
+
### 修复
|
|
24
|
+
|
|
25
|
+
- **监听器只绑一个具体局域网 IP 时,桌面端点通知不再抬不起窗**:抬窗路由的闸门只认 loopback 对端与 `Host`,而 `webServer` 可以被配置成只绑一块网卡;那种情况下壳按绑定地址拨号,请求的对端和 `Host` 都是那个 IP,被 `403 bad-remote` / `bad-host` 挡掉。现在闸门额外接受「恰好是监听器自己绑定的那个 IP」(`webServer.host`)作对端与 `Host`;局域网里别的机器连过来源地址不是这个 IP,照旧拒绝。
|
|
26
|
+
- **会话基线不再随子代理会话一直涨**:`prevById` 在会话首次出现时新增,消失后永远保留。长开的页面上子代理会话来来去去,`debug().sessionBaselines` 只增不减。现在连续 40 次列表更新都缺席的行会丢掉基线(顺带清掉 `doneFiredAt`);短暂消失仍保留,不影响「消失再出现不补报」的语义。
|
|
27
|
+
|
|
28
|
+
### 测试
|
|
29
|
+
|
|
30
|
+
- `host-route-test.mjs` 用 `webServer.host = 192.168.1.5` 的假宿主补了四条:本机自拨的绑定地址放行、局域网别处的客户端 `bad-remote`、自拨但 `Host` 是别的域名 `bad-host`、跨源 `Origin` 照旧拒绝。
|
|
31
|
+
- 冒烟新增 `vanishedBaselinesPruned()`:短暂缺席保留基线,连续 40+ 次更新后清零。
|
|
32
|
+
|
|
33
|
+
### 文档
|
|
34
|
+
|
|
35
|
+
- README / SECURITY 中英的闸门说明补上「或监听器自己绑定的那个 IP」。
|
|
36
|
+
- `docs/listing.md` 版本口径同步到 1.14.6。
|
|
37
|
+
|
|
5
38
|
## [1.14.5] — 2026-10-27
|
|
6
39
|
|
|
7
40
|
### 修复
|
package/README.en.md
CHANGED
|
@@ -80,7 +80,7 @@ Web users can also test the approval buttons, which then appear on the notificat
|
|
|
80
80
|
window.__dshNotifyMe.test("done") // "reply finished" sample
|
|
81
81
|
window.__dshNotifyMe.test("attention") // "needs you" sample
|
|
82
82
|
window.__dshNotifyMe.test("approval") // Approve / Reject when the bridge is available; a plain notification otherwise (which is what Desktop gets)
|
|
83
|
-
window.__dshNotifyMe.debug() //
|
|
83
|
+
window.__dshNotifyMe.debug() // bridge ("active" = buttons work), raiseChannel, the last raise attempt in raiseLast, a refused toast's platform message in lastToastReject, and configStored for whether the settings really persisted
|
|
84
84
|
```
|
|
85
85
|
|
|
86
86
|
If no test notification appears, check in this order: whether the notification permission was declined (click once on the page and choose **Allow**; or address-bar lock → Site settings → Notifications → Allow → reload), whether DSH was restarted after installing, and whether the browser's notifications are switched off in the OS settings.
|
|
@@ -160,7 +160,8 @@ Off by default. Supports Discord Webhook / Bark / Gotify / Feishu group bots / S
|
|
|
160
160
|
|
|
161
161
|
- **External notifications** (default off): forward each alert to your own push endpoints as well, so it reaches you away from the machine; any number of targets, each of which can be enabled or disabled on its own. "Forward 'needs you'" and "Forward 'reply finished'" switch independently; **Send test notification** sends one test message to every target (not limited by those two switches, and never pretending to be a real alert). Forwarding follows exactly the same trigger rules as local alerts ("stay quiet for the conversation on screen" and friends apply to it too); the alert text is sent as-is to the addresses you fill in, so **only use endpoints you trust**;
|
|
162
162
|
- **What each target takes**: Discord — the webhook URL; Bark — `https://api.day.app/<device key>`; Gotify — `https://<server>/message?token=<app token>`; Feishu — the group-bot webhook plus an optional verification secret; ServerChan — the full `…/send/<SendKey>.send` URL; WxPusher — the appToken and the receiver UID; a custom endpoint receives one POST of JSON: `{source, event, title, body, text, sessionId, time}`;
|
|
163
|
-
- **Reliable delivery**: failures that look transient (network error, 5xx, 429) are retried after 2 s and 6 s; anything else stops at once. A delivery that still fails is recorded in the failure log (10 entries at most — title and body snippet plus host only, never the full endpoint), which the settings page shows and can clear;
|
|
163
|
+
- **Reliable delivery**: failures that look transient (network error, 5xx, 429) are retried after 2 s and 6 s; anything else stops at once. Switching forwarding off or deleting a target cancels a retry that is already on a timer — it is not counted as a failure and never reaches the failure log. A delivery that still fails is recorded in the failure log (10 entries at most — title and body snippet plus host only, never the full endpoint), which the settings page shows and can clear;
|
|
164
|
+
- **Service codes and "unverified"**: a 2xx from Feishu / ServerChan / WxPusher also carries a service code (`0` for Feishu and ServerChan, `1000` for WxPusher); a wrong code is recorded as a failure with the service's own message, and a 2xx whose body is not that service's JSON (empty, or a proxy/WAF HTML page) is "sent but unverified" rather than a success;
|
|
164
165
|
- **Per-target state**: the right end of each target row shows how its last delivery went (last delivery ok / sent-unverified / failed with the reason) next to a switch of its own, so an endpoint that is temporarily down can be turned off alone instead of muting a whole alert kind;
|
|
165
166
|
- **Signing**: a custom target with a secret sends `X-DSH-Notify-Signature` (HMAC-SHA256 over the body, `sha256=<hex>`); a Feishu target with a secret carries `timestamp` / `sign` in the body per Feishu's own algorithm;
|
|
166
167
|
- **Message template** (optional): Feishu / ServerChan / WxPusher / custom targets accept a template with `{{title}}` `{{body}}` `{{event}}` `{{time}}` `{{session}}`; empty means "title, newline, body";
|
|
@@ -185,7 +186,7 @@ The last block inside Advanced. The page protocol is detected automatically to t
|
|
|
185
186
|
|
|
186
187
|
| Channel | What it does |
|
|
187
188
|
| --- | --- |
|
|
188
|
-
| System notification | Through the browser into the Windows
|
|
189
|
+
| System notification | Through the browser into the Windows / macOS / Linux notification centre; clicking it returns to the conversation it came from. Web can carry Approve / Reject |
|
|
189
190
|
| Sound | WebAudio cue by default, with different patterns for "needs you" and "done"; swap in a custom audio file, or hand the sound over to the system notification sound |
|
|
190
191
|
| Tab title | `🔔 Action needed · …` / `✅ Reply finished · …`, following the alert language; gone once you open that session, and both markers can be up at the same time |
|
|
191
192
|
| External push (optional, default off) | Forwards the same alert to Discord / Bark / Gotify / Feishu / ServerChan / WxPusher / a custom webhook |
|
|
@@ -241,6 +242,7 @@ window.__dshNotifyMe.setConfig({
|
|
|
241
242
|
volume: 0.5, // volume 0..1
|
|
242
243
|
autoFocus: true, // a toast click returns to the conversation that raised it
|
|
243
244
|
quickActions: true, // Approve / Reject buttons on approval toasts
|
|
245
|
+
hostEnv: "auto", // runtime: 'auto' detect | 'desktop' force the app | 'web' force the browser
|
|
244
246
|
externalEnabled: false, // external forwarding master switch (default off: no endpoint, nothing is sent)
|
|
245
247
|
externalAttention: true, // forward "needs you" (exactly the same trigger rules as local alerts)
|
|
246
248
|
externalDone: true, // forward "reply finished"
|
|
@@ -311,7 +313,7 @@ Measured with `powershell.exe` 5.1 in one round: window in front ×3, minimized
|
|
|
311
313
|
|
|
312
314
|
Security-wise the plugin opens exactly one exact route. Requests outside the vocabulary are refused: anything other than GET / HEAD / POST answers `405` (including a preflight `OPTIONS`, and it never returns a CORS header), a non-Windows host (Web, macOS / Linux, plain Node) `501` (macOS / Linux use the deep link and never reach this route), and a missing `x-dsh-notify-me-focus: focus` header `403`.
|
|
313
315
|
|
|
314
|
-
That header is only a "this came from the page" marker, not the defence — a DNS-rebinding page is same-origin with the address it resolved, so it can send any custom header and triggers no preflight. The real gate is three checks: the peer address must be loopback; `Host` must be a loopback name (`127.0.0.1` / `localhost` / `[::1]`, port optional), because the shell deletes `host` when forwarding and fetch refills it from the
|
|
316
|
+
That header is only a "this came from the page" marker, not the defence — a DNS-rebinding page is same-origin with the address it resolved, so it can send any custom header and triggers no preflight. The real gate is three checks: the peer address must be loopback, or exactly the address the listener itself is bound to; `Host` must be a loopback name (`127.0.0.1` / `localhost` / `[::1]`, port optional) or that same bind address, because the shell deletes `host` when forwarding and fetch refills it from the URL it dialled, while a rebound page still has the attacker's domain in `Host`; and an `Origin`, when present, must be same-origin with that `Host`. Any failure answers `403`, with `reason` set to `bad-remote` / `bad-host` / `cross-origin`. A `GET` returns only `{ok, route, enabled, desktop, platform}`, so after installing you can open it in a browser to confirm the route is there. Calls within 400 ms coalesce into one, and a script that has not answered after 8 s is killed and counted as a failure.
|
|
315
317
|
|
|
316
318
|
The cases where it will not raise are the same ones listed under [Known limitations](#known-limitations) (elevated window, another virtual desktop, a foreground repeatedly stolen, a window hidden to the tray with `SW_HIDE`); they all answer `202` truthfully and the conversation switch still happens.
|
|
317
319
|
|
|
@@ -381,6 +383,7 @@ powershell -NoProfile -File lib/focus-window.ps1 -ProcessId 0 # the last line
|
|
|
381
383
|
| <a href="https://github.com/shrekcg"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/shrekcg.png" width="40" height="40" alt="@shrekcg"></a> | [#16](https://github.com/chromoany/dsh-notify-me/pull/16): away detection (`idleMinutes`), reply-done routing (`donePolicy`), auto-dismiss (`autoDismiss`) |
|
|
382
384
|
| <a href="https://github.com/Donald-Yip"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/Donald-Yip.png" width="40" height="40" alt="@Donald-Yip"></a> | [#18](https://github.com/chromoany/dsh-notify-me/issues/18): the report that a Windows notification tag over the 64-character cap made the platform silently reject the approval test toast |
|
|
383
385
|
| <a href="https://github.com/dunxuan"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/dunxuan.png" width="40" height="40" alt="@dunxuan"></a> | [#20](https://github.com/chromoany/dsh-notify-me/issues/20): the report that alerts for the open session showed a placeholder instead of the session title |
|
|
386
|
+
| <a href="https://github.com/unnamed42"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/unnamed42.png" width="40" height="40" alt="@unnamed42"></a> | [#21](https://github.com/chromoany/dsh-notify-me/issues/21) / [#22](https://github.com/chromoany/dsh-notify-me/pull/22): the Linux `dsh://open` raise-path report and patch, which brought the deep link back on macOS / Linux in 1.14.4 |
|
|
384
387
|
|
|
385
388
|
Attribution policy: external PRs are landed as maintainer commits — the original commit is not reused and no Co-authored-by trailer is added, so GitHub's contributors graph lists the maintainer only and contributors are credited above.
|
|
386
389
|
|
package/README.md
CHANGED
|
@@ -80,7 +80,7 @@ Web 用户可再测审批按钮,通知上会带「同意 / 拒绝」。桌面
|
|
|
80
80
|
window.__dshNotifyMe.test("done") // 「完成」示例
|
|
81
81
|
window.__dshNotifyMe.test("attention") // 「需要你」示例
|
|
82
82
|
window.__dshNotifyMe.test("approval") // 桥可用时带「同意 / 拒绝」按钮;否则只发普通通知(桌面端即如此)
|
|
83
|
-
window.__dshNotifyMe.debug() //
|
|
83
|
+
window.__dshNotifyMe.debug() // 桥接看 bridge(active = 按钮可用)、抬窗通道 raiseChannel、最近一次尝试 raiseLast、平台拒发原文 lastToastReject、设置是否真存下来 configStored
|
|
84
84
|
```
|
|
85
85
|
|
|
86
86
|
没有测试通知时,先检查:通知权限是否被拒绝(在页面上点一下 → 选「允许」;或地址栏锁 → 站点设置 → 通知 → 允许 → 刷新)、装完没重启 DSH、系统设置里浏览器通知被关。
|
|
@@ -160,7 +160,8 @@ dsh-notify-me 把「监督」和「守在屏幕前」解耦:只在真的出现
|
|
|
160
160
|
|
|
161
161
|
- **外部通知**(默认关):把提醒同时转发到你自己的推送端点,人不在电脑前也能收到;可加多个目标,每个目标可单独启停。「转发「需要你」」「转发「回复完成」」各自独立开关;**发送测试通知**往所有目标发一条测试消息(不受这两类开关限制,也不会冒充真提醒)。转发跟本地提醒走同一套触发规则(「当前对话不弹通知」等开关同样管它);提醒正文会原样发往你填的地址,**只填你自己信任的端点**;
|
|
162
162
|
- **各目标的填法**:Discord 填 Webhook 地址;Bark 填 `https://api.day.app/<设备密钥>`;Gotify 填 `https://<服务器>/message?token=<应用令牌>`;飞书填群机器人 Webhook,可选填签名校验密钥;Server酱 填 `…/send/<SendKey>.send` 完整地址;WxPusher 填 appToken 与接收者 UID;自定义端点收一条 POST JSON:`{source, event, title, body, text, sessionId, time}`;
|
|
163
|
-
- **可靠投递**:明显是临时故障的失败(网络中断、5xx、429)按 2 秒 / 6
|
|
163
|
+
- **可靠投递**:明显是临时故障的失败(网络中断、5xx、429)按 2 秒 / 6 秒自动重试两次,其它错误立即停;关掉「外部通知」总开关或删掉某个目标后,已经排在定时器上的重试立刻作废,既不算失败也不进失败记录;重试仍失败会把这一条记进「失败记录」(最多 10 条,只留标题与正文摘要和主机名,不留完整端点),设置页能一眼看到并清空;
|
|
164
|
+
- **服务码与「不可确认」**:飞书 / Server酱 / WxPusher 的 2xx 还会读返回体里的服务码(飞书与 Server酱是 `0`,WxPusher 是 `1000`),码不对按失败记并带服务端文案;2xx 但正文不是该服务的 JSON(空白、代理或 WAF 的网页)记「已送出不可确认」,不冒充成功;
|
|
164
165
|
- **每个目标的状态**:目标行右侧显示它最近一次投递的结果(上次成功 / 上次已送出但不可确认 / 上次失败 + 原因),并各自带一个启停开关——某个端点临时不可用就单独关掉它,不用关掉整类事件;
|
|
165
166
|
- **签名**:自定义目标填了签名密钥时,请求带 `X-DSH-Notify-Signature`(对请求体做 HMAC-SHA256,`sha256=<hex>`);飞书填了签名密钥时按官方算法在请求体里带 `timestamp` / `sign`;
|
|
166
167
|
- **消息模板**(可选):飞书 / Server酱 / WxPusher / 自定义目标可填模板,占位符 `{{title}}` `{{body}}` `{{event}}` `{{time}}` `{{session}}`,留空默认是「标题 + 换行 + 正文」;
|
|
@@ -185,7 +186,7 @@ dsh-notify-me 把「监督」和「守在屏幕前」解耦:只在真的出现
|
|
|
185
186
|
|
|
186
187
|
| 渠道 | 表现 |
|
|
187
188
|
| --- | --- |
|
|
188
|
-
| 系统通知 | 经浏览器进 Windows
|
|
189
|
+
| 系统通知 | 经浏览器进 Windows / macOS / Linux 的系统通知中心,点击回到对应对话;Web 端可带「同意 / 拒绝」 |
|
|
189
190
|
| 提示音 | 默认 WebAudio 合成音,「需要你」与「完成」音型不同;可换自定义音频,或交给系统通知音 |
|
|
190
191
|
| 标签页标题 | `🔔 需要你 · …` / `✅ 回复完成 · …`(随通知语言切换),打开对应会话即消失;两种标记可同时出现 |
|
|
191
192
|
| 外部推送(可选,默认关) | 把同一条提醒转发到 Discord / Bark / Gotify / 飞书 / Server酱 / WxPusher / 自定义 Webhook |
|
|
@@ -241,6 +242,7 @@ window.__dshNotifyMe.setConfig({
|
|
|
241
242
|
volume: 0.5, // 音量 0~1
|
|
242
243
|
autoFocus: true, // 点通知回到提醒所属的对话
|
|
243
244
|
quickActions: true, // 审批通知上的「同意 / 拒绝」按钮
|
|
245
|
+
hostEnv: "auto", // 运行环境:'auto' 自动识别 | 'desktop' 强制桌面端 | 'web' 强制 Web
|
|
244
246
|
externalEnabled: false, // 外部通知转发主开关(默认关:不填端点就什么都不发)
|
|
245
247
|
externalAttention: true, // 转发「需要你」(触发规则跟本地提醒完全一致)
|
|
246
248
|
externalDone: true, // 转发「回复完成」
|
|
@@ -310,7 +312,7 @@ Windows 的激活顺序是实的:已经在前台就什么都不做(最常见
|
|
|
310
312
|
|
|
311
313
|
安全上只开一条 exact 路由。词表之外的请求一律拒:非 GET / HEAD / POST 回 `405`(包括预检的 `OPTIONS`,且从不回任何 CORS 头),非 Windows 宿主(Web 版、macOS / Linux、纯 Node)回 `501`(macOS / Linux 走深链,不经过这条路由),缺 `x-dsh-notify-me-focus: focus` 头回 `403`。
|
|
312
314
|
|
|
313
|
-
那个头只是「这是页面发来的」标记,不是防线——DNS rebinding 的恶意页对目标地址而言是同源的,能带任意自定义头、也不触发预检。真正的闸门是三层:对端地址必须是 loopback;`Host` 必须是 loopback 名(`127.0.0.1` / `localhost` / `[::1]
|
|
315
|
+
那个头只是「这是页面发来的」标记,不是防线——DNS rebinding 的恶意页对目标地址而言是同源的,能带任意自定义头、也不触发预检。真正的闸门是三层:对端地址必须是 loopback,或恰好是监听器自己绑定的那个 IP;`Host` 必须是 loopback 名(`127.0.0.1` / `localhost` / `[::1]`,可带端口)或同一个绑定地址,因为壳转发时 `host` 已被删掉、由 fetch 按它拨号的 URL 重填,而 rebinding 的页面 Host 仍是攻击者域名;带了 `Origin` 就必须和 `Host` 同源。任一条不符回 `403`,`reason` 分别是 `bad-remote` / `bad-host` / `cross-origin`。`GET` 只回 `{ok, route, enabled, desktop, platform}`,装完可以先用浏览器打开确认路由在不在。400 毫秒内的重复调用合并成一次,脚本超过 8 秒没回话就 kill 掉按失败处理。
|
|
314
316
|
|
|
315
317
|
抬不起来的几种场合与[已知限制](#已知限制)里列的一致(提权窗口、另一虚拟桌面、前台被反复抢走、`SW_HIDE` 托盘隐藏),一律如实回 `202`、对话照常切。
|
|
316
318
|
|
|
@@ -380,6 +382,7 @@ powershell -NoProfile -File lib/focus-window.ps1 -ProcessId 0 # 末行应是 F
|
|
|
380
382
|
| <a href="https://github.com/shrekcg"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/shrekcg.png" width="40" height="40" alt="@shrekcg"></a> | [#16](https://github.com/chromoany/dsh-notify-me/pull/16):离开判定 `idleMinutes`、「回复完成」判定 `donePolicy`、自动消失 `autoDismiss` |
|
|
381
383
|
| <a href="https://github.com/Donald-Yip"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/Donald-Yip.png" width="40" height="40" alt="@Donald-Yip"></a> | [#18](https://github.com/chromoany/dsh-notify-me/issues/18):Windows 通知 tag 超过 64 字符上限、审批测试通知被平台静默拒收的报告 |
|
|
382
384
|
| <a href="https://github.com/dunxuan"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/dunxuan.png" width="40" height="40" alt="@dunxuan"></a> | [#20](https://github.com/chromoany/dsh-notify-me/issues/20):当前会话的通知正文用占位符、未取会话标题的报告 |
|
|
385
|
+
| <a href="https://github.com/unnamed42"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/unnamed42.png" width="40" height="40" alt="@unnamed42"></a> | [#21](https://github.com/chromoany/dsh-notify-me/issues/21) / [#22](https://github.com/chromoany/dsh-notify-me/pull/22):Linux 上 `dsh://open` 抬窗失效的报障与补丁,1.14.4 起 macOS / Linux 恢复深链抬窗 |
|
|
383
386
|
|
|
384
387
|
署名口径:本仓库收编外部 PR 时以维护者提交落地——不沿用原 commit、不挂 Co-authored-by,GitHub 的 contributors 图只显示维护者,贡献者以上面的致谢署名。
|
|
385
388
|
|
package/lib/client.js
CHANGED
|
@@ -1944,6 +1944,10 @@
|
|
|
1944
1944
|
// prevById: per-session-id baseline of what we have already reported.
|
|
1945
1945
|
// { running: bool, pendingKeys: string[] , doneArmed: bool, seeded: bool }
|
|
1946
1946
|
var prevById = Object.create(null);
|
|
1947
|
+
// A row absent from this many list updates is gone, not asleep: dropping
|
|
1948
|
+
// its baseline bounds the map on long-lived pages (subagent sessions come
|
|
1949
|
+
// and go), while a short absence keeps the no-replay guarantee.
|
|
1950
|
+
var BASELINE_MISSING_LIMIT = 40;
|
|
1947
1951
|
var faceSub = null; // current session face unsubscribe
|
|
1948
1952
|
var currentFaceId = null;
|
|
1949
1953
|
var listStore = null;
|
|
@@ -2082,7 +2086,8 @@
|
|
|
2082
2086
|
running: runningNow,
|
|
2083
2087
|
pendingKeys: pendingNow.map(function (p) { return p.key; }),
|
|
2084
2088
|
completed: !!row.completed,
|
|
2085
|
-
seeded: true
|
|
2089
|
+
seeded: true,
|
|
2090
|
+
missing: 0
|
|
2086
2091
|
};
|
|
2087
2092
|
|
|
2088
2093
|
// a wait we alerted about has been resolved -> drop the title marker
|
|
@@ -2191,7 +2196,19 @@
|
|
|
2191
2196
|
if (!sum) continue;
|
|
2192
2197
|
evalListRow(sid, sum, cur);
|
|
2193
2198
|
}
|
|
2194
|
-
//
|
|
2199
|
+
// Sessions that vanished: keep the baseline for a while (they may
|
|
2200
|
+
// reappear), then drop it. Without the sweep one entry outlived every
|
|
2201
|
+
// subagent session that ever ran on the page.
|
|
2202
|
+
var gone;
|
|
2203
|
+
for (gone in prevById) {
|
|
2204
|
+
if (byId[gone]) continue;
|
|
2205
|
+
var goneEntry = prevById[gone];
|
|
2206
|
+
goneEntry.missing = (goneEntry.missing || 0) + 1;
|
|
2207
|
+
if (goneEntry.missing > BASELINE_MISSING_LIMIT) {
|
|
2208
|
+
delete prevById[gone];
|
|
2209
|
+
delete doneFiredAt[gone];
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2195
2212
|
} catch (e) {}
|
|
2196
2213
|
}
|
|
2197
2214
|
|
|
@@ -2406,7 +2423,7 @@
|
|
|
2406
2423
|
});
|
|
2407
2424
|
} catch (e) {}
|
|
2408
2425
|
// keep in sync with package.json "version" on every release
|
|
2409
|
-
api.version = "1.14.
|
|
2426
|
+
api.version = "1.14.7";
|
|
2410
2427
|
api.setConfig = function (patch) { return setConfigLocal(patch); };
|
|
2411
2428
|
api.resetConfig = function () {
|
|
2412
2429
|
try {
|
|
@@ -2421,7 +2438,12 @@
|
|
|
2421
2438
|
localStorage.removeItem(LS_EXTERNAL_DEAD);
|
|
2422
2439
|
localStorage.removeItem(LS_EXTERNAL_HEALTH);
|
|
2423
2440
|
externalHealth = {};
|
|
2424
|
-
|
|
2441
|
+
configWriteFailed = false;
|
|
2442
|
+
} catch (e) {
|
|
2443
|
+
// Same silent failure as a refused save: the reset only lives in
|
|
2444
|
+
// memory and the next reload brings the old profile back.
|
|
2445
|
+
configWriteFailed = true;
|
|
2446
|
+
}
|
|
2425
2447
|
config = readConfig();
|
|
2426
2448
|
return config;
|
|
2427
2449
|
};
|
package/lib/index.js
CHANGED
|
@@ -252,6 +252,25 @@ function splitHost(value) {
|
|
|
252
252
|
return { hostname: plain[1], port: plain[2] ?? "" };
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
+
/**
|
|
256
|
+
* Whether a peer / `Host` names the listener's own bind address.
|
|
257
|
+
*
|
|
258
|
+
* The webserver can be configured to bind one concrete LAN interface; on such a
|
|
259
|
+
* host the shell reaches it through that address, so the request arrives from
|
|
260
|
+
* this machine with the bind IP as both peer and `Host`. Accepting exactly that
|
|
261
|
+
* literal keeps the gate self-addressed: a remote LAN client connects from its
|
|
262
|
+
* own address, never the server's.
|
|
263
|
+
* @param hostname - bare hostname from the peer address or `Host` header.
|
|
264
|
+
* @param bindHost - configured bind address, if the host exposes one.
|
|
265
|
+
* @returns whether they name the same machine.
|
|
266
|
+
*/
|
|
267
|
+
function isBindAddress(hostname, bindHost) {
|
|
268
|
+
if (typeof bindHost !== "string" || bindHost.length === 0) return false;
|
|
269
|
+
const zone = bindHost.indexOf("%");
|
|
270
|
+
const text = zone === -1 ? bindHost : bindHost.slice(0, zone);
|
|
271
|
+
return bareHostname(hostname) === bareHostname(text);
|
|
272
|
+
}
|
|
273
|
+
|
|
255
274
|
/**
|
|
256
275
|
* Refuse a request that did not come from this machine's own page.
|
|
257
276
|
*
|
|
@@ -259,20 +278,21 @@ function splitHost(value) {
|
|
|
259
278
|
* also answers plain HTTP on the host port, and a DNS-rebinding page reaches
|
|
260
279
|
* that port while looking same-origin to the browser — it can send any header,
|
|
261
280
|
* including {@link RAISE_HEADER}, and no preflight fires. What it cannot forge
|
|
262
|
-
* is the connection's source address (
|
|
263
|
-
* or the `Host` header: the shell deletes the original and the fetch
|
|
264
|
-
* it from the
|
|
281
|
+
* is the connection's source address (this machine, so loopback or the bind
|
|
282
|
+
* address) or the `Host` header: the shell deletes the original and the fetch
|
|
283
|
+
* re-fills it from the URL it dialled, while a rebound page keeps its own name.
|
|
265
284
|
*
|
|
266
|
-
* So the gate is: loopback peer,
|
|
267
|
-
* with that `Host` when one is present.
|
|
285
|
+
* So the gate is: loopback or bind-address peer, the same for `Host`, and an
|
|
286
|
+
* `Origin` that agrees with that `Host` when one is present.
|
|
268
287
|
* @param req - the incoming request.
|
|
288
|
+
* @param bindHost - the listener's configured bind address, when known.
|
|
269
289
|
* @returns a short refusal reason, or `null` when the request may proceed.
|
|
270
290
|
*/
|
|
271
|
-
function gateRequest(req) {
|
|
272
|
-
const remote = req.socket?.remoteAddress ?? "";
|
|
273
|
-
if (!isLoopbackHostname(
|
|
291
|
+
function gateRequest(req, bindHost) {
|
|
292
|
+
const remote = String(req.socket?.remoteAddress ?? "").replace(/^::ffff:/i, "");
|
|
293
|
+
if (!isLoopbackHostname(remote) && !isBindAddress(remote, bindHost)) return "bad-remote";
|
|
274
294
|
const host = splitHost(req.headers.host);
|
|
275
|
-
if (host === null || !isLoopbackHostname(host.hostname)) return "bad-host";
|
|
295
|
+
if (host === null || (!isLoopbackHostname(host.hostname) && !isBindAddress(host.hostname, bindHost))) return "bad-host";
|
|
276
296
|
const origin = req.headers.origin;
|
|
277
297
|
if (typeof origin !== "string" || origin.length === 0) return null;
|
|
278
298
|
if (origin === "dsh-app://app") return null; // the desktop page, if not stripped
|
|
@@ -310,14 +330,14 @@ function respond(res, status, body) {
|
|
|
310
330
|
* whether activation is available at all; only the POST form touches the OS.
|
|
311
331
|
* @returns the web-server route handler.
|
|
312
332
|
*/
|
|
313
|
-
function createHandler() {
|
|
333
|
+
function createHandler(bindHost) {
|
|
314
334
|
return function handleFocus(req, res) {
|
|
315
335
|
const method = req.method ?? "GET";
|
|
316
336
|
if (method !== "GET" && method !== "HEAD" && method !== "POST") {
|
|
317
337
|
respond(res, 405, { ok: false, reason: "method-not-allowed" });
|
|
318
338
|
return;
|
|
319
339
|
}
|
|
320
|
-
const refusal = gateRequest(req);
|
|
340
|
+
const refusal = gateRequest(req, bindHost);
|
|
321
341
|
if (refusal !== null) {
|
|
322
342
|
respond(res, 403, { ok: false, reason: refusal });
|
|
323
343
|
return;
|
|
@@ -364,8 +384,15 @@ function createHandler() {
|
|
|
364
384
|
*/
|
|
365
385
|
export function apply(ctx) {
|
|
366
386
|
ctx.inject(["webServer"], (webCtx) => {
|
|
387
|
+
// The listener may be bound to one concrete LAN interface; read it so the
|
|
388
|
+
// gate can accept the self-addressed request the shell makes in that setup.
|
|
389
|
+
let bindHost;
|
|
390
|
+
try {
|
|
391
|
+
const server = webCtx.webServer;
|
|
392
|
+
if (server && typeof server.host === "string") bindHost = server.host;
|
|
393
|
+
} catch {}
|
|
367
394
|
webCtx.effect(
|
|
368
|
-
() => webCtx.webServer.register({ kind: "exact", path: FOCUS_ROUTE, handler: createHandler() }),
|
|
395
|
+
() => webCtx.webServer.register({ kind: "exact", path: FOCUS_ROUTE, handler: createHandler(bindHost) }),
|
|
369
396
|
"dsh-notify-me: window focus route",
|
|
370
397
|
);
|
|
371
398
|
});
|