@frontegg/client
Advanced tools
Comparing version 1.2.17 to 1.2.18
@@ -6,1 +6,7 @@ export declare const contextResolver: (req: any) => { | ||
}; | ||
export declare const contextResolverWithPermissions: (req: any) => { | ||
tenantId: any; | ||
userId: any; | ||
permissions: string[]; | ||
userPermissions: any; | ||
}; |
@@ -18,2 +18,18 @@ "use strict"; | ||
}; | ||
exports.contextResolverWithPermissions = function (req) { | ||
if (!req.user) { | ||
return { | ||
tenantId: '', | ||
userId: '', | ||
permissions: [index_1.FronteggPermissions.All], | ||
userPermissions: [] | ||
}; | ||
} | ||
return { | ||
tenantId: req.user.tenantId, | ||
userId: req.user.id, | ||
permissions: [index_1.FronteggPermissions.All], | ||
userPermissions: req.user.permissions | ||
}; | ||
}; | ||
//# sourceMappingURL=contextResolver.js.map |
@@ -52,2 +52,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var headers; | ||
return __generator(this, function (_a) { | ||
@@ -59,11 +60,16 @@ switch (_a.label) { | ||
logger_1.default.log("going to proxy request - " + req.originalUrl + " to " + target); | ||
headers = { | ||
'x-access-token': authenticator.accessToken, | ||
'frontegg-tenant-id': context && context.tenantId ? context.tenantId : 'WITHOUT_TENANT_ID', | ||
'frontegg-user-id': context && context.userId ? context.userId : '', | ||
'frontegg-vendor-host': req.hostname, | ||
'frontegg-middleware-client': "Node.js@" + pjson.version, | ||
'frontegg-user-permissions': (context.userPermissions || []).join(','), | ||
}; | ||
if (context.userPermissions) { | ||
headers['frontegg-user-permissions'] = context.userPermissions.join(','); | ||
} | ||
return [4 /*yield*/, proxy.web(req, res, { | ||
target: target, | ||
headers: { | ||
'x-access-token': authenticator.accessToken, | ||
'frontegg-tenant-id': context && context.tenantId ? context.tenantId : 'WITHOUT_TENANT_ID', | ||
'frontegg-user-id': context && context.userId ? context.userId : '', | ||
'frontegg-vendor-host': req.hostname, | ||
'frontegg-middleware-client': "Node.js@" + pjson.version, | ||
}, | ||
headers: headers | ||
})]; | ||
@@ -70,0 +76,0 @@ case 2: |
@@ -12,7 +12,9 @@ import { NextFunction, Request, Response } from 'express'; | ||
} | ||
export declare type fronteggContextResolver = (req: Request) => Promise<{ | ||
export declare type fronteggContextResolverRes = { | ||
tenantId: string; | ||
userId: string; | ||
permissions: FronteggPermissions[]; | ||
}>; | ||
userPermissions?: string[]; | ||
}; | ||
export declare type fronteggContextResolver = (req: Request) => Promise<fronteggContextResolverRes> | fronteggContextResolverRes; | ||
export declare type AuthMiddleware = (req: Request, res: Response, next: NextFunction) => Promise<any> | any; | ||
@@ -19,0 +21,0 @@ export interface INextHttpProxyMiddlewareOptions { |
{ | ||
"name": "@frontegg/client", | ||
"version": "1.2.17", | ||
"version": "1.2.18", | ||
"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
249143
3709