cursor-switch 1.0.5 → 1.0.7
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/dist/cli.js +16 -0
- package/dist/core/dashboard-launcher.d.ts +4 -4
- package/dist/core/dashboard-launcher.js +9 -9
- package/dist/core/outlook-launcher.d.ts +4 -0
- package/dist/core/outlook-launcher.js +162 -134
- package/dist/core/pure-login-service.d.ts +23 -2
- package/dist/core/pure-login-service.js +197 -73
- package/dist/core/welcome-offer-service.d.ts +52 -0
- package/dist/core/welcome-offer-service.js +369 -0
- package/dist/menu.js +14 -4
- package/package.json +1 -1
|
@@ -165,22 +165,50 @@ export class PureLoginService {
|
|
|
165
165
|
detail: data.message || '检测到手机短信二次验证',
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
|
+
const canRetry = Boolean(data.canRetry || data.can_retry || res.status === 400);
|
|
168
169
|
return {
|
|
169
170
|
ok: false,
|
|
171
|
+
canRetry,
|
|
170
172
|
detail: data.error || data.detail || data.message || '验证码提交未通过或已超时',
|
|
171
173
|
};
|
|
172
174
|
}
|
|
173
175
|
catch (err) {
|
|
174
176
|
return {
|
|
175
177
|
ok: false,
|
|
178
|
+
canRetry: true,
|
|
176
179
|
detail: `网络连接异常: ${err.message}`,
|
|
177
180
|
};
|
|
178
181
|
}
|
|
179
182
|
}
|
|
180
183
|
/**
|
|
181
|
-
*
|
|
184
|
+
* 向云端申请重新发送验证码 (同会话重发,不扣减卡密额度)
|
|
182
185
|
*/
|
|
183
|
-
async
|
|
186
|
+
async resendCode(taskId, cardCode, email) {
|
|
187
|
+
const apiBase = this.configStore.getSeatApiBase();
|
|
188
|
+
try {
|
|
189
|
+
const res = await fetch(`${apiBase}/api/v1/token-service/resend-code`, {
|
|
190
|
+
method: 'POST',
|
|
191
|
+
headers: { 'Content-Type': 'application/json' },
|
|
192
|
+
body: JSON.stringify({
|
|
193
|
+
task_id: taskId,
|
|
194
|
+
card_code: cardCode.trim(),
|
|
195
|
+
email: email.trim(),
|
|
196
|
+
}),
|
|
197
|
+
});
|
|
198
|
+
const data = await res.json().catch(() => ({}));
|
|
199
|
+
if (res.ok && data.success) {
|
|
200
|
+
return { ok: true, message: data.message || '已重新向 Cursor 鉴权中心请求发送最新验证码!' };
|
|
201
|
+
}
|
|
202
|
+
return { ok: false, message: data.detail || data.error || '重新请求发信失败,请稍后重试' };
|
|
203
|
+
}
|
|
204
|
+
catch (err) {
|
|
205
|
+
return { ok: false, message: `网络连接异常: ${err.message}` };
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* 结构化查询云端邮箱验证码并精准解析是否可重试
|
|
210
|
+
*/
|
|
211
|
+
async fetchMailCodeResult(email, emailPassword, cursorPassword) {
|
|
184
212
|
const apiBase = this.configStore.getSeatApiBase();
|
|
185
213
|
try {
|
|
186
214
|
const res = await fetch(`${apiBase}/api/v1/mail/code`, {
|
|
@@ -192,28 +220,67 @@ export class PureLoginService {
|
|
|
192
220
|
cursorPassword: cursorPassword?.trim() || '',
|
|
193
221
|
}),
|
|
194
222
|
});
|
|
195
|
-
const data = await res.json();
|
|
223
|
+
const data = await res.json().catch(() => ({}));
|
|
196
224
|
if (res.ok) {
|
|
225
|
+
let code = '';
|
|
197
226
|
if (data.code && /^\d{6}$/.test(data.code)) {
|
|
198
|
-
|
|
227
|
+
code = data.code;
|
|
199
228
|
}
|
|
200
|
-
if (Array.isArray(data.mails)) {
|
|
229
|
+
else if (Array.isArray(data.mails)) {
|
|
201
230
|
for (const m of data.mails) {
|
|
202
231
|
const text = `${m.subject || ''} ${m.body || m.content || ''}`;
|
|
203
232
|
const match = text.match(/\b\d{6}\b/);
|
|
204
|
-
if (match)
|
|
205
|
-
|
|
233
|
+
if (match) {
|
|
234
|
+
code = match[0];
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
206
237
|
}
|
|
207
238
|
}
|
|
239
|
+
if (code) {
|
|
240
|
+
return { ok: true, code, retryable: false, message: '取码成功' };
|
|
241
|
+
}
|
|
242
|
+
// data.retryable 由后端严格判定:
|
|
243
|
+
// 若密码错误/令牌未匹配/账号不存在,后端返回 retryable: false
|
|
244
|
+
// 只有收件箱暂无新邮件时,后端返回 retryable: true
|
|
245
|
+
const retryable = Boolean(data.retryable !== false && (data.ok === true || data.ok === undefined));
|
|
246
|
+
return {
|
|
247
|
+
ok: Boolean(data.ok),
|
|
248
|
+
code: '',
|
|
249
|
+
retryable,
|
|
250
|
+
message: data.message || (retryable ? '收件箱暂无新邮件' : '邮箱不存在或密码不正确'),
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
// HTTP 429 属于限流(稍后可重试),而 400/403/404/401 属于不可重试的致命错误
|
|
255
|
+
const retryable = res.status === 429;
|
|
256
|
+
return {
|
|
257
|
+
ok: false,
|
|
258
|
+
code: '',
|
|
259
|
+
retryable,
|
|
260
|
+
message: data.detail || data.message || `云端服务返回异常 (HTTP ${res.status})`,
|
|
261
|
+
};
|
|
208
262
|
}
|
|
209
263
|
}
|
|
210
|
-
catch {
|
|
211
|
-
|
|
264
|
+
catch (err) {
|
|
265
|
+
return {
|
|
266
|
+
ok: false,
|
|
267
|
+
code: '',
|
|
268
|
+
retryable: true,
|
|
269
|
+
message: `网络连接异常: ${err.message}`,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* 自动从用户邮箱中提取最新 6 位数字验证码 (保留兼容性)
|
|
275
|
+
*/
|
|
276
|
+
async autoFetchMailCode(email, emailPassword, cursorPassword) {
|
|
277
|
+
const res = await this.fetchMailCodeResult(email, emailPassword, cursorPassword);
|
|
278
|
+
return res.code || null;
|
|
212
279
|
}
|
|
213
280
|
/**
|
|
214
281
|
* 交互式运行纯净代登全流程 (终端交互式 TUI)
|
|
215
282
|
*/
|
|
216
|
-
async runInteractiveFlow(store, storage, sqlite, executablePath) {
|
|
283
|
+
async runInteractiveFlow(store, storage, sqlite, executablePath, options = {}) {
|
|
217
284
|
console.log(chalk.bold.cyan('\n☁ 正在连接海外纯净代登云服务...\n'));
|
|
218
285
|
console.log(chalk.grey('说明: 100% 云端集群托管执行,本地无需安装代理,全自动过人机盾/收信取码提取 Token。\n'));
|
|
219
286
|
// 1. 获取并核验代登卡密 (自动读取记忆,支持一键复用或更换)
|
|
@@ -239,7 +306,7 @@ export class PureLoginService {
|
|
|
239
306
|
message: '请输入【纯净代登卡密】(按 Esc 或输入空返回):',
|
|
240
307
|
});
|
|
241
308
|
if (!inputKey)
|
|
242
|
-
return;
|
|
309
|
+
return null;
|
|
243
310
|
const check = await this.checkKey(inputKey);
|
|
244
311
|
if (check.valid) {
|
|
245
312
|
activeKey = inputKey.trim();
|
|
@@ -251,34 +318,32 @@ export class PureLoginService {
|
|
|
251
318
|
console.log(chalk.red(`\n✖ 卡密核验失败: ${check.detail || '无效卡密'}\n`));
|
|
252
319
|
const retry = await safeConfirm({ message: '是否重新输入卡密?', default: true });
|
|
253
320
|
if (!retry)
|
|
254
|
-
return;
|
|
321
|
+
return null;
|
|
255
322
|
}
|
|
256
323
|
}
|
|
257
324
|
}
|
|
258
|
-
// 2. 录入待登账号信息 (
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
chalk.grey('
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
});
|
|
325
|
+
// 2. 录入待登账号信息 (支持直接输入邮箱,或粘贴带分隔符的账号)
|
|
326
|
+
let rawInput = options.prefilledInput?.trim();
|
|
327
|
+
if (!rawInput) {
|
|
328
|
+
console.log(chalk.grey('提示: 请输入待登 Cursor 邮箱 (支持直接粘贴 user@outlook.com 或 user@outlook.com----xxx 格式):'));
|
|
329
|
+
rawInput = await safeInput({
|
|
330
|
+
message: '请输入 Cursor 账号信息:',
|
|
331
|
+
});
|
|
332
|
+
}
|
|
267
333
|
if (!rawInput)
|
|
268
|
-
return;
|
|
334
|
+
return null;
|
|
269
335
|
const parsed = this.parseAccountString(rawInput);
|
|
270
336
|
if (!parsed.email || !parsed.email.includes('@')) {
|
|
271
337
|
console.log(chalk.red('\n未识别到有效的邮箱地址,操作已取消。\n'));
|
|
272
338
|
await safePressAnyKey();
|
|
273
|
-
return;
|
|
339
|
+
return null;
|
|
274
340
|
}
|
|
275
|
-
const isAutoMail = Boolean(parsed.emailPassword);
|
|
276
341
|
console.log(boxen([
|
|
277
342
|
chalk.bold.white('📋 账号待登要素确认:'),
|
|
278
343
|
chalk.dim('────────────────────────────────────────────────'),
|
|
279
|
-
` 目标邮箱 : ${chalk.yellow(parsed.email)}`,
|
|
280
|
-
`
|
|
281
|
-
`
|
|
344
|
+
` 目标邮箱 : ${chalk.bold.yellow(parsed.email)}`,
|
|
345
|
+
` 代登模式 : ${chalk.cyan('⚡ 纯净海外住宅 IP 专线代登')}`,
|
|
346
|
+
` 取码方式 : ${chalk.green('💬 查收邮件并在终端输入 6 位验证码')}`,
|
|
282
347
|
...(parsed.cursorPassword ? [` 附加信息 : ${chalk.grey('● 已保留备用')}`] : []),
|
|
283
348
|
].join('\n'), { padding: { top: 0, bottom: 0, left: 1, right: 1 }, borderColor: 'blue', borderStyle: 'round' }));
|
|
284
349
|
// 3. 启动云端任务并建立 SSE 流式监听
|
|
@@ -293,7 +358,7 @@ export class PureLoginService {
|
|
|
293
358
|
if (!startRes.ok || !startRes.taskId) {
|
|
294
359
|
console.log(chalk.red(`\n✖ 任务启动失败: ${startRes.detail || '未知原因'}\n`));
|
|
295
360
|
await safePressAnyKey();
|
|
296
|
-
return;
|
|
361
|
+
return null;
|
|
297
362
|
}
|
|
298
363
|
const taskId = startRes.taskId;
|
|
299
364
|
console.log(chalk.green(`✔ 任务已受理 (TaskID: ${taskId.slice(0, 8)}),正在实时处理...\n`));
|
|
@@ -342,44 +407,42 @@ export class PureLoginService {
|
|
|
342
407
|
console.log(chalk.grey(`⏳ ${step}${data.msg || '正在推进登录鉴权...'}`));
|
|
343
408
|
}
|
|
344
409
|
else if (currentEvent === 'need_code') {
|
|
345
|
-
console.log(chalk.yellow(`\n📨 验证码已派发至您的邮箱 (${parsed.email})`));
|
|
346
|
-
|
|
347
|
-
// 1. 若附带了邮箱密码,优先尝试云端协议 4 轮自动收信
|
|
410
|
+
console.log(chalk.yellow(`\n📨 Cursor 验证码已派发至您的邮箱 (${parsed.email})`));
|
|
411
|
+
// 若提供了邮箱密码,调起本地独立隔离浏览器协助自动登录 Outlook
|
|
348
412
|
if (parsed.emailPassword) {
|
|
349
|
-
console.log(chalk.cyan('
|
|
350
|
-
for (let i = 1; i <= 4; i++) {
|
|
351
|
-
await new Promise((r) => setTimeout(r, 2000));
|
|
352
|
-
const foundCode = await this.autoFetchMailCode(parsed.email, parsed.emailPassword, parsed.cursorPassword);
|
|
353
|
-
if (foundCode) {
|
|
354
|
-
otpToSubmit = foundCode;
|
|
355
|
-
console.log(chalk.green(`🎉 云端协议自动提取验证码成功: ${chalk.bold.white(foundCode)}`));
|
|
356
|
-
break;
|
|
357
|
-
}
|
|
358
|
-
else {
|
|
359
|
-
console.log(chalk.grey(`云端收信重试中 (${i}/4)...`));
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
// 2. 若云端协议取码未成功且提供了邮箱密码,触发本地独立隔离浏览器登录 Outlook 收件箱取码
|
|
364
|
-
if (!otpToSubmit && parsed.emailPassword) {
|
|
365
|
-
console.log(chalk.yellow('\n☁ 云端协议收信未就绪 (微软限制或需网页授权)'));
|
|
366
|
-
console.log(chalk.cyan('🚀 正在启动本地独立隔离浏览器,自动登录 Outlook 邮箱提取验证码...'));
|
|
413
|
+
console.log(chalk.cyan('🚀 正在启动本地独立隔离浏览器,自动登录 Outlook 邮箱...'));
|
|
367
414
|
try {
|
|
368
415
|
const mailRes = await OutlookLauncher.openMailbox({
|
|
369
416
|
email: parsed.email,
|
|
370
417
|
emailPassword: parsed.emailPassword,
|
|
371
|
-
sniffOtp:
|
|
372
|
-
sniffTimeoutMs: 20000,
|
|
418
|
+
sniffOtp: false, // 零等待,秒登进入后直接置顶
|
|
373
419
|
});
|
|
374
|
-
if (mailRes.
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
420
|
+
if (mailRes.status === 'logged_in') {
|
|
421
|
+
console.log(boxen([
|
|
422
|
+
chalk.bold.green('✔ 独立浏览器已自动登入 Outlook 收件箱!'),
|
|
423
|
+
chalk.dim('────────────────────────────────────────────────────────────'),
|
|
424
|
+
chalk.bold.white('💡【取码指引】:'),
|
|
425
|
+
` 1. 浏览器窗口已置顶展示,请查看最新的 ${chalk.bold.cyan('Cursor')} 官方邮件`,
|
|
426
|
+
` 2. ${chalk.bold.yellow('特别注意: 若收件箱未看到邮件,请务必点击上方【其他 / Other】分类栏')}`,
|
|
427
|
+
` 3. 复制或记下邮件中的 6 位数字验证码,直接在下方粘贴/输入`,
|
|
428
|
+
].join('\n'), {
|
|
429
|
+
padding: { top: 0, bottom: 0, left: 1, right: 1 },
|
|
430
|
+
borderColor: 'green',
|
|
431
|
+
borderStyle: 'round',
|
|
432
|
+
}));
|
|
380
433
|
}
|
|
381
434
|
else if (mailRes.status === 'manual_required') {
|
|
382
|
-
console.log(
|
|
435
|
+
console.log(boxen([
|
|
436
|
+
chalk.bold.yellow('⚠️ 微软要求安全验证 (辅助邮箱 / 二次认证)'),
|
|
437
|
+
chalk.dim('────────────────────────────────────────────────────────────'),
|
|
438
|
+
` • 浏览器窗口已为您调起并置顶,请在浏览器中完成辅助邮箱验证`,
|
|
439
|
+
` • 验证成功进入收件箱后,查看最新的 ${chalk.bold.cyan('Cursor')} 验证码并在下方输入`,
|
|
440
|
+
` • ${chalk.dim('提示: 若收件箱未看到邮件,请查看【其他】分类栏')}`,
|
|
441
|
+
].join('\n'), {
|
|
442
|
+
padding: { top: 0, bottom: 0, left: 1, right: 1 },
|
|
443
|
+
borderColor: 'yellow',
|
|
444
|
+
borderStyle: 'round',
|
|
445
|
+
}));
|
|
383
446
|
}
|
|
384
447
|
else {
|
|
385
448
|
console.log(chalk.grey(` → 浏览器状态: ${mailRes.message}`));
|
|
@@ -389,13 +452,52 @@ export class PureLoginService {
|
|
|
389
452
|
console.log(chalk.yellow(`本地浏览器唤起异常 (${e.message}),转入终端手动输入`));
|
|
390
453
|
}
|
|
391
454
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
455
|
+
else {
|
|
456
|
+
console.log(boxen([
|
|
457
|
+
chalk.bold.green('📨 Cursor 官方 6 位验证码已派发至您的邮箱!'),
|
|
458
|
+
chalk.dim('────────────────────────────────────────────────────────────'),
|
|
459
|
+
` 接收邮箱 : ${chalk.bold.yellow(parsed.email)}`,
|
|
460
|
+
'',
|
|
461
|
+
chalk.bold.white('💡【取码指引】:'),
|
|
462
|
+
` 1. 请打开/登录您的常用邮箱,查收来自 ${chalk.bold.cyan('Cursor')} 官方的 6 位数字验证码`,
|
|
463
|
+
` 2. ${chalk.bold.yellow('特别注意: 若收件箱未看到邮件,请查看【其他 / Other】或【垃圾邮件】分类栏')}`,
|
|
464
|
+
` 3. 复制收到的 6 位数字验证码,直接在下方粘贴并回车即可完成登录`,
|
|
465
|
+
].join('\n'), {
|
|
466
|
+
padding: { top: 0, bottom: 0, left: 1, right: 1 },
|
|
467
|
+
borderColor: 'cyan',
|
|
468
|
+
borderStyle: 'round',
|
|
469
|
+
}));
|
|
397
470
|
}
|
|
398
|
-
|
|
471
|
+
let otpToSubmit = '';
|
|
472
|
+
let submitAttempts = 0;
|
|
473
|
+
const MAX_ATTEMPTS = 3;
|
|
474
|
+
while (submitAttempts < MAX_ATTEMPTS) {
|
|
475
|
+
const inputVal = (await safeInput({
|
|
476
|
+
message: submitAttempts === 0
|
|
477
|
+
? '请输入收到的 6 位邮箱验证码 (可直接 Ctrl+V 粘贴):'
|
|
478
|
+
: `请重新输入 6 位验证码 (剩余 ${MAX_ATTEMPTS - submitAttempts} 次重试机会):`,
|
|
479
|
+
cancelHint: '输入 r 重发验证码,输入 0 或 q 取消',
|
|
480
|
+
})) || '';
|
|
481
|
+
if (!inputVal) {
|
|
482
|
+
console.log(chalk.red('\n未输入验证码,代登已终止。\n'));
|
|
483
|
+
await safePressAnyKey();
|
|
484
|
+
return null;
|
|
485
|
+
}
|
|
486
|
+
// 支持输入 r / resend 重发验证码 (同会话重发,不扣减卡密额度)
|
|
487
|
+
if (inputVal.toLowerCase() === 'r' || inputVal.toLowerCase() === 'resend') {
|
|
488
|
+
console.log(chalk.cyan('\n⏳ 正在向 Cursor 申请重新发送最新验证码 (同会话重发,不扣额度)...'));
|
|
489
|
+
const resendRes = await this.resendCode(taskId, activeKey, parsed.email);
|
|
490
|
+
if (resendRes.ok) {
|
|
491
|
+
console.log(chalk.green(`✔ ${resendRes.message}`));
|
|
492
|
+
console.log(chalk.grey('提示: 请稍候 3~5 秒,并在收件箱(特别注意点击【其他】分类栏)查收新邮件。\n'));
|
|
493
|
+
}
|
|
494
|
+
else {
|
|
495
|
+
console.log(chalk.yellow(`⚠️ ${resendRes.message}\n`));
|
|
496
|
+
}
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
otpToSubmit = inputVal;
|
|
500
|
+
submitAttempts++;
|
|
399
501
|
console.log(chalk.cyan('正在提交验证码并生成官方登录凭证...'));
|
|
400
502
|
const submitRes = await this.submitOtp(taskId, activeKey, otpToSubmit);
|
|
401
503
|
if (submitRes.ok) {
|
|
@@ -406,6 +508,7 @@ export class PureLoginService {
|
|
|
406
508
|
finishedEmail = submitRes.email;
|
|
407
509
|
break;
|
|
408
510
|
}
|
|
511
|
+
break;
|
|
409
512
|
}
|
|
410
513
|
else if (submitRes.needsSmsCode) {
|
|
411
514
|
console.log(chalk.yellow(`\n📱 检测到手机二次短信验证 (${submitRes.phoneMask || '••••'})`));
|
|
@@ -422,18 +525,35 @@ export class PureLoginService {
|
|
|
422
525
|
break;
|
|
423
526
|
}
|
|
424
527
|
}
|
|
528
|
+
break;
|
|
529
|
+
}
|
|
530
|
+
else if (submitRes.canRetry && submitAttempts < MAX_ATTEMPTS) {
|
|
531
|
+
console.log(chalk.yellow(`\n⚠️ 验证码未通过: ${submitRes.detail || '验证码有误或网络抖动'}`));
|
|
532
|
+
const shouldRetry = await safeConfirm({
|
|
533
|
+
message: `当前代登会话仍有效,是否重新输入验证码?(还可重试 ${MAX_ATTEMPTS - submitAttempts} 次)`,
|
|
534
|
+
default: true,
|
|
535
|
+
});
|
|
536
|
+
if (shouldRetry) {
|
|
537
|
+
otpToSubmit = '';
|
|
538
|
+
continue;
|
|
539
|
+
}
|
|
540
|
+
else {
|
|
541
|
+
console.log(chalk.grey('\n用户主动取消重试,代登已终止。\n'));
|
|
542
|
+
await safePressAnyKey();
|
|
543
|
+
return null;
|
|
544
|
+
}
|
|
425
545
|
}
|
|
426
546
|
else {
|
|
427
|
-
|
|
547
|
+
if (submitAttempts >= MAX_ATTEMPTS) {
|
|
548
|
+
console.log(chalk.red(`\n✖ 连续 ${MAX_ATTEMPTS} 次验证未通过,为防止账号触发官方风控已主动终止。\n`));
|
|
549
|
+
}
|
|
550
|
+
else {
|
|
551
|
+
console.log(chalk.red(`\n✖ 验证码提交未通过: ${submitRes.detail || '验证码错误或会话已过期'}\n`));
|
|
552
|
+
}
|
|
428
553
|
await safePressAnyKey();
|
|
429
|
-
return;
|
|
554
|
+
return null;
|
|
430
555
|
}
|
|
431
556
|
}
|
|
432
|
-
else {
|
|
433
|
-
console.log(chalk.red('\n未输入验证码,代登已终止。\n'));
|
|
434
|
-
await safePressAnyKey();
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
557
|
}
|
|
438
558
|
else if (currentEvent === 'need_sms_code') {
|
|
439
559
|
console.log(chalk.yellow(`\n📱 检测到手机二次短信验证 (${data.phoneMask || '••••'})`));
|
|
@@ -460,7 +580,7 @@ export class PureLoginService {
|
|
|
460
580
|
else if (currentEvent === 'failed' || (data.error && currentEvent !== 'status')) {
|
|
461
581
|
console.log(chalk.red(`\n✖ 代登未完成: ${data.error || data.detail || '官方服务响应超时或验证失败'}\n`));
|
|
462
582
|
await safePressAnyKey();
|
|
463
|
-
return;
|
|
583
|
+
return null;
|
|
464
584
|
}
|
|
465
585
|
}
|
|
466
586
|
catch { }
|
|
@@ -479,7 +599,7 @@ export class PureLoginService {
|
|
|
479
599
|
console.log(chalk.grey('可能原因: 验证码录入耗时过长导致云端会话超时、或网络连接波动。'));
|
|
480
600
|
console.log(chalk.grey('建议: 请检查邮箱验证码是否正确,在主菜单重新进入代登即可。\n'));
|
|
481
601
|
await safePressAnyKey();
|
|
482
|
-
return;
|
|
602
|
+
return null;
|
|
483
603
|
}
|
|
484
604
|
console.log(chalk.green.bold('\n🎉 纯净代登成功!官方凭据已安全捕获!'));
|
|
485
605
|
const parsedToken = TokenParser.parse(finishedToken);
|
|
@@ -511,6 +631,9 @@ export class PureLoginService {
|
|
|
511
631
|
].join('\n'), { padding: { top: 0, bottom: 0, left: 1, right: 1 }, borderColor: 'green', borderStyle: 'round' }));
|
|
512
632
|
console.log(chalk.bold.white('\n📋 官方完整 Token (点击或拖选即可复制):'));
|
|
513
633
|
console.log(chalk.cyan(finishedToken) + '\n');
|
|
634
|
+
if (options.skipSwitchPrompt) {
|
|
635
|
+
return newAccount;
|
|
636
|
+
}
|
|
514
637
|
// 询问是否立即切换
|
|
515
638
|
const doSwitch = await safeConfirm({
|
|
516
639
|
message: `是否立即切换到该账号 (${newAccount.email}) 并激活专属指纹?`,
|
|
@@ -546,5 +669,6 @@ export class PureLoginService {
|
|
|
546
669
|
}
|
|
547
670
|
}
|
|
548
671
|
await safePressAnyKey();
|
|
672
|
+
return newAccount;
|
|
549
673
|
}
|
|
550
674
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor 老用户回归特权 (Welcome-Back Offer) 检测与免密直通服务
|
|
3
|
+
* 支持:
|
|
4
|
+
* 1. 携带已有 Token / SessionCookie 进行毫秒级轻量嗅探
|
|
5
|
+
* 2. 只有邮箱与密码时,自动通过纯净住宅专线代登获取新 Token,展示并复制到剪贴板后紧接着检测
|
|
6
|
+
* 3. 命中资格后,调用独立 Chromium 原生 CDP 注入 Cookie,免串号直达激活与结账页
|
|
7
|
+
*/
|
|
8
|
+
import type { AccountStore } from './account-store.js';
|
|
9
|
+
import type { StorageBridge } from './storage-bridge.js';
|
|
10
|
+
import type { SqliteBridge } from './sqlite-bridge.js';
|
|
11
|
+
export interface WelcomeOfferResult {
|
|
12
|
+
status: 'ELIGIBLE' | 'NOT_ELIGIBLE' | 'EXPIRED_TOKEN' | 'ERROR';
|
|
13
|
+
canActivate?: boolean;
|
|
14
|
+
redemptionFlow?: string;
|
|
15
|
+
previousPlanTier?: string;
|
|
16
|
+
incentiveTreatment?: string;
|
|
17
|
+
headlineDiscount?: string;
|
|
18
|
+
discountedPrice?: string;
|
|
19
|
+
originalPrice?: string;
|
|
20
|
+
pricePeriodLabel?: string;
|
|
21
|
+
rolloverSentence?: string;
|
|
22
|
+
footnote?: string;
|
|
23
|
+
agentRuns?: number;
|
|
24
|
+
linesOfCodeWritten?: number;
|
|
25
|
+
message?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare class WelcomeOfferService {
|
|
28
|
+
/**
|
|
29
|
+
* 携带 SessionToken 静默嗅探 Cursor 官方回归资格接口
|
|
30
|
+
*/
|
|
31
|
+
static checkOffer(sessionToken: string): Promise<WelcomeOfferResult>;
|
|
32
|
+
/**
|
|
33
|
+
* 调起独立隔离浏览器免密直达激活结账页
|
|
34
|
+
*/
|
|
35
|
+
static openOfferPage(token: string, email?: string): Promise<boolean>;
|
|
36
|
+
/**
|
|
37
|
+
* 交互式运行回归资格检测主流程 (终端 TUI)
|
|
38
|
+
*/
|
|
39
|
+
static runInteractiveFlow(store: AccountStore, storage: StorageBridge, sqlite: SqliteBridge, executablePath?: string, initialIdentifier?: string): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* 执行纯净代登流程并衔接资格检测
|
|
42
|
+
*/
|
|
43
|
+
private static handlePureLoginFlow;
|
|
44
|
+
/**
|
|
45
|
+
* 统一处理资格判定结果与后续交互
|
|
46
|
+
*/
|
|
47
|
+
private static handleOfferResult;
|
|
48
|
+
/**
|
|
49
|
+
* 极速切换本机 Cursor IDE 为此账号
|
|
50
|
+
*/
|
|
51
|
+
private static switchCurrentIde;
|
|
52
|
+
}
|