@embarkai/ui-kit 0.1.3 → 0.1.5

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.
@@ -387,12 +387,7 @@ async function backupToLocalFile(data, password) {
387
387
  encryptionPassword = result.password;
388
388
  credentialId = result.credentialId;
389
389
  }
390
- const encrypted = await encryptKeyshare(
391
- data,
392
- encryptionPassword,
393
- password ? "password" : "passkey",
394
- credentialId
395
- );
390
+ const encrypted = await encryptKeyshare(data, encryptionPassword, password ? "password" : "passkey", credentialId);
396
391
  const backupData = {
397
392
  ...encrypted,
398
393
  userId: data.userId,
@@ -404,7 +399,7 @@ async function backupToLocalFile(data, password) {
404
399
  const url = URL.createObjectURL(blob);
405
400
  const a = document.createElement("a");
406
401
  a.href = url;
407
- a.download = `lumia-passport-backup-${data.userId}-${Date.now()}.json`;
402
+ a.download = `embarkai-backup-${data.userId}-${Date.now()}.json`;
408
403
  document.body.appendChild(a);
409
404
  a.click();
410
405
  document.body.removeChild(a);
@@ -419,13 +414,8 @@ async function restoreFromLocalFile(fileContent, userId, password) {
419
414
  decryptionPassword = password;
420
415
  } else {
421
416
  const credentialIdFromBackup = encryptedBackup.encryptionMethod === "passkey" ? encryptedBackup.credentialId : void 0;
422
- const result = await deriveBackupPasswordFromPasskey(
423
- userId,
424
- credentialIdFromBackup
425
- ).catch(() => {
426
- throw new Error(
427
- "Restore requires either password or passkey authentication"
428
- );
417
+ const result = await deriveBackupPasswordFromPasskey(userId, credentialIdFromBackup).catch(() => {
418
+ throw new Error("Restore requires either password or passkey authentication");
429
419
  });
430
420
  decryptionPassword = result.password;
431
421
  credentialId = result.credentialId;
@@ -1705,7 +1695,7 @@ var AuthorizationManager = class {
1705
1695
  */
1706
1696
  showIframe() {
1707
1697
  if (window.parent !== window) {
1708
- window.parent.postMessage({ type: "LUMIA_PASSPORT_SHOW_IFRAME", timestamp: Date.now() }, "*");
1698
+ window.parent.postMessage({ type: "IFRAME_MSG_SHOW_IFRAME", timestamp: Date.now() }, "*");
1709
1699
  console.log("[iframe][Auth] Requested parent to show iframe");
1710
1700
  }
1711
1701
  }
@@ -1714,7 +1704,7 @@ var AuthorizationManager = class {
1714
1704
  */
1715
1705
  hideIframe() {
1716
1706
  if (window.parent !== window) {
1717
- window.parent.postMessage({ type: "LUMIA_PASSPORT_HIDE_IFRAME", timestamp: Date.now() }, "*");
1707
+ window.parent.postMessage({ type: "IFRAME_MSG_HIDE_IFRAME", timestamp: Date.now() }, "*");
1718
1708
  console.log("[iframe][Auth] Requested parent to hide iframe");
1719
1709
  }
1720
1710
  }
@@ -1779,9 +1769,6 @@ var LOOCAL_BACKUP_STATUS_KEY = "passport-backup-status";
1779
1769
  var BLOCKSCOUT_QUERY_STALE_TIME = 30 * 1e3;
1780
1770
  var BLOCKSCOUT_QUERY_GC_TIME = 5 * 60 * 1e3;
1781
1771
 
1782
- // src/iframe/lib/backup/cloud-backup.ts
1783
- init_crypto_utils();
1784
-
1785
1772
  // src/iframe/lib/backup/cloudStorage.ts
1786
1773
  var GoogleDriveProvider = class {
1787
1774
  constructor() {
@@ -1992,6 +1979,7 @@ function getAvailableCloudProviders() {
1992
1979
  }
1993
1980
 
1994
1981
  // src/iframe/lib/backup/cloud-backup.ts
1982
+ init_crypto_utils();
1995
1983
  async function backupToCloud(data, providerId, password) {
1996
1984
  const encryptionMethod = password ? "password" : "passkey";
1997
1985
  let backupPassword;
@@ -2008,19 +1996,15 @@ async function backupToCloud(data, providerId, password) {
2008
1996
  }
2009
1997
  const encryptedBackup = await encryptKeyshare(data, backupPassword, encryptionMethod, credentialId);
2010
1998
  const timestamp = Date.now();
2011
- const fileName = `lumia-keyshare-backup-${data.userId}-${timestamp}.json`;
1999
+ const fileName = `embark-keyshare-backup-${data.userId}-${timestamp}.json`;
2012
2000
  const fileContent = JSON.stringify(encryptedBackup, null, 2);
2013
2001
  const providers = getAvailableCloudProviders();
2014
2002
  if (providers.length === 0) {
2015
- throw new Error(
2016
- "No cloud storage providers available in this environment"
2017
- );
2003
+ throw new Error("No cloud storage providers available in this environment");
2018
2004
  }
2019
2005
  const provider = providerId ? providers.find((p) => p.id === providerId) : providers[0];
2020
2006
  if (!provider) {
2021
- throw new Error(
2022
- providerId ? `Cloud provider '${providerId}' not available` : "No cloud storage provider available"
2023
- );
2007
+ throw new Error(providerId ? `Cloud provider '${providerId}' not available` : "No cloud storage provider available");
2024
2008
  }
2025
2009
  console.info(`[BACKUP] Using ${provider.name} for cloud backup`);
2026
2010
  if (!provider.isAuthenticated()) {
@@ -2132,7 +2116,7 @@ var TokenRefreshApiClient = class {
2132
2116
  }, 3e4);
2133
2117
  const messageHandler = (event) => {
2134
2118
  const message = event.data;
2135
- if (message && message.type === "LUMIA_PASSPORT_TOKEN_REFRESHED" && message.messageId === messageId) {
2119
+ if (message && message.type === "IFRAME_MSG_TOKEN_REFRESHED" && message.messageId === messageId) {
2136
2120
  cleanup();
2137
2121
  if (message.accessToken) {
2138
2122
  console.log("[iframe][TokenRefresh] \u2705 Received new token from parent");
@@ -2154,14 +2138,14 @@ var TokenRefreshApiClient = class {
2154
2138
  if (window.parent && window.parent !== window) {
2155
2139
  window.parent.postMessage(
2156
2140
  {
2157
- type: "LUMIA_PASSPORT_REQUEST_NEW_TOKEN",
2141
+ type: "IFRAME_MSG_REQUEST_NEW_TOKEN",
2158
2142
  messageId,
2159
2143
  timestamp: Date.now()
2160
2144
  },
2161
2145
  "*"
2162
2146
  // Parent will validate origin
2163
2147
  );
2164
- console.log("[iframe][TokenRefresh] \u{1F4E4} Sent LUMIA_PASSPORT_REQUEST_NEW_TOKEN to parent");
2148
+ console.log("[iframe][TokenRefresh] \u{1F4E4} Sent IFRAME_MSG_REQUEST_NEW_TOKEN to parent");
2165
2149
  } else {
2166
2150
  cleanup();
2167
2151
  reject(new Error("No parent window available"));
@@ -3498,9 +3482,9 @@ var SecureMessenger = class {
3498
3482
  }
3499
3483
  return;
3500
3484
  }
3501
- if (!this.isLumiaMessage(message)) {
3485
+ if (!this.validateMessageType(message)) {
3502
3486
  if (this.DEBUG_FILTERED_MESSAGES) {
3503
- console.debug("[iframe][Messenger] Filtered: not Lumia message", {
3487
+ console.debug("[iframe][Messenger] Filtered: not EmbarkAI message", {
3504
3488
  type: message.type,
3505
3489
  origin
3506
3490
  });
@@ -3561,7 +3545,7 @@ var SecureMessenger = class {
3561
3545
  return;
3562
3546
  }
3563
3547
  const response = {
3564
- type: "LUMIA_PASSPORT_RESPONSE",
3548
+ type: "IFRAME_MSG_RESPONSE",
3565
3549
  messageId,
3566
3550
  timestamp: Date.now(),
3567
3551
  data
@@ -3580,7 +3564,7 @@ var SecureMessenger = class {
3580
3564
  const errorMessage = error instanceof Error ? error.message : error;
3581
3565
  const errorCode = error instanceof AccountAbstractionError ? error.code : void 0;
3582
3566
  const response = {
3583
- type: "LUMIA_PASSPORT_ERROR",
3567
+ type: "IFRAME_MSG_ERROR",
3584
3568
  messageId,
3585
3569
  timestamp: Date.now(),
3586
3570
  error: errorMessage,
@@ -3623,7 +3607,7 @@ var SecureMessenger = class {
3623
3607
  * Quick check if message looks like EmbarkAI protocol
3624
3608
  * This filters out browser extension messages, dev tools, etc.
3625
3609
  */
3626
- isLumiaMessage(message) {
3610
+ validateMessageType(message) {
3627
3611
  const validTypes = [
3628
3612
  "SDK_AUTH",
3629
3613
  "SDK_CHANNEL_HEARTBEAT",
@@ -3745,9 +3729,12 @@ var StorageManager = class {
3745
3729
  saveKeyshare(userId, data) {
3746
3730
  try {
3747
3731
  const keyshareKey = `tss.${userId}.keyshare`;
3748
- this.storage.setItem(keyshareKey, JSON.stringify({
3749
- keyshare_b64: data.keyshare_b64
3750
- }));
3732
+ this.storage.setItem(
3733
+ keyshareKey,
3734
+ JSON.stringify({
3735
+ keyshare_b64: data.keyshare_b64
3736
+ })
3737
+ );
3751
3738
  this.storage.setItem(`tss.${userId}.ownerAddress`, data.ownerAddress);
3752
3739
  this.storage.setItem(`tss.${userId}.sessionId`, data.sessionId);
3753
3740
  console.log(`[iframe][Storage] \u2705 Saved keyshare for user: ${userId}`);
@@ -3858,7 +3845,7 @@ var StorageManager = class {
3858
3845
  };
3859
3846
 
3860
3847
  // src/iframe/lib/trusted-apps-manager.ts
3861
- var STORAGE_KEY2 = "passport-trusted-apps";
3848
+ var STORAGE_KEY2 = "lumia_passport_trusted_apps";
3862
3849
  var TrustedAppsManager = class {
3863
3850
  /**
3864
3851
  * Check if app is trusted by user
@@ -4217,7 +4204,15 @@ var SigningManager = class extends TokenRefreshApiClient {
4217
4204
  createConfirmationModal(userId, projectId, project, origin, transaction, risk, metadata, userProfile) {
4218
4205
  const modal = document.createElement("div");
4219
4206
  modal.className = "transaction-confirmation-modal";
4220
- const templateData = buildConfirmTxTemplateData(project, origin, transaction, risk, metadata, userProfile, this.explorerUrl);
4207
+ const templateData = buildConfirmTxTemplateData(
4208
+ project,
4209
+ origin,
4210
+ transaction,
4211
+ risk,
4212
+ metadata,
4213
+ userProfile,
4214
+ this.explorerUrl
4215
+ );
4221
4216
  const template = TemplateLoader.getTemplate("confirm-tx");
4222
4217
  modal.innerHTML = TemplateEngine.render(template, templateData);
4223
4218
  return modal;
@@ -4390,7 +4385,7 @@ var SigningManager = class extends TokenRefreshApiClient {
4390
4385
  */
4391
4386
  showIframe() {
4392
4387
  if (window.parent !== window) {
4393
- window.parent.postMessage({ type: "LUMIA_PASSPORT_SHOW_IFRAME", timestamp: Date.now() }, "*");
4388
+ window.parent.postMessage({ type: "IFRAME_MSG_SHOW_IFRAME", timestamp: Date.now() }, "*");
4394
4389
  }
4395
4390
  }
4396
4391
  /**
@@ -4398,13 +4393,13 @@ var SigningManager = class extends TokenRefreshApiClient {
4398
4393
  */
4399
4394
  hideIframe() {
4400
4395
  if (window.parent !== window) {
4401
- window.parent.postMessage({ type: "LUMIA_PASSPORT_HIDE_IFRAME", timestamp: Date.now() }, "*");
4396
+ window.parent.postMessage({ type: "IFRAME_MSG_HIDE_IFRAME", timestamp: Date.now() }, "*");
4402
4397
  }
4403
4398
  }
4404
4399
  };
4405
4400
 
4406
4401
  // src/iframe/main.ts
4407
- var IFRAME_VERSION = "0.1.3";
4402
+ var IFRAME_VERSION = "0.1.5";
4408
4403
  var IframeWallet = class {
4409
4404
  constructor() {
4410
4405
  console.log("=".repeat(60));
@@ -4434,7 +4429,7 @@ var IframeWallet = class {
4434
4429
  if (window.parent !== window) {
4435
4430
  window.parent.postMessage(
4436
4431
  {
4437
- type: "LUMIA_PASSPORT_IFRAME_READY",
4432
+ type: "IFRAME_MSG_IFRAME_READY",
4438
4433
  timestamp: Date.now()
4439
4434
  },
4440
4435
  "*"
@@ -4522,7 +4517,7 @@ var IframeWallet = class {
4522
4517
  this.messenger.sendResponse(
4523
4518
  messageId,
4524
4519
  {
4525
- type: "LUMIA_PASSPORT_HEARTBEAT_RESPONSE",
4520
+ type: "IFRAME_MSG_HEARTBEAT_RESPONSE",
4526
4521
  valid: isValid,
4527
4522
  channelsCount: stats.total
4528
4523
  },
@@ -4545,7 +4540,7 @@ var IframeWallet = class {
4545
4540
  this.messenger.sendResponse(
4546
4541
  messageId,
4547
4542
  {
4548
- type: "LUMIA_PASSPORT_SDK_AUTH_SUCCESS",
4543
+ type: "IFRAME_MSG_SDK_AUTH_SUCCESS",
4549
4544
  sessionToken
4550
4545
  },
4551
4546
  origin
@@ -4601,7 +4596,7 @@ var IframeWallet = class {
4601
4596
  this.messenger.sendResponse(
4602
4597
  messageId,
4603
4598
  {
4604
- type: "LUMIA_PASSPORT_AUTH_SUCCESS",
4599
+ type: "IFRAME_MSG_AUTH_SUCCESS",
4605
4600
  userId,
4606
4601
  address
4607
4602
  },
@@ -4638,7 +4633,7 @@ var IframeWallet = class {
4638
4633
  this.messenger.sendResponse(
4639
4634
  messageId,
4640
4635
  {
4641
- type: "LUMIA_PASSPORT_DKG_SUCCESS",
4636
+ type: "IFRAME_MSG_DKG_SUCCESS",
4642
4637
  ownerAddress: result.ownerAddress
4643
4638
  },
4644
4639
  origin
@@ -4669,7 +4664,7 @@ var IframeWallet = class {
4669
4664
  this.messenger.sendResponse(
4670
4665
  messageId,
4671
4666
  {
4672
- type: "LUMIA_PASSPORT_SIGNATURE",
4667
+ type: "IFRAME_MSG_SIGNATURE",
4673
4668
  signature
4674
4669
  },
4675
4670
  origin
@@ -4704,7 +4699,7 @@ var IframeWallet = class {
4704
4699
  this.messenger.sendResponse(
4705
4700
  messageId,
4706
4701
  {
4707
- type: "LUMIA_PASSPORT_EIP712_SIGNATURE",
4702
+ type: "IFRAME_MSG_EIP712_SIGNATURE",
4708
4703
  signature
4709
4704
  },
4710
4705
  origin
@@ -4725,7 +4720,7 @@ var IframeWallet = class {
4725
4720
  this.messenger.sendResponse(
4726
4721
  messageId,
4727
4722
  {
4728
- type: "LUMIA_PASSPORT_ADDRESS",
4723
+ type: "IFRAME_MSG_ADDRESS",
4729
4724
  address
4730
4725
  },
4731
4726
  origin
@@ -4742,7 +4737,7 @@ var IframeWallet = class {
4742
4737
  this.messenger.sendResponse(
4743
4738
  messageId,
4744
4739
  {
4745
- type: "LUMIA_PASSPORT_KEYSHARE_STATUS",
4740
+ type: "IFRAME_MSG_KEYSHARE_STATUS",
4746
4741
  hasKeyshare,
4747
4742
  address
4748
4743
  },
@@ -4761,7 +4756,7 @@ var IframeWallet = class {
4761
4756
  this.messenger.sendResponse(
4762
4757
  messageId,
4763
4758
  {
4764
- type: "LUMIA_PASSPORT_TRUSTED_APPS_LIST",
4759
+ type: "IFRAME_MSG_TRUSTED_APPS_LIST",
4765
4760
  apps: trustedApps
4766
4761
  },
4767
4762
  origin
@@ -4789,7 +4784,7 @@ var IframeWallet = class {
4789
4784
  this.messenger.sendResponse(
4790
4785
  messageId,
4791
4786
  {
4792
- type: "LUMIA_PASSPORT_TRUSTED_APP_REMOVED",
4787
+ type: "IFRAME_MSG_TRUSTED_APP_REMOVED",
4793
4788
  success: true
4794
4789
  },
4795
4790
  origin
@@ -4820,7 +4815,7 @@ var IframeWallet = class {
4820
4815
  this.messenger.sendResponse(
4821
4816
  messageId,
4822
4817
  {
4823
- type: "LUMIA_PASSPORT_AUTHORIZATIONS_CLEARED",
4818
+ type: "IFRAME_MSG_AUTHORIZATIONS_CLEARED",
4824
4819
  success: true,
4825
4820
  clearedCount
4826
4821
  },
@@ -4858,7 +4853,7 @@ var IframeWallet = class {
4858
4853
  this.messenger.sendResponse(
4859
4854
  messageId,
4860
4855
  {
4861
- type: "LUMIA_PASSPORT_BACKUP_CREATED",
4856
+ type: "IFRAME_MSG_BACKUP_CREATED",
4862
4857
  result
4863
4858
  },
4864
4859
  origin
@@ -4885,7 +4880,7 @@ var IframeWallet = class {
4885
4880
  this.messenger.sendResponse(
4886
4881
  messageId,
4887
4882
  {
4888
- type: "LUMIA_PASSPORT_BACKUP_STATUS",
4883
+ type: "IFRAME_MSG_BACKUP_STATUS",
4889
4884
  status
4890
4885
  },
4891
4886
  origin
@@ -4904,7 +4899,7 @@ var IframeWallet = class {
4904
4899
  this.messenger.sendResponse(
4905
4900
  messageId,
4906
4901
  {
4907
- type: "LUMIA_PASSPORT_CLOUD_PROVIDERS",
4902
+ type: "IFRAME_MSG_CLOUD_PROVIDERS",
4908
4903
  providers
4909
4904
  },
4910
4905
  origin
@@ -4936,7 +4931,7 @@ var IframeWallet = class {
4936
4931
  this.messenger.sendResponse(
4937
4932
  messageId,
4938
4933
  {
4939
- type: "LUMIA_PASSPORT_BACKUP_RESTORED",
4934
+ type: "IFRAME_MSG_BACKUP_RESTORED",
4940
4935
  result: {
4941
4936
  success: true,
4942
4937
  timestamp: Date.now(),
@@ -4952,7 +4947,7 @@ var IframeWallet = class {
4952
4947
  this.messenger.sendResponse(
4953
4948
  messageId,
4954
4949
  {
4955
- type: "LUMIA_PASSPORT_BACKUP_RESTORED",
4950
+ type: "IFRAME_MSG_BACKUP_RESTORED",
4956
4951
  result: {
4957
4952
  success: false,
4958
4953
  timestamp: Date.now(),
@@ -4994,7 +4989,7 @@ var IframeWallet = class {
4994
4989
  this.messenger.sendResponse(
4995
4990
  messageId,
4996
4991
  {
4997
- type: "LUMIA_PASSPORT_FILE_RESTORED",
4992
+ type: "IFRAME_MSG_FILE_RESTORED",
4998
4993
  result: {
4999
4994
  success: true,
5000
4995
  timestamp: Date.now(),
@@ -5010,7 +5005,7 @@ var IframeWallet = class {
5010
5005
  this.messenger.sendResponse(
5011
5006
  messageId,
5012
5007
  {
5013
- type: "LUMIA_PASSPORT_FILE_RESTORED",
5008
+ type: "IFRAME_MSG_FILE_RESTORED",
5014
5009
  result: {
5015
5010
  success: false,
5016
5011
  timestamp: Date.now(),
@@ -5046,7 +5041,7 @@ var IframeWallet = class {
5046
5041
  this.messenger.sendResponse(
5047
5042
  messageId,
5048
5043
  {
5049
- type: "LUMIA_PASSPORT_BACKUP_ENCRYPTED",
5044
+ type: "IFRAME_MSG_BACKUP_ENCRYPTED",
5050
5045
  encryptedData
5051
5046
  },
5052
5047
  origin
@@ -5089,7 +5084,7 @@ var IframeWallet = class {
5089
5084
  if (window.parent) {
5090
5085
  window.parent.postMessage(
5091
5086
  {
5092
- type: "LUMIA_PASSPORT_WALLET_READY",
5087
+ type: "IFRAME_MSG_WALLET_READY",
5093
5088
  data: status,
5094
5089
  timestamp: Date.now()
5095
5090
  },