Socket
Socket
Sign inDemoInstall

builder-util-runtime

Package Overview
Dependencies
Maintainers
1
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

builder-util-runtime - npm Package Compare versions

Comparing version 6.1.0 to 7.0.0

15

out/httpExecutor.d.ts

@@ -11,3 +11,2 @@ /// <reference types="node" />

readonly headers?: OutgoingHttpHeaders | null;
readonly skipDirCreation?: boolean;
readonly sha2?: string | null;

@@ -34,7 +33,15 @@ readonly sha512?: string | null;

private handleResponse;
abstract doRequest(options: any, callback: (response: any) => void): any;
protected doDownload(requestOptions: any, destination: string, redirectCount: number, options: DownloadOptions, callback: (error: Error | null) => void, onCancel: (callback: () => void) => void): void;
protected addTimeOutHandler(request: any, callback: (error: Error) => void): void;
abstract createRequest(options: any, callback: (response: any) => void): any;
protected doDownload(requestOptions: any, options: DownloadCallOptions, redirectCount: number): void;
protected createMaxRedirectError(): Error;
private addTimeOutHandler;
static prepareRedirectUrlOptions(redirectUrl: string, options: RequestOptions): RequestOptions;
}
export interface DownloadCallOptions {
responseHandler: ((response: IncomingMessage, callback: (error: Error | null) => void) => void) | null;
onCancel: (callback: () => void) => void;
callback: (error: Error | null) => void;
options: DownloadOptions;
destination: string | null;
}
export declare function configureRequestOptionsFromUrl(url: string, options: RequestOptions): RequestOptions;

