@dynamic-labs-wallet/browser 0.0.97 → 0.0.99

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
@@ -43,9 +43,51 @@ const DEFAULT_LOG_LEVEL = logger$1.LogLevel.DEBUG; //todo: change back to info w
43
43
  const STORAGE_KEY = 'dynamic-waas-wallet-client';
44
44
  const CLIENT_KEYSHARE_EXPORT_FILENAME_PREFIX = 'dynamicWalletKeyShareBackup';
45
45
 
46
+ const handleAxiosError = (error, message, context)=>{
47
+ var _error_response, _error_response1;
48
+ logger.debug("[DynamicWaasWalletClient] Axios error: " + message, {
49
+ error: (_error_response = error.response) == null ? void 0 : _error_response.status,
50
+ message: error.message,
51
+ context
52
+ });
53
+ switch((_error_response1 = error.response) == null ? void 0 : _error_response1.status){
54
+ case 400:
55
+ throw createHttpError(400, 'Invalid request');
56
+ case 401:
57
+ throw createHttpError(401, 'Authorization header or cookie is required');
58
+ case 403:
59
+ throw createHttpError(403, 'Forbidden');
60
+ case 422:
61
+ throw createHttpError(422, 'Unprocessable content');
62
+ case 500:
63
+ throw createHttpError(500, 'Internal server error');
64
+ default:
65
+ throw createHttpError(500, 'Internal server error');
66
+ }
67
+ };
68
+
46
69
  const logger = new logger$1.Logger('DynamicWaasWalletClient', logger$1.LogLevel.DEBUG);
