dsh-session-sync 0.2.26 → 0.2.28

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/sanitize.mjs CHANGED
@@ -7,8 +7,13 @@
7
7
  /** URL 中视为凭据的查询键(值一律整体打码)。 */
8
8
  const CREDENTIAL_QUERY_KEYS = /^(?:access_?token|token|key|secret|password|passwd|auth|credential|code|signature|x-amz-|sig)$/iu
9
9
 
10
- /** 常见令牌形态(前缀 + 足够长的 secret)。 */
11
- const TOKEN_PATTERN = /\b(?:sk-[A-Za-z0-9_-]{8,}|ghp_[A-Za-z0-9]{16,}|gho_[A-Za-z0-9]{16,}|xox[baprs]-[A-Za-z0-9-]{8,}|AKIA[0-9A-Z]{12,}|Bearer\s+[A-Za-z0-9._~+/=-]{8,}|authorization:\s*[A-Za-z0-9._~+/=-]{8,})/giu
10
+ /**
11
+ * 常见令牌形态(前缀 + 足够长的 secret)。
12
+ * `gh[pousr]_` 覆盖 GitHub 的 ghp/gho/ghu/ghs/ghr 全家族;`github_pat_` 单列
13
+ * (fine-grained PAT 是现在的默认形态,曾整体漏网);其余为各家用得最广的
14
+ * 前缀形态。
15
+ */
16
+ const TOKEN_PATTERN = /\b(?:sk-[A-Za-z0-9_-]{8,}|gh[pousr]_[A-Za-z0-9]{16,}|github_pat_[A-Za-z0-9_]{20,}|glpat-[A-Za-z0-9_-]{16,}|gldt-[A-Za-z0-9_-]{16,}|npm_[A-Za-z0-9]{30,}|pypi-[A-Za-z0-9_-]{16,}|xox[baprs]-[A-Za-z0-9-]{8,}|AKIA[0-9A-Z]{12,}|AIza[0-9A-Za-z_-]{30,}|ya29\.[A-Za-z0-9_-]{20,}|SG\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]{43}|dop_v1_[A-Fa-f0-9]{40,}|shpat_[A-Fa-f0-9]{32,}|eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}|Bearer\s+[A-Za-z0-9._~+/=-]{8,}|authorization:\s*[A-Za-z0-9._~+/=-]{8,})/giu
12
17
 
13
18
  /** key=value 形态的凭据(值整体打码)。 */
14
19
  const CREDENTIAL_ASSIGNMENT = /\b((?:api[_-]?key|access[_-]?token|auth[_-]?token|refresh[_-]?token|password|passwd|client[_-]?secret|private[_-]?key)\s*=\s*)([^\s&;,]+)/giu
