creditdaddy 0.9.5 → 1.2.0

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/src/constants.js CHANGED
@@ -1,81 +1,97 @@
1
- /**
2
- * CreditDaddy 常量 — 支持的产品线与 Qoder 官方 OpenAPI 端点(WorkBuddy 端点见 workbuddyClient.js)。
3
- *
4
- * 端点与请求头结构来自社区逆向成果(10router 项目实测可用):
5
- * openapi.qoder.sh 国际版:活动/签到、userinfo、配额、PAT 兑换
6
- * openapi.qoder.com.cn 国内版:同上
7
- *
8
- * ⚠️ 非官方接口,Qoder 调整服务端时可能失效。
9
- */
10
-
11
- import { readFileSync } from 'node:fs';
12
-
13
- export const OPENAPI_BASE = 'https://openapi.qoder.sh';
14
- export const CN_OPENAPI_BASE = 'https://openapi.qoder.com.cn';
15
-
16
- export const LOGIN_URL = 'https://qoder.com/device/selectAccounts';
17
- export const CN_LOGIN_URL = 'https://qoder.cn/device/selectAccounts';
18
-
19
- // 活动(签到)列表与领取
20
- export const CAMPAIGNS_PATH = '/sash/api/v1/me/campaigns?clientType=10';
21
- export const CAMPAIGN_CLAIM_PATH = (id) => `/sash/api/v1/me/campaigns/${encodeURIComponent(id)}/claim`;
22
-
23
- // 账号信息与配额
24
- export const USERINFO_PATH = '/api/v1/userinfo';
25
- export const QUOTA_USAGE_PATH = '/api/v2/quota/usage';
26
-
27
- // PAT (pt-...) → 短期 job token (jt-...) 兑换(普通 JSON POST,无需 COSY 签名)
28
- export const JOB_TOKEN_EXCHANGE_PATH = '/api/v1/jobToken/exchange';
29
-
30
- // 账号的 provider = 产品 + 区域。新增产品时在此登记,并在 providers.js 挂上对应实现。
31
- export const PROVIDERS = ['qoder', 'qoder-cn', 'workbuddy', 'workbuddy-intl', 'zcode', 'mirasim'];
32
- export const PROVIDER_LABEL = {
33
- qoder: 'Qoder 国际版',
34
- 'qoder-cn': 'Qoder 国内版',
35
- workbuddy: 'WorkBuddy 国内版',
36
- 'workbuddy-intl': 'WorkBuddy 国际版',
37
- zcode: 'ZCode',
38
- mirasim: 'mirasim',
39
- };
40
- /** provider → 产品线(qoder / workbuddy / zcode / mirasim) */
41
- export const productOf = (provider) => {
42
- const p = String(provider);
43
- if (p.startsWith('workbuddy')) return 'workbuddy';
44
- if (p.startsWith('zcode')) return 'zcode';
45
- if (p === 'mirasim') return 'mirasim';
46
- return 'qoder';
47
- };
48
- /** provider 是否国内版 */
49
- export const isCnProvider = (provider) => provider === 'qoder-cn' || provider === 'workbuddy';
50
-
51
- /** 签到请求头(源自 10router qoderCheckin.js,clientType=10 与官方客户端一致) */
52
- export function buildQoderHeaders(token) {
53
- return {
54
- Authorization: `Bearer ${token}`,
55
- 'Cosy-ClientType': '10',
56
- 'Cosy-Version': '0.3.3',
57
- 'Cosy-MachineOS':
58
- process.platform === 'win32' ? 'windows'
59
- : process.platform === 'darwin' ? 'macos' : 'linux',
60
- 'User-Agent': 'Qoder',
61
- Accept: 'application/json',
62
- };
63
- }
64
-
65
- /** PAT 兑换请求头(源自 10router qoderModels.js,模拟官方 qodercli) */
66
- export function buildExchangeHeaders() {
67
- return {
68
- 'Content-Type': 'application/json',
69
- Accept: 'application/json',
70
- 'User-Agent': 'qodercli/1.0.0',
71
- 'Cosy-Version': '1.0.0',
72
- 'Cosy-ClientType': '5',
73
- };
74
- }
75
-
76
- export const FETCH_TIMEOUT_MS = 15000;
77
-
78
- // 版本号 / 项目主页以 package.json 为唯一来源(桌面版 / fpk 打包时都会一并拷入 package.json)
79
- const PKG = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
80
- export const APP_VERSION = PKG.version;
81
- export const PROJECT_URL = PKG.homepage || 'https://github.com/techysy/CreditDaddy';
1
+ /**
2
+ * CreditDaddy 常量 — 支持的产品线与 Qoder 官方 OpenAPI 端点(WorkBuddy 端点见 workbuddyClient.js)。
3
+ *
4
+ * 端点与请求头结构来自社区逆向成果(10router 项目实测可用):
5
+ * openapi.qoder.sh 国际版:活动/签到、userinfo、配额、PAT 兑换
6
+ * openapi.qoder.com.cn 国内版:同上
7
+ *
8
+ * ⚠️ 非官方接口,Qoder 调整服务端时可能失效。
9
+ */
10
+
11
+ import { readFileSync } from 'node:fs';
12
+
13
+ export const OPENAPI_BASE = 'https://openapi.qoder.sh';
14
+ export const CN_OPENAPI_BASE = 'https://openapi.qoder.com.cn';
15
+
16
+ // 网页端(账号设置 → 用量明细)同源 API:逐资源包明细只在这里提供,且只认浏览器登录后的会话 Cookie。
17
+ export const WEB_BASE = 'https://qoder.com';
18
+ export const CN_WEB_BASE = 'https://qoder.cn';
19
+
20
+ export const LOGIN_URL = 'https://qoder.com/device/selectAccounts';
21
+ export const CN_LOGIN_URL = 'https://qoder.cn/device/selectAccounts';
22
+
23
+ // 活动(签到)列表与领取
24
+ export const CAMPAIGNS_PATH = '/sash/api/v1/me/campaigns?clientType=10';
25
+ export const CAMPAIGN_CLAIM_PATH = (id) => `/sash/api/v1/me/campaigns/${encodeURIComponent(id)}/claim`;
26
+
27
+ // 账号信息与配额
28
+ export const USERINFO_PATH = '/api/v1/userinfo';
29
+ export const QUOTA_USAGE_PATH = '/api/v2/quota/usage';
30
+ // 网页端逐资源包用量明细(plan / 个人资源包 / 组织资源包,含每包到期时间)。
31
+ // 仅接受浏览器登录的会话 Cookie(dt- / jt- token 一律 401),见 qoderClient.fetchUsageDetail。
32
+ export const WEB_USAGE_PATH = '/api/v2/me/usages/big_model_credits';
33
+
34
+ // PAT (pt-...) → 短期 job token (jt-...) 兑换(普通 JSON POST,无需 COSY 签名)
35
+ export const JOB_TOKEN_EXCHANGE_PATH = '/api/v1/jobToken/exchange';
36
+
37
+ // 账号的 provider = 产品 + 区域。新增产品时在此登记,并在 providers.js 挂上对应实现。
38
+ export const PROVIDERS = ['qoder', 'qoder-cn', 'workbuddy', 'workbuddy-intl', 'zcode', 'mirasim', 'catpaw', 'trae'];
39
+ export const PROVIDER_LABEL = {
40
+ qoder: 'Qoder 国际版',
41
+ 'qoder-cn': 'Qoder 国内版',
42
+ workbuddy: 'WorkBuddy 国内版',
43
+ 'workbuddy-intl': 'WorkBuddy 国际版',
44
+ zcode: 'ZCode',
45
+ mirasim: 'mirasim',
46
+ catpaw: '妙手',
47
+ trae: 'Trae',
48
+ };
49
+ /** provider → 产品线(qoder / workbuddy / zcode / mirasim / catpaw / trae) */
50
+ export const productOf = (provider) => {
51
+ const p = String(provider);
52
+ if (p.startsWith('workbuddy')) return 'workbuddy';
53
+ if (p.startsWith('zcode')) return 'zcode';
54
+ if (p === 'mirasim') return 'mirasim';
55
+ if (p === 'catpaw') return 'catpaw';
56
+ if (p.startsWith('trae')) return 'trae';
57
+ return 'qoder';
58
+ };
59
+ /** provider 是否国内版 */
60
+ export const isCnProvider = (provider) => provider === 'qoder-cn' || provider === 'workbuddy';
61
+
62
+ /** Qoder 网页端同源 API 的 host(用量明细逐资源包接口在这里,只认浏览器会话 Cookie) */
63
+ export function webBase(provider) {
64
+ return provider === 'qoder-cn' ? CN_WEB_BASE : WEB_BASE;
65
+ }
66
+
67
+ /** 签到请求头(源自 10router qoderCheckin.js,clientType=10 与官方客户端一致) */
68
+ export function buildQoderHeaders(token) {
69
+ return {
70
+ Authorization: `Bearer ${token}`,
71
+ 'Cosy-ClientType': '10',
72
+ 'Cosy-Version': '0.3.3',
73
+ 'Cosy-MachineOS':
74
+ process.platform === 'win32' ? 'windows'
75
+ : process.platform === 'darwin' ? 'macos' : 'linux',
76
+ 'User-Agent': 'Qoder',
77
+ Accept: 'application/json',
78
+ };
79
+ }
80
+
81
+ /** PAT 兑换请求头(源自 10router qoderModels.js,模拟官方 qodercli) */
82
+ export function buildExchangeHeaders() {
83
+ return {
84
+ 'Content-Type': 'application/json',
85
+ Accept: 'application/json',
86
+ 'User-Agent': 'qodercli/1.0.0',
87
+ 'Cosy-Version': '1.0.0',
88
+ 'Cosy-ClientType': '5',
89
+ };
90
+ }
91
+
92
+ export const FETCH_TIMEOUT_MS = 15000;
93
+
94
+ // 版本号 / 项目主页以 package.json 为唯一来源(桌面版 / fpk 打包时都会一并拷入 package.json)
95
+ const PKG = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
96
+ export const APP_VERSION = PKG.version;
97
+ export const PROJECT_URL = PKG.homepage || 'https://github.com/techysy/CreditDaddy';