Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/austingebauer/devise.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/tough-cookie/lib/cookie.js')
-rw-r--r--node_modules/tough-cookie/lib/cookie.js57
1 files changed, 54 insertions, 3 deletions
diff --git a/node_modules/tough-cookie/lib/cookie.js b/node_modules/tough-cookie/lib/cookie.js
index 039a0e7..32dc0f8 100644
--- a/node_modules/tough-cookie/lib/cookie.js
+++ b/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;