@passkeyme/react-auth 2.2.5 → 2.2.7

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.js CHANGED
@@ -6687,12 +6687,14 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
6687
6687
  };
6688
6688
  // Proceed with redirect after auth completion
6689
6689
  const proceedWithRedirect = async () => {
6690
- // Clean URL immediately to prevent effect re-run with stale URL params
6690
+ // CRITICAL: Clean URL synchronously BEFORE any async operations
6691
+ // This prevents Next.js App Router from remounting the component with stale URL params
6692
+ // Must happen outside setTimeout to execute immediately
6691
6693
  window.history.replaceState({}, document.title, window.location.pathname);
6692
6694
  setTimeout(async () => {
6693
6695
  const currentUser = state.authenticatedUser || user;
6694
6696
  if (onSuccess && currentUser) {
6695
- // Use auth's getAccessToken method instead of direct localStorage access
6697
+ // For custom callbacks, parent component handles navigation
6696
6698
  try {
6697
6699
  const token = await auth.getAccessToken();
6698
6700
  onSuccess(currentUser, token || "");
@@ -6703,7 +6705,7 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
6703
6705
  }
6704
6706
  }
6705
6707
  else {
6706
- // Redirect to success page
6708
+ // For redirects, navigate to success page
6707
6709
  window.location.href = successRedirect;
6708
6710
  }
6709
6711
  }, 100);