@pollar/react 0.8.1 → 0.9.0-rc.0

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.mjs CHANGED
@@ -2,6 +2,7 @@
2
2
  import { AUTH_ERROR_CODES, WalletType, PollarClient } from '@pollar/core';
3
3
  import { forwardRef, createContext, useState, useCallback, useEffect, useRef, useMemo, useContext, Component } from 'react';
4
4
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
+ import { startAuthentication, startRegistration } from '@simplewebauthn/browser';
5
6
 
6
7
  var __create = Object.create;
7
8
  var __defProp = Object.defineProperty;
@@ -1010,7 +1011,7 @@ var ModalErrorBoundary = class extends Component {
1010
1011
  return { crashed: true };
1011
1012
  }
1012
1013
  componentDidCatch(error) {
1013
- console.error("[Pollar] Modal crashed:", error);
1014
+ console.error("[PollarProvider] Modal crashed:", error);
1014
1015
  }
1015
1016
  render() {
1016
1017
  if (this.state.crashed) {
@@ -1028,7 +1029,7 @@ var PollarModalFooter = () => {
1028
1029
  /* @__PURE__ */ jsx("span", { className: "pollar-footer-name", children: "Pollar" }),
1029
1030
  /* @__PURE__ */ jsxs("span", { className: "pollar-footer-version", children: [
1030
1031
  "v",
1031
- "0.8.1"
1032
+ "0.9.0-rc.0"
1032
1033
  ] })
1033
1034
  ] })
1034
1035
  ] });
@@ -1065,7 +1066,8 @@ var REASON_LABEL = {
1065
1066
  DISTRIBUTION_RULE_NOT_STARTED: "Not started yet",
1066
1067
  DISTRIBUTION_RULE_EXPIRED: "Expired",
1067
1068
  DISTRIBUTION_RULE_EXHAUSTED: "Fully claimed",
1068
- DISTRIBUTION_RATE_LIMIT_EXCEEDED: "Already claimed"
1069
+ // Per-user, per-window claim limit (resets next period) — not permanent.
1070
+ DISTRIBUTION_RATE_LIMIT_EXCEEDED: "Claimed for this period"
1069
1071
  };
