@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.js CHANGED
@@ -2670,8 +2670,9 @@ function getJwtExpiration(token) {
2670
2670
  }
2671
2671
  }
2672
2672
  function isJwtExpiredOrExpiring(token, leewaySeconds = 60) {
2673
+ if (!token) return false;
2673
2674
  const expires = getJwtExpiration(token);
2674
- if (!expires) return false;
2675
+ if (!expires) return true;
2675
2676
  return expires.getTime() <= Date.now() + leewaySeconds * 1e3;
2676
2677
  }
2677
2678
 
@@ -2738,11 +2739,12 @@ function refreshTokenCookieOptions(token, overrides) {
2738
2739
  };
2739
2740
  }
2740
2741
  function expiredCookieOptions(overrides) {
2742
+ const { expires: _expires, maxAge: _maxAge, ...safeOverrides } = overrides ?? {};
2741
2743
  return {
2742
2744
  ...defaultCookieOptions(),
2745
+ ...safeOverrides,
2743
2746
  expires: EXPIRED_DATE,
2744
- maxAge: 0,
2745
- ...overrides
2747
+ maxAge: 0
2746
2748
  };
2747
2749
  }
2748
2750
  function setCookie(cookies, name, value, options) {
@@ -2883,6 +2885,13 @@ function withAuthHeader(init, token) {
2883
2885
  headers
2884
2886
  };
2885
2887
  }
2888
+ function getRequestUrl(input) {
2889
+ if (typeof input === "string") return input;
2890
+ if (typeof Request !== "undefined" && input instanceof Request) {
2891
+ return input.url;
2892
+ }
2893
+ return input.toString();
2894
+ }
2886
2895
  function createBrowserClient(options = {}) {
2887
2896
  let { baseUrl, anonKey } = options;
2888
2897
  try {
@@ -2939,7 +2948,7 @@ function createBrowserClient(options = {}) {
2939
2948
  return refreshPromise;
2940
2949
  };
2941
2950
  const shouldSkipRefresh = (input) => {
2942
- const url = typeof input === "string" ? input : input.toString();
2951
+ const url = getRequestUrl(input);
2943
2952
  return url === refreshUrl || url.endsWith(refreshUrl);
2944
2953
  };
2945
2954
  const ssrFetch = async (input, init) => {