@insforge/sdk 1.0.1-refresh.2 → 1.0.1-refresh.4
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.mts +32 -110
- package/dist/index.d.ts +32 -110
- package/dist/index.js +106 -175
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +104 -170
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -115,7 +115,7 @@ declare class HttpClient {
|
|
|
115
115
|
*
|
|
116
116
|
* Implements the Strategy Pattern for token storage:
|
|
117
117
|
* - SecureSessionStorage: In-memory tokens + httpOnly cookie refresh (XSS-resistant)
|
|
118
|
-
* -
|
|
118
|
+
* - LocalSessionStorage: localStorage-based storage (legacy/fallback)
|
|
119
119
|
*/
|
|
120
120
|
|
|
121
121
|
/**
|
|
@@ -147,7 +147,7 @@ interface SessionStorageStrategy {
|
|
|
147
147
|
*
|
|
148
148
|
* Stores access token in memory only (cleared on page refresh).
|
|
149
149
|
* Refresh token is stored in httpOnly cookie by the backend.
|
|
150
|
-
*
|
|
150
|
+
* The `isAuthenticated` cookie is set by the backend to signal that a refresh token exists.
|
|
151
151
|
*
|
|
152
152
|
* Security benefits:
|
|
153
153
|
* - Access token not accessible to XSS attacks (in memory only)
|
|
@@ -165,11 +165,10 @@ declare class SecureSessionStorage implements SessionStorageStrategy {
|
|
|
165
165
|
setUser(user: UserSchema): void;
|
|
166
166
|
clearSession(): void;
|
|
167
167
|
shouldAttemptRefresh(): boolean;
|
|
168
|
-
private setAuthFlag;
|
|
169
168
|
private hasAuthFlag;
|
|
170
169
|
}
|
|
171
170
|
/**
|
|
172
|
-
*
|
|
171
|
+
* Local Session Storage Strategy
|
|
173
172
|
*
|
|
174
173
|
* Stores tokens in localStorage for persistence across page reloads.
|
|
175
174
|
* Used for legacy backends or environments where httpOnly cookies aren't available.
|
|
@@ -177,8 +176,8 @@ declare class SecureSessionStorage implements SessionStorageStrategy {
|
|
|
177
176
|
* Note: This approach exposes tokens to XSS attacks. Use SecureSessionStorage
|
|
178
177
|
* when possible.
|
|
179
178
|
*/
|
|
180
|
-
declare class
|
|
181
|
-
readonly strategyId = "
|
|
179
|
+
declare class LocalSessionStorage implements SessionStorageStrategy {
|
|
180
|
+
readonly strategyId = "local";
|
|
182
181
|
private storage;
|
|
183
182
|
constructor(storage?: TokenStorage);
|
|
184
183
|
saveSession(session: AuthSession): void;
|
|
@@ -191,64 +190,6 @@ declare class PersistentSessionStorage implements SessionStorageStrategy {
|
|
|
191
190
|
shouldAttemptRefresh(): boolean;
|
|
192
191
|
}
|
|
193
192
|
|
|
194
|
-
/**
|
|
195
|
-
* Backend Capability Discovery for InsForge SDK
|
|
196
|
-
*
|
|
197
|
-
* Discovers backend capabilities via the /api/health endpoint
|
|
198
|
-
* and creates appropriate storage strategies based on those capabilities.
|
|
199
|
-
*/
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Backend capabilities returned from /api/health
|
|
203
|
-
*/
|
|
204
|
-
interface BackendCapabilities {
|
|
205
|
-
/** Whether backend supports secure httpOnly cookie storage for refresh tokens */
|
|
206
|
-
secureSessionStorage: boolean;
|
|
207
|
-
/** Whether backend supports token refresh endpoint */
|
|
208
|
-
refreshTokens: boolean;
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Discover backend capabilities from the /api/health endpoint
|
|
212
|
-
*
|
|
213
|
-
* This is the primary method for determining which features the backend supports.
|
|
214
|
-
* The SDK uses this information to select appropriate storage strategies.
|
|
215
|
-
*
|
|
216
|
-
* @param baseUrl - The backend base URL
|
|
217
|
-
* @param fetchImpl - Optional custom fetch implementation
|
|
218
|
-
* @returns Backend capabilities object
|
|
219
|
-
*
|
|
220
|
-
* @example
|
|
221
|
-
* ```typescript
|
|
222
|
-
* const capabilities = await discoverCapabilities('https://api.example.com');
|
|
223
|
-
* if (capabilities.secureSessionStorage) {
|
|
224
|
-
* // Use secure storage strategy
|
|
225
|
-
* }
|
|
226
|
-
* ```
|
|
227
|
-
*/
|
|
228
|
-
declare function discoverCapabilities(baseUrl: string, fetchImpl?: typeof fetch): Promise<BackendCapabilities>;
|
|
229
|
-
/**
|
|
230
|
-
* Create the appropriate session storage strategy based on backend capabilities
|
|
231
|
-
*
|
|
232
|
-
* This is the factory function that implements the Strategy Pattern.
|
|
233
|
-
* It selects the storage implementation based on what the backend supports.
|
|
234
|
-
*
|
|
235
|
-
* @param capabilities - Backend capabilities from discoverCapabilities()
|
|
236
|
-
* @param storage - Optional custom storage adapter (for PersistentSessionStorage)
|
|
237
|
-
* @returns Appropriate SessionStorageStrategy implementation
|
|
238
|
-
*
|
|
239
|
-
* @example
|
|
240
|
-
* ```typescript
|
|
241
|
-
* const capabilities = await discoverCapabilities(baseUrl);
|
|
242
|
-
* const storage = createSessionStorage(capabilities);
|
|
243
|
-
* storage.saveSession({ accessToken: '...', user: {...} });
|
|
244
|
-
* ```
|
|
245
|
-
*/
|
|
246
|
-
declare function createSessionStorage(capabilities: BackendCapabilities, storage?: TokenStorage): SessionStorageStrategy;
|
|
247
|
-
/**
|
|
248
|
-
* Get default capabilities (useful for testing or manual override)
|
|
249
|
-
*/
|
|
250
|
-
declare function getDefaultCapabilities(): BackendCapabilities;
|
|
251
|
-
|
|
252
193
|
/**
|
|
253
194
|
* Token Manager for InsForge SDK
|
|
254
195
|
*
|
|
@@ -260,14 +201,14 @@ declare function getDefaultCapabilities(): BackendCapabilities;
|
|
|
260
201
|
* TokenManager - Manages session storage using the Strategy Pattern
|
|
261
202
|
*
|
|
262
203
|
* The actual storage implementation is delegated to a SessionStorageStrategy.
|
|
263
|
-
* By default, uses
|
|
204
|
+
* By default, uses LocalSessionStorage until a strategy is explicitly set
|
|
264
205
|
* via setStrategy() during client initialization.
|
|
265
206
|
*/
|
|
266
207
|
declare class TokenManager {
|
|
267
208
|
private strategy;
|
|
268
209
|
/**
|
|
269
210
|
* Create a new TokenManager
|
|
270
|
-
* @param storage - Optional custom storage adapter (used for initial
|
|
211
|
+
* @param storage - Optional custom storage adapter (used for initial LocalSessionStorage)
|
|
271
212
|
*/
|
|
272
213
|
constructor(storage?: TokenStorage);
|
|
273
214
|
/**
|
|
@@ -338,28 +279,35 @@ declare class Auth {
|
|
|
338
279
|
private http;
|
|
339
280
|
private tokenManager;
|
|
340
281
|
private database;
|
|
341
|
-
private initPromise;
|
|
342
282
|
constructor(http: HttpClient, tokenManager: TokenManager);
|
|
343
283
|
/**
|
|
344
|
-
* Check if
|
|
345
|
-
* Used to determine appropriate HTTP status code (401 vs 500)
|
|
284
|
+
* Check if the isAuthenticated cookie flag exists
|
|
346
285
|
*/
|
|
347
|
-
private
|
|
286
|
+
private hasAuthenticatedCookie;
|
|
348
287
|
/**
|
|
349
|
-
*
|
|
350
|
-
*
|
|
288
|
+
* Switch to SecureSessionStorage (cookie-based auth)
|
|
289
|
+
* Called when we detect backend supports secure cookie mode
|
|
290
|
+
* @internal
|
|
351
291
|
*/
|
|
352
|
-
|
|
292
|
+
_switchToSecureStorage(): void;
|
|
353
293
|
/**
|
|
354
|
-
*
|
|
294
|
+
* Switch to LocalSessionStorage (localStorage-based auth)
|
|
295
|
+
* Called when cookie-based auth fails (fallback)
|
|
296
|
+
* @internal
|
|
355
297
|
*/
|
|
356
|
-
|
|
298
|
+
_switchToLocalStorage(): void;
|
|
357
299
|
/**
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
*
|
|
300
|
+
* Detect storage strategy after successful auth
|
|
301
|
+
* Checks for isAuthenticated cookie to determine backend mode
|
|
302
|
+
* @internal
|
|
361
303
|
*/
|
|
362
|
-
private
|
|
304
|
+
private _detectStorageAfterAuth;
|
|
305
|
+
/**
|
|
306
|
+
* Automatically detect and handle OAuth callback parameters in the URL
|
|
307
|
+
* This runs on initialization to seamlessly complete the OAuth flow
|
|
308
|
+
* Matches the backend's OAuth callback response (backend/src/api/routes/auth.ts:540-544)
|
|
309
|
+
*/
|
|
310
|
+
detectAuthCallback(): void;
|
|
363
311
|
/**
|
|
364
312
|
* Sign up a new user
|
|
365
313
|
*/
|
|
@@ -425,6 +373,9 @@ declare class Auth {
|
|
|
425
373
|
/**
|
|
426
374
|
* Get the current user with full profile information
|
|
427
375
|
* Returns both auth info (id, email, role) and profile data (dynamic fields from users table)
|
|
376
|
+
*
|
|
377
|
+
* In secure session mode (httpOnly cookie), this method will automatically attempt
|
|
378
|
+
* to refresh the session if no access token is available (e.g., after page reload).
|
|
428
379
|
*/
|
|
429
380
|
getCurrentUser(): Promise<{
|
|
430
381
|
data: {
|
|
@@ -829,11 +780,8 @@ declare class Functions {
|
|
|
829
780
|
* baseUrl: 'http://localhost:7130'
|
|
830
781
|
* });
|
|
831
782
|
*
|
|
832
|
-
* // Wait for initialization (optional but recommended)
|
|
833
|
-
* await client.initialize();
|
|
834
|
-
*
|
|
835
783
|
* // Authentication
|
|
836
|
-
* const
|
|
784
|
+
* const { data, error } = await client.auth.signUp({
|
|
837
785
|
* email: 'user@example.com',
|
|
838
786
|
* password: 'password123',
|
|
839
787
|
* name: 'John Doe'
|
|
@@ -862,30 +810,12 @@ declare class Functions {
|
|
|
862
810
|
declare class InsForgeClient {
|
|
863
811
|
private http;
|
|
864
812
|
private tokenManager;
|
|
865
|
-
private initialized;
|
|
866
|
-
private initializationPromise;
|
|
867
|
-
private capabilities;
|
|
868
813
|
readonly auth: Auth;
|
|
869
814
|
readonly database: Database;
|
|
870
815
|
readonly storage: Storage;
|
|
871
816
|
readonly ai: AI;
|
|
872
817
|
readonly functions: Functions;
|
|
873
818
|
constructor(config?: InsForgeConfig);
|
|
874
|
-
/**
|
|
875
|
-
* Initialize the client by discovering backend capabilities
|
|
876
|
-
* This is called automatically on construction but can be awaited for guaranteed initialization
|
|
877
|
-
*
|
|
878
|
-
* @example
|
|
879
|
-
* ```typescript
|
|
880
|
-
* const client = new InsForgeClient({ baseUrl: 'https://api.example.com' });
|
|
881
|
-
* await client.initialize(); // Wait for capability discovery
|
|
882
|
-
* ```
|
|
883
|
-
*/
|
|
884
|
-
initialize(): Promise<void>;
|
|
885
|
-
/**
|
|
886
|
-
* Internal async initialization - discovers capabilities and configures storage strategy
|
|
887
|
-
*/
|
|
888
|
-
private initializeAsync;
|
|
889
819
|
/**
|
|
890
820
|
* Get the underlying HTTP client for custom requests
|
|
891
821
|
*
|
|
@@ -896,18 +826,10 @@ declare class InsForgeClient {
|
|
|
896
826
|
* ```
|
|
897
827
|
*/
|
|
898
828
|
getHttpClient(): HttpClient;
|
|
899
|
-
/**
|
|
900
|
-
* Get the discovered backend capabilities
|
|
901
|
-
*/
|
|
902
|
-
getCapabilities(): BackendCapabilities | null;
|
|
903
829
|
/**
|
|
904
830
|
* Get the current storage strategy identifier
|
|
905
831
|
*/
|
|
906
832
|
getStorageStrategy(): string;
|
|
907
|
-
/**
|
|
908
|
-
* Check if the client has been fully initialized
|
|
909
|
-
*/
|
|
910
|
-
isInitialized(): boolean;
|
|
911
833
|
}
|
|
912
834
|
|
|
913
835
|
/**
|
|
@@ -918,4 +840,4 @@ declare class InsForgeClient {
|
|
|
918
840
|
|
|
919
841
|
declare function createClient(config: InsForgeConfig): InsForgeClient;
|
|
920
842
|
|
|
921
|
-
export { AI, type ApiError, Auth, type AuthSession, type
|
|
843
|
+
export { AI, type ApiError, Auth, type AuthSession, type InsForgeConfig as ClientOptions, Database, type FunctionInvokeOptions, Functions, HttpClient, InsForgeClient, type InsForgeConfig, InsForgeError, LocalSessionStorage, type ProfileData, SecureSessionStorage, type SessionStorageStrategy, Storage, StorageBucket, type StorageResponse, TokenManager, type TokenStorage, type UpdateProfileData, createClient, InsForgeClient as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -115,7 +115,7 @@ declare class HttpClient {
|
|
|
115
115
|
*
|
|
116
116
|
* Implements the Strategy Pattern for token storage:
|
|
117
117
|
* - SecureSessionStorage: In-memory tokens + httpOnly cookie refresh (XSS-resistant)
|
|
118
|
-
* -
|
|
118
|
+
* - LocalSessionStorage: localStorage-based storage (legacy/fallback)
|
|
119
119
|
*/
|
|
120
120
|
|
|
121
121
|
/**
|
|
@@ -147,7 +147,7 @@ interface SessionStorageStrategy {
|
|
|
147
147
|
*
|
|
148
148
|
* Stores access token in memory only (cleared on page refresh).
|
|
149
149
|
* Refresh token is stored in httpOnly cookie by the backend.
|
|
150
|
-
*
|
|
150
|
+
* The `isAuthenticated` cookie is set by the backend to signal that a refresh token exists.
|
|
151
151
|
*
|
|
152
152
|
* Security benefits:
|
|
153
153
|
* - Access token not accessible to XSS attacks (in memory only)
|
|
@@ -165,11 +165,10 @@ declare class SecureSessionStorage implements SessionStorageStrategy {
|
|
|
165
165
|
setUser(user: UserSchema): void;
|
|
166
166
|
clearSession(): void;
|
|
167
167
|
shouldAttemptRefresh(): boolean;
|
|
168
|
-
private setAuthFlag;
|
|
169
168
|
private hasAuthFlag;
|
|
170
169
|
}
|
|
171
170
|
/**
|
|
172
|
-
*
|
|
171
|
+
* Local Session Storage Strategy
|
|
173
172
|
*
|
|
174
173
|
* Stores tokens in localStorage for persistence across page reloads.
|
|
175
174
|
* Used for legacy backends or environments where httpOnly cookies aren't available.
|
|
@@ -177,8 +176,8 @@ declare class SecureSessionStorage implements SessionStorageStrategy {
|
|
|
177
176
|
* Note: This approach exposes tokens to XSS attacks. Use SecureSessionStorage
|
|
178
177
|
* when possible.
|
|
179
178
|
*/
|
|
180
|
-
declare class
|
|
181
|
-
readonly strategyId = "
|
|
179
|
+
declare class LocalSessionStorage implements SessionStorageStrategy {
|
|
180
|
+
readonly strategyId = "local";
|
|
182
181
|
private storage;
|
|
183
182
|
constructor(storage?: TokenStorage);
|
|
184
183
|
saveSession(session: AuthSession): void;
|
|
@@ -191,64 +190,6 @@ declare class PersistentSessionStorage implements SessionStorageStrategy {
|
|
|
191
190
|
shouldAttemptRefresh(): boolean;
|
|
192
191
|
}
|
|
193
192
|
|
|
194
|
-
/**
|
|
195
|
-
* Backend Capability Discovery for InsForge SDK
|
|
196
|
-
*
|
|
197
|
-
* Discovers backend capabilities via the /api/health endpoint
|
|
198
|
-
* and creates appropriate storage strategies based on those capabilities.
|
|
199
|
-
*/
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Backend capabilities returned from /api/health
|
|
203
|
-
*/
|
|
204
|
-
interface BackendCapabilities {
|
|
205
|
-
/** Whether backend supports secure httpOnly cookie storage for refresh tokens */
|
|
206
|
-
secureSessionStorage: boolean;
|
|
207
|
-
/** Whether backend supports token refresh endpoint */
|
|
208
|
-
refreshTokens: boolean;
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Discover backend capabilities from the /api/health endpoint
|
|
212
|
-
*
|
|
213
|
-
* This is the primary method for determining which features the backend supports.
|
|
214
|
-
* The SDK uses this information to select appropriate storage strategies.
|
|
215
|
-
*
|
|
216
|
-
* @param baseUrl - The backend base URL
|
|
217
|
-
* @param fetchImpl - Optional custom fetch implementation
|
|
218
|
-
* @returns Backend capabilities object
|
|
219
|
-
*
|
|
220
|
-
* @example
|
|
221
|
-
* ```typescript
|
|
222
|
-
* const capabilities = await discoverCapabilities('https://api.example.com');
|
|
223
|
-
* if (capabilities.secureSessionStorage) {
|
|
224
|
-
* // Use secure storage strategy
|
|
225
|
-
* }
|
|
226
|
-
* ```
|
|
227
|
-
*/
|
|
228
|
-
declare function discoverCapabilities(baseUrl: string, fetchImpl?: typeof fetch): Promise<BackendCapabilities>;
|
|
229
|
-
/**
|
|
230
|
-
* Create the appropriate session storage strategy based on backend capabilities
|
|
231
|
-
*
|
|
232
|
-
* This is the factory function that implements the Strategy Pattern.
|
|
233
|
-
* It selects the storage implementation based on what the backend supports.
|
|
234
|
-
*
|
|
235
|
-
* @param capabilities - Backend capabilities from discoverCapabilities()
|
|
236
|
-
* @param storage - Optional custom storage adapter (for PersistentSessionStorage)
|
|
237
|
-
* @returns Appropriate SessionStorageStrategy implementation
|
|
238
|
-
*
|
|
239
|
-
* @example
|
|
240
|
-
* ```typescript
|
|
241
|
-
* const capabilities = await discoverCapabilities(baseUrl);
|
|
242
|
-
* const storage = createSessionStorage(capabilities);
|
|
243
|
-
* storage.saveSession({ accessToken: '...', user: {...} });
|
|
244
|
-
* ```
|
|
245
|
-
*/
|
|
246
|
-
declare function createSessionStorage(capabilities: BackendCapabilities, storage?: TokenStorage): SessionStorageStrategy;
|
|
247
|
-
/**
|
|
248
|
-
* Get default capabilities (useful for testing or manual override)
|
|
249
|
-
*/
|
|
250
|
-
declare function getDefaultCapabilities(): BackendCapabilities;
|
|
251
|
-
|
|
252
193
|
/**
|
|
253
194
|
* Token Manager for InsForge SDK
|
|
254
195
|
*
|
|
@@ -260,14 +201,14 @@ declare function getDefaultCapabilities(): BackendCapabilities;
|
|
|
260
201
|
* TokenManager - Manages session storage using the Strategy Pattern
|
|
261
202
|
*
|
|
262
203
|
* The actual storage implementation is delegated to a SessionStorageStrategy.
|
|
263
|
-
* By default, uses
|
|
204
|
+
* By default, uses LocalSessionStorage until a strategy is explicitly set
|
|
264
205
|
* via setStrategy() during client initialization.
|
|
265
206
|
*/
|
|
266
207
|
declare class TokenManager {
|
|
267
208
|
private strategy;
|
|
268
209
|
/**
|
|
269
210
|
* Create a new TokenManager
|
|
270
|
-
* @param storage - Optional custom storage adapter (used for initial
|
|
211
|
+
* @param storage - Optional custom storage adapter (used for initial LocalSessionStorage)
|
|
271
212
|
*/
|
|
272
213
|
constructor(storage?: TokenStorage);
|
|
273
214
|
/**
|
|
@@ -338,28 +279,35 @@ declare class Auth {
|
|
|
338
279
|
private http;
|
|
339
280
|
private tokenManager;
|
|
340
281
|
private database;
|
|
341
|
-
private initPromise;
|
|
342
282
|
constructor(http: HttpClient, tokenManager: TokenManager);
|
|
343
283
|
/**
|
|
344
|
-
* Check if
|
|
345
|
-
* Used to determine appropriate HTTP status code (401 vs 500)
|
|
284
|
+
* Check if the isAuthenticated cookie flag exists
|
|
346
285
|
*/
|
|
347
|
-
private
|
|
286
|
+
private hasAuthenticatedCookie;
|
|
348
287
|
/**
|
|
349
|
-
*
|
|
350
|
-
*
|
|
288
|
+
* Switch to SecureSessionStorage (cookie-based auth)
|
|
289
|
+
* Called when we detect backend supports secure cookie mode
|
|
290
|
+
* @internal
|
|
351
291
|
*/
|
|
352
|
-
|
|
292
|
+
_switchToSecureStorage(): void;
|
|
353
293
|
/**
|
|
354
|
-
*
|
|
294
|
+
* Switch to LocalSessionStorage (localStorage-based auth)
|
|
295
|
+
* Called when cookie-based auth fails (fallback)
|
|
296
|
+
* @internal
|
|
355
297
|
*/
|
|
356
|
-
|
|
298
|
+
_switchToLocalStorage(): void;
|
|
357
299
|
/**
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
*
|
|
300
|
+
* Detect storage strategy after successful auth
|
|
301
|
+
* Checks for isAuthenticated cookie to determine backend mode
|
|
302
|
+
* @internal
|
|
361
303
|
*/
|
|
362
|
-
private
|
|
304
|
+
private _detectStorageAfterAuth;
|
|
305
|
+
/**
|
|
306
|
+
* Automatically detect and handle OAuth callback parameters in the URL
|
|
307
|
+
* This runs on initialization to seamlessly complete the OAuth flow
|
|
308
|
+
* Matches the backend's OAuth callback response (backend/src/api/routes/auth.ts:540-544)
|
|
309
|
+
*/
|
|
310
|
+
detectAuthCallback(): void;
|
|
363
311
|
/**
|
|
364
312
|
* Sign up a new user
|
|
365
313
|
*/
|
|
@@ -425,6 +373,9 @@ declare class Auth {
|
|
|
425
373
|
/**
|
|
426
374
|
* Get the current user with full profile information
|
|
427
375
|
* Returns both auth info (id, email, role) and profile data (dynamic fields from users table)
|
|
376
|
+
*
|
|
377
|
+
* In secure session mode (httpOnly cookie), this method will automatically attempt
|
|
378
|
+
* to refresh the session if no access token is available (e.g., after page reload).
|
|
428
379
|
*/
|
|
429
380
|
getCurrentUser(): Promise<{
|
|
430
381
|
data: {
|
|
@@ -829,11 +780,8 @@ declare class Functions {
|
|
|
829
780
|
* baseUrl: 'http://localhost:7130'
|
|
830
781
|
* });
|
|
831
782
|
*
|
|
832
|
-
* // Wait for initialization (optional but recommended)
|
|
833
|
-
* await client.initialize();
|
|
834
|
-
*
|
|
835
783
|
* // Authentication
|
|
836
|
-
* const
|
|
784
|
+
* const { data, error } = await client.auth.signUp({
|
|
837
785
|
* email: 'user@example.com',
|
|
838
786
|
* password: 'password123',
|
|
839
787
|
* name: 'John Doe'
|
|
@@ -862,30 +810,12 @@ declare class Functions {
|
|
|
862
810
|
declare class InsForgeClient {
|
|
863
811
|
private http;
|
|
864
812
|
private tokenManager;
|
|
865
|
-
private initialized;
|
|
866
|
-
private initializationPromise;
|
|
867
|
-
private capabilities;
|
|
868
813
|
readonly auth: Auth;
|
|
869
814
|
readonly database: Database;
|
|
870
815
|
readonly storage: Storage;
|
|
871
816
|
readonly ai: AI;
|
|
872
817
|
readonly functions: Functions;
|
|
873
818
|
constructor(config?: InsForgeConfig);
|
|
874
|
-
/**
|
|
875
|
-
* Initialize the client by discovering backend capabilities
|
|
876
|
-
* This is called automatically on construction but can be awaited for guaranteed initialization
|
|
877
|
-
*
|
|
878
|
-
* @example
|
|
879
|
-
* ```typescript
|
|
880
|
-
* const client = new InsForgeClient({ baseUrl: 'https://api.example.com' });
|
|
881
|
-
* await client.initialize(); // Wait for capability discovery
|
|
882
|
-
* ```
|
|
883
|
-
*/
|
|
884
|
-
initialize(): Promise<void>;
|
|
885
|
-
/**
|
|
886
|
-
* Internal async initialization - discovers capabilities and configures storage strategy
|
|
887
|
-
*/
|
|
888
|
-
private initializeAsync;
|
|
889
819
|
/**
|
|
890
820
|
* Get the underlying HTTP client for custom requests
|
|
891
821
|
*
|
|
@@ -896,18 +826,10 @@ declare class InsForgeClient {
|
|
|
896
826
|
* ```
|
|
897
827
|
*/
|
|
898
828
|
getHttpClient(): HttpClient;
|
|
899
|
-
/**
|
|
900
|
-
* Get the discovered backend capabilities
|
|
901
|
-
*/
|
|
902
|
-
getCapabilities(): BackendCapabilities | null;
|
|
903
829
|
/**
|
|
904
830
|
* Get the current storage strategy identifier
|
|
905
831
|
*/
|
|
906
832
|
getStorageStrategy(): string;
|
|
907
|
-
/**
|
|
908
|
-
* Check if the client has been fully initialized
|
|
909
|
-
*/
|
|
910
|
-
isInitialized(): boolean;
|
|
911
833
|
}
|
|
912
834
|
|
|
913
835
|
/**
|
|
@@ -918,4 +840,4 @@ declare class InsForgeClient {
|
|
|
918
840
|
|
|
919
841
|
declare function createClient(config: InsForgeConfig): InsForgeClient;
|
|
920
842
|
|
|
921
|
-
export { AI, type ApiError, Auth, type AuthSession, type
|
|
843
|
+
export { AI, type ApiError, Auth, type AuthSession, type InsForgeConfig as ClientOptions, Database, type FunctionInvokeOptions, Functions, HttpClient, InsForgeClient, type InsForgeConfig, InsForgeError, LocalSessionStorage, type ProfileData, SecureSessionStorage, type SessionStorageStrategy, Storage, StorageBucket, type StorageResponse, TokenManager, type TokenStorage, type UpdateProfileData, createClient, InsForgeClient as default };
|