@embarkai/ui-kit 0.2.5 → 0.2.7

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
@@ -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
- if (event.data?.type === "LUMIA_PASSPORT_IFRAME_READY") {
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 (event.data?.type === "LUMIA_PASSPORT_SHOW_IFRAME") {
2726
+ } else if (type === "IFRAME_MSG_SHOW_IFRAME") {
2726
2727
  console.log("[ IFRAME MESSAGE CACTHED ] Consent screen shown - hiding auth modal");
2727
- } else if (event.data?.type === "LUMIA_PASSPORT_HIDE_IFRAME") {
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);
@@ -10595,13 +10602,14 @@ function ProviderCard(props) {
10595
10602
  return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "w-full flex items-center justify-between gap-[var(--ui-kit-gap)]", children: [
10596
10603
  /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "w-12 h-12 flex items-center justify-center flex-none border border-[var(--ui-kit-bd)] rounded-full", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(IconComponent, { className: "w-5 h-5" }) }),
10597
10604
  /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "flex flex-col gap-1 flex-1", children: [
10598
- /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "block w-full text-[10px] font-medium", children: info.name }),
10605
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "block w-full text-[10px] font-medium", children: props.meta?.walletName || info.name }),
10599
10606
  props.externalId && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10600
10607
  "span",
10601
10608
  {
10602
10609
  style: { maxWidth: 184 },
10603
10610
  className: "block w-full font-bold text-xs whitespace-nowrap text-ellipsis overflow-hidden",
10604
- children: props.externalId
10611
+ title: props.externalId,
10612
+ children: formatExternalId(props.provider, props.externalId)
10605
10613
  }
10606
10614
  )
10607
10615
  ] }),
@@ -10681,19 +10689,19 @@ function ManageWalletMenu() {
10681
10689
  if (name === "x") return "twitter";
10682
10690
  return name;
10683
10691
  };
10684
- const usedProviders = (0, import_lodash_es4.fromPairs)(providers.map((p) => [normalizeProviderName(p.provider), true]));
10685
10692
  const used = [];
10686
10693
  const unused = [];
10687
- POSSIBLE_PROVIDERS.forEach((provider, providerIdx) => {
10694
+ POSSIBLE_PROVIDERS.forEach((provider) => {
10688
10695
  if (!configuredProviders[provider]) return;
10689
10696
  const Icon2 = PROVIDERS_META[provider].icon;
10690
- if (usedProviders[provider]) {
10691
- const apiProviderName = provider === "twitter" ? "x" : provider;
10692
- const providerData = providers.find((p) => p.provider === apiProviderName || p.provider === provider);
10693
- if (providerData) {
10694
- used.push(/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(ProviderCard, { ...providerData }, `${provider}-${providerIdx}`));
10695
- }
10696
- } else {
10697
+ const matches = providers.filter((p) => normalizeProviderName(p.provider) === provider);
10698
+ matches.forEach((providerData, idx) => {
10699
+ used.push(
10700
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(ProviderCard, { ...providerData }, `${provider}-${providerData.externalId || idx}`)
10701
+ );
10702
+ });
10703
+ const isMulti = MULTI_PROVIDERS.includes(provider);
10704
+ if (isMulti || matches.length === 0) {
10697
10705
  unused.push(
10698
10706
  /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
10699
10707
  Button,
@@ -10738,7 +10746,7 @@ function ManageWalletMenu() {
10738
10746
  ] })
10739
10747
  ]
10740
10748
  },
10741
- `${provider}-${providerIdx}`
10749
+ `add-${provider}`
10742
10750
  )
10743
10751
  );
10744
10752
  }
@@ -10800,7 +10808,7 @@ function ManageWalletMenu() {
10800
10808
  }
10801
10809
  );
10802
10810
  }
