CryptoCookie
Usage
var CryptoCookie = ; // create a cookie objectvar cookie = req res; // set a session cookiecookie; // get a cookiecookie; // orcookiereqCookiessessionId // set a cookie with attributescookie; // remove a cookiecookie; // remove a cookie with attributescookie; // set cookie expires with GMT date stringcookie; // set cookie expires with ISO date stringcookie; // set cookie expires with local date formatcookie; // set cookie expires with milliseconds timestampcookie; // create cookie object with default options// the default options will apply to cookie.set()var cookie = req res maxAge: 500 expires: '2015-05-13T07:30:00Z' path: '/foo' domain: 'www.example.com' secure: true httpOnly: true; // set a cookie and override some default optionscookie;/* will equivalent to cookie.set('defaults', 'ok', { maxAge: 100, expires: new Date('2015-05-13T07:30:00Z'), path: '/foo', domain: 'www.example.com', secure: true, httpOnly: true });*/ // create cookie object with keysvar cookie = req res keys: crypto; // set an encrypted cookie// this will use hmac to hash the cookie name, and aes-256-gcm to encrypt the valuecookie; // get an encrypted cookievar value = cookie; // set a signed cookiecookie; // get a signed cookievar value = cookie; // rotate keys supportvar cookie = req res keys: crypto crypto ; // when we insert a new password at the beginning of the keys list,// we still can get the cookie encrypted with old passwordvar encrypted = cookie; // and signed cookie as wellvar signed = cookie;
License
MIT