electron-updater 6.0.0-alpha.2 → 6.0.0-alpha.4
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 +4 -8
- package/out/AppImageUpdater.js.map +1 -1
- package/out/BaseUpdater.d.ts +8 -0
- package/out/BaseUpdater.js +55 -0
- package/out/BaseUpdater.js.map +1 -1
- package/out/DebUpdater.d.ts +10 -0
- package/out/DebUpdater.js +37 -0
- package/out/DebUpdater.js.map +1 -0
- package/out/NsisUpdater.js +2 -28
- package/out/NsisUpdater.js.map +1 -1
- package/out/RpmUpdater.d.ts +10 -0
- package/out/RpmUpdater.js +63 -0
- package/out/RpmUpdater.js.map +1 -0
- package/out/main.d.ts +2 -0
- package/out/main.js +29 -1
- package/out/main.js.map +1 -1
- package/out/windowsExecutableCodeSignatureVerifier.js +3 -9
- package/out/windowsExecutableCodeSignatureVerifier.js.map +1 -1
- package/package.json +1 -1
package/out/AppImageUpdater.js
CHANGED
|
@@ -29,7 +29,7 @@ class AppImageUpdater extends BaseUpdater_1.BaseUpdater {
|
|
|
29
29
|
/*** @private */
|
|
30
30
|
doDownloadUpdate(downloadUpdateOptions) {
|
|
31
31
|
const provider = downloadUpdateOptions.updateInfoAndProvider.provider;
|
|
32
|
-
const fileInfo = (0, Provider_1.findFile)(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), "AppImage");
|
|
32
|
+
const fileInfo = (0, Provider_1.findFile)(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), "AppImage", ["rpm", "deb"]);
|
|
33
33
|
return this.executeDownload({
|
|
34
34
|
fileExtension: "AppImage",
|
|
35
35
|
fileInfo,
|
|
@@ -90,19 +90,15 @@ class AppImageUpdater extends BaseUpdater_1.BaseUpdater {
|
|
|
90
90
|
this.emit("appimage-filename-updated", destination);
|
|
91
91
|
}
|
|
92
92
|
const env = {
|
|
93
|
-
...process.env,
|
|
94
93
|
APPIMAGE_SILENT_INSTALL: "true",
|
|
95
94
|
};
|
|
96
95
|
if (options.isForceRunAfter) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
stdio: "ignore",
|
|
100
|
-
env,
|
|
101
|
-
}).unref();
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
97
|
+
this.spawnLog(destination, [], env);
|
|
102
98
|
}
|
|
103
99
|
else {
|
|
104
100
|
env.APPIMAGE_EXIT_AFTER_INSTALL = "true";
|
|
105
|
-
(0, child_process_1.execFileSync)(destination, [],
|
|
101
|
+
(0, child_process_1.execFileSync)(destination, [], env);
|
|
106
102
|
}
|
|
107
103
|
return true;
|
|
108
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppImageUpdater.js","sourceRoot":"","sources":["../src/AppImageUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAAkE;AAClE,
|
|
1
|
+
{"version":3,"file":"AppImageUpdater.js","sourceRoot":"","sources":["../src/AppImageUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAAkE;AAClE,iDAA4C;AAC5C,uCAAgC;AAChC,2BAA+B;AAC/B,6BAA4B;AAE5B,+CAA2D;AAE3D,4IAAwI;AACxI,iCAA0C;AAC1C,mDAA+C;AAE/C,MAAa,eAAgB,SAAQ,yBAAW;IAC9C,YAAY,OAAkC,EAAE,GAAS;QACvD,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACrB,CAAC;IAEM,eAAe;QACpB,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,IAAI,EAAE;YACnC,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE;gBAC/B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,qEAAqE,CAAC,CAAA;aACzF;iBAAM;gBACL,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAA;aAC9D;YACD,OAAO,KAAK,CAAA;SACb;QACD,OA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A;SAC1F;QAED,IAAA,4BAAY,EAAC,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC,CAAA;QAC9D,IAAI,WAAW,KAAK,YAAY,EAAE;YAChC,IAAI,CAAC,IAAI,CAAC,2BAA2B,EAAE,WAAW,CAAC,CAAA;SACpD;QAED,MAAM,GAAG,GAAQ;YACf,uBAAuB,EAAE,MAAM;SAChC,CAAA;QAED,IAAI,OAAO,CAAC,eAAe,EAAE;YAC3B,mEAAmE;YACnE,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;SACpC;aAAM;YACL,GAAG,CAAC,2BAA2B,GAAG,MAAM,CAAA;YACxC,IAAA,4BAAY,EAAC,WAAW,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;SACnC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AArGD,0CAqGC","sourcesContent":["import { AllPublishOptions, newError } from \"builder-util-runtime\"\nimport { execFileSync } from \"child_process\"\nimport { chmod } from \"fs-extra\"\nimport { unlinkSync } from \"fs\"\nimport * as path from \"path\"\nimport { DownloadUpdateOptions } from \"./AppUpdater\"\nimport { BaseUpdater, InstallOptions } from \"./BaseUpdater\"\nimport { DifferentialDownloaderOptions } from \"./differentialDownloader/DifferentialDownloader\"\nimport { FileWithEmbeddedBlockMapDifferentialDownloader } from \"./differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader\"\nimport { DOWNLOAD_PROGRESS } from \"./main\"\nimport { findFile } from \"./providers/Provider\"\n\nexport class AppImageUpdater extends BaseUpdater {\n constructor(options?: AllPublishOptions | null, app?: any) {\n super(options, app)\n }\n\n public isUpdaterActive(): boolean {\n if (process.env[\"APPIMAGE\"] == null) {\n if (process.env[\"SNAP\"] == null) {\n this._logger.warn(\"APPIMAGE env is not defined, current application is not an AppImage\")\n } else {\n this._logger.info(\"SNAP env is defined, updater is disabled\")\n }\n return false\n }\n return super.isUpdaterActive()\n }\n\n /*** @private */\n protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const fileInfo = findFile(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), \"AppImage\", [\"rpm\", \"deb\"])!\n return this.executeDownload({\n fileExtension: \"AppImage\",\n fileInfo,\n downloadUpdateOptions,\n task: async (updateFile, downloadOptions) => {\n const oldFile = process.env[\"APPIMAGE\"]!\n if (oldFile == null) {\n throw newError(\"APPIMAGE env is not defined\", \"ERR_UPDATER_OLD_FILE_NOT_FOUND\")\n }\n\n let isDownloadFull = false\n try {\n const downloadOptions: DifferentialDownloaderOptions = {\n newUrl: fileInfo.url,\n oldFile,\n logger: this._logger,\n newFile: updateFile,\n isUseMultipleRangeRequest: provider.isUseMultipleRangeRequest,\n requestHeaders: downloadUpdateOptions.requestHeaders,\n cancellationToken: downloadUpdateOptions.cancellationToken,\n }\n\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n\n await new FileWithEmbeddedBlockMapDifferentialDownloader(fileInfo.info, this.httpExecutor, downloadOptions).download()\n } catch (e: any) {\n this._logger.error(`Cannot download differentially, fallback to full download: ${e.stack || e}`)\n // during test (developer machine mac) we must throw error\n isDownloadFull = process.platform === \"linux\"\n }\n\n if (isDownloadFull) {\n await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions)\n }\n\n await chmod(updateFile, 0o755)\n },\n })\n }\n\n protected doInstall(options: InstallOptions): boolean {\n const appImageFile = process.env[\"APPIMAGE\"]!\n if (appImageFile == null) {\n throw newError(\"APPIMAGE env is not defined\", \"ERR_UPDATER_OLD_FILE_NOT_FOUND\")\n }\n\n // https://stackoverflow.com/a/1712051/1910191\n unlinkSync(appImageFile)\n\n let destination: string\n const existingBaseName = path.basename(appImageFile)\n // https://github.com/electron-userland/electron-builder/issues/2964\n // if no version in existing file name, it means that user wants to preserve current custom name\n if (path.basename(options.installerPath) === existingBaseName || !/\\d+\\.\\d+\\.\\d+/.test(existingBaseName)) {\n // no version in the file name, overwrite existing\n destination = appImageFile\n } else {\n destination = path.join(path.dirname(appImageFile), path.basename(options.installerPath))\n }\n\n execFileSync(\"mv\", [\"-f\", options.installerPath, destination])\n if (destination !== appImageFile) {\n this.emit(\"appimage-filename-updated\", destination)\n }\n\n const env: any = {\n APPIMAGE_SILENT_INSTALL: \"true\",\n }\n\n if (options.isForceRunAfter) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.spawnLog(destination, [], env)\n } else {\n env.APPIMAGE_EXIT_AFTER_INSTALL = \"true\"\n execFileSync(destination, [], env)\n }\n return true\n }\n}\n"]}
|
package/out/BaseUpdater.d.ts
CHANGED
|
@@ -10,6 +10,14 @@ export declare abstract class BaseUpdater extends AppUpdater {
|
|
|
10
10
|
protected abstract doInstall(options: InstallOptions): boolean;
|
|
11
11
|
protected install(isSilent: boolean, isForceRunAfter: boolean): boolean;
|
|
12
12
|
protected addQuitHandler(): void;
|
|
13
|
+
protected wrapSudo(): string;
|
|
14
|
+
protected spawnSyncLog(cmd: string, args?: string[], env?: {}): string;
|
|
15
|
+
/**
|
|
16
|
+
* This handles both node 8 and node 10 way of emitting error when spawning a process
|
|
17
|
+
* - node 8: Throws the error
|
|
18
|
+
* - node 10: Emit the error(Need to listen with on)
|
|
19
|
+
*/
|
|
20
|
+
protected spawnLog(cmd: string, args?: string[], env?: any): Promise<boolean>;
|
|
13
21
|
}
|
|
14
22
|
export interface InstallOptions {
|
|
15
23
|
readonly installerPath: string;
|
package/out/BaseUpdater.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseUpdater = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
4
5
|
const AppUpdater_1 = require("./AppUpdater");
|
|
5
6
|
class BaseUpdater extends AppUpdater_1.AppUpdater {
|
|
6
7
|
constructor(options, app) {
|
|
@@ -84,6 +85,60 @@ class BaseUpdater extends AppUpdater_1.AppUpdater {
|
|
|
84
85
|
this.install(true, false);
|
|
85
86
|
});
|
|
86
87
|
}
|
|
88
|
+
wrapSudo() {
|
|
89
|
+
const { name } = this.app;
|
|
90
|
+
const installComment = `"${name} would like to update"`;
|
|
91
|
+
const sudo = this.spawnSyncLog("which gksudo || which kdesudo || which pkexec || which beesu");
|
|
92
|
+
const command = [sudo];
|
|
93
|
+
if (/kdesudo/i.test(sudo)) {
|
|
94
|
+
command.push("--comment", installComment);
|
|
95
|
+
command.push("-c");
|
|
96
|
+
}
|
|
97
|
+
else if (/gksudo/i.test(sudo)) {
|
|
98
|
+
command.push("--message", installComment);
|
|
99
|
+
}
|
|
100
|
+
else if (/pkexec/i.test(sudo)) {
|
|
101
|
+
command.push("--disable-internal-agent");
|
|
102
|
+
}
|
|
103
|
+
return command.join(" ");
|
|
104
|
+
}
|
|
105
|
+
spawnSyncLog(cmd, args = [], env = {}) {
|
|
106
|
+
this._logger.info(`Executing: ${cmd} with args: ${args}`);
|
|
107
|
+
const response = (0, child_process_1.spawnSync)(cmd, args, {
|
|
108
|
+
stdio: "pipe",
|
|
109
|
+
env: { ...process.env, ...env },
|
|
110
|
+
encoding: "utf-8",
|
|
111
|
+
shell: true,
|
|
112
|
+
});
|
|
113
|
+
return response.stdout.trim();
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* This handles both node 8 and node 10 way of emitting error when spawning a process
|
|
117
|
+
* - node 8: Throws the error
|
|
118
|
+
* - node 10: Emit the error(Need to listen with on)
|
|
119
|
+
*/
|
|
120
|
+
// https://github.com/electron-userland/electron-builder/issues/1129
|
|
121
|
+
// Node 8 sends errors: https://nodejs.org/dist/latest-v8.x/docs/api/errors.html#errors_common_system_errors
|
|
122
|
+
async spawnLog(cmd, args = [], env = {}) {
|
|
123
|
+
this._logger.info(`Executing: ${cmd} with args: ${args}`);
|
|
124
|
+
return new Promise((resolve, reject) => {
|
|
125
|
+
try {
|
|
126
|
+
const p = (0, child_process_1.spawn)(cmd, args, {
|
|
127
|
+
stdio: "pipe",
|
|
128
|
+
env: { ...process.env, ...env },
|
|
129
|
+
detached: true,
|
|
130
|
+
});
|
|
131
|
+
p.on("error", error => {
|
|
132
|
+
reject(error);
|
|
133
|
+
});
|
|
134
|
+
p.unref();
|
|
135
|
+
resolve(p.pid !== undefined);
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
reject(error);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
87
142
|
}
|
|
88
143
|
exports.BaseUpdater = BaseUpdater;
|
|
89
144
|
//# sourceMappingURL=BaseUpdater.js.map
|
package/out/BaseUpdater.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseUpdater.js","sourceRoot":"","sources":["../src/BaseUpdater.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"BaseUpdater.js","sourceRoot":"","sources":["../src/BaseUpdater.ts"],"names":[],"mappings":";;;AACA,iDAAgD;AAEhD,6CAA+D;AAE/D,MAAsB,WAAY,SAAQ,uBAAU;IAIlD,YAAsB,OAAkC,EAAE,GAAgB;QACxE,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QAJX,yBAAoB,GAAG,KAAK,CAAA;QAC9B,qBAAgB,GAAG,KAAK,CAAA;IAIhC,CAAC;IAED,cAAc,CAAC,QAAQ,GAAG,KAAK,EAAE,eAAe,GAAG,KAAK;QACtD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAA;QACvD,+FAA+F;QAC/F,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;QACpG,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,GAAG,eAAe,IAAI,EAAE,CAAC,CAAA;QACzD,OAAO,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC9C,IAAI;gBACF,MAAM,CAAC,GAAG,IAAA,qBAAK,EAAC,GAAG,EAAE,IAAI,EAAE;oBACzB,KAAK,EAAE,MAAM;oBACb,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE;oBAC/B,QAAQ,EAAE,IAAI;iBACf,CAAC,CAAA;gBACF,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;oBACpB,MAAM,CAAC,KAAK,CAAC,CAAA;gBACf,CAAC,CAAC,CAAA;gBACF,CAAC,CAAC,KAAK,EAAE,CAAA;gBACT,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,SAAS,CAAC,CAAA;aAC7B;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,CAAC,KAAK,CAAC,CAAA;aACd;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAtJD,kCAsJC","sourcesContent":["import { AllPublishOptions } from \"builder-util-runtime\"\nimport { spawn, spawnSync } from \"child_process\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { AppUpdater, DownloadExecutorTask } from \"./AppUpdater\"\n\nexport abstract class BaseUpdater extends AppUpdater {\n protected quitAndInstallCalled = false\n private quitHandlerAdded = false\n\n protected constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n super(options, app)\n }\n\n quitAndInstall(isSilent = false, isForceRunAfter = false): void {\n this._logger.info(`Install on explicit quitAndInstall`)\n // If NOT in silent mode use `autoRunAppAfterInstall` to determine whether to force run the app\n const isInstalled = this.install(isSilent, isSilent ? isForceRunAfter : this.autoRunAppAfterInstall)\n if (isInstalled) {\n setImmediate(() => {\n // this event is normally emitted when calling quitAndInstall, this emulates that\n require(\"electron\").autoUpdater.emit(\"before-quit-for-update\")\n this.app.quit()\n })\n } else {\n this.quitAndInstallCalled = false\n }\n }\n\n protected executeDownload(taskOptions: DownloadExecutorTask): Promise<Array<string>> {\n return super.executeDownload({\n ...taskOptions,\n done: event => {\n this.dispatchUpdateDownloaded(event)\n this.addQuitHandler()\n return Promise.resolve()\n },\n })\n }\n\n // must be sync\n protected abstract doInstall(options: InstallOptions): boolean\n\n // must be sync (because quit even handler is not async)\n protected install(isSilent: boolean, isForceRunAfter: boolean): boolean {\n if (this.quitAndInstallCalled) {\n this._logger.warn(\"install call ignored: quitAndInstallCalled is set to true\")\n return false\n }\n\n const downloadedUpdateHelper = this.downloadedUpdateHelper\n const installerPath = downloadedUpdateHelper == null ? null : downloadedUpdateHelper.file\n const downloadedFileInfo = downloadedUpdateHelper == null ? null : downloadedUpdateHelper.downloadedFileInfo\n if (installerPath == null || downloadedFileInfo == null) {\n this.dispatchError(new Error(\"No valid update available, can't quit and install\"))\n return false\n }\n\n // prevent calling several times\n this.quitAndInstallCalled = true\n\n try {\n this._logger.info(`Install: isSilent: ${isSilent}, isForceRunAfter: ${isForceRunAfter}`)\n return this.doInstall({\n installerPath,\n isSilent,\n isForceRunAfter,\n isAdminRightsRequired: downloadedFileInfo.isAdminRightsRequired,\n })\n } catch (e: any) {\n this.dispatchError(e)\n return false\n }\n }\n\n protected addQuitHandler(): void {\n if (this.quitHandlerAdded || !this.autoInstallOnAppQuit) {\n return\n }\n\n this.quitHandlerAdded = true\n\n this.app.onQuit(exitCode => {\n if (this.quitAndInstallCalled) {\n this._logger.info(\"Update installer has already been triggered. Quitting application.\")\n return\n }\n\n if (!this.autoInstallOnAppQuit) {\n this._logger.info(\"Update will not be installed on quit because autoInstallOnAppQuit is set to false.\")\n return\n }\n\n if (exitCode !== 0) {\n this._logger.info(`Update will be not installed on quit because application is quitting with exit code ${exitCode}`)\n return\n }\n\n this._logger.info(\"Auto install update on quit\")\n this.install(true, false)\n })\n }\n\n protected wrapSudo() {\n const { name } = this.app\n const installComment = `\"${name} would like to update\"`\n const sudo = this.spawnSyncLog(\"which gksudo || which kdesudo || which pkexec || which beesu\")\n const command = [sudo]\n if (/kdesudo/i.test(sudo)) {\n command.push(\"--comment\", installComment)\n command.push(\"-c\")\n } else if (/gksudo/i.test(sudo)) {\n command.push(\"--message\", installComment)\n } else if (/pkexec/i.test(sudo)) {\n command.push(\"--disable-internal-agent\")\n }\n return command.join(\" \")\n }\n\n protected spawnSyncLog(cmd: string, args: string[] = [], env = {}): string {\n this._logger.info(`Executing: ${cmd} with args: ${args}`)\n const response = spawnSync(cmd, args, {\n stdio: \"pipe\",\n env: { ...process.env, ...env },\n encoding: \"utf-8\",\n shell: true,\n })\n return response.stdout.trim()\n }\n\n /**\n * This handles both node 8 and node 10 way of emitting error when spawning a process\n * - node 8: Throws the error\n * - node 10: Emit the error(Need to listen with on)\n */\n // https://github.com/electron-userland/electron-builder/issues/1129\n // Node 8 sends errors: https://nodejs.org/dist/latest-v8.x/docs/api/errors.html#errors_common_system_errors\n protected async spawnLog(cmd: string, args: string[] = [], env: any = {}): Promise<boolean> {\n this._logger.info(`Executing: ${cmd} with args: ${args}`)\n return new Promise<boolean>((resolve, reject) => {\n try {\n const p = spawn(cmd, args, {\n stdio: \"pipe\",\n env: { ...process.env, ...env },\n detached: true,\n })\n p.on(\"error\", error => {\n reject(error)\n })\n p.unref()\n resolve(p.pid !== undefined)\n } catch (error) {\n reject(error)\n }\n })\n }\n}\n\nexport interface InstallOptions {\n readonly installerPath: string\n readonly isSilent: boolean\n readonly isForceRunAfter: boolean\n readonly isAdminRightsRequired: boolean\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AllPublishOptions } from "builder-util-runtime";
|
|
2
|
+
import { AppAdapter } from "./AppAdapter";
|
|
3
|
+
import { DownloadUpdateOptions } from "./AppUpdater";
|
|
4
|
+
import { BaseUpdater, InstallOptions } from "./BaseUpdater";
|
|
5
|
+
export declare class DebUpdater extends BaseUpdater {
|
|
6
|
+
constructor(options?: AllPublishOptions | null, app?: AppAdapter);
|
|
7
|
+
/*** @private */
|
|
8
|
+
protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>>;
|
|
9
|
+
protected doInstall(options: InstallOptions): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DebUpdater = void 0;
|
|
4
|
+
const BaseUpdater_1 = require("./BaseUpdater");
|
|
5
|
+
const main_1 = require("./main");
|
|
6
|
+
const Provider_1 = require("./providers/Provider");
|
|
7
|
+
class DebUpdater extends BaseUpdater_1.BaseUpdater {
|
|
8
|
+
constructor(options, app) {
|
|
9
|
+
super(options, app);
|
|
10
|
+
}
|
|
11
|
+
/*** @private */
|
|
12
|
+
doDownloadUpdate(downloadUpdateOptions) {
|
|
13
|
+
const provider = downloadUpdateOptions.updateInfoAndProvider.provider;
|
|
14
|
+
const fileInfo = (0, Provider_1.findFile)(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), "deb", ["AppImage", "rpm"]);
|
|
15
|
+
return this.executeDownload({
|
|
16
|
+
fileExtension: "deb",
|
|
17
|
+
fileInfo,
|
|
18
|
+
downloadUpdateOptions,
|
|
19
|
+
task: async (updateFile, downloadOptions) => {
|
|
20
|
+
if (this.listenerCount(main_1.DOWNLOAD_PROGRESS) > 0) {
|
|
21
|
+
downloadOptions.onProgress = it => this.emit(main_1.DOWNLOAD_PROGRESS, it);
|
|
22
|
+
}
|
|
23
|
+
await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
doInstall(options) {
|
|
28
|
+
const sudo = this.wrapSudo();
|
|
29
|
+
// pkexec doesn't want the command to be wrapped in " quotes
|
|
30
|
+
const wrapper = /pkexec/i.test(sudo) ? "" : `"`;
|
|
31
|
+
const cmd = ["dpkg", "-i", options.installerPath, "||", "apt-get", "install", "-f", "-y"];
|
|
32
|
+
this.spawnSyncLog(sudo, [`${wrapper}/bin/bash`, "-c", `'${cmd.join(" ")}'${wrapper}`]);
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.DebUpdater = DebUpdater;
|
|
37
|
+
//# sourceMappingURL=DebUpdater.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DebUpdater.js","sourceRoot":"","sources":["../src/DebUpdater.ts"],"names":[],"mappings":";;;AAGA,+CAA2D;AAC3D,iCAA0C;AAC1C,mDAA+C;AAE/C,MAAa,UAAW,SAAQ,yBAAW;IACzC,YAAY,OAAkC,EAAE,GAAgB;QAC9D,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACrB,CAAC;IAED,gBAAgB;IACN,gBAAgB,CAAC,qBAA4C;QACrE,MAAM,QAAQ,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,QAAQ,CAAA;QACrE,MAAM,QAAQ,GAAG,IAAA,mBAAQ,EAAC,QAAQ,CAAC,YAAY,CAAC,qBAAqB,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC,CAAE,CAAA;QAC/H,OAAO,IAAI,CAAC,eAAe,CAAC;YAC1B,aAAa,EAAE,KAAK;YACpB,QAAQ;YACR,qBAAqB;YACrB,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,EAAE;gBAC1C,IAAI,IAAI,CAAC,aAAa,CAAC,wBAAiB,CAAC,GAAG,CAAC,EAAE;oBAC7C,eAAe,CAAC,UAAU,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,wBAAiB,EAAE,EAAE,CAAC,CAAA;iBACpE;gBACD,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,eAAe,CAAC,CAAA;YAC7E,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;IAES,SAAS,CAAC,OAAuB;QACzC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;QAC5B,4DAA4D;QAC5D,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA;QAC/C,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;QACzF,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,WAAW,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAA;QACtF,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AA9BD,gCA8BC","sourcesContent":["import { AllPublishOptions } from \"builder-util-runtime\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { DownloadUpdateOptions } from \"./AppUpdater\"\nimport { BaseUpdater, InstallOptions } from \"./BaseUpdater\"\nimport { DOWNLOAD_PROGRESS } from \"./main\"\nimport { findFile } from \"./providers/Provider\"\n\nexport class DebUpdater extends BaseUpdater {\n constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n super(options, app)\n }\n\n /*** @private */\n protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const fileInfo = findFile(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), \"deb\", [\"AppImage\", \"rpm\"])!\n return this.executeDownload({\n fileExtension: \"deb\",\n fileInfo,\n downloadUpdateOptions,\n task: async (updateFile, downloadOptions) => {\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions)\n },\n })\n }\n\n protected doInstall(options: InstallOptions): boolean {\n const sudo = this.wrapSudo()\n // pkexec doesn't want the command to be wrapped in \" quotes\n const wrapper = /pkexec/i.test(sudo) ? \"\" : `\"`\n const cmd = [\"dpkg\", \"-i\", options.installerPath, \"||\", \"apt-get\", \"install\", \"-f\", \"-y\"]\n this.spawnSyncLog(sudo, [`${wrapper}/bin/bash`, \"-c\", `'${cmd.join(\" \")}'${wrapper}`])\n return true\n }\n}\n"]}
|
package/out/NsisUpdater.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NsisUpdater = void 0;
|
|
4
4
|
const builder_util_runtime_1 = require("builder-util-runtime");
|
|
5
|
-
const child_process_1 = require("child_process");
|
|
6
5
|
const path = require("path");
|
|
7
6
|
const BaseUpdater_1 = require("./BaseUpdater");
|
|
8
7
|
const FileWithEmbeddedBlockMapDifferentialDownloader_1 = require("./differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader");
|
|
@@ -105,14 +104,14 @@ class NsisUpdater extends BaseUpdater_1.BaseUpdater {
|
|
|
105
104
|
args.push(`--package-file=${packagePath}`);
|
|
106
105
|
}
|
|
107
106
|
const callUsingElevation = () => {
|
|
108
|
-
|
|
107
|
+
this.spawnLog(path.join(process.resourcesPath, "elevate.exe"), [options.installerPath].concat(args)).catch(e => this.dispatchError(e));
|
|
109
108
|
};
|
|
110
109
|
if (options.isAdminRightsRequired) {
|
|
111
110
|
this._logger.info("isAdminRightsRequired is set to true, run installer using elevate.exe");
|
|
112
111
|
callUsingElevation();
|
|
113
112
|
return true;
|
|
114
113
|
}
|
|
115
|
-
|
|
114
|
+
this.spawnLog(options.installerPath, args).catch((e) => {
|
|
116
115
|
// https://github.com/electron-userland/electron-builder/issues/1129
|
|
117
116
|
// Node 8 sends errors: https://nodejs.org/dist/latest-v8.x/docs/api/errors.html#errors_common_system_errors
|
|
118
117
|
const errorCode = e.code;
|
|
@@ -201,29 +200,4 @@ class NsisUpdater extends BaseUpdater_1.BaseUpdater {
|
|
|
201
200
|
}
|
|
202
201
|
}
|
|
203
202
|
exports.NsisUpdater = NsisUpdater;
|
|
204
|
-
/**
|
|
205
|
-
* This handles both node 8 and node 10 way of emitting error when spawning a process
|
|
206
|
-
* - node 8: Throws the error
|
|
207
|
-
* - node 10: Emit the error(Need to listen with on)
|
|
208
|
-
*/
|
|
209
|
-
async function _spawn(exe, args) {
|
|
210
|
-
return new Promise((resolve, reject) => {
|
|
211
|
-
try {
|
|
212
|
-
const process = (0, child_process_1.spawn)(exe, args, {
|
|
213
|
-
detached: true,
|
|
214
|
-
stdio: "ignore",
|
|
215
|
-
});
|
|
216
|
-
process.on("error", error => {
|
|
217
|
-
reject(error);
|
|
218
|
-
});
|
|
219
|
-
process.unref();
|
|
220
|
-
if (process.pid !== undefined) {
|
|
221
|
-
resolve(true);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
catch (error) {
|
|
225
|
-
reject(error);
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
203
|
//# sourceMappingURL=NsisUpdater.js.map
|
package/out/NsisUpdater.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NsisUpdater.js","sourceRoot":"","sources":["../src/NsisUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAA6J;AAC7J,iDAAqC;AACrC,6BAA4B;AAG5B,+CAA2D;AAE3D,4IAAwI;AACxI,0GAAsG;AACtG,iCAAkE;AAClE,iCAAsC;AACtC,mDAAyD;AACzD,uCAAiC;AACjC,qGAA0E;AAC1E,6BAAyB;AACzB,+BAAiC;AAEjC,MAAa,WAAY,SAAQ,yBAAW;IAO1C,YAAY,OAAkC,EAAE,GAAgB;QAC9D,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACrB,CAAC;IAED,gBAAgB;IACN,g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,eAAe,CAAC,CAAC,QAAQ,EAAE,CAAA;SACrH;QAAC,OAAO,CAAM,EAAE;YACf,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,8DAA8D,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC,CAAA;YAChG,mEAAmE;YACnE,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAA;SACpC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF;AAjOD,kCAiOC;AAED;;;;GAIG;AACH,KAAK,UAAU,MAAM,CAAC,GAAW,EAAE,IAAmB;IACpD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI;YACF,MAAM,OAAO,GAAG,IAAA,qBAAK,EAAC,GAAG,EAAE,IAAI,EAAE;gBAC/B,QAAQ,EAAE,IAAI;gBACd,KAAK,EAAE,QAAQ;aAChB,CAAC,CAAA;YACF,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;gBAC1B,MAAM,CAAC,KAAK,CAAC,CAAA;YACf,CAAC,CAAC,CAAA;YACF,OAAO,CAAC,KAAK,EAAE,CAAA;YAEf,IAAI,OAAO,CAAC,GAAG,KAAK,SAAS,EAAE;gBAC7B,OAAO,CAAC,IAAI,CAAC,CAAA;aACd;SACF;QAAC,OAAO,KAAU,EAAE;YACnB,MAAM,CAAC,KAAK,CAAC,CAAA;SACd;IACH,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { AllPublishOptions, newError, PackageFileInfo, BlockMap, CURRENT_APP_PACKAGE_FILE_NAME, CURRENT_APP_INSTALLER_FILE_NAME } from \"builder-util-runtime\"\nimport { spawn } from \"child_process\"\nimport * as path from \"path\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { DownloadUpdateOptions } from \"./AppUpdater\"\nimport { BaseUpdater, InstallOptions } from \"./BaseUpdater\"\nimport { DifferentialDownloaderOptions } from \"./differentialDownloader/DifferentialDownloader\"\nimport { FileWithEmbeddedBlockMapDifferentialDownloader } from \"./differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader\"\nimport { GenericDifferentialDownloader } from \"./differentialDownloader/GenericDifferentialDownloader\"\nimport { DOWNLOAD_PROGRESS, ResolvedUpdateFileInfo } from \"./main\"\nimport { blockmapFiles } from \"./util\"\nimport { findFile, Provider } from \"./providers/Provider\"\nimport { unlink } from \"fs-extra\"\nimport { verifySignature } from \"./windowsExecutableCodeSignatureVerifier\"\nimport { URL } from \"url\"\nimport { gunzipSync } from \"zlib\"\n\nexport class NsisUpdater extends BaseUpdater {\n /**\n * Specify custom install directory path\n *\n */\n installDirectory?: string\n\n constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n super(options, app)\n }\n\n /*** @private */\n protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const fileInfo = findFile(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), \"exe\")!\n return this.executeDownload({\n fileExtension: \"exe\",\n downloadUpdateOptions,\n fileInfo,\n task: async (destinationFile, downloadOptions, packageFile, removeTempDirIfAny) => {\n const packageInfo = fileInfo.packageInfo\n const isWebInstaller = packageInfo != null && packageFile != null\n if (isWebInstaller && downloadUpdateOptions.disableWebInstaller) {\n throw newError(\n `Unable to download new version ${downloadUpdateOptions.updateInfoAndProvider.info.version}. Web Installers are disabled`,\n \"ERR_UPDATER_WEB_INSTALLER_DISABLED\"\n )\n }\n if (!isWebInstaller && !downloadUpdateOptions.disableWebInstaller) {\n this._logger.warn(\n \"disableWebInstaller is set to false, you should set it to true if you do not plan on using a web installer. This will default to true in a future version.\"\n )\n }\n if (isWebInstaller || (await this.differentialDownloadInstaller(fileInfo, downloadUpdateOptions, destinationFile, provider))) {\n await this.httpExecutor.download(fileInfo.url, destinationFile, downloadOptions)\n }\n\n const signatureVerificationStatus = await this.verifySignature(destinationFile)\n if (signatureVerificationStatus != null) {\n await removeTempDirIfAny()\n // noinspection ThrowInsideFinallyBlockJS\n throw newError(\n `New version ${downloadUpdateOptions.updateInfoAndProvider.info.version} is not signed by the application owner: ${signatureVerificationStatus}`,\n \"ERR_UPDATER_INVALID_SIGNATURE\"\n )\n }\n\n if (isWebInstaller) {\n if (await this.differentialDownloadWebPackage(downloadUpdateOptions, packageInfo, packageFile, provider)) {\n try {\n await this.httpExecutor.download(new URL(packageInfo.path), packageFile, {\n headers: downloadUpdateOptions.requestHeaders,\n cancellationToken: downloadUpdateOptions.cancellationToken,\n sha512: packageInfo.sha512,\n })\n } catch (e: any) {\n try {\n await unlink(packageFile)\n } catch (ignored) {\n // ignore\n }\n\n throw e\n }\n }\n }\n },\n })\n }\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 }\n private async verifySignature(tempUpdateFile: string): Promise<string | null> {\n let publisherName: Array<string> | string | null\n try {\n publisherName = (await this.configOnDisk.value).publisherName\n if (publisherName == null) {\n return null\n }\n } catch (e: any) {\n if (e.code === \"ENOENT\") {\n // no app-update.yml\n return null\n }\n throw e\n }\n return await verifySignature(Array.isArray(publisherName) ? publisherName : [publisherName], tempUpdateFile, this._logger)\n }\n\n protected doInstall(options: InstallOptions): boolean {\n const args = [\"--updated\"]\n if (options.isSilent) {\n args.push(\"/S\")\n }\n\n if (options.isForceRunAfter) {\n args.push(\"--force-run\")\n }\n\n if (this.installDirectory) {\n // maybe check if folder exists\n args.push(`/D=${this.installDirectory}`)\n }\n\n const packagePath = this.downloadedUpdateHelper == null ? null : this.downloadedUpdateHelper.packageFile\n if (packagePath != null) {\n // only = form is supported\n args.push(`--package-file=${packagePath}`)\n }\n\n const callUsingElevation = (): void => {\n _spawn(path.join(process.resourcesPath!, \"elevate.exe\"), [options.installerPath].concat(args)).catch((e: any) => this.dispatchError(e))\n }\n\n if (options.isAdminRightsRequired) {\n this._logger.info(\"isAdminRightsRequired is set to true, run installer using elevate.exe\")\n callUsingElevation()\n return true\n }\n\n _spawn(options.installerPath, args).catch((e: Error) => {\n // https://github.com/electron-userland/electron-builder/issues/1129\n // Node 8 sends errors: https://nodejs.org/dist/latest-v8.x/docs/api/errors.html#errors_common_system_errors\n const errorCode = (e as NodeJS.ErrnoException).code\n this._logger.info(`Cannot run installer: error code: ${errorCode}, error message: \"${e.message}\", will be executed again using elevate if EACCES\"`)\n if (errorCode === \"UNKNOWN\" || errorCode === \"EACCES\") {\n callUsingElevation()\n } else {\n this.dispatchError(e)\n }\n })\n return true\n }\n\n private async differentialDownloadInstaller(\n fileInfo: ResolvedUpdateFileInfo,\n downloadUpdateOptions: DownloadUpdateOptions,\n installerPath: string,\n provider: Provider<any>\n ): Promise<boolean> {\n try {\n if (this._testOnlyOptions != null && !this._testOnlyOptions.isUseDifferentialDownload) {\n return true\n }\n const blockmapFileUrls = blockmapFiles(fileInfo.url, this.app.version, downloadUpdateOptions.updateInfoAndProvider.info.version)\n this._logger.info(`Download block maps (old: \"${blockmapFileUrls[0]}\", new: ${blockmapFileUrls[1]})`)\n\n const downloadBlockMap = async (url: URL): Promise<BlockMap> => {\n const data = await this.httpExecutor.downloadToBuffer(url, {\n headers: downloadUpdateOptions.requestHeaders,\n cancellationToken: downloadUpdateOptions.cancellationToken,\n })\n\n if (data == null || data.length === 0) {\n throw new Error(`Blockmap \"${url.href}\" is empty`)\n }\n\n try {\n return JSON.parse(gunzipSync(data).toString())\n } catch (e: any) {\n throw new Error(`Cannot parse blockmap \"${url.href}\", error: ${e}`)\n }\n }\n\n const downloadOptions: DifferentialDownloaderOptions = {\n newUrl: fileInfo.url,\n oldFile: path.join(this.downloadedUpdateHelper!.cacheDir, CURRENT_APP_INSTALLER_FILE_NAME),\n logger: this._logger,\n newFile: installerPath,\n isUseMultipleRangeRequest: provider.isUseMultipleRangeRequest,\n requestHeaders: downloadUpdateOptions.requestHeaders,\n cancellationToken: downloadUpdateOptions.cancellationToken,\n }\n\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n\n const blockMapDataList = await Promise.all(blockmapFileUrls.map(u => downloadBlockMap(u)))\n await new GenericDifferentialDownloader(fileInfo.info, this.httpExecutor, downloadOptions).download(blockMapDataList[0], blockMapDataList[1])\n return false\n } catch (e: any) {\n this._logger.error(`Cannot download differentially, fallback to full download: ${e.stack || e}`)\n if (this._testOnlyOptions != null) {\n // test mode\n throw e\n }\n return true\n }\n }\n\n private async differentialDownloadWebPackage(\n downloadUpdateOptions: DownloadUpdateOptions,\n packageInfo: PackageFileInfo,\n packagePath: string,\n provider: Provider<any>\n ): Promise<boolean> {\n if (packageInfo.blockMapSize == null) {\n return true\n }\n\n try {\n const downloadOptions: DifferentialDownloaderOptions = {\n newUrl: new URL(packageInfo.path),\n oldFile: path.join(this.downloadedUpdateHelper!.cacheDir, CURRENT_APP_PACKAGE_FILE_NAME),\n logger: this._logger,\n newFile: packagePath,\n requestHeaders: this.requestHeaders,\n isUseMultipleRangeRequest: provider.isUseMultipleRangeRequest,\n cancellationToken: downloadUpdateOptions.cancellationToken,\n }\n\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n\n await new FileWithEmbeddedBlockMapDifferentialDownloader(packageInfo, this.httpExecutor, downloadOptions).download()\n } catch (e: any) {\n this._logger.error(`Cannot download differentially, fallback to full download: ${e.stack || e}`)\n // during test (developer machine mac or linux) we must throw error\n return process.platform === \"win32\"\n }\n return false\n }\n}\n\n/**\n * This handles both node 8 and node 10 way of emitting error when spawning a process\n * - node 8: Throws the error\n * - node 10: Emit the error(Need to listen with on)\n */\nasync function _spawn(exe: string, args: Array<string>): Promise<any> {\n return new Promise((resolve, reject) => {\n try {\n const process = spawn(exe, args, {\n detached: true,\n stdio: \"ignore\",\n })\n process.on(\"error\", error => {\n reject(error)\n })\n process.unref()\n\n if (process.pid !== undefined) {\n resolve(true)\n }\n } catch (error: any) {\n reject(error)\n }\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NsisUpdater.js","sourceRoot":"","sources":["../src/NsisUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAA6J;AAC7J,6BAA4B;AAG5B,+CAA2D;AAE3D,4IAAwI;AACxI,0GAAsG;AACtG,iCAAkE;AAClE,iCAAsC;AACtC,mDAAyD;AACzD,uCAAiC;AACjC,qGAA0E;AAC1E,6BAAyB;AACzB,+BAAiC;AAEjC,MAAa,WAAY,SAAQ,yBAAW;IAO1C,YAAY,OAAkC,EAAE,GAAgB;QAC9D,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACrB,CAAC;IAED,gBAAgB;IACN,gBAAgB,CAAC,qBAA4C;QACrE,MAAM,QAAQ,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,QAAQ,CAAA;QACrE,MAAM,QAAQ,GAAG,IAAA,mBAAQ,EAAC,QAAQ,CAAC,YAAY,CAAC,qBAAqB,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,KAAK,CAAE,CAAA;QAC1G,OAAO,IAAI,CAAC,eAAe,CAAC;YAC1B,aAAa,EAAE,KAAK;YACpB,qBAAqB;YACrB,QAAQ;YACR,IAAI,EAAE,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,kBAAkB,EAAE,EAAE;gBAChF,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAA;gBACxC,MAAM,cAAc,GAAG,WAAW,IAAI,IAAI,IAAI,WAAW,IAAI,IAAI,CAAA;gBACjE,IAAI,cAAc,IAAI,qBAAqB,CAAC,mBAAmB,EAAE;oBAC/D,MAAM,IAAA,+BAAQ,EACZ,kCAAkC,qBAAqB,CAAC,qBAAqB,CAAC,IAAI,CAAC,OAA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AAG,CAAC,WAAW,CAAC,IAAI,CAAC;gBACjC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAuB,CAAC,QAAQ,EAAE,oDAA6B,CAAC;gBACxF,MAAM,EAAE,IAAI,CAAC,OAAO;gBACpB,OAAO,EAAE,WAAW;gBACpB,cAAc,EAAE,IAAI,CAAC,cAAc;gBACnC,yBAAyB,EAAE,QAAQ,CAAC,yBAAyB;gBAC7D,iBAAiB,EAAE,qBAAqB,CAAC,iBAAiB;aAC3D,CAAA;YAED,IAAI,IAAI,CAAC,aAAa,CAAC,wBAAiB,CAAC,GAAG,CAAC,EAAE;gBAC7C,eAAe,CAAC,UAAU,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,wBAAiB,EAAE,EAAE,CAAC,CAAA;aACpE;YAED,MAAM,IAAI,+FAA8C,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,QAAQ,EAAE,CAAA;SACrH;QAAC,OAAO,CAAM,EAAE;YACf,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,8DAA8D,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC,CAAA;YAChG,mEAAmE;YACnE,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAA;SACpC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF;AAjOD,kCAiOC","sourcesContent":["import { AllPublishOptions, newError, PackageFileInfo, BlockMap, CURRENT_APP_PACKAGE_FILE_NAME, CURRENT_APP_INSTALLER_FILE_NAME } from \"builder-util-runtime\"\nimport * as path from \"path\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { DownloadUpdateOptions } from \"./AppUpdater\"\nimport { BaseUpdater, InstallOptions } from \"./BaseUpdater\"\nimport { DifferentialDownloaderOptions } from \"./differentialDownloader/DifferentialDownloader\"\nimport { FileWithEmbeddedBlockMapDifferentialDownloader } from \"./differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader\"\nimport { GenericDifferentialDownloader } from \"./differentialDownloader/GenericDifferentialDownloader\"\nimport { DOWNLOAD_PROGRESS, ResolvedUpdateFileInfo } from \"./main\"\nimport { blockmapFiles } from \"./util\"\nimport { findFile, Provider } from \"./providers/Provider\"\nimport { unlink } from \"fs-extra\"\nimport { verifySignature } from \"./windowsExecutableCodeSignatureVerifier\"\nimport { URL } from \"url\"\nimport { gunzipSync } from \"zlib\"\n\nexport class NsisUpdater extends BaseUpdater {\n /**\n * Specify custom install directory path\n *\n */\n installDirectory?: string\n\n constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n super(options, app)\n }\n\n /*** @private */\n protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const fileInfo = findFile(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), \"exe\")!\n return this.executeDownload({\n fileExtension: \"exe\",\n downloadUpdateOptions,\n fileInfo,\n task: async (destinationFile, downloadOptions, packageFile, removeTempDirIfAny) => {\n const packageInfo = fileInfo.packageInfo\n const isWebInstaller = packageInfo != null && packageFile != null\n if (isWebInstaller && downloadUpdateOptions.disableWebInstaller) {\n throw newError(\n `Unable to download new version ${downloadUpdateOptions.updateInfoAndProvider.info.version}. Web Installers are disabled`,\n \"ERR_UPDATER_WEB_INSTALLER_DISABLED\"\n )\n }\n if (!isWebInstaller && !downloadUpdateOptions.disableWebInstaller) {\n this._logger.warn(\n \"disableWebInstaller is set to false, you should set it to true if you do not plan on using a web installer. This will default to true in a future version.\"\n )\n }\n if (isWebInstaller || (await this.differentialDownloadInstaller(fileInfo, downloadUpdateOptions, destinationFile, provider))) {\n await this.httpExecutor.download(fileInfo.url, destinationFile, downloadOptions)\n }\n\n const signatureVerificationStatus = await this.verifySignature(destinationFile)\n if (signatureVerificationStatus != null) {\n await removeTempDirIfAny()\n // noinspection ThrowInsideFinallyBlockJS\n throw newError(\n `New version ${downloadUpdateOptions.updateInfoAndProvider.info.version} is not signed by the application owner: ${signatureVerificationStatus}`,\n \"ERR_UPDATER_INVALID_SIGNATURE\"\n )\n }\n\n if (isWebInstaller) {\n if (await this.differentialDownloadWebPackage(downloadUpdateOptions, packageInfo, packageFile, provider)) {\n try {\n await this.httpExecutor.download(new URL(packageInfo.path), packageFile, {\n headers: downloadUpdateOptions.requestHeaders,\n cancellationToken: downloadUpdateOptions.cancellationToken,\n sha512: packageInfo.sha512,\n })\n } catch (e: any) {\n try {\n await unlink(packageFile)\n } catch (ignored) {\n // ignore\n }\n\n throw e\n }\n }\n }\n },\n })\n }\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 }\n private async verifySignature(tempUpdateFile: string): Promise<string | null> {\n let publisherName: Array<string> | string | null\n try {\n publisherName = (await this.configOnDisk.value).publisherName\n if (publisherName == null) {\n return null\n }\n } catch (e: any) {\n if (e.code === \"ENOENT\") {\n // no app-update.yml\n return null\n }\n throw e\n }\n return await verifySignature(Array.isArray(publisherName) ? publisherName : [publisherName], tempUpdateFile, this._logger)\n }\n\n protected doInstall(options: InstallOptions): boolean {\n const args = [\"--updated\"]\n if (options.isSilent) {\n args.push(\"/S\")\n }\n\n if (options.isForceRunAfter) {\n args.push(\"--force-run\")\n }\n\n if (this.installDirectory) {\n // maybe check if folder exists\n args.push(`/D=${this.installDirectory}`)\n }\n\n const packagePath = this.downloadedUpdateHelper == null ? null : this.downloadedUpdateHelper.packageFile\n if (packagePath != null) {\n // only = form is supported\n args.push(`--package-file=${packagePath}`)\n }\n\n const callUsingElevation = (): void => {\n this.spawnLog(path.join(process.resourcesPath!, \"elevate.exe\"), [options.installerPath].concat(args)).catch(e => this.dispatchError(e))\n }\n\n if (options.isAdminRightsRequired) {\n this._logger.info(\"isAdminRightsRequired is set to true, run installer using elevate.exe\")\n callUsingElevation()\n return true\n }\n\n this.spawnLog(options.installerPath, args).catch((e: Error) => {\n // https://github.com/electron-userland/electron-builder/issues/1129\n // Node 8 sends errors: https://nodejs.org/dist/latest-v8.x/docs/api/errors.html#errors_common_system_errors\n const errorCode = (e as NodeJS.ErrnoException).code\n this._logger.info(`Cannot run installer: error code: ${errorCode}, error message: \"${e.message}\", will be executed again using elevate if EACCES\"`)\n if (errorCode === \"UNKNOWN\" || errorCode === \"EACCES\") {\n callUsingElevation()\n } else {\n this.dispatchError(e)\n }\n })\n return true\n }\n\n private async differentialDownloadInstaller(\n fileInfo: ResolvedUpdateFileInfo,\n downloadUpdateOptions: DownloadUpdateOptions,\n installerPath: string,\n provider: Provider<any>\n ): Promise<boolean> {\n try {\n if (this._testOnlyOptions != null && !this._testOnlyOptions.isUseDifferentialDownload) {\n return true\n }\n const blockmapFileUrls = blockmapFiles(fileInfo.url, this.app.version, downloadUpdateOptions.updateInfoAndProvider.info.version)\n this._logger.info(`Download block maps (old: \"${blockmapFileUrls[0]}\", new: ${blockmapFileUrls[1]})`)\n\n const downloadBlockMap = async (url: URL): Promise<BlockMap> => {\n const data = await this.httpExecutor.downloadToBuffer(url, {\n headers: downloadUpdateOptions.requestHeaders,\n cancellationToken: downloadUpdateOptions.cancellationToken,\n })\n\n if (data == null || data.length === 0) {\n throw new Error(`Blockmap \"${url.href}\" is empty`)\n }\n\n try {\n return JSON.parse(gunzipSync(data).toString())\n } catch (e: any) {\n throw new Error(`Cannot parse blockmap \"${url.href}\", error: ${e}`)\n }\n }\n\n const downloadOptions: DifferentialDownloaderOptions = {\n newUrl: fileInfo.url,\n oldFile: path.join(this.downloadedUpdateHelper!.cacheDir, CURRENT_APP_INSTALLER_FILE_NAME),\n logger: this._logger,\n newFile: installerPath,\n isUseMultipleRangeRequest: provider.isUseMultipleRangeRequest,\n requestHeaders: downloadUpdateOptions.requestHeaders,\n cancellationToken: downloadUpdateOptions.cancellationToken,\n }\n\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n\n const blockMapDataList = await Promise.all(blockmapFileUrls.map(u => downloadBlockMap(u)))\n await new GenericDifferentialDownloader(fileInfo.info, this.httpExecutor, downloadOptions).download(blockMapDataList[0], blockMapDataList[1])\n return false\n } catch (e: any) {\n this._logger.error(`Cannot download differentially, fallback to full download: ${e.stack || e}`)\n if (this._testOnlyOptions != null) {\n // test mode\n throw e\n }\n return true\n }\n }\n\n private async differentialDownloadWebPackage(\n downloadUpdateOptions: DownloadUpdateOptions,\n packageInfo: PackageFileInfo,\n packagePath: string,\n provider: Provider<any>\n ): Promise<boolean> {\n if (packageInfo.blockMapSize == null) {\n return true\n }\n\n try {\n const downloadOptions: DifferentialDownloaderOptions = {\n newUrl: new URL(packageInfo.path),\n oldFile: path.join(this.downloadedUpdateHelper!.cacheDir, CURRENT_APP_PACKAGE_FILE_NAME),\n logger: this._logger,\n newFile: packagePath,\n requestHeaders: this.requestHeaders,\n isUseMultipleRangeRequest: provider.isUseMultipleRangeRequest,\n cancellationToken: downloadUpdateOptions.cancellationToken,\n }\n\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n\n await new FileWithEmbeddedBlockMapDifferentialDownloader(packageInfo, this.httpExecutor, downloadOptions).download()\n } catch (e: any) {\n this._logger.error(`Cannot download differentially, fallback to full download: ${e.stack || e}`)\n // during test (developer machine mac or linux) we must throw error\n return process.platform === \"win32\"\n }\n return false\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AllPublishOptions } from "builder-util-runtime";
|
|
2
|
+
import { AppAdapter } from "./AppAdapter";
|
|
3
|
+
import { DownloadUpdateOptions } from "./AppUpdater";
|
|
4
|
+
import { BaseUpdater, InstallOptions } from "./BaseUpdater";
|
|
5
|
+
export declare class RpmUpdater extends BaseUpdater {
|
|
6
|
+
constructor(options?: AllPublishOptions | null, app?: AppAdapter);
|
|
7
|
+
/*** @private */
|
|
8
|
+
protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>>;
|
|
9
|
+
protected doInstall(options: InstallOptions): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RpmUpdater = void 0;
|
|
4
|
+
const BaseUpdater_1 = require("./BaseUpdater");
|
|
5
|
+
const main_1 = require("./main");
|
|
6
|
+
const Provider_1 = require("./providers/Provider");
|
|
7
|
+
class RpmUpdater extends BaseUpdater_1.BaseUpdater {
|
|
8
|
+
constructor(options, app) {
|
|
9
|
+
super(options, app);
|
|
10
|
+
}
|
|
11
|
+
/*** @private */
|
|
12
|
+
doDownloadUpdate(downloadUpdateOptions) {
|
|
13
|
+
const provider = downloadUpdateOptions.updateInfoAndProvider.provider;
|
|
14
|
+
const fileInfo = (0, Provider_1.findFile)(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), "rpm", ["AppImage", "deb"]);
|
|
15
|
+
return this.executeDownload({
|
|
16
|
+
fileExtension: "rpm",
|
|
17
|
+
fileInfo,
|
|
18
|
+
downloadUpdateOptions,
|
|
19
|
+
task: async (updateFile, downloadOptions) => {
|
|
20
|
+
if (this.listenerCount(main_1.DOWNLOAD_PROGRESS) > 0) {
|
|
21
|
+
downloadOptions.onProgress = it => this.emit(main_1.DOWNLOAD_PROGRESS, it);
|
|
22
|
+
}
|
|
23
|
+
await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
doInstall(options) {
|
|
28
|
+
const upgradePath = options.installerPath;
|
|
29
|
+
const sudo = this.wrapSudo();
|
|
30
|
+
// pkexec doesn't want the command to be wrapped in " quotes
|
|
31
|
+
const wrapper = /pkexec/i.test(sudo) ? "" : `"`;
|
|
32
|
+
const packageManager = this.spawnSyncLog("which zypper");
|
|
33
|
+
let cmd;
|
|
34
|
+
if (!packageManager) {
|
|
35
|
+
const packageManager = this.spawnSyncLog("which dnf || which yum");
|
|
36
|
+
cmd = [packageManager, "-y", "remove", `'${this.app.name}'`, ";", packageManager, "-y", "install", upgradePath];
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
cmd = [
|
|
40
|
+
packageManager,
|
|
41
|
+
"remove",
|
|
42
|
+
"-y",
|
|
43
|
+
`'${this.app.name}'`,
|
|
44
|
+
";",
|
|
45
|
+
packageManager,
|
|
46
|
+
"clean",
|
|
47
|
+
"--all",
|
|
48
|
+
";",
|
|
49
|
+
packageManager,
|
|
50
|
+
"--no-refresh",
|
|
51
|
+
"install",
|
|
52
|
+
"--allow-unsigned-rpm",
|
|
53
|
+
"-y",
|
|
54
|
+
"-f",
|
|
55
|
+
upgradePath,
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
this.spawnSyncLog(sudo, [`${wrapper}/bin/bash`, "-c", `'${cmd.join(" ")}'${wrapper}`]);
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.RpmUpdater = RpmUpdater;
|
|
63
|
+
//# sourceMappingURL=RpmUpdater.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RpmUpdater.js","sourceRoot":"","sources":["../src/RpmUpdater.ts"],"names":[],"mappings":";;;AAGA,+CAA2D;AAC3D,iCAA0C;AAC1C,mDAA+C;AAE/C,MAAa,UAAW,SAAQ,yBAAW;IACzC,YAAY,OAAkC,EAAE,GAAgB;QAC9D,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACrB,CAAC;IAED,gBAAgB;IACN,gBAAgB,CAAC,qBAA4C;QACrE,MAAM,QAAQ,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,QAA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,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,CAAC,CAAA;SAChH;aAAM;YACL,GAAG,GAAG;gBACJ,cAAc;gBACd,QAAQ;gBACR,IAAI;gBACJ,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG;gBACpB,GAAG;gBACH,cAAc;gBACd,OAAO;gBACP,OAAO;gBACP,GAAG;gBACH,cAAc;gBACd,cAAc;gBACd,SAAS;gBACT,sBAAsB;gBACtB,IAAI;gBACJ,IAAI;gBACJ,WAAW;aACZ,CAAA;SACF;QACD,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,WAAW,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAA;QACtF,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAvDD,gCAuDC","sourcesContent":["import { AllPublishOptions } from \"builder-util-runtime\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { DownloadUpdateOptions } from \"./AppUpdater\"\nimport { BaseUpdater, InstallOptions } from \"./BaseUpdater\"\nimport { DOWNLOAD_PROGRESS } from \"./main\"\nimport { findFile } from \"./providers/Provider\"\n\nexport class RpmUpdater extends BaseUpdater {\n constructor(options?: AllPublishOptions | null, app?: AppAdapter) {\n super(options, app)\n }\n\n /*** @private */\n protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const fileInfo = findFile(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), \"rpm\", [\"AppImage\", \"deb\"])!\n return this.executeDownload({\n fileExtension: \"rpm\",\n fileInfo,\n downloadUpdateOptions,\n task: async (updateFile, downloadOptions) => {\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions)\n },\n })\n }\n\n protected doInstall(options: InstallOptions): boolean {\n const upgradePath = options.installerPath\n const sudo = this.wrapSudo()\n // pkexec doesn't want the command to be wrapped in \" quotes\n const wrapper = /pkexec/i.test(sudo) ? \"\" : `\"`\n const packageManager = this.spawnSyncLog(\"which zypper\")\n let cmd: string[]\n if (!packageManager) {\n const packageManager = this.spawnSyncLog(\"which dnf || which yum\")\n cmd = [packageManager, \"-y\", \"remove\", `'${this.app.name}'`, \";\", packageManager, \"-y\", \"install\", upgradePath]\n } else {\n cmd = [\n packageManager,\n \"remove\",\n \"-y\",\n `'${this.app.name}'`,\n \";\",\n packageManager,\n \"clean\",\n \"--all\",\n \";\",\n packageManager,\n \"--no-refresh\",\n \"install\",\n \"--allow-unsigned-rpm\",\n \"-y\",\n \"-f\",\n upgradePath,\n ]\n }\n this.spawnSyncLog(sudo, [`${wrapper}/bin/bash`, \"-c\", `'${cmd.join(\" \")}'${wrapper}`])\n return true\n }\n}\n"]}
|
package/out/main.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export { AppUpdater, NoOpLogger } from "./AppUpdater";
|
|
|
9
9
|
export { CancellationToken, PackageFileInfo, ProgressInfo, UpdateFileInfo, UpdateInfo };
|
|
10
10
|
export { Provider } from "./providers/Provider";
|
|
11
11
|
export { AppImageUpdater } from "./AppImageUpdater";
|
|
12
|
+
export { DebUpdater } from "./DebUpdater";
|
|
13
|
+
export { RpmUpdater } from "./RpmUpdater";
|
|
12
14
|
export { MacUpdater } from "./MacUpdater";
|
|
13
15
|
export { NsisUpdater } from "./NsisUpdater";
|
|
14
16
|
export declare const autoUpdater: AppUpdater;
|
package/out/main.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UpdaterSignal = exports.UPDATE_DOWNLOADED = exports.DOWNLOAD_PROGRESS = exports.NsisUpdater = exports.MacUpdater = exports.AppImageUpdater = exports.Provider = exports.CancellationToken = exports.NoOpLogger = exports.AppUpdater = void 0;
|
|
3
|
+
exports.UpdaterSignal = exports.UPDATE_DOWNLOADED = exports.DOWNLOAD_PROGRESS = exports.NsisUpdater = exports.MacUpdater = exports.RpmUpdater = exports.DebUpdater = exports.AppImageUpdater = exports.Provider = exports.CancellationToken = exports.NoOpLogger = exports.AppUpdater = void 0;
|
|
4
4
|
const builder_util_runtime_1 = require("builder-util-runtime");
|
|
5
5
|
Object.defineProperty(exports, "CancellationToken", { enumerable: true, get: function () { return builder_util_runtime_1.CancellationToken; } });
|
|
6
|
+
const fs_extra_1 = require("fs-extra");
|
|
7
|
+
const path = require("path");
|
|
6
8
|
var AppUpdater_1 = require("./AppUpdater");
|
|
7
9
|
Object.defineProperty(exports, "AppUpdater", { enumerable: true, get: function () { return AppUpdater_1.AppUpdater; } });
|
|
8
10
|
Object.defineProperty(exports, "NoOpLogger", { enumerable: true, get: function () { return AppUpdater_1.NoOpLogger; } });
|
|
@@ -10,6 +12,10 @@ var Provider_1 = require("./providers/Provider");
|
|
|
10
12
|
Object.defineProperty(exports, "Provider", { enumerable: true, get: function () { return Provider_1.Provider; } });
|
|
11
13
|
var AppImageUpdater_1 = require("./AppImageUpdater");
|
|
12
14
|
Object.defineProperty(exports, "AppImageUpdater", { enumerable: true, get: function () { return AppImageUpdater_1.AppImageUpdater; } });
|
|
15
|
+
var DebUpdater_1 = require("./DebUpdater");
|
|
16
|
+
Object.defineProperty(exports, "DebUpdater", { enumerable: true, get: function () { return DebUpdater_1.DebUpdater; } });
|
|
17
|
+
var RpmUpdater_1 = require("./RpmUpdater");
|
|
18
|
+
Object.defineProperty(exports, "RpmUpdater", { enumerable: true, get: function () { return RpmUpdater_1.RpmUpdater; } });
|
|
13
19
|
var MacUpdater_1 = require("./MacUpdater");
|
|
14
20
|
Object.defineProperty(exports, "MacUpdater", { enumerable: true, get: function () { return MacUpdater_1.MacUpdater; } });
|
|
15
21
|
var NsisUpdater_1 = require("./NsisUpdater");
|
|
@@ -26,6 +32,28 @@ function doLoadAutoUpdater() {
|
|
|
26
32
|
}
|
|
27
33
|
else {
|
|
28
34
|
_autoUpdater = new (require("./AppImageUpdater").AppImageUpdater)();
|
|
35
|
+
try {
|
|
36
|
+
const identity = path.join(process.resourcesPath, "package-type");
|
|
37
|
+
if (!(0, fs_extra_1.existsSync)(identity)) {
|
|
38
|
+
return _autoUpdater;
|
|
39
|
+
}
|
|
40
|
+
console.info("Checking for beta autoupdate feature for deb/rpm distributions");
|
|
41
|
+
const fileType = (0, fs_extra_1.readFileSync)(identity).toString().trim();
|
|
42
|
+
console.info("Found package-type:", fileType);
|
|
43
|
+
switch (fileType) {
|
|
44
|
+
case "deb":
|
|
45
|
+
_autoUpdater = new (require("./DebUpdater").DebUpdater)();
|
|
46
|
+
break;
|
|
47
|
+
case "rpm":
|
|
48
|
+
_autoUpdater = new (require("./RpmUpdater").RpmUpdater)();
|
|
49
|
+
break;
|
|
50
|
+
default:
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
console.warn("Unable to detect 'package-type' for autoUpdater (beta rpm/deb support). If you'd like to expand support, please consider contributing to electron-builder", error.message);
|
|
56
|
+
}
|
|
29
57
|
}
|
|
30
58
|
return _autoUpdater;
|
|
31
59
|
}
|
package/out/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;AAAA,+DAAmH;
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;AAAA,+DAAmH;AAS1G,kGATA,wCAAiB,OASA;AAP1B,uCAAmD;AACnD,6BAA4B;AAK5B,2CAAqD;AAA5C,wGAAA,UAAU,OAAA;AAAE,wGAAA,UAAU,OAAA;AAE/B,iDAA+C;AAAtC,oGAAA,QAAQ,OAAA;AACjB,qDAAmD;AAA1C,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AAG,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 { existsSync, readFileSync } from \"fs-extra\"\nimport * as path from \"path\"\nimport { URL } from \"url\"\nimport { AppUpdater } from \"./AppUpdater\"\nimport { LoginCallback } from \"./electronHttpExecutor\"\n\nexport { AppUpdater, NoOpLogger } from \"./AppUpdater\"\nexport { CancellationToken, PackageFileInfo, ProgressInfo, UpdateFileInfo, UpdateInfo }\nexport { Provider } from \"./providers/Provider\"\nexport { AppImageUpdater } from \"./AppImageUpdater\"\nexport { DebUpdater } from \"./DebUpdater\"\nexport { RpmUpdater } from \"./RpmUpdater\"\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 } else if (process.platform === \"darwin\") {\n _autoUpdater = new (require(\"./MacUpdater\").MacUpdater)()\n } else {\n _autoUpdater = new (require(\"./AppImageUpdater\").AppImageUpdater)()\n try {\n const identity = path.join(process.resourcesPath!, \"package-type\")\n if (!existsSync(identity)) {\n return _autoUpdater\n }\n console.info(\"Checking for beta autoupdate feature for deb/rpm distributions\")\n const fileType = readFileSync(identity).toString().trim()\n console.info(\"Found package-type:\", fileType)\n switch (fileType) {\n case \"deb\":\n _autoUpdater = new (require(\"./DebUpdater\").DebUpdater)()\n break\n case \"rpm\":\n _autoUpdater = new (require(\"./RpmUpdater\").RpmUpdater)()\n break\n default:\n break\n }\n } catch (error: any) {\n console.warn(\n \"Unable to detect 'package-type' for autoUpdater (beta rpm/deb support). If you'd like to expand support, please consider contributing to electron-builder\",\n error.message\n )\n }\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 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-not-available\" | \"update-cancelled\" | \"download-progress\" | \"update-downloaded\" | \"error\"\n\nexport const DOWNLOAD_PROGRESS = \"download-progress\"\nexport const UPDATE_DOWNLOADED = \"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\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 } 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"]}
|
|
@@ -30,14 +30,8 @@ function verifySignature(publisherNames, unescapedTempUpdateFile, logger) {
|
|
|
30
30
|
const tempUpdateFile = unescapedTempUpdateFile.replace(/'/g, "''");
|
|
31
31
|
// https://github.com/electron-userland/electron-builder/issues/2421
|
|
32
32
|
// https://github.com/electron-userland/electron-builder/issues/2535
|
|
33
|
-
(0, child_process_1.execFile)("powershell.exe", [
|
|
34
|
-
|
|
35
|
-
"-NonInteractive",
|
|
36
|
-
"-InputFormat",
|
|
37
|
-
"None",
|
|
38
|
-
"-Command",
|
|
39
|
-
`Get-AuthenticodeSignature -LiteralPath '${tempUpdateFile}' | ConvertTo-Json -Compress | ForEach-Object { [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($_)) }`,
|
|
40
|
-
], {
|
|
33
|
+
(0, child_process_1.execFile)("chcp 65001 >NUL & powershell.exe", ["-NoProfile", "-NonInteractive", "-InputFormat", "None", "-Command", `"Get-AuthenticodeSignature -LiteralPath '${tempUpdateFile}' | ConvertTo-Json -Compress"`], {
|
|
34
|
+
shell: true,
|
|
41
35
|
timeout: 20 * 1000,
|
|
42
36
|
}, (error, stdout, stderr) => {
|
|
43
37
|
try {
|
|
@@ -46,7 +40,7 @@ function verifySignature(publisherNames, unescapedTempUpdateFile, logger) {
|
|
|
46
40
|
resolve(null);
|
|
47
41
|
return;
|
|
48
42
|
}
|
|
49
|
-
const data = parseOut(
|
|
43
|
+
const data = parseOut(stdout);
|
|
50
44
|
if (data.Status === 0) {
|
|
51
45
|
const subject = (0, builder_util_runtime_1.parseDn)(data.SignerCertificate.Subject);
|
|
52
46
|
let match = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"windowsExecutableCodeSignatureVerifier.js","sourceRoot":"","sources":["../src/windowsExecutableCodeSignatureVerifier.ts"],"names":[],"mappings":";;;AAAA,+DAA8C;AAC9C,iDAAsD;AACtD,yBAAwB;AAGxB,8DAA8D;AAC9D,kJAAkJ;AAClJ,kEAAkE;AAClE,SAAgB,eAAe,CAAC,cAA6B,EAAE,uBAA+B,EAAE,MAAc;IAC5G,OAAO,IAAI,OAAO,CAAgB,OAAO,CAAC,EAAE;QAC1C,6EAA6E;QAC7E,oDAAoD;QACpD,EAAE;QACF,uCAAuC;QACvC,gBAAgB;QAChB,oEAAoE;QACpE,MAAM;QACN,+FAA+F;QAC/F,wCAAwC;QACxC,EAAE;QACF,iCAAiC;QACjC,2HAA2H;QAC3H,0EAA0E;QAC1E,sEAAsE;QACtE,EAAE;QACF,0FAA0F;QAC1F,kFAAkF;QAClF,sEAAsE;QACtE,MAAM,cAAc,GAAG,uBAAuB,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAElE,oEAAoE;QACpE,oEAAoE;QACpE,IAAA,wBAAQ,EACN,
|
|
1
|
+
{"version":3,"file":"windowsExecutableCodeSignatureVerifier.js","sourceRoot":"","sources":["../src/windowsExecutableCodeSignatureVerifier.ts"],"names":[],"mappings":";;;AAAA,+DAA8C;AAC9C,iDAAsD;AACtD,yBAAwB;AAGxB,8DAA8D;AAC9D,kJAAkJ;AAClJ,kEAAkE;AAClE,SAAgB,eAAe,CAAC,cAA6B,EAAE,uBAA+B,EAAE,MAAc;IAC5G,OAAO,IAAI,OAAO,CAAgB,OAAO,CAAC,EAAE;QAC1C,6EAA6E;QAC7E,oDAAoD;QACpD,EAAE;QACF,uCAAuC;QACvC,gBAAgB;QAChB,oEAAoE;QACpE,MAAM;QACN,+FAA+F;QAC/F,wCAAwC;QACxC,EAAE;QACF,i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QAC7B,OAAO,iBAAiB,CAAC,QAAQ,CAAA;QACjC,OAAO,iBAAiB,CAAC,UAAU,CAAA;QACnC,OAAO,iBAAiB,CAAC,MAAM,CAAA;QAC/B,OAAO,iBAAiB,CAAC,aAAa,CAAA;QACtC,uDAAuD;QACvD,OAAO,iBAAiB,CAAC,WAAW,CAAA;KACrC;IACD,OAAO,IAAI,CAAC,IAAI,CAAA;IAChB,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,WAAW,CAAC,MAAc,EAAE,KAAmB,EAAE,MAAqB;IAC7E,IAAI,SAAS,EAAE,EAAE;QACf,MAAM,CAAC,IAAI,CACT,6CAA6C,KAAK,IAAI,MAAM,kHAAkH,CAC/K,CAAA;QACD,OAAM;KACP;IAED,IAAI;QACF,IAAA,4BAAY,EAAC,gBAAgB,EAAE,CAAC,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,qBAAqB,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,GAAG,IAAI,EAAS,CAAC,CAAA;KACpI;IAAC,OAAO,SAAc,EAAE;QACvB,MAAM,CAAC,IAAI,CACT,kCAAkC,SAAS,CAAC,OAAO,kHAAkH,CACtK,CAAA;QACD,OAAM;KACP;IAED,IAAI,KAAK,IAAI,IAAI,EAAE;QACjB,MAAM,KAAK,CAAA;KACZ;IAED,IAAI,MAAM,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,qDAAqD,MAAM,uDAAuD,CAAC,CAAA;KACpI;AACH,CAAC;AAED,SAAS,SAAS;IAChB,MAAM,UAAU,GAAG,EAAE,CAAC,OAAO,EAAE,CAAA;IAC/B,OAAO,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;AACrE,CAAC","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 // 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 //\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 contain any illegal characters like <>:\"/\\|?*\n // https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file\n const tempUpdateFile = unescapedTempUpdateFile.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(\n \"chcp 65001 >NUL & powershell.exe\",\n [\"-NoProfile\", \"-NonInteractive\", \"-InputFormat\", \"None\", \"-Command\", `\"Get-AuthenticodeSignature -LiteralPath '${tempUpdateFile}' | ConvertTo-Json -Compress\"`],\n {\n shell: true,\n timeout: 20 * 1000,\n },\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(stdout)\n if (data.Status === 0) {\n const subject = parseDn(data.SignerCertificate.Subject)\n let match = false\n for (const name of publisherNames) {\n const dn = parseDn(name)\n if (dn.size) {\n // if we have a full DN, compare all values\n const allKeys = Array.from(dn.keys())\n match = allKeys.every(key => {\n return dn.get(key) === subject.get(key)\n })\n } else if (name === subject.get(\"CN\")!) {\n logger.warn(`Signature validated using only CN ${name}. Please add your full Distinguished Name (DN) to publisherNames configuration`)\n match = true\n }\n if (match) {\n resolve(null)\n return\n }\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 } catch (e: any) {\n handleError(logger, e, null)\n resolve(null)\n return\n }\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(\n `Cannot execute Get-AuthenticodeSignature: ${error || stderr}. Ignoring signature validation due to unsupported powershell version. Please upgrade to powershell 3 or higher.`\n )\n return\n }\n\n try {\n execFileSync(\"powershell.exe\", [\"-NoProfile\", \"-NonInteractive\", \"-Command\", \"ConvertTo-Json test\"], { timeout: 10 * 1000 } as any)\n } catch (testError: any) {\n logger.warn(\n `Cannot execute ConvertTo-Json: ${testError.message}. Ignoring signature validation due to unsupported powershell version. Please upgrade to powershell 3 or higher.`\n )\n return\n }\n\n if (error != null) {\n throw error\n }\n\n if (stderr) {\n throw new Error(`Cannot execute Get-AuthenticodeSignature, stderr: ${stderr}. Failing signature validation due to unknown stderr.`)\n }\n}\n\nfunction isOldWin6(): boolean {\n const winVersion = os.release()\n return winVersion.startsWith(\"6.\") && !winVersion.startsWith(\"6.3\")\n}\n"]}
|