@dsh-sparrow/dsh-file-manage 0.2.0-rc.2 → 0.2.1-rc.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 CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  English | [简体中文](CHANGELOG.zh-CN.md)
4
4
 
5
+ ## 0.2.1-rc.2 (2026-10-17)
6
+
7
+ - Now adapted to official dsh 0.2.1-rc.2 (web and desktop).
8
+ - Opening Cloud Files from another machine on the LAN works again: requests from a non-loopback address are no longer rejected.
9
+
5
10
  ## 0.2.0-rc.2 (2026-10-08)
6
11
 
7
12
  - Now adapted to official dsh 0.2.0-rc.2 (web and desktop).
@@ -2,6 +2,11 @@
2
2
 
3
3
  简体中文 | [English](CHANGELOG.md)
4
4
 
5
+ ## 0.2.1-rc.2(2026-10-17)
6
+
7
+ - 适配官方 dsh 0.2.1-rc.2(Web 与桌面端)。
8
+ - 从局域网内另一台机器打开「云端文件」恢复正常:非回环地址的请求不再被拒绝。
9
+
5
10
  ## 0.2.0-rc.2(2026-10-08)
6
11
 
7
12
  - 适配官方 dsh 0.2.0-rc.2(Web 与桌面端)。
package/README.md CHANGED
@@ -12,7 +12,7 @@ Large images pasted into DSH are auto-uploaded to the DeepSeek Files API, but DS
12
12
  dsh plugin --profile web add @dsh-sparrow/dsh-file-manage
13
13
  ```
14
14
 
15
- Requires dsh 0.2.0-rc.2 — the exact official version line this release is built and verified against (newer lines, pre-releases in particular, are not covered) — and a working `pnpm` (`dsh plugin` forwards installation to pnpm).
15
+ Requires dsh 0.2.1-rc.2 — the exact official version line this release is built and verified against (newer lines, pre-releases in particular, are not covered) — and a working `pnpm` (`dsh plugin` forwards installation to pnpm).
16
16
 
17
17
  > Do **not** run `npm install @dsh-sparrow/dsh-file-manage` directly: that only downloads the package into some `node_modules` and does not register it with the DSH web profile. Use the `dsh plugin` command above, then restart DSH.
18
18
 
package/README.zh-CN.md CHANGED
@@ -12,7 +12,7 @@ DSH 贴图的大图会自动上传到 DeepSeek Files API(云端文件库),
12
12
  dsh plugin --profile web add @dsh-sparrow/dsh-file-manage
13
13
  ```
14
14
 
15
- 适配 dsh 0.2.0-rc.2(本版构建与验证所对齐的确切官方版本线;更新的版本线、尤其是预发布版本不在承诺范围内),并需要可用的 `pnpm`(`dsh plugin` 会把安装操作转发给 pnpm)。
15
+ 适配 dsh 0.2.1-rc.2(本版构建与验证所对齐的确切官方版本线;更新的版本线、尤其是预发布版本不在承诺范围内),并需要可用的 `pnpm`(`dsh plugin` 会把安装操作转发给 pnpm)。
16
16
 
17
17
  > **不要**直接执行 `npm install @dsh-sparrow/dsh-file-manage`:那只会把包下载到某个 `node_modules`,不会注册进 DSH 的 web profile。请使用上面的 `dsh plugin` 命令安装,并在安装后重启 DSH。
18
18
 
