@embarkai/ui-kit 0.4.6 → 0.4.7
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 +16 -51
- package/dist/index.d.cts +22 -20
- package/dist/index.d.ts +22 -20
- package/dist/index.js +14 -49
- package/package.json +1 -1
package/dist/iframe/index.html
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<meta http-equiv="X-Content-Type-Options" content="nosniff" />
|
|
16
16
|
<meta http-equiv="Referrer-Policy" content="strict-origin-when-cross-origin" />
|
|
17
17
|
|
|
18
|
-
<title>EmbarkAI Secure Wallet - iframe version 0.4.
|
|
18
|
+
<title>EmbarkAI Secure Wallet - iframe version 0.4.7</title>
|
|
19
19
|
|
|
20
20
|
<!-- Styles will be injected by build process -->
|
|
21
21
|
<style>
|
package/dist/iframe/main.js
CHANGED
|
@@ -6262,7 +6262,7 @@ var SigningManager = class extends TokenRefreshApiClient {
|
|
|
6262
6262
|
};
|
|
6263
6263
|
|
|
6264
6264
|
// src/iframe/main.ts
|
|
6265
|
-
var IFRAME_VERSION = "0.4.
|
|
6265
|
+
var IFRAME_VERSION = "0.4.7";
|
|
6266
6266
|
var IframeWallet = class {
|
|
6267
6267
|
constructor() {
|
|
6268
6268
|
console.log("=".repeat(60));
|
package/dist/index.cjs
CHANGED
|
@@ -19167,7 +19167,7 @@ var init_package = __esm({
|
|
|
19167
19167
|
"package.json"() {
|
|
19168
19168
|
package_default = {
|
|
19169
19169
|
name: "@embarkai/ui-kit",
|
|
19170
|
-
version: "0.4.
|
|
19170
|
+
version: "0.4.7",
|
|
19171
19171
|
description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
|
|
19172
19172
|
type: "module",
|
|
19173
19173
|
main: "./dist/index.cjs",
|
|
@@ -19900,19 +19900,6 @@ Timestamp: ${timestamp}
|
|
|
19900
19900
|
|
|
19901
19901
|
Sign this message to link your wallet to ${projectName} Wallet`;
|
|
19902
19902
|
}
|
|
19903
|
-
function createNativeWalletSignatureMessage(address, projectName, nonce) {
|
|
19904
|
-
const timestamp = Date.now();
|
|
19905
|
-
const nonceValue = nonce || crypto.randomUUID();
|
|
19906
|
-
return [
|
|
19907
|
-
`${projectName} Wallet Sign`,
|
|
19908
|
-
"",
|
|
19909
|
-
`Address: ${address}`,
|
|
19910
|
-
`Nonce: ${nonceValue}`,
|
|
19911
|
-
`Timestamp: ${timestamp}`,
|
|
19912
|
-
"",
|
|
19913
|
-
`Project ${projectName} signature request for wallet operation`
|
|
19914
|
-
].join("\n");
|
|
19915
|
-
}
|
|
19916
19903
|
function createLoginMessage(address, projectName) {
|
|
19917
19904
|
const nonce = crypto.randomUUID();
|
|
19918
19905
|
const timestamp = Date.now();
|
|
@@ -21411,7 +21398,6 @@ __export(auth_exports, {
|
|
|
21411
21398
|
createInitialAuthState: () => createInitialAuthState,
|
|
21412
21399
|
createJwtTokenManager: () => import_auth20.createJwtTokenManager,
|
|
21413
21400
|
createLoginMessage: () => createLoginMessage,
|
|
21414
|
-
createNativeWalletSignatureMessage: () => createNativeWalletSignatureMessage,
|
|
21415
21401
|
createPasskeyHelpers: () => createPasskeyHelpers,
|
|
21416
21402
|
createSignatureMessage: () => createSignatureMessage,
|
|
21417
21403
|
deriveDemoPrivateKey: () => deriveDemoPrivateKey,
|
|
@@ -24563,39 +24549,18 @@ var init_useTransferToLinkedWallet = __esm({
|
|
|
24563
24549
|
|
|
24564
24550
|
// src/hooks/useNativeWalletSignature.ts
|
|
24565
24551
|
function useNativeWalletSignature() {
|
|
24566
|
-
const
|
|
24567
|
-
const
|
|
24568
|
-
|
|
24569
|
-
|
|
24570
|
-
|
|
24571
|
-
|
|
24572
|
-
|
|
24573
|
-
|
|
24574
|
-
"\nNative account:",
|
|
24575
|
-
nativeAccount
|
|
24576
|
-
);
|
|
24577
|
-
const projectName = projectId ? await fetchProjectName(projectId) : "EmbarkAI";
|
|
24578
|
-
const message = createNativeWalletSignatureMessage(nativeWalletAddress, projectName, nonce);
|
|
24579
|
-
const signature = await Promise.race([
|
|
24580
|
-
signMessageAsync({ message, account: nativeWalletAddress }),
|
|
24581
|
-
new Promise((_, rej) => setTimeout(() => rej(new Error("Singing timed out. Please try again.")), 12e4))
|
|
24582
|
-
]).catch((err) => {
|
|
24583
|
-
console.error("[GET WALLET SIGNATURE]", err);
|
|
24584
|
-
throw err;
|
|
24585
|
-
});
|
|
24586
|
-
return {
|
|
24587
|
-
message,
|
|
24588
|
-
signature
|
|
24589
|
-
};
|
|
24590
|
-
},
|
|
24591
|
-
[signMessageAsync]
|
|
24592
|
-
);
|
|
24593
|
-
return { getNativeWalletSignature };
|
|
24552
|
+
const signMessage = (0, import_wagmi10.useSignMessage)();
|
|
24553
|
+
const signTypedMessage = (0, import_wagmi10.useSignTypedData)();
|
|
24554
|
+
return {
|
|
24555
|
+
signMessage,
|
|
24556
|
+
/** EIP-712 signature */
|
|
24557
|
+
signTypedMessage,
|
|
24558
|
+
fetchProjectNameById: fetchProjectName
|
|
24559
|
+
};
|
|
24594
24560
|
}
|
|
24595
|
-
var
|
|
24561
|
+
var import_wagmi10;
|
|
24596
24562
|
var init_useNativeWalletSignature = __esm({
|
|
24597
24563
|
"src/hooks/useNativeWalletSignature.ts"() {
|
|
24598
|
-
import_react87 = require("react");
|
|
24599
24564
|
import_wagmi10 = require("wagmi");
|
|
24600
24565
|
init_providers();
|
|
24601
24566
|
}
|
|
@@ -24605,7 +24570,7 @@ var init_useNativeWalletSignature = __esm({
|
|
|
24605
24570
|
function useLogout() {
|
|
24606
24571
|
const { setSession, setIsLoading, setAddress, setStatus, setError, address } = useSession();
|
|
24607
24572
|
const { callbacksRef } = useProviderConfig();
|
|
24608
|
-
const logout2 = (0,
|
|
24573
|
+
const logout2 = (0, import_react87.useCallback)(async () => {
|
|
24609
24574
|
const prevAddress = address;
|
|
24610
24575
|
let userId = null;
|
|
24611
24576
|
setIsLoading(true);
|
|
@@ -24635,11 +24600,11 @@ function useLogout() {
|
|
|
24635
24600
|
}, [address, setAddress, setError, setSession, setStatus]);
|
|
24636
24601
|
return { logout: logout2 };
|
|
24637
24602
|
}
|
|
24638
|
-
var import_auth22,
|
|
24603
|
+
var import_auth22, import_react87;
|
|
24639
24604
|
var init_useLogout = __esm({
|
|
24640
24605
|
"src/hooks/useLogout.ts"() {
|
|
24641
24606
|
import_auth22 = require("@embarkai/core/auth");
|
|
24642
|
-
|
|
24607
|
+
import_react87 = require("react");
|
|
24643
24608
|
init_ProviderContext();
|
|
24644
24609
|
init_SessionContext();
|
|
24645
24610
|
}
|
|
@@ -24911,7 +24876,7 @@ function useTokenBalance(tokenAddress, userAddress) {
|
|
|
24911
24876
|
}
|
|
24912
24877
|
});
|
|
24913
24878
|
const { tokenInfo } = useTokenInfo(tokenAddress);
|
|
24914
|
-
const formattedBalance =
|
|
24879
|
+
const formattedBalance = import_react88.default.useMemo(() => {
|
|
24915
24880
|
if (!balance || !tokenInfo) return "0";
|
|
24916
24881
|
return (0, import_viem21.formatUnits)(balance, tokenInfo.decimals);
|
|
24917
24882
|
}, [balance, tokenInfo]);
|
|
@@ -24923,11 +24888,11 @@ function useTokenBalance(tokenAddress, userAddress) {
|
|
|
24923
24888
|
refetch
|
|
24924
24889
|
};
|
|
24925
24890
|
}
|
|
24926
|
-
var
|
|
24891
|
+
var import_react88, import_viem21, import_wagmi12, COMMON_TOKENS;
|
|
24927
24892
|
var init_assets2 = __esm({
|
|
24928
24893
|
"src/modules/assets.ts"() {
|
|
24929
24894
|
init_SessionContext();
|
|
24930
|
-
|
|
24895
|
+
import_react88 = __toESM(require("react"), 1);
|
|
24931
24896
|
import_viem21 = require("viem");
|
|
24932
24897
|
import_wagmi12 = require("wagmi");
|
|
24933
24898
|
COMMON_TOKENS = [
|
package/dist/index.d.cts
CHANGED
|
@@ -11,8 +11,8 @@ import { BundlerClient } from 'viem/account-abstraction';
|
|
|
11
11
|
import { UserOperationV07 } from '@embarkai/core/bundler';
|
|
12
12
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
13
13
|
import { VariantProps } from 'class-variance-authority';
|
|
14
|
-
export { JwtTokens, LoginResponse, VerifyResponse, getValidTokens, jwtTokenManager, logout } from '@embarkai/core/auth';
|
|
15
14
|
import * as wagmi from 'wagmi';
|
|
15
|
+
export { JwtTokens, LoginResponse, VerifyResponse, getValidTokens, jwtTokenManager, logout } from '@embarkai/core/auth';
|
|
16
16
|
|
|
17
17
|
interface TokenBalance {
|
|
18
18
|
address: `0x${string}`;
|
|
@@ -1357,11 +1357,28 @@ interface UseTransferToLinkedReturn {
|
|
|
1357
1357
|
}
|
|
1358
1358
|
declare function useTransferToLinkedWallet(): UseTransferToLinkedReturn;
|
|
1359
1359
|
|
|
1360
|
+
interface AuthProviderMeta extends Record<string, unknown> {
|
|
1361
|
+
walletName?: string;
|
|
1362
|
+
walletType?: string;
|
|
1363
|
+
chainId?: number;
|
|
1364
|
+
email?: string;
|
|
1365
|
+
}
|
|
1366
|
+
interface AuthProvider {
|
|
1367
|
+
provider: 'passkey' | 'email' | 'telegram' | 'google' | 'discord' | 'twitter' | 'wallet';
|
|
1368
|
+
verified: boolean;
|
|
1369
|
+
linkedAt: string;
|
|
1370
|
+
lastUsedAt?: string;
|
|
1371
|
+
externalId: string;
|
|
1372
|
+
meta?: AuthProviderMeta;
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
declare function fetchProjectName(projectId: string): Promise<string>;
|
|
1376
|
+
|
|
1360
1377
|
declare function useNativeWalletSignature(): {
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1378
|
+
signMessage: wagmi.UseSignMessageReturnType<unknown>;
|
|
1379
|
+
/** EIP-712 signature */
|
|
1380
|
+
signTypedMessage: wagmi.UseSignTypedDataReturnType<unknown>;
|
|
1381
|
+
fetchProjectNameById: typeof fetchProjectName;
|
|
1365
1382
|
};
|
|
1366
1383
|
|
|
1367
1384
|
interface UseLogoutReturn {
|
|
@@ -1733,21 +1750,6 @@ declare global {
|
|
|
1733
1750
|
}
|
|
1734
1751
|
}
|
|
1735
1752
|
|
|
1736
|
-
interface AuthProviderMeta extends Record<string, unknown> {
|
|
1737
|
-
walletName?: string;
|
|
1738
|
-
walletType?: string;
|
|
1739
|
-
chainId?: number;
|
|
1740
|
-
email?: string;
|
|
1741
|
-
}
|
|
1742
|
-
interface AuthProvider {
|
|
1743
|
-
provider: 'passkey' | 'email' | 'telegram' | 'google' | 'discord' | 'twitter' | 'wallet';
|
|
1744
|
-
verified: boolean;
|
|
1745
|
-
linkedAt: string;
|
|
1746
|
-
lastUsedAt?: string;
|
|
1747
|
-
externalId: string;
|
|
1748
|
-
meta?: AuthProviderMeta;
|
|
1749
|
-
}
|
|
1750
|
-
|
|
1751
1753
|
/**
|
|
1752
1754
|
* Provider information in user profile
|
|
1753
1755
|
* Matches the structure returned by backend /api/auth/profile
|
package/dist/index.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ import { BundlerClient } from 'viem/account-abstraction';
|
|
|
11
11
|
import { UserOperationV07 } from '@embarkai/core/bundler';
|
|
12
12
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
13
13
|
import { VariantProps } from 'class-variance-authority';
|
|
14
|
-
export { JwtTokens, LoginResponse, VerifyResponse, getValidTokens, jwtTokenManager, logout } from '@embarkai/core/auth';
|
|
15
14
|
import * as wagmi from 'wagmi';
|
|
15
|
+
export { JwtTokens, LoginResponse, VerifyResponse, getValidTokens, jwtTokenManager, logout } from '@embarkai/core/auth';
|
|
16
16
|
|
|
17
17
|
interface TokenBalance {
|
|
18
18
|
address: `0x${string}`;
|
|
@@ -1357,11 +1357,28 @@ interface UseTransferToLinkedReturn {
|
|
|
1357
1357
|
}
|
|
1358
1358
|
declare function useTransferToLinkedWallet(): UseTransferToLinkedReturn;
|
|
1359
1359
|
|
|
1360
|
+
interface AuthProviderMeta extends Record<string, unknown> {
|
|
1361
|
+
walletName?: string;
|
|
1362
|
+
walletType?: string;
|
|
1363
|
+
chainId?: number;
|
|
1364
|
+
email?: string;
|
|
1365
|
+
}
|
|
1366
|
+
interface AuthProvider {
|
|
1367
|
+
provider: 'passkey' | 'email' | 'telegram' | 'google' | 'discord' | 'twitter' | 'wallet';
|
|
1368
|
+
verified: boolean;
|
|
1369
|
+
linkedAt: string;
|
|
1370
|
+
lastUsedAt?: string;
|
|
1371
|
+
externalId: string;
|
|
1372
|
+
meta?: AuthProviderMeta;
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
declare function fetchProjectName(projectId: string): Promise<string>;
|
|
1376
|
+
|
|
1360
1377
|
declare function useNativeWalletSignature(): {
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1378
|
+
signMessage: wagmi.UseSignMessageReturnType<unknown>;
|
|
1379
|
+
/** EIP-712 signature */
|
|
1380
|
+
signTypedMessage: wagmi.UseSignTypedDataReturnType<unknown>;
|
|
1381
|
+
fetchProjectNameById: typeof fetchProjectName;
|
|
1365
1382
|
};
|
|
1366
1383
|
|
|
1367
1384
|
interface UseLogoutReturn {
|
|
@@ -1733,21 +1750,6 @@ declare global {
|
|
|
1733
1750
|
}
|
|
1734
1751
|
}
|
|
1735
1752
|
|
|
1736
|
-
interface AuthProviderMeta extends Record<string, unknown> {
|
|
1737
|
-
walletName?: string;
|
|
1738
|
-
walletType?: string;
|
|
1739
|
-
chainId?: number;
|
|
1740
|
-
email?: string;
|
|
1741
|
-
}
|
|
1742
|
-
interface AuthProvider {
|
|
1743
|
-
provider: 'passkey' | 'email' | 'telegram' | 'google' | 'discord' | 'twitter' | 'wallet';
|
|
1744
|
-
verified: boolean;
|
|
1745
|
-
linkedAt: string;
|
|
1746
|
-
lastUsedAt?: string;
|
|
1747
|
-
externalId: string;
|
|
1748
|
-
meta?: AuthProviderMeta;
|
|
1749
|
-
}
|
|
1750
|
-
|
|
1751
1753
|
/**
|
|
1752
1754
|
* Provider information in user profile
|
|
1753
1755
|
* Matches the structure returned by backend /api/auth/profile
|
package/dist/index.js
CHANGED
|
@@ -19086,7 +19086,7 @@ var init_package = __esm({
|
|
|
19086
19086
|
"package.json"() {
|
|
19087
19087
|
package_default = {
|
|
19088
19088
|
name: "@embarkai/ui-kit",
|
|
19089
|
-
version: "0.4.
|
|
19089
|
+
version: "0.4.7",
|
|
19090
19090
|
description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
|
|
19091
19091
|
type: "module",
|
|
19092
19092
|
main: "./dist/index.cjs",
|
|
@@ -19816,19 +19816,6 @@ Timestamp: ${timestamp}
|
|
|
19816
19816
|
|
|
19817
19817
|
Sign this message to link your wallet to ${projectName} Wallet`;
|
|
19818
19818
|
}
|
|
19819
|
-
function createNativeWalletSignatureMessage(address, projectName, nonce) {
|
|
19820
|
-
const timestamp = Date.now();
|
|
19821
|
-
const nonceValue = nonce || crypto.randomUUID();
|
|
19822
|
-
return [
|
|
19823
|
-
`${projectName} Wallet Sign`,
|
|
19824
|
-
"",
|
|
19825
|
-
`Address: ${address}`,
|
|
19826
|
-
`Nonce: ${nonceValue}`,
|
|
19827
|
-
`Timestamp: ${timestamp}`,
|
|
19828
|
-
"",
|
|
19829
|
-
`Project ${projectName} signature request for wallet operation`
|
|
19830
|
-
].join("\n");
|
|
19831
|
-
}
|
|
19832
19819
|
function createLoginMessage(address, projectName) {
|
|
19833
19820
|
const nonce = crypto.randomUUID();
|
|
19834
19821
|
const timestamp = Date.now();
|
|
@@ -21331,7 +21318,6 @@ __export(auth_exports, {
|
|
|
21331
21318
|
createInitialAuthState: () => createInitialAuthState,
|
|
21332
21319
|
createJwtTokenManager: () => createJwtTokenManager,
|
|
21333
21320
|
createLoginMessage: () => createLoginMessage,
|
|
21334
|
-
createNativeWalletSignatureMessage: () => createNativeWalletSignatureMessage,
|
|
21335
21321
|
createPasskeyHelpers: () => createPasskeyHelpers,
|
|
21336
21322
|
createSignatureMessage: () => createSignatureMessage,
|
|
21337
21323
|
deriveDemoPrivateKey: () => deriveDemoPrivateKey,
|
|
@@ -24497,37 +24483,16 @@ var init_useTransferToLinkedWallet = __esm({
|
|
|
24497
24483
|
});
|
|
24498
24484
|
|
|
24499
24485
|
// src/hooks/useNativeWalletSignature.ts
|
|
24500
|
-
import {
|
|
24501
|
-
import { useAccount as useAccount3, useSignMessage as useSignMessage2 } from "wagmi";
|
|
24486
|
+
import { useSignMessage as useSignMessage2, useSignTypedData } from "wagmi";
|
|
24502
24487
|
function useNativeWalletSignature() {
|
|
24503
|
-
const
|
|
24504
|
-
const
|
|
24505
|
-
|
|
24506
|
-
|
|
24507
|
-
|
|
24508
|
-
|
|
24509
|
-
|
|
24510
|
-
|
|
24511
|
-
"\nNative account:",
|
|
24512
|
-
nativeAccount
|
|
24513
|
-
);
|
|
24514
|
-
const projectName = projectId ? await fetchProjectName(projectId) : "EmbarkAI";
|
|
24515
|
-
const message = createNativeWalletSignatureMessage(nativeWalletAddress, projectName, nonce);
|
|
24516
|
-
const signature = await Promise.race([
|
|
24517
|
-
signMessageAsync({ message, account: nativeWalletAddress }),
|
|
24518
|
-
new Promise((_, rej) => setTimeout(() => rej(new Error("Singing timed out. Please try again.")), 12e4))
|
|
24519
|
-
]).catch((err) => {
|
|
24520
|
-
console.error("[GET WALLET SIGNATURE]", err);
|
|
24521
|
-
throw err;
|
|
24522
|
-
});
|
|
24523
|
-
return {
|
|
24524
|
-
message,
|
|
24525
|
-
signature
|
|
24526
|
-
};
|
|
24527
|
-
},
|
|
24528
|
-
[signMessageAsync]
|
|
24529
|
-
);
|
|
24530
|
-
return { getNativeWalletSignature };
|
|
24488
|
+
const signMessage = useSignMessage2();
|
|
24489
|
+
const signTypedMessage = useSignTypedData();
|
|
24490
|
+
return {
|
|
24491
|
+
signMessage,
|
|
24492
|
+
/** EIP-712 signature */
|
|
24493
|
+
signTypedMessage,
|
|
24494
|
+
fetchProjectNameById: fetchProjectName
|
|
24495
|
+
};
|
|
24531
24496
|
}
|
|
24532
24497
|
var init_useNativeWalletSignature = __esm({
|
|
24533
24498
|
"src/hooks/useNativeWalletSignature.ts"() {
|
|
@@ -24537,11 +24502,11 @@ var init_useNativeWalletSignature = __esm({
|
|
|
24537
24502
|
|
|
24538
24503
|
// src/hooks/useLogout.ts
|
|
24539
24504
|
import { logout as coreLogout, jwtTokenManager as jwtTokenManager3 } from "@embarkai/core/auth";
|
|
24540
|
-
import { useCallback as
|
|
24505
|
+
import { useCallback as useCallback36 } from "react";
|
|
24541
24506
|
function useLogout() {
|
|
24542
24507
|
const { setSession, setIsLoading, setAddress, setStatus, setError, address } = useSession();
|
|
24543
24508
|
const { callbacksRef } = useProviderConfig();
|
|
24544
|
-
const logout2 =
|
|
24509
|
+
const logout2 = useCallback36(async () => {
|
|
24545
24510
|
const prevAddress = address;
|
|
24546
24511
|
let userId = null;
|
|
24547
24512
|
setIsLoading(true);
|
|
@@ -24632,13 +24597,13 @@ var init_clients2 = __esm({
|
|
|
24632
24597
|
// src/modules/transactions.ts
|
|
24633
24598
|
import { getViemChain as getViemChain4 } from "@embarkai/core/read";
|
|
24634
24599
|
import { parseEther as parseEther6 } from "viem";
|
|
24635
|
-
import { useAccount as
|
|
24600
|
+
import { useAccount as useAccount3, usePublicClient, useWalletClient } from "wagmi";
|
|
24636
24601
|
function useTransactions() {
|
|
24637
24602
|
const chainId = requireActiveChainId();
|
|
24638
24603
|
const viemChain = getViemChain4(chainId);
|
|
24639
24604
|
const publicClient = usePublicClient({ chainId });
|
|
24640
24605
|
const { data: walletClient } = useWalletClient();
|
|
24641
|
-
const { address } =
|
|
24606
|
+
const { address } = useAccount3();
|
|
24642
24607
|
const sendTransaction = async (params) => {
|
|
24643
24608
|
if (!walletClient) {
|
|
24644
24609
|
throw new Error("Wallet not connected");
|