@forge-connect/react 1.0.14 → 1.0.17
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 +368 -95
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -1
- package/dist/index.d.ts +58 -1
- package/dist/index.js +404 -131
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/provider.tsx
|
|
2
|
-
import { useState as
|
|
2
|
+
import { useState as useState17, useCallback as useCallback9, useEffect as useEffect13, useRef as useRef9, useMemo as useMemo3 } from "react";
|
|
3
3
|
|
|
4
4
|
// src/context.ts
|
|
5
5
|
import { createContext } from "react";
|
|
@@ -454,7 +454,7 @@ function getRefreshDelay(token) {
|
|
|
454
454
|
}
|
|
455
455
|
|
|
456
456
|
// src/components/login-modal.tsx
|
|
457
|
-
import { useState as
|
|
457
|
+
import { useState as useState7 } from "react";
|
|
458
458
|
|
|
459
459
|
// src/hooks/use-forge-connect.ts
|
|
460
460
|
import { useContext } from "react";
|
|
@@ -843,7 +843,7 @@ function EmailOtpForm() {
|
|
|
843
843
|
}
|
|
844
844
|
|
|
845
845
|
// src/components/tabs/wallet-connect.tsx
|
|
846
|
-
import { useState as
|
|
846
|
+
import { useState as useState4, useMemo, useEffect as useEffect4, useRef as useRef4, useCallback } from "react";
|
|
847
847
|
|
|
848
848
|
// src/components/svg-icon.tsx
|
|
849
849
|
import { useRef as useRef3, useEffect as useEffect2 } from "react";
|
|
@@ -923,6 +923,111 @@ function OAuthButton({ provider }) {
|
|
|
923
923
|
);
|
|
924
924
|
}
|
|
925
925
|
|
|
926
|
+
// src/hooks/use-standard-wallets.ts
|
|
927
|
+
import { useEffect as useEffect3, useState as useState3 } from "react";
|
|
928
|
+
function useStandardWallets() {
|
|
929
|
+
const [wallets, setWallets] = useState3([]);
|
|
930
|
+
useEffect3(() => {
|
|
931
|
+
if (typeof window === "undefined") return;
|
|
932
|
+
let unsubRegister;
|
|
933
|
+
let unsubUnregister;
|
|
934
|
+
let cancelled = false;
|
|
935
|
+
(async () => {
|
|
936
|
+
try {
|
|
937
|
+
const { getWallets } = await import("@wallet-standard/app");
|
|
938
|
+
if (cancelled) return;
|
|
939
|
+
const registry = getWallets();
|
|
940
|
+
const update = () => {
|
|
941
|
+
const raw = registry.get();
|
|
942
|
+
const seen = /* @__PURE__ */ new Set();
|
|
943
|
+
const list = [];
|
|
944
|
+
for (const w of raw) {
|
|
945
|
+
if (seen.has(w.name)) continue;
|
|
946
|
+
seen.add(w.name);
|
|
947
|
+
list.push(w);
|
|
948
|
+
}
|
|
949
|
+
console.log("[ForgeConnect/MWA] useStandardWallets ->", list.map((w) => w.name), `(raw: ${raw.length})`);
|
|
950
|
+
setWallets(list);
|
|
951
|
+
};
|
|
952
|
+
update();
|
|
953
|
+
unsubRegister = registry.on("register", update);
|
|
954
|
+
unsubUnregister = registry.on("unregister", update);
|
|
955
|
+
} catch {
|
|
956
|
+
}
|
|
957
|
+
})();
|
|
958
|
+
return () => {
|
|
959
|
+
cancelled = true;
|
|
960
|
+
unsubRegister?.();
|
|
961
|
+
unsubUnregister?.();
|
|
962
|
+
};
|
|
963
|
+
}, []);
|
|
964
|
+
return wallets;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
// src/lib/standard-wallet.ts
|
|
968
|
+
async function connectAndPrepareStandardWallet(wallet) {
|
|
969
|
+
const connectFeature = wallet.features["standard:connect"];
|
|
970
|
+
const signMessageFeature = wallet.features["solana:signMessage"];
|
|
971
|
+
if (!connectFeature) throw new Error(`${wallet.name} does not support standard:connect`);
|
|
972
|
+
if (!signMessageFeature) throw new Error(`${wallet.name} does not support solana:signMessage`);
|
|
973
|
+
const { accounts } = await connectFeature.connect();
|
|
974
|
+
const account = accounts[0];
|
|
975
|
+
if (!account) throw new Error(`${wallet.name} did not return any accounts`);
|
|
976
|
+
const signMessage = async (msg) => {
|
|
977
|
+
const results = await signMessageFeature.signMessage({ account, message: msg });
|
|
978
|
+
const first = results[0];
|
|
979
|
+
if (!first) throw new Error("Wallet did not return a signature");
|
|
980
|
+
return first.signature;
|
|
981
|
+
};
|
|
982
|
+
return { address: account.address, signMessage };
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
// src/lib/seeker-bridge.ts
|
|
986
|
+
function isSeekerApp() {
|
|
987
|
+
return typeof window !== "undefined" && window.nomuSeeker?.isSeeker === true;
|
|
988
|
+
}
|
|
989
|
+
function uint8ToBase64(bytes) {
|
|
990
|
+
let bin = "";
|
|
991
|
+
for (let i = 0; i < bytes.length; i++) bin += String.fromCharCode(bytes[i]);
|
|
992
|
+
return btoa(bin);
|
|
993
|
+
}
|
|
994
|
+
function base58ToUint8(s) {
|
|
995
|
+
const ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
996
|
+
const map = /* @__PURE__ */ new Map();
|
|
997
|
+
for (let i = 0; i < ALPHABET.length; i++) map.set(ALPHABET[i], i);
|
|
998
|
+
const bytes = [0];
|
|
999
|
+
for (const ch of s) {
|
|
1000
|
+
const v = map.get(ch);
|
|
1001
|
+
if (v === void 0) throw new Error("Invalid base58 character");
|
|
1002
|
+
let carry = v;
|
|
1003
|
+
for (let j = 0; j < bytes.length; j++) {
|
|
1004
|
+
carry += bytes[j] * 58;
|
|
1005
|
+
bytes[j] = carry & 255;
|
|
1006
|
+
carry >>= 8;
|
|
1007
|
+
}
|
|
1008
|
+
while (carry > 0) {
|
|
1009
|
+
bytes.push(carry & 255);
|
|
1010
|
+
carry >>= 8;
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
for (const ch of s) {
|
|
1014
|
+
if (ch !== "1") break;
|
|
1015
|
+
bytes.push(0);
|
|
1016
|
+
}
|
|
1017
|
+
return new Uint8Array(bytes.reverse());
|
|
1018
|
+
}
|
|
1019
|
+
async function connectSeekerBridge() {
|
|
1020
|
+
const bridge = window.nomuSeeker;
|
|
1021
|
+
if (!bridge) throw new Error("NomuSeeker bridge not available");
|
|
1022
|
+
const { publicKey } = await bridge.connect();
|
|
1023
|
+
const signMessage = async (msg) => {
|
|
1024
|
+
const { signature } = await bridge.signMessage(uint8ToBase64(msg));
|
|
1025
|
+
return base58ToUint8(signature);
|
|
1026
|
+
};
|
|
1027
|
+
return { address: publicKey, signMessage };
|
|
1028
|
+
}
|
|
1029
|
+
var SEEKER_ICON = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0OCA0OCI+PHJlY3Qgd2lkdGg9IjQ4IiBoZWlnaHQ9IjQ4IiByeD0iMTAiIGZpbGw9IiMwMDAiLz48dGV4dCB4PSI1MCUiIHk9IjU4JSIgZm9udC1zaXplPSIyMCIgZmlsbD0iI2ZmZiIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZm9udC1mYW1pbHk9InNhbnMtc2VyaWYiIGZvbnQtd2VpZ2h0PSI3MDAiPlM8L3RleHQ+PC9zdmc+";
|
|
1030
|
+
|
|
926
1031
|
// src/components/tabs/wallet-connect.tsx
|
|
927
1032
|
import { Fragment, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
928
1033
|
function MatricaWalletEntry() {
|
|
@@ -963,6 +1068,22 @@ function isMobile() {
|
|
|
963
1068
|
if (typeof navigator === "undefined") return false;
|
|
964
1069
|
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
|
965
1070
|
}
|
|
1071
|
+
function SeekerWalletEntry({ onError }) {
|
|
1072
|
+
const { loginWithWallet } = useForgeConnect();
|
|
1073
|
+
const handleClick = async () => {
|
|
1074
|
+
try {
|
|
1075
|
+
const { address, signMessage } = await connectSeekerBridge();
|
|
1076
|
+
await loginWithWallet(address, signMessage, "solana");
|
|
1077
|
+
} catch (e) {
|
|
1078
|
+
onError(e instanceof Error ? e.message : "Seeker Wallet connection failed.");
|
|
1079
|
+
}
|
|
1080
|
+
};
|
|
1081
|
+
return /* @__PURE__ */ jsxs5("button", { type: "button", className: "fc-btn fc-btn-wallet", onClick: handleClick, children: [
|
|
1082
|
+
/* @__PURE__ */ jsx6("span", { style: { position: "relative", display: "inline-flex" }, children: /* @__PURE__ */ jsx6("img", { src: SEEKER_ICON, alt: "", className: "fc-wallet-icon" }) }),
|
|
1083
|
+
/* @__PURE__ */ jsx6("span", { className: "fc-wallet-name", children: "Seeker Wallet" }),
|
|
1084
|
+
/* @__PURE__ */ jsx6("span", { className: "fc-badge-preferred", children: "Detected" })
|
|
1085
|
+
] });
|
|
1086
|
+
}
|
|
966
1087
|
function WalletConnectForm() {
|
|
967
1088
|
const { walletAdapter, setModalStep, config } = useForgeConnect();
|
|
968
1089
|
const methods = resolveLoginMethods(config);
|
|
@@ -987,12 +1108,26 @@ function WalletConnectForm() {
|
|
|
987
1108
|
] });
|
|
988
1109
|
}
|
|
989
1110
|
function MobileWalletFlow() {
|
|
990
|
-
const { setModalStep, config } = useForgeConnect();
|
|
1111
|
+
const { setModalStep, config, loginWithWallet } = useForgeConnect();
|
|
1112
|
+
const standardWallets = useStandardWallets();
|
|
1113
|
+
const [loading, setLoading] = useState4(false);
|
|
1114
|
+
const [error, setError] = useState4("");
|
|
991
1115
|
const methods = resolveLoginMethods(config);
|
|
992
1116
|
const showBack = methods.length > 1;
|
|
993
1117
|
const walletConfig = config.walletConfig;
|
|
994
1118
|
const preferred = walletConfig?.preferredWallets ?? [];
|
|
995
1119
|
const onlyPreferred = walletConfig?.onlyPreferred ?? false;
|
|
1120
|
+
const handleStandardConnect = async (w) => {
|
|
1121
|
+
setError("");
|
|
1122
|
+
setLoading(true);
|
|
1123
|
+
try {
|
|
1124
|
+
const { address, signMessage } = await connectAndPrepareStandardWallet(w);
|
|
1125
|
+
await loginWithWallet(address, signMessage, "solana");
|
|
1126
|
+
} catch (err) {
|
|
1127
|
+
setError(err instanceof Error ? err.message : `Could not connect ${w.name}.`);
|
|
1128
|
+
setLoading(false);
|
|
1129
|
+
}
|
|
1130
|
+
};
|
|
996
1131
|
const walletsToShow = useMemo(() => {
|
|
997
1132
|
if (preferred.length > 0) {
|
|
998
1133
|
const prefList = preferred.map((name) => MOBILE_WALLETS.find((mw) => mw.name === name)).filter(Boolean);
|
|
@@ -1009,8 +1144,46 @@ function MobileWalletFlow() {
|
|
|
1009
1144
|
};
|
|
1010
1145
|
const showMatrica = methods.includes("matrica");
|
|
1011
1146
|
return /* @__PURE__ */ jsxs5("div", { className: "fc-tab", children: [
|
|
1012
|
-
/* @__PURE__ */ jsxs5("div", {
|
|
1147
|
+
loading && /* @__PURE__ */ jsxs5("div", { style: { textAlign: "center", padding: "24px 0" }, children: [
|
|
1148
|
+
/* @__PURE__ */ jsx6("p", { className: "fc-tab-title", children: "Connecting..." }),
|
|
1149
|
+
/* @__PURE__ */ jsx6("p", { className: "fc-text", children: "Approve in your wallet, then sign the verification request." }),
|
|
1150
|
+
error && /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
1151
|
+
/* @__PURE__ */ jsx6("p", { className: "fc-error", children: error }),
|
|
1152
|
+
/* @__PURE__ */ jsx6(
|
|
1153
|
+
"button",
|
|
1154
|
+
{
|
|
1155
|
+
type: "button",
|
|
1156
|
+
className: "fc-btn fc-btn-secondary",
|
|
1157
|
+
onClick: () => {
|
|
1158
|
+
setLoading(false);
|
|
1159
|
+
setError("");
|
|
1160
|
+
},
|
|
1161
|
+
style: { marginTop: 8 },
|
|
1162
|
+
children: "Try again"
|
|
1163
|
+
}
|
|
1164
|
+
)
|
|
1165
|
+
] })
|
|
1166
|
+
] }),
|
|
1167
|
+
!loading && /* @__PURE__ */ jsxs5("div", { className: "fc-wallet-list", children: [
|
|
1168
|
+
isSeekerApp() && /* @__PURE__ */ jsx6(SeekerWalletEntry, { onError: (m) => {
|
|
1169
|
+
setError(m);
|
|
1170
|
+
setLoading(false);
|
|
1171
|
+
} }),
|
|
1013
1172
|
showMatrica && /* @__PURE__ */ jsx6(MatricaWalletEntry, {}),
|
|
1173
|
+
standardWallets.map((w) => /* @__PURE__ */ jsxs5(
|
|
1174
|
+
"button",
|
|
1175
|
+
{
|
|
1176
|
+
type: "button",
|
|
1177
|
+
className: "fc-btn fc-btn-wallet",
|
|
1178
|
+
onClick: () => handleStandardConnect(w),
|
|
1179
|
+
children: [
|
|
1180
|
+
/* @__PURE__ */ jsx6("span", { style: { position: "relative", display: "inline-flex" }, children: /* @__PURE__ */ jsx6("img", { src: w.icon, alt: "", className: "fc-wallet-icon" }) }),
|
|
1181
|
+
/* @__PURE__ */ jsx6("span", { className: "fc-wallet-name", children: w.name }),
|
|
1182
|
+
/* @__PURE__ */ jsx6("span", { className: "fc-badge-preferred", children: "Detected" })
|
|
1183
|
+
]
|
|
1184
|
+
},
|
|
1185
|
+
`std:${w.name}`
|
|
1186
|
+
)),
|
|
1014
1187
|
walletsToShow.map((mw) => /* @__PURE__ */ jsxs5(
|
|
1015
1188
|
"button",
|
|
1016
1189
|
{
|
|
@@ -1033,13 +1206,17 @@ function MobileWalletFlow() {
|
|
|
1033
1206
|
function WalletAdapterFlow() {
|
|
1034
1207
|
const { walletAdapter, loginWithWallet, setModalStep, config } = useForgeConnect();
|
|
1035
1208
|
const wallet = walletAdapter;
|
|
1209
|
+
const standardWallets = useStandardWallets();
|
|
1036
1210
|
const walletConfig = config.walletConfig;
|
|
1037
1211
|
const methods = resolveLoginMethods(config);
|
|
1038
1212
|
const showBack = methods.length > 1;
|
|
1039
|
-
const [error, setError] =
|
|
1040
|
-
const [loading, setLoading] =
|
|
1041
|
-
const [showOther, setShowOther] =
|
|
1042
|
-
|
|
1213
|
+
const [error, setError] = useState4("");
|
|
1214
|
+
const [loading, setLoading] = useState4(false);
|
|
1215
|
+
const [showOther, setShowOther] = useState4(false);
|
|
1216
|
+
useEffect4(() => {
|
|
1217
|
+
if (isMobile()) setShowOther(true);
|
|
1218
|
+
}, []);
|
|
1219
|
+
const [coldWallet, setColdWallet] = useState4(false);
|
|
1043
1220
|
const mobile = useMemo(() => isMobile(), []);
|
|
1044
1221
|
const coldWalletRef = useRef4(coldWallet);
|
|
1045
1222
|
coldWalletRef.current = coldWallet;
|
|
@@ -1098,21 +1275,42 @@ function WalletAdapterFlow() {
|
|
|
1098
1275
|
const preferredSet = new Set(preferred);
|
|
1099
1276
|
const connectedWalletName = wallet.publicKey ? wallet.wallets.find((w) => w.adapter.connected)?.adapter.name ?? null : null;
|
|
1100
1277
|
const { preferredWallets, otherWallets } = useMemo(() => {
|
|
1101
|
-
const
|
|
1278
|
+
const seenNames = /* @__PURE__ */ new Set();
|
|
1279
|
+
const all = wallet.wallets.filter((w) => {
|
|
1280
|
+
if (seenNames.has(w.adapter.name)) return false;
|
|
1281
|
+
seenNames.add(w.adapter.name);
|
|
1282
|
+
return true;
|
|
1283
|
+
});
|
|
1102
1284
|
const prefList = preferred.map((name) => all.find((w) => w.adapter.name === name)).filter(Boolean);
|
|
1103
1285
|
if (onlyPreferred && preferred.length > 0) {
|
|
1104
1286
|
return { preferredWallets: prefList, otherWallets: [] };
|
|
1105
1287
|
}
|
|
1106
1288
|
const others = all.filter(
|
|
1107
|
-
(w) => !preferredSet.has(w.adapter.name) && w.readyState === "Installed"
|
|
1289
|
+
(w) => !preferredSet.has(w.adapter.name) && (w.readyState === "Installed" || mobile && w.readyState === "Loadable")
|
|
1108
1290
|
);
|
|
1109
1291
|
return { preferredWallets: prefList, otherWallets: others };
|
|
1110
|
-
}, [wallet.wallets, walletConfig]);
|
|
1292
|
+
}, [wallet.wallets, walletConfig, mobile]);
|
|
1111
1293
|
const mobileExtraWallets = useMemo(() => {
|
|
1112
1294
|
if (!mobile) return [];
|
|
1113
1295
|
const adapterNames = new Set(wallet.wallets.map((w) => w.adapter.name));
|
|
1114
|
-
|
|
1115
|
-
|
|
1296
|
+
const stdNames = new Set(standardWallets.map((w) => w.name));
|
|
1297
|
+
return MOBILE_WALLETS.filter((mw) => !adapterNames.has(mw.name) && !stdNames.has(mw.name));
|
|
1298
|
+
}, [mobile, wallet.wallets, standardWallets]);
|
|
1299
|
+
const standardExtras = useMemo(() => {
|
|
1300
|
+
const adapterNames = new Set(wallet.wallets.map((w) => w.adapter.name));
|
|
1301
|
+
return standardWallets.filter((w) => !adapterNames.has(w.name));
|
|
1302
|
+
}, [wallet.wallets, standardWallets]);
|
|
1303
|
+
const handleStandardConnect = async (w) => {
|
|
1304
|
+
setError("");
|
|
1305
|
+
setLoading(true);
|
|
1306
|
+
try {
|
|
1307
|
+
const { address, signMessage } = await connectAndPrepareStandardWallet(w);
|
|
1308
|
+
await loginWithWallet(address, signMessage, "solana");
|
|
1309
|
+
} catch (err) {
|
|
1310
|
+
setError(err instanceof Error ? err.message : `Could not connect ${w.name}.`);
|
|
1311
|
+
setLoading(false);
|
|
1312
|
+
}
|
|
1313
|
+
};
|
|
1116
1314
|
return /* @__PURE__ */ jsxs5("div", { className: "fc-tab", children: [
|
|
1117
1315
|
loading ? /* @__PURE__ */ jsxs5("div", { style: { textAlign: "center", padding: "24px 0" }, children: [
|
|
1118
1316
|
/* @__PURE__ */ jsx6("p", { className: "fc-tab-title", children: "Connecting..." }),
|
|
@@ -1135,6 +1333,10 @@ function WalletAdapterFlow() {
|
|
|
1135
1333
|
] })
|
|
1136
1334
|
] }) : /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
1137
1335
|
/* @__PURE__ */ jsxs5("div", { className: "fc-wallet-list", children: [
|
|
1336
|
+
isSeekerApp() && /* @__PURE__ */ jsx6(SeekerWalletEntry, { onError: (m) => {
|
|
1337
|
+
setError(m);
|
|
1338
|
+
setLoading(false);
|
|
1339
|
+
} }),
|
|
1138
1340
|
methods.includes("matrica") && /* @__PURE__ */ jsx6(MatricaWalletEntry, {}),
|
|
1139
1341
|
preferredWallets.map((w) => {
|
|
1140
1342
|
const installed = w.readyState === "Installed";
|
|
@@ -1155,6 +1357,20 @@ function WalletAdapterFlow() {
|
|
|
1155
1357
|
w.adapter.name
|
|
1156
1358
|
);
|
|
1157
1359
|
}),
|
|
1360
|
+
standardExtras.map((w) => /* @__PURE__ */ jsxs5(
|
|
1361
|
+
"button",
|
|
1362
|
+
{
|
|
1363
|
+
type: "button",
|
|
1364
|
+
className: "fc-btn fc-btn-wallet",
|
|
1365
|
+
onClick: () => handleStandardConnect(w),
|
|
1366
|
+
children: [
|
|
1367
|
+
/* @__PURE__ */ jsx6("span", { style: { position: "relative", display: "inline-flex" }, children: /* @__PURE__ */ jsx6("img", { src: w.icon, alt: "", className: "fc-wallet-icon" }) }),
|
|
1368
|
+
/* @__PURE__ */ jsx6("span", { className: "fc-wallet-name", children: w.name }),
|
|
1369
|
+
/* @__PURE__ */ jsx6("span", { className: "fc-badge-preferred", children: "Detected" })
|
|
1370
|
+
]
|
|
1371
|
+
},
|
|
1372
|
+
`std:${w.name}`
|
|
1373
|
+
)),
|
|
1158
1374
|
mobileExtraWallets.map((mw) => /* @__PURE__ */ jsxs5(
|
|
1159
1375
|
"button",
|
|
1160
1376
|
{
|
|
@@ -1203,7 +1419,7 @@ function WalletAdapterFlow() {
|
|
|
1203
1419
|
);
|
|
1204
1420
|
})
|
|
1205
1421
|
] }),
|
|
1206
|
-
preferredWallets.length === 0 && otherWallets.length === 0 && mobileExtraWallets.length === 0 && /* @__PURE__ */ jsx6("p", { className: "fc-text", children: "No wallet found. Please install a Solana wallet (like Phantom) to continue." }),
|
|
1422
|
+
preferredWallets.length === 0 && otherWallets.length === 0 && mobileExtraWallets.length === 0 && standardExtras.length === 0 && /* @__PURE__ */ jsx6("p", { className: "fc-text", children: "No wallet found. Please install a Solana wallet (like Phantom) to continue." }),
|
|
1207
1423
|
/* @__PURE__ */ jsxs5("label", { className: "fc-cold-wallet-toggle", children: [
|
|
1208
1424
|
/* @__PURE__ */ jsx6(
|
|
1209
1425
|
"input",
|
|
@@ -1226,16 +1442,16 @@ function WalletAdapterFlow() {
|
|
|
1226
1442
|
}
|
|
1227
1443
|
|
|
1228
1444
|
// src/components/tabs/forgot-password.tsx
|
|
1229
|
-
import { useState as
|
|
1445
|
+
import { useState as useState5 } from "react";
|
|
1230
1446
|
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1231
1447
|
function ForgotPasswordForm() {
|
|
1232
1448
|
const { forgotPassword, resetPassword, setModalStep } = useForgeConnect();
|
|
1233
|
-
const [step, setStep] =
|
|
1234
|
-
const [email, setEmail] =
|
|
1235
|
-
const [token, setToken] =
|
|
1236
|
-
const [password, setPassword] =
|
|
1237
|
-
const [error, setError] =
|
|
1238
|
-
const [loading, setLoading] =
|
|
1449
|
+
const [step, setStep] = useState5("email");
|
|
1450
|
+
const [email, setEmail] = useState5("");
|
|
1451
|
+
const [token, setToken] = useState5("");
|
|
1452
|
+
const [password, setPassword] = useState5("");
|
|
1453
|
+
const [error, setError] = useState5("");
|
|
1454
|
+
const [loading, setLoading] = useState5(false);
|
|
1239
1455
|
const handleSendCode = async (e) => {
|
|
1240
1456
|
e.preventDefault();
|
|
1241
1457
|
setError("");
|
|
@@ -1342,17 +1558,17 @@ function ForgotPasswordForm() {
|
|
|
1342
1558
|
}
|
|
1343
1559
|
|
|
1344
1560
|
// src/components/tabs/verify-2fa.tsx
|
|
1345
|
-
import { useState as
|
|
1561
|
+
import { useState as useState6, useRef as useRef5, useEffect as useEffect5, useCallback as useCallback2 } from "react";
|
|
1346
1562
|
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1347
1563
|
function Verify2FAForm() {
|
|
1348
1564
|
const { verify2FA, verifyRecoveryCode, setModalStep } = useForgeConnect();
|
|
1349
|
-
const [code, setCode] =
|
|
1350
|
-
const [loading, setLoading] =
|
|
1351
|
-
const [error, setError] =
|
|
1352
|
-
const [useRecovery, setUseRecovery] =
|
|
1565
|
+
const [code, setCode] = useState6("");
|
|
1566
|
+
const [loading, setLoading] = useState6(false);
|
|
1567
|
+
const [error, setError] = useState6("");
|
|
1568
|
+
const [useRecovery, setUseRecovery] = useState6(false);
|
|
1353
1569
|
const inputRef = useRef5(null);
|
|
1354
1570
|
const submittingRef = useRef5(false);
|
|
1355
|
-
|
|
1571
|
+
useEffect5(() => {
|
|
1356
1572
|
inputRef.current?.focus();
|
|
1357
1573
|
}, [useRecovery]);
|
|
1358
1574
|
const submitCode = useCallback2(async (codeValue, isRecovery) => {
|
|
@@ -1510,8 +1726,8 @@ var LoadingSpinner = () => /* @__PURE__ */ jsx9("div", { className: "fc-method-i
|
|
|
1510
1726
|
function MethodSelect() {
|
|
1511
1727
|
const { setModalStep, loginWithPasskey, config } = useForgeConnect();
|
|
1512
1728
|
const methods = resolveLoginMethods(config);
|
|
1513
|
-
const [passkeyLoading, setPasskeyLoading] =
|
|
1514
|
-
const [passkeyError, setPasskeyError] =
|
|
1729
|
+
const [passkeyLoading, setPasskeyLoading] = useState7(false);
|
|
1730
|
+
const [passkeyError, setPasskeyError] = useState7("");
|
|
1515
1731
|
const handlePasskey = async () => {
|
|
1516
1732
|
setPasskeyLoading(true);
|
|
1517
1733
|
setPasskeyError("");
|
|
@@ -1630,8 +1846,8 @@ var MigrationIcons = {
|
|
|
1630
1846
|
};
|
|
1631
1847
|
function MatricaMigrationView() {
|
|
1632
1848
|
const { matricaMigration, resolveMatricaMigration } = useForgeConnect();
|
|
1633
|
-
const [loading, setLoading] =
|
|
1634
|
-
const [error, setError] =
|
|
1849
|
+
const [loading, setLoading] = useState7(null);
|
|
1850
|
+
const [error, setError] = useState7("");
|
|
1635
1851
|
if (!matricaMigration) return null;
|
|
1636
1852
|
const { conflicts } = matricaMigration;
|
|
1637
1853
|
const total = conflicts.wallets.length + conflicts.socials.length + (conflicts.email ? 1 : 0);
|
|
@@ -1711,14 +1927,14 @@ function SuccessView() {
|
|
|
1711
1927
|
}
|
|
1712
1928
|
|
|
1713
1929
|
// src/components/account-modal.tsx
|
|
1714
|
-
import { useState as
|
|
1930
|
+
import { useState as useState15, useEffect as useEffect11, useRef as useRef7, useCallback as useCallback7 } from "react";
|
|
1715
1931
|
|
|
1716
1932
|
// src/hooks/use-user.ts
|
|
1717
|
-
import { useState as
|
|
1933
|
+
import { useState as useState8, useCallback as useCallback3, useEffect as useEffect6, useRef as useRef6 } from "react";
|
|
1718
1934
|
function useUser() {
|
|
1719
1935
|
const { auth, api, config, getAccessToken } = useForgeConnect();
|
|
1720
|
-
const [authMethods, setAuthMethods] =
|
|
1721
|
-
const [loading, setLoading] =
|
|
1936
|
+
const [authMethods, setAuthMethods] = useState8(null);
|
|
1937
|
+
const [loading, setLoading] = useState8(false);
|
|
1722
1938
|
const pendingRefreshRef = useRef6(false);
|
|
1723
1939
|
const updateProfile = useCallback3(
|
|
1724
1940
|
async (data) => {
|
|
@@ -1791,7 +2007,7 @@ function useUser() {
|
|
|
1791
2007
|
},
|
|
1792
2008
|
[api, config.apiUrl, getAccessToken]
|
|
1793
2009
|
);
|
|
1794
|
-
|
|
2010
|
+
useEffect6(() => {
|
|
1795
2011
|
const handleMessage = (event) => {
|
|
1796
2012
|
if (event.origin !== window.location.origin) return;
|
|
1797
2013
|
if (event.data?.type === "fc_oauth_link_success" && pendingRefreshRef.current) {
|
|
@@ -1818,7 +2034,7 @@ function useUser() {
|
|
|
1818
2034
|
}
|
|
1819
2035
|
|
|
1820
2036
|
// src/hooks/use-wallets.ts
|
|
1821
|
-
import { useState as
|
|
2037
|
+
import { useState as useState9, useCallback as useCallback4 } from "react";
|
|
1822
2038
|
|
|
1823
2039
|
// src/lib/utils.ts
|
|
1824
2040
|
var BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
@@ -1862,8 +2078,8 @@ function timeAgo(dateStr) {
|
|
|
1862
2078
|
// src/hooks/use-wallets.ts
|
|
1863
2079
|
function useWallets() {
|
|
1864
2080
|
const { api, getAccessToken } = useForgeConnect();
|
|
1865
|
-
const [wallets, setWallets] =
|
|
1866
|
-
const [loading, setLoading] =
|
|
2081
|
+
const [wallets, setWallets] = useState9(null);
|
|
2082
|
+
const [loading, setLoading] = useState9(false);
|
|
1867
2083
|
const fetchWallets = useCallback4(async () => {
|
|
1868
2084
|
const token = getAccessToken();
|
|
1869
2085
|
if (!token) throw new Error("Please sign in to continue.");
|
|
@@ -1927,11 +2143,11 @@ function useWallets() {
|
|
|
1927
2143
|
}
|
|
1928
2144
|
|
|
1929
2145
|
// src/hooks/use-sessions.ts
|
|
1930
|
-
import { useState as
|
|
2146
|
+
import { useState as useState10, useCallback as useCallback5 } from "react";
|
|
1931
2147
|
function useSessions() {
|
|
1932
2148
|
const { api, getAccessToken } = useForgeConnect();
|
|
1933
|
-
const [sessions, setSessions] =
|
|
1934
|
-
const [loading, setLoading] =
|
|
2149
|
+
const [sessions, setSessions] = useState10(null);
|
|
2150
|
+
const [loading, setLoading] = useState10(false);
|
|
1935
2151
|
const fetchSessions = useCallback5(async () => {
|
|
1936
2152
|
const token = getAccessToken();
|
|
1937
2153
|
if (!token) throw new Error("Please sign in to continue.");
|
|
@@ -1962,19 +2178,19 @@ function useSessions() {
|
|
|
1962
2178
|
}
|
|
1963
2179
|
|
|
1964
2180
|
// src/components/two-factor-modal.tsx
|
|
1965
|
-
import { useState as
|
|
2181
|
+
import { useState as useState11, useEffect as useEffect7 } from "react";
|
|
1966
2182
|
import { Fragment as Fragment3, jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1967
2183
|
function TwoFactorModal({ isOpen, onClose, initialEnabled, onStatusChange }) {
|
|
1968
2184
|
const { api, getAccessToken, config } = useForgeConnect();
|
|
1969
2185
|
const theme = config.appearance?.theme ?? "light";
|
|
1970
|
-
const [step, setStep] =
|
|
1971
|
-
const [setupData, setSetupData] =
|
|
1972
|
-
const [code, setCode] =
|
|
1973
|
-
const [loading, setLoading] =
|
|
1974
|
-
const [msg, setMsg] =
|
|
1975
|
-
const [showSecret, setShowSecret] =
|
|
1976
|
-
const [recoveryCodes, setRecoveryCodes] =
|
|
1977
|
-
|
|
2186
|
+
const [step, setStep] = useState11(initialEnabled ? "manage" : "setup");
|
|
2187
|
+
const [setupData, setSetupData] = useState11(null);
|
|
2188
|
+
const [code, setCode] = useState11("");
|
|
2189
|
+
const [loading, setLoading] = useState11(false);
|
|
2190
|
+
const [msg, setMsg] = useState11(null);
|
|
2191
|
+
const [showSecret, setShowSecret] = useState11(false);
|
|
2192
|
+
const [recoveryCodes, setRecoveryCodes] = useState11([]);
|
|
2193
|
+
useEffect7(() => {
|
|
1978
2194
|
if (isOpen) {
|
|
1979
2195
|
setStep(initialEnabled ? "manage" : "setup");
|
|
1980
2196
|
setSetupData(null);
|
|
@@ -2238,7 +2454,7 @@ function TwoFactorModal({ isOpen, onClose, initialEnabled, onStatusChange }) {
|
|
|
2238
2454
|
}
|
|
2239
2455
|
|
|
2240
2456
|
// src/components/passkeys-modal.tsx
|
|
2241
|
-
import { useState as
|
|
2457
|
+
import { useState as useState12, useEffect as useEffect8, useCallback as useCallback6 } from "react";
|
|
2242
2458
|
|
|
2243
2459
|
// ../../node_modules/.pnpm/@simplewebauthn+browser@13.2.2/node_modules/@simplewebauthn/browser/esm/helpers/bufferToBase64URLString.js
|
|
2244
2460
|
function bufferToBase64URLString(buffer) {
|
|
@@ -2664,10 +2880,10 @@ import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
|
2664
2880
|
function PasskeysModal({ isOpen, onClose, onCountChange }) {
|
|
2665
2881
|
const { api, getAccessToken, config } = useForgeConnect();
|
|
2666
2882
|
const theme = config.appearance?.theme ?? "light";
|
|
2667
|
-
const [passkeys, setPasskeys] =
|
|
2668
|
-
const [loading, setLoading] =
|
|
2669
|
-
const [addLoading, setAddLoading] =
|
|
2670
|
-
const [msg, setMsg] =
|
|
2883
|
+
const [passkeys, setPasskeys] = useState12([]);
|
|
2884
|
+
const [loading, setLoading] = useState12(false);
|
|
2885
|
+
const [addLoading, setAddLoading] = useState12(false);
|
|
2886
|
+
const [msg, setMsg] = useState12("");
|
|
2671
2887
|
const fetchPasskeys = useCallback6(async () => {
|
|
2672
2888
|
const token = getAccessToken();
|
|
2673
2889
|
if (!token) return;
|
|
@@ -2681,7 +2897,7 @@ function PasskeysModal({ isOpen, onClose, onCountChange }) {
|
|
|
2681
2897
|
setLoading(false);
|
|
2682
2898
|
}
|
|
2683
2899
|
}, [api, getAccessToken, onCountChange]);
|
|
2684
|
-
|
|
2900
|
+
useEffect8(() => {
|
|
2685
2901
|
if (isOpen) {
|
|
2686
2902
|
setMsg("");
|
|
2687
2903
|
fetchPasskeys();
|
|
@@ -2768,7 +2984,7 @@ function PasskeysModal({ isOpen, onClose, onCountChange }) {
|
|
|
2768
2984
|
}
|
|
2769
2985
|
|
|
2770
2986
|
// src/components/password-modal.tsx
|
|
2771
|
-
import { useState as
|
|
2987
|
+
import { useState as useState13, useEffect as useEffect9 } from "react";
|
|
2772
2988
|
|
|
2773
2989
|
// src/components/error-view.tsx
|
|
2774
2990
|
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
@@ -2798,12 +3014,12 @@ import { Fragment as Fragment4, jsx as jsx13, jsxs as jsxs12 } from "react/jsx-r
|
|
|
2798
3014
|
function PasswordModal({ isOpen, onClose, hasPassword }) {
|
|
2799
3015
|
const { api, getAccessToken, config } = useForgeConnect();
|
|
2800
3016
|
const theme = config.appearance?.theme ?? "light";
|
|
2801
|
-
const [step, setStep] =
|
|
2802
|
-
const [currentPassword, setCurrentPassword] =
|
|
2803
|
-
const [newPassword, setNewPassword] =
|
|
2804
|
-
const [loading, setLoading] =
|
|
2805
|
-
const [error, setError] =
|
|
2806
|
-
|
|
3017
|
+
const [step, setStep] = useState13("form");
|
|
3018
|
+
const [currentPassword, setCurrentPassword] = useState13("");
|
|
3019
|
+
const [newPassword, setNewPassword] = useState13("");
|
|
3020
|
+
const [loading, setLoading] = useState13(false);
|
|
3021
|
+
const [error, setError] = useState13("");
|
|
3022
|
+
useEffect9(() => {
|
|
2807
3023
|
if (isOpen) {
|
|
2808
3024
|
setStep("form");
|
|
2809
3025
|
setCurrentPassword("");
|
|
@@ -2899,16 +3115,16 @@ function PasswordModal({ isOpen, onClose, hasPassword }) {
|
|
|
2899
3115
|
}
|
|
2900
3116
|
|
|
2901
3117
|
// src/components/delete-account-modal.tsx
|
|
2902
|
-
import { useState as
|
|
3118
|
+
import { useState as useState14, useEffect as useEffect10 } from "react";
|
|
2903
3119
|
import { Fragment as Fragment5, jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2904
3120
|
function DeleteAccountModal({ isOpen, onClose, onDeleted }) {
|
|
2905
3121
|
const { api, getAccessToken, config, logout } = useForgeConnect();
|
|
2906
3122
|
const theme = config.appearance?.theme ?? "light";
|
|
2907
|
-
const [step, setStep] =
|
|
2908
|
-
const [code, setCode] =
|
|
2909
|
-
const [loading, setLoading] =
|
|
2910
|
-
const [error, setError] =
|
|
2911
|
-
|
|
3123
|
+
const [step, setStep] = useState14("confirm");
|
|
3124
|
+
const [code, setCode] = useState14("");
|
|
3125
|
+
const [loading, setLoading] = useState14(false);
|
|
3126
|
+
const [error, setError] = useState14("");
|
|
3127
|
+
useEffect10(() => {
|
|
2912
3128
|
if (isOpen) {
|
|
2913
3129
|
setStep("confirm");
|
|
2914
3130
|
setCode("");
|
|
@@ -3080,10 +3296,10 @@ var TABS = [
|
|
|
3080
3296
|
function AccountModal() {
|
|
3081
3297
|
const { accountModal, closeAccountModal, openLinkModal, linkModal, config, logout } = useForgeConnect();
|
|
3082
3298
|
const { user } = useUser();
|
|
3083
|
-
const [activeTab, setActiveTab] =
|
|
3084
|
-
const [refreshKey, setRefreshKey] =
|
|
3299
|
+
const [activeTab, setActiveTab] = useState15("profile");
|
|
3300
|
+
const [refreshKey, setRefreshKey] = useState15(0);
|
|
3085
3301
|
const prevLinkOpen = useRef7(false);
|
|
3086
|
-
|
|
3302
|
+
useEffect11(() => {
|
|
3087
3303
|
if (prevLinkOpen.current && !linkModal.isOpen) {
|
|
3088
3304
|
setRefreshKey((k) => k + 1);
|
|
3089
3305
|
}
|
|
@@ -3141,11 +3357,11 @@ function AccountModal() {
|
|
|
3141
3357
|
}
|
|
3142
3358
|
function ProfileTab() {
|
|
3143
3359
|
const { user, updateProfile } = useUser();
|
|
3144
|
-
const [displayName, setDisplayName] =
|
|
3145
|
-
const [avatarUrl, setAvatarUrl] =
|
|
3146
|
-
const [loading, setLoading] =
|
|
3147
|
-
const [msg, setMsg] =
|
|
3148
|
-
|
|
3360
|
+
const [displayName, setDisplayName] = useState15(user?.displayName ?? "");
|
|
3361
|
+
const [avatarUrl, setAvatarUrl] = useState15(user?.avatarUrl ?? "");
|
|
3362
|
+
const [loading, setLoading] = useState15(false);
|
|
3363
|
+
const [msg, setMsg] = useState15(null);
|
|
3364
|
+
useEffect11(() => {
|
|
3149
3365
|
setDisplayName(user?.displayName ?? "");
|
|
3150
3366
|
setAvatarUrl(user?.avatarUrl ?? "");
|
|
3151
3367
|
}, [user]);
|
|
@@ -3195,8 +3411,8 @@ function ProfileTab() {
|
|
|
3195
3411
|
}
|
|
3196
3412
|
function LoginsTab({ onLink, refreshKey }) {
|
|
3197
3413
|
const { authMethods, loading, fetchAuthMethods, unlinkAuthMethod } = useUser();
|
|
3198
|
-
const [msg, setMsg] =
|
|
3199
|
-
|
|
3414
|
+
const [msg, setMsg] = useState15("");
|
|
3415
|
+
useEffect11(() => {
|
|
3200
3416
|
fetchAuthMethods().catch(() => {
|
|
3201
3417
|
});
|
|
3202
3418
|
}, [fetchAuthMethods, refreshKey]);
|
|
@@ -3233,8 +3449,8 @@ function LoginsTab({ onLink, refreshKey }) {
|
|
|
3233
3449
|
}
|
|
3234
3450
|
function WalletsTab({ onLink, refreshKey }) {
|
|
3235
3451
|
const { wallets, loading, fetchWallets, updateWallet } = useWallets();
|
|
3236
|
-
const [msg, setMsg] =
|
|
3237
|
-
|
|
3452
|
+
const [msg, setMsg] = useState15("");
|
|
3453
|
+
useEffect11(() => {
|
|
3238
3454
|
fetchWallets().catch(() => {
|
|
3239
3455
|
});
|
|
3240
3456
|
}, [fetchWallets, refreshKey]);
|
|
@@ -3269,13 +3485,13 @@ function SecurityTab() {
|
|
|
3269
3485
|
const { sessions, loading, fetchSessions, revokeSession } = useSessions();
|
|
3270
3486
|
const { logoutAll, logout, closeAccountModal, api, getAccessToken } = useForgeConnect();
|
|
3271
3487
|
const { user, authMethods: userAuthMethods, fetchAuthMethods } = useUser();
|
|
3272
|
-
const [msg, setMsg] =
|
|
3273
|
-
const [totpEnabled, setTotpEnabled] =
|
|
3274
|
-
const [passkeyCount, setPasskeyCount] =
|
|
3275
|
-
const [show2FAModal, setShow2FAModal] =
|
|
3276
|
-
const [showPasskeyModal, setShowPasskeyModal] =
|
|
3277
|
-
const [showPasswordModal, setShowPasswordModal] =
|
|
3278
|
-
const [showDeleteModal, setShowDeleteModal] =
|
|
3488
|
+
const [msg, setMsg] = useState15("");
|
|
3489
|
+
const [totpEnabled, setTotpEnabled] = useState15(null);
|
|
3490
|
+
const [passkeyCount, setPasskeyCount] = useState15(0);
|
|
3491
|
+
const [show2FAModal, setShow2FAModal] = useState15(false);
|
|
3492
|
+
const [showPasskeyModal, setShowPasskeyModal] = useState15(false);
|
|
3493
|
+
const [showPasswordModal, setShowPasswordModal] = useState15(false);
|
|
3494
|
+
const [showDeleteModal, setShowDeleteModal] = useState15(false);
|
|
3279
3495
|
const refreshStatus = useCallback7(() => {
|
|
3280
3496
|
const token = getAccessToken();
|
|
3281
3497
|
if (!token) return;
|
|
@@ -3288,7 +3504,7 @@ function SecurityTab() {
|
|
|
3288
3504
|
api.getPasskeys(token).then((list) => setPasskeyCount(list.length)).catch(() => {
|
|
3289
3505
|
});
|
|
3290
3506
|
}, [api, getAccessToken]);
|
|
3291
|
-
|
|
3507
|
+
useEffect11(() => {
|
|
3292
3508
|
fetchSessions().catch(() => {
|
|
3293
3509
|
});
|
|
3294
3510
|
fetchAuthMethods().catch(() => {
|
|
@@ -3441,21 +3657,21 @@ function SecurityTab() {
|
|
|
3441
3657
|
}
|
|
3442
3658
|
|
|
3443
3659
|
// src/components/link-auth-modal.tsx
|
|
3444
|
-
import { useState as
|
|
3660
|
+
import { useState as useState16, useEffect as useEffect12, useMemo as useMemo2, useRef as useRef8, useCallback as useCallback8 } from "react";
|
|
3445
3661
|
import { Fragment as Fragment6, jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3446
3662
|
function LinkAuthModal() {
|
|
3447
3663
|
const { linkModal, closeLinkModal, config } = useForgeConnect();
|
|
3448
3664
|
const { linkOAuth, authMethods } = useUser();
|
|
3449
3665
|
const mode = linkModal.mode ?? "auth";
|
|
3450
|
-
const [step, setStep] =
|
|
3451
|
-
const [fatalError, setFatalError] =
|
|
3452
|
-
|
|
3666
|
+
const [step, setStep] = useState16("method-select");
|
|
3667
|
+
const [fatalError, setFatalError] = useState16("");
|
|
3668
|
+
useEffect12(() => {
|
|
3453
3669
|
if (linkModal.isOpen) {
|
|
3454
3670
|
setStep(mode === "wallet" ? "wallet" : "method-select");
|
|
3455
3671
|
setFatalError("");
|
|
3456
3672
|
}
|
|
3457
3673
|
}, [linkModal.isOpen, mode]);
|
|
3458
|
-
|
|
3674
|
+
useEffect12(() => {
|
|
3459
3675
|
if (!linkModal.isOpen) return;
|
|
3460
3676
|
const handleMessage = (event) => {
|
|
3461
3677
|
if (event.origin !== window.location.origin) return;
|
|
@@ -3606,10 +3822,10 @@ function AuthMethodSelectStep({
|
|
|
3606
3822
|
}
|
|
3607
3823
|
function EmailLinkStep({ onBack, onSuccess, onFatalError }) {
|
|
3608
3824
|
const { linkAuthMethod } = useUser();
|
|
3609
|
-
const [email, setEmail] =
|
|
3610
|
-
const [password, setPassword] =
|
|
3611
|
-
const [loading, setLoading] =
|
|
3612
|
-
const [error, setError] =
|
|
3825
|
+
const [email, setEmail] = useState16("");
|
|
3826
|
+
const [password, setPassword] = useState16("");
|
|
3827
|
+
const [loading, setLoading] = useState16(false);
|
|
3828
|
+
const [error, setError] = useState16("");
|
|
3613
3829
|
const handleSubmit = async (e) => {
|
|
3614
3830
|
e.preventDefault();
|
|
3615
3831
|
setLoading(true);
|
|
@@ -3641,11 +3857,11 @@ function EmailLinkStep({ onBack, onSuccess, onFatalError }) {
|
|
|
3641
3857
|
}
|
|
3642
3858
|
function OtpLinkStep({ onBack, onSuccess, onFatalError }) {
|
|
3643
3859
|
const { linkOtpSend, linkOtpVerify } = useUser();
|
|
3644
|
-
const [email, setEmail] =
|
|
3645
|
-
const [code, setCode] =
|
|
3646
|
-
const [codeSent, setCodeSent] =
|
|
3647
|
-
const [loading, setLoading] =
|
|
3648
|
-
const [error, setError] =
|
|
3860
|
+
const [email, setEmail] = useState16("");
|
|
3861
|
+
const [code, setCode] = useState16("");
|
|
3862
|
+
const [codeSent, setCodeSent] = useState16(false);
|
|
3863
|
+
const [loading, setLoading] = useState16(false);
|
|
3864
|
+
const [error, setError] = useState16("");
|
|
3649
3865
|
const handleSendCode = async (e) => {
|
|
3650
3866
|
e.preventDefault();
|
|
3651
3867
|
setLoading(true);
|
|
@@ -3722,10 +3938,10 @@ function OtpLinkStep({ onBack, onSuccess, onFatalError }) {
|
|
|
3722
3938
|
function WalletLinkStep({ onBack, onSuccess, onFatalError }) {
|
|
3723
3939
|
const { walletAdapter, config } = useForgeConnect();
|
|
3724
3940
|
const { linkWallet } = useWallets();
|
|
3725
|
-
const [loading, setLoading] =
|
|
3726
|
-
const [error, setError] =
|
|
3727
|
-
const [showOther, setShowOther] =
|
|
3728
|
-
const [coldWallet, setColdWallet] =
|
|
3941
|
+
const [loading, setLoading] = useState16(false);
|
|
3942
|
+
const [error, setError] = useState16("");
|
|
3943
|
+
const [showOther, setShowOther] = useState16(false);
|
|
3944
|
+
const [coldWallet, setColdWallet] = useState16(false);
|
|
3729
3945
|
const mobile = useMemo2(() => isMobile(), []);
|
|
3730
3946
|
const walletConfig = config.walletConfig;
|
|
3731
3947
|
const preferred = walletConfig?.preferredWallets ?? [];
|
|
@@ -3916,23 +4132,72 @@ function SuccessView2() {
|
|
|
3916
4132
|
] });
|
|
3917
4133
|
}
|
|
3918
4134
|
|
|
4135
|
+
// src/register-mwa.ts
|
|
4136
|
+
var registered = false;
|
|
4137
|
+
async function registerMwaIfAvailable(config, opts) {
|
|
4138
|
+
if (typeof window === "undefined") return;
|
|
4139
|
+
if (registered) return;
|
|
4140
|
+
if (opts?.enabled === false) return;
|
|
4141
|
+
let mod;
|
|
4142
|
+
try {
|
|
4143
|
+
mod = await import("@solana-mobile/wallet-standard-mobile");
|
|
4144
|
+
} catch (err) {
|
|
4145
|
+
console.warn("[ForgeConnect/MWA] dynamic import failed", err);
|
|
4146
|
+
return;
|
|
4147
|
+
}
|
|
4148
|
+
const {
|
|
4149
|
+
registerMwa,
|
|
4150
|
+
createDefaultAuthorizationCache,
|
|
4151
|
+
createDefaultChainSelector,
|
|
4152
|
+
createDefaultWalletNotFoundHandler
|
|
4153
|
+
} = mod;
|
|
4154
|
+
const origin = window.location.origin;
|
|
4155
|
+
const identity = opts?.appIdentity ?? {};
|
|
4156
|
+
const appName = identity.name ?? config.appearance?.title ?? (typeof document !== "undefined" ? document.title : "") ?? "App";
|
|
4157
|
+
registered = true;
|
|
4158
|
+
try {
|
|
4159
|
+
registerMwa({
|
|
4160
|
+
appIdentity: {
|
|
4161
|
+
name: appName,
|
|
4162
|
+
uri: identity.uri ?? origin,
|
|
4163
|
+
icon: identity.icon
|
|
4164
|
+
},
|
|
4165
|
+
authorizationCache: createDefaultAuthorizationCache(),
|
|
4166
|
+
chains: opts?.chains ?? ["solana:mainnet"],
|
|
4167
|
+
chainSelector: createDefaultChainSelector(),
|
|
4168
|
+
onWalletNotFound: createDefaultWalletNotFoundHandler()
|
|
4169
|
+
});
|
|
4170
|
+
console.log("[ForgeConnect/MWA] registered. appIdentity:", { name: appName, uri: identity.uri ?? origin });
|
|
4171
|
+
try {
|
|
4172
|
+
const { getWallets } = await import("@wallet-standard/app");
|
|
4173
|
+
const list = getWallets().get();
|
|
4174
|
+
console.log("[ForgeConnect/MWA] standard wallets after register:", list.map((w) => w.name));
|
|
4175
|
+
} catch (e) {
|
|
4176
|
+
console.warn("[ForgeConnect/MWA] could not enumerate standard wallets", e);
|
|
4177
|
+
}
|
|
4178
|
+
} catch (err) {
|
|
4179
|
+
registered = false;
|
|
4180
|
+
console.warn("[ForgeConnect/MWA] registerMwa threw:", err);
|
|
4181
|
+
}
|
|
4182
|
+
}
|
|
4183
|
+
|
|
3919
4184
|
// src/provider.tsx
|
|
3920
4185
|
import { jsx as jsx17, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
3921
4186
|
var oauthExchangeCache = /* @__PURE__ */ new Map();
|
|
3922
4187
|
function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapter }) {
|
|
3923
|
-
const [auth, setAuth] =
|
|
4188
|
+
const [auth, setAuth] = useState17({
|
|
3924
4189
|
status: "loading",
|
|
3925
4190
|
user: null,
|
|
3926
4191
|
accessToken: null
|
|
3927
4192
|
});
|
|
3928
|
-
const [modal, setModal] =
|
|
4193
|
+
const [modal, setModal] = useState17({
|
|
3929
4194
|
isOpen: false,
|
|
3930
4195
|
step: "method-select"
|
|
3931
4196
|
});
|
|
3932
|
-
const [accountModal, setAccountModal] =
|
|
3933
|
-
const [linkModal, setLinkModal] =
|
|
3934
|
-
const [challengeToken, setChallengeToken] =
|
|
3935
|
-
const [matricaMigration, setMatricaMigration] =
|
|
4197
|
+
const [accountModal, setAccountModal] = useState17({ isOpen: false });
|
|
4198
|
+
const [linkModal, setLinkModal] = useState17({ isOpen: false });
|
|
4199
|
+
const [challengeToken, setChallengeToken] = useState17(null);
|
|
4200
|
+
const [matricaMigration, setMatricaMigration] = useState17(null);
|
|
3936
4201
|
const apiRef = useRef9(createApiClient(config.apiUrl));
|
|
3937
4202
|
const refreshTimerRef = useRef9(null);
|
|
3938
4203
|
const api = apiRef.current;
|
|
@@ -3950,7 +4215,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
3950
4215
|
}
|
|
3951
4216
|
}, delay);
|
|
3952
4217
|
}, [api]);
|
|
3953
|
-
|
|
4218
|
+
useEffect13(() => {
|
|
3954
4219
|
const init = async () => {
|
|
3955
4220
|
try {
|
|
3956
4221
|
const { accessToken } = await api.refresh();
|
|
@@ -3966,7 +4231,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
3966
4231
|
if (refreshTimerRef.current) clearTimeout(refreshTimerRef.current);
|
|
3967
4232
|
};
|
|
3968
4233
|
}, [api, scheduleRefresh]);
|
|
3969
|
-
|
|
4234
|
+
useEffect13(() => {
|
|
3970
4235
|
if (window.location.pathname === "/fc-oauth-callback") {
|
|
3971
4236
|
const params = new URLSearchParams(window.location.search);
|
|
3972
4237
|
if (params.get("fc_link_success") && window.opener) {
|
|
@@ -4094,7 +4359,12 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4094
4359
|
window.removeEventListener("storage", handleStorage);
|
|
4095
4360
|
};
|
|
4096
4361
|
}, [api, config.apiUrl, scheduleRefresh, onLogin]);
|
|
4097
|
-
|
|
4362
|
+
useEffect13(() => {
|
|
4363
|
+
const methods = resolveLoginMethods(config);
|
|
4364
|
+
if (!methods.includes("wallet")) return;
|
|
4365
|
+
void registerMwaIfAvailable(config, config.mwa);
|
|
4366
|
+
}, [config]);
|
|
4367
|
+
useEffect13(() => {
|
|
4098
4368
|
if (config.loginMethods && config.loginMethods.length > 0) {
|
|
4099
4369
|
const hasLegacy = config.oauthProviders || config.walletLogin !== void 0 || config.passwordlessLogin !== void 0;
|
|
4100
4370
|
if (hasLegacy) {
|
|
@@ -4433,13 +4703,13 @@ function AccountButton({ className, loginLabel, compact }) {
|
|
|
4433
4703
|
}
|
|
4434
4704
|
|
|
4435
4705
|
// src/hooks/use-admin.ts
|
|
4436
|
-
import { useState as
|
|
4706
|
+
import { useState as useState18, useCallback as useCallback10 } from "react";
|
|
4437
4707
|
function useAdmin() {
|
|
4438
4708
|
const { api, getAccessToken } = useForgeConnect();
|
|
4439
|
-
const [users, setUsers] =
|
|
4440
|
-
const [selectedUser, setSelectedUser] =
|
|
4441
|
-
const [userSessions, setUserSessions] =
|
|
4442
|
-
const [loading, setLoading] =
|
|
4709
|
+
const [users, setUsers] = useState18(null);
|
|
4710
|
+
const [selectedUser, setSelectedUser] = useState18(null);
|
|
4711
|
+
const [userSessions, setUserSessions] = useState18(null);
|
|
4712
|
+
const [loading, setLoading] = useState18(false);
|
|
4443
4713
|
const listUsers = useCallback10(
|
|
4444
4714
|
async (params) => {
|
|
4445
4715
|
const token = getAccessToken();
|
|
@@ -4519,16 +4789,16 @@ function useAdmin() {
|
|
|
4519
4789
|
}
|
|
4520
4790
|
|
|
4521
4791
|
// src/hooks/use-roles.ts
|
|
4522
|
-
import { useState as
|
|
4792
|
+
import { useState as useState19, useCallback as useCallback11 } from "react";
|
|
4523
4793
|
function useRoles() {
|
|
4524
4794
|
const { api, getAccessToken } = useForgeConnect();
|
|
4525
|
-
const [roles, setRoles] =
|
|
4526
|
-
const [selectedRole, setSelectedRole] =
|
|
4527
|
-
const [userRoleAssignments, setUserRoleAssignments] =
|
|
4528
|
-
const [roleUsers, setRoleUsers] =
|
|
4529
|
-
const [permissionDomains, setPermissionDomains] =
|
|
4530
|
-
const [myPermissions, setMyPermissions] =
|
|
4531
|
-
const [loading, setLoading] =
|
|
4795
|
+
const [roles, setRoles] = useState19(null);
|
|
4796
|
+
const [selectedRole, setSelectedRole] = useState19(null);
|
|
4797
|
+
const [userRoleAssignments, setUserRoleAssignments] = useState19(null);
|
|
4798
|
+
const [roleUsers, setRoleUsers] = useState19(null);
|
|
4799
|
+
const [permissionDomains, setPermissionDomains] = useState19(null);
|
|
4800
|
+
const [myPermissions, setMyPermissions] = useState19([]);
|
|
4801
|
+
const [loading, setLoading] = useState19(false);
|
|
4532
4802
|
const listRoles = useCallback11(
|
|
4533
4803
|
async (tenantId) => {
|
|
4534
4804
|
const token = getAccessToken();
|
|
@@ -4712,11 +4982,14 @@ export {
|
|
|
4712
4982
|
ModalOverlay,
|
|
4713
4983
|
PasskeysModal,
|
|
4714
4984
|
TwoFactorModal,
|
|
4985
|
+
connectSeekerBridge,
|
|
4715
4986
|
createApiClient,
|
|
4716
4987
|
hasAllPermissions,
|
|
4717
4988
|
hasAnyPermission,
|
|
4718
4989
|
hasPermission,
|
|
4719
4990
|
isOAuthMethod,
|
|
4991
|
+
isSeekerApp,
|
|
4992
|
+
registerMwaIfAvailable,
|
|
4720
4993
|
resolveLoginMethods,
|
|
4721
4994
|
useAdmin,
|
|
4722
4995
|
useForgeConnect,
|