builder-util-runtime
Advanced tools
Comparing version 7.1.0 to 8.0.0
/// <reference types="node" /> | ||
import { IncomingMessage, OutgoingHttpHeaders, RequestOptions } from "http"; | ||
import { Transform } from "stream"; | ||
import { URL } from "url"; | ||
import { CancellationToken } from "./CancellationToken"; | ||
@@ -33,2 +34,3 @@ import { ProgressInfo } from "./ProgressCallbackTransform"; | ||
abstract createRequest(options: any, callback: (response: any) => void): any; | ||
downloadToBuffer(url: URL, options: DownloadOptions): Promise<Buffer>; | ||
protected doDownload(requestOptions: any, options: DownloadCallOptions, redirectCount: number): void; | ||
@@ -47,2 +49,3 @@ protected createMaxRedirectError(): Error; | ||
export declare function configureRequestOptionsFromUrl(url: string, options: RequestOptions): RequestOptions; | ||
export declare function configureRequestUrl(url: URL, options: RequestOptions): void; | ||
export declare class DigestTransform extends Transform { | ||
@@ -49,0 +52,0 @@ readonly expected: string; |
@@ -9,2 +9,3 @@ "use strict"; | ||
exports.configureRequestOptionsFromUrl = configureRequestOptionsFromUrl; | ||
exports.configureRequestUrl = configureRequestUrl; | ||
exports.safeGetHeader = safeGetHeader; | ||
@@ -15,2 +16,12 @@ exports.configureRequestOptions = configureRequestOptions; | ||
function _bluebirdLst() { | ||
const data = require("bluebird-lst"); | ||
_bluebirdLst = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _crypto() { | ||
@@ -217,2 +228,73 @@ const data = require("crypto"); | ||
downloadToBuffer(url, options) { | ||
var _this = this; | ||
return (0, _bluebirdLst().coroutine)(function* () { | ||
return yield options.cancellationToken.createPromise((resolve, reject, onCancel) => { | ||
let result = null; | ||
const requestOptions = { | ||
headers: options.headers || undefined, | ||
// because PrivateGitHubProvider requires HttpExecutor.prepareRedirectUrlOptions logic, so, we need to redirect manually | ||
redirect: "manual" | ||
}; | ||
configureRequestUrl(url, requestOptions); | ||
configureRequestOptions(requestOptions); | ||
_this.doDownload(requestOptions, { | ||
destination: null, | ||
options, | ||
onCancel, | ||
callback: error => { | ||
if (error == null) { | ||
resolve(result); | ||
} else { | ||
reject(error); | ||
} | ||
}, | ||
responseHandler: (response, callback) => { | ||
const contentLength = safeGetHeader(response, "content-length"); | ||
let position = -1; | ||
if (contentLength != null) { | ||
const size = parseInt(contentLength, 10); | ||
if (size > 0) { | ||
if (size > 5242880) { | ||
callback(new Error("Maximum allowed size is 5 MB")); | ||
return; | ||
} | ||
result = Buffer.alloc(size); | ||
position = 0; | ||
} | ||
} | ||
response.on("data", chunk => { | ||
if (position !== -1) { | ||
chunk.copy(result, position); | ||
position += chunk.length; | ||
} else if (result == null) { | ||
result = chunk; | ||
} else { | ||
if (result.length > 5242880) { | ||
callback(new Error("Maximum allowed size is 5 MB")); | ||
return; | ||
} | ||
result = Buffer.concat([result, chunk]); | ||
} | ||
}); | ||
response.on("end", () => { | ||
if (result != null && position !== -1 && position !== result.length) { | ||
callback(new Error(`Received data length ${position} is not equal to expected ${result.length}`)); | ||
} else { | ||
callback(null); | ||
} | ||
}); | ||
} | ||
}, 0); | ||
}); | ||
})(); | ||
} | ||
doDownload(requestOptions, options, redirectCount) { | ||
@@ -284,16 +366,18 @@ const request = this.createRequest(requestOptions, response => { | ||
function configureRequestOptionsFromUrl(url, options) { | ||
const parsedUrl = (0, _url().parse)(url); | ||
options.protocol = parsedUrl.protocol; | ||
options.hostname = parsedUrl.hostname; | ||
const result = configureRequestOptions(options); | ||
configureRequestUrl(new (_url().URL)(url), result); | ||
return result; | ||
} | ||
if (parsedUrl.port == null) { | ||
if (options.port != null) { | ||
delete options.port; | ||
} | ||
} else { | ||
options.port = parsedUrl.port; | ||
function configureRequestUrl(url, options) { | ||
options.protocol = url.protocol; | ||
options.hostname = url.hostname; | ||
if (url.port) { | ||
options.port = url.port; | ||
} else if (options.port) { | ||
delete options.port; | ||
} | ||
options.path = parsedUrl.path; | ||
return configureRequestOptions(options); | ||
options.path = url.pathname + url.search; | ||
} | ||
@@ -300,0 +384,0 @@ |
export { CancellationToken, CancellationError } from "./CancellationToken"; | ||
export { HttpError, createHttpError, HttpExecutor, DownloadOptions, DigestTransform, RequestHeaders, safeGetHeader, configureRequestOptions, configureRequestOptionsFromUrl, safeStringifyJson, parseJson } from "./httpExecutor"; | ||
export { HttpError, createHttpError, HttpExecutor, DownloadOptions, DigestTransform, RequestHeaders, safeGetHeader, configureRequestOptions, configureRequestOptionsFromUrl, safeStringifyJson, parseJson, configureRequestUrl } from "./httpExecutor"; | ||
export { BintrayOptions, GenericServerOptions, GithubOptions, PublishConfiguration, S3Options, SpacesOptions, BaseS3Options, getS3LikeProviderBaseUrl, Publish, githubUrl, PublishProvider, AllPublishOptions } from "./publishOptions"; | ||
@@ -10,5 +10,5 @@ export { UpdateInfo, UpdateFileInfo, WindowsUpdateInfo, BlockMapDataHolder, PackageFileInfo, ReleaseNoteInfo } from "./updateInfo"; | ||
export { BlockMap } from "./blockMapApi"; | ||
export declare const CURRENT_APP_INSTALLER_FILE_NAME = "__installer.exe"; | ||
export declare const CURRENT_APP_PACKAGE_FILE_NAME = "__package.7z"; | ||
export declare const CURRENT_APP_INSTALLER_FILE_NAME = "installer.exe"; | ||
export declare const CURRENT_APP_PACKAGE_FILE_NAME = "package.7z"; | ||
export declare function asArray<T>(v: null | undefined | T | Array<T>): Array<T>; | ||
export declare function newError(message: string, code: string): Error; |
@@ -74,2 +74,8 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "configureRequestUrl", { | ||
enumerable: true, | ||
get: function () { | ||
return _httpExecutor().configureRequestUrl; | ||
} | ||
}); | ||
Object.defineProperty(exports, "getS3LikeProviderBaseUrl", { | ||
@@ -190,6 +196,6 @@ enumerable: true, | ||
// nsis | ||
const CURRENT_APP_INSTALLER_FILE_NAME = "__installer.exe"; // nsis-web | ||
const CURRENT_APP_INSTALLER_FILE_NAME = "installer.exe"; // nsis-web | ||
exports.CURRENT_APP_INSTALLER_FILE_NAME = CURRENT_APP_INSTALLER_FILE_NAME; | ||
const CURRENT_APP_PACKAGE_FILE_NAME = "__package.7z"; | ||
const CURRENT_APP_PACKAGE_FILE_NAME = "package.7z"; | ||
exports.CURRENT_APP_PACKAGE_FILE_NAME = CURRENT_APP_PACKAGE_FILE_NAME; | ||
@@ -196,0 +202,0 @@ |
@@ -11,5 +11,11 @@ export declare type PublishProvider = "github" | "bintray" | "s3" | "spaces" | "generic" | "custom"; | ||
* @private | ||
* win-only | ||
*/ | ||
readonly publisherName?: Array<string> | null; | ||
publisherName?: Array<string> | null; | ||
/** | ||
* @private | ||
* win-only | ||
*/ | ||
readonly updaterCacheDirName?: string | null; | ||
/** | ||
* Whether to publish auto update info files. | ||
@@ -16,0 +22,0 @@ * |
{ | ||
"name": "builder-util-runtime", | ||
"version": "7.1.0", | ||
"version": "8.0.0", | ||
"main": "out/index.js", | ||
@@ -5,0 +5,0 @@ "author": "Vladimir Krivosheev", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
146418
1770