@passkeyme/react-auth 2.2.3 → 2.2.5
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 +14 -13
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +14 -13
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasskeymeCallbackHandler.d.ts","sourceRoot":"","sources":["../../src/components/PasskeymeCallbackHandler.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAuLzD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,iBAAiB,EAAE,GAAG,GAAG,IAAI,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,wBAAwB,GAAI,sIAQtC,6BAA6B,
|
|
1
|
+
{"version":3,"file":"PasskeymeCallbackHandler.d.ts","sourceRoot":"","sources":["../../src/components/PasskeymeCallbackHandler.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAuLzD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,iBAAiB,EAAE,GAAG,GAAG,IAAI,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,wBAAwB,GAAI,sIAQtC,6BAA6B,mDAo3B/B,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -6473,7 +6473,8 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
|
|
|
6473
6473
|
authenticatedUser: null,
|
|
6474
6474
|
});
|
|
6475
6475
|
// Track if we've already processed the callback to prevent loops
|
|
6476
|
-
|
|
6476
|
+
// Using useRef instead of useState to avoid triggering re-renders when marked as processed
|
|
6477
|
+
const callbackProcessedRef = useRef(false);
|
|
6477
6478
|
// Get effective passkey configuration (merge config with props)
|
|
6478
6479
|
const effectivePasskeyConfig = {
|
|
6479
6480
|
promptRegistration: (_d = (_b = (_a = passkey === null || passkey === void 0 ? void 0 : passkey.promptRegistration) !== null && _a !== void 0 ? _a : config.autoPromptPasskeyRegistration) !== null && _b !== void 0 ? _b : (_c = config.passkey) === null || _c === void 0 ? void 0 : _c.autoPromptRegistration) !== null && _d !== void 0 ? _d : true, // Default to true
|
|
@@ -6685,6 +6686,8 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
|
|
|
6685
6686
|
};
|
|
6686
6687
|
// Proceed with redirect after auth completion
|
|
6687
6688
|
const proceedWithRedirect = async () => {
|
|
6689
|
+
// Clean URL immediately to prevent effect re-run with stale URL params
|
|
6690
|
+
window.history.replaceState({}, document.title, window.location.pathname);
|
|
6688
6691
|
setTimeout(async () => {
|
|
6689
6692
|
const currentUser = state.authenticatedUser || user;
|
|
6690
6693
|
if (onSuccess && currentUser) {
|
|
@@ -6699,15 +6702,14 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
|
|
|
6699
6702
|
}
|
|
6700
6703
|
}
|
|
6701
6704
|
else {
|
|
6702
|
-
//
|
|
6703
|
-
window.history.replaceState({}, document.title, window.location.pathname);
|
|
6705
|
+
// Redirect to success page
|
|
6704
6706
|
window.location.href = successRedirect;
|
|
6705
6707
|
}
|
|
6706
6708
|
}, 100);
|
|
6707
6709
|
};
|
|
6708
6710
|
useEffect(() => {
|
|
6709
6711
|
// Don't process callback again if we've already done it
|
|
6710
|
-
if (
|
|
6712
|
+
if (callbackProcessedRef.current)
|
|
6711
6713
|
return;
|
|
6712
6714
|
const processCallback = async () => {
|
|
6713
6715
|
try {
|
|
@@ -6727,7 +6729,7 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
|
|
|
6727
6729
|
if (error) {
|
|
6728
6730
|
const errorMessage = errorDescription || error || "Authentication failed";
|
|
6729
6731
|
updateState({ loading: false, error: errorMessage, success: false });
|
|
6730
|
-
|
|
6732
|
+
callbackProcessedRef.current = true;
|
|
6731
6733
|
if (onError) {
|
|
6732
6734
|
onError(errorMessage);
|
|
6733
6735
|
}
|
|
@@ -6766,7 +6768,7 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
|
|
|
6766
6768
|
});
|
|
6767
6769
|
debugLog(config, "CallbackHandler", "Token flow - updated state, showPasskeyPrompt:", shouldPrompt);
|
|
6768
6770
|
// Mark callback as processed to prevent re-execution
|
|
6769
|
-
|
|
6771
|
+
callbackProcessedRef.current = true;
|
|
6770
6772
|
if (!shouldPrompt) {
|
|
6771
6773
|
// Proceed with normal redirect
|
|
6772
6774
|
proceedWithRedirect();
|
|
@@ -6779,7 +6781,7 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
|
|
|
6779
6781
|
error: errorMessage,
|
|
6780
6782
|
success: false,
|
|
6781
6783
|
});
|
|
6782
|
-
|
|
6784
|
+
callbackProcessedRef.current = true;
|
|
6783
6785
|
if (onError) {
|
|
6784
6786
|
onError(errorMessage);
|
|
6785
6787
|
}
|
|
@@ -6817,7 +6819,7 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
|
|
|
6817
6819
|
});
|
|
6818
6820
|
debugLog(config, "CallbackHandler", "OAuth code flow - updated state, showPasskeyPrompt:", shouldPrompt);
|
|
6819
6821
|
// Mark callback as processed to prevent re-execution
|
|
6820
|
-
|
|
6822
|
+
callbackProcessedRef.current = true;
|
|
6821
6823
|
if (!shouldPrompt) {
|
|
6822
6824
|
// Proceed with normal redirect
|
|
6823
6825
|
proceedWithRedirect();
|
|
@@ -6830,7 +6832,7 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
|
|
|
6830
6832
|
error: errorMessage,
|
|
6831
6833
|
success: false,
|
|
6832
6834
|
});
|
|
6833
|
-
|
|
6835
|
+
callbackProcessedRef.current = true;
|
|
6834
6836
|
if (onError) {
|
|
6835
6837
|
onError(errorMessage);
|
|
6836
6838
|
}
|
|
@@ -6848,7 +6850,7 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
|
|
|
6848
6850
|
if (!token && !code) {
|
|
6849
6851
|
const errorMessage = "No authentication token or code received";
|
|
6850
6852
|
updateState({ loading: false, error: errorMessage, success: false });
|
|
6851
|
-
|
|
6853
|
+
callbackProcessedRef.current = true;
|
|
6852
6854
|
if (onError) {
|
|
6853
6855
|
onError(errorMessage);
|
|
6854
6856
|
}
|
|
@@ -6861,12 +6863,12 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
|
|
|
6861
6863
|
}
|
|
6862
6864
|
}
|
|
6863
6865
|
// Mark as processed if we got here
|
|
6864
|
-
|
|
6866
|
+
callbackProcessedRef.current = true;
|
|
6865
6867
|
}
|
|
6866
6868
|
catch (err) {
|
|
6867
6869
|
const errorMessage = err instanceof Error ? err.message : "Authentication failed";
|
|
6868
6870
|
updateState({ loading: false, error: errorMessage, success: false });
|
|
6869
|
-
|
|
6871
|
+
callbackProcessedRef.current = true;
|
|
6870
6872
|
if (onError) {
|
|
6871
6873
|
onError(errorMessage);
|
|
6872
6874
|
}
|
|
@@ -6881,7 +6883,6 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
|
|
|
6881
6883
|
};
|
|
6882
6884
|
processCallback();
|
|
6883
6885
|
}, [
|
|
6884
|
-
callbackProcessed,
|
|
6885
6886
|
handleCallback,
|
|
6886
6887
|
handleTokenCallback,
|
|
6887
6888
|
onError,
|