@embarkai/ui-kit 0.2.2 → 0.2.3
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 +1 -1
- package/dist/index.cjs +107 -87
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +107 -87
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -328,7 +328,14 @@ interface CallbacksConfig {
|
|
|
328
328
|
interface UIContextType {
|
|
329
329
|
config: MutableRefObject<ProviderConfig>;
|
|
330
330
|
updateConfig: (updates: Partial<ProviderConfig>) => void;
|
|
331
|
+
/**
|
|
332
|
+
* Legacy snapshot of callbacks from provider props.
|
|
333
|
+
* This field is not reactive and may become stale after calling updateCallbacks().
|
|
334
|
+
* Use callbacksRef to read the current callbacks.
|
|
335
|
+
* @deprecated
|
|
336
|
+
*/
|
|
331
337
|
callbacks?: CallbacksConfig;
|
|
338
|
+
callbacksRef: MutableRefObject<CallbacksConfig | undefined>;
|
|
332
339
|
updateCallbacks: (updates: Partial<CallbacksConfig> | null) => void;
|
|
333
340
|
}
|
|
334
341
|
interface ProviderProps {
|
package/dist/index.d.ts
CHANGED
|
@@ -328,7 +328,14 @@ interface CallbacksConfig {
|
|
|
328
328
|
interface UIContextType {
|
|
329
329
|
config: MutableRefObject<ProviderConfig>;
|
|
330
330
|
updateConfig: (updates: Partial<ProviderConfig>) => void;
|
|
331
|
+
/**
|
|
332
|
+
* Legacy snapshot of callbacks from provider props.
|
|
333
|
+
* This field is not reactive and may become stale after calling updateCallbacks().
|
|
334
|
+
* Use callbacksRef to read the current callbacks.
|
|
335
|
+
* @deprecated
|
|
336
|
+
*/
|
|
331
337
|
callbacks?: CallbacksConfig;
|
|
338
|
+
callbacksRef: MutableRefObject<CallbacksConfig | undefined>;
|
|
332
339
|
updateCallbacks: (updates: Partial<CallbacksConfig> | null) => void;
|
|
333
340
|
}
|
|
334
341
|
interface ProviderProps {
|
package/dist/index.js
CHANGED
|
@@ -832,27 +832,27 @@ var PageKey, useLayoutDataStore;
|
|
|
832
832
|
var init_useLayoutDataStore = __esm({
|
|
833
833
|
"src/internal/hooks/useLayoutDataStore.ts"() {
|
|
834
834
|
init_constants();
|
|
835
|
-
PageKey = /* @__PURE__ */ ((
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
return
|
|
835
|
+
PageKey = /* @__PURE__ */ ((PageKey3) => {
|
|
836
|
+
PageKey3["AUTH"] = "auth";
|
|
837
|
+
PageKey3["LANGUAGES"] = "languages";
|
|
838
|
+
PageKey3["TERMS_OF_SERVICE"] = "terms-of-service";
|
|
839
|
+
PageKey3["MAIN_MENU"] = "main-menu";
|
|
840
|
+
PageKey3["SETTINGS"] = "settings";
|
|
841
|
+
PageKey3["SEND"] = "send";
|
|
842
|
+
PageKey3["RECEIVE"] = "receive";
|
|
843
|
+
PageKey3["BUY"] = "buy";
|
|
844
|
+
PageKey3["KYC"] = "kyc";
|
|
845
|
+
PageKey3["TRANSACTIONS"] = "transactions";
|
|
846
|
+
PageKey3["ASSETS"] = "assets";
|
|
847
|
+
PageKey3["MANAGE_WALLET"] = "manage-wallet";
|
|
848
|
+
PageKey3["UNLINK_PROVIDER"] = "unlink-provider";
|
|
849
|
+
PageKey3["SECURITY"] = "security";
|
|
850
|
+
PageKey3["KEYSARE_BACKUP"] = "keysare-backup";
|
|
851
|
+
PageKey3["KEYSHARE_RESTORE"] = "keyshare-restore";
|
|
852
|
+
PageKey3["CHAIN"] = "chain";
|
|
853
|
+
PageKey3["CHAIN_SWITCH_REQUEST"] = "chain-switch-request";
|
|
854
|
+
PageKey3["NICKNAME_SETTINGS"] = "nickname-settings";
|
|
855
|
+
return PageKey3;
|
|
856
856
|
})(PageKey || {});
|
|
857
857
|
useLayoutDataStore = create((set) => ({
|
|
858
858
|
page: null,
|
|
@@ -1148,7 +1148,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
|
1148
1148
|
import { throttle } from "lodash-es";
|
|
1149
1149
|
import { useCallback, useEffect as useEffect2, useRef } from "react";
|
|
1150
1150
|
function ChainSync() {
|
|
1151
|
-
const { config,
|
|
1151
|
+
const { config, callbacksRef } = useProviderConfig();
|
|
1152
1152
|
const qc = useQueryClient();
|
|
1153
1153
|
const setPage = useLayoutDataStore((st) => st.setPage);
|
|
1154
1154
|
const { address, session, activeChainId, setAddress, setSession, setActiveChain, setIsLoading, setStatus, setError } = useSession();
|
|
@@ -1213,7 +1213,7 @@ function ChainSync() {
|
|
|
1213
1213
|
address: smartAccountAddress,
|
|
1214
1214
|
factoryAddress: chainConfig.factoryAddress
|
|
1215
1215
|
});
|
|
1216
|
-
await
|
|
1216
|
+
await callbacksRef.current?.onChainChange?.({
|
|
1217
1217
|
chainId: targetChainId,
|
|
1218
1218
|
previousChainId: prevChainId.current
|
|
1219
1219
|
});
|
|
@@ -2397,7 +2397,7 @@ import { useCallback as useCallback2, useEffect as useEffect3, useRef as useRef2
|
|
|
2397
2397
|
function useAutoConnect() {
|
|
2398
2398
|
const {
|
|
2399
2399
|
config: { current: config },
|
|
2400
|
-
|
|
2400
|
+
callbacksRef
|
|
2401
2401
|
} = useProviderConfig();
|
|
2402
2402
|
const setPage = useLayoutDataStore((st) => st.setPage);
|
|
2403
2403
|
const {
|
|
@@ -2420,7 +2420,7 @@ function useAutoConnect() {
|
|
|
2420
2420
|
async (userId, hasServerKeyshare, isNewUser) => {
|
|
2421
2421
|
try {
|
|
2422
2422
|
try {
|
|
2423
|
-
|
|
2423
|
+
callbacksRef.current?.onConnecting?.({ method: "wallet" });
|
|
2424
2424
|
} catch {
|
|
2425
2425
|
}
|
|
2426
2426
|
setStatus("checking key management setup...");
|
|
@@ -2452,7 +2452,7 @@ function useAutoConnect() {
|
|
|
2452
2452
|
throw error;
|
|
2453
2453
|
}
|
|
2454
2454
|
},
|
|
2455
|
-
[usePaymaster, setStatus,
|
|
2455
|
+
[usePaymaster, setStatus, activeChainId]
|
|
2456
2456
|
);
|
|
2457
2457
|
const autoConnectAttemptedRef = useRef2(false);
|
|
2458
2458
|
useEffect3(() => {
|
|
@@ -2504,7 +2504,7 @@ function useAutoConnect() {
|
|
|
2504
2504
|
}
|
|
2505
2505
|
const finalHasKeyshare = verify?.hasKeyshare ?? hasKeyshare ?? false;
|
|
2506
2506
|
try {
|
|
2507
|
-
|
|
2507
|
+
callbacksRef.current?.onAccount?.({ userId, address: null, session: null, hasKeyshare: finalHasKeyshare });
|
|
2508
2508
|
} catch (error) {
|
|
2509
2509
|
console.warn("[UI-KIT][AutoConnect] Error due onAccount callback:", error);
|
|
2510
2510
|
}
|
|
@@ -2520,12 +2520,12 @@ function useAutoConnect() {
|
|
|
2520
2520
|
setStatus("ready");
|
|
2521
2521
|
setIsLoading(false);
|
|
2522
2522
|
try {
|
|
2523
|
-
|
|
2523
|
+
callbacksRef.current?.onConnect?.({ address: addr, session: sess });
|
|
2524
2524
|
} catch (error) {
|
|
2525
2525
|
console.warn("[UI-KIT][AutoConnect] Error due onConnect callback:", error);
|
|
2526
2526
|
}
|
|
2527
2527
|
try {
|
|
2528
|
-
|
|
2528
|
+
callbacksRef.current?.onAccount?.({
|
|
2529
2529
|
userId,
|
|
2530
2530
|
address: addr,
|
|
2531
2531
|
session: sess,
|
|
@@ -3888,7 +3888,7 @@ function PassKeyStep(props) {
|
|
|
3888
3888
|
const { pendingLoginResponseRef, onAuthSuccess } = props;
|
|
3889
3889
|
const {
|
|
3890
3890
|
config: { current: config },
|
|
3891
|
-
|
|
3891
|
+
callbacksRef
|
|
3892
3892
|
} = useProviderConfig();
|
|
3893
3893
|
const { t } = useT();
|
|
3894
3894
|
const isLoading = useSession((st) => st.isLoading);
|
|
@@ -3944,7 +3944,7 @@ function PassKeyStep(props) {
|
|
|
3944
3944
|
}
|
|
3945
3945
|
if (!normalized.benignCancel) {
|
|
3946
3946
|
try {
|
|
3947
|
-
|
|
3947
|
+
callbacksRef.current?.onError?.({
|
|
3948
3948
|
error: e instanceof Error ? e : new Error(errorMessage),
|
|
3949
3949
|
message: errorMessage
|
|
3950
3950
|
});
|
|
@@ -3955,7 +3955,7 @@ function PassKeyStep(props) {
|
|
|
3955
3955
|
} finally {
|
|
3956
3956
|
setIsLoading(false);
|
|
3957
3957
|
}
|
|
3958
|
-
}, [onAuthSuccess, setPage
|
|
3958
|
+
}, [onAuthSuccess, setPage]);
|
|
3959
3959
|
const onPasskeyAuth = useCallback6(async () => {
|
|
3960
3960
|
setAlert(null);
|
|
3961
3961
|
setPasskeyStatus("checking available passkeys...");
|
|
@@ -4024,7 +4024,7 @@ function PassKeyStep(props) {
|
|
|
4024
4024
|
message: errorMessage
|
|
4025
4025
|
});
|
|
4026
4026
|
try {
|
|
4027
|
-
|
|
4027
|
+
callbacksRef.current?.onError?.({
|
|
4028
4028
|
error: e instanceof Error ? e : new Error(errorMessage),
|
|
4029
4029
|
message: errorMessage
|
|
4030
4030
|
});
|
|
@@ -4036,7 +4036,7 @@ function PassKeyStep(props) {
|
|
|
4036
4036
|
} finally {
|
|
4037
4037
|
setIsLoading(false);
|
|
4038
4038
|
}
|
|
4039
|
-
}, [onAuthSuccess, setPage
|
|
4039
|
+
}, [onAuthSuccess, setPage]);
|
|
4040
4040
|
return /* @__PURE__ */ jsxs5(Fragment3, { children: [
|
|
4041
4041
|
/* @__PURE__ */ jsxs5("div", { className: "relative flex items-center justify-center gap-2 px-5 pt-3 pb-6", children: [
|
|
4042
4042
|
/* @__PURE__ */ jsx8(Key2, { className: "w-6 h-6" }),
|
|
@@ -4149,7 +4149,7 @@ import { ChevronRight, Loader as Loader2, Mail as Mail2 } from "lucide-react";
|
|
|
4149
4149
|
import { useEffect as useEffect8, useRef as useRef5 } from "react";
|
|
4150
4150
|
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
4151
4151
|
function Email() {
|
|
4152
|
-
const {
|
|
4152
|
+
const { callbacksRef } = useProviderConfig();
|
|
4153
4153
|
const { t } = useT();
|
|
4154
4154
|
const focusRef = useRef5(null);
|
|
4155
4155
|
const inputRef = useRef5(null);
|
|
@@ -4201,7 +4201,7 @@ function Email() {
|
|
|
4201
4201
|
setIsLoading(false);
|
|
4202
4202
|
},
|
|
4203
4203
|
onError: (error) => {
|
|
4204
|
-
|
|
4204
|
+
callbacksRef.current?.onError?.({ error, message: error?.message || "" });
|
|
4205
4205
|
setAlert({
|
|
4206
4206
|
title: "Failed to send verification code",
|
|
4207
4207
|
message: error?.message || "Unknown error occurred"
|
|
@@ -4421,7 +4421,7 @@ import { useCallback as useCallback7 } from "react";
|
|
|
4421
4421
|
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
4422
4422
|
function Social(props) {
|
|
4423
4423
|
const { pendingLoginResponseRef, onAuthSuccess } = props;
|
|
4424
|
-
const { config
|
|
4424
|
+
const { config } = useProviderConfig();
|
|
4425
4425
|
const { t } = useT();
|
|
4426
4426
|
const isLoading = useSession((st) => st.isLoading);
|
|
4427
4427
|
const setIsLoading = useSession((st) => st.setIsLoading);
|
|
@@ -4605,7 +4605,7 @@ function Social(props) {
|
|
|
4605
4605
|
setIsLoading(false);
|
|
4606
4606
|
}
|
|
4607
4607
|
},
|
|
4608
|
-
[onAuthSuccess
|
|
4608
|
+
[onAuthSuccess]
|
|
4609
4609
|
);
|
|
4610
4610
|
const enabledSocialProviders = config.current?.social?.providers?.filter((provider) => provider.enabled) || [];
|
|
4611
4611
|
const isPasskey = !!config.current?.passkey?.enabled;
|
|
@@ -4919,7 +4919,7 @@ var init_constants4 = __esm({
|
|
|
4919
4919
|
import { useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
4920
4920
|
import { useCallback as useCallback8, useRef as useRef6, useState as useState2 } from "react";
|
|
4921
4921
|
function useAuthMenuHandlers() {
|
|
4922
|
-
const { config,
|
|
4922
|
+
const { config, callbacksRef } = useProviderConfig();
|
|
4923
4923
|
const qc = useQueryClient2();
|
|
4924
4924
|
const pendingLoginResponseRef = useRef6(null);
|
|
4925
4925
|
const setPage = useLayoutDataStore((st) => st.setPage);
|
|
@@ -4943,7 +4943,7 @@ function useAuthMenuHandlers() {
|
|
|
4943
4943
|
async (userId, hasServerKeyshare, isNewUser) => {
|
|
4944
4944
|
try {
|
|
4945
4945
|
try {
|
|
4946
|
-
|
|
4946
|
+
callbacksRef.current?.onConnecting?.({ method: "wallet" });
|
|
4947
4947
|
} catch {
|
|
4948
4948
|
}
|
|
4949
4949
|
setStatus("checking key management setup...");
|
|
@@ -4978,7 +4978,7 @@ function useAuthMenuHandlers() {
|
|
|
4978
4978
|
throw error;
|
|
4979
4979
|
}
|
|
4980
4980
|
},
|
|
4981
|
-
[setStatus,
|
|
4981
|
+
[setStatus, usePaymaster, activeChainId]
|
|
4982
4982
|
);
|
|
4983
4983
|
const onAuthSuccess = useCallback8(async () => {
|
|
4984
4984
|
setIsLoading(true);
|
|
@@ -5031,12 +5031,12 @@ function useAuthMenuHandlers() {
|
|
|
5031
5031
|
setAddress(addr);
|
|
5032
5032
|
setStatus("ready");
|
|
5033
5033
|
try {
|
|
5034
|
-
|
|
5034
|
+
callbacksRef.current?.onConnect?.({ address: addr, session: sess });
|
|
5035
5035
|
} catch (error) {
|
|
5036
5036
|
console.warn("[UI-KIT][AuthMenu] Error due onConnect callback:", error);
|
|
5037
5037
|
}
|
|
5038
5038
|
try {
|
|
5039
|
-
|
|
5039
|
+
callbacksRef.current?.onAccount?.({ userId, address: addr, session: sess, hasKeyshare: hasServerKeyshare });
|
|
5040
5040
|
} catch (error) {
|
|
5041
5041
|
console.warn("[UI-KIT][AuthMenu] Error due onAccount callback:", error);
|
|
5042
5042
|
}
|
|
@@ -5078,7 +5078,6 @@ function useAuthMenuHandlers() {
|
|
|
5078
5078
|
}
|
|
5079
5079
|
}, [
|
|
5080
5080
|
qc,
|
|
5081
|
-
callbacks,
|
|
5082
5081
|
setStep,
|
|
5083
5082
|
setPage,
|
|
5084
5083
|
setError,
|
|
@@ -5276,7 +5275,7 @@ import { ArrowLeft as ArrowLeft2, Loader as Loader3 } from "lucide-react";
|
|
|
5276
5275
|
import { Fragment as Fragment7, jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
5277
5276
|
function VerifyStep(props) {
|
|
5278
5277
|
const { pendingLoginResponseRef, goBackToSignIn, onAuthSuccess } = props;
|
|
5279
|
-
const {
|
|
5278
|
+
const { callbacksRef } = useProviderConfig();
|
|
5280
5279
|
const { t } = useT();
|
|
5281
5280
|
const recoveryUserId = useSession((st) => st.recoveryUserId);
|
|
5282
5281
|
const isSessionLoading = useSession((st) => st.isLoading);
|
|
@@ -5349,7 +5348,7 @@ function VerifyStep(props) {
|
|
|
5349
5348
|
title: "Verification failed",
|
|
5350
5349
|
message: errorMessage
|
|
5351
5350
|
});
|
|
5352
|
-
|
|
5351
|
+
callbacksRef.current?.onError?.({
|
|
5353
5352
|
error: error instanceof Error ? error : new Error(errorMessage),
|
|
5354
5353
|
message: errorMessage
|
|
5355
5354
|
});
|
|
@@ -7440,7 +7439,7 @@ var init_useRestoreStore = __esm({
|
|
|
7440
7439
|
// src/internal/components/KeyshareRestoreMenu/hooks/useOnRestoreSuccess.ts
|
|
7441
7440
|
import { useCallback as useCallback10 } from "react";
|
|
7442
7441
|
function useOnRestoreSuccess() {
|
|
7443
|
-
const { config,
|
|
7442
|
+
const { config, callbacksRef } = useProviderConfig();
|
|
7444
7443
|
const setIsDialogForced = useLayoutStore((st) => st.setIsDialogForced);
|
|
7445
7444
|
const setPage = useLayoutDataStore((st) => st.setPage);
|
|
7446
7445
|
const {
|
|
@@ -7458,7 +7457,7 @@ function useOnRestoreSuccess() {
|
|
|
7458
7457
|
async (userId, hasServerKeyshare, isNewUser) => {
|
|
7459
7458
|
try {
|
|
7460
7459
|
try {
|
|
7461
|
-
|
|
7460
|
+
callbacksRef.current?.onConnecting?.({ method: "wallet" });
|
|
7462
7461
|
} catch {
|
|
7463
7462
|
}
|
|
7464
7463
|
setStatus("checking key management setup...");
|
|
@@ -7493,7 +7492,7 @@ function useOnRestoreSuccess() {
|
|
|
7493
7492
|
throw error;
|
|
7494
7493
|
}
|
|
7495
7494
|
},
|
|
7496
|
-
[setStatus,
|
|
7495
|
+
[setStatus, usePaymaster, activeChainId, publicClient]
|
|
7497
7496
|
);
|
|
7498
7497
|
const onRestoreSuccess = useCallback10(async () => {
|
|
7499
7498
|
const { verifyToken: verifyToken2, jwtTokenManager: jwtTokenManager4 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
|
|
@@ -7524,12 +7523,12 @@ function useOnRestoreSuccess() {
|
|
|
7524
7523
|
setAddress(addr);
|
|
7525
7524
|
setStatus("ready");
|
|
7526
7525
|
try {
|
|
7527
|
-
|
|
7526
|
+
callbacksRef.current?.onConnect?.({ address: addr, session: sess });
|
|
7528
7527
|
} catch (error) {
|
|
7529
7528
|
console.warn("[UI-KIT][Restore] Error due onConnect callback:", error);
|
|
7530
7529
|
}
|
|
7531
7530
|
try {
|
|
7532
|
-
|
|
7531
|
+
callbacksRef.current?.onAccount?.({
|
|
7533
7532
|
userId: recoveryUserId,
|
|
7534
7533
|
address: addr,
|
|
7535
7534
|
session: sess,
|
|
@@ -7556,8 +7555,7 @@ function useOnRestoreSuccess() {
|
|
|
7556
7555
|
setAddress,
|
|
7557
7556
|
setStatus,
|
|
7558
7557
|
setRecoveryUserId,
|
|
7559
|
-
setPage
|
|
7560
|
-
callbacks
|
|
7558
|
+
setPage
|
|
7561
7559
|
]);
|
|
7562
7560
|
return { onRestoreSuccess };
|
|
7563
7561
|
}
|
|
@@ -8928,7 +8926,7 @@ var init_KeyshareRestoreMenu = __esm({
|
|
|
8928
8926
|
};
|
|
8929
8927
|
KeyshareRestoreMenu = () => {
|
|
8930
8928
|
const qc = useQueryClient7();
|
|
8931
|
-
const
|
|
8929
|
+
const { callbacksRef } = useProviderConfig();
|
|
8932
8930
|
const { t } = useT();
|
|
8933
8931
|
const { address, setSession, setAddress, setStatus, setIsLoading } = useSession();
|
|
8934
8932
|
const maxScrollHeight = useLayoutStore((st) => st.maxScrollHeight);
|
|
@@ -8994,7 +8992,7 @@ var init_KeyshareRestoreMenu = __esm({
|
|
|
8994
8992
|
setStatus("idle");
|
|
8995
8993
|
setIsLoading(false);
|
|
8996
8994
|
setIsDialogForced(false);
|
|
8997
|
-
|
|
8995
|
+
callbacksRef.current?.onDisconnect?.({ address: "0x", userId: disconnectedUserId });
|
|
8998
8996
|
setTimeout(() => setPage("auth" /* AUTH */), 50);
|
|
8999
8997
|
},
|
|
9000
8998
|
onError: (err) => {
|
|
@@ -9860,7 +9858,7 @@ import { useMutation as useMutation10 } from "@tanstack/react-query";
|
|
|
9860
9858
|
import { ChevronRight as ChevronRight4, Loader as Loader14, Mail as Mail4 } from "lucide-react";
|
|
9861
9859
|
import { jsx as jsx52, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
9862
9860
|
function EmailForm() {
|
|
9863
|
-
const {
|
|
9861
|
+
const { callbacksRef } = useProviderConfig();
|
|
9864
9862
|
const { t } = useT();
|
|
9865
9863
|
const isLoading = useSession((st) => st.isLoading);
|
|
9866
9864
|
const setIsLoading = useSession((st) => st.setIsLoading);
|
|
@@ -9912,7 +9910,7 @@ function EmailForm() {
|
|
|
9912
9910
|
message: errorMessage
|
|
9913
9911
|
});
|
|
9914
9912
|
try {
|
|
9915
|
-
|
|
9913
|
+
callbacksRef.current?.onError?.({
|
|
9916
9914
|
error: error instanceof Error ? error : new Error(errorMessage),
|
|
9917
9915
|
message: errorMessage
|
|
9918
9916
|
});
|
|
@@ -10033,7 +10031,7 @@ var init_useSendVerificationCode = __esm({
|
|
|
10033
10031
|
// src/internal/components/ManageWalletMenu/hooks/useVerifyCode.ts
|
|
10034
10032
|
import { useMutation as useMutation12, useQueryClient as useQueryClient10 } from "@tanstack/react-query";
|
|
10035
10033
|
function useVerifyCode() {
|
|
10036
|
-
const {
|
|
10034
|
+
const { callbacksRef } = useProviderConfig();
|
|
10037
10035
|
const qc = useQueryClient10();
|
|
10038
10036
|
const address = useSession((st) => st.address);
|
|
10039
10037
|
const setIsLoading = useSession((st) => st.setIsLoading);
|
|
@@ -10059,7 +10057,7 @@ function useVerifyCode() {
|
|
|
10059
10057
|
setAlert(null);
|
|
10060
10058
|
setEmailStep("input");
|
|
10061
10059
|
try {
|
|
10062
|
-
|
|
10060
|
+
callbacksRef.current?.onAccountUpdate?.({ providers: qc.getQueryData([PROVIDERS_QUERY_KEY, address]) });
|
|
10063
10061
|
} catch {
|
|
10064
10062
|
}
|
|
10065
10063
|
setIsLoading(false);
|
|
@@ -10098,7 +10096,7 @@ function normalizePasskeyLinkError(msg) {
|
|
|
10098
10096
|
}
|
|
10099
10097
|
function AddProvider() {
|
|
10100
10098
|
const qc = useQueryClient11();
|
|
10101
|
-
const
|
|
10099
|
+
const { callbacksRef } = useProviderConfig();
|
|
10102
10100
|
const address = useSession((st) => st.address);
|
|
10103
10101
|
const { t } = useT();
|
|
10104
10102
|
const {
|
|
@@ -10162,7 +10160,7 @@ function AddProvider() {
|
|
|
10162
10160
|
await qc.invalidateQueries({ queryKey: [PROVIDERS_QUERY_KEY, address] });
|
|
10163
10161
|
await qc.invalidateQueries({ queryKey: [LINKED_PROFILES_QUERY_KEY, address] });
|
|
10164
10162
|
try {
|
|
10165
|
-
|
|
10163
|
+
callbacksRef.current?.onAccountUpdate?.({
|
|
10166
10164
|
providers: qc.getQueryData([PROVIDERS_QUERY_KEY, address])
|
|
10167
10165
|
});
|
|
10168
10166
|
} catch {
|
|
@@ -10203,7 +10201,7 @@ function AddProvider() {
|
|
|
10203
10201
|
await qc.invalidateQueries({ queryKey: [PROVIDERS_QUERY_KEY, address] });
|
|
10204
10202
|
await qc.invalidateQueries({ queryKey: [LINKED_PROFILES_QUERY_KEY, address] });
|
|
10205
10203
|
try {
|
|
10206
|
-
|
|
10204
|
+
callbacksRef.current?.onAccountUpdate?.({
|
|
10207
10205
|
providers: qc.getQueryData([PROVIDERS_QUERY_KEY, address])
|
|
10208
10206
|
});
|
|
10209
10207
|
} catch {
|
|
@@ -10281,7 +10279,7 @@ function useLinkSocial() {
|
|
|
10281
10279
|
const address = useSession((st) => st.address);
|
|
10282
10280
|
const {
|
|
10283
10281
|
config: { current: config },
|
|
10284
|
-
|
|
10282
|
+
callbacksRef
|
|
10285
10283
|
} = useProviderConfig();
|
|
10286
10284
|
const setPage = useLayoutDataStore((st) => st.setPage);
|
|
10287
10285
|
const isWalletLinking = useLayoutDataStore((st) => st.isWalletLinking);
|
|
@@ -10328,7 +10326,7 @@ function useLinkSocial() {
|
|
|
10328
10326
|
await qc.invalidateQueries({ queryKey: [PROVIDERS_QUERY_KEY, address] });
|
|
10329
10327
|
await qc.invalidateQueries({ queryKey: [LINKED_PROFILES_QUERY_KEY, address] });
|
|
10330
10328
|
try {
|
|
10331
|
-
|
|
10329
|
+
callbacksRef.current?.onAccountUpdate?.({ providers: qc.getQueryData([PROVIDERS_QUERY_KEY, address]) });
|
|
10332
10330
|
} catch {
|
|
10333
10331
|
}
|
|
10334
10332
|
setProviderType(null);
|
|
@@ -10342,7 +10340,7 @@ function useLinkSocial() {
|
|
|
10342
10340
|
setLinkIsLoading(false);
|
|
10343
10341
|
}
|
|
10344
10342
|
},
|
|
10345
|
-
[config.social?.providers
|
|
10343
|
+
[config.social?.providers]
|
|
10346
10344
|
);
|
|
10347
10345
|
const [socialLinkStarted, setSocialLinkStarted] = React5.useState(false);
|
|
10348
10346
|
useEffect26(() => {
|
|
@@ -10432,7 +10430,7 @@ import { useCallback as useCallback13, useEffect as useEffect27, useState as use
|
|
|
10432
10430
|
function useLinkTelegram() {
|
|
10433
10431
|
const {
|
|
10434
10432
|
config: { current: config },
|
|
10435
|
-
|
|
10433
|
+
callbacksRef
|
|
10436
10434
|
} = useProviderConfig();
|
|
10437
10435
|
const qc = useQueryClient13();
|
|
10438
10436
|
const address = useSession((st) => st.address);
|
|
@@ -10473,7 +10471,7 @@ function useLinkTelegram() {
|
|
|
10473
10471
|
await qc.invalidateQueries({ queryKey: [PROVIDERS_QUERY_KEY, address] });
|
|
10474
10472
|
await qc.invalidateQueries({ queryKey: [LINKED_PROFILES_QUERY_KEY, address] });
|
|
10475
10473
|
try {
|
|
10476
|
-
|
|
10474
|
+
callbacksRef.current?.onAccountUpdate?.({ providers: qc.getQueryData([PROVIDERS_QUERY_KEY, address]) });
|
|
10477
10475
|
} catch {
|
|
10478
10476
|
}
|
|
10479
10477
|
setPage("manage-wallet" /* MANAGE_WALLET */);
|
|
@@ -10485,7 +10483,7 @@ function useLinkTelegram() {
|
|
|
10485
10483
|
} finally {
|
|
10486
10484
|
setLinkIsLoading(false);
|
|
10487
10485
|
}
|
|
10488
|
-
}, [config.social?.providers
|
|
10486
|
+
}, [config.social?.providers]);
|
|
10489
10487
|
const [telegramLinkStarted, setTelegramLinkStarted] = useState9(false);
|
|
10490
10488
|
useEffect27(() => {
|
|
10491
10489
|
console.log("[useLinkTelegram] Effect triggered:", {
|
|
@@ -10791,7 +10789,7 @@ import { jsx as jsx57, jsxs as jsxs50 } from "react/jsx-runtime";
|
|
|
10791
10789
|
function UnlinkProviderMenu() {
|
|
10792
10790
|
const qc = useQueryClient14();
|
|
10793
10791
|
const address = useSession((st) => st.address);
|
|
10794
|
-
const {
|
|
10792
|
+
const { callbacksRef } = useProviderConfig();
|
|
10795
10793
|
const { t } = useT();
|
|
10796
10794
|
const setPage = useLayoutDataStore((st) => st.setPage);
|
|
10797
10795
|
const { confirmUnlink, setConfirmUnlink, setAlert } = useManageWalletStore();
|
|
@@ -10811,7 +10809,7 @@ function UnlinkProviderMenu() {
|
|
|
10811
10809
|
await qc.invalidateQueries({ queryKey: [LINKED_PROFILES_QUERY_KEY, address], refetchType: "active" });
|
|
10812
10810
|
await qc.refetchQueries({ queryKey: [PROVIDERS_QUERY_KEY, address] });
|
|
10813
10811
|
try {
|
|
10814
|
-
|
|
10812
|
+
callbacksRef.current?.onAccountUpdate?.({ providers: qc.getQueryData([PROVIDERS_QUERY_KEY, address]) });
|
|
10815
10813
|
} catch {
|
|
10816
10814
|
}
|
|
10817
10815
|
},
|
|
@@ -11034,7 +11032,7 @@ function NicknameEditForm(props) {
|
|
|
11034
11032
|
const qc = useQueryClient15();
|
|
11035
11033
|
const { t } = useT();
|
|
11036
11034
|
const passportWalletAddress = useSession((st) => st.address);
|
|
11037
|
-
const
|
|
11035
|
+
const { callbacksRef } = useProviderConfig();
|
|
11038
11036
|
const [isNicknameCopied, setIsNicknameCopied] = useState11(false);
|
|
11039
11037
|
const {
|
|
11040
11038
|
mutate: changeNickname2,
|
|
@@ -11049,7 +11047,9 @@ function NicknameEditForm(props) {
|
|
|
11049
11047
|
qc.invalidateQueries({ queryKey: [QUERY_KEYS.nicknameInfo] });
|
|
11050
11048
|
qc.invalidateQueries({ queryKey: [QUERY_KEYS.userProfile] });
|
|
11051
11049
|
try {
|
|
11052
|
-
|
|
11050
|
+
callbacksRef.current?.onAccountUpdate?.({
|
|
11051
|
+
providers: qc.getQueryData([PROVIDERS_QUERY_KEY, passportWalletAddress])
|
|
11052
|
+
});
|
|
11053
11053
|
} catch (err) {
|
|
11054
11054
|
console.warn("[NicknameEditForm] Error due executing onAccountUpdate callback", err);
|
|
11055
11055
|
}
|
|
@@ -15470,7 +15470,7 @@ var init_package = __esm({
|
|
|
15470
15470
|
"package.json"() {
|
|
15471
15471
|
package_default = {
|
|
15472
15472
|
name: "@embarkai/ui-kit",
|
|
15473
|
-
version: "0.2.
|
|
15473
|
+
version: "0.2.3",
|
|
15474
15474
|
description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
|
|
15475
15475
|
type: "module",
|
|
15476
15476
|
main: "./dist/index.cjs",
|
|
@@ -15572,7 +15572,7 @@ import { Loader as Loader31, LogOut } from "lucide-react";
|
|
|
15572
15572
|
import { jsx as jsx88, jsxs as jsxs79 } from "react/jsx-runtime";
|
|
15573
15573
|
function Footer() {
|
|
15574
15574
|
const qc = useQueryClient20();
|
|
15575
|
-
const {
|
|
15575
|
+
const { callbacksRef } = useProviderConfig();
|
|
15576
15576
|
const { address, setSession, setAddress, setStatus, setError, setIsLoading } = useSession();
|
|
15577
15577
|
const chainConfig = useSession((st) => st.chainConfig);
|
|
15578
15578
|
const { t } = useT();
|
|
@@ -15597,7 +15597,7 @@ function Footer() {
|
|
|
15597
15597
|
setError(null);
|
|
15598
15598
|
setStatus("idle");
|
|
15599
15599
|
setIsLoading(false);
|
|
15600
|
-
|
|
15600
|
+
callbacksRef.current?.onDisconnect?.({ address: disconnectAddress, userId: disconnectedUserId });
|
|
15601
15601
|
setTimeout(() => {
|
|
15602
15602
|
setPage("auth" /* AUTH */);
|
|
15603
15603
|
setIsDialogForced(false);
|
|
@@ -16252,7 +16252,7 @@ import React8, { useCallback as useCallback23, useEffect as useEffect36 } from "
|
|
|
16252
16252
|
import { useAccount, useDisconnect, useSignMessage } from "wagmi";
|
|
16253
16253
|
function WalletConnectHandler() {
|
|
16254
16254
|
const qc = useQueryClient21();
|
|
16255
|
-
const
|
|
16255
|
+
const { callbacksRef } = useProviderConfig();
|
|
16256
16256
|
const passportWalletAddress = useSession((st) => st.address);
|
|
16257
16257
|
const { address: walletAddress, isConnected, chain, connector } = useAccount();
|
|
16258
16258
|
const { openConnectModal, connectModalOpen } = useConnectModal();
|
|
@@ -16290,11 +16290,13 @@ function WalletConnectHandler() {
|
|
|
16290
16290
|
refetchType: "active"
|
|
16291
16291
|
});
|
|
16292
16292
|
try {
|
|
16293
|
-
|
|
16293
|
+
callbacksRef.current?.onAccountUpdate?.({
|
|
16294
|
+
providers: qc.getQueryData([PROVIDERS_QUERY_KEY, passportWalletAddress])
|
|
16295
|
+
});
|
|
16294
16296
|
} catch {
|
|
16295
16297
|
}
|
|
16296
16298
|
},
|
|
16297
|
-
[qc, passportWalletAddress,
|
|
16299
|
+
[qc, passportWalletAddress, setProviderType, setPage, setIsWalletLinking]
|
|
16298
16300
|
);
|
|
16299
16301
|
const [hasStartedLinking, setHasStartedLinking] = React8.useState(false);
|
|
16300
16302
|
useEffect36(() => {
|
|
@@ -16334,7 +16336,16 @@ function WalletConnectHandler() {
|
|
|
16334
16336
|
const shouldKeepConnected = walletMode === "direct" || walletMode === "both";
|
|
16335
16337
|
if (isConnected && !shouldKeepConnected) disconnect();
|
|
16336
16338
|
}
|
|
16337
|
-
}, [
|
|
16339
|
+
}, [
|
|
16340
|
+
isWalletLinking,
|
|
16341
|
+
hasStartedLinking,
|
|
16342
|
+
isConnected,
|
|
16343
|
+
openConnectModal,
|
|
16344
|
+
disconnect,
|
|
16345
|
+
setPage,
|
|
16346
|
+
setProviderType,
|
|
16347
|
+
walletMode
|
|
16348
|
+
]);
|
|
16338
16349
|
useEffect36(() => {
|
|
16339
16350
|
if (hasStartedLinking && !connectModalOpen && !isConnected && isWalletLinking) {
|
|
16340
16351
|
console.log("[WalletConnectHandler] Modal closed without connecting");
|
|
@@ -16447,7 +16458,16 @@ function WalletConnectHandler() {
|
|
|
16447
16458
|
}, 5e3);
|
|
16448
16459
|
return () => clearTimeout(timeout);
|
|
16449
16460
|
}
|
|
16450
|
-
}, [
|
|
16461
|
+
}, [
|
|
16462
|
+
isConnected,
|
|
16463
|
+
chain?.id,
|
|
16464
|
+
isWalletLinking,
|
|
16465
|
+
hasStartedLinking,
|
|
16466
|
+
connectModalOpen,
|
|
16467
|
+
isWalletSigning,
|
|
16468
|
+
onLinkingComplete,
|
|
16469
|
+
disconnect
|
|
16470
|
+
]);
|
|
16451
16471
|
return null;
|
|
16452
16472
|
}
|
|
16453
16473
|
var init_WalletConnectHandler = __esm({
|
|
@@ -19355,12 +19375,12 @@ function Provider(props) {
|
|
|
19355
19375
|
() => ({
|
|
19356
19376
|
config,
|
|
19357
19377
|
updateConfig,
|
|
19358
|
-
|
|
19359
|
-
|
|
19360
|
-
|
|
19378
|
+
/** @deprecated */
|
|
19379
|
+
callbacks,
|
|
19380
|
+
callbacksRef,
|
|
19361
19381
|
updateCallbacks
|
|
19362
19382
|
}),
|
|
19363
|
-
[config, updateConfig, updateCallbacks]
|
|
19383
|
+
[config, updateConfig, callbacks, updateCallbacks]
|
|
19364
19384
|
);
|
|
19365
19385
|
if (!!initialConfig?.wallet?.enabled)
|
|
19366
19386
|
return /* @__PURE__ */ jsx96(WagmiProvider2, { children: /* @__PURE__ */ jsx96(UIContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx96(RainbowKitProvider, { children: /* @__PURE__ */ jsx96(SessionProvider, { children }) }) }) });
|
|
@@ -20719,7 +20739,7 @@ import { logout as coreLogout, jwtTokenManager as jwtTokenManager3 } from "@emba
|
|
|
20719
20739
|
import { useCallback as useCallback32 } from "react";
|
|
20720
20740
|
function useLogout() {
|
|
20721
20741
|
const { setSession, setIsLoading, setAddress, setStatus, setError, address } = useSession();
|
|
20722
|
-
const {
|
|
20742
|
+
const { callbacksRef } = useProviderConfig();
|
|
20723
20743
|
const logout2 = useCallback32(async () => {
|
|
20724
20744
|
const prevAddress = address;
|
|
20725
20745
|
let userId = null;
|
|
@@ -20740,14 +20760,14 @@ function useLogout() {
|
|
|
20740
20760
|
setError(null);
|
|
20741
20761
|
setIsLoading(false);
|
|
20742
20762
|
try {
|
|
20743
|
-
|
|
20763
|
+
callbacksRef.current?.onDisconnect?.({
|
|
20744
20764
|
address: prevAddress,
|
|
20745
20765
|
userId
|
|
20746
20766
|
});
|
|
20747
20767
|
} catch (error) {
|
|
20748
20768
|
console.warn("[useLogout] Callback error:", error);
|
|
20749
20769
|
}
|
|
20750
|
-
}, [address, setAddress, setError, setSession, setStatus
|
|
20770
|
+
}, [address, setAddress, setError, setSession, setStatus]);
|
|
20751
20771
|
return { logout: logout2 };
|
|
20752
20772
|
}
|
|
20753
20773
|
var init_useLogout = __esm({
|