@lumiapassport/ui-kit 1.14.13 → 1.14.15

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.14.13</title>
18
+ <title>Lumia Passport Secure Wallet - iframe version 1.14.15</title>
19
19
 
20
20
  <!-- Styles will be injected by build process -->
21
21
  <style>
@@ -1476,6 +1476,13 @@ var AuthorizationManager = class {
1476
1476
  this.metadataCache = /* @__PURE__ */ new Map();
1477
1477
  console.log("[iframe][Auth] Initialized");
1478
1478
  }
1479
+ /**
1480
+ * Check if project is a trusted authorized app (auto-skip auth dialog)
1481
+ */
1482
+ async isTrustedAuthorizedApp(projectId) {
1483
+ const metadata = await this.fetchProjectMetadata(projectId);
1484
+ return metadata?.trustedAuthorizedApp === true;
1485
+ }
1479
1486
  /**
1480
1487
  * Fetch project metadata from public API (with caching)
1481
1488
  */
@@ -3135,6 +3142,30 @@ var RampnowOnrampAPI = class {
3135
3142
  }
3136
3143
  };
3137
3144
 
3145
+ // src/lib/errors.ts
3146
+ var LumiaPassportError = class extends Error {
3147
+ constructor(message, code) {
3148
+ super(message);
3149
+ this.code = code;
3150
+ this.name = "LumiaPassportError";
3151
+ if (Error.captureStackTrace) {
3152
+ Error.captureStackTrace(this, this.constructor);
3153
+ }
3154
+ }
3155
+ };
3156
+ var _UserRejectedError = class _UserRejectedError extends LumiaPassportError {
3157
+ constructor(message = "User rejected transaction") {
3158
+ super(message, _UserRejectedError.CODE);
3159
+ this.name = "UserRejectedError";
3160
+ }
3161
+ };
3162
+ _UserRejectedError.CODE = "USER_REJECTED";
3163
+ var UserRejectedError = _UserRejectedError;
3164
+ var ErrorCodes = {
3165
+ MPC_SIGNING_ERROR: "MPC_SIGNING_ERROR",
3166
+ USER_REJECTED: UserRejectedError.CODE
3167
+ };
3168
+
3138
3169
  // src/iframe/lib/secure-messenger.ts
