tough-cookie 4.1.2 → 4.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -406,7 +406,7 @@ Retrieve a cookie with the given domain, path, and key (name). The RFC maintains
406
406
 
407
407
  Callback takes an error and the resulting `Cookie` object. If no cookie is found then `null` MUST be passed instead (that is, not an error).
408
408
 
409
- #### `store.findCookies(domain, path, callback(err, cookies))`
409
+ #### `store.findCookies(domain, path, allowSpecialUseDomain, callback(err, cookies))`
410
410
 
411
411
  Locates cookies matching the given domain and path. This is most often called in the context of [`cookiejar.getCookies()`](#getcookiescurrenturl-options-callbackerr-cookies).
412
412
 
package/lib/cookie.js CHANGED
@@ -1116,7 +1116,8 @@ class CookieJar {
1116
1116
  }
1117
1117
 
1118
1118
  setCookie(cookie, url, options, cb) {
1119
- validators.validate(validators.isNonEmptyString(url), cb, options);
1119
+ validators.validate(validators.isUrlStringOrObject(url), cb, options);
1120
+
1120
1121
  let err;
1121
1122
 
1122
1123
  if (validators.isFunction(url)) {
@@ -1314,7 +1315,8 @@ class CookieJar {
1314
1315
 
1315
1316
  // RFC6365 S5.4
1316
1317
  getCookies(url, options, cb) {
1317
- validators.validate(validators.isNonEmptyString(url), cb, url);
1318
+ validators.validate(validators.isUrlStringOrObject(url), cb, url);
1319
+
1318
1320
  const context = getCookieContext(url);
1319
1321
  if (validators.isFunction(options)) {
1320
1322
  cb = options;
package/lib/memstore.js CHANGED
@@ -39,7 +39,7 @@ class MemoryCookieStore extends Store {
39
39
  constructor() {
40
40
  super();
41
41
  this.synchronous = true;
42
- this.idx = {};
42
+ this.idx = Object.create(null);
43
43
  const customInspectSymbol = getCustomInspectSymbol();
44
44
  if (customInspectSymbol) {
45
45
  this[customInspectSymbol] = this.inspect;
@@ -111,10 +111,10 @@ class MemoryCookieStore extends Store {
111
111
 
112
112
  putCookie(cookie, cb) {
113
113
  if (!this.idx[cookie.domain]) {
114
- this.idx[cookie.domain] = {};
114
+ this.idx[cookie.domain] = Object.create(null);
115
115
  }
116
116
  if (!this.idx[cookie.domain][cookie.path]) {
117
- this.idx[cookie.domain][cookie.path] = {};
117
+ this.idx[cookie.domain][cookie.path] = Object.create(null);
118
118
  }
119
119
  this.idx[cookie.domain][cookie.path][cookie.key] = cookie;
120
120
  cb(null);
@@ -146,7 +146,7 @@ class MemoryCookieStore extends Store {
146
146
  return cb(null);
147
147
  }
148
148
  removeAllCookies(cb) {
149
- this.idx = {};
149
+ this.idx = Object.create(null);
150
150
  return cb(null);
151
151
  }
152
152
  getAllCookies(cb) {
@@ -196,9 +196,9 @@ exports.MemoryCookieStore = MemoryCookieStore;
196
196
  function inspectFallback(val) {
197
197
  const domains = Object.keys(val);
198
198
  if (domains.length === 0) {
199
- return "{}";
199
+ return "[Object: null prototype] {}";
200
200
  }
201
- let result = "{\n";
201
+ let result = "[Object: null prototype] {\n";
202
202
  Object.keys(val).forEach((domain, i) => {
203
203
  result += formatDomain(domain, val[domain]);
204
204
  if (i < domains.length - 1) {
@@ -212,7 +212,7 @@ function inspectFallback(val) {
212
212
 
213
213
  function formatDomain(domainName, domainValue) {
214
214
  const indent = " ";
215
- let result = `${indent}'${domainName}': {\n`;
215
+ let result = `${indent}'${domainName}': [Object: null prototype] {\n`;
216
216
  Object.keys(domainValue).forEach((path, i, paths) => {
217
217
  result += formatPath(path, domainValue[path]);
218
218
  if (i < paths.length - 1) {
@@ -226,7 +226,7 @@ function formatDomain(domainName, domainValue) {
226
226
 
227
227
  function formatPath(pathName, pathValue) {
228
228
  const indent = " ";
229
- let result = `${indent}'${pathName}': {\n`;
229
+ let result = `${indent}'${pathName}': [Object: null prototype] {\n`;
230
230
  Object.keys(pathValue).forEach((cookieName, i, cookieNames) => {
231
231
  const cookie = pathValue[cookieName];
232
232
  result += ` ${cookieName}: ${cookie.inspect()}`;
package/lib/validators.js CHANGED
@@ -28,6 +28,9 @@ SOFTWARE.
28
28
  "use strict";
29
29
 
30
30
  /* Validation functions copied from check-types package - https://www.npmjs.com/package/check-types */
31
+
32
+ const toString = Object.prototype.toString;
33
+
31
34
  function isFunction(data) {
32
35
  return typeof data === "function";
33
36
  }
@@ -59,6 +62,17 @@ function isInstanceStrict(data, prototype) {
59
62
  }
60
63
  }
61
64
 
65
+ function isUrlStringOrObject(data) {
66
+ return (
67
+ isNonEmptyString(data) ||
68
+ (isObject(data) &&
69
+ "hostname" in data &&
70
+ "pathname" in data &&
71
+ "protocol" in data) ||
72
+ isInstanceStrict(data, URL)
73
+ );
74
+ }
75
+
62
76
  function isInteger(data) {
63
77
  return typeof data === "number" && data % 1 === 0;
64
78
  }
@@ -92,4 +106,5 @@ exports.isDate = isDate;
92
106
  exports.isEmptyString = isEmptyString;
93
107
  exports.isString = isString;
94
108
  exports.isObject = isObject;
109
+ exports.isUrlStringOrObject = isUrlStringOrObject;
95
110
  exports.validate = validate;
package/lib/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- module.exports = '4.1.2'
2
+ module.exports = '4.1.4'
package/package.json CHANGED
@@ -67,7 +67,7 @@
67
67
  "RFC6265",
68
68
  "RFC2965"
69
69
  ],
70
- "version": "4.1.2",
70
+ "version": "4.1.4",
71
71
  "homepage": "https://github.com/salesforce/tough-cookie",
72
72
  "repository": {
73
73
  "type": "git",