@passkeyme/react-auth 2.2.8 → 2.2.10
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/components/PasskeymeCallbackHandler.d.ts.map +1 -1
- package/dist/index.esm.js +23 -14
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +23 -14
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6608,7 +6608,7 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
|
|
|
6608
6608
|
showPasskeyPrompt: false,
|
|
6609
6609
|
});
|
|
6610
6610
|
handlePasskeyRegistrationComplete(true);
|
|
6611
|
-
proceedWithRedirect();
|
|
6611
|
+
proceedWithRedirect(currentUser);
|
|
6612
6612
|
}
|
|
6613
6613
|
catch (error) {
|
|
6614
6614
|
console.error("Passkey registration failed:", error);
|
|
@@ -6652,7 +6652,7 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
|
|
|
6652
6652
|
}
|
|
6653
6653
|
// This is actually a "success" case - user has passkeys, just localStorage was out of sync
|
|
6654
6654
|
handlePasskeyRegistrationComplete(true, "Passkey already registered and ready to use.");
|
|
6655
|
-
proceedWithRedirect();
|
|
6655
|
+
proceedWithRedirect(currentUser);
|
|
6656
6656
|
return;
|
|
6657
6657
|
}
|
|
6658
6658
|
else if (msg.includes("user cancelled") ||
|
|
@@ -6672,7 +6672,7 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
|
|
|
6672
6672
|
handlePasskeyRegistrationComplete(false, "Passkey registration failed. You can try again later.");
|
|
6673
6673
|
}
|
|
6674
6674
|
// Always proceed with redirect - don't block user flow
|
|
6675
|
-
proceedWithRedirect();
|
|
6675
|
+
proceedWithRedirect(currentUser);
|
|
6676
6676
|
}
|
|
6677
6677
|
};
|
|
6678
6678
|
// Handle skipping passkey registration
|
|
@@ -6683,18 +6683,23 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
|
|
|
6683
6683
|
sessionStorage.setItem("passkey_declined", Date.now().toString());
|
|
6684
6684
|
updateState({ showPasskeyPrompt: false });
|
|
6685
6685
|
handlePasskeyRegistrationComplete(false, "User chose to skip passkey registration");
|
|
6686
|
-
proceedWithRedirect();
|
|
6686
|
+
proceedWithRedirect(state.authenticatedUser);
|
|
6687
6687
|
};
|
|
6688
6688
|
// Proceed with redirect after auth completion
|
|
6689
|
-
const proceedWithRedirect = async () => {
|
|
6689
|
+
const proceedWithRedirect = async (authenticatedUser) => {
|
|
6690
6690
|
// CRITICAL: Clean URL synchronously BEFORE any async operations
|
|
6691
6691
|
// This prevents Next.js App Router from remounting the component with stale URL params
|
|
6692
6692
|
// Must happen outside setTimeout to execute immediately
|
|
6693
6693
|
window.history.replaceState({}, document.title, window.location.pathname);
|
|
6694
6694
|
setTimeout(async () => {
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
|
|
6695
|
+
// Use passed user or fall back to state/context user
|
|
6696
|
+
const currentUser = authenticatedUser || state.authenticatedUser || user;
|
|
6697
|
+
// If custom onSuccess callback provided, use it and let parent handle navigation
|
|
6698
|
+
if (onSuccess) {
|
|
6699
|
+
if (!currentUser) {
|
|
6700
|
+
debugLog(config, "CallbackHandler", "Warning: onSuccess provided but no currentUser available");
|
|
6701
|
+
return;
|
|
6702
|
+
}
|
|
6698
6703
|
try {
|
|
6699
6704
|
const token = await auth.getAccessToken();
|
|
6700
6705
|
onSuccess(currentUser, token || "");
|
|
@@ -6703,14 +6708,18 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
|
|
|
6703
6708
|
debugLog(config, "CallbackHandler", "Error getting access token:", error);
|
|
6704
6709
|
onSuccess(currentUser, "");
|
|
6705
6710
|
}
|
|
6711
|
+
return; // Don't proceed with redirect - parent handles navigation
|
|
6706
6712
|
}
|
|
6707
|
-
|
|
6713
|
+
// No custom callback - use successRedirect for navigation
|
|
6714
|
+
if (successRedirect) {
|
|
6708
6715
|
console.log("[CallbackHandler] Redirecting to success URL:", {
|
|
6709
6716
|
successRedirect,
|
|
6710
6717
|
});
|
|
6711
|
-
// For redirects, navigate to success page
|
|
6712
6718
|
window.location.href = successRedirect;
|
|
6713
6719
|
}
|
|
6720
|
+
else {
|
|
6721
|
+
debugLog(config, "CallbackHandler", "No successRedirect or onSuccess provided - user will remain on callback page");
|
|
6722
|
+
}
|
|
6714
6723
|
}, 100);
|
|
6715
6724
|
};
|
|
6716
6725
|
React.useEffect(() => {
|
|
@@ -6776,8 +6785,8 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
|
|
|
6776
6785
|
// Mark callback as processed to prevent re-execution
|
|
6777
6786
|
callbackProcessedRef.current = true;
|
|
6778
6787
|
if (!shouldPrompt) {
|
|
6779
|
-
// Proceed with normal redirect
|
|
6780
|
-
proceedWithRedirect();
|
|
6788
|
+
// Proceed with normal redirect, pass user directly to avoid state timing issues
|
|
6789
|
+
proceedWithRedirect(authenticatedUser);
|
|
6781
6790
|
}
|
|
6782
6791
|
}
|
|
6783
6792
|
catch (err) {
|
|
@@ -6827,8 +6836,8 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
|
|
|
6827
6836
|
// Mark callback as processed to prevent re-execution
|
|
6828
6837
|
callbackProcessedRef.current = true;
|
|
6829
6838
|
if (!shouldPrompt) {
|
|
6830
|
-
// Proceed with normal redirect
|
|
6831
|
-
proceedWithRedirect();
|
|
6839
|
+
// Proceed with normal redirect, pass user directly to avoid state timing issues
|
|
6840
|
+
proceedWithRedirect(authenticatedUser);
|
|
6832
6841
|
}
|
|
6833
6842
|
}
|
|
6834
6843
|
catch (err) {
|