Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
deps: update undici to 5.25.2
  • Loading branch information
nodejs-github-bot committed Sep 22, 2023
commit 1859ab0897d11814812f4856888f3d5ed1608ad1
1 change: 1 addition & 0 deletions deps/undici/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ and `undici.Agent`) which will enable the family autoselection algorithm when es
* [__Ethan Arrowood__](https://github.com/ethan-arrowood), <https://www.npmjs.com/~ethan_arrowood>
* [__Matteo Collina__](https://github.com/mcollina), <https://www.npmjs.com/~matteo.collina>
* [__Robert Nagy__](https://github.com/ronag), <https://www.npmjs.com/~ronag>
* [__Matthew Aitken__](https://github.com/KhafraDev), <https://www.npmjs.com/~khaf>

## License

Expand Down
58 changes: 2 additions & 56 deletions deps/undici/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,57 +1,3 @@
import Dispatcher from'./types/dispatcher'
import { setGlobalDispatcher, getGlobalDispatcher } from './types/global-dispatcher'
import { setGlobalOrigin, getGlobalOrigin } from './types/global-origin'
import Pool from'./types/pool'
import { RedirectHandler, DecoratorHandler } from './types/handlers'

import BalancedPool from './types/balanced-pool'
import Client from'./types/client'
import buildConnector from'./types/connector'
import errors from'./types/errors'
import Agent from'./types/agent'
import MockClient from'./types/mock-client'
import MockPool from'./types/mock-pool'
import MockAgent from'./types/mock-agent'
import mockErrors from'./types/mock-errors'
import ProxyAgent from'./types/proxy-agent'
import { request, pipeline, stream, connect, upgrade } from './types/api'

export * from './types/cookies'
export * from './types/fetch'
export * from './types/file'
export * from './types/filereader'
export * from './types/formdata'
export * from './types/diagnostics-channel'
export * from './types/websocket'
export * from './types/content-type'
export * from './types/cache'
export { Interceptable } from './types/mock-interceptor'

export { Dispatcher, BalancedPool, Pool, Client, buildConnector, errors, Agent, request, stream, pipeline, connect, upgrade, setGlobalDispatcher, getGlobalDispatcher, setGlobalOrigin, getGlobalOrigin, MockClient, MockPool, MockAgent, mockErrors, ProxyAgent, RedirectHandler, DecoratorHandler }
export * from './types/index'
import Undici from './types/index'
export default Undici

declare namespace Undici {
var Dispatcher: typeof import('./types/dispatcher').default
var Pool: typeof import('./types/pool').default;
var RedirectHandler: typeof import ('./types/handlers').RedirectHandler
var DecoratorHandler: typeof import ('./types/handlers').DecoratorHandler
var createRedirectInterceptor: typeof import ('./types/interceptors').createRedirectInterceptor
var BalancedPool: typeof import('./types/balanced-pool').default;
var Client: typeof import('./types/client').default;
var buildConnector: typeof import('./types/connector').default;
var errors: typeof import('./types/errors').default;
var Agent: typeof import('./types/agent').default;
var setGlobalDispatcher: typeof import('./types/global-dispatcher').setGlobalDispatcher;
var getGlobalDispatcher: typeof import('./types/global-dispatcher').getGlobalDispatcher;
var request: typeof import('./types/api').request;
var stream: typeof import('./types/api').stream;
var pipeline: typeof import('./types/api').pipeline;
var connect: typeof import('./types/api').connect;
var upgrade: typeof import('./types/api').upgrade;
var MockClient: typeof import('./types/mock-client').default;
var MockPool: typeof import('./types/mock-pool').default;
var MockAgent: typeof import('./types/mock-agent').default;
var mockErrors: typeof import('./types/mock-errors').default;
var fetch: typeof import('./types/fetch').fetch;
var caches: typeof import('./types/cache').caches;
}
2 changes: 1 addition & 1 deletion deps/undici/src/lib/core/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ function bodyLength (body) {
return 0
} else if (isStream(body)) {
const state = body._readableState
return state && state.ended === true && Number.isFinite(state.length)
return state && state.objectMode === false && state.ended === true && Number.isFinite(state.length)
? state.length
: null
} else if (isBlobLike(body)) {
Expand Down
13 changes: 10 additions & 3 deletions deps/undici/src/lib/websocket/connection.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict'

const { randomBytes, createHash } = require('crypto')
const diagnosticsChannel = require('diagnostics_channel')
const { uid, states } = require('./constants')
const {
Expand All @@ -22,6 +21,14 @@ channels.open = diagnosticsChannel.channel('undici:websocket:open')
channels.close = diagnosticsChannel.channel('undici:websocket:close')
channels.socketError = diagnosticsChannel.channel('undici:websocket:socket_error')

/** @type {import('crypto')} */
let crypto
try {
crypto = require('crypto')
} catch {

}

/**
* @see https://websockets.spec.whatwg.org/#concept-websocket-establish
* @param {URL} url
Expand Down Expand Up @@ -66,7 +73,7 @@ function establishWebSocketConnection (url, protocols, ws, onEstablish, options)
// 5. Let keyValue be a nonce consisting of a randomly selected
// 16-byte value that has been forgiving-base64-encoded and
// isomorphic encoded.
const keyValue = randomBytes(16).toString('base64')
const keyValue = crypto.randomBytes(16).toString('base64')

// 6. Append (`Sec-WebSocket-Key`, keyValue) to request’s
// header list.
Expand Down Expand Up @@ -148,7 +155,7 @@ function establishWebSocketConnection (url, protocols, ws, onEstablish, options)
// trailing whitespace, the client MUST _Fail the WebSocket
// Connection_.
const secWSAccept = response.headersList.get('Sec-WebSocket-Accept')
const digest = createHash('sha1').update(keyValue + uid).digest('base64')
const digest = crypto.createHash('sha1').update(keyValue + uid).digest('base64')
if (secWSAccept !== digest) {
failWebsocketConnection(ws, 'Incorrect hash received in Sec-WebSocket-Accept header.')
return
Expand Down
11 changes: 9 additions & 2 deletions deps/undici/src/lib/websocket/frame.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
'use strict'

const { randomBytes } = require('crypto')
const { maxUnsigned16Bit } = require('./constants')

/** @type {import('crypto')} */
let crypto
try {
crypto = require('crypto')
} catch {

}

class WebsocketFrameSend {
/**
* @param {Buffer|undefined} data
*/
constructor (data) {
this.frameData = data
this.maskKey = randomBytes(4)
this.maskKey = crypto.randomBytes(4)
}

createFrame (opcode) {
Expand Down
34 changes: 32 additions & 2 deletions deps/undici/src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "undici",
"version": "5.25.0",
"version": "5.25.2",
"description": "An HTTP/1.1 client, written from scratch for Node.js",
"homepage": "https://undici.nodejs.org",
"bugs": {
Expand All @@ -11,12 +11,41 @@
"url": "git+https://github.com/nodejs/undici.git"
},
"license": "MIT",
"author": "Matteo Collina <hello@matteocollina.com>",
"contributors": [
{
"name": "Daniele Belardi",
"url": "https://github.com/dnlup",
"author": true
},
{
"name": "Ethan Arrowood",
"url": "https://github.com/ethan-arrowood",
"author": true
},
{
"name": "Matteo Collina",
"url": "https://github.com/mcollina",
"author": true
},
{
"name": "Matthew Aitken",
"url": "https://github.com/KhafraDev",
"author": true
},
{
"name": "Robert Nagy",
"url": "https://github.com/ronag",
"author": true
},
{
"name": "Szymon Marczak",
"url": "https://github.com/szmarczak",
"author": true
},
{
"name": "Tomas Della Vedova",
"url": "https://github.com/delvedor",
"author": true
}
],
"keywords": [
Expand Down Expand Up @@ -64,6 +93,7 @@
"bench:run": "CONNECTIONS=1 node benchmarks/benchmark.js; CONNECTIONS=50 node benchmarks/benchmark.js",
"serve:website": "docsify serve .",
"prepare": "husky install",
"postpublish": "node scripts/update-undici-types-version.js && cd types && npm publish",
"fuzz": "jsfuzz test/fuzzing/fuzz.js corpus"
},
"devDependencies": {
Expand Down
6 changes: 6 additions & 0 deletions deps/undici/src/types/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# undici-types

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.

- [GitHub nodejs/undici](https://github.com/nodejs/undici)
- [Undici Documentation](https://undici.nodejs.org/#/)
57 changes: 57 additions & 0 deletions deps/undici/src/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import Dispatcher from'./dispatcher'
import { setGlobalDispatcher, getGlobalDispatcher } from './global-dispatcher'
import { setGlobalOrigin, getGlobalOrigin } from './global-origin'
import Pool from'./pool'
import { RedirectHandler, DecoratorHandler } from './handlers'

import BalancedPool from './balanced-pool'
import Client from'./client'
import buildConnector from'./connector'
import errors from'./errors'
import Agent from'./agent'
import MockClient from'./mock-client'
import MockPool from'./mock-pool'
import MockAgent from'./mock-agent'
import mockErrors from'./mock-errors'
import ProxyAgent from'./proxy-agent'
import { request, pipeline, stream, connect, upgrade } from './api'

export * from './cookies'
export * from './fetch'
export * from './file'
export * from './filereader'
export * from './formdata'
export * from './diagnostics-channel'
export * from './websocket'
export * from './content-type'
export * from './cache'
export { Interceptable } from './mock-interceptor'

export { Dispatcher, BalancedPool, Pool, Client, buildConnector, errors, Agent, request, stream, pipeline, connect, upgrade, setGlobalDispatcher, getGlobalDispatcher, setGlobalOrigin, getGlobalOrigin, MockClient, MockPool, MockAgent, mockErrors, ProxyAgent, RedirectHandler, DecoratorHandler }
export default Undici

declare namespace Undici {
var Dispatcher: typeof import('./dispatcher').default
var Pool: typeof import('./pool').default;
var RedirectHandler: typeof import ('./handlers').RedirectHandler
var DecoratorHandler: typeof import ('./handlers').DecoratorHandler
var createRedirectInterceptor: typeof import ('./interceptors').createRedirectInterceptor
var BalancedPool: typeof import('./balanced-pool').default;
var Client: typeof import('./client').default;
var buildConnector: typeof import('./connector').default;
var errors: typeof import('./errors').default;
var Agent: typeof import('./agent').default;
var setGlobalDispatcher: typeof import('./global-dispatcher').setGlobalDispatcher;
var getGlobalDispatcher: typeof import('./global-dispatcher').getGlobalDispatcher;
var request: typeof import('./api').request;
var stream: typeof import('./api').stream;
var pipeline: typeof import('./api').pipeline;
var connect: typeof import('./api').connect;
var upgrade: typeof import('./api').upgrade;
var MockClient: typeof import('./mock-client').default;
var MockPool: typeof import('./mock-pool').default;
var MockAgent: typeof import('./mock-agent').default;
var mockErrors: typeof import('./mock-errors').default;
var fetch: typeof import('./fetch').fetch;
var caches: typeof import('./cache').caches;
}
55 changes: 55 additions & 0 deletions deps/undici/src/types/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "undici-types",
"version": "5.25.1",
"description": "A stand-alone types package for Undici",
"homepage": "https://undici.nodejs.org",
"bugs": {
"url": "https://github.com/nodejs/undici/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nodejs/undici.git"
},
"license": "MIT",
"types": "index.d.ts",
"files": [
"*.d.ts"
],
"contributors": [
{
"name": "Daniele Belardi",
"url": "https://github.com/dnlup",
"author": true
},
{
"name": "Ethan Arrowood",
"url": "https://github.com/ethan-arrowood",
"author": true
},
{
"name": "Matteo Collina",
"url": "https://github.com/mcollina",
"author": true
},
{
"name": "Matthew Aitken",
"url": "https://github.com/KhafraDev",
"author": true
},
{
"name": "Robert Nagy",
"url": "https://github.com/ronag",
"author": true
},
{
"name": "Szymon Marczak",
"url": "https://github.com/szmarczak",
"author": true
},
{
"name": "Tomas Della Vedova",
"url": "https://github.com/delvedor",
"author": true
}
]
}
20 changes: 14 additions & 6 deletions deps/undici/undici.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ var require_util = __commonJS({
return 0;
} else if (isStream(body)) {
const state = body._readableState;
return state && state.ended === true && Number.isFinite(state.length) ? state.length : null;
return state && state.objectMode === false && state.ended === true && Number.isFinite(state.length) ? state.length : null;
} else if (isBlobLike(body)) {
return body.size != null ? body.size : null;
} else if (isBuffer(body)) {
Expand Down Expand Up @@ -12419,7 +12419,6 @@ var require_util3 = __commonJS({
var require_connection = __commonJS({
"lib/websocket/connection.js"(exports2, module2) {
"use strict";
var { randomBytes, createHash } = require("crypto");
var diagnosticsChannel = require("diagnostics_channel");
var { uid, states } = require_constants3();
var {
Expand All @@ -12439,6 +12438,11 @@ var require_connection = __commonJS({
channels.open = diagnosticsChannel.channel("undici:websocket:open");
channels.close = diagnosticsChannel.channel("undici:websocket:close");
channels.socketError = diagnosticsChannel.channel("undici:websocket:socket_error");
var crypto;
try {
crypto = require("crypto");
} catch {
}
function establishWebSocketConnection(url, protocols, ws, onEstablish, options) {
const requestURL = url;
requestURL.protocol = url.protocol === "ws:" ? "http:" : "https:";
Expand All @@ -12455,7 +12459,7 @@ var require_connection = __commonJS({
const headersList = new Headers(options.headers)[kHeadersList];
request.headersList = headersList;
}
const keyValue = randomBytes(16).toString("base64");
const keyValue = crypto.randomBytes(16).toString("base64");
request.headersList.append("sec-websocket-key", keyValue);
request.headersList.append("sec-websocket-version", "13");
for (const protocol of protocols) {
Expand Down Expand Up @@ -12484,7 +12488,7 @@ var require_connection = __commonJS({
return;
}
const secWSAccept = response.headersList.get("Sec-WebSocket-Accept");
const digest = createHash("sha1").update(keyValue + uid).digest("base64");
const digest = crypto.createHash("sha1").update(keyValue + uid).digest("base64");
if (secWSAccept !== digest) {
failWebsocketConnection(ws, "Incorrect hash received in Sec-WebSocket-Accept header.");
return;
Expand Down Expand Up @@ -12563,12 +12567,16 @@ var require_connection = __commonJS({
var require_frame = __commonJS({
"lib/websocket/frame.js"(exports2, module2) {
"use strict";
var { randomBytes } = require("crypto");
var { maxUnsigned16Bit } = require_constants3();
var crypto;
try {
crypto = require("crypto");
} catch {
}
var WebsocketFrameSend = class {
constructor(data) {
this.frameData = data;
this.maskKey = randomBytes(4);
this.maskKey = crypto.randomBytes(4);
}
createFrame(opcode) {
const bodyLength = this.frameData?.byteLength ?? 0;
Expand Down
Loading