koonjs 0.5.6 → 0.6.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/index.d.ts +8 -6
- package/index.js +28 -19
- package/package.json +16 -3
- package/koon.linux-x64-gnu.node +0 -0
- package/koon.win32-x64-msvc.node +0 -0
package/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export interface KoonOptions {
|
|
|
28
28
|
proxy?: string;
|
|
29
29
|
/** Array of proxy URLs for round-robin rotation. Takes priority over `proxy`. */
|
|
30
30
|
proxies?: string[];
|
|
31
|
-
/** Request timeout in
|
|
31
|
+
/** Request timeout in seconds. Default: 30. */
|
|
32
32
|
timeout?: number;
|
|
33
33
|
/** Skip TLS certificate verification. */
|
|
34
34
|
ignoreTlsErrors?: boolean;
|
|
@@ -44,7 +44,7 @@ export interface KoonOptions {
|
|
|
44
44
|
randomize?: boolean;
|
|
45
45
|
/** Enable TLS session resumption. Default: true. */
|
|
46
46
|
sessionResumption?: boolean;
|
|
47
|
-
/** DNS-over-HTTPS provider
|
|
47
|
+
/** DNS-over-HTTPS provider. Supported values: "cloudflare", "google". */
|
|
48
48
|
doh?: string;
|
|
49
49
|
/** Bind outgoing connections to a specific local IP address. */
|
|
50
50
|
localAddress?: string;
|
|
@@ -87,8 +87,10 @@ export class KoonResponse {
|
|
|
87
87
|
readonly connectionReused: boolean;
|
|
88
88
|
/** Remote IP address of the peer (e.g. "1.2.3.4" or "::1"), or null for H3/QUIC. */
|
|
89
89
|
readonly remoteAddress: string | null;
|
|
90
|
+
/** Content-Type header value (e.g. "text/html; charset=utf-8"), or null if absent. */
|
|
91
|
+
readonly contentType: string | null;
|
|
90
92
|
|
|
91
|
-
/** Decode response body as UTF-8
|
|
93
|
+
/** Decode response body as text, respecting the charset from the Content-Type header. Falls back to UTF-8. */
|
|
92
94
|
text(): string;
|
|
93
95
|
/** Parse response body as JSON (via JSON.parse()). */
|
|
94
96
|
json(): any;
|
|
@@ -106,7 +108,7 @@ export interface KoonWsMessage {
|
|
|
106
108
|
export interface KoonRequestOptions {
|
|
107
109
|
/** Additional headers for this request. Override constructor-level headers. */
|
|
108
110
|
headers?: Record<string, string>;
|
|
109
|
-
/** Per-request timeout in
|
|
111
|
+
/** Per-request timeout in seconds. Overrides constructor-level timeout. */
|
|
110
112
|
timeout?: number;
|
|
111
113
|
}
|
|
112
114
|
|
|
@@ -190,11 +192,11 @@ export interface KoonProxyOptions {
|
|
|
190
192
|
profileJson?: string;
|
|
191
193
|
/** Listen address. Default: "127.0.0.1:0". */
|
|
192
194
|
listenAddr?: string;
|
|
193
|
-
/** Header mode: "
|
|
195
|
+
/** Header mode: "impersonate" (default) or "passthrough". */
|
|
194
196
|
headerMode?: string;
|
|
195
197
|
/** CA certificate directory. */
|
|
196
198
|
caDir?: string;
|
|
197
|
-
/** Request timeout in
|
|
199
|
+
/** Request timeout in seconds. Default: 30. */
|
|
198
200
|
timeout?: number;
|
|
199
201
|
/** Apply fingerprint randomization. */
|
|
200
202
|
randomize?: boolean;
|
package/index.js
CHANGED
|
@@ -1,34 +1,43 @@
|
|
|
1
1
|
const { platform, arch } = process;
|
|
2
|
-
|
|
3
2
|
const platformArch = `${platform}-${arch}`;
|
|
4
3
|
|
|
5
|
-
const
|
|
6
|
-
'win32-x64': '
|
|
7
|
-
'linux-x64': '
|
|
8
|
-
'darwin-x64': '
|
|
9
|
-
'darwin-arm64': '
|
|
10
|
-
'linux-arm64': '
|
|
4
|
+
const packages = {
|
|
5
|
+
'win32-x64': '@koonjs/win32-x64-msvc',
|
|
6
|
+
'linux-x64': '@koonjs/linux-x64-gnu',
|
|
7
|
+
'darwin-x64': '@koonjs/darwin-x64',
|
|
8
|
+
'darwin-arm64': '@koonjs/darwin-arm64',
|
|
9
|
+
'linux-arm64': '@koonjs/linux-arm64-gnu',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const localFiles = {
|
|
13
|
+
'win32-x64': './koon.win32-x64-msvc.node',
|
|
14
|
+
'linux-x64': './koon.linux-x64-gnu.node',
|
|
15
|
+
'darwin-x64': './koon.darwin-x64.node',
|
|
16
|
+
'darwin-arm64': './koon.darwin-arm64.node',
|
|
17
|
+
'linux-arm64': './koon.linux-arm64-gnu.node',
|
|
11
18
|
};
|
|
12
19
|
|
|
13
|
-
const
|
|
14
|
-
if (!
|
|
20
|
+
const pkg = packages[platformArch];
|
|
21
|
+
if (!pkg) {
|
|
15
22
|
throw new Error(
|
|
16
23
|
`koon: unsupported platform ${platformArch}. ` +
|
|
17
|
-
`Supported: ${Object.keys(
|
|
24
|
+
`Supported: ${Object.keys(packages).join(', ')}`
|
|
18
25
|
);
|
|
19
26
|
}
|
|
20
27
|
|
|
21
28
|
let nativeModule;
|
|
22
29
|
try {
|
|
23
|
-
nativeModule = require(
|
|
24
|
-
} catch (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
nativeModule = require(pkg);
|
|
31
|
+
} catch (_) {
|
|
32
|
+
try {
|
|
33
|
+
nativeModule = require(localFiles[platformArch]);
|
|
34
|
+
} catch (e) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
`koon: failed to load native module for ${platformArch}.\n` +
|
|
37
|
+
`Install the platform package: npm install ${pkg}\n` +
|
|
38
|
+
`Original error: ${e.message}`
|
|
39
|
+
);
|
|
40
|
+
}
|
|
32
41
|
}
|
|
33
42
|
|
|
34
43
|
module.exports = nativeModule;
|
package/package.json
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koonjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Browser-impersonating HTTP client with TLS/HTTP2 fingerprint spoofing",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"license": "MIT",
|
|
8
|
+
"author": "Wedge",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/scrape-hub/koon.git",
|
|
12
|
+
"directory": "crates/node"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/scrape-hub/koon",
|
|
15
|
+
"bugs": "https://github.com/scrape-hub/koon/issues",
|
|
8
16
|
"engines": {
|
|
9
17
|
"node": ">= 16"
|
|
10
18
|
},
|
|
11
19
|
"files": [
|
|
12
20
|
"index.js",
|
|
13
|
-
"index.d.ts"
|
|
14
|
-
"koon.*.node"
|
|
21
|
+
"index.d.ts"
|
|
15
22
|
],
|
|
23
|
+
"optionalDependencies": {
|
|
24
|
+
"@koonjs/win32-x64-msvc": "0.6.1",
|
|
25
|
+
"@koonjs/linux-x64-gnu": "0.6.1",
|
|
26
|
+
"@koonjs/darwin-arm64": "0.6.1",
|
|
27
|
+
"@koonjs/darwin-x64": "0.6.1"
|
|
28
|
+
},
|
|
16
29
|
"scripts": {
|
|
17
30
|
"build": "cargo build --release -p koon-node && node -e \"require('fs').copyFileSync(require('path').resolve(__dirname,'../../target/release/koon_node.dll'), require('path').resolve(__dirname,'koon.win32-x64-msvc.node'))\"",
|
|
18
31
|
"build:linux": "cargo build --release -p koon-node && cp ../../target/release/libkoon_node.so koon.linux-x64-gnu.node",
|
package/koon.linux-x64-gnu.node
DELETED
|
Binary file
|
package/koon.win32-x64-msvc.node
DELETED
|
Binary file
|