@fluxbase/sdk 0.0.1-rc.26 → 0.0.1-rc.27

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
@@ -201,11 +201,24 @@ interface FileObject {
201
201
  * @deprecated Use FileObject instead. This alias is provided for backwards compatibility.
202
202
  */
203
203
  type StorageObject = FileObject;
204
+ /**
205
+ * Upload progress information
206
+ */
207
+ interface UploadProgress {
208
+ /** Number of bytes uploaded so far */
209
+ loaded: number;
210
+ /** Total number of bytes to upload */
211
+ total: number;
212
+ /** Upload percentage (0-100) */
213
+ percentage: number;
214
+ }
204
215
  interface UploadOptions {
205
216
  contentType?: string;
206
217
  metadata?: Record<string, string>;
207
218
  cacheControl?: string;
208
219
  upsert?: boolean;
220
+ /** Optional callback to track upload progress */
221
+ onUploadProgress?: (progress: UploadProgress) => void;
209
222
  }
210
223
  interface ListOptions {
211
224
  prefix?: string;
@@ -1302,21 +1315,28 @@ declare class FluxbaseAuth {
1302
1315
  private stateChangeListeners;
1303
1316
  constructor(fetch: FluxbaseFetch, autoRefresh?: boolean, persist?: boolean);
1304
1317
  /**
1305
- * Get the current session
1318
+ * Get the current session (Supabase-compatible)
1319
+ * Returns the session from the client-side cache without making a network request
1306
1320
  */
1307
- getSession(): AuthSession | null;
1321
+ getSession(): Promise<FluxbaseResponse<{
1322
+ session: AuthSession | null;
1323
+ }>>;
1308
1324
  /**
1309
- * Get the current user
1325
+ * Get the current user (Supabase-compatible)
1326
+ * Returns the user from the client-side session without making a network request
1327
+ * For server-side validation, use getCurrentUser() instead
1310
1328
  */
1311
- getUser(): User | null;
1329
+ getUser(): Promise<FluxbaseResponse<{
1330
+ user: User | null;
1331
+ }>>;
1312
1332
  /**
1313
1333
  * Get the current access token
1314
1334
  */
1315
1335
  getAccessToken(): string | null;
1316
1336
  /**
1317
- * Listen to auth state changes
1337
+ * Listen to auth state changes (Supabase-compatible)
1318
1338
  * @param callback - Function called when auth state changes
1319
- * @returns Subscription object with unsubscribe method
1339
+ * @returns Object containing subscription data
1320
1340
  *
1321
1341
  * @example
1322
1342
  * ```typescript
@@ -1328,7 +1348,11 @@ declare class FluxbaseAuth {
1328
1348
  * subscription.unsubscribe()
1329
1349
  * ```
1330
1350
  */
1331
- onAuthStateChange(callback: AuthStateChangeCallback): AuthSubscription;
1351
+ onAuthStateChange(callback: AuthStateChangeCallback): {
1352
+ data: {
1353
+ subscription: AuthSubscription;
1354
+ };
1355
+ };
1332
1356
  /**
1333
1357
  * Sign in with email and password
1334
1358
  * Returns AuthSession if successful, or SignInWith2FAResponse if 2FA is required
@@ -1349,9 +1373,13 @@ declare class FluxbaseAuth {
1349
1373
  */
1350
1374
  signOut(): Promise<VoidResponse>;
1351
1375
  /**
1352
- * Refresh the access token
1376
+ * Refresh the session (Supabase-compatible)
1377
+ * Returns a new session with refreshed tokens
1353
1378
  */
1354
- refreshToken(): Promise<SessionResponse>;
1379
+ refreshSession(): Promise<FluxbaseResponse<{
1380
+ session: AuthSession;
1381
+ user: User;
1382
+ }>>;
1355
1383
  /**
1356
1384
  * Get the current user from the server
1357
1385
  */
@@ -1361,9 +1389,15 @@ declare class FluxbaseAuth {
1361
1389
  */
1362
1390
  updateUser(data: Partial<Pick<User, "email" | "metadata">>): Promise<UserResponse>;
1363
1391
  /**
1364
- * Set the auth token manually
1392
+ * Set the session manually (Supabase-compatible)
1393
+ * Useful for restoring a session from storage or SSR scenarios
1394
+ * @param session - Object containing access_token and refresh_token
1395
+ * @returns Promise with session data
1365
1396
  */
1366
- setToken(token: string): void;
1397
+ setSession(session: {
1398
+ access_token: string;
1399
+ refresh_token: string;
1400
+ }): Promise<FluxbaseAuthResponse>;
1367
1401
  /**
1368
1402
  * Setup 2FA for the current user
1369
1403
  * Returns TOTP secret and QR code URL
@@ -1463,7 +1497,7 @@ declare class FluxbaseAuth {
1463
1497
  /**
1464
1498
  * Internal: Set the session and persist it
1465
1499
  */
1466
- private setSession;
1500
+ private setSessionInternal;
1467
1501
  /**
1468
1502
  * Internal: Clear the session
1469
1503
  */
@@ -1504,6 +1538,11 @@ declare class StorageBucket {
1504
1538
  } | null;
1505
1539
  error: Error | null;
1506
1540
  }>;
1541
+ /**
1542
+ * Upload with progress tracking using XMLHttpRequest
1543
+ * @private
1544
+ */
1545
+ private uploadWithProgress;
1507
1546
  /**
1508
1547
  * Download a file from the bucket
1509
1548
  * @param path - The path/key of the file
@@ -4465,4 +4504,4 @@ declare class FluxbaseClient<Database = any, _SchemaName extends string & keyof
4465
4504
  */
4466
4505
  declare function createClient<Database = any, SchemaName extends string & keyof Database = any>(fluxbaseUrl: string, fluxbaseKey: string, options?: FluxbaseClientOptions): FluxbaseClient<Database, SchemaName>;
4467
4506
 
4468
- export { type APIKey, APIKeysManager, type AcceptInvitationRequest, type AcceptInvitationResponse, type AdminAuthResponse, type AdminLoginRequest, type AdminMeResponse, type AdminRefreshRequest, type AdminRefreshResponse, type AdminSetupRequest, type AdminSetupStatusResponse, type AdminUser, type AppSettings, AppSettingsManager, type AuthResponse, type AuthSession, type AuthSettings, AuthSettingsManager, type AuthenticationSettings, type Column, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateColumnRequest, type CreateFunctionRequest, type CreateInvitationRequest, type CreateInvitationResponse, type CreateOAuthProviderRequest, type CreateOAuthProviderResponse, type CreateSchemaRequest, type CreateSchemaResponse, type CreateTableRequest, type CreateTableResponse, type CreateWebhookRequest, DDLManager, type DataResponse, type DeleteAPIKeyResponse, type DeleteOAuthProviderResponse, type DeleteTableResponse, type DeleteUserResponse, type DeleteWebhookResponse, type EdgeFunction, type EdgeFunctionExecution, type EmailSettings, type EmailTemplate, EmailTemplateManager, type EmailTemplateType, type EnrichedUser, type FeatureSettings, type FileObject, type FilterOperator, FluxbaseAdmin, FluxbaseAuth, type FluxbaseAuthResponse, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseFunctions, FluxbaseManagement, FluxbaseOAuth, FluxbaseRealtime, type FluxbaseResponse, FluxbaseSettings, FluxbaseStorage, type FunctionInvokeOptions, type GetImpersonationResponse, type HttpMethod, type ImpersonateAnonRequest, type ImpersonateServiceRequest, type ImpersonateUserRequest, ImpersonationManager, type ImpersonationSession, type ImpersonationTargetUser, type ImpersonationType, type Invitation, InvitationsManager, type InviteUserRequest, type InviteUserResponse, type ListAPIKeysResponse, type ListEmailTemplatesResponse, type ListImpersonationSessionsOptions, type ListImpersonationSessionsResponse, type ListInvitationsOptions, type ListInvitationsResponse, type ListOAuthProvidersResponse, type ListOptions, type ListSchemasResponse, type ListSystemSettingsResponse, type ListTablesResponse, type ListUsersOptions, type ListUsersResponse, type ListWebhookDeliveriesResponse, type ListWebhooksResponse, type MailgunSettings, type OAuthProvider, OAuthProviderManager, type OrderBy, type OrderDirection, type PostgresChangesConfig, type PostgrestError, type PostgrestResponse, QueryBuilder, type QueryFilter, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeMessage, type RealtimePostgresChangesPayload, type RequestOptions, type ResetUserPasswordResponse, type RevokeAPIKeyResponse, type RevokeInvitationResponse, type SESSettings, type SMTPSettings, type Schema, type SecuritySettings, type SendGridSettings, type SessionResponse, SettingsClient, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, type SupabaseAuthResponse, type SupabaseResponse, type SystemSetting, SystemSettingsManager, type Table, type TestEmailTemplateRequest, type TestWebhookResponse, type TwoFactorEnableResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorVerifyRequest, type UpdateAPIKeyRequest, type UpdateAppSettingsRequest, type UpdateAuthSettingsRequest, type UpdateAuthSettingsResponse, type UpdateEmailTemplateRequest, type UpdateFunctionRequest, type UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateSystemSettingRequest, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type User, type UserResponse, type ValidateInvitationResponse, type VoidResponse, type Webhook, type WebhookDelivery, WebhooksManager, createClient };
4507
+ export { type APIKey, APIKeysManager, type AcceptInvitationRequest, type AcceptInvitationResponse, type AdminAuthResponse, type AdminLoginRequest, type AdminMeResponse, type AdminRefreshRequest, type AdminRefreshResponse, type AdminSetupRequest, type AdminSetupStatusResponse, type AdminUser, type AppSettings, AppSettingsManager, type AuthResponse, type AuthSession, type AuthSettings, AuthSettingsManager, type AuthenticationSettings, type Column, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateColumnRequest, type CreateFunctionRequest, type CreateInvitationRequest, type CreateInvitationResponse, type CreateOAuthProviderRequest, type CreateOAuthProviderResponse, type CreateSchemaRequest, type CreateSchemaResponse, type CreateTableRequest, type CreateTableResponse, type CreateWebhookRequest, DDLManager, type DataResponse, type DeleteAPIKeyResponse, type DeleteOAuthProviderResponse, type DeleteTableResponse, type DeleteUserResponse, type DeleteWebhookResponse, type EdgeFunction, type EdgeFunctionExecution, type EmailSettings, type EmailTemplate, EmailTemplateManager, type EmailTemplateType, type EnrichedUser, type FeatureSettings, type FileObject, type FilterOperator, FluxbaseAdmin, FluxbaseAuth, type FluxbaseAuthResponse, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseFunctions, FluxbaseManagement, FluxbaseOAuth, FluxbaseRealtime, type FluxbaseResponse, FluxbaseSettings, FluxbaseStorage, type FunctionInvokeOptions, type GetImpersonationResponse, type HttpMethod, type ImpersonateAnonRequest, type ImpersonateServiceRequest, type ImpersonateUserRequest, ImpersonationManager, type ImpersonationSession, type ImpersonationTargetUser, type ImpersonationType, type Invitation, InvitationsManager, type InviteUserRequest, type InviteUserResponse, type ListAPIKeysResponse, type ListEmailTemplatesResponse, type ListImpersonationSessionsOptions, type ListImpersonationSessionsResponse, type ListInvitationsOptions, type ListInvitationsResponse, type ListOAuthProvidersResponse, type ListOptions, type ListSchemasResponse, type ListSystemSettingsResponse, type ListTablesResponse, type ListUsersOptions, type ListUsersResponse, type ListWebhookDeliveriesResponse, type ListWebhooksResponse, type MailgunSettings, type OAuthProvider, OAuthProviderManager, type OrderBy, type OrderDirection, type PostgresChangesConfig, type PostgrestError, type PostgrestResponse, QueryBuilder, type QueryFilter, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeMessage, type RealtimePostgresChangesPayload, type RequestOptions, type ResetUserPasswordResponse, type RevokeAPIKeyResponse, type RevokeInvitationResponse, type SESSettings, type SMTPSettings, type Schema, type SecuritySettings, type SendGridSettings, type SessionResponse, SettingsClient, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, type SupabaseAuthResponse, type SupabaseResponse, type SystemSetting, SystemSettingsManager, type Table, type TestEmailTemplateRequest, type TestWebhookResponse, type TwoFactorEnableResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorVerifyRequest, type UpdateAPIKeyRequest, type UpdateAppSettingsRequest, type UpdateAuthSettingsRequest, type UpdateAuthSettingsResponse, type UpdateEmailTemplateRequest, type UpdateFunctionRequest, type UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateSystemSettingRequest, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type UploadProgress, type User, type UserResponse, type ValidateInvitationResponse, type VoidResponse, type Webhook, type WebhookDelivery, WebhooksManager, createClient };
package/dist/index.d.ts CHANGED
@@ -201,11 +201,24 @@ interface FileObject {
201
201
  * @deprecated Use FileObject instead. This alias is provided for backwards compatibility.
202
202
  */
203
203
  type StorageObject = FileObject;
204
+ /**
205
+ * Upload progress information
206
+ */
207
+ interface UploadProgress {
208
+ /** Number of bytes uploaded so far */
209
+ loaded: number;
210
+ /** Total number of bytes to upload */
211
+ total: number;
212
+ /** Upload percentage (0-100) */
213
+ percentage: number;
214
+ }
204
215
  interface UploadOptions {
205
216
  contentType?: string;
206
217
  metadata?: Record<string, string>;
207
218
  cacheControl?: string;
208
219
  upsert?: boolean;
220
+ /** Optional callback to track upload progress */
221
+ onUploadProgress?: (progress: UploadProgress) => void;
209
222
  }
210
223
  interface ListOptions {
211
224
  prefix?: string;
@@ -1302,21 +1315,28 @@ declare class FluxbaseAuth {
1302
1315
  private stateChangeListeners;
1303
1316
  constructor(fetch: FluxbaseFetch, autoRefresh?: boolean, persist?: boolean);
1304
1317
  /**
1305
- * Get the current session
1318
+ * Get the current session (Supabase-compatible)
1319
+ * Returns the session from the client-side cache without making a network request
1306
1320
  */
1307
- getSession(): AuthSession | null;
1321
+ getSession(): Promise<FluxbaseResponse<{
1322
+ session: AuthSession | null;
1323
+ }>>;
1308
1324
  /**
1309
- * Get the current user
1325
+ * Get the current user (Supabase-compatible)
1326
+ * Returns the user from the client-side session without making a network request
1327
+ * For server-side validation, use getCurrentUser() instead
1310
1328
  */
1311
- getUser(): User | null;
1329
+ getUser(): Promise<FluxbaseResponse<{
1330
+ user: User | null;
1331
+ }>>;
1312
1332
  /**
1313
1333
  * Get the current access token
1314
1334
  */
1315
1335
  getAccessToken(): string | null;
1316
1336
  /**
1317
- * Listen to auth state changes
1337
+ * Listen to auth state changes (Supabase-compatible)
1318
1338
  * @param callback - Function called when auth state changes
1319
- * @returns Subscription object with unsubscribe method
1339
+ * @returns Object containing subscription data
1320
1340
  *
1321
1341
  * @example
1322
1342
  * ```typescript
@@ -1328,7 +1348,11 @@ declare class FluxbaseAuth {
1328
1348
  * subscription.unsubscribe()
1329
1349
  * ```
1330
1350
  */
1331
- onAuthStateChange(callback: AuthStateChangeCallback): AuthSubscription;
1351
+ onAuthStateChange(callback: AuthStateChangeCallback): {
1352
+ data: {
1353
+ subscription: AuthSubscription;
1354
+ };
1355
+ };
1332
1356
  /**
1333
1357
  * Sign in with email and password
1334
1358
  * Returns AuthSession if successful, or SignInWith2FAResponse if 2FA is required
@@ -1349,9 +1373,13 @@ declare class FluxbaseAuth {
1349
1373
  */
1350
1374
  signOut(): Promise<VoidResponse>;
1351
1375
  /**
1352
- * Refresh the access token
1376
+ * Refresh the session (Supabase-compatible)
1377
+ * Returns a new session with refreshed tokens
1353
1378
  */
1354
- refreshToken(): Promise<SessionResponse>;
1379
+ refreshSession(): Promise<FluxbaseResponse<{
1380
+ session: AuthSession;
1381
+ user: User;
1382
+ }>>;
1355
1383
  /**
1356
1384
  * Get the current user from the server
1357
1385
  */
@@ -1361,9 +1389,15 @@ declare class FluxbaseAuth {
1361
1389
  */
1362
1390
  updateUser(data: Partial<Pick<User, "email" | "metadata">>): Promise<UserResponse>;
1363
1391
  /**
1364
- * Set the auth token manually
1392
+ * Set the session manually (Supabase-compatible)
1393
+ * Useful for restoring a session from storage or SSR scenarios
1394
+ * @param session - Object containing access_token and refresh_token
1395
+ * @returns Promise with session data
1365
1396
  */
1366
- setToken(token: string): void;
1397
+ setSession(session: {
1398
+ access_token: string;
1399
+ refresh_token: string;
1400
+ }): Promise<FluxbaseAuthResponse>;
1367
1401
  /**
1368
1402
  * Setup 2FA for the current user
1369
1403
  * Returns TOTP secret and QR code URL
@@ -1463,7 +1497,7 @@ declare class FluxbaseAuth {
1463
1497
  /**
1464
1498
  * Internal: Set the session and persist it
1465
1499
  */
1466
- private setSession;
1500
+ private setSessionInternal;
1467
1501
  /**
1468
1502
  * Internal: Clear the session
1469
1503
  */
@@ -1504,6 +1538,11 @@ declare class StorageBucket {
1504
1538
  } | null;
1505
1539
  error: Error | null;
1506
1540
  }>;
1541
+ /**
1542
+ * Upload with progress tracking using XMLHttpRequest
1543
+ * @private
1544
+ */
1545
+ private uploadWithProgress;
1507
1546
  /**
1508
1547
  * Download a file from the bucket
1509
1548
  * @param path - The path/key of the file
@@ -4465,4 +4504,4 @@ declare class FluxbaseClient<Database = any, _SchemaName extends string & keyof
4465
4504
  */
4466
4505
  declare function createClient<Database = any, SchemaName extends string & keyof Database = any>(fluxbaseUrl: string, fluxbaseKey: string, options?: FluxbaseClientOptions): FluxbaseClient<Database, SchemaName>;
4467
4506
 
4468
- export { type APIKey, APIKeysManager, type AcceptInvitationRequest, type AcceptInvitationResponse, type AdminAuthResponse, type AdminLoginRequest, type AdminMeResponse, type AdminRefreshRequest, type AdminRefreshResponse, type AdminSetupRequest, type AdminSetupStatusResponse, type AdminUser, type AppSettings, AppSettingsManager, type AuthResponse, type AuthSession, type AuthSettings, AuthSettingsManager, type AuthenticationSettings, type Column, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateColumnRequest, type CreateFunctionRequest, type CreateInvitationRequest, type CreateInvitationResponse, type CreateOAuthProviderRequest, type CreateOAuthProviderResponse, type CreateSchemaRequest, type CreateSchemaResponse, type CreateTableRequest, type CreateTableResponse, type CreateWebhookRequest, DDLManager, type DataResponse, type DeleteAPIKeyResponse, type DeleteOAuthProviderResponse, type DeleteTableResponse, type DeleteUserResponse, type DeleteWebhookResponse, type EdgeFunction, type EdgeFunctionExecution, type EmailSettings, type EmailTemplate, EmailTemplateManager, type EmailTemplateType, type EnrichedUser, type FeatureSettings, type FileObject, type FilterOperator, FluxbaseAdmin, FluxbaseAuth, type FluxbaseAuthResponse, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseFunctions, FluxbaseManagement, FluxbaseOAuth, FluxbaseRealtime, type FluxbaseResponse, FluxbaseSettings, FluxbaseStorage, type FunctionInvokeOptions, type GetImpersonationResponse, type HttpMethod, type ImpersonateAnonRequest, type ImpersonateServiceRequest, type ImpersonateUserRequest, ImpersonationManager, type ImpersonationSession, type ImpersonationTargetUser, type ImpersonationType, type Invitation, InvitationsManager, type InviteUserRequest, type InviteUserResponse, type ListAPIKeysResponse, type ListEmailTemplatesResponse, type ListImpersonationSessionsOptions, type ListImpersonationSessionsResponse, type ListInvitationsOptions, type ListInvitationsResponse, type ListOAuthProvidersResponse, type ListOptions, type ListSchemasResponse, type ListSystemSettingsResponse, type ListTablesResponse, type ListUsersOptions, type ListUsersResponse, type ListWebhookDeliveriesResponse, type ListWebhooksResponse, type MailgunSettings, type OAuthProvider, OAuthProviderManager, type OrderBy, type OrderDirection, type PostgresChangesConfig, type PostgrestError, type PostgrestResponse, QueryBuilder, type QueryFilter, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeMessage, type RealtimePostgresChangesPayload, type RequestOptions, type ResetUserPasswordResponse, type RevokeAPIKeyResponse, type RevokeInvitationResponse, type SESSettings, type SMTPSettings, type Schema, type SecuritySettings, type SendGridSettings, type SessionResponse, SettingsClient, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, type SupabaseAuthResponse, type SupabaseResponse, type SystemSetting, SystemSettingsManager, type Table, type TestEmailTemplateRequest, type TestWebhookResponse, type TwoFactorEnableResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorVerifyRequest, type UpdateAPIKeyRequest, type UpdateAppSettingsRequest, type UpdateAuthSettingsRequest, type UpdateAuthSettingsResponse, type UpdateEmailTemplateRequest, type UpdateFunctionRequest, type UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateSystemSettingRequest, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type User, type UserResponse, type ValidateInvitationResponse, type VoidResponse, type Webhook, type WebhookDelivery, WebhooksManager, createClient };
4507
+ export { type APIKey, APIKeysManager, type AcceptInvitationRequest, type AcceptInvitationResponse, type AdminAuthResponse, type AdminLoginRequest, type AdminMeResponse, type AdminRefreshRequest, type AdminRefreshResponse, type AdminSetupRequest, type AdminSetupStatusResponse, type AdminUser, type AppSettings, AppSettingsManager, type AuthResponse, type AuthSession, type AuthSettings, AuthSettingsManager, type AuthenticationSettings, type Column, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateColumnRequest, type CreateFunctionRequest, type CreateInvitationRequest, type CreateInvitationResponse, type CreateOAuthProviderRequest, type CreateOAuthProviderResponse, type CreateSchemaRequest, type CreateSchemaResponse, type CreateTableRequest, type CreateTableResponse, type CreateWebhookRequest, DDLManager, type DataResponse, type DeleteAPIKeyResponse, type DeleteOAuthProviderResponse, type DeleteTableResponse, type DeleteUserResponse, type DeleteWebhookResponse, type EdgeFunction, type EdgeFunctionExecution, type EmailSettings, type EmailTemplate, EmailTemplateManager, type EmailTemplateType, type EnrichedUser, type FeatureSettings, type FileObject, type FilterOperator, FluxbaseAdmin, FluxbaseAuth, type FluxbaseAuthResponse, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseFunctions, FluxbaseManagement, FluxbaseOAuth, FluxbaseRealtime, type FluxbaseResponse, FluxbaseSettings, FluxbaseStorage, type FunctionInvokeOptions, type GetImpersonationResponse, type HttpMethod, type ImpersonateAnonRequest, type ImpersonateServiceRequest, type ImpersonateUserRequest, ImpersonationManager, type ImpersonationSession, type ImpersonationTargetUser, type ImpersonationType, type Invitation, InvitationsManager, type InviteUserRequest, type InviteUserResponse, type ListAPIKeysResponse, type ListEmailTemplatesResponse, type ListImpersonationSessionsOptions, type ListImpersonationSessionsResponse, type ListInvitationsOptions, type ListInvitationsResponse, type ListOAuthProvidersResponse, type ListOptions, type ListSchemasResponse, type ListSystemSettingsResponse, type ListTablesResponse, type ListUsersOptions, type ListUsersResponse, type ListWebhookDeliveriesResponse, type ListWebhooksResponse, type MailgunSettings, type OAuthProvider, OAuthProviderManager, type OrderBy, type OrderDirection, type PostgresChangesConfig, type PostgrestError, type PostgrestResponse, QueryBuilder, type QueryFilter, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeMessage, type RealtimePostgresChangesPayload, type RequestOptions, type ResetUserPasswordResponse, type RevokeAPIKeyResponse, type RevokeInvitationResponse, type SESSettings, type SMTPSettings, type Schema, type SecuritySettings, type SendGridSettings, type SessionResponse, SettingsClient, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, type SupabaseAuthResponse, type SupabaseResponse, type SystemSetting, SystemSettingsManager, type Table, type TestEmailTemplateRequest, type TestWebhookResponse, type TwoFactorEnableResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorVerifyRequest, type UpdateAPIKeyRequest, type UpdateAppSettingsRequest, type UpdateAuthSettingsRequest, type UpdateAuthSettingsResponse, type UpdateEmailTemplateRequest, type UpdateFunctionRequest, type UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateSystemSettingRequest, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type UploadProgress, type User, type UserResponse, type ValidateInvitationResponse, type VoidResponse, type Webhook, type WebhookDelivery, WebhooksManager, createClient };
package/dist/index.js CHANGED
@@ -163,16 +163,19 @@ var FluxbaseAuth = class {
163
163
  }
164
164
  }
165
165
  /**
166
- * Get the current session
166
+ * Get the current session (Supabase-compatible)
167
+ * Returns the session from the client-side cache without making a network request
167
168
  */
168
- getSession() {
169
- return this.session;
169
+ async getSession() {
170
+ return { data: { session: this.session }, error: null };
170
171
  }
171
172
  /**
172
- * Get the current user
173
+ * Get the current user (Supabase-compatible)
174
+ * Returns the user from the client-side session without making a network request
175
+ * For server-side validation, use getCurrentUser() instead
173
176
  */
174
- getUser() {
175
- return this.session?.user ?? null;
177
+ async getUser() {
178
+ return { data: { user: this.session?.user ?? null }, error: null };
176
179
  }
177
180
  /**
178
181
  * Get the current access token
@@ -181,9 +184,9 @@ var FluxbaseAuth = class {
181
184
  return this.session?.access_token ?? null;
182
185
  }
183
186
  /**
184
- * Listen to auth state changes
187
+ * Listen to auth state changes (Supabase-compatible)
185
188
  * @param callback - Function called when auth state changes
186
- * @returns Subscription object with unsubscribe method
189
+ * @returns Object containing subscription data
187
190
  *
188
191
  * @example
189
192
  * ```typescript
@@ -197,11 +200,12 @@ var FluxbaseAuth = class {
197
200
  */
198
201
  onAuthStateChange(callback) {
199
202
  this.stateChangeListeners.add(callback);
200
- return {
203
+ const subscription = {
201
204
  unsubscribe: () => {
202
205
  this.stateChangeListeners.delete(callback);
203
206
  }
204
207
  };
208
+ return { data: { subscription } };
205
209
  }
206
210
  /**
207
211
  * Sign in with email and password
@@ -218,7 +222,7 @@ var FluxbaseAuth = class {
218
222
  ...authResponse,
219
223
  expires_at: Date.now() + authResponse.expires_in * 1e3
220
224
  };
221
- this.setSession(session);
225
+ this.setSessionInternal(session);
222
226
  return session;
223
227
  });
224
228
  }
@@ -243,7 +247,7 @@ var FluxbaseAuth = class {
243
247
  ...response,
244
248
  expires_at: Date.now() + response.expires_in * 1e3
245
249
  };
246
- this.setSession(session);
250
+ this.setSessionInternal(session);
247
251
  return { user: session.user, session };
248
252
  });
249
253
  }
@@ -260,9 +264,10 @@ var FluxbaseAuth = class {
260
264
  });
261
265
  }
262
266
  /**
263
- * Refresh the access token
267
+ * Refresh the session (Supabase-compatible)
268
+ * Returns a new session with refreshed tokens
264
269
  */
265
- async refreshToken() {
270
+ async refreshSession() {
266
271
  return wrapAsync(async () => {
267
272
  if (!this.session?.refresh_token) {
268
273
  throw new Error("No refresh token available");
@@ -277,8 +282,8 @@ var FluxbaseAuth = class {
277
282
  ...response,
278
283
  expires_at: Date.now() + response.expires_in * 1e3
279
284
  };
280
- this.setSession(session, "TOKEN_REFRESHED");
281
- return { session };
285
+ this.setSessionInternal(session, "TOKEN_REFRESHED");
286
+ return { session, user: session.user };
282
287
  });
283
288
  }
284
289
  /**
@@ -311,10 +316,28 @@ var FluxbaseAuth = class {
311
316
  });
312
317
  }
313
318
  /**
314
- * Set the auth token manually
319
+ * Set the session manually (Supabase-compatible)
320
+ * Useful for restoring a session from storage or SSR scenarios
321
+ * @param session - Object containing access_token and refresh_token
322
+ * @returns Promise with session data
315
323
  */
316
- setToken(token) {
317
- this.fetch.setAuthToken(token);
324
+ async setSession(session) {
325
+ return wrapAsync(async () => {
326
+ const authSession = {
327
+ access_token: session.access_token,
328
+ refresh_token: session.refresh_token,
329
+ user: null,
330
+ // Will be populated by getCurrentUser
331
+ expires_in: 3600,
332
+ // Default, will be updated on refresh
333
+ expires_at: Date.now() + 3600 * 1e3
334
+ };
335
+ this.fetch.setAuthToken(session.access_token);
336
+ const user = await this.fetch.get("/api/v1/auth/user");
337
+ authSession.user = user;
338
+ this.setSessionInternal(authSession, "SIGNED_IN");
339
+ return { user, session: authSession };
340
+ });
318
341
  }
319
342
  /**
320
343
  * Setup 2FA for the current user
@@ -387,7 +410,7 @@ var FluxbaseAuth = class {
387
410
  ...response,
388
411
  expires_at: Date.now() + response.expires_in * 1e3
389
412
  };
390
- this.setSession(session, "MFA_CHALLENGE_VERIFIED");
413
+ this.setSessionInternal(session, "MFA_CHALLENGE_VERIFIED");
391
414
  return { user: session.user, session };
392
415
  });
393
416
  }
@@ -476,7 +499,7 @@ var FluxbaseAuth = class {
476
499
  ...response,
477
500
  expires_at: Date.now() + response.expires_in * 1e3
478
501
  };
479
- this.setSession(session);
502
+ this.setSessionInternal(session);
480
503
  return { user: session.user, session };
481
504
  });
482
505
  }
@@ -493,7 +516,7 @@ var FluxbaseAuth = class {
493
516
  ...response,
494
517
  expires_at: Date.now() + response.expires_in * 1e3
495
518
  };
496
- this.setSession(session);
519
+ this.setSessionInternal(session);
497
520
  return { user: session.user, session };
498
521
  });
499
522
  }
@@ -542,7 +565,7 @@ var FluxbaseAuth = class {
542
565
  ...response,
543
566
  expires_at: Date.now() + response.expires_in * 1e3
544
567
  };
545
- this.setSession(session);
568
+ this.setSessionInternal(session);
546
569
  return { user: session.user, session };
547
570
  });
548
571
  }
@@ -572,7 +595,7 @@ var FluxbaseAuth = class {
572
595
  /**
573
596
  * Internal: Set the session and persist it
574
597
  */
575
- setSession(session, event = "SIGNED_IN") {
598
+ setSessionInternal(session, event = "SIGNED_IN") {
576
599
  this.session = session;
577
600
  this.fetch.setAuthToken(session.access_token);
578
601
  this.saveSession();
@@ -616,7 +639,7 @@ var FluxbaseAuth = class {
616
639
  const delay = refreshAt - Date.now();
617
640
  if (delay > 0) {
618
641
  this.refreshTimer = setTimeout(async () => {
619
- const result = await this.refreshToken();
642
+ const result = await this.refreshSession();
620
643
  if (result.error) {
621
644
  console.error("Failed to refresh token:", result.error);
622
645
  this.clearSession();
@@ -937,15 +960,20 @@ var StorageBucket = class {
937
960
  if (options?.upsert !== void 0) {
938
961
  formData.append("upsert", String(options.upsert));
939
962
  }
940
- const response = await this.fetch.request(
941
- `/api/v1/storage/${this.bucketName}/${path}`,
942
- {
943
- method: "POST",
944
- body: formData,
945
- headers: {}
946
- // Let browser set Content-Type for FormData
947
- }
948
- );
963
+ let response;
964
+ if (options?.onUploadProgress) {
965
+ response = await this.uploadWithProgress(path, formData, options.onUploadProgress);
966
+ } else {
967
+ response = await this.fetch.request(
968
+ `/api/v1/storage/${this.bucketName}/${path}`,
969
+ {
970
+ method: "POST",
971
+ body: formData,
972
+ headers: {}
973
+ // Let browser set Content-Type for FormData
974
+ }
975
+ );
976
+ }
949
977
  return {
950
978
  data: {
951
979
  id: response.id || response.key || path,
@@ -958,6 +986,57 @@ var StorageBucket = class {
958
986
  return { data: null, error };
959
987
  }
960
988
  }
989
+ /**
990
+ * Upload with progress tracking using XMLHttpRequest
991
+ * @private
992
+ */
993
+ uploadWithProgress(path, formData, onProgress) {
994
+ return new Promise((resolve, reject) => {
995
+ const xhr = new XMLHttpRequest();
996
+ const url = `${this.fetch["baseUrl"]}/api/v1/storage/${this.bucketName}/${path}`;
997
+ xhr.upload.addEventListener("progress", (event) => {
998
+ if (event.lengthComputable) {
999
+ const percentage = Math.round(event.loaded / event.total * 100);
1000
+ onProgress({
1001
+ loaded: event.loaded,
1002
+ total: event.total,
1003
+ percentage
1004
+ });
1005
+ }
1006
+ });
1007
+ xhr.addEventListener("load", () => {
1008
+ if (xhr.status >= 200 && xhr.status < 300) {
1009
+ try {
1010
+ const response = JSON.parse(xhr.responseText);
1011
+ resolve(response);
1012
+ } catch (e) {
1013
+ resolve(xhr.responseText);
1014
+ }
1015
+ } else {
1016
+ try {
1017
+ const errorData = JSON.parse(xhr.responseText);
1018
+ reject(new Error(errorData.error || xhr.statusText));
1019
+ } catch (e) {
1020
+ reject(new Error(xhr.statusText));
1021
+ }
1022
+ }
1023
+ });
1024
+ xhr.addEventListener("error", () => {
1025
+ reject(new Error("Upload failed"));
1026
+ });
1027
+ xhr.addEventListener("abort", () => {
1028
+ reject(new Error("Upload aborted"));
1029
+ });
1030
+ xhr.open("POST", url);
1031
+ const headers = this.fetch["defaultHeaders"];
1032
+ for (const [key, value] of Object.entries(headers)) {
1033
+ if (key.toLowerCase() !== "content-type") {
1034
+ xhr.setRequestHeader(key, value);
1035
+ }
1036
+ }
1037
+ xhr.send(formData);
1038
+ });
1039
+ }
961
1040
  /**
962
1041
  * Download a file from the bucket
963
1042
  * @param path - The path/key of the file