@wenbin_wb/dsh-bridge 2.5.1 → 2.5.3

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/lib/index.js CHANGED
@@ -193,6 +193,38 @@ class ProxyServer {
193
193
  return;
194
194
  }
195
195
 
196
+ // 3.1 本机特权 Token 签发:仅限真正物理回环连接(127.0.0.1 / ::1,严禁隧道转发流量伪造)
197
+ if (req.url === '/__dsh_bridge__/loopback-token') {
198
+ const corsHeaders = {
199
+ 'Access-Control-Allow-Origin': '*',
200
+ 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
201
+ 'Access-Control-Allow-Headers': 'Content-Type',
202
+ };
203
+ if (req.method === 'OPTIONS') {
204
+ res.writeHead(204, corsHeaders);
205
+ res.end();
206
+ return;
207
+ }
208
+
209
+ const remote = req.socket?.remoteAddress || '';
210
+ const isLoopback = (remote === '127.0.0.1' || remote === '::1' || remote === '::ffff:127.0.0.1');
211
+ const internalTunnelHeader = req.headers?.['x-dsh-internal-tunnel'];
212
+ const isCustomTunnel = Boolean(isLoopback && internalTunnelHeader && internalTunnelHeader === this.authManager?.internalTunnelSecret);
213
+ const isCloudflare = Boolean(isLoopback && (req.headers?.['cf-ray'] || req.headers?.['cf-connecting-ip']));
214
+ const isPublicTunnel = isCustomTunnel || isCloudflare;
215
+
216
+ if (isLoopback && !isPublicTunnel && this.authManager) {
217
+ const adminToken = this.authManager.createAdminSession();
218
+ res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8', ...corsHeaders });
219
+ res.end(JSON.stringify({ ok: true, adminToken }));
220
+ return;
221
+ }
222
+
223
+ res.writeHead(403, { 'Content-Type': 'application/json; charset=utf-8', ...corsHeaders });
224
+ res.end(JSON.stringify({ ok: false, error: 'Forbidden: loopback only' }));
225
+ return;
226
+ }
227
+
196
228
  // 4. 核心鉴权拦截
197
229
  const auth = this.authManager?.verifyRequest(req) ?? { authenticated: true };
198
230
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wenbin_wb/dsh-bridge",
3
- "version": "2.5.1",
3
+ "version": "2.5.3",
4
4
  "description": "手机扫码即可在移动端/公网继续用 DeepSeek Harness,人不在电脑前也能接着干。一键局域网二维码、Cloudflare 公网隧道、自建隧道与微信 / QQ / 飞书 / Telegram Bot(多工作区/会话持久化/媒体/卡片审批/流式输出),无需自己搭公网服务器。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -22,17 +22,20 @@
22
22
  ],
23
23
  "scripts": {
24
24
  "build:client": "node client/build.mjs",
25
- "prepack": "npm run build:client",
25
+ "build:lark": "node scripts/bundle-lark.mjs",
26
+ "build:banner": "node scripts/generate-banner.mjs",
27
+ "prepack": "npm run build:lark && npm run build:client",
26
28
  "test": "node --test test/*.test.mjs"
27
29
  },
28
30
  "dependencies": {
29
- "@larksuiteoapi/node-sdk": "^1.73.0",
31
+ "@deepseek-ai/dsh-llm": "0.1.0-rc.6",
30
32
  "qrcode": "^1.5.3",
31
- "ws": "^8.18.0",
32
- "@deepseek-ai/dsh-llm": "0.1.0-rc.6"
33
+ "ws": "^8.18.0"
33
34
  },
34
35
  "devDependencies": {
35
- "esbuild": "^0.25.9"
36
+ "@larksuiteoapi/node-sdk": "^1.73.0",
37
+ "esbuild": "^0.25.9",
38
+ "puppeteer-core": "^25.8.0"
36
39
  },
37
40
  "peerDependencies": {
38
41
  "@deepseek-ai/cordis": "^4.0.1"