@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/index.d.cts CHANGED
@@ -618,6 +618,7 @@ declare class IframeManager {
618
618
  private isReady;
619
619
  private readyPromise;
620
620
  private readyResolve;
621
+ private initPromise;
621
622
  private onWalletReadyCallback?;
622
623
  private pendingRequests;
623
624
  private usedNonces;
@@ -639,6 +640,7 @@ declare class IframeManager {
639
640
  * Initialize iframe and wait for it to be ready
640
641
  */
641
642
  initialize(): Promise<void>;
643
+ private doInitialize;
642
644
  /**
643
645
  * Set the onWalletReady callback
644
646
  */
@@ -663,6 +665,12 @@ declare class IframeManager {
663
665
  * Setup visibility change handler to check channel when tab becomes visible
664
666
  */
665
667
  private setupVisibilityHandler;
668
+ /**
669
+ * Normalize legacy message types from cached iframe versions.
670
+ * Old iframe sends LUMIA_PASSPORT_*, new iframe sends IFRAME_MSG_*.
671
+ * This ensures both work until all browser caches expire.
672
+ */
673
+ private normalizeMessageType;
666
674
  /**
667
675
  * Handle incoming postMessage events
668
676
  */
package/dist/index.d.ts CHANGED
@@ -618,6 +618,7 @@ declare class IframeManager {
618
618
  private isReady;
619
619
  private readyPromise;
620
620
  private readyResolve;
621
+ private initPromise;
621
622
  private onWalletReadyCallback?;
622
623
  private pendingRequests;
623
624
  private usedNonces;
@@ -639,6 +640,7 @@ declare class IframeManager {
639
640
  * Initialize iframe and wait for it to be ready
640
641
  */
641
642
  initialize(): Promise<void>;
643
+ private doInitialize;
642
644
  /**
643
645
  * Set the onWalletReady callback
644
646
  */
@@ -663,6 +665,12 @@ declare class IframeManager {
663
665
  * Setup visibility change handler to check channel when tab becomes visible
664
666
  */
665
667
  private setupVisibilityHandler;
668
+ /**
669
+ * Normalize legacy message types from cached iframe versions.
670
+ * Old iframe sends LUMIA_PASSPORT_*, new iframe sends IFRAME_MSG_*.
671
+ * This ensures both work until all browser caches expire.
672
+ */
673
+ private normalizeMessageType;
666
674
  /**
667
675
  * Handle incoming postMessage events
668
676
  */
package/dist/index.js CHANGED
@@ -2713,12 +2713,13 @@ function useListenIframeAuthEvents() {
2713
2713
  const setIsIframeReady = useSession((state) => state.setIsIframeReady);
2714
2714
  const handleIframeMessage = useCallback4(
2715
2715
  (event) => {
2716
- if (event.data?.type === "IFRAME_MSG_IFRAME_READY") {
2716
+ const type = event.data?.type?.startsWith?.("LUMIA_PASSPORT_") ? event.data.type.replace("LUMIA_PASSPORT_", "IFRAME_MSG_") : event.data?.type;
2717
+ if (type === "IFRAME_MSG_IFRAME_READY") {
2717
2718
  console.log("[ IFRAME MESSAGE CACTHED ] Iframe is ready");
2718
2719
  setIsIframeReady(true);
2719
- } else if (event.data?.type === "IFRAME_MSG_SHOW_IFRAME") {
2720
+ } else if (type === "IFRAME_MSG_SHOW_IFRAME") {
2720
2721
  console.log("[ IFRAME MESSAGE CACTHED ] Consent screen shown - hiding auth modal");
2721
- } else if (event.data?.type === "IFRAME_MSG_HIDE_IFRAME") {
2722
+ } else if (type === "IFRAME_MSG_HIDE_IFRAME") {
2722
2723
  console.log("[ IFRAME MESSAGE CACTHED ] Consent screen hidden");
2723
2724
  } else if (event.data?.type === "KEYSHARE_RECOVERY_NEEDED") {
2724
2725
  console.log("[ IFRAME MESSAGE CACTHED] recovery neede");
@@ -10524,6 +10525,12 @@ var init_useLinkTelegram = __esm({
10524
10525
  // src/internal/components/ManageWalletMenu/ProviderCard.tsx
10525
10526
  import { CheckCircle, Clock, Trash2 } from "lucide-react";
10526
10527
  import { jsx as jsx55, jsxs as jsxs48 } from "react/jsx-runtime";
10528
+ function formatExternalId(provider, externalId) {
10529
+ if (provider === "wallet" && externalId.startsWith("0x") && externalId.length >= 14) {
10530
+ return `${externalId.slice(0, 10)}...${externalId.slice(-4)}`;
10531
+ }
10532
+ return externalId;
10533
+ }
10527
10534
  function ProviderCard(props) {
10528
10535
  const { t } = useT();
10529
10536
  const setPage = useLayoutDataStore((st) => st.setPage);
@@ -10550,7 +10557,8 @@ function ProviderCard(props) {
10550
10557
  {
10551
10558
  style: { maxWidth: 184 },
10552
10559
  className: "block w-full font-bold text-xs whitespace-nowrap text-ellipsis overflow-hidden",
10553
- children: props.externalId
10560
+ title: props.externalId,
10561
+ children: formatExternalId(props.provider, props.externalId)
10554
10562
  }
10555
10563
  )
10556
10564
  ] }),
@@ -15471,7 +15479,7 @@ var init_package = __esm({
15471
15479
  "package.json"() {
15472
15480
  package_default = {
15473
15481
  name: "@embarkai/ui-kit",
15474
- version: "0.2.6",
15482
+ version: "0.2.8",
15475
15483
  description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
15476
15484
  type: "module",
15477
15485
  main: "./dist/index.cjs",
@@ -17746,6 +17754,7 @@ var init_iframe_manager = __esm({
17746
17754
  this.iframe = null;
17747
17755
  this.channelToken = null;
17748
17756
  this.isReady = false;
17757
+ this.initPromise = null;
17749
17758
  // Message handling
17750
17759
  this.pendingRequests = /* @__PURE__ */ new Map();
17751
17760
  this.usedNonces = /* @__PURE__ */ new Set();
@@ -17783,9 +17792,13 @@ var init_iframe_manager = __esm({
17783
17792
  * Initialize iframe and wait for it to be ready
17784
17793
  */
17785
17794
  async initialize() {
17786
- if (this.iframe) {
17787
- return this.readyPromise;
17795
+ if (this.initPromise) {
17796
+ return this.initPromise;
17788
17797
  }
17798
+ this.initPromise = this.doInitialize();
17799
+ return this.initPromise;
17800
+ }
17801
+ async doInitialize() {
17789
17802
  this.iframe = document.createElement("iframe");
17790
17803
  let iframeUrl = this.iframeUrl;
17791
17804
  this.iframe.src = iframeUrl;
@@ -17905,6 +17918,17 @@ var init_iframe_manager = __esm({
17905
17918
  });
17906
17919
  this.log("[IframeManager] Visibility handler setup");
17907
17920
  }
17921
+ /**
17922
+ * Normalize legacy message types from cached iframe versions.
17923
+ * Old iframe sends LUMIA_PASSPORT_*, new iframe sends IFRAME_MSG_*.
17924
+ * This ensures both work until all browser caches expire.
17925
+ */
17926
+ normalizeMessageType(type) {
17927
+ if (type.startsWith("LUMIA_PASSPORT_")) {
17928
+ return type.replace("LUMIA_PASSPORT_", "IFRAME_MSG_");
17929
+ }
17930
+ return type;
17931
+ }
17908
17932
  /**
17909
17933
  * Handle incoming postMessage events
17910
17934
  */
@@ -17913,6 +17937,7 @@ var init_iframe_manager = __esm({
17913
17937
  if (!message || typeof message !== "object" || !message.type) {
17914
17938
  return;
17915
17939
  }
17940
+ message.type = this.normalizeMessageType(message.type);
17916
17941
  const validIframeTypes = [
17917
17942
  "IFRAME_MSG_IFRAME_READY",
17918
17943
  "IFRAME_MSG_WALLET_READY",
@@ -18043,9 +18068,15 @@ var init_iframe_manager = __esm({
18043
18068
  * Send secure message to iframe
18044
18069
  */
18045
18070
  async sendMessage(type, data) {
18071
+ if (this.initPromise && type !== "SDK_AUTH") {
18072
+ await this.initPromise;
18073
+ }
18046
18074
  if (!this.iframe || !this.iframe.contentWindow) {
18047
18075
  throw new Error("Iframe not initialized");
18048
18076
  }
18077
+ if (!this.channelToken && type !== "SDK_AUTH") {
18078
+ throw createAccountAbstractionError({ message: "SDK channel not established. Initialize iframe first." });
18079
+ }
18049
18080
  const messageId = this.generateMessageId();
18050
18081
  const nonce = this.generateNonce();
18051
18082
  const timestamp = Date.now();
@@ -18909,6 +18940,10 @@ var init_iframe_manager = __esm({
18909
18940
  this.iframe = null;
18910
18941
  this.isReady = false;
18911
18942
  this.channelToken = null;
18943
+ this.initPromise = null;
18944
+ this.readyPromise = new Promise((resolve) => {
18945
+ this.readyResolve = resolve;
18946
+ });
18912
18947
  this.log("[IframeManager] \u2705 Destroyed");
18913
18948
  }
18914
18949
  /**