Skip to content

Commit 887e19d

Browse files
committed
Replace crypto with nanoid for default boundary generator.
1 parent 322c6be commit 887e19d

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

lib/util/createBoundary.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import {randomBytes} from "crypto"
1+
import {customAlphabet} from "nanoid"
2+
3+
const alphabet = "0123456789abcdefghijklmnopqrstuvwxyz"
4+
const generate = customAlphabet(alphabet, 16)
25

36
/**
47
* Generates a boundary string for FormData encoder.
58
*/
6-
const createBoundary = (): string => (
7-
`form-data-boundary-${randomBytes(16).toString("hex")}`
8-
)
9+
const createBoundary = (): string => `form-data-boundary-${generate()}`
910

1011
export default createBoundary

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,8 @@
6060
"ttypescript": "1.5.12",
6161
"typescript": "4.2.4",
6262
"web-streams-polyfill": "3.0.3"
63+
},
64+
"dependencies": {
65+
"nanoid": "^3.1.23"
6366
}
6467
}

pnpm-lock.yaml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)