omp-multi-auth 1.1.1 → 1.3.0
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 +4 -3
- package/extensions/lib/providers.ts +69 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -77,7 +77,7 @@ Create `.omp/multi-auth.json` in a project to restrict which subscription provid
|
|
|
77
77
|
| `google-antigravity` | Antigravity |
|
|
78
78
|
| `kimi-code` | Kimi Code |
|
|
79
79
|
| `xai-oauth` | xAI Grok OAuth |
|
|
80
|
-
|
|
80
|
+
| `cursor` | Cursor (browser PKCE OAuth or API key) |
|
|
81
81
|
### API key
|
|
82
82
|
|
|
83
83
|
| Provider | Service |
|
|
@@ -96,12 +96,13 @@ Create `.omp/multi-auth.json` in a project to restrict which subscription provid
|
|
|
96
96
|
| `zai` | Z.AI (GLM) |
|
|
97
97
|
| `minimax` | MiniMax (Global) |
|
|
98
98
|
| `minimax-cn` | MiniMax (China) |
|
|
99
|
+
| `cursor` | Cursor (dashboard API key `crsr_...` / `cursor_...` or browser sign-in) |
|
|
99
100
|
|
|
100
101
|
API-key providers support full multi-account operation. Add an account with `/multi-auth add`, select the provider, then authenticate via `/multi-auth login` (or `/login <name>`) and paste your API key when prompted. Each account stores its own key independently in OMP auth storage.
|
|
101
102
|
|
|
102
|
-
|
|
103
|
+
For `cursor`, `/multi-auth login` prompts for a dashboard API key (`crsr_...`/`cursor_...`). Submit a key to use token exchange, or leave it blank to sign in via browser PKCE OAuth. Both methods refresh automatically.
|
|
103
104
|
|
|
104
|
-
## Built-in
|
|
105
|
+
## Built-in quotas
|
|
105
106
|
|
|
106
107
|
Run `/multi-auth limits` to inspect quota and usage information for supported providers. This currently includes built-in quota checks for Codex and Google providers. Results depend on provider availability and authenticated account state.
|
|
107
108
|
|
|
@@ -88,6 +88,68 @@ export function buildApiKeyOAuth(displayName: string, index: number, placeholder
|
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
const CURSOR_EXCHANGE_URL = "https://api2.cursor.sh/auth/exchange_user_api_key";
|
|
92
|
+
|
|
93
|
+
function cursorJwtExpiryMs(jwt: string): number {
|
|
94
|
+
const fallback = Date.now() + 55 * 60 * 1000;
|
|
95
|
+
const parts = jwt.split(".");
|
|
96
|
+
if (parts.length !== 3) return fallback;
|
|
97
|
+
try {
|
|
98
|
+
const payload = JSON.parse(atob(parts[1].replace(/-/g, "+").replace(/_/g, "/"))) as { exp?: number };
|
|
99
|
+
return typeof payload.exp === "number" ? payload.exp * 1000 : fallback;
|
|
100
|
+
} catch {
|
|
101
|
+
return fallback;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async function exchangeCursorApiKey(apiKey: string, signal?: AbortSignal): Promise<OAuthCredentials> {
|
|
106
|
+
const resp = await fetch(CURSOR_EXCHANGE_URL, {
|
|
107
|
+
method: "POST",
|
|
108
|
+
headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
|
|
109
|
+
body: "{}",
|
|
110
|
+
signal,
|
|
111
|
+
});
|
|
112
|
+
if (!resp.ok) {
|
|
113
|
+
const text = await resp.text().catch(() => "");
|
|
114
|
+
throw new Error(`Cursor API key exchange failed (${resp.status}): ${text || resp.statusText}`);
|
|
115
|
+
}
|
|
116
|
+
const data = (await resp.json()) as { accessToken?: string };
|
|
117
|
+
if (!data.accessToken) throw new Error("Cursor API key exchange returned no accessToken");
|
|
118
|
+
return { access: data.accessToken, refresh: apiKey, expires: cursorJwtExpiryMs(data.accessToken) };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const CURSOR_API_KEY_PREFIXES = ["crsr_", "cursor_"];
|
|
122
|
+
|
|
123
|
+
export function buildCursorOAuth(index: number): ProviderOAuth {
|
|
124
|
+
const definition = requireOAuthDefinition("cursor");
|
|
125
|
+
return {
|
|
126
|
+
name: `Cursor #${index}`,
|
|
127
|
+
async login(callbacks: OAuthLoginCallbacks): Promise<OAuthCredentials> {
|
|
128
|
+
const apiKey = (await callbacks.onPrompt({
|
|
129
|
+
message: "Paste your Cursor API key (crsr_...), or leave blank to sign in with your browser:",
|
|
130
|
+
placeholder: "crsr_... (blank = browser sign-in)",
|
|
131
|
+
allowEmpty: true,
|
|
132
|
+
})).trim();
|
|
133
|
+
if (apiKey) return exchangeCursorApiKey(apiKey, callbacks.signal);
|
|
134
|
+
const credentials = await definition.login(callbacks);
|
|
135
|
+
if (typeof credentials === "string") {
|
|
136
|
+
throw new Error(`Cursor #${index} browser login did not return renewable credentials`);
|
|
137
|
+
}
|
|
138
|
+
return credentials;
|
|
139
|
+
},
|
|
140
|
+
async refreshToken(credentials: OAuthCredentials, signal?: AbortSignal): Promise<OAuthCredentials> {
|
|
141
|
+
const refresh = credentials.refresh || credentials.access;
|
|
142
|
+
if (CURSOR_API_KEY_PREFIXES.some((prefix) => refresh.startsWith(prefix))) {
|
|
143
|
+
return exchangeCursorApiKey(refresh, signal);
|
|
144
|
+
}
|
|
145
|
+
return definition.refreshToken(credentials, signal);
|
|
146
|
+
},
|
|
147
|
+
getApiKey(credentials: OAuthCredentials): string {
|
|
148
|
+
return credentials.access;
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
91
153
|
|
|
92
154
|
|
|
93
155
|
// GitHub Copilot base URL derivation, ported from the pi-ai OAuth flow
|
|
@@ -319,6 +381,13 @@ export const PROVIDER_TEMPLATES: Record<string, ProviderTemplate> = {
|
|
|
319
381
|
},
|
|
320
382
|
},
|
|
321
383
|
|
|
384
|
+
cursor: {
|
|
385
|
+
displayName: "Cursor",
|
|
386
|
+
buildOAuth(index: number) {
|
|
387
|
+
return buildCursorOAuth(index);
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
|
|
322
391
|
};
|
|
323
392
|
|
|
324
393
|
for (const spec of API_KEY_PROVIDERS) {
|
package/package.json
CHANGED