Comparing version 0.11.0-rc4 to 0.11.0-rc5
const { URL } = require('url'); | ||
const querystring = require('querystring'); | ||
const cookie = require('cookie'); | ||
const cookieSignature = require('cookie-signature'); | ||
const http = require('http'); | ||
@@ -25,4 +27,13 @@ | ||
function handleCookies(app, req, res){ | ||
return forMiddleware(app._cookies, req, res); | ||
function parseCookies(cconf, req){ | ||
req.cookies = cookie.parse(req.headers.cookie); | ||
req.signedCookies = {}; | ||
for(let key in req.cookies) | ||
if(req.cookies[key] && req.cookies[key].substr(0, 2) == 's:'){ | ||
let val = cookieSignature.unsign(req.cookies[key].substr(2), cconf.secret); | ||
if(val){ | ||
req.signedCookies[key] = val; | ||
delete req.cookies[key]; | ||
} | ||
} | ||
} | ||
@@ -37,4 +48,8 @@ | ||
await forMiddleware(app._compress, req, res); | ||
await handleCookies(app, req, res); | ||
if(app.conf.cookie) | ||
req.secret = app.conf.cookie.secret; | ||
if(req.headers.cookie) | ||
parseCookies(app.conf.cookie, req); | ||
if(app.conf.cors) | ||
@@ -41,0 +56,0 @@ await handleCORS(app, req, res); |
@@ -6,4 +6,3 @@ const | ||
Logger = require('golog'), | ||
compression = require('compression'), | ||
cookieParser = require('cookie-parser'); | ||
compression = require('compression'); | ||
@@ -80,3 +79,2 @@ const { startServer } = require('./http'); | ||
this._cors = cors(this.conf.cors); | ||
this._cookies = cookieParser(this.conf.cookie && this.conf.cookie.secret); | ||
this._compress = compression(); | ||
@@ -83,0 +81,0 @@ |
{ | ||
"name": "nodecaf", | ||
"version": "0.11.0-rc4", | ||
"version": "0.11.0-rc5", | ||
"description": "Nodecaf is a light framework for developing RESTful Apps in a quick and convenient manner.", | ||
@@ -44,3 +44,2 @@ "main": "lib/main.js", | ||
"cookie": "^0.4.1", | ||
"cookie-parser": "^1.4.5", | ||
"cookie-signature": "^1.1.0", | ||
@@ -47,0 +46,0 @@ "cors": "^2.8.5", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86825
12
1318
- Removedcookie-parser@^1.4.5
- Removedcookie@0.7.2(transitive)
- Removedcookie-parser@1.4.7(transitive)
- Removedcookie-signature@1.0.6(transitive)