@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.cjs CHANGED
@@ -15553,7 +15553,7 @@ var init_package = __esm({
15553
15553
  "package.json"() {
15554
15554
  package_default = {
15555
15555
  name: "@embarkai/ui-kit",
15556
- version: "0.2.7",
15556
+ version: "0.2.8",
15557
15557
  description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
15558
15558
  type: "module",
15559
15559
  main: "./dist/index.cjs",
@@ -17813,6 +17813,7 @@ var init_iframe_manager = __esm({
17813
17813
  this.iframe = null;
17814
17814
  this.channelToken = null;
17815
17815
  this.isReady = false;
17816
+ this.initPromise = null;
17816
17817
  // Message handling
17817
17818
  this.pendingRequests = /* @__PURE__ */ new Map();
17818
17819
  this.usedNonces = /* @__PURE__ */ new Set();
@@ -17850,9 +17851,13 @@ var init_iframe_manager = __esm({
17850
17851
  * Initialize iframe and wait for it to be ready
17851
17852
  */
17852
17853
  async initialize() {
17853
- if (this.iframe) {
17854
- return this.readyPromise;
17854
+ if (this.initPromise) {
17855
+ return this.initPromise;
17855
17856
  }
17857
+ this.initPromise = this.doInitialize();
17858
+ return this.initPromise;
17859
+ }
17860
+ async doInitialize() {
17856
17861
  this.iframe = document.createElement("iframe");
17857
17862
  let iframeUrl = this.iframeUrl;
17858
17863
  this.iframe.src = iframeUrl;
@@ -18122,9 +18127,15 @@ var init_iframe_manager = __esm({
18122
18127
  * Send secure message to iframe
18123
18128
  */
18124
18129
  async sendMessage(type, data) {
18130
+ if (this.initPromise && type !== "SDK_AUTH") {
18131
+ await this.initPromise;
18132
+ }
18125
18133
  if (!this.iframe || !this.iframe.contentWindow) {
18126
18134
  throw new Error("Iframe not initialized");
18127
18135
  }
18136
+ if (!this.channelToken && type !== "SDK_AUTH") {
18137
+ throw createAccountAbstractionError({ message: "SDK channel not established. Initialize iframe first." });
18138
+ }
18128
18139
  const messageId = this.generateMessageId();
18129
18140
  const nonce = this.generateNonce();
18130
18141
  const timestamp = Date.now();
@@ -18988,6 +18999,10 @@ var init_iframe_manager = __esm({
18988
18999
  this.iframe = null;
18989
19000
  this.isReady = false;
18990
19001
  this.channelToken = null;
19002
+ this.initPromise = null;
19003
+ this.readyPromise = new Promise((resolve) => {
19004
+ this.readyResolve = resolve;
19005
+ });
18991
19006
  this.log("[IframeManager] \u2705 Destroyed");
18992
19007
  }
18993
19008
  /**