builder-util-runtime
Advanced tools
@@ -1,2 +0,3 @@ | ||
| export declare const BLOCK_MAP_FILE_NAME = "blockMap.yml"; | ||
| export declare const BLOCK_MAP_FILE_NAME = "_blockMap.yml"; | ||
| export declare const SIGNATURE_HEADER_SIZE: number; | ||
| export interface BlockMap { | ||
@@ -11,4 +12,5 @@ blockSize: number; | ||
| name: string; | ||
| offset: number; | ||
| size: number; | ||
| blocks: Array<string>; | ||
| } |
@@ -6,3 +6,4 @@ "use strict"; | ||
| }); | ||
| const BLOCK_MAP_FILE_NAME = exports.BLOCK_MAP_FILE_NAME = "blockMap.yml"; | ||
| const BLOCK_MAP_FILE_NAME = exports.BLOCK_MAP_FILE_NAME = "_blockMap.yml"; | ||
| const SIGNATURE_HEADER_SIZE = exports.SIGNATURE_HEADER_SIZE = 12 /* signature + 2 bytes version + 4 bytes CRC */ + 20; | ||
| //# sourceMappingURL=blockMapApi.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"blockMapApi.js","sourceRoot":"","sources":["../../src/differentialUpdate/blockMapApi.ts"],"names":[],"mappings":"AAAA,AAAM;;;;;AAAC,MAAM,AAAmB,oDAAG,AAAc","sourcesContent":["export const BLOCK_MAP_FILE_NAME = \"blockMap.yml\"\n\nexport interface BlockMap {\n blockSize: number\n hashMethod: \"sha256\" | \"md5\"\n\n // https://sourceforge.net/p/sevenzip/discussion/45798/thread/222c71f9/?limit=25\n compressionMethod: \"lzma\"\n compressionLevel: 9 | 1\n\n files: Array<BlockMapFile>\n}\n\nexport interface BlockMapFile {\n name: string\n size: number\n\n // size of block 64K, last block size `size % (64 * 1024)`\n blocks: Array<string>\n}"]} | ||
| {"version":3,"file":"blockMapApi.js","sourceRoot":"","sources":["../../src/differentialUpdate/blockMapApi.ts"],"names":[],"mappings":"AAAA,AAAM;;;;;AAAC,MAAM,AAAmB,oDAAG,AAAe,AAClD,AAAM;AAAC,MAAM,AAAqB,wDAAG,AAAE,GAAC,AAA+C,kDAAG,AAAE","sourcesContent":["export const BLOCK_MAP_FILE_NAME = \"_blockMap.yml\"\nexport const SIGNATURE_HEADER_SIZE = 12 /* signature + 2 bytes version + 4 bytes CRC */ + 20\n\nexport interface BlockMap {\n blockSize: number\n hashMethod: \"sha256\" | \"md5\"\n\n // https://sourceforge.net/p/sevenzip/discussion/45798/thread/222c71f9/?limit=25\n compressionMethod: \"lzma\"\n compressionLevel: 9 | 1\n\n files: Array<BlockMapFile>\n}\n\nexport interface BlockMapFile {\n name: string\n offset: number\n size: number\n\n // size of block 64K, last block size `size % (64 * 1024)`\n blocks: Array<string>\n}"]} |
@@ -56,9 +56,13 @@ /// <reference types="node" /> | ||
| export declare class DigestTransform extends Transform { | ||
| private readonly expected; | ||
| readonly expected: string; | ||
| private readonly algorithm; | ||
| private readonly encoding; | ||
| private readonly digester; | ||
| constructor(expected: string, algorithm: string, encoding: "hex" | "base64" | "latin1"); | ||
| private _actual; | ||
| readonly actual: string; | ||
| isValidateOnEnd: boolean; | ||
| constructor(expected: string, algorithm?: string, encoding?: "hex" | "base64" | "latin1"); | ||
| _transform(chunk: any, encoding: string, callback: any): void; | ||
| _flush(callback: any): void; | ||
| validate(): null; | ||
| } | ||
@@ -65,0 +69,0 @@ export declare function safeGetHeader(response: any, headerKey: string): any; |
+27
-3
@@ -202,3 +202,6 @@ "use strict"; | ||
| class DigestTransform extends (_stream || _load_stream()).Transform { | ||
| constructor(expected, algorithm, encoding) { | ||
| constructor(expected) { | ||
| let algorithm = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "sha512"; | ||
| let encoding = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "base64"; | ||
| super(); | ||
@@ -208,4 +211,8 @@ this.expected = expected; | ||
| this.encoding = encoding; | ||
| this.isValidateOnEnd = true; | ||
| this.digester = (0, (_crypto || _load_crypto()).createHash)(algorithm); | ||
| } | ||
| get actual() { | ||
| return this._actual; | ||
| } | ||
| _transform(chunk, encoding, callback) { | ||
@@ -216,5 +223,22 @@ this.digester.update(chunk); | ||
| _flush(callback) { | ||
| const hash = this.digester.digest(this.encoding); | ||
| callback(hash === this.expected ? null : new Error(`${this.algorithm} checksum mismatch, expected ${this.expected}, got ${hash}`)); | ||
| this._actual = this.digester.digest(this.encoding); | ||
| if (this.isValidateOnEnd) { | ||
| try { | ||
| this.validate(); | ||
| } catch (e) { | ||
| callback(e); | ||
| return; | ||
| } | ||
| } | ||
| callback(null); | ||
| } | ||
| validate() { | ||
| if (this._actual == null) { | ||
| throw new Error("Not finished yet"); | ||
| } | ||
| if (this._actual !== this.expected) { | ||
| throw new Error(`${this.algorithm} checksum mismatch, expected ${this.expected}, got ${this._actual}`); | ||
| } | ||
| return null; | ||
| } | ||
| } | ||
@@ -221,0 +245,0 @@ exports.DigestTransform = DigestTransform; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"httpExecutor.js","sourceRoot":"","sources":["../src/httpExecutor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,AAAO,AAAE,AAAU,AAAQ,AAAM,AAAQ;;;;AACzC,AAAO,AAAM,AAAM,AAAO;;;;AAE1B,AAAO,AAAE,AAAiB,AAAE,AAAM,AAAY;;;;;;AAG9C,AAAO,AAAE,AAAS,AAAE,AAAM,AAAQ;;;;;;AAClC,AAAO,AAAE,AAAK,AAAI,AAAQ,AAAE,AAAM,AAAK;;;;;;AACvC,AAAO,AAAE,AAAiB,AAAE,AAAM,AAAqB;;;;;;AACvD,AAAO,AAAE,AAAyB,AAAgB,AAAM,AAA6B;;;;;;AAErF,MAAM,AAAK,QAAG,AAAM,qBAAC,AAAkB,AAAC,AA0BxC,AAAM;MAAiB,kBAAQ,AAAK;AAClC,gBAAqB,AAAwI;YAAS,kFAA0B,AAAI;;AAClM,AAAK,cAAC,AAAQ,SAAC,AAAU,aAAG,AAAG,MAAG,AAAQ,SAAC,AAAa,AAAG,iBAAC,AAAW,eAAI,AAAI,OAAG,AAAE,AAAG,KAAC,AAAI,OAAG,AAAI,KAAC,AAAS,UAAC,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,QAAK,AAAO,QAAC,AAAgB,SAAC,AAAQ,YAAI,AAAI,AAAC,MAAC,AAAC;AAC3E,AAAO,gBAAC,AAAQ,WAAG,AAAQ,AAC7B;AAAC;AACD,AAAM,WAAC,AAAO,AAChB;AAAC,AAED,AAAM;2BAA4B,AAAS,MAAE,AAA0B;AACrE,AAAM,gBAAM,AAAS,UAAC,AAAI,MAAE,CAAC,AAAI,MAAE,AAAK;AACtC,AAAE,AAAC,YAAC,AAAI,KAAC,AAAQ,SAAC,AAAe,AAAC,oBAAI,AAAI,KAAC,AAAQ,SAAC,AAAU,AAAC,eAAI,AAAI,KAAC,AAAQ,SAAC,AAAU,AAAC,eAAI,AAAI,KAAC,AAAQ,SAAC,AAAO,AAAC,YAAI,AAAI,KAAC,AAAQ,QAAC,AAAU,AAAC,sBAAI,AAAI,KAAC,AAAQ,QAAC,AAAO,AAAC,AAAI,mBAAC,AAAY,gBAAI,AAAI,QAAI,AAAY,aAAC,AAAG,IAAC,AAAI,AAAC,AAAC,AAAC,OAAC,AAAC;AAClO,AAAM,mBAAC,AAA2B,AACpC;AAAC;AACD,AAAM,eAAC,AAAK,AACd;AAAC,KALM,AAAI,EAKR,AAAC,AAAC,AACP;AAAC","sourcesContent":["import { createHash, Hash } from \"crypto\"\nimport _debug from \"debug\"\nimport { EventEmitter } from \"events\"\nimport { createWriteStream } from \"fs-extra-p\"\nimport { IncomingMessage, OutgoingHttpHeaders, RequestOptions } from \"http\"\nimport { Socket } from \"net\"\nimport { Transform } from \"stream\"\nimport { parse as parseUrl } from \"url\"\nimport { CancellationToken } from \"./CancellationToken\"\nimport { ProgressCallbackTransform, ProgressInfo } from \"./ProgressCallbackTransform\"\n\nconst debug = _debug(\"electron-builder\")\n\nexport interface RequestHeaders extends OutgoingHttpHeaders {\n [key: string]: string\n}\n\nexport interface Response extends EventEmitter {\n statusCode?: number\n statusMessage?: string\n\n headers: any\n\n setEncoding(encoding: string): void\n}\n\nexport interface DownloadOptions {\n readonly headers?: OutgoingHttpHeaders | null\n readonly skipDirCreation?: boolean\n readonly sha2?: string | null\n readonly sha512?: string | null\n\n readonly cancellationToken: CancellationToken\n\n onProgress?(progress: ProgressInfo): void\n}\n\nexport class HttpError extends Error {\n constructor(readonly response: {statusMessage?: string | undefined, statusCode?: number | undefined, headers?: { [key: string]: Array<string>; } | undefined}, public description: any | null = null) {\n super(response.statusCode + \" \" + response.statusMessage + (description == null ? \"\" : (\"\\n\" + JSON.stringify(description, null, \" \"))) + \"\\nHeaders: \" + JSON.stringify(response.headers, null, \" \"))\n\n this.name = \"HttpError\"\n }\n}\n\nexport function parseJson(result: Promise<string | null>) {\n return result.then(it => it == null || it.length === 0 ? null : JSON.parse(it))\n}\n\nexport abstract class HttpExecutor<REQUEST> {\n protected readonly maxRedirects = 10\n\n request(options: RequestOptions, cancellationToken: CancellationToken = new CancellationToken(), data?: { [name: string]: any; } | null): Promise<string | null> {\n configureRequestOptions(options)\n const encodedData = data == null ? undefined : Buffer.from(JSON.stringify(data))\n if (encodedData != null) {\n options.method = \"post\"\n options.headers![\"Content-Type\"] = \"application/json\"\n options.headers![\"Content-Length\"] = encodedData.length\n }\n return this.doApiRequest(options, cancellationToken, it => (it as any).end(encodedData))\n }\n\n doApiRequest(options: RequestOptions, cancellationToken: CancellationToken, requestProcessor: (request: REQUEST, reject: (error: Error) => void) => void, redirectCount: number = 0): Promise<string> {\n if (debug.enabled) {\n debug(`Request: ${safeStringifyJson(options)}`)\n }\n\n return cancellationToken.createPromise<string>((resolve, reject, onCancel) => {\n const request = this.doRequest(options, (response: any) => {\n try {\n this.handleResponse(response, options, cancellationToken, resolve, reject, redirectCount, requestProcessor)\n }\n catch (e) {\n reject(e)\n }\n })\n this.addErrorAndTimeoutHandlers(request, reject)\n requestProcessor(request, reject)\n onCancel(() => request.abort())\n })\n }\n\n addErrorAndTimeoutHandlers(request: any, reject: (error?: Error | null) => void) {\n this.addTimeOutHandler(request, reject)\n request.on(\"error\", reject)\n request.on(\"aborted\", () => {\n reject(new Error(\"Request has been aborted by the server\"))\n })\n }\n\n protected handleResponse(response: Response, options: RequestOptions, cancellationToken: CancellationToken, resolve: (data?: any) => void, reject: (error: Error) => void, redirectCount: number, requestProcessor: (request: REQUEST, reject: (error: Error) => void) => void) {\n if (debug.enabled) {\n debug(`Response: ${response.statusCode} ${response.statusMessage}, request options: ${safeStringifyJson(options)}`)\n }\n\n // we handle any other >= 400 error on request end (read detailed message in the response body)\n if (response.statusCode === 404) {\n // error is clear, we don't need to read detailed error description\n reject(new HttpError(response, `method: ${options.method} url: ${options.protocol || \"https:\"}//${options.hostname}${options.path}\n\nPlease double check that your authentication token is correct. Due to security reasons actual status maybe not reported, but 404.\n`))\n return\n }\n else if (response.statusCode === 204) {\n // on DELETE request\n resolve()\n return\n }\n\n const redirectUrl = safeGetHeader(response, \"location\")\n if (redirectUrl != null) {\n if (redirectCount > 10) {\n reject(new Error(\"Too many redirects (> 10)\"))\n return\n }\n\n this.doApiRequest(configureRequestOptionsFromUrl(redirectUrl, {...options}), cancellationToken, requestProcessor, redirectCount)\n .then(resolve)\n .catch(reject)\n return\n }\n\n let data = \"\"\n response.setEncoding(\"utf8\")\n response.on(\"data\", (chunk: string) => {\n data += chunk\n })\n\n response.on(\"end\", () => {\n try {\n if (response.statusCode != null && response.statusCode >= 400) {\n const contentType = safeGetHeader(response, \"content-type\")\n const isJson = contentType != null && (Array.isArray(contentType) ? contentType.find(it => it.includes(\"json\")) != null : contentType.includes(\"json\"))\n reject(new HttpError(response, isJson ? JSON.parse(data) : data))\n }\n else {\n resolve(data.length === 0 ? null : data)\n }\n }\n catch (e) {\n reject(e)\n }\n })\n }\n\n abstract doRequest(options: any, callback: (response: any) => void): any\n\n protected doDownload(requestOptions: any, destination: string, redirectCount: number, options: DownloadOptions, callback: (error: Error | null) => void, onCancel: (callback: () => void) => void) {\n const request = this.doRequest(requestOptions, (response: IncomingMessage) => {\n if (response.statusCode! >= 400) {\n callback(new Error(`Cannot download \"${requestOptions.protocol || \"https:\"}//${requestOptions.hostname}${requestOptions.path}\", status ${response.statusCode}: ${response.statusMessage}`))\n return\n }\n\n const redirectUrl = safeGetHeader(response, \"location\")\n if (redirectUrl != null) {\n if (redirectCount < this.maxRedirects) {\n this.doDownload(configureRequestOptionsFromUrl(redirectUrl, {...requestOptions}), destination, redirectCount++, options, callback, onCancel)\n }\n else {\n callback(new Error(`Too many redirects (> ${this.maxRedirects})`))\n }\n return\n }\n\n configurePipes(options, response, destination, callback, options.cancellationToken)\n })\n this.addErrorAndTimeoutHandlers(request, callback)\n onCancel(() => request.abort())\n request.end()\n }\n\n protected addTimeOutHandler(request: any, callback: (error: Error) => void) {\n request.on(\"socket\", (socket: Socket) => {\n socket.setTimeout(60 * 1000, () => {\n callback(new Error(\"Request timed out\"))\n request.abort()\n })\n })\n }\n}\n\nexport function configureRequestOptionsFromUrl(url: string, options: RequestOptions) {\n const parsedUrl = parseUrl(url)\n options.protocol = parsedUrl.protocol\n options.hostname = parsedUrl.hostname\n if (parsedUrl.port == null) {\n if (options.port != null) {\n delete options.port\n }\n }\n else {\n options.port = parsedUrl.port\n }\n options.path = parsedUrl.path\n return configureRequestOptions(options)\n}\n\nexport class DigestTransform extends Transform {\n private readonly digester: Hash\n\n constructor(private readonly expected: string, private readonly algorithm: string, private readonly encoding: \"hex\" | \"base64\" | \"latin1\") {\n super()\n\n this.digester = createHash(algorithm)\n }\n\n _transform(chunk: any, encoding: string, callback: any) {\n this.digester.update(chunk)\n callback(null, chunk)\n }\n\n _flush(callback: any): void {\n const hash = this.digester.digest(this.encoding)\n callback(hash === this.expected ? null : new Error(`${this.algorithm} checksum mismatch, expected ${this.expected}, got ${hash}`))\n }\n}\n\nfunction checkSha2(sha2Header: string | null | undefined, sha2: string | null | undefined, callback: (error: Error | null) => void): boolean {\n if (sha2Header != null && sha2 != null) {\n // todo why bintray doesn't send this header always\n if (sha2Header == null) {\n callback(new Error(\"checksum is required, but server response doesn't contain X-Checksum-Sha2 header\"))\n return false\n }\n else if (sha2Header !== sha2) {\n callback(new Error(`checksum mismatch: expected ${sha2} but got ${sha2Header} (X-Checksum-Sha2 header)`))\n return false\n }\n }\n return true\n}\n\nexport function safeGetHeader(response: any, headerKey: string) {\n const value = response.headers[headerKey]\n if (value == null) {\n return null\n }\n else if (Array.isArray(value)) {\n // electron API\n return value.length === 0 ? null : value[value.length - 1]\n }\n else {\n return value\n }\n}\n\nfunction configurePipes(options: DownloadOptions, response: any, destination: string, callback: (error: Error | null) => void, cancellationToken: CancellationToken) {\n if (!checkSha2(safeGetHeader(response, \"X-Checksum-Sha2\"), options.sha2, callback)) {\n return\n }\n\n const streams: Array<any> = []\n if (options.onProgress != null) {\n const contentLength = safeGetHeader(response, \"content-length\")\n if (contentLength != null) {\n streams.push(new ProgressCallbackTransform(parseInt(contentLength, 10), options.cancellationToken, options.onProgress))\n }\n }\n\n const sha512 = options.sha512\n if (sha512 != null) {\n streams.push(new DigestTransform(sha512, \"sha512\", sha512.length === 128 && !sha512.includes(\"+\") && !sha512.includes(\"Z\") && !sha512.includes(\"=\") ? \"hex\" : \"base64\"))\n }\n else if (options.sha2 != null) {\n streams.push(new DigestTransform(options.sha2, \"sha256\", \"hex\"))\n }\n\n const fileOut = createWriteStream(destination)\n streams.push(fileOut)\n\n let lastStream = response\n for (const stream of streams) {\n stream.on(\"error\", (error: Error) => {\n if (!cancellationToken.cancelled) {\n callback(error)\n }\n })\n lastStream = lastStream.pipe(stream)\n }\n\n fileOut.on(\"finish\", () => {\n (fileOut.close as any)(callback)\n })\n}\n\nexport function configureRequestOptions(options: RequestOptions, token?: string | null, method?: \"GET\" | \"DELETE\" | \"PUT\"): RequestOptions {\n if (method != null) {\n options.method = method\n }\n\n let headers = options.headers\n if (headers == null) {\n headers = {}\n options.headers = headers\n }\n if (token != null) {\n (headers as any).authorization = token.startsWith(\"Basic\") ? token : `token ${token}`\n }\n if (headers[\"User-Agent\"] == null) {\n headers[\"User-Agent\"] = \"electron-builder\"\n }\n\n if ((method == null || method === \"GET\") || headers[\"Cache-Control\"] == null) {\n headers[\"Cache-Control\"] = \"no-cache\"\n }\n\n // do not specify for node (in any case we use https module)\n if (options.protocol == null && (process.versions as any).electron != null) {\n options.protocol = \"https:\"\n }\n return options\n}\n\nexport function safeStringifyJson(data: any, skippedNames?: Set<string>) {\n return JSON.stringify(data, (name, value) => {\n if (name.endsWith(\"authorization\") || name.endsWith(\"Password\") || name.endsWith(\"PASSWORD\") || name.endsWith(\"Token\") || name.includes(\"password\") || name.includes(\"token\") || (skippedNames != null && skippedNames.has(name))) {\n return \"<stripped sensitive data>\"\n }\n return value\n }, 2)\n}"]} | ||
| {"version":3,"file":"httpExecutor.js","sourceRoot":"","sources":["../src/httpExecutor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,AAAO,AAAE,AAAU,AAAQ,AAAM,AAAQ;;;;AACzC,AAAO,AAAM,AAAM,AAAO;;;;AAE1B,AAAO,AAAE,AAAiB,AAAE,AAAM,AAAY;;;;;;AAG9C,AAAO,AAAE,AAAS,AAAE,AAAM,AAAQ;;;;;;AAClC,AAAO,AAAE,AAAK,AAAI,AAAQ,AAAE,AAAM,AAAK;;;;;;AACvC,AAAO,AAAE,AAAiB,AAAE,AAAM,AAAqB;;;;;;AACvD,AAAO,AAAE,AAAyB,AAAgB,AAAM,AAA6B;;;;;;AAErF,MAAM,AAAK,QAAG,AAAM,qBAAC,AAAkB,AAAC,AA0BxC,AAAM;MAAiB,kBAAQ,AAAK;AAClC,gBAAqB,AAAwI;YAAS,kFAA0B,AAAI;;AAClM,AAAK,cAAC,AAAQ,SAAC,AAAU,aAAG,AAAG,MAAG,AAAQ,SAAC,AAAa,AAAG,iBAAC,AAAW,eAAI,AAAI,OAAG,AAAE,AAAG,KAAC,AAAI,OAAG,AAAI,KAAC,AAAS,UAAC,AAAW,aAAE,AAAI,MAAE,AAAI,AAAC,AAAC,AAAC,SAAG,AAAa,gBAAG,AAAI,KAAC,AAAS,UAAC,AAAQ,SAAC,AAAO,SA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C,AACP;AAAC","sourcesContent":["import { createHash, Hash } from \"crypto\"\nimport _debug from \"debug\"\nimport { EventEmitter } from \"events\"\nimport { createWriteStream } from \"fs-extra-p\"\nimport { IncomingMessage, OutgoingHttpHeaders, RequestOptions } from \"http\"\nimport { Socket } from \"net\"\nimport { Transform } from \"stream\"\nimport { parse as parseUrl } from \"url\"\nimport { CancellationToken } from \"./CancellationToken\"\nimport { ProgressCallbackTransform, ProgressInfo } from \"./ProgressCallbackTransform\"\n\nconst debug = _debug(\"electron-builder\")\n\nexport interface RequestHeaders extends OutgoingHttpHeaders {\n [key: string]: string\n}\n\nexport interface Response extends EventEmitter {\n statusCode?: number\n statusMessage?: string\n\n headers: any\n\n setEncoding(encoding: string): void\n}\n\nexport interface DownloadOptions {\n readonly headers?: OutgoingHttpHeaders | null\n readonly skipDirCreation?: boolean\n readonly sha2?: string | null\n readonly sha512?: string | null\n\n readonly cancellationToken: CancellationToken\n\n onProgress?(progress: ProgressInfo): void\n}\n\nexport class HttpError extends Error {\n constructor(readonly response: {statusMessage?: string | undefined, statusCode?: number | undefined, headers?: { [key: string]: Array<string>; } | undefined}, public description: any | null = null) {\n super(response.statusCode + \" \" + response.statusMessage + (description == null ? \"\" : (\"\\n\" + JSON.stringify(description, null, \" \"))) + \"\\nHeaders: \" + JSON.stringify(response.headers, null, \" \"))\n\n this.name = \"HttpError\"\n }\n}\n\nexport function parseJson(result: Promise<string | null>) {\n return result.then(it => it == null || it.length === 0 ? null : JSON.parse(it))\n}\n\nexport abstract class HttpExecutor<REQUEST> {\n protected readonly maxRedirects = 10\n\n request(options: RequestOptions, cancellationToken: CancellationToken = new CancellationToken(), data?: { [name: string]: any; } | null): Promise<string | null> {\n configureRequestOptions(options)\n const encodedData = data == null ? undefined : Buffer.from(JSON.stringify(data))\n if (encodedData != null) {\n options.method = \"post\"\n options.headers![\"Content-Type\"] = \"application/json\"\n options.headers![\"Content-Length\"] = encodedData.length\n }\n return this.doApiRequest(options, cancellationToken, it => (it as any).end(encodedData))\n }\n\n doApiRequest(options: RequestOptions, cancellationToken: CancellationToken, requestProcessor: (request: REQUEST, reject: (error: Error) => void) => void, redirectCount: number = 0): Promise<string> {\n if (debug.enabled) {\n debug(`Request: ${safeStringifyJson(options)}`)\n }\n\n return cancellationToken.createPromise<string>((resolve, reject, onCancel) => {\n const request = this.doRequest(options, (response: any) => {\n try {\n this.handleResponse(response, options, cancellationToken, resolve, reject, redirectCount, requestProcessor)\n }\n catch (e) {\n reject(e)\n }\n })\n this.addErrorAndTimeoutHandlers(request, reject)\n requestProcessor(request, reject)\n onCancel(() => request.abort())\n })\n }\n\n addErrorAndTimeoutHandlers(request: any, reject: (error?: Error | null) => void) {\n this.addTimeOutHandler(request, reject)\n request.on(\"error\", reject)\n request.on(\"aborted\", () => {\n reject(new Error(\"Request has been aborted by the server\"))\n })\n }\n\n protected handleResponse(response: Response, options: RequestOptions, cancellationToken: CancellationToken, resolve: (data?: any) => void, reject: (error: Error) => void, redirectCount: number, requestProcessor: (request: REQUEST, reject: (error: Error) => void) => void) {\n if (debug.enabled) {\n debug(`Response: ${response.statusCode} ${response.statusMessage}, request options: ${safeStringifyJson(options)}`)\n }\n\n // we handle any other >= 400 error on request end (read detailed message in the response body)\n if (response.statusCode === 404) {\n // error is clear, we don't need to read detailed error description\n reject(new HttpError(response, `method: ${options.method} url: ${options.protocol || \"https:\"}//${options.hostname}${options.path}\n\nPlease double check that your authentication token is correct. Due to security reasons actual status maybe not reported, but 404.\n`))\n return\n }\n else if (response.statusCode === 204) {\n // on DELETE request\n resolve()\n return\n }\n\n const redirectUrl = safeGetHeader(response, \"location\")\n if (redirectUrl != null) {\n if (redirectCount > 10) {\n reject(new Error(\"Too many redirects (> 10)\"))\n return\n }\n\n this.doApiRequest(configureRequestOptionsFromUrl(redirectUrl, {...options}), cancellationToken, requestProcessor, redirectCount)\n .then(resolve)\n .catch(reject)\n return\n }\n\n let data = \"\"\n response.setEncoding(\"utf8\")\n response.on(\"data\", (chunk: string) => {\n data += chunk\n })\n\n response.on(\"end\", () => {\n try {\n if (response.statusCode != null && response.statusCode >= 400) {\n const contentType = safeGetHeader(response, \"content-type\")\n const isJson = contentType != null && (Array.isArray(contentType) ? contentType.find(it => it.includes(\"json\")) != null : contentType.includes(\"json\"))\n reject(new HttpError(response, isJson ? JSON.parse(data) : data))\n }\n else {\n resolve(data.length === 0 ? null : data)\n }\n }\n catch (e) {\n reject(e)\n }\n })\n }\n\n abstract doRequest(options: any, callback: (response: any) => void): any\n\n protected doDownload(requestOptions: any, destination: string, redirectCount: number, options: DownloadOptions, callback: (error: Error | null) => void, onCancel: (callback: () => void) => void) {\n const request = this.doRequest(requestOptions, (response: IncomingMessage) => {\n if (response.statusCode! >= 400) {\n callback(new Error(`Cannot download \"${requestOptions.protocol || \"https:\"}//${requestOptions.hostname}${requestOptions.path}\", status ${response.statusCode}: ${response.statusMessage}`))\n return\n }\n\n const redirectUrl = safeGetHeader(response, \"location\")\n if (redirectUrl != null) {\n if (redirectCount < this.maxRedirects) {\n this.doDownload(configureRequestOptionsFromUrl(redirectUrl, {...requestOptions}), destination, redirectCount++, options, callback, onCancel)\n }\n else {\n callback(new Error(`Too many redirects (> ${this.maxRedirects})`))\n }\n return\n }\n\n configurePipes(options, response, destination, callback, options.cancellationToken)\n })\n this.addErrorAndTimeoutHandlers(request, callback)\n onCancel(() => request.abort())\n request.end()\n }\n\n protected addTimeOutHandler(request: any, callback: (error: Error) => void) {\n request.on(\"socket\", (socket: Socket) => {\n socket.setTimeout(60 * 1000, () => {\n callback(new Error(\"Request timed out\"))\n request.abort()\n })\n })\n }\n}\n\nexport function configureRequestOptionsFromUrl(url: string, options: RequestOptions) {\n const parsedUrl = parseUrl(url)\n options.protocol = parsedUrl.protocol\n options.hostname = parsedUrl.hostname\n if (parsedUrl.port == null) {\n if (options.port != null) {\n delete options.port\n }\n }\n else {\n options.port = parsedUrl.port\n }\n options.path = parsedUrl.path\n return configureRequestOptions(options)\n}\n\nexport class DigestTransform extends Transform {\n private readonly digester: Hash\n\n private _actual: string\n\n get actual() {\n return this._actual\n }\n\n isValidateOnEnd: boolean = true\n\n constructor(readonly expected: string, private readonly algorithm: string = \"sha512\", private readonly encoding: \"hex\" | \"base64\" | \"latin1\" = \"base64\") {\n super()\n\n this.digester = createHash(algorithm)\n }\n\n _transform(chunk: any, encoding: string, callback: any) {\n this.digester.update(chunk)\n callback(null, chunk)\n }\n\n _flush(callback: any): void {\n this._actual = this.digester.digest(this.encoding)\n\n if (this.isValidateOnEnd) {\n try {\n this.validate()\n }\n catch (e) {\n callback(e)\n return\n }\n }\n\n callback(null)\n }\n\n validate() {\n if (this._actual == null) {\n throw new Error(\"Not finished yet\")\n }\n\n if (this._actual !== this.expected) {\n throw new Error(`${this.algorithm} checksum mismatch, expected ${this.expected}, got ${this._actual}`)\n }\n\n return null\n }\n}\n\nfunction checkSha2(sha2Header: string | null | undefined, sha2: string | null | undefined, callback: (error: Error | null) => void): boolean {\n if (sha2Header != null && sha2 != null) {\n // todo why bintray doesn't send this header always\n if (sha2Header == null) {\n callback(new Error(\"checksum is required, but server response doesn't contain X-Checksum-Sha2 header\"))\n return false\n }\n else if (sha2Header !== sha2) {\n callback(new Error(`checksum mismatch: expected ${sha2} but got ${sha2Header} (X-Checksum-Sha2 header)`))\n return false\n }\n }\n return true\n}\n\nexport function safeGetHeader(response: any, headerKey: string) {\n const value = response.headers[headerKey]\n if (value == null) {\n return null\n }\n else if (Array.isArray(value)) {\n // electron API\n return value.length === 0 ? null : value[value.length - 1]\n }\n else {\n return value\n }\n}\n\nfunction configurePipes(options: DownloadOptions, response: any, destination: string, callback: (error: Error | null) => void, cancellationToken: CancellationToken) {\n if (!checkSha2(safeGetHeader(response, \"X-Checksum-Sha2\"), options.sha2, callback)) {\n return\n }\n\n const streams: Array<any> = []\n if (options.onProgress != null) {\n const contentLength = safeGetHeader(response, \"content-length\")\n if (contentLength != null) {\n streams.push(new ProgressCallbackTransform(parseInt(contentLength, 10), options.cancellationToken, options.onProgress))\n }\n }\n\n const sha512 = options.sha512\n if (sha512 != null) {\n streams.push(new DigestTransform(sha512, \"sha512\", sha512.length === 128 && !sha512.includes(\"+\") && !sha512.includes(\"Z\") && !sha512.includes(\"=\") ? \"hex\" : \"base64\"))\n }\n else if (options.sha2 != null) {\n streams.push(new DigestTransform(options.sha2, \"sha256\", \"hex\"))\n }\n\n const fileOut = createWriteStream(destination)\n streams.push(fileOut)\n\n let lastStream = response\n for (const stream of streams) {\n stream.on(\"error\", (error: Error) => {\n if (!cancellationToken.cancelled) {\n callback(error)\n }\n })\n lastStream = lastStream.pipe(stream)\n }\n\n fileOut.on(\"finish\", () => {\n (fileOut.close as any)(callback)\n })\n}\n\nexport function configureRequestOptions(options: RequestOptions, token?: string | null, method?: \"GET\" | \"DELETE\" | \"PUT\"): RequestOptions {\n if (method != null) {\n options.method = method\n }\n\n let headers = options.headers\n if (headers == null) {\n headers = {}\n options.headers = headers\n }\n if (token != null) {\n (headers as any).authorization = token.startsWith(\"Basic\") ? token : `token ${token}`\n }\n if (headers[\"User-Agent\"] == null) {\n headers[\"User-Agent\"] = \"electron-builder\"\n }\n\n if ((method == null || method === \"GET\") || headers[\"Cache-Control\"] == null) {\n headers[\"Cache-Control\"] = \"no-cache\"\n }\n\n // do not specify for node (in any case we use https module)\n if (options.protocol == null && (process.versions as any).electron != null) {\n options.protocol = \"https:\"\n }\n return options\n}\n\nexport function safeStringifyJson(data: any, skippedNames?: Set<string>) {\n return JSON.stringify(data, (name, value) => {\n if (name.endsWith(\"authorization\") || name.endsWith(\"Password\") || name.endsWith(\"PASSWORD\") || name.endsWith(\"Token\") || name.includes(\"password\") || name.includes(\"token\") || (skippedNames != null && skippedNames.has(name))) {\n return \"<stripped sensitive data>\"\n }\n return value\n }, 2)\n}"]} |
@@ -11,2 +11,5 @@ export interface VersionInfo { | ||
| sha512: string; | ||
| headerSize?: number; | ||
| blockMapSize?: number; | ||
| blockMapData?: string; | ||
| } | ||
@@ -13,0 +16,0 @@ export interface UpdateInfo extends VersionInfo { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"updateInfo.js","sourceRoot":"","sources":["../src/updateInfo.ts"],"names":[],"mappings":"","sourcesContent":["export interface VersionInfo {\n /**\n * The version.\n */\n readonly version: string\n}\n\nexport interface PackageFileInfo {\n file: string\n size: number\n sha512: string\n}\n\nexport interface UpdateInfo extends VersionInfo {\n readonly path: string\n\n packages?: { [arch: string]: PackageFileInfo } | null\n\n githubArtifactName?: string | null\n\n /**\n * The release name.\n */\n readonly releaseName?: string | null\n\n /**\n * The release notes.\n */\n readonly releaseNotes?: string | null\n\n /**\n * The release date.\n */\n readonly releaseDate: string\n\n /**\n * @deprecated\n * @private\n */\n readonly sha2?: string\n\n readonly sha512?: string\n\n /**\n * The [staged rollout](auto-update.md#staged-rollouts) percentage, 0-100.\n */\n readonly stagingPercentage?: number\n}"]} | ||
| {"version":3,"file":"updateInfo.js","sourceRoot":"","sources":["../src/updateInfo.ts"],"names":[],"mappings":"","sourcesContent":["export interface VersionInfo {\n /**\n * The version.\n */\n readonly version: string\n}\n\nexport interface PackageFileInfo {\n file: string\n size: number\n sha512: string\n\n headerSize?: number\n blockMapSize?: number\n\n // we cannot pack blockMap file as part of package file because of chicken and egg problem — we build blockMap for package file (and we don't to complicate)\n // used and not null only during build time\n blockMapData?: string\n}\n\nexport interface UpdateInfo extends VersionInfo {\n readonly path: string\n\n packages?: { [arch: string]: PackageFileInfo } | null\n\n githubArtifactName?: string | null\n\n /**\n * The release name.\n */\n readonly releaseName?: string | null\n\n /**\n * The release notes.\n */\n readonly releaseNotes?: string | null\n\n /**\n * The release date.\n */\n readonly releaseDate: string\n\n /**\n * @deprecated\n * @private\n */\n readonly sha2?: string\n\n readonly sha512?: string\n\n /**\n * The [staged rollout](auto-update.md#staged-rollouts) percentage, 0-100.\n */\n readonly stagingPercentage?: number\n}"]} |
+1
-1
| { | ||
| "name": "builder-util-runtime", | ||
| "version": "0.0.0-semantic-release", | ||
| "version": "1.0.0", | ||
| "main": "out/index.js", | ||
@@ -5,0 +5,0 @@ "author": "Vladimir Krivosheev", |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
High entropy strings
Supply chain riskContains high entropy strings. This could be a sign of encrypted data, leaked secrets or obfuscated code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
High entropy strings
Supply chain riskContains high entropy strings. This could be a sign of encrypted data, leaked secrets or obfuscated code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
160753
1.55%1763
1.91%0
-100%