@embarkai/ui-kit 0.6.9 → 0.6.11

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.
@@ -15,7 +15,7 @@
15
15
  <meta http-equiv="X-Content-Type-Options" content="nosniff" />
16
16
  <meta http-equiv="Referrer-Policy" content="strict-origin-when-cross-origin" />
17
17
 
18
- <title>embarkAI Secure Wallet - iframe version 0.6.9</title>
18
+ <title>embarkAI Secure Wallet - iframe version 0.6.11</title>
19
19
 
20
20
  <!-- Styles will be injected by build process -->
21
21
  <style>
@@ -2662,7 +2662,7 @@ var ACCOUNT_ROUTES = [
2662
2662
  { method: "POST", path: /^\/api\/auth\/link\/email\/(send-code|verify-code)$/ },
2663
2663
  { method: "POST", path: /^\/api\/auth\/link\/passkey\/(begin|complete)$/ },
2664
2664
  { method: "POST", path: /^\/api\/auth\/link\/(x|discord)\/start$/ },
2665
- { method: "DELETE", path: /^\/api\/auth\/unlink\/wallet$/, query: ["address"] },
2665
+ { method: "DELETE", path: /^\/api\/auth\/unlink\/wallet$/, query: ["address", "externalId"] },
2666
2666
  { method: "DELETE", path: new RegExp(`^/api/auth/unlink/(${UNLINKABLE})$`), query: ["externalId"] }
2667
2667
  ];
