cursor-switch 1.0.7 → 1.0.8

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 (86) hide show
  1. package/README.md +76 -75
  2. package/SECURITY.md +22 -19
  3. package/bin/cswitch.js +31 -8
  4. package/dist/cli.d.ts +0 -4
  5. package/dist/cli.js +404 -241
  6. package/dist/core/account-store.d.ts +0 -7
  7. package/dist/core/account-store.js +22 -28
  8. package/dist/core/cdp-engine.d.ts +11 -49
  9. package/dist/core/cdp-engine.js +155 -110
  10. package/dist/core/config-store.d.ts +7 -6
  11. package/dist/core/config-store.js +33 -12
  12. package/dist/core/cursor-paths.d.ts +8 -18
  13. package/dist/core/cursor-paths.js +18 -37
  14. package/dist/core/dashboard-launcher.d.ts +0 -20
  15. package/dist/core/dashboard-launcher.js +3 -53
  16. package/dist/core/extract-client.d.ts +57 -0
  17. package/dist/core/extract-client.js +219 -0
  18. package/dist/core/extract-menu.d.ts +3 -0
  19. package/dist/core/extract-menu.js +360 -0
  20. package/dist/core/extract-service.d.ts +64 -0
  21. package/dist/core/extract-service.js +435 -0
  22. package/dist/core/fingerprint.d.ts +0 -4
  23. package/dist/core/fingerprint.js +0 -6
  24. package/dist/core/oauth-receiver.d.ts +1 -11
  25. package/dist/core/oauth-receiver.js +509 -527
  26. package/dist/core/official-api.d.ts +0 -17
  27. package/dist/core/official-api.js +4 -23
  28. package/dist/core/outlook-launcher.d.ts +0 -31
  29. package/dist/core/outlook-launcher.js +194 -248
  30. package/dist/core/process-manager.d.ts +0 -14
  31. package/dist/core/process-manager.js +7 -22
  32. package/dist/core/pure-login-service.d.ts +54 -38
  33. package/dist/core/pure-login-service.js +483 -395
  34. package/dist/core/refund-client.d.ts +0 -22
  35. package/dist/core/refund-client.js +7 -27
  36. package/dist/core/refund-service.d.ts +0 -16
  37. package/dist/core/refund-service.js +8 -34
  38. package/dist/core/safe-storage.d.ts +27 -0
  39. package/dist/core/safe-storage.js +284 -0
  40. package/dist/core/sqlite-bridge.d.ts +10 -11
  41. package/dist/core/sqlite-bridge.js +112 -47
  42. package/dist/core/storage-bridge.d.ts +14 -5
  43. package/dist/core/storage-bridge.js +84 -24
  44. package/dist/core/switch-orchestrator.d.ts +96 -0
  45. package/dist/core/switch-orchestrator.js +341 -0
  46. package/dist/core/token-exchange.d.ts +81 -0
  47. package/dist/core/token-exchange.js +275 -0
  48. package/dist/core/token-parser.d.ts +56 -20
  49. package/dist/core/token-parser.js +354 -43
  50. package/dist/core/update-checker.d.ts +1 -29
  51. package/dist/core/update-checker.js +28 -43
  52. package/dist/index.d.ts +1 -3
  53. package/dist/index.js +1 -3
  54. package/dist/menu.d.ts +0 -7
  55. package/dist/menu.js +445 -548
  56. package/dist/types.d.ts +12 -4
  57. package/dist/types.js +0 -4
  58. package/dist/utils/account-text-importer.d.ts +9 -0
  59. package/dist/utils/account-text-importer.js +96 -0
  60. package/dist/utils/browser-utils.d.ts +0 -24
  61. package/dist/utils/browser-utils.js +0 -57
  62. package/dist/utils/clipboard.d.ts +0 -4
  63. package/dist/utils/clipboard.js +0 -5
  64. package/dist/utils/credential-bundle-ui.d.ts +36 -0
  65. package/dist/utils/credential-bundle-ui.js +246 -0
  66. package/dist/utils/live-menu.d.ts +37 -9
  67. package/dist/utils/live-menu.js +510 -81
  68. package/dist/utils/plan-formatter.d.ts +0 -26
  69. package/dist/utils/plan-formatter.js +10 -44
  70. package/dist/utils/prompt-utils.d.ts +0 -18
  71. package/dist/utils/prompt-utils.js +0 -23
  72. package/dist/utils/proxy-bootstrap.d.ts +12 -0
  73. package/dist/utils/proxy-bootstrap.js +141 -0
  74. package/dist/utils/security.d.ts +2 -4
  75. package/dist/utils/security.js +36 -4
  76. package/dist/utils/table-renderer.d.ts +0 -4
  77. package/dist/utils/table-renderer.js +24 -8
  78. package/dist/utils/time-formatter.d.ts +0 -4
  79. package/dist/utils/time-formatter.js +0 -8
  80. package/dist/utils/token-preflight-ui.d.ts +28 -0
  81. package/dist/utils/token-preflight-ui.js +222 -0
  82. package/dist/utils/window-focus.d.ts +3 -0
  83. package/dist/utils/window-focus.js +106 -0
  84. package/package.json +12 -5
  85. package/dist/core/welcome-offer-service.d.ts +0 -52
  86. package/dist/core/welcome-offer-service.js +0 -369
