Link Search Menu Expand Document

Cookie Thief

npm npm npm bundle size npm bundle size codecov

A node.js library for extracting cookies from a browser installed on your system. Inspired by chrome-cookies-secure.

Installation

npm install cookie-thief
yarn add cookie-thief

Usage

const { getCookie, listCookies, Browser, listBrowsers } = require('cookie-thief')

// Get a cookie from chrome browser for domain .github.com, searching for cookie named 'dotcom_user'
const cookie = await getCookie({
  browser: Browser.Chrome,
  domain: '.github.com',
  cookieName: 'dotcom_user',
});
console.log(cookie);
// Will be a Cookie if cookie is successfully found
// Will be undefined if not found
//{
//  name: 'cookie name here',
//  value: 'decrypted cookie content here',
//  host: 'hostname of cookie here',
//  path: 'path of cookie here'
//}

const cookies = await listCookies({
  browser: Browser.Chrome,
});
console.log(cookies);
// Array of cookies
//[
//  {
//    name: 'cookie name here',
//    value: 'decrypted cookie content here',
//    host: 'hostname of cookie here',
//    path: 'path of cookie here'
//  }
//]

const browsers = listBrowsers();
console.log(browsers);
// [ Browser.Chrome, Browser.Firefox ]