tough-cookie-document-store

tough-cookie store use document.cookie adapter

Usage no npm install needed!

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

README

tough-cookie-document-store

tough-cookie store use document.cookie adapter

npm install tough-cookie tough-cookie-document-store

usage

import DocumentCookieStore from 'tough-cookie-document-store';
import * as toughCookie from 'tough-cookie';

for node.js

u can make a document ny jsdom

import { createJSDOM } from 'jsdom-extra';
let jsdom = createJSDOM();
let document = jsdom.document;

demo

let store: DocumentCookieStore;

if (typeof document != 'undefined' && document)
{
    // if ur document not a global, this can help
    store = new DocumentCookieStore(document);
}
else
{
    // will auto use global document
    store = new DocumentCookieStore();
}

let jar = new toughCookie.CookieJar(store);

console.log(jar);

// ... anything u wanna do

other options

new DocumentCookieStore(document, another new toughCookie.Store for cache)