@@ -0,0 +1,435 @@
1
+ import chalk from 'chalk';
2
+ import boxen from 'boxen';
3
+ import path from 'path';
4
+ import { ExtractClient, cleanCursorToken, } from './extract-client.js';
5
+ import { AccountStore } from './account-store.js';
6
+ import { ConfigStore } from './config-store.js';
7
+ import { TokenParser } from './token-parser.js';
8
+ import { copyToClipboard } from '../utils/clipboard.js';
9
+ import { openBrowserUrl } from '../utils/browser-utils.js';
10
+ import { maskToken, writeSecureFileSync } from '../utils/security.js';
11
+ import { safeInput, safePressAnyKey } from '../utils/prompt-utils.js';
12
+ const TIER_PRICE_LABELS = {
13
+ pro: 'Pro 个人版 ($20/月)',
14
+ pro_plus: 'Pro+ 强化版 ($60/月)',
15
+ ultra: 'Ultra 旗舰版 ($200/月)',
16
+ team: 'Teams 团队席位 ($40/席/月)',
17
+ };
18
+ export class ExtractService {
19
+ client;
20
+ accountStore;
21
+ configStore;
22
+ customApiBase;
23
+ constructor(customApiBase, deps) {
24
+ this.accountStore = deps?.accountStore || new AccountStore();
25
+ this.configStore = deps?.configStore || new ConfigStore();
26
+ this.customApiBase =
27
+ customApiBase || process.env.CSWITCH_EXTRACT_API_BASE || process.env.CSWITCH_API_BASE;
28
+ this.client = new ExtractClient(this.customApiBase);
29
+ }
30
+ persistCheckoutLinkToStore(params) {
31
+ if (params.tier !== 'pro' && params.tier !== 'pro_plus' && params.tier !== 'ultra') {
32
+ return;
33
+ }
34
+ const cleanTok = params.rawToken ? cleanCursorToken(params.rawToken) : '';
35
+ const all = this.accountStore.loadAll();
36
+ const target = (params.account?.email ? this.accountStore.getByEmail(params.account.email) : undefined) ||
37
+ (params.accountEmail ? this.accountStore.getByEmail(params.accountEmail) : undefined) ||
38
+ (cleanTok
39
+ ? all.find((a) => cleanCursorToken(a.workos_cursor_session_token || '') === cleanTok ||
40
+ cleanCursorToken(a.token || '') === cleanTok)
41
+ : undefined);
42
+ if (!target) {
43
+ return;
44
+ }
45
+ this.accountStore.addOrUpdate({
46
+ ...target,
47
+ checkout_links: {
48
+ ...(target.checkout_links || {}),
49
+ [params.tier]: params.checkoutUrl,
50
+ updated_at: new Date().toISOString(),
51
+ },
52
+ });
53
+ }
54
+ getClient() {
55
+ return this.client;
56
+ }
57
+ getConfigStore() {
58
+ return this.configStore;
59
+ }
60
+ static isCardExhausted(check) {
61
+ return (check.max_uses !== undefined &&
62
+ check.max_uses !== -1 &&
63
+ (check.remaining ?? 0) <= 0);
64
+ }
65
+ static summarizeCardError(detail) {
66
+ const raw = (detail || '').trim();
67
+ if (!raw) {
68
+ return {
69
+ shortTag: '卡密无效',
70
+ humanHint: '卡密无效或网络异常,请核对后重试',
71
+ };
72
+ }
73
+ if (raw.includes('已并入')) {
74
+ return {
75
+ shortTag: '已绑定网站账号',
76
+ humanHint: '该卡密已绑定到 getdoubao.com 网站账号,请去官网「个人中心 → 服务权益」解绑还原,或换一张新卡密',
77
+ };
78
+ }
79
+ if (raw.includes('用完') || raw.includes('用尽') || raw.includes('耗尽')) {
80
+ return {
81
+ shortTag: '次数已用完',
82
+ humanHint: '卡密次数已用完,请更换有余额的卡密',
83
+ };
84
+ }
85
+ if (raw.includes('有效期') || raw.includes('过期')) {
86
+ return {
87
+ shortTag: '已过期',
88
+ humanHint: '卡密已过期,请更换有效卡密',
89
+ };
90
+ }
91
+ if (raw.includes('停用')) {
92
+ return {
93
+ shortTag: '已停用',
94
+ humanHint: '卡密已停用,请更换有效卡密',
95
+ };
96
+ }
97
+ if (raw.includes('不可用于')) {
98
+ return {
99
+ shortTag: '卡密类型不对',
100
+ humanHint: '这不是「提取老套餐支付链接」专用卡密,请检查是否填成了退款/代登卡密',
101
+ };
102
+ }
103
+ if (raw.includes('不存在')) {
104
+ return {
105
+ shortTag: '卡密不存在',
106
+ humanHint: '卡密不存在,请检查是否输错或有多余空格',
107
+ };
108
+ }
109
+ return {
110
+ shortTag: '暂不可用',
111
+ humanHint: raw,
112
+ };
113
+ }
114
+ async ensureCardAuth(providedCardCode, promptIfMissing = true, quiet = false) {
115
+ let code = (providedCardCode || this.configStore.getExtractCardCode() || '').trim();
116
+ if (!code && promptIfMissing && process.stdin.isTTY) {
117
+ console.clear();
118
+ console.log(boxen([
119
+ `${chalk.bold.cyan('CURSOR-SWITCH')} ${chalk.dim('●')} ${chalk.bold.white('Cursor 提取老套餐支付链接')}`,
120
+ chalk.dim('────────────────────────────────────────────────────────'),
121
+ '请输入提链卡密(与 getdoubao.com 通用)。',
122
+ chalk.dim('• 扣费规则 : 出链成功才扣 1 次,失败不扣'),
123
+ chalk.dim('• 取消返回 : 输入 0、q 或直接按回车'),
124
+ ].join('\n'), {
125
+ padding: { top: 0, bottom: 0, left: 1, right: 1 },
126
+ borderColor: 'cyan',
127
+ borderStyle: 'round',
128
+ }));
129
+ const answer = await safeInput({ message: '请输入卡密' });
130
+ if (!answer || answer.trim() === '0' || answer.trim().toLowerCase() === 'q') {
131
+ return null;
132
+ }
133
+ code = answer.trim();
134
+ }
135
+ if (!code || code === '0' || code.toLowerCase() === 'q') {
136
+ return null;
137
+ }
138
+ if (!quiet) {
139
+ process.stdout.write(chalk.cyan('\n正在验证卡密... '));
140
+ }
141
+ const check = await this.client.checkKey(code, this.customApiBase || this.configStore.getSeatApiBase());
142
+ const exhausted = ExtractService.isCardExhausted(check);
143
+ if (!check.valid || exhausted) {
144
+ const { humanHint } = ExtractService.summarizeCardError(exhausted ? '该卡密次数已用完' : check.detail);
145
+ if (!quiet) {
146
+ console.log(chalk.red('✖ 不可用\n'));
147
+ console.log(boxen([
148
+ chalk.bold.red('✖ 卡密验证未通过'),
149
+ chalk.dim('────────────────────────────────────────────────'),
150
+ ` 原因 : ${chalk.yellow(humanHint)}`,
151
+ ].join('\n'), {
152
+ padding: { top: 0, bottom: 0, left: 1, right: 1 },
153
+ borderColor: 'red',
154
+ borderStyle: 'round',
155
+ }));
156
+ if (promptIfMissing && process.stdin.isTTY) {
157
+ await safePressAnyKey();
158
+ }
159
+ }
160
+ return null;
161
+ }
162
+ if (!quiet) {
163
+ console.log(chalk.green('✔ 通过'));
164
+ }
165
+ this.configStore.setExtractCardCode(code);
166
+ return { cardCode: code, check };
167
+ }
168
+ async extractForAccount(params) {
169
+ if (params.portal) {
170
+ const res = {
171
+ success: false,
172
+ error: '已下线客户端直连账单门户模式,请使用提链卡密提取 Pro / Pro+ / Ultra / Teams 官方支付链接。',
173
+ };
174
+ if (params.json)
175
+ console.log(JSON.stringify(res, null, 2));
176
+ else if (!params.silent)
177
+ console.log(chalk.red(`\n✖ ${res.error}\n`));
178
+ return res;
179
+ }
180
+ if (params.mock) {
181
+ const res = {
182
+ success: false,
183
+ error: '已关闭离线仿真模式,请使用有效提链卡密发起服务端提取。',
184
+ };
185
+ if (params.json)
186
+ console.log(JSON.stringify(res, null, 2));
187
+ else if (!params.silent)
188
+ console.log(chalk.red(`\n✖ ${res.error}\n`));
189
+ return res;
190
+ }
191
+ const tier = params.tier || 'pro';
192
+ const rawToken = TokenParser.extractWebSessionToken(params.token || params.account?.workos_cursor_session_token || params.account?.token || '');
193
+ if (!rawToken) {
194
+ if (!params.silent && !params.json) {
195
+ console.log(boxen([
196
+ chalk.bold.red('✖ 缺少 Cursor 会话凭据'),
197
+ chalk.dim('────────────────────────────────────────────────'),
198
+ '未检测到有效的 Session Token,无法生成老套餐支付链接。',
199
+ '请指定目标账号,或通过 -t / --token 显式传入凭据。',
200
+ ].join('\n'), {
201
+ padding: { top: 0, bottom: 0, left: 1, right: 1 },
202
+ borderColor: 'red',
203
+ borderStyle: 'round',
204
+ }));
205
+ if (!params.skipPause) {
206
+ await safePressAnyKey();
207
+ }
208
+ }
209
+ const errRes = { success: false, error: '缺少有效的 Session Token' };
210
+ if (params.json)
211
+ console.log(JSON.stringify(errRes, null, 2));
212
+ return errRes;
213
+ }
214
+ let cardCode = (params.cardCode || this.configStore.getExtractCardCode() || '').trim();
215
+ if (!cardCode) {
216
+ const canPrompt = !params.silent && !params.json && process.stdin.isTTY;
217
+ if (canPrompt) {
218
+ const authRes = await this.ensureCardAuth(undefined, true, false);
219
+ if (!authRes) {
220
+ return { success: false, tier, error: '未绑定有效提链卡密,已取消提取' };
221
+ }
222
+ cardCode = authRes.cardCode;
223
+ }
224
+ else {
225
+ const noCardRes = {
226
+ success: false,
227
+ tier,
228
+ error: '未绑定提链卡密:请先执行 `cswitch extract --set-card <卡密>` 或传入 `-k <卡密>`。',
229
+ };
230
+ if (params.json)
231
+ console.log(JSON.stringify(noCardRes, null, 2));
232
+ else if (!params.silent)
233
+ console.log(chalk.red(`\n✖ ${noCardRes.error}\n`));
234
+ return noCardRes;
235
+ }
236
+ }
237
+ const apiBase = this.customApiBase || this.configStore.getSeatApiBase();
238
+ const email = params.account?.email || '指定凭据账号';
239
+ if (!params.json && !params.silent) {
240
+ console.log(chalk.bold.cyan(`\n⚡ 正在为 [${chalk.white(email)}] 提取 ${TIER_PRICE_LABELS[tier]} 支付链接...`));
241
+ console.log(chalk.dim(`• Token 特征 : ${maskToken(cleanCursorToken(rawToken))}`));
242
+ console.log(chalk.dim(`• 卡密凭据 : ${maskToken(cardCode)} (出链成功才扣次)`));
243
+ if (params.yearly) {
244
+ console.log(chalk.yellow('⚠ 提链网关当前仅支持月付老套餐直链,已按月付档位提取'));
245
+ }
246
+ }
247
+ const startT = Date.now();
248
+ const result = await this.client.extractCheckoutLink({
249
+ token: rawToken,
250
+ tier,
251
+ cardCode,
252
+ apiBase,
253
+ });
254
+ if (result.success && result.checkoutUrl) {
255
+ this.persistCheckoutLinkToStore({
256
+ account: params.account,
257
+ accountEmail: result.accountEmail,
258
+ rawToken,
259
+ tier,
260
+ checkoutUrl: result.checkoutUrl,
261
+ });
262
+ }
263
+ if (params.json) {
264
+ console.log(JSON.stringify(result, null, 2));
265
+ return result;
266
+ }
267
+ if (params.silent) {
268
+ return result;
269
+ }
270
+ if (result.success && result.checkoutUrl) {
271
+ const latency = result.latencyMs || Date.now() - startT;
272
+ const cardLines = [
273
+ `${chalk.bold.green('✔ 官方支付直链已生成成功!')} ${chalk.dim(`(${latency}ms)`)}`,
274
+ chalk.dim('────────────────────────────────────────────────────────────────────'),
275
+ `• 目标账号 : ${chalk.white(result.accountEmail || email)}`,
276
+ `• 订阅档位 : ${chalk.bold.yellow(result.tierName || TIER_PRICE_LABELS[tier])}`,
277
+ ...(result.dedup ? [`• 缓存复用 : ${chalk.cyan('3分钟内同账号快捷复用 · 本次未重复扣次')}`] : []),
278
+ ...(result.remaining !== undefined
279
+ ? [`• 提链卡余量 : ${chalk.bold.yellow(result.remaining === -1 ? '无限次' : `${result.remaining} 次`)}`]
280
+ : []),
281
+ `• 直链状态 : ${chalk.green('● 立即有效 (支持支付宝/信用卡)')}`,
282
+ chalk.dim('────────────────────────────────────────────────────────────────────'),
283
+ chalk.bold.white('🔗 官方支付链接 (直接在浏览器打开付款):'),
284
+ chalk.underline.cyan(result.checkoutUrl),
285
+ ];
286
+ console.log(boxen(cardLines.join('\n'), {
287
+ padding: { top: 0, bottom: 0, left: 1, right: 1 },
288
+ borderColor: 'green',
289
+ borderStyle: 'round',
290
+ }));
291
+ if (params.copy) {
292
+ const copied = await copyToClipboard(result.checkoutUrl);
293
+ if (copied) {
294
+ console.log(chalk.green('📋 已自动将官方支付链接复制到系统剪贴板!'));
295
+ }
296
+ }
297
+ if (params.open) {
298
+ console.log(chalk.cyan('🚀 正在调起默认浏览器打开支付页面...'));
299
+ await openBrowserUrl(result.checkoutUrl);
300
+ }
301
+ }
302
+ else {
303
+ const errLines = [
304
+ chalk.bold.red('✖ 支付链接生成暂未成功 (未扣次数)'),
305
+ chalk.dim('────────────────────────────────────────────────'),
306
+ `• 错误原因 : ${chalk.yellow(result.error || '未知异常')}`,
307
+ ];
308
+ if (result.suggestion) {
309
+ errLines.push(`• 排查建议 : ${chalk.white(result.suggestion)}`);
310
+ }
311
+ console.log(boxen(errLines.join('\n'), {
312
+ padding: { top: 0, bottom: 0, left: 1, right: 1 },
313
+ borderColor: 'red',
314
+ borderStyle: 'round',
315
+ }));
316
+ }
317
+ return result;
318
+ }
319
+ async batchExtract(params) {
320
+ if (params.portal) {
321
+ console.log(chalk.red('\n✖ 已下线客户端直连账单门户模式,请使用提链卡密批量提取老套餐支付链接。\n'));
322
+ return { total: 0, successDirect: 0, successPortal: 0, failed: 0, items: [] };
323
+ }
324
+ const auth = await this.ensureCardAuth(params.cardCode, process.stdin.isTTY, false);
325
+ if (!auth) {
326
+ console.log(chalk.yellow('\n已取消或未提供有效提链卡密,未执行批量提取。\n'));
327
+ return { total: 0, successDirect: 0, successPortal: 0, failed: 0, items: [] };
328
+ }
329
+ const apiBase = this.customApiBase || this.configStore.getSeatApiBase();
330
+ const allAccounts = this.accountStore.loadAll();
331
+ const candidates = allAccounts.filter((a) => (a.token || a.workos_cursor_session_token) && a.subscription_type !== 'token_expired');
332
+ const tier = params.tier || 'pro';
333
+ console.log(chalk.bold.magenta(`\n🚀 开始批量提取 ${TIER_PRICE_LABELS[tier]} 支付链接 (候选账号: ${candidates.length} · 卡密余量: ${auth.check.remaining === -1 ? '无限' : `${auth.check.remaining} 次`})...\n`));
334
+ const result = {
335
+ total: candidates.length,
336
+ successDirect: 0,
337
+ successPortal: 0,
338
+ failed: 0,
339
+ items: [],
340
+ };
341
+ let idx = 0;
342
+ for (const acc of candidates) {
343
+ idx++;
344
+ process.stdout.write(chalk.dim(`[${idx}/${candidates.length}] 正在提取 ${acc.email}... `));
345
+ const res = await this.client.extractCheckoutLink({
346
+ token: acc.workos_cursor_session_token || acc.token || '',
347
+ tier,
348
+ cardCode: auth.cardCode,
349
+ apiBase,
350
+ });
351
+ if (res.success && res.checkoutUrl) {
352
+ this.persistCheckoutLinkToStore({
353
+ account: acc,
354
+ accountEmail: res.accountEmail,
355
+ rawToken: acc.workos_cursor_session_token || acc.token,
356
+ tier,
357
+ checkoutUrl: res.checkoutUrl,
358
+ });
359
+ result.successDirect++;
360
+ console.log(chalk.green(`✔ 出链成功 (余 ${res.remaining === -1 ? '无限' : res.remaining ?? '--'} 次)`));
361
+ result.items.push({
362
+ email: acc.email,
363
+ success: true,
364
+ mode: res.mode,
365
+ tier: res.tier || tier,
366
+ url: res.checkoutUrl,
367
+ customerId: res.customerId,
368
+ });
369
+ if (res.remaining === 0) {
370
+ console.log(chalk.yellow('\n⚠ 当前提链卡密余量已归零,提前结束剩余扫描。'));
371
+ break;
372
+ }
373
+ }
374
+ else {
375
+ result.failed++;
376
+ console.log(chalk.red(`✖ 失败 (${res.error || '未知'})`));
377
+ result.items.push({
378
+ email: acc.email,
379
+ success: false,
380
+ error: res.error,
381
+ });
382
+ if (res.error && /用尽|耗尽|停用|过期/.test(res.error)) {
383
+ console.log(chalk.yellow('\n⚠ 卡密已不可用,提前停止批量提取。'));
384
+ break;
385
+ }
386
+ }
387
+ }
388
+ console.log(boxen([
389
+ chalk.bold.cyan('📊 批量提取老套餐支付链接统计'),
390
+ chalk.dim('──────────────────────────────────────────────'),
391
+ `• 候选扫描总量 : ${chalk.white(result.total)} 个`,
392
+ `• 成功出链数量 : ${chalk.bold.green(result.successDirect)} 个`,
393
+ `• 提取失败数量 : ${chalk.red(result.failed)} 个 (失败均未扣次)`,
394
+ ].join('\n'), {
395
+ padding: { top: 0, bottom: 0, left: 1, right: 1 },
396
+ borderColor: 'cyan',
397
+ borderStyle: 'round',
398
+ }));
399
+ if (params.exportFile) {
400
+ const outPath = path.resolve(params.exportFile);
401
+ writeSecureFileSync(outPath, JSON.stringify(result, null, 2));
402
+ console.log(chalk.green(`📁 批量提链结果已保存至: ${outPath}`));
403
+ }
404
+ return result;
405
+ }
406
+ async verifyLink(url) {
407
+ console.log(chalk.cyan(`\n🔍 正在向 Stripe 网关校验直链有效性: ${url.slice(0, 60)}...`));
408
+ const res = await this.client.verifyCheckoutLink(url);
409
+ if (res.valid) {
410
+ console.log(boxen([
411
+ chalk.bold.green('✔ Stripe 会话当前处于有效活跃状态!'),
412
+ chalk.dim('────────────────────────────────────────────────'),
413
+ `• 状态 : ${chalk.green('active')}`,
414
+ `• 地址 : ${chalk.white(res.sessionUrl || url)}`,
415
+ ].join('\n'), {
416
+ padding: { top: 0, bottom: 0, left: 1, right: 1 },
417
+ borderColor: 'green',
418
+ borderStyle: 'round',
419
+ }));
420
+ }
421
+ else {
422
+ console.log(boxen([
423
+ chalk.bold.yellow('✖ Stripe 结账会话已失效或已超时'),
424
+ chalk.dim('────────────────────────────────────────────────'),
425
+ `• 状态 : ${chalk.red(res.status || 'invalid')}`,
426
+ `• 原因 : ${chalk.yellow(res.error || (res.isExpired ? '会话已超时/已完成' : '无法连接'))}`,
427
+ ].join('\n'), {
428
+ padding: { top: 0, bottom: 0, left: 1, right: 1 },
429
+ borderColor: 'yellow',
430
+ borderStyle: 'round',
431
+ }));
432
+ }
433
+ return res;
434
+ }
435
+ }
@@ -1,7 +1,3 @@
1
- /**
2
- * Cursor 专属防封机器码 (Virtual Machine ID) 生成与管理引擎
3
- * 对齐官方指纹规范:UUID v4 + SHA-256 + SHA-512 体系
4
- */
5
1
  import type { MachineIds } from '../types.js';
