dsh-checkin-all 1.1.0 → 1.1.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.
package/README.md CHANGED
@@ -450,9 +450,11 @@ POST {openApi}/sash/api/v1/me/campaigns/{id}/claim 幂等领取(重复返回
450
450
 
451
451
  - 国内版 `https://openapi.qoder.com.cn`,国际版 `https://openapi.qoder.sh`
452
452
  - 凭据有两条路,**优先用本机 Qoder App 的登录**(零配置):
453
- 1. 本机 Qoder 桌面 App 登录态:`<App Support>/com.qoder.app.stable/auth.v1.dat`
454
- (Electron safeStorage,密钥在钥匙串「Qoder App Safe Storage」),
455
- 解出来直接当 token 用;`authenticationContext` 里是 `openapi.qoder.sh` 就走国际版
453
+ 1. 本机 Qoder 桌面 App 登录态(国内版优先,国际版兜底):
454
+ - 国内版:`<App Support>/com.qodercn.app.stable/auth.v1.dat`,密钥在钥匙串「Qoder CN App Safe Storage」
455
+ - 国际版:`<App Support>/com.qoder.app.stable/auth.v1.dat`,密钥在钥匙串「Qoder App Safe Storage」
456
+
457
+ (Electron safeStorage)解出来直接当 token 用;`authenticationContext` 里是 `openapi.qoder.sh` 就走国际版
456
458
  2. 个人访问令牌(PAT):面板里填,存 `~/.dsh/dsh-checkin-all/secrets.json`(0600),
457
459
  会先打 `exchange` 接口验真再落盘
458
460
  - 「今天」按**北京时间**算
@@ -780,6 +782,14 @@ node --test "test/*.test.js"
780
782
  `DeepSeek Harness` `dsh` `dsh-plugin` `cordis` `插件` `面板` `dashboard`
781
783
  `北京时区` `beijing-time` `零配置` `本机凭据` `OAuth`
782
784
 
785
+ ## 贡献者
786
+
787
+ 感谢以下朋友的贡献:
788
+
789
+ - [@holyhigh-dodo10901](https://github.com/holyhigh-dodo10901):支持 Qoder 国内版(CN)客户端的登录态识别([#1](https://github.com/AIcivilization/dsh-checkin-all/pull/1))
790
+
791
+ 欢迎提 Issue 和 PR。
792
+
783
793
  ## License
784
794
 
785
795
  MIT
@@ -25,18 +25,54 @@ const runExec = promisify(execFile)
25
25
  * 读本机 Qoder 桌面 App 的登录(只读,不写回)。
26
26
  *
27
27
  * Qoder 把 OAuth 登录态存在 Electron safeStorage 里:
28
- * <App Support>/com.qoder.app.stable/auth.v1.dat
29
- * 格式 v10/v11 + AES-128-CBC,密钥来自钥匙串「Qoder App Safe Storage」
28
+ * 国内版 <App Support>/com.qodercn.app.stable/auth.v1.dat
29
+ * 国际版 <App Support>/com.qoder.app.stable/auth.v1.dat
30
+ * 格式 v10/v11 + AES-128-CBC,密钥来自钥匙串
31
+ * (国内版「Qoder CN App Safe Storage」,国际版「Qoder App Safe Storage」)
30
32
  * 解出来 { token, refreshToken, expiresAt, user, authenticationContext }。
31
33
  * authenticationContext 里带 openapi.qoder.sh => 海外版。
32
34
  *
33
35
  * 读不到就返回 null,调用方回退到手工配置的 PAT。
34
36
  */
37
+ /**
38
+ * Qoder 桌面 App 在本机的两种发行版:
39
+ * 国内版 com.qodercn.app.stable 钥匙串「Qoder CN App Safe Storage」
40
+ * 国际版 com.qoder.app.stable 钥匙串「Qoder App Safe Storage」
41
+ * 两者 auth.v1.dat 格式一致(v10/v11 + AES-CBC),只有目录名和钥匙串条目名不同。
42
+ * 因此按「国内版优先、国际版兜底」逐个尝试,任一命中即可。
43
+ */
44
+ export const QODER_APP_CANDIDATES = [
45
+ { appDir: 'com.qodercn.app.stable', keychainNames: ['Qoder CN', 'Qoder'] },
46
+ { appDir: 'com.qoder.app.stable', keychainNames: ['Qoder'] },
47
+ ]
48
+
49
+ /** Qoder 数据根目录:macOS <Home>/Library/Application Support,Windows %APPDATA% */
50
+ export function qoderAppSupportRoot(env = process.env, platform = process.platform) {
51
+ return platform === 'darwin'
52
+ ? join(env.HOME || homedir(), 'Library', 'Application Support')
53
+ : join(env.APPDATA || join(env.HOME || homedir(), 'AppData', 'Roaming'))
54
+ }
55
+
56
+ /** 按优先级列出本机可能存在的 Qoder 数据目录(只列举,不判断是否存在) */
57
+ export function qoderLoginDirs(env = process.env, platform = process.platform) {
58
+ const root = qoderAppSupportRoot(env, platform)
59
+ return QODER_APP_CANDIDATES.map(candidate => ({
60
+ ...candidate,
61
+ dir: join(root, candidate.appDir),
62
+ }))
63
+ }
64
+
35
65
  export async function readLocalQoderLogin(env = process.env, platform = process.platform) {
36
66
  if (platform !== 'darwin' && platform !== 'win32') return null
37
- const dir = platform === 'darwin'
38
- ? join(env.HOME || homedir(), 'Library', 'Application Support', 'com.qoder.app.stable')
39
- : join(env.APPDATA || join(env.HOME || homedir(), 'AppData', 'Roaming'), 'com.qoder.app.stable')
67
+ for (const candidate of qoderLoginDirs(env, platform)) {
68
+ const login = await readQoderLoginFrom(candidate, platform)
69
+ if (login) return login
70
+ }
71
+ return null
72
+ }
73
+
74
+ /** 从单个候选目录解出登录态;目录不存在或解不开都返回 null,交给下一个候选 */
75
+ async function readQoderLoginFrom({ dir, keychainNames }, platform) {
40
76
  let buf
41
77
  try {
42
78
  buf = await readFile(join(dir, 'auth.v1.dat'))
@@ -48,50 +84,54 @@ export async function readLocalQoderLogin(env = process.env, platform = process.
48
84
  const body = buf.subarray(3)
49
85
  if (platform !== 'darwin') return null
50
86
 
51
- const password = await macSafeStorageKey()
52
- if (!password) return null
53
-
54
- for (const keyLen of [16, 32]) {
55
- try {
56
- const key = pbkdf2Sync(password, 'saltysalt', 1003, keyLen, 'sha1')
57
- const decipher = createDecipheriv(`aes-${keyLen * 8}-cbc`, key, Buffer.alloc(16, 0x20))
58
- const plain = Buffer.concat([decipher.update(body), decipher.final()])
59
- // Chromium 的 v10 可能带 32 字节 host 前缀,从第一个 { 开始解析
60
- const text = plain.toString('utf8')
61
- const start = text.indexOf('{')
62
- if (start < 0) continue
63
- const json = JSON.parse(text.slice(start))
64
- if (typeof json.token !== 'string' || !json.token) continue
65
- const ctx = String(json.authenticationContext || '')
66
- return {
67
- token: json.token,
68
- refreshToken: typeof json.refreshToken === 'string' ? json.refreshToken : '',
69
- expiresAt: json.expiresAt || '',
70
- email: (json.user && json.user.email) || '',
71
- region: /openapi[.]qoder[.]sh/.test(ctx) ? 'intl'
72
- : /openapi[.]qoder[.]com[.]cn/.test(ctx) ? 'cn'
73
- : 'intl',
87
+ const passwords = await macSafeStorageKeys(keychainNames)
88
+ if (passwords.length === 0) return null
89
+
90
+ for (const password of passwords) {
91
+ for (const keyLen of [16, 32]) {
92
+ try {
93
+ const key = pbkdf2Sync(password, 'saltysalt', 1003, keyLen, 'sha1')
94
+ const decipher = createDecipheriv(`aes-${keyLen * 8}-cbc`, key, Buffer.alloc(16, 0x20))
95
+ const plain = Buffer.concat([decipher.update(body), decipher.final()])
96
+ // Chromium 的 v10 可能带 32 字节 host 前缀,从第一个 { 开始解析
97
+ const text = plain.toString('utf8')
98
+ const start = text.indexOf('{')
99
+ if (start < 0) continue
100
+ const json = JSON.parse(text.slice(start))
101
+ if (typeof json.token !== 'string' || !json.token) continue
102
+ const ctx = String(json.authenticationContext || '')
103
+ return {
104
+ token: json.token,
105
+ refreshToken: typeof json.refreshToken === 'string' ? json.refreshToken : '',
106
+ expiresAt: json.expiresAt || '',
107
+ email: (json.user && json.user.email) || '',
108
+ region: /openapi[.]qoder[.]sh/.test(ctx) ? 'intl'
109
+ : /openapi[.]qoder[.]com[.]cn/.test(ctx) ? 'cn'
110
+ : 'intl',
111
+ }
112
+ } catch {
113
+ // 换下一个密钥长度
74
114
  }
75
- } catch {
76
- // 换下一个密钥长度
77
115
  }
78
116
  }
79
117
  return null
80
118
  }
81
119
 
82
- /** macOS 钥匙串里那个 App 的 safeStorage 密码 */
83
- async function macSafeStorageKey() {
84
- const name = 'Qoder'
85
- for (const service of [`${name} App Safe Storage`, `${name} Safe Storage`]) {
86
- try {
87
- const out = await runExec('/usr/bin/security', ['find-generic-password', '-w', '-s', service], { timeout: 30_000 })
88
- const v = (out.stdout || '').trim()
89
- if (v) return v
90
- } catch {
91
- // 换下一个服务名
120
+ /** macOS 钥匙串里该 App 的 safeStorage 密码,按候选名依次尝试(去重保序) */
121
+ async function macSafeStorageKeys(names) {
122
+ const found = []
123
+ for (const name of names) {
124
+ for (const service of [`${name} App Safe Storage`, `${name} Safe Storage`]) {
125
+ try {
126
+ const out = await runExec('/usr/bin/security', ['find-generic-password', '-w', '-s', service], { timeout: 30_000 })
127
+ const v = (out.stdout || '').trim()
128
+ if (v && !found.includes(v)) found.push(v)
129
+ } catch {
130
+ // 换下一个服务名
131
+ }
92
132
  }
93
133
  }
94
- return null
134
+ return found
95
135
  }
96
136
 
97
137
  export const QODER_REGIONS = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-checkin-all",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "每日自动签到领积分:内置 MiniMax Code、WPS 灵犀、百度 DuMate、AStudio、Qoder、Trae、豆包、华为 CodeArts、腾讯 WorkBuddy、商汤小浣熊、天翼 AI(TeleAgent) 十一个服务,凭据从本机 App 自动读,零配置。支持多账号、自定义签到服务(DIY 一份 JSON 就能加卡片)、连续签到记账、面板折叠排序。DeepSeek Harness (dsh) 插件。",
5
5
  "keywords": [
6
6
  "dsh-plugin",