wallaby-cash 1.7.15 → 1.7.16
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 +37 -45
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +37 -45
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +37 -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,27 @@ 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
|
-
_e = {};
|
|
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
|
+
if (!isTest && (!accessToken || jwtHasExpired(accessToken))) {
|
|
4819
|
+
throw new Error('Access token has expired, please sign in to continue.');
|
|
4820
|
+
}
|
|
4821
|
+
headers = __assign(__assign({}, headers), { Authorization: 'Bearer ' + accessToken });
|
|
4822
|
+
}
|
|
4823
|
+
return [2 /*return*/, headers];
|
|
4829
4824
|
}
|
|
4830
4825
|
});
|
|
4831
4826
|
});
|
|
@@ -6433,8 +6428,8 @@ var MerchantsRoutes = {
|
|
|
6433
6428
|
},
|
|
6434
6429
|
update: {
|
|
6435
6430
|
fullPath: function (_a) {
|
|
6436
|
-
var
|
|
6437
|
-
return "/merchants/".concat(
|
|
6431
|
+
var merchantId = _a.merchantId;
|
|
6432
|
+
return "/merchants/".concat(merchantId);
|
|
6438
6433
|
},
|
|
6439
6434
|
method: exports.RequestMethod.Put,
|
|
6440
6435
|
requiresAccessToken: false,
|
|
@@ -6454,24 +6449,24 @@ var MerchantsRoutes = {
|
|
|
6454
6449
|
},
|
|
6455
6450
|
getAssets: {
|
|
6456
6451
|
fullPath: function (_a) {
|
|
6457
|
-
var
|
|
6458
|
-
return "/merchants/".concat(
|
|
6452
|
+
var merchantId = _a.merchantId;
|
|
6453
|
+
return "/merchants/".concat(merchantId, "/assets");
|
|
6459
6454
|
},
|
|
6460
6455
|
method: exports.RequestMethod.Get,
|
|
6461
|
-
requiresAccessToken:
|
|
6456
|
+
requiresAccessToken: true,
|
|
6462
6457
|
},
|
|
6463
6458
|
addAsset: {
|
|
6464
6459
|
fullPath: function (_a) {
|
|
6465
|
-
var
|
|
6466
|
-
return "/merchants/".concat(
|
|
6460
|
+
var merchantId = _a.merchantId, configId = _a.configId;
|
|
6461
|
+
return "/merchants/".concat(merchantId, "/assets").concat(configId);
|
|
6467
6462
|
},
|
|
6468
6463
|
method: exports.RequestMethod.Post,
|
|
6469
6464
|
requiresAccessToken: false,
|
|
6470
6465
|
},
|
|
6471
6466
|
deleteAsset: {
|
|
6472
6467
|
fullPath: function (_a) {
|
|
6473
|
-
var
|
|
6474
|
-
return "/merchants/".concat(
|
|
6468
|
+
var merchantId = _a.merchantId, configId = _a.configId;
|
|
6469
|
+
return "/merchants/".concat(merchantId, "/assets").concat(configId);
|
|
6475
6470
|
},
|
|
6476
6471
|
method: exports.RequestMethod.Delete,
|
|
6477
6472
|
requiresAccessToken: false,
|
|
@@ -6631,29 +6626,26 @@ var Merchants = /** @class */ (function (_super) {
|
|
|
6631
6626
|
*/
|
|
6632
6627
|
Merchants.prototype.getAssets = function () {
|
|
6633
6628
|
return __awaiter(this, void 0, void 0, function () {
|
|
6634
|
-
var
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
switch (_e.label) {
|
|
6629
|
+
var merchantId, response, error_5;
|
|
6630
|
+
return __generator(this, function (_a) {
|
|
6631
|
+
switch (_a.label) {
|
|
6638
6632
|
case 0:
|
|
6639
|
-
|
|
6640
|
-
_a = this.request;
|
|
6641
|
-
_b = [MerchantsRoutes.getAssets];
|
|
6642
|
-
_c = {
|
|
6643
|
-
method: MerchantsRoutes.getAssets.method
|
|
6644
|
-
};
|
|
6645
|
-
_d = {};
|
|
6633
|
+
_a.trys.push([0, 3, , 4]);
|
|
6646
6634
|
return [4 /*yield*/, this.device];
|
|
6647
|
-
case 1:
|
|
6648
|
-
|
|
6635
|
+
case 1:
|
|
6636
|
+
merchantId = (_a.sent()).user.merchantId;
|
|
6637
|
+
return [4 /*yield*/, this.request(MerchantsRoutes.getAssets, {
|
|
6638
|
+
method: MerchantsRoutes.getAssets.method,
|
|
6639
|
+
payload: { merchantId: merchantId },
|
|
6640
|
+
})];
|
|
6649
6641
|
case 2:
|
|
6650
|
-
response =
|
|
6642
|
+
response = _a.sent();
|
|
6651
6643
|
if (!response || response.error) {
|
|
6652
6644
|
throw new Error(response.error);
|
|
6653
6645
|
}
|
|
6654
6646
|
return [2 /*return*/, response];
|
|
6655
6647
|
case 3:
|
|
6656
|
-
error_5 =
|
|
6648
|
+
error_5 = _a.sent();
|
|
6657
6649
|
logger.error('SDK::Merchants::list::error', error_5);
|
|
6658
6650
|
return [2 /*return*/, Promise.reject(error_5)];
|
|
6659
6651
|
case 4: return [2 /*return*/];
|