@pollar/react 0.8.0 → 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.0"
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,
@@ -1691,7 +1686,9 @@ function LoginModalTemplate({
1691
1686
  }) }, codeInputKey)
1692
1687
  ] }) : showWalletPicker ? /* @__PURE__ */ jsxs(Fragment, { children: [
1693
1688
  /* @__PURE__ */ jsx(BackButton, { onClick: () => setShowWalletPicker(false) }),
1694
- renderWallets ? renderWallets({ onConnect: onWalletConnect, authState }) : /* @__PURE__ */ jsx(DefaultFreighterAlbedoButtons, { onConnect: onWalletConnect, isLoading })
1689
+ renderWallets ? renderWallets({ onConnect: onWalletConnect ?? (() => {
1690
+ }), authState }) : /* @__PURE__ */ jsx(DefaultFreighterAlbedoButtons, { onConnect: onWalletConnect ?? (() => {
1691
+ }), isLoading })
1695
1692
  ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1696
1693
  emailEnabled && /* @__PURE__ */ jsxs("div", { className: "pollar-email-section", children: [
1697
1694
  /* @__PURE__ */ jsx(
@@ -1726,32 +1723,60 @@ function LoginModalTemplate({
1726
1723
  enabledSocial.some(([key]) => key === "google") && /* @__PURE__ */ jsx(GoogleButton, { disabled: isLoading, onClick: () => onSocialLogin?.("google") }),
1727
1724
  enabledSocial.some(([key]) => key === "github") && /* @__PURE__ */ jsx(GithubButton, { disabled: isLoading, onClick: () => onSocialLogin?.("github") })
1728
1725
  ] }),
1729
- embeddedWallets && /* @__PURE__ */ jsx("div", { className: "pollar-wallet-section", children: /* @__PURE__ */ jsxs(
1730
- "button",
1731
- {
1732
- type: "button",
1733
- disabled: isLoading,
1734
- className: "pollar-wallet-entry-btn",
1735
- onClick: () => setShowWalletPicker(true),
1736
- children: [
1737
- /* @__PURE__ */ jsx(
1738
- "svg",
1739
- {
1740
- width: "18",
1741
- height: "20",
1742
- viewBox: "0 0 24 24",
1743
- fill: "none",
1744
- stroke: "currentColor",
1745
- strokeWidth: "2",
1746
- strokeLinecap: "round",
1747
- strokeLinejoin: "round",
1748
- 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" })
1749
- }
1750
- ),
1751
- "Wallet"
1752
- ]
1753
- }
1754
- ) })
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
+ ] })
1755
1780
  ] }),
1756
1781
  /* @__PURE__ */ jsx(
1757
1782
  ModalStatusBanner,
@@ -1800,6 +1825,7 @@ function LoginModal({ onClose }) {
1800
1825
  };
1801
1826
  }, [getClient]);
1802
1827
  const { theme = "light", accentColor = "#005DB4", logoUrl, emailEnabled, embeddedWallets, providers } = styles;
