@frontegg/client
Advanced tools
Comparing version 1.0.30 to 1.0.31-0
import { AuditsClient } from './src/audits'; | ||
import { frontegg } from './src/middleware'; | ||
import { frontegg, IFronteggOptions } from './src/middleware'; | ||
import { FronteggPermissions } from './src/permissions'; | ||
export { AuditsClient, frontegg, FronteggPermissions, }; | ||
export { AuditsClient, frontegg, FronteggPermissions, IFronteggOptions, }; |
@@ -7,7 +7,8 @@ import { FronteggPermissions } from '../permissions'; | ||
}>; | ||
export declare function frontegg(options: { | ||
export interface IFronteggOptions { | ||
clientId: string; | ||
apiKey: string; | ||
contextResolver: fronteggContextResolver; | ||
}): (req: any, res: any) => Promise<void>; | ||
} | ||
export declare function frontegg(options: IFronteggOptions): (req: any, res: any) => Promise<void>; | ||
export {}; |
@@ -144,3 +144,3 @@ "use strict"; | ||
var _this = this; | ||
logger_1.default.log('you got to my frontegg middleware'); | ||
logger_1.default.debug('you got to my frontegg middleware'); | ||
if (!options) { | ||
@@ -184,2 +184,4 @@ throw new Error('Missing options'); | ||
case 0: | ||
logger_1.default.debug("proxyReq - returned for " + req.originalUrl); | ||
enableCors(req, proxyRes); | ||
if (!(proxyRes.statusCode === 401)) return [3 /*break*/, 3]; | ||
@@ -202,2 +204,17 @@ req.frontegg.retryCount = req.frontegg.retryCount + 1; | ||
}); }); | ||
function enableCors(req, res) { | ||
if (req.headers['access-control-request-method']) { | ||
logger_1.default.debug("enableCors - going to set access-control-request-method"); | ||
res.headers["access-control-allow-methods"] = req.headers['access-control-request-method']; | ||
} | ||
if (req.headers['access-control-request-headers']) { | ||
logger_1.default.debug("enableCors - going to set access-control-request-headers"); | ||
res.headers['access-control-allow-headers'] = req.headers['access-control-request-headers']; | ||
} | ||
if (req.headers.origin) { | ||
logger_1.default.debug("enableCors - going to set access-control-allow-origin to " + req.headers.origin); | ||
res.headers['access-control-allow-origin'] = req.headers.origin; | ||
res.headers['access-control-allow-credentials'] = 'true'; | ||
} | ||
} | ||
proxy.on('proxyReq', function (proxyReq, req, res, _) { | ||
@@ -204,0 +221,0 @@ if (req.body) { |
import { AuditsClient } from './src/audits'; | ||
import { frontegg } from './src/middleware'; | ||
import { frontegg, IFronteggOptions } from './src/middleware'; | ||
import { FronteggPermissions } from './src/permissions'; | ||
@@ -9,2 +9,3 @@ | ||
FronteggPermissions, | ||
IFronteggOptions, | ||
}; |
{ | ||
"name": "@frontegg/client", | ||
"version": "1.0.30", | ||
"version": "1.0.31-0", | ||
"description": "Frontegg Javascript Library for backend", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
40749
803
3