undici 5.25.0 → 5.25.2
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 +1 -0
- package/index.d.ts +2 -56
- package/lib/core/util.js +1 -1
- package/lib/websocket/connection.js +10 -3
- package/lib/websocket/frame.js +9 -2
- package/package.json +32 -2
- package/types/README.md +6 -0
- package/types/index.d.ts +57 -0
- package/types/package.json +55 -0
package/README.md
CHANGED
|
@@ -436,6 +436,7 @@ and `undici.Agent`) which will enable the family autoselection algorithm when es
|
|
|
436
436
|
* [__Ethan Arrowood__](https://github.com/ethan-arrowood), <https://www.npmjs.com/~ethan_arrowood>
|
|
437
437
|
* [__Matteo Collina__](https://github.com/mcollina), <https://www.npmjs.com/~matteo.collina>
|
|
438
438
|
* [__Robert Nagy__](https://github.com/ronag), <https://www.npmjs.com/~ronag>
|
|
439
|
+
* [__Matthew Aitken__](https://github.com/KhafraDev), <https://www.npmjs.com/~khaf>
|
|
439
440
|
|
|
440
441
|
## License
|
|
441
442
|
|
package/index.d.ts
CHANGED
|
@@ -1,57 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { setGlobalOrigin, getGlobalOrigin } from './types/global-origin'
|
|
4
|
-
import Pool from'./types/pool'
|
|
5
|
-
import { RedirectHandler, DecoratorHandler } from './types/handlers'
|
|
6
|
-
|
|
7
|
-
import BalancedPool from './types/balanced-pool'
|
|
8
|
-
import Client from'./types/client'
|
|
9
|
-
import buildConnector from'./types/connector'
|
|
10
|
-
import errors from'./types/errors'
|
|
11
|
-
import Agent from'./types/agent'
|
|
12
|
-
import MockClient from'./types/mock-client'
|
|
13
|
-
import MockPool from'./types/mock-pool'
|
|
14
|
-
import MockAgent from'./types/mock-agent'
|
|
15
|
-
import mockErrors from'./types/mock-errors'
|
|
16
|
-
import ProxyAgent from'./types/proxy-agent'
|
|
17
|
-
import { request, pipeline, stream, connect, upgrade } from './types/api'
|
|
18
|
-
|
|
19
|
-
export * from './types/cookies'
|
|
20
|
-
export * from './types/fetch'
|
|
21
|
-
export * from './types/file'
|
|
22
|
-
export * from './types/filereader'
|
|
23
|
-
export * from './types/formdata'
|
|
24
|
-
export * from './types/diagnostics-channel'
|
|
25
|
-
export * from './types/websocket'
|
|
26
|
-
export * from './types/content-type'
|
|
27
|
-
export * from './types/cache'
|
|
28
|
-
export { Interceptable } from './types/mock-interceptor'
|
|
29
|
-
|
|
30
|
-
export { Dispatcher, BalancedPool, Pool, Client, buildConnector, errors, Agent, request, stream, pipeline, connect, upgrade, setGlobalDispatcher, getGlobalDispatcher, setGlobalOrigin, getGlobalOrigin, MockClient, MockPool, MockAgent, mockErrors, ProxyAgent, RedirectHandler, DecoratorHandler }
|
|
1
|
+
export * from './types/index'
|
|
2
|
+
import Undici from './types/index'
|
|
31
3
|
export default Undici
|
|
32
|
-
|
|
33
|
-
declare namespace Undici {
|
|
34
|
-
var Dispatcher: typeof import('./types/dispatcher').default
|
|
35
|
-
var Pool: typeof import('./types/pool').default;
|
|
36
|
-
var RedirectHandler: typeof import ('./types/handlers').RedirectHandler
|
|
37
|
-
var DecoratorHandler: typeof import ('./types/handlers').DecoratorHandler
|
|
38
|
-
var createRedirectInterceptor: typeof import ('./types/interceptors').createRedirectInterceptor
|
|
39
|
-
var BalancedPool: typeof import('./types/balanced-pool').default;
|
|
40
|
-
var Client: typeof import('./types/client').default;
|
|
41
|
-
var buildConnector: typeof import('./types/connector').default;
|
|
42
|
-
var errors: typeof import('./types/errors').default;
|
|
43
|
-
var Agent: typeof import('./types/agent').default;
|
|
44
|
-
var setGlobalDispatcher: typeof import('./types/global-dispatcher').setGlobalDispatcher;
|
|
45
|
-
var getGlobalDispatcher: typeof import('./types/global-dispatcher').getGlobalDispatcher;
|
|
46
|
-
var request: typeof import('./types/api').request;
|
|
47
|
-
var stream: typeof import('./types/api').stream;
|
|
48
|
-
var pipeline: typeof import('./types/api').pipeline;
|
|
49
|
-
var connect: typeof import('./types/api').connect;
|
|
50
|
-
var upgrade: typeof import('./types/api').upgrade;
|
|
51
|
-
var MockClient: typeof import('./types/mock-client').default;
|
|
52
|
-
var MockPool: typeof import('./types/mock-pool').default;
|
|
53
|
-
var MockAgent: typeof import('./types/mock-agent').default;
|
|
54
|
-
var mockErrors: typeof import('./types/mock-errors').default;
|
|
55
|
-
var fetch: typeof import('./types/fetch').fetch;
|
|
56
|
-
var caches: typeof import('./types/cache').caches;
|
|
57
|
-
}
|
package/lib/core/util.js
CHANGED
|
@@ -168,7 +168,7 @@ function bodyLength (body) {
|
|
|
168
168
|
return 0
|
|
169
169
|
} else if (isStream(body)) {
|
|
170
170
|
const state = body._readableState
|
|
171
|
-
return state && state.ended === true && Number.isFinite(state.length)
|
|
171
|
+
return state && state.objectMode === false && state.ended === true && Number.isFinite(state.length)
|
|
172
172
|
? state.length
|
|
173
173
|
: null
|
|
174
174
|
} else if (isBlobLike(body)) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { randomBytes, createHash } = require('crypto')
|
|
4
3
|
const diagnosticsChannel = require('diagnostics_channel')
|
|
5
4
|
const { uid, states } = require('./constants')
|
|
6
5
|
const {
|
|
@@ -22,6 +21,14 @@ channels.open = diagnosticsChannel.channel('undici:websocket:open')
|
|
|
22
21
|
channels.close = diagnosticsChannel.channel('undici:websocket:close')
|
|
23
22
|
channels.socketError = diagnosticsChannel.channel('undici:websocket:socket_error')
|
|
24
23
|
|
|
24
|
+
/** @type {import('crypto')} */
|
|
25
|
+
let crypto
|
|
26
|
+
try {
|
|
27
|
+
crypto = require('crypto')
|
|
28
|
+
} catch {
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
25
32
|
/**
|
|
26
33
|
* @see https://websockets.spec.whatwg.org/#concept-websocket-establish
|
|
27
34
|
* @param {URL} url
|
|
@@ -66,7 +73,7 @@ function establishWebSocketConnection (url, protocols, ws, onEstablish, options)
|
|
|
66
73
|
// 5. Let keyValue be a nonce consisting of a randomly selected
|
|
67
74
|
// 16-byte value that has been forgiving-base64-encoded and
|
|
68
75
|
// isomorphic encoded.
|
|
69
|
-
const keyValue = randomBytes(16).toString('base64')
|
|
76
|
+
const keyValue = crypto.randomBytes(16).toString('base64')
|
|
70
77
|
|
|
71
78
|
// 6. Append (`Sec-WebSocket-Key`, keyValue) to request’s
|
|
72
79
|
// header list.
|
|
@@ -148,7 +155,7 @@ function establishWebSocketConnection (url, protocols, ws, onEstablish, options)
|
|
|
148
155
|
// trailing whitespace, the client MUST _Fail the WebSocket
|
|
149
156
|
// Connection_.
|
|
150
157
|
const secWSAccept = response.headersList.get('Sec-WebSocket-Accept')
|
|
151
|
-
const digest = createHash('sha1').update(keyValue + uid).digest('base64')
|
|
158
|
+
const digest = crypto.createHash('sha1').update(keyValue + uid).digest('base64')
|
|
152
159
|
if (secWSAccept !== digest) {
|
|
153
160
|
failWebsocketConnection(ws, 'Incorrect hash received in Sec-WebSocket-Accept header.')
|
|
154
161
|
return
|
package/lib/websocket/frame.js
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { randomBytes } = require('crypto')
|
|
4
3
|
const { maxUnsigned16Bit } = require('./constants')
|
|
5
4
|
|
|
5
|
+
/** @type {import('crypto')} */
|
|
6
|
+
let crypto
|
|
7
|
+
try {
|
|
8
|
+
crypto = require('crypto')
|
|
9
|
+
} catch {
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
6
13
|
class WebsocketFrameSend {
|
|
7
14
|
/**
|
|
8
15
|
* @param {Buffer|undefined} data
|
|
9
16
|
*/
|
|
10
17
|
constructor (data) {
|
|
11
18
|
this.frameData = data
|
|
12
|
-
this.maskKey = randomBytes(4)
|
|
19
|
+
this.maskKey = crypto.randomBytes(4)
|
|
13
20
|
}
|
|
14
21
|
|
|
15
22
|
createFrame (opcode) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "undici",
|
|
3
|
-
"version": "5.25.
|
|
3
|
+
"version": "5.25.2",
|
|
4
4
|
"description": "An HTTP/1.1 client, written from scratch for Node.js",
|
|
5
5
|
"homepage": "https://undici.nodejs.org",
|
|
6
6
|
"bugs": {
|
|
@@ -11,12 +11,41 @@
|
|
|
11
11
|
"url": "git+https://github.com/nodejs/undici.git"
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
|
-
"author": "Matteo Collina <hello@matteocollina.com>",
|
|
15
14
|
"contributors": [
|
|
15
|
+
{
|
|
16
|
+
"name": "Daniele Belardi",
|
|
17
|
+
"url": "https://github.com/dnlup",
|
|
18
|
+
"author": true
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "Ethan Arrowood",
|
|
22
|
+
"url": "https://github.com/ethan-arrowood",
|
|
23
|
+
"author": true
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "Matteo Collina",
|
|
27
|
+
"url": "https://github.com/mcollina",
|
|
28
|
+
"author": true
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "Matthew Aitken",
|
|
32
|
+
"url": "https://github.com/KhafraDev",
|
|
33
|
+
"author": true
|
|
34
|
+
},
|
|
16
35
|
{
|
|
17
36
|
"name": "Robert Nagy",
|
|
18
37
|
"url": "https://github.com/ronag",
|
|
19
38
|
"author": true
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"name": "Szymon Marczak",
|
|
42
|
+
"url": "https://github.com/szmarczak",
|
|
43
|
+
"author": true
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"name": "Tomas Della Vedova",
|
|
47
|
+
"url": "https://github.com/delvedor",
|
|
48
|
+
"author": true
|
|
20
49
|
}
|
|
21
50
|
],
|
|
22
51
|
"keywords": [
|
|
@@ -64,6 +93,7 @@
|
|
|
64
93
|
"bench:run": "CONNECTIONS=1 node benchmarks/benchmark.js; CONNECTIONS=50 node benchmarks/benchmark.js",
|
|
65
94
|
"serve:website": "docsify serve .",
|
|
66
95
|
"prepare": "husky install",
|
|
96
|
+
"postpublish": "node scripts/update-undici-types-version.js && cd types && npm publish",
|
|
67
97
|
"fuzz": "jsfuzz test/fuzzing/fuzz.js corpus"
|
|
68
98
|
},
|
|
69
99
|
"devDependencies": {
|
package/types/README.md
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# undici-types
|
|
2
|
+
|
|
3
|
+
This package is a dual-publish of the [undici](https://www.npmjs.com/package/undici) library types. The `undici` package **still contains types**. This package is for users who _only_ need undici types (such as for `@types/node`). It is published alongside every release of `undici`, so you can always use the same version.
|
|
4
|
+
|
|
5
|
+
- [GitHub nodejs/undici](https://github.com/nodejs/undici)
|
|
6
|
+
- [Undici Documentation](https://undici.nodejs.org/#/)
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import Dispatcher from'./dispatcher'
|
|
2
|
+
import { setGlobalDispatcher, getGlobalDispatcher } from './global-dispatcher'
|
|
3
|
+
import { setGlobalOrigin, getGlobalOrigin } from './global-origin'
|
|
4
|
+
import Pool from'./pool'
|
|
5
|
+
import { RedirectHandler, DecoratorHandler } from './handlers'
|
|
6
|
+
|
|
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'
|
|
17
|
+
import { request, pipeline, stream, connect, upgrade } from './api'
|
|
18
|
+
|
|
19
|
+
export * from './cookies'
|
|
20
|
+
export * from './fetch'
|
|
21
|
+
export * from './file'
|
|
22
|
+
export * from './filereader'
|
|
23
|
+
export * from './formdata'
|
|
24
|
+
export * from './diagnostics-channel'
|
|
25
|
+
export * from './websocket'
|
|
26
|
+
export * from './content-type'
|
|
27
|
+
export * from './cache'
|
|
28
|
+
export { Interceptable } from './mock-interceptor'
|
|
29
|
+
|
|
30
|
+
export { Dispatcher, BalancedPool, Pool, Client, buildConnector, errors, Agent, request, stream, pipeline, connect, upgrade, setGlobalDispatcher, getGlobalDispatcher, setGlobalOrigin, getGlobalOrigin, MockClient, MockPool, MockAgent, mockErrors, ProxyAgent, RedirectHandler, DecoratorHandler }
|
|
31
|
+
export default Undici
|
|
32
|
+
|
|
33
|
+
declare namespace Undici {
|
|
34
|
+
var Dispatcher: typeof import('./dispatcher').default
|
|
35
|
+
var Pool: typeof import('./pool').default;
|
|
36
|
+
var RedirectHandler: typeof import ('./handlers').RedirectHandler
|
|
37
|
+
var DecoratorHandler: typeof import ('./handlers').DecoratorHandler
|
|
38
|
+
var createRedirectInterceptor: typeof import ('./interceptors').createRedirectInterceptor
|
|
39
|
+
var BalancedPool: typeof import('./balanced-pool').default;
|
|
40
|
+
var Client: typeof import('./client').default;
|
|
41
|
+
var buildConnector: typeof import('./connector').default;
|
|
42
|
+
var errors: typeof import('./errors').default;
|
|
43
|
+
var Agent: typeof import('./agent').default;
|
|
44
|
+
var setGlobalDispatcher: typeof import('./global-dispatcher').setGlobalDispatcher;
|
|
45
|
+
var getGlobalDispatcher: typeof import('./global-dispatcher').getGlobalDispatcher;
|
|
46
|
+
var request: typeof import('./api').request;
|
|
47
|
+
var stream: typeof import('./api').stream;
|
|
48
|
+
var pipeline: typeof import('./api').pipeline;
|
|
49
|
+
var connect: typeof import('./api').connect;
|
|
50
|
+
var upgrade: typeof import('./api').upgrade;
|
|
51
|
+
var MockClient: typeof import('./mock-client').default;
|
|
52
|
+
var MockPool: typeof import('./mock-pool').default;
|
|
53
|
+
var MockAgent: typeof import('./mock-agent').default;
|
|
54
|
+
var mockErrors: typeof import('./mock-errors').default;
|
|
55
|
+
var fetch: typeof import('./fetch').fetch;
|
|
56
|
+
var caches: typeof import('./cache').caches;
|
|
57
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "undici-types",
|
|
3
|
+
"version": "5.25.1",
|
|
4
|
+
"description": "A stand-alone types package for Undici",
|
|
5
|
+
"homepage": "https://undici.nodejs.org",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/nodejs/undici/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/nodejs/undici.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"types": "index.d.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
"*.d.ts"
|
|
17
|
+
],
|
|
18
|
+
"contributors": [
|
|
19
|
+
{
|
|
20
|
+
"name": "Daniele Belardi",
|
|
21
|
+
"url": "https://github.com/dnlup",
|
|
22
|
+
"author": true
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "Ethan Arrowood",
|
|
26
|
+
"url": "https://github.com/ethan-arrowood",
|
|
27
|
+
"author": true
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "Matteo Collina",
|
|
31
|
+
"url": "https://github.com/mcollina",
|
|
32
|
+
"author": true
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "Matthew Aitken",
|
|
36
|
+
"url": "https://github.com/KhafraDev",
|
|
37
|
+
"author": true
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "Robert Nagy",
|
|
41
|
+
"url": "https://github.com/ronag",
|
|
42
|
+
"author": true
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "Szymon Marczak",
|
|
46
|
+
"url": "https://github.com/szmarczak",
|
|
47
|
+
"author": true
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "Tomas Della Vedova",
|
|
51
|
+
"url": "https://github.com/delvedor",
|
|
52
|
+
"author": true
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|