@dynamic-labs-wallet/node 0.0.135 → 0.0.136
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 +93 -187
- package/index.esm.js +93 -187
- package/package.json +2 -2
- package/src/backup/encryption.d.ts +2 -42
- package/src/backup/encryption.d.ts.map +1 -1
- package/src/client.d.ts +8 -15
- package/src/client.d.ts.map +1 -1
- package/src/backup/utils.d.ts +0 -4
- package/src/backup/utils.d.ts.map +0 -1
package/index.cjs.js
CHANGED
|
@@ -160,33 +160,12 @@ const formatMessage = (chainName, message)=>{
|
|
|
160
160
|
}
|
|
161
161
|
};
|
|
162
162
|
|
|
163
|
-
const ENCRYPTION_VERSION_LEGACY = 'v1';
|
|
164
|
-
const ENCRYPTION_VERSION_CURRENT = 'v2';
|
|
165
163
|
const PBKDF2_ALGORITHM = 'PBKDF2';
|
|
164
|
+
const PBKDF2_ITERATIONS = 100000;
|
|
166
165
|
const PBKDF2_HASH_ALGORITHM = 'SHA-256';
|
|
167
166
|
const AES_GCM_ALGORITHM = 'AES-GCM';
|
|
168
167
|
const AES_GCM_LENGTH = 256;
|
|
169
|
-
const
|
|
170
|
-
[ENCRYPTION_VERSION_LEGACY]: {
|
|
171
|
-
version: ENCRYPTION_VERSION_LEGACY,
|
|
172
|
-
algorithm: AES_GCM_ALGORITHM,
|
|
173
|
-
keyDerivation: PBKDF2_ALGORITHM,
|
|
174
|
-
iterations: 100000,
|
|
175
|
-
hashAlgorithm: PBKDF2_HASH_ALGORITHM,
|
|
176
|
-
algorithmLength: AES_GCM_LENGTH
|
|
177
|
-
},
|
|
178
|
-
[ENCRYPTION_VERSION_CURRENT]: {
|
|
179
|
-
version: ENCRYPTION_VERSION_CURRENT,
|
|
180
|
-
algorithm: AES_GCM_ALGORITHM,
|
|
181
|
-
keyDerivation: PBKDF2_ALGORITHM,
|
|
182
|
-
iterations: 1000000,
|
|
183
|
-
hashAlgorithm: PBKDF2_HASH_ALGORITHM,
|
|
184
|
-
algorithmLength: AES_GCM_LENGTH
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
ENCRYPTION_VERSIONS[ENCRYPTION_VERSION_CURRENT].iterations;
|
|
188
|
-
ENCRYPTION_VERSIONS[ENCRYPTION_VERSION_LEGACY].iterations;
|
|
189
|
-
const getKey = async ({ password, salt, encryptionConfig })=>{
|
|
168
|
+
const getKey = async ({ password, salt })=>{
|
|
190
169
|
const passwordBytes = stringToBytes(password);
|
|
191
170
|
const initialKey = await crypto.subtle.importKey('raw', passwordBytes, {
|
|
192
171
|
name: 'PBKDF2'
|
|
@@ -194,34 +173,26 @@ const getKey = async ({ password, salt, encryptionConfig })=>{
|
|
|
194
173
|
'deriveKey'
|
|
195
174
|
]);
|
|
196
175
|
return crypto.subtle.deriveKey({
|
|
197
|
-
name:
|
|
198
|
-
salt
|
|
199
|
-
iterations:
|
|
200
|
-
hash:
|
|
176
|
+
name: PBKDF2_ALGORITHM,
|
|
177
|
+
salt,
|
|
178
|
+
iterations: PBKDF2_ITERATIONS,
|
|
179
|
+
hash: PBKDF2_HASH_ALGORITHM
|
|
201
180
|
}, initialKey, {
|
|
202
|
-
name:
|
|
203
|
-
length:
|
|
181
|
+
name: AES_GCM_ALGORITHM,
|
|
182
|
+
length: AES_GCM_LENGTH
|
|
204
183
|
}, false, [
|
|
205
184
|
'encrypt',
|
|
206
185
|
'decrypt'
|
|
207
186
|
]);
|
|
208
187
|
};
|
|
209
|
-
|
|
210
|
-
* Encrypts data using the specified encryption version.
|
|
211
|
-
* Always uses the latest encryption configuration for new encryptions by default.
|
|
212
|
-
*/ const encryptData = async ({ data, password, version = ENCRYPTION_VERSION_CURRENT })=>{
|
|
213
|
-
const encryptionConfig = ENCRYPTION_VERSIONS[version];
|
|
214
|
-
if (!encryptionConfig) {
|
|
215
|
-
throw new Error(`Unsupported encryption version: ${version}`);
|
|
216
|
-
}
|
|
188
|
+
const encryptData = async ({ data, password })=>{
|
|
217
189
|
try {
|
|
218
190
|
// Generate a random salt and IV
|
|
219
191
|
const salt = crypto.getRandomValues(new Uint8Array(16));
|
|
220
192
|
const iv = crypto.getRandomValues(new Uint8Array(12)); // AES-GCM requires 12 bytes
|
|
221
193
|
const key = await getKey({
|
|
222
194
|
password,
|
|
223
|
-
salt
|
|
224
|
-
encryptionConfig
|
|
195
|
+
salt
|
|
225
196
|
});
|
|
226
197
|
// Convert the input string to bytes
|
|
227
198
|
const dataBytes = new TextEncoder().encode(data);
|
|
@@ -234,39 +205,25 @@ const getKey = async ({ password, salt, encryptionConfig })=>{
|
|
|
234
205
|
return {
|
|
235
206
|
salt: bytesToBase64(salt),
|
|
236
207
|
iv: bytesToBase64(iv),
|
|
237
|
-
cipher: bytesToBase64(new Uint8Array(encryptedData))
|
|
238
|
-
version
|
|
208
|
+
cipher: bytesToBase64(new Uint8Array(encryptedData))
|
|
239
209
|
};
|
|
240
210
|
} catch (error) {
|
|
241
211
|
throw new Error('Error encrypting data');
|
|
242
212
|
}
|
|
243
213
|
};
|
|
244
|
-
|
|
245
|
-
* Decrypts data with version-based configuration.
|
|
246
|
-
* Uses the version field from the data to determine encryption parameters.
|
|
247
|
-
* Falls back to legacy version for backward compatibility if no version is specified.
|
|
248
|
-
*/ const decryptData = async ({ data, password })=>{
|
|
249
|
-
const { salt, iv, cipher, version } = data;
|
|
250
|
-
// Ensure proper base64 padding for all values
|
|
251
|
-
const paddedSalt = ensureBase64Padding(salt);
|
|
252
|
-
const paddedIv = ensureBase64Padding(iv);
|
|
253
|
-
const paddedCipher = ensureBase64Padding(cipher);
|
|
254
|
-
const saltBytes = base64ToBytes(paddedSalt);
|
|
255
|
-
const ivBytes = base64ToBytes(paddedIv);
|
|
256
|
-
const cipherBytes = base64ToBytes(paddedCipher);
|
|
257
|
-
let encryptionConfig;
|
|
258
|
-
// Use version-based configuration if available, otherwise fallback to legacy
|
|
259
|
-
if (version && ENCRYPTION_VERSIONS[version]) {
|
|
260
|
-
encryptionConfig = ENCRYPTION_VERSIONS[version];
|
|
261
|
-
} else {
|
|
262
|
-
// Fallback to legacy version for backward compatibility
|
|
263
|
-
encryptionConfig = ENCRYPTION_VERSIONS[ENCRYPTION_VERSION_LEGACY];
|
|
264
|
-
}
|
|
214
|
+
const decryptData = async ({ data, password })=>{
|
|
265
215
|
try {
|
|
216
|
+
const { salt, iv, cipher } = data;
|
|
217
|
+
// Ensure proper base64 padding for all values
|
|
218
|
+
const paddedSalt = ensureBase64Padding(salt);
|
|
219
|
+
const paddedIv = ensureBase64Padding(iv);
|
|
220
|
+
const paddedCipher = ensureBase64Padding(cipher);
|
|
221
|
+
const saltBytes = base64ToBytes(paddedSalt);
|
|
222
|
+
const ivBytes = base64ToBytes(paddedIv);
|
|
223
|
+
const cipherBytes = base64ToBytes(paddedCipher);
|
|
266
224
|
const key = await getKey({
|
|
267
225
|
password,
|
|
268
|
-
salt: saltBytes
|
|
269
|
-
encryptionConfig
|
|
226
|
+
salt: saltBytes
|
|
270
227
|
});
|
|
271
228
|
const decryptedData = await crypto.subtle.decrypt({
|
|
272
229
|
name: AES_GCM_ALGORITHM,
|
|
@@ -274,7 +231,7 @@ const getKey = async ({ password, salt, encryptionConfig })=>{
|
|
|
274
231
|
}, key, cipherBytes);
|
|
275
232
|
return new TextDecoder().decode(decryptedData);
|
|
276
233
|
} catch (error) {
|
|
277
|
-
throw new Error('Decryption failed
|
|
234
|
+
throw new Error('Decryption failed');
|
|
278
235
|
}
|
|
279
236
|
};
|
|
280
237
|
|
|
@@ -507,6 +464,7 @@ class DynamicWalletClient {
|
|
|
507
464
|
throw error;
|
|
508
465
|
}
|
|
509
466
|
}
|
|
467
|
+
//todo: need to modify with imported flag
|
|
510
468
|
async sign({ accountAddress, externalServerKeyShares, message, chainName, password = undefined, isFormatted = false }) {
|
|
511
469
|
await this.verifyPassword({
|
|
512
470
|
accountAddress,
|
|
@@ -518,10 +476,6 @@ class DynamicWalletClient {
|
|
|
518
476
|
walletOperation: core.WalletOperation.SIGN_MESSAGE,
|
|
519
477
|
password
|
|
520
478
|
});
|
|
521
|
-
externalServerKeyShares = externalServerKeyShares != null ? externalServerKeyShares : wallet.externalServerKeyShares;
|
|
522
|
-
if (!externalServerKeyShares) {
|
|
523
|
-
throw new Error('External server key shares are required to sign a message');
|
|
524
|
-
}
|
|
525
479
|
// Perform the dynamic server sign
|
|
526
480
|
const data = await this.dynamicServerSign({
|
|
527
481
|
walletId: wallet.walletId,
|
|
@@ -540,7 +494,7 @@ class DynamicWalletClient {
|
|
|
540
494
|
});
|
|
541
495
|
return signature;
|
|
542
496
|
}
|
|
543
|
-
async refreshWalletAccountShares({ accountAddress, chainName, password = undefined
|
|
497
|
+
async refreshWalletAccountShares({ accountAddress, chainName, password = undefined }) {
|
|
544
498
|
this.ensureApiClientAuthenticated();
|
|
545
499
|
await this.verifyPassword({
|
|
546
500
|
accountAddress,
|
|
@@ -561,19 +515,14 @@ class DynamicWalletClient {
|
|
|
561
515
|
walletId: wallet.walletId
|
|
562
516
|
});
|
|
563
517
|
const roomId = data.roomId;
|
|
564
|
-
|
|
565
|
-
if (!externalServerKeyShares) {
|
|
566
|
-
throw new Error('External server key shares are required to refresh');
|
|
567
|
-
}
|
|
568
|
-
const refreshResults = await Promise.all(externalServerKeyShares.map((serverKeyShare)=>mpcSigner.refresh(roomId, serverKeyShare)));
|
|
518
|
+
const refreshResults = await Promise.all(wallet.externalServerKeyShares.map((serverKeyShare)=>mpcSigner.refresh(roomId, serverKeyShare)));
|
|
569
519
|
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress], {
|
|
570
520
|
externalServerKeyShares: refreshResults,
|
|
571
521
|
externalServerKeySharesBackupInfo: getExternalServerKeyShareBackupInfo()
|
|
572
522
|
});
|
|
573
523
|
await this.storeEncryptedBackupByWallet({
|
|
574
524
|
accountAddress,
|
|
575
|
-
password: password != null ? password : this.environmentId
|
|
576
|
-
backUpToClientShareService
|
|
525
|
+
password: password != null ? password : this.environmentId
|
|
577
526
|
});
|
|
578
527
|
return refreshResults;
|
|
579
528
|
}
|
|
@@ -626,7 +575,7 @@ class DynamicWalletClient {
|
|
|
626
575
|
existingExternalServerKeyShares
|
|
627
576
|
};
|
|
628
577
|
}
|
|
629
|
-
async reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password = undefined
|
|
578
|
+
async reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password = undefined }) {
|
|
630
579
|
this.ensureApiClientAuthenticated();
|
|
631
580
|
await this.verifyPassword({
|
|
632
581
|
accountAddress,
|
|
@@ -643,15 +592,9 @@ class DynamicWalletClient {
|
|
|
643
592
|
shareCount: existingExternalServerShareCount,
|
|
644
593
|
password
|
|
645
594
|
});
|
|
646
|
-
externalServerKeyShares = externalServerKeyShares != null ? externalServerKeyShares : wallet.externalServerKeyShares;
|
|
647
|
-
if (!externalServerKeyShares) {
|
|
648
|
-
throw new Error('External server key shares are required to reshare');
|
|
649
|
-
}
|
|
650
595
|
const { newExternalServerInitKeygenResults, newExternalServerKeygenIds, existingExternalServerKeygenIds, existingExternalServerKeyShares } = await this.reshareStrategy({
|
|
651
596
|
chainName,
|
|
652
|
-
wallet
|
|
653
|
-
externalServerKeyShares
|
|
654
|
-
}),
|
|
597
|
+
wallet,
|
|
655
598
|
oldThresholdSignatureScheme,
|
|
656
599
|
newThresholdSignatureScheme
|
|
657
600
|
});
|
|
@@ -689,8 +632,7 @@ class DynamicWalletClient {
|
|
|
689
632
|
});
|
|
690
633
|
await this.storeEncryptedBackupByWallet({
|
|
691
634
|
accountAddress,
|
|
692
|
-
password
|
|
693
|
-
backUpToClientShareService
|
|
635
|
+
password
|
|
694
636
|
});
|
|
695
637
|
return reshareResults;
|
|
696
638
|
}
|
|
@@ -706,10 +648,6 @@ class DynamicWalletClient {
|
|
|
706
648
|
password,
|
|
707
649
|
walletOperation: core.WalletOperation.EXPORT_PRIVATE_KEY
|
|
708
650
|
});
|
|
709
|
-
externalServerKeyShares = externalServerKeyShares != null ? externalServerKeyShares : wallet.externalServerKeyShares;
|
|
710
|
-
if (!externalServerKeyShares) {
|
|
711
|
-
throw new Error('External server key shares are required to export a private key');
|
|
712
|
-
}
|
|
713
651
|
const mpcSigner = getMPCSigner({
|
|
714
652
|
chainName,
|
|
715
653
|
baseRelayUrl: this.baseMPCRelayApiUrl
|
|
@@ -794,7 +732,7 @@ class DynamicWalletClient {
|
|
|
794
732
|
throw new Error('Ceremony completion timeout');
|
|
795
733
|
}
|
|
796
734
|
}
|
|
797
|
-
async storeEncryptedBackupByWallet({ accountAddress, externalServerKeyShares = undefined, password = undefined
|
|
735
|
+
async storeEncryptedBackupByWallet({ accountAddress, externalServerKeyShares = undefined, password = undefined }) {
|
|
798
736
|
this.ensureApiClientAuthenticated();
|
|
799
737
|
//add retry logic for ceremony completion to prevent race condition
|
|
800
738
|
await this.ensureCeremonyCompletionBeforeBackup({
|
|
@@ -802,8 +740,7 @@ class DynamicWalletClient {
|
|
|
802
740
|
});
|
|
803
741
|
try {
|
|
804
742
|
const keySharesToBackup = externalServerKeyShares != null ? externalServerKeyShares : await this.getExternalServerKeyShares({
|
|
805
|
-
accountAddress
|
|
806
|
-
password
|
|
743
|
+
accountAddress
|
|
807
744
|
});
|
|
808
745
|
if (!keySharesToBackup || keySharesToBackup.length === 0) {
|
|
809
746
|
throw new Error(`Key shares not found for accountAddress: ${accountAddress}`);
|
|
@@ -815,42 +752,27 @@ class DynamicWalletClient {
|
|
|
815
752
|
if (!this.walletMap[accountAddress] || !this.walletMap[accountAddress].walletId) {
|
|
816
753
|
throw new Error(`WalletId not found for accountAddress: ${accountAddress}`);
|
|
817
754
|
}
|
|
818
|
-
|
|
819
|
-
if (backUpToClientShareService) {
|
|
820
|
-
const data = await this.apiClient.storeEncryptedBackupByWallet({
|
|
821
|
-
walletId: this.walletMap[accountAddress].walletId,
|
|
822
|
-
encryptedKeyShares: encryptedKeyShares,
|
|
823
|
-
passwordEncrypted: Boolean(password) && password !== this.environmentId,
|
|
824
|
-
encryptionVersion: ENCRYPTION_VERSION_CURRENT,
|
|
825
|
-
requiresSignedSessionId: false
|
|
826
|
-
});
|
|
827
|
-
locations.push({
|
|
828
|
-
location: core.BackupLocation.DYNAMIC,
|
|
829
|
-
externalKeyShareId: data.keyShareIds[0]
|
|
830
|
-
});
|
|
831
|
-
} else {
|
|
832
|
-
locations.push({
|
|
833
|
-
location: core.BackupLocation.EXTERNAL
|
|
834
|
-
});
|
|
835
|
-
}
|
|
836
|
-
const backupData = await this.apiClient.markKeySharesAsBackedUp({
|
|
755
|
+
await this.apiClient.markKeySharesAsBackedUp({
|
|
837
756
|
walletId: this.walletMap[accountAddress].walletId,
|
|
838
|
-
locations
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
keyShares: backupData.locationsWithKeyShares.map((ks)=>({
|
|
844
|
-
id: ks.keyShareId,
|
|
845
|
-
backupLocation: ks.location,
|
|
846
|
-
externalKeyShareId: ks.externalKeyShareId,
|
|
847
|
-
passwordEncrypted: Boolean(password) && password !== this.environmentId
|
|
848
|
-
})),
|
|
849
|
-
thresholdSignatureScheme: this.walletMap[accountAddress].thresholdSignatureScheme
|
|
850
|
-
}
|
|
757
|
+
locations: [
|
|
758
|
+
{
|
|
759
|
+
location: core.BackupLocation.EXTERNAL
|
|
760
|
+
}
|
|
761
|
+
]
|
|
851
762
|
});
|
|
852
763
|
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress], {
|
|
853
|
-
externalServerKeySharesBackupInfo:
|
|
764
|
+
externalServerKeySharesBackupInfo: getExternalServerKeyShareBackupInfo({
|
|
765
|
+
walletProperties: {
|
|
766
|
+
derivationPath: this.walletMap[accountAddress].derivationPath,
|
|
767
|
+
keyShares: encryptedKeyShares.map((encryptedKeyShare)=>({
|
|
768
|
+
id: uuid.v4(),
|
|
769
|
+
encryptedKeyShare,
|
|
770
|
+
backupLocation: core.BackupLocation.EXTERNAL,
|
|
771
|
+
passwordEncrypted: Boolean(password) && password !== this.environmentId
|
|
772
|
+
})),
|
|
773
|
+
thresholdSignatureScheme: this.walletMap[accountAddress].thresholdSignatureScheme
|
|
774
|
+
}
|
|
775
|
+
})
|
|
854
776
|
});
|
|
855
777
|
return encryptedKeyShares;
|
|
856
778
|
} catch (error) {
|
|
@@ -858,16 +780,19 @@ class DynamicWalletClient {
|
|
|
858
780
|
throw error;
|
|
859
781
|
}
|
|
860
782
|
}
|
|
861
|
-
async storeEncryptedBackupByWalletWithRetry({ accountAddress, externalServerKeyShares, password
|
|
783
|
+
async storeEncryptedBackupByWalletWithRetry({ accountAddress, externalServerKeyShares, password }) {
|
|
862
784
|
await retryPromise(()=>this.storeEncryptedBackupByWallet({
|
|
863
785
|
accountAddress,
|
|
864
786
|
externalServerKeyShares,
|
|
865
|
-
password
|
|
866
|
-
backUpToClientShareService
|
|
787
|
+
password
|
|
867
788
|
}), {
|
|
868
789
|
operationName: 'store encrypted backup',
|
|
869
790
|
logContext: {
|
|
870
|
-
walletAddress: accountAddress
|
|
791
|
+
walletAddress: accountAddress,
|
|
792
|
+
keyShares: externalServerKeyShares == null ? void 0 : externalServerKeyShares.map((keyShare)=>this.encryptKeyShare({
|
|
793
|
+
keyShare,
|
|
794
|
+
password
|
|
795
|
+
}))
|
|
871
796
|
}
|
|
872
797
|
});
|
|
873
798
|
}
|
|
@@ -879,7 +804,7 @@ class DynamicWalletClient {
|
|
|
879
804
|
});
|
|
880
805
|
return wallet.externalServerKeyShares;
|
|
881
806
|
}
|
|
882
|
-
async updatePassword({ accountAddress, existingPassword, newPassword
|
|
807
|
+
async updatePassword({ accountAddress, existingPassword, newPassword }) {
|
|
883
808
|
await this.getWallet({
|
|
884
809
|
accountAddress,
|
|
885
810
|
password: existingPassword,
|
|
@@ -887,8 +812,7 @@ class DynamicWalletClient {
|
|
|
887
812
|
});
|
|
888
813
|
await this.storeEncryptedBackupByWallet({
|
|
889
814
|
accountAddress,
|
|
890
|
-
password: newPassword
|
|
891
|
-
backUpToClientShareService
|
|
815
|
+
password: newPassword
|
|
892
816
|
});
|
|
893
817
|
}
|
|
894
818
|
async decryptKeyShare({ keyShare, password }) {
|
|
@@ -1105,61 +1029,43 @@ class DynamicWalletClient {
|
|
|
1105
1029
|
walletProperties: wallet == null ? void 0 : wallet.walletProperties
|
|
1106
1030
|
});
|
|
1107
1031
|
}
|
|
1108
|
-
async getWallet({ accountAddress, walletOperation = core.WalletOperation.NO_OPERATION, shareCount = undefined
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
this.logger.debug(`Wallet ${accountAddress} already exists`);
|
|
1119
|
-
return this.walletMap[accountAddress];
|
|
1120
|
-
}
|
|
1121
|
-
//todo: Question - why don't we just call getWallets here? so then all are preloaded
|
|
1122
|
-
// Fetch and restore wallet from server
|
|
1123
|
-
const user = await this.apiClient.getUser();
|
|
1124
|
-
const wallet = (_user_verifiedCredentials = user.verifiedCredentials) == null ? void 0 : _user_verifiedCredentials.find((vc)=>vc.address.toLowerCase() === accountAddress.toLowerCase());
|
|
1125
|
-
this.logger.debug('Restoring wallet', wallet);
|
|
1126
|
-
const walletProperties = wallet.walletProperties;
|
|
1127
|
-
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress], {
|
|
1128
|
-
walletId: wallet.id,
|
|
1129
|
-
chainName: wallet.chainName,
|
|
1130
|
-
accountAddress,
|
|
1131
|
-
thresholdSignatureScheme: walletProperties.thresholdSignatureScheme,
|
|
1132
|
-
derivationPath: walletProperties.derivationPath,
|
|
1133
|
-
externalServerKeySharesBackupInfo: getExternalServerKeyShareBackupInfo({
|
|
1134
|
-
walletProperties
|
|
1135
|
-
})
|
|
1136
|
-
});
|
|
1137
|
-
if (walletOperation !== core.WalletOperation.NO_OPERATION && await this.requiresRestoreBackupSharesForOperation({
|
|
1138
|
-
accountAddress,
|
|
1139
|
-
walletOperation
|
|
1140
|
-
})) {
|
|
1141
|
-
const decryptedKeyShares = await this.recoverEncryptedBackupByWallet({
|
|
1142
|
-
accountAddress,
|
|
1143
|
-
password: password != null ? password : this.environmentId,
|
|
1144
|
-
walletOperation: walletOperation,
|
|
1145
|
-
shareCount
|
|
1146
|
-
});
|
|
1147
|
-
this.logger.debug('[DynamicWaasWalletClient] Recovered backup', decryptedKeyShares);
|
|
1148
|
-
}
|
|
1149
|
-
// externalServerKeyShares
|
|
1150
|
-
const walletCount = Object.keys(this.walletMap).length;
|
|
1151
|
-
if (walletCount === 0) {
|
|
1152
|
-
throw new Error('No wallets found');
|
|
1153
|
-
}
|
|
1154
|
-
// Return the only wallet if there's just one
|
|
1155
|
-
if (walletCount === 1) {
|
|
1156
|
-
return Object.values(this.walletMap)[0];
|
|
1157
|
-
}
|
|
1032
|
+
async getWallet({ accountAddress, walletOperation = core.WalletOperation.NO_OPERATION, shareCount = undefined }) {
|
|
1033
|
+
var _user_verifiedCredentials;
|
|
1034
|
+
this.ensureApiClientAuthenticated();
|
|
1035
|
+
const existingWalletCheck = await this.checkWalletFields({
|
|
1036
|
+
accountAddress,
|
|
1037
|
+
walletOperation,
|
|
1038
|
+
shareCount
|
|
1039
|
+
});
|
|
1040
|
+
if (existingWalletCheck) {
|
|
1041
|
+
this.logger.debug(`Wallet ${accountAddress} already exists`);
|
|
1158
1042
|
return this.walletMap[accountAddress];
|
|
1159
|
-
} catch (error) {
|
|
1160
|
-
this.logger.error('Error in getWallet', error);
|
|
1161
|
-
throw error;
|
|
1162
1043
|
}
|
|
1044
|
+
//todo: Question - why don't we just call getWallets here? so then all are preloaded
|
|
1045
|
+
// Fetch and restore wallet from server
|
|
1046
|
+
const user = await this.apiClient.getUser();
|
|
1047
|
+
const wallet = (_user_verifiedCredentials = user.verifiedCredentials) == null ? void 0 : _user_verifiedCredentials.find((vc)=>vc.address.toLowerCase() === accountAddress.toLowerCase());
|
|
1048
|
+
this.logger.debug('Restoring wallet', wallet);
|
|
1049
|
+
const walletProperties = wallet.walletProperties;
|
|
1050
|
+
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress], {
|
|
1051
|
+
walletId: wallet.id,
|
|
1052
|
+
chainName: wallet.chainName,
|
|
1053
|
+
accountAddress,
|
|
1054
|
+
thresholdSignatureScheme: walletProperties.thresholdSignatureScheme,
|
|
1055
|
+
derivationPath: walletProperties.derivationPath,
|
|
1056
|
+
externalServerKeySharesBackupInfo: getExternalServerKeyShareBackupInfo({
|
|
1057
|
+
walletProperties
|
|
1058
|
+
})
|
|
1059
|
+
});
|
|
1060
|
+
const walletCount = Object.keys(this.walletMap).length;
|
|
1061
|
+
if (walletCount === 0) {
|
|
1062
|
+
throw new Error('No wallets found');
|
|
1063
|
+
}
|
|
1064
|
+
// Return the only wallet if there's just one
|
|
1065
|
+
if (walletCount === 1) {
|
|
1066
|
+
return Object.values(this.walletMap)[0];
|
|
1067
|
+
}
|
|
1068
|
+
return this.walletMap[accountAddress];
|
|
1163
1069
|
}
|
|
1164
1070
|
async getWallets() {
|
|
1165
1071
|
var _user_verifiedCredentials;
|
package/index.esm.js
CHANGED
|
@@ -160,33 +160,12 @@ const formatMessage = (chainName, message)=>{
|
|
|
160
160
|
}
|
|
161
161
|
};
|
|
162
162
|
|
|
163
|
-
const ENCRYPTION_VERSION_LEGACY = 'v1';
|
|
164
|
-
const ENCRYPTION_VERSION_CURRENT = 'v2';
|
|
165
163
|
const PBKDF2_ALGORITHM = 'PBKDF2';
|
|
164
|
+
const PBKDF2_ITERATIONS = 100000;
|
|
166
165
|
const PBKDF2_HASH_ALGORITHM = 'SHA-256';
|
|
167
166
|
const AES_GCM_ALGORITHM = 'AES-GCM';
|
|
168
167
|
const AES_GCM_LENGTH = 256;
|
|
169
|
-
const
|
|
170
|
-
[ENCRYPTION_VERSION_LEGACY]: {
|
|
171
|
-
version: ENCRYPTION_VERSION_LEGACY,
|
|
172
|
-
algorithm: AES_GCM_ALGORITHM,
|
|
173
|
-
keyDerivation: PBKDF2_ALGORITHM,
|
|
174
|
-
iterations: 100000,
|
|
175
|
-
hashAlgorithm: PBKDF2_HASH_ALGORITHM,
|
|
176
|
-
algorithmLength: AES_GCM_LENGTH
|
|
177
|
-
},
|
|
178
|
-
[ENCRYPTION_VERSION_CURRENT]: {
|
|
179
|
-
version: ENCRYPTION_VERSION_CURRENT,
|
|
180
|
-
algorithm: AES_GCM_ALGORITHM,
|
|
181
|
-
keyDerivation: PBKDF2_ALGORITHM,
|
|
182
|
-
iterations: 1000000,
|
|
183
|
-
hashAlgorithm: PBKDF2_HASH_ALGORITHM,
|
|
184
|
-
algorithmLength: AES_GCM_LENGTH
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
ENCRYPTION_VERSIONS[ENCRYPTION_VERSION_CURRENT].iterations;
|
|
188
|
-
ENCRYPTION_VERSIONS[ENCRYPTION_VERSION_LEGACY].iterations;
|
|
189
|
-
const getKey = async ({ password, salt, encryptionConfig })=>{
|
|
168
|
+
const getKey = async ({ password, salt })=>{
|
|
190
169
|
const passwordBytes = stringToBytes(password);
|
|
191
170
|
const initialKey = await crypto.subtle.importKey('raw', passwordBytes, {
|
|
192
171
|
name: 'PBKDF2'
|
|
@@ -194,34 +173,26 @@ const getKey = async ({ password, salt, encryptionConfig })=>{
|
|
|
194
173
|
'deriveKey'
|
|
195
174
|
]);
|
|
196
175
|
return crypto.subtle.deriveKey({
|
|
197
|
-
name:
|
|
198
|
-
salt
|
|
199
|
-
iterations:
|
|
200
|
-
hash:
|
|
176
|
+
name: PBKDF2_ALGORITHM,
|
|
177
|
+
salt,
|
|
178
|
+
iterations: PBKDF2_ITERATIONS,
|
|
179
|
+
hash: PBKDF2_HASH_ALGORITHM
|
|
201
180
|
}, initialKey, {
|
|
202
|
-
name:
|
|
203
|
-
length:
|
|
181
|
+
name: AES_GCM_ALGORITHM,
|
|
182
|
+
length: AES_GCM_LENGTH
|
|
204
183
|
}, false, [
|
|
205
184
|
'encrypt',
|
|
206
185
|
'decrypt'
|
|
207
186
|
]);
|
|
208
187
|
};
|
|
209
|
-
|
|
210
|
-
* Encrypts data using the specified encryption version.
|
|
211
|
-
* Always uses the latest encryption configuration for new encryptions by default.
|
|
212
|
-
*/ const encryptData = async ({ data, password, version = ENCRYPTION_VERSION_CURRENT })=>{
|
|
213
|
-
const encryptionConfig = ENCRYPTION_VERSIONS[version];
|
|
214
|
-
if (!encryptionConfig) {
|
|
215
|
-
throw new Error(`Unsupported encryption version: ${version}`);
|
|
216
|
-
}
|
|
188
|
+
const encryptData = async ({ data, password })=>{
|
|
217
189
|
try {
|
|
218
190
|
// Generate a random salt and IV
|
|
219
191
|
const salt = crypto.getRandomValues(new Uint8Array(16));
|
|
220
192
|
const iv = crypto.getRandomValues(new Uint8Array(12)); // AES-GCM requires 12 bytes
|
|
221
193
|
const key = await getKey({
|
|
222
194
|
password,
|
|
223
|
-
salt
|
|
224
|
-
encryptionConfig
|
|
195
|
+
salt
|
|
225
196
|
});
|
|
226
197
|
// Convert the input string to bytes
|
|
227
198
|
const dataBytes = new TextEncoder().encode(data);
|
|
@@ -234,39 +205,25 @@ const getKey = async ({ password, salt, encryptionConfig })=>{
|
|
|
234
205
|
return {
|
|
235
206
|
salt: bytesToBase64(salt),
|
|
236
207
|
iv: bytesToBase64(iv),
|
|
237
|
-
cipher: bytesToBase64(new Uint8Array(encryptedData))
|
|
238
|
-
version
|
|
208
|
+
cipher: bytesToBase64(new Uint8Array(encryptedData))
|
|
239
209
|
};
|
|
240
210
|
} catch (error) {
|
|
241
211
|
throw new Error('Error encrypting data');
|
|
242
212
|
}
|
|
243
213
|
};
|
|
244
|
-
|
|
245
|
-
* Decrypts data with version-based configuration.
|
|
246
|
-
* Uses the version field from the data to determine encryption parameters.
|
|
247
|
-
* Falls back to legacy version for backward compatibility if no version is specified.
|
|
248
|
-
*/ const decryptData = async ({ data, password })=>{
|
|
249
|
-
const { salt, iv, cipher, version } = data;
|
|
250
|
-
// Ensure proper base64 padding for all values
|
|
251
|
-
const paddedSalt = ensureBase64Padding(salt);
|
|
252
|
-
const paddedIv = ensureBase64Padding(iv);
|
|
253
|
-
const paddedCipher = ensureBase64Padding(cipher);
|
|
254
|
-
const saltBytes = base64ToBytes(paddedSalt);
|
|
255
|
-
const ivBytes = base64ToBytes(paddedIv);
|
|
256
|
-
const cipherBytes = base64ToBytes(paddedCipher);
|
|
257
|
-
let encryptionConfig;
|
|
258
|
-
// Use version-based configuration if available, otherwise fallback to legacy
|
|
259
|
-
if (version && ENCRYPTION_VERSIONS[version]) {
|
|
260
|
-
encryptionConfig = ENCRYPTION_VERSIONS[version];
|
|
261
|
-
} else {
|
|
262
|
-
// Fallback to legacy version for backward compatibility
|
|
263
|
-
encryptionConfig = ENCRYPTION_VERSIONS[ENCRYPTION_VERSION_LEGACY];
|
|
264
|
-
}
|
|
214
|
+
const decryptData = async ({ data, password })=>{
|
|
265
215
|
try {
|
|
216
|
+
const { salt, iv, cipher } = data;
|
|
217
|
+
// Ensure proper base64 padding for all values
|
|
218
|
+
const paddedSalt = ensureBase64Padding(salt);
|
|
219
|
+
const paddedIv = ensureBase64Padding(iv);
|
|
220
|
+
const paddedCipher = ensureBase64Padding(cipher);
|
|
221
|
+
const saltBytes = base64ToBytes(paddedSalt);
|
|
222
|
+
const ivBytes = base64ToBytes(paddedIv);
|
|
223
|
+
const cipherBytes = base64ToBytes(paddedCipher);
|
|
266
224
|
const key = await getKey({
|
|
267
225
|
password,
|
|
268
|
-
salt: saltBytes
|
|
269
|
-
encryptionConfig
|
|
226
|
+
salt: saltBytes
|
|
270
227
|
});
|
|
271
228
|
const decryptedData = await crypto.subtle.decrypt({
|
|
272
229
|
name: AES_GCM_ALGORITHM,
|
|
@@ -274,7 +231,7 @@ const getKey = async ({ password, salt, encryptionConfig })=>{
|
|
|
274
231
|
}, key, cipherBytes);
|
|
275
232
|
return new TextDecoder().decode(decryptedData);
|
|
276
233
|
} catch (error) {
|
|
277
|
-
throw new Error('Decryption failed
|
|
234
|
+
throw new Error('Decryption failed');
|
|
278
235
|
}
|
|
279
236
|
};
|
|
280
237
|
|
|
@@ -507,6 +464,7 @@ class DynamicWalletClient {
|
|
|
507
464
|
throw error;
|
|
508
465
|
}
|
|
509
466
|
}
|
|
467
|
+
//todo: need to modify with imported flag
|
|
510
468
|
async sign({ accountAddress, externalServerKeyShares, message, chainName, password = undefined, isFormatted = false }) {
|
|
511
469
|
await this.verifyPassword({
|
|
512
470
|
accountAddress,
|
|
@@ -518,10 +476,6 @@ class DynamicWalletClient {
|
|
|
518
476
|
walletOperation: WalletOperation.SIGN_MESSAGE,
|
|
519
477
|
password
|
|
520
478
|
});
|
|
521
|
-
externalServerKeyShares = externalServerKeyShares != null ? externalServerKeyShares : wallet.externalServerKeyShares;
|
|
522
|
-
if (!externalServerKeyShares) {
|
|
523
|
-
throw new Error('External server key shares are required to sign a message');
|
|
524
|
-
}
|
|
525
479
|
// Perform the dynamic server sign
|
|
526
480
|
const data = await this.dynamicServerSign({
|
|
527
481
|
walletId: wallet.walletId,
|
|
@@ -540,7 +494,7 @@ class DynamicWalletClient {
|
|
|
540
494
|
});
|
|
541
495
|
return signature;
|
|
542
496
|
}
|
|
543
|
-
async refreshWalletAccountShares({ accountAddress, chainName, password = undefined
|
|
497
|
+
async refreshWalletAccountShares({ accountAddress, chainName, password = undefined }) {
|
|
544
498
|
this.ensureApiClientAuthenticated();
|
|
545
499
|
await this.verifyPassword({
|
|
546
500
|
accountAddress,
|
|
@@ -561,19 +515,14 @@ class DynamicWalletClient {
|
|
|
561
515
|
walletId: wallet.walletId
|
|
562
516
|
});
|
|
563
517
|
const roomId = data.roomId;
|
|
564
|
-
|
|
565
|
-
if (!externalServerKeyShares) {
|
|
566
|
-
throw new Error('External server key shares are required to refresh');
|
|
567
|
-
}
|
|
568
|
-
const refreshResults = await Promise.all(externalServerKeyShares.map((serverKeyShare)=>mpcSigner.refresh(roomId, serverKeyShare)));
|
|
518
|
+
const refreshResults = await Promise.all(wallet.externalServerKeyShares.map((serverKeyShare)=>mpcSigner.refresh(roomId, serverKeyShare)));
|
|
569
519
|
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress], {
|
|
570
520
|
externalServerKeyShares: refreshResults,
|
|
571
521
|
externalServerKeySharesBackupInfo: getExternalServerKeyShareBackupInfo()
|
|
572
522
|
});
|
|
573
523
|
await this.storeEncryptedBackupByWallet({
|
|
574
524
|
accountAddress,
|
|
575
|
-
password: password != null ? password : this.environmentId
|
|
576
|
-
backUpToClientShareService
|
|
525
|
+
password: password != null ? password : this.environmentId
|
|
577
526
|
});
|
|
578
527
|
return refreshResults;
|
|
579
528
|
}
|
|
@@ -626,7 +575,7 @@ class DynamicWalletClient {
|
|
|
626
575
|
existingExternalServerKeyShares
|
|
627
576
|
};
|
|
628
577
|
}
|
|
629
|
-
async reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password = undefined
|
|
578
|
+
async reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password = undefined }) {
|
|
630
579
|
this.ensureApiClientAuthenticated();
|
|
631
580
|
await this.verifyPassword({
|
|
632
581
|
accountAddress,
|
|
@@ -643,15 +592,9 @@ class DynamicWalletClient {
|
|
|
643
592
|
shareCount: existingExternalServerShareCount,
|
|
644
593
|
password
|
|
645
594
|
});
|
|
646
|
-
externalServerKeyShares = externalServerKeyShares != null ? externalServerKeyShares : wallet.externalServerKeyShares;
|
|
647
|
-
if (!externalServerKeyShares) {
|
|
648
|
-
throw new Error('External server key shares are required to reshare');
|
|
649
|
-
}
|
|
650
595
|
const { newExternalServerInitKeygenResults, newExternalServerKeygenIds, existingExternalServerKeygenIds, existingExternalServerKeyShares } = await this.reshareStrategy({
|
|
651
596
|
chainName,
|
|
652
|
-
wallet
|
|
653
|
-
externalServerKeyShares
|
|
654
|
-
}),
|
|
597
|
+
wallet,
|
|
655
598
|
oldThresholdSignatureScheme,
|
|
656
599
|
newThresholdSignatureScheme
|
|
657
600
|
});
|
|
@@ -689,8 +632,7 @@ class DynamicWalletClient {
|
|
|
689
632
|
});
|
|
690
633
|
await this.storeEncryptedBackupByWallet({
|
|
691
634
|
accountAddress,
|
|
692
|
-
password
|
|
693
|
-
backUpToClientShareService
|
|
635
|
+
password
|
|
694
636
|
});
|
|
695
637
|
return reshareResults;
|
|
696
638
|
}
|
|
@@ -706,10 +648,6 @@ class DynamicWalletClient {
|
|
|
706
648
|
password,
|
|
707
649
|
walletOperation: WalletOperation.EXPORT_PRIVATE_KEY
|
|
708
650
|
});
|
|
709
|
-
externalServerKeyShares = externalServerKeyShares != null ? externalServerKeyShares : wallet.externalServerKeyShares;
|
|
710
|
-
if (!externalServerKeyShares) {
|
|
711
|
-
throw new Error('External server key shares are required to export a private key');
|
|
712
|
-
}
|
|
713
651
|
const mpcSigner = getMPCSigner({
|
|
714
652
|
chainName,
|
|
715
653
|
baseRelayUrl: this.baseMPCRelayApiUrl
|
|
@@ -794,7 +732,7 @@ class DynamicWalletClient {
|
|
|
794
732
|
throw new Error('Ceremony completion timeout');
|
|
795
733
|
}
|
|
796
734
|
}
|
|
797
|
-
async storeEncryptedBackupByWallet({ accountAddress, externalServerKeyShares = undefined, password = undefined
|
|
735
|
+
async storeEncryptedBackupByWallet({ accountAddress, externalServerKeyShares = undefined, password = undefined }) {
|
|
798
736
|
this.ensureApiClientAuthenticated();
|
|
799
737
|
//add retry logic for ceremony completion to prevent race condition
|
|
800
738
|
await this.ensureCeremonyCompletionBeforeBackup({
|
|
@@ -802,8 +740,7 @@ class DynamicWalletClient {
|
|
|
802
740
|
});
|
|
803
741
|
try {
|
|
804
742
|
const keySharesToBackup = externalServerKeyShares != null ? externalServerKeyShares : await this.getExternalServerKeyShares({
|
|
805
|
-
accountAddress
|
|
806
|
-
password
|
|
743
|
+
accountAddress
|
|
807
744
|
});
|
|
808
745
|
if (!keySharesToBackup || keySharesToBackup.length === 0) {
|
|
809
746
|
throw new Error(`Key shares not found for accountAddress: ${accountAddress}`);
|
|
@@ -815,42 +752,27 @@ class DynamicWalletClient {
|
|
|
815
752
|
if (!this.walletMap[accountAddress] || !this.walletMap[accountAddress].walletId) {
|
|
816
753
|
throw new Error(`WalletId not found for accountAddress: ${accountAddress}`);
|
|
817
754
|
}
|
|
818
|
-
|
|
819
|
-
if (backUpToClientShareService) {
|
|
820
|
-
const data = await this.apiClient.storeEncryptedBackupByWallet({
|
|
821
|
-
walletId: this.walletMap[accountAddress].walletId,
|
|
822
|
-
encryptedKeyShares: encryptedKeyShares,
|
|
823
|
-
passwordEncrypted: Boolean(password) && password !== this.environmentId,
|
|
824
|
-
encryptionVersion: ENCRYPTION_VERSION_CURRENT,
|
|
825
|
-
requiresSignedSessionId: false
|
|
826
|
-
});
|
|
827
|
-
locations.push({
|
|
828
|
-
location: BackupLocation.DYNAMIC,
|
|
829
|
-
externalKeyShareId: data.keyShareIds[0]
|
|
830
|
-
});
|
|
831
|
-
} else {
|
|
832
|
-
locations.push({
|
|
833
|
-
location: BackupLocation.EXTERNAL
|
|
834
|
-
});
|
|
835
|
-
}
|
|
836
|
-
const backupData = await this.apiClient.markKeySharesAsBackedUp({
|
|
755
|
+
await this.apiClient.markKeySharesAsBackedUp({
|
|
837
756
|
walletId: this.walletMap[accountAddress].walletId,
|
|
838
|
-
locations
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
keyShares: backupData.locationsWithKeyShares.map((ks)=>({
|
|
844
|
-
id: ks.keyShareId,
|
|
845
|
-
backupLocation: ks.location,
|
|
846
|
-
externalKeyShareId: ks.externalKeyShareId,
|
|
847
|
-
passwordEncrypted: Boolean(password) && password !== this.environmentId
|
|
848
|
-
})),
|
|
849
|
-
thresholdSignatureScheme: this.walletMap[accountAddress].thresholdSignatureScheme
|
|
850
|
-
}
|
|
757
|
+
locations: [
|
|
758
|
+
{
|
|
759
|
+
location: BackupLocation.EXTERNAL
|
|
760
|
+
}
|
|
761
|
+
]
|
|
851
762
|
});
|
|
852
763
|
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress], {
|
|
853
|
-
externalServerKeySharesBackupInfo:
|
|
764
|
+
externalServerKeySharesBackupInfo: getExternalServerKeyShareBackupInfo({
|
|
765
|
+
walletProperties: {
|
|
766
|
+
derivationPath: this.walletMap[accountAddress].derivationPath,
|
|
767
|
+
keyShares: encryptedKeyShares.map((encryptedKeyShare)=>({
|
|
768
|
+
id: v4(),
|
|
769
|
+
encryptedKeyShare,
|
|
770
|
+
backupLocation: BackupLocation.EXTERNAL,
|
|
771
|
+
passwordEncrypted: Boolean(password) && password !== this.environmentId
|
|
772
|
+
})),
|
|
773
|
+
thresholdSignatureScheme: this.walletMap[accountAddress].thresholdSignatureScheme
|
|
774
|
+
}
|
|
775
|
+
})
|
|
854
776
|
});
|
|
855
777
|
return encryptedKeyShares;
|
|
856
778
|
} catch (error) {
|
|
@@ -858,16 +780,19 @@ class DynamicWalletClient {
|
|
|
858
780
|
throw error;
|
|
859
781
|
}
|
|
860
782
|
}
|
|
861
|
-
async storeEncryptedBackupByWalletWithRetry({ accountAddress, externalServerKeyShares, password
|
|
783
|
+
async storeEncryptedBackupByWalletWithRetry({ accountAddress, externalServerKeyShares, password }) {
|
|
862
784
|
await retryPromise(()=>this.storeEncryptedBackupByWallet({
|
|
863
785
|
accountAddress,
|
|
864
786
|
externalServerKeyShares,
|
|
865
|
-
password
|
|
866
|
-
backUpToClientShareService
|
|
787
|
+
password
|
|
867
788
|
}), {
|
|
868
789
|
operationName: 'store encrypted backup',
|
|
869
790
|
logContext: {
|
|
870
|
-
walletAddress: accountAddress
|
|
791
|
+
walletAddress: accountAddress,
|
|
792
|
+
keyShares: externalServerKeyShares == null ? void 0 : externalServerKeyShares.map((keyShare)=>this.encryptKeyShare({
|
|
793
|
+
keyShare,
|
|
794
|
+
password
|
|
795
|
+
}))
|
|
871
796
|
}
|
|
872
797
|
});
|
|
873
798
|
}
|
|
@@ -879,7 +804,7 @@ class DynamicWalletClient {
|
|
|
879
804
|
});
|
|
880
805
|
return wallet.externalServerKeyShares;
|
|
881
806
|
}
|
|
882
|
-
async updatePassword({ accountAddress, existingPassword, newPassword
|
|
807
|
+
async updatePassword({ accountAddress, existingPassword, newPassword }) {
|
|
883
808
|
await this.getWallet({
|
|
884
809
|
accountAddress,
|
|
885
810
|
password: existingPassword,
|
|
@@ -887,8 +812,7 @@ class DynamicWalletClient {
|
|
|
887
812
|
});
|
|
888
813
|
await this.storeEncryptedBackupByWallet({
|
|
889
814
|
accountAddress,
|
|
890
|
-
password: newPassword
|
|
891
|
-
backUpToClientShareService
|
|
815
|
+
password: newPassword
|
|
892
816
|
});
|
|
893
817
|
}
|
|
894
818
|
async decryptKeyShare({ keyShare, password }) {
|
|
@@ -1105,61 +1029,43 @@ class DynamicWalletClient {
|
|
|
1105
1029
|
walletProperties: wallet == null ? void 0 : wallet.walletProperties
|
|
1106
1030
|
});
|
|
1107
1031
|
}
|
|
1108
|
-
async getWallet({ accountAddress, walletOperation = WalletOperation.NO_OPERATION, shareCount = undefined
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
this.logger.debug(`Wallet ${accountAddress} already exists`);
|
|
1119
|
-
return this.walletMap[accountAddress];
|
|
1120
|
-
}
|
|
1121
|
-
//todo: Question - why don't we just call getWallets here? so then all are preloaded
|
|
1122
|
-
// Fetch and restore wallet from server
|
|
1123
|
-
const user = await this.apiClient.getUser();
|
|
1124
|
-
const wallet = (_user_verifiedCredentials = user.verifiedCredentials) == null ? void 0 : _user_verifiedCredentials.find((vc)=>vc.address.toLowerCase() === accountAddress.toLowerCase());
|
|
1125
|
-
this.logger.debug('Restoring wallet', wallet);
|
|
1126
|
-
const walletProperties = wallet.walletProperties;
|
|
1127
|
-
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress], {
|
|
1128
|
-
walletId: wallet.id,
|
|
1129
|
-
chainName: wallet.chainName,
|
|
1130
|
-
accountAddress,
|
|
1131
|
-
thresholdSignatureScheme: walletProperties.thresholdSignatureScheme,
|
|
1132
|
-
derivationPath: walletProperties.derivationPath,
|
|
1133
|
-
externalServerKeySharesBackupInfo: getExternalServerKeyShareBackupInfo({
|
|
1134
|
-
walletProperties
|
|
1135
|
-
})
|
|
1136
|
-
});
|
|
1137
|
-
if (walletOperation !== WalletOperation.NO_OPERATION && await this.requiresRestoreBackupSharesForOperation({
|
|
1138
|
-
accountAddress,
|
|
1139
|
-
walletOperation
|
|
1140
|
-
})) {
|
|
1141
|
-
const decryptedKeyShares = await this.recoverEncryptedBackupByWallet({
|
|
1142
|
-
accountAddress,
|
|
1143
|
-
password: password != null ? password : this.environmentId,
|
|
1144
|
-
walletOperation: walletOperation,
|
|
1145
|
-
shareCount
|
|
1146
|
-
});
|
|
1147
|
-
this.logger.debug('[DynamicWaasWalletClient] Recovered backup', decryptedKeyShares);
|
|
1148
|
-
}
|
|
1149
|
-
// externalServerKeyShares
|
|
1150
|
-
const walletCount = Object.keys(this.walletMap).length;
|
|
1151
|
-
if (walletCount === 0) {
|
|
1152
|
-
throw new Error('No wallets found');
|
|
1153
|
-
}
|
|
1154
|
-
// Return the only wallet if there's just one
|
|
1155
|
-
if (walletCount === 1) {
|
|
1156
|
-
return Object.values(this.walletMap)[0];
|
|
1157
|
-
}
|
|
1032
|
+
async getWallet({ accountAddress, walletOperation = WalletOperation.NO_OPERATION, shareCount = undefined }) {
|
|
1033
|
+
var _user_verifiedCredentials;
|
|
1034
|
+
this.ensureApiClientAuthenticated();
|
|
1035
|
+
const existingWalletCheck = await this.checkWalletFields({
|
|
1036
|
+
accountAddress,
|
|
1037
|
+
walletOperation,
|
|
1038
|
+
shareCount
|
|
1039
|
+
});
|
|
1040
|
+
if (existingWalletCheck) {
|
|
1041
|
+
this.logger.debug(`Wallet ${accountAddress} already exists`);
|
|
1158
1042
|
return this.walletMap[accountAddress];
|
|
1159
|
-
} catch (error) {
|
|
1160
|
-
this.logger.error('Error in getWallet', error);
|
|
1161
|
-
throw error;
|
|
1162
1043
|
}
|
|
1044
|
+
//todo: Question - why don't we just call getWallets here? so then all are preloaded
|
|
1045
|
+
// Fetch and restore wallet from server
|
|
1046
|
+
const user = await this.apiClient.getUser();
|
|
1047
|
+
const wallet = (_user_verifiedCredentials = user.verifiedCredentials) == null ? void 0 : _user_verifiedCredentials.find((vc)=>vc.address.toLowerCase() === accountAddress.toLowerCase());
|
|
1048
|
+
this.logger.debug('Restoring wallet', wallet);
|
|
1049
|
+
const walletProperties = wallet.walletProperties;
|
|
1050
|
+
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress], {
|
|
1051
|
+
walletId: wallet.id,
|
|
1052
|
+
chainName: wallet.chainName,
|
|
1053
|
+
accountAddress,
|
|
1054
|
+
thresholdSignatureScheme: walletProperties.thresholdSignatureScheme,
|
|
1055
|
+
derivationPath: walletProperties.derivationPath,
|
|
1056
|
+
externalServerKeySharesBackupInfo: getExternalServerKeyShareBackupInfo({
|
|
1057
|
+
walletProperties
|
|
1058
|
+
})
|
|
1059
|
+
});
|
|
1060
|
+
const walletCount = Object.keys(this.walletMap).length;
|
|
1061
|
+
if (walletCount === 0) {
|
|
1062
|
+
throw new Error('No wallets found');
|
|
1063
|
+
}
|
|
1064
|
+
// Return the only wallet if there's just one
|
|
1065
|
+
if (walletCount === 1) {
|
|
1066
|
+
return Object.values(this.walletMap)[0];
|
|
1067
|
+
}
|
|
1068
|
+
return this.walletMap[accountAddress];
|
|
1163
1069
|
}
|
|
1164
1070
|
async getWallets() {
|
|
1165
1071
|
var _user_verifiedCredentials;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/node",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.136",
|
|
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.136",
|
|
7
7
|
"@dynamic-labs/logger": "^4.25.3",
|
|
8
8
|
"uuid": "11.1.0",
|
|
9
9
|
"@noble/hashes": "1.7.1"
|
|
@@ -1,62 +1,22 @@
|
|
|
1
|
-
import { EncryptionMetadata } from '@dynamic-labs-wallet/core';
|
|
2
|
-
export declare const ENCRYPTION_VERSION_LEGACY = "v1";
|
|
3
|
-
export declare const ENCRYPTION_VERSION_CURRENT = "v2";
|
|
4
1
|
export declare const PBKDF2_ALGORITHM = "PBKDF2";
|
|
2
|
+
export declare const PBKDF2_ITERATIONS = 100000;
|
|
5
3
|
export declare const PBKDF2_HASH_ALGORITHM = "SHA-256";
|
|
6
4
|
export declare const AES_GCM_ALGORITHM = "AES-GCM";
|
|
7
5
|
export declare const AES_GCM_LENGTH = 256;
|
|
8
|
-
export declare const
|
|
9
|
-
readonly v1: {
|
|
10
|
-
readonly version: "v1";
|
|
11
|
-
readonly algorithm: "AES-GCM";
|
|
12
|
-
readonly keyDerivation: "PBKDF2";
|
|
13
|
-
readonly iterations: 100000;
|
|
14
|
-
readonly hashAlgorithm: "SHA-256";
|
|
15
|
-
readonly algorithmLength: 256;
|
|
16
|
-
};
|
|
17
|
-
readonly v2: {
|
|
18
|
-
readonly version: "v2";
|
|
19
|
-
readonly algorithm: "AES-GCM";
|
|
20
|
-
readonly keyDerivation: "PBKDF2";
|
|
21
|
-
readonly iterations: 1000000;
|
|
22
|
-
readonly hashAlgorithm: "SHA-256";
|
|
23
|
-
readonly algorithmLength: 256;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
export declare const PBKDF2_ITERATIONS: 1000000;
|
|
27
|
-
export declare const PBKDF2_ITERATIONS_LEGACY: 100000;
|
|
28
|
-
export type EncryptionVersion = (typeof ENCRYPTION_VERSIONS)[keyof typeof ENCRYPTION_VERSIONS];
|
|
29
|
-
/**
|
|
30
|
-
* Encrypts data using the specified encryption version.
|
|
31
|
-
* Always uses the latest encryption configuration for new encryptions by default.
|
|
32
|
-
*/
|
|
33
|
-
export declare const encryptData: ({ data, password, version, }: {
|
|
6
|
+
export declare const encryptData: ({ data, password, }: {
|
|
34
7
|
data: string;
|
|
35
8
|
password: string;
|
|
36
|
-
version?: string;
|
|
37
9
|
}) => Promise<{
|
|
38
10
|
salt: string;
|
|
39
11
|
iv: string;
|
|
40
12
|
cipher: string;
|
|
41
|
-
version: string;
|
|
42
13
|
}>;
|
|
43
|
-
/**
|
|
44
|
-
* Decrypts data with version-based configuration.
|
|
45
|
-
* Uses the version field from the data to determine encryption parameters.
|
|
46
|
-
* Falls back to legacy version for backward compatibility if no version is specified.
|
|
47
|
-
*/
|
|
48
14
|
export declare const decryptData: ({ data, password, }: {
|
|
49
15
|
data: {
|
|
50
16
|
salt: string;
|
|
51
17
|
iv: string;
|
|
52
18
|
cipher: string;
|
|
53
|
-
version?: string;
|
|
54
19
|
};
|
|
55
20
|
password: string;
|
|
56
21
|
}) => Promise<string>;
|
|
57
|
-
/**
|
|
58
|
-
* Gets encryption metadata for a specific version.
|
|
59
|
-
* Used when we need to include metadata in legacy systems or APIs that require it.
|
|
60
|
-
*/
|
|
61
|
-
export declare const getEncryptionMetadataForVersion: (version: string) => EncryptionMetadata;
|
|
62
22
|
//# sourceMappingURL=encryption.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../src/backup/encryption.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../src/backup/encryption.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,gBAAgB,WAAW,CAAC;AACzC,eAAO,MAAM,iBAAiB,SAAS,CAAC;AACxC,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAE/C,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAC3C,eAAO,MAAM,cAAc,MAAM,CAAC;AAiClC,eAAO,MAAM,WAAW,wBAGrB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;;;;EA2BA,CAAC;AAEF,eAAO,MAAM,WAAW,wBAGrB;IACD,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,QAAQ,EAAE,MAAM,CAAC;CAClB,oBAyBA,CAAC"}
|
package/src/client.d.ts
CHANGED
|
@@ -82,18 +82,16 @@ export declare class DynamicWalletClient {
|
|
|
82
82
|
}): Promise<Uint8Array | EcdsaSignature>;
|
|
83
83
|
sign({ accountAddress, externalServerKeyShares, message, chainName, password, isFormatted, }: {
|
|
84
84
|
accountAddress: string;
|
|
85
|
-
externalServerKeyShares
|
|
85
|
+
externalServerKeyShares: ServerKeyShare[];
|
|
86
86
|
message: string | Uint8Array;
|
|
87
87
|
chainName: string;
|
|
88
88
|
password?: string;
|
|
89
89
|
isFormatted?: boolean;
|
|
90
90
|
}): Promise<Uint8Array | EcdsaSignature>;
|
|
91
|
-
refreshWalletAccountShares({ accountAddress, chainName, password,
|
|
91
|
+
refreshWalletAccountShares({ accountAddress, chainName, password, }: {
|
|
92
92
|
accountAddress: string;
|
|
93
93
|
chainName: string;
|
|
94
94
|
password?: string;
|
|
95
|
-
externalServerKeyShares?: ServerKeyShare[];
|
|
96
|
-
backUpToClientShareService?: boolean;
|
|
97
95
|
}): Promise<(EcdsaKeygenResult | BIP340KeygenResult)[]>;
|
|
98
96
|
getExportId({ chainName, serverKeyShare, }: {
|
|
99
97
|
chainName: string;
|
|
@@ -124,20 +122,18 @@ export declare class DynamicWalletClient {
|
|
|
124
122
|
existingExternalServerKeygenIds: string[];
|
|
125
123
|
existingExternalServerKeyShares: ServerKeyShare[];
|
|
126
124
|
}>;
|
|
127
|
-
reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password,
|
|
125
|
+
reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password, }: {
|
|
128
126
|
chainName: string;
|
|
129
127
|
accountAddress: string;
|
|
130
128
|
oldThresholdSignatureScheme: ThresholdSignatureScheme;
|
|
131
129
|
newThresholdSignatureScheme: ThresholdSignatureScheme;
|
|
132
130
|
password?: string;
|
|
133
|
-
externalServerKeyShares?: ServerKeyShare[];
|
|
134
|
-
backUpToClientShareService?: boolean;
|
|
135
131
|
}): Promise<(EcdsaKeygenResult | BIP340KeygenResult)[]>;
|
|
136
132
|
exportKey({ accountAddress, chainName, password, externalServerKeyShares, }: {
|
|
137
133
|
accountAddress: string;
|
|
138
134
|
chainName: string;
|
|
139
135
|
password?: string;
|
|
140
|
-
externalServerKeyShares
|
|
136
|
+
externalServerKeyShares: ServerKeyShare[];
|
|
141
137
|
}): Promise<{
|
|
142
138
|
derivedPrivateKey: string | undefined;
|
|
143
139
|
}>;
|
|
@@ -155,27 +151,24 @@ export declare class DynamicWalletClient {
|
|
|
155
151
|
ensureCeremonyCompletionBeforeBackup({ accountAddress, }: {
|
|
156
152
|
accountAddress: string;
|
|
157
153
|
}): Promise<void>;
|
|
158
|
-
storeEncryptedBackupByWallet({ accountAddress, externalServerKeyShares, password,
|
|
154
|
+
storeEncryptedBackupByWallet({ accountAddress, externalServerKeyShares, password, }: {
|
|
159
155
|
accountAddress: string;
|
|
160
156
|
externalServerKeyShares?: ServerKeyShare[];
|
|
161
157
|
password?: string;
|
|
162
|
-
backUpToClientShareService: boolean;
|
|
163
158
|
}): Promise<string[]>;
|
|
164
|
-
storeEncryptedBackupByWalletWithRetry({ accountAddress, externalServerKeyShares, password,
|
|
159
|
+
storeEncryptedBackupByWalletWithRetry({ accountAddress, externalServerKeyShares, password, }: {
|
|
165
160
|
accountAddress: string;
|
|
166
161
|
externalServerKeyShares?: ServerKeyShare[];
|
|
167
162
|
password?: string;
|
|
168
|
-
backUpToClientShareService: boolean;
|
|
169
163
|
}): Promise<void>;
|
|
170
164
|
getExternalServerKeyShares({ accountAddress, password, }: {
|
|
171
165
|
accountAddress: string;
|
|
172
166
|
password?: string;
|
|
173
167
|
}): Promise<import("./mpc").ServerKeyShare[]>;
|
|
174
|
-
updatePassword({ accountAddress, existingPassword, newPassword,
|
|
168
|
+
updatePassword({ accountAddress, existingPassword, newPassword, }: {
|
|
175
169
|
accountAddress: string;
|
|
176
170
|
existingPassword?: string;
|
|
177
171
|
newPassword?: string;
|
|
178
|
-
backUpToClientShareService: boolean;
|
|
179
172
|
}): Promise<void>;
|
|
180
173
|
decryptKeyShare({ keyShare, password, }: {
|
|
181
174
|
keyShare: string;
|
|
@@ -250,7 +243,7 @@ export declare class DynamicWalletClient {
|
|
|
250
243
|
getWalletExternalServerKeyShareBackupInfo({ accountAddress, }: {
|
|
251
244
|
accountAddress: string;
|
|
252
245
|
}): Promise<KeyShareBackupInfo>;
|
|
253
|
-
getWallet({ accountAddress, walletOperation, shareCount,
|
|
246
|
+
getWallet({ accountAddress, walletOperation, shareCount, }: {
|
|
254
247
|
accountAddress: string;
|
|
255
248
|
walletOperation?: WalletOperation;
|
|
256
249
|
shareCount?: number;
|
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,EACL,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EAEd,cAAc,EAId,6BAA6B,EAC9B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAIhB,eAAe,EACf,kBAAkB,EAClB,cAAc,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../packages/src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EAEd,cAAc,EAId,6BAA6B,EAC9B,M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AAC,EAAE,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;IAQpB;;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;IA+Bd,yCAAyC,CAAC,EAC9C,cAAc,GACf,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;KACxB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAoBzB,SAAS,CAAC,EACd,cAAc,EACd,eAA8C,EAC9C,UAAsB,GACvB,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;IAgDK,UAAU;CAuCjB"}
|
package/src/backup/utils.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { ServerKeyShare } from '../mpc/types';
|
|
2
|
-
import { WalletProperties } from '../types';
|
|
3
|
-
export declare const checkIfExternalServerKeySharesAreRequired: (wallet: WalletProperties, externalServerKeyShares?: ServerKeyShare[]) => void;
|
|
4
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/backup/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,eAAO,MAAM,yCAAyC,WAC5C,gBAAgB,4BACE,cAAc,EAAE,SAkB3C,CAAC"}
|