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,167 +1,167 @@
1
- /**
2
- * 豆包(doubao.com)网页会话 — 每日签到领体验额度(issue #32)。
3
- *
4
- * POST https://www.doubao.com/alice/ug/campaign/v3/detail/ 任务面板数据(含签到状态)
5
- * POST https://www.doubao.com/alice/ug/campaign/landing/checkin 领取(+200 额度/天)
6
- *
7
- * 鉴权:纯 doubao.com 会话 cookie(网页捕获线),无 a_bogus / msToken 请求签名;
8
- * device_id 空可过;服务端自带幂等(重复领取返回 idempotent:true 不重复发放)。
9
- * 接口形状 2026-10-19/20 带调试端口实测(CDP 挂监听抓已签 + 未签两个场景)。
10
- *
11
- * 参与门槛:仅个人账号(飞书企业号被排除,活动页会提示「请切换至个人账号」)。
12
- * 活动页 UI 有「仅支持豆包电脑版」前端墙,但接口不吃这套——cookie 直打即通。
13
- */
14
-
15
- import crypto from 'node:crypto';
16
- import { fetchJsonRace } from './zcodeClient.js';
17
- import { FETCH_TIMEOUT_MS } from './constants.js';
18
-
19
- const DETAIL_URL = 'https://www.doubao.com/alice/ug/campaign/v3/detail/';
20
- const CHECKIN_URL = 'https://www.doubao.com/alice/ug/campaign/landing/checkin';
21
- /** 任务面板所属活动组(pc 端激励任务 v3;签到是其中的 daily_signin 任务) */
22
- const CAMPAIGN_GROUP = 'pc_incentive_task_mvp_v3';
23
-
24
- /**
25
- * 客户端指纹伪装(issue #32 用户实测反馈:纯网页 cookie 裸 UA 打活动接口吃「请求非法」,
26
- * 活动在服务端按客户端环境放行)。指纹 = 豆包桌面版 webview 的完整请求形状(CDP 抓包):
27
- * - UA 与 webview 同款(Chrome/147 + DoubaoWebView 标识)
28
- * - URL 必带 version_code / device_platform=web / web_platform=desktop / aid 等平台参数
29
- * - web_id / tea_uuid 按账号 uid 确定性派生(每号一台稳定「设备」,同 attempt 语义)
30
- * - device_id 空(实测可过)
31
- */
32
- const CLIENT_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) DoubaoDesktop/2.32.6 Chrome/147.0.7727.149 Safari/537.36';
33
- const COMMON_PARAMS = {
34
- version_code: '20800',
35
- language: 'zh',
36
- device_platform: 'web',
37
- doubao_device_platform: 'web',
38
- aid: '497858',
39
- real_aid: '497858',
40
- pkg_type: 'release_version',
41
- pc_version: '2.32.6',
42
- doubao_pc_version: '5.72.66',
43
- samantha_web: '1',
44
- web_platform: 'desktop',
45
- 'use-olympus-account': '1',
46
- web_tab_id: '0',
47
- };
48
-
49
- /** 按 uid 派生稳定设备标识(每号恒定,账号间互异;纯数字 web_id 风格) */
50
- function deviceIdsFor(uid) {
51
- const seed = crypto.createHash('sha256').update(`doubao-dev:${uid || 'anonymous'}`).digest();
52
- const webId = '76' + [...seed.subarray(0, 8)].map((b) => b % 10).join(''); // 18 位数字
53
- const teaUuid = [...seed.subarray(8, 16)].map((b) => (b % 10)).join('').padEnd(16, '7');
54
- return { web_id: webId, tea_uuid: teaUuid };
55
- }
56
-
57
- /** 组装带客户端指纹的接口 URL */
58
- function apiUrl(base, uid) {
59
- const params = new URLSearchParams({ ...COMMON_PARAMS, ...deviceIdsFor(uid), device_id: '', region: '', sys_region: '' });
60
- return base + '?' + params.toString();
61
- }
62
-
63
- const postJson = (url, cookie, body, uid) => fetchJsonRace(url, {
64
- method: 'POST',
65
- headers: {
66
- Cookie: String(cookie || ''),
67
- 'Content-Type': 'application/json',
68
- Accept: 'application/json, text/plain, */*',
69
- Referer: 'https://www.doubao.com/pc/agent-explore',
70
- Origin: 'https://www.doubao.com',
71
- 'User-Agent': CLIENT_UA,
72
- },
73
- body: JSON.stringify(body),
74
- timeoutMs: FETCH_TIMEOUT_MS,
75
- });
76
-
77
- /** 会话失效的业务码(实测:匿名 / 过期 cookie 返 code 710012001「登录已过期」) */
78
- const LOGIN_INVALID = 710012001;
79
-
80
- /** detail 响应里挖签到任务(tasks[].task_kind === 'daily_signin') */
81
- function findCheckinTask(body) {
82
- const tasks = body?.data?.tasks;
83
- if (!Array.isArray(tasks)) return null;
84
- return tasks.find((t) => t && t.task_kind === 'daily_signin') || null;
85
- }
86
-
87
- /**
88
- * 签到状态 + 体验额度读数(detail 接口一次拿全)。
89
- * @returns {{ auth: boolean, code: number|string|null, checkin: { checkedIn: boolean, continuousDays: number, lastDate: string, rewardAmount: number }|null, totalAmount: number|null }}
90
- */
91
- /**
92
- * 签到状态 + 体验额度读数(detail 接口一次拿全)。uid 用于派生稳定设备指纹。
93
- * @returns {{ auth: boolean, code: number|string|null, checkin: object|null, totalAmount: number|null }}
94
- */
95
- export async function fetchDoubaoStatus(cookie, uid = '') {
96
- const res = await postJson(apiUrl(DETAIL_URL, uid), cookie, { campaign_group_code: CAMPAIGN_GROUP }, uid);
97
- let body = null;
98
- try { body = JSON.parse(await res.text()); } catch { /* 非 JSON */ }
99
- if (!body || typeof body !== 'object') return { auth: false, code: `HTTP ${res.status}`, checkin: null, totalAmount: null };
100
- const code = Number(body.code);
101
- if (code === LOGIN_INVALID) return { auth: false, code, checkin: null, totalAmount: null };
102
- const task = findCheckinTask(body);
103
- const c = task?.daily_checkin || {};
104
- return {
105
- auth: true,
106
- code,
107
- checkin: task ? {
108
- checkedIn: c.checked_in_today === true,
109
- continuousDays: Number(c.continuous_days) || 0,
110
- lastDate: typeof c.last_checkin_date === 'string' ? c.last_checkin_date : null,
111
- rewardAmount: Number(c.reward?.reward_amount) || 0,
112
- } : null,
113
- totalAmount: Number(body.data?.progress?.total_amount) || 0,
114
- };
115
- }
116
-
117
- /**
118
- * 每日签到:先查状态,未签才 claim。返回 CreditDaddy 签到契约。
119
- * 服务端幂等:重复领取 code 0 + idempotent:true——归 already 不算错误。
120
- */
121
- export async function checkinDoubao(account) {
122
- const base = { accountId: account.id, account: account.name || account.id, provider: 'doubao' };
123
- const cookie = account.meta?.cookieSiteSession?.cookie || account.cookie;
124
- if (!cookie) return { ...base, status: 'failed', message: '缺少豆包会话 cookie(请重新登录捕获)' };
125
-
126
- const uid = account.uid || '';
127
- let st;
128
- try {
129
- st = await fetchDoubaoStatus(cookie, uid);
130
- } catch (e) {
131
- return { ...base, status: 'failed', message: e?.message || '网络错误' };
132
- }
133
- if (!st.auth) {
134
- const e = new Error('豆包会话已失效,请重新登录捕获');
135
- e.auth = true;
136
- throw e;
137
- }
138
- if (st.checkin?.checkedIn) {
139
- return { ...base, status: 'already', message: '今天已签到', uid: null };
140
- }
141
- if (!st.checkin) {
142
- // 活动下线 / 飞书企业号被排除等场景:detail 里没有签到任务
143
- return { ...base, status: 'no-activity', message: '当前账号无签到任务(活动可能未开放,或飞书企业账号不支持参与)' };
144
- }
145
-
146
- let body = null;
147
- try {
148
- const res = await postJson(apiUrl(CHECKIN_URL, uid), cookie, { scene: CAMPAIGN_GROUP }, uid);
149
- const text = await res.text();
150
- body = JSON.parse(text);
151
- } catch (e) {
152
- return { ...base, status: 'failed', message: e?.message || '网络错误' };
153
- }
154
- if (!body || typeof body !== 'object') return { ...base, status: 'failed', message: '签到接口返回无法解析' };
155
- const code = Number(body.code);
156
- if (code === LOGIN_INVALID) {
157
- const e = new Error('豆包会话已失效,请重新登录捕获');
158
- e.auth = true;
159
- throw e;
160
- }
161
- if (code !== 0) return { ...base, status: 'failed', message: `${body.msg || body.message || '签到失败'}(code ${code})` };
162
- const d = body.data || {};
163
- if (d.idempotent === true) return { ...base, status: 'already', message: '今天已签到(服务端幂等去重)' };
164
- const amount = Number(d.reward_amount) || st.checkin.rewardAmount || 200;
165
- const days = Number(d.continuous_days) || st.checkin.continuousDays + 1;
166
- return { ...base, status: 'checked-in', claimedAmount: amount, message: `签到成功,+${amount} 额度(连续 ${days} 天)` };
167
- }
1
+ /**
2
+ * 豆包(doubao.com)网页会话 — 每日签到领体验额度(issue #32)。
3
+ *
4
+ * POST https://www.doubao.com/alice/ug/campaign/v3/detail/ 任务面板数据(含签到状态)
5
+ * POST https://www.doubao.com/alice/ug/campaign/landing/checkin 领取(+200 额度/天)
6
+ *
7
+ * 鉴权:纯 doubao.com 会话 cookie(网页捕获线),无 a_bogus / msToken 请求签名;
8
+ * device_id 空可过;服务端自带幂等(重复领取返回 idempotent:true 不重复发放)。
9
+ * 接口形状 2026-10-19/20 带调试端口实测(CDP 挂监听抓已签 + 未签两个场景)。
10
+ *
11
+ * 参与门槛:仅个人账号(飞书企业号被排除,活动页会提示「请切换至个人账号」)。
12
+ * 活动页 UI 有「仅支持豆包电脑版」前端墙,但接口不吃这套——cookie 直打即通。
13
+ */
14
+
15
+ import crypto from 'node:crypto';
16
+ import { fetchJsonRace } from './zcodeClient.js';
17
+ import { FETCH_TIMEOUT_MS } from './constants.js';
18
+
19
+ const DETAIL_URL = 'https://www.doubao.com/alice/ug/campaign/v3/detail/';
20
+ const CHECKIN_URL = 'https://www.doubao.com/alice/ug/campaign/landing/checkin';
21
+ /** 任务面板所属活动组(pc 端激励任务 v3;签到是其中的 daily_signin 任务) */
22
+ const CAMPAIGN_GROUP = 'pc_incentive_task_mvp_v3';
23
+
24
+ /**
25
+ * 客户端指纹伪装(issue #32 用户实测反馈:纯网页 cookie 裸 UA 打活动接口吃「请求非法」,
26
+ * 活动在服务端按客户端环境放行)。指纹 = 豆包桌面版 webview 的完整请求形状(CDP 抓包):
27
+ * - UA 与 webview 同款(Chrome/147 + DoubaoWebView 标识)
28
+ * - URL 必带 version_code / device_platform=web / web_platform=desktop / aid 等平台参数
29
+ * - web_id / tea_uuid 按账号 uid 确定性派生(每号一台稳定「设备」,同 attempt 语义)
30
+ * - device_id 空(实测可过)
31
+ */
32
+ const CLIENT_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) DoubaoDesktop/2.32.6 Chrome/147.0.7727.149 Safari/537.36';
33
+ const COMMON_PARAMS = {
34
+ version_code: '20800',
35
+ language: 'zh',
36
+ device_platform: 'web',
37
+ doubao_device_platform: 'web',
38
+ aid: '497858',
39
+ real_aid: '497858',
40
+ pkg_type: 'release_version',
41
+ pc_version: '2.32.6',
42
+ doubao_pc_version: '5.72.66',
43
+ samantha_web: '1',
44
+ web_platform: 'desktop',
45
+ 'use-olympus-account': '1',
46
+ web_tab_id: '0',
47
+ };
48
+
49
+ /** 按 uid 派生稳定设备标识(每号恒定,账号间互异;纯数字 web_id 风格) */
50
+ function deviceIdsFor(uid) {
51
+ const seed = crypto.createHash('sha256').update(`doubao-dev:${uid || 'anonymous'}`).digest();
52
+ const webId = '76' + [...seed.subarray(0, 8)].map((b) => b % 10).join(''); // 18 位数字
53
+ const teaUuid = [...seed.subarray(8, 16)].map((b) => (b % 10)).join('').padEnd(16, '7');
54
+ return { web_id: webId, tea_uuid: teaUuid };
55
+ }
56
+
57
+ /** 组装带客户端指纹的接口 URL */
58
+ function apiUrl(base, uid) {
59
+ const params = new URLSearchParams({ ...COMMON_PARAMS, ...deviceIdsFor(uid), device_id: '', region: '', sys_region: '' });
60
+ return base + '?' + params.toString();
61
+ }
62
+
63
+ const postJson = (url, cookie, body, uid) => fetchJsonRace(url, {
64
+ method: 'POST',
65
+ headers: {
66
+ Cookie: String(cookie || ''),
67
+ 'Content-Type': 'application/json',
68
+ Accept: 'application/json, text/plain, */*',
69
+ Referer: 'https://www.doubao.com/pc/agent-explore',
70
+ Origin: 'https://www.doubao.com',
71
+ 'User-Agent': CLIENT_UA,
72
+ },
73
+ body: JSON.stringify(body),
74
+ timeoutMs: FETCH_TIMEOUT_MS,
75
+ });
76
+
77
+ /** 会话失效的业务码(实测:匿名 / 过期 cookie 返 code 710012001「登录已过期」) */
78
+ const LOGIN_INVALID = 710012001;
79
+
80
+ /** detail 响应里挖签到任务(tasks[].task_kind === 'daily_signin') */
81
+ function findCheckinTask(body) {
82
+ const tasks = body?.data?.tasks;
83
+ if (!Array.isArray(tasks)) return null;
84
+ return tasks.find((t) => t && t.task_kind === 'daily_signin') || null;
85
+ }
86
+
87
+ /**
88
+ * 签到状态 + 体验额度读数(detail 接口一次拿全)。
89
+ * @returns {{ auth: boolean, code: number|string|null, checkin: { checkedIn: boolean, continuousDays: number, lastDate: string, rewardAmount: number }|null, totalAmount: number|null }}
90
+ */
91
+ /**
92
+ * 签到状态 + 体验额度读数(detail 接口一次拿全)。uid 用于派生稳定设备指纹。
93
+ * @returns {{ auth: boolean, code: number|string|null, checkin: object|null, totalAmount: number|null }}
94
+ */
95
+ export async function fetchDoubaoStatus(cookie, uid = '') {
96
+ const res = await postJson(apiUrl(DETAIL_URL, uid), cookie, { campaign_group_code: CAMPAIGN_GROUP }, uid);
97
+ let body = null;
98
+ try { body = JSON.parse(await res.text()); } catch { /* 非 JSON */ }
99
+ if (!body || typeof body !== 'object') return { auth: false, code: `HTTP ${res.status}`, checkin: null, totalAmount: null };
100
+ const code = Number(body.code);
101
+ if (code === LOGIN_INVALID) return { auth: false, code, checkin: null, totalAmount: null };
102
+ const task = findCheckinTask(body);
103
+ const c = task?.daily_checkin || {};
104
+ return {
105
+ auth: true,
106
+ code,
107
+ checkin: task ? {
108
+ checkedIn: c.checked_in_today === true,
109
+ continuousDays: Number(c.continuous_days) || 0,
110
+ lastDate: typeof c.last_checkin_date === 'string' ? c.last_checkin_date : null,
111
+ rewardAmount: Number(c.reward?.reward_amount) || 0,
112
+ } : null,
113
+ totalAmount: Number(body.data?.progress?.total_amount) || 0,
114
+ };
115
+ }
116
+
117
+ /**
118
+ * 每日签到:先查状态,未签才 claim。返回 CreditDaddy 签到契约。
119
+ * 服务端幂等:重复领取 code 0 + idempotent:true——归 already 不算错误。
120
+ */
121
+ export async function checkinDoubao(account) {
122
+ const base = { accountId: account.id, account: account.name || account.id, provider: 'doubao' };
123
+ const cookie = account.meta?.cookieSiteSession?.cookie || account.cookie;
124
+ if (!cookie) return { ...base, status: 'failed', message: '缺少豆包会话 cookie(请重新登录捕获)' };
125
+
126
+ const uid = account.uid || '';
127
+ let st;
128
+ try {
129
+ st = await fetchDoubaoStatus(cookie, uid);
130
+ } catch (e) {
131
+ return { ...base, status: 'failed', message: e?.message || '网络错误' };
132
+ }
133
+ if (!st.auth) {
134
+ const e = new Error('豆包会话已失效,请重新登录捕获');
135
+ e.auth = true;
136
+ throw e;
137
+ }
138
+ if (st.checkin?.checkedIn) {
139
+ return { ...base, status: 'already', message: '今天已签到', uid: null };
140
+ }
141
+ if (!st.checkin) {
142
+ // 活动下线 / 飞书企业号被排除等场景:detail 里没有签到任务
143
+ return { ...base, status: 'no-activity', message: '当前账号无签到任务(活动可能未开放,或飞书企业账号不支持参与)' };
144
+ }
145
+
146
+ let body = null;
147
+ try {
148
+ const res = await postJson(apiUrl(CHECKIN_URL, uid), cookie, { scene: CAMPAIGN_GROUP }, uid);
149
+ const text = await res.text();
150
+ body = JSON.parse(text);
151
+ } catch (e) {
152
+ return { ...base, status: 'failed', message: e?.message || '网络错误' };
153
+ }
154
+ if (!body || typeof body !== 'object') return { ...base, status: 'failed', message: '签到接口返回无法解析' };
155
+ const code = Number(body.code);
156
+ if (code === LOGIN_INVALID) {
157
+ const e = new Error('豆包会话已失效,请重新登录捕获');
158
+ e.auth = true;
159
+ throw e;
160
+ }
161
+ if (code !== 0) return { ...base, status: 'failed', message: `${body.msg || body.message || '签到失败'}(code ${code})` };
162
+ const d = body.data || {};
163
+ if (d.idempotent === true) return { ...base, status: 'already', message: '今天已签到(服务端幂等去重)' };
164
+ const amount = Number(d.reward_amount) || st.checkin.rewardAmount || 200;
165
+ const days = Number(d.continuous_days) || st.checkin.continuousDays + 1;
166
+ return { ...base, status: 'checked-in', claimedAmount: amount, message: `签到成功,+${amount} 额度(连续 ${days} 天)` };
167
+ }