nlcurl 0.1.0
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/LICENSE +21 -0
- package/README.md +162 -0
- package/dist/cli/args.d.ts +42 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +262 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +114 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/output.d.ts +22 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +105 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/cookies/jar.d.ts +41 -0
- package/dist/cookies/jar.d.ts.map +1 -0
- package/dist/cookies/jar.js +148 -0
- package/dist/cookies/jar.js.map +1 -0
- package/dist/cookies/parser.d.ts +24 -0
- package/dist/cookies/parser.d.ts.map +1 -0
- package/dist/cookies/parser.js +93 -0
- package/dist/cookies/parser.js.map +1 -0
- package/dist/core/client.d.ts +79 -0
- package/dist/core/client.d.ts.map +1 -0
- package/dist/core/client.js +106 -0
- package/dist/core/client.js.map +1 -0
- package/dist/core/errors.d.ts +36 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +65 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/request.d.ts +96 -0
- package/dist/core/request.d.ts.map +1 -0
- package/dist/core/request.js +5 -0
- package/dist/core/request.js.map +1 -0
- package/dist/core/response.d.ts +48 -0
- package/dist/core/response.d.ts.map +1 -0
- package/dist/core/response.js +65 -0
- package/dist/core/response.js.map +1 -0
- package/dist/core/session.d.ts +60 -0
- package/dist/core/session.d.ts.map +1 -0
- package/dist/core/session.js +305 -0
- package/dist/core/session.js.map +1 -0
- package/dist/fingerprints/akamai.d.ts +17 -0
- package/dist/fingerprints/akamai.d.ts.map +1 -0
- package/dist/fingerprints/akamai.js +30 -0
- package/dist/fingerprints/akamai.js.map +1 -0
- package/dist/fingerprints/database.d.ts +33 -0
- package/dist/fingerprints/database.d.ts.map +1 -0
- package/dist/fingerprints/database.js +68 -0
- package/dist/fingerprints/database.js.map +1 -0
- package/dist/fingerprints/extensions.d.ts +49 -0
- package/dist/fingerprints/extensions.d.ts.map +1 -0
- package/dist/fingerprints/extensions.js +178 -0
- package/dist/fingerprints/extensions.js.map +1 -0
- package/dist/fingerprints/ja3.d.ts +32 -0
- package/dist/fingerprints/ja3.d.ts.map +1 -0
- package/dist/fingerprints/ja3.js +64 -0
- package/dist/fingerprints/ja3.js.map +1 -0
- package/dist/fingerprints/profiles/chrome.d.ts +30 -0
- package/dist/fingerprints/profiles/chrome.d.ts.map +1 -0
- package/dist/fingerprints/profiles/chrome.js +202 -0
- package/dist/fingerprints/profiles/chrome.js.map +1 -0
- package/dist/fingerprints/profiles/edge.d.ts +16 -0
- package/dist/fingerprints/profiles/edge.d.ts.map +1 -0
- package/dist/fingerprints/profiles/edge.js +61 -0
- package/dist/fingerprints/profiles/edge.js.map +1 -0
- package/dist/fingerprints/profiles/firefox.d.ts +13 -0
- package/dist/fingerprints/profiles/firefox.d.ts.map +1 -0
- package/dist/fingerprints/profiles/firefox.js +160 -0
- package/dist/fingerprints/profiles/firefox.js.map +1 -0
- package/dist/fingerprints/profiles/safari.d.ts +16 -0
- package/dist/fingerprints/profiles/safari.d.ts.map +1 -0
- package/dist/fingerprints/profiles/safari.js +140 -0
- package/dist/fingerprints/profiles/safari.js.map +1 -0
- package/dist/fingerprints/profiles/tor.d.ts +14 -0
- package/dist/fingerprints/profiles/tor.d.ts.map +1 -0
- package/dist/fingerprints/profiles/tor.js +136 -0
- package/dist/fingerprints/profiles/tor.js.map +1 -0
- package/dist/fingerprints/types.d.ts +104 -0
- package/dist/fingerprints/types.d.ts.map +1 -0
- package/dist/fingerprints/types.js +9 -0
- package/dist/fingerprints/types.js.map +1 -0
- package/dist/http/h1/client.d.ts +21 -0
- package/dist/http/h1/client.d.ts.map +1 -0
- package/dist/http/h1/client.js +136 -0
- package/dist/http/h1/client.js.map +1 -0
- package/dist/http/h1/encoder.d.ts +11 -0
- package/dist/http/h1/encoder.d.ts.map +1 -0
- package/dist/http/h1/encoder.js +75 -0
- package/dist/http/h1/encoder.js.map +1 -0
- package/dist/http/h1/parser.d.ts +61 -0
- package/dist/http/h1/parser.d.ts.map +1 -0
- package/dist/http/h1/parser.js +258 -0
- package/dist/http/h1/parser.js.map +1 -0
- package/dist/http/h2/client.d.ts +48 -0
- package/dist/http/h2/client.d.ts.map +1 -0
- package/dist/http/h2/client.js +376 -0
- package/dist/http/h2/client.js.map +1 -0
- package/dist/http/h2/frames.d.ts +65 -0
- package/dist/http/h2/frames.d.ts.map +1 -0
- package/dist/http/h2/frames.js +184 -0
- package/dist/http/h2/frames.js.map +1 -0
- package/dist/http/h2/hpack.d.ts +27 -0
- package/dist/http/h2/hpack.d.ts.map +1 -0
- package/dist/http/h2/hpack.js +423 -0
- package/dist/http/h2/hpack.js.map +1 -0
- package/dist/http/negotiator.d.ts +36 -0
- package/dist/http/negotiator.d.ts.map +1 -0
- package/dist/http/negotiator.js +101 -0
- package/dist/http/negotiator.js.map +1 -0
- package/dist/http/pool.d.ts +63 -0
- package/dist/http/pool.d.ts.map +1 -0
- package/dist/http/pool.js +177 -0
- package/dist/http/pool.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware/interceptor.d.ts +27 -0
- package/dist/middleware/interceptor.d.ts.map +1 -0
- package/dist/middleware/interceptor.js +35 -0
- package/dist/middleware/interceptor.js.map +1 -0
- package/dist/middleware/rate-limiter.d.ts +26 -0
- package/dist/middleware/rate-limiter.d.ts.map +1 -0
- package/dist/middleware/rate-limiter.js +59 -0
- package/dist/middleware/rate-limiter.js.map +1 -0
- package/dist/middleware/retry.d.ts +17 -0
- package/dist/middleware/retry.d.ts.map +1 -0
- package/dist/middleware/retry.js +64 -0
- package/dist/middleware/retry.js.map +1 -0
- package/dist/proxy/http-proxy.d.ts +23 -0
- package/dist/proxy/http-proxy.d.ts.map +1 -0
- package/dist/proxy/http-proxy.js +93 -0
- package/dist/proxy/http-proxy.js.map +1 -0
- package/dist/proxy/socks.d.ts +24 -0
- package/dist/proxy/socks.d.ts.map +1 -0
- package/dist/proxy/socks.js +196 -0
- package/dist/proxy/socks.js.map +1 -0
- package/dist/tls/constants.d.ts +142 -0
- package/dist/tls/constants.d.ts.map +1 -0
- package/dist/tls/constants.js +163 -0
- package/dist/tls/constants.js.map +1 -0
- package/dist/tls/node-engine.d.ts +22 -0
- package/dist/tls/node-engine.d.ts.map +1 -0
- package/dist/tls/node-engine.js +190 -0
- package/dist/tls/node-engine.js.map +1 -0
- package/dist/tls/stealth/client-hello.d.ts +38 -0
- package/dist/tls/stealth/client-hello.d.ts.map +1 -0
- package/dist/tls/stealth/client-hello.js +197 -0
- package/dist/tls/stealth/client-hello.js.map +1 -0
- package/dist/tls/stealth/engine.d.ts +16 -0
- package/dist/tls/stealth/engine.d.ts.map +1 -0
- package/dist/tls/stealth/engine.js +196 -0
- package/dist/tls/stealth/engine.js.map +1 -0
- package/dist/tls/stealth/handshake.d.ts +45 -0
- package/dist/tls/stealth/handshake.d.ts.map +1 -0
- package/dist/tls/stealth/handshake.js +403 -0
- package/dist/tls/stealth/handshake.js.map +1 -0
- package/dist/tls/stealth/key-schedule.d.ts +85 -0
- package/dist/tls/stealth/key-schedule.d.ts.map +1 -0
- package/dist/tls/stealth/key-schedule.js +141 -0
- package/dist/tls/stealth/key-schedule.js.map +1 -0
- package/dist/tls/stealth/record-layer.d.ts +74 -0
- package/dist/tls/stealth/record-layer.d.ts.map +1 -0
- package/dist/tls/stealth/record-layer.js +167 -0
- package/dist/tls/stealth/record-layer.js.map +1 -0
- package/dist/tls/types.d.ts +58 -0
- package/dist/tls/types.d.ts.map +1 -0
- package/dist/tls/types.js +6 -0
- package/dist/tls/types.js.map +1 -0
- package/dist/utils/buffer-reader.d.ts +32 -0
- package/dist/utils/buffer-reader.d.ts.map +1 -0
- package/dist/utils/buffer-reader.js +99 -0
- package/dist/utils/buffer-reader.js.map +1 -0
- package/dist/utils/buffer-writer.d.ts +35 -0
- package/dist/utils/buffer-writer.d.ts.map +1 -0
- package/dist/utils/buffer-writer.js +121 -0
- package/dist/utils/buffer-writer.js.map +1 -0
- package/dist/utils/encoding.d.ts +19 -0
- package/dist/utils/encoding.d.ts.map +1 -0
- package/dist/utils/encoding.js +63 -0
- package/dist/utils/encoding.js.map +1 -0
- package/dist/utils/logger.d.ts +24 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +56 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/url.d.ts +22 -0
- package/dist/utils/url.d.ts.map +1 -0
- package/dist/utils/url.js +56 -0
- package/dist/utils/url.js.map +1 -0
- package/dist/ws/client.d.ts +63 -0
- package/dist/ws/client.d.ts.map +1 -0
- package/dist/ws/client.js +273 -0
- package/dist/ws/client.js.map +1 -0
- package/dist/ws/frame.d.ts +44 -0
- package/dist/ws/frame.d.ts.map +1 -0
- package/dist/ws/frame.js +146 -0
- package/dist/ws/frame.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connection pool.
|
|
3
|
+
*
|
|
4
|
+
* Manages TLS connections keyed by origin, supporting both HTTP/1.1
|
|
5
|
+
* keep-alive and HTTP/2 multiplexing. Handles connection reuse,
|
|
6
|
+
* eviction, and idle timeout.
|
|
7
|
+
*/
|
|
8
|
+
import type { TLSSocket } from '../tls/types.js';
|
|
9
|
+
import { H2Client } from './h2/client.js';
|
|
10
|
+
import type { H2Profile } from '../fingerprints/types.js';
|
|
11
|
+
export interface PoolEntry {
|
|
12
|
+
origin: string;
|
|
13
|
+
socket: TLSSocket;
|
|
14
|
+
protocol: 'h1' | 'h2';
|
|
15
|
+
h2Client?: H2Client;
|
|
16
|
+
createdAt: number;
|
|
17
|
+
lastUsed: number;
|
|
18
|
+
busy: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface PoolOptions {
|
|
21
|
+
/** Maximum connections per origin. */
|
|
22
|
+
maxConnectionsPerOrigin?: number;
|
|
23
|
+
/** Maximum total connections across all origins. */
|
|
24
|
+
maxTotalConnections?: number;
|
|
25
|
+
/** Connection idle timeout in milliseconds. */
|
|
26
|
+
idleTimeout?: number;
|
|
27
|
+
/** Connection max age in milliseconds. */
|
|
28
|
+
maxAge?: number;
|
|
29
|
+
}
|
|
30
|
+
export declare class ConnectionPool {
|
|
31
|
+
private readonly options;
|
|
32
|
+
private readonly connections;
|
|
33
|
+
private totalConnections;
|
|
34
|
+
private cleanupTimer;
|
|
35
|
+
constructor(options?: PoolOptions);
|
|
36
|
+
/**
|
|
37
|
+
* Get an existing idle connection for the given origin.
|
|
38
|
+
*
|
|
39
|
+
* Returns undefined if no reusable connection is available.
|
|
40
|
+
*/
|
|
41
|
+
get(origin: string): PoolEntry | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Add a new connection to the pool.
|
|
44
|
+
*/
|
|
45
|
+
put(origin: string, socket: TLSSocket, protocol: 'h1' | 'h2', h2Profile?: H2Profile, defaultHeaders?: Array<[string, string]>): PoolEntry;
|
|
46
|
+
/**
|
|
47
|
+
* Release an H1 connection back to the pool.
|
|
48
|
+
*/
|
|
49
|
+
release(entry: PoolEntry): void;
|
|
50
|
+
/**
|
|
51
|
+
* Remove a specific connection from the pool.
|
|
52
|
+
*/
|
|
53
|
+
remove(entry: PoolEntry): void;
|
|
54
|
+
/**
|
|
55
|
+
* Close all connections and stop the cleanup timer.
|
|
56
|
+
*/
|
|
57
|
+
close(): void;
|
|
58
|
+
get size(): number;
|
|
59
|
+
private isExpired;
|
|
60
|
+
private evictIdle;
|
|
61
|
+
private evictOldest;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=pool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1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M,CAAC,CAAC,GACvC,SAAS;IAyCZ;;OAEG;IACH,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAK/B;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAe9B;;OAEG;IACH,KAAK,IAAI,IAAI;IAgBb,IAAI,IAAI,IAAI,MAAM,CAEjB;IAID,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,SAAS;IAkBjB,OAAO,CAAC,WAAW;CAiBpB"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connection pool.
|
|
3
|
+
*
|
|
4
|
+
* Manages TLS connections keyed by origin, supporting both HTTP/1.1
|
|
5
|
+
* keep-alive and HTTP/2 multiplexing. Handles connection reuse,
|
|
6
|
+
* eviction, and idle timeout.
|
|
7
|
+
*/
|
|
8
|
+
import { H2Client } from './h2/client.js';
|
|
9
|
+
const DEFAULT_POOL_OPTIONS = {
|
|
10
|
+
maxConnectionsPerOrigin: 6,
|
|
11
|
+
maxTotalConnections: 64,
|
|
12
|
+
idleTimeout: 60_000,
|
|
13
|
+
maxAge: 300_000,
|
|
14
|
+
};
|
|
15
|
+
export class ConnectionPool {
|
|
16
|
+
options;
|
|
17
|
+
connections = new Map();
|
|
18
|
+
totalConnections = 0;
|
|
19
|
+
cleanupTimer;
|
|
20
|
+
constructor(options = {}) {
|
|
21
|
+
this.options = { ...DEFAULT_POOL_OPTIONS, ...options };
|
|
22
|
+
// Periodic cleanup
|
|
23
|
+
this.cleanupTimer = setInterval(() => this.evictIdle(), 30_000);
|
|
24
|
+
if (this.cleanupTimer.unref) {
|
|
25
|
+
this.cleanupTimer.unref();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get an existing idle connection for the given origin.
|
|
30
|
+
*
|
|
31
|
+
* Returns undefined if no reusable connection is available.
|
|
32
|
+
*/
|
|
33
|
+
get(origin) {
|
|
34
|
+
const entries = this.connections.get(origin);
|
|
35
|
+
if (!entries)
|
|
36
|
+
return undefined;
|
|
37
|
+
const now = Date.now();
|
|
38
|
+
for (const entry of entries) {
|
|
39
|
+
// H2 connections can be multiplexed (always reusable)
|
|
40
|
+
if (entry.protocol === 'h2' && !this.isExpired(entry, now)) {
|
|
41
|
+
entry.lastUsed = now;
|
|
42
|
+
return entry;
|
|
43
|
+
}
|
|
44
|
+
// H1 connections must be idle
|
|
45
|
+
if (entry.protocol === 'h1' && !entry.busy && !this.isExpired(entry, now)) {
|
|
46
|
+
entry.busy = true;
|
|
47
|
+
entry.lastUsed = now;
|
|
48
|
+
return entry;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Add a new connection to the pool.
|
|
55
|
+
*/
|
|
56
|
+
put(origin, socket, protocol, h2Profile, defaultHeaders) {
|
|
57
|
+
// Evict if at capacity
|
|
58
|
+
if (this.totalConnections >= this.options.maxTotalConnections) {
|
|
59
|
+
this.evictOldest();
|
|
60
|
+
// If eviction failed (all busy), allow temporary over-capacity
|
|
61
|
+
}
|
|
62
|
+
const entry = {
|
|
63
|
+
origin,
|
|
64
|
+
socket,
|
|
65
|
+
protocol,
|
|
66
|
+
createdAt: Date.now(),
|
|
67
|
+
lastUsed: Date.now(),
|
|
68
|
+
busy: protocol === 'h1',
|
|
69
|
+
};
|
|
70
|
+
if (protocol === 'h2') {
|
|
71
|
+
entry.h2Client = new H2Client(socket, h2Profile, defaultHeaders);
|
|
72
|
+
}
|
|
73
|
+
let entries = this.connections.get(origin);
|
|
74
|
+
if (!entries) {
|
|
75
|
+
entries = [];
|
|
76
|
+
this.connections.set(origin, entries);
|
|
77
|
+
}
|
|
78
|
+
// Check per-origin limit
|
|
79
|
+
while (entries.length >= this.options.maxConnectionsPerOrigin) {
|
|
80
|
+
const evicted = entries.shift();
|
|
81
|
+
if (evicted) {
|
|
82
|
+
evicted.socket.destroyTLS();
|
|
83
|
+
this.totalConnections--;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
entries.push(entry);
|
|
87
|
+
this.totalConnections++;
|
|
88
|
+
return entry;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Release an H1 connection back to the pool.
|
|
92
|
+
*/
|
|
93
|
+
release(entry) {
|
|
94
|
+
entry.busy = false;
|
|
95
|
+
entry.lastUsed = Date.now();
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Remove a specific connection from the pool.
|
|
99
|
+
*/
|
|
100
|
+
remove(entry) {
|
|
101
|
+
const entries = this.connections.get(entry.origin);
|
|
102
|
+
if (entries) {
|
|
103
|
+
const idx = entries.indexOf(entry);
|
|
104
|
+
if (idx >= 0) {
|
|
105
|
+
entries.splice(idx, 1);
|
|
106
|
+
this.totalConnections--;
|
|
107
|
+
}
|
|
108
|
+
if (entries.length === 0) {
|
|
109
|
+
this.connections.delete(entry.origin);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
entry.socket.destroyTLS();
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Close all connections and stop the cleanup timer.
|
|
116
|
+
*/
|
|
117
|
+
close() {
|
|
118
|
+
if (this.cleanupTimer) {
|
|
119
|
+
clearInterval(this.cleanupTimer);
|
|
120
|
+
this.cleanupTimer = undefined;
|
|
121
|
+
}
|
|
122
|
+
for (const [, entries] of this.connections) {
|
|
123
|
+
for (const entry of entries) {
|
|
124
|
+
if (entry.h2Client)
|
|
125
|
+
entry.h2Client.destroy();
|
|
126
|
+
entry.socket.destroyTLS();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
this.connections.clear();
|
|
130
|
+
this.totalConnections = 0;
|
|
131
|
+
}
|
|
132
|
+
get size() {
|
|
133
|
+
return this.totalConnections;
|
|
134
|
+
}
|
|
135
|
+
// ---- Internal ----
|
|
136
|
+
isExpired(entry, now) {
|
|
137
|
+
if (now - entry.createdAt > this.options.maxAge)
|
|
138
|
+
return true;
|
|
139
|
+
if (now - entry.lastUsed > this.options.idleTimeout)
|
|
140
|
+
return true;
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
evictIdle() {
|
|
144
|
+
const now = Date.now();
|
|
145
|
+
for (const [origin, entries] of this.connections) {
|
|
146
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
147
|
+
const entry = entries[i];
|
|
148
|
+
if (this.isExpired(entry, now) && !entry.busy) {
|
|
149
|
+
entries.splice(i, 1);
|
|
150
|
+
this.totalConnections--;
|
|
151
|
+
if (entry.h2Client)
|
|
152
|
+
entry.h2Client.destroy();
|
|
153
|
+
entry.socket.destroyTLS();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (entries.length === 0) {
|
|
157
|
+
this.connections.delete(origin);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
evictOldest() {
|
|
162
|
+
let oldest;
|
|
163
|
+
for (const [origin, entries] of this.connections) {
|
|
164
|
+
for (const entry of entries) {
|
|
165
|
+
if (!entry.busy) {
|
|
166
|
+
if (!oldest || entry.lastUsed < oldest.entry.lastUsed) {
|
|
167
|
+
oldest = { entry, origin };
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (oldest) {
|
|
173
|
+
this.remove(oldest.entry);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../../src/http/pool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAwB1C,MAAM,oBAAoB,GAA0B;IAClD,uBAAuB,EAAE,CAAC;IAC1B,mBAAmB,EAAE,EAAE;IACvB,WAAW,EAAE,MAAM;IACnB,MAAM,EAAE,OAAO;CAChB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AAE,CAAC;gBACzB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;IACH,CAAC;IAEO,WAAW;QACjB,IAAI,MAAwD,CAAC;QAE7D,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACjD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC5B,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;oBAChB,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;wBACtD,MAAM,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;oBAC7B,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NLcURL -- Pure TypeScript HTTP client with browser fingerprint impersonation.
|
|
3
|
+
*
|
|
4
|
+
* Zero runtime dependencies. Uses Node.js built-in modules exclusively.
|
|
5
|
+
*
|
|
6
|
+
* @module nlcurl
|
|
7
|
+
*/
|
|
8
|
+
export type { HttpMethod, NLcURLRequest, NLcURLSessionConfig, RequestBody, RequestTimings, RetryConfig, TimeoutConfig, } from './core/request.js';
|
|
9
|
+
export { NLcURLResponse } from './core/response.js';
|
|
10
|
+
export type { ResponseMeta } from './core/response.js';
|
|
11
|
+
export { NLcURLError, TLSError, HTTPError, TimeoutError, ProxyError, AbortError, ConnectionError, ProtocolError, } from './core/errors.js';
|
|
12
|
+
export { NLcURLSession, type RequestOptions } from './core/session.js';
|
|
13
|
+
export { createSession, request, get, post, put, patch, del, head, } from './core/client.js';
|
|
14
|
+
export { getProfile, listProfiles, DEFAULT_PROFILE, } from './fingerprints/database.js';
|
|
15
|
+
export type { BrowserProfile, TLSProfile, H2Profile, HeaderProfile, } from './fingerprints/types.js';
|
|
16
|
+
export type { RequestInterceptor, ResponseInterceptor, } from './middleware/interceptor.js';
|
|
17
|
+
export type { RateLimitConfig } from './middleware/rate-limiter.js';
|
|
18
|
+
export { CookieJar } from './cookies/jar.js';
|
|
19
|
+
export { WebSocketClient, type WebSocketOptions, type WebSocketEvents } from './ws/client.js';
|
|
20
|
+
export { ja3Hash, ja3String } from './fingerprints/ja3.js';
|
|
21
|
+
export { akamaiFingerprint } from './fingerprints/akamai.js';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EACV,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,WAAW,EACX,aAAa,GACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,OAAO,EACL,WAAW,EACX,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,UAAU,EACV,UAAU,EACV,eAAe,EACf,aAAa,GACd,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EACL,aAAa,EACb,OAAO,EACP,GAAG,EACH,IAAI,EACJ,GAAG,EACH,KAAK,EACL,GAAG,EACH,IAAI,GACL,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,UAAU,EACV,YAAY,EACZ,eAAe,GAChB,MAAM,4BAA4B,CAAC;AAEpC,YAAY,EACV,cAAc,EACd,UAAU,EACV,SAAS,EACT,aAAa,GACd,MAAM,yBAAyB,CAAC;AAGjC,YAAY,EACV,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AAErC,YAAY,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAGpE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C,OAAO,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAG9F,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NLcURL -- Pure TypeScript HTTP client with browser fingerprint impersonation.
|
|
3
|
+
*
|
|
4
|
+
* Zero runtime dependencies. Uses Node.js built-in modules exclusively.
|
|
5
|
+
*
|
|
6
|
+
* @module nlcurl
|
|
7
|
+
*/
|
|
8
|
+
export { NLcURLResponse } from './core/response.js';
|
|
9
|
+
// ---- Error types ----
|
|
10
|
+
export { NLcURLError, TLSError, HTTPError, TimeoutError, ProxyError, AbortError, ConnectionError, ProtocolError, } from './core/errors.js';
|
|
11
|
+
// ---- Session and client ----
|
|
12
|
+
export { NLcURLSession } from './core/session.js';
|
|
13
|
+
export { createSession, request, get, post, put, patch, del, head, } from './core/client.js';
|
|
14
|
+
// ---- Fingerprints ----
|
|
15
|
+
export { getProfile, listProfiles, DEFAULT_PROFILE, } from './fingerprints/database.js';
|
|
16
|
+
// ---- Cookies ----
|
|
17
|
+
export { CookieJar } from './cookies/jar.js';
|
|
18
|
+
// ---- WebSocket ----
|
|
19
|
+
export { WebSocketClient } from './ws/client.js';
|
|
20
|
+
// ---- Utilities ----
|
|
21
|
+
export { ja3Hash, ja3String } from './fingerprints/ja3.js';
|
|
22
|
+
export { akamaiFingerprint } from './fingerprints/akamai.js';
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAaH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,wBAAwB;AACxB,OAAO,EACL,WAAW,EACX,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,UAAU,EACV,UAAU,EACV,eAAe,EACf,aAAa,GACd,MAAM,kBAAkB,CAAC;AAE1B,+BAA+B;AAC/B,OAAO,EAAE,aAAa,EAAuB,MAAM,mBAAmB,CAAC;AACvE,OAAO,EACL,aAAa,EACb,OAAO,EACP,GAAG,EACH,IAAI,EACJ,GAAG,EACH,KAAK,EACL,GAAG,EACH,IAAI,GACL,MAAM,kBAAkB,CAAC;AAE1B,yBAAyB;AACzB,OAAO,EACL,UAAU,EACV,YAAY,EACZ,eAAe,GAChB,MAAM,4BAA4B,CAAC;AAiBpC,oBAAoB;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,sBAAsB;AACtB,OAAO,EAAE,eAAe,EAA+C,MAAM,gBAAgB,CAAC;AAE9F,sBAAsB;AACtB,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request/response interceptor middleware.
|
|
3
|
+
*/
|
|
4
|
+
import type { NLcURLRequest } from '../core/request.js';
|
|
5
|
+
import { NLcURLResponse } from '../core/response.js';
|
|
6
|
+
/**
|
|
7
|
+
* A function that can modify a request before it is sent.
|
|
8
|
+
*/
|
|
9
|
+
export type RequestInterceptor = (request: NLcURLRequest) => NLcURLRequest | Promise<NLcURLRequest>;
|
|
10
|
+
/**
|
|
11
|
+
* A function that can modify or inspect a response after it is received.
|
|
12
|
+
*/
|
|
13
|
+
export type ResponseInterceptor = (response: NLcURLResponse) => NLcURLResponse | Promise<NLcURLResponse>;
|
|
14
|
+
/**
|
|
15
|
+
* Middleware chain.
|
|
16
|
+
*
|
|
17
|
+
* Interceptors are executed in FIFO order.
|
|
18
|
+
*/
|
|
19
|
+
export declare class InterceptorChain {
|
|
20
|
+
private readonly requestInterceptors;
|
|
21
|
+
private readonly responseInterceptors;
|
|
22
|
+
addRequestInterceptor(fn: RequestInterceptor): this;
|
|
23
|
+
addResponseInterceptor(fn: ResponseInterceptor): this;
|
|
24
|
+
processRequest(request: NLcURLRequest): Promise<NLcURLRequest>;
|
|
25
|
+
processResponse(response: NLcURLResponse): Promise<NLcURLResponse>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=interceptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interceptor.d.ts","sourceRoot":"","sources":["../../src/middleware/interceptor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAC/B,OAAO,EAAE,aAAa,KACnB,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAChC,QAAQ,EAAE,cAAc,KACrB,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAE9C;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAA4B;IAChE,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAA6B;IAElE,qBAAqB,CAAC,EAAE,EAAE,kBAAkB,GAAG,IAAI;IAKnD,sBAAsB,CAAC,EAAE,EAAE,mBAAmB,GAAG,IAAI;IAK/C,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAQ9D,eAAe,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;CAOzE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request/response interceptor middleware.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Middleware chain.
|
|
6
|
+
*
|
|
7
|
+
* Interceptors are executed in FIFO order.
|
|
8
|
+
*/
|
|
9
|
+
export class InterceptorChain {
|
|
10
|
+
requestInterceptors = [];
|
|
11
|
+
responseInterceptors = [];
|
|
12
|
+
addRequestInterceptor(fn) {
|
|
13
|
+
this.requestInterceptors.push(fn);
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
addResponseInterceptor(fn) {
|
|
17
|
+
this.responseInterceptors.push(fn);
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
async processRequest(request) {
|
|
21
|
+
let req = request;
|
|
22
|
+
for (const fn of this.requestInterceptors) {
|
|
23
|
+
req = await fn(req);
|
|
24
|
+
}
|
|
25
|
+
return req;
|
|
26
|
+
}
|
|
27
|
+
async processResponse(response) {
|
|
28
|
+
let resp = response;
|
|
29
|
+
for (const fn of this.responseInterceptors) {
|
|
30
|
+
resp = await fn(resp);
|
|
31
|
+
}
|
|
32
|
+
return resp;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=interceptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interceptor.js","sourceRoot":"","sources":["../../src/middleware/interceptor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAmBH;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IACV,mBAAmB,GAAyB,EAAE,CAAC;IAC/C,oBAAoB,GAA0B,EAAE,CAAC;IAElE,qBAAqB,CAAC,EAAsB;QAC1C,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,sBAAsB,CAAC,EAAuB;QAC5C,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,OAAsB;QACzC,IAAI,GAAG,GAAG,OAAO,CAAC;QAClB,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC1C,GAAG,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,QAAwB;QAC5C,IAAI,IAAI,GAAG,QAAQ,CAAC;QACpB,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC3C,IAAI,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rate limiter middleware.
|
|
3
|
+
*
|
|
4
|
+
* Token-bucket rate limiter for controlling request frequency.
|
|
5
|
+
*/
|
|
6
|
+
export interface RateLimitConfig {
|
|
7
|
+
/** Maximum requests per window. */
|
|
8
|
+
maxRequests: number;
|
|
9
|
+
/** Window duration in milliseconds. */
|
|
10
|
+
windowMs: number;
|
|
11
|
+
}
|
|
12
|
+
export declare class RateLimiter {
|
|
13
|
+
private readonly maxRequests;
|
|
14
|
+
private readonly windowMs;
|
|
15
|
+
private tokens;
|
|
16
|
+
private lastRefill;
|
|
17
|
+
private waitQueue;
|
|
18
|
+
constructor(config: RateLimitConfig);
|
|
19
|
+
/**
|
|
20
|
+
* Wait until a request token is available.
|
|
21
|
+
*/
|
|
22
|
+
acquire(): Promise<void>;
|
|
23
|
+
private drain;
|
|
24
|
+
private refill;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=rate-limiter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rate-limiter.d.ts","sourceRoot":"","sources":["../../src/middleware/rate-limiter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,eAAe;IAC9B,mCAAmC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAyB;gBAE9B,MAAM,EAAE,eAAe;IAOnC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAkB9B,OAAO,CAAC,KAAK;IAgBb,OAAO,CAAC,MAAM;CAQf"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rate limiter middleware.
|
|
3
|
+
*
|
|
4
|
+
* Token-bucket rate limiter for controlling request frequency.
|
|
5
|
+
*/
|
|
6
|
+
export class RateLimiter {
|
|
7
|
+
maxRequests;
|
|
8
|
+
windowMs;
|
|
9
|
+
tokens;
|
|
10
|
+
lastRefill;
|
|
11
|
+
waitQueue = [];
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.maxRequests = config.maxRequests;
|
|
14
|
+
this.windowMs = config.windowMs;
|
|
15
|
+
this.tokens = config.maxRequests;
|
|
16
|
+
this.lastRefill = Date.now();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Wait until a request token is available.
|
|
20
|
+
*/
|
|
21
|
+
async acquire() {
|
|
22
|
+
this.refill();
|
|
23
|
+
if (this.tokens > 0) {
|
|
24
|
+
this.tokens--;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
// Enqueue and wait for a token to become available
|
|
28
|
+
await new Promise((resolve) => {
|
|
29
|
+
this.waitQueue.push(resolve);
|
|
30
|
+
// Schedule a refill check after the current window expires
|
|
31
|
+
const elapsed = Date.now() - this.lastRefill;
|
|
32
|
+
const waitMs = Math.max(1, this.windowMs - elapsed);
|
|
33
|
+
setTimeout(() => this.drain(), waitMs);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
drain() {
|
|
37
|
+
this.refill();
|
|
38
|
+
while (this.tokens > 0 && this.waitQueue.length > 0) {
|
|
39
|
+
this.tokens--;
|
|
40
|
+
const next = this.waitQueue.shift();
|
|
41
|
+
next();
|
|
42
|
+
}
|
|
43
|
+
// If there are still waiters, schedule another drain
|
|
44
|
+
if (this.waitQueue.length > 0) {
|
|
45
|
+
const elapsed = Date.now() - this.lastRefill;
|
|
46
|
+
const waitMs = Math.max(1, this.windowMs - elapsed);
|
|
47
|
+
setTimeout(() => this.drain(), waitMs);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
refill() {
|
|
51
|
+
const now = Date.now();
|
|
52
|
+
const elapsed = now - this.lastRefill;
|
|
53
|
+
if (elapsed >= this.windowMs) {
|
|
54
|
+
this.tokens = this.maxRequests;
|
|
55
|
+
this.lastRefill = now;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=rate-limiter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rate-limiter.js","sourceRoot":"","sources":["../../src/middleware/rate-limiter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,MAAM,OAAO,WAAW;IACL,WAAW,CAAS;IACpB,QAAQ,CAAS;IAC1B,MAAM,CAAS;IACf,UAAU,CAAS;IACnB,SAAS,GAAsB,EAAE,CAAC;IAE1C,YAAY,MAAuB;QACjC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACtC,IAAI,CAAC,Q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AC;YAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,CAAC;YACpD,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,MAAM,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAEO,MAAM;QACZ,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC;QACtC,IAAI,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC;YAC/B,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;QACxB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retry middleware.
|
|
3
|
+
*
|
|
4
|
+
* Implements configurable retry logic with exponential backoff.
|
|
5
|
+
*/
|
|
6
|
+
import type { RetryConfig } from '../core/request.js';
|
|
7
|
+
import { NLcURLResponse } from '../core/response.js';
|
|
8
|
+
export interface RetryContext {
|
|
9
|
+
attempt: number;
|
|
10
|
+
lastError?: Error;
|
|
11
|
+
lastResponse?: NLcURLResponse;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Execute a request function with retry logic.
|
|
15
|
+
*/
|
|
16
|
+
export declare function withRetry(config: RetryConfig | undefined, execute: (ctx: RetryContext) => Promise<NLcURLResponse>): Promise<NLcURLResponse>;
|
|
17
|
+
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/middleware/retry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB,YAAY,CAAC,EAAE,cAAc,CAAC;CAC/B;AAQD;;GAEG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,OAAO,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,OAAO,CAAC,cAAc,CAAC,GACtD,OAAO,CAAC,cAAc,CAAC,CAgDzB"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retry middleware.
|
|
3
|
+
*
|
|
4
|
+
* Implements configurable retry logic with exponential backoff.
|
|
5
|
+
*/
|
|
6
|
+
import { AbortError, TimeoutError, ConnectionError } from '../core/errors.js';
|
|
7
|
+
function shouldRetryDefault(error, statusCode) {
|
|
8
|
+
if (error instanceof ConnectionError || error instanceof TimeoutError)
|
|
9
|
+
return true;
|
|
10
|
+
if (statusCode !== undefined && [429, 500, 502, 503, 504].includes(statusCode))
|
|
11
|
+
return true;
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Execute a request function with retry logic.
|
|
16
|
+
*/
|
|
17
|
+
export async function withRetry(config, execute) {
|
|
18
|
+
const count = config?.count ?? 3;
|
|
19
|
+
const baseDelay = config?.delay ?? 1000;
|
|
20
|
+
const backoff = config?.backoff ?? 'exponential';
|
|
21
|
+
const jitterMax = config?.jitter ?? 200;
|
|
22
|
+
const retryOn = config?.retryOn ?? shouldRetryDefault;
|
|
23
|
+
let lastError;
|
|
24
|
+
let lastResponse;
|
|
25
|
+
for (let attempt = 0; attempt <= count; attempt++) {
|
|
26
|
+
// Wait before retry (skip first attempt)
|
|
27
|
+
if (attempt > 0) {
|
|
28
|
+
const factor = backoff === 'exponential'
|
|
29
|
+
? Math.pow(2, attempt - 1)
|
|
30
|
+
: attempt;
|
|
31
|
+
const delay = baseDelay * factor;
|
|
32
|
+
const jitter = Math.random() * jitterMax;
|
|
33
|
+
await sleep(delay + jitter);
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const response = await execute({ attempt, lastError, lastResponse });
|
|
37
|
+
// Check if response status warrants retry
|
|
38
|
+
if (attempt < count && retryOn(null, response.status)) {
|
|
39
|
+
lastResponse = response;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
return response;
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
// Never retry aborted requests
|
|
46
|
+
if (err instanceof AbortError)
|
|
47
|
+
throw err;
|
|
48
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
49
|
+
if (attempt < count && retryOn(error)) {
|
|
50
|
+
lastError = error;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
throw err;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Should not reach here, but if it does, throw the last error
|
|
57
|
+
if (lastError)
|
|
58
|
+
throw lastError;
|
|
59
|
+
return lastResponse;
|
|
60
|
+
}
|
|
61
|
+
function sleep(ms) {
|
|
62
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=retry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/middleware/retry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAQ9E,SAAS,kBAAkB,CAAC,KAAmB,EAAE,UAAmB;IAClE,IAAI,KAAK,YAAY,eAAe,IAAI,KAAK,YAAY,YAAY;QAAE,OAAO,IAAI,CAAC;IACnF,IAAI,UAAU,KAAK,SAAS,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC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G,QAAQ,CAAC;gBACxB,SAAS;YACX,CAAC;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,+BAA+B;YAC/B,IAAI,GAAG,YAAY,UAAU;gBAAE,MAAM,GAAG,CAAC;YAEzC,MAAM,KAAK,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YAClE,IAAI,OAAO,GAAG,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACtC,SAAS,GAAG,KAAK,CAAC;gBAClB,SAAS;YACX,CAAC;YAED,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;IAED,8DAA8D;IAC9D,IAAI,SAAS;QAAE,MAAM,SAAS,CAAC;IAC/B,OAAO,YAAa,CAAC;AACvB,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP CONNECT proxy tunneling.
|
|
3
|
+
*
|
|
4
|
+
* Establishes a TCP tunnel through an HTTP proxy using the CONNECT
|
|
5
|
+
* method, then returns the raw socket for TLS negotiation.
|
|
6
|
+
*/
|
|
7
|
+
import * as net from 'node:net';
|
|
8
|
+
export interface HttpProxyOptions {
|
|
9
|
+
host: string;
|
|
10
|
+
port: number;
|
|
11
|
+
/** Proxy authentication (user:pass). */
|
|
12
|
+
auth?: string;
|
|
13
|
+
/** Timeout in milliseconds. */
|
|
14
|
+
timeout?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Connect to a target host:port through an HTTP CONNECT proxy.
|
|
18
|
+
*
|
|
19
|
+
* Returns a raw TCP socket with the tunnel established, ready for
|
|
20
|
+
* TLS handshake.
|
|
21
|
+
*/
|
|
22
|
+
export declare function httpProxyConnect(proxy: HttpProxyOptions, targetHost: string, targetPort: number): Promise<net.Socket>;
|
|
23
|
+
//# sourceMappingURL=http-proxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-proxy.d.ts","sourceRoot":"","sources":["../../src/proxy/http-proxy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAGhC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,gBAAgB,EACvB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAwFrB"}
|