@kervnet/opencode-kiro-auth 1.7.10 → 1.7.12

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.
@@ -25,6 +25,18 @@ export class AuthHandler {
25
25
  try {
26
26
  const logger = await import('../../plugin/logger.js');
27
27
  logger.log('Background token refresh starting...');
28
+ // Force kiro-cli to refresh its token first
29
+ try {
30
+ const { exec } = await import('node:child_process');
31
+ await new Promise((resolve) => {
32
+ exec('kiro-cli whoami', (error) => {
33
+ resolve(); // Continue even if it fails
34
+ });
35
+ });
36
+ }
37
+ catch (e) {
38
+ // Silent fail - continue with sync anyway
39
+ }
28
40
  const { syncFromKiroCli } = await import('../../plugin/sync/kiro-cli.js');
29
41
  await syncFromKiroCli();
30
42
  logger.log('Background token refresh completed');
@@ -33,6 +33,18 @@ export class TokenRefresher {
33
33
  const now = Date.now();
34
34
  if (this.config.auto_sync_kiro_cli && now - this.lastSyncTime > this.SYNC_COOLDOWN_MS) {
35
35
  this.lastSyncTime = now;
36
+ // Force kiro-cli to refresh its token first
37
+ try {
38
+ const { exec } = await import('node:child_process');
39
+ await new Promise((resolve) => {
40
+ exec('kiro-cli whoami', (error) => {
41
+ resolve(); // Continue even if it fails
42
+ });
43
+ });
44
+ }
45
+ catch (e) {
46
+ // Silent fail - continue with sync anyway
47
+ }
36
48
  await this.syncFromKiroCli();
37
49
  }
38
50
  this.repository.invalidateCache();
@@ -146,6 +146,14 @@ export async function syncFromKiroCli() {
146
146
  }
147
147
  }
148
148
  }
149
+ // Encode refresh token with client credentials for IDC
150
+ const { encodeRefreshToken } = await import('../../kiro/auth.js');
151
+ const encodedRefreshToken = encodeRefreshToken({
152
+ refreshToken,
153
+ clientId,
154
+ clientSecret,
155
+ authMethod: 'idc'
156
+ });
149
157
  await kiroDb.upsertAccount({
150
158
  id,
151
159
  email: resolvedEmail,
@@ -154,7 +162,7 @@ export async function syncFromKiroCli() {
154
162
  clientId,
155
163
  clientSecret,
156
164
  profileArn: tokenProfileArn,
157
- refreshToken,
165
+ refreshToken: encodedRefreshToken,
158
166
  accessToken,
159
167
  expiresAt: tokenExpiresAt,
160
168
  rateLimitResetTime: 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kervnet/opencode-kiro-auth",
3
- "version": "1.7.10",
3
+ "version": "1.7.12",
4
4
  "description": "OpenCode plugin for AWS Kiro (CodeWhisperer) with IAM Identity Center profile support",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",