undici 6.19.8 → 7.0.0-alpha.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/README.md +5 -9
- package/docs/docs/api/Agent.md +0 -3
- package/docs/docs/api/Client.md +0 -2
- package/docs/docs/api/Dispatcher.md +204 -6
- package/docs/docs/api/EnvHttpProxyAgent.md +0 -1
- package/docs/docs/api/Fetch.md +1 -0
- package/docs/docs/api/Pool.md +0 -1
- package/docs/docs/api/RetryHandler.md +1 -1
- package/index.js +0 -4
- package/lib/api/api-connect.js +3 -1
- package/lib/api/api-pipeline.js +3 -4
- package/lib/api/api-request.js +29 -46
- package/lib/api/api-stream.js +36 -49
- package/lib/api/api-upgrade.js +5 -3
- package/lib/api/readable.js +71 -27
- package/lib/core/connect.js +39 -24
- package/lib/core/errors.js +17 -4
- package/lib/core/request.js +7 -5
- package/lib/core/symbols.js +0 -1
- package/lib/core/tree.js +6 -0
- package/lib/core/util.js +1 -11
- package/lib/dispatcher/agent.js +3 -17
- package/lib/dispatcher/balanced-pool.js +5 -8
- package/lib/dispatcher/client-h1.js +44 -39
- package/lib/dispatcher/client.js +3 -27
- package/lib/dispatcher/dispatcher-base.js +2 -34
- package/lib/dispatcher/dispatcher.js +3 -24
- package/lib/dispatcher/pool.js +3 -6
- package/lib/dispatcher/proxy-agent.js +3 -6
- package/lib/handler/decorator-handler.js +24 -0
- package/lib/handler/redirect-handler.js +9 -0
- package/lib/handler/retry-handler.js +22 -3
- package/lib/interceptor/dump.js +2 -2
- package/lib/interceptor/redirect.js +11 -14
- package/lib/interceptor/response-error.js +89 -0
- package/lib/llhttp/constants.d.ts +97 -0
- package/lib/llhttp/constants.js +412 -192
- package/lib/llhttp/constants.js.map +1 -0
- package/lib/llhttp/llhttp-wasm.js +11 -1
- package/lib/llhttp/llhttp_simd-wasm.js +11 -1
- package/lib/llhttp/utils.d.ts +2 -0
- package/lib/llhttp/utils.js +9 -9
- package/lib/llhttp/utils.js.map +1 -0
- package/lib/mock/mock-client.js +2 -2
- package/lib/mock/mock-pool.js +2 -2
- package/lib/mock/mock-symbols.js +1 -0
- package/lib/util/timers.js +324 -44
- package/lib/web/cookies/index.js +15 -13
- package/lib/web/cookies/parse.js +2 -2
- package/lib/web/eventsource/eventsource-stream.js +9 -8
- package/lib/web/eventsource/eventsource.js +10 -6
- package/lib/web/fetch/body.js +4 -6
- package/lib/web/fetch/data-url.js +1 -1
- package/lib/web/fetch/formdata-parser.js +1 -2
- package/lib/web/fetch/formdata.js +28 -37
- package/lib/web/fetch/headers.js +1 -1
- package/lib/web/fetch/index.js +7 -8
- package/lib/web/fetch/request.js +7 -24
- package/lib/web/fetch/response.js +9 -22
- package/lib/web/fetch/symbols.js +0 -1
- package/lib/web/fetch/util.js +3 -12
- package/lib/web/fetch/webidl.js +73 -62
- package/lib/web/websocket/connection.js +26 -174
- package/lib/web/websocket/constants.js +1 -1
- package/lib/web/websocket/frame.js +45 -3
- package/lib/web/websocket/receiver.js +28 -26
- package/lib/web/websocket/sender.js +18 -13
- package/lib/web/websocket/util.js +20 -74
- package/lib/web/websocket/websocket.js +294 -70
- package/package.json +16 -29
- package/scripts/strip-comments.js +3 -1
- package/types/agent.d.ts +7 -7
- package/types/api.d.ts +24 -24
- package/types/balanced-pool.d.ts +11 -11
- package/types/client.d.ts +11 -12
- package/types/diagnostics-channel.d.ts +10 -10
- package/types/dispatcher.d.ts +96 -97
- package/types/env-http-proxy-agent.d.ts +2 -2
- package/types/errors.d.ts +53 -47
- package/types/eventsource.d.ts +0 -2
- package/types/fetch.d.ts +8 -8
- package/types/formdata.d.ts +7 -7
- package/types/global-dispatcher.d.ts +4 -4
- package/types/global-origin.d.ts +5 -5
- package/types/handlers.d.ts +4 -4
- package/types/header.d.ts +157 -1
- package/types/index.d.ts +42 -46
- package/types/interceptors.d.ts +10 -8
- package/types/mock-agent.d.ts +18 -18
- package/types/mock-client.d.ts +4 -4
- package/types/mock-errors.d.ts +3 -3
- package/types/mock-interceptor.d.ts +19 -19
- package/types/mock-pool.d.ts +4 -4
- package/types/patch.d.ts +0 -42
- package/types/pool-stats.d.ts +8 -8
- package/types/pool.d.ts +12 -12
- package/types/proxy-agent.d.ts +4 -4
- package/types/readable.d.ts +14 -9
- package/types/retry-agent.d.ts +1 -1
- package/types/retry-handler.d.ts +8 -8
- package/types/util.d.ts +3 -3
- package/types/utility.d.ts +7 -0
- package/types/webidl.d.ts +22 -4
- package/types/websocket.d.ts +1 -3
- package/docs/docs/api/DispatchInterceptor.md +0 -60
- package/lib/interceptor/redirect-interceptor.js +0 -21
- package/lib/web/fetch/file.js +0 -126
- package/lib/web/fileapi/encoding.js +0 -290
- package/lib/web/fileapi/filereader.js +0 -344
- package/lib/web/fileapi/progressevent.js +0 -78
- package/lib/web/fileapi/symbols.js +0 -10
- package/lib/web/fileapi/util.js +0 -391
- package/lib/web/websocket/symbols.js +0 -12
- package/types/file.d.ts +0 -39
- package/types/filereader.d.ts +0 -54
package/types/errors.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { IncomingHttpHeaders } from
|
|
1
|
+
import { IncomingHttpHeaders } from './header'
|
|
2
2
|
import Client from './client'
|
|
3
3
|
|
|
4
4
|
export default Errors
|
|
5
5
|
|
|
6
6
|
declare namespace Errors {
|
|
7
7
|
export class UndiciError extends Error {
|
|
8
|
-
name: string
|
|
9
|
-
code: string
|
|
8
|
+
name: string
|
|
9
|
+
code: string
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
/** Connect timeout error. */
|
|
13
13
|
export class ConnectTimeoutError extends UndiciError {
|
|
14
|
-
name: 'ConnectTimeoutError'
|
|
15
|
-
code: 'UND_ERR_CONNECT_TIMEOUT'
|
|
14
|
+
name: 'ConnectTimeoutError'
|
|
15
|
+
code: 'UND_ERR_CONNECT_TIMEOUT'
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/** A header exceeds the `headersTimeout` option. */
|
|
19
19
|
export class HeadersTimeoutError extends UndiciError {
|
|
20
|
-
name: 'HeadersTimeoutError'
|
|
21
|
-
code: 'UND_ERR_HEADERS_TIMEOUT'
|
|
20
|
+
name: 'HeadersTimeoutError'
|
|
21
|
+
code: 'UND_ERR_HEADERS_TIMEOUT'
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/** Headers overflow error. */
|
|
@@ -29,8 +29,8 @@ declare namespace Errors {
|
|
|
29
29
|
|
|
30
30
|
/** A body exceeds the `bodyTimeout` option. */
|
|
31
31
|
export class BodyTimeoutError extends UndiciError {
|
|
32
|
-
name: 'BodyTimeoutError'
|
|
33
|
-
code: 'UND_ERR_BODY_TIMEOUT'
|
|
32
|
+
name: 'BodyTimeoutError'
|
|
33
|
+
code: 'UND_ERR_BODY_TIMEOUT'
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export class ResponseStatusCodeError extends UndiciError {
|
|
@@ -39,91 +39,91 @@ declare namespace Errors {
|
|
|
39
39
|
statusCode?: number,
|
|
40
40
|
headers?: IncomingHttpHeaders | string[] | null,
|
|
41
41
|
body?: null | Record<string, any> | string
|
|
42
|
-
)
|
|
43
|
-
name: 'ResponseStatusCodeError'
|
|
44
|
-
code: 'UND_ERR_RESPONSE_STATUS_CODE'
|
|
42
|
+
)
|
|
43
|
+
name: 'ResponseStatusCodeError'
|
|
44
|
+
code: 'UND_ERR_RESPONSE_STATUS_CODE'
|
|
45
45
|
body: null | Record<string, any> | string
|
|
46
46
|
status: number
|
|
47
47
|
statusCode: number
|
|
48
|
-
headers: IncomingHttpHeaders | string[] | null
|
|
48
|
+
headers: IncomingHttpHeaders | string[] | null
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
/** Passed an invalid argument. */
|
|
52
52
|
export class InvalidArgumentError extends UndiciError {
|
|
53
|
-
name: 'InvalidArgumentError'
|
|
54
|
-
code: 'UND_ERR_INVALID_ARG'
|
|
53
|
+
name: 'InvalidArgumentError'
|
|
54
|
+
code: 'UND_ERR_INVALID_ARG'
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/** Returned an invalid value. */
|
|
58
58
|
export class InvalidReturnValueError extends UndiciError {
|
|
59
|
-
name: 'InvalidReturnValueError'
|
|
60
|
-
code: 'UND_ERR_INVALID_RETURN_VALUE'
|
|
59
|
+
name: 'InvalidReturnValueError'
|
|
60
|
+
code: 'UND_ERR_INVALID_RETURN_VALUE'
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/** The request has been aborted by the user. */
|
|
64
64
|
export class RequestAbortedError extends UndiciError {
|
|
65
|
-
name: 'AbortError'
|
|
66
|
-
code: 'UND_ERR_ABORTED'
|
|
65
|
+
name: 'AbortError'
|
|
66
|
+
code: 'UND_ERR_ABORTED'
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/** Expected error with reason. */
|
|
70
70
|
export class InformationalError extends UndiciError {
|
|
71
|
-
name: 'InformationalError'
|
|
72
|
-
code: 'UND_ERR_INFO'
|
|
71
|
+
name: 'InformationalError'
|
|
72
|
+
code: 'UND_ERR_INFO'
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
/** Request body length does not match content-length header. */
|
|
76
76
|
export class RequestContentLengthMismatchError extends UndiciError {
|
|
77
|
-
name: 'RequestContentLengthMismatchError'
|
|
78
|
-
code: 'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH'
|
|
77
|
+
name: 'RequestContentLengthMismatchError'
|
|
78
|
+
code: 'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH'
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/** Response body length does not match content-length header. */
|
|
82
82
|
export class ResponseContentLengthMismatchError extends UndiciError {
|
|
83
|
-
name: 'ResponseContentLengthMismatchError'
|
|
84
|
-
code: 'UND_ERR_RES_CONTENT_LENGTH_MISMATCH'
|
|
83
|
+
name: 'ResponseContentLengthMismatchError'
|
|
84
|
+
code: 'UND_ERR_RES_CONTENT_LENGTH_MISMATCH'
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/** Trying to use a destroyed client. */
|
|
88
88
|
export class ClientDestroyedError extends UndiciError {
|
|
89
|
-
name: 'ClientDestroyedError'
|
|
90
|
-
code: 'UND_ERR_DESTROYED'
|
|
89
|
+
name: 'ClientDestroyedError'
|
|
90
|
+
code: 'UND_ERR_DESTROYED'
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
/** Trying to use a closed client. */
|
|
94
94
|
export class ClientClosedError extends UndiciError {
|
|
95
|
-
name: 'ClientClosedError'
|
|
96
|
-
code: 'UND_ERR_CLOSED'
|
|
95
|
+
name: 'ClientClosedError'
|
|
96
|
+
code: 'UND_ERR_CLOSED'
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
/** There is an error with the socket. */
|
|
100
100
|
export class SocketError extends UndiciError {
|
|
101
|
-
name: 'SocketError'
|
|
102
|
-
code: 'UND_ERR_SOCKET'
|
|
101
|
+
name: 'SocketError'
|
|
102
|
+
code: 'UND_ERR_SOCKET'
|
|
103
103
|
socket: Client.SocketInfo | null
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
/** Encountered unsupported functionality. */
|
|
107
107
|
export class NotSupportedError extends UndiciError {
|
|
108
|
-
name: 'NotSupportedError'
|
|
109
|
-
code: 'UND_ERR_NOT_SUPPORTED'
|
|
108
|
+
name: 'NotSupportedError'
|
|
109
|
+
code: 'UND_ERR_NOT_SUPPORTED'
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
/** No upstream has been added to the BalancedPool. */
|
|
113
113
|
export class BalancedPoolMissingUpstreamError extends UndiciError {
|
|
114
|
-
name: 'MissingUpstreamError'
|
|
115
|
-
code: 'UND_ERR_BPL_MISSING_UPSTREAM'
|
|
114
|
+
name: 'MissingUpstreamError'
|
|
115
|
+
code: 'UND_ERR_BPL_MISSING_UPSTREAM'
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
export class HTTPParserError extends UndiciError {
|
|
119
|
-
name: 'HTTPParserError'
|
|
120
|
-
code: string
|
|
119
|
+
name: 'HTTPParserError'
|
|
120
|
+
code: string
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
/** The response exceed the length allowed. */
|
|
124
124
|
export class ResponseExceededMaxSizeError extends UndiciError {
|
|
125
|
-
name: 'ResponseExceededMaxSizeError'
|
|
126
|
-
code: 'UND_ERR_RES_EXCEEDED_MAX_SIZE'
|
|
125
|
+
name: 'ResponseExceededMaxSizeError'
|
|
126
|
+
code: 'UND_ERR_RES_EXCEEDED_MAX_SIZE'
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
export class RequestRetryError extends UndiciError {
|
|
@@ -132,18 +132,24 @@ declare namespace Errors {
|
|
|
132
132
|
statusCode: number,
|
|
133
133
|
headers?: IncomingHttpHeaders | string[] | null,
|
|
134
134
|
body?: null | Record<string, any> | string
|
|
135
|
-
)
|
|
136
|
-
name: 'RequestRetryError'
|
|
137
|
-
code: 'UND_ERR_REQ_RETRY'
|
|
138
|
-
statusCode: number
|
|
135
|
+
)
|
|
136
|
+
name: 'RequestRetryError'
|
|
137
|
+
code: 'UND_ERR_REQ_RETRY'
|
|
138
|
+
statusCode: number
|
|
139
139
|
data: {
|
|
140
140
|
count: number;
|
|
141
|
-
}
|
|
142
|
-
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
headers: Record<string, string | string[]>
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
export class SecureProxyConnectionError extends UndiciError {
|
|
146
|
-
|
|
147
|
-
|
|
147
|
+
constructor (
|
|
148
|
+
cause?: Error,
|
|
149
|
+
message?: string,
|
|
150
|
+
options?: Record<any, any>
|
|
151
|
+
)
|
|
152
|
+
name: 'SecureProxyConnectionError'
|
|
153
|
+
code: 'UND_ERR_PRX_TLS'
|
|
148
154
|
}
|
|
149
155
|
}
|
package/types/eventsource.d.ts
CHANGED
package/types/fetch.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { Blob } from 'buffer'
|
|
|
6
6
|
import { URL, URLSearchParams } from 'url'
|
|
7
7
|
import { ReadableStream } from 'stream/web'
|
|
8
8
|
import { FormData } from './formdata'
|
|
9
|
-
|
|
9
|
+
import { HeaderRecord } from './header'
|
|
10
10
|
import Dispatcher from './dispatcher'
|
|
11
11
|
|
|
12
12
|
export type RequestInfo = string | URL | Request
|
|
@@ -36,17 +36,17 @@ export class BodyMixin {
|
|
|
36
36
|
/**
|
|
37
37
|
* @deprecated This method is not recommended for parsing multipart/form-data bodies in server environments.
|
|
38
38
|
* It is recommended to use a library such as [@fastify/busboy](https://www.npmjs.com/package/@fastify/busboy) as follows:
|
|
39
|
-
*
|
|
39
|
+
*
|
|
40
40
|
* @example
|
|
41
41
|
* ```js
|
|
42
42
|
* import { Busboy } from '@fastify/busboy'
|
|
43
43
|
* import { Readable } from 'node:stream'
|
|
44
|
-
*
|
|
44
|
+
*
|
|
45
45
|
* const response = await fetch('...')
|
|
46
46
|
* const busboy = new Busboy({ headers: { 'content-type': response.headers.get('content-type') } })
|
|
47
|
-
*
|
|
47
|
+
*
|
|
48
48
|
* // handle events emitted from `busboy`
|
|
49
|
-
*
|
|
49
|
+
*
|
|
50
50
|
* Readable.fromWeb(response.body).pipe(busboy)
|
|
51
51
|
* ```
|
|
52
52
|
*/
|
|
@@ -67,7 +67,7 @@ export interface SpecIterable<T> {
|
|
|
67
67
|
[Symbol.iterator](): SpecIterator<T>;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export type HeadersInit =
|
|
70
|
+
export type HeadersInit = [string, string][] | HeaderRecord | Headers
|
|
71
71
|
|
|
72
72
|
export declare class Headers implements SpecIterable<[string, string]> {
|
|
73
73
|
constructor (init?: HeadersInit)
|
|
@@ -144,7 +144,7 @@ export type ReferrerPolicy =
|
|
|
144
144
|
| 'same-origin'
|
|
145
145
|
| 'strict-origin'
|
|
146
146
|
| 'strict-origin-when-cross-origin'
|
|
147
|
-
| 'unsafe-url'
|
|
147
|
+
| 'unsafe-url'
|
|
148
148
|
|
|
149
149
|
export type RequestMode = 'cors' | 'navigate' | 'no-cors' | 'same-origin'
|
|
150
150
|
|
|
@@ -204,6 +204,6 @@ export declare class Response extends BodyMixin {
|
|
|
204
204
|
readonly clone: () => Response
|
|
205
205
|
|
|
206
206
|
static error (): Response
|
|
207
|
-
static json(data: any, init?: ResponseInit): Response
|
|
207
|
+
static json (data: any, init?: ResponseInit): Response
|
|
208
208
|
static redirect (url: string | URL, status: ResponseRedirectStatus): Response
|
|
209
209
|
}
|
package/types/formdata.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Based on https://github.com/octet-stream/form-data/blob/2d0f0dc371517444ce1f22cdde13f51995d0953a/lib/FormData.ts (MIT)
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
|
|
4
|
-
import { File } from '
|
|
4
|
+
import { File } from 'buffer'
|
|
5
5
|
import { SpecIterableIterator } from './fetch'
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -24,7 +24,7 @@ export declare class FormData {
|
|
|
24
24
|
or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string.
|
|
25
25
|
* @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.
|
|
26
26
|
*/
|
|
27
|
-
append(name: string, value: unknown, fileName?: string): void
|
|
27
|
+
append (name: string, value: unknown, fileName?: string): void
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Set a new value for an existing key inside FormData,
|
|
@@ -36,7 +36,7 @@ export declare class FormData {
|
|
|
36
36
|
* @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.
|
|
37
37
|
*
|
|
38
38
|
*/
|
|
39
|
-
set(name: string, value: unknown, fileName?: string): void
|
|
39
|
+
set (name: string, value: unknown, fileName?: string): void
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Returns the first value associated with a given key from within a `FormData` object.
|
|
@@ -46,7 +46,7 @@ export declare class FormData {
|
|
|
46
46
|
*
|
|
47
47
|
* @returns A `FormDataEntryValue` containing the value. If the key doesn't exist, the method returns null.
|
|
48
48
|
*/
|
|
49
|
-
get(name: string): FormDataEntryValue | null
|
|
49
|
+
get (name: string): FormDataEntryValue | null
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* Returns all the values associated with a given key from within a `FormData` object.
|
|
@@ -55,7 +55,7 @@ export declare class FormData {
|
|
|
55
55
|
*
|
|
56
56
|
* @returns An array of `FormDataEntryValue` whose key matches the value passed in the `name` parameter. If the key doesn't exist, the method returns an empty list.
|
|
57
57
|
*/
|
|
58
|
-
getAll(name: string): FormDataEntryValue[]
|
|
58
|
+
getAll (name: string): FormDataEntryValue[]
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* Returns a boolean stating whether a `FormData` object contains a certain key.
|
|
@@ -64,14 +64,14 @@ export declare class FormData {
|
|
|
64
64
|
*
|
|
65
65
|
* @return A boolean value.
|
|
66
66
|
*/
|
|
67
|
-
has(name: string): boolean
|
|
67
|
+
has (name: string): boolean
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* Deletes a key and its value(s) from a `FormData` object.
|
|
71
71
|
*
|
|
72
72
|
* @param name The name of the key you want to delete.
|
|
73
73
|
*/
|
|
74
|
-
delete(name: string): void
|
|
74
|
+
delete (name: string): void
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* Executes given callback function for each field of the FormData instance
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import Dispatcher from
|
|
1
|
+
import Dispatcher from './dispatcher'
|
|
2
|
+
|
|
3
|
+
declare function setGlobalDispatcher<DispatcherImplementation extends Dispatcher> (dispatcher: DispatcherImplementation): void
|
|
4
|
+
declare function getGlobalDispatcher (): Dispatcher
|
|
2
5
|
|
|
3
6
|
export {
|
|
4
7
|
getGlobalDispatcher,
|
|
5
8
|
setGlobalDispatcher
|
|
6
9
|
}
|
|
7
|
-
|
|
8
|
-
declare function setGlobalDispatcher<DispatcherImplementation extends Dispatcher>(dispatcher: DispatcherImplementation): void;
|
|
9
|
-
declare function getGlobalDispatcher(): Dispatcher;
|
package/types/global-origin.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
declare function setGlobalOrigin (origin: string | URL | undefined): void
|
|
2
|
+
declare function getGlobalOrigin (): URL | undefined
|
|
3
|
+
|
|
1
4
|
export {
|
|
2
|
-
|
|
3
|
-
|
|
5
|
+
setGlobalOrigin,
|
|
6
|
+
getGlobalOrigin
|
|
4
7
|
}
|
|
5
|
-
|
|
6
|
-
declare function setGlobalOrigin(origin: string | URL | undefined): void;
|
|
7
|
-
declare function getGlobalOrigin(): URL | undefined;
|
package/types/handlers.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import Dispatcher from
|
|
1
|
+
import Dispatcher from './dispatcher'
|
|
2
2
|
|
|
3
3
|
export declare class RedirectHandler implements Dispatcher.DispatchHandlers {
|
|
4
|
-
constructor(
|
|
4
|
+
constructor (
|
|
5
5
|
dispatch: Dispatcher,
|
|
6
6
|
maxRedirections: number,
|
|
7
7
|
opts: Dispatcher.DispatchOptions,
|
|
8
8
|
handler: Dispatcher.DispatchHandlers,
|
|
9
9
|
redirectionLimitReached: boolean
|
|
10
|
-
)
|
|
10
|
+
)
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export declare class DecoratorHandler implements Dispatcher.DispatchHandlers {
|
|
14
|
-
constructor(handler: Dispatcher.DispatchHandlers)
|
|
14
|
+
constructor (handler: Dispatcher.DispatchHandlers)
|
|
15
15
|
}
|
package/types/header.d.ts
CHANGED
|
@@ -1,4 +1,160 @@
|
|
|
1
|
+
import { Autocomplete } from './utility'
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* The header type declaration of `undici`.
|
|
3
5
|
*/
|
|
4
|
-
export type IncomingHttpHeaders = Record<string, string | string[] | undefined
|
|
6
|
+
export type IncomingHttpHeaders = Record<string, string | string[] | undefined>
|
|
7
|
+
|
|
8
|
+
type HeaderNames = Autocomplete<
|
|
9
|
+
| 'Accept'
|
|
10
|
+
| 'Accept-CH'
|
|
11
|
+
| 'Accept-Charset'
|
|
12
|
+
| 'Accept-Encoding'
|
|
13
|
+
| 'Accept-Language'
|
|
14
|
+
| 'Accept-Patch'
|
|
15
|
+
| 'Accept-Post'
|
|
16
|
+
| 'Accept-Ranges'
|
|
17
|
+
| 'Access-Control-Allow-Credentials'
|
|
18
|
+
| 'Access-Control-Allow-Headers'
|
|
19
|
+
| 'Access-Control-Allow-Methods'
|
|
20
|
+
| 'Access-Control-Allow-Origin'
|
|
21
|
+
| 'Access-Control-Expose-Headers'
|
|
22
|
+
| 'Access-Control-Max-Age'
|
|
23
|
+
| 'Access-Control-Request-Headers'
|
|
24
|
+
| 'Access-Control-Request-Method'
|
|
25
|
+
| 'Age'
|
|
26
|
+
| 'Allow'
|
|
27
|
+
| 'Alt-Svc'
|
|
28
|
+
| 'Alt-Used'
|
|
29
|
+
| 'Authorization'
|
|
30
|
+
| 'Cache-Control'
|
|
31
|
+
| 'Clear-Site-Data'
|
|
32
|
+
| 'Connection'
|
|
33
|
+
| 'Content-Disposition'
|
|
34
|
+
| 'Content-Encoding'
|
|
35
|
+
| 'Content-Language'
|
|
36
|
+
| 'Content-Length'
|
|
37
|
+
| 'Content-Location'
|
|
38
|
+
| 'Content-Range'
|
|
39
|
+
| 'Content-Security-Policy'
|
|
40
|
+
| 'Content-Security-Policy-Report-Only'
|
|
41
|
+
| 'Content-Type'
|
|
42
|
+
| 'Cookie'
|
|
43
|
+
| 'Cross-Origin-Embedder-Policy'
|
|
44
|
+
| 'Cross-Origin-Opener-Policy'
|
|
45
|
+
| 'Cross-Origin-Resource-Policy'
|
|
46
|
+
| 'Date'
|
|
47
|
+
| 'Device-Memory'
|
|
48
|
+
| 'ETag'
|
|
49
|
+
| 'Expect'
|
|
50
|
+
| 'Expect-CT'
|
|
51
|
+
| 'Expires'
|
|
52
|
+
| 'Forwarded'
|
|
53
|
+
| 'From'
|
|
54
|
+
| 'Host'
|
|
55
|
+
| 'If-Match'
|
|
56
|
+
| 'If-Modified-Since'
|
|
57
|
+
| 'If-None-Match'
|
|
58
|
+
| 'If-Range'
|
|
59
|
+
| 'If-Unmodified-Since'
|
|
60
|
+
| 'Keep-Alive'
|
|
61
|
+
| 'Last-Modified'
|
|
62
|
+
| 'Link'
|
|
63
|
+
| 'Location'
|
|
64
|
+
| 'Max-Forwards'
|
|
65
|
+
| 'Origin'
|
|
66
|
+
| 'Permissions-Policy'
|
|
67
|
+
| 'Priority'
|
|
68
|
+
| 'Proxy-Authenticate'
|
|
69
|
+
| 'Proxy-Authorization'
|
|
70
|
+
| 'Range'
|
|
71
|
+
| 'Referer'
|
|
72
|
+
| 'Referrer-Policy'
|
|
73
|
+
| 'Retry-After'
|
|
74
|
+
| 'Sec-Fetch-Dest'
|
|
75
|
+
| 'Sec-Fetch-Mode'
|
|
76
|
+
| 'Sec-Fetch-Site'
|
|
77
|
+
| 'Sec-Fetch-User'
|
|
78
|
+
| 'Sec-Purpose'
|
|
79
|
+
| 'Sec-WebSocket-Accept'
|
|
80
|
+
| 'Server'
|
|
81
|
+
| 'Server-Timing'
|
|
82
|
+
| 'Service-Worker-Navigation-Preload'
|
|
83
|
+
| 'Set-Cookie'
|
|
84
|
+
| 'SourceMap'
|
|
85
|
+
| 'Strict-Transport-Security'
|
|
86
|
+
| 'TE'
|
|
87
|
+
| 'Timing-Allow-Origin'
|
|
88
|
+
| 'Trailer'
|
|
89
|
+
| 'Transfer-Encoding'
|
|
90
|
+
| 'Upgrade'
|
|
91
|
+
| 'Upgrade-Insecure-Requests'
|
|
92
|
+
| 'User-Agent'
|
|
93
|
+
| 'Vary'
|
|
94
|
+
| 'Via'
|
|
95
|
+
| 'WWW-Authenticate'
|
|
96
|
+
| 'X-Content-Type-Options'
|
|
97
|
+
| 'X-Frame-Options'
|
|
98
|
+
>
|
|
99
|
+
|
|
100
|
+
type IANARegisteredMimeType = Autocomplete<
|
|
101
|
+
| 'audio/aac'
|
|
102
|
+
| 'video/x-msvideo'
|
|
103
|
+
| 'image/avif'
|
|
104
|
+
| 'video/av1'
|
|
105
|
+
| 'application/octet-stream'
|
|
106
|
+
| 'image/bmp'
|
|
107
|
+
| 'text/css'
|
|
108
|
+
| 'text/csv'
|
|
109
|
+
| 'application/vnd.ms-fontobject'
|
|
110
|
+
| 'application/epub+zip'
|
|
111
|
+
| 'image/gif'
|
|
112
|
+
| 'application/gzip'
|
|
113
|
+
| 'text/html'
|
|
114
|
+
| 'image/x-icon'
|
|
115
|
+
| 'text/calendar'
|
|
116
|
+
| 'image/jpeg'
|
|
117
|
+
| 'text/javascript'
|
|
118
|
+
| 'application/json'
|
|
119
|
+
| 'application/ld+json'
|
|
120
|
+
| 'audio/x-midi'
|
|
121
|
+
| 'audio/mpeg'
|
|
122
|
+
| 'video/mp4'
|
|
123
|
+
| 'video/mpeg'
|
|
124
|
+
| 'audio/ogg'
|
|
125
|
+
| 'video/ogg'
|
|
126
|
+
| 'application/ogg'
|
|
127
|
+
| 'audio/opus'
|
|
128
|
+
| 'font/otf'
|
|
129
|
+
| 'application/pdf'
|
|
130
|
+
| 'image/png'
|
|
131
|
+
| 'application/rtf'
|
|
132
|
+
| 'image/svg+xml'
|
|
133
|
+
| 'image/tiff'
|
|
134
|
+
| 'video/mp2t'
|
|
135
|
+
| 'font/ttf'
|
|
136
|
+
| 'text/plain'
|
|
137
|
+
| 'application/wasm'
|
|
138
|
+
| 'video/webm'
|
|
139
|
+
| 'audio/webm'
|
|
140
|
+
| 'image/webp'
|
|
141
|
+
| 'font/woff'
|
|
142
|
+
| 'font/woff2'
|
|
143
|
+
| 'application/xhtml+xml'
|
|
144
|
+
| 'application/xml'
|
|
145
|
+
| 'application/zip'
|
|
146
|
+
| 'video/3gpp'
|
|
147
|
+
| 'video/3gpp2'
|
|
148
|
+
| 'model/gltf+json'
|
|
149
|
+
| 'model/gltf-binary'
|
|
150
|
+
>
|
|
151
|
+
|
|
152
|
+
type KnownHeaderValues = {
|
|
153
|
+
'content-type': IANARegisteredMimeType
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export type HeaderRecord = {
|
|
157
|
+
[K in HeaderNames | Lowercase<HeaderNames>]?: Lowercase<K> extends keyof KnownHeaderValues
|
|
158
|
+
? KnownHeaderValues[Lowercase<K>]
|
|
159
|
+
: string
|
|
160
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import Dispatcher from'./dispatcher'
|
|
1
|
+
import Dispatcher from './dispatcher'
|
|
2
2
|
import { setGlobalDispatcher, getGlobalDispatcher } from './global-dispatcher'
|
|
3
3
|
import { setGlobalOrigin, getGlobalOrigin } from './global-origin'
|
|
4
|
-
import Pool from'./pool'
|
|
4
|
+
import Pool from './pool'
|
|
5
5
|
import { RedirectHandler, DecoratorHandler } from './handlers'
|
|
6
6
|
|
|
7
7
|
import BalancedPool from './balanced-pool'
|
|
8
|
-
import Client from'./client'
|
|
9
|
-
import buildConnector from'./connector'
|
|
10
|
-
import errors from'./errors'
|
|
11
|
-
import Agent from'./agent'
|
|
12
|
-
import MockClient from'./mock-client'
|
|
13
|
-
import MockPool from'./mock-pool'
|
|
14
|
-
import MockAgent from'./mock-agent'
|
|
15
|
-
import mockErrors from'./mock-errors'
|
|
16
|
-
import ProxyAgent from'./proxy-agent'
|
|
8
|
+
import Client from './client'
|
|
9
|
+
import buildConnector from './connector'
|
|
10
|
+
import errors from './errors'
|
|
11
|
+
import Agent from './agent'
|
|
12
|
+
import MockClient from './mock-client'
|
|
13
|
+
import MockPool from './mock-pool'
|
|
14
|
+
import MockAgent from './mock-agent'
|
|
15
|
+
import mockErrors from './mock-errors'
|
|
16
|
+
import ProxyAgent from './proxy-agent'
|
|
17
17
|
import EnvHttpProxyAgent from './env-http-proxy-agent'
|
|
18
|
-
import RetryHandler from'./retry-handler'
|
|
19
|
-
import RetryAgent from'./retry-agent'
|
|
18
|
+
import RetryHandler from './retry-handler'
|
|
19
|
+
import RetryAgent from './retry-agent'
|
|
20
20
|
import { request, pipeline, stream, connect, upgrade } from './api'
|
|
21
21
|
import interceptors from './interceptors'
|
|
22
22
|
|
|
@@ -24,8 +24,6 @@ export * from './util'
|
|
|
24
24
|
export * from './cookies'
|
|
25
25
|
export * from './eventsource'
|
|
26
26
|
export * from './fetch'
|
|
27
|
-
export * from './file'
|
|
28
|
-
export * from './filereader'
|
|
29
27
|
export * from './formdata'
|
|
30
28
|
export * from './diagnostics-channel'
|
|
31
29
|
export * from './websocket'
|
|
@@ -37,35 +35,33 @@ export { Dispatcher, BalancedPool, Pool, Client, buildConnector, errors, Agent,
|
|
|
37
35
|
export default Undici
|
|
38
36
|
|
|
39
37
|
declare namespace Undici {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
var caches: typeof import('./cache').caches;
|
|
70
|
-
var interceptors: typeof import('./interceptors').default;
|
|
38
|
+
const Dispatcher: typeof import('./dispatcher').default
|
|
39
|
+
const Pool: typeof import('./pool').default
|
|
40
|
+
const RedirectHandler: typeof import ('./handlers').RedirectHandler
|
|
41
|
+
const DecoratorHandler: typeof import ('./handlers').DecoratorHandler
|
|
42
|
+
const RetryHandler: typeof import ('./retry-handler').default
|
|
43
|
+
const createRedirectInterceptor: typeof import ('./interceptors').default.createRedirectInterceptor
|
|
44
|
+
const BalancedPool: typeof import('./balanced-pool').default
|
|
45
|
+
const Client: typeof import('./client').default
|
|
46
|
+
const buildConnector: typeof import('./connector').default
|
|
47
|
+
const errors: typeof import('./errors').default
|
|
48
|
+
const Agent: typeof import('./agent').default
|
|
49
|
+
const setGlobalDispatcher: typeof import('./global-dispatcher').setGlobalDispatcher
|
|
50
|
+
const getGlobalDispatcher: typeof import('./global-dispatcher').getGlobalDispatcher
|
|
51
|
+
const request: typeof import('./api').request
|
|
52
|
+
const stream: typeof import('./api').stream
|
|
53
|
+
const pipeline: typeof import('./api').pipeline
|
|
54
|
+
const connect: typeof import('./api').connect
|
|
55
|
+
const upgrade: typeof import('./api').upgrade
|
|
56
|
+
const MockClient: typeof import('./mock-client').default
|
|
57
|
+
const MockPool: typeof import('./mock-pool').default
|
|
58
|
+
const MockAgent: typeof import('./mock-agent').default
|
|
59
|
+
const mockErrors: typeof import('./mock-errors').default
|
|
60
|
+
const fetch: typeof import('./fetch').fetch
|
|
61
|
+
const Headers: typeof import('./fetch').Headers
|
|
62
|
+
const Response: typeof import('./fetch').Response
|
|
63
|
+
const Request: typeof import('./fetch').Request
|
|
64
|
+
const FormData: typeof import('./formdata').FormData
|
|
65
|
+
const caches: typeof import('./cache').caches
|
|
66
|
+
const interceptors: typeof import('./interceptors').default
|
|
71
67
|
}
|
package/types/interceptors.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import Dispatcher from
|
|
2
|
-
import RetryHandler from
|
|
1
|
+
import Dispatcher from './dispatcher'
|
|
2
|
+
import RetryHandler from './retry-handler'
|
|
3
3
|
|
|
4
|
-
export default Interceptors
|
|
4
|
+
export default Interceptors
|
|
5
5
|
|
|
6
6
|
declare namespace Interceptors {
|
|
7
7
|
export type DumpInterceptorOpts = { maxSize?: number }
|
|
8
8
|
export type RetryInterceptorOpts = RetryHandler.RetryOptions
|
|
9
9
|
export type RedirectInterceptorOpts = { maxRedirections?: number }
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export function
|
|
13
|
-
export function
|
|
14
|
-
export function
|
|
10
|
+
export type ResponseErrorInterceptorOpts = { throwOnError: boolean }
|
|
11
|
+
|
|
12
|
+
export function createRedirectInterceptor (opts: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
|
|
13
|
+
export function dump (opts?: DumpInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
|
|
14
|
+
export function retry (opts?: RetryInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
|
|
15
|
+
export function redirect (opts?: RedirectInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
|
|
16
|
+
export function responseError (opts?: ResponseErrorInterceptorOpts): Dispatcher.DispatcherComposeInterceptor
|
|
15
17
|
}
|