Socket
Socket
Sign inDemoInstall

@advanced-rest-client/cookie-parser

Package Overview
Dependencies
1
Maintainers
3
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @advanced-rest-client/cookie-parser

A javascript cookie parser for javascript HTTP clients.


Version published
Weekly downloads
9
increased by200%
Maintainers
3
Created
Weekly downloads
 

Changelog

Source

3.2.0 (2020-05-23)

Build

  • bumping version 51c3e64 by Pawel Psztyc
  • bumping version 69f2d88 by Pawel Psztyc

Update

  • [ci skip] automated merge master->stage. syncing main branches 57e8f26 by Ci agent
  • [ci skip] automated merge master->stage. syncing main branches 9466c69 by Ci agent
  • removing unused packages 301aa0d by Pawel Psztyc
  • updating lock file 5cb57f4 by Pawel Psztyc
  • adding types ca0e198 by Pawel Psztyc
  • updating dependencies and renaming main file a841761 by Pawel Psztyc
  • upgrading project, adding more tests, fixing issues f25d909 by Pawel Psztyc

Documentation

  • updating readme file f78ecd2 by Pawel

Refactor

  • upgrading to open-wc standards af79a8f by Pawel

Testing

  • adding assert function 202e4b7 by Pawel
  • updating SL and travis config 91e1719 by Pawel Psztyc

Other

  • Update: Restoring previous mocha version due to tests errors 0cf8774 by Pawel
  • Update: Upgrading dependencies 454b0fe by Pawel
  • Update: Updating node version for travis f6f02e9 by Pawel
  • Update: Removing FF from local tests due to unknown WCT error 376119c by Pawel
  • Breaking: Upgrading to ES6 modules 5527fbd by Pawel

Readme

Source

Published on NPM

Build Status

A JavaScript cookie parser for HTTP clients. Works in the browser as ES6 module or in NodeJS.

import { Cookies } from '@advanced-rest-client/cookie-parser';
const parser = new Cookies('rememberme=1; domain=foo.com; path=/; ssid=Hy1t5e#oj21.876aak;', 'http://bar.com/');
console.log(parser.cookies);

In Node:

const {Cookies} = require('@advanced-rest-client/cookie-parser');
const parser = new Cookies('rememberme=1; domain=foo.com; path=/; ssid=Hy1t5e#oj21.876aak;', 'http://bar.com/');
console.log(parser.cookies);

Usage

Installation

npm install --save @advanced-rest-client/cookie-parser

It parses set-cookie header received from the server and produces a Cookie object.

import { Cookies } from '@advanced-rest-client/cookie-parser';
const parser = new Cookies('rememberme=1; domain=foo.com; path=/; ssid=Hy1t5e#oj21.876aak;', 'http://bar.com/');
console.log(parser.cookies);

which is equivalent to:

const cookies = Cookies.parse('...');

Manipulating cookies

The filter function filters out cookies that should not be considered for given URL. This is defined in https://tools.ietf.org/html/rfc6265.

const instance = new Cookies('a=b; domain=foo.com; path=/;', 'http://sub.foo.com/');
const removed = instance.filter();
console.log(removed); // has the cookies because domain does not match

To clear expired cookies just call clearExpired() function.

const instance = new Cookies('a=b; expires=0;', 'http://sub.foo.com/');
// wait a second here, then
const removed = instance.filter();
console.log(removed); // the cookie expired

Development

git clone https://github.com/advanced-rest-client/cookie-parser
cd cookie-parser
npm install

Running the demo locally

npm start

Running the tests

npm test

Keywords

FAQs

Last updated on 23 May 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc