Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cookiefile

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cookiefile

Package for operating with Netscape HTTP Cookie File

  • 1.0.4
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

node-cookiefile

Package for operating with Netscape HTTP Cookie File using Node.JS

It can read and create Netscape HTTP Cookie File like this:

# Netscape HTTP Cookie File
# https://curl.haxx.se/docs/http-cookies.html
# This file was generated by node-httpcookie! Edit at your own risk

horatius.pro	false	/	false	0	testKey	testValue
google.com   false	/	false	0	secondKey	secondValue

Install

npm install cookiefile --save

Usage

Loading library
let {Cookie, CookieMap, CookieError} = require('http-cookiefile')

It will provide JavaScript Map object with overloaded .set method

let cookie = new Cookie({
    domain: ".google.com",
    name: "testKey",
    value: "textValue",
    https: "false", // default
    crossDomain: "false", // default
    expire: Date.now() + 600 // default: 0
});
Reading Netscape Cookiefile

You can just enter your cookiefile path to load it into Map object

let cookieFile = new CookieMap('curl.cookiefile');

Or you can initialize it

let cookieFile = new CookieFile([
    cookie // Here is array of Cookie objects
]);
Adding new cookies

Overloaded Map.set method. It will get name for the row from cookie object

cookieFile.set(cookie);
Reading values

You are able to use default Map methods like get, has, clear, and others.

let cookieValue = cookieFile.get('testKey')

You can specify new name for new cookiefile. If you create CookieMap using filename it will be used by default.

cookieFile.save('new.cookiefile');
cookieFile.save(); // If you had specify filename when create object
toString methods

You are able to use toString methods for Cookie object

cookie.toString()

will return string like

google.com   false	/	false	0	secondKey	secondValue

For CookieMap toString is available too

cookieFile.toString();

will return string will full cookiefile

Tests

You are able to test this package using mocha

git clone https://github.com/horat1us/node-cookiefile
cd node-cookiefile
npm install
npm test

Keywords

FAQs

Package last updated on 10 Oct 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc