electron-updater 4.3.4 → 4.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/AppImageUpdater.js +25 -3
- package/out/AppImageUpdater.js.map +1 -1
- package/out/AppUpdater.d.ts +0 -2
- package/out/AppUpdater.js +5 -7
- package/out/AppUpdater.js.map +1 -1
- package/out/DownloadedUpdateHelper.js +1 -2
- package/out/DownloadedUpdateHelper.js.map +1 -1
- package/out/MacUpdater.d.ts +1 -1
- package/out/MacUpdater.js +29 -10
- package/out/MacUpdater.js.map +1 -1
- package/out/NsisUpdater.js +23 -17
- package/out/NsisUpdater.js.map +1 -1
- package/out/differentialDownloader/DifferentialDownloader.d.ts +3 -0
- package/out/differentialDownloader/DifferentialDownloader.js +50 -2
- package/out/differentialDownloader/DifferentialDownloader.js.map +1 -1
- package/out/differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader.js +1 -1
- package/out/differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader.js.map +1 -1
- package/out/differentialDownloader/ProgressDifferentialDownloadCallbackTransform.d.ts +32 -0
- package/out/differentialDownloader/ProgressDifferentialDownloadCallbackTransform.js +118 -0
- package/out/differentialDownloader/ProgressDifferentialDownloadCallbackTransform.js.map +1 -0
- package/out/differentialDownloader/downloadPlanBuilder.js +2 -3
- package/out/differentialDownloader/downloadPlanBuilder.js.map +1 -1
- package/out/differentialDownloader/multipleRangeDownloader.js +6 -0
- package/out/differentialDownloader/multipleRangeDownloader.js.map +1 -1
- package/out/main.d.ts +0 -1
- package/out/main.js +0 -16
- package/out/main.js.map +1 -1
- package/out/providers/BintrayProvider.js +1 -1
- package/out/providers/BintrayProvider.js.map +1 -1
- package/out/providers/GenericProvider.js +1 -1
- package/out/providers/GenericProvider.js.map +1 -1
- package/out/providers/PrivateGitHubProvider.js +2 -2
- package/out/providers/PrivateGitHubProvider.js.map +1 -1
- package/out/providers/Provider.js +1 -1
- package/out/providers/Provider.js.map +1 -1
- package/out/windowsExecutableCodeSignatureVerifier.d.ts +1 -1
- package/out/windowsExecutableCodeSignatureVerifier.js +22 -2
- package/out/windowsExecutableCodeSignatureVerifier.js.map +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/differentialDownloader/downloadPlanBuilder.ts"],"names":[],"mappings":";;;;;;;AAGA,IAAY,aAAZ;;;AAAA,CAAA,UAAY,aAAZ,EAAyB;AACvB,EAAA,aAAA,CAAA,aAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAA;AAAM,EAAA,aAAA,CAAA,aAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAAA,GAAA,UAAA;AACP,CAFD,EAAY,aAAa,6BAAb,aAAa,GAAA,EAAA,CAAzB;;AAgBM,SAAU,iBAAV,CAA4B,WAA5B,EAAmD,WAAnD,EAA0E,MAA1E,EAAwF;AAC5F,QAAM,eAAe,GAAG,iBAAiB,CAAC,WAAW,CAAC,KAAb,CAAzC;AACA,QAAM,eAAe,GAAG,iBAAiB,CAAC,WAAW,CAAC,KAAb,CAAzC;AAEA,MAAI,aAAa,GAAqB,IAAtC,CAJ4F,CAM5F;;AACA,QAAM,YAAY,GAAG,WAAW,CAAC,KAAZ,CAAkB,CAAlB,CAArB;AACA,QAAM,UAAU,GAAqB,EAArC;AACA,QAAM,IAAI,GAAG,YAAY,CAAC,IAA1B;AACA,QAAM,QAAQ,GAAG,eAAe,CAAC,GAAhB,CAAoB,IAApB,CAAjB;;AACA,MAAI,QAAQ,IAAI,IAAhB,EAAsB;AACpB;AACA,UAAM,IAAI,KAAJ,CAAU,WAAW,IAAI,kBAAzB,CAAN;AACD;;AAED,QAAM,OAAO,GAAG,eAAe,CAAC,GAAhB,CAAoB,IAApB,CAAhB;AACA,MAAI,iBAAiB,GAAG,CAAxB;AAEA,QAAM;AAAC,IAAA,gBAAgB,EAAE,mBAAnB;AAAwC,IAAA;AAAxC,MAA6D,gB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qB,QAArB,EAA+B,MAA/B;AACA,MAAA,cAAc,CAAC,GAAf,CAAmB,QAAnB,EAA6B,IAA7B;AACD,KAHD,MAIK,IAAI,QAAQ,IAAI,IAAhB,EAAsB;AACzB,YAAM,eAAe,GAAG,QAAQ,KAAK,IAAb,GAAoB,aAApB,GAAoC,UAAU,QAAQ,gBAAgB,IAAI,GAAlG;AACA,MAAA,QAAQ,CAAC,GAAG,QAAQ,2BAA2B,eAAe,gGAAtD,CAAR;AACD;;AACD,IAAA,MAAM,IAAI,IAAV;AACD;;AACD,SAAO;AAAC,IAAA,gBAAD;AAAmB,IAAA,iBAAiB,EAAE;AAAtC,GAAP;AACD;;AAED,SAAS,iBAAT,CAA2B,IAA3B,EAAoD;AAClD,QAAM,MAAM,GAAG,IAAI,GAAJ,EAAf;;AACA,OAAK,MAAM,IAAX,IAAmB,IAAnB,EAAyB;AACvB,IAAA,MAAM,CAAC,GAAP,CAAW,IAAI,CAAC,IAAhB,EAAsB,IAAtB;AACD;;AACD,SAAO,MAAP;AACD,C","sourcesContent":["import { BlockMap, BlockMapFile } from \"builder-util-runtime/out/blockMapApi\"\nimport { Logger } from \"../main\"\n\nexport enum OperationKind {\n COPY, DOWNLOAD\n}\n\nexport interface Operation {\n kind: OperationKind\n\n // inclusive\n start: number\n // exclusive\n end: number\n\n // debug only\n // oldBlocks: Array<string> | null\n}\n\nexport function computeOperations(oldBlockMap: BlockMap, newBlockMap: BlockMap, logger: Logger): Array<Operation> {\n const nameToOldBlocks = buildBlockFileMap(oldBlockMap.files)\n const nameToNewBlocks = buildBlockFileMap(newBlockMap.files)\n\n let lastOperation: Operation | null = null\n\n // for now only one file is supported in block map\n const blockMapFile = newBlockMap.files[0]\n const operations: Array<Operation> = []\n const name = blockMapFile.name\n const oldEntry = nameToOldBlocks.get(name)\n if (oldEntry == null) {\n // new file (unrealistic case for now, because in any case both blockmap contain the only file named as \"file\")\n throw new Error(`no file ${name} in old blockmap`)\n }\n\n const newFile = nameToNewBlocks.get(name)!!\n let changedBlockCount = 0\n\n const {checksumToOffset: checksumToOldOffset, checksumToOldSize} = buildChecksumMap(nameToOldBlocks.get(name)!!, oldEntry.offset, logger)\n\n let newOffset = blockMapFile.offset\n for (let i = 0; i < newFile.checksums.length; newOffset += newFile.sizes[i], i++) {\n const blockSize = newFile.sizes[i]\n const checksum = newFile.checksums[i]\n let oldOffset = checksumToOldOffset.get(checksum)\n if (oldOffset != null && checksumToOldSize.get(checksum) !== blockSize) {\n logger.warn(`Checksum (\"${checksum}\") matches, but size differs (old: ${checksumToOldSize.get(checksum)}, new: ${blockSize})`)\n oldOffset = undefined\n }\n\n if (oldOffset === undefined) {\n // download data from new file\n changedBlockCount++\n\n if (lastOperation != null && lastOperation.kind === OperationKind.DOWNLOAD && lastOperation.end === newOffset) {\n lastOperation.end += blockSize\n }\n else {\n lastOperation = {\n kind: OperationKind.DOWNLOAD,\n start: newOffset,\n end: newOffset + blockSize,\n // oldBlocks: null,\n }\n validateAndAdd(lastOperation, operations, checksum, i)\n }\n }\n else {\n // reuse data from old file\n if (lastOperation != null && lastOperation.kind === OperationKind.COPY && lastOperation.end === oldOffset) {\n lastOperation.end += blockSize\n // lastOperation.oldBlocks!!.push(checksum)\n }\n else {\n lastOperation = {\n kind: OperationKind.COPY,\n start: oldOffset,\n end: oldOffset + blockSize,\n // oldBlocks: [checksum]\n }\n validateAndAdd(lastOperation, operations, checksum, i)\n }\n }\n }\n\n if (changedBlockCount > 0) {\n logger.info(`File${blockMapFile.name === \"file\" ? \"\" : (\" \" + blockMapFile.name)} has ${changedBlockCount} changed blocks`)\n }\n return operations\n}\n\nconst isValidateOperationRange = process.env.DIFFERENTIAL_DOWNLOAD_PLAN_BUILDER_VALIDATE_RANGES === \"true\"\n\nfunction validateAndAdd(operation: Operation, operations: Array<Operation>, checksum: string, index: number): void {\n if (isValidateOperationRange && operations.length !== 0) {\n const lastOperation = operations[operations.length - 1]\n if (lastOperation.kind === operation.kind && operation.start < lastOperation.end && operation.start > lastOperation.start) {\n const min = [lastOperation.start, lastOperation.end, operation.start, operation.end].reduce((p, v) => p < v ? p : v)\n throw new Error(`operation (block index: ${index}, checksum: ${checksum}, kind: ${OperationKind[operation.kind]}) overlaps previous operation (checksum: ${checksum}):\\n` +\n `abs: ${lastOperation.start} until ${lastOperation.end} and ${operation.start} until ${operation.end}\\n` +\n `rel: ${lastOperation.start - min} until ${lastOperation.end - min} and ${operation.start - min} until ${operation.end - min}`\n )\n }\n }\n operations.push(operation)\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nfunction buildChecksumMap(file: BlockMapFile, fileOffset: number, logger: Logger) {\n const checksumToOffset = new Map<string, number>()\n const checksumToSize = new Map<string, number>()\n let offset = fileOffset\n const debugLog = logger.debug\n for (let i = 0; i < file.checksums.length; i++) {\n const checksum = file.checksums[i]\n const size = file.sizes[i]\n\n const existing = checksumToSize.get(checksum)\n if (existing === undefined) {\n checksumToOffset.set(checksum, offset)\n checksumToSize.set(checksum, size)\n }\n else if (debugLog != null) {\n const sizeExplanation = existing === size ? \"(same size)\" : `(size: ${existing}, this size: ${size})`\n debugLog(`${checksum} duplicated in blockmap ${sizeExplanation}, it doesn't lead to broken differential downloader, just corresponding block will be skipped)`)\n }\n offset += size\n }\n return {checksumToOffset, checksumToOldSize: checksumToSize}\n}\n\nfunction buildBlockFileMap(list: Array<BlockMapFile>): Map<string, BlockMapFile> {\n const result = new Map<string, BlockMapFile>()\n for (const item of list) {\n result.set(item.name, item)\n }\n return result\n}\n"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"sources":["../../src/differentialDownloader/downloadPlanBuilder.ts"],"names":[],"mappings":";;;;;;;AAGA,IAAY,aAAZ;;;AAAA,CAAA,UAAY,aAAZ,EAAyB;AACvB,EAAA,aAAA,CAAA,aAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAA;AAAM,EAAA,aAAA,CAAA,aAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAAA,GAAA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AAM,GAAG,IAAI,GAAJ,EAAf;;AACA,OAAK,MAAM,IAAX,IAAmB,IAAnB,EAAyB;AACvB,IAAA,MAAM,CAAC,GAAP,CAAW,IAAI,CAAC,IAAhB,EAAsB,IAAtB;AACD;;AACD,SAAO,MAAP;AACD,C","sourcesContent":["import { BlockMap, BlockMapFile } from \"builder-util-runtime/out/blockMapApi\"\nimport { Logger } from \"../main\"\n\nexport enum OperationKind {\n COPY, DOWNLOAD\n}\n\nexport interface Operation {\n kind: OperationKind\n\n // inclusive\n start: number\n // exclusive\n end: number\n\n // debug only\n // oldBlocks: Array<string> | null\n}\n\nexport function computeOperations(oldBlockMap: BlockMap, newBlockMap: BlockMap, logger: Logger): Array<Operation> {\n const nameToOldBlocks = buildBlockFileMap(oldBlockMap.files)\n const nameToNewBlocks = buildBlockFileMap(newBlockMap.files)\n\n let lastOperation: Operation | null = null\n\n // for now only one file is supported in block map\n const blockMapFile = newBlockMap.files[0]\n const operations: Array<Operation> = []\n const name = blockMapFile.name\n const oldEntry = nameToOldBlocks.get(name)\n if (oldEntry == null) {\n // new file (unrealistic case for now, because in any case both blockmap contain the only file named as \"file\")\n throw new Error(`no file ${name} in old blockmap`)\n }\n\n const newFile = nameToNewBlocks.get(name)!!\n let changedBlockCount = 0\n\n const {checksumToOffset: checksumToOldOffset, checksumToOldSize} = buildChecksumMap(nameToOldBlocks.get(name)!!, oldEntry.offset, logger)\n\n let newOffset = blockMapFile.offset\n for (let i = 0; i < newFile.checksums.length; newOffset += newFile.sizes[i], i++) {\n const blockSize = newFile.sizes[i]\n const checksum = newFile.checksums[i]\n let oldOffset = checksumToOldOffset.get(checksum)\n if (oldOffset != null && checksumToOldSize.get(checksum) !== blockSize) {\n logger.warn(`Checksum (\"${checksum}\") matches, but size differs (old: ${checksumToOldSize.get(checksum)}, new: ${blockSize})`)\n oldOffset = undefined\n }\n\n if (oldOffset === undefined) {\n // download data from new file\n changedBlockCount++\n\n if (lastOperation != null && lastOperation.kind === OperationKind.DOWNLOAD && lastOperation.end === newOffset) {\n lastOperation.end += blockSize\n }\n else {\n lastOperation = {\n kind: OperationKind.DOWNLOAD,\n start: newOffset,\n end: newOffset + blockSize,\n // oldBlocks: null,\n }\n validateAndAdd(lastOperation, operations, checksum, i)\n }\n }\n else {\n // reuse data from old file\n if (lastOperation != null && lastOperation.kind === OperationKind.COPY && lastOperation.end === oldOffset) {\n lastOperation.end += blockSize\n // lastOperation.oldBlocks!!.push(checksum)\n }\n else {\n lastOperation = {\n kind: OperationKind.COPY,\n start: oldOffset,\n end: oldOffset + blockSize,\n // oldBlocks: [checksum]\n }\n validateAndAdd(lastOperation, operations, checksum, i)\n }\n }\n }\n\n if (changedBlockCount > 0) {\n logger.info(`File${blockMapFile.name === \"file\" ? \"\" : (\" \" + blockMapFile.name)} has ${changedBlockCount} changed blocks`)\n }\n return operations\n}\n\nconst isValidateOperationRange = process.env.DIFFERENTIAL_DOWNLOAD_PLAN_BUILDER_VALIDATE_RANGES === \"true\"\n\nfunction validateAndAdd(operation: Operation, operations: Array<Operation>, checksum: string, index: number): void {\n if (isValidateOperationRange && operations.length !== 0) {\n const lastOperation = operations[operations.length - 1]\n if (lastOperation.kind === operation.kind && operation.start < lastOperation.end && operation.start > lastOperation.start) {\n const min = [lastOperation.start, lastOperation.end, operation.start, operation.end].reduce((p, v) => p < v ? p : v)\n throw new Error(`operation (block index: ${index}, checksum: ${checksum}, kind: ${OperationKind[operation.kind]}) overlaps previous operation (checksum: ${checksum}):\\n` +\n `abs: ${lastOperation.start} until ${lastOperation.end} and ${operation.start} until ${operation.end}\\n` +\n `rel: ${lastOperation.start - min} until ${lastOperation.end - min} and ${operation.start - min} until ${operation.end - min}`\n )\n }\n }\n operations.push(operation)\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nfunction buildChecksumMap(file: BlockMapFile, fileOffset: number, logger: Logger) {\n const checksumToOffset = new Map<string, number>()\n const checksumToSize = new Map<string, number>()\n let offset = fileOffset\n for (let i = 0; i < file.checksums.length; i++) {\n const checksum = file.checksums[i]\n const size = file.sizes[i]\n\n const existing = checksumToSize.get(checksum)\n if (existing === undefined) {\n checksumToOffset.set(checksum, offset)\n checksumToSize.set(checksum, size)\n }\n else if (logger.debug != null) {\n const sizeExplanation = existing === size ? \"(same size)\" : `(size: ${existing}, this size: ${size})`\n logger.debug(`${checksum} duplicated in blockmap ${sizeExplanation}, it doesn't lead to broken differential downloader, just corresponding block will be skipped)`)\n }\n offset += size\n }\n return {checksumToOffset, checksumToOldSize: checksumToSize}\n}\n\nfunction buildBlockFileMap(list: Array<BlockMapFile>): Map<string, BlockMapFile> {\n const result = new Map<string, BlockMapFile>()\n for (const item of list) {\n result.set(item.name, item)\n }\n return result\n}\n"],"sourceRoot":""}
|
|
@@ -128,6 +128,12 @@ function doExecuteTasks(differentialDownloader, options, out, resolve, reject) {
|
|
|
128
128
|
const dicer = new (_DataSplitter().DataSplitter)(out, options, partIndexToTaskIndex, m[1] || m[2], partIndexToLength, resolve);
|
|
129
129
|
dicer.on("error", reject);
|
|
130
130
|
response.pipe(dicer);
|
|
131
|
+
response.on('end', () => {
|
|
132
|
+
setTimeout(() => {
|
|
133
|
+
request.abort();
|
|
134
|
+
reject(new Error("Response ends without calling any handlers"));
|
|
135
|
+
}, 10000);
|
|
136
|
+
});
|
|
131
137
|
});
|
|
132
138
|
differentialDownloader.httpExecutor.addErrorAndTimeoutHandlers(request, reject);
|
|
133
139
|
request.end();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/differentialDownloader/multipleRangeDownloader.ts"],"names":[],"mappings":";;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEM,SAAU,sCAAV,CAAiD,sBAAjD,EAAiG,KAAjG,EAA0H,GAA1H,EAAyI,SAAzI,EAA4J,MAA5J,EA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AAI,QAAQ,CAAC,UAAT,IAAyB,GAA7B,EAAkC;AAChC,IAAA,MAAM,CAAC,2CAAgB,QAAhB,CAAD,CAAN;AACA,WAAO,KAAP;AACD;;AAED,MAAI,QAAQ,CAAC,UAAT,KAAwB,GAA5B,EAAiC;AAC/B,UAAM,YAAY,GAAG,yCAAc,QAAd,EAAwB,eAAxB,CAArB;;AACA,QAAI,YAAY,IAAI,IAAhB,IAAwB,YAAY,KAAK,MAA7C,EAAqD;AACnD,MAAA,MAAM,CAAC,IAAI,KAAJ,CAAU,uDAAuD,QAAQ,CAAC,UAAU,GAApF,CAAD,CAAN;AACA,aAAO,KAAP;AACD;AACF;;AACD,SAAO,IAAP;AACD,C","sourcesContent":["import { createHttpError, safeGetHeader } from \"builder-util-runtime\"\nimport { IncomingMessage } from \"http\"\nimport { Writable } from \"stream\"\nimport { copyData, DataSplitter, PartListDataTask } from \"./DataSplitter\"\nimport { DifferentialDownloader } from \"./DifferentialDownloader\"\nimport { Operation, OperationKind } from \"./downloadPlanBuilder\"\n\nexport function executeTasksUsingMultipleRangeRequests(differentialDownloader: DifferentialDownloader, tasks: Array<Operation>, out: Writable, oldFileFd: number, reject: (error: Error) => void): (taskOffset: number) => void {\n const w = (taskOffset: number): void => {\n if (taskOffset >= tasks.length) {\n if (differentialDownloader.fileMetadataBuffer != null) {\n out.write(differentialDownloader.fileMetadataBuffer)\n }\n out.end()\n return\n }\n\n const nextOffset = taskOffset + 1000\n doExecuteTasks(differentialDownloader, {\n tasks,\n start: taskOffset,\n end: Math.min(tasks.length, nextOffset),\n oldFileFd,\n }, out, () => w(nextOffset), reject)\n }\n return w\n}\n\nfunction doExecuteTasks(differentialDownloader: DifferentialDownloader, options: PartListDataTask, out: Writable, resolve: () => void, reject: (error: Error) => void): void {\n let ranges = \"bytes=\"\n let partCount = 0\n const partIndexToTaskIndex = new Map<number, number>()\n const partIndexToLength: Array<number> = []\n for (let i = options.start; i < options.end; i++) {\n const task = options.tasks[i]\n if (task.kind === OperationKind.DOWNLOAD) {\n ranges += `${task.start}-${task.end - 1}, `\n partIndexToTaskIndex.set(partCount, i)\n partCount++\n partIndexToLength.push(task.end - task.start)\n }\n }\n\n if (partCount <= 1) {\n // the only remote range - copy\n const w = (index: number): void => {\n if (index >= options.end) {\n resolve()\n return\n }\n\n const task = options.tasks[index++]\n\n if (task.kind === OperationKind.COPY) {\n copyData(task, out, options.oldFileFd, reject, () => w(index))\n }\n else {\n const requestOptions = differentialDownloader.createRequestOptions()\n requestOptions.headers!!.Range = `bytes=${task.start}-${task.end - 1}`\n const request = differentialDownloader.httpExecutor.createRequest(requestOptions, response => {\n if (!checkIsRangesSupported(response, reject)) {\n return\n }\n\n response.pipe(out, {\n end: false\n })\n response.once(\"end\", () => w(index))\n })\n differentialDownloader.httpExecutor.addErrorAndTimeoutHandlers(request, reject)\n request.end()\n }\n }\n\n w(options.start)\n return\n }\n\n const requestOptions = differentialDownloader.createRequestOptions()\n requestOptions.headers!!.Range = ranges.substring(0, ranges.length - 2)\n const request = differentialDownloader.httpExecutor.createRequest(requestOptions, response => {\n if (!checkIsRangesSupported(response, reject)) {\n return\n }\n\n const contentType = safeGetHeader(response, \"content-type\")\n const m = /^multipart\\/.+?(?:; boundary=(?:(?:\"(.+)\")|(?:([^\\s]+))))$/i.exec(contentType)\n if (m == null) {\n reject(new Error(`Content-Type \"multipart/byteranges\" is expected, but got \"${contentType}\"`))\n return\n }\n\n const dicer = new DataSplitter(out, options, partIndexToTaskIndex, m[1] || m[2], partIndexToLength, resolve)\n dicer.on(\"error\", reject)\n response.pipe(dicer)\n\n response.on('end', () => {\n setTimeout(() => {\n request.abort()\n reject(new Error(\"Response ends without calling any handlers\"))\n }, 10000)\n })\n })\n differentialDownloader.httpExecutor.addErrorAndTimeoutHandlers(request, reject)\n request.end()\n}\n\nexport function checkIsRangesSupported(response: IncomingMessage, reject: (error: Error) => void): boolean {\n // Electron net handles redirects automatically, our NodeJS test server doesn't use redirects - so, we don't check 3xx codes.\n if (response.statusCode!! >= 400) {\n reject(createHttpError(response))\n return false\n }\n\n if (response.statusCode !== 206) {\n const acceptRanges = safeGetHeader(response, \"accept-ranges\")\n if (acceptRanges == null || acceptRanges === \"none\") {\n reject(new Error(`Server doesn't support Accept-Ranges (response code ${response.statusCode})`))\n return false\n }\n }\n return true\n}\n"],"sourceRoot":""}
|
package/out/main.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ import { AppUpdater } from "./AppUpdater";
|
|
|
6
6
|
import { LoginCallback } from "./electronHttpExecutor";
|
|
7
7
|
export { AppUpdater, NoOpLogger } from "./AppUpdater";
|
|
8
8
|
export { UpdateInfo };
|
|
9
|
-
export { CancellationToken } from "builder-util-runtime";
|
|
10
9
|
export { Provider } from "./providers/Provider";
|
|
11
10
|
export { AppImageUpdater } from "./AppImageUpdater";
|
|
12
11
|
export { MacUpdater } from "./MacUpdater";
|
package/out/main.js
CHANGED
|
@@ -18,12 +18,6 @@ Object.defineProperty(exports, "NoOpLogger", {
|
|
|
18
18
|
return _AppUpdater().NoOpLogger;
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
|
-
Object.defineProperty(exports, "CancellationToken", {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _builderUtilRuntime().CancellationToken;
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
21
|
Object.defineProperty(exports, "Provider", {
|
|
28
22
|
enumerable: true,
|
|
29
23
|
get: function () {
|
|
@@ -70,16 +64,6 @@ function _AppUpdater() {
|
|
|
70
64
|
return data;
|
|
71
65
|
}
|
|
72
66
|
|
|
73
|
-
function _builderUtilRuntime() {
|
|
74
|
-
const data = require("builder-util-runtime");
|
|
75
|
-
|
|
76
|
-
_builderUtilRuntime = function () {
|
|
77
|
-
return data;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
return data;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
67
|
function _Provider() {
|
|
84
68
|
const data = require("./providers/Provider");
|
|
85
69
|
|
package/out/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/main.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/main.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AACA,IAAI,YAAJ;;AAKA,SAAS,iBAAT,GAA0B;AACxB;AACA,MAAI,OAAO,CAAC,QAAR,KAAqB,OAAzB,EAAkC;AAChC,IAAA,YAAY,GAAG,KAAK,OAAO,CAAC,eAAD,CAAP,CAAyB,WAA9B,GAAf;AACD,GAFD,MAGK,IAAI,OAAO,CAAC,QAAR,KAAqB,QAAzB,EAAmC;AACtC,IAAA,YAAY,GAAG,KAAK,OAAO,CAAC,cAAD,CAAP,CAAwB,UAA7B,GAAf;AACD,GAFI,MAGA;AACH,IAAA,YAAY,GAAG,KAAK,OAAO,CAAC,mBAAD,CAAP,CAA6B,eAAlC,GAAf;AACD;;AACD,SAAO,YAAP;AACD;;AAED,MAAM,CAAC,cAAP,CAAsB,OAAtB,EAA+B,aAA/B,EAA8C;AAC5C,EAAA,UAAU,EAAE,IADgC;AAE5C,EAAA,GAAG,EAAE,MAAK;AACR,WAAO,YAAY,IAAI,iBAAiB,EAAxC;AACD;AAJ2C,CAA9C;;AAcM,SAAU,kBAAV,CAA6B,OAA7B,EAA4C;AAChD,SAAO,GAAG,OAAO,MAAjB;AACD;;AAeM,MAAM,iBAAiB,GAAkB,mBAAzC;;AACA,MAAM,iBAAiB,GAAkB,mBA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AAO,MAAP;AACD,C,CAED;AACA;;;AACM,SAAU,cAAV,CAAyB,QAAzB,EAA2C,OAA3C,EAAyD,4BAA4B,GAAG,KAAxF,EAA6F;AACjG,QAAM,MAAM,GAAG,KAAI,UAAJ,EAAQ,QAAR,EAAkB,OAAlB,CAAf,CADiG,CAEjG;;AACA,QAAM,MAAM,GAAG,OAAO,CAAC,MAAvB;;AACA,MAAI,MAAM,IAAI,IAAV,IAAkB,MAAM,CAAC,MAAP,KAAkB,CAAxC,EAA2C;AACzC,IAAA,MAAM,CAAC,MAAP,GAAgB,MAAhB;AACD,GAFD,MAGK,IAAI,4BAAJ,EAAkC;AACrC,IAAA,MAAM,CAAC,MAAP,GAAgB,WAAW,IAAI,CAAC,GAAL,GAAW,QAAX,CAAoB,EAApB,CAAuB,EAAlD;AACD;;AACD,SAAO,MAAP;AACD,C","sourcesContent":["import { CancellationToken, PackageFileInfo, ProgressInfo, UpdateFileInfo, UpdateInfo } from \"builder-util-runtime\"\nimport { EventEmitter } from \"events\"\nimport { URL } from \"url\"\nimport { AppUpdater } from \"./AppUpdater\"\nimport { LoginCallback } from \"./electronHttpExecutor\"\n\nexport { AppUpdater, NoOpLogger } from \"./AppUpdater\"\nexport { UpdateInfo }\nexport { Provider } from \"./providers/Provider\"\nexport { AppImageUpdater } from \"./AppImageUpdater\"\nexport { MacUpdater } from \"./MacUpdater\"\nexport { NsisUpdater } from \"./NsisUpdater\"\n\n// autoUpdater to mimic electron bundled autoUpdater\nlet _autoUpdater: any\n\n// required for jsdoc\nexport declare const autoUpdater: AppUpdater\n\nfunction doLoadAutoUpdater(): AppUpdater {\n // tslint:disable:prefer-conditional-expression\n if (process.platform === \"win32\") {\n _autoUpdater = new (require(\"./NsisUpdater\").NsisUpdater)()\n }\n else if (process.platform === \"darwin\") {\n _autoUpdater = new (require(\"./MacUpdater\").MacUpdater)()\n }\n else {\n _autoUpdater = new (require(\"./AppImageUpdater\").AppImageUpdater)()\n }\n return _autoUpdater\n}\n\nObject.defineProperty(exports, \"autoUpdater\", {\n enumerable: true,\n get: () => {\n return _autoUpdater || doLoadAutoUpdater()\n }\n})\n\nexport interface ResolvedUpdateFileInfo {\n readonly url: URL\n readonly info: UpdateFileInfo\n\n packageInfo?: PackageFileInfo\n}\n\nexport function getChannelFilename(channel: string): string {\n return `${channel}.yml`\n}\n\nexport interface UpdateCheckResult {\n readonly updateInfo: UpdateInfo\n\n readonly downloadPromise?: Promise<Array<string>> | null\n\n readonly cancellationToken?: CancellationToken\n\n /** @deprecated */\n readonly versionInfo: UpdateInfo\n}\n\nexport type UpdaterEvents = \"login\" | \"checking-for-update\" | \"update-available\" | \"update-cancelled\" | \"download-progress\" | \"update-downloaded\" | \"error\"\n\nexport const DOWNLOAD_PROGRESS: UpdaterEvents = \"download-progress\"\nexport const UPDATE_DOWNLOADED: UpdaterEvents = \"update-downloaded\"\n\nexport type LoginHandler = (authInfo: any, callback: LoginCallback) => void\n\nexport class UpdaterSignal {\n constructor(private emitter: EventEmitter) {\n }\n\n /**\n * Emitted when an authenticating proxy is [asking for user credentials](https://github.com/electron/electron/blob/master/docs/api/client-request.md#event-login).\n */\n login(handler: LoginHandler): void {\n addHandler(this.emitter, \"login\", handler)\n }\n\n progress(handler: (info: ProgressInfo) => void): void {\n addHandler(this.emitter, DOWNLOAD_PROGRESS, handler)\n }\n\n updateDownloaded(handler: (info: UpdateDownloadedEvent) => void): void {\n addHandler(this.emitter, UPDATE_DOWNLOADED, handler)\n }\n\n updateCancelled(handler: (info: UpdateInfo) => void): void {\n addHandler(this.emitter, \"update-cancelled\", handler)\n }\n}\n\nexport interface UpdateDownloadedEvent extends UpdateInfo {\n downloadedFile: string\n}\n\nconst isLogEvent = false\n\nfunction addHandler(emitter: EventEmitter, event: UpdaterEvents, handler: (...args: Array<any>) => void): void {\n if (isLogEvent) {\n emitter.on(event, (...args: Array<any>) => {\n console.log(\"%s %s\", event, args)\n handler(...args)\n })\n }\n else {\n emitter.on(event, handler)\n }\n}\n\nexport interface Logger {\n info(message?: any): void\n\n warn(message?: any): void\n\n error(message?: any): void\n\n debug?(message: string): void\n}\n\n// if baseUrl path doesn't ends with /, this path will be not prepended to passed pathname for new URL(input, base)\n/** @internal */\nexport function newBaseUrl(url: string): URL {\n const result = new URL(url)\n if (!result.pathname.endsWith(\"/\")) {\n result.pathname += \"/\"\n }\n return result\n}\n\n// addRandomQueryToAvoidCaching is false by default because in most cases URL already contains version number,\n// so, it makes sense only for Generic Provider for channel files\nexport function newUrlFromBase(pathname: string, baseUrl: URL, addRandomQueryToAvoidCaching = false): URL {\n const result = new URL(pathname, baseUrl)\n // search is not propagated (search is an empty string if not specified)\n const search = baseUrl.search\n if (search != null && search.length !== 0) {\n result.search = search\n }\n else if (addRandomQueryToAvoidCaching) {\n result.search = `noCache=${Date.now().toString(32)}`\n }\n return result\n}\n"],"sourceRoot":""}
|
|
@@ -80,7 +80,7 @@ class BintrayProvider extends _main().Provider {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
const channelFileUrl = new (_url().URL)(`https://dl.bintray.com/${this.client.owner}/${this.client.repo}/${channelFile.name}`);
|
|
83
|
-
return (0, _Provider().parseUpdateInfo)(
|
|
83
|
+
return (0, _Provider().parseUpdateInfo)(await this.httpRequest(channelFileUrl), channelFilename, channelFileUrl);
|
|
84
84
|
} catch (e) {
|
|
85
85
|
if ("statusCode" in e && e.statusCode === 404) {
|
|
86
86
|
throw (0, _builderUtilRuntime().newError)(`No latest version, please ensure that user, package and repository correctly configured. Or at least one version is published. ${e.stack || e.message}`, "ERR_UPDATER_LATEST_VERSION_NOT_FOUND");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/providers/BintrayProvider.ts"],"names":[],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAA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,EAAE,IAAI,EAAE,CAAC,IAAH,CAAQ,QAAR,CAAiB,IAAI,eAAe,EAApC,KAA2C,EAAE,CAAC,IAAH,CAAQ,QAAR,CAAiB,IAAI,eAAe,EAApC,CAA5D,CAApB;;AACA,UAAI,WAAW,IAAI,IAAnB,EAAyB;AACvB;AACA,cAAM,oCAAS,6BAA6B,eAAe,uBAAuB,KAAK,CAAC,GAAN,CAAU,EAAE,IAAI,IAAI,CAAC,SAAL,CAAe,EAAf,EAAmB,IAAnB,EAAyB,CAAzB,CAAhB,EAA6C,IAA7C,CAAkD,KAAlD,CAAwD,EAApI,EAAwI,oCAAxI,CAAN;AACD;;AAED,YAAM,cAAc,GAAG,KAAI,UAAJ,EAAQ,0BAA0B,KAAK,MAAL,CAAY,KAAK,IAAI,KAAK,MAAL,CAAY,IAAI,IAAI,WAAW,CAAC,IAAI,EAA3F,CAAvB;AACA,aAAO,iCAAgB,MAAM,KAAK,WAAL,CAAiB,cAAjB,CAAtB,EAAwD,eAAxD,EAAyE,cAAzE,CAAP;AACD,KAZD,CAaA,OAAO,CAAP,EAAU;AACR,UAAI,gBAAgB,CAAhB,IAAqB,CAAC,CAAC,UAAF,KAAiB,GAA1C,EAA+C;AAC7C,cAAM,oCAAS,kIAAkI,CAAC,CAAC,KAAF,IAAW,CAAC,CAAC,OAAO,EAA/J,EAAmK,sCAAnK,CAAN;AACD;;AACD,YAAM,CAAN;AACD;AACF;;AAED,EAAA,YAAY,CAAC,UAAD,EAAuB;AACjC,WAAO,8BAAa,UAAb,EAAyB,KAAK,OAA9B,CAAP;AACD;;AAxCsD,C","sourcesContent":["import { BintrayOptions, CancellationToken, newError, UpdateInfo } from \"builder-util-runtime\"\nimport { BintrayClient } from \"builder-util-runtime/out/bintray\"\nimport { URL } from \"url\"\nimport { getChannelFilename, newBaseUrl, Provider, ResolvedUpdateFileInfo } from \"../main\"\nimport { parseUpdateInfo, ProviderRuntimeOptions, resolveFiles } from \"./Provider\"\n\nexport class BintrayProvider extends Provider<UpdateInfo> {\n private client: BintrayClient\n private readonly baseUrl: URL\n\n constructor(configuration: BintrayOptions, runtimeOptions: ProviderRuntimeOptions) {\n super(runtimeOptions)\n\n this.client = new BintrayClient(configuration, runtimeOptions.executor, new CancellationToken())\n this.baseUrl = newBaseUrl(`https://dl.bintray.com/${this.client.owner}/${this.client.repo}`)\n }\n\n setRequestHeaders(value: any): void {\n super.setRequestHeaders(value)\n this.client.setRequestHeaders(value)\n }\n\n async getLatestVersion(): Promise<UpdateInfo> {\n try {\n const data = await this.client.getVersion(\"_latest\")\n const channelFilename = getChannelFilename(this.getDefaultChannelName())\n const files = await this.client.getVersionFiles(data.name)\n const channelFile = files.find(it => it.name.endsWith(`_${channelFilename}`) || it.name.endsWith(`-${channelFilename}`))\n if (channelFile == null) {\n // noinspection ExceptionCaughtLocallyJS\n throw newError(`Cannot find channel file \"${channelFilename}\", existing files:\\n${files.map(it => JSON.stringify(it, null, 2)).join(\",\\n\")}`, \"ERR_UPDATER_CHANNEL_FILE_NOT_FOUND\")\n }\n\n const channelFileUrl = new URL(`https://dl.bintray.com/${this.client.owner}/${this.client.repo}/${channelFile.name}`)\n return parseUpdateInfo(await this.httpRequest(channelFileUrl), channelFilename, channelFileUrl)\n }\n catch (e) {\n if (\"statusCode\" in e && e.statusCode === 404) {\n throw newError(`No latest version, please ensure that user, package and repository correctly configured. Or at least one version is published. ${e.stack || e.message}`, \"ERR_UPDATER_LATEST_VERSION_NOT_FOUND\")\n }\n throw e\n }\n }\n\n resolveFiles(updateInfo: UpdateInfo): Array<ResolvedUpdateFileInfo> {\n return resolveFiles(updateInfo, this.baseUrl)\n }\n}"],"sourceRoot":""}
|
|
@@ -54,7 +54,7 @@ class GenericProvider extends _main().Provider {
|
|
|
54
54
|
|
|
55
55
|
for (let attemptNumber = 0;; attemptNumber++) {
|
|
56
56
|
try {
|
|
57
|
-
return (0, _Provider().parseUpdateInfo)(
|
|
57
|
+
return (0, _Provider().parseUpdateInfo)(await this.httpRequest(channelUrl), channelFile, channelUrl);
|
|
58
58
|
} catch (e) {
|
|
59
59
|
if (e instanceof _builderUtilRuntime().HttpError && e.statusCode === 404) {
|
|
60
60
|
throw (0, _builderUtilRuntime().newError)(`Cannot find channel "${channelFile}" update info: ${e.stack || e.message}`, "ERR_UPDATER_CHANNEL_FILE_NOT_FOUND");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/providers/GenericProvider.ts"],"names":[],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEM,MAAO,eAAP,SAA+B,gBAA/B,CAAmD;AAGvD,EAAA,WAAA,CAA6B,aAA7B,EAAmF,OAAnF,EAAwG,cAAxG,EAA8I;AAC5I,UAAM,cAAN;AAD2B,SAAA,aAAA,GAAA,aAAA;AAAsD,SAAA,OAAA,GAAA,OAAA;AAFlE,SAAA,OAAA,GAAU,wBAAW,KAAK,aAAL,CAAmB,GAA9B,CAAV;AAIhB;;AAED,MAAY,OAAZ,GAAmB;AACjB,UAAM,MAAM,GAAG,KAAK,OAAL,CAAa,OAAb,IAAwB,KAAK,aAAL,CAAmB,OAA1D;AACA,WAAO,MAAM,IAAI,IAAV,GAAiB,KAAK,qBAAL,EAAjB,GAAgD,KAAK,oBAAL,CAA0B,MAA1B,CAAvD;AACD;;AAED,QAAM,gBAAN,GAAsB;AACpB,UAAM,WAAW,GAAG,gCAAmB,KAAK,OAAxB,CAApB;AACA,UAAM,UAAU,GAAG,4BAAe,WAAf,EAA4B,KAAK,OAAjC,EAA0C,KAAK,OAAL,CAAa,iBAAvD,CAAnB;;AACA,SAAK,IAAI,aAAa,GAAG,CAAzB,GAA8B,aAAa,EAA3C,EAA+C;AAC7C,UAAI;AACF,eAAO,
|
|
1
|
+
{"version":3,"sources":["../../src/providers/GenericProvider.ts"],"names":[],"m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IAAF,KAAW,cAAf,EAA+B;AAClC,cAAI,aAAa,GAAG,CAApB,EAAuB;AACrB,kBAAM,IAAI,OAAJ,CAAY,CAAC,OAAD,EAAU,MAAV,KAAoB;AACpC,kBAAI;AACF,gBAAA,UAAU,CAAC,OAAD,EAAU,OAAO,aAAjB,CAAV;AACD,eAFD,CAGA,OAAO,CAAP,EAAU;AACR,gBAAA,MAAM,CAAC,CAAD,CAAN;AACD;AACF,aAPK,CAAN;AAQA;AACD;AACF;;AACD,cAAM,CAAN;AACD;AACF;AACF;;AAED,EAAA,YAAY,CAAC,UAAD,EAAuB;AACjC,WAAO,8BAAa,UAAb,EAAyB,KAAK,OAA9B,CAAP;AACD;;AA3CsD,C","sourcesContent":["import { GenericServerOptions, HttpError, newError, UpdateInfo } from \"builder-util-runtime\"\nimport { AppUpdater } from \"../AppUpdater\"\nimport { getChannelFilename, newBaseUrl, newUrlFromBase, Provider, ResolvedUpdateFileInfo } from \"../main\"\nimport { parseUpdateInfo, ProviderRuntimeOptions, resolveFiles } from \"./Provider\"\n\nexport class GenericProvider extends Provider<UpdateInfo> {\n private readonly baseUrl = newBaseUrl(this.configuration.url)\n\n constructor(private readonly configuration: GenericServerOptions, private readonly updater: AppUpdater, runtimeOptions: ProviderRuntimeOptions) {\n super(runtimeOptions)\n }\n\n private get channel(): string {\n const result = this.updater.channel || this.configuration.channel\n return result == null ? this.getDefaultChannelName() : this.getCustomChannelName(result)\n }\n\n async getLatestVersion(): Promise<UpdateInfo> {\n const channelFile = getChannelFilename(this.channel)\n const channelUrl = newUrlFromBase(channelFile, this.baseUrl, this.updater.isAddNoCacheQuery)\n for (let attemptNumber = 0; ; attemptNumber++) {\n try {\n return parseUpdateInfo(await this.httpRequest(channelUrl), channelFile, channelUrl)\n }\n catch (e) {\n if (e instanceof HttpError && e.statusCode === 404) {\n throw newError(`Cannot find channel \"${channelFile}\" update info: ${e.stack || e.message}`, \"ERR_UPDATER_CHANNEL_FILE_NOT_FOUND\")\n }\n else if (e.code === \"ECONNREFUSED\") {\n if (attemptNumber < 3) {\n await new Promise((resolve, reject) => {\n try {\n setTimeout(resolve, 1000 * attemptNumber)\n }\n catch (e) {\n reject(e)\n }\n })\n continue\n }\n }\n throw e\n }\n }\n }\n\n resolveFiles(updateInfo: UpdateInfo): Array<ResolvedUpdateFileInfo> {\n return resolveFiles(updateInfo, this.baseUrl)\n }\n}"],"sourceRoot":""}
|
|
@@ -99,7 +99,7 @@ class PrivateGitHubProvider extends _GitHubProvider().BaseGitHubProvider {
|
|
|
99
99
|
let result;
|
|
100
100
|
|
|
101
101
|
try {
|
|
102
|
-
result = (0, _jsYaml().
|
|
102
|
+
result = (0, _jsYaml().load)(await this.httpRequest(url, this.configureHeaders("application/octet-stream"), cancellationToken));
|
|
103
103
|
} catch (e) {
|
|
104
104
|
if (e instanceof _builderUtilRuntime().HttpError && e.statusCode === 404) {
|
|
105
105
|
throw (0, _builderUtilRuntime().newError)(`Cannot find ${channelFile} in the latest release artifacts (${url}): ${e.stack || e.message}`, "ERR_UPDATER_CHANNEL_FILE_NOT_FOUND");
|
|
@@ -135,7 +135,7 @@ class PrivateGitHubProvider extends _GitHubProvider().BaseGitHubProvider {
|
|
|
135
135
|
const url = (0, _main().newUrlFromBase)(basePath, this.baseUrl);
|
|
136
136
|
|
|
137
137
|
try {
|
|
138
|
-
const version = JSON.parse(
|
|
138
|
+
const version = JSON.parse(await this.httpRequest(url, this.configureHeaders("application/vnd.github.v3+json"), cancellationToken));
|
|
139
139
|
|
|
140
140
|
if (allowPrerelease) {
|
|
141
141
|
return version.find(v => v.prerelease) || version[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/providers/PrivateGitHubProvider.ts"],"names":[],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAC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OAAO,CAAC,IAAR,CAAc,CAAD,IAAY,CAAC,CAAC,UAA3B,KAA0C,OAAO,CAAC,CAAD,CAAxD;AACD,OAFD,MAGK;AACH,eAAO,OAAP;AACD;AACF,KARD,CASA,OAAO,CAAP,EAAU;AACR,YAAM,oCAAS,4CAA4C,GAAG,iDAAiD,CAAC,CAAC,KAAF,IAAW,CAAC,CAAC,OAAO,EAA7H,EAAiI,sCAAjI,CAAN;AACD;AACF;;AAED,MAAY,QAAZ,GAAoB;AAClB,WAAO,KAAK,qBAAL,CAA2B,UAAU,KAAK,OAAL,CAAa,KAAK,IAAI,KAAK,OAAL,CAAa,IAAI,WAA5E,CAAP;AACD;;AAED,EAAA,YAAY,CAAC,UAAD,EAAoC;AAC9C,WAAO,6BAAY,UAAZ,EAAwB,GAAxB,CAA4B,EAAE,IAAG;AACtC,YAAM,IAAI,GAAG,IAAI,CAAC,KAAL,CAAW,QAAX,CAAoB,EAAE,CAAC,GAAvB,EAA4B,OAA5B,CAAoC,IAApC,EAA0C,GAA1C,CAAb;AACA,YAAM,KAAK,GAAG,UAAU,CAAC,MAAX,CAAkB,IAAlB,CAAuB,EAAE,IAAI,EAAE,IAAI,IAAN,IAAc,EAAE,CAAC,IAAH,KAAY,IAAvD,CAAd;;AACA,UAAI,KAAK,IAAI,IAAb,EAAmB;AACjB,cAAM,oCAAS,sBAAsB,IAAI,SAAS,IAAI,CAAC,SAAL,CAAe,UAAU,CAAC,MAA1B,EAAkC,IAAlC,EAAwC,CAAxC,CAA0C,EAAtF,EAA0F,6BAA1F,CAAN;AACD;;AAED,aAAO;AACL,QAAA,GAAG,EAAE,KAAI,UAAJ,EAAQ,KAAK,CAAC,GAAd,CADA;AAEL,QAAA,IAAI,EAAE;AAFD,OAAP;AAID,KAXM,CAAP;AAYD;;AAzFmF,C","sourcesContent":["import { CancellationToken, GithubOptions, HttpError, newError, UpdateInfo } from \"builder-util-runtime\"\nimport { OutgoingHttpHeaders, RequestOptions } from \"http\"\nimport { load } from \"js-yaml\"\nimport * as path from \"path\"\nimport { AppUpdater } from \"../AppUpdater\"\nimport { URL } from \"url\"\nimport { BaseGitHubProvider } from \"./GitHubProvider\"\nimport { getChannelFilename, newUrlFromBase, ResolvedUpdateFileInfo } from \"../main\"\nimport { getFileList, ProviderRuntimeOptions } from \"./Provider\"\n\nexport interface PrivateGitHubUpdateInfo extends UpdateInfo {\n assets: Array<Asset>\n}\n\nexport class PrivateGitHubProvider extends BaseGitHubProvider<PrivateGitHubUpdateInfo> {\n constructor(options: GithubOptions, private readonly updater: AppUpdater, private readonly token: string, runtimeOptions: ProviderRuntimeOptions) {\n super(options, \"api.github.com\", runtimeOptions)\n }\n\n protected createRequestOptions(url: URL, headers?: OutgoingHttpHeaders | null): RequestOptions {\n const result = super.createRequestOptions(url, headers);\n (result as any).redirect = \"manual\"\n return result\n }\n\n async getLatestVersion(): Promise<PrivateGitHubUpdateInfo> {\n const cancellationToken = new CancellationToken()\n const channelFile = getChannelFilename(this.getDefaultChannelName())\n\n const releaseInfo = await this.getLatestVersionInfo(cancellationToken)\n const asset = releaseInfo.assets.find(it => it.name === channelFile)\n if (asset == null) {\n // html_url must be always, but just to be sure\n throw newError(`Cannot find ${channelFile} in the release ${releaseInfo.html_url || releaseInfo.name}`, \"ERR_UPDATER_CHANNEL_FILE_NOT_FOUND\")\n }\n\n const url = new URL(asset.url)\n let result: any\n try {\n result = load((await this.httpRequest(url, this.configureHeaders(\"application/octet-stream\"), cancellationToken))!!)\n }\n catch (e) {\n if (e instanceof HttpError && e.statusCode === 404) {\n throw newError(`Cannot find ${channelFile} in the latest release artifacts (${url}): ${e.stack || e.message}`, \"ERR_UPDATER_CHANNEL_FILE_NOT_FOUND\")\n }\n throw e\n }\n\n (result as PrivateGitHubUpdateInfo).assets = releaseInfo.assets\n return result\n }\n\n get fileExtraDownloadHeaders(): OutgoingHttpHeaders | null {\n return this.configureHeaders(\"application/octet-stream\")\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n private configureHeaders(accept: string) {\n return {\n accept,\n authorization: `token ${this.token}`,\n }\n }\n\n private async getLatestVersionInfo(cancellationToken: CancellationToken): Promise<ReleaseInfo> {\n const allowPrerelease = this.updater.allowPrerelease\n let basePath = this.basePath\n if (!allowPrerelease) {\n basePath = `${basePath}/latest`\n }\n\n const url = newUrlFromBase(basePath, this.baseUrl)\n try {\n const version = (JSON.parse((await this.httpRequest(url, this.configureHeaders(\"application/vnd.github.v3+json\"), cancellationToken))!!))\n if (allowPrerelease) {\n return version.find((v: any) => v.prerelease) || version[0]\n }\n else {\n return version\n }\n }\n catch (e) {\n throw newError(`Unable to find latest version on GitHub (${url}), please ensure a production release exists: ${e.stack || e.message}`, \"ERR_UPDATER_LATEST_VERSION_NOT_FOUND\")\n }\n }\n\n private get basePath(): string {\n return this.computeGithubBasePath(`/repos/${this.options.owner}/${this.options.repo}/releases`)\n }\n\n resolveFiles(updateInfo: PrivateGitHubUpdateInfo): Array<ResolvedUpdateFileInfo> {\n return getFileList(updateInfo).map(it => {\n const name = path.posix.basename(it.url).replace(/ /g, \"-\")\n const asset = updateInfo.assets.find(it => it != null && it.name === name)\n if (asset == null) {\n throw newError(`Cannot find asset \"${name}\" in: ${JSON.stringify(updateInfo.assets, null, 2)}`, \"ERR_UPDATER_ASSET_NOT_FOUND\")\n }\n\n return {\n url: new URL(asset.url),\n info: it,\n }\n })\n }\n}\n\ninterface ReleaseInfo {\n name: string\n html_url: string\n assets: Array<Asset>\n}\n\nexport interface Asset {\n name: string\n url: string\n}"],"sourceRoot":""}
|
|
@@ -130,7 +130,7 @@ function parseUpdateInfo(rawData, channelFile, channelFileUrl) {
|
|
|
130
130
|
let result;
|
|
131
131
|
|
|
132
132
|
try {
|
|
133
|
-
result = (0, _jsYaml().
|
|
133
|
+
result = (0, _jsYaml().load)(rawData);
|
|
134
134
|
} catch (e) {
|
|
135
135
|
throw (0, _builderUtilRuntime().newError)(`Cannot parse update info from ${channelFile} in the latest release artifacts (${channelFileUrl}):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pdateInfo, WindowsUpdateInfo, configureRequestUrl } from \"builder-util-runtime\"\nimport { OutgoingHttpHeaders, RequestOptions } from \"http\"\nimport { load } from \"js-yaml\"\nimport { URL } from \"url\"\nimport { newUrlFromBase, ResolvedUpdateFileInfo } from \"../main\"\n\nexport type ProviderPlatform = \"darwin\" | \"linux\" | \"win32\"\n\nexport interface ProviderRuntimeOptions {\n isUseMultipleRangeRequest: boolean\n platform: ProviderPlatform\n\n executor: HttpExecutor<any>\n}\n\nexport abstract class Provider<T extends UpdateInfo> {\n private requestHeaders: OutgoingHttpHeaders | null = null\n protected readonly executor: HttpExecutor<any>\n\n protected constructor(private readonly runtimeOptions: ProviderRuntimeOptions) {\n this.executor = runtimeOptions.executor\n }\n\n get isUseMultipleRangeRequest(): boolean {\n return this.runtimeOptions.isUseMultipleRangeRequest !== false\n }\n\n private getChannelFilePrefix(): string {\n if (this.runtimeOptions.platform === \"linux\") {\n const arch = process.env.TEST_UPDATER_ARCH || process.arch\n const archSuffix = arch === \"x64\" ? \"\" : `-${arch}`\n return \"-linux\" + archSuffix\n }\n else {\n return this.runtimeOptions.platform === \"darwin\" ? \"-mac\" : \"\"\n }\n }\n\n // due to historical reasons for windows we use channel name without platform specifier\n protected getDefaultChannelName(): string {\n return this.getCustomChannelName(\"latest\")\n }\n\n protected getCustomChannelName(channel: string): string {\n return `${channel}${this.getChannelFilePrefix()}`\n }\n\n get fileExtraDownloadHeaders(): OutgoingHttpHeaders | null {\n return null\n }\n\n setRequestHeaders(value: OutgoingHttpHeaders | null): void {\n this.requestHeaders = value\n }\n\n abstract getLatestVersion(): Promise<T>\n\n abstract resolveFiles(updateInfo: UpdateInfo): Array<ResolvedUpdateFileInfo>\n\n /**\n * Method to perform API request only to resolve update info, but not to download update.\n */\n protected httpRequest(url: URL, headers?: OutgoingHttpHeaders | null, cancellationToken?: CancellationToken): Promise<string | null> {\n return this.executor.request(this.createRequestOptions(url, headers), cancellationToken)\n }\n\n protected createRequestOptions(url: URL, headers?: OutgoingHttpHeaders | null): RequestOptions {\n const result: RequestOptions = {}\n if (this.requestHeaders == null) {\n if (headers != null) {\n result.headers = headers\n }\n }\n else {\n result.headers = headers == null ? this.requestHeaders : {...this.requestHeaders, ...headers}\n }\n\n configureRequestUrl(url, result)\n return result\n }\n}\n\nexport function findFile(files: Array<ResolvedUpdateFileInfo>, extension: string, not?: Array<string>): ResolvedUpdateFileInfo | null | undefined {\n if (files.length === 0) {\n throw newError(\"No files provided\", \"ERR_UPDATER_NO_FILES_PROVIDED\")\n }\n\n const result = files.find(it => it.url.pathname.toLowerCase().endsWith(`.${extension}`))\n if (result != null) {\n return result\n }\n else if (not == null) {\n return files[0]\n }\n else {\n return files.find(fileInfo => !not.some(ext => fileInfo.url.pathname.toLowerCase().endsWith(`.${ext}`)))\n }\n}\n\nexport function parseUpdateInfo(rawData: string | null, channelFile: string, channelFileUrl: URL): UpdateInfo {\n if (rawData == null) {\n throw newError(`Cannot parse update info from ${channelFile} in the latest release artifacts (${channelFileUrl}): rawData: null`, \"ERR_UPDATER_INVALID_UPDATE_INFO\")\n }\n\n let result: UpdateInfo\n try {\n result = load(rawData) as UpdateInfo\n }\n catch (e) {\n throw newError(`Cannot parse update info from ${channelFile} in the latest release artifacts (${channelFileUrl}): ${e.stack || e.message}, rawData: ${rawData}`, \"ERR_UPDATER_INVALID_UPDATE_INFO\")\n }\n return result\n}\n\nexport function getFileList(updateInfo: UpdateInfo): Array<UpdateFileInfo> {\n const files = updateInfo.files\n if (files != null && files.length > 0) {\n return files\n }\n\n // noinspection JSDeprecatedSymbols\n if (updateInfo.path != null) {\n // noinspection JSDeprecatedSymbols\n return [\n {\n url: updateInfo.path,\n sha2: (updateInfo as any).sha2,\n sha512: updateInfo.sha512,\n } as any,\n ]\n }\n else {\n throw newError(`No files provided: ${safeStringifyJson(updateInfo)}`, \"ERR_UPDATER_NO_FILES_PROVIDED\")\n }\n}\n\nexport function resolveFiles(updateInfo: UpdateInfo, baseUrl: URL, pathTransformer: (p: string) => string = (p: string): string => p): Array<ResolvedUpdateFileInfo> {\n const files = getFileList(updateInfo)\n const result: Array<ResolvedUpdateFileInfo> = files.map(fileInfo => {\n if ((fileInfo as any).sha2 == null && fileInfo.sha512 == null) {\n throw newError(`Update info doesn't contain nor sha256 neither sha512 checksum: ${safeStringifyJson(fileInfo)}`, \"ERR_UPDATER_NO_CHECKSUM\")\n }\n return {\n url: newUrlFromBase(pathTransformer(fileInfo.url), baseUrl),\n info: fileInfo,\n }\n })\n\n const packages = (updateInfo as WindowsUpdateInfo).packages\n const packageInfo = packages == null ? null : (packages[process.arch] || packages.ia32)\n if (packageInfo != null) {\n (result[0] as any).packageInfo = {\n ...packageInfo,\n path: newUrlFromBase(pathTransformer(packageInfo.path), baseUrl).href,\n }\n }\n return result\n}"],"sourceRoot":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Logger } from "./main";
|
|
2
|
-
export declare function verifySignature(publisherNames: Array<string>,
|
|
2
|
+
export declare function verifySignature(publisherNames: Array<string>, unescapedTempUpdateFile: string, logger: Logger): Promise<string | null>;
|
|
@@ -42,10 +42,30 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
42
42
|
// $certificateInfo = (Get-AuthenticodeSignature 'xxx\yyy.exe'
|
|
43
43
|
// | where {$_.Status.Equals([System.Management.Automation.SignatureStatus]::Valid) -and $_.SignerCertificate.Subject.Contains("CN=siemens.com")})
|
|
44
44
|
// | Out-String ; if ($certificateInfo) { exit 0 } else { exit 1 }
|
|
45
|
-
function verifySignature(publisherNames,
|
|
45
|
+
function verifySignature(publisherNames, unescapedTempUpdateFile, logger) {
|
|
46
46
|
return new Promise(resolve => {
|
|
47
|
-
//
|
|
47
|
+
// Escape quotes and backticks in filenames to prevent user from breaking the
|
|
48
|
+
// arguments and perform a remote command injection.
|
|
49
|
+
//
|
|
50
|
+
// Consider example powershell command:
|
|
51
|
+
// ```powershell
|
|
52
|
+
// Get-AuthenticodeSignature 'C:\\path\\my-bad-';calc;'filename.exe'
|
|
53
|
+
// ```
|
|
54
|
+
// The above would work expected and find the file name, however, it will also execute `;calc;`
|
|
55
|
+
// command and start the calculator app.
|
|
56
|
+
//
|
|
57
|
+
// From Powershell quoting rules:
|
|
58
|
+
// https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-7
|
|
59
|
+
// * Double quotes `"` are treated literally within single-quoted strings;
|
|
60
|
+
// * Single quotes can be escaped by doubling them: 'don''t' -> don't;
|
|
61
|
+
// * Backticks can be escaped by doubling them: 'A backtick (``) character';
|
|
62
|
+
//
|
|
63
|
+
// Also note that at this point the file has already been written to the disk, thus we are
|
|
64
|
+
// guaranteed that the path will not contains any illegal characters like <>:"/\|?*
|
|
65
|
+
// https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
|
|
66
|
+
const tempUpdateFile = unescapedTempUpdateFile.replace(/'/g, "''").replace(/`/g, "``"); // https://github.com/electron-userland/electron-builder/issues/2421
|
|
48
67
|
// https://github.com/electron-userland/electron-builder/issues/2535
|
|
68
|
+
|
|
49
69
|
(0, _child_process().execFile)("powershell.exe", ["-NoProfile", "-NonInteractive", "-InputFormat", "None", "-Command", `Get-AuthenticodeSignature '${tempUpdateFile}' | ConvertTo-Json -Compress | ForEach-Object { [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($_)) }`], {
|
|
50
70
|
timeout: 20 * 1000
|
|
51
71
|
}, (error, stdout, stderr) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/windowsExecutableCodeSignatureVerifier.ts"],"names":[],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;AAGA;AACA;AACA;AACM,SAAU,eAAV,CAA0B,cAA1B,EAAyD,
|
|
1
|
+
{"version":3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AAiB;AACf,IAAA,MAAM,CAAC,IAAP,CAAY,6CAA6C,KAAK,IAAI,MAAM,kHAAxE;AACA;AACD;;AAED,MAAI;AACF,uCAAa,gBAAb,EAA+B,CAAC,YAAD,EAAe,iBAAf,EAAkC,UAAlC,EAA8C,qBAA9C,CAA/B,EAAqG;AAAC,MAAA,OAAO,EAAE,KAAK;AAAf,KAArG;AACD,GAFD,CAGA,OAAO,SAAP,EAAkB;AAChB,IAAA,MAAM,CAAC,IAAP,CAAY,kCAAkC,SAAS,CAAC,OAAO,kHAA/D;AACA;AACD;;AAED,MAAI,KAAK,IAAI,IAAb,EAAmB;AACjB,UAAM,KAAN;AACD;;AAED,MAAI,MAAJ,EAAY;AACV,IAAA,MAAM,CAAC,IAAP,CAAY,qDAAqD,MAAM,wDAAvE;AACA;AACD;AACF;;AAED,SAAS,SAAT,GAAkB;AAChB,QAAM,UAAU,GAAG,EAAE,GAAC,OAAH,EAAnB;AACA,SAAO,UAAU,CAAC,UAAX,CAAsB,IAAtB,KAA+B,CAAC,UAAU,CAAC,UAAX,CAAsB,KAAtB,CAAvC;AACD,C","sourcesContent":["import { parseDn } from \"builder-util-runtime\"\nimport { execFile, execFileSync } from \"child_process\"\nimport * as os from \"os\"\nimport { Logger } from \"./main\"\n\n// $certificateInfo = (Get-AuthenticodeSignature 'xxx\\yyy.exe'\n// | where {$_.Status.Equals([System.Management.Automation.SignatureStatus]::Valid) -and $_.SignerCertificate.Subject.Contains(\"CN=siemens.com\")})\n// | Out-String ; if ($certificateInfo) { exit 0 } else { exit 1 }\nexport function verifySignature(publisherNames: Array<string>, unescapedTempUpdateFile: string, logger: Logger): Promise<string | null> {\n return new Promise<string | null>(resolve => {\n\n // Escape quotes and backticks in filenames to prevent user from breaking the\n // arguments and perform a remote command injection.\n //\n // Consider example powershell command:\n // ```powershell\n // Get-AuthenticodeSignature 'C:\\\\path\\\\my-bad-';calc;'filename.exe'\n // ```\n // The above would work expected and find the file name, however, it will also execute `;calc;`\n // command and start the calculator app.\n //\n // From Powershell quoting rules:\n // https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-7\n // * Double quotes `\"` are treated literally within single-quoted strings;\n // * Single quotes can be escaped by doubling them: 'don''t' -> don't;\n // * Backticks can be escaped by doubling them: 'A backtick (``) character';\n //\n // Also note that at this point the file has already been written to the disk, thus we are\n // guaranteed that the path will not contains any illegal characters like <>:\"/\\|?*\n // https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file\n const tempUpdateFile = unescapedTempUpdateFile.replace(/'/g, \"''\").replace(/`/g, \"``\");\n\n // https://github.com/electron-userland/electron-builder/issues/2421\n // https://github.com/electron-userland/electron-builder/issues/2535\n execFile(\"powershell.exe\", [\"-NoProfile\", \"-NonInteractive\", \"-InputFormat\", \"None\", \"-Command\", `Get-AuthenticodeSignature '${tempUpdateFile}' | ConvertTo-Json -Compress | ForEach-Object { [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($_)) }`], {\n timeout: 20 * 1000\n }, (error, stdout, stderr) => {\n try {\n if (error != null || stderr) {\n handleError(logger, error, stderr)\n resolve(null)\n return\n }\n\n const data = parseOut(Buffer.from(stdout, \"base64\").toString(\"utf-8\"))\n if (data.Status === 0) {\n const name = parseDn(data.SignerCertificate.Subject).get(\"CN\")!\n if (publisherNames.includes(name)) {\n resolve(null)\n return\n }\n }\n\n const result = `publisherNames: ${publisherNames.join(\" | \")}, raw info: ` + JSON.stringify(data, (name, value) => name === \"RawData\" ? undefined : value, 2)\n logger.warn(`Sign verification failed, installer signed with incorrect certificate: ${result}`)\n resolve(result)\n }\n catch (e) {\n logger.warn(`Cannot execute Get-AuthenticodeSignature: ${error}. Ignoring signature validation due to unknown error.`)\n resolve(null)\n return\n }\n })\n })\n}\n\nfunction parseOut(out: string): any {\n const data = JSON.parse(out)\n delete data.PrivateKey\n delete data.IsOSBinary\n delete data.SignatureType\n const signerCertificate = data.SignerCertificate\n if (signerCertificate != null) {\n delete signerCertificate.Archived\n delete signerCertificate.Extensions\n delete signerCertificate.Handle\n delete signerCertificate.HasPrivateKey\n // duplicates data.SignerCertificate (contains RawData)\n delete signerCertificate.SubjectName\n }\n delete data.Path\n return data\n}\n\nfunction handleError(logger: Logger, error: Error | null, stderr: string | null): void {\n if (isOldWin6()) {\n logger.warn(`Cannot execute Get-AuthenticodeSignature: ${error || stderr}. Ignoring signature validation due to unsupported powershell version. Please upgrade to powershell 3 or higher.`)\n return\n }\n\n try {\n execFileSync(\"powershell.exe\", [\"-NoProfile\", \"-NonInteractive\", \"-Command\", \"ConvertTo-Json test\"], {timeout: 10 * 1000})\n }\n catch (testError) {\n logger.warn(`Cannot execute ConvertTo-Json: ${testError.message}. Ignoring signature validation due to unsupported powershell version. Please upgrade to powershell 3 or higher.`)\n return\n }\n\n if (error != null) {\n throw error\n }\n\n if (stderr) {\n logger.warn(`Cannot execute Get-AuthenticodeSignature, stderr: ${stderr}. Ignoring signature validation due to unknown stderr.`)\n return\n }\n}\n\nfunction isOldWin6(): boolean {\n const winVersion = os.release()\n return winVersion.startsWith(\"6.\") && !winVersion.startsWith(\"6.3\")\n}\n"],"sourceRoot":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "electron-updater",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.8",
|
|
4
4
|
"description": "Cross platform updater for electron applications",
|
|
5
5
|
"main": "out/main.js",
|
|
6
6
|
"author": "Vladimir Krivosheev",
|
|
@@ -12,17 +12,17 @@
|
|
|
12
12
|
"out"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@types/semver": "^7.3.
|
|
16
|
-
"builder-util-runtime": "8.7.
|
|
17
|
-
"fs-extra": "^9.0
|
|
18
|
-
"js-yaml": "^
|
|
15
|
+
"@types/semver": "^7.3.4",
|
|
16
|
+
"builder-util-runtime": "8.7.3",
|
|
17
|
+
"fs-extra": "^9.1.0",
|
|
18
|
+
"js-yaml": "^4.0.0",
|
|
19
19
|
"lazy-val": "^1.0.4",
|
|
20
20
|
"lodash.isequal": "^4.5.0",
|
|
21
|
-
"semver": "^7.3.
|
|
21
|
+
"semver": "^7.3.4"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@types/fs-extra": "^9.0.
|
|
25
|
-
"@types/js-yaml": "^3.12.
|
|
24
|
+
"@types/fs-extra": "^9.0.7",
|
|
25
|
+
"@types/js-yaml": "^3.12.6",
|
|
26
26
|
"@types/lodash.isequal": "^4.5.5"
|
|
27
27
|
},
|
|
28
28
|
"typings": "./out/main.d.ts",
|