@swype-org/react-sdk 0.1.158 → 0.1.159

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
@@ -6472,16 +6472,10 @@ function useMobileFlowHandlers(dispatch, polling, reloadAccounts, pollingTransfe
6472
6472
  clearMobileFlowState();
6473
6473
  try {
6474
6474
  await reloadAccounts();
6475
- loadingDataRef.current = false;
6476
- dispatch({ type: "MOBILE_SETUP_COMPLETE", transfer: authorizedTransfer });
6477
- } catch (err) {
6478
- handlingMobileReturnRef.current = false;
6479
- dispatch({
6480
- type: "SET_ERROR",
6481
- error: err instanceof Error ? err.message : "Wallet authorized, but we could not refresh your account yet."
6482
- });
6483
- dispatch({ type: "NAVIGATE", step: "open-wallet" });
6475
+ } catch {
6484
6476
  }
6477
+ loadingDataRef.current = false;
6478
+ dispatch({ type: "MOBILE_SETUP_COMPLETE", transfer: authorizedTransfer });
6485
6479
  return;
6486
6480
  }
6487
6481
  mobileSetupFlowRef.current = false;
@@ -6662,7 +6656,17 @@ function useProviderHandlers(deps) {
6662
6656
  const acct = accounts.find((a) => a.id === accountId);
6663
6657
  if (!acct) return;
6664
6658
  const matchedProvider = providers.find((p) => p.name === acct.name);
6665
- if (matchedProvider) {
6659
+ if (!matchedProvider) return;
6660
+ const pendingSession = acct.authorizationSessions?.find(
6661
+ (s) => s.status === "PENDING"
6662
+ );
6663
+ if (pendingSession) {
6664
+ handleSelectProvider(matchedProvider.id, {
6665
+ accountId: acct.id,
6666
+ sessionId: pendingSession.id,
6667
+ uri: pendingSession.uri
6668
+ });
6669
+ } else {
6666
6670
  handleSelectProvider(matchedProvider.id);
6667
6671
  }
6668
6672
  },
@@ -7099,8 +7103,25 @@ function usePaymentEffects(deps) {
7099
7103
  return;
7100
7104
  }
7101
7105
  if (resolved.step === "open-wallet" && persisted && persisted.accountId && !persisted.transferId) {
7102
- clearMobileFlowState();
7103
- dispatch({ type: "NAVIGATE", step: "deposit" });
7106
+ if (persisted.sessionId) {
7107
+ try {
7108
+ const session = await fetchAuthorizationSession(apiBaseUrl, persisted.sessionId);
7109
+ if (cancelled) return;
7110
+ if (session.status === "AUTHORIZED") {
7111
+ clearMobileFlowState();
7112
+ dispatch({ type: "NAVIGATE", step: "deposit" });
7113
+ return;
7114
+ }
7115
+ } catch {
7116
+ }
7117
+ }
7118
+ mobileSetupFlowRef.current = true;
7119
+ setupAccountIdRef.current = persisted.accountId;
7120
+ dispatch({
7121
+ type: "ENTER_MOBILE_FLOW",
7122
+ deeplinkUri: persisted.deeplinkUri,
7123
+ providerId: persisted.providerId
7124
+ });
7104
7125
  return;
7105
7126
  }
7106
7127
  if (resolved.step === "open-wallet" && persisted && persisted.transferId) {
@@ -7369,6 +7390,8 @@ function usePaymentEffects(deps) {
7369
7390
  const isReauth = !!reauthSessionIdRef.current;
7370
7391
  const sessionId = reauthSessionIdRef.current;
7371
7392
  const tokenSelection = reauthTokenRef.current;
7393
+ const persistedFlow = loadMobileFlowState();
7394
+ const setupSessionId = !isReauth ? persistedFlow?.sessionId : void 0;
7372
7395
  let cancelled = false;
7373
7396
  const POLL_INTERVAL_MS = 3e3;
7374
7397
  const pollReauthorization = async () => {
@@ -7395,6 +7418,17 @@ function usePaymentEffects(deps) {
7395
7418
  } catch {
7396
7419
  }
7397
7420
  };
7421
+ const completeSetup = async () => {
7422
+ cancelled = true;
7423
+ mobileSetupFlowRef.current = false;
7424
+ setupAccountIdRef.current = null;
7425
+ clearMobileFlowState();
7426
+ try {
7427
+ await reloadAccounts();
7428
+ } catch {
7429
+ }
7430
+ dispatch({ type: "MOBILE_SETUP_COMPLETE" });
7431
+ };
7398
7432
  const pollWalletActive = async () => {
7399
7433
  try {
7400
7434
  const token = await getAccessTokenRef.current();
@@ -7403,15 +7437,18 @@ function usePaymentEffects(deps) {
7403
7437
  if (cancelled) return;
7404
7438
  const hasActive = acct.wallets.some((w) => w.status === "ACTIVE");
7405
7439
  if (hasActive) {
7406
- cancelled = true;
7407
- mobileSetupFlowRef.current = false;
7408
- setupAccountIdRef.current = null;
7409
- clearMobileFlowState();
7440
+ await completeSetup();
7441
+ return;
7442
+ }
7443
+ if (setupSessionId) {
7410
7444
  try {
7411
- await reloadAccounts();
7445
+ const session = await fetchAuthorizationSession(apiBaseUrl, setupSessionId);
7446
+ if (cancelled) return;
7447
+ if (session.status === "AUTHORIZED") {
7448
+ await completeSetup();
7449
+ }
7412
7450
  } catch {
7413
7451
  }
7414
- dispatch({ type: "MOBILE_SETUP_COMPLETE" });
7415
7452
  }
7416
7453
  } catch {
7417
7454
  }