undici 5.28.4 → 5.28.5

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.
package/lib/fetch/body.js CHANGED
@@ -22,6 +22,14 @@ const { isUint8Array, isArrayBuffer } = require('util/types')
22
22
  const { File: UndiciFile } = require('./file')
23
23
  const { parseMIMEType, serializeAMimeType } = require('./dataURL')
24
24
 
25
+ let random
26
+ try {
27
+ const crypto = require('node:crypto')
28
+ random = (max) => crypto.randomInt(0, max)
29
+ } catch {
30
+ random = (max) => Math.floor(Math.random(max))
31
+ }
32
+
25
33
  let ReadableStream = globalThis.ReadableStream
26
34
 
27
35
  /** @type {globalThis['File']} */
@@ -107,7 +115,7 @@ function extractBody (object, keepalive = false) {
107
115
  // Set source to a copy of the bytes held by object.
108
116
  source = new Uint8Array(object.buffer.slice(object.byteOffset, object.byteOffset + object.byteLength))
109
117
  } else if (util.isFormDataLike(object)) {
110
- const boundary = `----formdata-undici-0${`${Math.floor(Math.random() * 1e11)}`.padStart(11, '0')}`
118
+ const boundary = `----formdata-undici-0${`${random(1e11)}`.padStart(11, '0')}`
111
119
  const prefix = `--${boundary}\r\nContent-Disposition: form-data`
112
120
 
113
121
  /*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "undici",
3
- "version": "5.28.4",
3
+ "version": "5.28.5",
4
4
  "description": "An HTTP/1.1 client, written from scratch for Node.js",
5
5
  "homepage": "https://undici.nodejs.org",
6
6
  "bugs": {