@dynamic-labs-wallet/browser 0.0.71 → 0.0.73
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 +290 -15
- package/index.esm.js +290 -15
- package/package.json +4 -5
- package/src/client.d.ts +78 -4
- package/src/client.d.ts.map +1 -1
- package/src/services/iframeDisplay.d.ts +9 -0
- package/src/services/iframeDisplay.d.ts.map +1 -0
- package/src/services/iframeLocalStorage.d.ts +13 -0
- package/src/services/iframeLocalStorage.d.ts.map +1 -0
- package/src/services/messageTransportBridge.d.ts +3 -0
- package/src/services/messageTransportBridge.d.ts.map +1 -0
- package/src/types.d.ts +4 -0
- package/src/types.d.ts.map +1 -1
package/index.cjs.js
CHANGED
|
@@ -4,6 +4,7 @@ var core = require('@dynamic-labs-wallet/core');
|
|
|
4
4
|
var web = require('./internal/web');
|
|
5
5
|
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
6
6
|
var logger$1 = require('@dynamic-labs/logger');
|
|
7
|
+
var messageTransport = require('@dynamic-labs/message-transport');
|
|
7
8
|
|
|
8
9
|
function _extends() {
|
|
9
10
|
_extends = Object.assign || function assign(target) {
|
|
@@ -433,6 +434,88 @@ const localStorageWriteTest = {
|
|
|
433
434
|
}
|
|
434
435
|
});
|
|
435
436
|
|
|
437
|
+
/**
|
|
438
|
+
* StorageRequestChannelAdapter.getItem() sends a message within host domain
|
|
439
|
+
* the bridge on host will capture this request and forwards it to the iframe via contentWindow.postMessage()
|
|
440
|
+
*/ class StorageRequestChannelAdapter {
|
|
441
|
+
async getItem(key) {
|
|
442
|
+
const item = await this.requestChannel.request('getItem', {
|
|
443
|
+
source: 'localStorage',
|
|
444
|
+
key
|
|
445
|
+
});
|
|
446
|
+
return item ? JSON.parse(item) : null;
|
|
447
|
+
}
|
|
448
|
+
async setItem(key, value) {
|
|
449
|
+
const stringifiedValue = typeof value === 'object' ? JSON.stringify(value) : value;
|
|
450
|
+
return this.requestChannel.request('setItem', {
|
|
451
|
+
source: 'localStorage',
|
|
452
|
+
key,
|
|
453
|
+
data: stringifiedValue
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
async removeItem(key) {
|
|
457
|
+
return this.requestChannel.request('deleteItem', {
|
|
458
|
+
source: 'localStorage',
|
|
459
|
+
key
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
constructor(messageTransport$1){
|
|
463
|
+
this.requestChannel = messageTransport.createRequestChannel(messageTransport$1);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
const setupMessageTransportBridge = (messageTransport$1, iframe, iframeOrigin)=>{
|
|
468
|
+
if (!(iframe == null ? void 0 : iframe.contentWindow)) {
|
|
469
|
+
throw new Error('Iframe or contentWindow not available');
|
|
470
|
+
}
|
|
471
|
+
const logger = new logger$1.Logger('debug');
|
|
472
|
+
messageTransport$1.on((message)=>{
|
|
473
|
+
// Forward the message to webview via postMessage
|
|
474
|
+
if (message.origin === 'host') {
|
|
475
|
+
var _iframe_contentWindow;
|
|
476
|
+
iframe == null ? void 0 : (_iframe_contentWindow = iframe.contentWindow) == null ? void 0 : _iframe_contentWindow.postMessage(message, iframeOrigin);
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
const handleIncomingMessage = (message)=>{
|
|
480
|
+
const { data } = message;
|
|
481
|
+
if (!data) return;
|
|
482
|
+
if ((data == null ? void 0 : data.origin) !== 'webview') {
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
if (typeof data !== 'object') {
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
try {
|
|
489
|
+
const message = messageTransport.parseMessageTransportData(data);
|
|
490
|
+
messageTransport$1.emit(message);
|
|
491
|
+
} catch (error) {
|
|
492
|
+
if (!(error instanceof SyntaxError)) {
|
|
493
|
+
logger.error('Error handling incoming message:', error);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
/**
|
|
498
|
+
* Handle incoming message from android client
|
|
499
|
+
*/ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
500
|
+
// @ts-ignore
|
|
501
|
+
document.addEventListener('message', handleIncomingMessage);
|
|
502
|
+
/**
|
|
503
|
+
* Handle incoming message from iOS client
|
|
504
|
+
*/ window.addEventListener('message', handleIncomingMessage);
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
class IframeDisplayChannelAdapter {
|
|
508
|
+
async displayClientShares(clientKeyShares) {
|
|
509
|
+
await this.requestChannel.request('displayClientShares', clientKeyShares);
|
|
510
|
+
}
|
|
511
|
+
async displayPrivateKey(privateKey) {
|
|
512
|
+
await this.requestChannel.request('displayPrivateKey', privateKey);
|
|
513
|
+
}
|
|
514
|
+
constructor(messageTransport$1){
|
|
515
|
+
this.requestChannel = messageTransport.createRequestChannel(messageTransport$1);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
436
519
|
/**
|
|
437
520
|
* Updates the wallet map with backup information after successful backup to Google Drive
|
|
438
521
|
* @param data - Response data containing key shares information
|
|
@@ -495,11 +578,197 @@ class DynamicWalletClient {
|
|
|
495
578
|
return result;
|
|
496
579
|
}
|
|
497
580
|
/**
|
|
581
|
+
* Initializes the iframe display for a specific container.
|
|
582
|
+
*
|
|
583
|
+
* @param {HTMLElement} container - The container to which the iframe will be attached.
|
|
584
|
+
* @returns {Promise<{
|
|
585
|
+
* iframe: HTMLIFrameElement;
|
|
586
|
+
* iframeDisplay: IframeDisplayChannelAdapter;
|
|
587
|
+
* cleanup: () => void;
|
|
588
|
+
* }>} A promise that resolves when the iframe is loaded.
|
|
589
|
+
*/ async initializeIframeDisplayForContainer({ container }) {
|
|
590
|
+
try {
|
|
591
|
+
const iframe = await this.loadIframeForContainer(container);
|
|
592
|
+
const transport = messageTransport.applyDefaultMessageOrigin({
|
|
593
|
+
defaultOrigin: 'host',
|
|
594
|
+
messageTransport: messageTransport.createMessageTransport()
|
|
595
|
+
});
|
|
596
|
+
setupMessageTransportBridge(transport, iframe, this.iframeDomain);
|
|
597
|
+
const iframeDisplay = new IframeDisplayChannelAdapter(transport);
|
|
598
|
+
return {
|
|
599
|
+
iframe,
|
|
600
|
+
iframeDisplay,
|
|
601
|
+
cleanup: ()=>{
|
|
602
|
+
container.removeChild(iframe);
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
} catch (error) {
|
|
606
|
+
this.logger.error('Error initializing iframe:', error);
|
|
607
|
+
throw error;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* this is called on class construction time
|
|
612
|
+
* @returns {Promise<void>} that resolves when the iframe is loaded and the message transport and iframe storage are initialized
|
|
613
|
+
*/ initializeIframeCommunication() {
|
|
614
|
+
if (!this.iframeLoadPromise) {
|
|
615
|
+
this.iframeLoadPromise = this.doInitializeIframeCommunication();
|
|
616
|
+
}
|
|
617
|
+
return this.iframeLoadPromise;
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* initialize the iframe communication by awaiting the iframe load promise
|
|
621
|
+
* and initializing the message transport and iframe storage after iframe is successfully loaded
|
|
622
|
+
*/ async doInitializeIframeCommunication() {
|
|
623
|
+
try {
|
|
624
|
+
await this.loadIframe();
|
|
625
|
+
this.initializeMessageTransport();
|
|
626
|
+
this.initializeIframeStorage();
|
|
627
|
+
} catch (error) {
|
|
628
|
+
this.logger.error('Error initializing iframe:', error);
|
|
629
|
+
throw error;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* create a promise to load an iframe
|
|
634
|
+
* @returns {Promise<void>} that resolves when the iframe is loaded
|
|
635
|
+
*/ loadIframe() {
|
|
636
|
+
return new Promise((resolve, reject)=>{
|
|
637
|
+
const iframe = document.createElement('iframe');
|
|
638
|
+
const iframeTimeoutId = setTimeout(()=>{
|
|
639
|
+
reject(new Error('Iframe load timeout'));
|
|
640
|
+
}, 10000);
|
|
641
|
+
iframe.style.display = 'none';
|
|
642
|
+
iframe.setAttribute('title', 'Dynamic Wallet Iframe');
|
|
643
|
+
iframe.setAttribute('referrerpolicy', 'origin');
|
|
644
|
+
iframe.style.position = 'fixed';
|
|
645
|
+
iframe.style.top = '0';
|
|
646
|
+
iframe.style.left = '0';
|
|
647
|
+
iframe.style.width = '0';
|
|
648
|
+
iframe.style.height = '0';
|
|
649
|
+
iframe.style.border = 'none';
|
|
650
|
+
iframe.style.pointerEvents = 'none';
|
|
651
|
+
const params = new URLSearchParams({
|
|
652
|
+
instanceId: this.instanceId,
|
|
653
|
+
hostOrigin: window.location.origin
|
|
654
|
+
});
|
|
655
|
+
iframe.src = `${this.iframeDomain}/waas/${this.environmentId}?${params.toString()}`;
|
|
656
|
+
this.logger.debug('Creating iframe with src:', iframe.src);
|
|
657
|
+
document.body.appendChild(iframe);
|
|
658
|
+
iframe.onload = ()=>{
|
|
659
|
+
clearTimeout(iframeTimeoutId);
|
|
660
|
+
this.logger.debug('Iframe loaded successfully');
|
|
661
|
+
this.iframe = iframe;
|
|
662
|
+
resolve();
|
|
663
|
+
};
|
|
664
|
+
iframe.onerror = (error)=>{
|
|
665
|
+
clearTimeout(iframeTimeoutId);
|
|
666
|
+
this.logger.error('Iframe failed to load:', error);
|
|
667
|
+
reject(new Error('Failed to load iframe'));
|
|
668
|
+
};
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Load an iframe for a specific container
|
|
673
|
+
* @param {HTMLElement} container - The container to which the iframe will be attached
|
|
674
|
+
* @returns {Promise<HTMLIFrameElement>} that resolves when the iframe is loaded
|
|
675
|
+
*/ loadIframeForContainer(container) {
|
|
676
|
+
return new Promise((resolve, reject)=>{
|
|
677
|
+
const iframe = document.createElement('iframe');
|
|
678
|
+
const iframeTimeoutId = setTimeout(()=>{
|
|
679
|
+
reject(new Error('Iframe load timeout'));
|
|
680
|
+
}, 10000);
|
|
681
|
+
iframe.style.display = 'block';
|
|
682
|
+
iframe.style.width = '100%';
|
|
683
|
+
iframe.style.height = '100%';
|
|
684
|
+
iframe.setAttribute('title', 'Dynamic Wallet Storage');
|
|
685
|
+
iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin');
|
|
686
|
+
iframe.setAttribute('referrerpolicy', 'origin');
|
|
687
|
+
const params = new URLSearchParams({
|
|
688
|
+
instanceId: this.instanceId,
|
|
689
|
+
hostOrigin: window.location.origin
|
|
690
|
+
});
|
|
691
|
+
iframe.src = `${this.iframeDomain}/waas/${this.environmentId}?${params.toString()}`;
|
|
692
|
+
this.logger.debug('Creating iframe with src:', iframe.src);
|
|
693
|
+
// Add iframe to the provided container
|
|
694
|
+
container.appendChild(iframe);
|
|
695
|
+
iframe.onload = ()=>{
|
|
696
|
+
clearTimeout(iframeTimeoutId);
|
|
697
|
+
this.logger.debug('Iframe loaded successfully');
|
|
698
|
+
this.iframe = iframe;
|
|
699
|
+
resolve(iframe);
|
|
700
|
+
};
|
|
701
|
+
iframe.onerror = (error)=>{
|
|
702
|
+
clearTimeout(iframeTimeoutId);
|
|
703
|
+
this.logger.error('Iframe failed to load:', error);
|
|
704
|
+
reject(new Error('Failed to load iframe'));
|
|
705
|
+
};
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* initialize the message transport after iframe is successfully loaded
|
|
710
|
+
*/ initializeMessageTransport() {
|
|
711
|
+
const transport = messageTransport.applyDefaultMessageOrigin({
|
|
712
|
+
defaultOrigin: 'host',
|
|
713
|
+
messageTransport: messageTransport.createMessageTransport()
|
|
714
|
+
});
|
|
715
|
+
this.messageTransport = transport;
|
|
716
|
+
if (!this.iframe) {
|
|
717
|
+
throw new Error('Iframe not available');
|
|
718
|
+
}
|
|
719
|
+
setupMessageTransportBridge(this.messageTransport, this.iframe, this.iframeDomain);
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* initialize the iframe storage after iframe is successfully loaded
|
|
723
|
+
*/ initializeIframeStorage() {
|
|
724
|
+
if (!this.messageTransport) {
|
|
725
|
+
throw new Error('Message transport not initialized');
|
|
726
|
+
}
|
|
727
|
+
this.iframeStorage = new StorageRequestChannelAdapter(this.messageTransport);
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Gets the initialized iframe instance. This method ensures the iframe is properly loaded and configured.
|
|
731
|
+
* The first call will initialize and await the iframe loading process.
|
|
732
|
+
* Subsequent calls will return the same iframe instance immediately.
|
|
733
|
+
*
|
|
734
|
+
* @throws {Error} If iframe initialization fails
|
|
735
|
+
* @throws {Error} If message transport initialization fails
|
|
736
|
+
* @throws {Error} If iframe storage initialization fails
|
|
737
|
+
* @returns {Promise<HTMLIFrameElement>} The initialized iframe element
|
|
738
|
+
*/ async getIframe() {
|
|
739
|
+
await this.initializeIframeCommunication();
|
|
740
|
+
if (!this.iframe) {
|
|
741
|
+
throw new Error('Failed to initialize iframe');
|
|
742
|
+
}
|
|
743
|
+
if (!this.messageTransport) {
|
|
744
|
+
throw new Error('Failed to initialize message transport');
|
|
745
|
+
}
|
|
746
|
+
if (!this.iframeStorage) {
|
|
747
|
+
throw new Error('Failed to initialize iframe storage');
|
|
748
|
+
}
|
|
749
|
+
return this.iframe;
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Gets the initialized iframe storage instance. This method ensures the iframe storage is properly configured.
|
|
753
|
+
* The first call will initialize and await the iframe communication process.
|
|
754
|
+
* Subsequent calls will return the same storage instance immediately.
|
|
755
|
+
*
|
|
756
|
+
* @throws {Error} If iframe storage initialization fails
|
|
757
|
+
* @returns {Promise<SupportedStorage>} The initialized iframe storage instance
|
|
758
|
+
*/ async getIframeStorage() {
|
|
759
|
+
await this.initializeIframeCommunication();
|
|
760
|
+
if (!this.iframeStorage) {
|
|
761
|
+
throw new Error('Failed to initialize iframe storage');
|
|
762
|
+
}
|
|
763
|
+
return this.iframeStorage;
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
498
766
|
* Client initialization logic
|
|
499
767
|
*/ async _initialize() {
|
|
500
768
|
try {
|
|
501
769
|
const initializePromises = [
|
|
502
|
-
this.restoreWallets()
|
|
770
|
+
this.restoreWallets(),
|
|
771
|
+
this.initializeIframeCommunication()
|
|
503
772
|
];
|
|
504
773
|
await Promise.all(initializePromises);
|
|
505
774
|
return {
|
|
@@ -754,6 +1023,7 @@ class DynamicWalletClient {
|
|
|
754
1023
|
accountAddress,
|
|
755
1024
|
password: password != null ? password : this.environmentId
|
|
756
1025
|
});
|
|
1026
|
+
return refreshResults;
|
|
757
1027
|
}
|
|
758
1028
|
async getExportId({ chainName, clientKeyShare }) {
|
|
759
1029
|
const mpcSigner = getMPCSigner({
|
|
@@ -866,6 +1136,7 @@ class DynamicWalletClient {
|
|
|
866
1136
|
accountAddress,
|
|
867
1137
|
password
|
|
868
1138
|
});
|
|
1139
|
+
return reshareResults;
|
|
869
1140
|
}
|
|
870
1141
|
async exportKey({ accountAddress, chainName, password = undefined }) {
|
|
871
1142
|
const wallet = await this.getWallet({
|
|
@@ -958,20 +1229,15 @@ class DynamicWalletClient {
|
|
|
958
1229
|
/**
|
|
959
1230
|
* helper function to store encrypted backup by wallet from iframe local storage
|
|
960
1231
|
*/ async getClientKeySharesFromLocalStorage({ accountAddress }) {
|
|
961
|
-
var
|
|
962
|
-
|
|
1232
|
+
var _this_iframeStorage;
|
|
1233
|
+
await this.initializeIframeCommunication();
|
|
1234
|
+
const walletObject = await ((_this_iframeStorage = this.iframeStorage) == null ? void 0 : _this_iframeStorage.getItem(accountAddress));
|
|
963
1235
|
if (!walletObject) {
|
|
964
1236
|
this.logger.debug(`No item found in iframe local storage for accountAddress: ${accountAddress}`);
|
|
965
1237
|
return [];
|
|
966
1238
|
}
|
|
967
1239
|
try {
|
|
968
|
-
|
|
969
|
-
if (typeof walletObject === 'string') {
|
|
970
|
-
parsedWalletObject = JSON.parse(walletObject);
|
|
971
|
-
} else {
|
|
972
|
-
parsedWalletObject = walletObject;
|
|
973
|
-
}
|
|
974
|
-
return (parsedWalletObject == null ? void 0 : parsedWalletObject.clientKeyShares) || [];
|
|
1240
|
+
return (walletObject == null ? void 0 : walletObject.clientKeyShares) || [];
|
|
975
1241
|
} catch (error) {
|
|
976
1242
|
this.logger.error(`Error parsing clientKeyShares: ${error} for accountAddress: ${accountAddress}`);
|
|
977
1243
|
return [];
|
|
@@ -980,13 +1246,13 @@ class DynamicWalletClient {
|
|
|
980
1246
|
/**
|
|
981
1247
|
* helper function to store encrypted backup by wallet from iframe local storage
|
|
982
1248
|
*/ async setClientKeySharesToLocalStorage({ accountAddress, clientKeyShares, overwriteOrMerge = 'merge' }) {
|
|
983
|
-
var
|
|
984
|
-
|
|
1249
|
+
var _this_iframeStorage;
|
|
1250
|
+
await this.initializeIframeCommunication();
|
|
1251
|
+
await ((_this_iframeStorage = this.iframeStorage) == null ? void 0 : _this_iframeStorage.setItem(accountAddress, {
|
|
985
1252
|
clientKeyShares: overwriteOrMerge === 'overwrite' ? clientKeyShares : mergeUniqueKeyShares(await this.getClientKeySharesFromLocalStorage({
|
|
986
1253
|
accountAddress
|
|
987
1254
|
}), clientKeyShares)
|
|
988
|
-
});
|
|
989
|
-
await ((_this_storage = this.storage) == null ? void 0 : _this_storage.setItem(accountAddress, stringifiedClientKeyShares));
|
|
1255
|
+
}));
|
|
990
1256
|
}
|
|
991
1257
|
/**
|
|
992
1258
|
* Encrypts and stores wallet key shares as backups.
|
|
@@ -1208,7 +1474,7 @@ class DynamicWalletClient {
|
|
|
1208
1474
|
storageKey: this.storageKey
|
|
1209
1475
|
});
|
|
1210
1476
|
}
|
|
1211
|
-
async restoreBackupFromGoogleDrive({ accountAddress, password }) {
|
|
1477
|
+
async restoreBackupFromGoogleDrive({ accountAddress, displayContainer, password }) {
|
|
1212
1478
|
await this.getWallet({
|
|
1213
1479
|
accountAddress
|
|
1214
1480
|
});
|
|
@@ -1260,6 +1526,11 @@ class DynamicWalletClient {
|
|
|
1260
1526
|
clientKeyShares: decryptedKeyShares,
|
|
1261
1527
|
overwriteOrMerge: 'merge'
|
|
1262
1528
|
});
|
|
1529
|
+
// Display the client shares in the container via iframe
|
|
1530
|
+
const { iframeDisplay } = await this.initializeIframeDisplayForContainer({
|
|
1531
|
+
container: displayContainer
|
|
1532
|
+
});
|
|
1533
|
+
iframeDisplay.displayClientShares(keyShares);
|
|
1263
1534
|
return decryptedKeyShares;
|
|
1264
1535
|
}
|
|
1265
1536
|
async exportClientKeyshares({ accountAddress, password }) {
|
|
@@ -1531,8 +1802,12 @@ class DynamicWalletClient {
|
|
|
1531
1802
|
this.logger = logger;
|
|
1532
1803
|
this.walletMap = {} // todo: store in session storage
|
|
1533
1804
|
;
|
|
1805
|
+
this.iframeStorage = null;
|
|
1806
|
+
this.iframeDisplay = null;
|
|
1534
1807
|
this.memoryStorage = null;
|
|
1808
|
+
this.messageTransport = null;
|
|
1535
1809
|
this.iframe = null;
|
|
1810
|
+
this.iframeLoadPromise = null;
|
|
1536
1811
|
this.environmentId = environmentId;
|
|
1537
1812
|
this.storageKey = `${STORAGE_KEY}-${storageKey != null ? storageKey : environmentId}`;
|
|
1538
1813
|
this.baseMPCRelayApiUrl = baseMPCRelayApiUrl;
|
package/index.esm.js
CHANGED
|
@@ -4,6 +4,7 @@ import { BIP340, ExportableEd25519, Ecdsa, MessageHash, EcdsaKeygenResult, Expor
|
|
|
4
4
|
export { BIP340, BIP340InitKeygenResult, BIP340KeygenResult, Ecdsa, EcdsaInitKeygenResult, EcdsaKeygenResult, EcdsaPublicKey, EcdsaSignature, Ed25519, Ed25519InitKeygenResult, Ed25519KeygenResult, MessageHash } from './internal/web';
|
|
5
5
|
import { ProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
6
6
|
import { Logger } from '@dynamic-labs/logger';
|
|
7
|
+
import { createRequestChannel, parseMessageTransportData, applyDefaultMessageOrigin, createMessageTransport } from '@dynamic-labs/message-transport';
|
|
7
8
|
|
|
8
9
|
function _extends() {
|
|
9
10
|
_extends = Object.assign || function assign(target) {
|
|
@@ -433,6 +434,88 @@ const localStorageWriteTest = {
|
|
|
433
434
|
}
|
|
434
435
|
});
|
|
435
436
|
|
|
437
|
+
/**
|
|
438
|
+
* StorageRequestChannelAdapter.getItem() sends a message within host domain
|
|
439
|
+
* the bridge on host will capture this request and forwards it to the iframe via contentWindow.postMessage()
|
|
440
|
+
*/ class StorageRequestChannelAdapter {
|
|
441
|
+
async getItem(key) {
|
|
442
|
+
const item = await this.requestChannel.request('getItem', {
|
|
443
|
+
source: 'localStorage',
|
|
444
|
+
key
|
|
445
|
+
});
|
|
446
|
+
return item ? JSON.parse(item) : null;
|
|
447
|
+
}
|
|
448
|
+
async setItem(key, value) {
|
|
449
|
+
const stringifiedValue = typeof value === 'object' ? JSON.stringify(value) : value;
|
|
450
|
+
return this.requestChannel.request('setItem', {
|
|
451
|
+
source: 'localStorage',
|
|
452
|
+
key,
|
|
453
|
+
data: stringifiedValue
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
async removeItem(key) {
|
|
457
|
+
return this.requestChannel.request('deleteItem', {
|
|
458
|
+
source: 'localStorage',
|
|
459
|
+
key
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
constructor(messageTransport){
|
|
463
|
+
this.requestChannel = createRequestChannel(messageTransport);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
const setupMessageTransportBridge = (messageTransport, iframe, iframeOrigin)=>{
|
|
468
|
+
if (!(iframe == null ? void 0 : iframe.contentWindow)) {
|
|
469
|
+
throw new Error('Iframe or contentWindow not available');
|
|
470
|
+
}
|
|
471
|
+
const logger = new Logger('debug');
|
|
472
|
+
messageTransport.on((message)=>{
|
|
473
|
+
// Forward the message to webview via postMessage
|
|
474
|
+
if (message.origin === 'host') {
|
|
475
|
+
var _iframe_contentWindow;
|
|
476
|
+
iframe == null ? void 0 : (_iframe_contentWindow = iframe.contentWindow) == null ? void 0 : _iframe_contentWindow.postMessage(message, iframeOrigin);
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
const handleIncomingMessage = (message)=>{
|
|
480
|
+
const { data } = message;
|
|
481
|
+
if (!data) return;
|
|
482
|
+
if ((data == null ? void 0 : data.origin) !== 'webview') {
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
if (typeof data !== 'object') {
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
try {
|
|
489
|
+
const message = parseMessageTransportData(data);
|
|
490
|
+
messageTransport.emit(message);
|
|
491
|
+
} catch (error) {
|
|
492
|
+
if (!(error instanceof SyntaxError)) {
|
|
493
|
+
logger.error('Error handling incoming message:', error);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
/**
|
|
498
|
+
* Handle incoming message from android client
|
|
499
|
+
*/ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
500
|
+
// @ts-ignore
|
|
501
|
+
document.addEventListener('message', handleIncomingMessage);
|
|
502
|
+
/**
|
|
503
|
+
* Handle incoming message from iOS client
|
|
504
|
+
*/ window.addEventListener('message', handleIncomingMessage);
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
class IframeDisplayChannelAdapter {
|
|
508
|
+
async displayClientShares(clientKeyShares) {
|
|
509
|
+
await this.requestChannel.request('displayClientShares', clientKeyShares);
|
|
510
|
+
}
|
|
511
|
+
async displayPrivateKey(privateKey) {
|
|
512
|
+
await this.requestChannel.request('displayPrivateKey', privateKey);
|
|
513
|
+
}
|
|
514
|
+
constructor(messageTransport){
|
|
515
|
+
this.requestChannel = createRequestChannel(messageTransport);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
436
519
|
/**
|
|
437
520
|
* Updates the wallet map with backup information after successful backup to Google Drive
|
|
438
521
|
* @param data - Response data containing key shares information
|
|
@@ -495,11 +578,197 @@ class DynamicWalletClient {
|
|
|
495
578
|
return result;
|
|
496
579
|
}
|
|
497
580
|
/**
|
|
581
|
+
* Initializes the iframe display for a specific container.
|
|
582
|
+
*
|
|
583
|
+
* @param {HTMLElement} container - The container to which the iframe will be attached.
|
|
584
|
+
* @returns {Promise<{
|
|
585
|
+
* iframe: HTMLIFrameElement;
|
|
586
|
+
* iframeDisplay: IframeDisplayChannelAdapter;
|
|
587
|
+
* cleanup: () => void;
|
|
588
|
+
* }>} A promise that resolves when the iframe is loaded.
|
|
589
|
+
*/ async initializeIframeDisplayForContainer({ container }) {
|
|
590
|
+
try {
|
|
591
|
+
const iframe = await this.loadIframeForContainer(container);
|
|
592
|
+
const transport = applyDefaultMessageOrigin({
|
|
593
|
+
defaultOrigin: 'host',
|
|
594
|
+
messageTransport: createMessageTransport()
|
|
595
|
+
});
|
|
596
|
+
setupMessageTransportBridge(transport, iframe, this.iframeDomain);
|
|
597
|
+
const iframeDisplay = new IframeDisplayChannelAdapter(transport);
|
|
598
|
+
return {
|
|
599
|
+
iframe,
|
|
600
|
+
iframeDisplay,
|
|
601
|
+
cleanup: ()=>{
|
|
602
|
+
container.removeChild(iframe);
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
} catch (error) {
|
|
606
|
+
this.logger.error('Error initializing iframe:', error);
|
|
607
|
+
throw error;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* this is called on class construction time
|
|
612
|
+
* @returns {Promise<void>} that resolves when the iframe is loaded and the message transport and iframe storage are initialized
|
|
613
|
+
*/ initializeIframeCommunication() {
|
|
614
|
+
if (!this.iframeLoadPromise) {
|
|
615
|
+
this.iframeLoadPromise = this.doInitializeIframeCommunication();
|
|
616
|
+
}
|
|
617
|
+
return this.iframeLoadPromise;
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* initialize the iframe communication by awaiting the iframe load promise
|
|
621
|
+
* and initializing the message transport and iframe storage after iframe is successfully loaded
|
|
622
|
+
*/ async doInitializeIframeCommunication() {
|
|
623
|
+
try {
|
|
624
|
+
await this.loadIframe();
|
|
625
|
+
this.initializeMessageTransport();
|
|
626
|
+
this.initializeIframeStorage();
|
|
627
|
+
} catch (error) {
|
|
628
|
+
this.logger.error('Error initializing iframe:', error);
|
|
629
|
+
throw error;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* create a promise to load an iframe
|
|
634
|
+
* @returns {Promise<void>} that resolves when the iframe is loaded
|
|
635
|
+
*/ loadIframe() {
|
|
636
|
+
return new Promise((resolve, reject)=>{
|
|
637
|
+
const iframe = document.createElement('iframe');
|
|
638
|
+
const iframeTimeoutId = setTimeout(()=>{
|
|
639
|
+
reject(new Error('Iframe load timeout'));
|
|
640
|
+
}, 10000);
|
|
641
|
+
iframe.style.display = 'none';
|
|
642
|
+
iframe.setAttribute('title', 'Dynamic Wallet Iframe');
|
|
643
|
+
iframe.setAttribute('referrerpolicy', 'origin');
|
|
644
|
+
iframe.style.position = 'fixed';
|
|
645
|
+
iframe.style.top = '0';
|
|
646
|
+
iframe.style.left = '0';
|
|
647
|
+
iframe.style.width = '0';
|
|
648
|
+
iframe.style.height = '0';
|
|
649
|
+
iframe.style.border = 'none';
|
|
650
|
+
iframe.style.pointerEvents = 'none';
|
|
651
|
+
const params = new URLSearchParams({
|
|
652
|
+
instanceId: this.instanceId,
|
|
653
|
+
hostOrigin: window.location.origin
|
|
654
|
+
});
|
|
655
|
+
iframe.src = `${this.iframeDomain}/waas/${this.environmentId}?${params.toString()}`;
|
|
656
|
+
this.logger.debug('Creating iframe with src:', iframe.src);
|
|
657
|
+
document.body.appendChild(iframe);
|
|
658
|
+
iframe.onload = ()=>{
|
|
659
|
+
clearTimeout(iframeTimeoutId);
|
|
660
|
+
this.logger.debug('Iframe loaded successfully');
|
|
661
|
+
this.iframe = iframe;
|
|
662
|
+
resolve();
|
|
663
|
+
};
|
|
664
|
+
iframe.onerror = (error)=>{
|
|
665
|
+
clearTimeout(iframeTimeoutId);
|
|
666
|
+
this.logger.error('Iframe failed to load:', error);
|
|
667
|
+
reject(new Error('Failed to load iframe'));
|
|
668
|
+
};
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Load an iframe for a specific container
|
|
673
|
+
* @param {HTMLElement} container - The container to which the iframe will be attached
|
|
674
|
+
* @returns {Promise<HTMLIFrameElement>} that resolves when the iframe is loaded
|
|
675
|
+
*/ loadIframeForContainer(container) {
|
|
676
|
+
return new Promise((resolve, reject)=>{
|
|
677
|
+
const iframe = document.createElement('iframe');
|
|
678
|
+
const iframeTimeoutId = setTimeout(()=>{
|
|
679
|
+
reject(new Error('Iframe load timeout'));
|
|
680
|
+
}, 10000);
|
|
681
|
+
iframe.style.display = 'block';
|
|
682
|
+
iframe.style.width = '100%';
|
|
683
|
+
iframe.style.height = '100%';
|
|
684
|
+
iframe.setAttribute('title', 'Dynamic Wallet Storage');
|
|
685
|
+
iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin');
|
|
686
|
+
iframe.setAttribute('referrerpolicy', 'origin');
|
|
687
|
+
const params = new URLSearchParams({
|
|
688
|
+
instanceId: this.instanceId,
|
|
689
|
+
hostOrigin: window.location.origin
|
|
690
|
+
});
|
|
691
|
+
iframe.src = `${this.iframeDomain}/waas/${this.environmentId}?${params.toString()}`;
|
|
692
|
+
this.logger.debug('Creating iframe with src:', iframe.src);
|
|
693
|
+
// Add iframe to the provided container
|
|
694
|
+
container.appendChild(iframe);
|
|
695
|
+
iframe.onload = ()=>{
|
|
696
|
+
clearTimeout(iframeTimeoutId);
|
|
697
|
+
this.logger.debug('Iframe loaded successfully');
|
|
698
|
+
this.iframe = iframe;
|
|
699
|
+
resolve(iframe);
|
|
700
|
+
};
|
|
701
|
+
iframe.onerror = (error)=>{
|
|
702
|
+
clearTimeout(iframeTimeoutId);
|
|
703
|
+
this.logger.error('Iframe failed to load:', error);
|
|
704
|
+
reject(new Error('Failed to load iframe'));
|
|
705
|
+
};
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* initialize the message transport after iframe is successfully loaded
|
|
710
|
+
*/ initializeMessageTransport() {
|
|
711
|
+
const transport = applyDefaultMessageOrigin({
|
|
712
|
+
defaultOrigin: 'host',
|
|
713
|
+
messageTransport: createMessageTransport()
|
|
714
|
+
});
|
|
715
|
+
this.messageTransport = transport;
|
|
716
|
+
if (!this.iframe) {
|
|
717
|
+
throw new Error('Iframe not available');
|
|
718
|
+
}
|
|
719
|
+
setupMessageTransportBridge(this.messageTransport, this.iframe, this.iframeDomain);
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* initialize the iframe storage after iframe is successfully loaded
|
|
723
|
+
*/ initializeIframeStorage() {
|
|
724
|
+
if (!this.messageTransport) {
|
|
725
|
+
throw new Error('Message transport not initialized');
|
|
726
|
+
}
|
|
727
|
+
this.iframeStorage = new StorageRequestChannelAdapter(this.messageTransport);
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Gets the initialized iframe instance. This method ensures the iframe is properly loaded and configured.
|
|
731
|
+
* The first call will initialize and await the iframe loading process.
|
|
732
|
+
* Subsequent calls will return the same iframe instance immediately.
|
|
733
|
+
*
|
|
734
|
+
* @throws {Error} If iframe initialization fails
|
|
735
|
+
* @throws {Error} If message transport initialization fails
|
|
736
|
+
* @throws {Error} If iframe storage initialization fails
|
|
737
|
+
* @returns {Promise<HTMLIFrameElement>} The initialized iframe element
|
|
738
|
+
*/ async getIframe() {
|
|
739
|
+
await this.initializeIframeCommunication();
|
|
740
|
+
if (!this.iframe) {
|
|
741
|
+
throw new Error('Failed to initialize iframe');
|
|
742
|
+
}
|
|
743
|
+
if (!this.messageTransport) {
|
|
744
|
+
throw new Error('Failed to initialize message transport');
|
|
745
|
+
}
|
|
746
|
+
if (!this.iframeStorage) {
|
|
747
|
+
throw new Error('Failed to initialize iframe storage');
|
|
748
|
+
}
|
|
749
|
+
return this.iframe;
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Gets the initialized iframe storage instance. This method ensures the iframe storage is properly configured.
|
|
753
|
+
* The first call will initialize and await the iframe communication process.
|
|
754
|
+
* Subsequent calls will return the same storage instance immediately.
|
|
755
|
+
*
|
|
756
|
+
* @throws {Error} If iframe storage initialization fails
|
|
757
|
+
* @returns {Promise<SupportedStorage>} The initialized iframe storage instance
|
|
758
|
+
*/ async getIframeStorage() {
|
|
759
|
+
await this.initializeIframeCommunication();
|
|
760
|
+
if (!this.iframeStorage) {
|
|
761
|
+
throw new Error('Failed to initialize iframe storage');
|
|
762
|
+
}
|
|
763
|
+
return this.iframeStorage;
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
498
766
|
* Client initialization logic
|
|
499
767
|
*/ async _initialize() {
|
|
500
768
|
try {
|
|
501
769
|
const initializePromises = [
|
|
502
|
-
this.restoreWallets()
|
|
770
|
+
this.restoreWallets(),
|
|
771
|
+
this.initializeIframeCommunication()
|
|
503
772
|
];
|
|
504
773
|
await Promise.all(initializePromises);
|
|
505
774
|
return {
|
|
@@ -754,6 +1023,7 @@ class DynamicWalletClient {
|
|
|
754
1023
|
accountAddress,
|
|
755
1024
|
password: password != null ? password : this.environmentId
|
|
756
1025
|
});
|
|
1026
|
+
return refreshResults;
|
|
757
1027
|
}
|
|
758
1028
|
async getExportId({ chainName, clientKeyShare }) {
|
|
759
1029
|
const mpcSigner = getMPCSigner({
|
|
@@ -866,6 +1136,7 @@ class DynamicWalletClient {
|
|
|
866
1136
|
accountAddress,
|
|
867
1137
|
password
|
|
868
1138
|
});
|
|
1139
|
+
return reshareResults;
|
|
869
1140
|
}
|
|
870
1141
|
async exportKey({ accountAddress, chainName, password = undefined }) {
|
|
871
1142
|
const wallet = await this.getWallet({
|
|
@@ -958,20 +1229,15 @@ class DynamicWalletClient {
|
|
|
958
1229
|
/**
|
|
959
1230
|
* helper function to store encrypted backup by wallet from iframe local storage
|
|
960
1231
|
*/ async getClientKeySharesFromLocalStorage({ accountAddress }) {
|
|
961
|
-
var
|
|
962
|
-
|
|
1232
|
+
var _this_iframeStorage;
|
|
1233
|
+
await this.initializeIframeCommunication();
|
|
1234
|
+
const walletObject = await ((_this_iframeStorage = this.iframeStorage) == null ? void 0 : _this_iframeStorage.getItem(accountAddress));
|
|
963
1235
|
if (!walletObject) {
|
|
964
1236
|
this.logger.debug(`No item found in iframe local storage for accountAddress: ${accountAddress}`);
|
|
965
1237
|
return [];
|
|
966
1238
|
}
|
|
967
1239
|
try {
|
|
968
|
-
|
|
969
|
-
if (typeof walletObject === 'string') {
|
|
970
|
-
parsedWalletObject = JSON.parse(walletObject);
|
|
971
|
-
} else {
|
|
972
|
-
parsedWalletObject = walletObject;
|
|
973
|
-
}
|
|
974
|
-
return (parsedWalletObject == null ? void 0 : parsedWalletObject.clientKeyShares) || [];
|
|
1240
|
+
return (walletObject == null ? void 0 : walletObject.clientKeyShares) || [];
|
|
975
1241
|
} catch (error) {
|
|
976
1242
|
this.logger.error(`Error parsing clientKeyShares: ${error} for accountAddress: ${accountAddress}`);
|
|
977
1243
|
return [];
|
|
@@ -980,13 +1246,13 @@ class DynamicWalletClient {
|
|
|
980
1246
|
/**
|
|
981
1247
|
* helper function to store encrypted backup by wallet from iframe local storage
|
|
982
1248
|
*/ async setClientKeySharesToLocalStorage({ accountAddress, clientKeyShares, overwriteOrMerge = 'merge' }) {
|
|
983
|
-
var
|
|
984
|
-
|
|
1249
|
+
var _this_iframeStorage;
|
|
1250
|
+
await this.initializeIframeCommunication();
|
|
1251
|
+
await ((_this_iframeStorage = this.iframeStorage) == null ? void 0 : _this_iframeStorage.setItem(accountAddress, {
|
|
985
1252
|
clientKeyShares: overwriteOrMerge === 'overwrite' ? clientKeyShares : mergeUniqueKeyShares(await this.getClientKeySharesFromLocalStorage({
|
|
986
1253
|
accountAddress
|
|
987
1254
|
}), clientKeyShares)
|
|
988
|
-
});
|
|
989
|
-
await ((_this_storage = this.storage) == null ? void 0 : _this_storage.setItem(accountAddress, stringifiedClientKeyShares));
|
|
1255
|
+
}));
|
|
990
1256
|
}
|
|
991
1257
|
/**
|
|
992
1258
|
* Encrypts and stores wallet key shares as backups.
|
|
@@ -1208,7 +1474,7 @@ class DynamicWalletClient {
|
|
|
1208
1474
|
storageKey: this.storageKey
|
|
1209
1475
|
});
|
|
1210
1476
|
}
|
|
1211
|
-
async restoreBackupFromGoogleDrive({ accountAddress, password }) {
|
|
1477
|
+
async restoreBackupFromGoogleDrive({ accountAddress, displayContainer, password }) {
|
|
1212
1478
|
await this.getWallet({
|
|
1213
1479
|
accountAddress
|
|
1214
1480
|
});
|
|
@@ -1260,6 +1526,11 @@ class DynamicWalletClient {
|
|
|
1260
1526
|
clientKeyShares: decryptedKeyShares,
|
|
1261
1527
|
overwriteOrMerge: 'merge'
|
|
1262
1528
|
});
|
|
1529
|
+
// Display the client shares in the container via iframe
|
|
1530
|
+
const { iframeDisplay } = await this.initializeIframeDisplayForContainer({
|
|
1531
|
+
container: displayContainer
|
|
1532
|
+
});
|
|
1533
|
+
iframeDisplay.displayClientShares(keyShares);
|
|
1263
1534
|
return decryptedKeyShares;
|
|
1264
1535
|
}
|
|
1265
1536
|
async exportClientKeyshares({ accountAddress, password }) {
|
|
@@ -1531,8 +1802,12 @@ class DynamicWalletClient {
|
|
|
1531
1802
|
this.logger = logger;
|
|
1532
1803
|
this.walletMap = {} // todo: store in session storage
|
|
1533
1804
|
;
|
|
1805
|
+
this.iframeStorage = null;
|
|
1806
|
+
this.iframeDisplay = null;
|
|
1534
1807
|
this.memoryStorage = null;
|
|
1808
|
+
this.messageTransport = null;
|
|
1535
1809
|
this.iframe = null;
|
|
1810
|
+
this.iframeLoadPromise = null;
|
|
1536
1811
|
this.environmentId = environmentId;
|
|
1537
1812
|
this.storageKey = `${STORAGE_KEY}-${storageKey != null ? storageKey : environmentId}`;
|
|
1538
1813
|
this.baseMPCRelayApiUrl = baseMPCRelayApiUrl;
|
package/package.json
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/browser",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.73",
|
|
4
4
|
"license": "Licensed under the Dynamic Labs, Inc. Terms Of Service (https://www.dynamic.xyz/terms-conditions)",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@dynamic-labs-wallet/core": "0.0.
|
|
6
|
+
"@dynamic-labs-wallet/core": "0.0.73",
|
|
7
7
|
"@dynamic-labs/logger": "^4.9.9",
|
|
8
|
+
"@dynamic-labs/message-transport": "^4.9.9",
|
|
9
|
+
"@dynamic-labs/sdk-api-core": "^0.0.663",
|
|
8
10
|
"@noble/hashes": "1.7.1"
|
|
9
11
|
},
|
|
10
|
-
"peerDependencies": {
|
|
11
|
-
"@dynamic-labs/sdk-api-core": "^0.0.663"
|
|
12
|
-
},
|
|
13
12
|
"files": [
|
|
14
13
|
"*",
|
|
15
14
|
"node_modules/**/*"
|
package/src/client.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ import { ExportableEd25519, type EcdsaPublicKey, EcdsaKeygenResult, BIP340Keygen
|
|
|
3
3
|
import type { ClientInitKeygenResult, ClientKeyShare } from './mpc/types';
|
|
4
4
|
import { type SupportedStorage } from './services/localStorage';
|
|
5
5
|
import type { WalletProperties } from './types';
|
|
6
|
+
import { type MessageTransportWithDefaultOrigin } from '@dynamic-labs/message-transport';
|
|
7
|
+
import { StorageRequestChannelAdapter } from './services/iframeLocalStorage';
|
|
8
|
+
import { IframeDisplayChannelAdapter } from './services/iframeDisplay';
|
|
6
9
|
export declare class DynamicWalletClient {
|
|
7
10
|
environmentId: string;
|
|
8
11
|
storageKey: string;
|
|
@@ -12,15 +15,85 @@ export declare class DynamicWalletClient {
|
|
|
12
15
|
protected apiClient: DynamicApiClient;
|
|
13
16
|
protected walletMap: Record<string, WalletProperties>;
|
|
14
17
|
protected storage: SupportedStorage;
|
|
18
|
+
protected iframeStorage: StorageRequestChannelAdapter | null;
|
|
19
|
+
protected iframeDisplay: IframeDisplayChannelAdapter | null;
|
|
15
20
|
protected memoryStorage: {
|
|
16
21
|
[key: string]: string;
|
|
17
22
|
} | null;
|
|
18
23
|
protected baseMPCRelayApiUrl?: string;
|
|
24
|
+
protected messageTransport: MessageTransportWithDefaultOrigin | null;
|
|
19
25
|
protected iframe: HTMLIFrameElement | null;
|
|
20
26
|
readonly instanceId: string;
|
|
21
27
|
readonly iframeDomain: string;
|
|
28
|
+
private iframeLoadPromise;
|
|
22
29
|
constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, storageKey, debug, }: DynamicWalletClientProps);
|
|
23
30
|
initialize(): Promise<InitializeResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Initializes the iframe display for a specific container.
|
|
33
|
+
*
|
|
34
|
+
* @param {HTMLElement} container - The container to which the iframe will be attached.
|
|
35
|
+
* @returns {Promise<{
|
|
36
|
+
* iframe: HTMLIFrameElement;
|
|
37
|
+
* iframeDisplay: IframeDisplayChannelAdapter;
|
|
38
|
+
* cleanup: () => void;
|
|
39
|
+
* }>} A promise that resolves when the iframe is loaded.
|
|
40
|
+
*/
|
|
41
|
+
initializeIframeDisplayForContainer({ container, }: {
|
|
42
|
+
container: HTMLElement;
|
|
43
|
+
}): Promise<{
|
|
44
|
+
iframe: HTMLIFrameElement;
|
|
45
|
+
iframeDisplay: IframeDisplayChannelAdapter;
|
|
46
|
+
cleanup: () => void;
|
|
47
|
+
}>;
|
|
48
|
+
/**
|
|
49
|
+
* this is called on class construction time
|
|
50
|
+
* @returns {Promise<void>} that resolves when the iframe is loaded and the message transport and iframe storage are initialized
|
|
51
|
+
*/
|
|
52
|
+
initializeIframeCommunication(): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* initialize the iframe communication by awaiting the iframe load promise
|
|
55
|
+
* and initializing the message transport and iframe storage after iframe is successfully loaded
|
|
56
|
+
*/
|
|
57
|
+
private doInitializeIframeCommunication;
|
|
58
|
+
/**
|
|
59
|
+
* create a promise to load an iframe
|
|
60
|
+
* @returns {Promise<void>} that resolves when the iframe is loaded
|
|
61
|
+
*/
|
|
62
|
+
private loadIframe;
|
|
63
|
+
/**
|
|
64
|
+
* Load an iframe for a specific container
|
|
65
|
+
* @param {HTMLElement} container - The container to which the iframe will be attached
|
|
66
|
+
* @returns {Promise<HTMLIFrameElement>} that resolves when the iframe is loaded
|
|
67
|
+
*/
|
|
68
|
+
private loadIframeForContainer;
|
|
69
|
+
/**
|
|
70
|
+
* initialize the message transport after iframe is successfully loaded
|
|
71
|
+
*/
|
|
72
|
+
private initializeMessageTransport;
|
|
73
|
+
/**
|
|
74
|
+
* initialize the iframe storage after iframe is successfully loaded
|
|
75
|
+
*/
|
|
76
|
+
private initializeIframeStorage;
|
|
77
|
+
/**
|
|
78
|
+
* Gets the initialized iframe instance. This method ensures the iframe is properly loaded and configured.
|
|
79
|
+
* The first call will initialize and await the iframe loading process.
|
|
80
|
+
* Subsequent calls will return the same iframe instance immediately.
|
|
81
|
+
*
|
|
82
|
+
* @throws {Error} If iframe initialization fails
|
|
83
|
+
* @throws {Error} If message transport initialization fails
|
|
84
|
+
* @throws {Error} If iframe storage initialization fails
|
|
85
|
+
* @returns {Promise<HTMLIFrameElement>} The initialized iframe element
|
|
86
|
+
*/
|
|
87
|
+
getIframe(): Promise<HTMLIFrameElement>;
|
|
88
|
+
/**
|
|
89
|
+
* Gets the initialized iframe storage instance. This method ensures the iframe storage is properly configured.
|
|
90
|
+
* The first call will initialize and await the iframe communication process.
|
|
91
|
+
* Subsequent calls will return the same storage instance immediately.
|
|
92
|
+
*
|
|
93
|
+
* @throws {Error} If iframe storage initialization fails
|
|
94
|
+
* @returns {Promise<SupportedStorage>} The initialized iframe storage instance
|
|
95
|
+
*/
|
|
96
|
+
getIframeStorage(): Promise<StorageRequestChannelAdapter>;
|
|
24
97
|
/**
|
|
25
98
|
* Client initialization logic
|
|
26
99
|
*/
|
|
@@ -94,7 +167,7 @@ export declare class DynamicWalletClient {
|
|
|
94
167
|
accountAddress: string;
|
|
95
168
|
chainName: string;
|
|
96
169
|
password?: string;
|
|
97
|
-
}): Promise<
|
|
170
|
+
}): Promise<(EcdsaKeygenResult | BIP340KeygenResult)[]>;
|
|
98
171
|
getExportId({ chainName, clientKeyShare, }: {
|
|
99
172
|
chainName: string;
|
|
100
173
|
clientKeyShare: EcdsaKeygenResult | ExportableEd25519 | BIP340KeygenResult;
|
|
@@ -131,7 +204,7 @@ export declare class DynamicWalletClient {
|
|
|
131
204
|
oldThresholdSignatureScheme: ThresholdSignatureScheme;
|
|
132
205
|
newThresholdSignatureScheme: ThresholdSignatureScheme;
|
|
133
206
|
password?: string;
|
|
134
|
-
}): Promise<
|
|
207
|
+
}): Promise<(EcdsaKeygenResult | BIP340KeygenResult)[]>;
|
|
135
208
|
exportKey({ accountAddress, chainName, password, }: {
|
|
136
209
|
accountAddress: string;
|
|
137
210
|
chainName: string;
|
|
@@ -242,10 +315,11 @@ export declare class DynamicWalletClient {
|
|
|
242
315
|
accountAddress: string;
|
|
243
316
|
password?: string;
|
|
244
317
|
}): Promise<void>;
|
|
245
|
-
restoreBackupFromGoogleDrive({ accountAddress, password, }: {
|
|
318
|
+
restoreBackupFromGoogleDrive({ accountAddress, displayContainer, password, }: {
|
|
246
319
|
accountAddress: string;
|
|
247
320
|
password?: string;
|
|
248
|
-
|
|
321
|
+
displayContainer: HTMLElement;
|
|
322
|
+
}): Promise<ClientKeyShare[] | null>;
|
|
249
323
|
exportClientKeyshares({ accountAddress, password, }: {
|
|
250
324
|
accountAddress: string;
|
|
251
325
|
password?: string;
|
package/src/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../packages/src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,wBAAwB,EAC7B,gBAAgB,EAIhB,cAAc,EAEd,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,eAAe,EAGhB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAEL,iBAAiB,EAEjB,KAAK,cAAc,EACnB,iBAAiB,EAEjB,kBAAkB,EAClB,KAAK,cAAc,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E,MAAM,CAAC;QAClB,eAAe,CAAC,EAAE,eAAe,CAAC;KACnC;IA6CK,mBAAmB,CAAC,EACxB,cAAc,GACf,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;KACxB,GAAG,OAAO,CAAC,OAAO,CAAC;IAMpB;;OAEG;IACG,4BAA4B,CAAC,EACjC,cAAc,EACd,eAAiD,GAClD,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;QACvB,eAAe,CAAC,EAAE,eAAe,CAAC;KACnC,GAAG,OAAO,CAAC,OAAO,CAAC;IAYpB;;OAEG;IACG,uCAAuC,CAAC,EAC5C,cAAc,EACd,eAAiD,GAClD,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;QACvB,eAAe,CAAC,EAAE,eAAe,CAAC;KACnC,GAAG,OAAO,CAAC,OAAO,CAAC;IAgCd,iCAAiC,CAAC,EACtC,cAAc,GACf,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;KACxB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAoBzB,SAAS,CAAC,EACd,cAAc,EACd,eAA8C,EAC9C,UAAsB,EACtB,QAAoB,GACrB,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;QACvB,eAAe,CAAC,EAAE,eAAe,CAAC;QAClC,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB;IA2EK,UAAU;CAkCjB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type MessageTransportWithDefaultOrigin, type RequestChannel } from '@dynamic-labs/message-transport';
|
|
2
|
+
import { DisplayMessages } from '../types';
|
|
3
|
+
export declare class IframeDisplayChannelAdapter {
|
|
4
|
+
requestChannel: RequestChannel<DisplayMessages>;
|
|
5
|
+
constructor(messageTransport: MessageTransportWithDefaultOrigin);
|
|
6
|
+
displayClientShares(clientKeyShares?: string[]): Promise<void>;
|
|
7
|
+
displayPrivateKey(privateKey: string): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=iframeDisplay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iframeDisplay.d.ts","sourceRoot":"","sources":["../../src/services/iframeDisplay.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iCAAiC,EACtC,KAAK,cAAc,EACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,qBAAa,2BAA2B;IACtC,cAAc,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;gBAEpC,gBAAgB,EAAE,iCAAiC;IAKzD,mBAAmB,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9D,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG3D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type MessageTransportWithDefaultOrigin, type RequestChannel, type StorageMessages } from '@dynamic-labs/message-transport';
|
|
2
|
+
/**
|
|
3
|
+
* StorageRequestChannelAdapter.getItem() sends a message within host domain
|
|
4
|
+
* the bridge on host will capture this request and forwards it to the iframe via contentWindow.postMessage()
|
|
5
|
+
*/
|
|
6
|
+
export declare class StorageRequestChannelAdapter {
|
|
7
|
+
requestChannel: RequestChannel<StorageMessages>;
|
|
8
|
+
constructor(messageTransport: MessageTransportWithDefaultOrigin);
|
|
9
|
+
getItem(key: string): Promise<string | object>;
|
|
10
|
+
setItem(key: string, value: string | object): Promise<void>;
|
|
11
|
+
removeItem(key: string): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=iframeLocalStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iframeLocalStorage.d.ts","sourceRoot":"","sources":["../../src/services/iframeLocalStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iCAAiC,EACtC,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,iCAAiC,CAAC;AACzC;;;GAGG;AACH,qBAAa,4BAA4B;IACvC,cAAc,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;gBAEpC,gBAAgB,EAAE,iCAAiC;IAKzD,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;IAQ9C,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3D,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAM7C"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type MessageTransportWithDefaultOrigin } from '@dynamic-labs/message-transport';
|
|
2
|
+
export declare const setupMessageTransportBridge: (messageTransport: MessageTransportWithDefaultOrigin, iframe: HTMLIFrameElement, iframeOrigin: string) => void;
|
|
3
|
+
//# sourceMappingURL=messageTransportBridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messageTransportBridge.d.ts","sourceRoot":"","sources":["../../src/services/messageTransportBridge.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iCAAiC,EAGvC,MAAM,iCAAiC,CAAC;AAGzC,eAAO,MAAM,2BAA2B,qBACpB,iCAAiC,UAC3C,iBAAiB,gBACX,MAAM,SAgDrB,CAAC"}
|
package/src/types.d.ts
CHANGED
|
@@ -7,4 +7,8 @@ export interface WalletProperties {
|
|
|
7
7
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
8
8
|
derivationPath?: string;
|
|
9
9
|
}
|
|
10
|
+
export type DisplayMessages = {
|
|
11
|
+
displayClientShares: (clientKeyShares?: string[]) => Promise<void>;
|
|
12
|
+
displayPrivateKey: (privateKey: string) => Promise<void>;
|
|
13
|
+
};
|
|
10
14
|
//# sourceMappingURL=types.d.ts.map
|
package/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../packages/src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACzB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,yBAAyB,EAAE,kBAAkB,CAAC;IAC9C,wBAAwB,EAAE,wBAAwB,CAAC;IACnD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../packages/src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACzB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,yBAAyB,EAAE,kBAAkB,CAAC;IAC9C,wBAAwB,EAAE,wBAAwB,CAAC;IACnD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,mBAAmB,EAAE,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,iBAAiB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D,CAAC"}
|