creditdaddy 1.7.2 → 1.8.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 (73) hide show
  1. package/LICENSE +701 -2
  2. package/README.md +454 -440
  3. package/bin/creditdaddy.js +6 -0
  4. package/build.json +3 -3
  5. package/package.json +34 -34
  6. package/src/accounts.js +15 -0
  7. package/src/assets/donate-alipay.svg +1 -1
  8. package/src/assets/donate-ifdian.svg +1 -1
  9. package/src/assets/donate-wechat.svg +1 -1
  10. package/src/assets/providers/catpaw.png +0 -0
  11. package/src/assets/providers/codebuddy-ide.png +0 -0
  12. package/src/assets/providers/dumate.png +0 -0
  13. package/src/assets/providers/loomy.png +0 -0
  14. package/src/assets/providers/meoo.png +0 -0
  15. package/src/assets/providers/mirasim.png +0 -0
  16. package/src/bgdaemon.js +341 -341
  17. package/src/buildInfo.js +65 -65
  18. package/src/catpawClient.js +103 -103
  19. package/src/catpawLocal.js +236 -236
  20. package/src/checkin.js +98 -5
  21. package/src/codebuddyIdeLocal.js +381 -381
  22. package/src/constants.js +121 -117
  23. package/src/cookieSites.js +340 -301
  24. package/src/daemon.js +2720 -2443
  25. package/src/doubaoClient.js +167 -167
  26. package/src/dumateClient.js +517 -0
  27. package/src/dumateLocal.js +298 -0
  28. package/src/dumateQr.js +337 -0
  29. package/src/externalQuota.js +577 -574
  30. package/src/formatDuration.js +17 -17
  31. package/src/i18n/en.json +257 -7
  32. package/src/i18n/ja.json +257 -7
  33. package/src/i18n/ko.json +257 -7
  34. package/src/i18n/zh-TW.json +257 -7
  35. package/src/i18n.js +47 -47
  36. package/src/lingxiClient.js +373 -373
  37. package/src/localDetect.js +147 -147
  38. package/src/longcatClient.js +260 -260
  39. package/src/loomyAuth.js +230 -230
  40. package/src/loomyClient.js +366 -366
  41. package/src/loomyLocal.js +206 -206
  42. package/src/meooAuth.js +246 -0
  43. package/src/meooClient.js +250 -0
  44. package/src/minimaxGateway.js +520 -520
  45. package/src/minimaxLocal.js +344 -344
  46. package/src/mirasimClient.js +211 -211
  47. package/src/mirasimLocal.js +392 -392
  48. package/src/modelscopeClient.js +275 -275
  49. package/src/panel.html +704 -85
  50. package/src/prodIcons.json +7 -5
  51. package/src/providers.js +34 -0
  52. package/src/qoderApp.js +578 -578
  53. package/src/qoderClient.js +266 -266
  54. package/src/qoderUmid.js +199 -199
  55. package/src/quotaRefresh.js +119 -119
  56. package/src/refreshGuard.js +75 -75
  57. package/src/riverClient.js +372 -372
  58. package/src/store.js +2 -1
  59. package/src/tenrouterAccounts.js +237 -232
  60. package/src/traeAuth.js +601 -599
  61. package/src/traeClient.js +356 -360
  62. package/src/traeGateway.js +875 -875
  63. package/src/traeLocal.js +463 -371
  64. package/src/transfer.js +4 -0
  65. package/src/usageSync.js +535 -523
  66. package/src/winProc.js +134 -134
  67. package/src/xiaomiMimoClient.js +206 -206
  68. package/src/zcodeAuth.js +131 -131
  69. package/src/zcodeAutoClaim.js +53 -6
  70. package/src/zcodeClient.js +55 -2
  71. package/src/zcodeGateway.js +850 -850
  72. package/src/zcodeLocal.js +340 -340
  73. package/src/zcrypto.js +160 -160
