@lanonasis/oauth-client 1.2.1 → 1.2.3

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/index.d.cts CHANGED
@@ -1,47 +1,5 @@
1
- interface TokenResponse {
2
- access_token: string;
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, b as TokenResponse, T as TokenStorageAdapter } from './api-key-storage-web-DannE11B.cjs';
2
+ export { f as ApiKeyData, g as ApiKeyStorage, A as ApiKeyStorageWeb, d as AuthError, D as DesktopOAuthFlow, c as DeviceCodeResponse, G as GrantType, P as PKCEChallenge, e as TokenStorage, a as TokenStorageWeb } from './api-key-storage-web-DannE11B.cjs';
45
3
 
46
4
  declare class TerminalOAuthFlow extends BaseOAuthFlow {
47
5
  private pollInterval;
@@ -55,128 +13,17 @@ declare class TerminalOAuthFlow extends BaseOAuthFlow {
55
13
  private checkDeviceCode;
56
14
  }
57
15
 
58
- declare class DesktopOAuthFlow extends BaseOAuthFlow {
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
16
  interface MCPClientConfig extends Partial<OAuthConfig> {
173
17
  mcpEndpoint?: string;
174
18
  autoRefresh?: boolean;
19
+ apiKey?: string;
20
+ tokenStorage?: TokenStorageAdapter;
175
21
  }
176
22
  declare class MCPClient {
177
23
  private tokenStorage;
178
24
  private authFlow;
179
25
  private config;
26
+ private authMode;
180
27
  private ws;
181
28
  private eventSource;
182
29
  private accessToken;
@@ -204,4 +51,4 @@ declare class MCPClient {
204
51
  deleteMemory(id: string): Promise<void>;
205
52
  }
206
53
 
207
- export { type ApiKeyData, ApiKeyStorage, type AuthError, BaseOAuthFlow, DesktopOAuthFlow, type DeviceCodeResponse, type GrantType, MCPClient, type MCPClientConfig, type OAuthConfig, type PKCEChallenge, TerminalOAuthFlow, type TokenResponse, TokenStorage };
54
+ export { BaseOAuthFlow, MCPClient, type MCPClientConfig, OAuthConfig, TerminalOAuthFlow, TokenResponse, TokenStorageAdapter };
package/dist/index.d.ts CHANGED
@@ -1,47 +1,5 @@
1
- interface TokenResponse {
2
- access_token: string;
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, b as TokenResponse, T as TokenStorageAdapter } from './api-key-storage-web-DannE11B.js';
2
+ export { f as ApiKeyData, g as ApiKeyStorage, A as ApiKeyStorageWeb, d as AuthError, D as DesktopOAuthFlow, c as DeviceCodeResponse, G as GrantType, P as PKCEChallenge, e as TokenStorage, a as TokenStorageWeb } from './api-key-storage-web-DannE11B.js';
45
3
 
46
4
  declare class TerminalOAuthFlow extends BaseOAuthFlow {
47
5
  private pollInterval;
@@ -55,128 +13,17 @@ declare class TerminalOAuthFlow extends BaseOAuthFlow {
55
13
  private checkDeviceCode;
56
14
  }
57
15
 
58
- declare class DesktopOAuthFlow extends BaseOAuthFlow {
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
16
  interface MCPClientConfig extends Partial<OAuthConfig> {
173
17
  mcpEndpoint?: string;
174
18
  autoRefresh?: boolean;
19
+ apiKey?: string;
20
+ tokenStorage?: TokenStorageAdapter;
175
21
  }
176
22
  declare class MCPClient {
177
23
  private tokenStorage;
178
24
  private authFlow;
179
25
  private config;
26
+ private authMode;
180
27
  private ws;
181
28
  private eventSource;
182
29
  private accessToken;
@@ -204,4 +51,4 @@ declare class MCPClient {
204
51
  deleteMemory(id: string): Promise<void>;
205
52
  }
206
53
 
207
- export { type ApiKeyData, ApiKeyStorage, type AuthError, BaseOAuthFlow, DesktopOAuthFlow, type DeviceCodeResponse, type GrantType, MCPClient, type MCPClientConfig, type OAuthConfig, type PKCEChallenge, TerminalOAuthFlow, type TokenResponse, TokenStorage };
54
+ export { BaseOAuthFlow, MCPClient, type MCPClientConfig, OAuthConfig, TerminalOAuthFlow, TokenResponse, TokenStorageAdapter };