@yanglaofish/dsh-proxy-pro 2.0.1 → 2.0.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/lib/proxy-core.js CHANGED
@@ -110,6 +110,21 @@ export function normalizeProxyUrl(value) {
110
110
  return url.toString().replace(/\/+$/, '')
111
111
  }
112
112
 
113
+ /** 仅用于状态展示;传输层和可编辑配置继续使用完整的原始地址。 */
114
+ export function redactProxyUrl(value) {
115
+ if (typeof value !== 'string' || value === '') return ''
116
+ try {
117
+ const url = new URL(value)
118
+ if (!url.username && !url.password) return value
119
+ url.username = ''
120
+ url.password = ''
121
+ return url.toString().replace(/\/+$/, '')
122
+ } catch {
123
+ // 无效地址也不能把 user:password 原样带入错误提示。
124
+ return value.replace(/(https?:\/\/)[^\s/?#]*@/gi, '$1[redacted]@')
125
+ }
126
+ }
127
+
113
128
  /**
114
129
  * Parse a Windows `ProxyServer` string: single `host:port` (both protocols)
115
130
  * or `http=...;https=...` form; `socks=` ignored (undici speaks HTTP CONNECT).
@@ -324,7 +339,7 @@ export function summarize(snapshot) {
324
339
  active: effective?.active === true,
325
340
  enabled: config?.enabled === true,
326
341
  mode: config?.mode ?? 'none',
327
- url: effective?.url ?? '',
342
+ url: redactProxyUrl(effective?.url ?? ''),
328
343
  noProxy: effective?.noProxy ?? composeNoProxy(config?.noProxy),
329
344
  reason: effective?.reason ?? 'unknown',
330
345
  source: config?.mode === 'system' ? 'system' : config?.mode === 'custom' ? 'custom' : 'none',
@@ -342,7 +357,7 @@ export function summarize(snapshot) {
342
357
  export function keepaliveHint(message = '', proxyUrl = '') {
343
358
  const text = typeof message === 'string' ? message : ''
344
359
  if (!/407|NTLM|proxy authentication|authentication required/i.test(text)) return ''
345
- const example = typeof proxyUrl === 'string' && proxyUrl !== '' ? proxyUrl : 'http://localhost:7890'
360
+ const example = typeof proxyUrl === 'string' && proxyUrl !== '' ? redactProxyUrl(proxyUrl) : 'http://localhost:7890'
346
361
  return `该代理要求 NTLM 认证,undici 无法自行协商。最近一次 curl/浏览器到同一代理的连接会保持一段已认证窗口——先执行一次 \`curl -x ${example} -I https://github.com\`,然后重试。`
347
362
  }
348
363
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yanglaofish/dsh-proxy-pro",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "DSH proxy manager: route model requests, web fetches and spawned tools through the Windows system proxy or a custom address; per-URL route diagnosis, one-click toggle from the conversation header, a dedicated Settings page, and keepalive-aware 407 hints.",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -53,10 +53,10 @@
53
53
  "client": {
54
54
  "platform": "web",
55
55
  "inject": [
56
- "@deepseek-ai/dsh-client-runtime",
56
+ "@deepseek-ai/dsh-client-ui-slots",
57
57
  "@deepseek-ai/dsh-client-ui-settings",
58
58
  "@deepseek-ai/dsh-client-ui-conversation"
59
59
  ]
60
60
  }
61
61
  }
62
- }
62
+ }