@neumatter/cookie-jar
v1.0.2
Published
Module for working with cookies and/or signing and verifying cookies.
Downloads
5
Maintainers
Readme
CookieJar
Module for working with cookies and/or signing and verifying cookies.
Table of Contents
Install
npm i @neumatter/cookie-jar
Usage
CookieJar:
import CookieJar from '@neumatter/cookie-jar'
const cookieJar = new CookieJar(req.get('cookie'))
cookieJar.set('id', {
sameSite: true,
httpOnly: true,
strict: true
})
// ...use cookieJar
Server Cookies:
import { RequestCookies, ResponseCookies } from '@neumatter/cookie-jar'
const reqCookies = new RequestCookies(req)
const resCookies = new ResponseCookies(res) // Will set cookies automatically on Response
resCookies.set('id', {
sameSite: 'lax',
httpOnly: true,
strict: true,
maxAge: 'P2W' // 2 week duration string
})
resCookies.sign('id', secret) // Will update the value automatically on Response