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