@swype-org/react-sdk 0.1.131 → 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
@@ -6008,6 +6008,7 @@ function SwypePaymentInner({
6008
6008
  const preSelectSourceStepRef = react.useRef(null);
6009
6009
  const pendingTokenAuthRef = react.useRef(null);
6010
6010
  const pendingTokenSelectionRef = react.useRef(null);
6011
+ const pendingTokenAuthSessionRef = react.useRef(null);
6011
6012
  const reauthSessionIdRef = react.useRef(null);
6012
6013
  const reauthTokenRef = react.useRef(null);
6013
6014
  const checkingPasskeyRef = react.useRef(false);
@@ -6506,10 +6507,14 @@ function SwypePaymentInner({
6506
6507
  dispatch({ type: "MOBILE_DEEPLINK_READY", deeplinkUri: session.uri });
6507
6508
  triggerDeeplink(session.uri);
6508
6509
  } else {
6509
- dispatch({ type: "NAVIGATE", step: "setup-status" });
6510
- await authExecutor.executeSessionById(session.id);
6511
- await reloadAccounts();
6512
- pendingTokenSelectionRef.current = { walletId: _walletId, tokenSymbol };
6510
+ pendingTokenAuthSessionRef.current = {
6511
+ sessionId: session.id,
6512
+ walletId: _walletId,
6513
+ tokenSymbol,
6514
+ tokenAddress,
6515
+ chainId
6516
+ };
6517
+ dispatch({ type: "SELECT_TOKEN", walletId: _walletId, tokenSymbol });
6513
6518
  dispatch({ type: "NAVIGATE", step: "setup" });
6514
6519
  }
6515
6520
  } catch (err) {
@@ -6660,10 +6665,32 @@ function SwypePaymentInner({
6660
6665
  await updateUserConfig(apiBaseUrl, token, { defaultAllowance: limit });
6661
6666
  if (authExecutor.pendingOneTapSetup) {
6662
6667
  authExecutor.resolveOneTapSetup();
6663
- } else if (pendingTokenSelectionRef.current) {
6664
- const sel = pendingTokenSelectionRef.current;
6665
- pendingTokenSelectionRef.current = null;
6666
- dispatch({ type: "SELECT_TOKEN", walletId: sel.walletId, tokenSymbol: sel.tokenSymbol });
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
+ }
6667
6694
  } else {
6668
6695
  dispatch({ type: "NAVIGATE", step: "deposit" });
6669
6696
  }
@@ -6676,13 +6703,14 @@ function SwypePaymentInner({
6676
6703
  } finally {
6677
6704
  setSavingOneTapLimit(false);
6678
6705
  }
6679
- }, [getAccessToken, apiBaseUrl, authExecutor]);
6706
+ }, [getAccessToken, apiBaseUrl, authExecutor, reloadAccounts, onError]);
6680
6707
  const handleNewPayment = react.useCallback(() => {
6681
6708
  clearMobileFlowState();
6682
6709
  processingStartedAtRef.current = null;
6683
6710
  pollingTransferIdRef.current = null;
6684
6711
  preSelectSourceStepRef.current = null;
6685
6712
  pendingTokenSelectionRef.current = null;
6713
+ pendingTokenAuthSessionRef.current = null;
6686
6714
  dispatch({
6687
6715
  type: "NEW_PAYMENT",
6688
6716
  depositAmount,
@@ -6701,6 +6729,7 @@ function SwypePaymentInner({
6701
6729
  polling.stopPolling();
6702
6730
  preSelectSourceStepRef.current = null;
6703
6731
  pendingTokenSelectionRef.current = null;
6732
+ pendingTokenAuthSessionRef.current = null;
6704
6733
  checkingPasskeyRef.current = false;
6705
6734
  setAuthInput("");
6706
6735
  setOtpCode("");