@dynamic-labs-wallet/browser-wallet-client 0.0.0-beta.232.7 → 0.0.0-beta.244.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 CHANGED
@@ -1,60 +1,15 @@
1
1
  'use strict';
2
2
 
3
+ var core = require('@dynamic-labs-wallet/core');
3
4
  var messageTransport = require('@dynamic-labs/message-transport');
4
5
  var logger$1 = require('@dynamic-labs/logger');
5
- var core = require('@dynamic-labs-wallet/core');
6
-
7
- const setupMessageTransportBridge = (messageTransport$1, iframe, iframeOrigin)=>{
8
- if (!(iframe == null ? void 0 : iframe.contentWindow)) {
9
- throw new Error('Iframe or contentWindow not available');
10
- }
11
- const logger = new logger$1.Logger('debug');
12
- messageTransport$1.on((message)=>{
13
- // Forward the message to webview via postMessage
14
- if (message.origin === 'host') {
15
- var _iframe_contentWindow;
16
- iframe == null ? void 0 : (_iframe_contentWindow = iframe.contentWindow) == null ? void 0 : _iframe_contentWindow.postMessage(message, iframeOrigin);
17
- }
18
- });
19
- const handleIncomingMessage = (message)=>{
20
- const { data } = message;
21
- if (!data) return;
22
- if ((data == null ? void 0 : data.origin) !== 'webview') {
23
- return;
24
- }
25
- if (typeof data !== 'object') {
26
- return;
27
- }
28
- try {
29
- const message = messageTransport.parseMessageTransportData(data);
30
- messageTransport$1.emit(message);
31
- } catch (error) {
32
- if (!(error instanceof SyntaxError)) {
33
- logger.error('Error handling incoming message:', error);
34
- }
35
- }
36
- };
37
- /**
38
- * Handle incoming message from android client
39
- */ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
40
- // @ts-ignore
41
- document.addEventListener('message', handleIncomingMessage);
42
- /**
43
- * Handle incoming message from iOS client
44
- */ window.addEventListener('message', handleIncomingMessage);
45
- };
46
6
 
