cursor-switch 1.0.6 → 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 (84) 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 -225
  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 +2 -22
  15. package/dist/core/dashboard-launcher.js +10 -60
  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 -27
  29. package/dist/core/outlook-launcher.js +235 -261
  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 +64 -28
  33. package/dist/core/pure-login-service.js +527 -346
  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 -538
  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
@@ -1,14 +1,3 @@
1
- /**
2
- * Cursor 官方接口直连服务 (Official API Only)
3
- * 优先直连 Cursor 官方原生核心端点:
4
- * 1. 订阅与身份: https://api2.cursor.sh/auth/full_stripe_profile
5
- * 2. 用量与计费周期: https://api2.cursor.sh/aiserver.v1.DashboardService/GetCurrentPeriodUsage
6
- * 3. 降级备用: https://www.cursor.com/api/usage
7
- * 绝不经过任何第三方代理,原生支持官方全档位专业解析:
8
- * • Ultra 尊享版 / Pro+ 进阶版 / Pro 专业版
9
- * • Team 团队商业版 (Self-Serve / Enterprise) / Enterprise 企业定制版
10
- * • Student 教育学生版 / Pro 试用版 / Free 免费体验版 / 欠费逾期 / 凭据失效
11
- */
12
1
  import type { CurrentPeriodUsage } from '../types.js';
