@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.cjs CHANGED
@@ -8707,7 +8707,6 @@ function useMobilePollingEffect(deps) {
8707
8707
  const finishMobileAndDispatch = async () => {
8708
8708
  mobileSetupFlowRef.current = false;
8709
8709
  setupAccountIdRef.current = null;
8710
- clearMobileFlowState();
8711
8710
  try {
8712
8711
  await reloadAccounts();
8713
8712
  } catch {
@@ -8718,6 +8717,7 @@ function useMobilePollingEffect(deps) {
8718
8717
  completedGuestPreauth = true;
8719
8718
  cancelled = true;
8720
8719
  await finishMobileAndDispatch();
8720
+ clearMobileFlowState();
8721
8721
  dispatch({ type: "MOBILE_SETUP_COMPLETE" });
8722
8722
  };
8723
8723
  const completeGuestPreauthWithAccount = async (guestLookup) => {
@@ -8745,6 +8745,18 @@ function useMobilePollingEffect(deps) {
8745
8745
  const guestLookup = await fetchGuestAccount(apiBaseUrl, guestToken);
8746
8746
  if (cancelled) return;
8747
8747
  if (guestLookup != null) {
8748
+ if (preauthSessionId) {
8749
+ try {
8750
+ const session = await fetchAuthorizationSession(
8751
+ apiBaseUrl,
8752
+ preauthSessionId
8753
+ );
8754
+ if (cancelled) return;
8755
+ if (session.status !== "AUTHORIZED") return;
8756
+ } catch {
8757
+ return;
8758
+ }
8759
+ }
8748
8760
  await completeGuestPreauthWithAccount(guestLookup);
8749
8761
  }
8750
8762
  } catch {
@@ -8755,8 +8767,8 @@ function useMobilePollingEffect(deps) {
8755
8767
  const handleVisibility = () => {
8756
8768
  if (document.visibilityState === "visible" && !cancelled) void pollGuestAccount();
8757
8769
  };
8758
- const handlePageShow = (e) => {
8759
- if (e.persisted && !cancelled) void pollGuestAccount();
8770
+ const handlePageShow = () => {
8771
+ if (document.visibilityState === "visible" && !cancelled) void pollGuestAccount();
8760
8772
  };
8761
8773
  document.addEventListener("visibilitychange", handleVisibility);
8762
8774
  window.addEventListener("pageshow", handlePageShow);
@@ -8958,6 +8970,18 @@ function useGuestPreauthMobileRestoreEffect(deps) {
8958
8970
  const guestLookup = await fetchGuestAccount(apiBaseUrl, guestToken);
8959
8971
  if (cancelled) return;
8960
8972
  if (guestLookup != null) {
8973
+ if (persisted.sessionId) {
8974
+ try {
8975
+ const session = await fetchAuthorizationSession(
8976
+ apiBaseUrl,
8977
+ persisted.sessionId
8978
+ );
8979
+ if (cancelled) return;
8980
+ if (session.status !== "AUTHORIZED") return;
8981
+ } catch {
8982
+ return;
8983
+ }
8984
+ }
8961
8985
  await handleAccountFound(guestLookup);
8962
8986
  }
8963
8987
  } catch {
@@ -8968,8 +8992,8 @@ function useGuestPreauthMobileRestoreEffect(deps) {
8968
8992
  const handlePollVisibility = () => {
8969
8993
  if (document.visibilityState === "visible" && !cancelled) void pollGuestAccount();
8970
8994
  };
8971
- const handlePollPageShow = (e) => {
8972
- if (e.persisted && !cancelled) void pollGuestAccount();
8995
+ const handlePollPageShow = () => {
8996
+ if (document.visibilityState === "visible" && !cancelled) void pollGuestAccount();
8973
8997
  };
8974
8998
  document.addEventListener("visibilitychange", handlePollVisibility);
8975
8999
  window.addEventListener("pageshow", handlePollPageShow);
@@ -8987,8 +9011,8 @@ function useGuestPreauthMobileRestoreEffect(deps) {
8987
9011
  const onOuterVisibility = () => {
8988
9012
  if (document.visibilityState === "visible") tryStart();
8989
9013
  };
8990
- const onOuterPageShow = (e) => {
8991
- if (e.persisted) tryStart();
9014
+ const onOuterPageShow = () => {
9015
+ if (document.visibilityState === "visible") tryStart();
8992
9016
  };
8993
9017
  tryStart();
8994
9018
  document.addEventListener("visibilitychange", onOuterVisibility);