@swype-org/react-sdk 0.1.115 → 0.1.121
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 +50 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +50 -29
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1908,7 +1908,10 @@ function buildSelectSourceChoices(options) {
|
|
|
1908
1908
|
chainChoice.tokens.push({ tokenSymbol, balance });
|
|
1909
1909
|
}
|
|
1910
1910
|
}
|
|
1911
|
-
return chainChoices
|
|
1911
|
+
return chainChoices.map((chain) => ({
|
|
1912
|
+
...chain,
|
|
1913
|
+
tokens: chain.tokens.filter((t) => t.balance > 0)
|
|
1914
|
+
})).filter((chain) => chain.tokens.length > 0);
|
|
1912
1915
|
}
|
|
1913
1916
|
|
|
1914
1917
|
// src/paymentReducer.ts
|
|
@@ -2169,7 +2172,7 @@ function paymentReducer(state, action) {
|
|
|
2169
2172
|
};
|
|
2170
2173
|
// ── Navigation & error ───────────────────────────────────────
|
|
2171
2174
|
case "NAVIGATE":
|
|
2172
|
-
return { ...state, step: action.step };
|
|
2175
|
+
return { ...state, step: action.step, error: null };
|
|
2173
2176
|
case "SET_ERROR":
|
|
2174
2177
|
return { ...state, error: action.error };
|
|
2175
2178
|
// ── Lifecycle ────────────────────────────────────────────────
|
|
@@ -2248,7 +2251,7 @@ var spinnerStyle = {
|
|
|
2248
2251
|
};
|
|
2249
2252
|
var FOOTER_CSS = `
|
|
2250
2253
|
.swype-screen-footer {
|
|
2251
|
-
padding-bottom: max(
|
|
2254
|
+
padding-bottom: max(32px, env(safe-area-inset-bottom, 32px));
|
|
2252
2255
|
}`;
|
|
2253
2256
|
function ScreenLayout({ children, footer }) {
|
|
2254
2257
|
const { tokens } = useSwypeConfig();
|
|
@@ -2271,12 +2274,16 @@ var containerStyle2 = (bg) => ({
|
|
|
2271
2274
|
});
|
|
2272
2275
|
var bodyStyle = {
|
|
2273
2276
|
flex: 1,
|
|
2277
|
+
minHeight: 0,
|
|
2274
2278
|
padding: "0 24px",
|
|
2275
2279
|
display: "flex",
|
|
2276
|
-
flexDirection: "column"
|
|
2280
|
+
flexDirection: "column",
|
|
2281
|
+
overflowY: "auto"
|
|
2277
2282
|
};
|
|
2278
2283
|
var footerStyle = {
|
|
2279
|
-
|
|
2284
|
+
paddingTop: 16,
|
|
2285
|
+
paddingLeft: 24,
|
|
2286
|
+
paddingRight: 24,
|
|
2280
2287
|
marginTop: "auto"
|
|
2281
2288
|
};
|
|
2282
2289
|
function ScreenHeader({ title, right, onBack, badge }) {
|
|
@@ -3153,7 +3160,7 @@ function LoginScreen({
|
|
|
3153
3160
|
] }),
|
|
3154
3161
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: walletSectionStyle, children: [
|
|
3155
3162
|
/* @__PURE__ */ jsxRuntime.jsx("span", { style: walletLabelStyle(tokens.textMuted), children: "Works with" }),
|
|
3156
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: walletLogosStyle, children: walletIcons.map(({ key,
|
|
3163
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: walletLogosStyle, children: walletIcons.map(({ key, logo }) => /* @__PURE__ */ jsxRuntime.jsx("img", { src: logo, alt: key, style: walletLogoImgStyle }, key)) })
|
|
3157
3164
|
] }),
|
|
3158
3165
|
/* @__PURE__ */ jsxRuntime.jsx(PoweredByFooter, {})
|
|
3159
3166
|
] }),
|
|
@@ -3192,11 +3199,9 @@ function LoginScreen({
|
|
|
3192
3199
|
);
|
|
3193
3200
|
}
|
|
3194
3201
|
var walletIcons = [
|
|
3195
|
-
{ key: "metamask",
|
|
3196
|
-
{ key: "
|
|
3197
|
-
{ key: "
|
|
3198
|
-
{ key: "rainbow", emoji: "\u{1F439}" },
|
|
3199
|
-
{ key: "coinbase", emoji: "\u{1F535}", logo: KNOWN_LOGOS["base"] }
|
|
3202
|
+
{ key: "metamask", logo: KNOWN_LOGOS["metamask"] },
|
|
3203
|
+
{ key: "base", logo: KNOWN_LOGOS["base"] },
|
|
3204
|
+
{ key: "trust wallet", logo: KNOWN_LOGOS["trust wallet"] }
|
|
3200
3205
|
];
|
|
3201
3206
|
function socialLabel(provider) {
|
|
3202
3207
|
switch (provider) {
|
|
@@ -3316,10 +3321,6 @@ var walletLogosStyle = {
|
|
|
3316
3321
|
justifyContent: "center",
|
|
3317
3322
|
gap: 16
|
|
3318
3323
|
};
|
|
3319
|
-
var walletEmojiStyle = {
|
|
3320
|
-
fontSize: "1.4rem",
|
|
3321
|
-
lineHeight: 1
|
|
3322
|
-
};
|
|
3323
3324
|
var walletLogoImgStyle = {
|
|
3324
3325
|
width: 24,
|
|
3325
3326
|
height: 24,
|
|
@@ -3481,7 +3482,7 @@ function CreatePasskeyScreen({
|
|
|
3481
3482
|
}) {
|
|
3482
3483
|
const { tokens } = useSwypeConfig();
|
|
3483
3484
|
const handleCreate = popupFallback && onCreatePasskeyViaPopup ? onCreatePasskeyViaPopup : onCreatePasskey;
|
|
3484
|
-
const buttonLabel = popupFallback ? "Open passkey setup" : "
|
|
3485
|
+
const buttonLabel = popupFallback ? "Open passkey setup" : "Set up passkey";
|
|
3485
3486
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3486
3487
|
ScreenLayout,
|
|
3487
3488
|
{
|
|
@@ -3498,7 +3499,7 @@ function CreatePasskeyScreen({
|
|
|
3498
3499
|
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "15", cy: "10", r: "1", fill: tokens.accent }),
|
|
3499
3500
|
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 14c0 1.5 1.34 2.5 3 2.5s3-1 3-2.5", stroke: tokens.accent, strokeWidth: "1.2", strokeLinecap: "round" })
|
|
3500
3501
|
] }) }),
|
|
3501
|
-
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle3(tokens.text), children: "
|
|
3502
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle3(tokens.text), children: "Set up your passkey" }),
|
|
3502
3503
|
/* @__PURE__ */ jsxRuntime.jsx("p", { style: subtitleStyle3(tokens.textSecondary), children: popupFallback ? "Your browser requires a separate window for passkey setup. Tap the button below to continue." : "Use Face ID to sign in instantly \u2014 no passwords, no codes." }),
|
|
3503
3504
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: errorBannerStyle2(tokens), children: error }),
|
|
3504
3505
|
/* @__PURE__ */ jsxRuntime.jsx(InfoBanner, { children: "Your passkey is stored securely on your device. Swype never sees your biometric data." })
|
|
@@ -3842,16 +3843,16 @@ function SetupScreen({
|
|
|
3842
3843
|
error
|
|
3843
3844
|
}) {
|
|
3844
3845
|
const { tokens } = useSwypeConfig();
|
|
3845
|
-
const effectiveMax = DEFAULT_MAX;
|
|
3846
|
+
const effectiveMax = Math.min(DEFAULT_MAX, availableBalance);
|
|
3846
3847
|
const effectiveMin = Math.min(ABSOLUTE_MIN, effectiveMax);
|
|
3847
|
-
const [limit, setLimit] = react.useState(() => effectiveMax);
|
|
3848
|
+
const [limit, setLimit] = react.useState(() => Math.min(availableBalance, effectiveMax));
|
|
3848
3849
|
const [editing, setEditing] = react.useState(false);
|
|
3849
3850
|
const [inputValue, setInputValue] = react.useState("");
|
|
3850
3851
|
const inputRef = react.useRef(null);
|
|
3851
3852
|
const startEditing = react.useCallback(() => {
|
|
3852
3853
|
setInputValue(limit.toFixed(2));
|
|
3853
3854
|
setEditing(true);
|
|
3854
|
-
requestAnimationFrame(() => inputRef.current?.
|
|
3855
|
+
requestAnimationFrame(() => inputRef.current?.focus());
|
|
3855
3856
|
}, [limit]);
|
|
3856
3857
|
const commitEdit = react.useCallback(() => {
|
|
3857
3858
|
const parsed = parseFloat(inputValue);
|
|
@@ -5141,6 +5142,7 @@ function OpenWalletScreen({
|
|
|
5141
5142
|
loading,
|
|
5142
5143
|
error,
|
|
5143
5144
|
onRetryStatus,
|
|
5145
|
+
onBack,
|
|
5144
5146
|
onLogout
|
|
5145
5147
|
}) {
|
|
5146
5148
|
const { tokens } = useSwypeConfig();
|
|
@@ -5171,7 +5173,7 @@ function OpenWalletScreen({
|
|
|
5171
5173
|
/* @__PURE__ */ jsxRuntime.jsx("p", { style: hintStyle3(tokens.textMuted), children: loading ? "Preparing authorization..." : error ? "Retry the status check after returning to the browser, or reopen your wallet if needed." : "If your wallet didn't open automatically, tap the button above" })
|
|
5172
5174
|
] }),
|
|
5173
5175
|
children: [
|
|
5174
|
-
/* @__PURE__ */ jsxRuntime.jsx(ScreenHeader, { right: /* @__PURE__ */ jsxRuntime.jsx(SettingsMenu, { onLogout }) }),
|
|
5176
|
+
/* @__PURE__ */ jsxRuntime.jsx(ScreenHeader, { onBack, right: /* @__PURE__ */ jsxRuntime.jsx(SettingsMenu, { onLogout }) }),
|
|
5175
5177
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: contentStyle8, children: [
|
|
5176
5178
|
logoSrc ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: logoSrc, alt: displayName, style: logoStyle }) : /* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: 48 }),
|
|
5177
5179
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle10(tokens.text), children: loading ? "Connecting..." : `Open ${displayName}` }),
|
|
@@ -5641,6 +5643,19 @@ function StepRenderer({
|
|
|
5641
5643
|
}
|
|
5642
5644
|
);
|
|
5643
5645
|
}
|
|
5646
|
+
if (step === "verify-passkey") {
|
|
5647
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5648
|
+
CreatePasskeyScreen,
|
|
5649
|
+
{
|
|
5650
|
+
onCreatePasskey: handlers.onRegisterPasskey,
|
|
5651
|
+
onBack: handlers.onLogout,
|
|
5652
|
+
creating: state.verifyingPasskeyPopup,
|
|
5653
|
+
error: state.error,
|
|
5654
|
+
popupFallback: true,
|
|
5655
|
+
onCreatePasskeyViaPopup: handlers.onVerifyPasskeyViaPopup
|
|
5656
|
+
}
|
|
5657
|
+
);
|
|
5658
|
+
}
|
|
5644
5659
|
if (step === "wallet-picker") {
|
|
5645
5660
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5646
5661
|
WalletPickerScreen,
|
|
@@ -5664,6 +5679,7 @@ function StepRenderer({
|
|
|
5664
5679
|
loading: state.creatingTransfer || !state.deeplinkUri,
|
|
5665
5680
|
error: state.error || pollingError,
|
|
5666
5681
|
onRetryStatus: handlers.onRetryMobileStatus,
|
|
5682
|
+
onBack: () => handlers.onNavigate("wallet-picker"),
|
|
5667
5683
|
onLogout: handlers.onLogout
|
|
5668
5684
|
}
|
|
5669
5685
|
);
|
|
@@ -6247,7 +6263,7 @@ function SwypePaymentInner({
|
|
|
6247
6263
|
return;
|
|
6248
6264
|
}
|
|
6249
6265
|
if (!state.activeCredentialId) {
|
|
6250
|
-
dispatch({ type: "SET_ERROR", error: "
|
|
6266
|
+
dispatch({ type: "SET_ERROR", error: "Set up a passkey on this device before continuing." });
|
|
6251
6267
|
dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
6252
6268
|
return;
|
|
6253
6269
|
}
|
|
@@ -6328,7 +6344,7 @@ function SwypePaymentInner({
|
|
|
6328
6344
|
return;
|
|
6329
6345
|
}
|
|
6330
6346
|
if (!state.activeCredentialId) {
|
|
6331
|
-
dispatch({ type: "SET_ERROR", error: "
|
|
6347
|
+
dispatch({ type: "SET_ERROR", error: "Set up a passkey on this device before continuing." });
|
|
6332
6348
|
dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
6333
6349
|
return;
|
|
6334
6350
|
}
|
|
@@ -6402,7 +6418,7 @@ function SwypePaymentInner({
|
|
|
6402
6418
|
return;
|
|
6403
6419
|
}
|
|
6404
6420
|
if (!state.activeCredentialId) {
|
|
6405
|
-
dispatch({ type: "SET_ERROR", error: "
|
|
6421
|
+
dispatch({ type: "SET_ERROR", error: "Set up a passkey on this device before continuing." });
|
|
6406
6422
|
dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
6407
6423
|
return;
|
|
6408
6424
|
}
|
|
@@ -6499,7 +6515,7 @@ function SwypePaymentInner({
|
|
|
6499
6515
|
const handleSelectProvider = react.useCallback(async (providerId) => {
|
|
6500
6516
|
dispatch({ type: "SELECT_PROVIDER", providerId });
|
|
6501
6517
|
if (!state.activeCredentialId) {
|
|
6502
|
-
dispatch({ type: "SET_ERROR", error: "
|
|
6518
|
+
dispatch({ type: "SET_ERROR", error: "Set up a passkey on this device before continuing." });
|
|
6503
6519
|
dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
6504
6520
|
return;
|
|
6505
6521
|
}
|
|
@@ -6663,11 +6679,11 @@ function SwypePaymentInner({
|
|
|
6663
6679
|
}
|
|
6664
6680
|
}, [depositAmount]);
|
|
6665
6681
|
react.useEffect(() => {
|
|
6666
|
-
if (authenticated) return;
|
|
6682
|
+
if (authenticated || state.step !== "otp-verify") return;
|
|
6667
6683
|
if (activeOtpErrorMessage) dispatch({ type: "SET_ERROR", error: activeOtpErrorMessage });
|
|
6668
|
-
}, [activeOtpErrorMessage, authenticated]);
|
|
6684
|
+
}, [activeOtpErrorMessage, authenticated, state.step]);
|
|
6669
6685
|
react.useEffect(() => {
|
|
6670
|
-
if (state.step === "otp-verify" && /^\d{6}$/.test(otpCode.trim()) && activeOtpStatus
|
|
6686
|
+
if (state.step === "otp-verify" && /^\d{6}$/.test(otpCode.trim()) && activeOtpStatus === "awaiting-code-input") {
|
|
6671
6687
|
handleVerifyLoginCode();
|
|
6672
6688
|
}
|
|
6673
6689
|
}, [otpCode, state.step, activeOtpStatus, handleVerifyLoginCode]);
|
|
@@ -6763,6 +6779,7 @@ function SwypePaymentInner({
|
|
|
6763
6779
|
});
|
|
6764
6780
|
pollingTransferIdRef.current = persisted.transferId ?? null;
|
|
6765
6781
|
mobileSetupFlowRef.current = persisted.isSetup;
|
|
6782
|
+
setupAccountIdRef.current = persisted.accountId ?? null;
|
|
6766
6783
|
if (persisted.transferId) pollingRef.current.startPolling(persisted.transferId);
|
|
6767
6784
|
return;
|
|
6768
6785
|
}
|
|
@@ -6773,6 +6790,7 @@ function SwypePaymentInner({
|
|
|
6773
6790
|
});
|
|
6774
6791
|
pollingTransferIdRef.current = persisted.transferId ?? null;
|
|
6775
6792
|
mobileSetupFlowRef.current = persisted.isSetup;
|
|
6793
|
+
setupAccountIdRef.current = persisted.accountId ?? null;
|
|
6776
6794
|
if (persisted.transferId) pollingRef.current.startPolling(persisted.transferId);
|
|
6777
6795
|
return;
|
|
6778
6796
|
}
|
|
@@ -6991,7 +7009,10 @@ function SwypePaymentInner({
|
|
|
6991
7009
|
mobileSetupFlowRef.current = false;
|
|
6992
7010
|
setupAccountIdRef.current = null;
|
|
6993
7011
|
clearMobileFlowState();
|
|
6994
|
-
|
|
7012
|
+
try {
|
|
7013
|
+
await reloadAccounts();
|
|
7014
|
+
} catch {
|
|
7015
|
+
}
|
|
6995
7016
|
dispatch({ type: "MOBILE_SETUP_COMPLETE" });
|
|
6996
7017
|
}
|
|
6997
7018
|
} catch {
|