@dynamic-labs-wallet/browser 0.0.97 → 0.0.98

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.esm.js CHANGED
@@ -2,6 +2,7 @@ import { SigningAlgorithm, MPC_RELAY_PROD_API_URL, getMPCChainConfig, BackupLoca
2
2
  export * from '@dynamic-labs-wallet/core';
3
3
  import { BIP340, ExportableEd25519, Ecdsa, MessageHash, EcdsaKeygenResult, ExportableEd25519KeygenResult, BIP340KeygenResult } from './internal/web';
4
4
  export { BIP340, BIP340InitKeygenResult, BIP340KeygenResult, Ecdsa, EcdsaInitKeygenResult, EcdsaKeygenResult, EcdsaPublicKey, EcdsaSignature, Ed25519, Ed25519InitKeygenResult, Ed25519KeygenResult, MessageHash } from './internal/web';
5
+ import jwt from 'jsonwebtoken';
5
6
  import { LogLevel, Logger } from '@dynamic-labs/logger';
6
7
  import { ProviderEnum } from '@dynamic-labs/sdk-api-core';
7
8
  import { AxiosError } from 'axios';
@@ -43,9 +44,52 @@ const DEFAULT_LOG_LEVEL = LogLevel.DEBUG; //todo: change back to info when done
43
44
  const STORAGE_KEY = 'dynamic-waas-wallet-client';
44
45
  const CLIENT_KEYSHARE_EXPORT_FILENAME_PREFIX = 'dynamicWalletKeyShareBackup';
45
46
 
47
+ const handleAxiosError = (error, message, context)=>{
48
+ var _error_response, _error_response1;
49
+ logger.debug("[DynamicWaasWalletClient] Axios error: " + message, {
50
+ error: (_error_response = error.response) == null ? void 0 : _error_response.status,
51
+ message: error.message,
52
+ context
53
+ });
54
+ switch((_error_response1 = error.response) == null ? void 0 : _error_response1.status){
55
+ case 400:
56
+ throw createHttpError(400, 'Invalid request');
57
+ case 401:
58
+ throw createHttpError(401, 'Authorization header or cookie is required');
59
+ case 403:
60
+ throw createHttpError(403, 'Forbidden');
61
+ case 422:
62
+ throw createHttpError(422, 'Unprocessable content');
63
+ case 500:
64
+ throw createHttpError(500, 'Internal server error');
65
+ default:
66
+ throw createHttpError(500, 'Internal server error');
67
+ }
68
+ };
69
+
46
70
  const logger = new Logger('DynamicWaasWalletClient', LogLevel.DEBUG);
47
- const setLoggerEnvironmentId = (environmentId)=>{
48
- Logger.setEnvironmentId(environmentId);
71
+ const setLoggerContext = ({ environmentId, sessionId, userId, verifiedCredentials })=>{
72
+ try {
73
+ Logger.setEnvironmentId(environmentId);
74
+ Logger.globalMetaData.set('sid', sessionId);
75
+ Logger.globalMetaData.set('user_id', userId);
76
+ Logger.globalMetaData.set('verified_credentials', verifiedCredentials);
77
+ } catch (error) {
78
+ logError({
79
+ message: '[DynamicWaasWalletClient] Error setting logger context',
80
+ error: error,
81
+ context: {}
82
+ });
83
+ }
84
+ };
85
+ const logError = ({ message, error, context })=>{
86
+ if (error instanceof AxiosError) {
87
+ handleAxiosError(error, message, context);
88
+ }
89
+ logger.error(message, {
90
+ error: error instanceof Error ? error.message : 'Unknown error',
91
+ context
92
+ });
49
93
  };
50
94
 
51
95
  const bytesToBase64 = (arr)=>{
@@ -429,29 +473,6 @@ const downloadFileFromGoogleDrive = async ({ accessToken, fileName })=>{
429
473
  }
430
474
  };
431
475
 
432
- const handleAxiosError = (error, message, context)=>{
433
- var _error_response, _error_response1;
434
- logger.debug("[DynamicWaasWalletClient] Axios error: " + message, {
435
- error: (_error_response = error.response) == null ? void 0 : _error_response.status,
436
- message: error.message,
437
- context
438
- });
439
- switch((_error_response1 = error.response) == null ? void 0 : _error_response1.status){
440
- case 400:
441
- throw createHttpError(400, 'Invalid request');
442
- case 401:
443
- throw createHttpError(401, 'Authorization header or cookie is required');
444
- case 403:
445
- throw createHttpError(403, 'Forbidden');
446
- case 422:
447
- throw createHttpError(422, 'Unprocessable content');
448
- case 500:
449
- throw createHttpError(500, 'Internal server error');
450
- default:
451
- throw createHttpError(500, 'Internal server error');
452
- }
453
- };
454
-
455
476
  const localStorageWriteTest = {
456
477
  tested: false,
457
478
  writable: false
@@ -522,11 +543,34 @@ const localStorageWriteTest = {
522
543
  });
523
544
 
524
545
  class DynamicWalletClient {
546
+ async initLoggerContext(authToken) {
547
+ try {
548
+ const payload = jwt.decode(authToken);
549
+ if (!payload || typeof payload !== 'object') {
550
+ throw new Error('Invalid JWT payload');
551
+ }
552
+ const userId = payload['sub'];
553
+ const sessionId = payload['sid'];
554
+ const verifiedCredentials = payload['verified_credentials'];
555
+ setLoggerContext({
556
+ environmentId: this.environmentId,
557
+ sessionId,
558
+ userId: userId || 'unknown',
559
+ verifiedCredentials
560
+ });
561
+ } catch (error) {
562
+ logError({
563
+ message: '[DynamicWaasWalletClient] Error initializing auth token',
564
+ error: error,
565
+ context: {}
566
+ });
567
+ throw error;
568
+ }
569
+ }
525
570
  async initialize() {
526
571
  if (this.initializePromise) {
527
572
  return await this.initializePromise;
528
573
  }
529
- setLoggerEnvironmentId(this.environmentId);
530
574
  this.logger.debug('[DynamicWaasWalletClient] Initializing Dynamic Waas Wallet SDK');
531
575
  this.initializePromise = this._initialize();
532
576
  const result = await this.initializePromise;
@@ -669,17 +713,13 @@ class DynamicWalletClient {
669
713
  clientKeyShares
670
714
  };
671
715
  } catch (error) {
672
- const message = '[DynamicWaasWalletClient] Error in keyGen';
673
- const context = {
674
- chainName,
675
- thresholdSignatureScheme
676
- };
677
- if (error instanceof AxiosError) {
678
- handleAxiosError(error, message, context);
679
- }
680
- this.logger.error(message, {
681
- error,
682
- context
716
+ logError({
717
+ message: '[DynamicWaasWalletClient] Error in keyGen',
718
+ error: error,
719
+ context: {
720
+ chainName,
721
+ thresholdSignatureScheme
722
+ }
683
723
  });
684
724
  throw error;
685
725
  }
@@ -750,17 +790,13 @@ class DynamicWalletClient {
750
790
  clientKeyShares: clientKeygenResults
751
791
  };
752
792
  } catch (error) {
753
- const message = '[DynamicWaasWalletClient] Error in importRawPrivateKey';
754
- const context = {
755
- chainName,
756
- thresholdSignatureScheme
757
- };
758
- if (error instanceof AxiosError) {
759
- handleAxiosError(error, message, context);
760
- }
761
- this.logger.error(message, {
762
- error,
763
- context
793
+ logError({
794
+ message: '[DynamicWaasWalletClient] Error in importRawPrivateKey',
795
+ error: error,
796
+ context: {
797
+ chainName,
798
+ thresholdSignatureScheme
799
+ }
764
800
  });
765
801
  throw error;
766
802
  }
@@ -794,12 +830,15 @@ class DynamicWalletClient {
794
830
  const signature = await mpcSigner.sign(roomId, keyShare, formattedMessage, derivationPath);
795
831
  return signature;
796
832
  } catch (error) {
797
- this.logger.error('[DynamicWaasWalletClient] Error in clientSign', {
798
- error,
799
- chainName,
800
- roomId,
801
- derivationPath,
802
- isFormatted
833
+ logError({
834
+ message: '[DynamicWaasWalletClient] Error in clientSign',
835
+ error: error,
836
+ context: {
837
+ chainName,
838
+ roomId,
839
+ derivationPath,
840
+ isFormatted
841
+ }
803
842
  });
804
843
  throw error;
805
844
  }
@@ -853,18 +892,14 @@ class DynamicWalletClient {
853
892
  });
854
893
  return signature;
855
894
  } catch (error) {
856
- const message = '[DynamicWaasWalletClient] Error in sign';
857
- const context = {
858
- accountAddress,
859
- chainName,
860
- isFormatted: isFormatted ? 'true' : 'false'
861
- };
862
- if (error instanceof AxiosError) {
863
- handleAxiosError(error, message, context);
864
- }
865
- this.logger.error(message, {
866
- error,
867
- context
895
+ logError({
896
+ message: '[DynamicWaasWalletClient] Error in sign',
897
+ error: error,
898
+ context: {
899
+ accountAddress,
900
+ chainName,
901
+ isFormatted: isFormatted ? 'true' : 'false'
902
+ }
868
903
  });
869
904
  throw error;
870
905
  }
@@ -907,17 +942,13 @@ class DynamicWalletClient {
907
942
  signedSessionId
908
943
  });
909
944
  } catch (error) {
910
- const message = '[DynamicWaasWalletClient] Error in refreshWalletAccountShares';
911
- const context = {
912
- accountAddress,
913
- chainName
914
- };
915
- if (error instanceof AxiosError) {
916
- handleAxiosError(error, message, context);
917
- }
918
- this.logger.error(message, {
919
- error,
920
- context
945
+ logError({
946
+ message: '[DynamicWaasWalletClient] Error in refreshWalletAccountShares',
947
+ error: error,
948
+ context: {
949
+ accountAddress,
950
+ chainName
951
+ }
921
952
  });
922
953
  throw error;
923
954
  }
@@ -1042,19 +1073,16 @@ class DynamicWalletClient {
1042
1073
  backupToGoogleDrive
1043
1074
  });
1044
1075
  } catch (error) {
1045
- const message = '[DynamicWaasWalletClient] Error in reshare';
1046
- const context = {
1047
- accountAddress,
1048
- chainName,
1049
- oldThresholdSignatureScheme,
1050
- newThresholdSignatureScheme
1051
- };
1052
- if (error instanceof AxiosError) {
1053
- handleAxiosError(error, message, context);
1054
- }
1055
- this.logger.error(message, {
1056
- error,
1057
- context
1076
+ logError({
1077
+ message: '[DynamicWaasWalletClient] Error in reshare',
1078
+ error: error,
1079
+ context: {
1080
+ accountAddress,
1081
+ chainName,
1082
+ oldThresholdSignatureScheme,
1083
+ newThresholdSignatureScheme,
1084
+ backupToGoogleDrive
1085
+ }
1058
1086
  });
1059
1087
  throw error;
1060
1088
  }
@@ -1113,17 +1141,13 @@ class DynamicWalletClient {
1113
1141
  derivedPrivateKey
1114
1142
  };
1115
1143
  } catch (error) {
1116
- const message = '[DynamicWaasWalletClient] Error in exportKey';
1117
- const context = {
1118
- accountAddress,
1119
- chainName
1120
- };
1121
- if (error instanceof AxiosError) {
1122
- handleAxiosError(error, message, context);
1123
- }
1124
- this.logger.error(message, {
1125
- error,
1126
- context
1144
+ logError({
1145
+ message: '[DynamicWaasWalletClient] Error in exportKey',
1146
+ error: error,
1147
+ context: {
1148
+ accountAddress,
1149
+ chainName
1150
+ }
1127
1151
  });
1128
1152
  throw error;
1129
1153
  }
@@ -1164,7 +1188,13 @@ class DynamicWalletClient {
1164
1188
  rawPublicKey
1165
1189
  };
1166
1190
  } catch (error) {
1167
- this.logger.error('[DynamicWaasWalletClient] Error in offlineExportKey', error);
1191
+ logError({
1192
+ message: '[DynamicWaasWalletClient] Error in offlineExportKey',
1193
+ error: error,
1194
+ context: {
1195
+ chainName
1196
+ }
1197
+ });
1168
1198
  throw error;
1169
1199
  }
1170
1200
  }
@@ -1196,7 +1226,13 @@ class DynamicWalletClient {
1196
1226
  }
1197
1227
  return (parsedWalletObject == null ? void 0 : parsedWalletObject.clientKeyShares) || [];
1198
1228
  } catch (error) {
1199
- this.logger.error(`[DynamicWaasWalletClient] Error parsing clientKeyShares: ${error} for accountAddress: ${accountAddress}`);
1229
+ logError({
1230
+ message: `[DynamicWaasWalletClient] Error parsing clientKeyShares: ${error} for accountAddress: ${accountAddress}`,
1231
+ error: error,
1232
+ context: {
1233
+ accountAddress
1234
+ }
1235
+ });
1200
1236
  return [];
1201
1237
  }
1202
1238
  }
@@ -1244,13 +1280,16 @@ class DynamicWalletClient {
1244
1280
  accountAddress
1245
1281
  });
1246
1282
  if (!((_this_walletMap_accountAddress = this.walletMap[accountAddress]) == null ? void 0 : _this_walletMap_accountAddress.walletId)) {
1247
- this.logger.error('[DynamicWaasWalletClient] Error in storeEncryptedBackupByWallet, wallet or walletId not found from the wallet map', {
1283
+ const error = new Error(`WalletId not found for accountAddress ${accountAddress}`);
1284
+ logError({
1285
+ message: '[DynamicWaasWalletClient] Error in storeEncryptedBackupByWallet, wallet or walletId not found from the wallet map',
1286
+ error,
1248
1287
  context: {
1249
1288
  accountAddress,
1250
1289
  walletMap: this.walletMap
1251
1290
  }
1252
1291
  });
1253
- throw new Error(`WalletId not found for accountAddress ${accountAddress}`);
1292
+ throw error;
1254
1293
  }
1255
1294
  // TODO(zfaizal2): throw error if signedSessionId is not provided after service deploy
1256
1295
  let dynamicClientKeyShares = [];
@@ -1306,16 +1345,12 @@ class DynamicWalletClient {
1306
1345
  await this.storage.setItem(this.storageKey, JSON.stringify(this.walletMap));
1307
1346
  return data;
1308
1347
  } catch (error) {
1309
- const message = '[DynamicWaasWalletClient] Error in storeEncryptedBackupByWallet';
1310
- const context = {
1311
- accountAddress
1312
- };
1313
- if (error instanceof AxiosError) {
1314
- handleAxiosError(error, message, context);
1315
- }
1316
- this.logger.error(message, {
1317
- error: error instanceof Error ? error.message : 'Unknown error',
1318
- context
1348
+ logError({
1349
+ message: '[DynamicWaasWalletClient] Error in storeEncryptedBackupByWallet',
1350
+ error: error,
1351
+ context: {
1352
+ accountAddress
1353
+ }
1319
1354
  });
1320
1355
  throw error;
1321
1356
  }
@@ -1365,23 +1400,25 @@ class DynamicWalletClient {
1365
1400
  const user = await this.apiClient.getUser();
1366
1401
  const oauthAccountId = getGoogleOAuthAccountId(user == null ? void 0 : user.verifiedCredentials);
1367
1402
  if (!oauthAccountId) {
1368
- this.logger.error('No Google OAuth account ID found', {
1369
- user,
1370
- accountAddress
1403
+ const error = new Error('No Google OAuth account ID found');
1404
+ logError({
1405
+ message: 'No Google OAuth account ID found',
1406
+ error,
1407
+ context: {
1408
+ user,
1409
+ accountAddress
1410
+ }
1371
1411
  });
1372
- throw new Error('No Google OAuth account ID found');
1412
+ throw error;
1373
1413
  }
1374
1414
  return oauthAccountId;
1375
1415
  } catch (error) {
1376
- const message = '[DynamicWaasWalletClient] Error in getGoogleOauthAccountIdOrThrow';
1377
- if (error instanceof AxiosError) {
1378
- handleAxiosError(error, message, {
1416
+ logError({
1417
+ message: '[DynamicWaasWalletClient] Error in getGoogleOauthAccountIdOrThrow',
1418
+ error: error,
1419
+ context: {
1379
1420
  accountAddress
1380
- });
1381
- }
1382
- this.logger.error(message, {
1383
- error,
1384
- accountAddress
1421
+ }
1385
1422
  });
1386
1423
  throw error;
1387
1424
  }
@@ -1444,21 +1481,14 @@ class DynamicWalletClient {
1444
1481
  }
1445
1482
  return decryptedKeyShares;
1446
1483
  } catch (error) {
1447
- const message = '[DynamicWaasWalletClient] Error in recoverEncryptedBackupByWallet';
1448
- const context = {
1449
- accountAddress,
1450
- password,
1451
- walletOperation,
1452
- signedSessionId,
1453
- shareCount,
1454
- storeRecoveredShares
1455
- };
1456
- if (error instanceof AxiosError) {
1457
- handleAxiosError(error, message, context);
1458
- }
1459
- this.logger.error(message, {
1460
- error,
1461
- context
1484
+ logError({
1485
+ message: '[DynamicWaasWalletClient] Error in recoverEncryptedBackupByWallet',
1486
+ error: error,
1487
+ context: {
1488
+ accountAddress,
1489
+ walletOperation,
1490
+ shareCount
1491
+ }
1462
1492
  });
1463
1493
  throw error;
1464
1494
  }
@@ -1515,13 +1545,13 @@ class DynamicWalletClient {
1515
1545
  return googleDriveKeyShares.map((ks)=>ks.id);
1516
1546
  }
1517
1547
  } catch (error) {
1518
- this.logger.error('[DynamicWaasWalletClient]: Error in backupKeySharesToGoogleDrive', error);
1519
- if (error instanceof AxiosError) {
1520
- const message = '[DynamicWaasWalletClient] Error in backupKeySharesToGoogleDrive';
1521
- handleAxiosError(error, message, {
1548
+ logError({
1549
+ message: '[DynamicWaasWalletClient] Error in backupKeySharesToGoogleDrive',
1550
+ error: error,
1551
+ context: {
1522
1552
  accountAddress
1523
- });
1524
- }
1553
+ }
1554
+ });
1525
1555
  throw error;
1526
1556
  }
1527
1557
  }
@@ -1573,16 +1603,12 @@ class DynamicWalletClient {
1573
1603
  });
1574
1604
  return data.keyShares.map((ks)=>ks.id);
1575
1605
  } catch (error) {
1576
- const message = '[DynamicWaasWalletClient] Error in backupKeySharesToGoogleDrive';
1577
- const context = {
1578
- accountAddress
1579
- };
1580
- if (error instanceof AxiosError) {
1581
- handleAxiosError(error, message, context);
1582
- }
1583
- this.logger.error(message, {
1584
- error,
1585
- context
1606
+ logError({
1607
+ message: '[DynamicWaasWalletClient] Error in backupKeySharesToGoogleDrive',
1608
+ error: error,
1609
+ context: {
1610
+ accountAddress
1611
+ }
1586
1612
  });
1587
1613
  throw error;
1588
1614
  }
@@ -1609,27 +1635,40 @@ class DynamicWalletClient {
1609
1635
  fileName
1610
1636
  }));
1611
1637
  } catch (error) {
1612
- this.logger.error('[DynamicWaasWalletClient] Failed to download backup from Google Drive', {
1613
- accountAddress,
1614
- fileName,
1615
- error
1638
+ logError({
1639
+ message: '[DynamicWaasWalletClient] Failed to download backup from Google Drive',
1640
+ error: error,
1641
+ context: {
1642
+ accountAddress,
1643
+ fileName
1644
+ }
1616
1645
  });
1617
- throw new Error('Failed to restore backup from Google Drive');
1646
+ throw error;
1618
1647
  }
1619
1648
  if (!backupData) {
1620
- this.logger.error('[DynamicWaasWalletClient] No backup file found', {
1621
- accountAddress,
1622
- fileName
1649
+ const error = new Error('No backup file found');
1650
+ logError({
1651
+ message: '[DynamicWaasWalletClient] No backup file found',
1652
+ error: new Error('No backup file found'),
1653
+ context: {
1654
+ accountAddress,
1655
+ fileName
1656
+ }
1623
1657
  });
1624
- throw new Error('No backup file found');
1658
+ throw error;
1625
1659
  }
1626
1660
  // Validate the backup data structure
1627
1661
  if (!backupData.keyShares || !backupData.metadata) {
1628
- this.logger.error('[DynamicWaasWalletClient] Invalid backup format: missing keyShares or metadata', {
1629
- accountAddress,
1630
- fileName
1662
+ const error = new Error('Invalid backup format: missing keyShares or metadata');
1663
+ logError({
1664
+ message: '[DynamicWaasWalletClient] Invalid backup format: missing keyShares or metadata',
1665
+ error,
1666
+ context: {
1667
+ accountAddress,
1668
+ fileName
1669
+ }
1631
1670
  });
1632
- throw new Error('Invalid backup format: missing keyShares or metadata');
1671
+ throw error;
1633
1672
  }
1634
1673
  const { keyShares } = backupData;
1635
1674
  const decryptedKeyShares = await Promise.all(keyShares.map((keyShare)=>this.decryptKeyShare({
@@ -1643,16 +1682,12 @@ class DynamicWalletClient {
1643
1682
  });
1644
1683
  return decryptedKeyShares;
1645
1684
  } catch (error) {
1646
- const message = '[DynamicWaasWalletClient] Error in restoreBackupFromGoogleDrive';
1647
- const context = {
1648
- accountAddress
1649
- };
1650
- if (error instanceof AxiosError) {
1651
- handleAxiosError(error, message, context);
1652
- }
1653
- this.logger.error(message, {
1654
- error,
1655
- context
1685
+ logError({
1686
+ message: '[DynamicWaasWalletClient] Error in restoreBackupFromGoogleDrive',
1687
+ error: error,
1688
+ context: {
1689
+ accountAddress
1690
+ }
1656
1691
  });
1657
1692
  throw error;
1658
1693
  }
@@ -1779,8 +1814,14 @@ class DynamicWalletClient {
1779
1814
  signedSessionId
1780
1815
  });
1781
1816
  } catch (error) {
1782
- this.logger.error('Error in verifying password', error);
1783
- throw new Error('Incorrect password');
1817
+ logError({
1818
+ message: '[DynamicWaasWalletClient] Error in verifyPassword',
1819
+ error: error,
1820
+ context: {
1821
+ accountAddress
1822
+ }
1823
+ });
1824
+ throw error;
1784
1825
  }
1785
1826
  }
1786
1827
  async isPasswordEncrypted({ accountAddress }) {
@@ -1839,15 +1880,12 @@ class DynamicWalletClient {
1839
1880
  walletProperties: wallet == null ? void 0 : wallet.walletProperties
1840
1881
  });
1841
1882
  } catch (error) {
1842
- const message = '[DynamicWaasWalletClient] Error in getWalletClientKeyShareBackupInfo';
1843
- if (error instanceof AxiosError) {
1844
- handleAxiosError(error, message, {
1883
+ logError({
1884
+ message: '[DynamicWaasWalletClient] Error in getWalletClientKeyShareBackupInfo',
1885
+ error: error,
1886
+ context: {
1845
1887
  accountAddress
1846
- });
1847
- }
1848
- this.logger.error(message, {
1849
- error,
1850
- accountAddress
1888
+ }
1851
1889
  });
1852
1890
  throw error;
1853
1891
  }
@@ -1910,17 +1948,15 @@ class DynamicWalletClient {
1910
1948
  }
1911
1949
  return this.walletMap[accountAddress];
1912
1950
  } catch (error) {
1913
- const message = '[DynamicWaasWalletClient] Error in getWallet';
1914
- const context = {
1915
- accountAddress,
1916
- walletOperation,
1917
- shareCount,
1918
- password,
1919
- signedSessionId
1920
- };
1921
- if (error instanceof AxiosError) {
1922
- handleAxiosError(error, message, context);
1923
- }
1951
+ logError({
1952
+ message: '[DynamicWaasWalletClient] Error in getWallet',
1953
+ error: error,
1954
+ context: {
1955
+ accountAddress,
1956
+ walletOperation,
1957
+ shareCount
1958
+ }
1959
+ });
1924
1960
  throw error;
1925
1961
  }
1926
1962
  }
@@ -1958,12 +1994,10 @@ class DynamicWalletClient {
1958
1994
  }, {});
1959
1995
  return wallets;
1960
1996
  } catch (error) {
1961
- const message = '[DynamicWaasWalletClient] Error in getWallets';
1962
- if (error instanceof AxiosError) {
1963
- handleAxiosError(error, message, {});
1964
- }
1965
- this.logger.error(message, {
1966
- error
1997
+ logError({
1998
+ message: '[DynamicWaasWalletClient] Error in getWallets',
1999
+ error: error,
2000
+ context: {}
1967
2001
  });
1968
2002
  throw error;
1969
2003
  }
@@ -1996,13 +2030,15 @@ class DynamicWalletClient {
1996
2030
  this.iframeDomain = IFRAME_DOMAIN_MAP[environment];
1997
2031
  // Generate unique instanceId when client is created
1998
2032
  this.instanceId = crypto.randomUUID();
2033
+ // initialize logger context
2034
+ this.initLoggerContext(authToken);
1999
2035
  // initialize the client
2000
2036
  this.initialize();
2001
2037
  }
2002
2038
  }
2003
2039
 
2004
2040
  const ERROR_KEYGEN_FAILED = '[DynamicWaasWalletClient]: Error with keygen';
2005
- const ERROR_CREATE_WALLET_ACCOUNT = '[DynamicWaasWalletClient]: Error creating evm wallet account';
2041
+ const ERROR_CREATE_WALLET_ACCOUNT = '[DynamicWaasWalletClient]: Error creating wallet account';
2006
2042
  const ERROR_SIGN_MESSAGE = '[DynamicWaasWalletClient]: Error signing message';
2007
2043
  const ERROR_ACCOUNT_ADDRESS_REQUIRED = '[DynamicWaasWalletClient]: Account address is required';
2008
2044
  const ERROR_VERIFY_MESSAGE_SIGNATURE = '[DynamicWaasWalletClient]: Error verifying message signature';