@dynamic-labs-wallet/browser 0.0.33 → 0.0.35
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 +195 -37
- package/index.esm.js +195 -37
- package/package.json +2 -2
- package/src/client.d.ts +57 -10
- package/src/client.d.ts.map +1 -1
- package/src/types.d.ts +3 -2
- package/src/types.d.ts.map +1 -1
package/index.cjs.js
CHANGED
|
@@ -356,6 +356,7 @@ var WalletOperation = /*#__PURE__*/ function(WalletOperation) {
|
|
|
356
356
|
WalletOperation["REFRESH"] = "REFRESH";
|
|
357
357
|
WalletOperation["RESHARE"] = "RESHARE";
|
|
358
358
|
WalletOperation["EXPORT_PRIVATE_KEY"] = "EXPORT_PRIVATE_KEY";
|
|
359
|
+
WalletOperation["NO_OPERATION"] = "NO_OPERATION";
|
|
359
360
|
return WalletOperation;
|
|
360
361
|
}({});
|
|
361
362
|
|
|
@@ -525,9 +526,16 @@ class DynamicWalletClient {
|
|
|
525
526
|
}
|
|
526
527
|
}
|
|
527
528
|
//todo: need to modify with imported flag
|
|
528
|
-
async sign({ accountAddress, message, chainName }) {
|
|
529
|
+
async sign({ accountAddress, message, chainName, password = undefined }) {
|
|
530
|
+
await this.verifyPassword({
|
|
531
|
+
accountAddress,
|
|
532
|
+
password,
|
|
533
|
+
walletOperation: WalletOperation.SIGN_MESSAGE
|
|
534
|
+
});
|
|
529
535
|
const wallet = await this.getWallet({
|
|
530
|
-
accountAddress
|
|
536
|
+
accountAddress,
|
|
537
|
+
password,
|
|
538
|
+
walletOperation: WalletOperation.SIGN_MESSAGE
|
|
531
539
|
});
|
|
532
540
|
// Perform the server sign
|
|
533
541
|
const data = await this.serverSign({
|
|
@@ -545,11 +553,17 @@ class DynamicWalletClient {
|
|
|
545
553
|
});
|
|
546
554
|
return signature;
|
|
547
555
|
}
|
|
548
|
-
async refreshWalletAccountShares({ accountAddress, chainName }) {
|
|
549
|
-
|
|
556
|
+
async refreshWalletAccountShares({ accountAddress, chainName, password = undefined }) {
|
|
557
|
+
await this.verifyPassword({
|
|
550
558
|
accountAddress,
|
|
559
|
+
password,
|
|
551
560
|
walletOperation: WalletOperation.REFRESH
|
|
552
561
|
});
|
|
562
|
+
const wallet = await this.getWallet({
|
|
563
|
+
accountAddress,
|
|
564
|
+
walletOperation: WalletOperation.REFRESH,
|
|
565
|
+
password
|
|
566
|
+
});
|
|
553
567
|
const mpcSigner = getMPCSigner({
|
|
554
568
|
chainName,
|
|
555
569
|
baseRelayUrl: this.baseMPCRelayApiUrl
|
|
@@ -561,11 +575,12 @@ class DynamicWalletClient {
|
|
|
561
575
|
const roomId = data.roomId;
|
|
562
576
|
const refreshResults = await Promise.all(wallet.clientKeyShares.map((clientKeyShare)=>mpcSigner.refresh(roomId, clientKeyShare)));
|
|
563
577
|
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress], {
|
|
564
|
-
clientKeyShares: refreshResults
|
|
578
|
+
clientKeyShares: refreshResults,
|
|
579
|
+
clientKeySharesBackupInfo: getClientKeyShareBackupInfo()
|
|
565
580
|
});
|
|
566
581
|
await this.storeEncryptedBackupByWallet({
|
|
567
582
|
accountAddress,
|
|
568
|
-
password:
|
|
583
|
+
password: password != null ? password : this.environmentId
|
|
569
584
|
});
|
|
570
585
|
return refreshResults;
|
|
571
586
|
}
|
|
@@ -618,7 +633,12 @@ class DynamicWalletClient {
|
|
|
618
633
|
existingClientKeyShares
|
|
619
634
|
};
|
|
620
635
|
}
|
|
621
|
-
async reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme }) {
|
|
636
|
+
async reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password = undefined }) {
|
|
637
|
+
await this.verifyPassword({
|
|
638
|
+
accountAddress,
|
|
639
|
+
password,
|
|
640
|
+
walletOperation: WalletOperation.RESHARE
|
|
641
|
+
});
|
|
622
642
|
const { existingClientShareCount } = core.getReshareConfig({
|
|
623
643
|
oldThresholdSignatureScheme,
|
|
624
644
|
newThresholdSignatureScheme
|
|
@@ -626,7 +646,8 @@ class DynamicWalletClient {
|
|
|
626
646
|
const wallet = await this.getWallet({
|
|
627
647
|
accountAddress,
|
|
628
648
|
walletOperation: WalletOperation.RESHARE,
|
|
629
|
-
shareCount: existingClientShareCount
|
|
649
|
+
shareCount: existingClientShareCount,
|
|
650
|
+
password
|
|
630
651
|
});
|
|
631
652
|
console.log(`Resharing from ${oldThresholdSignatureScheme} to ${newThresholdSignatureScheme}`);
|
|
632
653
|
const { newClientInitKeygenResults, newClientKeygenIds, existingClientKeygenIds, existingClientKeyShares } = await this.reshareStrategy({
|
|
@@ -664,17 +685,20 @@ class DynamicWalletClient {
|
|
|
664
685
|
...existingClientKeyShares.map((keyShare)=>mpcSigner.reshareRemainingParty(roomId, newMpcConfig.threshold, keyShare, allPartyKeygenIds))
|
|
665
686
|
]);
|
|
666
687
|
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress], {
|
|
667
|
-
clientKeyShares: reshareResults
|
|
688
|
+
clientKeyShares: reshareResults,
|
|
689
|
+
clientKeySharesBackupInfo: getClientKeyShareBackupInfo()
|
|
668
690
|
});
|
|
669
691
|
await this.storeEncryptedBackupByWallet({
|
|
670
692
|
accountAddress,
|
|
671
|
-
password
|
|
693
|
+
password
|
|
672
694
|
});
|
|
673
695
|
return reshareResults;
|
|
674
696
|
}
|
|
675
|
-
async exportKey({ accountAddress, chainName }) {
|
|
697
|
+
async exportKey({ accountAddress, chainName, password = undefined }) {
|
|
676
698
|
const wallet = await this.getWallet({
|
|
677
|
-
accountAddress
|
|
699
|
+
accountAddress,
|
|
700
|
+
password,
|
|
701
|
+
walletOperation: WalletOperation.EXPORT_PRIVATE_KEY
|
|
678
702
|
});
|
|
679
703
|
const mpcSigner = getMPCSigner({
|
|
680
704
|
chainName,
|
|
@@ -749,9 +773,11 @@ class DynamicWalletClient {
|
|
|
749
773
|
const serializedEncryptedKeyShare = Buffer.from(JSON.stringify(encryptedKeyShare)).toString('base64');
|
|
750
774
|
return serializedEncryptedKeyShare;
|
|
751
775
|
}
|
|
752
|
-
async storeEncryptedBackupByWallet({ accountAddress, password }) {
|
|
776
|
+
async storeEncryptedBackupByWallet({ accountAddress, password = undefined, walletOperation = WalletOperation.REACH_ALL_PARTIES }) {
|
|
753
777
|
await this.getWallet({
|
|
754
|
-
accountAddress
|
|
778
|
+
accountAddress,
|
|
779
|
+
password,
|
|
780
|
+
walletOperation
|
|
755
781
|
});
|
|
756
782
|
const encryptedKeyShares = await Promise.all(this.walletMap[accountAddress].clientKeyShares.map((keyShare)=>this.encryptKeyShare({
|
|
757
783
|
keyShare,
|
|
@@ -762,8 +788,28 @@ class DynamicWalletClient {
|
|
|
762
788
|
encryptedKeyShares,
|
|
763
789
|
passwordEncrypted: Boolean(password)
|
|
764
790
|
});
|
|
791
|
+
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress], {
|
|
792
|
+
clientKeySharesBackupInfo: getClientKeyShareBackupInfo({
|
|
793
|
+
walletProperties: {
|
|
794
|
+
derivationPath: this.walletMap[accountAddress].derivationPath,
|
|
795
|
+
keyShares: data.keyShares,
|
|
796
|
+
thresholdSignatureScheme: this.walletMap[accountAddress].thresholdSignatureScheme
|
|
797
|
+
}
|
|
798
|
+
})
|
|
799
|
+
});
|
|
765
800
|
return data;
|
|
766
801
|
}
|
|
802
|
+
async updatePassword({ accountAddress, existingPassword, newPassword }) {
|
|
803
|
+
await this.getWallet({
|
|
804
|
+
accountAddress,
|
|
805
|
+
password: existingPassword,
|
|
806
|
+
walletOperation: WalletOperation.REACH_ALL_PARTIES
|
|
807
|
+
});
|
|
808
|
+
await this.storeEncryptedBackupByWallet({
|
|
809
|
+
accountAddress,
|
|
810
|
+
password: newPassword
|
|
811
|
+
});
|
|
812
|
+
}
|
|
767
813
|
async decryptKeyShare({ keyShare, password }) {
|
|
768
814
|
const decodedKeyShare = JSON.parse(Buffer.from(keyShare, 'base64').toString());
|
|
769
815
|
const decryptedKeyShare = await decryptData({
|
|
@@ -782,29 +828,34 @@ class DynamicWalletClient {
|
|
|
782
828
|
* @param thresholdSignatureScheme - The signature scheme being used (2-of-2, 2-of-3, etc)
|
|
783
829
|
* @param walletOperation - The operation being performed (REFRESH, SIGN_MESSAGE, etc)
|
|
784
830
|
* @param shareCount - The number of shares to recover if specified for reshare operations
|
|
785
|
-
* @returns Object mapping backup locations to arrays of share IDs to recover
|
|
786
|
-
|
|
831
|
+
* @returns @shares: Object mapping backup locations to arrays of share IDs to recover
|
|
832
|
+
* @returns @requiredShareCount: The number of shares required to recover
|
|
833
|
+
*/ recoverStrategy({ clientKeyShareBackupInfo, thresholdSignatureScheme, walletOperation, shareCount = undefined }) {
|
|
787
834
|
const { backups } = clientKeyShareBackupInfo;
|
|
788
835
|
const { clientThreshold } = core.MPC_CONFIG[thresholdSignatureScheme];
|
|
789
|
-
let
|
|
790
|
-
// Override
|
|
836
|
+
let requiredShareCount = walletOperation === WalletOperation.REFRESH || walletOperation === WalletOperation.REACH_ALL_PARTIES || walletOperation === WalletOperation.RESHARE ? clientThreshold : 1;
|
|
837
|
+
// Override requiredShareCount if shareCount is provided
|
|
791
838
|
if (shareCount !== undefined) {
|
|
792
|
-
|
|
839
|
+
requiredShareCount = shareCount;
|
|
793
840
|
}
|
|
794
|
-
const dynamicShares = backups[core.BackupLocation.DYNAMIC].slice(0,
|
|
841
|
+
const dynamicShares = backups[core.BackupLocation.DYNAMIC].slice(0, requiredShareCount);
|
|
795
842
|
return {
|
|
796
|
-
|
|
843
|
+
shares: {
|
|
844
|
+
[core.BackupLocation.DYNAMIC]: dynamicShares
|
|
845
|
+
},
|
|
846
|
+
requiredShareCount
|
|
797
847
|
};
|
|
798
848
|
}
|
|
799
849
|
async recoverEncryptedBackupByWallet({ accountAddress, password, walletOperation, shareCount = undefined }) {
|
|
800
850
|
const wallet = this.walletMap[accountAddress];
|
|
801
851
|
this.logger.debug(`recoverEncryptedBackupByWallet wallet: ${walletOperation}`, wallet);
|
|
802
|
-
const {
|
|
852
|
+
const { shares } = this.recoverStrategy({
|
|
803
853
|
clientKeyShareBackupInfo: wallet.clientKeySharesBackupInfo,
|
|
804
854
|
thresholdSignatureScheme: wallet.thresholdSignatureScheme,
|
|
805
855
|
walletOperation,
|
|
806
856
|
shareCount
|
|
807
857
|
});
|
|
858
|
+
const { dynamic: dynamicKeyShareIds } = shares;
|
|
808
859
|
const data = await this.apiClient.recoverEncryptedBackupByWallet({
|
|
809
860
|
walletId: wallet.walletId,
|
|
810
861
|
keyShareIds: dynamicKeyShareIds
|
|
@@ -831,7 +882,8 @@ class DynamicWalletClient {
|
|
|
831
882
|
async backupKeySharesToGoogleDrive({ accountAddress, fileName, oauthAccountId, password }) {
|
|
832
883
|
await this.getWallet({
|
|
833
884
|
accountAddress,
|
|
834
|
-
walletOperation: WalletOperation.REACH_ALL_PARTIES
|
|
885
|
+
walletOperation: WalletOperation.REACH_ALL_PARTIES,
|
|
886
|
+
password
|
|
835
887
|
});
|
|
836
888
|
const clientKeyShares = this.walletMap[accountAddress].clientKeyShares;
|
|
837
889
|
if (clientKeyShares.length === 0) {
|
|
@@ -965,13 +1017,20 @@ class DynamicWalletClient {
|
|
|
965
1017
|
clientKeyShares: clientKeygenResults
|
|
966
1018
|
};
|
|
967
1019
|
}
|
|
968
|
-
async exportClientKeyshares({ accountAddress }) {
|
|
969
|
-
await this.
|
|
1020
|
+
async exportClientKeyshares({ accountAddress, password }) {
|
|
1021
|
+
await this.verifyPassword({
|
|
970
1022
|
accountAddress,
|
|
1023
|
+
password,
|
|
971
1024
|
walletOperation: WalletOperation.REACH_ALL_PARTIES
|
|
972
1025
|
});
|
|
1026
|
+
await this.getWallet({
|
|
1027
|
+
accountAddress,
|
|
1028
|
+
walletOperation: WalletOperation.REACH_ALL_PARTIES,
|
|
1029
|
+
password
|
|
1030
|
+
});
|
|
973
1031
|
const clientKeyShares = await this.getClientKeyShares({
|
|
974
|
-
accountAddress
|
|
1032
|
+
accountAddress,
|
|
1033
|
+
password
|
|
975
1034
|
});
|
|
976
1035
|
if (!accountAddress) {
|
|
977
1036
|
throw new Error('Must provide an account address');
|
|
@@ -992,9 +1051,11 @@ class DynamicWalletClient {
|
|
|
992
1051
|
a.download = `${CLIENT_KEYSHARE_EXPORT_FILENAME_PREFIX}-${accountAddress}.txt`;
|
|
993
1052
|
a.click();
|
|
994
1053
|
}
|
|
995
|
-
async getClientKeyShares({ accountAddress }) {
|
|
1054
|
+
async getClientKeyShares({ accountAddress, password }) {
|
|
996
1055
|
const wallet = await this.getWallet({
|
|
997
|
-
accountAddress
|
|
1056
|
+
accountAddress,
|
|
1057
|
+
password,
|
|
1058
|
+
walletOperation: WalletOperation.REACH_THRESHOLD
|
|
998
1059
|
});
|
|
999
1060
|
return wallet.clientKeyShares;
|
|
1000
1061
|
}
|
|
@@ -1019,7 +1080,7 @@ class DynamicWalletClient {
|
|
|
1019
1080
|
// check if wallet already exists with sufficient keyshares
|
|
1020
1081
|
if (existingWallet) {
|
|
1021
1082
|
var _existingWallet_clientKeyShares;
|
|
1022
|
-
const {
|
|
1083
|
+
const { shares } = this.recoverStrategy({
|
|
1023
1084
|
clientKeyShareBackupInfo: existingWallet.clientKeySharesBackupInfo || {
|
|
1024
1085
|
backups: getClientKeyShareBackupInfo()
|
|
1025
1086
|
},
|
|
@@ -1027,13 +1088,106 @@ class DynamicWalletClient {
|
|
|
1027
1088
|
walletOperation,
|
|
1028
1089
|
shareCount
|
|
1029
1090
|
});
|
|
1091
|
+
const { dynamic: requiredDynamicKeyShareIds = [] } = shares;
|
|
1030
1092
|
if (requiredDynamicKeyShareIds.length <= (((_existingWallet_clientKeyShares = existingWallet.clientKeyShares) == null ? void 0 : _existingWallet_clientKeyShares.length) || 0)) {
|
|
1031
1093
|
keyshareCheck = true;
|
|
1032
1094
|
}
|
|
1033
1095
|
}
|
|
1034
1096
|
return walletCheck && thresholdSignatureSchemeCheck && keyshareCheck;
|
|
1035
1097
|
}
|
|
1036
|
-
|
|
1098
|
+
/**
|
|
1099
|
+
* verifyPassword attempts to recover and decrypt 1 client key share using the provided password
|
|
1100
|
+
* if successful, the key share is encrypted with the new password and stored
|
|
1101
|
+
* if unsuccessful, throws an error
|
|
1102
|
+
*/ async verifyPassword({ accountAddress, password = undefined, walletOperation = WalletOperation.NO_OPERATION }) {
|
|
1103
|
+
await this.getWallet({
|
|
1104
|
+
accountAddress,
|
|
1105
|
+
password,
|
|
1106
|
+
walletOperation
|
|
1107
|
+
});
|
|
1108
|
+
if (await this.requiresPasswordForOperation({
|
|
1109
|
+
accountAddress,
|
|
1110
|
+
walletOperation
|
|
1111
|
+
}) && !password) {
|
|
1112
|
+
throw new Error('Password is required for operation but not provided');
|
|
1113
|
+
}
|
|
1114
|
+
// silent return if no password is provided and operation does not require a password
|
|
1115
|
+
if (!password) {
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
const { backups } = await this.getWalletClientKeyShareBackupInfo({
|
|
1119
|
+
accountAddress
|
|
1120
|
+
});
|
|
1121
|
+
const { dynamic: dynamicKeyShareIds = [] } = backups;
|
|
1122
|
+
if (!dynamicKeyShareIds || dynamicKeyShareIds.length === 0) {
|
|
1123
|
+
throw new Error('No dynamic key shares found');
|
|
1124
|
+
}
|
|
1125
|
+
try {
|
|
1126
|
+
await this.recoverEncryptedBackupByWallet({
|
|
1127
|
+
accountAddress,
|
|
1128
|
+
password,
|
|
1129
|
+
walletOperation,
|
|
1130
|
+
shareCount: 1
|
|
1131
|
+
});
|
|
1132
|
+
} catch (error) {
|
|
1133
|
+
this.logger.error('Error in verifying password', error);
|
|
1134
|
+
throw new Error('Incorrect password');
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
async isPasswordEncrypted({ accountAddress }) {
|
|
1138
|
+
const clientKeySharesBackupInfo = await this.getWalletClientKeyShareBackupInfo({
|
|
1139
|
+
accountAddress
|
|
1140
|
+
});
|
|
1141
|
+
return clientKeySharesBackupInfo == null ? void 0 : clientKeySharesBackupInfo.passwordEncrypted;
|
|
1142
|
+
}
|
|
1143
|
+
/**
|
|
1144
|
+
* check if the operation requires a password
|
|
1145
|
+
*/ async requiresPasswordForOperation({ accountAddress, walletOperation = WalletOperation.REACH_THRESHOLD }) {
|
|
1146
|
+
const isEncrypted = await this.isPasswordEncrypted({
|
|
1147
|
+
accountAddress
|
|
1148
|
+
});
|
|
1149
|
+
if (!isEncrypted) {
|
|
1150
|
+
return false;
|
|
1151
|
+
}
|
|
1152
|
+
return this.requiresRestoreBackupSharesForOperation({
|
|
1153
|
+
accountAddress,
|
|
1154
|
+
walletOperation
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
/**
|
|
1158
|
+
* check if the operation requires restoring backup shares
|
|
1159
|
+
*/ async requiresRestoreBackupSharesForOperation({ accountAddress, walletOperation = WalletOperation.REACH_THRESHOLD }) {
|
|
1160
|
+
const clientKeySharesBackupInfo = await this.getWalletClientKeyShareBackupInfo({
|
|
1161
|
+
accountAddress
|
|
1162
|
+
});
|
|
1163
|
+
const clientKeyShares = this.walletMap[accountAddress].clientKeyShares || [];
|
|
1164
|
+
if (walletOperation === WalletOperation.REACH_ALL_PARTIES || walletOperation === WalletOperation.REFRESH || walletOperation === WalletOperation.RESHARE) {
|
|
1165
|
+
return true;
|
|
1166
|
+
}
|
|
1167
|
+
const { requiredShareCount } = this.recoverStrategy({
|
|
1168
|
+
clientKeyShareBackupInfo: clientKeySharesBackupInfo,
|
|
1169
|
+
thresholdSignatureScheme: this.walletMap[accountAddress].thresholdSignatureScheme,
|
|
1170
|
+
walletOperation
|
|
1171
|
+
});
|
|
1172
|
+
if (clientKeyShares.length >= requiredShareCount) {
|
|
1173
|
+
return false;
|
|
1174
|
+
}
|
|
1175
|
+
return true;
|
|
1176
|
+
}
|
|
1177
|
+
async getWalletClientKeyShareBackupInfo({ accountAddress }) {
|
|
1178
|
+
var _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups_BackupLocation_DYNAMIC, _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups, _this_walletMap_accountAddress_clientKeySharesBackupInfo, _this_walletMap_accountAddress, _user_verifiedCredentials;
|
|
1179
|
+
// Return existing backup info if it exists
|
|
1180
|
+
if (((_this_walletMap_accountAddress = this.walletMap[accountAddress]) == null ? void 0 : (_this_walletMap_accountAddress_clientKeySharesBackupInfo = _this_walletMap_accountAddress.clientKeySharesBackupInfo) == null ? void 0 : (_this_walletMap_accountAddress_clientKeySharesBackupInfo_backups = _this_walletMap_accountAddress_clientKeySharesBackupInfo.backups) == null ? void 0 : (_this_walletMap_accountAddress_clientKeySharesBackupInfo_backups_BackupLocation_DYNAMIC = _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups[core.BackupLocation.DYNAMIC]) == null ? void 0 : _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups_BackupLocation_DYNAMIC.length) > 0) {
|
|
1181
|
+
return this.walletMap[accountAddress].clientKeySharesBackupInfo;
|
|
1182
|
+
}
|
|
1183
|
+
// Get backup info from server
|
|
1184
|
+
const user = await this.apiClient.getUser();
|
|
1185
|
+
const wallet = (_user_verifiedCredentials = user.verifiedCredentials) == null ? void 0 : _user_verifiedCredentials.find((vc)=>vc.address.toLowerCase() === accountAddress.toLowerCase());
|
|
1186
|
+
return getClientKeyShareBackupInfo({
|
|
1187
|
+
walletProperties: wallet == null ? void 0 : wallet.walletProperties
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
async getWallet({ accountAddress, walletOperation = WalletOperation.NO_OPERATION, shareCount = undefined, password = undefined }) {
|
|
1037
1191
|
var _user_verifiedCredentials;
|
|
1038
1192
|
const existingWalletCheck = await this.checkWalletFields({
|
|
1039
1193
|
accountAddress,
|
|
@@ -1059,14 +1213,18 @@ class DynamicWalletClient {
|
|
|
1059
1213
|
walletProperties
|
|
1060
1214
|
})
|
|
1061
1215
|
});
|
|
1062
|
-
|
|
1063
|
-
const decryptedKeyShares = await this.recoverEncryptedBackupByWallet({
|
|
1216
|
+
if (walletOperation !== WalletOperation.NO_OPERATION && await this.requiresRestoreBackupSharesForOperation({
|
|
1064
1217
|
accountAddress,
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1218
|
+
walletOperation
|
|
1219
|
+
})) {
|
|
1220
|
+
const decryptedKeyShares = await this.recoverEncryptedBackupByWallet({
|
|
1221
|
+
accountAddress,
|
|
1222
|
+
password: password != null ? password : this.environmentId,
|
|
1223
|
+
walletOperation: walletOperation,
|
|
1224
|
+
shareCount
|
|
1225
|
+
});
|
|
1226
|
+
this.logger.debug('Recovered backup', decryptedKeyShares);
|
|
1227
|
+
}
|
|
1070
1228
|
const walletCount = Object.keys(this.walletMap).length;
|
|
1071
1229
|
if (walletCount === 0) {
|
|
1072
1230
|
throw new Error('No wallets found');
|
package/index.esm.js
CHANGED
|
@@ -356,6 +356,7 @@ var WalletOperation = /*#__PURE__*/ function(WalletOperation) {
|
|
|
356
356
|
WalletOperation["REFRESH"] = "REFRESH";
|
|
357
357
|
WalletOperation["RESHARE"] = "RESHARE";
|
|
358
358
|
WalletOperation["EXPORT_PRIVATE_KEY"] = "EXPORT_PRIVATE_KEY";
|
|
359
|
+
WalletOperation["NO_OPERATION"] = "NO_OPERATION";
|
|
359
360
|
return WalletOperation;
|
|
360
361
|
}({});
|
|
361
362
|
|
|
@@ -525,9 +526,16 @@ class DynamicWalletClient {
|
|
|
525
526
|
}
|
|
526
527
|
}
|
|
527
528
|
//todo: need to modify with imported flag
|
|
528
|
-
async sign({ accountAddress, message, chainName }) {
|
|
529
|
+
async sign({ accountAddress, message, chainName, password = undefined }) {
|
|
530
|
+
await this.verifyPassword({
|
|
531
|
+
accountAddress,
|
|
532
|
+
password,
|
|
533
|
+
walletOperation: WalletOperation.SIGN_MESSAGE
|
|
534
|
+
});
|
|
529
535
|
const wallet = await this.getWallet({
|
|
530
|
-
accountAddress
|
|
536
|
+
accountAddress,
|
|
537
|
+
password,
|
|
538
|
+
walletOperation: WalletOperation.SIGN_MESSAGE
|
|
531
539
|
});
|
|
532
540
|
// Perform the server sign
|
|
533
541
|
const data = await this.serverSign({
|
|
@@ -545,11 +553,17 @@ class DynamicWalletClient {
|
|
|
545
553
|
});
|
|
546
554
|
return signature;
|
|
547
555
|
}
|
|
548
|
-
async refreshWalletAccountShares({ accountAddress, chainName }) {
|
|
549
|
-
|
|
556
|
+
async refreshWalletAccountShares({ accountAddress, chainName, password = undefined }) {
|
|
557
|
+
await this.verifyPassword({
|
|
550
558
|
accountAddress,
|
|
559
|
+
password,
|
|
551
560
|
walletOperation: WalletOperation.REFRESH
|
|
552
561
|
});
|
|
562
|
+
const wallet = await this.getWallet({
|
|
563
|
+
accountAddress,
|
|
564
|
+
walletOperation: WalletOperation.REFRESH,
|
|
565
|
+
password
|
|
566
|
+
});
|
|
553
567
|
const mpcSigner = getMPCSigner({
|
|
554
568
|
chainName,
|
|
555
569
|
baseRelayUrl: this.baseMPCRelayApiUrl
|
|
@@ -561,11 +575,12 @@ class DynamicWalletClient {
|
|
|
561
575
|
const roomId = data.roomId;
|
|
562
576
|
const refreshResults = await Promise.all(wallet.clientKeyShares.map((clientKeyShare)=>mpcSigner.refresh(roomId, clientKeyShare)));
|
|
563
577
|
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress], {
|
|
564
|
-
clientKeyShares: refreshResults
|
|
578
|
+
clientKeyShares: refreshResults,
|
|
579
|
+
clientKeySharesBackupInfo: getClientKeyShareBackupInfo()
|
|
565
580
|
});
|
|
566
581
|
await this.storeEncryptedBackupByWallet({
|
|
567
582
|
accountAddress,
|
|
568
|
-
password:
|
|
583
|
+
password: password != null ? password : this.environmentId
|
|
569
584
|
});
|
|
570
585
|
return refreshResults;
|
|
571
586
|
}
|
|
@@ -618,7 +633,12 @@ class DynamicWalletClient {
|
|
|
618
633
|
existingClientKeyShares
|
|
619
634
|
};
|
|
620
635
|
}
|
|
621
|
-
async reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme }) {
|
|
636
|
+
async reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password = undefined }) {
|
|
637
|
+
await this.verifyPassword({
|
|
638
|
+
accountAddress,
|
|
639
|
+
password,
|
|
640
|
+
walletOperation: WalletOperation.RESHARE
|
|
641
|
+
});
|
|
622
642
|
const { existingClientShareCount } = getReshareConfig({
|
|
623
643
|
oldThresholdSignatureScheme,
|
|
624
644
|
newThresholdSignatureScheme
|
|
@@ -626,7 +646,8 @@ class DynamicWalletClient {
|
|
|
626
646
|
const wallet = await this.getWallet({
|
|
627
647
|
accountAddress,
|
|
628
648
|
walletOperation: WalletOperation.RESHARE,
|
|
629
|
-
shareCount: existingClientShareCount
|
|
649
|
+
shareCount: existingClientShareCount,
|
|
650
|
+
password
|
|
630
651
|
});
|
|
631
652
|
console.log(`Resharing from ${oldThresholdSignatureScheme} to ${newThresholdSignatureScheme}`);
|
|
632
653
|
const { newClientInitKeygenResults, newClientKeygenIds, existingClientKeygenIds, existingClientKeyShares } = await this.reshareStrategy({
|
|
@@ -664,17 +685,20 @@ class DynamicWalletClient {
|
|
|
664
685
|
...existingClientKeyShares.map((keyShare)=>mpcSigner.reshareRemainingParty(roomId, newMpcConfig.threshold, keyShare, allPartyKeygenIds))
|
|
665
686
|
]);
|
|
666
687
|
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress], {
|
|
667
|
-
clientKeyShares: reshareResults
|
|
688
|
+
clientKeyShares: reshareResults,
|
|
689
|
+
clientKeySharesBackupInfo: getClientKeyShareBackupInfo()
|
|
668
690
|
});
|
|
669
691
|
await this.storeEncryptedBackupByWallet({
|
|
670
692
|
accountAddress,
|
|
671
|
-
password
|
|
693
|
+
password
|
|
672
694
|
});
|
|
673
695
|
return reshareResults;
|
|
674
696
|
}
|
|
675
|
-
async exportKey({ accountAddress, chainName }) {
|
|
697
|
+
async exportKey({ accountAddress, chainName, password = undefined }) {
|
|
676
698
|
const wallet = await this.getWallet({
|
|
677
|
-
accountAddress
|
|
699
|
+
accountAddress,
|
|
700
|
+
password,
|
|
701
|
+
walletOperation: WalletOperation.EXPORT_PRIVATE_KEY
|
|
678
702
|
});
|
|
679
703
|
const mpcSigner = getMPCSigner({
|
|
680
704
|
chainName,
|
|
@@ -749,9 +773,11 @@ class DynamicWalletClient {
|
|
|
749
773
|
const serializedEncryptedKeyShare = Buffer.from(JSON.stringify(encryptedKeyShare)).toString('base64');
|
|
750
774
|
return serializedEncryptedKeyShare;
|
|
751
775
|
}
|
|
752
|
-
async storeEncryptedBackupByWallet({ accountAddress, password }) {
|
|
776
|
+
async storeEncryptedBackupByWallet({ accountAddress, password = undefined, walletOperation = WalletOperation.REACH_ALL_PARTIES }) {
|
|
753
777
|
await this.getWallet({
|
|
754
|
-
accountAddress
|
|
778
|
+
accountAddress,
|
|
779
|
+
password,
|
|
780
|
+
walletOperation
|
|
755
781
|
});
|
|
756
782
|
const encryptedKeyShares = await Promise.all(this.walletMap[accountAddress].clientKeyShares.map((keyShare)=>this.encryptKeyShare({
|
|
757
783
|
keyShare,
|
|
@@ -762,8 +788,28 @@ class DynamicWalletClient {
|
|
|
762
788
|
encryptedKeyShares,
|
|
763
789
|
passwordEncrypted: Boolean(password)
|
|
764
790
|
});
|
|
791
|
+
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress], {
|
|
792
|
+
clientKeySharesBackupInfo: getClientKeyShareBackupInfo({
|
|
793
|
+
walletProperties: {
|
|
794
|
+
derivationPath: this.walletMap[accountAddress].derivationPath,
|
|
795
|
+
keyShares: data.keyShares,
|
|
796
|
+
thresholdSignatureScheme: this.walletMap[accountAddress].thresholdSignatureScheme
|
|
797
|
+
}
|
|
798
|
+
})
|
|
799
|
+
});
|
|
765
800
|
return data;
|
|
766
801
|
}
|
|
802
|
+
async updatePassword({ accountAddress, existingPassword, newPassword }) {
|
|
803
|
+
await this.getWallet({
|
|
804
|
+
accountAddress,
|
|
805
|
+
password: existingPassword,
|
|
806
|
+
walletOperation: WalletOperation.REACH_ALL_PARTIES
|
|
807
|
+
});
|
|
808
|
+
await this.storeEncryptedBackupByWallet({
|
|
809
|
+
accountAddress,
|
|
810
|
+
password: newPassword
|
|
811
|
+
});
|
|
812
|
+
}
|
|
767
813
|
async decryptKeyShare({ keyShare, password }) {
|
|
768
814
|
const decodedKeyShare = JSON.parse(Buffer.from(keyShare, 'base64').toString());
|
|
769
815
|
const decryptedKeyShare = await decryptData({
|
|
@@ -782,29 +828,34 @@ class DynamicWalletClient {
|
|
|
782
828
|
* @param thresholdSignatureScheme - The signature scheme being used (2-of-2, 2-of-3, etc)
|
|
783
829
|
* @param walletOperation - The operation being performed (REFRESH, SIGN_MESSAGE, etc)
|
|
784
830
|
* @param shareCount - The number of shares to recover if specified for reshare operations
|
|
785
|
-
* @returns Object mapping backup locations to arrays of share IDs to recover
|
|
786
|
-
|
|
831
|
+
* @returns @shares: Object mapping backup locations to arrays of share IDs to recover
|
|
832
|
+
* @returns @requiredShareCount: The number of shares required to recover
|
|
833
|
+
*/ recoverStrategy({ clientKeyShareBackupInfo, thresholdSignatureScheme, walletOperation, shareCount = undefined }) {
|
|
787
834
|
const { backups } = clientKeyShareBackupInfo;
|
|
788
835
|
const { clientThreshold } = MPC_CONFIG[thresholdSignatureScheme];
|
|
789
|
-
let
|
|
790
|
-
// Override
|
|
836
|
+
let requiredShareCount = walletOperation === WalletOperation.REFRESH || walletOperation === WalletOperation.REACH_ALL_PARTIES || walletOperation === WalletOperation.RESHARE ? clientThreshold : 1;
|
|
837
|
+
// Override requiredShareCount if shareCount is provided
|
|
791
838
|
if (shareCount !== undefined) {
|
|
792
|
-
|
|
839
|
+
requiredShareCount = shareCount;
|
|
793
840
|
}
|
|
794
|
-
const dynamicShares = backups[BackupLocation.DYNAMIC].slice(0,
|
|
841
|
+
const dynamicShares = backups[BackupLocation.DYNAMIC].slice(0, requiredShareCount);
|
|
795
842
|
return {
|
|
796
|
-
|
|
843
|
+
shares: {
|
|
844
|
+
[BackupLocation.DYNAMIC]: dynamicShares
|
|
845
|
+
},
|
|
846
|
+
requiredShareCount
|
|
797
847
|
};
|
|
798
848
|
}
|
|
799
849
|
async recoverEncryptedBackupByWallet({ accountAddress, password, walletOperation, shareCount = undefined }) {
|
|
800
850
|
const wallet = this.walletMap[accountAddress];
|
|
801
851
|
this.logger.debug(`recoverEncryptedBackupByWallet wallet: ${walletOperation}`, wallet);
|
|
802
|
-
const {
|
|
852
|
+
const { shares } = this.recoverStrategy({
|
|
803
853
|
clientKeyShareBackupInfo: wallet.clientKeySharesBackupInfo,
|
|
804
854
|
thresholdSignatureScheme: wallet.thresholdSignatureScheme,
|
|
805
855
|
walletOperation,
|
|
806
856
|
shareCount
|
|
807
857
|
});
|
|
858
|
+
const { dynamic: dynamicKeyShareIds } = shares;
|
|
808
859
|
const data = await this.apiClient.recoverEncryptedBackupByWallet({
|
|
809
860
|
walletId: wallet.walletId,
|
|
810
861
|
keyShareIds: dynamicKeyShareIds
|
|
@@ -831,7 +882,8 @@ class DynamicWalletClient {
|
|
|
831
882
|
async backupKeySharesToGoogleDrive({ accountAddress, fileName, oauthAccountId, password }) {
|
|
832
883
|
await this.getWallet({
|
|
833
884
|
accountAddress,
|
|
834
|
-
walletOperation: WalletOperation.REACH_ALL_PARTIES
|
|
885
|
+
walletOperation: WalletOperation.REACH_ALL_PARTIES,
|
|
886
|
+
password
|
|
835
887
|
});
|
|
836
888
|
const clientKeyShares = this.walletMap[accountAddress].clientKeyShares;
|
|
837
889
|
if (clientKeyShares.length === 0) {
|
|
@@ -965,13 +1017,20 @@ class DynamicWalletClient {
|
|
|
965
1017
|
clientKeyShares: clientKeygenResults
|
|
966
1018
|
};
|
|
967
1019
|
}
|
|
968
|
-
async exportClientKeyshares({ accountAddress }) {
|
|
969
|
-
await this.
|
|
1020
|
+
async exportClientKeyshares({ accountAddress, password }) {
|
|
1021
|
+
await this.verifyPassword({
|
|
970
1022
|
accountAddress,
|
|
1023
|
+
password,
|
|
971
1024
|
walletOperation: WalletOperation.REACH_ALL_PARTIES
|
|
972
1025
|
});
|
|
1026
|
+
await this.getWallet({
|
|
1027
|
+
accountAddress,
|
|
1028
|
+
walletOperation: WalletOperation.REACH_ALL_PARTIES,
|
|
1029
|
+
password
|
|
1030
|
+
});
|
|
973
1031
|
const clientKeyShares = await this.getClientKeyShares({
|
|
974
|
-
accountAddress
|
|
1032
|
+
accountAddress,
|
|
1033
|
+
password
|
|
975
1034
|
});
|
|
976
1035
|
if (!accountAddress) {
|
|
977
1036
|
throw new Error('Must provide an account address');
|
|
@@ -992,9 +1051,11 @@ class DynamicWalletClient {
|
|
|
992
1051
|
a.download = `${CLIENT_KEYSHARE_EXPORT_FILENAME_PREFIX}-${accountAddress}.txt`;
|
|
993
1052
|
a.click();
|
|
994
1053
|
}
|
|
995
|
-
async getClientKeyShares({ accountAddress }) {
|
|
1054
|
+
async getClientKeyShares({ accountAddress, password }) {
|
|
996
1055
|
const wallet = await this.getWallet({
|
|
997
|
-
accountAddress
|
|
1056
|
+
accountAddress,
|
|
1057
|
+
password,
|
|
1058
|
+
walletOperation: WalletOperation.REACH_THRESHOLD
|
|
998
1059
|
});
|
|
999
1060
|
return wallet.clientKeyShares;
|
|
1000
1061
|
}
|
|
@@ -1019,7 +1080,7 @@ class DynamicWalletClient {
|
|
|
1019
1080
|
// check if wallet already exists with sufficient keyshares
|
|
1020
1081
|
if (existingWallet) {
|
|
1021
1082
|
var _existingWallet_clientKeyShares;
|
|
1022
|
-
const {
|
|
1083
|
+
const { shares } = this.recoverStrategy({
|
|
1023
1084
|
clientKeyShareBackupInfo: existingWallet.clientKeySharesBackupInfo || {
|
|
1024
1085
|
backups: getClientKeyShareBackupInfo()
|
|
1025
1086
|
},
|
|
@@ -1027,13 +1088,106 @@ class DynamicWalletClient {
|
|
|
1027
1088
|
walletOperation,
|
|
1028
1089
|
shareCount
|
|
1029
1090
|
});
|
|
1091
|
+
const { dynamic: requiredDynamicKeyShareIds = [] } = shares;
|
|
1030
1092
|
if (requiredDynamicKeyShareIds.length <= (((_existingWallet_clientKeyShares = existingWallet.clientKeyShares) == null ? void 0 : _existingWallet_clientKeyShares.length) || 0)) {
|
|
1031
1093
|
keyshareCheck = true;
|
|
1032
1094
|
}
|
|
1033
1095
|
}
|
|
1034
1096
|
return walletCheck && thresholdSignatureSchemeCheck && keyshareCheck;
|
|
1035
1097
|
}
|
|
1036
|
-
|
|
1098
|
+
/**
|
|
1099
|
+
* verifyPassword attempts to recover and decrypt 1 client key share using the provided password
|
|
1100
|
+
* if successful, the key share is encrypted with the new password and stored
|
|
1101
|
+
* if unsuccessful, throws an error
|
|
1102
|
+
*/ async verifyPassword({ accountAddress, password = undefined, walletOperation = WalletOperation.NO_OPERATION }) {
|
|
1103
|
+
await this.getWallet({
|
|
1104
|
+
accountAddress,
|
|
1105
|
+
password,
|
|
1106
|
+
walletOperation
|
|
1107
|
+
});
|
|
1108
|
+
if (await this.requiresPasswordForOperation({
|
|
1109
|
+
accountAddress,
|
|
1110
|
+
walletOperation
|
|
1111
|
+
}) && !password) {
|
|
1112
|
+
throw new Error('Password is required for operation but not provided');
|
|
1113
|
+
}
|
|
1114
|
+
// silent return if no password is provided and operation does not require a password
|
|
1115
|
+
if (!password) {
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
const { backups } = await this.getWalletClientKeyShareBackupInfo({
|
|
1119
|
+
accountAddress
|
|
1120
|
+
});
|
|
1121
|
+
const { dynamic: dynamicKeyShareIds = [] } = backups;
|
|
1122
|
+
if (!dynamicKeyShareIds || dynamicKeyShareIds.length === 0) {
|
|
1123
|
+
throw new Error('No dynamic key shares found');
|
|
1124
|
+
}
|
|
1125
|
+
try {
|
|
1126
|
+
await this.recoverEncryptedBackupByWallet({
|
|
1127
|
+
accountAddress,
|
|
1128
|
+
password,
|
|
1129
|
+
walletOperation,
|
|
1130
|
+
shareCount: 1
|
|
1131
|
+
});
|
|
1132
|
+
} catch (error) {
|
|
1133
|
+
this.logger.error('Error in verifying password', error);
|
|
1134
|
+
throw new Error('Incorrect password');
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
async isPasswordEncrypted({ accountAddress }) {
|
|
1138
|
+
const clientKeySharesBackupInfo = await this.getWalletClientKeyShareBackupInfo({
|
|
1139
|
+
accountAddress
|
|
1140
|
+
});
|
|
1141
|
+
return clientKeySharesBackupInfo == null ? void 0 : clientKeySharesBackupInfo.passwordEncrypted;
|
|
1142
|
+
}
|
|
1143
|
+
/**
|
|
1144
|
+
* check if the operation requires a password
|
|
1145
|
+
*/ async requiresPasswordForOperation({ accountAddress, walletOperation = WalletOperation.REACH_THRESHOLD }) {
|
|
1146
|
+
const isEncrypted = await this.isPasswordEncrypted({
|
|
1147
|
+
accountAddress
|
|
1148
|
+
});
|
|
1149
|
+
if (!isEncrypted) {
|
|
1150
|
+
return false;
|
|
1151
|
+
}
|
|
1152
|
+
return this.requiresRestoreBackupSharesForOperation({
|
|
1153
|
+
accountAddress,
|
|
1154
|
+
walletOperation
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
/**
|
|
1158
|
+
* check if the operation requires restoring backup shares
|
|
1159
|
+
*/ async requiresRestoreBackupSharesForOperation({ accountAddress, walletOperation = WalletOperation.REACH_THRESHOLD }) {
|
|
1160
|
+
const clientKeySharesBackupInfo = await this.getWalletClientKeyShareBackupInfo({
|
|
1161
|
+
accountAddress
|
|
1162
|
+
});
|
|
1163
|
+
const clientKeyShares = this.walletMap[accountAddress].clientKeyShares || [];
|
|
1164
|
+
if (walletOperation === WalletOperation.REACH_ALL_PARTIES || walletOperation === WalletOperation.REFRESH || walletOperation === WalletOperation.RESHARE) {
|
|
1165
|
+
return true;
|
|
1166
|
+
}
|
|
1167
|
+
const { requiredShareCount } = this.recoverStrategy({
|
|
1168
|
+
clientKeyShareBackupInfo: clientKeySharesBackupInfo,
|
|
1169
|
+
thresholdSignatureScheme: this.walletMap[accountAddress].thresholdSignatureScheme,
|
|
1170
|
+
walletOperation
|
|
1171
|
+
});
|
|
1172
|
+
if (clientKeyShares.length >= requiredShareCount) {
|
|
1173
|
+
return false;
|
|
1174
|
+
}
|
|
1175
|
+
return true;
|
|
1176
|
+
}
|
|
1177
|
+
async getWalletClientKeyShareBackupInfo({ accountAddress }) {
|
|
1178
|
+
var _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups_BackupLocation_DYNAMIC, _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups, _this_walletMap_accountAddress_clientKeySharesBackupInfo, _this_walletMap_accountAddress, _user_verifiedCredentials;
|
|
1179
|
+
// Return existing backup info if it exists
|
|
1180
|
+
if (((_this_walletMap_accountAddress = this.walletMap[accountAddress]) == null ? void 0 : (_this_walletMap_accountAddress_clientKeySharesBackupInfo = _this_walletMap_accountAddress.clientKeySharesBackupInfo) == null ? void 0 : (_this_walletMap_accountAddress_clientKeySharesBackupInfo_backups = _this_walletMap_accountAddress_clientKeySharesBackupInfo.backups) == null ? void 0 : (_this_walletMap_accountAddress_clientKeySharesBackupInfo_backups_BackupLocation_DYNAMIC = _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups[BackupLocation.DYNAMIC]) == null ? void 0 : _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups_BackupLocation_DYNAMIC.length) > 0) {
|
|
1181
|
+
return this.walletMap[accountAddress].clientKeySharesBackupInfo;
|
|
1182
|
+
}
|
|
1183
|
+
// Get backup info from server
|
|
1184
|
+
const user = await this.apiClient.getUser();
|
|
1185
|
+
const wallet = (_user_verifiedCredentials = user.verifiedCredentials) == null ? void 0 : _user_verifiedCredentials.find((vc)=>vc.address.toLowerCase() === accountAddress.toLowerCase());
|
|
1186
|
+
return getClientKeyShareBackupInfo({
|
|
1187
|
+
walletProperties: wallet == null ? void 0 : wallet.walletProperties
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
async getWallet({ accountAddress, walletOperation = WalletOperation.NO_OPERATION, shareCount = undefined, password = undefined }) {
|
|
1037
1191
|
var _user_verifiedCredentials;
|
|
1038
1192
|
const existingWalletCheck = await this.checkWalletFields({
|
|
1039
1193
|
accountAddress,
|
|
@@ -1059,14 +1213,18 @@ class DynamicWalletClient {
|
|
|
1059
1213
|
walletProperties
|
|
1060
1214
|
})
|
|
1061
1215
|
});
|
|
1062
|
-
|
|
1063
|
-
const decryptedKeyShares = await this.recoverEncryptedBackupByWallet({
|
|
1216
|
+
if (walletOperation !== WalletOperation.NO_OPERATION && await this.requiresRestoreBackupSharesForOperation({
|
|
1064
1217
|
accountAddress,
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1218
|
+
walletOperation
|
|
1219
|
+
})) {
|
|
1220
|
+
const decryptedKeyShares = await this.recoverEncryptedBackupByWallet({
|
|
1221
|
+
accountAddress,
|
|
1222
|
+
password: password != null ? password : this.environmentId,
|
|
1223
|
+
walletOperation: walletOperation,
|
|
1224
|
+
shareCount
|
|
1225
|
+
});
|
|
1226
|
+
this.logger.debug('Recovered backup', decryptedKeyShares);
|
|
1227
|
+
}
|
|
1070
1228
|
const walletCount = Object.keys(this.walletMap).length;
|
|
1071
1229
|
if (walletCount === 0) {
|
|
1072
1230
|
throw new Error('No wallets found');
|
package/package.json
CHANGED
package/src/client.d.ts
CHANGED
|
@@ -64,14 +64,16 @@ export declare class DynamicWalletClient {
|
|
|
64
64
|
keyShare: ClientKeyShare;
|
|
65
65
|
derivationPath: Uint32Array | undefined;
|
|
66
66
|
}): Promise<Uint8Array | EcdsaSignature>;
|
|
67
|
-
sign({ accountAddress, message, chainName, }: {
|
|
67
|
+
sign({ accountAddress, message, chainName, password, }: {
|
|
68
68
|
accountAddress: string;
|
|
69
69
|
message: string | Uint8Array;
|
|
70
70
|
chainName: string;
|
|
71
|
+
password?: string;
|
|
71
72
|
}): Promise<Uint8Array | EcdsaSignature>;
|
|
72
|
-
refreshWalletAccountShares({ accountAddress, chainName, }: {
|
|
73
|
+
refreshWalletAccountShares({ accountAddress, chainName, password, }: {
|
|
73
74
|
accountAddress: string;
|
|
74
75
|
chainName: string;
|
|
76
|
+
password?: string;
|
|
75
77
|
}): Promise<(EcdsaKeygenResult | BIP340KeygenResult)[]>;
|
|
76
78
|
getExportId({ chainName, clientKeyShare, }: {
|
|
77
79
|
chainName: string;
|
|
@@ -102,15 +104,17 @@ export declare class DynamicWalletClient {
|
|
|
102
104
|
existingClientKeygenIds: string[];
|
|
103
105
|
existingClientKeyShares: ClientKeyShare[];
|
|
104
106
|
}>;
|
|
105
|
-
reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, }: {
|
|
107
|
+
reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password, }: {
|
|
106
108
|
chainName: string;
|
|
107
109
|
accountAddress: string;
|
|
108
110
|
oldThresholdSignatureScheme: ThresholdSignatureScheme;
|
|
109
111
|
newThresholdSignatureScheme: ThresholdSignatureScheme;
|
|
112
|
+
password?: string;
|
|
110
113
|
}): Promise<(EcdsaKeygenResult | BIP340KeygenResult)[]>;
|
|
111
|
-
exportKey({ accountAddress, chainName, }: {
|
|
114
|
+
exportKey({ accountAddress, chainName, password, }: {
|
|
112
115
|
accountAddress: string;
|
|
113
116
|
chainName: string;
|
|
117
|
+
password?: string;
|
|
114
118
|
}): Promise<{
|
|
115
119
|
derivedPrivateKey: string | undefined;
|
|
116
120
|
}>;
|
|
@@ -125,10 +129,16 @@ export declare class DynamicWalletClient {
|
|
|
125
129
|
keyShare: ClientKeyShare;
|
|
126
130
|
password?: string;
|
|
127
131
|
}): Promise<string>;
|
|
128
|
-
storeEncryptedBackupByWallet({ accountAddress, password, }: {
|
|
132
|
+
storeEncryptedBackupByWallet({ accountAddress, password, walletOperation, }: {
|
|
129
133
|
accountAddress: string;
|
|
130
134
|
password?: string;
|
|
135
|
+
walletOperation?: WalletOperation;
|
|
131
136
|
}): Promise<any>;
|
|
137
|
+
updatePassword({ accountAddress, existingPassword, newPassword, }: {
|
|
138
|
+
accountAddress: string;
|
|
139
|
+
existingPassword?: string;
|
|
140
|
+
newPassword?: string;
|
|
141
|
+
}): Promise<void>;
|
|
132
142
|
decryptKeyShare({ keyShare, password, }: {
|
|
133
143
|
keyShare: string;
|
|
134
144
|
password?: string;
|
|
@@ -142,14 +152,18 @@ export declare class DynamicWalletClient {
|
|
|
142
152
|
* @param thresholdSignatureScheme - The signature scheme being used (2-of-2, 2-of-3, etc)
|
|
143
153
|
* @param walletOperation - The operation being performed (REFRESH, SIGN_MESSAGE, etc)
|
|
144
154
|
* @param shareCount - The number of shares to recover if specified for reshare operations
|
|
145
|
-
* @returns Object mapping backup locations to arrays of share IDs to recover
|
|
155
|
+
* @returns @shares: Object mapping backup locations to arrays of share IDs to recover
|
|
156
|
+
* @returns @requiredShareCount: The number of shares required to recover
|
|
146
157
|
*/
|
|
147
158
|
recoverStrategy({ clientKeyShareBackupInfo, thresholdSignatureScheme, walletOperation, shareCount, }: {
|
|
148
159
|
clientKeyShareBackupInfo: KeyShareBackupInfo;
|
|
149
160
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
150
161
|
walletOperation: WalletOperation;
|
|
151
162
|
shareCount?: number;
|
|
152
|
-
}):
|
|
163
|
+
}): {
|
|
164
|
+
shares: Partial<Record<BackupLocation, string[]>>;
|
|
165
|
+
requiredShareCount: number;
|
|
166
|
+
};
|
|
153
167
|
recoverEncryptedBackupByWallet({ accountAddress, password, walletOperation, shareCount, }: {
|
|
154
168
|
accountAddress: string;
|
|
155
169
|
password?: string;
|
|
@@ -180,11 +194,13 @@ export declare class DynamicWalletClient {
|
|
|
180
194
|
rawPublicKey: EcdsaPublicKey | Uint8Array | undefined;
|
|
181
195
|
clientKeyShares: ClientKeyShare[];
|
|
182
196
|
}>;
|
|
183
|
-
exportClientKeyshares({ accountAddress }: {
|
|
197
|
+
exportClientKeyshares({ accountAddress, password }: {
|
|
184
198
|
accountAddress: string;
|
|
199
|
+
password?: string;
|
|
185
200
|
}): Promise<void>;
|
|
186
|
-
getClientKeyShares({ accountAddress }: {
|
|
201
|
+
getClientKeyShares({ accountAddress, password }: {
|
|
187
202
|
accountAddress: string;
|
|
203
|
+
password?: string;
|
|
188
204
|
}): Promise<ClientKeyShare[]>;
|
|
189
205
|
/**
|
|
190
206
|
* Helper function to check if the required wallet fields are present and valid
|
|
@@ -193,10 +209,41 @@ export declare class DynamicWalletClient {
|
|
|
193
209
|
* @returns boolean indicating if wallet needs to be re-fetched and restored from server
|
|
194
210
|
*/
|
|
195
211
|
private checkWalletFields;
|
|
196
|
-
|
|
212
|
+
/**
|
|
213
|
+
* verifyPassword attempts to recover and decrypt 1 client key share using the provided password
|
|
214
|
+
* if successful, the key share is encrypted with the new password and stored
|
|
215
|
+
* if unsuccessful, throws an error
|
|
216
|
+
*/
|
|
217
|
+
verifyPassword({ accountAddress, password, walletOperation, }: {
|
|
218
|
+
accountAddress: string;
|
|
219
|
+
password?: string;
|
|
220
|
+
walletOperation?: WalletOperation;
|
|
221
|
+
}): Promise<void>;
|
|
222
|
+
isPasswordEncrypted({ accountAddress }: {
|
|
223
|
+
accountAddress: string;
|
|
224
|
+
}): Promise<boolean>;
|
|
225
|
+
/**
|
|
226
|
+
* check if the operation requires a password
|
|
227
|
+
*/
|
|
228
|
+
requiresPasswordForOperation({ accountAddress, walletOperation, }: {
|
|
229
|
+
accountAddress: string;
|
|
230
|
+
walletOperation?: WalletOperation;
|
|
231
|
+
}): Promise<boolean>;
|
|
232
|
+
/**
|
|
233
|
+
* check if the operation requires restoring backup shares
|
|
234
|
+
*/
|
|
235
|
+
requiresRestoreBackupSharesForOperation({ accountAddress, walletOperation, }: {
|
|
236
|
+
accountAddress: string;
|
|
237
|
+
walletOperation?: WalletOperation;
|
|
238
|
+
}): Promise<boolean>;
|
|
239
|
+
getWalletClientKeyShareBackupInfo({ accountAddress, }: {
|
|
240
|
+
accountAddress: string;
|
|
241
|
+
}): Promise<KeyShareBackupInfo>;
|
|
242
|
+
getWallet({ accountAddress, walletOperation, shareCount, password, }: {
|
|
197
243
|
accountAddress: string;
|
|
198
244
|
walletOperation?: WalletOperation;
|
|
199
245
|
shareCount?: number;
|
|
246
|
+
password?: string;
|
|
200
247
|
}): Promise<WalletProperties>;
|
|
201
248
|
getWallets(): Promise<any>;
|
|
202
249
|
}
|
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,wBAAwB,EACxB,gBAAgB,EAIhB,cAAc,EACf,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAIL,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAElB,cAAc,EACf,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAoBrE,OAAO,EAGL,gBAAgB,EAEjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,wBAAwB,EACxB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EAChB,MAAM,SAAS,CAAC;AAIjB,qBAAa,mBAAmB;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,OAAO,CAAC;IAEtB,SAAS,CAAC,iBAAiB,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAQ;IACrE,SAAS,CAAC,MAAM,wCAAU;IAC1B,SAAS,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACtC,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAM;IAC3D,SAAS,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACpC,SAAS,CAAC,aAAa,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI,CAAQ;IACjE,SAA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AAc,CAAC,EACnB,cAAc,EACd,QAAoB,EACpB,eAA8C,GAC/C,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,eAAe,CAAC,EAAE,eAAe,CAAC;KACnC;IAuCK,mBAAmB,CAAC,EAAE,cAAc,EAAE,EAAE;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAK3F;;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;IASpB;;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;IA4Bd,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;IA4DK,UAAU;CAiCjB"}
|
package/src/types.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ export declare enum WalletOperation {
|
|
|
10
10
|
SIGN_TRANSACTION = "SIGN_TRANSACTION",
|
|
11
11
|
REFRESH = "REFRESH",
|
|
12
12
|
RESHARE = "RESHARE",
|
|
13
|
-
EXPORT_PRIVATE_KEY = "EXPORT_PRIVATE_KEY"
|
|
13
|
+
EXPORT_PRIVATE_KEY = "EXPORT_PRIVATE_KEY",
|
|
14
|
+
NO_OPERATION = "NO_OPERATION"
|
|
14
15
|
}
|
|
15
16
|
export interface WalletProperties {
|
|
16
17
|
chainName: string;
|
|
@@ -26,7 +27,7 @@ export interface KeyShareBackupInfo {
|
|
|
26
27
|
backups: Record<BackupLocation, string[]>;
|
|
27
28
|
}
|
|
28
29
|
export interface WaasWalletProperties {
|
|
29
|
-
derivationPath
|
|
30
|
+
derivationPath?: string;
|
|
30
31
|
keyShares: KeyShareInfo[];
|
|
31
32
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
32
33
|
}
|
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,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,GAAG,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,MAAM,gBAAgB,GAAG;IAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,CAAC;AAEzD,oBAAY,eAAe;IACzB,eAAe,oBAAoB;IACnC,iBAAiB,sBAAsB;IACvC,YAAY,iBAAiB;IAC7B,gBAAgB,qBAAqB;IACrC,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,kBAAkB,uBAAuB;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../packages/src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,GAAG,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,MAAM,gBAAgB,GAAG;IAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,CAAC;AAEzD,oBAAY,eAAe;IACzB,eAAe,oBAAoB;IACnC,iBAAiB,sBAAsB;IACvC,YAAY,iBAA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