@lumiapassport/ui-kit 1.10.1 → 1.11.0

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>Lumia Passport Secure Wallet - iframe version 1.10.1</title>
18
+ <title>Lumia Passport Secure Wallet - iframe version 1.11.0</title>
19
19
 
20
20
  <!-- Styles will be injected by build process -->
21
21
  <style>
@@ -156,6 +156,16 @@
156
156
  }
157
157
 
158
158
  /* Modal Overlays */
159
+ /* Authorization modal container */
160
+ .authorization-modal {
161
+ position: fixed;
162
+ top: 0;
163
+ left: 0;
164
+ right: 0;
165
+ bottom: 0;
166
+ z-index: 10000;
167
+ }
168
+
159
169
  /* Transaction confirmation modal container */
160
170
  .transaction-confirmation-modal {
161
171
  position: fixed;
@@ -232,6 +242,12 @@
232
242
  object-fit: contain;
233
243
  }
234
244
 
245
+ .lumia-logo.user-avatar {
246
+ border-radius: 50%;
247
+ border: 2px solid var(--iframe-border);
248
+ object-fit: cover;
249
+ }
250
+
235
251
  /* Authorization Title */
236
252
  .auth-title {
237
253
  font-size: 1.5rem;
@@ -2507,9 +2507,11 @@ var TrustedAppsManager = class {
2507
2507
  */
2508
2508
  isTrusted(userId, projectId, origin) {
2509
2509
  const trustedApps = this.getTrustedApps();
2510
- return trustedApps.some(
2510
+ const result = trustedApps.some(
2511
2511
  (app) => app.userId === userId && app.projectId === projectId && app.origin === origin
2512
2512
  );
2513
+ console.log("[TrustedApps] isTrusted check:", { userId, projectId, origin, result, totalApps: trustedApps.length });
2514
+ return result;
2513
2515
  }
2514
2516
  /**
2515
2517
  * Add app to trusted list
@@ -2549,8 +2551,12 @@ var TrustedAppsManager = class {
2549
2551
  * Get all trusted apps for a user
2550
2552
  */
2551
2553
  getTrustedAppsForUser(userId) {
2554
+ console.log("[TrustedApps] Getting trusted apps for user:", userId);
2552
2555
  const trustedApps = this.getTrustedApps();
2553
- return trustedApps.filter((app) => app.userId === userId);
2556
+ console.log("[TrustedApps] Total apps in storage:", trustedApps.length, trustedApps);
2557
+ const filtered = trustedApps.filter((app) => app.userId === userId);
2558
+ console.log("[TrustedApps] Filtered apps for user:", filtered.length, filtered);
2559
+ return filtered;
2554
2560
  }
2555
2561
  /**
2556
2562
  * Clear all trusted apps for a user
@@ -2568,10 +2574,13 @@ var TrustedAppsManager = class {
2568
2574
  getTrustedApps() {
2569
2575
  try {
2570
2576
  const data = localStorage.getItem(STORAGE_KEY);
2577
+ console.log("[TrustedApps] Raw storage data:", data);
2571
2578
  if (!data) {
2579
+ console.log("[TrustedApps] No data in storage");
2572
2580
  return [];
2573
2581
  }
2574
2582
  const apps = JSON.parse(data);
2583
+ console.log("[TrustedApps] Parsed apps:", apps);
2575
2584
  return Array.isArray(apps) ? apps : [];
2576
2585
  } catch (error) {
2577
2586
  console.error("[TrustedApps] Error reading trusted apps:", error);
@@ -2677,7 +2686,7 @@ var SigningManager = class extends TokenRefreshApiClient {
2677
2686
  /**
2678
2687
  * Sign transaction with user confirmation
2679
2688
  */
2680
- async signTransaction(userId, projectId, origin, transaction, accessToken) {
2689
+ async signTransaction(userId, projectId, origin, transaction, accessToken, userProfile) {
2681
2690
  if (!this.wasmLoaded) {
2682
2691
  await this.initialize();
2683
2692
  }
@@ -2702,7 +2711,8 @@ var SigningManager = class extends TokenRefreshApiClient {
2702
2711
  projectInfo,
2703
2712
  origin,
2704
2713
  transaction,
2705
- risk
2714
+ risk,
2715
+ userProfile
2706
2716
  );
2707
2717
  if (!confirmResult.confirmed) {
2708
2718
  throw new Error("User rejected transaction");
@@ -2782,11 +2792,11 @@ var SigningManager = class extends TokenRefreshApiClient {
2782
2792
  /**
2783
2793
  * Show transaction confirmation dialog
2784
2794
  */
2785
- async showConfirmationDialog(userId, projectId, project, origin, transaction, risk) {
2795
+ async showConfirmationDialog(userId, projectId, project, origin, transaction, risk, userProfile) {
2786
2796
  this.showIframe();
2787
2797
  const metadata = await this.fetchProjectMetadata(projectId);
2788
2798
  return new Promise((resolve) => {
2789
- const modal = this.createConfirmationModal(userId, projectId, project, origin, transaction, risk, metadata);
2799
+ const modal = this.createConfirmationModal(userId, projectId, project, origin, transaction, risk, metadata, userProfile);
2790
2800
  const confirmBtn = modal.querySelector(".confirm-btn");
2791
2801
  const cancelBtn = modal.querySelector(".cancel-btn");
2792
2802
  const trustCheckbox = modal.querySelector(".trust-app-checkbox");
@@ -2809,11 +2819,13 @@ var SigningManager = class extends TokenRefreshApiClient {
2809
2819
  /**
2810
2820
  * Create confirmation modal UI
2811
2821
  */
2812
- createConfirmationModal(userId, projectId, project, origin, transaction, risk, metadata) {
2822
+ createConfirmationModal(userId, projectId, project, origin, transaction, risk, metadata, userProfile) {
2813
2823
  const modal = document.createElement("div");
2814
2824
  modal.className = "transaction-confirmation-modal";
2815
2825
  const isVerifiedOrigin = project.domains.includes(origin);
2816
2826
  const isUserOp = !!transaction.userOpDetails;
2827
+ const userAvatar = userProfile?.avatar;
2828
+ const userName = userProfile?.displayName || "Lumia Passport";
2817
2829
  const isSponsored = isUserOp && !!transaction.userOpDetails?.paymaster;
2818
2830
  const estimatedCost = isSponsored ? "0 (Sponsored)" : "Free (Sponsored Transaction)";
2819
2831
  const displayName = metadata?.name || project.name;
@@ -2849,7 +2861,7 @@ var SigningManager = class extends TokenRefreshApiClient {
2849
2861
  <path d="M23.7071 8.70711C24.0976 8.31658 24.0976 7.68342 23.7071 7.29289L17.3431 0.928932C16.9526 0.538408 16.3195 0.538408 15.9289 0.928932C15.5384 1.31946 15.5384 1.95262 15.9289 2.34315L21.5858 8L15.9289 13.6569C15.5384 14.0474 15.5384 14.6805 15.9289 15.0711C16.3195 15.4616 16.9526 15.4616 17.3431 15.0711L23.7071 8.70711ZM0 9H23V7H0V9Z"/>
2850
2862
  </svg>
2851
2863
  </div>
2852
- <img src="./lumia-logo.svg" alt="Lumia Passport" class="lumia-logo" />
2864
+ ${userAvatar ? `<img src="${userAvatar}" alt="${userName}" class="lumia-logo user-avatar" />` : '<img src="./lumia-logo.svg" alt="Lumia Passport" class="lumia-logo" />'}
2853
2865
  </div>
2854
2866
  </div>
2855
2867
 
@@ -3018,7 +3030,7 @@ var SigningManager = class extends TokenRefreshApiClient {
3018
3030
  /**
3019
3031
  * Sign EIP712 typed data with user confirmation
3020
3032
  */
3021
- async signTypedData(userId, projectId, origin, typedData, digest32, accessToken) {
3033
+ async signTypedData(userId, projectId, origin, typedData, digest32, accessToken, userProfile) {
3022
3034
  console.log("[iframe][Sign] EIP712 signing request:", { userId, projectId, origin, primaryType: typedData.primaryType });
3023
3035
  await this.initialize();
3024
3036
  const projectInfo = {
@@ -3035,7 +3047,8 @@ var SigningManager = class extends TokenRefreshApiClient {
3035
3047
  projectId,
3036
3048
  projectInfo,
3037
3049
  origin,
3038
- typedData
3050
+ typedData,
3051
+ userProfile
3039
3052
  );
3040
3053
  if (!confirmResult.confirmed) {
3041
3054
  throw new Error("User rejected signature request");
@@ -3055,11 +3068,11 @@ var SigningManager = class extends TokenRefreshApiClient {
3055
3068
  /**
3056
3069
  * Show EIP712 confirmation dialog
3057
3070
  */
3058
- async showEIP712ConfirmationDialog(userId, projectId, project, origin, typedData) {
3071
+ async showEIP712ConfirmationDialog(userId, projectId, project, origin, typedData, userProfile) {
3059
3072
  this.showIframe();
3060
3073
  const metadata = await this.fetchProjectMetadata(projectId);
3061
3074
  return new Promise((resolve) => {
3062
- const modal = this.createEIP712ConfirmationModal(userId, projectId, project, origin, typedData, metadata);
3075
+ const modal = this.createEIP712ConfirmationModal(userId, projectId, project, origin, typedData, metadata, userProfile);
3063
3076
  const confirmBtn = modal.querySelector(".confirm-btn");
3064
3077
  const cancelBtn = modal.querySelector(".cancel-btn");
3065
3078
  const trustCheckbox = modal.querySelector(".trust-app-checkbox");
@@ -3082,10 +3095,12 @@ var SigningManager = class extends TokenRefreshApiClient {
3082
3095
  /**
3083
3096
  * Create EIP712 confirmation modal UI (similar to MetaMask)
3084
3097
  */
3085
- createEIP712ConfirmationModal(userId, projectId, project, origin, typedData, metadata) {
3098
+ createEIP712ConfirmationModal(userId, projectId, project, origin, typedData, metadata, userProfile) {
3086
3099
  const modal = document.createElement("div");
3087
3100
  modal.className = "eip712-confirmation-modal";
3088
3101
  const isVerifiedOrigin = project.domains.includes(origin);
3102
+ const userAvatar = userProfile?.avatar;
3103
+ const userName = userProfile?.displayName || "Lumia Passport";
3089
3104
  const formatFieldValue = (value) => {
3090
3105
  if (Array.isArray(value)) {
3091
3106
  return `[${value.map((v) => formatFieldValue(v)).join(", ")}]`;
@@ -3118,7 +3133,7 @@ var SigningManager = class extends TokenRefreshApiClient {
3118
3133
  <div class="logo-container">
3119
3134
  ${metadata?.logo ? `<img src="${metadata.logo}" alt="${metadata.name}" class="project-logo" />` : '<div class="project-logo-placeholder">\u{1F510}</div>'}
3120
3135
  <span class="arrow-icon">\u2192</span>
3121
- <div class="lumia-logo">L</div>
3136
+ ${userAvatar ? `<img src="${userAvatar}" alt="${userName}" class="lumia-logo user-avatar" style="width: 40px; height: 40px;" />` : '<div class="lumia-logo">L</div>'}
3122
3137
  </div>
3123
3138
  <h2 class="modal-title">Signature Request</h2>
3124
3139
  <p class="origin-text">
@@ -3292,11 +3307,11 @@ var AuthorizationManager = class {
3292
3307
  /**
3293
3308
  * Request user authorization with consent screen
3294
3309
  */
3295
- async requestAuthorization(project, origin) {
3310
+ async requestAuthorization(project, origin, userProfile) {
3296
3311
  this.showIframe();
3297
3312
  const metadata = await this.fetchProjectMetadata(project.id);
3298
3313
  return new Promise((resolve) => {
3299
- const modal = this.createAuthorizationModal(project, origin, metadata);
3314
+ const modal = this.createAuthorizationModal(project, origin, metadata, userProfile);
3300
3315
  const authorizeBtn = modal.querySelector(".authorize-btn");
3301
3316
  const cancelBtn = modal.querySelector(".cancel-btn");
3302
3317
  const cleanup = (result) => {
@@ -3344,13 +3359,15 @@ var AuthorizationManager = class {
3344
3359
  /**
3345
3360
  * Create authorization consent modal
3346
3361
  */
3347
- createAuthorizationModal(project, origin, metadata) {
3362
+ createAuthorizationModal(project, origin, metadata, userProfile) {
3348
3363
  const modal = document.createElement("div");
3349
3364
  modal.className = "authorization-modal";
3350
3365
  const isVerifiedOrigin = project.domains.includes(origin);
3351
3366
  const displayName = metadata?.name || project.name;
3352
3367
  const displayLogo = metadata?.logo || project.logoUrl;
3353
3368
  const displayDescription = metadata?.description;
3369
+ const userAvatar = userProfile?.avatar;
3370
+ const userName = userProfile?.displayName || "Lumia Passport";
3354
3371
  modal.innerHTML = `
3355
3372
  <div class="modal-overlay">
3356
3373
  <div class="modal-content">
@@ -3363,7 +3380,7 @@ var AuthorizationManager = class {
3363
3380
  <path d="M23.7071 8.70711C24.0976 8.31658 24.0976 7.68342 23.7071 7.29289L17.3431 0.928932C16.9526 0.538408 16.3195 0.538408 15.9289 0.928932C15.5384 1.31946 15.5384 1.95262 15.9289 2.34315L21.5858 8L15.9289 13.6569C15.5384 14.0474 15.5384 14.6805 15.9289 15.0711C16.3195 15.4616 16.9526 15.4616 17.3431 15.0711L23.7071 8.70711ZM0 9H23V7H0V9Z"/>
3364
3381
  </svg>
3365
3382
  </div>
3366
- <img src="./lumia-logo.svg" alt="Lumia Passport" class="lumia-logo" />
3383
+ ${userAvatar ? `<img src="${userAvatar}" alt="${userName}" class="lumia-logo user-avatar" />` : '<img src="./lumia-logo.svg" alt="Lumia Passport" class="lumia-logo" />'}
3367
3384
  </div>
3368
3385
  </div>
3369
3386
 
@@ -3947,7 +3964,7 @@ var BackupManager = class {
3947
3964
  };
3948
3965
 
3949
3966
  // src/iframe/main.ts
3950
- var IFRAME_VERSION = "1.10.1";
3967
+ var IFRAME_VERSION = "1.11.0";
3951
3968
  var IframeWallet = class {
3952
3969
  constructor() {
3953
3970
  console.log("=".repeat(60));
@@ -4098,7 +4115,7 @@ var IframeWallet = class {
4098
4115
  console.log(`[iframe] \u2705 SDK authenticated for origin: ${origin.substring(0, 40)}...`);
4099
4116
  }
4100
4117
  async handleAuthenticate(message, origin) {
4101
- const { sessionToken, projectId, userId } = message.data;
4118
+ const { sessionToken, projectId, userId, avatar, displayName } = message.data;
4102
4119
  const { messageId } = message;
4103
4120
  if (!this.sessionManager.validateSession(sessionToken, origin)) {
4104
4121
  throw new Error("Invalid session");
@@ -4114,7 +4131,7 @@ var IframeWallet = class {
4114
4131
  website: origin,
4115
4132
  domains: [origin]
4116
4133
  };
4117
- const consent = await this.authManager.requestAuthorization(projectInfo, origin);
4134
+ const consent = await this.authManager.requestAuthorization(projectInfo, origin, { avatar, displayName });
4118
4135
  if (!consent) {
4119
4136
  throw new Error("User denied authorization");
4120
4137
  }
@@ -4175,7 +4192,7 @@ var IframeWallet = class {
4175
4192
  }
4176
4193
  }
4177
4194
  async handleSignTransaction(message, origin) {
4178
- const { sessionToken, userId, projectId, transaction, accessToken } = message.data;
4195
+ const { sessionToken, userId, projectId, transaction, accessToken, avatar, displayName } = message.data;
4179
4196
  const { messageId } = message;
4180
4197
  if (!this.sessionManager.validateSession(sessionToken, origin)) {
4181
4198
  throw new Error("Invalid session");
@@ -4191,7 +4208,8 @@ var IframeWallet = class {
4191
4208
  projectId,
4192
4209
  origin,
4193
4210
  transaction,
4194
- accessToken
4211
+ accessToken,
4212
+ { avatar, displayName }
4195
4213
  );
4196
4214
  this.messenger.sendResponse(
4197
4215
  messageId,
@@ -4208,7 +4226,7 @@ var IframeWallet = class {
4208
4226
  }
4209
4227
  }
4210
4228
  async handleSignTypedData(message, origin) {
4211
- const { sessionToken, userId, projectId, typedData, digest32, accessToken } = message.data;
4229
+ const { sessionToken, userId, projectId, typedData, digest32, accessToken, avatar, displayName } = message.data;
4212
4230
  const { messageId } = message;
4213
4231
  if (!this.sessionManager.validateSession(sessionToken, origin)) {
4214
4232
  throw new Error("Invalid session");
@@ -4225,7 +4243,8 @@ var IframeWallet = class {
4225
4243
  origin,
4226
4244
  typedData,
4227
4245
  digest32,
4228
- accessToken
4246
+ accessToken,
4247
+ { avatar, displayName }
4229
4248
  );
4230
4249
  this.messenger.sendResponse(
4231
4250
  messageId,