@lanonasis/oauth-client 1.2.1 → 1.2.2
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/README.md +41 -6
- package/dist/browser-CUJNgghM.d.cts +246 -0
- package/dist/browser-CUJNgghM.d.ts +246 -0
- package/dist/browser.cjs +1312 -0
- package/dist/browser.d.cts +1 -0
- package/dist/browser.d.ts +1 -0
- package/dist/browser.mjs +1286 -0
- package/dist/index.cjs +517 -107
- package/dist/index.d.cts +3 -194
- package/dist/index.d.ts +3 -194
- package/dist/index.mjs +514 -95
- package/package.json +12 -6
package/dist/index.d.cts
CHANGED
|
@@ -1,47 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
refresh_token?: string;
|
|
4
|
-
expires_in: number;
|
|
5
|
-
token_type: string;
|
|
6
|
-
scope?: string;
|
|
7
|
-
issued_at?: number;
|
|
8
|
-
}
|
|
9
|
-
interface DeviceCodeResponse {
|
|
10
|
-
device_code: string;
|
|
11
|
-
user_code: string;
|
|
12
|
-
verification_uri: string;
|
|
13
|
-
verification_uri_complete?: string;
|
|
14
|
-
expires_in: number;
|
|
15
|
-
interval: number;
|
|
16
|
-
}
|
|
17
|
-
interface OAuthConfig {
|
|
18
|
-
clientId: string;
|
|
19
|
-
authBaseUrl?: string;
|
|
20
|
-
redirectUri?: string;
|
|
21
|
-
scope?: string;
|
|
22
|
-
}
|
|
23
|
-
interface AuthError {
|
|
24
|
-
error: string;
|
|
25
|
-
error_description?: string;
|
|
26
|
-
}
|
|
27
|
-
type GrantType = 'authorization_code' | 'urn:ietf:params:oauth:grant-type:device_code' | 'refresh_token';
|
|
28
|
-
interface PKCEChallenge {
|
|
29
|
-
codeVerifier: string;
|
|
30
|
-
codeChallenge: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
declare abstract class BaseOAuthFlow {
|
|
34
|
-
protected readonly clientId: string;
|
|
35
|
-
protected readonly authBaseUrl: string;
|
|
36
|
-
protected readonly scope: string;
|
|
37
|
-
constructor(config: OAuthConfig);
|
|
38
|
-
abstract authenticate(): Promise<TokenResponse>;
|
|
39
|
-
protected makeTokenRequest(body: Record<string, string>): Promise<TokenResponse>;
|
|
40
|
-
protected generateState(): string;
|
|
41
|
-
protected base64URLEncode(buffer: ArrayBuffer | Uint8Array): string;
|
|
42
|
-
refreshToken(refreshToken: string): Promise<TokenResponse>;
|
|
43
|
-
revokeToken(token: string, tokenType?: 'access_token' | 'refresh_token'): Promise<void>;
|
|
44
|
-
}
|
|
1
|
+
import { B as BaseOAuthFlow, O as OAuthConfig, T as TokenResponse } from './browser-CUJNgghM.cjs';
|
|
2
|
+
export { A as ApiKeyData, c as ApiKeyStorage, e as ApiKeyStorageWeb, h as AuthError, D as DesktopOAuthFlow, g as DeviceCodeResponse, G as GrantType, f as MCPClient, M as MCPClientConfig, P as PKCEChallenge, b as TokenStorage, a as TokenStorageAdapter, d as TokenStorageWeb } from './browser-CUJNgghM.cjs';
|
|
45
3
|
|
|
46
4
|
declare class TerminalOAuthFlow extends BaseOAuthFlow {
|
|
47
5
|
private pollInterval;
|
|
@@ -55,153 +13,4 @@ declare class TerminalOAuthFlow extends BaseOAuthFlow {
|
|
|
55
13
|
private checkDeviceCode;
|
|
56
14
|
}
|
|
57
15
|
|
|
58
|
-
|
|
59
|
-
private readonly redirectUri;
|
|
60
|
-
private authWindow;
|
|
61
|
-
constructor(config: OAuthConfig);
|
|
62
|
-
authenticate(): Promise<TokenResponse>;
|
|
63
|
-
private generatePKCEChallenge;
|
|
64
|
-
private generateCodeVerifier;
|
|
65
|
-
private generateCodeChallenge;
|
|
66
|
-
private buildAuthorizationUrl;
|
|
67
|
-
private openAuthWindow;
|
|
68
|
-
private openBrowserWindow;
|
|
69
|
-
private openElectronWindow;
|
|
70
|
-
private exchangeCodeForToken;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
declare class TokenStorage {
|
|
74
|
-
private readonly storageKey;
|
|
75
|
-
private readonly webEncryptionKeyStorage;
|
|
76
|
-
private keytar;
|
|
77
|
-
constructor();
|
|
78
|
-
store(tokens: TokenResponse): Promise<void>;
|
|
79
|
-
retrieve(): Promise<TokenResponse | null>;
|
|
80
|
-
clear(): Promise<void>;
|
|
81
|
-
isTokenExpired(tokens: TokenResponse & {
|
|
82
|
-
issued_at?: number;
|
|
83
|
-
}): boolean;
|
|
84
|
-
private storeToFile;
|
|
85
|
-
private retrieveFromFile;
|
|
86
|
-
private deleteFile;
|
|
87
|
-
private getFileEncryptionKey;
|
|
88
|
-
private encrypt;
|
|
89
|
-
private decrypt;
|
|
90
|
-
private isNode;
|
|
91
|
-
private isElectron;
|
|
92
|
-
private isMobile;
|
|
93
|
-
private getWebEncryptionKey;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* API Key Storage Service
|
|
98
|
-
* Secure multi-platform API key storage with encryption
|
|
99
|
-
* Supports Node.js, Electron, Web, and Mobile environments
|
|
100
|
-
*/
|
|
101
|
-
interface ApiKeyData {
|
|
102
|
-
apiKey: string;
|
|
103
|
-
organizationId?: string;
|
|
104
|
-
userId?: string;
|
|
105
|
-
environment?: 'development' | 'staging' | 'production';
|
|
106
|
-
createdAt?: string;
|
|
107
|
-
expiresAt?: string;
|
|
108
|
-
metadata?: Record<string, unknown>;
|
|
109
|
-
}
|
|
110
|
-
declare class ApiKeyStorage {
|
|
111
|
-
private readonly storageKey;
|
|
112
|
-
private readonly legacyConfigKey;
|
|
113
|
-
private readonly webEncryptionKeyStorage;
|
|
114
|
-
private keytar;
|
|
115
|
-
private migrationCompleted;
|
|
116
|
-
constructor();
|
|
117
|
-
/**
|
|
118
|
-
* Initialize and migrate from legacy storage if needed
|
|
119
|
-
*/
|
|
120
|
-
initialize(): Promise<void>;
|
|
121
|
-
/**
|
|
122
|
-
* Store API key securely
|
|
123
|
-
*/
|
|
124
|
-
store(data: ApiKeyData): Promise<void>;
|
|
125
|
-
/**
|
|
126
|
-
* Retrieve API key from secure storage
|
|
127
|
-
*/
|
|
128
|
-
retrieve(): Promise<ApiKeyData | null>;
|
|
129
|
-
/**
|
|
130
|
-
* Get just the API key string (convenience method)
|
|
131
|
-
*/
|
|
132
|
-
getApiKey(): Promise<string | null>;
|
|
133
|
-
/**
|
|
134
|
-
* Check if API key exists
|
|
135
|
-
*/
|
|
136
|
-
hasApiKey(): Promise<boolean>;
|
|
137
|
-
/**
|
|
138
|
-
* Clear API key from storage
|
|
139
|
-
*/
|
|
140
|
-
clear(): Promise<void>;
|
|
141
|
-
/**
|
|
142
|
-
* Check if API key is expired
|
|
143
|
-
*/
|
|
144
|
-
isExpired(data: ApiKeyData): boolean;
|
|
145
|
-
/**
|
|
146
|
-
* Update API key metadata without changing the key itself
|
|
147
|
-
*/
|
|
148
|
-
updateMetadata(metadata: Record<string, unknown>): Promise<void>;
|
|
149
|
-
/**
|
|
150
|
-
* Migrate from legacy configuration storage
|
|
151
|
-
*/
|
|
152
|
-
private migrateFromLegacyIfNeeded;
|
|
153
|
-
private storeToFile;
|
|
154
|
-
private retrieveFromFile;
|
|
155
|
-
private deleteFile;
|
|
156
|
-
private retrieveLegacyFromFile;
|
|
157
|
-
private deleteLegacyFile;
|
|
158
|
-
private getFileEncryptionKey;
|
|
159
|
-
private encrypt;
|
|
160
|
-
private decrypt;
|
|
161
|
-
private getWebEncryptionKey;
|
|
162
|
-
private isNode;
|
|
163
|
-
private isElectron;
|
|
164
|
-
private isMobile;
|
|
165
|
-
/**
|
|
166
|
-
* Normalize API keys to a SHA-256 hex digest.
|
|
167
|
-
* Accepts pre-hashed input and lowercases it to prevent double hashing.
|
|
168
|
-
*/
|
|
169
|
-
private normalizeApiKey;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
interface MCPClientConfig extends Partial<OAuthConfig> {
|
|
173
|
-
mcpEndpoint?: string;
|
|
174
|
-
autoRefresh?: boolean;
|
|
175
|
-
}
|
|
176
|
-
declare class MCPClient {
|
|
177
|
-
private tokenStorage;
|
|
178
|
-
private authFlow;
|
|
179
|
-
private config;
|
|
180
|
-
private ws;
|
|
181
|
-
private eventSource;
|
|
182
|
-
private accessToken;
|
|
183
|
-
private refreshTimer;
|
|
184
|
-
constructor(config?: MCPClientConfig);
|
|
185
|
-
connect(): Promise<void>;
|
|
186
|
-
private authenticate;
|
|
187
|
-
private ensureAccessToken;
|
|
188
|
-
private scheduleTokenRefresh;
|
|
189
|
-
private establishConnection;
|
|
190
|
-
private connectWebSocket;
|
|
191
|
-
private connectSSE;
|
|
192
|
-
private handleMessage;
|
|
193
|
-
private reconnect;
|
|
194
|
-
request<T = unknown>(method: string, params?: unknown): Promise<T>;
|
|
195
|
-
disconnect(): void;
|
|
196
|
-
logout(): Promise<void>;
|
|
197
|
-
private isTerminal;
|
|
198
|
-
private isElectron;
|
|
199
|
-
private generateId;
|
|
200
|
-
createMemory<T = unknown>(title: string, content: string, options?: unknown): Promise<T>;
|
|
201
|
-
searchMemories<T = unknown>(query: string, options?: unknown): Promise<T[]>;
|
|
202
|
-
getMemory<T = unknown>(id: string): Promise<T>;
|
|
203
|
-
updateMemory<T = unknown>(id: string, updates: Partial<T>): Promise<T>;
|
|
204
|
-
deleteMemory(id: string): Promise<void>;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
export { type ApiKeyData, ApiKeyStorage, type AuthError, BaseOAuthFlow, DesktopOAuthFlow, type DeviceCodeResponse, type GrantType, MCPClient, type MCPClientConfig, type OAuthConfig, type PKCEChallenge, TerminalOAuthFlow, type TokenResponse, TokenStorage };
|
|
16
|
+
export { BaseOAuthFlow, OAuthConfig, TerminalOAuthFlow, TokenResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,47 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
refresh_token?: string;
|
|
4
|
-
expires_in: number;
|
|
5
|
-
token_type: string;
|
|
6
|
-
scope?: string;
|
|
7
|
-
issued_at?: number;
|
|
8
|
-
}
|
|
9
|
-
interface DeviceCodeResponse {
|
|
10
|
-
device_code: string;
|
|
11
|
-
user_code: string;
|
|
12
|
-
verification_uri: string;
|
|
13
|
-
verification_uri_complete?: string;
|
|
14
|
-
expires_in: number;
|
|
15
|
-
interval: number;
|
|
16
|
-
}
|
|
17
|
-
interface OAuthConfig {
|
|
18
|
-
clientId: string;
|
|
19
|
-
authBaseUrl?: string;
|
|
20
|
-
redirectUri?: string;
|
|
21
|
-
scope?: string;
|
|
22
|
-
}
|
|
23
|
-
interface AuthError {
|
|
24
|
-
error: string;
|
|
25
|
-
error_description?: string;
|
|
26
|
-
}
|
|
27
|
-
type GrantType = 'authorization_code' | 'urn:ietf:params:oauth:grant-type:device_code' | 'refresh_token';
|
|
28
|
-
interface PKCEChallenge {
|
|
29
|
-
codeVerifier: string;
|
|
30
|
-
codeChallenge: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
declare abstract class BaseOAuthFlow {
|
|
34
|
-
protected readonly clientId: string;
|
|
35
|
-
protected readonly authBaseUrl: string;
|
|
36
|
-
protected readonly scope: string;
|
|
37
|
-
constructor(config: OAuthConfig);
|
|
38
|
-
abstract authenticate(): Promise<TokenResponse>;
|
|
39
|
-
protected makeTokenRequest(body: Record<string, string>): Promise<TokenResponse>;
|
|
40
|
-
protected generateState(): string;
|
|
41
|
-
protected base64URLEncode(buffer: ArrayBuffer | Uint8Array): string;
|
|
42
|
-
refreshToken(refreshToken: string): Promise<TokenResponse>;
|
|
43
|
-
revokeToken(token: string, tokenType?: 'access_token' | 'refresh_token'): Promise<void>;
|
|
44
|
-
}
|
|
1
|
+
import { B as BaseOAuthFlow, O as OAuthConfig, T as TokenResponse } from './browser-CUJNgghM.js';
|
|
2
|
+
export { A as ApiKeyData, c as ApiKeyStorage, e as ApiKeyStorageWeb, h as AuthError, D as DesktopOAuthFlow, g as DeviceCodeResponse, G as GrantType, f as MCPClient, M as MCPClientConfig, P as PKCEChallenge, b as TokenStorage, a as TokenStorageAdapter, d as TokenStorageWeb } from './browser-CUJNgghM.js';
|
|
45
3
|
|
|
46
4
|
declare class TerminalOAuthFlow extends BaseOAuthFlow {
|
|
47
5
|
private pollInterval;
|
|
@@ -55,153 +13,4 @@ declare class TerminalOAuthFlow extends BaseOAuthFlow {
|
|
|
55
13
|
private checkDeviceCode;
|
|
56
14
|
}
|
|
57
15
|
|
|
58
|
-
|
|
59
|
-
private readonly redirectUri;
|
|
60
|
-
private authWindow;
|
|
61
|
-
constructor(config: OAuthConfig);
|
|
62
|
-
authenticate(): Promise<TokenResponse>;
|
|
63
|
-
private generatePKCEChallenge;
|
|
64
|
-
private generateCodeVerifier;
|
|
65
|
-
private generateCodeChallenge;
|
|
66
|
-
private buildAuthorizationUrl;
|
|
67
|
-
private openAuthWindow;
|
|
68
|
-
private openBrowserWindow;
|
|
69
|
-
private openElectronWindow;
|
|
70
|
-
private exchangeCodeForToken;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
declare class TokenStorage {
|
|
74
|
-
private readonly storageKey;
|
|
75
|
-
private readonly webEncryptionKeyStorage;
|
|
76
|
-
private keytar;
|
|
77
|
-
constructor();
|
|
78
|
-
store(tokens: TokenResponse): Promise<void>;
|
|
79
|
-
retrieve(): Promise<TokenResponse | null>;
|
|
80
|
-
clear(): Promise<void>;
|
|
81
|
-
isTokenExpired(tokens: TokenResponse & {
|
|
82
|
-
issued_at?: number;
|
|
83
|
-
}): boolean;
|
|
84
|
-
private storeToFile;
|
|
85
|
-
private retrieveFromFile;
|
|
86
|
-
private deleteFile;
|
|
87
|
-
private getFileEncryptionKey;
|
|
88
|
-
private encrypt;
|
|
89
|
-
private decrypt;
|
|
90
|
-
private isNode;
|
|
91
|
-
private isElectron;
|
|
92
|
-
private isMobile;
|
|
93
|
-
private getWebEncryptionKey;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* API Key Storage Service
|
|
98
|
-
* Secure multi-platform API key storage with encryption
|
|
99
|
-
* Supports Node.js, Electron, Web, and Mobile environments
|
|
100
|
-
*/
|
|
101
|
-
interface ApiKeyData {
|
|
102
|
-
apiKey: string;
|
|
103
|
-
organizationId?: string;
|
|
104
|
-
userId?: string;
|
|
105
|
-
environment?: 'development' | 'staging' | 'production';
|
|
106
|
-
createdAt?: string;
|
|
107
|
-
expiresAt?: string;
|
|
108
|
-
metadata?: Record<string, unknown>;
|
|
109
|
-
}
|
|
110
|
-
declare class ApiKeyStorage {
|
|
111
|
-
private readonly storageKey;
|
|
112
|
-
private readonly legacyConfigKey;
|
|
113
|
-
private readonly webEncryptionKeyStorage;
|
|
114
|
-
private keytar;
|
|
115
|
-
private migrationCompleted;
|
|
116
|
-
constructor();
|
|
117
|
-
/**
|
|
118
|
-
* Initialize and migrate from legacy storage if needed
|
|
119
|
-
*/
|
|
120
|
-
initialize(): Promise<void>;
|
|
121
|
-
/**
|
|
122
|
-
* Store API key securely
|
|
123
|
-
*/
|
|
124
|
-
store(data: ApiKeyData): Promise<void>;
|
|
125
|
-
/**
|
|
126
|
-
* Retrieve API key from secure storage
|
|
127
|
-
*/
|
|
128
|
-
retrieve(): Promise<ApiKeyData | null>;
|
|
129
|
-
/**
|
|
130
|
-
* Get just the API key string (convenience method)
|
|
131
|
-
*/
|
|
132
|
-
getApiKey(): Promise<string | null>;
|
|
133
|
-
/**
|
|
134
|
-
* Check if API key exists
|
|
135
|
-
*/
|
|
136
|
-
hasApiKey(): Promise<boolean>;
|
|
137
|
-
/**
|
|
138
|
-
* Clear API key from storage
|
|
139
|
-
*/
|
|
140
|
-
clear(): Promise<void>;
|
|
141
|
-
/**
|
|
142
|
-
* Check if API key is expired
|
|
143
|
-
*/
|
|
144
|
-
isExpired(data: ApiKeyData): boolean;
|
|
145
|
-
/**
|
|
146
|
-
* Update API key metadata without changing the key itself
|
|
147
|
-
*/
|
|
148
|
-
updateMetadata(metadata: Record<string, unknown>): Promise<void>;
|
|
149
|
-
/**
|
|
150
|
-
* Migrate from legacy configuration storage
|
|
151
|
-
*/
|
|
152
|
-
private migrateFromLegacyIfNeeded;
|
|
153
|
-
private storeToFile;
|
|
154
|
-
private retrieveFromFile;
|
|
155
|
-
private deleteFile;
|
|
156
|
-
private retrieveLegacyFromFile;
|
|
157
|
-
private deleteLegacyFile;
|
|
158
|
-
private getFileEncryptionKey;
|
|
159
|
-
private encrypt;
|
|
160
|
-
private decrypt;
|
|
161
|
-
private getWebEncryptionKey;
|
|
162
|
-
private isNode;
|
|
163
|
-
private isElectron;
|
|
164
|
-
private isMobile;
|
|
165
|
-
/**
|
|
166
|
-
* Normalize API keys to a SHA-256 hex digest.
|
|
167
|
-
* Accepts pre-hashed input and lowercases it to prevent double hashing.
|
|
168
|
-
*/
|
|
169
|
-
private normalizeApiKey;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
interface MCPClientConfig extends Partial<OAuthConfig> {
|
|
173
|
-
mcpEndpoint?: string;
|
|
174
|
-
autoRefresh?: boolean;
|
|
175
|
-
}
|
|
176
|
-
declare class MCPClient {
|
|
177
|
-
private tokenStorage;
|
|
178
|
-
private authFlow;
|
|
179
|
-
private config;
|
|
180
|
-
private ws;
|
|
181
|
-
private eventSource;
|
|
182
|
-
private accessToken;
|
|
183
|
-
private refreshTimer;
|
|
184
|
-
constructor(config?: MCPClientConfig);
|
|
185
|
-
connect(): Promise<void>;
|
|
186
|
-
private authenticate;
|
|
187
|
-
private ensureAccessToken;
|
|
188
|
-
private scheduleTokenRefresh;
|
|
189
|
-
private establishConnection;
|
|
190
|
-
private connectWebSocket;
|
|
191
|
-
private connectSSE;
|
|
192
|
-
private handleMessage;
|
|
193
|
-
private reconnect;
|
|
194
|
-
request<T = unknown>(method: string, params?: unknown): Promise<T>;
|
|
195
|
-
disconnect(): void;
|
|
196
|
-
logout(): Promise<void>;
|
|
197
|
-
private isTerminal;
|
|
198
|
-
private isElectron;
|
|
199
|
-
private generateId;
|
|
200
|
-
createMemory<T = unknown>(title: string, content: string, options?: unknown): Promise<T>;
|
|
201
|
-
searchMemories<T = unknown>(query: string, options?: unknown): Promise<T[]>;
|
|
202
|
-
getMemory<T = unknown>(id: string): Promise<T>;
|
|
203
|
-
updateMemory<T = unknown>(id: string, updates: Partial<T>): Promise<T>;
|
|
204
|
-
deleteMemory(id: string): Promise<void>;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
export { type ApiKeyData, ApiKeyStorage, type AuthError, BaseOAuthFlow, DesktopOAuthFlow, type DeviceCodeResponse, type GrantType, MCPClient, type MCPClientConfig, type OAuthConfig, type PKCEChallenge, TerminalOAuthFlow, type TokenResponse, TokenStorage };
|
|
16
|
+
export { BaseOAuthFlow, OAuthConfig, TerminalOAuthFlow, TokenResponse };
|