@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.d.cts CHANGED
@@ -119,7 +119,7 @@ interface AuthState {
119
119
  user: User | null;
120
120
  accessToken: string | null;
121
121
  }
122
- type ModalStep = 'method-select' | 'email-login' | 'email-register' | 'email-otp' | 'wallet-connect' | 'oauth' | 'forgot-password' | 'verify-2fa' | 'success' | 'error';
122
+ type ModalStep = 'method-select' | 'email-login' | 'email-register' | 'email-otp' | 'wallet-connect' | 'oauth' | 'forgot-password' | 'verify-2fa' | 'matrica-migration' | 'success' | 'error';
123
123
  interface ModalState {
124
124
  isOpen: boolean;
125
125
  step: ModalStep;
@@ -278,6 +278,28 @@ declare function createApiClient(apiUrl: string): {
278
278
  challengeToken?: string;
279
279
  userId?: string;
280
280
  }>;
281
+ getMatricaMigration(token: string): Promise<{
282
+ matricaUsername: string | null;
283
+ matricaDisplayName: string | null;
284
+ conflicts: {
285
+ wallets: {
286
+ address: string;
287
+ }[];
288
+ socials: {
289
+ provider: "twitter" | "discord" | "telegram";
290
+ externalName: string;
291
+ }[];
292
+ email: {
293
+ email: string;
294
+ } | null;
295
+ };
296
+ }>;
297
+ resolveMatricaMigration(token: string, migrate: boolean): Promise<{
298
+ code?: string;
299
+ accessToken?: string;
300
+ requires2FA?: boolean;
301
+ challengeToken?: string;
302
+ }>;
281
303
  createLinkIntent(token: string): Promise<{
282
304
  intentToken: string;
283
305
  }>;
@@ -506,6 +528,24 @@ interface ForgeConnectContextValue {
506
528
  challengeToken: string | null;
507
529
  verify2FA: (code: string) => Promise<void>;
508
530
  verifyRecoveryCode: (code: string) => Promise<void>;
531
+ matricaMigration: {
532
+ token: string;
533
+ matricaUsername: string | null;
534
+ matricaDisplayName: string | null;
535
+ conflicts: {
536
+ wallets: {
537
+ address: string;
538
+ }[];
539
+ socials: {
540
+ provider: 'twitter' | 'discord' | 'telegram';
541
+ externalName: string;
542
+ }[];
543
+ email: {
544
+ email: string;
545
+ } | null;
546
+ };
547
+ } | null;
548
+ resolveMatricaMigration: (migrate: boolean) => Promise<void>;
509
549
  openModal: () => void;
510
550
  closeModal: () => void;
511
551
  setModalStep: (step: ModalState['step']) => void;
package/dist/index.d.ts CHANGED
@@ -119,7 +119,7 @@ interface AuthState {
119
119
  user: User | null;
120
120
  accessToken: string | null;
121
121
  }
122
- type ModalStep = 'method-select' | 'email-login' | 'email-register' | 'email-otp' | 'wallet-connect' | 'oauth' | 'forgot-password' | 'verify-2fa' | 'success' | 'error';
122
+ type ModalStep = 'method-select' | 'email-login' | 'email-register' | 'email-otp' | 'wallet-connect' | 'oauth' | 'forgot-password' | 'verify-2fa' | 'matrica-migration' | 'success' | 'error';
123
123
  interface ModalState {
124
124
  isOpen: boolean;
125
125
  step: ModalStep;
@@ -278,6 +278,28 @@ declare function createApiClient(apiUrl: string): {
278
278
  challengeToken?: string;
279
279
  userId?: string;
280
280
  }>;
281
+ getMatricaMigration(token: string): Promise<{
282
+ matricaUsername: string | null;
283
+ matricaDisplayName: string | null;
284
+ conflicts: {
285
+ wallets: {
286
+ address: string;
287
+ }[];
288
+ socials: {
289
+ provider: "twitter" | "discord" | "telegram";
290
+ externalName: string;
291
+ }[];
292
+ email: {
293
+ email: string;
294
+ } | null;
295
+ };
296
+ }>;
297
+ resolveMatricaMigration(token: string, migrate: boolean): Promise<{
298
+ code?: string;
299
+ accessToken?: string;
300
+ requires2FA?: boolean;
301
+ challengeToken?: string;
302
+ }>;
281
303
  createLinkIntent(token: string): Promise<{
282
304
  intentToken: string;
283
305
  }>;
@@ -506,6 +528,24 @@ interface ForgeConnectContextValue {
506
528
  challengeToken: string | null;
507
529
  verify2FA: (code: string) => Promise<void>;
508
530
  verifyRecoveryCode: (code: string) => Promise<void>;
531
+ matricaMigration: {
532
+ token: string;
533
+ matricaUsername: string | null;
534
+ matricaDisplayName: string | null;
535
+ conflicts: {
536
+ wallets: {
537
+ address: string;
538
+ }[];
539
+ socials: {
540
+ provider: 'twitter' | 'discord' | 'telegram';
541
+ externalName: string;
542
+ }[];
543
+ email: {
544
+ email: string;
545
+ } | null;
546
+ };
547
+ } | null;
548
+ resolveMatricaMigration: (migrate: boolean) => Promise<void>;
509
549
  openModal: () => void;
510
550
  closeModal: () => void;
511
551
  setModalStep: (step: ModalState['step']) => void;
package/dist/index.js 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__ */ jsx6("span", { style: { position: "relative", display: "inline-flex" }, children: /* @__PURE__ */ jsx6(SvgIcon, { svg: info.icon, className: "fc-wallet-icon" }) }),
938
+ /* @__PURE__ */ jsx6(SvgIcon, { svg: info.icon, className: "fc-oauth-icon" }),
930
939
  /* @__PURE__ */ jsx6("span", { className: "fc-wallet-name", children: info.label }),
931
940
  /* @__PURE__ */ jsx6("span", { className: "fc-badge-preferred", children: "Brings wallets" })
932
941
  ]
@@ -1434,6 +1443,8 @@ function LoginModal() {
1434
1443
  return /* @__PURE__ */ jsx9(ForgotPasswordForm, {});
1435
1444
  case "verify-2fa":
1436
1445
  return /* @__PURE__ */ jsx9(Verify2FAForm, {});
1446
+ case "matrica-migration":
1447
+ return /* @__PURE__ */ jsx9(MatricaMigrationView, {});
1437
1448
  case "oauth":
1438
1449
  return /* @__PURE__ */ jsx9(OAuthLoadingView, {});
1439
1450
  case "success":
@@ -1460,7 +1471,7 @@ function LoginModal() {
1460
1471
  "--fc-accent": config.appearance?.accentColor ?? "#8b5cf6"
1461
1472
  },
1462
1473
  "data-theme": config.appearance?.theme ?? "light",
1463
- children: modal.step === "success" || modal.step === "oauth" ? renderStep() : /* @__PURE__ */ jsxs8(Fragment2, { children: [
1474
+ children: modal.step === "success" || modal.step === "oauth" || modal.step === "matrica-migration" ? renderStep() : /* @__PURE__ */ jsxs8(Fragment2, { children: [
1464
1475
  renderLogo(),
1465
1476
  /* @__PURE__ */ jsx9("h2", { className: "fc-modal-title", children: config.appearance?.title ?? "Log in or sign up" }),
1466
1477
  renderStep(),
@@ -1470,7 +1481,8 @@ function LoginModal() {
1470
1481
  config.appearance.termsUrl && /* @__PURE__ */ jsx9("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__ */ jsx9("a", { href: config.appearance.privacyUrl, target: "_blank", rel: "noopener noreferrer", className: "fc-legal-link", children: "Privacy Policy" })
1473
- ] })
1484
+ ] }),
1485
+ /* @__PURE__ */ jsx9(NomuPill, {})
1474
1486
  ] })
1475
1487
  }
1476
1488
  ) });
