mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2026-03-16 14:02:19 +07:00
node_modules: update (#276)
Co-authored-by: dawidd6 <9713907+dawidd6@users.noreply.github.com>
This commit is contained in:
52
node_modules/undici/lib/web/websocket/permessage-deflate.js
generated
vendored
52
node_modules/undici/lib/web/websocket/permessage-deflate.js
generated
vendored
@@ -2,17 +2,30 @@
|
||||
|
||||
const { createInflateRaw, Z_DEFAULT_WINDOWBITS } = require('node:zlib')
|
||||
const { isValidClientWindowBits } = require('./util')
|
||||
const { MessageSizeExceededError } = require('../../core/errors')
|
||||
|
||||
const tail = Buffer.from([0x00, 0x00, 0xff, 0xff])
|
||||
const kBuffer = Symbol('kBuffer')
|
||||
const kLength = Symbol('kLength')
|
||||
|
||||
// Default maximum decompressed message size: 4 MB
|
||||
const kDefaultMaxDecompressedSize = 4 * 1024 * 1024
|
||||
|
||||
class PerMessageDeflate {
|
||||
/** @type {import('node:zlib').InflateRaw} */
|
||||
#inflate
|
||||
|
||||
#options = {}
|
||||
|
||||
/** @type {boolean} */
|
||||
#aborted = false
|
||||
|
||||
/** @type {Function|null} */
|
||||
#currentCallback = null
|
||||
|
||||
/**
|
||||
* @param {Map<string, string>} extensions
|
||||
*/
|
||||
constructor (extensions) {
|
||||
this.#options.serverNoContextTakeover = extensions.has('server_no_context_takeover')
|
||||
this.#options.serverMaxWindowBits = extensions.get('server_max_window_bits')
|
||||
@@ -24,6 +37,11 @@ class PerMessageDeflate {
|
||||
// payload of the message.
|
||||
// 2. Decompress the resulting data using DEFLATE.
|
||||
|
||||
if (this.#aborted) {
|
||||
callback(new MessageSizeExceededError())
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.#inflate) {
|
||||
let windowBits = Z_DEFAULT_WINDOWBITS
|
||||
|
||||
@@ -36,13 +54,37 @@ class PerMessageDeflate {
|
||||
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[kLength] = 0
|
||||
|
||||
this.#inflate.on('data', (data) => {
|
||||
this.#inflate[kBuffer].push(data)
|
||||
if (this.#aborted) {
|
||||
return
|
||||
}
|
||||
|
||||
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) => {
|
||||
@@ -51,16 +93,22 @@ class PerMessageDeflate {
|
||||
})
|
||||
}
|
||||
|
||||
this.#currentCallback = callback
|
||||
this.#inflate.write(chunk)
|
||||
if (fin) {
|
||||
this.#inflate.write(tail)
|
||||
}
|
||||
|
||||
this.#inflate.flush(() => {
|
||||
if (this.#aborted || !this.#inflate) {
|
||||
return
|
||||
}
|
||||
|
||||
const full = Buffer.concat(this.#inflate[kBuffer], this.#inflate[kLength])
|
||||
|
||||
this.#inflate[kBuffer].length = 0
|
||||
this.#inflate[kLength] = 0
|
||||
this.#currentCallback = null
|
||||
|
||||
callback(null, full)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user