@frontegg/client
Advanced tools
Comparing version 1.0.48 to 1.0.49
@@ -102,6 +102,2 @@ "use strict"; | ||
response = _b.sent(); | ||
if (response.status !== 200) { | ||
logger_1.default.info('Invalid authentication status - ', response.status); | ||
throw new Error('Failed to authenticate'); | ||
} | ||
return [3 /*break*/, 4]; | ||
@@ -111,3 +107,5 @@ case 3: | ||
logger_1.default.error('failed to authenticate with frontegg - ', e_1.message); | ||
return [2 /*return*/]; | ||
this.accessToken = ''; | ||
this.accessTokenExpiry = 0; | ||
throw new Error('Failed to authenticate with frontegg'); | ||
case 4: | ||
@@ -114,0 +112,0 @@ logger_1.default.info('authenticated with frontegg'); |
@@ -97,4 +97,4 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var permissions, url, allowedOperations, _i, allowedOperations_1, operation, allowedMethod, route; | ||
return __generator(this, function (_a) { | ||
var permissions, url, _i, Whitelist_1, whiteListed, allowedOperations, _a, allowedOperations_1, operation, allowedMethod, route; | ||
return __generator(this, function (_b) { | ||
permissions = context.permissions; | ||
@@ -119,10 +119,13 @@ if (!permissions) { | ||
url = getUrlWithoutQueryParams(req); | ||
if (Whitelist.includes(url)) { | ||
logger_1.default.log("URL " + url + " is whitelisted"); | ||
return [2 /*return*/]; | ||
for (_i = 0, Whitelist_1 = Whitelist; _i < Whitelist_1.length; _i++) { | ||
whiteListed = Whitelist_1[_i]; | ||
if (url.startsWith(whiteListed)) { | ||
logger_1.default.log("URL " + url + " is whitelisted"); | ||
return [2 /*return*/]; | ||
} | ||
} | ||
allowedOperations = flattenPermissions(permissions); | ||
logger_1.default.log("allowedOperations for this user - ", allowedOperations); | ||
for (_i = 0, allowedOperations_1 = allowedOperations; _i < allowedOperations_1.length; _i++) { | ||
operation = allowedOperations_1[_i]; | ||
for (_a = 0, allowedOperations_1 = allowedOperations; _a < allowedOperations_1.length; _a++) { | ||
operation = allowedOperations_1[_a]; | ||
if (operation === '*') { | ||
@@ -129,0 +132,0 @@ logger_1.default.log("All operations are allowed for this user"); |
@@ -125,4 +125,7 @@ "use strict"; | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
_a.trys.push([0, 3, , 4]); | ||
logger_1.default.info('going to send notification'); | ||
return [4 /*yield*/, this.authenticator.validateAuthentication()]; | ||
case 1: | ||
_a.sent(); | ||
return [4 /*yield*/, axios_1.default.post(config_1.config.urls.notificationService, notificationDto, { | ||
@@ -133,10 +136,10 @@ headers: { | ||
})]; | ||
case 1: | ||
case 2: | ||
response = _a.sent(); | ||
return [2 /*return*/, response.data]; | ||
case 2: | ||
case 3: | ||
e_1 = _a.sent(); | ||
logger_1.default.error('failed to send notification to notifications service - ', e_1); | ||
throw e_1; | ||
case 3: | ||
case 4: | ||
logger_1.default.info('sent notification successfully'); | ||
@@ -143,0 +146,0 @@ return [2 /*return*/]; |
{ | ||
"name": "@frontegg/client", | ||
"version": "1.0.48", | ||
"version": "1.0.49", | ||
"description": "Frontegg Javascript Library for backend", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
72908
1474