@bogyie/opencode-kiro-plugin 0.3.23 → 0.3.24

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.
Files changed (2) hide show
  1. package/dist/plugin.js +16 -1
  2. package/package.json +1 -1
package/dist/plugin.js CHANGED
@@ -65,6 +65,20 @@ function bearerToken(init) {
65
65
  const match = header?.match(/^Bearer\s+(.+)$/i);
66
66
  return match?.[1] || undefined;
67
67
  }
68
+ function isLikelyKiroApiKey(value) {
69
+ return Boolean(value?.startsWith("ksk_"));
70
+ }
71
+ function localAccessToken(incoming, fallback) {
72
+ if (!incoming || incoming === KIRO_LOCAL_TRANSPORT_KEY)
73
+ return fallback ?? incoming;
74
+ if (isKiroDeviceAuthKey(incoming))
75
+ return incoming;
76
+ if (process.env.KIRO_API_KEY && incoming === process.env.KIRO_API_KEY)
77
+ return incoming;
78
+ if (isLikelyKiroApiKey(incoming))
79
+ return incoming;
80
+ return fallback;
81
+ }
68
82
  export function effectiveBackend(options, accessToken) {
69
83
  const apiKey = accessToken || process.env.KIRO_API_KEY;
70
84
  if (options.backend === "acp")
@@ -311,7 +325,8 @@ export function createKiroPlugin() {
311
325
  });
312
326
  const localFetch = async (input, init) => {
313
327
  startupDeviceAuthKey ??= sharedDeviceAuthKey;
314
- const transport = localTransport(options, bearerToken(init) || startupDeviceAuthKey || sharedDeviceAuthKey, {
328
+ const accessToken = localAccessToken(bearerToken(init), startupDeviceAuthKey || sharedDeviceAuthKey);
329
+ const transport = localTransport(options, accessToken, {
315
330
  loginOnAuthFailure: shouldLoginOnAuthFailure(init),
316
331
  });
317
332
  return createKiroFetch({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bogyie/opencode-kiro-plugin",
3
- "version": "0.3.23",
3
+ "version": "0.3.24",
4
4
  "description": "OpenCode plugin for using Kiro as a provider adapter",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",