@forge-connect/react 1.0.11 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +203 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -1
- package/dist/index.d.ts +41 -1
- package/dist/index.js +190 -10
- package/dist/index.js.map +1 -1
- package/dist/styles.css +162 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -154,6 +154,15 @@ function buildApiClient(base) {
|
|
|
154
154
|
body: { code }
|
|
155
155
|
});
|
|
156
156
|
},
|
|
157
|
+
getMatricaMigration(token) {
|
|
158
|
+
return request(`/auth/oauth/matrica/migration/${encodeURIComponent(token)}`);
|
|
159
|
+
},
|
|
160
|
+
resolveMatricaMigration(token, migrate) {
|
|
161
|
+
return request(`/auth/oauth/matrica/migration/${encodeURIComponent(token)}/resolve`, {
|
|
162
|
+
method: "POST",
|
|
163
|
+
body: { migrate }
|
|
164
|
+
});
|
|
165
|
+
},
|
|
157
166
|
createLinkIntent(token) {
|
|
158
167
|
return request("/auth/oauth/link-intent", {
|
|
159
168
|
method: "POST",
|
|
@@ -926,7 +935,7 @@ function MatricaWalletEntry() {
|
|
|
926
935
|
className: "fc-btn fc-btn-wallet",
|
|
927
936
|
onClick: () => loginWithOAuth("matrica"),
|
|
928
937
|
children: [
|
|
929
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
938
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SvgIcon, { svg: info.icon, className: "fc-oauth-icon" }),
|
|
930
939
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-wallet-name", children: info.label }),
|
|
931
940
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-badge-preferred", children: "Brings wallets" })
|
|
932
941
|
]
|
|
@@ -1434,6 +1443,8 @@ function LoginModal() {
|
|
|
1434
1443
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ForgotPasswordForm, {});
|
|
1435
1444
|
case "verify-2fa":
|
|
1436
1445
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Verify2FAForm, {});
|
|
1446
|
+
case "matrica-migration":
|
|
1447
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MatricaMigrationView, {});
|
|
1437
1448
|
case "oauth":
|
|
1438
1449
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, OAuthLoadingView, {});
|
|
1439
1450
|
case "success":
|
|
@@ -1460,7 +1471,7 @@ function LoginModal() {
|
|
|
1460
1471
|
"--fc-accent": _nullishCoalesce(_optionalChain([config, 'access', _33 => _33.appearance, 'optionalAccess', _34 => _34.accentColor]), () => ( "#8b5cf6"))
|
|
1461
1472
|
},
|
|
1462
1473
|
"data-theme": _nullishCoalesce(_optionalChain([config, 'access', _35 => _35.appearance, 'optionalAccess', _36 => _36.theme]), () => ( "light")),
|
|
1463
|
-
children: modal.step === "success" || modal.step === "oauth" ? renderStep() : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1474
|
+
children: modal.step === "success" || modal.step === "oauth" || modal.step === "matrica-migration" ? renderStep() : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1464
1475
|
renderLogo(),
|
|
1465
1476
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "fc-modal-title", children: _nullishCoalesce(_optionalChain([config, 'access', _37 => _37.appearance, 'optionalAccess', _38 => _38.title]), () => ( "Log in or sign up")) }),
|
|
1466
1477
|
renderStep(),
|
|
@@ -1470,7 +1481,8 @@ function LoginModal() {
|
|
|
1470
1481
|
config.appearance.termsUrl && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "a", { href: config.appearance.termsUrl, target: "_blank", rel: "noopener noreferrer", className: "fc-legal-link", children: "Terms" }),
|
|
1471
1482
|
config.appearance.termsUrl && config.appearance.privacyUrl && " and ",
|
|
1472
1483
|
config.appearance.privacyUrl && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "a", { href: config.appearance.privacyUrl, target: "_blank", rel: "noopener noreferrer", className: "fc-legal-link", children: "Privacy Policy" })
|
|
1473
|
-
] })
|
|
1484
|
+
] }),
|
|
1485
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, NomuPill, {})
|
|
1474
1486
|
] })
|
|
1475
1487
|
}
|
|
1476
1488
|
) });
|
|
@@ -1587,6 +1599,107 @@ function OAuthLoadingView() {
|
|
|
1587
1599
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "fc-btn fc-btn-secondary", style: { marginTop: "16px" }, onClick: () => setModalStep("method-select"), children: "Cancel" })
|
|
1588
1600
|
] });
|
|
1589
1601
|
}
|
|
1602
|
+
var NOMU_LOGO = '<svg viewBox="0 0 466 115" fill="currentColor" xmlns="http://www.w3.org/2000/svg" aria-label="Nomu"><path d="M86.1037 1.64399C89.2226 2.96692 92.9067 6.05804 94.8954 8.90299C101.195 17.9195 103.263 31.5362 105.652 42.3487C108.921 57.1343 113.078 73.2835 111.843 88.981C111.25 96.5118 107.934 104.178 100.485 106.907C78.5857 114.928 68.4753 94.3605 55.5778 81.0755C54.0151 79.4657 49.9264 75.4498 48.017 74.7242C45.1699 73.6431 46.4243 77.2266 46.9038 78.6202C48.9075 84.4342 52.7842 89.1608 55.1111 94.4333C58.2322 101.506 56.3335 109.491 48.9353 112.563C38.6837 116.818 24.7051 108.932 18.1076 100.994C9.79754 90.9975 3.49328 72.2174 1.14497 59.3049C-1.5908 44.2668 -0.458383 24.9194 16.2003 18.5938C32.7091 12.3216 46.9723 35.7212 56.8964 45.2451C58.5169 46.8013 61.9677 50.9392 63.3912 46.949C64.6285 43.4833 63.6652 36.0102 63.4983 32.0543C62.9845 19.8418 61.3918 -1.3144 79.4334 0.0641835C81.3279 0.209749 84.3483 0.899043 86.1015 1.64399H86.1037Z"/><path d="M198.265 10.0303C208.463 15.8037 214.843 26.2244 217.82 37.2467C220.237 46.1968 221.048 56.7482 219.807 66.1799C216.628 90.3223 200.149 109.849 174.493 110.988C157.695 111.733 139.746 105.682 131.472 90.1896C118.984 66.8071 137.597 43.8678 152.329 27.1128C164.501 13.2691 178.368 -1.23604 198.265 10.0303ZM175.364 41.9176C169.771 38.1072 164.25 44.1996 162.46 49.0803C159.339 57.5916 160.988 72.0346 172.766 71.1591C180.16 70.609 181.427 61.1108 181.02 55.2047C180.752 51.3451 178.7 44.1867 175.364 41.9155V41.9176Z"/><path d="M324.975 3.83292C329.706 5.77236 335.978 13.6051 338.509 17.8479C348.347 34.3438 351.002 53.6547 350.321 73.0085C349.884 85.4008 348.086 102.122 337.415 109.993C321.938 121.407 304.25 107.993 308.199 89.9711C308.681 87.7705 309.725 85.6213 310.52 83.5555C311.913 79.9293 311.83 74.2415 310.92 70.2556C310.903 70.1807 310.614 69.4079 310.483 68.9476C309.62 65.8737 307.548 61.6908 303.712 63.5468C302.409 64.1783 300.839 66.2162 299.022 67.096C292.491 70.2577 283.616 65.5697 280.37 59.4559C279.444 57.707 277.958 52.7728 276.322 51.9444C274.342 50.9425 273.617 52.8948 273.09 54.4382C271.587 58.8437 271.701 66.5394 273.096 71.2232C273.957 74.1088 275.809 76.866 276.92 79.6103C281.115 89.9733 285.647 107.621 270.934 111.791C262.391 114.212 256.003 109.961 250.756 103.888C231.165 81.2072 230.598 47.9049 244.878 21.7289C250.014 12.3142 256.371 6.06777 268.012 6.30967C275.396 6.4638 279.829 10.469 283.241 16.5442C285.532 20.62 287.7 25.1582 290.905 28.7995C293.204 31.4111 296.462 34.0398 299.778 31.2077C303.727 27.8362 305.846 18.0876 308.505 13.2219C311.802 7.18948 317.203 0.649749 324.973 3.83292H324.975Z"/><path d="M452.977 13.4681C459.921 19.2693 464.095 29.0907 465.288 37.8695C468.466 61.282 454.854 98.4611 432.55 109.468C421.31 115.015 406.192 112.904 394.569 109.445C375.919 103.894 364.978 87.4109 363.803 68.2841C362.775 51.5612 371.925 30.2787 381.817 17.15C388.977 7.64763 404.21 11.5072 408.836 21.3243C411.705 27.4124 409.059 30.8824 406.488 36.0436C430.727 62.0334 432.463 57.1377 431.208 47.5453C429.772 36.5723 421.213 13.8256 437.17 9.58065C442.973 8.03724 448.492 9.72193 452.977 13.4681Z"/></svg>';
|
|
1603
|
+
function NomuPill() {
|
|
1604
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "fc-nomu-wrap", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1605
|
+
"a",
|
|
1606
|
+
{
|
|
1607
|
+
href: "https://www.nomu.dev/",
|
|
1608
|
+
target: "_blank",
|
|
1609
|
+
rel: "noopener noreferrer",
|
|
1610
|
+
className: "fc-nomu-pill",
|
|
1611
|
+
children: [
|
|
1612
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Powered by" }),
|
|
1613
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SvgIcon, { svg: NOMU_LOGO, className: "fc-nomu-logo" })
|
|
1614
|
+
]
|
|
1615
|
+
}
|
|
1616
|
+
) });
|
|
1617
|
+
}
|
|
1618
|
+
var MigrationIcons = {
|
|
1619
|
+
wallet: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "svg", { width: "16", height: "16", viewBox: "0 0 20 20", fill: "none", children: [
|
|
1620
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "rect", { x: "2", y: "5", width: "16", height: "11", rx: "2", stroke: "currentColor", strokeWidth: "1.6" }),
|
|
1621
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "rect", { x: "13", y: "9", width: "5", height: "3", rx: "1", stroke: "currentColor", strokeWidth: "1.6" })
|
|
1622
|
+
] }),
|
|
1623
|
+
email: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "svg", { width: "16", height: "16", viewBox: "0 0 20 20", fill: "none", children: [
|
|
1624
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "rect", { x: "2", y: "4", width: "16", height: "12", rx: "2", stroke: "currentColor", strokeWidth: "1.6" }),
|
|
1625
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M2 6l8 5 8-5", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" })
|
|
1626
|
+
] }),
|
|
1627
|
+
twitter: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z" }) }),
|
|
1628
|
+
discord: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M20.317 4.37a19.79 19.79 0 0 0-4.885-1.515.07.07 0 0 0-.073.035c-.21.375-.444.864-.608 1.249a18.27 18.27 0 0 0-5.487 0a12.6 12.6 0 0 0-.617-1.25.07.07 0 0 0-.073-.034A19.74 19.74 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.08.08 0 0 0 .031.057a19.9 19.9 0 0 0 5.993 3.03.08.08 0 0 0 .084-.028a14.1 14.1 0 0 0 1.226-1.994.076.076 0 0 0-.041-.106a13.1 13.1 0 0 1-1.872-.892.077.077 0 0 1-.008-.128a10 10 0 0 0 .372-.292.07.07 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.07.07 0 0 1 .078.01q.181.149.373.292a.077.077 0 0 1-.006.127a12.3 12.3 0 0 1-1.873.893.077.077 0 0 0-.041.107a16 16 0 0 0 1.226 1.993.08.08 0 0 0 .084.028a19.84 19.84 0 0 0 6.002-3.03.08.08 0 0 0 .031-.056c.5-5.177-.838-9.673-3.549-13.66a.06.06 0 0 0-.031-.028M8.02 15.331c-1.182 0-2.157-1.086-2.157-2.419c0-1.332.956-2.418 2.157-2.418c1.21 0 2.176 1.096 2.157 2.418c0 1.333-.956 2.42-2.157 2.42m7.974 0c-1.183 0-2.157-1.086-2.157-2.419c0-1.332.955-2.418 2.157-2.418c1.21 0 2.176 1.096 2.157 2.418c0 1.333-.946 2.42-2.157 2.42" }) }),
|
|
1629
|
+
telegram: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12a12 12 0 0 0 12-12A12 12 0 0 0 12 0zm4.962 7.224c.1-.002.321.023.465.14a.5.5 0 0 1 .171.325c.016.093.036.306.02.472c-.18 1.898-.962 6.502-1.36 8.627c-.168.9-.499 1.201-.82 1.23c-.696.065-1.225-.46-1.9-.902c-1.056-.693-1.653-1.124-2.678-1.8c-1.185-.78-.417-1.21.258-1.91c.177-.184 3.247-2.977 3.307-3.23c.007-.032.014-.15-.056-.212s-.174-.041-.249-.024q-.16.036-5.061 3.345q-.72.495-1.302.48c-.428-.008-1.252-.241-1.865-.44c-.752-.245-1.349-.374-1.297-.789q.04-.324.893-.663q5.247-2.286 6.998-3.014q3.333-1.386 4.025-1.627q.227-.078.378-.08" }) })
|
|
1630
|
+
};
|
|
1631
|
+
function MatricaMigrationView() {
|
|
1632
|
+
const { matricaMigration, resolveMatricaMigration } = useForgeConnect();
|
|
1633
|
+
const [loading, setLoading] = _react.useState.call(void 0, null);
|
|
1634
|
+
const [error, setError] = _react.useState.call(void 0, "");
|
|
1635
|
+
if (!matricaMigration) return null;
|
|
1636
|
+
const { conflicts } = matricaMigration;
|
|
1637
|
+
const total = conflicts.wallets.length + conflicts.socials.length + (conflicts.email ? 1 : 0);
|
|
1638
|
+
const handle = async (migrate) => {
|
|
1639
|
+
setLoading(migrate ? "migrate" : "skip");
|
|
1640
|
+
setError("");
|
|
1641
|
+
try {
|
|
1642
|
+
await resolveMatricaMigration(migrate);
|
|
1643
|
+
} catch (err) {
|
|
1644
|
+
setError(err instanceof Error ? err.message : "Something went wrong.");
|
|
1645
|
+
setLoading(null);
|
|
1646
|
+
}
|
|
1647
|
+
};
|
|
1648
|
+
const truncate2 = (s, n = 6) => s.length > n * 2 + 1 ? `${s.slice(0, n)}\u2026${s.slice(-n)}` : s;
|
|
1649
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-mig", children: [
|
|
1650
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-mig-hero", children: [
|
|
1651
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "fc-modal-title", style: { margin: 0 }, children: "Account already linked" }),
|
|
1652
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "fc-mig-sub", children: [
|
|
1653
|
+
"Move ",
|
|
1654
|
+
total,
|
|
1655
|
+
" ",
|
|
1656
|
+
total > 1 ? "accounts" : "account",
|
|
1657
|
+
" to Matrica?"
|
|
1658
|
+
] })
|
|
1659
|
+
] }),
|
|
1660
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "ul", { className: "fc-mig-list", children: [
|
|
1661
|
+
conflicts.wallets.map((w) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { className: "fc-mig-item", children: [
|
|
1662
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-mig-ic", children: MigrationIcons.wallet }),
|
|
1663
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-mig-label", children: "Wallet" }),
|
|
1664
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-mig-value", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "code", { children: truncate2(w.address) }) })
|
|
1665
|
+
] }, `w-${w.address}`)),
|
|
1666
|
+
conflicts.socials.map((s) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { className: "fc-mig-item", children: [
|
|
1667
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-mig-ic", children: MigrationIcons[s.provider] }),
|
|
1668
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-mig-label", style: { textTransform: "capitalize" }, children: s.provider === "twitter" ? "X" : s.provider }),
|
|
1669
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "fc-mig-value", children: [
|
|
1670
|
+
"@",
|
|
1671
|
+
s.externalName
|
|
1672
|
+
] })
|
|
1673
|
+
] }, `s-${s.provider}-${s.externalName}`)),
|
|
1674
|
+
conflicts.email && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { className: "fc-mig-item", children: [
|
|
1675
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-mig-ic", children: MigrationIcons.email }),
|
|
1676
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-mig-label", children: "Email" }),
|
|
1677
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-mig-value", children: conflicts.email.email })
|
|
1678
|
+
] })
|
|
1679
|
+
] }),
|
|
1680
|
+
error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-error", children: error }),
|
|
1681
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1682
|
+
"button",
|
|
1683
|
+
{
|
|
1684
|
+
type: "button",
|
|
1685
|
+
className: "fc-btn fc-btn-primary",
|
|
1686
|
+
onClick: () => handle(true),
|
|
1687
|
+
disabled: loading !== null,
|
|
1688
|
+
children: loading === "migrate" ? "Moving\u2026" : `Move ${total > 1 ? "them all" : "it"}`
|
|
1689
|
+
}
|
|
1690
|
+
),
|
|
1691
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1692
|
+
"button",
|
|
1693
|
+
{
|
|
1694
|
+
type: "button",
|
|
1695
|
+
className: "fc-mig-skip",
|
|
1696
|
+
onClick: () => handle(false),
|
|
1697
|
+
disabled: loading !== null,
|
|
1698
|
+
children: loading === "skip" ? "Skipping\u2026" : "Not now"
|
|
1699
|
+
}
|
|
1700
|
+
)
|
|
1701
|
+
] });
|
|
1702
|
+
}
|
|
1590
1703
|
function SuccessView() {
|
|
1591
1704
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-success", children: [
|
|
1592
1705
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "fc-success-icon", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "svg", { viewBox: "0 0 52 52", className: "fc-success-check", children: [
|
|
@@ -3101,7 +3214,7 @@ function LoginsTab({ onLink, refreshKey }) {
|
|
|
3101
3214
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-account-section-desc", children: "Ways you can sign in to your account." }),
|
|
3102
3215
|
_optionalChain([authMethods, 'optionalAccess', _90 => _90.map, 'call', _91 => _91((m) => {
|
|
3103
3216
|
const display = getMethodDisplay(m.provider);
|
|
3104
|
-
const detail = m.provider === "email" ? m.providerId : m.provider.endsWith("_wallet") ? truncate(m.providerId) : m.providerId;
|
|
3217
|
+
const detail = m.provider === "email" ? m.providerId : m.provider.endsWith("_wallet") ? truncate(m.providerId) : m.providerUsername ? m.provider === "twitter" || m.provider === "telegram" ? `@${m.providerUsername}` : m.providerUsername : truncate(m.providerId);
|
|
3105
3218
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-account-item", children: [
|
|
3106
3219
|
display.iconHtml && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SvgIcon, { svg: display.iconHtml, className: "fc-account-item-icon" }),
|
|
3107
3220
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-account-item-info", children: [
|
|
@@ -3819,6 +3932,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
3819
3932
|
const [accountModal, setAccountModal] = _react.useState.call(void 0, { isOpen: false });
|
|
3820
3933
|
const [linkModal, setLinkModal] = _react.useState.call(void 0, { isOpen: false });
|
|
3821
3934
|
const [challengeToken, setChallengeToken] = _react.useState.call(void 0, null);
|
|
3935
|
+
const [matricaMigration, setMatricaMigration] = _react.useState.call(void 0, null);
|
|
3822
3936
|
const apiRef = _react.useRef.call(void 0, createApiClient(config.apiUrl));
|
|
3823
3937
|
const refreshTimerRef = _react.useRef.call(void 0, null);
|
|
3824
3938
|
const api = apiRef.current;
|
|
@@ -3863,11 +3977,26 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
3863
3977
|
window.close();
|
|
3864
3978
|
return;
|
|
3865
3979
|
}
|
|
3980
|
+
const migrationToken = params.get("fc_migration");
|
|
3981
|
+
if (migrationToken) {
|
|
3982
|
+
try {
|
|
3983
|
+
localStorage.setItem("fc_matrica_migration_pending", migrationToken);
|
|
3984
|
+
} catch (e9) {
|
|
3985
|
+
}
|
|
3986
|
+
if (window.opener) {
|
|
3987
|
+
window.opener.postMessage(
|
|
3988
|
+
{ type: "fc_matrica_migration", token: migrationToken },
|
|
3989
|
+
window.location.origin
|
|
3990
|
+
);
|
|
3991
|
+
}
|
|
3992
|
+
window.close();
|
|
3993
|
+
return;
|
|
3994
|
+
}
|
|
3866
3995
|
const authCode = params.get("fc_code");
|
|
3867
3996
|
if (authCode) {
|
|
3868
3997
|
try {
|
|
3869
3998
|
localStorage.setItem("fc_oauth_code_pending", authCode);
|
|
3870
|
-
} catch (
|
|
3999
|
+
} catch (e10) {
|
|
3871
4000
|
}
|
|
3872
4001
|
if (window.opener) {
|
|
3873
4002
|
window.opener.postMessage(
|
|
@@ -3884,7 +4013,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
3884
4013
|
if (!exchangePromise) {
|
|
3885
4014
|
try {
|
|
3886
4015
|
localStorage.removeItem("fc_oauth_code_pending");
|
|
3887
|
-
} catch (
|
|
4016
|
+
} catch (e11) {
|
|
3888
4017
|
}
|
|
3889
4018
|
exchangePromise = (async () => {
|
|
3890
4019
|
try {
|
|
@@ -3896,7 +4025,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
3896
4025
|
if (!token) return null;
|
|
3897
4026
|
const user = await api.getMe(token);
|
|
3898
4027
|
return { kind: "authenticated", accessToken: token, user };
|
|
3899
|
-
} catch (
|
|
4028
|
+
} catch (e12) {
|
|
3900
4029
|
return null;
|
|
3901
4030
|
}
|
|
3902
4031
|
})();
|
|
@@ -3917,21 +4046,46 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
3917
4046
|
setModal({ isOpen: false, step: "method-select" });
|
|
3918
4047
|
}, 1500);
|
|
3919
4048
|
};
|
|
4049
|
+
const handleMigrationToken = async (token) => {
|
|
4050
|
+
try {
|
|
4051
|
+
localStorage.removeItem("fc_matrica_migration_pending");
|
|
4052
|
+
} catch (e13) {
|
|
4053
|
+
}
|
|
4054
|
+
try {
|
|
4055
|
+
const preview = await api.getMatricaMigration(token);
|
|
4056
|
+
setMatricaMigration({ token, ...preview });
|
|
4057
|
+
setModal({ isOpen: true, step: "matrica-migration" });
|
|
4058
|
+
} catch (e14) {
|
|
4059
|
+
setModal({ isOpen: true, step: "error" });
|
|
4060
|
+
}
|
|
4061
|
+
};
|
|
3920
4062
|
const handleMessage = (event) => {
|
|
3921
4063
|
if (event.origin !== window.location.origin) return;
|
|
3922
|
-
if (_optionalChain([event, 'access', _121 => _121.data, 'optionalAccess', _122 => _122.type])
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
4064
|
+
if (_optionalChain([event, 'access', _121 => _121.data, 'optionalAccess', _122 => _122.type]) === "fc_oauth_code") {
|
|
4065
|
+
const code = event.data.code;
|
|
4066
|
+
if (code) void handleCode(code);
|
|
4067
|
+
return;
|
|
4068
|
+
}
|
|
4069
|
+
if (_optionalChain([event, 'access', _123 => _123.data, 'optionalAccess', _124 => _124.type]) === "fc_matrica_migration") {
|
|
4070
|
+
const token = event.data.token;
|
|
4071
|
+
if (token) void handleMigrationToken(token);
|
|
4072
|
+
}
|
|
3926
4073
|
};
|
|
3927
4074
|
const handleStorage = (event) => {
|
|
3928
|
-
if (event.key
|
|
3929
|
-
|
|
4075
|
+
if (event.key === "fc_oauth_code_pending" && event.newValue) {
|
|
4076
|
+
void handleCode(event.newValue);
|
|
4077
|
+
return;
|
|
4078
|
+
}
|
|
4079
|
+
if (event.key === "fc_matrica_migration_pending" && event.newValue) {
|
|
4080
|
+
void handleMigrationToken(event.newValue);
|
|
4081
|
+
}
|
|
3930
4082
|
};
|
|
3931
4083
|
try {
|
|
3932
4084
|
const pending = localStorage.getItem("fc_oauth_code_pending");
|
|
3933
4085
|
if (pending) void handleCode(pending);
|
|
3934
|
-
|
|
4086
|
+
const pendingMigration = localStorage.getItem("fc_matrica_migration_pending");
|
|
4087
|
+
if (pendingMigration) void handleMigrationToken(pendingMigration);
|
|
4088
|
+
} catch (e15) {
|
|
3935
4089
|
}
|
|
3936
4090
|
window.addEventListener("message", handleMessage);
|
|
3937
4091
|
window.addEventListener("storage", handleStorage);
|
|
@@ -3956,7 +4110,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
3956
4110
|
setAuth({ status: "authenticated", user, accessToken: token });
|
|
3957
4111
|
scheduleRefresh(token);
|
|
3958
4112
|
setModal({ isOpen: true, step: "success" });
|
|
3959
|
-
_optionalChain([onLogin, 'optionalCall',
|
|
4113
|
+
_optionalChain([onLogin, 'optionalCall', _125 => _125(user)]);
|
|
3960
4114
|
setTimeout(() => {
|
|
3961
4115
|
setModal({ isOpen: false, step: "method-select" });
|
|
3962
4116
|
}, 1500);
|
|
@@ -4056,11 +4210,11 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4056
4210
|
const token = auth.accessToken;
|
|
4057
4211
|
if (refreshTimerRef.current) clearTimeout(refreshTimerRef.current);
|
|
4058
4212
|
setAuth({ status: "unauthenticated", user: null, accessToken: null });
|
|
4059
|
-
_optionalChain([onLogout, 'optionalCall',
|
|
4213
|
+
_optionalChain([onLogout, 'optionalCall', _126 => _126()]);
|
|
4060
4214
|
if (token) {
|
|
4061
4215
|
try {
|
|
4062
4216
|
await api.logout(token);
|
|
4063
|
-
} catch (
|
|
4217
|
+
} catch (e16) {
|
|
4064
4218
|
}
|
|
4065
4219
|
}
|
|
4066
4220
|
}, [auth.accessToken, api, onLogout]);
|
|
@@ -4110,11 +4264,11 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4110
4264
|
const token = auth.accessToken;
|
|
4111
4265
|
if (refreshTimerRef.current) clearTimeout(refreshTimerRef.current);
|
|
4112
4266
|
setAuth({ status: "unauthenticated", user: null, accessToken: null });
|
|
4113
|
-
_optionalChain([onLogout, 'optionalCall',
|
|
4267
|
+
_optionalChain([onLogout, 'optionalCall', _127 => _127()]);
|
|
4114
4268
|
if (token) {
|
|
4115
4269
|
try {
|
|
4116
4270
|
await api.logoutAll(token);
|
|
4117
|
-
} catch (
|
|
4271
|
+
} catch (e17) {
|
|
4118
4272
|
}
|
|
4119
4273
|
}
|
|
4120
4274
|
}, [auth.accessToken, api, onLogout]);
|
|
@@ -4150,6 +4304,28 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4150
4304
|
setLinkModal({ isOpen: false });
|
|
4151
4305
|
}, []);
|
|
4152
4306
|
const getAccessToken = _react.useCallback.call(void 0, () => auth.accessToken, [auth.accessToken]);
|
|
4307
|
+
const resolveMatricaMigration = _react.useCallback.call(void 0, async (migrate) => {
|
|
4308
|
+
if (!matricaMigration) return;
|
|
4309
|
+
const res = await api.resolveMatricaMigration(matricaMigration.token, migrate);
|
|
4310
|
+
setMatricaMigration(null);
|
|
4311
|
+
let accessToken = _nullishCoalesce(res.accessToken, () => ( null));
|
|
4312
|
+
let requires2FA = res.requires2FA;
|
|
4313
|
+
let challenge = res.challengeToken;
|
|
4314
|
+
if (res.code) {
|
|
4315
|
+
const exchange = await api.exchangeOAuthCode(res.code);
|
|
4316
|
+
accessToken = _nullishCoalesce(exchange.accessToken, () => ( null));
|
|
4317
|
+
requires2FA = exchange.requires2FA;
|
|
4318
|
+
challenge = exchange.challengeToken;
|
|
4319
|
+
}
|
|
4320
|
+
if (requires2FA && challenge) {
|
|
4321
|
+
setChallengeToken(challenge);
|
|
4322
|
+
setModal({ isOpen: true, step: "verify-2fa" });
|
|
4323
|
+
return;
|
|
4324
|
+
}
|
|
4325
|
+
if (accessToken) {
|
|
4326
|
+
await handleAuthSuccess(accessToken);
|
|
4327
|
+
}
|
|
4328
|
+
}, [api, matricaMigration, handleAuthSuccess]);
|
|
4153
4329
|
const value = _react.useMemo.call(void 0, () => ({
|
|
4154
4330
|
auth,
|
|
4155
4331
|
modal,
|
|
@@ -4170,6 +4346,8 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4170
4346
|
challengeToken,
|
|
4171
4347
|
verify2FA,
|
|
4172
4348
|
verifyRecoveryCode,
|
|
4349
|
+
matricaMigration,
|
|
4350
|
+
resolveMatricaMigration,
|
|
4173
4351
|
openModal,
|
|
4174
4352
|
closeModal,
|
|
4175
4353
|
setModalStep,
|
|
@@ -4203,6 +4381,8 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4203
4381
|
verifyEmailToken,
|
|
4204
4382
|
verify2FA,
|
|
4205
4383
|
verifyRecoveryCode,
|
|
4384
|
+
matricaMigration,
|
|
4385
|
+
resolveMatricaMigration,
|
|
4206
4386
|
openModal,
|
|
4207
4387
|
closeModal,
|
|
4208
4388
|
setModalStep,
|
|
@@ -4295,11 +4475,11 @@ function useAdmin() {
|
|
|
4295
4475
|
const token = getAccessToken();
|
|
4296
4476
|
if (!token) throw new Error("Please sign in to continue.");
|
|
4297
4477
|
await api.adminUpdateUserStatus(token, id, status);
|
|
4298
|
-
if (_optionalChain([selectedUser, 'optionalAccess',
|
|
4478
|
+
if (_optionalChain([selectedUser, 'optionalAccess', _128 => _128.id]) === id) {
|
|
4299
4479
|
await getUser(id);
|
|
4300
4480
|
}
|
|
4301
4481
|
},
|
|
4302
|
-
[api, getAccessToken, _optionalChain([selectedUser, 'optionalAccess',
|
|
4482
|
+
[api, getAccessToken, _optionalChain([selectedUser, 'optionalAccess', _129 => _129.id]), getUser]
|
|
4303
4483
|
);
|
|
4304
4484
|
const getUserSessions = _react.useCallback.call(void 0,
|
|
4305
4485
|
async (id) => {
|
|
@@ -4416,9 +4596,9 @@ function useRoles() {
|
|
|
4416
4596
|
const token = getAccessToken();
|
|
4417
4597
|
if (!token) throw new Error("Please sign in to continue.");
|
|
4418
4598
|
await api.adminDeleteRole(token, id);
|
|
4419
|
-
if (_optionalChain([selectedRole, 'optionalAccess',
|
|
4599
|
+
if (_optionalChain([selectedRole, 'optionalAccess', _130 => _130.id]) === id) setSelectedRole(null);
|
|
4420
4600
|
},
|
|
4421
|
-
[api, getAccessToken, _optionalChain([selectedRole, 'optionalAccess',
|
|
4601
|
+
[api, getAccessToken, _optionalChain([selectedRole, 'optionalAccess', _131 => _131.id])]
|
|
4422
4602
|
);
|
|
4423
4603
|
const getPermissions = _react.useCallback.call(void 0,
|
|
4424
4604
|
async () => {
|