@frontegg/client
Advanced tools
Comparing version 1.1.4 to 1.2.0
@@ -19,2 +19,3 @@ /// <reference types="node" /> | ||
disableCors?: boolean; | ||
cookieDomainRewrite?: string; | ||
} | ||
@@ -21,0 +22,0 @@ export declare function frontegg(options: IFronteggOptions): (req: any, res: any) => Promise<any>; |
@@ -52,2 +52,11 @@ "use strict"; | ||
} | ||
function rewriteCookieDomain(header, oldDomain, newDomain) { | ||
if (Array.isArray(header)) { | ||
return header.map(function (headerElement) { | ||
return rewriteCookieDomain(headerElement, oldDomain, newDomain); | ||
}); | ||
} | ||
return header.replace(new RegExp("(;\\s*domain=)" + oldDomain + ";", 'i'), "$1" + newDomain + ";"); | ||
} | ||
; | ||
function proxyRequest(req, res, context) { | ||
@@ -229,3 +238,3 @@ return __awaiter(this, void 0, void 0, function () { | ||
proxy.on('proxyRes', function (proxyRes, req, res) { return __awaiter(_this, void 0, void 0, function () { | ||
var context; | ||
var context, host_1; | ||
return __generator(this, function (_a) { | ||
@@ -257,3 +266,12 @@ switch (_a.label) { | ||
return [2 /*return*/, proxyRequest(req, res, context)]; | ||
case 3: return [2 /*return*/]; | ||
case 3: | ||
if (options.cookieDomainRewrite) { | ||
host_1 = req.headers.host; | ||
Object.keys(proxyRes.headers).forEach(function (key) { | ||
if (key.toLowerCase() === 'set-cookie') { | ||
proxyRes.headers[key] = rewriteCookieDomain(proxyRes.headers[key], host_1, options.cookieDomainRewrite); | ||
} | ||
}); | ||
} | ||
return [2 /*return*/]; | ||
} | ||
@@ -260,0 +278,0 @@ }); |
{ | ||
"name": "@frontegg/client", | ||
"version": "1.1.4", | ||
"version": "1.2.0", | ||
"description": "Frontegg Javascript Library for backend", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
222271
3317