@magpie-community/opencode-cursor-auth 0.1.1 → 0.1.2
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/index.mjs +7 -6
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -268,7 +268,7 @@ async function browserSignIn() {
|
|
|
268
268
|
try {
|
|
269
269
|
res = await fetch(`${API}/auth/poll?uuid=${uuid}&verifier=${verifier}`, { headers, signal: AbortSignal.timeout(15_000) })
|
|
270
270
|
} catch {
|
|
271
|
-
if (++errors >= 3) return { type: "failed" }
|
|
271
|
+
if (++errors >= 3) return { type: "failed", error: "couldn't reach Cursor" }
|
|
272
272
|
await sleep(wait)
|
|
273
273
|
continue
|
|
274
274
|
}
|
|
@@ -278,12 +278,12 @@ async function browserSignIn() {
|
|
|
278
278
|
continue
|
|
279
279
|
}
|
|
280
280
|
if (!res.ok) {
|
|
281
|
-
if (res.status === 403 || ++errors >= 3) return { type: "failed" }
|
|
281
|
+
if (res.status === 403 || ++errors >= 3) return { type: "failed", error: res.status === 403 ? "Cursor refused the sign-in (403)" : `Cursor's sign-in answered HTTP ${res.status}` }
|
|
282
282
|
await sleep(wait)
|
|
283
283
|
continue
|
|
284
284
|
}
|
|
285
285
|
const j = await res.json().catch(() => null)
|
|
286
|
-
if (!j?.accessToken || !("refreshToken" in j)) return { type: "failed" }
|
|
286
|
+
if (!j?.accessToken || !("refreshToken" in j)) return { type: "failed", error: "Cursor sent back no token" }
|
|
287
287
|
const who = await whoIs(j.accessToken)
|
|
288
288
|
return {
|
|
289
289
|
type: "success",
|
|
@@ -294,7 +294,7 @@ async function browserSignIn() {
|
|
|
294
294
|
...(who.plan ? { plan: who.plan } : {}),
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
|
-
return { type: "failed" }
|
|
297
|
+
return { type: "failed", error: "the sign-in timed out" }
|
|
298
298
|
},
|
|
299
299
|
}
|
|
300
300
|
}
|
|
@@ -309,9 +309,10 @@ async function cliSignIn() {
|
|
|
309
309
|
async callback() {
|
|
310
310
|
const tok = await cliToken()
|
|
311
311
|
const exp = expiry(tok)
|
|
312
|
-
if (!tok
|
|
312
|
+
if (!tok) return { type: "failed", error: "cursor-agent isn't signed in: run `cursor-agent login`" }
|
|
313
|
+
if (exp && exp <= Date.now()) return { type: "failed", error: "cursor-agent's sign-in has run out: run `cursor-agent login` again" }
|
|
313
314
|
const who = await whoIs(tok)
|
|
314
|
-
if (!who.email) return { type: "failed" }
|
|
315
|
+
if (!who.email) return { type: "failed", error: "Cursor couldn't say which account is signed in" }
|
|
315
316
|
return { type: "success", access: "", refresh: CLI_MARK, expires: 0, accountId: who.email, ...(who.plan ? { plan: who.plan } : {}) }
|
|
316
317
|
},
|
|
317
318
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpie-community/opencode-cursor-auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Cursor subscriptions (Pro, Pro+, Ultra, Teams) in OpenCode and magpie, through the API cursor-agent talks to",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.mjs",
|