diff options
author | Myles Borins <mylesborins@github.com> | 2020-10-02 17:52:19 -0400 |
---|---|---|
committer | Myles Borins <mylesborins@github.com> | 2020-10-07 09:59:49 -0400 |
commit | 2e545249557c265f7d5f338cc3a382985211603c (patch) | |
tree | a18ca49252a58cc5a80cd438a020a99bf48a8d23 /deps/npm/node_modules/tough-cookie/lib | |
parent | 14699846452e627f97dedb85991eea67d932a79d (diff) | |
download | node-new-2e545249557c265f7d5f338cc3a382985211603c.tar.gz |
deps: update npm to 7.0.0-rc.3
PR-URL: https://github.com/nodejs/node/pull/35474
Reviewed-By: Ruy Adorno <ruyadorno@github.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
Reviewed-By: Ben Coe <bencoe@gmail.com>
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'deps/npm/node_modules/tough-cookie/lib')
4 files changed, 65 insertions, 3 deletions
diff --git a/deps/npm/node_modules/tough-cookie/lib/cookie.js b/deps/npm/node_modules/tough-cookie/lib/cookie.js index 039a0e71f3..32dc0f8dc7 100644 --- a/deps/npm/node_modules/tough-cookie/lib/cookie.js +++ b/deps/npm/node_modules/tough-cookie/lib/cookie.js @@ -36,7 +36,7 @@ var pubsuffix = require('./pubsuffix-psl'); var Store = require('./store').Store; var MemoryCookieStore = require('./memstore').MemoryCookieStore; var pathMatch = require('./pathMatch').pathMatch; -var VERSION = require('../package.json').version; +var VERSION = require('./version'); var punycode; try { @@ -1371,7 +1371,6 @@ CookieJar.deserializeSync = function(strOrObj, store) { }; CookieJar.fromJSON = CookieJar.deserializeSync; -CAN_BE_SYNC.push('clone'); CookieJar.prototype.clone = function(newStore, cb) { if (arguments.length === 1) { cb = newStore; @@ -1382,10 +1381,61 @@ CookieJar.prototype.clone = function(newStore, cb) { if (err) { return cb(err); } - CookieJar.deserialize(newStore, serialized, cb); + CookieJar.deserialize(serialized, newStore, cb); }); }; +CAN_BE_SYNC.push('removeAllCookies'); +CookieJar.prototype.removeAllCookies = function(cb) { + var store = this.store; + + // Check that the store implements its own removeAllCookies(). The default + // implementation in Store will immediately call the callback with a "not + // implemented" Error. + if (store.removeAllCookies instanceof Function && + store.removeAllCookies !== Store.prototype.removeAllCookies) + { + return store.removeAllCookies(cb); + } + + store.getAllCookies(function(err, cookies) { + if (err) { + return cb(err); + } + + if (cookies.length === 0) { + return cb(null); + } + + var completedCount = 0; + var removeErrors = []; + + function removeCookieCb(removeErr) { + if (removeErr) { + removeErrors.push(removeErr); + } + + completedCount++; + + if (completedCount === cookies.length) { + return cb(removeErrors.length ? removeErrors[0] : null); + } + } + + cookies.forEach(function(cookie) { + store.removeCookie(cookie.domain, cookie.path, cookie.key, removeCookieCb); + }); + }); +}; + +CookieJar.prototype._cloneSync = syncWrap('clone'); +CookieJar.prototype.cloneSync = function(newStore) { + if (!newStore.synchronous) { + throw new Error('CookieJar clone destination store is not synchronous; use async API instead.'); + } + return this._cloneSync(newStore); +}; + // Use a closure to provide a true imperative API for synchronous stores. function syncWrap(method) { return function() { @@ -1413,6 +1463,7 @@ CAN_BE_SYNC.forEach(function(method) { CookieJar.prototype[method+'Sync'] = syncWrap(method); }); +exports.version = VERSION; exports.CookieJar = CookieJar; exports.Cookie = Cookie; exports.Store = Store; diff --git a/deps/npm/node_modules/tough-cookie/lib/memstore.js b/deps/npm/node_modules/tough-cookie/lib/memstore.js index bf306ba783..d2b915c935 100644 --- a/deps/npm/node_modules/tough-cookie/lib/memstore.js +++ b/deps/npm/node_modules/tough-cookie/lib/memstore.js @@ -149,6 +149,11 @@ MemoryCookieStore.prototype.removeCookies = function(domain, path, cb) { return cb(null); }; +MemoryCookieStore.prototype.removeAllCookies = function(cb) { + this.idx = {}; + return cb(null); +} + MemoryCookieStore.prototype.getAllCookies = function(cb) { var cookies = []; var idx = this.idx; diff --git a/deps/npm/node_modules/tough-cookie/lib/store.js b/deps/npm/node_modules/tough-cookie/lib/store.js index bce52925db..859208fc95 100644 --- a/deps/npm/node_modules/tough-cookie/lib/store.js +++ b/deps/npm/node_modules/tough-cookie/lib/store.js @@ -66,6 +66,10 @@ Store.prototype.removeCookies = function(domain, path, cb) { throw new Error('removeCookies is not implemented'); }; +Store.prototype.removeAllCookies = function(cb) { + throw new Error('removeAllCookies is not implemented'); +} + Store.prototype.getAllCookies = function(cb) { throw new Error('getAllCookies is not implemented (therefore jar cannot be serialized)'); }; diff --git a/deps/npm/node_modules/tough-cookie/lib/version.js b/deps/npm/node_modules/tough-cookie/lib/version.js new file mode 100644 index 0000000000..b34c6ae503 --- /dev/null +++ b/deps/npm/node_modules/tough-cookie/lib/version.js @@ -0,0 +1,2 @@ +// generated by genversion +module.exports = '2.5.0' |