@magpie-community/opencode-kiro-auth 0.1.18 → 0.1.19
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 +3 -0
- package/index.mjs +8 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,6 +62,9 @@ Refreshing such a sign-in:
|
|
|
62
62
|
plugin's `auth.refresh`, once for the account and before its requests,
|
|
63
63
|
models and usage need it. magpie saves the new token. A failed renewal,
|
|
64
64
|
even one Kiro refused, doesn't mark the account: it is tried again.
|
|
65
|
+
The usage read does: a sign-in Kiro refused there marks the account
|
|
66
|
+
signed out (`signIn: "expired"`), so magpie passes over it and offers
|
|
67
|
+
Sign in again on its row, and a clean read takes the mark off.
|
|
65
68
|
- OpenCode doesn't call that hook: there the token is refreshed 2 minutes
|
|
66
69
|
before it expires, before a request, and saved.
|
|
67
70
|
- Either way, a token Kiro turns down (a 403) is refreshed and the request
|
package/index.mjs
CHANGED
|
@@ -219,7 +219,8 @@ const EXPIRED_CLI = EXPIRED + " with `kiro-cli login` or the Kiro IDE"
|
|
|
219
219
|
|
|
220
220
|
// gone is an error saying the sign-in itself is gone — refused, or never
|
|
221
221
|
// there. The built-in marked no Kiro account lapsed, not even then, nor
|
|
222
|
-
// cleared one: every answer
|
|
222
|
+
// cleared one: every answer says the account is kept. The usage read says
|
|
223
|
+
// expired for it, and renewed for a clean read (auth.usage).
|
|
223
224
|
const gone = (msg) => Object.assign(new Error(msg), { gone: true })
|
|
224
225
|
const EARLY_MS = 2 * 60 * 1000 // a token this close to its end is refreshed before a request
|
|
225
226
|
const LEAD_MS = 10 * 60 * 1000 // and this close, magpie renews it ahead of time (auth.refresh)
|
|
@@ -1697,8 +1698,10 @@ export async function KiroAuthPlugin({ client } = {}) {
|
|
|
1697
1698
|
},
|
|
1698
1699
|
}
|
|
1699
1700
|
},
|
|
1700
|
-
// the account's credits, as magpie's built-in showed them
|
|
1701
|
-
//
|
|
1701
|
+
// the account's credits, as magpie's built-in showed them. A sign-in
|
|
1702
|
+
// Kiro refused (gone) marks the account signed out, so magpie passes
|
|
1703
|
+
// over it and its row offers Sign in again; a clean read takes the
|
|
1704
|
+
// mark off, as after `kiro-cli login`. Any other failure keeps it.
|
|
1702
1705
|
async usage(getAuth) {
|
|
1703
1706
|
const auth = await getAuth()
|
|
1704
1707
|
if (!(auth?.type === "api" && auth.key) && auth?.type !== "oauth") return { error: "not signed in", signIn: "kept" }
|
|
@@ -1706,9 +1709,9 @@ export async function KiroAuthPlugin({ client } = {}) {
|
|
|
1706
1709
|
const u = usageOf(await usageLimits(await creds(auth), true))
|
|
1707
1710
|
// named as the account is
|
|
1708
1711
|
if (u.user && auth.type === "oauth" && !auth.source) u.user = nameOf(u.user, auth.loginProvider)
|
|
1709
|
-
return { ...u, signIn: "
|
|
1712
|
+
return { ...u, signIn: "renewed" }
|
|
1710
1713
|
} catch (e) {
|
|
1711
|
-
return { error: e.message, signIn: "kept" }
|
|
1714
|
+
return { error: e.message, signIn: e.gone ? "expired" : "kept" }
|
|
1712
1715
|
}
|
|
1713
1716
|
},
|
|
1714
1717
|
methods: [
|