@embarkai/ui-kit 0.2.6 → 0.2.8
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 +7 -2
- package/dist/iframe/main.js.map +1 -1
- package/dist/index.cjs +42 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +42 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2719,12 +2719,13 @@ function useListenIframeAuthEvents() {
|
|
|
2719
2719
|
const setIsIframeReady = useSession((state) => state.setIsIframeReady);
|
|
2720
2720
|
const handleIframeMessage = (0, import_react6.useCallback)(
|
|
2721
2721
|
(event) => {
|
|
2722
|
-
|
|
2722
|
+
const type = event.data?.type?.startsWith?.("LUMIA_PASSPORT_") ? event.data.type.replace("LUMIA_PASSPORT_", "IFRAME_MSG_") : event.data?.type;
|
|
2723
|
+
if (type === "IFRAME_MSG_IFRAME_READY") {
|
|
2723
2724
|
console.log("[ IFRAME MESSAGE CACTHED ] Iframe is ready");
|
|
2724
2725
|
setIsIframeReady(true);
|
|
2725
|
-
} else if (
|
|
2726
|
+
} else if (type === "IFRAME_MSG_SHOW_IFRAME") {
|
|
2726
2727
|
console.log("[ IFRAME MESSAGE CACTHED ] Consent screen shown - hiding auth modal");
|
|
2727
|
-
} else if (
|
|
2728
|
+
} else if (type === "IFRAME_MSG_HIDE_IFRAME") {
|
|
2728
2729
|
console.log("[ IFRAME MESSAGE CACTHED ] Consent screen hidden");
|
|
2729
2730
|
} else if (event.data?.type === "KEYSHARE_RECOVERY_NEEDED") {
|
|
2730
2731
|
console.log("[ IFRAME MESSAGE CACTHED] recovery neede");
|
|
@@ -10575,6 +10576,12 @@ var init_useLinkTelegram = __esm({
|
|
|
10575
10576
|
});
|
|
10576
10577
|
|
|
10577
10578
|
// src/internal/components/ManageWalletMenu/ProviderCard.tsx
|
|
10579
|
+
function formatExternalId(provider, externalId) {
|
|
10580
|
+
if (provider === "wallet" && externalId.startsWith("0x") && externalId.length >= 14) {
|
|
10581
|
+
return `${externalId.slice(0, 10)}...${externalId.slice(-4)}`;
|
|
10582
|
+
}
|
|
10583
|
+
return externalId;
|
|
10584
|
+
}
|
|
10578
10585
|
function ProviderCard(props) {
|
|
10579
10586
|
const { t } = useT();
|
|
10580
10587
|
const setPage = useLayoutDataStore((st) => st.setPage);
|
|
@@ -10601,7 +10608,8 @@ function ProviderCard(props) {
|
|
|
10601
10608
|
{
|
|
10602
10609
|
style: { maxWidth: 184 },
|
|
10603
10610
|
className: "block w-full font-bold text-xs whitespace-nowrap text-ellipsis overflow-hidden",
|
|
10604
|
-
|
|
10611
|
+
title: props.externalId,
|
|
10612
|
+
children: formatExternalId(props.provider, props.externalId)
|
|
10605
10613
|
}
|
|
10606
10614
|
)
|
|
10607
10615
|
] }),
|
|
@@ -15545,7 +15553,7 @@ var init_package = __esm({
|
|
|
15545
15553
|
"package.json"() {
|
|
15546
15554
|
package_default = {
|
|
15547
15555
|
name: "@embarkai/ui-kit",
|
|
15548
|
-
version: "0.2.
|
|
15556
|
+
version: "0.2.8",
|
|
15549
15557
|
description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
|
|
15550
15558
|
type: "module",
|
|
15551
15559
|
main: "./dist/index.cjs",
|
|
@@ -17805,6 +17813,7 @@ var init_iframe_manager = __esm({
|
|
|
17805
17813
|
this.iframe = null;
|
|
17806
17814
|
this.channelToken = null;
|
|
17807
17815
|
this.isReady = false;
|
|
17816
|
+
this.initPromise = null;
|
|
17808
17817
|
// Message handling
|
|
17809
17818
|
this.pendingRequests = /* @__PURE__ */ new Map();
|
|
17810
17819
|
this.usedNonces = /* @__PURE__ */ new Set();
|
|
@@ -17842,9 +17851,13 @@ var init_iframe_manager = __esm({
|
|
|
17842
17851
|
* Initialize iframe and wait for it to be ready
|
|
17843
17852
|
*/
|
|
17844
17853
|
async initialize() {
|
|
17845
|
-
if (this.
|
|
17846
|
-
return this.
|
|
17854
|
+
if (this.initPromise) {
|
|
17855
|
+
return this.initPromise;
|
|
17847
17856
|
}
|
|
17857
|
+
this.initPromise = this.doInitialize();
|
|
17858
|
+
return this.initPromise;
|
|
17859
|
+
}
|
|
17860
|
+
async doInitialize() {
|
|
17848
17861
|
this.iframe = document.createElement("iframe");
|
|
17849
17862
|
let iframeUrl = this.iframeUrl;
|
|
17850
17863
|
this.iframe.src = iframeUrl;
|
|
@@ -17964,6 +17977,17 @@ var init_iframe_manager = __esm({
|
|
|
17964
17977
|
});
|
|
17965
17978
|
this.log("[IframeManager] Visibility handler setup");
|
|
17966
17979
|
}
|
|
17980
|
+
/**
|
|
17981
|
+
* Normalize legacy message types from cached iframe versions.
|
|
17982
|
+
* Old iframe sends LUMIA_PASSPORT_*, new iframe sends IFRAME_MSG_*.
|
|
17983
|
+
* This ensures both work until all browser caches expire.
|
|
17984
|
+
*/
|
|
17985
|
+
normalizeMessageType(type) {
|
|
17986
|
+
if (type.startsWith("LUMIA_PASSPORT_")) {
|
|
17987
|
+
return type.replace("LUMIA_PASSPORT_", "IFRAME_MSG_");
|
|
17988
|
+
}
|
|
17989
|
+
return type;
|
|
17990
|
+
}
|
|
17967
17991
|
/**
|
|
17968
17992
|
* Handle incoming postMessage events
|
|
17969
17993
|
*/
|
|
@@ -17972,6 +17996,7 @@ var init_iframe_manager = __esm({
|
|
|
17972
17996
|
if (!message || typeof message !== "object" || !message.type) {
|
|
17973
17997
|
return;
|
|
17974
17998
|
}
|
|
17999
|
+
message.type = this.normalizeMessageType(message.type);
|
|
17975
18000
|
const validIframeTypes = [
|
|
17976
18001
|
"IFRAME_MSG_IFRAME_READY",
|
|
17977
18002
|
"IFRAME_MSG_WALLET_READY",
|
|
@@ -18102,9 +18127,15 @@ var init_iframe_manager = __esm({
|
|
|
18102
18127
|
* Send secure message to iframe
|
|
18103
18128
|
*/
|
|
18104
18129
|
async sendMessage(type, data) {
|
|
18130
|
+
if (this.initPromise && type !== "SDK_AUTH") {
|
|
18131
|
+
await this.initPromise;
|
|
18132
|
+
}
|
|
18105
18133
|
if (!this.iframe || !this.iframe.contentWindow) {
|
|
18106
18134
|
throw new Error("Iframe not initialized");
|
|
18107
18135
|
}
|
|
18136
|
+
if (!this.channelToken && type !== "SDK_AUTH") {
|
|
18137
|
+
throw createAccountAbstractionError({ message: "SDK channel not established. Initialize iframe first." });
|
|
18138
|
+
}
|
|
18108
18139
|
const messageId = this.generateMessageId();
|
|
18109
18140
|
const nonce = this.generateNonce();
|
|
18110
18141
|
const timestamp = Date.now();
|
|
@@ -18968,6 +18999,10 @@ var init_iframe_manager = __esm({
|
|
|
18968
18999
|
this.iframe = null;
|
|
18969
19000
|
this.isReady = false;
|
|
18970
19001
|
this.channelToken = null;
|
|
19002
|
+
this.initPromise = null;
|
|
19003
|
+
this.readyPromise = new Promise((resolve) => {
|
|
19004
|
+
this.readyResolve = resolve;
|
|
19005
|
+
});
|
|
18971
19006
|
this.log("[IframeManager] \u2705 Destroyed");
|
|
18972
19007
|
}
|
|
18973
19008
|
/**
|