dsh-qwenwork-connect 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/lib/loopback.js +14 -3
  2. package/package.json +1 -1
package/lib/loopback.js CHANGED
@@ -14,10 +14,21 @@
14
14
  * 那时 Host 不是环回但请求仍来自本机代理;部署时用这个环境变量补齐。
15
15
  */
16
16
  function extraTrustedHosts() {
17
- const raw = process.env.QWENWORK_TRUSTED_HOSTS ?? '';
17
+ const parts = [];
18
+ const fromEnv = process.env.QWENWORK_TRUSTED_HOSTS;
19
+ if (typeof fromEnv === 'string' && fromEnv.length > 0) parts.push(fromEnv);
20
+ // DSH 往往由 systemd 托管,进程环境改不了;用文件更实际:
21
+ // ~/.dsh/qwenwork-trusted-hosts,一行一个域名(也接受逗号分隔)。
22
+ try {
23
+ const file = path.join(os.homedir(), '.dsh', 'qwenwork-trusted-hosts');
24
+ parts.push(fs.readFileSync(file, 'utf8'));
25
+ } catch {
26
+ // 没有这个文件就是不需要额外放行
27
+ }
18
28
  return new Set(
19
- raw
20
- .split(',')
29
+ parts
30
+ .join(',')
31
+ .split(/[s,]+/)
21
32
  .map((item) => item.trim().toLowerCase())
22
33
  .filter((item) => item.length > 0),
23
34
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-qwenwork-connect",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "千问办公(QwenWork)的 DSH 模型提供方:device flow 登录、官方网关、支持工具调用",
5
5
  "license": "MIT",
6
6
  "author": "AaIchhe",