@depup/undici 7.24.3-depup.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 +25 -0
- package/changes.json +5 -0
- package/docs/docs/api/Agent.md +84 -0
- package/docs/docs/api/BalancedPool.md +99 -0
- package/docs/docs/api/CacheStorage.md +30 -0
- package/docs/docs/api/CacheStore.md +164 -0
- package/docs/docs/api/Client.md +285 -0
- package/docs/docs/api/ClientStats.md +27 -0
- package/docs/docs/api/Connector.md +115 -0
- package/docs/docs/api/ContentType.md +57 -0
- package/docs/docs/api/Cookies.md +101 -0
- package/docs/docs/api/Debug.md +62 -0
- package/docs/docs/api/DiagnosticsChannel.md +313 -0
- package/docs/docs/api/Dispatcher.md +1392 -0
- package/docs/docs/api/EnvHttpProxyAgent.md +159 -0
- package/docs/docs/api/Errors.md +49 -0
- package/docs/docs/api/EventSource.md +45 -0
- package/docs/docs/api/Fetch.md +52 -0
- package/docs/docs/api/GlobalInstallation.md +91 -0
- package/docs/docs/api/H2CClient.md +263 -0
- package/docs/docs/api/MockAgent.md +603 -0
- package/docs/docs/api/MockCallHistory.md +197 -0
- package/docs/docs/api/MockCallHistoryLog.md +43 -0
- package/docs/docs/api/MockClient.md +81 -0
- package/docs/docs/api/MockErrors.md +12 -0
- package/docs/docs/api/MockPool.md +555 -0
- package/docs/docs/api/Pool.md +84 -0
- package/docs/docs/api/PoolStats.md +35 -0
- package/docs/docs/api/ProxyAgent.md +229 -0
- package/docs/docs/api/RedirectHandler.md +96 -0
- package/docs/docs/api/RetryAgent.md +50 -0
- package/docs/docs/api/RetryHandler.md +118 -0
- package/docs/docs/api/RoundRobinPool.md +145 -0
- package/docs/docs/api/SnapshotAgent.md +616 -0
- package/docs/docs/api/Socks5ProxyAgent.md +274 -0
- package/docs/docs/api/Util.md +25 -0
- package/docs/docs/api/WebSocket.md +141 -0
- package/docs/docs/api/api-lifecycle.md +91 -0
- package/docs/docs/best-practices/client-certificate.md +64 -0
- package/docs/docs/best-practices/crawling.md +58 -0
- package/docs/docs/best-practices/mocking-request.md +190 -0
- package/docs/docs/best-practices/proxy.md +127 -0
- package/docs/docs/best-practices/undici-vs-builtin-fetch.md +137 -0
- package/docs/docs/best-practices/writing-tests.md +20 -0
- package/index-fetch.js +65 -0
- package/index.d.ts +3 -0
- package/index.js +234 -0
- package/lib/api/abort-signal.js +59 -0
- package/lib/api/api-connect.js +110 -0
- package/lib/api/api-pipeline.js +252 -0
- package/lib/api/api-request.js +214 -0
- package/lib/api/api-stream.js +209 -0
- package/lib/api/api-upgrade.js +111 -0
- package/lib/api/index.js +7 -0
- package/lib/api/readable.js +580 -0
- package/lib/cache/memory-cache-store.js +234 -0
- package/lib/cache/sqlite-cache-store.js +461 -0
- package/lib/core/connect.js +137 -0
- package/lib/core/constants.js +143 -0
- package/lib/core/diagnostics.js +225 -0
- package/lib/core/errors.js +477 -0
- package/lib/core/request.js +430 -0
- package/lib/core/socks5-client.js +407 -0
- package/lib/core/socks5-utils.js +203 -0
- package/lib/core/symbols.js +75 -0
- package/lib/core/tree.js +160 -0
- package/lib/core/util.js +972 -0
- package/lib/dispatcher/agent.js +158 -0
- package/lib/dispatcher/balanced-pool.js +219 -0
- package/lib/dispatcher/client-h1.js +1610 -0
- package/lib/dispatcher/client-h2.js +995 -0
- package/lib/dispatcher/client.js +654 -0
- package/lib/dispatcher/dispatcher-base.js +165 -0
- package/lib/dispatcher/dispatcher.js +48 -0
- package/lib/dispatcher/env-http-proxy-agent.js +146 -0
- package/lib/dispatcher/fixed-queue.js +135 -0
- package/lib/dispatcher/h2c-client.js +51 -0
- package/lib/dispatcher/pool-base.js +214 -0
- package/lib/dispatcher/pool.js +118 -0
- package/lib/dispatcher/proxy-agent.js +318 -0
- package/lib/dispatcher/retry-agent.js +35 -0
- package/lib/dispatcher/round-robin-pool.js +137 -0
- package/lib/dispatcher/socks5-proxy-agent.js +249 -0
- package/lib/encoding/index.js +33 -0
- package/lib/global.js +50 -0
- package/lib/handler/cache-handler.js +561 -0
- package/lib/handler/cache-revalidation-handler.js +124 -0
- package/lib/handler/decorator-handler.js +67 -0
- package/lib/handler/deduplication-handler.js +460 -0
- package/lib/handler/redirect-handler.js +238 -0
- package/lib/handler/retry-handler.js +394 -0
- package/lib/handler/unwrap-handler.js +100 -0
- package/lib/handler/wrap-handler.js +105 -0
- package/lib/interceptor/cache.js +495 -0
- package/lib/interceptor/decompress.js +259 -0
- package/lib/interceptor/deduplicate.js +117 -0
- package/lib/interceptor/dns.js +571 -0
- package/lib/interceptor/dump.js +112 -0
- package/lib/interceptor/redirect.js +21 -0
- package/lib/interceptor/response-error.js +95 -0
- package/lib/interceptor/retry.js +19 -0
- package/lib/llhttp/.gitkeep +0 -0
- package/lib/llhttp/constants.d.ts +195 -0
- package/lib/llhttp/constants.js +531 -0
- package/lib/llhttp/llhttp-wasm.js +15 -0
- package/lib/llhttp/llhttp_simd-wasm.js +15 -0
- package/lib/llhttp/utils.d.ts +2 -0
- package/lib/llhttp/utils.js +12 -0
- package/lib/mock/mock-agent.js +232 -0
- package/lib/mock/mock-call-history.js +248 -0
- package/lib/mock/mock-client.js +68 -0
- package/lib/mock/mock-errors.js +29 -0
- package/lib/mock/mock-interceptor.js +209 -0
- package/lib/mock/mock-pool.js +68 -0
- package/lib/mock/mock-symbols.js +31 -0
- package/lib/mock/mock-utils.js +480 -0
- package/lib/mock/pending-interceptors-formatter.js +43 -0
- package/lib/mock/snapshot-agent.js +353 -0
- package/lib/mock/snapshot-recorder.js +588 -0
- package/lib/mock/snapshot-utils.js +158 -0
- package/lib/util/cache.js +407 -0
- package/lib/util/date.js +653 -0
- package/lib/util/promise.js +28 -0
- package/lib/util/runtime-features.js +124 -0
- package/lib/util/stats.js +32 -0
- package/lib/util/timers.js +425 -0
- package/lib/web/cache/cache.js +864 -0
- package/lib/web/cache/cachestorage.js +152 -0
- package/lib/web/cache/util.js +45 -0
- package/lib/web/cookies/constants.js +12 -0
- package/lib/web/cookies/index.js +199 -0
- package/lib/web/cookies/parse.js +322 -0
- package/lib/web/cookies/util.js +282 -0
- package/lib/web/eventsource/eventsource-stream.js +399 -0
- package/lib/web/eventsource/eventsource.js +501 -0
- package/lib/web/eventsource/util.js +29 -0
- package/lib/web/fetch/LICENSE +21 -0
- package/lib/web/fetch/body.js +509 -0
- package/lib/web/fetch/constants.js +131 -0
- package/lib/web/fetch/data-url.js +596 -0
- package/lib/web/fetch/formdata-parser.js +575 -0
- package/lib/web/fetch/formdata.js +259 -0
- package/lib/web/fetch/global.js +40 -0
- package/lib/web/fetch/headers.js +719 -0
- package/lib/web/fetch/index.js +2378 -0
- package/lib/web/fetch/request.js +1115 -0
- package/lib/web/fetch/response.js +641 -0
- package/lib/web/fetch/util.js +1520 -0
- package/lib/web/infra/index.js +229 -0
- package/lib/web/subresource-integrity/Readme.md +9 -0
- package/lib/web/subresource-integrity/subresource-integrity.js +307 -0
- package/lib/web/webidl/index.js +1006 -0
- package/lib/web/websocket/connection.js +329 -0
- package/lib/web/websocket/constants.js +126 -0
- package/lib/web/websocket/events.js +331 -0
- package/lib/web/websocket/frame.js +133 -0
- package/lib/web/websocket/permessage-deflate.js +118 -0
- package/lib/web/websocket/receiver.js +450 -0
- package/lib/web/websocket/sender.js +109 -0
- package/lib/web/websocket/stream/websocketerror.js +104 -0
- package/lib/web/websocket/stream/websocketstream.js +497 -0
- package/lib/web/websocket/util.js +347 -0
- package/lib/web/websocket/websocket.js +739 -0
- package/package.json +163 -0
- package/scripts/strip-comments.js +10 -0
- package/types/README.md +6 -0
- package/types/agent.d.ts +32 -0
- package/types/api.d.ts +43 -0
- package/types/balanced-pool.d.ts +30 -0
- package/types/cache-interceptor.d.ts +179 -0
- package/types/cache.d.ts +36 -0
- package/types/client-stats.d.ts +15 -0
- package/types/client.d.ts +123 -0
- package/types/connector.d.ts +36 -0
- package/types/content-type.d.ts +21 -0
- package/types/cookies.d.ts +30 -0
- package/types/diagnostics-channel.d.ts +74 -0
- package/types/dispatcher.d.ts +279 -0
- package/types/env-http-proxy-agent.d.ts +22 -0
- package/types/errors.d.ts +177 -0
- package/types/eventsource.d.ts +66 -0
- package/types/fetch.d.ts +211 -0
- package/types/formdata.d.ts +108 -0
- package/types/global-dispatcher.d.ts +9 -0
- package/types/global-origin.d.ts +7 -0
- package/types/h2c-client.d.ts +73 -0
- package/types/handlers.d.ts +15 -0
- package/types/header.d.ts +160 -0
- package/types/index.d.ts +91 -0
- package/types/interceptors.d.ts +80 -0
- package/types/mock-agent.d.ts +68 -0
- package/types/mock-call-history.d.ts +111 -0
- package/types/mock-client.d.ts +27 -0
- package/types/mock-errors.d.ts +12 -0
- package/types/mock-interceptor.d.ts +94 -0
- package/types/mock-pool.d.ts +27 -0
- package/types/patch.d.ts +29 -0
- package/types/pool-stats.d.ts +19 -0
- package/types/pool.d.ts +41 -0
- package/types/proxy-agent.d.ts +29 -0
- package/types/readable.d.ts +68 -0
- package/types/retry-agent.d.ts +8 -0
- package/types/retry-handler.d.ts +125 -0
- package/types/round-robin-pool.d.ts +41 -0
- package/types/snapshot-agent.d.ts +109 -0
- package/types/socks5-proxy-agent.d.ts +25 -0
- package/types/util.d.ts +18 -0
- package/types/utility.d.ts +7 -0
- package/types/webidl.d.ts +347 -0
- package/types/websocket.d.ts +188 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
|
|
3
|
+
import type { Blob } from 'node:buffer'
|
|
4
|
+
import type { ReadableStream, WritableStream } from 'node:stream/web'
|
|
5
|
+
import type { MessagePort } from 'node:worker_threads'
|
|
6
|
+
import {
|
|
7
|
+
EventInit,
|
|
8
|
+
EventListenerOptions,
|
|
9
|
+
AddEventListenerOptions,
|
|
10
|
+
EventListenerOrEventListenerObject
|
|
11
|
+
} from './patch'
|
|
12
|
+
import Dispatcher from './dispatcher'
|
|
13
|
+
import { HeadersInit } from './fetch'
|
|
14
|
+
|
|
15
|
+
export type BinaryType = 'blob' | 'arraybuffer'
|
|
16
|
+
|
|
17
|
+
interface WebSocketEventMap {
|
|
18
|
+
close: CloseEvent
|
|
19
|
+
error: ErrorEvent
|
|
20
|
+
message: MessageEvent
|
|
21
|
+
open: Event
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface WebSocket extends EventTarget {
|
|
25
|
+
binaryType: BinaryType
|
|
26
|
+
|
|
27
|
+
readonly bufferedAmount: number
|
|
28
|
+
readonly extensions: string
|
|
29
|
+
|
|
30
|
+
onclose: ((this: WebSocket, ev: WebSocketEventMap['close']) => any) | null
|
|
31
|
+
onerror: ((this: WebSocket, ev: WebSocketEventMap['error']) => any) | null
|
|
32
|
+
onmessage: ((this: WebSocket, ev: WebSocketEventMap['message']) => any) | null
|
|
33
|
+
onopen: ((this: WebSocket, ev: WebSocketEventMap['open']) => any) | null
|
|
34
|
+
|
|
35
|
+
readonly protocol: string
|
|
36
|
+
readonly readyState: number
|
|
37
|
+
readonly url: string
|
|
38
|
+
|
|
39
|
+
close(code?: number, reason?: string): void
|
|
40
|
+
send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void
|
|
41
|
+
|
|
42
|
+
readonly CLOSED: number
|
|
43
|
+
readonly CLOSING: number
|
|
44
|
+
readonly CONNECTING: number
|
|
45
|
+
readonly OPEN: number
|
|
46
|
+
|
|
47
|
+
addEventListener<K extends keyof WebSocketEventMap>(
|
|
48
|
+
type: K,
|
|
49
|
+
listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any,
|
|
50
|
+
options?: boolean | AddEventListenerOptions
|
|
51
|
+
): void
|
|
52
|
+
addEventListener(
|
|
53
|
+
type: string,
|
|
54
|
+
listener: EventListenerOrEventListenerObject,
|
|
55
|
+
options?: boolean | AddEventListenerOptions
|
|
56
|
+
): void
|
|
57
|
+
removeEventListener<K extends keyof WebSocketEventMap>(
|
|
58
|
+
type: K,
|
|
59
|
+
listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any,
|
|
60
|
+
options?: boolean | EventListenerOptions
|
|
61
|
+
): void
|
|
62
|
+
removeEventListener(
|
|
63
|
+
type: string,
|
|
64
|
+
listener: EventListenerOrEventListenerObject,
|
|
65
|
+
options?: boolean | EventListenerOptions
|
|
66
|
+
): void
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export declare const WebSocket: {
|
|
70
|
+
prototype: WebSocket
|
|
71
|
+
new (url: string | URL, protocols?: string | string[] | WebSocketInit): WebSocket
|
|
72
|
+
readonly CLOSED: number
|
|
73
|
+
readonly CLOSING: number
|
|
74
|
+
readonly CONNECTING: number
|
|
75
|
+
readonly OPEN: number
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
interface CloseEventInit extends EventInit {
|
|
79
|
+
code?: number
|
|
80
|
+
reason?: string
|
|
81
|
+
wasClean?: boolean
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface CloseEvent extends Event {
|
|
85
|
+
readonly code: number
|
|
86
|
+
readonly reason: string
|
|
87
|
+
readonly wasClean: boolean
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export declare const CloseEvent: {
|
|
91
|
+
prototype: CloseEvent
|
|
92
|
+
new (type: string, eventInitDict?: CloseEventInit): CloseEvent
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
interface MessageEventInit<T = any> extends EventInit {
|
|
96
|
+
data?: T
|
|
97
|
+
lastEventId?: string
|
|
98
|
+
origin?: string
|
|
99
|
+
ports?: MessagePort[]
|
|
100
|
+
source?: MessagePort | null
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
interface MessageEvent<T = any> extends Event {
|
|
104
|
+
readonly data: T
|
|
105
|
+
readonly lastEventId: string
|
|
106
|
+
readonly origin: string
|
|
107
|
+
readonly ports: readonly MessagePort[]
|
|
108
|
+
readonly source: MessagePort | null
|
|
109
|
+
initMessageEvent(
|
|
110
|
+
type: string,
|
|
111
|
+
bubbles?: boolean,
|
|
112
|
+
cancelable?: boolean,
|
|
113
|
+
data?: any,
|
|
114
|
+
origin?: string,
|
|
115
|
+
lastEventId?: string,
|
|
116
|
+
source?: MessagePort | null,
|
|
117
|
+
ports?: MessagePort[]
|
|
118
|
+
): void;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export declare const MessageEvent: {
|
|
122
|
+
prototype: MessageEvent
|
|
123
|
+
new<T>(type: string, eventInitDict?: MessageEventInit<T>): MessageEvent<T>
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
interface ErrorEventInit extends EventInit {
|
|
127
|
+
message?: string
|
|
128
|
+
filename?: string
|
|
129
|
+
lineno?: number
|
|
130
|
+
colno?: number
|
|
131
|
+
error?: any
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
interface ErrorEvent extends Event {
|
|
135
|
+
readonly message: string
|
|
136
|
+
readonly filename: string
|
|
137
|
+
readonly lineno: number
|
|
138
|
+
readonly colno: number
|
|
139
|
+
readonly error: Error
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export declare const ErrorEvent: {
|
|
143
|
+
prototype: ErrorEvent
|
|
144
|
+
new (type: string, eventInitDict?: ErrorEventInit): ErrorEvent
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
interface WebSocketInit {
|
|
148
|
+
protocols?: string | string[],
|
|
149
|
+
dispatcher?: Dispatcher,
|
|
150
|
+
headers?: HeadersInit
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
interface WebSocketStreamOptions {
|
|
154
|
+
protocols?: string | string[]
|
|
155
|
+
signal?: AbortSignal
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
interface WebSocketCloseInfo {
|
|
159
|
+
closeCode: number
|
|
160
|
+
reason: string
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
interface WebSocketStream {
|
|
164
|
+
closed: Promise<WebSocketCloseInfo>
|
|
165
|
+
opened: Promise<{
|
|
166
|
+
extensions: string
|
|
167
|
+
protocol: string
|
|
168
|
+
readable: ReadableStream
|
|
169
|
+
writable: WritableStream
|
|
170
|
+
}>
|
|
171
|
+
url: string
|
|
172
|
+
|
|
173
|
+
close(options?: Partial<WebSocketCloseInfo>): void
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export declare const WebSocketStream: {
|
|
177
|
+
prototype: WebSocketStream
|
|
178
|
+
new (url: string | URL, options?: WebSocketStreamOptions): WebSocketStream
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
interface WebSocketError extends Event, WebSocketCloseInfo {}
|
|
182
|
+
|
|
183
|
+
export declare const WebSocketError: {
|
|
184
|
+
prototype: WebSocketError
|
|
185
|
+
new (type: string, init?: WebSocketCloseInfo): WebSocketError
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export declare const ping: (ws: WebSocket, body?: Buffer) => void
|