dsh-notify-me 1.20.0 → 1.20.1
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 +12 -0
- package/LICENSE +21 -21
- package/lib/client.js +1 -1
- package/lib/win-toast.js +27 -5
- package/package.json +1 -1
- package/smoke/win-toast-test.mjs +17 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to **dsh-notify-me** are documented here.
|
|
4
4
|
|
|
5
|
+
## [1.20.1] — 2026-11-13
|
|
6
|
+
|
|
7
|
+
Windows 中文用户名下点审批通知的「同意 / 拒绝」不再弹脚本错误:协议处理器改成纯 ASCII + UTF-16LE BOM 落盘。
|
|
8
|
+
|
|
9
|
+
### 修复
|
|
10
|
+
|
|
11
|
+
- **非 ASCII 用户名下点通知按钮必弹 800A004C**([#36](https://github.com/chromoany/dsh-notify-me/issues/36)):`notify-handler.vbs` 原来按 UTF-8 无 BOM 写入,且把 `C:\Users\<用户名>\AppData\Local\dsh-notify-me\actions` 整个绝对路径烘进脚本。WSH 用系统 ANSI 代码页(中文是 CP936)解码这种文件,中文用户名被按双字节拆开、路径里的反斜杠被吃掉,第 8 行 `FolderExists` 找不到目录,于是每次点按钮都弹 Windows Script Host 错误框,动作写不进 actions 目录,DSH 也不会被唤回。现在脚本里只写 `sh.ExpandEnvironmentStrings("%LOCALAPPDATA%") & "\dsh-notify-me\actions"`,点击时才解析路径,脚本正文保持纯 ASCII;文件本身同时改成 UTF-16LE + BOM 写入,将来真有非 ASCII 进脚本也不会被按 ANSI 解码。
|
|
12
|
+
|
|
13
|
+
### 测试
|
|
14
|
+
|
|
15
|
+
- `smoke/win-toast-test.mjs` 原来用 UTF-8 回读脚本并断言包含临时目录路径,恰好把编码问题盖住;现在断言脚本带 UTF-16LE BOM、正文纯 ASCII、含 `ExpandEnvironmentStrings` 表达式、不烘入任何 profile 路径。测试把 `LOCALAPPDATA` 指向临时目录,走的是生产分支。
|
|
16
|
+
|
|
5
17
|
## [1.20.0] — 2026-11-12
|
|
6
18
|
|
|
7
19
|
同源中继可以按网关自己的字段形状发请求体了:`relay.bodyTemplate` 写一段 JSON 模板,宿主渲染后转发;模板配错在宿主启动时就拦下,不会让每条提醒都回 500。
|
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/lib/client.js
CHANGED
|
@@ -3300,7 +3300,7 @@
|
|
|
3300
3300
|
});
|
|
3301
3301
|
} catch (e) {}
|
|
3302
3302
|
// keep in sync with package.json "version" on every release
|
|
3303
|
-
api.version = "1.20.
|
|
3303
|
+
api.version = "1.20.1";
|
|
3304
3304
|
api.setConfig = function (patch) { return setConfigLocal(patch); };
|
|
3305
3305
|
api.resetConfig = function () {
|
|
3306
3306
|
try {
|
package/lib/win-toast.js
CHANGED
|
@@ -57,10 +57,26 @@ function wscriptPath() {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
* The protocol handler: record the clicked URL, then raise DSH.
|
|
61
|
-
*
|
|
62
|
-
*
|
|
60
|
+
* The protocol handler: record the clicked URL, then raise DSH.
|
|
61
|
+
*
|
|
62
|
+
* The script stays pure ASCII: the actions directory is resolved from
|
|
63
|
+
* %LOCALAPPDATA% when the click happens rather than baked into the file. A
|
|
64
|
+
* profile path like C:\Users\<中文名>\... written as UTF-8 without a BOM is
|
|
65
|
+
* decoded by WSH with the system ANSI code page, which ate the backslash after
|
|
66
|
+
* the user name and made FolderExists fail with 800A004C (issue #36). Even so
|
|
67
|
+
* the file is written as UTF-16LE with a BOM: any non-ASCII that ever reaches
|
|
68
|
+
* it would then decode correctly.
|
|
63
69
|
*/
|
|
70
|
+
function actionsDirExpression(actionsDir) {
|
|
71
|
+
const defaultDir = process.env.LOCALAPPDATA
|
|
72
|
+
? join(process.env.LOCALAPPDATA, "dsh-notify-me", "actions")
|
|
73
|
+
: "";
|
|
74
|
+
if (defaultDir && actionsDir.toLowerCase() === defaultDir.toLowerCase()) {
|
|
75
|
+
return 'sh.ExpandEnvironmentStrings("%LOCALAPPDATA%") & "\\dsh-notify-me\\actions"';
|
|
76
|
+
}
|
|
77
|
+
return '"' + actionsDir + '"';
|
|
78
|
+
}
|
|
79
|
+
|
|
64
80
|
function handlerVbs(actionsDir) {
|
|
65
81
|
return [
|
|
66
82
|
"' Generated by dsh-notify-me. Records a toast action click and raises DSH.",
|
|
@@ -69,7 +85,7 @@ function handlerVbs(actionsDir) {
|
|
|
69
85
|
'Set fso = CreateObject("Scripting.FileSystemObject")',
|
|
70
86
|
'Set sh = CreateObject("WScript.Shell")',
|
|
71
87
|
"url = WScript.Arguments(0)",
|
|
72
|
-
|
|
88
|
+
"dir = " + actionsDirExpression(actionsDir),
|
|
73
89
|
"If Not fso.FolderExists(dir) Then fso.CreateFolder(dir)",
|
|
74
90
|
"name = fso.GetTempName()",
|
|
75
91
|
"Set out = fso.CreateTextFile(dir & \"\\\" & name, True)",
|
|
@@ -80,6 +96,12 @@ function handlerVbs(actionsDir) {
|
|
|
80
96
|
].join("\r\n");
|
|
81
97
|
}
|
|
82
98
|
|
|
99
|
+
/** UTF-16LE with a BOM: WSH must not decode the handler with the ANSI code page. */
|
|
100
|
+
function writeHandlerScript(vbsPath, actionsDir) {
|
|
101
|
+
const body = Buffer.from(handlerVbs(actionsDir), "utf16le");
|
|
102
|
+
writeFileSync(vbsPath, Buffer.concat([Buffer.from([0xff, 0xfe]), body]));
|
|
103
|
+
}
|
|
104
|
+
|
|
83
105
|
/**
|
|
84
106
|
* Register the route — only on the packed Windows desktop shell.
|
|
85
107
|
* @param webCtx - cordis context holding `webServer`.
|
|
@@ -155,7 +177,7 @@ export function mountWinToast(webCtx, config, shared, logger, deps = {}) {
|
|
|
155
177
|
protocolReady = (async () => {
|
|
156
178
|
try {
|
|
157
179
|
mkdirSync(actionsDir, { recursive: true });
|
|
158
|
-
|
|
180
|
+
writeHandlerScript(vbsPath, actionsDir);
|
|
159
181
|
} catch (e) {
|
|
160
182
|
return false;
|
|
161
183
|
}
|
package/package.json
CHANGED
package/smoke/win-toast-test.mjs
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
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
7
|
// POST send/remove), the decoded toast payload, the HKCU protocol registration,
|
|
8
|
-
// and the token rules — single use,
|
|
8
|
+
// the encoding of the generated VBS handler, and the token rules — single use,
|
|
9
|
+
// bound to one approval key, expiring.
|
|
9
10
|
import fs from 'node:fs';
|
|
10
11
|
import os from 'node:os';
|
|
11
12
|
import path from 'node:path';
|
|
@@ -20,11 +21,15 @@ const win = await import(pathToFileURL(path.join(ROOT, 'lib', 'win-toast.js')).h
|
|
|
20
21
|
assert(win.WIN_TOAST_ROUTE === '/__dsh-notify-me/win-toast', 'WIN_TOAST_ROUTE is the path the page calls');
|
|
21
22
|
|
|
22
23
|
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'dsh-notify-me-win-'));
|
|
24
|
+
// mountWinToast derives its directories from %LOCALAPPDATA% on Windows; point
|
|
25
|
+
// that at the scratch dir so the test never touches the real profile directory.
|
|
26
|
+
const realLocalAppData = process.env.LOCALAPPDATA;
|
|
27
|
+
process.env.LOCALAPPDATA = tmp;
|
|
23
28
|
const psPath = path.join(tmp, 'powershell.exe');
|
|
24
29
|
const scriptPath = path.join(tmp, 'win-toast.ps1');
|
|
25
30
|
fs.writeFileSync(psPath, '');
|
|
26
31
|
fs.writeFileSync(scriptPath, '');
|
|
27
|
-
const actionsDir = path.join(tmp, 'actions');
|
|
32
|
+
const actionsDir = path.join(tmp, 'dsh-notify-me', 'actions');
|
|
28
33
|
|
|
29
34
|
const spawned = [];
|
|
30
35
|
const execCalls = [];
|
|
@@ -61,7 +66,6 @@ function mount(config = {}, deps = {}) {
|
|
|
61
66
|
win.mountWinToast(ctx, config, { bindHost: undefined, allowedOrigins: [] }, undefined, {
|
|
62
67
|
spawn: fakeSpawn,
|
|
63
68
|
execFile: fakeExec,
|
|
64
|
-
dir: tmp,
|
|
65
69
|
psPath: psPath,
|
|
66
70
|
scriptPath: scriptPath,
|
|
67
71
|
aumid: 'test.aumid',
|
|
@@ -153,9 +157,15 @@ try {
|
|
|
153
157
|
assert(execCalls.length === 3, 'first approval registers the protocol with three reg.exe calls');
|
|
154
158
|
assert(execCalls[0].file === 'reg' && execCalls[0].args.join(' ').includes('HKCU\\Software\\Classes\\dsh-notify-me'),
|
|
155
159
|
'the protocol is registered under HKCU\\Software\\Classes');
|
|
156
|
-
const handlerVbs = path.join(tmp, 'notify-handler.vbs');
|
|
160
|
+
const handlerVbs = path.join(tmp, 'dsh-notify-me', 'notify-handler.vbs');
|
|
157
161
|
assert(fs.existsSync(handlerVbs), 'the protocol handler script is written');
|
|
158
|
-
|
|
162
|
+
const vbsBytes = fs.readFileSync(handlerVbs);
|
|
163
|
+
assert(vbsBytes[0] === 0xff && vbsBytes[1] === 0xfe, 'the handler script carries a UTF-16LE BOM');
|
|
164
|
+
const vbsText = vbsBytes.subarray(2).toString('utf16le');
|
|
165
|
+
assert(/^[\x00-\x7f]*$/.test(vbsText), 'the handler script is pure ASCII, so a non-ASCII profile path cannot be garbled');
|
|
166
|
+
assert(vbsText.includes('sh.ExpandEnvironmentStrings("%LOCALAPPDATA%") & "\\dsh-notify-me\\actions"'),
|
|
167
|
+
'the actions directory is resolved from %LOCALAPPDATA% at click time');
|
|
168
|
+
assert(!vbsText.includes(tmp), 'no profile path is baked into the handler script');
|
|
159
169
|
|
|
160
170
|
// 3b. Approve click: single use, bound to the approval key.
|
|
161
171
|
writeAction('a1.txt', 'dsh-notify-me://approve?token=' + sentBody.token);
|
|
@@ -194,6 +204,8 @@ try {
|
|
|
194
204
|
assert(spawned.length === 1 && spawned[0].args.includes('-RemoveTag') && spawned[0].args.includes(sentBody.id),
|
|
195
205
|
'the remove spawns -RemoveTag for the history tag');
|
|
196
206
|
} finally {
|
|
207
|
+
if (realLocalAppData === undefined) delete process.env.LOCALAPPDATA;
|
|
208
|
+
else process.env.LOCALAPPDATA = realLocalAppData;
|
|
197
209
|
Object.defineProperty(process, 'platform', realPlatform);
|
|
198
210
|
if (realElectron === undefined) delete process.versions.electron;
|
|
199
211
|
else Object.defineProperty(process.versions, 'electron', { value: realElectron, configurable: true, writable: true });
|