@embarkai/ui-kit 0.2.5 → 0.2.6
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 +2 -7
- package/dist/iframe/main.js.map +1 -1
- package/dist/index.cjs +63 -62
- 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 +63 -62
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1660,12 +1660,19 @@ declare global {
|
|
|
1660
1660
|
}
|
|
1661
1661
|
}
|
|
1662
1662
|
|
|
1663
|
+
interface AuthProviderMeta extends Record<string, unknown> {
|
|
1664
|
+
walletName?: string;
|
|
1665
|
+
walletType?: string;
|
|
1666
|
+
chainId?: number;
|
|
1667
|
+
email?: string;
|
|
1668
|
+
}
|
|
1663
1669
|
interface AuthProvider {
|
|
1664
1670
|
provider: 'passkey' | 'email' | 'telegram' | 'google' | 'discord' | 'twitter' | 'wallet';
|
|
1665
1671
|
verified: boolean;
|
|
1666
1672
|
linkedAt: string;
|
|
1667
1673
|
lastUsedAt?: string;
|
|
1668
1674
|
externalId: string;
|
|
1675
|
+
meta?: AuthProviderMeta;
|
|
1669
1676
|
}
|
|
1670
1677
|
|
|
1671
1678
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1660,12 +1660,19 @@ declare global {
|
|
|
1660
1660
|
}
|
|
1661
1661
|
}
|
|
1662
1662
|
|
|
1663
|
+
interface AuthProviderMeta extends Record<string, unknown> {
|
|
1664
|
+
walletName?: string;
|
|
1665
|
+
walletType?: string;
|
|
1666
|
+
chainId?: number;
|
|
1667
|
+
email?: string;
|
|
1668
|
+
}
|
|
1663
1669
|
interface AuthProvider {
|
|
1664
1670
|
provider: 'passkey' | 'email' | 'telegram' | 'google' | 'discord' | 'twitter' | 'wallet';
|
|
1665
1671
|
verified: boolean;
|
|
1666
1672
|
linkedAt: string;
|
|
1667
1673
|
lastUsedAt?: string;
|
|
1668
1674
|
externalId: string;
|
|
1675
|
+
meta?: AuthProviderMeta;
|
|
1669
1676
|
}
|
|
1670
1677
|
|
|
1671
1678
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2713,12 +2713,12 @@ function useListenIframeAuthEvents() {
|
|
|
2713
2713
|
const setIsIframeReady = useSession((state) => state.setIsIframeReady);
|
|
2714
2714
|
const handleIframeMessage = useCallback4(
|
|
2715
2715
|
(event) => {
|
|
2716
|
-
if (event.data?.type === "
|
|
2716
|
+
if (event.data?.type === "IFRAME_MSG_IFRAME_READY") {
|
|
2717
2717
|
console.log("[ IFRAME MESSAGE CACTHED ] Iframe is ready");
|
|
2718
2718
|
setIsIframeReady(true);
|
|
2719
|
-
} else if (event.data?.type === "
|
|
2719
|
+
} else if (event.data?.type === "IFRAME_MSG_SHOW_IFRAME") {
|
|
2720
2720
|
console.log("[ IFRAME MESSAGE CACTHED ] Consent screen shown - hiding auth modal");
|
|
2721
|
-
} else if (event.data?.type === "
|
|
2721
|
+
} else if (event.data?.type === "IFRAME_MSG_HIDE_IFRAME") {
|
|
2722
2722
|
console.log("[ IFRAME MESSAGE CACTHED ] Consent screen hidden");
|
|
2723
2723
|
} else if (event.data?.type === "KEYSHARE_RECOVERY_NEEDED") {
|
|
2724
2724
|
console.log("[ IFRAME MESSAGE CACTHED] recovery neede");
|
|
@@ -10544,7 +10544,7 @@ function ProviderCard(props) {
|
|
|
10544
10544
|
return /* @__PURE__ */ jsxs48("div", { className: "w-full flex items-center justify-between gap-[var(--ui-kit-gap)]", children: [
|
|
10545
10545
|
/* @__PURE__ */ jsx55("div", { className: "w-12 h-12 flex items-center justify-center flex-none border border-[var(--ui-kit-bd)] rounded-full", children: /* @__PURE__ */ jsx55(IconComponent, { className: "w-5 h-5" }) }),
|
|
10546
10546
|
/* @__PURE__ */ jsxs48("div", { className: "flex flex-col gap-1 flex-1", children: [
|
|
10547
|
-
/* @__PURE__ */ jsx55("span", { className: "block w-full text-[10px] font-medium", children: info.name }),
|
|
10547
|
+
/* @__PURE__ */ jsx55("span", { className: "block w-full text-[10px] font-medium", children: props.meta?.walletName || info.name }),
|
|
10548
10548
|
props.externalId && /* @__PURE__ */ jsx55(
|
|
10549
10549
|
"span",
|
|
10550
10550
|
{
|
|
@@ -10631,19 +10631,19 @@ function ManageWalletMenu() {
|
|
|
10631
10631
|
if (name === "x") return "twitter";
|
|
10632
10632
|
return name;
|
|
10633
10633
|
};
|
|
10634
|
-
const usedProviders = fromPairs(providers.map((p) => [normalizeProviderName(p.provider), true]));
|
|
10635
10634
|
const used = [];
|
|
10636
10635
|
const unused = [];
|
|
10637
|
-
POSSIBLE_PROVIDERS.forEach((provider
|
|
10636
|
+
POSSIBLE_PROVIDERS.forEach((provider) => {
|
|
10638
10637
|
if (!configuredProviders[provider]) return;
|
|
10639
10638
|
const Icon2 = PROVIDERS_META[provider].icon;
|
|
10640
|
-
|
|
10641
|
-
|
|
10642
|
-
|
|
10643
|
-
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
10639
|
+
const matches = providers.filter((p) => normalizeProviderName(p.provider) === provider);
|
|
10640
|
+
matches.forEach((providerData, idx) => {
|
|
10641
|
+
used.push(
|
|
10642
|
+
/* @__PURE__ */ jsx56(ProviderCard, { ...providerData }, `${provider}-${providerData.externalId || idx}`)
|
|
10643
|
+
);
|
|
10644
|
+
});
|
|
10645
|
+
const isMulti = MULTI_PROVIDERS.includes(provider);
|
|
10646
|
+
if (isMulti || matches.length === 0) {
|
|
10647
10647
|
unused.push(
|
|
10648
10648
|
/* @__PURE__ */ jsxs49(
|
|
10649
10649
|
Button,
|
|
@@ -10688,7 +10688,7 @@ function ManageWalletMenu() {
|
|
|
10688
10688
|
] })
|
|
10689
10689
|
]
|
|
10690
10690
|
},
|
|
10691
|
-
|
|
10691
|
+
`add-${provider}`
|
|
10692
10692
|
)
|
|
10693
10693
|
);
|
|
10694
10694
|
}
|
|
@@ -10750,7 +10750,7 @@ function ManageWalletMenu() {
|
|
|
10750
10750
|
}
|
|
10751
10751
|
);
|
|
10752
10752
|
}
|
|
10753
|
-
var POSSIBLE_PROVIDERS;
|
|
10753
|
+
var POSSIBLE_PROVIDERS, MULTI_PROVIDERS;
|
|
10754
10754
|
var init_ManageWallet = __esm({
|
|
10755
10755
|
"src/internal/components/ManageWalletMenu/ManageWallet.tsx"() {
|
|
10756
10756
|
init_useLayoutDataStore();
|
|
@@ -10778,6 +10778,7 @@ var init_ManageWallet = __esm({
|
|
|
10778
10778
|
"passkey",
|
|
10779
10779
|
"wallet"
|
|
10780
10780
|
];
|
|
10781
|
+
MULTI_PROVIDERS = ["email", "wallet"];
|
|
10781
10782
|
}
|
|
10782
10783
|
});
|
|
10783
10784
|
|
|
@@ -15470,7 +15471,7 @@ var init_package = __esm({
|
|
|
15470
15471
|
"package.json"() {
|
|
15471
15472
|
package_default = {
|
|
15472
15473
|
name: "@embarkai/ui-kit",
|
|
15473
|
-
version: "0.2.
|
|
15474
|
+
version: "0.2.6",
|
|
15474
15475
|
description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
|
|
15475
15476
|
type: "module",
|
|
15476
15477
|
main: "./dist/index.cjs",
|
|
@@ -17823,7 +17824,7 @@ var init_iframe_manager = __esm({
|
|
|
17823
17824
|
const response = await this.sendMessage("SDK_AUTH", {
|
|
17824
17825
|
projectId: this.projectId
|
|
17825
17826
|
});
|
|
17826
|
-
if (response.type === "
|
|
17827
|
+
if (response.type === "IFRAME_MSG_SDK_AUTH_SUCCESS") {
|
|
17827
17828
|
this.channelToken = response.sessionToken;
|
|
17828
17829
|
} else {
|
|
17829
17830
|
throw new Error("SDK channel authentication failed");
|
|
@@ -17913,23 +17914,23 @@ var init_iframe_manager = __esm({
|
|
|
17913
17914
|
return;
|
|
17914
17915
|
}
|
|
17915
17916
|
const validIframeTypes = [
|
|
17916
|
-
"
|
|
17917
|
-
"
|
|
17918
|
-
"
|
|
17919
|
-
"
|
|
17920
|
-
"
|
|
17921
|
-
"
|
|
17922
|
-
"
|
|
17923
|
-
"
|
|
17924
|
-
"
|
|
17925
|
-
"
|
|
17926
|
-
"
|
|
17927
|
-
"
|
|
17928
|
-
"
|
|
17929
|
-
"
|
|
17930
|
-
"
|
|
17931
|
-
"
|
|
17932
|
-
"
|
|
17917
|
+
"IFRAME_MSG_IFRAME_READY",
|
|
17918
|
+
"IFRAME_MSG_WALLET_READY",
|
|
17919
|
+
"IFRAME_MSG_SHOW_IFRAME",
|
|
17920
|
+
"IFRAME_MSG_HIDE_IFRAME",
|
|
17921
|
+
"IFRAME_MSG_SDK_AUTH_SUCCESS",
|
|
17922
|
+
"IFRAME_MSG_AUTH_SUCCESS",
|
|
17923
|
+
"IFRAME_MSG_DKG_SUCCESS",
|
|
17924
|
+
"IFRAME_MSG_SIGNATURE",
|
|
17925
|
+
"IFRAME_MSG_ADDRESS",
|
|
17926
|
+
"IFRAME_MSG_KEYSHARE_STATUS",
|
|
17927
|
+
"IFRAME_MSG_TRUSTED_APPS_LIST",
|
|
17928
|
+
"IFRAME_MSG_TRUSTED_APP_REMOVED",
|
|
17929
|
+
"IFRAME_MSG_REQUEST_NEW_TOKEN",
|
|
17930
|
+
"IFRAME_MSG_TOKEN_REFRESHED",
|
|
17931
|
+
"IFRAME_MSG_HEARTBEAT_RESPONSE",
|
|
17932
|
+
"IFRAME_MSG_RESPONSE",
|
|
17933
|
+
"IFRAME_MSG_ERROR"
|
|
17933
17934
|
];
|
|
17934
17935
|
if (!validIframeTypes.includes(message.type) && !message.messageId) {
|
|
17935
17936
|
return;
|
|
@@ -17942,31 +17943,31 @@ var init_iframe_manager = __esm({
|
|
|
17942
17943
|
});
|
|
17943
17944
|
return;
|
|
17944
17945
|
}
|
|
17945
|
-
if (message.type === "
|
|
17946
|
-
this.log("[IframeManager] \u{1F4E8} Received
|
|
17946
|
+
if (message.type === "IFRAME_MSG_IFRAME_READY") {
|
|
17947
|
+
this.log("[IframeManager] \u{1F4E8} Received IFRAME_MSG_IFRAME_READY");
|
|
17947
17948
|
this.isReady = true;
|
|
17948
17949
|
this.readyResolve();
|
|
17949
17950
|
return;
|
|
17950
17951
|
}
|
|
17951
|
-
if (message.type === "
|
|
17952
|
-
this.log("[IframeManager] \u{1F4E8} Received
|
|
17952
|
+
if (message.type === "IFRAME_MSG_WALLET_READY") {
|
|
17953
|
+
this.log("[IframeManager] \u{1F4E8} Received IFRAME_MSG_WALLET_READY", message.data);
|
|
17953
17954
|
if (this.onWalletReadyCallback) {
|
|
17954
17955
|
this.onWalletReadyCallback(message.data);
|
|
17955
17956
|
}
|
|
17956
17957
|
return;
|
|
17957
17958
|
}
|
|
17958
|
-
if (message.type === "
|
|
17959
|
-
this.log("[IframeManager] \u{1F4E8} Received
|
|
17959
|
+
if (message.type === "IFRAME_MSG_SHOW_IFRAME") {
|
|
17960
|
+
this.log("[IframeManager] \u{1F4E8} Received IFRAME_MSG_SHOW_IFRAME");
|
|
17960
17961
|
this.showIframe();
|
|
17961
17962
|
return;
|
|
17962
17963
|
}
|
|
17963
|
-
if (message.type === "
|
|
17964
|
-
this.log("[IframeManager] \u{1F4E8} Received
|
|
17964
|
+
if (message.type === "IFRAME_MSG_HIDE_IFRAME") {
|
|
17965
|
+
this.log("[IframeManager] \u{1F4E8} Received IFRAME_MSG_HIDE_IFRAME");
|
|
17965
17966
|
this.hideIframe();
|
|
17966
17967
|
return;
|
|
17967
17968
|
}
|
|
17968
|
-
if (message.type === "
|
|
17969
|
-
this.log("[IframeManager] \u{1F4E8} Received
|
|
17969
|
+
if (message.type === "IFRAME_MSG_REQUEST_NEW_TOKEN") {
|
|
17970
|
+
this.log("[IframeManager] \u{1F4E8} Received IFRAME_MSG_REQUEST_NEW_TOKEN");
|
|
17970
17971
|
this.handleTokenRefreshRequest(message).catch((error) => {
|
|
17971
17972
|
this.log("[IframeManager] \u274C Token refresh error:", error);
|
|
17972
17973
|
});
|
|
@@ -17976,7 +17977,7 @@ var init_iframe_manager = __esm({
|
|
|
17976
17977
|
const pending = this.pendingRequests.get(message.messageId);
|
|
17977
17978
|
if (pending) {
|
|
17978
17979
|
this.pendingRequests.delete(message.messageId);
|
|
17979
|
-
if (message.type === "
|
|
17980
|
+
if (message.type === "IFRAME_MSG_ERROR") {
|
|
17980
17981
|
const passportError = createAccountAbstractionError({
|
|
17981
17982
|
message: message.error || "Unknown error",
|
|
17982
17983
|
code: message.code
|
|
@@ -18001,7 +18002,7 @@ var init_iframe_manager = __esm({
|
|
|
18001
18002
|
const iframeOrigin = new URL(this.iframeUrl).origin;
|
|
18002
18003
|
this.iframe.contentWindow.postMessage(
|
|
18003
18004
|
{
|
|
18004
|
-
type: "
|
|
18005
|
+
type: "IFRAME_MSG_TOKEN_REFRESHED",
|
|
18005
18006
|
messageId: message.messageId,
|
|
18006
18007
|
accessToken: newAccessToken,
|
|
18007
18008
|
timestamp: Date.now()
|
|
@@ -18014,7 +18015,7 @@ var init_iframe_manager = __esm({
|
|
|
18014
18015
|
const iframeOrigin = new URL(this.iframeUrl).origin;
|
|
18015
18016
|
this.iframe.contentWindow.postMessage(
|
|
18016
18017
|
{
|
|
18017
|
-
type: "
|
|
18018
|
+
type: "IFRAME_MSG_TOKEN_REFRESHED",
|
|
18018
18019
|
messageId: message.messageId,
|
|
18019
18020
|
error: "Token refresh failed",
|
|
18020
18021
|
timestamp: Date.now()
|
|
@@ -18028,7 +18029,7 @@ var init_iframe_manager = __esm({
|
|
|
18028
18029
|
const iframeOrigin = new URL(this.iframeUrl).origin;
|
|
18029
18030
|
this.iframe.contentWindow.postMessage(
|
|
18030
18031
|
{
|
|
18031
|
-
type: "
|
|
18032
|
+
type: "IFRAME_MSG_TOKEN_REFRESHED",
|
|
18032
18033
|
messageId: message.messageId,
|
|
18033
18034
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
18034
18035
|
timestamp: Date.now()
|
|
@@ -18279,7 +18280,7 @@ var init_iframe_manager = __esm({
|
|
|
18279
18280
|
avatar,
|
|
18280
18281
|
displayName
|
|
18281
18282
|
});
|
|
18282
|
-
if (response.type === "
|
|
18283
|
+
if (response.type === "IFRAME_MSG_AUTH_SUCCESS") {
|
|
18283
18284
|
return {
|
|
18284
18285
|
userId: response.userId,
|
|
18285
18286
|
address: response.address
|
|
@@ -18297,7 +18298,7 @@ var init_iframe_manager = __esm({
|
|
|
18297
18298
|
accessToken
|
|
18298
18299
|
// Pass access token for TSS API authentication
|
|
18299
18300
|
});
|
|
18300
|
-
if (response.type === "
|
|
18301
|
+
if (response.type === "IFRAME_MSG_DKG_SUCCESS") {
|
|
18301
18302
|
return response.ownerAddress;
|
|
18302
18303
|
}
|
|
18303
18304
|
throw new Error("DKG failed");
|
|
@@ -18320,7 +18321,7 @@ var init_iframe_manager = __esm({
|
|
|
18320
18321
|
avatar,
|
|
18321
18322
|
displayName
|
|
18322
18323
|
});
|
|
18323
|
-
if (response.type === "
|
|
18324
|
+
if (response.type === "IFRAME_MSG_SIGNATURE") {
|
|
18324
18325
|
return response.signature;
|
|
18325
18326
|
}
|
|
18326
18327
|
throw new Error("Transaction signing failed");
|
|
@@ -18353,7 +18354,7 @@ var init_iframe_manager = __esm({
|
|
|
18353
18354
|
type: response.type,
|
|
18354
18355
|
hasSignature: !!response.signature
|
|
18355
18356
|
});
|
|
18356
|
-
if (response.type === "
|
|
18357
|
+
if (response.type === "IFRAME_MSG_EIP712_SIGNATURE") {
|
|
18357
18358
|
return response.signature;
|
|
18358
18359
|
}
|
|
18359
18360
|
throw new Error("EIP712 signing failed");
|
|
@@ -18365,7 +18366,7 @@ var init_iframe_manager = __esm({
|
|
|
18365
18366
|
const response = await this.sendMessage("GET_ADDRESS", {
|
|
18366
18367
|
userId
|
|
18367
18368
|
});
|
|
18368
|
-
if (response.type === "
|
|
18369
|
+
if (response.type === "IFRAME_MSG_ADDRESS") {
|
|
18369
18370
|
return response.address;
|
|
18370
18371
|
}
|
|
18371
18372
|
return void 0;
|
|
@@ -18377,7 +18378,7 @@ var init_iframe_manager = __esm({
|
|
|
18377
18378
|
const response = await this.sendMessage("CHECK_KEYSHARE", {
|
|
18378
18379
|
userId
|
|
18379
18380
|
});
|
|
18380
|
-
if (response.type === "
|
|
18381
|
+
if (response.type === "IFRAME_MSG_KEYSHARE_STATUS") {
|
|
18381
18382
|
return {
|
|
18382
18383
|
hasKeyshare: response.hasKeyshare,
|
|
18383
18384
|
address: response.address
|
|
@@ -18773,7 +18774,7 @@ var init_iframe_manager = __esm({
|
|
|
18773
18774
|
const response = await this.sendMessage("GET_TRUSTED_APPS", {
|
|
18774
18775
|
userId
|
|
18775
18776
|
});
|
|
18776
|
-
if (response.type === "
|
|
18777
|
+
if (response.type === "IFRAME_MSG_TRUSTED_APPS_LIST") {
|
|
18777
18778
|
return response.apps || [];
|
|
18778
18779
|
}
|
|
18779
18780
|
return [];
|
|
@@ -18787,7 +18788,7 @@ var init_iframe_manager = __esm({
|
|
|
18787
18788
|
projectId,
|
|
18788
18789
|
appOrigin: origin
|
|
18789
18790
|
});
|
|
18790
|
-
if (response.type === "
|
|
18791
|
+
if (response.type === "IFRAME_MSG_TRUSTED_APP_REMOVED") {
|
|
18791
18792
|
return response.success;
|
|
18792
18793
|
}
|
|
18793
18794
|
return false;
|
|
@@ -18818,7 +18819,7 @@ var init_iframe_manager = __esm({
|
|
|
18818
18819
|
accessToken
|
|
18819
18820
|
// Pass access token for TSS API authentication
|
|
18820
18821
|
});
|
|
18821
|
-
if (response.type === "
|
|
18822
|
+
if (response.type === "IFRAME_MSG_BACKUP_CREATED") {
|
|
18822
18823
|
return response.result;
|
|
18823
18824
|
}
|
|
18824
18825
|
throw new Error("Unexpected response type");
|
|
@@ -18833,7 +18834,7 @@ var init_iframe_manager = __esm({
|
|
|
18833
18834
|
accessToken
|
|
18834
18835
|
// Pass access token for TSS API authentication
|
|
18835
18836
|
});
|
|
18836
|
-
if (response.type === "
|
|
18837
|
+
if (response.type === "IFRAME_MSG_BACKUP_RESTORED") {
|
|
18837
18838
|
return response.result;
|
|
18838
18839
|
}
|
|
18839
18840
|
throw new Error("Unexpected response type");
|
|
@@ -18847,7 +18848,7 @@ var init_iframe_manager = __esm({
|
|
|
18847
18848
|
userId,
|
|
18848
18849
|
password
|
|
18849
18850
|
});
|
|
18850
|
-
if (response.type === "
|
|
18851
|
+
if (response.type === "IFRAME_MSG_BACKUP_ENCRYPTED") {
|
|
18851
18852
|
return response.encryptedData;
|
|
18852
18853
|
}
|
|
18853
18854
|
throw new Error("Unexpected response type");
|
|
@@ -18861,7 +18862,7 @@ var init_iframe_manager = __esm({
|
|
|
18861
18862
|
fileContent,
|
|
18862
18863
|
password
|
|
18863
18864
|
});
|
|
18864
|
-
if (response.type === "
|
|
18865
|
+
if (response.type === "IFRAME_MSG_FILE_RESTORED") {
|
|
18865
18866
|
return response.result;
|
|
18866
18867
|
}
|
|
18867
18868
|
throw new Error("Unexpected response type");
|
|
@@ -18873,7 +18874,7 @@ var init_iframe_manager = __esm({
|
|
|
18873
18874
|
const response = await this.sendMessage("GET_BACKUP_STATUS", {
|
|
18874
18875
|
userId
|
|
18875
18876
|
});
|
|
18876
|
-
if (response.type === "
|
|
18877
|
+
if (response.type === "IFRAME_MSG_BACKUP_STATUS") {
|
|
18877
18878
|
return response.status;
|
|
18878
18879
|
}
|
|
18879
18880
|
throw new Error("Unexpected response type");
|
|
@@ -18883,7 +18884,7 @@ var init_iframe_manager = __esm({
|
|
|
18883
18884
|
*/
|
|
18884
18885
|
async getCloudProviders() {
|
|
18885
18886
|
const response = await this.sendMessage("GET_CLOUD_PROVIDERS", {});
|
|
18886
|
-
if (response.type === "
|
|
18887
|
+
if (response.type === "IFRAME_MSG_CLOUD_PROVIDERS") {
|
|
18887
18888
|
return response.providers;
|
|
18888
18889
|
}
|
|
18889
18890
|
throw new Error("Unexpected response type");
|