@dynamic-labs-wallet/core 0.0.48 → 0.0.50

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 CHANGED
@@ -9,6 +9,46 @@ const DYNAMIC_CLIENT_RELAY_PREPROD_BASE_API_URL = 'https://app-dynamic-preprod-x
9
9
  const MPC_RELAY_PROD_API_URL = 'relay.dynamicauth.com';
10
10
  const MPC_RELAY_PREPROD_API_URL = 'relay.dynamic-preprod.xyz';
11
11
  const SOLANA_RPC_URL = 'https://api.devnet.solana.com';
12
+ const chain = {
13
+ EVM: 'EVM',
14
+ SOL: 'SOL',
15
+ COSMOS: 'COSMOS',
16
+ BTC: 'BTC',
17
+ FLOW: 'FLOW',
18
+ SUI: 'SUI'
19
+ };
20
+ var WalletOperation = /*#__PURE__*/ function(WalletOperation) {
21
+ WalletOperation["REACH_THRESHOLD"] = "REACH_THRESHOLD";
22
+ WalletOperation["REACH_ALL_PARTIES"] = "REACH_ALL_PARTIES";
23
+ WalletOperation["SIGN_MESSAGE"] = "SIGN_MESSAGE";
24
+ WalletOperation["SIGN_TRANSACTION"] = "SIGN_TRANSACTION";
25
+ WalletOperation["REFRESH"] = "REFRESH";
26
+ WalletOperation["RESHARE"] = "RESHARE";
27
+ WalletOperation["EXPORT_PRIVATE_KEY"] = "EXPORT_PRIVATE_KEY";
28
+ WalletOperation["NO_OPERATION"] = "NO_OPERATION";
29
+ return WalletOperation;
30
+ }({});
31
+ var BackupLocation = /*#__PURE__*/ function(BackupLocation) {
32
+ BackupLocation["DYNAMIC"] = "dynamic";
33
+ BackupLocation["GOOGLE_DRIVE"] = "googleDrive";
34
+ BackupLocation["ICLOUD"] = "iCloud";
35
+ BackupLocation["USER"] = "user";
36
+ BackupLocation["EXTERNAL"] = "external";
37
+ return BackupLocation;
38
+ }({});
39
+ // TODO: replace with apiClient proxy and move this to apiClient when ready
40
+ const IFRAME_DOMAIN = 'http://localhost:8090';
41
+ const ChainEnumToVerifiedCredentialName = {
42
+ BTC: 'bip122',
43
+ EVM: 'eip155',
44
+ FLOW: 'flow',
45
+ SOL: 'solana'
46
+ };
47
+ const VerifiedCredentialNameToChainEnum = {
48
+ bip122: 'BTC',
49
+ eip155: 'EVM',
50
+ solana: 'SOL'
51
+ };
12
52
 
13
53
  var SigningAlgorithm = /*#__PURE__*/ function(SigningAlgorithm) {
14
54
  SigningAlgorithm["ECDSA"] = "ECDSA";
@@ -123,14 +163,6 @@ var CreateRoomPartiesOptions = /*#__PURE__*/ function(CreateRoomPartiesOptions)
123
163
  CreateRoomPartiesOptions["FULL"] = "full";
124
164
  return CreateRoomPartiesOptions;
125
165
  }({});
126
- var BackupLocation = /*#__PURE__*/ function(BackupLocation) {
127
- BackupLocation["DYNAMIC"] = "dynamic";
128
- BackupLocation["GOOGLE_DRIVE"] = "googleDrive";
129
- BackupLocation["ICLOUD"] = "iCloud";
130
- BackupLocation["USER"] = "user";
131
- BackupLocation["EXTERNAL"] = "external";
132
- return BackupLocation;
133
- }({});
134
166
 
