@frontegg/client
Advanced tools
Comparing version 2.0.17 to 2.0.18
@@ -164,22 +164,31 @@ "use strict"; | ||
return function (req, res) { return __awaiter(_this, void 0, void 0, function () { | ||
var _a, e_1, context, e_2; | ||
var e_1, _a, e_2, context, e_3; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, authInitedPromise]; | ||
case 0: | ||
_b.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, authInitedPromise]; | ||
case 1: | ||
_b.sent(); | ||
return [3 /*break*/, 3]; | ||
case 2: | ||
e_1 = _b.sent(); | ||
logger_1.default.error('Failed to authenticate via promise - ', e_1); | ||
authInitedPromise = authenticator.init(options.clientId, options.apiKey); | ||
throw e_1; | ||
case 3: | ||
_a = options.authMiddleware; | ||
if (!_a) return [3 /*break*/, 3]; | ||
if (!_a) return [3 /*break*/, 5]; | ||
return [4 /*yield*/, FronteggRoutes_1.fronteggRoutes.isFronteggPublicRoute(req)]; | ||
case 2: | ||
case 4: | ||
_a = !(_b.sent()); | ||
_b.label = 3; | ||
case 3: | ||
if (!_a) return [3 /*break*/, 7]; | ||
_b.label = 5; | ||
case 5: | ||
if (!_a) return [3 /*break*/, 9]; | ||
logger_1.default.debug('will pass request threw the auth middleware'); | ||
_b.label = 4; | ||
case 4: | ||
_b.trys.push([4, 6, , 7]); | ||
_b.label = 6; | ||
case 6: | ||
_b.trys.push([6, 8, , 9]); | ||
return [4 /*yield*/, utils_1.callMiddleware(req, res, options.authMiddleware)]; | ||
case 5: | ||
case 7: | ||
_b.sent(); | ||
@@ -191,6 +200,6 @@ if (res.headersSent) { | ||
} | ||
return [3 /*break*/, 7]; | ||
case 6: | ||
e_1 = _b.sent(); | ||
logger_1.default.error("Failed to call middleware - ", e_1); | ||
return [3 /*break*/, 9]; | ||
case 8: | ||
e_2 = _b.sent(); | ||
logger_1.default.error("Failed to call middleware - ", e_2); | ||
if (res.headersSent) { | ||
@@ -201,7 +210,7 @@ // response was already sent from the middleware, we have nothing left to do | ||
} | ||
return [2 /*return*/, res.status(401).send(e_1.message)]; | ||
case 7: | ||
return [2 /*return*/, res.status(401).send(e_2.message)]; | ||
case 9: | ||
logger_1.default.debug("going to resolve resolve context"); | ||
return [4 /*yield*/, options.contextResolver(req)]; | ||
case 8: | ||
case 10: | ||
context = _b.sent(); | ||
@@ -216,14 +225,14 @@ logger_1.default.debug("context resolved - " + JSON.stringify(context)); | ||
logger_1.default.debug("going to validate permissions for - ", req.url); | ||
_b.label = 9; | ||
case 9: | ||
_b.trys.push([9, 11, , 12]); | ||
_b.label = 11; | ||
case 11: | ||
_b.trys.push([11, 13, , 14]); | ||
return [4 /*yield*/, utils_1.validatePermissions(req, res, context)]; | ||
case 10: | ||
case 12: | ||
_b.sent(); | ||
return [3 /*break*/, 12]; | ||
case 11: | ||
e_2 = _b.sent(); | ||
logger_1.default.error('Failed at permissions check - ', e_2); | ||
return [3 /*break*/, 14]; | ||
case 13: | ||
e_3 = _b.sent(); | ||
logger_1.default.error('Failed at permissions check - ', e_3); | ||
return [2 /*return*/, res.status(403).send()]; | ||
case 12: | ||
case 14: | ||
if (!req.frontegg) { | ||
@@ -230,0 +239,0 @@ req.frontegg = {}; |
{ | ||
"name": "@frontegg/client", | ||
"version": "2.0.17", | ||
"version": "2.0.18", | ||
"description": "Frontegg Javascript Library for backend", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
242439
3548