6
2
  export declare function generateMachineIds(): MachineIds;
7
3
  export declare function formatMachineIdSummary(ids?: MachineIds): string;
@@ -1,7 +1,3 @@
1
- /**
2
- * Cursor 专属防封机器码 (Virtual Machine ID) 生成与管理引擎
3
- * 对齐官方指纹规范:UUID v4 + SHA-256 + SHA-512 体系
4
- */
5
1
  import crypto from 'node:crypto';
6
2
  export function generateMachineIds() {
7
3
  const devDeviceId = crypto.randomUUID();
@@ -9,10 +5,8 @@ export function generateMachineIds() {
9
5
  const machineGuid = crypto.randomUUID();
10
6
  const sqmId = `{${crypto.randomUUID().toUpperCase()}}`;
11
7
  const sqmClientId = `{${crypto.randomUUID().toUpperCase()}}`;
12
- // SHA-256 全局机器码 (64 字符十六进制)
13
8
  const randomBytes32 = crypto.randomBytes(32);
14
9
  const machineId = crypto.createHash('sha256').update(randomBytes32).digest('hex');
15
- // SHA-512 网卡硬件码 (128 字符十六进制)
16
10
  const randomBytes64 = crypto.randomBytes(64);
17
11
  const macMachineId = crypto.createHash('sha512').update(randomBytes64).digest('hex');
18
12
  return {
@@ -1,8 +1,3 @@
1
- /**
2
- * 本地认证回调监听服务 (Local OAuth Receiver)
3
- * 启动临时 HTTP 监听,支持跨浏览器 (Chrome/Edge/Safari/Firefox/Arc) 登录与凭据捕获
4
- * 具备端口冲突自愈、CORS 支持、一键控制台抓取脚本、书签栏抓取与手动辅助提交
5
- */
6
1
  export interface OAuthLoginResult {
7
2
  success: boolean;
8
3
  token?: string;
@@ -19,13 +14,8 @@ export interface OfficialOAuthResult {
19
14
  email?: string;
20
15
  message?: string;
21
16
  }
17
+ export declare function escapeHtml(input: string): string;
22
18
  export declare class OAuthReceiver {
23
- /**
24
- * 调起无痕新浏览器实例,通过官方原生 PKCE 端点执行全自动 OAuth 登录与秒级回传
25
- */
26
19
  static startOfficialOAuthFlow(): Promise<OfficialOAuthResult>;
27
- /**
28
- * 启动本地监听服务并调起浏览器协助登录
29
- */
30
20
  static startBrowserLoginFlow(defaultPort?: number): Promise<OAuthLoginResult>;
31
21
  }