1070
1072
  function reasonLabel(reason) {
1071
1073
  if (!reason) return "Not available";
@@ -1342,11 +1344,7 @@ function KycModalTemplate({
1342
1344
  step === "verifying" && selectedProvider && /* @__PURE__ */ jsxs(Fragment, { children: [
1343
1345
  /* @__PURE__ */ jsx("div", { className: "pollar-kyc-iframe-wrap", children: session?.kycUrl ? /* @__PURE__ */ jsx("iframe", { className: "pollar-kyc-iframe", src: session.kycUrl, title: "KYC verification", allow: "camera; microphone" }) : /* @__PURE__ */ jsxs("div", { className: "pollar-kyc-iframe-mock", children: [
1344
1346
  /* @__PURE__ */ jsx("span", { children: "\u{1F512}" }),
1345
- /* @__PURE__ */ jsx("span", { children: selectedProvider.flow === "form" ? "Form-based KYC \u2014 fields will render here once backend is connected" : "KYC iframe will load here once backend is connected" }),
1346
- /* @__PURE__ */ jsxs("code", { style: { fontSize: "0.7rem", opacity: 0.6 }, children: [
1347
- "provider: ",
1348
- selectedProvider.id
1349
- ] })
1347
+ /* @__PURE__ */ jsx("span", { children: selectedProvider.flow === "form" ? "The identity verification form will appear here." : "Identity verification will open here." })
1350
1348
  ] }) }),
1351
1349
  /* @__PURE__ */ jsxs("div", { className: "pollar-modal-actions", children: [
1352
1350
  /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onClose, children: "Cancel" }),
@@ -1495,46 +1493,37 @@ var GoogleButton = ({ disabled, onClick }) => {
1495
1493
  return /* @__PURE__ */ jsxs("button", { className: "gsi-material-button", disabled, onClick, children: [
1496
1494
  /* @__PURE__ */ jsx("div", { className: "gsi-material-button-state" }),
1497
1495
  /* @__PURE__ */ jsxs("div", { className: "gsi-material-button-content-wrapper", children: [
1498
- /* @__PURE__ */ jsx("div", { className: "gsi-material-button-icon", children: /* @__PURE__ */ jsxs(
1499
- "svg",
1500
- {
1501
- version: "1.1",
1502
- xmlns: "http://www.w3.org/2000/svg",
1503
- viewBox: "0 0 48 48",
1504
- style: { display: "block" },
1505
- children: [
1506
- /* @__PURE__ */ jsx(
1507
- "path",
1508
- {
1509
- fill: "#EA4335",
1510
- d: "M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"
1511
- }
1512
- ),
1513
- /* @__PURE__ */ jsx(
1514
- "path",
1515
- {
1516
- fill: "#4285F4",
1517
- d: "M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"
1518
- }
1519
- ),
1520
- /* @__PURE__ */ jsx(
1521
- "path",
1522
- {
1523
- fill: "#FBBC05",
1524
- d: "M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z"
1525
- }
1526
- ),
1527
- /* @__PURE__ */ jsx(
1528
- "path",
1529
- {
1530
- fill: "#34A853",
1531
- d: "M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"
1532
- }
1533
- ),
1534
- /* @__PURE__ */ jsx("path", { fill: "none", d: "M0 0h48v48H0z" })
1535
- ]
1536
- }
1537
- ) }),
1496
+ /* @__PURE__ */ jsx("div", { className: "gsi-material-button-icon", children: /* @__PURE__ */ jsxs("svg", { version: "1.1", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 48 48", style: { display: "block" }, children: [
1497
+ /* @__PURE__ */ jsx(
1498
+ "path",
1499
+ {
1500
+ fill: "#EA4335",
1501
+ d: "M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"
1502
+ }
1503
+ ),
1504
+ /* @__PURE__ */ jsx(
1505
+ "path",
1506
+ {
1507
+ fill: "#4285F4",
1508
+ d: "M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"
1509
+ }
1510
+ ),
1511
+ /* @__PURE__ */ jsx(
1512
+ "path",
1513
+ {
1514
+ fill: "#FBBC05",
1515
+ d: "M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z"
1516
+ }
1517
+ ),
1518
+ /* @__PURE__ */ jsx(
1519
+ "path",
1520
+ {
1521
+ fill: "#34A853",
1522
+ d: "M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"
1523
+ }
1524
+ ),
1525
+ /* @__PURE__ */ jsx("path", { fill: "none", d: "M0 0h48v48H0z" })
1526
+ ] }) }),
1538
1527
  /* @__PURE__ */ jsx("span", { className: "gsi-material-button-contents", children: "Google" }),
1539
1528
  /* @__PURE__ */ jsx("span", { style: { display: "none" }, children: "Google" })
1540
1529
  ] })
@@ -1581,6 +1570,8 @@ var AUTH_STATE_MESSAGES = {
1581
1570
  connecting_wallet: "Connecting wallet\u2026",
1582
1571
  wallet_not_installed: "Wallet not installed",
1583
1572
  authenticating_wallet: "Signing in with wallet\u2026",
1573
+ creating_passkey: "Waiting for passkey\u2026",
1574
+ deploying_smart_account: "Creating your wallet\u2026",
1584
1575
  authenticating: "Authenticating\u2026",
1585
1576
  authenticated: "Welcome!",
1586
1577
  error: ""
@@ -1593,6 +1584,8 @@ function authStateToStatus(step) {
1593
1584
  "opening_oauth",
1594
1585
  "connecting_wallet",
1595
1586
  "authenticating_wallet",
1587
+ "creating_passkey",
1588
+ "deploying_smart_account",
1596
1589
  "authenticating"
1597
1590
  ];
1598
1591
  const success = ["authenticated", "entering_code"];
@@ -1608,6 +1601,7 @@ function LoginModalTemplate({
1608
1601
  logoUrl,
1609
1602
  emailEnabled,
1610
1603
  embeddedWallets,
1604
+ smartWallet = false,
1611
1605
  providers,
1612
1606
  appName,
1613
1607
  email = "",
@@ -1615,6 +1609,7 @@ function LoginModalTemplate({
1615
1609
  onEmailSubmit,
1616
1610
  onSocialLogin,
1617
1611
  onWalletConnect,
1612
+ onSmartWallet,
1618
1613
  renderWallets,
1619
1614
  authState,
1620
1615
  codeInputKey,
@@ -1728,32 +1723,60 @@ function LoginModalTemplate({
1728
1723
  enabledSocial.some(([key]) => key === "google") && /* @__PURE__ */ jsx(GoogleButton, { disabled: isLoading, onClick: () => onSocialLogin?.("google") }),
1729
1724
  enabledSocial.some(([key]) => key === "github") && /* @__PURE__ */ jsx(GithubButton, { disabled: isLoading, onClick: () => onSocialLogin?.("github") })
1730
1725
  ] }),
1731
- embeddedWallets && /* @__PURE__ */ jsx("div", { className: "pollar-wallet-section", children: /* @__PURE__ */ jsxs(
1732
- "button",
1733
- {
1734
- type: "button",
1735
- disabled: isLoading,
1736
- className: "pollar-wallet-entry-btn",
1737
- onClick: () => setShowWalletPicker(true),
1738
- children: [
1739
- /* @__PURE__ */ jsx(
1740
- "svg",
1741
- {
1742
- width: "18",
1743
- height: "20",
1744
- viewBox: "0 0 24 24",
1745
- fill: "none",
1746
- stroke: "currentColor",
1747
- strokeWidth: "2",
1748
- strokeLinecap: "round",
1749
- strokeLinejoin: "round",
1750
- children: /* @__PURE__ */ jsx("path", { d: "M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z" })
1751
- }
1752
- ),
1753
- "Wallet"
1754
- ]
1755
- }
1756
- ) })
1726
+ (embeddedWallets || smartWallet) && /* @__PURE__ */ jsxs("div", { className: "pollar-wallet-section", children: [
1727
+ embeddedWallets && /* @__PURE__ */ jsxs(
1728
+ "button",
1729
+ {
1730
+ type: "button",
1731
+ disabled: isLoading,
1732
+ className: "pollar-wallet-entry-btn",
1733
+ onClick: () => setShowWalletPicker(true),
1734
+ children: [
1735
+ /* @__PURE__ */ jsx(
1736
+ "svg",
1737
+ {
1738
+ width: "18",
1739
+ height: "20",
1740
+ viewBox: "0 0 24 24",
1741
+ fill: "none",
1742
+ stroke: "currentColor",
1743
+ strokeWidth: "2",
1744
+ strokeLinecap: "round",
1745
+ strokeLinejoin: "round",
1746
+ children: /* @__PURE__ */ jsx("path", { d: "M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z" })
1747
+ }
1748
+ ),
1749
+ "Wallet"
1750
+ ]
1751
+ }
1752
+ ),
1753
+ smartWallet && /* @__PURE__ */ jsxs(
1754
+ "button",
1755
+ {
1756
+ type: "button",
1757
+ disabled: isLoading,
1758
+ className: "pollar-wallet-entry-btn",
1759
+ onClick: onSmartWallet,
1760
+ children: [
1761
+ /* @__PURE__ */ jsx(
1762
+ "svg",
1763
+ {
1764
+ width: "18",
1765
+ height: "20",
1766
+ viewBox: "0 0 24 24",
1767
+ fill: "none",
1768
+ stroke: "currentColor",
1769
+ strokeWidth: "2",
1770
+ strokeLinecap: "round",
1771
+ strokeLinejoin: "round",
1772
+ children: /* @__PURE__ */ jsx("path", { d: "M16 8V6a4 4 0 00-8 0v2M5 8h14a1 1 0 011 1v10a1 1 0 01-1 1H5a1 1 0 01-1-1V9a1 1 0 011-1zm7 5v2" })
1773
+ }
1774
+ ),
1775
+ "Smart Wallet"
1776
+ ]
1777
+ }
1778
+ )
1779
+ ] })
1757
1780
  ] }),
1758
1781
  /* @__PURE__ */ jsx(
1759
1782
  ModalStatusBanner,
@@ -1802,6 +1825,7 @@ function LoginModal({ onClose }) {
1802
1825
  };
1803
1826
  }, [getClient]);
1804
1827
  const { theme = "light", accentColor = "#005DB4", logoUrl, emailEnabled, embeddedWallets, providers } = styles;
1828
+ const smartWallet = styles.smartWallet ?? true;
1805
1829
  function handleClose() {
1806
1830
  setEmail("");
1807
1831
  getClient().cancelLogin();
@@ -1818,6 +1842,9 @@ function LoginModal({ onClose }) {
1818
1842
  function handleWalletConnect(type) {
1819
1843
  getClient().loginWallet(type);
1820
1844
  }
1845
+ function handleSmartWallet() {
1846
+ getClient().loginSmartWallet();
1847
+ }
1821
1848
  function handleVerifyCode(code) {
1822
1849
  getClient().verifyEmailCode(code);
1823
1850
  }
@@ -1839,6 +1866,7 @@ function LoginModal({ onClose }) {
1839
1866
  logoUrl: logoUrl ?? null,
1840
1867
  emailEnabled: !!emailEnabled,
1841
1868
  embeddedWallets: !!embeddedWallets,
1869
+ smartWallet,
1842
1870
  providers: {
1843
1871
  google: !!providers?.google,
1844
1872
  discord: !!providers?.discord,
@@ -1852,6 +1880,7 @@ function LoginModal({ onClose }) {
1852
1880
  onEmailSubmit: handleEmailSubmit,
1853
1881
  onSocialLogin: handleSocialLogin,
1854
1882
  onWalletConnect: handleWalletConnect,
1883
+ onSmartWallet: handleSmartWallet,
1855
1884
  ...renderWallets !== void 0 && { renderWallets },
1856
1885
  authState,
1857
1886
  codeInputKey,
@@ -3078,18 +3107,16 @@ function SessionsModalTemplate({
3078
3107
  );
3079
3108
  }
3080
3109
  function SessionsModal({ onClose }) {
3081
- const { getClient, styles } = usePollar();
3110
+ const { getClient, styles, sessions } = usePollar();
3082
3111
  const { theme = "light", accentColor = "#005DB4" } = styles;
3083
- const [state, setState] = useState({ step: "idle" });
3084
3112
  const [revokingFamilyId, setRevokingFamilyId] = useState(null);
3085
3113
  const [signingOutEverywhere, setSigningOutEverywhere] = useState(false);
3086
- const mountedRef = useRef(true);
3087
- useEffect(
3088
- () => () => {
3089
- mountedRef.current = false;
3090
- },
3091
- []
3092
- );
3114
+ const load = useCallback(() => {
3115
+ void getClient().fetchSessions();
3116
+ }, [getClient]);
3117
+ useEffect(() => {
3118
+ load();
3119
+ }, [load]);
3093
3120
  const onCloseRef = useRef(onClose);
3094
3121
  onCloseRef.current = onClose;
3095
3122
  useEffect(() => {
@@ -3097,33 +3124,15 @@ function SessionsModal({ onClose }) {
3097
3124
  if (authState.step === "idle") onCloseRef.current();
3098
3125
  });
3099
3126
  }, [getClient]);
3100
- const load = useCallback(async () => {
3101
- setState({ step: "loading" });
3102
- try {
3103
- const sessions = await getClient().listSessions();
3104
- if (!mountedRef.current) return;
3105
- setState({ step: "loaded", sessions });
3106
- } catch (err) {
3107
- if (!mountedRef.current) return;
3108
- const message = err instanceof Error ? err.message : "Failed to load sessions";
3109
- setState({ step: "error", message });
3110
- }
3111
- }, [getClient]);
3112
- useEffect(() => {
3113
- void load();
3114
- }, [load]);
3115
3127
  const handleRevoke = useCallback(
3116
3128
  async (familyId) => {
3117
3129
  setRevokingFamilyId(familyId);
3118
3130
  try {
3119
3131
  await getClient().revokeSession(familyId);
3120
- if (!mountedRef.current) return;
3121
- await load();
3122
3132
  } catch {
3123
- if (!mountedRef.current) return;
3124
- setState((prev) => prev.step === "loaded" ? { step: "error", message: "Failed to revoke session" } : prev);
3125
3133
  } finally {
3126
- if (mountedRef.current) setRevokingFamilyId(null);
3134
+ setRevokingFamilyId(null);
3135
+ load();
3127
3136
  }
3128
3137
  },
3129
3138
  [getClient, load]
@@ -3134,7 +3143,6 @@ function SessionsModal({ onClose }) {
3134
3143
  await getClient().logoutEverywhere();
3135
3144
  onClose();
3136
3145
  } catch {
3137
- if (!mountedRef.current) return;
3138
3146
  setSigningOutEverywhere(false);
3139
3147
  }
3140
3148
  }, [getClient, onClose]);
@@ -3143,10 +3151,10 @@ function SessionsModal({ onClose }) {
3143
3151
  {
3144
3152
  theme,
3145
3153
  accentColor,
3146
- state,
3154
+ state: sessions,
3147
3155
  revokingFamilyId,
3148
3156
  signingOutEverywhere,
3149
- onRefresh: () => void load(),
3157
+ onRefresh: () => load(),
3150
3158
  onRevoke: (familyId) => void handleRevoke(familyId),
3151
3159
  onLogoutEverywhere: () => void handleLogoutEverywhere(),
3152
3160
  onClose
@@ -3560,6 +3568,60 @@ function WalletBalanceModal({ onClose }) {
3560
3568
  }
3561
3569
  ) });
3562
3570
  }
3571
+ function hexToBase64url(hex) {
3572
+ const bytes = new Uint8Array(hex.length / 2);
3573
+ for (let i = 0; i < bytes.length; i++) bytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
3574
+ let bin = "";
3575
+ for (const b of bytes) bin += String.fromCharCode(b);
3576
+ return btoa(bin).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
3577
+ }
3578
+ function randomUserId() {
3579
+ const bytes = new Uint8Array(16);
3580
+ crypto.getRandomValues(bytes);
3581
+ let bin = "";
3582
+ for (const b of bytes) bin += String.fromCharCode(b);
3583
+ return btoa(bin).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
3584
+ }
3585
+ var browserPasskeyCeremony = async ({ challenge }) => {
3586
+ const rpId = window.location.hostname;
3587
+ try {
3588
+ const response2 = await startAuthentication({
3589
+ optionsJSON: { challenge, rpId, userVerification: "required" }
3590
+ });
3591
+ return { kind: "login", response: response2 };
3592
+ } catch {
3593
+ }
3594
+ const userId = randomUserId();
3595
+ const response = await startRegistration({
3596
+ optionsJSON: {
3597
+ challenge,
3598
+ rp: { id: rpId, name: rpId },
3599
+ user: { id: userId, name: "Smart Wallet", displayName: "Smart Wallet" },
3600
+ // ES256 (secp256r1) — the curve the on-chain WebAuthn verifier expects.
3601
+ pubKeyCredParams: [{ type: "public-key", alg: -7 }],
3602
+ authenticatorSelection: { residentKey: "required", userVerification: "required" },
3603
+ attestation: "none",
3604
+ timeout: 6e4
3605
+ }
3606
+ });
3607
+ return { kind: "register", response };
3608
+ };
3609
+ var browserPasskeySigner = async ({ credentialId, challenge }) => {
3610
+ const rpId = window.location.hostname;
3611
+ const { response } = await startAuthentication({
3612
+ optionsJSON: {
3613
+ challenge: hexToBase64url(challenge),
3614
+ rpId,
3615
+ allowCredentials: [{ id: credentialId, type: "public-key" }],
3616
+ userVerification: "required"
3617
+ }
3618
+ });
3619
+ return {
3620
+ authenticatorData: response.authenticatorData,
3621
+ clientDataJSON: response.clientDataJSON,
3622
+ signature: response.signature
3623
+ };
3624
+ };
3563
3625
  var DEFAULT_APP_CONFIG = {
3564
3626
  application: { name: "" },
3565
3627
  styles: {}
@@ -3567,7 +3629,7 @@ var DEFAULT_APP_CONFIG = {
3567
3629
  function sessionsEqual(a, b) {
3568
3630
  if (a === b) return true;
3569
3631
  if (!a || !b) return false;
3570
- return a.clientSessionId === b.clientSessionId && a.userId === b.userId && a.status === b.status && a.token?.accessToken === b.token?.accessToken && a.token?.refreshToken === b.token?.refreshToken && a.token?.expiresAt === b.token?.expiresAt && a.wallet?.publicKey === b.wallet?.publicKey;
3632
+ return a.clientSessionId === b.clientSessionId && a.userId === b.userId && a.status === b.status && a.token?.accessToken === b.token?.accessToken && a.token?.refreshToken === b.token?.refreshToken && a.token?.expiresAt === b.token?.expiresAt && a.wallet?.address === b.wallet?.address;
3571
3633
  }
3572
3634
  var PollarContext = createContext(null);
3573
3635
  function PollarProvider({
@@ -3578,11 +3640,15 @@ function PollarProvider({
3578
3640
  onStorageDegrade,
3579
3641
  children
3580
3642
  }) {
3581
- const [pollarClient] = useState(() => client instanceof PollarClient ? client : new PollarClient(client));
3643
+ const [pollarClient] = useState(
3644
+ () => client instanceof PollarClient ? client : new PollarClient({ passkey: browserPasskeyCeremony, passkeySign: browserPasskeySigner, ...client })
3645
+ );
3582
3646
  const [networkState, setNetworkState] = useState(() => pollarClient.getNetworkState());
3583
3647
  const [sessionState, setSessionState] = useState(null);
3648
+ const [verified, setVerified] = useState(false);
3584
3649
  const [transaction, setTransaction] = useState({ step: "idle" });
3585
3650
  const [txHistory, setTxHistory] = useState({ step: "idle" });
3651
+ const [sessions, setSessions] = useState({ step: "idle" });
3586
3652
  const [walletBalance, setWalletBalance] = useState({ step: "idle" });
3587
3653
  const [resolvedConfig, setResolvedConfig] = useState(() => appConfigProp ?? DEFAULT_APP_CONFIG);
3588
3654
  useEffect(() => {
@@ -3591,6 +3657,9 @@ function PollarProvider({
3591
3657
  useEffect(() => {
3592
3658
  return pollarClient.onTxHistoryStateChange(setTxHistory);
3593
3659
  }, [pollarClient]);
3660
+ useEffect(() => {
3661
+ return pollarClient.onSessionsStateChange(setSessions);
3662
+ }, [pollarClient]);
3594
3663
  useEffect(() => {
3595
3664
  return pollarClient.onWalletBalanceStateChange(setWalletBalance);
3596
3665
  }, [pollarClient]);
@@ -3607,8 +3676,10 @@ function PollarProvider({
3607
3676
  return pollarClient.onAuthStateChange((authState) => {
3608
3677
  if (authState.step === "authenticated") {
3609
3678
  setSessionState((prev) => sessionsEqual(prev, authState.session) ? prev : authState.session);
3679
+ setVerified(authState.verified);
3610
3680
  } else if (authState.step === "idle") {
3611
3681
  setSessionState(null);
3682
+ setVerified(false);
3612
3683
  }
3613
3684
  });
3614
3685
  }, [pollarClient]);
@@ -3636,9 +3707,9 @@ function PollarProvider({
3636
3707
  const [receiveModalOpen, setReceiveModalOpen] = useState(false);
3637
3708
  const [sessionsModalOpen, setSessionsModalOpen] = useState(false);
3638
3709
  const [distributionRulesModalOpen, setDistributionRulesModalOpen] = useState(false);
3639
- const walletAddress = sessionState?.wallet?.publicKey || "";
3710
+ const walletAddress = sessionState?.wallet?.address || "";
3640
3711
  const getClient = useCallback(() => pollarClient, [pollarClient]);
3641
- const refreshWalletBalance = useCallback(() => pollarClient.refreshBalance(walletAddress), [pollarClient, walletAddress]);
3712
+ const refreshWalletBalance = useCallback(() => pollarClient.refreshBalance(), [pollarClient, walletAddress]);
3642
3713
  const renderWallets = ui?.renderWallets;
3643
3714
  const contextValue = useMemo(() => {
3644
3715
  const styles = resolvedConfig.styles ?? {};
@@ -3646,6 +3717,7 @@ function PollarProvider({
3646
3717
  // session
3647
3718
  walletAddress,
3648
3719
  isAuthenticated: !!walletAddress,
3720
+ verified,
3649
3721
  walletType: pollarClient.getWalletType(),
3650
3722
  // client
3651
3723
  getClient,
@@ -3673,6 +3745,7 @@ function PollarProvider({
3673
3745
  openSendModal: () => setSendModalOpen(true),
3674
3746
  openReceiveModal: () => setReceiveModalOpen(true),
3675
3747
  // sessions
3748
+ sessions,
3676
3749
  openSessionsModal: () => setSessionsModalOpen(true),
3677
3750
  // distribution
3678
3751
  openDistributionRulesModal: () => setDistributionRulesModalOpen(true),
@@ -3694,10 +3767,12 @@ function PollarProvider({
3694
3767
  };
3695
3768
  }, [
3696
3769
  walletAddress,
3770
+ verified,
3697
3771
  pollarClient,
3698
3772
  getClient,
3699
3773
  transaction,
3700
3774
  txHistory,
3775
+ sessions,
3701
3776
  walletBalance,
3702
3777
  refreshWalletBalance,
3703
3778
  networkState,
@@ -3777,6 +3852,10 @@ function WalletButtonTemplate({
3777
3852
  onTxHistory,
3778
3853
  onSend,
3779
3854
  onReceive,
3855
+ onSessions,
3856
+ onKyc,
3857
+ onRamp,
3858
+ onDistributionRules,
3780
3859
  onLogout,
3781
3860
  onLogin
3782
3861
  }) {
@@ -3936,6 +4015,94 @@ function WalletButtonTemplate({
3936
4015
  "Transaction history"
3937
4016
  ] }),
3938
4017
  /* @__PURE__ */ jsx("div", { className: "wallet-dropdown-divider" }),
4018
+ /* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onRamp, children: [
4019
+ /* @__PURE__ */ jsxs(
4020
+ "svg",
4021
+ {
4022
+ width: "14",
4023
+ height: "14",
4024
+ viewBox: "0 0 24 24",
4025
+ fill: "none",
4026
+ stroke: "currentColor",
4027
+ strokeWidth: "2",
4028
+ strokeLinecap: "round",
4029
+ strokeLinejoin: "round",
4030
+ children: [
4031
+ /* @__PURE__ */ jsx("polyline", { points: "17 1 21 5 17 9" }),
4032
+ /* @__PURE__ */ jsx("path", { d: "M3 11V9a4 4 0 0 1 4-4h14" }),
4033
+ /* @__PURE__ */ jsx("polyline", { points: "7 23 3 19 7 15" }),
4034
+ /* @__PURE__ */ jsx("path", { d: "M21 13v2a4 4 0 0 1-4 4H3" })
4035
+ ]
4036
+ }
4037
+ ),
4038
+ "Buy / Sell"
4039
+ ] }),
4040
+ /* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onKyc, children: [
4041
+ /* @__PURE__ */ jsxs(
4042
+ "svg",
4043
+ {
4044
+ width: "14",
4045
+ height: "14",
4046
+ viewBox: "0 0 24 24",
4047
+ fill: "none",
4048
+ stroke: "currentColor",
4049
+ strokeWidth: "2",
4050
+ strokeLinecap: "round",
4051
+ strokeLinejoin: "round",
4052
+ children: [
4053
+ /* @__PURE__ */ jsx("path", { d: "M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8z" }),
4054
+ /* @__PURE__ */ jsx("path", { d: "M2 21v-1a6 6 0 0 1 6-6h2" }),
4055
+ /* @__PURE__ */ jsx("polyline", { points: "16 11 18 13 22 9" })
4056
+ ]
4057
+ }
4058
+ ),
4059
+ "Identity verification"
4060
+ ] }),
4061
+ /* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onDistributionRules, children: [
4062
+ /* @__PURE__ */ jsxs(
4063
+ "svg",
4064
+ {
4065
+ width: "14",
4066
+ height: "14",
4067
+ viewBox: "0 0 24 24",
4068
+ fill: "none",
4069
+ stroke: "currentColor",
4070
+ strokeWidth: "2",
4071
+ strokeLinecap: "round",
4072
+ strokeLinejoin: "round",
4073
+ children: [
4074
+ /* @__PURE__ */ jsx("circle", { cx: "18", cy: "5", r: "3" }),
4075
+ /* @__PURE__ */ jsx("circle", { cx: "6", cy: "12", r: "3" }),
4076
+ /* @__PURE__ */ jsx("circle", { cx: "18", cy: "19", r: "3" }),
4077
+ /* @__PURE__ */ jsx("line", { x1: "8.59", y1: "13.51", x2: "15.42", y2: "17.49" }),
4078
+ /* @__PURE__ */ jsx("line", { x1: "15.41", y1: "6.51", x2: "8.59", y2: "10.49" })
4079
+ ]
4080
+ }
4081
+ ),
4082
+ "Distribution rules"
4083
+ ] }),
4084
+ /* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onSessions, children: [
4085
+ /* @__PURE__ */ jsxs(
4086
+ "svg",
4087
+ {
4088
+ width: "14",
4089
+ height: "14",
4090
+ viewBox: "0 0 24 24",
4091
+ fill: "none",
4092
+ stroke: "currentColor",
4093
+ strokeWidth: "2",
4094
+ strokeLinecap: "round",
4095
+ strokeLinejoin: "round",
4096
+ children: [
4097
+ /* @__PURE__ */ jsx("rect", { x: "2", y: "3", width: "20", height: "14", rx: "2", ry: "2" }),
4098
+ /* @__PURE__ */ jsx("line", { x1: "8", y1: "21", x2: "16", y2: "21" }),
4099
+ /* @__PURE__ */ jsx("line", { x1: "12", y1: "17", x2: "12", y2: "21" })
4100
+ ]
4101
+ }
4102
+ ),
4103
+ "Active sessions"
4104
+ ] }),
4105
+ /* @__PURE__ */ jsx("div", { className: "wallet-dropdown-divider" }),
3939
4106
  /* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item danger", onClick: onLogout, children: [
3940
4107
  /* @__PURE__ */ jsxs(
3941
4108
  "svg",
@@ -3970,6 +4137,10 @@ function WalletButton() {
3970
4137
  openWalletBalanceModal,
3971
4138
  openSendModal,
3972
4139
  openReceiveModal,
4140
+ openSessionsModal,
4141
+ openKycModal,
4142
+ openRampModal,
4143
+ openDistributionRulesModal,
3973
4144
  tx: transaction,
3974
4145
  walletType
3975
4146
  } = usePollar();
@@ -4028,6 +4199,22 @@ function WalletButton() {
4028
4199
  setOpen(false);
4029
4200
  openReceiveModal();
4030
4201
  }
4202
+ function handleSessions() {
4203
+ setOpen(false);
4204
+ openSessionsModal();
4205
+ }
4206
+ function handleKyc() {
4207
+ setOpen(false);
4208
+ openKycModal();
4209
+ }
4210
+ function handleRamp() {
4211
+ setOpen(false);
4212
+ openRampModal();
4213
+ }
4214
+ function handleDistributionRules() {
4215
+ setOpen(false);
4216
+ openDistributionRulesModal();
4217
+ }
4031
4218
  return /* @__PURE__ */ jsx(
4032
4219
  WalletButtonTemplate,
4033
4220
  {
@@ -4047,12 +4234,16 @@ function WalletButton() {
4047
4234
  onTxHistory: handleTxHistory,
4048
4235
  onSend: handleSend,
4049
4236
  onReceive: handleReceive,
4237
+ onSessions: handleSessions,
4238
+ onKyc: handleKyc,
4239
+ onRamp: handleRamp,
4240
+ onDistributionRules: handleDistributionRules,
4050
4241
  onLogout: handleLogout,
4051
4242
  onLogin: openLoginModal
4052
4243
  }
4053
4244
  );
4054
4245
  }
4055
4246
 
4056
- export { DistributionRulesModal, DistributionRulesModalTemplate, KycModal, KycModalTemplate, KycStatus, LoginModalTemplate, PollarProvider, RampWidget, RampWidgetTemplate, ReceiveModal, ReceiveModalTemplate, RouteDisplay, SendModal, SendModalTemplate, SessionsModal, SessionsModalTemplate, TransactionModalTemplate, TxHistoryModalTemplate, TxStatusView, WalletBalanceModal, WalletBalanceModalTemplate, WalletButton, createPollarAdapterHook, usePollar };
4247
+ export { DistributionRulesModal, DistributionRulesModalTemplate, KycModal, KycModalTemplate, KycStatus, LoginModalTemplate, PollarProvider, RampWidget, RampWidgetTemplate, ReceiveModal, ReceiveModalTemplate, RouteDisplay, SendModal, SendModalTemplate, SessionsModal, SessionsModalTemplate, TransactionModalTemplate, TxHistoryModalTemplate, TxStatusView, WalletBalanceModal, WalletBalanceModalTemplate, WalletButton, WalletButtonTemplate, createPollarAdapterHook, usePollar };
4057
4248
  //# sourceMappingURL=index.mjs.map
4058
4249
  //# sourceMappingURL=index.mjs.map