47
7
  class iframeMessageHandler {
48
8
  async getWallets(request) {
49
9
  return this.requestChannel.request('getWallets', request);
50
10
  }
51
- async getWallet({ chainName, accountAddress, walletOperation, signedSessionId }) {
52
- return this.requestChannel.request('getWallet', {
53
- chainName,
54
- accountAddress,
55
- walletOperation,
56
- signedSessionId
57
- });
11
+ async getWallet(request) {
12
+ return this.requestChannel.request('getWallet', request);
58
13
  }
59
14
  async createWalletAccount(request) {
60
15
  return this.requestChannel.request('createWalletAccount', request);
@@ -107,6 +62,9 @@ class iframeMessageHandler {
107
62
  async offlineExportPrivateKey(request) {
108
63
  return this.requestChannel.request('offlineExportPrivateKey', request);
109
64
  }
65
+ async signTypedData(request) {
66
+ return this.requestChannel.request('signTypedData', request);
67
+ }
110
68
  async cleanup() {
111
69
  return this.requestChannel.request('cleanup');
112
70
  }
@@ -117,6 +75,46 @@ class iframeMessageHandler {
117
75
 
118
76
  const logger = new logger$1.Logger('DynamicWaasWalletClient');
119
77
 
78
+ const setupMessageTransportBridge = (messageTransport$1, iframe, iframeOrigin)=>{
79
+ if (!(iframe == null ? void 0 : iframe.contentWindow)) {
80
+ throw new Error('Iframe or contentWindow not available');
81
+ }
82
+ const logger = new logger$1.Logger('debug');
83
+ messageTransport$1.on((message)=>{
84
+ // Forward the message to webview via postMessage
85
+ if (message.origin === 'host') {
86
+ var _iframe_contentWindow;
87
+ iframe == null ? void 0 : (_iframe_contentWindow = iframe.contentWindow) == null ? void 0 : _iframe_contentWindow.postMessage(message, iframeOrigin);
88
+ }
89
+ });
90
+ const handleIncomingMessage = (message)=>{
91
+ const { data } = message;
92
+ if (!data) return;
93
+ if ((data == null ? void 0 : data.origin) !== 'webview') {
94
+ return;
95
+ }
96
+ if (typeof data !== 'object') {
97
+ return;
98
+ }
99
+ try {
100
+ const message = messageTransport.parseMessageTransportData(data);
101
+ messageTransport$1.emit(message);
102
+ } catch (error) {
103
+ if (!(error instanceof SyntaxError)) {
104
+ logger.error('Error handling incoming message:', error);
105
+ }
106
+ }
107
+ };
108
+ /**
109
+ * Handle incoming message from android client
110
+ */ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
111
+ // @ts-ignore
112
+ document.addEventListener('message', handleIncomingMessage);
113
+ /**
114
+ * Handle incoming message from iOS client
115
+ */ window.addEventListener('message', handleIncomingMessage);
116
+ };
117
+
120
118
  class DynamicWalletClient {
121
119
  // Simply load the iframe from localhost
122
120
  async initialize() {
@@ -145,6 +143,10 @@ class DynamicWalletClient {
145
143
  /**
146
144
  * initialize the message transport after iframe is successfully loaded
147
145
  */ async initializeMessageTransport() {
146
+ if (this.messageTransport && this.iframeMessageHandler) {
147
+ this.logger.debug('Skipping initializeMessageTransport: transport and message handler already initialized');
148
+ return;
149
+ }
148
150
  await this.initializeIframeCommunication();
149
151
  const transport = messageTransport.applyDefaultMessageOrigin({
150
152
  defaultOrigin: 'host',
@@ -171,6 +173,18 @@ class DynamicWalletClient {
171
173
  throw new Error('Failed to establish secure token exchange: ' + error);
172
174
  }
173
175
  }
176
+ /**
177
+ * Reset the shared iframe and iframe load promise, and iframe instance count
178
+ */ async resetSharedIframe() {
179
+ DynamicWalletClient.sharedIframe = null;
180
+ DynamicWalletClient.iframeInstanceCount = 0;
181
+ DynamicWalletClient.iframeLoadPromise = null;
182
+ this.iframe = null;
183
+ this.iframeMessageHandler = null;
184
+ this.messageTransport = null;
185
+ // Double the timeout and cap at 60 seconds to give more time for slow networks
186
+ this.iframeLoadTimeout = Math.min(this.iframeLoadTimeout * 2, 60000);
187
+ }
174
188
  async loadIframe() {
175
189
  // If the iframe is already loaded, just assign and resolve
176
190
  if (DynamicWalletClient.sharedIframe) {
@@ -186,10 +200,27 @@ class DynamicWalletClient {
186
200
  });
187
201
  }
188
202
  DynamicWalletClient.iframeLoadPromise = new Promise((resolve, reject)=>{
203
+ var _this_sdkVersion;
204
+ this.logger.info(`Loading iframe for waas wallet client...`, {
205
+ iframeDomain: this.iframeDomain,
206
+ environmentId: this.environmentId,
207
+ sdkVersion: (_this_sdkVersion = this.sdkVersion) != null ? _this_sdkVersion : '',
208
+ instanceId: this.instanceId,
209
+ chainName: this.chainName
210
+ });
189
211
  const iframe = document.createElement('iframe');
190
212
  const iframeTimeoutId = setTimeout(()=>{
191
- reject(new Error('Iframe load timeout'));
192
- }, 10000);
213
+ this.resetSharedIframe();
214
+ var _this_sdkVersion;
215
+ this.logger.error('Iframe load timeout due to no handshake message from iframe, this could be network issues, incorrect iframe domain, or CORS errors that prevents iframe from being loaded or sending handshake message. A retry will be attempted to load the iframe with wallet interaction function calls.', {
216
+ iframeDomain: this.iframeDomain,
217
+ environmentId: this.environmentId,
218
+ sdkVersion: (_this_sdkVersion = this.sdkVersion) != null ? _this_sdkVersion : '',
219
+ instanceId: this.instanceId,
220
+ chainName: this.chainName
221
+ });
222
+ reject(new Error('Iframe load timeout due to no handshake message from iframe, this could be network issues, incorrect iframe domain, or CORS errors that prevents iframe from being loaded or sending handshake message. A retry will be attempted to load the iframe with wallet interaction function calls.'));
223
+ }, this.iframeLoadTimeout);
193
224
  iframe.style.display = 'none';
194
225
  iframe.setAttribute('title', 'Dynamic Wallet Iframe');
195
226
  iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-downloads');
@@ -201,28 +232,45 @@ class DynamicWalletClient {
201
232
  iframe.style.height = '0';
202
233
  iframe.style.border = 'none';
203
234
  iframe.style.pointerEvents = 'none';
204
- var _this_instanceId;
235
+ var _this_instanceId, _this_sdkVersion1;
205
236
  const params = new URLSearchParams({
206
237
  instanceId: (_this_instanceId = this.instanceId) != null ? _this_instanceId : '',
207
238
  hostOrigin: window.location.origin,
208
239
  environmentId: this.environmentId,
209
240
  baseApiUrl: this.baseApiUrl,
210
- baseMPCRelayApiUrl: this.baseMPCRelayApiUrl
241
+ baseMPCRelayApiUrl: this.baseMPCRelayApiUrl,
242
+ sdkVersion: (_this_sdkVersion1 = this.sdkVersion) != null ? _this_sdkVersion1 : ''
211
243
  });
212
244
  iframe.src = `${this.iframeDomain}/waas-v1/${this.environmentId}?${params.toString()}`;
213
245
  this.logger.debug('Creating iframe with src:', iframe.src);
214
246
  document.body.appendChild(iframe);
215
247
  iframe.onload = ()=>{
216
- clearTimeout(iframeTimeoutId);
217
- DynamicWalletClient.sharedIframe = iframe;
218
- this.iframe = iframe;
219
- DynamicWalletClient.iframeInstanceCount++;
220
- resolve();
248
+ // Listen for handshake
249
+ const onMessage = (event)=>{
250
+ if (event.source === iframe.contentWindow && event.data === `iframe-ready-${this.instanceId}`) {
251
+ window.removeEventListener('message', onMessage);
252
+ clearTimeout(iframeTimeoutId);
253
+ DynamicWalletClient.sharedIframe = iframe;
254
+ this.iframe = iframe;
255
+ DynamicWalletClient.iframeInstanceCount++;
256
+ resolve();
257
+ var _this_sdkVersion;
258
+ this.logger.info('Iframe loaded successfully...', {
259
+ iframeDomain: this.iframeDomain,
260
+ environmentId: this.environmentId,
261
+ sdkVersion: (_this_sdkVersion = this.sdkVersion) != null ? _this_sdkVersion : '',
262
+ instanceId: this.instanceId,
263
+ chainName: this.chainName
264
+ });
265
+ }
266
+ };
267
+ window.addEventListener('message', onMessage);
221
268
  };
222
269
  iframe.onerror = (error)=>{
223
270
  clearTimeout(iframeTimeoutId);
224
- this.logger.error('Iframe failed to load:', error);
225
- reject(new Error('Failed to load iframe'));
271
+ this.logger.error('Iframe failed to load due to errors: ', error);
272
+ this.resetSharedIframe();
273
+ reject(new Error('Failed to load iframe due to unknown load errors, this is likely a browser or network issue.'));
226
274
  };
227
275
  });
228
276
  return DynamicWalletClient.iframeLoadPromise;
@@ -233,38 +281,71 @@ class DynamicWalletClient {
233
281
  * @returns {Promise<HTMLIFrameElement>} that resolves when the iframe is loaded
234
282
  */ loadIframeForContainer(container) {
235
283
  return new Promise((resolve, reject)=>{
284
+ var _this_sdkVersion;
285
+ this.logger.info(`Loading iframe for container...`, {
286
+ iframeDomain: this.iframeDomain,
287
+ environmentId: this.environmentId,
288
+ sdkVersion: (_this_sdkVersion = this.sdkVersion) != null ? _this_sdkVersion : '',
289
+ instanceId: this.instanceId,
290
+ chainName: this.chainName
291
+ });
236
292
  const iframe = document.createElement('iframe');
237
293
  const iframeTimeoutId = setTimeout(()=>{
238
- reject(new Error('Iframe load timeout'));
239
- }, 10000);
294
+ var _this_sdkVersion;
295
+ this.logger.error('Iframe load timeout due to no handshake message from iframe, this could be network issues, incorrect iframe domain, or CORS errors that prevents iframe from being loaded or sending handshake message.', {
296
+ iframeDomain: this.iframeDomain,
297
+ environmentId: this.environmentId,
298
+ sdkVersion: (_this_sdkVersion = this.sdkVersion) != null ? _this_sdkVersion : '',
299
+ instanceId: this.instanceId,
300
+ chainName: this.chainName
301
+ });
302
+ reject(new Error('Iframe load timeout due to no handshake message from iframe, this could be network issues, incorrect iframe domain, or CORS errors that prevents iframe from being loaded or sending handshake message.'));
303
+ }, this.iframeLoadTimeout);
240
304
  iframe.style.display = 'block';
241
305
  iframe.style.width = '100%';
242
306
  iframe.style.height = '100%';
243
307
  iframe.setAttribute('title', 'Dynamic Wallet Storage');
244
308
  iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin');
245
309
  iframe.setAttribute('referrerpolicy', 'origin');
246
- var _this_instanceId;
310
+ var _this_instanceId, _this_sdkVersion1;
247
311
  const params = new URLSearchParams({
248
312
  instanceId: (_this_instanceId = this.instanceId) != null ? _this_instanceId : '',
249
313
  hostOrigin: window.location.origin,
250
314
  environmentId: this.environmentId,
251
315
  baseApiUrl: this.baseApiUrl,
252
316
  baseMPCRelayApiUrl: this.baseMPCRelayApiUrl,
253
- chain: this.chainName
317
+ sdkVersion: (_this_sdkVersion1 = this.sdkVersion) != null ? _this_sdkVersion1 : ''
254
318
  });
255
319
  iframe.src = `${this.iframeDomain}/waas-v1/${this.environmentId}?${params.toString()}`;
256
320
  this.logger.debug('Creating iframe with src:', iframe.src);
257
321
  // Add iframe to the provided container
258
322
  container.appendChild(iframe);
259
323
  iframe.onload = ()=>{
260
- clearTimeout(iframeTimeoutId);
261
- this.logger.debug('Iframe loaded successfully');
262
- resolve(iframe);
324
+ // Listen for handshake
325
+ const onMessage = (event)=>{
326
+ if (event.source === iframe.contentWindow && event.data === `iframe-ready-${this.instanceId}`) {
327
+ window.removeEventListener('message', onMessage);
328
+ clearTimeout(iframeTimeoutId);
329
+ DynamicWalletClient.sharedIframe = iframe;
330
+ this.iframe = iframe;
331
+ DynamicWalletClient.iframeInstanceCount++;
332
+ resolve(iframe);
333
+ var _this_sdkVersion;
334
+ this.logger.info('Iframe loaded successfully...', {
335
+ iframeDomain: this.iframeDomain,
336
+ environmentId: this.environmentId,
337
+ sdkVersion: (_this_sdkVersion = this.sdkVersion) != null ? _this_sdkVersion : '',
338
+ instanceId: this.instanceId,
339
+ chainName: this.chainName
340
+ });
341
+ }
342
+ };
343
+ window.addEventListener('message', onMessage);
263
344
  };
264
345
  iframe.onerror = (error)=>{
265
346
  clearTimeout(iframeTimeoutId);
266
- this.logger.error('Iframe failed to load:', error);
267
- reject(new Error('Failed to load iframe'));
347
+ this.logger.error('Iframe failed to load due to errors: ', error);
348
+ reject(new Error('Failed to load iframe due to unknown load errors, this is likely a browser or network issue.'));
268
349
  };
269
350
  });
270
351
  }
@@ -308,7 +389,7 @@ class DynamicWalletClient {
308
389
  chainName: this.chainName
309
390
  });
310
391
  }
311
- async getWallet({ accountAddress, walletOperation = core.WalletOperation.NO_OPERATION, signedSessionId }) {
392
+ async getWallet({ accountAddress, walletOperation = core.WalletOperation.NO_OPERATION, signedSessionId, authToken }) {
312
393
  await this.initializeMessageTransport();
313
394
  if (!this.iframeMessageHandler) {
314
395
  throw new Error('Iframe message handler not initialized');
@@ -317,10 +398,11 @@ class DynamicWalletClient {
317
398
  chainName: this.chainName,
318
399
  accountAddress,
319
400
  walletOperation,
320
- signedSessionId
401
+ signedSessionId,
402
+ authToken
321
403
  });
322
404
  }
323
- async createWalletAccount({ thresholdSignatureScheme, password = undefined, signedSessionId }) {
405
+ async createWalletAccount({ thresholdSignatureScheme, password = undefined, signedSessionId, authToken }) {
324
406
  await this.initializeMessageTransport();
325
407
  if (!this.iframeMessageHandler) {
326
408
  throw new Error('Iframe message handler not initialized');
@@ -329,10 +411,11 @@ class DynamicWalletClient {
329
411
  chainName: this.chainName,
330
412
  thresholdSignatureScheme,
331
413
  password,
332
- signedSessionId
414
+ signedSessionId,
415
+ authToken
333
416
  });
334
417
  }
335
- async requiresPasswordForOperation({ accountAddress, walletOperation = core.WalletOperation.REACH_THRESHOLD }) {
418
+ async requiresPasswordForOperation({ accountAddress, walletOperation = core.WalletOperation.REACH_THRESHOLD, authToken }) {
336
419
  await this.initializeMessageTransport();
337
420
  if (!this.iframeMessageHandler) {
338
421
  throw new Error('Iframe message handler not initialized');
@@ -340,20 +423,22 @@ class DynamicWalletClient {
340
423
  return this.iframeMessageHandler.requiresPasswordForOperation({
341
424
  chainName: this.chainName,
342
425
  accountAddress,
343
- walletOperation
426
+ walletOperation,
427
+ authToken
344
428
  });
345
429
  }
346
- async isPasswordEncrypted({ accountAddress }) {
430
+ async isPasswordEncrypted({ accountAddress, authToken }) {
347
431
  await this.initializeMessageTransport();
348
432
  if (!this.iframeMessageHandler) {
349
433
  throw new Error('Iframe message handler not initialized');
350
434
  }
351
435
  return this.iframeMessageHandler.isPasswordEncrypted({
352
436
  chainName: this.chainName,
353
- accountAddress
437
+ accountAddress,
438
+ authToken
354
439
  });
355
440
  }
356
- async signMessage({ message, accountAddress, password = undefined, signedSessionId }) {
441
+ async signMessage({ message, accountAddress, password = undefined, signedSessionId, authToken }) {
357
442
  await this.initializeMessageTransport();
358
443
  if (!this.iframeMessageHandler) {
359
444
  throw new Error('Iframe message handler not initialized');
@@ -363,10 +448,11 @@ class DynamicWalletClient {
363
448
  message,
364
449
  accountAddress,
365
450
  password,
366
- signedSessionId
451
+ signedSessionId,
452
+ authToken
367
453
  });
368
454
  }
369
- async signRawMessage({ message, accountAddress, password = undefined, signedSessionId }) {
455
+ async signRawMessage({ message, accountAddress, password = undefined, signedSessionId, authToken }) {
370
456
  await this.initializeMessageTransport();
371
457
  if (!this.iframeMessageHandler) {
372
458
  throw new Error('Iframe message handler not initialized');
@@ -376,7 +462,8 @@ class DynamicWalletClient {
376
462
  message,
377
463
  accountAddress,
378
464
  password,
379
- signedSessionId
465
+ signedSessionId,
466
+ authToken
380
467
  });
381
468
  }
382
469
  /**
@@ -389,7 +476,7 @@ class DynamicWalletClient {
389
476
  * SUI:
390
477
  * const txBytes = await txb.build({ client });
391
478
  * const txString = Buffer.from(txBytes).toString("hex");
392
- */ async signTransaction({ senderAddress, transaction, password = undefined, signedSessionId }) {
479
+ */ async signTransaction({ senderAddress, transaction, password = undefined, signedSessionId, authToken }) {
393
480
  await this.initializeMessageTransport();
394
481
  if (!this.iframeMessageHandler) {
395
482
  throw new Error('Iframe message handler not initialized');
@@ -399,10 +486,24 @@ class DynamicWalletClient {
399
486
  senderAddress,
400
487
  transaction,
401
488
  password,
489
+ signedSessionId,
490
+ authToken
491
+ });
492
+ }
493
+ async signTypedData({ accountAddress, typedData, password = undefined, signedSessionId }) {
494
+ await this.initializeMessageTransport();
495
+ if (!this.iframeMessageHandler) {
496
+ throw new Error('Iframe message handler not initialized');
497
+ }
498
+ return this.iframeMessageHandler.signTypedData({
499
+ chainName: this.chainName,
500
+ accountAddress,
501
+ typedData: JSON.stringify(typedData),
502
+ password,
402
503
  signedSessionId
403
504
  });
404
505
  }
405
- async backupKeySharesToGoogleDrive({ accountAddress, password = undefined, signedSessionId }) {
506
+ async backupKeySharesToGoogleDrive({ accountAddress, password = undefined, signedSessionId, authToken }) {
406
507
  await this.initializeMessageTransport();
407
508
  if (!this.iframeMessageHandler) {
408
509
  throw new Error('Iframe message handler not initialized');
@@ -411,10 +512,11 @@ class DynamicWalletClient {
411
512
  chainName: this.chainName,
412
513
  accountAddress,
413
514
  password,
414
- signedSessionId
515
+ signedSessionId,
516
+ authToken
415
517
  });
416
518
  }
417
- async restoreBackupFromGoogleDrive({ accountAddress, displayContainer, password, signedSessionId }) {
519
+ async restoreBackupFromGoogleDrive({ accountAddress, displayContainer, password, signedSessionId, authToken }) {
418
520
  const { iframeDisplay } = await this.initializeIframeDisplayForContainer({
419
521
  container: displayContainer
420
522
  });
@@ -425,10 +527,11 @@ class DynamicWalletClient {
425
527
  chainName: this.chainName,
426
528
  accountAddress,
427
529
  password,
428
- signedSessionId
530
+ signedSessionId,
531
+ authToken
429
532
  });
430
533
  }
431
- async refreshWalletAccountShares({ accountAddress, password, signedSessionId }) {
534
+ async refreshWalletAccountShares({ accountAddress, password, signedSessionId, authToken }) {
432
535
  await this.initializeMessageTransport();
433
536
  if (!this.iframeMessageHandler) {
434
537
  throw new Error('Iframe message handler not initialized');
@@ -437,10 +540,11 @@ class DynamicWalletClient {
437
540
  chainName: this.chainName,
438
541
  accountAddress: accountAddress,
439
542
  password: password,
440
- signedSessionId
543
+ signedSessionId,
544
+ authToken
441
545
  });
442
546
  }
443
- async reshare({ accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password, signedSessionId }) {
547
+ async reshare({ accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password, signedSessionId, authToken }) {
444
548
  await this.initializeMessageTransport();
445
549
  if (!this.iframeMessageHandler) {
446
550
  throw new Error('Iframe message handler not initialized');
@@ -451,10 +555,11 @@ class DynamicWalletClient {
451
555
  oldThresholdSignatureScheme,
452
556
  newThresholdSignatureScheme,
453
557
  password,
454
- signedSessionId
558
+ signedSessionId,
559
+ authToken
455
560
  });
456
561
  }
457
- async exportPrivateKey({ accountAddress, displayContainer, password, signedSessionId }) {
562
+ async exportPrivateKey({ accountAddress, displayContainer, password, signedSessionId, authToken }) {
458
563
  const { iframeDisplay } = await this.initializeIframeDisplayForContainer({
459
564
  container: displayContainer
460
565
  });
@@ -465,10 +570,11 @@ class DynamicWalletClient {
465
570
  chainName: this.chainName,
466
571
  accountAddress,
467
572
  password,
468
- signedSessionId
573
+ signedSessionId,
574
+ authToken
469
575
  });
470
576
  }
471
- async verifyPassword({ accountAddress, password, walletOperation = core.WalletOperation.NO_OPERATION, signedSessionId }) {
577
+ async verifyPassword({ accountAddress, password, walletOperation = core.WalletOperation.NO_OPERATION, signedSessionId, authToken }) {
472
578
  await this.initializeMessageTransport();
473
579
  if (!this.iframeMessageHandler) {
474
580
  throw new Error('Iframe message handler not initialized');
@@ -478,10 +584,11 @@ class DynamicWalletClient {
478
584
  accountAddress,
479
585
  password,
480
586
  walletOperation,
481
- signedSessionId
587
+ signedSessionId,
588
+ authToken
482
589
  });
483
590
  }
484
- async updatePassword({ accountAddress, existingPassword, newPassword, signedSessionId }) {
591
+ async updatePassword({ accountAddress, existingPassword, newPassword, signedSessionId, authToken }) {
485
592
  await this.initializeMessageTransport();
486
593
  if (!this.iframeMessageHandler) {
487
594
  throw new Error('Iframe message handler not initialized');
@@ -491,10 +598,11 @@ class DynamicWalletClient {
491
598
  accountAddress,
492
599
  existingPassword,
493
600
  newPassword,
494
- signedSessionId
601
+ signedSessionId,
602
+ authToken
495
603
  });
496
604
  }
497
- async importPrivateKey({ privateKey, thresholdSignatureScheme, signedSessionId }) {
605
+ async importPrivateKey({ privateKey, thresholdSignatureScheme, signedSessionId, authToken }) {
498
606
  await this.initializeMessageTransport();
499
607
  if (!this.iframeMessageHandler) {
500
608
  throw new Error('Iframe message handler not initialized');
@@ -503,10 +611,11 @@ class DynamicWalletClient {
503
611
  chainName: this.chainName,
504
612
  privateKey,
505
613
  thresholdSignatureScheme,
506
- signedSessionId
614
+ signedSessionId,
615
+ authToken
507
616
  });
508
617
  }
509
- async exportClientKeyshares({ accountAddress, password, signedSessionId }) {
618
+ async exportClientKeyshares({ accountAddress, password, signedSessionId, authToken }) {
510
619
  await this.initializeMessageTransport();
511
620
  if (!this.iframeMessageHandler) {
512
621
  throw new Error('Iframe message handler not initialized');
@@ -515,7 +624,8 @@ class DynamicWalletClient {
515
624
  chainName: this.chainName,
516
625
  accountAddress,
517
626
  password,
518
- signedSessionId
627
+ signedSessionId,
628
+ authToken
519
629
  });
520
630
  }
521
631
  /**
@@ -554,18 +664,20 @@ class DynamicWalletClient {
554
664
  this.iframe = null;
555
665
  }
556
666
  }
557
- constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, chainName, debug }){
667
+ constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, chainName, sdkVersion, debug }){
558
668
  this.logger = logger;
559
669
  this.instanceId = null;
560
670
  this.iframeDomain = null;
561
671
  this.messageTransport = null;
562
672
  this.iframeMessageHandler = null;
563
673
  this.iframe = null;
674
+ this.iframeLoadTimeout = 10000;
564
675
  this.environmentId = environmentId;
565
676
  this.authToken = authToken;
566
677
  this.baseApiUrl = baseApiUrl;
567
678
  this.baseMPCRelayApiUrl = baseMPCRelayApiUrl;
568
679
  this.chainName = chainName;
680
+ this.sdkVersion = sdkVersion;
569
681
  const environment = core.getEnvironmentFromUrl(baseApiUrl);
570
682
  this.iframeDomain = core.IFRAME_DOMAIN_MAP[environment];
571
683
  // Generate unique instanceId when client is created