13
2
  export interface FetchUsageResult {
14
3
  success: boolean;
@@ -18,12 +7,6 @@ export interface FetchUsageResult {
18
7
  message?: string;
19
8
  }
20
9
  export declare class OfficialApiClient {
21
- /**
22
- * 直连 Cursor 官方 API 查询当前账号的最新用量与账单周期
23
- */
24
10
  static fetchUsage(token: string): Promise<FetchUsageResult>;
25
- /**
26
- * 直连 Cursor 官方 RPC 服务查询当前 Token 对应的真实绑定邮箱
27
- */
28
11
  static fetchEmail(token: string): Promise<string | null>;
29
12
  }
@@ -1,23 +1,10 @@
1
- /**
2
- * Cursor 官方接口直连服务 (Official API Only)
3
- * 优先直连 Cursor 官方原生核心端点:
4
- * 1. 订阅与身份: https://api2.cursor.sh/auth/full_stripe_profile
5
- * 2. 用量与计费周期: https://api2.cursor.sh/aiserver.v1.DashboardService/GetCurrentPeriodUsage
6
- * 3. 降级备用: https://www.cursor.com/api/usage
7
- * 绝不经过任何第三方代理,原生支持官方全档位专业解析:
8
- * • Ultra 尊享版 / Pro+ 进阶版 / Pro 专业版
9
- * • Team 团队商业版 (Self-Serve / Enterprise) / Enterprise 企业定制版
10
- * • Student 教育学生版 / Pro 试用版 / Free 免费体验版 / 欠费逾期 / 凭据失效
11
- */
1
+ import { ensureGlobalProxy, formatNetworkError } from '../utils/proxy-bootstrap.js';
12
2
  export class OfficialApiClient {
13
- /**
14
- * 直连 Cursor 官方 API 查询当前账号的最新用量与账单周期
15
- */
16
3
  static async fetchUsage(token) {
4
+ ensureGlobalProxy();
17
5
  const rawToken = token.trim();
18
6
  const cleanToken = rawToken.includes('::') ? rawToken.split('::').pop() : rawToken;
19
7
  try {
20
- // 1. 优先直连 Cursor 原生核心服务集群 (api2.cursor.sh)
21
8
  const [profileRes, usageRpcRes] = await Promise.allSettled([
22
9
  fetch('https://api2.cursor.sh/auth/full_stripe_profile', {
23
10
  method: 'GET',
@@ -57,15 +44,12 @@ export class OfficialApiClient {
57
44
  const teamMembershipType = profData?.teamMembershipType;
58
45
  const isStudent = profData?.isOnStudentPlan || profData?.verifiedStudent;
59
46
  const subscription = profData?.subscription;
60
- // 1. Team 优先判断
61
47
  if (isTeamMember || teamMembershipType) {
62
48
  subscriptionType = teamMembershipType ? `team:${teamMembershipType}` : 'team';
63
49
  }
64
- // 2. 认证学生优惠身份优先
65
50
  else if (isStudent) {
66
51
  subscriptionType = 'student';
67
52
  }
68
- // 3. 个人订阅档位细分:Ultra / Pro+ / Pro / Enterprise / Free
69
53
  else {
70
54
  const rawTier = (profData?.membershipType ||
71
55
  profData?.individualMembershipType ||
@@ -125,7 +109,6 @@ export class OfficialApiClient {
125
109
  trialDaysRemaining,
126
110
  };
127
111
  }
128
- // 2. 降级备用:尝试访问 web 端点 https://www.cursor.com/api/usage
129
112
  const fallbackRes = await fetch('https://www.cursor.com/api/usage', {
130
113
  method: 'GET',
131
114
  headers: {
@@ -170,14 +153,12 @@ export class OfficialApiClient {
170
153
  catch (err) {
171
154
  return {
172
155
  success: false,
173
- message: `网络连接异常: ${err.message}`,
156
+ message: `网络连接异常: ${formatNetworkError(err)}`,
174
157
  };
175
158
  }
176
159
  }
177
- /**
178
- * 直连 Cursor 官方 RPC 服务查询当前 Token 对应的真实绑定邮箱
179
- */
180
160
  static async fetchEmail(token) {
161
+ ensureGlobalProxy();
181
162
  const rawToken = token.trim();
182
163
  const cleanToken = rawToken.includes('::') ? rawToken.split('::').pop() : rawToken;
183
164
  try {
@@ -1,9 +1,3 @@
1
- /**
2
- * Outlook / 微软邮箱独立浏览器实例自动登录与安全交接引擎
3
- * 支持 Windows / macOS / Linux / WSL 全平台多浏览器 (Chrome / Edge / Brave / Chromium)
4
- * 采用 Detached 独立进程常驻 + 原生零依赖 CDP 会话控制
5
- * 遇到辅助邮箱验证、两步验证、安全代码、密码错误时自动优雅停下交接给用户
6
- */
7
1
  import { CdpEngine } from './cdp-engine.js';
8
2
  export interface MailboxOpenOptions {
9
3
  email: string;
@@ -24,31 +18,10 @@ export interface MailboxOpenResult {
24
18
  message: string;
25
19
  }
26
20
  export declare class OutlookLauncher {
27
- /**
28
- * 生成专属隔离的 Outlook 浏览器 Profile 目录
29
- * 使得同一个邮箱的 Cookie 与登录态长期有效,下一次打开直接秒进收件箱
30
- */
31
21
  static getOutlookProfileDir(email: string): string;
32
- /**
33
- * 构造微软官方带预填参数的直接登录 URL
34
- * 传入 login_hint 与 username 可跳过微软官网首页引导,直达该账号的密码验证页
35
- */
36
22
  static getOutlookLoginUrl(email: string): string;
37
- /**
38
- * 调起全新独立浏览器实例并执行 Outlook 自动化登录
39
- */
40
23
  static openMailbox(options: MailboxOpenOptions): Promise<MailboxOpenResult>;
41
- /**
42
- * 优先尝试点击页面上的“使用密码 / 改用密码 / 密码登录 / Use your password / 使用其他方式”入口
43
- * 采用原生 CDP 屏幕坐标模拟真实用户点击,彻底击穿各类前端框架 (Fluent UI / React) 遮挡与事件委托限制
44
- */
45
24
  private static tryClickUsePassword;
46
- /**
47
- * 格式化打印操作结果卡片
48
- */
49
25
  static printResultCard(result: MailboxOpenResult): void;
50
- /**
51
- * 在已到达 Outlook 收件箱页面时,利用 CDP 实时嗅探 Cursor / WorkOS 最新的 6 位数字验证码
52
- */
53
26
  static sniffVerificationCode(cdp: CdpEngine, timeoutMs?: number): Promise<string | null>;
54
27
  }