@magpie-community/opencode-kiro-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 +8 -4
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -411,7 +411,11 @@ function account(client) {
|
|
|
411
411
|
const read = await credOf(auth)
|
|
412
412
|
if (!read) {
|
|
413
413
|
held = null
|
|
414
|
-
throw new Error(
|
|
414
|
+
throw new Error(
|
|
415
|
+
auth?.source
|
|
416
|
+
? "Kiro isn't signed in; add the Kiro subscription in magpie, sign in with `kiro-cli login` or the Kiro IDE, or save a Kiro API key on the provider"
|
|
417
|
+
: "this Kiro account's sign-in is gone; add it again in magpie",
|
|
418
|
+
)
|
|
415
419
|
}
|
|
416
420
|
let c = held?.id === id ? held.c : null
|
|
417
421
|
if (!c || read.access !== c.access || !fresh(c) || stale) {
|
|
@@ -1171,7 +1175,7 @@ async function browserSignIn() {
|
|
|
1171
1175
|
const q = url.searchParams
|
|
1172
1176
|
if (!waiting) return html(200, page(false, "This sign-in is over", "Start it again."))
|
|
1173
1177
|
const fail = (msg) => {
|
|
1174
|
-
finish({ type: "failed" })
|
|
1178
|
+
finish({ type: "failed", error: msg })
|
|
1175
1179
|
html(200, page(false, "Sign-in didn't finish", msg))
|
|
1176
1180
|
}
|
|
1177
1181
|
if (q.get("error")) return fail(q.get("error_description") || q.get("error"))
|
|
@@ -1226,7 +1230,7 @@ async function browserSignIn() {
|
|
|
1226
1230
|
html(200, page(true, "You're signed in", `${user} is signed in. You can close this tab.`))
|
|
1227
1231
|
})
|
|
1228
1232
|
|
|
1229
|
-
const timer = setTimeout(() => finish({ type: "failed" }), SIGN_IN_TIMEOUT)
|
|
1233
|
+
const timer = setTimeout(() => finish({ type: "failed", error: "the sign-in timed out" }), SIGN_IN_TIMEOUT)
|
|
1230
1234
|
done.then(() => {
|
|
1231
1235
|
clearTimeout(timer)
|
|
1232
1236
|
setTimeout(() => server.close(), 10_000).unref?.()
|
|
@@ -1251,7 +1255,7 @@ async function ownSignIn() {
|
|
|
1251
1255
|
callback: async () => {
|
|
1252
1256
|
const cli = await readCLI()
|
|
1253
1257
|
const c = cli ?? (await readIDE())
|
|
1254
|
-
if (!c) return { type: "failed" }
|
|
1258
|
+
if (!c) return { type: "failed", error: "neither kiro-cli nor the Kiro IDE is signed in" }
|
|
1255
1259
|
const who = fresh(c) ? await whoIs(c) : { email: "", plan: "" }
|
|
1256
1260
|
return { type: "success", provider: ID, refresh: "", access: "", expires: 0, source: cli ? "kiro-cli" : "kiro-ide",
|
|
1257
1261
|
accountId: who.email || (cli ? "kiro-cli's account" : "Kiro IDE's account"), ...(who.plan ? { plan: who.plan } : {}) }
|