@zuplo/cli 6.71.0 → 6.71.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/node_modules/@fastify/reply-from/node_modules/undici/docs/docs/api/Client.md +3 -0
  2. package/node_modules/@fastify/reply-from/node_modules/undici/docs/docs/api/Cookies.md +27 -0
  3. package/node_modules/@fastify/reply-from/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +1 -0
  4. package/node_modules/@fastify/reply-from/node_modules/undici/lib/core/socks5-client.js +14 -4
  5. package/node_modules/@fastify/reply-from/node_modules/undici/lib/core/socks5-utils.js +18 -4
  6. package/node_modules/@fastify/reply-from/node_modules/undici/lib/dispatcher/agent.js +1 -1
  7. package/node_modules/@fastify/reply-from/node_modules/undici/lib/dispatcher/balanced-pool.js +1 -1
  8. package/node_modules/@fastify/reply-from/node_modules/undici/lib/dispatcher/client-h1.js +69 -1
  9. package/node_modules/@fastify/reply-from/node_modules/undici/lib/dispatcher/client.js +3 -2
  10. package/node_modules/@fastify/reply-from/node_modules/undici/lib/dispatcher/dispatcher-base.js +19 -0
  11. package/node_modules/@fastify/reply-from/node_modules/undici/lib/dispatcher/pool.js +1 -1
  12. package/node_modules/@fastify/reply-from/node_modules/undici/lib/dispatcher/proxy-agent.js +2 -1
  13. package/node_modules/@fastify/reply-from/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +45 -34
  14. package/node_modules/@fastify/reply-from/node_modules/undici/lib/util/cache.js +8 -2
  15. package/node_modules/@fastify/reply-from/node_modules/undici/lib/web/cookies/parse.js +17 -25
  16. package/node_modules/@fastify/reply-from/node_modules/undici/lib/web/websocket/permessage-deflate.js +13 -31
  17. package/node_modules/@fastify/reply-from/node_modules/undici/lib/web/websocket/receiver.js +80 -23
  18. package/node_modules/@fastify/reply-from/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -1
  19. package/node_modules/@fastify/reply-from/node_modules/undici/lib/web/websocket/websocket.js +8 -1
  20. package/node_modules/@fastify/reply-from/node_modules/undici/package.json +1 -1
  21. package/node_modules/@fastify/reply-from/node_modules/undici/types/client.d.ts +16 -0
  22. package/node_modules/@zuplo/core/package.json +1 -1
  23. package/node_modules/@zuplo/graphql/package.json +1 -1
  24. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  25. package/node_modules/@zuplo/otel/package.json +1 -1
  26. package/node_modules/@zuplo/runtime/package.json +1 -1
  27. package/node_modules/body-parser/README.md +16 -1
  28. package/node_modules/body-parser/index.js +4 -20
  29. package/node_modules/body-parser/lib/read.js +17 -17
  30. package/node_modules/body-parser/lib/types/json.js +60 -32
  31. package/node_modules/body-parser/lib/types/raw.js +3 -3
  32. package/node_modules/body-parser/lib/types/text.js +3 -3
  33. package/node_modules/body-parser/lib/types/urlencoded.js +16 -20
  34. package/node_modules/body-parser/lib/utils.js +18 -16
  35. package/node_modules/body-parser/node_modules/content-type/LICENSE +22 -0
  36. package/node_modules/body-parser/node_modules/content-type/README.md +69 -0
  37. package/node_modules/body-parser/node_modules/content-type/dist/index.d.ts +26 -0
  38. package/node_modules/body-parser/node_modules/content-type/dist/index.js +170 -0
  39. package/node_modules/body-parser/node_modules/content-type/dist/index.js.map +1 -0
  40. package/node_modules/body-parser/node_modules/content-type/package.json +52 -0
  41. package/node_modules/body-parser/node_modules/http-errors/HISTORY.md +186 -0
  42. package/node_modules/body-parser/node_modules/http-errors/LICENSE +23 -0
  43. package/node_modules/body-parser/node_modules/http-errors/README.md +169 -0
  44. package/node_modules/body-parser/node_modules/http-errors/index.js +290 -0
  45. package/node_modules/body-parser/node_modules/http-errors/package.json +54 -0
  46. package/node_modules/body-parser/package.json +23 -10
  47. package/package.json +6 -6
