dsh-notify-me 1.21.0 → 1.21.2
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 +26 -0
- package/LICENSE +21 -21
- package/README.en.md +8 -4
- package/README.md +8 -4
- package/lib/client.js +16 -9
- package/lib/host-fallback.js +8 -4
- package/lib/index.js +37 -10
- package/lib/mac-notify.js +8 -4
- package/lib/page-bridge.js +40 -1
- package/lib/relay.js +8 -9
- package/lib/win-toast.js +51 -15
- package/lib/win-toast.ps1 +6 -3
- package/package.json +1 -1
- package/smoke/win-toast-test.mjs +67 -7
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to **dsh-notify-me** are documented here.
|
|
4
4
|
|
|
5
|
+
## [1.21.2] — 2026-11-16
|
|
6
|
+
|
|
7
|
+
Windows 原生审批通知的「同意 / 拒绝」按钮现在真会把决定送回页面,而不是只把通知收掉。
|
|
8
|
+
|
|
9
|
+
### 修复
|
|
10
|
+
|
|
11
|
+
- **Windows 审批 Toast 的按钮点了只 dismiss、没有决定**([#41](https://github.com/chromoany/dsh-notify-me/issues/41)):Toast 原来借用 DSH 桌面壳的 AUMID(`electron.app.DeepSeek Harness`),而这个 AUMID 在注册表里挂着一个 COM Toast 激活器(`HKCU\Software\Classes\CLSID\{…}\LocalServer32` 指向 DSH 主程序)。Windows 对这种 AUMID 一律把激活交给那个 COM 服务——正文点击和按钮都一样——Toast XML 里的 `activationType="protocol"` 根本不参与派发;DSH 那一侧没有对应的 Notification 对象,按 Electron 自己的处理([electron/electron#51330](https://github.com/electron/electron/pull/51330))把动作参数丢掉。于是协议处理器一次都没跑过:通知被 dismiss,动作目录里没有文件,`approval/decided` 也不会出现。现在 Toast 改发到插件自己的 AUMID `dsh-notify-me`:首次发送前写 `HKCU\Software\Classes\AppUserModelId\dsh-notify-me`(`DisplayName` 是通知抬头,`CustomActivator` 指一个 CLSID),CLSID 只建一个空的存根、不注册 `LocalServer32`——微软文档里「不实现 COM 激活器」的替代路线,代价是 Toast 上的输入框与 in-process 激活不可用,这两样本插件都没用。当前用户级注册,不需要管理员权限;旧版借 DSH AUMID 发出去的 Toast 留在操作中心没有影响,token 本来就是单次且 3 分钟过期。真机验证(Windows 11 26200 / DSH 0.2.2-rc.3):按本改动注册自有 AUMID 与空存根后,用真实的 `lib/win-toast.ps1` 发一条审批通知,点「同意」,协议处理器收到的就是 `dsh-notify-me://approve/?token=<那条通知的 approveToken>`(Windows 会在无路径的 URI 里补一个 `/`,解析已按这个形式处理);正文点击同样会派发。
|
|
12
|
+
- **在页面里答复后原生 Toast 仍留在操作中心**:`decidePending()` 原来只关 Service Worker 那条通知,不管原生 Toast,于是操作中心里会留一条按钮已失效(token 已被消费)的通知。现在不是从 Toast 上点下来的答复,会按 tag 把原生 Toast 一起撤回。
|
|
13
|
+
|
|
14
|
+
### 测试
|
|
15
|
+
|
|
16
|
+
- `smoke/win-toast-test.mjs`:HKCU 注册命令从 3 条扩到 6 条(协议 3 条 + AUMID 的 `DisplayName` / `CustomActivator` + 空 CLSID 存根),断言默认 AUMID 是插件自己的、不是 DSH 的,且不带按钮的 Toast 也会先注册身份;另加一条归一化用例——Windows 会把无路径的 URI 改写成 `dsh-notify-me://approve/?token=…` 再交给处理器,这个形式同样要解析成决定。
|
|
17
|
+
|
|
18
|
+
## [1.21.1] — 2026-11-16
|
|
19
|
+
|
|
20
|
+
宿主 HTTP 路由补齐 DSH 的访问准入:浏览器里打开的网页不能再借着对本机回环的访问直接调用插件的路由。
|
|
21
|
+
|
|
22
|
+
### 修复
|
|
23
|
+
|
|
24
|
+
- **宿主 HTTP 路由缺少 DSH 的 Host / Origin 准入**:focus、macOS 通知、Windows Toast、页面桥接、host-fallback 健康探针、同源中继这六条 `webServer.register` 路由原来只由插件自己的 `gateRequest` 把守;DSH 对这张路由表之外的路由不做围栏,所以浏览器里打开的网页可以按地址调用它们。现在每条 handler 都先调宿主的 `connection.requestRejection(req)`(DSH 自己的路由同款:Host / Origin 围栏 + 浏览器登录态),401 / 403 原样回(`reason` 为 `unauthenticated` / `untrusted`),放行后再过原有 `gateRequest`;宿主不提供 `connection` 服务(旧版 DSH、纯 Node、离线测试)时退回原逻辑,行为不变。这一层收在 `lib/page-bridge.js` 新增的 `guardRequest()` 里,六条路由共用。
|
|
25
|
+
|
|
26
|
+
### 测试
|
|
27
|
+
|
|
28
|
+
- `smoke/host-route-test.mjs`:新增 admission 用例——假 `connection` 返回 403 → `untrusted`、返回 401 → `unauthenticated`、放行后仍被插件自己的 `Host` 闸门拒绝,并断言每个请求都先问 `requestRejection`。
|
|
29
|
+
- `smoke/win-toast-test.mjs`:新增 3g 用例——带 deny 头 → 401 `unauthenticated`、正常 `GET` 仍 200、非回环 peer 仍 403 `bad-remote`(admission 之后插件闸门继续生效)。
|
|
30
|
+
|
|
5
31
|
## [1.21.0] — 2026-11-16
|
|
6
32
|
|
|
7
33
|
点桌面通知的正文现在真能把 DSH 从最小化和托盘里拉回来;macOS 在 DSH 已经处于前台时点原生通知也会立即切到对应会话。
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 chromoany
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 chromoany
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.en.md
CHANGED
|
@@ -397,6 +397,8 @@ Security-wise the plugin opens exactly one exact route. Requests outside the voc
|
|
|
397
397
|
|
|
398
398
|
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.
|
|
399
399
|
|
|
400
|
+
All six host routes (focus, macOS notifications, Windows toasts, the page bridge, the host-fallback health probe and the same-origin relay) now also pass through a DSH admission step: when the host exposes a `connection` service, the handler first calls `connection.requestRejection(req)` — the same call DSH's own routes make, covering the Host / Origin fence and the browser session check. A 401 / 403 is relayed verbatim (`reason` `unauthenticated` / `untrusted`); only then does the plugin's own gate above run. Hosts without that service (older DSH, plain Node, the offline tests) skip it and fall back to the plugin gate, so their behaviour is unchanged. The step lives in `guardRequest()` in `lib/page-bridge.js`.
|
|
401
|
+
|
|
400
402
|
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); they all answer `202` truthfully and the conversation switch still happens. A main window hidden to the tray with `SW_HIDE` used to answer `202` outright; since 1.21.0 it is `ShowWindow(SW_SHOW)`-ed first and then goes through the same activation steps ([#40](https://github.com/chromoany/dsh-notify-me/issues/40)).
|
|
401
403
|
|
|
402
404
|
</details>
|
|
@@ -418,11 +420,11 @@ Like the window-raise route, this one registers exactly one exact path and refus
|
|
|
418
420
|
|
|
419
421
|
The page's own `new Notification()` is not refused on Windows Desktop, but it cannot carry buttons: Electron's renderer hands the platform only title / body / tag / icon / silent and drops the `actions` array entirely (`DisplayNotification()` in `shell/browser/notifications/platform_notification_service.cc`); and a `dsh-app://` page cannot register a Service Worker, while only a Service Worker can draw button notifications. The plugin therefore posts approval alerts through the host as native toasts.
|
|
420
422
|
|
|
421
|
-
- **Who posts it**: the host half (`lib/index.js`) registers `POST /__dsh-notify-me/win-toast` and runs one `powershell.exe` with `lib/win-toast.ps1`, which sends the toast through the WinRT `ToastNotificationManager` under the
|
|
422
|
-
- **How the buttons decide**: the toast's two buttons use `activationType="protocol"` and point at `dsh-notify-me://approve?token=…` / reject. Clicking one invokes the handler registered for that protocol (a VBS that writes the action to a file and opens `dsh://open`); the host hands the action back on the page's next probe, and the page still goes through the same `decidePending()` the approval panel uses — "Approve" is "Allow once" and releases nothing extra.
|
|
423
|
+
- **Who posts it**: the host half (`lib/index.js`) registers `POST /__dsh-notify-me/win-toast` and runs one `powershell.exe` with `lib/win-toast.ps1`, which sends the toast through the WinRT `ToastNotificationManager` under the plugin's own AUMID, `dsh-notify-me`, so it follows the same system notification settings. **Do not borrow DSH's AUMID**: that one has a COM toast activator registered, and Windows hands every click to DSH itself, so the protocol buttons on the toast are never dispatched ([#41](https://github.com/chromoany/dsh-notify-me/issues/41), fixed in 1.21.2).
|
|
424
|
+
- **How the buttons decide**: the toast's two buttons use `activationType="protocol"` and point at `dsh-notify-me://approve?token=…` / reject. Clicking one invokes the handler registered for that protocol (a VBS that writes the action to a file and opens `dsh://open`); the host hands the action back on the page's next probe, and the page still goes through the same `decidePending()` the approval panel uses — "Approve" is "Allow once" and releases nothing extra. The chain needs the toast to carry its own AUMID; under another app's AUMID its activator swallows the click.
|
|
423
425
|
- **The body click raises too**: a body click now always goes through `dsh-notify-me://open` (with `?session=` when there is a conversation, and still kept as a plain raise request when there is none) instead of treating `dsh://open` as the Windows raising mechanism — that deep link neither restores a minimized window nor a window hidden to the tray with `SW_HIDE`. While an approval is pending the page probes every 1.5 s; an `open` action first POSTs the host focus route to raise the window and only then switches the conversation, with tray-hidden windows shown first by `focus-window.ps1` ([#40](https://github.com/chromoany/dsh-notify-me/issues/40)).
|
|
424
426
|
- **Non-ASCII user names**: the handler script is written as UTF-16LE with a BOM and resolves its action directory from `sh.ExpandEnvironmentStrings("%LOCALAPPDATA%")` at click time, so its body stays pure ASCII — WSH can no longer decode it in the system ANSI code page and mangle the path (which made every button click fail with an `800A004C` script error, [#36](https://github.com/chromoany/dsh-notify-me/issues/36)); fixed in 1.20.1. An upgrade needs only a restart: the first buttoned toast after it rewrites the script, and no manual cleanup is required.
|
|
425
|
-
- **Registration**: the first
|
|
427
|
+
- **Registration**: before the first toast, `HKCU\Software\Classes\AppUserModelId\dsh-notify-me` is written (`DisplayName` for the toast header, `CustomActivator` pointing at a CLSID) and that CLSID is created as an empty stub with no `LocalServer32` — an unpackaged app without a COM activator is what makes Windows dispatch the `activationType="protocol"` clicks from the XML. The toast is then booked into `ToastNotificationManager.History` by tag. Both are current-user and need no admin rights. Tokens are single-use and valid for 3 minutes; an action file is deleted once taken.
|
|
426
428
|
- **When it does not post**: outside the Windows desktop host, with `winToast.enabled: false`, or without `powershell.exe`, the route reports `enabled: false` (`501`) and the page keeps its own buttonless notification — the same behaviour as before this change.
|
|
427
429
|
- **Turning it off**: add `winToast: { enabled: false }` to the `notify-me` entry in the profile's patch layer; approval alerts go back to the page's own notification, without buttons.
|
|
428
430
|
- **Auto-dismiss and withdrawal**: native toasts are tracked by `trackToast()`: a plain toast closes after 5 s, a buttoned approval after 12 s ("always close" / "never close" still apply), and they are withdrawn when you come back to the page unless "keep alerts when you come back" is on.
|
|
@@ -504,7 +506,7 @@ powershell -NoProfile -File lib/focus-window.ps1 -ProcessId 0 # the last line
|
|
|
504
506
|
| <a href="https://github.com/RiZhiZhaoYi"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/RiZhiZhaoYi.png" width="40" height="40" alt="@RiZhiZhaoYi"></a> | [#12](https://github.com/chromoany/dsh-notify-me/issues/12): external notification forwarding (Discord / Bark / Gotify / custom webhook) |
|
|
505
507
|
| <a href="https://github.com/yuexian7"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/yuexian7.png" width="40" height="40" alt="@yuexian7"></a> | [#17](https://github.com/chromoany/dsh-notify-me/issues/17): the ask for Android delivery, which led to the Feishu / ServerChan / WxPusher targets |
|
|
506
508
|
| <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`) |
|
|
507
|
-
| <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> |
|
|
509
|
+
| <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 (the original issue has been deleted): the report that a Windows notification tag over the 64-character cap made the platform silently reject the approval test toast |
|
|
508
510
|
| <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 |
|
|
509
511
|
| <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 |
|
|
510
512
|
| <a href="https://github.com/LIEGU0317"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/LIEGU0317.png" width="40" height="40" alt="@LIEGU0317"></a> | [#24](https://github.com/chromoany/dsh-notify-me/issues/24) / [#25](https://github.com/chromoany/dsh-notify-me/pull/25): the host-side fallback push and same-origin relay modules (optional, off by default), with tests and docs; [#29](https://github.com/chromoany/dsh-notify-me/issues/29) / [#30](https://github.com/chromoany/dsh-notify-me/pull/30): the host fallback ignored the "Forward to external targets" switch (the heartbeat and pagehide now carry `external`), landing in 1.19.0 |
|
|
@@ -515,6 +517,8 @@ powershell -NoProfile -File lib/focus-window.ps1 -ProcessId 0 # the last line
|
|
|
515
517
|
| <a href="https://github.com/Inh-ui"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/Inh-ui.png" width="40" height="40" alt="@Inh-ui"></a> | [#33](https://github.com/chromoany/dsh-notify-me/issues/33): the report that Windows Desktop approval notifications carry no Approve / Reject buttons, with the source-level finding that Electron drops `actions` and Desktop cannot register a Service Worker — fixed in 1.19.0 |
|
|
516
518
|
| <a href="https://github.com/sakurakugu"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/sakurakugu.png" width="40" height="40" alt="@sakurakugu"></a> | [#34](https://github.com/chromoany/dsh-notify-me/pull/34): the custom JSON body template for the same-origin relay (`relay.bodyTemplate`), with tests and docs — supported since 1.20.0 |
|
|
517
519
|
| <a href="https://github.com/AlbertDope"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/AlbertDope.png" width="40" height="40" alt="@AlbertDope"></a> | [#36](https://github.com/chromoany/dsh-notify-me/issues/36): the root-cause analysis (WSH decoding the handler in the ANSI code page) and fix verification for the `800A004C` approval-button error under a non-ASCII Windows user name — fixed in 1.20.1 |
|
|
520
|
+
| <a href="https://github.com/TianqiCai"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/TianqiCai.png" width="40" height="40" alt="@TianqiCai"></a> | [#38](https://github.com/chromoany/dsh-notify-me/pull/38): the fix for macOS toast clicks not switching sessions while DSH is already frontmost (1-second polling), with a smoke test — landed in 1.21.0 |
|
|
521
|
+
| <a href="https://github.com/MVennn"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/MVennn.png" width="40" height="40" alt="@MVennn"></a> | [#40](https://github.com/chromoany/dsh-notify-me/issues/40): the report and diagnosis of Windows native approval toasts not raising minimized/tray windows — fixed in 1.21.0 |
|
|
518
522
|
|
|
519
523
|
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.
|
|
520
524
|
|
package/README.md
CHANGED
|
@@ -397,6 +397,8 @@ Windows 的激活顺序是实的:已经在前台就什么都不做(最常见
|
|
|
397
397
|
|
|
398
398
|
那个头只是「这是页面发来的」标记,不是防线——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 掉按失败处理。
|
|
399
399
|
|
|
400
|
+
这六条宿主路由(focus、macOS 通知、Windows Toast、页面桥接、host-fallback 健康探针、同源中继)现在还共用一层 DSH 准入:宿主若提供 `connection` 服务,handler 会先调 `connection.requestRejection(req)`——DSH 自己的路由也走这里,包含 Host / Origin 围栏和浏览器登录态校验;它返回 401 / 403 就原样转发(`reason` 为 `unauthenticated` / `untrusted`),通过后才轮到上面这套插件自己的闸门。宿主没有这个服务(旧版 DSH、纯 Node、离线测试)时跳过前者、退回插件闸门,行为与之前相同。这一层收在 `lib/page-bridge.js` 的 `guardRequest()` 里。
|
|
401
|
+
|
|
400
402
|
抬不起来的几种场合与[已知限制](#已知限制)里列的一致(提权窗口、另一虚拟桌面、前台被反复抢走),一律如实回 `202`、对话照常切。`SW_HIDE` 到托盘的隐藏主窗原来直接回 `202`,1.21.0 起先 `SW_SHOW` 再走同一套激活步骤([#40](https://github.com/chromoany/dsh-notify-me/issues/40))。
|
|
401
403
|
|
|
402
404
|
</details>
|
|
@@ -418,11 +420,11 @@ Windows 的激活顺序是实的:已经在前台就什么都不做(最常见
|
|
|
418
420
|
|
|
419
421
|
页面里的 `new Notification()` 在 Windows 桌面端不会被拒,但它带不了按钮:Electron 的渲染进程收到通知请求后只把 title / body / tag / icon / silent 抄给平台,`actions` 数组整个丢掉(`shell/browser/notifications/platform_notification_service.cc` 的 `DisplayNotification()`);`dsh-app://` 页面又注册不了 Service Worker,而按钮通知只有 Service Worker 才画得出来。于是插件把审批提醒改由宿主发原生 Toast。
|
|
420
422
|
|
|
421
|
-
- **谁去弹**:宿主半(`lib/index.js`)注册 `POST /__dsh-notify-me/win-toast`,由它起一次 `powershell.exe` 跑 `lib/win-toast.ps1`,用 WinRT `ToastNotificationManager`
|
|
422
|
-
- **按钮怎么裁决**:Toast 的两个按钮是 `activationType="protocol"`,分别指向 `dsh-notify-me://approve?token=…` / reject。点按钮后系统调起注册在这个协议下的处理器(一个写入动作文件、再打开 `dsh://open` 的 VBS),宿主在页面下一次探针时把动作交回页面;页面仍走审批面板里同一个 `decidePending()
|
|
423
|
+
- **谁去弹**:宿主半(`lib/index.js`)注册 `POST /__dsh-notify-me/win-toast`,由它起一次 `powershell.exe` 跑 `lib/win-toast.ps1`,用 WinRT `ToastNotificationManager` 把通知发到插件自己的 AUMID `dsh-notify-me` 下,走同一套系统通知设置。**不能借 DSH 的 AUMID**:那个 AUMID 挂着 COM Toast 激活器,Windows 会把每次点击都交给 DSH 本体,Toast 上的协议按钮永远等不到派发([#41](https://github.com/chromoany/dsh-notify-me/issues/41),1.21.2 修)。
|
|
424
|
+
- **按钮怎么裁决**:Toast 的两个按钮是 `activationType="protocol"`,分别指向 `dsh-notify-me://approve?token=…` / reject。点按钮后系统调起注册在这个协议下的处理器(一个写入动作文件、再打开 `dsh://open` 的 VBS),宿主在页面下一次探针时把动作交回页面;页面仍走审批面板里同一个 `decidePending()`——「同意」就是「允许一次」,不多放行任何东西。这条链路要求 Toast 挂在自己的 AUMID 下,否则点击会被别的应用的激活器截走。
|
|
423
425
|
- **点正文也会抬窗**:正文点击统一走 `dsh-notify-me://open`(有会话时带 `?session=`,没有会话也保留为一次纯抬窗),不再把 `dsh://open` 当 Windows 抬窗手段——那条深链拉不起最小化窗口,更拉不起 `SW_HIDE` 到托盘的窗口。等待审批期间页面每 1.5 秒取一次动作,取到 `open` 先 POST 宿主 focus 路由抬窗、再切会话;托盘隐藏的窗口由 `focus-window.ps1` 先 `SW_SHOW` 再激活([#40](https://github.com/chromoany/dsh-notify-me/issues/40))。
|
|
424
426
|
- **中文用户名等非 ASCII profile**:处理器脚本按 UTF-16LE + BOM 写盘,动作目录在点击时才用 `sh.ExpandEnvironmentStrings("%LOCALAPPDATA%")` 解析——脚本正文因此全是 ASCII,不会再被 WSH 按系统 ANSI 代码页解码后把路径弄乱(此前每次点按钮都弹 `800A004C` 脚本错误,[#36](https://github.com/chromoany/dsh-notify-me/issues/36)),1.20.1 起修复。升级后重启桌面端即可,第一次发带按钮的 Toast 时会重写这份脚本,不用手动清旧文件。
|
|
425
|
-
-
|
|
427
|
+
- **注册**:第一次发 Toast 前写 `HKCU\Software\Classes\AppUserModelId\dsh-notify-me`(`DisplayName` = 通知抬头,`CustomActivator` = 一个 CLSID),CLSID 只建空的存根、不注册 `LocalServer32`——未打包应用不实现 COM 激活器时,Windows 才会按 XML 把 `activationType="protocol"` 的点击派发出去;随后按 tag 记账到 `ToastNotificationManager.History`。两者都是当前用户级,不需要管理员权限。token 单次、3 分钟有效;动作文件被取走后即删。
|
|
426
428
|
- **不弹的场合**:非 Windows 桌面宿主、`winToast.enabled: false`、或 `powershell.exe` 不存在时,路由报 `enabled: false`(`501`),页面继续用自己那条不带按钮的通知,行为与改动前一致。
|
|
427
429
|
- **关掉它**:在 profile 的 patch 层给 `notify-me` 加 `winToast: { enabled: false }`,审批提醒回到页面自己的通知(无按钮)。
|
|
428
430
|
- **自动消失与收起**:原生 Toast 归 `trackToast()` 记账,普通通知 5 秒、带按钮的审批 12 秒(「总是关闭 / 从不关闭」照旧),回到页面(`keepOnReturn` 关闭时)同样收起。
|
|
@@ -504,7 +506,7 @@ powershell -NoProfile -File lib/focus-window.ps1 -ProcessId 0 # 末行应是 F
|
|
|
504
506
|
| <a href="https://github.com/RiZhiZhaoYi"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/RiZhiZhaoYi.png" width="40" height="40" alt="@RiZhiZhaoYi"></a> | [#12](https://github.com/chromoany/dsh-notify-me/issues/12):外部通知转发(Discord / Bark / Gotify / 自定义 Webhook) |
|
|
505
507
|
| <a href="https://github.com/yuexian7"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/yuexian7.png" width="40" height="40" alt="@yuexian7"></a> | [#17](https://github.com/chromoany/dsh-notify-me/issues/17):安卓端收消息的诉求,促成飞书 / Server酱 / WxPusher 三种目标 |
|
|
506
508
|
| <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` |
|
|
507
|
-
| <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> |
|
|
509
|
+
| <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(原 issue 已删除):Windows 通知 tag 超过 64 字符上限、审批测试通知被平台静默拒收的报告 |
|
|
508
510
|
| <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):当前会话的通知正文用占位符、未取会话标题的报告 |
|
|
509
511
|
| <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 恢复深链抬窗 |
|
|
510
512
|
| <a href="https://github.com/LIEGU0317"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/LIEGU0317.png" width="40" height="40" alt="@LIEGU0317"></a> | [#24](https://github.com/chromoany/dsh-notify-me/issues/24) / [#25](https://github.com/chromoany/dsh-notify-me/pull/25):页面关闭后由宿主兜底推送、同源中继两个可选模块(默认关),含测试与文档;[#29](https://github.com/chromoany/dsh-notify-me/issues/29) / [#30](https://github.com/chromoany/dsh-notify-me/pull/30):宿主兜底漏读「转发外部通知」开关(心跳与 pagehide 带 `external`),1.19.0 起生效 |
|
|
@@ -515,6 +517,8 @@ powershell -NoProfile -File lib/focus-window.ps1 -ProcessId 0 # 末行应是 F
|
|
|
515
517
|
| <a href="https://github.com/Inh-ui"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/Inh-ui.png" width="40" height="40" alt="@Inh-ui"></a> | [#33](https://github.com/chromoany/dsh-notify-me/issues/33):Windows 桌面端审批通知没有「同意 / 拒绝」按钮的反馈,以及 Electron 丢弃 `actions` / 桌面端注册不了 Service Worker 的源码级定位,1.19.0 起支持 |
|
|
516
518
|
| <a href="https://github.com/sakurakugu"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/sakurakugu.png" width="40" height="40" alt="@sakurakugu"></a> | [#34](https://github.com/chromoany/dsh-notify-me/pull/34):同源中继自定义 JSON 请求体模板(`relay.bodyTemplate`),含测试与文档,1.20.0 起支持 |
|
|
517
519
|
| <a href="https://github.com/AlbertDope"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/AlbertDope.png" width="40" height="40" alt="@AlbertDope"></a> | [#36](https://github.com/chromoany/dsh-notify-me/issues/36):Windows 中文用户名下审批按钮必弹 `800A004C` 的根因定位(WSH 按 ANSI 代码页解码处理器脚本)与修复验证,1.20.1 起修复 |
|
|
520
|
+
| <a href="https://github.com/TianqiCai"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/TianqiCai.png" width="40" height="40" alt="@TianqiCai"></a> | [#38](https://github.com/chromoany/dsh-notify-me/pull/38):macOS 已在前台时点通知不切会话的修复(1 秒轮询),含冒烟测试,1.21.0 起收编 |
|
|
521
|
+
| <a href="https://github.com/MVennn"><img src="https://raw.githubusercontent.com/chromoany/dsh-notify-me/main/docs/contributors/MVennn.png" width="40" height="40" alt="@MVennn"></a> | [#40](https://github.com/chromoany/dsh-notify-me/issues/40):Windows 原生审批 Toast 点正文不唤醒最小化/托盘窗口的报障与定位,1.21.0 起修复 |
|
|
518
522
|
|
|
519
523
|
署名口径:本仓库收编外部 PR 时以维护者提交落地——不沿用原 commit、不挂 Co-authored-by,GitHub 的 contributors 图只显示维护者,贡献者以上面的致谢署名。
|
|
520
524
|
|
package/lib/client.js
CHANGED
|
@@ -910,9 +910,10 @@
|
|
|
910
910
|
// Electron's renderer notification drops PlatformNotificationData::actions
|
|
911
911
|
// before it reaches the Windows toast platform (issue #33), so an approval
|
|
912
912
|
// alert can only carry 同意 / 拒绝 when the host half posts it through
|
|
913
|
-
// WinRT.
|
|
914
|
-
//
|
|
915
|
-
// decidePending(), the same path a
|
|
913
|
+
// WinRT. The toast carries the plugin's own AUMID and its buttons activate
|
|
914
|
+
// the registered dsh-notify-me:// protocol; the host collects the chosen
|
|
915
|
+
// action and this side applies it through decidePending(), the same path a
|
|
916
|
+
// worker-button click takes.
|
|
916
917
|
var WIN_TOAST_ROUTE = "/__dsh-notify-me/win-toast";
|
|
917
918
|
var winNative = { enabled: false, last: null, poll: null, pollKey: null };
|
|
918
919
|
function isWindowsDesktopPage() {
|
|
@@ -942,8 +943,8 @@
|
|
|
942
943
|
}
|
|
943
944
|
function applyWinAction(action) {
|
|
944
945
|
if (!action || typeof action !== "object") return;
|
|
945
|
-
if (action.action === "approve" && typeof action.key === "string") decidePending(action.key, "allowed-once");
|
|
946
|
-
else if (action.action === "reject" && typeof action.key === "string") decidePending(action.key, "rejected");
|
|
946
|
+
if (action.action === "approve" && typeof action.key === "string") decidePending(action.key, "allowed-once", true);
|
|
947
|
+
else if (action.action === "reject" && typeof action.key === "string") decidePending(action.key, "rejected", true);
|
|
947
948
|
else if (action.action === "open") {
|
|
948
949
|
// Clicking the toast body is a request to come back to DSH. The helper's
|
|
949
950
|
// dsh://open launch cannot raise a minimized or tray-hidden window on
|
|
@@ -1523,12 +1524,18 @@
|
|
|
1523
1524
|
} catch (e) {}
|
|
1524
1525
|
}
|
|
1525
1526
|
// One toast button press. outcome: 'allowed-once' | 'rejected' — exactly
|
|
1526
|
-
// the two decisions a manual answer in the conversation makes.
|
|
1527
|
-
|
|
1527
|
+
// the two decisions a manual answer in the conversation makes. fromToast
|
|
1528
|
+
// marks the clicks Windows already took out of the Action Center itself;
|
|
1529
|
+
// any other answer has to withdraw the native toast too, or it sits there
|
|
1530
|
+
// with buttons whose token is spent.
|
|
1531
|
+
function decidePending(key, outcome, fromToast) {
|
|
1528
1532
|
var rec = key ? pendingActions[key] : null;
|
|
1529
1533
|
if (!rec) return false; // already answered elsewhere, or a stale toast
|
|
1530
1534
|
delete pendingActions[key];
|
|
1531
|
-
if (!rec.test)
|
|
1535
|
+
if (!rec.test) {
|
|
1536
|
+
closeNotificationTag(rec.tag);
|
|
1537
|
+
if (!fromToast && isWindowsDesktopPage()) removeWinToast(rec.tag);
|
|
1538
|
+
}
|
|
1532
1539
|
if (rec.test) {
|
|
1533
1540
|
// Test toasts settle nothing real; the feedback toast IS the proof that
|
|
1534
1541
|
// the button clicked all the way through the worker bridge.
|
|
@@ -3355,7 +3362,7 @@
|
|
|
3355
3362
|
});
|
|
3356
3363
|
} catch (e) {}
|
|
3357
3364
|
// keep in sync with package.json "version" on every release
|
|
3358
|
-
api.version = "1.21.
|
|
3365
|
+
api.version = "1.21.2";
|
|
3359
3366
|
api.setConfig = function (patch) { return setConfigLocal(patch); };
|
|
3360
3367
|
api.resetConfig = function () {
|
|
3361
3368
|
try {
|
package/lib/host-fallback.js
CHANGED
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
createPresence,
|
|
33
33
|
copyFor,
|
|
34
34
|
deliverNote,
|
|
35
|
-
|
|
35
|
+
guardRequest,
|
|
36
36
|
pickLanguage,
|
|
37
37
|
sessionName,
|
|
38
38
|
clip,
|
|
@@ -291,9 +291,13 @@ export function mountHostFallback(ctx, config, shared) {
|
|
|
291
291
|
respond(res, 405, { ok: false, reason: "method-not-allowed" });
|
|
292
292
|
return;
|
|
293
293
|
}
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
|
|
294
|
+
const guard = guardRequest(req, {
|
|
295
|
+
bindHost: shared?.bindHost,
|
|
296
|
+
allowedOrigins: shared?.allowedOrigins,
|
|
297
|
+
connection: shared?.connection,
|
|
298
|
+
});
|
|
299
|
+
if (guard !== null) {
|
|
300
|
+
respond(res, guard.status, { ok: false, reason: guard.reason });
|
|
297
301
|
return;
|
|
298
302
|
}
|
|
299
303
|
const page = presence.snapshot();
|
package/lib/index.js
CHANGED
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
BRIDGE_ROUTE,
|
|
43
43
|
bindHostOf,
|
|
44
44
|
createPresence,
|
|
45
|
-
|
|
45
|
+
guardRequest,
|
|
46
46
|
pickLanguage,
|
|
47
47
|
readBody,
|
|
48
48
|
respond,
|
|
@@ -473,23 +473,45 @@ function raiseWindow() {
|
|
|
473
473
|
return pendingRaise;
|
|
474
474
|
}
|
|
475
475
|
|
|
476
|
+
/**
|
|
477
|
+
* The composition's DSH connection service, when this host has one.
|
|
478
|
+
*
|
|
479
|
+
* `webServer.register` routes sit outside DSH's route table, so the composition
|
|
480
|
+
* never fences them for us; `connection.requestRejection` is the call its own
|
|
481
|
+
* routes make, and it carries both the Host/Origin fence and the browser
|
|
482
|
+
* session / API authentication. Read it lazily because a host that predates the
|
|
483
|
+
* service (or the route tests) must keep working without it.
|
|
484
|
+
* @param ctx - host cordis context.
|
|
485
|
+
* @returns the `connection` service, or `undefined` when this host has none.
|
|
486
|
+
*/
|
|
487
|
+
function connectionOf(ctx) {
|
|
488
|
+
try {
|
|
489
|
+
return typeof ctx?.get === "function" ? ctx.get("connection") : Reflect.get(ctx, "connection");
|
|
490
|
+
} catch {
|
|
491
|
+
return undefined;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
476
495
|
/**
|
|
477
496
|
* Build the focus-route handler. The GET form is a probe the page may use to
|
|
478
497
|
* find out whether activation is available at all; only the POST form touches
|
|
479
498
|
* the OS.
|
|
480
|
-
* @param
|
|
499
|
+
* @param shared - `{ bindHost, connection }` from {@link apply}.
|
|
481
500
|
* @returns the web-server route handler.
|
|
482
501
|
*/
|
|
483
|
-
function createHandler(
|
|
502
|
+
function createHandler(shared) {
|
|
484
503
|
return function handleFocus(req, res) {
|
|
485
504
|
const method = req.method ?? "GET";
|
|
486
505
|
if (method !== "GET" && method !== "HEAD" && method !== "POST") {
|
|
487
506
|
respond(res, 405, { ok: false, reason: "method-not-allowed" });
|
|
488
507
|
return;
|
|
489
508
|
}
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
|
|
509
|
+
const guard = guardRequest(req, {
|
|
510
|
+
bindHost: shared.bindHost,
|
|
511
|
+
connection: shared.connection,
|
|
512
|
+
});
|
|
513
|
+
if (guard !== null) {
|
|
514
|
+
respond(res, guard.status, { ok: false, reason: guard.reason });
|
|
493
515
|
return;
|
|
494
516
|
}
|
|
495
517
|
if (method === "GET" || method === "HEAD") {
|
|
@@ -626,9 +648,13 @@ function createBridgeHandler(state, shared) {
|
|
|
626
648
|
respond(res, 405, { ok: false, reason: "method-not-allowed" });
|
|
627
649
|
return;
|
|
628
650
|
}
|
|
629
|
-
const
|
|
630
|
-
|
|
631
|
-
|
|
651
|
+
const guard = guardRequest(req, {
|
|
652
|
+
bindHost: shared.bindHost,
|
|
653
|
+
allowedOrigins: shared.allowedOrigins,
|
|
654
|
+
connection: shared.connection,
|
|
655
|
+
});
|
|
656
|
+
if (guard !== null) {
|
|
657
|
+
respond(res, guard.status, { ok: false, reason: guard.reason });
|
|
632
658
|
return;
|
|
633
659
|
}
|
|
634
660
|
if (method === "GET" || method === "HEAD") {
|
|
@@ -695,6 +721,7 @@ export function apply(ctx, config) {
|
|
|
695
721
|
bindHost: undefined,
|
|
696
722
|
allowedOrigins: state.allowedOrigins,
|
|
697
723
|
presence: createPresence({ leaseMs: state.hostFallback.pageLeaseMs }),
|
|
724
|
+
connection: () => connectionOf(ctx),
|
|
698
725
|
};
|
|
699
726
|
|
|
700
727
|
// Both are mounted whenever they are enabled, even if the configuration is
|
|
@@ -712,7 +739,7 @@ export function apply(ctx, config) {
|
|
|
712
739
|
shared.bindHost = bindHostOf(webCtx.webServer);
|
|
713
740
|
|
|
714
741
|
webCtx.effect(
|
|
715
|
-
() => webCtx.webServer.register({ kind: "exact", path: FOCUS_ROUTE, handler: createHandler(shared
|
|
742
|
+
() => webCtx.webServer.register({ kind: "exact", path: FOCUS_ROUTE, handler: createHandler(shared) }),
|
|
716
743
|
"dsh-notify-me: window focus route",
|
|
717
744
|
);
|
|
718
745
|
|
package/lib/mac-notify.js
CHANGED
|
@@ -20,7 +20,7 @@ import { tmpdir } from "node:os";
|
|
|
20
20
|
import { join } from "node:path";
|
|
21
21
|
import { fileURLToPath } from "node:url";
|
|
22
22
|
|
|
23
|
-
import {
|
|
23
|
+
import { guardRequest, readBody, respond } from "./page-bridge.js";
|
|
24
24
|
|
|
25
25
|
export const MAC_NOTIFY_ROUTE = "/__dsh-notify-me/mac-notify";
|
|
26
26
|
const HEADER = "x-dsh-notify-me-mac";
|
|
@@ -123,9 +123,13 @@ export function mountMacNotify(webCtx, config, shared, logger, deps = {}) {
|
|
|
123
123
|
respond(res, 405, { ok: false, reason: "method-not-allowed" });
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
const guard = guardRequest(req, {
|
|
127
|
+
bindHost: shared.bindHost,
|
|
128
|
+
allowedOrigins: shared.allowedOrigins,
|
|
129
|
+
connection: shared.connection,
|
|
130
|
+
});
|
|
131
|
+
if (guard !== null) {
|
|
132
|
+
respond(res, guard.status, { ok: false, reason: guard.reason });
|
|
129
133
|
return;
|
|
130
134
|
}
|
|
131
135
|
if (method === "GET") {
|
package/lib/page-bridge.js
CHANGED
|
@@ -11,7 +11,11 @@
|
|
|
11
11
|
* Those three sit on the same few primitives, and every one of them is a
|
|
12
12
|
* correctness or security decision that must not drift apart:
|
|
13
13
|
*
|
|
14
|
-
* - {@link
|
|
14
|
+
* - {@link guardRequest}: every web-server route enters through this. When the
|
|
15
|
+
* host composition exposes its `connection` service, this is the same
|
|
16
|
+
* `requestRejection` call DSH's own routes make (Host/Origin fence plus
|
|
17
|
+
* browser authentication); a host without that service falls back to
|
|
18
|
+
* {@link gateRequest}, the boundary the focus route has always used. It
|
|
15
19
|
* moved here when a second and a third route needed the same gate, and grew
|
|
16
20
|
* the permitted-origin list so a tunnel-fronted host accepts the public
|
|
17
21
|
* name its own page dials.
|
|
@@ -255,6 +259,41 @@ export function gateRequest(req, options) {
|
|
|
255
259
|
return null;
|
|
256
260
|
}
|
|
257
261
|
|
|
262
|
+
/**
|
|
263
|
+
* Refuse a request the DSH composition itself does not admit, then fall back to
|
|
264
|
+
* {@link gateRequest} for the part DSH leaves to the route.
|
|
265
|
+
*
|
|
266
|
+
* A `webServer` route is outside the composition's own route table, so DSH does
|
|
267
|
+
* not fence it: `connection.requestRejection` is the composition's Host/Origin
|
|
268
|
+
* fence plus its browser-session/API authentication, and every DSH route calls
|
|
269
|
+
* it before touching a payload. Hosts without a `connection` service (older DSH
|
|
270
|
+
* releases, plain Node, the route tests) have no such fence to apply and use
|
|
271
|
+
* {@link gateRequest} alone.
|
|
272
|
+
* @param req - the incoming request.
|
|
273
|
+
* @param options - `{ bindHost, allowedOrigins, connection }`; `connection` is
|
|
274
|
+
* the service, a getter returning it, or `undefined`.
|
|
275
|
+
* @returns `{ status, reason }` when refused, or `null` when the request may
|
|
276
|
+
* proceed.
|
|
277
|
+
*/
|
|
278
|
+
export function guardRequest(req, options) {
|
|
279
|
+
const connection = typeof options?.connection === "function" ? options.connection() : options?.connection;
|
|
280
|
+
if (connection !== undefined && connection !== null && typeof connection.requestRejection === "function") {
|
|
281
|
+
let status;
|
|
282
|
+
try {
|
|
283
|
+
status = connection.requestRejection(req);
|
|
284
|
+
} catch {
|
|
285
|
+
// A composition that cannot answer for this request must not open the
|
|
286
|
+
// route: fail closed here rather than falling through to the weaker gate.
|
|
287
|
+
status = 403;
|
|
288
|
+
}
|
|
289
|
+
if (typeof status === "number") {
|
|
290
|
+
return { status, reason: status === 401 ? "unauthenticated" : "untrusted" };
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
const refusal = gateRequest(req, options);
|
|
294
|
+
return refusal === null ? null : { status: 403, reason: refusal };
|
|
295
|
+
}
|
|
296
|
+
|
|
258
297
|
/**
|
|
259
298
|
* @param webServer - the host web server service.
|
|
260
299
|
* @returns its configured bind address when it exposes one.
|
package/lib/relay.js
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* {@link RELAY_HEADER}, which a cross-site form post cannot set.
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
import { bindHostOf, createCredentialReader, deliverNote,
|
|
30
|
+
import { bindHostOf, createCredentialReader, deliverNote, guardRequest, readBody, respond } from "./page-bridge.js";
|
|
31
31
|
|
|
32
32
|
/** Reject oversized bodies instead of buffering them. */
|
|
33
33
|
const MAX_BODY_BYTES = 64 * 1024;
|
|
@@ -206,14 +206,13 @@ function createHandler(config, credentials, shared, logger) {
|
|
|
206
206
|
respond(res, 405, { ok: false, reason: "method-not-allowed" });
|
|
207
207
|
return;
|
|
208
208
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
respond(res, 403, { ok: false, reason: refusal });
|
|
209
|
+
const guard = guardRequest(req, {
|
|
210
|
+
bindHost: shared?.bindHost,
|
|
211
|
+
allowedOrigins: shared?.allowedOrigins,
|
|
212
|
+
connection: shared?.connection,
|
|
213
|
+
});
|
|
214
|
+
if (guard !== null) {
|
|
215
|
+
respond(res, guard.status, { ok: false, reason: guard.reason });
|
|
217
216
|
return;
|
|
218
217
|
}
|
|
219
218
|
if (method === "GET" || method === "HEAD") {
|
package/lib/win-toast.js
CHANGED
|
@@ -14,9 +14,21 @@
|
|
|
14
14
|
*
|
|
15
15
|
* The route only exists on the packaged Windows desktop shell. Tokens are
|
|
16
16
|
* single use, bound to one approval key and expire after three minutes. The
|
|
17
|
-
* protocol handler is registered under HKCU\Software\Classes
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* protocol handler is registered under HKCU\Software\Classes before the first
|
|
18
|
+
* toast is posted; it survives app updates because it points at the actions
|
|
19
|
+
* directory, not at a binary.
|
|
20
|
+
*
|
|
21
|
+
* The toast carries its own AUMID. One posted under another app's AUMID is
|
|
22
|
+
* activated through that app: Windows looks the AUMID up under
|
|
23
|
+
* `HKCU\Software\Classes\AppUserModelId` and, when it names a CustomActivator,
|
|
24
|
+
* hands every activation — body click and buttons alike — to that COM server,
|
|
25
|
+
* so `activationType="protocol"` in the XML is never consulted. The DSH desktop
|
|
26
|
+
* shell registers such an activator for `electron.app.DeepSeek Harness`, which
|
|
27
|
+
* is why the approval buttons only dismissed the toast and the VBS handler
|
|
28
|
+
* never ran (issue #41). dsh-notify-me registers its own AUMID with a CLSID
|
|
29
|
+
* that has no LocalServer32: the documented "no COM activator" fallback, where
|
|
30
|
+
* protocol activation is still dispatched for unpackaged apps (at the cost of
|
|
31
|
+
* toast inputs and in-process activation, neither of which is used here).
|
|
20
32
|
*/
|
|
21
33
|
|
|
22
34
|
import { spawn, execFile } from "node:child_process";
|
|
@@ -26,12 +38,17 @@ import { join } from "node:path";
|
|
|
26
38
|
import { fileURLToPath } from "node:url";
|
|
27
39
|
import { randomBytes } from "node:crypto";
|
|
28
40
|
|
|
29
|
-
import {
|
|
41
|
+
import { guardRequest, readBody, respond } from "./page-bridge.js";
|
|
30
42
|
|
|
31
43
|
export const WIN_TOAST_ROUTE = "/__dsh-notify-me/win-toast";
|
|
44
|
+
// The app identity the toasts are posted under, and the stub COM activator it
|
|
45
|
+
// names. Exported so the smoke test can pin them: posting under the DSH shell's
|
|
46
|
+
// AUMID is what silently ate every button click (issue #41).
|
|
47
|
+
export const AUMID = "dsh-notify-me";
|
|
48
|
+
export const ACTIVATOR_CLSID = "{F0C6A9D2-4B7E-4D1A-9C53-8E2B6F7A0D41}";
|
|
49
|
+
const AUMID_DISPLAY_NAME = "DSH Notify Me";
|
|
32
50
|
const HEADER = "x-dsh-notify-me-win";
|
|
33
51
|
const HEADER_VALUE = "toast";
|
|
34
|
-
const DEFAULT_AUMID = "electron.app.DeepSeek Harness";
|
|
35
52
|
const PROTOCOL = "dsh-notify-me";
|
|
36
53
|
const TOAST_GROUP = "dsh-notify-me";
|
|
37
54
|
const ACTION_TTL_MS = 3 * 60 * 1000;
|
|
@@ -121,7 +138,7 @@ export function mountWinToast(webCtx, config, shared, logger, deps = {}) {
|
|
|
121
138
|
const vbsPath = join(baseDir, "notify-handler.vbs");
|
|
122
139
|
const psPath = typeof deps.psPath === "string" && deps.psPath ? deps.psPath : powershellPath();
|
|
123
140
|
const scriptPath = typeof deps.scriptPath === "string" && deps.scriptPath ? deps.scriptPath : SCRIPT_PATH;
|
|
124
|
-
const aumid = typeof deps.aumid === "string" && deps.aumid ? deps.aumid :
|
|
141
|
+
const aumid = typeof deps.aumid === "string" && deps.aumid ? deps.aumid : AUMID;
|
|
125
142
|
const nowFn = typeof deps.now === "function" ? deps.now : function () { return Date.now(); };
|
|
126
143
|
const available = config.enabled !== false && existsSync(psPath) && existsSync(scriptPath);
|
|
127
144
|
if (config.enabled !== false && !available) {
|
|
@@ -130,7 +147,7 @@ export function mountWinToast(webCtx, config, shared, logger, deps = {}) {
|
|
|
130
147
|
|
|
131
148
|
const tokens = Object.create(null);
|
|
132
149
|
const ids = Object.create(null);
|
|
133
|
-
let
|
|
150
|
+
let appReady = null;
|
|
134
151
|
let seq = 0;
|
|
135
152
|
|
|
136
153
|
function runPowerShell(extraArgs) {
|
|
@@ -172,9 +189,13 @@ export function mountWinToast(webCtx, config, shared, logger, deps = {}) {
|
|
|
172
189
|
});
|
|
173
190
|
}
|
|
174
191
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
192
|
+
// Registers everything a protocol-activated toast needs from this side: the
|
|
193
|
+
// `dsh-notify-me://` handler, the app identity the toast is posted under, and
|
|
194
|
+
// the empty CLSID that identity names (see the module comment). Once per
|
|
195
|
+
// plugin instance, current-user rights only.
|
|
196
|
+
function registerToastApp() {
|
|
197
|
+
if (appReady) return appReady;
|
|
198
|
+
appReady = (async () => {
|
|
178
199
|
try {
|
|
179
200
|
mkdirSync(actionsDir, { recursive: true });
|
|
180
201
|
writeHandlerScript(vbsPath, actionsDir);
|
|
@@ -182,10 +203,18 @@ export function mountWinToast(webCtx, config, shared, logger, deps = {}) {
|
|
|
182
203
|
return false;
|
|
183
204
|
}
|
|
184
205
|
const command = '"' + wscriptPath() + '" "' + vbsPath + '" "%1"';
|
|
206
|
+
const appKey = "HKCU\\Software\\Classes\\AppUserModelId\\" + aumid;
|
|
185
207
|
const commands = [
|
|
186
208
|
["add", "HKCU\\Software\\Classes\\" + PROTOCOL, "/ve", "/d", "URL:DSH Notify Me", "/f"],
|
|
187
209
|
["add", "HKCU\\Software\\Classes\\" + PROTOCOL, "/v", "URL Protocol", "/d", "", "/f"],
|
|
188
210
|
["add", "HKCU\\Software\\Classes\\" + PROTOCOL + "\\shell\\open\\command", "/ve", "/d", command, "/f"],
|
|
211
|
+
// Own AUMID: the name Windows shows on the toast, and the activator it
|
|
212
|
+
// points at. The CLSID is registered empty on purpose — with no
|
|
213
|
+
// LocalServer32 behind it Windows cannot hand an activation to a COM
|
|
214
|
+
// server, so the protocol in the XML is dispatched instead (#41).
|
|
215
|
+
["add", appKey, "/v", "DisplayName", "/d", AUMID_DISPLAY_NAME, "/f"],
|
|
216
|
+
["add", appKey, "/v", "CustomActivator", "/d", ACTIVATOR_CLSID, "/f"],
|
|
217
|
+
["add", "HKCU\\Software\\Classes\\CLSID\\" + ACTIVATOR_CLSID, "/f"],
|
|
189
218
|
];
|
|
190
219
|
for (let i = 0; i < commands.length; i++) {
|
|
191
220
|
const args = commands[i];
|
|
@@ -196,7 +225,7 @@ export function mountWinToast(webCtx, config, shared, logger, deps = {}) {
|
|
|
196
225
|
}
|
|
197
226
|
return true;
|
|
198
227
|
})();
|
|
199
|
-
return
|
|
228
|
+
return appReady;
|
|
200
229
|
}
|
|
201
230
|
|
|
202
231
|
function makeToken(approvalKey, sessionId) {
|
|
@@ -263,9 +292,13 @@ export function mountWinToast(webCtx, config, shared, logger, deps = {}) {
|
|
|
263
292
|
respond(res, 405, { ok: false, reason: "method-not-allowed" });
|
|
264
293
|
return;
|
|
265
294
|
}
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
|
|
295
|
+
const guard = guardRequest(req, {
|
|
296
|
+
bindHost: shared.bindHost,
|
|
297
|
+
allowedOrigins: shared.allowedOrigins,
|
|
298
|
+
connection: shared.connection,
|
|
299
|
+
});
|
|
300
|
+
if (guard !== null) {
|
|
301
|
+
respond(res, guard.status, { ok: false, reason: guard.reason });
|
|
269
302
|
return;
|
|
270
303
|
}
|
|
271
304
|
if (method === "GET") {
|
|
@@ -304,10 +337,13 @@ export function mountWinToast(webCtx, config, shared, logger, deps = {}) {
|
|
|
304
337
|
const historyTag = nextHistoryTag();
|
|
305
338
|
if (pageTag) ids[pageTag] = historyTag;
|
|
306
339
|
const approvalKey = str(note.approvalKey, 200);
|
|
340
|
+
// Before the toast is shown, not after: Windows has to know this AUMID
|
|
341
|
+
// when the activation comes back, and a body click needs the handler even
|
|
342
|
+
// when the toast has no buttons at all.
|
|
343
|
+
await registerToastApp();
|
|
307
344
|
let approveToken = "";
|
|
308
345
|
let rejectToken = "";
|
|
309
346
|
if (approvalKey) {
|
|
310
|
-
await registerProtocol();
|
|
311
347
|
approveToken = makeToken(approvalKey, str(note.sessionId, 200));
|
|
312
348
|
rejectToken = makeToken(approvalKey, str(note.sessionId, 200));
|
|
313
349
|
}
|
package/lib/win-toast.ps1
CHANGED
|
@@ -4,9 +4,12 @@
|
|
|
4
4
|
# powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -File win-toast.ps1 \
|
|
5
5
|
# -Base64 <base64 JSON payload> [-RemoveTag <history tag>]
|
|
6
6
|
#
|
|
7
|
-
# The toast
|
|
8
|
-
#
|
|
9
|
-
#
|
|
7
|
+
# The toast is posted under dsh-notify-me's own AUMID: lib/win-toast.js
|
|
8
|
+
# registers it (a DisplayName plus a stub CustomActivator with no LocalServer32)
|
|
9
|
+
# before the first toast goes out. Borrowing the DSH shell's AUMID instead made
|
|
10
|
+
# Windows route every activation to DSH's COM activator, which silently dropped
|
|
11
|
+
# it — the buttons only dismissed the toast (issue #41). Approval buttons and
|
|
12
|
+
# the body both use protocol activation, so the click comes back through the
|
|
10
13
|
# dsh-notify-me:// handler registered in HKCU (see lib/win-toast.js).
|
|
11
14
|
|
|
12
15
|
param(
|
package/package.json
CHANGED
package/smoke/win-toast-test.mjs
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
// that environment (a `win32` platform and an `electron` version string). The
|
|
5
5
|
// PowerShell helper cannot reasonably run in CI, so spawn/exec are injected:
|
|
6
6
|
// what is pinned here is the route contract (405/403/501/400, GET actions,
|
|
7
|
-
// POST send/remove), the decoded toast payload, the HKCU
|
|
8
|
-
//
|
|
7
|
+
// POST send/remove), the decoded toast payload, the HKCU registrations (the
|
|
8
|
+
// protocol handler, the plugin's own AUMID and its empty activator CLSID), the
|
|
9
|
+
// encoding of the generated VBS handler, and the token rules — single use,
|
|
9
10
|
// bound to one approval key, expiring.
|
|
10
11
|
import fs from 'node:fs';
|
|
11
12
|
import os from 'node:os';
|
|
@@ -19,6 +20,13 @@ function assert(cond, msg) { if (!cond) throw new Error('ASSERT FAILED: ' + msg)
|
|
|
19
20
|
|
|
20
21
|
const win = await import(pathToFileURL(path.join(ROOT, 'lib', 'win-toast.js')).href);
|
|
21
22
|
assert(win.WIN_TOAST_ROUTE === '/__dsh-notify-me/win-toast', 'WIN_TOAST_ROUTE is the path the page calls');
|
|
23
|
+
// The toast must not borrow the DSH shell's AUMID: that AUMID has a COM toast
|
|
24
|
+
// activator registered, so Windows handed every activation to DSH and the
|
|
25
|
+
// protocol handler never ran — the buttons only dismissed the toast (issue #41).
|
|
26
|
+
assert(win.AUMID === 'dsh-notify-me', "the toast posts under the plugin's own AUMID");
|
|
27
|
+
assert(win.AUMID !== 'electron.app.DeepSeek Harness', 'never under the DSH shell AUMID');
|
|
28
|
+
assert(/^\{[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}\}$/.test(win.ACTIVATOR_CLSID),
|
|
29
|
+
'the activator stub is a full CLSID');
|
|
22
30
|
// The toast body click must always come back through our protocol handler: the
|
|
23
31
|
// helper's dsh://open launch is dead on Windows, and the page's host-route raise
|
|
24
32
|
// is what brings a minimized or tray-hidden window back (issue #40).
|
|
@@ -63,13 +71,13 @@ function decodePayload(call) {
|
|
|
63
71
|
return JSON.parse(Buffer.from(call.args[at + 1], 'base64').toString('utf8'));
|
|
64
72
|
}
|
|
65
73
|
|
|
66
|
-
function mount(config = {}, deps = {}) {
|
|
74
|
+
function mount(config = {}, deps = {}, shared = { bindHost: undefined, allowedOrigins: [] }) {
|
|
67
75
|
const routes = [];
|
|
68
76
|
const ctx = {
|
|
69
77
|
effect(fn) { fn(); return () => {}; },
|
|
70
78
|
webServer: { register(route) { routes.push(route); return () => {}; } },
|
|
71
79
|
};
|
|
72
|
-
win.mountWinToast(ctx, config,
|
|
80
|
+
win.mountWinToast(ctx, config, shared, undefined, {
|
|
73
81
|
spawn: fakeSpawn,
|
|
74
82
|
execFile: fakeExec,
|
|
75
83
|
psPath: psPath,
|
|
@@ -160,9 +168,17 @@ try {
|
|
|
160
168
|
assert(payload.approveText === '同意' && payload.rejectText === '拒绝', 'button labels reach the helper');
|
|
161
169
|
assert(payload.sound === false, 'the sound flag is off unless the cue is system');
|
|
162
170
|
|
|
163
|
-
assert(execCalls.length ===
|
|
164
|
-
|
|
171
|
+
assert(execCalls.length === 6, 'the first toast registers the protocol, the AUMID and the activator stub');
|
|
172
|
+
const regs = execCalls.map((c) => c.args.join(' '));
|
|
173
|
+
assert(execCalls[0].file === 'reg' && regs[0].includes('HKCU\\Software\\Classes\\dsh-notify-me'),
|
|
165
174
|
'the protocol is registered under HKCU\\Software\\Classes');
|
|
175
|
+
assert(regs[3].includes('HKCU\\Software\\Classes\\AppUserModelId\\test.aumid') && regs[3].includes('DisplayName'),
|
|
176
|
+
'the toast AUMID gets the display name the notification header shows');
|
|
177
|
+
assert(regs[4].includes('\\test.aumid') && regs[4].includes('CustomActivator') && regs[4].includes(win.ACTIVATOR_CLSID),
|
|
178
|
+
'the AUMID names the activator stub');
|
|
179
|
+
assert(regs[5] === 'add HKCU\\Software\\Classes\\CLSID\\' + win.ACTIVATOR_CLSID + ' /f',
|
|
180
|
+
'the activator CLSID is created empty: with no LocalServer32 Windows dispatches the protocol (issue #41)');
|
|
181
|
+
assert(!regs.some((line) => line.includes('LocalServer32')), 'no COM server is installed');
|
|
166
182
|
const handlerVbs = path.join(tmp, 'dsh-notify-me', 'notify-handler.vbs');
|
|
167
183
|
assert(fs.existsSync(handlerVbs), 'the protocol handler script is written');
|
|
168
184
|
const vbsBytes = fs.readFileSync(handlerVbs);
|
|
@@ -181,6 +197,15 @@ try {
|
|
|
181
197
|
assert(JSON.parse((await call(handler, 'GET')).body).actions.length === 0, 'the action is delivered once');
|
|
182
198
|
writeAction('a2.txt', 'dsh-notify-me://approve?token=' + sentBody.token);
|
|
183
199
|
assert(JSON.parse((await call(handler, 'GET')).body).actions.length === 0, 'a used token is dead');
|
|
200
|
+
// Windows rewrites a protocol URI that has no path before handing it to the
|
|
201
|
+
// handler: dsh-notify-me://approve?token=… arrives as approve/?token=… (seen
|
|
202
|
+
// on Windows 11 26200 with a real toast click). The decision must survive it.
|
|
203
|
+
const rewritten = JSON.parse((await post(handler, { ...APPROVAL, tag: 'tag-4' })).body);
|
|
204
|
+
writeAction('a2b.txt', 'dsh-notify-me://approve/?token=' + rewritten.token);
|
|
205
|
+
const normalized = JSON.parse((await call(handler, 'GET')).body);
|
|
206
|
+
assert(normalized.actions.length === 1 && normalized.actions[0].action === 'approve'
|
|
207
|
+
&& normalized.actions[0].key === 'approval:sess-1:1',
|
|
208
|
+
'a shell-normalized action URL (slash before the query) still delivers the decision');
|
|
184
209
|
|
|
185
210
|
// 3c. Reject click.
|
|
186
211
|
const second = JSON.parse((await post(handler, { ...APPROVAL, tag: 'tag-2' })).body);
|
|
@@ -211,12 +236,47 @@ try {
|
|
|
211
236
|
writeAction('a5.txt', 'dsh-notify-me://approve?token=' + aged.token);
|
|
212
237
|
assert(JSON.parse((await call(clocked[0].handler, 'GET')).body).actions.length === 0, 'an expired token is ignored');
|
|
213
238
|
|
|
239
|
+
// 3g. The composition's admission fence runs first when the host exposes its
|
|
240
|
+
// connection service: an unauthenticated browser session never reaches the
|
|
241
|
+
// action files or the toast helper, and an admitted request still gets the
|
|
242
|
+
// plugin's own loopback gate.
|
|
243
|
+
let admissionCalls = 0;
|
|
244
|
+
const fenced = mount({}, {}, {
|
|
245
|
+
bindHost: undefined,
|
|
246
|
+
allowedOrigins: [],
|
|
247
|
+
connection: () => ({
|
|
248
|
+
requestRejection(req) {
|
|
249
|
+
admissionCalls += 1;
|
|
250
|
+
return req.headers['x-test-deny'] ? 401 : undefined;
|
|
251
|
+
},
|
|
252
|
+
}),
|
|
253
|
+
});
|
|
254
|
+
assert(fenced.length === 1, 'fenced mount registers the toast route');
|
|
255
|
+
const fencedDenied = await call(fenced[0].handler, 'GET', { 'x-test-deny': '1' });
|
|
256
|
+
assert(fencedDenied.status === 401 && JSON.parse(fencedDenied.body).reason === 'unauthenticated',
|
|
257
|
+
'a connection 401 is relayed before the toast route answers');
|
|
258
|
+
const fencedProbe = JSON.parse((await call(fenced[0].handler, 'GET')).body);
|
|
259
|
+
assert(fencedProbe.ok === true && admissionCalls === 2, 'an admitted probe answers normally after one admission call');
|
|
260
|
+
const fencedPeer = await call(fenced[0].handler, 'GET', {}, undefined, '10.0.0.9');
|
|
261
|
+
assert(fencedPeer.status === 403 && JSON.parse(fencedPeer.body).reason === 'bad-remote',
|
|
262
|
+
'the plugin gate still refuses a non-loopback peer after admission');
|
|
263
|
+
|
|
214
264
|
// 3f. Removal: withdraw by page tag, resolved to the history tag.
|
|
215
265
|
spawned.length = 0;
|
|
216
266
|
const removed = await post(handler, { remove: 'tag-1' });
|
|
217
267
|
assert(removed.status === 200, 'a remove answers 200');
|
|
218
268
|
assert(spawned.length === 1 && spawned[0].args.includes('-RemoveTag') && spawned[0].args.includes(sentBody.id),
|
|
219
269
|
'the remove spawns -RemoveTag for the history tag');
|
|
270
|
+
// 3h. A toast without buttons registers the app identity first too: its body
|
|
271
|
+
// click comes back through the same protocol, and Windows only dispatches it
|
|
272
|
+
// for an AUMID that does not answer to a COM activator.
|
|
273
|
+
const plain = mount({}, { aumid: '' }); // '' falls back to the module default
|
|
274
|
+
const plainSent = JSON.parse((await post(plain[0].handler, { title: 'DSH waiting for input', body: 'session: bash', tag: 'q-1' })).body);
|
|
275
|
+
assert(plainSent.ok === true && plainSent.token === '', 'a toast without an approval key carries no token');
|
|
276
|
+
const plainRegs = execCalls.slice(-6).map((c) => c.args.join(' '));
|
|
277
|
+
assert(plainRegs.some((line) => line.includes('HKCU\\Software\\Classes\\AppUserModelId\\' + win.AUMID)),
|
|
278
|
+
'without an injected AUMID the registration writes the plugin-owned one');
|
|
279
|
+
assert(!plainRegs.some((line) => line.includes('electron.app')), 'the DSH shell AUMID is never registered here');
|
|
220
280
|
} finally {
|
|
221
281
|
if (realLocalAppData === undefined) delete process.env.LOCALAPPDATA;
|
|
222
282
|
else process.env.LOCALAPPDATA = realLocalAppData;
|
|
@@ -226,4 +286,4 @@ try {
|
|
|
226
286
|
fs.rmSync(tmp, { recursive: true, force: true });
|
|
227
287
|
}
|
|
228
288
|
|
|
229
|
-
console.log('win toast route OK: desktop gate, 405/403/501/400, payload, HKCU protocol, tokens (single-use/TTL), remove');
|
|
289
|
+
console.log('win toast route OK: desktop gate, 405/403/501/400, payload, HKCU protocol + app identity, tokens (single-use/TTL), remove');
|