@dynamic-labs-wallet/browser-wallet-client 0.0.0-beta.177.1 → 0.0.0-beta.232.1
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 +78 -60
- package/index.esm.js +78 -44
- package/package.json +3 -4
- package/src/client/client.d.ts +29 -20
- package/src/client/client.d.ts.map +1 -1
- package/src/index.d.ts +0 -1
- package/src/index.d.ts.map +1 -1
- package/src/services/iframeMessageHandler.d.ts +4 -3
- package/src/services/iframeMessageHandler.d.ts.map +1 -1
- package/internal/core/bip340.d.ts +0 -22
- package/internal/core/bip340.js +0 -1
- package/internal/core/common.d.ts +0 -1
- package/internal/core/common.js +0 -1
- package/internal/core/ecdsa.d.ts +0 -23
- package/internal/core/ecdsa.js +0 -1
- package/internal/core/ed25519.d.ts +0 -22
- package/internal/core/ed25519.js +0 -1
- package/internal/core/ed25519_exportable.d.ts +0 -21
- package/internal/core/ed25519_exportable.js +0 -1
- package/internal/core/index.d.ts +0 -8
- package/internal/core/index.js +0 -1
- package/internal/core/native.d.ts +0 -168
- package/internal/core/native.js +0 -1
- package/internal/core/sr25519.d.ts +0 -22
- package/internal/core/sr25519.js +0 -1
- package/internal/core/types.d.ts +0 -78
- package/internal/core/types.js +0 -1
- package/internal/web/generated/libmpc_executor.d.ts +0 -91
- package/internal/web/generated/libmpc_executor.js +0 -2
- package/internal/web/generated/libmpc_executor_bg.wasm +0 -0
- package/internal/web/index.d.ts +0 -17
- package/internal/web/index.js +0 -1
package/index.cjs.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
var messageTransport = require('@dynamic-labs/message-transport');
|
|
4
4
|
var logger$1 = require('@dynamic-labs/logger');
|
|
5
5
|
var core = require('@dynamic-labs-wallet/core');
|
|
6
|
-
var web = require('./internal/web');
|
|
7
6
|
|
|
8
7
|
const setupMessageTransportBridge = (messageTransport$1, iframe, iframeOrigin)=>{
|
|
9
8
|
if (!(iframe == null ? void 0 : iframe.contentWindow)) {
|
|
@@ -49,11 +48,12 @@ class iframeMessageHandler {
|
|
|
49
48
|
async getWallets(request) {
|
|
50
49
|
return this.requestChannel.request('getWallets', request);
|
|
51
50
|
}
|
|
52
|
-
async getWallet({ chainName, accountAddress, walletOperation }) {
|
|
51
|
+
async getWallet({ chainName, accountAddress, walletOperation, signedSessionId }) {
|
|
53
52
|
return this.requestChannel.request('getWallet', {
|
|
54
53
|
chainName,
|
|
55
54
|
accountAddress,
|
|
56
|
-
walletOperation
|
|
55
|
+
walletOperation,
|
|
56
|
+
signedSessionId
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
async createWalletAccount(request) {
|
|
@@ -107,8 +107,8 @@ class iframeMessageHandler {
|
|
|
107
107
|
async offlineExportPrivateKey(request) {
|
|
108
108
|
return this.requestChannel.request('offlineExportPrivateKey', request);
|
|
109
109
|
}
|
|
110
|
-
async cleanup(
|
|
111
|
-
return this.requestChannel.request('cleanup'
|
|
110
|
+
async cleanup() {
|
|
111
|
+
return this.requestChannel.request('cleanup');
|
|
112
112
|
}
|
|
113
113
|
constructor(messageTransport$1){
|
|
114
114
|
this.requestChannel = messageTransport.createRequestChannel(messageTransport$1);
|
|
@@ -145,6 +145,10 @@ class DynamicWalletClient {
|
|
|
145
145
|
/**
|
|
146
146
|
* initialize the message transport after iframe is successfully loaded
|
|
147
147
|
*/ async initializeMessageTransport() {
|
|
148
|
+
if (this.messageTransport && this.iframeMessageHandler) {
|
|
149
|
+
this.logger.debug('Skipping initializeMessageTransport: transport and message handler already initialized');
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
148
152
|
await this.initializeIframeCommunication();
|
|
149
153
|
const transport = messageTransport.applyDefaultMessageOrigin({
|
|
150
154
|
defaultOrigin: 'host',
|
|
@@ -201,13 +205,14 @@ class DynamicWalletClient {
|
|
|
201
205
|
iframe.style.height = '0';
|
|
202
206
|
iframe.style.border = 'none';
|
|
203
207
|
iframe.style.pointerEvents = 'none';
|
|
204
|
-
var _this_instanceId;
|
|
208
|
+
var _this_instanceId, _this_sdkVersion;
|
|
205
209
|
const params = new URLSearchParams({
|
|
206
210
|
instanceId: (_this_instanceId = this.instanceId) != null ? _this_instanceId : '',
|
|
207
211
|
hostOrigin: window.location.origin,
|
|
208
212
|
environmentId: this.environmentId,
|
|
209
213
|
baseApiUrl: this.baseApiUrl,
|
|
210
|
-
baseMPCRelayApiUrl: this.baseMPCRelayApiUrl
|
|
214
|
+
baseMPCRelayApiUrl: this.baseMPCRelayApiUrl,
|
|
215
|
+
sdkVersion: (_this_sdkVersion = this.sdkVersion) != null ? _this_sdkVersion : ''
|
|
211
216
|
});
|
|
212
217
|
iframe.src = `${this.iframeDomain}/waas-v1/${this.environmentId}?${params.toString()}`;
|
|
213
218
|
this.logger.debug('Creating iframe with src:', iframe.src);
|
|
@@ -308,7 +313,7 @@ class DynamicWalletClient {
|
|
|
308
313
|
chainName: this.chainName
|
|
309
314
|
});
|
|
310
315
|
}
|
|
311
|
-
async getWallet({ accountAddress, walletOperation = core.WalletOperation.NO_OPERATION }) {
|
|
316
|
+
async getWallet({ accountAddress, walletOperation = core.WalletOperation.NO_OPERATION, signedSessionId }) {
|
|
312
317
|
await this.initializeMessageTransport();
|
|
313
318
|
if (!this.iframeMessageHandler) {
|
|
314
319
|
throw new Error('Iframe message handler not initialized');
|
|
@@ -316,10 +321,11 @@ class DynamicWalletClient {
|
|
|
316
321
|
return this.iframeMessageHandler.getWallet({
|
|
317
322
|
chainName: this.chainName,
|
|
318
323
|
accountAddress,
|
|
319
|
-
walletOperation
|
|
324
|
+
walletOperation,
|
|
325
|
+
signedSessionId
|
|
320
326
|
});
|
|
321
327
|
}
|
|
322
|
-
async createWalletAccount({ thresholdSignatureScheme, password = undefined }) {
|
|
328
|
+
async createWalletAccount({ thresholdSignatureScheme, password = undefined, signedSessionId, authToken }) {
|
|
323
329
|
await this.initializeMessageTransport();
|
|
324
330
|
if (!this.iframeMessageHandler) {
|
|
325
331
|
throw new Error('Iframe message handler not initialized');
|
|
@@ -327,10 +333,12 @@ class DynamicWalletClient {
|
|
|
327
333
|
return this.iframeMessageHandler.createWalletAccount({
|
|
328
334
|
chainName: this.chainName,
|
|
329
335
|
thresholdSignatureScheme,
|
|
330
|
-
password
|
|
336
|
+
password,
|
|
337
|
+
signedSessionId,
|
|
338
|
+
authToken
|
|
331
339
|
});
|
|
332
340
|
}
|
|
333
|
-
async requiresPasswordForOperation({ accountAddress, walletOperation = core.WalletOperation.REACH_THRESHOLD }) {
|
|
341
|
+
async requiresPasswordForOperation({ accountAddress, walletOperation = core.WalletOperation.REACH_THRESHOLD, authToken }) {
|
|
334
342
|
await this.initializeMessageTransport();
|
|
335
343
|
if (!this.iframeMessageHandler) {
|
|
336
344
|
throw new Error('Iframe message handler not initialized');
|
|
@@ -338,20 +346,22 @@ class DynamicWalletClient {
|
|
|
338
346
|
return this.iframeMessageHandler.requiresPasswordForOperation({
|
|
339
347
|
chainName: this.chainName,
|
|
340
348
|
accountAddress,
|
|
341
|
-
walletOperation
|
|
349
|
+
walletOperation,
|
|
350
|
+
authToken
|
|
342
351
|
});
|
|
343
352
|
}
|
|
344
|
-
async isPasswordEncrypted({ accountAddress }) {
|
|
353
|
+
async isPasswordEncrypted({ accountAddress, authToken }) {
|
|
345
354
|
await this.initializeMessageTransport();
|
|
346
355
|
if (!this.iframeMessageHandler) {
|
|
347
356
|
throw new Error('Iframe message handler not initialized');
|
|
348
357
|
}
|
|
349
358
|
return this.iframeMessageHandler.isPasswordEncrypted({
|
|
350
359
|
chainName: this.chainName,
|
|
351
|
-
accountAddress
|
|
360
|
+
accountAddress,
|
|
361
|
+
authToken
|
|
352
362
|
});
|
|
353
363
|
}
|
|
354
|
-
async signMessage({ message, accountAddress, password = undefined }) {
|
|
364
|
+
async signMessage({ message, accountAddress, password = undefined, signedSessionId, authToken }) {
|
|
355
365
|
await this.initializeMessageTransport();
|
|
356
366
|
if (!this.iframeMessageHandler) {
|
|
357
367
|
throw new Error('Iframe message handler not initialized');
|
|
@@ -360,10 +370,12 @@ class DynamicWalletClient {
|
|
|
360
370
|
chainName: this.chainName,
|
|
361
371
|
message,
|
|
362
372
|
accountAddress,
|
|
363
|
-
password
|
|
373
|
+
password,
|
|
374
|
+
signedSessionId,
|
|
375
|
+
authToken
|
|
364
376
|
});
|
|
365
377
|
}
|
|
366
|
-
async signRawMessage({ message, accountAddress, password = undefined }) {
|
|
378
|
+
async signRawMessage({ message, accountAddress, password = undefined, signedSessionId, authToken }) {
|
|
367
379
|
await this.initializeMessageTransport();
|
|
368
380
|
if (!this.iframeMessageHandler) {
|
|
369
381
|
throw new Error('Iframe message handler not initialized');
|
|
@@ -372,7 +384,9 @@ class DynamicWalletClient {
|
|
|
372
384
|
chainName: this.chainName,
|
|
373
385
|
message,
|
|
374
386
|
accountAddress,
|
|
375
|
-
password
|
|
387
|
+
password,
|
|
388
|
+
signedSessionId,
|
|
389
|
+
authToken
|
|
376
390
|
});
|
|
377
391
|
}
|
|
378
392
|
/**
|
|
@@ -385,7 +399,7 @@ class DynamicWalletClient {
|
|
|
385
399
|
* SUI:
|
|
386
400
|
* const txBytes = await txb.build({ client });
|
|
387
401
|
* const txString = Buffer.from(txBytes).toString("hex");
|
|
388
|
-
*/ async signTransaction({ senderAddress, transaction, password = undefined }) {
|
|
402
|
+
*/ async signTransaction({ senderAddress, transaction, password = undefined, signedSessionId, authToken }) {
|
|
389
403
|
await this.initializeMessageTransport();
|
|
390
404
|
if (!this.iframeMessageHandler) {
|
|
391
405
|
throw new Error('Iframe message handler not initialized');
|
|
@@ -394,10 +408,12 @@ class DynamicWalletClient {
|
|
|
394
408
|
chainName: this.chainName,
|
|
395
409
|
senderAddress,
|
|
396
410
|
transaction,
|
|
397
|
-
password
|
|
411
|
+
password,
|
|
412
|
+
signedSessionId,
|
|
413
|
+
authToken
|
|
398
414
|
});
|
|
399
415
|
}
|
|
400
|
-
async backupKeySharesToGoogleDrive({ accountAddress, password = undefined }) {
|
|
416
|
+
async backupKeySharesToGoogleDrive({ accountAddress, password = undefined, signedSessionId, authToken }) {
|
|
401
417
|
await this.initializeMessageTransport();
|
|
402
418
|
if (!this.iframeMessageHandler) {
|
|
403
419
|
throw new Error('Iframe message handler not initialized');
|
|
@@ -405,10 +421,12 @@ class DynamicWalletClient {
|
|
|
405
421
|
return this.iframeMessageHandler.backupKeySharesToGoogleDrive({
|
|
406
422
|
chainName: this.chainName,
|
|
407
423
|
accountAddress,
|
|
408
|
-
password
|
|
424
|
+
password,
|
|
425
|
+
signedSessionId,
|
|
426
|
+
authToken
|
|
409
427
|
});
|
|
410
428
|
}
|
|
411
|
-
async restoreBackupFromGoogleDrive({ accountAddress, displayContainer, password }) {
|
|
429
|
+
async restoreBackupFromGoogleDrive({ accountAddress, displayContainer, password, signedSessionId, authToken }) {
|
|
412
430
|
const { iframeDisplay } = await this.initializeIframeDisplayForContainer({
|
|
413
431
|
container: displayContainer
|
|
414
432
|
});
|
|
@@ -418,10 +436,12 @@ class DynamicWalletClient {
|
|
|
418
436
|
return iframeDisplay.restoreBackupFromGoogleDrive({
|
|
419
437
|
chainName: this.chainName,
|
|
420
438
|
accountAddress,
|
|
421
|
-
password
|
|
439
|
+
password,
|
|
440
|
+
signedSessionId,
|
|
441
|
+
authToken
|
|
422
442
|
});
|
|
423
443
|
}
|
|
424
|
-
async refreshWalletAccountShares({ accountAddress, password }) {
|
|
444
|
+
async refreshWalletAccountShares({ accountAddress, password, signedSessionId, authToken }) {
|
|
425
445
|
await this.initializeMessageTransport();
|
|
426
446
|
if (!this.iframeMessageHandler) {
|
|
427
447
|
throw new Error('Iframe message handler not initialized');
|
|
@@ -429,10 +449,12 @@ class DynamicWalletClient {
|
|
|
429
449
|
return this.iframeMessageHandler.refreshWalletAccountShares({
|
|
430
450
|
chainName: this.chainName,
|
|
431
451
|
accountAddress: accountAddress,
|
|
432
|
-
password: password
|
|
452
|
+
password: password,
|
|
453
|
+
signedSessionId,
|
|
454
|
+
authToken
|
|
433
455
|
});
|
|
434
456
|
}
|
|
435
|
-
async reshare({ accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password }) {
|
|
457
|
+
async reshare({ accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password, signedSessionId, authToken }) {
|
|
436
458
|
await this.initializeMessageTransport();
|
|
437
459
|
if (!this.iframeMessageHandler) {
|
|
438
460
|
throw new Error('Iframe message handler not initialized');
|
|
@@ -442,10 +464,12 @@ class DynamicWalletClient {
|
|
|
442
464
|
accountAddress,
|
|
443
465
|
oldThresholdSignatureScheme,
|
|
444
466
|
newThresholdSignatureScheme,
|
|
445
|
-
password
|
|
467
|
+
password,
|
|
468
|
+
signedSessionId,
|
|
469
|
+
authToken
|
|
446
470
|
});
|
|
447
471
|
}
|
|
448
|
-
async exportPrivateKey({ accountAddress, displayContainer, password }) {
|
|
472
|
+
async exportPrivateKey({ accountAddress, displayContainer, password, signedSessionId, authToken }) {
|
|
449
473
|
const { iframeDisplay } = await this.initializeIframeDisplayForContainer({
|
|
450
474
|
container: displayContainer
|
|
451
475
|
});
|
|
@@ -455,10 +479,12 @@ class DynamicWalletClient {
|
|
|
455
479
|
return iframeDisplay.exportPrivateKey({
|
|
456
480
|
chainName: this.chainName,
|
|
457
481
|
accountAddress,
|
|
458
|
-
password
|
|
482
|
+
password,
|
|
483
|
+
signedSessionId,
|
|
484
|
+
authToken
|
|
459
485
|
});
|
|
460
486
|
}
|
|
461
|
-
async verifyPassword({ accountAddress, password, walletOperation = core.WalletOperation.NO_OPERATION }) {
|
|
487
|
+
async verifyPassword({ accountAddress, password, walletOperation = core.WalletOperation.NO_OPERATION, signedSessionId, authToken }) {
|
|
462
488
|
await this.initializeMessageTransport();
|
|
463
489
|
if (!this.iframeMessageHandler) {
|
|
464
490
|
throw new Error('Iframe message handler not initialized');
|
|
@@ -467,10 +493,12 @@ class DynamicWalletClient {
|
|
|
467
493
|
chainName: this.chainName,
|
|
468
494
|
accountAddress,
|
|
469
495
|
password,
|
|
470
|
-
walletOperation
|
|
496
|
+
walletOperation,
|
|
497
|
+
signedSessionId,
|
|
498
|
+
authToken
|
|
471
499
|
});
|
|
472
500
|
}
|
|
473
|
-
async updatePassword({ accountAddress, existingPassword, newPassword }) {
|
|
501
|
+
async updatePassword({ accountAddress, existingPassword, newPassword, signedSessionId, authToken }) {
|
|
474
502
|
await this.initializeMessageTransport();
|
|
475
503
|
if (!this.iframeMessageHandler) {
|
|
476
504
|
throw new Error('Iframe message handler not initialized');
|
|
@@ -479,10 +507,12 @@ class DynamicWalletClient {
|
|
|
479
507
|
chainName: this.chainName,
|
|
480
508
|
accountAddress,
|
|
481
509
|
existingPassword,
|
|
482
|
-
newPassword
|
|
510
|
+
newPassword,
|
|
511
|
+
signedSessionId,
|
|
512
|
+
authToken
|
|
483
513
|
});
|
|
484
514
|
}
|
|
485
|
-
async importPrivateKey({ privateKey, thresholdSignatureScheme }) {
|
|
515
|
+
async importPrivateKey({ privateKey, thresholdSignatureScheme, authToken }) {
|
|
486
516
|
await this.initializeMessageTransport();
|
|
487
517
|
if (!this.iframeMessageHandler) {
|
|
488
518
|
throw new Error('Iframe message handler not initialized');
|
|
@@ -490,10 +520,11 @@ class DynamicWalletClient {
|
|
|
490
520
|
return this.iframeMessageHandler.importPrivateKey({
|
|
491
521
|
chainName: this.chainName,
|
|
492
522
|
privateKey,
|
|
493
|
-
thresholdSignatureScheme
|
|
523
|
+
thresholdSignatureScheme,
|
|
524
|
+
authToken
|
|
494
525
|
});
|
|
495
526
|
}
|
|
496
|
-
async exportClientKeyshares({ accountAddress, password }) {
|
|
527
|
+
async exportClientKeyshares({ accountAddress, password, signedSessionId, authToken }) {
|
|
497
528
|
await this.initializeMessageTransport();
|
|
498
529
|
if (!this.iframeMessageHandler) {
|
|
499
530
|
throw new Error('Iframe message handler not initialized');
|
|
@@ -501,10 +532,14 @@ class DynamicWalletClient {
|
|
|
501
532
|
return this.iframeMessageHandler.exportClientKeyshares({
|
|
502
533
|
chainName: this.chainName,
|
|
503
534
|
accountAddress,
|
|
504
|
-
password
|
|
535
|
+
password,
|
|
536
|
+
signedSessionId,
|
|
537
|
+
authToken
|
|
505
538
|
});
|
|
506
539
|
}
|
|
507
|
-
|
|
540
|
+
/**
|
|
541
|
+
* keyShares is stringified list of EcdsaKeygenResult[] and Ed25519KeygenResult[]
|
|
542
|
+
*/ async offlineExportPrivateKey({ keyShares, derivationPath }) {
|
|
508
543
|
await this.initializeMessageTransport();
|
|
509
544
|
if (!this.iframeMessageHandler) {
|
|
510
545
|
throw new Error('Iframe message handler not initialized');
|
|
@@ -527,9 +562,7 @@ class DynamicWalletClient {
|
|
|
527
562
|
if (!this.iframeMessageHandler) {
|
|
528
563
|
throw new Error('Iframe message handler not initialized');
|
|
529
564
|
}
|
|
530
|
-
await this.iframeMessageHandler.cleanup(
|
|
531
|
-
chainName: this.chainName
|
|
532
|
-
});
|
|
565
|
+
await this.iframeMessageHandler.cleanup();
|
|
533
566
|
if (this.iframe) {
|
|
534
567
|
DynamicWalletClient.iframeInstanceCount--;
|
|
535
568
|
if (DynamicWalletClient.sharedIframe && DynamicWalletClient.iframeInstanceCount === 0) {
|
|
@@ -540,7 +573,7 @@ class DynamicWalletClient {
|
|
|
540
573
|
this.iframe = null;
|
|
541
574
|
}
|
|
542
575
|
}
|
|
543
|
-
constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, chainName, debug }){
|
|
576
|
+
constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, chainName, sdkVersion, debug }){
|
|
544
577
|
this.logger = logger;
|
|
545
578
|
this.instanceId = null;
|
|
546
579
|
this.iframeDomain = null;
|
|
@@ -552,6 +585,7 @@ class DynamicWalletClient {
|
|
|
552
585
|
this.baseApiUrl = baseApiUrl;
|
|
553
586
|
this.baseMPCRelayApiUrl = baseMPCRelayApiUrl;
|
|
554
587
|
this.chainName = chainName;
|
|
588
|
+
this.sdkVersion = sdkVersion;
|
|
555
589
|
const environment = core.getEnvironmentFromUrl(baseApiUrl);
|
|
556
590
|
this.iframeDomain = core.IFRAME_DOMAIN_MAP[environment];
|
|
557
591
|
// Generate unique instanceId when client is created
|
|
@@ -582,20 +616,4 @@ Object.defineProperty(exports, "WalletOperation", {
|
|
|
582
616
|
enumerable: true,
|
|
583
617
|
get: function () { return core.WalletOperation; }
|
|
584
618
|
});
|
|
585
|
-
Object.defineProperty(exports, "BIP340KeygenResult", {
|
|
586
|
-
enumerable: true,
|
|
587
|
-
get: function () { return web.BIP340KeygenResult; }
|
|
588
|
-
});
|
|
589
|
-
Object.defineProperty(exports, "EcdsaKeygenResult", {
|
|
590
|
-
enumerable: true,
|
|
591
|
-
get: function () { return web.EcdsaKeygenResult; }
|
|
592
|
-
});
|
|
593
|
-
Object.defineProperty(exports, "EcdsaSignature", {
|
|
594
|
-
enumerable: true,
|
|
595
|
-
get: function () { return web.EcdsaSignature; }
|
|
596
|
-
});
|
|
597
|
-
Object.defineProperty(exports, "Ed25519KeygenResult", {
|
|
598
|
-
enumerable: true,
|
|
599
|
-
get: function () { return web.Ed25519KeygenResult; }
|
|
600
|
-
});
|
|
601
619
|
exports.DynamicWalletClient = DynamicWalletClient;
|