@insforge/sdk 1.3.0-ssr.2 → 1.3.0-ssr.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/ssr.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as InsForgeConfig, I as InsForgeClient, l as AuthRefreshResponse, d as InsForgeError } from './client-B8ykVESe.mjs';
1
+ import { a as InsForgeConfig, I as InsForgeClient, m as AuthRefreshResponse, e as InsForgeError } from './client-CQfw9UsO.mjs';
2
2
  import '@insforge/shared-schemas';
3
3
  import '@supabase/postgrest-js';
4
4
 
package/dist/ssr.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as InsForgeConfig, I as InsForgeClient, l as AuthRefreshResponse, d as InsForgeError } from './client-B8ykVESe.js';
1
+ import { a as InsForgeConfig, I as InsForgeClient, m as AuthRefreshResponse, e as InsForgeError } from './client-CQfw9UsO.js';
2
2
  import '@insforge/shared-schemas';
3
3
  import '@supabase/postgrest-js';
4
4
 
package/dist/ssr.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/ssr.ts
@@ -2215,7 +2225,6 @@ var Functions = class _Functions {
2215
2225
  };
2216
2226
 
2217
2227
  // src/modules/realtime.ts
2218
- var import_socket = require("socket.io-client");
2219
2228
  var CONNECT_TIMEOUT = 1e4;
2220
2229
  var Realtime = class {
2221
2230
  constructor(baseUrl, tokenManager, anonKey) {
@@ -2250,61 +2259,69 @@ var Realtime = class {
2250
2259
  if (this.connectPromise) {
2251
2260
  return this.connectPromise;
2252
2261
  }
2253
- this.connectPromise = new Promise((resolve, reject) => {
2254
- const token = this.tokenManager.getAccessToken() ?? this.anonKey;
2255
- this.socket = (0, import_socket.io)(this.baseUrl, {
2256
- transports: ["websocket"],
2257
- auth: token ? { token } : void 0
2258
- });
2259
- let initialConnection = true;
2260
- let timeoutId = null;
2261
- const cleanup = () => {
2262
- if (timeoutId) {
2263
- clearTimeout(timeoutId);
2264
- timeoutId = null;
2265
- }
2266
- };
2267
- timeoutId = setTimeout(() => {
2268
- if (initialConnection) {
2269
- initialConnection = false;
2270
- this.connectPromise = null;
2271
- this.socket?.disconnect();
2272
- this.socket = null;
2273
- reject(new Error(`Connection timeout after ${CONNECT_TIMEOUT}ms`));
2274
- }
2275
- }, CONNECT_TIMEOUT);
2276
- this.socket.on("connect", () => {
2277
- cleanup();
2278
- for (const channel of this.subscribedChannels) {
2279
- this.socket.emit("realtime:subscribe", { channel });
2280
- }
2281
- this.notifyListeners("connect");
2282
- if (initialConnection) {
2283
- initialConnection = false;
2284
- this.connectPromise = null;
2285
- resolve();
2286
- }
2287
- });
2288
- this.socket.on("connect_error", (error) => {
2289
- cleanup();
2290
- this.notifyListeners("connect_error", error);
2291
- if (initialConnection) {
2292
- initialConnection = false;
2293
- this.connectPromise = null;
2294
- reject(error);
2295
- }
2296
- });
2297
- this.socket.on("disconnect", (reason) => {
2298
- this.notifyListeners("disconnect", reason);
2299
- });
2300
- this.socket.on("realtime:error", (error) => {
2301
- this.notifyListeners("error", error);
2302
- });
2303
- this.socket.onAny((event, message) => {
2304
- if (event === "realtime:error") return;
2305
- this.notifyListeners(event, message);
2306
- });
2307
- });
2262
+ this.connectPromise = (async () => {
2263
+ try {
2264
+ const { io } = await import("socket.io-client");
2265
+ await new Promise((resolve, reject) => {
2266
+ const token = this.tokenManager.getAccessToken() ?? this.anonKey;
2267
+ this.socket = io(this.baseUrl, {
2268
+ transports: ["websocket"],
2269
+ auth: token ? { token } : void 0
2270
+ });
2271
+ let initialConnection = true;
2272
+ let timeoutId = null;
2273
+ const cleanup = () => {
2274
+ if (timeoutId) {
2275
+ clearTimeout(timeoutId);
2276
+ timeoutId = null;
2277
+ }
2278
+ };
2279
+ timeoutId = setTimeout(() => {
2280
+ if (initialConnection) {
2281
+ initialConnection = false;
2282
+ this.connectPromise = null;
2283
+ this.socket?.disconnect();
2284
+ this.socket = null;
2285
+ reject(new Error(`Connection timeout after ${CONNECT_TIMEOUT}ms`));
2286
+ }
2287
+ }, CONNECT_TIMEOUT);
2288
+ this.socket.on("connect", () => {
2289
+ cleanup();
2290
+ for (const channel of this.subscribedChannels) {
2291
+ this.socket.emit("realtime:subscribe", { channel });
2292
+ }
2293
+ this.notifyListeners("connect");
2294
+ if (initialConnection) {
2295
+ initialConnection = false;
2296
+ this.connectPromise = null;
2297
+ resolve();
2298
+ }
2299
+ });
2300
+ this.socket.on("connect_error", (error) => {
2301
+ cleanup();
2302
+ this.notifyListeners("connect_error", error);
2303
+ if (initialConnection) {
2304
+ initialConnection = false;
2305
+ this.connectPromise = null;
2306
+ reject(error);
2307
+ }
2308
+ });
2309
+ this.socket.on("disconnect", (reason) => {
2310
+ this.notifyListeners("disconnect", reason);
2311
+ });
2312
+ this.socket.on("realtime:error", (error) => {
2313
+ this.notifyListeners("error", error);
2314
+ });
2315
+ this.socket.onAny((event, message) => {
2316
+ if (event === "realtime:error") return;
2317
+ this.notifyListeners(event, message);
2318
+ });
2319
+ });
2320
+ } catch (error) {
2321
+ this.connectPromise = null;
2322
+ throw error;
2323
+ }
2324
+ })();
2308
2325
  return this.connectPromise;
2309
2326
  }
2310
2327
  /**
@@ -2634,10 +2651,9 @@ function decodeBase64Url(input) {
2634
2651
  normalized.length + (4 - normalized.length % 4) % 4,
2635
2652
  "="
2636
2653
  );
2637
- if (typeof atob === "function") {
2638
- return atob(padded);
2639
- }
2640
- return Buffer.from(padded, "base64").toString("utf8");
2654
+ const binary = atob(padded);
2655
+ const bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
2656
+ return new TextDecoder().decode(bytes);
2641
2657
  }
2642
2658
  function getJwtExpiration(token) {
2643
2659
  if (!token) return null;