3139
3170
  var SecureMessenger = class {
3140
3171
  constructor() {
@@ -3256,14 +3287,19 @@ var SecureMessenger = class {
3256
3287
  console.error("[iframe][Messenger] No parent window");
3257
3288
  return;
3258
3289
  }
3290
+ const errorMessage = error instanceof Error ? error.message : error;
3291
+ const errorCode = error instanceof LumiaPassportError ? error.code : void 0;
3259
3292
  const response = {
3260
3293
  type: "LUMIA_PASSPORT_ERROR",
3261
3294
  messageId,
3262
3295
  timestamp: Date.now(),
3263
- error
3296
+ error: errorMessage,
3297
+ code: errorCode
3264
3298
  };
3265
3299
  window.parent.postMessage(response, targetOrigin);
3266
- console.log(`[iframe][Messenger] Sent error to ${targetOrigin}: ${error}`);
3300
+ console.log(
3301
+ `[iframe][Messenger] Sent error to ${targetOrigin}: ${errorMessage}${errorCode ? ` [${errorCode}]` : ""}`
3302
+ );
3267
3303
  }
3268
3304
  /**
3269
3305
  * Add allowed origin
@@ -3866,7 +3902,7 @@ var SigningManager = class extends TokenRefreshApiClient {
3866
3902
  userProfile
3867
3903
  );
3868
3904
  if (!confirmResult.confirmed) {
3869
- throw new Error("User rejected transaction");
3905
+ throw new UserRejectedError("User rejected transaction");
3870
3906
  }
3871
3907
  if (confirmResult.trustApp) {
3872
3908
  this.trustedApps.addTrustedApp(userId, projectId, origin, confirmResult.appName, confirmResult.appLogo);
@@ -4114,7 +4150,7 @@ var SigningManager = class extends TokenRefreshApiClient {
4114
4150
  userProfile
4115
4151
  );
4116
4152
  if (!confirmResult.confirmed) {
4117
- throw new Error("User rejected signature request");
4153
+ throw new UserRejectedError("User rejected signature request");
4118
4154
  }
4119
4155
  if (confirmResult.trustApp) {
4120
4156
  this.trustedApps.addTrustedApp(userId, projectId, origin, confirmResult.appName, confirmResult.appLogo);
@@ -4192,7 +4228,7 @@ var SigningManager = class extends TokenRefreshApiClient {
4192
4228
  };
4193
4229
 
4194
4230
  // src/iframe/main.ts
4195
- var IFRAME_VERSION = "1.14.13";
4231
+ var IFRAME_VERSION = "1.14.15";
4196
4232
  var IframeWallet = class {
4197
4233
  constructor() {
4198
4234
  console.log("=".repeat(60));
@@ -4292,7 +4328,7 @@ var IframeWallet = class {
4292
4328
  }
4293
4329
  } catch (error) {
4294
4330
  console.error(`[iframe] \u274C Error handling ${type}:`, error);
4295
- this.messenger.sendError(messageId, error instanceof Error ? error.message : "Unknown error", origin);
4331
+ this.messenger.sendError(messageId, error instanceof Error ? error : new Error("Unknown error"), origin);
4296
4332
  }
4297
4333
  }
4298
4334
  async handleSDKAuth(message, origin) {
@@ -4326,20 +4362,27 @@ var IframeWallet = class {
4326
4362
  console.log(`[iframe] AUTHENTICATE: userId=${userId}, projectId=${projectId}`);
4327
4363
  const isAuthorized = await this.authManager.checkAuthorization(userId, projectId);
4328
4364
  if (!isAuthorized) {
4329
- console.log(`[iframe] Authorization needed for project: ${projectId}`);
4330
- const projectInfo = {
4331
- id: projectId,
4332
- name: "Application",
4333
- logoUrl: "",
4334
- website: origin,
4335
- domains: [origin]
4336
- };
4337
- const consent = await this.authManager.requestAuthorization(projectInfo, origin, { avatar, displayName });
4338
- if (!consent) {
4339
- throw new Error("User denied authorization");
4365
+ const isTrustedApp = await this.authManager.isTrustedAuthorizedApp(projectId);
4366
+ if (isTrustedApp) {
4367
+ console.log(`[iframe] Project ${projectId} is a trusted authorized app, auto-authorizing`);
4368
+ await this.authManager.storeAuthorization(userId, projectId, origin);
4369
+ console.log(`[iframe] \u2705 Auto-authorization granted for trusted app: ${userId} -> ${projectId}`);
4370
+ } else {
4371
+ console.log(`[iframe] Authorization needed for project: ${projectId}`);
4372
+ const projectInfo = {
4373
+ id: projectId,
4374
+ name: "Application",
4375
+ logoUrl: "",
4376
+ website: origin,
4377
+ domains: [origin]
4378
+ };
4379
+ const consent = await this.authManager.requestAuthorization(projectInfo, origin, { avatar, displayName });
4380
+ if (!consent) {
4381
+ throw new Error("User denied authorization");
4382
+ }
4383
+ await this.authManager.storeAuthorization(userId, projectId, origin);
4384
+ console.log(`[iframe] \u2705 Authorization granted: ${userId} -> ${projectId}`);
4340
4385
  }
4341
- await this.authManager.storeAuthorization(userId, projectId, origin);
4342
- console.log(`[iframe] \u2705 Authorization granted: ${userId} -> ${projectId}`);
4343
4386
  }
4344
4387
  const address = this.storage.getOwnerAddress(userId);
4345
4388
  this.messenger.sendResponse(