@advanced-rest-client/arc-cookies
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

Deprecated

This component is deprecated. Use @advanced-rest-client/app instead.


A module that contains the logic and the UIs for handle cookies and sessions in Advanced REST Client.

Published on NPM

tests

Usage

Installation

npm install --save @advanced-rest-client/arc-cookies

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('...');

The second argument is the request URL needed to properly pase cookies.

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

Cookie screen

The cookie-manager renders the cookies screen in Advanced REST Client. It uses events defined in @advanced-rest-client/arc-events to request and to communicate the state.

<cookie-manager listType="default"></cookie-manager>

Development

git clone https://github.com/advanced-rest-client/arc-cookies
cd arc-cookies
npm install

Running the demo locally

npm start

Running the tests

npm test

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.2.1
    718
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.2.1
    718
  • 0.2.0
    2
  • 0.1.1
    0
  • 0.1.0
    0

Package Sidebar

Install

npm i @advanced-rest-client/arc-cookies

Weekly Downloads

720

Version

0.2.1

License

Apache-2.0

Unpacked Size

117 kB

Total Files

26

Last publish

Collaborators

  • jarrodek
  • twoplustwoone
  • lbauret
  • carowright