1.1.0 • Published 4 years ago

cookie-boss v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

cookie-boss

Takes cookie-manager (extends prototype) and cookie (adds parse and serialize methods as class and prototype methods), and adds a toJSON method. It is the boss!

Installation

npm install cookie-boss

Usage

const CookieBoss = require('cookie-boss');
const cookieboss = new CookieBoss();
const url = 'https://github.com'
const cookiesToStore = [
    `_octo=GH1.1.1249112545.1582225594; Path=/; Domain=github.com; Expires=Sat, 20 Feb 2021 19:06:34 GMT; Secure`,
    `logged_in=no; Path=/; Domain=github.com; Expires=Sat, 20 Feb 2021 19:06:34 GMT; HttpOnly; Secure`
];

cookieboss.store(url, cookiesToStore);

const prepared = cookieboss.prepare(url);
// '_octo=GH1.1.1249112545.1582225594; logged_in=no'

const parsed = CookieBoss.parse(prepared);
// { _octo: 'GH1.1.1249112545.1582225594', logged_in: 'no' }

const json = cookieboss.toJSON();
// {
//     "github.com": [
//         "_octo=GH1.1.1249112545.1582225594; Expires=Sat, 20 Feb 2021 19:06:34 GMT; Max-Age=31611923; Path=/; Domain=github.com; secure",
//         "logged_in=no; Expires=Sat, 20 Feb 2021 19:06:34 GMT; Max-Age=31611923; Path=/; Domain=github.com; secure; HttpOnly"
//     ]
// }

Typescript supported too!