@lumiapassport/ui-kit 1.15.13 → 1.16.1
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/iframe/index.html +1 -1
- package/dist/iframe/main.js +130 -102
- package/dist/iframe/main.js.map +1 -1
- package/dist/index.cjs +974 -873
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -3
- package/dist/index.d.ts +22 -3
- package/dist/index.js +1041 -940
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +2 -2
package/dist/iframe/index.html
CHANGED
|
@@ -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.
|
|
18
|
+
<title>Lumia Passport Secure Wallet - iframe version 1.16.1</title>
|
|
19
19
|
|
|
20
20
|
<!-- Styles will be injected by build process -->
|
|
21
21
|
<style>
|
package/dist/iframe/main.js
CHANGED
|
@@ -3265,7 +3265,7 @@ var SecureMessenger = class {
|
|
|
3265
3265
|
this.allowedOrigins = /* @__PURE__ */ new Set();
|
|
3266
3266
|
this.usedNonces = /* @__PURE__ */ new Set();
|
|
3267
3267
|
this.pendingMessages = /* @__PURE__ */ new Map();
|
|
3268
|
-
this.
|
|
3268
|
+
this.channelToken = null;
|
|
3269
3269
|
this.messageHandlers = [];
|
|
3270
3270
|
this.MESSAGE_TIMEOUT = 6e4;
|
|
3271
3271
|
// 60 seconds
|
|
@@ -3344,7 +3344,7 @@ var SecureMessenger = class {
|
|
|
3344
3344
|
console.error("[iframe][Messenger] Nonce already used (replay attack?)");
|
|
3345
3345
|
return;
|
|
3346
3346
|
}
|
|
3347
|
-
if (this.
|
|
3347
|
+
if (this.channelToken && message.hmac) {
|
|
3348
3348
|
const expectedHmac = await this.computeHMAC(message);
|
|
3349
3349
|
if (!this.constantTimeCompare(expectedHmac, message.hmac)) {
|
|
3350
3350
|
console.error("[iframe][Messenger] HMAC validation failed");
|
|
@@ -3410,11 +3410,18 @@ var SecureMessenger = class {
|
|
|
3410
3410
|
console.log(`[iframe][Messenger] Removed allowed origin: ${origin}`);
|
|
3411
3411
|
}
|
|
3412
3412
|
/**
|
|
3413
|
-
* Set
|
|
3413
|
+
* Set channel token for HMAC authentication
|
|
3414
|
+
* @deprecated Use setChannelToken instead
|
|
3414
3415
|
*/
|
|
3415
3416
|
setSessionToken(token) {
|
|
3416
|
-
this.
|
|
3417
|
-
|
|
3417
|
+
this.setChannelToken(token);
|
|
3418
|
+
}
|
|
3419
|
+
/**
|
|
3420
|
+
* Set SDK channel token for HMAC authentication
|
|
3421
|
+
*/
|
|
3422
|
+
setChannelToken(token) {
|
|
3423
|
+
this.channelToken = token;
|
|
3424
|
+
console.log("[iframe][Messenger] SDK channel token set");
|
|
3418
3425
|
}
|
|
3419
3426
|
/**
|
|
3420
3427
|
* Quick check if message looks like Lumia Passport protocol
|
|
@@ -3423,6 +3430,7 @@ var SecureMessenger = class {
|
|
|
3423
3430
|
isLumiaMessage(message) {
|
|
3424
3431
|
const validTypes = [
|
|
3425
3432
|
"SDK_AUTH",
|
|
3433
|
+
"SDK_CHANNEL_HEARTBEAT",
|
|
3426
3434
|
"AUTHENTICATE",
|
|
3427
3435
|
"START_DKG",
|
|
3428
3436
|
"SIGN_TRANSACTION",
|
|
@@ -3431,6 +3439,7 @@ var SecureMessenger = class {
|
|
|
3431
3439
|
"CHECK_KEYSHARE",
|
|
3432
3440
|
"GET_TRUSTED_APPS",
|
|
3433
3441
|
"REMOVE_TRUSTED_APP",
|
|
3442
|
+
"CLEAR_AUTHORIZATIONS",
|
|
3434
3443
|
"CREATE_BACKUP",
|
|
3435
3444
|
"ENCRYPT_BACKUP_DATA",
|
|
3436
3445
|
"RESTORE_BACKUP",
|
|
@@ -3473,8 +3482,8 @@ var SecureMessenger = class {
|
|
|
3473
3482
|
* Compute HMAC-SHA256 for message authentication
|
|
3474
3483
|
*/
|
|
3475
3484
|
async computeHMAC(message) {
|
|
3476
|
-
if (!this.
|
|
3477
|
-
throw new Error("No
|
|
3485
|
+
if (!this.channelToken) {
|
|
3486
|
+
throw new Error("No SDK channel token for HMAC");
|
|
3478
3487
|
}
|
|
3479
3488
|
const encoder3 = new TextEncoder();
|
|
3480
3489
|
const payload = JSON.stringify({
|
|
@@ -3485,7 +3494,7 @@ var SecureMessenger = class {
|
|
|
3485
3494
|
data: JSON.stringify(message.data)
|
|
3486
3495
|
});
|
|
3487
3496
|
const data = encoder3.encode(payload);
|
|
3488
|
-
const key = encoder3.encode(this.
|
|
3497
|
+
const key = encoder3.encode(this.channelToken);
|
|
3489
3498
|
const cryptoKey = await crypto.subtle.importKey("raw", key, { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
3490
3499
|
const signature = await crypto.subtle.sign("HMAC", cryptoKey, data);
|
|
3491
3500
|
return Array.from(new Uint8Array(signature)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
@@ -3523,79 +3532,78 @@ var SecureMessenger = class {
|
|
|
3523
3532
|
}
|
|
3524
3533
|
};
|
|
3525
3534
|
|
|
3526
|
-
// src/iframe/lib/
|
|
3527
|
-
var
|
|
3535
|
+
// src/iframe/lib/sdk-channel-manager.ts
|
|
3536
|
+
var SdkChannelManager = class {
|
|
3528
3537
|
// 30 minutes
|
|
3529
3538
|
constructor() {
|
|
3530
|
-
this.
|
|
3531
|
-
this.
|
|
3532
|
-
setInterval(() => this.
|
|
3539
|
+
this.channels = /* @__PURE__ */ new Map();
|
|
3540
|
+
this.CHANNEL_TIMEOUT = 30 * 60 * 1e3;
|
|
3541
|
+
setInterval(() => this.cleanupExpiredChannels(), 5 * 60 * 1e3);
|
|
3533
3542
|
}
|
|
3534
3543
|
/**
|
|
3535
|
-
* Create a new
|
|
3544
|
+
* Create a new SDK channel
|
|
3536
3545
|
*/
|
|
3537
|
-
|
|
3538
|
-
const
|
|
3539
|
-
const
|
|
3540
|
-
token:
|
|
3546
|
+
createChannel(projectId, origin) {
|
|
3547
|
+
const channelToken = this.generateSecureToken();
|
|
3548
|
+
const channel = {
|
|
3549
|
+
token: channelToken,
|
|
3541
3550
|
projectId,
|
|
3542
3551
|
origin,
|
|
3543
3552
|
createdAt: Date.now(),
|
|
3544
3553
|
lastActivity: Date.now()
|
|
3545
3554
|
};
|
|
3546
|
-
this.
|
|
3547
|
-
console.log(`[iframe][
|
|
3548
|
-
|
|
3549
|
-
return sessionToken;
|
|
3555
|
+
this.channels.set(channelToken, channel);
|
|
3556
|
+
console.log(`[iframe][SdkChannel] \u2713 Created: ${channelToken.slice(0, 16)}... origin=${origin}, total=${this.channels.size}`);
|
|
3557
|
+
return channelToken;
|
|
3550
3558
|
}
|
|
3551
3559
|
/**
|
|
3552
|
-
* Validate
|
|
3560
|
+
* Validate channel token and origin
|
|
3553
3561
|
*/
|
|
3554
|
-
|
|
3555
|
-
const
|
|
3556
|
-
if (!
|
|
3557
|
-
console.warn(`[iframe][
|
|
3562
|
+
validateChannel(channelToken, origin) {
|
|
3563
|
+
const channel = this.channels.get(channelToken);
|
|
3564
|
+
if (!channel) {
|
|
3565
|
+
console.warn(`[iframe][SdkChannel] \u2717 NOT FOUND: ${channelToken.slice(0, 16)}... (active channels: ${this.channels.size})`);
|
|
3558
3566
|
return false;
|
|
3559
3567
|
}
|
|
3560
|
-
if (
|
|
3561
|
-
console.error(`[iframe][
|
|
3568
|
+
if (channel.origin !== origin) {
|
|
3569
|
+
console.error(`[iframe][SdkChannel] \u2717 ORIGIN MISMATCH: expected ${channel.origin}, got ${origin}`);
|
|
3562
3570
|
return false;
|
|
3563
3571
|
}
|
|
3564
|
-
const age = Date.now() -
|
|
3565
|
-
if (age > this.
|
|
3566
|
-
console.warn(`[iframe][
|
|
3567
|
-
this.
|
|
3572
|
+
const age = Date.now() - channel.lastActivity;
|
|
3573
|
+
if (age > this.CHANNEL_TIMEOUT) {
|
|
3574
|
+
console.warn(`[iframe][SdkChannel] \u2717 EXPIRED: age=${Math.round(age / 1e3)}s > timeout=${this.CHANNEL_TIMEOUT / 1e3}s`);
|
|
3575
|
+
this.channels.delete(channelToken);
|
|
3568
3576
|
return false;
|
|
3569
3577
|
}
|
|
3570
|
-
|
|
3578
|
+
channel.lastActivity = Date.now();
|
|
3571
3579
|
return true;
|
|
3572
3580
|
}
|
|
3573
3581
|
/**
|
|
3574
|
-
* Get
|
|
3582
|
+
* Get channel by token
|
|
3575
3583
|
*/
|
|
3576
|
-
|
|
3577
|
-
return this.
|
|
3584
|
+
getChannel(channelToken) {
|
|
3585
|
+
return this.channels.get(channelToken) || null;
|
|
3578
3586
|
}
|
|
3579
3587
|
/**
|
|
3580
|
-
* Invalidate
|
|
3588
|
+
* Invalidate channel
|
|
3581
3589
|
*/
|
|
3582
|
-
|
|
3583
|
-
const
|
|
3584
|
-
if (
|
|
3585
|
-
console.log(`[iframe][
|
|
3586
|
-
this.
|
|
3590
|
+
invalidateChannel(channelToken) {
|
|
3591
|
+
const channel = this.channels.get(channelToken);
|
|
3592
|
+
if (channel) {
|
|
3593
|
+
console.log(`[iframe][SdkChannel] Invalidated channel for origin: ${channel.origin}`);
|
|
3594
|
+
this.channels.delete(channelToken);
|
|
3587
3595
|
}
|
|
3588
3596
|
}
|
|
3589
3597
|
/**
|
|
3590
|
-
* Get all
|
|
3598
|
+
* Get all channels for a project
|
|
3591
3599
|
*/
|
|
3592
|
-
|
|
3593
|
-
return Array.from(this.
|
|
3594
|
-
(
|
|
3600
|
+
getProjectChannels(projectId) {
|
|
3601
|
+
return Array.from(this.channels.values()).filter(
|
|
3602
|
+
(channel) => channel.projectId === projectId
|
|
3595
3603
|
);
|
|
3596
3604
|
}
|
|
3597
3605
|
/**
|
|
3598
|
-
* Generate cryptographically secure
|
|
3606
|
+
* Generate cryptographically secure channel token
|
|
3599
3607
|
*/
|
|
3600
3608
|
generateSecureToken() {
|
|
3601
3609
|
const buffer = new Uint8Array(32);
|
|
@@ -3603,31 +3611,31 @@ var SessionManager = class {
|
|
|
3603
3611
|
return Array.from(buffer, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
3604
3612
|
}
|
|
3605
3613
|
/**
|
|
3606
|
-
* Cleanup expired
|
|
3614
|
+
* Cleanup expired channels
|
|
3607
3615
|
*/
|
|
3608
|
-
|
|
3616
|
+
cleanupExpiredChannels() {
|
|
3609
3617
|
const now = Date.now();
|
|
3610
3618
|
let cleanedCount = 0;
|
|
3611
|
-
for (const [token,
|
|
3612
|
-
const age = now -
|
|
3613
|
-
if (age > this.
|
|
3614
|
-
this.
|
|
3619
|
+
for (const [token, channel] of this.channels.entries()) {
|
|
3620
|
+
const age = now - channel.lastActivity;
|
|
3621
|
+
if (age > this.CHANNEL_TIMEOUT) {
|
|
3622
|
+
this.channels.delete(token);
|
|
3615
3623
|
cleanedCount++;
|
|
3616
3624
|
}
|
|
3617
3625
|
}
|
|
3618
3626
|
if (cleanedCount > 0) {
|
|
3619
|
-
console.log(`[iframe][
|
|
3627
|
+
console.log(`[iframe][SdkChannel] Cleaned up ${cleanedCount} expired channels`);
|
|
3620
3628
|
}
|
|
3621
3629
|
}
|
|
3622
3630
|
/**
|
|
3623
|
-
* Check if there is an active
|
|
3631
|
+
* Check if there is an active channel for a given origin
|
|
3624
3632
|
*/
|
|
3625
|
-
|
|
3633
|
+
hasChannel(origin) {
|
|
3626
3634
|
const now = Date.now();
|
|
3627
|
-
for (const
|
|
3628
|
-
if (
|
|
3629
|
-
const age = now -
|
|
3630
|
-
if (age <= this.
|
|
3635
|
+
for (const channel of this.channels.values()) {
|
|
3636
|
+
if (channel.origin === origin) {
|
|
3637
|
+
const age = now - channel.lastActivity;
|
|
3638
|
+
if (age <= this.CHANNEL_TIMEOUT) {
|
|
3631
3639
|
return true;
|
|
3632
3640
|
}
|
|
3633
3641
|
}
|
|
@@ -3635,15 +3643,15 @@ var SessionManager = class {
|
|
|
3635
3643
|
return false;
|
|
3636
3644
|
}
|
|
3637
3645
|
/**
|
|
3638
|
-
* Get
|
|
3646
|
+
* Get channel statistics
|
|
3639
3647
|
*/
|
|
3640
3648
|
getStats() {
|
|
3641
3649
|
const stats = {
|
|
3642
|
-
total: this.
|
|
3650
|
+
total: this.channels.size,
|
|
3643
3651
|
byProject: {}
|
|
3644
3652
|
};
|
|
3645
|
-
for (const
|
|
3646
|
-
stats.byProject[
|
|
3653
|
+
for (const channel of this.channels.values()) {
|
|
3654
|
+
stats.byProject[channel.projectId] = (stats.byProject[channel.projectId] || 0) + 1;
|
|
3647
3655
|
}
|
|
3648
3656
|
return stats;
|
|
3649
3657
|
}
|
|
@@ -4403,14 +4411,14 @@ var SigningManager = class extends TokenRefreshApiClient {
|
|
|
4403
4411
|
};
|
|
4404
4412
|
|
|
4405
4413
|
// src/iframe/main.ts
|
|
4406
|
-
var IFRAME_VERSION = "1.
|
|
4414
|
+
var IFRAME_VERSION = "1.16.1";
|
|
4407
4415
|
var IframeWallet = class {
|
|
4408
4416
|
constructor() {
|
|
4409
4417
|
console.log("=".repeat(60));
|
|
4410
4418
|
console.log(` Lumia Passport Secure Wallet - iframe version ${IFRAME_VERSION}`);
|
|
4411
4419
|
console.log("=".repeat(60));
|
|
4412
4420
|
this.messenger = new SecureMessenger();
|
|
4413
|
-
this.
|
|
4421
|
+
this.sdkChannelManager = new SdkChannelManager();
|
|
4414
4422
|
this.dkgManager = new DKGManager();
|
|
4415
4423
|
this.signingManager = new SigningManager();
|
|
4416
4424
|
this.authManager = new AuthorizationManager();
|
|
@@ -4454,6 +4462,9 @@ var IframeWallet = class {
|
|
|
4454
4462
|
case type === "SDK_AUTH":
|
|
4455
4463
|
await this.handleSDKAuth(message, origin);
|
|
4456
4464
|
break;
|
|
4465
|
+
case type === "SDK_CHANNEL_HEARTBEAT":
|
|
4466
|
+
await this.handleHeartbeat(message, origin);
|
|
4467
|
+
break;
|
|
4457
4468
|
case type === "AUTHENTICATE":
|
|
4458
4469
|
await this.handleAuthenticate(message, origin);
|
|
4459
4470
|
break;
|
|
@@ -4507,6 +4518,21 @@ var IframeWallet = class {
|
|
|
4507
4518
|
this.messenger.sendError(messageId, error instanceof Error ? error : new Error("Unknown error"), origin);
|
|
4508
4519
|
}
|
|
4509
4520
|
}
|
|
4521
|
+
/**
|
|
4522
|
+
* Handle SDK channel heartbeat - allows parent to check if channel is still valid
|
|
4523
|
+
*/
|
|
4524
|
+
async handleHeartbeat(message, origin) {
|
|
4525
|
+
const { sessionToken } = message.data;
|
|
4526
|
+
const { messageId } = message;
|
|
4527
|
+
const isValid = this.sdkChannelManager.validateChannel(sessionToken, origin);
|
|
4528
|
+
const stats = this.sdkChannelManager.getStats();
|
|
4529
|
+
this.messenger.sendResponse(messageId, {
|
|
4530
|
+
type: "LUMIA_PASSPORT_HEARTBEAT_RESPONSE",
|
|
4531
|
+
valid: isValid,
|
|
4532
|
+
channelsCount: stats.total
|
|
4533
|
+
}, origin);
|
|
4534
|
+
console.log(`[iframe] HEARTBEAT: valid=${isValid}, channels=${stats.total}`);
|
|
4535
|
+
}
|
|
4510
4536
|
async handleSDKAuth(message, origin) {
|
|
4511
4537
|
const { projectId } = message.data;
|
|
4512
4538
|
const { messageId } = message;
|
|
@@ -4516,8 +4542,8 @@ var IframeWallet = class {
|
|
|
4516
4542
|
if (!isHttps && !isLocalhost) {
|
|
4517
4543
|
throw new Error("Only HTTPS origins are allowed (or localhost for dev)");
|
|
4518
4544
|
}
|
|
4519
|
-
const sessionToken = this.
|
|
4520
|
-
this.messenger.
|
|
4545
|
+
const sessionToken = this.sdkChannelManager.createChannel(projectId, origin);
|
|
4546
|
+
this.messenger.setChannelToken(sessionToken);
|
|
4521
4547
|
this.messenger.addAllowedOrigin(origin);
|
|
4522
4548
|
this.messenger.sendResponse(
|
|
4523
4549
|
messageId,
|
|
@@ -4532,8 +4558,8 @@ var IframeWallet = class {
|
|
|
4532
4558
|
async handleAuthenticate(message, origin) {
|
|
4533
4559
|
const { sessionToken, projectId, userId, avatar, displayName } = message.data;
|
|
4534
4560
|
const { messageId } = message;
|
|
4535
|
-
if (!this.
|
|
4536
|
-
throw new Error("Invalid
|
|
4561
|
+
if (!this.sdkChannelManager.validateChannel(sessionToken, origin)) {
|
|
4562
|
+
throw new Error("Invalid SDK channel");
|
|
4537
4563
|
}
|
|
4538
4564
|
console.log(`[iframe] AUTHENTICATE: userId=${userId}, projectId=${projectId}`);
|
|
4539
4565
|
const isAuthorized = await this.authManager.checkAuthorization(userId, projectId);
|
|
@@ -4601,8 +4627,8 @@ var IframeWallet = class {
|
|
|
4601
4627
|
async handleStartDKG(message, origin) {
|
|
4602
4628
|
const { sessionToken, userId, projectId, accessToken } = message.data;
|
|
4603
4629
|
const { messageId } = message;
|
|
4604
|
-
if (!this.
|
|
4605
|
-
throw new Error("Invalid
|
|
4630
|
+
if (!this.sdkChannelManager.validateChannel(sessionToken, origin)) {
|
|
4631
|
+
throw new Error("Invalid SDK channel");
|
|
4606
4632
|
}
|
|
4607
4633
|
const isAuthorized = await this.authManager.checkAuthorization(userId, projectId);
|
|
4608
4634
|
if (!isAuthorized) {
|
|
@@ -4636,8 +4662,8 @@ var IframeWallet = class {
|
|
|
4636
4662
|
async handleSignTransaction(message, origin) {
|
|
4637
4663
|
const { sessionToken, userId, projectId, transaction, accessToken, avatar, displayName } = message.data;
|
|
4638
4664
|
const { messageId } = message;
|
|
4639
|
-
if (!this.
|
|
4640
|
-
throw new Error("Invalid
|
|
4665
|
+
if (!this.sdkChannelManager.validateChannel(sessionToken, origin)) {
|
|
4666
|
+
throw new Error("Invalid SDK channel");
|
|
4641
4667
|
}
|
|
4642
4668
|
const isAuthorized = await this.authManager.checkAuthorization(userId, projectId);
|
|
4643
4669
|
if (!isAuthorized) {
|
|
@@ -4666,8 +4692,8 @@ var IframeWallet = class {
|
|
|
4666
4692
|
async handleSignTypedData(message, origin) {
|
|
4667
4693
|
const { sessionToken, userId, projectId, typedData, digest32, accessToken, avatar, displayName } = message.data;
|
|
4668
4694
|
const { messageId } = message;
|
|
4669
|
-
if (!this.
|
|
4670
|
-
throw new Error("Invalid
|
|
4695
|
+
if (!this.sdkChannelManager.validateChannel(sessionToken, origin)) {
|
|
4696
|
+
throw new Error("Invalid SDK channel");
|
|
4671
4697
|
}
|
|
4672
4698
|
const isAuthorized = await this.authManager.checkAuthorization(userId, projectId);
|
|
4673
4699
|
if (!isAuthorized) {
|
|
@@ -4701,8 +4727,8 @@ var IframeWallet = class {
|
|
|
4701
4727
|
async handleGetAddress(message, origin) {
|
|
4702
4728
|
const { sessionToken, userId } = message.data;
|
|
4703
4729
|
const { messageId } = message;
|
|
4704
|
-
if (!this.
|
|
4705
|
-
throw new Error("Invalid
|
|
4730
|
+
if (!this.sdkChannelManager.validateChannel(sessionToken, origin)) {
|
|
4731
|
+
throw new Error("Invalid SDK channel");
|
|
4706
4732
|
}
|
|
4707
4733
|
const address = this.storage.getOwnerAddress(userId);
|
|
4708
4734
|
this.messenger.sendResponse(
|
|
@@ -4717,8 +4743,8 @@ var IframeWallet = class {
|
|
|
4717
4743
|
async handleCheckKeyshare(message, origin) {
|
|
4718
4744
|
const { sessionToken, userId } = message.data;
|
|
4719
4745
|
const { messageId } = message;
|
|
4720
|
-
if (!this.
|
|
4721
|
-
throw new Error("Invalid
|
|
4746
|
+
if (!this.sdkChannelManager.validateChannel(sessionToken, origin)) {
|
|
4747
|
+
throw new Error("Invalid SDK channel");
|
|
4722
4748
|
}
|
|
4723
4749
|
const hasKeyshare = this.storage.hasKeyshare(userId);
|
|
4724
4750
|
const address = hasKeyshare ? this.storage.getOwnerAddress(userId) : void 0;
|
|
@@ -4736,9 +4762,9 @@ var IframeWallet = class {
|
|
|
4736
4762
|
const { sessionToken, userId } = message.data;
|
|
4737
4763
|
const { messageId } = message;
|
|
4738
4764
|
console.log(`[iframe] GET_TRUSTED_APPS: userId=${userId}, sessionToken=${sessionToken ? "present" : "missing"}`);
|
|
4739
|
-
if (!this.
|
|
4765
|
+
if (!this.sdkChannelManager.validateChannel(sessionToken, origin)) {
|
|
4740
4766
|
console.error("[iframe] GET_TRUSTED_APPS: Session validation failed");
|
|
4741
|
-
throw new Error("Invalid
|
|
4767
|
+
throw new Error("Invalid SDK channel");
|
|
4742
4768
|
}
|
|
4743
4769
|
const trustedApps = this.trustedApps.getTrustedAppsForUser(userId);
|
|
4744
4770
|
this.messenger.sendResponse(
|
|
@@ -4755,9 +4781,9 @@ var IframeWallet = class {
|
|
|
4755
4781
|
const { sessionToken, userId, projectId, appOrigin } = message.data;
|
|
4756
4782
|
const { messageId } = message;
|
|
4757
4783
|
console.log(`[iframe] REMOVE_TRUSTED_APP: userId=${userId}, projectId=${projectId}, origin=${appOrigin}`);
|
|
4758
|
-
if (!this.
|
|
4784
|
+
if (!this.sdkChannelManager.validateChannel(sessionToken, origin)) {
|
|
4759
4785
|
console.error("[iframe] REMOVE_TRUSTED_APP: Session validation failed");
|
|
4760
|
-
throw new Error("Invalid
|
|
4786
|
+
throw new Error("Invalid SDK channel");
|
|
4761
4787
|
}
|
|
4762
4788
|
const isEcosystemApp = await this.authManager.isTrustedAuthorizedApp(projectId);
|
|
4763
4789
|
if (isEcosystemApp) {
|
|
@@ -4783,9 +4809,9 @@ var IframeWallet = class {
|
|
|
4783
4809
|
const { sessionToken, projectId } = message.data;
|
|
4784
4810
|
const { messageId } = message;
|
|
4785
4811
|
console.log(`[iframe] CLEAR_AUTHORIZATIONS: projectId=${projectId}`);
|
|
4786
|
-
if (!this.
|
|
4812
|
+
if (!this.sdkChannelManager.validateChannel(sessionToken, origin)) {
|
|
4787
4813
|
console.error("[iframe] CLEAR_AUTHORIZATIONS: Session validation failed");
|
|
4788
|
-
throw new Error("Invalid
|
|
4814
|
+
throw new Error("Invalid SDK channel");
|
|
4789
4815
|
}
|
|
4790
4816
|
const storage = this.storage;
|
|
4791
4817
|
const allKeys = Object.keys(localStorage).filter((key) => key.startsWith("auth_"));
|
|
@@ -4831,9 +4857,9 @@ var IframeWallet = class {
|
|
|
4831
4857
|
this.messenger.sendError(messageId, "backupRequest is required", origin);
|
|
4832
4858
|
return;
|
|
4833
4859
|
}
|
|
4834
|
-
if (!this.
|
|
4860
|
+
if (!this.sdkChannelManager.validateChannel(sessionToken, origin)) {
|
|
4835
4861
|
console.error("[iframe] CREATE_BACKUP: Session validation failed", { sessionToken, origin });
|
|
4836
|
-
this.messenger.sendError(messageId, "Invalid
|
|
4862
|
+
this.messenger.sendError(messageId, "Invalid SDK channel", origin);
|
|
4837
4863
|
return;
|
|
4838
4864
|
}
|
|
4839
4865
|
try {
|
|
@@ -4860,9 +4886,9 @@ var IframeWallet = class {
|
|
|
4860
4886
|
const { sessionToken, userId } = message.data;
|
|
4861
4887
|
const { messageId } = message;
|
|
4862
4888
|
console.log(`[iframe] GET_BACKUP_STATUS: userId=${userId}`);
|
|
4863
|
-
if (!this.
|
|
4889
|
+
if (!this.sdkChannelManager.validateChannel(sessionToken, origin)) {
|
|
4864
4890
|
console.error("[iframe] GET_BACKUP_STATUS: Session validation failed");
|
|
4865
|
-
throw new Error("Invalid
|
|
4891
|
+
throw new Error("Invalid SDK channel");
|
|
4866
4892
|
}
|
|
4867
4893
|
const status = this.backupManager.getBackupStatus(userId);
|
|
4868
4894
|
this.messenger.sendResponse(
|
|
@@ -4879,9 +4905,9 @@ var IframeWallet = class {
|
|
|
4879
4905
|
const { sessionToken } = message.data;
|
|
4880
4906
|
const { messageId } = message;
|
|
4881
4907
|
console.log(`[iframe] GET_CLOUD_PROVIDERS`);
|
|
4882
|
-
if (!this.
|
|
4908
|
+
if (!this.sdkChannelManager.validateChannel(sessionToken, origin)) {
|
|
4883
4909
|
console.error("[iframe] GET_CLOUD_PROVIDERS: Session validation failed");
|
|
4884
|
-
throw new Error("Invalid
|
|
4910
|
+
throw new Error("Invalid SDK channel");
|
|
4885
4911
|
}
|
|
4886
4912
|
const providers = this.backupManager.getAvailableCloudProviders();
|
|
4887
4913
|
this.messenger.sendResponse(
|
|
@@ -4909,9 +4935,9 @@ var IframeWallet = class {
|
|
|
4909
4935
|
this.messenger.sendError(messageId, "userId is required", origin);
|
|
4910
4936
|
return;
|
|
4911
4937
|
}
|
|
4912
|
-
if (!this.
|
|
4938
|
+
if (!this.sdkChannelManager.validateChannel(sessionToken, origin)) {
|
|
4913
4939
|
console.error("[iframe] RESTORE_BACKUP: Session validation failed", { sessionToken, origin });
|
|
4914
|
-
this.messenger.sendError(messageId, "Invalid
|
|
4940
|
+
this.messenger.sendError(messageId, "Invalid SDK channel", origin);
|
|
4915
4941
|
return;
|
|
4916
4942
|
}
|
|
4917
4943
|
try {
|
|
@@ -4967,9 +4993,9 @@ var IframeWallet = class {
|
|
|
4967
4993
|
this.messenger.sendError(messageId, "fileContent is required", origin);
|
|
4968
4994
|
return;
|
|
4969
4995
|
}
|
|
4970
|
-
if (!this.
|
|
4996
|
+
if (!this.sdkChannelManager.validateChannel(sessionToken, origin)) {
|
|
4971
4997
|
console.error("[iframe] RESTORE_FROM_FILE: Session validation failed", { sessionToken, origin });
|
|
4972
|
-
this.messenger.sendError(messageId, "Invalid
|
|
4998
|
+
this.messenger.sendError(messageId, "Invalid SDK channel", origin);
|
|
4973
4999
|
return;
|
|
4974
5000
|
}
|
|
4975
5001
|
try {
|
|
@@ -5019,9 +5045,9 @@ var IframeWallet = class {
|
|
|
5019
5045
|
this.messenger.sendError(messageId, "userId is required", origin);
|
|
5020
5046
|
return;
|
|
5021
5047
|
}
|
|
5022
|
-
if (!this.
|
|
5048
|
+
if (!this.sdkChannelManager.validateChannel(sessionToken, origin)) {
|
|
5023
5049
|
console.error("[iframe] ENCRYPT_BACKUP_DATA: Session validation failed", { sessionToken, origin });
|
|
5024
|
-
this.messenger.sendError(messageId, "Invalid
|
|
5050
|
+
this.messenger.sendError(messageId, "Invalid SDK channel", origin);
|
|
5025
5051
|
return;
|
|
5026
5052
|
}
|
|
5027
5053
|
try {
|
|
@@ -5058,13 +5084,15 @@ var IframeWallet = class {
|
|
|
5058
5084
|
sendWalletReadyStatus(userId, origin) {
|
|
5059
5085
|
const hasKeyshare = this.storage.hasKeyshare(userId);
|
|
5060
5086
|
const address = hasKeyshare ? this.storage.getOwnerAddress(userId) : void 0;
|
|
5061
|
-
const
|
|
5087
|
+
const hasChannel = this.sdkChannelManager.hasChannel(origin);
|
|
5062
5088
|
const status = {
|
|
5063
|
-
ready: hasKeyshare &&
|
|
5089
|
+
ready: hasKeyshare && hasChannel,
|
|
5064
5090
|
userId,
|
|
5065
5091
|
address,
|
|
5066
5092
|
hasKeyshare,
|
|
5067
|
-
|
|
5093
|
+
hasChannel,
|
|
5094
|
+
hasSession: hasChannel,
|
|
5095
|
+
// backward compatibility
|
|
5068
5096
|
timestamp: Date.now()
|
|
5069
5097
|
};
|
|
5070
5098
|
if (window.parent) {
|