@swype-org/react-sdk 0.1.130 → 0.1.132

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
@@ -6007,6 +6007,8 @@ function SwypePaymentInner({
6007
6007
  const initializedSelectSourceActionRef = react.useRef(null);
6008
6008
  const preSelectSourceStepRef = react.useRef(null);
6009
6009
  const pendingTokenAuthRef = react.useRef(null);
6010
+ const pendingTokenSelectionRef = react.useRef(null);
6011
+ const pendingTokenAuthSessionRef = react.useRef(null);
6010
6012
  const reauthSessionIdRef = react.useRef(null);
6011
6013
  const reauthTokenRef = react.useRef(null);
6012
6014
  const checkingPasskeyRef = react.useRef(false);
@@ -6505,10 +6507,15 @@ function SwypePaymentInner({
6505
6507
  dispatch({ type: "MOBILE_DEEPLINK_READY", deeplinkUri: session.uri });
6506
6508
  triggerDeeplink(session.uri);
6507
6509
  } else {
6508
- dispatch({ type: "NAVIGATE", step: "setup-status" });
6509
- await authExecutor.executeSessionById(session.id);
6510
- await reloadAccounts();
6510
+ pendingTokenAuthSessionRef.current = {
6511
+ sessionId: session.id,
6512
+ walletId: _walletId,
6513
+ tokenSymbol,
6514
+ tokenAddress,
6515
+ chainId
6516
+ };
6511
6517
  dispatch({ type: "SELECT_TOKEN", walletId: _walletId, tokenSymbol });
6518
+ dispatch({ type: "NAVIGATE", step: "setup" });
6512
6519
  }
6513
6520
  } catch (err) {
6514
6521
  captureException(err);
@@ -6658,6 +6665,32 @@ function SwypePaymentInner({
6658
6665
  await updateUserConfig(apiBaseUrl, token, { defaultAllowance: limit });
6659
6666
  if (authExecutor.pendingOneTapSetup) {
6660
6667
  authExecutor.resolveOneTapSetup();
6668
+ } else if (pendingTokenAuthSessionRef.current) {
6669
+ const pending = pendingTokenAuthSessionRef.current;
6670
+ pendingTokenAuthSessionRef.current = null;
6671
+ pendingTokenAuthRef.current = {
6672
+ tokenAddress: pending.tokenAddress,
6673
+ chainId: pending.chainId,
6674
+ tokenSymbol: pending.tokenSymbol,
6675
+ walletId: pending.walletId
6676
+ };
6677
+ dispatch({ type: "SET_INCREASING_LIMIT", value: true });
6678
+ dispatch({ type: "NAVIGATE", step: "setup-status" });
6679
+ try {
6680
+ await authExecutor.executeSessionById(pending.sessionId);
6681
+ await reloadAccounts();
6682
+ dispatch({ type: "SELECT_TOKEN", walletId: pending.walletId, tokenSymbol: pending.tokenSymbol });
6683
+ } catch (authErr) {
6684
+ captureException(authErr);
6685
+ dispatch({
6686
+ type: "SET_ERROR",
6687
+ error: authErr instanceof Error ? authErr.message : "Failed to authorize token"
6688
+ });
6689
+ dispatch({ type: "NAVIGATE", step: "deposit" });
6690
+ } finally {
6691
+ pendingTokenAuthRef.current = null;
6692
+ dispatch({ type: "SET_INCREASING_LIMIT", value: false });
6693
+ }
6661
6694
  } else {
6662
6695
  dispatch({ type: "NAVIGATE", step: "deposit" });
6663
6696
  }
@@ -6670,12 +6703,14 @@ function SwypePaymentInner({
6670
6703
  } finally {
6671
6704
  setSavingOneTapLimit(false);
6672
6705
  }
6673
- }, [getAccessToken, apiBaseUrl, authExecutor]);
6706
+ }, [getAccessToken, apiBaseUrl, authExecutor, reloadAccounts, onError]);
6674
6707
  const handleNewPayment = react.useCallback(() => {
6675
6708
  clearMobileFlowState();
6676
6709
  processingStartedAtRef.current = null;
6677
6710
  pollingTransferIdRef.current = null;
6678
6711
  preSelectSourceStepRef.current = null;
6712
+ pendingTokenSelectionRef.current = null;
6713
+ pendingTokenAuthSessionRef.current = null;
6679
6714
  dispatch({
6680
6715
  type: "NEW_PAYMENT",
6681
6716
  depositAmount,
@@ -6693,6 +6728,8 @@ function SwypePaymentInner({
6693
6728
  }
6694
6729
  polling.stopPolling();
6695
6730
  preSelectSourceStepRef.current = null;
6731
+ pendingTokenSelectionRef.current = null;
6732
+ pendingTokenAuthSessionRef.current = null;
6696
6733
  checkingPasskeyRef.current = false;
6697
6734
  setAuthInput("");
6698
6735
  setOtpCode("");