@frontegg/client
Advanced tools
Comparing version 1.0.69 to 1.0.70
@@ -287,9 +287,34 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var context, e_2, _a, e_3; | ||
var _a, e_2, context, e_3; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_a = options.authMiddleware; | ||
if (!_a) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, FronteggRoutes_1.fronteggRoutes.isFronteggPublicRoute(req)]; | ||
case 1: | ||
_a = !(_b.sent()); | ||
_b.label = 2; | ||
case 2: | ||
if (!_a) return [3 /*break*/, 6]; | ||
logger_1.default.debug('will pass request threw the auth middleware'); | ||
_b.label = 3; | ||
case 3: | ||
_b.trys.push([3, 5, , 6]); | ||
return [4 /*yield*/, callMiddleware(req, res, options.authMiddleware)]; | ||
case 4: | ||
_b.sent(); | ||
if (res.headersSent) { | ||
// response was already sent from the middleware, we have nothing left to do | ||
return [2 /*return*/]; | ||
} | ||
return [3 /*break*/, 6]; | ||
case 5: | ||
e_2 = _b.sent(); | ||
logger_1.default.error("Failed to call middleware - ", e_2); | ||
return [2 /*return*/, res.status(401).send(e_2.message)]; | ||
case 6: | ||
logger_1.default.debug("going to resolve resolve context"); | ||
return [4 /*yield*/, options.contextResolver(req)]; | ||
case 1: | ||
case 7: | ||
context = _b.sent(); | ||
@@ -304,38 +329,13 @@ logger_1.default.debug("context resolved - " + JSON.stringify(context)); | ||
logger_1.default.debug("going to validate permissions for - ", req.url); | ||
_b.label = 2; | ||
case 2: | ||
_b.trys.push([2, 4, , 5]); | ||
return [4 /*yield*/, validatePermissions(req, res, context)]; | ||
case 3: | ||
_b.sent(); | ||
return [3 /*break*/, 5]; | ||
case 4: | ||
e_2 = _b.sent(); | ||
logger_1.default.error('Failed at permissions check - ', e_2); | ||
return [2 /*return*/, res.status(403).send()]; | ||
case 5: | ||
_a = options.authMiddleware; | ||
if (!_a) return [3 /*break*/, 7]; | ||
return [4 /*yield*/, FronteggRoutes_1.fronteggRoutes.isFronteggPublicRoute(req)]; | ||
case 6: | ||
_a = !(_b.sent()); | ||
_b.label = 7; | ||
case 7: | ||
if (!_a) return [3 /*break*/, 11]; | ||
logger_1.default.debug('will pass request threw the auth middleware'); | ||
_b.label = 8; | ||
case 8: | ||
_b.trys.push([8, 10, , 11]); | ||
return [4 /*yield*/, callMiddleware(req, res, options.authMiddleware)]; | ||
return [4 /*yield*/, validatePermissions(req, res, context)]; | ||
case 9: | ||
_b.sent(); | ||
if (res.headersSent) { | ||
// response was already sent from the middleware, we have nothing left to do | ||
return [2 /*return*/]; | ||
} | ||
return [3 /*break*/, 11]; | ||
case 10: | ||
e_3 = _b.sent(); | ||
logger_1.default.error("Failed to call middleware - ", e_3); | ||
return [2 /*return*/, res.status(401).send(e_3.message)]; | ||
logger_1.default.error('Failed at permissions check - ', e_3); | ||
return [2 /*return*/, res.status(403).send()]; | ||
case 11: | ||
@@ -342,0 +342,0 @@ if (!req.frontegg) { |
{ | ||
"name": "@frontegg/client", | ||
"version": "1.0.69", | ||
"version": "1.0.70", | ||
"description": "Frontegg Javascript Library for backend", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
202688