1828
+ const smartWallet = styles.smartWallet ?? true;
1803
1829
  function handleClose() {
1804
1830
  setEmail("");
1805
1831
  getClient().cancelLogin();
@@ -1816,6 +1842,9 @@ function LoginModal({ onClose }) {
1816
1842
  function handleWalletConnect(type) {
1817
1843
  getClient().loginWallet(type);
1818
1844
  }
1845
+ function handleSmartWallet() {
1846
+ getClient().loginSmartWallet();
1847
+ }
1819
1848
  function handleVerifyCode(code) {
1820
1849
  getClient().verifyEmailCode(code);
1821
1850
  }
@@ -1837,6 +1866,7 @@ function LoginModal({ onClose }) {
1837
1866
  logoUrl: logoUrl ?? null,
1838
1867
  emailEnabled: !!emailEnabled,
1839
1868
  embeddedWallets: !!embeddedWallets,
1869
+ smartWallet,
1840
1870
  providers: {
1841
1871
  google: !!providers?.google,
1842
1872
  discord: !!providers?.discord,
@@ -1850,6 +1880,7 @@ function LoginModal({ onClose }) {
1850
1880
  onEmailSubmit: handleEmailSubmit,
1851
1881
  onSocialLogin: handleSocialLogin,
1852
1882
  onWalletConnect: handleWalletConnect,
1883
+ onSmartWallet: handleSmartWallet,
1853
1884
  ...renderWallets !== void 0 && { renderWallets },
1854
1885
  authState,
1855
1886
  codeInputKey,
@@ -3076,18 +3107,16 @@ function SessionsModalTemplate({
3076
3107
  );
3077
3108
  }
3078
3109
  function SessionsModal({ onClose }) {
3079
- const { getClient, styles } = usePollar();
3110
+ const { getClient, styles, sessions } = usePollar();
3080
3111
  const { theme = "light", accentColor = "#005DB4" } = styles;
3081
- const [state, setState] = useState({ step: "idle" });
3082
3112
  const [revokingFamilyId, setRevokingFamilyId] = useState(null);
3083
3113
  const [signingOutEverywhere, setSigningOutEverywhere] = useState(false);
3084
- const mountedRef = useRef(true);
3085
- useEffect(
3086
- () => () => {
3087
- mountedRef.current = false;
3088
- },
3089
- []
3090
- );
3114
+ const load = useCallback(() => {
3115
+ void getClient().fetchSessions();
3116
+ }, [getClient]);
3117
+ useEffect(() => {
3118
+ load();
3119
+ }, [load]);
3091
3120
  const onCloseRef = useRef(onClose);
3092
3121
  onCloseRef.current = onClose;
3093
3122
  useEffect(() => {
@@ -3095,33 +3124,15 @@ function SessionsModal({ onClose }) {
3095
3124
  if (authState.step === "idle") onCloseRef.current();
3096
3125
  });
3097
3126
  }, [getClient]);
3098
- const load = useCallback(async () => {
3099
- setState({ step: "loading" });
3100
- try {
3101
- const sessions = await getClient().listSessions();
3102
- if (!mountedRef.current) return;
3103
- setState({ step: "loaded", sessions });
3104
- } catch (err) {
3105
- if (!mountedRef.current) return;
3106
- const message = err instanceof Error ? err.message : "Failed to load sessions";
3107
- setState({ step: "error", message });
3108
- }
3109
- }, [getClient]);
3110
- useEffect(() => {
3111
- void load();
3112
- }, [load]);
3113
3127
  const handleRevoke = useCallback(
3114
3128
  async (familyId) => {
3115
3129
  setRevokingFamilyId(familyId);
3116
3130
  try {
3117
3131
  await getClient().revokeSession(familyId);
3118
- if (!mountedRef.current) return;
3119
- await load();
3120
3132
  } catch {
3121
- if (!mountedRef.current) return;
3122
- setState((prev) => prev.step === "loaded" ? { step: "error", message: "Failed to revoke session" } : prev);
3123
3133
  } finally {
3124
- if (mountedRef.current) setRevokingFamilyId(null);
3134
+ setRevokingFamilyId(null);
3135
+ load();
3125
3136
  }
3126
3137
  },
3127
3138
  [getClient, load]
@@ -3132,7 +3143,6 @@ function SessionsModal({ onClose }) {
3132
3143
  await getClient().logoutEverywhere();
3133
3144
  onClose();
3134
3145
  } catch {
3135
- if (!mountedRef.current) return;
3136
3146
  setSigningOutEverywhere(false);
3137
3147
  }
3138
3148
  }, [getClient, onClose]);
@@ -3141,10 +3151,10 @@ function SessionsModal({ onClose }) {
3141
3151
  {
3142
3152
  theme,
3143
3153
  accentColor,
3144
- state,
3154
+ state: sessions,
3145
3155
  revokingFamilyId,
3146
3156
  signingOutEverywhere,
3147
- onRefresh: () => void load(),
3157
+ onRefresh: () => load(),
3148
3158
  onRevoke: (familyId) => void handleRevoke(familyId),
3149
3159
  onLogoutEverywhere: () => void handleLogoutEverywhere(),
3150
3160
  onClose
@@ -3558,6 +3568,60 @@ function WalletBalanceModal({ onClose }) {
3558
3568
  }
3559
3569
  ) });
3560
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
+ };
3561
3625
  var DEFAULT_APP_CONFIG = {
3562
3626
  application: { name: "" },
3563
3627
  styles: {}
@@ -3565,7 +3629,7 @@ var DEFAULT_APP_CONFIG = {
3565
3629
  function sessionsEqual(a, b) {
3566
3630
  if (a === b) return true;
3567
3631
  if (!a || !b) return false;
3568
- 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;
3569
3633
  }
3570
3634
  var PollarContext = createContext(null);
3571
3635
  function PollarProvider({
@@ -3576,11 +3640,15 @@ function PollarProvider({
3576
3640
  onStorageDegrade,
3577
3641
  children
3578
3642
  }) {
3579
- 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
+ );
3580
3646
  const [networkState, setNetworkState] = useState(() => pollarClient.getNetworkState());
3581
3647
  const [sessionState, setSessionState] = useState(null);
3648
+ const [verified, setVerified] = useState(false);
3582
3649
  const [transaction, setTransaction] = useState({ step: "idle" });
3583
3650
  const [txHistory, setTxHistory] = useState({ step: "idle" });
3651
+ const [sessions, setSessions] = useState({ step: "idle" });
3584
3652
  const [walletBalance, setWalletBalance] = useState({ step: "idle" });
3585
3653
  const [resolvedConfig, setResolvedConfig] = useState(() => appConfigProp ?? DEFAULT_APP_CONFIG);
3586
3654
  useEffect(() => {
@@ -3589,6 +3657,9 @@ function PollarProvider({
3589
3657
  useEffect(() => {
3590
3658
  return pollarClient.onTxHistoryStateChange(setTxHistory);
3591
3659
  }, [pollarClient]);
3660
+ useEffect(() => {
3661
+ return pollarClient.onSessionsStateChange(setSessions);
3662
+ }, [pollarClient]);
3592
3663
  useEffect(() => {
3593
3664
  return pollarClient.onWalletBalanceStateChange(setWalletBalance);
3594
3665
  }, [pollarClient]);
@@ -3605,8 +3676,10 @@ function PollarProvider({
3605
3676
  return pollarClient.onAuthStateChange((authState) => {
3606
3677
  if (authState.step === "authenticated") {
3607
3678
  setSessionState((prev) => sessionsEqual(prev, authState.session) ? prev : authState.session);
3679
+ setVerified(authState.verified);
3608
3680
  } else if (authState.step === "idle") {
3609
3681
  setSessionState(null);
3682
+ setVerified(false);
3610
3683
  }
3611
3684
  });
3612
3685
  }, [pollarClient]);
@@ -3634,9 +3707,9 @@ function PollarProvider({
3634
3707
  const [receiveModalOpen, setReceiveModalOpen] = useState(false);
3635
3708
  const [sessionsModalOpen, setSessionsModalOpen] = useState(false);
3636
3709
  const [distributionRulesModalOpen, setDistributionRulesModalOpen] = useState(false);
3637
- const walletAddress = sessionState?.wallet?.publicKey || "";
3710
+ const walletAddress = sessionState?.wallet?.address || "";
3638
3711
  const getClient = useCallback(() => pollarClient, [pollarClient]);
3639
- const refreshWalletBalance = useCallback(() => pollarClient.refreshBalance(walletAddress), [pollarClient, walletAddress]);
3712
+ const refreshWalletBalance = useCallback(() => pollarClient.refreshBalance(), [pollarClient, walletAddress]);
3640
3713
  const renderWallets = ui?.renderWallets;
3641
3714
  const contextValue = useMemo(() => {
3642
3715
  const styles = resolvedConfig.styles ?? {};
@@ -3644,6 +3717,7 @@ function PollarProvider({
3644
3717
  // session
3645
3718
  walletAddress,
3646
3719
  isAuthenticated: !!walletAddress,
3720
+ verified,
3647
3721
  walletType: pollarClient.getWalletType(),
3648
3722
  // client
3649
3723
  getClient,
@@ -3671,6 +3745,7 @@ function PollarProvider({
3671
3745
  openSendModal: () => setSendModalOpen(true),
3672
3746
  openReceiveModal: () => setReceiveModalOpen(true),
3673
3747
  // sessions
3748
+ sessions,
3674
3749
  openSessionsModal: () => setSessionsModalOpen(true),
3675
3750
  // distribution
3676
3751
  openDistributionRulesModal: () => setDistributionRulesModalOpen(true),
@@ -3692,10 +3767,12 @@ function PollarProvider({
3692
3767
  };
3693
3768
  }, [
3694
3769
  walletAddress,
3770
+ verified,
3695
3771
  pollarClient,
3696
3772
  getClient,
3697
3773
  transaction,
3698
3774
  txHistory,
3775
+ sessions,
3699
3776
  walletBalance,
3700
3777
  refreshWalletBalance,
3701
3778
  networkState,
@@ -3775,6 +3852,10 @@ function WalletButtonTemplate({
3775
3852
  onTxHistory,
3776
3853
  onSend,
3777
3854
  onReceive,
3855
+ onSessions,
3856
+ onKyc,
3857
+ onRamp,
3858
+ onDistributionRules,
3778
3859
  onLogout,
3779
3860
  onLogin
3780
3861
  }) {
@@ -3934,6 +4015,94 @@ function WalletButtonTemplate({
3934
4015
  "Transaction history"
3935
4016
  ] }),
3936
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" }),
3937
4106
  /* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item danger", onClick: onLogout, children: [
3938
4107
  /* @__PURE__ */ jsxs(
3939
4108
  "svg",
@@ -3968,6 +4137,10 @@ function WalletButton() {
3968
4137
  openWalletBalanceModal,
3969
4138
  openSendModal,
3970
4139
  openReceiveModal,
4140
+ openSessionsModal,
4141
+ openKycModal,
4142
+ openRampModal,
4143
+ openDistributionRulesModal,
3971
4144
  tx: transaction,
3972
4145
  walletType
3973
4146
  } = usePollar();
@@ -4026,6 +4199,22 @@ function WalletButton() {
4026
4199
  setOpen(false);
4027
4200
  openReceiveModal();
4028
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
+ }
4029
4218
  return /* @__PURE__ */ jsx(
4030
4219
  WalletButtonTemplate,
4031
4220
  {
@@ -4045,12 +4234,16 @@ function WalletButton() {
4045
4234
  onTxHistory: handleTxHistory,
4046
4235
  onSend: handleSend,
4047
4236
  onReceive: handleReceive,
4237
+ onSessions: handleSessions,
4238
+ onKyc: handleKyc,
4239
+ onRamp: handleRamp,
4240
+ onDistributionRules: handleDistributionRules,
4048
4241
  onLogout: handleLogout,
4049
4242
  onLogin: openLoginModal
4050
4243
  }
4051
4244
  );
4052
4245
  }
4053
4246
 
4054
- 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 };
4055
4248
  //# sourceMappingURL=index.mjs.map
4056
4249
  //# sourceMappingURL=index.mjs.map