@swype-org/react-sdk 0.1.25 → 0.1.27
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 +69 -108
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +70 -109
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -77,6 +77,26 @@ var wagmiConfig = wagmi.createConfig({
|
|
|
77
77
|
[chains.base.id]: wagmi.http()
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
|
+
var PRIVY_MODAL_CENTER_CSS = `
|
|
81
|
+
@media (max-width: 440px) {
|
|
82
|
+
#privy-dialog [data-headlessui-state] {
|
|
83
|
+
position: static !important;
|
|
84
|
+
bottom: auto !important;
|
|
85
|
+
margin: auto !important;
|
|
86
|
+
width: 360px !important;
|
|
87
|
+
max-width: calc(100vw - 32px) !important;
|
|
88
|
+
box-shadow: 0px 8px 36px rgba(55, 65, 81, 0.15) !important;
|
|
89
|
+
border-radius: var(--privy-border-radius-lg) !important;
|
|
90
|
+
transform: none !important;
|
|
91
|
+
transition: opacity 100ms ease-in !important;
|
|
92
|
+
}
|
|
93
|
+
#privy-dialog [data-headlessui-state].entering,
|
|
94
|
+
#privy-dialog [data-headlessui-state].leaving {
|
|
95
|
+
opacity: 0 !important;
|
|
96
|
+
transform: none !important;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
`;
|
|
80
100
|
var SwypeContext = react.createContext(null);
|
|
81
101
|
function SwypeProvider({
|
|
82
102
|
apiBaseUrl,
|
|
@@ -87,6 +107,15 @@ function SwypeProvider({
|
|
|
87
107
|
if (!queryClientRef.current) {
|
|
88
108
|
queryClientRef.current = new reactQuery.QueryClient();
|
|
89
109
|
}
|
|
110
|
+
react.useEffect(() => {
|
|
111
|
+
const style = document.createElement("style");
|
|
112
|
+
style.setAttribute("data-swype", "privy-modal-center");
|
|
113
|
+
style.textContent = PRIVY_MODAL_CENTER_CSS;
|
|
114
|
+
document.head.appendChild(style);
|
|
115
|
+
return () => {
|
|
116
|
+
style.remove();
|
|
117
|
+
};
|
|
118
|
+
}, []);
|
|
90
119
|
const [depositAmount, setDepositAmountRaw] = react.useState(null);
|
|
91
120
|
const setDepositAmount = react.useCallback((amount) => {
|
|
92
121
|
setDepositAmountRaw(amount);
|
|
@@ -799,7 +828,7 @@ async function deviceHasPasskey(credentialId) {
|
|
|
799
828
|
type: "public-key",
|
|
800
829
|
id: base64ToBytes(credentialId)
|
|
801
830
|
}],
|
|
802
|
-
userVerification: "
|
|
831
|
+
userVerification: "discouraged",
|
|
803
832
|
timeout: 3e4
|
|
804
833
|
}
|
|
805
834
|
});
|
|
@@ -2270,17 +2299,15 @@ function SwypePayment({
|
|
|
2270
2299
|
const loadingDataRef = react.useRef(false);
|
|
2271
2300
|
react.useEffect(() => {
|
|
2272
2301
|
if (!authenticated) return;
|
|
2302
|
+
if (step === "login") return;
|
|
2273
2303
|
if (accounts.length > 0 || loadingDataRef.current) return;
|
|
2304
|
+
if (!activeCredentialId) return;
|
|
2274
2305
|
let cancelled = false;
|
|
2275
2306
|
loadingDataRef.current = true;
|
|
2276
2307
|
const load = async () => {
|
|
2277
2308
|
setLoadingData(true);
|
|
2278
2309
|
setError(null);
|
|
2279
2310
|
try {
|
|
2280
|
-
if (!activeCredentialId) {
|
|
2281
|
-
setStep("register-passkey");
|
|
2282
|
-
return;
|
|
2283
|
-
}
|
|
2284
2311
|
const token = await getAccessToken();
|
|
2285
2312
|
if (!token) throw new Error("Not authenticated");
|
|
2286
2313
|
const [prov, accts, chn] = await Promise.all([
|
|
@@ -2317,7 +2344,7 @@ function SwypePayment({
|
|
|
2317
2344
|
cancelled = true;
|
|
2318
2345
|
loadingDataRef.current = false;
|
|
2319
2346
|
};
|
|
2320
|
-
}, [authenticated, accounts.length, apiBaseUrl, getAccessToken, activeCredentialId]);
|
|
2347
|
+
}, [authenticated, step, accounts.length, apiBaseUrl, getAccessToken, activeCredentialId]);
|
|
2321
2348
|
react.useEffect(() => {
|
|
2322
2349
|
if (!polling.transfer) return;
|
|
2323
2350
|
if (polling.transfer.status === "COMPLETED") {
|
|
@@ -3027,7 +3054,7 @@ function SwypePayment({
|
|
|
3027
3054
|
]
|
|
3028
3055
|
}
|
|
3029
3056
|
),
|
|
3030
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3057
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3031
3058
|
"div",
|
|
3032
3059
|
{
|
|
3033
3060
|
style: {
|
|
@@ -3040,74 +3067,39 @@ function SwypePayment({
|
|
|
3040
3067
|
border: `1px solid ${tokens.border}`,
|
|
3041
3068
|
lineHeight: 1.7
|
|
3042
3069
|
},
|
|
3043
|
-
children:
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
{
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
style: { display: "flex", justifyContent: "space-between" },
|
|
3071
|
-
children: [
|
|
3072
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Token" }),
|
|
3073
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontWeight: 600 }, children: destination.token.symbol })
|
|
3074
|
-
]
|
|
3075
|
-
}
|
|
3076
|
-
),
|
|
3077
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3078
|
-
"div",
|
|
3079
|
-
{
|
|
3080
|
-
style: {
|
|
3081
|
-
display: "flex",
|
|
3082
|
-
justifyContent: "space-between",
|
|
3083
|
-
alignItems: "center"
|
|
3084
|
-
},
|
|
3085
|
-
children: [
|
|
3086
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "From" }),
|
|
3087
|
-
noAccounts ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontWeight: 500, color: tokens.textMuted }, children: "New account" }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
3088
|
-
AccountDropdown,
|
|
3089
|
-
{
|
|
3090
|
-
accounts,
|
|
3091
|
-
selectedAccountId,
|
|
3092
|
-
selectedWalletId,
|
|
3093
|
-
onSelect: (id) => {
|
|
3094
|
-
setSelectedAccountId(id);
|
|
3095
|
-
setSelectedWalletId(null);
|
|
3096
|
-
setConnectingNewAccount(false);
|
|
3097
|
-
setSelectedProviderId(null);
|
|
3098
|
-
},
|
|
3099
|
-
onWalletSelect: (accountId, walletId) => {
|
|
3100
|
-
setSelectedAccountId(accountId);
|
|
3101
|
-
setSelectedWalletId(walletId);
|
|
3102
|
-
setConnectingNewAccount(false);
|
|
3103
|
-
setSelectedProviderId(null);
|
|
3104
|
-
}
|
|
3070
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3071
|
+
"div",
|
|
3072
|
+
{
|
|
3073
|
+
style: {
|
|
3074
|
+
display: "flex",
|
|
3075
|
+
justifyContent: "space-between",
|
|
3076
|
+
alignItems: "center"
|
|
3077
|
+
},
|
|
3078
|
+
children: noAccounts ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {}) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
3079
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "From" }),
|
|
3080
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3081
|
+
AccountDropdown,
|
|
3082
|
+
{
|
|
3083
|
+
accounts,
|
|
3084
|
+
selectedAccountId,
|
|
3085
|
+
selectedWalletId,
|
|
3086
|
+
onSelect: (id) => {
|
|
3087
|
+
setSelectedAccountId(id);
|
|
3088
|
+
setSelectedWalletId(null);
|
|
3089
|
+
setConnectingNewAccount(false);
|
|
3090
|
+
setSelectedProviderId(null);
|
|
3091
|
+
},
|
|
3092
|
+
onWalletSelect: (accountId, walletId) => {
|
|
3093
|
+
setSelectedAccountId(accountId);
|
|
3094
|
+
setSelectedWalletId(walletId);
|
|
3095
|
+
setConnectingNewAccount(false);
|
|
3096
|
+
setSelectedProviderId(null);
|
|
3105
3097
|
}
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
}
|
|
3109
|
-
|
|
3110
|
-
|
|
3098
|
+
}
|
|
3099
|
+
)
|
|
3100
|
+
] })
|
|
3101
|
+
}
|
|
3102
|
+
)
|
|
3111
3103
|
}
|
|
3112
3104
|
),
|
|
3113
3105
|
noAccounts && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "16px" }, children: [
|
|
@@ -3373,10 +3365,9 @@ function SwypePayment({
|
|
|
3373
3365
|
}
|
|
3374
3366
|
};
|
|
3375
3367
|
const regMsg = getRegistrationMessage();
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
const statusLabel = creatingTransfer ? "Creating
|
|
3379
|
-
const statusDescription = creatingTransfer ? "Setting up your transfer..." : mobileFlow ? "Complete the authorization in your wallet app, then return here." : authExecutor.executing && regMsg.description ? regMsg.description : authExecutor.executing ? "Complete the wallet prompts to authorize this payment." : transferSigning.signing ? "Waiting for backend to prepare your transfer payload..." : polling.isPolling ? "Your payment is being processed. This usually takes a few moments." : "Hang tight...";
|
|
3368
|
+
getDisplayTransferStatus(polling.transfer, transfer);
|
|
3369
|
+
getTransferIdSuffix(polling.transfer, transfer);
|
|
3370
|
+
const statusLabel = creatingTransfer ? "Creating Transfer" : mobileFlow ? "Waiting for Authorization" : authExecutor.executing && regMsg.label ? regMsg.label : authExecutor.executing ? "Authorizing" : transferSigning.signing ? "Sending transfer" : polling.isPolling ? "Transfer Sent" : "Please wait...";
|
|
3380
3371
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: cardStyle, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { textAlign: "center", padding: "16px 0" }, children: [
|
|
3381
3372
|
/* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: 48 }),
|
|
3382
3373
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3390,36 +3381,6 @@ function SwypePayment({
|
|
|
3390
3381
|
children: statusLabel
|
|
3391
3382
|
}
|
|
3392
3383
|
),
|
|
3393
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3394
|
-
"p",
|
|
3395
|
-
{
|
|
3396
|
-
style: {
|
|
3397
|
-
fontSize: "0.85rem",
|
|
3398
|
-
color: tokens.textSecondary,
|
|
3399
|
-
margin: 0,
|
|
3400
|
-
lineHeight: 1.5
|
|
3401
|
-
},
|
|
3402
|
-
children: statusDescription
|
|
3403
|
-
}
|
|
3404
|
-
),
|
|
3405
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3406
|
-
"p",
|
|
3407
|
-
{
|
|
3408
|
-
style: {
|
|
3409
|
-
marginTop: "12px",
|
|
3410
|
-
marginBottom: 0,
|
|
3411
|
-
fontSize: "0.8rem",
|
|
3412
|
-
color: tokens.textSecondary
|
|
3413
|
-
},
|
|
3414
|
-
children: [
|
|
3415
|
-
"Current status: ",
|
|
3416
|
-
/* @__PURE__ */ jsxRuntime.jsx("strong", { style: { color: tokens.text }, children: transferStatus }),
|
|
3417
|
-
" \xB7 ",
|
|
3418
|
-
"Transfer: ",
|
|
3419
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: tokens.textMuted }, children: transferIdSuffix })
|
|
3420
|
-
]
|
|
3421
|
-
}
|
|
3422
|
-
),
|
|
3423
3384
|
polling.error && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3424
3385
|
"p",
|
|
3425
3386
|
{
|