@swype-org/react-sdk 0.1.91 → 0.1.93

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
@@ -4949,7 +4949,7 @@ function StepRenderer({
4949
4949
  );
4950
4950
  }
4951
4951
  if ((step === "login" || step === "otp-verify") && authenticated) {
4952
- return /* @__PURE__ */ jsxRuntime.jsx(CenteredSpinner, { label: "Verifying your passkey..." });
4952
+ return /* @__PURE__ */ jsxRuntime.jsx(CenteredSpinner, { label: "Verifying your passkey...test2" });
4953
4953
  }
4954
4954
  if (step === "verify-passkey") {
4955
4955
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -5233,12 +5233,20 @@ function SwypePaymentInner({
5233
5233
  const processingStartedAtRef = react.useRef(null);
5234
5234
  const initializedSelectSourceActionRef = react.useRef(null);
5235
5235
  const preSelectSourceStepRef = react.useRef(null);
5236
+ const checkingPasskeyRef = react.useRef(false);
5237
+ const onCompleteRef = react.useRef(onComplete);
5238
+ onCompleteRef.current = onComplete;
5239
+ const pollingRef = react.useRef(null);
5240
+ const handleAuthorizedMobileReturnRef = react.useRef(
5241
+ null
5242
+ );
5236
5243
  const [authInput, setAuthInput] = react.useState("");
5237
5244
  const [otpCode, setOtpCode] = react.useState("");
5238
5245
  const [selectSourceChainName, setSelectSourceChainName] = react.useState("");
5239
5246
  const [selectSourceTokenSymbol, setSelectSourceTokenSymbol] = react.useState("");
5240
5247
  const authExecutor = useAuthorizationExecutor();
5241
5248
  const polling = useTransferPolling();
5249
+ pollingRef.current = polling;
5242
5250
  const transferSigning = useTransferSigning();
5243
5251
  const { sourceType, sourceId } = deriveSourceTypeAndId(state);
5244
5252
  const selectedAccount = state.accounts.find((a) => a.id === state.selectedAccountId);
@@ -5492,6 +5500,7 @@ function SwypePaymentInner({
5492
5500
  clearMobileFlowState();
5493
5501
  dispatch({ type: "MOBILE_SIGN_READY", transfer: authorizedTransfer });
5494
5502
  }, [polling.stopPolling, reloadAccounts]);
5503
+ handleAuthorizedMobileReturnRef.current = handleAuthorizedMobileReturn;
5495
5504
  const handlePay = react.useCallback(async (payAmount, sourceOverrides) => {
5496
5505
  if (isNaN(payAmount) || payAmount < MIN_SEND_AMOUNT_USD) {
5497
5506
  dispatch({ type: "SET_ERROR", error: `Minimum amount is $${MIN_SEND_AMOUNT_USD.toFixed(2)}.` });
@@ -5761,6 +5770,7 @@ function SwypePaymentInner({
5761
5770
  }
5762
5771
  polling.stopPolling();
5763
5772
  preSelectSourceStepRef.current = null;
5773
+ checkingPasskeyRef.current = false;
5764
5774
  setAuthInput("");
5765
5775
  setOtpCode("");
5766
5776
  dispatch({ type: "LOGOUT", depositAmount });
@@ -5809,8 +5819,13 @@ function SwypePaymentInner({
5809
5819
  }
5810
5820
  }, [otpCode, state.step, activeOtpStatus, handleVerifyLoginCode]);
5811
5821
  react.useEffect(() => {
5812
- if (!ready || !authenticated) return;
5822
+ if (!ready || !authenticated) {
5823
+ checkingPasskeyRef.current = false;
5824
+ return;
5825
+ }
5813
5826
  if (state.step !== "login" && state.step !== "otp-verify") return;
5827
+ if (checkingPasskeyRef.current) return;
5828
+ checkingPasskeyRef.current = true;
5814
5829
  let cancelled = false;
5815
5830
  dispatch({ type: "SET_ERROR", error: null });
5816
5831
  setAuthInput("");
@@ -5836,7 +5851,7 @@ function SwypePaymentInner({
5836
5851
  const existingTransfer = await fetchTransfer(apiBaseUrl, token, persisted.transferId);
5837
5852
  if (cancelled) return;
5838
5853
  if (existingTransfer.status === "AUTHORIZED") {
5839
- await handleAuthorizedMobileReturn(existingTransfer, true);
5854
+ await handleAuthorizedMobileReturnRef.current(existingTransfer, true);
5840
5855
  return;
5841
5856
  }
5842
5857
  } catch {
@@ -5851,17 +5866,17 @@ function SwypePaymentInner({
5851
5866
  persisted.isSetup
5852
5867
  );
5853
5868
  if (mobileResolution.kind === "resume-setup-deposit") {
5854
- await handleAuthorizedMobileReturn(existingTransfer, true);
5869
+ await handleAuthorizedMobileReturnRef.current(existingTransfer, true);
5855
5870
  return;
5856
5871
  }
5857
5872
  if (mobileResolution.kind === "resume-confirm-sign") {
5858
- await handleAuthorizedMobileReturn(existingTransfer, false);
5873
+ await handleAuthorizedMobileReturnRef.current(existingTransfer, false);
5859
5874
  return;
5860
5875
  }
5861
5876
  if (mobileResolution.kind === "resume-success") {
5862
5877
  clearMobileFlowState();
5863
5878
  dispatch({ type: "MOBILE_RESUME_SUCCESS", transfer: existingTransfer });
5864
- onComplete?.(existingTransfer);
5879
+ onCompleteRef.current?.(existingTransfer);
5865
5880
  return;
5866
5881
  }
5867
5882
  if (mobileResolution.kind === "resume-failed") {
@@ -5872,7 +5887,7 @@ function SwypePaymentInner({
5872
5887
  if (mobileResolution.kind === "resume-processing") {
5873
5888
  clearMobileFlowState();
5874
5889
  dispatch({ type: "MOBILE_RESUME_PROCESSING", transfer: existingTransfer });
5875
- polling.startPolling(existingTransfer.id);
5890
+ pollingRef.current.startPolling(existingTransfer.id);
5876
5891
  return;
5877
5892
  }
5878
5893
  if (mobileResolution.kind === "resume-stale-setup") {
@@ -5890,7 +5905,7 @@ function SwypePaymentInner({
5890
5905
  });
5891
5906
  pollingTransferIdRef.current = persisted.transferId;
5892
5907
  mobileSetupFlowRef.current = persisted.isSetup;
5893
- polling.startPolling(persisted.transferId);
5908
+ pollingRef.current.startPolling(persisted.transferId);
5894
5909
  return;
5895
5910
  }
5896
5911
  dispatch({
@@ -5900,7 +5915,7 @@ function SwypePaymentInner({
5900
5915
  });
5901
5916
  pollingTransferIdRef.current = persisted.transferId;
5902
5917
  mobileSetupFlowRef.current = persisted.isSetup;
5903
- polling.startPolling(persisted.transferId);
5918
+ pollingRef.current.startPolling(persisted.transferId);
5904
5919
  return;
5905
5920
  }
5906
5921
  dispatch({ type: "NAVIGATE", step: resolved.step });
@@ -5959,17 +5974,7 @@ function SwypePaymentInner({
5959
5974
  return () => {
5960
5975
  cancelled = true;
5961
5976
  };
5962
- }, [
5963
- ready,
5964
- authenticated,
5965
- state.step,
5966
- apiBaseUrl,
5967
- getAccessToken,
5968
- state.activeCredentialId,
5969
- handleAuthorizedMobileReturn,
5970
- onComplete,
5971
- polling
5972
- ]);
5977
+ }, [ready, authenticated, state.step, apiBaseUrl, getAccessToken, state.activeCredentialId]);
5973
5978
  react.useEffect(() => {
5974
5979
  const loadAction = resolveDataLoadAction({
5975
5980
  authenticated,