@@ -16,6 +21,24 @@ const CREDENTIAL_ASSIGNMENT = /\b((?:api[_-]?key|access[_-]?token|auth[_-]?token
16
21
  /** URL userinfo(user:password@)——git stderr 可能回显远端地址。 */
17
22
  const URL_USERINFO = /\/\/([^/\s:@]+):([^/\s@]+)@/gu
18
23
 
24
+ /**
25
+ * 无密码时,URL 里的用户名本身是否就是凭据。
26
+ * `https://<token>@host/…` 是 PAT 最常见的免交互写法:此时用户名字段装的是
27
+ * 密钥而不是身份,`user:pass@` 的「用户名不是秘密」前提在这里不成立。
28
+ * @param {string} username - URL 的用户名部分。
29
+ * @returns {boolean} 是否按凭据处理。
30
+ */
31
+ function usernameIsCredential(username) {
32
+ if (username.length === 0) return false
33
+ if (redactText(username) !== username) return true
34
+ if (/^[A-Fa-f0-9]{16,}$/u.test(username)) return true
35
+ if (username.length >= 20 && !/[-_.]/u.test(username)) {
36
+ const classes = [/[a-z]/u, /[A-Z]/u, /[0-9]/u].filter(pattern => pattern.test(username)).length
37
+ if (classes >= 2) return true
38
+ }
39
+ return false
40
+ }
41
+
19
42
  /**
20
43
  * 脱敏 remote URL:用户信息中的密码打码,凭据查询键的值打码。
21
44
  * scp 语法(user@host:path)不含密码,原样保留(用户名不是秘密)。
@@ -27,23 +50,19 @@ export function sanitizeRemote(remote) {
27
50
  const trimmed = remote.trim()
28
51
  try {
29
52
  const url = new URL(trimmed)
30
- // Token-in-username is a real git credential form (`https://<token>@host`).
31
- // Keep a normal username when a password is present; otherwise mask a
32
- // token-shaped username. A plain `user@host` stays readable.
33
53
  if (url.username !== '' && url.password !== '') {
34
54
  url.password = '***'
35
- return url.toString()
36
- }
37
- if (url.username !== '' && (/token|ghp_|github_pat_|glpat-|sk-|x-access-token/i.test(url.username) || url.username.length >= 32)) {
38
- url.username = '***'
39
- return url.toString()
55
+ } else if (url.username !== '') {
56
+ if (usernameIsCredential(url.username)) url.username = '***'
40
57
  }
41
58
  for (const key of [...url.searchParams.keys()]) {
42
59
  if (CREDENTIAL_QUERY_KEYS.test(key)) url.searchParams.set(key, '***')
43
60
  }
44
61
  return url.toString()
45
62
  } catch {
46
- return remote
63
+ // 解析失败(scp 语法、畸形 URL)走通用脱敏。模块契约是「输入不合法时返回
64
+ // 保守的脱敏文本」:原样回显会让畸形 URL 里的令牌直接落到日志与模型。
65
+ return redactText(trimmed)
47
66
  }
48
67
  }
49
68
 
package/lib/status.mjs CHANGED
File without changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-session-sync",
3
3
  "description": "Cross-device sync for DeepSeek Harness sessions: a dedicated git mirror of the session store, append-only three-way merge with keep-both + fork conflict resolution, /sync command, sync_pull/sync_push/sync_status tools, and configurable auto push/pull",
4
- "version": "0.2.26",
4
+ "version": "0.2.28",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/PerryLink/dsh-session-sync.git"
@@ -114,22 +114,22 @@
114
114
  "zod": "^4.4.3"
115
115
  },
116
116
  "devDependencies": {
117
- "@deepseek-ai/dsh-attachment": "0.2.1-alpha.1",
117
+ "@deepseek-ai/dsh-attachment": "0.2.1-rc.2",
118
118
  "@deepseek-ai/cordis": "^4.0.5-alpha.1",
119
119
  "@deepseek-ai/cordis-plugin-include": "^1.0.10-alpha.1",
120
120
  "@deepseek-ai/cordis-plugin-loader": "^1.0.6-alpha.1",
121
- "@deepseek-ai/dsh-commands": "0.2.1-alpha.1",
122
- "@deepseek-ai/dsh-llm": "0.2.1-alpha.1",
123
- "@deepseek-ai/dsh-session": "0.2.1-alpha.1",
124
- "@deepseek-ai/dsh-session-format-v3-to-v4": "0.2.1-alpha.1",
125
- "@deepseek-ai/dsh-storage": "0.2.1-alpha.1",
126
- "@deepseek-ai/dsh-storage-domain": "0.2.1-alpha.1",
127
- "@deepseek-ai/dsh-storage-json": "0.2.1-alpha.1",
128
- "@deepseek-ai/dsh-subprocess": "0.2.1-alpha.1",
129
- "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.1",
130
- "@deepseek-ai/dsh-tools": "0.2.1-alpha.1",
131
- "@deepseek-ai/dsh-user-approval": "0.2.1-alpha.1",
132
- "@deepseek-ai/dsh-user-questions": "0.2.1-alpha.1",
121
+ "@deepseek-ai/dsh-commands": "0.2.1-rc.2",
122
+ "@deepseek-ai/dsh-llm": "0.2.1-rc.2",
123
+ "@deepseek-ai/dsh-session": "0.2.1-rc.2",
124
+ "@deepseek-ai/dsh-session-format-v3-to-v4": "0.2.1-rc.2",
125
+ "@deepseek-ai/dsh-storage": "0.2.1-rc.2",
126
+ "@deepseek-ai/dsh-storage-domain": "0.2.1-rc.2",
127
+ "@deepseek-ai/dsh-storage-json": "0.2.1-rc.2",
128
+ "@deepseek-ai/dsh-subprocess": "0.2.1-rc.2",
129
+ "@deepseek-ai/dsh-system-prompt": "0.2.1-rc.2",
130
+ "@deepseek-ai/dsh-tools": "0.2.1-rc.2",
131
+ "@deepseek-ai/dsh-user-approval": "0.2.1-rc.2",
132
+ "@deepseek-ai/dsh-user-questions": "0.2.1-rc.2",
133
133
  "@deepseek-ai/schemastery": "^3.18.5-alpha.1",
134
134
  "@types/node": "^22.19.0",
135
135
  "oxlint": "0.18.1",
package/types.d.ts CHANGED
File without changes