47
- const setLoggerEnvironmentId = (environmentId)=>{
48
- logger$1.Logger.setEnvironmentId(environmentId);
70
+ const setLoggerContext = ({ environmentId, sessionId, userId })=>{
71
+ try {
72
+ logger$1.Logger.setEnvironmentId(environmentId);
73
+ logger$1.Logger.globalMetaData.set('sid', sessionId);
74
+ logger$1.Logger.globalMetaData.set('user_id', userId);
75
+ } catch (error) {
76
+ logError({
77
+ message: '[DynamicWaasWalletClient] Error setting logger context',
78
+ error: error,
79
+ context: {}
80
+ });
81
+ }
82
+ };
83
+ const logError = ({ message, error, context })=>{
84
+ if (error instanceof axios.AxiosError) {
85
+ handleAxiosError(error, message, context);
86
+ }
87
+ logger.error(message, {
88
+ error: error instanceof Error ? error.message : 'Unknown error',
89
+ context
90
+ });
49
91
  };
50
92
 
51
93
  const bytesToBase64 = (arr)=>{
@@ -429,29 +471,6 @@ const downloadFileFromGoogleDrive = async ({ accessToken, fileName })=>{
429
471
  }
430
472
  };
431
473
 
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
474
  const localStorageWriteTest = {
456
475
  tested: false,
457
476
  writable: false
@@ -522,11 +541,42 @@ const localStorageWriteTest = {
522
541
  });
523
542
 
524
543
  class DynamicWalletClient {
544
+ async initLoggerContext(authToken) {
545
+ try {
546
+ // Split the JWT token into its parts (header.payload.signature)
547
+ const parts = authToken.split('.');
548
+ if (parts.length !== 3) {
549
+ logger.debug('[DynamicWaasWalletClient] Invalid JWT token when initializing logger context');
550
+ return;
551
+ }
552
+ // Decode the payload (second part)
553
+ const base64Payload = parts[1].replace(/-/g, '+').replace(/_/g, '/');
554
+ const jsonPayload = decodeURIComponent(Buffer.from(base64Payload, 'base64').toString('utf-8'));
555
+ const payload = JSON.parse(jsonPayload);
556
+ if (!payload || typeof payload !== 'object') {
557
+ logger.debug('[DynamicWaasWalletClient] Invalid JWT payload when initializing logger context');
558
+ return;
559
+ }
560
+ const userId = payload['sub'] || 'unknown';
561
+ const sessionId = payload['sid'] || 'unknown';
562
+ setLoggerContext({
563
+ environmentId: this.environmentId,
564
+ sessionId,
565
+ userId
566
+ });
567
+ } catch (error) {
568
+ logError({
569
+ message: '[DynamicWaasWalletClient] Error initializing logger context',
570
+ error: error,
571
+ context: {}
572
+ });
573
+ throw error;
574
+ }
575
+ }
525
576
  async initialize() {
526
577
  if (this.initializePromise) {
527
578
  return await this.initializePromise;
528
579
  }
529
- setLoggerEnvironmentId(this.environmentId);
530
580
  this.logger.debug('[DynamicWaasWalletClient] Initializing Dynamic Waas Wallet SDK');
531
581
  this.initializePromise = this._initialize();
532
582
  const result = await this.initializePromise;
@@ -669,17 +719,13 @@ class DynamicWalletClient {
669
719
  clientKeyShares
670
720
  };
671
721
  } catch (error) {
672
- const message = '[DynamicWaasWalletClient] Error in keyGen';
673
- const context = {
674
- chainName,
675
- thresholdSignatureScheme
676
- };
677
- if (error instanceof axios.AxiosError) {
678
- handleAxiosError(error, message, context);
679
- }
680
- this.logger.error(message, {
681
- error,
682
- context
722
+ logError({
723
+ message: '[DynamicWaasWalletClient] Error in keyGen',
724
+ error: error,
725
+ context: {
726
+ chainName,
727
+ thresholdSignatureScheme
728
+ }
683
729
  });
684
730
  throw error;
685
731
  }
@@ -750,17 +796,13 @@ class DynamicWalletClient {
750
796
  clientKeyShares: clientKeygenResults
751
797
  };
752
798
  } catch (error) {
753
- const message = '[DynamicWaasWalletClient] Error in importRawPrivateKey';
754
- const context = {
755
- chainName,
756
- thresholdSignatureScheme
757
- };
758
- if (error instanceof axios.AxiosError) {
759
- handleAxiosError(error, message, context);
760
- }
761
- this.logger.error(message, {
762
- error,
763
- context
799
+ logError({
800
+ message: '[DynamicWaasWalletClient] Error in importRawPrivateKey',
801
+ error: error,
802
+ context: {
803
+ chainName,
804
+ thresholdSignatureScheme
805
+ }
764
806
  });
765
807
  throw error;
766
808
  }
@@ -794,12 +836,15 @@ class DynamicWalletClient {
794
836
  const signature = await mpcSigner.sign(roomId, keyShare, formattedMessage, derivationPath);
795
837
  return signature;
796
838
  } catch (error) {
797
- this.logger.error('[DynamicWaasWalletClient] Error in clientSign', {
798
- error,
799
- chainName,
800
- roomId,
801
- derivationPath,
802
- isFormatted
839
+ logError({
840
+ message: '[DynamicWaasWalletClient] Error in clientSign',
841
+ error: error,
842
+ context: {
843
+ chainName,
844
+ roomId,
845
+ derivationPath,
846
+ isFormatted
847
+ }
803
848
  });
804
849
  throw error;
805
850
  }
@@ -853,18 +898,14 @@ class DynamicWalletClient {
853
898
  });
854
899
  return signature;
855
900
  } 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 axios.AxiosError) {
863
- handleAxiosError(error, message, context);
864
- }
865
- this.logger.error(message, {
866
- error,
867
- context
901
+ logError({
902
+ message: '[DynamicWaasWalletClient] Error in sign',
903
+ error: error,
904
+ context: {
905
+ accountAddress,
906
+ chainName,
907
+ isFormatted: isFormatted ? 'true' : 'false'
908
+ }
868
909
  });
869
910
  throw error;
870
911
  }
@@ -907,17 +948,13 @@ class DynamicWalletClient {
907
948
  signedSessionId
908
949
  });
909
950
  } catch (error) {
910
- const message = '[DynamicWaasWalletClient] Error in refreshWalletAccountShares';
911
- const context = {
912
- accountAddress,
913
- chainName
914
- };
915
- if (error instanceof axios.AxiosError) {
916
- handleAxiosError(error, message, context);
917
- }
918
- this.logger.error(message, {
919
- error,
920
- context
951
+ logError({
952
+ message: '[DynamicWaasWalletClient] Error in refreshWalletAccountShares',
953
+ error: error,
954
+ context: {
955
+ accountAddress,
956
+ chainName
957
+ }
921
958
  });
922
959
  throw error;
923
960
  }
@@ -1042,19 +1079,16 @@ class DynamicWalletClient {
1042
1079
  backupToGoogleDrive
1043
1080
  });
1044
1081
  } 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 axios.AxiosError) {
1053
- handleAxiosError(error, message, context);
1054
- }
1055
- this.logger.error(message, {
1056
- error,
1057
- context
1082
+ logError({
1083
+ message: '[DynamicWaasWalletClient] Error in reshare',
1084
+ error: error,
1085
+ context: {
1086
+ accountAddress,
1087
+ chainName,
1088
+ oldThresholdSignatureScheme,
1089
+ newThresholdSignatureScheme,
1090
+ backupToGoogleDrive
1091
+ }
1058
1092
  });
1059
1093
  throw error;
1060
1094
  }
@@ -1113,17 +1147,13 @@ class DynamicWalletClient {
1113
1147
  derivedPrivateKey
1114
1148
  };
1115
1149
  } catch (error) {
1116
- const message = '[DynamicWaasWalletClient] Error in exportKey';
1117
- const context = {
1118
- accountAddress,
1119
- chainName
1120
- };
1121
- if (error instanceof axios.AxiosError) {
1122
- handleAxiosError(error, message, context);
1123
- }
1124
- this.logger.error(message, {
1125
- error,
1126
- context
1150
+ logError({
1151
+ message: '[DynamicWaasWalletClient] Error in exportKey',
1152
+ error: error,
1153
+ context: {
1154
+ accountAddress,
1155
+ chainName
1156
+ }
1127
1157
  });
1128
1158
  throw error;
1129
1159
  }
@@ -1164,7 +1194,13 @@ class DynamicWalletClient {
1164
1194
  rawPublicKey
1165
1195
  };
1166
1196
  } catch (error) {
1167
- this.logger.error('[DynamicWaasWalletClient] Error in offlineExportKey', error);
1197
+ logError({
1198
+ message: '[DynamicWaasWalletClient] Error in offlineExportKey',
1199
+ error: error,
1200
+ context: {
1201
+ chainName
1202
+ }
1203
+ });
1168
1204
  throw error;
1169
1205
  }
1170
1206
  }
@@ -1196,7 +1232,13 @@ class DynamicWalletClient {
1196
1232
  }
1197
1233
  return (parsedWalletObject == null ? void 0 : parsedWalletObject.clientKeyShares) || [];
1198
1234
  } catch (error) {
1199
- this.logger.error(`[DynamicWaasWalletClient] Error parsing clientKeyShares: ${error} for accountAddress: ${accountAddress}`);
1235
+ logError({
1236
+ message: `[DynamicWaasWalletClient] Error parsing clientKeyShares: ${error} for accountAddress: ${accountAddress}`,
1237
+ error: error,
1238
+ context: {
1239
+ accountAddress
1240
+ }
1241
+ });
1200
1242
  return [];
1201
1243
  }
1202
1244
  }
