@swype-org/react-sdk 0.1.92 → 0.1.94
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 +30 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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(
|
|
@@ -5236,12 +5236,17 @@ function SwypePaymentInner({
|
|
|
5236
5236
|
const checkingPasskeyRef = react.useRef(false);
|
|
5237
5237
|
const onCompleteRef = react.useRef(onComplete);
|
|
5238
5238
|
onCompleteRef.current = onComplete;
|
|
5239
|
+
const pollingRef = react.useRef(null);
|
|
5240
|
+
const handleAuthorizedMobileReturnRef = react.useRef(
|
|
5241
|
+
null
|
|
5242
|
+
);
|
|
5239
5243
|
const [authInput, setAuthInput] = react.useState("");
|
|
5240
5244
|
const [otpCode, setOtpCode] = react.useState("");
|
|
5241
5245
|
const [selectSourceChainName, setSelectSourceChainName] = react.useState("");
|
|
5242
5246
|
const [selectSourceTokenSymbol, setSelectSourceTokenSymbol] = react.useState("");
|
|
5243
5247
|
const authExecutor = useAuthorizationExecutor();
|
|
5244
5248
|
const polling = useTransferPolling();
|
|
5249
|
+
pollingRef.current = polling;
|
|
5245
5250
|
const transferSigning = useTransferSigning();
|
|
5246
5251
|
const { sourceType, sourceId } = deriveSourceTypeAndId(state);
|
|
5247
5252
|
const selectedAccount = state.accounts.find((a) => a.id === state.selectedAccountId);
|
|
@@ -5495,6 +5500,7 @@ function SwypePaymentInner({
|
|
|
5495
5500
|
clearMobileFlowState();
|
|
5496
5501
|
dispatch({ type: "MOBILE_SIGN_READY", transfer: authorizedTransfer });
|
|
5497
5502
|
}, [polling.stopPolling, reloadAccounts]);
|
|
5503
|
+
handleAuthorizedMobileReturnRef.current = handleAuthorizedMobileReturn;
|
|
5498
5504
|
const handlePay = react.useCallback(async (payAmount, sourceOverrides) => {
|
|
5499
5505
|
if (isNaN(payAmount) || payAmount < MIN_SEND_AMOUNT_USD) {
|
|
5500
5506
|
dispatch({ type: "SET_ERROR", error: `Minimum amount is $${MIN_SEND_AMOUNT_USD.toFixed(2)}.` });
|
|
@@ -5764,6 +5770,7 @@ function SwypePaymentInner({
|
|
|
5764
5770
|
}
|
|
5765
5771
|
polling.stopPolling();
|
|
5766
5772
|
preSelectSourceStepRef.current = null;
|
|
5773
|
+
checkingPasskeyRef.current = false;
|
|
5767
5774
|
setAuthInput("");
|
|
5768
5775
|
setOtpCode("");
|
|
5769
5776
|
dispatch({ type: "LOGOUT", depositAmount });
|
|
@@ -5812,7 +5819,10 @@ function SwypePaymentInner({
|
|
|
5812
5819
|
}
|
|
5813
5820
|
}, [otpCode, state.step, activeOtpStatus, handleVerifyLoginCode]);
|
|
5814
5821
|
react.useEffect(() => {
|
|
5815
|
-
if (!ready || !authenticated)
|
|
5822
|
+
if (!ready || !authenticated) {
|
|
5823
|
+
checkingPasskeyRef.current = false;
|
|
5824
|
+
return;
|
|
5825
|
+
}
|
|
5816
5826
|
if (state.step !== "login" && state.step !== "otp-verify") return;
|
|
5817
5827
|
if (checkingPasskeyRef.current) return;
|
|
5818
5828
|
checkingPasskeyRef.current = true;
|
|
@@ -5841,7 +5851,7 @@ function SwypePaymentInner({
|
|
|
5841
5851
|
const existingTransfer = await fetchTransfer(apiBaseUrl, token, persisted.transferId);
|
|
5842
5852
|
if (cancelled) return;
|
|
5843
5853
|
if (existingTransfer.status === "AUTHORIZED") {
|
|
5844
|
-
await
|
|
5854
|
+
await handleAuthorizedMobileReturnRef.current(existingTransfer, true);
|
|
5845
5855
|
return;
|
|
5846
5856
|
}
|
|
5847
5857
|
} catch {
|
|
@@ -5856,17 +5866,17 @@ function SwypePaymentInner({
|
|
|
5856
5866
|
persisted.isSetup
|
|
5857
5867
|
);
|
|
5858
5868
|
if (mobileResolution.kind === "resume-setup-deposit") {
|
|
5859
|
-
await
|
|
5869
|
+
await handleAuthorizedMobileReturnRef.current(existingTransfer, true);
|
|
5860
5870
|
return;
|
|
5861
5871
|
}
|
|
5862
5872
|
if (mobileResolution.kind === "resume-confirm-sign") {
|
|
5863
|
-
await
|
|
5873
|
+
await handleAuthorizedMobileReturnRef.current(existingTransfer, false);
|
|
5864
5874
|
return;
|
|
5865
5875
|
}
|
|
5866
5876
|
if (mobileResolution.kind === "resume-success") {
|
|
5867
5877
|
clearMobileFlowState();
|
|
5868
5878
|
dispatch({ type: "MOBILE_RESUME_SUCCESS", transfer: existingTransfer });
|
|
5869
|
-
|
|
5879
|
+
onCompleteRef.current?.(existingTransfer);
|
|
5870
5880
|
return;
|
|
5871
5881
|
}
|
|
5872
5882
|
if (mobileResolution.kind === "resume-failed") {
|
|
@@ -5877,7 +5887,7 @@ function SwypePaymentInner({
|
|
|
5877
5887
|
if (mobileResolution.kind === "resume-processing") {
|
|
5878
5888
|
clearMobileFlowState();
|
|
5879
5889
|
dispatch({ type: "MOBILE_RESUME_PROCESSING", transfer: existingTransfer });
|
|
5880
|
-
|
|
5890
|
+
pollingRef.current.startPolling(existingTransfer.id);
|
|
5881
5891
|
return;
|
|
5882
5892
|
}
|
|
5883
5893
|
if (mobileResolution.kind === "resume-stale-setup") {
|
|
@@ -5895,7 +5905,7 @@ function SwypePaymentInner({
|
|
|
5895
5905
|
});
|
|
5896
5906
|
pollingTransferIdRef.current = persisted.transferId;
|
|
5897
5907
|
mobileSetupFlowRef.current = persisted.isSetup;
|
|
5898
|
-
|
|
5908
|
+
pollingRef.current.startPolling(persisted.transferId);
|
|
5899
5909
|
return;
|
|
5900
5910
|
}
|
|
5901
5911
|
dispatch({
|
|
@@ -5905,7 +5915,7 @@ function SwypePaymentInner({
|
|
|
5905
5915
|
});
|
|
5906
5916
|
pollingTransferIdRef.current = persisted.transferId;
|
|
5907
5917
|
mobileSetupFlowRef.current = persisted.isSetup;
|
|
5908
|
-
|
|
5918
|
+
pollingRef.current.startPolling(persisted.transferId);
|
|
5909
5919
|
return;
|
|
5910
5920
|
}
|
|
5911
5921
|
dispatch({ type: "NAVIGATE", step: resolved.step });
|
|
@@ -5940,12 +5950,18 @@ function SwypePaymentInner({
|
|
|
5940
5950
|
return;
|
|
5941
5951
|
}
|
|
5942
5952
|
if (cancelled) return;
|
|
5953
|
+
const credentialIds = allPasskeys.map((p) => p.credentialId);
|
|
5954
|
+
let matched = null;
|
|
5943
5955
|
if (isSafari() && isInCrossOriginIframe()) {
|
|
5944
|
-
|
|
5945
|
-
|
|
5956
|
+
matched = await findDevicePasskeyViaPopup({
|
|
5957
|
+
credentialIds,
|
|
5958
|
+
rpId: resolvePasskeyRpId(),
|
|
5959
|
+
authToken: token ?? void 0,
|
|
5960
|
+
apiBaseUrl
|
|
5961
|
+
});
|
|
5962
|
+
} else {
|
|
5963
|
+
matched = await findDevicePasskey(credentialIds);
|
|
5946
5964
|
}
|
|
5947
|
-
const credentialIds = allPasskeys.map((p) => p.credentialId);
|
|
5948
|
-
const matched = await findDevicePasskey(credentialIds);
|
|
5949
5965
|
if (cancelled) return;
|
|
5950
5966
|
if (matched) {
|
|
5951
5967
|
dispatch({ type: "PASSKEY_ACTIVATED", credentialId: matched });
|
|
@@ -5963,19 +5979,8 @@ function SwypePaymentInner({
|
|
|
5963
5979
|
checkPasskey();
|
|
5964
5980
|
return () => {
|
|
5965
5981
|
cancelled = true;
|
|
5966
|
-
checkingPasskeyRef.current = false;
|
|
5967
5982
|
};
|
|
5968
|
-
}, [
|
|
5969
|
-
ready,
|
|
5970
|
-
authenticated,
|
|
5971
|
-
state.step,
|
|
5972
|
-
apiBaseUrl,
|
|
5973
|
-
getAccessToken,
|
|
5974
|
-
state.activeCredentialId,
|
|
5975
|
-
handleAuthorizedMobileReturn,
|
|
5976
|
-
onComplete,
|
|
5977
|
-
polling
|
|
5978
|
-
]);
|
|
5983
|
+
}, [ready, authenticated, state.step, apiBaseUrl, getAccessToken, state.activeCredentialId]);
|
|
5979
5984
|
react.useEffect(() => {
|
|
5980
5985
|
const loadAction = resolveDataLoadAction({
|
|
5981
5986
|
authenticated,
|