@@ -1587,6 +1599,107 @@ function OAuthLoadingView() {
1587
1599
  /* @__PURE__ */ jsx9("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__ */ jsx9("div", { className: "fc-nomu-wrap", children: /* @__PURE__ */ jsxs8(
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__ */ jsx9("span", { children: "Powered by" }),
1613
+ /* @__PURE__ */ jsx9(SvgIcon, { svg: NOMU_LOGO, className: "fc-nomu-logo" })
1614
+ ]
1615
+ }
1616
+ ) });
1617
+ }
1618
+ var MigrationIcons = {
1619
+ wallet: /* @__PURE__ */ jsxs8("svg", { width: "16", height: "16", viewBox: "0 0 20 20", fill: "none", children: [
1620
+ /* @__PURE__ */ jsx9("rect", { x: "2", y: "5", width: "16", height: "11", rx: "2", stroke: "currentColor", strokeWidth: "1.6" }),
1621
+ /* @__PURE__ */ jsx9("rect", { x: "13", y: "9", width: "5", height: "3", rx: "1", stroke: "currentColor", strokeWidth: "1.6" })
1622
+ ] }),
1623
+ email: /* @__PURE__ */ jsxs8("svg", { width: "16", height: "16", viewBox: "0 0 20 20", fill: "none", children: [
1624
+ /* @__PURE__ */ jsx9("rect", { x: "2", y: "4", width: "16", height: "12", rx: "2", stroke: "currentColor", strokeWidth: "1.6" }),
1625
+ /* @__PURE__ */ jsx9("path", { d: "M2 6l8 5 8-5", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" })
1626
+ ] }),
1627
+ twitter: /* @__PURE__ */ jsx9("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx9("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__ */ jsx9("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx9("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__ */ jsx9("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx9("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] = useState6(null);
1634
+ const [error, setError] = useState6("");
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__ */ jsxs8("div", { className: "fc-mig", children: [
1650
+ /* @__PURE__ */ jsxs8("div", { className: "fc-mig-hero", children: [
1651
+ /* @__PURE__ */ jsx9("h2", { className: "fc-modal-title", style: { margin: 0 }, children: "Account already linked" }),
1652
+ /* @__PURE__ */ jsxs8("p", { className: "fc-mig-sub", children: [
1653
+ "Move ",
1654
+ total,
1655
+ " ",
1656
+ total > 1 ? "accounts" : "account",
1657
+ " to Matrica?"
1658
+ ] })
1659
+ ] }),
1660
+ /* @__PURE__ */ jsxs8("ul", { className: "fc-mig-list", children: [
1661
+ conflicts.wallets.map((w) => /* @__PURE__ */ jsxs8("li", { className: "fc-mig-item", children: [
1662
+ /* @__PURE__ */ jsx9("span", { className: "fc-mig-ic", children: MigrationIcons.wallet }),
1663
+ /* @__PURE__ */ jsx9("span", { className: "fc-mig-label", children: "Wallet" }),
1664
+ /* @__PURE__ */ jsx9("span", { className: "fc-mig-value", children: /* @__PURE__ */ jsx9("code", { children: truncate2(w.address) }) })
1665
+ ] }, `w-${w.address}`)),
1666
+ conflicts.socials.map((s) => /* @__PURE__ */ jsxs8("li", { className: "fc-mig-item", children: [
1667
+ /* @__PURE__ */ jsx9("span", { className: "fc-mig-ic", children: MigrationIcons[s.provider] }),
1668
+ /* @__PURE__ */ jsx9("span", { className: "fc-mig-label", style: { textTransform: "capitalize" }, children: s.provider === "twitter" ? "X" : s.provider }),
1669
+ /* @__PURE__ */ jsxs8("span", { className: "fc-mig-value", children: [
1670
+ "@",
1671
+ s.externalName
1672
+ ] })
1673
+ ] }, `s-${s.provider}-${s.externalName}`)),
1674
+ conflicts.email && /* @__PURE__ */ jsxs8("li", { className: "fc-mig-item", children: [
1675
+ /* @__PURE__ */ jsx9("span", { className: "fc-mig-ic", children: MigrationIcons.email }),
1676
+ /* @__PURE__ */ jsx9("span", { className: "fc-mig-label", children: "Email" }),
1677
+ /* @__PURE__ */ jsx9("span", { className: "fc-mig-value", children: conflicts.email.email })
1678
+ ] })
1679
+ ] }),
1680
+ error && /* @__PURE__ */ jsx9("p", { className: "fc-error", children: error }),
1681
+ /* @__PURE__ */ jsx9(
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__ */ jsx9(
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__ */ jsxs8("div", { className: "fc-success", children: [
1592
1705
  /* @__PURE__ */ jsx9("div", { className: "fc-success-icon", children: /* @__PURE__ */ jsxs8("svg", { viewBox: "0 0 52 52", className: "fc-success-check", children: [
@@ -3101,7 +3214,7 @@ function LoginsTab({ onLink, refreshKey }) {
3101
3214
  /* @__PURE__ */ jsx15("p", { className: "fc-account-section-desc", children: "Ways you can sign in to your account." }),
3102
3215
  authMethods?.map((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__ */ jsxs14("div", { className: "fc-account-item", children: [
3106
3219
  display.iconHtml && /* @__PURE__ */ jsx15(SvgIcon, { svg: display.iconHtml, className: "fc-account-item-icon" }),
3107
3220
  /* @__PURE__ */ jsxs14("div", { className: "fc-account-item-info", children: [
@@ -3819,6 +3932,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
3819
3932
  const [accountModal, setAccountModal] = useState16({ isOpen: false });
3820
3933
  const [linkModal, setLinkModal] = useState16({ isOpen: false });
3821
3934
  const [challengeToken, setChallengeToken] = useState16(null);
3935
+ const [matricaMigration, setMatricaMigration] = useState16(null);
3822
3936
  const apiRef = useRef9(createApiClient(config.apiUrl));
3823
3937
  const refreshTimerRef = useRef9(null);
3824
3938
  const api = apiRef.current;
@@ -3863,6 +3977,21 @@ 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 {
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 {
@@ -3917,20 +4046,45 @@ 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 {
4053
+ }
4054
+ try {
4055
+ const preview = await api.getMatricaMigration(token);
4056
+ setMatricaMigration({ token, ...preview });
4057
+ setModal({ isOpen: true, step: "matrica-migration" });
4058
+ } catch {
4059
+ setModal({ isOpen: true, step: "error" });
4060
+ }
4061
+ };
3920
4062
  const handleMessage = (event) => {
3921
4063
  if (event.origin !== window.location.origin) return;
3922
- if (event.data?.type !== "fc_oauth_code") return;
3923
- const code = event.data.code;
3924
- if (!code) return;
3925
- void handleCode(code);
4064
+ if (event.data?.type === "fc_oauth_code") {
4065
+ const code = event.data.code;
4066
+ if (code) void handleCode(code);
4067
+ return;
4068
+ }
4069
+ if (event.data?.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 !== "fc_oauth_code_pending" || !event.newValue) return;
3929
- void handleCode(event.newValue);
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);
4086
+ const pendingMigration = localStorage.getItem("fc_matrica_migration_pending");
4087
+ if (pendingMigration) void handleMigrationToken(pendingMigration);
3934
4088
  } catch {
3935
4089
  }
3936
4090
  window.addEventListener("message", handleMessage);
@@ -4150,6 +4304,28 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
4150
4304
  setLinkModal({ isOpen: false });
4151
4305
  }, []);
4152
4306
  const getAccessToken = useCallback9(() => auth.accessToken, [auth.accessToken]);
4307
+ const resolveMatricaMigration = useCallback9(async (migrate) => {
4308
+ if (!matricaMigration) return;
4309
+ const res = await api.resolveMatricaMigration(matricaMigration.token, migrate);
4310
+ setMatricaMigration(null);
4311
+ let accessToken = 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 = 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 = useMemo3(() => ({
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,