@forge-connect/react 1.0.13 → 1.0.16
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 +296 -95
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +332 -131
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/provider.tsx
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/provider.tsx
|
|
2
2
|
var _react = require('react');
|
|
3
3
|
|
|
4
4
|
// src/context.ts
|
|
@@ -923,6 +923,65 @@ function OAuthButton({ provider }) {
|
|
|
923
923
|
);
|
|
924
924
|
}
|
|
925
925
|
|
|
926
|
+
// src/hooks/use-standard-wallets.ts
|
|
927
|
+
|
|
928
|
+
function useStandardWallets() {
|
|
929
|
+
const [wallets, setWallets] = _react.useState.call(void 0, []);
|
|
930
|
+
_react.useEffect.call(void 0, () => {
|
|
931
|
+
if (typeof window === "undefined") return;
|
|
932
|
+
let unsubRegister;
|
|
933
|
+
let unsubUnregister;
|
|
934
|
+
let cancelled = false;
|
|
935
|
+
(async () => {
|
|
936
|
+
try {
|
|
937
|
+
const { getWallets } = await Promise.resolve().then(() => _interopRequireWildcard(require("@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 (e6) {
|
|
956
|
+
}
|
|
957
|
+
})();
|
|
958
|
+
return () => {
|
|
959
|
+
cancelled = true;
|
|
960
|
+
_optionalChain([unsubRegister, 'optionalCall', _13 => _13()]);
|
|
961
|
+
_optionalChain([unsubUnregister, 'optionalCall', _14 => _14()]);
|
|
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
|
+
|
|
926
985
|
// src/components/tabs/wallet-connect.tsx
|
|
927
986
|
|
|
928
987
|
function MatricaWalletEntry() {
|
|
@@ -987,12 +1046,26 @@ function WalletConnectForm() {
|
|
|
987
1046
|
] });
|
|
988
1047
|
}
|
|
989
1048
|
function MobileWalletFlow() {
|
|
990
|
-
const { setModalStep, config } = useForgeConnect();
|
|
1049
|
+
const { setModalStep, config, loginWithWallet } = useForgeConnect();
|
|
1050
|
+
const standardWallets = useStandardWallets();
|
|
1051
|
+
const [loading, setLoading] = _react.useState.call(void 0, false);
|
|
1052
|
+
const [error, setError] = _react.useState.call(void 0, "");
|
|
991
1053
|
const methods = resolveLoginMethods(config);
|
|
992
1054
|
const showBack = methods.length > 1;
|
|
993
1055
|
const walletConfig = config.walletConfig;
|
|
994
|
-
const preferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess',
|
|
995
|
-
const onlyPreferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess',
|
|
1056
|
+
const preferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess', _15 => _15.preferredWallets]), () => ( []));
|
|
1057
|
+
const onlyPreferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess', _16 => _16.onlyPreferred]), () => ( false));
|
|
1058
|
+
const handleStandardConnect = async (w) => {
|
|
1059
|
+
setError("");
|
|
1060
|
+
setLoading(true);
|
|
1061
|
+
try {
|
|
1062
|
+
const { address, signMessage } = await connectAndPrepareStandardWallet(w);
|
|
1063
|
+
await loginWithWallet(address, signMessage, "solana");
|
|
1064
|
+
} catch (err) {
|
|
1065
|
+
setError(err instanceof Error ? err.message : `Could not connect ${w.name}.`);
|
|
1066
|
+
setLoading(false);
|
|
1067
|
+
}
|
|
1068
|
+
};
|
|
996
1069
|
const walletsToShow = _react.useMemo.call(void 0, () => {
|
|
997
1070
|
if (preferred.length > 0) {
|
|
998
1071
|
const prefList = preferred.map((name) => MOBILE_WALLETS.find((mw) => mw.name === name)).filter(Boolean);
|
|
@@ -1009,8 +1082,42 @@ function MobileWalletFlow() {
|
|
|
1009
1082
|
};
|
|
1010
1083
|
const showMatrica = methods.includes("matrica");
|
|
1011
1084
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-tab", children: [
|
|
1012
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", {
|
|
1085
|
+
loading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { style: { textAlign: "center", padding: "24px 0" }, children: [
|
|
1086
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-tab-title", children: "Connecting..." }),
|
|
1087
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-text", children: "Approve in your wallet, then sign the verification request." }),
|
|
1088
|
+
error && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1089
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-error", children: error }),
|
|
1090
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1091
|
+
"button",
|
|
1092
|
+
{
|
|
1093
|
+
type: "button",
|
|
1094
|
+
className: "fc-btn fc-btn-secondary",
|
|
1095
|
+
onClick: () => {
|
|
1096
|
+
setLoading(false);
|
|
1097
|
+
setError("");
|
|
1098
|
+
},
|
|
1099
|
+
style: { marginTop: 8 },
|
|
1100
|
+
children: "Try again"
|
|
1101
|
+
}
|
|
1102
|
+
)
|
|
1103
|
+
] })
|
|
1104
|
+
] }),
|
|
1105
|
+
!loading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-wallet-list", children: [
|
|
1013
1106
|
showMatrica && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MatricaWalletEntry, {}),
|
|
1107
|
+
standardWallets.map((w) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1108
|
+
"button",
|
|
1109
|
+
{
|
|
1110
|
+
type: "button",
|
|
1111
|
+
className: "fc-btn fc-btn-wallet",
|
|
1112
|
+
onClick: () => handleStandardConnect(w),
|
|
1113
|
+
children: [
|
|
1114
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { style: { position: "relative", display: "inline-flex" }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "img", { src: w.icon, alt: "", className: "fc-wallet-icon" }) }),
|
|
1115
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-wallet-name", children: w.name }),
|
|
1116
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-badge-preferred", children: "Detected" })
|
|
1117
|
+
]
|
|
1118
|
+
},
|
|
1119
|
+
`std:${w.name}`
|
|
1120
|
+
)),
|
|
1014
1121
|
walletsToShow.map((mw) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1015
1122
|
"button",
|
|
1016
1123
|
{
|
|
@@ -1033,19 +1140,23 @@ function MobileWalletFlow() {
|
|
|
1033
1140
|
function WalletAdapterFlow() {
|
|
1034
1141
|
const { walletAdapter, loginWithWallet, setModalStep, config } = useForgeConnect();
|
|
1035
1142
|
const wallet = walletAdapter;
|
|
1143
|
+
const standardWallets = useStandardWallets();
|
|
1036
1144
|
const walletConfig = config.walletConfig;
|
|
1037
1145
|
const methods = resolveLoginMethods(config);
|
|
1038
1146
|
const showBack = methods.length > 1;
|
|
1039
1147
|
const [error, setError] = _react.useState.call(void 0, "");
|
|
1040
1148
|
const [loading, setLoading] = _react.useState.call(void 0, false);
|
|
1041
1149
|
const [showOther, setShowOther] = _react.useState.call(void 0, false);
|
|
1150
|
+
_react.useEffect.call(void 0, () => {
|
|
1151
|
+
if (isMobile()) setShowOther(true);
|
|
1152
|
+
}, []);
|
|
1042
1153
|
const [coldWallet, setColdWallet] = _react.useState.call(void 0, false);
|
|
1043
1154
|
const mobile = _react.useMemo.call(void 0, () => isMobile(), []);
|
|
1044
1155
|
const coldWalletRef = _react.useRef.call(void 0, coldWallet);
|
|
1045
1156
|
coldWalletRef.current = coldWallet;
|
|
1046
1157
|
const buildSignTxFnForAdapter = _react.useCallback.call(void 0, (adapter) => {
|
|
1047
1158
|
if (!adapter.signTransaction) return void 0;
|
|
1048
|
-
const TxClass = _optionalChain([walletConfig, 'optionalAccess',
|
|
1159
|
+
const TxClass = _optionalChain([walletConfig, 'optionalAccess', _17 => _17.Transaction]);
|
|
1049
1160
|
if (!TxClass) return void 0;
|
|
1050
1161
|
return async (txBase64) => {
|
|
1051
1162
|
const bytes = Uint8Array.from(atob(txBase64), (c) => c.charCodeAt(0));
|
|
@@ -1053,7 +1164,7 @@ function WalletAdapterFlow() {
|
|
|
1053
1164
|
const signedTx = await adapter.signTransaction(tx);
|
|
1054
1165
|
return btoa(String.fromCharCode(...new Uint8Array(signedTx.serialize())));
|
|
1055
1166
|
};
|
|
1056
|
-
}, [_optionalChain([walletConfig, 'optionalAccess',
|
|
1167
|
+
}, [_optionalChain([walletConfig, 'optionalAccess', _18 => _18.Transaction])]);
|
|
1057
1168
|
const handleConnect = async (w) => {
|
|
1058
1169
|
if (w.readyState !== "Installed") {
|
|
1059
1170
|
if (mobile) {
|
|
@@ -1093,26 +1204,47 @@ function WalletAdapterFlow() {
|
|
|
1093
1204
|
const handleMobileOpen = (mw) => {
|
|
1094
1205
|
window.location.href = mw.buildUrl(window.location.href);
|
|
1095
1206
|
};
|
|
1096
|
-
const preferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess',
|
|
1097
|
-
const onlyPreferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess',
|
|
1207
|
+
const preferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess', _19 => _19.preferredWallets]), () => ( []));
|
|
1208
|
+
const onlyPreferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess', _20 => _20.onlyPreferred]), () => ( false));
|
|
1098
1209
|
const preferredSet = new Set(preferred);
|
|
1099
|
-
const connectedWalletName = wallet.publicKey ? _nullishCoalesce(_optionalChain([wallet, 'access',
|
|
1210
|
+
const connectedWalletName = wallet.publicKey ? _nullishCoalesce(_optionalChain([wallet, 'access', _21 => _21.wallets, 'access', _22 => _22.find, 'call', _23 => _23((w) => w.adapter.connected), 'optionalAccess', _24 => _24.adapter, 'access', _25 => _25.name]), () => ( null)) : null;
|
|
1100
1211
|
const { preferredWallets, otherWallets } = _react.useMemo.call(void 0, () => {
|
|
1101
|
-
const
|
|
1212
|
+
const seenNames = /* @__PURE__ */ new Set();
|
|
1213
|
+
const all = wallet.wallets.filter((w) => {
|
|
1214
|
+
if (seenNames.has(w.adapter.name)) return false;
|
|
1215
|
+
seenNames.add(w.adapter.name);
|
|
1216
|
+
return true;
|
|
1217
|
+
});
|
|
1102
1218
|
const prefList = preferred.map((name) => all.find((w) => w.adapter.name === name)).filter(Boolean);
|
|
1103
1219
|
if (onlyPreferred && preferred.length > 0) {
|
|
1104
1220
|
return { preferredWallets: prefList, otherWallets: [] };
|
|
1105
1221
|
}
|
|
1106
1222
|
const others = all.filter(
|
|
1107
|
-
(w) => !preferredSet.has(w.adapter.name) && w.readyState === "Installed"
|
|
1223
|
+
(w) => !preferredSet.has(w.adapter.name) && (w.readyState === "Installed" || mobile && w.readyState === "Loadable")
|
|
1108
1224
|
);
|
|
1109
1225
|
return { preferredWallets: prefList, otherWallets: others };
|
|
1110
|
-
}, [wallet.wallets, walletConfig]);
|
|
1226
|
+
}, [wallet.wallets, walletConfig, mobile]);
|
|
1111
1227
|
const mobileExtraWallets = _react.useMemo.call(void 0, () => {
|
|
1112
1228
|
if (!mobile) return [];
|
|
1113
1229
|
const adapterNames = new Set(wallet.wallets.map((w) => w.adapter.name));
|
|
1114
|
-
|
|
1115
|
-
|
|
1230
|
+
const stdNames = new Set(standardWallets.map((w) => w.name));
|
|
1231
|
+
return MOBILE_WALLETS.filter((mw) => !adapterNames.has(mw.name) && !stdNames.has(mw.name));
|
|
1232
|
+
}, [mobile, wallet.wallets, standardWallets]);
|
|
1233
|
+
const standardExtras = _react.useMemo.call(void 0, () => {
|
|
1234
|
+
const adapterNames = new Set(wallet.wallets.map((w) => w.adapter.name));
|
|
1235
|
+
return standardWallets.filter((w) => !adapterNames.has(w.name));
|
|
1236
|
+
}, [wallet.wallets, standardWallets]);
|
|
1237
|
+
const handleStandardConnect = async (w) => {
|
|
1238
|
+
setError("");
|
|
1239
|
+
setLoading(true);
|
|
1240
|
+
try {
|
|
1241
|
+
const { address, signMessage } = await connectAndPrepareStandardWallet(w);
|
|
1242
|
+
await loginWithWallet(address, signMessage, "solana");
|
|
1243
|
+
} catch (err) {
|
|
1244
|
+
setError(err instanceof Error ? err.message : `Could not connect ${w.name}.`);
|
|
1245
|
+
setLoading(false);
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1116
1248
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-tab", children: [
|
|
1117
1249
|
loading ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { style: { textAlign: "center", padding: "24px 0" }, children: [
|
|
1118
1250
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-tab-title", children: "Connecting..." }),
|
|
@@ -1155,6 +1287,20 @@ function WalletAdapterFlow() {
|
|
|
1155
1287
|
w.adapter.name
|
|
1156
1288
|
);
|
|
1157
1289
|
}),
|
|
1290
|
+
standardExtras.map((w) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1291
|
+
"button",
|
|
1292
|
+
{
|
|
1293
|
+
type: "button",
|
|
1294
|
+
className: "fc-btn fc-btn-wallet",
|
|
1295
|
+
onClick: () => handleStandardConnect(w),
|
|
1296
|
+
children: [
|
|
1297
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { style: { position: "relative", display: "inline-flex" }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "img", { src: w.icon, alt: "", className: "fc-wallet-icon" }) }),
|
|
1298
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-wallet-name", children: w.name }),
|
|
1299
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-badge-preferred", children: "Detected" })
|
|
1300
|
+
]
|
|
1301
|
+
},
|
|
1302
|
+
`std:${w.name}`
|
|
1303
|
+
)),
|
|
1158
1304
|
mobileExtraWallets.map((mw) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1159
1305
|
"button",
|
|
1160
1306
|
{
|
|
@@ -1203,7 +1349,7 @@ function WalletAdapterFlow() {
|
|
|
1203
1349
|
);
|
|
1204
1350
|
})
|
|
1205
1351
|
] }),
|
|
1206
|
-
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." }),
|
|
1352
|
+
preferredWallets.length === 0 && otherWallets.length === 0 && mobileExtraWallets.length === 0 && standardExtras.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." }),
|
|
1207
1353
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { className: "fc-cold-wallet-toggle", children: [
|
|
1208
1354
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1209
1355
|
"input",
|
|
@@ -1353,7 +1499,7 @@ function Verify2FAForm() {
|
|
|
1353
1499
|
const inputRef = _react.useRef.call(void 0, null);
|
|
1354
1500
|
const submittingRef = _react.useRef.call(void 0, false);
|
|
1355
1501
|
_react.useEffect.call(void 0, () => {
|
|
1356
|
-
_optionalChain([inputRef, 'access',
|
|
1502
|
+
_optionalChain([inputRef, 'access', _26 => _26.current, 'optionalAccess', _27 => _27.focus, 'call', _28 => _28()]);
|
|
1357
1503
|
}, [useRecovery]);
|
|
1358
1504
|
const submitCode = _react.useCallback.call(void 0, async (codeValue, isRecovery) => {
|
|
1359
1505
|
if (submittingRef.current || !codeValue.trim()) return;
|
|
@@ -1374,7 +1520,7 @@ function Verify2FAForm() {
|
|
|
1374
1520
|
}
|
|
1375
1521
|
}, [verify2FA, verifyRecoveryCode]);
|
|
1376
1522
|
const handleSubmit = async (e) => {
|
|
1377
|
-
_optionalChain([e, 'optionalAccess',
|
|
1523
|
+
_optionalChain([e, 'optionalAccess', _29 => _29.preventDefault, 'call', _30 => _30()]);
|
|
1378
1524
|
await submitCode(code, useRecovery);
|
|
1379
1525
|
};
|
|
1380
1526
|
const handleCodeChange = (value) => {
|
|
@@ -1455,10 +1601,10 @@ function LoginModal() {
|
|
|
1455
1601
|
}
|
|
1456
1602
|
};
|
|
1457
1603
|
const renderLogo = () => {
|
|
1458
|
-
if (_optionalChain([config, 'access',
|
|
1604
|
+
if (_optionalChain([config, 'access', _31 => _31.appearance, 'optionalAccess', _32 => _32.logoNode])) {
|
|
1459
1605
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "fc-logo", children: config.appearance.logoNode });
|
|
1460
1606
|
}
|
|
1461
|
-
if (_optionalChain([config, 'access',
|
|
1607
|
+
if (_optionalChain([config, 'access', _33 => _33.appearance, 'optionalAccess', _34 => _34.logo])) {
|
|
1462
1608
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "img", { src: config.appearance.logo, alt: "", className: "fc-logo" });
|
|
1463
1609
|
}
|
|
1464
1610
|
return null;
|
|
@@ -1468,14 +1614,14 @@ function LoginModal() {
|
|
|
1468
1614
|
{
|
|
1469
1615
|
className: "fc-modal-content",
|
|
1470
1616
|
style: {
|
|
1471
|
-
"--fc-accent": _nullishCoalesce(_optionalChain([config, 'access',
|
|
1617
|
+
"--fc-accent": _nullishCoalesce(_optionalChain([config, 'access', _35 => _35.appearance, 'optionalAccess', _36 => _36.accentColor]), () => ( "#8b5cf6"))
|
|
1472
1618
|
},
|
|
1473
|
-
"data-theme": _nullishCoalesce(_optionalChain([config, 'access',
|
|
1619
|
+
"data-theme": _nullishCoalesce(_optionalChain([config, 'access', _37 => _37.appearance, 'optionalAccess', _38 => _38.theme]), () => ( "light")),
|
|
1474
1620
|
children: modal.step === "success" || modal.step === "oauth" || modal.step === "matrica-migration" ? renderStep() : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1475
1621
|
renderLogo(),
|
|
1476
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "fc-modal-title", children: _nullishCoalesce(_optionalChain([config, 'access',
|
|
1622
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "fc-modal-title", children: _nullishCoalesce(_optionalChain([config, 'access', _39 => _39.appearance, 'optionalAccess', _40 => _40.title]), () => ( "Log in or sign up")) }),
|
|
1477
1623
|
renderStep(),
|
|
1478
|
-
(_optionalChain([config, 'access',
|
|
1624
|
+
(_optionalChain([config, 'access', _41 => _41.appearance, 'optionalAccess', _42 => _42.termsUrl]) || _optionalChain([config, 'access', _43 => _43.appearance, 'optionalAccess', _44 => _44.privacyUrl])) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "fc-legal", children: [
|
|
1479
1625
|
"By continuing, you agree to our",
|
|
1480
1626
|
" ",
|
|
1481
1627
|
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" }),
|
|
@@ -1794,7 +1940,7 @@ function useUser() {
|
|
|
1794
1940
|
_react.useEffect.call(void 0, () => {
|
|
1795
1941
|
const handleMessage = (event) => {
|
|
1796
1942
|
if (event.origin !== window.location.origin) return;
|
|
1797
|
-
if (_optionalChain([event, 'access',
|
|
1943
|
+
if (_optionalChain([event, 'access', _45 => _45.data, 'optionalAccess', _46 => _46.type]) === "fc_oauth_link_success" && pendingRefreshRef.current) {
|
|
1798
1944
|
pendingRefreshRef.current = false;
|
|
1799
1945
|
fetchAuthMethods().catch(() => {
|
|
1800
1946
|
});
|
|
@@ -1966,7 +2112,7 @@ function useSessions() {
|
|
|
1966
2112
|
|
|
1967
2113
|
function TwoFactorModal({ isOpen, onClose, initialEnabled, onStatusChange }) {
|
|
1968
2114
|
const { api, getAccessToken, config } = useForgeConnect();
|
|
1969
|
-
const theme = _nullishCoalesce(_optionalChain([config, 'access',
|
|
2115
|
+
const theme = _nullishCoalesce(_optionalChain([config, 'access', _47 => _47.appearance, 'optionalAccess', _48 => _48.theme]), () => ( "light"));
|
|
1970
2116
|
const [step, setStep] = _react.useState.call(void 0, initialEnabled ? "manage" : "setup");
|
|
1971
2117
|
const [setupData, setSetupData] = _react.useState.call(void 0, null);
|
|
1972
2118
|
const [code, setCode] = _react.useState.call(void 0, "");
|
|
@@ -2059,7 +2205,7 @@ function TwoFactorModal({ isOpen, onClose, initialEnabled, onStatusChange }) {
|
|
|
2059
2205
|
"div",
|
|
2060
2206
|
{
|
|
2061
2207
|
className: "fc-modal-content",
|
|
2062
|
-
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access',
|
|
2208
|
+
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access', _49 => _49.appearance, 'optionalAccess', _50 => _50.accentColor]), () => ( "#8b5cf6")) },
|
|
2063
2209
|
"data-theme": theme,
|
|
2064
2210
|
children: [
|
|
2065
2211
|
step === "setup" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
@@ -2267,7 +2413,7 @@ function base64URLStringToBuffer(base64URLString) {
|
|
|
2267
2413
|
|
|
2268
2414
|
// ../../node_modules/.pnpm/@simplewebauthn+browser@13.2.2/node_modules/@simplewebauthn/browser/esm/helpers/browserSupportsWebAuthn.js
|
|
2269
2415
|
function browserSupportsWebAuthn() {
|
|
2270
|
-
return _browserSupportsWebAuthnInternals.stubThis(_optionalChain([globalThis, 'optionalAccess',
|
|
2416
|
+
return _browserSupportsWebAuthnInternals.stubThis(_optionalChain([globalThis, 'optionalAccess', _51 => _51.PublicKeyCredential]) !== void 0 && typeof globalThis.PublicKeyCredential === "function");
|
|
2271
2417
|
}
|
|
2272
2418
|
var _browserSupportsWebAuthnInternals = {
|
|
2273
2419
|
stubThis: (value) => value
|
|
@@ -2326,7 +2472,7 @@ function identifyRegistrationError({ error, options }) {
|
|
|
2326
2472
|
});
|
|
2327
2473
|
}
|
|
2328
2474
|
} else if (error.name === "ConstraintError") {
|
|
2329
|
-
if (_optionalChain([publicKey, 'access',
|
|
2475
|
+
if (_optionalChain([publicKey, 'access', _52 => _52.authenticatorSelection, 'optionalAccess', _53 => _53.requireResidentKey]) === true) {
|
|
2330
2476
|
return new WebAuthnError({
|
|
2331
2477
|
message: "Discoverable credentials were required but no available authenticator supported it",
|
|
2332
2478
|
code: "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
|
|
@@ -2334,14 +2480,14 @@ function identifyRegistrationError({ error, options }) {
|
|
|
2334
2480
|
});
|
|
2335
2481
|
} else if (
|
|
2336
2482
|
// @ts-ignore: `mediation` doesn't yet exist on CredentialCreationOptions but it's possible as of Sept 2024
|
|
2337
|
-
options.mediation === "conditional" && _optionalChain([publicKey, 'access',
|
|
2483
|
+
options.mediation === "conditional" && _optionalChain([publicKey, 'access', _54 => _54.authenticatorSelection, 'optionalAccess', _55 => _55.userVerification]) === "required"
|
|
2338
2484
|
) {
|
|
2339
2485
|
return new WebAuthnError({
|
|
2340
2486
|
message: "User verification was required during automatic registration but it could not be performed",
|
|
2341
2487
|
code: "ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",
|
|
2342
2488
|
cause: error
|
|
2343
2489
|
});
|
|
2344
|
-
} else if (_optionalChain([publicKey, 'access',
|
|
2490
|
+
} else if (_optionalChain([publicKey, 'access', _56 => _56.authenticatorSelection, 'optionalAccess', _57 => _57.userVerification]) === "required") {
|
|
2345
2491
|
return new WebAuthnError({
|
|
2346
2492
|
message: "User verification was required but no available authenticator supported it",
|
|
2347
2493
|
code: "ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",
|
|
@@ -2467,7 +2613,7 @@ async function startRegistration(options) {
|
|
|
2467
2613
|
...optionsJSON.user,
|
|
2468
2614
|
id: base64URLStringToBuffer(optionsJSON.user.id)
|
|
2469
2615
|
},
|
|
2470
|
-
excludeCredentials: _optionalChain([optionsJSON, 'access',
|
|
2616
|
+
excludeCredentials: _optionalChain([optionsJSON, 'access', _58 => _58.excludeCredentials, 'optionalAccess', _59 => _59.map, 'call', _60 => _60(toPublicKeyCredentialDescriptor)])
|
|
2471
2617
|
};
|
|
2472
2618
|
const createOptions = {};
|
|
2473
2619
|
if (useAutoRegister) {
|
|
@@ -2543,7 +2689,7 @@ function browserSupportsWebAuthnAutofill() {
|
|
|
2543
2689
|
return _browserSupportsWebAuthnAutofillInternals.stubThis(new Promise((resolve) => resolve(false)));
|
|
2544
2690
|
}
|
|
2545
2691
|
const globalPublicKeyCredential = globalThis.PublicKeyCredential;
|
|
2546
|
-
if (_optionalChain([globalPublicKeyCredential, 'optionalAccess',
|
|
2692
|
+
if (_optionalChain([globalPublicKeyCredential, 'optionalAccess', _61 => _61.isConditionalMediationAvailable]) === void 0) {
|
|
2547
2693
|
return _browserSupportsWebAuthnAutofillInternals.stubThis(new Promise((resolve) => resolve(false)));
|
|
2548
2694
|
}
|
|
2549
2695
|
return _browserSupportsWebAuthnAutofillInternals.stubThis(globalPublicKeyCredential.isConditionalMediationAvailable());
|
|
@@ -2608,8 +2754,8 @@ async function startAuthentication(options) {
|
|
|
2608
2754
|
throw new Error("WebAuthn is not supported in this browser");
|
|
2609
2755
|
}
|
|
2610
2756
|
let allowCredentials;
|
|
2611
|
-
if (_optionalChain([optionsJSON, 'access',
|
|
2612
|
-
allowCredentials = _optionalChain([optionsJSON, 'access',
|
|
2757
|
+
if (_optionalChain([optionsJSON, 'access', _62 => _62.allowCredentials, 'optionalAccess', _63 => _63.length]) !== 0) {
|
|
2758
|
+
allowCredentials = _optionalChain([optionsJSON, 'access', _64 => _64.allowCredentials, 'optionalAccess', _65 => _65.map, 'call', _66 => _66(toPublicKeyCredentialDescriptor)]);
|
|
2613
2759
|
}
|
|
2614
2760
|
const publicKey = {
|
|
2615
2761
|
...optionsJSON,
|
|
@@ -2663,7 +2809,7 @@ async function startAuthentication(options) {
|
|
|
2663
2809
|
|
|
2664
2810
|
function PasskeysModal({ isOpen, onClose, onCountChange }) {
|
|
2665
2811
|
const { api, getAccessToken, config } = useForgeConnect();
|
|
2666
|
-
const theme = _nullishCoalesce(_optionalChain([config, 'access',
|
|
2812
|
+
const theme = _nullishCoalesce(_optionalChain([config, 'access', _67 => _67.appearance, 'optionalAccess', _68 => _68.theme]), () => ( "light"));
|
|
2667
2813
|
const [passkeys, setPasskeys] = _react.useState.call(void 0, []);
|
|
2668
2814
|
const [loading, setLoading] = _react.useState.call(void 0, false);
|
|
2669
2815
|
const [addLoading, setAddLoading] = _react.useState.call(void 0, false);
|
|
@@ -2676,7 +2822,7 @@ function PasskeysModal({ isOpen, onClose, onCountChange }) {
|
|
|
2676
2822
|
const list = await api.getPasskeys(token);
|
|
2677
2823
|
setPasskeys(list);
|
|
2678
2824
|
onCountChange(list.length);
|
|
2679
|
-
} catch (
|
|
2825
|
+
} catch (e7) {
|
|
2680
2826
|
} finally {
|
|
2681
2827
|
setLoading(false);
|
|
2682
2828
|
}
|
|
@@ -2723,7 +2869,7 @@ function PasskeysModal({ isOpen, onClose, onCountChange }) {
|
|
|
2723
2869
|
"div",
|
|
2724
2870
|
{
|
|
2725
2871
|
className: "fc-modal-content",
|
|
2726
|
-
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access',
|
|
2872
|
+
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access', _69 => _69.appearance, 'optionalAccess', _70 => _70.accentColor]), () => ( "#8b5cf6")) },
|
|
2727
2873
|
"data-theme": theme,
|
|
2728
2874
|
children: [
|
|
2729
2875
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "fc-modal-title", children: "Passkeys" }),
|
|
@@ -2797,7 +2943,7 @@ function ErrorView({
|
|
|
2797
2943
|
|
|
2798
2944
|
function PasswordModal({ isOpen, onClose, hasPassword }) {
|
|
2799
2945
|
const { api, getAccessToken, config } = useForgeConnect();
|
|
2800
|
-
const theme = _nullishCoalesce(_optionalChain([config, 'access',
|
|
2946
|
+
const theme = _nullishCoalesce(_optionalChain([config, 'access', _71 => _71.appearance, 'optionalAccess', _72 => _72.theme]), () => ( "light"));
|
|
2801
2947
|
const [step, setStep] = _react.useState.call(void 0, "form");
|
|
2802
2948
|
const [currentPassword, setCurrentPassword] = _react.useState.call(void 0, "");
|
|
2803
2949
|
const [newPassword, setNewPassword] = _react.useState.call(void 0, "");
|
|
@@ -2834,7 +2980,7 @@ function PasswordModal({ isOpen, onClose, hasPassword }) {
|
|
|
2834
2980
|
"div",
|
|
2835
2981
|
{
|
|
2836
2982
|
className: "fc-modal-content",
|
|
2837
|
-
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access',
|
|
2983
|
+
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access', _73 => _73.appearance, 'optionalAccess', _74 => _74.accentColor]), () => ( "#8b5cf6")) },
|
|
2838
2984
|
"data-theme": theme,
|
|
2839
2985
|
children: step === "done" ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-tab", style: { textAlign: "center", padding: "24px 0" }, children: [
|
|
2840
2986
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-success", children: [
|
|
@@ -2903,7 +3049,7 @@ function PasswordModal({ isOpen, onClose, hasPassword }) {
|
|
|
2903
3049
|
|
|
2904
3050
|
function DeleteAccountModal({ isOpen, onClose, onDeleted }) {
|
|
2905
3051
|
const { api, getAccessToken, config, logout } = useForgeConnect();
|
|
2906
|
-
const theme = _nullishCoalesce(_optionalChain([config, 'access',
|
|
3052
|
+
const theme = _nullishCoalesce(_optionalChain([config, 'access', _75 => _75.appearance, 'optionalAccess', _76 => _76.theme]), () => ( "light"));
|
|
2907
3053
|
const [step, setStep] = _react.useState.call(void 0, "confirm");
|
|
2908
3054
|
const [code, setCode] = _react.useState.call(void 0, "");
|
|
2909
3055
|
const [loading, setLoading] = _react.useState.call(void 0, false);
|
|
@@ -2963,7 +3109,7 @@ function DeleteAccountModal({ isOpen, onClose, onDeleted }) {
|
|
|
2963
3109
|
"div",
|
|
2964
3110
|
{
|
|
2965
3111
|
className: "fc-modal-content",
|
|
2966
|
-
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access',
|
|
3112
|
+
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access', _77 => _77.appearance, 'optionalAccess', _78 => _78.accentColor]), () => ( "#8b5cf6")) },
|
|
2967
3113
|
"data-theme": theme,
|
|
2968
3114
|
children: [
|
|
2969
3115
|
step === "confirm" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
@@ -3090,20 +3236,20 @@ function AccountModal() {
|
|
|
3090
3236
|
prevLinkOpen.current = linkModal.isOpen;
|
|
3091
3237
|
}, [linkModal.isOpen]);
|
|
3092
3238
|
if (!accountModal.isOpen) return null;
|
|
3093
|
-
const theme = _nullishCoalesce(_optionalChain([config, 'access',
|
|
3094
|
-
const initial = (_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
3239
|
+
const theme = _nullishCoalesce(_optionalChain([config, 'access', _79 => _79.appearance, 'optionalAccess', _80 => _80.theme]), () => ( "light"));
|
|
3240
|
+
const initial = (_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _81 => _81.displayName]), () => ( _optionalChain([user, 'optionalAccess', _82 => _82.primaryEmail]))), () => ( "?"))).charAt(0).toUpperCase();
|
|
3095
3241
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ModalOverlay, { isOpen: accountModal.isOpen, onClose: closeAccountModal, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3096
3242
|
"div",
|
|
3097
3243
|
{
|
|
3098
3244
|
className: "fc-modal-content",
|
|
3099
|
-
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access',
|
|
3245
|
+
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access', _83 => _83.appearance, 'optionalAccess', _84 => _84.accentColor]), () => ( "#8b5cf6")) },
|
|
3100
3246
|
"data-theme": theme,
|
|
3101
3247
|
children: [
|
|
3102
3248
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-account-hero", children: [
|
|
3103
|
-
_optionalChain([user, 'optionalAccess',
|
|
3249
|
+
_optionalChain([user, 'optionalAccess', _85 => _85.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 }),
|
|
3104
3250
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-account-hero-info", children: [
|
|
3105
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-account-hero-name", children: _nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
3106
|
-
_optionalChain([user, 'optionalAccess',
|
|
3251
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-account-hero-name", children: _nullishCoalesce(_optionalChain([user, 'optionalAccess', _86 => _86.displayName]), () => ( "Your account")) }),
|
|
3252
|
+
_optionalChain([user, 'optionalAccess', _87 => _87.primaryEmail]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-account-hero-email", children: user.primaryEmail })
|
|
3107
3253
|
] })
|
|
3108
3254
|
] }),
|
|
3109
3255
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "fc-account-tabs", children: TABS.map((tab) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -3141,13 +3287,13 @@ function AccountModal() {
|
|
|
3141
3287
|
}
|
|
3142
3288
|
function ProfileTab() {
|
|
3143
3289
|
const { user, updateProfile } = useUser();
|
|
3144
|
-
const [displayName, setDisplayName] = _react.useState.call(void 0, _nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
3145
|
-
const [avatarUrl, setAvatarUrl] = _react.useState.call(void 0, _nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
3290
|
+
const [displayName, setDisplayName] = _react.useState.call(void 0, _nullishCoalesce(_optionalChain([user, 'optionalAccess', _88 => _88.displayName]), () => ( "")));
|
|
3291
|
+
const [avatarUrl, setAvatarUrl] = _react.useState.call(void 0, _nullishCoalesce(_optionalChain([user, 'optionalAccess', _89 => _89.avatarUrl]), () => ( "")));
|
|
3146
3292
|
const [loading, setLoading] = _react.useState.call(void 0, false);
|
|
3147
3293
|
const [msg, setMsg] = _react.useState.call(void 0, null);
|
|
3148
3294
|
_react.useEffect.call(void 0, () => {
|
|
3149
|
-
setDisplayName(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
3150
|
-
setAvatarUrl(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
3295
|
+
setDisplayName(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _90 => _90.displayName]), () => ( "")));
|
|
3296
|
+
setAvatarUrl(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _91 => _91.avatarUrl]), () => ( "")));
|
|
3151
3297
|
}, [user]);
|
|
3152
3298
|
const handleSave = async () => {
|
|
3153
3299
|
setLoading(true);
|
|
@@ -3212,7 +3358,7 @@ function LoginsTab({ onLink, refreshKey }) {
|
|
|
3212
3358
|
msg && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-error", children: msg }),
|
|
3213
3359
|
loading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-text", children: "Loading..." }),
|
|
3214
3360
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-account-section-desc", children: "Ways you can sign in to your account." }),
|
|
3215
|
-
_optionalChain([authMethods, 'optionalAccess',
|
|
3361
|
+
_optionalChain([authMethods, 'optionalAccess', _92 => _92.map, 'call', _93 => _93((m) => {
|
|
3216
3362
|
const display = getMethodDisplay(m.provider);
|
|
3217
3363
|
const detail = m.provider === "email" ? m.providerId : m.provider.endsWith("_wallet") ? truncate(m.providerId) : m.providerUsername ? m.provider === "twitter" || m.provider === "telegram" ? `@${m.providerUsername}` : m.providerUsername : truncate(m.providerId);
|
|
3218
3364
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-account-item", children: [
|
|
@@ -3227,7 +3373,7 @@ function LoginsTab({ onLink, refreshKey }) {
|
|
|
3227
3373
|
] })
|
|
3228
3374
|
] }, m.id);
|
|
3229
3375
|
})]),
|
|
3230
|
-
_optionalChain([authMethods, 'optionalAccess',
|
|
3376
|
+
_optionalChain([authMethods, 'optionalAccess', _94 => _94.length]) === 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-account-empty", children: "No login methods yet" }),
|
|
3231
3377
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "fc-btn fc-btn-secondary", onClick: onLink, style: { marginTop: 8 }, children: "+ Add login method" })
|
|
3232
3378
|
] });
|
|
3233
3379
|
}
|
|
@@ -3250,8 +3396,8 @@ function WalletsTab({ onLink, refreshKey }) {
|
|
|
3250
3396
|
msg && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-error", children: msg }),
|
|
3251
3397
|
loading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-text", children: "Loading..." }),
|
|
3252
3398
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-account-section-desc", children: "Crypto wallets connected to your account." }),
|
|
3253
|
-
_optionalChain([wallets, 'optionalAccess',
|
|
3254
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SvgIcon, { svg: _nullishCoalesce(_optionalChain([METHOD_DISPLAY, 'access',
|
|
3399
|
+
_optionalChain([wallets, 'optionalAccess', _95 => _95.map, 'call', _96 => _96((w) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-account-item", children: [
|
|
3400
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SvgIcon, { svg: _nullishCoalesce(_optionalChain([METHOD_DISPLAY, 'access', _97 => _97[`${w.chain}_wallet`], 'optionalAccess', _98 => _98.iconHtml]), () => ( "")), className: "fc-account-item-icon" }),
|
|
3255
3401
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-account-item-info", children: [
|
|
3256
3402
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "fc-account-item-label", children: [
|
|
3257
3403
|
w.chain.charAt(0).toUpperCase() + w.chain.slice(1),
|
|
@@ -3261,7 +3407,7 @@ function WalletsTab({ onLink, refreshKey }) {
|
|
|
3261
3407
|
] }),
|
|
3262
3408
|
/* @__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" }) })
|
|
3263
3409
|
] }, w.id))]),
|
|
3264
|
-
_optionalChain([wallets, 'optionalAccess',
|
|
3410
|
+
_optionalChain([wallets, 'optionalAccess', _99 => _99.length]) === 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-account-empty", children: "No wallets connected" }),
|
|
3265
3411
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "fc-btn fc-btn-secondary", onClick: onLink, style: { marginTop: 8 }, children: "+ Connect wallet" })
|
|
3266
3412
|
] });
|
|
3267
3413
|
}
|
|
@@ -3296,7 +3442,7 @@ function SecurityTab() {
|
|
|
3296
3442
|
refreshStatus();
|
|
3297
3443
|
refreshPasskeyCount();
|
|
3298
3444
|
}, [fetchSessions, fetchAuthMethods, refreshStatus, refreshPasskeyCount]);
|
|
3299
|
-
const hasPassword = _optionalChain([userAuthMethods, 'optionalAccess',
|
|
3445
|
+
const hasPassword = _optionalChain([userAuthMethods, 'optionalAccess', _100 => _100.some, 'call', _101 => _101((m) => m.provider === "email")]);
|
|
3300
3446
|
const handleRevoke = async (id) => {
|
|
3301
3447
|
setMsg("");
|
|
3302
3448
|
try {
|
|
@@ -3330,7 +3476,7 @@ function SecurityTab() {
|
|
|
3330
3476
|
] }),
|
|
3331
3477
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChevronRight, {})
|
|
3332
3478
|
] }),
|
|
3333
|
-
_optionalChain([user, 'optionalAccess',
|
|
3479
|
+
_optionalChain([user, 'optionalAccess', _102 => _102.primaryEmail]) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3334
3480
|
"button",
|
|
3335
3481
|
{
|
|
3336
3482
|
type: "button",
|
|
@@ -3351,7 +3497,7 @@ function SecurityTab() {
|
|
|
3351
3497
|
),
|
|
3352
3498
|
/* @__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" }) }),
|
|
3353
3499
|
loading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-text", children: "Loading..." }),
|
|
3354
|
-
_optionalChain([sessions, 'optionalAccess',
|
|
3500
|
+
_optionalChain([sessions, 'optionalAccess', _103 => _103.map, 'call', _104 => _104((s) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-account-item", children: [
|
|
3355
3501
|
/* @__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: [
|
|
3356
3502
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "rect", { x: "2", y: "3", width: "16", height: "11", rx: "2", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
3357
3503
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M7 17h6M10 14v3", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
|
|
@@ -3367,7 +3513,7 @@ function SecurityTab() {
|
|
|
3367
3513
|
] }),
|
|
3368
3514
|
/* @__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" }) })
|
|
3369
3515
|
] }, s.id))]),
|
|
3370
|
-
_optionalChain([sessions, 'optionalAccess',
|
|
3516
|
+
_optionalChain([sessions, 'optionalAccess', _105 => _105.length]) === 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-account-empty", children: "No active sessions" }),
|
|
3371
3517
|
sessions && sessions.length > 1 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3372
3518
|
"button",
|
|
3373
3519
|
{
|
|
@@ -3414,7 +3560,7 @@ function SecurityTab() {
|
|
|
3414
3560
|
onCountChange: (count) => setPasskeyCount(count)
|
|
3415
3561
|
}
|
|
3416
3562
|
),
|
|
3417
|
-
_optionalChain([user, 'optionalAccess',
|
|
3563
|
+
_optionalChain([user, 'optionalAccess', _106 => _106.primaryEmail]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3418
3564
|
PasswordModal,
|
|
3419
3565
|
{
|
|
3420
3566
|
isOpen: showPasswordModal,
|
|
@@ -3459,7 +3605,7 @@ function LinkAuthModal() {
|
|
|
3459
3605
|
if (!linkModal.isOpen) return;
|
|
3460
3606
|
const handleMessage = (event) => {
|
|
3461
3607
|
if (event.origin !== window.location.origin) return;
|
|
3462
|
-
if (_optionalChain([event, 'access',
|
|
3608
|
+
if (_optionalChain([event, 'access', _107 => _107.data, 'optionalAccess', _108 => _108.type]) === "fc_oauth_link_success") {
|
|
3463
3609
|
setStep("success");
|
|
3464
3610
|
setTimeout(() => {
|
|
3465
3611
|
handleClose();
|
|
@@ -3470,7 +3616,7 @@ function LinkAuthModal() {
|
|
|
3470
3616
|
return () => window.removeEventListener("message", handleMessage);
|
|
3471
3617
|
}, [linkModal.isOpen]);
|
|
3472
3618
|
if (!linkModal.isOpen) return null;
|
|
3473
|
-
const theme = _nullishCoalesce(_optionalChain([config, 'access',
|
|
3619
|
+
const theme = _nullishCoalesce(_optionalChain([config, 'access', _109 => _109.appearance, 'optionalAccess', _110 => _110.theme]), () => ( "light"));
|
|
3474
3620
|
const handleClose = () => {
|
|
3475
3621
|
setStep("method-select");
|
|
3476
3622
|
closeLinkModal();
|
|
@@ -3493,7 +3639,7 @@ function LinkAuthModal() {
|
|
|
3493
3639
|
"div",
|
|
3494
3640
|
{
|
|
3495
3641
|
className: "fc-modal-content",
|
|
3496
|
-
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access',
|
|
3642
|
+
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access', _111 => _111.appearance, 'optionalAccess', _112 => _112.accentColor]), () => ( "#8b5cf6")) },
|
|
3497
3643
|
"data-theme": theme,
|
|
3498
3644
|
children: step === "success" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SuccessView2, {}) : step === "error" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3499
3645
|
ErrorView,
|
|
@@ -3509,7 +3655,7 @@ function LinkAuthModal() {
|
|
|
3509
3655
|
AuthMethodSelectStep,
|
|
3510
3656
|
{
|
|
3511
3657
|
config,
|
|
3512
|
-
connectedProviders: _nullishCoalesce(_optionalChain([authMethods, 'optionalAccess',
|
|
3658
|
+
connectedProviders: _nullishCoalesce(_optionalChain([authMethods, 'optionalAccess', _113 => _113.map, 'call', _114 => _114((m) => m.provider)]), () => ( [])),
|
|
3513
3659
|
onSelectEmail: () => setStep("email"),
|
|
3514
3660
|
onSelectOtp: () => setStep("otp"),
|
|
3515
3661
|
onOAuth: handleOAuthDirect
|
|
@@ -3728,13 +3874,13 @@ function WalletLinkStep({ onBack, onSuccess, onFatalError }) {
|
|
|
3728
3874
|
const [coldWallet, setColdWallet] = _react.useState.call(void 0, false);
|
|
3729
3875
|
const mobile = _react.useMemo.call(void 0, () => isMobile(), []);
|
|
3730
3876
|
const walletConfig = config.walletConfig;
|
|
3731
|
-
const preferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess',
|
|
3732
|
-
const onlyPreferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess',
|
|
3877
|
+
const preferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess', _115 => _115.preferredWallets]), () => ( []));
|
|
3878
|
+
const onlyPreferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess', _116 => _116.onlyPreferred]), () => ( false));
|
|
3733
3879
|
const coldWalletRef = _react.useRef.call(void 0, coldWallet);
|
|
3734
3880
|
coldWalletRef.current = coldWallet;
|
|
3735
3881
|
const buildSignTxFnForAdapter = _react.useCallback.call(void 0, (adapter) => {
|
|
3736
3882
|
if (!adapter.signTransaction) return void 0;
|
|
3737
|
-
const TxClass = _optionalChain([walletConfig, 'optionalAccess',
|
|
3883
|
+
const TxClass = _optionalChain([walletConfig, 'optionalAccess', _117 => _117.Transaction]);
|
|
3738
3884
|
if (!TxClass) return void 0;
|
|
3739
3885
|
return async (txBase64) => {
|
|
3740
3886
|
const bytes = Uint8Array.from(atob(txBase64), (c) => c.charCodeAt(0));
|
|
@@ -3742,7 +3888,7 @@ function WalletLinkStep({ onBack, onSuccess, onFatalError }) {
|
|
|
3742
3888
|
const signedTx = await adapter.signTransaction(tx);
|
|
3743
3889
|
return btoa(String.fromCharCode(...new Uint8Array(signedTx.serialize())));
|
|
3744
3890
|
};
|
|
3745
|
-
}, [_optionalChain([walletConfig, 'optionalAccess',
|
|
3891
|
+
}, [_optionalChain([walletConfig, 'optionalAccess', _118 => _118.Transaction])]);
|
|
3746
3892
|
const wallet = walletAdapter;
|
|
3747
3893
|
const handleConnect = async (w) => {
|
|
3748
3894
|
if (w.readyState !== "Installed") {
|
|
@@ -3785,12 +3931,12 @@ function WalletLinkStep({ onBack, onSuccess, onFatalError }) {
|
|
|
3785
3931
|
const prefSet = new Set(preferred);
|
|
3786
3932
|
const others = all.filter((w) => !prefSet.has(w.adapter.name) && w.readyState === "Installed");
|
|
3787
3933
|
return { preferredWallets: prefList, otherWallets: others };
|
|
3788
|
-
}, [_optionalChain([walletAdapter, 'optionalAccess',
|
|
3934
|
+
}, [_optionalChain([walletAdapter, 'optionalAccess', _119 => _119.wallets]), walletConfig]);
|
|
3789
3935
|
const mobileExtraWallets = _react.useMemo.call(void 0, () => {
|
|
3790
3936
|
if (!mobile || !walletAdapter) return [];
|
|
3791
3937
|
const adapterNames = new Set(walletAdapter.wallets.map((w) => w.adapter.name));
|
|
3792
3938
|
return MOBILE_WALLETS.filter((mw) => !adapterNames.has(mw.name));
|
|
3793
|
-
}, [mobile, _optionalChain([walletAdapter, 'optionalAccess',
|
|
3939
|
+
}, [mobile, _optionalChain([walletAdapter, 'optionalAccess', _120 => _120.wallets])]);
|
|
3794
3940
|
if (!walletAdapter && mobile) {
|
|
3795
3941
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-tab", children: [
|
|
3796
3942
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "fc-wallet-list", children: MOBILE_WALLETS.map((mw) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
@@ -3886,7 +4032,7 @@ function WalletLinkStep({ onBack, onSuccess, onFatalError }) {
|
|
|
3886
4032
|
] }, w.adapter.name))
|
|
3887
4033
|
] }),
|
|
3888
4034
|
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." }),
|
|
3889
|
-
_optionalChain([walletConfig, 'optionalAccess',
|
|
4035
|
+
_optionalChain([walletConfig, 'optionalAccess', _121 => _121.Transaction]) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { className: "fc-cold-wallet-toggle", children: [
|
|
3890
4036
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3891
4037
|
"input",
|
|
3892
4038
|
{
|
|
@@ -3916,6 +4062,55 @@ function SuccessView2() {
|
|
|
3916
4062
|
] });
|
|
3917
4063
|
}
|
|
3918
4064
|
|
|
4065
|
+
// src/register-mwa.ts
|
|
4066
|
+
var registered = false;
|
|
4067
|
+
async function registerMwaIfAvailable(config, opts) {
|
|
4068
|
+
if (typeof window === "undefined") return;
|
|
4069
|
+
if (registered) return;
|
|
4070
|
+
if (_optionalChain([opts, 'optionalAccess', _122 => _122.enabled]) === false) return;
|
|
4071
|
+
let mod;
|
|
4072
|
+
try {
|
|
4073
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("@solana-mobile/wallet-standard-mobile")));
|
|
4074
|
+
} catch (err) {
|
|
4075
|
+
console.warn("[ForgeConnect/MWA] dynamic import failed", err);
|
|
4076
|
+
return;
|
|
4077
|
+
}
|
|
4078
|
+
const {
|
|
4079
|
+
registerMwa,
|
|
4080
|
+
createDefaultAuthorizationCache,
|
|
4081
|
+
createDefaultChainSelector,
|
|
4082
|
+
createDefaultWalletNotFoundHandler
|
|
4083
|
+
} = mod;
|
|
4084
|
+
const origin = window.location.origin;
|
|
4085
|
+
const identity = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _123 => _123.appIdentity]), () => ( {}));
|
|
4086
|
+
const appName = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(identity.name, () => ( _optionalChain([config, 'access', _124 => _124.appearance, 'optionalAccess', _125 => _125.title]))), () => ( (typeof document !== "undefined" ? document.title : ""))), () => ( "App"));
|
|
4087
|
+
registered = true;
|
|
4088
|
+
try {
|
|
4089
|
+
registerMwa({
|
|
4090
|
+
appIdentity: {
|
|
4091
|
+
name: appName,
|
|
4092
|
+
uri: _nullishCoalesce(identity.uri, () => ( origin)),
|
|
4093
|
+
icon: identity.icon
|
|
4094
|
+
},
|
|
4095
|
+
authorizationCache: createDefaultAuthorizationCache(),
|
|
4096
|
+
chains: _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _126 => _126.chains]), () => ( ["solana:mainnet"])),
|
|
4097
|
+
chainSelector: createDefaultChainSelector(),
|
|
4098
|
+
onWalletNotFound: createDefaultWalletNotFoundHandler()
|
|
4099
|
+
});
|
|
4100
|
+
console.log("[ForgeConnect/MWA] registered. appIdentity:", { name: appName, uri: _nullishCoalesce(identity.uri, () => ( origin)) });
|
|
4101
|
+
try {
|
|
4102
|
+
const { getWallets } = await Promise.resolve().then(() => _interopRequireWildcard(require("@wallet-standard/app")));
|
|
4103
|
+
const list = getWallets().get();
|
|
4104
|
+
console.log("[ForgeConnect/MWA] standard wallets after register:", list.map((w) => w.name));
|
|
4105
|
+
} catch (e) {
|
|
4106
|
+
console.warn("[ForgeConnect/MWA] could not enumerate standard wallets", e);
|
|
4107
|
+
}
|
|
4108
|
+
} catch (err) {
|
|
4109
|
+
registered = false;
|
|
4110
|
+
console.warn("[ForgeConnect/MWA] registerMwa threw:", err);
|
|
4111
|
+
}
|
|
4112
|
+
}
|
|
4113
|
+
|
|
3919
4114
|
// src/provider.tsx
|
|
3920
4115
|
|
|
3921
4116
|
var oauthExchangeCache = /* @__PURE__ */ new Map();
|
|
@@ -3945,7 +4140,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
3945
4140
|
const { accessToken } = await api.refresh();
|
|
3946
4141
|
setAuth((prev) => ({ ...prev, accessToken }));
|
|
3947
4142
|
scheduleRefresh(accessToken);
|
|
3948
|
-
} catch (
|
|
4143
|
+
} catch (e8) {
|
|
3949
4144
|
setAuth({ status: "unauthenticated", user: null, accessToken: null });
|
|
3950
4145
|
}
|
|
3951
4146
|
}, delay);
|
|
@@ -3957,7 +4152,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
3957
4152
|
const user = await api.getMe(accessToken);
|
|
3958
4153
|
setAuth({ status: "authenticated", user, accessToken });
|
|
3959
4154
|
scheduleRefresh(accessToken);
|
|
3960
|
-
} catch (
|
|
4155
|
+
} catch (e9) {
|
|
3961
4156
|
setAuth({ status: "unauthenticated", user: null, accessToken: null });
|
|
3962
4157
|
}
|
|
3963
4158
|
};
|
|
@@ -3981,7 +4176,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
3981
4176
|
if (migrationToken) {
|
|
3982
4177
|
try {
|
|
3983
4178
|
localStorage.setItem("fc_matrica_migration_pending", migrationToken);
|
|
3984
|
-
} catch (
|
|
4179
|
+
} catch (e10) {
|
|
3985
4180
|
}
|
|
3986
4181
|
if (window.opener) {
|
|
3987
4182
|
window.opener.postMessage(
|
|
@@ -3996,7 +4191,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
3996
4191
|
if (authCode) {
|
|
3997
4192
|
try {
|
|
3998
4193
|
localStorage.setItem("fc_oauth_code_pending", authCode);
|
|
3999
|
-
} catch (
|
|
4194
|
+
} catch (e11) {
|
|
4000
4195
|
}
|
|
4001
4196
|
if (window.opener) {
|
|
4002
4197
|
window.opener.postMessage(
|
|
@@ -4013,7 +4208,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4013
4208
|
if (!exchangePromise) {
|
|
4014
4209
|
try {
|
|
4015
4210
|
localStorage.removeItem("fc_oauth_code_pending");
|
|
4016
|
-
} catch (
|
|
4211
|
+
} catch (e12) {
|
|
4017
4212
|
}
|
|
4018
4213
|
exchangePromise = (async () => {
|
|
4019
4214
|
try {
|
|
@@ -4025,7 +4220,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4025
4220
|
if (!token) return null;
|
|
4026
4221
|
const user = await api.getMe(token);
|
|
4027
4222
|
return { kind: "authenticated", accessToken: token, user };
|
|
4028
|
-
} catch (
|
|
4223
|
+
} catch (e13) {
|
|
4029
4224
|
return null;
|
|
4030
4225
|
}
|
|
4031
4226
|
})();
|
|
@@ -4041,7 +4236,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4041
4236
|
setModal({ isOpen: true, step: "success" });
|
|
4042
4237
|
setAuth({ status: "authenticated", user: outcome.user, accessToken: outcome.accessToken });
|
|
4043
4238
|
scheduleRefresh(outcome.accessToken);
|
|
4044
|
-
_optionalChain([onLogin, 'optionalCall',
|
|
4239
|
+
_optionalChain([onLogin, 'optionalCall', _127 => _127(outcome.user)]);
|
|
4045
4240
|
setTimeout(() => {
|
|
4046
4241
|
setModal({ isOpen: false, step: "method-select" });
|
|
4047
4242
|
}, 1500);
|
|
@@ -4049,24 +4244,24 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4049
4244
|
const handleMigrationToken = async (token) => {
|
|
4050
4245
|
try {
|
|
4051
4246
|
localStorage.removeItem("fc_matrica_migration_pending");
|
|
4052
|
-
} catch (
|
|
4247
|
+
} catch (e14) {
|
|
4053
4248
|
}
|
|
4054
4249
|
try {
|
|
4055
4250
|
const preview = await api.getMatricaMigration(token);
|
|
4056
4251
|
setMatricaMigration({ token, ...preview });
|
|
4057
4252
|
setModal({ isOpen: true, step: "matrica-migration" });
|
|
4058
|
-
} catch (
|
|
4253
|
+
} catch (e15) {
|
|
4059
4254
|
setModal({ isOpen: true, step: "error" });
|
|
4060
4255
|
}
|
|
4061
4256
|
};
|
|
4062
4257
|
const handleMessage = (event) => {
|
|
4063
4258
|
if (event.origin !== window.location.origin) return;
|
|
4064
|
-
if (_optionalChain([event, 'access',
|
|
4259
|
+
if (_optionalChain([event, 'access', _128 => _128.data, 'optionalAccess', _129 => _129.type]) === "fc_oauth_code") {
|
|
4065
4260
|
const code = event.data.code;
|
|
4066
4261
|
if (code) void handleCode(code);
|
|
4067
4262
|
return;
|
|
4068
4263
|
}
|
|
4069
|
-
if (_optionalChain([event, 'access',
|
|
4264
|
+
if (_optionalChain([event, 'access', _130 => _130.data, 'optionalAccess', _131 => _131.type]) === "fc_matrica_migration") {
|
|
4070
4265
|
const token = event.data.token;
|
|
4071
4266
|
if (token) void handleMigrationToken(token);
|
|
4072
4267
|
}
|
|
@@ -4085,7 +4280,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4085
4280
|
if (pending) void handleCode(pending);
|
|
4086
4281
|
const pendingMigration = localStorage.getItem("fc_matrica_migration_pending");
|
|
4087
4282
|
if (pendingMigration) void handleMigrationToken(pendingMigration);
|
|
4088
|
-
} catch (
|
|
4283
|
+
} catch (e16) {
|
|
4089
4284
|
}
|
|
4090
4285
|
window.addEventListener("message", handleMessage);
|
|
4091
4286
|
window.addEventListener("storage", handleStorage);
|
|
@@ -4094,6 +4289,11 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4094
4289
|
window.removeEventListener("storage", handleStorage);
|
|
4095
4290
|
};
|
|
4096
4291
|
}, [api, config.apiUrl, scheduleRefresh, onLogin]);
|
|
4292
|
+
_react.useEffect.call(void 0, () => {
|
|
4293
|
+
const methods = resolveLoginMethods(config);
|
|
4294
|
+
if (!methods.includes("wallet")) return;
|
|
4295
|
+
void registerMwaIfAvailable(config, config.mwa);
|
|
4296
|
+
}, [config]);
|
|
4097
4297
|
_react.useEffect.call(void 0, () => {
|
|
4098
4298
|
if (config.loginMethods && config.loginMethods.length > 0) {
|
|
4099
4299
|
const hasLegacy = config.oauthProviders || config.walletLogin !== void 0 || config.passwordlessLogin !== void 0;
|
|
@@ -4110,7 +4310,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4110
4310
|
setAuth({ status: "authenticated", user, accessToken: token });
|
|
4111
4311
|
scheduleRefresh(token);
|
|
4112
4312
|
setModal({ isOpen: true, step: "success" });
|
|
4113
|
-
_optionalChain([onLogin, 'optionalCall',
|
|
4313
|
+
_optionalChain([onLogin, 'optionalCall', _132 => _132(user)]);
|
|
4114
4314
|
setTimeout(() => {
|
|
4115
4315
|
setModal({ isOpen: false, step: "method-select" });
|
|
4116
4316
|
}, 1500);
|
|
@@ -4210,11 +4410,11 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4210
4410
|
const token = auth.accessToken;
|
|
4211
4411
|
if (refreshTimerRef.current) clearTimeout(refreshTimerRef.current);
|
|
4212
4412
|
setAuth({ status: "unauthenticated", user: null, accessToken: null });
|
|
4213
|
-
_optionalChain([onLogout, 'optionalCall',
|
|
4413
|
+
_optionalChain([onLogout, 'optionalCall', _133 => _133()]);
|
|
4214
4414
|
if (token) {
|
|
4215
4415
|
try {
|
|
4216
4416
|
await api.logout(token);
|
|
4217
|
-
} catch (
|
|
4417
|
+
} catch (e17) {
|
|
4218
4418
|
}
|
|
4219
4419
|
}
|
|
4220
4420
|
}, [auth.accessToken, api, onLogout]);
|
|
@@ -4264,11 +4464,11 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4264
4464
|
const token = auth.accessToken;
|
|
4265
4465
|
if (refreshTimerRef.current) clearTimeout(refreshTimerRef.current);
|
|
4266
4466
|
setAuth({ status: "unauthenticated", user: null, accessToken: null });
|
|
4267
|
-
_optionalChain([onLogout, 'optionalCall',
|
|
4467
|
+
_optionalChain([onLogout, 'optionalCall', _134 => _134()]);
|
|
4268
4468
|
if (token) {
|
|
4269
4469
|
try {
|
|
4270
4470
|
await api.logoutAll(token);
|
|
4271
|
-
} catch (
|
|
4471
|
+
} catch (e18) {
|
|
4272
4472
|
}
|
|
4273
4473
|
}
|
|
4274
4474
|
}, [auth.accessToken, api, onLogout]);
|
|
@@ -4475,11 +4675,11 @@ function useAdmin() {
|
|
|
4475
4675
|
const token = getAccessToken();
|
|
4476
4676
|
if (!token) throw new Error("Please sign in to continue.");
|
|
4477
4677
|
await api.adminUpdateUserStatus(token, id, status);
|
|
4478
|
-
if (_optionalChain([selectedUser, 'optionalAccess',
|
|
4678
|
+
if (_optionalChain([selectedUser, 'optionalAccess', _135 => _135.id]) === id) {
|
|
4479
4679
|
await getUser(id);
|
|
4480
4680
|
}
|
|
4481
4681
|
},
|
|
4482
|
-
[api, getAccessToken, _optionalChain([selectedUser, 'optionalAccess',
|
|
4682
|
+
[api, getAccessToken, _optionalChain([selectedUser, 'optionalAccess', _136 => _136.id]), getUser]
|
|
4483
4683
|
);
|
|
4484
4684
|
const getUserSessions = _react.useCallback.call(void 0,
|
|
4485
4685
|
async (id) => {
|
|
@@ -4596,9 +4796,9 @@ function useRoles() {
|
|
|
4596
4796
|
const token = getAccessToken();
|
|
4597
4797
|
if (!token) throw new Error("Please sign in to continue.");
|
|
4598
4798
|
await api.adminDeleteRole(token, id);
|
|
4599
|
-
if (_optionalChain([selectedRole, 'optionalAccess',
|
|
4799
|
+
if (_optionalChain([selectedRole, 'optionalAccess', _137 => _137.id]) === id) setSelectedRole(null);
|
|
4600
4800
|
},
|
|
4601
|
-
[api, getAccessToken, _optionalChain([selectedRole, 'optionalAccess',
|
|
4801
|
+
[api, getAccessToken, _optionalChain([selectedRole, 'optionalAccess', _138 => _138.id])]
|
|
4602
4802
|
);
|
|
4603
4803
|
const getPermissions = _react.useCallback.call(void 0,
|
|
4604
4804
|
async () => {
|
|
@@ -4724,5 +4924,6 @@ function hasAnyPermission(required, granted) {
|
|
|
4724
4924
|
|
|
4725
4925
|
|
|
4726
4926
|
|
|
4727
|
-
|
|
4927
|
+
|
|
4928
|
+
exports.AccountButton = AccountButton; exports.AccountModal = AccountModal; exports.DeleteAccountModal = DeleteAccountModal; exports.ErrorView = ErrorView; exports.ForgeConnectApiError = ForgeConnectApiError; exports.ForgeConnectContext = ForgeConnectContext; exports.ForgeConnectProvider = ForgeConnectProvider; exports.LinkAuthModal = LinkAuthModal; exports.LoginButton = LoginButton; exports.LoginModal = LoginModal; exports.ModalOverlay = ModalOverlay; exports.PasskeysModal = PasskeysModal; exports.TwoFactorModal = TwoFactorModal; exports.createApiClient = createApiClient; exports.hasAllPermissions = hasAllPermissions; exports.hasAnyPermission = hasAnyPermission; exports.hasPermission = hasPermission; exports.isOAuthMethod = isOAuthMethod; exports.registerMwaIfAvailable = registerMwaIfAvailable; exports.resolveLoginMethods = resolveLoginMethods; exports.useAdmin = useAdmin; exports.useForgeConnect = useForgeConnect; exports.useRoles = useRoles; exports.useSessions = useSessions; exports.useUser = useUser; exports.useWallets = useWallets;
|
|
4728
4929
|
//# sourceMappingURL=index.cjs.map
|