rezo 1.0.29 → 1.0.31
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/adapters/curl.cjs +8 -10
- package/dist/adapters/curl.js +8 -10
- package/dist/adapters/entries/curl.d.ts +169 -313
- package/dist/adapters/entries/fetch.d.ts +169 -313
- package/dist/adapters/entries/http.d.ts +169 -313
- package/dist/adapters/entries/http2.d.ts +169 -313
- package/dist/adapters/entries/react-native.d.ts +169 -313
- package/dist/adapters/entries/xhr.d.ts +169 -313
- package/dist/adapters/fetch.cjs +10 -7
- package/dist/adapters/fetch.js +10 -7
- package/dist/adapters/http.cjs +9 -12
- package/dist/adapters/http.js +9 -12
- package/dist/adapters/http2.cjs +6 -11
- package/dist/adapters/http2.js +6 -11
- package/dist/adapters/index.cjs +6 -6
- package/dist/adapters/react-native.cjs +4 -4
- package/dist/adapters/react-native.js +4 -4
- package/dist/adapters/xhr.cjs +4 -4
- package/dist/adapters/xhr.js +4 -4
- package/dist/cache/index.cjs +13 -13
- package/dist/cache/universal-response-cache.cjs +156 -0
- package/dist/cache/universal-response-cache.js +155 -0
- package/dist/core/rezo.cjs +2 -8
- package/dist/core/rezo.js +2 -8
- package/dist/crawler.d.ts +163 -313
- package/dist/entries/crawler.cjs +5 -5
- package/dist/index.cjs +24 -24
- package/dist/index.d.ts +169 -313
- package/dist/platform/browser.d.ts +169 -313
- package/dist/platform/bun.d.ts +169 -313
- package/dist/platform/deno.d.ts +169 -313
- package/dist/platform/node.d.ts +169 -313
- package/dist/platform/react-native.d.ts +169 -313
- package/dist/platform/worker.d.ts +169 -313
- package/dist/plugin/crawler.cjs +1 -1
- package/dist/plugin/crawler.js +1 -1
- package/dist/plugin/index.cjs +36 -36
- package/dist/proxy/index.cjs +5 -80
- package/dist/proxy/index.js +2 -77
- package/dist/proxy/parse.cjs +79 -0
- package/dist/proxy/parse.js +77 -0
- package/dist/queue/index.cjs +8 -8
- package/dist/responses/buildResponse.cjs +15 -15
- package/dist/responses/buildResponse.js +15 -15
- package/dist/responses/universal/download.cjs +23 -0
- package/dist/responses/universal/download.js +22 -0
- package/dist/responses/universal/event-emitter.cjs +104 -0
- package/dist/responses/universal/event-emitter.js +102 -0
- package/dist/responses/universal/index.cjs +11 -0
- package/dist/responses/universal/index.js +4 -0
- package/dist/responses/universal/stream.cjs +32 -0
- package/dist/responses/universal/stream.js +31 -0
- package/dist/responses/universal/upload.cjs +23 -0
- package/dist/responses/universal/upload.js +22 -0
- package/dist/utils/cookies.browser.cjs +63 -0
- package/dist/utils/cookies.browser.js +61 -0
- package/dist/utils/form-data.cjs +212 -189
- package/dist/utils/form-data.js +212 -189
- package/dist/utils/http-config.cjs +41 -21
- package/dist/utils/http-config.js +41 -21
- package/package.json +11 -4
- package/dist/types/cookies.cjs +0 -394
- package/dist/types/cookies.js +0 -391
package/dist/plugin/index.cjs
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
const
|
|
2
|
-
exports.Crawler =
|
|
3
|
-
const
|
|
4
|
-
exports.CrawlerOptions =
|
|
5
|
-
const
|
|
6
|
-
exports.FileCacher =
|
|
7
|
-
const
|
|
8
|
-
exports.UrlStore =
|
|
9
|
-
const
|
|
10
|
-
exports.Oxylabs =
|
|
11
|
-
const
|
|
12
|
-
exports.OXYLABS_BROWSER_TYPES =
|
|
13
|
-
exports.OXYLABS_COMMON_LOCALES =
|
|
14
|
-
exports.OXYLABS_COMMON_GEO_LOCATIONS =
|
|
15
|
-
exports.OXYLABS_US_STATES =
|
|
16
|
-
exports.OXYLABS_EUROPEAN_COUNTRIES =
|
|
17
|
-
exports.OXYLABS_ASIAN_COUNTRIES =
|
|
18
|
-
exports.getRandomOxylabsBrowserType =
|
|
19
|
-
exports.getRandomOxylabsLocale =
|
|
20
|
-
exports.getRandomOxylabsGeoLocation =
|
|
21
|
-
const
|
|
22
|
-
exports.Decodo =
|
|
23
|
-
const
|
|
24
|
-
exports.DECODO_DEVICE_TYPES =
|
|
25
|
-
exports.DECODO_HEADLESS_MODES =
|
|
26
|
-
exports.DECODO_COMMON_LOCALES =
|
|
27
|
-
exports.DECODO_COMMON_COUNTRIES =
|
|
28
|
-
exports.DECODO_EUROPEAN_COUNTRIES =
|
|
29
|
-
exports.DECODO_ASIAN_COUNTRIES =
|
|
30
|
-
exports.DECODO_US_STATES =
|
|
31
|
-
exports.DECODO_COMMON_CITIES =
|
|
32
|
-
exports.getRandomDecodoDeviceType =
|
|
33
|
-
exports.getRandomDecodoLocale =
|
|
34
|
-
exports.getRandomDecodoCountry =
|
|
35
|
-
exports.getRandomDecodoCity =
|
|
36
|
-
exports.generateDecodoSessionId =
|
|
1
|
+
const _mod_ozd9xa = require('./crawler.cjs');
|
|
2
|
+
exports.Crawler = _mod_ozd9xa.Crawler;;
|
|
3
|
+
const _mod_75ajju = require('./crawler-options.cjs');
|
|
4
|
+
exports.CrawlerOptions = _mod_75ajju.CrawlerOptions;;
|
|
5
|
+
const _mod_xamy9c = require('../cache/file-cacher.cjs');
|
|
6
|
+
exports.FileCacher = _mod_xamy9c.FileCacher;;
|
|
7
|
+
const _mod_ll052q = require('../cache/url-store.cjs');
|
|
8
|
+
exports.UrlStore = _mod_ll052q.UrlStore;;
|
|
9
|
+
const _mod_saehzf = require('./addon/oxylabs/index.cjs');
|
|
10
|
+
exports.Oxylabs = _mod_saehzf.Oxylabs;;
|
|
11
|
+
const _mod_mgemv8 = require('./addon/oxylabs/options.cjs');
|
|
12
|
+
exports.OXYLABS_BROWSER_TYPES = _mod_mgemv8.OXYLABS_BROWSER_TYPES;
|
|
13
|
+
exports.OXYLABS_COMMON_LOCALES = _mod_mgemv8.OXYLABS_COMMON_LOCALES;
|
|
14
|
+
exports.OXYLABS_COMMON_GEO_LOCATIONS = _mod_mgemv8.OXYLABS_COMMON_GEO_LOCATIONS;
|
|
15
|
+
exports.OXYLABS_US_STATES = _mod_mgemv8.OXYLABS_US_STATES;
|
|
16
|
+
exports.OXYLABS_EUROPEAN_COUNTRIES = _mod_mgemv8.OXYLABS_EUROPEAN_COUNTRIES;
|
|
17
|
+
exports.OXYLABS_ASIAN_COUNTRIES = _mod_mgemv8.OXYLABS_ASIAN_COUNTRIES;
|
|
18
|
+
exports.getRandomOxylabsBrowserType = _mod_mgemv8.getRandomBrowserType;
|
|
19
|
+
exports.getRandomOxylabsLocale = _mod_mgemv8.getRandomLocale;
|
|
20
|
+
exports.getRandomOxylabsGeoLocation = _mod_mgemv8.getRandomGeoLocation;;
|
|
21
|
+
const _mod_ad0knl = require('./addon/decodo/index.cjs');
|
|
22
|
+
exports.Decodo = _mod_ad0knl.Decodo;;
|
|
23
|
+
const _mod_0gdkhq = require('./addon/decodo/options.cjs');
|
|
24
|
+
exports.DECODO_DEVICE_TYPES = _mod_0gdkhq.DECODO_DEVICE_TYPES;
|
|
25
|
+
exports.DECODO_HEADLESS_MODES = _mod_0gdkhq.DECODO_HEADLESS_MODES;
|
|
26
|
+
exports.DECODO_COMMON_LOCALES = _mod_0gdkhq.DECODO_COMMON_LOCALES;
|
|
27
|
+
exports.DECODO_COMMON_COUNTRIES = _mod_0gdkhq.DECODO_COMMON_COUNTRIES;
|
|
28
|
+
exports.DECODO_EUROPEAN_COUNTRIES = _mod_0gdkhq.DECODO_EUROPEAN_COUNTRIES;
|
|
29
|
+
exports.DECODO_ASIAN_COUNTRIES = _mod_0gdkhq.DECODO_ASIAN_COUNTRIES;
|
|
30
|
+
exports.DECODO_US_STATES = _mod_0gdkhq.DECODO_US_STATES;
|
|
31
|
+
exports.DECODO_COMMON_CITIES = _mod_0gdkhq.DECODO_COMMON_CITIES;
|
|
32
|
+
exports.getRandomDecodoDeviceType = _mod_0gdkhq.getRandomDeviceType;
|
|
33
|
+
exports.getRandomDecodoLocale = _mod_0gdkhq.getRandomLocale;
|
|
34
|
+
exports.getRandomDecodoCountry = _mod_0gdkhq.getRandomCountry;
|
|
35
|
+
exports.getRandomDecodoCity = _mod_0gdkhq.getRandomCity;
|
|
36
|
+
exports.generateDecodoSessionId = _mod_0gdkhq.generateSessionId;;
|
package/dist/proxy/index.cjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
const { SocksProxyAgent: RezoSocksProxy } = require("socks-proxy-agent");
|
|
2
2
|
const { HttpsProxyAgent: RezoHttpsSocks } = require("https-proxy-agent");
|
|
3
3
|
const { HttpProxyAgent: RezoHttpSocks } = require("http-proxy-agent");
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const { parseProxyString } = require('./parse.cjs');
|
|
5
|
+
const _mod_6fvk9y = require('./manager.cjs');
|
|
6
|
+
exports.ProxyManager = _mod_6fvk9y.ProxyManager;;
|
|
7
|
+
const _mod_n5bh9r = require('./parse.cjs');
|
|
8
|
+
exports.parseProxyString = _mod_n5bh9r.parseProxyString;;
|
|
6
9
|
function createOptions(uri, opts) {
|
|
7
10
|
if (uri instanceof URL || typeof uri === "string") {
|
|
8
11
|
return {
|
|
@@ -18,83 +21,6 @@ function createOptions(uri, opts) {
|
|
|
18
21
|
uri: `${protocol}://${authstr}${host}:${port}`
|
|
19
22
|
};
|
|
20
23
|
}
|
|
21
|
-
function isIPv4(host) {
|
|
22
|
-
const ipv4Regex = /^(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)){3}$/;
|
|
23
|
-
return ipv4Regex.test(host);
|
|
24
|
-
}
|
|
25
|
-
function isDomain(host) {
|
|
26
|
-
const domainRegex = /^(?=.{1,253}$)(?!-)([a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,63}$/;
|
|
27
|
-
return domainRegex.test(host);
|
|
28
|
-
}
|
|
29
|
-
function isNumeric(value) {
|
|
30
|
-
if (typeof value === "number")
|
|
31
|
-
return isFinite(value);
|
|
32
|
-
if (typeof value === "string" && value.trim() !== "") {
|
|
33
|
-
return !isNaN(Number(value));
|
|
34
|
-
}
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
function parseProxyString(input) {
|
|
38
|
-
if (!input)
|
|
39
|
-
return null;
|
|
40
|
-
let host = "";
|
|
41
|
-
let port = 0;
|
|
42
|
-
let username;
|
|
43
|
-
let password;
|
|
44
|
-
const proto = input.includes("://") ? input.split("://")[0].toLowerCase() : "";
|
|
45
|
-
const protocol = proto.startsWith("http") ? "http" : proto.startsWith("https") ? "https" : "socks5";
|
|
46
|
-
if (protocol !== "socks5" || input.includes("://")) {
|
|
47
|
-
input = input.split("://")[1];
|
|
48
|
-
}
|
|
49
|
-
const getProxy = (authPart, hostPart) => {
|
|
50
|
-
if (authPart && authPart.includes(":")) {
|
|
51
|
-
const [p1, ..._p2] = authPart.split(":");
|
|
52
|
-
const p2 = _p2.join(":");
|
|
53
|
-
if ((isIPv4(p1) || isDomain(p1)) && isNumeric(p2)) {
|
|
54
|
-
host = p1;
|
|
55
|
-
port = parseInt(p2, 10);
|
|
56
|
-
} else {
|
|
57
|
-
username = p1;
|
|
58
|
-
password = p2;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
if (hostPart && hostPart.includes(":")) {
|
|
62
|
-
const [p1, ..._p2] = hostPart.split(":");
|
|
63
|
-
const p2 = _p2.join(":");
|
|
64
|
-
if ((isIPv4(p1) || isDomain(p1)) && isNumeric(p2)) {
|
|
65
|
-
host = p1;
|
|
66
|
-
port = parseInt(p2, 10);
|
|
67
|
-
} else {
|
|
68
|
-
username = p1;
|
|
69
|
-
password = p2;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (!host && !port)
|
|
73
|
-
return null;
|
|
74
|
-
if (username && password) {
|
|
75
|
-
return { protocol, host, port, auth: { username, password } };
|
|
76
|
-
}
|
|
77
|
-
return {
|
|
78
|
-
protocol,
|
|
79
|
-
host,
|
|
80
|
-
port
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
input = input.trim();
|
|
84
|
-
if (input.includes("@")) {
|
|
85
|
-
const [authPart, hostPart] = input.split("@");
|
|
86
|
-
if (!authPart && !hostPart)
|
|
87
|
-
return null;
|
|
88
|
-
return getProxy(authPart, hostPart);
|
|
89
|
-
} else if (input.split(":").length === 4 || input.split(":").length === 2) {
|
|
90
|
-
const parts = input.split(":");
|
|
91
|
-
const authPart = input.split(":").length === 2 ? undefined : parts[2] + ":" + parts[3];
|
|
92
|
-
const hostPart = parts[0] + ":" + parts[1];
|
|
93
|
-
return getProxy(authPart || "", hostPart || "");
|
|
94
|
-
} else {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
24
|
function rezoProxy(uri, over, opts) {
|
|
99
25
|
if (typeof uri === "string") {
|
|
100
26
|
if (typeof over === "string") {
|
|
@@ -139,5 +65,4 @@ function rezoProxy(uri, over, opts) {
|
|
|
139
65
|
return new RezoSocksProxy(config.uri, config.opts);
|
|
140
66
|
}
|
|
141
67
|
|
|
142
|
-
exports.parseProxyString = parseProxyString;
|
|
143
68
|
exports.rezoProxy = rezoProxy;
|
package/dist/proxy/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { SocksProxyAgent as RezoSocksProxy } from "socks-proxy-agent";
|
|
2
2
|
import { HttpsProxyAgent as RezoHttpsSocks } from "https-proxy-agent";
|
|
3
3
|
import { HttpProxyAgent as RezoHttpSocks } from "http-proxy-agent";
|
|
4
|
+
import { parseProxyString } from './parse.js';
|
|
4
5
|
export { ProxyManager } from './manager.js';
|
|
6
|
+
export { parseProxyString } from './parse.js';
|
|
5
7
|
function createOptions(uri, opts) {
|
|
6
8
|
if (uri instanceof URL || typeof uri === "string") {
|
|
7
9
|
return {
|
|
@@ -17,83 +19,6 @@ function createOptions(uri, opts) {
|
|
|
17
19
|
uri: `${protocol}://${authstr}${host}:${port}`
|
|
18
20
|
};
|
|
19
21
|
}
|
|
20
|
-
function isIPv4(host) {
|
|
21
|
-
const ipv4Regex = /^(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)){3}$/;
|
|
22
|
-
return ipv4Regex.test(host);
|
|
23
|
-
}
|
|
24
|
-
function isDomain(host) {
|
|
25
|
-
const domainRegex = /^(?=.{1,253}$)(?!-)([a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,63}$/;
|
|
26
|
-
return domainRegex.test(host);
|
|
27
|
-
}
|
|
28
|
-
function isNumeric(value) {
|
|
29
|
-
if (typeof value === "number")
|
|
30
|
-
return isFinite(value);
|
|
31
|
-
if (typeof value === "string" && value.trim() !== "") {
|
|
32
|
-
return !isNaN(Number(value));
|
|
33
|
-
}
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
export function parseProxyString(input) {
|
|
37
|
-
if (!input)
|
|
38
|
-
return null;
|
|
39
|
-
let host = "";
|
|
40
|
-
let port = 0;
|
|
41
|
-
let username;
|
|
42
|
-
let password;
|
|
43
|
-
const proto = input.includes("://") ? input.split("://")[0].toLowerCase() : "";
|
|
44
|
-
const protocol = proto.startsWith("http") ? "http" : proto.startsWith("https") ? "https" : "socks5";
|
|
45
|
-
if (protocol !== "socks5" || input.includes("://")) {
|
|
46
|
-
input = input.split("://")[1];
|
|
47
|
-
}
|
|
48
|
-
const getProxy = (authPart, hostPart) => {
|
|
49
|
-
if (authPart && authPart.includes(":")) {
|
|
50
|
-
const [p1, ..._p2] = authPart.split(":");
|
|
51
|
-
const p2 = _p2.join(":");
|
|
52
|
-
if ((isIPv4(p1) || isDomain(p1)) && isNumeric(p2)) {
|
|
53
|
-
host = p1;
|
|
54
|
-
port = parseInt(p2, 10);
|
|
55
|
-
} else {
|
|
56
|
-
username = p1;
|
|
57
|
-
password = p2;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
if (hostPart && hostPart.includes(":")) {
|
|
61
|
-
const [p1, ..._p2] = hostPart.split(":");
|
|
62
|
-
const p2 = _p2.join(":");
|
|
63
|
-
if ((isIPv4(p1) || isDomain(p1)) && isNumeric(p2)) {
|
|
64
|
-
host = p1;
|
|
65
|
-
port = parseInt(p2, 10);
|
|
66
|
-
} else {
|
|
67
|
-
username = p1;
|
|
68
|
-
password = p2;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (!host && !port)
|
|
72
|
-
return null;
|
|
73
|
-
if (username && password) {
|
|
74
|
-
return { protocol, host, port, auth: { username, password } };
|
|
75
|
-
}
|
|
76
|
-
return {
|
|
77
|
-
protocol,
|
|
78
|
-
host,
|
|
79
|
-
port
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
input = input.trim();
|
|
83
|
-
if (input.includes("@")) {
|
|
84
|
-
const [authPart, hostPart] = input.split("@");
|
|
85
|
-
if (!authPart && !hostPart)
|
|
86
|
-
return null;
|
|
87
|
-
return getProxy(authPart, hostPart);
|
|
88
|
-
} else if (input.split(":").length === 4 || input.split(":").length === 2) {
|
|
89
|
-
const parts = input.split(":");
|
|
90
|
-
const authPart = input.split(":").length === 2 ? undefined : parts[2] + ":" + parts[3];
|
|
91
|
-
const hostPart = parts[0] + ":" + parts[1];
|
|
92
|
-
return getProxy(authPart || "", hostPart || "");
|
|
93
|
-
} else {
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
22
|
export function rezoProxy(uri, over, opts) {
|
|
98
23
|
if (typeof uri === "string") {
|
|
99
24
|
if (typeof over === "string") {
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
function isIPv4(host) {
|
|
2
|
+
const ipv4Regex = /^(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)){3}$/;
|
|
3
|
+
return ipv4Regex.test(host);
|
|
4
|
+
}
|
|
5
|
+
function isDomain(host) {
|
|
6
|
+
const domainRegex = /^(?=.{1,253}$)(?!-)([a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,63}$/;
|
|
7
|
+
return domainRegex.test(host);
|
|
8
|
+
}
|
|
9
|
+
function isNumeric(value) {
|
|
10
|
+
if (typeof value === "number")
|
|
11
|
+
return isFinite(value);
|
|
12
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
13
|
+
return !isNaN(Number(value));
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
function parseProxyString(input) {
|
|
18
|
+
if (!input)
|
|
19
|
+
return null;
|
|
20
|
+
let host = "";
|
|
21
|
+
let port = 0;
|
|
22
|
+
let username;
|
|
23
|
+
let password;
|
|
24
|
+
const proto = input.includes("://") ? input.split("://")[0].toLowerCase() : "";
|
|
25
|
+
const protocol = proto.startsWith("http") ? "http" : proto.startsWith("https") ? "https" : "socks5";
|
|
26
|
+
if (protocol !== "socks5" || input.includes("://")) {
|
|
27
|
+
input = input.split("://")[1];
|
|
28
|
+
}
|
|
29
|
+
const getProxy = (authPart, hostPart) => {
|
|
30
|
+
if (authPart && authPart.includes(":")) {
|
|
31
|
+
const [p1, ..._p2] = authPart.split(":");
|
|
32
|
+
const p2 = _p2.join(":");
|
|
33
|
+
if ((isIPv4(p1) || isDomain(p1)) && isNumeric(p2)) {
|
|
34
|
+
host = p1;
|
|
35
|
+
port = parseInt(p2, 10);
|
|
36
|
+
} else {
|
|
37
|
+
username = p1;
|
|
38
|
+
password = p2;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (hostPart && hostPart.includes(":")) {
|
|
42
|
+
const [p1, ..._p2] = hostPart.split(":");
|
|
43
|
+
const p2 = _p2.join(":");
|
|
44
|
+
if ((isIPv4(p1) || isDomain(p1)) && isNumeric(p2)) {
|
|
45
|
+
host = p1;
|
|
46
|
+
port = parseInt(p2, 10);
|
|
47
|
+
} else {
|
|
48
|
+
username = p1;
|
|
49
|
+
password = p2;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (!host && !port)
|
|
53
|
+
return null;
|
|
54
|
+
if (username && password) {
|
|
55
|
+
return { protocol, host, port, auth: { username, password } };
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
protocol,
|
|
59
|
+
host,
|
|
60
|
+
port
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
input = input.trim();
|
|
64
|
+
if (input.includes("@")) {
|
|
65
|
+
const [authPart, hostPart] = input.split("@");
|
|
66
|
+
if (!authPart && !hostPart)
|
|
67
|
+
return null;
|
|
68
|
+
return getProxy(authPart, hostPart);
|
|
69
|
+
} else if (input.split(":").length === 4 || input.split(":").length === 2) {
|
|
70
|
+
const parts = input.split(":");
|
|
71
|
+
const authPart = input.split(":").length === 2 ? undefined : parts[2] + ":" + parts[3];
|
|
72
|
+
const hostPart = parts[0] + ":" + parts[1];
|
|
73
|
+
return getProxy(authPart || "", hostPart || "");
|
|
74
|
+
} else {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
exports.parseProxyString = parseProxyString;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
function isIPv4(host) {
|
|
2
|
+
const ipv4Regex = /^(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)){3}$/;
|
|
3
|
+
return ipv4Regex.test(host);
|
|
4
|
+
}
|
|
5
|
+
function isDomain(host) {
|
|
6
|
+
const domainRegex = /^(?=.{1,253}$)(?!-)([a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,63}$/;
|
|
7
|
+
return domainRegex.test(host);
|
|
8
|
+
}
|
|
9
|
+
function isNumeric(value) {
|
|
10
|
+
if (typeof value === "number")
|
|
11
|
+
return isFinite(value);
|
|
12
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
13
|
+
return !isNaN(Number(value));
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
export function parseProxyString(input) {
|
|
18
|
+
if (!input)
|
|
19
|
+
return null;
|
|
20
|
+
let host = "";
|
|
21
|
+
let port = 0;
|
|
22
|
+
let username;
|
|
23
|
+
let password;
|
|
24
|
+
const proto = input.includes("://") ? input.split("://")[0].toLowerCase() : "";
|
|
25
|
+
const protocol = proto.startsWith("http") ? "http" : proto.startsWith("https") ? "https" : "socks5";
|
|
26
|
+
if (protocol !== "socks5" || input.includes("://")) {
|
|
27
|
+
input = input.split("://")[1];
|
|
28
|
+
}
|
|
29
|
+
const getProxy = (authPart, hostPart) => {
|
|
30
|
+
if (authPart && authPart.includes(":")) {
|
|
31
|
+
const [p1, ..._p2] = authPart.split(":");
|
|
32
|
+
const p2 = _p2.join(":");
|
|
33
|
+
if ((isIPv4(p1) || isDomain(p1)) && isNumeric(p2)) {
|
|
34
|
+
host = p1;
|
|
35
|
+
port = parseInt(p2, 10);
|
|
36
|
+
} else {
|
|
37
|
+
username = p1;
|
|
38
|
+
password = p2;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (hostPart && hostPart.includes(":")) {
|
|
42
|
+
const [p1, ..._p2] = hostPart.split(":");
|
|
43
|
+
const p2 = _p2.join(":");
|
|
44
|
+
if ((isIPv4(p1) || isDomain(p1)) && isNumeric(p2)) {
|
|
45
|
+
host = p1;
|
|
46
|
+
port = parseInt(p2, 10);
|
|
47
|
+
} else {
|
|
48
|
+
username = p1;
|
|
49
|
+
password = p2;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (!host && !port)
|
|
53
|
+
return null;
|
|
54
|
+
if (username && password) {
|
|
55
|
+
return { protocol, host, port, auth: { username, password } };
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
protocol,
|
|
59
|
+
host,
|
|
60
|
+
port
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
input = input.trim();
|
|
64
|
+
if (input.includes("@")) {
|
|
65
|
+
const [authPart, hostPart] = input.split("@");
|
|
66
|
+
if (!authPart && !hostPart)
|
|
67
|
+
return null;
|
|
68
|
+
return getProxy(authPart, hostPart);
|
|
69
|
+
} else if (input.split(":").length === 4 || input.split(":").length === 2) {
|
|
70
|
+
const parts = input.split(":");
|
|
71
|
+
const authPart = input.split(":").length === 2 ? undefined : parts[2] + ":" + parts[3];
|
|
72
|
+
const hostPart = parts[0] + ":" + parts[1];
|
|
73
|
+
return getProxy(authPart || "", hostPart || "");
|
|
74
|
+
} else {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
package/dist/queue/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const
|
|
2
|
-
exports.RezoQueue =
|
|
3
|
-
const
|
|
4
|
-
exports.HttpQueue =
|
|
5
|
-
exports.extractDomain =
|
|
6
|
-
const
|
|
7
|
-
exports.Priority =
|
|
8
|
-
exports.HttpMethodPriority =
|
|
1
|
+
const _mod_zxou4r = require('./queue.cjs');
|
|
2
|
+
exports.RezoQueue = _mod_zxou4r.RezoQueue;;
|
|
3
|
+
const _mod_4vomvf = require('./http-queue.cjs');
|
|
4
|
+
exports.HttpQueue = _mod_4vomvf.HttpQueue;
|
|
5
|
+
exports.extractDomain = _mod_4vomvf.extractDomain;;
|
|
6
|
+
const _mod_5t6002 = require('./types.cjs');
|
|
7
|
+
exports.Priority = _mod_5t6002.Priority;
|
|
8
|
+
exports.HttpMethodPriority = _mod_5t6002.HttpMethodPriority;;
|
|
@@ -87,7 +87,7 @@ function formatResponse(data, config, headers) {
|
|
|
87
87
|
if (responseType === "buffer" || responseType === "binary") {
|
|
88
88
|
config.responseType = "buffer";
|
|
89
89
|
if (supportsBuffer()) {
|
|
90
|
-
return data
|
|
90
|
+
return Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
91
91
|
}
|
|
92
92
|
return data;
|
|
93
93
|
}
|
|
@@ -99,7 +99,7 @@ function formatResponse(data, config, headers) {
|
|
|
99
99
|
const encoder = new TextEncoder;
|
|
100
100
|
return encoder.encode(data).buffer;
|
|
101
101
|
}
|
|
102
|
-
if (supportsBuffer() && data
|
|
102
|
+
if (supportsBuffer() && Buffer.isBuffer(data)) {
|
|
103
103
|
return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
@@ -110,7 +110,7 @@ function formatResponse(data, config, headers) {
|
|
|
110
110
|
if (typeof data === "string") {
|
|
111
111
|
return new Blob([data]);
|
|
112
112
|
}
|
|
113
|
-
if (data instanceof ArrayBuffer || supportsBuffer() && data
|
|
113
|
+
if (data instanceof ArrayBuffer || supportsBuffer() && Buffer.isBuffer(data)) {
|
|
114
114
|
return new Blob([data]);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
@@ -119,7 +119,7 @@ function formatResponse(data, config, headers) {
|
|
|
119
119
|
if (responseType === "text") {
|
|
120
120
|
if (typeof data === "string")
|
|
121
121
|
return data;
|
|
122
|
-
if (supportsBuffer() && data
|
|
122
|
+
if (supportsBuffer() && Buffer.isBuffer(data)) {
|
|
123
123
|
return data.toString("utf-8");
|
|
124
124
|
}
|
|
125
125
|
if (data instanceof ArrayBuffer) {
|
|
@@ -140,14 +140,14 @@ function parseResponseBodyWithAutoDetect(data, contentType, config) {
|
|
|
140
140
|
if (contentType && (contentType.includes("image/") || contentType.includes("video/") || contentType.includes("audio/"))) {
|
|
141
141
|
config.responseType = "buffer";
|
|
142
142
|
if (supportsBuffer()) {
|
|
143
|
-
return data
|
|
143
|
+
return Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
144
144
|
}
|
|
145
145
|
return data;
|
|
146
146
|
}
|
|
147
147
|
if (contentType && contentType.includes("application/octet-stream")) {
|
|
148
148
|
config.responseType = "buffer";
|
|
149
149
|
if (supportsBuffer()) {
|
|
150
|
-
return data
|
|
150
|
+
return Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
151
151
|
}
|
|
152
152
|
return data;
|
|
153
153
|
}
|
|
@@ -155,7 +155,7 @@ function parseResponseBodyWithAutoDetect(data, contentType, config) {
|
|
|
155
155
|
config.responseType = "text";
|
|
156
156
|
if (typeof data === "string")
|
|
157
157
|
return data;
|
|
158
|
-
if (supportsBuffer() && data
|
|
158
|
+
if (supportsBuffer() && Buffer.isBuffer(data)) {
|
|
159
159
|
return data.toString("utf-8");
|
|
160
160
|
}
|
|
161
161
|
if (data instanceof ArrayBuffer) {
|
|
@@ -165,7 +165,7 @@ function parseResponseBodyWithAutoDetect(data, contentType, config) {
|
|
|
165
165
|
}
|
|
166
166
|
config.responseType = "buffer";
|
|
167
167
|
if (supportsBuffer()) {
|
|
168
|
-
return data
|
|
168
|
+
return Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
169
169
|
}
|
|
170
170
|
if (supportsArrayBuffer()) {
|
|
171
171
|
if (data instanceof ArrayBuffer)
|
|
@@ -191,7 +191,7 @@ function parseResponseBody(data, contentType, responseType) {
|
|
|
191
191
|
if (responseType === "arrayBuffer" && supportsArrayBuffer()) {
|
|
192
192
|
if (data instanceof ArrayBuffer)
|
|
193
193
|
return data;
|
|
194
|
-
if (supportsBuffer() && data
|
|
194
|
+
if (supportsBuffer() && Buffer.isBuffer(data)) {
|
|
195
195
|
return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
196
196
|
}
|
|
197
197
|
}
|
|
@@ -200,19 +200,19 @@ function parseResponseBody(data, contentType, responseType) {
|
|
|
200
200
|
if (responseType === "arrayBuffer" && supportsArrayBuffer()) {
|
|
201
201
|
if (data instanceof ArrayBuffer)
|
|
202
202
|
return data;
|
|
203
|
-
if (supportsBuffer() && data
|
|
203
|
+
if (supportsBuffer() && Buffer.isBuffer(data)) {
|
|
204
204
|
return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
if (supportsBuffer()) {
|
|
208
|
-
return data
|
|
208
|
+
return Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
209
209
|
}
|
|
210
210
|
return data;
|
|
211
211
|
}
|
|
212
212
|
if (contentType && textRelatedTypes.some((type) => contentType.includes(type))) {
|
|
213
213
|
if (typeof data === "string")
|
|
214
214
|
return data;
|
|
215
|
-
if (supportsBuffer() && data
|
|
215
|
+
if (supportsBuffer() && Buffer.isBuffer(data)) {
|
|
216
216
|
return data.toString("utf-8");
|
|
217
217
|
}
|
|
218
218
|
if (data instanceof ArrayBuffer) {
|
|
@@ -221,7 +221,7 @@ function parseResponseBody(data, contentType, responseType) {
|
|
|
221
221
|
return String(data);
|
|
222
222
|
}
|
|
223
223
|
if (supportsBuffer()) {
|
|
224
|
-
return data
|
|
224
|
+
return Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
225
225
|
}
|
|
226
226
|
if (supportsArrayBuffer()) {
|
|
227
227
|
if (data instanceof ArrayBuffer)
|
|
@@ -240,7 +240,7 @@ function parseJsonData(body) {
|
|
|
240
240
|
if (body.length < 3)
|
|
241
241
|
return body;
|
|
242
242
|
jsonString = body;
|
|
243
|
-
} else if (supportsBuffer() && body
|
|
243
|
+
} else if (supportsBuffer() && Buffer.isBuffer(body)) {
|
|
244
244
|
jsonString = body.toString("utf-8");
|
|
245
245
|
} else if (body instanceof ArrayBuffer) {
|
|
246
246
|
jsonString = new TextDecoder().decode(body);
|
|
@@ -270,7 +270,7 @@ function parseJsonData(body) {
|
|
|
270
270
|
} catch {
|
|
271
271
|
if (typeof body === "string")
|
|
272
272
|
return body;
|
|
273
|
-
if (supportsBuffer() && body
|
|
273
|
+
if (supportsBuffer() && Buffer.isBuffer(body)) {
|
|
274
274
|
return body.toString("utf-8");
|
|
275
275
|
}
|
|
276
276
|
if (body instanceof ArrayBuffer) {
|