@@ -8,40 +8,35 @@ const tail = Buffer.from([0x00, 0x00, 0xff, 0xff])
8
8
  const kBuffer = Symbol('kBuffer')
9
9
  const kLength = Symbol('kLength')
10
10
 
11
- // Default maximum decompressed message size: 4 MB
12
- const kDefaultMaxDecompressedSize = 4 * 1024 * 1024
13
-
14
11
  class PerMessageDeflate {
15
12
  /** @type {import('node:zlib').InflateRaw} */
16
13
  #inflate
17
14
 
18
15
  #options = {}
19
16
 
20
- /** @type {boolean} */
21
- #aborted = false
22
-
23
- /** @type {Function|null} */
24
- #currentCallback = null
17
+ #maxPayloadSize = 0
25
18
 
26
19
  /**
27
20
  * @param {Map<string, string>} extensions
28
21
  */
29
- constructor (extensions) {
22
+ constructor (extensions, options) {
30
23
  this.#options.serverNoContextTakeover = extensions.has('server_no_context_takeover')
31
24
  this.#options.serverMaxWindowBits = extensions.get('server_max_window_bits')
25
+
26
+ this.#maxPayloadSize = options.maxPayloadSize
32
27
  }
33
28
 
29
+ /**
30
+ * Decompress a compressed payload.
31
+ * @param {Buffer} chunk Compressed data
32
+ * @param {boolean} fin Final fragment flag
33
+ * @param {Function} callback Callback function
34
+ */
34
35
  decompress (chunk, fin, callback) {
35
36
  // An endpoint uses the following algorithm to decompress a message.
36
37
  // 1. Append 4 octets of 0x00 0x00 0xff 0xff to the tail end of the
37
38
  // payload of the message.
38
39
  // 2. Decompress the resulting data using DEFLATE.
39
-
40
- if (this.#aborted) {
41
- callback(new MessageSizeExceededError())
42
- return
43
- }
44
-
45
40
  if (!this.#inflate) {
46
41
  let windowBits = Z_DEFAULT_WINDOWBITS
47
42
 
@@ -64,23 +59,12 @@ class PerMessageDeflate {
64
59
  this.#inflate[kLength] = 0
65
60
 
66
61
  this.#inflate.on('data', (data) => {
67
- if (this.#aborted) {
68
- return
69
- }
70
-
71
62
  this.#inflate[kLength] += data.length
72
63
 
73
- if (this.#inflate[kLength] > kDefaultMaxDecompressedSize) {
74
- this.#aborted = true
64
+ if (this.#maxPayloadSize > 0 && this.#inflate[kLength] > this.#maxPayloadSize) {
65
+ callback(new MessageSizeExceededError())
75
66
  this.#inflate.removeAllListeners()
76
- this.#inflate.destroy()
77
67
  this.#inflate = null
78
-
79
- if (this.#currentCallback) {
80
- const cb = this.#currentCallback
81
- this.#currentCallback = null
82
- cb(new MessageSizeExceededError())
83
- }
84
68
  return
85
69
  }
86
70
 
@@ -93,14 +77,13 @@ class PerMessageDeflate {
93
77
  })
94
78
  }
95
79
 
96
- this.#currentCallback = callback
97
80
  this.#inflate.write(chunk)
98
81
  if (fin) {
99
82
  this.#inflate.write(tail)
100
83
  }
101
84
 
102
85
  this.#inflate.flush(() => {
103
- if (this.#aborted || !this.#inflate) {
86
+ if (!this.#inflate) {
104
87
  return
105
88
  }
106
89
 
@@ -108,7 +91,6 @@ class PerMessageDeflate {
108
91
 
109
92
  this.#inflate[kBuffer].length = 0
110
93
  this.#inflate[kLength] = 0
111
- this.#currentCallback = null
112
94
 
113
95
  callback(null, full)
114
96
  })
@@ -39,18 +39,27 @@ class ByteParser extends Writable {
39
39
  /** @type {import('./websocket').Handler} */
40
40
  #handler
41
41
 
42
+ /** @type {number} */
43
+ #maxFragments
44
+
45
+ /** @type {number} */
46
+ #maxPayloadSize
47
+
42
48
  /**
43
49
  * @param {import('./websocket').Handler} handler
44
50
  * @param {Map<string, string>|null} extensions
51
+ * @param {{ maxFragments?: number, maxPayloadSize?: number }} [options]
45
52
  */
46
- constructor (handler, extensions) {
53
+ constructor (handler, extensions, options = {}) {
47
54
  super()
48
55
 
49
56
  this.#handler = handler
50
57
  this.#extensions = extensions == null ? new Map() : extensions
58
+ this.#maxFragments = options.maxFragments ?? 0
59
+ this.#maxPayloadSize = options.maxPayloadSize ?? 0
51
60
 
52
61
  if (this.#extensions.has('permessage-deflate')) {
53
- this.#extensions.set('permessage-deflate', new PerMessageDeflate(extensions))
62
+ this.#extensions.set('permessage-deflate', new PerMessageDeflate(extensions, options))
54
63
  }
55
64
  }
56
65
 
@@ -66,6 +75,19 @@ class ByteParser extends Writable {
66
75
  this.run(callback)
67
76
  }
68
77
 
78
+ #validatePayloadLength () {
79
+ if (
80
+ this.#maxPayloadSize > 0 &&
81
+ !isControlFrame(this.#info.opcode) &&
82
+ this.#info.payloadLength + this.#fragmentsBytes > this.#maxPayloadSize
83
+ ) {
84
+ failWebsocketConnection(this.#handler, 1009, 'Payload size exceeds maximum allowed size')
85
+ return false
86
+ }
87
+
88
+ return true
89
+ }
90
+
69
91
  /**
70
92
  * Runs whenever a new chunk is received.
71
93
  * Callback is called whenever there are no more chunks buffering,
@@ -154,6 +176,10 @@ class ByteParser extends Writable {
154
176
  if (payloadLength <= 125) {
155
177
  this.#info.payloadLength = payloadLength
156
178
  this.#state = parserStates.READ_DATA
179
+
180
+ if (!this.#validatePayloadLength()) {
181
+ return
182
+ }
157
183
  } else if (payloadLength === 126) {
158
184
  this.#state = parserStates.PAYLOADLENGTH_16
159
185
  } else if (payloadLength === 127) {
@@ -178,6 +204,10 @@ class ByteParser extends Writable {
178
204
 
179
205
  this.#info.payloadLength = buffer.readUInt16BE(0)
180
206
  this.#state = parserStates.READ_DATA
207
+
208
+ if (!this.#validatePayloadLength()) {
209
+ return
210
+ }
181
211
  } else if (this.#state === parserStates.PAYLOADLENGTH_64) {
182
212
  if (this.#byteOffset < 8) {
183
213
  return callback()
@@ -200,6 +230,10 @@ class ByteParser extends Writable {
200
230
 
201
231
  this.#info.payloadLength = lower
202
232
  this.#state = parserStates.READ_DATA
233
+
234
+ if (!this.#validatePayloadLength()) {
235
+ return
236
+ }
203
237
  } else if (this.#state === parserStates.READ_DATA) {
204
238
  if (this.#byteOffset < this.#info.payloadLength) {
205
239
  return callback()
@@ -212,7 +246,9 @@ class ByteParser extends Writable {
212
246
  this.#state = parserStates.INFO
213
247
  } else {
214
248
  if (!this.#info.compressed) {
215
- this.writeFragments(body)
249
+ if (!this.writeFragments(body)) {
250
+ return
251
+ }
216
252
 
217
253
  // If the frame is not fragmented, a message has been received.
218
254
  // If the frame is fragmented, it will terminate with a fin bit set
@@ -224,29 +260,41 @@ class ByteParser extends Writable {
224
260
 
225
261
  this.#state = parserStates.INFO
226
262
  } else {
227
- this.#extensions.get('permessage-deflate').decompress(body, this.#info.fin, (error, data) => {
228
- if (error) {
229
- // Use 1009 (Message Too Big) for decompression size limit errors
230
- const code = error instanceof MessageSizeExceededError ? 1009 : 1007
231
- failWebsocketConnection(this.#handler, code, error.message)
232
- return
233
- }
234
-
235
- this.writeFragments(data)
263
+ this.#extensions.get('permessage-deflate').decompress(
264
+ body,
265
+ this.#info.fin,
266
+ (error, data) => {
267
+ if (error) {
268
+ const code = error instanceof MessageSizeExceededError ? 1009 : 1007
269
+ failWebsocketConnection(this.#handler, code, error.message)
270
+ return
271
+ }
272
+
273
+ if (!this.writeFragments(data)) {
274
+ return
275
+ }
276
+
277
+ // Check cumulative fragment size
278
+ if (this.#maxPayloadSize > 0 && this.#fragmentsBytes > this.#maxPayloadSize) {
279
+ failWebsocketConnection(this.#handler, 1009, new MessageSizeExceededError().message)
280
+ return
281
+ }
282
+
283
+ if (!this.#info.fin) {
284
+ this.#state = parserStates.INFO
285
+ this.#loop = true
286
+ this.run(callback)
287
+ return
288
+ }
289
+
290
+ websocketMessageReceived(this.#handler, this.#info.binaryType, this.consumeFragments())
236
291
 
237
- if (!this.#info.fin) {
238
- this.#state = parserStates.INFO
239
292
  this.#loop = true
293
+ this.#state = parserStates.INFO
240
294
  this.run(callback)
241
- return
242
- }
243
-
244
- websocketMessageReceived(this.#handler, this.#info.binaryType, this.consumeFragments())
245
-
246
- this.#loop = true
247
- this.#state = parserStates.INFO
248
- this.run(callback)
249
- })
295
+ },
296
+ this.#fragmentsBytes
297
+ )
250
298
 
251
299
  this.#loop = false
252
300
  break
@@ -305,8 +353,17 @@ class ByteParser extends Writable {
305
353
  }
306
354
 
307
355
  writeFragments (fragment) {
356
+ if (
357
+ this.#maxFragments > 0 &&
358
+ this.#fragments.length === this.#maxFragments
359
+ ) {
360
+ failWebsocketConnection(this.#handler, 1008, 'Too many message fragments')
361
+ return false
362
+ }
363
+
308
364
  this.#fragmentsBytes += fragment.length
309
365
  this.#fragments.push(fragment)
366
+ return true
310
367
  }
311
368
 
312
369
  consumeFragments () {
@@ -258,7 +258,14 @@ class WebSocketStream {
258
258
  #onConnectionEstablished (response, parsedExtensions) {
259
259
  this.#handler.socket = response.socket
260
260
 
261
- const parser = new ByteParser(this.#handler, parsedExtensions)
261
+ // Get options from dispatcher options
262
+ const maxFragments = this.#handler.controller.dispatcher?.webSocketOptions?.maxFragments
263
+ const maxPayloadSize = this.#handler.controller.dispatcher?.webSocketOptions?.maxPayloadSize
264
+
265
+ const parser = new ByteParser(this.#handler, parsedExtensions, {
266
+ maxFragments,
267
+ maxPayloadSize
268
+ })
262
269
  parser.on('drain', () => this.#handler.onParserDrain())
263
270
  parser.on('error', (err) => this.#handler.onParserError(err))
264
271
 
@@ -468,7 +468,14 @@ class WebSocket extends EventTarget {
468
468
  // once this happens, the connection is open
469
469
  this.#handler.socket = response.socket
470
470
 
471
- const parser = new ByteParser(this.#handler, parsedExtensions)
471
+ const webSocketOptions = this.#handler.controller.dispatcher?.webSocketOptions
472
+ const maxFragments = webSocketOptions?.maxFragments
473
+ const maxPayloadSize = webSocketOptions?.maxPayloadSize
474
+
475
+ const parser = new ByteParser(this.#handler, parsedExtensions, {
476
+ maxFragments,
477
+ maxPayloadSize
478
+ })
472
479
  parser.on('drain', () => this.#handler.onParserDrain())
473
480
  parser.on('error', (err) => this.#handler.onParserError(err))
474
481
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "undici",
3
- "version": "7.27.2",
3
+ "version": "7.28.0",
4
4
  "description": "An HTTP/1.1 client, written from scratch for Node.js",
5
5
  "homepage": "https://undici.nodejs.org",
6
6
  "bugs": {
@@ -107,6 +107,8 @@ export declare namespace Client {
107
107
  * @default 60000
108
108
  */
109
109
  pingInterval?: number;
110
+ /** WebSocket-specific configuration options. */
111
+ webSocket?: WebSocketOptions;
110
112
  }
111
113
  export interface SocketInfo {
112
114
  localAddress?: string
@@ -118,6 +120,20 @@ export declare namespace Client {
118
120
  bytesWritten?: number
119
121
  bytesRead?: number
120
122
  }
123
+ export interface WebSocketOptions {
124
+ /**
125
+ * Maximum number of fragments in a message. Set to 0 to disable the limit.
126
+ * @default 131072
127
+ */
128
+ maxFragments?: number;
129
+ /**
130
+ * Maximum allowed payload size in bytes for WebSocket messages.
131
+ * Applied to uncompressed messages, compressed frame payloads, and decompressed (permessage-deflate) messages.
132
+ * Set to 0 to disable the limit.
133
+ * @default 134217728 (128 MB)
134
+ */
135
+ maxPayloadSize?: number;
136
+ }
121
137
  }
122
138
 
123
139
  export default Client
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/core",
3
- "version": "6.71.0",
3
+ "version": "6.71.2",
4
4
  "repository": "https://github.com/zuplo/zuplo",
5
5
  "author": "Zuplo, Inc.",
6
6
  "type": "module",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zuplo/graphql",
3
3
  "type": "module",
4
- "version": "6.71.0",
4
+ "version": "6.71.2",
5
5
  "repository": "https://github.com/zuplo/zuplo",
6
6
  "author": "Zuplo, Inc.",
7
7
  "exports": {
@@ -2,7 +2,7 @@
2
2
  "name": "@zuplo/openapi-tools",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "6.71.0",
5
+ "version": "6.71.2",
6
6
  "description": "Tooling for OpenAPI files",
7
7
  "repository": {
8
8
  "type": "git",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zuplo/otel",
3
3
  "type": "module",
4
- "version": "6.71.0",
4
+ "version": "6.71.2",
5
5
  "repository": "https://github.com/zuplo/zuplo",
6
6
  "author": "Zuplo, Inc.",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zuplo/runtime",
3
3
  "type": "module",
4
- "version": "6.71.0",
4
+ "version": "6.71.2",
5
5
  "repository": "https://github.com/zuplo/zuplo",
6
6
  "author": "Zuplo, Inc.",
7
7
  "exports": {
@@ -51,7 +51,14 @@ $ npm install body-parser
51
51
  ## API
52
52
 
53
53
  ```js
54
+ // Import all parsers
54
55
  const bodyParser = require('body-parser')
56
+
57
+ // Or import individual parsers directly
58
+ const json = require('body-parser/json')
59
+ const urlencoded = require('body-parser/urlencoded')
60
+ const raw = require('body-parser/raw')
61
+ const text = require('body-parser/text')
55
62
  ```
56
63
 
57
64
  The `bodyParser` object exposes various factories to create middlewares. All
@@ -93,11 +100,13 @@ specifies the number of bytes; if it is a string, the value is passed to the
93
100
  [bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults
94
101
  to `'100kb'`.
95
102
 
103
+ > It’s recommended not to configure a very high limit and to use the default value whenever possible. Allowing larger payloads increases memory usage because of the resources required for decoding and transformations, and it can also lead to longer response times as more data is processed. By ‘very high’, we mean values above the default, for example payloads of 5 MB or more can already start to introduce these risks. With the default limits, these issues do not occur.
104
+
96
105
  ##### reviver
97
106
 
98
107
  The `reviver` option is passed directly to `JSON.parse` as the second
99
108
  argument. You can find more information on this argument
100
- [in the MDN documentation about JSON.parse](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter).
109
+ [in the MDN documentation about JSON.parse](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#the_reviver_parameter).
101
110
 
102
111
  ##### strict
103
112
 
@@ -149,6 +158,8 @@ specifies the number of bytes; if it is a string, the value is passed to the
149
158
  [bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults
150
159
  to `'100kb'`.
151
160
 
161
+ > It’s recommended not to configure a very high limit and to use the default value whenever possible. Allowing larger payloads increases memory usage because of the resources required for decoding and transformations, and it can also lead to longer response times as more data is processed. By ‘very high’, we mean values above the default, for example payloads of 5 MB or more can already start to introduce these risks. With the default limits, these issues do not occur.
162
+
152
163
  ##### type
153
164
 
154
165
  The `type` option is used to determine what media type the middleware will
@@ -200,6 +211,8 @@ specifies the number of bytes; if it is a string, the value is passed to the
200
211
  [bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults
201
212
  to `'100kb'`.
202
213
 
214
+ > It’s recommended not to configure a very high limit and to use the default value whenever possible. Allowing larger payloads increases memory usage because of the resources required for decoding and transformations, and it can also lead to longer response times as more data is processed. By ‘very high’, we mean values above the default, for example payloads of 5 MB or more can already start to introduce these risks. With the default limits, these issues do not occur.
215
+
203
216
  ##### type
204
217
 
205
218
  The `type` option is used to determine what media type the middleware will
@@ -255,6 +268,8 @@ specifies the number of bytes; if it is a string, the value is passed to the
255
268
  [bytes](https://www.npmjs.com/package/bytes) library for parsing. Defaults
256
269
  to `'100kb'`.
257
270
 
271
+ > It’s recommended not to configure a very high limit and to use the default value whenever possible. Allowing larger payloads increases memory usage because of the resources required for decoding and transformations, and it can also lead to longer response times as more data is processed. By ‘very high’, we mean values above the default, for example payloads of 5 MB or more can already start to introduce these risks. With the default limits, these issues do not occur.
272
+
258
273
  ##### parameterLimit
259
274
 
260
275
  The `parameterLimit` option controls the maximum number of parameters that
@@ -24,41 +24,25 @@ exports = module.exports = bodyParser
24
24
  * JSON parser.
25
25
  * @public
26
26
  */
27
- Object.defineProperty(exports, 'json', {
28
- configurable: true,
29
- enumerable: true,
30
- get: () => require('./lib/types/json')
31
- })
27
+ exports.json = require('./lib/types/json')
32
28
 
33
29
  /**
34
30
  * Raw parser.
35
31
  * @public
36
32
  */
37
- Object.defineProperty(exports, 'raw', {
38
- configurable: true,
39
- enumerable: true,
40
- get: () => require('./lib/types/raw')
41
- })
33
+ exports.raw = require('./lib/types/raw')
42
34
 
43
35
  /**
44
36
  * Text parser.
45
37
  * @public
46
38
  */
47
- Object.defineProperty(exports, 'text', {
48
- configurable: true,
49
- enumerable: true,
50
- get: () => require('./lib/types/text')
51
- })
39
+ exports.text = require('./lib/types/text')
52
40
 
53
41
  /**
54
42
  * URL-encoded parser.
55
43
  * @public
56
44
  */
57
- Object.defineProperty(exports, 'urlencoded', {
58
- configurable: true,
59
- enumerable: true,
60
- get: () => require('./lib/types/urlencoded')
61
- })
45
+ exports.urlencoded = require('./lib/types/urlencoded')
62
46
 
63
47
  /**
64
48
  * Create a middleware to parse json and urlencoded bodies.
@@ -11,13 +11,13 @@
11
11
  * @private
12
12
  */
13
13
 
14
- var createError = require('http-errors')
15
- var getBody = require('raw-body')
16
- var iconv = require('iconv-lite')
17
- var onFinished = require('on-finished')
18
- var zlib = require('node:zlib')
19
- var hasBody = require('type-is').hasBody
20
- var { getCharset } = require('./utils')
14
+ const createError = require('http-errors')
15
+ const getBody = require('raw-body')
16
+ const iconv = require('iconv-lite')
17
+ const onFinished = require('on-finished')
18
+ const zlib = require('node:zlib')
19
+ const hasBody = require('type-is').hasBody
20
+ const { getCharset } = require('./utils')
21
21
 
22
22
  /**
23
23
  * Module exports.
@@ -63,7 +63,7 @@ function read (req, res, next, parse, debug, options) {
63
63
  return
64
64
  }
65
65
 
66
- var encoding = null
66
+ let encoding = null
67
67
  if (options?.skipCharset !== true) {
68
68
  encoding = getCharset(req) || options.defaultCharset
69
69
 
@@ -78,12 +78,12 @@ function read (req, res, next, parse, debug, options) {
78
78
  }
79
79
  }
80
80
 
81
- var length
82
- var opts = options
83
- var stream
81
+ let length
82
+ const opts = options
83
+ let stream
84
84
 
85
85
  // read options
86
- var verify = opts.verify
86
+ const verify = opts.verify
87
87
 
88
88
  try {
89
89
  // get the content stream
@@ -112,7 +112,7 @@ function read (req, res, next, parse, debug, options) {
112
112
  debug('read body')
113
113
  getBody(stream, opts, function (error, body) {
114
114
  if (error) {
115
- var _error
115
+ let _error
116
116
 
117
117
  if (error.type === 'encoding.unsupported') {
118
118
  // echo back charset
@@ -153,7 +153,7 @@ function read (req, res, next, parse, debug, options) {
153
153
  }
154
154
 
155
155
  // parse
156
- var str = body
156
+ let str = body
157
157
  try {
158
158
  debug('parse body')
159
159
  str = typeof body !== 'string' && encoding !== null
@@ -182,8 +182,8 @@ function read (req, res, next, parse, debug, options) {
182
182
  * @private
183
183
  */
184
184
  function contentstream (req, debug, inflate) {
185
- var encoding = (req.headers['content-encoding'] || 'identity').toLowerCase()
186
- var length = req.headers['content-length']
185
+ const encoding = (req.headers['content-encoding'] || 'identity').toLowerCase()
186
+ const length = req.headers['content-length']
187
187
 
188
188
  debug('content-encoding "%s"', encoding)
189
189
 
@@ -199,7 +199,7 @@ function contentstream (req, debug, inflate) {
199
199
  return req
200
200
  }
201
201
 
202
- var stream = createDecompressionStream(encoding, debug)
202
+ const stream = createDecompressionStream(encoding, debug)
203
203
  req.pipe(stream)
204
204
  return stream
205
205
  }