@kervnet/opencode-kiro-auth 1.7.11 → 1.7.13
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,8 +25,26 @@ 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();
|
|
42
|
+
// Reload accounts from database into memory
|
|
43
|
+
if (this.accountManager) {
|
|
44
|
+
this.repository.invalidateCache();
|
|
45
|
+
const freshAccounts = await this.repository.findAll();
|
|
46
|
+
this.accountManager.replaceAccounts(freshAccounts);
|
|
47
|
+
}
|
|
30
48
|
logger.log('Background token refresh completed');
|
|
31
49
|
}
|
|
32
50
|
catch (e) {
|
|
@@ -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();
|
|
@@ -10,6 +10,7 @@ export declare class AccountManager {
|
|
|
10
10
|
static loadFromDisk(strategy?: AccountSelectionStrategy): Promise<AccountManager>;
|
|
11
11
|
getAccountCount(): number;
|
|
12
12
|
getAccounts(): ManagedAccount[];
|
|
13
|
+
replaceAccounts(newAccounts: ManagedAccount[]): void;
|
|
13
14
|
shouldShowToast(debounce?: number): boolean;
|
|
14
15
|
shouldShowUsageToast(debounce?: number): boolean;
|
|
15
16
|
getMinWaitTime(): number;
|
package/dist/plugin/accounts.js
CHANGED
|
@@ -50,6 +50,9 @@ export class AccountManager {
|
|
|
50
50
|
getAccounts() {
|
|
51
51
|
return [...this.accounts];
|
|
52
52
|
}
|
|
53
|
+
replaceAccounts(newAccounts) {
|
|
54
|
+
this.accounts = newAccounts;
|
|
55
|
+
}
|
|
53
56
|
shouldShowToast(debounce = 10000) {
|
|
54
57
|
if (Date.now() - this.lastToastTime < debounce)
|
|
55
58
|
return false;
|
package/package.json
CHANGED