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

balena-request

Package Overview
Dependencies
Maintainers
1
Versions
177
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

balena-request - npm Package Compare versions

Comparing version 12.1.0-build-otaviojacobi-does-multipart-form-when-blob-is-present-d4c119a7e7f62c54d12b954846dedf44bd7245dd-1 to 13.0.0-build-drop-support-to-node14-16-c7bdf11c4ce4ea3b885a608d5ce76eeab758d32d-1

38

build/utils.js

@@ -25,4 +25,2 @@ "use strict";

const balena_auth_1 = require("balena-auth");
const NodeFormData = require("form-data");
const buffer_1 = require("buffer");
const IS_BROWSER = typeof window !== 'undefined' && window !== null;

@@ -320,9 +318,2 @@ /**

exports.getBody = getBody;
const isBlob = (value) => {
return ((typeof Blob !== 'undefined' && value instanceof Blob) ||
(typeof buffer_1.Blob !== 'undefined' && value instanceof buffer_1.Blob));
};
const hasBlob = (requestBody) => {
return Object.values(requestBody !== null && requestBody !== void 0 ? requestBody : {}).some(isBlob);
};
// This is the actual implementation that hides the internal `retriesRemaining` parameter

@@ -345,31 +336,2 @@ function requestAsync(fetch, options, retriesRemaining) {

}
if (hasBlob(options.body)) {
if (IS_BROWSER) {
const form = new FormData();
for (const [k, v] of Object.entries(options.body)) {
form.append(k, v);
}
opts.headers.delete('Content-Type');
opts.body = form;
}
else {
const form = new NodeFormData();
for (const [k, v] of Object.entries(options.body)) {
if (v instanceof buffer_1.Blob) {
form.append(k, Buffer.from(yield v.arrayBuffer()), {
filename: 'upload',
contentType: v.type,
});
}
else {
form.append(k, v);
}
}
for (const [k, v] of Object.entries(form.getHeaders())) {
opts.headers.set(k, v);
}
// @ts-expect-error
opts.body = form;
}
}
try {

@@ -376,0 +338,0 @@ const requestTime = Date.now();

4

CHANGELOG.md

@@ -7,5 +7,5 @@ # Change Log

## 12.1.0 - 2023-10-05
## 13.0.0 - 2023-10-11
* Add multi part request support when Blob is present [Otávio Jacobi]
* Drop support for node 14 & 16 [Otávio Jacobi]

@@ -12,0 +12,0 @@ ## 12.0.4 - 2023-08-23

@@ -27,4 +27,2 @@ /*

import type { BalenaRequestOptions, BalenaRequestResponse } from './request';
import * as NodeFormData from 'form-data';
import { Blob as BufferBlob } from 'buffer';

@@ -378,13 +376,2 @@ const IS_BROWSER = typeof window !== 'undefined' && window !== null;

const isBlob = (value: any) => {
return (
(typeof Blob !== 'undefined' && value instanceof Blob) ||
(typeof BufferBlob !== 'undefined' && value instanceof BufferBlob)
);
};
const hasBlob = (requestBody?: any) => {
return Object.values(requestBody ?? {}).some(isBlob);
};
// This is the actual implementation that hides the internal `retriesRemaining` parameter

@@ -413,32 +400,2 @@

if (hasBlob(options.body)) {
if (IS_BROWSER) {
const form = new FormData();
for (const [k, v] of Object.entries(options.body)) {
form.append(k, v as string | Blob);
}
opts.headers.delete('Content-Type');
opts.body = form;
} else {
const form = new NodeFormData();
for (const [k, v] of Object.entries(options.body)) {
if (v instanceof BufferBlob) {
form.append(k, Buffer.from(await v.arrayBuffer()), {
filename: 'upload',
contentType: v.type,
});
} else {
form.append(k, v);
}
}
for (const [k, v] of Object.entries(form.getHeaders())) {
opts.headers.set(k, v);
}
// @ts-expect-error
opts.body = form;
}
}
try {

@@ -445,0 +402,0 @@ const requestTime = Date.now();

{
"name": "balena-request",
"version": "12.1.0-build-otaviojacobi-does-multipart-form-when-blob-is-present-d4c119a7e7f62c54d12b954846dedf44bd7245dd-1",
"version": "13.0.0-build-drop-support-to-node14-16-c7bdf11c4ce4ea3b885a608d5ce76eeab758d32d-1",
"description": "Balena HTTP client",

@@ -21,3 +21,3 @@ "main": "build/request.js",

"engines": {
"node": ">=14.0.0"
"node": ">=18.0.0"
},

@@ -44,3 +44,2 @@ "scripts": {

"@types/mocha": "^9.1.1",
"@types/node": "^16.0.0",
"@types/progress-stream": "^2.0.0",

@@ -77,3 +76,2 @@ "@types/qs": "^6.9.3",

"fetch-readablestream": "^0.2.0",
"form-data": "^4.0.0",
"progress-stream": "^2.0.0",

@@ -88,4 +86,4 @@ "qs": "^6.9.4",

"versionist": {
"publishedAt": "2023-10-05T14:50:27.601Z"
"publishedAt": "2023-10-11T17:31:39.709Z"
}
}

Sorry, the diff of this file is not supported yet

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