@embarkai/ui-kit 0.2.7 → 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
  */
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
  */
package/dist/index.js CHANGED
@@ -15479,7 +15479,7 @@ var init_package = __esm({
15479
15479
  "package.json"() {
15480
15480
  package_default = {
15481
15481
  name: "@embarkai/ui-kit",
15482
- version: "0.2.7",
15482
+ version: "0.2.8",
15483
15483
  description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
15484
15484
  type: "module",
15485
15485
  main: "./dist/index.cjs",
@@ -17754,6 +17754,7 @@ var init_iframe_manager = __esm({
17754
17754
  this.iframe = null;
17755
17755
  this.channelToken = null;
17756
17756
  this.isReady = false;
17757
+ this.initPromise = null;
17757
17758
  // Message handling
17758
17759
  this.pendingRequests = /* @__PURE__ */ new Map();
17759
17760
  this.usedNonces = /* @__PURE__ */ new Set();
@@ -17791,9 +17792,13 @@ var init_iframe_manager = __esm({
17791
17792
  * Initialize iframe and wait for it to be ready
17792
17793
  */
17793
17794
  async initialize() {
17794
- if (this.iframe) {
17795
- return this.readyPromise;
17795
+ if (this.initPromise) {
17796
+ return this.initPromise;
17796
17797
  }
17798
+ this.initPromise = this.doInitialize();
17799
+ return this.initPromise;
17800
+ }
17801
+ async doInitialize() {
17797
17802
  this.iframe = document.createElement("iframe");
17798
17803
  let iframeUrl = this.iframeUrl;
17799
17804
  this.iframe.src = iframeUrl;
@@ -18063,9 +18068,15 @@ var init_iframe_manager = __esm({
18063
18068
  * Send secure message to iframe
18064
18069
  */
18065
18070
  async sendMessage(type, data) {
18071
+ if (this.initPromise && type !== "SDK_AUTH") {
18072
+ await this.initPromise;
18073
+ }
18066
18074
  if (!this.iframe || !this.iframe.contentWindow) {
18067
18075
  throw new Error("Iframe not initialized");
18068
18076
  }
18077
+ if (!this.channelToken && type !== "SDK_AUTH") {
18078
+ throw createAccountAbstractionError({ message: "SDK channel not established. Initialize iframe first." });
18079
+ }
18069
18080
  const messageId = this.generateMessageId();
18070
18081
  const nonce = this.generateNonce();
18071
18082
  const timestamp = Date.now();
@@ -18929,6 +18940,10 @@ var init_iframe_manager = __esm({
18929
18940
  this.iframe = null;
18930
18941
  this.isReady = false;
18931
18942
  this.channelToken = null;
18943
+ this.initPromise = null;
18944
+ this.readyPromise = new Promise((resolve) => {
18945
+ this.readyResolve = resolve;
18946
+ });
18932
18947
  this.log("[IframeManager] \u2705 Destroyed");
18933
18948
  }
18934
18949
  /**