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/tenrouterAccounts.js
CHANGED
|
@@ -1,222 +1,232 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CreditDaddy 账号 → 10Router 连接同步:把本机管理的订阅账号推给 10Router 当上游连接。
|
|
3
|
-
*
|
|
4
|
-
* 通道一(推荐):POST /api/oauth/transfer/import —— 需在 10Router 设置里配置「面板密码」。
|
|
5
|
-
* 完整 OAuth 形态(accessToken + refreshToken),10R 端按 JWT sub 去重并原位更新,反复同步幂等;
|
|
6
|
-
* 先用面板密码登录(/api/auth/login)换 auth_token 会话再推送——transfer 路由只认会话 / CLI token。
|
|
7
|
-
* 通道二(默认):POST /api/providers —— 仅用已配的 sk- 虚拟 key。
|
|
8
|
-
* dashboardGuard 为远程 agent 留的口子(POST /api/providers 认虚拟 key);apikey 形态、
|
|
9
|
-
* 不带 refreshToken,token 过期后需重新同步;同名连接返回 409 且不覆盖。
|
|
10
|
-
*
|
|
11
|
-
* 扩展新产品:在 TENROUTER_PROVIDER_MAP 加一行即可(如 zcode → glm 等反代就绪后补上),
|
|
12
|
-
* 同步主流程只读这张表,无需改动其他代码。
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import crypto from 'node:crypto';
|
|
16
|
-
import { buildExportPayload, sealTransfer } from './transfer.js';
|
|
17
|
-
|
|
18
|
-
/** CreditDaddy provider → 10Router 连接类型。留空 / 缺失 = 该产品暂不同步。 */
|
|
19
|
-
export const TENROUTER_PROVIDER_MAP = {
|
|
20
|
-
qoder: 'qoder',
|
|
21
|
-
'qoder-cn': 'qoder-cn',
|
|
22
|
-
workbuddy: 'codebuddy-cn',
|
|
23
|
-
'workbuddy-intl': 'codebuddy-intl',
|
|
24
|
-
minimax: 'minimax-code', // #55:MiniMax 国内订阅线 → 10R minimax-code
|
|
25
|
-
'minimax-global': 'minimax-code-global', // #55:MiniMax 国际订阅线 → 10R minimax-code-global
|
|
26
|
-
trae: 'trae-cn', // #56:CD 的 Trae 线读国内客户端(#28)→ 10R trae-cn(条目钉死国内站)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
...(
|
|
45
|
-
...(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
//
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
else
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
*
|
|
129
|
-
* -
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
1
|
+
/**
|
|
2
|
+
* CreditDaddy 账号 → 10Router 连接同步:把本机管理的订阅账号推给 10Router 当上游连接。
|
|
3
|
+
*
|
|
4
|
+
* 通道一(推荐):POST /api/oauth/transfer/import —— 需在 10Router 设置里配置「面板密码」。
|
|
5
|
+
* 完整 OAuth 形态(accessToken + refreshToken),10R 端按 JWT sub 去重并原位更新,反复同步幂等;
|
|
6
|
+
* 先用面板密码登录(/api/auth/login)换 auth_token 会话再推送——transfer 路由只认会话 / CLI token。
|
|
7
|
+
* 通道二(默认):POST /api/providers —— 仅用已配的 sk- 虚拟 key。
|
|
8
|
+
* dashboardGuard 为远程 agent 留的口子(POST /api/providers 认虚拟 key);apikey 形态、
|
|
9
|
+
* 不带 refreshToken,token 过期后需重新同步;同名连接返回 409 且不覆盖。
|
|
10
|
+
*
|
|
11
|
+
* 扩展新产品:在 TENROUTER_PROVIDER_MAP 加一行即可(如 zcode → glm 等反代就绪后补上),
|
|
12
|
+
* 同步主流程只读这张表,无需改动其他代码。
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import crypto from 'node:crypto';
|
|
16
|
+
import { buildExportPayload, sealTransfer } from './transfer.js';
|
|
17
|
+
|
|
18
|
+
/** CreditDaddy provider → 10Router 连接类型。留空 / 缺失 = 该产品暂不同步。 */
|
|
19
|
+
export const TENROUTER_PROVIDER_MAP = {
|
|
20
|
+
qoder: 'qoder',
|
|
21
|
+
'qoder-cn': 'qoder-cn',
|
|
22
|
+
workbuddy: 'codebuddy-cn',
|
|
23
|
+
'workbuddy-intl': 'codebuddy-intl',
|
|
24
|
+
minimax: 'minimax-code', // #55:MiniMax 国内订阅线 → 10R minimax-code
|
|
25
|
+
'minimax-global': 'minimax-code-global', // #55:MiniMax 国际订阅线 → 10R minimax-code-global
|
|
26
|
+
trae: 'trae-cn', // #56:CD 的 Trae 线读国内客户端(#28)→ 10R trae-cn(条目钉死国内站)
|
|
27
|
+
'trae-intl': 'trae', // 国际线(浏览器 OAuth 登录,10R trae 条目缺省国际站);连接同步走 transfer 管线
|
|
28
|
+
tokenharbor: 'tokenharbor-free', // #23:会话 cookie 只喂「额度监控卡」(freeTier,不走路由);tokenharbor 钱包卡留给 sk- 运输 key
|
|
29
|
+
loomy: 'loomy',
|
|
30
|
+
// zcode → glm:等 zcode 反代就绪后补一行(同步流程已就绪,无需改代码)
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const mapProviderId = (provider) => TENROUTER_PROVIDER_MAP[provider] || null;
|
|
34
|
+
|
|
35
|
+
const TIMEOUT_MS = 60_000;
|
|
36
|
+
|
|
37
|
+
async function trFetch(url, { key, cookie, method = 'GET', body } = {}) {
|
|
38
|
+
let res;
|
|
39
|
+
try {
|
|
40
|
+
res = await fetch(url, {
|
|
41
|
+
method,
|
|
42
|
+
headers: {
|
|
43
|
+
Accept: 'application/json',
|
|
44
|
+
...(body ? { 'Content-Type': 'application/json' } : {}),
|
|
45
|
+
...(key ? { Authorization: `Bearer ${key}` } : {}),
|
|
46
|
+
...(cookie ? { Cookie: cookie } : {}),
|
|
47
|
+
},
|
|
48
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
49
|
+
signal: AbortSignal.timeout(TIMEOUT_MS),
|
|
50
|
+
// 这里的 body 是账号明文 token(/api/oauth/transfer/import)与 apiKey(/api/providers)。
|
|
51
|
+
// 307/308 重定向会把 body 原样重放到新地址,Authorization 反而会被剥掉——所以必须拒绝。
|
|
52
|
+
redirect: 'error',
|
|
53
|
+
});
|
|
54
|
+
} catch (e) {
|
|
55
|
+
// redirect:'error' 抛的是 cause.message === 'unexpected redirect'(顶层 message 只是 "fetch failed")
|
|
56
|
+
if (e?.cause?.message === 'unexpected redirect') {
|
|
57
|
+
throw new Error(`10Router 返回了重定向,已拒绝跟随:账号凭据只发往你填写的地址,请把地址改成最终地址`);
|
|
58
|
+
}
|
|
59
|
+
throw new Error(`无法连接 10Router:${e.cause?.code || e.message}`);
|
|
60
|
+
}
|
|
61
|
+
const text = await res.text();
|
|
62
|
+
let data = null;
|
|
63
|
+
try { data = text ? JSON.parse(text) : null; } catch {}
|
|
64
|
+
return { status: res.status, data, setCookie: res.headers.get('set-cookie') || '' };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const authCookie = (setCookie) => {
|
|
68
|
+
const m = /(?:^|,\s*)auth_token=([^;,\s]+)/.exec(setCookie || '');
|
|
69
|
+
return m ? `auth_token=${m[1]}` : null;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/** 用面板密码登录换会话 Cookie;失败抛「面板密码不正确」类错误 */
|
|
73
|
+
async function login(endpoint, password) {
|
|
74
|
+
const r = await trFetch(`${endpoint}/api/auth/login`, { method: 'POST', body: { password } });
|
|
75
|
+
const cookie = authCookie(r.setCookie);
|
|
76
|
+
if (r.status !== 200 || !cookie) {
|
|
77
|
+
throw Object.assign(new Error(r.status === 401 ? '10Router 面板密码不正确' : `10Router 登录失败(HTTP ${r.status})`), { code: 'BAD_PASSWORD' });
|
|
78
|
+
}
|
|
79
|
+
return cookie;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const connName = (a) => a.name || a.email || a.uid || 'account-' + a.id;
|
|
83
|
+
|
|
84
|
+
/** 通道一:transfer/import(OAuth 形态,按目标 provider 分组推送) */
|
|
85
|
+
async function syncViaTransfer({ endpoint, cookie, groups }) {
|
|
86
|
+
const results = [];
|
|
87
|
+
for (const [target, list] of groups) {
|
|
88
|
+
const passphrase = crypto.randomBytes(18).toString('base64url'); // 仅作传输口令,不落盘
|
|
89
|
+
const blob = sealTransfer(buildExportPayload(list), passphrase);
|
|
90
|
+
const r = await trFetch(`${endpoint}/api/oauth/transfer/import`, {
|
|
91
|
+
cookie, method: 'POST', body: { provider: target, passphrase, blob },
|
|
92
|
+
});
|
|
93
|
+
if (r.status !== 200) {
|
|
94
|
+
results.push({ provider: target, count: list.length, status: 'failed', error: r.data?.error || `HTTP ${r.status}` });
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const d = r.data || {};
|
|
98
|
+
results.push({
|
|
99
|
+
provider: target, count: list.length, status: (d.failed || 0) ? 'partial' : 'ok',
|
|
100
|
+
imported: d.imported || 0, updated: d.updated || 0, skipped: d.skipped || 0, failed: d.failed || 0,
|
|
101
|
+
// 10Router issue #44:导入端会探测刚同步过去的网页会话是否仍可用,
|
|
102
|
+
// 失败清单直接回显到本端摘要(见 syncAccountsTo10r 的 sessionWarns)。
|
|
103
|
+
webSessions: d.webSessions || null,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return results;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** 通道二:POST /api/providers(apikey 形态,逐账号建连接;同名 409 记「已存在」) */
|
|
110
|
+
async function syncViaProviders({ endpoint, key, groups }) {
|
|
111
|
+
const results = [];
|
|
112
|
+
for (const [target, list] of groups) {
|
|
113
|
+
const row = { provider: target, count: list.length, status: 'ok', imported: 0, skipped: 0, failed: 0 };
|
|
114
|
+
for (const a of list) {
|
|
115
|
+
const body = buildConnPayload(a, target);
|
|
116
|
+
const r = await trFetch(`${endpoint}/api/providers`, { key, method: 'POST', body });
|
|
117
|
+
if (r.status === 201 || r.status === 200) row.imported++;
|
|
118
|
+
else if (r.status === 409) row.skipped++;
|
|
119
|
+
else { row.failed++; row.error = r.data?.error || `HTTP ${r.status}`; }
|
|
120
|
+
}
|
|
121
|
+
row.status = row.failed ? (row.imported ? 'partial' : 'failed') : 'ok';
|
|
122
|
+
results.push(row);
|
|
123
|
+
}
|
|
124
|
+
return results;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 连接体(POST /api/providers 的单账号载荷)。网页会话两种走同一形状(issue #23):
|
|
129
|
+
* - qoder 专属老形状 meta.qoderWebSession(issue #44:usage 侧不区分 authType)
|
|
130
|
+
* - 通用站点 meta.cookieSiteSession(tokenharbor 等,10R 卡片直接读 creditDaddyWebSession)
|
|
131
|
+
*/
|
|
132
|
+
export function buildConnPayload(a, target) {
|
|
133
|
+
const body = { provider: target, apiKey: a.token, name: connName(a) };
|
|
134
|
+
const qc = a.meta?.qoderWebSession?.cookie && String(a.provider).startsWith('qoder') ? a.meta.qoderWebSession : null;
|
|
135
|
+
const sc = a.meta?.cookieSiteSession?.cookie ? a.meta.cookieSiteSession : null;
|
|
136
|
+
// creditDaddySync:所有经 CreditDaddy 同步的连接都带标记,10R 连接行据此亮「CD Sync」徽章
|
|
137
|
+
//(此前只有 qoder 网页会话带 creditDaddyWebSession,CodeBuddy 等连接在 10R 上看不出同步来源)
|
|
138
|
+
const psd = { creditDaddySync: true, userId: a.uid || null };
|
|
139
|
+
if (qc) psd.creditDaddyWebSession = { cookie: qc.cookie, capturedAt: qc.capturedAt || null, userId: a.uid || null };
|
|
140
|
+
else if (sc) psd.creditDaddyWebSession = { cookie: sc.cookie, capturedAt: sc.capturedAt || null, userId: null };
|
|
141
|
+
// Trae 签到(10R traeCheckin)优先用「登录时注册的设备」:CD 浏览器登录给每个账号
|
|
142
|
+
// 造了独立指纹(meta.traeDevice.deviceId),随 psd 带过去,避免 10R 端陌生派生号
|
|
143
|
+
// 领积分吃 9074(#31 口径)。私钥只服务本机 refresh 链,不出本机。
|
|
144
|
+
if (a.provider === 'trae' && a.meta?.traeDevice?.deviceId && /^\d{8,}$/.test(String(a.meta.traeDevice.deviceId))) {
|
|
145
|
+
psd.creditDaddyTraeDevice = {
|
|
146
|
+
deviceId: String(a.meta.traeDevice.deviceId),
|
|
147
|
+
...(a.meta.traeDevice.machineId ? { machineId: String(a.meta.traeDevice.machineId) } : {}),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
body.providerSpecificData = psd;
|
|
151
|
+
return body;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* 同步账号到 10Router。
|
|
156
|
+
* @returns {{ channel: 'oauth'|'apikey', results: Array, summary: string }}
|
|
157
|
+
*/
|
|
158
|
+
export async function syncAccountsTo10r({ endpoint, key, adminPassword, accounts }) {
|
|
159
|
+
if (!endpoint) throw Object.assign(new Error('尚未配置 10Router 地址'), { code: 'NOT_CONFIGURED' });
|
|
160
|
+
if (!key && !adminPassword) throw Object.assign(new Error('尚未配置 10Router 虚拟 key'), { code: 'NOT_CONFIGURED' });
|
|
161
|
+
|
|
162
|
+
// 按目标 10R 连接类型分组;无映射的产品(zcode/mirasim/catpaw 等)记入跳过原因
|
|
163
|
+
const groups = new Map();
|
|
164
|
+
const unmapped = new Map();
|
|
165
|
+
const traeIntl = [];
|
|
166
|
+
for (const a of accounts || []) {
|
|
167
|
+
if (!a || !a.token) continue;
|
|
168
|
+
// #56:国内线(provider trae)里混进国际账号(旧 meta.isIntl 标记)不往 trae-cn 推——
|
|
169
|
+
// 10R 拿国内端点打国际 token 必然 20101。provider 'trae-intl' 有独立映射(→ trae),不走这。
|
|
170
|
+
if (a.provider === 'trae' && (a.meta?.isIntl || a.isIntl)) {
|
|
171
|
+
traeIntl.push(a);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
const target = mapProviderId(a.provider);
|
|
175
|
+
if (!target) {
|
|
176
|
+
if (a.provider) unmapped.set(a.provider, (unmapped.get(a.provider) || 0) + 1);
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
if (!groups.has(target)) groups.set(target, []);
|
|
180
|
+
groups.get(target).push(a);
|
|
181
|
+
}
|
|
182
|
+
if (!groups.size) throw new Error('没有可同步的账号(qoder / WorkBuddy / MiniMax / Loomy / Trae 系列);zcode 待反代就绪后支持');
|
|
183
|
+
|
|
184
|
+
let channel = 'apikey';
|
|
185
|
+
let cookie = null;
|
|
186
|
+
const results = [];
|
|
187
|
+
if (adminPassword) {
|
|
188
|
+
channel = 'oauth';
|
|
189
|
+
cookie = await login(endpoint, adminPassword);
|
|
190
|
+
try {
|
|
191
|
+
results.push(...await syncViaTransfer({ endpoint, cookie, groups }));
|
|
192
|
+
} finally {
|
|
193
|
+
trFetch(`${endpoint}/api/auth/logout`, { cookie, method: 'POST' }).catch(() => {});
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
if (!key) throw Object.assign(new Error('尚未配置 10Router 虚拟 key'), { code: 'NOT_CONFIGURED' });
|
|
197
|
+
results.push(...await syncViaProviders({ endpoint, key, groups }));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const sum = (k) => results.reduce((n, r) => n + (r[k] || 0), 0);
|
|
201
|
+
const failed = results.filter((r) => r.status === 'failed' || r.status === 'partial');
|
|
202
|
+
const parts = [];
|
|
203
|
+
if (sum('imported')) parts.push(`导入 ${sum('imported')}`);
|
|
204
|
+
if (sum('updated')) parts.push(`更新 ${sum('updated')}`);
|
|
205
|
+
if (sum('skipped')) parts.push(`已存在 ${sum('skipped')}`);
|
|
206
|
+
if (sum('failed')) parts.push(`失败 ${sum('failed')}`);
|
|
207
|
+
if (unmapped.size) parts.push('跳过 ' + [...unmapped].map(([p, n]) => `${p} ×${n}`).join('、'));
|
|
208
|
+
if (traeIntl.length) parts.push(`跳过 Trae 国际版 ×${traeIntl.length}(CreditDaddy 的 Trae 线仅支持国内站)`);
|
|
209
|
+
// issue #44:Qoder 网页会话决定 10Router 端「套餐内 Credits」能不能显示。
|
|
210
|
+
// OAuth 通道:10Router 导入时已逐账号探测,失效清单原样带回(deadNames);
|
|
211
|
+
// 两条通道都要点名本地就没有会话的账号(apikey 通道 webSessions 恒为
|
|
212
|
+
// null,条件自动适用;OAuth 通道里已被探测过的组不重复报)。
|
|
213
|
+
const deadNames = [];
|
|
214
|
+
for (const r of results) {
|
|
215
|
+
for (const f of r.webSessions?.failures || []) deadNames.push(f.name);
|
|
216
|
+
}
|
|
217
|
+
const sessionless = [];
|
|
218
|
+
for (const [target, list] of groups) {
|
|
219
|
+
if (!String(target).startsWith('qoder')) continue;
|
|
220
|
+
for (const a of list) {
|
|
221
|
+
if (results.find((r) => r.provider === target)?.webSessions == null && !a.meta?.qoderWebSession?.cookie) {
|
|
222
|
+
sessionless.push(connName(a));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (sessionless.length) parts.push(`未带网页会话 ${sessionless.length}(${sessionless.join('、')},在 CreditDaddy 重新浏览器登录 Qoder 后再同步可补齐逐资源包明细)`);
|
|
227
|
+
if (deadNames.length) parts.push(`网页会话已失效 ${deadNames.length}(${deadNames.join('、')},重新登录 Qoder 网页后再次同步)`);
|
|
228
|
+
const summary = (channel === 'oauth' ? '账号同步完成(OAuth 通道):' : '账号同步完成(apikey 通道,token 过期后需重新同步):')
|
|
229
|
+
+ (parts.join(',') || '无变化')
|
|
230
|
+
+ (failed.length ? `;${failed.map((r) => r.provider + ':' + (r.error || r.status)).join(';')}` : '');
|
|
231
|
+
return { channel, results, summary };
|
|
232
|
+
}
|