rekwest 4.5.2 → 4.5.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/dist/ackn.js +3 -1
- package/dist/constants.js +3 -1
- package/dist/cookies.js +3 -1
- package/dist/defaults.js +3 -1
- package/dist/errors.js +3 -1
- package/dist/file.js +9 -2
- package/dist/formdata.js +3 -1
- package/dist/index.js +63 -12
- package/dist/mediatypes.js +3 -1
- package/dist/mixin.js +3 -1
- package/dist/postflight.js +6 -9
- package/dist/preflight.js +12 -2
- package/dist/transfer.js +3 -1
- package/dist/transform.js +3 -1
- package/dist/utils.js +3 -1
- package/dist/validation.js +3 -1
- package/package.json +1 -1
- package/src/postflight.mjs +4 -12
- package/src/preflight.mjs +12 -1
package/dist/ackn.js
CHANGED
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
exports
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
4
6
|
exports.requestRedirectCodes = exports.requestRedirect = exports.requestCredentials = void 0;
|
|
5
7
|
var _nodeHttp = _interopRequireDefault(require("node:http2"));
|
|
6
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/dist/cookies.js
CHANGED
package/dist/defaults.js
CHANGED
package/dist/errors.js
CHANGED
package/dist/file.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
exports
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Blob", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _nodeBuffer.Blob;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
4
12
|
exports.File = void 0;
|
|
5
13
|
var _nodeBuffer = require("node:buffer");
|
|
6
|
-
exports.Blob = _nodeBuffer.Blob;
|
|
7
14
|
var _nodeUtil = require("node:util");
|
|
8
15
|
class File extends _nodeBuffer.Blob {
|
|
9
16
|
static alike(instance) {
|
package/dist/formdata.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
exports
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
4
6
|
var _exportNames = {
|
|
5
7
|
constants: true,
|
|
6
8
|
mediatypes: true
|
|
7
9
|
};
|
|
8
|
-
exports
|
|
10
|
+
Object.defineProperty(exports, "constants", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _nodeHttp2.constants;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
9
16
|
exports.default = rekwest;
|
|
10
17
|
exports.mediatypes = void 0;
|
|
11
18
|
var _nodeHttp = _interopRequireDefault(require("node:http"));
|
|
12
19
|
var _nodeHttp2 = _interopRequireWildcard(require("node:http2"));
|
|
13
|
-
exports.constants = _nodeHttp2.constants;
|
|
14
20
|
var _nodeHttps = _interopRequireDefault(require("node:https"));
|
|
15
21
|
var _constants = require("./constants");
|
|
16
22
|
Object.keys(_constants).forEach(function (key) {
|
|
17
23
|
if (key === "default" || key === "__esModule") return;
|
|
18
24
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
19
25
|
if (key in exports && exports[key] === _constants[key]) return;
|
|
20
|
-
exports
|
|
26
|
+
Object.defineProperty(exports, key, {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () {
|
|
29
|
+
return _constants[key];
|
|
30
|
+
}
|
|
31
|
+
});
|
|
21
32
|
});
|
|
22
33
|
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
23
34
|
var _mediatypes = _interopRequireWildcard(require("./mediatypes"));
|
|
@@ -29,56 +40,96 @@ Object.keys(_utils).forEach(function (key) {
|
|
|
29
40
|
if (key === "default" || key === "__esModule") return;
|
|
30
41
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
31
42
|
if (key in exports && exports[key] === _utils[key]) return;
|
|
32
|
-
exports
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _utils[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
33
49
|
});
|
|
34
50
|
var _validation = require("./validation");
|
|
35
51
|
Object.keys(_validation).forEach(function (key) {
|
|
36
52
|
if (key === "default" || key === "__esModule") return;
|
|
37
53
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
38
54
|
if (key in exports && exports[key] === _validation[key]) return;
|
|
39
|
-
exports
|
|
55
|
+
Object.defineProperty(exports, key, {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () {
|
|
58
|
+
return _validation[key];
|
|
59
|
+
}
|
|
60
|
+
});
|
|
40
61
|
});
|
|
41
62
|
var _ackn = require("./ackn");
|
|
42
63
|
Object.keys(_ackn).forEach(function (key) {
|
|
43
64
|
if (key === "default" || key === "__esModule") return;
|
|
44
65
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
45
66
|
if (key in exports && exports[key] === _ackn[key]) return;
|
|
46
|
-
exports
|
|
67
|
+
Object.defineProperty(exports, key, {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get: function () {
|
|
70
|
+
return _ackn[key];
|
|
71
|
+
}
|
|
72
|
+
});
|
|
47
73
|
});
|
|
48
74
|
var _cookies = require("./cookies");
|
|
49
75
|
Object.keys(_cookies).forEach(function (key) {
|
|
50
76
|
if (key === "default" || key === "__esModule") return;
|
|
51
77
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
52
78
|
if (key in exports && exports[key] === _cookies[key]) return;
|
|
53
|
-
exports
|
|
79
|
+
Object.defineProperty(exports, key, {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function () {
|
|
82
|
+
return _cookies[key];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
54
85
|
});
|
|
55
86
|
var _errors = require("./errors");
|
|
56
87
|
Object.keys(_errors).forEach(function (key) {
|
|
57
88
|
if (key === "default" || key === "__esModule") return;
|
|
58
89
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
59
90
|
if (key in exports && exports[key] === _errors[key]) return;
|
|
60
|
-
exports
|
|
91
|
+
Object.defineProperty(exports, key, {
|
|
92
|
+
enumerable: true,
|
|
93
|
+
get: function () {
|
|
94
|
+
return _errors[key];
|
|
95
|
+
}
|
|
96
|
+
});
|
|
61
97
|
});
|
|
62
98
|
var _file = require("./file");
|
|
63
99
|
Object.keys(_file).forEach(function (key) {
|
|
64
100
|
if (key === "default" || key === "__esModule") return;
|
|
65
101
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
66
102
|
if (key in exports && exports[key] === _file[key]) return;
|
|
67
|
-
exports
|
|
103
|
+
Object.defineProperty(exports, key, {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
get: function () {
|
|
106
|
+
return _file[key];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
68
109
|
});
|
|
69
110
|
var _formdata = require("./formdata");
|
|
70
111
|
Object.keys(_formdata).forEach(function (key) {
|
|
71
112
|
if (key === "default" || key === "__esModule") return;
|
|
72
113
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
73
114
|
if (key in exports && exports[key] === _formdata[key]) return;
|
|
74
|
-
exports
|
|
115
|
+
Object.defineProperty(exports, key, {
|
|
116
|
+
enumerable: true,
|
|
117
|
+
get: function () {
|
|
118
|
+
return _formdata[key];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
75
121
|
});
|
|
76
122
|
var _mixin = require("./mixin");
|
|
77
123
|
Object.keys(_mixin).forEach(function (key) {
|
|
78
124
|
if (key === "default" || key === "__esModule") return;
|
|
79
125
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
80
126
|
if (key in exports && exports[key] === _mixin[key]) return;
|
|
81
|
-
exports
|
|
127
|
+
Object.defineProperty(exports, key, {
|
|
128
|
+
enumerable: true,
|
|
129
|
+
get: function () {
|
|
130
|
+
return _mixin[key];
|
|
131
|
+
}
|
|
132
|
+
});
|
|
82
133
|
});
|
|
83
134
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
84
135
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
package/dist/mediatypes.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
exports
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
4
6
|
exports.WILDCARD = exports.TEXT_PLAIN = exports.MULTIPART_FORM_DATA = exports.APPLICATION_OCTET_STREAM = exports.APPLICATION_JSON = exports.APPLICATION_FORM_URLENCODED = void 0;
|
|
5
7
|
const APPLICATION_FORM_URLENCODED = 'application/x-www-form-urlencoded';
|
|
6
8
|
exports.APPLICATION_FORM_URLENCODED = APPLICATION_FORM_URLENCODED;
|
package/dist/mixin.js
CHANGED
package/dist/postflight.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
exports
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
4
6
|
exports.postflight = void 0;
|
|
5
7
|
var _nodeHttp = _interopRequireDefault(require("node:http2"));
|
|
6
8
|
var _promises = require("node:timers/promises");
|
|
@@ -12,7 +14,6 @@ var _mixin = require("./mixin");
|
|
|
12
14
|
var _utils = require("./utils");
|
|
13
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
16
|
const {
|
|
15
|
-
HTTP2_HEADER_AUTHORIZATION,
|
|
16
17
|
HTTP2_HEADER_LOCATION,
|
|
17
18
|
HTTP2_HEADER_RETRY_AFTER,
|
|
18
19
|
HTTP2_HEADER_SET_COOKIE,
|
|
@@ -77,14 +78,10 @@ const postflight = (req, res, options, {
|
|
|
77
78
|
return res.emit('error', new _errors.RequestError('URL scheme must be "http" or "https".'));
|
|
78
79
|
}
|
|
79
80
|
if (!(0, _utils.sameOrigin)(location, url)) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
Object.keys(options.headers).filter(it => new RegExp(HTTP2_HEADER_AUTHORIZATION, 'i').test(it)).forEach(it => Reflect.deleteProperty(options.headers, it));
|
|
83
|
-
location.password = location.username = '';
|
|
84
|
-
if (credentials === _constants.requestCredentials.omit) {
|
|
85
|
-
options.cookies = false;
|
|
86
|
-
}
|
|
81
|
+
if (credentials !== _constants.requestCredentials.include) {
|
|
82
|
+
options.credentials = _constants.requestCredentials.omit;
|
|
87
83
|
}
|
|
84
|
+
options.h2 = false;
|
|
88
85
|
}
|
|
89
86
|
if (statusCode !== HTTP_STATUS_SEE_OTHER && options.body?.pipe?.constructor === Function) {
|
|
90
87
|
return res.emit('error', new _errors.RequestError(`Unable to ${redirect} redirect with streamable body.`));
|
package/dist/preflight.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
exports
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
4
6
|
exports.preflight = void 0;
|
|
5
7
|
var _nodeHttp = _interopRequireDefault(require("node:http2"));
|
|
6
8
|
var _constants = require("./constants");
|
|
@@ -11,6 +13,7 @@ const {
|
|
|
11
13
|
HTTP2_HEADER_ACCEPT,
|
|
12
14
|
HTTP2_HEADER_ACCEPT_ENCODING,
|
|
13
15
|
HTTP2_HEADER_AUTHORITY,
|
|
16
|
+
HTTP2_HEADER_AUTHORIZATION,
|
|
14
17
|
HTTP2_HEADER_COOKIE,
|
|
15
18
|
HTTP2_HEADER_METHOD,
|
|
16
19
|
HTTP2_HEADER_PATH,
|
|
@@ -30,7 +33,7 @@ const preflight = options => {
|
|
|
30
33
|
if (h2) {
|
|
31
34
|
options.endStream = [HTTP2_METHOD_GET, HTTP2_METHOD_HEAD].includes(method);
|
|
32
35
|
}
|
|
33
|
-
if (cookies !== false) {
|
|
36
|
+
if (cookies !== false && credentials !== _constants.requestCredentials.omit) {
|
|
34
37
|
let cookie = _cookies.Cookies.jar.has(url.origin);
|
|
35
38
|
if (cookies === Object(cookies) && [_constants.requestCredentials.include, _constants.requestCredentials.sameOrigin].includes(credentials)) {
|
|
36
39
|
if (cookie) {
|
|
@@ -45,6 +48,8 @@ const preflight = options => {
|
|
|
45
48
|
cookie = new _cookies.Cookies(cookies, options);
|
|
46
49
|
_cookies.Cookies.jar.set(url.origin, cookie);
|
|
47
50
|
}
|
|
51
|
+
} else {
|
|
52
|
+
cookie &&= _cookies.Cookies.jar.get(url.origin);
|
|
48
53
|
}
|
|
49
54
|
options.headers = {
|
|
50
55
|
...(cookie && {
|
|
@@ -53,6 +58,11 @@ const preflight = options => {
|
|
|
53
58
|
...headers
|
|
54
59
|
};
|
|
55
60
|
}
|
|
61
|
+
if (credentials === _constants.requestCredentials.omit) {
|
|
62
|
+
options.cookies = false;
|
|
63
|
+
Object.keys(options.headers ?? {}).filter(it => new RegExp(`^${HTTP2_HEADER_AUTHORIZATION}`, 'i').test(it)).forEach(it => Reflect.deleteProperty(options.headers, it));
|
|
64
|
+
url.password = url.username = '';
|
|
65
|
+
}
|
|
56
66
|
options.headers = {
|
|
57
67
|
[HTTP2_HEADER_ACCEPT]: `${_mediatypes.APPLICATION_JSON}, ${_mediatypes.TEXT_PLAIN}, ${_mediatypes.WILDCARD}`,
|
|
58
68
|
[HTTP2_HEADER_ACCEPT_ENCODING]: 'br, deflate, deflate-raw, gzip, identity',
|
package/dist/transfer.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
exports
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
4
6
|
exports.transfer = void 0;
|
|
5
7
|
var _nodeHttp = _interopRequireDefault(require("node:http"));
|
|
6
8
|
var _nodeHttp2 = _interopRequireDefault(require("node:http2"));
|
package/dist/transform.js
CHANGED
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
exports
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
4
6
|
exports.sameOrigin = exports.normalize = exports.merge = exports.maxRetryAfterError = exports.maxRetryAfter = exports.dispatch = exports.decompress = exports.compress = exports.brandCheck = exports.affix = exports.admix = void 0;
|
|
5
7
|
exports.tap = tap;
|
|
6
8
|
exports.unwind = exports.toCamelCase = void 0;
|
package/dist/validation.js
CHANGED
package/package.json
CHANGED
package/src/postflight.mjs
CHANGED
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
} from './utils.mjs';
|
|
17
17
|
|
|
18
18
|
const {
|
|
19
|
-
HTTP2_HEADER_AUTHORIZATION,
|
|
20
19
|
HTTP2_HEADER_LOCATION,
|
|
21
20
|
HTTP2_HEADER_RETRY_AFTER,
|
|
22
21
|
HTTP2_HEADER_SET_COOKIE,
|
|
@@ -83,18 +82,11 @@ export const postflight = (req, res, options, { reject, resolve }) => {
|
|
|
83
82
|
}
|
|
84
83
|
|
|
85
84
|
if (!sameOrigin(location, url)) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
requestCredentials.omit,
|
|
89
|
-
requestCredentials.sameOrigin,
|
|
90
|
-
].includes(credentials)) {
|
|
91
|
-
Object.keys(options.headers).filter((it) => new RegExp(HTTP2_HEADER_AUTHORIZATION, 'i').test(it))
|
|
92
|
-
.forEach((it) => Reflect.deleteProperty(options.headers, it));
|
|
93
|
-
location.password = location.username = '';
|
|
94
|
-
if (credentials === requestCredentials.omit) {
|
|
95
|
-
options.cookies = false;
|
|
96
|
-
}
|
|
85
|
+
if (credentials !== requestCredentials.include) {
|
|
86
|
+
options.credentials = requestCredentials.omit;
|
|
97
87
|
}
|
|
88
|
+
|
|
89
|
+
options.h2 = false;
|
|
98
90
|
}
|
|
99
91
|
|
|
100
92
|
if (statusCode !== HTTP_STATUS_SEE_OTHER && options.body?.pipe?.constructor === Function) {
|
package/src/preflight.mjs
CHANGED
|
@@ -11,6 +11,7 @@ const {
|
|
|
11
11
|
HTTP2_HEADER_ACCEPT,
|
|
12
12
|
HTTP2_HEADER_ACCEPT_ENCODING,
|
|
13
13
|
HTTP2_HEADER_AUTHORITY,
|
|
14
|
+
HTTP2_HEADER_AUTHORIZATION,
|
|
14
15
|
HTTP2_HEADER_COOKIE,
|
|
15
16
|
HTTP2_HEADER_METHOD,
|
|
16
17
|
HTTP2_HEADER_PATH,
|
|
@@ -29,7 +30,7 @@ export const preflight = (options) => {
|
|
|
29
30
|
].includes(method);
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
if (cookies !== false) {
|
|
33
|
+
if (cookies !== false && credentials !== requestCredentials.omit) {
|
|
33
34
|
let cookie = Cookies.jar.has(url.origin);
|
|
34
35
|
|
|
35
36
|
if (cookies === Object(cookies) && [
|
|
@@ -49,6 +50,8 @@ export const preflight = (options) => {
|
|
|
49
50
|
cookie = new Cookies(cookies, options);
|
|
50
51
|
Cookies.jar.set(url.origin, cookie);
|
|
51
52
|
}
|
|
53
|
+
} else {
|
|
54
|
+
cookie &&= Cookies.jar.get(url.origin);
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
options.headers = {
|
|
@@ -57,6 +60,14 @@ export const preflight = (options) => {
|
|
|
57
60
|
};
|
|
58
61
|
}
|
|
59
62
|
|
|
63
|
+
if (credentials === requestCredentials.omit) {
|
|
64
|
+
options.cookies = false;
|
|
65
|
+
Object.keys(options.headers ?? {})
|
|
66
|
+
.filter((it) => new RegExp(`^${ HTTP2_HEADER_AUTHORIZATION }`, 'i').test(it))
|
|
67
|
+
.forEach((it) => Reflect.deleteProperty(options.headers, it));
|
|
68
|
+
url.password = url.username = '';
|
|
69
|
+
}
|
|
70
|
+
|
|
60
71
|
options.headers = {
|
|
61
72
|
[HTTP2_HEADER_ACCEPT]: `${ APPLICATION_JSON }, ${ TEXT_PLAIN }, ${ WILDCARD }`,
|
|
62
73
|
[HTTP2_HEADER_ACCEPT_ENCODING]: 'br, deflate, deflate-raw, gzip, identity',
|