@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.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,111 @@ 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
|
+
|
|
985
|
+
// src/lib/seeker-bridge.ts
|
|
986
|
+
function isSeekerApp() {
|
|
987
|
+
return typeof window !== "undefined" && _optionalChain([window, 'access', _15 => _15.nomuSeeker, 'optionalAccess', _16 => _16.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
|
|
|
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__ */ _jsxruntime.jsxs.call(void 0, "button", { type: "button", className: "fc-btn fc-btn-wallet", onClick: handleClick, children: [
|
|
1082
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { style: { position: "relative", display: "inline-flex" }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "img", { src: SEEKER_ICON, alt: "", className: "fc-wallet-icon" }) }),
|
|
1083
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-wallet-name", children: "Seeker Wallet" }),
|
|
1084
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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] = _react.useState.call(void 0, false);
|
|
1114
|
+
const [error, setError] = _react.useState.call(void 0, "");
|
|
991
1115
|
const methods = resolveLoginMethods(config);
|
|
992
1116
|
const showBack = methods.length > 1;
|
|
993
1117
|
const walletConfig = config.walletConfig;
|
|
994
|
-
const preferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess',
|
|
995
|
-
const onlyPreferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess',
|
|
1118
|
+
const preferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess', _17 => _17.preferredWallets]), () => ( []));
|
|
1119
|
+
const onlyPreferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess', _18 => _18.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 = _react.useMemo.call(void 0, () => {
|
|
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__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-tab", children: [
|
|
1012
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", {
|
|
1147
|
+
loading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { style: { textAlign: "center", padding: "24px 0" }, children: [
|
|
1148
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-tab-title", children: "Connecting..." }),
|
|
1149
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-text", children: "Approve in your wallet, then sign the verification request." }),
|
|
1150
|
+
error && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1151
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-error", children: error }),
|
|
1152
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
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__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-wallet-list", children: [
|
|
1168
|
+
isSeekerApp() && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SeekerWalletEntry, { onError: (m) => {
|
|
1169
|
+
setError(m);
|
|
1170
|
+
setLoading(false);
|
|
1171
|
+
} }),
|
|
1013
1172
|
showMatrica && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MatricaWalletEntry, {}),
|
|
1173
|
+
standardWallets.map((w) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1174
|
+
"button",
|
|
1175
|
+
{
|
|
1176
|
+
type: "button",
|
|
1177
|
+
className: "fc-btn fc-btn-wallet",
|
|
1178
|
+
onClick: () => handleStandardConnect(w),
|
|
1179
|
+
children: [
|
|
1180
|
+
/* @__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" }) }),
|
|
1181
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-wallet-name", children: w.name }),
|
|
1182
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-badge-preferred", children: "Detected" })
|
|
1183
|
+
]
|
|
1184
|
+
},
|
|
1185
|
+
`std:${w.name}`
|
|
1186
|
+
)),
|
|
1014
1187
|
walletsToShow.map((mw) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1015
1188
|
"button",
|
|
1016
1189
|
{
|
|
@@ -1033,19 +1206,23 @@ 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
1213
|
const [error, setError] = _react.useState.call(void 0, "");
|
|
1040
1214
|
const [loading, setLoading] = _react.useState.call(void 0, false);
|
|
1041
1215
|
const [showOther, setShowOther] = _react.useState.call(void 0, false);
|
|
1216
|
+
_react.useEffect.call(void 0, () => {
|
|
1217
|
+
if (isMobile()) setShowOther(true);
|
|
1218
|
+
}, []);
|
|
1042
1219
|
const [coldWallet, setColdWallet] = _react.useState.call(void 0, false);
|
|
1043
1220
|
const mobile = _react.useMemo.call(void 0, () => isMobile(), []);
|
|
1044
1221
|
const coldWalletRef = _react.useRef.call(void 0, coldWallet);
|
|
1045
1222
|
coldWalletRef.current = coldWallet;
|
|
1046
1223
|
const buildSignTxFnForAdapter = _react.useCallback.call(void 0, (adapter) => {
|
|
1047
1224
|
if (!adapter.signTransaction) return void 0;
|
|
1048
|
-
const TxClass = _optionalChain([walletConfig, 'optionalAccess',
|
|
1225
|
+
const TxClass = _optionalChain([walletConfig, 'optionalAccess', _19 => _19.Transaction]);
|
|
1049
1226
|
if (!TxClass) return void 0;
|
|
1050
1227
|
return async (txBase64) => {
|
|
1051
1228
|
const bytes = Uint8Array.from(atob(txBase64), (c) => c.charCodeAt(0));
|
|
@@ -1053,7 +1230,7 @@ function WalletAdapterFlow() {
|
|
|
1053
1230
|
const signedTx = await adapter.signTransaction(tx);
|
|
1054
1231
|
return btoa(String.fromCharCode(...new Uint8Array(signedTx.serialize())));
|
|
1055
1232
|
};
|
|
1056
|
-
}, [_optionalChain([walletConfig, 'optionalAccess',
|
|
1233
|
+
}, [_optionalChain([walletConfig, 'optionalAccess', _20 => _20.Transaction])]);
|
|
1057
1234
|
const handleConnect = async (w) => {
|
|
1058
1235
|
if (w.readyState !== "Installed") {
|
|
1059
1236
|
if (mobile) {
|
|
@@ -1093,26 +1270,47 @@ function WalletAdapterFlow() {
|
|
|
1093
1270
|
const handleMobileOpen = (mw) => {
|
|
1094
1271
|
window.location.href = mw.buildUrl(window.location.href);
|
|
1095
1272
|
};
|
|
1096
|
-
const preferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess',
|
|
1097
|
-
const onlyPreferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess',
|
|
1273
|
+
const preferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess', _21 => _21.preferredWallets]), () => ( []));
|
|
1274
|
+
const onlyPreferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess', _22 => _22.onlyPreferred]), () => ( false));
|
|
1098
1275
|
const preferredSet = new Set(preferred);
|
|
1099
|
-
const connectedWalletName = wallet.publicKey ? _nullishCoalesce(_optionalChain([wallet, 'access',
|
|
1276
|
+
const connectedWalletName = wallet.publicKey ? _nullishCoalesce(_optionalChain([wallet, 'access', _23 => _23.wallets, 'access', _24 => _24.find, 'call', _25 => _25((w) => w.adapter.connected), 'optionalAccess', _26 => _26.adapter, 'access', _27 => _27.name]), () => ( null)) : null;
|
|
1100
1277
|
const { preferredWallets, otherWallets } = _react.useMemo.call(void 0, () => {
|
|
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 = _react.useMemo.call(void 0, () => {
|
|
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 = _react.useMemo.call(void 0, () => {
|
|
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__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-tab", children: [
|
|
1117
1315
|
loading ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { style: { textAlign: "center", padding: "24px 0" }, children: [
|
|
1118
1316
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-tab-title", children: "Connecting..." }),
|
|
@@ -1135,6 +1333,10 @@ function WalletAdapterFlow() {
|
|
|
1135
1333
|
] })
|
|
1136
1334
|
] }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1137
1335
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-wallet-list", children: [
|
|
1336
|
+
isSeekerApp() && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SeekerWalletEntry, { onError: (m) => {
|
|
1337
|
+
setError(m);
|
|
1338
|
+
setLoading(false);
|
|
1339
|
+
} }),
|
|
1138
1340
|
methods.includes("matrica") && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 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__ */ _jsxruntime.jsxs.call(void 0,
|
|
1361
|
+
"button",
|
|
1362
|
+
{
|
|
1363
|
+
type: "button",
|
|
1364
|
+
className: "fc-btn fc-btn-wallet",
|
|
1365
|
+
onClick: () => handleStandardConnect(w),
|
|
1366
|
+
children: [
|
|
1367
|
+
/* @__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" }) }),
|
|
1368
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-wallet-name", children: w.name }),
|
|
1369
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-badge-preferred", children: "Detected" })
|
|
1370
|
+
]
|
|
1371
|
+
},
|
|
1372
|
+
`std:${w.name}`
|
|
1373
|
+
)),
|
|
1158
1374
|
mobileExtraWallets.map((mw) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
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__ */ _jsxruntime.jsx.call(void 0, "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__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-text", children: "No wallet found. Please install a Solana wallet (like Phantom) to continue." }),
|
|
1207
1423
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { className: "fc-cold-wallet-toggle", children: [
|
|
1208
1424
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1209
1425
|
"input",
|
|
@@ -1353,7 +1569,7 @@ function Verify2FAForm() {
|
|
|
1353
1569
|
const inputRef = _react.useRef.call(void 0, null);
|
|
1354
1570
|
const submittingRef = _react.useRef.call(void 0, false);
|
|
1355
1571
|
_react.useEffect.call(void 0, () => {
|
|
1356
|
-
_optionalChain([inputRef, 'access',
|
|
1572
|
+
_optionalChain([inputRef, 'access', _28 => _28.current, 'optionalAccess', _29 => _29.focus, 'call', _30 => _30()]);
|
|
1357
1573
|
}, [useRecovery]);
|
|
1358
1574
|
const submitCode = _react.useCallback.call(void 0, async (codeValue, isRecovery) => {
|
|
1359
1575
|
if (submittingRef.current || !codeValue.trim()) return;
|
|
@@ -1374,7 +1590,7 @@ function Verify2FAForm() {
|
|
|
1374
1590
|
}
|
|
1375
1591
|
}, [verify2FA, verifyRecoveryCode]);
|
|
1376
1592
|
const handleSubmit = async (e) => {
|
|
1377
|
-
_optionalChain([e, 'optionalAccess',
|
|
1593
|
+
_optionalChain([e, 'optionalAccess', _31 => _31.preventDefault, 'call', _32 => _32()]);
|
|
1378
1594
|
await submitCode(code, useRecovery);
|
|
1379
1595
|
};
|
|
1380
1596
|
const handleCodeChange = (value) => {
|
|
@@ -1455,10 +1671,10 @@ function LoginModal() {
|
|
|
1455
1671
|
}
|
|
1456
1672
|
};
|
|
1457
1673
|
const renderLogo = () => {
|
|
1458
|
-
if (_optionalChain([config, 'access',
|
|
1674
|
+
if (_optionalChain([config, 'access', _33 => _33.appearance, 'optionalAccess', _34 => _34.logoNode])) {
|
|
1459
1675
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "fc-logo", children: config.appearance.logoNode });
|
|
1460
1676
|
}
|
|
1461
|
-
if (_optionalChain([config, 'access',
|
|
1677
|
+
if (_optionalChain([config, 'access', _35 => _35.appearance, 'optionalAccess', _36 => _36.logo])) {
|
|
1462
1678
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "img", { src: config.appearance.logo, alt: "", className: "fc-logo" });
|
|
1463
1679
|
}
|
|
1464
1680
|
return null;
|
|
@@ -1468,14 +1684,14 @@ function LoginModal() {
|
|
|
1468
1684
|
{
|
|
1469
1685
|
className: "fc-modal-content",
|
|
1470
1686
|
style: {
|
|
1471
|
-
"--fc-accent": _nullishCoalesce(_optionalChain([config, 'access',
|
|
1687
|
+
"--fc-accent": _nullishCoalesce(_optionalChain([config, 'access', _37 => _37.appearance, 'optionalAccess', _38 => _38.accentColor]), () => ( "#8b5cf6"))
|
|
1472
1688
|
},
|
|
1473
|
-
"data-theme": _nullishCoalesce(_optionalChain([config, 'access',
|
|
1689
|
+
"data-theme": _nullishCoalesce(_optionalChain([config, 'access', _39 => _39.appearance, 'optionalAccess', _40 => _40.theme]), () => ( "light")),
|
|
1474
1690
|
children: modal.step === "success" || modal.step === "oauth" || modal.step === "matrica-migration" ? renderStep() : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1475
1691
|
renderLogo(),
|
|
1476
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "fc-modal-title", children: _nullishCoalesce(_optionalChain([config, 'access',
|
|
1692
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "fc-modal-title", children: _nullishCoalesce(_optionalChain([config, 'access', _41 => _41.appearance, 'optionalAccess', _42 => _42.title]), () => ( "Log in or sign up")) }),
|
|
1477
1693
|
renderStep(),
|
|
1478
|
-
(_optionalChain([config, 'access',
|
|
1694
|
+
(_optionalChain([config, 'access', _43 => _43.appearance, 'optionalAccess', _44 => _44.termsUrl]) || _optionalChain([config, 'access', _45 => _45.appearance, 'optionalAccess', _46 => _46.privacyUrl])) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "fc-legal", children: [
|
|
1479
1695
|
"By continuing, you agree to our",
|
|
1480
1696
|
" ",
|
|
1481
1697
|
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 +2010,7 @@ function useUser() {
|
|
|
1794
2010
|
_react.useEffect.call(void 0, () => {
|
|
1795
2011
|
const handleMessage = (event) => {
|
|
1796
2012
|
if (event.origin !== window.location.origin) return;
|
|
1797
|
-
if (_optionalChain([event, 'access',
|
|
2013
|
+
if (_optionalChain([event, 'access', _47 => _47.data, 'optionalAccess', _48 => _48.type]) === "fc_oauth_link_success" && pendingRefreshRef.current) {
|
|
1798
2014
|
pendingRefreshRef.current = false;
|
|
1799
2015
|
fetchAuthMethods().catch(() => {
|
|
1800
2016
|
});
|
|
@@ -1966,7 +2182,7 @@ function useSessions() {
|
|
|
1966
2182
|
|
|
1967
2183
|
function TwoFactorModal({ isOpen, onClose, initialEnabled, onStatusChange }) {
|
|
1968
2184
|
const { api, getAccessToken, config } = useForgeConnect();
|
|
1969
|
-
const theme = _nullishCoalesce(_optionalChain([config, 'access',
|
|
2185
|
+
const theme = _nullishCoalesce(_optionalChain([config, 'access', _49 => _49.appearance, 'optionalAccess', _50 => _50.theme]), () => ( "light"));
|
|
1970
2186
|
const [step, setStep] = _react.useState.call(void 0, initialEnabled ? "manage" : "setup");
|
|
1971
2187
|
const [setupData, setSetupData] = _react.useState.call(void 0, null);
|
|
1972
2188
|
const [code, setCode] = _react.useState.call(void 0, "");
|
|
@@ -2059,7 +2275,7 @@ function TwoFactorModal({ isOpen, onClose, initialEnabled, onStatusChange }) {
|
|
|
2059
2275
|
"div",
|
|
2060
2276
|
{
|
|
2061
2277
|
className: "fc-modal-content",
|
|
2062
|
-
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access',
|
|
2278
|
+
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access', _51 => _51.appearance, 'optionalAccess', _52 => _52.accentColor]), () => ( "#8b5cf6")) },
|
|
2063
2279
|
"data-theme": theme,
|
|
2064
2280
|
children: [
|
|
2065
2281
|
step === "setup" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
@@ -2267,7 +2483,7 @@ function base64URLStringToBuffer(base64URLString) {
|
|
|
2267
2483
|
|
|
2268
2484
|
// ../../node_modules/.pnpm/@simplewebauthn+browser@13.2.2/node_modules/@simplewebauthn/browser/esm/helpers/browserSupportsWebAuthn.js
|
|
2269
2485
|
function browserSupportsWebAuthn() {
|
|
2270
|
-
return _browserSupportsWebAuthnInternals.stubThis(_optionalChain([globalThis, 'optionalAccess',
|
|
2486
|
+
return _browserSupportsWebAuthnInternals.stubThis(_optionalChain([globalThis, 'optionalAccess', _53 => _53.PublicKeyCredential]) !== void 0 && typeof globalThis.PublicKeyCredential === "function");
|
|
2271
2487
|
}
|
|
2272
2488
|
var _browserSupportsWebAuthnInternals = {
|
|
2273
2489
|
stubThis: (value) => value
|
|
@@ -2326,7 +2542,7 @@ function identifyRegistrationError({ error, options }) {
|
|
|
2326
2542
|
});
|
|
2327
2543
|
}
|
|
2328
2544
|
} else if (error.name === "ConstraintError") {
|
|
2329
|
-
if (_optionalChain([publicKey, 'access',
|
|
2545
|
+
if (_optionalChain([publicKey, 'access', _54 => _54.authenticatorSelection, 'optionalAccess', _55 => _55.requireResidentKey]) === true) {
|
|
2330
2546
|
return new WebAuthnError({
|
|
2331
2547
|
message: "Discoverable credentials were required but no available authenticator supported it",
|
|
2332
2548
|
code: "ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
|
|
@@ -2334,14 +2550,14 @@ function identifyRegistrationError({ error, options }) {
|
|
|
2334
2550
|
});
|
|
2335
2551
|
} else if (
|
|
2336
2552
|
// @ts-ignore: `mediation` doesn't yet exist on CredentialCreationOptions but it's possible as of Sept 2024
|
|
2337
|
-
options.mediation === "conditional" && _optionalChain([publicKey, 'access',
|
|
2553
|
+
options.mediation === "conditional" && _optionalChain([publicKey, 'access', _56 => _56.authenticatorSelection, 'optionalAccess', _57 => _57.userVerification]) === "required"
|
|
2338
2554
|
) {
|
|
2339
2555
|
return new WebAuthnError({
|
|
2340
2556
|
message: "User verification was required during automatic registration but it could not be performed",
|
|
2341
2557
|
code: "ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",
|
|
2342
2558
|
cause: error
|
|
2343
2559
|
});
|
|
2344
|
-
} else if (_optionalChain([publicKey, 'access',
|
|
2560
|
+
} else if (_optionalChain([publicKey, 'access', _58 => _58.authenticatorSelection, 'optionalAccess', _59 => _59.userVerification]) === "required") {
|
|
2345
2561
|
return new WebAuthnError({
|
|
2346
2562
|
message: "User verification was required but no available authenticator supported it",
|
|
2347
2563
|
code: "ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",
|
|
@@ -2467,7 +2683,7 @@ async function startRegistration(options) {
|
|
|
2467
2683
|
...optionsJSON.user,
|
|
2468
2684
|
id: base64URLStringToBuffer(optionsJSON.user.id)
|
|
2469
2685
|
},
|
|
2470
|
-
excludeCredentials: _optionalChain([optionsJSON, 'access',
|
|
2686
|
+
excludeCredentials: _optionalChain([optionsJSON, 'access', _60 => _60.excludeCredentials, 'optionalAccess', _61 => _61.map, 'call', _62 => _62(toPublicKeyCredentialDescriptor)])
|
|
2471
2687
|
};
|
|
2472
2688
|
const createOptions = {};
|
|
2473
2689
|
if (useAutoRegister) {
|
|
@@ -2543,7 +2759,7 @@ function browserSupportsWebAuthnAutofill() {
|
|
|
2543
2759
|
return _browserSupportsWebAuthnAutofillInternals.stubThis(new Promise((resolve) => resolve(false)));
|
|
2544
2760
|
}
|
|
2545
2761
|
const globalPublicKeyCredential = globalThis.PublicKeyCredential;
|
|
2546
|
-
if (_optionalChain([globalPublicKeyCredential, 'optionalAccess',
|
|
2762
|
+
if (_optionalChain([globalPublicKeyCredential, 'optionalAccess', _63 => _63.isConditionalMediationAvailable]) === void 0) {
|
|
2547
2763
|
return _browserSupportsWebAuthnAutofillInternals.stubThis(new Promise((resolve) => resolve(false)));
|
|
2548
2764
|
}
|
|
2549
2765
|
return _browserSupportsWebAuthnAutofillInternals.stubThis(globalPublicKeyCredential.isConditionalMediationAvailable());
|
|
@@ -2608,8 +2824,8 @@ async function startAuthentication(options) {
|
|
|
2608
2824
|
throw new Error("WebAuthn is not supported in this browser");
|
|
2609
2825
|
}
|
|
2610
2826
|
let allowCredentials;
|
|
2611
|
-
if (_optionalChain([optionsJSON, 'access',
|
|
2612
|
-
allowCredentials = _optionalChain([optionsJSON, 'access',
|
|
2827
|
+
if (_optionalChain([optionsJSON, 'access', _64 => _64.allowCredentials, 'optionalAccess', _65 => _65.length]) !== 0) {
|
|
2828
|
+
allowCredentials = _optionalChain([optionsJSON, 'access', _66 => _66.allowCredentials, 'optionalAccess', _67 => _67.map, 'call', _68 => _68(toPublicKeyCredentialDescriptor)]);
|
|
2613
2829
|
}
|
|
2614
2830
|
const publicKey = {
|
|
2615
2831
|
...optionsJSON,
|
|
@@ -2663,7 +2879,7 @@ async function startAuthentication(options) {
|
|
|
2663
2879
|
|
|
2664
2880
|
function PasskeysModal({ isOpen, onClose, onCountChange }) {
|
|
2665
2881
|
const { api, getAccessToken, config } = useForgeConnect();
|
|
2666
|
-
const theme = _nullishCoalesce(_optionalChain([config, 'access',
|
|
2882
|
+
const theme = _nullishCoalesce(_optionalChain([config, 'access', _69 => _69.appearance, 'optionalAccess', _70 => _70.theme]), () => ( "light"));
|
|
2667
2883
|
const [passkeys, setPasskeys] = _react.useState.call(void 0, []);
|
|
2668
2884
|
const [loading, setLoading] = _react.useState.call(void 0, false);
|
|
2669
2885
|
const [addLoading, setAddLoading] = _react.useState.call(void 0, false);
|
|
@@ -2676,7 +2892,7 @@ function PasskeysModal({ isOpen, onClose, onCountChange }) {
|
|
|
2676
2892
|
const list = await api.getPasskeys(token);
|
|
2677
2893
|
setPasskeys(list);
|
|
2678
2894
|
onCountChange(list.length);
|
|
2679
|
-
} catch (
|
|
2895
|
+
} catch (e7) {
|
|
2680
2896
|
} finally {
|
|
2681
2897
|
setLoading(false);
|
|
2682
2898
|
}
|
|
@@ -2723,7 +2939,7 @@ function PasskeysModal({ isOpen, onClose, onCountChange }) {
|
|
|
2723
2939
|
"div",
|
|
2724
2940
|
{
|
|
2725
2941
|
className: "fc-modal-content",
|
|
2726
|
-
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access',
|
|
2942
|
+
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access', _71 => _71.appearance, 'optionalAccess', _72 => _72.accentColor]), () => ( "#8b5cf6")) },
|
|
2727
2943
|
"data-theme": theme,
|
|
2728
2944
|
children: [
|
|
2729
2945
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "fc-modal-title", children: "Passkeys" }),
|
|
@@ -2797,7 +3013,7 @@ function ErrorView({
|
|
|
2797
3013
|
|
|
2798
3014
|
function PasswordModal({ isOpen, onClose, hasPassword }) {
|
|
2799
3015
|
const { api, getAccessToken, config } = useForgeConnect();
|
|
2800
|
-
const theme = _nullishCoalesce(_optionalChain([config, 'access',
|
|
3016
|
+
const theme = _nullishCoalesce(_optionalChain([config, 'access', _73 => _73.appearance, 'optionalAccess', _74 => _74.theme]), () => ( "light"));
|
|
2801
3017
|
const [step, setStep] = _react.useState.call(void 0, "form");
|
|
2802
3018
|
const [currentPassword, setCurrentPassword] = _react.useState.call(void 0, "");
|
|
2803
3019
|
const [newPassword, setNewPassword] = _react.useState.call(void 0, "");
|
|
@@ -2834,7 +3050,7 @@ function PasswordModal({ isOpen, onClose, hasPassword }) {
|
|
|
2834
3050
|
"div",
|
|
2835
3051
|
{
|
|
2836
3052
|
className: "fc-modal-content",
|
|
2837
|
-
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access',
|
|
3053
|
+
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access', _75 => _75.appearance, 'optionalAccess', _76 => _76.accentColor]), () => ( "#8b5cf6")) },
|
|
2838
3054
|
"data-theme": theme,
|
|
2839
3055
|
children: step === "done" ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-tab", style: { textAlign: "center", padding: "24px 0" }, children: [
|
|
2840
3056
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-success", children: [
|
|
@@ -2903,7 +3119,7 @@ function PasswordModal({ isOpen, onClose, hasPassword }) {
|
|
|
2903
3119
|
|
|
2904
3120
|
function DeleteAccountModal({ isOpen, onClose, onDeleted }) {
|
|
2905
3121
|
const { api, getAccessToken, config, logout } = useForgeConnect();
|
|
2906
|
-
const theme = _nullishCoalesce(_optionalChain([config, 'access',
|
|
3122
|
+
const theme = _nullishCoalesce(_optionalChain([config, 'access', _77 => _77.appearance, 'optionalAccess', _78 => _78.theme]), () => ( "light"));
|
|
2907
3123
|
const [step, setStep] = _react.useState.call(void 0, "confirm");
|
|
2908
3124
|
const [code, setCode] = _react.useState.call(void 0, "");
|
|
2909
3125
|
const [loading, setLoading] = _react.useState.call(void 0, false);
|
|
@@ -2963,7 +3179,7 @@ function DeleteAccountModal({ isOpen, onClose, onDeleted }) {
|
|
|
2963
3179
|
"div",
|
|
2964
3180
|
{
|
|
2965
3181
|
className: "fc-modal-content",
|
|
2966
|
-
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access',
|
|
3182
|
+
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access', _79 => _79.appearance, 'optionalAccess', _80 => _80.accentColor]), () => ( "#8b5cf6")) },
|
|
2967
3183
|
"data-theme": theme,
|
|
2968
3184
|
children: [
|
|
2969
3185
|
step === "confirm" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
@@ -3090,20 +3306,20 @@ function AccountModal() {
|
|
|
3090
3306
|
prevLinkOpen.current = linkModal.isOpen;
|
|
3091
3307
|
}, [linkModal.isOpen]);
|
|
3092
3308
|
if (!accountModal.isOpen) return null;
|
|
3093
|
-
const theme = _nullishCoalesce(_optionalChain([config, 'access',
|
|
3094
|
-
const initial = (_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
3309
|
+
const theme = _nullishCoalesce(_optionalChain([config, 'access', _81 => _81.appearance, 'optionalAccess', _82 => _82.theme]), () => ( "light"));
|
|
3310
|
+
const initial = (_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _83 => _83.displayName]), () => ( _optionalChain([user, 'optionalAccess', _84 => _84.primaryEmail]))), () => ( "?"))).charAt(0).toUpperCase();
|
|
3095
3311
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ModalOverlay, { isOpen: accountModal.isOpen, onClose: closeAccountModal, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3096
3312
|
"div",
|
|
3097
3313
|
{
|
|
3098
3314
|
className: "fc-modal-content",
|
|
3099
|
-
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access',
|
|
3315
|
+
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access', _85 => _85.appearance, 'optionalAccess', _86 => _86.accentColor]), () => ( "#8b5cf6")) },
|
|
3100
3316
|
"data-theme": theme,
|
|
3101
3317
|
children: [
|
|
3102
3318
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-account-hero", children: [
|
|
3103
|
-
_optionalChain([user, 'optionalAccess',
|
|
3319
|
+
_optionalChain([user, 'optionalAccess', _87 => _87.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
3320
|
/* @__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',
|
|
3321
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-account-hero-name", children: _nullishCoalesce(_optionalChain([user, 'optionalAccess', _88 => _88.displayName]), () => ( "Your account")) }),
|
|
3322
|
+
_optionalChain([user, 'optionalAccess', _89 => _89.primaryEmail]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "fc-account-hero-email", children: user.primaryEmail })
|
|
3107
3323
|
] })
|
|
3108
3324
|
] }),
|
|
3109
3325
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "fc-account-tabs", children: TABS.map((tab) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -3141,13 +3357,13 @@ function AccountModal() {
|
|
|
3141
3357
|
}
|
|
3142
3358
|
function ProfileTab() {
|
|
3143
3359
|
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',
|
|
3360
|
+
const [displayName, setDisplayName] = _react.useState.call(void 0, _nullishCoalesce(_optionalChain([user, 'optionalAccess', _90 => _90.displayName]), () => ( "")));
|
|
3361
|
+
const [avatarUrl, setAvatarUrl] = _react.useState.call(void 0, _nullishCoalesce(_optionalChain([user, 'optionalAccess', _91 => _91.avatarUrl]), () => ( "")));
|
|
3146
3362
|
const [loading, setLoading] = _react.useState.call(void 0, false);
|
|
3147
3363
|
const [msg, setMsg] = _react.useState.call(void 0, null);
|
|
3148
3364
|
_react.useEffect.call(void 0, () => {
|
|
3149
|
-
setDisplayName(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
3150
|
-
setAvatarUrl(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
3365
|
+
setDisplayName(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _92 => _92.displayName]), () => ( "")));
|
|
3366
|
+
setAvatarUrl(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _93 => _93.avatarUrl]), () => ( "")));
|
|
3151
3367
|
}, [user]);
|
|
3152
3368
|
const handleSave = async () => {
|
|
3153
3369
|
setLoading(true);
|
|
@@ -3212,7 +3428,7 @@ function LoginsTab({ onLink, refreshKey }) {
|
|
|
3212
3428
|
msg && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-error", children: msg }),
|
|
3213
3429
|
loading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-text", children: "Loading..." }),
|
|
3214
3430
|
/* @__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',
|
|
3431
|
+
_optionalChain([authMethods, 'optionalAccess', _94 => _94.map, 'call', _95 => _95((m) => {
|
|
3216
3432
|
const display = getMethodDisplay(m.provider);
|
|
3217
3433
|
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
3434
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-account-item", children: [
|
|
@@ -3227,7 +3443,7 @@ function LoginsTab({ onLink, refreshKey }) {
|
|
|
3227
3443
|
] })
|
|
3228
3444
|
] }, m.id);
|
|
3229
3445
|
})]),
|
|
3230
|
-
_optionalChain([authMethods, 'optionalAccess',
|
|
3446
|
+
_optionalChain([authMethods, 'optionalAccess', _96 => _96.length]) === 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-account-empty", children: "No login methods yet" }),
|
|
3231
3447
|
/* @__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
3448
|
] });
|
|
3233
3449
|
}
|
|
@@ -3250,8 +3466,8 @@ function WalletsTab({ onLink, refreshKey }) {
|
|
|
3250
3466
|
msg && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-error", children: msg }),
|
|
3251
3467
|
loading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-text", children: "Loading..." }),
|
|
3252
3468
|
/* @__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',
|
|
3469
|
+
_optionalChain([wallets, 'optionalAccess', _97 => _97.map, 'call', _98 => _98((w) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-account-item", children: [
|
|
3470
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SvgIcon, { svg: _nullishCoalesce(_optionalChain([METHOD_DISPLAY, 'access', _99 => _99[`${w.chain}_wallet`], 'optionalAccess', _100 => _100.iconHtml]), () => ( "")), className: "fc-account-item-icon" }),
|
|
3255
3471
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-account-item-info", children: [
|
|
3256
3472
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "fc-account-item-label", children: [
|
|
3257
3473
|
w.chain.charAt(0).toUpperCase() + w.chain.slice(1),
|
|
@@ -3261,7 +3477,7 @@ function WalletsTab({ onLink, refreshKey }) {
|
|
|
3261
3477
|
] }),
|
|
3262
3478
|
/* @__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
3479
|
] }, w.id))]),
|
|
3264
|
-
_optionalChain([wallets, 'optionalAccess',
|
|
3480
|
+
_optionalChain([wallets, 'optionalAccess', _101 => _101.length]) === 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-account-empty", children: "No wallets connected" }),
|
|
3265
3481
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "fc-btn fc-btn-secondary", onClick: onLink, style: { marginTop: 8 }, children: "+ Connect wallet" })
|
|
3266
3482
|
] });
|
|
3267
3483
|
}
|
|
@@ -3296,7 +3512,7 @@ function SecurityTab() {
|
|
|
3296
3512
|
refreshStatus();
|
|
3297
3513
|
refreshPasskeyCount();
|
|
3298
3514
|
}, [fetchSessions, fetchAuthMethods, refreshStatus, refreshPasskeyCount]);
|
|
3299
|
-
const hasPassword = _optionalChain([userAuthMethods, 'optionalAccess',
|
|
3515
|
+
const hasPassword = _optionalChain([userAuthMethods, 'optionalAccess', _102 => _102.some, 'call', _103 => _103((m) => m.provider === "email")]);
|
|
3300
3516
|
const handleRevoke = async (id) => {
|
|
3301
3517
|
setMsg("");
|
|
3302
3518
|
try {
|
|
@@ -3330,7 +3546,7 @@ function SecurityTab() {
|
|
|
3330
3546
|
] }),
|
|
3331
3547
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChevronRight, {})
|
|
3332
3548
|
] }),
|
|
3333
|
-
_optionalChain([user, 'optionalAccess',
|
|
3549
|
+
_optionalChain([user, 'optionalAccess', _104 => _104.primaryEmail]) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3334
3550
|
"button",
|
|
3335
3551
|
{
|
|
3336
3552
|
type: "button",
|
|
@@ -3351,7 +3567,7 @@ function SecurityTab() {
|
|
|
3351
3567
|
),
|
|
3352
3568
|
/* @__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
3569
|
loading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-text", children: "Loading..." }),
|
|
3354
|
-
_optionalChain([sessions, 'optionalAccess',
|
|
3570
|
+
_optionalChain([sessions, 'optionalAccess', _105 => _105.map, 'call', _106 => _106((s) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-account-item", children: [
|
|
3355
3571
|
/* @__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
3572
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "rect", { x: "2", y: "3", width: "16", height: "11", rx: "2", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
3357
3573
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M7 17h6M10 14v3", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
|
|
@@ -3367,7 +3583,7 @@ function SecurityTab() {
|
|
|
3367
3583
|
] }),
|
|
3368
3584
|
/* @__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
3585
|
] }, s.id))]),
|
|
3370
|
-
_optionalChain([sessions, 'optionalAccess',
|
|
3586
|
+
_optionalChain([sessions, 'optionalAccess', _107 => _107.length]) === 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "fc-account-empty", children: "No active sessions" }),
|
|
3371
3587
|
sessions && sessions.length > 1 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3372
3588
|
"button",
|
|
3373
3589
|
{
|
|
@@ -3414,7 +3630,7 @@ function SecurityTab() {
|
|
|
3414
3630
|
onCountChange: (count) => setPasskeyCount(count)
|
|
3415
3631
|
}
|
|
3416
3632
|
),
|
|
3417
|
-
_optionalChain([user, 'optionalAccess',
|
|
3633
|
+
_optionalChain([user, 'optionalAccess', _108 => _108.primaryEmail]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3418
3634
|
PasswordModal,
|
|
3419
3635
|
{
|
|
3420
3636
|
isOpen: showPasswordModal,
|
|
@@ -3459,7 +3675,7 @@ function LinkAuthModal() {
|
|
|
3459
3675
|
if (!linkModal.isOpen) return;
|
|
3460
3676
|
const handleMessage = (event) => {
|
|
3461
3677
|
if (event.origin !== window.location.origin) return;
|
|
3462
|
-
if (_optionalChain([event, 'access',
|
|
3678
|
+
if (_optionalChain([event, 'access', _109 => _109.data, 'optionalAccess', _110 => _110.type]) === "fc_oauth_link_success") {
|
|
3463
3679
|
setStep("success");
|
|
3464
3680
|
setTimeout(() => {
|
|
3465
3681
|
handleClose();
|
|
@@ -3470,7 +3686,7 @@ function LinkAuthModal() {
|
|
|
3470
3686
|
return () => window.removeEventListener("message", handleMessage);
|
|
3471
3687
|
}, [linkModal.isOpen]);
|
|
3472
3688
|
if (!linkModal.isOpen) return null;
|
|
3473
|
-
const theme = _nullishCoalesce(_optionalChain([config, 'access',
|
|
3689
|
+
const theme = _nullishCoalesce(_optionalChain([config, 'access', _111 => _111.appearance, 'optionalAccess', _112 => _112.theme]), () => ( "light"));
|
|
3474
3690
|
const handleClose = () => {
|
|
3475
3691
|
setStep("method-select");
|
|
3476
3692
|
closeLinkModal();
|
|
@@ -3493,7 +3709,7 @@ function LinkAuthModal() {
|
|
|
3493
3709
|
"div",
|
|
3494
3710
|
{
|
|
3495
3711
|
className: "fc-modal-content",
|
|
3496
|
-
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access',
|
|
3712
|
+
style: { "--fc-accent": _nullishCoalesce(_optionalChain([config, 'access', _113 => _113.appearance, 'optionalAccess', _114 => _114.accentColor]), () => ( "#8b5cf6")) },
|
|
3497
3713
|
"data-theme": theme,
|
|
3498
3714
|
children: step === "success" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SuccessView2, {}) : step === "error" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3499
3715
|
ErrorView,
|
|
@@ -3509,7 +3725,7 @@ function LinkAuthModal() {
|
|
|
3509
3725
|
AuthMethodSelectStep,
|
|
3510
3726
|
{
|
|
3511
3727
|
config,
|
|
3512
|
-
connectedProviders: _nullishCoalesce(_optionalChain([authMethods, 'optionalAccess',
|
|
3728
|
+
connectedProviders: _nullishCoalesce(_optionalChain([authMethods, 'optionalAccess', _115 => _115.map, 'call', _116 => _116((m) => m.provider)]), () => ( [])),
|
|
3513
3729
|
onSelectEmail: () => setStep("email"),
|
|
3514
3730
|
onSelectOtp: () => setStep("otp"),
|
|
3515
3731
|
onOAuth: handleOAuthDirect
|
|
@@ -3728,13 +3944,13 @@ function WalletLinkStep({ onBack, onSuccess, onFatalError }) {
|
|
|
3728
3944
|
const [coldWallet, setColdWallet] = _react.useState.call(void 0, false);
|
|
3729
3945
|
const mobile = _react.useMemo.call(void 0, () => isMobile(), []);
|
|
3730
3946
|
const walletConfig = config.walletConfig;
|
|
3731
|
-
const preferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess',
|
|
3732
|
-
const onlyPreferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess',
|
|
3947
|
+
const preferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess', _117 => _117.preferredWallets]), () => ( []));
|
|
3948
|
+
const onlyPreferred = _nullishCoalesce(_optionalChain([walletConfig, 'optionalAccess', _118 => _118.onlyPreferred]), () => ( false));
|
|
3733
3949
|
const coldWalletRef = _react.useRef.call(void 0, coldWallet);
|
|
3734
3950
|
coldWalletRef.current = coldWallet;
|
|
3735
3951
|
const buildSignTxFnForAdapter = _react.useCallback.call(void 0, (adapter) => {
|
|
3736
3952
|
if (!adapter.signTransaction) return void 0;
|
|
3737
|
-
const TxClass = _optionalChain([walletConfig, 'optionalAccess',
|
|
3953
|
+
const TxClass = _optionalChain([walletConfig, 'optionalAccess', _119 => _119.Transaction]);
|
|
3738
3954
|
if (!TxClass) return void 0;
|
|
3739
3955
|
return async (txBase64) => {
|
|
3740
3956
|
const bytes = Uint8Array.from(atob(txBase64), (c) => c.charCodeAt(0));
|
|
@@ -3742,7 +3958,7 @@ function WalletLinkStep({ onBack, onSuccess, onFatalError }) {
|
|
|
3742
3958
|
const signedTx = await adapter.signTransaction(tx);
|
|
3743
3959
|
return btoa(String.fromCharCode(...new Uint8Array(signedTx.serialize())));
|
|
3744
3960
|
};
|
|
3745
|
-
}, [_optionalChain([walletConfig, 'optionalAccess',
|
|
3961
|
+
}, [_optionalChain([walletConfig, 'optionalAccess', _120 => _120.Transaction])]);
|
|
3746
3962
|
const wallet = walletAdapter;
|
|
3747
3963
|
const handleConnect = async (w) => {
|
|
3748
3964
|
if (w.readyState !== "Installed") {
|
|
@@ -3785,12 +4001,12 @@ function WalletLinkStep({ onBack, onSuccess, onFatalError }) {
|
|
|
3785
4001
|
const prefSet = new Set(preferred);
|
|
3786
4002
|
const others = all.filter((w) => !prefSet.has(w.adapter.name) && w.readyState === "Installed");
|
|
3787
4003
|
return { preferredWallets: prefList, otherWallets: others };
|
|
3788
|
-
}, [_optionalChain([walletAdapter, 'optionalAccess',
|
|
4004
|
+
}, [_optionalChain([walletAdapter, 'optionalAccess', _121 => _121.wallets]), walletConfig]);
|
|
3789
4005
|
const mobileExtraWallets = _react.useMemo.call(void 0, () => {
|
|
3790
4006
|
if (!mobile || !walletAdapter) return [];
|
|
3791
4007
|
const adapterNames = new Set(walletAdapter.wallets.map((w) => w.adapter.name));
|
|
3792
4008
|
return MOBILE_WALLETS.filter((mw) => !adapterNames.has(mw.name));
|
|
3793
|
-
}, [mobile, _optionalChain([walletAdapter, 'optionalAccess',
|
|
4009
|
+
}, [mobile, _optionalChain([walletAdapter, 'optionalAccess', _122 => _122.wallets])]);
|
|
3794
4010
|
if (!walletAdapter && mobile) {
|
|
3795
4011
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "fc-tab", children: [
|
|
3796
4012
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "fc-wallet-list", children: MOBILE_WALLETS.map((mw) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
@@ -3886,7 +4102,7 @@ function WalletLinkStep({ onBack, onSuccess, onFatalError }) {
|
|
|
3886
4102
|
] }, w.adapter.name))
|
|
3887
4103
|
] }),
|
|
3888
4104
|
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',
|
|
4105
|
+
_optionalChain([walletConfig, 'optionalAccess', _123 => _123.Transaction]) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { className: "fc-cold-wallet-toggle", children: [
|
|
3890
4106
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3891
4107
|
"input",
|
|
3892
4108
|
{
|
|
@@ -3916,6 +4132,55 @@ 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 (_optionalChain([opts, 'optionalAccess', _124 => _124.enabled]) === false) return;
|
|
4141
|
+
let mod;
|
|
4142
|
+
try {
|
|
4143
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("@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 = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _125 => _125.appIdentity]), () => ( {}));
|
|
4156
|
+
const appName = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(identity.name, () => ( _optionalChain([config, 'access', _126 => _126.appearance, 'optionalAccess', _127 => _127.title]))), () => ( (typeof document !== "undefined" ? document.title : ""))), () => ( "App"));
|
|
4157
|
+
registered = true;
|
|
4158
|
+
try {
|
|
4159
|
+
registerMwa({
|
|
4160
|
+
appIdentity: {
|
|
4161
|
+
name: appName,
|
|
4162
|
+
uri: _nullishCoalesce(identity.uri, () => ( origin)),
|
|
4163
|
+
icon: identity.icon
|
|
4164
|
+
},
|
|
4165
|
+
authorizationCache: createDefaultAuthorizationCache(),
|
|
4166
|
+
chains: _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _128 => _128.chains]), () => ( ["solana:mainnet"])),
|
|
4167
|
+
chainSelector: createDefaultChainSelector(),
|
|
4168
|
+
onWalletNotFound: createDefaultWalletNotFoundHandler()
|
|
4169
|
+
});
|
|
4170
|
+
console.log("[ForgeConnect/MWA] registered. appIdentity:", { name: appName, uri: _nullishCoalesce(identity.uri, () => ( origin)) });
|
|
4171
|
+
try {
|
|
4172
|
+
const { getWallets } = await Promise.resolve().then(() => _interopRequireWildcard(require("@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
|
|
|
3921
4186
|
var oauthExchangeCache = /* @__PURE__ */ new Map();
|
|
@@ -3945,7 +4210,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
3945
4210
|
const { accessToken } = await api.refresh();
|
|
3946
4211
|
setAuth((prev) => ({ ...prev, accessToken }));
|
|
3947
4212
|
scheduleRefresh(accessToken);
|
|
3948
|
-
} catch (
|
|
4213
|
+
} catch (e8) {
|
|
3949
4214
|
setAuth({ status: "unauthenticated", user: null, accessToken: null });
|
|
3950
4215
|
}
|
|
3951
4216
|
}, delay);
|
|
@@ -3957,7 +4222,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
3957
4222
|
const user = await api.getMe(accessToken);
|
|
3958
4223
|
setAuth({ status: "authenticated", user, accessToken });
|
|
3959
4224
|
scheduleRefresh(accessToken);
|
|
3960
|
-
} catch (
|
|
4225
|
+
} catch (e9) {
|
|
3961
4226
|
setAuth({ status: "unauthenticated", user: null, accessToken: null });
|
|
3962
4227
|
}
|
|
3963
4228
|
};
|
|
@@ -3981,7 +4246,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
3981
4246
|
if (migrationToken) {
|
|
3982
4247
|
try {
|
|
3983
4248
|
localStorage.setItem("fc_matrica_migration_pending", migrationToken);
|
|
3984
|
-
} catch (
|
|
4249
|
+
} catch (e10) {
|
|
3985
4250
|
}
|
|
3986
4251
|
if (window.opener) {
|
|
3987
4252
|
window.opener.postMessage(
|
|
@@ -3996,7 +4261,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
3996
4261
|
if (authCode) {
|
|
3997
4262
|
try {
|
|
3998
4263
|
localStorage.setItem("fc_oauth_code_pending", authCode);
|
|
3999
|
-
} catch (
|
|
4264
|
+
} catch (e11) {
|
|
4000
4265
|
}
|
|
4001
4266
|
if (window.opener) {
|
|
4002
4267
|
window.opener.postMessage(
|
|
@@ -4013,7 +4278,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4013
4278
|
if (!exchangePromise) {
|
|
4014
4279
|
try {
|
|
4015
4280
|
localStorage.removeItem("fc_oauth_code_pending");
|
|
4016
|
-
} catch (
|
|
4281
|
+
} catch (e12) {
|
|
4017
4282
|
}
|
|
4018
4283
|
exchangePromise = (async () => {
|
|
4019
4284
|
try {
|
|
@@ -4025,7 +4290,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4025
4290
|
if (!token) return null;
|
|
4026
4291
|
const user = await api.getMe(token);
|
|
4027
4292
|
return { kind: "authenticated", accessToken: token, user };
|
|
4028
|
-
} catch (
|
|
4293
|
+
} catch (e13) {
|
|
4029
4294
|
return null;
|
|
4030
4295
|
}
|
|
4031
4296
|
})();
|
|
@@ -4041,7 +4306,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4041
4306
|
setModal({ isOpen: true, step: "success" });
|
|
4042
4307
|
setAuth({ status: "authenticated", user: outcome.user, accessToken: outcome.accessToken });
|
|
4043
4308
|
scheduleRefresh(outcome.accessToken);
|
|
4044
|
-
_optionalChain([onLogin, 'optionalCall',
|
|
4309
|
+
_optionalChain([onLogin, 'optionalCall', _129 => _129(outcome.user)]);
|
|
4045
4310
|
setTimeout(() => {
|
|
4046
4311
|
setModal({ isOpen: false, step: "method-select" });
|
|
4047
4312
|
}, 1500);
|
|
@@ -4049,24 +4314,24 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4049
4314
|
const handleMigrationToken = async (token) => {
|
|
4050
4315
|
try {
|
|
4051
4316
|
localStorage.removeItem("fc_matrica_migration_pending");
|
|
4052
|
-
} catch (
|
|
4317
|
+
} catch (e14) {
|
|
4053
4318
|
}
|
|
4054
4319
|
try {
|
|
4055
4320
|
const preview = await api.getMatricaMigration(token);
|
|
4056
4321
|
setMatricaMigration({ token, ...preview });
|
|
4057
4322
|
setModal({ isOpen: true, step: "matrica-migration" });
|
|
4058
|
-
} catch (
|
|
4323
|
+
} catch (e15) {
|
|
4059
4324
|
setModal({ isOpen: true, step: "error" });
|
|
4060
4325
|
}
|
|
4061
4326
|
};
|
|
4062
4327
|
const handleMessage = (event) => {
|
|
4063
4328
|
if (event.origin !== window.location.origin) return;
|
|
4064
|
-
if (_optionalChain([event, 'access',
|
|
4329
|
+
if (_optionalChain([event, 'access', _130 => _130.data, 'optionalAccess', _131 => _131.type]) === "fc_oauth_code") {
|
|
4065
4330
|
const code = event.data.code;
|
|
4066
4331
|
if (code) void handleCode(code);
|
|
4067
4332
|
return;
|
|
4068
4333
|
}
|
|
4069
|
-
if (_optionalChain([event, 'access',
|
|
4334
|
+
if (_optionalChain([event, 'access', _132 => _132.data, 'optionalAccess', _133 => _133.type]) === "fc_matrica_migration") {
|
|
4070
4335
|
const token = event.data.token;
|
|
4071
4336
|
if (token) void handleMigrationToken(token);
|
|
4072
4337
|
}
|
|
@@ -4085,7 +4350,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4085
4350
|
if (pending) void handleCode(pending);
|
|
4086
4351
|
const pendingMigration = localStorage.getItem("fc_matrica_migration_pending");
|
|
4087
4352
|
if (pendingMigration) void handleMigrationToken(pendingMigration);
|
|
4088
|
-
} catch (
|
|
4353
|
+
} catch (e16) {
|
|
4089
4354
|
}
|
|
4090
4355
|
window.addEventListener("message", handleMessage);
|
|
4091
4356
|
window.addEventListener("storage", handleStorage);
|
|
@@ -4094,6 +4359,11 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4094
4359
|
window.removeEventListener("storage", handleStorage);
|
|
4095
4360
|
};
|
|
4096
4361
|
}, [api, config.apiUrl, scheduleRefresh, onLogin]);
|
|
4362
|
+
_react.useEffect.call(void 0, () => {
|
|
4363
|
+
const methods = resolveLoginMethods(config);
|
|
4364
|
+
if (!methods.includes("wallet")) return;
|
|
4365
|
+
void registerMwaIfAvailable(config, config.mwa);
|
|
4366
|
+
}, [config]);
|
|
4097
4367
|
_react.useEffect.call(void 0, () => {
|
|
4098
4368
|
if (config.loginMethods && config.loginMethods.length > 0) {
|
|
4099
4369
|
const hasLegacy = config.oauthProviders || config.walletLogin !== void 0 || config.passwordlessLogin !== void 0;
|
|
@@ -4110,7 +4380,7 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4110
4380
|
setAuth({ status: "authenticated", user, accessToken: token });
|
|
4111
4381
|
scheduleRefresh(token);
|
|
4112
4382
|
setModal({ isOpen: true, step: "success" });
|
|
4113
|
-
_optionalChain([onLogin, 'optionalCall',
|
|
4383
|
+
_optionalChain([onLogin, 'optionalCall', _134 => _134(user)]);
|
|
4114
4384
|
setTimeout(() => {
|
|
4115
4385
|
setModal({ isOpen: false, step: "method-select" });
|
|
4116
4386
|
}, 1500);
|
|
@@ -4210,11 +4480,11 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4210
4480
|
const token = auth.accessToken;
|
|
4211
4481
|
if (refreshTimerRef.current) clearTimeout(refreshTimerRef.current);
|
|
4212
4482
|
setAuth({ status: "unauthenticated", user: null, accessToken: null });
|
|
4213
|
-
_optionalChain([onLogout, 'optionalCall',
|
|
4483
|
+
_optionalChain([onLogout, 'optionalCall', _135 => _135()]);
|
|
4214
4484
|
if (token) {
|
|
4215
4485
|
try {
|
|
4216
4486
|
await api.logout(token);
|
|
4217
|
-
} catch (
|
|
4487
|
+
} catch (e17) {
|
|
4218
4488
|
}
|
|
4219
4489
|
}
|
|
4220
4490
|
}, [auth.accessToken, api, onLogout]);
|
|
@@ -4264,11 +4534,11 @@ function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapt
|
|
|
4264
4534
|
const token = auth.accessToken;
|
|
4265
4535
|
if (refreshTimerRef.current) clearTimeout(refreshTimerRef.current);
|
|
4266
4536
|
setAuth({ status: "unauthenticated", user: null, accessToken: null });
|
|
4267
|
-
_optionalChain([onLogout, 'optionalCall',
|
|
4537
|
+
_optionalChain([onLogout, 'optionalCall', _136 => _136()]);
|
|
4268
4538
|
if (token) {
|
|
4269
4539
|
try {
|
|
4270
4540
|
await api.logoutAll(token);
|
|
4271
|
-
} catch (
|
|
4541
|
+
} catch (e18) {
|
|
4272
4542
|
}
|
|
4273
4543
|
}
|
|
4274
4544
|
}, [auth.accessToken, api, onLogout]);
|
|
@@ -4475,11 +4745,11 @@ function useAdmin() {
|
|
|
4475
4745
|
const token = getAccessToken();
|
|
4476
4746
|
if (!token) throw new Error("Please sign in to continue.");
|
|
4477
4747
|
await api.adminUpdateUserStatus(token, id, status);
|
|
4478
|
-
if (_optionalChain([selectedUser, 'optionalAccess',
|
|
4748
|
+
if (_optionalChain([selectedUser, 'optionalAccess', _137 => _137.id]) === id) {
|
|
4479
4749
|
await getUser(id);
|
|
4480
4750
|
}
|
|
4481
4751
|
},
|
|
4482
|
-
[api, getAccessToken, _optionalChain([selectedUser, 'optionalAccess',
|
|
4752
|
+
[api, getAccessToken, _optionalChain([selectedUser, 'optionalAccess', _138 => _138.id]), getUser]
|
|
4483
4753
|
);
|
|
4484
4754
|
const getUserSessions = _react.useCallback.call(void 0,
|
|
4485
4755
|
async (id) => {
|
|
@@ -4596,9 +4866,9 @@ function useRoles() {
|
|
|
4596
4866
|
const token = getAccessToken();
|
|
4597
4867
|
if (!token) throw new Error("Please sign in to continue.");
|
|
4598
4868
|
await api.adminDeleteRole(token, id);
|
|
4599
|
-
if (_optionalChain([selectedRole, 'optionalAccess',
|
|
4869
|
+
if (_optionalChain([selectedRole, 'optionalAccess', _139 => _139.id]) === id) setSelectedRole(null);
|
|
4600
4870
|
},
|
|
4601
|
-
[api, getAccessToken, _optionalChain([selectedRole, 'optionalAccess',
|
|
4871
|
+
[api, getAccessToken, _optionalChain([selectedRole, 'optionalAccess', _140 => _140.id])]
|
|
4602
4872
|
);
|
|
4603
4873
|
const getPermissions = _react.useCallback.call(void 0,
|
|
4604
4874
|
async () => {
|
|
@@ -4724,5 +4994,8 @@ function hasAnyPermission(required, granted) {
|
|
|
4724
4994
|
|
|
4725
4995
|
|
|
4726
4996
|
|
|
4727
|
-
|
|
4997
|
+
|
|
4998
|
+
|
|
4999
|
+
|
|
5000
|
+
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.connectSeekerBridge = connectSeekerBridge; exports.createApiClient = createApiClient; exports.hasAllPermissions = hasAllPermissions; exports.hasAnyPermission = hasAnyPermission; exports.hasPermission = hasPermission; exports.isOAuthMethod = isOAuthMethod; exports.isSeekerApp = isSeekerApp; 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
5001
|
//# sourceMappingURL=index.cjs.map
|