@dloizides/auth-web 1.9.0 → 1.9.1

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.mjs CHANGED
@@ -2519,6 +2519,18 @@ var PasskeyCeremonyMode = /* @__PURE__ */ ((PasskeyCeremonyMode2) => {
2519
2519
  return PasskeyCeremonyMode2;
2520
2520
  })(PasskeyCeremonyMode || {});
2521
2521
 
2522
+ // src/passkey/browserLocation.ts
2523
+ function getBrowserLocation() {
2524
+ if (typeof window === "undefined") {
2525
+ return null;
2526
+ }
2527
+ const browserLocation = window.location;
2528
+ if (browserLocation === void 0) {
2529
+ return null;
2530
+ }
2531
+ return browserLocation;
2532
+ }
2533
+
2522
2534
  // src/passkey/passkeyNavigation.ts
2523
2535
  var PASSKEY_LOGIN_ENDPOINT = "/bff/passkey/login";
2524
2536
  var PASSKEY_REGISTER_ENDPOINT = "/bff/passkey/register";
@@ -2532,22 +2544,25 @@ function buildNavigationUrl(endpoint, returnUrl) {
2532
2544
  return `${endpoint}?${RETURN_URL_PARAM}=${encodeURIComponent(returnUrl)}`;
2533
2545
  }
2534
2546
  function readSearchParams() {
2535
- if (typeof window === "undefined") {
2547
+ const browserLocation = getBrowserLocation();
2548
+ if (browserLocation === null) {
2536
2549
  return null;
2537
2550
  }
2538
- return new URLSearchParams(window.location.search);
2551
+ return new URLSearchParams(browserLocation.search);
2539
2552
  }
2540
2553
  function startPasskeyLogin(returnUrl) {
2541
- if (typeof window === "undefined") {
2554
+ const browserLocation = getBrowserLocation();
2555
+ if (browserLocation === null) {
2542
2556
  return;
2543
2557
  }
2544
- window.location.assign(buildNavigationUrl(PASSKEY_LOGIN_ENDPOINT, returnUrl));
2558
+ browserLocation.assign(buildNavigationUrl(PASSKEY_LOGIN_ENDPOINT, returnUrl));
2545
2559
  }
2546
2560
  function startPasskeyRegistration(returnUrl) {
2547
- if (typeof window === "undefined") {
2561
+ const browserLocation = getBrowserLocation();
2562
+ if (browserLocation === null) {
2548
2563
  return;
2549
2564
  }
2550
- window.location.assign(buildNavigationUrl(PASSKEY_REGISTER_ENDPOINT, returnUrl));
2565
+ browserLocation.assign(buildNavigationUrl(PASSKEY_REGISTER_ENDPOINT, returnUrl));
2551
2566
  }
2552
2567
  function readPasskeyError() {
2553
2568
  const params = readSearchParams();
@@ -2724,8 +2739,9 @@ function usePasskeyCeremony(optionsArg) {
2724
2739
  onSuccess(user);
2725
2740
  return;
2726
2741
  }
2727
- if (mode === "login" /* Login */ && typeof window !== "undefined") {
2728
- window.location.assign(returnUrl);
2742
+ const browserLocation = getBrowserLocation();
2743
+ if (mode === "login" /* Login */ && browserLocation !== null) {
2744
+ browserLocation.assign(returnUrl);
2729
2745
  }
2730
2746
  },
2731
2747
  [mode, onSuccess, returnUrl]
@@ -2847,10 +2863,11 @@ function PasskeyLoginButton({
2847
2863
  }
2848
2864
  var DEFAULT_RETURN_PATH = "/";
2849
2865
  function readCurrentPath() {
2850
- if (typeof window === "undefined") {
2866
+ const browserLocation = getBrowserLocation();
2867
+ if (browserLocation === null) {
2851
2868
  return DEFAULT_RETURN_PATH;
2852
2869
  }
2853
- return window.location.pathname;
2870
+ return browserLocation.pathname;
2854
2871
  }
2855
2872
  function PasskeySettingsCard({
2856
2873
  returnUrl,