package/lib/host.js CHANGED
@@ -115,7 +115,7 @@ export async function apply(ctx) {
115
115
  // 浏览器信任栅栏(官方 /api 栅栏同口径,见 trust.ts):必须在本路由**任何**
116
116
  // 分发之前 —— 官方栅栏挂在 /api 前缀上,而本路由 /api/file-manage 更长,
117
117
  // 「前缀最长者胜」使请求根本走不到官方那道检查。
118
- // 额外信任面复用官方 webRuntime.trustedHosts(故这里在**请求期**读取)。
118
+ // 额外信任面复用官方 webStartup.trustedHosts(rc.2 起;旧宿主回退 webRuntime),故这里在**请求期**读取。
119
119
  if (!isTrustedPluginRequest(req.headers, officialTrustedHosts(ctx))) {
120
120
  sendError(res, new FileManageError('FORBIDDEN', '拒绝跨站来源的请求', 403));
121
121
  return;
package/lib/trust.js CHANGED
@@ -75,26 +75,57 @@ export function isTrustedPluginRequest(headers, trustedHosts = []) {
75
75
  return false;
76
76
  }
77
77
  }
78
- /**
79
- * 官方给出的额外信任面:`webRuntime.trustedHosts` 就是喂给官方 `/api` 栅栏的同一份值 ——
80
- * 自造白名单会语义漂移,还会把 `--host 0.0.0.0` 的 LAN 用户静默挡成 403;服务缺失时回退空
81
- * (只认回环,与官方默认同口径)。⚠️ 必须**请求期**读取:webRuntime 与本插件加载顺序不保证
82
- * 谁先,apply 期读会拿到空值并永久冻结。
83
- */
84
- export function officialTrustedHosts(ctx) {
85
- let runtime;
78
+ /** 读一个官方服务值里的 `trustedHosts`:服务缺失 / 读取抛错 / 形状不对一律按空处理
79
+ * (`ctx.get` 可选读取,绝不因此让插件抛穿)。 */
80
+ function trustedHostsOfService(ctx, serviceName) {
81
+ let service;
86
82
  try {
87
- runtime = ctx.get('webRuntime');
83
+ service = ctx.get(serviceName);
88
84
  }
89
85
  catch {
90
- // 宿主不认识该服务名(老版本 / 代理路径)时按「无额外信任」处理,绝不抛穿。
86
+ // 宿主不认识该服务名(老版本 / 代理路径)时按「无额外信任」处理。
91
87
  return [];
92
88
  }
93
- if (typeof runtime !== 'object' || runtime === null)
89
+ if (typeof service !== 'object' || service === null)
94
90
  return [];
95
- const value = runtime.trustedHosts;
91
+ const value = service.trustedHosts;
96
92
  if (!Array.isArray(value))
97
93
  return [];
98
94
  return value.filter((entry) => typeof entry === 'string');
99
95
  }
96
+ /** webServer 的监听绑定地址作为一条 authority:IPv6 字面量加方括号、去掉 `%zone`(接口选择器,不是
97
+ * 地址文本);服务缺失 / 读取抛错 / 形状不对时为空。 */
98
+ function bindAddressAuthority(ctx) {
99
+ let server;
100
+ try {
101
+ server = ctx.get('webServer');
102
+ }
103
+ catch {
104
+ return [];
105
+ }
106
+ if (typeof server !== 'object' || server === null)
107
+ return [];
108
+ const host = server.host;
109
+ if (typeof host !== 'string' || host === '')
110
+ return [];
111
+ const zoneAt = host.indexOf('%');
112
+ const address = zoneAt === -1 ? host : host.slice(0, zoneAt);
113
+ return [address.includes(':') ? `[${address}]` : address];
114
+ }
115
+ /**
116
+ * 官方给出的额外信任面:`webStartup.trustedHosts`(rc.2 起即喂给官方 `/api` 栅栏的同一份值;旧宿主
117
+ * 回退 `webRuntime`),两份合并去重,再把 webServer 的监听绑定地址纳入(官方 rc.2 栅栏同样接受
118
+ * 绑定地址本身)—— 自造白名单会语义漂移,还会把 LAN 用户静默挡成 403;服务缺失时回退空
119
+ * (只认回环,与官方默认同口径)。⚠️ 必须**请求期**读取:`webStartup` 与本插件加载顺序不保证
120
+ * 谁先,apply 期读会拿到空值并永久冻结。
121
+ */
122
+ export function officialTrustedHosts(ctx) {
123
+ return [
124
+ ...new Set([
125
+ ...trustedHostsOfService(ctx, 'webStartup'),
126
+ ...trustedHostsOfService(ctx, 'webRuntime'),
127
+ ...bindAddressAuthority(ctx),
128
+ ]),
129
+ ];
130
+ }
100
131
  //# sourceMappingURL=trust.js.map
@@ -17,9 +17,10 @@ export declare function isLoopbackHostname(hostname: string): boolean;
17
17
  * 入口不许因畸形输入抛错,也不许在缺头时放行。 */
18
18
  export declare function isTrustedPluginRequest(headers: TrustHeaders | undefined, trustedHosts?: readonly string[]): boolean;
19
19
  /**
20
- * 官方给出的额外信任面:`webRuntime.trustedHosts` 就是喂给官方 `/api` 栅栏的同一份值 ——
21
- * 自造白名单会语义漂移,还会把 `--host 0.0.0.0` 的 LAN 用户静默挡成 403;服务缺失时回退空
22
- * (只认回环,与官方默认同口径)。⚠️ 必须**请求期**读取:webRuntime 与本插件加载顺序不保证
20
+ * 官方给出的额外信任面:`webStartup.trustedHosts`(rc.2 起即喂给官方 `/api` 栅栏的同一份值;旧宿主
21
+ * 回退 `webRuntime`),两份合并去重,再把 webServer 的监听绑定地址纳入(官方 rc.2 栅栏同样接受
22
+ * 绑定地址本身)—— 自造白名单会语义漂移,还会把 LAN 用户静默挡成 403;服务缺失时回退空
23
+ * (只认回环,与官方默认同口径)。⚠️ 必须**请求期**读取:`webStartup` 与本插件加载顺序不保证
23
24
  * 谁先,apply 期读会拿到空值并永久冻结。
24
25
  */
25
26
  export declare function officialTrustedHosts(ctx: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dsh-sparrow/dsh-file-manage",
3
3
  "description": "Manage DeepSeek Files API cloud files from the sidebar — list with cursor pagination, delete, and copy file_id (reuses the official DeepSeekFilesClient, no extra credentials)",
4
- "version": "0.2.0-rc.2",
4
+ "version": "0.2.1-rc.2",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -48,26 +48,26 @@
48
48
  "verify": "node ../../scripts/verify.mjs"
49
49
  },
50
50
  "peerDependencies": {
51
- "@deepseek-ai/cordis": "^4.0.4",
52
- "@deepseek-ai/dsh-credentials": "0.2.0-rc.2",
53
- "@deepseek-ai/dsh-host-webserver": "0.2.0-rc.2",
54
- "@deepseek-ai/dsh-llm": "0.2.0-rc.2",
55
- "@deepseek-ai/dsh-llm-deepseek": "0.2.0-rc.2",
56
- "@deepseek-ai/dsh-settings": "0.2.0-rc.2"
51
+ "@deepseek-ai/cordis": "^4.0.5",
52
+ "@deepseek-ai/dsh-credentials": "0.2.1-rc.2",
53
+ "@deepseek-ai/dsh-host-webserver": "0.2.1-rc.2",
54
+ "@deepseek-ai/dsh-llm": "0.2.1-rc.2",
55
+ "@deepseek-ai/dsh-llm-deepseek": "0.2.1-rc.2",
56
+ "@deepseek-ai/dsh-settings": "0.2.1-rc.2"
57
57
  },
58
58
  "devDependencies": {
59
- "@deepseek-ai/cordis": "4.0.4",
60
- "@deepseek-ai/dsh-client-locale": "0.2.0-rc.2",
61
- "@deepseek-ai/dsh-client-ui-layout": "0.2.0-rc.2",
62
- "@deepseek-ai/dsh-client-ui-primitives": "0.2.0-rc.2",
63
- "@deepseek-ai/dsh-client-ui-renderer": "0.2.0-rc.2",
64
- "@deepseek-ai/dsh-client-ui-sidebar": "0.2.0-rc.2",
65
- "@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.2",
66
- "@deepseek-ai/dsh-credentials": "0.2.0-rc.2",
67
- "@deepseek-ai/dsh-host-webserver": "0.2.0-rc.2",
68
- "@deepseek-ai/dsh-llm": "0.2.0-rc.2",
69
- "@deepseek-ai/dsh-llm-deepseek": "0.2.0-rc.2",
70
- "@deepseek-ai/dsh-settings": "0.2.0-rc.2",
59
+ "@deepseek-ai/cordis": "4.0.5",
60
+ "@deepseek-ai/dsh-client-locale": "0.2.1-rc.2",
61
+ "@deepseek-ai/dsh-client-ui-layout": "0.2.1-rc.2",
62
+ "@deepseek-ai/dsh-client-ui-primitives": "0.2.1-rc.2",
63
+ "@deepseek-ai/dsh-client-ui-renderer": "0.2.1-rc.2",
64
+ "@deepseek-ai/dsh-client-ui-sidebar": "0.2.1-rc.2",
65
+ "@deepseek-ai/dsh-client-ui-slots": "0.2.1-rc.2",
66
+ "@deepseek-ai/dsh-credentials": "0.2.1-rc.2",
67
+ "@deepseek-ai/dsh-host-webserver": "0.2.1-rc.2",
68
+ "@deepseek-ai/dsh-llm": "0.2.1-rc.2",
69
+ "@deepseek-ai/dsh-llm-deepseek": "0.2.1-rc.2",
70
+ "@deepseek-ai/dsh-settings": "0.2.1-rc.2",
71
71
  "@types/node": "^22.20.0",
72
72
  "@types/react": "~18.3.1",
73
73
  "@types/react-dom": "~18.3.1",