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

balena-request

Package Overview
Dependencies
Maintainers
0
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 14.0.0 to 14.0.1-build-conditional-imports-ba3e2921299da12edd932b7c939f4e8bd9774f8d-1

build/conditional-imports.browser.d.ts

22

build/progress.js

@@ -122,22 +122,6 @@ "use strict";

if (!isBrowser && utils.isResponseCompressed(response)) {
const { createGunzip } =
// eslint-disable-next-line @typescript-eslint/no-var-requires
const zlib = require('zlib');
// Be more lenient with decoding compressed responses, since (very rarely)
// servers send slightly invalid gzip responses that are still accepted
// by common browsers.
// Always using Z_SYNC_FLUSH is what cURL does.
let zlibOptions = {
flush: zlib.constants.Z_SYNC_FLUSH,
finishFlush: zlib.constants.Z_SYNC_FLUSH,
};
// Allow overriding this behaviour by setting the ZLIB_FLUSH env var
// to one of the allowed zlib flush values (process.env.ZLIB_FLUSH="Z_NO_FLUSH").
// https://github.com/nodejs/node/blob/master/doc/api/zlib.md#zlib-constants
if (process.env.ZLIB_FLUSH && process.env.ZLIB_FLUSH in zlib.constants) {
zlibOptions = {
flush: zlib.constants[process.env.ZLIB_FLUSH],
finishFlush: zlib.constants[process.env.ZLIB_FLUSH],
};
}
const gunzip = zlib.createGunzip(zlibOptions);
require('./conditional-imports');
const gunzip = createGunzip();
gunzip.on('error', (e) => output.emit('error', e));

@@ -144,0 +128,0 @@ // Uncompress after or before piping through progress

@@ -331,11 +331,2 @@ "use strict";

};
const getForm = () => {
if (!IS_BROWSER) {
const { FormData: NodeFormData } =
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('formdata-node');
return new NodeFormData();
}
return new FormData();
};
// This is the actual implementation that hides the internal `retriesRemaining` parameter

@@ -366,3 +357,6 @@ async function requestAsync(fetch, options, retriesRemaining) {

if (fileKeys.size > 0) {
const form = getForm();
const { getFormDataConstructor, getFormDataEncoder } =
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('./conditional-imports');
const form = getFormDataConstructor();
for (const [k, v] of bodyEntries) {

@@ -384,5 +378,3 @@ if (fileKeys.has(k)) {

else {
const { FormDataEncoder } =
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('form-data-encoder');
const FormDataEncoder = getFormDataEncoder();
const encoder = new FormDataEncoder(form);

@@ -389,0 +381,0 @@ opts.headers.set('Content-Type', encoder.headers['Content-Type']);

@@ -7,2 +7,6 @@ # Change Log

## 14.0.1 - 2024-12-05
* Avoid requiring some node dependencies using the package.json browser field [Thodoris Greasidis]
## 14.0.0 - 2024-12-04

@@ -9,0 +13,0 @@

@@ -159,31 +159,7 @@ /*

if (!isBrowser && utils.isResponseCompressed(response)) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const zlib = require('zlib') as typeof import('zlib');
const { createGunzip } =
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('./conditional-imports') as typeof import('./conditional-imports');
// Be more lenient with decoding compressed responses, since (very rarely)
// servers send slightly invalid gzip responses that are still accepted
// by common browsers.
// Always using Z_SYNC_FLUSH is what cURL does.
let zlibOptions = {
flush: zlib.constants.Z_SYNC_FLUSH,
finishFlush: zlib.constants.Z_SYNC_FLUSH,
};
// Allow overriding this behaviour by setting the ZLIB_FLUSH env var
// to one of the allowed zlib flush values (process.env.ZLIB_FLUSH="Z_NO_FLUSH").
// https://github.com/nodejs/node/blob/master/doc/api/zlib.md#zlib-constants
if (process.env.ZLIB_FLUSH && process.env.ZLIB_FLUSH in zlib.constants) {
zlibOptions = {
flush:
zlib.constants[
process.env.ZLIB_FLUSH as keyof typeof zlib.constants
],
finishFlush:
zlib.constants[
process.env.ZLIB_FLUSH as keyof typeof zlib.constants
],
};
}
const gunzip = zlib.createGunzip(zlibOptions);
const gunzip = createGunzip();
gunzip.on('error', (e) => output.emit('error', e));

@@ -190,0 +166,0 @@

@@ -389,13 +389,2 @@ /*

const getForm = (): FormDataNodeType | FormData => {
if (!IS_BROWSER) {
const { FormData: NodeFormData } =
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('formdata-node') as typeof import('formdata-node');
return new NodeFormData();
}
return new FormData();
};
// This is the actual implementation that hides the internal `retriesRemaining` parameter

@@ -433,3 +422,6 @@ async function requestAsync(

if (fileKeys.size > 0) {
const form = getForm();
const { getFormDataConstructor, getFormDataEncoder } =
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('./conditional-imports') as typeof import('./conditional-imports');
const form = getFormDataConstructor();
for (const [k, v] of bodyEntries) {

@@ -450,6 +442,3 @@ if (fileKeys.has(k)) {

} else {
const { FormDataEncoder } =
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('form-data-encoder') as typeof import('form-data-encoder');
const FormDataEncoder = getFormDataEncoder();
const encoder = new FormDataEncoder(form as FormDataNodeType);

@@ -456,0 +445,0 @@ opts.headers.set('Content-Type', encoder.headers['Content-Type']);

{
"name": "balena-request",
"version": "14.0.0",
"version": "14.0.1-build-conditional-imports-ba3e2921299da12edd932b7c939f4e8bd9774f8d-1",
"description": "Balena HTTP client",

@@ -8,2 +8,6 @@ "type": "commonjs",

"types": "build/request.d.ts",
"browser": {
"./build/request.js": "./build/request.js",
"./build/conditional-imports.js": "./build/conditional-imports.browser.js"
},
"homepage": "https://github.com/balena-io-modules/balena-request",

@@ -87,4 +91,4 @@ "repository": {

"versionist": {
"publishedAt": "2024-12-04T16:35:59.225Z"
"publishedAt": "2024-12-05T18:05:22.618Z"
}
}

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