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.
- package/README.md +76 -75
- package/SECURITY.md +22 -19
- package/bin/cswitch.js +31 -8
- package/dist/cli.d.ts +0 -4
- package/dist/cli.js +404 -241
- package/dist/core/account-store.d.ts +0 -7
- package/dist/core/account-store.js +22 -28
- package/dist/core/cdp-engine.d.ts +11 -49
- package/dist/core/cdp-engine.js +155 -110
- package/dist/core/config-store.d.ts +7 -6
- package/dist/core/config-store.js +33 -12
- package/dist/core/cursor-paths.d.ts +8 -18
- package/dist/core/cursor-paths.js +18 -37
- package/dist/core/dashboard-launcher.d.ts +0 -20
- package/dist/core/dashboard-launcher.js +3 -53
- package/dist/core/extract-client.d.ts +57 -0
- package/dist/core/extract-client.js +219 -0
- package/dist/core/extract-menu.d.ts +3 -0
- package/dist/core/extract-menu.js +360 -0
- package/dist/core/extract-service.d.ts +64 -0
- package/dist/core/extract-service.js +435 -0
- package/dist/core/fingerprint.d.ts +0 -4
- package/dist/core/fingerprint.js +0 -6
- package/dist/core/oauth-receiver.d.ts +1 -11
- package/dist/core/oauth-receiver.js +509 -527
- package/dist/core/official-api.d.ts +0 -17
- package/dist/core/official-api.js +4 -23
- package/dist/core/outlook-launcher.d.ts +0 -31
- package/dist/core/outlook-launcher.js +194 -248
- package/dist/core/process-manager.d.ts +0 -14
- package/dist/core/process-manager.js +7 -22
- package/dist/core/pure-login-service.d.ts +54 -38
- package/dist/core/pure-login-service.js +483 -395
- package/dist/core/refund-client.d.ts +0 -22
- package/dist/core/refund-client.js +7 -27
- package/dist/core/refund-service.d.ts +0 -16
- package/dist/core/refund-service.js +8 -34
- package/dist/core/safe-storage.d.ts +27 -0
- package/dist/core/safe-storage.js +284 -0
- package/dist/core/sqlite-bridge.d.ts +10 -11
- package/dist/core/sqlite-bridge.js +112 -47
- package/dist/core/storage-bridge.d.ts +14 -5
- package/dist/core/storage-bridge.js +84 -24
- package/dist/core/switch-orchestrator.d.ts +96 -0
- package/dist/core/switch-orchestrator.js +341 -0
- package/dist/core/token-exchange.d.ts +81 -0
- package/dist/core/token-exchange.js +275 -0
- package/dist/core/token-parser.d.ts +56 -20
- package/dist/core/token-parser.js +354 -43
- package/dist/core/update-checker.d.ts +1 -29
- package/dist/core/update-checker.js +28 -43
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -3
- package/dist/menu.d.ts +0 -7
- package/dist/menu.js +445 -548
- package/dist/types.d.ts +12 -4
- package/dist/types.js +0 -4
- package/dist/utils/account-text-importer.d.ts +9 -0
- package/dist/utils/account-text-importer.js +96 -0
- package/dist/utils/browser-utils.d.ts +0 -24
- package/dist/utils/browser-utils.js +0 -57
- package/dist/utils/clipboard.d.ts +0 -4
- package/dist/utils/clipboard.js +0 -5
- package/dist/utils/credential-bundle-ui.d.ts +36 -0
- package/dist/utils/credential-bundle-ui.js +246 -0
- package/dist/utils/live-menu.d.ts +37 -9
- package/dist/utils/live-menu.js +510 -81
- package/dist/utils/plan-formatter.d.ts +0 -26
- package/dist/utils/plan-formatter.js +10 -44
- package/dist/utils/prompt-utils.d.ts +0 -18
- package/dist/utils/prompt-utils.js +0 -23
- package/dist/utils/proxy-bootstrap.d.ts +12 -0
- package/dist/utils/proxy-bootstrap.js +141 -0
- package/dist/utils/security.d.ts +2 -4
- package/dist/utils/security.js +36 -4
- package/dist/utils/table-renderer.d.ts +0 -4
- package/dist/utils/table-renderer.js +24 -8
- package/dist/utils/time-formatter.d.ts +0 -4
- package/dist/utils/time-formatter.js +0 -8
- package/dist/utils/token-preflight-ui.d.ts +28 -0
- package/dist/utils/token-preflight-ui.js +222 -0
- package/dist/utils/window-focus.d.ts +3 -0
- package/dist/utils/window-focus.js +106 -0
- package/package.json +12 -5
- package/dist/core/welcome-offer-service.d.ts +0 -52
- package/dist/core/welcome-offer-service.js +0 -369
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 本地认证回调监听服务 (Local OAuth Receiver)
|
|
3
|
-
* 启动临时 HTTP 监听,支持跨浏览器 (Chrome/Edge/Safari/Firefox/Arc) 登录与凭据捕获
|
|
4
|
-
* 具备端口冲突自愈、CORS 支持、一键控制台抓取脚本、书签栏抓取与手动辅助提交
|
|
5
|
-
*/
|
|
6
1
|
import http from 'node:http';
|
|
7
2
|
import readline from 'node:readline';
|
|
8
3
|
import crypto from 'node:crypto';
|
|
@@ -11,10 +6,15 @@ import boxen from 'boxen';
|
|
|
11
6
|
import { TokenParser } from './token-parser.js';
|
|
12
7
|
import { openBrowserUrl, openIncognitoBrowserUrl } from '../utils/browser-utils.js';
|
|
13
8
|
import { OfficialApiClient } from './official-api.js';
|
|
9
|
+
export function escapeHtml(input) {
|
|
10
|
+
return String(input ?? '')
|
|
11
|
+
.replace(/&/g, '&')
|
|
12
|
+
.replace(/</g, '<')
|
|
13
|
+
.replace(/>/g, '>')
|
|
14
|
+
.replace(/"/g, '"')
|
|
15
|
+
.replace(/'/g, ''');
|
|
16
|
+
}
|
|
14
17
|
export class OAuthReceiver {
|
|
15
|
-
/**
|
|
16
|
-
* 调起无痕新浏览器实例,通过官方原生 PKCE 端点执行全自动 OAuth 登录与秒级回传
|
|
17
|
-
*/
|
|
18
18
|
static async startOfficialOAuthFlow() {
|
|
19
19
|
const verifier = crypto.randomBytes(32).toString('base64url');
|
|
20
20
|
const challenge = crypto.createHash('sha256').update(verifier).digest('base64url');
|
|
@@ -40,7 +40,6 @@ export class OAuthReceiver {
|
|
|
40
40
|
borderColor: 'cyan',
|
|
41
41
|
borderStyle: 'round',
|
|
42
42
|
}));
|
|
43
|
-
// 调起无痕浏览器
|
|
44
43
|
await openIncognitoBrowserUrl(loginUrl);
|
|
45
44
|
return new Promise((resolve) => {
|
|
46
45
|
let isDone = false;
|
|
@@ -59,10 +58,9 @@ export class OAuthReceiver {
|
|
|
59
58
|
if (spinnerTimer)
|
|
60
59
|
clearInterval(spinnerTimer);
|
|
61
60
|
cleanupStdin();
|
|
62
|
-
process.stdout.write('\r\x1b[K\x1b[?25h');
|
|
61
|
+
process.stdout.write('\r\x1b[K\x1b[?25h');
|
|
63
62
|
resolve(result);
|
|
64
63
|
};
|
|
65
|
-
// 终端单键即时退出监听
|
|
66
64
|
if (process.stdin.isTTY) {
|
|
67
65
|
readline.emitKeypressEvents(process.stdin);
|
|
68
66
|
const wasRaw = process.stdin.isRaw;
|
|
@@ -103,7 +101,6 @@ export class OAuthReceiver {
|
|
|
103
101
|
process.stdout.write('\x1b[?25h');
|
|
104
102
|
};
|
|
105
103
|
}
|
|
106
|
-
// 实时走字动画与时间提示
|
|
107
104
|
spinnerTimer = setInterval(() => {
|
|
108
105
|
if (isDone)
|
|
109
106
|
return;
|
|
@@ -111,7 +108,6 @@ export class OAuthReceiver {
|
|
|
111
108
|
const frame = chalk.cyan(spinnerFrames[spinnerIdx++ % spinnerFrames.length]);
|
|
112
109
|
process.stdout.write(`\r ${frame} 正在等待网页端授权回传... (已等待 ${chalk.bold.yellow(elapsedSeconds)}s, 按 0 或 q 取消)`);
|
|
113
110
|
}, 1000);
|
|
114
|
-
// 轮询官方端点 (防重入保护)
|
|
115
111
|
let isPolling = false;
|
|
116
112
|
const poll = async () => {
|
|
117
113
|
if (isDone || isPolling)
|
|
@@ -130,7 +126,6 @@ export class OAuthReceiver {
|
|
|
130
126
|
if (data && data.accessToken) {
|
|
131
127
|
process.stdout.write('\r\x1b[K');
|
|
132
128
|
console.log(chalk.green('\n✔ 官方授权完成!已成功捕获登录凭据'));
|
|
133
|
-
// 尝试向官方接口查询精准真实邮箱
|
|
134
129
|
let email;
|
|
135
130
|
try {
|
|
136
131
|
process.stdout.write(chalk.grey('正在向官方端点同步账号邮箱信息... '));
|
|
@@ -170,15 +165,12 @@ export class OAuthReceiver {
|
|
|
170
165
|
}
|
|
171
166
|
}
|
|
172
167
|
catch {
|
|
173
|
-
// 网络抖动或超时,继续轮询
|
|
174
168
|
}
|
|
175
169
|
finally {
|
|
176
170
|
isPolling = false;
|
|
177
171
|
}
|
|
178
172
|
};
|
|
179
|
-
// 每 1000ms 轮询一次
|
|
180
173
|
pollTimer = setInterval(poll, 1000);
|
|
181
|
-
// 5 分钟安全超时
|
|
182
174
|
setTimeout(() => {
|
|
183
175
|
finish({
|
|
184
176
|
success: false,
|
|
@@ -187,9 +179,6 @@ export class OAuthReceiver {
|
|
|
187
179
|
}, 5 * 60 * 1000);
|
|
188
180
|
});
|
|
189
181
|
}
|
|
190
|
-
/**
|
|
191
|
-
* 启动本地监听服务并调起浏览器协助登录
|
|
192
|
-
*/
|
|
193
182
|
static async startBrowserLoginFlow(defaultPort = 41890) {
|
|
194
183
|
return new Promise((resolve) => {
|
|
195
184
|
let isResolved = false;
|
|
@@ -197,7 +186,6 @@ export class OAuthReceiver {
|
|
|
197
186
|
let cleanupStdin = () => { };
|
|
198
187
|
const createAndListen = (portToTry) => {
|
|
199
188
|
const server = http.createServer((req, res) => {
|
|
200
|
-
// 开启跨域允许与完全禁用浏览器缓存
|
|
201
189
|
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
202
190
|
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
|
|
203
191
|
res.setHeader('Access-Control-Allow-Headers', '*');
|
|
@@ -210,36 +198,35 @@ export class OAuthReceiver {
|
|
|
210
198
|
return;
|
|
211
199
|
}
|
|
212
200
|
const url = new URL(req.url || '/', `http://127.0.0.1:${portToTry}`);
|
|
213
|
-
// 检查用户在网页端是否点击了取消
|
|
214
201
|
const action = url.searchParams.get('action');
|
|
215
202
|
if (action === 'cancel') {
|
|
216
203
|
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
217
|
-
res.end(`
|
|
218
|
-
<!DOCTYPE html>
|
|
219
|
-
<html lang="zh-CN">
|
|
220
|
-
<head>
|
|
221
|
-
<meta charset="utf-8">
|
|
222
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
223
|
-
<title>Cursor-Switch 已取消操作</title>
|
|
224
|
-
<style>
|
|
225
|
-
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #080c14; color: #f8fafc; display: flex; align-items: center; justify-content: center; min-height: 100vh; margin: 0; padding: 20px; }
|
|
226
|
-
.card { text-align: center; border: 1px solid rgba(255, 255, 255, 0.08); padding: 40px; border-radius: 20px; background: #111827; box-shadow: 0 20px 50px rgba(0,0,0,0.6); max-width: 440px; width: 100%; }
|
|
227
|
-
h2 { color: #f1f5f9; margin: 0 0 12px 0; font-size: 20px; font-weight: 700; }
|
|
228
|
-
p { color: #94a3b8; font-size: 14px; line-height: 1.6; margin: 0 0 24px 0; }
|
|
229
|
-
.btn-close { background: #334155; color: #fff; border: none; border-radius: 8px; padding: 10px 24px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.2s; }
|
|
230
|
-
.btn-close:hover { background: #475569; }
|
|
231
|
-
</style>
|
|
232
|
-
</head>
|
|
233
|
-
<body>
|
|
234
|
-
<div class="card">
|
|
235
|
-
<div style="font-size: 36px; margin-bottom: 14px;">👋</div>
|
|
236
|
-
<h2>已取消本次提取操作</h2>
|
|
237
|
-
<p>本地监听服务已安全关闭。<br>您可以关闭此标签页并切回命令行终端。</p>
|
|
238
|
-
<button type="button" class="btn-close" onclick="window.close()">✕ 关闭此标签页</button>
|
|
239
|
-
</div>
|
|
240
|
-
<script>setTimeout(() => { window.close(); }, 2000);</script>
|
|
241
|
-
</body>
|
|
242
|
-
</html>
|
|
204
|
+
res.end(`
|
|
205
|
+
<!DOCTYPE html>
|
|
206
|
+
<html lang="zh-CN">
|
|
207
|
+
<head>
|
|
208
|
+
<meta charset="utf-8">
|
|
209
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
210
|
+
<title>Cursor-Switch 已取消操作</title>
|
|
211
|
+
<style>
|
|
212
|
+
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #080c14; color: #f8fafc; display: flex; align-items: center; justify-content: center; min-height: 100vh; margin: 0; padding: 20px; }
|
|
213
|
+
.card { text-align: center; border: 1px solid rgba(255, 255, 255, 0.08); padding: 40px; border-radius: 20px; background: #111827; box-shadow: 0 20px 50px rgba(0,0,0,0.6); max-width: 440px; width: 100%; }
|
|
214
|
+
h2 { color: #f1f5f9; margin: 0 0 12px 0; font-size: 20px; font-weight: 700; }
|
|
215
|
+
p { color: #94a3b8; font-size: 14px; line-height: 1.6; margin: 0 0 24px 0; }
|
|
216
|
+
.btn-close { background: #334155; color: #fff; border: none; border-radius: 8px; padding: 10px 24px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.2s; }
|
|
217
|
+
.btn-close:hover { background: #475569; }
|
|
218
|
+
</style>
|
|
219
|
+
</head>
|
|
220
|
+
<body>
|
|
221
|
+
<div class="card">
|
|
222
|
+
<div style="font-size: 36px; margin-bottom: 14px;">👋</div>
|
|
223
|
+
<h2>已取消本次提取操作</h2>
|
|
224
|
+
<p>本地监听服务已安全关闭。<br>您可以关闭此标签页并切回命令行终端。</p>
|
|
225
|
+
<button type="button" class="btn-close" onclick="window.close()">✕ 关闭此标签页</button>
|
|
226
|
+
</div>
|
|
227
|
+
<script>setTimeout(() => { window.close(); }, 2000);</script>
|
|
228
|
+
</body>
|
|
229
|
+
</html>
|
|
243
230
|
`);
|
|
244
231
|
cleanupStdin();
|
|
245
232
|
if (!isResolved) {
|
|
@@ -253,105 +240,104 @@ export class OAuthReceiver {
|
|
|
253
240
|
}
|
|
254
241
|
return;
|
|
255
242
|
}
|
|
256
|
-
// 处理提交或回调中的 token 参数
|
|
257
243
|
const rawToken = url.searchParams.get('token') || url.searchParams.get('session');
|
|
258
244
|
const rawEmail = url.searchParams.get('email');
|
|
259
245
|
if (rawToken) {
|
|
260
246
|
const parsed = TokenParser.parse(rawToken);
|
|
261
247
|
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
262
|
-
res.end(`
|
|
263
|
-
<!DOCTYPE html>
|
|
264
|
-
<html lang="zh-CN">
|
|
265
|
-
<head>
|
|
266
|
-
<meta charset="utf-8">
|
|
267
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
268
|
-
<title>Cursor-Switch 凭据捕获成功</title>
|
|
269
|
-
<style>
|
|
270
|
-
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
271
|
-
body {
|
|
272
|
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
273
|
-
background: #080c14;
|
|
274
|
-
color: #f8fafc;
|
|
275
|
-
display: flex;
|
|
276
|
-
align-items: center;
|
|
277
|
-
justify-content: center;
|
|
278
|
-
min-height: 100vh;
|
|
279
|
-
padding: 20px;
|
|
280
|
-
}
|
|
281
|
-
.card {
|
|
282
|
-
text-align: center;
|
|
283
|
-
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
284
|
-
padding: 44px 36px;
|
|
285
|
-
border-radius: 20px;
|
|
286
|
-
background: #111827;
|
|
287
|
-
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
|
|
288
|
-
max-width: 480px;
|
|
289
|
-
width: 100%;
|
|
290
|
-
}
|
|
291
|
-
.icon-circle {
|
|
292
|
-
width: 64px;
|
|
293
|
-
height: 64px;
|
|
294
|
-
background: rgba(16, 185, 129, 0.15);
|
|
295
|
-
border: 1px solid rgba(16, 185, 129, 0.3);
|
|
296
|
-
border-radius: 50%;
|
|
297
|
-
display: flex;
|
|
298
|
-
align-items: center;
|
|
299
|
-
justify-content: center;
|
|
300
|
-
margin: 0 auto 20px;
|
|
301
|
-
color: #34d399;
|
|
302
|
-
font-size: 32px;
|
|
303
|
-
box-shadow: 0 0 25px rgba(16, 185, 129, 0.25);
|
|
304
|
-
}
|
|
305
|
-
h2 { color: #ffffff; margin: 0 0 10px 0; font-size: 22px; font-weight: 700; }
|
|
306
|
-
p { color: #94a3b8; font-size: 14px; line-height: 1.6; margin: 0 0 22px 0; }
|
|
307
|
-
.email-box {
|
|
308
|
-
background: rgba(0, 0, 0, 0.25);
|
|
309
|
-
border: 1px solid rgba(255, 255, 255, 0.06);
|
|
310
|
-
border-radius: 10px;
|
|
311
|
-
padding: 10px 14px;
|
|
312
|
-
font-size: 13px;
|
|
313
|
-
color: #e2e8f0;
|
|
314
|
-
margin-bottom: 22px;
|
|
315
|
-
word-break: break-all;
|
|
316
|
-
}
|
|
317
|
-
.btn-close {
|
|
318
|
-
background: #2563eb;
|
|
319
|
-
color: #fff;
|
|
320
|
-
border: none;
|
|
321
|
-
border-radius: 8px;
|
|
322
|
-
padding: 10px 24px;
|
|
323
|
-
font-size: 13px;
|
|
324
|
-
font-weight: 600;
|
|
325
|
-
cursor: pointer;
|
|
326
|
-
transition: background 0.2s;
|
|
327
|
-
}
|
|
328
|
-
.btn-close:hover { background: #1d4ed8; }
|
|
329
|
-
.countdown { font-size: 12px; color: #64748b; margin-top: 14px; }
|
|
330
|
-
</style>
|
|
331
|
-
</head>
|
|
332
|
-
<body>
|
|
333
|
-
<div class="card">
|
|
334
|
-
<div class="icon-circle">✔</div>
|
|
335
|
-
<h2>🎉 官方 Token 捕获成功!</h2>
|
|
336
|
-
<p>凭据已安全传输回终端,账号已自动纳管入库。<br>终端即将自动为您激活账号与专属防封指纹。</p>
|
|
337
|
-
${rawEmail || parsed.email ? `<div class="email-box">已成功收录: <b>${rawEmail || parsed.email}</b></div>` : ''}
|
|
338
|
-
<button type="button" class="btn-close" onclick="window.close()">✕ 关闭此标签页</button>
|
|
339
|
-
<div class="countdown" id="cd">本页面将在 3 秒后尝试自动关闭...</div>
|
|
340
|
-
</div>
|
|
341
|
-
<script>
|
|
342
|
-
let s = 3;
|
|
343
|
-
const timer = setInterval(() => {
|
|
344
|
-
s--;
|
|
345
|
-
const el = document.getElementById('cd');
|
|
346
|
-
if (el) el.textContent = '本页面将在 ' + s + ' 秒后尝试自动关闭...';
|
|
347
|
-
if (s <= 0) {
|
|
348
|
-
clearInterval(timer);
|
|
349
|
-
window.close();
|
|
350
|
-
}
|
|
351
|
-
}, 1000);
|
|
352
|
-
</script>
|
|
353
|
-
</body>
|
|
354
|
-
</html>
|
|
248
|
+
res.end(`
|
|
249
|
+
<!DOCTYPE html>
|
|
250
|
+
<html lang="zh-CN">
|
|
251
|
+
<head>
|
|
252
|
+
<meta charset="utf-8">
|
|
253
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
254
|
+
<title>Cursor-Switch 凭据捕获成功</title>
|
|
255
|
+
<style>
|
|
256
|
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
257
|
+
body {
|
|
258
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
259
|
+
background: #080c14;
|
|
260
|
+
color: #f8fafc;
|
|
261
|
+
display: flex;
|
|
262
|
+
align-items: center;
|
|
263
|
+
justify-content: center;
|
|
264
|
+
min-height: 100vh;
|
|
265
|
+
padding: 20px;
|
|
266
|
+
}
|
|
267
|
+
.card {
|
|
268
|
+
text-align: center;
|
|
269
|
+
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
270
|
+
padding: 44px 36px;
|
|
271
|
+
border-radius: 20px;
|
|
272
|
+
background: #111827;
|
|
273
|
+
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
|
|
274
|
+
max-width: 480px;
|
|
275
|
+
width: 100%;
|
|
276
|
+
}
|
|
277
|
+
.icon-circle {
|
|
278
|
+
width: 64px;
|
|
279
|
+
height: 64px;
|
|
280
|
+
background: rgba(16, 185, 129, 0.15);
|
|
281
|
+
border: 1px solid rgba(16, 185, 129, 0.3);
|
|
282
|
+
border-radius: 50%;
|
|
283
|
+
display: flex;
|
|
284
|
+
align-items: center;
|
|
285
|
+
justify-content: center;
|
|
286
|
+
margin: 0 auto 20px;
|
|
287
|
+
color: #34d399;
|
|
288
|
+
font-size: 32px;
|
|
289
|
+
box-shadow: 0 0 25px rgba(16, 185, 129, 0.25);
|
|
290
|
+
}
|
|
291
|
+
h2 { color: #ffffff; margin: 0 0 10px 0; font-size: 22px; font-weight: 700; }
|
|
292
|
+
p { color: #94a3b8; font-size: 14px; line-height: 1.6; margin: 0 0 22px 0; }
|
|
293
|
+
.email-box {
|
|
294
|
+
background: rgba(0, 0, 0, 0.25);
|
|
295
|
+
border: 1px solid rgba(255, 255, 255, 0.06);
|
|
296
|
+
border-radius: 10px;
|
|
297
|
+
padding: 10px 14px;
|
|
298
|
+
font-size: 13px;
|
|
299
|
+
color: #e2e8f0;
|
|
300
|
+
margin-bottom: 22px;
|
|
301
|
+
word-break: break-all;
|
|
302
|
+
}
|
|
303
|
+
.btn-close {
|
|
304
|
+
background: #2563eb;
|
|
305
|
+
color: #fff;
|
|
306
|
+
border: none;
|
|
307
|
+
border-radius: 8px;
|
|
308
|
+
padding: 10px 24px;
|
|
309
|
+
font-size: 13px;
|
|
310
|
+
font-weight: 600;
|
|
311
|
+
cursor: pointer;
|
|
312
|
+
transition: background 0.2s;
|
|
313
|
+
}
|
|
314
|
+
.btn-close:hover { background: #1d4ed8; }
|
|
315
|
+
.countdown { font-size: 12px; color: #64748b; margin-top: 14px; }
|
|
316
|
+
</style>
|
|
317
|
+
</head>
|
|
318
|
+
<body>
|
|
319
|
+
<div class="card">
|
|
320
|
+
<div class="icon-circle">✔</div>
|
|
321
|
+
<h2>🎉 官方 Token 捕获成功!</h2>
|
|
322
|
+
<p>凭据已安全传输回终端,账号已自动纳管入库。<br>终端即将自动为您激活账号与专属防封指纹。</p>
|
|
323
|
+
${rawEmail || parsed.email ? `<div class="email-box">已成功收录: <b>${escapeHtml(rawEmail || parsed.email || '')}</b></div>` : ''}
|
|
324
|
+
<button type="button" class="btn-close" onclick="window.close()">✕ 关闭此标签页</button>
|
|
325
|
+
<div class="countdown" id="cd">本页面将在 3 秒后尝试自动关闭...</div>
|
|
326
|
+
</div>
|
|
327
|
+
<script>
|
|
328
|
+
let s = 3;
|
|
329
|
+
const timer = setInterval(() => {
|
|
330
|
+
s--;
|
|
331
|
+
const el = document.getElementById('cd');
|
|
332
|
+
if (el) el.textContent = '本页面将在 ' + s + ' 秒后尝试自动关闭...';
|
|
333
|
+
if (s <= 0) {
|
|
334
|
+
clearInterval(timer);
|
|
335
|
+
window.close();
|
|
336
|
+
}
|
|
337
|
+
}, 1000);
|
|
338
|
+
</script>
|
|
339
|
+
</body>
|
|
340
|
+
</html>
|
|
355
341
|
`);
|
|
356
342
|
cleanupStdin();
|
|
357
343
|
if (!isResolved) {
|
|
@@ -366,389 +352,388 @@ export class OAuthReceiver {
|
|
|
366
352
|
}
|
|
367
353
|
return;
|
|
368
354
|
}
|
|
369
|
-
// 浏览器访问时的引导提取与提交页面
|
|
370
355
|
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
371
|
-
res.end(`
|
|
372
|
-
<!DOCTYPE html>
|
|
373
|
-
<html lang="zh-CN">
|
|
374
|
-
<head>
|
|
375
|
-
<meta charset="utf-8">
|
|
376
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
377
|
-
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
|
|
378
|
-
<meta http-equiv="Pragma" content="no-cache">
|
|
379
|
-
<meta http-equiv="Expires" content="0">
|
|
380
|
-
<title>Cursor-Switch 浏览器凭据同步助手</title>
|
|
381
|
-
<style>
|
|
382
|
-
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
383
|
-
body {
|
|
384
|
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
385
|
-
background: #080c14;
|
|
386
|
-
color: #e2e8f0;
|
|
387
|
-
min-height: 100vh;
|
|
388
|
-
display: flex;
|
|
389
|
-
align-items: center;
|
|
390
|
-
justify-content: center;
|
|
391
|
-
padding: 24px;
|
|
392
|
-
line-height: 1.5;
|
|
393
|
-
}
|
|
394
|
-
.wrapper {
|
|
395
|
-
max-width: 540px;
|
|
396
|
-
width: 100%;
|
|
397
|
-
background: #111827;
|
|
398
|
-
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
399
|
-
border-radius: 20px;
|
|
400
|
-
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
|
|
401
|
-
overflow: hidden;
|
|
402
|
-
}
|
|
403
|
-
.header {
|
|
404
|
-
padding: 24px 28px 20px;
|
|
405
|
-
background: linear-gradient(180deg, rgba(30, 41, 59, 0.4) 0%, rgba(17, 24, 39, 0) 100%);
|
|
406
|
-
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
|
|
407
|
-
}
|
|
408
|
-
.header-top {
|
|
409
|
-
display: flex;
|
|
410
|
-
align-items: center;
|
|
411
|
-
justify-content: space-between;
|
|
412
|
-
margin-bottom: 8px;
|
|
413
|
-
}
|
|
414
|
-
.brand {
|
|
415
|
-
display: flex;
|
|
416
|
-
align-items: center;
|
|
417
|
-
gap: 10px;
|
|
418
|
-
}
|
|
419
|
-
.brand-icon {
|
|
420
|
-
width: 32px;
|
|
421
|
-
height: 32px;
|
|
422
|
-
background: linear-gradient(135deg, #0ea5e9 0%, #3b82f6 100%);
|
|
423
|
-
border-radius: 9px;
|
|
424
|
-
display: flex;
|
|
425
|
-
align-items: center;
|
|
426
|
-
justify-content: center;
|
|
427
|
-
font-size: 18px;
|
|
428
|
-
box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
|
|
429
|
-
}
|
|
430
|
-
.brand-title {
|
|
431
|
-
font-size: 18px;
|
|
432
|
-
font-weight: 700;
|
|
433
|
-
color: #ffffff;
|
|
434
|
-
}
|
|
435
|
-
.status-pill {
|
|
436
|
-
display: flex;
|
|
437
|
-
align-items: center;
|
|
438
|
-
gap: 6px;
|
|
439
|
-
background: rgba(16, 185, 129, 0.12);
|
|
440
|
-
border: 1px solid rgba(16, 185, 129, 0.3);
|
|
441
|
-
color: #34d399;
|
|
442
|
-
font-size: 12px;
|
|
443
|
-
font-weight: 500;
|
|
444
|
-
padding: 4px 10px;
|
|
445
|
-
border-radius: 9999px;
|
|
446
|
-
}
|
|
447
|
-
.status-dot {
|
|
448
|
-
width: 7px;
|
|
449
|
-
height: 7px;
|
|
450
|
-
background: #10b981;
|
|
451
|
-
border-radius: 50%;
|
|
452
|
-
box-shadow: 0 0 8px #10b981;
|
|
453
|
-
animation: pulse 2s infinite;
|
|
454
|
-
}
|
|
455
|
-
@keyframes pulse {
|
|
456
|
-
0%, 100% { opacity: 1; transform: scale(1); }
|
|
457
|
-
50% { opacity: 0.4; transform: scale(0.85); }
|
|
458
|
-
}
|
|
459
|
-
.header-desc {
|
|
460
|
-
font-size: 13px;
|
|
461
|
-
color: #94a3b8;
|
|
462
|
-
}
|
|
463
|
-
.content {
|
|
464
|
-
padding: 24px 28px;
|
|
465
|
-
}
|
|
466
|
-
.step-card {
|
|
467
|
-
background: #161f30;
|
|
468
|
-
border: 1px solid rgba(255, 255, 255, 0.06);
|
|
469
|
-
border-radius: 14px;
|
|
470
|
-
padding: 18px 20px;
|
|
471
|
-
margin-bottom: 18px;
|
|
472
|
-
}
|
|
473
|
-
.step-header {
|
|
474
|
-
display: flex;
|
|
475
|
-
align-items: center;
|
|
476
|
-
gap: 12px;
|
|
477
|
-
margin-bottom: 12px;
|
|
478
|
-
}
|
|
479
|
-
.step-badge {
|
|
480
|
-
width: 24px;
|
|
481
|
-
height: 24px;
|
|
482
|
-
background: #3b82f6;
|
|
483
|
-
color: #fff;
|
|
484
|
-
font-size: 12px;
|
|
485
|
-
font-weight: 700;
|
|
486
|
-
border-radius: 50%;
|
|
487
|
-
display: flex;
|
|
488
|
-
align-items: center;
|
|
489
|
-
justify-content: center;
|
|
490
|
-
flex-shrink: 0;
|
|
491
|
-
}
|
|
492
|
-
.step-title {
|
|
493
|
-
font-size: 15px;
|
|
494
|
-
font-weight: 600;
|
|
495
|
-
color: #f1f5f9;
|
|
496
|
-
}
|
|
497
|
-
.step-subtext {
|
|
498
|
-
font-size: 12px;
|
|
499
|
-
color: #64748b;
|
|
500
|
-
margin-left: auto;
|
|
501
|
-
}
|
|
502
|
-
.step-row {
|
|
503
|
-
display: flex;
|
|
504
|
-
align-items: center;
|
|
505
|
-
justify-content: space-between;
|
|
506
|
-
gap: 14px;
|
|
507
|
-
background: rgba(0, 0, 0, 0.2);
|
|
508
|
-
border: 1px solid rgba(255, 255, 255, 0.04);
|
|
509
|
-
padding: 12px 14px;
|
|
510
|
-
border-radius: 10px;
|
|
511
|
-
}
|
|
512
|
-
.step-row-text {
|
|
513
|
-
font-size: 13px;
|
|
514
|
-
color: #cbd5e1;
|
|
515
|
-
}
|
|
516
|
-
.btn-login {
|
|
517
|
-
background: #2563eb;
|
|
518
|
-
color: #ffffff;
|
|
519
|
-
text-decoration: none;
|
|
520
|
-
font-size: 13px;
|
|
521
|
-
font-weight: 600;
|
|
522
|
-
padding: 8px 16px;
|
|
523
|
-
border-radius: 8px;
|
|
524
|
-
display: inline-flex;
|
|
525
|
-
align-items: center;
|
|
526
|
-
gap: 6px;
|
|
527
|
-
white-space: nowrap;
|
|
528
|
-
transition: all 0.2s;
|
|
529
|
-
}
|
|
530
|
-
.btn-login:hover {
|
|
531
|
-
background: #1d4ed8;
|
|
532
|
-
transform: translateY(-1px);
|
|
533
|
-
}
|
|
534
|
-
.input-form {
|
|
535
|
-
display: flex;
|
|
536
|
-
gap: 10px;
|
|
537
|
-
}
|
|
538
|
-
.token-input {
|
|
539
|
-
flex: 1;
|
|
540
|
-
background: #0a0e17;
|
|
541
|
-
border: 1px solid #334155;
|
|
542
|
-
border-radius: 10px;
|
|
543
|
-
padding: 12px 14px;
|
|
544
|
-
color: #fff;
|
|
545
|
-
font-size: 13px;
|
|
546
|
-
outline: none;
|
|
547
|
-
transition: all 0.2s;
|
|
548
|
-
}
|
|
549
|
-
.token-input:focus {
|
|
550
|
-
border-color: #3b82f6;
|
|
551
|
-
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
|
552
|
-
}
|
|
553
|
-
.btn-submit {
|
|
554
|
-
background: #059669;
|
|
555
|
-
color: #ffffff;
|
|
556
|
-
border: none;
|
|
557
|
-
font-size: 13px;
|
|
558
|
-
font-weight: 600;
|
|
559
|
-
padding: 0 20px;
|
|
560
|
-
border-radius: 10px;
|
|
561
|
-
cursor: pointer;
|
|
562
|
-
white-space: nowrap;
|
|
563
|
-
transition: all 0.2s;
|
|
564
|
-
}
|
|
565
|
-
.btn-submit:hover {
|
|
566
|
-
background: #047857;
|
|
567
|
-
transform: translateY(-1px);
|
|
568
|
-
}
|
|
569
|
-
.assistant-card {
|
|
570
|
-
background: rgba(0, 0, 0, 0.2);
|
|
571
|
-
border: 1px dashed rgba(255, 255, 255, 0.1);
|
|
572
|
-
border-radius: 12px;
|
|
573
|
-
padding: 14px 16px;
|
|
574
|
-
margin-top: 14px;
|
|
575
|
-
}
|
|
576
|
-
.assistant-label {
|
|
577
|
-
font-size: 12px;
|
|
578
|
-
font-weight: 600;
|
|
579
|
-
color: #38bdf8;
|
|
580
|
-
margin-bottom: 6px;
|
|
581
|
-
display: flex;
|
|
582
|
-
align-items: center;
|
|
583
|
-
gap: 6px;
|
|
584
|
-
}
|
|
585
|
-
.assistant-desc {
|
|
586
|
-
font-size: 12px;
|
|
587
|
-
color: #94a3b8;
|
|
588
|
-
line-height: 1.5;
|
|
589
|
-
margin-bottom: 10px;
|
|
590
|
-
}
|
|
591
|
-
.copy-btn {
|
|
592
|
-
background: #1e293b;
|
|
593
|
-
color: #e2e8f0;
|
|
594
|
-
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
595
|
-
font-size: 12px;
|
|
596
|
-
font-weight: 600;
|
|
597
|
-
padding: 9px 14px;
|
|
598
|
-
border-radius: 8px;
|
|
599
|
-
cursor: pointer;
|
|
600
|
-
transition: all 0.2s;
|
|
601
|
-
width: 100%;
|
|
602
|
-
display: flex;
|
|
603
|
-
align-items: center;
|
|
604
|
-
justify-content: center;
|
|
605
|
-
gap: 6px;
|
|
606
|
-
}
|
|
607
|
-
.copy-btn:hover {
|
|
608
|
-
background: #334155;
|
|
609
|
-
border-color: rgba(255, 255, 255, 0.2);
|
|
610
|
-
}
|
|
611
|
-
.copy-btn.copied {
|
|
612
|
-
background: #059669;
|
|
613
|
-
color: #fff;
|
|
614
|
-
border-color: #059669;
|
|
615
|
-
}
|
|
616
|
-
.cancel-link {
|
|
617
|
-
color: #64748b;
|
|
618
|
-
font-size: 12px;
|
|
619
|
-
text-decoration: none;
|
|
620
|
-
padding: 6px 14px;
|
|
621
|
-
border-radius: 6px;
|
|
622
|
-
border: 1px solid rgba(255, 255, 255, 0.06);
|
|
623
|
-
display: inline-flex;
|
|
624
|
-
align-items: center;
|
|
625
|
-
gap: 4px;
|
|
626
|
-
transition: all 0.2s;
|
|
627
|
-
}
|
|
628
|
-
.cancel-link:hover {
|
|
629
|
-
color: #cbd5e1;
|
|
630
|
-
border-color: rgba(255, 255, 255, 0.2);
|
|
631
|
-
}
|
|
632
|
-
.toast {
|
|
633
|
-
position: fixed;
|
|
634
|
-
top: 24px;
|
|
635
|
-
left: 50%;
|
|
636
|
-
transform: translateX(-50%) translateY(-20px);
|
|
637
|
-
background: #1e293b;
|
|
638
|
-
color: #f8fafc;
|
|
639
|
-
border: 1px solid rgba(255, 255, 255, 0.15);
|
|
640
|
-
padding: 10px 20px;
|
|
641
|
-
border-radius: 30px;
|
|
642
|
-
font-size: 13px;
|
|
643
|
-
font-weight: 500;
|
|
644
|
-
box-shadow: 0 10px 30px rgba(0,0,0,0.5);
|
|
645
|
-
opacity: 0;
|
|
646
|
-
pointer-events: none;
|
|
647
|
-
transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
|
|
648
|
-
z-index: 9999;
|
|
649
|
-
display: flex;
|
|
650
|
-
align-items: center;
|
|
651
|
-
gap: 8px;
|
|
652
|
-
}
|
|
653
|
-
.toast.show {
|
|
654
|
-
opacity: 1;
|
|
655
|
-
transform: translateX(-50%) translateY(0);
|
|
656
|
-
}
|
|
657
|
-
</style>
|
|
658
|
-
</head>
|
|
659
|
-
<body>
|
|
660
|
-
<div class="wrapper">
|
|
661
|
-
<div class="header">
|
|
662
|
-
<div class="header-top">
|
|
663
|
-
<div class="brand">
|
|
664
|
-
<div class="brand-icon">⚡</div>
|
|
665
|
-
<div class="brand-title">Cursor-Switch 凭据同步助手</div>
|
|
666
|
-
</div>
|
|
667
|
-
<div class="status-pill">
|
|
668
|
-
<span class="status-dot"></span>
|
|
669
|
-
<span>终端等待接收中</span>
|
|
670
|
-
</div>
|
|
671
|
-
</div>
|
|
672
|
-
<p class="header-desc">只需简单两步,即可将浏览器中的 Cursor 登录凭据安全同步至本地终端:</p>
|
|
673
|
-
</div>
|
|
674
|
-
|
|
675
|
-
<div class="content">
|
|
676
|
-
<!-- 步骤 1 -->
|
|
677
|
-
<div class="step-card">
|
|
678
|
-
<div class="step-header">
|
|
679
|
-
<div class="step-badge">1</div>
|
|
680
|
-
<div class="step-title">确认浏览器已登录官网</div>
|
|
681
|
-
<div class="step-subtext">若已登录请直接看第 2 步</div>
|
|
682
|
-
</div>
|
|
683
|
-
<div class="step-row">
|
|
684
|
-
<div class="step-row-text">在当前浏览器中打开 Cursor 官网并完成账号登录</div>
|
|
685
|
-
<a href="https://cursor.com/login" target="_blank" class="btn-login">
|
|
686
|
-
<span>打开官网登录</span>
|
|
687
|
-
<span>↗</span>
|
|
688
|
-
</a>
|
|
689
|
-
</div>
|
|
690
|
-
</div>
|
|
691
|
-
|
|
692
|
-
<!-- 步骤 2 -->
|
|
693
|
-
<div class="step-card">
|
|
694
|
-
<div class="step-header">
|
|
695
|
-
<div class="step-badge">2</div>
|
|
696
|
-
<div class="step-title">同步 Token 凭据给终端</div>
|
|
697
|
-
<div class="step-subtext">直接输入即可</div>
|
|
698
|
-
</div>
|
|
699
|
-
|
|
700
|
-
<form method="GET" action="/" class="input-form">
|
|
701
|
-
<input type="text" name="token" class="token-input" placeholder="请在此粘贴 Token (支持 user_xxx:: 或 eyJ...)" required autofocus autocomplete="off" spellcheck="false" />
|
|
702
|
-
<button type="submit" class="btn-submit">立即同步 🚀</button>
|
|
703
|
-
</form>
|
|
704
|
-
|
|
705
|
-
<!-- 极客辅助:不想手动复制 -->
|
|
706
|
-
<div class="assistant-card">
|
|
707
|
-
<div class="assistant-label">💡 极客自动提取(不想手动找 Cookie?):</div>
|
|
708
|
-
<p class="assistant-desc">切到已登录的 cursor.com 网页,按 <b>F12</b> 打开控制台(Console)粘贴此代码回车,凭据将全自动秒传回终端:</p>
|
|
709
|
-
<button type="button" class="copy-btn" id="copyBtn" onclick="onCopyScript()">
|
|
710
|
-
📋 复制控制台一键抓取代码
|
|
711
|
-
</button>
|
|
712
|
-
</div>
|
|
713
|
-
</div>
|
|
714
|
-
|
|
715
|
-
<!-- 底部取消 -->
|
|
716
|
-
<div style="text-align: center; margin-top: 14px;">
|
|
717
|
-
<a href="/?action=cancel" class="cancel-link">
|
|
718
|
-
✕ 取消本次操作并返回终端
|
|
719
|
-
</a>
|
|
720
|
-
</div>
|
|
721
|
-
</div>
|
|
722
|
-
</div>
|
|
723
|
-
|
|
724
|
-
<div class="toast" id="toast"></div>
|
|
725
|
-
|
|
726
|
-
<script>
|
|
727
|
-
function showToast(msg, icon = '💡') {
|
|
728
|
-
const t = document.getElementById('toast');
|
|
729
|
-
t.innerHTML = '<span>' + icon + '</span><span>' + msg + '</span>';
|
|
730
|
-
t.classList.add('show');
|
|
731
|
-
setTimeout(() => { t.classList.remove('show'); }, 3500);
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
function onCopyScript() {
|
|
735
|
-
const code = "fetch('http://127.0.0.1:${portToTry}/?token=' + encodeURIComponent((document.cookie.match(/WorkosCursorSessionToken=([^;]+)/)||[,''])[1])).then(() => alert('🎉 凭据已成功同步回终端!请返回命令行查看。')).catch(() => alert('未找到登录 Cookie,请先在 cursor.com 登录!'));";
|
|
736
|
-
navigator.clipboard.writeText(code).then(() => {
|
|
737
|
-
const btn = document.getElementById('copyBtn');
|
|
738
|
-
btn.classList.add('copied');
|
|
739
|
-
btn.innerHTML = '✔ 代码已复制到剪贴板!';
|
|
740
|
-
showToast('代码已复制!请切到 cursor.com 网页按 F12 粘贴并回车即可。', '📋');
|
|
741
|
-
setTimeout(() => {
|
|
742
|
-
btn.classList.remove('copied');
|
|
743
|
-
btn.innerHTML = '📋 复制控制台一键抓取代码';
|
|
744
|
-
}, 3500);
|
|
745
|
-
}).catch(() => {
|
|
746
|
-
prompt('请手动复制以下代码:', code);
|
|
747
|
-
});
|
|
748
|
-
}
|
|
749
|
-
</script>
|
|
750
|
-
</body>
|
|
751
|
-
</html>
|
|
356
|
+
res.end(`
|
|
357
|
+
<!DOCTYPE html>
|
|
358
|
+
<html lang="zh-CN">
|
|
359
|
+
<head>
|
|
360
|
+
<meta charset="utf-8">
|
|
361
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
362
|
+
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
|
|
363
|
+
<meta http-equiv="Pragma" content="no-cache">
|
|
364
|
+
<meta http-equiv="Expires" content="0">
|
|
365
|
+
<title>Cursor-Switch 浏览器凭据同步助手</title>
|
|
366
|
+
<style>
|
|
367
|
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
368
|
+
body {
|
|
369
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
370
|
+
background: #080c14;
|
|
371
|
+
color: #e2e8f0;
|
|
372
|
+
min-height: 100vh;
|
|
373
|
+
display: flex;
|
|
374
|
+
align-items: center;
|
|
375
|
+
justify-content: center;
|
|
376
|
+
padding: 24px;
|
|
377
|
+
line-height: 1.5;
|
|
378
|
+
}
|
|
379
|
+
.wrapper {
|
|
380
|
+
max-width: 540px;
|
|
381
|
+
width: 100%;
|
|
382
|
+
background: #111827;
|
|
383
|
+
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
384
|
+
border-radius: 20px;
|
|
385
|
+
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
|
|
386
|
+
overflow: hidden;
|
|
387
|
+
}
|
|
388
|
+
.header {
|
|
389
|
+
padding: 24px 28px 20px;
|
|
390
|
+
background: linear-gradient(180deg, rgba(30, 41, 59, 0.4) 0%, rgba(17, 24, 39, 0) 100%);
|
|
391
|
+
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
|
|
392
|
+
}
|
|
393
|
+
.header-top {
|
|
394
|
+
display: flex;
|
|
395
|
+
align-items: center;
|
|
396
|
+
justify-content: space-between;
|
|
397
|
+
margin-bottom: 8px;
|
|
398
|
+
}
|
|
399
|
+
.brand {
|
|
400
|
+
display: flex;
|
|
401
|
+
align-items: center;
|
|
402
|
+
gap: 10px;
|
|
403
|
+
}
|
|
404
|
+
.brand-icon {
|
|
405
|
+
width: 32px;
|
|
406
|
+
height: 32px;
|
|
407
|
+
background: linear-gradient(135deg, #0ea5e9 0%, #3b82f6 100%);
|
|
408
|
+
border-radius: 9px;
|
|
409
|
+
display: flex;
|
|
410
|
+
align-items: center;
|
|
411
|
+
justify-content: center;
|
|
412
|
+
font-size: 18px;
|
|
413
|
+
box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
|
|
414
|
+
}
|
|
415
|
+
.brand-title {
|
|
416
|
+
font-size: 18px;
|
|
417
|
+
font-weight: 700;
|
|
418
|
+
color: #ffffff;
|
|
419
|
+
}
|
|
420
|
+
.status-pill {
|
|
421
|
+
display: flex;
|
|
422
|
+
align-items: center;
|
|
423
|
+
gap: 6px;
|
|
424
|
+
background: rgba(16, 185, 129, 0.12);
|
|
425
|
+
border: 1px solid rgba(16, 185, 129, 0.3);
|
|
426
|
+
color: #34d399;
|
|
427
|
+
font-size: 12px;
|
|
428
|
+
font-weight: 500;
|
|
429
|
+
padding: 4px 10px;
|
|
430
|
+
border-radius: 9999px;
|
|
431
|
+
}
|
|
432
|
+
.status-dot {
|
|
433
|
+
width: 7px;
|
|
434
|
+
height: 7px;
|
|
435
|
+
background: #10b981;
|
|
436
|
+
border-radius: 50%;
|
|
437
|
+
box-shadow: 0 0 8px #10b981;
|
|
438
|
+
animation: pulse 2s infinite;
|
|
439
|
+
}
|
|
440
|
+
@keyframes pulse {
|
|
441
|
+
0%, 100% { opacity: 1; transform: scale(1); }
|
|
442
|
+
50% { opacity: 0.4; transform: scale(0.85); }
|
|
443
|
+
}
|
|
444
|
+
.header-desc {
|
|
445
|
+
font-size: 13px;
|
|
446
|
+
color: #94a3b8;
|
|
447
|
+
}
|
|
448
|
+
.content {
|
|
449
|
+
padding: 24px 28px;
|
|
450
|
+
}
|
|
451
|
+
.step-card {
|
|
452
|
+
background: #161f30;
|
|
453
|
+
border: 1px solid rgba(255, 255, 255, 0.06);
|
|
454
|
+
border-radius: 14px;
|
|
455
|
+
padding: 18px 20px;
|
|
456
|
+
margin-bottom: 18px;
|
|
457
|
+
}
|
|
458
|
+
.step-header {
|
|
459
|
+
display: flex;
|
|
460
|
+
align-items: center;
|
|
461
|
+
gap: 12px;
|
|
462
|
+
margin-bottom: 12px;
|
|
463
|
+
}
|
|
464
|
+
.step-badge {
|
|
465
|
+
width: 24px;
|
|
466
|
+
height: 24px;
|
|
467
|
+
background: #3b82f6;
|
|
468
|
+
color: #fff;
|
|
469
|
+
font-size: 12px;
|
|
470
|
+
font-weight: 700;
|
|
471
|
+
border-radius: 50%;
|
|
472
|
+
display: flex;
|
|
473
|
+
align-items: center;
|
|
474
|
+
justify-content: center;
|
|
475
|
+
flex-shrink: 0;
|
|
476
|
+
}
|
|
477
|
+
.step-title {
|
|
478
|
+
font-size: 15px;
|
|
479
|
+
font-weight: 600;
|
|
480
|
+
color: #f1f5f9;
|
|
481
|
+
}
|
|
482
|
+
.step-subtext {
|
|
483
|
+
font-size: 12px;
|
|
484
|
+
color: #64748b;
|
|
485
|
+
margin-left: auto;
|
|
486
|
+
}
|
|
487
|
+
.step-row {
|
|
488
|
+
display: flex;
|
|
489
|
+
align-items: center;
|
|
490
|
+
justify-content: space-between;
|
|
491
|
+
gap: 14px;
|
|
492
|
+
background: rgba(0, 0, 0, 0.2);
|
|
493
|
+
border: 1px solid rgba(255, 255, 255, 0.04);
|
|
494
|
+
padding: 12px 14px;
|
|
495
|
+
border-radius: 10px;
|
|
496
|
+
}
|
|
497
|
+
.step-row-text {
|
|
498
|
+
font-size: 13px;
|
|
499
|
+
color: #cbd5e1;
|
|
500
|
+
}
|
|
501
|
+
.btn-login {
|
|
502
|
+
background: #2563eb;
|
|
503
|
+
color: #ffffff;
|
|
504
|
+
text-decoration: none;
|
|
505
|
+
font-size: 13px;
|
|
506
|
+
font-weight: 600;
|
|
507
|
+
padding: 8px 16px;
|
|
508
|
+
border-radius: 8px;
|
|
509
|
+
display: inline-flex;
|
|
510
|
+
align-items: center;
|
|
511
|
+
gap: 6px;
|
|
512
|
+
white-space: nowrap;
|
|
513
|
+
transition: all 0.2s;
|
|
514
|
+
}
|
|
515
|
+
.btn-login:hover {
|
|
516
|
+
background: #1d4ed8;
|
|
517
|
+
transform: translateY(-1px);
|
|
518
|
+
}
|
|
519
|
+
.input-form {
|
|
520
|
+
display: flex;
|
|
521
|
+
gap: 10px;
|
|
522
|
+
}
|
|
523
|
+
.token-input {
|
|
524
|
+
flex: 1;
|
|
525
|
+
background: #0a0e17;
|
|
526
|
+
border: 1px solid #334155;
|
|
527
|
+
border-radius: 10px;
|
|
528
|
+
padding: 12px 14px;
|
|
529
|
+
color: #fff;
|
|
530
|
+
font-size: 13px;
|
|
531
|
+
outline: none;
|
|
532
|
+
transition: all 0.2s;
|
|
533
|
+
}
|
|
534
|
+
.token-input:focus {
|
|
535
|
+
border-color: #3b82f6;
|
|
536
|
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
|
537
|
+
}
|
|
538
|
+
.btn-submit {
|
|
539
|
+
background: #059669;
|
|
540
|
+
color: #ffffff;
|
|
541
|
+
border: none;
|
|
542
|
+
font-size: 13px;
|
|
543
|
+
font-weight: 600;
|
|
544
|
+
padding: 0 20px;
|
|
545
|
+
border-radius: 10px;
|
|
546
|
+
cursor: pointer;
|
|
547
|
+
white-space: nowrap;
|
|
548
|
+
transition: all 0.2s;
|
|
549
|
+
}
|
|
550
|
+
.btn-submit:hover {
|
|
551
|
+
background: #047857;
|
|
552
|
+
transform: translateY(-1px);
|
|
553
|
+
}
|
|
554
|
+
.assistant-card {
|
|
555
|
+
background: rgba(0, 0, 0, 0.2);
|
|
556
|
+
border: 1px dashed rgba(255, 255, 255, 0.1);
|
|
557
|
+
border-radius: 12px;
|
|
558
|
+
padding: 14px 16px;
|
|
559
|
+
margin-top: 14px;
|
|
560
|
+
}
|
|
561
|
+
.assistant-label {
|
|
562
|
+
font-size: 12px;
|
|
563
|
+
font-weight: 600;
|
|
564
|
+
color: #38bdf8;
|
|
565
|
+
margin-bottom: 6px;
|
|
566
|
+
display: flex;
|
|
567
|
+
align-items: center;
|
|
568
|
+
gap: 6px;
|
|
569
|
+
}
|
|
570
|
+
.assistant-desc {
|
|
571
|
+
font-size: 12px;
|
|
572
|
+
color: #94a3b8;
|
|
573
|
+
line-height: 1.5;
|
|
574
|
+
margin-bottom: 10px;
|
|
575
|
+
}
|
|
576
|
+
.copy-btn {
|
|
577
|
+
background: #1e293b;
|
|
578
|
+
color: #e2e8f0;
|
|
579
|
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
580
|
+
font-size: 12px;
|
|
581
|
+
font-weight: 600;
|
|
582
|
+
padding: 9px 14px;
|
|
583
|
+
border-radius: 8px;
|
|
584
|
+
cursor: pointer;
|
|
585
|
+
transition: all 0.2s;
|
|
586
|
+
width: 100%;
|
|
587
|
+
display: flex;
|
|
588
|
+
align-items: center;
|
|
589
|
+
justify-content: center;
|
|
590
|
+
gap: 6px;
|
|
591
|
+
}
|
|
592
|
+
.copy-btn:hover {
|
|
593
|
+
background: #334155;
|
|
594
|
+
border-color: rgba(255, 255, 255, 0.2);
|
|
595
|
+
}
|
|
596
|
+
.copy-btn.copied {
|
|
597
|
+
background: #059669;
|
|
598
|
+
color: #fff;
|
|
599
|
+
border-color: #059669;
|
|
600
|
+
}
|
|
601
|
+
.cancel-link {
|
|
602
|
+
color: #64748b;
|
|
603
|
+
font-size: 12px;
|
|
604
|
+
text-decoration: none;
|
|
605
|
+
padding: 6px 14px;
|
|
606
|
+
border-radius: 6px;
|
|
607
|
+
border: 1px solid rgba(255, 255, 255, 0.06);
|
|
608
|
+
display: inline-flex;
|
|
609
|
+
align-items: center;
|
|
610
|
+
gap: 4px;
|
|
611
|
+
transition: all 0.2s;
|
|
612
|
+
}
|
|
613
|
+
.cancel-link:hover {
|
|
614
|
+
color: #cbd5e1;
|
|
615
|
+
border-color: rgba(255, 255, 255, 0.2);
|
|
616
|
+
}
|
|
617
|
+
.toast {
|
|
618
|
+
position: fixed;
|
|
619
|
+
top: 24px;
|
|
620
|
+
left: 50%;
|
|
621
|
+
transform: translateX(-50%) translateY(-20px);
|
|
622
|
+
background: #1e293b;
|
|
623
|
+
color: #f8fafc;
|
|
624
|
+
border: 1px solid rgba(255, 255, 255, 0.15);
|
|
625
|
+
padding: 10px 20px;
|
|
626
|
+
border-radius: 30px;
|
|
627
|
+
font-size: 13px;
|
|
628
|
+
font-weight: 500;
|
|
629
|
+
box-shadow: 0 10px 30px rgba(0,0,0,0.5);
|
|
630
|
+
opacity: 0;
|
|
631
|
+
pointer-events: none;
|
|
632
|
+
transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
|
|
633
|
+
z-index: 9999;
|
|
634
|
+
display: flex;
|
|
635
|
+
align-items: center;
|
|
636
|
+
gap: 8px;
|
|
637
|
+
}
|
|
638
|
+
.toast.show {
|
|
639
|
+
opacity: 1;
|
|
640
|
+
transform: translateX(-50%) translateY(0);
|
|
641
|
+
}
|
|
642
|
+
</style>
|
|
643
|
+
</head>
|
|
644
|
+
<body>
|
|
645
|
+
<div class="wrapper">
|
|
646
|
+
<div class="header">
|
|
647
|
+
<div class="header-top">
|
|
648
|
+
<div class="brand">
|
|
649
|
+
<div class="brand-icon">⚡</div>
|
|
650
|
+
<div class="brand-title">Cursor-Switch 凭据同步助手</div>
|
|
651
|
+
</div>
|
|
652
|
+
<div class="status-pill">
|
|
653
|
+
<span class="status-dot"></span>
|
|
654
|
+
<span>终端等待接收中</span>
|
|
655
|
+
</div>
|
|
656
|
+
</div>
|
|
657
|
+
<p class="header-desc">只需简单两步,即可将浏览器中的 Cursor 登录凭据安全同步至本地终端:</p>
|
|
658
|
+
</div>
|
|
659
|
+
|
|
660
|
+
<div class="content">
|
|
661
|
+
<!-- 步骤 1 -->
|
|
662
|
+
<div class="step-card">
|
|
663
|
+
<div class="step-header">
|
|
664
|
+
<div class="step-badge">1</div>
|
|
665
|
+
<div class="step-title">确认浏览器已登录官网</div>
|
|
666
|
+
<div class="step-subtext">若已登录请直接看第 2 步</div>
|
|
667
|
+
</div>
|
|
668
|
+
<div class="step-row">
|
|
669
|
+
<div class="step-row-text">在当前浏览器中打开 Cursor 官网并完成账号登录</div>
|
|
670
|
+
<a href="https://cursor.com/login" target="_blank" class="btn-login">
|
|
671
|
+
<span>打开官网登录</span>
|
|
672
|
+
<span>↗</span>
|
|
673
|
+
</a>
|
|
674
|
+
</div>
|
|
675
|
+
</div>
|
|
676
|
+
|
|
677
|
+
<!-- 步骤 2 -->
|
|
678
|
+
<div class="step-card">
|
|
679
|
+
<div class="step-header">
|
|
680
|
+
<div class="step-badge">2</div>
|
|
681
|
+
<div class="step-title">同步 Token 凭据给终端</div>
|
|
682
|
+
<div class="step-subtext">直接输入即可</div>
|
|
683
|
+
</div>
|
|
684
|
+
|
|
685
|
+
<form method="GET" action="/" class="input-form">
|
|
686
|
+
<input type="text" name="token" class="token-input" placeholder="请在此粘贴 Token (支持 user_xxx:: 或 eyJ...)" required autofocus autocomplete="off" spellcheck="false" />
|
|
687
|
+
<button type="submit" class="btn-submit">立即同步 🚀</button>
|
|
688
|
+
</form>
|
|
689
|
+
|
|
690
|
+
<!-- 极客辅助:不想手动复制 -->
|
|
691
|
+
<div class="assistant-card">
|
|
692
|
+
<div class="assistant-label">💡 极客自动提取(不想手动找 Cookie?):</div>
|
|
693
|
+
<p class="assistant-desc">切到已登录的 cursor.com 网页,按 <b>F12</b> 打开控制台(Console)粘贴此代码回车,凭据将全自动秒传回终端:</p>
|
|
694
|
+
<button type="button" class="copy-btn" id="copyBtn" onclick="onCopyScript()">
|
|
695
|
+
📋 复制控制台一键抓取代码
|
|
696
|
+
</button>
|
|
697
|
+
</div>
|
|
698
|
+
</div>
|
|
699
|
+
|
|
700
|
+
<!-- 底部取消 -->
|
|
701
|
+
<div style="text-align: center; margin-top: 14px;">
|
|
702
|
+
<a href="/?action=cancel" class="cancel-link">
|
|
703
|
+
✕ 取消本次操作并返回终端
|
|
704
|
+
</a>
|
|
705
|
+
</div>
|
|
706
|
+
</div>
|
|
707
|
+
</div>
|
|
708
|
+
|
|
709
|
+
<div class="toast" id="toast"></div>
|
|
710
|
+
|
|
711
|
+
<script>
|
|
712
|
+
function showToast(msg, icon = '💡') {
|
|
713
|
+
const t = document.getElementById('toast');
|
|
714
|
+
t.innerHTML = '<span>' + icon + '</span><span>' + msg + '</span>';
|
|
715
|
+
t.classList.add('show');
|
|
716
|
+
setTimeout(() => { t.classList.remove('show'); }, 3500);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
function onCopyScript() {
|
|
720
|
+
const code = "fetch('http://127.0.0.1:${portToTry}/?token=' + encodeURIComponent((document.cookie.match(/WorkosCursorSessionToken=([^;]+)/)||[,''])[1])).then(() => alert('🎉 凭据已成功同步回终端!请返回命令行查看。')).catch(() => alert('未找到登录 Cookie,请先在 cursor.com 登录!'));";
|
|
721
|
+
navigator.clipboard.writeText(code).then(() => {
|
|
722
|
+
const btn = document.getElementById('copyBtn');
|
|
723
|
+
btn.classList.add('copied');
|
|
724
|
+
btn.innerHTML = '✔ 代码已复制到剪贴板!';
|
|
725
|
+
showToast('代码已复制!请切到 cursor.com 网页按 F12 粘贴并回车即可。', '📋');
|
|
726
|
+
setTimeout(() => {
|
|
727
|
+
btn.classList.remove('copied');
|
|
728
|
+
btn.innerHTML = '📋 复制控制台一键抓取代码';
|
|
729
|
+
}, 3500);
|
|
730
|
+
}).catch(() => {
|
|
731
|
+
prompt('请手动复制以下代码:', code);
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
</script>
|
|
735
|
+
</body>
|
|
736
|
+
</html>
|
|
752
737
|
`);
|
|
753
738
|
});
|
|
754
739
|
server.on('error', (err) => {
|
|
@@ -774,7 +759,6 @@ export class OAuthReceiver {
|
|
|
774
759
|
console.log(chalk.grey('已尝试调起系统默认浏览器。若未自动弹出,可在任意浏览器访问下方地址:'));
|
|
775
760
|
console.log(chalk.bold.yellow(`👉 ${helperUrl}\n`));
|
|
776
761
|
console.log(chalk.dim(' 💡 提示: 在终端随时按 [Esc]、[q]、[0] 或 [回车] 即可立即停止监听并返回\n'));
|
|
777
|
-
// 终端单键即时监听,支持 Esc, q, Enter, 0
|
|
778
762
|
if (process.stdin.isTTY) {
|
|
779
763
|
readline.emitKeypressEvents(process.stdin);
|
|
780
764
|
const wasRaw = process.stdin.isRaw;
|
|
@@ -824,10 +808,8 @@ export class OAuthReceiver {
|
|
|
824
808
|
process.stdout.write('\x1b[?25h');
|
|
825
809
|
};
|
|
826
810
|
}
|
|
827
|
-
// 调起系统默认浏览器访问本地认证助手页
|
|
828
811
|
await openBrowserUrl(helperUrl);
|
|
829
812
|
});
|
|
830
|
-
// 5 分钟超时保护
|
|
831
813
|
setTimeout(() => {
|
|
832
814
|
cleanupStdin();
|
|
833
815
|
if (!isResolved) {
|