@frontegg/client
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -207,3 +207,3 @@ "use strict"; | ||
exports.FRONTEGG_API_KEY = options.apiKey; | ||
authenticator.init(options.clientId, options.apiKey); | ||
var authInitedPromise = authenticator.init(options.clientId, options.apiKey); | ||
proxy.on('error', function (err, req, res, _) { return __awaiter(_this, void 0, void 0, function () { | ||
@@ -293,17 +293,19 @@ var context; | ||
switch (_b.label) { | ||
case 0: | ||
case 0: return [4 /*yield*/, authInitedPromise]; | ||
case 1: | ||
_b.sent(); | ||
_a = options.authMiddleware; | ||
if (!_a) return [3 /*break*/, 2]; | ||
if (!_a) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, FronteggRoutes_1.fronteggRoutes.isFronteggPublicRoute(req)]; | ||
case 1: | ||
case 2: | ||
_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]); | ||
if (!_a) return [3 /*break*/, 7]; | ||
logger_1.default.debug('will pass request threw the auth middleware'); | ||
_b.label = 4; | ||
case 4: | ||
_b.trys.push([4, 6, , 7]); | ||
return [4 /*yield*/, callMiddleware(req, res, options.authMiddleware)]; | ||
case 4: | ||
case 5: | ||
_b.sent(); | ||
@@ -314,11 +316,11 @@ if (res.headersSent) { | ||
} | ||
return [3 /*break*/, 6]; | ||
case 5: | ||
return [3 /*break*/, 7]; | ||
case 6: | ||
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: | ||
case 7: | ||
logger_1.default.debug("going to resolve resolve context"); | ||
return [4 /*yield*/, options.contextResolver(req)]; | ||
case 7: | ||
case 8: | ||
context = _b.sent(); | ||
@@ -333,14 +335,14 @@ logger_1.default.debug("context resolved - " + JSON.stringify(context)); | ||
logger_1.default.debug("going to validate permissions for - ", req.url); | ||
_b.label = 8; | ||
case 8: | ||
_b.trys.push([8, 10, , 11]); | ||
_b.label = 9; | ||
case 9: | ||
_b.trys.push([9, 11, , 12]); | ||
return [4 /*yield*/, validatePermissions(req, res, context)]; | ||
case 9: | ||
case 10: | ||
_b.sent(); | ||
return [3 /*break*/, 11]; | ||
case 10: | ||
return [3 /*break*/, 12]; | ||
case 11: | ||
e_3 = _b.sent(); | ||
logger_1.default.error('Failed at permissions check - ', e_3); | ||
return [2 /*return*/, res.status(403).send()]; | ||
case 11: | ||
case 12: | ||
if (!req.frontegg) { | ||
@@ -347,0 +349,0 @@ req.frontegg = {}; |
{ | ||
"name": "@frontegg/client", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "Frontegg Javascript Library for backend", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
220686
3298