@@ -41,0 +48,0 @@ export declare class DigestTransform extends Transform {

@@ -86,12 +86,2 @@ "use strict";

function _zlib() {
const data = require("zlib");
_zlib = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -149,3 +139,3 @@

return cancellationToken.createPromise((resolve, reject, onCancel) => {
const request = this.doRequest(options, response => {
const request = this.createRequest(options, response => {
try {

@@ -200,4 +190,4 @@ this.handleResponse(response, options, cancellationToken, resolve, reject, redirectCount, requestProcessor);

if (redirectUrl != null) {
if (redirectCount > 10) {
reject(new Error("Too many redirects (> 10)"));
if (redirectCount > this.maxRedirects) {
reject(this.createMaxRedirectError());
return;

@@ -210,15 +200,6 @@ }

let stream = response;
if (options.gzip) {
const gUnzip = (0, _zlib().createGunzip)();
gUnzip.on("error", reject);
response.pipe(gUnzip);
stream = gUnzip;
}
stream.setEncoding("utf8");
response.setEncoding("utf8");
let data = "";
stream.on("data", chunk => data += chunk);
stream.on("end", () => {
response.on("data", chunk => data += chunk);
response.on("end", () => {
try {

@@ -238,9 +219,10 @@ if (response.statusCode != null && response.statusCode >= 400) {

doDownload(requestOptions, destination, redirectCount, options, callback, onCancel) {
const request = this.doRequest(requestOptions, response => {
doDownload(requestOptions, options, redirectCount) {
const request = this.createRequest(requestOptions, response => {
if (response.statusCode >= 400) {
callback(new Error(`Cannot download "${requestOptions.protocol || "https:"}//${requestOptions.hostname}${requestOptions.path}", status ${response.statusCode}: ${response.statusMessage}`));
options.callback(new Error(`Cannot download "${requestOptions.protocol || "https:"}//${requestOptions.hostname}${requestOptions.path}", status ${response.statusCode}: ${response.statusMessage}`));
return;
}
} // this code not relevant for Electron (redirect event instead handled)
const redirectUrl = safeGetHeader(response, "location");

@@ -250,5 +232,5 @@

if (redirectCount < this.maxRedirects) {
this.doDownload(HttpExecutor.prepareRedirectUrlOptions(redirectUrl, requestOptions), destination, redirectCount++, options, callback, onCancel);
this.doDownload(HttpExecutor.prepareRedirectUrlOptions(redirectUrl, requestOptions), options, redirectCount++);
} else {
callback(new Error(`Too many redirects (> ${this.maxRedirects})`));
options.callback(this.createMaxRedirectError());
}

@@ -259,17 +241,24 @@

configurePipes(options, response, destination, callback, options.cancellationToken);
if (options.responseHandler == null) {
configurePipes(options, response);
} else {
options.responseHandler(response, options.callback);
}
});
this.addErrorAndTimeoutHandlers(request, callback);
this.addRedirectHandlers(request, requestOptions, callback, redirectCount, requestOptions => {
this.doDownload(requestOptions, destination, redirectCount++, options, callback, onCancel);
this.addErrorAndTimeoutHandlers(request, options.callback);
this.addRedirectHandlers(request, requestOptions, options.callback, redirectCount, requestOptions => {
this.doDownload(requestOptions, options, redirectCount++);
});
onCancel(() => request.abort());
request.end();
}
createMaxRedirectError() {
return new Error(`Too many redirects (> ${this.maxRedirects})`);
}
addTimeOutHandler(request, callback) {
request.on("socket", socket => {
socket.setTimeout(60 * 1000, () => {
request.abort();
callback(new Error("Request timed out"));
request.abort();
});

@@ -370,11 +359,5 @@ });

function checkSha2(sha2Header, sha2, callback) {
if (sha2Header != null && sha2 != null) {
// todo why bintray doesn't send this header always
if (sha2Header == null) {
callback(new Error("checksum is required, but server response doesn't contain X-Checksum-Sha2 header"));
return false;
} else if (sha2Header !== sha2) {
callback(new Error(`checksum mismatch: expected ${sha2} but got ${sha2Header} (X-Checksum-Sha2 header)`));
return false;
}
if (sha2Header != null && sha2 != null && sha2Header !== sha2) {
callback(new Error(`checksum mismatch: expected ${sha2} but got ${sha2Header} (X-Checksum-Sha2 header)`));
return false;
}

@@ -398,4 +381,4 @@

function configurePipes(options, response, destination, callback, cancellationToken) {
if (!checkSha2(safeGetHeader(response, "X-Checksum-Sha2"), options.sha2, callback)) {
function configurePipes(options, response) {
if (!checkSha2(safeGetHeader(response, "X-Checksum-Sha2"), options.options.sha2, options.callback)) {
return;

@@ -406,19 +389,19 @@ }

if (options.onProgress != null) {
if (options.options.onProgress != null) {
const contentLength = safeGetHeader(response, "content-length");
if (contentLength != null) {
streams.push(new (_ProgressCallbackTransform().ProgressCallbackTransform)(parseInt(contentLength, 10), options.cancellationToken, options.onProgress));
streams.push(new (_ProgressCallbackTransform().ProgressCallbackTransform)(parseInt(contentLength, 10), options.options.cancellationToken, options.options.onProgress));
}
}
const sha512 = options.sha512;
const sha512 = options.options.sha512;
if (sha512 != null) {
streams.push(new DigestTransform(sha512, "sha512", sha512.length === 128 && !sha512.includes("+") && !sha512.includes("Z") && !sha512.includes("=") ? "hex" : "base64"));
} else if (options.sha2 != null) {
streams.push(new DigestTransform(options.sha2, "sha256", "hex"));
} else if (options.options.sha2 != null) {
streams.push(new DigestTransform(options.options.sha2, "sha256", "hex"));
}
const fileOut = (0, _fsExtraP().createWriteStream)(destination);
const fileOut = (0, _fsExtraP().createWriteStream)(options.destination);
streams.push(fileOut);

@@ -429,4 +412,4 @@ let lastStream = response;

stream.on("error", error => {
if (!cancellationToken.cancelled) {
callback(error);
if (!options.options.cancellationToken.cancelled) {
options.callback(error);
}

@@ -438,3 +421,3 @@ });

fileOut.on("finish", () => {
fileOut.close(callback);
fileOut.close(options.callback);
});

@@ -441,0 +424,0 @@ }

{
"name": "builder-util-runtime",
"version": "6.1.0",
"version": "7.0.0",
"main": "out/index.js",

@@ -5,0 +5,0 @@ "author": "Vladimir Krivosheev",

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