This commit is contained in:
GrantBirki 2023-11-07 16:16:43 -07:00
Родитель 3046b44217
Коммит 054aa0be6e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 9029BBCCC15C6F8C
3 изменённых файлов: 242 добавлений и 155 удалений

241
dist/index.js сгенерированный поставляемый
Просмотреть файл

@ -13582,6 +13582,10 @@ class StreamHandler extends AsyncResource {
{ callback, body: res, contentType, statusCode, statusMessage, headers }
)
} else {
if (factory === null) {
return
}
res = this.runInAsyncScope(factory, null, {
statusCode,
headers,
@ -13630,7 +13634,7 @@ class StreamHandler extends AsyncResource {
onData (chunk) {
const { res } = this
return res.write(chunk)
return res ? res.write(chunk) : true
}
onComplete (trailers) {
@ -13638,6 +13642,10 @@ class StreamHandler extends AsyncResource {
removeSignal(this)
if (!res) {
return
}
this.trailers = util.parseHeaders(trailers)
res.end()
@ -14094,7 +14102,7 @@ function consumeEnd (consume) {
pos += buf.byteLength
}
resolve(dst)
resolve(dst.buffer)
} else if (type === 'blob') {
if (!Blob) {
Blob = (__nccwpck_require__(4300).Blob)
@ -16530,7 +16538,9 @@ function onParserTimeout (parser) {
function onSocketReadable () {
const { [kParser]: parser } = this
parser.readMore()
if (parser) {
parser.readMore()
}
}
function onSocketError (err) {
@ -16920,23 +16930,7 @@ function _resume (client, sync) {
return
}
if (util.isStream(request.body) && util.bodyLength(request.body) === 0) {
request.body
.on('data', /* istanbul ignore next */ function () {
/* istanbul ignore next */
assert(false)
})
.on('error', function (err) {
errorRequest(client, request, err)
})
.on('end', function () {
util.destroy(this)
})
request.body = null
}
if (client[kRunning] > 0 &&
if (client[kRunning] > 0 && util.bodyLength(request.body) !== 0 &&
(util.isStream(request.body) || util.isAsyncIterable(request.body))) {
// Request with stream or iterator body can error while other requests
// are inflight and indirectly error those as well.
@ -16957,6 +16951,11 @@ function _resume (client, sync) {
}
}
// https://www.rfc-editor.org/rfc/rfc7230#section-3.3.2
function shouldSendContentLength (method) {
return method !== 'GET' && method !== 'HEAD' && method !== 'OPTIONS' && method !== 'TRACE' && method !== 'CONNECT'
}
function write (client, request) {
if (client[kHTTPConnVersion] === 'h2') {
writeH2(client, client[kHTTP2Session], request)
@ -16985,7 +16984,9 @@ function write (client, request) {
body.read(0)
}
let contentLength = util.bodyLength(body)
const bodyLength = util.bodyLength(body)
let contentLength = bodyLength
if (contentLength === null) {
contentLength = request.contentLength
@ -17000,7 +17001,9 @@ function write (client, request) {
contentLength = null
}
if (request.contentLength !== null && request.contentLength !== contentLength) {
// https://github.com/nodejs/undici/issues/2046
// A user agent may send a Content-Length header with 0 value, this should be allowed.
if (shouldSendContentLength(method) && contentLength > 0 && request.contentLength !== null && request.contentLength !== contentLength) {
if (client[kStrictContentLength]) {
errorRequest(client, request, new RequestContentLengthMismatchError())
return false
@ -17081,7 +17084,7 @@ function write (client, request) {
}
/* istanbul ignore else: assertion */
if (!body) {
if (!body || bodyLength === 0) {
if (contentLength === 0) {
socket.write(`${header}content-length: 0\r\n\r\n`, 'latin1')
} else {
@ -17221,7 +17224,9 @@ function writeH2 (client, session, request) {
contentLength = null
}
if (request.contentLength != null && request.contentLength !== contentLength) {
// https://github.com/nodejs/undici/issues/2046
// A user agent may send a Content-Length header with 0 value, this should be allowed.
if (shouldSendContentLength(method) && contentLength > 0 && request.contentLength != null && request.contentLength !== contentLength) {
if (client[kStrictContentLength]) {
errorRequest(client, request, new RequestContentLengthMismatchError())
return false
@ -19183,10 +19188,29 @@ class Request {
this.method = method
this.abort = null
if (body == null) {
this.body = null
} else if (util.isStream(body)) {
this.body = body
const rState = this.body._readableState
if (!rState || !rState.autoDestroy) {
this.endHandler = function autoDestroy () {
util.destroy(this)
}
this.body.on('end', this.endHandler)
}
this.errorHandler = err => {
if (this.abort) {
this.abort(err)
} else {
this.error = err
}
}
this.body.on('error', this.errorHandler)
} else if (util.isBuffer(body)) {
this.body = body.byteLength ? body : null
} else if (ArrayBuffer.isView(body)) {
@ -19293,13 +19317,26 @@ class Request {
if (channels.bodySent.hasSubscribers) {
channels.bodySent.publish({ request: this })
}
if (this[kHandler].onRequestSent) {
try {
this[kHandler].onRequestSent()
} catch (err) {
this.onError(err)
}
}
}
onConnect (abort) {
assert(!this.aborted)
assert(!this.completed)
return this[kHandler].onConnect(abort)
if (this.error) {
abort(this.error)
} else {
this.abort = abort
return this[kHandler].onConnect(abort)
}
}
onHeaders (statusCode, headers, resume, statusText) {
@ -19328,6 +19365,8 @@ class Request {
}
onComplete (trailers) {
this.onFinally()
assert(!this.aborted)
this.completed = true
@ -19338,6 +19377,8 @@ class Request {
}
onError (error) {
this.onFinally()
if (channels.error.hasSubscribers) {
channels.error.publish({ request: this, error })
}
@ -19349,6 +19390,18 @@ class Request {
return this[kHandler].onError(error)
}
onFinally () {
if (this.errorHandler) {
this.body.off('error', this.errorHandler)
this.errorHandler = null
}
if (this.endHandler) {
this.body.off('end', this.endHandler)
this.endHandler = null
}
}
// TODO: adjust to support H2
addHeader (key, value) {
processHeader(this, key, value)
@ -19772,7 +19825,7 @@ function isReadableAborted (stream) {
}
function destroy (stream, err) {
if (!isStream(stream) || isDestroyed(stream)) {
if (stream == null || !isStream(stream) || isDestroyed(stream)) {
return
}
@ -20346,6 +20399,8 @@ let ReadableStream = globalThis.ReadableStream
/** @type {globalThis['File']} */
const File = NativeFile ?? UndiciFile
const textEncoder = new TextEncoder()
const textDecoder = new TextDecoder()
// https://fetch.spec.whatwg.org/#concept-bodyinit-extract
function extractBody (object, keepalive = false) {
@ -20369,7 +20424,7 @@ function extractBody (object, keepalive = false) {
stream = new ReadableStream({
async pull (controller) {
controller.enqueue(
typeof source === 'string' ? new TextEncoder().encode(source) : source
typeof source === 'string' ? textEncoder.encode(source) : source
)
queueMicrotask(() => readableStreamClose(controller))
},
@ -20439,7 +20494,6 @@ function extractBody (object, keepalive = false) {
// - That the content-length is calculated in advance.
// - And that all parts are pre-encoded and ready to be sent.
const enc = new TextEncoder()
const blobParts = []
const rn = new Uint8Array([13, 10]) // '\r\n'
length = 0
@ -20447,13 +20501,13 @@ function extractBody (object, keepalive = false) {
for (const [name, value] of object) {
if (typeof value === 'string') {
const chunk = enc.encode(prefix +
const chunk = textEncoder.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))}"` +
const chunk = textEncoder.encode(`${prefix}; name="${escape(normalizeLinefeeds(name))}"` +
(value.name ? `; filename="${escape(value.name)}"` : '') + '\r\n' +
`Content-Type: ${
value.type || 'application/octet-stream'
@ -20467,7 +20521,7 @@ function extractBody (object, keepalive = false) {
}
}
const chunk = enc.encode(`--${boundary}--`)
const chunk = textEncoder.encode(`--${boundary}--`)
blobParts.push(chunk)
length += chunk.byteLength
if (hasUnknownSizeValue) {
@ -20763,14 +20817,16 @@ function bodyMixinMethods (instance) {
let text = ''
// application/x-www-form-urlencoded parser will keep the BOM.
// https://url.spec.whatwg.org/#concept-urlencoded-parser
const textDecoder = new TextDecoder('utf-8', { ignoreBOM: true })
// Note that streaming decoder is stateful and cannot be reused
const streamingDecoder = new TextDecoder('utf-8', { ignoreBOM: true })
for await (const chunk of consumeBody(this[kState].body)) {
if (!isUint8Array(chunk)) {
throw new TypeError('Expected Uint8Array chunk')
}
text += textDecoder.decode(chunk, { stream: true })
text += streamingDecoder.decode(chunk, { stream: true })
}
text += textDecoder.decode()
text += streamingDecoder.decode()
entries = new URLSearchParams(text)
} catch (err) {
// istanbul ignore next: Unclear when new URLSearchParams can fail on a string.
@ -20885,7 +20941,7 @@ function utf8DecodeBytes (buffer) {
// 3. Process a queue with an instance of UTF-8s
// decoder, ioQueue, output, and "replacement".
const output = new TextDecoder().decode(buffer)
const output = textDecoder.decode(buffer)
// 4. Return output.
return output
@ -20933,10 +20989,12 @@ module.exports = {
const { MessageChannel, receiveMessageOnPort } = __nccwpck_require__(1267)
const corsSafeListedMethods = ['GET', 'HEAD', 'POST']
const corsSafeListedMethodsSet = new Set(corsSafeListedMethods)
const nullBodyStatus = [101, 204, 205, 304]
const redirectStatus = [301, 302, 303, 307, 308]
const redirectStatusSet = new Set(redirectStatus)
// https://fetch.spec.whatwg.org/#block-bad-port
const badPorts = [
@ -20948,6 +21006,8 @@ const badPorts = [
'10080'
]
const badPortsSet = new Set(badPorts)
// https://w3c.github.io/webappsec-referrer-policy/#referrer-policies
const referrerPolicy = [
'',
@ -20960,10 +21020,12 @@ const referrerPolicy = [
'strict-origin-when-cross-origin',
'unsafe-url'
]
const referrerPolicySet = new Set(referrerPolicy)
const requestRedirect = ['follow', 'manual', 'error']
const safeMethods = ['GET', 'HEAD', 'OPTIONS', 'TRACE']
const safeMethodsSet = new Set(safeMethods)
const requestMode = ['navigate', 'same-origin', 'no-cors', 'cors']
@ -20998,6 +21060,7 @@ const requestDuplex = [
// http://fetch.spec.whatwg.org/#forbidden-method
const forbiddenMethods = ['CONNECT', 'TRACE', 'TRACK']
const forbiddenMethodsSet = new Set(forbiddenMethods)
const subresource = [
'audio',
@ -21013,6 +21076,7 @@ const subresource = [
'xslt',
''
]
const subresourceSet = new Set(subresource)
/** @type {globalThis['DOMException']} */
const DOMException = globalThis.DOMException ?? (() => {
@ -21062,7 +21126,14 @@ module.exports = {
nullBodyStatus,
safeMethods,
badPorts,
requestDuplex
requestDuplex,
subresourceSet,
badPortsSet,
redirectStatusSet,
corsSafeListedMethodsSet,
safeMethodsSet,
forbiddenMethodsSet,
referrerPolicySet
}
@ -21718,6 +21789,7 @@ const { isBlobLike } = __nccwpck_require__(2538)
const { webidl } = __nccwpck_require__(1744)
const { parseMIMEType, serializeAMimeType } = __nccwpck_require__(685)
const { kEnumerableProperty } = __nccwpck_require__(3983)
const encoder = new TextEncoder()
class File extends Blob {
constructor (fileBits, fileName, options = {}) {
@ -21991,7 +22063,7 @@ function processBlobParts (parts, options) {
}
// 3. Append the result of UTF-8 encoding s to bytes.
bytes.push(new TextEncoder().encode(s))
bytes.push(encoder.encode(s))
} else if (
types.isAnyArrayBuffer(element) ||
types.isTypedArray(element)
@ -22989,11 +23061,11 @@ const { kState, kHeaders, kGuard, kRealm } = __nccwpck_require__(5861)
const assert = __nccwpck_require__(9491)
const { safelyExtractBody } = __nccwpck_require__(1472)
const {
redirectStatus,
redirectStatusSet,
nullBodyStatus,
safeMethods,
safeMethodsSet,
requestBodyHeader,
subresource,
subresourceSet,
DOMException
} = __nccwpck_require__(1037)
const { kHeadersList } = __nccwpck_require__(2785)
@ -23005,6 +23077,7 @@ const { TransformStream } = __nccwpck_require__(5356)
const { getGlobalDispatcher } = __nccwpck_require__(1892)
const { webidl } = __nccwpck_require__(1744)
const { STATUS_CODES } = __nccwpck_require__(3685)
const GET_OR_HEAD = ['GET', 'HEAD']
/** @type {import('buffer').resolveObjectURL} */
let resolveObjectURL
@ -23064,7 +23137,7 @@ class Fetch extends EE {
}
// https://fetch.spec.whatwg.org/#fetch-method
async function fetch (input, init = {}) {
function fetch (input, init = {}) {
webidl.argumentLengthCheck(arguments, 1, { header: 'globalThis.fetch' })
// 1. Let p be a new promise.
@ -23147,7 +23220,7 @@ async function fetch (input, init = {}) {
const processResponse = (response) => {
// 1. If locallyAborted is true, terminate these substeps.
if (locallyAborted) {
return
return Promise.resolve()
}
// 2. If responses aborted flag is set, then:
@ -23160,7 +23233,7 @@ async function fetch (input, init = {}) {
// deserializedError.
abortFetch(p, request, responseObject, controller.serializedAbortReason)
return
return Promise.resolve()
}
// 3. If response is a network error, then reject p with a TypeError
@ -23169,7 +23242,7 @@ async function fetch (input, init = {}) {
p.reject(
Object.assign(new TypeError('fetch failed'), { cause: response.error })
)
return
return Promise.resolve()
}
// 4. Set responseObject to the result of creating a Response object,
@ -23452,7 +23525,7 @@ function fetching ({
}
// 15. If request is a subresource request, then:
if (subresource.includes(request.destination)) {
if (subresourceSet.has(request.destination)) {
// TODO
}
@ -23719,13 +23792,13 @@ async function mainFetch (fetchParams, recursive = false) {
// https://fetch.spec.whatwg.org/#concept-scheme-fetch
// given a fetch params fetchParams
async function schemeFetch (fetchParams) {
function schemeFetch (fetchParams) {
// Note: since the connection is destroyed on redirect, which sets fetchParams to a
// cancelled state, we do not want this condition to trigger *unless* there have been
// no redirects. See https://github.com/nodejs/undici/issues/1776
// 1. If fetchParams is canceled, then return the appropriate network error for fetchParams.
if (isCancelled(fetchParams) && fetchParams.request.redirectCount === 0) {
return makeAppropriateNetworkError(fetchParams)
return Promise.resolve(makeAppropriateNetworkError(fetchParams))
}
// 2. Let request be fetchParamss request.
@ -23741,7 +23814,7 @@ async function schemeFetch (fetchParams) {
// and body is the empty byte sequence as a body.
// Otherwise, return a network error.
return makeNetworkError('about scheme is not supported')
return Promise.resolve(makeNetworkError('about scheme is not supported'))
}
case 'blob:': {
if (!resolveObjectURL) {
@ -23754,7 +23827,7 @@ async function schemeFetch (fetchParams) {
// https://github.com/web-platform-tests/wpt/blob/7b0ebaccc62b566a1965396e5be7bb2bc06f841f/FileAPI/url/resources/fetch-tests.js#L52-L56
// Buffer.resolveObjectURL does not ignore URL queries.
if (blobURLEntry.search.length !== 0) {
return makeNetworkError('NetworkError when attempting to fetch resource.')
return Promise.resolve(makeNetworkError('NetworkError when attempting to fetch resource.'))
}
const blobURLEntryObject = resolveObjectURL(blobURLEntry.toString())
@ -23762,7 +23835,7 @@ async function schemeFetch (fetchParams) {
// 2. If requests method is not `GET`, blobURLEntry is null, or blobURLEntrys
// object is not a Blob object, then return a network error.
if (request.method !== 'GET' || !isBlobLike(blobURLEntryObject)) {
return makeNetworkError('invalid method')
return Promise.resolve(makeNetworkError('invalid method'))
}
// 3. Let bodyWithType be the result of safely extracting blobURLEntrys object.
@ -23789,7 +23862,7 @@ async function schemeFetch (fetchParams) {
response.body = body
return response
return Promise.resolve(response)
}
case 'data:': {
// 1. Let dataURLStruct be the result of running the
@ -23800,7 +23873,7 @@ async function schemeFetch (fetchParams) {
// 2. If dataURLStruct is failure, then return a
// network error.
if (dataURLStruct === 'failure') {
return makeNetworkError('failed to fetch the data URL')
return Promise.resolve(makeNetworkError('failed to fetch the data URL'))
}
// 3. Let mimeType be dataURLStructs MIME type, serialized.
@ -23809,28 +23882,28 @@ async function schemeFetch (fetchParams) {
// 4. Return a response whose status message is `OK`,
// header list is « (`Content-Type`, mimeType) »,
// and body is dataURLStructs body as a body.
return makeResponse({
return Promise.resolve(makeResponse({
statusText: 'OK',
headersList: [
['content-type', { name: 'Content-Type', value: mimeType }]
],
body: safelyExtractBody(dataURLStruct.body)[0]
})
}))
}
case 'file:': {
// For now, unfortunate as it is, file URLs are left as an exercise for the reader.
// When in doubt, return a network error.
return makeNetworkError('not implemented... yet...')
return Promise.resolve(makeNetworkError('not implemented... yet...'))
}
case 'http:':
case 'https:': {
// Return the result of running HTTP fetch given fetchParams.
return await httpFetch(fetchParams)
return httpFetch(fetchParams)
.catch((err) => makeNetworkError(err))
}
default: {
return makeNetworkError('unknown scheme')
return Promise.resolve(makeNetworkError('unknown scheme'))
}
}
}
@ -23849,7 +23922,7 @@ function finalizeResponse (fetchParams, response) {
}
// https://fetch.spec.whatwg.org/#fetch-finale
async function fetchFinale (fetchParams, response) {
function fetchFinale (fetchParams, response) {
// 1. If response is a network error, then:
if (response.type === 'error') {
// 1. Set responses URL list to « fetchParamss requests URL list[0] ».
@ -23933,8 +24006,9 @@ async function fetchFinale (fetchParams, response) {
} else {
// 4. Otherwise, fully read responses body given processBody, processBodyError,
// and fetchParamss task destination.
await fullyReadBody(response.body, processBody, processBodyError)
return fullyReadBody(response.body, processBody, processBodyError)
}
return Promise.resolve()
}
}
@ -24005,7 +24079,7 @@ async function httpFetch (fetchParams) {
}
// 8. If actualResponses status is a redirect status, then:
if (redirectStatus.includes(actualResponse.status)) {
if (redirectStatusSet.has(actualResponse.status)) {
// 1. If actualResponses status is not 303, requests body is not null,
// and the connection uses HTTP/2, then user agents may, and are even
// encouraged to, transmit an RST_STREAM frame.
@ -24042,7 +24116,7 @@ async function httpFetch (fetchParams) {
}
// https://fetch.spec.whatwg.org/#http-redirect-fetch
async function httpRedirectFetch (fetchParams, response) {
function httpRedirectFetch (fetchParams, response) {
// 1. Let request be fetchParamss request.
const request = fetchParams.request
@ -24068,18 +24142,18 @@ async function httpRedirectFetch (fetchParams, response) {
}
} catch (err) {
// 5. If locationURL is failure, then return a network error.
return makeNetworkError(err)
return Promise.resolve(makeNetworkError(err))
}
// 6. If locationURLs scheme is not an HTTP(S) scheme, then return a network
// error.
if (!urlIsHttpHttpsScheme(locationURL)) {
return makeNetworkError('URL scheme must be a HTTP(S) scheme')
return Promise.resolve(makeNetworkError('URL scheme must be a HTTP(S) scheme'))
}
// 7. If requests redirect count is 20, then return a network error.
if (request.redirectCount === 20) {
return makeNetworkError('redirect count exceeded')
return Promise.resolve(makeNetworkError('redirect count exceeded'))
}
// 8. Increase requests redirect count by 1.
@ -24093,7 +24167,7 @@ async function httpRedirectFetch (fetchParams, response) {
(locationURL.username || locationURL.password) &&
!sameOrigin(request, locationURL)
) {
return makeNetworkError('cross origin not allowed for request mode "cors"')
return Promise.resolve(makeNetworkError('cross origin not allowed for request mode "cors"'))
}
// 10. If requests response tainting is "cors" and locationURL includes
@ -24102,9 +24176,9 @@ async function httpRedirectFetch (fetchParams, response) {
request.responseTainting === 'cors' &&
(locationURL.username || locationURL.password)
) {
return makeNetworkError(
return Promise.resolve(makeNetworkError(
'URL cannot contain credentials for request mode "cors"'
)
))
}
// 11. If actualResponses status is not 303, requests body is non-null,
@ -24114,7 +24188,7 @@ async function httpRedirectFetch (fetchParams, response) {
request.body != null &&
request.body.source == null
) {
return makeNetworkError()
return Promise.resolve(makeNetworkError())
}
// 12. If one of the following is true
@ -24123,7 +24197,7 @@ async function httpRedirectFetch (fetchParams, response) {
if (
([301, 302].includes(actualResponse.status) && request.method === 'POST') ||
(actualResponse.status === 303 &&
!['GET', 'HEAD'].includes(request.method))
!GET_OR_HEAD.includes(request.method))
) {
// then:
// 1. Set requests method to `GET` and requests body to null.
@ -24407,7 +24481,7 @@ async function httpNetworkOrCacheFetch (
// responses in httpCache, as per the "Invalidation" chapter of HTTP
// Caching, and set storedResponse to null. [HTTP-CACHING]
if (
!safeMethods.includes(httpRequest.method) &&
!safeMethodsSet.has(httpRequest.method) &&
forwardResponse.status >= 200 &&
forwardResponse.status <= 399
) {
@ -24967,7 +25041,7 @@ async function httpNetworkFetch (
const willFollow = request.redirect === 'follow' &&
location &&
redirectStatus.includes(status)
redirectStatusSet.has(status)
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
if (request.method !== 'HEAD' && request.method !== 'CONNECT' && !nullBodyStatus.includes(status) && !willFollow) {
@ -25107,8 +25181,8 @@ const {
makePolicyContainer
} = __nccwpck_require__(2538)
const {
forbiddenMethods,
corsSafeListedMethods,
forbiddenMethodsSet,
corsSafeListedMethodsSet,
referrerPolicy,
requestRedirect,
requestMode,
@ -25413,7 +25487,7 @@ class Request {
throw TypeError(`'${init.method}' is not a valid HTTP method.`)
}
if (forbiddenMethods.indexOf(method.toUpperCase()) !== -1) {
if (forbiddenMethodsSet.has(method.toUpperCase())) {
throw TypeError(`'${init.method}' HTTP method is unsupported.`)
}
@ -25498,7 +25572,7 @@ class Request {
if (mode === 'no-cors') {
// 1. If thiss requests method is not a CORS-safelisted method,
// then throw a TypeError.
if (!corsSafeListedMethods.includes(request.method)) {
if (!corsSafeListedMethodsSet.has(request.method)) {
throw new TypeError(
`'${request.method} is unsupported in no-cors mode.`
)
@ -26060,7 +26134,7 @@ const {
isomorphicEncode
} = __nccwpck_require__(2538)
const {
redirectStatus,
redirectStatusSet,
nullBodyStatus,
DOMException
} = __nccwpck_require__(1037)
@ -26074,6 +26148,7 @@ const assert = __nccwpck_require__(9491)
const { types } = __nccwpck_require__(3837)
const ReadableStream = globalThis.ReadableStream || (__nccwpck_require__(5356).ReadableStream)
const textEncoder = new TextEncoder('utf-8')
// https://fetch.spec.whatwg.org/#response-class
class Response {
@ -26103,7 +26178,7 @@ class Response {
}
// 1. Let bytes the result of running serialize a JavaScript value to JSON bytes on data.
const bytes = new TextEncoder('utf-8').encode(
const bytes = textEncoder.encode(
serializeJavascriptValueToJSONString(data)
)
@ -26148,7 +26223,7 @@ class Response {
}
// 3. If status is not a redirect status, then throw a RangeError.
if (!redirectStatus.includes(status)) {
if (!redirectStatusSet.has(status)) {
throw new RangeError('Invalid status code ' + status)
}
@ -26646,7 +26721,7 @@ module.exports = {
"use strict";
const { redirectStatus, badPorts, referrerPolicy: referrerPolicyTokens } = __nccwpck_require__(1037)
const { redirectStatusSet, referrerPolicySet: referrerPolicyTokens, badPortsSet } = __nccwpck_require__(1037)
const { getGlobalOrigin } = __nccwpck_require__(1246)
const { performance } = __nccwpck_require__(4074)
const { isBlobLike, toUSVString, ReadableStreamFrom } = __nccwpck_require__(3983)
@ -26675,7 +26750,7 @@ function responseURL (response) {
// https://fetch.spec.whatwg.org/#concept-response-location-url
function responseLocationURL (response, requestFragment) {
// 1. If responses status is not a redirect status, then return null.
if (!redirectStatus.includes(response.status)) {
if (!redirectStatusSet.has(response.status)) {
return null
}
@ -26710,7 +26785,7 @@ function requestBadPort (request) {
// 2. If urls scheme is an HTTP(S) scheme and urls port is a bad port,
// then return blocked.
if (urlIsHttpHttpsScheme(url) && badPorts.includes(url.port)) {
if (urlIsHttpHttpsScheme(url) && badPortsSet.has(url.port)) {
return 'blocked'
}
@ -26852,7 +26927,7 @@ function setRequestReferrerPolicyOnRedirect (request, actualResponse) {
// The left-most policy is the fallback.
for (let i = policyHeader.length; i !== 0; i--) {
const token = policyHeader[i - 1].trim()
if (referrerPolicyTokens.includes(token)) {
if (referrerPolicyTokens.has(token)) {
policy = token
break
}
@ -31621,7 +31696,7 @@ class Pool extends PoolBase {
maxCachedSessions,
allowH2,
socketPath,
timeout: connectTimeout == null ? 10e3 : connectTimeout,
timeout: connectTimeout,
...(util.nodeHasAutoSelectFamily && autoSelectFamily ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : undefined),
...connect
})

2
dist/index.js.map сгенерированный поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

154
package-lock.json сгенерированный
Просмотреть файл

@ -618,9 +618,9 @@
}
},
"node_modules/@eslint-community/regexpp": {
"version": "4.9.1",
"resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.9.1.tgz",
"integrity": "sha512-Y27x+MBLjXa+0JWDhykM3+JE+il3kHKAEqabfEWq3SDhZjLYb6/BHL/JKFnH3fe207JaXkyDo685Oc2Glt6ifA==",
"version": "4.10.0",
"resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz",
"integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==",
"dev": true,
"engines": {
"node": "^12.0.0 || ^14.0.0 || >=16.0.0"
@ -1501,9 +1501,9 @@
"dev": true
},
"node_modules/@jridgewell/trace-mapping": {
"version": "0.3.19",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.19.tgz",
"integrity": "sha512-kf37QtfW+Hwx/buWGMPcR60iF9ziHa6r/CZJIHbmcm4+0qrXiVdxegAH0F6yddEVQ7zdkjcGCgCzUu+BcbhQxw==",
"version": "0.3.20",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz",
"integrity": "sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==",
"dev": true,
"dependencies": {
"@jridgewell/resolve-uri": "^3.1.0",
@ -1671,9 +1671,9 @@
}
},
"node_modules/@types/babel__core": {
"version": "7.20.2",
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.2.tgz",
"integrity": "sha512-pNpr1T1xLUc2l3xJKuPtsEky3ybxN3m4fJkknfIpTCTfIZCDW57oAg+EfCgIIp2rvCe0Wn++/FfodDS4YXxBwA==",
"version": "7.20.4",
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.4.tgz",
"integrity": "sha512-mLnSC22IC4vcWiuObSRjrLd9XcBTGf59vUSoq2jkQDJ/QQ8PMI9rSuzE+aEV8karUMbskw07bKYoUJCKTUaygg==",
"dev": true,
"dependencies": {
"@babel/parser": "^7.20.7",
@ -1684,18 +1684,18 @@
}
},
"node_modules/@types/babel__generator": {
"version": "7.6.5",
"resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.5.tgz",
"integrity": "sha512-h9yIuWbJKdOPLJTbmSpPzkF67e659PbQDba7ifWm5BJ8xTv+sDmS7rFmywkWOvXedGTivCdeGSIIX8WLcRTz8w==",
"version": "7.6.7",
"resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.7.tgz",
"integrity": "sha512-6Sfsq+EaaLrw4RmdFWE9Onp63TOUue71AWb4Gpa6JxzgTYtimbM086WnYTy2U67AofR++QKCo08ZP6pwx8YFHQ==",
"dev": true,
"dependencies": {
"@babel/types": "^7.0.0"
}
},
"node_modules/@types/babel__template": {
"version": "7.4.2",
"resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.2.tgz",
"integrity": "sha512-/AVzPICMhMOMYoSx9MoKpGDKdBRsIXMNByh1PXSZoa+v6ZoLa8xxtsT/uLQ/NJm0XVAWl/BvId4MlDeXJaeIZQ==",
"version": "7.4.4",
"resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz",
"integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==",
"dev": true,
"dependencies": {
"@babel/parser": "^7.1.0",
@ -1703,75 +1703,75 @@
}
},
"node_modules/@types/babel__traverse": {
"version": "7.20.2",
"resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.2.tgz",
"integrity": "sha512-ojlGK1Hsfce93J0+kn3H5R73elidKUaZonirN33GSmgTUMpzI/MIFfSpF3haANe3G1bEBS9/9/QEqwTzwqFsKw==",
"version": "7.20.4",
"resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.4.tgz",
"integrity": "sha512-mSM/iKUk5fDDrEV/e83qY+Cr3I1+Q3qqTuEn++HAWYjEa1+NxZr6CNrcJGf2ZTnq4HoFGC3zaTPZTobCzCFukA==",
"dev": true,
"dependencies": {
"@babel/types": "^7.20.7"
}
},
"node_modules/@types/graceful-fs": {
"version": "4.1.7",
"resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.7.tgz",
"integrity": "sha512-MhzcwU8aUygZroVwL2jeYk6JisJrPl/oov/gsgGCue9mkgl9wjGbzReYQClxiUgFDnib9FuHqTndccKeZKxTRw==",
"version": "4.1.9",
"resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz",
"integrity": "sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==",
"dev": true,
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/istanbul-lib-coverage": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz",
"integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==",
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz",
"integrity": "sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==",
"dev": true
},
"node_modules/@types/istanbul-lib-report": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz",
"integrity": "sha512-gPQuzaPR5h/djlAv2apEG1HVOyj1IUs7GpfMZixU0/0KXT3pm64ylHuMUI1/Akh+sq/iikxg6Z2j+fcMDXaaTQ==",
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.3.tgz",
"integrity": "sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA==",
"dev": true,
"dependencies": {
"@types/istanbul-lib-coverage": "*"
}
},
"node_modules/@types/istanbul-reports": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.2.tgz",
"integrity": "sha512-kv43F9eb3Lhj+lr/Hn6OcLCs/sSM8bt+fIaP11rCYngfV6NVjzWXJ17owQtDQTL9tQ8WSLUrGsSJ6rJz0F1w1A==",
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.4.tgz",
"integrity": "sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ==",
"dev": true,
"dependencies": {
"@types/istanbul-lib-report": "*"
}
},
"node_modules/@types/node": {
"version": "20.8.6",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.6.tgz",
"integrity": "sha512-eWO4K2Ji70QzKUqRy6oyJWUeB7+g2cRagT3T/nxYibYcT4y2BDL8lqolRXjTHmkZCdJfIPaY73KbJAZmcryxTQ==",
"version": "20.9.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.0.tgz",
"integrity": "sha512-nekiGu2NDb1BcVofVcEKMIwzlx4NjHlcjhoxxKBNLtz15Y1z7MYf549DFvkHSId02Ax6kGwWntIBPC3l/JZcmw==",
"dev": true,
"dependencies": {
"undici-types": "~5.25.1"
"undici-types": "~5.26.4"
}
},
"node_modules/@types/stack-utils": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz",
"integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==",
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz",
"integrity": "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==",
"dev": true
},
"node_modules/@types/yargs": {
"version": "17.0.28",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.28.tgz",
"integrity": "sha512-N3e3fkS86hNhtk6BEnc0rj3zcehaxx8QWhCROJkqpl5Zaoi7nAic3jH8q94jVD3zu5LGk+PUB6KAiDmimYOEQw==",
"version": "17.0.31",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.31.tgz",
"integrity": "sha512-bocYSx4DI8TmdlvxqGpVNXOgCNR1Jj0gNPhhAY+iz1rgKDAaYrAYdFYnhDV1IFuiuVc9HkOwyDcFxaTElF3/wg==",
"dev": true,
"dependencies": {
"@types/yargs-parser": "*"
}
},
"node_modules/@types/yargs-parser": {
"version": "21.0.1",
"resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.1.tgz",
"integrity": "sha512-axdPBuLuEJt0c4yI5OZssC19K2Mq1uKdrfZBzuxLvaztgqUtFYZUNw7lETExPYJR9jdEoIg4mb7RQKRQzOkeGQ==",
"version": "21.0.3",
"resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.3.tgz",
"integrity": "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==",
"dev": true
},
"node_modules/@ungap/structured-clone": {
@ -2156,9 +2156,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001549",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001549.tgz",
"integrity": "sha512-qRp48dPYSCYaP+KurZLhDYdVE+yEyht/3NlmcJgVQ2VMGt6JL36ndQ/7rgspdZsJuxDPFIo/OzBT2+GmIJ53BA==",
"version": "1.0.30001561",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001561.tgz",
"integrity": "sha512-NTt0DNoKe958Q0BE0j0c1V9jbUzhBxHIEJy7asmGrpE0yG63KTV7PLHPnK2E1O9RsQrQ081I3NLuXGS6zht3cw==",
"dev": true,
"funding": [
{
@ -2463,9 +2463,9 @@
}
},
"node_modules/electron-to-chromium": {
"version": "1.4.554",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.554.tgz",
"integrity": "sha512-Q0umzPJjfBrrj8unkONTgbKQXzXRrH7sVV7D9ea2yBV3Oaogz991yhbpfvo2LMNkJItmruXTEzVpP9cp7vaIiQ==",
"version": "1.4.578",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.578.tgz",
"integrity": "sha512-V0ZhSu1BQZKfG0yNEL6Dadzik8E1vAzfpVOapdSiT9F6yapEJ3Bk+4tZ4SMPdWiUchCgnM/ByYtBzp5ntzDMIA==",
"dev": true
},
"node_modules/emittery": {
@ -2941,6 +2941,15 @@
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/function-bind": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
"dev": true,
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/gensync": {
"version": "1.0.0-beta.2",
"resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz",
@ -3033,15 +3042,6 @@
"integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==",
"dev": true
},
"node_modules/has": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.4.tgz",
"integrity": "sha512-qdSAmqLF6209RFj4VVItywPMbm3vWylknmB3nvNiUIs72xAimcM8nVYxYr7ncvZq5qzk9MKIZR8ijqD/1QuYjQ==",
"dev": true,
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/has-flag": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
@ -3051,6 +3051,18 @@
"node": ">=4"
}
},
"node_modules/hasown": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz",
"integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==",
"dev": true,
"dependencies": {
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/html-escaper": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz",
@ -3142,12 +3154,12 @@
"dev": true
},
"node_modules/is-core-module": {
"version": "2.13.0",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.0.tgz",
"integrity": "sha512-Z7dk6Qo8pOCp3l4tsX2C5ZVas4V+UxwQodwZhLopL91TX8UyyHEXafPcyoeeWuLrwzHcr3igO78wNLwHJHsMCQ==",
"version": "2.13.1",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz",
"integrity": "sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==",
"dev": true,
"dependencies": {
"has": "^1.0.3"
"hasown": "^2.0.0"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
@ -3237,9 +3249,9 @@
"dev": true
},
"node_modules/istanbul-lib-coverage": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz",
"integrity": "sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==",
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.1.tgz",
"integrity": "sha512-opCrKqbthmq3SKZ10mFMQG9dk3fTa3quaOLD35kJa5ejwZHd9xAr+kLuziiZz2cG32s4lMZxNdmdcEQnTDP4+g==",
"dev": true,
"engines": {
"node": ">=8"
@ -6008,9 +6020,9 @@
}
},
"node_modules/undici": {
"version": "5.26.3",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.26.3.tgz",
"integrity": "sha512-H7n2zmKEWgOllKkIUkLvFmsJQj062lSm3uA4EYApG8gLuiOM0/go9bIoC3HVaSnfg4xunowDE2i9p8drkXuvDw==",
"version": "5.27.2",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.27.2.tgz",
"integrity": "sha512-iS857PdOEy/y3wlM3yRp+6SNQQ6xU0mmZcwRSriqk+et/cwWAtwmIGf6WkoDN2EK/AMdCO/dfXzIwi+rFMrjjQ==",
"dependencies": {
"@fastify/busboy": "^2.0.0"
},
@ -6019,9 +6031,9 @@
}
},
"node_modules/undici-types": {
"version": "5.25.3",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.25.3.tgz",
"integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==",
"version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
"dev": true
},
"node_modules/universal-user-agent": {