@embarkai/ui-kit 0.2.8 → 0.3.1
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/iframe/index.html +1 -1
- package/dist/iframe/main.js +22 -11
- package/dist/iframe/main.js.map +1 -1
- package/dist/index.cjs +205 -136
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +114 -45
- package/dist/index.js.map +1 -1
- package/package.json +15 -14
package/dist/index.cjs
CHANGED
|
@@ -877,6 +877,7 @@ var init_useLayoutDataStore = __esm({
|
|
|
877
877
|
transitionPageHeight: DEFAULT_MAIN_MENU_HEIGHT,
|
|
878
878
|
settingsNotifications: [],
|
|
879
879
|
isWalletLinking: false,
|
|
880
|
+
pendingWalletLogin: null,
|
|
880
881
|
setPageParams: (pageOptions) => set({ pageParams: pageOptions }),
|
|
881
882
|
setPage: (page) => set((prev) => ({
|
|
882
883
|
page,
|
|
@@ -898,7 +899,8 @@ var init_useLayoutDataStore = __esm({
|
|
|
898
899
|
const filtered = prev.settingsNotifications.filter((n) => n.id !== notification.id);
|
|
899
900
|
return { settingsNotifications: filtered };
|
|
900
901
|
}),
|
|
901
|
-
setIsWalletLinking: (isWalletLinking) => set({ isWalletLinking })
|
|
902
|
+
setIsWalletLinking: (isWalletLinking) => set({ isWalletLinking }),
|
|
903
|
+
setPendingWalletLogin: (pendingWalletLogin) => set({ pendingWalletLogin })
|
|
902
904
|
}));
|
|
903
905
|
}
|
|
904
906
|
});
|
|
@@ -1552,7 +1554,7 @@ var init_deploy_account = __esm({
|
|
|
1552
1554
|
|
|
1553
1555
|
// src/internal/clients/account/register-smart-account-address.ts
|
|
1554
1556
|
async function registerSmartAccountAddress(chainId, smartAccountAddress, factoryAddress) {
|
|
1555
|
-
const accessToken =
|
|
1557
|
+
const accessToken = import_auth19.jwtTokenManager.getAccessToken();
|
|
1556
1558
|
if (!accessToken) {
|
|
1557
1559
|
console.warn("[Account] No access token available for Smart Account registration");
|
|
1558
1560
|
return { success: true, chainId, smartAccountAddress, alreadySet: false };
|
|
@@ -1597,7 +1599,7 @@ async function registerSmartAccountAddress(chainId, smartAccountAddress, factory
|
|
|
1597
1599
|
}
|
|
1598
1600
|
}
|
|
1599
1601
|
async function getAllSmartAccounts() {
|
|
1600
|
-
const accessToken =
|
|
1602
|
+
const accessToken = import_auth19.jwtTokenManager.getAccessToken();
|
|
1601
1603
|
if (!accessToken) {
|
|
1602
1604
|
console.warn("[Account] No access token available");
|
|
1603
1605
|
return [];
|
|
@@ -1624,7 +1626,7 @@ async function getAllSmartAccounts() {
|
|
|
1624
1626
|
}
|
|
1625
1627
|
}
|
|
1626
1628
|
async function getSmartAccountForChain(chainId) {
|
|
1627
|
-
const accessToken =
|
|
1629
|
+
const accessToken = import_auth19.jwtTokenManager.getAccessToken();
|
|
1628
1630
|
if (!accessToken) {
|
|
1629
1631
|
console.warn("[Account] No access token available");
|
|
1630
1632
|
return null;
|
|
@@ -2174,7 +2176,7 @@ var init_httpClient = __esm({
|
|
|
2174
2176
|
...headers
|
|
2175
2177
|
};
|
|
2176
2178
|
if (requireAuth) {
|
|
2177
|
-
const accessToken =
|
|
2179
|
+
const accessToken = import_auth19.jwtTokenManager.getAccessToken();
|
|
2178
2180
|
if (accessToken) {
|
|
2179
2181
|
requestHeaders["Authorization"] = `Bearer ${accessToken}`;
|
|
2180
2182
|
}
|
|
@@ -2191,9 +2193,9 @@ var init_httpClient = __esm({
|
|
|
2191
2193
|
try {
|
|
2192
2194
|
const response = await fetch(url, requestConfig);
|
|
2193
2195
|
if (response.status === 401 && requireAuth) {
|
|
2194
|
-
const refreshSuccess = await
|
|
2196
|
+
const refreshSuccess = await import_auth19.jwtTokenManager.refreshAccessToken();
|
|
2195
2197
|
if (refreshSuccess) {
|
|
2196
|
-
const newAccessToken =
|
|
2198
|
+
const newAccessToken = import_auth19.jwtTokenManager.getAccessToken();
|
|
2197
2199
|
if (newAccessToken) {
|
|
2198
2200
|
requestHeaders["Authorization"] = `Bearer ${newAccessToken}`;
|
|
2199
2201
|
requestConfig.headers = requestHeaders;
|
|
@@ -2568,6 +2570,8 @@ function useAutoConnect() {
|
|
|
2568
2570
|
}
|
|
2569
2571
|
} catch (e) {
|
|
2570
2572
|
if (e?.code === "KEYSHARE_RECOVERY_NEEDED") {
|
|
2573
|
+
setSession(null);
|
|
2574
|
+
setAddress(null);
|
|
2571
2575
|
setRecoveryUserId(userId);
|
|
2572
2576
|
setError(null);
|
|
2573
2577
|
setStatus("recovery_needed");
|
|
@@ -3973,7 +3977,7 @@ function PassKeyStep(props) {
|
|
|
3973
3977
|
setPasskeyStatus("checking available passkeys...");
|
|
3974
3978
|
setIsLoading(true);
|
|
3975
3979
|
try {
|
|
3976
|
-
|
|
3980
|
+
import_auth19.jwtTokenManager.clearTokens();
|
|
3977
3981
|
setPasskeyStatus("authenticating with passkey...");
|
|
3978
3982
|
const result = await authenticateWithPasskey(
|
|
3979
3983
|
void 0,
|
|
@@ -4463,8 +4467,8 @@ function Social(props) {
|
|
|
4463
4467
|
const iframeManager = getIframeManager2();
|
|
4464
4468
|
const finalizeSocialLogin = async (rawLoginResponse, providerKey, userData) => {
|
|
4465
4469
|
let loginResponse2 = await normalizeSocialLoginResponse(rawLoginResponse, providerKey, userData);
|
|
4466
|
-
const existingAccessToken =
|
|
4467
|
-
const existingRefreshToken =
|
|
4470
|
+
const existingAccessToken = import_auth19.jwtTokenManager.getAccessToken();
|
|
4471
|
+
const existingRefreshToken = import_auth19.jwtTokenManager.getRefreshToken();
|
|
4468
4472
|
if (existingAccessToken && existingRefreshToken && !loginResponse2.accessToken) {
|
|
4469
4473
|
console.log("[AuthModal] Using tokens already stored by iframe-manager");
|
|
4470
4474
|
loginResponse2 = {
|
|
@@ -4493,7 +4497,7 @@ function Social(props) {
|
|
|
4493
4497
|
setIsLoading(false);
|
|
4494
4498
|
return;
|
|
4495
4499
|
}
|
|
4496
|
-
await
|
|
4500
|
+
await import_auth19.jwtTokenManager.clearTokens();
|
|
4497
4501
|
if (!loginResponse2.accessToken || !loginResponse2.refreshToken) {
|
|
4498
4502
|
console.warn(
|
|
4499
4503
|
"[AuthModal] Authentication tokens were not issued; continuing with cookie-based session only."
|
|
@@ -4502,7 +4506,7 @@ function Social(props) {
|
|
|
4502
4506
|
let tokensPersisted = false;
|
|
4503
4507
|
const persistTokensIfAvailable = async () => {
|
|
4504
4508
|
if (!tokensPersisted && loginResponse2.accessToken && loginResponse2.refreshToken) {
|
|
4505
|
-
await
|
|
4509
|
+
await import_auth19.jwtTokenManager.setTokens(loginResponse2);
|
|
4506
4510
|
tokensPersisted = true;
|
|
4507
4511
|
}
|
|
4508
4512
|
};
|
|
@@ -5015,7 +5019,7 @@ function useAuthMenuHandlers() {
|
|
|
5015
5019
|
const iframeManager = getIframeManager2();
|
|
5016
5020
|
await iframeManager.authenticate(userId, loginResponse.avatar, loginResponse.displayName);
|
|
5017
5021
|
if (loginResponse.accessToken && loginResponse.refreshToken) {
|
|
5018
|
-
await
|
|
5022
|
+
await import_auth19.jwtTokenManager.setTokens(loginResponse);
|
|
5019
5023
|
} else {
|
|
5020
5024
|
console.warn("[ConnectWalletButton] Login response missing tokens; skipping jwtTokenManager.setTokens");
|
|
5021
5025
|
}
|
|
@@ -5073,6 +5077,8 @@ function useAuthMenuHandlers() {
|
|
|
5073
5077
|
console.warn("[AuthMenu] Keyshare recovery needed for user:", userId);
|
|
5074
5078
|
pendingLoginResponseRef.current = null;
|
|
5075
5079
|
setError(null);
|
|
5080
|
+
setSession(null);
|
|
5081
|
+
setAddress(null);
|
|
5076
5082
|
setRecoveryUserId(userId);
|
|
5077
5083
|
setStatus("recovery_needed");
|
|
5078
5084
|
setTimeout(() => {
|
|
@@ -5080,7 +5086,7 @@ function useAuthMenuHandlers() {
|
|
|
5080
5086
|
}, 100);
|
|
5081
5087
|
} else {
|
|
5082
5088
|
pendingLoginResponseRef.current = null;
|
|
5083
|
-
await
|
|
5089
|
+
await import_auth19.jwtTokenManager.clearTokens();
|
|
5084
5090
|
setStatus("error");
|
|
5085
5091
|
setError(error?.message || String(error));
|
|
5086
5092
|
setAlert({
|
|
@@ -5482,6 +5488,7 @@ var init_AuthMenu = __esm({
|
|
|
5482
5488
|
init_SessionContext();
|
|
5483
5489
|
import_lucide_react8 = require("lucide-react");
|
|
5484
5490
|
import_react17 = require("react");
|
|
5491
|
+
init_auth();
|
|
5485
5492
|
init_constants();
|
|
5486
5493
|
init_useLayoutDataStore();
|
|
5487
5494
|
init_useLayoutStore();
|
|
@@ -5499,8 +5506,20 @@ var init_AuthMenu = __esm({
|
|
|
5499
5506
|
const isIframeReady = useSession((st) => st.isIframeReady);
|
|
5500
5507
|
const maxScrollHeight = useLayoutStore((st) => st.maxScrollHeight);
|
|
5501
5508
|
const setTransitionPageHeight = useLayoutDataStore((st) => st.setTransitionPageHeight);
|
|
5509
|
+
const pendingWalletLogin = useLayoutDataStore((st) => st.pendingWalletLogin);
|
|
5510
|
+
const setPendingWalletLogin = useLayoutDataStore((st) => st.setPendingWalletLogin);
|
|
5502
5511
|
const { step, alert: alert2, setStep, setPasskeyStatus, setEmail, setAlert } = useAuthStore();
|
|
5503
5512
|
const { pendingLoginResponseRef, onAuthSuccess, goBackToSignIn } = useAuthMenuHandlers();
|
|
5513
|
+
(0, import_react17.useEffect)(() => {
|
|
5514
|
+
if (!pendingWalletLogin) return;
|
|
5515
|
+
const loginResponse = pendingWalletLogin;
|
|
5516
|
+
setPendingWalletLogin(null);
|
|
5517
|
+
console.log("[AuthMenu] Processing wallet login response:", loginResponse);
|
|
5518
|
+
import_auth19.jwtTokenManager.clearTokens().then(() => {
|
|
5519
|
+
pendingLoginResponseRef.current = loginResponse;
|
|
5520
|
+
onAuthSuccess();
|
|
5521
|
+
});
|
|
5522
|
+
}, [pendingWalletLogin]);
|
|
5504
5523
|
(0, import_react17.useEffect)(() => {
|
|
5505
5524
|
setTransitionPageHeight(DEFAULT_AUTH_MENU_HEIGHT);
|
|
5506
5525
|
return () => {
|
|
@@ -6048,7 +6067,7 @@ var init_queryKeys = __esm({
|
|
|
6048
6067
|
|
|
6049
6068
|
// src/internal/components/BuyMenu/binance/api.ts
|
|
6050
6069
|
async function getLumiaNetworkQuery() {
|
|
6051
|
-
const accessToken =
|
|
6070
|
+
const accessToken = import_auth19.jwtTokenManager.getAccessToken();
|
|
6052
6071
|
if (!accessToken) {
|
|
6053
6072
|
throw new Error("Access token is not available");
|
|
6054
6073
|
}
|
|
@@ -6059,7 +6078,7 @@ async function getLumiaNetworkQuery() {
|
|
|
6059
6078
|
return await iframeManager.sendMessage("BINANCE_GET_LUMIA_NETWORK_QUERY", { accessToken });
|
|
6060
6079
|
}
|
|
6061
6080
|
async function getPaymentMethodsQuery(payload) {
|
|
6062
|
-
const accessToken =
|
|
6081
|
+
const accessToken = import_auth19.jwtTokenManager.getAccessToken();
|
|
6063
6082
|
if (!accessToken) {
|
|
6064
6083
|
throw new Error("Access token is not available");
|
|
6065
6084
|
}
|
|
@@ -6073,7 +6092,7 @@ async function getPaymentMethodsQuery(payload) {
|
|
|
6073
6092
|
});
|
|
6074
6093
|
}
|
|
6075
6094
|
async function getQuoteQuery(payload) {
|
|
6076
|
-
const accessToken =
|
|
6095
|
+
const accessToken = import_auth19.jwtTokenManager.getAccessToken();
|
|
6077
6096
|
if (!accessToken) {
|
|
6078
6097
|
throw new Error("Access token is not available");
|
|
6079
6098
|
}
|
|
@@ -6087,7 +6106,7 @@ async function getQuoteQuery(payload) {
|
|
|
6087
6106
|
});
|
|
6088
6107
|
}
|
|
6089
6108
|
async function createPreorderMutation(payload) {
|
|
6090
|
-
const accessToken =
|
|
6109
|
+
const accessToken = import_auth19.jwtTokenManager.getAccessToken();
|
|
6091
6110
|
if (!accessToken) {
|
|
6092
6111
|
throw new Error("Access token is not available");
|
|
6093
6112
|
}
|
|
@@ -6389,7 +6408,7 @@ var init_binance = __esm({
|
|
|
6389
6408
|
|
|
6390
6409
|
// src/internal/components/BuyMenu/rampnow/api.ts
|
|
6391
6410
|
async function getRampnowConfigQuery() {
|
|
6392
|
-
const accessToken =
|
|
6411
|
+
const accessToken = import_auth19.jwtTokenManager.getAccessToken();
|
|
6393
6412
|
if (!accessToken) {
|
|
6394
6413
|
throw new Error("Access token is not available");
|
|
6395
6414
|
}
|
|
@@ -6400,7 +6419,7 @@ async function getRampnowConfigQuery() {
|
|
|
6400
6419
|
return await iframeManager.sendMessage("RAMPNOW_GET_CONFIG", { accessToken });
|
|
6401
6420
|
}
|
|
6402
6421
|
async function getRampOrderQuoteQuery(payload) {
|
|
6403
|
-
const accessToken =
|
|
6422
|
+
const accessToken = import_auth19.jwtTokenManager.getAccessToken();
|
|
6404
6423
|
if (!accessToken) {
|
|
6405
6424
|
throw new Error("Access token is not available");
|
|
6406
6425
|
}
|
|
@@ -7649,9 +7668,9 @@ __export(passkey_exports2, {
|
|
|
7649
7668
|
linkPasskeyWithWebAuthn: () => linkPasskeyWithWebAuthn
|
|
7650
7669
|
});
|
|
7651
7670
|
async function completePasskeyLinking(payload) {
|
|
7652
|
-
const hasValidToken = await (0,
|
|
7671
|
+
const hasValidToken = await (0, import_auth19.ensureValidToken)();
|
|
7653
7672
|
if (!hasValidToken) throw new Error("No authentication token available");
|
|
7654
|
-
const response = await (0,
|
|
7673
|
+
const response = await (0, import_auth19.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/passkey/complete`, {
|
|
7655
7674
|
method: "POST",
|
|
7656
7675
|
body: JSON.stringify(payload)
|
|
7657
7676
|
});
|
|
@@ -7661,9 +7680,9 @@ async function completePasskeyLinking(payload) {
|
|
|
7661
7680
|
}
|
|
7662
7681
|
}
|
|
7663
7682
|
async function beginPasskeyLinking() {
|
|
7664
|
-
const hasValidToken = await (0,
|
|
7683
|
+
const hasValidToken = await (0, import_auth19.ensureValidToken)();
|
|
7665
7684
|
if (!hasValidToken) throw new Error("No authentication token available");
|
|
7666
|
-
let res = await (0,
|
|
7685
|
+
let res = await (0, import_auth19.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/passkey/begin`, { method: "POST" });
|
|
7667
7686
|
if (res.ok) {
|
|
7668
7687
|
const begin2 = await res.json();
|
|
7669
7688
|
const options2 = {
|
|
@@ -7678,7 +7697,7 @@ async function beginPasskeyLinking() {
|
|
|
7678
7697
|
};
|
|
7679
7698
|
return { challengeId: begin2.challengeId, options: options2 };
|
|
7680
7699
|
}
|
|
7681
|
-
res = await (0,
|
|
7700
|
+
res = await (0, import_auth19.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/passkey/options`, { method: "GET" });
|
|
7682
7701
|
if (!res.ok) throw new Error("Failed to get passkey linking options");
|
|
7683
7702
|
const begin = await res.json();
|
|
7684
7703
|
const options = {
|
|
@@ -7697,7 +7716,7 @@ async function linkPasskeyWithWebAuthn(optionsOverride) {
|
|
|
7697
7716
|
if (!("credentials" in navigator) || !("create" in navigator.credentials)) {
|
|
7698
7717
|
throw new Error("WebAuthn not supported in this browser");
|
|
7699
7718
|
}
|
|
7700
|
-
const userId =
|
|
7719
|
+
const userId = import_auth19.jwtTokenManager.getUserId();
|
|
7701
7720
|
if (!userId) throw new Error("No authenticated user");
|
|
7702
7721
|
let challengeId = null;
|
|
7703
7722
|
let publicKeyOptions = null;
|
|
@@ -7999,7 +8018,8 @@ function useCreateBackup() {
|
|
|
7999
8018
|
setIsDialogForced(true);
|
|
8000
8019
|
}
|
|
8001
8020
|
}, [hasServerVault, setIsDialogForced, setMethod]);
|
|
8002
|
-
const
|
|
8021
|
+
const recoveryUserId = useSession((st) => st.recoveryUserId);
|
|
8022
|
+
const passportUserId = session?.mpcUserId || recoveryUserId || "";
|
|
8003
8023
|
const onBackupSuccess = () => console.log("[ConnectWalletButton] Backup created successfully");
|
|
8004
8024
|
const { mutate: createPasswordBackup, isPending: isPasswordBackupCreating } = (0, import_react_query10.useMutation)({
|
|
8005
8025
|
mutationFn: async () => {
|
|
@@ -9709,9 +9729,9 @@ var init_LanguagesMenu2 = __esm({
|
|
|
9709
9729
|
|
|
9710
9730
|
// src/internal/auth/providers/common.ts
|
|
9711
9731
|
async function getLinkedProviders() {
|
|
9712
|
-
const hasValidToken = await (0,
|
|
9732
|
+
const hasValidToken = await (0, import_auth19.ensureValidToken)();
|
|
9713
9733
|
if (!hasValidToken) throw new Error("No authentication token available");
|
|
9714
|
-
const response = await (0,
|
|
9734
|
+
const response = await (0, import_auth19.authenticatedFetch)(`${getTssUrl3()}/api/auth/providers`, { method: "GET" });
|
|
9715
9735
|
if (!response.ok) {
|
|
9716
9736
|
const errorData = await response.json().catch(() => ({}));
|
|
9717
9737
|
throw new Error(errorData.message || `Failed to fetch providers: ${response.statusText}`);
|
|
@@ -9720,11 +9740,11 @@ async function getLinkedProviders() {
|
|
|
9720
9740
|
return data.providers;
|
|
9721
9741
|
}
|
|
9722
9742
|
async function unlinkProvider(providerType, externalId) {
|
|
9723
|
-
const hasValidToken = await (0,
|
|
9743
|
+
const hasValidToken = await (0, import_auth19.ensureValidToken)();
|
|
9724
9744
|
if (!hasValidToken) throw new Error("No authentication token available");
|
|
9725
9745
|
let url = `${getTssUrl3()}/api/auth/unlink/${providerType}`;
|
|
9726
9746
|
if (externalId) url += `?externalId=${encodeURIComponent(externalId)}`;
|
|
9727
|
-
const response = await (0,
|
|
9747
|
+
const response = await (0, import_auth19.authenticatedFetch)(url, { method: "DELETE" });
|
|
9728
9748
|
if (!response.ok) {
|
|
9729
9749
|
const errorData = await response.json().catch(() => ({}));
|
|
9730
9750
|
throw new Error(errorData.message || `Failed to unlink provider: ${response.statusText}`);
|
|
@@ -9732,12 +9752,12 @@ async function unlinkProvider(providerType, externalId) {
|
|
|
9732
9752
|
try {
|
|
9733
9753
|
const data = await response.json();
|
|
9734
9754
|
if (data?.accessToken && data?.refreshToken && data?.expiresIn) {
|
|
9735
|
-
|
|
9755
|
+
import_auth19.jwtTokenManager.setTokens({
|
|
9736
9756
|
accessToken: data.accessToken,
|
|
9737
9757
|
refreshToken: data.refreshToken,
|
|
9738
|
-
userId:
|
|
9758
|
+
userId: import_auth19.jwtTokenManager.getUserId() || "",
|
|
9739
9759
|
expiresIn: data.expiresIn,
|
|
9740
|
-
hasKeyshare:
|
|
9760
|
+
hasKeyshare: import_auth19.jwtTokenManager.getHasKeyshare() ?? false
|
|
9741
9761
|
});
|
|
9742
9762
|
}
|
|
9743
9763
|
} catch {
|
|
@@ -9834,7 +9854,7 @@ async function getLinkProfilesData() {
|
|
|
9834
9854
|
});
|
|
9835
9855
|
let avatar = null;
|
|
9836
9856
|
try {
|
|
9837
|
-
avatar =
|
|
9857
|
+
avatar = import_auth19.jwtTokenManager.getAvatar() || null;
|
|
9838
9858
|
} catch {
|
|
9839
9859
|
avatar = null;
|
|
9840
9860
|
}
|
|
@@ -10011,9 +10031,9 @@ var init_EmailForm = __esm({
|
|
|
10011
10031
|
|
|
10012
10032
|
// src/internal/auth/providers/email.ts
|
|
10013
10033
|
async function sendEmailLinkCode(email) {
|
|
10014
|
-
const hasValidToken = await (0,
|
|
10034
|
+
const hasValidToken = await (0, import_auth19.ensureValidToken)();
|
|
10015
10035
|
if (!hasValidToken) throw new Error("No authentication token available");
|
|
10016
|
-
const response = await (0,
|
|
10036
|
+
const response = await (0, import_auth19.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/email/send-code`, {
|
|
10017
10037
|
method: "POST",
|
|
10018
10038
|
body: JSON.stringify({ email })
|
|
10019
10039
|
});
|
|
@@ -10023,9 +10043,9 @@ async function sendEmailLinkCode(email) {
|
|
|
10023
10043
|
}
|
|
10024
10044
|
}
|
|
10025
10045
|
async function verifyEmailLinkCode(email, code) {
|
|
10026
|
-
const hasValidToken = await (0,
|
|
10046
|
+
const hasValidToken = await (0, import_auth19.ensureValidToken)();
|
|
10027
10047
|
if (!hasValidToken) throw new Error("No authentication token available");
|
|
10028
|
-
const response = await (0,
|
|
10048
|
+
const response = await (0, import_auth19.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/email/verify-code`, {
|
|
10029
10049
|
method: "POST",
|
|
10030
10050
|
credentials: "include",
|
|
10031
10051
|
body: JSON.stringify({ email, code })
|
|
@@ -10297,7 +10317,7 @@ var init_AddProvider = __esm({
|
|
|
10297
10317
|
|
|
10298
10318
|
// src/internal/components/ManageWalletMenu/EmailNotConnectedWarning.tsx
|
|
10299
10319
|
function EmailNotConnectedWarning() {
|
|
10300
|
-
const providers =
|
|
10320
|
+
const providers = import_auth19.jwtTokenManager.getProviders();
|
|
10301
10321
|
const hasEmail = providers.includes("email");
|
|
10302
10322
|
const { t } = useT();
|
|
10303
10323
|
const config = useProviderConfig().config;
|
|
@@ -10358,11 +10378,11 @@ function useLinkSocial() {
|
|
|
10358
10378
|
mode: "link"
|
|
10359
10379
|
};
|
|
10360
10380
|
try {
|
|
10361
|
-
await (0,
|
|
10381
|
+
await (0, import_auth19.ensureValidToken)();
|
|
10362
10382
|
} catch (tokenError) {
|
|
10363
10383
|
console.warn("[ManageWallet] ensureValidToken failed before linking", tokenError);
|
|
10364
10384
|
}
|
|
10365
|
-
const accessToken =
|
|
10385
|
+
const accessToken = import_auth19.jwtTokenManager.getAccessToken();
|
|
10366
10386
|
if (accessToken) {
|
|
10367
10387
|
authConfig.token = accessToken;
|
|
10368
10388
|
}
|
|
@@ -10429,7 +10449,7 @@ var init_useLinkSocial = __esm({
|
|
|
10429
10449
|
|
|
10430
10450
|
// src/internal/auth/providers/telegram.ts
|
|
10431
10451
|
async function linkTelegram(telegramData) {
|
|
10432
|
-
const hasValidToken = await (0,
|
|
10452
|
+
const hasValidToken = await (0, import_auth19.ensureValidToken)();
|
|
10433
10453
|
if (!hasValidToken) throw new Error("No authentication token available");
|
|
10434
10454
|
const formattedData = {
|
|
10435
10455
|
id: telegramData.id,
|
|
@@ -10440,7 +10460,7 @@ async function linkTelegram(telegramData) {
|
|
|
10440
10460
|
if (telegramData.last_name) formattedData.last_name = telegramData.last_name;
|
|
10441
10461
|
if (telegramData.username) formattedData.username = telegramData.username;
|
|
10442
10462
|
if (telegramData.photo_url) formattedData.photo_url = telegramData.photo_url;
|
|
10443
|
-
const response = await (0,
|
|
10463
|
+
const response = await (0, import_auth19.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/telegram`, {
|
|
10444
10464
|
method: "POST",
|
|
10445
10465
|
body: JSON.stringify(formattedData)
|
|
10446
10466
|
});
|
|
@@ -12592,8 +12612,8 @@ function SecurityMenu() {
|
|
|
12592
12612
|
const { t } = useT();
|
|
12593
12613
|
const maxScrollHeight = useLayoutStore((st) => st.maxScrollHeight);
|
|
12594
12614
|
const setPage = useLayoutDataStore((st) => st.setPage);
|
|
12595
|
-
const userId =
|
|
12596
|
-
const serverHasKeyshare =
|
|
12615
|
+
const userId = import_auth19.jwtTokenManager.getUserId();
|
|
12616
|
+
const serverHasKeyshare = import_auth19.jwtTokenManager.getHasKeyshare() ?? false;
|
|
12597
12617
|
const [isRemoving, setIsRemoving] = (0, import_react49.useState)(false);
|
|
12598
12618
|
const [appToRemove, setAppToRemove] = (0, import_react49.useState)(null);
|
|
12599
12619
|
const {
|
|
@@ -15503,7 +15523,7 @@ var init_usePageMapper = __esm({
|
|
|
15503
15523
|
function useSettingsNotifications() {
|
|
15504
15524
|
const address = useSession((st) => st.address);
|
|
15505
15525
|
const setSettingsNotifications = useLayoutDataStore((st) => st.setSettingsNotifications);
|
|
15506
|
-
const providers =
|
|
15526
|
+
const providers = import_auth19.jwtTokenManager.getProviders();
|
|
15507
15527
|
const hasEmail = providers.includes("email");
|
|
15508
15528
|
const { data: userProfile = null } = (0, import_react_query38.useQuery)({
|
|
15509
15529
|
retry: false,
|
|
@@ -15553,7 +15573,7 @@ var init_package = __esm({
|
|
|
15553
15573
|
"package.json"() {
|
|
15554
15574
|
package_default = {
|
|
15555
15575
|
name: "@embarkai/ui-kit",
|
|
15556
|
-
version: "0.
|
|
15576
|
+
version: "0.3.1",
|
|
15557
15577
|
description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
|
|
15558
15578
|
type: "module",
|
|
15559
15579
|
main: "./dist/index.cjs",
|
|
@@ -15591,51 +15611,52 @@ var init_package = __esm({
|
|
|
15591
15611
|
},
|
|
15592
15612
|
peerDependencies: {
|
|
15593
15613
|
"@tanstack/react-query": ">=5.0.0",
|
|
15614
|
+
i18next: "^25.8.0",
|
|
15594
15615
|
react: ">=18",
|
|
15595
15616
|
"react-dom": ">=18",
|
|
15596
|
-
"
|
|
15597
|
-
|
|
15598
|
-
"react-i18next": "^16.5.3"
|
|
15617
|
+
"react-i18next": "^16.5.3",
|
|
15618
|
+
"tailwind-merge": ">=2.2.0"
|
|
15599
15619
|
},
|
|
15600
15620
|
dependencies: {
|
|
15601
|
-
"@
|
|
15621
|
+
"@embarkai/core": "workspace:*",
|
|
15602
15622
|
"@radix-ui/react-checkbox": ">=1.3.3",
|
|
15603
|
-
"@radix-ui/react-select": ">=2.2.6",
|
|
15604
15623
|
"@radix-ui/react-dialog": ">=1.1.15",
|
|
15605
|
-
"@
|
|
15624
|
+
"@radix-ui/react-select": ">=2.2.6",
|
|
15625
|
+
"@radix-ui/react-slot": ">=1.2.4",
|
|
15606
15626
|
"@rainbow-me/rainbowkit": "^2.2.10",
|
|
15607
15627
|
"@sentry/browser": "^10.22.0",
|
|
15608
15628
|
"class-variance-authority": "^0.7.0",
|
|
15609
|
-
"lodash-es": "^4.17.21",
|
|
15610
15629
|
clsx: "^2.1.1",
|
|
15630
|
+
dayjs: "^1.11.9",
|
|
15611
15631
|
"dkls23-wasm": "^0.1.0",
|
|
15632
|
+
"framer-motion": "^12.23.24",
|
|
15633
|
+
"lodash-es": "^4.17.21",
|
|
15612
15634
|
"lucide-react": "^0.454.0",
|
|
15613
15635
|
qrcode: "^1.5.0",
|
|
15614
|
-
zustand: "^5.0.8",
|
|
15615
15636
|
viem: "^2.38.0",
|
|
15616
15637
|
wagmi: "^2.17.5",
|
|
15617
|
-
|
|
15618
|
-
"framer-motion": "^12.23.24"
|
|
15638
|
+
zustand: "^5.0.8"
|
|
15619
15639
|
},
|
|
15620
15640
|
devDependencies: {
|
|
15621
15641
|
"@tailwindcss/typography": "^0.5.16",
|
|
15622
15642
|
"@tanstack/react-query": "^5.90.2",
|
|
15643
|
+
"@types/lodash-es": "^4.17.12",
|
|
15623
15644
|
"@types/qrcode": "^1.5.0",
|
|
15624
15645
|
"@types/react": "^18.3.3",
|
|
15625
15646
|
"@types/react-dom": "^18.3.0",
|
|
15626
15647
|
autoprefixer: "^10.4.20",
|
|
15627
15648
|
dotenv: "^17.2.3",
|
|
15649
|
+
i18next: "^25.8.0",
|
|
15628
15650
|
postcss: "^8.4.47",
|
|
15629
15651
|
react: "^18.3.1",
|
|
15630
15652
|
"react-dom": "^18.3.1",
|
|
15653
|
+
"react-i18next": "^16.5.3",
|
|
15631
15654
|
"tailwind-merge": "^2.2.0",
|
|
15632
|
-
"@types/lodash-es": "^4.17.12",
|
|
15633
15655
|
tailwindcss: "^3.4.10",
|
|
15634
15656
|
tsup: "^8.5.0",
|
|
15635
15657
|
typescript: "^5.4.5",
|
|
15636
15658
|
vite: "^5.0.0",
|
|
15637
|
-
|
|
15638
|
-
"react-i18next": "^16.5.3"
|
|
15659
|
+
vitest: "^4.0.18"
|
|
15639
15660
|
},
|
|
15640
15661
|
repository: {
|
|
15641
15662
|
type: "git",
|
|
@@ -15665,7 +15686,7 @@ function Footer() {
|
|
|
15665
15686
|
setError(null);
|
|
15666
15687
|
setStatus("disconnecting");
|
|
15667
15688
|
setIsLoading(true);
|
|
15668
|
-
const userId =
|
|
15689
|
+
const userId = import_auth19.jwtTokenManager.getUserId() || null;
|
|
15669
15690
|
const { logout: logout2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
|
|
15670
15691
|
await logout2();
|
|
15671
15692
|
return { disconnectedUserId: userId, disconnectAddress };
|
|
@@ -15802,8 +15823,8 @@ function Header() {
|
|
|
15802
15823
|
queryKey: [QUERY_KEYS.userProfile, address],
|
|
15803
15824
|
queryFn: getUserProfile
|
|
15804
15825
|
});
|
|
15805
|
-
const avatar = profile?.avatar ||
|
|
15806
|
-
const displayName = profile?.nicknameDisplay || profile?.displayName ||
|
|
15826
|
+
const avatar = profile?.avatar || import_auth19.jwtTokenManager.getAvatar();
|
|
15827
|
+
const displayName = profile?.nicknameDisplay || profile?.displayName || import_auth19.jwtTokenManager.getDisplayName();
|
|
15807
15828
|
const ChainIcon = NETWORK_OPTIONS.find((net) => net.chainId === chainConfig.id)?.Icon || (() => /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "flex-none w-4 h-4 rounded-full flex items-center justify-center bg-[var(--ui-kit-primary)]", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("span", { className: "text-[var(--ui-kit-fg-inverted)] text-xs font-bold", children: chainConfig.name.charAt(0) }) }));
|
|
15808
15829
|
return /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
|
|
15809
15830
|
"div",
|
|
@@ -16237,10 +16258,23 @@ var init_TssManager = __esm({
|
|
|
16237
16258
|
});
|
|
16238
16259
|
|
|
16239
16260
|
// src/internal/auth/providers/wallet.ts
|
|
16261
|
+
async function walletLogin(walletData) {
|
|
16262
|
+
const response = await fetch(addProjectIdToUrl(`${getTssUrl3()}/api/auth/wallet/login`), {
|
|
16263
|
+
method: "POST",
|
|
16264
|
+
headers: { "Content-Type": "application/json" },
|
|
16265
|
+
credentials: "include",
|
|
16266
|
+
body: JSON.stringify(walletData)
|
|
16267
|
+
});
|
|
16268
|
+
if (!response.ok) {
|
|
16269
|
+
const errorData = await response.json().catch(() => ({}));
|
|
16270
|
+
throw new Error(errorData.message || `Wallet login failed: ${response.statusText}`);
|
|
16271
|
+
}
|
|
16272
|
+
return response.json();
|
|
16273
|
+
}
|
|
16240
16274
|
async function linkWallet(walletData) {
|
|
16241
|
-
const hasValidToken = await (0,
|
|
16275
|
+
const hasValidToken = await (0, import_auth19.ensureValidToken)();
|
|
16242
16276
|
if (!hasValidToken) throw new Error("No authentication token available");
|
|
16243
|
-
const response = await (0,
|
|
16277
|
+
const response = await (0, import_auth19.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/wallet`, {
|
|
16244
16278
|
method: "POST",
|
|
16245
16279
|
body: JSON.stringify(walletData)
|
|
16246
16280
|
});
|
|
@@ -16250,9 +16284,9 @@ async function linkWallet(walletData) {
|
|
|
16250
16284
|
}
|
|
16251
16285
|
}
|
|
16252
16286
|
async function unlinkWallet(address) {
|
|
16253
|
-
const hasValidToken = await (0,
|
|
16287
|
+
const hasValidToken = await (0, import_auth19.ensureValidToken)();
|
|
16254
16288
|
if (!hasValidToken) throw new Error("No authentication token available");
|
|
16255
|
-
const response = await (0,
|
|
16289
|
+
const response = await (0, import_auth19.authenticatedFetch)(
|
|
16256
16290
|
`${getTssUrl3()}/api/auth/unlink/wallet?address=${encodeURIComponent(address)}`,
|
|
16257
16291
|
{
|
|
16258
16292
|
method: "DELETE"
|
|
@@ -16289,9 +16323,23 @@ Timestamp: ${timestamp}
|
|
|
16289
16323
|
|
|
16290
16324
|
Sign this message to link your wallet to ${projectName} Wallet`;
|
|
16291
16325
|
}
|
|
16326
|
+
function createLoginMessage(address, projectName) {
|
|
16327
|
+
const nonce = crypto.randomUUID();
|
|
16328
|
+
const timestamp = Date.now();
|
|
16329
|
+
return [
|
|
16330
|
+
`${projectName} Wallet Login`,
|
|
16331
|
+
"",
|
|
16332
|
+
`Address: ${address}`,
|
|
16333
|
+
`Nonce: ${nonce}`,
|
|
16334
|
+
`Timestamp: ${timestamp}`,
|
|
16335
|
+
"",
|
|
16336
|
+
`Sign this message to login your wallet to ${projectName}`
|
|
16337
|
+
].join("\n");
|
|
16338
|
+
}
|
|
16292
16339
|
var METADATA_API_URL, METADATA_CACHE_TTL, metadataCache;
|
|
16293
16340
|
var init_wallet = __esm({
|
|
16294
16341
|
"src/internal/auth/providers/wallet.ts"() {
|
|
16342
|
+
init_projectId();
|
|
16295
16343
|
init_auth();
|
|
16296
16344
|
init_types();
|
|
16297
16345
|
METADATA_API_URL = "https://dashboard.lumiapassport.com/api/public/project";
|
|
@@ -16351,6 +16399,7 @@ function WalletConnectHandler() {
|
|
|
16351
16399
|
const walletMode = providerConfig?.wallet?.mode || "linked";
|
|
16352
16400
|
const projectId = providerConfig?.projectId;
|
|
16353
16401
|
const setExternalWallet = useExternalWalletStore((st) => st.setExternalWallet);
|
|
16402
|
+
const setPendingWalletLogin = useLayoutDataStore((st) => st.setPendingWalletLogin);
|
|
16354
16403
|
const onLinkingComplete = (0, import_react63.useCallback)(
|
|
16355
16404
|
async (success) => {
|
|
16356
16405
|
setIsWalletLinking(false);
|
|
@@ -16390,19 +16439,8 @@ function WalletConnectHandler() {
|
|
|
16390
16439
|
});
|
|
16391
16440
|
setHasStartedLinking(true);
|
|
16392
16441
|
setProviderType(null);
|
|
16393
|
-
|
|
16394
|
-
|
|
16395
|
-
setTimeout(() => {
|
|
16396
|
-
setPage(null);
|
|
16397
|
-
if (openConnectModal) {
|
|
16398
|
-
openConnectModal();
|
|
16399
|
-
} else {
|
|
16400
|
-
console.error("[WalletConnectHandler] openConnectModal is undefined!");
|
|
16401
|
-
setIsWalletLinking(false);
|
|
16402
|
-
setHasStartedLinking(false);
|
|
16403
|
-
}
|
|
16404
|
-
}, 500);
|
|
16405
|
-
} else {
|
|
16442
|
+
disconnect();
|
|
16443
|
+
setTimeout(() => {
|
|
16406
16444
|
setPage(null);
|
|
16407
16445
|
if (openConnectModal) {
|
|
16408
16446
|
openConnectModal();
|
|
@@ -16411,7 +16449,7 @@ function WalletConnectHandler() {
|
|
|
16411
16449
|
setIsWalletLinking(false);
|
|
16412
16450
|
setHasStartedLinking(false);
|
|
16413
16451
|
}
|
|
16414
|
-
}
|
|
16452
|
+
}, 500);
|
|
16415
16453
|
}
|
|
16416
16454
|
if (!isWalletLinking && hasStartedLinking) {
|
|
16417
16455
|
setHasStartedLinking(false);
|
|
@@ -16439,12 +16477,21 @@ function WalletConnectHandler() {
|
|
|
16439
16477
|
if (isWalletLinking) {
|
|
16440
16478
|
const timeout = setTimeout(() => {
|
|
16441
16479
|
console.warn("[WalletConnectHandler] Wallet linking timed out, resetting state");
|
|
16480
|
+
disconnect();
|
|
16442
16481
|
setIsWalletLinking(false);
|
|
16443
16482
|
setHasStartedLinking(false);
|
|
16483
|
+
if (passportWalletAddress) {
|
|
16484
|
+
setManageWalletLinkError("Wallet connection timed out. Please try again.");
|
|
16485
|
+
setPage("manage-wallet" /* MANAGE_WALLET */);
|
|
16486
|
+
} else {
|
|
16487
|
+
setAuthError({ title: "Connection timed out", message: "Wallet did not respond. Please try again." });
|
|
16488
|
+
setPage("auth" /* AUTH */);
|
|
16489
|
+
}
|
|
16444
16490
|
}, 12e4);
|
|
16445
16491
|
return () => clearTimeout(timeout);
|
|
16446
16492
|
}
|
|
16447
|
-
}, [isWalletLinking, setIsWalletLinking]);
|
|
16493
|
+
}, [isWalletLinking, setIsWalletLinking, disconnect]);
|
|
16494
|
+
const isAuthFlow = !passportWalletAddress;
|
|
16448
16495
|
const { mutate: handleWalletSign, isPending: isWalletSigning } = (0, import_react_query41.useMutation)({
|
|
16449
16496
|
mutationFn: async (payload) => {
|
|
16450
16497
|
const { chainId, signingWalletAddress } = payload;
|
|
@@ -16463,24 +16510,45 @@ function WalletConnectHandler() {
|
|
|
16463
16510
|
}
|
|
16464
16511
|
setLinkIsLoading(true);
|
|
16465
16512
|
const projectName = projectId ? await fetchProjectName(projectId) : "EmbarkAI";
|
|
16466
|
-
const message = createSignatureMessage(signingWalletAddress, projectName);
|
|
16467
|
-
const signature = await
|
|
16513
|
+
const message = isAuthFlow ? createLoginMessage(signingWalletAddress, projectName) : createSignatureMessage(signingWalletAddress, projectName);
|
|
16514
|
+
const signature = await Promise.race([
|
|
16515
|
+
signMessageAsync({ message, account: signingWalletAddress }),
|
|
16516
|
+
new Promise(
|
|
16517
|
+
(_, reject) => setTimeout(() => reject(new Error("Signature request timed out. Please try again.")), 6e4)
|
|
16518
|
+
)
|
|
16519
|
+
]);
|
|
16468
16520
|
if (!signature) {
|
|
16469
16521
|
throw new Error("Failed to get signature");
|
|
16470
16522
|
}
|
|
16471
16523
|
const walletName = connector?.name || "Unknown Wallet";
|
|
16472
16524
|
const walletType = connector?.id || "unknown";
|
|
16473
|
-
|
|
16474
|
-
// chainId: chain.id,
|
|
16525
|
+
const walletData = {
|
|
16475
16526
|
chainId,
|
|
16476
16527
|
address: signingWalletAddress,
|
|
16477
16528
|
signature,
|
|
16478
16529
|
message,
|
|
16479
16530
|
walletName,
|
|
16480
16531
|
walletType
|
|
16481
|
-
}
|
|
16532
|
+
};
|
|
16533
|
+
if (isAuthFlow) {
|
|
16534
|
+
const loginResponse = await walletLogin(walletData);
|
|
16535
|
+
return loginResponse;
|
|
16536
|
+
} else {
|
|
16537
|
+
await linkWallet(walletData);
|
|
16538
|
+
return void 0;
|
|
16539
|
+
}
|
|
16482
16540
|
},
|
|
16483
|
-
onSuccess: () => {
|
|
16541
|
+
onSuccess: (data) => {
|
|
16542
|
+
if (isAuthFlow && data) {
|
|
16543
|
+
console.log("[WalletConnectHandler] Wallet login successful, passing to AuthMenu");
|
|
16544
|
+
disconnect();
|
|
16545
|
+
setPendingWalletLogin(data);
|
|
16546
|
+
setIsWalletLinking(false);
|
|
16547
|
+
setHasStartedLinking(false);
|
|
16548
|
+
setLinkIsLoading(false);
|
|
16549
|
+
setPage("auth" /* AUTH */);
|
|
16550
|
+
return;
|
|
16551
|
+
}
|
|
16484
16552
|
const shouldKeepConnected = walletMode === "direct" || walletMode === "both";
|
|
16485
16553
|
if (shouldKeepConnected && walletAddress && chain?.id && connector) {
|
|
16486
16554
|
setExternalWallet({
|
|
@@ -16501,7 +16569,7 @@ function WalletConnectHandler() {
|
|
|
16501
16569
|
onLinkingComplete(false);
|
|
16502
16570
|
setHasStartedLinking(false);
|
|
16503
16571
|
setLinkIsLoading(false);
|
|
16504
|
-
const errorMsg = err?.message || "Failed to link wallet";
|
|
16572
|
+
const errorMsg = err?.message || (isAuthFlow ? "Wallet login failed" : "Failed to link wallet");
|
|
16505
16573
|
if (errorMsg.includes("User rejected") || errorMsg.includes("User denied")) {
|
|
16506
16574
|
if (passportWalletAddress) {
|
|
16507
16575
|
setManageWalletLinkError("Signature request was cancelled");
|
|
@@ -17548,7 +17616,7 @@ var init_vaultClient = __esm({
|
|
|
17548
17616
|
|
|
17549
17617
|
// src/internal/auth/keyshare.ts
|
|
17550
17618
|
async function checkKeyshareStatusWithSync(userId) {
|
|
17551
|
-
const serverHasKeyshare = await (0,
|
|
17619
|
+
const serverHasKeyshare = await (0, import_auth19.syncKeyshareStatus)();
|
|
17552
17620
|
return checkKeyshareStatus(userId, serverHasKeyshare);
|
|
17553
17621
|
}
|
|
17554
17622
|
async function checkKeyshareStatus(userId, serverHasKeyshare) {
|
|
@@ -17582,7 +17650,7 @@ async function ensureKeyshareForNewUser(userId, onProgress) {
|
|
|
17582
17650
|
onProgress?.("Setting up secure key management...");
|
|
17583
17651
|
const result = await ensureDkgAndGetOwner(userId);
|
|
17584
17652
|
if (!result.ownerAddress) throw new Error("DKG completed but no owner address received");
|
|
17585
|
-
await (0,
|
|
17653
|
+
await (0, import_auth19.syncKeyshareStatus)();
|
|
17586
17654
|
onProgress?.("Key management setup complete");
|
|
17587
17655
|
return { ownerAddress: result.ownerAddress };
|
|
17588
17656
|
}
|
|
@@ -17667,7 +17735,7 @@ var init_keyshare = __esm({
|
|
|
17667
17735
|
|
|
17668
17736
|
// src/internal/auth/providers/x.ts
|
|
17669
17737
|
async function linkX() {
|
|
17670
|
-
const hasValidToken = await (0,
|
|
17738
|
+
const hasValidToken = await (0, import_auth19.ensureValidToken)();
|
|
17671
17739
|
if (!hasValidToken) throw new Error("No authentication token available");
|
|
17672
17740
|
throw new Error('Use openSocialAuthPopup("x") to link X account');
|
|
17673
17741
|
}
|
|
@@ -17675,10 +17743,10 @@ async function loginWithX() {
|
|
|
17675
17743
|
throw new Error('Use openSocialAuthPopup("x") to login with X account');
|
|
17676
17744
|
}
|
|
17677
17745
|
async function unlinkX(externalId) {
|
|
17678
|
-
const hasValidToken = await (0,
|
|
17746
|
+
const hasValidToken = await (0, import_auth19.ensureValidToken)();
|
|
17679
17747
|
if (!hasValidToken) throw new Error("No authentication token available");
|
|
17680
17748
|
const url = externalId ? `${getTssUrl3()}/api/auth/unlink/x?externalId=${encodeURIComponent(externalId)}` : `${getTssUrl3()}/api/auth/unlink/x`;
|
|
17681
|
-
const response = await (0,
|
|
17749
|
+
const response = await (0, import_auth19.authenticatedFetch)(url, {
|
|
17682
17750
|
method: "DELETE"
|
|
17683
17751
|
});
|
|
17684
17752
|
if (!response.ok) {
|
|
@@ -17709,9 +17777,9 @@ var init_providers = __esm({
|
|
|
17709
17777
|
// src/internal/auth/index.ts
|
|
17710
17778
|
var auth_exports = {};
|
|
17711
17779
|
__export(auth_exports, {
|
|
17712
|
-
JwtTokenManager: () =>
|
|
17780
|
+
JwtTokenManager: () => import_auth19.JwtTokenManager,
|
|
17713
17781
|
authenticateWithPasskey: () => authenticateWithPasskey,
|
|
17714
|
-
authenticatedFetch: () =>
|
|
17782
|
+
authenticatedFetch: () => import_auth19.authenticatedFetch,
|
|
17715
17783
|
beginPasskeyAuthentication: () => beginPasskeyAuthentication,
|
|
17716
17784
|
beginPasskeyLinking: () => beginPasskeyLinking,
|
|
17717
17785
|
beginPasskeyRegistration: () => beginPasskeyRegistration,
|
|
@@ -17721,51 +17789,53 @@ __export(auth_exports, {
|
|
|
17721
17789
|
completePasskeyAuthentication: () => completePasskeyAuthentication,
|
|
17722
17790
|
completePasskeyLinking: () => completePasskeyLinking,
|
|
17723
17791
|
completePasskeyRegistration: () => completePasskeyRegistration,
|
|
17724
|
-
configureJwtModule: () =>
|
|
17792
|
+
configureJwtModule: () => import_auth19.configureJwtModule,
|
|
17725
17793
|
createInitialAuthState: () => createInitialAuthState,
|
|
17726
|
-
createJwtTokenManager: () =>
|
|
17794
|
+
createJwtTokenManager: () => import_auth19.createJwtTokenManager,
|
|
17795
|
+
createLoginMessage: () => createLoginMessage,
|
|
17727
17796
|
createPasskeyHelpers: () => createPasskeyHelpers,
|
|
17728
17797
|
createSignatureMessage: () => createSignatureMessage,
|
|
17729
17798
|
deriveDemoPrivateKey: () => deriveDemoPrivateKey,
|
|
17730
17799
|
ensureKeyshare: () => ensureKeyshare,
|
|
17731
|
-
ensureValidToken: () =>
|
|
17800
|
+
ensureValidToken: () => import_auth19.ensureValidToken,
|
|
17732
17801
|
fetchProjectName: () => fetchProjectName,
|
|
17733
17802
|
formatDate: () => formatDate,
|
|
17734
17803
|
getKeyshareInfo: () => getKeyshareInfo,
|
|
17735
17804
|
getLinkedProviders: () => getLinkedProviders,
|
|
17736
17805
|
getProviderDisplayInfo: () => getProviderDisplayInfo,
|
|
17737
17806
|
getTssUrl: () => getTssUrl3,
|
|
17738
|
-
getValidTokens: () =>
|
|
17807
|
+
getValidTokens: () => import_auth19.getValidTokens,
|
|
17739
17808
|
hasAvailablePasskeys: () => hasAvailablePasskeys,
|
|
17740
17809
|
hideTelegramWidget: () => hideTelegramWidget,
|
|
17741
17810
|
initTelegramWidget: () => initTelegramWidget,
|
|
17742
17811
|
isWebAuthnSupported: () => isWebAuthnSupported,
|
|
17743
|
-
jwtTokenManager: () =>
|
|
17812
|
+
jwtTokenManager: () => import_auth19.jwtTokenManager,
|
|
17744
17813
|
linkPasskeyWithWebAuthn: () => linkPasskeyWithWebAuthn,
|
|
17745
17814
|
linkTelegram: () => linkTelegram,
|
|
17746
17815
|
linkWallet: () => linkWallet,
|
|
17747
17816
|
linkX: () => linkX,
|
|
17748
|
-
loginWithEmail: () =>
|
|
17749
|
-
loginWithTelegram: () =>
|
|
17750
|
-
loginWithUserId: () =>
|
|
17817
|
+
loginWithEmail: () => import_auth19.loginWithEmail,
|
|
17818
|
+
loginWithTelegram: () => import_auth19.loginWithTelegram,
|
|
17819
|
+
loginWithUserId: () => import_auth19.loginWithUserId,
|
|
17751
17820
|
loginWithX: () => loginWithX,
|
|
17752
|
-
logout: () =>
|
|
17821
|
+
logout: () => import_auth19.logout,
|
|
17753
17822
|
mountTelegramLoginWidget: () => mountTelegramLoginWidget,
|
|
17754
17823
|
registerPasskey: () => registerPasskey,
|
|
17755
17824
|
resetWebAuthnFlags: () => resetWebAuthnFlags,
|
|
17756
17825
|
sendEmailLinkCode: () => sendEmailLinkCode,
|
|
17757
17826
|
showTelegramWidget: () => showTelegramWidget,
|
|
17758
|
-
syncKeyshareStatus: () =>
|
|
17827
|
+
syncKeyshareStatus: () => import_auth19.syncKeyshareStatus,
|
|
17759
17828
|
unlinkProvider: () => unlinkProvider,
|
|
17760
17829
|
unlinkWallet: () => unlinkWallet,
|
|
17761
17830
|
unlinkX: () => unlinkX,
|
|
17762
17831
|
verifyEmailLinkCode: () => verifyEmailLinkCode,
|
|
17763
|
-
verifyToken: () =>
|
|
17832
|
+
verifyToken: () => import_auth19.verifyToken,
|
|
17833
|
+
walletLogin: () => walletLogin
|
|
17764
17834
|
});
|
|
17765
|
-
var
|
|
17835
|
+
var import_auth19, createInitialAuthState;
|
|
17766
17836
|
var init_auth = __esm({
|
|
17767
17837
|
"src/internal/auth/index.ts"() {
|
|
17768
|
-
|
|
17838
|
+
import_auth19 = require("@embarkai/core/auth");
|
|
17769
17839
|
init_passkeyAuth();
|
|
17770
17840
|
init_telegram();
|
|
17771
17841
|
init_passkey();
|
|
@@ -19023,10 +19093,9 @@ var init_iframe_manager = __esm({
|
|
|
19023
19093
|
});
|
|
19024
19094
|
|
|
19025
19095
|
// src/config/rainbowkit.ts
|
|
19026
|
-
var
|
|
19096
|
+
var import_rainbowkit2, import_wallets, import_chains, getProjectId, WALLET_MAP, createRainbowConfig, rainbowTheme;
|
|
19027
19097
|
var init_rainbowkit = __esm({
|
|
19028
19098
|
"src/config/rainbowkit.ts"() {
|
|
19029
|
-
import_read13 = require("@embarkai/core/read");
|
|
19030
19099
|
import_rainbowkit2 = require("@rainbow-me/rainbowkit");
|
|
19031
19100
|
import_wallets = require("@rainbow-me/rainbowkit/wallets");
|
|
19032
19101
|
import_chains = require("wagmi/chains");
|
|
@@ -19048,7 +19117,7 @@ var init_rainbowkit = __esm({
|
|
|
19048
19117
|
const config = {
|
|
19049
19118
|
appName: "EmbarkAI Wallet",
|
|
19050
19119
|
projectId: getProjectId(opts.projectId),
|
|
19051
|
-
chains: [
|
|
19120
|
+
chains: [import_chains.mainnet, import_chains.polygon, import_chains.bsc, import_chains.arbitrum, import_chains.optimism, import_chains.avalanche, import_chains.base, import_chains.zora],
|
|
19052
19121
|
ssr: false
|
|
19053
19122
|
};
|
|
19054
19123
|
if (opts.allowedWallets && opts.allowedWallets.length > 0) {
|
|
@@ -19327,17 +19396,17 @@ function buildTransport(urls) {
|
|
|
19327
19396
|
retryCount: 0
|
|
19328
19397
|
});
|
|
19329
19398
|
}
|
|
19330
|
-
var
|
|
19399
|
+
var import_read13, import_viem17, import_wagmi5, wagmiConfig;
|
|
19331
19400
|
var init_wagmi = __esm({
|
|
19332
19401
|
"src/config/wagmi.ts"() {
|
|
19333
|
-
|
|
19402
|
+
import_read13 = require("@embarkai/core/read");
|
|
19334
19403
|
import_viem17 = require("viem");
|
|
19335
19404
|
import_wagmi5 = require("wagmi");
|
|
19336
19405
|
wagmiConfig = (0, import_wagmi5.createConfig)({
|
|
19337
|
-
chains: [
|
|
19406
|
+
chains: [import_read13.lumiaMainnetChain, import_read13.lumiaTestnetChain],
|
|
19338
19407
|
transports: {
|
|
19339
|
-
[
|
|
19340
|
-
[
|
|
19408
|
+
[import_read13.lumiaTestnetChain.id]: buildTransport(import_read13.lumiaTestnetChain.rpcUrls.default.http),
|
|
19409
|
+
[import_read13.lumiaMainnetChain.id]: buildTransport(import_read13.lumiaMainnetChain.rpcUrls.default.http)
|
|
19341
19410
|
}
|
|
19342
19411
|
});
|
|
19343
19412
|
}
|
|
@@ -19510,11 +19579,11 @@ function ConnectWalletButton(props) {
|
|
|
19510
19579
|
queryKey: [QUERY_KEYS.userProfile, address],
|
|
19511
19580
|
queryFn: getUserProfile
|
|
19512
19581
|
});
|
|
19513
|
-
const displayName = profile?.nicknameDisplay || profile?.displayName ||
|
|
19582
|
+
const displayName = profile?.nicknameDisplay || profile?.displayName || import_auth19.jwtTokenManager.getDisplayName();
|
|
19514
19583
|
const indicators = (0, import_react68.useMemo)(() => {
|
|
19515
19584
|
const userId = session?.mpcUserId;
|
|
19516
19585
|
if (!userId) return { server: false, local: false, backup: false };
|
|
19517
|
-
const server =
|
|
19586
|
+
const server = import_auth19.jwtTokenManager.getHasKeyshare() ?? false;
|
|
19518
19587
|
const local = !!address;
|
|
19519
19588
|
return { server, local, backup: hasServerVault };
|
|
19520
19589
|
}, [session, address, hasServerVault]);
|
|
@@ -19811,7 +19880,7 @@ var init_LangToggle = __esm({
|
|
|
19811
19880
|
// src/clients/bundler/getUserOperationByHash.ts
|
|
19812
19881
|
async function getUserOperationByHash(userOpHash, chainId) {
|
|
19813
19882
|
const targetChainId = chainId ?? requireActiveChainId();
|
|
19814
|
-
const chainConfig = (0,
|
|
19883
|
+
const chainConfig = (0, import_read14.getChainConfig)(targetChainId);
|
|
19815
19884
|
if (!chainConfig) {
|
|
19816
19885
|
throw new Error(`Chain ${targetChainId} is not supported`);
|
|
19817
19886
|
}
|
|
@@ -19839,19 +19908,19 @@ async function getUserOperationByHash(userOpHash, chainId) {
|
|
|
19839
19908
|
return null;
|
|
19840
19909
|
}
|
|
19841
19910
|
}
|
|
19842
|
-
var import_core,
|
|
19911
|
+
var import_core, import_read14;
|
|
19843
19912
|
var init_getUserOperationByHash = __esm({
|
|
19844
19913
|
"src/clients/bundler/getUserOperationByHash.ts"() {
|
|
19845
19914
|
init_SessionContext();
|
|
19846
19915
|
import_core = require("@embarkai/core");
|
|
19847
|
-
|
|
19916
|
+
import_read14 = require("@embarkai/core/read");
|
|
19848
19917
|
}
|
|
19849
19918
|
});
|
|
19850
19919
|
|
|
19851
19920
|
// src/clients/bundler/getUserOperationReceipt.ts
|
|
19852
19921
|
async function getUserOperationReceipt(userOpHash, chainId) {
|
|
19853
19922
|
const targetChainId = chainId ?? requireActiveChainId();
|
|
19854
|
-
const chainConfig = (0,
|
|
19923
|
+
const chainConfig = (0, import_read15.getChainConfig)(targetChainId);
|
|
19855
19924
|
if (!chainConfig) {
|
|
19856
19925
|
throw new Error(`Chain ${targetChainId} is not supported`);
|
|
19857
19926
|
}
|
|
@@ -19885,12 +19954,12 @@ async function getUserOperationReceipt(userOpHash, chainId) {
|
|
|
19885
19954
|
return null;
|
|
19886
19955
|
}
|
|
19887
19956
|
}
|
|
19888
|
-
var import_core2,
|
|
19957
|
+
var import_core2, import_read15;
|
|
19889
19958
|
var init_getUserOperationReceipt = __esm({
|
|
19890
19959
|
"src/clients/bundler/getUserOperationReceipt.ts"() {
|
|
19891
19960
|
init_SessionContext();
|
|
19892
19961
|
import_core2 = require("@embarkai/core");
|
|
19893
|
-
|
|
19962
|
+
import_read15 = require("@embarkai/core/read");
|
|
19894
19963
|
}
|
|
19895
19964
|
});
|
|
19896
19965
|
|
|
@@ -20833,12 +20902,12 @@ function useLogout() {
|
|
|
20833
20902
|
let userId = null;
|
|
20834
20903
|
setIsLoading(true);
|
|
20835
20904
|
try {
|
|
20836
|
-
userId =
|
|
20905
|
+
userId = import_auth21.jwtTokenManager.getUserId() || null;
|
|
20837
20906
|
} catch (error) {
|
|
20838
20907
|
console.warn("[useLogout] Could not get userId:", error);
|
|
20839
20908
|
}
|
|
20840
20909
|
try {
|
|
20841
|
-
await (0,
|
|
20910
|
+
await (0, import_auth21.logout)();
|
|
20842
20911
|
} catch (error) {
|
|
20843
20912
|
console.warn("[useLogout] Core logout failed:", error);
|
|
20844
20913
|
}
|
|
@@ -20858,10 +20927,10 @@ function useLogout() {
|
|
|
20858
20927
|
}, [address, setAddress, setError, setSession, setStatus]);
|
|
20859
20928
|
return { logout: logout2 };
|
|
20860
20929
|
}
|
|
20861
|
-
var
|
|
20930
|
+
var import_auth21, import_react75;
|
|
20862
20931
|
var init_useLogout = __esm({
|
|
20863
20932
|
"src/hooks/useLogout.ts"() {
|
|
20864
|
-
|
|
20933
|
+
import_auth21 = require("@embarkai/core/auth");
|
|
20865
20934
|
import_react75 = require("react");
|
|
20866
20935
|
init_ProviderContext();
|
|
20867
20936
|
init_SessionContext();
|
|
@@ -20922,7 +20991,7 @@ var init_clients2 = __esm({
|
|
|
20922
20991
|
// src/modules/transactions.ts
|
|
20923
20992
|
function useTransactions() {
|
|
20924
20993
|
const chainId = requireActiveChainId();
|
|
20925
|
-
const viemChain = (0,
|
|
20994
|
+
const viemChain = (0, import_read16.getViemChain)(chainId);
|
|
20926
20995
|
const publicClient = (0, import_wagmi10.usePublicClient)({ chainId });
|
|
20927
20996
|
const { data: walletClient } = (0, import_wagmi10.useWalletClient)();
|
|
20928
20997
|
const { address } = (0, import_wagmi10.useAccount)();
|
|
@@ -20980,11 +21049,11 @@ function useTransactions() {
|
|
|
20980
21049
|
isConnected: !!address && !!walletClient
|
|
20981
21050
|
};
|
|
20982
21051
|
}
|
|
20983
|
-
var
|
|
21052
|
+
var import_read16, import_viem20, import_wagmi10;
|
|
20984
21053
|
var init_transactions = __esm({
|
|
20985
21054
|
"src/modules/transactions.ts"() {
|
|
20986
21055
|
init_SessionContext();
|
|
20987
|
-
|
|
21056
|
+
import_read16 = require("@embarkai/core/read");
|
|
20988
21057
|
import_viem20 = require("viem");
|
|
20989
21058
|
import_wagmi10 = require("wagmi");
|
|
20990
21059
|
}
|
|
@@ -21251,9 +21320,9 @@ __export(index_exports, {
|
|
|
21251
21320
|
getUserOperationByHash: () => getUserOperationByHash,
|
|
21252
21321
|
getUserOperationReceipt: () => getUserOperationReceipt,
|
|
21253
21322
|
getUserProfile: () => getUserProfile,
|
|
21254
|
-
getValidTokens: () =>
|
|
21255
|
-
jwtTokenManager: () =>
|
|
21256
|
-
logout: () =>
|
|
21323
|
+
getValidTokens: () => import_auth19.getValidTokens,
|
|
21324
|
+
jwtTokenManager: () => import_auth19.jwtTokenManager,
|
|
21325
|
+
logout: () => import_auth19.logout,
|
|
21257
21326
|
looksLikeNickname: () => looksLikeNickname,
|
|
21258
21327
|
prepareUserOperation: () => prepareUserOperation,
|
|
21259
21328
|
requireActiveChainId: () => requireActiveChainId,
|