@insforge/sdk 1.2.7 → 1.2.8-dev.0

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 CHANGED
@@ -74,12 +74,6 @@ interface InsForgeConfig {
74
74
  * @default 500
75
75
  */
76
76
  retryDelay?: number;
77
- /**
78
- * Automatically refresh the access token when a request fails with 401 INVALID_TOKEN.
79
- * When true, the SDK will attempt a token refresh and retry the original request.
80
- * @default true
81
- */
82
- autoRefreshToken?: boolean;
83
77
  }
84
78
  interface AuthSession {
85
79
  user: UserSchema;
@@ -217,6 +211,8 @@ interface RequestOptions extends Omit<RequestInit, 'body'> {
217
211
  body?: RequestInit['body'] | JsonRequestBody;
218
212
  /** Allow retrying non-idempotent requests (POST, PATCH). Off by default to prevent duplicate writes. */
219
213
  idempotent?: boolean;
214
+ /** Disable automatic access-token refresh for auth/control-flow requests. */
215
+ skipAuthRefresh?: boolean;
220
216
  }
221
217
  /**
222
218
  * HTTP client with built-in retry, timeout, and exponential backoff support.
@@ -225,11 +221,11 @@ interface RequestOptions extends Omit<RequestInit, 'body'> {
225
221
  declare class HttpClient {
226
222
  readonly baseUrl: string;
227
223
  readonly fetch: typeof fetch;
224
+ private readonly config;
228
225
  private defaultHeaders;
229
226
  private anonKey;
230
227
  private userToken;
231
228
  private logger;
232
- private autoRefreshToken;
233
229
  private isRefreshing;
234
230
  private refreshPromise;
235
231
  private tokenManager;
@@ -257,6 +253,8 @@ declare class HttpClient {
257
253
  * @returns Delay in milliseconds.
258
254
  */
259
255
  private computeRetryDelay;
256
+ private shouldRefreshAccessToken;
257
+ private fetchWithRetry;
260
258
  /**
261
259
  * Performs an HTTP request with automatic retry and timeout handling.
262
260
  * Retries on network errors and 5xx server errors with exponential backoff.
@@ -269,6 +267,14 @@ declare class HttpClient {
269
267
  */
270
268
  private handleRequest;
271
269
  request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
270
+ /**
271
+ * Performs an SDK-configured fetch and returns the raw Response.
272
+ * This is used by clients such as postgrest-js that need to own response
273
+ * parsing while still sharing SDK auth and refresh behavior.
274
+ */
275
+ rawFetch(input: RequestInfo | URL, init?: RequestInit, options?: {
276
+ skipAuthRefresh?: boolean;
277
+ }): Promise<Response>;
272
278
  /** Performs a GET request. */
273
279
  get<T>(path: string, options?: RequestOptions): Promise<T>;
274
280
  /** Performs a POST request with an optional JSON body. */
@@ -284,7 +290,9 @@ declare class HttpClient {
284
290
  setRefreshToken(token: string | null): void;
285
291
  /** Returns the current default headers including the authorization header if set. */
286
292
  getHeaders(): Record<string, string>;
287
- handleTokenRefresh(): Promise<AuthRefreshResponse>;
293
+ refreshAccessToken(): Promise<AuthRefreshResponse>;
294
+ private refreshAndSaveSession;
295
+ private clearAuthSession;
288
296
  }
289
297
 
290
298
  /**
@@ -433,7 +441,7 @@ declare class Auth {
433
441
  */
434
442
  declare class Database {
435
443
  private postgrest;
436
- constructor(httpClient: HttpClient, tokenManager: TokenManager);
444
+ constructor(httpClient: HttpClient);
437
445
  /**
438
446
  * Create a query builder for a table
439
447
  *
package/dist/index.d.ts CHANGED
@@ -74,12 +74,6 @@ interface InsForgeConfig {
74
74
  * @default 500
75
75
  */
76
76
  retryDelay?: number;
77
- /**
78
- * Automatically refresh the access token when a request fails with 401 INVALID_TOKEN.
79
- * When true, the SDK will attempt a token refresh and retry the original request.
80
- * @default true
81
- */
82
- autoRefreshToken?: boolean;
83
77
  }
84
78
  interface AuthSession {
85
79
  user: UserSchema;
@@ -217,6 +211,8 @@ interface RequestOptions extends Omit<RequestInit, 'body'> {
217
211
  body?: RequestInit['body'] | JsonRequestBody;
218
212
  /** Allow retrying non-idempotent requests (POST, PATCH). Off by default to prevent duplicate writes. */
219
213
  idempotent?: boolean;
214
+ /** Disable automatic access-token refresh for auth/control-flow requests. */
215
+ skipAuthRefresh?: boolean;
220
216
  }
221
217
  /**
222
218
  * HTTP client with built-in retry, timeout, and exponential backoff support.
@@ -225,11 +221,11 @@ interface RequestOptions extends Omit<RequestInit, 'body'> {
225
221
  declare class HttpClient {
226
222
  readonly baseUrl: string;
227
223
  readonly fetch: typeof fetch;
224
+ private readonly config;
228
225
  private defaultHeaders;
229
226
  private anonKey;
230
227
  private userToken;
231
228
  private logger;
232
- private autoRefreshToken;
233
229
  private isRefreshing;
234
230
  private refreshPromise;
235
231
  private tokenManager;
@@ -257,6 +253,8 @@ declare class HttpClient {
257
253
  * @returns Delay in milliseconds.
258
254
  */
259
255
  private computeRetryDelay;
256
+ private shouldRefreshAccessToken;
257
+ private fetchWithRetry;
260
258
  /**
261
259
  * Performs an HTTP request with automatic retry and timeout handling.
262
260
  * Retries on network errors and 5xx server errors with exponential backoff.
@@ -269,6 +267,14 @@ declare class HttpClient {
269
267
  */
270
268
  private handleRequest;
271
269
  request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
270
+ /**
271
+ * Performs an SDK-configured fetch and returns the raw Response.
272
+ * This is used by clients such as postgrest-js that need to own response
273
+ * parsing while still sharing SDK auth and refresh behavior.
274
+ */
275
+ rawFetch(input: RequestInfo | URL, init?: RequestInit, options?: {
276
+ skipAuthRefresh?: boolean;
277
+ }): Promise<Response>;
272
278
  /** Performs a GET request. */
273
279
  get<T>(path: string, options?: RequestOptions): Promise<T>;
274
280
  /** Performs a POST request with an optional JSON body. */
@@ -284,7 +290,9 @@ declare class HttpClient {
284
290
  setRefreshToken(token: string | null): void;
285
291
  /** Returns the current default headers including the authorization header if set. */
286
292
  getHeaders(): Record<string, string>;
287
- handleTokenRefresh(): Promise<AuthRefreshResponse>;
293
+ refreshAccessToken(): Promise<AuthRefreshResponse>;
294
+ private refreshAndSaveSession;
295
+ private clearAuthSession;
288
296
  }
289
297
 
290
298
  /**
@@ -433,7 +441,7 @@ declare class Auth {
433
441
  */
434
442
  declare class Database {
435
443
  private postgrest;
436
- constructor(httpClient: HttpClient, tokenManager: TokenManager);
444
+ constructor(httpClient: HttpClient);
437
445
  /**
438
446
  * Create a query builder for a table
439
447
  *