@swype-org/react-sdk 0.1.267 → 0.1.269

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
@@ -8704,7 +8704,6 @@ function useMobilePollingEffect(deps) {
8704
8704
  const finishMobileAndDispatch = async () => {
8705
8705
  mobileSetupFlowRef.current = false;
8706
8706
  setupAccountIdRef.current = null;
8707
- clearMobileFlowState();
8708
8707
  try {
8709
8708
  await reloadAccounts();
8710
8709
  } catch {
@@ -8715,6 +8714,7 @@ function useMobilePollingEffect(deps) {
8715
8714
  completedGuestPreauth = true;
8716
8715
  cancelled = true;
8717
8716
  await finishMobileAndDispatch();
8717
+ clearMobileFlowState();
8718
8718
  dispatch({ type: "MOBILE_SETUP_COMPLETE" });
8719
8719
  };
8720
8720
  const completeGuestPreauthWithAccount = async (guestLookup) => {
@@ -8742,6 +8742,18 @@ function useMobilePollingEffect(deps) {
8742
8742
  const guestLookup = await fetchGuestAccount(apiBaseUrl, guestToken);
8743
8743
  if (cancelled) return;
8744
8744
  if (guestLookup != null) {
8745
+ if (preauthSessionId) {
8746
+ try {
8747
+ const session = await fetchAuthorizationSession(
8748
+ apiBaseUrl,
8749
+ preauthSessionId
8750
+ );
8751
+ if (cancelled) return;
8752
+ if (session.status !== "AUTHORIZED") return;
8753
+ } catch {
8754
+ return;
8755
+ }
8756
+ }
8745
8757
  await completeGuestPreauthWithAccount(guestLookup);
8746
8758
  }
8747
8759
  } catch {
@@ -8752,8 +8764,8 @@ function useMobilePollingEffect(deps) {
8752
8764
  const handleVisibility = () => {
8753
8765
  if (document.visibilityState === "visible" && !cancelled) void pollGuestAccount();
8754
8766
  };
8755
- const handlePageShow = (e) => {
8756
- if (e.persisted && !cancelled) void pollGuestAccount();
8767
+ const handlePageShow = () => {
8768
+ if (document.visibilityState === "visible" && !cancelled) void pollGuestAccount();
8757
8769
  };
8758
8770
  document.addEventListener("visibilitychange", handleVisibility);
8759
8771
  window.addEventListener("pageshow", handlePageShow);
@@ -8955,6 +8967,18 @@ function useGuestPreauthMobileRestoreEffect(deps) {
8955
8967
  const guestLookup = await fetchGuestAccount(apiBaseUrl, guestToken);
8956
8968
  if (cancelled) return;
8957
8969
  if (guestLookup != null) {
8970
+ if (persisted.sessionId) {
8971
+ try {
8972
+ const session = await fetchAuthorizationSession(
8973
+ apiBaseUrl,
8974
+ persisted.sessionId
8975
+ );
8976
+ if (cancelled) return;
8977
+ if (session.status !== "AUTHORIZED") return;
8978
+ } catch {
8979
+ return;
8980
+ }
8981
+ }
8958
8982
  await handleAccountFound(guestLookup);
8959
8983
  }
8960
8984
  } catch {
@@ -8965,8 +8989,8 @@ function useGuestPreauthMobileRestoreEffect(deps) {
8965
8989
  const handlePollVisibility = () => {
8966
8990
  if (document.visibilityState === "visible" && !cancelled) void pollGuestAccount();
8967
8991
  };
8968
- const handlePollPageShow = (e) => {
8969
- if (e.persisted && !cancelled) void pollGuestAccount();
8992
+ const handlePollPageShow = () => {
8993
+ if (document.visibilityState === "visible" && !cancelled) void pollGuestAccount();
8970
8994
  };
8971
8995
  document.addEventListener("visibilitychange", handlePollVisibility);
8972
8996
  window.addEventListener("pageshow", handlePollPageShow);
@@ -8984,8 +9008,8 @@ function useGuestPreauthMobileRestoreEffect(deps) {
8984
9008
  const onOuterVisibility = () => {
8985
9009
  if (document.visibilityState === "visible") tryStart();
8986
9010
  };
8987
- const onOuterPageShow = (e) => {
8988
- if (e.persisted) tryStart();
9011
+ const onOuterPageShow = () => {
9012
+ if (document.visibilityState === "visible") tryStart();
8989
9013
  };
8990
9014
  tryStart();
8991
9015
  document.addEventListener("visibilitychange", onOuterVisibility);