@frontegg/client
Advanced tools
Comparing version 1.0.65 to 1.0.66
import { AuditsClient } from './src/audits'; | ||
import { FronteggAuthenticator } from './src/authenticator'; | ||
import { withAuthentication } from './src/identity'; | ||
import { frontegg, IFronteggOptions } from './src/middleware'; | ||
@@ -10,2 +11,2 @@ import { NotificationsClient } from './src/notifications'; | ||
export * from './src/events'; | ||
export { AuditsClient, NotificationsClient, TenantsClient, frontegg, FronteggPermissions, IFronteggOptions, FronteggAuthenticator, RbacMiddleware, SsoClient, }; | ||
export { AuditsClient, NotificationsClient, TenantsClient, frontegg, FronteggPermissions, IFronteggOptions, FronteggAuthenticator, RbacMiddleware, SsoClient, withAuthentication, }; |
@@ -10,2 +10,4 @@ "use strict"; | ||
exports.FronteggAuthenticator = authenticator_1.FronteggAuthenticator; | ||
var identity_1 = require("./src/identity"); | ||
exports.withAuthentication = identity_1.withAuthentication; | ||
var middleware_1 = require("./src/middleware"); | ||
@@ -24,1 +26,2 @@ exports.frontegg = middleware_1.frontegg; | ||
__export(require("./src/events")); | ||
//# sourceMappingURL=index.js.map |
@@ -265,1 +265,2 @@ "use strict"; | ||
exports.AuditsClient = AuditsClient; | ||
//# sourceMappingURL=index.js.map |
@@ -127,1 +127,2 @@ "use strict"; | ||
exports.FronteggAuthenticator = FronteggAuthenticator; | ||
//# sourceMappingURL=index.js.map |
@@ -0,1 +1,2 @@ | ||
export declare let baseUrl: string; | ||
export declare namespace config { | ||
@@ -10,3 +11,4 @@ class urls { | ||
static eventService: string; | ||
static identityService: string; | ||
} | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var baseUrl = process.env.FRONTEGG_API_GATEWAY_URL || "https://api.frontegg.com/"; | ||
if (baseUrl.endsWith('/')) { | ||
baseUrl = baseUrl.slice(0, -1); | ||
exports.baseUrl = process.env.FRONTEGG_API_GATEWAY_URL || "https://api.frontegg.com/"; | ||
if (exports.baseUrl.endsWith('/')) { | ||
exports.baseUrl = exports.baseUrl.slice(0, -1); | ||
} | ||
@@ -14,9 +14,10 @@ // tslint:disable-next-line:no-namespace | ||
} | ||
urls.authenticationService = process.env.FRONTEGG_AUTHENTICATION_SERVICE_URL || baseUrl + "/vendors/auth/token"; | ||
urls.auditsService = process.env.FRONTEGG_AUDITS_SERVICE_URL || baseUrl + "/audits/"; | ||
urls.notificationService = process.env.FRONTEGG_NOTIFICATION_SERVICE_URL || baseUrl + "/notification/"; | ||
urls.tenantsService = process.env.FRONTEGG_TENANTS_SERVICE_URL || baseUrl + "/tenants/"; | ||
urls.metadataService = process.env.FRONTEGG_METADATA_SERVICE_URL || baseUrl + "/metadata/"; | ||
urls.teamService = process.env.FRONTEGG_TEAM_MANAGEMENT_SERVICE_URL || baseUrl + "/team"; | ||
urls.eventService = process.env.FRONTEGG_EVENT_SERVICE_URL || baseUrl + "/event"; | ||
urls.authenticationService = process.env.FRONTEGG_AUTHENTICATION_SERVICE_URL || exports.baseUrl + "/vendors/auth/token"; | ||
urls.auditsService = process.env.FRONTEGG_AUDITS_SERVICE_URL || exports.baseUrl + "/audits/"; | ||
urls.notificationService = process.env.FRONTEGG_NOTIFICATION_SERVICE_URL || exports.baseUrl + "/notification/"; | ||
urls.tenantsService = process.env.FRONTEGG_TENANTS_SERVICE_URL || exports.baseUrl + "/tenants/"; | ||
urls.metadataService = process.env.FRONTEGG_METADATA_SERVICE_URL || exports.baseUrl + "/metadata/"; | ||
urls.teamService = process.env.FRONTEGG_TEAM_MANAGEMENT_SERVICE_URL || exports.baseUrl + "/team"; | ||
urls.eventService = process.env.FRONTEGG_EVENT_SERVICE_URL || exports.baseUrl + "/event"; | ||
urls.identityService = process.env.FRONTEGG_IDENTITY_SERVICE_URL || exports.baseUrl + "/identity"; | ||
return urls; | ||
@@ -26,1 +27,2 @@ }()); | ||
})(config = exports.config || (exports.config = {})); | ||
//# sourceMappingURL=index.js.map |
@@ -179,1 +179,2 @@ "use strict"; | ||
exports.EventsClient = EventsClient; | ||
//# sourceMappingURL=EventsClient.js.map |
@@ -7,1 +7,2 @@ "use strict"; | ||
__export(require("./EventsClient")); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=AuditProperties.interface.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=BellAction.interface.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=BellProperties.interface.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=Channels.type.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=ChannelsConfiguration.interface.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=TriggerOptions.interface.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=WebhookBody.type.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=WebpushProperties.interface.js.map |
@@ -54,1 +54,2 @@ "use strict"; | ||
exports.default = Logger; | ||
//# sourceMappingURL=logger.js.map |
@@ -0,1 +1,2 @@ | ||
import { NextFunction, Request, Response } from 'express'; | ||
import { FronteggPermissions } from '../permissions'; | ||
@@ -7,2 +8,3 @@ declare type fronteggContextResolver = (req: Request) => Promise<{ | ||
}>; | ||
declare type AuthMiddleware = (req: Request, res: Response, next: NextFunction) => Promise<any> | any; | ||
export interface IFronteggOptions { | ||
@@ -12,2 +14,3 @@ clientId: string; | ||
contextResolver: fronteggContextResolver; | ||
authMiddleware?: AuthMiddleware; | ||
disableCors?: boolean; | ||
@@ -14,0 +17,0 @@ } |
@@ -41,5 +41,7 @@ "use strict"; | ||
var logger_1 = require("../helpers/logger"); | ||
var identity_1 = require("../identity"); | ||
var permissions_1 = require("../permissions"); | ||
var FronteggRoutes_1 = require("./FronteggRoutes"); | ||
var proxy = httpProxy.createProxyServer({ secure: false, changeOrigin: true }); | ||
var target = process.env.FRONTEGG_API_GATEWAY_URL || "https://api.frontegg.com/"; | ||
var target = process.env.FRONTEGG_API_GATEWAY_URL || 'https://api.frontegg.com/'; | ||
var authenticator = new authenticator_1.FronteggAuthenticator(); | ||
@@ -49,3 +51,3 @@ var Whitelist = ['/metadata']; | ||
function getUrlWithoutQueryParams(req) { | ||
return req.url.split("?").shift(); | ||
return req.url.split('?').shift(); | ||
} | ||
@@ -151,2 +153,31 @@ function proxyRequest(req, res, context) { | ||
} | ||
function callMiddleware(req, res, middleware) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var middlewareWrap, nextValue; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
middlewareWrap = new Promise(function (next, reject) { return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, middleware(req, res, next).catch(reject)]; | ||
case 1: | ||
_a.sent(); | ||
next(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
return [4 /*yield*/, middlewareWrap]; | ||
case 1: | ||
nextValue = _a.sent(); | ||
if (nextValue) { | ||
throw new Error(nextValue); | ||
} | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
function frontegg(options) { | ||
@@ -167,2 +198,5 @@ var _this = this; | ||
} | ||
if (!options.authMiddleware) { | ||
options.authMiddleware = identity_1.withAuthentication(); | ||
} | ||
authenticator.init(options.clientId, options.apiKey); | ||
@@ -199,3 +233,3 @@ proxy.on('error', function (err, req, res, _) { return __awaiter(_this, void 0, void 0, function () { | ||
else { | ||
delete proxyRes.headers["access-control-allow-methods"]; | ||
delete proxyRes.headers['access-control-allow-methods']; | ||
delete proxyRes.headers['access-control-allow-headers']; | ||
@@ -225,3 +259,3 @@ delete proxyRes.headers['access-control-allow-origin']; | ||
logger_1.default.debug("enableCors - going to set access-control-request-method"); | ||
res.headers["access-control-allow-methods"] = req.headers['access-control-request-method']; | ||
res.headers['access-control-allow-methods'] = req.headers['access-control-request-method']; | ||
} | ||
@@ -252,5 +286,5 @@ if (req.headers['access-control-request-headers']) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var context, e_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
var context, e_1, _a, e_2; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
@@ -260,3 +294,3 @@ logger_1.default.debug("going to resolve resolve context"); | ||
case 1: | ||
context = _a.sent(); | ||
context = _b.sent(); | ||
logger_1.default.debug("context resolved - " + JSON.stringify(context)); | ||
@@ -270,14 +304,38 @@ if (req.method === 'OPTIONS') { | ||
logger_1.default.debug("going to validate permissions for - ", req.url); | ||
_a.label = 2; | ||
_b.label = 2; | ||
case 2: | ||
_a.trys.push([2, 4, , 5]); | ||
_b.trys.push([2, 4, , 5]); | ||
return [4 /*yield*/, validatePermissions(req, res, context)]; | ||
case 3: | ||
_a.sent(); | ||
_b.sent(); | ||
return [3 /*break*/, 5]; | ||
case 4: | ||
e_1 = _a.sent(); | ||
e_1 = _b.sent(); | ||
logger_1.default.error('Failed at permissions check - ', e_1); | ||
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)]; | ||
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_2 = _b.sent(); | ||
return [2 /*return*/, res.status(401).send(e_2.message)]; | ||
case 11: | ||
if (!req.frontegg) { | ||
@@ -296,1 +354,2 @@ req.frontegg = {}; | ||
exports.frontegg = frontegg; | ||
//# sourceMappingURL=index.js.map |
@@ -180,1 +180,2 @@ "use strict"; | ||
exports.NotificationsClient = NotificationsClient; | ||
//# sourceMappingURL=index.js.map |
@@ -45,1 +45,2 @@ "use strict"; | ||
exports.FronteggPermissions = FronteggPermissions; | ||
//# sourceMappingURL=index.js.map |
@@ -146,1 +146,2 @@ "use strict"; | ||
exports.RbacMiddleware = RbacMiddleware; | ||
//# sourceMappingURL=index.js.map |
@@ -517,1 +517,2 @@ "use strict"; | ||
}); | ||
//# sourceMappingURL=rbac.spec.js.map |
@@ -105,1 +105,2 @@ "use strict"; | ||
exports.SsoClient = SsoClient; | ||
//# sourceMappingURL=index.js.map |
@@ -279,1 +279,2 @@ "use strict"; | ||
exports.TenantsClient = TenantsClient; | ||
//# sourceMappingURL=index.js.map |
import { AuditsClient } from './src/audits'; | ||
import { FronteggAuthenticator } from './src/authenticator'; | ||
import { withAuthentication } from './src/identity'; | ||
import { frontegg, IFronteggOptions } from './src/middleware'; | ||
@@ -21,2 +22,3 @@ import { NotificationsClient } from './src/notifications'; | ||
SsoClient, | ||
withAuthentication, | ||
}; |
{ | ||
"name": "@frontegg/client", | ||
"version": "1.0.65", | ||
"version": "1.0.66", | ||
"description": "Frontegg Javascript Library for backend", | ||
@@ -24,2 +24,3 @@ "main": "dist/index.js", | ||
"http-proxy": "^1.18.1", | ||
"jsonwebtoken": "^8.5.1", | ||
"winston": "^3.2.1" | ||
@@ -33,2 +34,3 @@ }, | ||
"@types/jest": "^25.2.3", | ||
"@types/jsonwebtoken": "^8.5.0", | ||
"@types/node": "^12.6.2", | ||
@@ -35,0 +37,0 @@ "babel-core": "^6.26.3", |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
200472
89
2983
1
5
14
4
+ Addedjsonwebtoken@^8.5.1
+ Addedbuffer-equal-constant-time@1.0.1(transitive)
+ Addedecdsa-sig-formatter@1.0.11(transitive)
+ Addedjsonwebtoken@8.5.1(transitive)
+ Addedjwa@1.4.1(transitive)
+ Addedjws@3.2.2(transitive)
+ Addedlodash.includes@4.3.0(transitive)
+ Addedlodash.isboolean@3.0.3(transitive)
+ Addedlodash.isinteger@4.0.4(transitive)
+ Addedlodash.isnumber@3.0.3(transitive)
+ Addedlodash.isplainobject@4.0.6(transitive)
+ Addedlodash.isstring@4.0.1(transitive)
+ Addedlodash.once@4.1.1(transitive)
+ Addedsemver@5.7.2(transitive)