@frontegg/client
Advanced tools
Comparing version 2.0.14 to 2.0.16
import { AuditsClient } from './src/audits'; | ||
import { IdentityClient } from './src/identity'; | ||
import { FronteggAuthenticator } from './src/authenticator'; | ||
import { IdentityClient } from './src/identity'; | ||
import { contextResolver, withAuthentication } from './src/identity'; | ||
import { ContextHolder, frontegg, fronteggNextJs, IFronteggOptions } from './src/middleware'; | ||
import { frontegg, fronteggNextJs, IFronteggOptions } from './src/middleware'; | ||
import { NotificationsClient } from './src/notifications'; | ||
@@ -12,2 +12,2 @@ import { FronteggPermissions } from './src/permissions'; | ||
export * from './src/events'; | ||
export { AuditsClient, ContextHolder, NotificationsClient, TenantsClient, frontegg, fronteggNextJs, FronteggPermissions, IFronteggOptions, FronteggAuthenticator, RbacMiddleware, SsoClient, withAuthentication, contextResolver, IdentityClient, }; | ||
export { AuditsClient, NotificationsClient, TenantsClient, frontegg, fronteggNextJs, FronteggPermissions, IFronteggOptions, FronteggAuthenticator, RbacMiddleware, SsoClient, withAuthentication, contextResolver, IdentityClient }; |
@@ -8,6 +8,6 @@ "use strict"; | ||
exports.AuditsClient = audits_1.AuditsClient; | ||
var identity_1 = require("./src/identity"); | ||
exports.IdentityClient = identity_1.IdentityClient; | ||
var authenticator_1 = require("./src/authenticator"); | ||
exports.FronteggAuthenticator = authenticator_1.FronteggAuthenticator; | ||
var identity_1 = require("./src/identity"); | ||
exports.IdentityClient = identity_1.IdentityClient; | ||
var identity_2 = require("./src/identity"); | ||
@@ -17,3 +17,2 @@ exports.contextResolver = identity_2.contextResolver; | ||
var middleware_1 = require("./src/middleware"); | ||
exports.ContextHolder = middleware_1.ContextHolder; | ||
exports.frontegg = middleware_1.frontegg; | ||
@@ -20,0 +19,0 @@ exports.fronteggNextJs = middleware_1.fronteggNextJs; |
@@ -6,9 +6,6 @@ export declare class FronteggAuthenticator { | ||
private apiKey; | ||
private refreshTimeout; | ||
private shuttingDown; | ||
init(clientId: string, apiKey: string): Promise<void>; | ||
refreshAuthentication(): Promise<void>; | ||
validateAuthentication(): Promise<void>; | ||
shutdown(): Promise<void>; | ||
private authenticate; | ||
} |
@@ -47,4 +47,2 @@ "use strict"; | ||
this.apiKey = ''; | ||
this.refreshTimeout = null; | ||
this.shuttingDown = false; | ||
} | ||
@@ -88,13 +86,2 @@ FronteggAuthenticator.prototype.init = function (clientId, apiKey) { | ||
}; | ||
FronteggAuthenticator.prototype.shutdown = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
this.shuttingDown = true; | ||
if (this.refreshTimeout !== null) { | ||
clearTimeout(this.refreshTimeout); | ||
} | ||
return [2 /*return*/]; | ||
}); | ||
}); | ||
}; | ||
FronteggAuthenticator.prototype.authenticate = function (force) { | ||
@@ -141,7 +128,5 @@ if (force === void 0) { force = false; } | ||
this.accessTokenExpiry = Date.now() + nextRefresh; | ||
if (!this.shuttingDown) { | ||
this.refreshTimeout = setTimeout(function () { | ||
_this.refreshAuthentication(); | ||
}, nextRefresh); | ||
} | ||
setTimeout(function () { | ||
_this.refreshAuthentication(); | ||
}, nextRefresh); | ||
return [2 /*return*/]; | ||
@@ -148,0 +133,0 @@ } |
@@ -5,3 +5,2 @@ "use strict"; | ||
if (exports.baseUrl.endsWith('/')) { | ||
// Take the base url | ||
exports.baseUrl = exports.baseUrl.slice(0, -1); | ||
@@ -8,0 +7,0 @@ } |
@@ -0,2 +1,2 @@ | ||
export * from './EventsClient'; | ||
export * from './types'; | ||
export * from './events'; |
@@ -6,4 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./types")); | ||
__export(require("./events")); | ||
__export(require("./EventsClient")); | ||
//# sourceMappingURL=index.js.map |
@@ -1,4 +0,9 @@ | ||
export * from './channel-configuration'; | ||
export * from './errors'; | ||
export * from './event-types'; | ||
export * from './status-types'; | ||
export * from './WebpushProperties.interface'; | ||
export * from './BellProperties.interface'; | ||
export * from './AuditProperties.interface'; | ||
export * from './TriggerOptions.interface'; | ||
export * from './BellAction.interface'; | ||
export * from './ChannelsConfiguration.interface'; | ||
export * from './WebhookBody.type'; | ||
export * from './Channels.type'; | ||
export * from './SlackProperties.interface'; |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./errors")); | ||
//# sourceMappingURL=index.js.map |
@@ -95,5 +95,2 @@ "use strict"; | ||
this.publicKey = publicKey; | ||
return [4 /*yield*/, authenticator.shutdown()]; | ||
case 3: | ||
_b.sent(); | ||
return [2 /*return*/]; | ||
@@ -100,0 +97,0 @@ } |
@@ -45,7 +45,8 @@ "use strict"; | ||
var utils_1 = require("./utils"); | ||
var proxy = httpProxy.createProxyServer({ secure: false, changeOrigin: true, xfwd: true }); | ||
var proxy = httpProxy.createProxyServer({ secure: false, changeOrigin: true }); | ||
var target = process.env.FRONTEGG_API_GATEWAY_URL || 'https://api.frontegg.com/'; | ||
var pjson = getPackageJSON_1.getPackageJson() || { version: 'unknown' }; | ||
var authenticator = new authenticator_1.FronteggAuthenticator(); | ||
var MAX_RETRIES = 3; | ||
function proxyRequest(req, res, context, authenticator) { | ||
function proxyRequest(req, res, context) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -96,3 +97,2 @@ var headers; | ||
} | ||
var authenticator = new authenticator_1.FronteggAuthenticator(); | ||
ContextHolder_1.ContextHolder.setContext({ | ||
@@ -118,3 +118,3 @@ FRONTEGG_CLIENT_ID: options.clientId, | ||
context = _a.sent(); | ||
return [2 /*return*/, proxyRequest(req, res, context, authenticator)]; | ||
return [2 /*return*/, proxyRequest(req, res, context)]; | ||
} | ||
@@ -190,3 +190,2 @@ }); | ||
// response was already sent from the middleware, we have nothing left to do | ||
logger_1.default.debug('Headers was already sent from authMiddleware'); | ||
return [2 /*return*/]; | ||
@@ -198,7 +197,2 @@ } | ||
logger_1.default.error("Failed to call middleware - ", e_1); | ||
if (res.headersSent) { | ||
// response was already sent from the middleware, we have nothing left to do | ||
logger_1.default.debug('authMiddleware threw error, but headers was already sent'); | ||
return [2 /*return*/]; | ||
} | ||
return [2 /*return*/, res.status(401).send(e_1.message)]; | ||
@@ -235,3 +229,3 @@ case 7: | ||
logger_1.default.debug("going to proxy request"); | ||
return [2 /*return*/, proxyRequest(req, res, context, authenticator)]; | ||
return [2 /*return*/, proxyRequest(req, res, context)]; | ||
} | ||
@@ -238,0 +232,0 @@ }); |
{ | ||
"name": "@frontegg/client", | ||
"version": "2.0.14", | ||
"version": "2.0.16", | ||
"description": "Frontegg Javascript Library for backend", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
265458
142
3939