@magpie-community/opencode-kiro-auth 0.1.41 → 0.1.42
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 +6 -3
- package/index.mjs +8 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -55,8 +55,10 @@ them, are under "Other ways to sign in…".
|
|
|
55
55
|
again the same way goes beside it rather than replacing it: magpie
|
|
56
56
|
matches a sign-in by its name, and the plugin can't see the other
|
|
57
57
|
accounts to match it by `uid`.
|
|
58
|
-
- A company's own identity provider (`external_idp`) is not
|
|
59
|
-
here. Sign in with `kiro-cli login`
|
|
58
|
+
- A company's own identity provider (`external_idp`) is not offered as a
|
|
59
|
+
browser sign-in here. Sign in with `kiro-cli login` or the Kiro IDE and
|
|
60
|
+
use the next method instead; its management calls carry
|
|
61
|
+
`TokenType: EXTERNAL_IDP`.
|
|
60
62
|
- **Kiro CLI's or Kiro IDE's sign-in**: uses the account kiro-cli is signed
|
|
61
63
|
in to, or else the Kiro IDE's. Nothing is copied. It is read each time
|
|
62
64
|
from where they keep it:
|
|
@@ -68,7 +70,8 @@ them, are under "Other ways to sign in…".
|
|
|
68
70
|
|
|
69
71
|
kiro-cli refreshes its own token first (`kiro-cli debug refresh-auth-token`).
|
|
70
72
|
A token the plugin refreshes itself is written back, so kiro-cli and the
|
|
71
|
-
IDE go on with it.
|
|
73
|
+
IDE go on with it. An external-IdP sign-in read from either source sends
|
|
74
|
+
the control-plane `TokenType` that Kiro's own clients send.
|
|
72
75
|
- **Kiro API key (`ksk_…`)**: sent with `tokentype: API_KEY`, as kiro-cli
|
|
73
76
|
sends it. `GetProfile` is asked in us-east-1, then eu-central-1, for the
|
|
74
77
|
region the key's profile is in; a key it finds none for is used in
|
package/index.mjs
CHANGED
|
@@ -213,6 +213,7 @@ async function readIDE() {
|
|
|
213
213
|
return null
|
|
214
214
|
}
|
|
215
215
|
if (!t?.accessToken) return null
|
|
216
|
+
const authMethod = String(t.authMethod ?? t.provider ?? "").toLowerCase().replace(/[^a-z]/g, "")
|
|
216
217
|
const c = { access: t.accessToken, refresh: t.refreshToken ?? "", expires: time(t.expiresAt), region: t.region || "us-east-1",
|
|
217
218
|
profile: arnOf(t.profileArn), method: "idc", idePath: path, builderID: isBuilderID(t.provider) }
|
|
218
219
|
if (t.clientIdHash) {
|
|
@@ -221,7 +222,9 @@ async function readIDE() {
|
|
|
221
222
|
;[c.clientId, c.clientSecret] = [reg.clientId ?? "", reg.clientSecret ?? ""]
|
|
222
223
|
} catch {}
|
|
223
224
|
}
|
|
224
|
-
if (
|
|
225
|
+
if (authMethod === "externalidp") c.method = "external-idp"
|
|
226
|
+
else if (authMethod === "machinetoken") c.method = "machine-token"
|
|
227
|
+
else if (authMethod === "social" || !c.clientId) c.method = "social"
|
|
225
228
|
return c
|
|
226
229
|
}
|
|
227
230
|
|
|
@@ -347,7 +350,10 @@ function authHeaders(a) {
|
|
|
347
350
|
if (a.tokenType) h.tokentype = a.tokenType
|
|
348
351
|
return h
|
|
349
352
|
}
|
|
350
|
-
const tokenType = (c) =>
|
|
353
|
+
const tokenType = (c) => c.method === "apikey" ? "API_KEY"
|
|
354
|
+
: c.method === "external-idp" ? "EXTERNAL_IDP"
|
|
355
|
+
: c.method === "machine-token" ? "KIRO_MACHINE_TOKEN"
|
|
356
|
+
: ""
|
|
351
357
|
|
|
352
358
|
// region is where the account's API is: the region its profile is in, else
|
|
353
359
|
// the nearer of Kiro's two to where it signed in. It goes into the API's host
|