@swype-org/react-sdk 0.1.13 → 0.1.14

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
@@ -2062,7 +2062,7 @@ function SwypePayment({
2062
2062
  useWalletConnector
2063
2063
  }) {
2064
2064
  const { apiBaseUrl, tokens, depositAmount } = useSwypeConfig();
2065
- const { ready, authenticated, login, getAccessToken } = usePrivy();
2065
+ const { ready, authenticated, login, logout, getAccessToken } = usePrivy();
2066
2066
  const [step, setStep] = useState("login");
2067
2067
  const [error, setError] = useState(null);
2068
2068
  const [providers, setProviders] = useState([]);
@@ -2413,6 +2413,38 @@ function SwypePayment({
2413
2413
  setAdvancedSettings({ asset: null, chain: null });
2414
2414
  if (accounts.length > 0) setSelectedAccountId(accounts[0].id);
2415
2415
  };
2416
+ const handleLogout = useCallback(async () => {
2417
+ try {
2418
+ await logout();
2419
+ } catch {
2420
+ }
2421
+ if (typeof window !== "undefined") {
2422
+ window.localStorage.removeItem(ACTIVE_CREDENTIAL_STORAGE_KEY);
2423
+ }
2424
+ polling.stopPolling();
2425
+ setActiveCredentialId(null);
2426
+ setStep("login");
2427
+ setError(null);
2428
+ setTransfer(null);
2429
+ setCreatingTransfer(false);
2430
+ setRegisteringPasskey(false);
2431
+ setProviders([]);
2432
+ setAccounts([]);
2433
+ setChains([]);
2434
+ setSelectedAccountId(null);
2435
+ setSelectedWalletId(null);
2436
+ setSelectedProviderId(null);
2437
+ setConnectingNewAccount(false);
2438
+ setAmount(depositAmount != null ? depositAmount.toString() : "");
2439
+ setAdvancedSettings({ asset: null, chain: null });
2440
+ setMobileFlow(false);
2441
+ setSelectSourceChainName("");
2442
+ setSelectSourceTokenSymbol("");
2443
+ initializedSelectSourceActionRef.current = null;
2444
+ processingStartedAtRef.current = null;
2445
+ pollingTransferIdRef.current = null;
2446
+ mobileSigningTransferIdRef.current = null;
2447
+ }, [logout, polling, depositAmount]);
2416
2448
  const handleConnectNewAccount = (providerId) => {
2417
2449
  setSelectedProviderId(providerId);
2418
2450
  setSelectedAccountId(null);
@@ -2770,7 +2802,32 @@ function SwypePayment({
2770
2802
  const canPay = !isNaN(parsedAmount) && parsedAmount > 0 && !!sourceId && !loadingData;
2771
2803
  const noAccounts = !loadingData && accounts.length === 0;
2772
2804
  return /* @__PURE__ */ jsxs("div", { style: cardStyle, children: [
2773
- stepBadge("Review & pay"),
2805
+ /* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
2806
+ stepBadge("Review & pay"),
2807
+ /* @__PURE__ */ jsx(
2808
+ "button",
2809
+ {
2810
+ type: "button",
2811
+ onClick: handleLogout,
2812
+ style: {
2813
+ position: "absolute",
2814
+ top: 0,
2815
+ right: 0,
2816
+ background: "transparent",
2817
+ border: "none",
2818
+ color: tokens.textMuted,
2819
+ cursor: "pointer",
2820
+ fontSize: "0.75rem",
2821
+ fontWeight: 600,
2822
+ letterSpacing: "0.04em",
2823
+ textTransform: "uppercase",
2824
+ fontFamily: "inherit",
2825
+ padding: 0
2826
+ },
2827
+ children: "Logout"
2828
+ }
2829
+ )
2830
+ ] }),
2774
2831
  error && /* @__PURE__ */ jsx("div", { style: errorStyle, children: error }),
2775
2832
  loadingData ? /* @__PURE__ */ jsx("div", { style: { padding: "24px 0", textAlign: "center" }, children: /* @__PURE__ */ jsx(Spinner, { label: "Loading..." }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2776
2833
  /* @__PURE__ */ jsxs(