@neumatter/cookie-jar
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

CookieJar

JavaScript Style Guide

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

Package Sidebar

Install

npm i @neumatter/cookie-jar

Weekly Downloads

0

Version

1.0.2

License

none

Unpacked Size

51.8 kB

Total Files

7

Last publish

Collaborators

  • clyng57