10803
- var import_lodash_es4, import_lucide_react33, import_react40, import_jsx_runtime56, POSSIBLE_PROVIDERS;
10811
+ var import_lodash_es4, import_lucide_react33, import_react40, import_jsx_runtime56, POSSIBLE_PROVIDERS, MULTI_PROVIDERS;
10804
10812
  var init_ManageWallet = __esm({
10805
10813
  "src/internal/components/ManageWalletMenu/ManageWallet.tsx"() {
10806
10814
  init_useLayoutDataStore();
@@ -10832,6 +10840,7 @@ var init_ManageWallet = __esm({
10832
10840
  "passkey",
10833
10841
  "wallet"
10834
10842
  ];
10843
+ MULTI_PROVIDERS = ["email", "wallet"];
10835
10844
  }
10836
10845
  });
10837
10846
 
@@ -15544,7 +15553,7 @@ var init_package = __esm({
15544
15553
  "package.json"() {
15545
15554
  package_default = {
15546
15555
  name: "@embarkai/ui-kit",
15547
- version: "0.2.5",
15556
+ version: "0.2.7",
15548
15557
  description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
15549
15558
  type: "module",
15550
15559
  main: "./dist/index.cjs",
@@ -17882,7 +17891,7 @@ var init_iframe_manager = __esm({
17882
17891
  const response = await this.sendMessage("SDK_AUTH", {
17883
17892
  projectId: this.projectId
17884
17893
  });
17885
- if (response.type === "LUMIA_PASSPORT_SDK_AUTH_SUCCESS") {
17894
+ if (response.type === "IFRAME_MSG_SDK_AUTH_SUCCESS") {
17886
17895
  this.channelToken = response.sessionToken;
17887
17896
  } else {
17888
17897
  throw new Error("SDK channel authentication failed");
@@ -17963,6 +17972,17 @@ var init_iframe_manager = __esm({
17963
17972
  });
17964
17973
  this.log("[IframeManager] Visibility handler setup");
17965
17974
  }
17975
+ /**
17976
+ * Normalize legacy message types from cached iframe versions.
17977
+ * Old iframe sends LUMIA_PASSPORT_*, new iframe sends IFRAME_MSG_*.
17978
+ * This ensures both work until all browser caches expire.
17979
+ */
17980
+ normalizeMessageType(type) {
17981
+ if (type.startsWith("LUMIA_PASSPORT_")) {
17982
+ return type.replace("LUMIA_PASSPORT_", "IFRAME_MSG_");
17983
+ }
17984
+ return type;
17985
+ }
17966
17986
  /**
17967
17987
  * Handle incoming postMessage events
17968
17988
  */
@@ -17971,24 +17991,25 @@ var init_iframe_manager = __esm({
17971
17991
  if (!message || typeof message !== "object" || !message.type) {
17972
17992
  return;
17973
17993
  }
17994
+ message.type = this.normalizeMessageType(message.type);
17974
17995
  const validIframeTypes = [
17975
- "LUMIA_PASSPORT_IFRAME_READY",
17976
- "LUMIA_PASSPORT_WALLET_READY",
17977
- "LUMIA_PASSPORT_SHOW_IFRAME",
17978
- "LUMIA_PASSPORT_HIDE_IFRAME",
17979
- "LUMIA_PASSPORT_SDK_AUTH_SUCCESS",
17980
- "LUMIA_PASSPORT_AUTH_SUCCESS",
17981
- "LUMIA_PASSPORT_DKG_SUCCESS",
17982
- "LUMIA_PASSPORT_SIGNATURE",
17983
- "LUMIA_PASSPORT_ADDRESS",
17984
- "LUMIA_PASSPORT_KEYSHARE_STATUS",
17985
- "LUMIA_PASSPORT_TRUSTED_APPS_LIST",
17986
- "LUMIA_PASSPORT_TRUSTED_APP_REMOVED",
17987
- "LUMIA_PASSPORT_REQUEST_NEW_TOKEN",
17988
- "LUMIA_PASSPORT_TOKEN_REFRESHED",
17989
- "LUMIA_PASSPORT_HEARTBEAT_RESPONSE",
17990
- "LUMIA_PASSPORT_RESPONSE",
17991
- "LUMIA_PASSPORT_ERROR"
17996
+ "IFRAME_MSG_IFRAME_READY",
17997
+ "IFRAME_MSG_WALLET_READY",
17998
+ "IFRAME_MSG_SHOW_IFRAME",
17999
+ "IFRAME_MSG_HIDE_IFRAME",
18000
+ "IFRAME_MSG_SDK_AUTH_SUCCESS",
18001
+ "IFRAME_MSG_AUTH_SUCCESS",
18002
+ "IFRAME_MSG_DKG_SUCCESS",
18003
+ "IFRAME_MSG_SIGNATURE",
18004
+ "IFRAME_MSG_ADDRESS",
18005
+ "IFRAME_MSG_KEYSHARE_STATUS",
18006
+ "IFRAME_MSG_TRUSTED_APPS_LIST",
18007
+ "IFRAME_MSG_TRUSTED_APP_REMOVED",
18008
+ "IFRAME_MSG_REQUEST_NEW_TOKEN",
18009
+ "IFRAME_MSG_TOKEN_REFRESHED",
18010
+ "IFRAME_MSG_HEARTBEAT_RESPONSE",
18011
+ "IFRAME_MSG_RESPONSE",
18012
+ "IFRAME_MSG_ERROR"
17992
18013
  ];
17993
18014
  if (!validIframeTypes.includes(message.type) && !message.messageId) {
17994
18015
  return;
@@ -18001,31 +18022,31 @@ var init_iframe_manager = __esm({
18001
18022
  });
18002
18023
  return;
18003
18024
  }
18004
- if (message.type === "LUMIA_PASSPORT_IFRAME_READY") {
18005
- this.log("[IframeManager] \u{1F4E8} Received LUMIA_PASSPORT_IFRAME_READY");
18025
+ if (message.type === "IFRAME_MSG_IFRAME_READY") {
18026
+ this.log("[IframeManager] \u{1F4E8} Received IFRAME_MSG_IFRAME_READY");
18006
18027
  this.isReady = true;
18007
18028
  this.readyResolve();
18008
18029
  return;
18009
18030
  }
18010
- if (message.type === "LUMIA_PASSPORT_WALLET_READY") {
18011
- this.log("[IframeManager] \u{1F4E8} Received LUMIA_PASSPORT_WALLET_READY", message.data);
18031
+ if (message.type === "IFRAME_MSG_WALLET_READY") {
18032
+ this.log("[IframeManager] \u{1F4E8} Received IFRAME_MSG_WALLET_READY", message.data);
18012
18033
  if (this.onWalletReadyCallback) {
18013
18034
  this.onWalletReadyCallback(message.data);
18014
18035
  }
18015
18036
  return;
18016
18037
  }
18017
- if (message.type === "LUMIA_PASSPORT_SHOW_IFRAME") {
18018
- this.log("[IframeManager] \u{1F4E8} Received LUMIA_PASSPORT_SHOW_IFRAME");
18038
+ if (message.type === "IFRAME_MSG_SHOW_IFRAME") {
18039
+ this.log("[IframeManager] \u{1F4E8} Received IFRAME_MSG_SHOW_IFRAME");
18019
18040
  this.showIframe();
18020
18041
  return;
18021
18042
  }
18022
- if (message.type === "LUMIA_PASSPORT_HIDE_IFRAME") {
18023
- this.log("[IframeManager] \u{1F4E8} Received LUMIA_PASSPORT_HIDE_IFRAME");
18043
+ if (message.type === "IFRAME_MSG_HIDE_IFRAME") {
18044
+ this.log("[IframeManager] \u{1F4E8} Received IFRAME_MSG_HIDE_IFRAME");
18024
18045
  this.hideIframe();
18025
18046
  return;
18026
18047
  }
18027
- if (message.type === "LUMIA_PASSPORT_REQUEST_NEW_TOKEN") {
18028
- this.log("[IframeManager] \u{1F4E8} Received LUMIA_PASSPORT_REQUEST_NEW_TOKEN");
18048
+ if (message.type === "IFRAME_MSG_REQUEST_NEW_TOKEN") {
18049
+ this.log("[IframeManager] \u{1F4E8} Received IFRAME_MSG_REQUEST_NEW_TOKEN");
18029
18050
  this.handleTokenRefreshRequest(message).catch((error) => {
18030
18051
  this.log("[IframeManager] \u274C Token refresh error:", error);
18031
18052
  });
@@ -18035,7 +18056,7 @@ var init_iframe_manager = __esm({
18035
18056
  const pending = this.pendingRequests.get(message.messageId);
18036
18057
  if (pending) {
18037
18058
  this.pendingRequests.delete(message.messageId);
18038
- if (message.type === "LUMIA_PASSPORT_ERROR") {
18059
+ if (message.type === "IFRAME_MSG_ERROR") {
18039
18060
  const passportError = createAccountAbstractionError({
18040
18061
  message: message.error || "Unknown error",
18041
18062
  code: message.code
@@ -18060,7 +18081,7 @@ var init_iframe_manager = __esm({
18060
18081
  const iframeOrigin = new URL(this.iframeUrl).origin;
18061
18082
  this.iframe.contentWindow.postMessage(
18062
18083
  {
18063
- type: "LUMIA_PASSPORT_TOKEN_REFRESHED",
18084
+ type: "IFRAME_MSG_TOKEN_REFRESHED",
18064
18085
  messageId: message.messageId,
18065
18086
  accessToken: newAccessToken,
18066
18087
  timestamp: Date.now()
@@ -18073,7 +18094,7 @@ var init_iframe_manager = __esm({
18073
18094
  const iframeOrigin = new URL(this.iframeUrl).origin;
18074
18095
  this.iframe.contentWindow.postMessage(
18075
18096
  {
18076
- type: "LUMIA_PASSPORT_TOKEN_REFRESHED",
18097
+ type: "IFRAME_MSG_TOKEN_REFRESHED",
18077
18098
  messageId: message.messageId,
18078
18099
  error: "Token refresh failed",
18079
18100
  timestamp: Date.now()
@@ -18087,7 +18108,7 @@ var init_iframe_manager = __esm({
18087
18108
  const iframeOrigin = new URL(this.iframeUrl).origin;
18088
18109
  this.iframe.contentWindow.postMessage(
18089
18110
  {
18090
- type: "LUMIA_PASSPORT_TOKEN_REFRESHED",
18111
+ type: "IFRAME_MSG_TOKEN_REFRESHED",
18091
18112
  messageId: message.messageId,
18092
18113
  error: error instanceof Error ? error.message : "Unknown error",
18093
18114
  timestamp: Date.now()
@@ -18338,7 +18359,7 @@ var init_iframe_manager = __esm({
18338
18359
  avatar,
18339
18360
  displayName
18340
18361
  });
18341
- if (response.type === "LUMIA_PASSPORT_AUTH_SUCCESS") {
18362
+ if (response.type === "IFRAME_MSG_AUTH_SUCCESS") {
18342
18363
  return {
18343
18364
  userId: response.userId,
18344
18365
  address: response.address
@@ -18356,7 +18377,7 @@ var init_iframe_manager = __esm({
18356
18377
  accessToken
18357
18378
  // Pass access token for TSS API authentication
18358
18379
  });
18359
- if (response.type === "LUMIA_PASSPORT_DKG_SUCCESS") {
18380
+ if (response.type === "IFRAME_MSG_DKG_SUCCESS") {
18360
18381
  return response.ownerAddress;
18361
18382
  }
18362
18383
  throw new Error("DKG failed");
@@ -18379,7 +18400,7 @@ var init_iframe_manager = __esm({
18379
18400
  avatar,
18380
18401
  displayName
18381
18402
  });
18382
- if (response.type === "LUMIA_PASSPORT_SIGNATURE") {
18403
+ if (response.type === "IFRAME_MSG_SIGNATURE") {
18383
18404
  return response.signature;
18384
18405
  }
18385
18406
  throw new Error("Transaction signing failed");
@@ -18412,7 +18433,7 @@ var init_iframe_manager = __esm({
18412
18433
  type: response.type,
18413
18434
  hasSignature: !!response.signature
18414
18435
  });
18415
- if (response.type === "LUMIA_PASSPORT_EIP712_SIGNATURE") {
18436
+ if (response.type === "IFRAME_MSG_EIP712_SIGNATURE") {
18416
18437
  return response.signature;
18417
18438
  }
18418
18439
  throw new Error("EIP712 signing failed");
@@ -18424,7 +18445,7 @@ var init_iframe_manager = __esm({
18424
18445
  const response = await this.sendMessage("GET_ADDRESS", {
18425
18446
  userId
18426
18447
  });
18427
- if (response.type === "LUMIA_PASSPORT_ADDRESS") {
18448
+ if (response.type === "IFRAME_MSG_ADDRESS") {
18428
18449
  return response.address;
18429
18450
  }
18430
18451
  return void 0;
@@ -18436,7 +18457,7 @@ var init_iframe_manager = __esm({
18436
18457
  const response = await this.sendMessage("CHECK_KEYSHARE", {
18437
18458
  userId
18438
18459
  });
18439
- if (response.type === "LUMIA_PASSPORT_KEYSHARE_STATUS") {
18460
+ if (response.type === "IFRAME_MSG_KEYSHARE_STATUS") {
18440
18461
  return {
18441
18462
  hasKeyshare: response.hasKeyshare,
18442
18463
  address: response.address
@@ -18832,7 +18853,7 @@ var init_iframe_manager = __esm({
18832
18853
  const response = await this.sendMessage("GET_TRUSTED_APPS", {
18833
18854
  userId
18834
18855
  });
18835
- if (response.type === "LUMIA_PASSPORT_TRUSTED_APPS_LIST") {
18856
+ if (response.type === "IFRAME_MSG_TRUSTED_APPS_LIST") {
18836
18857
  return response.apps || [];
18837
18858
  }
18838
18859
  return [];
@@ -18846,7 +18867,7 @@ var init_iframe_manager = __esm({
18846
18867
  projectId,
18847
18868
  appOrigin: origin
18848
18869
  });
18849
- if (response.type === "LUMIA_PASSPORT_TRUSTED_APP_REMOVED") {
18870
+ if (response.type === "IFRAME_MSG_TRUSTED_APP_REMOVED") {
18850
18871
  return response.success;
18851
18872
  }
18852
18873
  return false;
@@ -18877,7 +18898,7 @@ var init_iframe_manager = __esm({
18877
18898
  accessToken
18878
18899
  // Pass access token for TSS API authentication
18879
18900
  });
18880
- if (response.type === "LUMIA_PASSPORT_BACKUP_CREATED") {
18901
+ if (response.type === "IFRAME_MSG_BACKUP_CREATED") {
18881
18902
  return response.result;
18882
18903
  }
18883
18904
  throw new Error("Unexpected response type");
@@ -18892,7 +18913,7 @@ var init_iframe_manager = __esm({
18892
18913
  accessToken
18893
18914
  // Pass access token for TSS API authentication
18894
18915
  });
18895
- if (response.type === "LUMIA_PASSPORT_BACKUP_RESTORED") {
18916
+ if (response.type === "IFRAME_MSG_BACKUP_RESTORED") {
18896
18917
  return response.result;
18897
18918
  }
18898
18919
  throw new Error("Unexpected response type");
@@ -18906,7 +18927,7 @@ var init_iframe_manager = __esm({
18906
18927
  userId,
18907
18928
  password
18908
18929
  });
18909
- if (response.type === "LUMIA_PASSPORT_BACKUP_ENCRYPTED") {
18930
+ if (response.type === "IFRAME_MSG_BACKUP_ENCRYPTED") {
18910
18931
  return response.encryptedData;
18911
18932
  }
18912
18933
  throw new Error("Unexpected response type");
@@ -18920,7 +18941,7 @@ var init_iframe_manager = __esm({
18920
18941
  fileContent,
18921
18942
  password
18922
18943
  });
18923
- if (response.type === "LUMIA_PASSPORT_FILE_RESTORED") {
18944
+ if (response.type === "IFRAME_MSG_FILE_RESTORED") {
18924
18945
  return response.result;
18925
18946
  }
18926
18947
  throw new Error("Unexpected response type");
@@ -18932,7 +18953,7 @@ var init_iframe_manager = __esm({
18932
18953
  const response = await this.sendMessage("GET_BACKUP_STATUS", {
18933
18954
  userId
18934
18955
  });
18935
- if (response.type === "LUMIA_PASSPORT_BACKUP_STATUS") {
18956
+ if (response.type === "IFRAME_MSG_BACKUP_STATUS") {
18936
18957
  return response.status;
18937
18958
  }
18938
18959
  throw new Error("Unexpected response type");
@@ -18942,7 +18963,7 @@ var init_iframe_manager = __esm({
18942
18963
  */
18943
18964
  async getCloudProviders() {
18944
18965
  const response = await this.sendMessage("GET_CLOUD_PROVIDERS", {});
18945
- if (response.type === "LUMIA_PASSPORT_CLOUD_PROVIDERS") {
18966
+ if (response.type === "IFRAME_MSG_CLOUD_PROVIDERS") {
18946
18967
  return response.providers;
18947
18968
  }
18948
18969
  throw new Error("Unexpected response type");