@swype-org/react-sdk 0.2.26 → 0.2.31
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 +44 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -53
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -241,9 +241,6 @@ async function checkServerForPasskeyByToken(authToken, apiBaseUrl, verificationT
|
|
|
241
241
|
function shouldUsePasskeySignupPopup() {
|
|
242
242
|
return isSafari() && isInCrossOriginIframe();
|
|
243
243
|
}
|
|
244
|
-
function shouldUsePasskeyLoginPopup() {
|
|
245
|
-
return isSafari() && isInCrossOriginIframe();
|
|
246
|
-
}
|
|
247
244
|
var SIGNUP_POPUP_TIMEOUT_MS = 12e4;
|
|
248
245
|
function signupWithPasskeyViaPopup() {
|
|
249
246
|
return new Promise((resolve, reject) => {
|
|
@@ -3498,7 +3495,7 @@ var FALLBACK = "Biometric verification";
|
|
|
3498
3495
|
function getDeviceBiometricUnlockText() {
|
|
3499
3496
|
const ua = typeof navigator !== "undefined" && typeof navigator.userAgent === "string" ? navigator.userAgent : "";
|
|
3500
3497
|
if (/iPhone|iPad|iPod/i.test(ua)) {
|
|
3501
|
-
return "Face ID
|
|
3498
|
+
return "Face ID";
|
|
3502
3499
|
}
|
|
3503
3500
|
if (/Android/i.test(ua)) {
|
|
3504
3501
|
return "Fingerprint or face unlock";
|
|
@@ -4907,30 +4904,6 @@ var waitHintStyle = (color) => ({
|
|
|
4907
4904
|
color,
|
|
4908
4905
|
margin: 0
|
|
4909
4906
|
});
|
|
4910
|
-
|
|
4911
|
-
// src/feeFormat.ts
|
|
4912
|
-
function isPreciseMoneyNonPositive(fee) {
|
|
4913
|
-
const raw = fee.value.trim();
|
|
4914
|
-
if (!/^-?\d+(\.\d*)?$/.test(raw)) return false;
|
|
4915
|
-
const n = Number(raw);
|
|
4916
|
-
return Number.isFinite(n) && n <= 0;
|
|
4917
|
-
}
|
|
4918
|
-
function formatNonPositiveFeeDisplay(fee) {
|
|
4919
|
-
return "< $0.01";
|
|
4920
|
-
}
|
|
4921
|
-
function formatPreciseMoneyForDisplay(fee) {
|
|
4922
|
-
const raw = fee.value.trim();
|
|
4923
|
-
if (fee.currency === "USD") {
|
|
4924
|
-
if (!/^\d+(\.\d*)?$/.test(raw)) {
|
|
4925
|
-
return `$${raw}`;
|
|
4926
|
-
}
|
|
4927
|
-
const [whole, frac = ""] = raw.split(".");
|
|
4928
|
-
const dec = `${frac}00`.slice(0, 2);
|
|
4929
|
-
const intFmt = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
4930
|
-
return `$${intFmt}.${dec}`;
|
|
4931
|
-
}
|
|
4932
|
-
return `${raw} ${fee.currency}`;
|
|
4933
|
-
}
|
|
4934
4907
|
function formatUsdTwoDecimals(value) {
|
|
4935
4908
|
const n = Number(value);
|
|
4936
4909
|
return (Number.isFinite(n) ? n : 0).toLocaleString("en-US", {
|
|
@@ -5102,10 +5075,9 @@ function DepositScreen({
|
|
|
5102
5075
|
return /* @__PURE__ */ jsx(WarningBanner, { title: "Fee estimate unavailable", children: quoteError });
|
|
5103
5076
|
}
|
|
5104
5077
|
if (quoteFee) {
|
|
5105
|
-
const feeText = isPreciseMoneyNonPositive(quoteFee) ? formatNonPositiveFeeDisplay() : formatPreciseMoneyForDisplay(quoteFee);
|
|
5106
5078
|
return /* @__PURE__ */ jsxs("div", { style: feeRowContainerStyle, "aria-live": "polite", children: [
|
|
5107
5079
|
/* @__PURE__ */ jsx("span", { style: feeRowLabelStyle(tokens.textMuted), children: "Fee estimate: " }),
|
|
5108
|
-
/* @__PURE__ */ jsx("span", { style: feeRowAmountStyle(tokens.textSecondary), children:
|
|
5080
|
+
/* @__PURE__ */ jsx("span", { style: feeRowAmountStyle(tokens.textSecondary), children: "Free" })
|
|
5109
5081
|
] });
|
|
5110
5082
|
}
|
|
5111
5083
|
return null;
|
|
@@ -6671,6 +6643,30 @@ var selectCircleSelectedStyle = (color) => ({
|
|
|
6671
6643
|
justifyContent: "center",
|
|
6672
6644
|
flexShrink: 0
|
|
6673
6645
|
});
|
|
6646
|
+
|
|
6647
|
+
// src/feeFormat.ts
|
|
6648
|
+
function isPreciseMoneyNonPositive(fee) {
|
|
6649
|
+
const raw = fee.value.trim();
|
|
6650
|
+
if (!/^-?\d+(\.\d*)?$/.test(raw)) return false;
|
|
6651
|
+
const n = Number(raw);
|
|
6652
|
+
return Number.isFinite(n) && n <= 0;
|
|
6653
|
+
}
|
|
6654
|
+
function formatNonPositiveFeeDisplay(fee) {
|
|
6655
|
+
return "< $0.01";
|
|
6656
|
+
}
|
|
6657
|
+
function formatPreciseMoneyForDisplay(fee) {
|
|
6658
|
+
const raw = fee.value.trim();
|
|
6659
|
+
if (fee.currency === "USD") {
|
|
6660
|
+
if (!/^\d+(\.\d*)?$/.test(raw)) {
|
|
6661
|
+
return `$${raw}`;
|
|
6662
|
+
}
|
|
6663
|
+
const [whole, frac = ""] = raw.split(".");
|
|
6664
|
+
const dec = `${frac}00`.slice(0, 2);
|
|
6665
|
+
const intFmt = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
6666
|
+
return `$${intFmt}.${dec}`;
|
|
6667
|
+
}
|
|
6668
|
+
return `${raw} ${fee.currency}`;
|
|
6669
|
+
}
|
|
6674
6670
|
function entryKey(entry) {
|
|
6675
6671
|
return `${entry.sourceChainId}-${entry.tokenAddress.toLowerCase()}`;
|
|
6676
6672
|
}
|
|
@@ -6725,7 +6721,6 @@ function GuestTokenPickerScreen({
|
|
|
6725
6721
|
const [limitInputValue, setLimitInputValue] = useState("");
|
|
6726
6722
|
const limitInputRef = useRef(null);
|
|
6727
6723
|
const [managingAllowance, setManagingAllowance] = useState(false);
|
|
6728
|
-
const biometricText = getDeviceBiometricUnlockText();
|
|
6729
6724
|
useEffect(() => {
|
|
6730
6725
|
if (!tokenListOpen) return;
|
|
6731
6726
|
const handleMouseDown = (e) => {
|
|
@@ -6759,8 +6754,6 @@ function GuestTokenPickerScreen({
|
|
|
6759
6754
|
const canConfirm = Boolean(pendingEntry && !quoteLoading && (!confirmNeedsQuote || quoteFee));
|
|
6760
6755
|
const ctaLabel = confirmLabel ?? (variant === "auth-setup" ? "Continue" : providerName ? `Open ${providerName} to Deposit` : "Open Wallet to Deposit");
|
|
6761
6756
|
const tokenCardLabel = selectionLabel ?? (variant === "auth-setup" ? "Token for one-tap" : "Deposit");
|
|
6762
|
-
const oneTapSubtitle = variant === "auth-setup" ? `Skip wallet next time \u2014 just ${biometricText}` : `Skip ${providerName ?? "wallet"} next time \u2014 just ${biometricText}`;
|
|
6763
|
-
const oneTapBody = variant === "auth-setup" ? `Future deposits up to your allowance are confirmed with just ${biometricText} \u2014 no wallet pop-up.` : `Future deposits up to your allowance are confirmed with just ${biometricText} \u2014 no wallet pop-up. You'll re-authorize with ${providerName ?? "your wallet"} when you need to top up.`;
|
|
6764
6757
|
const feeLine = (() => {
|
|
6765
6758
|
if (quoteLoading && pendingEntry) {
|
|
6766
6759
|
return /* @__PURE__ */ jsx("div", { style: feeRowContainerStyle2, "aria-live": "polite", children: /* @__PURE__ */ jsx("span", { style: feeRowLabelStyle2(t.textMuted), children: "Getting fee estimate\u2026" }) });
|
|
@@ -6977,10 +6970,25 @@ function GuestTokenPickerScreen({
|
|
|
6977
6970
|
!tokenListOpen && !isBridging && /* @__PURE__ */ jsxs("div", { style: oneTapCardStyle(t, oneTapEnabled), children: [
|
|
6978
6971
|
/* @__PURE__ */ jsxs("div", { style: oneTapHeaderRowStyle, children: [
|
|
6979
6972
|
/* @__PURE__ */ jsxs("div", { style: oneTapHeaderLeftStyle, children: [
|
|
6980
|
-
/* @__PURE__ */ jsx("div", { style: lightningIconStyle, children: /* @__PURE__ */ jsx("svg", { width: "
|
|
6973
|
+
/* @__PURE__ */ jsx("div", { style: lightningIconStyle, children: /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "36", height: "36", viewBox: "0 0 80 80", children: /* @__PURE__ */ jsx("g", { stroke: "none", strokeWidth: "1", fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ jsx("g", { fill: "#000000", children: /* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsxs("g", { children: [
|
|
6974
|
+
/* @__PURE__ */ jsxs("g", { fillRule: "nonzero", children: [
|
|
6975
|
+
/* @__PURE__ */ jsx("path", { d: "M4.11428571,21.9428571 L4.11428571,13.0285714 C4.11428571,7.99327149 7.99327149,4.11428571 13.0285714,4.11428571 L21.9428571,4.11428571 C23.0789858,4.11428571 24,3.19327149 24,2.05714286 C24,0.921014229 23.0789858,0 21.9428571,0 L13.0285714,0 C5.72101423,0 0,5.72101423 0,13.0285714 L0,21.9428571 C0,23.0789858 0.921014229,24 2.05714286,24 C3.19327149,24 4.11428571,23.0789858 4.11428571,21.9428571 Z" }),
|
|
6976
|
+
/* @__PURE__ */ jsx("path", { d: "M4.11428571,21.9428571 L4.11428571,13.0285714 C4.11428571,7.99327149 7.99327149,4.11428571 13.0285714,4.11428571 L21.9428571,4.11428571 C23.0789858,4.11428571 24,3.19327149 24,2.05714286 C24,0.921014229 23.0789858,0 21.9428571,0 L13.0285714,0 C5.72101423,0 0,5.72101423 0,13.0285714 L0,21.9428571 C0,23.0789858 0.921014229,24 2.05714286,24 C3.19327149,24 4.11428571,23.0789858 4.11428571,21.9428571 Z", transform: "translate(68.070175, 11.929825) scale(-1, 1) translate(-68.070175, -11.929825) translate(56.140351, 0.000000)" }),
|
|
6977
|
+
/* @__PURE__ */ jsx("path", { d: "M4.11428571,21.9428571 L4.11428571,13.0285714 C4.11428571,7.99327149 7.99327149,4.11428571 13.0285714,4.11428571 L21.9428571,4.11428571 C23.0789858,4.11428571 24,3.19327149 24,2.05714286 C24,0.921014229 23.0789858,0 21.9428571,0 L13.0285714,0 C5.72101423,0 0,5.72101423 0,13.0285714 L0,21.9428571 C0,23.0789858 0.921014229,24 2.05714286,24 C3.19327149,24 4.11428571,23.0789858 4.11428571,21.9428571 Z", transform: "translate(11.929825, 68.070175) scale(1, -1) translate(-11.929825, -68.070175) translate(0.000000, 56.140351)" }),
|
|
6978
|
+
/* @__PURE__ */ jsx("path", { d: "M4.11428571,21.9428571 L4.11428571,13.0285714 C4.11428571,7.99327149 7.99327149,4.11428571 13.0285714,4.11428571 L21.9428571,4.11428571 C23.0789858,4.11428571 24,3.19327149 24,2.05714286 C24,0.921014229 23.0789858,0 21.9428571,0 L13.0285714,0 C5.72101423,0 0,5.72101423 0,13.0285714 L0,21.9428571 C0,23.0789858 0.921014229,24 2.05714286,24 C3.19327149,24 4.11428571,23.0789858 4.11428571,21.9428571 Z", transform: "translate(68.070175, 68.070175) scale(-1, -1) translate(-68.070175, -68.070175) translate(56.140351, 56.140351)" })
|
|
6979
|
+
] }),
|
|
6980
|
+
/* @__PURE__ */ jsx("g", { transform: "translate(21.754386, 28.070175)", fillRule: "nonzero", children: /* @__PURE__ */ jsx("path", { d: "M0,2.14285714 L0,7.86037654 C0,9.04384386 0.8954305,10.0032337 2,10.0032337 C3.1045695,10.0032337 4,9.04384386 4,7.86037654 L4,2.14285714 C4,0.959389822 3.1045695,0 2,0 C0.8954305,0 0,0.959389822 0,2.14285714 Z" }) }),
|
|
6981
|
+
/* @__PURE__ */ jsx("g", { transform: "translate(54.736842, 28.070175)", fillRule: "nonzero", children: /* @__PURE__ */ jsx("path", { d: "M0,2.14285714 L0,7.86037654 C0,9.04384386 0.8954305,10.0032337 2,10.0032337 C3.1045695,10.0032337 4,9.04384386 4,7.86037654 L4,2.14285714 C4,0.959389822 3.1045695,0 2,0 C0.8954305,0 0,0.959389822 0,2.14285714 Z" }) }),
|
|
6982
|
+
/* @__PURE__ */ jsx("path", { d: "M25.9319616,59.0829234 C29.8331111,62.7239962 34.5578726,64.5614035 40,64.5614035 C45.4421274,64.5614035 50.1668889,62.7239962 54.0680384,59.0829234 C54.9180398,58.2895887 54.9639773,56.9574016 54.1706427,56.1074002 C53.377308,55.2573988 52.0451209,55.2114613 51.1951195,56.0047959 C48.0787251,58.9134307 44.382434,60.3508772 40,60.3508772 C35.617566,60.3508772 31.9212749,58.9134307 28.8048805,56.0047959 C27.9548791,55.2114613 26.622692,55.2573988 25.8293573,56.1074002 C25.0360227,56.9574016 25.0819602,58.2895887 25.9319616,59.0829234 Z", fillRule: "nonzero" }),
|
|
6983
|
+
/* @__PURE__ */ jsx("path", { d: "M40,30.1754386 L40,44.9122807 C40,45.85537 39.539042,46.3157895 38.5912711,46.3157895 L37.1929825,46.3157895 C36.0302777,46.3157895 35.0877193,47.2583479 35.0877193,48.4210526 C35.0877193,49.5837574 36.0302777,50.5263158 37.1929825,50.5263158 L38.5912711,50.5263158 C41.8633505,50.5263158 44.2105263,48.1818819 44.2105263,44.9122807 L44.2105263,30.1754386 C44.2105263,29.0127339 43.2679679,28.0701754 42.1052632,28.0701754 C40.9425584,28.0701754 40,29.0127339 40,30.1754386 Z", fillRule: "nonzero" })
|
|
6984
|
+
] }) }) }) }) }) }),
|
|
6981
6985
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
6982
|
-
/* @__PURE__ */
|
|
6983
|
-
|
|
6986
|
+
/* @__PURE__ */ jsxs("div", { style: oneTapTitleStyle(t.text), children: [
|
|
6987
|
+
"Deposit with ",
|
|
6988
|
+
getDeviceBiometricUnlockText(),
|
|
6989
|
+
" next time"
|
|
6990
|
+
] }),
|
|
6991
|
+
/* @__PURE__ */ jsx("div", { style: oneTapSubtitleStyle(t.textMuted), children: "No need to reopen your wallet every time. Your money stays under your control." })
|
|
6984
6992
|
] })
|
|
6985
6993
|
] }),
|
|
6986
6994
|
/* @__PURE__ */ jsx(
|
|
@@ -6997,7 +7005,6 @@ function GuestTokenPickerScreen({
|
|
|
6997
7005
|
)
|
|
6998
7006
|
] }),
|
|
6999
7007
|
oneTapEnabled && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7000
|
-
/* @__PURE__ */ jsx("p", { style: oneTapBodyStyle(t.textMuted), children: oneTapBody }),
|
|
7001
7008
|
/* @__PURE__ */ jsxs(
|
|
7002
7009
|
"button",
|
|
7003
7010
|
{
|
|
@@ -7322,8 +7329,6 @@ var oneTapHeaderLeftStyle = {
|
|
|
7322
7329
|
var lightningIconStyle = {
|
|
7323
7330
|
width: 36,
|
|
7324
7331
|
height: 36,
|
|
7325
|
-
borderRadius: 10,
|
|
7326
|
-
background: "linear-gradient(135deg, #e8f5e9 0%, #fffde7 100%)",
|
|
7327
7332
|
display: "flex",
|
|
7328
7333
|
alignItems: "center",
|
|
7329
7334
|
justifyContent: "center",
|
|
@@ -7365,12 +7370,6 @@ var toggleThumbStyle = (on) => ({
|
|
|
7365
7370
|
transition: "transform 0.2s ease",
|
|
7366
7371
|
transform: on ? "translateX(0)" : "translateX(0)"
|
|
7367
7372
|
});
|
|
7368
|
-
var oneTapBodyStyle = (color) => ({
|
|
7369
|
-
fontSize: "0.84rem",
|
|
7370
|
-
color,
|
|
7371
|
-
lineHeight: 1.55,
|
|
7372
|
-
margin: "10px 0 0"
|
|
7373
|
-
});
|
|
7374
7373
|
var manageAllowanceBtnStyle = (color) => ({
|
|
7375
7374
|
display: "flex",
|
|
7376
7375
|
alignItems: "center",
|
|
@@ -8143,10 +8142,6 @@ function useAuthHandlers(dispatch, apiBaseUrl, popupAuthRef) {
|
|
|
8143
8142
|
},
|
|
8144
8143
|
onError: (error) => {
|
|
8145
8144
|
captureException(new Error(String(error)));
|
|
8146
|
-
if (isInCrossOriginIframe()) {
|
|
8147
|
-
handlePopupLogin();
|
|
8148
|
-
return;
|
|
8149
|
-
}
|
|
8150
8145
|
dispatch({
|
|
8151
8146
|
type: "SET_ERROR",
|
|
8152
8147
|
error: typeof error === "string" ? error : "Passkey login failed. Try again or create an account."
|
|
@@ -8200,10 +8195,6 @@ function useAuthHandlers(dispatch, apiBaseUrl, popupAuthRef) {
|
|
|
8200
8195
|
const passkeyAuthError = loginState.status === "error" ? loginState.error?.message ?? "Passkey login failed." : signupState.status === "error" ? signupState.error?.message ?? "Passkey signup failed." : null;
|
|
8201
8196
|
const handleLoginWithPasskey = useCallback(() => {
|
|
8202
8197
|
dispatch({ type: "SET_ERROR", error: null });
|
|
8203
|
-
if (shouldUsePasskeyLoginPopup()) {
|
|
8204
|
-
handlePopupLogin();
|
|
8205
|
-
return;
|
|
8206
|
-
}
|
|
8207
8198
|
loginWithPasskey();
|
|
8208
8199
|
}, [loginWithPasskey, dispatch, handlePopupLogin]);
|
|
8209
8200
|
const handleSignupWithPasskey = useCallback(() => {
|