wallaby-cash 1.7.0 → 1.7.3

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/dist/index.cjs.js CHANGED
@@ -4922,7 +4922,6 @@ var StorageService = /** @class */ (function () {
4922
4922
  return StorageService;
4923
4923
  }());
4924
4924
 
4925
- /* eslint-disable no-prototype-builtins */
4926
4925
  /**
4927
4926
  * Converts an object to query parameters string.
4928
4927
  *
@@ -4931,11 +4930,11 @@ var StorageService = /** @class */ (function () {
4931
4930
  */
4932
4931
  function objectToQueryParams(obj) {
4933
4932
  var params = new URLSearchParams();
4934
- for (var key in obj) {
4935
- if (obj.hasOwnProperty(key) && obj[key] !== undefined && obj[key] !== null) {
4933
+ Object.keys(obj).forEach(function (key) {
4934
+ if (obj[key] !== null && obj[key] !== undefined && obj[key] !== '') {
4936
4935
  params.append(key, obj[key]);
4937
4936
  }
4938
- }
4937
+ });
4939
4938
  return params.toString();
4940
4939
  }
4941
4940
 
@@ -5189,12 +5188,6 @@ var WalletRoutes = {
5189
5188
  method: exports.RequestMethod.Post,
5190
5189
  requiresAccessToken: false,
5191
5190
  },
5192
- // TODO Move this to transactions module
5193
- estimateFee: {
5194
- fullPath: '/transactions/estimate-fee',
5195
- method: exports.RequestMethod.Get,
5196
- requiresAccessToken: true,
5197
- },
5198
5191
  getWalletAssets: {
5199
5192
  fullPath: function (_a) {
5200
5193
  var walletId = _a.walletId;
@@ -5469,16 +5462,16 @@ var Auth = /** @class */ (function (_super) {
5469
5462
  */
5470
5463
  Auth.prototype.signIn = function (_a) {
5471
5464
  return __awaiter(this, arguments, void 0, function (_b) {
5472
- var signatureMessage, message, signature, clientAuthPubKey, response, accessToken, user, wallabyAuthPubKey, error_3;
5465
+ var signatureMessage, message, signature, clientAuthPubKey, decryptedClientAuthPrivKey, response, accessToken, user, error_3;
5473
5466
  var password = _b.password;
5474
5467
  return __generator(this, function (_c) {
5475
5468
  switch (_c.label) {
5476
5469
  case 0:
5477
- _c.trys.push([0, 4, , 5]);
5470
+ _c.trys.push([0, 3, , 4]);
5478
5471
  return [4 /*yield*/, this.signatureMessage({ password: password })];
5479
5472
  case 1:
5480
5473
  signatureMessage = _c.sent();
5481
- message = signatureMessage.message, signature = signatureMessage.signature, clientAuthPubKey = signatureMessage.clientAuthPubKey;
5474
+ message = signatureMessage.message, signature = signatureMessage.signature, clientAuthPubKey = signatureMessage.clientAuthPubKey, decryptedClientAuthPrivKey = signatureMessage.decryptedClientAuthPrivKey;
5482
5475
  return [4 /*yield*/, this.request(AuthRoutes.signIn, {
5483
5476
  method: AuthRoutes.signUp.method,
5484
5477
  payload: { clientAuthPubKey: clientAuthPubKey, signature: signature, message: message },
@@ -5489,22 +5482,15 @@ var Auth = /** @class */ (function (_super) {
5489
5482
  throw new Error(response.error);
5490
5483
  }
5491
5484
  accessToken = response.accessToken, user = response.user;
5492
- return [4 /*yield*/, this.storageService.getWallabyAuthPubKey()];
5493
- case 3:
5494
- wallabyAuthPubKey = _c.sent();
5495
- if (wallabyAuthPubKey !== user.wallabyAuthPubKey) {
5496
- throw new Error('Wallaby Auth Public Key does not match the one stored in local storage');
5497
- }
5498
- if (!wallabyAuthPubKey) {
5499
- this.storageService.setWallabyAuthPubKey(user.wallabyAuthPubKey);
5500
- }
5485
+ this.storageService.setWallabyAuthPubKey(user.wallabyAuthPubKey);
5486
+ this.storageService.setEncryptedPrivateKey(decryptedClientAuthPrivKey, password);
5501
5487
  this.storageService.setAccessToken(accessToken);
5502
5488
  return [2 /*return*/, response];
5503
- case 4:
5489
+ case 3:
5504
5490
  error_3 = _c.sent();
5505
5491
  logger('SDK::Auth::signIn::error', error_3);
5506
5492
  return [2 /*return*/, Promise.reject(error_3)];
5507
- case 5: return [2 /*return*/];
5493
+ case 4: return [2 /*return*/];
5508
5494
  }
5509
5495
  });
5510
5496
  });
@@ -6162,8 +6148,8 @@ var Wallet = /** @class */ (function (_super) {
6162
6148
  return [4 /*yield*/, this.initRecoveryFlow({ clientAuthPubKey: publicKey })];
6163
6149
  case 1:
6164
6150
  initRecovery = _d.sent();
6165
- if (!initRecovery || initRecovery.error) {
6166
- throw new Error(initRecovery === null || initRecovery === void 0 ? void 0 : initRecovery.error);
6151
+ if (!initRecovery) {
6152
+ throw new Error('Wallet could not be recovered');
6167
6153
  }
6168
6154
  signatureMessage = initRecovery.signatureMessage, wallabyAuthPubKey = initRecovery.wallabyAuthPubKey;
6169
6155
  hashedMessage = ethCryptoJs.keccak256(signatureMessage);
@@ -6410,8 +6396,8 @@ var Wallet = /** @class */ (function (_super) {
6410
6396
  })];
6411
6397
  case 1:
6412
6398
  initRecovery = _c.sent();
6413
- if (!initRecovery || initRecovery.error) {
6414
- throw new Error(initRecovery.error);
6399
+ if (!initRecovery) {
6400
+ throw new Error('Wallet recovery could not be initiated');
6415
6401
  }
6416
6402
  return [2 /*return*/, { signatureMessage: initRecovery.signatureMessage, wallabyAuthPubKey: initRecovery.wallabyAuthPubKey }];
6417
6403
  case 2:
@@ -6633,8 +6619,8 @@ var MerchantsRoutes = {
6633
6619
  },
6634
6620
  getMerchantData: {
6635
6621
  fullPath: function (_a) {
6636
- var id = _a.id;
6637
- return "/merchants/".concat(id);
6622
+ var merchantId = _a.merchantId;
6623
+ return "/merchants/".concat(merchantId);
6638
6624
  },
6639
6625
  method: exports.RequestMethod.Get,
6640
6626
  requiresAccessToken: false,
@@ -6670,7 +6656,7 @@ var MerchantsRoutes = {
6670
6656
  },
6671
6657
  };
6672
6658
 
6673
- /** @class */ ((function (_super) {
6659
+ var Merchants = /** @class */ (function (_super) {
6674
6660
  __extends(Merchants, _super);
6675
6661
  function Merchants(config) {
6676
6662
  return _super.call(this, config) || this;
@@ -6894,7 +6880,7 @@ var MerchantsRoutes = {
6894
6880
  });
6895
6881
  };
6896
6882
  return Merchants;
6897
- })(Base));
6883
+ }(Base));
6898
6884
 
6899
6885
  var System = /** @class */ (function (_super) {
6900
6886
  __extends(System, _super);
@@ -7047,10 +7033,7 @@ var TransactionsRoutes = {
7047
7033
  requiresAccessToken: true,
7048
7034
  },
7049
7035
  estimateFee: {
7050
- fullPath: function (_a) {
7051
- var assetSymbol = _a.assetSymbol, originAddress = _a.originAddress, recipientAddress = _a.recipientAddress, amount = _a.amount, transactionType = _a.transactionType, tokenType = _a.tokenType, tokenStandard = _a.tokenStandard, blockchain = _a.blockchain;
7052
- return "/transactions/estimate-fee?assetSymbol=".concat(assetSymbol, "&originAddress=").concat(originAddress, "&recipientAddress=").concat(recipientAddress, "&chainName=").concat(blockchain, "&amount=").concat(amount, "&transactionType=").concat(transactionType).concat(tokenStandard ? "&tokenStandard=".concat(tokenStandard) : tokenType ? "&tokenType=".concat(tokenType) : null).trim();
7053
- },
7036
+ fullPath: '/transactions/estimate-fee',
7054
7037
  method: exports.RequestMethod.Get,
7055
7038
  requiresAccessToken: true,
7056
7039
  },
@@ -7097,8 +7080,8 @@ var Transactions = /** @class */ (function (_super) {
7097
7080
  _c.trys.push([0, 2, , 3]);
7098
7081
  return [4 /*yield*/, this.request(TransactionsRoutes.estimateFee, {
7099
7082
  method: TransactionsRoutes.estimateFee.method,
7100
- payload: {
7101
- blockchain: blockchain,
7083
+ queryParams: {
7084
+ chainName: blockchain,
7102
7085
  originAddress: originAddress,
7103
7086
  recipientAddress: recipientAddress,
7104
7087
  amount: amount,
@@ -7341,6 +7324,7 @@ var Wallaby = /** @class */ (function () {
7341
7324
  this.auth = new Auth(config);
7342
7325
  this.system = new System(config);
7343
7326
  this.transactions = new Transactions(config);
7327
+ this.merchants = new Merchants(config);
7344
7328
  }
7345
7329
  return Wallaby;
7346
7330
  }());