@sumor/token-middleware
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "@sumor/token-middleware", | ||
"description": "A token middleware for ExpressJS.", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "repository": "sumor-cloud/token-middleware", |
@@ -5,2 +5,3 @@ # token-middleware | ||
[More Documentation](https://sumor.cloud/token-middleware) | ||
A token middleware for ExpressJS. | ||
@@ -23,3 +24,3 @@ | ||
Require Node.JS version 16.x or above | ||
Require Node.JS version 18.x or above | ||
@@ -26,0 +27,0 @@ ### require Node.JS ES module |
@@ -5,3 +5,3 @@ import Token from './Token.js' | ||
const cookie = parseCookie(req.headers.cookie) | ||
req.token = new Token(() => { | ||
req.token = new Token(id => { | ||
let existingCookie = res.getHeader('Set-Cookie') || [] | ||
@@ -11,6 +11,4 @@ if (typeof existingCookie === 'string') { | ||
} | ||
res.setHeader('Set-Cookie', [ | ||
...existingCookie, | ||
`t=${req.token.id}; Path=/; HttpOnly; Max-Age=86400` | ||
]) | ||
const maxAge = 100 * 24 * 60 * 60 | ||
res.setHeader('Set-Cookie', [...existingCookie, `t=${id}; Path=/; HttpOnly; Max-Age=${maxAge}`]) | ||
}) | ||
@@ -17,0 +15,0 @@ req.token._id = cookie.t || null |
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
9364
101
149