electron-updater 6.1.4 → 6.1.5
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/AppUpdater.d.ts +1 -1
- package/out/AppUpdater.js +56 -56
- package/out/AppUpdater.js.map +1 -1
- package/out/NsisUpdater.js +6 -1
- package/out/NsisUpdater.js.map +1 -1
- package/out/differentialDownloader/downloadPlanBuilder.js +1 -1
- package/out/differentialDownloader/downloadPlanBuilder.js.map +1 -1
- package/out/electronHttpExecutor.d.ts +1 -1
- package/out/main.d.ts +3 -3
- package/out/providers/Provider.d.ts +1 -1
- package/package.json +3 -3
package/out/AppUpdater.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { ProviderPlatform } from "./providers/Provider";
|
|
|
11
11
|
import type { TypedEmitter } from "tiny-typed-emitter";
|
|
12
12
|
import Session = Electron.Session;
|
|
13
13
|
import { AuthInfo } from "electron";
|
|
14
|
-
export
|
|
14
|
+
export type AppUpdaterEvents = {
|
|
15
15
|
error: (error: Error, message?: string) => void;
|
|
16
16
|
login: (info: AuthInfo, callback: LoginCallback) => void;
|
|
17
17
|
"checking-for-update": () => void;
|
package/out/AppUpdater.js
CHANGED
|
@@ -16,6 +16,62 @@ const GenericProvider_1 = require("./providers/GenericProvider");
|
|
|
16
16
|
const main_1 = require("./main");
|
|
17
17
|
const providerFactory_1 = require("./providerFactory");
|
|
18
18
|
class AppUpdater extends events_1.EventEmitter {
|
|
19
|
+
/**
|
|
20
|
+
* Get the update channel. Not applicable for GitHub. Doesn't return `channel` from the update configuration, only if was previously set.
|
|
21
|
+
*/
|
|
22
|
+
get channel() {
|
|
23
|
+
return this._channel;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Set the update channel. Not applicable for GitHub. Overrides `channel` in the update configuration.
|
|
27
|
+
*
|
|
28
|
+
* `allowDowngrade` will be automatically set to `true`. If this behavior is not suitable for you, simple set `allowDowngrade` explicitly after.
|
|
29
|
+
*/
|
|
30
|
+
set channel(value) {
|
|
31
|
+
if (this._channel != null) {
|
|
32
|
+
// noinspection SuspiciousTypeOfGuard
|
|
33
|
+
if (typeof value !== "string") {
|
|
34
|
+
throw (0, builder_util_runtime_1.newError)(`Channel must be a string, but got: ${value}`, "ERR_UPDATER_INVALID_CHANNEL");
|
|
35
|
+
}
|
|
36
|
+
else if (value.length === 0) {
|
|
37
|
+
throw (0, builder_util_runtime_1.newError)(`Channel must be not an empty string`, "ERR_UPDATER_INVALID_CHANNEL");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
this._channel = value;
|
|
41
|
+
this.allowDowngrade = true;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Shortcut for explicitly adding auth tokens to request headers
|
|
45
|
+
*/
|
|
46
|
+
addAuthHeader(token) {
|
|
47
|
+
this.requestHeaders = Object.assign({}, this.requestHeaders, {
|
|
48
|
+
authorization: token,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// noinspection JSMethodCanBeStatic,JSUnusedGlobalSymbols
|
|
52
|
+
get netSession() {
|
|
53
|
+
return (0, electronHttpExecutor_1.getNetSession)();
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The logger. You can pass [electron-log](https://github.com/megahertz/electron-log), [winston](https://github.com/winstonjs/winston) or another logger with the following interface: `{ info(), warn(), error() }`.
|
|
57
|
+
* Set it to `null` if you would like to disable a logging feature.
|
|
58
|
+
*/
|
|
59
|
+
get logger() {
|
|
60
|
+
return this._logger;
|
|
61
|
+
}
|
|
62
|
+
set logger(value) {
|
|
63
|
+
this._logger = value == null ? new NoOpLogger() : value;
|
|
64
|
+
}
|
|
65
|
+
// noinspection JSUnusedGlobalSymbols
|
|
66
|
+
/**
|
|
67
|
+
* test only
|
|
68
|
+
* @private
|
|
69
|
+
*/
|
|
70
|
+
set updateConfigPath(value) {
|
|
71
|
+
this.clientPromise = null;
|
|
72
|
+
this._appUpdateConfigPath = value;
|
|
73
|
+
this.configOnDisk = new lazy_val_1.Lazy(() => this.loadUpdateConfig());
|
|
74
|
+
}
|
|
19
75
|
constructor(options, app) {
|
|
20
76
|
super();
|
|
21
77
|
/**
|
|
@@ -117,62 +173,6 @@ class AppUpdater extends events_1.EventEmitter {
|
|
|
117
173
|
}
|
|
118
174
|
}
|
|
119
175
|
}
|
|
120
|
-
/**
|
|
121
|
-
* Get the update channel. Not applicable for GitHub. Doesn't return `channel` from the update configuration, only if was previously set.
|
|
122
|
-
*/
|
|
123
|
-
get channel() {
|
|
124
|
-
return this._channel;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Set the update channel. Not applicable for GitHub. Overrides `channel` in the update configuration.
|
|
128
|
-
*
|
|
129
|
-
* `allowDowngrade` will be automatically set to `true`. If this behavior is not suitable for you, simple set `allowDowngrade` explicitly after.
|
|
130
|
-
*/
|
|
131
|
-
set channel(value) {
|
|
132
|
-
if (this._channel != null) {
|
|
133
|
-
// noinspection SuspiciousTypeOfGuard
|
|
134
|
-
if (typeof value !== "string") {
|
|
135
|
-
throw (0, builder_util_runtime_1.newError)(`Channel must be a string, but got: ${value}`, "ERR_UPDATER_INVALID_CHANNEL");
|
|
136
|
-
}
|
|
137
|
-
else if (value.length === 0) {
|
|
138
|
-
throw (0, builder_util_runtime_1.newError)(`Channel must be not an empty string`, "ERR_UPDATER_INVALID_CHANNEL");
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
this._channel = value;
|
|
142
|
-
this.allowDowngrade = true;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Shortcut for explicitly adding auth tokens to request headers
|
|
146
|
-
*/
|
|
147
|
-
addAuthHeader(token) {
|
|
148
|
-
this.requestHeaders = Object.assign({}, this.requestHeaders, {
|
|
149
|
-
authorization: token,
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
// noinspection JSMethodCanBeStatic,JSUnusedGlobalSymbols
|
|
153
|
-
get netSession() {
|
|
154
|
-
return (0, electronHttpExecutor_1.getNetSession)();
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* The logger. You can pass [electron-log](https://github.com/megahertz/electron-log), [winston](https://github.com/winstonjs/winston) or another logger with the following interface: `{ info(), warn(), error() }`.
|
|
158
|
-
* Set it to `null` if you would like to disable a logging feature.
|
|
159
|
-
*/
|
|
160
|
-
get logger() {
|
|
161
|
-
return this._logger;
|
|
162
|
-
}
|
|
163
|
-
set logger(value) {
|
|
164
|
-
this._logger = value == null ? new NoOpLogger() : value;
|
|
165
|
-
}
|
|
166
|
-
// noinspection JSUnusedGlobalSymbols
|
|
167
|
-
/**
|
|
168
|
-
* test only
|
|
169
|
-
* @private
|
|
170
|
-
*/
|
|
171
|
-
set updateConfigPath(value) {
|
|
172
|
-
this.clientPromise = null;
|
|
173
|
-
this._appUpdateConfigPath = value;
|
|
174
|
-
this.configOnDisk = new lazy_val_1.Lazy(() => this.loadUpdateConfig());
|
|
175
|
-
}
|
|
176
176
|
//noinspection JSMethodCanBeStatic,JSUnusedGlobalSymbols
|
|
177
177
|
getFeedURL() {
|
|
178
178
|
return "Deprecated. Do not use it.";
|
package/out/AppUpdater.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppUpdater.js","sourceRoot":"","sources":["../src/AppUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAW6B;AAC7B,mCAAoC;AACpC,mCAAqC;AACrC,uCAAsE;AAEtE,qCAA8B;AAC9B,uCAA+B;AAC/B,6BAA4B;AAC5B,mCAA8K;AAE9K,qEAAuF;AACvF,6DAAyD;AACzD,iEAA2F;AAC3F,iEAA6D;AAC7D,iCAAgK;AAChK,uDAAwF;AAkBxF,MAAsB,UAAW,SAAS,qBAAyD;IAkKjG,YAAsB,OAA6C,EAAE,GAAgB;QACnF,KAAK,EAAE,CAAA;QAlKT;;WAEG;QACH,iBAAY,GAAG,IAAI,CAAA;QAEnB;;WAEG;QACH,yBAAoB,GAAG,IAAI,CAAA;QAE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,MAAa,UAAU;IACrB,6DAA6D;IAC7D,IAAI,CAAC,OAAa;QAChB,SAAS;IACX,CAAC;IAED,6DAA6D;IAC7D,IAAI,CAAC,OAAa;QAChB,SAAS;IACX,CAAC;IAED,6DAA6D;IAC7D,KAAK,CAAC,OAAa;QACjB,SAAS;IACX,CAAC;CACF;AAfD,gCAeC","sourcesContent":["import {\n AllPublishOptions,\n asArray,\n CancellationToken,\n newError,\n PublishConfiguration,\n UpdateInfo,\n UUID,\n DownloadOptions,\n CancellationError,\n ProgressInfo,\n} from \"builder-util-runtime\"\nimport { randomBytes } from \"crypto\"\nimport { EventEmitter } from \"events\"\nimport { mkdir, outputFile, readFile, rename, unlink } from \"fs-extra\"\nimport { OutgoingHttpHeaders } from \"http\"\nimport { load } from \"js-yaml\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { eq as isVersionsEqual, gt as isVersionGreaterThan, lt as isVersionLessThan, parse as parseVersion, prerelease as getVersionPreleaseComponents, SemVer } from \"semver\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { createTempUpdateFile, DownloadedUpdateHelper } from \"./DownloadedUpdateHelper\"\nimport { ElectronAppAdapter } from \"./ElectronAppAdapter\"\nimport { ElectronHttpExecutor, getNetSession, LoginCallback } from \"./electronHttpExecutor\"\nimport { GenericProvider } from \"./providers/GenericProvider\"\nimport { DOWNLOAD_PROGRESS, Logger, Provider, ResolvedUpdateFileInfo, UPDATE_DOWNLOADED, UpdateCheckResult, UpdateDownloadedEvent, UpdaterSignal } from \"./main\"\nimport { createClient, isUrlProbablySupportMultiRangeRequests } from \"./providerFactory\"\nimport { ProviderPlatform } from \"./providers/Provider\"\nimport type { TypedEmitter } from \"tiny-typed-emitter\"\nimport Session = Electron.Session\nimport { AuthInfo } from \"electron\"\n\nexport type AppUpdaterEvents = {\n error: (error: Error, message?: string) => void\n login: (info: AuthInfo, callback: LoginCallback) => void\n \"checking-for-update\": () => void\n \"update-not-available\": (info: UpdateInfo) => void\n \"update-available\": (info: UpdateInfo) => void\n \"update-downloaded\": (event: UpdateDownloadedEvent) => void\n \"download-progress\": (info: ProgressInfo) => void\n \"update-cancelled\": (info: UpdateInfo) => void\n \"appimage-filename-updated\": (path: string) => void\n}\n\nexport abstract class AppUpdater extends (EventEmitter as new () => TypedEmitter<AppUpdaterEvents>) {\n /**\n * Whether to automatically download an update when it is found.\n */\n autoDownload = true\n\n /**\n * Whether to automatically install a downloaded update on app quit (if `quitAndInstall` was not called before).\n */\n autoInstallOnAppQuit = true\n\n /**\n * *windows-only* Whether to run the app after finish install when run the installer NOT in silent mode.\n * @default true\n */\n autoRunAppAfterInstall = true\n\n /**\n * *GitHub provider only.* Whether to allow update to pre-release versions. Defaults to `true` if application version contains prerelease components (e.g. `0.12.1-alpha.1`, here `alpha` is a prerelease component), otherwise `false`.\n *\n * If `true`, downgrade will be allowed (`allowDowngrade` will be set to `true`).\n */\n allowPrerelease = false\n\n /**\n * *GitHub provider only.* Get all release notes (from current version to latest), not just the latest.\n * @default false\n */\n fullChangelog = false\n\n /**\n * Whether to allow version downgrade (when a user from the beta channel wants to go back to the stable channel).\n *\n * Taken in account only if channel differs (pre-release version component in terms of semantic versioning).\n *\n * @default false\n */\n allowDowngrade = false\n\n /**\n * Web installer files might not have signature verification, this switch prevents to load them unless it is needed.\n *\n * Currently false to prevent breaking the current API, but it should be changed to default true at some point that\n * breaking changes are allowed.\n *\n * @default false\n */\n disableWebInstaller = false\n\n /**\n * Allows developer to force the updater to work in \"dev\" mode, looking for \"dev-app-update.yml\" instead of \"app-update.yml\"\n * Dev: `path.join(this.app.getAppPath(), \"dev-app-update.yml\")`\n * Prod: `path.join(process.resourcesPath!, \"app-update.yml\")`\n *\n * @default false\n */\n forceDevUpdateConfig = false\n\n /**\n * The current application version.\n */\n readonly currentVersion: SemVer\n\n private _channel: string | null = null\n\n protected downloadedUpdateHelper: DownloadedUpdateHelper | null = null\n\n /**\n * Get the update channel. Not applicable for GitHub. Doesn't return `channel` from the update configuration, only if was previously set.\n */\n get channel(): string | null {\n return this._channel\n }\n\n /**\n * Set the update channel. Not applicable for GitHub. Overrides `channel` in the update configuration.\n *\n * `allowDowngrade` will be automatically set to `true`. If this behavior is not suitable for you, simple set `allowDowngrade` explicitly after.\n */\n set channel(value: string | null) {\n if (this._channel != null) {\n // noinspection SuspiciousTypeOfGuard\n if (typeof value !== \"string\") {\n throw newError(`Channel must be a string, but got: ${value}`, \"ERR_UPDATER_INVALID_CHANNEL\")\n } else if (value.length === 0) {\n throw newError(`Channel must be not an empty string`, \"ERR_UPDATER_INVALID_CHANNEL\")\n }\n }\n\n this._channel = value\n this.allowDowngrade = true\n }\n\n /**\n * The request headers.\n */\n requestHeaders: OutgoingHttpHeaders | null = null\n\n /**\n * Shortcut for explicitly adding auth tokens to request headers\n */\n addAuthHeader(token: string) {\n this.requestHeaders = Object.assign({}, this.requestHeaders, {\n authorization: token,\n })\n }\n\n protected _logger: Logger = console\n\n // noinspection JSMethodCanBeStatic,JSUnusedGlobalSymbols\n get netSession(): Session {\n return getNetSession()\n }\n\n /**\n * The logger. You can pass [electron-log](https://github.com/megahertz/electron-log), [winston](https://github.com/winstonjs/winston) or another logger with the following interface: `{ info(), warn(), error() }`.\n * Set it to `null` if you would like to disable a logging feature.\n */\n get logger(): Logger | null {\n return this._logger\n }\n\n set logger(value: Logger | null) {\n this._logger = value == null ? new NoOpLogger() : value\n }\n\n // noinspection JSUnusedGlobalSymbols\n /**\n * For type safety you can use signals, e.g. `autoUpdater.signals.updateDownloaded(() => {})` instead of `autoUpdater.on('update-available', () => {})`\n */\n readonly signals = new UpdaterSignal(this)\n\n private _appUpdateConfigPath: string | null = null\n\n // noinspection JSUnusedGlobalSymbols\n /**\n * test only\n * @private\n */\n set updateConfigPath(value: string | null) {\n this.clientPromise = null\n this._appUpdateConfigPath = value\n this.configOnDisk = new Lazy<any>(() => this.loadUpdateConfig())\n }\n\n private clientPromise: Promise<Provider<any>> | null = null\n\n protected readonly stagingUserIdPromise = new Lazy<string>(() => this.getOrCreateStagingUserId())\n\n // public, allow to read old config for anyone\n /** @internal */\n configOnDisk = new Lazy<any>(() => this.loadUpdateConfig())\n\n private checkForUpdatesPromise: Promise<UpdateCheckResult> | null = null\n\n protected readonly app: AppAdapter\n\n protected updateInfoAndProvider: UpdateInfoAndProvider | null = null\n\n /** @internal */\n readonly httpExecutor: ElectronHttpExecutor\n\n protected constructor(options: AllPublishOptions | null | undefined, app?: AppAdapter) {\n super()\n\n this.on(\"error\", (error: Error) => {\n this._logger.error(`Error: ${error.stack || error.message}`)\n })\n\n if (app == null) {\n this.app = new ElectronAppAdapter()\n this.httpExecutor = new ElectronHttpExecutor((authInfo, callback) => this.emit(\"login\", authInfo, callback))\n } else {\n this.app = app\n this.httpExecutor = null as any\n }\n\n const currentVersionString = this.app.version\n const currentVersion = parseVersion(currentVersionString)\n if (currentVersion == null) {\n throw newError(`App version is not a valid semver version: \"${currentVersionString}\"`, \"ERR_UPDATER_INVALID_VERSION\")\n }\n this.currentVersion = currentVersion\n this.allowPrerelease = hasPrereleaseComponents(currentVersion)\n\n if (options != null) {\n this.setFeedURL(options)\n\n if (typeof options !== \"string\" && options.requestHeaders) {\n this.requestHeaders = options.requestHeaders\n }\n }\n }\n\n //noinspection JSMethodCanBeStatic,JSUnusedGlobalSymbols\n getFeedURL(): string | null | undefined {\n return \"Deprecated. Do not use it.\"\n }\n\n /**\n * Configure update provider. If value is `string`, [GenericServerOptions](/configuration/publish#genericserveroptions) will be set with value as `url`.\n * @param options If you want to override configuration in the `app-update.yml`.\n */\n setFeedURL(options: PublishConfiguration | AllPublishOptions | string) {\n const runtimeOptions = this.createProviderRuntimeOptions()\n // https://github.com/electron-userland/electron-builder/issues/1105\n let provider: Provider<any>\n if (typeof options === \"string\") {\n provider = new GenericProvider({ provider: \"generic\", url: options }, this, {\n ...runtimeOptions,\n isUseMultipleRangeRequest: isUrlProbablySupportMultiRangeRequests(options),\n })\n } else {\n provider = createClient(options, this, runtimeOptions)\n }\n this.clientPromise = Promise.resolve(provider)\n }\n\n /**\n * Asks the server whether there is an update.\n */\n checkForUpdates(): Promise<UpdateCheckResult | null> {\n if (!this.isUpdaterActive()) {\n return Promise.resolve(null)\n }\n\n let checkForUpdatesPromise = this.checkForUpdatesPromise\n if (checkForUpdatesPromise != null) {\n this._logger.info(\"Checking for update (already in progress)\")\n return checkForUpdatesPromise\n }\n\n const nullizePromise = () => (this.checkForUpdatesPromise = null)\n\n this._logger.info(\"Checking for update\")\n checkForUpdatesPromise = this.doCheckForUpdates()\n .then(it => {\n nullizePromise()\n return it\n })\n .catch((e: any) => {\n nullizePromise()\n this.emit(\"error\", e, `Cannot check for updates: ${(e.stack || e).toString()}`)\n throw e\n })\n\n this.checkForUpdatesPromise = checkForUpdatesPromise\n return checkForUpdatesPromise\n }\n\n public isUpdaterActive(): boolean {\n const isEnabled = this.app.isPackaged || this.forceDevUpdateConfig\n if (!isEnabled) {\n this._logger.info(\"Skip checkForUpdates because application is not packed and dev update config is not forced\")\n return false\n }\n return true\n }\n\n // noinspection JSUnusedGlobalSymbols\n checkForUpdatesAndNotify(downloadNotification?: DownloadNotification): Promise<UpdateCheckResult | null> {\n return this.checkForUpdates().then(it => {\n if (!it?.downloadPromise) {\n if (this._logger.debug != null) {\n this._logger.debug(\"checkForUpdatesAndNotify called, downloadPromise is null\")\n }\n return it\n }\n\n void it.downloadPromise.then(() => {\n const notificationContent = AppUpdater.formatDownloadNotification(it.updateInfo.version, this.app.name, downloadNotification)\n new (require(\"electron\").Notification)(notificationContent).show()\n })\n\n return it\n })\n }\n\n private static formatDownloadNotification(version: string, appName: string, downloadNotification?: DownloadNotification): DownloadNotification {\n if (downloadNotification == null) {\n downloadNotification = {\n title: \"A new update is ready to install\",\n body: `{appName} version {version} has been downloaded and will be automatically installed on exit`,\n }\n }\n downloadNotification = {\n title: downloadNotification.title.replace(\"{appName}\", appName).replace(\"{version}\", version),\n body: downloadNotification.body.replace(\"{appName}\", appName).replace(\"{version}\", version),\n }\n return downloadNotification\n }\n\n private async isStagingMatch(updateInfo: UpdateInfo): Promise<boolean> {\n const rawStagingPercentage = updateInfo.stagingPercentage\n let stagingPercentage = rawStagingPercentage\n if (stagingPercentage == null) {\n return true\n }\n\n stagingPercentage = parseInt(stagingPercentage as any, 10)\n if (isNaN(stagingPercentage)) {\n this._logger.warn(`Staging percentage is NaN: ${rawStagingPercentage}`)\n return true\n }\n\n // convert from user 0-100 to internal 0-1\n stagingPercentage = stagingPercentage / 100\n\n const stagingUserId = await this.stagingUserIdPromise.value\n const val = UUID.parse(stagingUserId).readUInt32BE(12)\n const percentage = val / 0xffffffff\n this._logger.info(`Staging percentage: ${stagingPercentage}, percentage: ${percentage}, user id: ${stagingUserId}`)\n return percentage < stagingPercentage\n }\n\n private computeFinalHeaders(headers: OutgoingHttpHeaders) {\n if (this.requestHeaders != null) {\n Object.assign(headers, this.requestHeaders)\n }\n return headers\n }\n\n private async isUpdateAvailable(updateInfo: UpdateInfo): Promise<boolean> {\n const latestVersion = parseVersion(updateInfo.version)\n if (latestVersion == null) {\n throw newError(\n `This file could not be downloaded, or the latest version (from update server) does not have a valid semver version: \"${updateInfo.version}\"`,\n \"ERR_UPDATER_INVALID_VERSION\"\n )\n }\n\n const currentVersion = this.currentVersion\n if (isVersionsEqual(latestVersion, currentVersion)) {\n return false\n }\n\n const isStagingMatch = await this.isStagingMatch(updateInfo)\n if (!isStagingMatch) {\n return false\n }\n\n // https://github.com/electron-userland/electron-builder/pull/3111#issuecomment-405033227\n // https://github.com/electron-userland/electron-builder/pull/3111#issuecomment-405030797\n const isLatestVersionNewer = isVersionGreaterThan(latestVersion, currentVersion)\n const isLatestVersionOlder = isVersionLessThan(latestVersion, currentVersion)\n\n if (isLatestVersionNewer) {\n return true\n }\n return this.allowDowngrade && isLatestVersionOlder\n }\n\n protected async getUpdateInfoAndProvider(): Promise<UpdateInfoAndProvider> {\n await this.app.whenReady()\n\n if (this.clientPromise == null) {\n this.clientPromise = this.configOnDisk.value.then(it => createClient(it, this, this.createProviderRuntimeOptions()))\n }\n\n const client = await this.clientPromise\n const stagingUserId = await this.stagingUserIdPromise.value\n client.setRequestHeaders(this.computeFinalHeaders({ \"x-user-staging-id\": stagingUserId }))\n return {\n info: await client.getLatestVersion(),\n provider: client,\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n private createProviderRuntimeOptions() {\n return {\n isUseMultipleRangeRequest: true,\n platform: this._testOnlyOptions == null ? (process.platform as ProviderPlatform) : this._testOnlyOptions.platform,\n executor: this.httpExecutor,\n }\n }\n\n private async doCheckForUpdates(): Promise<UpdateCheckResult> {\n this.emit(\"checking-for-update\")\n\n const result = await this.getUpdateInfoAndProvider()\n const updateInfo = result.info\n if (!(await this.isUpdateAvailable(updateInfo))) {\n this._logger.info(\n `Update for version ${this.currentVersion} is not available (latest version: ${updateInfo.version}, downgrade is ${this.allowDowngrade ? \"allowed\" : \"disallowed\"}).`\n )\n this.emit(\"update-not-available\", updateInfo)\n return {\n versionInfo: updateInfo,\n updateInfo,\n }\n }\n\n this.updateInfoAndProvider = result\n this.onUpdateAvailable(updateInfo)\n\n const cancellationToken = new CancellationToken()\n //noinspection ES6MissingAwait\n return {\n versionInfo: updateInfo,\n updateInfo,\n cancellationToken,\n downloadPromise: this.autoDownload ? this.downloadUpdate(cancellationToken) : null,\n }\n }\n\n protected onUpdateAvailable(updateInfo: UpdateInfo): void {\n this._logger.info(\n `Found version ${updateInfo.version} (url: ${asArray(updateInfo.files)\n .map(it => it.url)\n .join(\", \")})`\n )\n this.emit(\"update-available\", updateInfo)\n }\n\n /**\n * Start downloading update manually. You can use this method if `autoDownload` option is set to `false`.\n * @returns {Promise<Array<string>>} Paths to downloaded files.\n */\n downloadUpdate(cancellationToken: CancellationToken = new CancellationToken()): Promise<Array<string>> {\n const updateInfoAndProvider = this.updateInfoAndProvider\n if (updateInfoAndProvider == null) {\n const error = new Error(\"Please check update first\")\n this.dispatchError(error)\n return Promise.reject(error)\n }\n\n this._logger.info(\n `Downloading update from ${asArray(updateInfoAndProvider.info.files)\n .map(it => it.url)\n .join(\", \")}`\n )\n const errorHandler = (e: Error): Error => {\n // https://github.com/electron-userland/electron-builder/issues/1150#issuecomment-436891159\n if (!(e instanceof CancellationError)) {\n try {\n this.dispatchError(e)\n } catch (nestedError: any) {\n this._logger.warn(`Cannot dispatch error event: ${nestedError.stack || nestedError}`)\n }\n }\n\n return e\n }\n\n try {\n return this.doDownloadUpdate({\n updateInfoAndProvider,\n requestHeaders: this.computeRequestHeaders(updateInfoAndProvider.provider),\n cancellationToken,\n disableWebInstaller: this.disableWebInstaller,\n }).catch((e: any) => {\n throw errorHandler(e)\n })\n } catch (e: any) {\n return Promise.reject(errorHandler(e))\n }\n }\n\n protected dispatchError(e: Error): void {\n this.emit(\"error\", e, (e.stack || e).toString())\n }\n\n protected dispatchUpdateDownloaded(event: UpdateDownloadedEvent): void {\n this.emit(UPDATE_DOWNLOADED, event)\n }\n\n protected abstract doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>>\n\n /**\n * Restarts the app and installs the update after it has been downloaded.\n * It should only be called after `update-downloaded` has been emitted.\n *\n * **Note:** `autoUpdater.quitAndInstall()` will close all application windows first and only emit `before-quit` event on `app` after that.\n * This is different from the normal quit event sequence.\n *\n * @param isSilent *windows-only* Runs the installer in silent mode. Defaults to `false`.\n * @param isForceRunAfter Run the app after finish even on silent install. Not applicable for macOS.\n * Ignored if `isSilent` is set to `false`(In this case you can still set `autoRunAppAfterInstall` to `false` to prevent run the app after finish).\n */\n abstract quitAndInstall(isSilent?: boolean, isForceRunAfter?: boolean): void\n\n private async loadUpdateConfig(): Promise<any> {\n if (this._appUpdateConfigPath == null) {\n this._appUpdateConfigPath = this.app.appUpdateConfigPath\n }\n return load(await readFile(this._appUpdateConfigPath, \"utf-8\"))\n }\n\n private computeRequestHeaders(provider: Provider<any>): OutgoingHttpHeaders {\n const fileExtraDownloadHeaders = provider.fileExtraDownloadHeaders\n if (fileExtraDownloadHeaders != null) {\n const requestHeaders = this.requestHeaders\n return requestHeaders == null\n ? fileExtraDownloadHeaders\n : {\n ...fileExtraDownloadHeaders,\n ...requestHeaders,\n }\n }\n return this.computeFinalHeaders({ accept: \"*/*\" })\n }\n\n private async getOrCreateStagingUserId(): Promise<string> {\n const file = path.join(this.app.userDataPath, \".updaterId\")\n try {\n const id = await readFile(file, \"utf-8\")\n if (UUID.check(id)) {\n return id\n } else {\n this._logger.warn(`Staging user id file exists, but content was invalid: ${id}`)\n }\n } catch (e: any) {\n if (e.code !== \"ENOENT\") {\n this._logger.warn(`Couldn't read staging user ID, creating a blank one: ${e}`)\n }\n }\n\n const id = UUID.v5(randomBytes(4096), UUID.OID)\n this._logger.info(`Generated new staging user ID: ${id}`)\n try {\n await outputFile(file, id)\n } catch (e: any) {\n this._logger.warn(`Couldn't write out staging user ID: ${e}`)\n }\n return id\n }\n\n /** @internal */\n get isAddNoCacheQuery(): boolean {\n const headers = this.requestHeaders\n // https://github.com/electron-userland/electron-builder/issues/3021\n if (headers == null) {\n return true\n }\n\n for (const headerName of Object.keys(headers)) {\n const s = headerName.toLowerCase()\n if (s === \"authorization\" || s === \"private-token\") {\n return false\n }\n }\n return true\n }\n\n /**\n * @private\n * @internal\n */\n _testOnlyOptions: TestOnlyUpdaterOptions | null = null\n\n private async getOrCreateDownloadHelper(): Promise<DownloadedUpdateHelper> {\n let result = this.downloadedUpdateHelper\n if (result == null) {\n const dirName = (await this.configOnDisk.value).updaterCacheDirName\n const logger = this._logger\n if (dirName == null) {\n logger.error(\"updaterCacheDirName is not specified in app-update.yml Was app build using at least electron-builder 20.34.0?\")\n }\n const cacheDir = path.join(this.app.baseCachePath, dirName || this.app.name)\n if (logger.debug != null) {\n logger.debug(`updater cache dir: ${cacheDir}`)\n }\n\n result = new DownloadedUpdateHelper(cacheDir)\n this.downloadedUpdateHelper = result\n }\n return result\n }\n\n protected async executeDownload(taskOptions: DownloadExecutorTask): Promise<Array<string>> {\n const fileInfo = taskOptions.fileInfo\n const downloadOptions: DownloadOptions = {\n headers: taskOptions.downloadUpdateOptions.requestHeaders,\n cancellationToken: taskOptions.downloadUpdateOptions.cancellationToken,\n sha2: (fileInfo.info as any).sha2,\n sha512: fileInfo.info.sha512,\n }\n\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n\n const updateInfo = taskOptions.downloadUpdateOptions.updateInfoAndProvider.info\n const version = updateInfo.version\n const packageInfo = fileInfo.packageInfo\n\n function getCacheUpdateFileName(): string {\n // NodeJS URL doesn't decode automatically\n const urlPath = decodeURIComponent(taskOptions.fileInfo.url.pathname)\n if (urlPath.endsWith(`.${taskOptions.fileExtension}`)) {\n return path.basename(urlPath)\n } else {\n // url like /latest, generate name\n return taskOptions.fileInfo.info.url\n }\n }\n\n const downloadedUpdateHelper = await this.getOrCreateDownloadHelper()\n const cacheDir = downloadedUpdateHelper.cacheDirForPendingUpdate\n await mkdir(cacheDir, { recursive: true })\n const updateFileName = getCacheUpdateFileName()\n let updateFile = path.join(cacheDir, updateFileName)\n const packageFile = packageInfo == null ? null : path.join(cacheDir, `package-${version}${path.extname(packageInfo.path) || \".7z\"}`)\n\n const done = async (isSaveCache: boolean) => {\n await downloadedUpdateHelper.setDownloadedFile(updateFile, packageFile, updateInfo, fileInfo, updateFileName, isSaveCache)\n await taskOptions.done!({\n ...updateInfo,\n downloadedFile: updateFile,\n })\n return packageFile == null ? [updateFile] : [updateFile, packageFile]\n }\n\n const log = this._logger\n const cachedUpdateFile = await downloadedUpdateHelper.validateDownloadedPath(updateFile, updateInfo, fileInfo, log)\n if (cachedUpdateFile != null) {\n updateFile = cachedUpdateFile\n return await done(false)\n }\n\n const removeFileIfAny = async () => {\n await downloadedUpdateHelper.clear().catch(() => {\n // ignore\n })\n return await unlink(updateFile).catch(() => {\n // ignore\n })\n }\n\n const tempUpdateFile = await createTempUpdateFile(`temp-${updateFileName}`, cacheDir, log)\n try {\n await taskOptions.task(tempUpdateFile, downloadOptions, packageFile, removeFileIfAny)\n await rename(tempUpdateFile, updateFile)\n } catch (e: any) {\n await removeFileIfAny()\n\n if (e instanceof CancellationError) {\n log.info(\"cancelled\")\n this.emit(\"update-cancelled\", updateInfo)\n }\n throw e\n }\n\n log.info(`New version ${version} has been downloaded to ${updateFile}`)\n return await done(true)\n }\n}\n\nexport interface DownloadUpdateOptions {\n readonly updateInfoAndProvider: UpdateInfoAndProvider\n readonly requestHeaders: OutgoingHttpHeaders\n readonly cancellationToken: CancellationToken\n readonly disableWebInstaller?: boolean\n}\n\nfunction hasPrereleaseComponents(version: SemVer) {\n const versionPrereleaseComponent = getVersionPreleaseComponents(version)\n return versionPrereleaseComponent != null && versionPrereleaseComponent.length > 0\n}\n\n/** @private */\nexport class NoOpLogger implements Logger {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n info(message?: any) {\n // ignore\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n warn(message?: any) {\n // ignore\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n error(message?: any) {\n // ignore\n }\n}\n\nexport interface UpdateInfoAndProvider {\n info: UpdateInfo\n provider: Provider<any>\n}\n\nexport interface DownloadExecutorTask {\n readonly fileExtension: string\n readonly fileInfo: ResolvedUpdateFileInfo\n readonly downloadUpdateOptions: DownloadUpdateOptions\n readonly task: (destinationFile: string, downloadOptions: DownloadOptions, packageFile: string | null, removeTempDirIfAny: () => Promise<any>) => Promise<any>\n\n readonly done?: (event: UpdateDownloadedEvent) => Promise<any>\n}\n\nexport interface DownloadNotification {\n body: string\n title: string\n}\n\n/** @private */\nexport interface TestOnlyUpdaterOptions {\n platform: ProviderPlatform\n\n isUseDifferentialDownload?: boolean\n}\n"]}
|
|
1
|
+
{"version":3,"file":"AppUpdater.js","sourceRoot":"","sources":["../src/AppUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAW6B;AAC7B,mCAAoC;AACpC,m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SACR;QAED,GAAG,CAAC,IAAI,CAAC,eAAe,OAAO,2BAA2B,UAAU,EAAE,CAAC,CAAA;QACvE,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;CACF;AAvoBD,gCAuoBC;AASD,SAAS,uBAAuB,CAAC,OAAe;IAC9C,MAAM,0BAA0B,GAAG,IAAA,mBAA4B,EAAC,OAAO,CAAC,CAAA;IACxE,OAAO,0BAA0B,IAAI,IAAI,IAAI,0BAA0B,CAAC,MAAM,GAAG,CAAC,CAAA;AACpF,CAAC;AAED,eAAe;AACf,MAAa,UAAU;IACrB,6DAA6D;IAC7D,IAAI,CAAC,OAAa;QAChB,SAAS;IACX,CAAC;IAED,6DAA6D;IAC7D,IAAI,CAAC,OAAa;QAChB,SAAS;IACX,CAAC;IAED,6DAA6D;IAC7D,KAAK,CAAC,OAAa;QACjB,SAAS;IACX,CAAC;CACF;AAfD,gCAeC","sourcesContent":["import {\n AllPublishOptions,\n asArray,\n CancellationToken,\n newError,\n PublishConfiguration,\n UpdateInfo,\n UUID,\n DownloadOptions,\n CancellationError,\n ProgressInfo,\n} from \"builder-util-runtime\"\nimport { randomBytes } from \"crypto\"\nimport { EventEmitter } from \"events\"\nimport { mkdir, outputFile, readFile, rename, unlink } from \"fs-extra\"\nimport { OutgoingHttpHeaders } from \"http\"\nimport { load } from \"js-yaml\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { eq as isVersionsEqual, gt as isVersionGreaterThan, lt as isVersionLessThan, parse as parseVersion, prerelease as getVersionPreleaseComponents, SemVer } from \"semver\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { createTempUpdateFile, DownloadedUpdateHelper } from \"./DownloadedUpdateHelper\"\nimport { ElectronAppAdapter } from \"./ElectronAppAdapter\"\nimport { ElectronHttpExecutor, getNetSession, LoginCallback } from \"./electronHttpExecutor\"\nimport { GenericProvider } from \"./providers/GenericProvider\"\nimport { DOWNLOAD_PROGRESS, Logger, Provider, ResolvedUpdateFileInfo, UPDATE_DOWNLOADED, UpdateCheckResult, UpdateDownloadedEvent, UpdaterSignal } from \"./main\"\nimport { createClient, isUrlProbablySupportMultiRangeRequests } from \"./providerFactory\"\nimport { ProviderPlatform } from \"./providers/Provider\"\nimport type { TypedEmitter } from \"tiny-typed-emitter\"\nimport Session = Electron.Session\nimport { AuthInfo } from \"electron\"\n\nexport type AppUpdaterEvents = {\n error: (error: Error, message?: string) => void\n login: (info: AuthInfo, callback: LoginCallback) => void\n \"checking-for-update\": () => void\n \"update-not-available\": (info: UpdateInfo) => void\n \"update-available\": (info: UpdateInfo) => void\n \"update-downloaded\": (event: UpdateDownloadedEvent) => void\n \"download-progress\": (info: ProgressInfo) => void\n \"update-cancelled\": (info: UpdateInfo) => void\n \"appimage-filename-updated\": (path: string) => void\n}\n\nexport abstract class AppUpdater extends (EventEmitter as new () => TypedEmitter<AppUpdaterEvents>) {\n /**\n * Whether to automatically download an update when it is found.\n */\n autoDownload = true\n\n /**\n * Whether to automatically install a downloaded update on app quit (if `quitAndInstall` was not called before).\n */\n autoInstallOnAppQuit = true\n\n /**\n * *windows-only* Whether to run the app after finish install when run the installer NOT in silent mode.\n * @default true\n */\n autoRunAppAfterInstall = true\n\n /**\n * *GitHub provider only.* Whether to allow update to pre-release versions. Defaults to `true` if application version contains prerelease components (e.g. `0.12.1-alpha.1`, here `alpha` is a prerelease component), otherwise `false`.\n *\n * If `true`, downgrade will be allowed (`allowDowngrade` will be set to `true`).\n */\n allowPrerelease = false\n\n /**\n * *GitHub provider only.* Get all release notes (from current version to latest), not just the latest.\n * @default false\n */\n fullChangelog = false\n\n /**\n * Whether to allow version downgrade (when a user from the beta channel wants to go back to the stable channel).\n *\n * Taken in account only if channel differs (pre-release version component in terms of semantic versioning).\n *\n * @default false\n */\n allowDowngrade = false\n\n /**\n * Web installer files might not have signature verification, this switch prevents to load them unless it is needed.\n *\n * Currently false to prevent breaking the current API, but it should be changed to default true at some point that\n * breaking changes are allowed.\n *\n * @default false\n */\n disableWebInstaller = false\n\n /**\n * Allows developer to force the updater to work in \"dev\" mode, looking for \"dev-app-update.yml\" instead of \"app-update.yml\"\n * Dev: `path.join(this.app.getAppPath(), \"dev-app-update.yml\")`\n * Prod: `path.join(process.resourcesPath!, \"app-update.yml\")`\n *\n * @default false\n */\n forceDevUpdateConfig = false\n\n /**\n * The current application version.\n */\n readonly currentVersion: SemVer\n\n private _channel: string | null = null\n\n protected downloadedUpdateHelper: DownloadedUpdateHelper | null = null\n\n /**\n * Get the update channel. Not applicable for GitHub. Doesn't return `channel` from the update configuration, only if was previously set.\n */\n get channel(): string | null {\n return this._channel\n }\n\n /**\n * Set the update channel. Not applicable for GitHub. Overrides `channel` in the update configuration.\n *\n * `allowDowngrade` will be automatically set to `true`. If this behavior is not suitable for you, simple set `allowDowngrade` explicitly after.\n */\n set channel(value: string | null) {\n if (this._channel != null) {\n // noinspection SuspiciousTypeOfGuard\n if (typeof value !== \"string\") {\n throw newError(`Channel must be a string, but got: ${value}`, \"ERR_UPDATER_INVALID_CHANNEL\")\n } else if (value.length === 0) {\n throw newError(`Channel must be not an empty string`, \"ERR_UPDATER_INVALID_CHANNEL\")\n }\n }\n\n this._channel = value\n this.allowDowngrade = true\n }\n\n /**\n * The request headers.\n */\n requestHeaders: OutgoingHttpHeaders | null = null\n\n /**\n * Shortcut for explicitly adding auth tokens to request headers\n */\n addAuthHeader(token: string) {\n this.requestHeaders = Object.assign({}, this.requestHeaders, {\n authorization: token,\n })\n }\n\n protected _logger: Logger = console\n\n // noinspection JSMethodCanBeStatic,JSUnusedGlobalSymbols\n get netSession(): Session {\n return getNetSession()\n }\n\n /**\n * The logger. You can pass [electron-log](https://github.com/megahertz/electron-log), [winston](https://github.com/winstonjs/winston) or another logger with the following interface: `{ info(), warn(), error() }`.\n * Set it to `null` if you would like to disable a logging feature.\n */\n get logger(): Logger | null {\n return this._logger\n }\n\n set logger(value: Logger | null) {\n this._logger = value == null ? new NoOpLogger() : value\n }\n\n // noinspection JSUnusedGlobalSymbols\n /**\n * For type safety you can use signals, e.g. `autoUpdater.signals.updateDownloaded(() => {})` instead of `autoUpdater.on('update-available', () => {})`\n */\n readonly signals = new UpdaterSignal(this)\n\n private _appUpdateConfigPath: string | null = null\n\n // noinspection JSUnusedGlobalSymbols\n /**\n * test only\n * @private\n */\n set updateConfigPath(value: string | null) {\n this.clientPromise = null\n this._appUpdateConfigPath = value\n this.configOnDisk = new Lazy<any>(() => this.loadUpdateConfig())\n }\n\n private clientPromise: Promise<Provider<any>> | null = null\n\n protected readonly stagingUserIdPromise = new Lazy<string>(() => this.getOrCreateStagingUserId())\n\n // public, allow to read old config for anyone\n /** @internal */\n configOnDisk = new Lazy<any>(() => this.loadUpdateConfig())\n\n private checkForUpdatesPromise: Promise<UpdateCheckResult> | null = null\n\n protected readonly app: AppAdapter\n\n protected updateInfoAndProvider: UpdateInfoAndProvider | null = null\n\n /** @internal */\n readonly httpExecutor: ElectronHttpExecutor\n\n protected constructor(options: AllPublishOptions | null | undefined, app?: AppAdapter) {\n super()\n\n this.on(\"error\", (error: Error) => {\n this._logger.error(`Error: ${error.stack || error.message}`)\n })\n\n if (app == null) {\n this.app = new ElectronAppAdapter()\n this.httpExecutor = new ElectronHttpExecutor((authInfo, callback) => this.emit(\"login\", authInfo, callback))\n } else {\n this.app = app\n this.httpExecutor = null as any\n }\n\n const currentVersionString = this.app.version\n const currentVersion = parseVersion(currentVersionString)\n if (currentVersion == null) {\n throw newError(`App version is not a valid semver version: \"${currentVersionString}\"`, \"ERR_UPDATER_INVALID_VERSION\")\n }\n this.currentVersion = currentVersion\n this.allowPrerelease = hasPrereleaseComponents(currentVersion)\n\n if (options != null) {\n this.setFeedURL(options)\n\n if (typeof options !== \"string\" && options.requestHeaders) {\n this.requestHeaders = options.requestHeaders\n }\n }\n }\n\n //noinspection JSMethodCanBeStatic,JSUnusedGlobalSymbols\n getFeedURL(): string | null | undefined {\n return \"Deprecated. Do not use it.\"\n }\n\n /**\n * Configure update provider. If value is `string`, [GenericServerOptions](/configuration/publish#genericserveroptions) will be set with value as `url`.\n * @param options If you want to override configuration in the `app-update.yml`.\n */\n setFeedURL(options: PublishConfiguration | AllPublishOptions | string) {\n const runtimeOptions = this.createProviderRuntimeOptions()\n // https://github.com/electron-userland/electron-builder/issues/1105\n let provider: Provider<any>\n if (typeof options === \"string\") {\n provider = new GenericProvider({ provider: \"generic\", url: options }, this, {\n ...runtimeOptions,\n isUseMultipleRangeRequest: isUrlProbablySupportMultiRangeRequests(options),\n })\n } else {\n provider = createClient(options, this, runtimeOptions)\n }\n this.clientPromise = Promise.resolve(provider)\n }\n\n /**\n * Asks the server whether there is an update.\n */\n checkForUpdates(): Promise<UpdateCheckResult | null> {\n if (!this.isUpdaterActive()) {\n return Promise.resolve(null)\n }\n\n let checkForUpdatesPromise = this.checkForUpdatesPromise\n if (checkForUpdatesPromise != null) {\n this._logger.info(\"Checking for update (already in progress)\")\n return checkForUpdatesPromise\n }\n\n const nullizePromise = () => (this.checkForUpdatesPromise = null)\n\n this._logger.info(\"Checking for update\")\n checkForUpdatesPromise = this.doCheckForUpdates()\n .then(it => {\n nullizePromise()\n return it\n })\n .catch((e: any) => {\n nullizePromise()\n this.emit(\"error\", e, `Cannot check for updates: ${(e.stack || e).toString()}`)\n throw e\n })\n\n this.checkForUpdatesPromise = checkForUpdatesPromise\n return checkForUpdatesPromise\n }\n\n public isUpdaterActive(): boolean {\n const isEnabled = this.app.isPackaged || this.forceDevUpdateConfig\n if (!isEnabled) {\n this._logger.info(\"Skip checkForUpdates because application is not packed and dev update config is not forced\")\n return false\n }\n return true\n }\n\n // noinspection JSUnusedGlobalSymbols\n checkForUpdatesAndNotify(downloadNotification?: DownloadNotification): Promise<UpdateCheckResult | null> {\n return this.checkForUpdates().then(it => {\n if (!it?.downloadPromise) {\n if (this._logger.debug != null) {\n this._logger.debug(\"checkForUpdatesAndNotify called, downloadPromise is null\")\n }\n return it\n }\n\n void it.downloadPromise.then(() => {\n const notificationContent = AppUpdater.formatDownloadNotification(it.updateInfo.version, this.app.name, downloadNotification)\n new (require(\"electron\").Notification)(notificationContent).show()\n })\n\n return it\n })\n }\n\n private static formatDownloadNotification(version: string, appName: string, downloadNotification?: DownloadNotification): DownloadNotification {\n if (downloadNotification == null) {\n downloadNotification = {\n title: \"A new update is ready to install\",\n body: `{appName} version {version} has been downloaded and will be automatically installed on exit`,\n }\n }\n downloadNotification = {\n title: downloadNotification.title.replace(\"{appName}\", appName).replace(\"{version}\", version),\n body: downloadNotification.body.replace(\"{appName}\", appName).replace(\"{version}\", version),\n }\n return downloadNotification\n }\n\n private async isStagingMatch(updateInfo: UpdateInfo): Promise<boolean> {\n const rawStagingPercentage = updateInfo.stagingPercentage\n let stagingPercentage = rawStagingPercentage\n if (stagingPercentage == null) {\n return true\n }\n\n stagingPercentage = parseInt(stagingPercentage as any, 10)\n if (isNaN(stagingPercentage)) {\n this._logger.warn(`Staging percentage is NaN: ${rawStagingPercentage}`)\n return true\n }\n\n // convert from user 0-100 to internal 0-1\n stagingPercentage = stagingPercentage / 100\n\n const stagingUserId = await this.stagingUserIdPromise.value\n const val = UUID.parse(stagingUserId).readUInt32BE(12)\n const percentage = val / 0xffffffff\n this._logger.info(`Staging percentage: ${stagingPercentage}, percentage: ${percentage}, user id: ${stagingUserId}`)\n return percentage < stagingPercentage\n }\n\n private computeFinalHeaders(headers: OutgoingHttpHeaders) {\n if (this.requestHeaders != null) {\n Object.assign(headers, this.requestHeaders)\n }\n return headers\n }\n\n private async isUpdateAvailable(updateInfo: UpdateInfo): Promise<boolean> {\n const latestVersion = parseVersion(updateInfo.version)\n if (latestVersion == null) {\n throw newError(\n `This file could not be downloaded, or the latest version (from update server) does not have a valid semver version: \"${updateInfo.version}\"`,\n \"ERR_UPDATER_INVALID_VERSION\"\n )\n }\n\n const currentVersion = this.currentVersion\n if (isVersionsEqual(latestVersion, currentVersion)) {\n return false\n }\n\n const isStagingMatch = await this.isStagingMatch(updateInfo)\n if (!isStagingMatch) {\n return false\n }\n\n // https://github.com/electron-userland/electron-builder/pull/3111#issuecomment-405033227\n // https://github.com/electron-userland/electron-builder/pull/3111#issuecomment-405030797\n const isLatestVersionNewer = isVersionGreaterThan(latestVersion, currentVersion)\n const isLatestVersionOlder = isVersionLessThan(latestVersion, currentVersion)\n\n if (isLatestVersionNewer) {\n return true\n }\n return this.allowDowngrade && isLatestVersionOlder\n }\n\n protected async getUpdateInfoAndProvider(): Promise<UpdateInfoAndProvider> {\n await this.app.whenReady()\n\n if (this.clientPromise == null) {\n this.clientPromise = this.configOnDisk.value.then(it => createClient(it, this, this.createProviderRuntimeOptions()))\n }\n\n const client = await this.clientPromise\n const stagingUserId = await this.stagingUserIdPromise.value\n client.setRequestHeaders(this.computeFinalHeaders({ \"x-user-staging-id\": stagingUserId }))\n return {\n info: await client.getLatestVersion(),\n provider: client,\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n private createProviderRuntimeOptions() {\n return {\n isUseMultipleRangeRequest: true,\n platform: this._testOnlyOptions == null ? (process.platform as ProviderPlatform) : this._testOnlyOptions.platform,\n executor: this.httpExecutor,\n }\n }\n\n private async doCheckForUpdates(): Promise<UpdateCheckResult> {\n this.emit(\"checking-for-update\")\n\n const result = await this.getUpdateInfoAndProvider()\n const updateInfo = result.info\n if (!(await this.isUpdateAvailable(updateInfo))) {\n this._logger.info(\n `Update for version ${this.currentVersion} is not available (latest version: ${updateInfo.version}, downgrade is ${this.allowDowngrade ? \"allowed\" : \"disallowed\"}).`\n )\n this.emit(\"update-not-available\", updateInfo)\n return {\n versionInfo: updateInfo,\n updateInfo,\n }\n }\n\n this.updateInfoAndProvider = result\n this.onUpdateAvailable(updateInfo)\n\n const cancellationToken = new CancellationToken()\n //noinspection ES6MissingAwait\n return {\n versionInfo: updateInfo,\n updateInfo,\n cancellationToken,\n downloadPromise: this.autoDownload ? this.downloadUpdate(cancellationToken) : null,\n }\n }\n\n protected onUpdateAvailable(updateInfo: UpdateInfo): void {\n this._logger.info(\n `Found version ${updateInfo.version} (url: ${asArray(updateInfo.files)\n .map(it => it.url)\n .join(\", \")})`\n )\n this.emit(\"update-available\", updateInfo)\n }\n\n /**\n * Start downloading update manually. You can use this method if `autoDownload` option is set to `false`.\n * @returns {Promise<Array<string>>} Paths to downloaded files.\n */\n downloadUpdate(cancellationToken: CancellationToken = new CancellationToken()): Promise<Array<string>> {\n const updateInfoAndProvider = this.updateInfoAndProvider\n if (updateInfoAndProvider == null) {\n const error = new Error(\"Please check update first\")\n this.dispatchError(error)\n return Promise.reject(error)\n }\n\n this._logger.info(\n `Downloading update from ${asArray(updateInfoAndProvider.info.files)\n .map(it => it.url)\n .join(\", \")}`\n )\n const errorHandler = (e: Error): Error => {\n // https://github.com/electron-userland/electron-builder/issues/1150#issuecomment-436891159\n if (!(e instanceof CancellationError)) {\n try {\n this.dispatchError(e)\n } catch (nestedError: any) {\n this._logger.warn(`Cannot dispatch error event: ${nestedError.stack || nestedError}`)\n }\n }\n\n return e\n }\n\n try {\n return this.doDownloadUpdate({\n updateInfoAndProvider,\n requestHeaders: this.computeRequestHeaders(updateInfoAndProvider.provider),\n cancellationToken,\n disableWebInstaller: this.disableWebInstaller,\n }).catch((e: any) => {\n throw errorHandler(e)\n })\n } catch (e: any) {\n return Promise.reject(errorHandler(e))\n }\n }\n\n protected dispatchError(e: Error): void {\n this.emit(\"error\", e, (e.stack || e).toString())\n }\n\n protected dispatchUpdateDownloaded(event: UpdateDownloadedEvent): void {\n this.emit(UPDATE_DOWNLOADED, event)\n }\n\n protected abstract doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>>\n\n /**\n * Restarts the app and installs the update after it has been downloaded.\n * It should only be called after `update-downloaded` has been emitted.\n *\n * **Note:** `autoUpdater.quitAndInstall()` will close all application windows first and only emit `before-quit` event on `app` after that.\n * This is different from the normal quit event sequence.\n *\n * @param isSilent *windows-only* Runs the installer in silent mode. Defaults to `false`.\n * @param isForceRunAfter Run the app after finish even on silent install. Not applicable for macOS.\n * Ignored if `isSilent` is set to `false`(In this case you can still set `autoRunAppAfterInstall` to `false` to prevent run the app after finish).\n */\n abstract quitAndInstall(isSilent?: boolean, isForceRunAfter?: boolean): void\n\n private async loadUpdateConfig(): Promise<any> {\n if (this._appUpdateConfigPath == null) {\n this._appUpdateConfigPath = this.app.appUpdateConfigPath\n }\n return load(await readFile(this._appUpdateConfigPath, \"utf-8\"))\n }\n\n private computeRequestHeaders(provider: Provider<any>): OutgoingHttpHeaders {\n const fileExtraDownloadHeaders = provider.fileExtraDownloadHeaders\n if (fileExtraDownloadHeaders != null) {\n const requestHeaders = this.requestHeaders\n return requestHeaders == null\n ? fileExtraDownloadHeaders\n : {\n ...fileExtraDownloadHeaders,\n ...requestHeaders,\n }\n }\n return this.computeFinalHeaders({ accept: \"*/*\" })\n }\n\n private async getOrCreateStagingUserId(): Promise<string> {\n const file = path.join(this.app.userDataPath, \".updaterId\")\n try {\n const id = await readFile(file, \"utf-8\")\n if (UUID.check(id)) {\n return id\n } else {\n this._logger.warn(`Staging user id file exists, but content was invalid: ${id}`)\n }\n } catch (e: any) {\n if (e.code !== \"ENOENT\") {\n this._logger.warn(`Couldn't read staging user ID, creating a blank one: ${e}`)\n }\n }\n\n const id = UUID.v5(randomBytes(4096), UUID.OID)\n this._logger.info(`Generated new staging user ID: ${id}`)\n try {\n await outputFile(file, id)\n } catch (e: any) {\n this._logger.warn(`Couldn't write out staging user ID: ${e}`)\n }\n return id\n }\n\n /** @internal */\n get isAddNoCacheQuery(): boolean {\n const headers = this.requestHeaders\n // https://github.com/electron-userland/electron-builder/issues/3021\n if (headers == null) {\n return true\n }\n\n for (const headerName of Object.keys(headers)) {\n const s = headerName.toLowerCase()\n if (s === \"authorization\" || s === \"private-token\") {\n return false\n }\n }\n return true\n }\n\n /**\n * @private\n * @internal\n */\n _testOnlyOptions: TestOnlyUpdaterOptions | null = null\n\n private async getOrCreateDownloadHelper(): Promise<DownloadedUpdateHelper> {\n let result = this.downloadedUpdateHelper\n if (result == null) {\n const dirName = (await this.configOnDisk.value).updaterCacheDirName\n const logger = this._logger\n if (dirName == null) {\n logger.error(\"updaterCacheDirName is not specified in app-update.yml Was app build using at least electron-builder 20.34.0?\")\n }\n const cacheDir = path.join(this.app.baseCachePath, dirName || this.app.name)\n if (logger.debug != null) {\n logger.debug(`updater cache dir: ${cacheDir}`)\n }\n\n result = new DownloadedUpdateHelper(cacheDir)\n this.downloadedUpdateHelper = result\n }\n return result\n }\n\n protected async executeDownload(taskOptions: DownloadExecutorTask): Promise<Array<string>> {\n const fileInfo = taskOptions.fileInfo\n const downloadOptions: DownloadOptions = {\n headers: taskOptions.downloadUpdateOptions.requestHeaders,\n cancellationToken: taskOptions.downloadUpdateOptions.cancellationToken,\n sha2: (fileInfo.info as any).sha2,\n sha512: fileInfo.info.sha512,\n }\n\n if (this.listenerCount(DOWNLOAD_PROGRESS) > 0) {\n downloadOptions.onProgress = it => this.emit(DOWNLOAD_PROGRESS, it)\n }\n\n const updateInfo = taskOptions.downloadUpdateOptions.updateInfoAndProvider.info\n const version = updateInfo.version\n const packageInfo = fileInfo.packageInfo\n\n function getCacheUpdateFileName(): string {\n // NodeJS URL doesn't decode automatically\n const urlPath = decodeURIComponent(taskOptions.fileInfo.url.pathname)\n if (urlPath.endsWith(`.${taskOptions.fileExtension}`)) {\n return path.basename(urlPath)\n } else {\n // url like /latest, generate name\n return taskOptions.fileInfo.info.url\n }\n }\n\n const downloadedUpdateHelper = await this.getOrCreateDownloadHelper()\n const cacheDir = downloadedUpdateHelper.cacheDirForPendingUpdate\n await mkdir(cacheDir, { recursive: true })\n const updateFileName = getCacheUpdateFileName()\n let updateFile = path.join(cacheDir, updateFileName)\n const packageFile = packageInfo == null ? null : path.join(cacheDir, `package-${version}${path.extname(packageInfo.path) || \".7z\"}`)\n\n const done = async (isSaveCache: boolean) => {\n await downloadedUpdateHelper.setDownloadedFile(updateFile, packageFile, updateInfo, fileInfo, updateFileName, isSaveCache)\n await taskOptions.done!({\n ...updateInfo,\n downloadedFile: updateFile,\n })\n return packageFile == null ? [updateFile] : [updateFile, packageFile]\n }\n\n const log = this._logger\n const cachedUpdateFile = await downloadedUpdateHelper.validateDownloadedPath(updateFile, updateInfo, fileInfo, log)\n if (cachedUpdateFile != null) {\n updateFile = cachedUpdateFile\n return await done(false)\n }\n\n const removeFileIfAny = async () => {\n await downloadedUpdateHelper.clear().catch(() => {\n // ignore\n })\n return await unlink(updateFile).catch(() => {\n // ignore\n })\n }\n\n const tempUpdateFile = await createTempUpdateFile(`temp-${updateFileName}`, cacheDir, log)\n try {\n await taskOptions.task(tempUpdateFile, downloadOptions, packageFile, removeFileIfAny)\n await rename(tempUpdateFile, updateFile)\n } catch (e: any) {\n await removeFileIfAny()\n\n if (e instanceof CancellationError) {\n log.info(\"cancelled\")\n this.emit(\"update-cancelled\", updateInfo)\n }\n throw e\n }\n\n log.info(`New version ${version} has been downloaded to ${updateFile}`)\n return await done(true)\n }\n}\n\nexport interface DownloadUpdateOptions {\n readonly updateInfoAndProvider: UpdateInfoAndProvider\n readonly requestHeaders: OutgoingHttpHeaders\n readonly cancellationToken: CancellationToken\n readonly disableWebInstaller?: boolean\n}\n\nfunction hasPrereleaseComponents(version: SemVer) {\n const versionPrereleaseComponent = getVersionPreleaseComponents(version)\n return versionPrereleaseComponent != null && versionPrereleaseComponent.length > 0\n}\n\n/** @private */\nexport class NoOpLogger implements Logger {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n info(message?: any) {\n // ignore\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n warn(message?: any) {\n // ignore\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n error(message?: any) {\n // ignore\n }\n}\n\nexport interface UpdateInfoAndProvider {\n info: UpdateInfo\n provider: Provider<any>\n}\n\nexport interface DownloadExecutorTask {\n readonly fileExtension: string\n readonly fileInfo: ResolvedUpdateFileInfo\n readonly downloadUpdateOptions: DownloadUpdateOptions\n readonly task: (destinationFile: string, downloadOptions: DownloadOptions, packageFile: string | null, removeTempDirIfAny: () => Promise<any>) => Promise<any>\n\n readonly done?: (event: UpdateDownloadedEvent) => Promise<any>\n}\n\nexport interface DownloadNotification {\n body: string\n title: string\n}\n\n/** @private */\nexport interface TestOnlyUpdaterOptions {\n platform: ProviderPlatform\n\n isUseDifferentialDownload?: boolean\n}\n"]}
|
package/out/NsisUpdater.js
CHANGED
|
@@ -128,10 +128,15 @@ class NsisUpdater extends BaseUpdater_1.BaseUpdater {
|
|
|
128
128
|
// https://github.com/electron-userland/electron-builder/issues/1129
|
|
129
129
|
// Node 8 sends errors: https://nodejs.org/dist/latest-v8.x/docs/api/errors.html#errors_common_system_errors
|
|
130
130
|
const errorCode = e.code;
|
|
131
|
-
this._logger.info(`Cannot run installer: error code: ${errorCode}, error message: "${e.message}", will be executed again using elevate if EACCES
|
|
131
|
+
this._logger.info(`Cannot run installer: error code: ${errorCode}, error message: "${e.message}", will be executed again using elevate if EACCES, and will try to use electron.shell.openItem if ENOENT`);
|
|
132
132
|
if (errorCode === "UNKNOWN" || errorCode === "EACCES") {
|
|
133
133
|
callUsingElevation();
|
|
134
134
|
}
|
|
135
|
+
else if (errorCode === "ENOENT") {
|
|
136
|
+
require("electron")
|
|
137
|
+
.shell.openPath(options.installerPath)
|
|
138
|
+
.catch((err) => this.dispatchError(err));
|
|
139
|
+
}
|
|
135
140
|
else {
|
|
136
141
|
this.dispatchError(e);
|
|
137
142
|
}
|
package/out/NsisUpdater.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NsisUpdater.js","sourceRoot":"","sources":["../src/NsisUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAA6J;AAC7J,6BAA4B;AAG5B,+CAA2D;AAE3D,4IAAwI;AACxI,0GAAsG;AACtG,iCAA6F;AAC7F,iCAAsC;AACtC,mDAAyD;AACzD,uCAAiC;AACjC,qGAA0E;AAC1E,6BAAyB;AACzB,+BAAiC;AA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,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;AAlPD,kCAkPC","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, verifyUpdateCodeSignature } 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 protected _verifyUpdateCodeSignature: verifyUpdateCodeSignature = (publisherNames: Array<string>, unescapedTempUpdateFile: string) =>\n verifySignature(publisherNames, unescapedTempUpdateFile, this._logger)\n\n /**\n * The verifyUpdateCodeSignature. You can pass [win-verify-signature](https://github.com/beyondkmp/win-verify-trust) or another custom verify function: ` (publisherName: string[], path: string) => Promise<string | null>`.\n * The default verify function uses [windowsExecutableCodeSignatureVerifier](https://github.com/electron-userland/electron-builder/blob/master/packages/electron-updater/src/windowsExecutableCodeSignatureVerifier.ts)\n */\n get verifyUpdateCodeSignature(): verifyUpdateCodeSignature {\n return this._verifyUpdateCodeSignature\n }\n\n set verifyUpdateCodeSignature(value: verifyUpdateCodeSignature) {\n if (value) {\n this._verifyUpdateCodeSignature = value\n }\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 this._verifyUpdateCodeSignature(Array.isArray(publisherName) ? publisherName : [publisherName], tempUpdateFile)\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"]}
|
|
1
|
+
{"version":3,"file":"NsisUpdater.js","sourceRoot":"","sources":["../src/NsisUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAA6J;AAC7J,6BAA4B;AAG5B,+CAA2D;AAE3D,4IAAwI;AACxI,0GAAsG;AACtG,iCAA6F;AAC7F,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;QAGX,+BAA0B,GAA8B,CAAC,cAA6B,EAAE,uBAA+B,EAAE,EAAE,CACnI,IAAA,wDAAe,EAAC,cAAc,EAAE,uBAAuB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;IAHxE,CAAC;IAKD;;;OAGG;IACH,IAAI,yBAAyB;QAC3B,OAAO,IAAI,CAAC,0BAA0B,CAAA;IACxC,CAAC;IAED,IAAI,yBAAyB,CAAC,KAAgC;QAC5D,IAAI,KAAK,EAAE;YACT,IAAI,CAAC,0BAA0B,GAAG,KAAK,CAAA;SACxC;IACH,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,CAA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AE,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;AAxPD,kCAwPC","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, verifyUpdateCodeSignature } 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 protected _verifyUpdateCodeSignature: verifyUpdateCodeSignature = (publisherNames: Array<string>, unescapedTempUpdateFile: string) =>\n verifySignature(publisherNames, unescapedTempUpdateFile, this._logger)\n\n /**\n * The verifyUpdateCodeSignature. You can pass [win-verify-signature](https://github.com/beyondkmp/win-verify-trust) or another custom verify function: ` (publisherName: string[], path: string) => Promise<string | null>`.\n * The default verify function uses [windowsExecutableCodeSignatureVerifier](https://github.com/electron-userland/electron-builder/blob/master/packages/electron-updater/src/windowsExecutableCodeSignatureVerifier.ts)\n */\n get verifyUpdateCodeSignature(): verifyUpdateCodeSignature {\n return this._verifyUpdateCodeSignature\n }\n\n set verifyUpdateCodeSignature(value: verifyUpdateCodeSignature) {\n if (value) {\n this._verifyUpdateCodeSignature = value\n }\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 this._verifyUpdateCodeSignature(Array.isArray(publisherName) ? publisherName : [publisherName], tempUpdateFile)\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(\n `Cannot run installer: error code: ${errorCode}, error message: \"${e.message}\", will be executed again using elevate if EACCES, and will try to use electron.shell.openItem if ENOENT`\n )\n if (errorCode === \"UNKNOWN\" || errorCode === \"EACCES\") {\n callUsingElevation()\n } else if (errorCode === \"ENOENT\") {\n require(\"electron\")\n .shell.openPath(options.installerPath)\n .catch((err: Error) => this.dispatchError(err))\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"]}
|
|
@@ -5,7 +5,7 @@ var OperationKind;
|
|
|
5
5
|
(function (OperationKind) {
|
|
6
6
|
OperationKind[OperationKind["COPY"] = 0] = "COPY";
|
|
7
7
|
OperationKind[OperationKind["DOWNLOAD"] = 1] = "DOWNLOAD";
|
|
8
|
-
})(OperationKind
|
|
8
|
+
})(OperationKind || (exports.OperationKind = OperationKind = {}));
|
|
9
9
|
function computeOperations(oldBlockMap, newBlockMap, logger) {
|
|
10
10
|
const nameToOldBlocks = buildBlockFileMap(oldBlockMap.files);
|
|
11
11
|
const nameToNewBlocks = buildBlockFileMap(newBlockMap.files);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"downloadPlanBuilder.js","sourceRoot":"","sources":["../../src/differentialDownloader/downloadPlanBuilder.ts"],"names":[],"mappings":";;;AAGA,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,iDAAI,CAAA;IACJ,yDAAQ,CAAA;AACV,CAAC,EAHW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAGxB;AAcD,SAAgB,iBAAiB,CAAC,WAAqB,EAAE,WAAqB,EAAE,MAAc;IAC5F,MAAM,eAAe,GAAG,iBAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;IAC5D,MAAM,eAAe,GAAG,iBAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;IAE5D,IAAI,aAAa,GAAqB,IAAI,CAAA;IAE1C,kDAAkD;IAClD,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACzC,MAAM,UAAU,GAAqB,EAAE,CAAA;IACvC,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAA;IAC9B,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC1C,IAAI,QAAQ,IAAI,IAAI,EAAE;QACpB,+GAA+G;QAC/G,MAAM,IAAI,KAAK,CAAC,WAAW,IAAI,kBAAkB,CAAC,CAAA;KACnD;IAED,MAAM,OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,IAAI,CAAE,CAAA;IAC1C,IAAI,iBAAiB,GAAG,CAAC,CAAA;IAEzB,MAAM,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,GAAG,gBAAgB,CAAC,eAAe,CAAC,GAAG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KAAK,SAAS,EAAE;YAC1B,gBAAgB,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;YACtC,cAAc,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;SACnC;aAAM,IAAI,MAAM,CAAC,KAAK,IAAI,IAAI,EAAE;YAC/B,MAAM,eAAe,GAAG,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,UAAU,QAAQ,gBAAgB,IAAI,GAAG,CAAA;YACrG,MAAM,CAAC,KAAK,CAAC,GAAG,QAAQ,2BAA2B,eAAe,gGAAgG,CAAC,CAAA;SACpK;QACD,MAAM,IAAI,IAAI,CAAA;KACf;IACD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAA;AAChE,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAyB;IAClD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAwB,CAAA;IAC9C,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;QACvB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;KAC5B;IACD,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { BlockMap, BlockMapFile } from \"builder-util-runtime/out/blockMapApi\"\nimport { Logger } from \"../main\"\n\nexport enum OperationKind {\n COPY,\n DOWNLOAD,\n}\n\nexport interface Operation {\n kind: OperationKind\n\n // inclusive\n start: number\n // exclusive\n end: number\n\n // debug only\n // oldBlocks: Array<string> | null\n}\n\nexport function computeOperations(oldBlockMap: BlockMap, newBlockMap: BlockMap, logger: Logger): Array<Operation> {\n const nameToOldBlocks = buildBlockFileMap(oldBlockMap.files)\n const nameToNewBlocks = buildBlockFileMap(newBlockMap.files)\n\n let lastOperation: Operation | null = null\n\n // for now only one file is supported in block map\n const blockMapFile = newBlockMap.files[0]\n const operations: Array<Operation> = []\n const name = blockMapFile.name\n const oldEntry = nameToOldBlocks.get(name)\n if (oldEntry == null) {\n // new file (unrealistic case for now, because in any case both blockmap contain the only file named as \"file\")\n throw new Error(`no file ${name} in old blockmap`)\n }\n\n const newFile = nameToNewBlocks.get(name)!\n let changedBlockCount = 0\n\n const { checksumToOffset: checksumToOldOffset, checksumToOldSize } = buildChecksumMap(nameToOldBlocks.get(name)!, oldEntry.offset, logger)\n\n let newOffset = blockMapFile.offset\n for (let i = 0; i < newFile.checksums.length; newOffset += newFile.sizes[i], i++) {\n const blockSize = newFile.sizes[i]\n const checksum = newFile.checksums[i]\n let oldOffset = checksumToOldOffset.get(checksum)\n if (oldOffset != null && checksumToOldSize.get(checksum) !== blockSize) {\n logger.warn(`Checksum (\"${checksum}\") matches, but size differs (old: ${checksumToOldSize.get(checksum)}, new: ${blockSize})`)\n oldOffset = undefined\n }\n\n if (oldOffset === undefined) {\n // download data from new file\n changedBlockCount++\n\n if (lastOperation != null && lastOperation.kind === OperationKind.DOWNLOAD && lastOperation.end === newOffset) {\n lastOperation.end += blockSize\n } else {\n lastOperation = {\n kind: OperationKind.DOWNLOAD,\n start: newOffset,\n end: newOffset + blockSize,\n // oldBlocks: null,\n }\n validateAndAdd(lastOperation, operations, checksum, i)\n }\n } else {\n // reuse data from old file\n if (lastOperation != null && lastOperation.kind === OperationKind.COPY && lastOperation.end === oldOffset) {\n lastOperation.end += blockSize\n // lastOperation.oldBlocks!!.push(checksum)\n } else {\n lastOperation = {\n kind: OperationKind.COPY,\n start: oldOffset,\n end: oldOffset + blockSize,\n // oldBlocks: [checksum]\n }\n validateAndAdd(lastOperation, operations, checksum, i)\n }\n }\n }\n\n if (changedBlockCount > 0) {\n logger.info(`File${blockMapFile.name === \"file\" ? \"\" : \" \" + blockMapFile.name} has ${changedBlockCount} changed blocks`)\n }\n return operations\n}\n\nconst isValidateOperationRange = process.env[\"DIFFERENTIAL_DOWNLOAD_PLAN_BUILDER_VALIDATE_RANGES\"] === \"true\"\n\nfunction validateAndAdd(operation: Operation, operations: Array<Operation>, checksum: string, index: number): void {\n if (isValidateOperationRange && operations.length !== 0) {\n const lastOperation = operations[operations.length - 1]\n if (lastOperation.kind === operation.kind && operation.start < lastOperation.end && operation.start > lastOperation.start) {\n const min = [lastOperation.start, lastOperation.end, operation.start, operation.end].reduce((p, v) => (p < v ? p : v))\n throw new Error(\n `operation (block index: ${index}, checksum: ${checksum}, kind: ${OperationKind[operation.kind]}) overlaps previous operation (checksum: ${checksum}):\\n` +\n `abs: ${lastOperation.start} until ${lastOperation.end} and ${operation.start} until ${operation.end}\\n` +\n `rel: ${lastOperation.start - min} until ${lastOperation.end - min} and ${operation.start - min} until ${operation.end - min}`\n )\n }\n }\n operations.push(operation)\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nfunction buildChecksumMap(file: BlockMapFile, fileOffset: number, logger: Logger) {\n const checksumToOffset = new Map<string, number>()\n const checksumToSize = new Map<string, number>()\n let offset = fileOffset\n for (let i = 0; i < file.checksums.length; i++) {\n const checksum = file.checksums[i]\n const size = file.sizes[i]\n\n const existing = checksumToSize.get(checksum)\n if (existing === undefined) {\n checksumToOffset.set(checksum, offset)\n checksumToSize.set(checksum, size)\n } else if (logger.debug != null) {\n const sizeExplanation = existing === size ? \"(same size)\" : `(size: ${existing}, this size: ${size})`\n logger.debug(`${checksum} duplicated in blockmap ${sizeExplanation}, it doesn't lead to broken differential downloader, just corresponding block will be skipped)`)\n }\n offset += size\n }\n return { checksumToOffset, checksumToOldSize: checksumToSize }\n}\n\nfunction buildBlockFileMap(list: Array<BlockMapFile>): Map<string, BlockMapFile> {\n const result = new Map<string, BlockMapFile>()\n for (const item of list) {\n result.set(item.name, item)\n }\n return result\n}\n"]}
|
|
1
|
+
{"version":3,"file":"downloadPlanBuilder.js","sourceRoot":"","sources":["../../src/differentialDownloader/downloadPlanBuilder.ts"],"names":[],"mappings":";;;AAGA,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,iDAAI,CAAA;IACJ,yDAAQ,CAAA;AACV,CAAC,EAH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;SACpK;QACD,MAAM,IAAI,IAAI,CAAA;KACf;IACD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAA;AAChE,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAyB;IAClD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAwB,CAAA;IAC9C,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;QACvB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;KAC5B;IACD,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { BlockMap, BlockMapFile } from \"builder-util-runtime/out/blockMapApi\"\nimport { Logger } from \"../main\"\n\nexport enum OperationKind {\n COPY,\n DOWNLOAD,\n}\n\nexport interface Operation {\n kind: OperationKind\n\n // inclusive\n start: number\n // exclusive\n end: number\n\n // debug only\n // oldBlocks: Array<string> | null\n}\n\nexport function computeOperations(oldBlockMap: BlockMap, newBlockMap: BlockMap, logger: Logger): Array<Operation> {\n const nameToOldBlocks = buildBlockFileMap(oldBlockMap.files)\n const nameToNewBlocks = buildBlockFileMap(newBlockMap.files)\n\n let lastOperation: Operation | null = null\n\n // for now only one file is supported in block map\n const blockMapFile = newBlockMap.files[0]\n const operations: Array<Operation> = []\n const name = blockMapFile.name\n const oldEntry = nameToOldBlocks.get(name)\n if (oldEntry == null) {\n // new file (unrealistic case for now, because in any case both blockmap contain the only file named as \"file\")\n throw new Error(`no file ${name} in old blockmap`)\n }\n\n const newFile = nameToNewBlocks.get(name)!\n let changedBlockCount = 0\n\n const { checksumToOffset: checksumToOldOffset, checksumToOldSize } = buildChecksumMap(nameToOldBlocks.get(name)!, oldEntry.offset, logger)\n\n let newOffset = blockMapFile.offset\n for (let i = 0; i < newFile.checksums.length; newOffset += newFile.sizes[i], i++) {\n const blockSize = newFile.sizes[i]\n const checksum = newFile.checksums[i]\n let oldOffset = checksumToOldOffset.get(checksum)\n if (oldOffset != null && checksumToOldSize.get(checksum) !== blockSize) {\n logger.warn(`Checksum (\"${checksum}\") matches, but size differs (old: ${checksumToOldSize.get(checksum)}, new: ${blockSize})`)\n oldOffset = undefined\n }\n\n if (oldOffset === undefined) {\n // download data from new file\n changedBlockCount++\n\n if (lastOperation != null && lastOperation.kind === OperationKind.DOWNLOAD && lastOperation.end === newOffset) {\n lastOperation.end += blockSize\n } else {\n lastOperation = {\n kind: OperationKind.DOWNLOAD,\n start: newOffset,\n end: newOffset + blockSize,\n // oldBlocks: null,\n }\n validateAndAdd(lastOperation, operations, checksum, i)\n }\n } else {\n // reuse data from old file\n if (lastOperation != null && lastOperation.kind === OperationKind.COPY && lastOperation.end === oldOffset) {\n lastOperation.end += blockSize\n // lastOperation.oldBlocks!!.push(checksum)\n } else {\n lastOperation = {\n kind: OperationKind.COPY,\n start: oldOffset,\n end: oldOffset + blockSize,\n // oldBlocks: [checksum]\n }\n validateAndAdd(lastOperation, operations, checksum, i)\n }\n }\n }\n\n if (changedBlockCount > 0) {\n logger.info(`File${blockMapFile.name === \"file\" ? \"\" : \" \" + blockMapFile.name} has ${changedBlockCount} changed blocks`)\n }\n return operations\n}\n\nconst isValidateOperationRange = process.env[\"DIFFERENTIAL_DOWNLOAD_PLAN_BUILDER_VALIDATE_RANGES\"] === \"true\"\n\nfunction validateAndAdd(operation: Operation, operations: Array<Operation>, checksum: string, index: number): void {\n if (isValidateOperationRange && operations.length !== 0) {\n const lastOperation = operations[operations.length - 1]\n if (lastOperation.kind === operation.kind && operation.start < lastOperation.end && operation.start > lastOperation.start) {\n const min = [lastOperation.start, lastOperation.end, operation.start, operation.end].reduce((p, v) => (p < v ? p : v))\n throw new Error(\n `operation (block index: ${index}, checksum: ${checksum}, kind: ${OperationKind[operation.kind]}) overlaps previous operation (checksum: ${checksum}):\\n` +\n `abs: ${lastOperation.start} until ${lastOperation.end} and ${operation.start} until ${operation.end}\\n` +\n `rel: ${lastOperation.start - min} until ${lastOperation.end - min} and ${operation.start - min} until ${operation.end - min}`\n )\n }\n }\n operations.push(operation)\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nfunction buildChecksumMap(file: BlockMapFile, fileOffset: number, logger: Logger) {\n const checksumToOffset = new Map<string, number>()\n const checksumToSize = new Map<string, number>()\n let offset = fileOffset\n for (let i = 0; i < file.checksums.length; i++) {\n const checksum = file.checksums[i]\n const size = file.sizes[i]\n\n const existing = checksumToSize.get(checksum)\n if (existing === undefined) {\n checksumToOffset.set(checksum, offset)\n checksumToSize.set(checksum, size)\n } else if (logger.debug != null) {\n const sizeExplanation = existing === size ? \"(same size)\" : `(size: ${existing}, this size: ${size})`\n logger.debug(`${checksum} duplicated in blockmap ${sizeExplanation}, it doesn't lead to broken differential downloader, just corresponding block will be skipped)`)\n }\n offset += size\n }\n return { checksumToOffset, checksumToOldSize: checksumToSize }\n}\n\nfunction buildBlockFileMap(list: Array<BlockMapFile>): Map<string, BlockMapFile> {\n const result = new Map<string, BlockMapFile>()\n for (const item of list) {\n result.set(item.name, item)\n }\n return result\n}\n"]}
|
|
@@ -4,7 +4,7 @@ import { AuthInfo } from "electron";
|
|
|
4
4
|
import { RequestOptions } from "http";
|
|
5
5
|
import Session = Electron.Session;
|
|
6
6
|
import ClientRequest = Electron.ClientRequest;
|
|
7
|
-
export
|
|
7
|
+
export type LoginCallback = (username: string, password: string) => void;
|
|
8
8
|
export declare const NET_SESSION_NAME = "electron-updater";
|
|
9
9
|
export declare function getNetSession(): Session;
|
|
10
10
|
export declare class ElectronHttpExecutor extends HttpExecutor<Electron.ClientRequest> {
|
package/out/main.d.ts
CHANGED
|
@@ -26,10 +26,10 @@ export interface UpdateCheckResult {
|
|
|
26
26
|
/** @deprecated */
|
|
27
27
|
readonly versionInfo: UpdateInfo;
|
|
28
28
|
}
|
|
29
|
-
export
|
|
29
|
+
export type UpdaterEvents = "login" | "checking-for-update" | "update-available" | "update-not-available" | "update-cancelled" | "download-progress" | "update-downloaded" | "error";
|
|
30
30
|
export declare const DOWNLOAD_PROGRESS = "download-progress";
|
|
31
31
|
export declare const UPDATE_DOWNLOADED = "update-downloaded";
|
|
32
|
-
export
|
|
32
|
+
export type LoginHandler = (authInfo: any, callback: LoginCallback) => void;
|
|
33
33
|
export declare class UpdaterSignal {
|
|
34
34
|
private emitter;
|
|
35
35
|
constructor(emitter: EventEmitter);
|
|
@@ -50,4 +50,4 @@ export interface Logger {
|
|
|
50
50
|
error(message?: any): void;
|
|
51
51
|
debug?(message: string): void;
|
|
52
52
|
}
|
|
53
|
-
export
|
|
53
|
+
export type verifyUpdateCodeSignature = (publisherName: string[], path: string) => Promise<string | null>;
|
|
@@ -5,7 +5,7 @@ import { OutgoingHttpHeaders, RequestOptions } from "http";
|
|
|
5
5
|
import { URL } from "url";
|
|
6
6
|
import { ElectronHttpExecutor } from "../electronHttpExecutor";
|
|
7
7
|
import { ResolvedUpdateFileInfo } from "../main";
|
|
8
|
-
export
|
|
8
|
+
export type ProviderPlatform = "darwin" | "linux" | "win32";
|
|
9
9
|
export interface ProviderRuntimeOptions {
|
|
10
10
|
isUseMultipleRangeRequest: boolean;
|
|
11
11
|
platform: ProviderPlatform;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "electron-updater",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.5",
|
|
4
4
|
"description": "Cross platform updater for electron applications",
|
|
5
5
|
"main": "out/main.js",
|
|
6
6
|
"author": "Vladimir Krivosheev",
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"out"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"builder-util-runtime": "9.2.1",
|
|
20
19
|
"fs-extra": "^10.1.0",
|
|
21
20
|
"js-yaml": "^4.1.0",
|
|
22
21
|
"lazy-val": "^1.0.5",
|
|
23
22
|
"lodash.escaperegexp": "^4.1.2",
|
|
24
23
|
"lodash.isequal": "^4.5.0",
|
|
25
24
|
"semver": "^7.3.8",
|
|
26
|
-
"tiny-typed-emitter": "^2.1.0"
|
|
25
|
+
"tiny-typed-emitter": "^2.1.0",
|
|
26
|
+
"builder-util-runtime": "9.2.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/fs-extra": "9.0.13",
|