creditdaddy 1.7.1 → 1.7.2
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/build.json +3 -3
- package/package.json +1 -1
- package/src/authDevice.js +3 -1
- package/src/buildInfo.js +33 -0
- package/src/checkin.js +6 -2
- package/src/constants.js +3 -2
- package/src/cookieSites.js +1 -1
- package/src/daemon.js +43 -15
- package/src/i18n/en.json +2002 -1980
- package/src/i18n/ja.json +2002 -1980
- package/src/i18n/ko.json +2002 -1980
- package/src/i18n/zh-TW.json +2002 -1980
- package/src/lingxiClient.js +46 -5
- package/src/minimaxClient.js +86 -28
- package/src/minimaxLocal.js +22 -0
- package/src/panel.html +5638 -5528
- package/src/providers.js +18 -4
- package/src/riverClient.js +55 -12
- package/src/store.js +1 -0
- package/src/tenrouterAccounts.js +232 -222
- package/src/traeAuth.js +127 -58
- package/src/traeClient.js +25 -2
- package/src/traeGateway.js +100 -37
- package/src/transfer.js +20 -1
- package/src/workbuddyLocal.js +35 -4
package/src/providers.js
CHANGED
|
@@ -15,6 +15,9 @@ import { fetchZcodeQuota } from './zcodeClient.js';
|
|
|
15
15
|
import { fetchMirasimQuota, fetchMirasimProfile } from './mirasimClient.js';
|
|
16
16
|
import { fetchCatpawQuota, fetchCatpawProfile } from './catpawClient.js';
|
|
17
17
|
import { fetchTraeQuota, checkinTrae, verifyTraeAccount } from './traeClient.js';
|
|
18
|
+
|
|
19
|
+
/** Trae 国际账号判定:provider trae-intl 或旧线账号带 isIntl 标记(浏览器 OAuth / 本机导入都落这个键) */
|
|
20
|
+
const isTraeIntl = (account) => account?.provider === 'trae-intl' || Boolean(account?.meta?.isIntl);
|
|
18
21
|
import { fetchMiniMaxQuota, checkinMiniMax, verifyMiniMaxAccount } from './minimaxClient.js';
|
|
19
22
|
import { fetchDoubaoStatus, checkinDoubao } from './doubaoClient.js';
|
|
20
23
|
import { checkinLingxi, fetchLingxiQuota } from './lingxiClient.js';
|
|
@@ -182,10 +185,21 @@ const PRODUCTS = {
|
|
|
182
185
|
},
|
|
183
186
|
trae: {
|
|
184
187
|
label: 'Trae',
|
|
185
|
-
// 每日签到发 150 通用积分(7
|
|
186
|
-
//
|
|
187
|
-
|
|
188
|
-
|
|
188
|
+
// 每日签到发 150 通用积分(7 天有效)。凭据线:本机客户端导入 + 浏览器 OAuth(授权码
|
|
189
|
+
// + PKCE)双线。国际版账号(meta.isIntl / provider trae-intl)分流跳过签到与额度——
|
|
190
|
+
// ug 签到接口只在 api.trae.cn 注册、pay 端点国际网关 404(10R traeCheckin 同口径结论),
|
|
191
|
+
// 与其每天报错不如如实说「国际线无 API 口径」(用户拍板:国际版没必要做签到)。
|
|
192
|
+
checkin: (account, ctx) => (isTraeIntl(account)
|
|
193
|
+
? { accountId: account.id, account: account.name || account.id, provider: account.provider, status: 'no-activity', message: 'Trae 国际线无每日签到(Dollar Usage 走官网 Usage 页,无 API 口径)' }
|
|
194
|
+
: checkinTrae(account, ctx)),
|
|
195
|
+
quota: (account) => {
|
|
196
|
+
if (isTraeIntl(account)) {
|
|
197
|
+
const e = new Error('Trae 国际线额度无 API 口径(Dollar Usage 只在 trae.ai 官网 Usage 页可见),不影响登录与 10Router 同步');
|
|
198
|
+
e.quotaUnavailable = true;
|
|
199
|
+
throw e;
|
|
200
|
+
}
|
|
201
|
+
return fetchTraeQuota(account);
|
|
202
|
+
},
|
|
189
203
|
verify: (account) => verifyTraeAccount(account),
|
|
190
204
|
},
|
|
191
205
|
minimax: {
|
package/src/riverClient.js
CHANGED
|
@@ -29,6 +29,35 @@ export const RIVER_STORAGE_KEYS = ['workos:access-token', 'workos:refresh-token'
|
|
|
29
29
|
/** WorkOS 刷新端点(console 配置 workos_api_hostname = auth.console.river.ai) */
|
|
30
30
|
export const RIVER_WORKOS_AUTH_BASE = 'https://auth.console.river.ai';
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* 从 JWT payload 的 exp 提取绝对到期时间(ISO 字符串)。
|
|
34
|
+
* @param {string} token
|
|
35
|
+
* @returns {string|null}
|
|
36
|
+
*/
|
|
37
|
+
export function jwtExpiresAt(token) {
|
|
38
|
+
try {
|
|
39
|
+
const part = String(token || '').split('.')[1];
|
|
40
|
+
if (!part) return null;
|
|
41
|
+
const payload = JSON.parse(Buffer.from(part, 'base64url').toString('utf8'));
|
|
42
|
+
return Number.isFinite(payload?.exp) ? new Date(payload.exp * 1000).toISOString() : null;
|
|
43
|
+
} catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 判断 Bearer token 是否已过期。
|
|
50
|
+
* 留 60 秒容差:WorkOS 上游有时钟容差(实测过期 25 秒仍返 200);
|
|
51
|
+
* 过早判定会白刷一次单次轮换的 refresh 链(多消耗一次轮换,且有与浏览器抢刷新的风险)。
|
|
52
|
+
* 只有在已过期且超过 60 秒容差后才视为过期。
|
|
53
|
+
*/
|
|
54
|
+
export function isBearerExpired(expiresAt) {
|
|
55
|
+
if (!expiresAt) return false;
|
|
56
|
+
const t = Date.parse(expiresAt);
|
|
57
|
+
if (!Number.isFinite(t)) return false;
|
|
58
|
+
return Date.now() > t + 60_000;
|
|
59
|
+
}
|
|
60
|
+
|
|
32
61
|
const RIVER_UA =
|
|
33
62
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36';
|
|
34
63
|
|
|
@@ -71,10 +100,12 @@ export function parseRiverSession(storage) {
|
|
|
71
100
|
};
|
|
72
101
|
}
|
|
73
102
|
} catch { /* user 解析失败不影响 token 可用性 */ }
|
|
103
|
+
const at = pick('workos:access-token');
|
|
104
|
+
const exp = pick('workos:expires-at') || jwtExpiresAt(at);
|
|
74
105
|
return {
|
|
75
|
-
accessToken:
|
|
106
|
+
accessToken: at,
|
|
76
107
|
refreshToken: refresh,
|
|
77
|
-
expiresAt:
|
|
108
|
+
expiresAt: exp,
|
|
78
109
|
user,
|
|
79
110
|
};
|
|
80
111
|
}
|
|
@@ -84,10 +115,14 @@ export function riverSessionOf(account) {
|
|
|
84
115
|
const cookie = account?.meta?.workosSession?.cookie || account?.meta?.cookieSiteSession?.cookie || '';
|
|
85
116
|
const sess = account?.meta?.workosSession;
|
|
86
117
|
if (sess && (sess.accessToken || account?.token || cookie)) {
|
|
87
|
-
|
|
118
|
+
const accessToken = sess.accessToken || account?.token || null;
|
|
119
|
+
const expiresAt = sess.expiresAt || account?.expiresAt || jwtExpiresAt(accessToken);
|
|
120
|
+
return { ...sess, accessToken, expiresAt, cookie: sess.cookie || cookie };
|
|
88
121
|
}
|
|
122
|
+
const accessToken = account?.token || null;
|
|
123
|
+
const expiresAt = account?.expiresAt || jwtExpiresAt(accessToken);
|
|
89
124
|
return (account?.token || cookie)
|
|
90
|
-
? { accessToken
|
|
125
|
+
? { accessToken, refreshToken: null, expiresAt, user: account?.meta?.workosUser || {}, cookie }
|
|
91
126
|
: null;
|
|
92
127
|
}
|
|
93
128
|
|
|
@@ -149,12 +184,13 @@ export async function refreshRiverSession(account, { fetchImpl, log } = {}) {
|
|
|
149
184
|
throw err;
|
|
150
185
|
}
|
|
151
186
|
const parsedUser = parseWorkOsUser(data.user) || sess.user;
|
|
187
|
+
const expiresAt = Number.isFinite(data.expires_in)
|
|
188
|
+
? new Date(Date.now() + data.expires_in * 1000).toISOString()
|
|
189
|
+
: jwtExpiresAt(data.access_token);
|
|
152
190
|
const creds = {
|
|
153
191
|
accessToken: data.access_token,
|
|
154
192
|
refreshToken: data.refresh_token || sess.refreshToken || null, // 无新 refresh 时保留旧链
|
|
155
|
-
expiresAt
|
|
156
|
-
? new Date(Date.now() + data.expires_in * 1000).toISOString()
|
|
157
|
-
: null,
|
|
193
|
+
expiresAt,
|
|
158
194
|
clientId: clientId || undefined,
|
|
159
195
|
authBase: authBase || undefined,
|
|
160
196
|
user: parsedUser,
|
|
@@ -167,6 +203,7 @@ export async function refreshRiverSession(account, { fetchImpl, log } = {}) {
|
|
|
167
203
|
const cur = list.find((it) => it.id === account.id);
|
|
168
204
|
if (cur) {
|
|
169
205
|
cur.token = creds.accessToken;
|
|
206
|
+
cur.expiresAt = creds.expiresAt;
|
|
170
207
|
cur.meta = {
|
|
171
208
|
...(cur.meta || {}),
|
|
172
209
|
workosSession: { ...(cur.meta?.workosSession || {}), ...creds },
|
|
@@ -182,6 +219,7 @@ export async function refreshRiverSession(account, { fetchImpl, log } = {}) {
|
|
|
182
219
|
if (account) {
|
|
183
220
|
account.token = creds.accessToken;
|
|
184
221
|
account.refreshToken = creds.refreshToken;
|
|
222
|
+
account.expiresAt = creds.expiresAt;
|
|
185
223
|
if (account.meta) account.meta.workosSession = { ...(account.meta.workosSession || {}), ...creds };
|
|
186
224
|
}
|
|
187
225
|
return creds;
|
|
@@ -238,12 +276,17 @@ export async function fetchRiverBalance(account, { fetchImpl, log } = {}) {
|
|
|
238
276
|
if (r.authExpired) authExpired = true;
|
|
239
277
|
misses.push(`cookie:${r.status || r.error || '?'}`);
|
|
240
278
|
}
|
|
241
|
-
// 2) Bearer
|
|
279
|
+
// 2) Bearer:本地已知过期(留 60s 容差)直接跳过,避免每轮无谓 401 浪费网络
|
|
280
|
+
const bearerExpired = isBearerExpired(sess?.expiresAt);
|
|
242
281
|
if (sess?.accessToken) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
282
|
+
if (bearerExpired) {
|
|
283
|
+
misses.push(t('bearer:过期跳过'));
|
|
284
|
+
} else {
|
|
285
|
+
const r = await attempt({ token: sess.accessToken }).catch((e) => ({ ok: false, error: e.message || String(e) }));
|
|
286
|
+
if (r.ok) return { ...r, channel: 'bearer' };
|
|
287
|
+
if (r.authExpired) authExpired = true;
|
|
288
|
+
misses.push(`bearer:${r.status || r.error || '?'}`);
|
|
289
|
+
}
|
|
247
290
|
}
|
|
248
291
|
// 3) 刷新兑换(cookie 授予或 refreshToken 授予)→ Bearer 重试
|
|
249
292
|
if (sess?.refreshToken || cookie) {
|
package/src/store.js
CHANGED
|
@@ -247,6 +247,7 @@ export function publicAccount(a) {
|
|
|
247
247
|
(a.provider.startsWith('workbuddy') && Boolean(a.token)) ||
|
|
248
248
|
a.provider === 'catpaw' ||
|
|
249
249
|
a.provider === 'trae' ||
|
|
250
|
+
a.provider === 'trae-intl' ||
|
|
250
251
|
a.provider === 'loomy'
|
|
251
252
|
),
|
|
252
253
|
canSwitchWorkbuddyClient: Boolean(meta.session?.account || (a.provider.startsWith('workbuddy') && Boolean(a.token))),
|