2668
2668
  function parseAccountRoute(method, pathWithQuery) {
@@ -2765,7 +2765,7 @@ function createAccountAbstractionError(params) {
2765
2765
 
2766
2766
  // src/iframe/lib/sdk-version.ts
2767
2767
  var SDK_VERSION_HEADER = "X-Embark-SDK-Version";
2768
- var IFRAME_SDK_VERSION = `iframe-${"0.6.9"}`;
2768
+ var IFRAME_SDK_VERSION = `iframe-${"0.6.11"}`;
2769
2769
  function sdkVersionHeaders() {
2770
2770
  return { [SDK_VERSION_HEADER]: IFRAME_SDK_VERSION };
2771
2771
  }
@@ -5280,7 +5280,7 @@ var GoogleDriveProvider = class {
5280
5280
  __publicField(this, "icon", "\u{1F4C1}");
5281
5281
  // Can be replaced with proper icon
5282
5282
  __publicField(this, "accessToken", null);
5283
- __publicField(this, "CLIENT_ID", typeof window.__GOOGLE_DRIVE_CLIENT_ID__ !== "undefined" && window.__GOOGLE_DRIVE_CLIENT_ID__ || "");
5283
+ __publicField(this, "CLIENT_ID", "41560291859-hjqblt3jb80e268i0nafeu4m89eomhg3.apps.googleusercontent.com");
5284
5284
  __publicField(this, "DISCOVERY_DOC", "https://www.googleapis.com/discovery/v1/apis/drive/v3/rest");
5285
5285
  __publicField(this, "SCOPES", "https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/drive.appdata");
5286
5286
  __publicField(this, "gapiInitialized", false);
@@ -8746,7 +8746,7 @@ var UserPolicyAPI = class extends TokenRefreshApiClient {
8746
8746
  };
8747
8747
 
8748
8748
  // src/iframe/main.ts
8749
- var IFRAME_VERSION = "0.6.9";
8749
+ var IFRAME_VERSION = "0.6.11";
8750
8750
  function walletOwnerOf(data) {
8751
8751
  const owner = data?.walletOwner;
8752
8752
  return typeof owner === "string" && /^0x[0-9a-fA-F]{40}$/.test(owner) ? owner : void 0;
package/dist/index.cjs CHANGED
@@ -333,7 +333,7 @@ var import_auth, UI_KIT_VERSION;
333
333
  var init_sdk_version = __esm({
334
334
  "src/internal/lib/sdk-version.ts"() {
335
335
  import_auth = require("@embarkai/core/auth");
336
- UI_KIT_VERSION = "0.6.9";
336
+ UI_KIT_VERSION = "0.6.11";
337
337
  if (UI_KIT_VERSION) (0, import_auth.setSdkVersion)(UI_KIT_VERSION);
338
338
  }
339
339
  });
@@ -6281,7 +6281,7 @@ var init_account_routes = __esm({
6281
6281
  { method: "POST", path: /^\/api\/auth\/link\/email\/(send-code|verify-code)$/ },
6282
6282
  { method: "POST", path: /^\/api\/auth\/link\/passkey\/(begin|complete)$/ },
6283
6283
  { method: "POST", path: /^\/api\/auth\/link\/(x|discord)\/start$/ },
6284
- { method: "DELETE", path: /^\/api\/auth\/unlink\/wallet$/, query: ["address"] },
6284
+ { method: "DELETE", path: /^\/api\/auth\/unlink\/wallet$/, query: ["address", "externalId"] },
6285
6285
  { method: "DELETE", path: new RegExp(`^/api/auth/unlink/(${UNLINKABLE})$`), query: ["externalId"] }
6286
6286
  ];
6287
6287
  }
@@ -10137,6 +10137,11 @@ function useAutoConnect() {
10137
10137
  if (!hasHydrated) return;
10138
10138
  if (autoConnectAttemptedRef.current) return;
10139
10139
  setIsLoading(true);
10140
+ const startedAt = Date.now();
10141
+ const run = (attempt) => tryAutoConnect(attempt).catch((error) => {
10142
+ console.warn("[UI-KIT][AutoConnect] Auto-connect failed:", error);
10143
+ setIsLoading(false);
10144
+ });
10140
10145
  const tryAutoConnect = async (attempt) => {
10141
10146
  console.log("[AUTOCONNECT] attempt", attempt);
10142
10147
  if (address || session) {
@@ -10154,9 +10159,11 @@ function useAutoConnect() {
10154
10159
  } catch (iframeError) {
10155
10160
  console.error("[UI-KIT][AutoConnect] Failed to initialize iframe:", iframeError);
10156
10161
  setIsIframeReady(false);
10157
- if (attempt < 20) {
10158
- setTimeout(() => tryAutoConnect(attempt + 1), 500);
10162
+ if (Date.now() - startedAt < IFRAME_RETRY_DEADLINE_MS) {
10163
+ setTimeout(() => run(attempt + 1), 500);
10164
+ return;
10159
10165
  }
10166
+ setIsLoading(false);
10160
10167
  return;
10161
10168
  }
10162
10169
  const { ensureValidToken: ensureValidToken2, restoreDappSessionFromIframe: restoreDappSessionFromIframe2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
@@ -10248,11 +10255,11 @@ function useAutoConnect() {
10248
10255
  }
10249
10256
  };
10250
10257
  autoConnectAttemptedRef.current = true;
10251
- tryAutoConnect(0);
10258
+ run(0);
10252
10259
  }, [hasHydrated]);
10253
10260
  return null;
10254
10261
  }
10255
- var import_react11;
10262
+ var import_react11, IFRAME_RETRY_DEADLINE_MS;
10256
10263
  var init_useAutoConnect = __esm({
10257
10264
  "src/internal/hooks/useAutoConnect.ts"() {
10258
10265
  init_ProviderContext();
@@ -10260,6 +10267,7 @@ var init_useAutoConnect = __esm({
10260
10267
  import_react11 = require("react");
10261
10268
  init_post_login_backup();
10262
10269
  init_useLayoutDataStore();
10270
+ IFRAME_RETRY_DEADLINE_MS = 1e4;
10263
10271
  }
10264
10272
  });
10265
10273
 
@@ -34195,7 +34203,7 @@ var init_package = __esm({
34195
34203
  "package.json"() {
34196
34204
  package_default = {
34197
34205
  name: "@embarkai/ui-kit",
34198
- version: "0.6.9",
34206
+ version: "0.6.11",
34199
34207
  description: "React UI components and hooks for embarkAI authentication and Account Abstraction",
34200
34208
  type: "module",
34201
34209
  main: "./dist/index.cjs",
@@ -35314,6 +35322,7 @@ var init_iframe_manager = __esm({
35314
35322
  // 5 minutes (for user interactions like consent)
35315
35323
  ENSURE_BACKUP_TIMEOUT = 15e3;
35316
35324
  // silent backup, no user interaction
35325
+ READY_TIMEOUT = 15e3;
35317
35326
  NONCE_EXPIRY = 3e5;
35318
35327
  // 5 minutes
35319
35328
  HEARTBEAT_INTERVAL = 5 * 60 * 1e3;
@@ -35393,8 +35402,12 @@ var init_iframe_manager = __esm({
35393
35402
  this.messageListener = this.handleMessage.bind(this);
35394
35403
  window.addEventListener("message", this.messageListener);
35395
35404
  document.body.appendChild(this.iframe);
35396
- await this.readyPromise;
35397
- await this.authenticateSDK();
35405
+ try {
35406
+ await this.withinReadyTimeout(this.readyPromise.then(() => this.authenticateSDK()));
35407
+ } catch (error) {
35408
+ this.destroy();
35409
+ throw error;
35410
+ }
35398
35411
  (0, import_auth28.setDappSessionRecovery)(async (userId) => {
35399
35412
  const pair = await this.getDappTokens();
35400
35413
  return pair && pair.userId === userId ? pair : null;
@@ -35410,6 +35423,18 @@ var init_iframe_manager = __esm({
35410
35423
  setOnWalletReady(callback) {
35411
35424
  this.onWalletReadyCallback = callback;
35412
35425
  }
35426
+ withinReadyTimeout(handshake) {
35427
+ handshake.catch(() => {
35428
+ });
35429
+ let timer;
35430
+ const timeout = new Promise((_, reject) => {
35431
+ timer = setTimeout(
35432
+ () => reject(new Error(`Iframe did not become ready in ${this.READY_TIMEOUT} ms: ${this.iframeUrl}`)),
35433
+ this.READY_TIMEOUT
35434
+ );
35435
+ });
35436
+ return Promise.race([handshake, timeout]).finally(() => clearTimeout(timer));
35437
+ }
35413
35438
  /**
35414
35439
  * Authenticate SDK with iframe to establish secure channel
35415
35440
  */
package/dist/index.d.cts CHANGED
@@ -851,6 +851,7 @@ declare class IframeManager {
851
851
  private providerConnections;
852
852
  private readonly REQUEST_TIMEOUT;
853
853
  private readonly ENSURE_BACKUP_TIMEOUT;
854
+ private readonly READY_TIMEOUT;
854
855
  private readonly NONCE_EXPIRY;
855
856
  private readonly HEARTBEAT_INTERVAL;
856
857
  private heartbeatInterval?;
@@ -875,6 +876,7 @@ declare class IframeManager {
875
876
  * Set the onWalletReady callback
876
877
  */
877
878
  setOnWalletReady(callback: (status: WalletReadyStatus) => void): void;
879
+ private withinReadyTimeout;
878
880
  /**
879
881
  * Authenticate SDK with iframe to establish secure channel
880
882
  */
package/dist/index.d.ts CHANGED
@@ -851,6 +851,7 @@ declare class IframeManager {
851
851
  private providerConnections;
852
852
  private readonly REQUEST_TIMEOUT;
853
853
  private readonly ENSURE_BACKUP_TIMEOUT;
854
+ private readonly READY_TIMEOUT;
854
855
  private readonly NONCE_EXPIRY;
855
856
  private readonly HEARTBEAT_INTERVAL;
856
857
  private heartbeatInterval?;
@@ -875,6 +876,7 @@ declare class IframeManager {
875
876
  * Set the onWalletReady callback
876
877
  */
877
878
  setOnWalletReady(callback: (status: WalletReadyStatus) => void): void;
879
+ private withinReadyTimeout;
878
880
  /**
879
881
  * Authenticate SDK with iframe to establish secure channel
880
882
  */
package/dist/index.js CHANGED
@@ -323,7 +323,7 @@ import { getSdkVersion, sdkVersionHeaders, setSdkVersion } from "@embarkai/core/
323
323
  var UI_KIT_VERSION;
324
324
  var init_sdk_version = __esm({
325
325
  "src/internal/lib/sdk-version.ts"() {
326
- UI_KIT_VERSION = "0.6.9";
326
+ UI_KIT_VERSION = "0.6.11";
327
327
  if (UI_KIT_VERSION) setSdkVersion(UI_KIT_VERSION);
328
328
  }
329
329
  });
@@ -6267,7 +6267,7 @@ var init_account_routes = __esm({
6267
6267
  { method: "POST", path: /^\/api\/auth\/link\/email\/(send-code|verify-code)$/ },
6268
6268
  { method: "POST", path: /^\/api\/auth\/link\/passkey\/(begin|complete)$/ },
6269
6269
  { method: "POST", path: /^\/api\/auth\/link\/(x|discord)\/start$/ },
6270
- { method: "DELETE", path: /^\/api\/auth\/unlink\/wallet$/, query: ["address"] },
6270
+ { method: "DELETE", path: /^\/api\/auth\/unlink\/wallet$/, query: ["address", "externalId"] },
6271
6271
  { method: "DELETE", path: new RegExp(`^/api/auth/unlink/(${UNLINKABLE})$`), query: ["externalId"] }
6272
6272
  ];
6273
6273
  }
@@ -10140,6 +10140,11 @@ function useAutoConnect() {
10140
10140
  if (!hasHydrated) return;
10141
10141
  if (autoConnectAttemptedRef.current) return;
10142
10142
  setIsLoading(true);
10143
+ const startedAt = Date.now();
10144
+ const run = (attempt) => tryAutoConnect(attempt).catch((error) => {
10145
+ console.warn("[UI-KIT][AutoConnect] Auto-connect failed:", error);
10146
+ setIsLoading(false);
10147
+ });
10143
10148
  const tryAutoConnect = async (attempt) => {
10144
10149
  console.log("[AUTOCONNECT] attempt", attempt);
10145
10150
  if (address || session) {
@@ -10157,9 +10162,11 @@ function useAutoConnect() {
10157
10162
  } catch (iframeError) {
10158
10163
  console.error("[UI-KIT][AutoConnect] Failed to initialize iframe:", iframeError);
10159
10164
  setIsIframeReady(false);
10160
- if (attempt < 20) {
10161
- setTimeout(() => tryAutoConnect(attempt + 1), 500);
10165
+ if (Date.now() - startedAt < IFRAME_RETRY_DEADLINE_MS) {
10166
+ setTimeout(() => run(attempt + 1), 500);
10167
+ return;
10162
10168
  }
10169
+ setIsLoading(false);
10163
10170
  return;
10164
10171
  }
10165
10172
  const { ensureValidToken: ensureValidToken2, restoreDappSessionFromIframe: restoreDappSessionFromIframe2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
@@ -10251,16 +10258,18 @@ function useAutoConnect() {
10251
10258
  }
10252
10259
  };
10253
10260
  autoConnectAttemptedRef.current = true;
10254
- tryAutoConnect(0);
10261
+ run(0);
10255
10262
  }, [hasHydrated]);
10256
10263
  return null;
10257
10264
  }
10265
+ var IFRAME_RETRY_DEADLINE_MS;
10258
10266
  var init_useAutoConnect = __esm({
10259
10267
  "src/internal/hooks/useAutoConnect.ts"() {
10260
10268
  init_ProviderContext();
10261
10269
  init_SessionContext();
10262
10270
  init_post_login_backup();
10263
10271
  init_useLayoutDataStore();
10272
+ IFRAME_RETRY_DEADLINE_MS = 1e4;
10264
10273
  }
10265
10274
  });
10266
10275
 
@@ -34126,7 +34135,7 @@ var init_package = __esm({
34126
34135
  "package.json"() {
34127
34136
  package_default = {
34128
34137
  name: "@embarkai/ui-kit",
34129
- version: "0.6.9",
34138
+ version: "0.6.11",
34130
34139
  description: "React UI components and hooks for embarkAI authentication and Account Abstraction",
34131
34140
  type: "module",
34132
34141
  main: "./dist/index.cjs",
@@ -35248,6 +35257,7 @@ var init_iframe_manager = __esm({
35248
35257
  // 5 minutes (for user interactions like consent)
35249
35258
  ENSURE_BACKUP_TIMEOUT = 15e3;
35250
35259
  // silent backup, no user interaction
35260
+ READY_TIMEOUT = 15e3;
35251
35261
  NONCE_EXPIRY = 3e5;
35252
35262
  // 5 minutes
35253
35263
  HEARTBEAT_INTERVAL = 5 * 60 * 1e3;
@@ -35327,8 +35337,12 @@ var init_iframe_manager = __esm({
35327
35337
  this.messageListener = this.handleMessage.bind(this);
35328
35338
  window.addEventListener("message", this.messageListener);
35329
35339
  document.body.appendChild(this.iframe);
35330
- await this.readyPromise;
35331
- await this.authenticateSDK();
35340
+ try {
35341
+ await this.withinReadyTimeout(this.readyPromise.then(() => this.authenticateSDK()));
35342
+ } catch (error) {
35343
+ this.destroy();
35344
+ throw error;
35345
+ }
35332
35346
  setDappSessionRecovery(async (userId) => {
35333
35347
  const pair = await this.getDappTokens();
35334
35348
  return pair && pair.userId === userId ? pair : null;
@@ -35344,6 +35358,18 @@ var init_iframe_manager = __esm({
35344
35358
  setOnWalletReady(callback) {
35345
35359
  this.onWalletReadyCallback = callback;
35346
35360
  }
35361
+ withinReadyTimeout(handshake) {
35362
+ handshake.catch(() => {
35363
+ });
35364
+ let timer;
35365
+ const timeout = new Promise((_, reject) => {
35366
+ timer = setTimeout(
35367
+ () => reject(new Error(`Iframe did not become ready in ${this.READY_TIMEOUT} ms: ${this.iframeUrl}`)),
35368
+ this.READY_TIMEOUT
35369
+ );
35370
+ });
35371
+ return Promise.race([handshake, timeout]).finally(() => clearTimeout(timer));
35372
+ }
35347
35373
  /**
35348
35374
  * Authenticate SDK with iframe to establish secure channel
35349
35375
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embarkai/ui-kit",
3
- "version": "0.6.9",
3
+ "version": "0.6.11",
4
4
  "description": "React UI components and hooks for embarkAI authentication and Account Abstraction",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",