electron-updater 4.3.5 → 4.3.9
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/LICENSE +22 -0
- package/out/AppAdapter.js +19 -28
- package/out/AppAdapter.js.map +1 -1
- package/out/AppImageUpdater.js +103 -173
- package/out/AppImageUpdater.js.map +1 -1
- package/out/AppUpdater.d.ts +1 -3
- package/out/AppUpdater.js +517 -773
- package/out/AppUpdater.js.map +1 -1
- package/out/BaseUpdater.js +79 -103
- package/out/BaseUpdater.js.map +1 -1
- package/out/DownloadedUpdateHelper.js +150 -224
- package/out/DownloadedUpdateHelper.js.map +1 -1
- package/out/ElectronAppAdapter.js +35 -63
- package/out/ElectronAppAdapter.js.map +1 -1
- package/out/MacUpdater.d.ts +1 -1
- package/out/MacUpdater.js +132 -182
- package/out/MacUpdater.js.map +1 -1
- package/out/NoOpLogger.d.ts +6 -0
- package/out/NoOpLogger.js +19 -0
- package/out/NoOpLogger.js.map +1 -0
- package/out/NsisUpdater.js +199 -331
- package/out/NsisUpdater.js.map +1 -1
- package/out/differentialDownloader/DataSplitter.js +180 -252
- package/out/differentialDownloader/DataSplitter.js.map +1 -1
- package/out/differentialDownloader/DifferentialDownloader.d.ts +3 -0
- package/out/differentialDownloader/DifferentialDownloader.js +243 -308
- package/out/differentialDownloader/DifferentialDownloader.js.map +1 -1
- package/out/differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader.js +29 -65
- package/out/differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader.js.map +1 -1
- package/out/differentialDownloader/GenericDifferentialDownloader.js +7 -21
- package/out/differentialDownloader/GenericDifferentialDownloader.js.map +1 -1
- package/out/differentialDownloader/ProgressDifferentialDownloadCallbackTransform.d.ts +32 -0
- package/out/differentialDownloader/ProgressDifferentialDownloadCallbackTransform.js +90 -0
- package/out/differentialDownloader/ProgressDifferentialDownloadCallbackTransform.js.map +1 -0
- package/out/differentialDownloader/downloadPlanBuilder.js +99 -124
- package/out/differentialDownloader/downloadPlanBuilder.js.map +1 -1
- package/out/differentialDownloader/multipleRangeDownloader.js +99 -148
- package/out/differentialDownloader/multipleRangeDownloader.js.map +1 -1
- package/out/electronHttpExecutor.js +73 -106
- package/out/electronHttpExecutor.js.map +1 -1
- package/out/event.d.ts +35 -0
- package/out/event.js +39 -0
- package/out/event.js.map +1 -0
- package/out/log.d.ts +11 -0
- package/out/log.js +19 -0
- package/out/log.js.map +1 -0
- package/out/main.d.ts +1 -4
- package/out/main.js +60 -212
- package/out/main.js.map +1 -1
- package/out/providerFactory.js +49 -105
- package/out/providerFactory.js.map +1 -1
- package/out/providers/BintrayProvider.d.ts +2 -2
- package/out/providers/BintrayProvider.js +40 -95
- package/out/providers/BintrayProvider.js.map +1 -1
- package/out/providers/GenericProvider.d.ts +2 -2
- package/out/providers/GenericProvider.js +46 -80
- package/out/providers/GenericProvider.js.map +1 -1
- package/out/providers/GitHubProvider.d.ts +2 -2
- package/out/providers/GitHubProvider.js +122 -201
- package/out/providers/GitHubProvider.js.map +1 -1
- package/out/providers/PrivateGitHubProvider.js +87 -165
- package/out/providers/PrivateGitHubProvider.js.map +1 -1
- package/out/providers/Provider.js +122 -173
- package/out/providers/Provider.js.map +1 -1
- package/out/util.d.ts +5 -0
- package/out/util.js +42 -0
- package/out/util.js.map +1 -0
- package/out/windowsExecutableCodeSignatureVerifier.js +99 -139
- package/out/windowsExecutableCodeSignatureVerifier.js.map +1 -1
- package/package.json +33 -31
|
@@ -1,161 +1,112 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.checkIsRangesSupported = checkIsRangesSupported;
|
|
8
|
-
|
|
9
|
-
function _builderUtilRuntime() {
|
|
10
|
-
const data = require("builder-util-runtime");
|
|
11
|
-
|
|
12
|
-
_builderUtilRuntime = function () {
|
|
13
|
-
return data;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
return data;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function _DataSplitter() {
|
|
20
|
-
const data = require("./DataSplitter");
|
|
21
|
-
|
|
22
|
-
_DataSplitter = function () {
|
|
23
|
-
return data;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
return data;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function _downloadPlanBuilder() {
|
|
30
|
-
const data = require("./downloadPlanBuilder");
|
|
31
|
-
|
|
32
|
-
_downloadPlanBuilder = function () {
|
|
33
|
-
return data;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
return data;
|
|
37
|
-
}
|
|
38
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkIsRangesSupported = exports.executeTasksUsingMultipleRangeRequests = void 0;
|
|
4
|
+
const builder_util_runtime_1 = require("builder-util-runtime");
|
|
5
|
+
const DataSplitter_1 = require("./DataSplitter");
|
|
6
|
+
const downloadPlanBuilder_1 = require("./downloadPlanBuilder");
|
|
39
7
|
function executeTasksUsingMultipleRangeRequests(differentialDownloader, tasks, out, oldFileFd, reject) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
return w;
|
|
8
|
+
const w = (taskOffset) => {
|
|
9
|
+
if (taskOffset >= tasks.length) {
|
|
10
|
+
if (differentialDownloader.fileMetadataBuffer != null) {
|
|
11
|
+
out.write(differentialDownloader.fileMetadataBuffer);
|
|
12
|
+
}
|
|
13
|
+
out.end();
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const nextOffset = taskOffset + 1000;
|
|
17
|
+
doExecuteTasks(differentialDownloader, {
|
|
18
|
+
tasks,
|
|
19
|
+
start: taskOffset,
|
|
20
|
+
end: Math.min(tasks.length, nextOffset),
|
|
21
|
+
oldFileFd,
|
|
22
|
+
}, out, () => w(nextOffset), reject);
|
|
23
|
+
};
|
|
24
|
+
return w;
|
|
60
25
|
}
|
|
61
|
-
|
|
26
|
+
exports.executeTasksUsingMultipleRangeRequests = executeTasksUsingMultipleRangeRequests;
|
|
62
27
|
function doExecuteTasks(differentialDownloader, options, out, resolve, reject) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
partIndexToLength.push(task.end - task.start);
|
|
28
|
+
let ranges = "bytes=";
|
|
29
|
+
let partCount = 0;
|
|
30
|
+
const partIndexToTaskIndex = new Map();
|
|
31
|
+
const partIndexToLength = [];
|
|
32
|
+
for (let i = options.start; i < options.end; i++) {
|
|
33
|
+
const task = options.tasks[i];
|
|
34
|
+
if (task.kind === downloadPlanBuilder_1.OperationKind.DOWNLOAD) {
|
|
35
|
+
ranges += `${task.start}-${task.end - 1}, `;
|
|
36
|
+
partIndexToTaskIndex.set(partCount, i);
|
|
37
|
+
partCount++;
|
|
38
|
+
partIndexToLength.push(task.end - task.start);
|
|
39
|
+
}
|
|
76
40
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
41
|
+
if (partCount <= 1) {
|
|
42
|
+
// the only remote range - copy
|
|
43
|
+
const w = (index) => {
|
|
44
|
+
if (index >= options.end) {
|
|
45
|
+
resolve();
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const task = options.tasks[index++];
|
|
49
|
+
if (task.kind === downloadPlanBuilder_1.OperationKind.COPY) {
|
|
50
|
+
DataSplitter_1.copyData(task, out, options.oldFileFd, reject, () => w(index));
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const requestOptions = differentialDownloader.createRequestOptions();
|
|
54
|
+
requestOptions.headers.Range = `bytes=${task.start}-${task.end - 1}`;
|
|
55
|
+
const request = differentialDownloader.httpExecutor.createRequest(requestOptions, response => {
|
|
56
|
+
if (!checkIsRangesSupported(response, reject)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
response.pipe(out, {
|
|
60
|
+
end: false,
|
|
61
|
+
});
|
|
62
|
+
response.once("end", () => w(index));
|
|
63
|
+
});
|
|
64
|
+
differentialDownloader.httpExecutor.addErrorAndTimeoutHandlers(request, reject);
|
|
65
|
+
request.end();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
w(options.start);
|
|
84
69
|
return;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
70
|
+
}
|
|
71
|
+
const requestOptions = differentialDownloader.createRequestOptions();
|
|
72
|
+
requestOptions.headers.Range = ranges.substring(0, ranges.length - 2);
|
|
73
|
+
const request = differentialDownloader.httpExecutor.createRequest(requestOptions, response => {
|
|
74
|
+
if (!checkIsRangesSupported(response, reject)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const contentType = builder_util_runtime_1.safeGetHeader(response, "content-type");
|
|
78
|
+
const m = /^multipart\/.+?(?:; boundary=(?:(?:"(.+)")|(?:([^\s]+))))$/i.exec(contentType);
|
|
79
|
+
if (m == null) {
|
|
80
|
+
reject(new Error(`Content-Type "multipart/byteranges" is expected, but got "${contentType}"`));
|
|
96
81
|
return;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
82
|
+
}
|
|
83
|
+
const dicer = new DataSplitter_1.DataSplitter(out, options, partIndexToTaskIndex, m[1] || m[2], partIndexToLength, resolve);
|
|
84
|
+
dicer.on("error", reject);
|
|
85
|
+
response.pipe(dicer);
|
|
86
|
+
response.on("end", () => {
|
|
87
|
+
setTimeout(() => {
|
|
88
|
+
request.abort();
|
|
89
|
+
reject(new Error("Response ends without calling any handlers"));
|
|
90
|
+
}, 10000);
|
|
103
91
|
});
|
|
104
|
-
differentialDownloader.httpExecutor.addErrorAndTimeoutHandlers(request, reject);
|
|
105
|
-
request.end();
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
w(options.start);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const requestOptions = differentialDownloader.createRequestOptions();
|
|
114
|
-
requestOptions.headers.Range = ranges.substring(0, ranges.length - 2);
|
|
115
|
-
const request = differentialDownloader.httpExecutor.createRequest(requestOptions, response => {
|
|
116
|
-
if (!checkIsRangesSupported(response, reject)) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const contentType = (0, _builderUtilRuntime().safeGetHeader)(response, "content-type");
|
|
121
|
-
const m = /^multipart\/.+?(?:; boundary=(?:(?:"(.+)")|(?:([^\s]+))))$/i.exec(contentType);
|
|
122
|
-
|
|
123
|
-
if (m == null) {
|
|
124
|
-
reject(new Error(`Content-Type "multipart/byteranges" is expected, but got "${contentType}"`));
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const dicer = new (_DataSplitter().DataSplitter)(out, options, partIndexToTaskIndex, m[1] || m[2], partIndexToLength, resolve);
|
|
129
|
-
dicer.on("error", reject);
|
|
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
92
|
});
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
request.end();
|
|
93
|
+
differentialDownloader.httpExecutor.addErrorAndTimeoutHandlers(request, reject);
|
|
94
|
+
request.end();
|
|
140
95
|
}
|
|
141
|
-
|
|
142
96
|
function checkIsRangesSupported(response, reject) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
return false;
|
|
97
|
+
// Electron net handles redirects automatically, our NodeJS test server doesn't use redirects - so, we don't check 3xx codes.
|
|
98
|
+
if (response.statusCode >= 400) {
|
|
99
|
+
reject(builder_util_runtime_1.createHttpError(response));
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
if (response.statusCode !== 206) {
|
|
103
|
+
const acceptRanges = builder_util_runtime_1.safeGetHeader(response, "accept-ranges");
|
|
104
|
+
if (acceptRanges == null || acceptRanges === "none") {
|
|
105
|
+
reject(new Error(`Server doesn't support Accept-Ranges (response code ${response.statusCode})`));
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
155
108
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
// __ts-babel@6.0.4
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
exports.checkIsRangesSupported = checkIsRangesSupported;
|
|
161
112
|
//# sourceMappingURL=multipleRangeDownloader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/differentialDownloader/multipleRangeDownloader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"multipleRangeDownloader.js","sourceRoot":"","sources":["../../src/differentialDownloader/multipleRangeDownloader.ts"],"names":[],"mappings":";;;AAAA,+DAAqE;AAGrE,iDAAyE;AAEzE,+DAAgE;AAEhE,SAAgB,sCAAsC,CACpD,sBAA8C,EAC9C,KAAuB,EACvB,GAAa,EACb,SAAiB,EACjB,MAA8B;IAE9B,MAAM,CAAC,GAAG,CAAC,UAAkB,EAAQ,EAAE;QACrC,IAA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AAA;QACX,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IACF,sBAAsB,CAAC,YAAY,CAAC,0BAA0B,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAC/E,OAAO,CAAC,GAAG,EAAE,CAAA;AACf,CAAC;AAED,SAAgB,sBAAsB,CAAC,QAAyB,EAAE,MAA8B;IAC9F,6HAA6H;IAC7H,IAAI,QAAQ,CAAC,UAAW,IAAI,GAAG,EAAE;QAC/B,MAAM,CAAC,sCAAe,CAAC,QAAQ,CAAC,CAAC,CAAA;QACjC,OAAO,KAAK,CAAA;KACb;IAED,IAAI,QAAQ,CAAC,UAAU,KAAK,GAAG,EAAE;QAC/B,MAAM,YAAY,GAAG,oCAAa,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAA;QAC7D,IAAI,YAAY,IAAI,IAAI,IAAI,YAAY,KAAK,MAAM,EAAE;YACnD,MAAM,CAAC,IAAI,KAAK,CAAC,uDAAuD,QAAQ,CAAC,UAAU,GAAG,CAAC,CAAC,CAAA;YAChG,OAAO,KAAK,CAAA;SACb;KACF;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAfD,wDAeC","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(\n differentialDownloader: DifferentialDownloader,\n tasks: Array<Operation>,\n out: Writable,\n oldFileFd: number,\n reject: (error: Error) => void\n): (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(\n differentialDownloader,\n {\n tasks,\n start: taskOffset,\n end: Math.min(tasks.length, nextOffset),\n oldFileFd,\n },\n out,\n () => w(nextOffset),\n reject\n )\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 } 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"]}
|
|
@@ -1,112 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.getNetSession = getNetSession;
|
|
7
|
-
exports.ElectronHttpExecutor = exports.NET_SESSION_NAME = void 0;
|
|
8
|
-
|
|
9
|
-
function _builderUtilRuntime() {
|
|
10
|
-
const data = require("builder-util-runtime");
|
|
11
|
-
|
|
12
|
-
_builderUtilRuntime = function () {
|
|
13
|
-
return data;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
return data;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function _electron() {
|
|
20
|
-
const data = require("electron");
|
|
21
|
-
|
|
22
|
-
_electron = function () {
|
|
23
|
-
return data;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
return data;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const NET_SESSION_NAME = "electron-updater";
|
|
30
|
-
exports.NET_SESSION_NAME = NET_SESSION_NAME;
|
|
31
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ElectronHttpExecutor = exports.getNetSession = exports.NET_SESSION_NAME = void 0;
|
|
4
|
+
const builder_util_runtime_1 = require("builder-util-runtime");
|
|
5
|
+
exports.NET_SESSION_NAME = "electron-updater";
|
|
32
6
|
function getNetSession() {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
class ElectronHttpExecutor extends _builderUtilRuntime().HttpExecutor {
|
|
39
|
-
constructor(proxyLoginCallback) {
|
|
40
|
-
super();
|
|
41
|
-
this.proxyLoginCallback = proxyLoginCallback;
|
|
42
|
-
this.cachedSession = null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async download(url, destination, options) {
|
|
46
|
-
return await options.cancellationToken.createPromise((resolve, reject, onCancel) => {
|
|
47
|
-
const requestOptions = {
|
|
48
|
-
headers: options.headers || undefined,
|
|
49
|
-
redirect: "manual"
|
|
50
|
-
};
|
|
51
|
-
(0, _builderUtilRuntime().configureRequestUrl)(url, requestOptions);
|
|
52
|
-
(0, _builderUtilRuntime().configureRequestOptions)(requestOptions);
|
|
53
|
-
this.doDownload(requestOptions, {
|
|
54
|
-
destination,
|
|
55
|
-
options,
|
|
56
|
-
onCancel,
|
|
57
|
-
callback: error => {
|
|
58
|
-
if (error == null) {
|
|
59
|
-
resolve(destination);
|
|
60
|
-
} else {
|
|
61
|
-
reject(error);
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
responseHandler: null
|
|
65
|
-
}, 0);
|
|
7
|
+
return require("electron").session.fromPartition(exports.NET_SESSION_NAME, {
|
|
8
|
+
cache: false,
|
|
66
9
|
});
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
delete options.headers.Host;
|
|
76
|
-
} // differential downloader can call this method very often, so, better to cache session
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (this.cachedSession == null) {
|
|
80
|
-
this.cachedSession = getNetSession();
|
|
10
|
+
}
|
|
11
|
+
exports.getNetSession = getNetSession;
|
|
12
|
+
class ElectronHttpExecutor extends builder_util_runtime_1.HttpExecutor {
|
|
13
|
+
constructor(proxyLoginCallback) {
|
|
14
|
+
super();
|
|
15
|
+
this.proxyLoginCallback = proxyLoginCallback;
|
|
16
|
+
this.cachedSession = null;
|
|
81
17
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
18
|
+
async download(url, destination, options) {
|
|
19
|
+
return await options.cancellationToken.createPromise((resolve, reject, onCancel) => {
|
|
20
|
+
const requestOptions = {
|
|
21
|
+
headers: options.headers || undefined,
|
|
22
|
+
redirect: "manual",
|
|
23
|
+
};
|
|
24
|
+
builder_util_runtime_1.configureRequestUrl(url, requestOptions);
|
|
25
|
+
builder_util_runtime_1.configureRequestOptions(requestOptions);
|
|
26
|
+
this.doDownload(requestOptions, {
|
|
27
|
+
destination,
|
|
28
|
+
options,
|
|
29
|
+
onCancel,
|
|
30
|
+
callback: error => {
|
|
31
|
+
if (error == null) {
|
|
32
|
+
resolve(destination);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
reject(error);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
responseHandler: null,
|
|
39
|
+
}, 0);
|
|
40
|
+
});
|
|
91
41
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
42
|
+
createRequest(options, callback) {
|
|
43
|
+
// fix (node 7+) for making electron updater work when using AWS private buckets, check if headers contain Host property
|
|
44
|
+
if (options.headers && options.headers.Host) {
|
|
45
|
+
// set host value from headers.Host
|
|
46
|
+
options.host = options.headers.Host;
|
|
47
|
+
// remove header property 'Host', if not removed causes net::ERR_INVALID_ARGUMENT exception
|
|
48
|
+
delete options.headers.Host;
|
|
49
|
+
}
|
|
50
|
+
// differential downloader can call this method very often, so, better to cache session
|
|
51
|
+
if (this.cachedSession == null) {
|
|
52
|
+
this.cachedSession = getNetSession();
|
|
53
|
+
}
|
|
54
|
+
const request = require("electron").net.request({
|
|
55
|
+
...options,
|
|
56
|
+
session: this.cachedSession,
|
|
57
|
+
});
|
|
58
|
+
request.on("response", callback);
|
|
59
|
+
if (this.proxyLoginCallback != null) {
|
|
60
|
+
request.on("login", this.proxyLoginCallback);
|
|
61
|
+
}
|
|
62
|
+
return request;
|
|
63
|
+
}
|
|
64
|
+
addRedirectHandlers(request, options, reject, redirectCount, handler) {
|
|
65
|
+
request.on("redirect", (statusCode, method, redirectUrl) => {
|
|
66
|
+
// no way to modify request options, abort old and make a new one
|
|
67
|
+
// https://github.com/electron/electron/issues/11505
|
|
68
|
+
request.abort();
|
|
69
|
+
if (redirectCount > this.maxRedirects) {
|
|
70
|
+
reject(this.createMaxRedirectError());
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
handler(builder_util_runtime_1.HttpExecutor.prepareRedirectUrlOptions(redirectUrl, options));
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.ElectronHttpExecutor = ElectronHttpExecutor;
|
|
112
79
|
//# sourceMappingURL=electronHttpExecutor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/electronHttpExecutor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"electronHttpExecutor.js","sourceRoot":"","sources":["../src/electronHttpExecutor.ts"],"names":[],"mappings":";;;AAAA,+DAAkH;AAMrG,QAAA,gBAAgB,GAAG,kBAAkB,CAAA;AAElD,SAAgB,aAAa;IAC3B,OA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FAA2F;YAC3F,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAA;SAC5B;QAED,uFAAuF;QACvF,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,EAAE;YAC9B,IAAI,CAAC,aAAa,GAAG,aAAa,EAAE,CAAA;SACrC;QAED,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC;YAC9C,GAAG,OAAO;YACV,OAAO,EAAE,IAAI,CAAC,aAAa;SAC5B,CAAC,CAAA;QACF,OAAO,CAAC,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;QAChC,IAAI,IAAI,CAAC,kBAAkB,IAAI,IAAI,EAAE;YACnC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAA;SAC7C;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IAES,mBAAmB,CAC3B,OAAsB,EACtB,OAAuB,EACvB,MAA8B,EAC9B,aAAqB,EACrB,OAA0C;QAE1C,OAAO,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,UAAkB,EAAE,MAAc,EAAE,WAAmB,EAAE,EAAE;YACjF,iEAAiE;YACjE,oDAAoD;YACpD,OAAO,CAAC,KAAK,EAAE,CAAA;YAEf,IAAI,aAAa,GAAG,IAAI,CAAC,YAAY,EAAE;gBACrC,MAAM,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAAA;aACtC;iBAAM;gBACL,OAAO,CAAC,mCAAY,CAAC,yBAAyB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAA;aACtE;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AA/ED,oDA+EC","sourcesContent":["import { DownloadOptions, HttpExecutor, configureRequestOptions, configureRequestUrl } from \"builder-util-runtime\"\nimport { RequestOptions } from \"http\"\nimport Session = Electron.Session\nimport ClientRequest = Electron.ClientRequest\n\nexport type LoginCallback = (username: string, password: string) => void\nexport const NET_SESSION_NAME = \"electron-updater\"\n\nexport function getNetSession(): Session {\n return require(\"electron\").session.fromPartition(NET_SESSION_NAME, {\n cache: false,\n })\n}\n\nexport class ElectronHttpExecutor extends HttpExecutor<Electron.ClientRequest> {\n private cachedSession: Session | null = null\n\n constructor(private readonly proxyLoginCallback?: (authInfo: any, callback: LoginCallback) => void) {\n super()\n }\n\n async download(url: URL, destination: string, options: DownloadOptions): Promise<string> {\n return await options.cancellationToken.createPromise<string>((resolve, reject, onCancel) => {\n const requestOptions = {\n headers: options.headers || undefined,\n redirect: \"manual\",\n }\n configureRequestUrl(url, requestOptions)\n configureRequestOptions(requestOptions)\n this.doDownload(\n requestOptions,\n {\n destination,\n options,\n onCancel,\n callback: error => {\n if (error == null) {\n resolve(destination)\n } else {\n reject(error)\n }\n },\n responseHandler: null,\n },\n 0\n )\n })\n }\n\n createRequest(options: any, callback: (response: any) => void): any {\n // fix (node 7+) for making electron updater work when using AWS private buckets, check if headers contain Host property\n if (options.headers && options.headers.Host) {\n // set host value from headers.Host\n options.host = options.headers.Host\n // remove header property 'Host', if not removed causes net::ERR_INVALID_ARGUMENT exception\n delete options.headers.Host\n }\n\n // differential downloader can call this method very often, so, better to cache session\n if (this.cachedSession == null) {\n this.cachedSession = getNetSession()\n }\n\n const request = require(\"electron\").net.request({\n ...options,\n session: this.cachedSession,\n })\n request.on(\"response\", callback)\n if (this.proxyLoginCallback != null) {\n request.on(\"login\", this.proxyLoginCallback)\n }\n return request\n }\n\n protected addRedirectHandlers(\n request: ClientRequest,\n options: RequestOptions,\n reject: (error: Error) => void,\n redirectCount: number,\n handler: (options: RequestOptions) => void\n ): void {\n request.on(\"redirect\", (statusCode: number, method: string, redirectUrl: string) => {\n // no way to modify request options, abort old and make a new one\n // https://github.com/electron/electron/issues/11505\n request.abort()\n\n if (redirectCount > this.maxRedirects) {\n reject(this.createMaxRedirectError())\n } else {\n handler(HttpExecutor.prepareRedirectUrlOptions(redirectUrl, options))\n }\n })\n }\n}\n"]}
|
package/out/event.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { CancellationToken, PackageFileInfo, ProgressInfo, UpdateFileInfo, UpdateInfo } from "builder-util-runtime";
|
|
3
|
+
import { EventEmitter } from "events";
|
|
4
|
+
import { URL } from "url";
|
|
5
|
+
import { LoginCallback } from "./electronHttpExecutor";
|
|
6
|
+
export declare type UpdaterEvents = "login" | "checking-for-update" | "update-available" | "update-cancelled" | "download-progress" | "update-downloaded" | "error";
|
|
7
|
+
export declare const DOWNLOAD_PROGRESS: UpdaterEvents;
|
|
8
|
+
export declare const UPDATE_DOWNLOADED: UpdaterEvents;
|
|
9
|
+
export declare type LoginHandler = (authInfo: any, callback: LoginCallback) => void;
|
|
10
|
+
export declare class UpdaterSignal {
|
|
11
|
+
private emitter;
|
|
12
|
+
constructor(emitter: EventEmitter);
|
|
13
|
+
/**
|
|
14
|
+
* Emitted when an authenticating proxy is [asking for user credentials](https://github.com/electron/electron/blob/master/docs/api/client-request.md#event-login).
|
|
15
|
+
*/
|
|
16
|
+
login(handler: LoginHandler): void;
|
|
17
|
+
progress(handler: (info: ProgressInfo) => void): void;
|
|
18
|
+
updateDownloaded(handler: (info: UpdateDownloadedEvent) => void): void;
|
|
19
|
+
updateCancelled(handler: (info: UpdateInfo) => void): void;
|
|
20
|
+
}
|
|
21
|
+
export interface UpdateCheckResult {
|
|
22
|
+
readonly updateInfo: UpdateInfo;
|
|
23
|
+
readonly downloadPromise?: Promise<Array<string>> | null;
|
|
24
|
+
readonly cancellationToken?: CancellationToken;
|
|
25
|
+
/** @deprecated */
|
|
26
|
+
readonly versionInfo: UpdateInfo;
|
|
27
|
+
}
|
|
28
|
+
export interface ResolvedUpdateFileInfo {
|
|
29
|
+
readonly url: URL;
|
|
30
|
+
readonly info: UpdateFileInfo;
|
|
31
|
+
packageInfo?: PackageFileInfo;
|
|
32
|
+
}
|
|
33
|
+
export interface UpdateDownloadedEvent extends UpdateInfo {
|
|
34
|
+
downloadedFile: string;
|
|
35
|
+
}
|
package/out/event.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UpdaterSignal = exports.UPDATE_DOWNLOADED = exports.DOWNLOAD_PROGRESS = void 0;
|
|
4
|
+
exports.DOWNLOAD_PROGRESS = "download-progress";
|
|
5
|
+
exports.UPDATE_DOWNLOADED = "update-downloaded";
|
|
6
|
+
class UpdaterSignal {
|
|
7
|
+
constructor(emitter) {
|
|
8
|
+
this.emitter = emitter;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Emitted when an authenticating proxy is [asking for user credentials](https://github.com/electron/electron/blob/master/docs/api/client-request.md#event-login).
|
|
12
|
+
*/
|
|
13
|
+
login(handler) {
|
|
14
|
+
addHandler(this.emitter, "login", handler);
|
|
15
|
+
}
|
|
16
|
+
progress(handler) {
|
|
17
|
+
addHandler(this.emitter, exports.DOWNLOAD_PROGRESS, handler);
|
|
18
|
+
}
|
|
19
|
+
updateDownloaded(handler) {
|
|
20
|
+
addHandler(this.emitter, exports.UPDATE_DOWNLOADED, handler);
|
|
21
|
+
}
|
|
22
|
+
updateCancelled(handler) {
|
|
23
|
+
addHandler(this.emitter, "update-cancelled", handler);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.UpdaterSignal = UpdaterSignal;
|
|
27
|
+
const isLogEvent = false;
|
|
28
|
+
function addHandler(emitter, event, handler) {
|
|
29
|
+
if (isLogEvent) {
|
|
30
|
+
emitter.on(event, (...args) => {
|
|
31
|
+
console.log("%s %s", event, args);
|
|
32
|
+
handler(...args);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
emitter.on(event, handler);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=event.js.map
|
package/out/event.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.js","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":";;;AAOa,QAAA,iBAAiB,GAAkB,mBAAmB,CAAA;AACtD,QAAA,iBAAiB,GAAkB,mBAAmB,CAAA;AAInE,MAAa,aAAa;IACxB,YAAoB,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;IAAG,CAAC;IAE7C;;OAEG;IACH,KAAK,CAAC,OAAqB;QACzB,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IAC5C,CAAC;IAED,QAAQ,CAAC,OAAqC;QAC5C,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,yBAAiB,EAAE,OAAO,CAAC,CAAA;IACtD,CAAC;IAED,gBAAgB,CAAC,OAA8C;QAC7D,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,yBAAiB,EAAE,OAAO,CAAC,CAAA;IACtD,CAAC;IAED,eAAe,CAAC,OAAmC;QACjD,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,kBAAkB,EAAE,OAAO,CAAC,CAAA;IACvD,CAAC;CACF;AArBD,sCAqBC;AAED,MAAM,UAAU,GAAG,KAAK,CAAA;AAExB,SAAS,UAAU,CAAC,OAAqB,EAAE,KAAoB,EAAE,OAAsC;IACrG,IAAI,UAAU,EAAE;QACd,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,IAAgB,EAAE,EAAE;YACxC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;YACjC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAA;QAClB,CAAC,CAAC,CAAA;KACH;SAAM;QACL,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;KAC3B;AACH,CAAC","sourcesContent":["import { CancellationToken, PackageFileInfo, ProgressInfo, UpdateFileInfo, UpdateInfo } from \"builder-util-runtime\"\nimport { EventEmitter } from \"events\"\nimport { URL } from \"url\"\nimport { LoginCallback } from \"./electronHttpExecutor\"\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 * 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\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 } else {\n emitter.on(event, handler)\n }\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 interface ResolvedUpdateFileInfo {\n readonly url: URL\n readonly info: UpdateFileInfo\n\n packageInfo?: PackageFileInfo\n}\n\nexport interface UpdateDownloadedEvent extends UpdateInfo {\n downloadedFile: string\n}\n"]}
|