Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const cookiejar = new CookieJar();
cookiejar.setCookie(cookie, 'http://currentdomain.example.com/path', cb);
// ...
cookiejar.getCookies('http://example.com/otherpath', (err, cookies) => {
// res.headers['cookie'] = cookies.join('; ');
});
// All option are optional.
cookiejar.getCookies('http://example.com/otherpath', {}, () => {});
cookiejar.getCookies('http://example.com/otherpath', {
now: new Date(),
allPaths: true,
}, () => {});
CookieJar.deserializeSync("test cookie with store", new MemoryCookieStore());
CookieJar.deserializeSync("test cookie");
export function polyfill(options) {
const opts = { ...defaultOptions, ...options };
let root = null;
try {
root = window || global;
} catch (e) {
root = global;
}
if (opts.isomorphicFetch) {
const Tough = require('tough-cookie');
const Store = new Tough.MemoryCookieStore();
const rejectPublicSuffixes = false; // See https://github.com/salesforce/tough-cookie#cookiejarstoreoptions
const cookieJar = new Tough.CookieJar(Store, rejectPublicSuffixes);
const fetch = require('fetch-cookie')(require('@yeutech-lab/isomorphic-fetch'), cookieJar);
root.fetch = fetch;
root.cookieJar = cookieJar;
}
if (opts.fetch && !opts.isomorphicFetch) {
require('whatwg-fetch');
root.fetchMock = require('fetch-mock');
}
if (opts.localStorage && !root.localStorage) {
root.localStorage = require('localStorage');
}