135
167
  const getMPCChainConfig = (chainName)=>{
136
168
  const chainConfig = MPC_CHAIN_CONFIG[chainName];
@@ -165,7 +197,7 @@ const getDynamicServerThreshold = (thresholdSignatureScheme)=>{
165
197
  */ const getReshareConfig = ({ oldThresholdSignatureScheme, newThresholdSignatureScheme })=>{
166
198
  switch(true){
167
199
  // 2-of-2 -> 2-of-2:
168
- // -- server shares: 1 existing, 0 new
200
+ // -- dynamic server shares: 1 existing, 0 new
169
201
  // -- client shares: 1 existing, 0 new
170
202
  case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_TWO && newThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_TWO:
171
203
  return {
@@ -175,7 +207,7 @@ const getDynamicServerThreshold = (thresholdSignatureScheme)=>{
175
207
  newServerShareCount: 0
176
208
  };
177
209
  // 2-of-3 -> 2-of-3:
178
- // -- server shares: 1 existing, 0 new
210
+ // -- dynamic server shares: 1 existing, 0 new
179
211
  // -- client shares: 1 existing, 1 new
180
212
  case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE && newThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE:
181
213
  return {
@@ -185,7 +217,7 @@ const getDynamicServerThreshold = (thresholdSignatureScheme)=>{
185
217
  newServerShareCount: 0
186
218
  };
187
219
  // 3-of-5 -> 3-of-5:
188
- // -- server shares: 2 existing, 0 new
220
+ // -- dynamic server shares: 2 existing, 0 new
189
221
  // -- client shares: 1 existing, 2 new
190
222
  case oldThresholdSignatureScheme === ThresholdSignatureScheme.THREE_OF_FIVE && newThresholdSignatureScheme === ThresholdSignatureScheme.THREE_OF_FIVE:
191
223
  return {
@@ -195,7 +227,7 @@ const getDynamicServerThreshold = (thresholdSignatureScheme)=>{
195
227
  newServerShareCount: 0
196
228
  };
197
229
  // 2-of-2 -> 2-of-3:
198
- // -- server shares: 1 existing, 0 new
230
+ // -- dynamic server shares: 1 existing, 0 new
199
231
  // -- client shares: 1 existing, 1 new
200
232
  case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_TWO && newThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE:
201
233
  return {
@@ -205,7 +237,7 @@ const getDynamicServerThreshold = (thresholdSignatureScheme)=>{
205
237
  newServerShareCount: 0
206
238
  };
207
239
  // 2-of-2 -> 3-of-5:
208
- // -- server shares: 1 existing, 1 new
240
+ // -- dynamic server shares: 1 existing, 1 new
209
241
  // -- client shares: 1 existing, 2 new
210
242
  case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_TWO && newThresholdSignatureScheme === ThresholdSignatureScheme.THREE_OF_FIVE:
211
243
  return {
@@ -215,7 +247,7 @@ const getDynamicServerThreshold = (thresholdSignatureScheme)=>{
215
247
  newServerShareCount: 1
216
248
  };
217
249
  // 2-of-3 -> 3-of-5:
218
- // -- server shares: 1 existing, 1 new
250
+ // -- dynamic server shares: 1 existing, 1 new
219
251
  // -- client shares: 1 existing, 2 new
220
252
  case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE && newThresholdSignatureScheme === ThresholdSignatureScheme.THREE_OF_FIVE:
221
253
  return {
@@ -225,7 +257,7 @@ const getDynamicServerThreshold = (thresholdSignatureScheme)=>{
225
257
  newServerShareCount: 1
226
258
  };
227
259
  // 2-of-3 -> 2-of-2:
228
- // -- server shares: 1 existing, 0 new
260
+ // -- dynamic server shares: 1 existing, 0 new
229
261
  // -- client shares: 1 existing, 0 new
230
262
  case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE && newThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_TWO:
231
263
  return {
@@ -235,7 +267,7 @@ const getDynamicServerThreshold = (thresholdSignatureScheme)=>{
235
267
  newServerShareCount: 0
236
268
  };
237
269
  // 3-of-5 -> 2-of-3:
238
- // -- server shares: 1 existing, 0 new
270
+ // -- dynamic server shares: 1 existing, 0 new
239
271
  // -- client shares: 2 existing, 0 new
240
272
  case oldThresholdSignatureScheme === ThresholdSignatureScheme.THREE_OF_FIVE && newThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE:
241
273
  return {
@@ -248,6 +280,102 @@ const getDynamicServerThreshold = (thresholdSignatureScheme)=>{
248
280
  throw new Error(`Unsupported reshare from ${oldThresholdSignatureScheme} to ${newThresholdSignatureScheme}`);
249
281
  }
250
282
  };
283
+ /**
284
+ * Helper function to get the reshare config for client and server shares
285
+ * @param {ThresholdSignatureScheme} oldThresholdSignatureScheme - The current threshold signature scheme
286
+ * @param {ThresholdSignatureScheme} newThresholdSignatureScheme - The target threshold signature scheme
287
+ * @returns {{
288
+ * existingServerShareCount: number,
289
+ * newServerhareCount: number,
290
+ * existingDynamicServerShareCount: number,
291
+ * newDynamicServerShareCount: number
292
+ * }} The number of existing and new client and server shares needed
293
+ */ const getServerWalletReshareConfig = ({ oldThresholdSignatureScheme, newThresholdSignatureScheme })=>{
294
+ switch(true){
295
+ // 2-of-2 -> 2-of-2:
296
+ // -- dyanmic server shares: 1 existing, 0 new
297
+ // -- external server shares: 1 existing, 0 new
298
+ case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_TWO && newThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_TWO:
299
+ return {
300
+ existingExternalServerShareCount: 1,
301
+ newExternalServerShareCount: 0,
302
+ existingDynamicServerShareCount: 1,
303
+ newDynamicServerShareCount: 0
304
+ };
305
+ // 2-of-3 -> 2-of-3:
306
+ // -- dyanmic server shares: 1 existing, 0 new
307
+ // -- external server shares: 1 existing, 1 new
308
+ case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE && newThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE:
309
+ return {
310
+ existingExternalServerShareCount: 1,
311
+ newExternalServerShareCount: 1,
312
+ existingDynamicServerShareCount: 1,
313
+ newDynamicServerShareCount: 0
314
+ };
315
+ // 3-of-5 -> 3-of-5:
316
+ // -- dyanmic server shares: 2 existing, 0 new
317
+ // -- external server shares: 1 existing, 2 new
318
+ case oldThresholdSignatureScheme === ThresholdSignatureScheme.THREE_OF_FIVE && newThresholdSignatureScheme === ThresholdSignatureScheme.THREE_OF_FIVE:
319
+ return {
320
+ existingExternalServerShareCount: 1,
321
+ newExternalServerShareCount: 2,
322
+ existingDynamicServerShareCount: 2,
323
+ newDynamicServerShareCount: 0
324
+ };
325
+ // 2-of-2 -> 2-of-3:
326
+ // -- dyanmic server shares: 1 existing, 0 new
327
+ // -- external server shares: 1 existing, 1 new
328
+ case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_TWO && newThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE:
329
+ return {
330
+ existingExternalServerShareCount: 1,
331
+ newExternalServerShareCount: 1,
332
+ existingDynamicServerShareCount: 1,
333
+ newDynamicServerShareCount: 0
334
+ };
335
+ // 2-of-2 -> 3-of-5:
336
+ // -- dyanmic server shares: 1 existing, 1 new
337
+ // -- external server shares: 1 existing, 2 new
338
+ case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_TWO && newThresholdSignatureScheme === ThresholdSignatureScheme.THREE_OF_FIVE:
339
+ return {
340
+ existingExternalServerShareCount: 1,
341
+ newExternalServerShareCount: 2,
342
+ existingDynamicServerShareCount: 1,
343
+ newDynamicServerShareCount: 1
344
+ };
345
+ // 2-of-3 -> 3-of-5:
346
+ // -- dyanmic server shares: 1 existing, 1 new
347
+ // -- external server shares: 1 existing, 2 new
348
+ case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE && newThresholdSignatureScheme === ThresholdSignatureScheme.THREE_OF_FIVE:
349
+ return {
350
+ existingExternalServerShareCount: 1,
351
+ newExternalServerShareCount: 2,
352
+ existingDynamicServerShareCount: 1,
353
+ newDynamicServerShareCount: 1
354
+ };
355
+ // 2-of-3 -> 2-of-2:
356
+ // -- dyanmic server shares: 1 existing, 0 new
357
+ // -- external server shares: 1 existing, 0 new
358
+ case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE && newThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_TWO:
359
+ return {
360
+ existingExternalServerShareCount: 1,
361
+ newExternalServerShareCount: 0,
362
+ existingDynamicServerShareCount: 1,
363
+ newDynamicServerShareCount: 0
364
+ };
365
+ // 3-of-5 -> 2-of-3:
366
+ // -- dyanmic server shares: 1 existing, 0 new
367
+ // -- external server shares: 2 existing, 0 new
368
+ case oldThresholdSignatureScheme === ThresholdSignatureScheme.THREE_OF_FIVE && newThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE:
369
+ return {
370
+ existingExternalServerShareCount: 2,
371
+ newExternalServerShareCount: 0,
372
+ existingDynamicServerShareCount: 1,
373
+ newDynamicServerShareCount: 0
374
+ };
375
+ default:
376
+ throw new Error(`Unsupported reshare from ${oldThresholdSignatureScheme} to ${newThresholdSignatureScheme}`);
377
+ }
378
+ };
251
379
 
252
380
  class BaseClient {
253
381
  constructor({ environmentId, baseApiUrl, authToken, baseClientRelayApiUrl }){
@@ -407,6 +535,9 @@ var SuccessEventType = /*#__PURE__*/ function(SuccessEventType) {
407
535
  };
408
536
 
409
537
  class DynamicApiClient extends BaseClient {
538
+ async authenticateApiToken({ environmentId }) {
539
+ return this.apiClient.post(`/api/v0/environments/${environmentId}/waas/authenticate`);
540
+ }
410
541
  async createWalletAccount({ chainName, clientKeygenIds, thresholdSignatureScheme, onError, onCeremonyComplete }) {
411
542
  return createEventStreamPromise({
412
543
  apiClient: this.apiClient,
@@ -490,7 +621,6 @@ class DynamicApiClient extends BaseClient {
490
621
  }
491
622
  async getAccessToken({ oauthAccountId }) {
492
623
  const { data } = await this.apiClient.get(`/api/v0/sdk/${this.environmentId}/oauthAccounts/${oauthAccountId}/accessToken`);
493
- console.log('data', data);
494
624
  return data.accessToken;
495
625
  }
496
626
  // TODO: return array instead considering cases where server has multiple parties
@@ -556,21 +686,28 @@ class DynamicApiClient extends BaseClient {
556
686
 
557
687
  exports.BITCOIN_DERIVATION_PATHS = BITCOIN_DERIVATION_PATHS;
558
688
  exports.BackupLocation = BackupLocation;
689
+ exports.ChainEnumToVerifiedCredentialName = ChainEnumToVerifiedCredentialName;
559
690
  exports.CreateRoomPartiesOptions = CreateRoomPartiesOptions;
560
691
  exports.DYNAMIC_AUTH_PREPROD_BASE_API_URL = DYNAMIC_AUTH_PREPROD_BASE_API_URL;
561
692
  exports.DYNAMIC_AUTH_PROD_BASE_API_URL = DYNAMIC_AUTH_PROD_BASE_API_URL;
562
693
  exports.DYNAMIC_CLIENT_RELAY_PREPROD_BASE_API_URL = DYNAMIC_CLIENT_RELAY_PREPROD_BASE_API_URL;
563
694
  exports.DYNAMIC_CLIENT_RELAY_PROD_BASE_API_URL = DYNAMIC_CLIENT_RELAY_PROD_BASE_API_URL;
564
695
  exports.DynamicApiClient = DynamicApiClient;
696
+ exports.IFRAME_DOMAIN = IFRAME_DOMAIN;
565
697
  exports.MPC_CHAIN_CONFIG = MPC_CHAIN_CONFIG;
566
698
  exports.MPC_CONFIG = MPC_CONFIG;
567
699
  exports.MPC_RELAY_PREPROD_API_URL = MPC_RELAY_PREPROD_API_URL;
568
700
  exports.MPC_RELAY_PROD_API_URL = MPC_RELAY_PROD_API_URL;
569
701
  exports.SOLANA_RPC_URL = SOLANA_RPC_URL;
570
702
  exports.SigningAlgorithm = SigningAlgorithm;
703
+ exports.SuccessEventType = SuccessEventType;
571
704
  exports.ThresholdSignatureScheme = ThresholdSignatureScheme;
705
+ exports.VerifiedCredentialNameToChainEnum = VerifiedCredentialNameToChainEnum;
706
+ exports.WalletOperation = WalletOperation;
707
+ exports.chain = chain;
572
708
  exports.getClientThreshold = getClientThreshold;
573
709
  exports.getDynamicServerThreshold = getDynamicServerThreshold;
574
710
  exports.getMPCChainConfig = getMPCChainConfig;
575
711
  exports.getReshareConfig = getReshareConfig;
712
+ exports.getServerWalletReshareConfig = getServerWalletReshareConfig;
576
713
  exports.getTSSConfig = getTSSConfig;
package/index.esm.js CHANGED
@@ -7,6 +7,46 @@ const DYNAMIC_CLIENT_RELAY_PREPROD_BASE_API_URL = 'https://app-dynamic-preprod-x
7
7
  const MPC_RELAY_PROD_API_URL = 'relay.dynamicauth.com';
8
8
  const MPC_RELAY_PREPROD_API_URL = 'relay.dynamic-preprod.xyz';
9
9
  const SOLANA_RPC_URL = 'https://api.devnet.solana.com';
10
+ const chain = {
11
+ EVM: 'EVM',
12
+ SOL: 'SOL',
13
+ COSMOS: 'COSMOS',
14
+ BTC: 'BTC',
15
+ FLOW: 'FLOW',
16
+ SUI: 'SUI'
17
+ };
18
+ var WalletOperation = /*#__PURE__*/ function(WalletOperation) {
19
+ WalletOperation["REACH_THRESHOLD"] = "REACH_THRESHOLD";
20
+ WalletOperation["REACH_ALL_PARTIES"] = "REACH_ALL_PARTIES";
21
+ WalletOperation["SIGN_MESSAGE"] = "SIGN_MESSAGE";
22
+ WalletOperation["SIGN_TRANSACTION"] = "SIGN_TRANSACTION";
23
+ WalletOperation["REFRESH"] = "REFRESH";
24
+ WalletOperation["RESHARE"] = "RESHARE";
25
+ WalletOperation["EXPORT_PRIVATE_KEY"] = "EXPORT_PRIVATE_KEY";
26
+ WalletOperation["NO_OPERATION"] = "NO_OPERATION";
27
+ return WalletOperation;
28
+ }({});
29
+ var BackupLocation = /*#__PURE__*/ function(BackupLocation) {
30
+ BackupLocation["DYNAMIC"] = "dynamic";
31
+ BackupLocation["GOOGLE_DRIVE"] = "googleDrive";
32
+ BackupLocation["ICLOUD"] = "iCloud";
33
+ BackupLocation["USER"] = "user";
34
+ BackupLocation["EXTERNAL"] = "external";
35
+ return BackupLocation;
36
+ }({});
37
+ // TODO: replace with apiClient proxy and move this to apiClient when ready
38
+ const IFRAME_DOMAIN = 'http://localhost:8090';
39
+ const ChainEnumToVerifiedCredentialName = {
40
+ BTC: 'bip122',
41
+ EVM: 'eip155',
42
+ FLOW: 'flow',
43
+ SOL: 'solana'
44
+ };
45
+ const VerifiedCredentialNameToChainEnum = {
46
+ bip122: 'BTC',
47
+ eip155: 'EVM',
48
+ solana: 'SOL'
49
+ };
10
50
 
11
51
  var SigningAlgorithm = /*#__PURE__*/ function(SigningAlgorithm) {
12
52
  SigningAlgorithm["ECDSA"] = "ECDSA";
@@ -121,14 +161,6 @@ var CreateRoomPartiesOptions = /*#__PURE__*/ function(CreateRoomPartiesOptions)
121
161
  CreateRoomPartiesOptions["FULL"] = "full";
122
162
  return CreateRoomPartiesOptions;
123
163
  }({});
124
- var BackupLocation = /*#__PURE__*/ function(BackupLocation) {
125
- BackupLocation["DYNAMIC"] = "dynamic";
126
- BackupLocation["GOOGLE_DRIVE"] = "googleDrive";
127
- BackupLocation["ICLOUD"] = "iCloud";
128
- BackupLocation["USER"] = "user";
129
- BackupLocation["EXTERNAL"] = "external";
130
- return BackupLocation;
131
- }({});
132
164
 
133
165
  const getMPCChainConfig = (chainName)=>{
134
166
  const chainConfig = MPC_CHAIN_CONFIG[chainName];
@@ -163,7 +195,7 @@ const getDynamicServerThreshold = (thresholdSignatureScheme)=>{
163
195
  */ const getReshareConfig = ({ oldThresholdSignatureScheme, newThresholdSignatureScheme })=>{
164
196
  switch(true){
165
197
  // 2-of-2 -> 2-of-2:
166
- // -- server shares: 1 existing, 0 new
198
+ // -- dynamic server shares: 1 existing, 0 new
167
199
  // -- client shares: 1 existing, 0 new
168
200
  case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_TWO && newThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_TWO:
169
201
  return {
@@ -173,7 +205,7 @@ const getDynamicServerThreshold = (thresholdSignatureScheme)=>{
173
205
  newServerShareCount: 0
174
206
  };
175
207
  // 2-of-3 -> 2-of-3:
176
- // -- server shares: 1 existing, 0 new
208
+ // -- dynamic server shares: 1 existing, 0 new
177
209
  // -- client shares: 1 existing, 1 new
178
210
  case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE && newThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE:
179
211
  return {
@@ -183,7 +215,7 @@ const getDynamicServerThreshold = (thresholdSignatureScheme)=>{
183
215
  newServerShareCount: 0
184
216
  };
185
217
  // 3-of-5 -> 3-of-5:
186
- // -- server shares: 2 existing, 0 new
218
+ // -- dynamic server shares: 2 existing, 0 new
187
219
  // -- client shares: 1 existing, 2 new
188
220
  case oldThresholdSignatureScheme === ThresholdSignatureScheme.THREE_OF_FIVE && newThresholdSignatureScheme === ThresholdSignatureScheme.THREE_OF_FIVE:
189
221
  return {
@@ -193,7 +225,7 @@ const getDynamicServerThreshold = (thresholdSignatureScheme)=>{
193
225
  newServerShareCount: 0
194
226
  };
195
227
  // 2-of-2 -> 2-of-3:
196
- // -- server shares: 1 existing, 0 new
228
+ // -- dynamic server shares: 1 existing, 0 new
197
229
  // -- client shares: 1 existing, 1 new
198
230
  case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_TWO && newThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE:
199
231
  return {
@@ -203,7 +235,7 @@ const getDynamicServerThreshold = (thresholdSignatureScheme)=>{
203
235
  newServerShareCount: 0
204
236
  };
205
237
  // 2-of-2 -> 3-of-5:
206
- // -- server shares: 1 existing, 1 new
238
+ // -- dynamic server shares: 1 existing, 1 new
207
239
  // -- client shares: 1 existing, 2 new
208
240
  case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_TWO && newThresholdSignatureScheme === ThresholdSignatureScheme.THREE_OF_FIVE:
209
241
  return {
@@ -213,7 +245,7 @@ const getDynamicServerThreshold = (thresholdSignatureScheme)=>{
213
245
  newServerShareCount: 1
214
246
  };
215
247
  // 2-of-3 -> 3-of-5:
216
- // -- server shares: 1 existing, 1 new
248
+ // -- dynamic server shares: 1 existing, 1 new
217
249
  // -- client shares: 1 existing, 2 new
218
250
  case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE && newThresholdSignatureScheme === ThresholdSignatureScheme.THREE_OF_FIVE:
219
251
  return {
@@ -223,7 +255,7 @@ const getDynamicServerThreshold = (thresholdSignatureScheme)=>{
223
255
  newServerShareCount: 1
224
256
  };
225
257
  // 2-of-3 -> 2-of-2:
226
- // -- server shares: 1 existing, 0 new
258
+ // -- dynamic server shares: 1 existing, 0 new
227
259
  // -- client shares: 1 existing, 0 new
228
260
  case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE && newThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_TWO:
229
261
  return {
@@ -233,7 +265,7 @@ const getDynamicServerThreshold = (thresholdSignatureScheme)=>{
233
265
  newServerShareCount: 0
234
266
  };
235
267
  // 3-of-5 -> 2-of-3:
236
- // -- server shares: 1 existing, 0 new
268
+ // -- dynamic server shares: 1 existing, 0 new
237
269
  // -- client shares: 2 existing, 0 new
238
270
  case oldThresholdSignatureScheme === ThresholdSignatureScheme.THREE_OF_FIVE && newThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE:
239
271
  return {
@@ -246,6 +278,102 @@ const getDynamicServerThreshold = (thresholdSignatureScheme)=>{
246
278
  throw new Error(`Unsupported reshare from ${oldThresholdSignatureScheme} to ${newThresholdSignatureScheme}`);
247
279
  }
248
280
  };
281
+ /**
282
+ * Helper function to get the reshare config for client and server shares
283
+ * @param {ThresholdSignatureScheme} oldThresholdSignatureScheme - The current threshold signature scheme
284
+ * @param {ThresholdSignatureScheme} newThresholdSignatureScheme - The target threshold signature scheme
285
+ * @returns {{
286
+ * existingServerShareCount: number,
287
+ * newServerhareCount: number,
288
+ * existingDynamicServerShareCount: number,
289
+ * newDynamicServerShareCount: number
290
+ * }} The number of existing and new client and server shares needed
291
+ */ const getServerWalletReshareConfig = ({ oldThresholdSignatureScheme, newThresholdSignatureScheme })=>{
292
+ switch(true){
293
+ // 2-of-2 -> 2-of-2:
294
+ // -- dyanmic server shares: 1 existing, 0 new
295
+ // -- external server shares: 1 existing, 0 new
296
+ case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_TWO && newThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_TWO:
297
+ return {
298
+ existingExternalServerShareCount: 1,
299
+ newExternalServerShareCount: 0,
300
+ existingDynamicServerShareCount: 1,
301
+ newDynamicServerShareCount: 0
302
+ };
303
+ // 2-of-3 -> 2-of-3:
304
+ // -- dyanmic server shares: 1 existing, 0 new
305
+ // -- external server shares: 1 existing, 1 new
306
+ case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE && newThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE:
307
+ return {
308
+ existingExternalServerShareCount: 1,
309
+ newExternalServerShareCount: 1,
310
+ existingDynamicServerShareCount: 1,
311
+ newDynamicServerShareCount: 0
312
+ };
313
+ // 3-of-5 -> 3-of-5:
314
+ // -- dyanmic server shares: 2 existing, 0 new
315
+ // -- external server shares: 1 existing, 2 new
316
+ case oldThresholdSignatureScheme === ThresholdSignatureScheme.THREE_OF_FIVE && newThresholdSignatureScheme === ThresholdSignatureScheme.THREE_OF_FIVE:
317
+ return {
318
+ existingExternalServerShareCount: 1,
319
+ newExternalServerShareCount: 2,
320
+ existingDynamicServerShareCount: 2,
321
+ newDynamicServerShareCount: 0
322
+ };
323
+ // 2-of-2 -> 2-of-3:
324
+ // -- dyanmic server shares: 1 existing, 0 new
325
+ // -- external server shares: 1 existing, 1 new
326
+ case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_TWO && newThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE:
327
+ return {
328
+ existingExternalServerShareCount: 1,
329
+ newExternalServerShareCount: 1,
330
+ existingDynamicServerShareCount: 1,
331
+ newDynamicServerShareCount: 0
332
+ };
333
+ // 2-of-2 -> 3-of-5:
334
+ // -- dyanmic server shares: 1 existing, 1 new
335
+ // -- external server shares: 1 existing, 2 new
336
+ case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_TWO && newThresholdSignatureScheme === ThresholdSignatureScheme.THREE_OF_FIVE:
337
+ return {
338
+ existingExternalServerShareCount: 1,
339
+ newExternalServerShareCount: 2,
340
+ existingDynamicServerShareCount: 1,
341
+ newDynamicServerShareCount: 1
342
+ };
343
+ // 2-of-3 -> 3-of-5:
344
+ // -- dyanmic server shares: 1 existing, 1 new
345
+ // -- external server shares: 1 existing, 2 new
346
+ case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE && newThresholdSignatureScheme === ThresholdSignatureScheme.THREE_OF_FIVE:
347
+ return {
348
+ existingExternalServerShareCount: 1,
349
+ newExternalServerShareCount: 2,
350
+ existingDynamicServerShareCount: 1,
351
+ newDynamicServerShareCount: 1
352
+ };
353
+ // 2-of-3 -> 2-of-2:
354
+ // -- dyanmic server shares: 1 existing, 0 new
355
+ // -- external server shares: 1 existing, 0 new
356
+ case oldThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE && newThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_TWO:
357
+ return {
358
+ existingExternalServerShareCount: 1,
359
+ newExternalServerShareCount: 0,
360
+ existingDynamicServerShareCount: 1,
361
+ newDynamicServerShareCount: 0
362
+ };
363
+ // 3-of-5 -> 2-of-3:
364
+ // -- dyanmic server shares: 1 existing, 0 new
365
+ // -- external server shares: 2 existing, 0 new
366
+ case oldThresholdSignatureScheme === ThresholdSignatureScheme.THREE_OF_FIVE && newThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_THREE:
367
+ return {
368
+ existingExternalServerShareCount: 2,
369
+ newExternalServerShareCount: 0,
370
+ existingDynamicServerShareCount: 1,
371
+ newDynamicServerShareCount: 0
372
+ };
373
+ default:
374
+ throw new Error(`Unsupported reshare from ${oldThresholdSignatureScheme} to ${newThresholdSignatureScheme}`);
375
+ }
376
+ };
249
377
 
250
378
  class BaseClient {
251
379
  constructor({ environmentId, baseApiUrl, authToken, baseClientRelayApiUrl }){
@@ -405,6 +533,9 @@ var SuccessEventType = /*#__PURE__*/ function(SuccessEventType) {
405
533
  };
406
534
 
407
535
  class DynamicApiClient extends BaseClient {
536
+ async authenticateApiToken({ environmentId }) {
537
+ return this.apiClient.post(`/api/v0/environments/${environmentId}/waas/authenticate`);
538
+ }
408
539
  async createWalletAccount({ chainName, clientKeygenIds, thresholdSignatureScheme, onError, onCeremonyComplete }) {
409
540
  return createEventStreamPromise({
410
541
  apiClient: this.apiClient,
@@ -488,7 +619,6 @@ class DynamicApiClient extends BaseClient {
488
619
  }
489
620
  async getAccessToken({ oauthAccountId }) {
490
621
  const { data } = await this.apiClient.get(`/api/v0/sdk/${this.environmentId}/oauthAccounts/${oauthAccountId}/accessToken`);
491
- console.log('data', data);
492
622
  return data.accessToken;
493
623
  }
494
624
  // TODO: return array instead considering cases where server has multiple parties
@@ -552,4 +682,4 @@ class DynamicApiClient extends BaseClient {
552
682
  }
553
683
  }
554
684
 
555
- export { BITCOIN_DERIVATION_PATHS, BackupLocation, CreateRoomPartiesOptions, DYNAMIC_AUTH_PREPROD_BASE_API_URL, DYNAMIC_AUTH_PROD_BASE_API_URL, DYNAMIC_CLIENT_RELAY_PREPROD_BASE_API_URL, DYNAMIC_CLIENT_RELAY_PROD_BASE_API_URL, DynamicApiClient, MPC_CHAIN_CONFIG, MPC_CONFIG, MPC_RELAY_PREPROD_API_URL, MPC_RELAY_PROD_API_URL, SOLANA_RPC_URL, SigningAlgorithm, ThresholdSignatureScheme, getClientThreshold, getDynamicServerThreshold, getMPCChainConfig, getReshareConfig, getTSSConfig };
685
+ export { BITCOIN_DERIVATION_PATHS, BackupLocation, ChainEnumToVerifiedCredentialName, CreateRoomPartiesOptions, DYNAMIC_AUTH_PREPROD_BASE_API_URL, DYNAMIC_AUTH_PROD_BASE_API_URL, DYNAMIC_CLIENT_RELAY_PREPROD_BASE_API_URL, DYNAMIC_CLIENT_RELAY_PROD_BASE_API_URL, DynamicApiClient, IFRAME_DOMAIN, MPC_CHAIN_CONFIG, MPC_CONFIG, MPC_RELAY_PREPROD_API_URL, MPC_RELAY_PROD_API_URL, SOLANA_RPC_URL, SigningAlgorithm, SuccessEventType, ThresholdSignatureScheme, VerifiedCredentialNameToChainEnum, WalletOperation, chain, getClientThreshold, getDynamicServerThreshold, getMPCChainConfig, getReshareConfig, getServerWalletReshareConfig, getTSSConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs-wallet/core",
3
- "version": "0.0.48",
3
+ "version": "0.0.50",
4
4
  "license": "MIT",
5
5
  "dependencies": {
6
6
  "axios": "1.7.9"
package/src/api/api.d.ts CHANGED
@@ -7,6 +7,9 @@ export declare class DynamicApiClient extends BaseClient {
7
7
  authToken: string;
8
8
  baseApiUrl?: string;
9
9
  });
10
+ authenticateApiToken({ environmentId }: {
11
+ environmentId: string;
12
+ }): Promise<import("axios").AxiosResponse<any, any>>;
10
13
  createWalletAccount({ chainName, clientKeygenIds, thresholdSignatureScheme, onError, onCeremonyComplete, }: {
11
14
  chainName: string;
12
15
  clientKeygenIds: string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,CAAA;KAAE;IAQ7D,gBAAgB,CAAC,EACrB,SAAS,EACT,eAAe,EACf,wBAAwB,EACxB,OAAO,EACP,kBAAkB,GACnB,EAAE;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,EAAE,CAAC;QAC1B,wBAAwB,EAAE,wBAAwB,CAAC;QACnD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;QACjC,kBAAkB,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;KACzE;IAiBK,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC;IAsBvB,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC;CAqBlC"}
@@ -8,7 +8,7 @@ export declare class BaseClient {
8
8
  constructor({ environmentId, baseApiUrl, authToken, baseClientRelayApiUrl, }: {
9
9
  environmentId: string;
10
10
  baseApiUrl?: string;
11
- authToken?: string;
11
+ authToken: string;
12
12
  baseClientRelayApiUrl?: string;
13
13
  });
14
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAQlD,qBAAa,UAAU;IACd,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,oBAAoB,EAAE,aAAa,CAAC;gBAC/B,EACV,aAAa,EACb,UAAU,EACV,SAAS,EACT,qBAAqB,GACtB,EAAE;QACD,aAAa,EAAE,MAAM,CAAC;QACtB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,qBAAqB,CAAC,EAAE,MAAM,CAAC;KAChC;CA0BF"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAQlD,qBAAa,UAAU;IACd,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,oBAAoB,EAAE,aAAa,CAAC;gBAE/B,EACV,aAAa,EACb,UAAU,EACV,SAAS,EACT,qBAAqB,GACtB,EAAE;QACD,aAAa,EAAE,MAAM,CAAC;QACtB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,qBAAqB,CAAC,EAAE,MAAM,CAAC;KAChC;CA0BF"}
@@ -5,4 +5,37 @@ export declare const DYNAMIC_CLIENT_RELAY_PREPROD_BASE_API_URL = "https://app-dy
5
5
  export declare const MPC_RELAY_PROD_API_URL = "relay.dynamicauth.com";
6
6
  export declare const MPC_RELAY_PREPROD_API_URL = "relay.dynamic-preprod.xyz";
7
7
  export declare const SOLANA_RPC_URL = "https://api.devnet.solana.com";
8
+ export declare const chain: {
9
+ readonly EVM: "EVM";
10
+ readonly SOL: "SOL";
11
+ readonly COSMOS: "COSMOS";
12
+ readonly BTC: "BTC";
13
+ readonly FLOW: "FLOW";
14
+ readonly SUI: "SUI";
15
+ };
16
+ export type ChainType = (typeof chain)[keyof typeof chain];
17
+ export declare enum WalletOperation {
18
+ REACH_THRESHOLD = "REACH_THRESHOLD",
19
+ REACH_ALL_PARTIES = "REACH_ALL_PARTIES",
20
+ SIGN_MESSAGE = "SIGN_MESSAGE",
21
+ SIGN_TRANSACTION = "SIGN_TRANSACTION",
22
+ REFRESH = "REFRESH",
23
+ RESHARE = "RESHARE",
24
+ EXPORT_PRIVATE_KEY = "EXPORT_PRIVATE_KEY",
25
+ NO_OPERATION = "NO_OPERATION"
26
+ }
27
+ export declare enum BackupLocation {
28
+ DYNAMIC = "dynamic",
29
+ GOOGLE_DRIVE = "googleDrive",
30
+ ICLOUD = "iCloud",
31
+ USER = "user",
32
+ EXTERNAL = "external"
33
+ }
34
+ export declare const IFRAME_DOMAIN = "http://localhost:8090";
35
+ export declare const ChainEnumToVerifiedCredentialName: {
36
+ [key: string]: string;
37
+ };
38
+ export declare const VerifiedCredentialNameToChainEnum: {
39
+ [key: string]: string;
40
+ };
8
41
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../packages/src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,8BAA8B,gCAAgC,CAAC;AAC5E,eAAO,MAAM,iCAAiC,oCACX,CAAC;AAEpC,eAAO,MAAM,sCAAsC,qEACiB,CAAC;AACrE,eAAO,MAAM,yCAAyC,yEACkB,CAAC;AAEzE,eAAO,MAAM,sBAAsB,0BAA0B,CAAC;AAC9D,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AAErE,eAAO,MAAM,cAAc,kCAAkC,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../packages/src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,8BAA8B,gCAAgC,CAAC;AAC5E,eAAO,MAAM,iCAAiC,oCACX,CAAC;AAEpC,eAAO,MAAM,sCAAsC,qEACiB,CAAC;AACrE,eAAO,MAAM,yCAAyC,yEACkB,CAAC;AAEzE,eAAO,MAAM,sBAAsB,0BAA0B,CAAC;AAC9D,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AAErE,eAAO,MAAM,cAAc,kCAAkC,CAAC;AAE9D,eAAO,MAAM,KAAK;;;;;;;CAOR,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,OAAO,KAAK,CAAC,CAAC;AAE3D,oBAAY,eAAe;IACzB,eAAe,oBAAoB;IACnC,iBAAiB,sBAAsB;IACvC,YAAY,iBAAiB;IAC7B,gBAAgB,qBAAqB;IACrC,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,kBAAkB,uBAAuB;IACzC,YAAY,iBAAiB;CAC9B;AAED,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,YAAY,gBAAgB;IAC5B,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,QAAQ,aAAa;CACtB;AAGD,eAAO,MAAM,aAAa,0BAA0B,CAAC;AAErD,eAAO,MAAM,iCAAiC,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAKtE,CAAC;AAEF,eAAO,MAAM,iCAAiC,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAItE,CAAC"}
package/src/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './constants';
2
2
  export * from './mpc/index';
3
3
  export * from './api/index';
4
+ export * from './types';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
@@ -41,11 +41,4 @@ export declare enum CreateRoomPartiesOptions {
41
41
  THRESHOLD = "threshold",
42
42
  FULL = "full"
43
43
  }
44
- export declare enum BackupLocation {
45
- DYNAMIC = "dynamic",
46
- GOOGLE_DRIVE = "googleDrive",
47
- ICLOUD = "iCloud",
48
- USER = "user",
49
- EXTERNAL = "external"
50
- }
51
44
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/mpc/constants.ts"],"names":[],"mappings":"AAAA,oBAAY,gBAAgB;IAC1B,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,MAAM,WAAW;CAClB;AAED,eAAO,MAAM,wBAAwB;;;;CAMpC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,MAAM,EACN;IAAE,cAAc,EAAE,MAAM,EAAE,CAAC;IAAC,gBAAgB,EAAE,gBAAgB,CAAA;CAAE,CA2BjE,CAAC;AAEF,oBAAY,wBAAwB;IAClC,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAC7B,aAAa,kBAAkB;CAChC;AAED,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;CAmBtB,CAAC;AAEF,oBAAY,wBAAwB;IAClC,SAAS,cAAc;IACvB,IAAI,SAAS;CACd;AAED,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,YAAY,gBAAgB;IAC5B,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,QAAQ,aAAa;CACtB"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/mpc/constants.ts"],"names":[],"mappings":"AAAA,oBAAY,gBAAgB;IAC1B,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,MAAM,WAAW;CAClB;AAED,eAAO,MAAM,wBAAwB;;;;CAMpC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,MAAM,EACN;IAAE,cAAc,EAAE,MAAM,EAAE,CAAC;IAAC,gBAAgB,EAAE,gBAAgB,CAAA;CAAE,CA2BjE,CAAC;AAEF,oBAAY,wBAAwB;IAClC,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAC7B,aAAa,kBAAkB;CAChC;AAED,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;CAmBtB,CAAC;AAEF,oBAAY,wBAAwB;IAClC,SAAS,cAAc;IACvB,IAAI,SAAS;CACd"}
@@ -29,4 +29,24 @@ export declare const getReshareConfig: ({ oldThresholdSignatureScheme, newThresh
29
29
  existingServerShareCount: number;
30
30
  newServerShareCount: number;
31
31
  };
32
+ /**
33
+ * Helper function to get the reshare config for client and server shares
34
+ * @param {ThresholdSignatureScheme} oldThresholdSignatureScheme - The current threshold signature scheme
35
+ * @param {ThresholdSignatureScheme} newThresholdSignatureScheme - The target threshold signature scheme
36
+ * @returns {{
37
+ * existingServerShareCount: number,
38
+ * newServerhareCount: number,
39
+ * existingDynamicServerShareCount: number,
40
+ * newDynamicServerShareCount: number
41
+ * }} The number of existing and new client and server shares needed
42
+ */
43
+ export declare const getServerWalletReshareConfig: ({ oldThresholdSignatureScheme, newThresholdSignatureScheme, }: {
44
+ oldThresholdSignatureScheme: ThresholdSignatureScheme;
45
+ newThresholdSignatureScheme: ThresholdSignatureScheme;
46
+ }) => {
47
+ existingExternalServerShareCount: number;
48
+ newExternalServerShareCount: number;
49
+ existingDynamicServerShareCount: number;
50
+ newDynamicServerShareCount: number;
51
+ };
32
52
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/mpc/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,wBAAwB,EACzB,MAAM,aAAa,CAAC;AAErB,eAAO,MAAM,iBAAiB,cAAe,MAAM;;;CAMlD,CAAC;AAEF,eAAO,MAAM,YAAY,6BACG,wBAAwB;;;CAInD,CAAC;AAEF,eAAO,MAAM,kBAAkB,6BACH,wBAAwB,WAGnD,CAAC;AAEF,eAAO,MAAM,yBAAyB,6BACV,wBAAwB,WAGnD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,kEAG1B;IACD,2BAA2B,EAAE,wBAAwB,CAAC;IACtD,2BAA2B,EAAE,wBAAwB,CAAC;CACvD,KAAG;IACF,wBAAwB,EAAE,MAAM,CAAC;IACjC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,wBAAwB,EAAE,MAAM,CAAC;IACjC,mBAAmB,EAAE,MAAM,CAAC;CA6G7B,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/mpc/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,wBAAwB,EACzB,MAAM,aAAa,CAAC;AAErB,eAAO,MAAM,iBAAiB,cAAe,MAAM;;;CAMlD,CAAC;AAEF,eAAO,MAAM,YAAY,6BACG,wBAAwB;;;CAInD,CAAC;AAEF,eAAO,MAAM,kBAAkB,6BACH,wBAAwB,WAGnD,CAAC;AAEF,eAAO,MAAM,yBAAyB,6BACV,wBAAwB,WAGnD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,kEAG1B;IACD,2BAA2B,EAAE,wBAAwB,CAAC;IACtD,2BAA2B,EAAE,wBAAwB,CAAC;CACvD,KAAG;IACF,wBAAwB,EAAE,MAAM,CAAC;IACjC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,wBAAwB,EAAE,MAAM,CAAC;IACjC,mBAAmB,EAAE,MAAM,CAAC;CA6G7B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,4BAA4B,kEAGtC;IACD,2BAA2B,EAAE,wBAAwB,CAAC;IACtD,2BAA2B,EAAE,wBAAwB,CAAC;CACvD,KAAG;IACF,gCAAgC,EAAE,MAAM,CAAC;IACzC,2BAA2B,EAAE,MAAM,CAAC;IACpC,+BAA+B,EAAE,MAAM,CAAC;IACxC,0BAA0B,EAAE,MAAM,CAAC;CA6GpC,CAAC"}
package/src/types.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { BackupLocation } from './constants';
2
+ import { ThresholdSignatureScheme } from './mpc';
1
3
  export type InitKeygenResult = {
2
4
  keygenId: string;
3
5
  keygenSecret: string;
@@ -25,4 +27,46 @@ export declare enum SuccessEventType {
25
27
  RoomCreated = "room_created",
26
28
  CeremonyComplete = "ceremony_complete"
27
29
  }
30
+ export type InitializeResult = {
31
+ error: unknown | null;
32
+ };
33
+ export interface KeyShareBackupInfo {
34
+ passwordEncrypted: boolean;
35
+ backups: Record<BackupLocation, string[]>;
36
+ }
37
+ export interface WaasWalletProperties {
38
+ derivationPath?: string;
39
+ keyShares: KeyShareInfo[];
40
+ thresholdSignatureScheme: ThresholdSignatureScheme;
41
+ }
42
+ export interface KeyShareInfo {
43
+ id: string;
44
+ backupLocation: BackupLocation;
45
+ passwordEncrypted: boolean;
46
+ }
47
+ export interface DynamicWalletClientProps {
48
+ environmentId: string;
49
+ authToken: string;
50
+ baseApiUrl?: string;
51
+ storageKey?: string;
52
+ debug?: boolean;
53
+ baseMPCRelayApiUrl?: string;
54
+ }
55
+ export type BackupData = {
56
+ keyShares: string[];
57
+ metadata: {
58
+ version: string;
59
+ createdAt: string;
60
+ accountAddress: string;
61
+ thresholdSignatureScheme: ThresholdSignatureScheme;
62
+ hasPassword: boolean;
63
+ encryption?: {
64
+ algorithm: string;
65
+ keyDerivation: string;
66
+ iterations: number;
67
+ hashAlgorithm: string;
68
+ };
69
+ shareCount: number;
70
+ };
71
+ };
28
72
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../packages/src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,eAAe,GAA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