5361 lines
625 KiB
Diff
5361 lines
625 KiB
Diff
|
Index: node-v16.20.2/deps/undici/src/README.md
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/README.md
|
|||
|
+++ node-v16.20.2/deps/undici/src/README.md
|
|||
|
@@ -407,7 +407,7 @@ Refs: https://fetch.spec.whatwg.org/#ato
|
|||
|
|
|||
|
## Workarounds
|
|||
|
|
|||
|
-### Network address family autoselection.
|
|||
|
+### Network address family autoselection.
|
|||
|
|
|||
|
If you experience problem when connecting to a remote server that is resolved by your DNS servers to a IPv6 (AAAA record)
|
|||
|
first, there are chances that your local router or ISP might have problem connecting to IPv6 networks. In that case
|
|||
|
Index: node-v16.20.2/deps/undici/src/docs/api/ProxyAgent.md
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/docs/api/ProxyAgent.md
|
|||
|
+++ node-v16.20.2/deps/undici/src/docs/api/ProxyAgent.md
|
|||
|
@@ -19,6 +19,7 @@ Extends: [`AgentOptions`](Agent.md#param
|
|||
|
* **uri** `string` (required) - It can be passed either by a string or a object containing `uri` as string.
|
|||
|
* **token** `string` (optional) - It can be passed by a string of token for authentication.
|
|||
|
* **auth** `string` (**deprecated**) - Use token.
|
|||
|
+* **clientFactory** `(origin: URL, opts: Object) => Dispatcher` - Default: `(origin, opts) => new Pool(origin, opts)`
|
|||
|
|
|||
|
Examples:
|
|||
|
|
|||
|
@@ -83,7 +84,8 @@ import { setGlobalDispatcher, request, P
|
|||
|
|
|||
|
const proxyAgent = new ProxyAgent({
|
|||
|
uri: 'my.proxy.server',
|
|||
|
- token: 'Bearer xxxx'
|
|||
|
+ // token: 'Bearer xxxx'
|
|||
|
+ token: `Basic ${Buffer.from('username:password').toString('base64')}`
|
|||
|
});
|
|||
|
setGlobalDispatcher(proxyAgent);
|
|||
|
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/api/api-stream.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/api/api-stream.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/api/api-stream.js
|
|||
|
@@ -1,12 +1,13 @@
|
|||
|
'use strict'
|
|||
|
|
|||
|
-const { finished } = require('stream')
|
|||
|
+const { finished, PassThrough } = require('stream')
|
|||
|
const {
|
|||
|
InvalidArgumentError,
|
|||
|
InvalidReturnValueError,
|
|||
|
RequestAbortedError
|
|||
|
} = require('../core/errors')
|
|||
|
const util = require('../core/util')
|
|||
|
+const { getResolveErrorBodyCallback } = require('./util')
|
|||
|
const { AsyncResource } = require('async_hooks')
|
|||
|
const { addSignal, removeSignal } = require('./abort-signal')
|
|||
|
|
|||
|
@@ -16,7 +17,7 @@ class StreamHandler extends AsyncResourc
|
|||
|
throw new InvalidArgumentError('invalid opts')
|
|||
|
}
|
|||
|
|
|||
|
- const { signal, method, opaque, body, onInfo, responseHeaders } = opts
|
|||
|
+ const { signal, method, opaque, body, onInfo, responseHeaders, throwOnError } = opts
|
|||
|
|
|||
|
try {
|
|||
|
if (typeof callback !== 'function') {
|
|||
|
@@ -57,6 +58,7 @@ class StreamHandler extends AsyncResourc
|
|||
|
this.trailers = null
|
|||
|
this.body = body
|
|||
|
this.onInfo = onInfo || null
|
|||
|
+ this.throwOnError = throwOnError || false
|
|||
|
|
|||
|
if (util.isStream(body)) {
|
|||
|
body.on('error', (err) => {
|
|||
|
@@ -76,52 +78,67 @@ class StreamHandler extends AsyncResourc
|
|||
|
this.context = context
|
|||
|
}
|
|||
|
|
|||
|
- onHeaders (statusCode, rawHeaders, resume) {
|
|||
|
- const { factory, opaque, context } = this
|
|||
|
+ onHeaders (statusCode, rawHeaders, resume, statusMessage) {
|
|||
|
+ const { factory, opaque, context, callback, responseHeaders } = this
|
|||
|
+
|
|||
|
+ const headers = responseHeaders === 'raw' ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders)
|
|||
|
|
|||
|
if (statusCode < 200) {
|
|||
|
if (this.onInfo) {
|
|||
|
- const headers = this.responseHeaders === 'raw' ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders)
|
|||
|
this.onInfo({ statusCode, headers })
|
|||
|
}
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
this.factory = null
|
|||
|
- const headers = this.responseHeaders === 'raw' ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders)
|
|||
|
- const res = this.runInAsyncScope(factory, null, {
|
|||
|
- statusCode,
|
|||
|
- headers,
|
|||
|
- opaque,
|
|||
|
- context
|
|||
|
- })
|
|||
|
-
|
|||
|
- if (
|
|||
|
- !res ||
|
|||
|
- typeof res.write !== 'function' ||
|
|||
|
- typeof res.end !== 'function' ||
|
|||
|
- typeof res.on !== 'function'
|
|||
|
- ) {
|
|||
|
- throw new InvalidReturnValueError('expected Writable')
|
|||
|
- }
|
|||
|
|
|||
|
- res.on('drain', resume)
|
|||
|
- // TODO: Avoid finished. It registers an unnecessary amount of listeners.
|
|||
|
- finished(res, { readable: false }, (err) => {
|
|||
|
- const { callback, res, opaque, trailers, abort } = this
|
|||
|
-
|
|||
|
- this.res = null
|
|||
|
- if (err || !res.readable) {
|
|||
|
- util.destroy(res, err)
|
|||
|
- }
|
|||
|
+ let res
|
|||
|
+
|
|||
|
+ if (this.throwOnError && statusCode >= 400) {
|
|||
|
+ const parsedHeaders = responseHeaders === 'raw' ? util.parseHeaders(rawHeaders) : headers
|
|||
|
+ const contentType = parsedHeaders['content-type']
|
|||
|
+ res = new PassThrough()
|
|||
|
|
|||
|
this.callback = null
|
|||
|
- this.runInAsyncScope(callback, null, err || null, { opaque, trailers })
|
|||
|
+ this.runInAsyncScope(getResolveErrorBodyCallback, null,
|
|||
|
+ { callback, body: res, contentType, statusCode, statusMessage, headers }
|
|||
|
+ )
|
|||
|
+ } else {
|
|||
|
+ res = this.runInAsyncScope(factory, null, {
|
|||
|
+ statusCode,
|
|||
|
+ headers,
|
|||
|
+ opaque,
|
|||
|
+ context
|
|||
|
+ })
|
|||
|
|
|||
|
- if (err) {
|
|||
|
- abort()
|
|||
|
- }
|
|||
|
- })
|
|||
|
+ if (
|
|||
|
+ !res ||
|
|||
|
+ typeof res.write !== 'function' ||
|
|||
|
+ typeof res.end !== 'function' ||
|
|||
|
+ typeof res.on !== 'function'
|
|||
|
+ ) {
|
|||
|
+ throw new InvalidReturnValueError('expected Writable')
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // TODO: Avoid finished. It registers an unnecessary amount of listeners.
|
|||
|
+ finished(res, { readable: false }, (err) => {
|
|||
|
+ const { callback, res, opaque, trailers, abort } = this
|
|||
|
+
|
|||
|
+ this.res = null
|
|||
|
+ if (err || !res.readable) {
|
|||
|
+ util.destroy(res, err)
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ this.callback = null
|
|||
|
+ this.runInAsyncScope(callback, null, err || null, { opaque, trailers })
|
|||
|
+
|
|||
|
+ if (err) {
|
|||
|
+ abort()
|
|||
|
+ }
|
|||
|
+ })
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ res.on('drain', resume)
|
|||
|
|
|||
|
this.res = res
|
|||
|
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/api/readable.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/api/readable.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/api/readable.js
|
|||
|
@@ -4,7 +4,7 @@
|
|||
|
|
|||
|
const assert = require('assert')
|
|||
|
const { Readable } = require('stream')
|
|||
|
-const { RequestAbortedError, NotSupportedError } = require('../core/errors')
|
|||
|
+const { RequestAbortedError, NotSupportedError, InvalidArgumentError } = require('../core/errors')
|
|||
|
const util = require('../core/util')
|
|||
|
const { ReadableStreamFrom, toUSVString } = require('../core/util')
|
|||
|
|
|||
|
@@ -17,11 +17,16 @@ const kAbort = Symbol('abort')
|
|||
|
const kContentType = Symbol('kContentType')
|
|||
|
|
|||
|
module.exports = class BodyReadable extends Readable {
|
|||
|
- constructor (resume, abort, contentType = '') {
|
|||
|
+ constructor ({
|
|||
|
+ resume,
|
|||
|
+ abort,
|
|||
|
+ contentType = '',
|
|||
|
+ highWaterMark = 64 * 1024 // Same as nodejs fs streams.
|
|||
|
+ }) {
|
|||
|
super({
|
|||
|
autoDestroy: true,
|
|||
|
read: resume,
|
|||
|
- highWaterMark: 64 * 1024 // Same as nodejs fs streams.
|
|||
|
+ highWaterMark
|
|||
|
})
|
|||
|
|
|||
|
this._readableState.dataEmitted = false
|
|||
|
@@ -146,15 +151,31 @@ module.exports = class BodyReadable exte
|
|||
|
|
|||
|
async dump (opts) {
|
|||
|
let limit = opts && Number.isFinite(opts.limit) ? opts.limit : 262144
|
|||
|
+ const signal = opts && opts.signal
|
|||
|
+ const abortFn = () => {
|
|||
|
+ this.destroy()
|
|||
|
+ }
|
|||
|
+ if (signal) {
|
|||
|
+ if (typeof signal !== 'object' || !('aborted' in signal)) {
|
|||
|
+ throw new InvalidArgumentError('signal must be an AbortSignal')
|
|||
|
+ }
|
|||
|
+ util.throwIfAborted(signal)
|
|||
|
+ signal.addEventListener('abort', abortFn, { once: true })
|
|||
|
+ }
|
|||
|
try {
|
|||
|
for await (const chunk of this) {
|
|||
|
+ util.throwIfAborted(signal)
|
|||
|
limit -= Buffer.byteLength(chunk)
|
|||
|
if (limit < 0) {
|
|||
|
return
|
|||
|
}
|
|||
|
}
|
|||
|
} catch {
|
|||
|
- // Do nothing...
|
|||
|
+ util.throwIfAborted(signal)
|
|||
|
+ } finally {
|
|||
|
+ if (signal) {
|
|||
|
+ signal.removeEventListener('abort', abortFn)
|
|||
|
+ }
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/client.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/client.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/client.js
|
|||
|
@@ -1,3 +1,5 @@
|
|||
|
+// @ts-check
|
|||
|
+
|
|||
|
'use strict'
|
|||
|
|
|||
|
/* global WebAssembly */
|
|||
|
@@ -19,7 +21,8 @@ const {
|
|||
|
InformationalError,
|
|||
|
BodyTimeoutError,
|
|||
|
HTTPParserError,
|
|||
|
- ResponseExceededMaxSizeError
|
|||
|
+ ResponseExceededMaxSizeError,
|
|||
|
+ ClientDestroyedError
|
|||
|
} = require('./core/errors')
|
|||
|
const buildConnector = require('./core/connect')
|
|||
|
const {
|
|||
|
@@ -85,7 +88,15 @@ try {
|
|||
|
channels.connected = { hasSubscribers: false }
|
|||
|
}
|
|||
|
|
|||
|
+/**
|
|||
|
+ * @type {import('../types/client').default}
|
|||
|
+ */
|
|||
|
class Client extends DispatcherBase {
|
|||
|
+ /**
|
|||
|
+ *
|
|||
|
+ * @param {string|URL} url
|
|||
|
+ * @param {import('../types/client').Client.Options} options
|
|||
|
+ */
|
|||
|
constructor (url, {
|
|||
|
interceptors,
|
|||
|
maxHeaderSize,
|
|||
|
@@ -310,7 +321,7 @@ class Client extends DispatcherBase {
|
|||
|
async [kClose] () {
|
|||
|
return new Promise((resolve) => {
|
|||
|
if (!this[kSize]) {
|
|||
|
- this.destroy(resolve)
|
|||
|
+ resolve(null)
|
|||
|
} else {
|
|||
|
this[kClosedResolve] = resolve
|
|||
|
}
|
|||
|
@@ -327,6 +338,7 @@ class Client extends DispatcherBase {
|
|||
|
|
|||
|
const callback = () => {
|
|||
|
if (this[kClosedResolve]) {
|
|||
|
+ // TODO (fix): Should we error here with ClientDestroyedError?
|
|||
|
this[kClosedResolve]()
|
|||
|
this[kClosedResolve] = null
|
|||
|
}
|
|||
|
@@ -349,11 +361,11 @@ const createRedirectInterceptor = requir
|
|||
|
const EMPTY_BUF = Buffer.alloc(0)
|
|||
|
|
|||
|
async function lazyllhttp () {
|
|||
|
- const llhttpWasmData = process.env.JEST_WORKER_ID ? require('./llhttp/llhttp.wasm.js') : undefined
|
|||
|
+ const llhttpWasmData = process.env.JEST_WORKER_ID ? require('./llhttp/llhttp-wasm.js') : undefined
|
|||
|
|
|||
|
let mod
|
|||
|
try {
|
|||
|
- mod = await WebAssembly.compile(Buffer.from(require('./llhttp/llhttp_simd.wasm.js'), 'base64'))
|
|||
|
+ mod = await WebAssembly.compile(Buffer.from(require('./llhttp/llhttp_simd-wasm.js'), 'base64'))
|
|||
|
} catch (e) {
|
|||
|
/* istanbul ignore next */
|
|||
|
|
|||
|
@@ -361,7 +373,7 @@ async function lazyllhttp () {
|
|||
|
// being enabled, but the occurring of this other error
|
|||
|
// * https://github.com/emscripten-core/emscripten/issues/11495
|
|||
|
// got me to remove that check to avoid breaking Node 12.
|
|||
|
- mod = await WebAssembly.compile(Buffer.from(llhttpWasmData || require('./llhttp/llhttp.wasm.js'), 'base64'))
|
|||
|
+ mod = await WebAssembly.compile(Buffer.from(llhttpWasmData || require('./llhttp/llhttp-wasm.js'), 'base64'))
|
|||
|
}
|
|||
|
|
|||
|
return await WebAssembly.instantiate(mod, {
|
|||
|
@@ -557,7 +569,10 @@ class Parser {
|
|||
|
/* istanbul ignore else: difficult to make a test case for */
|
|||
|
if (ptr) {
|
|||
|
const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0)
|
|||
|
- message = Buffer.from(llhttp.memory.buffer, ptr, len).toString()
|
|||
|
+ message =
|
|||
|
+ 'Response does not match the HTTP/1.1 protocol (' +
|
|||
|
+ Buffer.from(llhttp.memory.buffer, ptr, len).toString() +
|
|||
|
+ ')'
|
|||
|
}
|
|||
|
throw new HTTPParserError(message, constants.ERROR[ret], data.slice(offset))
|
|||
|
}
|
|||
|
@@ -1072,6 +1087,11 @@ async function connect (client) {
|
|||
|
})
|
|||
|
})
|
|||
|
|
|||
|
+ if (client.destroyed) {
|
|||
|
+ util.destroy(socket.on('error', () => {}), new ClientDestroyedError())
|
|||
|
+ return
|
|||
|
+ }
|
|||
|
+
|
|||
|
if (!llhttpInstance) {
|
|||
|
llhttpInstance = await llhttpPromise
|
|||
|
llhttpPromise = null
|
|||
|
@@ -1114,6 +1134,10 @@ async function connect (client) {
|
|||
|
}
|
|||
|
client.emit('connect', client[kUrl], [client])
|
|||
|
} catch (err) {
|
|||
|
+ if (client.destroyed) {
|
|||
|
+ return
|
|||
|
+ }
|
|||
|
+
|
|||
|
client[kConnecting] = false
|
|||
|
|
|||
|
if (channels.connectError.hasSubscribers) {
|
|||
|
@@ -1176,8 +1200,9 @@ function _resume (client, sync) {
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
- if (client.closed && !client[kSize]) {
|
|||
|
- client.destroy()
|
|||
|
+ if (client[kClosedResolve] && !client[kSize]) {
|
|||
|
+ client[kClosedResolve]()
|
|||
|
+ client[kClosedResolve] = null
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
@@ -1429,17 +1454,17 @@ function write (client, request) {
|
|||
|
/* istanbul ignore else: assertion */
|
|||
|
if (!body) {
|
|||
|
if (contentLength === 0) {
|
|||
|
- socket.write(`${header}content-length: 0\r\n\r\n`, 'ascii')
|
|||
|
+ socket.write(`${header}content-length: 0\r\n\r\n`, 'latin1')
|
|||
|
} else {
|
|||
|
assert(contentLength === null, 'no body must not have content length')
|
|||
|
- socket.write(`${header}\r\n`, 'ascii')
|
|||
|
+ socket.write(`${header}\r\n`, 'latin1')
|
|||
|
}
|
|||
|
request.onRequestSent()
|
|||
|
} else if (util.isBuffer(body)) {
|
|||
|
assert(contentLength === body.byteLength, 'buffer body must have content length')
|
|||
|
|
|||
|
socket.cork()
|
|||
|
- socket.write(`${header}content-length: ${contentLength}\r\n\r\n`, 'ascii')
|
|||
|
+ socket.write(`${header}content-length: ${contentLength}\r\n\r\n`, 'latin1')
|
|||
|
socket.write(body)
|
|||
|
socket.uncork()
|
|||
|
request.onBodySent(body)
|
|||
|
@@ -1472,9 +1497,11 @@ function writeStream ({ body, client, re
|
|||
|
const writer = new AsyncWriter({ socket, request, contentLength, client, expectsPayload, header })
|
|||
|
|
|||
|
const onData = function (chunk) {
|
|||
|
- try {
|
|||
|
- assert(!finished)
|
|||
|
+ if (finished) {
|
|||
|
+ return
|
|||
|
+ }
|
|||
|
|
|||
|
+ try {
|
|||
|
if (!writer.write(chunk) && this.pause) {
|
|||
|
this.pause()
|
|||
|
}
|
|||
|
@@ -1483,7 +1510,9 @@ function writeStream ({ body, client, re
|
|||
|
}
|
|||
|
}
|
|||
|
const onDrain = function () {
|
|||
|
- assert(!finished)
|
|||
|
+ if (finished) {
|
|||
|
+ return
|
|||
|
+ }
|
|||
|
|
|||
|
if (body.resume) {
|
|||
|
body.resume()
|
|||
|
@@ -1554,7 +1583,7 @@ async function writeBlob ({ body, client
|
|||
|
const buffer = Buffer.from(await body.arrayBuffer())
|
|||
|
|
|||
|
socket.cork()
|
|||
|
- socket.write(`${header}content-length: ${contentLength}\r\n\r\n`, 'ascii')
|
|||
|
+ socket.write(`${header}content-length: ${contentLength}\r\n\r\n`, 'latin1')
|
|||
|
socket.write(buffer)
|
|||
|
socket.uncork()
|
|||
|
|
|||
|
@@ -1658,26 +1687,30 @@ class AsyncWriter {
|
|||
|
process.emitWarning(new RequestContentLengthMismatchError())
|
|||
|
}
|
|||
|
|
|||
|
+ socket.cork()
|
|||
|
+
|
|||
|
if (bytesWritten === 0) {
|
|||
|
if (!expectsPayload) {
|
|||
|
socket[kReset] = true
|
|||
|
}
|
|||
|
|
|||
|
if (contentLength === null) {
|
|||
|
- socket.write(`${header}transfer-encoding: chunked\r\n`, 'ascii')
|
|||
|
+ socket.write(`${header}transfer-encoding: chunked\r\n`, 'latin1')
|
|||
|
} else {
|
|||
|
- socket.write(`${header}content-length: ${contentLength}\r\n\r\n`, 'ascii')
|
|||
|
+ socket.write(`${header}content-length: ${contentLength}\r\n\r\n`, 'latin1')
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (contentLength === null) {
|
|||
|
- socket.write(`\r\n${len.toString(16)}\r\n`, 'ascii')
|
|||
|
+ socket.write(`\r\n${len.toString(16)}\r\n`, 'latin1')
|
|||
|
}
|
|||
|
|
|||
|
this.bytesWritten += len
|
|||
|
|
|||
|
const ret = socket.write(chunk)
|
|||
|
|
|||
|
+ socket.uncork()
|
|||
|
+
|
|||
|
request.onBodySent(chunk)
|
|||
|
|
|||
|
if (!ret) {
|
|||
|
@@ -1713,12 +1746,12 @@ class AsyncWriter {
|
|||
|
// no Transfer-Encoding is sent and the request method defines a meaning
|
|||
|
// for an enclosed payload body.
|
|||
|
|
|||
|
- socket.write(`${header}content-length: 0\r\n\r\n`, 'ascii')
|
|||
|
+ socket.write(`${header}content-length: 0\r\n\r\n`, 'latin1')
|
|||
|
} else {
|
|||
|
- socket.write(`${header}\r\n`, 'ascii')
|
|||
|
+ socket.write(`${header}\r\n`, 'latin1')
|
|||
|
}
|
|||
|
} else if (contentLength === null) {
|
|||
|
- socket.write('\r\n0\r\n\r\n', 'ascii')
|
|||
|
+ socket.write('\r\n0\r\n\r\n', 'latin1')
|
|||
|
}
|
|||
|
|
|||
|
if (contentLength !== null && bytesWritten !== contentLength) {
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/core/util.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/core/util.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/core/util.js
|
|||
|
@@ -15,7 +15,7 @@ const [nodeMajor, nodeMinor] = process.v
|
|||
|
function nop () {}
|
|||
|
|
|||
|
function isStream (obj) {
|
|||
|
- return obj && typeof obj.pipe === 'function'
|
|||
|
+ return obj && typeof obj === 'object' && typeof obj.pipe === 'function' && typeof obj.on === 'function'
|
|||
|
}
|
|||
|
|
|||
|
// based on https://github.com/node-fetch/fetch-blob/blob/8ab587d34080de94140b54f07168451e7d0b655e/index.js#L229-L241 (MIT License)
|
|||
|
@@ -46,34 +46,40 @@ function buildURL (url, queryParams) {
|
|||
|
function parseURL (url) {
|
|||
|
if (typeof url === 'string') {
|
|||
|
url = new URL(url)
|
|||
|
+
|
|||
|
+ if (!/^https?:/.test(url.origin || url.protocol)) {
|
|||
|
+ throw new InvalidArgumentError('Invalid URL protocol: the URL must start with `http:` or `https:`.')
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ return url
|
|||
|
}
|
|||
|
|
|||
|
if (!url || typeof url !== 'object') {
|
|||
|
- throw new InvalidArgumentError('invalid url')
|
|||
|
+ throw new InvalidArgumentError('Invalid URL: The URL argument must be a non-null object.')
|
|||
|
}
|
|||
|
|
|||
|
if (url.port != null && url.port !== '' && !Number.isFinite(parseInt(url.port))) {
|
|||
|
- throw new InvalidArgumentError('invalid port')
|
|||
|
+ throw new InvalidArgumentError('Invalid URL: port must be a valid integer or a string representation of an integer.')
|
|||
|
}
|
|||
|
|
|||
|
if (url.path != null && typeof url.path !== 'string') {
|
|||
|
- throw new InvalidArgumentError('invalid path')
|
|||
|
+ throw new InvalidArgumentError('Invalid URL path: the path must be a string or null/undefined.')
|
|||
|
}
|
|||
|
|
|||
|
if (url.pathname != null && typeof url.pathname !== 'string') {
|
|||
|
- throw new InvalidArgumentError('invalid pathname')
|
|||
|
+ throw new InvalidArgumentError('Invalid URL pathname: the pathname must be a string or null/undefined.')
|
|||
|
}
|
|||
|
|
|||
|
if (url.hostname != null && typeof url.hostname !== 'string') {
|
|||
|
- throw new InvalidArgumentError('invalid hostname')
|
|||
|
+ throw new InvalidArgumentError('Invalid URL hostname: the hostname must be a string or null/undefined.')
|
|||
|
}
|
|||
|
|
|||
|
if (url.origin != null && typeof url.origin !== 'string') {
|
|||
|
- throw new InvalidArgumentError('invalid origin')
|
|||
|
+ throw new InvalidArgumentError('Invalid URL origin: the origin must be a string or null/undefined.')
|
|||
|
}
|
|||
|
|
|||
|
if (!/^https?:/.test(url.origin || url.protocol)) {
|
|||
|
- throw new InvalidArgumentError('invalid protocol')
|
|||
|
+ throw new InvalidArgumentError('Invalid URL protocol: the URL must start with `http:` or `https:`.')
|
|||
|
}
|
|||
|
|
|||
|
if (!(url instanceof URL)) {
|
|||
|
@@ -216,40 +222,53 @@ function parseHeaders (headers, obj = {}
|
|||
|
const key = headers[i].toString().toLowerCase()
|
|||
|
let val = obj[key]
|
|||
|
|
|||
|
- const encoding = key.length === 19 && key === 'content-disposition'
|
|||
|
- ? 'latin1'
|
|||
|
- : 'utf8'
|
|||
|
-
|
|||
|
if (!val) {
|
|||
|
if (Array.isArray(headers[i + 1])) {
|
|||
|
obj[key] = headers[i + 1]
|
|||
|
} else {
|
|||
|
- obj[key] = headers[i + 1].toString(encoding)
|
|||
|
+ obj[key] = headers[i + 1].toString('utf8')
|
|||
|
}
|
|||
|
} else {
|
|||
|
if (!Array.isArray(val)) {
|
|||
|
val = [val]
|
|||
|
obj[key] = val
|
|||
|
}
|
|||
|
- val.push(headers[i + 1].toString(encoding))
|
|||
|
+ val.push(headers[i + 1].toString('utf8'))
|
|||
|
}
|
|||
|
}
|
|||
|
+
|
|||
|
+ // See https://github.com/nodejs/node/pull/46528
|
|||
|
+ if ('content-length' in obj && 'content-disposition' in obj) {
|
|||
|
+ obj['content-disposition'] = Buffer.from(obj['content-disposition']).toString('latin1')
|
|||
|
+ }
|
|||
|
+
|
|||
|
return obj
|
|||
|
}
|
|||
|
|
|||
|
function parseRawHeaders (headers) {
|
|||
|
const ret = []
|
|||
|
+ let hasContentLength = false
|
|||
|
+ let contentDispositionIdx = -1
|
|||
|
+
|
|||
|
for (let n = 0; n < headers.length; n += 2) {
|
|||
|
const key = headers[n + 0].toString()
|
|||
|
+ const val = headers[n + 1].toString('utf8')
|
|||
|
|
|||
|
- const encoding = key.length === 19 && key.toLowerCase() === 'content-disposition'
|
|||
|
- ? 'latin1'
|
|||
|
- : 'utf8'
|
|||
|
-
|
|||
|
- const val = headers[n + 1].toString(encoding)
|
|||
|
+ if (key.length === 14 && (key === 'content-length' || key.toLowerCase() === 'content-length')) {
|
|||
|
+ ret.push(key, val)
|
|||
|
+ hasContentLength = true
|
|||
|
+ } else if (key.length === 19 && (key === 'content-disposition' || key.toLowerCase() === 'content-disposition')) {
|
|||
|
+ contentDispositionIdx = ret.push(key, val) - 1
|
|||
|
+ } else {
|
|||
|
+ ret.push(key, val)
|
|||
|
+ }
|
|||
|
+ }
|
|||
|
|
|||
|
- ret.push(key, val)
|
|||
|
+ // See https://github.com/nodejs/node/pull/46528
|
|||
|
+ if (hasContentLength && contentDispositionIdx !== -1) {
|
|||
|
+ ret[contentDispositionIdx] = Buffer.from(ret[contentDispositionIdx]).toString('latin1')
|
|||
|
}
|
|||
|
+
|
|||
|
return ret
|
|||
|
}
|
|||
|
|
|||
|
@@ -375,23 +394,49 @@ function ReadableStreamFrom (iterable) {
|
|||
|
|
|||
|
// The chunk should be a FormData instance and contains
|
|||
|
// all the required methods.
|
|||
|
-function isFormDataLike (chunk) {
|
|||
|
- return (chunk &&
|
|||
|
- chunk.constructor && chunk.constructor.name === 'FormData' &&
|
|||
|
- typeof chunk === 'object' &&
|
|||
|
- (typeof chunk.append === 'function' &&
|
|||
|
- typeof chunk.delete === 'function' &&
|
|||
|
- typeof chunk.get === 'function' &&
|
|||
|
- typeof chunk.getAll === 'function' &&
|
|||
|
- typeof chunk.has === 'function' &&
|
|||
|
- typeof chunk.set === 'function' &&
|
|||
|
- typeof chunk.entries === 'function' &&
|
|||
|
- typeof chunk.keys === 'function' &&
|
|||
|
- typeof chunk.values === 'function' &&
|
|||
|
- typeof chunk.forEach === 'function')
|
|||
|
+function isFormDataLike (object) {
|
|||
|
+ return (
|
|||
|
+ object &&
|
|||
|
+ typeof object === 'object' &&
|
|||
|
+ typeof object.append === 'function' &&
|
|||
|
+ typeof object.delete === 'function' &&
|
|||
|
+ typeof object.get === 'function' &&
|
|||
|
+ typeof object.getAll === 'function' &&
|
|||
|
+ typeof object.has === 'function' &&
|
|||
|
+ typeof object.set === 'function' &&
|
|||
|
+ object[Symbol.toStringTag] === 'FormData'
|
|||
|
)
|
|||
|
}
|
|||
|
|
|||
|
+function throwIfAborted (signal) {
|
|||
|
+ if (!signal) { return }
|
|||
|
+ if (typeof signal.throwIfAborted === 'function') {
|
|||
|
+ signal.throwIfAborted()
|
|||
|
+ } else {
|
|||
|
+ if (signal.aborted) {
|
|||
|
+ // DOMException not available < v17.0.0
|
|||
|
+ const err = new Error('The operation was aborted')
|
|||
|
+ err.name = 'AbortError'
|
|||
|
+ throw err
|
|||
|
+ }
|
|||
|
+ }
|
|||
|
+}
|
|||
|
+
|
|||
|
+const hasToWellFormed = !!String.prototype.toWellFormed
|
|||
|
+
|
|||
|
+/**
|
|||
|
+ * @param {string} val
|
|||
|
+ */
|
|||
|
+function toUSVString (val) {
|
|||
|
+ if (hasToWellFormed) {
|
|||
|
+ return `${val}`.toWellFormed()
|
|||
|
+ } else if (nodeUtil.toUSVString) {
|
|||
|
+ return nodeUtil.toUSVString(val)
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ return `${val}`
|
|||
|
+}
|
|||
|
+
|
|||
|
const kEnumerableProperty = Object.create(null)
|
|||
|
kEnumerableProperty.enumerable = true
|
|||
|
|
|||
|
@@ -401,7 +446,7 @@ module.exports = {
|
|||
|
isDisturbed,
|
|||
|
isErrored,
|
|||
|
isReadable,
|
|||
|
- toUSVString: nodeUtil.toUSVString || ((val) => `${val}`),
|
|||
|
+ toUSVString,
|
|||
|
isReadableAborted,
|
|||
|
isBlobLike,
|
|||
|
parseOrigin,
|
|||
|
@@ -423,6 +468,7 @@ module.exports = {
|
|||
|
getSocketInfo,
|
|||
|
isFormDataLike,
|
|||
|
buildURL,
|
|||
|
+ throwIfAborted,
|
|||
|
nodeMajor,
|
|||
|
nodeMinor,
|
|||
|
nodeHasAutoSelectFamily: nodeMajor > 18 || (nodeMajor === 18 && nodeMinor >= 13)
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/fetch/dataURL.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/fetch/dataURL.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/fetch/dataURL.js
|
|||
|
@@ -1,15 +1,18 @@
|
|||
|
const assert = require('assert')
|
|||
|
const { atob } = require('buffer')
|
|||
|
-const { format } = require('url')
|
|||
|
-const { isValidHTTPToken, isomorphicDecode } = require('./util')
|
|||
|
+const { isomorphicDecode } = require('./util')
|
|||
|
|
|||
|
const encoder = new TextEncoder()
|
|||
|
|
|||
|
-// Regex
|
|||
|
-const HTTP_TOKEN_CODEPOINTS = /^[!#$%&'*+-.^_|~A-z0-9]+$/
|
|||
|
+/**
|
|||
|
+ * @see https://mimesniff.spec.whatwg.org/#http-token-code-point
|
|||
|
+ */
|
|||
|
+const HTTP_TOKEN_CODEPOINTS = /^[!#$%&'*+-.^_|~A-Za-z0-9]+$/
|
|||
|
const HTTP_WHITESPACE_REGEX = /(\u000A|\u000D|\u0009|\u0020)/ // eslint-disable-line
|
|||
|
-// https://mimesniff.spec.whatwg.org/#http-quoted-string-token-code-point
|
|||
|
-const HTTP_QUOTED_STRING_TOKENS = /^(\u0009|\x{0020}-\x{007E}|\x{0080}-\x{00FF})+$/ // eslint-disable-line
|
|||
|
+/**
|
|||
|
+ * @see https://mimesniff.spec.whatwg.org/#http-quoted-string-token-code-point
|
|||
|
+ */
|
|||
|
+const HTTP_QUOTED_STRING_TOKENS = /[\u0009|\u0020-\u007E|\u0080-\u00FF]/ // eslint-disable-line
|
|||
|
|
|||
|
// https://fetch.spec.whatwg.org/#data-url-processor
|
|||
|
/** @param {URL} dataURL */
|
|||
|
@@ -39,14 +42,12 @@ function dataURLProcessor (dataURL) {
|
|||
|
|
|||
|
// 6. Strip leading and trailing ASCII whitespace
|
|||
|
// from mimeType.
|
|||
|
- // Note: This will only remove U+0020 SPACE code
|
|||
|
- // points, if any.
|
|||
|
// Undici implementation note: we need to store the
|
|||
|
// length because if the mimetype has spaces removed,
|
|||
|
// the wrong amount will be sliced from the input in
|
|||
|
// step #9
|
|||
|
const mimeTypeLength = mimeType.length
|
|||
|
- mimeType = mimeType.replace(/^(\u0020)+|(\u0020)+$/g, '')
|
|||
|
+ mimeType = removeASCIIWhitespace(mimeType, true, true)
|
|||
|
|
|||
|
// 7. If position is past the end of input, then
|
|||
|
// return failure
|
|||
|
@@ -118,7 +119,17 @@ function dataURLProcessor (dataURL) {
|
|||
|
* @param {boolean} excludeFragment
|
|||
|
*/
|
|||
|
function URLSerializer (url, excludeFragment = false) {
|
|||
|
- return format(url, { fragment: !excludeFragment })
|
|||
|
+ const href = url.href
|
|||
|
+
|
|||
|
+ if (!excludeFragment) {
|
|||
|
+ return href
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ const hash = href.lastIndexOf('#')
|
|||
|
+ if (hash === -1) {
|
|||
|
+ return href
|
|||
|
+ }
|
|||
|
+ return href.slice(0, hash)
|
|||
|
}
|
|||
|
|
|||
|
// https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points
|
|||
|
@@ -224,7 +235,7 @@ function percentDecode (input) {
|
|||
|
function parseMIMEType (input) {
|
|||
|
// 1. Remove any leading and trailing HTTP whitespace
|
|||
|
// from input.
|
|||
|
- input = input.trim()
|
|||
|
+ input = removeHTTPWhitespace(input, true, true)
|
|||
|
|
|||
|
// 2. Let position be a position variable for input,
|
|||
|
// initially pointing at the start of input.
|
|||
|
@@ -265,7 +276,7 @@ function parseMIMEType (input) {
|
|||
|
)
|
|||
|
|
|||
|
// 8. Remove any trailing HTTP whitespace from subtype.
|
|||
|
- subtype = subtype.trimEnd()
|
|||
|
+ subtype = removeHTTPWhitespace(subtype, false, true)
|
|||
|
|
|||
|
// 9. If subtype is the empty string or does not solely
|
|||
|
// contain HTTP token code points, then return failure.
|
|||
|
@@ -273,17 +284,20 @@ function parseMIMEType (input) {
|
|||
|
return 'failure'
|
|||
|
}
|
|||
|
|
|||
|
+ const typeLowercase = type.toLowerCase()
|
|||
|
+ const subtypeLowercase = subtype.toLowerCase()
|
|||
|
+
|
|||
|
// 10. Let mimeType be a new MIME type record whose type
|
|||
|
// is type, in ASCII lowercase, and subtype is subtype,
|
|||
|
// in ASCII lowercase.
|
|||
|
// https://mimesniff.spec.whatwg.org/#mime-type
|
|||
|
const mimeType = {
|
|||
|
- type: type.toLowerCase(),
|
|||
|
- subtype: subtype.toLowerCase(),
|
|||
|
+ type: typeLowercase,
|
|||
|
+ subtype: subtypeLowercase,
|
|||
|
/** @type {Map<string, string>} */
|
|||
|
parameters: new Map(),
|
|||
|
// https://mimesniff.spec.whatwg.org/#mime-type-essence
|
|||
|
- essence: `${type}/${subtype}`
|
|||
|
+ essence: `${typeLowercase}/${subtypeLowercase}`
|
|||
|
}
|
|||
|
|
|||
|
// 11. While position is not past the end of input:
|
|||
|
@@ -361,8 +375,7 @@ function parseMIMEType (input) {
|
|||
|
)
|
|||
|
|
|||
|
// 2. Remove any trailing HTTP whitespace from parameterValue.
|
|||
|
- // Note: it says "trailing" whitespace; leading is fine.
|
|||
|
- parameterValue = parameterValue.trimEnd()
|
|||
|
+ parameterValue = removeHTTPWhitespace(parameterValue, false, true)
|
|||
|
|
|||
|
// 3. If parameterValue is the empty string, then continue.
|
|||
|
if (parameterValue.length === 0) {
|
|||
|
@@ -379,7 +392,7 @@ function parseMIMEType (input) {
|
|||
|
if (
|
|||
|
parameterName.length !== 0 &&
|
|||
|
HTTP_TOKEN_CODEPOINTS.test(parameterName) &&
|
|||
|
- !HTTP_QUOTED_STRING_TOKENS.test(parameterValue) &&
|
|||
|
+ (parameterValue.length === 0 || HTTP_QUOTED_STRING_TOKENS.test(parameterValue)) &&
|
|||
|
!mimeType.parameters.has(parameterName)
|
|||
|
) {
|
|||
|
mimeType.parameters.set(parameterName, parameterValue)
|
|||
|
@@ -513,11 +526,11 @@ function collectAnHTTPQuotedString (inpu
|
|||
|
*/
|
|||
|
function serializeAMimeType (mimeType) {
|
|||
|
assert(mimeType !== 'failure')
|
|||
|
- const { type, subtype, parameters } = mimeType
|
|||
|
+ const { parameters, essence } = mimeType
|
|||
|
|
|||
|
// 1. Let serialization be the concatenation of mimeType’s
|
|||
|
// type, U+002F (/), and mimeType’s subtype.
|
|||
|
- let serialization = `${type}/${subtype}`
|
|||
|
+ let serialization = essence
|
|||
|
|
|||
|
// 2. For each name → value of mimeType’s parameters:
|
|||
|
for (let [name, value] of parameters.entries()) {
|
|||
|
@@ -532,7 +545,7 @@ function serializeAMimeType (mimeType) {
|
|||
|
|
|||
|
// 4. If value does not solely contain HTTP token code
|
|||
|
// points or value is the empty string, then:
|
|||
|
- if (!isValidHTTPToken(value)) {
|
|||
|
+ if (!HTTP_TOKEN_CODEPOINTS.test(value)) {
|
|||
|
// 1. Precede each occurence of U+0022 (") or
|
|||
|
// U+005C (\) in value with U+005C (\).
|
|||
|
value = value.replace(/(\\|")/g, '\\$1')
|
|||
|
@@ -552,6 +565,59 @@ function serializeAMimeType (mimeType) {
|
|||
|
return serialization
|
|||
|
}
|
|||
|
|
|||
|
+/**
|
|||
|
+ * @see https://fetch.spec.whatwg.org/#http-whitespace
|
|||
|
+ * @param {string} char
|
|||
|
+ */
|
|||
|
+function isHTTPWhiteSpace (char) {
|
|||
|
+ return char === '\r' || char === '\n' || char === '\t' || char === ' '
|
|||
|
+}
|
|||
|
+
|
|||
|
+/**
|
|||
|
+ * @see https://fetch.spec.whatwg.org/#http-whitespace
|
|||
|
+ * @param {string} str
|
|||
|
+ */
|
|||
|
+function removeHTTPWhitespace (str, leading = true, trailing = true) {
|
|||
|
+ let lead = 0
|
|||
|
+ let trail = str.length - 1
|
|||
|
+
|
|||
|
+ if (leading) {
|
|||
|
+ for (; lead < str.length && isHTTPWhiteSpace(str[lead]); lead++);
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ if (trailing) {
|
|||
|
+ for (; trail > 0 && isHTTPWhiteSpace(str[trail]); trail--);
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ return str.slice(lead, trail + 1)
|
|||
|
+}
|
|||
|
+
|
|||
|
+/**
|
|||
|
+ * @see https://infra.spec.whatwg.org/#ascii-whitespace
|
|||
|
+ * @param {string} char
|
|||
|
+ */
|
|||
|
+function isASCIIWhitespace (char) {
|
|||
|
+ return char === '\r' || char === '\n' || char === '\t' || char === '\f' || char === ' '
|
|||
|
+}
|
|||
|
+
|
|||
|
+/**
|
|||
|
+ * @see https://infra.spec.whatwg.org/#strip-leading-and-trailing-ascii-whitespace
|
|||
|
+ */
|
|||
|
+function removeASCIIWhitespace (str, leading = true, trailing = true) {
|
|||
|
+ let lead = 0
|
|||
|
+ let trail = str.length - 1
|
|||
|
+
|
|||
|
+ if (leading) {
|
|||
|
+ for (; lead < str.length && isASCIIWhitespace(str[lead]); lead++);
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ if (trailing) {
|
|||
|
+ for (; trail > 0 && isASCIIWhitespace(str[trail]); trail--);
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ return str.slice(lead, trail + 1)
|
|||
|
+}
|
|||
|
+
|
|||
|
module.exports = {
|
|||
|
dataURLProcessor,
|
|||
|
URLSerializer,
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/fetch/index.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/fetch/index.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/fetch/index.js
|
|||
|
@@ -37,9 +37,12 @@ const {
|
|||
|
isErrorLike,
|
|||
|
fullyReadBody,
|
|||
|
readableStreamClose,
|
|||
|
- isomorphicEncode
|
|||
|
+ isomorphicEncode,
|
|||
|
+ urlIsLocal,
|
|||
|
+ urlIsHttpHttpsScheme,
|
|||
|
+ urlHasHttpsScheme
|
|||
|
} = require('./util')
|
|||
|
-const { kState, kHeaders, kGuard, kRealm, kHeadersCaseInsensitive } = require('./symbols')
|
|||
|
+const { kState, kHeaders, kGuard, kRealm } = require('./symbols')
|
|||
|
const assert = require('assert')
|
|||
|
const { safelyExtractBody } = require('./body')
|
|||
|
const {
|
|||
|
@@ -272,7 +275,7 @@ function finalizeAndReportTiming (respon
|
|||
|
let cacheState = response.cacheState
|
|||
|
|
|||
|
// 6. If originalURL’s scheme is not an HTTP(S) scheme, then return.
|
|||
|
- if (!/^https?:/.test(originalURL.protocol)) {
|
|||
|
+ if (!urlIsHttpHttpsScheme(originalURL)) {
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
@@ -297,7 +300,7 @@ function finalizeAndReportTiming (respon
|
|||
|
// capability.
|
|||
|
// TODO: given global’s relevant settings object’s cross-origin isolated
|
|||
|
// capability?
|
|||
|
- response.timingInfo.endTime = coarsenedSharedCurrentTime()
|
|||
|
+ timingInfo.endTime = coarsenedSharedCurrentTime()
|
|||
|
|
|||
|
// 10. Set response’s timing info to timingInfo.
|
|||
|
response.timingInfo = timingInfo
|
|||
|
@@ -315,7 +318,7 @@ function finalizeAndReportTiming (respon
|
|||
|
|
|||
|
// https://w3c.github.io/resource-timing/#dfn-mark-resource-timing
|
|||
|
function markResourceTiming (timingInfo, originalURL, initiatorType, globalThis, cacheState) {
|
|||
|
- if (nodeMajor >= 18 && nodeMinor >= 2) {
|
|||
|
+ if (nodeMajor > 18 || (nodeMajor === 18 && nodeMinor >= 2)) {
|
|||
|
performance.markResourceTiming(timingInfo, originalURL, initiatorType, globalThis, cacheState)
|
|||
|
}
|
|||
|
}
|
|||
|
@@ -530,10 +533,7 @@ async function mainFetch (fetchParams, r
|
|||
|
|
|||
|
// 3. If request’s local-URLs-only flag is set and request’s current URL is
|
|||
|
// not local, then set response to a network error.
|
|||
|
- if (
|
|||
|
- request.localURLsOnly &&
|
|||
|
- !/^(about|blob|data):/.test(requestCurrentURL(request).protocol)
|
|||
|
- ) {
|
|||
|
+ if (request.localURLsOnly && !urlIsLocal(requestCurrentURL(request))) {
|
|||
|
response = makeNetworkError('local URLs only')
|
|||
|
}
|
|||
|
|
|||
|
@@ -623,7 +623,7 @@ async function mainFetch (fetchParams, r
|
|||
|
}
|
|||
|
|
|||
|
// request’s current URL’s scheme is not an HTTP(S) scheme
|
|||
|
- if (!/^https?:/.test(requestCurrentURL(request).protocol)) {
|
|||
|
+ if (!urlIsHttpHttpsScheme(requestCurrentURL(request))) {
|
|||
|
// Return a network error.
|
|||
|
return makeNetworkError('URL scheme must be a HTTP(S) scheme')
|
|||
|
}
|
|||
|
@@ -1130,7 +1130,7 @@ async function httpRedirectFetch (fetchP
|
|||
|
|
|||
|
// 6. If locationURL’s scheme is not an HTTP(S) scheme, then return a network
|
|||
|
// error.
|
|||
|
- if (!/^https?:/.test(locationURL.protocol)) {
|
|||
|
+ if (!urlIsHttpHttpsScheme(locationURL)) {
|
|||
|
return makeNetworkError('URL scheme must be a HTTP(S) scheme')
|
|||
|
}
|
|||
|
|
|||
|
@@ -1205,7 +1205,7 @@ async function httpRedirectFetch (fetchP
|
|||
|
// 14. If request’s body is non-null, then set request’s body to the first return
|
|||
|
// value of safely extracting request’s body’s source.
|
|||
|
if (request.body != null) {
|
|||
|
- assert(request.body.source)
|
|||
|
+ assert(request.body.source != null)
|
|||
|
request.body = safelyExtractBody(request.body.source)[0]
|
|||
|
}
|
|||
|
|
|||
|
@@ -1399,7 +1399,7 @@ async function httpNetworkOrCacheFetch (
|
|||
|
// header if httpRequest’s header list contains that header’s name.
|
|||
|
// TODO: https://github.com/whatwg/fetch/issues/1285#issuecomment-896560129
|
|||
|
if (!httpRequest.headersList.contains('accept-encoding')) {
|
|||
|
- if (/^https:/.test(requestCurrentURL(httpRequest).protocol)) {
|
|||
|
+ if (urlHasHttpsScheme(requestCurrentURL(httpRequest))) {
|
|||
|
httpRequest.headersList.append('accept-encoding', 'br, gzip, deflate')
|
|||
|
} else {
|
|||
|
httpRequest.headersList.append('accept-encoding', 'gzip, deflate')
|
|||
|
@@ -1845,6 +1845,7 @@ async function httpNetworkFetch (
|
|||
|
// 4. Set bytes to the result of handling content codings given
|
|||
|
// codings and bytes.
|
|||
|
let bytes
|
|||
|
+ let isFailure
|
|||
|
try {
|
|||
|
const { done, value } = await fetchParams.controller.next()
|
|||
|
|
|||
|
@@ -1859,6 +1860,10 @@ async function httpNetworkFetch (
|
|||
|
bytes = undefined
|
|||
|
} else {
|
|||
|
bytes = err
|
|||
|
+
|
|||
|
+ // err may be propagated from the result of calling readablestream.cancel,
|
|||
|
+ // which might not be an error. https://github.com/nodejs/undici/issues/2009
|
|||
|
+ isFailure = true
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
@@ -1878,7 +1883,7 @@ async function httpNetworkFetch (
|
|||
|
timingInfo.decodedBodySize += bytes?.byteLength ?? 0
|
|||
|
|
|||
|
// 6. If bytes is failure, then terminate fetchParams’s controller.
|
|||
|
- if (isErrorLike(bytes)) {
|
|||
|
+ if (isFailure) {
|
|||
|
fetchParams.controller.terminate(bytes)
|
|||
|
return
|
|||
|
}
|
|||
|
@@ -1945,7 +1950,7 @@ async function httpNetworkFetch (
|
|||
|
origin: url.origin,
|
|||
|
method: request.method,
|
|||
|
body: fetchParams.controller.dispatcher.isMockActive ? request.body && request.body.source : body,
|
|||
|
- headers: request.headersList[kHeadersCaseInsensitive],
|
|||
|
+ headers: request.headersList.entries,
|
|||
|
maxRedirections: 0,
|
|||
|
upgrade: request.mode === 'websocket' ? 'websocket' : undefined
|
|||
|
},
|
|||
|
@@ -1979,7 +1984,9 @@ async function httpNetworkFetch (
|
|||
|
const val = headersList[n + 1].toString('latin1')
|
|||
|
|
|||
|
if (key.toLowerCase() === 'content-encoding') {
|
|||
|
- codings = val.split(',').map((x) => x.trim())
|
|||
|
+ // https://www.rfc-editor.org/rfc/rfc7231#section-3.1.2.1
|
|||
|
+ // "All content-coding values are case-insensitive..."
|
|||
|
+ codings = val.toLowerCase().split(',').map((x) => x.trim())
|
|||
|
} else if (key.toLowerCase() === 'location') {
|
|||
|
location = val
|
|||
|
}
|
|||
|
@@ -1998,9 +2005,10 @@ async function httpNetworkFetch (
|
|||
|
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
|
|||
|
if (request.method !== 'HEAD' && request.method !== 'CONNECT' && !nullBodyStatus.includes(status) && !willFollow) {
|
|||
|
for (const coding of codings) {
|
|||
|
- if (/(x-)?gzip/.test(coding)) {
|
|||
|
+ // https://www.rfc-editor.org/rfc/rfc9112.html#section-7.2
|
|||
|
+ if (coding === 'x-gzip' || coding === 'gzip') {
|
|||
|
decoders.push(zlib.createGunzip())
|
|||
|
- } else if (/(x-)?deflate/.test(coding)) {
|
|||
|
+ } else if (coding === 'deflate') {
|
|||
|
decoders.push(zlib.createInflate())
|
|||
|
} else if (coding === 'br') {
|
|||
|
decoders.push(zlib.createBrotliDecompress())
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/fetch/request.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/fetch/request.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/fetch/request.js
|
|||
|
@@ -9,7 +9,8 @@ const util = require('../core/util')
|
|||
|
const {
|
|||
|
isValidHTTPToken,
|
|||
|
sameOrigin,
|
|||
|
- normalizeMethod
|
|||
|
+ normalizeMethod,
|
|||
|
+ makePolicyContainer
|
|||
|
} = require('./util')
|
|||
|
const {
|
|||
|
forbiddenMethods,
|
|||
|
@@ -28,11 +29,12 @@ const { getGlobalOrigin } = require('./g
|
|||
|
const { URLSerializer } = require('./dataURL')
|
|||
|
const { kHeadersList } = require('../core/symbols')
|
|||
|
const assert = require('assert')
|
|||
|
-const { setMaxListeners, getEventListeners, defaultMaxListeners } = require('events')
|
|||
|
+const { getMaxListeners, setMaxListeners, getEventListeners, defaultMaxListeners } = require('events')
|
|||
|
|
|||
|
let TransformStream = globalThis.TransformStream
|
|||
|
|
|||
|
const kInit = Symbol('init')
|
|||
|
+const kAbortController = Symbol('abortController')
|
|||
|
|
|||
|
const requestFinalizer = new FinalizationRegistry(({ signal, abort }) => {
|
|||
|
signal.removeEventListener('abort', abort)
|
|||
|
@@ -51,10 +53,14 @@ class Request {
|
|||
|
input = webidl.converters.RequestInfo(input)
|
|||
|
init = webidl.converters.RequestInit(init)
|
|||
|
|
|||
|
- // TODO
|
|||
|
+ // https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object
|
|||
|
this[kRealm] = {
|
|||
|
settingsObject: {
|
|||
|
- baseUrl: getGlobalOrigin()
|
|||
|
+ baseUrl: getGlobalOrigin(),
|
|||
|
+ get origin () {
|
|||
|
+ return this.baseUrl?.origin
|
|||
|
+ },
|
|||
|
+ policyContainer: makePolicyContainer()
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
@@ -123,12 +129,12 @@ class Request {
|
|||
|
}
|
|||
|
|
|||
|
// 10. If init["window"] exists and is non-null, then throw a TypeError.
|
|||
|
- if (init.window !== undefined && init.window != null) {
|
|||
|
+ if (init.window != null) {
|
|||
|
throw new TypeError(`'window' option '${window}' must be null`)
|
|||
|
}
|
|||
|
|
|||
|
// 11. If init["window"] exists, then set window to "no-window".
|
|||
|
- if (init.window !== undefined) {
|
|||
|
+ if ('window' in init) {
|
|||
|
window = 'no-window'
|
|||
|
}
|
|||
|
|
|||
|
@@ -349,17 +355,34 @@ class Request {
|
|||
|
if (signal.aborted) {
|
|||
|
ac.abort(signal.reason)
|
|||
|
} else {
|
|||
|
+ // Keep a strong ref to ac while request object
|
|||
|
+ // is alive. This is needed to prevent AbortController
|
|||
|
+ // from being prematurely garbage collected.
|
|||
|
+ // See, https://github.com/nodejs/undici/issues/1926.
|
|||
|
+ this[kAbortController] = ac
|
|||
|
+
|
|||
|
const acRef = new WeakRef(ac)
|
|||
|
const abort = function () {
|
|||
|
- acRef.deref()?.abort(this.reason)
|
|||
|
+ const ac = acRef.deref()
|
|||
|
+ if (ac !== undefined) {
|
|||
|
+ ac.abort(this.reason)
|
|||
|
+ }
|
|||
|
}
|
|||
|
|
|||
|
- if (getEventListeners(signal, 'abort').length >= defaultMaxListeners) {
|
|||
|
- setMaxListeners(100, signal)
|
|||
|
- }
|
|||
|
+ // Third-party AbortControllers may not work with these.
|
|||
|
+ // See, https://github.com/nodejs/undici/pull/1910#issuecomment-1464495619.
|
|||
|
+ try {
|
|||
|
+ // If the max amount of listeners is equal to the default, increase it
|
|||
|
+ // This is only available in node >= v19.9.0
|
|||
|
+ if (typeof getMaxListeners === 'function' && getMaxListeners(signal) === defaultMaxListeners) {
|
|||
|
+ setMaxListeners(100, signal)
|
|||
|
+ } else if (getEventListeners(signal, 'abort').length >= defaultMaxListeners) {
|
|||
|
+ setMaxListeners(100, signal)
|
|||
|
+ }
|
|||
|
+ } catch {}
|
|||
|
|
|||
|
signal.addEventListener('abort', abort, { once: true })
|
|||
|
- requestFinalizer.register(this, { signal, abort })
|
|||
|
+ requestFinalizer.register(ac, { signal, abort })
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
@@ -419,7 +442,7 @@ class Request {
|
|||
|
// non-null, and request’s method is `GET` or `HEAD`, then throw a
|
|||
|
// TypeError.
|
|||
|
if (
|
|||
|
- ((init.body !== undefined && init.body != null) || inputBody != null) &&
|
|||
|
+ (init.body != null || inputBody != null) &&
|
|||
|
(request.method === 'GET' || request.method === 'HEAD')
|
|||
|
) {
|
|||
|
throw new TypeError('Request with GET/HEAD method cannot have body.')
|
|||
|
@@ -429,7 +452,7 @@ class Request {
|
|||
|
let initBody = null
|
|||
|
|
|||
|
// 36. If init["body"] exists and is non-null, then:
|
|||
|
- if (init.body !== undefined && init.body != null) {
|
|||
|
+ if (init.body != null) {
|
|||
|
// 1. Let Content-Type be null.
|
|||
|
// 2. Set initBody and Content-Type to the result of extracting
|
|||
|
// init["body"], with keepalive set to request’s keepalive.
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/fetch/util.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/fetch/util.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/fetch/util.js
|
|||
|
@@ -1,6 +1,7 @@
|
|||
|
'use strict'
|
|||
|
|
|||
|
const { redirectStatus, badPorts, referrerPolicy: referrerPolicyTokens } = require('./constants')
|
|||
|
+const { getGlobalOrigin } = require('./global')
|
|||
|
const { performance } = require('perf_hooks')
|
|||
|
const { isBlobLike, toUSVString, ReadableStreamFrom } = require('../core/util')
|
|||
|
const assert = require('assert')
|
|||
|
@@ -36,9 +37,11 @@ function responseLocationURL (response,
|
|||
|
// `Location` and response’s header list.
|
|||
|
let location = response.headersList.get('location')
|
|||
|
|
|||
|
- // 3. If location is a value, then set location to the result of parsing
|
|||
|
- // location with response’s URL.
|
|||
|
- location = location ? new URL(location, responseURL(response)) : null
|
|||
|
+ // 3. If location is a header value, then set location to the result of
|
|||
|
+ // parsing location with response’s URL.
|
|||
|
+ if (location !== null && isValidHeaderValue(location)) {
|
|||
|
+ location = new URL(location, responseURL(response))
|
|||
|
+ }
|
|||
|
|
|||
|
// 4. If location is a URL whose fragment is null, then set location’s
|
|||
|
// fragment to requestFragment.
|
|||
|
@@ -61,7 +64,7 @@ function requestBadPort (request) {
|
|||
|
|
|||
|
// 2. If url’s scheme is an HTTP(S) scheme and url’s port is a bad port,
|
|||
|
// then return blocked.
|
|||
|
- if (/^https?:/.test(url.protocol) && badPorts.includes(url.port)) {
|
|||
|
+ if (urlIsHttpHttpsScheme(url) && badPorts.includes(url.port)) {
|
|||
|
return 'blocked'
|
|||
|
}
|
|||
|
|
|||
|
@@ -267,7 +270,7 @@ function appendRequestOriginHeader (requ
|
|||
|
// 2. If request’s response tainting is "cors" or request’s mode is "websocket", then append (`Origin`, serializedOrigin) to request’s header list.
|
|||
|
if (request.responseTainting === 'cors' || request.mode === 'websocket') {
|
|||
|
if (serializedOrigin) {
|
|||
|
- request.headersList.append('Origin', serializedOrigin)
|
|||
|
+ request.headersList.append('origin', serializedOrigin)
|
|||
|
}
|
|||
|
|
|||
|
// 3. Otherwise, if request’s method is neither `GET` nor `HEAD`, then:
|
|||
|
@@ -282,7 +285,7 @@ function appendRequestOriginHeader (requ
|
|||
|
case 'strict-origin':
|
|||
|
case 'strict-origin-when-cross-origin':
|
|||
|
// If request’s origin is a tuple origin, its scheme is "https", and request’s current URL’s scheme is not "https", then set serializedOrigin to `null`.
|
|||
|
- if (/^https:/.test(request.origin) && !/^https:/.test(requestCurrentURL(request))) {
|
|||
|
+ if (request.origin && urlHasHttpsScheme(request.origin) && !urlHasHttpsScheme(requestCurrentURL(request))) {
|
|||
|
serializedOrigin = null
|
|||
|
}
|
|||
|
break
|
|||
|
@@ -298,7 +301,7 @@ function appendRequestOriginHeader (requ
|
|||
|
|
|||
|
if (serializedOrigin) {
|
|||
|
// 2. Append (`Origin`, serializedOrigin) to request’s header list.
|
|||
|
- request.headersList.append('Origin', serializedOrigin)
|
|||
|
+ request.headersList.append('origin', serializedOrigin)
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
@@ -327,14 +330,17 @@ function createOpaqueTimingInfo (timingI
|
|||
|
|
|||
|
// https://html.spec.whatwg.org/multipage/origin.html#policy-container
|
|||
|
function makePolicyContainer () {
|
|||
|
- // TODO
|
|||
|
- return {}
|
|||
|
+ // Note: the fetch spec doesn't make use of embedder policy or CSP list
|
|||
|
+ return {
|
|||
|
+ referrerPolicy: 'strict-origin-when-cross-origin'
|
|||
|
+ }
|
|||
|
}
|
|||
|
|
|||
|
// https://html.spec.whatwg.org/multipage/origin.html#clone-a-policy-container
|
|||
|
-function clonePolicyContainer () {
|
|||
|
- // TODO
|
|||
|
- return {}
|
|||
|
+function clonePolicyContainer (policyContainer) {
|
|||
|
+ return {
|
|||
|
+ referrerPolicy: policyContainer.referrerPolicy
|
|||
|
+ }
|
|||
|
}
|
|||
|
|
|||
|
// https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer
|
|||
|
@@ -342,104 +348,76 @@ function determineRequestsReferrer (requ
|
|||
|
// 1. Let policy be request's referrer policy.
|
|||
|
const policy = request.referrerPolicy
|
|||
|
|
|||
|
- // Return no-referrer when empty or policy says so
|
|||
|
- if (policy == null || policy === '' || policy === 'no-referrer') {
|
|||
|
- return 'no-referrer'
|
|||
|
- }
|
|||
|
+ // Note: policy cannot (shouldn't) be null or an empty string.
|
|||
|
+ assert(policy)
|
|||
|
+
|
|||
|
+ // 2. Let environment be request’s client.
|
|||
|
|
|||
|
- // 2. Let environment be the request client
|
|||
|
- const environment = request.client
|
|||
|
let referrerSource = null
|
|||
|
|
|||
|
- /**
|
|||
|
- * 3, Switch on request’s referrer:
|
|||
|
- "client"
|
|||
|
- If environment’s global object is a Window object, then
|
|||
|
- Let document be the associated Document of environment’s global object.
|
|||
|
- If document’s origin is an opaque origin, return no referrer.
|
|||
|
- While document is an iframe srcdoc document,
|
|||
|
- let document be document’s browsing context’s browsing context container’s node document.
|
|||
|
- Let referrerSource be document’s URL.
|
|||
|
-
|
|||
|
- Otherwise, let referrerSource be environment’s creation URL.
|
|||
|
-
|
|||
|
- a URL
|
|||
|
- Let referrerSource be request’s referrer.
|
|||
|
- */
|
|||
|
+ // 3. Switch on request’s referrer:
|
|||
|
if (request.referrer === 'client') {
|
|||
|
- // Not defined in Node but part of the spec
|
|||
|
- if (request.client?.globalObject?.constructor?.name === 'Window' ) { // eslint-disable-line
|
|||
|
- const origin = environment.globalObject.self?.origin ?? environment.globalObject.location?.origin
|
|||
|
-
|
|||
|
- // If document’s origin is an opaque origin, return no referrer.
|
|||
|
- if (origin == null || origin === 'null') return 'no-referrer'
|
|||
|
-
|
|||
|
- // Let referrerSource be document’s URL.
|
|||
|
- referrerSource = new URL(environment.globalObject.location.href)
|
|||
|
- } else {
|
|||
|
- // 3(a)(II) If environment's global object is not Window,
|
|||
|
- // Let referrerSource be environments creationURL
|
|||
|
- if (environment?.globalObject?.location == null) {
|
|||
|
- return 'no-referrer'
|
|||
|
- }
|
|||
|
+ // Note: node isn't a browser and doesn't implement document/iframes,
|
|||
|
+ // so we bypass this step and replace it with our own.
|
|||
|
|
|||
|
- referrerSource = new URL(environment.globalObject.location.href)
|
|||
|
+ const globalOrigin = getGlobalOrigin()
|
|||
|
+
|
|||
|
+ if (!globalOrigin || globalOrigin.origin === 'null') {
|
|||
|
+ return 'no-referrer'
|
|||
|
}
|
|||
|
+
|
|||
|
+ // note: we need to clone it as it's mutated
|
|||
|
+ referrerSource = new URL(globalOrigin)
|
|||
|
} else if (request.referrer instanceof URL) {
|
|||
|
- // 3(b) If requests's referrer is a URL instance, then make
|
|||
|
- // referrerSource be requests's referrer.
|
|||
|
+ // Let referrerSource be request’s referrer.
|
|||
|
referrerSource = request.referrer
|
|||
|
- } else {
|
|||
|
- // If referrerSource neither client nor instance of URL
|
|||
|
- // then return "no-referrer".
|
|||
|
- return 'no-referrer'
|
|||
|
}
|
|||
|
|
|||
|
- const urlProtocol = referrerSource.protocol
|
|||
|
-
|
|||
|
- // If url's scheme is a local scheme (i.e. one of "about", "data", "javascript", "file")
|
|||
|
- // then return "no-referrer".
|
|||
|
- if (
|
|||
|
- urlProtocol === 'about:' || urlProtocol === 'data:' ||
|
|||
|
- urlProtocol === 'blob:'
|
|||
|
- ) {
|
|||
|
- return 'no-referrer'
|
|||
|
+ // 4. Let request’s referrerURL be the result of stripping referrerSource for
|
|||
|
+ // use as a referrer.
|
|||
|
+ let referrerURL = stripURLForReferrer(referrerSource)
|
|||
|
+
|
|||
|
+ // 5. Let referrerOrigin be the result of stripping referrerSource for use as
|
|||
|
+ // a referrer, with the origin-only flag set to true.
|
|||
|
+ const referrerOrigin = stripURLForReferrer(referrerSource, true)
|
|||
|
+
|
|||
|
+ // 6. If the result of serializing referrerURL is a string whose length is
|
|||
|
+ // greater than 4096, set referrerURL to referrerOrigin.
|
|||
|
+ if (referrerURL.toString().length > 4096) {
|
|||
|
+ referrerURL = referrerOrigin
|
|||
|
}
|
|||
|
|
|||
|
- let temp
|
|||
|
- let referrerOrigin
|
|||
|
- // 4. Let requests's referrerURL be the result of stripping referrer
|
|||
|
- // source for use as referrer (using util function, without origin only)
|
|||
|
- const referrerUrl = (temp = stripURLForReferrer(referrerSource)).length > 4096
|
|||
|
- // 5. Let referrerOrigin be the result of stripping referrer
|
|||
|
- // source for use as referrer (using util function, with originOnly true)
|
|||
|
- ? (referrerOrigin = stripURLForReferrer(referrerSource, true))
|
|||
|
- // 6. If result of seralizing referrerUrl is a string whose length is greater than
|
|||
|
- // 4096, then set referrerURL to referrerOrigin
|
|||
|
- : temp
|
|||
|
- const areSameOrigin = sameOrigin(request, referrerUrl)
|
|||
|
- const isNonPotentiallyTrustWorthy = isURLPotentiallyTrustworthy(referrerUrl) &&
|
|||
|
+ const areSameOrigin = sameOrigin(request, referrerURL)
|
|||
|
+ const isNonPotentiallyTrustWorthy = isURLPotentiallyTrustworthy(referrerURL) &&
|
|||
|
!isURLPotentiallyTrustworthy(request.url)
|
|||
|
|
|||
|
- // NOTE: How to treat step 7?
|
|||
|
// 8. Execute the switch statements corresponding to the value of policy:
|
|||
|
switch (policy) {
|
|||
|
case 'origin': return referrerOrigin != null ? referrerOrigin : stripURLForReferrer(referrerSource, true)
|
|||
|
- case 'unsafe-url': return referrerUrl
|
|||
|
+ case 'unsafe-url': return referrerURL
|
|||
|
case 'same-origin':
|
|||
|
return areSameOrigin ? referrerOrigin : 'no-referrer'
|
|||
|
case 'origin-when-cross-origin':
|
|||
|
- return areSameOrigin ? referrerUrl : referrerOrigin
|
|||
|
- case 'strict-origin-when-cross-origin':
|
|||
|
- /**
|
|||
|
- * 1. If the origin of referrerURL and the origin of request’s current URL are the same,
|
|||
|
- * then return referrerURL.
|
|||
|
- * 2. If referrerURL is a potentially trustworthy URL and request’s current URL is not a
|
|||
|
- * potentially trustworthy URL, then return no referrer.
|
|||
|
- * 3. Return referrerOrigin
|
|||
|
- */
|
|||
|
- if (areSameOrigin) return referrerOrigin
|
|||
|
- // else return isNonPotentiallyTrustWorthy ? 'no-referrer' : referrerOrigin
|
|||
|
+ return areSameOrigin ? referrerURL : referrerOrigin
|
|||
|
+ case 'strict-origin-when-cross-origin': {
|
|||
|
+ const currentURL = requestCurrentURL(request)
|
|||
|
+
|
|||
|
+ // 1. If the origin of referrerURL and the origin of request’s current
|
|||
|
+ // URL are the same, then return referrerURL.
|
|||
|
+ if (sameOrigin(referrerURL, currentURL)) {
|
|||
|
+ return referrerURL
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 2. If referrerURL is a potentially trustworthy URL and request’s
|
|||
|
+ // current URL is not a potentially trustworthy URL, then return no
|
|||
|
+ // referrer.
|
|||
|
+ if (isURLPotentiallyTrustworthy(referrerURL) && !isURLPotentiallyTrustworthy(currentURL)) {
|
|||
|
+ return 'no-referrer'
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 3. Return referrerOrigin.
|
|||
|
+ return referrerOrigin
|
|||
|
+ }
|
|||
|
case 'strict-origin': // eslint-disable-line
|
|||
|
/**
|
|||
|
* 1. If referrerURL is a potentially trustworthy URL and
|
|||
|
@@ -458,15 +436,42 @@ function determineRequestsReferrer (requ
|
|||
|
default: // eslint-disable-line
|
|||
|
return isNonPotentiallyTrustWorthy ? 'no-referrer' : referrerOrigin
|
|||
|
}
|
|||
|
+}
|
|||
|
+
|
|||
|
+/**
|
|||
|
+ * @see https://w3c.github.io/webappsec-referrer-policy/#strip-url
|
|||
|
+ * @param {URL} url
|
|||
|
+ * @param {boolean|undefined} originOnly
|
|||
|
+ */
|
|||
|
+function stripURLForReferrer (url, originOnly) {
|
|||
|
+ // 1. Assert: url is a URL.
|
|||
|
+ assert(url instanceof URL)
|
|||
|
+
|
|||
|
+ // 2. If url’s scheme is a local scheme, then return no referrer.
|
|||
|
+ if (url.protocol === 'file:' || url.protocol === 'about:' || url.protocol === 'blank:') {
|
|||
|
+ return 'no-referrer'
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 3. Set url’s username to the empty string.
|
|||
|
+ url.username = ''
|
|||
|
+
|
|||
|
+ // 4. Set url’s password to the empty string.
|
|||
|
+ url.password = ''
|
|||
|
+
|
|||
|
+ // 5. Set url’s fragment to null.
|
|||
|
+ url.hash = ''
|
|||
|
|
|||
|
- function stripURLForReferrer (url, originOnly = false) {
|
|||
|
- const urlObject = new URL(url.href)
|
|||
|
- urlObject.username = ''
|
|||
|
- urlObject.password = ''
|
|||
|
- urlObject.hash = ''
|
|||
|
+ // 6. If the origin-only flag is true, then:
|
|||
|
+ if (originOnly) {
|
|||
|
+ // 1. Set url’s path to « the empty string ».
|
|||
|
+ url.pathname = ''
|
|||
|
|
|||
|
- return originOnly ? urlObject.origin : urlObject.href
|
|||
|
+ // 2. Set url’s query to null.
|
|||
|
+ url.search = ''
|
|||
|
}
|
|||
|
+
|
|||
|
+ // 7. Return url.
|
|||
|
+ return url
|
|||
|
}
|
|||
|
|
|||
|
function isURLPotentiallyTrustworthy (url) {
|
|||
|
@@ -633,7 +638,9 @@ function tryUpgradeRequestToAPotentially
|
|||
|
*/
|
|||
|
function sameOrigin (A, B) {
|
|||
|
// 1. If A and B are the same opaque origin, then return true.
|
|||
|
- // "opaque origin" is an internal value we cannot access, ignore.
|
|||
|
+ if (A.origin === B.origin && A.origin === 'null') {
|
|||
|
+ return true
|
|||
|
+ }
|
|||
|
|
|||
|
// 2. If A and B are both tuple origins and their schemes,
|
|||
|
// hosts, and port are identical, then return true.
|
|||
|
@@ -940,6 +947,41 @@ async function readAllBytes (reader, suc
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
+ * @see https://fetch.spec.whatwg.org/#is-local
|
|||
|
+ * @param {URL} url
|
|||
|
+ */
|
|||
|
+function urlIsLocal (url) {
|
|||
|
+ assert('protocol' in url) // ensure it's a url object
|
|||
|
+
|
|||
|
+ const protocol = url.protocol
|
|||
|
+
|
|||
|
+ return protocol === 'about:' || protocol === 'blob:' || protocol === 'data:'
|
|||
|
+}
|
|||
|
+
|
|||
|
+/**
|
|||
|
+ * @param {string|URL} url
|
|||
|
+ */
|
|||
|
+function urlHasHttpsScheme (url) {
|
|||
|
+ if (typeof url === 'string') {
|
|||
|
+ return url.startsWith('https:')
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ return url.protocol === 'https:'
|
|||
|
+}
|
|||
|
+
|
|||
|
+/**
|
|||
|
+ * @see https://fetch.spec.whatwg.org/#http-scheme
|
|||
|
+ * @param {URL} url
|
|||
|
+ */
|
|||
|
+function urlIsHttpHttpsScheme (url) {
|
|||
|
+ assert('protocol' in url) // ensure it's a url object
|
|||
|
+
|
|||
|
+ const protocol = url.protocol
|
|||
|
+
|
|||
|
+ return protocol === 'http:' || protocol === 'https:'
|
|||
|
+}
|
|||
|
+
|
|||
|
+/**
|
|||
|
* Fetch supports node >= 16.8.0, but Object.hasOwn was added in v16.9.0.
|
|||
|
*/
|
|||
|
const hasOwn = Object.hasOwn || ((dict, key) => Object.prototype.hasOwnProperty.call(dict, key))
|
|||
|
@@ -983,5 +1025,9 @@ module.exports = {
|
|||
|
isReadableStreamLike,
|
|||
|
readableStreamClose,
|
|||
|
isomorphicEncode,
|
|||
|
- isomorphicDecode
|
|||
|
+ isomorphicDecode,
|
|||
|
+ urlIsLocal,
|
|||
|
+ urlHasHttpsScheme,
|
|||
|
+ urlIsHttpHttpsScheme,
|
|||
|
+ readAllBytes
|
|||
|
}
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/fileapi/encoding.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/fileapi/encoding.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/fileapi/encoding.js
|
|||
|
@@ -2,9 +2,13 @@
|
|||
|
|
|||
|
/**
|
|||
|
* @see https://encoding.spec.whatwg.org/#concept-encoding-get
|
|||
|
- * @param {string} label
|
|||
|
+ * @param {string|undefined} label
|
|||
|
*/
|
|||
|
function getEncoding (label) {
|
|||
|
+ if (!label) {
|
|||
|
+ return 'failure'
|
|||
|
+ }
|
|||
|
+
|
|||
|
// 1. Remove any leading and trailing ASCII whitespace from label.
|
|||
|
// 2. If label is an ASCII case-insensitive match for any of the
|
|||
|
// labels listed in the table below, then return the
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/proxy-agent.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/proxy-agent.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/proxy-agent.js
|
|||
|
@@ -3,7 +3,7 @@
|
|||
|
const { kProxy, kClose, kDestroy, kInterceptors } = require('./core/symbols')
|
|||
|
const { URL } = require('url')
|
|||
|
const Agent = require('./agent')
|
|||
|
-const Client = require('./client')
|
|||
|
+const Pool = require('./pool')
|
|||
|
const DispatcherBase = require('./dispatcher-base')
|
|||
|
const { InvalidArgumentError, RequestAbortedError } = require('./core/errors')
|
|||
|
const buildConnector = require('./core/connect')
|
|||
|
@@ -34,6 +34,10 @@ function buildProxyOptions (opts) {
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
+function defaultFactory (origin, opts) {
|
|||
|
+ return new Pool(origin, opts)
|
|||
|
+}
|
|||
|
+
|
|||
|
class ProxyAgent extends DispatcherBase {
|
|||
|
constructor (opts) {
|
|||
|
super(opts)
|
|||
|
@@ -51,6 +55,12 @@ class ProxyAgent extends DispatcherBase
|
|||
|
throw new InvalidArgumentError('Proxy opts.uri is mandatory')
|
|||
|
}
|
|||
|
|
|||
|
+ const { clientFactory = defaultFactory } = opts
|
|||
|
+
|
|||
|
+ if (typeof clientFactory !== 'function') {
|
|||
|
+ throw new InvalidArgumentError('Proxy opts.clientFactory must be a function.')
|
|||
|
+ }
|
|||
|
+
|
|||
|
this[kRequestTls] = opts.requestTls
|
|||
|
this[kProxyTls] = opts.proxyTls
|
|||
|
this[kProxyHeaders] = opts.headers || {}
|
|||
|
@@ -69,7 +79,7 @@ class ProxyAgent extends DispatcherBase
|
|||
|
|
|||
|
const connect = buildConnector({ ...opts.proxyTls })
|
|||
|
this[kConnectEndpoint] = buildConnector({ ...opts.requestTls })
|
|||
|
- this[kClient] = new Client(resolvedUrl, { connect })
|
|||
|
+ this[kClient] = clientFactory(resolvedUrl, { connect })
|
|||
|
this[kAgent] = new Agent({
|
|||
|
...opts,
|
|||
|
connect: async (opts, callback) => {
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/timers.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/timers.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/timers.js
|
|||
|
@@ -13,13 +13,15 @@ function onTimeout () {
|
|||
|
while (idx < len) {
|
|||
|
const timer = fastTimers[idx]
|
|||
|
|
|||
|
- if (timer.expires && fastNow >= timer.expires) {
|
|||
|
- timer.expires = 0
|
|||
|
+ if (timer.state === 0) {
|
|||
|
+ timer.state = fastNow + timer.delay
|
|||
|
+ } else if (timer.state > 0 && fastNow >= timer.state) {
|
|||
|
+ timer.state = -1
|
|||
|
timer.callback(timer.opaque)
|
|||
|
}
|
|||
|
|
|||
|
- if (timer.expires === 0) {
|
|||
|
- timer.active = false
|
|||
|
+ if (timer.state === -1) {
|
|||
|
+ timer.state = -2
|
|||
|
if (idx !== len - 1) {
|
|||
|
fastTimers[idx] = fastTimers.pop()
|
|||
|
} else {
|
|||
|
@@ -53,37 +55,43 @@ class Timeout {
|
|||
|
this.callback = callback
|
|||
|
this.delay = delay
|
|||
|
this.opaque = opaque
|
|||
|
- this.expires = 0
|
|||
|
- this.active = false
|
|||
|
+
|
|||
|
+ // -2 not in timer list
|
|||
|
+ // -1 in timer list but inactive
|
|||
|
+ // 0 in timer list waiting for time
|
|||
|
+ // > 0 in timer list waiting for time to expire
|
|||
|
+ this.state = -2
|
|||
|
|
|||
|
this.refresh()
|
|||
|
}
|
|||
|
|
|||
|
refresh () {
|
|||
|
- if (!this.active) {
|
|||
|
- this.active = true
|
|||
|
+ if (this.state === -2) {
|
|||
|
fastTimers.push(this)
|
|||
|
if (!fastNowTimeout || fastTimers.length === 1) {
|
|||
|
refreshTimeout()
|
|||
|
- fastNow = Date.now()
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
- this.expires = fastNow + this.delay
|
|||
|
+ this.state = 0
|
|||
|
}
|
|||
|
|
|||
|
clear () {
|
|||
|
- this.expires = 0
|
|||
|
+ this.state = -1
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
module.exports = {
|
|||
|
setTimeout (callback, delay, opaque) {
|
|||
|
- return new Timeout(callback, delay, opaque)
|
|||
|
+ return delay < 1e3
|
|||
|
+ ? setTimeout(callback, delay, opaque)
|
|||
|
+ : new Timeout(callback, delay, opaque)
|
|||
|
},
|
|||
|
clearTimeout (timeout) {
|
|||
|
- if (timeout && timeout.clear) {
|
|||
|
+ if (timeout instanceof Timeout) {
|
|||
|
timeout.clear()
|
|||
|
+ } else {
|
|||
|
+ clearTimeout(timeout)
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/websocket/connection.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/websocket/connection.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/websocket/connection.js
|
|||
|
@@ -5,19 +5,17 @@ const diagnosticsChannel = require('diag
|
|||
|
const { uid, states } = require('./constants')
|
|||
|
const {
|
|||
|
kReadyState,
|
|||
|
- kResponse,
|
|||
|
- kExtensions,
|
|||
|
- kProtocol,
|
|||
|
kSentClose,
|
|||
|
kByteParser,
|
|||
|
kReceivedClose
|
|||
|
} = require('./symbols')
|
|||
|
const { fireEvent, failWebsocketConnection } = require('./util')
|
|||
|
const { CloseEvent } = require('./events')
|
|||
|
-const { ByteParser } = require('./receiver')
|
|||
|
const { makeRequest } = require('../fetch/request')
|
|||
|
const { fetching } = require('../fetch/index')
|
|||
|
-const { getGlobalDispatcher } = require('../..')
|
|||
|
+const { Headers } = require('../fetch/headers')
|
|||
|
+const { getGlobalDispatcher } = require('../global')
|
|||
|
+const { kHeadersList } = require('../core/symbols')
|
|||
|
|
|||
|
const channels = {}
|
|||
|
channels.open = diagnosticsChannel.channel('undici:websocket:open')
|
|||
|
@@ -29,8 +27,10 @@ channels.socketError = diagnosticsChanne
|
|||
|
* @param {URL} url
|
|||
|
* @param {string|string[]} protocols
|
|||
|
* @param {import('./websocket').WebSocket} ws
|
|||
|
+ * @param {(response: any) => void} onEstablish
|
|||
|
+ * @param {Partial<import('../../types/websocket').WebSocketInit>} options
|
|||
|
*/
|
|||
|
-function establishWebSocketConnection (url, protocols, ws) {
|
|||
|
+function establishWebSocketConnection (url, protocols, ws, onEstablish, options) {
|
|||
|
// 1. Let requestURL be a copy of url, with its scheme set to "http", if url’s
|
|||
|
// scheme is "ws", and to "https" otherwise.
|
|||
|
const requestURL = url
|
|||
|
@@ -51,6 +51,13 @@ function establishWebSocketConnection (u
|
|||
|
redirect: 'error'
|
|||
|
})
|
|||
|
|
|||
|
+ // Note: undici extension, allow setting custom headers.
|
|||
|
+ if (options.headers) {
|
|||
|
+ const headersList = new Headers(options.headers)[kHeadersList]
|
|||
|
+
|
|||
|
+ request.headersList = headersList
|
|||
|
+ }
|
|||
|
+
|
|||
|
// 3. Append (`Upgrade`, `websocket`) to request’s header list.
|
|||
|
// 4. Append (`Connection`, `Upgrade`) to request’s header list.
|
|||
|
// Note: both of these are handled by undici currently.
|
|||
|
@@ -91,7 +98,7 @@ function establishWebSocketConnection (u
|
|||
|
const controller = fetching({
|
|||
|
request,
|
|||
|
useParallelQueue: true,
|
|||
|
- dispatcher: getGlobalDispatcher(),
|
|||
|
+ dispatcher: options.dispatcher ?? getGlobalDispatcher(),
|
|||
|
processResponse (response) {
|
|||
|
// 1. If response is a network error or its status is not 101,
|
|||
|
// fail the WebSocket connection.
|
|||
|
@@ -173,21 +180,19 @@ function establishWebSocketConnection (u
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
- // processResponse is called when the "response’s header list has been received and initialized."
|
|||
|
- // once this happens, the connection is open
|
|||
|
- ws[kResponse] = response
|
|||
|
-
|
|||
|
- const parser = new ByteParser(ws)
|
|||
|
- response.socket.ws = ws // TODO: use symbol
|
|||
|
- ws[kByteParser] = parser
|
|||
|
-
|
|||
|
- whenConnectionEstablished(ws)
|
|||
|
-
|
|||
|
response.socket.on('data', onSocketData)
|
|||
|
response.socket.on('close', onSocketClose)
|
|||
|
response.socket.on('error', onSocketError)
|
|||
|
|
|||
|
- parser.on('drain', onParserDrain)
|
|||
|
+ if (channels.open.hasSubscribers) {
|
|||
|
+ channels.open.publish({
|
|||
|
+ address: response.socket.address(),
|
|||
|
+ protocol: secProtocol,
|
|||
|
+ extensions: secExtension
|
|||
|
+ })
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ onEstablish(response)
|
|||
|
}
|
|||
|
})
|
|||
|
|
|||
|
@@ -195,46 +200,6 @@ function establishWebSocketConnection (u
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
- * @see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
|||
|
- * @param {import('./websocket').WebSocket} ws
|
|||
|
- */
|
|||
|
-function whenConnectionEstablished (ws) {
|
|||
|
- const { [kResponse]: response } = ws
|
|||
|
-
|
|||
|
- // 1. Change the ready state to OPEN (1).
|
|||
|
- ws[kReadyState] = states.OPEN
|
|||
|
-
|
|||
|
- // 2. Change the extensions attribute’s value to the extensions in use, if
|
|||
|
- // it is not the null value.
|
|||
|
- // https://datatracker.ietf.org/doc/html/rfc6455#section-9.1
|
|||
|
- const extensions = response.headersList.get('sec-websocket-extensions')
|
|||
|
-
|
|||
|
- if (extensions !== null) {
|
|||
|
- ws[kExtensions] = extensions
|
|||
|
- }
|
|||
|
-
|
|||
|
- // 3. Change the protocol attribute’s value to the subprotocol in use, if
|
|||
|
- // it is not the null value.
|
|||
|
- // https://datatracker.ietf.org/doc/html/rfc6455#section-1.9
|
|||
|
- const protocol = response.headersList.get('sec-websocket-protocol')
|
|||
|
-
|
|||
|
- if (protocol !== null) {
|
|||
|
- ws[kProtocol] = protocol
|
|||
|
- }
|
|||
|
-
|
|||
|
- // 4. Fire an event named open at the WebSocket object.
|
|||
|
- fireEvent('open', ws)
|
|||
|
-
|
|||
|
- if (channels.open.hasSubscribers) {
|
|||
|
- channels.open.publish({
|
|||
|
- address: response.socket.address(),
|
|||
|
- protocol,
|
|||
|
- extensions
|
|||
|
- })
|
|||
|
- }
|
|||
|
-}
|
|||
|
-
|
|||
|
-/**
|
|||
|
* @param {Buffer} chunk
|
|||
|
*/
|
|||
|
function onSocketData (chunk) {
|
|||
|
@@ -243,10 +208,6 @@ function onSocketData (chunk) {
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
-function onParserDrain () {
|
|||
|
- this.ws[kResponse].socket.resume()
|
|||
|
-}
|
|||
|
-
|
|||
|
/**
|
|||
|
* @see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
|||
|
* @see https://datatracker.ietf.org/doc/html/rfc6455#section-7.1.4
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/websocket/symbols.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/websocket/symbols.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/websocket/symbols.js
|
|||
|
@@ -5,10 +5,7 @@ module.exports = {
|
|||
|
kReadyState: Symbol('ready state'),
|
|||
|
kController: Symbol('controller'),
|
|||
|
kResponse: Symbol('response'),
|
|||
|
- kExtensions: Symbol('extensions'),
|
|||
|
- kProtocol: Symbol('protocol'),
|
|||
|
kBinaryType: Symbol('binary type'),
|
|||
|
- kClosingFrame: Symbol('closing frame'),
|
|||
|
kSentClose: Symbol('sent close'),
|
|||
|
kReceivedClose: Symbol('received close'),
|
|||
|
kByteParser: Symbol('byte parser')
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/websocket/websocket.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/websocket/websocket.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/websocket/websocket.js
|
|||
|
@@ -8,16 +8,17 @@ const {
|
|||
|
kWebSocketURL,
|
|||
|
kReadyState,
|
|||
|
kController,
|
|||
|
- kExtensions,
|
|||
|
- kProtocol,
|
|||
|
kBinaryType,
|
|||
|
kResponse,
|
|||
|
- kSentClose
|
|||
|
+ kSentClose,
|
|||
|
+ kByteParser
|
|||
|
} = require('./symbols')
|
|||
|
-const { isEstablished, isClosing, isValidSubprotocol, failWebsocketConnection } = require('./util')
|
|||
|
+const { isEstablished, isClosing, isValidSubprotocol, failWebsocketConnection, fireEvent } = require('./util')
|
|||
|
const { establishWebSocketConnection } = require('./connection')
|
|||
|
const { WebsocketFrameSend } = require('./frame')
|
|||
|
+const { ByteParser } = require('./receiver')
|
|||
|
const { kEnumerableProperty, isBlobLike } = require('../core/util')
|
|||
|
+const { getGlobalDispatcher } = require('../global')
|
|||
|
const { types } = require('util')
|
|||
|
|
|||
|
let experimentalWarned = false
|
|||
|
@@ -32,6 +33,8 @@ class WebSocket extends EventTarget {
|
|||
|
}
|
|||
|
|
|||
|
#bufferedAmount = 0
|
|||
|
+ #protocol = ''
|
|||
|
+ #extensions = ''
|
|||
|
|
|||
|
/**
|
|||
|
* @param {string} url
|
|||
|
@@ -49,8 +52,10 @@ class WebSocket extends EventTarget {
|
|||
|
})
|
|||
|
}
|
|||
|
|
|||
|
+ const options = webidl.converters['DOMString or sequence<DOMString> or WebSocketInit'](protocols)
|
|||
|
+
|
|||
|
url = webidl.converters.USVString(url)
|
|||
|
- protocols = webidl.converters['DOMString or sequence<DOMString>'](protocols)
|
|||
|
+ protocols = options.protocols
|
|||
|
|
|||
|
// 1. Let urlRecord be the result of applying the URL parser to url.
|
|||
|
let urlRecord
|
|||
|
@@ -104,7 +109,13 @@ class WebSocket extends EventTarget {
|
|||
|
|
|||
|
// 1. Establish a WebSocket connection given urlRecord, protocols,
|
|||
|
// and client.
|
|||
|
- this[kController] = establishWebSocketConnection(urlRecord, protocols, this)
|
|||
|
+ this[kController] = establishWebSocketConnection(
|
|||
|
+ urlRecord,
|
|||
|
+ protocols,
|
|||
|
+ this,
|
|||
|
+ (response) => this.#onConnectionEstablished(response),
|
|||
|
+ options
|
|||
|
+ )
|
|||
|
|
|||
|
// Each WebSocket object has an associated ready state, which is a
|
|||
|
// number representing the state of the connection. Initially it must
|
|||
|
@@ -112,10 +123,8 @@ class WebSocket extends EventTarget {
|
|||
|
this[kReadyState] = WebSocket.CONNECTING
|
|||
|
|
|||
|
// The extensions attribute must initially return the empty string.
|
|||
|
- this[kExtensions] = ''
|
|||
|
|
|||
|
// The protocol attribute must initially return the empty string.
|
|||
|
- this[kProtocol] = ''
|
|||
|
|
|||
|
// Each WebSocket object has an associated binary type, which is a
|
|||
|
// BinaryType. Initially it must be "blob".
|
|||
|
@@ -368,13 +377,13 @@ class WebSocket extends EventTarget {
|
|||
|
get extensions () {
|
|||
|
webidl.brandCheck(this, WebSocket)
|
|||
|
|
|||
|
- return this[kExtensions]
|
|||
|
+ return this.#extensions
|
|||
|
}
|
|||
|
|
|||
|
get protocol () {
|
|||
|
webidl.brandCheck(this, WebSocket)
|
|||
|
|
|||
|
- return this[kProtocol]
|
|||
|
+ return this.#protocol
|
|||
|
}
|
|||
|
|
|||
|
get onopen () {
|
|||
|
@@ -476,6 +485,47 @@ class WebSocket extends EventTarget {
|
|||
|
this[kBinaryType] = type
|
|||
|
}
|
|||
|
}
|
|||
|
+
|
|||
|
+ /**
|
|||
|
+ * @see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
|||
|
+ */
|
|||
|
+ #onConnectionEstablished (response) {
|
|||
|
+ // processResponse is called when the "response’s header list has been received and initialized."
|
|||
|
+ // once this happens, the connection is open
|
|||
|
+ this[kResponse] = response
|
|||
|
+
|
|||
|
+ const parser = new ByteParser(this)
|
|||
|
+ parser.on('drain', function onParserDrain () {
|
|||
|
+ this.ws[kResponse].socket.resume()
|
|||
|
+ })
|
|||
|
+
|
|||
|
+ response.socket.ws = this
|
|||
|
+ this[kByteParser] = parser
|
|||
|
+
|
|||
|
+ // 1. Change the ready state to OPEN (1).
|
|||
|
+ this[kReadyState] = states.OPEN
|
|||
|
+
|
|||
|
+ // 2. Change the extensions attribute’s value to the extensions in use, if
|
|||
|
+ // it is not the null value.
|
|||
|
+ // https://datatracker.ietf.org/doc/html/rfc6455#section-9.1
|
|||
|
+ const extensions = response.headersList.get('sec-websocket-extensions')
|
|||
|
+
|
|||
|
+ if (extensions !== null) {
|
|||
|
+ this.#extensions = extensions
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 3. Change the protocol attribute’s value to the subprotocol in use, if
|
|||
|
+ // it is not the null value.
|
|||
|
+ // https://datatracker.ietf.org/doc/html/rfc6455#section-1.9
|
|||
|
+ const protocol = response.headersList.get('sec-websocket-protocol')
|
|||
|
+
|
|||
|
+ if (protocol !== null) {
|
|||
|
+ this.#protocol = protocol
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 4. Fire an event named open at the WebSocket object.
|
|||
|
+ fireEvent('open', this)
|
|||
|
+ }
|
|||
|
}
|
|||
|
|
|||
|
// https://websockets.spec.whatwg.org/#dom-websocket-connecting
|
|||
|
@@ -531,6 +581,36 @@ webidl.converters['DOMString or sequence
|
|||
|
return webidl.converters.DOMString(V)
|
|||
|
}
|
|||
|
|
|||
|
+// This implements the propsal made in https://github.com/whatwg/websockets/issues/42
|
|||
|
+webidl.converters.WebSocketInit = webidl.dictionaryConverter([
|
|||
|
+ {
|
|||
|
+ key: 'protocols',
|
|||
|
+ converter: webidl.converters['DOMString or sequence<DOMString>'],
|
|||
|
+ get defaultValue () {
|
|||
|
+ return []
|
|||
|
+ }
|
|||
|
+ },
|
|||
|
+ {
|
|||
|
+ key: 'dispatcher',
|
|||
|
+ converter: (V) => V,
|
|||
|
+ get defaultValue () {
|
|||
|
+ return getGlobalDispatcher()
|
|||
|
+ }
|
|||
|
+ },
|
|||
|
+ {
|
|||
|
+ key: 'headers',
|
|||
|
+ converter: webidl.nullableConverter(webidl.converters.HeadersInit)
|
|||
|
+ }
|
|||
|
+])
|
|||
|
+
|
|||
|
+webidl.converters['DOMString or sequence<DOMString> or WebSocketInit'] = function (V) {
|
|||
|
+ if (webidl.util.Type(V) === 'Object' && !(Symbol.iterator in V)) {
|
|||
|
+ return webidl.converters.WebSocketInit(V)
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ return { protocols: webidl.converters['DOMString or sequence<DOMString>'](V) }
|
|||
|
+}
|
|||
|
+
|
|||
|
webidl.converters.WebSocketSendData = function (V) {
|
|||
|
if (webidl.util.Type(V) === 'Object') {
|
|||
|
if (isBlobLike(V)) {
|
|||
|
Index: node-v16.20.2/deps/undici/src/package.json
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/package.json
|
|||
|
+++ node-v16.20.2/deps/undici/src/package.json
|
|||
|
@@ -1,6 +1,6 @@
|
|||
|
{
|
|||
|
"name": "undici",
|
|||
|
- "version": "5.20.0",
|
|||
|
+ "version": "5.22.1",
|
|||
|
"description": "An HTTP/1.1 client, written from scratch for Node.js",
|
|||
|
"homepage": "https://undici.nodejs.org",
|
|||
|
"bugs": {
|
|||
|
@@ -42,18 +42,18 @@
|
|||
|
],
|
|||
|
"scripts": {
|
|||
|
"build:node": "npx esbuild@0.14.38 index-fetch.js --bundle --platform=node --outfile=undici-fetch.js",
|
|||
|
- "prebuild:wasm": "docker build -t llhttp_wasm_builder -f build/Dockerfile .",
|
|||
|
+ "prebuild:wasm": "node build/wasm.js --prebuild",
|
|||
|
"build:wasm": "node build/wasm.js --docker",
|
|||
|
"lint": "standard | snazzy",
|
|||
|
"lint:fix": "standard --fix | snazzy",
|
|||
|
- "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": "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 && npm run test:typescript",
|
|||
|
"test:cookies": "node scripts/verifyVersion 16 || tap test/cookie/*.js",
|
|||
|
- "test:node-fetch": "node scripts/verifyVersion.js 16 || mocha test/node-fetch",
|
|||
|
- "test:fetch": "node scripts/verifyVersion.js 16 || (npm run build:node && tap test/fetch/*.js && tap test/webidl/*.js)",
|
|||
|
+ "test:node-fetch": "node scripts/verifyVersion.js 16 || mocha --exit test/node-fetch",
|
|||
|
+ "test:fetch": "node scripts/verifyVersion.js 16 || (npm run build:node && tap --expose-gc test/fetch/*.js && tap test/webidl/*.js)",
|
|||
|
"test:jest": "node scripts/verifyVersion.js 14 || jest",
|
|||
|
"test:tap": "tap test/*.js test/diagnostics-channel/*.js",
|
|||
|
"test:tdd": "tap test/*.js test/diagnostics-channel/*.js -w",
|
|||
|
- "test:typescript": "tsd && tsc test/imports/undici-import.ts",
|
|||
|
+ "test:typescript": "node scripts/verifyVersion.js 14 || tsd && tsc --skipLibCheck test/imports/undici-import.ts",
|
|||
|
"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 --no-warnings test/wpt/start-websockets.mjs)",
|
|||
|
"coverage": "nyc --reporter=text --reporter=html npm run test",
|
|||
|
@@ -61,7 +61,7 @@
|
|||
|
"bench": "PORT=3042 concurrently -k -s first npm:bench:server npm:bench:run",
|
|||
|
"bench:server": "node benchmarks/server.js",
|
|||
|
"prebench:run": "node benchmarks/wait.js",
|
|||
|
- "bench:run": "CONNECTIONS=1 node --experimental-wasm-simd benchmarks/benchmark.js; CONNECTIONS=50 node --experimental-wasm-simd benchmarks/benchmark.js",
|
|||
|
+ "bench:run": "CONNECTIONS=1 node benchmarks/benchmark.js; CONNECTIONS=50 node benchmarks/benchmark.js",
|
|||
|
"serve:website": "docsify serve .",
|
|||
|
"prepare": "husky install",
|
|||
|
"fuzz": "jsfuzz test/fuzzing/fuzz.js corpus"
|
|||
|
@@ -75,7 +75,7 @@
|
|||
|
"chai-as-promised": "^7.1.1",
|
|||
|
"chai-iterator": "^3.0.2",
|
|||
|
"chai-string": "^1.5.0",
|
|||
|
- "concurrently": "^7.1.0",
|
|||
|
+ "concurrently": "^8.0.1",
|
|||
|
"cronometro": "^1.0.5",
|
|||
|
"delay": "^5.0.0",
|
|||
|
"dns-packet": "^5.4.0",
|
|||
|
@@ -86,6 +86,7 @@
|
|||
|
"husky": "^8.0.1",
|
|||
|
"import-fresh": "^3.3.0",
|
|||
|
"jest": "^29.0.2",
|
|||
|
+ "jsdom": "^21.1.0",
|
|||
|
"jsfuzz": "^1.0.15",
|
|||
|
"mocha": "^10.0.0",
|
|||
|
"p-timeout": "^3.2.0",
|
|||
|
@@ -97,13 +98,13 @@
|
|||
|
"standard": "^17.0.0",
|
|||
|
"table": "^6.8.0",
|
|||
|
"tap": "^16.1.0",
|
|||
|
- "tsd": "^0.25.0",
|
|||
|
- "typescript": "^4.9.5",
|
|||
|
- "wait-on": "^6.0.0",
|
|||
|
+ "tsd": "^0.28.1",
|
|||
|
+ "typescript": "^5.0.2",
|
|||
|
+ "wait-on": "^7.0.1",
|
|||
|
"ws": "^8.11.0"
|
|||
|
},
|
|||
|
"engines": {
|
|||
|
- "node": ">=12.18"
|
|||
|
+ "node": ">=14.0"
|
|||
|
},
|
|||
|
"standard": {
|
|||
|
"env": [
|
|||
|
@@ -112,8 +113,7 @@
|
|||
|
"ignore": [
|
|||
|
"lib/llhttp/constants.js",
|
|||
|
"lib/llhttp/utils.js",
|
|||
|
- "test/wpt/tests",
|
|||
|
- "test/wpt/runner/resources"
|
|||
|
+ "test/wpt/tests"
|
|||
|
]
|
|||
|
},
|
|||
|
"tsd": {
|
|||
|
Index: node-v16.20.2/deps/undici/src/types/balanced-pool.d.ts
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/types/balanced-pool.d.ts
|
|||
|
+++ node-v16.20.2/deps/undici/src/types/balanced-pool.d.ts
|
|||
|
@@ -5,10 +5,10 @@ import { URL } from 'url'
|
|||
|
export default BalancedPool
|
|||
|
|
|||
|
declare class BalancedPool extends Dispatcher {
|
|||
|
- constructor(url: string | URL | string[], options?: Pool.Options);
|
|||
|
+ constructor(url: string | string[] | URL | URL[], options?: Pool.Options);
|
|||
|
|
|||
|
- addUpstream(upstream: string): BalancedPool;
|
|||
|
- removeUpstream(upstream: string): BalancedPool;
|
|||
|
+ addUpstream(upstream: string | URL): BalancedPool;
|
|||
|
+ removeUpstream(upstream: string | URL): BalancedPool;
|
|||
|
upstreams: Array<string>;
|
|||
|
|
|||
|
/** `true` after `pool.close()` has been called. */
|
|||
|
Index: node-v16.20.2/deps/undici/src/types/client.d.ts
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/types/client.d.ts
|
|||
|
+++ node-v16.20.2/deps/undici/src/types/client.d.ts
|
|||
|
@@ -4,10 +4,10 @@ import Dispatcher from './dispatcher'
|
|||
|
import DispatchInterceptor from './dispatcher'
|
|||
|
import buildConnector from "./connector";
|
|||
|
|
|||
|
-export default Client
|
|||
|
-
|
|||
|
-/** A basic HTTP/1.1 client, mapped on top a single TCP/TLS connection. Pipelining is disabled by default. */
|
|||
|
-declare class Client extends Dispatcher {
|
|||
|
+/**
|
|||
|
+ * A basic HTTP/1.1 client, mapped on top a single TCP/TLS connection. Pipelining is disabled by default.
|
|||
|
+ */
|
|||
|
+export class Client extends Dispatcher {
|
|||
|
constructor(url: string | URL, options?: Client.Options);
|
|||
|
/** Property to get and set the pipelining factor. */
|
|||
|
pipelining: number;
|
|||
|
@@ -17,40 +17,62 @@ declare class Client extends Dispatcher
|
|||
|
destroyed: boolean;
|
|||
|
}
|
|||
|
|
|||
|
-declare namespace Client {
|
|||
|
+export declare namespace Client {
|
|||
|
+ export interface OptionsInterceptors {
|
|||
|
+ Client: readonly DispatchInterceptor[];
|
|||
|
+ }
|
|||
|
export interface Options {
|
|||
|
+ /** TODO */
|
|||
|
+ interceptors?: OptionsInterceptors;
|
|||
|
+ /** The maximum length of request headers in bytes. Default: `16384` (16KiB). */
|
|||
|
+ maxHeaderSize?: number;
|
|||
|
+ /** The amount of time the parser will wait to receive the complete HTTP headers (Node 14 and above only). Default: `300e3` milliseconds (300s). */
|
|||
|
+ headersTimeout?: number;
|
|||
|
+ /** @deprecated unsupported socketTimeout, use headersTimeout & bodyTimeout instead */
|
|||
|
+ socketTimeout?: never;
|
|||
|
+ /** @deprecated unsupported requestTimeout, use headersTimeout & bodyTimeout instead */
|
|||
|
+ requestTimeout?: never;
|
|||
|
+ /** TODO */
|
|||
|
+ connectTimeout?: number;
|
|||
|
+ /** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Default: `300e3` milliseconds (300s). */
|
|||
|
+ bodyTimeout?: number;
|
|||
|
+ /** @deprecated unsupported idleTimeout, use keepAliveTimeout instead */
|
|||
|
+ idleTimeout?: never;
|
|||
|
+ /** @deprecated unsupported keepAlive, use pipelining=0 instead */
|
|||
|
+ keepAlive?: never;
|
|||
|
/** the timeout after which a socket without active requests will time out. Monitors time between activity on a connected socket. This value may be overridden by *keep-alive* hints from the server. Default: `4e3` milliseconds (4s). */
|
|||
|
- keepAliveTimeout?: number | null;
|
|||
|
+ keepAliveTimeout?: number;
|
|||
|
+ /** @deprecated unsupported maxKeepAliveTimeout, use keepAliveMaxTimeout instead */
|
|||
|
+ maxKeepAliveTimeout?: never;
|
|||
|
/** the maximum allowed `idleTimeout` when overridden by *keep-alive* hints from the server. Default: `600e3` milliseconds (10min). */
|
|||
|
- keepAliveMaxTimeout?: number | null;
|
|||
|
+ keepAliveMaxTimeout?: number;
|
|||
|
/** A number subtracted from server *keep-alive* hints when overriding `idleTimeout` to account for timing inaccuracies caused by e.g. transport latency. Default: `1e3` milliseconds (1s). */
|
|||
|
- keepAliveTimeoutThreshold?: number | null;
|
|||
|
+ keepAliveTimeoutThreshold?: number;
|
|||
|
+ /** TODO */
|
|||
|
+ socketPath?: string;
|
|||
|
/** The amount of concurrent requests to be sent over the single TCP/TLS connection according to [RFC7230](https://tools.ietf.org/html/rfc7230#section-6.3.2). Default: `1`. */
|
|||
|
- pipelining?: number | null;
|
|||
|
- /** **/
|
|||
|
- connect?: buildConnector.BuildOptions | buildConnector.connector | null;
|
|||
|
- /** The maximum length of request headers in bytes. Default: `16384` (16KiB). */
|
|||
|
- maxHeaderSize?: number | null;
|
|||
|
- /** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Default: `300e3` milliseconds (300s). */
|
|||
|
- bodyTimeout?: number | null;
|
|||
|
- /** The amount of time the parser will wait to receive the complete HTTP headers (Node 14 and above only). Default: `300e3` milliseconds (300s). */
|
|||
|
- headersTimeout?: number | null;
|
|||
|
+ pipelining?: number;
|
|||
|
+ /** @deprecated use the connect option instead */
|
|||
|
+ tls?: never;
|
|||
|
/** If `true`, an error is thrown when the request content-length header doesn't match the length of the request body. Default: `true`. */
|
|||
|
strictContentLength?: boolean;
|
|||
|
- /** @deprecated use the connect option instead */
|
|||
|
- tls?: TlsOptions | null;
|
|||
|
- /** */
|
|||
|
+ /** TODO */
|
|||
|
+ maxCachedSessions?: number;
|
|||
|
+ /** TODO */
|
|||
|
+ maxRedirections?: number;
|
|||
|
+ /** TODO */
|
|||
|
+ connect?: buildConnector.BuildOptions | buildConnector.connector;
|
|||
|
+ /** TODO */
|
|||
|
maxRequestsPerClient?: number;
|
|||
|
+ /** TODO */
|
|||
|
+ localAddress?: string;
|
|||
|
/** Max response body size in bytes, -1 is disabled */
|
|||
|
- maxResponseSize?: number | null;
|
|||
|
+ maxResponseSize?: number;
|
|||
|
/** Enables a family autodetection algorithm that loosely implements section 5 of RFC 8305. */
|
|||
|
autoSelectFamily?: boolean;
|
|||
|
/** The amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the `autoSelectFamily` option. */
|
|||
|
- autoSelectFamilyAttemptTimeout?: number;
|
|||
|
-
|
|||
|
- interceptors?: {Client: readonly DispatchInterceptor[] | undefined}
|
|||
|
+ autoSelectFamilyAttemptTimeout?: number;
|
|||
|
}
|
|||
|
-
|
|||
|
export interface SocketInfo {
|
|||
|
localAddress?: string
|
|||
|
localPort?: number
|
|||
|
@@ -61,6 +83,6 @@ declare namespace Client {
|
|||
|
bytesWritten?: number
|
|||
|
bytesRead?: number
|
|||
|
}
|
|||
|
-
|
|||
|
-
|
|||
|
}
|
|||
|
+
|
|||
|
+export default Client;
|
|||
|
Index: node-v16.20.2/deps/undici/src/types/proxy-agent.d.ts
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/types/proxy-agent.d.ts
|
|||
|
+++ node-v16.20.2/deps/undici/src/types/proxy-agent.d.ts
|
|||
|
@@ -1,7 +1,9 @@
|
|||
|
import Agent from './agent'
|
|||
|
import buildConnector from './connector';
|
|||
|
+import Client from './client'
|
|||
|
import Dispatcher from './dispatcher'
|
|||
|
import { IncomingHttpHeaders } from './header'
|
|||
|
+import Pool from './pool'
|
|||
|
|
|||
|
export default ProxyAgent
|
|||
|
|
|||
|
@@ -23,5 +25,6 @@ declare namespace ProxyAgent {
|
|||
|
headers?: IncomingHttpHeaders;
|
|||
|
requestTls?: buildConnector.BuildOptions;
|
|||
|
proxyTls?: buildConnector.BuildOptions;
|
|||
|
+ clientFactory?(origin: URL, opts: object): Dispatcher;
|
|||
|
}
|
|||
|
}
|
|||
|
Index: node-v16.20.2/deps/undici/src/types/websocket.d.ts
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/types/websocket.d.ts
|
|||
|
+++ node-v16.20.2/deps/undici/src/types/websocket.d.ts
|
|||
|
@@ -1,5 +1,7 @@
|
|||
|
/// <reference types="node" />
|
|||
|
|
|||
|
+import type { Blob } from 'buffer'
|
|||
|
+import type { MessagePort } from 'worker_threads'
|
|||
|
import {
|
|||
|
EventTarget,
|
|||
|
Event,
|
|||
|
@@ -8,6 +10,8 @@ import {
|
|||
|
AddEventListenerOptions,
|
|||
|
EventListenerOrEventListenerObject
|
|||
|
} from './patch'
|
|||
|
+import Dispatcher from './dispatcher'
|
|||
|
+import { HeadersInit } from './fetch'
|
|||
|
|
|||
|
export type BinaryType = 'blob' | 'arraybuffer'
|
|||
|
|
|||
|
@@ -65,7 +69,7 @@ interface WebSocket extends EventTarget
|
|||
|
|
|||
|
export declare const WebSocket: {
|
|||
|
prototype: WebSocket
|
|||
|
- new (url: string | URL, protocols?: string | string[]): WebSocket
|
|||
|
+ new (url: string | URL, protocols?: string | string[] | WebSocketInit): WebSocket
|
|||
|
readonly CLOSED: number
|
|||
|
readonly CLOSING: number
|
|||
|
readonly CONNECTING: number
|
|||
|
@@ -119,3 +123,9 @@ export declare const MessageEvent: {
|
|||
|
prototype: MessageEvent
|
|||
|
new<T>(type: string, eventInitDict?: MessageEventInit<T>): MessageEvent<T>
|
|||
|
}
|
|||
|
+
|
|||
|
+interface WebSocketInit {
|
|||
|
+ protocols?: string | string[],
|
|||
|
+ dispatcher?: Dispatcher,
|
|||
|
+ headers?: HeadersInit
|
|||
|
+}
|
|||
|
Index: node-v16.20.2/deps/undici/undici.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/undici.js
|
|||
|
+++ node-v16.20.2/deps/undici/undici.js
|
|||
|
@@ -50,7 +50,7 @@ var require_symbols = __commonJS({
|
|||
|
kClient: Symbol("client"),
|
|||
|
kParser: Symbol("parser"),
|
|||
|
kOnDestroyed: Symbol("destroy callbacks"),
|
|||
|
- kPipelining: Symbol("pipelinig"),
|
|||
|
+ kPipelining: Symbol("pipelining"),
|
|||
|
kSocket: Symbol("socket"),
|
|||
|
kHostHeader: Symbol("host header"),
|
|||
|
kConnector: Symbol("connector"),
|
|||
|
@@ -75,8 +75,7 @@ var require_symbols2 = __commonJS({
|
|||
|
kSignal: Symbol("signal"),
|
|||
|
kState: Symbol("state"),
|
|||
|
kGuard: Symbol("guard"),
|
|||
|
- kRealm: Symbol("realm"),
|
|||
|
- kHeadersCaseInsensitive: Symbol("headers case insensitive")
|
|||
|
+ kRealm: Symbol("realm")
|
|||
|
};
|
|||
|
}
|
|||
|
});
|
|||
|
@@ -300,7 +299,7 @@ var require_util = __commonJS({
|
|||
|
function nop() {
|
|||
|
}
|
|||
|
function isStream(obj) {
|
|||
|
- return obj && typeof obj.pipe === "function";
|
|||
|
+ return obj && typeof obj === "object" && typeof obj.pipe === "function" && typeof obj.on === "function";
|
|||
|
}
|
|||
|
function isBlobLike(object) {
|
|||
|
return Blob && object instanceof Blob || object && typeof object === "object" && (typeof object.stream === "function" || typeof object.arrayBuffer === "function") && /^(Blob|File)$/.test(object[Symbol.toStringTag]);
|
|||
|
@@ -318,27 +317,31 @@ var require_util = __commonJS({
|
|||
|
function parseURL(url) {
|
|||
|
if (typeof url === "string") {
|
|||
|
url = new URL(url);
|
|||
|
+ if (!/^https?:/.test(url.origin || url.protocol)) {
|
|||
|
+ throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|||
|
+ }
|
|||
|
+ return url;
|
|||
|
}
|
|||
|
if (!url || typeof url !== "object") {
|
|||
|
- throw new InvalidArgumentError("invalid url");
|
|||
|
+ throw new InvalidArgumentError("Invalid URL: The URL argument must be a non-null object.");
|
|||
|
}
|
|||
|
if (url.port != null && url.port !== "" && !Number.isFinite(parseInt(url.port))) {
|
|||
|
- throw new InvalidArgumentError("invalid port");
|
|||
|
+ throw new InvalidArgumentError("Invalid URL: port must be a valid integer or a string representation of an integer.");
|
|||
|
}
|
|||
|
if (url.path != null && typeof url.path !== "string") {
|
|||
|
- throw new InvalidArgumentError("invalid path");
|
|||
|
+ throw new InvalidArgumentError("Invalid URL path: the path must be a string or null/undefined.");
|
|||
|
}
|
|||
|
if (url.pathname != null && typeof url.pathname !== "string") {
|
|||
|
- throw new InvalidArgumentError("invalid pathname");
|
|||
|
+ throw new InvalidArgumentError("Invalid URL pathname: the pathname must be a string or null/undefined.");
|
|||
|
}
|
|||
|
if (url.hostname != null && typeof url.hostname !== "string") {
|
|||
|
- throw new InvalidArgumentError("invalid hostname");
|
|||
|
+ throw new InvalidArgumentError("Invalid URL hostname: the hostname must be a string or null/undefined.");
|
|||
|
}
|
|||
|
if (url.origin != null && typeof url.origin !== "string") {
|
|||
|
- throw new InvalidArgumentError("invalid origin");
|
|||
|
+ throw new InvalidArgumentError("Invalid URL origin: the origin must be a string or null/undefined.");
|
|||
|
}
|
|||
|
if (!/^https?:/.test(url.origin || url.protocol)) {
|
|||
|
- throw new InvalidArgumentError("invalid protocol");
|
|||
|
+ throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|||
|
}
|
|||
|
if (!(url instanceof URL)) {
|
|||
|
const port = url.port != null ? url.port : url.protocol === "https:" ? 443 : 80;
|
|||
|
@@ -439,30 +442,43 @@ var require_util = __commonJS({
|
|||
|
for (let i = 0; i < headers.length; i += 2) {
|
|||
|
const key = headers[i].toString().toLowerCase();
|
|||
|
let val = obj[key];
|
|||
|
- const encoding = key.length === 19 && key === "content-disposition" ? "latin1" : "utf8";
|
|||
|
if (!val) {
|
|||
|
if (Array.isArray(headers[i + 1])) {
|
|||
|
obj[key] = headers[i + 1];
|
|||
|
} else {
|
|||
|
- obj[key] = headers[i + 1].toString(encoding);
|
|||
|
+ obj[key] = headers[i + 1].toString("utf8");
|
|||
|
}
|
|||
|
} else {
|
|||
|
if (!Array.isArray(val)) {
|
|||
|
val = [val];
|
|||
|
obj[key] = val;
|
|||
|
}
|
|||
|
- val.push(headers[i + 1].toString(encoding));
|
|||
|
+ val.push(headers[i + 1].toString("utf8"));
|
|||
|
}
|
|||
|
}
|
|||
|
+ if ("content-length" in obj && "content-disposition" in obj) {
|
|||
|
+ obj["content-disposition"] = Buffer.from(obj["content-disposition"]).toString("latin1");
|
|||
|
+ }
|
|||
|
return obj;
|
|||
|
}
|
|||
|
function parseRawHeaders(headers) {
|
|||
|
const ret = [];
|
|||
|
+ let hasContentLength = false;
|
|||
|
+ let contentDispositionIdx = -1;
|
|||
|
for (let n = 0; n < headers.length; n += 2) {
|
|||
|
const key = headers[n + 0].toString();
|
|||
|
- const encoding = key.length === 19 && key.toLowerCase() === "content-disposition" ? "latin1" : "utf8";
|
|||
|
- const val = headers[n + 1].toString(encoding);
|
|||
|
- ret.push(key, val);
|
|||
|
+ const val = headers[n + 1].toString("utf8");
|
|||
|
+ if (key.length === 14 && (key === "content-length" || key.toLowerCase() === "content-length")) {
|
|||
|
+ ret.push(key, val);
|
|||
|
+ hasContentLength = true;
|
|||
|
+ } else if (key.length === 19 && (key === "content-disposition" || key.toLowerCase() === "content-disposition")) {
|
|||
|
+ contentDispositionIdx = ret.push(key, val) - 1;
|
|||
|
+ } else {
|
|||
|
+ ret.push(key, val);
|
|||
|
+ }
|
|||
|
+ }
|
|||
|
+ if (hasContentLength && contentDispositionIdx !== -1) {
|
|||
|
+ ret[contentDispositionIdx] = Buffer.from(ret[contentDispositionIdx]).toString("latin1");
|
|||
|
}
|
|||
|
return ret;
|
|||
|
}
|
|||
|
@@ -549,8 +565,31 @@ var require_util = __commonJS({
|
|||
|
}
|
|||
|
}, 0);
|
|||
|
}
|
|||
|
- function isFormDataLike(chunk) {
|
|||
|
- return chunk && chunk.constructor && chunk.constructor.name === "FormData" && typeof chunk === "object" && (typeof chunk.append === "function" && typeof chunk.delete === "function" && typeof chunk.get === "function" && typeof chunk.getAll === "function" && typeof chunk.has === "function" && typeof chunk.set === "function" && typeof chunk.entries === "function" && typeof chunk.keys === "function" && typeof chunk.values === "function" && typeof chunk.forEach === "function");
|
|||
|
+ function isFormDataLike(object) {
|
|||
|
+ return object && typeof object === "object" && typeof object.append === "function" && typeof object.delete === "function" && typeof object.get === "function" && typeof object.getAll === "function" && typeof object.has === "function" && typeof object.set === "function" && object[Symbol.toStringTag] === "FormData";
|
|||
|
+ }
|
|||
|
+ function throwIfAborted(signal) {
|
|||
|
+ if (!signal) {
|
|||
|
+ return;
|
|||
|
+ }
|
|||
|
+ if (typeof signal.throwIfAborted === "function") {
|
|||
|
+ signal.throwIfAborted();
|
|||
|
+ } else {
|
|||
|
+ if (signal.aborted) {
|
|||
|
+ const err = new Error("The operation was aborted");
|
|||
|
+ err.name = "AbortError";
|
|||
|
+ throw err;
|
|||
|
+ }
|
|||
|
+ }
|
|||
|
+ }
|
|||
|
+ var hasToWellFormed = !!String.prototype.toWellFormed;
|
|||
|
+ function toUSVString(val) {
|
|||
|
+ if (hasToWellFormed) {
|
|||
|
+ return `${val}`.toWellFormed();
|
|||
|
+ } else if (nodeUtil.toUSVString) {
|
|||
|
+ return nodeUtil.toUSVString(val);
|
|||
|
+ }
|
|||
|
+ return `${val}`;
|
|||
|
}
|
|||
|
var kEnumerableProperty = /* @__PURE__ */ Object.create(null);
|
|||
|
kEnumerableProperty.enumerable = true;
|
|||
|
@@ -560,7 +599,7 @@ var require_util = __commonJS({
|
|||
|
isDisturbed,
|
|||
|
isErrored,
|
|||
|
isReadable,
|
|||
|
- toUSVString: nodeUtil.toUSVString || ((val) => `${val}`),
|
|||
|
+ toUSVString,
|
|||
|
isReadableAborted,
|
|||
|
isBlobLike,
|
|||
|
parseOrigin,
|
|||
|
@@ -582,6 +621,7 @@ var require_util = __commonJS({
|
|||
|
getSocketInfo,
|
|||
|
isFormDataLike,
|
|||
|
buildURL,
|
|||
|
+ throwIfAborted,
|
|||
|
nodeMajor,
|
|||
|
nodeMinor,
|
|||
|
nodeHasAutoSelectFamily: nodeMajor > 18 || nodeMajor === 18 && nodeMinor >= 13
|
|||
|
@@ -706,7 +746,8 @@ var require_constants = __commonJS({
|
|||
|
"content-encoding",
|
|||
|
"content-language",
|
|||
|
"content-location",
|
|||
|
- "content-type"
|
|||
|
+ "content-type",
|
|||
|
+ "content-length"
|
|||
|
];
|
|||
|
var requestDuplex = [
|
|||
|
"half"
|
|||
|
@@ -767,11 +808,51 @@ var require_constants = __commonJS({
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
+// lib/fetch/global.js
|
|||
|
+var require_global = __commonJS({
|
|||
|
+ "lib/fetch/global.js"(exports2, module2) {
|
|||
|
+ "use strict";
|
|||
|
+ var globalOrigin = Symbol.for("undici.globalOrigin.1");
|
|||
|
+ function getGlobalOrigin() {
|
|||
|
+ return globalThis[globalOrigin];
|
|||
|
+ }
|
|||
|
+ function setGlobalOrigin(newOrigin) {
|
|||
|
+ if (newOrigin !== void 0 && typeof newOrigin !== "string" && !(newOrigin instanceof URL)) {
|
|||
|
+ throw new Error("Invalid base url");
|
|||
|
+ }
|
|||
|
+ if (newOrigin === void 0) {
|
|||
|
+ Object.defineProperty(globalThis, globalOrigin, {
|
|||
|
+ value: void 0,
|
|||
|
+ writable: true,
|
|||
|
+ enumerable: false,
|
|||
|
+ configurable: false
|
|||
|
+ });
|
|||
|
+ return;
|
|||
|
+ }
|
|||
|
+ const parsedURL = new URL(newOrigin);
|
|||
|
+ if (parsedURL.protocol !== "http:" && parsedURL.protocol !== "https:") {
|
|||
|
+ throw new TypeError(`Only http & https urls are allowed, received ${parsedURL.protocol}`);
|
|||
|
+ }
|
|||
|
+ Object.defineProperty(globalThis, globalOrigin, {
|
|||
|
+ value: parsedURL,
|
|||
|
+ writable: true,
|
|||
|
+ enumerable: false,
|
|||
|
+ configurable: false
|
|||
|
+ });
|
|||
|
+ }
|
|||
|
+ module2.exports = {
|
|||
|
+ getGlobalOrigin,
|
|||
|
+ setGlobalOrigin
|
|||
|
+ };
|
|||
|
+ }
|
|||
|
+});
|
|||
|
+
|
|||
|
// lib/fetch/util.js
|
|||
|
var require_util2 = __commonJS({
|
|||
|
"lib/fetch/util.js"(exports2, module2) {
|
|||
|
"use strict";
|
|||
|
var { redirectStatus, badPorts, referrerPolicy: referrerPolicyTokens } = require_constants();
|
|||
|
+ var { getGlobalOrigin } = require_global();
|
|||
|
var { performance: performance2 } = require("perf_hooks");
|
|||
|
var { isBlobLike, toUSVString, ReadableStreamFrom } = require_util();
|
|||
|
var assert = require("assert");
|
|||
|
@@ -791,7 +872,9 @@ var require_util2 = __commonJS({
|
|||
|
return null;
|
|||
|
}
|
|||
|
let location = response.headersList.get("location");
|
|||
|
- location = location ? new URL(location, responseURL(response)) : null;
|
|||
|
+ if (location !== null && isValidHeaderValue(location)) {
|
|||
|
+ location = new URL(location, responseURL(response));
|
|||
|
+ }
|
|||
|
if (location && !location.hash) {
|
|||
|
location.hash = requestFragment;
|
|||
|
}
|
|||
|
@@ -802,7 +885,7 @@ var require_util2 = __commonJS({
|
|||
|
}
|
|||
|
function requestBadPort(request) {
|
|||
|
const url = requestCurrentURL(request);
|
|||
|
- if (/^https?:/.test(url.protocol) && badPorts.includes(url.port)) {
|
|||
|
+ if (urlIsHttpHttpsScheme(url) && badPorts.includes(url.port)) {
|
|||
|
return "blocked";
|
|||
|
}
|
|||
|
return "allowed";
|
|||
|
@@ -884,7 +967,7 @@ var require_util2 = __commonJS({
|
|||
|
let serializedOrigin = request.origin;
|
|||
|
if (request.responseTainting === "cors" || request.mode === "websocket") {
|
|||
|
if (serializedOrigin) {
|
|||
|
- request.headersList.append("Origin", serializedOrigin);
|
|||
|
+ request.headersList.append("origin", serializedOrigin);
|
|||
|
}
|
|||
|
} else if (request.method !== "GET" && request.method !== "HEAD") {
|
|||
|
switch (request.referrerPolicy) {
|
|||
|
@@ -894,7 +977,7 @@ var require_util2 = __commonJS({
|
|||
|
case "no-referrer-when-downgrade":
|
|||
|
case "strict-origin":
|
|||
|
case "strict-origin-when-cross-origin":
|
|||
|
- if (/^https:/.test(request.origin) && !/^https:/.test(requestCurrentURL(request))) {
|
|||
|
+ if (request.origin && urlHasHttpsScheme(request.origin) && !urlHasHttpsScheme(requestCurrentURL(request))) {
|
|||
|
serializedOrigin = null;
|
|||
|
}
|
|||
|
break;
|
|||
|
@@ -906,7 +989,7 @@ var require_util2 = __commonJS({
|
|||
|
default:
|
|||
|
}
|
|||
|
if (serializedOrigin) {
|
|||
|
- request.headersList.append("Origin", serializedOrigin);
|
|||
|
+ request.headersList.append("origin", serializedOrigin);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
@@ -929,68 +1012,73 @@ var require_util2 = __commonJS({
|
|||
|
};
|
|||
|
}
|
|||
|
function makePolicyContainer() {
|
|||
|
- return {};
|
|||
|
+ return {
|
|||
|
+ referrerPolicy: "strict-origin-when-cross-origin"
|
|||
|
+ };
|
|||
|
}
|
|||
|
- function clonePolicyContainer() {
|
|||
|
- return {};
|
|||
|
+ function clonePolicyContainer(policyContainer) {
|
|||
|
+ return {
|
|||
|
+ referrerPolicy: policyContainer.referrerPolicy
|
|||
|
+ };
|
|||
|
}
|
|||
|
function determineRequestsReferrer(request) {
|
|||
|
const policy = request.referrerPolicy;
|
|||
|
- if (policy == null || policy === "" || policy === "no-referrer") {
|
|||
|
- return "no-referrer";
|
|||
|
- }
|
|||
|
- const environment = request.client;
|
|||
|
+ assert(policy);
|
|||
|
let referrerSource = null;
|
|||
|
if (request.referrer === "client") {
|
|||
|
- if (request.client?.globalObject?.constructor?.name === "Window") {
|
|||
|
- const origin = environment.globalObject.self?.origin ?? environment.globalObject.location?.origin;
|
|||
|
- if (origin == null || origin === "null")
|
|||
|
- return "no-referrer";
|
|||
|
- referrerSource = new URL(environment.globalObject.location.href);
|
|||
|
- } else {
|
|||
|
- if (environment?.globalObject?.location == null) {
|
|||
|
- return "no-referrer";
|
|||
|
- }
|
|||
|
- referrerSource = new URL(environment.globalObject.location.href);
|
|||
|
+ const globalOrigin = getGlobalOrigin();
|
|||
|
+ if (!globalOrigin || globalOrigin.origin === "null") {
|
|||
|
+ return "no-referrer";
|
|||
|
}
|
|||
|
+ referrerSource = new URL(globalOrigin);
|
|||
|
} else if (request.referrer instanceof URL) {
|
|||
|
referrerSource = request.referrer;
|
|||
|
- } else {
|
|||
|
- return "no-referrer";
|
|||
|
}
|
|||
|
- const urlProtocol = referrerSource.protocol;
|
|||
|
- if (urlProtocol === "about:" || urlProtocol === "data:" || urlProtocol === "blob:") {
|
|||
|
- return "no-referrer";
|
|||
|
+ let referrerURL = stripURLForReferrer(referrerSource);
|
|||
|
+ const referrerOrigin = stripURLForReferrer(referrerSource, true);
|
|||
|
+ if (referrerURL.toString().length > 4096) {
|
|||
|
+ referrerURL = referrerOrigin;
|
|||
|
}
|
|||
|
- let temp;
|
|||
|
- let referrerOrigin;
|
|||
|
- const referrerUrl = (temp = stripURLForReferrer(referrerSource)).length > 4096 ? referrerOrigin = stripURLForReferrer(referrerSource, true) : temp;
|
|||
|
- const areSameOrigin = sameOrigin(request, referrerUrl);
|
|||
|
- const isNonPotentiallyTrustWorthy = isURLPotentiallyTrustworthy(referrerUrl) && !isURLPotentiallyTrustworthy(request.url);
|
|||
|
+ const areSameOrigin = sameOrigin(request, referrerURL);
|
|||
|
+ const isNonPotentiallyTrustWorthy = isURLPotentiallyTrustworthy(referrerURL) && !isURLPotentiallyTrustworthy(request.url);
|
|||
|
switch (policy) {
|
|||
|
case "origin":
|
|||
|
return referrerOrigin != null ? referrerOrigin : stripURLForReferrer(referrerSource, true);
|
|||
|
case "unsafe-url":
|
|||
|
- return referrerUrl;
|
|||
|
+ return referrerURL;
|
|||
|
case "same-origin":
|
|||
|
return areSameOrigin ? referrerOrigin : "no-referrer";
|
|||
|
case "origin-when-cross-origin":
|
|||
|
- return areSameOrigin ? referrerUrl : referrerOrigin;
|
|||
|
- case "strict-origin-when-cross-origin":
|
|||
|
- if (areSameOrigin)
|
|||
|
- return referrerOrigin;
|
|||
|
+ return areSameOrigin ? referrerURL : referrerOrigin;
|
|||
|
+ case "strict-origin-when-cross-origin": {
|
|||
|
+ const currentURL = requestCurrentURL(request);
|
|||
|
+ if (sameOrigin(referrerURL, currentURL)) {
|
|||
|
+ return referrerURL;
|
|||
|
+ }
|
|||
|
+ if (isURLPotentiallyTrustworthy(referrerURL) && !isURLPotentiallyTrustworthy(currentURL)) {
|
|||
|
+ return "no-referrer";
|
|||
|
+ }
|
|||
|
+ return referrerOrigin;
|
|||
|
+ }
|
|||
|
case "strict-origin":
|
|||
|
case "no-referrer-when-downgrade":
|
|||
|
default:
|
|||
|
return isNonPotentiallyTrustWorthy ? "no-referrer" : referrerOrigin;
|
|||
|
}
|
|||
|
- function stripURLForReferrer(url, originOnly = false) {
|
|||
|
- const urlObject = new URL(url.href);
|
|||
|
- urlObject.username = "";
|
|||
|
- urlObject.password = "";
|
|||
|
- urlObject.hash = "";
|
|||
|
- return originOnly ? urlObject.origin : urlObject.href;
|
|||
|
+ }
|
|||
|
+ function stripURLForReferrer(url, originOnly) {
|
|||
|
+ assert(url instanceof URL);
|
|||
|
+ if (url.protocol === "file:" || url.protocol === "about:" || url.protocol === "blank:") {
|
|||
|
+ return "no-referrer";
|
|||
|
+ }
|
|||
|
+ url.username = "";
|
|||
|
+ url.password = "";
|
|||
|
+ url.hash = "";
|
|||
|
+ if (originOnly) {
|
|||
|
+ url.pathname = "";
|
|||
|
+ url.search = "";
|
|||
|
}
|
|||
|
+ return url;
|
|||
|
}
|
|||
|
function isURLPotentiallyTrustworthy(url) {
|
|||
|
if (!(url instanceof URL)) {
|
|||
|
@@ -1065,6 +1153,9 @@ var require_util2 = __commonJS({
|
|||
|
function tryUpgradeRequestToAPotentiallyTrustworthyURL(request) {
|
|||
|
}
|
|||
|
function sameOrigin(A, B) {
|
|||
|
+ if (A.origin === B.origin && A.origin === "null") {
|
|||
|
+ return true;
|
|||
|
+ }
|
|||
|
if (A.protocol === B.protocol && A.hostname === B.hostname && A.port === B.port) {
|
|||
|
return true;
|
|||
|
}
|
|||
|
@@ -1206,6 +1297,22 @@ var require_util2 = __commonJS({
|
|||
|
byteLength += chunk.length;
|
|||
|
}
|
|||
|
}
|
|||
|
+ function urlIsLocal(url) {
|
|||
|
+ assert("protocol" in url);
|
|||
|
+ const protocol = url.protocol;
|
|||
|
+ return protocol === "about:" || protocol === "blob:" || protocol === "data:";
|
|||
|
+ }
|
|||
|
+ function urlHasHttpsScheme(url) {
|
|||
|
+ if (typeof url === "string") {
|
|||
|
+ return url.startsWith("https:");
|
|||
|
+ }
|
|||
|
+ return url.protocol === "https:";
|
|||
|
+ }
|
|||
|
+ function urlIsHttpHttpsScheme(url) {
|
|||
|
+ assert("protocol" in url);
|
|||
|
+ const protocol = url.protocol;
|
|||
|
+ return protocol === "http:" || protocol === "https:";
|
|||
|
+ }
|
|||
|
var hasOwn = Object.hasOwn || ((dict, key) => Object.prototype.hasOwnProperty.call(dict, key));
|
|||
|
module2.exports = {
|
|||
|
isAborted,
|
|||
|
@@ -1246,7 +1353,11 @@ var require_util2 = __commonJS({
|
|||
|
isReadableStreamLike,
|
|||
|
readableStreamClose,
|
|||
|
isomorphicEncode,
|
|||
|
- isomorphicDecode
|
|||
|
+ isomorphicDecode,
|
|||
|
+ urlIsLocal,
|
|||
|
+ urlHasHttpsScheme,
|
|||
|
+ urlIsHttpHttpsScheme,
|
|||
|
+ readAllBytes
|
|||
|
};
|
|||
|
}
|
|||
|
});
|
|||
|
@@ -1293,6 +1404,12 @@ var require_webidl = __commonJS({
|
|||
|
});
|
|||
|
}
|
|||
|
};
|
|||
|
+ webidl.illegalConstructor = function() {
|
|||
|
+ throw webidl.errors.exception({
|
|||
|
+ header: "TypeError",
|
|||
|
+ message: "Illegal constructor"
|
|||
|
+ });
|
|||
|
+ };
|
|||
|
webidl.util.Type = function(V) {
|
|||
|
switch (typeof V) {
|
|||
|
case "undefined":
|
|||
|
@@ -1611,7 +1728,7 @@ var require_headers = __commonJS({
|
|||
|
"lib/fetch/headers.js"(exports2, module2) {
|
|||
|
"use strict";
|
|||
|
var { kHeadersList } = require_symbols();
|
|||
|
- var { kGuard, kHeadersCaseInsensitive } = require_symbols2();
|
|||
|
+ var { kGuard } = require_symbols2();
|
|||
|
var { kEnumerableProperty } = require_util();
|
|||
|
var {
|
|||
|
makeIterator,
|
|||
|
@@ -1670,6 +1787,7 @@ var require_headers = __commonJS({
|
|||
|
clear() {
|
|||
|
this[kHeadersMap].clear();
|
|||
|
this[kHeadersSortedMap] = null;
|
|||
|
+ this.cookies = null;
|
|||
|
}
|
|||
|
append(name, value) {
|
|||
|
this[kHeadersSortedMap] = null;
|
|||
|
@@ -1716,12 +1834,14 @@ var require_headers = __commonJS({
|
|||
|
yield [name, value];
|
|||
|
}
|
|||
|
}
|
|||
|
- get [kHeadersCaseInsensitive]() {
|
|||
|
- const flatList = [];
|
|||
|
- for (const { name, value } of this[kHeadersMap].values()) {
|
|||
|
- flatList.push(name, value);
|
|||
|
+ get entries() {
|
|||
|
+ const headers = {};
|
|||
|
+ if (this[kHeadersMap].size) {
|
|||
|
+ for (const { name, value } of this[kHeadersMap].values()) {
|
|||
|
+ headers[name] = value;
|
|||
|
+ }
|
|||
|
}
|
|||
|
- return flatList;
|
|||
|
+ return headers;
|
|||
|
}
|
|||
|
};
|
|||
|
var Headers = class {
|
|||
|
@@ -1891,6 +2011,7 @@ var require_headers = __commonJS({
|
|||
|
get: kEnumerableProperty,
|
|||
|
has: kEnumerableProperty,
|
|||
|
set: kEnumerableProperty,
|
|||
|
+ getSetCookie: kEnumerableProperty,
|
|||
|
keys: kEnumerableProperty,
|
|||
|
values: kEnumerableProperty,
|
|||
|
entries: kEnumerableProperty,
|
|||
|
@@ -5620,12 +5741,11 @@ var require_dataURL = __commonJS({
|
|||
|
"lib/fetch/dataURL.js"(exports2, module2) {
|
|||
|
var assert = require("assert");
|
|||
|
var { atob: atob2 } = require("buffer");
|
|||
|
- var { format } = require("url");
|
|||
|
- var { isValidHTTPToken, isomorphicDecode } = require_util2();
|
|||
|
+ var { isomorphicDecode } = require_util2();
|
|||
|
var encoder = new TextEncoder();
|
|||
|
- var HTTP_TOKEN_CODEPOINTS = /^[!#$%&'*+-.^_|~A-z0-9]+$/;
|
|||
|
+ var HTTP_TOKEN_CODEPOINTS = /^[!#$%&'*+-.^_|~A-Za-z0-9]+$/;
|
|||
|
var HTTP_WHITESPACE_REGEX = /(\u000A|\u000D|\u0009|\u0020)/;
|
|||
|
- var HTTP_QUOTED_STRING_TOKENS = /^(\u0009|\x{0020}-\x{007E}|\x{0080}-\x{00FF})+$/;
|
|||
|
+ var HTTP_QUOTED_STRING_TOKENS = /[\u0009|\u0020-\u007E|\u0080-\u00FF]/;
|
|||
|
function dataURLProcessor(dataURL) {
|
|||
|
assert(dataURL.protocol === "data:");
|
|||
|
let input = URLSerializer(dataURL, true);
|
|||
|
@@ -5633,7 +5753,7 @@ var require_dataURL = __commonJS({
|
|||
|
const position = { position: 0 };
|
|||
|
let mimeType = collectASequenceOfCodePointsFast(",", input, position);
|
|||
|
const mimeTypeLength = mimeType.length;
|
|||
|
- mimeType = mimeType.replace(/^(\u0020)+|(\u0020)+$/g, "");
|
|||
|
+ mimeType = removeASCIIWhitespace(mimeType, true, true);
|
|||
|
if (position.position >= input.length) {
|
|||
|
return "failure";
|
|||
|
}
|
|||
|
@@ -5660,7 +5780,15 @@ var require_dataURL = __commonJS({
|
|||
|
return { mimeType: mimeTypeRecord, body };
|
|||
|
}
|
|||
|
function URLSerializer(url, excludeFragment = false) {
|
|||
|
- return format(url, { fragment: !excludeFragment });
|
|||
|
+ const href = url.href;
|
|||
|
+ if (!excludeFragment) {
|
|||
|
+ return href;
|
|||
|
+ }
|
|||
|
+ const hash = href.lastIndexOf("#");
|
|||
|
+ if (hash === -1) {
|
|||
|
+ return href;
|
|||
|
+ }
|
|||
|
+ return href.slice(0, hash);
|
|||
|
}
|
|||
|
function collectASequenceOfCodePoints(condition, input, position) {
|
|||
|
let result = "";
|
|||
|
@@ -5702,7 +5830,7 @@ var require_dataURL = __commonJS({
|
|||
|
return Uint8Array.from(output);
|
|||
|
}
|
|||
|
function parseMIMEType(input) {
|
|||
|
- input = input.trim();
|
|||
|
+ input = removeHTTPWhitespace(input, true, true);
|
|||
|
const position = { position: 0 };
|
|||
|
const type = collectASequenceOfCodePointsFast("/", input, position);
|
|||
|
if (type.length === 0 || !HTTP_TOKEN_CODEPOINTS.test(type)) {
|
|||
|
@@ -5713,15 +5841,17 @@ var require_dataURL = __commonJS({
|
|||
|
}
|
|||
|
position.position++;
|
|||
|
let subtype = collectASequenceOfCodePointsFast(";", input, position);
|
|||
|
- subtype = subtype.trimEnd();
|
|||
|
+ subtype = removeHTTPWhitespace(subtype, false, true);
|
|||
|
if (subtype.length === 0 || !HTTP_TOKEN_CODEPOINTS.test(subtype)) {
|
|||
|
return "failure";
|
|||
|
}
|
|||
|
+ const typeLowercase = type.toLowerCase();
|
|||
|
+ const subtypeLowercase = subtype.toLowerCase();
|
|||
|
const mimeType = {
|
|||
|
- type: type.toLowerCase(),
|
|||
|
- subtype: subtype.toLowerCase(),
|
|||
|
+ type: typeLowercase,
|
|||
|
+ subtype: subtypeLowercase,
|
|||
|
parameters: /* @__PURE__ */ new Map(),
|
|||
|
- essence: `${type}/${subtype}`
|
|||
|
+ essence: `${typeLowercase}/${subtypeLowercase}`
|
|||
|
};
|
|||
|
while (position.position < input.length) {
|
|||
|
position.position++;
|
|||
|
@@ -5743,12 +5873,12 @@ var require_dataURL = __commonJS({
|
|||
|
collectASequenceOfCodePointsFast(";", input, position);
|
|||
|
} else {
|
|||
|
parameterValue = collectASequenceOfCodePointsFast(";", input, position);
|
|||
|
- parameterValue = parameterValue.trimEnd();
|
|||
|
+ parameterValue = removeHTTPWhitespace(parameterValue, false, true);
|
|||
|
if (parameterValue.length === 0) {
|
|||
|
continue;
|
|||
|
}
|
|||
|
}
|
|||
|
- if (parameterName.length !== 0 && HTTP_TOKEN_CODEPOINTS.test(parameterName) && !HTTP_QUOTED_STRING_TOKENS.test(parameterValue) && !mimeType.parameters.has(parameterName)) {
|
|||
|
+ if (parameterName.length !== 0 && HTTP_TOKEN_CODEPOINTS.test(parameterName) && (parameterValue.length === 0 || HTTP_QUOTED_STRING_TOKENS.test(parameterValue)) && !mimeType.parameters.has(parameterName)) {
|
|||
|
mimeType.parameters.set(parameterName, parameterValue);
|
|||
|
}
|
|||
|
}
|
|||
|
@@ -5803,13 +5933,13 @@ var require_dataURL = __commonJS({
|
|||
|
}
|
|||
|
function serializeAMimeType(mimeType) {
|
|||
|
assert(mimeType !== "failure");
|
|||
|
- const { type, subtype, parameters } = mimeType;
|
|||
|
- let serialization = `${type}/${subtype}`;
|
|||
|
+ const { parameters, essence } = mimeType;
|
|||
|
+ let serialization = essence;
|
|||
|
for (let [name, value] of parameters.entries()) {
|
|||
|
serialization += ";";
|
|||
|
serialization += name;
|
|||
|
serialization += "=";
|
|||
|
- if (!isValidHTTPToken(value)) {
|
|||
|
+ if (!HTTP_TOKEN_CODEPOINTS.test(value)) {
|
|||
|
value = value.replace(/(\\|")/g, "\\$1");
|
|||
|
value = '"' + value;
|
|||
|
value += '"';
|
|||
|
@@ -5818,6 +5948,38 @@ var require_dataURL = __commonJS({
|
|||
|
}
|
|||
|
return serialization;
|
|||
|
}
|
|||
|
+ function isHTTPWhiteSpace(char) {
|
|||
|
+ return char === "\r" || char === "\n" || char === " " || char === " ";
|
|||
|
+ }
|
|||
|
+ function removeHTTPWhitespace(str, leading = true, trailing = true) {
|
|||
|
+ let lead = 0;
|
|||
|
+ let trail = str.length - 1;
|
|||
|
+ if (leading) {
|
|||
|
+ for (; lead < str.length && isHTTPWhiteSpace(str[lead]); lead++)
|
|||
|
+ ;
|
|||
|
+ }
|
|||
|
+ if (trailing) {
|
|||
|
+ for (; trail > 0 && isHTTPWhiteSpace(str[trail]); trail--)
|
|||
|
+ ;
|
|||
|
+ }
|
|||
|
+ return str.slice(lead, trail + 1);
|
|||
|
+ }
|
|||
|
+ function isASCIIWhitespace(char) {
|
|||
|
+ return char === "\r" || char === "\n" || char === " " || char === "\f" || char === " ";
|
|||
|
+ }
|
|||
|
+ function removeASCIIWhitespace(str, leading = true, trailing = true) {
|
|||
|
+ let lead = 0;
|
|||
|
+ let trail = str.length - 1;
|
|||
|
+ if (leading) {
|
|||
|
+ for (; lead < str.length && isASCIIWhitespace(str[lead]); lead++)
|
|||
|
+ ;
|
|||
|
+ }
|
|||
|
+ if (trailing) {
|
|||
|
+ for (; trail > 0 && isASCIIWhitespace(str[trail]); trail--)
|
|||
|
+ ;
|
|||
|
+ }
|
|||
|
+ return str.slice(lead, trail + 1);
|
|||
|
+ }
|
|||
|
module2.exports = {
|
|||
|
dataURLProcessor,
|
|||
|
URLSerializer,
|
|||
|
@@ -6049,13 +6211,7 @@ var require_formdata = __commonJS({
|
|||
|
webidl.brandCheck(this, FormData);
|
|||
|
webidl.argumentLengthCheck(arguments, 1, { header: "FormData.delete" });
|
|||
|
name = webidl.converters.USVString(name);
|
|||
|
- const next = [];
|
|||
|
- for (const entry of this[kState]) {
|
|||
|
- if (entry.name !== name) {
|
|||
|
- next.push(entry);
|
|||
|
- }
|
|||
|
- }
|
|||
|
- this[kState] = next;
|
|||
|
+ this[kState] = this[kState].filter((entry) => entry.name !== name);
|
|||
|
}
|
|||
|
get(name) {
|
|||
|
webidl.brandCheck(this, FormData);
|
|||
|
@@ -6224,6 +6380,7 @@ Content-Disposition: form-data`;
|
|||
|
const blobParts = [];
|
|||
|
const rn = new Uint8Array([13, 10]);
|
|||
|
length = 0;
|
|||
|
+ let hasUnknownSizeValue = false;
|
|||
|
for (const [name, value] of object) {
|
|||
|
if (typeof value === "string") {
|
|||
|
const chunk2 = enc.encode(prefix + `; name="${escape(normalizeLinefeeds(name))}"\r
|
|||
|
@@ -6238,12 +6395,19 @@ Content-Type: ${value.type || "applicati
|
|||
|
\r
|
|||
|
`);
|
|||
|
blobParts.push(chunk2, value, rn);
|
|||
|
- length += chunk2.byteLength + value.size + rn.byteLength;
|
|||
|
+ if (typeof value.size === "number") {
|
|||
|
+ length += chunk2.byteLength + value.size + rn.byteLength;
|
|||
|
+ } else {
|
|||
|
+ hasUnknownSizeValue = true;
|
|||
|
+ }
|
|||
|
}
|
|||
|
}
|
|||
|
const chunk = enc.encode(`--${boundary}--`);
|
|||
|
blobParts.push(chunk);
|
|||
|
length += chunk.byteLength;
|
|||
|
+ if (hasUnknownSizeValue) {
|
|||
|
+ length = null;
|
|||
|
+ }
|
|||
|
source = object;
|
|||
|
action = async function* () {
|
|||
|
for (const part of blobParts) {
|
|||
|
@@ -6514,45 +6678,6 @@ Content-Type: ${value.type || "applicati
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
-// lib/fetch/global.js
|
|||
|
-var require_global = __commonJS({
|
|||
|
- "lib/fetch/global.js"(exports2, module2) {
|
|||
|
- "use strict";
|
|||
|
- var globalOrigin = Symbol.for("undici.globalOrigin.1");
|
|||
|
- function getGlobalOrigin() {
|
|||
|
- return globalThis[globalOrigin];
|
|||
|
- }
|
|||
|
- function setGlobalOrigin(newOrigin) {
|
|||
|
- if (newOrigin !== void 0 && typeof newOrigin !== "string" && !(newOrigin instanceof URL)) {
|
|||
|
- throw new Error("Invalid base url");
|
|||
|
- }
|
|||
|
- if (newOrigin === void 0) {
|
|||
|
- Object.defineProperty(globalThis, globalOrigin, {
|
|||
|
- value: void 0,
|
|||
|
- writable: true,
|
|||
|
- enumerable: false,
|
|||
|
- configurable: false
|
|||
|
- });
|
|||
|
- return;
|
|||
|
- }
|
|||
|
- const parsedURL = new URL(newOrigin);
|
|||
|
- if (parsedURL.protocol !== "http:" && parsedURL.protocol !== "https:") {
|
|||
|
- throw new TypeError(`Only http & https urls are allowed, received ${parsedURL.protocol}`);
|
|||
|
- }
|
|||
|
- Object.defineProperty(globalThis, globalOrigin, {
|
|||
|
- value: parsedURL,
|
|||
|
- writable: true,
|
|||
|
- enumerable: false,
|
|||
|
- configurable: false
|
|||
|
- });
|
|||
|
- }
|
|||
|
- module2.exports = {
|
|||
|
- getGlobalOrigin,
|
|||
|
- setGlobalOrigin
|
|||
|
- };
|
|||
|
- }
|
|||
|
-});
|
|||
|
-
|
|||
|
// lib/fetch/response.js
|
|||
|
var require_response = __commonJS({
|
|||
|
"lib/fetch/response.js"(exports2, module2) {
|
|||
|
@@ -6765,9 +6890,7 @@ var require_response = __commonJS({
|
|||
|
return makeResponse({
|
|||
|
type: "error",
|
|||
|
status: 0,
|
|||
|
- error: isError ? reason : new Error(reason ? String(reason) : reason, {
|
|||
|
- cause: isError ? reason : void 0
|
|||
|
- }),
|
|||
|
+ error: isError ? reason : new Error(reason ? String(reason) : reason),
|
|||
|
aborted: reason && reason.name === "AbortError"
|
|||
|
});
|
|||
|
}
|
|||
|
@@ -6838,7 +6961,7 @@ var require_response = __commonJS({
|
|||
|
response[kState].statusText = init.statusText;
|
|||
|
}
|
|||
|
if ("headers" in init && init.headers != null) {
|
|||
|
- fill(response[kState].headersList, init.headers);
|
|||
|
+ fill(response[kHeaders], init.headers);
|
|||
|
}
|
|||
|
if (body) {
|
|||
|
if (nullBodyStatus.includes(response.status)) {
|
|||
|
@@ -6904,7 +7027,8 @@ var require_response = __commonJS({
|
|||
|
makeResponse,
|
|||
|
makeAppropriateNetworkError,
|
|||
|
filterResponse,
|
|||
|
- Response
|
|||
|
+ Response,
|
|||
|
+ cloneResponse
|
|||
|
};
|
|||
|
}
|
|||
|
});
|
|||
|
@@ -6954,7 +7078,8 @@ var require_request = __commonJS({
|
|||
|
var {
|
|||
|
isValidHTTPToken,
|
|||
|
sameOrigin,
|
|||
|
- normalizeMethod
|
|||
|
+ normalizeMethod,
|
|||
|
+ makePolicyContainer
|
|||
|
} = require_util2();
|
|||
|
var {
|
|||
|
forbiddenMethods,
|
|||
|
@@ -6973,9 +7098,10 @@ var require_request = __commonJS({
|
|||
|
var { URLSerializer } = require_dataURL();
|
|||
|
var { kHeadersList } = require_symbols();
|
|||
|
var assert = require("assert");
|
|||
|
- var { setMaxListeners, getEventListeners, defaultMaxListeners } = require("events");
|
|||
|
+ var { getMaxListeners, setMaxListeners, getEventListeners, defaultMaxListeners } = require("events");
|
|||
|
var TransformStream = globalThis.TransformStream;
|
|||
|
var kInit = Symbol("init");
|
|||
|
+ var kAbortController = Symbol("abortController");
|
|||
|
var requestFinalizer = new FinalizationRegistry(({ signal, abort }) => {
|
|||
|
signal.removeEventListener("abort", abort);
|
|||
|
});
|
|||
|
@@ -6989,7 +7115,11 @@ var require_request = __commonJS({
|
|||
|
init = webidl.converters.RequestInit(init);
|
|||
|
this[kRealm] = {
|
|||
|
settingsObject: {
|
|||
|
- baseUrl: getGlobalOrigin()
|
|||
|
+ baseUrl: getGlobalOrigin(),
|
|||
|
+ get origin() {
|
|||
|
+ return this.baseUrl?.origin;
|
|||
|
+ },
|
|||
|
+ policyContainer: makePolicyContainer()
|
|||
|
}
|
|||
|
};
|
|||
|
let request = null;
|
|||
|
@@ -7018,10 +7148,10 @@ var require_request = __commonJS({
|
|||
|
if (request.window?.constructor?.name === "EnvironmentSettingsObject" && sameOrigin(request.window, origin)) {
|
|||
|
window = request.window;
|
|||
|
}
|
|||
|
- if (init.window !== void 0 && init.window != null) {
|
|||
|
+ if (init.window != null) {
|
|||
|
throw new TypeError(`'window' option '${window}' must be null`);
|
|||
|
}
|
|||
|
- if (init.window !== void 0) {
|
|||
|
+ if ("window" in init) {
|
|||
|
window = "no-window";
|
|||
|
}
|
|||
|
request = makeRequest({
|
|||
|
@@ -7131,15 +7261,24 @@ var require_request = __commonJS({
|
|||
|
if (signal.aborted) {
|
|||
|
ac.abort(signal.reason);
|
|||
|
} else {
|
|||
|
+ this[kAbortController] = ac;
|
|||
|
const acRef = new WeakRef(ac);
|
|||
|
const abort = function() {
|
|||
|
- acRef.deref()?.abort(this.reason);
|
|||
|
+ const ac2 = acRef.deref();
|
|||
|
+ if (ac2 !== void 0) {
|
|||
|
+ ac2.abort(this.reason);
|
|||
|
+ }
|
|||
|
};
|
|||
|
- if (getEventListeners(signal, "abort").length >= defaultMaxListeners) {
|
|||
|
- setMaxListeners(100, signal);
|
|||
|
+ try {
|
|||
|
+ if (typeof getMaxListeners === "function" && getMaxListeners(signal) === defaultMaxListeners) {
|
|||
|
+ setMaxListeners(100, signal);
|
|||
|
+ } else if (getEventListeners(signal, "abort").length >= defaultMaxListeners) {
|
|||
|
+ setMaxListeners(100, signal);
|
|||
|
+ }
|
|||
|
+ } catch {
|
|||
|
}
|
|||
|
signal.addEventListener("abort", abort, { once: true });
|
|||
|
- requestFinalizer.register(this, { signal, abort });
|
|||
|
+ requestFinalizer.register(ac, { signal, abort });
|
|||
|
}
|
|||
|
}
|
|||
|
this[kHeaders] = new Headers();
|
|||
|
@@ -7167,11 +7306,11 @@ var require_request = __commonJS({
|
|||
|
}
|
|||
|
}
|
|||
|
const inputBody = input instanceof Request ? input[kState].body : null;
|
|||
|
- if ((init.body !== void 0 && init.body != null || inputBody != null) && (request.method === "GET" || request.method === "HEAD")) {
|
|||
|
+ if ((init.body != null || inputBody != null) && (request.method === "GET" || request.method === "HEAD")) {
|
|||
|
throw new TypeError("Request with GET/HEAD method cannot have body.");
|
|||
|
}
|
|||
|
let initBody = null;
|
|||
|
- if (init.body !== void 0 && init.body != null) {
|
|||
|
+ if (init.body != null) {
|
|||
|
const [extractedBody, contentType] = extractBody(init.body, request.keepalive);
|
|||
|
initBody = extractedBody;
|
|||
|
if (contentType && !this[kHeaders][kHeadersList].contains("content-type")) {
|
|||
|
@@ -7504,7 +7643,7 @@ var require_dispatcher_base = __commonJS
|
|||
|
constructor() {
|
|||
|
super();
|
|||
|
this[kDestroyed] = false;
|
|||
|
- this[kOnDestroyed] = [];
|
|||
|
+ this[kOnDestroyed] = null;
|
|||
|
this[kClosed] = false;
|
|||
|
this[kOnClosed] = [];
|
|||
|
}
|
|||
|
@@ -7591,6 +7730,7 @@ var require_dispatcher_base = __commonJS
|
|||
|
err = new ClientDestroyedError();
|
|||
|
}
|
|||
|
this[kDestroyed] = true;
|
|||
|
+ this[kOnDestroyed] = this[kOnDestroyed] || [];
|
|||
|
this[kOnDestroyed].push(callback);
|
|||
|
const onDestroyed = () => {
|
|||
|
const callbacks = this[kOnDestroyed];
|
|||
|
@@ -7623,7 +7763,7 @@ var require_dispatcher_base = __commonJS
|
|||
|
if (!opts || typeof opts !== "object") {
|
|||
|
throw new InvalidArgumentError("opts must be an object.");
|
|||
|
}
|
|||
|
- if (this[kDestroyed]) {
|
|||
|
+ if (this[kDestroyed] || this[kOnDestroyed]) {
|
|||
|
throw new ClientDestroyedError();
|
|||
|
}
|
|||
|
if (this[kClosed]) {
|
|||
|
@@ -7900,12 +8040,14 @@ var require_timers = __commonJS({
|
|||
|
let idx = 0;
|
|||
|
while (idx < len) {
|
|||
|
const timer = fastTimers[idx];
|
|||
|
- if (timer.expires && fastNow >= timer.expires) {
|
|||
|
- timer.expires = 0;
|
|||
|
+ if (timer.state === 0) {
|
|||
|
+ timer.state = fastNow + timer.delay;
|
|||
|
+ } else if (timer.state > 0 && fastNow >= timer.state) {
|
|||
|
+ timer.state = -1;
|
|||
|
timer.callback(timer.opaque);
|
|||
|
}
|
|||
|
- if (timer.expires === 0) {
|
|||
|
- timer.active = false;
|
|||
|
+ if (timer.state === -1) {
|
|||
|
+ timer.state = -2;
|
|||
|
if (idx !== len - 1) {
|
|||
|
fastTimers[idx] = fastTimers.pop();
|
|||
|
} else {
|
|||
|
@@ -7936,32 +8078,31 @@ var require_timers = __commonJS({
|
|||
|
this.callback = callback;
|
|||
|
this.delay = delay;
|
|||
|
this.opaque = opaque;
|
|||
|
- this.expires = 0;
|
|||
|
- this.active = false;
|
|||
|
+ this.state = -2;
|
|||
|
this.refresh();
|
|||
|
}
|
|||
|
refresh() {
|
|||
|
- if (!this.active) {
|
|||
|
- this.active = true;
|
|||
|
+ if (this.state === -2) {
|
|||
|
fastTimers.push(this);
|
|||
|
if (!fastNowTimeout || fastTimers.length === 1) {
|
|||
|
refreshTimeout();
|
|||
|
- fastNow = Date.now();
|
|||
|
}
|
|||
|
}
|
|||
|
- this.expires = fastNow + this.delay;
|
|||
|
+ this.state = 0;
|
|||
|
}
|
|||
|
clear() {
|
|||
|
- this.expires = 0;
|
|||
|
+ this.state = -1;
|
|||
|
}
|
|||
|
};
|
|||
|
module2.exports = {
|
|||
|
setTimeout(callback, delay, opaque) {
|
|||
|
- return new Timeout(callback, delay, opaque);
|
|||
|
+ return delay < 1e3 ? setTimeout(callback, delay, opaque) : new Timeout(callback, delay, opaque);
|
|||
|
},
|
|||
|
clearTimeout(timeout) {
|
|||
|
- if (timeout && timeout.clear) {
|
|||
|
+ if (timeout instanceof Timeout) {
|
|||
|
timeout.clear();
|
|||
|
+ } else {
|
|||
|
+ clearTimeout(timeout);
|
|||
|
}
|
|||
|
}
|
|||
|
};
|
|||
|
@@ -8100,6 +8241,7 @@ var require_request2 = __commonJS({
|
|||
|
`;
|
|||
|
}
|
|||
|
this.body = bodyStream.stream;
|
|||
|
+ this.contentLength = bodyStream.length;
|
|||
|
} else if (util.isBlobLike(body) && this.contentType == null && body.type) {
|
|||
|
this.contentType = body.type;
|
|||
|
this.headers += `content-type: ${body.type}\r
|
|||
|
@@ -8884,16 +9026,16 @@ var require_redirectInterceptor = __comm
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
-// lib/llhttp/llhttp.wasm.js
|
|||
|
+// lib/llhttp/llhttp-wasm.js
|
|||
|
var require_llhttp_wasm = __commonJS({
|
|||
|
- "lib/llhttp/llhttp.wasm.js"(exports2, module2) {
|
|||
|
+ "lib/llhttp/llhttp-wasm.js"(exports2, module2) {
|
|||
|
module2.exports = "AGFzbQEAAAABMAhgAX8Bf2ADf39/AX9gBH9/f38Bf2AAAGADf39/AGABfwBgAn9/AGAGf39/f39/AALLAQgDZW52GHdhc21fb25faGVhZGVyc19jb21wbGV0ZQACA2VudhV3YXNtX29uX21lc3NhZ2VfYmVnaW4AAANlbnYLd2FzbV9vbl91cmwAAQNlbnYOd2FzbV9vbl9zdGF0dXMAAQNlbnYUd2FzbV9vbl9oZWFkZXJfZmllbGQAAQNlbnYUd2FzbV9vbl9oZWFkZXJfdmFsdWUAAQNlbnYMd2FzbV9vbl9ib2R5AAEDZW52GHdhc21fb25fbWVzc2FnZV9jb21wbGV0ZQAAA0ZFAwMEAAAFAAAAAAAABQEFAAUFBQAABgAAAAAGBgYGAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQABAAABAQcAAAUFAAMBBAUBcAESEgUDAQACBggBfwFBgNQECwfRBSIGbWVtb3J5AgALX2luaXRpYWxpemUACRlfX2luZGlyZWN0X2Z1bmN0aW9uX3RhYmxlAQALbGxodHRwX2luaXQAChhsbGh0dHBfc2hvdWxkX2tlZXBfYWxpdmUAQQxsbGh0dHBfYWxsb2MADAZtYWxsb2MARgtsbGh0dHBfZnJlZQANBGZyZWUASA9sbGh0dHBfZ2V0X3R5cGUADhVsbGh0dHBfZ2V0X2h0dHBfbWFqb3IADxVsbGh0dHBfZ2V0X2h0dHBfbWlub3IAEBFsbGh0dHBfZ2V0X21ldGhvZAARFmxsaHR0cF9nZXRfc3RhdHVzX2NvZGUAEhJsbGh0dHBfZ2V0X3VwZ3JhZGU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
|
|
|||
|
-// lib/llhttp/llhttp_simd.wasm.js
|
|||
|
+// lib/llhttp/llhttp_simd-wasm.js
|
|||
|
var require_llhttp_simd_wasm = __commonJS({
|
|||
|
- "lib/llhttp/llhttp_simd.wasm.js"(exports2, module2) {
|
|||
|
+ "lib/llhttp/llhttp_simd-wasm.js"(exports2, module2) {
|
|||
|
module2.exports = "AGFzbQEAAAABMAhgAX8Bf2ADf39/AX9gBH9/f38Bf2AAAGADf39/AGABfwBgAn9/AGAGf39/f39/AALLAQgDZW52GHdhc21fb25faGVhZGVyc19jb21wbGV0ZQACA2VudhV3YXNtX29uX21lc3NhZ2VfYmVnaW4AAANlbnYLd2FzbV9vbl91cmwAAQNlbnYOd2FzbV9vbl9zdGF0dXMAAQNlbnYUd2FzbV9vbl9oZWFkZXJfZmllbGQAAQNlbnYUd2FzbV9vbl9oZWFkZXJfdmFsdWUAAQNlbnYMd2FzbV9vbl9ib2R5AAEDZW52GHdhc21fb25fbWVzc2FnZV9jb21wbGV0ZQAAA0ZFAwMEAAAFAAAAAAAABQEFAAUFBQAABgAAAAAGBgYGAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQABAAABAQcAAAUFAAMBBAUBcAESEgUDAQACBggBfwFBgNQECwfRBSIGbWVtb3J5AgALX2luaXRpYWxpemUACRlfX2luZGlyZWN0X2Z1bmN0aW9uX3RhYmxlAQALbGxodHRwX2luaXQAChhsbGh0dHBfc2hvdWxkX2tlZXBfYWxpdmUAQQxsbGh0dHBfYWxsb2MADAZtYWxsb2MARgtsbGh0dHBfZnJlZQANBGZyZWUASA9sbGh0dHBfZ2V0X3R5cGUADhVsbGh0dHBfZ2V0X2h0dHBfbWFqb3IADxVsbGh0dHBfZ2V0X2h0dHBfbWlub3IAEBFsbGh0dHBfZ2V0X21ldGhvZAARFmxsaHR0cF9nZXRfc3RhdHVzX2NvZGUAEhJsbGh0dHBfZ2V0X3VwZ3JhZGUAEwxsbGh0dHBfcmVzZXQAFA5sbGh0dHBf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|
|||
|
InformationalError,
|
|||
|
BodyTimeoutError,
|
|||
|
HTTPParserError,
|
|||
|
- ResponseExceededMaxSizeError
|
|||
|
+ ResponseExceededMaxSizeError,
|
|||
|
+ ClientDestroyedError
|
|||
|
} = require_errors();
|
|||
|
var buildConnector = require_connect();
|
|||
|
var {
|
|||
|
@@ -9150,7 +9293,7 @@ var require_client = __commonJS({
|
|||
|
async [kClose]() {
|
|||
|
return new Promise((resolve) => {
|
|||
|
if (!this[kSize]) {
|
|||
|
- this.destroy(resolve);
|
|||
|
+ resolve(null);
|
|||
|
} else {
|
|||
|
this[kClosedResolve] = resolve;
|
|||
|
}
|
|||
|
@@ -9346,7 +9489,7 @@ var require_client = __commonJS({
|
|||
|
let message = "";
|
|||
|
if (ptr) {
|
|||
|
const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0);
|
|||
|
- message = Buffer.from(llhttp.memory.buffer, ptr, len).toString();
|
|||
|
+ message = "Response does not match the HTTP/1.1 protocol (" + Buffer.from(llhttp.memory.buffer, ptr, len).toString() + ")";
|
|||
|
}
|
|||
|
throw new HTTPParserError(message, constants.ERROR[ret], data.slice(offset));
|
|||
|
}
|
|||
|
@@ -9714,6 +9857,11 @@ var require_client = __commonJS({
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
+ if (client.destroyed) {
|
|||
|
+ util.destroy(socket.on("error", () => {
|
|||
|
+ }), new ClientDestroyedError());
|
|||
|
+ return;
|
|||
|
+ }
|
|||
|
if (!llhttpInstance) {
|
|||
|
llhttpInstance = await llhttpPromise;
|
|||
|
llhttpPromise = null;
|
|||
|
@@ -9747,6 +9895,9 @@ var require_client = __commonJS({
|
|||
|
}
|
|||
|
client.emit("connect", client[kUrl], [client]);
|
|||
|
} catch (err) {
|
|||
|
+ if (client.destroyed) {
|
|||
|
+ return;
|
|||
|
+ }
|
|||
|
client[kConnecting] = false;
|
|||
|
if (channels.connectError.hasSubscribers) {
|
|||
|
channels.connectError.publish({
|
|||
|
@@ -9798,8 +9949,9 @@ var require_client = __commonJS({
|
|||
|
assert(client[kPending] === 0);
|
|||
|
return;
|
|||
|
}
|
|||
|
- if (client.closed && !client[kSize]) {
|
|||
|
- client.destroy();
|
|||
|
+ if (client[kClosedResolve] && !client[kSize]) {
|
|||
|
+ client[kClosedResolve]();
|
|||
|
+ client[kClosedResolve] = null;
|
|||
|
return;
|
|||
|
}
|
|||
|
const socket = client[kSocket];
|
|||
|
@@ -9966,11 +10118,11 @@ upgrade: ${upgrade}\r
|
|||
|
if (contentLength === 0) {
|
|||
|
socket.write(`${header}content-length: 0\r
|
|||
|
\r
|
|||
|
-`, "ascii");
|
|||
|
+`, "latin1");
|
|||
|
} else {
|
|||
|
assert(contentLength === null, "no body must not have content length");
|
|||
|
socket.write(`${header}\r
|
|||
|
-`, "ascii");
|
|||
|
+`, "latin1");
|
|||
|
}
|
|||
|
request.onRequestSent();
|
|||
|
} else if (util.isBuffer(body)) {
|
|||
|
@@ -9978,7 +10130,7 @@ upgrade: ${upgrade}\r
|
|||
|
socket.cork();
|
|||
|
socket.write(`${header}content-length: ${contentLength}\r
|
|||
|
\r
|
|||
|
-`, "ascii");
|
|||
|
+`, "latin1");
|
|||
|
socket.write(body);
|
|||
|
socket.uncork();
|
|||
|
request.onBodySent(body);
|
|||
|
@@ -10006,8 +10158,10 @@ upgrade: ${upgrade}\r
|
|||
|
let finished = false;
|
|||
|
const writer = new AsyncWriter({ socket, request, contentLength, client, expectsPayload, header });
|
|||
|
const onData = function(chunk) {
|
|||
|
+ if (finished) {
|
|||
|
+ return;
|
|||
|
+ }
|
|||
|
try {
|
|||
|
- assert(!finished);
|
|||
|
if (!writer.write(chunk) && this.pause) {
|
|||
|
this.pause();
|
|||
|
}
|
|||
|
@@ -10016,7 +10170,9 @@ upgrade: ${upgrade}\r
|
|||
|
}
|
|||
|
};
|
|||
|
const onDrain = function() {
|
|||
|
- assert(!finished);
|
|||
|
+ if (finished) {
|
|||
|
+ return;
|
|||
|
+ }
|
|||
|
if (body.resume) {
|
|||
|
body.resume();
|
|||
|
}
|
|||
|
@@ -10062,7 +10218,7 @@ upgrade: ${upgrade}\r
|
|||
|
socket.cork();
|
|||
|
socket.write(`${header}content-length: ${contentLength}\r
|
|||
|
\r
|
|||
|
-`, "ascii");
|
|||
|
+`, "latin1");
|
|||
|
socket.write(buffer);
|
|||
|
socket.uncork();
|
|||
|
request.onBodySent(buffer);
|
|||
|
@@ -10140,26 +10296,28 @@ upgrade: ${upgrade}\r
|
|||
|
}
|
|||
|
process.emitWarning(new RequestContentLengthMismatchError());
|
|||
|
}
|
|||
|
+ socket.cork();
|
|||
|
if (bytesWritten === 0) {
|
|||
|
if (!expectsPayload) {
|
|||
|
socket[kReset] = true;
|
|||
|
}
|
|||
|
if (contentLength === null) {
|
|||
|
socket.write(`${header}transfer-encoding: chunked\r
|
|||
|
-`, "ascii");
|
|||
|
+`, "latin1");
|
|||
|
} else {
|
|||
|
socket.write(`${header}content-length: ${contentLength}\r
|
|||
|
\r
|
|||
|
-`, "ascii");
|
|||
|
+`, "latin1");
|
|||
|
}
|
|||
|
}
|
|||
|
if (contentLength === null) {
|
|||
|
socket.write(`\r
|
|||
|
${len.toString(16)}\r
|
|||
|
-`, "ascii");
|
|||
|
+`, "latin1");
|
|||
|
}
|
|||
|
this.bytesWritten += len;
|
|||
|
const ret = socket.write(chunk);
|
|||
|
+ socket.uncork();
|
|||
|
request.onBodySent(chunk);
|
|||
|
if (!ret) {
|
|||
|
if (socket[kParser].timeout && socket[kParser].timeoutType === TIMEOUT_HEADERS) {
|
|||
|
@@ -10184,13 +10342,13 @@ ${len.toString(16)}\r
|
|||
|
if (expectsPayload) {
|
|||
|
socket.write(`${header}content-length: 0\r
|
|||
|
\r
|
|||
|
-`, "ascii");
|
|||
|
+`, "latin1");
|
|||
|
} else {
|
|||
|
socket.write(`${header}\r
|
|||
|
-`, "ascii");
|
|||
|
+`, "latin1");
|
|||
|
}
|
|||
|
} else if (contentLength === null) {
|
|||
|
- socket.write("\r\n0\r\n\r\n", "ascii");
|
|||
|
+ socket.write("\r\n0\r\n\r\n", "latin1");
|
|||
|
}
|
|||
|
if (contentLength !== null && bytesWritten !== contentLength) {
|
|||
|
if (client[kStrictContentLength]) {
|
|||
|
@@ -10492,9 +10650,12 @@ var require_fetch = __commonJS({
|
|||
|
isErrorLike,
|
|||
|
fullyReadBody,
|
|||
|
readableStreamClose,
|
|||
|
- isomorphicEncode
|
|||
|
+ isomorphicEncode,
|
|||
|
+ urlIsLocal,
|
|||
|
+ urlIsHttpHttpsScheme,
|
|||
|
+ urlHasHttpsScheme
|
|||
|
} = require_util2();
|
|||
|
- var { kState, kHeaders, kGuard, kRealm, kHeadersCaseInsensitive } = require_symbols2();
|
|||
|
+ var { kState, kHeaders, kGuard, kRealm } = require_symbols2();
|
|||
|
var assert = require("assert");
|
|||
|
var { safelyExtractBody } = require_body();
|
|||
|
var {
|
|||
|
@@ -10615,7 +10776,7 @@ var require_fetch = __commonJS({
|
|||
|
const originalURL = response.urlList[0];
|
|||
|
let timingInfo = response.timingInfo;
|
|||
|
let cacheState = response.cacheState;
|
|||
|
- if (!/^https?:/.test(originalURL.protocol)) {
|
|||
|
+ if (!urlIsHttpHttpsScheme(originalURL)) {
|
|||
|
return;
|
|||
|
}
|
|||
|
if (timingInfo === null) {
|
|||
|
@@ -10627,12 +10788,12 @@ var require_fetch = __commonJS({
|
|||
|
});
|
|||
|
cacheState = "";
|
|||
|
}
|
|||
|
- response.timingInfo.endTime = coarsenedSharedCurrentTime();
|
|||
|
+ timingInfo.endTime = coarsenedSharedCurrentTime();
|
|||
|
response.timingInfo = timingInfo;
|
|||
|
markResourceTiming(timingInfo, originalURL, initiatorType, globalThis, cacheState);
|
|||
|
}
|
|||
|
function markResourceTiming(timingInfo, originalURL, initiatorType, globalThis2, cacheState) {
|
|||
|
- if (nodeMajor >= 18 && nodeMinor >= 2) {
|
|||
|
+ if (nodeMajor > 18 || nodeMajor === 18 && nodeMinor >= 2) {
|
|||
|
performance.markResourceTiming(timingInfo, originalURL, initiatorType, globalThis2, cacheState);
|
|||
|
}
|
|||
|
}
|
|||
|
@@ -10727,7 +10888,7 @@ var require_fetch = __commonJS({
|
|||
|
async function mainFetch(fetchParams, recursive = false) {
|
|||
|
const request = fetchParams.request;
|
|||
|
let response = null;
|
|||
|
- if (request.localURLsOnly && !/^(about|blob|data):/.test(requestCurrentURL(request).protocol)) {
|
|||
|
+ if (request.localURLsOnly && !urlIsLocal(requestCurrentURL(request))) {
|
|||
|
response = makeNetworkError("local URLs only");
|
|||
|
}
|
|||
|
tryUpgradeRequestToAPotentiallyTrustworthyURL(request);
|
|||
|
@@ -10757,7 +10918,7 @@ var require_fetch = __commonJS({
|
|||
|
request.responseTainting = "opaque";
|
|||
|
return await schemeFetch(fetchParams);
|
|||
|
}
|
|||
|
- if (!/^https?:/.test(requestCurrentURL(request).protocol)) {
|
|||
|
+ if (!urlIsHttpHttpsScheme(requestCurrentURL(request))) {
|
|||
|
return makeNetworkError("URL scheme must be a HTTP(S) scheme");
|
|||
|
}
|
|||
|
request.responseTainting = "cors";
|
|||
|
@@ -10981,7 +11142,7 @@ var require_fetch = __commonJS({
|
|||
|
} catch (err) {
|
|||
|
return makeNetworkError(err);
|
|||
|
}
|
|||
|
- if (!/^https?:/.test(locationURL.protocol)) {
|
|||
|
+ if (!urlIsHttpHttpsScheme(locationURL)) {
|
|||
|
return makeNetworkError("URL scheme must be a HTTP(S) scheme");
|
|||
|
}
|
|||
|
if (request.redirectCount === 20) {
|
|||
|
@@ -11008,7 +11169,7 @@ var require_fetch = __commonJS({
|
|||
|
request.headersList.delete("authorization");
|
|||
|
}
|
|||
|
if (request.body != null) {
|
|||
|
- assert(request.body.source);
|
|||
|
+ assert(request.body.source != null);
|
|||
|
request.body = safelyExtractBody(request.body.source)[0];
|
|||
|
}
|
|||
|
const timingInfo = fetchParams.timingInfo;
|
|||
|
@@ -11075,7 +11236,7 @@ var require_fetch = __commonJS({
|
|||
|
httpRequest.headersList.append("accept-encoding", "identity");
|
|||
|
}
|
|||
|
if (!httpRequest.headersList.contains("accept-encoding")) {
|
|||
|
- if (/^https:/.test(requestCurrentURL(httpRequest).protocol)) {
|
|||
|
+ if (urlHasHttpsScheme(requestCurrentURL(httpRequest))) {
|
|||
|
httpRequest.headersList.append("accept-encoding", "br, gzip, deflate");
|
|||
|
} else {
|
|||
|
httpRequest.headersList.append("accept-encoding", "gzip, deflate");
|
|||
|
@@ -11235,6 +11396,7 @@ var require_fetch = __commonJS({
|
|||
|
fetchParams.controller.resume = async () => {
|
|||
|
while (true) {
|
|||
|
let bytes;
|
|||
|
+ let isFailure;
|
|||
|
try {
|
|||
|
const { done, value } = await fetchParams.controller.next();
|
|||
|
if (isAborted(fetchParams)) {
|
|||
|
@@ -11246,6 +11408,7 @@ var require_fetch = __commonJS({
|
|||
|
bytes = void 0;
|
|||
|
} else {
|
|||
|
bytes = err;
|
|||
|
+ isFailure = true;
|
|||
|
}
|
|||
|
}
|
|||
|
if (bytes === void 0) {
|
|||
|
@@ -11254,7 +11417,7 @@ var require_fetch = __commonJS({
|
|||
|
return;
|
|||
|
}
|
|||
|
timingInfo.decodedBodySize += bytes?.byteLength ?? 0;
|
|||
|
- if (isErrorLike(bytes)) {
|
|||
|
+ if (isFailure) {
|
|||
|
fetchParams.controller.terminate(bytes);
|
|||
|
return;
|
|||
|
}
|
|||
|
@@ -11292,7 +11455,7 @@ var require_fetch = __commonJS({
|
|||
|
origin: url.origin,
|
|||
|
method: request.method,
|
|||
|
body: fetchParams.controller.dispatcher.isMockActive ? request.body && request.body.source : body,
|
|||
|
- headers: request.headersList[kHeadersCaseInsensitive],
|
|||
|
+ headers: request.headersList.entries,
|
|||
|
maxRedirections: 0,
|
|||
|
upgrade: request.mode === "websocket" ? "websocket" : void 0
|
|||
|
}, {
|
|||
|
@@ -11318,7 +11481,7 @@ var require_fetch = __commonJS({
|
|||
|
const key = headersList[n + 0].toString("latin1");
|
|||
|
const val = headersList[n + 1].toString("latin1");
|
|||
|
if (key.toLowerCase() === "content-encoding") {
|
|||
|
- codings = val.split(",").map((x) => x.trim());
|
|||
|
+ codings = val.toLowerCase().split(",").map((x) => x.trim());
|
|||
|
} else if (key.toLowerCase() === "location") {
|
|||
|
location = val;
|
|||
|
}
|
|||
|
@@ -11329,9 +11492,9 @@ var require_fetch = __commonJS({
|
|||
|
const willFollow = request.redirect === "follow" && location && redirectStatus.includes(status);
|
|||
|
if (request.method !== "HEAD" && request.method !== "CONNECT" && !nullBodyStatus.includes(status) && !willFollow) {
|
|||
|
for (const coding of codings) {
|
|||
|
- if (/(x-)?gzip/.test(coding)) {
|
|||
|
+ if (coding === "x-gzip" || coding === "gzip") {
|
|||
|
decoders.push(zlib.createGunzip());
|
|||
|
- } else if (/(x-)?deflate/.test(coding)) {
|
|||
|
+ } else if (coding === "deflate") {
|
|||
|
decoders.push(zlib.createInflate());
|
|||
|
} else if (coding === "br") {
|
|||
|
decoders.push(zlib.createBrotliDecompress());
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/core/symbols.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/core/symbols.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/core/symbols.js
|
|||
|
@@ -41,7 +41,7 @@ module.exports = {
|
|||
|
kClient: Symbol('client'),
|
|||
|
kParser: Symbol('parser'),
|
|||
|
kOnDestroyed: Symbol('destroy callbacks'),
|
|||
|
- kPipelining: Symbol('pipelinig'),
|
|||
|
+ kPipelining: Symbol('pipelining'),
|
|||
|
kSocket: Symbol('socket'),
|
|||
|
kHostHeader: Symbol('host header'),
|
|||
|
kConnector: Symbol('connector'),
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/fetch/constants.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/fetch/constants.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/fetch/constants.js
|
|||
|
@@ -48,11 +48,17 @@ const requestCache = [
|
|||
|
'only-if-cached'
|
|||
|
]
|
|||
|
|
|||
|
+// https://fetch.spec.whatwg.org/#request-body-header-name
|
|||
|
const requestBodyHeader = [
|
|||
|
'content-encoding',
|
|||
|
'content-language',
|
|||
|
'content-location',
|
|||
|
- 'content-type'
|
|||
|
+ 'content-type',
|
|||
|
+ // See https://github.com/nodejs/undici/issues/2021
|
|||
|
+ // 'Content-Length' is a forbidden header name, which is typically
|
|||
|
+ // removed in the Headers implementation. However, undici doesn't
|
|||
|
+ // filter out headers, so we add it here.
|
|||
|
+ 'content-length'
|
|||
|
]
|
|||
|
|
|||
|
// https://fetch.spec.whatwg.org/#enumdef-requestduplex
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/fetch/formdata.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/fetch/formdata.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/fetch/formdata.js
|
|||
|
@@ -61,14 +61,7 @@ class FormData {
|
|||
|
|
|||
|
// The delete(name) method steps are to remove all entries whose name
|
|||
|
// is name from this’s entry list.
|
|||
|
- const next = []
|
|||
|
- for (const entry of this[kState]) {
|
|||
|
- if (entry.name !== name) {
|
|||
|
- next.push(entry)
|
|||
|
- }
|
|||
|
- }
|
|||
|
-
|
|||
|
- this[kState] = next
|
|||
|
+ this[kState] = this[kState].filter(entry => entry.name !== name)
|
|||
|
}
|
|||
|
|
|||
|
get (name) {
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/fetch/response.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/fetch/response.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/fetch/response.js
|
|||
|
@@ -348,9 +348,7 @@ function makeNetworkError (reason) {
|
|||
|
status: 0,
|
|||
|
error: isError
|
|||
|
? reason
|
|||
|
- : new Error(reason ? String(reason) : reason, {
|
|||
|
- cause: isError ? reason : undefined
|
|||
|
- }),
|
|||
|
+ : new Error(reason ? String(reason) : reason),
|
|||
|
aborted: reason && reason.name === 'AbortError'
|
|||
|
})
|
|||
|
}
|
|||
|
@@ -469,7 +467,7 @@ function initializeResponse (response, i
|
|||
|
|
|||
|
// 5. If init["headers"] exists, then fill response’s headers with init["headers"].
|
|||
|
if ('headers' in init && init.headers != null) {
|
|||
|
- fill(response[kState].headersList, init.headers)
|
|||
|
+ fill(response[kHeaders], init.headers)
|
|||
|
}
|
|||
|
|
|||
|
// 6. If body was given, then:
|
|||
|
@@ -571,5 +569,6 @@ module.exports = {
|
|||
|
makeResponse,
|
|||
|
makeAppropriateNetworkError,
|
|||
|
filterResponse,
|
|||
|
- Response
|
|||
|
+ Response,
|
|||
|
+ cloneResponse
|
|||
|
}
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/fetch/headers.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/fetch/headers.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/fetch/headers.js
|
|||
|
@@ -3,7 +3,7 @@
|
|||
|
'use strict'
|
|||
|
|
|||
|
const { kHeadersList } = require('../core/symbols')
|
|||
|
-const { kGuard, kHeadersCaseInsensitive } = require('./symbols')
|
|||
|
+const { kGuard } = require('./symbols')
|
|||
|
const { kEnumerableProperty } = require('../core/util')
|
|||
|
const {
|
|||
|
makeIterator,
|
|||
|
@@ -95,6 +95,7 @@ class HeadersList {
|
|||
|
clear () {
|
|||
|
this[kHeadersMap].clear()
|
|||
|
this[kHeadersSortedMap] = null
|
|||
|
+ this.cookies = null
|
|||
|
}
|
|||
|
|
|||
|
// https://fetch.spec.whatwg.org/#concept-header-list-append
|
|||
|
@@ -172,15 +173,16 @@ class HeadersList {
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
- get [kHeadersCaseInsensitive] () {
|
|||
|
- /** @type {string[]} */
|
|||
|
- const flatList = []
|
|||
|
+ get entries () {
|
|||
|
+ const headers = {}
|
|||
|
|
|||
|
- for (const { name, value } of this[kHeadersMap].values()) {
|
|||
|
- flatList.push(name, value)
|
|||
|
+ if (this[kHeadersMap].size) {
|
|||
|
+ for (const { name, value } of this[kHeadersMap].values()) {
|
|||
|
+ headers[name] = value
|
|||
|
+ }
|
|||
|
}
|
|||
|
|
|||
|
- return flatList
|
|||
|
+ return headers
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
@@ -515,6 +517,7 @@ Object.defineProperties(Headers.prototyp
|
|||
|
get: kEnumerableProperty,
|
|||
|
has: kEnumerableProperty,
|
|||
|
set: kEnumerableProperty,
|
|||
|
+ getSetCookie: kEnumerableProperty,
|
|||
|
keys: kEnumerableProperty,
|
|||
|
values: kEnumerableProperty,
|
|||
|
entries: kEnumerableProperty,
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/api/api-request.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/api/api-request.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/api/api-request.js
|
|||
|
@@ -3,10 +3,10 @@
|
|||
|
const Readable = require('./readable')
|
|||
|
const {
|
|||
|
InvalidArgumentError,
|
|||
|
- RequestAbortedError,
|
|||
|
- ResponseStatusCodeError
|
|||
|
+ RequestAbortedError
|
|||
|
} = require('../core/errors')
|
|||
|
const util = require('../core/util')
|
|||
|
+const { getResolveErrorBodyCallback } = require('./util')
|
|||
|
const { AsyncResource } = require('async_hooks')
|
|||
|
const { addSignal, removeSignal } = require('./abort-signal')
|
|||
|
|
|||
|
@@ -16,13 +16,17 @@ class RequestHandler extends AsyncResour
|
|||
|
throw new InvalidArgumentError('invalid opts')
|
|||
|
}
|
|||
|
|
|||
|
- const { signal, method, opaque, body, onInfo, responseHeaders, throwOnError } = opts
|
|||
|
+ const { signal, method, opaque, body, onInfo, responseHeaders, throwOnError, highWaterMark } = opts
|
|||
|
|
|||
|
try {
|
|||
|
if (typeof callback !== 'function') {
|
|||
|
throw new InvalidArgumentError('invalid callback')
|
|||
|
}
|
|||
|
|
|||
|
+ if (highWaterMark && (typeof highWaterMark !== 'number' || highWaterMark < 0)) {
|
|||
|
+ throw new InvalidArgumentError('invalid highWaterMark')
|
|||
|
+ }
|
|||
|
+
|
|||
|
if (signal && typeof signal.on !== 'function' && typeof signal.addEventListener !== 'function') {
|
|||
|
throw new InvalidArgumentError('signal must be an EventEmitter or EventTarget')
|
|||
|
}
|
|||
|
@@ -53,6 +57,7 @@ class RequestHandler extends AsyncResour
|
|||
|
this.context = null
|
|||
|
this.onInfo = onInfo || null
|
|||
|
this.throwOnError = throwOnError
|
|||
|
+ this.highWaterMark = highWaterMark
|
|||
|
|
|||
|
if (util.isStream(body)) {
|
|||
|
body.on('error', (err) => {
|
|||
|
@@ -73,40 +78,39 @@ class RequestHandler extends AsyncResour
|
|||
|
}
|
|||
|
|
|||
|
onHeaders (statusCode, rawHeaders, resume, statusMessage) {
|
|||
|
- const { callback, opaque, abort, context } = this
|
|||
|
+ const { callback, opaque, abort, context, responseHeaders, highWaterMark } = this
|
|||
|
+
|
|||
|
+ const headers = responseHeaders === 'raw' ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders)
|
|||
|
|
|||
|
if (statusCode < 200) {
|
|||
|
if (this.onInfo) {
|
|||
|
- const headers = this.responseHeaders === 'raw' ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders)
|
|||
|
this.onInfo({ statusCode, headers })
|
|||
|
}
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
- const parsedHeaders = util.parseHeaders(rawHeaders)
|
|||
|
+ const parsedHeaders = responseHeaders === 'raw' ? util.parseHeaders(rawHeaders) : headers
|
|||
|
const contentType = parsedHeaders['content-type']
|
|||
|
- const body = new Readable(resume, abort, contentType)
|
|||
|
+ const body = new Readable({ resume, abort, contentType, highWaterMark })
|
|||
|
|
|||
|
this.callback = null
|
|||
|
this.res = body
|
|||
|
- const headers = this.responseHeaders === 'raw' ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders)
|
|||
|
|
|||
|
if (callback !== null) {
|
|||
|
if (this.throwOnError && statusCode >= 400) {
|
|||
|
this.runInAsyncScope(getResolveErrorBodyCallback, null,
|
|||
|
{ callback, body, contentType, statusCode, statusMessage, headers }
|
|||
|
)
|
|||
|
- return
|
|||
|
+ } else {
|
|||
|
+ this.runInAsyncScope(callback, null, null, {
|
|||
|
+ statusCode,
|
|||
|
+ headers,
|
|||
|
+ trailers: this.trailers,
|
|||
|
+ opaque,
|
|||
|
+ body,
|
|||
|
+ context
|
|||
|
+ })
|
|||
|
}
|
|||
|
-
|
|||
|
- this.runInAsyncScope(callback, null, null, {
|
|||
|
- statusCode,
|
|||
|
- headers,
|
|||
|
- trailers: this.trailers,
|
|||
|
- opaque,
|
|||
|
- body,
|
|||
|
- context
|
|||
|
- })
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
@@ -153,33 +157,6 @@ class RequestHandler extends AsyncResour
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
-async function getResolveErrorBodyCallback ({ callback, body, contentType, statusCode, statusMessage, headers }) {
|
|||
|
- if (statusCode === 204 || !contentType) {
|
|||
|
- body.dump()
|
|||
|
- process.nextTick(callback, new ResponseStatusCodeError(`Response status code ${statusCode}${statusMessage ? `: ${statusMessage}` : ''}`, statusCode, headers))
|
|||
|
- return
|
|||
|
- }
|
|||
|
-
|
|||
|
- try {
|
|||
|
- if (contentType.startsWith('application/json')) {
|
|||
|
- const payload = await body.json()
|
|||
|
- process.nextTick(callback, new ResponseStatusCodeError(`Response status code ${statusCode}${statusMessage ? `: ${statusMessage}` : ''}`, statusCode, headers, payload))
|
|||
|
- return
|
|||
|
- }
|
|||
|
-
|
|||
|
- if (contentType.startsWith('text/')) {
|
|||
|
- const payload = await body.text()
|
|||
|
- process.nextTick(callback, new ResponseStatusCodeError(`Response status code ${statusCode}${statusMessage ? `: ${statusMessage}` : ''}`, statusCode, headers, payload))
|
|||
|
- return
|
|||
|
- }
|
|||
|
- } catch (err) {
|
|||
|
- // Process in a fallback if error
|
|||
|
- }
|
|||
|
-
|
|||
|
- body.dump()
|
|||
|
- process.nextTick(callback, new ResponseStatusCodeError(`Response status code ${statusCode}${statusMessage ? `: ${statusMessage}` : ''}`, statusCode, headers))
|
|||
|
-}
|
|||
|
-
|
|||
|
function request (opts, callback) {
|
|||
|
if (callback === undefined) {
|
|||
|
return new Promise((resolve, reject) => {
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/core/request.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/core/request.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/core/request.js
|
|||
|
@@ -182,6 +182,7 @@ class Request {
|
|||
|
this.headers += `content-type: ${contentType}\r\n`
|
|||
|
}
|
|||
|
this.body = bodyStream.stream
|
|||
|
+ this.contentLength = bodyStream.length
|
|||
|
} else if (util.isBlobLike(body) && this.contentType == null && body.type) {
|
|||
|
this.contentType = body.type
|
|||
|
this.headers += `content-type: ${body.type}\r\n`
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/dispatcher-base.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/dispatcher-base.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/dispatcher-base.js
|
|||
|
@@ -19,7 +19,7 @@ class DispatcherBase extends Dispatcher
|
|||
|
super()
|
|||
|
|
|||
|
this[kDestroyed] = false
|
|||
|
- this[kOnDestroyed] = []
|
|||
|
+ this[kOnDestroyed] = null
|
|||
|
this[kClosed] = false
|
|||
|
this[kOnClosed] = []
|
|||
|
}
|
|||
|
@@ -127,6 +127,7 @@ class DispatcherBase extends Dispatcher
|
|||
|
}
|
|||
|
|
|||
|
this[kDestroyed] = true
|
|||
|
+ this[kOnDestroyed] = this[kOnDestroyed] || []
|
|||
|
this[kOnDestroyed].push(callback)
|
|||
|
|
|||
|
const onDestroyed = () => {
|
|||
|
@@ -167,7 +168,7 @@ class DispatcherBase extends Dispatcher
|
|||
|
throw new InvalidArgumentError('opts must be an object.')
|
|||
|
}
|
|||
|
|
|||
|
- if (this[kDestroyed]) {
|
|||
|
+ if (this[kDestroyed] || this[kOnDestroyed]) {
|
|||
|
throw new ClientDestroyedError()
|
|||
|
}
|
|||
|
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/fetch/symbols.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/fetch/symbols.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/fetch/symbols.js
|
|||
|
@@ -6,6 +6,5 @@ module.exports = {
|
|||
|
kSignal: Symbol('signal'),
|
|||
|
kState: Symbol('state'),
|
|||
|
kGuard: Symbol('guard'),
|
|||
|
- kRealm: Symbol('realm'),
|
|||
|
- kHeadersCaseInsensitive: Symbol('headers case insensitive')
|
|||
|
+ kRealm: Symbol('realm')
|
|||
|
}
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/llhttp/llhttp.wasm.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/llhttp/llhttp.wasm.js
|
|||
|
+++ /dev/null
|
|||
|
@@ -1 +0,0 @@
|
|||
|
-module.exports = 'AGFzbQEAAAABMAhgAX8Bf2ADf39/AX9gBH9/f38Bf2AAAGADf39/AGABfwBgAn9/AGAGf39/f39/AALLAQgDZW52GHdhc21fb25faGVhZGVyc19jb21wbGV0ZQACA2VudhV3YXNtX29uX21lc3NhZ2VfYmVnaW4AAANlbnYLd2FzbV9vbl91cmwAAQNlbnYOd2FzbV9vbl9zdGF0dXMAAQNlbnYUd2FzbV9vbl9oZWFkZXJfZmllbGQAAQNlbnYUd2FzbV9vbl9oZWFkZXJfdmFsdWUAAQNlbnYMd2FzbV9vbl9ib2R5AAEDZW52GHdhc21fb25fbWVzc2FnZV9jb21wbGV0ZQAAA0ZFAwMEAAAFAAAAAAAABQEFAAUFBQAABgAAAAAGBgYGAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQABAAABAQcAAAUFAAMBBAUB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gAAPC0HepYCAAA8LQdSegIAADwtB9JyAgAAPC0GnsoCAAA8LQbGdgIAADwtBoJ2AgAAPC0G5sYCAAA8LQbywgIAADwtBkqGAgAAPC0GzpoCAAA8LQemsgIAADwtBrJ6AgAAPC0HUq4CAAA8LQfemgIAADwtBgKaAgAAPC0GwoYCAAA8LQf6egIAADwtBjaOAgAAPC0GJrYCAAA8LQfeigIAADwtBoLGAgAAPC0Gun4CAAA8LQcalgIAADwtB6J6AgAAPC0GTooCAAA8LQcKvgIAADwtBw52AgAAPC0GLrICAAA8LQeGdgIAADwtBja+AgAAPC0HqoYCAAA8LQbStgIAADwtB0q+AgAAPC0HfsoCAAA8LQdKygIAA
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/llhttp/llhttp_simd.wasm.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/llhttp/llhttp_simd.wasm.js
|
|||
|
+++ /dev/null
|
|||
|
@@ -1 +0,0 @@
|
|||
|
-module.exports = 'AGFzbQEAAAABMAhgAX8Bf2ADf39/AX9gBH9/f38Bf2AAAGADf39/AGABfwBgAn9/AGAGf39/f39/AALLAQgDZW52GHdhc21fb25faGVhZGVyc19jb21wbGV0ZQACA2VudhV3YXNtX29uX21lc3NhZ2VfYmVnaW4AAANlbnYLd2FzbV9vbl91cmwAAQNlbnYOd2FzbV9vbl9zdGF0dXMAAQNlbnYUd2FzbV9vbl9oZWFkZXJfZmllbGQAAQNlbnYUd2FzbV9vbl9oZWFkZXJfdmFsdWUAAQNlbnYMd2FzbV9vbl9ib2R5AAEDZW52GHdhc21fb25fbWVzc2FnZV9jb21wbGV0ZQAAA0ZFAwMEAAAFAAAAAAAABQEFAAUFBQAABgAAAAAGBgYGAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQABAAABAQcAAAUFAAMBBAUBcAESEgUDAQACBggBfwFBgNQECwfRBSIGbWVtb3J5AgALX2luaXRpYWxpemUACRlfX2luZGlyZWN0X2Z1bmN0a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QbywgIAADwtBkqGAgAAPC0GzpoCAAA8LQemsgIAADwtBrJ6AgAAPC0HUq4CAAA8LQfemgIAADwtBgKaAgAAPC0GwoYCAAA8LQf6egIAADwtBjaOAgAAPC0GJrYCAAA8LQfeigIAADwtBoLGAgAAPC0Gun4CAAA8LQcalgIAADwtB6J6AgAAPC0GTooCAAA8LQcKvgIAADwtBw52AgAAPC0GLrICAAA8LQeGdgIAADwtBja+AgAAPC0HqoYCAAA8LQbStgIAADwtB0q+AgAAPC0HfsoCAAA8LQdKygIAA
|
|||
|
Index: node-v16.20.2/deps/undici/src/types/connector.d.ts
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/types/connector.d.ts
|
|||
|
+++ node-v16.20.2/deps/undici/src/types/connector.d.ts
|
|||
|
@@ -27,13 +27,7 @@ declare namespace buildConnector {
|
|||
|
export type Callback = (...args: CallbackArgs) => void
|
|||
|
type CallbackArgs = [null, Socket | TLSSocket] | [Error, null]
|
|||
|
|
|||
|
- export type connector = connectorAsync | connectorSync
|
|||
|
-
|
|||
|
- interface connectorSync {
|
|||
|
- (options: buildConnector.Options): Socket | TLSSocket
|
|||
|
- }
|
|||
|
-
|
|||
|
- interface connectorAsync {
|
|||
|
+ export interface connector {
|
|||
|
(options: buildConnector.Options, callback: buildConnector.Callback): void
|
|||
|
}
|
|||
|
}
|
|||
|
Index: node-v16.20.2/deps/undici/src/types/dispatcher.d.ts
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/types/dispatcher.d.ts
|
|||
|
+++ node-v16.20.2/deps/undici/src/types/dispatcher.d.ts
|
|||
|
@@ -142,6 +142,8 @@ declare namespace Dispatcher {
|
|||
|
onInfo?: (info: { statusCode: number, headers: Record<string, string | string[]> }) => void;
|
|||
|
/** Default: `null` */
|
|||
|
responseHeader?: 'raw' | null;
|
|||
|
+ /** Default: `64 KiB` */
|
|||
|
+ highWaterMark?: number;
|
|||
|
}
|
|||
|
export interface PipelineOptions extends RequestOptions {
|
|||
|
/** `true` if the `handler` will return an object stream. Default: `false` */
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/api/util.js
|
|||
|
===================================================================
|
|||
|
--- /dev/null
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/api/util.js
|
|||
|
@@ -0,0 +1,46 @@
|
|||
|
+const assert = require('assert')
|
|||
|
+const {
|
|||
|
+ ResponseStatusCodeError
|
|||
|
+} = require('../core/errors')
|
|||
|
+const { toUSVString } = require('../core/util')
|
|||
|
+
|
|||
|
+async function getResolveErrorBodyCallback ({ callback, body, contentType, statusCode, statusMessage, headers }) {
|
|||
|
+ assert(body)
|
|||
|
+
|
|||
|
+ let chunks = []
|
|||
|
+ let limit = 0
|
|||
|
+
|
|||
|
+ for await (const chunk of body) {
|
|||
|
+ chunks.push(chunk)
|
|||
|
+ limit += chunk.length
|
|||
|
+ if (limit > 128 * 1024) {
|
|||
|
+ chunks = null
|
|||
|
+ break
|
|||
|
+ }
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ if (statusCode === 204 || !contentType || !chunks) {
|
|||
|
+ process.nextTick(callback, new ResponseStatusCodeError(`Response status code ${statusCode}${statusMessage ? `: ${statusMessage}` : ''}`, statusCode, headers))
|
|||
|
+ return
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ try {
|
|||
|
+ if (contentType.startsWith('application/json')) {
|
|||
|
+ const payload = JSON.parse(toUSVString(Buffer.concat(chunks)))
|
|||
|
+ process.nextTick(callback, new ResponseStatusCodeError(`Response status code ${statusCode}${statusMessage ? `: ${statusMessage}` : ''}`, statusCode, headers, payload))
|
|||
|
+ return
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ if (contentType.startsWith('text/')) {
|
|||
|
+ const payload = toUSVString(Buffer.concat(chunks))
|
|||
|
+ process.nextTick(callback, new ResponseStatusCodeError(`Response status code ${statusCode}${statusMessage ? `: ${statusMessage}` : ''}`, statusCode, headers, payload))
|
|||
|
+ return
|
|||
|
+ }
|
|||
|
+ } catch (err) {
|
|||
|
+ // Process in a fallback if error
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ process.nextTick(callback, new ResponseStatusCodeError(`Response status code ${statusCode}${statusMessage ? `: ${statusMessage}` : ''}`, statusCode, headers))
|
|||
|
+}
|
|||
|
+
|
|||
|
+module.exports = { getResolveErrorBodyCallback }
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/llhttp/llhttp-wasm.js
|
|||
|
===================================================================
|
|||
|
--- /dev/null
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/llhttp/llhttp-wasm.js
|
|||
|
@@ -0,0 +1 @@
|
|||
|
+module.exports = 'AGFzbQEAAAABMAhgAX8Bf2ADf39/AX9gBH9/f38Bf2AAAGADf39/AGABfwBgAn9/AGAGf39/f39/AALLAQgDZW52GHdhc21fb25faGVhZGVyc19jb21wbGV0ZQACA2VudhV3YXNtX29uX21lc3NhZ2VfYmVnaW4AAANlbnYLd2FzbV9vbl91cmwAAQNlbnYOd2FzbV9vbl9zdGF0dXMAAQNlbnYUd2FzbV9vbl9oZWFkZXJfZmllbGQAAQNlbnYUd2FzbV9vbl9oZWFkZXJfdmFsdWUAAQNlbnYMd2FzbV9vbl9ib2R5AAEDZW52GHdhc21fb25fbWVzc2FnZV9jb21wbGV0ZQAAA0ZFAwMEAAAFAAAAAAAABQEFAAUFBQAABgAAAAAGBgYGAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQABAAABAQcAAAUFAAMBBAUBcAESEgUDAQACBggBfwFBgNQECwfRBSIGbWVtb3J5AgALX2luaXRpYWxpemUACRlfX2luZGlyZWN0X2Z1bmN0aW9uX3RhYmxlAQALbGxodHRwX2luaXQAChhsbGh0dHBfc2hvdWxkX2tlZXBfYWxpdmUAQQxsbGh0dHBfYWxsb2MADAZtYWxsb2MARgtsbGh0dHBfZnJlZQANBGZyZWUASA9sbGh0dHBfZ2V0X3R5cGUADhVsbGh0dHBfZ2V0X2h0dHBfbWFqb3IADxVsbGh0dHB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AADwtBw52AgAAPC0GLrICAAA8LQeGdgIAADwtBja+AgAAPC0HqoYCAAA8LQbStgIAADwtB0q+AgAAPC0HfsoCAAA8LQdKygIAA
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/llhttp/llhttp_simd-wasm.js
|
|||
|
===================================================================
|
|||
|
--- /dev/null
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/llhttp/llhttp_simd-wasm.js
|
|||
|
@@ -0,0 +1 @@
|
|||
|
+module.exports = 'AGFzbQEAAAABMAhgAX8Bf2ADf39/AX9gBH9/f38Bf2AAAGADf39/AGABfwBgAn9/AGAGf39/f39/AALLAQgDZW52GHdhc21fb25faGVhZGVyc19jb21wbGV0ZQACA2VudhV3YXNtX29uX21lc3NhZ2VfYmVnaW4AAANlbnYLd2FzbV9vbl91cmwAAQNlbnYOd2FzbV9vbl9zdGF0dXMAAQNlbnYUd2FzbV9vbl9oZWFkZXJfZmllbGQAAQNlbnYUd2FzbV9vbl9oZWFkZXJfdmFsdWUAAQNlbnYMd2FzbV9vbl9ib2R5AAEDZW52GHdhc21fb25fbWVzc2FnZV9jb21wbGV0ZQAAA0ZFAwMEAAAFAAAAAAAABQEFAAUFBQAABgAAAAAGBgYGAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQABAAABAQcAAAUFAAMBBAUBcAESEgUDAQACBggBfwFBgNQECwfRBSIGbWVtb3J5AgALX2luaXRpYWxpemUACRlfX2luZGlyZWN0X2Z1bmN0aW9uX3RhYmxlAQALbGxodHRwX2luaXQAChhsbGh0dHBfc2hvdWxkX2tlZXBfYWxpdmUAQQxsbGh0dHBfYWxsb2MADAZtYWxsb2MARgtsbGh0dHBfZnJlZQANBGZyZWUASA9sbGh0dHBfZ2V0X3R5cGUADhVsbGh0dHBfZ2V0X2h0dHBfbWFqb3IADxVsbGh0dHBfZ2V0X2h0dHBfbWlub3IAEBFsbGh0dHBfZ2V0X21ldGhvZAARFmxsaHR0cF9nZXRfc3RhdHVzX2NvZGUA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A8LQdKygIAA
|
|||
|
Index: node-v16.20.2/deps/undici/src/docs/api/CacheStorage.md
|
|||
|
===================================================================
|
|||
|
--- /dev/null
|
|||
|
+++ node-v16.20.2/deps/undici/src/docs/api/CacheStorage.md
|
|||
|
@@ -0,0 +1,30 @@
|
|||
|
+# CacheStorage
|
|||
|
+
|
|||
|
+Undici exposes a W3C spec-compliant implementation of [CacheStorage](https://developer.mozilla.org/en-US/docs/Web/API/CacheStorage) and [Cache](https://developer.mozilla.org/en-US/docs/Web/API/Cache).
|
|||
|
+
|
|||
|
+## Opening a Cache
|
|||
|
+
|
|||
|
+Undici exports a top-level CacheStorage instance. You can open a new Cache, or duplicate a Cache with an existing name, by using `CacheStorage.prototype.open`. If you open a Cache with the same name as an already-existing Cache, its list of cached Responses will be shared between both instances.
|
|||
|
+
|
|||
|
+```mjs
|
|||
|
+import { caches } from 'undici'
|
|||
|
+
|
|||
|
+const cache_1 = await caches.open('v1')
|
|||
|
+const cache_2 = await caches.open('v1')
|
|||
|
+
|
|||
|
+// Although .open() creates a new instance,
|
|||
|
+assert(cache_1 !== cache_2)
|
|||
|
+// The same Response is matched in both.
|
|||
|
+assert.deepStrictEqual(await cache_1.match('/req'), await cache_2.match('/req'))
|
|||
|
+```
|
|||
|
+
|
|||
|
+## Deleting a Cache
|
|||
|
+
|
|||
|
+If a Cache is deleted, the cached Responses/Requests can still be used.
|
|||
|
+
|
|||
|
+```mjs
|
|||
|
+const response = await cache_1.match('/req')
|
|||
|
+await caches.delete('v1')
|
|||
|
+
|
|||
|
+await response.text() // the Response's body
|
|||
|
+```
|
|||
|
Index: node-v16.20.2/deps/undici/src/docs/api/Errors.md
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/docs/api/Errors.md
|
|||
|
+++ node-v16.20.2/deps/undici/src/docs/api/Errors.md
|
|||
|
@@ -7,19 +7,25 @@ You can find all the error objects insid
|
|||
|
import { errors } from 'undici'
|
|||
|
```
|
|||
|
|
|||
|
-| Error | Error Codes | Description |
|
|||
|
-| ------------------------------------ | ------------------------------------- | -------------------------------------------------- |
|
|||
|
-| `InvalidArgumentError` | `UND_ERR_INVALID_ARG` | passed an invalid argument. |
|
|||
|
-| `InvalidReturnValueError` | `UND_ERR_INVALID_RETURN_VALUE` | returned an invalid value. |
|
|||
|
-| `RequestAbortedError` | `UND_ERR_ABORTED` | the request has been aborted by the user |
|
|||
|
-| `ClientDestroyedError` | `UND_ERR_DESTROYED` | trying to use a destroyed client. |
|
|||
|
-| `ClientClosedError` | `UND_ERR_CLOSED` | trying to use a closed client. |
|
|||
|
-| `SocketError` | `UND_ERR_SOCKET` | there is an error with the socket. |
|
|||
|
-| `NotSupportedError` | `UND_ERR_NOT_SUPPORTED` | encountered unsupported functionality. |
|
|||
|
-| `RequestContentLengthMismatchError` | `UND_ERR_REQ_CONTENT_LENGTH_MISMATCH` | request body does not match content-length header |
|
|||
|
-| `ResponseContentLengthMismatchError` | `UND_ERR_RES_CONTENT_LENGTH_MISMATCH` | response body does not match content-length header |
|
|||
|
-| `InformationalError` | `UND_ERR_INFO` | expected error with reason |
|
|||
|
-| `ResponseExceededMaxSizeError` | `UND_ERR_RES_EXCEEDED_MAX_SIZE` | response body exceed the max size allowed |
|
|||
|
+| Error | Error Codes | Description |
|
|||
|
+| ------------------------------------ | ------------------------------------- | ------------------------------------------------------------------------- |
|
|||
|
+| `UndiciError` | `UND_ERR` | all errors below are extended from `UndiciError`. |
|
|||
|
+| `ConnectTimeoutError` | `UND_ERR_CONNECT_TIMEOUT` | socket is destroyed due to connect timeout. |
|
|||
|
+| `HeadersTimeoutError` | `UND_ERR_HEADERS_TIMEOUT` | socket is destroyed due to headers timeout. |
|
|||
|
+| `HeadersOverflowError` | `UND_ERR_HEADERS_OVERFLOW` | socket is destroyed due to headers' max size being exceeded. |
|
|||
|
+| `BodyTimeoutError` | `UND_ERR_BODY_TIMEOUT` | socket is destroyed due to body timeout. |
|
|||
|
+| `ResponseStatusCodeError` | `UND_ERR_RESPONSE_STATUS_CODE` | an error is thrown when `throwOnError` is `true` for status codes >= 400. |
|
|||
|
+| `InvalidArgumentError` | `UND_ERR_INVALID_ARG` | passed an invalid argument. |
|
|||
|
+| `InvalidReturnValueError` | `UND_ERR_INVALID_RETURN_VALUE` | returned an invalid value. |
|
|||
|
+| `RequestAbortedError` | `UND_ERR_ABORTED` | the request has been aborted by the user |
|
|||
|
+| `ClientDestroyedError` | `UND_ERR_DESTROYED` | trying to use a destroyed client. |
|
|||
|
+| `ClientClosedError` | `UND_ERR_CLOSED` | trying to use a closed client. |
|
|||
|
+| `SocketError` | `UND_ERR_SOCKET` | there is an error with the socket. |
|
|||
|
+| `NotSupportedError` | `UND_ERR_NOT_SUPPORTED` | encountered unsupported functionality. |
|
|||
|
+| `RequestContentLengthMismatchError` | `UND_ERR_REQ_CONTENT_LENGTH_MISMATCH` | request body does not match content-length header |
|
|||
|
+| `ResponseContentLengthMismatchError` | `UND_ERR_RES_CONTENT_LENGTH_MISMATCH` | response body does not match content-length header |
|
|||
|
+| `InformationalError` | `UND_ERR_INFO` | expected error with reason |
|
|||
|
+| `ResponseExceededMaxSizeError` | `UND_ERR_RES_EXCEEDED_MAX_SIZE` | response body exceed the max size allowed |
|
|||
|
|
|||
|
### `SocketError`
|
|||
|
|
|||
|
Index: node-v16.20.2/deps/undici/src/docs/api/Fetch.md
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/docs/api/Fetch.md
|
|||
|
+++ node-v16.20.2/deps/undici/src/docs/api/Fetch.md
|
|||
|
@@ -8,6 +8,8 @@ Documentation and examples can be found
|
|||
|
|
|||
|
This API is implemented as per the standard, you can find documentation on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/File)
|
|||
|
|
|||
|
+In Node versions v18.13.0 and above and v19.2.0 and above, undici will default to using Node's [File](https://nodejs.org/api/buffer.html#class-file) class. In versions where it's not available, it will default to the undici one.
|
|||
|
+
|
|||
|
## FormData
|
|||
|
|
|||
|
This API is implemented as per the standard, you can find documentation on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/FormData)
|
|||
|
Index: node-v16.20.2/deps/undici/src/docs/api/WebSocket.md
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/docs/api/WebSocket.md
|
|||
|
+++ node-v16.20.2/deps/undici/src/docs/api/WebSocket.md
|
|||
|
@@ -1,17 +1,40 @@
|
|||
|
# Class: WebSocket
|
|||
|
|
|||
|
-> ⚠️ Warning: the WebSocket API is experimental and has known bugs.
|
|||
|
+> ⚠️ Warning: the WebSocket API is experimental.
|
|||
|
|
|||
|
Extends: [`EventTarget`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget)
|
|||
|
|
|||
|
-The WebSocket object provides a way to manage a WebSocket connection to a server, allowing bidirectional communication. The API follows the [WebSocket spec](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket).
|
|||
|
+The WebSocket object provides a way to manage a WebSocket connection to a server, allowing bidirectional communication. The API follows the [WebSocket spec](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) and [RFC 6455](https://datatracker.ietf.org/doc/html/rfc6455).
|
|||
|
|
|||
|
## `new WebSocket(url[, protocol])`
|
|||
|
|
|||
|
Arguments:
|
|||
|
|
|||
|
* **url** `URL | string` - The url's protocol *must* be `ws` or `wss`.
|
|||
|
-* **protocol** `string | string[]` (optional) - Subprotocol(s) to request the server use.
|
|||
|
+* **protocol** `string | string[] | WebSocketInit` (optional) - Subprotocol(s) to request the server use, or a [`Dispatcher`](./Dispatcher.md).
|
|||
|
+
|
|||
|
+### Example:
|
|||
|
+
|
|||
|
+This example will not work in browsers or other platforms that don't allow passing an object.
|
|||
|
+
|
|||
|
+```mjs
|
|||
|
+import { WebSocket, ProxyAgent } from 'undici'
|
|||
|
+
|
|||
|
+const proxyAgent = new ProxyAgent('my.proxy.server')
|
|||
|
+
|
|||
|
+const ws = new WebSocket('wss://echo.websocket.events', {
|
|||
|
+ dispatcher: proxyAgent,
|
|||
|
+ protocols: ['echo', 'chat']
|
|||
|
+})
|
|||
|
+```
|
|||
|
+
|
|||
|
+If you do not need a custom Dispatcher, it's recommended to use the following pattern:
|
|||
|
+
|
|||
|
+```mjs
|
|||
|
+import { WebSocket } from 'undici'
|
|||
|
+
|
|||
|
+const ws = new WebSocket('wss://echo.websocket.events', ['echo', 'chat'])
|
|||
|
+```
|
|||
|
|
|||
|
## Read More
|
|||
|
|
|||
|
Index: node-v16.20.2/deps/undici/src/index.d.ts
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/index.d.ts
|
|||
|
+++ node-v16.20.2/deps/undici/src/index.d.ts
|
|||
|
@@ -24,6 +24,7 @@ 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 }
|
|||
|
@@ -52,4 +53,5 @@ declare namespace Undici {
|
|||
|
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;
|
|||
|
}
|
|||
|
Index: node-v16.20.2/deps/undici/src/index.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/index.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/index.js
|
|||
|
@@ -121,6 +121,13 @@ if (util.nodeMajor > 16 || (util.nodeMaj
|
|||
|
|
|||
|
module.exports.setGlobalOrigin = setGlobalOrigin
|
|||
|
module.exports.getGlobalOrigin = getGlobalOrigin
|
|||
|
+
|
|||
|
+ const { CacheStorage } = require('./lib/cache/cachestorage')
|
|||
|
+ const { kConstruct } = require('./lib/cache/symbols')
|
|||
|
+
|
|||
|
+ // Cache & CacheStorage are tightly coupled with fetch. Even if it may run
|
|||
|
+ // in an older version of Node, it doesn't have any use without fetch.
|
|||
|
+ module.exports.caches = new CacheStorage(kConstruct)
|
|||
|
}
|
|||
|
|
|||
|
if (util.nodeMajor >= 16) {
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/cache/cache.js
|
|||
|
===================================================================
|
|||
|
--- /dev/null
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/cache/cache.js
|
|||
|
@@ -0,0 +1,842 @@
|
|||
|
+'use strict'
|
|||
|
+
|
|||
|
+const { kConstruct } = require('./symbols')
|
|||
|
+const { urlEquals, fieldValues: getFieldValues } = require('./util')
|
|||
|
+const { kEnumerableProperty, isDisturbed } = require('../core/util')
|
|||
|
+const { kHeadersList } = require('../core/symbols')
|
|||
|
+const { webidl } = require('../fetch/webidl')
|
|||
|
+const { Response, cloneResponse } = require('../fetch/response')
|
|||
|
+const { Request } = require('../fetch/request')
|
|||
|
+const { kState, kHeaders, kGuard, kRealm } = require('../fetch/symbols')
|
|||
|
+const { fetching } = require('../fetch/index')
|
|||
|
+const { urlIsHttpHttpsScheme, createDeferredPromise, readAllBytes } = require('../fetch/util')
|
|||
|
+const assert = require('assert')
|
|||
|
+const { getGlobalDispatcher } = require('../global')
|
|||
|
+
|
|||
|
+/**
|
|||
|
+ * @see https://w3c.github.io/ServiceWorker/#dfn-cache-batch-operation
|
|||
|
+ * @typedef {Object} CacheBatchOperation
|
|||
|
+ * @property {'delete' | 'put'} type
|
|||
|
+ * @property {any} request
|
|||
|
+ * @property {any} response
|
|||
|
+ * @property {import('../../types/cache').CacheQueryOptions} options
|
|||
|
+ */
|
|||
|
+
|
|||
|
+/**
|
|||
|
+ * @see https://w3c.github.io/ServiceWorker/#dfn-request-response-list
|
|||
|
+ * @typedef {[any, any][]} requestResponseList
|
|||
|
+ */
|
|||
|
+
|
|||
|
+class Cache {
|
|||
|
+ /**
|
|||
|
+ * @see https://w3c.github.io/ServiceWorker/#dfn-relevant-request-response-list
|
|||
|
+ * @type {requestResponseList}
|
|||
|
+ */
|
|||
|
+ #relevantRequestResponseList
|
|||
|
+
|
|||
|
+ constructor () {
|
|||
|
+ if (arguments[0] !== kConstruct) {
|
|||
|
+ webidl.illegalConstructor()
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ this.#relevantRequestResponseList = arguments[1]
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ async match (request, options = {}) {
|
|||
|
+ webidl.brandCheck(this, Cache)
|
|||
|
+ webidl.argumentLengthCheck(arguments, 1, { header: 'Cache.match' })
|
|||
|
+
|
|||
|
+ request = webidl.converters.RequestInfo(request)
|
|||
|
+ options = webidl.converters.CacheQueryOptions(options)
|
|||
|
+
|
|||
|
+ const p = await this.matchAll(request, options)
|
|||
|
+
|
|||
|
+ if (p.length === 0) {
|
|||
|
+ return
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ return p[0]
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ async matchAll (request = undefined, options = {}) {
|
|||
|
+ webidl.brandCheck(this, Cache)
|
|||
|
+
|
|||
|
+ if (request !== undefined) request = webidl.converters.RequestInfo(request)
|
|||
|
+ options = webidl.converters.CacheQueryOptions(options)
|
|||
|
+
|
|||
|
+ // 1.
|
|||
|
+ let r = null
|
|||
|
+
|
|||
|
+ // 2.
|
|||
|
+ if (request !== undefined) {
|
|||
|
+ if (request instanceof Request) {
|
|||
|
+ // 2.1.1
|
|||
|
+ r = request[kState]
|
|||
|
+
|
|||
|
+ // 2.1.2
|
|||
|
+ if (r.method !== 'GET' && !options.ignoreMethod) {
|
|||
|
+ return []
|
|||
|
+ }
|
|||
|
+ } else if (typeof request === 'string') {
|
|||
|
+ // 2.2.1
|
|||
|
+ r = new Request(request)[kState]
|
|||
|
+ }
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 5.
|
|||
|
+ // 5.1
|
|||
|
+ const responses = []
|
|||
|
+
|
|||
|
+ // 5.2
|
|||
|
+ if (request === undefined) {
|
|||
|
+ // 5.2.1
|
|||
|
+ for (const requestResponse of this.#relevantRequestResponseList) {
|
|||
|
+ responses.push(requestResponse[1])
|
|||
|
+ }
|
|||
|
+ } else { // 5.3
|
|||
|
+ // 5.3.1
|
|||
|
+ const requestResponses = this.#queryCache(r, options)
|
|||
|
+
|
|||
|
+ // 5.3.2
|
|||
|
+ for (const requestResponse of requestResponses) {
|
|||
|
+ responses.push(requestResponse[1])
|
|||
|
+ }
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 5.4
|
|||
|
+ // We don't implement CORs so we don't need to loop over the responses, yay!
|
|||
|
+
|
|||
|
+ // 5.5.1
|
|||
|
+ const responseList = []
|
|||
|
+
|
|||
|
+ // 5.5.2
|
|||
|
+ for (const response of responses) {
|
|||
|
+ // 5.5.2.1
|
|||
|
+ const responseObject = new Response(response.body?.source ?? null)
|
|||
|
+ const body = responseObject[kState].body
|
|||
|
+ responseObject[kState] = response
|
|||
|
+ responseObject[kState].body = body
|
|||
|
+ responseObject[kHeaders][kHeadersList] = response.headersList
|
|||
|
+ responseObject[kHeaders][kGuard] = 'immutable'
|
|||
|
+
|
|||
|
+ responseList.push(responseObject)
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 6.
|
|||
|
+ return Object.freeze(responseList)
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ async add (request) {
|
|||
|
+ webidl.brandCheck(this, Cache)
|
|||
|
+ webidl.argumentLengthCheck(arguments, 1, { header: 'Cache.add' })
|
|||
|
+
|
|||
|
+ request = webidl.converters.RequestInfo(request)
|
|||
|
+
|
|||
|
+ // 1.
|
|||
|
+ const requests = [request]
|
|||
|
+
|
|||
|
+ // 2.
|
|||
|
+ const responseArrayPromise = this.addAll(requests)
|
|||
|
+
|
|||
|
+ // 3.
|
|||
|
+ return await responseArrayPromise
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ async addAll (requests) {
|
|||
|
+ webidl.brandCheck(this, Cache)
|
|||
|
+ webidl.argumentLengthCheck(arguments, 1, { header: 'Cache.addAll' })
|
|||
|
+
|
|||
|
+ requests = webidl.converters['sequence<RequestInfo>'](requests)
|
|||
|
+
|
|||
|
+ // 1.
|
|||
|
+ const responsePromises = []
|
|||
|
+
|
|||
|
+ // 2.
|
|||
|
+ const requestList = []
|
|||
|
+
|
|||
|
+ // 3.
|
|||
|
+ for (const request of requests) {
|
|||
|
+ if (typeof request === 'string') {
|
|||
|
+ continue
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 3.1
|
|||
|
+ const r = request[kState]
|
|||
|
+
|
|||
|
+ // 3.2
|
|||
|
+ if (!urlIsHttpHttpsScheme(r.url) || r.method !== 'GET') {
|
|||
|
+ throw webidl.errors.exception({
|
|||
|
+ header: 'Cache.addAll',
|
|||
|
+ message: 'Expected http/s scheme when method is not GET.'
|
|||
|
+ })
|
|||
|
+ }
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 4.
|
|||
|
+ /** @type {ReturnType<typeof fetching>[]} */
|
|||
|
+ const fetchControllers = []
|
|||
|
+
|
|||
|
+ // 5.
|
|||
|
+ for (const request of requests) {
|
|||
|
+ // 5.1
|
|||
|
+ const r = new Request(request)[kState]
|
|||
|
+
|
|||
|
+ // 5.2
|
|||
|
+ if (!urlIsHttpHttpsScheme(r.url)) {
|
|||
|
+ throw webidl.errors.exception({
|
|||
|
+ header: 'Cache.addAll',
|
|||
|
+ message: 'Expected http/s scheme.'
|
|||
|
+ })
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 5.4
|
|||
|
+ r.initiator = 'fetch'
|
|||
|
+ r.destination = 'subresource'
|
|||
|
+
|
|||
|
+ // 5.5
|
|||
|
+ requestList.push(r)
|
|||
|
+
|
|||
|
+ // 5.6
|
|||
|
+ const responsePromise = createDeferredPromise()
|
|||
|
+
|
|||
|
+ // 5.7
|
|||
|
+ fetchControllers.push(fetching({
|
|||
|
+ request: r,
|
|||
|
+ dispatcher: getGlobalDispatcher(),
|
|||
|
+ processResponse (response) {
|
|||
|
+ // 1.
|
|||
|
+ if (response.type === 'error' || response.status === 206 || response.status < 200 || response.status > 299) {
|
|||
|
+ responsePromise.reject(webidl.errors.exception({
|
|||
|
+ header: 'Cache.addAll',
|
|||
|
+ message: 'Received an invalid status code or the request failed.'
|
|||
|
+ }))
|
|||
|
+ } else if (response.headersList.contains('vary')) { // 2.
|
|||
|
+ // 2.1
|
|||
|
+ const fieldValues = getFieldValues(response.headersList.get('vary'))
|
|||
|
+
|
|||
|
+ // 2.2
|
|||
|
+ for (const fieldValue of fieldValues) {
|
|||
|
+ // 2.2.1
|
|||
|
+ if (fieldValue === '*') {
|
|||
|
+ responsePromise.reject(webidl.errors.exception({
|
|||
|
+ header: 'Cache.addAll',
|
|||
|
+ message: 'invalid vary field value'
|
|||
|
+ }))
|
|||
|
+
|
|||
|
+ for (const controller of fetchControllers) {
|
|||
|
+ controller.abort()
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ return
|
|||
|
+ }
|
|||
|
+ }
|
|||
|
+ }
|
|||
|
+ },
|
|||
|
+ processResponseEndOfBody (response) {
|
|||
|
+ // 1.
|
|||
|
+ if (response.aborted) {
|
|||
|
+ responsePromise.reject(new DOMException('aborted', 'AbortError'))
|
|||
|
+ return
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 2.
|
|||
|
+ responsePromise.resolve(response)
|
|||
|
+ }
|
|||
|
+ }))
|
|||
|
+
|
|||
|
+ // 5.8
|
|||
|
+ responsePromises.push(responsePromise.promise)
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 6.
|
|||
|
+ const p = Promise.all(responsePromises)
|
|||
|
+
|
|||
|
+ // 7.
|
|||
|
+ const responses = await p
|
|||
|
+
|
|||
|
+ // 7.1
|
|||
|
+ const operations = []
|
|||
|
+
|
|||
|
+ // 7.2
|
|||
|
+ let index = 0
|
|||
|
+
|
|||
|
+ // 7.3
|
|||
|
+ for (const response of responses) {
|
|||
|
+ // 7.3.1
|
|||
|
+ /** @type {CacheBatchOperation} */
|
|||
|
+ const operation = {
|
|||
|
+ type: 'put', // 7.3.2
|
|||
|
+ request: requestList[index], // 7.3.3
|
|||
|
+ response // 7.3.4
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ operations.push(operation) // 7.3.5
|
|||
|
+
|
|||
|
+ index++ // 7.3.6
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 7.5
|
|||
|
+ const cacheJobPromise = createDeferredPromise()
|
|||
|
+
|
|||
|
+ // 7.6.1
|
|||
|
+ let errorData = null
|
|||
|
+
|
|||
|
+ // 7.6.2
|
|||
|
+ try {
|
|||
|
+ this.#batchCacheOperations(operations)
|
|||
|
+ } catch (e) {
|
|||
|
+ errorData = e
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 7.6.3
|
|||
|
+ queueMicrotask(() => {
|
|||
|
+ // 7.6.3.1
|
|||
|
+ if (errorData === null) {
|
|||
|
+ cacheJobPromise.resolve(undefined)
|
|||
|
+ } else {
|
|||
|
+ // 7.6.3.2
|
|||
|
+ cacheJobPromise.reject(errorData)
|
|||
|
+ }
|
|||
|
+ })
|
|||
|
+
|
|||
|
+ // 7.7
|
|||
|
+ return cacheJobPromise.promise
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ async put (request, response) {
|
|||
|
+ webidl.brandCheck(this, Cache)
|
|||
|
+ webidl.argumentLengthCheck(arguments, 2, { header: 'Cache.put' })
|
|||
|
+
|
|||
|
+ request = webidl.converters.RequestInfo(request)
|
|||
|
+ response = webidl.converters.Response(response)
|
|||
|
+
|
|||
|
+ // 1.
|
|||
|
+ let innerRequest = null
|
|||
|
+
|
|||
|
+ // 2.
|
|||
|
+ if (request instanceof Request) {
|
|||
|
+ innerRequest = request[kState]
|
|||
|
+ } else { // 3.
|
|||
|
+ innerRequest = new Request(request)[kState]
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 4.
|
|||
|
+ if (!urlIsHttpHttpsScheme(innerRequest.url) || innerRequest.method !== 'GET') {
|
|||
|
+ throw webidl.errors.exception({
|
|||
|
+ header: 'Cache.put',
|
|||
|
+ message: 'Expected an http/s scheme when method is not GET'
|
|||
|
+ })
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 5.
|
|||
|
+ const innerResponse = response[kState]
|
|||
|
+
|
|||
|
+ // 6.
|
|||
|
+ if (innerResponse.status === 206) {
|
|||
|
+ throw webidl.errors.exception({
|
|||
|
+ header: 'Cache.put',
|
|||
|
+ message: 'Got 206 status'
|
|||
|
+ })
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 7.
|
|||
|
+ if (innerResponse.headersList.contains('vary')) {
|
|||
|
+ // 7.1.
|
|||
|
+ const fieldValues = getFieldValues(innerResponse.headersList.get('vary'))
|
|||
|
+
|
|||
|
+ // 7.2.
|
|||
|
+ for (const fieldValue of fieldValues) {
|
|||
|
+ // 7.2.1
|
|||
|
+ if (fieldValue === '*') {
|
|||
|
+ throw webidl.errors.exception({
|
|||
|
+ header: 'Cache.put',
|
|||
|
+ message: 'Got * vary field value'
|
|||
|
+ })
|
|||
|
+ }
|
|||
|
+ }
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 8.
|
|||
|
+ if (innerResponse.body && (isDisturbed(innerResponse.body.stream) || innerResponse.body.stream.locked)) {
|
|||
|
+ throw webidl.errors.exception({
|
|||
|
+ header: 'Cache.put',
|
|||
|
+ message: 'Response body is locked or disturbed'
|
|||
|
+ })
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 9.
|
|||
|
+ const clonedResponse = cloneResponse(innerResponse)
|
|||
|
+
|
|||
|
+ // 10.
|
|||
|
+ const bodyReadPromise = createDeferredPromise()
|
|||
|
+
|
|||
|
+ // 11.
|
|||
|
+ if (innerResponse.body != null) {
|
|||
|
+ // 11.1
|
|||
|
+ const stream = innerResponse.body.stream
|
|||
|
+
|
|||
|
+ // 11.2
|
|||
|
+ const reader = stream.getReader()
|
|||
|
+
|
|||
|
+ // 11.3
|
|||
|
+ readAllBytes(
|
|||
|
+ reader,
|
|||
|
+ (bytes) => bodyReadPromise.resolve(bytes),
|
|||
|
+ (error) => bodyReadPromise.reject(error)
|
|||
|
+ )
|
|||
|
+ } else {
|
|||
|
+ bodyReadPromise.resolve(undefined)
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 12.
|
|||
|
+ /** @type {CacheBatchOperation[]} */
|
|||
|
+ const operations = []
|
|||
|
+
|
|||
|
+ // 13.
|
|||
|
+ /** @type {CacheBatchOperation} */
|
|||
|
+ const operation = {
|
|||
|
+ type: 'put', // 14.
|
|||
|
+ request: innerRequest, // 15.
|
|||
|
+ response: clonedResponse // 16.
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 17.
|
|||
|
+ operations.push(operation)
|
|||
|
+
|
|||
|
+ // 19.
|
|||
|
+ const bytes = await bodyReadPromise.promise
|
|||
|
+
|
|||
|
+ if (clonedResponse.body != null) {
|
|||
|
+ clonedResponse.body.source = bytes
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 19.1
|
|||
|
+ const cacheJobPromise = createDeferredPromise()
|
|||
|
+
|
|||
|
+ // 19.2.1
|
|||
|
+ let errorData = null
|
|||
|
+
|
|||
|
+ // 19.2.2
|
|||
|
+ try {
|
|||
|
+ this.#batchCacheOperations(operations)
|
|||
|
+ } catch (e) {
|
|||
|
+ errorData = e
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 19.2.3
|
|||
|
+ queueMicrotask(() => {
|
|||
|
+ // 19.2.3.1
|
|||
|
+ if (errorData === null) {
|
|||
|
+ cacheJobPromise.resolve()
|
|||
|
+ } else { // 19.2.3.2
|
|||
|
+ cacheJobPromise.reject(errorData)
|
|||
|
+ }
|
|||
|
+ })
|
|||
|
+
|
|||
|
+ return cacheJobPromise.promise
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ async delete (request, options = {}) {
|
|||
|
+ webidl.brandCheck(this, Cache)
|
|||
|
+ webidl.argumentLengthCheck(arguments, 1, { header: 'Cache.delete' })
|
|||
|
+
|
|||
|
+ request = webidl.converters.RequestInfo(request)
|
|||
|
+ options = webidl.converters.CacheQueryOptions(options)
|
|||
|
+
|
|||
|
+ /**
|
|||
|
+ * @type {Request}
|
|||
|
+ */
|
|||
|
+ let r = null
|
|||
|
+
|
|||
|
+ if (request instanceof Request) {
|
|||
|
+ r = request[kState]
|
|||
|
+
|
|||
|
+ if (r.method !== 'GET' && !options.ignoreMethod) {
|
|||
|
+ return false
|
|||
|
+ }
|
|||
|
+ } else {
|
|||
|
+ assert(typeof request === 'string')
|
|||
|
+
|
|||
|
+ r = new Request(request)[kState]
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ /** @type {CacheBatchOperation[]} */
|
|||
|
+ const operations = []
|
|||
|
+
|
|||
|
+ /** @type {CacheBatchOperation} */
|
|||
|
+ const operation = {
|
|||
|
+ type: 'delete',
|
|||
|
+ request: r,
|
|||
|
+ options
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ operations.push(operation)
|
|||
|
+
|
|||
|
+ const cacheJobPromise = createDeferredPromise()
|
|||
|
+
|
|||
|
+ let errorData = null
|
|||
|
+ let requestResponses
|
|||
|
+
|
|||
|
+ try {
|
|||
|
+ requestResponses = this.#batchCacheOperations(operations)
|
|||
|
+ } catch (e) {
|
|||
|
+ errorData = e
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ queueMicrotask(() => {
|
|||
|
+ if (errorData === null) {
|
|||
|
+ cacheJobPromise.resolve(!!requestResponses?.length)
|
|||
|
+ } else {
|
|||
|
+ cacheJobPromise.reject(errorData)
|
|||
|
+ }
|
|||
|
+ })
|
|||
|
+
|
|||
|
+ return cacheJobPromise.promise
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ /**
|
|||
|
+ * @see https://w3c.github.io/ServiceWorker/#dom-cache-keys
|
|||
|
+ * @param {any} request
|
|||
|
+ * @param {import('../../types/cache').CacheQueryOptions} options
|
|||
|
+ * @returns {readonly Request[]}
|
|||
|
+ */
|
|||
|
+ async keys (request = undefined, options = {}) {
|
|||
|
+ webidl.brandCheck(this, Cache)
|
|||
|
+
|
|||
|
+ if (request !== undefined) request = webidl.converters.RequestInfo(request)
|
|||
|
+ options = webidl.converters.CacheQueryOptions(options)
|
|||
|
+
|
|||
|
+ // 1.
|
|||
|
+ let r = null
|
|||
|
+
|
|||
|
+ // 2.
|
|||
|
+ if (request !== undefined) {
|
|||
|
+ // 2.1
|
|||
|
+ if (request instanceof Request) {
|
|||
|
+ // 2.1.1
|
|||
|
+ r = request[kState]
|
|||
|
+
|
|||
|
+ // 2.1.2
|
|||
|
+ if (r.method !== 'GET' && !options.ignoreMethod) {
|
|||
|
+ return []
|
|||
|
+ }
|
|||
|
+ } else if (typeof request === 'string') { // 2.2
|
|||
|
+ r = new Request(request)[kState]
|
|||
|
+ }
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 4.
|
|||
|
+ const promise = createDeferredPromise()
|
|||
|
+
|
|||
|
+ // 5.
|
|||
|
+ // 5.1
|
|||
|
+ const requests = []
|
|||
|
+
|
|||
|
+ // 5.2
|
|||
|
+ if (request === undefined) {
|
|||
|
+ // 5.2.1
|
|||
|
+ for (const requestResponse of this.#relevantRequestResponseList) {
|
|||
|
+ // 5.2.1.1
|
|||
|
+ requests.push(requestResponse[0])
|
|||
|
+ }
|
|||
|
+ } else { // 5.3
|
|||
|
+ // 5.3.1
|
|||
|
+ const requestResponses = this.#queryCache(r, options)
|
|||
|
+
|
|||
|
+ // 5.3.2
|
|||
|
+ for (const requestResponse of requestResponses) {
|
|||
|
+ // 5.3.2.1
|
|||
|
+ requests.push(requestResponse[0])
|
|||
|
+ }
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 5.4
|
|||
|
+ queueMicrotask(() => {
|
|||
|
+ // 5.4.1
|
|||
|
+ const requestList = []
|
|||
|
+
|
|||
|
+ // 5.4.2
|
|||
|
+ for (const request of requests) {
|
|||
|
+ const requestObject = new Request('https://a')
|
|||
|
+ requestObject[kState] = request
|
|||
|
+ requestObject[kHeaders][kHeadersList] = request.headersList
|
|||
|
+ requestObject[kHeaders][kGuard] = 'immutable'
|
|||
|
+ requestObject[kRealm] = request.client
|
|||
|
+
|
|||
|
+ // 5.4.2.1
|
|||
|
+ requestList.push(requestObject)
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 5.4.3
|
|||
|
+ promise.resolve(Object.freeze(requestList))
|
|||
|
+ })
|
|||
|
+
|
|||
|
+ return promise.promise
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ /**
|
|||
|
+ * @see https://w3c.github.io/ServiceWorker/#batch-cache-operations-algorithm
|
|||
|
+ * @param {CacheBatchOperation[]} operations
|
|||
|
+ * @returns {requestResponseList}
|
|||
|
+ */
|
|||
|
+ #batchCacheOperations (operations) {
|
|||
|
+ // 1.
|
|||
|
+ const cache = this.#relevantRequestResponseList
|
|||
|
+
|
|||
|
+ // 2.
|
|||
|
+ const backupCache = [...cache]
|
|||
|
+
|
|||
|
+ // 3.
|
|||
|
+ const addedItems = []
|
|||
|
+
|
|||
|
+ // 4.1
|
|||
|
+ const resultList = []
|
|||
|
+
|
|||
|
+ try {
|
|||
|
+ // 4.2
|
|||
|
+ for (const operation of operations) {
|
|||
|
+ // 4.2.1
|
|||
|
+ if (operation.type !== 'delete' && operation.type !== 'put') {
|
|||
|
+ throw webidl.errors.exception({
|
|||
|
+ header: 'Cache.#batchCacheOperations',
|
|||
|
+ message: 'operation type does not match "delete" or "put"'
|
|||
|
+ })
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 4.2.2
|
|||
|
+ if (operation.type === 'delete' && operation.response != null) {
|
|||
|
+ throw webidl.errors.exception({
|
|||
|
+ header: 'Cache.#batchCacheOperations',
|
|||
|
+ message: 'delete operation should not have an associated response'
|
|||
|
+ })
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 4.2.3
|
|||
|
+ if (this.#queryCache(operation.request, operation.options, addedItems).length) {
|
|||
|
+ throw new DOMException('???', 'InvalidStateError')
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 4.2.4
|
|||
|
+ let requestResponses
|
|||
|
+
|
|||
|
+ // 4.2.5
|
|||
|
+ if (operation.type === 'delete') {
|
|||
|
+ // 4.2.5.1
|
|||
|
+ requestResponses = this.#queryCache(operation.request, operation.options)
|
|||
|
+
|
|||
|
+ // TODO: the spec is wrong, this is needed to pass WPTs
|
|||
|
+ if (requestResponses.length === 0) {
|
|||
|
+ return []
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 4.2.5.2
|
|||
|
+ for (const requestResponse of requestResponses) {
|
|||
|
+ const idx = cache.indexOf(requestResponse)
|
|||
|
+ assert(idx !== -1)
|
|||
|
+
|
|||
|
+ // 4.2.5.2.1
|
|||
|
+ cache.splice(idx, 1)
|
|||
|
+ }
|
|||
|
+ } else if (operation.type === 'put') { // 4.2.6
|
|||
|
+ // 4.2.6.1
|
|||
|
+ if (operation.response == null) {
|
|||
|
+ throw webidl.errors.exception({
|
|||
|
+ header: 'Cache.#batchCacheOperations',
|
|||
|
+ message: 'put operation should have an associated response'
|
|||
|
+ })
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 4.2.6.2
|
|||
|
+ const r = operation.request
|
|||
|
+
|
|||
|
+ // 4.2.6.3
|
|||
|
+ if (!urlIsHttpHttpsScheme(r.url)) {
|
|||
|
+ throw webidl.errors.exception({
|
|||
|
+ header: 'Cache.#batchCacheOperations',
|
|||
|
+ message: 'expected http or https scheme'
|
|||
|
+ })
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 4.2.6.4
|
|||
|
+ if (r.method !== 'GET') {
|
|||
|
+ throw webidl.errors.exception({
|
|||
|
+ header: 'Cache.#batchCacheOperations',
|
|||
|
+ message: 'not get method'
|
|||
|
+ })
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 4.2.6.5
|
|||
|
+ if (operation.options != null) {
|
|||
|
+ throw webidl.errors.exception({
|
|||
|
+ header: 'Cache.#batchCacheOperations',
|
|||
|
+ message: 'options must not be defined'
|
|||
|
+ })
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 4.2.6.6
|
|||
|
+ requestResponses = this.#queryCache(operation.request)
|
|||
|
+
|
|||
|
+ // 4.2.6.7
|
|||
|
+ for (const requestResponse of requestResponses) {
|
|||
|
+ const idx = cache.indexOf(requestResponse)
|
|||
|
+ assert(idx !== -1)
|
|||
|
+
|
|||
|
+ // 4.2.6.7.1
|
|||
|
+ cache.splice(idx, 1)
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 4.2.6.8
|
|||
|
+ cache.push([operation.request, operation.response])
|
|||
|
+
|
|||
|
+ // 4.2.6.10
|
|||
|
+ addedItems.push([operation.request, operation.response])
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 4.2.7
|
|||
|
+ resultList.push([operation.request, operation.response])
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 4.3
|
|||
|
+ return resultList
|
|||
|
+ } catch (e) { // 5.
|
|||
|
+ // 5.1
|
|||
|
+ this.#relevantRequestResponseList.length = 0
|
|||
|
+
|
|||
|
+ // 5.2
|
|||
|
+ this.#relevantRequestResponseList = backupCache
|
|||
|
+
|
|||
|
+ // 5.3
|
|||
|
+ throw e
|
|||
|
+ }
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ /**
|
|||
|
+ * @see https://w3c.github.io/ServiceWorker/#query-cache
|
|||
|
+ * @param {any} requestQuery
|
|||
|
+ * @param {import('../../types/cache').CacheQueryOptions} options
|
|||
|
+ * @param {requestResponseList} targetStorage
|
|||
|
+ * @returns {requestResponseList}
|
|||
|
+ */
|
|||
|
+ #queryCache (requestQuery, options, targetStorage) {
|
|||
|
+ /** @type {requestResponseList} */
|
|||
|
+ const resultList = []
|
|||
|
+
|
|||
|
+ const storage = targetStorage ?? this.#relevantRequestResponseList
|
|||
|
+
|
|||
|
+ for (const requestResponse of storage) {
|
|||
|
+ const [cachedRequest, cachedResponse] = requestResponse
|
|||
|
+ if (this.#requestMatchesCachedItem(requestQuery, cachedRequest, cachedResponse, options)) {
|
|||
|
+ resultList.push(requestResponse)
|
|||
|
+ }
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ return resultList
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ /**
|
|||
|
+ * @see https://w3c.github.io/ServiceWorker/#request-matches-cached-item-algorithm
|
|||
|
+ * @param {any} requestQuery
|
|||
|
+ * @param {any} request
|
|||
|
+ * @param {any | null} response
|
|||
|
+ * @param {import('../../types/cache').CacheQueryOptions | undefined} options
|
|||
|
+ * @returns {boolean}
|
|||
|
+ */
|
|||
|
+ #requestMatchesCachedItem (requestQuery, request, response = null, options) {
|
|||
|
+ // if (options?.ignoreMethod === false && request.method === 'GET') {
|
|||
|
+ // return false
|
|||
|
+ // }
|
|||
|
+
|
|||
|
+ const queryURL = new URL(requestQuery.url)
|
|||
|
+
|
|||
|
+ const cachedURL = new URL(request.url)
|
|||
|
+
|
|||
|
+ if (options?.ignoreSearch) {
|
|||
|
+ cachedURL.search = ''
|
|||
|
+
|
|||
|
+ queryURL.search = ''
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ if (!urlEquals(queryURL, cachedURL, true)) {
|
|||
|
+ return false
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ if (
|
|||
|
+ response == null ||
|
|||
|
+ options?.ignoreVary ||
|
|||
|
+ !response.headersList.contains('vary')
|
|||
|
+ ) {
|
|||
|
+ return true
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ const fieldValues = getFieldValues(response.headersList.get('vary'))
|
|||
|
+
|
|||
|
+ for (const fieldValue of fieldValues) {
|
|||
|
+ if (fieldValue === '*') {
|
|||
|
+ return false
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ const requestValue = request.headersList.get(fieldValue)
|
|||
|
+ const queryValue = requestQuery.headersList.get(fieldValue)
|
|||
|
+
|
|||
|
+ // If one has the header and the other doesn't, or one has
|
|||
|
+ // a different value than the other, return false
|
|||
|
+ if (requestValue !== queryValue) {
|
|||
|
+ return false
|
|||
|
+ }
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ return true
|
|||
|
+ }
|
|||
|
+}
|
|||
|
+
|
|||
|
+Object.defineProperties(Cache.prototype, {
|
|||
|
+ [Symbol.toStringTag]: {
|
|||
|
+ value: 'Cache',
|
|||
|
+ configurable: true
|
|||
|
+ },
|
|||
|
+ match: kEnumerableProperty,
|
|||
|
+ matchAll: kEnumerableProperty,
|
|||
|
+ add: kEnumerableProperty,
|
|||
|
+ addAll: kEnumerableProperty,
|
|||
|
+ put: kEnumerableProperty,
|
|||
|
+ delete: kEnumerableProperty,
|
|||
|
+ keys: kEnumerableProperty
|
|||
|
+})
|
|||
|
+
|
|||
|
+const cacheQueryOptionConverters = [
|
|||
|
+ {
|
|||
|
+ key: 'ignoreSearch',
|
|||
|
+ converter: webidl.converters.boolean,
|
|||
|
+ defaultValue: false
|
|||
|
+ },
|
|||
|
+ {
|
|||
|
+ key: 'ignoreMethod',
|
|||
|
+ converter: webidl.converters.boolean,
|
|||
|
+ defaultValue: false
|
|||
|
+ },
|
|||
|
+ {
|
|||
|
+ key: 'ignoreVary',
|
|||
|
+ converter: webidl.converters.boolean,
|
|||
|
+ defaultValue: false
|
|||
|
+ }
|
|||
|
+]
|
|||
|
+
|
|||
|
+webidl.converters.CacheQueryOptions = webidl.dictionaryConverter(cacheQueryOptionConverters)
|
|||
|
+
|
|||
|
+webidl.converters.MultiCacheQueryOptions = webidl.dictionaryConverter([
|
|||
|
+ ...cacheQueryOptionConverters,
|
|||
|
+ {
|
|||
|
+ key: 'cacheName',
|
|||
|
+ converter: webidl.converters.DOMString
|
|||
|
+ }
|
|||
|
+])
|
|||
|
+
|
|||
|
+webidl.converters.Response = webidl.interfaceConverter(Response)
|
|||
|
+
|
|||
|
+webidl.converters['sequence<RequestInfo>'] = webidl.sequenceConverter(
|
|||
|
+ webidl.converters.RequestInfo
|
|||
|
+)
|
|||
|
+
|
|||
|
+module.exports = {
|
|||
|
+ Cache
|
|||
|
+}
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/cache/cachestorage.js
|
|||
|
===================================================================
|
|||
|
--- /dev/null
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/cache/cachestorage.js
|
|||
|
@@ -0,0 +1,144 @@
|
|||
|
+'use strict'
|
|||
|
+
|
|||
|
+const { kConstruct } = require('./symbols')
|
|||
|
+const { Cache } = require('./cache')
|
|||
|
+const { webidl } = require('../fetch/webidl')
|
|||
|
+const { kEnumerableProperty } = require('../core/util')
|
|||
|
+
|
|||
|
+class CacheStorage {
|
|||
|
+ /**
|
|||
|
+ * @see https://w3c.github.io/ServiceWorker/#dfn-relevant-name-to-cache-map
|
|||
|
+ * @type {Map<string, import('./cache').requestResponseList}
|
|||
|
+ */
|
|||
|
+ #caches = new Map()
|
|||
|
+
|
|||
|
+ constructor () {
|
|||
|
+ if (arguments[0] !== kConstruct) {
|
|||
|
+ webidl.illegalConstructor()
|
|||
|
+ }
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ async match (request, options = {}) {
|
|||
|
+ webidl.brandCheck(this, CacheStorage)
|
|||
|
+ webidl.argumentLengthCheck(arguments, 1, { header: 'CacheStorage.match' })
|
|||
|
+
|
|||
|
+ request = webidl.converters.RequestInfo(request)
|
|||
|
+ options = webidl.converters.MultiCacheQueryOptions(options)
|
|||
|
+
|
|||
|
+ // 1.
|
|||
|
+ if (options.cacheName != null) {
|
|||
|
+ // 1.1.1.1
|
|||
|
+ if (this.#caches.has(options.cacheName)) {
|
|||
|
+ // 1.1.1.1.1
|
|||
|
+ const cacheList = this.#caches.get(options.cacheName)
|
|||
|
+ const cache = new Cache(kConstruct, cacheList)
|
|||
|
+
|
|||
|
+ return await cache.match(request, options)
|
|||
|
+ }
|
|||
|
+ } else { // 2.
|
|||
|
+ // 2.2
|
|||
|
+ for (const cacheList of this.#caches.values()) {
|
|||
|
+ const cache = new Cache(kConstruct, cacheList)
|
|||
|
+
|
|||
|
+ // 2.2.1.2
|
|||
|
+ const response = await cache.match(request, options)
|
|||
|
+
|
|||
|
+ if (response !== undefined) {
|
|||
|
+ return response
|
|||
|
+ }
|
|||
|
+ }
|
|||
|
+ }
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ /**
|
|||
|
+ * @see https://w3c.github.io/ServiceWorker/#cache-storage-has
|
|||
|
+ * @param {string} cacheName
|
|||
|
+ * @returns {Promise<boolean>}
|
|||
|
+ */
|
|||
|
+ async has (cacheName) {
|
|||
|
+ webidl.brandCheck(this, CacheStorage)
|
|||
|
+ webidl.argumentLengthCheck(arguments, 1, { header: 'CacheStorage.has' })
|
|||
|
+
|
|||
|
+ cacheName = webidl.converters.DOMString(cacheName)
|
|||
|
+
|
|||
|
+ // 2.1.1
|
|||
|
+ // 2.2
|
|||
|
+ return this.#caches.has(cacheName)
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ /**
|
|||
|
+ * @see https://w3c.github.io/ServiceWorker/#dom-cachestorage-open
|
|||
|
+ * @param {string} cacheName
|
|||
|
+ * @returns {Promise<Cache>}
|
|||
|
+ */
|
|||
|
+ async open (cacheName) {
|
|||
|
+ webidl.brandCheck(this, CacheStorage)
|
|||
|
+ webidl.argumentLengthCheck(arguments, 1, { header: 'CacheStorage.open' })
|
|||
|
+
|
|||
|
+ cacheName = webidl.converters.DOMString(cacheName)
|
|||
|
+
|
|||
|
+ // 2.1
|
|||
|
+ if (this.#caches.has(cacheName)) {
|
|||
|
+ // await caches.open('v1') !== await caches.open('v1')
|
|||
|
+
|
|||
|
+ // 2.1.1
|
|||
|
+ const cache = this.#caches.get(cacheName)
|
|||
|
+
|
|||
|
+ // 2.1.1.1
|
|||
|
+ return new Cache(kConstruct, cache)
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ // 2.2
|
|||
|
+ const cache = []
|
|||
|
+
|
|||
|
+ // 2.3
|
|||
|
+ this.#caches.set(cacheName, cache)
|
|||
|
+
|
|||
|
+ // 2.4
|
|||
|
+ return new Cache(kConstruct, cache)
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ /**
|
|||
|
+ * @see https://w3c.github.io/ServiceWorker/#cache-storage-delete
|
|||
|
+ * @param {string} cacheName
|
|||
|
+ * @returns {Promise<boolean>}
|
|||
|
+ */
|
|||
|
+ async delete (cacheName) {
|
|||
|
+ webidl.brandCheck(this, CacheStorage)
|
|||
|
+ webidl.argumentLengthCheck(arguments, 1, { header: 'CacheStorage.delete' })
|
|||
|
+
|
|||
|
+ cacheName = webidl.converters.DOMString(cacheName)
|
|||
|
+
|
|||
|
+ return this.#caches.delete(cacheName)
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ /**
|
|||
|
+ * @see https://w3c.github.io/ServiceWorker/#cache-storage-keys
|
|||
|
+ * @returns {string[]}
|
|||
|
+ */
|
|||
|
+ async keys () {
|
|||
|
+ webidl.brandCheck(this, CacheStorage)
|
|||
|
+
|
|||
|
+ // 2.1
|
|||
|
+ const keys = this.#caches.keys()
|
|||
|
+
|
|||
|
+ // 2.2
|
|||
|
+ return [...keys]
|
|||
|
+ }
|
|||
|
+}
|
|||
|
+
|
|||
|
+Object.defineProperties(CacheStorage.prototype, {
|
|||
|
+ [Symbol.toStringTag]: {
|
|||
|
+ value: 'CacheStorage',
|
|||
|
+ configurable: true
|
|||
|
+ },
|
|||
|
+ match: kEnumerableProperty,
|
|||
|
+ has: kEnumerableProperty,
|
|||
|
+ open: kEnumerableProperty,
|
|||
|
+ delete: kEnumerableProperty,
|
|||
|
+ keys: kEnumerableProperty
|
|||
|
+})
|
|||
|
+
|
|||
|
+module.exports = {
|
|||
|
+ CacheStorage
|
|||
|
+}
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/cache/symbols.js
|
|||
|
===================================================================
|
|||
|
--- /dev/null
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/cache/symbols.js
|
|||
|
@@ -0,0 +1,5 @@
|
|||
|
+'use strict'
|
|||
|
+
|
|||
|
+module.exports = {
|
|||
|
+ kConstruct: Symbol('constructable')
|
|||
|
+}
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/cache/util.js
|
|||
|
===================================================================
|
|||
|
--- /dev/null
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/cache/util.js
|
|||
|
@@ -0,0 +1,49 @@
|
|||
|
+'use strict'
|
|||
|
+
|
|||
|
+const assert = require('assert')
|
|||
|
+const { URLSerializer } = require('../fetch/dataURL')
|
|||
|
+const { isValidHeaderName } = require('../fetch/util')
|
|||
|
+
|
|||
|
+/**
|
|||
|
+ * @see https://url.spec.whatwg.org/#concept-url-equals
|
|||
|
+ * @param {URL} A
|
|||
|
+ * @param {URL} B
|
|||
|
+ * @param {boolean | undefined} excludeFragment
|
|||
|
+ * @returns {boolean}
|
|||
|
+ */
|
|||
|
+function urlEquals (A, B, excludeFragment = false) {
|
|||
|
+ const serializedA = URLSerializer(A, excludeFragment)
|
|||
|
+
|
|||
|
+ const serializedB = URLSerializer(B, excludeFragment)
|
|||
|
+
|
|||
|
+ return serializedA === serializedB
|
|||
|
+}
|
|||
|
+
|
|||
|
+/**
|
|||
|
+ * @see https://github.com/chromium/chromium/blob/694d20d134cb553d8d89e5500b9148012b1ba299/content/browser/cache_storage/cache_storage_cache.cc#L260-L262
|
|||
|
+ * @param {string} header
|
|||
|
+ */
|
|||
|
+function fieldValues (header) {
|
|||
|
+ assert(header !== null)
|
|||
|
+
|
|||
|
+ const values = []
|
|||
|
+
|
|||
|
+ for (let value of header.split(',')) {
|
|||
|
+ value = value.trim()
|
|||
|
+
|
|||
|
+ if (!value.length) {
|
|||
|
+ continue
|
|||
|
+ } else if (!isValidHeaderName(value)) {
|
|||
|
+ continue
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ values.push(value)
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ return values
|
|||
|
+}
|
|||
|
+
|
|||
|
+module.exports = {
|
|||
|
+ urlEquals,
|
|||
|
+ fieldValues
|
|||
|
+}
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/fetch/body.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/fetch/body.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/fetch/body.js
|
|||
|
@@ -123,6 +123,7 @@ function extractBody (object, keepalive
|
|||
|
const blobParts = []
|
|||
|
const rn = new Uint8Array([13, 10]) // '\r\n'
|
|||
|
length = 0
|
|||
|
+ let hasUnknownSizeValue = false
|
|||
|
|
|||
|
for (const [name, value] of object) {
|
|||
|
if (typeof value === 'string') {
|
|||
|
@@ -138,13 +139,20 @@ function extractBody (object, keepalive
|
|||
|
value.type || 'application/octet-stream'
|
|||
|
}\r\n\r\n`)
|
|||
|
blobParts.push(chunk, value, rn)
|
|||
|
- length += chunk.byteLength + value.size + rn.byteLength
|
|||
|
+ if (typeof value.size === 'number') {
|
|||
|
+ length += chunk.byteLength + value.size + rn.byteLength
|
|||
|
+ } else {
|
|||
|
+ hasUnknownSizeValue = true
|
|||
|
+ }
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
const chunk = enc.encode(`--${boundary}--`)
|
|||
|
blobParts.push(chunk)
|
|||
|
length += chunk.byteLength
|
|||
|
+ if (hasUnknownSizeValue) {
|
|||
|
+ length = null
|
|||
|
+ }
|
|||
|
|
|||
|
// Set source to object.
|
|||
|
source = object
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/fetch/webidl.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/fetch/webidl.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/fetch/webidl.js
|
|||
|
@@ -51,6 +51,13 @@ webidl.argumentLengthCheck = function ({
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
+webidl.illegalConstructor = function () {
|
|||
|
+ throw webidl.errors.exception({
|
|||
|
+ header: 'TypeError',
|
|||
|
+ message: 'Illegal constructor'
|
|||
|
+ })
|
|||
|
+}
|
|||
|
+
|
|||
|
// https://tc39.es/ecma262/#sec-ecmascript-data-types-and-values
|
|||
|
webidl.util.Type = function (V) {
|
|||
|
switch (typeof V) {
|
|||
|
Index: node-v16.20.2/deps/undici/src/lib/websocket/frame.js
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/lib/websocket/frame.js
|
|||
|
+++ node-v16.20.2/deps/undici/src/lib/websocket/frame.js
|
|||
|
@@ -43,7 +43,7 @@ class WebsocketFrameSend {
|
|||
|
buffer[1] = payloadLength
|
|||
|
|
|||
|
if (payloadLength === 126) {
|
|||
|
- new DataView(buffer.buffer).setUint16(2, bodyLength)
|
|||
|
+ buffer.writeUInt16BE(bodyLength, 2)
|
|||
|
} else if (payloadLength === 127) {
|
|||
|
// Clear extended payload length
|
|||
|
buffer[2] = buffer[3] = 0
|
|||
|
Index: node-v16.20.2/deps/undici/src/types/cache.d.ts
|
|||
|
===================================================================
|
|||
|
--- /dev/null
|
|||
|
+++ node-v16.20.2/deps/undici/src/types/cache.d.ts
|
|||
|
@@ -0,0 +1,36 @@
|
|||
|
+import type { RequestInfo, Response, Request } from './fetch'
|
|||
|
+
|
|||
|
+export interface CacheStorage {
|
|||
|
+ match (request: RequestInfo, options?: MultiCacheQueryOptions): Promise<Response | undefined>,
|
|||
|
+ has (cacheName: string): Promise<boolean>,
|
|||
|
+ open (cacheName: string): Promise<Cache>,
|
|||
|
+ delete (cacheName: string): Promise<boolean>,
|
|||
|
+ keys (): Promise<string[]>
|
|||
|
+}
|
|||
|
+
|
|||
|
+declare const CacheStorage: {
|
|||
|
+ prototype: CacheStorage
|
|||
|
+ new(): CacheStorage
|
|||
|
+}
|
|||
|
+
|
|||
|
+export interface Cache {
|
|||
|
+ match (request: RequestInfo, options?: CacheQueryOptions): Promise<Response | undefined>,
|
|||
|
+ matchAll (request?: RequestInfo, options?: CacheQueryOptions): Promise<readonly Response[]>,
|
|||
|
+ add (request: RequestInfo): Promise<undefined>,
|
|||
|
+ addAll (requests: RequestInfo[]): Promise<undefined>,
|
|||
|
+ put (request: RequestInfo, response: Response): Promise<undefined>,
|
|||
|
+ delete (request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>,
|
|||
|
+ keys (request?: RequestInfo, options?: CacheQueryOptions): Promise<readonly Request[]>
|
|||
|
+}
|
|||
|
+
|
|||
|
+export interface CacheQueryOptions {
|
|||
|
+ ignoreSearch?: boolean,
|
|||
|
+ ignoreMethod?: boolean,
|
|||
|
+ ignoreVary?: boolean
|
|||
|
+}
|
|||
|
+
|
|||
|
+export interface MultiCacheQueryOptions extends CacheQueryOptions {
|
|||
|
+ cacheName?: string
|
|||
|
+}
|
|||
|
+
|
|||
|
+export declare const caches: CacheStorage
|
|||
|
Index: node-v16.20.2/deps/undici/src/types/errors.d.ts
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/types/errors.d.ts
|
|||
|
+++ node-v16.20.2/deps/undici/src/types/errors.d.ts
|
|||
|
@@ -4,7 +4,10 @@ import Client from './client'
|
|||
|
export default Errors
|
|||
|
|
|||
|
declare namespace Errors {
|
|||
|
- export class UndiciError extends Error { }
|
|||
|
+ export class UndiciError extends Error {
|
|||
|
+ name: string;
|
|||
|
+ code: string;
|
|||
|
+ }
|
|||
|
|
|||
|
/** Connect timeout error. */
|
|||
|
export class ConnectTimeoutError extends UndiciError {
|
|||
|
@@ -31,6 +34,12 @@ declare namespace Errors {
|
|||
|
}
|
|||
|
|
|||
|
export class ResponseStatusCodeError extends UndiciError {
|
|||
|
+ constructor (
|
|||
|
+ message?: string,
|
|||
|
+ statusCode?: number,
|
|||
|
+ headers?: IncomingHttpHeaders | string[] | null,
|
|||
|
+ body?: null | Record<string, any> | string
|
|||
|
+ );
|
|||
|
name: 'ResponseStatusCodeError';
|
|||
|
code: 'UND_ERR_RESPONSE_STATUS_CODE';
|
|||
|
body: null | Record<string, any> | string
|
|||
|
Index: node-v16.20.2/deps/undici/src/types/webidl.d.ts
|
|||
|
===================================================================
|
|||
|
--- node-v16.20.2.orig/deps/undici/src/types/webidl.d.ts
|
|||
|
+++ node-v16.20.2/deps/undici/src/types/webidl.d.ts
|
|||
|
@@ -170,6 +170,8 @@ export interface Webidl {
|
|||
|
*/
|
|||
|
sequenceConverter <Type>(C: Converter<Type>): SequenceConverter<Type>
|
|||
|
|
|||
|
+ illegalConstructor (): never
|
|||
|
+
|
|||
|
/**
|
|||
|
* @see https://webidl.spec.whatwg.org/#es-to-record
|
|||
|
* @description Convert a value, V, to a WebIDL record type.
|