electron-updater 7.0.0-alpha.7 → 7.0.0-alpha.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/dist/AppImageUpdater.d.ts +2 -1
- package/dist/AppImageUpdater.d.ts.map +1 -1
- package/dist/AppImageUpdater.js +4 -2
- package/dist/AppImageUpdater.js.map +1 -1
- package/dist/AppUpdater.d.ts +87 -8
- package/dist/AppUpdater.d.ts.map +1 -1
- package/dist/AppUpdater.js +360 -42
- package/dist/AppUpdater.js.map +1 -1
- package/dist/BaseUpdater.d.ts +9 -5
- package/dist/BaseUpdater.d.ts.map +1 -1
- package/dist/BaseUpdater.js +33 -10
- package/dist/BaseUpdater.js.map +1 -1
- package/dist/DebUpdater.d.ts +2 -2
- package/dist/DebUpdater.d.ts.map +1 -1
- package/dist/DebUpdater.js.map +1 -1
- package/dist/DownloadedUpdateHelper.d.ts +22 -1
- package/dist/DownloadedUpdateHelper.d.ts.map +1 -1
- package/dist/DownloadedUpdateHelper.js +51 -1
- package/dist/DownloadedUpdateHelper.js.map +1 -1
- package/dist/MacUpdater.d.ts +3 -3
- package/dist/MacUpdater.d.ts.map +1 -1
- package/dist/MacUpdater.js +5 -4
- package/dist/MacUpdater.js.map +1 -1
- package/dist/NsisUpdater.d.ts +25 -6
- package/dist/NsisUpdater.d.ts.map +1 -1
- package/dist/NsisUpdater.js +122 -38
- package/dist/NsisUpdater.js.map +1 -1
- package/dist/PacmanUpdater.d.ts +2 -2
- package/dist/PacmanUpdater.d.ts.map +1 -1
- package/dist/PacmanUpdater.js.map +1 -1
- package/dist/RpmUpdater.d.ts +2 -2
- package/dist/RpmUpdater.d.ts.map +1 -1
- package/dist/RpmUpdater.js.map +1 -1
- package/dist/differentialDownloader/DataSplitter.d.ts +3 -2
- package/dist/differentialDownloader/DataSplitter.d.ts.map +1 -1
- package/dist/differentialDownloader/DataSplitter.js +36 -15
- package/dist/differentialDownloader/DataSplitter.js.map +1 -1
- package/dist/differentialDownloader/ProgressDifferentialDownloadCallbackTransform.d.ts +1 -0
- package/dist/differentialDownloader/ProgressDifferentialDownloadCallbackTransform.d.ts.map +1 -1
- package/dist/differentialDownloader/ProgressDifferentialDownloadCallbackTransform.js +7 -3
- package/dist/differentialDownloader/ProgressDifferentialDownloadCallbackTransform.js.map +1 -1
- package/dist/differentialDownloader/multipleRangeDownloader.d.ts.map +1 -1
- package/dist/differentialDownloader/multipleRangeDownloader.js +22 -2
- package/dist/differentialDownloader/multipleRangeDownloader.js.map +1 -1
- package/dist/index.d.ts +1 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/providers/BitbucketProvider.d.ts +1 -0
- package/dist/providers/BitbucketProvider.d.ts.map +1 -1
- package/dist/providers/BitbucketProvider.js +3 -0
- package/dist/providers/BitbucketProvider.js.map +1 -1
- package/dist/providers/GenericProvider.d.ts +1 -0
- package/dist/providers/GenericProvider.d.ts.map +1 -1
- package/dist/providers/GenericProvider.js +3 -0
- package/dist/providers/GenericProvider.js.map +1 -1
- package/dist/providers/GitHubProvider.d.ts +1 -0
- package/dist/providers/GitHubProvider.d.ts.map +1 -1
- package/dist/providers/GitHubProvider.js +3 -0
- package/dist/providers/GitHubProvider.js.map +1 -1
- package/dist/providers/GitLabProvider.d.ts +1 -0
- package/dist/providers/GitLabProvider.d.ts.map +1 -1
- package/dist/providers/GitLabProvider.js +3 -0
- package/dist/providers/GitLabProvider.js.map +1 -1
- package/dist/providers/KeygenProvider.d.ts +1 -0
- package/dist/providers/KeygenProvider.d.ts.map +1 -1
- package/dist/providers/KeygenProvider.js +3 -0
- package/dist/providers/KeygenProvider.js.map +1 -1
- package/dist/providers/PrivateGitHubProvider.d.ts +1 -0
- package/dist/providers/PrivateGitHubProvider.d.ts.map +1 -1
- package/dist/providers/PrivateGitHubProvider.js +4 -0
- package/dist/providers/PrivateGitHubProvider.js.map +1 -1
- package/dist/providers/Provider.d.ts +7 -0
- package/dist/providers/Provider.d.ts.map +1 -1
- package/dist/providers/Provider.js +15 -0
- package/dist/providers/Provider.js.map +1 -1
- package/dist/types.d.ts +81 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -1
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +6 -0
- package/dist/util.js.map +1 -1
- package/dist/windowsExecutableCodeSignatureVerifier.d.ts +2 -1
- package/dist/windowsExecutableCodeSignatureVerifier.d.ts.map +1 -1
- package/dist/windowsExecutableCodeSignatureVerifier.js +116 -78
- package/dist/windowsExecutableCodeSignatureVerifier.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { AllPublishOptions } from "builder-util-runtime";
|
|
2
2
|
import { DownloadUpdateOptions } from "./AppUpdater.js";
|
|
3
3
|
import { BaseUpdater, InstallOptions } from "./BaseUpdater.js";
|
|
4
|
+
import { DownloadExecutorResult } from "./types.js";
|
|
4
5
|
export declare class AppImageUpdater extends BaseUpdater {
|
|
5
6
|
constructor(options?: AllPublishOptions | null, app?: any);
|
|
6
7
|
isUpdaterActive(): boolean;
|
|
7
8
|
protected get isAutoInstallOnNextLaunchSupported(): boolean;
|
|
8
9
|
/*** @private */
|
|
9
|
-
protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<
|
|
10
|
+
protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<DownloadExecutorResult>;
|
|
10
11
|
private downloadDifferential;
|
|
11
12
|
protected doInstall(options: InstallOptions): boolean;
|
|
12
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppImageUpdater.d.ts","sourceRoot":"","sources":["../src/AppImageUpdater.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAY,MAAM,sBAAsB,CAAA;AAKlE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"AppImageUpdater.d.ts","sourceRoot":"","sources":["../src/AppImageUpdater.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAY,MAAM,sBAAsB,CAAA;AAKlE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAI9D,OAAO,EAA6C,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAE9F,qBAAa,eAAgB,SAAQ,WAAW;gBAClC,OAAO,CAAC,EAAE,iBAAiB,GAAG,IAAI,EAAE,GAAG,CAAC,EAAE,GAAG;IAIlD,eAAe,IAAI,OAAO;IAajC,SAAS,KAAK,kCAAkC,IAAI,OAAO,CAE1D;IAED,gBAAgB;IAChB,SAAS,CAAC,gBAAgB,CAAC,qBAAqB,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;YAuB3F,oBAAoB;IAyBlC,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO;CA+CtD"}
|
package/dist/AppImageUpdater.js
CHANGED
|
@@ -43,8 +43,10 @@ export class AppImageUpdater extends BaseUpdater {
|
|
|
43
43
|
if (downloadUpdateOptions.disableDifferentialDownload || (await this.downloadDifferential(fileInfo, oldFile, updateFile, provider, downloadUpdateOptions))) {
|
|
44
44
|
await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions);
|
|
45
45
|
}
|
|
46
|
-
await fsExtra.chmod(updateFile, 0o755);
|
|
47
46
|
},
|
|
47
|
+
// deferred until after verification: the temporary path is predictable, so marking the AppImage executable
|
|
48
|
+
// before it is verified would leave an unverified binary runnable for as long as verification takes
|
|
49
|
+
afterVerification: updateFile => fsExtra.chmod(updateFile, 0o755),
|
|
48
50
|
});
|
|
49
51
|
}
|
|
50
52
|
async downloadDifferential(fileInfo, oldFile, updateFile, provider, downloadUpdateOptions) {
|
|
@@ -55,7 +57,7 @@ export class AppImageUpdater extends BaseUpdater {
|
|
|
55
57
|
logger: this._logger,
|
|
56
58
|
newFile: updateFile,
|
|
57
59
|
isUseMultipleRangeRequest: provider.isUseMultipleRangeRequest,
|
|
58
|
-
requestHeaders:
|
|
60
|
+
requestHeaders: this.downloadRequestHeaders(fileInfo.url, downloadUpdateOptions),
|
|
59
61
|
cancellationToken: downloadUpdateOptions.cancellationToken,
|
|
60
62
|
};
|
|
61
63
|
if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppImageUpdater.js","sourceRoot":"","sources":["../src/AppImageUpdater.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAC/B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO,EAAE,WAAW,EAAkB,MAAM,kBAAkB,CAAA;AAE9D,OAAO,EAAE,8CAA8C,EAAE,MAAM,4EAA4E,CAAA;AAC3I,OAAO,EAAE,QAAQ,EAAY,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,iBAAiB,EAA0B,MAAM,YAAY,CAAA;AAEtE,MAAM,OAAO,eAAgB,SAAQ,WAAW;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,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAClE,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;gBAChC,IAAI,CAAC,O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AAC,eAAe,EAAE,CAAC;YAC5B,mEAAmE;YACnE,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;QACrC,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,2BAA2B,GAAG,MAAM,CAAA;YACxC,YAAY,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAA;QACxC,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF","sourcesContent":["import { AllPublishOptions, newError } from \"builder-util-runtime\"\nimport { execFileSync } from \"child_process\"\nimport fsExtra from \"fs-extra\"\nimport { unlinkSync } from \"fs\"\nimport * as path from \"path\"\nimport { DownloadUpdateOptions } from \"./AppUpdater.js\"\nimport { BaseUpdater, InstallOptions } from \"./BaseUpdater.js\"\nimport { DifferentialDownloaderOptions } from \"./differentialDownloader/DifferentialDownloader.js\"\nimport { FileWithEmbeddedBlockMapDifferentialDownloader } from \"./differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader.js\"\nimport { findFile, Provider } from \"./providers/Provider.js\"\nimport { DOWNLOAD_PROGRESS, ResolvedUpdateFileInfo } from \"./types.js\"\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 && !this.forceDevUpdateConfig) {\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 // replacing the AppImage file needs no elevation, so the automatic install at startup is allowed\n protected get isAutoInstallOnNextLaunchSupported(): boolean {\n return true\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\", \"pacman\"])!\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 if (downloadUpdateOptions.disableDifferentialDownload || (await this.downloadDifferential(fileInfo, oldFile, updateFile, provider, downloadUpdateOptions))) {\n await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions)\n }\n\n await fsExtra.chmod(updateFile, 0o755)\n },\n })\n }\n\n private async downloadDifferential(fileInfo: ResolvedUpdateFileInfo, oldFile: string, updateFile: string, provider: Provider<any>, downloadUpdateOptions: DownloadUpdateOptions) {\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 return false\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 return process.platform === \"linux\"\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 if (!path.isAbsolute(appImageFile) || appImageFile.includes(\"\\0\")) {\n throw newError(`APPIMAGE env is not a valid absolute path: \"${appImageFile}\"`, \"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 const installerPath = this.installerPath\n if (installerPath == null) {\n this.dispatchError(new Error(\"No update filepath provided, can't quit and install\"))\n return false\n }\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(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(installerPath))\n }\n\n execFileSync(\"mv\", [\"-f\", installerPath, destination])\n if (destination !== appImageFile) {\n this.emit(\"appimage-filename-updated\", destination)\n }\n\n const env: NodeJS.ProcessEnv = {\n ...process.env,\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"]}
|
|
1
|
+
{"version":3,"file":"AppImageUpdater.js","sourceRoot":"","sources":["../src/AppImageUpdater.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAC/B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO,EAAE,WAAW,EAAkB,MAAM,kBAAkB,CAAA;AAE9D,OAAO,EAAE,8CAA8C,EAAE,MAAM,4EAA4E,CAAA;AAC3I,OAAO,EAAE,QAAQ,EAAY,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,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5B,CAAC;aAAM,CAAC;YACN,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAA;QACnF,CAAC;QAED,YAAY,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAA;QACtD,IAAI,WAAW,KAAK,YAAY,EAAE,CAAC;YACjC,IAAI,CAAC,IAAI,CAAC,2BAA2B,EAAE,WAAW,CAAC,CAAA;QACrD,CAAC;QAED,MAAM,GAAG,GAAsB;YAC7B,GAAG,OAAO,CAAC,GAAG;YACd,uBAAuB,EAAE,MAAM;SAChC,CAAA;QAED,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;YAC5B,mEAAmE;YACnE,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;QACrC,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,2BAA2B,GAAG,MAAM,CAAA;YACxC,YAAY,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAA;QACxC,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF","sourcesContent":["import { AllPublishOptions, newError } from \"builder-util-runtime\"\nimport { execFileSync } from \"child_process\"\nimport fsExtra from \"fs-extra\"\nimport { unlinkSync } from \"fs\"\nimport * as path from \"path\"\nimport { DownloadUpdateOptions } from \"./AppUpdater.js\"\nimport { BaseUpdater, InstallOptions } from \"./BaseUpdater.js\"\nimport { DifferentialDownloaderOptions } from \"./differentialDownloader/DifferentialDownloader.js\"\nimport { FileWithEmbeddedBlockMapDifferentialDownloader } from \"./differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader.js\"\nimport { findFile, Provider } from \"./providers/Provider.js\"\nimport { DOWNLOAD_PROGRESS, ResolvedUpdateFileInfo, DownloadExecutorResult } from \"./types.js\"\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 && !this.forceDevUpdateConfig) {\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 // replacing the AppImage file needs no elevation, so the automatic install at startup is allowed\n protected get isAutoInstallOnNextLaunchSupported(): boolean {\n return true\n }\n\n /*** @private */\n protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<DownloadExecutorResult> {\n const provider = downloadUpdateOptions.updateInfoAndProvider.provider\n const fileInfo = findFile(provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info), \"AppImage\", [\"rpm\", \"deb\", \"pacman\"])!\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 if (downloadUpdateOptions.disableDifferentialDownload || (await this.downloadDifferential(fileInfo, oldFile, updateFile, provider, downloadUpdateOptions))) {\n await this.httpExecutor.download(fileInfo.url, updateFile, downloadOptions)\n }\n },\n // deferred until after verification: the temporary path is predictable, so marking the AppImage executable\n // before it is verified would leave an unverified binary runnable for as long as verification takes\n afterVerification: updateFile => fsExtra.chmod(updateFile, 0o755),\n })\n }\n\n private async downloadDifferential(fileInfo: ResolvedUpdateFileInfo, oldFile: string, updateFile: string, provider: Provider<any>, downloadUpdateOptions: DownloadUpdateOptions) {\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: this.downloadRequestHeaders(fileInfo.url, downloadUpdateOptions),\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 return false\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 return process.platform === \"linux\"\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 if (!path.isAbsolute(appImageFile) || appImageFile.includes(\"\\0\")) {\n throw newError(`APPIMAGE env is not a valid absolute path: \"${appImageFile}\"`, \"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 const installerPath = this.installerPath\n if (installerPath == null) {\n this.dispatchError(new Error(\"No update filepath provided, can't quit and install\"))\n return false\n }\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(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(installerPath))\n }\n\n execFileSync(\"mv\", [\"-f\", installerPath, destination])\n if (destination !== appImageFile) {\n this.emit(\"appimage-filename-updated\", destination)\n }\n\n const env: NodeJS.ProcessEnv = {\n ...process.env,\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/dist/AppUpdater.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ import { Provider, ProviderPlatform } from "./providers/Provider.js";
|
|
|
9
9
|
import type { TypedEmitter } from "tiny-typed-emitter";
|
|
10
10
|
type Session = Electron.Session;
|
|
11
11
|
import type { AuthInfo } from "electron";
|
|
12
|
-
import { AutoInstallEvent, Logger, QuitAndInstallOptions, ResolvedUpdateFileInfo, UpdateCheckResult, UpdateDownloadedEvent, UpdaterSignal } from "./types.js";
|
|
13
|
-
import { VerifyUpdateSupport } from "./index.js";
|
|
12
|
+
import { AutoInstallEvent, Logger, QuitAndInstallOptions, ResolvedUpdateFileInfo, UpdateCheckResult, DownloadExecutorResult, UpdateDownloadedEvent, UpdaterSignal, VerifyUpdateFile } from "./types.js";
|
|
13
|
+
import type { VerifyUpdateSupport } from "./index.js";
|
|
14
14
|
export type AppUpdaterEvents = {
|
|
15
15
|
error: (error: Error, message?: string) => void;
|
|
16
16
|
login: (info: AuthInfo, callback: LoginCallback) => void;
|
|
@@ -49,6 +49,17 @@ export declare abstract class AppUpdater extends AppUpdater_base {
|
|
|
49
49
|
* @default "onQuit"
|
|
50
50
|
*/
|
|
51
51
|
autoInstallEvent: AutoInstallEvent;
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated Removed in v27 — use {@link autoInstallEvent}. This accessor is a compatibility shim
|
|
54
|
+
* and will be deleted in v28.
|
|
55
|
+
*
|
|
56
|
+
* A boolean cannot express the three install timings, so `autoInstallOnAppQuit` was replaced rather
|
|
57
|
+
* than extended. Without this shim the property assignment silently no-ops on a plain object: an app
|
|
58
|
+
* that set `autoInstallOnAppQuit = false` to opt *out* of install-on-quit would keep the `"onQuit"`
|
|
59
|
+
* default and install on quit anyway — the exact opposite of what it asked for.
|
|
60
|
+
*/
|
|
61
|
+
get autoInstallOnAppQuit(): boolean;
|
|
62
|
+
set autoInstallOnAppQuit(value: boolean);
|
|
52
63
|
/**
|
|
53
64
|
* Installs an update that a previous launch marked as pending (see `autoInstallEvent: "onNextLaunch"` and
|
|
54
65
|
* `quitAndInstall({ waitUntilNextLaunch: true })`), then quits the app.
|
|
@@ -116,15 +127,22 @@ export declare abstract class AppUpdater extends AppUpdater_base {
|
|
|
116
127
|
*/
|
|
117
128
|
allowUnverifiedLinuxPackages: boolean;
|
|
118
129
|
private _disableWebInstaller;
|
|
130
|
+
protected disableWebInstallerDefault: boolean;
|
|
119
131
|
/**
|
|
120
|
-
* Whether to block NSIS web-installer packages. Web installer files might not have signature verification, so they are disabled by default as of v27
|
|
132
|
+
* Whether to block NSIS web-installer packages. Web installer files might not have signature verification, so they are disabled by default as of v27:
|
|
133
|
+
* a web-installer update is rejected with `ERR_UPDATER_WEB_INSTALLER_DISABLED` at download time, before an install on next launch, and at install time unless this is `false`.
|
|
121
134
|
*
|
|
122
|
-
*
|
|
135
|
+
* `NsisUpdater` defaults it to `false` for installs made by an `nsis-web` installer built with electron-builder v27+ (`resources/package-type` marker).
|
|
136
|
+
* Set it to `false` explicitly only if you intentionally publish and rely on NSIS web-installer packages and your installs lack that marker.
|
|
137
|
+
*
|
|
138
|
+
* Set it before the app is `ready` (e.g. right after creating the updater): with `autoInstallEvent: "onNextLaunch"` a pending
|
|
139
|
+
* web-installer update is checked against it when the app is ready, and rejected (its pending-install marker cleared) while it is `true`.
|
|
123
140
|
*
|
|
124
141
|
* @default true
|
|
125
142
|
*/
|
|
126
143
|
get disableWebInstaller(): boolean;
|
|
127
144
|
set disableWebInstaller(value: boolean);
|
|
145
|
+
protected get isWebInstallerEnabledByApp(): boolean;
|
|
128
146
|
/**
|
|
129
147
|
* *NSIS only* Disable differential downloads and always perform full download of installer.
|
|
130
148
|
*
|
|
@@ -166,6 +184,20 @@ export declare abstract class AppUpdater extends AppUpdater_base {
|
|
|
166
184
|
* `allowDowngrade` will be automatically set to `true`. If this behavior is not suitable for you, simple set `allowDowngrade` explicitly after.
|
|
167
185
|
*/
|
|
168
186
|
set channel(value: string | null);
|
|
187
|
+
/**
|
|
188
|
+
* The Ed25519 public key(s) (PEM or base64 SPKI) trusted to have signed the update manifest — the
|
|
189
|
+
* install's trust list. A single string or an array of keys; a manifest is accepted when any listed key
|
|
190
|
+
* validates one of its signatures. When set (non-empty), overrides the `updateManifestPublicKey` value
|
|
191
|
+
* embedded in `app-update.yml`.
|
|
192
|
+
*
|
|
193
|
+
* When at least one key is available (here or in config) the manifest signature is enforced and a
|
|
194
|
+
* download will not start unless verification succeeds. When no key is available, verification is
|
|
195
|
+
* skipped (opt-in) and a one-time warning is logged.
|
|
196
|
+
*/
|
|
197
|
+
updateManifestPublicKey: string | Array<string> | null;
|
|
198
|
+
private manifestVerificationWarned;
|
|
199
|
+
private crossOriginHeadersWarned;
|
|
200
|
+
private crossOriginFeedQueryWarned;
|
|
169
201
|
/**
|
|
170
202
|
* The request headers.
|
|
171
203
|
*/
|
|
@@ -192,6 +224,26 @@ export declare abstract class AppUpdater extends AppUpdater_base {
|
|
|
192
224
|
* @private
|
|
193
225
|
*/
|
|
194
226
|
set updateConfigPath(value: string | null);
|
|
227
|
+
protected _verifyUpdateFile: VerifyUpdateFile;
|
|
228
|
+
/**
|
|
229
|
+
* Allows developer to set custom logic for verifying an update file before it is allowed to become installable.
|
|
230
|
+
* When the verification fails, the file is deleted and electron-updater emits an `ERR_UPDATER_INVALID_UPDATE_FILE` error.
|
|
231
|
+
* The default behavior is a stub – immediately succeeds.
|
|
232
|
+
*
|
|
233
|
+
* It runs on every path that can lead to an install:
|
|
234
|
+
* - right after a fresh download, while the file still sits under a temporary name and before it is renamed into the
|
|
235
|
+
* updater cache under its real filename, so an unverified file can never be executed under its real name;
|
|
236
|
+
* - when an update downloaded by an earlier session is reused from the updater cache;
|
|
237
|
+
* - before an install-on-next-launch spawns the cached installer (see {@link BaseUpdater}).
|
|
238
|
+
*
|
|
239
|
+
* The custom logic gets `updateFilePath` (the file to verify), `originalUpdateFileName` (its real filename), the
|
|
240
|
+
* optional `packageFilePath` of an NSIS web installer package, and the active `cancellationToken` when the
|
|
241
|
+
* verification belongs to a download.
|
|
242
|
+
*
|
|
243
|
+
* Assigning `null` restores the default stub.
|
|
244
|
+
*/
|
|
245
|
+
get verifyUpdateFile(): VerifyUpdateFile;
|
|
246
|
+
set verifyUpdateFile(value: VerifyUpdateFile | null | undefined);
|
|
195
247
|
protected _isUpdateSupported: VerifyUpdateSupport;
|
|
196
248
|
/**
|
|
197
249
|
* Allows developer to override default logic for determining if an update is supported.
|
|
@@ -233,17 +285,32 @@ export declare abstract class AppUpdater extends AppUpdater_base {
|
|
|
233
285
|
private isUpdateAvailable;
|
|
234
286
|
private checkIfUpdateSupported;
|
|
235
287
|
protected getUpdateInfoAndProvider(): Promise<UpdateInfoAndProvider>;
|
|
288
|
+
/**
|
|
289
|
+
* Verifies the Ed25519 signature(s) embedded in the update manifest against the configured trust list.
|
|
290
|
+
* Provider-agnostic: runs for every provider since it operates on the resolved `UpdateInfo`.
|
|
291
|
+
*
|
|
292
|
+
* - No public key configured → verification skipped (opt-in phase), warns once.
|
|
293
|
+
* - Key(s) configured, manifest carries no signature at all → throws ERR_UPDATER_MANIFEST_NOT_SIGNED.
|
|
294
|
+
* - Key(s) configured, no trusted key validates any signature → throws ERR_UPDATER_MANIFEST_SIGNATURE_INVALID.
|
|
295
|
+
*
|
|
296
|
+
* A manifest may carry several signatures (`signatures`, one per signing key, tagged with the key id) plus
|
|
297
|
+
* the legacy single `signature`; any trusted key matching any of them is sufficient, which is what allows
|
|
298
|
+
* a release to be dual-signed while installs trust `[old, new]` during key rotation. Never fails open once
|
|
299
|
+
* a key is configured. A throw here propagates before any download starts (fail-closed).
|
|
300
|
+
*/
|
|
301
|
+
private verifyManifestSignature;
|
|
236
302
|
private createProviderRuntimeOptions;
|
|
237
303
|
private doCheckForUpdates;
|
|
238
304
|
protected onUpdateAvailable(updateInfo: UpdateInfo): void;
|
|
239
305
|
/**
|
|
240
306
|
* Start downloading update manually. You can use this method if `autoDownload` option is set to `false`.
|
|
241
|
-
* @returns {Promise<
|
|
307
|
+
* @returns {Promise<DownloadExecutorResult>} The downloaded files: `updateFile` is the path to the downloaded update (installer, AppImage, zip, ...),
|
|
308
|
+
* `packageFile` is the path to the NSIS web installer package and is only set for web installers.
|
|
242
309
|
*/
|
|
243
|
-
downloadUpdate(cancellationToken?: CancellationToken): Promise<
|
|
310
|
+
downloadUpdate(cancellationToken?: CancellationToken): Promise<DownloadExecutorResult>;
|
|
244
311
|
protected dispatchError(e: Error): void;
|
|
245
312
|
protected dispatchUpdateDownloaded(event: UpdateDownloadedEvent): void;
|
|
246
|
-
protected abstract doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<
|
|
313
|
+
protected abstract doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<DownloadExecutorResult>;
|
|
247
314
|
/**
|
|
248
315
|
* Restarts the app and installs the update after it has been downloaded.
|
|
249
316
|
* It should only be called after `update-downloaded` has been emitted.
|
|
@@ -257,9 +324,16 @@ export declare abstract class AppUpdater extends AppUpdater_base {
|
|
|
257
324
|
abstract quitAndInstall(options?: QuitAndInstallOptions): void;
|
|
258
325
|
private loadUpdateConfig;
|
|
259
326
|
private computeRequestHeaders;
|
|
327
|
+
/**
|
|
328
|
+
* Headers for a download from `url`: when the provider has a `feedBaseUrl`, the credential-bearing ones are dropped if `url` is on
|
|
329
|
+
* another origin than `originUrl` (the feed by default). `null` keeps them for every URL.
|
|
330
|
+
*/
|
|
331
|
+
protected downloadRequestHeaders(url: URL, downloadUpdateOptions: DownloadUpdateOptions, originUrl?: URL): OutgoingHttpHeaders;
|
|
332
|
+
private announceCrossOriginDownload;
|
|
333
|
+
private static checkFeedBaseUrlDeclared;
|
|
260
334
|
private getOrCreateStagingUserId;
|
|
261
335
|
protected getOrCreateDownloadHelper(): Promise<DownloadedUpdateHelper>;
|
|
262
|
-
protected executeDownload(taskOptions: DownloadExecutorTask): Promise<
|
|
336
|
+
protected executeDownload(taskOptions: DownloadExecutorTask): Promise<DownloadExecutorResult>;
|
|
263
337
|
protected differentialDownloadInstaller(fileInfo: ResolvedUpdateFileInfo, downloadUpdateOptions: DownloadUpdateOptions, installerPath: string, provider: Provider<any>, oldInstallerFileName: string): Promise<boolean>;
|
|
264
338
|
}
|
|
265
339
|
export interface DownloadUpdateOptions {
|
|
@@ -284,6 +358,11 @@ export interface DownloadExecutorTask {
|
|
|
284
358
|
readonly fileInfo: ResolvedUpdateFileInfo;
|
|
285
359
|
readonly downloadUpdateOptions: DownloadUpdateOptions;
|
|
286
360
|
readonly task: (destinationFile: string, downloadOptions: DownloadOptions, packageFile: string | null, removeTempDirIfAny: () => Promise<any>) => Promise<any>;
|
|
361
|
+
/**
|
|
362
|
+
* Runs after the downloaded file passed verification and before it is renamed into the cache under its real name.
|
|
363
|
+
* For anything that must not be done to a file that is still unverified — making it executable, in particular.
|
|
364
|
+
*/
|
|
365
|
+
readonly afterVerification?: (destinationFile: string) => Promise<void>;
|
|
287
366
|
readonly done?: (event: UpdateDownloadedEvent) => Promise<any>;
|
|
288
367
|
}
|
|
289
368
|
export interface DownloadNotification {
|
package/dist/AppUpdater.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppUpdater.d.ts","sourceRoot":"","sources":["../src/AppUpdater.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EAEjB,iBAAiB,EAEjB,oBAAoB,EACpB,UAAU,EAEV,eAAe,
|
|
1
|
+
{"version":3,"file":"AppUpdater.d.ts","sourceRoot":"","sources":["../src/AppUpdater.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EAEjB,iBAAiB,EAEjB,oBAAoB,EACpB,UAAU,EAEV,eAAe,EAGf,YAAY,EAMb,MAAM,sBAAsB,CAAA;AAK7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAA;AAE1C,OA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