tough-cookie-store

file store for tough-cookie, edit on mitsuru/tough-cookie-filestore

Usage no npm install needed!

<script type="module">
  import toughCookieStore from 'https://cdn.skypack.dev/tough-cookie-store';
</script>

README

File Cookie Store

NPM

tough-cookie-filestore is a File store modified from tough-cookie-filestore, fully compatible with it. And add some functions needed in use.

installation

$ npm install tough-cookie-store

Usage

  var FileCookieStore = require("tough-cookie-store"),
      request = require('request');
  
  var fileStore = new FileCookieStore(filePath, option);
  var jar = request.jar(fileStore);
  var req = request.defaults({jar: jar});

Options

filePath

file path of cookie file.

option

with or without encrypt

option.encrypt

true as default, unless explicitly specified as false fileStore will encrypt the cookie file with the default setting.

option.algorithm

'aes-256-cbc'as default, you can use any algorithm nodejs supported.

option.password

'tough-cookie-store'as default.

API

see tough-cookie#store-api

extra API

fileStore.getCookie(domain, path, key)

sync version of fileStore.findCookie, return a cookie object.

fileStore.flush()

write current cookies to file.

fileStore.isEmpty()

check if fileStore is empty.

License

MIT