@@ -1244,13 +1286,16 @@ class DynamicWalletClient {
1244
1286
  accountAddress
1245
1287
  });
1246
1288
  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', {
1289
+ const error = new Error(`WalletId not found for accountAddress ${accountAddress}`);
1290
+ logError({
1291
+ message: '[DynamicWaasWalletClient] Error in storeEncryptedBackupByWallet, wallet or walletId not found from the wallet map',
1292
+ error,
1248
1293
  context: {
1249
1294
  accountAddress,
1250
1295
  walletMap: this.walletMap
1251
1296
  }
1252
1297
  });
1253
- throw new Error(`WalletId not found for accountAddress ${accountAddress}`);
1298
+ throw error;
1254
1299
  }
1255
1300
  // TODO(zfaizal2): throw error if signedSessionId is not provided after service deploy
1256
1301
  let dynamicClientKeyShares = [];
@@ -1306,16 +1351,12 @@ class DynamicWalletClient {
1306
1351
  await this.storage.setItem(this.storageKey, JSON.stringify(this.walletMap));
1307
1352
  return data;
1308
1353
  } catch (error) {
1309
- const message = '[DynamicWaasWalletClient] Error in storeEncryptedBackupByWallet';
1310
- const context = {
1311
- accountAddress
1312
- };
1313
- if (error instanceof axios.AxiosError) {
1314
- handleAxiosError(error, message, context);
1315
- }
1316
- this.logger.error(message, {
1317
- error: error instanceof Error ? error.message : 'Unknown error',
1318
- context
1354
+ logError({
1355
+ message: '[DynamicWaasWalletClient] Error in storeEncryptedBackupByWallet',
1356
+ error: error,
1357
+ context: {
1358
+ accountAddress
1359
+ }
1319
1360
  });
1320
1361
  throw error;
1321
1362
  }
@@ -1365,23 +1406,25 @@ class DynamicWalletClient {
1365
1406
  const user = await this.apiClient.getUser();
1366
1407
  const oauthAccountId = getGoogleOAuthAccountId(user == null ? void 0 : user.verifiedCredentials);
1367
1408
  if (!oauthAccountId) {
1368
- this.logger.error('No Google OAuth account ID found', {
1369
- user,
1370
- accountAddress
1409
+ const error = new Error('No Google OAuth account ID found');
1410
+ logError({
1411
+ message: 'No Google OAuth account ID found',
1412
+ error,
1413
+ context: {
1414
+ user,
1415
+ accountAddress
1416
+ }
1371
1417
  });
1372
- throw new Error('No Google OAuth account ID found');
1418
+ throw error;
1373
1419
  }
1374
1420
  return oauthAccountId;
1375
1421
  } catch (error) {
1376
- const message = '[DynamicWaasWalletClient] Error in getGoogleOauthAccountIdOrThrow';
1377
- if (error instanceof axios.AxiosError) {
1378
- handleAxiosError(error, message, {
1422
+ logError({
1423
+ message: '[DynamicWaasWalletClient] Error in getGoogleOauthAccountIdOrThrow',
1424
+ error: error,
1425
+ context: {
1379
1426
  accountAddress
1380
- });
1381
- }
1382
- this.logger.error(message, {
1383
- error,
1384
- accountAddress
1427
+ }
1385
1428
  });
1386
1429
  throw error;
1387
1430
  }
@@ -1444,21 +1487,14 @@ class DynamicWalletClient {
1444
1487
  }
1445
1488
  return decryptedKeyShares;
1446
1489
  } 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 axios.AxiosError) {
1457
- handleAxiosError(error, message, context);
1458
- }
1459
- this.logger.error(message, {
1460
- error,
1461
- context
1490
+ logError({
1491
+ message: '[DynamicWaasWalletClient] Error in recoverEncryptedBackupByWallet',
1492
+ error: error,
1493
+ context: {
1494
+ accountAddress,
1495
+ walletOperation,
1496
+ shareCount
1497
+ }
1462
1498
  });
1463
1499
  throw error;
1464
1500
  }
@@ -1515,13 +1551,13 @@ class DynamicWalletClient {
1515
1551
  return googleDriveKeyShares.map((ks)=>ks.id);
1516
1552
  }
1517
1553
  } catch (error) {
1518
- this.logger.error('[DynamicWaasWalletClient]: Error in backupKeySharesToGoogleDrive', error);
1519
- if (error instanceof axios.AxiosError) {
1520
- const message = '[DynamicWaasWalletClient] Error in backupKeySharesToGoogleDrive';
1521
- handleAxiosError(error, message, {
1554
+ logError({
1555
+ message: '[DynamicWaasWalletClient] Error in backupKeySharesToGoogleDrive',
1556
+ error: error,
1557
+ context: {
1522
1558
  accountAddress
1523
- });
1524
- }
1559
+ }
1560
+ });
1525
1561
  throw error;
1526
1562
  }
1527
1563
  }
@@ -1573,16 +1609,12 @@ class DynamicWalletClient {
1573
1609
  });
1574
1610
  return data.keyShares.map((ks)=>ks.id);
1575
1611
  } catch (error) {
1576
- const message = '[DynamicWaasWalletClient] Error in backupKeySharesToGoogleDrive';
1577
- const context = {
1578
- accountAddress
1579
- };
1580
- if (error instanceof axios.AxiosError) {
1581
- handleAxiosError(error, message, context);
1582
- }
1583
- this.logger.error(message, {
1584
- error,
1585
- context
1612
+ logError({
1613
+ message: '[DynamicWaasWalletClient] Error in backupKeySharesToGoogleDrive',
1614
+ error: error,
1615
+ context: {
1616
+ accountAddress
1617
+ }
1586
1618
  });
1587
1619
  throw error;
1588
1620
  }
@@ -1609,27 +1641,40 @@ class DynamicWalletClient {
1609
1641
  fileName
1610
1642
  }));
1611
1643
  } catch (error) {
1612
- this.logger.error('[DynamicWaasWalletClient] Failed to download backup from Google Drive', {
1613
- accountAddress,
1614
- fileName,
1615
- error
1644
+ logError({
1645
+ message: '[DynamicWaasWalletClient] Failed to download backup from Google Drive',
1646
+ error: error,
1647
+ context: {
1648
+ accountAddress,
1649
+ fileName
1650
+ }
1616
1651
  });
1617
- throw new Error('Failed to restore backup from Google Drive');
1652
+ throw error;
1618
1653
  }
1619
1654
  if (!backupData) {
1620
- this.logger.error('[DynamicWaasWalletClient] No backup file found', {
1621
- accountAddress,
1622
- fileName
1655
+ const error = new Error('No backup file found');
1656
+ logError({
1657
+ message: '[DynamicWaasWalletClient] No backup file found',
1658
+ error: new Error('No backup file found'),
1659
+ context: {
1660
+ accountAddress,
1661
+ fileName
1662
+ }
1623
1663
  });
1624
- throw new Error('No backup file found');
1664
+ throw error;
1625
1665
  }
1626
1666
  // Validate the backup data structure
1627
1667
  if (!backupData.keyShares || !backupData.metadata) {
1628
- this.logger.error('[DynamicWaasWalletClient] Invalid backup format: missing keyShares or metadata', {
1629
- accountAddress,
1630
- fileName
1668
+ const error = new Error('Invalid backup format: missing keyShares or metadata');
1669
+ logError({
1670
+ message: '[DynamicWaasWalletClient] Invalid backup format: missing keyShares or metadata',
1671
+ error,
1672
+ context: {
1673
+ accountAddress,
1674
+ fileName
1675
+ }
1631
1676
  });
1632
- throw new Error('Invalid backup format: missing keyShares or metadata');
1677
+ throw error;
1633
1678
  }
1634
1679
  const { keyShares } = backupData;
1635
1680
  const decryptedKeyShares = await Promise.all(keyShares.map((keyShare)=>this.decryptKeyShare({
@@ -1643,16 +1688,12 @@ class DynamicWalletClient {
1643
1688
  });
1644
1689
  return decryptedKeyShares;
1645
1690
  } catch (error) {
1646
- const message = '[DynamicWaasWalletClient] Error in restoreBackupFromGoogleDrive';
1647
- const context = {
1648
- accountAddress
1649
- };
1650
- if (error instanceof axios.AxiosError) {
1651
- handleAxiosError(error, message, context);
1652
- }
1653
- this.logger.error(message, {
1654
- error,
1655
- context
1691
+ logError({
1692
+ message: '[DynamicWaasWalletClient] Error in restoreBackupFromGoogleDrive',
1693
+ error: error,
1694
+ context: {
1695
+ accountAddress
1696
+ }
1656
1697
  });
1657
1698
  throw error;
1658
1699
  }
@@ -1779,8 +1820,14 @@ class DynamicWalletClient {
1779
1820
  signedSessionId
1780
1821
  });
1781
1822
  } catch (error) {
1782
- this.logger.error('Error in verifying password', error);
1783
- throw new Error('Incorrect password');
1823
+ logError({
1824
+ message: '[DynamicWaasWalletClient] Error in verifyPassword',
1825
+ error: error,
1826
+ context: {
1827
+ accountAddress
1828
+ }
1829
+ });
1830
+ throw error;
1784
1831
  }
1785
1832
  }
1786
1833
  async isPasswordEncrypted({ accountAddress }) {
@@ -1839,15 +1886,12 @@ class DynamicWalletClient {
1839
1886
  walletProperties: wallet == null ? void 0 : wallet.walletProperties
1840
1887
  });
1841
1888
  } catch (error) {
1842
- const message = '[DynamicWaasWalletClient] Error in getWalletClientKeyShareBackupInfo';
1843
- if (error instanceof axios.AxiosError) {
1844
- handleAxiosError(error, message, {
1889
+ logError({
1890
+ message: '[DynamicWaasWalletClient] Error in getWalletClientKeyShareBackupInfo',
1891
+ error: error,
1892
+ context: {
1845
1893
  accountAddress
1846
- });
1847
- }
1848
- this.logger.error(message, {
1849
- error,
1850
- accountAddress
1894
+ }
1851
1895
  });
1852
1896
  throw error;
1853
1897
  }
@@ -1910,17 +1954,15 @@ class DynamicWalletClient {
1910
1954
  }
1911
1955
  return this.walletMap[accountAddress];
1912
1956
  } 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 axios.AxiosError) {
1922
- handleAxiosError(error, message, context);
1923
- }
1957
+ logError({
1958
+ message: '[DynamicWaasWalletClient] Error in getWallet',
1959
+ error: error,
1960
+ context: {
1961
+ accountAddress,
1962
+ walletOperation,
1963
+ shareCount
1964
+ }
1965
+ });
1924
1966
  throw error;
1925
1967
  }
1926
1968
  }
@@ -1958,12 +2000,10 @@ class DynamicWalletClient {
1958
2000
  }, {});
1959
2001
  return wallets;
1960
2002
  } catch (error) {
1961
- const message = '[DynamicWaasWalletClient] Error in getWallets';
1962
- if (error instanceof axios.AxiosError) {
1963
- handleAxiosError(error, message, {});
1964
- }
1965
- this.logger.error(message, {
1966
- error
2003
+ logError({
2004
+ message: '[DynamicWaasWalletClient] Error in getWallets',
2005
+ error: error,
2006
+ context: {}
1967
2007
  });
1968
2008
  throw error;
1969
2009
  }
@@ -1996,13 +2036,15 @@ class DynamicWalletClient {
1996
2036
  this.iframeDomain = core.IFRAME_DOMAIN_MAP[environment];
1997
2037
  // Generate unique instanceId when client is created
1998
2038
  this.instanceId = crypto.randomUUID();
2039
+ // initialize logger context
2040
+ this.initLoggerContext(authToken);
1999
2041
  // initialize the client
2000
2042
  this.initialize();
2001
2043
  }
2002
2044
  }
2003
2045
 
2004
2046
  const ERROR_KEYGEN_FAILED = '[DynamicWaasWalletClient]: Error with keygen';
2005
- const ERROR_CREATE_WALLET_ACCOUNT = '[DynamicWaasWalletClient]: Error creating evm wallet account';
2047
+ const ERROR_CREATE_WALLET_ACCOUNT = '[DynamicWaasWalletClient]: Error creating wallet account';
2006
2048
  const ERROR_SIGN_MESSAGE = '[DynamicWaasWalletClient]: Error signing message';
2007
2049
  const ERROR_ACCOUNT_ADDRESS_REQUIRED = '[DynamicWaasWalletClient]: Account address is required';
2008
2050
  const ERROR_VERIFY_MESSAGE_SIGNATURE = '[DynamicWaasWalletClient]: Error verifying message signature';