@kervnet/opencode-kiro-auth 1.7.5 → 1.7.6

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.
@@ -62,9 +62,9 @@ export class ErrorHandler {
62
62
  await this.sleep(w);
63
63
  return { shouldRetry: true };
64
64
  }
65
- if ((response.status === 402 || response.status === 403) &&
66
- this.accountManager.getAccountCount() > 1) {
67
- let errorReason = response.status === 402 ? 'Quota' : 'Forbidden';
65
+ // Handle 403 Forbidden - might be invalid/stale token
66
+ if (response.status === 403) {
67
+ let errorReason = 'Forbidden';
68
68
  let isPermanent = false;
69
69
  try {
70
70
  const errorBody = await response.text();
@@ -84,10 +84,25 @@ export class ErrorHandler {
84
84
  }
85
85
  if (isPermanent) {
86
86
  account.failCount = 10;
87
+ this.accountManager.markUnhealthy(account, errorReason);
88
+ await this.repository.batchSave(this.accountManager.getAccounts());
89
+ if (this.accountManager.getAccountCount() > 1) {
90
+ showToast(`${errorReason} (${account.email}). Switching account...`, 'warning');
91
+ return { shouldRetry: true, switchAccount: true };
92
+ }
93
+ throw new Error(errorReason);
87
94
  }
88
- this.accountManager.markUnhealthy(account, errorReason);
95
+ // For non-permanent 403, force token expiry to trigger refresh
96
+ account.expiresAt = 0;
97
+ await this.repository.batchSave(this.accountManager.getAccounts());
98
+ showToast('Token expired. Refreshing...', 'info');
99
+ return { shouldRetry: true };
100
+ }
101
+ // Handle 402 Payment Required (quota exceeded)
102
+ if (response.status === 402 && this.accountManager.getAccountCount() > 1) {
103
+ this.accountManager.markUnhealthy(account, 'Quota');
89
104
  await this.repository.batchSave(this.accountManager.getAccounts());
90
- showToast(`${errorReason} (${account.email}). Switching account...`, 'warning');
105
+ showToast(`Quota exceeded (${account.email}). Switching account...`, 'warning');
91
106
  return { shouldRetry: true, switchAccount: true };
92
107
  }
93
108
  return { shouldRetry: false };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kervnet/opencode-kiro-auth",
3
- "version": "1.7.5",
3
+ "version": "1.7.6",
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",