tough-cookie 3.0.1 → 4.1.1
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 +284 -215
- package/lib/cookie.js +1084 -816
- package/lib/memstore.js +190 -129
- package/lib/pathMatch.js +2 -2
- package/lib/permuteDomain.js +17 -8
- package/lib/pubsuffix-psl.js +35 -3
- package/lib/store.js +34 -33
- package/lib/utilHelper.js +39 -0
- package/lib/validators.js +95 -0
- package/lib/version.js +1 -1
- package/package.json +48 -17
package/lib/memstore.js
CHANGED
|
@@ -28,154 +28,215 @@
|
|
|
28
28
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
29
29
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
30
30
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// force a default depth:
|
|
49
|
-
MemoryCookieStore.prototype.inspect = function() {
|
|
50
|
-
return "{ idx: "+util.inspect(this.idx, false, 2)+' }';
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// Use the new custom inspection symbol to add the custom inspect function if
|
|
54
|
-
// available.
|
|
55
|
-
if (util.inspect.custom) {
|
|
56
|
-
MemoryCookieStore.prototype[util.inspect.custom] = MemoryCookieStore.prototype.inspect;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
MemoryCookieStore.prototype.findCookie = function(domain, path, key, cb) {
|
|
60
|
-
if (!this.idx[domain]) {
|
|
61
|
-
return cb(null,undefined);
|
|
31
|
+
"use strict";
|
|
32
|
+
const { fromCallback } = require("universalify");
|
|
33
|
+
const Store = require("./store").Store;
|
|
34
|
+
const permuteDomain = require("./permuteDomain").permuteDomain;
|
|
35
|
+
const pathMatch = require("./pathMatch").pathMatch;
|
|
36
|
+
const { getCustomInspectSymbol, getUtilInspect } = require("./utilHelper");
|
|
37
|
+
|
|
38
|
+
class MemoryCookieStore extends Store {
|
|
39
|
+
constructor() {
|
|
40
|
+
super();
|
|
41
|
+
this.synchronous = true;
|
|
42
|
+
this.idx = {};
|
|
43
|
+
const customInspectSymbol = getCustomInspectSymbol();
|
|
44
|
+
if (customInspectSymbol) {
|
|
45
|
+
this[customInspectSymbol] = this.inspect;
|
|
46
|
+
}
|
|
62
47
|
}
|
|
63
|
-
|
|
64
|
-
|
|
48
|
+
|
|
49
|
+
inspect() {
|
|
50
|
+
const util = { inspect: getUtilInspect(inspectFallback) };
|
|
51
|
+
return `{ idx: ${util.inspect(this.idx, false, 2)} }`;
|
|
65
52
|
}
|
|
66
|
-
return cb(null,this.idx[domain][path][key]||null);
|
|
67
|
-
};
|
|
68
53
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
54
|
+
findCookie(domain, path, key, cb) {
|
|
55
|
+
if (!this.idx[domain]) {
|
|
56
|
+
return cb(null, undefined);
|
|
57
|
+
}
|
|
58
|
+
if (!this.idx[domain][path]) {
|
|
59
|
+
return cb(null, undefined);
|
|
60
|
+
}
|
|
61
|
+
return cb(null, this.idx[domain][path][key] || null);
|
|
73
62
|
}
|
|
63
|
+
findCookies(domain, path, allowSpecialUseDomain, cb) {
|
|
64
|
+
const results = [];
|
|
65
|
+
if (typeof allowSpecialUseDomain === "function") {
|
|
66
|
+
cb = allowSpecialUseDomain;
|
|
67
|
+
allowSpecialUseDomain = true;
|
|
68
|
+
}
|
|
69
|
+
if (!domain) {
|
|
70
|
+
return cb(null, []);
|
|
71
|
+
}
|
|
74
72
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
73
|
+
let pathMatcher;
|
|
74
|
+
if (!path) {
|
|
75
|
+
// null means "all paths"
|
|
76
|
+
pathMatcher = function matchAll(domainIndex) {
|
|
77
|
+
for (const curPath in domainIndex) {
|
|
78
|
+
const pathIndex = domainIndex[curPath];
|
|
79
|
+
for (const key in pathIndex) {
|
|
80
|
+
results.push(pathIndex[key]);
|
|
81
|
+
}
|
|
83
82
|
}
|
|
83
|
+
};
|
|
84
|
+
} else {
|
|
85
|
+
pathMatcher = function matchRFC(domainIndex) {
|
|
86
|
+
//NOTE: we should use path-match algorithm from S5.1.4 here
|
|
87
|
+
//(see : https://github.com/ChromiumWebApps/chromium/blob/b3d3b4da8bb94c1b2e061600df106d590fda3620/net/cookies/canonical_cookie.cc#L299)
|
|
88
|
+
Object.keys(domainIndex).forEach(cookiePath => {
|
|
89
|
+
if (pathMatch(path, cookiePath)) {
|
|
90
|
+
const pathIndex = domainIndex[cookiePath];
|
|
91
|
+
for (const key in pathIndex) {
|
|
92
|
+
results.push(pathIndex[key]);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const domains = permuteDomain(domain, allowSpecialUseDomain) || [domain];
|
|
100
|
+
const idx = this.idx;
|
|
101
|
+
domains.forEach(curDomain => {
|
|
102
|
+
const domainIndex = idx[curDomain];
|
|
103
|
+
if (!domainIndex) {
|
|
104
|
+
return;
|
|
84
105
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
//NOTE: we should use path-match algorithm from S5.1.4 here
|
|
90
|
-
//(see : https://github.com/ChromiumWebApps/chromium/blob/b3d3b4da8bb94c1b2e061600df106d590fda3620/net/cookies/canonical_cookie.cc#L299)
|
|
91
|
-
Object.keys(domainIndex).forEach(function (cookiePath) {
|
|
92
|
-
if (pathMatch(path, cookiePath)) {
|
|
93
|
-
var pathIndex = domainIndex[cookiePath];
|
|
94
|
-
|
|
95
|
-
for (var key in pathIndex) {
|
|
96
|
-
results.push(pathIndex[key]);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
};
|
|
106
|
+
pathMatcher(domainIndex);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
cb(null, results);
|
|
101
110
|
}
|
|
102
111
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
var domainIndex = idx[curDomain];
|
|
107
|
-
if (!domainIndex) {
|
|
108
|
-
return;
|
|
112
|
+
putCookie(cookie, cb) {
|
|
113
|
+
if (!this.idx[cookie.domain]) {
|
|
114
|
+
this.idx[cookie.domain] = {};
|
|
109
115
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
MemoryCookieStore.prototype.putCookie = function(cookie, cb) {
|
|
117
|
-
if (!this.idx[cookie.domain]) {
|
|
118
|
-
this.idx[cookie.domain] = {};
|
|
116
|
+
if (!this.idx[cookie.domain][cookie.path]) {
|
|
117
|
+
this.idx[cookie.domain][cookie.path] = {};
|
|
118
|
+
}
|
|
119
|
+
this.idx[cookie.domain][cookie.path][cookie.key] = cookie;
|
|
120
|
+
cb(null);
|
|
119
121
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
updateCookie(oldCookie, newCookie, cb) {
|
|
123
|
+
// updateCookie() may avoid updating cookies that are identical. For example,
|
|
124
|
+
// lastAccessed may not be important to some stores and an equality
|
|
125
|
+
// comparison could exclude that field.
|
|
126
|
+
this.putCookie(newCookie, cb);
|
|
122
127
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
MemoryCookieStore.prototype.removeCookie = function(domain, path, key, cb) {
|
|
135
|
-
if (this.idx[domain] && this.idx[domain][path] && this.idx[domain][path][key]) {
|
|
136
|
-
delete this.idx[domain][path][key];
|
|
128
|
+
removeCookie(domain, path, key, cb) {
|
|
129
|
+
if (
|
|
130
|
+
this.idx[domain] &&
|
|
131
|
+
this.idx[domain][path] &&
|
|
132
|
+
this.idx[domain][path][key]
|
|
133
|
+
) {
|
|
134
|
+
delete this.idx[domain][path][key];
|
|
135
|
+
}
|
|
136
|
+
cb(null);
|
|
137
137
|
}
|
|
138
|
-
cb
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
} else {
|
|
146
|
-
delete this.idx[domain];
|
|
138
|
+
removeCookies(domain, path, cb) {
|
|
139
|
+
if (this.idx[domain]) {
|
|
140
|
+
if (path) {
|
|
141
|
+
delete this.idx[domain][path];
|
|
142
|
+
} else {
|
|
143
|
+
delete this.idx[domain];
|
|
144
|
+
}
|
|
147
145
|
}
|
|
146
|
+
return cb(null);
|
|
147
|
+
}
|
|
148
|
+
removeAllCookies(cb) {
|
|
149
|
+
this.idx = {};
|
|
150
|
+
return cb(null);
|
|
148
151
|
}
|
|
149
|
-
|
|
150
|
-
|
|
152
|
+
getAllCookies(cb) {
|
|
153
|
+
const cookies = [];
|
|
154
|
+
const idx = this.idx;
|
|
155
|
+
|
|
156
|
+
const domains = Object.keys(idx);
|
|
157
|
+
domains.forEach(domain => {
|
|
158
|
+
const paths = Object.keys(idx[domain]);
|
|
159
|
+
paths.forEach(path => {
|
|
160
|
+
const keys = Object.keys(idx[domain][path]);
|
|
161
|
+
keys.forEach(key => {
|
|
162
|
+
if (key !== null) {
|
|
163
|
+
cookies.push(idx[domain][path][key]);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// Sort by creationIndex so deserializing retains the creation order.
|
|
170
|
+
// When implementing your own store, this SHOULD retain the order too
|
|
171
|
+
cookies.sort((a, b) => {
|
|
172
|
+
return (a.creationIndex || 0) - (b.creationIndex || 0);
|
|
173
|
+
});
|
|
151
174
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
return cb(null);
|
|
175
|
+
cb(null, cookies);
|
|
176
|
+
}
|
|
155
177
|
}
|
|
156
178
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
179
|
+
[
|
|
180
|
+
"findCookie",
|
|
181
|
+
"findCookies",
|
|
182
|
+
"putCookie",
|
|
183
|
+
"updateCookie",
|
|
184
|
+
"removeCookie",
|
|
185
|
+
"removeCookies",
|
|
186
|
+
"removeAllCookies",
|
|
187
|
+
"getAllCookies"
|
|
188
|
+
].forEach(name => {
|
|
189
|
+
MemoryCookieStore.prototype[name] = fromCallback(
|
|
190
|
+
MemoryCookieStore.prototype[name]
|
|
191
|
+
);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
exports.MemoryCookieStore = MemoryCookieStore;
|
|
195
|
+
|
|
196
|
+
function inspectFallback(val) {
|
|
197
|
+
const domains = Object.keys(val);
|
|
198
|
+
if (domains.length === 0) {
|
|
199
|
+
return "{}";
|
|
200
|
+
}
|
|
201
|
+
let result = "{\n";
|
|
202
|
+
Object.keys(val).forEach((domain, i) => {
|
|
203
|
+
result += formatDomain(domain, val[domain]);
|
|
204
|
+
if (i < domains.length - 1) {
|
|
205
|
+
result += ",";
|
|
206
|
+
}
|
|
207
|
+
result += "\n";
|
|
172
208
|
});
|
|
209
|
+
result += "}";
|
|
210
|
+
return result;
|
|
211
|
+
}
|
|
173
212
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
213
|
+
function formatDomain(domainName, domainValue) {
|
|
214
|
+
const indent = " ";
|
|
215
|
+
let result = `${indent}'${domainName}': {\n`;
|
|
216
|
+
Object.keys(domainValue).forEach((path, i, paths) => {
|
|
217
|
+
result += formatPath(path, domainValue[path]);
|
|
218
|
+
if (i < paths.length - 1) {
|
|
219
|
+
result += ",";
|
|
220
|
+
}
|
|
221
|
+
result += "\n";
|
|
178
222
|
});
|
|
223
|
+
result += `${indent}}`;
|
|
224
|
+
return result;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function formatPath(pathName, pathValue) {
|
|
228
|
+
const indent = " ";
|
|
229
|
+
let result = `${indent}'${pathName}': {\n`;
|
|
230
|
+
Object.keys(pathValue).forEach((cookieName, i, cookieNames) => {
|
|
231
|
+
const cookie = pathValue[cookieName];
|
|
232
|
+
result += ` ${cookieName}: ${cookie.inspect()}`;
|
|
233
|
+
if (i < cookieNames.length - 1) {
|
|
234
|
+
result += ",";
|
|
235
|
+
}
|
|
236
|
+
result += "\n";
|
|
237
|
+
});
|
|
238
|
+
result += `${indent}}`;
|
|
239
|
+
return result;
|
|
240
|
+
}
|
|
179
241
|
|
|
180
|
-
|
|
181
|
-
};
|
|
242
|
+
exports.inspectFallback = inspectFallback;
|
package/lib/pathMatch.js
CHANGED
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
* "A request-path path-matches a given cookie-path if at least one of the
|
|
34
34
|
* following conditions holds:"
|
|
35
35
|
*/
|
|
36
|
-
function pathMatch
|
|
36
|
+
function pathMatch(reqPath, cookiePath) {
|
|
37
37
|
// "o The cookie-path and the request-path are identical."
|
|
38
38
|
if (cookiePath === reqPath) {
|
|
39
39
|
return true;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
const idx = reqPath.indexOf(cookiePath);
|
|
43
43
|
if (idx === 0) {
|
|
44
44
|
// "o The cookie-path is a prefix of the request-path, and the last
|
|
45
45
|
// character of the cookie-path is %x2F ("/")."
|
package/lib/permuteDomain.js
CHANGED
|
@@ -29,12 +29,16 @@
|
|
|
29
29
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
30
30
|
*/
|
|
31
31
|
"use strict";
|
|
32
|
-
|
|
32
|
+
const pubsuffix = require("./pubsuffix-psl");
|
|
33
33
|
|
|
34
34
|
// Gives the permutation of all possible domainMatch()es of a given domain. The
|
|
35
35
|
// array is in shortest-to-longest order. Handy for indexing.
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
|
|
37
|
+
function permuteDomain(domain, allowSpecialUseDomain) {
|
|
38
|
+
const pubSuf = pubsuffix.getPublicSuffix(domain, {
|
|
39
|
+
allowSpecialUseDomain: allowSpecialUseDomain
|
|
40
|
+
});
|
|
41
|
+
|
|
38
42
|
if (!pubSuf) {
|
|
39
43
|
return null;
|
|
40
44
|
}
|
|
@@ -42,12 +46,17 @@ function permuteDomain (domain) {
|
|
|
42
46
|
return [domain];
|
|
43
47
|
}
|
|
44
48
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
// Nuke trailing dot
|
|
50
|
+
if (domain.slice(-1) == ".") {
|
|
51
|
+
domain = domain.slice(0, -1);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const prefix = domain.slice(0, -(pubSuf.length + 1)); // ".example.com"
|
|
55
|
+
const parts = prefix.split(".").reverse();
|
|
56
|
+
let cur = pubSuf;
|
|
57
|
+
const permutations = [cur];
|
|
49
58
|
while (parts.length) {
|
|
50
|
-
cur = parts.shift()
|
|
59
|
+
cur = `${parts.shift()}.${cur}`;
|
|
51
60
|
permutations.push(cur);
|
|
52
61
|
}
|
|
53
62
|
return permutations;
|
package/lib/pubsuffix-psl.js
CHANGED
|
@@ -28,10 +28,42 @@
|
|
|
28
28
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
29
29
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
30
30
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
"use strict";
|
|
32
|
+
const psl = require("psl");
|
|
33
|
+
|
|
34
|
+
// RFC 6761
|
|
35
|
+
const SPECIAL_USE_DOMAINS = [
|
|
36
|
+
"local",
|
|
37
|
+
"example",
|
|
38
|
+
"invalid",
|
|
39
|
+
"localhost",
|
|
40
|
+
"test"
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
function getPublicSuffix(domain, options = {}) {
|
|
44
|
+
const domainParts = domain.split(".");
|
|
45
|
+
const topLevelDomain = domainParts[domainParts.length - 1];
|
|
46
|
+
const allowSpecialUseDomain = !!options.allowSpecialUseDomain;
|
|
47
|
+
const ignoreError = !!options.ignoreError;
|
|
48
|
+
|
|
49
|
+
if (
|
|
50
|
+
allowSpecialUseDomain &&
|
|
51
|
+
domainParts.length > 1 &&
|
|
52
|
+
SPECIAL_USE_DOMAINS.includes(topLevelDomain)
|
|
53
|
+
) {
|
|
54
|
+
// If the right-most label in the name is a special-use domain (e.g. bananas.apple.localhost),
|
|
55
|
+
// then don't use PSL. This is because most special-use domains are not listed on PSL.
|
|
56
|
+
const secondLevelDomain = domainParts[domainParts.length - 2];
|
|
57
|
+
// In aforementioned example, the eTLD/pubSuf will be apple.localhost
|
|
58
|
+
return `${secondLevelDomain}.${topLevelDomain}`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (!ignoreError && SPECIAL_USE_DOMAINS.includes(topLevelDomain)) {
|
|
62
|
+
throw new Error(
|
|
63
|
+
`Cookie has domain set to the public suffix "${topLevelDomain}" which is a special use domain. To allow this, configure your CookieJar with {allowSpecialUseDomain:true, rejectPublicSuffixes: false}.`
|
|
64
|
+
);
|
|
65
|
+
}
|
|
33
66
|
|
|
34
|
-
function getPublicSuffix(domain) {
|
|
35
67
|
return psl.get(domain);
|
|
36
68
|
}
|
|
37
69
|
|
package/lib/store.js
CHANGED
|
@@ -28,48 +28,49 @@
|
|
|
28
28
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
29
29
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
"use strict";
|
|
32
32
|
/*jshint unused:false */
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
class Store {
|
|
35
|
+
constructor() {
|
|
36
|
+
this.synchronous = false;
|
|
37
|
+
}
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
Store.prototype.synchronous = false;
|
|
39
|
+
findCookie(domain, path, key, cb) {
|
|
40
|
+
throw new Error("findCookie is not implemented");
|
|
41
|
+
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
43
|
+
findCookies(domain, path, allowSpecialUseDomain, cb) {
|
|
44
|
+
throw new Error("findCookies is not implemented");
|
|
45
|
+
}
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
47
|
+
putCookie(cookie, cb) {
|
|
48
|
+
throw new Error("putCookie is not implemented");
|
|
49
|
+
}
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
updateCookie(oldCookie, newCookie, cb) {
|
|
52
|
+
// recommended default implementation:
|
|
53
|
+
// return this.putCookie(newCookie, cb);
|
|
54
|
+
throw new Error("updateCookie is not implemented");
|
|
55
|
+
}
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
throw new Error('updateCookie is not implemented');
|
|
59
|
-
};
|
|
57
|
+
removeCookie(domain, path, key, cb) {
|
|
58
|
+
throw new Error("removeCookie is not implemented");
|
|
59
|
+
}
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
61
|
+
removeCookies(domain, path, cb) {
|
|
62
|
+
throw new Error("removeCookies is not implemented");
|
|
63
|
+
}
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
65
|
+
removeAllCookies(cb) {
|
|
66
|
+
throw new Error("removeAllCookies is not implemented");
|
|
67
|
+
}
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
getAllCookies(cb) {
|
|
70
|
+
throw new Error(
|
|
71
|
+
"getAllCookies is not implemented (therefore jar cannot be serialized)"
|
|
72
|
+
);
|
|
73
|
+
}
|
|
71
74
|
}
|
|
72
75
|
|
|
73
|
-
Store
|
|
74
|
-
throw new Error('getAllCookies is not implemented (therefore jar cannot be serialized)');
|
|
75
|
-
};
|
|
76
|
+
exports.Store = Store;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
function requireUtil() {
|
|
2
|
+
try {
|
|
3
|
+
// eslint-disable-next-line no-restricted-modules
|
|
4
|
+
return require("util");
|
|
5
|
+
} catch (e) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// for v10.12.0+
|
|
11
|
+
function lookupCustomInspectSymbol() {
|
|
12
|
+
return Symbol.for("nodejs.util.inspect.custom");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// for older node environments
|
|
16
|
+
function tryReadingCustomSymbolFromUtilInspect(options) {
|
|
17
|
+
const _requireUtil = options.requireUtil || requireUtil;
|
|
18
|
+
const util = _requireUtil();
|
|
19
|
+
return util ? util.inspect.custom : null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.getUtilInspect = function getUtilInspect(fallback, options = {}) {
|
|
23
|
+
const _requireUtil = options.requireUtil || requireUtil;
|
|
24
|
+
const util = _requireUtil();
|
|
25
|
+
return function inspect(value, showHidden, depth) {
|
|
26
|
+
return util ? util.inspect(value, showHidden, depth) : fallback(value);
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports.getCustomInspectSymbol = function getCustomInspectSymbol(options = {}) {
|
|
31
|
+
const _lookupCustomInspectSymbol =
|
|
32
|
+
options.lookupCustomInspectSymbol || lookupCustomInspectSymbol;
|
|
33
|
+
|
|
34
|
+
// get custom inspect symbol for node environments
|
|
35
|
+
return (
|
|
36
|
+
_lookupCustomInspectSymbol() ||
|
|
37
|
+
tryReadingCustomSymbolFromUtilInspect(options)
|
|
38
|
+
);
|
|
39
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/* ************************************************************************************
|
|
2
|
+
Extracted from check-types.js
|
|
3
|
+
https://gitlab.com/philbooth/check-types.js
|
|
4
|
+
|
|
5
|
+
MIT License
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Phil Booth
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
************************************************************************************ */
|
|
28
|
+
"use strict";
|
|
29
|
+
|
|
30
|
+
/* Validation functions copied from check-types package - https://www.npmjs.com/package/check-types */
|
|
31
|
+
function isFunction(data) {
|
|
32
|
+
return typeof data === "function";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function isNonEmptyString(data) {
|
|
36
|
+
return isString(data) && data !== "";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function isDate(data) {
|
|
40
|
+
return isInstanceStrict(data, Date) && isInteger(data.getTime());
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function isEmptyString(data) {
|
|
44
|
+
return data === "" || (data instanceof String && data.toString() === "");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function isString(data) {
|
|
48
|
+
return typeof data === "string" || data instanceof String;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function isObject(data) {
|
|
52
|
+
return toString.call(data) === "[object Object]";
|
|
53
|
+
}
|
|
54
|
+
function isInstanceStrict(data, prototype) {
|
|
55
|
+
try {
|
|
56
|
+
return data instanceof prototype;
|
|
57
|
+
} catch (error) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function isInteger(data) {
|
|
63
|
+
return typeof data === "number" && data % 1 === 0;
|
|
64
|
+
}
|
|
65
|
+
/* End validation functions */
|
|
66
|
+
|
|
67
|
+
function validate(bool, cb, options) {
|
|
68
|
+
if (!isFunction(cb)) {
|
|
69
|
+
options = cb;
|
|
70
|
+
cb = null;
|
|
71
|
+
}
|
|
72
|
+
if (!isObject(options)) options = { Error: "Failed Check" };
|
|
73
|
+
if (!bool) {
|
|
74
|
+
if (cb) {
|
|
75
|
+
cb(new ParameterError(options));
|
|
76
|
+
} else {
|
|
77
|
+
throw new ParameterError(options);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
class ParameterError extends Error {
|
|
83
|
+
constructor(...params) {
|
|
84
|
+
super(...params);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
exports.ParameterError = ParameterError;
|
|
89
|
+
exports.isFunction = isFunction;
|
|
90
|
+
exports.isNonEmptyString = isNonEmptyString;
|
|
91
|
+
exports.isDate = isDate;
|
|
92
|
+
exports.isEmptyString = isEmptyString;
|
|
93
|
+
exports.isString = isString;
|
|
94
|
+
exports.isObject = isObject;
|
|
95
|
+
exports.validate = validate;
|
package/lib/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
module.exports = '
|
|
2
|
+
module.exports = '4.1.1'
|