@dynamic-labs-wallet/browser-wallet-client 0.0.320 → 0.0.321
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/index.cjs.js +38 -18
- package/index.esm.js +38 -18
- package/package.json +3 -4
package/index.cjs.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var core = require('@dynamic-labs-wallet/core');
|
|
4
4
|
var messageTransport = require('@dynamic-labs/message-transport');
|
|
5
|
-
var uuid = require('uuid');
|
|
6
5
|
var logger$1 = require('@dynamic-labs/logger');
|
|
7
6
|
|
|
8
7
|
function _extends() {
|
|
@@ -262,23 +261,29 @@ class IframeManager {
|
|
|
262
261
|
}
|
|
263
262
|
setupMessageTransportBridge(this.messageTransport, this.iframe, this.iframeDomain);
|
|
264
263
|
this.iframeMessageHandler = new iframeMessageHandler(this.messageTransport);
|
|
265
|
-
// Set up request channel to handle messages from iframe (for secureStorage)
|
|
266
|
-
if (this.secureStorage) {
|
|
267
|
-
this.iframeRequestChannel = this.
|
|
264
|
+
// Set up request channel to handle messages from iframe (for secureStorage and getSignedSessionId)
|
|
265
|
+
if (this.secureStorage || this.getSignedSessionIdCallback) {
|
|
266
|
+
this.iframeRequestChannel = this.setupIframeRequestHandlers(this.messageTransport);
|
|
268
267
|
}
|
|
269
268
|
await this.initAuthToken();
|
|
270
269
|
}
|
|
271
270
|
/**
|
|
272
|
-
* Sets up message handlers for secureStorage
|
|
273
|
-
*/
|
|
271
|
+
* Sets up message handlers for iframe → host requests (secureStorage and getSignedSessionId)
|
|
272
|
+
*/ setupIframeRequestHandlers(transport) {
|
|
274
273
|
// Create a request channel to handle requests FROM iframe
|
|
275
274
|
const requestChannel = messageTransport.createRequestChannel(transport);
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
275
|
+
if (this.secureStorage) {
|
|
276
|
+
// Handle getClientKeyShare requests from iframe
|
|
277
|
+
requestChannel.handle('getClientKeyShare', this.handleGetClientKeyShare.bind(this));
|
|
278
|
+
// Handle setClientKeyShare requests from iframe
|
|
279
|
+
requestChannel.handle('setClientKeyShare', this.handleSetClientKeyShare.bind(this));
|
|
280
|
+
// Handle removeClientKeyShare requests from iframe
|
|
281
|
+
requestChannel.handle('removeClientKeyShare', this.handleRemoveClientKeyShare.bind(this));
|
|
282
|
+
}
|
|
283
|
+
if (this.getSignedSessionIdCallback) {
|
|
284
|
+
// Handle getSignedSessionId requests from iframe
|
|
285
|
+
requestChannel.handle('getSignedSessionId', this.handleGetSignedSessionId.bind(this));
|
|
286
|
+
}
|
|
282
287
|
return requestChannel;
|
|
283
288
|
}
|
|
284
289
|
/**
|
|
@@ -309,6 +314,17 @@ class IframeManager {
|
|
|
309
314
|
await this.secureStorage.removeClientKeyShare(request.accountAddress);
|
|
310
315
|
}
|
|
311
316
|
/**
|
|
317
|
+
* Handler for getSignedSessionId requests from iframe
|
|
318
|
+
*/ async handleGetSignedSessionId(_request) {
|
|
319
|
+
if (!this.getSignedSessionIdCallback) {
|
|
320
|
+
throw new Error('Signed session ID callback not available');
|
|
321
|
+
}
|
|
322
|
+
const signedSessionId = await this.getSignedSessionIdCallback();
|
|
323
|
+
return {
|
|
324
|
+
signedSessionId
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
312
328
|
* securely exchange the auth token with iframe securely
|
|
313
329
|
*/ async initAuthToken() {
|
|
314
330
|
if (!this.iframeMessageHandler) {
|
|
@@ -591,10 +607,10 @@ class IframeManager {
|
|
|
591
607
|
});
|
|
592
608
|
setupMessageTransportBridge(transport, iframe, this.iframeDomain);
|
|
593
609
|
const iframeDisplay = new iframeMessageHandler(transport);
|
|
594
|
-
// Set up
|
|
595
|
-
// can access key shares (e.g. for exportPrivateKey)
|
|
596
|
-
if (this.secureStorage) {
|
|
597
|
-
this.
|
|
610
|
+
// Set up iframe request handlers on this transport so the display iframe
|
|
611
|
+
// can access key shares (e.g. for exportPrivateKey) and signed session ID
|
|
612
|
+
if (this.secureStorage || this.getSignedSessionIdCallback) {
|
|
613
|
+
this.setupIframeRequestHandlers(transport);
|
|
598
614
|
}
|
|
599
615
|
var _this_authMode;
|
|
600
616
|
// if authMode is header: inform iframe the authMode with auth token
|
|
@@ -647,13 +663,17 @@ class IframeManager {
|
|
|
647
663
|
if (internalOptions == null ? void 0 : internalOptions.secureStorage) {
|
|
648
664
|
this.secureStorage = internalOptions.secureStorage;
|
|
649
665
|
}
|
|
666
|
+
// Set signed session ID callback if provided (internal use only)
|
|
667
|
+
if (internalOptions == null ? void 0 : internalOptions.getSignedSessionId) {
|
|
668
|
+
this.getSignedSessionIdCallback = internalOptions.getSignedSessionId;
|
|
669
|
+
}
|
|
650
670
|
const environment = core.getEnvironmentFromUrl(baseApiUrl);
|
|
651
671
|
this.iframeDomain = core.IFRAME_DOMAIN_MAP[environment];
|
|
652
672
|
if (this.authMode === core.AuthMode.COOKIE) {
|
|
653
673
|
this.iframeDomain = this.baseApiUrl;
|
|
654
674
|
}
|
|
655
675
|
// Generate unique instanceId when client is created
|
|
656
|
-
this.instanceId =
|
|
676
|
+
this.instanceId = crypto.randomUUID();
|
|
657
677
|
this.debug = Boolean(debug);
|
|
658
678
|
this.logger.setLogLevel(this.debug ? 'DEBUG' : 'INFO');
|
|
659
679
|
}
|
|
@@ -1006,7 +1026,7 @@ class DynamicWalletClient extends IframeManager {
|
|
|
1006
1026
|
debug,
|
|
1007
1027
|
authMode
|
|
1008
1028
|
}, internalOptions);
|
|
1009
|
-
// Note: secureStorage
|
|
1029
|
+
// Note: secureStorage and getSignedSessionId are already set by IframeManager constructor
|
|
1010
1030
|
}
|
|
1011
1031
|
}
|
|
1012
1032
|
|
package/index.esm.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AuthMode, getEnvironmentFromUrl, IFRAME_DOMAIN_MAP, WalletOperation } from '@dynamic-labs-wallet/core';
|
|
2
2
|
export { AuthMode, MPC_RELAY_PREPROD_API_URL, MPC_RELAY_PROD_API_URL, ThresholdSignatureScheme, WalletOperation } from '@dynamic-labs-wallet/core';
|
|
3
3
|
import { createRequestChannel, parseMessageTransportData, applyDefaultMessageOrigin, createMessageTransport } from '@dynamic-labs/message-transport';
|
|
4
|
-
import { v4 } from 'uuid';
|
|
5
4
|
import { Logger } from '@dynamic-labs/logger';
|
|
6
5
|
|
|
7
6
|
function _extends() {
|
|
@@ -261,23 +260,29 @@ class IframeManager {
|
|
|
261
260
|
}
|
|
262
261
|
setupMessageTransportBridge(this.messageTransport, this.iframe, this.iframeDomain);
|
|
263
262
|
this.iframeMessageHandler = new iframeMessageHandler(this.messageTransport);
|
|
264
|
-
// Set up request channel to handle messages from iframe (for secureStorage)
|
|
265
|
-
if (this.secureStorage) {
|
|
266
|
-
this.iframeRequestChannel = this.
|
|
263
|
+
// Set up request channel to handle messages from iframe (for secureStorage and getSignedSessionId)
|
|
264
|
+
if (this.secureStorage || this.getSignedSessionIdCallback) {
|
|
265
|
+
this.iframeRequestChannel = this.setupIframeRequestHandlers(this.messageTransport);
|
|
267
266
|
}
|
|
268
267
|
await this.initAuthToken();
|
|
269
268
|
}
|
|
270
269
|
/**
|
|
271
|
-
* Sets up message handlers for secureStorage
|
|
272
|
-
*/
|
|
270
|
+
* Sets up message handlers for iframe → host requests (secureStorage and getSignedSessionId)
|
|
271
|
+
*/ setupIframeRequestHandlers(transport) {
|
|
273
272
|
// Create a request channel to handle requests FROM iframe
|
|
274
273
|
const requestChannel = createRequestChannel(transport);
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
274
|
+
if (this.secureStorage) {
|
|
275
|
+
// Handle getClientKeyShare requests from iframe
|
|
276
|
+
requestChannel.handle('getClientKeyShare', this.handleGetClientKeyShare.bind(this));
|
|
277
|
+
// Handle setClientKeyShare requests from iframe
|
|
278
|
+
requestChannel.handle('setClientKeyShare', this.handleSetClientKeyShare.bind(this));
|
|
279
|
+
// Handle removeClientKeyShare requests from iframe
|
|
280
|
+
requestChannel.handle('removeClientKeyShare', this.handleRemoveClientKeyShare.bind(this));
|
|
281
|
+
}
|
|
282
|
+
if (this.getSignedSessionIdCallback) {
|
|
283
|
+
// Handle getSignedSessionId requests from iframe
|
|
284
|
+
requestChannel.handle('getSignedSessionId', this.handleGetSignedSessionId.bind(this));
|
|
285
|
+
}
|
|
281
286
|
return requestChannel;
|
|
282
287
|
}
|
|
283
288
|
/**
|
|
@@ -308,6 +313,17 @@ class IframeManager {
|
|
|
308
313
|
await this.secureStorage.removeClientKeyShare(request.accountAddress);
|
|
309
314
|
}
|
|
310
315
|
/**
|
|
316
|
+
* Handler for getSignedSessionId requests from iframe
|
|
317
|
+
*/ async handleGetSignedSessionId(_request) {
|
|
318
|
+
if (!this.getSignedSessionIdCallback) {
|
|
319
|
+
throw new Error('Signed session ID callback not available');
|
|
320
|
+
}
|
|
321
|
+
const signedSessionId = await this.getSignedSessionIdCallback();
|
|
322
|
+
return {
|
|
323
|
+
signedSessionId
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
311
327
|
* securely exchange the auth token with iframe securely
|
|
312
328
|
*/ async initAuthToken() {
|
|
313
329
|
if (!this.iframeMessageHandler) {
|
|
@@ -590,10 +606,10 @@ class IframeManager {
|
|
|
590
606
|
});
|
|
591
607
|
setupMessageTransportBridge(transport, iframe, this.iframeDomain);
|
|
592
608
|
const iframeDisplay = new iframeMessageHandler(transport);
|
|
593
|
-
// Set up
|
|
594
|
-
// can access key shares (e.g. for exportPrivateKey)
|
|
595
|
-
if (this.secureStorage) {
|
|
596
|
-
this.
|
|
609
|
+
// Set up iframe request handlers on this transport so the display iframe
|
|
610
|
+
// can access key shares (e.g. for exportPrivateKey) and signed session ID
|
|
611
|
+
if (this.secureStorage || this.getSignedSessionIdCallback) {
|
|
612
|
+
this.setupIframeRequestHandlers(transport);
|
|
597
613
|
}
|
|
598
614
|
var _this_authMode;
|
|
599
615
|
// if authMode is header: inform iframe the authMode with auth token
|
|
@@ -646,13 +662,17 @@ class IframeManager {
|
|
|
646
662
|
if (internalOptions == null ? void 0 : internalOptions.secureStorage) {
|
|
647
663
|
this.secureStorage = internalOptions.secureStorage;
|
|
648
664
|
}
|
|
665
|
+
// Set signed session ID callback if provided (internal use only)
|
|
666
|
+
if (internalOptions == null ? void 0 : internalOptions.getSignedSessionId) {
|
|
667
|
+
this.getSignedSessionIdCallback = internalOptions.getSignedSessionId;
|
|
668
|
+
}
|
|
649
669
|
const environment = getEnvironmentFromUrl(baseApiUrl);
|
|
650
670
|
this.iframeDomain = IFRAME_DOMAIN_MAP[environment];
|
|
651
671
|
if (this.authMode === AuthMode.COOKIE) {
|
|
652
672
|
this.iframeDomain = this.baseApiUrl;
|
|
653
673
|
}
|
|
654
674
|
// Generate unique instanceId when client is created
|
|
655
|
-
this.instanceId =
|
|
675
|
+
this.instanceId = crypto.randomUUID();
|
|
656
676
|
this.debug = Boolean(debug);
|
|
657
677
|
this.logger.setLogLevel(this.debug ? 'DEBUG' : 'INFO');
|
|
658
678
|
}
|
|
@@ -1005,7 +1025,7 @@ class DynamicWalletClient extends IframeManager {
|
|
|
1005
1025
|
debug,
|
|
1006
1026
|
authMode
|
|
1007
1027
|
}, internalOptions);
|
|
1008
|
-
// Note: secureStorage
|
|
1028
|
+
// Note: secureStorage and getSignedSessionId are already set by IframeManager constructor
|
|
1009
1029
|
}
|
|
1010
1030
|
}
|
|
1011
1031
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/browser-wallet-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.321",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@dynamic-labs-wallet/core": "0.0.
|
|
7
|
+
"@dynamic-labs-wallet/core": "0.0.321",
|
|
8
8
|
"@dynamic-labs/logger": "^4.45.2",
|
|
9
|
-
"@dynamic-labs/message-transport": "^4.45.2"
|
|
10
|
-
"uuid": "11.1.0"
|
|
9
|
+
"@dynamic-labs/message-transport": "^4.45.2"
|
|
11
10
|
},
|
|
12
11
|
"publishConfig": {
|
|
13
12
|
"access": "public"
|