@dynamic-labs-wallet/node 0.0.0-beta.271.2 → 0.0.0-beta.290.2
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 +96 -67
- package/index.esm.js +91 -64
- package/package.json +4 -3
- package/src/client.d.ts +31 -25
- package/src/client.d.ts.map +1 -1
- package/src/mpc/mpc.d.ts +4 -4
- package/src/mpc/mpc.d.ts.map +1 -1
- package/src/utils.d.ts +3 -0
- package/src/utils.d.ts.map +1 -1
package/index.cjs.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var core = require('@dynamic-labs-wallet/core');
|
|
4
4
|
var node = require('./internal/node');
|
|
5
|
+
var uuid = require('uuid');
|
|
5
6
|
var logger$1 = require('@dynamic-labs/logger');
|
|
6
7
|
var crypto = require('crypto');
|
|
7
8
|
|
|
@@ -10,7 +11,7 @@ const getMPCSignatureScheme = ({ signingAlgorithm, baseRelayUrl = core.MPC_RELAY
|
|
|
10
11
|
case core.SigningAlgorithm.ECDSA:
|
|
11
12
|
return new node.Ecdsa(baseRelayUrl);
|
|
12
13
|
case core.SigningAlgorithm.ED25519:
|
|
13
|
-
return new node.
|
|
14
|
+
return new node.ExportableEd25519(baseRelayUrl);
|
|
14
15
|
case core.SigningAlgorithm.BIP340:
|
|
15
16
|
return new node.BIP340(baseRelayUrl);
|
|
16
17
|
default:
|
|
@@ -75,7 +76,10 @@ const getExternalServerKeyShareBackupInfo = (params)=>{
|
|
|
75
76
|
}
|
|
76
77
|
params.walletProperties.keyShares.forEach((keyShare)=>{
|
|
77
78
|
if (backups[keyShare.backupLocation]) {
|
|
78
|
-
backups[keyShare.backupLocation].push(
|
|
79
|
+
backups[keyShare.backupLocation].push({
|
|
80
|
+
location: keyShare.backupLocation,
|
|
81
|
+
keyShareId: keyShare.id
|
|
82
|
+
});
|
|
79
83
|
}
|
|
80
84
|
});
|
|
81
85
|
const passwordEncrypted = Boolean((_params_walletProperties_keyShares_ = params.walletProperties.keyShares[0]) == null ? void 0 : _params_walletProperties_keyShares_.passwordEncrypted);
|
|
@@ -125,6 +129,36 @@ const getExternalServerKeyShareBackupInfo = (params)=>{
|
|
|
125
129
|
// TypeScript needs this even though it's unreachable
|
|
126
130
|
throw new Error('Unreachable code');
|
|
127
131
|
}
|
|
132
|
+
const formatEvmMessage = (message)=>{
|
|
133
|
+
if (typeof message === 'string' && message.startsWith('0x')) {
|
|
134
|
+
const serializedTxBytes = Uint8Array.from(Buffer.from(message.slice(2), 'hex'));
|
|
135
|
+
return node.MessageHash.keccak256(serializedTxBytes);
|
|
136
|
+
}
|
|
137
|
+
return node.MessageHash.keccak256(message);
|
|
138
|
+
};
|
|
139
|
+
const formatSolanaMessage = (message)=>{
|
|
140
|
+
if (typeof message === 'string') {
|
|
141
|
+
if (!isHexString(message)) {
|
|
142
|
+
return Buffer.from(message).toString('hex');
|
|
143
|
+
} else {
|
|
144
|
+
return new Uint8Array(Buffer.from(message, 'hex'));
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
return message;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
const formatMessage = (chainName, message)=>{
|
|
151
|
+
switch(chainName){
|
|
152
|
+
case 'EVM':
|
|
153
|
+
return formatEvmMessage(message);
|
|
154
|
+
case 'SVM':
|
|
155
|
+
return formatSolanaMessage(message);
|
|
156
|
+
case 'SUI':
|
|
157
|
+
return message;
|
|
158
|
+
default:
|
|
159
|
+
throw new Error('Unsupported chain name');
|
|
160
|
+
}
|
|
161
|
+
};
|
|
128
162
|
|
|
129
163
|
const PBKDF2_ALGORITHM = 'PBKDF2';
|
|
130
164
|
const PBKDF2_ITERATIONS = 100000;
|
|
@@ -227,13 +261,14 @@ class DynamicWalletClient {
|
|
|
227
261
|
});
|
|
228
262
|
this.isApiClientAuthenticated = true;
|
|
229
263
|
}
|
|
230
|
-
async dynamicServerInitializeKeyGen({ chainName, externalServerKeygenIds, thresholdSignatureScheme, onError, onCeremonyComplete }) {
|
|
264
|
+
async dynamicServerInitializeKeyGen({ chainName, externalServerKeygenIds, thresholdSignatureScheme, dynamicRequestId, onError, onCeremonyComplete }) {
|
|
231
265
|
this.ensureApiClientAuthenticated();
|
|
232
266
|
try {
|
|
233
267
|
const data = await this.apiClient.createWalletAccount({
|
|
234
268
|
chainName,
|
|
235
269
|
clientKeygenIds: externalServerKeygenIds,
|
|
236
270
|
thresholdSignatureScheme,
|
|
271
|
+
dynamicRequestId,
|
|
237
272
|
onError,
|
|
238
273
|
onCeremonyComplete
|
|
239
274
|
});
|
|
@@ -267,8 +302,8 @@ class DynamicWalletClient {
|
|
|
267
302
|
let publicKey;
|
|
268
303
|
if (mpcSigner instanceof node.Ecdsa) {
|
|
269
304
|
publicKey = await mpcSigner.derivePubkey(keyShare, derivationPath);
|
|
270
|
-
} else if (mpcSigner instanceof node.
|
|
271
|
-
publicKey = await mpcSigner.
|
|
305
|
+
} else if (mpcSigner instanceof node.ExportableEd25519) {
|
|
306
|
+
publicKey = await mpcSigner.getPubkey(keyShare);
|
|
272
307
|
}
|
|
273
308
|
return publicKey;
|
|
274
309
|
} catch (error) {
|
|
@@ -294,7 +329,13 @@ class DynamicWalletClient {
|
|
|
294
329
|
...dynamicServerKeygenIds,
|
|
295
330
|
...otherExternalServerKeygenIds
|
|
296
331
|
];
|
|
297
|
-
|
|
332
|
+
if (!(mpcSigner instanceof node.ExportableEd25519)) {
|
|
333
|
+
return mpcSigner.keygen(roomId, mpcConfig.numberOfParties, mpcConfig.threshold, currentInit, allOtherKeygenIds);
|
|
334
|
+
} else {
|
|
335
|
+
// One party joins the keygen room using acting as the sampler: (wallet-service)
|
|
336
|
+
// The remaining parties join the key sampling ceremony using: (browser)
|
|
337
|
+
return mpcSigner.receiveKey(roomId, mpcConfig.numberOfParties, mpcConfig.threshold, currentInit, allOtherKeygenIds);
|
|
338
|
+
}
|
|
298
339
|
}));
|
|
299
340
|
// only need one client keygen result to derive the public key
|
|
300
341
|
const [serverKeygenResult] = serverKeygenResults;
|
|
@@ -315,6 +356,7 @@ class DynamicWalletClient {
|
|
|
315
356
|
}
|
|
316
357
|
}
|
|
317
358
|
async keyGen({ chainName, thresholdSignatureScheme, onError, onCeremonyComplete }) {
|
|
359
|
+
const dynamicRequestId = uuid.v4();
|
|
318
360
|
try {
|
|
319
361
|
const externalServerInitKeygenResults = await this.externalServerInitializeKeyGen({
|
|
320
362
|
chainName,
|
|
@@ -324,6 +366,7 @@ class DynamicWalletClient {
|
|
|
324
366
|
const { roomId, serverKeygenIds: dynamicServerKeygenIds } = await this.dynamicServerInitializeKeyGen({
|
|
325
367
|
chainName,
|
|
326
368
|
externalServerKeygenIds,
|
|
369
|
+
dynamicRequestId,
|
|
327
370
|
thresholdSignatureScheme,
|
|
328
371
|
onCeremonyComplete
|
|
329
372
|
});
|
|
@@ -345,6 +388,7 @@ class DynamicWalletClient {
|
|
|
345
388
|
}
|
|
346
389
|
async importRawPrivateKey({ chainName, privateKey, thresholdSignatureScheme, onError, onCeremonyComplete }) {
|
|
347
390
|
this.ensureApiClientAuthenticated();
|
|
391
|
+
const dynamicRequestId = uuid.v4();
|
|
348
392
|
const mpcSigner = getMPCSigner({
|
|
349
393
|
chainName,
|
|
350
394
|
baseRelayUrl: this.baseMPCRelayApiUrl
|
|
@@ -358,6 +402,7 @@ class DynamicWalletClient {
|
|
|
358
402
|
chainName,
|
|
359
403
|
clientKeygenIds: externalServerKeygenIds,
|
|
360
404
|
thresholdSignatureScheme,
|
|
405
|
+
dynamicRequestId,
|
|
361
406
|
onError,
|
|
362
407
|
onCeremonyComplete
|
|
363
408
|
});
|
|
@@ -390,7 +435,8 @@ class DynamicWalletClient {
|
|
|
390
435
|
externalServerKeyShares: externalServerKeygenResults
|
|
391
436
|
};
|
|
392
437
|
}
|
|
393
|
-
async dynamicServerSign({ walletId, message }) {
|
|
438
|
+
async dynamicServerSign({ walletId, message, isFormatted }) {
|
|
439
|
+
const dynamicRequestId = uuid.v4();
|
|
394
440
|
this.ensureApiClientAuthenticated();
|
|
395
441
|
// Create the room and sign the message
|
|
396
442
|
if (typeof message !== 'string') {
|
|
@@ -398,35 +444,19 @@ class DynamicWalletClient {
|
|
|
398
444
|
}
|
|
399
445
|
const data = await this.apiClient.signMessage({
|
|
400
446
|
walletId,
|
|
401
|
-
message
|
|
447
|
+
message,
|
|
448
|
+
isFormatted,
|
|
449
|
+
dynamicRequestId
|
|
402
450
|
});
|
|
403
451
|
return data;
|
|
404
452
|
}
|
|
405
|
-
async externalServerSign({ chainName, message, roomId, keyShare, derivationPath }) {
|
|
453
|
+
async externalServerSign({ chainName, message, roomId, keyShare, derivationPath, isFormatted }) {
|
|
406
454
|
try {
|
|
407
455
|
const mpcSigner = getMPCSigner({
|
|
408
456
|
chainName,
|
|
409
457
|
baseRelayUrl: this.baseMPCRelayApiUrl
|
|
410
458
|
});
|
|
411
|
-
|
|
412
|
-
//note: Ecdsa can also be used by bitcoin, but only keccak256 is used by ethereum
|
|
413
|
-
if (mpcSigner instanceof node.Ecdsa) {
|
|
414
|
-
formattedMessage = node.MessageHash.keccak256(message);
|
|
415
|
-
} else if (mpcSigner instanceof node.Ed25519) {
|
|
416
|
-
if (typeof message === 'string') {
|
|
417
|
-
if (!isHexString(message)) {
|
|
418
|
-
formattedMessage = Buffer.from(message).toString('hex');
|
|
419
|
-
} else {
|
|
420
|
-
formattedMessage = Buffer.from(message, 'hex');
|
|
421
|
-
}
|
|
422
|
-
} else {
|
|
423
|
-
formattedMessage = message;
|
|
424
|
-
}
|
|
425
|
-
} else if (mpcSigner instanceof node.BIP340 && typeof message === 'string') {
|
|
426
|
-
formattedMessage = new TextEncoder().encode(message);
|
|
427
|
-
} else {
|
|
428
|
-
throw new Error('Unsupported signer type');
|
|
429
|
-
}
|
|
459
|
+
const formattedMessage = isFormatted ? new node.MessageHash(message) : formatMessage(chainName, message);
|
|
430
460
|
const signature = await mpcSigner.sign(roomId, keyShare, formattedMessage, derivationPath);
|
|
431
461
|
return signature;
|
|
432
462
|
} catch (error) {
|
|
@@ -435,7 +465,7 @@ class DynamicWalletClient {
|
|
|
435
465
|
}
|
|
436
466
|
}
|
|
437
467
|
//todo: need to modify with imported flag
|
|
438
|
-
async sign({ accountAddress, message, chainName, password = undefined, signedSessionId }) {
|
|
468
|
+
async sign({ accountAddress, externalServerKeyShares, message, chainName, password = undefined, isFormatted = false, signedSessionId }) {
|
|
439
469
|
await this.verifyPassword({
|
|
440
470
|
accountAddress,
|
|
441
471
|
password,
|
|
@@ -451,7 +481,8 @@ class DynamicWalletClient {
|
|
|
451
481
|
// Perform the dynamic server sign
|
|
452
482
|
const data = await this.dynamicServerSign({
|
|
453
483
|
walletId: wallet.walletId,
|
|
454
|
-
message
|
|
484
|
+
message,
|
|
485
|
+
isFormatted
|
|
455
486
|
});
|
|
456
487
|
const derivationPath = wallet.derivationPath && wallet.derivationPath != '' ? new Uint32Array(Object.values(JSON.parse(wallet.derivationPath))) : undefined;
|
|
457
488
|
// Perform the external server sign and return the signature
|
|
@@ -459,8 +490,9 @@ class DynamicWalletClient {
|
|
|
459
490
|
chainName,
|
|
460
491
|
message,
|
|
461
492
|
roomId: data.roomId,
|
|
462
|
-
keyShare:
|
|
463
|
-
derivationPath
|
|
493
|
+
keyShare: externalServerKeyShares[0],
|
|
494
|
+
derivationPath,
|
|
495
|
+
isFormatted
|
|
464
496
|
});
|
|
465
497
|
return signature;
|
|
466
498
|
}
|
|
@@ -612,7 +644,7 @@ class DynamicWalletClient {
|
|
|
612
644
|
});
|
|
613
645
|
return reshareResults;
|
|
614
646
|
}
|
|
615
|
-
async exportKey({ accountAddress, chainName, password = undefined, signedSessionId }) {
|
|
647
|
+
async exportKey({ accountAddress, chainName, password = undefined, signedSessionId, externalServerKeyShares }) {
|
|
616
648
|
this.ensureApiClientAuthenticated();
|
|
617
649
|
await this.verifyPassword({
|
|
618
650
|
accountAddress,
|
|
@@ -632,13 +664,13 @@ class DynamicWalletClient {
|
|
|
632
664
|
});
|
|
633
665
|
const exportId = await this.getExportId({
|
|
634
666
|
chainName,
|
|
635
|
-
serverKeyShare:
|
|
667
|
+
serverKeyShare: externalServerKeyShares[0]
|
|
636
668
|
});
|
|
637
669
|
const data = await this.apiClient.exportKey({
|
|
638
670
|
walletId: wallet.walletId,
|
|
639
671
|
exportId
|
|
640
672
|
});
|
|
641
|
-
const keyExportRaw = await mpcSigner.exportFullPrivateKey(data.roomId,
|
|
673
|
+
const keyExportRaw = await mpcSigner.exportFullPrivateKey(data.roomId, externalServerKeyShares[0], exportId);
|
|
642
674
|
if (!keyExportRaw) {
|
|
643
675
|
throw new Error('Error exporting private key');
|
|
644
676
|
}
|
|
@@ -646,7 +678,7 @@ class DynamicWalletClient {
|
|
|
646
678
|
let derivedPrivateKey;
|
|
647
679
|
if (mpcSigner instanceof node.Ecdsa) {
|
|
648
680
|
derivedPrivateKey = await mpcSigner.derivePrivateKeyFromXpriv(keyExportRaw, derivationPath);
|
|
649
|
-
} else if (mpcSigner instanceof node.
|
|
681
|
+
} else if (mpcSigner instanceof node.ExportableEd25519) {
|
|
650
682
|
derivedPrivateKey = keyExportRaw;
|
|
651
683
|
} else if (mpcSigner instanceof node.BIP340) {
|
|
652
684
|
derivedPrivateKey = await mpcSigner.derivePrivateKeyFromXpriv(keyExportRaw, derivationPath);
|
|
@@ -665,7 +697,7 @@ class DynamicWalletClient {
|
|
|
665
697
|
baseRelayUrl: this.baseMPCRelayApiUrl
|
|
666
698
|
});
|
|
667
699
|
const walletKeyShares = keyShares.map((keyShare)=>{
|
|
668
|
-
return mpcSigner instanceof node.Ecdsa ? new node.EcdsaKeygenResult(keyShare.pubkey, keyShare.secretShare) : mpcSigner instanceof node.
|
|
700
|
+
return mpcSigner instanceof node.Ecdsa ? new node.EcdsaKeygenResult(keyShare.pubkey, keyShare.secretShare) : mpcSigner instanceof node.ExportableEd25519 ? new node.ExportableEd25519KeygenResult(keyShare.pubkey, keyShare.secretShare) : new node.BIP340KeygenResult(keyShare.pubkey, keyShare.secretShare);
|
|
669
701
|
});
|
|
670
702
|
const keyExportRaw = await mpcSigner.offlineExportFullPrivateKey(walletKeyShares);
|
|
671
703
|
if (!keyExportRaw) {
|
|
@@ -676,7 +708,7 @@ class DynamicWalletClient {
|
|
|
676
708
|
let derivedPrivateKey;
|
|
677
709
|
if (mpcSigner instanceof node.Ecdsa) {
|
|
678
710
|
derivedPrivateKey = await mpcSigner.derivePrivateKeyFromXpriv(keyExportRaw, walletDerivationPath);
|
|
679
|
-
} else if (mpcSigner instanceof node.
|
|
711
|
+
} else if (mpcSigner instanceof node.ExportableEd25519) {
|
|
680
712
|
derivedPrivateKey = keyExportRaw;
|
|
681
713
|
} else if (mpcSigner instanceof node.BIP340) {
|
|
682
714
|
derivedPrivateKey = await mpcSigner.derivePrivateKeyFromXpriv(keyExportRaw, walletDerivationPath);
|
|
@@ -731,23 +763,29 @@ class DynamicWalletClient {
|
|
|
731
763
|
if (!this.walletMap[accountAddress] || !this.walletMap[accountAddress].walletId) {
|
|
732
764
|
throw new Error(`WalletId not found for accountAddress: ${accountAddress}`);
|
|
733
765
|
}
|
|
734
|
-
|
|
735
|
-
const data = await this.apiClient.storeEncryptedBackupByWallet({
|
|
766
|
+
await this.apiClient.markKeySharesAsBackedUp({
|
|
736
767
|
walletId: this.walletMap[accountAddress].walletId,
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
768
|
+
locations: [
|
|
769
|
+
{
|
|
770
|
+
location: core.BackupLocation.EXTERNAL
|
|
771
|
+
}
|
|
772
|
+
]
|
|
740
773
|
});
|
|
741
774
|
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress], {
|
|
742
775
|
externalServerKeySharesBackupInfo: getExternalServerKeyShareBackupInfo({
|
|
743
776
|
walletProperties: {
|
|
744
777
|
derivationPath: this.walletMap[accountAddress].derivationPath,
|
|
745
|
-
keyShares:
|
|
778
|
+
keyShares: encryptedKeyShares.map((encryptedKeyShare)=>({
|
|
779
|
+
id: uuid.v4(),
|
|
780
|
+
encryptedKeyShare,
|
|
781
|
+
backupLocation: core.BackupLocation.EXTERNAL,
|
|
782
|
+
passwordEncrypted: Boolean(password) && password !== this.environmentId
|
|
783
|
+
})),
|
|
746
784
|
thresholdSignatureScheme: this.walletMap[accountAddress].thresholdSignatureScheme
|
|
747
785
|
}
|
|
748
786
|
})
|
|
749
787
|
});
|
|
750
|
-
return
|
|
788
|
+
return encryptedKeyShares;
|
|
751
789
|
} catch (error) {
|
|
752
790
|
this.logger.error('Error in storeEncryptedBackupByWallet:', error);
|
|
753
791
|
throw error;
|
|
@@ -823,7 +861,10 @@ class DynamicWalletClient {
|
|
|
823
861
|
const dynamicShares = backups[core.BackupLocation.DYNAMIC].slice(0, requiredShareCount);
|
|
824
862
|
return {
|
|
825
863
|
shares: {
|
|
826
|
-
[core.BackupLocation.DYNAMIC]: dynamicShares
|
|
864
|
+
[core.BackupLocation.DYNAMIC]: dynamicShares.map((ks)=>{
|
|
865
|
+
var _ks_externalKeyShareId, _ref;
|
|
866
|
+
return (_ref = (_ks_externalKeyShareId = ks.externalKeyShareId) != null ? _ks_externalKeyShareId : ks.keyShareId) != null ? _ref : '';
|
|
867
|
+
})
|
|
827
868
|
},
|
|
828
869
|
requiredShareCount
|
|
829
870
|
};
|
|
@@ -1008,7 +1049,7 @@ class DynamicWalletClient {
|
|
|
1008
1049
|
walletProperties: wallet == null ? void 0 : wallet.walletProperties
|
|
1009
1050
|
});
|
|
1010
1051
|
}
|
|
1011
|
-
async getWallet({ accountAddress, walletOperation = core.WalletOperation.NO_OPERATION,
|
|
1052
|
+
async getWallet({ accountAddress, walletOperation = core.WalletOperation.NO_OPERATION, shareCount = undefined }) {
|
|
1012
1053
|
var _user_verifiedCredentials;
|
|
1013
1054
|
this.ensureApiClientAuthenticated();
|
|
1014
1055
|
const existingWalletCheck = await this.checkWalletFields({
|
|
@@ -1036,20 +1077,6 @@ class DynamicWalletClient {
|
|
|
1036
1077
|
walletProperties
|
|
1037
1078
|
})
|
|
1038
1079
|
});
|
|
1039
|
-
if (walletOperation !== core.WalletOperation.NO_OPERATION && await this.requiresRestoreBackupSharesForOperation({
|
|
1040
|
-
accountAddress,
|
|
1041
|
-
walletOperation
|
|
1042
|
-
})) {
|
|
1043
|
-
// TODO(zfaizal2): throw error if signedSessionId is not provided after service deploy
|
|
1044
|
-
const decryptedKeyShares = await this.recoverEncryptedBackupByWallet({
|
|
1045
|
-
accountAddress,
|
|
1046
|
-
password: password != null ? password : this.environmentId,
|
|
1047
|
-
walletOperation: walletOperation,
|
|
1048
|
-
signedSessionId,
|
|
1049
|
-
shareCount
|
|
1050
|
-
});
|
|
1051
|
-
this.logger.debug('Recovered backup', decryptedKeyShares);
|
|
1052
|
-
}
|
|
1053
1080
|
const walletCount = Object.keys(this.walletMap).length;
|
|
1054
1081
|
if (walletCount === 0) {
|
|
1055
1082
|
throw new Error('No wallets found');
|
|
@@ -1141,17 +1168,17 @@ Object.defineProperty(exports, "EcdsaSignature", {
|
|
|
1141
1168
|
enumerable: true,
|
|
1142
1169
|
get: function () { return node.EcdsaSignature; }
|
|
1143
1170
|
});
|
|
1144
|
-
Object.defineProperty(exports, "
|
|
1171
|
+
Object.defineProperty(exports, "ExportableEd25519", {
|
|
1145
1172
|
enumerable: true,
|
|
1146
|
-
get: function () { return node.
|
|
1173
|
+
get: function () { return node.ExportableEd25519; }
|
|
1147
1174
|
});
|
|
1148
|
-
Object.defineProperty(exports, "
|
|
1175
|
+
Object.defineProperty(exports, "ExportableEd25519InitKeygenResult", {
|
|
1149
1176
|
enumerable: true,
|
|
1150
|
-
get: function () { return node.
|
|
1177
|
+
get: function () { return node.ExportableEd25519InitKeygenResult; }
|
|
1151
1178
|
});
|
|
1152
|
-
Object.defineProperty(exports, "
|
|
1179
|
+
Object.defineProperty(exports, "ExportableEd25519KeygenResult", {
|
|
1153
1180
|
enumerable: true,
|
|
1154
|
-
get: function () { return node.
|
|
1181
|
+
get: function () { return node.ExportableEd25519KeygenResult; }
|
|
1155
1182
|
});
|
|
1156
1183
|
Object.defineProperty(exports, "MessageHash", {
|
|
1157
1184
|
enumerable: true,
|
|
@@ -1161,6 +1188,8 @@ exports.DynamicWalletClient = DynamicWalletClient;
|
|
|
1161
1188
|
exports.base64ToBytes = base64ToBytes;
|
|
1162
1189
|
exports.bytesToBase64 = bytesToBase64;
|
|
1163
1190
|
exports.ensureBase64Padding = ensureBase64Padding;
|
|
1191
|
+
exports.formatEvmMessage = formatEvmMessage;
|
|
1192
|
+
exports.formatMessage = formatMessage;
|
|
1164
1193
|
exports.getExternalServerKeyShareBackupInfo = getExternalServerKeyShareBackupInfo;
|
|
1165
1194
|
exports.getMPCSignatureScheme = getMPCSignatureScheme;
|
|
1166
1195
|
exports.getMPCSigner = getMPCSigner;
|
package/index.esm.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { SigningAlgorithm, MPC_RELAY_PROD_API_URL, getMPCChainConfig, BackupLocation, DynamicApiClient, getClientThreshold, MPC_CONFIG, getTSSConfig, WalletOperation, getServerWalletReshareConfig } from '@dynamic-labs-wallet/core';
|
|
2
2
|
export * from '@dynamic-labs-wallet/core';
|
|
3
|
-
import { BIP340,
|
|
4
|
-
export { BIP340, BIP340InitKeygenResult, BIP340KeygenResult, Ecdsa, EcdsaInitKeygenResult, EcdsaKeygenResult, EcdsaPublicKey, EcdsaSignature,
|
|
3
|
+
import { BIP340, ExportableEd25519, Ecdsa, MessageHash, EcdsaKeygenResult, ExportableEd25519KeygenResult, BIP340KeygenResult } from './internal/node';
|
|
4
|
+
export { BIP340, BIP340InitKeygenResult, BIP340KeygenResult, Ecdsa, EcdsaInitKeygenResult, EcdsaKeygenResult, EcdsaPublicKey, EcdsaSignature, ExportableEd25519, ExportableEd25519InitKeygenResult, ExportableEd25519KeygenResult, MessageHash } from './internal/node';
|
|
5
|
+
import { v4 } from 'uuid';
|
|
5
6
|
import { Logger } from '@dynamic-labs/logger';
|
|
6
7
|
import crypto from 'crypto';
|
|
7
8
|
|
|
@@ -10,7 +11,7 @@ const getMPCSignatureScheme = ({ signingAlgorithm, baseRelayUrl = MPC_RELAY_PROD
|
|
|
10
11
|
case SigningAlgorithm.ECDSA:
|
|
11
12
|
return new Ecdsa(baseRelayUrl);
|
|
12
13
|
case SigningAlgorithm.ED25519:
|
|
13
|
-
return new
|
|
14
|
+
return new ExportableEd25519(baseRelayUrl);
|
|
14
15
|
case SigningAlgorithm.BIP340:
|
|
15
16
|
return new BIP340(baseRelayUrl);
|
|
16
17
|
default:
|
|
@@ -75,7 +76,10 @@ const getExternalServerKeyShareBackupInfo = (params)=>{
|
|
|
75
76
|
}
|
|
76
77
|
params.walletProperties.keyShares.forEach((keyShare)=>{
|
|
77
78
|
if (backups[keyShare.backupLocation]) {
|
|
78
|
-
backups[keyShare.backupLocation].push(
|
|
79
|
+
backups[keyShare.backupLocation].push({
|
|
80
|
+
location: keyShare.backupLocation,
|
|
81
|
+
keyShareId: keyShare.id
|
|
82
|
+
});
|
|
79
83
|
}
|
|
80
84
|
});
|
|
81
85
|
const passwordEncrypted = Boolean((_params_walletProperties_keyShares_ = params.walletProperties.keyShares[0]) == null ? void 0 : _params_walletProperties_keyShares_.passwordEncrypted);
|
|
@@ -125,6 +129,36 @@ const getExternalServerKeyShareBackupInfo = (params)=>{
|
|
|
125
129
|
// TypeScript needs this even though it's unreachable
|
|
126
130
|
throw new Error('Unreachable code');
|
|
127
131
|
}
|
|
132
|
+
const formatEvmMessage = (message)=>{
|
|
133
|
+
if (typeof message === 'string' && message.startsWith('0x')) {
|
|
134
|
+
const serializedTxBytes = Uint8Array.from(Buffer.from(message.slice(2), 'hex'));
|
|
135
|
+
return MessageHash.keccak256(serializedTxBytes);
|
|
136
|
+
}
|
|
137
|
+
return MessageHash.keccak256(message);
|
|
138
|
+
};
|
|
139
|
+
const formatSolanaMessage = (message)=>{
|
|
140
|
+
if (typeof message === 'string') {
|
|
141
|
+
if (!isHexString(message)) {
|
|
142
|
+
return Buffer.from(message).toString('hex');
|
|
143
|
+
} else {
|
|
144
|
+
return new Uint8Array(Buffer.from(message, 'hex'));
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
return message;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
const formatMessage = (chainName, message)=>{
|
|
151
|
+
switch(chainName){
|
|
152
|
+
case 'EVM':
|
|
153
|
+
return formatEvmMessage(message);
|
|
154
|
+
case 'SVM':
|
|
155
|
+
return formatSolanaMessage(message);
|
|
156
|
+
case 'SUI':
|
|
157
|
+
return message;
|
|
158
|
+
default:
|
|
159
|
+
throw new Error('Unsupported chain name');
|
|
160
|
+
}
|
|
161
|
+
};
|
|
128
162
|
|
|
129
163
|
const PBKDF2_ALGORITHM = 'PBKDF2';
|
|
130
164
|
const PBKDF2_ITERATIONS = 100000;
|
|
@@ -227,13 +261,14 @@ class DynamicWalletClient {
|
|
|
227
261
|
});
|
|
228
262
|
this.isApiClientAuthenticated = true;
|
|
229
263
|
}
|
|
230
|
-
async dynamicServerInitializeKeyGen({ chainName, externalServerKeygenIds, thresholdSignatureScheme, onError, onCeremonyComplete }) {
|
|
264
|
+
async dynamicServerInitializeKeyGen({ chainName, externalServerKeygenIds, thresholdSignatureScheme, dynamicRequestId, onError, onCeremonyComplete }) {
|
|
231
265
|
this.ensureApiClientAuthenticated();
|
|
232
266
|
try {
|
|
233
267
|
const data = await this.apiClient.createWalletAccount({
|
|
234
268
|
chainName,
|
|
235
269
|
clientKeygenIds: externalServerKeygenIds,
|
|
236
270
|
thresholdSignatureScheme,
|
|
271
|
+
dynamicRequestId,
|
|
237
272
|
onError,
|
|
238
273
|
onCeremonyComplete
|
|
239
274
|
});
|
|
@@ -267,8 +302,8 @@ class DynamicWalletClient {
|
|
|
267
302
|
let publicKey;
|
|
268
303
|
if (mpcSigner instanceof Ecdsa) {
|
|
269
304
|
publicKey = await mpcSigner.derivePubkey(keyShare, derivationPath);
|
|
270
|
-
} else if (mpcSigner instanceof
|
|
271
|
-
publicKey = await mpcSigner.
|
|
305
|
+
} else if (mpcSigner instanceof ExportableEd25519) {
|
|
306
|
+
publicKey = await mpcSigner.getPubkey(keyShare);
|
|
272
307
|
}
|
|
273
308
|
return publicKey;
|
|
274
309
|
} catch (error) {
|
|
@@ -294,7 +329,13 @@ class DynamicWalletClient {
|
|
|
294
329
|
...dynamicServerKeygenIds,
|
|
295
330
|
...otherExternalServerKeygenIds
|
|
296
331
|
];
|
|
297
|
-
|
|
332
|
+
if (!(mpcSigner instanceof ExportableEd25519)) {
|
|
333
|
+
return mpcSigner.keygen(roomId, mpcConfig.numberOfParties, mpcConfig.threshold, currentInit, allOtherKeygenIds);
|
|
334
|
+
} else {
|
|
335
|
+
// One party joins the keygen room using acting as the sampler: (wallet-service)
|
|
336
|
+
// The remaining parties join the key sampling ceremony using: (browser)
|
|
337
|
+
return mpcSigner.receiveKey(roomId, mpcConfig.numberOfParties, mpcConfig.threshold, currentInit, allOtherKeygenIds);
|
|
338
|
+
}
|
|
298
339
|
}));
|
|
299
340
|
// only need one client keygen result to derive the public key
|
|
300
341
|
const [serverKeygenResult] = serverKeygenResults;
|
|
@@ -315,6 +356,7 @@ class DynamicWalletClient {
|
|
|
315
356
|
}
|
|
316
357
|
}
|
|
317
358
|
async keyGen({ chainName, thresholdSignatureScheme, onError, onCeremonyComplete }) {
|
|
359
|
+
const dynamicRequestId = v4();
|
|
318
360
|
try {
|
|
319
361
|
const externalServerInitKeygenResults = await this.externalServerInitializeKeyGen({
|
|
320
362
|
chainName,
|
|
@@ -324,6 +366,7 @@ class DynamicWalletClient {
|
|
|
324
366
|
const { roomId, serverKeygenIds: dynamicServerKeygenIds } = await this.dynamicServerInitializeKeyGen({
|
|
325
367
|
chainName,
|
|
326
368
|
externalServerKeygenIds,
|
|
369
|
+
dynamicRequestId,
|
|
327
370
|
thresholdSignatureScheme,
|
|
328
371
|
onCeremonyComplete
|
|
329
372
|
});
|
|
@@ -345,6 +388,7 @@ class DynamicWalletClient {
|
|
|
345
388
|
}
|
|
346
389
|
async importRawPrivateKey({ chainName, privateKey, thresholdSignatureScheme, onError, onCeremonyComplete }) {
|
|
347
390
|
this.ensureApiClientAuthenticated();
|
|
391
|
+
const dynamicRequestId = v4();
|
|
348
392
|
const mpcSigner = getMPCSigner({
|
|
349
393
|
chainName,
|
|
350
394
|
baseRelayUrl: this.baseMPCRelayApiUrl
|
|
@@ -358,6 +402,7 @@ class DynamicWalletClient {
|
|
|
358
402
|
chainName,
|
|
359
403
|
clientKeygenIds: externalServerKeygenIds,
|
|
360
404
|
thresholdSignatureScheme,
|
|
405
|
+
dynamicRequestId,
|
|
361
406
|
onError,
|
|
362
407
|
onCeremonyComplete
|
|
363
408
|
});
|
|
@@ -390,7 +435,8 @@ class DynamicWalletClient {
|
|
|
390
435
|
externalServerKeyShares: externalServerKeygenResults
|
|
391
436
|
};
|
|
392
437
|
}
|
|
393
|
-
async dynamicServerSign({ walletId, message }) {
|
|
438
|
+
async dynamicServerSign({ walletId, message, isFormatted }) {
|
|
439
|
+
const dynamicRequestId = v4();
|
|
394
440
|
this.ensureApiClientAuthenticated();
|
|
395
441
|
// Create the room and sign the message
|
|
396
442
|
if (typeof message !== 'string') {
|
|
@@ -398,35 +444,19 @@ class DynamicWalletClient {
|
|
|
398
444
|
}
|
|
399
445
|
const data = await this.apiClient.signMessage({
|
|
400
446
|
walletId,
|
|
401
|
-
message
|
|
447
|
+
message,
|
|
448
|
+
isFormatted,
|
|
449
|
+
dynamicRequestId
|
|
402
450
|
});
|
|
403
451
|
return data;
|
|
404
452
|
}
|
|
405
|
-
async externalServerSign({ chainName, message, roomId, keyShare, derivationPath }) {
|
|
453
|
+
async externalServerSign({ chainName, message, roomId, keyShare, derivationPath, isFormatted }) {
|
|
406
454
|
try {
|
|
407
455
|
const mpcSigner = getMPCSigner({
|
|
408
456
|
chainName,
|
|
409
457
|
baseRelayUrl: this.baseMPCRelayApiUrl
|
|
410
458
|
});
|
|
411
|
-
|
|
412
|
-
//note: Ecdsa can also be used by bitcoin, but only keccak256 is used by ethereum
|
|
413
|
-
if (mpcSigner instanceof Ecdsa) {
|
|
414
|
-
formattedMessage = MessageHash.keccak256(message);
|
|
415
|
-
} else if (mpcSigner instanceof Ed25519) {
|
|
416
|
-
if (typeof message === 'string') {
|
|
417
|
-
if (!isHexString(message)) {
|
|
418
|
-
formattedMessage = Buffer.from(message).toString('hex');
|
|
419
|
-
} else {
|
|
420
|
-
formattedMessage = Buffer.from(message, 'hex');
|
|
421
|
-
}
|
|
422
|
-
} else {
|
|
423
|
-
formattedMessage = message;
|
|
424
|
-
}
|
|
425
|
-
} else if (mpcSigner instanceof BIP340 && typeof message === 'string') {
|
|
426
|
-
formattedMessage = new TextEncoder().encode(message);
|
|
427
|
-
} else {
|
|
428
|
-
throw new Error('Unsupported signer type');
|
|
429
|
-
}
|
|
459
|
+
const formattedMessage = isFormatted ? new MessageHash(message) : formatMessage(chainName, message);
|
|
430
460
|
const signature = await mpcSigner.sign(roomId, keyShare, formattedMessage, derivationPath);
|
|
431
461
|
return signature;
|
|
432
462
|
} catch (error) {
|
|
@@ -435,7 +465,7 @@ class DynamicWalletClient {
|
|
|
435
465
|
}
|
|
436
466
|
}
|
|
437
467
|
//todo: need to modify with imported flag
|
|
438
|
-
async sign({ accountAddress, message, chainName, password = undefined, signedSessionId }) {
|
|
468
|
+
async sign({ accountAddress, externalServerKeyShares, message, chainName, password = undefined, isFormatted = false, signedSessionId }) {
|
|
439
469
|
await this.verifyPassword({
|
|
440
470
|
accountAddress,
|
|
441
471
|
password,
|
|
@@ -451,7 +481,8 @@ class DynamicWalletClient {
|
|
|
451
481
|
// Perform the dynamic server sign
|
|
452
482
|
const data = await this.dynamicServerSign({
|
|
453
483
|
walletId: wallet.walletId,
|
|
454
|
-
message
|
|
484
|
+
message,
|
|
485
|
+
isFormatted
|
|
455
486
|
});
|
|
456
487
|
const derivationPath = wallet.derivationPath && wallet.derivationPath != '' ? new Uint32Array(Object.values(JSON.parse(wallet.derivationPath))) : undefined;
|
|
457
488
|
// Perform the external server sign and return the signature
|
|
@@ -459,8 +490,9 @@ class DynamicWalletClient {
|
|
|
459
490
|
chainName,
|
|
460
491
|
message,
|
|
461
492
|
roomId: data.roomId,
|
|
462
|
-
keyShare:
|
|
463
|
-
derivationPath
|
|
493
|
+
keyShare: externalServerKeyShares[0],
|
|
494
|
+
derivationPath,
|
|
495
|
+
isFormatted
|
|
464
496
|
});
|
|
465
497
|
return signature;
|
|
466
498
|
}
|
|
@@ -612,7 +644,7 @@ class DynamicWalletClient {
|
|
|
612
644
|
});
|
|
613
645
|
return reshareResults;
|
|
614
646
|
}
|
|
615
|
-
async exportKey({ accountAddress, chainName, password = undefined, signedSessionId }) {
|
|
647
|
+
async exportKey({ accountAddress, chainName, password = undefined, signedSessionId, externalServerKeyShares }) {
|
|
616
648
|
this.ensureApiClientAuthenticated();
|
|
617
649
|
await this.verifyPassword({
|
|
618
650
|
accountAddress,
|
|
@@ -632,13 +664,13 @@ class DynamicWalletClient {
|
|
|
632
664
|
});
|
|
633
665
|
const exportId = await this.getExportId({
|
|
634
666
|
chainName,
|
|
635
|
-
serverKeyShare:
|
|
667
|
+
serverKeyShare: externalServerKeyShares[0]
|
|
636
668
|
});
|
|
637
669
|
const data = await this.apiClient.exportKey({
|
|
638
670
|
walletId: wallet.walletId,
|
|
639
671
|
exportId
|
|
640
672
|
});
|
|
641
|
-
const keyExportRaw = await mpcSigner.exportFullPrivateKey(data.roomId,
|
|
673
|
+
const keyExportRaw = await mpcSigner.exportFullPrivateKey(data.roomId, externalServerKeyShares[0], exportId);
|
|
642
674
|
if (!keyExportRaw) {
|
|
643
675
|
throw new Error('Error exporting private key');
|
|
644
676
|
}
|
|
@@ -646,7 +678,7 @@ class DynamicWalletClient {
|
|
|
646
678
|
let derivedPrivateKey;
|
|
647
679
|
if (mpcSigner instanceof Ecdsa) {
|
|
648
680
|
derivedPrivateKey = await mpcSigner.derivePrivateKeyFromXpriv(keyExportRaw, derivationPath);
|
|
649
|
-
} else if (mpcSigner instanceof
|
|
681
|
+
} else if (mpcSigner instanceof ExportableEd25519) {
|
|
650
682
|
derivedPrivateKey = keyExportRaw;
|
|
651
683
|
} else if (mpcSigner instanceof BIP340) {
|
|
652
684
|
derivedPrivateKey = await mpcSigner.derivePrivateKeyFromXpriv(keyExportRaw, derivationPath);
|
|
@@ -665,7 +697,7 @@ class DynamicWalletClient {
|
|
|
665
697
|
baseRelayUrl: this.baseMPCRelayApiUrl
|
|
666
698
|
});
|
|
667
699
|
const walletKeyShares = keyShares.map((keyShare)=>{
|
|
668
|
-
return mpcSigner instanceof Ecdsa ? new EcdsaKeygenResult(keyShare.pubkey, keyShare.secretShare) : mpcSigner instanceof
|
|
700
|
+
return mpcSigner instanceof Ecdsa ? new EcdsaKeygenResult(keyShare.pubkey, keyShare.secretShare) : mpcSigner instanceof ExportableEd25519 ? new ExportableEd25519KeygenResult(keyShare.pubkey, keyShare.secretShare) : new BIP340KeygenResult(keyShare.pubkey, keyShare.secretShare);
|
|
669
701
|
});
|
|
670
702
|
const keyExportRaw = await mpcSigner.offlineExportFullPrivateKey(walletKeyShares);
|
|
671
703
|
if (!keyExportRaw) {
|
|
@@ -676,7 +708,7 @@ class DynamicWalletClient {
|
|
|
676
708
|
let derivedPrivateKey;
|
|
677
709
|
if (mpcSigner instanceof Ecdsa) {
|
|
678
710
|
derivedPrivateKey = await mpcSigner.derivePrivateKeyFromXpriv(keyExportRaw, walletDerivationPath);
|
|
679
|
-
} else if (mpcSigner instanceof
|
|
711
|
+
} else if (mpcSigner instanceof ExportableEd25519) {
|
|
680
712
|
derivedPrivateKey = keyExportRaw;
|
|
681
713
|
} else if (mpcSigner instanceof BIP340) {
|
|
682
714
|
derivedPrivateKey = await mpcSigner.derivePrivateKeyFromXpriv(keyExportRaw, walletDerivationPath);
|
|
@@ -731,23 +763,29 @@ class DynamicWalletClient {
|
|
|
731
763
|
if (!this.walletMap[accountAddress] || !this.walletMap[accountAddress].walletId) {
|
|
732
764
|
throw new Error(`WalletId not found for accountAddress: ${accountAddress}`);
|
|
733
765
|
}
|
|
734
|
-
|
|
735
|
-
const data = await this.apiClient.storeEncryptedBackupByWallet({
|
|
766
|
+
await this.apiClient.markKeySharesAsBackedUp({
|
|
736
767
|
walletId: this.walletMap[accountAddress].walletId,
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
768
|
+
locations: [
|
|
769
|
+
{
|
|
770
|
+
location: BackupLocation.EXTERNAL
|
|
771
|
+
}
|
|
772
|
+
]
|
|
740
773
|
});
|
|
741
774
|
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress], {
|
|
742
775
|
externalServerKeySharesBackupInfo: getExternalServerKeyShareBackupInfo({
|
|
743
776
|
walletProperties: {
|
|
744
777
|
derivationPath: this.walletMap[accountAddress].derivationPath,
|
|
745
|
-
keyShares:
|
|
778
|
+
keyShares: encryptedKeyShares.map((encryptedKeyShare)=>({
|
|
779
|
+
id: v4(),
|
|
780
|
+
encryptedKeyShare,
|
|
781
|
+
backupLocation: BackupLocation.EXTERNAL,
|
|
782
|
+
passwordEncrypted: Boolean(password) && password !== this.environmentId
|
|
783
|
+
})),
|
|
746
784
|
thresholdSignatureScheme: this.walletMap[accountAddress].thresholdSignatureScheme
|
|
747
785
|
}
|
|
748
786
|
})
|
|
749
787
|
});
|
|
750
|
-
return
|
|
788
|
+
return encryptedKeyShares;
|
|
751
789
|
} catch (error) {
|
|
752
790
|
this.logger.error('Error in storeEncryptedBackupByWallet:', error);
|
|
753
791
|
throw error;
|
|
@@ -823,7 +861,10 @@ class DynamicWalletClient {
|
|
|
823
861
|
const dynamicShares = backups[BackupLocation.DYNAMIC].slice(0, requiredShareCount);
|
|
824
862
|
return {
|
|
825
863
|
shares: {
|
|
826
|
-
[BackupLocation.DYNAMIC]: dynamicShares
|
|
864
|
+
[BackupLocation.DYNAMIC]: dynamicShares.map((ks)=>{
|
|
865
|
+
var _ks_externalKeyShareId, _ref;
|
|
866
|
+
return (_ref = (_ks_externalKeyShareId = ks.externalKeyShareId) != null ? _ks_externalKeyShareId : ks.keyShareId) != null ? _ref : '';
|
|
867
|
+
})
|
|
827
868
|
},
|
|
828
869
|
requiredShareCount
|
|
829
870
|
};
|
|
@@ -1008,7 +1049,7 @@ class DynamicWalletClient {
|
|
|
1008
1049
|
walletProperties: wallet == null ? void 0 : wallet.walletProperties
|
|
1009
1050
|
});
|
|
1010
1051
|
}
|
|
1011
|
-
async getWallet({ accountAddress, walletOperation = WalletOperation.NO_OPERATION,
|
|
1052
|
+
async getWallet({ accountAddress, walletOperation = WalletOperation.NO_OPERATION, shareCount = undefined }) {
|
|
1012
1053
|
var _user_verifiedCredentials;
|
|
1013
1054
|
this.ensureApiClientAuthenticated();
|
|
1014
1055
|
const existingWalletCheck = await this.checkWalletFields({
|
|
@@ -1036,20 +1077,6 @@ class DynamicWalletClient {
|
|
|
1036
1077
|
walletProperties
|
|
1037
1078
|
})
|
|
1038
1079
|
});
|
|
1039
|
-
if (walletOperation !== WalletOperation.NO_OPERATION && await this.requiresRestoreBackupSharesForOperation({
|
|
1040
|
-
accountAddress,
|
|
1041
|
-
walletOperation
|
|
1042
|
-
})) {
|
|
1043
|
-
// TODO(zfaizal2): throw error if signedSessionId is not provided after service deploy
|
|
1044
|
-
const decryptedKeyShares = await this.recoverEncryptedBackupByWallet({
|
|
1045
|
-
accountAddress,
|
|
1046
|
-
password: password != null ? password : this.environmentId,
|
|
1047
|
-
walletOperation: walletOperation,
|
|
1048
|
-
signedSessionId,
|
|
1049
|
-
shareCount
|
|
1050
|
-
});
|
|
1051
|
-
this.logger.debug('Recovered backup', decryptedKeyShares);
|
|
1052
|
-
}
|
|
1053
1080
|
const walletCount = Object.keys(this.walletMap).length;
|
|
1054
1081
|
if (walletCount === 0) {
|
|
1055
1082
|
throw new Error('No wallets found');
|
|
@@ -1109,4 +1136,4 @@ class DynamicWalletClient {
|
|
|
1109
1136
|
}
|
|
1110
1137
|
}
|
|
1111
1138
|
|
|
1112
|
-
export { DynamicWalletClient, base64ToBytes, bytesToBase64, ensureBase64Padding, getExternalServerKeyShareBackupInfo, getMPCSignatureScheme, getMPCSigner, isHexString, mergeUniqueKeyShares, retryPromise, stringToBytes };
|
|
1139
|
+
export { DynamicWalletClient, base64ToBytes, bytesToBase64, ensureBase64Padding, formatEvmMessage, formatMessage, getExternalServerKeyShareBackupInfo, getMPCSignatureScheme, getMPCSigner, isHexString, mergeUniqueKeyShares, retryPromise, stringToBytes };
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/node",
|
|
3
|
-
"version": "0.0.0-beta.
|
|
3
|
+
"version": "0.0.0-beta.290.2",
|
|
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.0-beta.
|
|
7
|
-
"@dynamic-labs/logger": "^4.
|
|
6
|
+
"@dynamic-labs-wallet/core": "0.0.0-beta.290.2",
|
|
7
|
+
"@dynamic-labs/logger": "^4.25.3",
|
|
8
|
+
"uuid": "11.1.0",
|
|
8
9
|
"@noble/hashes": "1.7.1"
|
|
9
10
|
},
|
|
10
11
|
"files": [
|
package/src/client.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { EcdsaKeygenResult, BIP340KeygenResult, EcdsaPublicKey, EcdsaSignature } from '../../internal/node';
|
|
1
|
+
import { EcdsaKeygenResult, BIP340KeygenResult, EcdsaPublicKey, EcdsaSignature, ExportableEd25519KeygenResult } from '../../internal/node';
|
|
2
2
|
import { ThresholdSignatureScheme, DynamicApiClient, WalletOperation, KeyShareBackupInfo, BackupLocation } from '@dynamic-labs-wallet/core';
|
|
3
3
|
import { ServerInitKeygenResult } from './mpc/types';
|
|
4
4
|
import { WalletProperties } from './types';
|
|
5
|
-
type ServerKeyShare = EcdsaKeygenResult | BIP340KeygenResult;
|
|
5
|
+
type ServerKeyShare = EcdsaKeygenResult | BIP340KeygenResult | ExportableEd25519KeygenResult;
|
|
6
6
|
export declare class DynamicWalletClient {
|
|
7
7
|
environmentId: string;
|
|
8
8
|
debug: boolean;
|
|
@@ -21,10 +21,11 @@ export declare class DynamicWalletClient {
|
|
|
21
21
|
});
|
|
22
22
|
private ensureApiClientAuthenticated;
|
|
23
23
|
authenticateApiToken(authToken: string): Promise<void>;
|
|
24
|
-
dynamicServerInitializeKeyGen({ chainName, externalServerKeygenIds, thresholdSignatureScheme, onError, onCeremonyComplete, }: {
|
|
24
|
+
dynamicServerInitializeKeyGen({ chainName, externalServerKeygenIds, thresholdSignatureScheme, dynamicRequestId, onError, onCeremonyComplete, }: {
|
|
25
25
|
chainName: string;
|
|
26
26
|
externalServerKeygenIds: string[];
|
|
27
27
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
28
|
+
dynamicRequestId: string;
|
|
28
29
|
onError?: (error: Error) => void;
|
|
29
30
|
onCeremonyComplete?: (accountAddress: string, walletId: string) => void;
|
|
30
31
|
}): Promise<import("@dynamic-labs-wallet/core").KeygenCompleteResponse>;
|
|
@@ -36,7 +37,7 @@ export declare class DynamicWalletClient {
|
|
|
36
37
|
chainName: string;
|
|
37
38
|
keyShare: ServerKeyShare;
|
|
38
39
|
derivationPath: Uint32Array | undefined;
|
|
39
|
-
}): Promise<
|
|
40
|
+
}): Promise<string | EcdsaPublicKey | undefined>;
|
|
40
41
|
externalServerKeyGen({ chainName, roomId, dynamicServerKeygenIds, externalServerInitKeygenResults, thresholdSignatureScheme, }: {
|
|
41
42
|
chainName: string;
|
|
42
43
|
roomId: string;
|
|
@@ -44,7 +45,7 @@ export declare class DynamicWalletClient {
|
|
|
44
45
|
externalServerInitKeygenResults: ServerInitKeygenResult[];
|
|
45
46
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
46
47
|
}): Promise<{
|
|
47
|
-
rawPublicKey: EcdsaPublicKey | Uint8Array | undefined;
|
|
48
|
+
rawPublicKey: EcdsaPublicKey | Uint8Array | string | undefined;
|
|
48
49
|
externalServerKeyGenResults: ServerKeyShare[];
|
|
49
50
|
}>;
|
|
50
51
|
keyGen({ chainName, thresholdSignatureScheme, onError, onCeremonyComplete, }: {
|
|
@@ -53,7 +54,7 @@ export declare class DynamicWalletClient {
|
|
|
53
54
|
onError?: (error: Error) => void;
|
|
54
55
|
onCeremonyComplete?: (accountAddress: string, walletId: string) => void;
|
|
55
56
|
}): Promise<{
|
|
56
|
-
rawPublicKey: EcdsaPublicKey | Uint8Array | undefined;
|
|
57
|
+
rawPublicKey: EcdsaPublicKey | Uint8Array | string | undefined;
|
|
57
58
|
externalServerKeyShares: ServerKeyShare[];
|
|
58
59
|
}>;
|
|
59
60
|
importRawPrivateKey({ chainName, privateKey, thresholdSignatureScheme, onError, onCeremonyComplete, }: {
|
|
@@ -63,32 +64,36 @@ export declare class DynamicWalletClient {
|
|
|
63
64
|
onError?: (error: Error) => void;
|
|
64
65
|
onCeremonyComplete?: (accountAddress: string, walletId: string) => void;
|
|
65
66
|
}): Promise<{
|
|
66
|
-
rawPublicKey: EcdsaPublicKey | Uint8Array | undefined;
|
|
67
|
+
rawPublicKey: EcdsaPublicKey | Uint8Array | string | undefined;
|
|
67
68
|
externalServerKeyShares: ServerKeyShare[];
|
|
68
69
|
}>;
|
|
69
|
-
dynamicServerSign({ walletId, message, }: {
|
|
70
|
+
dynamicServerSign({ walletId, message, isFormatted, }: {
|
|
70
71
|
walletId: string;
|
|
71
72
|
message: string | Uint8Array;
|
|
73
|
+
isFormatted?: boolean;
|
|
72
74
|
}): Promise<import("@dynamic-labs-wallet/core").OpenRoomResponse>;
|
|
73
|
-
externalServerSign({ chainName, message, roomId, keyShare, derivationPath, }: {
|
|
75
|
+
externalServerSign({ chainName, message, roomId, keyShare, derivationPath, isFormatted, }: {
|
|
74
76
|
chainName: string;
|
|
75
77
|
message: string | Uint8Array;
|
|
76
78
|
roomId: string;
|
|
77
79
|
keyShare: ServerKeyShare;
|
|
78
80
|
derivationPath: Uint32Array | undefined;
|
|
81
|
+
isFormatted?: boolean;
|
|
79
82
|
}): Promise<Uint8Array | EcdsaSignature>;
|
|
80
|
-
sign({ accountAddress, message, chainName, password, signedSessionId, }: {
|
|
83
|
+
sign({ accountAddress, externalServerKeyShares, message, chainName, password, isFormatted, signedSessionId, }: {
|
|
81
84
|
accountAddress: string;
|
|
85
|
+
externalServerKeyShares: ServerKeyShare[];
|
|
82
86
|
message: string | Uint8Array;
|
|
83
87
|
chainName: string;
|
|
84
88
|
password?: string;
|
|
85
|
-
signedSessionId
|
|
89
|
+
signedSessionId: string;
|
|
90
|
+
isFormatted?: boolean;
|
|
86
91
|
}): Promise<Uint8Array | EcdsaSignature>;
|
|
87
92
|
refreshWalletAccountShares({ accountAddress, chainName, password, signedSessionId, }: {
|
|
88
93
|
accountAddress: string;
|
|
89
94
|
chainName: string;
|
|
90
95
|
password?: string;
|
|
91
|
-
signedSessionId
|
|
96
|
+
signedSessionId: string;
|
|
92
97
|
}): Promise<(EcdsaKeygenResult | BIP340KeygenResult)[]>;
|
|
93
98
|
getExportId({ chainName, serverKeyShare, }: {
|
|
94
99
|
chainName: string;
|
|
@@ -125,13 +130,14 @@ export declare class DynamicWalletClient {
|
|
|
125
130
|
oldThresholdSignatureScheme: ThresholdSignatureScheme;
|
|
126
131
|
newThresholdSignatureScheme: ThresholdSignatureScheme;
|
|
127
132
|
password?: string;
|
|
128
|
-
signedSessionId
|
|
133
|
+
signedSessionId: string;
|
|
129
134
|
}): Promise<(EcdsaKeygenResult | BIP340KeygenResult)[]>;
|
|
130
|
-
exportKey({ accountAddress, chainName, password, signedSessionId, }: {
|
|
135
|
+
exportKey({ accountAddress, chainName, password, signedSessionId, externalServerKeyShares, }: {
|
|
131
136
|
accountAddress: string;
|
|
132
137
|
chainName: string;
|
|
133
138
|
password?: string;
|
|
134
|
-
signedSessionId
|
|
139
|
+
signedSessionId: string;
|
|
140
|
+
externalServerKeyShares: ServerKeyShare[];
|
|
135
141
|
}): Promise<{
|
|
136
142
|
derivedPrivateKey: string | undefined;
|
|
137
143
|
}>;
|
|
@@ -153,24 +159,24 @@ export declare class DynamicWalletClient {
|
|
|
153
159
|
accountAddress: string;
|
|
154
160
|
externalServerKeyShares?: ServerKeyShare[];
|
|
155
161
|
password?: string;
|
|
156
|
-
signedSessionId
|
|
157
|
-
}): Promise<
|
|
162
|
+
signedSessionId: string;
|
|
163
|
+
}): Promise<string[]>;
|
|
158
164
|
storeEncryptedBackupByWalletWithRetry({ accountAddress, externalServerKeyShares, password, signedSessionId, }: {
|
|
159
165
|
accountAddress: string;
|
|
160
166
|
externalServerKeyShares?: ServerKeyShare[];
|
|
161
167
|
password?: string;
|
|
162
|
-
signedSessionId
|
|
168
|
+
signedSessionId: string;
|
|
163
169
|
}): Promise<void>;
|
|
164
170
|
getExternalServerKeyShares({ accountAddress, password, signedSessionId, }: {
|
|
165
171
|
accountAddress: string;
|
|
166
172
|
password?: string;
|
|
167
|
-
signedSessionId
|
|
173
|
+
signedSessionId: string;
|
|
168
174
|
}): Promise<import("./mpc").ServerKeyShare[]>;
|
|
169
175
|
updatePassword({ accountAddress, existingPassword, newPassword, signedSessionId, }: {
|
|
170
176
|
accountAddress: string;
|
|
171
177
|
existingPassword?: string;
|
|
172
178
|
newPassword?: string;
|
|
173
|
-
signedSessionId
|
|
179
|
+
signedSessionId: string;
|
|
174
180
|
}): Promise<void>;
|
|
175
181
|
decryptKeyShare({ keyShare, password, }: {
|
|
176
182
|
keyShare: string;
|
|
@@ -201,14 +207,14 @@ export declare class DynamicWalletClient {
|
|
|
201
207
|
accountAddress: string;
|
|
202
208
|
password?: string;
|
|
203
209
|
walletOperation: WalletOperation;
|
|
204
|
-
signedSessionId
|
|
210
|
+
signedSessionId: string;
|
|
205
211
|
shareCount?: number;
|
|
206
212
|
storeRecoveredShares?: boolean;
|
|
207
213
|
}): Promise<any[]>;
|
|
208
214
|
exportExternalServerKeyShares({ accountAddress, password, signedSessionId, }: {
|
|
209
215
|
accountAddress: string;
|
|
210
216
|
password?: string;
|
|
211
|
-
signedSessionId
|
|
217
|
+
signedSessionId: string;
|
|
212
218
|
}): Promise<import("./mpc").ServerKeyShare[]>;
|
|
213
219
|
/**
|
|
214
220
|
* Helper function to check if the required wallet fields are present and valid
|
|
@@ -226,7 +232,7 @@ export declare class DynamicWalletClient {
|
|
|
226
232
|
accountAddress: string;
|
|
227
233
|
password?: string;
|
|
228
234
|
walletOperation?: WalletOperation;
|
|
229
|
-
signedSessionId
|
|
235
|
+
signedSessionId: string;
|
|
230
236
|
}): Promise<void>;
|
|
231
237
|
isPasswordEncrypted({ accountAddress, }: {
|
|
232
238
|
accountAddress: string;
|
|
@@ -248,10 +254,10 @@ export declare class DynamicWalletClient {
|
|
|
248
254
|
getWalletExternalServerKeyShareBackupInfo({ accountAddress, }: {
|
|
249
255
|
accountAddress: string;
|
|
250
256
|
}): Promise<KeyShareBackupInfo>;
|
|
251
|
-
getWallet({ accountAddress, walletOperation,
|
|
257
|
+
getWallet({ accountAddress, walletOperation, shareCount, }: {
|
|
252
258
|
accountAddress: string;
|
|
253
259
|
walletOperation?: WalletOperation;
|
|
254
|
-
signedSessionId
|
|
260
|
+
signedSessionId: string;
|
|
255
261
|
shareCount?: number;
|
|
256
262
|
password?: string;
|
|
257
263
|
}): Promise<WalletProperties>;
|
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,
|
|
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,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MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB;IAgDK,UAAU;CAuCjB"}
|
package/src/mpc/mpc.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { SigningAlgorithm } from '@dynamic-labs-wallet/core';
|
|
2
|
-
import { Ecdsa,
|
|
3
|
-
export { Ecdsa,
|
|
2
|
+
import { Ecdsa, ExportableEd25519, BIP340, BIP340KeygenResult, EcdsaPublicKey, ExportableEd25519KeygenResult, EcdsaKeygenResult, MessageHash, EcdsaInitKeygenResult, ExportableEd25519InitKeygenResult, BIP340InitKeygenResult, EcdsaSignature } from '../../../internal/node';
|
|
3
|
+
export { Ecdsa, ExportableEd25519, BIP340, EcdsaPublicKey, EcdsaKeygenResult, ExportableEd25519KeygenResult, BIP340KeygenResult, MessageHash, EcdsaInitKeygenResult, ExportableEd25519InitKeygenResult, BIP340InitKeygenResult, EcdsaSignature, };
|
|
4
4
|
export declare const getMPCSignatureScheme: ({ signingAlgorithm, baseRelayUrl, }: {
|
|
5
5
|
signingAlgorithm: SigningAlgorithm;
|
|
6
6
|
baseRelayUrl?: string;
|
|
7
|
-
}) => Ecdsa |
|
|
7
|
+
}) => Ecdsa | ExportableEd25519 | BIP340;
|
|
8
8
|
export declare const getMPCSigner: ({ chainName, baseRelayUrl, }: {
|
|
9
9
|
chainName: string;
|
|
10
10
|
baseRelayUrl?: string;
|
|
11
|
-
}) => Ecdsa |
|
|
11
|
+
}) => Ecdsa | ExportableEd25519 | BIP340;
|
|
12
12
|
//# sourceMappingURL=mpc.d.ts.map
|
package/src/mpc/mpc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mpc.d.ts","sourceRoot":"","sources":["../../src/mpc/mpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAEjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,KAAK,EACL,
|
|
1
|
+
{"version":3,"file":"mpc.d.ts","sourceRoot":"","sources":["../../src/mpc/mpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAEjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,KAAK,EACL,iBAAiB,EACjB,MAAM,EACN,kBAAkB,EAClB,cAAc,EACd,6BAA6B,EAC7B,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,iCAAiC,EACjC,sBAAsB,EACtB,cAAc,EACf,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,KAAK,EACL,iBAAiB,EACjB,MAAM,EACN,cAAc,EACd,iBAAiB,EACjB,6BAA6B,EAC7B,kBAAkB,EAClB,WAAW,EACX,qBAAqB,EACrB,iCAAiC,EACjC,sBAAsB,EACtB,cAAc,GACf,CAAC;AAEF,eAAO,MAAM,qBAAqB,wCAG/B;IACD,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,uCAWA,CAAC;AAEF,eAAO,MAAM,YAAY,iCAGtB;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,uCAOA,CAAC"}
|
package/src/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { WaasWalletProperties, KeyShareBackupInfo } from '@dynamic-labs-wallet/core';
|
|
2
2
|
import { ServerKeyShare } from './mpc/types';
|
|
3
|
+
import { MessageHash } from '../../internal/node';
|
|
3
4
|
export declare const bytesToBase64: (arr: Uint8Array) => string;
|
|
4
5
|
export declare const stringToBytes: (str: string) => Uint8Array;
|
|
5
6
|
export declare const base64ToBytes: (base64: string) => Uint8Array;
|
|
@@ -30,5 +31,7 @@ interface RetryConfig {
|
|
|
30
31
|
* @throws Last error encountered after all retries are exhausted
|
|
31
32
|
*/
|
|
32
33
|
export declare function retryPromise<T>(operation: () => Promise<T>, { maxAttempts, retryInterval, operationName, logContext, }?: RetryConfig): Promise<T>;
|
|
34
|
+
export declare const formatEvmMessage: (message: string | Uint8Array) => MessageHash;
|
|
35
|
+
export declare const formatMessage: (chainName: string, message: string | Uint8Array) => string | Uint8Array | MessageHash;
|
|
33
36
|
export {};
|
|
34
37
|
//# sourceMappingURL=utils.d.ts.map
|
package/src/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../packages/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oBAAoB,EACpB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../packages/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oBAAoB,EACpB,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,eAAO,MAAM,aAAa,QAAS,UAAU,WAE5C,CAAC;AAEF,eAAO,MAAM,aAAa,QAAS,MAAM,eAExC,CAAC;AAEF,eAAO,MAAM,aAAa,WAAY,MAAM,eAE3C,CAAC;AAGF,eAAO,MAAM,mBAAmB,QAAS,MAAM,KAAG,MAEjD,CAAC;AAEF,eAAO,MAAM,WAAW,QAAS,MAAM,YAKtC,CAAC;AAEF,eAAO,MAAM,mCAAmC,YAAa;IAC3D,gBAAgB,EAAE,oBAAoB,CAAC;CACxC,KAAG,kBAsCH,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,sBACZ,cAAc,EAAE,gBACrB,cAAc,EAAE,KAC7B,cAAc,EAchB,CAAC;AAEF,UAAU,WAAW;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED;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