@forge-connect/react 1.0.9 → 1.0.11
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 +257 -181
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +282 -206
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -16,8 +16,16 @@ var ForgeConnectApiError = class extends Error {
|
|
|
16
16
|
this.code = code;
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
+
var clientCache = /* @__PURE__ */ new Map();
|
|
19
20
|
function createApiClient(apiUrl) {
|
|
20
21
|
const base = apiUrl.replace(/\/+$/, "");
|
|
22
|
+
const cached = clientCache.get(base);
|
|
23
|
+
if (cached) return cached;
|
|
24
|
+
const client = buildApiClient(base);
|
|
25
|
+
clientCache.set(base, client);
|
|
26
|
+
return client;
|
|
27
|
+
}
|
|
28
|
+
function buildApiClient(base) {
|
|
21
29
|
const inflightRequests = /* @__PURE__ */ new Map();
|
|
22
30
|
let inflightRefresh = null;
|
|
23
31
|
async function request(path, options = {}) {
|
|
@@ -486,7 +494,7 @@ function ModalOverlay({ isOpen, onClose, children }) {
|
|
|
486
494
|
|
|
487
495
|
|
|
488
496
|
// src/resolve-config.ts
|
|
489
|
-
var OAUTH_PROVIDERS = /* @__PURE__ */ new Set(["google", "discord", "twitter", "apple", "telegram"]);
|
|
497
|
+
var OAUTH_PROVIDERS = /* @__PURE__ */ new Set(["google", "discord", "twitter", "apple", "telegram", "matrica"]);
|
|
490
498
|
function isOAuthMethod(method) {
|
|
491
499
|
return OAUTH_PROVIDERS.has(method);
|
|
492
500
|
}
|
|
@@ -828,6 +836,103 @@ function EmailOtpForm() {
|
|
|
828
836
|
// src/components/tabs/wallet-connect.tsx
|
|
829
837
|
|
|
830
838
|
|
|
839
|
+
// src/components/svg-icon.tsx
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
function SvgIcon({ svg, className }) {
|
|
843
|
+
const ref = _react.useRef.call(void 0, null);
|
|
844
|
+
_react.useEffect.call(void 0, () => {
|
|
845
|
+
if (!ref.current || !svg) return;
|
|
846
|
+
try {
|
|
847
|
+
const doc = new DOMParser().parseFromString(svg, "text/html");
|
|
848
|
+
const svgEl = doc.body.querySelector("svg");
|
|
849
|
+
if (!svgEl) {
|
|
850
|
+
ref.current.textContent = "";
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
const dangerous = svgEl.querySelectorAll("script,iframe,object,embed,foreignObject");
|
|
854
|
+
dangerous.forEach((el) => el.remove());
|
|
855
|
+
const all = svgEl.querySelectorAll("*");
|
|
856
|
+
all.forEach((el) => {
|
|
857
|
+
for (const attr of Array.from(el.attributes)) {
|
|
858
|
+
if (attr.name.startsWith("on")) {
|
|
859
|
+
el.removeAttribute(attr.name);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
});
|
|
863
|
+
ref.current.textContent = "";
|
|
864
|
+
ref.current.appendChild(svgEl);
|
|
865
|
+
} catch (e5) {
|
|
866
|
+
ref.current.textContent = "";
|
|
867
|
+
}
|
|
868
|
+
}, [svg]);
|
|
869
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { ref, className });
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
// src/components/tabs/oauth-buttons.tsx
|
|
873
|
+
|
|
874
|
+
var PROVIDER_INFO = {
|
|
875
|
+
google: {
|
|
876
|
+
label: "Google",
|
|
877
|
+
icon: '<svg viewBox="0 0 24 24" width="20" height="20"><path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z" fill="#4285F4"/><path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="#34A853"/><path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" fill="#FBBC05"/><path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" fill="#EA4335"/></svg>'
|
|
878
|
+
},
|
|
879
|
+
discord: {
|
|
880
|
+
label: "Discord",
|
|
881
|
+
icon: '<svg viewBox="0 0 24 24" width="20" height="20"><path d="M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128c.126-.094.252-.192.372-.292a.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03z" fill="#5865F2"/></svg>'
|
|
882
|
+
},
|
|
883
|
+
twitter: {
|
|
884
|
+
label: "Twitter",
|
|
885
|
+
icon: '<svg viewBox="0 0 24 24" width="20" height="20"><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" fill="currentColor"/></svg>'
|
|
886
|
+
},
|
|
887
|
+
apple: {
|
|
888
|
+
label: "Apple",
|
|
889
|
+
icon: '<svg viewBox="0 0 24 24" width="20" height="20"><path d="M17.05 20.28c-.98.95-2.05.88-3.08.4-1.09-.5-2.08-.52-3.23 0-1.44.64-2.2.45-3.06-.4C3.79 16.17 4.36 9.02 8.8 8.78c1.27.06 2.15.72 2.91.76.93-.19 1.82-.88 2.83-.8 1.21.1 2.12.58 2.72 1.49-2.46 1.48-1.88 4.73.52 5.64-.42 1.13-.98 2.24-1.73 3.41zM12.03 8.7c-.12-2.35 1.82-4.38 4.04-4.54.29 2.56-2.34 4.68-4.04 4.54z" fill="currentColor"/></svg>'
|
|
890
|
+
},
|
|
891
|
+
telegram: {
|
|
892
|
+
label: "Telegram",
|
|
893
|
+
icon: '<svg viewBox="0 0 24 24" width="20" height="20"><path d="M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.479.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z" fill="#2AABEE"/></svg>'
|
|
894
|
+
},
|
|
895
|
+
matrica: {
|
|
896
|
+
label: "Matrica",
|
|
897
|
+
icon: '<svg viewBox="2 1 26 26" width="20" height="20" xmlns="http://www.w3.org/2000/svg"><rect x="11.457" y="10.6387" width="7.00961" height="7.00962" fill="#4A99BF"/><path d="M12.6266 1.87695V5.08969H5.90903V23.1979H12.6266V26.4106H2.69629V1.87695H12.6266Z" fill="#4A99BF"/><path d="M17.2997 26.4106H27.2299V1.87695H17.2997V5.08969H24.0172V23.1979H17.2997V26.4106Z" fill="#4A99BF"/></svg>'
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
function OAuthButton({ provider }) {
|
|
901
|
+
const { loginWithOAuth } = useForgeConnect();
|
|
902
|
+
const info = PROVIDER_INFO[provider];
|
|
903
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
904
|
+
"button",
|
|
905
|
+
{
|
|
906
|
+
type: "button",
|
|
907
|
+
className: "fc-btn fc-btn-oauth",
|
|
908
|
+
onClick: () => loginWithOAuth(provider),
|
|
909
|
+
children: [
|
|
910
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SvgIcon, { svg: info.icon, className: "fc-oauth-icon" }),
|
|
911
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-btn-name", children: info.label })
|
|
912
|
+
]
|
|
913
|
+
}
|
|
914
|
+
);
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
// src/components/tabs/wallet-connect.tsx
|
|
918
|
+
|
|
919
|
+
function MatricaWalletEntry() {
|
|
920
|
+
const { loginWithOAuth } = useForgeConnect();
|
|
921
|
+
const info = PROVIDER_INFO.matrica;
|
|
922
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
923
|
+
"button",
|
|
924
|
+
{
|
|
925
|
+
type: "button",
|
|
926
|
+
className: "fc-btn fc-btn-wallet",
|
|
927
|
+
onClick: () => loginWithOAuth("matrica"),
|
|
928
|
+
children: [
|
|
929
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { style: { position: "relative", display: "inline-flex" }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SvgIcon, { svg: info.icon, className: "fc-wallet-icon" }) }),
|
|
930
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-wallet-name", children: info.label }),
|
|
931
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-badge-preferred", children: "Brings wallets" })
|
|
932
|
+
]
|
|
933
|
+
}
|
|
934
|
+
);
|
|
935
|
+
}
|
|
831
936
|
var MOBILE_WALLETS = [
|
|
832
937
|
{
|
|
833
938
|
name: "Phantom",
|
|
@@ -893,21 +998,25 @@ function MobileWalletFlow() {
|
|
|
893
998
|
const pageUrl = window.location.href;
|
|
894
999
|
window.location.href = mw.buildUrl(pageUrl);
|
|
895
1000
|
};
|
|
1001
|
+
const showMatrica = methods.includes("matrica");
|
|
896
1002
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-tab", children: [
|
|
897
|
-
/* @__PURE__ */ _jsxruntime.
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
1003
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-wallet-list", children: [
|
|
1004
|
+
showMatrica && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MatricaWalletEntry, {}),
|
|
1005
|
+
walletsToShow.map((mw) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1006
|
+
"button",
|
|
1007
|
+
{
|
|
1008
|
+
type: "button",
|
|
1009
|
+
className: "fc-btn fc-btn-wallet",
|
|
1010
|
+
onClick: () => handleOpen(mw),
|
|
1011
|
+
children: [
|
|
1012
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { style: { position: "relative", display: "inline-flex" }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "img", { src: mw.icon, alt: "", className: "fc-wallet-icon" }) }),
|
|
1013
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-wallet-name", children: mw.name }),
|
|
1014
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-badge-preferred", children: "Open app" })
|
|
1015
|
+
]
|
|
1016
|
+
},
|
|
1017
|
+
mw.name
|
|
1018
|
+
))
|
|
1019
|
+
] }),
|
|
911
1020
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-text", style: { textAlign: "center", fontSize: 12, opacity: 0.6 }, children: "You'll be redirected to the wallet app to sign in." }),
|
|
912
1021
|
showBack && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-switch", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "fc-link", onClick: () => setModalStep("method-select"), children: "Back" }) })
|
|
913
1022
|
] });
|
|
@@ -1017,6 +1126,7 @@ function WalletAdapterFlow() {
|
|
|
1017
1126
|
] })
|
|
1018
1127
|
] }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1019
1128
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-wallet-list", children: [
|
|
1129
|
+
methods.includes("matrica") && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MatricaWalletEntry, {}),
|
|
1020
1130
|
preferredWallets.map((w) => {
|
|
1021
1131
|
const installed = w.readyState === "Installed";
|
|
1022
1132
|
const isConnected = w.adapter.name === connectedWalletName;
|
|
@@ -1085,7 +1195,7 @@ function WalletAdapterFlow() {
|
|
|
1085
1195
|
})
|
|
1086
1196
|
] }),
|
|
1087
1197
|
preferredWallets.length === 0 && otherWallets.length === 0 && mobileExtraWallets.length === 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-text", children: "No wallet found. Please install a Solana wallet (like Phantom) to continue." }),
|
|
1088
|
-
|
|
1198
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { className: "fc-cold-wallet-toggle", children: [
|
|
1089
1199
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1090
1200
|
"input",
|
|
1091
1201
|
{
|
|
@@ -1234,7 +1344,7 @@ function Verify2FAForm() {
|
|
|
1234
1344
|
const inputRef = _react.useRef.call(void 0, null);
|
|
1235
1345
|
const submittingRef = _react.useRef.call(void 0, false);
|
|
1236
1346
|
_react.useEffect.call(void 0, () => {
|
|
1237
|
-
_optionalChain([inputRef, 'access',
|
|
1347
|
+
_optionalChain([inputRef, 'access', _24 => _24.current, 'optionalAccess', _25 => _25.focus, 'call', _26 => _26()]);
|
|
1238
1348
|
}, [useRecovery]);
|
|
1239
1349
|
const submitCode = _react.useCallback.call(void 0, async (codeValue, isRecovery) => {
|
|
1240
1350
|
if (submittingRef.current || !codeValue.trim()) return;
|
|
@@ -1255,7 +1365,7 @@ function Verify2FAForm() {
|
|
|
1255
1365
|
}
|
|
1256
1366
|
}, [verify2FA, verifyRecoveryCode]);
|
|
1257
1367
|
const handleSubmit = async (e) => {
|
|
1258
|
-
_optionalChain([e, 'optionalAccess',
|
|
1368
|
+
_optionalChain([e, 'optionalAccess', _27 => _27.preventDefault, 'call', _28 => _28()]);
|
|
1259
1369
|
await submitCode(code, useRecovery);
|
|
1260
1370
|
};
|
|
1261
1371
|
const handleCodeChange = (value) => {
|
|
@@ -1306,80 +1416,6 @@ function Verify2FAForm() {
|
|
|
1306
1416
|
] });
|
|
1307
1417
|
}
|
|
1308
1418
|
|
|
1309
|
-
// src/components/svg-icon.tsx
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
function SvgIcon({ svg, className }) {
|
|
1313
|
-
const ref = _react.useRef.call(void 0, null);
|
|
1314
|
-
_react.useEffect.call(void 0, () => {
|
|
1315
|
-
if (!ref.current || !svg) return;
|
|
1316
|
-
try {
|
|
1317
|
-
const doc = new DOMParser().parseFromString(svg, "text/html");
|
|
1318
|
-
const svgEl = doc.body.querySelector("svg");
|
|
1319
|
-
if (!svgEl) {
|
|
1320
|
-
ref.current.textContent = "";
|
|
1321
|
-
return;
|
|
1322
|
-
}
|
|
1323
|
-
const dangerous = svgEl.querySelectorAll("script,iframe,object,embed,foreignObject");
|
|
1324
|
-
dangerous.forEach((el) => el.remove());
|
|
1325
|
-
const all = svgEl.querySelectorAll("*");
|
|
1326
|
-
all.forEach((el) => {
|
|
1327
|
-
for (const attr of Array.from(el.attributes)) {
|
|
1328
|
-
if (attr.name.startsWith("on")) {
|
|
1329
|
-
el.removeAttribute(attr.name);
|
|
1330
|
-
}
|
|
1331
|
-
}
|
|
1332
|
-
});
|
|
1333
|
-
ref.current.textContent = "";
|
|
1334
|
-
ref.current.appendChild(svgEl);
|
|
1335
|
-
} catch (e5) {
|
|
1336
|
-
ref.current.textContent = "";
|
|
1337
|
-
}
|
|
1338
|
-
}, [svg]);
|
|
1339
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { ref, className });
|
|
1340
|
-
}
|
|
1341
|
-
|
|
1342
|
-
// src/components/tabs/oauth-buttons.tsx
|
|
1343
|
-
|
|
1344
|
-
var PROVIDER_INFO = {
|
|
1345
|
-
google: {
|
|
1346
|
-
label: "Google",
|
|
1347
|
-
icon: '<svg viewBox="0 0 24 24" width="20" height="20"><path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z" fill="#4285F4"/><path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="#34A853"/><path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" fill="#FBBC05"/><path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" fill="#EA4335"/></svg>'
|
|
1348
|
-
},
|
|
1349
|
-
discord: {
|
|
1350
|
-
label: "Discord",
|
|
1351
|
-
icon: '<svg viewBox="0 0 24 24" width="20" height="20"><path d="M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128c.126-.094.252-.192.372-.292a.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03z" fill="#5865F2"/></svg>'
|
|
1352
|
-
},
|
|
1353
|
-
twitter: {
|
|
1354
|
-
label: "Twitter",
|
|
1355
|
-
icon: '<svg viewBox="0 0 24 24" width="20" height="20"><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" fill="currentColor"/></svg>'
|
|
1356
|
-
},
|
|
1357
|
-
apple: {
|
|
1358
|
-
label: "Apple",
|
|
1359
|
-
icon: '<svg viewBox="0 0 24 24" width="20" height="20"><path d="M17.05 20.28c-.98.95-2.05.88-3.08.4-1.09-.5-2.08-.52-3.23 0-1.44.64-2.2.45-3.06-.4C3.79 16.17 4.36 9.02 8.8 8.78c1.27.06 2.15.72 2.91.76.93-.19 1.82-.88 2.83-.8 1.21.1 2.12.58 2.72 1.49-2.46 1.48-1.88 4.73.52 5.64-.42 1.13-.98 2.24-1.73 3.41zM12.03 8.7c-.12-2.35 1.82-4.38 4.04-4.54.29 2.56-2.34 4.68-4.04 4.54z" fill="currentColor"/></svg>'
|
|
1360
|
-
},
|
|
1361
|
-
telegram: {
|
|
1362
|
-
label: "Telegram",
|
|
1363
|
-
icon: '<svg viewBox="0 0 24 24" width="20" height="20"><path d="M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.479.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z" fill="#2AABEE"/></svg>'
|
|
1364
|
-
}
|
|
1365
|
-
};
|
|
1366
|
-
function OAuthButton({ provider }) {
|
|
1367
|
-
const { loginWithOAuth } = useForgeConnect();
|
|
1368
|
-
const info = PROVIDER_INFO[provider];
|
|
1369
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1370
|
-
"button",
|
|
1371
|
-
{
|
|
1372
|
-
type: "button",
|
|
1373
|
-
className: "fc-btn fc-btn-oauth",
|
|
1374
|
-
onClick: () => loginWithOAuth(provider),
|
|
1375
|
-
children: [
|
|
1376
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SvgIcon, { svg: info.icon, className: "fc-oauth-icon" }),
|
|
1377
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-btn-name", children: info.label })
|
|
1378
|
-
]
|
|
1379
|
-
}
|
|
1380
|
-
);
|
|
1381
|
-
}
|
|
1382
|
-
|
|
1383
1419
|
// src/components/login-modal.tsx
|
|
1384
1420
|
|
|
1385
1421
|
function LoginModal() {
|
|
@@ -1408,10 +1444,10 @@ function LoginModal() {
|
|
|
1408
1444
|
}
|
|
1409
1445
|
};
|
|
1410
1446
|
const renderLogo = () => {
|
|
1411
|
-
if (_optionalChain([config, 'access',
|
|
1447
|
+
if (_optionalChain([config, 'access', _29 => _29.appearance, 'optionalAccess', _30 => _30.logoNode])) {
|
|
1412
1448
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "fc-logo", children: config.appearance.logoNode });
|
|
1413
1449
|
}
|
|
1414
|
-
if (_optionalChain([config, 'access',
|
|
1450
|
+
if (_optionalChain([config, 'access', _31 => _31.appearance, 'optionalAccess', _32 => _32.logo])) {
|
|
1415
1451
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "img", { src: config.appearance.logo, alt: "", className: "fc-logo" });
|
|
1416
1452
|
}
|
|
1417
1453
|
return null;
|
|
@@ -1421,14 +1457,14 @@ function LoginModal() {
|
|
|
1421
1457
|
{
|
|
1422
1458
|
className: "fc-modal-content",
|
|
1423
1459
|
style: {
|
|
1424
|
-
"--fc-accent": _nullishCoalesce(_optionalChain([config, 'access',
|
|
1460
|
+
"--fc-accent": _nullishCoalesce(_optionalChain([config, 'access', _33 => _33.appearance, 'optionalAccess', _34 => _34.accentColor]), () => ( "#8b5cf6"))
|
|
1425
1461
|
},
|
|
1426
|
-
"data-theme": _nullishCoalesce(_optionalChain([config, 'access',
|
|
1462
|
+
"data-theme": _nullishCoalesce(_optionalChain([config, 'access', _35 => _35.appearance, 'optionalAccess', _36 => _36.theme]), () => ( "light")),
|
|
1427
1463
|
children: modal.step === "success" || modal.step === "oauth" ? renderStep() : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1428
1464
|
renderLogo(),
|
|
1429
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "fc-modal-title", children: _nullishCoalesce(_optionalChain([config, 'access',
|
|
1465
|
+
/* @__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")) }),
|
|
1430
1466
|
renderStep(),
|
|
1431
|
-
(_optionalChain([config, 'access',
|
|
1467
|
+
(_optionalChain([config, 'access', _39 => _39.appearance, 'optionalAccess', _40 => _40.termsUrl]) || _optionalChain([config, 'access', _41 => _41.appearance, 'optionalAccess', _42 => _42.privacyUrl])) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "fc-legal", children: [
|
|
1432
1468
|
"By continuing, you agree to our",
|
|
1433
1469
|
" ",
|
|
1434
1470
|
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" }),
|
|
@@ -1645,7 +1681,7 @@ function useUser() {
|
|
|
1645
1681
|
_react.useEffect.call(void 0, () => {
|
|
1646
1682
|
const handleMessage = (event) => {
|
|
1647
1683
|
if (event.origin !== window.location.origin) return;
|
|
1648
|
-
if (_optionalChain([event, 'access',
|
|
1684
|
+
if (_optionalChain([event, 'access', _43 => _43.data, 'optionalAccess', _44 => _44.type]) === "fc_oauth_link_success" && pendingRefreshRef.current) {
|
|
1649
1685
|
pendingRefreshRef.current = false;
|
|
1650
1686
|
fetchAuthMethods().catch(() => {
|
|
1651
1687
|
});
|
|
@@ -1817,7 +1853,7 @@ function useSessions() {
|
|
|
1817
1853
|
|
|
1818
1854
|
function TwoFactorModal({ isOpen, onClose, initialEnabled, onStatusChange }) {
|
|
1819
1855
|
const { api, getAccessToken, config } = useForgeConnect();
|
|
1820
|
-
const theme = _nullishCoalesce(_optionalChain([config, 'access',
|
|
1856
|
+
const theme = _nullishCoalesce(_optionalChain([config, 'access', _45 => _45.appearance, 'optionalAccess', _46 => _46.theme]), () => ( "light"));
|
|
1821
1857
|
const [step, setStep] = _react.useState.call(void 0, initialEnabled ? "manage" : "setup");
|
|
1822
1858
|
const [setupData, setSetupData] = _react.useState.call(void 0, null);
|
|
1823
1859
|
const [code, setCode] = _react.useState.call(void 0, "");
|
|
@@ -1910,7 +1946,7 @@ function TwoFactorModal({ isOpen, onClose, initialEnabled, onStatusChange }) {
|
|
|
1910
1946
|
"div",
|
|
1911
1947
|
{
|
|
1912
1948
|
className: "fc-modal-content",
|
|
1913
|
-
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access',
|
|
1949
|
+
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access', _47 => _47.appearance, 'optionalAccess', _48 => _48.accentColor]), () => ( "#8b5cf6")) },
|
|
1914
1950
|
"data-theme": theme,
|
|
1915
1951
|
children: [
|
|
1916
1952
|
step === "setup" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
@@ -2118,7 +2154,7 @@ function base64URLStringToBuffer(base64URLString) {
|
|
|
2118
2154
|
|
|
2119
2155
|
// ../../node_modules/.pnpm/@simplewebauthn+browser@13.2.2/node_modules/@simplewebauthn/browser/esm/helpers/browserSupportsWebAuthn.js
|
|
2120
2156
|
function browserSupportsWebAuthn() {
|
|
2121
|
-
return _browserSupportsWebAuthnInternals.stubThis(_optionalChain([globalThis, 'optionalAccess',
|
|
2157
|
+
return _browserSupportsWebAuthnInternals.stubThis(_optionalChain([globalThis, 'optionalAccess', _49 => _49.PublicKeyCredential]) !== void 0 && typeof globalThis.PublicKeyCredential === "function");
|
|
2122
2158
|
}
|
|
2123
2159
|
var _browserSupportsWebAuthnInternals = {
|
|
2124
2160
|
stubThis: (value) => value
|
|
@@ -2177,7 +2213,7 @@ function identifyRegistrationError({ error, options }) {
|
|
|
2177
2213
|
});
|
|
2178
2214
|
}
|
|
2179
2215
|
} else if (error.name === "ConstraintError") {
|
|
2180
|
-
if (_optionalChain([publicKey, 'access',
|
|
2216
|
+
if (_optionalChain([publicKey, 'access', _50 => _50.authenticatorSelection, 'optionalAccess', _51 => _51.requireResidentKey]) === true) {
|
|
2181
2217
|
return new WebAuthnError({
|
|
2182
2218
|
message: "Discoverable credentials were required but no available authenticator supported it",
|
|
2183
2219
|
code: "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
|
|
@@ -2185,14 +2221,14 @@ function identifyRegistrationError({ error, options }) {
|
|
|
2185
2221
|
});
|
|
2186
2222
|
} else if (
|
|
2187
2223
|
// @ts-ignore: `mediation` doesn't yet exist on CredentialCreationOptions but it's possible as of Sept 2024
|
|
2188
|
-
options.mediation === "conditional" && _optionalChain([publicKey, 'access',
|
|
2224
|
+
options.mediation === "conditional" && _optionalChain([publicKey, 'access', _52 => _52.authenticatorSelection, 'optionalAccess', _53 => _53.userVerification]) === "required"
|
|
2189
2225
|
) {
|
|
2190
2226
|
return new WebAuthnError({
|
|
2191
2227
|
message: "User verification was required during automatic registration but it could not be performed",
|
|
2192
2228
|
code: "ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",
|
|
2193
2229
|
cause: error
|
|
2194
2230
|
});
|
|
2195
|
-
} else if (_optionalChain([publicKey, 'access',
|
|
2231
|
+
} else if (_optionalChain([publicKey, 'access', _54 => _54.authenticatorSelection, 'optionalAccess', _55 => _55.userVerification]) === "required") {
|
|
2196
2232
|
return new WebAuthnError({
|
|
2197
2233
|
message: "User verification was required but no available authenticator supported it",
|
|
2198
2234
|
code: "ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",
|
|
@@ -2318,7 +2354,7 @@ async function startRegistration(options) {
|
|
|
2318
2354
|
...optionsJSON.user,
|
|
2319
2355
|
id: base64URLStringToBuffer(optionsJSON.user.id)
|
|
2320
2356
|
},
|
|
2321
|
-
excludeCredentials: _optionalChain([optionsJSON, 'access',
|
|
2357
|
+
excludeCredentials: _optionalChain([optionsJSON, 'access', _56 => _56.excludeCredentials, 'optionalAccess', _57 => _57.map, 'call', _58 => _58(toPublicKeyCredentialDescriptor)])
|
|
2322
2358
|
};
|
|
2323
2359
|
const createOptions = {};
|
|
2324
2360
|
if (useAutoRegister) {
|
|
@@ -2394,7 +2430,7 @@ function browserSupportsWebAuthnAutofill() {
|
|
|
2394
2430
|
return _browserSupportsWebAuthnAutofillInternals.stubThis(new Promise((resolve) => resolve(false)));
|
|
2395
2431
|
}
|
|
2396
2432
|
const globalPublicKeyCredential = globalThis.PublicKeyCredential;
|
|
2397
|
-
if (_optionalChain([globalPublicKeyCredential, 'optionalAccess',
|
|
2433
|
+
if (_optionalChain([globalPublicKeyCredential, 'optionalAccess', _59 => _59.isConditionalMediationAvailable]) === void 0) {
|
|
2398
2434
|
return _browserSupportsWebAuthnAutofillInternals.stubThis(new Promise((resolve) => resolve(false)));
|
|
2399
2435
|
}
|
|
2400
2436
|
return _browserSupportsWebAuthnAutofillInternals.stubThis(globalPublicKeyCredential.isConditionalMediationAvailable());
|
|
@@ -2459,8 +2495,8 @@ async function startAuthentication(options) {
|
|
|
2459
2495
|
throw new Error("WebAuthn is not supported in this browser");
|
|
2460
2496
|
}
|
|
2461
2497
|
let allowCredentials;
|
|
2462
|
-
if (_optionalChain([optionsJSON, 'access',
|
|
2463
|
-
allowCredentials = _optionalChain([optionsJSON, 'access',
|
|
2498
|
+
if (_optionalChain([optionsJSON, 'access', _60 => _60.allowCredentials, 'optionalAccess', _61 => _61.length]) !== 0) {
|
|
2499
|
+
allowCredentials = _optionalChain([optionsJSON, 'access', _62 => _62.allowCredentials, 'optionalAccess', _63 => _63.map, 'call', _64 => _64(toPublicKeyCredentialDescriptor)]);
|
|
2464
2500
|
}
|
|
2465
2501
|
const publicKey = {
|
|
2466
2502
|
...optionsJSON,
|
|
@@ -2514,7 +2550,7 @@ async function startAuthentication(options) {
|
|
|
2514
2550
|
|
|
2515
2551
|
function PasskeysModal({ isOpen, onClose, onCountChange }) {
|
|
2516
2552
|
const { api, getAccessToken, config } = useForgeConnect();
|
|
2517
|
-
const theme = _nullishCoalesce(_optionalChain([config, 'access',
|
|
2553
|
+
const theme = _nullishCoalesce(_optionalChain([config, 'access', _65 => _65.appearance, 'optionalAccess', _66 => _66.theme]), () => ( "light"));
|
|
2518
2554
|
const [passkeys, setPasskeys] = _react.useState.call(void 0, []);
|
|
2519
2555
|
const [loading, setLoading] = _react.useState.call(void 0, false);
|
|
2520
2556
|
const [addLoading, setAddLoading] = _react.useState.call(void 0, false);
|
|
@@ -2574,7 +2610,7 @@ function PasskeysModal({ isOpen, onClose, onCountChange }) {
|
|
|
2574
2610
|
"div",
|
|
2575
2611
|
{
|
|
2576
2612
|
className: "fc-modal-content",
|
|
2577
|
-
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access',
|
|
2613
|
+
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access', _67 => _67.appearance, 'optionalAccess', _68 => _68.accentColor]), () => ( "#8b5cf6")) },
|
|
2578
2614
|
"data-theme": theme,
|
|
2579
2615
|
children: [
|
|
2580
2616
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "fc-modal-title", children: "Passkeys" }),
|
|
@@ -2648,7 +2684,7 @@ function ErrorView({
|
|
|
2648
2684
|
|
|
2649
2685
|
function PasswordModal({ isOpen, onClose, hasPassword }) {
|
|
2650
2686
|
const { api, getAccessToken, config } = useForgeConnect();
|
|
2651
|
-
const theme = _nullishCoalesce(_optionalChain([config, 'access',
|
|
2687
|
+
const theme = _nullishCoalesce(_optionalChain([config, 'access', _69 => _69.appearance, 'optionalAccess', _70 => _70.theme]), () => ( "light"));
|
|
2652
2688
|
const [step, setStep] = _react.useState.call(void 0, "form");
|
|
2653
2689
|
const [currentPassword, setCurrentPassword] = _react.useState.call(void 0, "");
|
|
2654
2690
|
const [newPassword, setNewPassword] = _react.useState.call(void 0, "");
|
|
@@ -2685,7 +2721,7 @@ function PasswordModal({ isOpen, onClose, hasPassword }) {
|
|
|
2685
2721
|
"div",
|
|
2686
2722
|
{
|
|
2687
2723
|
className: "fc-modal-content",
|
|
2688
|
-
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access',
|
|
2724
|
+
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access', _71 => _71.appearance, 'optionalAccess', _72 => _72.accentColor]), () => ( "#8b5cf6")) },
|
|
2689
2725
|
"data-theme": theme,
|
|
2690
2726
|
children: step === "done" ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-tab", style: { textAlign: "center", padding: "24px 0" }, children: [
|
|
2691
2727
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-success", children: [
|
|
@@ -2754,7 +2790,7 @@ function PasswordModal({ isOpen, onClose, hasPassword }) {
|
|
|
2754
2790
|
|
|
2755
2791
|
function DeleteAccountModal({ isOpen, onClose, onDeleted }) {
|
|
2756
2792
|
const { api, getAccessToken, config, logout } = useForgeConnect();
|
|
2757
|
-
const theme = _nullishCoalesce(_optionalChain([config, 'access',
|
|
2793
|
+
const theme = _nullishCoalesce(_optionalChain([config, 'access', _73 => _73.appearance, 'optionalAccess', _74 => _74.theme]), () => ( "light"));
|
|
2758
2794
|
const [step, setStep] = _react.useState.call(void 0, "confirm");
|
|
2759
2795
|
const [code, setCode] = _react.useState.call(void 0, "");
|
|
2760
2796
|
const [loading, setLoading] = _react.useState.call(void 0, false);
|
|
@@ -2814,7 +2850,7 @@ function DeleteAccountModal({ isOpen, onClose, onDeleted }) {
|
|
|
2814
2850
|
"div",
|
|
2815
2851
|
{
|
|
2816
2852
|
className: "fc-modal-content",
|
|
2817
|
-
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access',
|
|
2853
|
+
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access', _75 => _75.appearance, 'optionalAccess', _76 => _76.accentColor]), () => ( "#8b5cf6")) },
|
|
2818
2854
|
"data-theme": theme,
|
|
2819
2855
|
children: [
|
|
2820
2856
|
step === "confirm" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
@@ -2941,20 +2977,20 @@ function AccountModal() {
|
|
|
2941
2977
|
prevLinkOpen.current = linkModal.isOpen;
|
|
2942
2978
|
}, [linkModal.isOpen]);
|
|
2943
2979
|
if (!accountModal.isOpen) return null;
|
|
2944
|
-
const theme = _nullishCoalesce(_optionalChain([config, 'access',
|
|
2945
|
-
const initial = (_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
2980
|
+
const theme = _nullishCoalesce(_optionalChain([config, 'access', _77 => _77.appearance, 'optionalAccess', _78 => _78.theme]), () => ( "light"));
|
|
2981
|
+
const initial = (_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _79 => _79.displayName]), () => ( _optionalChain([user, 'optionalAccess', _80 => _80.primaryEmail]))), () => ( "?"))).charAt(0).toUpperCase();
|
|
2946
2982
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ModalOverlay, { isOpen: accountModal.isOpen, onClose: closeAccountModal, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2947
2983
|
"div",
|
|
2948
2984
|
{
|
|
2949
2985
|
className: "fc-modal-content",
|
|
2950
|
-
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access',
|
|
2986
|
+
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access', _81 => _81.appearance, 'optionalAccess', _82 => _82.accentColor]), () => ( "#8b5cf6")) },
|
|
2951
2987
|
"data-theme": theme,
|
|
2952
2988
|
children: [
|
|
2953
2989
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-account-hero", children: [
|
|
2954
|
-
_optionalChain([user, 'optionalAccess',
|
|
2990
|
+
_optionalChain([user, 'optionalAccess', _83 => _83.avatarUrl]) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "img", { src: user.avatarUrl, alt: "", className: "fc-account-hero-avatar" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-account-hero-avatar fc-account-hero-avatar-placeholder", children: initial }),
|
|
2955
2991
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-account-hero-info", children: [
|
|
2956
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-account-hero-name", children: _nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
2957
|
-
_optionalChain([user, 'optionalAccess',
|
|
2992
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-account-hero-name", children: _nullishCoalesce(_optionalChain([user, 'optionalAccess', _84 => _84.displayName]), () => ( "Your account")) }),
|
|
2993
|
+
_optionalChain([user, 'optionalAccess', _85 => _85.primaryEmail]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-account-hero-email", children: user.primaryEmail })
|
|
2958
2994
|
] })
|
|
2959
2995
|
] }),
|
|
2960
2996
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "fc-account-tabs", children: TABS.map((tab) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -2992,13 +3028,13 @@ function AccountModal() {
|
|
|
2992
3028
|
}
|
|
2993
3029
|
function ProfileTab() {
|
|
2994
3030
|
const { user, updateProfile } = useUser();
|
|
2995
|
-
const [displayName, setDisplayName] = _react.useState.call(void 0, _nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
2996
|
-
const [avatarUrl, setAvatarUrl] = _react.useState.call(void 0, _nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
3031
|
+
const [displayName, setDisplayName] = _react.useState.call(void 0, _nullishCoalesce(_optionalChain([user, 'optionalAccess', _86 => _86.displayName]), () => ( "")));
|
|
3032
|
+
const [avatarUrl, setAvatarUrl] = _react.useState.call(void 0, _nullishCoalesce(_optionalChain([user, 'optionalAccess', _87 => _87.avatarUrl]), () => ( "")));
|
|
2997
3033
|
const [loading, setLoading] = _react.useState.call(void 0, false);
|
|
2998
3034
|
const [msg, setMsg] = _react.useState.call(void 0, null);
|
|
2999
3035
|
_react.useEffect.call(void 0, () => {
|
|
3000
|
-
setDisplayName(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
3001
|
-
setAvatarUrl(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
3036
|
+
setDisplayName(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _88 => _88.displayName]), () => ( "")));
|
|
3037
|
+
setAvatarUrl(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _89 => _89.avatarUrl]), () => ( "")));
|
|
3002
3038
|
}, [user]);
|
|
3003
3039
|
const handleSave = async () => {
|
|
3004
3040
|
setLoading(true);
|
|
@@ -3063,7 +3099,7 @@ function LoginsTab({ onLink, refreshKey }) {
|
|
|
3063
3099
|
msg && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-error", children: msg }),
|
|
3064
3100
|
loading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-text", children: "Loading..." }),
|
|
3065
3101
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-account-section-desc", children: "Ways you can sign in to your account." }),
|
|
3066
|
-
_optionalChain([authMethods, 'optionalAccess',
|
|
3102
|
+
_optionalChain([authMethods, 'optionalAccess', _90 => _90.map, 'call', _91 => _91((m) => {
|
|
3067
3103
|
const display = getMethodDisplay(m.provider);
|
|
3068
3104
|
const detail = m.provider === "email" ? m.providerId : m.provider.endsWith("_wallet") ? truncate(m.providerId) : m.providerId;
|
|
3069
3105
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-account-item", children: [
|
|
@@ -3078,7 +3114,7 @@ function LoginsTab({ onLink, refreshKey }) {
|
|
|
3078
3114
|
] })
|
|
3079
3115
|
] }, m.id);
|
|
3080
3116
|
})]),
|
|
3081
|
-
_optionalChain([authMethods, 'optionalAccess',
|
|
3117
|
+
_optionalChain([authMethods, 'optionalAccess', _92 => _92.length]) === 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-account-empty", children: "No login methods yet" }),
|
|
3082
3118
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "fc-btn fc-btn-secondary", onClick: onLink, style: { marginTop: 8 }, children: "+ Add login method" })
|
|
3083
3119
|
] });
|
|
3084
3120
|
}
|
|
@@ -3101,8 +3137,8 @@ function WalletsTab({ onLink, refreshKey }) {
|
|
|
3101
3137
|
msg && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-error", children: msg }),
|
|
3102
3138
|
loading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-text", children: "Loading..." }),
|
|
3103
3139
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-account-section-desc", children: "Crypto wallets connected to your account." }),
|
|
3104
|
-
_optionalChain([wallets, 'optionalAccess',
|
|
3105
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SvgIcon, { svg: _nullishCoalesce(_optionalChain([METHOD_DISPLAY, 'access',
|
|
3140
|
+
_optionalChain([wallets, 'optionalAccess', _93 => _93.map, 'call', _94 => _94((w) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-account-item", children: [
|
|
3141
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SvgIcon, { svg: _nullishCoalesce(_optionalChain([METHOD_DISPLAY, 'access', _95 => _95[`${w.chain}_wallet`], 'optionalAccess', _96 => _96.iconHtml]), () => ( "")), className: "fc-account-item-icon" }),
|
|
3106
3142
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-account-item-info", children: [
|
|
3107
3143
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "fc-account-item-label", children: [
|
|
3108
3144
|
w.chain.charAt(0).toUpperCase() + w.chain.slice(1),
|
|
@@ -3112,7 +3148,7 @@ function WalletsTab({ onLink, refreshKey }) {
|
|
|
3112
3148
|
] }),
|
|
3113
3149
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "fc-account-item-actions", children: !w.isPrimary && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "fc-btn-primary-sm", onClick: () => handleSetPrimary(w.id), children: "Make primary" }) })
|
|
3114
3150
|
] }, w.id))]),
|
|
3115
|
-
_optionalChain([wallets, 'optionalAccess',
|
|
3151
|
+
_optionalChain([wallets, 'optionalAccess', _97 => _97.length]) === 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-account-empty", children: "No wallets connected" }),
|
|
3116
3152
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "fc-btn fc-btn-secondary", onClick: onLink, style: { marginTop: 8 }, children: "+ Connect wallet" })
|
|
3117
3153
|
] });
|
|
3118
3154
|
}
|
|
@@ -3147,7 +3183,7 @@ function SecurityTab() {
|
|
|
3147
3183
|
refreshStatus();
|
|
3148
3184
|
refreshPasskeyCount();
|
|
3149
3185
|
}, [fetchSessions, fetchAuthMethods, refreshStatus, refreshPasskeyCount]);
|
|
3150
|
-
const hasPassword = _optionalChain([userAuthMethods, 'optionalAccess',
|
|
3186
|
+
const hasPassword = _optionalChain([userAuthMethods, 'optionalAccess', _98 => _98.some, 'call', _99 => _99((m) => m.provider === "email")]);
|
|
3151
3187
|
const handleRevoke = async (id) => {
|
|
3152
3188
|
setMsg("");
|
|
3153
3189
|
try {
|
|
@@ -3181,7 +3217,7 @@ function SecurityTab() {
|
|
|
3181
3217
|
] }),
|
|
3182
3218
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChevronRight, {})
|
|
3183
3219
|
] }),
|
|
3184
|
-
_optionalChain([user, 'optionalAccess',
|
|
3220
|
+
_optionalChain([user, 'optionalAccess', _100 => _100.primaryEmail]) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3185
3221
|
"button",
|
|
3186
3222
|
{
|
|
3187
3223
|
type: "button",
|
|
@@ -3202,7 +3238,7 @@ function SecurityTab() {
|
|
|
3202
3238
|
),
|
|
3203
3239
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "fc-divider", style: { margin: "16px 0" }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "active sessions" }) }),
|
|
3204
3240
|
loading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-text", children: "Loading..." }),
|
|
3205
|
-
_optionalChain([sessions, 'optionalAccess',
|
|
3241
|
+
_optionalChain([sessions, 'optionalAccess', _101 => _101.map, 'call', _102 => _102((s) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-account-item", children: [
|
|
3206
3242
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-account-item-icon", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "svg", { width: "16", height: "16", viewBox: "0 0 20 20", fill: "none", children: [
|
|
3207
3243
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "rect", { x: "2", y: "3", width: "16", height: "11", rx: "2", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
3208
3244
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M7 17h6M10 14v3", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
|
|
@@ -3218,7 +3254,7 @@ function SecurityTab() {
|
|
|
3218
3254
|
] }),
|
|
3219
3255
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "fc-account-item-actions", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "fc-btn-danger-sm", onClick: () => handleRevoke(s.id), children: "Sign out" }) })
|
|
3220
3256
|
] }, s.id))]),
|
|
3221
|
-
_optionalChain([sessions, 'optionalAccess',
|
|
3257
|
+
_optionalChain([sessions, 'optionalAccess', _103 => _103.length]) === 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-account-empty", children: "No active sessions" }),
|
|
3222
3258
|
sessions && sessions.length > 1 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3223
3259
|
"button",
|
|
3224
3260
|
{
|
|
@@ -3265,7 +3301,7 @@ function SecurityTab() {
|
|
|
3265
3301
|
onCountChange: (count) => setPasskeyCount(count)
|
|
3266
3302
|
}
|
|
3267
3303
|
),
|
|
3268
|
-
_optionalChain([user, 'optionalAccess',
|
|
3304
|
+
_optionalChain([user, 'optionalAccess', _104 => _104.primaryEmail]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3269
3305
|
PasswordModal,
|
|
3270
3306
|
{
|
|
3271
3307
|
isOpen: showPasswordModal,
|
|
@@ -3310,7 +3346,7 @@ function LinkAuthModal() {
|
|
|
3310
3346
|
if (!linkModal.isOpen) return;
|
|
3311
3347
|
const handleMessage = (event) => {
|
|
3312
3348
|
if (event.origin !== window.location.origin) return;
|
|
3313
|
-
if (_optionalChain([event, 'access',
|
|
3349
|
+
if (_optionalChain([event, 'access', _105 => _105.data, 'optionalAccess', _106 => _106.type]) === "fc_oauth_link_success") {
|
|
3314
3350
|
setStep("success");
|
|
3315
3351
|
setTimeout(() => {
|
|
3316
3352
|
handleClose();
|
|
@@ -3321,7 +3357,7 @@ function LinkAuthModal() {
|
|
|
3321
3357
|
return () => window.removeEventListener("message", handleMessage);
|
|
3322
3358
|
}, [linkModal.isOpen]);
|
|
3323
3359
|
if (!linkModal.isOpen) return null;
|
|
3324
|
-
const theme = _nullishCoalesce(_optionalChain([config, 'access',
|
|
3360
|
+
const theme = _nullishCoalesce(_optionalChain([config, 'access', _107 => _107.appearance, 'optionalAccess', _108 => _108.theme]), () => ( "light"));
|
|
3325
3361
|
const handleClose = () => {
|
|
3326
3362
|
setStep("method-select");
|
|
3327
3363
|
closeLinkModal();
|
|
@@ -3344,7 +3380,7 @@ function LinkAuthModal() {
|
|
|
3344
3380
|
"div",
|
|
3345
3381
|
{
|
|
3346
3382
|
className: "fc-modal-content",
|
|
3347
|
-
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access',
|
|
3383
|
+
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access', _109 => _109.appearance, 'optionalAccess', _110 => _110.accentColor]), () => ( "#8b5cf6")) },
|
|
3348
3384
|
"data-theme": theme,
|
|
3349
3385
|
children: step === "success" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SuccessView2, {}) : step === "error" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3350
3386
|
ErrorView,
|
|
@@ -3360,7 +3396,7 @@ function LinkAuthModal() {
|
|
|
3360
3396
|
AuthMethodSelectStep,
|
|
3361
3397
|
{
|
|
3362
3398
|
config,
|
|
3363
|
-
connectedProviders: _nullishCoalesce(_optionalChain([authMethods, 'optionalAccess',
|
|
3399
|
+
connectedProviders: _nullishCoalesce(_optionalChain([authMethods, 'optionalAccess', _111 => _111.map, 'call', _112 => _112((m) => m.provider)]), () => ( [])),
|
|
3364
3400
|
onSelectEmail: () => setStep("email"),
|
|
3365
3401
|
onSelectOtp: () => setStep("otp"),
|
|
3366
3402
|
onOAuth: handleOAuthDirect
|
|
@@ -3579,13 +3615,13 @@ function WalletLinkStep({ onBack, onSuccess, onFatalError }) {
|
|
|
3579
3615
|
const [coldWallet, setColdWallet] = _react.useState.call(void 0, false);
|
|
3580
3616
|
const mobile = _react.useMemo.call(void 0, () => isMobile(), []);
|
|
3581
3617
|
const walletConfig = config.walletConfig;
|
|
3582
|
-
const preferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess',
|
|
3583
|
-
const onlyPreferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess',
|
|
3618
|
+
const preferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess', _113 => _113.preferredWallets]), () => ( []));
|
|
3619
|
+
const onlyPreferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess', _114 => _114.onlyPreferred]), () => ( false));
|
|
3584
3620
|
const coldWalletRef = _react.useRef.call(void 0, coldWallet);
|
|
3585
3621
|
coldWalletRef.current = coldWallet;
|
|
3586
3622
|
const buildSignTxFnForAdapter = _react.useCallback.call(void 0, (adapter) => {
|
|
3587
3623
|
if (!adapter.signTransaction) return void 0;
|
|
3588
|
-
const TxClass = _optionalChain([walletConfig, 'optionalAccess',
|
|
3624
|
+
const TxClass = _optionalChain([walletConfig, 'optionalAccess', _115 => _115.Transaction]);
|
|
3589
3625
|
if (!TxClass) return void 0;
|
|
3590
3626
|
return async (txBase64) => {
|
|
3591
3627
|
const bytes = Uint8Array.from(atob(txBase64), (c) => c.charCodeAt(0));
|
|
@@ -3593,7 +3629,7 @@ function WalletLinkStep({ onBack, onSuccess, onFatalError }) {
|
|
|
3593
3629
|
const signedTx = await adapter.signTransaction(tx);
|
|
3594
3630
|
return btoa(String.fromCharCode(...new Uint8Array(signedTx.serialize())));
|
|
3595
3631
|
};
|
|
3596
|
-
}, [_optionalChain([walletConfig, 'optionalAccess',
|
|
3632
|
+
}, [_optionalChain([walletConfig, 'optionalAccess', _116 => _116.Transaction])]);
|
|
3597
3633
|
const wallet = walletAdapter;
|
|
3598
3634
|
const handleConnect = async (w) => {
|
|
3599
3635
|
if (w.readyState !== "Installed") {
|
|
@@ -3636,12 +3672,12 @@ function WalletLinkStep({ onBack, onSuccess, onFatalError }) {
|
|
|
3636
3672
|
const prefSet = new Set(preferred);
|
|
3637
3673
|
const others = all.filter((w) => !prefSet.has(w.adapter.name) && w.readyState === "Installed");
|
|
3638
3674
|
return { preferredWallets: prefList, otherWallets: others };
|
|
3639
|
-
}, [_optionalChain([walletAdapter, 'optionalAccess',
|
|
3675
|
+
}, [_optionalChain([walletAdapter, 'optionalAccess', _117 => _117.wallets]), walletConfig]);
|
|
3640
3676
|
const mobileExtraWallets = _react.useMemo.call(void 0, () => {
|
|
3641
3677
|
if (!mobile || !walletAdapter) return [];
|
|
3642
3678
|
const adapterNames = new Set(walletAdapter.wallets.map((w) => w.adapter.name));
|
|
3643
3679
|
return MOBILE_WALLETS.filter((mw) => !adapterNames.has(mw.name));
|
|
3644
|
-
}, [mobile, _optionalChain([walletAdapter, 'optionalAccess',
|
|
3680
|
+
}, [mobile, _optionalChain([walletAdapter, 'optionalAccess', _118 => _118.wallets])]);
|
|
3645
3681
|
if (!walletAdapter && mobile) {
|
|
3646
3682
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-tab", children: [
|
|
3647
3683
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "fc-wallet-list", children: MOBILE_WALLETS.map((mw) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
@@ -3737,7 +3773,7 @@ function WalletLinkStep({ onBack, onSuccess, onFatalError }) {
|
|
|
3737
3773
|
] }, w.adapter.name))
|
|
3738
3774
|
] }),
|
|
3739
3775
|
preferredWallets.length === 0 && otherWallets.length === 0 && mobileExtraWallets.length === 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-text", children: "No wallet found. Please install a Solana wallet (like Phantom) to continue." }),
|
|
3740
|
-
_optionalChain([walletConfig, 'optionalAccess',
|
|
3776
|
+
_optionalChain([walletConfig, 'optionalAccess', _119 => _119.Transaction]) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { className: "fc-cold-wallet-toggle", children: [
|
|
3741
3777
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3742
3778
|
"input",
|
|
3743
3779
|
{
|
|
@@ -3769,6 +3805,7 @@ function SuccessView2() {
|
|
|
3769
3805
|
|
|
3770
3806
|
// src/provider.tsx
|
|
3771
3807
|
|
|
3808
|
+
var oauthExchangeCache = /* @__PURE__ */ new Map();
|
|
3772
3809
|
function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapter }) {
|
|
3773
3810
|
const [auth, setAuth] = _react.useState.call(void 0, {
|
|
3774
3811
|
status: "loading",
|
|
@@ -3827,42 +3864,81 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
3827
3864
|
return;
|
|
3828
3865
|
}
|
|
3829
3866
|
const authCode = params.get("fc_code");
|
|
3830
|
-
if (authCode
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3867
|
+
if (authCode) {
|
|
3868
|
+
try {
|
|
3869
|
+
localStorage.setItem("fc_oauth_code_pending", authCode);
|
|
3870
|
+
} catch (e9) {
|
|
3871
|
+
}
|
|
3872
|
+
if (window.opener) {
|
|
3873
|
+
window.opener.postMessage(
|
|
3874
|
+
{ type: "fc_oauth_code", code: authCode },
|
|
3875
|
+
window.location.origin
|
|
3876
|
+
);
|
|
3877
|
+
}
|
|
3835
3878
|
window.close();
|
|
3836
3879
|
return;
|
|
3837
3880
|
}
|
|
3838
3881
|
}
|
|
3839
|
-
const
|
|
3882
|
+
const handleCode = async (code) => {
|
|
3883
|
+
let exchangePromise = oauthExchangeCache.get(code);
|
|
3884
|
+
if (!exchangePromise) {
|
|
3885
|
+
try {
|
|
3886
|
+
localStorage.removeItem("fc_oauth_code_pending");
|
|
3887
|
+
} catch (e10) {
|
|
3888
|
+
}
|
|
3889
|
+
exchangePromise = (async () => {
|
|
3890
|
+
try {
|
|
3891
|
+
const result = await api.exchangeOAuthCode(code);
|
|
3892
|
+
if (result.requires2FA && result.challengeToken) {
|
|
3893
|
+
return { kind: "requires2FA", challengeToken: result.challengeToken };
|
|
3894
|
+
}
|
|
3895
|
+
const token = result.accessToken;
|
|
3896
|
+
if (!token) return null;
|
|
3897
|
+
const user = await api.getMe(token);
|
|
3898
|
+
return { kind: "authenticated", accessToken: token, user };
|
|
3899
|
+
} catch (e11) {
|
|
3900
|
+
return null;
|
|
3901
|
+
}
|
|
3902
|
+
})();
|
|
3903
|
+
oauthExchangeCache.set(code, exchangePromise);
|
|
3904
|
+
}
|
|
3905
|
+
const outcome = await exchangePromise;
|
|
3906
|
+
if (!outcome) return;
|
|
3907
|
+
if (outcome.kind === "requires2FA") {
|
|
3908
|
+
setChallengeToken(outcome.challengeToken);
|
|
3909
|
+
setModal({ isOpen: true, step: "verify-2fa" });
|
|
3910
|
+
return;
|
|
3911
|
+
}
|
|
3912
|
+
setModal({ isOpen: true, step: "success" });
|
|
3913
|
+
setAuth({ status: "authenticated", user: outcome.user, accessToken: outcome.accessToken });
|
|
3914
|
+
scheduleRefresh(outcome.accessToken);
|
|
3915
|
+
_optionalChain([onLogin, 'optionalCall', _120 => _120(outcome.user)]);
|
|
3916
|
+
setTimeout(() => {
|
|
3917
|
+
setModal({ isOpen: false, step: "method-select" });
|
|
3918
|
+
}, 1500);
|
|
3919
|
+
};
|
|
3920
|
+
const handleMessage = (event) => {
|
|
3840
3921
|
if (event.origin !== window.location.origin) return;
|
|
3841
3922
|
if (_optionalChain([event, 'access', _121 => _121.data, 'optionalAccess', _122 => _122.type]) !== "fc_oauth_code") return;
|
|
3842
3923
|
const code = event.data.code;
|
|
3843
3924
|
if (!code) return;
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
return;
|
|
3850
|
-
}
|
|
3851
|
-
const token = result.accessToken;
|
|
3852
|
-
if (!token) return;
|
|
3853
|
-
setModal({ isOpen: true, step: "success" });
|
|
3854
|
-
const user = await api.getMe(token);
|
|
3855
|
-
setAuth({ status: "authenticated", user, accessToken: token });
|
|
3856
|
-
scheduleRefresh(token);
|
|
3857
|
-
_optionalChain([onLogin, 'optionalCall', _123 => _123(user)]);
|
|
3858
|
-
setTimeout(() => {
|
|
3859
|
-
setModal({ isOpen: false, step: "method-select" });
|
|
3860
|
-
}, 1500);
|
|
3861
|
-
} catch (e9) {
|
|
3862
|
-
}
|
|
3925
|
+
void handleCode(code);
|
|
3926
|
+
};
|
|
3927
|
+
const handleStorage = (event) => {
|
|
3928
|
+
if (event.key !== "fc_oauth_code_pending" || !event.newValue) return;
|
|
3929
|
+
void handleCode(event.newValue);
|
|
3863
3930
|
};
|
|
3931
|
+
try {
|
|
3932
|
+
const pending = localStorage.getItem("fc_oauth_code_pending");
|
|
3933
|
+
if (pending) void handleCode(pending);
|
|
3934
|
+
} catch (e12) {
|
|
3935
|
+
}
|
|
3864
3936
|
window.addEventListener("message", handleMessage);
|
|
3865
|
-
|
|
3937
|
+
window.addEventListener("storage", handleStorage);
|
|
3938
|
+
return () => {
|
|
3939
|
+
window.removeEventListener("message", handleMessage);
|
|
3940
|
+
window.removeEventListener("storage", handleStorage);
|
|
3941
|
+
};
|
|
3866
3942
|
}, [api, config.apiUrl, scheduleRefresh, onLogin]);
|
|
3867
3943
|
_react.useEffect.call(void 0, () => {
|
|
3868
3944
|
if (config.loginMethods && config.loginMethods.length > 0) {
|
|
@@ -3880,7 +3956,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
3880
3956
|
setAuth({ status: "authenticated", user, accessToken: token });
|
|
3881
3957
|
scheduleRefresh(token);
|
|
3882
3958
|
setModal({ isOpen: true, step: "success" });
|
|
3883
|
-
_optionalChain([onLogin, 'optionalCall',
|
|
3959
|
+
_optionalChain([onLogin, 'optionalCall', _123 => _123(user)]);
|
|
3884
3960
|
setTimeout(() => {
|
|
3885
3961
|
setModal({ isOpen: false, step: "method-select" });
|
|
3886
3962
|
}, 1500);
|
|
@@ -3980,11 +4056,11 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
3980
4056
|
const token = auth.accessToken;
|
|
3981
4057
|
if (refreshTimerRef.current) clearTimeout(refreshTimerRef.current);
|
|
3982
4058
|
setAuth({ status: "unauthenticated", user: null, accessToken: null });
|
|
3983
|
-
_optionalChain([onLogout, 'optionalCall',
|
|
4059
|
+
_optionalChain([onLogout, 'optionalCall', _124 => _124()]);
|
|
3984
4060
|
if (token) {
|
|
3985
4061
|
try {
|
|
3986
4062
|
await api.logout(token);
|
|
3987
|
-
} catch (
|
|
4063
|
+
} catch (e13) {
|
|
3988
4064
|
}
|
|
3989
4065
|
}
|
|
3990
4066
|
}, [auth.accessToken, api, onLogout]);
|
|
@@ -4034,11 +4110,11 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4034
4110
|
const token = auth.accessToken;
|
|
4035
4111
|
if (refreshTimerRef.current) clearTimeout(refreshTimerRef.current);
|
|
4036
4112
|
setAuth({ status: "unauthenticated", user: null, accessToken: null });
|
|
4037
|
-
_optionalChain([onLogout, 'optionalCall',
|
|
4113
|
+
_optionalChain([onLogout, 'optionalCall', _125 => _125()]);
|
|
4038
4114
|
if (token) {
|
|
4039
4115
|
try {
|
|
4040
4116
|
await api.logoutAll(token);
|
|
4041
|
-
} catch (
|
|
4117
|
+
} catch (e14) {
|
|
4042
4118
|
}
|
|
4043
4119
|
}
|
|
4044
4120
|
}, [auth.accessToken, api, onLogout]);
|
|
@@ -4219,11 +4295,11 @@ function useAdmin() {
|
|
|
4219
4295
|
const token = getAccessToken();
|
|
4220
4296
|
if (!token) throw new Error("Please sign in to continue.");
|
|
4221
4297
|
await api.adminUpdateUserStatus(token, id, status);
|
|
4222
|
-
if (_optionalChain([selectedUser, 'optionalAccess',
|
|
4298
|
+
if (_optionalChain([selectedUser, 'optionalAccess', _126 => _126.id]) === id) {
|
|
4223
4299
|
await getUser(id);
|
|
4224
4300
|
}
|
|
4225
4301
|
},
|
|
4226
|
-
[api, getAccessToken, _optionalChain([selectedUser, 'optionalAccess',
|
|
4302
|
+
[api, getAccessToken, _optionalChain([selectedUser, 'optionalAccess', _127 => _127.id]), getUser]
|
|
4227
4303
|
);
|
|
4228
4304
|
const getUserSessions = _react.useCallback.call(void 0,
|
|
4229
4305
|
async (id) => {
|
|
@@ -4340,9 +4416,9 @@ function useRoles() {
|
|
|
4340
4416
|
const token = getAccessToken();
|
|
4341
4417
|
if (!token) throw new Error("Please sign in to continue.");
|
|
4342
4418
|
await api.adminDeleteRole(token, id);
|
|
4343
|
-
if (_optionalChain([selectedRole, 'optionalAccess',
|
|
4419
|
+
if (_optionalChain([selectedRole, 'optionalAccess', _128 => _128.id]) === id) setSelectedRole(null);
|
|
4344
4420
|
},
|
|
4345
|
-
[api, getAccessToken, _optionalChain([selectedRole, 'optionalAccess',
|
|
4421
|
+
[api, getAccessToken, _optionalChain([selectedRole, 'optionalAccess', _129 => _129.id])]
|
|
4346
4422
|
);
|
|
4347
4423
|
const getPermissions = _react.useCallback.call(void 0,
|
|
4348
4424
|
async () => {
|