@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/README.md +3 -0
- package/dist/index.d.mts +43 -27
- package/dist/index.d.ts +43 -27
- package/dist/index.js +305 -111
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +305 -112
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
var core = require('@pollar/core');
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var browser = require('@simplewebauthn/browser');
|
|
7
8
|
|
|
8
9
|
var __create = Object.create;
|
|
9
10
|
var __defProp = Object.defineProperty;
|
|
@@ -1012,7 +1013,7 @@ var ModalErrorBoundary = class extends react.Component {
|
|
|
1012
1013
|
return { crashed: true };
|
|
1013
1014
|
}
|
|
1014
1015
|
componentDidCatch(error) {
|
|
1015
|
-
console.error("[
|
|
1016
|
+
console.error("[PollarProvider] Modal crashed:", error);
|
|
1016
1017
|
}
|
|
1017
1018
|
render() {
|
|
1018
1019
|
if (this.state.crashed) {
|
|
@@ -1030,7 +1031,7 @@ var PollarModalFooter = () => {
|
|
|
1030
1031
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-footer-name", children: "Pollar" }),
|
|
1031
1032
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-footer-version", children: [
|
|
1032
1033
|
"v",
|
|
1033
|
-
"0.
|
|
1034
|
+
"0.9.0-rc.0"
|
|
1034
1035
|
] })
|
|
1035
1036
|
] })
|
|
1036
1037
|
] });
|
|
@@ -1067,7 +1068,8 @@ var REASON_LABEL = {
|
|
|
1067
1068
|
DISTRIBUTION_RULE_NOT_STARTED: "Not started yet",
|
|
1068
1069
|
DISTRIBUTION_RULE_EXPIRED: "Expired",
|
|
1069
1070
|
DISTRIBUTION_RULE_EXHAUSTED: "Fully claimed",
|
|
1070
|
-
|
|
1071
|
+
// Per-user, per-window claim limit (resets next period) — not permanent.
|
|
1072
|
+
DISTRIBUTION_RATE_LIMIT_EXCEEDED: "Claimed for this period"
|
|
1071
1073
|
};
|
|
1072
1074
|
function reasonLabel(reason) {
|
|
1073
1075
|
if (!reason) return "Not available";
|
|
@@ -1344,11 +1346,7 @@ function KycModalTemplate({
|
|
|
1344
1346
|
step === "verifying" && selectedProvider && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1345
1347
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-kyc-iframe-wrap", children: session?.kycUrl ? /* @__PURE__ */ jsxRuntime.jsx("iframe", { className: "pollar-kyc-iframe", src: session.kycUrl, title: "KYC verification", allow: "camera; microphone" }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-kyc-iframe-mock", children: [
|
|
1346
1348
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u{1F512}" }),
|
|
1347
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: selectedProvider.flow === "form" ? "
|
|
1348
|
-
/* @__PURE__ */ jsxRuntime.jsxs("code", { style: { fontSize: "0.7rem", opacity: 0.6 }, children: [
|
|
1349
|
-
"provider: ",
|
|
1350
|
-
selectedProvider.id
|
|
1351
|
-
] })
|
|
1349
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: selectedProvider.flow === "form" ? "The identity verification form will appear here." : "Identity verification will open here." })
|
|
1352
1350
|
] }) }),
|
|
1353
1351
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-actions", children: [
|
|
1354
1352
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onClose, children: "Cancel" }),
|
|
@@ -1497,46 +1495,37 @@ var GoogleButton = ({ disabled, onClick }) => {
|
|
|
1497
1495
|
return /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "gsi-material-button", disabled, onClick, children: [
|
|
1498
1496
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "gsi-material-button-state" }),
|
|
1499
1497
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "gsi-material-button-content-wrapper", children: [
|
|
1500
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "gsi-material-button-icon", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
{
|
|
1532
|
-
fill: "#34A853",
|
|
1533
|
-
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"
|
|
1534
|
-
}
|
|
1535
|
-
),
|
|
1536
|
-
/* @__PURE__ */ jsxRuntime.jsx("path", { fill: "none", d: "M0 0h48v48H0z" })
|
|
1537
|
-
]
|
|
1538
|
-
}
|
|
1539
|
-
) }),
|
|
1498
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "gsi-material-button-icon", children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { version: "1.1", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 48 48", style: { display: "block" }, children: [
|
|
1499
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1500
|
+
"path",
|
|
1501
|
+
{
|
|
1502
|
+
fill: "#EA4335",
|
|
1503
|
+
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"
|
|
1504
|
+
}
|
|
1505
|
+
),
|
|
1506
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1507
|
+
"path",
|
|
1508
|
+
{
|
|
1509
|
+
fill: "#4285F4",
|
|
1510
|
+
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"
|
|
1511
|
+
}
|
|
1512
|
+
),
|
|
1513
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1514
|
+
"path",
|
|
1515
|
+
{
|
|
1516
|
+
fill: "#FBBC05",
|
|
1517
|
+
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"
|
|
1518
|
+
}
|
|
1519
|
+
),
|
|
1520
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1521
|
+
"path",
|
|
1522
|
+
{
|
|
1523
|
+
fill: "#34A853",
|
|
1524
|
+
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"
|
|
1525
|
+
}
|
|
1526
|
+
),
|
|
1527
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { fill: "none", d: "M0 0h48v48H0z" })
|
|
1528
|
+
] }) }),
|
|
1540
1529
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "gsi-material-button-contents", children: "Google" }),
|
|
1541
1530
|
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { display: "none" }, children: "Google" })
|
|
1542
1531
|
] })
|
|
@@ -1583,6 +1572,8 @@ var AUTH_STATE_MESSAGES = {
|
|
|
1583
1572
|
connecting_wallet: "Connecting wallet\u2026",
|
|
1584
1573
|
wallet_not_installed: "Wallet not installed",
|
|
1585
1574
|
authenticating_wallet: "Signing in with wallet\u2026",
|
|
1575
|
+
creating_passkey: "Waiting for passkey\u2026",
|
|
1576
|
+
deploying_smart_account: "Creating your wallet\u2026",
|
|
1586
1577
|
authenticating: "Authenticating\u2026",
|
|
1587
1578
|
authenticated: "Welcome!",
|
|
1588
1579
|
error: ""
|
|
@@ -1595,6 +1586,8 @@ function authStateToStatus(step) {
|
|
|
1595
1586
|
"opening_oauth",
|
|
1596
1587
|
"connecting_wallet",
|
|
1597
1588
|
"authenticating_wallet",
|
|
1589
|
+
"creating_passkey",
|
|
1590
|
+
"deploying_smart_account",
|
|
1598
1591
|
"authenticating"
|
|
1599
1592
|
];
|
|
1600
1593
|
const success = ["authenticated", "entering_code"];
|
|
@@ -1610,6 +1603,7 @@ function LoginModalTemplate({
|
|
|
1610
1603
|
logoUrl,
|
|
1611
1604
|
emailEnabled,
|
|
1612
1605
|
embeddedWallets,
|
|
1606
|
+
smartWallet = false,
|
|
1613
1607
|
providers,
|
|
1614
1608
|
appName,
|
|
1615
1609
|
email = "",
|
|
@@ -1617,6 +1611,7 @@ function LoginModalTemplate({
|
|
|
1617
1611
|
onEmailSubmit,
|
|
1618
1612
|
onSocialLogin,
|
|
1619
1613
|
onWalletConnect,
|
|
1614
|
+
onSmartWallet,
|
|
1620
1615
|
renderWallets,
|
|
1621
1616
|
authState,
|
|
1622
1617
|
codeInputKey,
|
|
@@ -1693,7 +1688,9 @@ function LoginModalTemplate({
|
|
|
1693
1688
|
}) }, codeInputKey)
|
|
1694
1689
|
] }) : showWalletPicker ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1695
1690
|
/* @__PURE__ */ jsxRuntime.jsx(BackButton, { onClick: () => setShowWalletPicker(false) }),
|
|
1696
|
-
renderWallets ? renderWallets({ onConnect: onWalletConnect
|
|
1691
|
+
renderWallets ? renderWallets({ onConnect: onWalletConnect ?? (() => {
|
|
1692
|
+
}), authState }) : /* @__PURE__ */ jsxRuntime.jsx(DefaultFreighterAlbedoButtons, { onConnect: onWalletConnect ?? (() => {
|
|
1693
|
+
}), isLoading })
|
|
1697
1694
|
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1698
1695
|
emailEnabled && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-email-section", children: [
|
|
1699
1696
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1728,32 +1725,60 @@ function LoginModalTemplate({
|
|
|
1728
1725
|
enabledSocial.some(([key]) => key === "google") && /* @__PURE__ */ jsxRuntime.jsx(GoogleButton, { disabled: isLoading, onClick: () => onSocialLogin?.("google") }),
|
|
1729
1726
|
enabledSocial.some(([key]) => key === "github") && /* @__PURE__ */ jsxRuntime.jsx(GithubButton, { disabled: isLoading, onClick: () => onSocialLogin?.("github") })
|
|
1730
1727
|
] }),
|
|
1731
|
-
embeddedWallets && /* @__PURE__ */ jsxRuntime.
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1728
|
+
(embeddedWallets || smartWallet) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-wallet-section", children: [
|
|
1729
|
+
embeddedWallets && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1730
|
+
"button",
|
|
1731
|
+
{
|
|
1732
|
+
type: "button",
|
|
1733
|
+
disabled: isLoading,
|
|
1734
|
+
className: "pollar-wallet-entry-btn",
|
|
1735
|
+
onClick: () => setShowWalletPicker(true),
|
|
1736
|
+
children: [
|
|
1737
|
+
/* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.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
|
+
),
|
|
1755
|
+
smartWallet && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1756
|
+
"button",
|
|
1757
|
+
{
|
|
1758
|
+
type: "button",
|
|
1759
|
+
disabled: isLoading,
|
|
1760
|
+
className: "pollar-wallet-entry-btn",
|
|
1761
|
+
onClick: onSmartWallet,
|
|
1762
|
+
children: [
|
|
1763
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1764
|
+
"svg",
|
|
1765
|
+
{
|
|
1766
|
+
width: "18",
|
|
1767
|
+
height: "20",
|
|
1768
|
+
viewBox: "0 0 24 24",
|
|
1769
|
+
fill: "none",
|
|
1770
|
+
stroke: "currentColor",
|
|
1771
|
+
strokeWidth: "2",
|
|
1772
|
+
strokeLinecap: "round",
|
|
1773
|
+
strokeLinejoin: "round",
|
|
1774
|
+
children: /* @__PURE__ */ jsxRuntime.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" })
|
|
1775
|
+
}
|
|
1776
|
+
),
|
|
1777
|
+
"Smart Wallet"
|
|
1778
|
+
]
|
|
1779
|
+
}
|
|
1780
|
+
)
|
|
1781
|
+
] })
|
|
1757
1782
|
] }),
|
|
1758
1783
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1759
1784
|
ModalStatusBanner,
|
|
@@ -1802,6 +1827,7 @@ function LoginModal({ onClose }) {
|
|
|
1802
1827
|
};
|
|
1803
1828
|
}, [getClient]);
|
|
1804
1829
|
const { theme = "light", accentColor = "#005DB4", logoUrl, emailEnabled, embeddedWallets, providers } = styles;
|
|
1830
|
+
const smartWallet = styles.smartWallet ?? true;
|
|
1805
1831
|
function handleClose() {
|
|
1806
1832
|
setEmail("");
|
|
1807
1833
|
getClient().cancelLogin();
|
|
@@ -1818,6 +1844,9 @@ function LoginModal({ onClose }) {
|
|
|
1818
1844
|
function handleWalletConnect(type) {
|
|
1819
1845
|
getClient().loginWallet(type);
|
|
1820
1846
|
}
|
|
1847
|
+
function handleSmartWallet() {
|
|
1848
|
+
getClient().loginSmartWallet();
|
|
1849
|
+
}
|
|
1821
1850
|
function handleVerifyCode(code) {
|
|
1822
1851
|
getClient().verifyEmailCode(code);
|
|
1823
1852
|
}
|
|
@@ -1839,6 +1868,7 @@ function LoginModal({ onClose }) {
|
|
|
1839
1868
|
logoUrl: logoUrl ?? null,
|
|
1840
1869
|
emailEnabled: !!emailEnabled,
|
|
1841
1870
|
embeddedWallets: !!embeddedWallets,
|
|
1871
|
+
smartWallet,
|
|
1842
1872
|
providers: {
|
|
1843
1873
|
google: !!providers?.google,
|
|
1844
1874
|
discord: !!providers?.discord,
|
|
@@ -1852,6 +1882,7 @@ function LoginModal({ onClose }) {
|
|
|
1852
1882
|
onEmailSubmit: handleEmailSubmit,
|
|
1853
1883
|
onSocialLogin: handleSocialLogin,
|
|
1854
1884
|
onWalletConnect: handleWalletConnect,
|
|
1885
|
+
onSmartWallet: handleSmartWallet,
|
|
1855
1886
|
...renderWallets !== void 0 && { renderWallets },
|
|
1856
1887
|
authState,
|
|
1857
1888
|
codeInputKey,
|
|
@@ -3078,18 +3109,16 @@ function SessionsModalTemplate({
|
|
|
3078
3109
|
);
|
|
3079
3110
|
}
|
|
3080
3111
|
function SessionsModal({ onClose }) {
|
|
3081
|
-
const { getClient, styles } = usePollar();
|
|
3112
|
+
const { getClient, styles, sessions } = usePollar();
|
|
3082
3113
|
const { theme = "light", accentColor = "#005DB4" } = styles;
|
|
3083
|
-
const [state, setState] = react.useState({ step: "idle" });
|
|
3084
3114
|
const [revokingFamilyId, setRevokingFamilyId] = react.useState(null);
|
|
3085
3115
|
const [signingOutEverywhere, setSigningOutEverywhere] = react.useState(false);
|
|
3086
|
-
const
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
);
|
|
3116
|
+
const load = react.useCallback(() => {
|
|
3117
|
+
void getClient().fetchSessions();
|
|
3118
|
+
}, [getClient]);
|
|
3119
|
+
react.useEffect(() => {
|
|
3120
|
+
load();
|
|
3121
|
+
}, [load]);
|
|
3093
3122
|
const onCloseRef = react.useRef(onClose);
|
|
3094
3123
|
onCloseRef.current = onClose;
|
|
3095
3124
|
react.useEffect(() => {
|
|
@@ -3097,33 +3126,15 @@ function SessionsModal({ onClose }) {
|
|
|
3097
3126
|
if (authState.step === "idle") onCloseRef.current();
|
|
3098
3127
|
});
|
|
3099
3128
|
}, [getClient]);
|
|
3100
|
-
const load = react.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
|
-
react.useEffect(() => {
|
|
3113
|
-
void load();
|
|
3114
|
-
}, [load]);
|
|
3115
3129
|
const handleRevoke = react.useCallback(
|
|
3116
3130
|
async (familyId) => {
|
|
3117
3131
|
setRevokingFamilyId(familyId);
|
|
3118
3132
|
try {
|
|
3119
3133
|
await getClient().revokeSession(familyId);
|
|
3120
|
-
if (!mountedRef.current) return;
|
|
3121
|
-
await load();
|
|
3122
3134
|
} catch {
|
|
3123
|
-
if (!mountedRef.current) return;
|
|
3124
|
-
setState((prev) => prev.step === "loaded" ? { step: "error", message: "Failed to revoke session" } : prev);
|
|
3125
3135
|
} finally {
|
|
3126
|
-
|
|
3136
|
+
setRevokingFamilyId(null);
|
|
3137
|
+
load();
|
|
3127
3138
|
}
|
|
3128
3139
|
},
|
|
3129
3140
|
[getClient, load]
|
|
@@ -3134,7 +3145,6 @@ function SessionsModal({ onClose }) {
|
|
|
3134
3145
|
await getClient().logoutEverywhere();
|
|
3135
3146
|
onClose();
|
|
3136
3147
|
} catch {
|
|
3137
|
-
if (!mountedRef.current) return;
|
|
3138
3148
|
setSigningOutEverywhere(false);
|
|
3139
3149
|
}
|
|
3140
3150
|
}, [getClient, onClose]);
|
|
@@ -3143,10 +3153,10 @@ function SessionsModal({ onClose }) {
|
|
|
3143
3153
|
{
|
|
3144
3154
|
theme,
|
|
3145
3155
|
accentColor,
|
|
3146
|
-
state,
|
|
3156
|
+
state: sessions,
|
|
3147
3157
|
revokingFamilyId,
|
|
3148
3158
|
signingOutEverywhere,
|
|
3149
|
-
onRefresh: () =>
|
|
3159
|
+
onRefresh: () => load(),
|
|
3150
3160
|
onRevoke: (familyId) => void handleRevoke(familyId),
|
|
3151
3161
|
onLogoutEverywhere: () => void handleLogoutEverywhere(),
|
|
3152
3162
|
onClose
|
|
@@ -3560,6 +3570,60 @@ function WalletBalanceModal({ onClose }) {
|
|
|
3560
3570
|
}
|
|
3561
3571
|
) });
|
|
3562
3572
|
}
|
|
3573
|
+
function hexToBase64url(hex) {
|
|
3574
|
+
const bytes = new Uint8Array(hex.length / 2);
|
|
3575
|
+
for (let i = 0; i < bytes.length; i++) bytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
3576
|
+
let bin = "";
|
|
3577
|
+
for (const b of bytes) bin += String.fromCharCode(b);
|
|
3578
|
+
return btoa(bin).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
3579
|
+
}
|
|
3580
|
+
function randomUserId() {
|
|
3581
|
+
const bytes = new Uint8Array(16);
|
|
3582
|
+
crypto.getRandomValues(bytes);
|
|
3583
|
+
let bin = "";
|
|
3584
|
+
for (const b of bytes) bin += String.fromCharCode(b);
|
|
3585
|
+
return btoa(bin).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
3586
|
+
}
|
|
3587
|
+
var browserPasskeyCeremony = async ({ challenge }) => {
|
|
3588
|
+
const rpId = window.location.hostname;
|
|
3589
|
+
try {
|
|
3590
|
+
const response2 = await browser.startAuthentication({
|
|
3591
|
+
optionsJSON: { challenge, rpId, userVerification: "required" }
|
|
3592
|
+
});
|
|
3593
|
+
return { kind: "login", response: response2 };
|
|
3594
|
+
} catch {
|
|
3595
|
+
}
|
|
3596
|
+
const userId = randomUserId();
|
|
3597
|
+
const response = await browser.startRegistration({
|
|
3598
|
+
optionsJSON: {
|
|
3599
|
+
challenge,
|
|
3600
|
+
rp: { id: rpId, name: rpId },
|
|
3601
|
+
user: { id: userId, name: "Smart Wallet", displayName: "Smart Wallet" },
|
|
3602
|
+
// ES256 (secp256r1) — the curve the on-chain WebAuthn verifier expects.
|
|
3603
|
+
pubKeyCredParams: [{ type: "public-key", alg: -7 }],
|
|
3604
|
+
authenticatorSelection: { residentKey: "required", userVerification: "required" },
|
|
3605
|
+
attestation: "none",
|
|
3606
|
+
timeout: 6e4
|
|
3607
|
+
}
|
|
3608
|
+
});
|
|
3609
|
+
return { kind: "register", response };
|
|
3610
|
+
};
|
|
3611
|
+
var browserPasskeySigner = async ({ credentialId, challenge }) => {
|
|
3612
|
+
const rpId = window.location.hostname;
|
|
3613
|
+
const { response } = await browser.startAuthentication({
|
|
3614
|
+
optionsJSON: {
|
|
3615
|
+
challenge: hexToBase64url(challenge),
|
|
3616
|
+
rpId,
|
|
3617
|
+
allowCredentials: [{ id: credentialId, type: "public-key" }],
|
|
3618
|
+
userVerification: "required"
|
|
3619
|
+
}
|
|
3620
|
+
});
|
|
3621
|
+
return {
|
|
3622
|
+
authenticatorData: response.authenticatorData,
|
|
3623
|
+
clientDataJSON: response.clientDataJSON,
|
|
3624
|
+
signature: response.signature
|
|
3625
|
+
};
|
|
3626
|
+
};
|
|
3563
3627
|
var DEFAULT_APP_CONFIG = {
|
|
3564
3628
|
application: { name: "" },
|
|
3565
3629
|
styles: {}
|
|
@@ -3567,7 +3631,7 @@ var DEFAULT_APP_CONFIG = {
|
|
|
3567
3631
|
function sessionsEqual(a, b) {
|
|
3568
3632
|
if (a === b) return true;
|
|
3569
3633
|
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?.
|
|
3634
|
+
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
3635
|
}
|
|
3572
3636
|
var PollarContext = react.createContext(null);
|
|
3573
3637
|
function PollarProvider({
|
|
@@ -3578,11 +3642,15 @@ function PollarProvider({
|
|
|
3578
3642
|
onStorageDegrade,
|
|
3579
3643
|
children
|
|
3580
3644
|
}) {
|
|
3581
|
-
const [pollarClient] = react.useState(
|
|
3645
|
+
const [pollarClient] = react.useState(
|
|
3646
|
+
() => client instanceof core.PollarClient ? client : new core.PollarClient({ passkey: browserPasskeyCeremony, passkeySign: browserPasskeySigner, ...client })
|
|
3647
|
+
);
|
|
3582
3648
|
const [networkState, setNetworkState] = react.useState(() => pollarClient.getNetworkState());
|
|
3583
3649
|
const [sessionState, setSessionState] = react.useState(null);
|
|
3650
|
+
const [verified, setVerified] = react.useState(false);
|
|
3584
3651
|
const [transaction, setTransaction] = react.useState({ step: "idle" });
|
|
3585
3652
|
const [txHistory, setTxHistory] = react.useState({ step: "idle" });
|
|
3653
|
+
const [sessions, setSessions] = react.useState({ step: "idle" });
|
|
3586
3654
|
const [walletBalance, setWalletBalance] = react.useState({ step: "idle" });
|
|
3587
3655
|
const [resolvedConfig, setResolvedConfig] = react.useState(() => appConfigProp ?? DEFAULT_APP_CONFIG);
|
|
3588
3656
|
react.useEffect(() => {
|
|
@@ -3591,6 +3659,9 @@ function PollarProvider({
|
|
|
3591
3659
|
react.useEffect(() => {
|
|
3592
3660
|
return pollarClient.onTxHistoryStateChange(setTxHistory);
|
|
3593
3661
|
}, [pollarClient]);
|
|
3662
|
+
react.useEffect(() => {
|
|
3663
|
+
return pollarClient.onSessionsStateChange(setSessions);
|
|
3664
|
+
}, [pollarClient]);
|
|
3594
3665
|
react.useEffect(() => {
|
|
3595
3666
|
return pollarClient.onWalletBalanceStateChange(setWalletBalance);
|
|
3596
3667
|
}, [pollarClient]);
|
|
@@ -3607,8 +3678,10 @@ function PollarProvider({
|
|
|
3607
3678
|
return pollarClient.onAuthStateChange((authState) => {
|
|
3608
3679
|
if (authState.step === "authenticated") {
|
|
3609
3680
|
setSessionState((prev) => sessionsEqual(prev, authState.session) ? prev : authState.session);
|
|
3681
|
+
setVerified(authState.verified);
|
|
3610
3682
|
} else if (authState.step === "idle") {
|
|
3611
3683
|
setSessionState(null);
|
|
3684
|
+
setVerified(false);
|
|
3612
3685
|
}
|
|
3613
3686
|
});
|
|
3614
3687
|
}, [pollarClient]);
|
|
@@ -3636,9 +3709,9 @@ function PollarProvider({
|
|
|
3636
3709
|
const [receiveModalOpen, setReceiveModalOpen] = react.useState(false);
|
|
3637
3710
|
const [sessionsModalOpen, setSessionsModalOpen] = react.useState(false);
|
|
3638
3711
|
const [distributionRulesModalOpen, setDistributionRulesModalOpen] = react.useState(false);
|
|
3639
|
-
const walletAddress = sessionState?.wallet?.
|
|
3712
|
+
const walletAddress = sessionState?.wallet?.address || "";
|
|
3640
3713
|
const getClient = react.useCallback(() => pollarClient, [pollarClient]);
|
|
3641
|
-
const refreshWalletBalance = react.useCallback(() => pollarClient.refreshBalance(
|
|
3714
|
+
const refreshWalletBalance = react.useCallback(() => pollarClient.refreshBalance(), [pollarClient, walletAddress]);
|
|
3642
3715
|
const renderWallets = ui?.renderWallets;
|
|
3643
3716
|
const contextValue = react.useMemo(() => {
|
|
3644
3717
|
const styles = resolvedConfig.styles ?? {};
|
|
@@ -3646,6 +3719,7 @@ function PollarProvider({
|
|
|
3646
3719
|
// session
|
|
3647
3720
|
walletAddress,
|
|
3648
3721
|
isAuthenticated: !!walletAddress,
|
|
3722
|
+
verified,
|
|
3649
3723
|
walletType: pollarClient.getWalletType(),
|
|
3650
3724
|
// client
|
|
3651
3725
|
getClient,
|
|
@@ -3673,6 +3747,7 @@ function PollarProvider({
|
|
|
3673
3747
|
openSendModal: () => setSendModalOpen(true),
|
|
3674
3748
|
openReceiveModal: () => setReceiveModalOpen(true),
|
|
3675
3749
|
// sessions
|
|
3750
|
+
sessions,
|
|
3676
3751
|
openSessionsModal: () => setSessionsModalOpen(true),
|
|
3677
3752
|
// distribution
|
|
3678
3753
|
openDistributionRulesModal: () => setDistributionRulesModalOpen(true),
|
|
@@ -3694,10 +3769,12 @@ function PollarProvider({
|
|
|
3694
3769
|
};
|
|
3695
3770
|
}, [
|
|
3696
3771
|
walletAddress,
|
|
3772
|
+
verified,
|
|
3697
3773
|
pollarClient,
|
|
3698
3774
|
getClient,
|
|
3699
3775
|
transaction,
|
|
3700
3776
|
txHistory,
|
|
3777
|
+
sessions,
|
|
3701
3778
|
walletBalance,
|
|
3702
3779
|
refreshWalletBalance,
|
|
3703
3780
|
networkState,
|
|
@@ -3777,6 +3854,10 @@ function WalletButtonTemplate({
|
|
|
3777
3854
|
onTxHistory,
|
|
3778
3855
|
onSend,
|
|
3779
3856
|
onReceive,
|
|
3857
|
+
onSessions,
|
|
3858
|
+
onKyc,
|
|
3859
|
+
onRamp,
|
|
3860
|
+
onDistributionRules,
|
|
3780
3861
|
onLogout,
|
|
3781
3862
|
onLogin
|
|
3782
3863
|
}) {
|
|
@@ -3936,6 +4017,94 @@ function WalletButtonTemplate({
|
|
|
3936
4017
|
"Transaction history"
|
|
3937
4018
|
] }),
|
|
3938
4019
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "wallet-dropdown-divider" }),
|
|
4020
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onRamp, children: [
|
|
4021
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4022
|
+
"svg",
|
|
4023
|
+
{
|
|
4024
|
+
width: "14",
|
|
4025
|
+
height: "14",
|
|
4026
|
+
viewBox: "0 0 24 24",
|
|
4027
|
+
fill: "none",
|
|
4028
|
+
stroke: "currentColor",
|
|
4029
|
+
strokeWidth: "2",
|
|
4030
|
+
strokeLinecap: "round",
|
|
4031
|
+
strokeLinejoin: "round",
|
|
4032
|
+
children: [
|
|
4033
|
+
/* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "17 1 21 5 17 9" }),
|
|
4034
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3 11V9a4 4 0 0 1 4-4h14" }),
|
|
4035
|
+
/* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "7 23 3 19 7 15" }),
|
|
4036
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M21 13v2a4 4 0 0 1-4 4H3" })
|
|
4037
|
+
]
|
|
4038
|
+
}
|
|
4039
|
+
),
|
|
4040
|
+
"Buy / Sell"
|
|
4041
|
+
] }),
|
|
4042
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onKyc, children: [
|
|
4043
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4044
|
+
"svg",
|
|
4045
|
+
{
|
|
4046
|
+
width: "14",
|
|
4047
|
+
height: "14",
|
|
4048
|
+
viewBox: "0 0 24 24",
|
|
4049
|
+
fill: "none",
|
|
4050
|
+
stroke: "currentColor",
|
|
4051
|
+
strokeWidth: "2",
|
|
4052
|
+
strokeLinecap: "round",
|
|
4053
|
+
strokeLinejoin: "round",
|
|
4054
|
+
children: [
|
|
4055
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8z" }),
|
|
4056
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 21v-1a6 6 0 0 1 6-6h2" }),
|
|
4057
|
+
/* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "16 11 18 13 22 9" })
|
|
4058
|
+
]
|
|
4059
|
+
}
|
|
4060
|
+
),
|
|
4061
|
+
"Identity verification"
|
|
4062
|
+
] }),
|
|
4063
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onDistributionRules, children: [
|
|
4064
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4065
|
+
"svg",
|
|
4066
|
+
{
|
|
4067
|
+
width: "14",
|
|
4068
|
+
height: "14",
|
|
4069
|
+
viewBox: "0 0 24 24",
|
|
4070
|
+
fill: "none",
|
|
4071
|
+
stroke: "currentColor",
|
|
4072
|
+
strokeWidth: "2",
|
|
4073
|
+
strokeLinecap: "round",
|
|
4074
|
+
strokeLinejoin: "round",
|
|
4075
|
+
children: [
|
|
4076
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "18", cy: "5", r: "3" }),
|
|
4077
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "6", cy: "12", r: "3" }),
|
|
4078
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "18", cy: "19", r: "3" }),
|
|
4079
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "8.59", y1: "13.51", x2: "15.42", y2: "17.49" }),
|
|
4080
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "15.41", y1: "6.51", x2: "8.59", y2: "10.49" })
|
|
4081
|
+
]
|
|
4082
|
+
}
|
|
4083
|
+
),
|
|
4084
|
+
"Distribution rules"
|
|
4085
|
+
] }),
|
|
4086
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onSessions, children: [
|
|
4087
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4088
|
+
"svg",
|
|
4089
|
+
{
|
|
4090
|
+
width: "14",
|
|
4091
|
+
height: "14",
|
|
4092
|
+
viewBox: "0 0 24 24",
|
|
4093
|
+
fill: "none",
|
|
4094
|
+
stroke: "currentColor",
|
|
4095
|
+
strokeWidth: "2",
|
|
4096
|
+
strokeLinecap: "round",
|
|
4097
|
+
strokeLinejoin: "round",
|
|
4098
|
+
children: [
|
|
4099
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "2", y: "3", width: "20", height: "14", rx: "2", ry: "2" }),
|
|
4100
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "8", y1: "21", x2: "16", y2: "21" }),
|
|
4101
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "12", y1: "17", x2: "12", y2: "21" })
|
|
4102
|
+
]
|
|
4103
|
+
}
|
|
4104
|
+
),
|
|
4105
|
+
"Active sessions"
|
|
4106
|
+
] }),
|
|
4107
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "wallet-dropdown-divider" }),
|
|
3939
4108
|
/* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item danger", onClick: onLogout, children: [
|
|
3940
4109
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3941
4110
|
"svg",
|
|
@@ -3970,6 +4139,10 @@ function WalletButton() {
|
|
|
3970
4139
|
openWalletBalanceModal,
|
|
3971
4140
|
openSendModal,
|
|
3972
4141
|
openReceiveModal,
|
|
4142
|
+
openSessionsModal,
|
|
4143
|
+
openKycModal,
|
|
4144
|
+
openRampModal,
|
|
4145
|
+
openDistributionRulesModal,
|
|
3973
4146
|
tx: transaction,
|
|
3974
4147
|
walletType
|
|
3975
4148
|
} = usePollar();
|
|
@@ -4028,6 +4201,22 @@ function WalletButton() {
|
|
|
4028
4201
|
setOpen(false);
|
|
4029
4202
|
openReceiveModal();
|
|
4030
4203
|
}
|
|
4204
|
+
function handleSessions() {
|
|
4205
|
+
setOpen(false);
|
|
4206
|
+
openSessionsModal();
|
|
4207
|
+
}
|
|
4208
|
+
function handleKyc() {
|
|
4209
|
+
setOpen(false);
|
|
4210
|
+
openKycModal();
|
|
4211
|
+
}
|
|
4212
|
+
function handleRamp() {
|
|
4213
|
+
setOpen(false);
|
|
4214
|
+
openRampModal();
|
|
4215
|
+
}
|
|
4216
|
+
function handleDistributionRules() {
|
|
4217
|
+
setOpen(false);
|
|
4218
|
+
openDistributionRulesModal();
|
|
4219
|
+
}
|
|
4031
4220
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4032
4221
|
WalletButtonTemplate,
|
|
4033
4222
|
{
|
|
@@ -4047,6 +4236,10 @@ function WalletButton() {
|
|
|
4047
4236
|
onTxHistory: handleTxHistory,
|
|
4048
4237
|
onSend: handleSend,
|
|
4049
4238
|
onReceive: handleReceive,
|
|
4239
|
+
onSessions: handleSessions,
|
|
4240
|
+
onKyc: handleKyc,
|
|
4241
|
+
onRamp: handleRamp,
|
|
4242
|
+
onDistributionRules: handleDistributionRules,
|
|
4050
4243
|
onLogout: handleLogout,
|
|
4051
4244
|
onLogin: openLoginModal
|
|
4052
4245
|
}
|
|
@@ -4075,6 +4268,7 @@ exports.TxStatusView = TxStatusView;
|
|
|
4075
4268
|
exports.WalletBalanceModal = WalletBalanceModal;
|
|
4076
4269
|
exports.WalletBalanceModalTemplate = WalletBalanceModalTemplate;
|
|
4077
4270
|
exports.WalletButton = WalletButton;
|
|
4271
|
+
exports.WalletButtonTemplate = WalletButtonTemplate;
|
|
4078
4272
|
exports.createPollarAdapterHook = createPollarAdapterHook;
|
|
4079
4273
|
exports.usePollar = usePollar;
|
|
4080
4274
|
//# sourceMappingURL=index.js.map
|