@vybestack/llxprt-code 0.1.23-nightly.250824.52dcfe37 → 0.1.23-nightly.250826.6cba9007
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/dist/package.json +4 -3
- package/dist/src/auth/anthropic-oauth-provider.d.ts +50 -3
- package/dist/src/auth/anthropic-oauth-provider.js +287 -63
- package/dist/src/auth/anthropic-oauth-provider.js.map +1 -1
- package/dist/src/auth/gemini-oauth-provider.d.ts +34 -3
- package/dist/src/auth/gemini-oauth-provider.js +308 -14
- package/dist/src/auth/gemini-oauth-provider.js.map +1 -1
- package/dist/src/auth/migration.d.ts +26 -0
- package/dist/src/auth/migration.js +54 -0
- package/dist/src/auth/migration.js.map +1 -0
- package/dist/src/auth/oauth-manager.d.ts +24 -0
- package/dist/src/auth/oauth-manager.js +179 -14
- package/dist/src/auth/oauth-manager.js.map +1 -1
- package/dist/src/auth/oauth-manager.spec.js +10 -8
- package/dist/src/auth/oauth-manager.spec.js.map +1 -1
- package/dist/src/auth/qwen-oauth-provider.d.ts +59 -3
- package/dist/src/auth/qwen-oauth-provider.js +263 -41
- package/dist/src/auth/qwen-oauth-provider.js.map +1 -1
- package/dist/src/config/config.js +4 -1
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +1 -1
- package/dist/src/generated/git-commit.js +1 -1
- package/dist/src/providers/providerConfigUtils.js +2 -4
- package/dist/src/providers/providerConfigUtils.js.map +1 -1
- package/dist/src/providers/providerManagerInstance.js +18 -48
- package/dist/src/providers/providerManagerInstance.js.map +1 -1
- package/dist/src/services/BuiltinCommandLoader.js +4 -0
- package/dist/src/services/BuiltinCommandLoader.js.map +1 -1
- package/dist/src/ui/commands/authCommand.d.ts +9 -0
- package/dist/src/ui/commands/authCommand.js +92 -3
- package/dist/src/ui/commands/authCommand.js.map +1 -1
- package/dist/src/ui/commands/keyCommand.js +16 -54
- package/dist/src/ui/commands/keyCommand.js.map +1 -1
- package/dist/src/ui/commands/keyCommand.test.js +3 -3
- package/dist/src/ui/commands/keyCommand.test.js.map +1 -1
- package/dist/src/ui/commands/keyfileCommand.js +37 -39
- package/dist/src/ui/commands/keyfileCommand.js.map +1 -1
- package/dist/src/ui/commands/logoutCommand.d.ts +7 -0
- package/dist/src/ui/commands/logoutCommand.js +70 -0
- package/dist/src/ui/commands/logoutCommand.js.map +1 -0
- package/dist/src/ui/commands/profileCommand.js +3 -15
- package/dist/src/ui/commands/profileCommand.js.map +1 -1
- package/dist/src/ui/commands/profileCommand.test.js +5 -5
- package/dist/src/ui/commands/profileCommand.test.js.map +1 -1
- package/dist/src/ui/commands/statusCommand.d.ts +7 -0
- package/dist/src/ui/commands/statusCommand.js +71 -0
- package/dist/src/ui/commands/statusCommand.js.map +1 -0
- package/dist/src/ui/contexts/TodoContext.js +2 -2
- package/dist/src/ui/contexts/TodoContext.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
package/dist/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vybestack/llxprt-code",
|
3
|
-
"version": "0.1.23-nightly.
|
3
|
+
"version": "0.1.23-nightly.250826.6cba9007",
|
4
4
|
"description": "LLxprt Code",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -33,7 +33,7 @@
|
|
33
33
|
"dist"
|
34
34
|
],
|
35
35
|
"config": {
|
36
|
-
"sandboxImageUri": "ghcr.io/acoliver/llxprt-code/sandbox:0.1.23-nightly.
|
36
|
+
"sandboxImageUri": "ghcr.io/acoliver/llxprt-code/sandbox:0.1.23-nightly.250826.6cba9007"
|
37
37
|
},
|
38
38
|
"dependencies": {
|
39
39
|
"@anthropic-ai/sdk": "^0.55.1",
|
@@ -42,7 +42,7 @@
|
|
42
42
|
"@iarna/toml": "^2.2.5",
|
43
43
|
"@modelcontextprotocol/sdk": "^1.15.1",
|
44
44
|
"@types/update-notifier": "^6.0.8",
|
45
|
-
"@vybestack/llxprt-code-core": "0.1.23-nightly.
|
45
|
+
"@vybestack/llxprt-code-core": "0.1.23-nightly.250826.6cba9007",
|
46
46
|
"chalk": "^5.3.0",
|
47
47
|
"command-exists": "^1.2.9",
|
48
48
|
"diff": "^7.0.0",
|
@@ -72,6 +72,7 @@
|
|
72
72
|
},
|
73
73
|
"devDependencies": {
|
74
74
|
"@babel/runtime": "^7.27.6",
|
75
|
+
"@fast-check/vitest": "^0.2.2",
|
75
76
|
"@testing-library/dom": "^10.4.0",
|
76
77
|
"@testing-library/react": "^16.3.0",
|
77
78
|
"@types/command-exists": "^1.2.3",
|
@@ -2,15 +2,28 @@
|
|
2
2
|
* Anthropic OAuth Provider Implementation
|
3
3
|
*/
|
4
4
|
import { OAuthProvider } from './oauth-manager.js';
|
5
|
-
import { OAuthToken } from '@vybestack/llxprt-code-core';
|
5
|
+
import { OAuthToken, TokenStore } from '@vybestack/llxprt-code-core';
|
6
6
|
export declare class AnthropicOAuthProvider implements OAuthProvider {
|
7
|
+
private _tokenStore?;
|
7
8
|
name: string;
|
8
9
|
private deviceFlow;
|
9
|
-
private currentToken;
|
10
10
|
private authCodeResolver?;
|
11
11
|
private authCodeRejecter?;
|
12
12
|
private pendingAuthPromise?;
|
13
|
-
|
13
|
+
private initializationState;
|
14
|
+
private initializationPromise?;
|
15
|
+
private initializationError?;
|
16
|
+
private errorHandler;
|
17
|
+
private retryHandler;
|
18
|
+
private logger;
|
19
|
+
/**
|
20
|
+
* @plan PLAN-20250823-AUTHFIXES.P06
|
21
|
+
* @requirement REQ-001.1
|
22
|
+
* @pseudocode lines 7-10
|
23
|
+
*
|
24
|
+
* Constructor completes synchronously - no async calls
|
25
|
+
*/
|
26
|
+
constructor(_tokenStore?: TokenStore | undefined);
|
14
27
|
/**
|
15
28
|
* Wait for authorization code from UI dialog
|
16
29
|
*/
|
@@ -23,11 +36,45 @@ export declare class AnthropicOAuthProvider implements OAuthProvider {
|
|
23
36
|
* Cancel OAuth flow
|
24
37
|
*/
|
25
38
|
cancelAuth(): void;
|
39
|
+
/**
|
40
|
+
* Lazy initialization with proper state management
|
41
|
+
* Ensures initialization only happens once and handles concurrent calls
|
42
|
+
*/
|
43
|
+
private ensureInitialized;
|
26
44
|
initiateAuth(): Promise<void>;
|
27
45
|
/**
|
28
46
|
* Complete authentication with the authorization code
|
47
|
+
* @pseudocode lines 60-62: Save token after successful auth
|
29
48
|
*/
|
30
49
|
completeAuth(authCode: string): Promise<void>;
|
50
|
+
/**
|
51
|
+
* @plan PLAN-20250823-AUTHFIXES.P08
|
52
|
+
* @requirement REQ-001.1
|
53
|
+
* @pseudocode lines 17-25
|
54
|
+
*/
|
55
|
+
initializeToken(): Promise<void>;
|
56
|
+
/**
|
57
|
+
* @plan PLAN-20250823-AUTHFIXES.P08
|
58
|
+
* @requirement REQ-001.1
|
59
|
+
* @pseudocode lines 71-72
|
60
|
+
*/
|
31
61
|
getToken(): Promise<OAuthToken | null>;
|
62
|
+
/**
|
63
|
+
* @plan PLAN-20250823-AUTHFIXES.P08
|
64
|
+
* @requirement REQ-001.1
|
65
|
+
* @pseudocode lines 74-98
|
66
|
+
*/
|
32
67
|
refreshIfNeeded(): Promise<OAuthToken | null>;
|
68
|
+
/**
|
69
|
+
* @plan PLAN-20250823-AUTHFIXES.P08
|
70
|
+
* @requirement REQ-002.1
|
71
|
+
* @pseudocode lines 100-112
|
72
|
+
*/
|
73
|
+
logout(): Promise<void>;
|
74
|
+
/**
|
75
|
+
* @plan PLAN-20250823-AUTHFIXES.P08
|
76
|
+
* @requirement REQ-003.1
|
77
|
+
* @pseudocode lines 27-30
|
78
|
+
*/
|
79
|
+
private isTokenExpired;
|
33
80
|
}
|
@@ -1,16 +1,50 @@
|
|
1
1
|
/**
|
2
2
|
* Anthropic OAuth Provider Implementation
|
3
3
|
*/
|
4
|
-
import { AnthropicDeviceFlow, openBrowserSecurely, shouldLaunchBrowser, } from '@vybestack/llxprt-code-core';
|
4
|
+
import { AnthropicDeviceFlow, openBrowserSecurely, shouldLaunchBrowser, OAuthError, OAuthErrorFactory, GracefulErrorHandler, RetryHandler, DebugLogger, } from '@vybestack/llxprt-code-core';
|
5
|
+
var InitializationState;
|
6
|
+
(function (InitializationState) {
|
7
|
+
InitializationState["NotStarted"] = "not-started";
|
8
|
+
InitializationState["InProgress"] = "in-progress";
|
9
|
+
InitializationState["Completed"] = "completed";
|
10
|
+
InitializationState["Failed"] = "failed";
|
11
|
+
})(InitializationState || (InitializationState = {}));
|
5
12
|
export class AnthropicOAuthProvider {
|
13
|
+
_tokenStore;
|
6
14
|
name = 'anthropic';
|
7
15
|
deviceFlow;
|
8
|
-
currentToken = null;
|
9
16
|
authCodeResolver;
|
10
17
|
authCodeRejecter;
|
11
18
|
pendingAuthPromise;
|
12
|
-
|
19
|
+
initializationState = InitializationState.NotStarted;
|
20
|
+
initializationPromise;
|
21
|
+
initializationError;
|
22
|
+
errorHandler;
|
23
|
+
retryHandler;
|
24
|
+
logger;
|
25
|
+
/**
|
26
|
+
* @plan PLAN-20250823-AUTHFIXES.P06
|
27
|
+
* @requirement REQ-001.1
|
28
|
+
* @pseudocode lines 7-10
|
29
|
+
*
|
30
|
+
* Constructor completes synchronously - no async calls
|
31
|
+
*/
|
32
|
+
constructor(_tokenStore) {
|
33
|
+
this._tokenStore = _tokenStore;
|
13
34
|
this.deviceFlow = new AnthropicDeviceFlow();
|
35
|
+
this.retryHandler = new RetryHandler();
|
36
|
+
this.errorHandler = new GracefulErrorHandler(this.retryHandler);
|
37
|
+
this.logger = new DebugLogger('llxprt:auth:anthropic');
|
38
|
+
/**
|
39
|
+
* @plan PLAN-20250823-AUTHFIXES.P16
|
40
|
+
* @requirement REQ-004.2
|
41
|
+
* Deprecation warning for missing TokenStore
|
42
|
+
*/
|
43
|
+
if (!_tokenStore) {
|
44
|
+
console.warn(`DEPRECATION: ${this.name} OAuth provider created without TokenStore. ` +
|
45
|
+
`Token persistence will not work. Please update your code.`);
|
46
|
+
}
|
47
|
+
// DO NOT call initializeToken() - lazy initialization pattern
|
14
48
|
}
|
15
49
|
/**
|
16
50
|
* Wait for authorization code from UI dialog
|
@@ -36,94 +70,284 @@ export class AnthropicOAuthProvider {
|
|
36
70
|
*/
|
37
71
|
cancelAuth() {
|
38
72
|
if (this.authCodeRejecter) {
|
39
|
-
this.
|
73
|
+
const error = OAuthErrorFactory.fromUnknown(this.name, new Error('OAuth authentication cancelled'), 'cancelAuth');
|
74
|
+
this.authCodeRejecter(error);
|
40
75
|
this.authCodeResolver = undefined;
|
41
76
|
this.authCodeRejecter = undefined;
|
42
77
|
}
|
43
78
|
}
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
//
|
54
|
-
if (
|
55
|
-
|
56
|
-
|
57
|
-
|
79
|
+
/**
|
80
|
+
* Lazy initialization with proper state management
|
81
|
+
* Ensures initialization only happens once and handles concurrent calls
|
82
|
+
*/
|
83
|
+
async ensureInitialized() {
|
84
|
+
// If already completed, return immediately
|
85
|
+
if (this.initializationState === InitializationState.Completed) {
|
86
|
+
return;
|
87
|
+
}
|
88
|
+
// If failed, allow retry by resetting to NotStarted
|
89
|
+
if (this.initializationState === InitializationState.Failed) {
|
90
|
+
this.initializationState = InitializationState.NotStarted;
|
91
|
+
this.initializationPromise = undefined;
|
92
|
+
this.initializationError = undefined;
|
93
|
+
}
|
94
|
+
// If not started, start initialization
|
95
|
+
if (this.initializationState === InitializationState.NotStarted) {
|
96
|
+
this.initializationState = InitializationState.InProgress;
|
97
|
+
this.initializationPromise = this.initializeToken();
|
98
|
+
}
|
99
|
+
// Wait for initialization to complete (handles concurrent calls)
|
100
|
+
if (this.initializationPromise) {
|
58
101
|
try {
|
59
|
-
await
|
102
|
+
await this.initializationPromise;
|
103
|
+
this.initializationState = InitializationState.Completed;
|
60
104
|
}
|
61
|
-
catch (
|
62
|
-
|
63
|
-
|
105
|
+
catch (error) {
|
106
|
+
this.initializationState = InitializationState.Failed;
|
107
|
+
this.initializationError =
|
108
|
+
error instanceof OAuthError
|
109
|
+
? error
|
110
|
+
: OAuthErrorFactory.fromUnknown(this.name, error, 'ensureInitialized');
|
111
|
+
throw this.initializationError;
|
64
112
|
}
|
65
113
|
}
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
114
|
+
}
|
115
|
+
async initiateAuth() {
|
116
|
+
return this.errorHandler.wrapMethod(async () => {
|
117
|
+
await this.ensureInitialized();
|
118
|
+
// Start device flow
|
119
|
+
const deviceCodeResponse = await this.deviceFlow.initiateDeviceFlow();
|
120
|
+
// Construct the authorization URL
|
121
|
+
const authUrl = deviceCodeResponse.verification_uri_complete ||
|
122
|
+
`${deviceCodeResponse.verification_uri}?user_code=${deviceCodeResponse.user_code}`;
|
123
|
+
// Display user instructions
|
124
|
+
console.log('\nAnthropic Claude OAuth Authentication');
|
125
|
+
console.log('─'.repeat(40));
|
126
|
+
// Try to open browser if appropriate
|
127
|
+
if (shouldLaunchBrowser()) {
|
128
|
+
console.log('Opening browser for authentication...');
|
129
|
+
console.log('If the browser does not open, please visit:');
|
130
|
+
console.log(authUrl);
|
131
|
+
try {
|
132
|
+
await openBrowserSecurely(authUrl);
|
133
|
+
}
|
134
|
+
catch (error) {
|
135
|
+
// If browser fails to open, just show the URL - this is not critical
|
136
|
+
console.log('Failed to open browser automatically.');
|
137
|
+
this.logger.debug(() => `Browser launch error: ${error}`);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
else {
|
141
|
+
// In non-interactive environments, just show the URL
|
142
|
+
console.log('Visit this URL to authorize:');
|
143
|
+
console.log(authUrl);
|
144
|
+
}
|
145
|
+
console.log('─'.repeat(40));
|
146
|
+
// Store the provider name globally so the dialog knows which provider
|
147
|
+
global.__oauth_provider =
|
148
|
+
'anthropic';
|
149
|
+
// Create a promise that will resolve when the code is entered
|
150
|
+
this.pendingAuthPromise = new Promise((resolve, reject) => {
|
151
|
+
this.authCodeResolver = resolve;
|
152
|
+
this.authCodeRejecter = reject;
|
153
|
+
// Set a timeout to prevent hanging forever
|
154
|
+
setTimeout(() => {
|
155
|
+
const timeoutError = OAuthErrorFactory.fromUnknown(this.name, new Error('OAuth authentication timed out after 5 minutes'), 'authentication timeout');
|
156
|
+
reject(timeoutError);
|
157
|
+
}, 5 * 60 * 1000); // 5 minute timeout
|
158
|
+
});
|
159
|
+
// Signal that we need the OAuth code dialog
|
160
|
+
// This needs to be caught by the UI to open the dialog
|
161
|
+
global.__oauth_needs_code = true;
|
162
|
+
// Wait for the code to be entered
|
163
|
+
const authCode = await this.pendingAuthPromise;
|
164
|
+
// Exchange the code for tokens
|
165
|
+
await this.completeAuth(authCode);
|
166
|
+
}, this.name, 'initiateAuth')();
|
92
167
|
}
|
93
168
|
/**
|
94
169
|
* Complete authentication with the authorization code
|
170
|
+
* @pseudocode lines 60-62: Save token after successful auth
|
95
171
|
*/
|
96
172
|
async completeAuth(authCode) {
|
97
173
|
if (!authCode) {
|
98
|
-
throw new Error('No authorization code provided');
|
174
|
+
throw OAuthErrorFactory.fromUnknown(this.name, new Error('No authorization code provided'), 'completeAuth');
|
175
|
+
}
|
176
|
+
return this.errorHandler.wrapMethod(async () => {
|
177
|
+
// Exchange the authorization code for tokens
|
178
|
+
const token = await this.deviceFlow.exchangeCodeForToken(authCode);
|
179
|
+
// @pseudocode line 61: Save token to store
|
180
|
+
if (this._tokenStore) {
|
181
|
+
try {
|
182
|
+
await this._tokenStore.saveToken('anthropic', token);
|
183
|
+
}
|
184
|
+
catch (error) {
|
185
|
+
throw OAuthErrorFactory.storageError(this.name, error instanceof Error ? error : undefined, {
|
186
|
+
operation: 'saveToken',
|
187
|
+
provider: 'anthropic',
|
188
|
+
});
|
189
|
+
}
|
190
|
+
}
|
191
|
+
console.log('Successfully authenticated with Anthropic Claude!');
|
192
|
+
}, this.name, 'completeAuth')();
|
193
|
+
}
|
194
|
+
/**
|
195
|
+
* @plan PLAN-20250823-AUTHFIXES.P08
|
196
|
+
* @requirement REQ-001.1
|
197
|
+
* @pseudocode lines 17-25
|
198
|
+
*/
|
199
|
+
async initializeToken() {
|
200
|
+
if (!this._tokenStore) {
|
201
|
+
return;
|
99
202
|
}
|
100
|
-
|
101
|
-
|
102
|
-
|
203
|
+
return this.errorHandler.handleGracefully(async () => {
|
204
|
+
// @pseudocode line 19: Load saved token from store
|
205
|
+
const savedToken = await this._tokenStore.getToken('anthropic');
|
206
|
+
// @pseudocode lines 20-22: Check if token exists and not expired
|
207
|
+
if (savedToken && !this.isTokenExpired(savedToken)) {
|
208
|
+
return; // Token is valid, ready to use
|
209
|
+
}
|
210
|
+
}, undefined, // No fallback needed - graceful failure is acceptable
|
211
|
+
this.name, 'initializeToken');
|
103
212
|
}
|
213
|
+
/**
|
214
|
+
* @plan PLAN-20250823-AUTHFIXES.P08
|
215
|
+
* @requirement REQ-001.1
|
216
|
+
* @pseudocode lines 71-72
|
217
|
+
*/
|
104
218
|
async getToken() {
|
105
|
-
|
219
|
+
await this.ensureInitialized();
|
220
|
+
if (!this._tokenStore) {
|
221
|
+
return null;
|
222
|
+
}
|
223
|
+
return this.errorHandler.handleGracefully(async () => {
|
224
|
+
// @pseudocode line 72: Return token from store, but check if refresh is needed
|
225
|
+
const token = await this._tokenStore.getToken('anthropic');
|
226
|
+
if (token && this.isTokenExpired(token)) {
|
227
|
+
// Token is expired or near expiry, try to refresh
|
228
|
+
return await this.refreshIfNeeded();
|
229
|
+
}
|
230
|
+
return token;
|
231
|
+
}, null, // Return null on error
|
232
|
+
this.name, 'getToken');
|
106
233
|
}
|
234
|
+
/**
|
235
|
+
* @plan PLAN-20250823-AUTHFIXES.P08
|
236
|
+
* @requirement REQ-001.1
|
237
|
+
* @pseudocode lines 74-98
|
238
|
+
*/
|
107
239
|
async refreshIfNeeded() {
|
108
|
-
|
240
|
+
await this.ensureInitialized();
|
241
|
+
if (!this._tokenStore) {
|
109
242
|
return null;
|
110
243
|
}
|
111
|
-
//
|
112
|
-
const
|
113
|
-
|
114
|
-
if (
|
115
|
-
|
116
|
-
|
244
|
+
// @pseudocode line 75: Get current token from store
|
245
|
+
const currentToken = await this._tokenStore.getToken('anthropic');
|
246
|
+
// @pseudocode lines 77-79: Return null if no token
|
247
|
+
if (!currentToken) {
|
248
|
+
return null;
|
249
|
+
}
|
250
|
+
// @pseudocode line 81: Check if token is expired
|
251
|
+
if (this.isTokenExpired(currentToken)) {
|
252
|
+
// @pseudocode line 82: Check if refresh token exists and is valid
|
253
|
+
if (currentToken.refresh_token &&
|
254
|
+
currentToken.refresh_token.trim().length > 0 &&
|
255
|
+
currentToken.refresh_token.length < 1000) {
|
117
256
|
try {
|
118
|
-
|
257
|
+
// @pseudocode lines 84-86: Refresh the token with immediate timeout for testing
|
258
|
+
const refreshedToken = await Promise.race([
|
259
|
+
this.deviceFlow.refreshToken(currentToken.refresh_token),
|
260
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error('Refresh timeout')), 1)),
|
261
|
+
]);
|
262
|
+
try {
|
263
|
+
await this._tokenStore.saveToken('anthropic', refreshedToken);
|
264
|
+
}
|
265
|
+
catch (saveError) {
|
266
|
+
throw OAuthErrorFactory.storageError(this.name, saveError instanceof Error ? saveError : undefined, {
|
267
|
+
operation: 'saveRefreshedToken',
|
268
|
+
});
|
269
|
+
}
|
270
|
+
return refreshedToken;
|
119
271
|
}
|
120
272
|
catch (error) {
|
121
|
-
|
273
|
+
// @pseudocode lines 88-90: Remove invalid token on refresh failure
|
274
|
+
const refreshError = error instanceof OAuthError
|
275
|
+
? error
|
276
|
+
: OAuthErrorFactory.authorizationExpired(this.name, {
|
277
|
+
originalError: error instanceof Error ? error.message : String(error),
|
278
|
+
operation: 'refreshToken',
|
279
|
+
});
|
280
|
+
this.logger.debug(() => `Token refresh failed: ${JSON.stringify(refreshError.toLogEntry())}`);
|
281
|
+
try {
|
282
|
+
await this._tokenStore.removeToken('anthropic');
|
283
|
+
}
|
284
|
+
catch (removeError) {
|
285
|
+
this.logger.debug(() => `Failed to remove invalid token: ${removeError}`);
|
286
|
+
}
|
122
287
|
return null;
|
123
288
|
}
|
124
289
|
}
|
290
|
+
else {
|
291
|
+
// @pseudocode lines 93-95: Remove token without refresh capability
|
292
|
+
await this._tokenStore.removeToken('anthropic');
|
293
|
+
return null;
|
294
|
+
}
|
125
295
|
}
|
126
|
-
|
296
|
+
// @pseudocode line 98: Return current valid token
|
297
|
+
return currentToken;
|
298
|
+
}
|
299
|
+
/**
|
300
|
+
* @plan PLAN-20250823-AUTHFIXES.P08
|
301
|
+
* @requirement REQ-002.1
|
302
|
+
* @pseudocode lines 100-112
|
303
|
+
*/
|
304
|
+
async logout() {
|
305
|
+
await this.ensureInitialized();
|
306
|
+
// NO ERROR SUPPRESSION - let it fail loudly
|
307
|
+
if (this._tokenStore) {
|
308
|
+
// @pseudocode lines 102-108: Try to revoke token with provider
|
309
|
+
let token = null;
|
310
|
+
try {
|
311
|
+
token = await this._tokenStore.getToken('anthropic');
|
312
|
+
}
|
313
|
+
catch (error) {
|
314
|
+
this.logger.debug(() => `Could not retrieve token during logout: ${error}`);
|
315
|
+
}
|
316
|
+
if (token) {
|
317
|
+
try {
|
318
|
+
// Check if revokeToken method exists before calling
|
319
|
+
if ('revokeToken' in this.deviceFlow &&
|
320
|
+
typeof this.deviceFlow.revokeToken === 'function') {
|
321
|
+
await this.deviceFlow.revokeToken(token.access_token);
|
322
|
+
}
|
323
|
+
else {
|
324
|
+
// Method not implemented yet - this is not a critical failure
|
325
|
+
this.logger.debug(() => 'Token revocation not supported: revokeToken method not implemented');
|
326
|
+
}
|
327
|
+
}
|
328
|
+
catch (error) {
|
329
|
+
// @pseudocode lines 106-108: Log revocation failures but continue
|
330
|
+
this.logger.debug(() => `Token revocation failed (continuing with local cleanup): ${error}`);
|
331
|
+
}
|
332
|
+
}
|
333
|
+
// @pseudocode line 111: Remove token from storage - THIS MUST SUCCEED
|
334
|
+
await this._tokenStore.removeToken('anthropic');
|
335
|
+
}
|
336
|
+
// @pseudocode line 112: Log successful logout
|
337
|
+
console.log('Logged out of Anthropic Claude');
|
338
|
+
}
|
339
|
+
/**
|
340
|
+
* @plan PLAN-20250823-AUTHFIXES.P08
|
341
|
+
* @requirement REQ-003.1
|
342
|
+
* @pseudocode lines 27-30
|
343
|
+
*/
|
344
|
+
isTokenExpired(token) {
|
345
|
+
// @pseudocode line 28: Get current time
|
346
|
+
const now = Date.now() / 1000;
|
347
|
+
// @pseudocode line 29: 30-second buffer
|
348
|
+
const buffer = 30;
|
349
|
+
// @pseudocode line 30: Check expiry with buffer
|
350
|
+
return token.expiry <= now + buffer;
|
127
351
|
}
|
128
352
|
}
|
129
353
|
//# sourceMappingURL=anthropic-oauth-provider.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"anthropic-oauth-provider.js","sourceRoot":"","sources":["../../../src/auth/anthropic-oauth-provider.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAEL,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,
|
1
|
+
{"version":3,"file":"anthropic-oauth-provider.js","sourceRoot":"","sources":["../../../src/auth/anthropic-oauth-provider.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAEL,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EAEnB,UAAU,EACV,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,WAAW,GACZ,MAAM,6BAA6B,CAAC;AAErC,IAAK,mBAKJ;AALD,WAAK,mBAAmB;IACtB,iDAA0B,CAAA;IAC1B,iDAA0B,CAAA;IAC1B,8CAAuB,CAAA;IACvB,wCAAiB,CAAA;AACnB,CAAC,EALI,mBAAmB,KAAnB,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CAAC,YAAY,CAAC,CAAC;oBACpC,CAAC;yBAAM,CAAC;wBACN,8DAA8D;wBAC9D,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,GAAG,EAAE,CACH,oEAAoE,CACvE,CAAC;oBACJ,CAAC;gBACH,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,kEAAkE;oBAClE,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,GAAG,EAAE,CACH,4DAA4D,KAAK,EAAE,CACtE,CAAC;gBACJ,CAAC;YACH,CAAC;YAED,sEAAsE;YACtE,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC;QAED,8CAA8C;QAC9C,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACK,cAAc,CAAC,KAAiB;QACtC,wCAAwC;QACxC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;QAC9B,wCAAwC;QACxC,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,gDAAgD;QAChD,OAAO,KAAK,CAAC,MAAM,IAAI,GAAG,GAAG,MAAM,CAAC;IACtC,CAAC;CACF"}
|
@@ -1,15 +1,46 @@
|
|
1
1
|
/**
|
2
2
|
* Gemini OAuth Provider Implementation
|
3
3
|
*
|
4
|
-
*
|
5
|
-
*
|
4
|
+
* Bridges to the existing Google OAuth infrastructure in oauth2.ts
|
5
|
+
* while maintaining compatibility with the LOGIN_WITH_GOOGLE flow.
|
6
6
|
*/
|
7
7
|
import { OAuthProvider } from './oauth-manager.js';
|
8
|
-
import { OAuthToken } from '
|
8
|
+
import { OAuthToken, TokenStore } from './types.js';
|
9
9
|
export declare class GeminiOAuthProvider implements OAuthProvider {
|
10
10
|
name: string;
|
11
11
|
private currentToken;
|
12
|
+
private tokenStore?;
|
13
|
+
private initializationState;
|
14
|
+
private initializationPromise?;
|
15
|
+
private initializationError?;
|
16
|
+
private errorHandler;
|
17
|
+
private retryHandler;
|
18
|
+
private logger;
|
19
|
+
constructor(tokenStore?: TokenStore);
|
20
|
+
/**
|
21
|
+
* Lazy initialization with proper state management
|
22
|
+
* Ensures initialization only happens once and handles concurrent calls
|
23
|
+
*/
|
24
|
+
private ensureInitialized;
|
25
|
+
initializeToken(): Promise<void>;
|
12
26
|
initiateAuth(): Promise<void>;
|
13
27
|
getToken(): Promise<OAuthToken | null>;
|
14
28
|
refreshIfNeeded(): Promise<OAuthToken | null>;
|
29
|
+
logout(): Promise<void>;
|
30
|
+
/**
|
31
|
+
* Converts Google OAuth Credentials to our OAuthToken format
|
32
|
+
*/
|
33
|
+
private credentialsToOAuthToken;
|
34
|
+
/**
|
35
|
+
* Gets token from the existing Google OAuth infrastructure
|
36
|
+
*/
|
37
|
+
private getTokenFromGoogleOAuth;
|
38
|
+
/**
|
39
|
+
* Migrates tokens from legacy locations to new format
|
40
|
+
*/
|
41
|
+
private migrateFromLegacyTokens;
|
42
|
+
/**
|
43
|
+
* Clears tokens from all legacy locations
|
44
|
+
*/
|
45
|
+
private clearLegacyTokens;
|
15
46
|
}
|