Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

form-data-encoder

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

form-data-encoder - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

6

lib/cjs/util/createBoundary.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const crypto_1 = require("crypto");
const nanoid_1 = require("nanoid");
const alphabet = "0123456789abcdefghijklmnopqrstuvwxyz";
const generate = nanoid_1.customAlphabet(alphabet, 16);
/**
* Generates a boundary string for FormData encoder.
*/
const createBoundary = () => (`FormDataBoundary${crypto_1.randomBytes(16).toString("hex")}`);
const createBoundary = () => `form-data-boundary-${generate()}`;
exports.default = createBoundary;

@@ -1,6 +0,8 @@

import { randomBytes } from "crypto";
import { customAlphabet } from "nanoid";
const alphabet = "0123456789abcdefghijklmnopqrstuvwxyz";
const generate = customAlphabet(alphabet, 16);
/**
* Generates a boundary string for FormData encoder.
*/
const createBoundary = () => (`FormDataBoundary${randomBytes(16).toString("hex")}`);
const createBoundary = () => `form-data-boundary-${generate()}`;
export default createBoundary;
{
"name": "form-data-encoder",
"version": "0.4.0",
"version": "0.5.0",
"description": "Encode FormData content into the multipart/form-data format",
"repository": "octet-stream/form-data-encoder",
"sideEffects": false,
"keywords": [

@@ -62,3 +63,6 @@ "form-data",

"web-streams-polyfill": "3.0.3"
},
"dependencies": {
"nanoid": "3.1.23"
}
}

@@ -73,4 +73,2 @@ # form-data-encoder

```js
import {randomBytes} from "crypto"
import {FormData} from "formdata-polyfill/esm-min.js"

@@ -84,5 +82,3 @@ import {blobFrom} from "fetch-blob/from.js"

async function toBlob(form) {
// Note that Blob will lowercase the boundary string before assign it to Blob#type property. So you may need to bring your own boundary string, which must contain only lowercase alphabetic characters.
const boundary = randomBytes(16).toString("hex")
const encoder = new Encoder(form, boundary)
const encoder = new Encoder(form)
const chunks = []

@@ -89,0 +85,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc