@insforge/sdk 1.3.0-ssr.3 → 1.3.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/ssr.mjs CHANGED
@@ -2622,8 +2622,9 @@ function getJwtExpiration(token) {
2622
2622
  }
2623
2623
  }
2624
2624
  function isJwtExpiredOrExpiring(token, leewaySeconds = 60) {
2625
+ if (!token) return false;
2625
2626
  const expires = getJwtExpiration(token);
2626
- if (!expires) return false;
2627
+ if (!expires) return true;
2627
2628
  return expires.getTime() <= Date.now() + leewaySeconds * 1e3;
2628
2629
  }
2629
2630
 
@@ -2690,11 +2691,12 @@ function refreshTokenCookieOptions(token, overrides) {
2690
2691
  };
2691
2692
  }
2692
2693
  function expiredCookieOptions(overrides) {
2694
+ const { expires: _expires, maxAge: _maxAge, ...safeOverrides } = overrides ?? {};
2693
2695
  return {
2694
2696
  ...defaultCookieOptions(),
2697
+ ...safeOverrides,
2695
2698
  expires: EXPIRED_DATE,
2696
- maxAge: 0,
2697
- ...overrides
2699
+ maxAge: 0
2698
2700
  };
2699
2701
  }
2700
2702
  function setCookie(cookies, name, value, options) {
@@ -2835,6 +2837,13 @@ function withAuthHeader(init, token) {
2835
2837
  headers
2836
2838
  };
2837
2839
  }
2840
+ function getRequestUrl(input) {
2841
+ if (typeof input === "string") return input;
2842
+ if (typeof Request !== "undefined" && input instanceof Request) {
2843
+ return input.url;
2844
+ }
2845
+ return input.toString();
2846
+ }
2838
2847
  function createBrowserClient(options = {}) {
2839
2848
  let { baseUrl, anonKey } = options;
2840
2849
  try {
@@ -2891,7 +2900,7 @@ function createBrowserClient(options = {}) {
2891
2900
  return refreshPromise;
2892
2901
  };
2893
2902
  const shouldSkipRefresh = (input) => {
2894
- const url = typeof input === "string" ? input : input.toString();
2903
+ const url = getRequestUrl(input);
2895
2904
  return url === refreshUrl || url.endsWith(refreshUrl);
2896
2905
  };
2897
2906
  const ssrFetch = async (input, init) => {