wallaby-cash 1.7.15 → 1.7.17
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 +38 -45
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +38 -45
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +38 -45
- package/dist/index.js.map +1 -1
- package/dist/routes/merchants.d.ts +8 -8
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -4800,32 +4800,28 @@ var Base = /** @class */ (function () {
|
|
|
4800
4800
|
};
|
|
4801
4801
|
Base.prototype.getRequestHeaders = function (requiresAccessToken) {
|
|
4802
4802
|
return __awaiter(this, void 0, void 0, function () {
|
|
4803
|
-
var
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
case
|
|
4803
|
+
var accessToken, headers;
|
|
4804
|
+
return __generator(this, function (_a) {
|
|
4805
|
+
switch (_a.label) {
|
|
4806
|
+
case 0: return [4 /*yield*/, this.device];
|
|
4807
|
+
case 1:
|
|
4808
|
+
accessToken = (_a.sent()).authTokens.accessToken;
|
|
4808
4809
|
if (!isTest && jwtHasExpired(this.clientAuthToken)) {
|
|
4809
4810
|
throw new Error('Auth token has expired - blocking API call.');
|
|
4810
4811
|
}
|
|
4811
|
-
|
|
4812
|
+
headers = {
|
|
4812
4813
|
'Content-Type': 'application/json',
|
|
4813
|
-
'x-api-key': this.settings.apiKey
|
|
4814
|
+
'x-api-key': this.settings.apiKey,
|
|
4815
|
+
'x-client-jwt': this.clientAuthToken,
|
|
4814
4816
|
};
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
_c = 'Bearer ';
|
|
4824
|
-
return [4 /*yield*/, this.device];
|
|
4825
|
-
case 2:
|
|
4826
|
-
headers = __assign.apply(void 0, _b.concat([(_e.Authorization = _c + (_f.sent()).authTokens.accessToken, _e)]));
|
|
4827
|
-
_f.label = 3;
|
|
4828
|
-
case 3: return [2 /*return*/, headers];
|
|
4817
|
+
if (requiresAccessToken && this.userId) {
|
|
4818
|
+
// TODO: Add this validation back.
|
|
4819
|
+
// if (!isTest && (!accessToken || jwtHasExpired(accessToken))) {
|
|
4820
|
+
// throw new Error('Access token has expired, please sign in to continue.');
|
|
4821
|
+
// }
|
|
4822
|
+
headers = __assign(__assign({}, headers), { Authorization: 'Bearer ' + accessToken });
|
|
4823
|
+
}
|
|
4824
|
+
return [2 /*return*/, headers];
|
|
4829
4825
|
}
|
|
4830
4826
|
});
|
|
4831
4827
|
});
|
|
@@ -6433,8 +6429,8 @@ var MerchantsRoutes = {
|
|
|
6433
6429
|
},
|
|
6434
6430
|
update: {
|
|
6435
6431
|
fullPath: function (_a) {
|
|
6436
|
-
var
|
|
6437
|
-
return "/merchants/".concat(
|
|
6432
|
+
var merchantId = _a.merchantId;
|
|
6433
|
+
return "/merchants/".concat(merchantId);
|
|
6438
6434
|
},
|
|
6439
6435
|
method: exports.RequestMethod.Put,
|
|
6440
6436
|
requiresAccessToken: false,
|
|
@@ -6454,24 +6450,24 @@ var MerchantsRoutes = {
|
|
|
6454
6450
|
},
|
|
6455
6451
|
getAssets: {
|
|
6456
6452
|
fullPath: function (_a) {
|
|
6457
|
-
var
|
|
6458
|
-
return "/merchants/".concat(
|
|
6453
|
+
var merchantId = _a.merchantId;
|
|
6454
|
+
return "/merchants/".concat(merchantId, "/assets");
|
|
6459
6455
|
},
|
|
6460
6456
|
method: exports.RequestMethod.Get,
|
|
6461
|
-
requiresAccessToken:
|
|
6457
|
+
requiresAccessToken: true,
|
|
6462
6458
|
},
|
|
6463
6459
|
addAsset: {
|
|
6464
6460
|
fullPath: function (_a) {
|
|
6465
|
-
var
|
|
6466
|
-
return "/merchants/".concat(
|
|
6461
|
+
var merchantId = _a.merchantId, configId = _a.configId;
|
|
6462
|
+
return "/merchants/".concat(merchantId, "/assets").concat(configId);
|
|
6467
6463
|
},
|
|
6468
6464
|
method: exports.RequestMethod.Post,
|
|
6469
6465
|
requiresAccessToken: false,
|
|
6470
6466
|
},
|
|
6471
6467
|
deleteAsset: {
|
|
6472
6468
|
fullPath: function (_a) {
|
|
6473
|
-
var
|
|
6474
|
-
return "/merchants/".concat(
|
|
6469
|
+
var merchantId = _a.merchantId, configId = _a.configId;
|
|
6470
|
+
return "/merchants/".concat(merchantId, "/assets").concat(configId);
|
|
6475
6471
|
},
|
|
6476
6472
|
method: exports.RequestMethod.Delete,
|
|
6477
6473
|
requiresAccessToken: false,
|
|
@@ -6631,29 +6627,26 @@ var Merchants = /** @class */ (function (_super) {
|
|
|
6631
6627
|
*/
|
|
6632
6628
|
Merchants.prototype.getAssets = function () {
|
|
6633
6629
|
return __awaiter(this, void 0, void 0, function () {
|
|
6634
|
-
var
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
switch (_e.label) {
|
|
6630
|
+
var merchantId, response, error_5;
|
|
6631
|
+
return __generator(this, function (_a) {
|
|
6632
|
+
switch (_a.label) {
|
|
6638
6633
|
case 0:
|
|
6639
|
-
|
|
6640
|
-
_a = this.request;
|
|
6641
|
-
_b = [MerchantsRoutes.getAssets];
|
|
6642
|
-
_c = {
|
|
6643
|
-
method: MerchantsRoutes.getAssets.method
|
|
6644
|
-
};
|
|
6645
|
-
_d = {};
|
|
6634
|
+
_a.trys.push([0, 3, , 4]);
|
|
6646
6635
|
return [4 /*yield*/, this.device];
|
|
6647
|
-
case 1:
|
|
6648
|
-
|
|
6636
|
+
case 1:
|
|
6637
|
+
merchantId = (_a.sent()).user.merchantId;
|
|
6638
|
+
return [4 /*yield*/, this.request(MerchantsRoutes.getAssets, {
|
|
6639
|
+
method: MerchantsRoutes.getAssets.method,
|
|
6640
|
+
payload: { merchantId: merchantId },
|
|
6641
|
+
})];
|
|
6649
6642
|
case 2:
|
|
6650
|
-
response =
|
|
6643
|
+
response = _a.sent();
|
|
6651
6644
|
if (!response || response.error) {
|
|
6652
6645
|
throw new Error(response.error);
|
|
6653
6646
|
}
|
|
6654
6647
|
return [2 /*return*/, response];
|
|
6655
6648
|
case 3:
|
|
6656
|
-
error_5 =
|
|
6649
|
+
error_5 = _a.sent();
|
|
6657
6650
|
logger.error('SDK::Merchants::list::error', error_5);
|
|
6658
6651
|
return [2 /*return*/, Promise.reject(error_5)];
|
|
6659
6652
|
case 4: return [2 /*return*/];
|