@@ -1,147 +1,147 @@
1
- /**
2
- * 本机 Qoder 检测 — 安装探测 + 凭据扫描。
3
- *
4
- * Qoder IDE 是 VS Code 系(Electron),凭据散落在 userData 目录;
5
- * 另扫 ~/.qoder(CLI)。扫描纯本地进行,候选 token 只保留在内存,
6
- * 面板按 candidateId 导入,token 不在日志中输出。
7
- */
8
-
9
- import fs from 'node:fs';
10
- import fsp from 'node:fs/promises';
11
- import path from 'node:path';
12
- import os from 'node:os';
13
- import crypto from 'node:crypto';
14
-
15
- // 候选内存表:candidateId → { token, file?, provider?, user?, refreshToken?, expiresAt?, at }(10 分钟过期)
16
- const candidates = new Map();
17
- const CAND_TTL_MS = 10 * 60 * 1000;
18
-
19
- const TOKEN_RE = /\b(?:dt|pt)-[A-Za-z0-9_-]{16,}\b/g;
20
-
21
- /** 纯函数:提取文本中的 Qoder token(去重)——供测试 */
22
- export function extractTokens(text) {
23
- const found = new Set();
24
- let m;
25
- TOKEN_RE.lastIndex = 0;
26
- while ((m = TOKEN_RE.exec(String(text))) !== null) found.add(m[0]);
27
- return [...found];
28
- }
29
-
30
- function mask(token) {
31
- return token.slice(0, 5) + '...' + token.slice(-4);
32
- }
33
-
34
- function isWindows() { return process.platform === 'win32'; }
35
- function isMac() { return process.platform === 'darwin'; }
36
-
37
- /** 安装探测:IDE 可执行文件 + CLI */
38
- export function detectInstalls() {
39
- const home = os.homedir();
40
- const appdata = process.env.APPDATA || path.join(home, 'AppData', 'Roaming');
41
- const localAppData = process.env.LOCALAPPDATA || path.join(home, 'AppData', 'Local');
42
- const programFiles = process.env.ProgramFiles || 'C:\\Program Files';
43
-
44
- const idePaths = isMac()
45
- ? ['/Applications/Qoder.app']
46
- : isWindows()
47
- ? [
48
- path.join(localAppData, 'Programs', 'Qoder', 'Qoder.exe'),
49
- path.join(programFiles, 'Qoder', 'Qoder.exe'),
50
- ]
51
- : ['/usr/bin/qoder', '/opt/Qoder/qoder', '/usr/share/qoder/qoder'];
52
-
53
- const ideDataDirs = isMac()
54
- ? [path.join(home, 'Library', 'Application Support', 'Qoder')]
55
- : isWindows()
56
- ? [path.join(appdata, 'Qoder')]
57
- : [path.join(home, '.config', 'Qoder')];
58
-
59
- const exists = (p) => { try { return fs.existsSync(p); } catch { return false; } };
60
-
61
- return {
62
- platform: process.platform,
63
- ide: idePaths.map((p) => ({ path: p, exists: exists(p) })),
64
- ideDataDirs: ideDataDirs.map((p) => ({ path: p, exists: exists(p) })),
65
- cliDir: { path: path.join(home, '.qoder'), exists: exists(path.join(home, '.qoder')) },
66
- installed: idePaths.some((p) => exists(p)),
67
- };
68
- }
69
-
70
- // 扫描时跳过的目录(缓存/噪音)
71
- const SKIP_DIRS = new Set([
72
- 'node_modules', '.git', 'Cache', 'CachedData', 'CacheStorage', 'Code Cache',
73
- 'GPUCache', 'logs', 'Crashes', 'crashpad', 'blob_storage', 'Service Worker',
74
- 'History', 'DawnGraphiteCache', 'DawnWebGPUCache', 'SharedDictionary',
75
- 'index', 'tmp', 'temp', 'workspaceStorage',
76
- ]);
77
-
78
- const MAX_FILE_BYTES = 1.5 * 1024 * 1024;
79
- const MAX_FILES = 4000;
80
- const MAX_MS = 6000;
81
-
82
- /** 扫描目录集合,产出候选 token(含少量上下文以辅助辨认) */
83
- export async function scanLocalTokens(dirs) {
84
- const deadline = Date.now() + MAX_MS;
85
- const found = new Map(); // token → { file, count }
86
- let scanned = 0;
87
-
88
- async function walk(dir, depth) {
89
- if (depth > 5 || scanned >= MAX_FILES || Date.now() > deadline) return;
90
- let entries;
91
- try { entries = await fsp.readdir(dir, { withFileTypes: true }); } catch { return; }
92
- for (const e of entries) {
93
- if (scanned >= MAX_FILES || Date.now() > deadline) return;
94
- const p = path.join(dir, e.name);
95
- if (e.isDirectory()) {
96
- if (!SKIP_DIRS.has(e.name) && !e.name.startsWith('.')) await walk(p, depth + 1);
97
- continue;
98
- }
99
- let st;
100
- try { st = await fsp.stat(p); } catch { continue; }
101
- if (!st.isFile() || st.size === 0 || st.size > MAX_FILE_BYTES) continue;
102
- scanned++;
103
- let text;
104
- try { text = await fsp.readFile(p, 'utf8'); } catch { continue; }
105
- for (const token of extractTokens(text)) {
106
- const prev = found.get(token);
107
- if (prev) prev.count++;
108
- else found.set(token, { file: p, count: 1 });
109
- }
110
- }
111
- }
112
-
113
- for (const d of dirs) {
114
- try { if (fs.existsSync(d) && fs.statSync(d).isDirectory()) await walk(d, 0); } catch {}
115
- }
116
-
117
- const list = [];
118
- for (const [token, meta] of found) {
119
- const id = putCandidate({ token, file: meta.file });
120
- list.push({
121
- id,
122
- tokenMasked: mask(token),
123
- kind: token.startsWith('pt-') ? 'PAT' : 'device',
124
- file: meta.file,
125
- hits: meta.count,
126
- });
127
- }
128
- list.sort((a, b) => b.hits - a.hits);
129
- return { scanned, candidates: list.slice(0, 50) };
130
- }
131
-
132
- /** 放入候选表(带 TTL),返回 candidateId。c 至少含 token,可带 provider / user / refreshToken / expiresAt */
133
- export function putCandidate(c) {
134
- const now = Date.now();
135
- for (const [k, v] of candidates) if (v.at < now - CAND_TTL_MS) candidates.delete(k);
136
- const id = crypto.createHash('sha256').update(c.token).digest('hex').slice(0, 16);
137
- candidates.set(id, { ...c, at: now });
138
- return id;
139
- }
140
-
141
- /** 按 candidateId 读取候选(不会消费掉,导入前可反复查询);过期返回 null */
142
- export function peekCandidate(id) {
143
- const c = candidates.get(id);
144
- if (!c) return null;
145
- if (c.at < Date.now() - CAND_TTL_MS) { candidates.delete(id); return null; }
146
- return c;
147
- }
1
+ /**
2
+ * 本机 Qoder 检测 — 安装探测 + 凭据扫描。
3
+ *
4
+ * Qoder IDE 是 VS Code 系(Electron),凭据散落在 userData 目录;
5
+ * 另扫 ~/.qoder(CLI)。扫描纯本地进行,候选 token 只保留在内存,
6
+ * 面板按 candidateId 导入,token 不在日志中输出。
7
+ */
8
+
9
+ import fs from 'node:fs';
10
+ import fsp from 'node:fs/promises';
11
+ import path from 'node:path';
12
+ import os from 'node:os';
13
+ import crypto from 'node:crypto';
14
+
15
+ // 候选内存表:candidateId → { token, file?, provider?, user?, refreshToken?, expiresAt?, at }(10 分钟过期)
16
+ const candidates = new Map();
17
+ const CAND_TTL_MS = 10 * 60 * 1000;
18
+
19
+ const TOKEN_RE = /\b(?:dt|pt)-[A-Za-z0-9_-]{16,}\b/g;
20
+
21
+ /** 纯函数:提取文本中的 Qoder token(去重)——供测试 */
22
+ export function extractTokens(text) {
23
+ const found = new Set();
24
+ let m;
25
+ TOKEN_RE.lastIndex = 0;
26
+ while ((m = TOKEN_RE.exec(String(text))) !== null) found.add(m[0]);
27
+ return [...found];
28
+ }
29
+
30
+ function mask(token) {
31
+ return token.slice(0, 5) + '...' + token.slice(-4);
32
+ }
33
+
34
+ function isWindows() { return process.platform === 'win32'; }
35
+ function isMac() { return process.platform === 'darwin'; }
36
+
37
+ /** 安装探测:IDE 可执行文件 + CLI */
38
+ export function detectInstalls() {
39
+ const home = os.homedir();
40
+ const appdata = process.env.APPDATA || path.join(home, 'AppData', 'Roaming');
41
+ const localAppData = process.env.LOCALAPPDATA || path.join(home, 'AppData', 'Local');
42
+ const programFiles = process.env.ProgramFiles || 'C:\\Program Files';
43
+
44
+ const idePaths = isMac()
45
+ ? ['/Applications/Qoder.app']
46
+ : isWindows()
47
+ ? [
48
+ path.join(localAppData, 'Programs', 'Qoder', 'Qoder.exe'),
49
+ path.join(programFiles, 'Qoder', 'Qoder.exe'),
50
+ ]
51
+ : ['/usr/bin/qoder', '/opt/Qoder/qoder', '/usr/share/qoder/qoder'];
52
+
53
+ const ideDataDirs = isMac()
54
+ ? [path.join(home, 'Library', 'Application Support', 'Qoder')]
55
+ : isWindows()
56
+ ? [path.join(appdata, 'Qoder')]
57
+ : [path.join(home, '.config', 'Qoder')];
58
+
59
+ const exists = (p) => { try { return fs.existsSync(p); } catch { return false; } };
60
+
61
+ return {
62
+ platform: process.platform,
63
+ ide: idePaths.map((p) => ({ path: p, exists: exists(p) })),
64
+ ideDataDirs: ideDataDirs.map((p) => ({ path: p, exists: exists(p) })),
65
+ cliDir: { path: path.join(home, '.qoder'), exists: exists(path.join(home, '.qoder')) },
66
+ installed: idePaths.some((p) => exists(p)),
67
+ };
68
+ }
69
+
70
+ // 扫描时跳过的目录(缓存/噪音)
71
+ const SKIP_DIRS = new Set([
72
+ 'node_modules', '.git', 'Cache', 'CachedData', 'CacheStorage', 'Code Cache',
73
+ 'GPUCache', 'logs', 'Crashes', 'crashpad', 'blob_storage', 'Service Worker',
74
+ 'History', 'DawnGraphiteCache', 'DawnWebGPUCache', 'SharedDictionary',
75
+ 'index', 'tmp', 'temp', 'workspaceStorage',
76
+ ]);
77
+
78
+ const MAX_FILE_BYTES = 1.5 * 1024 * 1024;
79
+ const MAX_FILES = 4000;
80
+ const MAX_MS = 6000;
81
+
82
+ /** 扫描目录集合,产出候选 token(含少量上下文以辅助辨认) */
83
+ export async function scanLocalTokens(dirs) {
84
+ const deadline = Date.now() + MAX_MS;
85
+ const found = new Map(); // token → { file, count }
86
+ let scanned = 0;
87
+
88
+ async function walk(dir, depth) {
89
+ if (depth > 5 || scanned >= MAX_FILES || Date.now() > deadline) return;
90
+ let entries;
91
+ try { entries = await fsp.readdir(dir, { withFileTypes: true }); } catch { return; }
92
+ for (const e of entries) {
93
+ if (scanned >= MAX_FILES || Date.now() > deadline) return;
94
+ const p = path.join(dir, e.name);
95
+ if (e.isDirectory()) {
96
+ if (!SKIP_DIRS.has(e.name) && !e.name.startsWith('.')) await walk(p, depth + 1);
97
+ continue;
98
+ }
99
+ let st;
100
+ try { st = await fsp.stat(p); } catch { continue; }
101
+ if (!st.isFile() || st.size === 0 || st.size > MAX_FILE_BYTES) continue;
102
+ scanned++;
103
+ let text;
104
+ try { text = await fsp.readFile(p, 'utf8'); } catch { continue; }
105
+ for (const token of extractTokens(text)) {
106
+ const prev = found.get(token);
107
+ if (prev) prev.count++;
108
+ else found.set(token, { file: p, count: 1 });
109
+ }
110
+ }
111
+ }
112
+
113
+ for (const d of dirs) {
114
+ try { if (fs.existsSync(d) && fs.statSync(d).isDirectory()) await walk(d, 0); } catch {}
115
+ }
116
+
117
+ const list = [];
118
+ for (const [token, meta] of found) {
119
+ const id = putCandidate({ token, file: meta.file });
120
+ list.push({
121
+ id,
122
+ tokenMasked: mask(token),
123
+ kind: token.startsWith('pt-') ? 'PAT' : 'device',
124
+ file: meta.file,
125
+ hits: meta.count,
126
+ });
127
+ }
128
+ list.sort((a, b) => b.hits - a.hits);
129
+ return { scanned, candidates: list.slice(0, 50) };
130
+ }
131
+
132
+ /** 放入候选表(带 TTL),返回 candidateId。c 至少含 token,可带 provider / user / refreshToken / expiresAt */
133
+ export function putCandidate(c) {
134
+ const now = Date.now();
135
+ for (const [k, v] of candidates) if (v.at < now - CAND_TTL_MS) candidates.delete(k);
136
+ const id = crypto.createHash('sha256').update(c.token).digest('hex').slice(0, 16);
137
+ candidates.set(id, { ...c, at: now });
138
+ return id;
139
+ }
140
+
141
+ /** 按 candidateId 读取候选(不会消费掉,导入前可反复查询);过期返回 null */
142
+ export function peekCandidate(id) {
143
+ const c = candidates.get(id);
144
+ if (!c) return null;
145
+ if (c.at < Date.now() - CAND_TTL_MS) { candidates.delete(id); return null; }
146
+ return c;
147
+ }