@swype-org/react-sdk 0.1.90 → 0.1.92

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.js CHANGED
@@ -5230,6 +5230,9 @@ function SwypePaymentInner({
5230
5230
  const processingStartedAtRef = useRef(null);
5231
5231
  const initializedSelectSourceActionRef = useRef(null);
5232
5232
  const preSelectSourceStepRef = useRef(null);
5233
+ const checkingPasskeyRef = useRef(false);
5234
+ const onCompleteRef = useRef(onComplete);
5235
+ onCompleteRef.current = onComplete;
5233
5236
  const [authInput, setAuthInput] = useState("");
5234
5237
  const [otpCode, setOtpCode] = useState("");
5235
5238
  const [selectSourceChainName, setSelectSourceChainName] = useState("");
@@ -5808,6 +5811,8 @@ function SwypePaymentInner({
5808
5811
  useEffect(() => {
5809
5812
  if (!ready || !authenticated) return;
5810
5813
  if (state.step !== "login" && state.step !== "otp-verify") return;
5814
+ if (checkingPasskeyRef.current) return;
5815
+ checkingPasskeyRef.current = true;
5811
5816
  let cancelled = false;
5812
5817
  dispatch({ type: "SET_ERROR", error: null });
5813
5818
  setAuthInput("");
@@ -5904,8 +5909,17 @@ function SwypePaymentInner({
5904
5909
  };
5905
5910
  const checkPasskey = async () => {
5906
5911
  try {
5907
- const token = await getAccessToken();
5908
- if (!token || cancelled) return;
5912
+ let token = null;
5913
+ for (let attempt = 0; attempt < 3; attempt++) {
5914
+ token = await getAccessToken();
5915
+ if (token || cancelled) break;
5916
+ await new Promise((r) => setTimeout(r, 1e3));
5917
+ }
5918
+ if (!token) {
5919
+ if (!cancelled) dispatch({ type: "NAVIGATE", step: "create-passkey" });
5920
+ return;
5921
+ }
5922
+ if (cancelled) return;
5909
5923
  const { config } = await fetchUserConfig(apiBaseUrl, token);
5910
5924
  if (cancelled) return;
5911
5925
  const allPasskeys = config.passkeys ?? (config.passkey ? [config.passkey] : []);
@@ -5946,6 +5960,7 @@ function SwypePaymentInner({
5946
5960
  checkPasskey();
5947
5961
  return () => {
5948
5962
  cancelled = true;
5963
+ checkingPasskeyRef.current = false;
5949
5964
  };
5950
5965
  }, [
5951
5966
  ready,