Socket
Socket
Sign inDemoInstall

undici

Package Overview
Dependencies
Maintainers
3
Versions
212
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

undici - npm Package Compare versions

Comparing version 5.14.0 to 5.15.0

docs/api/Cookies.md

67

docs/api/DiagnosticsChannel.md

@@ -138,1 +138,68 @@ # Diagnostics Channel Support

})
```
## `undici:websocket:open`
This message is published after the client has successfully connected to a server.
```js
import diagnosticsChannel from 'diagnostics_channel'
diagnosticsChannel.channel('undici:websocket:open').subscribe(({ address, protocol, extensions }) => {
console.log(address) // address, family, and port
console.log(protocol) // negotiated subprotocols
console.log(extensions) // negotiated extensions
})
```
## `undici:websocket:close`
This message is published after the connection has closed.
```js
import diagnosticsChannel from 'diagnostics_channel'
diagnosticsChannel.channel('undici:websocket:close').subscribe(({ websocket, code, reason }) => {
console.log(websocket) // the WebSocket object
console.log(code) // the closing status code
console.log(reason) // the closing reason
})
```
## `undici:websocket:socket_error`
This message is published if the socket experiences an error.
```js
import diagnosticsChannel from 'diagnostics_channel'
diagnosticsChannel.channel('undici:websocket:socket_error').subscribe((error) => {
console.log(error)
})
```
## `undici:websocket:ping`
This message is published after the client receives a ping frame, if the connection is not closing.
```js
import diagnosticsChannel from 'diagnostics_channel'
diagnosticsChannel.channel('undici:websocket:ping').subscribe(({ payload }) => {
// a Buffer or undefined, containing the optional application data of the frame
console.log(payload)
})
```
## `undici:websocket:pong`
This message is published after the client receives a pong frame.
```js
import diagnosticsChannel from 'diagnostics_channel'
diagnosticsChannel.channel('undici:websocket:pong').subscribe(({ payload }) => {
// a Buffer or undefined, containing the optional application data of the frame
console.log(payload)
})
```

1

docs/api/Dispatcher.md

@@ -195,2 +195,3 @@ # Dispatcher

* **method** `string`
* **reset** `boolean` (optional) - Default: `false` - If `false`, the request will attempt to create a long-living connection by sending the `connection: keep-alive` header,otherwise will attempt to close it immediately after response by sending `connection: close` within the request and closing the socket afterwards.
* **body** `string | Buffer | Uint8Array | stream.Readable | Iterable | AsyncIterable | null` (optional) - Default: `null`

@@ -197,0 +198,0 @@ * **headers** `UndiciHeaders | string[]` (optional) - Default: `null`.

@@ -19,2 +19,3 @@ import Dispatcher from'./types/dispatcher'

export * from './types/cookies'
export * from './types/fetch'

@@ -25,2 +26,3 @@ export * from './types/file'

export * from './types/diagnostics-channel'
export * from './types/websocket'
export { Interceptable } from './types/mock-interceptor'

@@ -27,0 +29,0 @@

@@ -122,2 +122,17 @@ 'use strict'

if (nodeMajor >= 16) {
const { deleteCookie, getCookies, getSetCookies, setCookie } = require('./lib/cookies')
module.exports.deleteCookie = deleteCookie
module.exports.getCookies = getCookies
module.exports.getSetCookies = getSetCookies
module.exports.setCookie = setCookie
}
if (nodeMajor >= 18) {
const { WebSocket } = require('./lib/websocket/websocket')
module.exports.WebSocket = WebSocket
}
module.exports.request = makeDispatcher(api.request)

@@ -124,0 +139,0 @@ module.exports.stream = makeDispatcher(api.stream)

9

lib/client.js

@@ -1298,3 +1298,3 @@ 'use strict'

function write (client, request) {
const { body, method, path, host, upgrade, headers, blocking } = request
const { body, method, path, host, upgrade, headers, blocking, reset } = request

@@ -1367,3 +1367,2 @@ // https://tools.ietf.org/html/rfc7231#section-4.3.1

// https://github.com/mcollina/undici/issues/258
// Close after a HEAD request to interop with misbehaving servers

@@ -1382,2 +1381,6 @@ // that may send a body in the response.

if (reset) {
socket[kReset] = true
}
if (client[kMaxRequests] && socket[kCounter]++ >= client[kMaxRequests]) {

@@ -1401,3 +1404,3 @@ socket[kReset] = true

header += `connection: upgrade\r\nupgrade: ${upgrade}\r\n`
} else if (client[kPipelining]) {
} else if (client[kPipelining] && !socket[kReset]) {
header += 'connection: keep-alive\r\n'

@@ -1404,0 +1407,0 @@ } else {

@@ -68,2 +68,3 @@ 'use strict'

bodyTimeout,
reset,
throwOnError

@@ -101,2 +102,6 @@ }, handler) {

if (reset != null && typeof reset !== 'boolean') {
throw new InvalidArgumentError('invalid reset')
}
this.headersTimeout = headersTimeout

@@ -144,2 +149,4 @@

this.reset = reset == null ? false : reset
this.host = null

@@ -277,4 +284,13 @@

function processHeaderValue (key, val) {
if (val && (typeof val === 'object' && !Array.isArray(val))) {
throw new InvalidArgumentError(`invalid ${key} header`)
} else if (headerCharRegex.exec(val) !== null) {
throw new InvalidArgumentError(`invalid ${key} header`)
}
return `${key}: ${val}\r\n`
}
function processHeader (request, key, val) {
if (val && typeof val === 'object') {
if (val && (typeof val === 'object' && !Array.isArray(val))) {
throw new InvalidArgumentError(`invalid ${key} header`)

@@ -318,3 +334,8 @@ } else if (val === undefined) {

) {
throw new InvalidArgumentError('invalid connection header')
const value = val.toLowerCase()
if (value !== 'close' && value !== 'keep-alive') {
throw new InvalidArgumentError('invalid connection header')
} else if (value === 'close') {
request.reset = true
}
} else if (

@@ -337,6 +358,10 @@ key.length === 10 &&

throw new InvalidArgumentError('invalid header key')
} else if (headerCharRegex.exec(val) !== null) {
throw new InvalidArgumentError(`invalid ${key} header`)
} else {
request.headers += `${key}: ${val}\r\n`
if (Array.isArray(val)) {
for (let i = 0; i < val.length; i++) {
request.headers += processHeaderValue(key, val[i])
}
} else {
request.headers += processHeaderValue(key, val)
}
}

@@ -343,0 +368,0 @@ }

@@ -35,3 +35,3 @@ module.exports = {

kReset: Symbol('reset'),
kDestroyed: Symbol('destroyed'),
kDestroyed: Symbol.for('nodejs.stream.destroyed'),
kMaxHeadersSize: Symbol('max headers size'),

@@ -38,0 +38,0 @@ kRunningIdx: Symbol('running index'),

@@ -5,3 +5,10 @@ 'use strict'

const util = require('../core/util')
const { ReadableStreamFrom, isBlobLike, isReadableStreamLike, readableStreamClose } = require('./util')
const {
ReadableStreamFrom,
isBlobLike,
isReadableStreamLike,
readableStreamClose,
createDeferredPromise,
fullyReadBody
} = require('./util')
const { FormData } = require('./formdata')

@@ -17,3 +24,2 @@ const { kState } = require('./symbols')

const { File: UndiciFile } = require('./file')
const { StringDecoder } = require('string_decoder')
const { parseMIMEType, serializeAMimeType } = require('./dataURL')

@@ -104,3 +110,3 @@

} else if (util.isFormDataLike(object)) {
const boundary = '----formdata-undici-' + Math.random()
const boundary = `----formdata-undici-${Math.random()}`.replace('.', '').slice(0, 32)
const prefix = `--${boundary}\r\nContent-Disposition: form-data`

@@ -115,65 +121,46 @@

// encoding algorithm, with object’s entry list and UTF-8.
action = async function * (object) {
const enc = new TextEncoder()
// - This ensures that the body is immutable and can't be changed afterwords
// - That the content-length is calculated in advance.
// - And that all parts are pre-encoded and ready to be sent.
for (const [name, value] of object) {
if (typeof value === 'string') {
yield enc.encode(
prefix +
`; name="${escape(normalizeLinefeeds(name))}"` +
`\r\n\r\n${normalizeLinefeeds(value)}\r\n`
)
} else {
yield enc.encode(
prefix +
`; name="${escape(normalizeLinefeeds(name))}"` +
(value.name ? `; filename="${escape(value.name)}"` : '') +
'\r\n' +
`Content-Type: ${
value.type || 'application/octet-stream'
}\r\n\r\n`
)
const enc = new TextEncoder()
const blobParts = []
const rn = new Uint8Array([13, 10]) // '\r\n'
length = 0
yield * value.stream()
// '\r\n' encoded
yield new Uint8Array([13, 10])
}
for (const [name, value] of object) {
if (typeof value === 'string') {
const chunk = enc.encode(prefix +
`; name="${escape(normalizeLinefeeds(name))}"` +
`\r\n\r\n${normalizeLinefeeds(value)}\r\n`)
blobParts.push(chunk)
length += chunk.byteLength
} else {
const chunk = enc.encode(`${prefix}; name="${escape(normalizeLinefeeds(name))}"` +
(value.name ? `; filename="${escape(value.name)}"` : '') + '\r\n' +
`Content-Type: ${
value.type || 'application/octet-stream'
}\r\n\r\n`)
blobParts.push(chunk, value, rn)
length += chunk.byteLength + value.size + rn.byteLength
}
yield enc.encode(`--${boundary}--`)
}
const chunk = enc.encode(`--${boundary}--`)
blobParts.push(chunk)
length += chunk.byteLength
// Set source to object.
source = object
// Set length to unclear, see html/6424 for improving this.
length = (() => {
const prefixLength = prefix.length
const boundaryLength = boundary.length
let bodyLength = 0
for (const [name, value] of object) {
if (typeof value === 'string') {
bodyLength +=
prefixLength +
Buffer.byteLength(`; name="${escape(normalizeLinefeeds(name))}"\r\n\r\n${normalizeLinefeeds(value)}\r\n`)
action = async function * () {
for (const part of blobParts) {
if (part.stream) {
yield * part.stream()
} else {
bodyLength +=
prefixLength +
Buffer.byteLength(`; name="${escape(normalizeLinefeeds(name))}"` + (value.name ? `; filename="${escape(value.name)}"` : '')) +
2 + // \r\n
`Content-Type: ${
value.type || 'application/octet-stream'
}\r\n\r\n`.length
// value is a Blob or File, and \r\n
bodyLength += value.size + 2
yield part
}
}
}
bodyLength += boundaryLength + 4 // --boundary--
return bodyLength
})()
// Set type to `multipart/form-data; boundary=`,

@@ -197,7 +184,2 @@ // followed by the multipart/form-data boundary string generated

}
} else if (object instanceof Uint8Array) {
// byte sequence
// Set source to object.
source = object
} else if (typeof object[Symbol.asyncIterator] === 'function') {

@@ -345,22 +327,41 @@ // If keepalive is true, then throw a TypeError.

// The blob() method steps are to return the result of
// running consume body with this and Blob.
return specConsumeBody(this, 'Blob', instance)
// running consume body with this and the following step
// given a byte sequence bytes: return a Blob whose
// contents are bytes and whose type attribute is this’s
// MIME type.
return specConsumeBody(this, (bytes) => {
let mimeType = bodyMimeType(this)
if (mimeType === 'failure') {
mimeType = ''
} else if (mimeType) {
mimeType = serializeAMimeType(mimeType)
}
// Return a Blob whose contents are bytes and type attribute
// is mimeType.
return new Blob([bytes], { type: mimeType })
}, instance)
},
arrayBuffer () {
// The arrayBuffer() method steps are to return the
// result of running consume body with this and ArrayBuffer.
return specConsumeBody(this, 'ArrayBuffer', instance)
// The arrayBuffer() method steps are to return the result
// of running consume body with this and the following step
// given a byte sequence bytes: return a new ArrayBuffer
// whose contents are bytes.
return specConsumeBody(this, (bytes) => {
return new Uint8Array(bytes).buffer
}, instance)
},
text () {
// The text() method steps are to return the result of
// running consume body with this and text.
return specConsumeBody(this, 'text', instance)
// The text() method steps are to return the result of running
// consume body with this and UTF-8 decode.
return specConsumeBody(this, utf8DecodeBytes, instance)
},
json () {
// The json() method steps are to return the result of
// running consume body with this and JSON.
return specConsumeBody(this, 'JSON', instance)
// The json() method steps are to return the result of running
// consume body with this and parse JSON from bytes.
return specConsumeBody(this, parseJSONFromBytes, instance)
},

@@ -390,4 +391,3 @@

} catch (err) {
// Error due to headers:
throw Object.assign(new TypeError(), { cause: err })
throw new DOMException(`${err}`, 'AbortError')
}

@@ -490,4 +490,9 @@

// https://fetch.spec.whatwg.org/#concept-body-consume-body
async function specConsumeBody (object, type, instance) {
/**
* @see https://fetch.spec.whatwg.org/#concept-body-consume-body
* @param {Response|Request} object
* @param {(value: unknown) => unknown} convertBytesToJSValue
* @param {Response|Request} instance
*/
async function specConsumeBody (object, convertBytesToJSValue, instance) {
webidl.brandCheck(object, instance)

@@ -503,67 +508,33 @@

// 2. Let promise be a promise resolved with an empty byte
// sequence.
let promise
// 2. Let promise be a new promise.
const promise = createDeferredPromise()
// 3. If object’s body is non-null, then set promise to the
// result of fully reading body as promise given object’s
// body.
if (object[kState].body != null) {
promise = await fullyReadBodyAsPromise(object[kState].body)
} else {
// step #2
promise = { size: 0, bytes: [new Uint8Array()] }
// 3. Let errorSteps given error be to reject promise with error.
const errorSteps = (error) => promise.reject(error)
// 4. Let successSteps given a byte sequence data be to resolve
// promise with the result of running convertBytesToJSValue
// with data. If that threw an exception, then run errorSteps
// with that exception.
const successSteps = (data) => {
try {
promise.resolve(convertBytesToJSValue(data))
} catch (e) {
errorSteps(e)
}
}
// 4. Let steps be to return the result of package data with
// the first argument given, type, and object’s MIME type.
const mimeType = type === 'Blob' || type === 'FormData'
? bodyMimeType(object)
: undefined
// 5. If object’s body is null, then run successSteps with an
// empty byte sequence.
if (object[kState].body == null) {
successSteps(new Uint8Array())
return promise.promise
}
// 5. Return the result of upon fulfillment of promise given
// steps.
return packageData(promise, type, mimeType)
}
// 6. Otherwise, fully read object’s body given successSteps,
// errorSteps, and object’s relevant global object.
fullyReadBody(object[kState].body, successSteps, errorSteps)
/**
* @see https://fetch.spec.whatwg.org/#concept-body-package-data
* @param {{ size: number, bytes: Uint8Array[] }} bytes
* @param {string} type
* @param {ReturnType<typeof parseMIMEType>|undefined} mimeType
*/
function packageData ({ bytes, size }, type, mimeType) {
switch (type) {
case 'ArrayBuffer': {
// Return a new ArrayBuffer whose contents are bytes.
const uint8 = new Uint8Array(size)
let offset = 0
for (const chunk of bytes) {
uint8.set(chunk, offset)
offset += chunk.byteLength
}
return uint8.buffer
}
case 'Blob': {
if (mimeType === 'failure') {
mimeType = ''
} else if (mimeType) {
mimeType = serializeAMimeType(mimeType)
}
// Return a Blob whose contents are bytes and type attribute
// is mimeType.
return new Blob(bytes, { type: mimeType })
}
case 'JSON': {
// Return the result of running parse JSON from bytes on bytes.
return JSON.parse(utf8DecodeBytes(bytes))
}
case 'text': {
// 1. Return the result of running UTF-8 decode on bytes.
return utf8DecodeBytes(bytes)
}
}
// 7. Return promise.
return promise.promise
}

@@ -579,47 +550,13 @@

// https://fetch.spec.whatwg.org/#fully-reading-body-as-promise
async function fullyReadBodyAsPromise (body) {
// 1. Let reader be the result of getting a reader for body’s
// stream. If that threw an exception, then return a promise
// rejected with that exception.
const reader = body.stream.getReader()
// 2. Return the result of reading all bytes from reader.
/** @type {Uint8Array[]} */
const bytes = []
let size = 0
while (true) {
const { done, value } = await reader.read()
if (done) {
break
}
// https://streams.spec.whatwg.org/#read-loop
// If chunk is not a Uint8Array object, reject promise with
// a TypeError and abort these steps.
if (!isUint8Array(value)) {
throw new TypeError('Value is not a Uint8Array.')
}
bytes.push(value)
size += value.byteLength
}
return { size, bytes }
}
/**
* @see https://encoding.spec.whatwg.org/#utf-8-decode
* @param {Uint8Array[]} ioQueue
* @param {Buffer} buffer
*/
function utf8DecodeBytes (ioQueue) {
if (ioQueue.length === 0) {
function utf8DecodeBytes (buffer) {
if (buffer.length === 0) {
return ''
}
// 1. Let buffer be the result of peeking three bytes
// from ioQueue, converted to a byte sequence.
const buffer = ioQueue[0]
// 1. Let buffer be the result of peeking three bytes from
// ioQueue, converted to a byte sequence.

@@ -629,3 +566,3 @@ // 2. If buffer is 0xEF 0xBB 0xBF, then read three

if (buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) {
ioQueue[0] = ioQueue[0].subarray(3)
buffer = buffer.subarray(3)
}

@@ -635,11 +572,4 @@

// decoder, ioQueue, output, and "replacement".
const decoder = new StringDecoder('utf-8')
let output = ''
const output = new TextDecoder().decode(buffer)
for (const chunk of ioQueue) {
output += decoder.write(chunk)
}
output += decoder.end()
// 4. Return output.

@@ -650,2 +580,10 @@ return output

/**
* @see https://infra.spec.whatwg.org/#parse-json-bytes-to-a-javascript-value
* @param {Uint8Array} bytes
*/
function parseJSONFromBytes (bytes) {
return JSON.parse(utf8DecodeBytes(bytes))
}
/**
* @see https://fetch.spec.whatwg.org/#concept-body-mime-type

@@ -652,0 +590,0 @@ * @param {import('./response').Response|import('./request').Request} object

@@ -68,2 +68,5 @@ // https://github.com/Ethan-Arrowood/undici-fetch

class HeadersList {
/** @type {[string, string][]|null} */
cookies = null
constructor (init) {

@@ -109,2 +112,7 @@ if (init instanceof HeadersList) {

}
if (lowercaseName === 'set-cookie') {
this.cookies ??= []
this.cookies.push([name, value])
}
}

@@ -117,2 +125,6 @@

if (lowercaseName === 'set-cookie') {
this.cookies = [[name, value]]
}
// 1. If list contains name, then set the value of

@@ -130,2 +142,7 @@ // the first such header to value and remove the

name = name.toLowerCase()
if (name === 'set-cookie') {
this.cookies = null
}
return this[kHeadersMap].delete(name)

@@ -132,0 +149,0 @@ }

@@ -351,3 +351,6 @@ /* globals AbortController */

} else {
const abort = () => ac.abort(signal.reason)
const acRef = new WeakRef(ac)
const abort = function () {
acRef.deref()?.abort(this.reason)
}
signal.addEventListener('abort', abort, { once: true })

@@ -354,0 +357,0 @@ requestFinalizer.register(this, { signal, abort })

@@ -808,44 +808,28 @@ 'use strict'

*/
async function fullyReadBody (body, processBody, processBodyError) {
function fullyReadBody (body, processBody, processBodyError) {
// 1. If taskDestination is null, then set taskDestination to
// the result of starting a new parallel queue.
// 2. Let promise be the result of fully reading body as promise
// given body.
try {
/** @type {Uint8Array[]} */
const chunks = []
let length = 0
// 2. Let successSteps given a byte sequence bytes be to queue a
// fetch task to run processBody given bytes, with taskDestination.
const successSteps = (bytes) => queueMicrotask(() => processBody(bytes))
const reader = body.stream.getReader()
// 3. Let errorSteps be to queue a fetch task to run processBodyError,
// with taskDestination.
const errorSteps = (error) => queueMicrotask(() => processBodyError(error))
while (true) {
const { done, value } = await reader.read()
// 4. Let reader be the result of getting a reader for body’s stream.
// If that threw an exception, then run errorSteps with that
// exception and return.
let reader
if (done === true) {
break
}
// read-loop chunk steps
assert(isUint8Array(value))
chunks.push(value)
length += value.byteLength
}
// 3. Let fulfilledSteps given a byte sequence bytes be to queue
// a fetch task to run processBody given bytes, with
// taskDestination.
const fulfilledSteps = (bytes) => queueMicrotask(() => {
processBody(bytes)
})
fulfilledSteps(Buffer.concat(chunks, length))
} catch (err) {
// 4. Let rejectedSteps be to queue a fetch task to run
// processBodyError, with taskDestination.
queueMicrotask(() => processBodyError(err))
try {
reader = body.stream.getReader()
} catch (e) {
errorSteps(e)
return
}
// 5. React to promise with fulfilledSteps and rejectedSteps.
// 5. Read all bytes from reader, given successSteps and errorSteps.
readAllBytes(reader, successSteps, errorSteps)
}

@@ -916,2 +900,46 @@

/**
* @see https://streams.spec.whatwg.org/#readablestreamdefaultreader-read-all-bytes
* @see https://streams.spec.whatwg.org/#read-loop
* @param {ReadableStreamDefaultReader} reader
* @param {(bytes: Uint8Array) => void} successSteps
* @param {(error: Error) => void} failureSteps
*/
async function readAllBytes (reader, successSteps, failureSteps) {
const bytes = []
let byteLength = 0
while (true) {
let done
let chunk
try {
({ done, value: chunk } = await reader.read())
} catch (e) {
// 1. Call failureSteps with e.
failureSteps(e)
return
}
if (done) {
// 1. Call successSteps with bytes.
successSteps(Buffer.concat(bytes, byteLength))
return
}
// 1. If chunk is not a Uint8Array object, call failureSteps
// with a TypeError and abort these steps.
if (!isUint8Array(chunk)) {
failureSteps(new TypeError('Received non-Uint8Array chunk'))
return
}
// 2. Append the bytes represented by chunk to bytes.
bytes.push(chunk)
byteLength += chunk.length
// 3. Read-loop given reader, bytes, successSteps, and failureSteps.
}
}
/**
* Fetch supports node >= 16.8.0, but Object.hasOwn was added in v16.9.0.

@@ -918,0 +946,0 @@ */

@@ -36,5 +36,7 @@ 'use strict'

// https://webidl.spec.whatwg.org/#implements
webidl.brandCheck = function (V, I) {
if (!(V instanceof I)) {
webidl.brandCheck = function (V, I, opts = undefined) {
if (opts?.strict !== false && !(V instanceof I)) {
throw new TypeError('Illegal invocation')
} else {
return V?.[Symbol.toStringTag] === I.prototype[Symbol.toStringTag]
}

@@ -476,6 +478,16 @@ }

// https://webidl.spec.whatwg.org/#es-unsigned-long
webidl.converters['unsigned long'] = function (V) {
// 1. Let x be ? ConvertToInt(V, 32, "unsigned").
const x = webidl.util.ConvertToInt(V, 32, 'unsigned')
// 2. Return the IDL unsigned long value that
// represents the same numeric value as x.
return x
}
// https://webidl.spec.whatwg.org/#es-unsigned-short
webidl.converters['unsigned short'] = function (V) {
webidl.converters['unsigned short'] = function (V, opts) {
// 1. Let x be ? ConvertToInt(V, 16, "unsigned").
const x = webidl.util.ConvertToInt(V, 16, 'unsigned')
const x = webidl.util.ConvertToInt(V, 16, 'unsigned', opts)

@@ -482,0 +494,0 @@ // 2. Return the IDL unsigned short value that represents

{
"name": "undici",
"version": "5.14.0",
"version": "5.15.0",
"description": "An HTTP/1.1 client, written from scratch for Node.js",

@@ -49,3 +49,4 @@ "homepage": "https://undici.nodejs.org",

"lint:fix": "standard --fix | snazzy",
"test": "npm run test:tap && npm run test:node-fetch && npm run test:fetch && npm run test:wpt && npm run test:jest && tsd",
"test": "npm run test:tap && npm run test:node-fetch && npm run test:fetch && npm run test:cookies && npm run test:wpt && npm run test:websocket && npm run test:jest && tsd",
"test:cookies": "node scripts/verifyVersion 16 || tap test/cookie/*.js",
"test:node-fetch": "node scripts/verifyVersion.js 16 || mocha test/node-fetch",

@@ -57,3 +58,4 @@ "test:fetch": "node scripts/verifyVersion.js 16 || (npm run build:node && tap test/fetch/*.js && tap test/webidl/*.js)",

"test:typescript": "tsd && tsc test/imports/undici-import.ts",
"test:wpt": "node scripts/verifyVersion 18 || (node test/wpt/start-fetch.mjs && node test/wpt/start-FileAPI.mjs && node test/wpt/start-mimesniff.mjs && node test/wpt/start-xhr.mjs)",
"test:websocket": "node scripts/verifyVersion.js 18 || tap test/websocket/*.js",
"test:wpt": "node scripts/verifyVersion 18 || (node test/wpt/start-fetch.mjs && node test/wpt/start-FileAPI.mjs && node test/wpt/start-mimesniff.mjs && node test/wpt/start-xhr.mjs && node test/wpt/start-websockets.mjs)",
"coverage": "nyc --reporter=text --reporter=html npm run test",

@@ -70,3 +72,3 @@ "coverage:ci": "nyc --reporter=lcov npm run test",

"devDependencies": {
"@sinonjs/fake-timers": "^9.1.2",
"@sinonjs/fake-timers": "^10.0.2",
"@types/node": "^18.0.3",

@@ -102,3 +104,4 @@ "abort-controller": "^3.0.0",

"typescript": "^4.8.4",
"wait-on": "^6.0.0"
"wait-on": "^6.0.0",
"ws": "^8.11.0"
},

@@ -105,0 +108,0 @@ "engines": {

@@ -114,2 +114,4 @@ import { URL } from 'url'

bodyTimeout?: number | null;
/** Whether the request should stablish a keep-alive or not. Default `false` */
reset?: boolean;
/** Whether Undici should throw an error upon receiving a 4xx or 5xx response from the server. Defaults to false */

@@ -116,0 +118,0 @@ throwOnError?: boolean;

@@ -52,1 +52,21 @@ /// <reference types="node" />

}
export interface EventListenerOptions {
capture?: boolean
}
export interface AddEventListenerOptions extends EventListenerOptions {
once?: boolean
passive?: boolean
signal?: AbortSignal
}
export type EventListenerOrEventListenerObject = EventListener | EventListenerObject
export interface EventListenerObject {
handleEvent (object: Event): void
}
export interface EventListener {
(evt: Event): void
}

@@ -1,3 +0,3 @@

import { TlsOptions } from 'tls'
import Agent from './agent'
import buildConnector from './connector';
import Dispatcher from './dispatcher'

@@ -22,5 +22,5 @@

token?: string;
requestTls?: TlsOptions & { servername?: string };
proxyTls?: TlsOptions & { servername?: string };
requestTls?: buildConnector.BuildOptions;
proxyTls?: buildConnector.BuildOptions;
}
}

@@ -106,5 +106,10 @@ // These types are not exported, and are only used internally

/**
* @see https://webidl.spec.whatwg.org/#es-unsigned-long
*/
['unsigned long'] (V: unknown): number
/**
* @see https://webidl.spec.whatwg.org/#es-unsigned-short
*/
['unsigned short'] (V: unknown): number
['unsigned short'] (V: unknown, opts?: ConvertToIntOpts): number

@@ -161,3 +166,3 @@ /**

*/
brandCheck <Interface>(V: unknown, cls: Interface): asserts V is Interface
brandCheck <Interface>(V: unknown, cls: Interface, opts?: { strict?: boolean }): asserts V is Interface

@@ -164,0 +169,0 @@ /**

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc