koonjs 0.4.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/index.d.ts +141 -0
- package/index.js +32 -0
- package/koon.darwin-arm64.node +0 -0
- package/koon.darwin-x64.node +0 -0
- package/koon.linux-arm64-gnu.node +0 -0
- package/koon.linux-x64-gnu.node +0 -0
- package/koon.win32-x64-msvc.node +0 -0
- package/package.json +32 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
export type Browser =
|
|
2
|
+
| 'chrome' | 'chrome131' | 'chrome132' | 'chrome133' | 'chrome134' | 'chrome135'
|
|
3
|
+
| 'chrome136' | 'chrome137' | 'chrome138' | 'chrome139' | 'chrome140'
|
|
4
|
+
| 'chrome141' | 'chrome142' | 'chrome143' | 'chrome144' | 'chrome145'
|
|
5
|
+
| 'firefox' | 'firefox135' | 'firefox136' | 'firefox137' | 'firefox138'
|
|
6
|
+
| 'firefox139' | 'firefox140' | 'firefox141' | 'firefox142' | 'firefox143'
|
|
7
|
+
| 'firefox144' | 'firefox145' | 'firefox146' | 'firefox147'
|
|
8
|
+
| 'safari' | 'safari156' | 'safari160' | 'safari161' | 'safari170' | 'safari171'
|
|
9
|
+
| 'safari172' | 'safari173' | 'safari180' | 'safari181' | 'safari182' | 'safari183'
|
|
10
|
+
| 'edge' | 'edge131' | 'edge132' | 'edge133' | 'edge134' | 'edge135'
|
|
11
|
+
| 'edge136' | 'edge137' | 'edge138' | 'edge139' | 'edge140'
|
|
12
|
+
| 'edge141' | 'edge142' | 'edge143' | 'edge144' | 'edge145'
|
|
13
|
+
| 'opera' | 'opera124' | 'opera125' | 'opera126' | 'opera127'
|
|
14
|
+
// OS-specific variants
|
|
15
|
+
| `${string}-windows` | `${string}-macos` | `${string}-linux`;
|
|
16
|
+
|
|
17
|
+
export interface KoonOptions {
|
|
18
|
+
/** Browser profile to impersonate. */
|
|
19
|
+
browser?: Browser;
|
|
20
|
+
/** Custom browser profile as JSON string. */
|
|
21
|
+
profileJson?: string;
|
|
22
|
+
/** Proxy URL (http://, socks5://). */
|
|
23
|
+
proxy?: string;
|
|
24
|
+
/** Request timeout in milliseconds. Default: 30000. */
|
|
25
|
+
timeout?: number;
|
|
26
|
+
/** Skip TLS certificate verification. */
|
|
27
|
+
ignoreTlsErrors?: boolean;
|
|
28
|
+
/** Default headers to send with every request. */
|
|
29
|
+
headers?: Record<string, string>;
|
|
30
|
+
/** Follow redirects. Default: true. */
|
|
31
|
+
followRedirects?: boolean;
|
|
32
|
+
/** Maximum redirects to follow. Default: 10. */
|
|
33
|
+
maxRedirects?: number;
|
|
34
|
+
/** Enable cookie jar. Default: true. */
|
|
35
|
+
cookieJar?: boolean;
|
|
36
|
+
/** Apply slight fingerprint randomization. */
|
|
37
|
+
randomize?: boolean;
|
|
38
|
+
/** Enable TLS session resumption. Default: true. */
|
|
39
|
+
sessionResumption?: boolean;
|
|
40
|
+
/** DNS-over-HTTPS provider ("cloudflare", "google", or URL). */
|
|
41
|
+
doh?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface KoonResponse {
|
|
45
|
+
/** HTTP status code. */
|
|
46
|
+
status: number;
|
|
47
|
+
/** Response headers as [name, value] pairs. */
|
|
48
|
+
headers: Array<{ name: string; value: string }>;
|
|
49
|
+
/** Response body as Buffer. */
|
|
50
|
+
body: Buffer;
|
|
51
|
+
/** HTTP version string (e.g., "HTTP/2.0"). */
|
|
52
|
+
version: string;
|
|
53
|
+
/** Final URL after redirects. */
|
|
54
|
+
url: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface KoonWsMessage {
|
|
58
|
+
/** Whether the message is text (true) or binary (false). */
|
|
59
|
+
isText: boolean;
|
|
60
|
+
/** Message data. */
|
|
61
|
+
data: Buffer;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface KoonMultipartField {
|
|
65
|
+
/** Field name. */
|
|
66
|
+
name: string;
|
|
67
|
+
/** Text value (for form fields). */
|
|
68
|
+
value?: string;
|
|
69
|
+
/** Binary data (for file uploads). */
|
|
70
|
+
fileData?: Buffer;
|
|
71
|
+
/** Filename (for file uploads). */
|
|
72
|
+
filename?: string;
|
|
73
|
+
/** MIME type (for file uploads). */
|
|
74
|
+
contentType?: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export class Koon {
|
|
78
|
+
constructor(options?: KoonOptions);
|
|
79
|
+
|
|
80
|
+
get(url: string): Promise<KoonResponse>;
|
|
81
|
+
post(url: string, body?: Buffer): Promise<KoonResponse>;
|
|
82
|
+
put(url: string, body?: Buffer): Promise<KoonResponse>;
|
|
83
|
+
delete(url: string): Promise<KoonResponse>;
|
|
84
|
+
patch(url: string, body?: Buffer): Promise<KoonResponse>;
|
|
85
|
+
head(url: string): Promise<KoonResponse>;
|
|
86
|
+
request(method: string, url: string, body?: Buffer): Promise<KoonResponse>;
|
|
87
|
+
postMultipart(url: string, fields: KoonMultipartField[]): Promise<KoonResponse>;
|
|
88
|
+
requestStreaming(method: string, url: string, body?: Buffer): Promise<KoonStreamingResponse>;
|
|
89
|
+
|
|
90
|
+
websocket(url: string, headers?: Record<string, string>): Promise<KoonWebSocket>;
|
|
91
|
+
|
|
92
|
+
exportProfile(): string;
|
|
93
|
+
saveSession(): string;
|
|
94
|
+
loadSession(json: string): void;
|
|
95
|
+
saveSessionToFile(path: string): void;
|
|
96
|
+
loadSessionFromFile(path: string): void;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export class KoonStreamingResponse {
|
|
100
|
+
readonly status: number;
|
|
101
|
+
readonly headers: Array<{ name: string; value: string }>;
|
|
102
|
+
readonly version: string;
|
|
103
|
+
readonly url: string;
|
|
104
|
+
|
|
105
|
+
nextChunk(): Promise<Buffer | null>;
|
|
106
|
+
collect(): Promise<Buffer>;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export class KoonWebSocket {
|
|
110
|
+
send(data: string | Buffer): Promise<void>;
|
|
111
|
+
receive(): Promise<KoonWsMessage | null>;
|
|
112
|
+
close(code?: number, reason?: string): Promise<void>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface KoonProxyOptions {
|
|
116
|
+
/** Browser profile. Default: "chrome". */
|
|
117
|
+
browser?: Browser;
|
|
118
|
+
/** Custom profile JSON. */
|
|
119
|
+
profileJson?: string;
|
|
120
|
+
/** Listen address. Default: "127.0.0.1:0". */
|
|
121
|
+
listenAddr?: string;
|
|
122
|
+
/** Header mode: "forward", "replace", or "merge". */
|
|
123
|
+
headerMode?: string;
|
|
124
|
+
/** CA certificate directory. */
|
|
125
|
+
caDir?: string;
|
|
126
|
+
/** Request timeout in milliseconds. Default: 30000. */
|
|
127
|
+
timeout?: number;
|
|
128
|
+
/** Apply fingerprint randomization. */
|
|
129
|
+
randomize?: boolean;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export class KoonProxy {
|
|
133
|
+
static start(options?: KoonProxyOptions): Promise<KoonProxy>;
|
|
134
|
+
|
|
135
|
+
readonly port: number;
|
|
136
|
+
readonly url: string;
|
|
137
|
+
readonly caCertPath: string;
|
|
138
|
+
|
|
139
|
+
caCertPem(): Buffer;
|
|
140
|
+
shutdown(): Promise<void>;
|
|
141
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const { platform, arch } = process;
|
|
2
|
+
|
|
3
|
+
const platformArch = `${platform}-${arch}`;
|
|
4
|
+
|
|
5
|
+
const triples = {
|
|
6
|
+
'win32-x64': 'koon.win32-x64-msvc.node',
|
|
7
|
+
'linux-x64': 'koon.linux-x64-gnu.node',
|
|
8
|
+
'darwin-x64': 'koon.darwin-x64.node',
|
|
9
|
+
'darwin-arm64': 'koon.darwin-arm64.node',
|
|
10
|
+
'linux-arm64': 'koon.linux-arm64-gnu.node',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const binding = triples[platformArch];
|
|
14
|
+
if (!binding) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
`koon: unsupported platform ${platformArch}. ` +
|
|
17
|
+
`Supported: ${Object.keys(triples).join(', ')}`
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let nativeModule;
|
|
22
|
+
try {
|
|
23
|
+
nativeModule = require(`./${binding}`);
|
|
24
|
+
} catch (e) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
`koon: failed to load native module ${binding}. ` +
|
|
27
|
+
`Make sure you've built it with: cargo build --release -p koon-node\n` +
|
|
28
|
+
`Original error: ${e.message}`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = nativeModule;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "koonjs",
|
|
3
|
+
"version": "0.4.4",
|
|
4
|
+
"description": "Browser-impersonating HTTP client with TLS/HTTP2 fingerprint spoofing",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">= 16"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"index.js",
|
|
13
|
+
"index.d.ts",
|
|
14
|
+
"koon.*.node"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "cargo build --release -p koon-node",
|
|
18
|
+
"test": "node ../../test_node.cjs"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"tls",
|
|
22
|
+
"fingerprint",
|
|
23
|
+
"http2",
|
|
24
|
+
"browser",
|
|
25
|
+
"impersonation",
|
|
26
|
+
"anti-bot",
|
|
27
|
+
"akamai",
|
|
28
|
+
"cloudflare",
|
|
29
|
+
"ja3",
|
|
30
|
+
"ja4"
|
|
31
|
+
]
|
|
32
|
+
}
|