mirror of
https://github.com/opentofu/setup-opentofu.git
synced 2026-12-01 04:04:28 +01:00
1 parent
fc711fa910
commit
4959f8f18c
3 files changed
+208
-31
No files matched your search
Vendored
+100
-12
@@ -5599,6 +5599,24 @@ class SecureProxyConnectionError extends UndiciError {
|
|||||||
[kSecureProxyConnectionError] = true
|
[kSecureProxyConnectionError] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const kMessageSizeExceededError = Symbol.for('undici.error.UND_ERR_WS_MESSAGE_SIZE_EXCEEDED')
|
||||||
|
class MessageSizeExceededError extends UndiciError {
|
||||||
|
constructor (message) {
|
||||||
|
super(message)
|
||||||
|
this.name = 'MessageSizeExceededError'
|
||||||
|
this.message = message || 'Max decompressed message size exceeded'
|
||||||
|
this.code = 'UND_ERR_WS_MESSAGE_SIZE_EXCEEDED'
|
||||||
|
}
|
||||||
|
|
||||||
|
static [Symbol.hasInstance] (instance) {
|
||||||
|
return instance && instance[kMessageSizeExceededError] === true
|
||||||
|
}
|
||||||
|
|
||||||
|
get [kMessageSizeExceededError] () {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
AbortError,
|
AbortError,
|
||||||
HTTPParserError,
|
HTTPParserError,
|
||||||
@@ -5622,7 +5640,8 @@ module.exports = {
|
|||||||
ResponseExceededMaxSizeError,
|
ResponseExceededMaxSizeError,
|
||||||
RequestRetryError,
|
RequestRetryError,
|
||||||
ResponseError,
|
ResponseError,
|
||||||
SecureProxyConnectionError
|
SecureProxyConnectionError,
|
||||||
|
MessageSizeExceededError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -5699,6 +5718,10 @@ class Request {
|
|||||||
throw new InvalidArgumentError('upgrade must be a string')
|
throw new InvalidArgumentError('upgrade must be a string')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (upgrade && !isValidHeaderValue(upgrade)) {
|
||||||
|
throw new InvalidArgumentError('invalid upgrade header')
|
||||||
|
}
|
||||||
|
|
||||||
if (headersTimeout != null && (!Number.isFinite(headersTimeout) || headersTimeout < 0)) {
|
if (headersTimeout != null && (!Number.isFinite(headersTimeout) || headersTimeout < 0)) {
|
||||||
throw new InvalidArgumentError('invalid headersTimeout')
|
throw new InvalidArgumentError('invalid headersTimeout')
|
||||||
}
|
}
|
||||||
@@ -5993,13 +6016,19 @@ function processHeader (request, key, val) {
|
|||||||
val = `${val}`
|
val = `${val}`
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.host === null && headerName === 'host') {
|
if (headerName === 'host') {
|
||||||
|
if (request.host !== null) {
|
||||||
|
throw new InvalidArgumentError('duplicate host header')
|
||||||
|
}
|
||||||
if (typeof val !== 'string') {
|
if (typeof val !== 'string') {
|
||||||
throw new InvalidArgumentError('invalid host header')
|
throw new InvalidArgumentError('invalid host header')
|
||||||
}
|
}
|
||||||
// Consumed by Client
|
// Consumed by Client
|
||||||
request.host = val
|
request.host = val
|
||||||
} else if (request.contentLength === null && headerName === 'content-length') {
|
} else if (headerName === 'content-length') {
|
||||||
|
if (request.contentLength !== null) {
|
||||||
|
throw new InvalidArgumentError('duplicate content-length header')
|
||||||
|
}
|
||||||
request.contentLength = parseInt(val, 10)
|
request.contentLength = parseInt(val, 10)
|
||||||
if (!Number.isFinite(request.contentLength)) {
|
if (!Number.isFinite(request.contentLength)) {
|
||||||
throw new InvalidArgumentError('invalid content-length header')
|
throw new InvalidArgumentError('invalid content-length header')
|
||||||
@@ -28716,17 +28745,30 @@ module.exports = {
|
|||||||
|
|
||||||
const { createInflateRaw, Z_DEFAULT_WINDOWBITS } = __nccwpck_require__(8522)
|
const { createInflateRaw, Z_DEFAULT_WINDOWBITS } = __nccwpck_require__(8522)
|
||||||
const { isValidClientWindowBits } = __nccwpck_require__(8625)
|
const { isValidClientWindowBits } = __nccwpck_require__(8625)
|
||||||
|
const { MessageSizeExceededError } = __nccwpck_require__(8707)
|
||||||
|
|
||||||
const tail = Buffer.from([0x00, 0x00, 0xff, 0xff])
|
const tail = Buffer.from([0x00, 0x00, 0xff, 0xff])
|
||||||
const kBuffer = Symbol('kBuffer')
|
const kBuffer = Symbol('kBuffer')
|
||||||
const kLength = Symbol('kLength')
|
const kLength = Symbol('kLength')
|
||||||
|
|
||||||
|
// Default maximum decompressed message size: 4 MB
|
||||||
|
const kDefaultMaxDecompressedSize = 4 * 1024 * 1024
|
||||||
|
|
||||||
class PerMessageDeflate {
|
class PerMessageDeflate {
|
||||||
/** @type {import('node:zlib').InflateRaw} */
|
/** @type {import('node:zlib').InflateRaw} */
|
||||||
#inflate
|
#inflate
|
||||||
|
|
||||||
#options = {}
|
#options = {}
|
||||||
|
|
||||||
|
/** @type {boolean} */
|
||||||
|
#aborted = false
|
||||||
|
|
||||||
|
/** @type {Function|null} */
|
||||||
|
#currentCallback = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Map<string, string>} extensions
|
||||||
|
*/
|
||||||
constructor (extensions) {
|
constructor (extensions) {
|
||||||
this.#options.serverNoContextTakeover = extensions.has('server_no_context_takeover')
|
this.#options.serverNoContextTakeover = extensions.has('server_no_context_takeover')
|
||||||
this.#options.serverMaxWindowBits = extensions.get('server_max_window_bits')
|
this.#options.serverMaxWindowBits = extensions.get('server_max_window_bits')
|
||||||
@@ -28738,6 +28780,11 @@ class PerMessageDeflate {
|
|||||||
// payload of the message.
|
// payload of the message.
|
||||||
// 2. Decompress the resulting data using DEFLATE.
|
// 2. Decompress the resulting data using DEFLATE.
|
||||||
|
|
||||||
|
if (this.#aborted) {
|
||||||
|
callback(new MessageSizeExceededError())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.#inflate) {
|
if (!this.#inflate) {
|
||||||
let windowBits = Z_DEFAULT_WINDOWBITS
|
let windowBits = Z_DEFAULT_WINDOWBITS
|
||||||
|
|
||||||
@@ -28750,13 +28797,37 @@ class PerMessageDeflate {
|
|||||||
windowBits = Number.parseInt(this.#options.serverMaxWindowBits)
|
windowBits = Number.parseInt(this.#options.serverMaxWindowBits)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#inflate = createInflateRaw({ windowBits })
|
try {
|
||||||
|
this.#inflate = createInflateRaw({ windowBits })
|
||||||
|
} catch (err) {
|
||||||
|
callback(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
this.#inflate[kBuffer] = []
|
this.#inflate[kBuffer] = []
|
||||||
this.#inflate[kLength] = 0
|
this.#inflate[kLength] = 0
|
||||||
|
|
||||||
this.#inflate.on('data', (data) => {
|
this.#inflate.on('data', (data) => {
|
||||||
this.#inflate[kBuffer].push(data)
|
if (this.#aborted) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
this.#inflate[kLength] += data.length
|
this.#inflate[kLength] += data.length
|
||||||
|
|
||||||
|
if (this.#inflate[kLength] > kDefaultMaxDecompressedSize) {
|
||||||
|
this.#aborted = true
|
||||||
|
this.#inflate.removeAllListeners()
|
||||||
|
this.#inflate.destroy()
|
||||||
|
this.#inflate = null
|
||||||
|
|
||||||
|
if (this.#currentCallback) {
|
||||||
|
const cb = this.#currentCallback
|
||||||
|
this.#currentCallback = null
|
||||||
|
cb(new MessageSizeExceededError())
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.#inflate[kBuffer].push(data)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.#inflate.on('error', (err) => {
|
this.#inflate.on('error', (err) => {
|
||||||
@@ -28765,16 +28836,22 @@ class PerMessageDeflate {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.#currentCallback = callback
|
||||||
this.#inflate.write(chunk)
|
this.#inflate.write(chunk)
|
||||||
if (fin) {
|
if (fin) {
|
||||||
this.#inflate.write(tail)
|
this.#inflate.write(tail)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#inflate.flush(() => {
|
this.#inflate.flush(() => {
|
||||||
|
if (this.#aborted || !this.#inflate) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const full = Buffer.concat(this.#inflate[kBuffer], this.#inflate[kLength])
|
const full = Buffer.concat(this.#inflate[kBuffer], this.#inflate[kLength])
|
||||||
|
|
||||||
this.#inflate[kBuffer].length = 0
|
this.#inflate[kBuffer].length = 0
|
||||||
this.#inflate[kLength] = 0
|
this.#inflate[kLength] = 0
|
||||||
|
this.#currentCallback = null
|
||||||
|
|
||||||
callback(null, full)
|
callback(null, full)
|
||||||
})
|
})
|
||||||
@@ -28828,6 +28905,10 @@ class ByteParser extends Writable {
|
|||||||
/** @type {Map<string, PerMessageDeflate>} */
|
/** @type {Map<string, PerMessageDeflate>} */
|
||||||
#extensions
|
#extensions
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {import('./websocket').WebSocket} ws
|
||||||
|
* @param {Map<string, string>|null} extensions
|
||||||
|
*/
|
||||||
constructor (ws, extensions) {
|
constructor (ws, extensions) {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
@@ -28970,6 +29051,7 @@ class ByteParser extends Writable {
|
|||||||
|
|
||||||
const buffer = this.consume(8)
|
const buffer = this.consume(8)
|
||||||
const upper = buffer.readUInt32BE(0)
|
const upper = buffer.readUInt32BE(0)
|
||||||
|
const lower = buffer.readUInt32BE(4)
|
||||||
|
|
||||||
// 2^31 is the maximum bytes an arraybuffer can contain
|
// 2^31 is the maximum bytes an arraybuffer can contain
|
||||||
// on 32-bit systems. Although, on 64-bit systems, this is
|
// on 32-bit systems. Although, on 64-bit systems, this is
|
||||||
@@ -28977,14 +29059,12 @@ class ByteParser extends Writable {
|
|||||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_array_length
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_array_length
|
||||||
// https://source.chromium.org/chromium/chromium/src/+/main:v8/src/common/globals.h;drc=1946212ac0100668f14eb9e2843bdd846e510a1e;bpv=1;bpt=1;l=1275
|
// https://source.chromium.org/chromium/chromium/src/+/main:v8/src/common/globals.h;drc=1946212ac0100668f14eb9e2843bdd846e510a1e;bpv=1;bpt=1;l=1275
|
||||||
// https://source.chromium.org/chromium/chromium/src/+/main:v8/src/objects/js-array-buffer.h;l=34;drc=1946212ac0100668f14eb9e2843bdd846e510a1e
|
// https://source.chromium.org/chromium/chromium/src/+/main:v8/src/objects/js-array-buffer.h;l=34;drc=1946212ac0100668f14eb9e2843bdd846e510a1e
|
||||||
if (upper > 2 ** 31 - 1) {
|
if (upper !== 0 || lower > 2 ** 31 - 1) {
|
||||||
failWebsocketConnection(this.ws, 'Received payload length > 2^31 bytes.')
|
failWebsocketConnection(this.ws, 'Received payload length > 2^31 bytes.')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const lower = buffer.readUInt32BE(4)
|
this.#info.payloadLength = lower
|
||||||
|
|
||||||
this.#info.payloadLength = (upper << 8) + lower
|
|
||||||
this.#state = parserStates.READ_DATA
|
this.#state = parserStates.READ_DATA
|
||||||
} else if (this.#state === parserStates.READ_DATA) {
|
} else if (this.#state === parserStates.READ_DATA) {
|
||||||
if (this.#byteOffset < this.#info.payloadLength) {
|
if (this.#byteOffset < this.#info.payloadLength) {
|
||||||
@@ -29014,7 +29094,7 @@ class ByteParser extends Writable {
|
|||||||
} else {
|
} else {
|
||||||
this.#extensions.get('permessage-deflate').decompress(body, this.#info.fin, (error, data) => {
|
this.#extensions.get('permessage-deflate').decompress(body, this.#info.fin, (error, data) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
closeWebSocketConnection(this.ws, 1007, error.message, error.message.length)
|
failWebsocketConnection(this.ws, error.message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29618,6 +29698,12 @@ function parseExtensions (extensions) {
|
|||||||
* @param {string} value
|
* @param {string} value
|
||||||
*/
|
*/
|
||||||
function isValidClientWindowBits (value) {
|
function isValidClientWindowBits (value) {
|
||||||
|
// Must have at least one character
|
||||||
|
if (value.length === 0) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check all characters are ASCII digits
|
||||||
for (let i = 0; i < value.length; i++) {
|
for (let i = 0; i < value.length; i++) {
|
||||||
const byte = value.charCodeAt(i)
|
const byte = value.charCodeAt(i)
|
||||||
|
|
||||||
@@ -29626,7 +29712,9 @@ function isValidClientWindowBits (value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
// Check numeric range: zlib requires windowBits in range 8-15
|
||||||
|
const num = Number.parseInt(value, 10)
|
||||||
|
return num >= 8 && num <= 15
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://nodejs.org/api/intl.html#detecting-internationalization-support
|
// https://nodejs.org/api/intl.html#detecting-internationalization-support
|
||||||
@@ -30104,7 +30192,7 @@ class WebSocket extends EventTarget {
|
|||||||
* @see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
* @see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
||||||
*/
|
*/
|
||||||
#onConnectionEstablished (response, parsedExtensions) {
|
#onConnectionEstablished (response, parsedExtensions) {
|
||||||
// processResponse is called when the "response’s header list has been received and initialized."
|
// processResponse is called when the "response's header list has been received and initialized."
|
||||||
// once this happens, the connection is open
|
// once this happens, the connection is open
|
||||||
this[kResponse] = response
|
this[kResponse] = response
|
||||||
|
|
||||||
|
|||||||
Vendored
+100
-12
@@ -2930,6 +2930,24 @@ class SecureProxyConnectionError extends UndiciError {
|
|||||||
[kSecureProxyConnectionError] = true
|
[kSecureProxyConnectionError] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const kMessageSizeExceededError = Symbol.for('undici.error.UND_ERR_WS_MESSAGE_SIZE_EXCEEDED')
|
||||||
|
class MessageSizeExceededError extends UndiciError {
|
||||||
|
constructor (message) {
|
||||||
|
super(message)
|
||||||
|
this.name = 'MessageSizeExceededError'
|
||||||
|
this.message = message || 'Max decompressed message size exceeded'
|
||||||
|
this.code = 'UND_ERR_WS_MESSAGE_SIZE_EXCEEDED'
|
||||||
|
}
|
||||||
|
|
||||||
|
static [Symbol.hasInstance] (instance) {
|
||||||
|
return instance && instance[kMessageSizeExceededError] === true
|
||||||
|
}
|
||||||
|
|
||||||
|
get [kMessageSizeExceededError] () {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
AbortError,
|
AbortError,
|
||||||
HTTPParserError,
|
HTTPParserError,
|
||||||
@@ -2953,7 +2971,8 @@ module.exports = {
|
|||||||
ResponseExceededMaxSizeError,
|
ResponseExceededMaxSizeError,
|
||||||
RequestRetryError,
|
RequestRetryError,
|
||||||
ResponseError,
|
ResponseError,
|
||||||
SecureProxyConnectionError
|
SecureProxyConnectionError,
|
||||||
|
MessageSizeExceededError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3030,6 +3049,10 @@ class Request {
|
|||||||
throw new InvalidArgumentError('upgrade must be a string')
|
throw new InvalidArgumentError('upgrade must be a string')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (upgrade && !isValidHeaderValue(upgrade)) {
|
||||||
|
throw new InvalidArgumentError('invalid upgrade header')
|
||||||
|
}
|
||||||
|
|
||||||
if (headersTimeout != null && (!Number.isFinite(headersTimeout) || headersTimeout < 0)) {
|
if (headersTimeout != null && (!Number.isFinite(headersTimeout) || headersTimeout < 0)) {
|
||||||
throw new InvalidArgumentError('invalid headersTimeout')
|
throw new InvalidArgumentError('invalid headersTimeout')
|
||||||
}
|
}
|
||||||
@@ -3324,13 +3347,19 @@ function processHeader (request, key, val) {
|
|||||||
val = `${val}`
|
val = `${val}`
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.host === null && headerName === 'host') {
|
if (headerName === 'host') {
|
||||||
|
if (request.host !== null) {
|
||||||
|
throw new InvalidArgumentError('duplicate host header')
|
||||||
|
}
|
||||||
if (typeof val !== 'string') {
|
if (typeof val !== 'string') {
|
||||||
throw new InvalidArgumentError('invalid host header')
|
throw new InvalidArgumentError('invalid host header')
|
||||||
}
|
}
|
||||||
// Consumed by Client
|
// Consumed by Client
|
||||||
request.host = val
|
request.host = val
|
||||||
} else if (request.contentLength === null && headerName === 'content-length') {
|
} else if (headerName === 'content-length') {
|
||||||
|
if (request.contentLength !== null) {
|
||||||
|
throw new InvalidArgumentError('duplicate content-length header')
|
||||||
|
}
|
||||||
request.contentLength = parseInt(val, 10)
|
request.contentLength = parseInt(val, 10)
|
||||||
if (!Number.isFinite(request.contentLength)) {
|
if (!Number.isFinite(request.contentLength)) {
|
||||||
throw new InvalidArgumentError('invalid content-length header')
|
throw new InvalidArgumentError('invalid content-length header')
|
||||||
@@ -26047,17 +26076,30 @@ module.exports = {
|
|||||||
|
|
||||||
const { createInflateRaw, Z_DEFAULT_WINDOWBITS } = __nccwpck_require__(8522)
|
const { createInflateRaw, Z_DEFAULT_WINDOWBITS } = __nccwpck_require__(8522)
|
||||||
const { isValidClientWindowBits } = __nccwpck_require__(8625)
|
const { isValidClientWindowBits } = __nccwpck_require__(8625)
|
||||||
|
const { MessageSizeExceededError } = __nccwpck_require__(8707)
|
||||||
|
|
||||||
const tail = Buffer.from([0x00, 0x00, 0xff, 0xff])
|
const tail = Buffer.from([0x00, 0x00, 0xff, 0xff])
|
||||||
const kBuffer = Symbol('kBuffer')
|
const kBuffer = Symbol('kBuffer')
|
||||||
const kLength = Symbol('kLength')
|
const kLength = Symbol('kLength')
|
||||||
|
|
||||||
|
// Default maximum decompressed message size: 4 MB
|
||||||
|
const kDefaultMaxDecompressedSize = 4 * 1024 * 1024
|
||||||
|
|
||||||
class PerMessageDeflate {
|
class PerMessageDeflate {
|
||||||
/** @type {import('node:zlib').InflateRaw} */
|
/** @type {import('node:zlib').InflateRaw} */
|
||||||
#inflate
|
#inflate
|
||||||
|
|
||||||
#options = {}
|
#options = {}
|
||||||
|
|
||||||
|
/** @type {boolean} */
|
||||||
|
#aborted = false
|
||||||
|
|
||||||
|
/** @type {Function|null} */
|
||||||
|
#currentCallback = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Map<string, string>} extensions
|
||||||
|
*/
|
||||||
constructor (extensions) {
|
constructor (extensions) {
|
||||||
this.#options.serverNoContextTakeover = extensions.has('server_no_context_takeover')
|
this.#options.serverNoContextTakeover = extensions.has('server_no_context_takeover')
|
||||||
this.#options.serverMaxWindowBits = extensions.get('server_max_window_bits')
|
this.#options.serverMaxWindowBits = extensions.get('server_max_window_bits')
|
||||||
@@ -26069,6 +26111,11 @@ class PerMessageDeflate {
|
|||||||
// payload of the message.
|
// payload of the message.
|
||||||
// 2. Decompress the resulting data using DEFLATE.
|
// 2. Decompress the resulting data using DEFLATE.
|
||||||
|
|
||||||
|
if (this.#aborted) {
|
||||||
|
callback(new MessageSizeExceededError())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.#inflate) {
|
if (!this.#inflate) {
|
||||||
let windowBits = Z_DEFAULT_WINDOWBITS
|
let windowBits = Z_DEFAULT_WINDOWBITS
|
||||||
|
|
||||||
@@ -26081,13 +26128,37 @@ class PerMessageDeflate {
|
|||||||
windowBits = Number.parseInt(this.#options.serverMaxWindowBits)
|
windowBits = Number.parseInt(this.#options.serverMaxWindowBits)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#inflate = createInflateRaw({ windowBits })
|
try {
|
||||||
|
this.#inflate = createInflateRaw({ windowBits })
|
||||||
|
} catch (err) {
|
||||||
|
callback(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
this.#inflate[kBuffer] = []
|
this.#inflate[kBuffer] = []
|
||||||
this.#inflate[kLength] = 0
|
this.#inflate[kLength] = 0
|
||||||
|
|
||||||
this.#inflate.on('data', (data) => {
|
this.#inflate.on('data', (data) => {
|
||||||
this.#inflate[kBuffer].push(data)
|
if (this.#aborted) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
this.#inflate[kLength] += data.length
|
this.#inflate[kLength] += data.length
|
||||||
|
|
||||||
|
if (this.#inflate[kLength] > kDefaultMaxDecompressedSize) {
|
||||||
|
this.#aborted = true
|
||||||
|
this.#inflate.removeAllListeners()
|
||||||
|
this.#inflate.destroy()
|
||||||
|
this.#inflate = null
|
||||||
|
|
||||||
|
if (this.#currentCallback) {
|
||||||
|
const cb = this.#currentCallback
|
||||||
|
this.#currentCallback = null
|
||||||
|
cb(new MessageSizeExceededError())
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.#inflate[kBuffer].push(data)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.#inflate.on('error', (err) => {
|
this.#inflate.on('error', (err) => {
|
||||||
@@ -26096,16 +26167,22 @@ class PerMessageDeflate {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.#currentCallback = callback
|
||||||
this.#inflate.write(chunk)
|
this.#inflate.write(chunk)
|
||||||
if (fin) {
|
if (fin) {
|
||||||
this.#inflate.write(tail)
|
this.#inflate.write(tail)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#inflate.flush(() => {
|
this.#inflate.flush(() => {
|
||||||
|
if (this.#aborted || !this.#inflate) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const full = Buffer.concat(this.#inflate[kBuffer], this.#inflate[kLength])
|
const full = Buffer.concat(this.#inflate[kBuffer], this.#inflate[kLength])
|
||||||
|
|
||||||
this.#inflate[kBuffer].length = 0
|
this.#inflate[kBuffer].length = 0
|
||||||
this.#inflate[kLength] = 0
|
this.#inflate[kLength] = 0
|
||||||
|
this.#currentCallback = null
|
||||||
|
|
||||||
callback(null, full)
|
callback(null, full)
|
||||||
})
|
})
|
||||||
@@ -26159,6 +26236,10 @@ class ByteParser extends Writable {
|
|||||||
/** @type {Map<string, PerMessageDeflate>} */
|
/** @type {Map<string, PerMessageDeflate>} */
|
||||||
#extensions
|
#extensions
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {import('./websocket').WebSocket} ws
|
||||||
|
* @param {Map<string, string>|null} extensions
|
||||||
|
*/
|
||||||
constructor (ws, extensions) {
|
constructor (ws, extensions) {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
@@ -26301,6 +26382,7 @@ class ByteParser extends Writable {
|
|||||||
|
|
||||||
const buffer = this.consume(8)
|
const buffer = this.consume(8)
|
||||||
const upper = buffer.readUInt32BE(0)
|
const upper = buffer.readUInt32BE(0)
|
||||||
|
const lower = buffer.readUInt32BE(4)
|
||||||
|
|
||||||
// 2^31 is the maximum bytes an arraybuffer can contain
|
// 2^31 is the maximum bytes an arraybuffer can contain
|
||||||
// on 32-bit systems. Although, on 64-bit systems, this is
|
// on 32-bit systems. Although, on 64-bit systems, this is
|
||||||
@@ -26308,14 +26390,12 @@ class ByteParser extends Writable {
|
|||||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_array_length
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_array_length
|
||||||
// https://source.chromium.org/chromium/chromium/src/+/main:v8/src/common/globals.h;drc=1946212ac0100668f14eb9e2843bdd846e510a1e;bpv=1;bpt=1;l=1275
|
// https://source.chromium.org/chromium/chromium/src/+/main:v8/src/common/globals.h;drc=1946212ac0100668f14eb9e2843bdd846e510a1e;bpv=1;bpt=1;l=1275
|
||||||
// https://source.chromium.org/chromium/chromium/src/+/main:v8/src/objects/js-array-buffer.h;l=34;drc=1946212ac0100668f14eb9e2843bdd846e510a1e
|
// https://source.chromium.org/chromium/chromium/src/+/main:v8/src/objects/js-array-buffer.h;l=34;drc=1946212ac0100668f14eb9e2843bdd846e510a1e
|
||||||
if (upper > 2 ** 31 - 1) {
|
if (upper !== 0 || lower > 2 ** 31 - 1) {
|
||||||
failWebsocketConnection(this.ws, 'Received payload length > 2^31 bytes.')
|
failWebsocketConnection(this.ws, 'Received payload length > 2^31 bytes.')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const lower = buffer.readUInt32BE(4)
|
this.#info.payloadLength = lower
|
||||||
|
|
||||||
this.#info.payloadLength = (upper << 8) + lower
|
|
||||||
this.#state = parserStates.READ_DATA
|
this.#state = parserStates.READ_DATA
|
||||||
} else if (this.#state === parserStates.READ_DATA) {
|
} else if (this.#state === parserStates.READ_DATA) {
|
||||||
if (this.#byteOffset < this.#info.payloadLength) {
|
if (this.#byteOffset < this.#info.payloadLength) {
|
||||||
@@ -26345,7 +26425,7 @@ class ByteParser extends Writable {
|
|||||||
} else {
|
} else {
|
||||||
this.#extensions.get('permessage-deflate').decompress(body, this.#info.fin, (error, data) => {
|
this.#extensions.get('permessage-deflate').decompress(body, this.#info.fin, (error, data) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
closeWebSocketConnection(this.ws, 1007, error.message, error.message.length)
|
failWebsocketConnection(this.ws, error.message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26949,6 +27029,12 @@ function parseExtensions (extensions) {
|
|||||||
* @param {string} value
|
* @param {string} value
|
||||||
*/
|
*/
|
||||||
function isValidClientWindowBits (value) {
|
function isValidClientWindowBits (value) {
|
||||||
|
// Must have at least one character
|
||||||
|
if (value.length === 0) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check all characters are ASCII digits
|
||||||
for (let i = 0; i < value.length; i++) {
|
for (let i = 0; i < value.length; i++) {
|
||||||
const byte = value.charCodeAt(i)
|
const byte = value.charCodeAt(i)
|
||||||
|
|
||||||
@@ -26957,7 +27043,9 @@ function isValidClientWindowBits (value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
// Check numeric range: zlib requires windowBits in range 8-15
|
||||||
|
const num = Number.parseInt(value, 10)
|
||||||
|
return num >= 8 && num <= 15
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://nodejs.org/api/intl.html#detecting-internationalization-support
|
// https://nodejs.org/api/intl.html#detecting-internationalization-support
|
||||||
@@ -27435,7 +27523,7 @@ class WebSocket extends EventTarget {
|
|||||||
* @see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
* @see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
||||||
*/
|
*/
|
||||||
#onConnectionEstablished (response, parsedExtensions) {
|
#onConnectionEstablished (response, parsedExtensions) {
|
||||||
// processResponse is called when the "response’s header list has been received and initialized."
|
// processResponse is called when the "response's header list has been received and initialized."
|
||||||
// once this happens, the connection is open
|
// once this happens, the connection is open
|
||||||
this[kResponse] = response
|
this[kResponse] = response
|
||||||
|
|
||||||
|
|||||||
Generated
+8
-7
@@ -3471,10 +3471,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/flatted": {
|
"node_modules/flatted": {
|
||||||
"version": "3.2.9",
|
"version": "3.4.2",
|
||||||
"resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.9.tgz",
|
"resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.2.tgz",
|
||||||
"integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==",
|
"integrity": "sha512-PjDse7RzhcPkIJwy5t7KPWQSZ9cAbzQXcafsetQoD7sOJRQlGikNbx7yZp2OotDnJyrDcbyRq3Ttb18iYOqkxA==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
"node_modules/for-each": {
|
"node_modules/for-each": {
|
||||||
"version": "0.3.3",
|
"version": "0.3.3",
|
||||||
@@ -6737,9 +6738,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/undici": {
|
"node_modules/undici": {
|
||||||
"version": "6.23.0",
|
"version": "6.24.1",
|
||||||
"resolved": "https://registry.npmjs.org/undici/-/undici-6.23.0.tgz",
|
"resolved": "https://registry.npmjs.org/undici/-/undici-6.24.1.tgz",
|
||||||
"integrity": "sha512-VfQPToRA5FZs/qJxLIinmU59u0r7LXqoJkCzinq3ckNJp3vKEh7jTWN589YQ5+aoAC/TGRLyJLCPKcLQbM8r9g==",
|
"integrity": "sha512-sC+b0tB1whOCzbtlx20fx3WgCXwkW627p4EA9uM+/tNNPkSS+eSEld6pAs9nDv7WbY1UUljBMYPtu9BCOrCWKA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.17"
|
"node": ">=18.17"
|
||||||
|
|||||||
Reference in new issue
Block a user