@swype-org/react-sdk 0.1.261 → 0.1.264
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.cjs +43 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +43 -34
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8665,24 +8665,32 @@ function useMobilePollingEffect(deps) {
|
|
|
8665
8665
|
handlingMobileReturnRef.current = false;
|
|
8666
8666
|
return;
|
|
8667
8667
|
}
|
|
8668
|
+
if (state.isGuestFlow && state.guestPreauthSessionId != null && mobileSetupFlowRef.current) {
|
|
8669
|
+
return;
|
|
8670
|
+
}
|
|
8668
8671
|
if (handlingMobileReturnRef.current) return;
|
|
8669
8672
|
const polledTransfer = polling.transfer;
|
|
8670
8673
|
if (!polledTransfer || polledTransfer.status !== "AUTHORIZED") return;
|
|
8671
8674
|
void handleAuthorizedMobileReturnRef.current(polledTransfer, mobileSetupFlowRef.current);
|
|
8672
|
-
}, [
|
|
8675
|
+
}, [
|
|
8676
|
+
state.mobileFlow,
|
|
8677
|
+
state.isGuestFlow,
|
|
8678
|
+
state.guestPreauthSessionId,
|
|
8679
|
+
polling.transfer,
|
|
8680
|
+
handlingMobileReturnRef,
|
|
8681
|
+
mobileSetupFlowRef
|
|
8682
|
+
]);
|
|
8673
8683
|
react.useEffect(() => {
|
|
8674
8684
|
if (!state.mobileFlow || !mobileSetupFlowRef.current) return;
|
|
8675
8685
|
if (!setupAccountIdRef.current) return;
|
|
8676
8686
|
if (!state.guestPreauthSessionId || !state.isGuestFlow) return;
|
|
8677
|
-
|
|
8678
|
-
const
|
|
8687
|
+
const guestToken = state.guestSessionToken;
|
|
8688
|
+
const preauthAccountId = state.guestPreauthAccountId;
|
|
8689
|
+
const preauthSessionId = state.guestPreauthSessionId;
|
|
8679
8690
|
let cancelled = false;
|
|
8680
8691
|
let completedGuestPreauth = false;
|
|
8681
8692
|
const POLL_INTERVAL_MS = 3e3;
|
|
8682
|
-
const
|
|
8683
|
-
if (completedGuestPreauth) return;
|
|
8684
|
-
completedGuestPreauth = true;
|
|
8685
|
-
cancelled = true;
|
|
8693
|
+
const finishMobileAndDispatch = async () => {
|
|
8686
8694
|
mobileSetupFlowRef.current = false;
|
|
8687
8695
|
setupAccountIdRef.current = null;
|
|
8688
8696
|
clearMobileFlowState();
|
|
@@ -8690,24 +8698,19 @@ function useMobilePollingEffect(deps) {
|
|
|
8690
8698
|
await reloadAccounts();
|
|
8691
8699
|
} catch {
|
|
8692
8700
|
}
|
|
8693
|
-
|
|
8694
|
-
|
|
8695
|
-
|
|
8696
|
-
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
}
|
|
8700
|
-
|
|
8701
|
-
|
|
8702
|
-
|
|
8703
|
-
|
|
8704
|
-
|
|
8705
|
-
|
|
8706
|
-
}
|
|
8707
|
-
if (guestLookup == null) {
|
|
8708
|
-
dispatch({ type: "MOBILE_SETUP_COMPLETE" });
|
|
8709
|
-
return;
|
|
8710
|
-
}
|
|
8701
|
+
};
|
|
8702
|
+
const completeGuestPreauthWithoutToken = async () => {
|
|
8703
|
+
if (completedGuestPreauth) return;
|
|
8704
|
+
completedGuestPreauth = true;
|
|
8705
|
+
cancelled = true;
|
|
8706
|
+
await finishMobileAndDispatch();
|
|
8707
|
+
dispatch({ type: "MOBILE_SETUP_COMPLETE" });
|
|
8708
|
+
};
|
|
8709
|
+
const completeGuestPreauthWithAccount = async (guestLookup) => {
|
|
8710
|
+
if (completedGuestPreauth) return;
|
|
8711
|
+
completedGuestPreauth = true;
|
|
8712
|
+
cancelled = true;
|
|
8713
|
+
await finishMobileAndDispatch();
|
|
8711
8714
|
if (guestLookup.accountId !== preauthAccountId) {
|
|
8712
8715
|
dispatch({
|
|
8713
8716
|
type: "GUEST_PREAUTH_DETECTED",
|
|
@@ -8720,24 +8723,28 @@ function useMobilePollingEffect(deps) {
|
|
|
8720
8723
|
}
|
|
8721
8724
|
dispatch({ type: "MOBILE_SETUP_COMPLETE" });
|
|
8722
8725
|
};
|
|
8723
|
-
const
|
|
8726
|
+
const pollGuestAccount = async () => {
|
|
8724
8727
|
try {
|
|
8725
8728
|
if (cancelled) return;
|
|
8726
|
-
|
|
8729
|
+
if (!guestToken) {
|
|
8730
|
+
await completeGuestPreauthWithoutToken();
|
|
8731
|
+
return;
|
|
8732
|
+
}
|
|
8733
|
+
const guestLookup = await fetchGuestAccount(apiBaseUrl, guestToken);
|
|
8727
8734
|
if (cancelled) return;
|
|
8728
|
-
if (
|
|
8729
|
-
await
|
|
8735
|
+
if (guestLookup != null) {
|
|
8736
|
+
await completeGuestPreauthWithAccount(guestLookup);
|
|
8730
8737
|
}
|
|
8731
8738
|
} catch {
|
|
8732
8739
|
}
|
|
8733
8740
|
};
|
|
8734
|
-
|
|
8735
|
-
const intervalId = window.setInterval(
|
|
8741
|
+
pollGuestAccount();
|
|
8742
|
+
const intervalId = window.setInterval(pollGuestAccount, POLL_INTERVAL_MS);
|
|
8736
8743
|
const handleVisibility = () => {
|
|
8737
|
-
if (document.visibilityState === "visible" && !cancelled) void
|
|
8744
|
+
if (document.visibilityState === "visible" && !cancelled) void pollGuestAccount();
|
|
8738
8745
|
};
|
|
8739
8746
|
const handlePageShow = (e) => {
|
|
8740
|
-
if (e.persisted && !cancelled) void
|
|
8747
|
+
if (e.persisted && !cancelled) void pollGuestAccount();
|
|
8741
8748
|
};
|
|
8742
8749
|
document.addEventListener("visibilitychange", handleVisibility);
|
|
8743
8750
|
window.addEventListener("pageshow", handlePageShow);
|
|
@@ -8749,7 +8756,6 @@ function useMobilePollingEffect(deps) {
|
|
|
8749
8756
|
};
|
|
8750
8757
|
}, [
|
|
8751
8758
|
state.mobileFlow,
|
|
8752
|
-
state.activeCredentialId,
|
|
8753
8759
|
state.guestPreauthSessionId,
|
|
8754
8760
|
state.isGuestFlow,
|
|
8755
8761
|
state.guestSessionToken,
|
|
@@ -8762,6 +8768,7 @@ function useMobilePollingEffect(deps) {
|
|
|
8762
8768
|
]);
|
|
8763
8769
|
react.useEffect(() => {
|
|
8764
8770
|
if (!state.mobileFlow || !mobileSetupFlowRef.current) return;
|
|
8771
|
+
if (state.isGuestFlow && state.guestPreauthSessionId != null) return;
|
|
8765
8772
|
if (!state.activeCredentialId || !setupAccountIdRef.current) return;
|
|
8766
8773
|
const accountId = setupAccountIdRef.current;
|
|
8767
8774
|
const credentialId = state.activeCredentialId;
|
|
@@ -8850,6 +8857,8 @@ function useMobilePollingEffect(deps) {
|
|
|
8850
8857
|
};
|
|
8851
8858
|
}, [
|
|
8852
8859
|
state.mobileFlow,
|
|
8860
|
+
state.isGuestFlow,
|
|
8861
|
+
state.guestPreauthSessionId,
|
|
8853
8862
|
state.activeCredentialId,
|
|
8854
8863
|
apiBaseUrl,
|
|
8855
8864
|
reloadAccounts,
|