github electron-userland/electron-builder electron-updater@7.0.0-alpha.15

pre-release59 minutes ago

Major Changes

  • Feat(updater)!: a missing NSIS update installer (ENOENT) fails the install with ERR_UPDATER_INSTALLER_START_FAILED; electron-updater neither starts it elevated nor opens it with the shell. quitAndInstall() and the install on launch wait for the installer to start and keep the app running when the start is refused or fails. elevate.exe (for isAdminRightsRequired and the retry after EACCES or UNKNOWN, e.g. AppLocker or WDAC rules that let only administrators run the installer) runs only when the current user cannot modify it, its folder or the install folder of the app; elsewhere the installer is started directly, which installs in an app that runs with administrator rights and fails with ERR_UPDATER_INSTALLER_ELEVATION_REFUSED in any other, so an update cannot switch an app installed per user to a per-machine build unless the app runs with administrator rights: install per-machine apps into a folder only administrators can write, e.g. with nsis.perMachine: true #10660 f0dc4dd
  • Fix(updater)!: on Linux, run the elevation helper (pkexec, gksudo, kdesudo, beesu, else sudo) and the package manager only from /usr/sbin, /usr/bin, /sbin and /bin, by absolute path, never a copy elsewhere in the app's PATH (a helper found only elsewhere is skipped with a warning; a package manager, or sudo as the last helper, found in none of them fails with ERR_UPDATER_ELEVATION_COMMAND_NOT_FOUND); under gksudo, kdesudo or beesu, run the package manager in a clean environment (env -i, a PATH of those directories), so the app's environment variables, proxy settings included, do not reach it; and warn once per updater when pkexec is used although gksudo or kdesudo is installed in those directories too. See https://www.electron.build/docs/migration/v27-runtime-changes#linux-update-elevation #10664 1e02ba7
  • Feat(updater)!: the app chooses the request headers sent to another origin with the required autoUpdater.crossOriginHeaders property: (headerNames: string[], hop: { from: URL; to: URL }) => string[] (the CrossOriginHeadersCallback and CrossOriginHop types), null by default. electron-updater calls it for each request and redirect to another origin than the update feed (Provider.feedBaseUrl; private GitHub's feed is the GitHub API): a redirect, a download or channel file on another origin, a blockmap or differential range request and their redirects, a private GitHub release asset or GitLab release link on another origin, and a provider's own request there. It gets the lowercase names of the request headers about to be sent, never their values, and returns the names of the ones to send (case-insensitive); the feed's origin gets every header without it. A header it leaves out stays on the original origin: Authorization from addAuthHeader, a custom header from requestHeaders, a provider's token (private GitHub, GitLab), a provider's other request headers and x-user-staging-id. The headers electron-updater builds for each request itself are sent whatever it returns: its default User-Agent, Cache-Control, the Accept it or the provider sets, and Range; an app's own User-Agent from requestHeaders goes to another origin only when it keeps user-agent. autoUpdater.crossOriginHeaders = () => [] sends none of the app's headers to another origin. Without a function, checkForUpdates(), checkForUpdatesAndNotify() and downloadUpdate() emit error and reject with ERR_UPDATER_CROSS_ORIGIN_HEADERS_NOT_CONFIGURED, whose message names the property and links the migration guide, and so does each request to another origin, such as one of the install at launch of an update marked for the next launch: set it before the app is ready. An unpackaged app without forceDevUpdateConfig, which skips the check, gets the same error from checkForUpdates() and checkForUpdatesAndNotify(), so a missing callback shows up in development. A throw, or a result that is not an array of strings, fails that request, unsent, with ERR_UPDATER_INVALID_CROSS_ORIGIN_HEADERS. builder-util-runtime: HttpExecutor takes a CrossOriginHeaderPolicy ((headers, hop) => headers) for its redirects as its constructor argument, by default electron-builder's, which sends only the headers that carry no credential (Accept, Content-Type, Range, User-Agent and the like); HttpExecutor.crossOriginHeaders(headers, ownHeaders, hop, policy) applies one, and ApiRequestOptions.ownHeaders and DownloadOptions.ownHeaders name the headers a request builds itself, which a hop to another origin sends whatever the policy keeps. electron-updater's ProviderRuntimeOptions has a required crossOriginHeaderPolicy, set by electron-updater, so code that constructs a built-in provider passes on the runtime options it was given. The first time a request to an origin goes without some of the app's or a provider's headers, electron-updater logs a warning, once per origin, naming those headers and both origins (never a value), with a link to the migration guide. A Host header is never sent to another origin. A provider constructed with runtime options without a crossOriginHeaderPolicy function throws ERR_UPDATER_CROSS_ORIGIN_HEADER_POLICY_MISSING. See https://www.electron.build/docs/migration/v27-runtime-changes#cross-origin-headers #10563 d699bdf — electron-updater, builder-util-runtime · updated in #10665
  • Feat(runtime)!: an HttpExecutor without a cross-origin header policy of its own, such as builder-util's httpExecutor, sends a redirect to another origin only the headers that carry no credential (Accept, Accept-Encoding, Accept-Language, Cache-Control, Content-Encoding, Content-Language, Content-Length, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Range, If-Unmodified-Since, Pragma, Range, User-Agent); every other header, a custom credential header such as X-Api-Token too, stays on its origin. builder-util's NodeHttpExecutor warns once per process, at the first redirect that leaves out headers other than the well-known credential headers (Authorization, Cookie, PRIVATE-TOKEN, X-Api-Key and the like), naming them and both origins (never a value). electron-updater keeps its own policy (autoUpdater.crossOriginHeaders). https://www.electron.build/docs/migration/v27-developer-changes#builder-util-runtime-default-cross-origin-headers #10665 12bafb3 — builder-util-runtime

Minor Changes

  • Feat: add the optional blockMapSha512 field to UpdateFileInfo. It is not covered by the manifest signature. decodeBlockMapV3 and checkBlockMapV3Header reject an empty map (no blocks, or a 0-byte file), a region that is empty or extends past the file, and blocks that do not cover the file #10496 d0d4046 — builder-util-runtime
  • Feat: reject block maps that cannot be planned on. An update of unknown, zero or invalid size is downloaded in full without fetching any block map. A block map (v2 or v3, separate or embedded) that is empty, describes a 0-byte file, does not end at the update's size or plans no data is rejected with one log line (ERR_UPDATER_INVALID_BLOCKMAP) and the update is downloaded in full. When the update manifest has a blockMapSha512 for a file, the new block map (downloaded whole, or assembled from Range requests) is checked against it before it is decoded, used or cached, and a mismatch error quotes the manifest value; blockMapSha512 is base64 only #10496 d0d4046
  • Feat(updater): when no login listener takes the url argument, a server's authentication challenge from another origin than the update feed (Provider.feedBaseUrl of the last update check or of the update being downloaded, or previousBlockmapBaseUrlOverride) still reaches login, and logs a warning once per updater that the handler cannot tell which origin it is answering. electron-updater 8, the next major version, will cancel such a challenge; take (authInfo, callback, url) and answer only when new URL(url).origin is the origin your credentials are meant for. See https://www.electron.build/docs/features/auto-update#event-login #10666 26cae9e

Patch Changes

  • Fix(updater): an update pending for the next launch is installed only when the cached file is the installer the target picks from the update info fetched on that launch (new protected BaseUpdater.findUpdateFile, which picks the first file unless a target overrides it; an updater subclass that downloads another file overrides it to return that file, and otherwise logs a warning and does not install the pending update), and is started with that update info's isAdminRightsRequired, as a cached update that an update check reuses is. A pending cache that marks the update per-machine makes the automatic install at launch skip it without a request, and a deb, rpm, pacman or AppImage download whose update info has no file for the target rejects with ERR_UPDATER_UPDATE_FILE_NOT_FOUND. See https://www.electron.build/docs/migration/v27-runtime-changes#downloaded-updates-are-checked-again-before-they-are-installed #10663 6f4d55e
  • Fix(updater): hash the downloaded update again right before it is installed, and verify an NSIS installer's signature again before quitAndInstall(), installAsync() or the install on launch starts it and before an installer cached by an earlier launch is reused, and refuse to download an update file whose update info has no checksum (ERR_UPDATER_NO_CHECKSUM) with every provider, including GitLab, private GitHub and custom ones #10661 47c9a1d
  • Fix(updater): the Linux install only elevates a bare command name found as an executable regular file in the system directories (/usr/sbin, /usr/bin, /sbin, /bin), symlinks there followed wherever they lead #10460 e15f702 — updated in #10664
  • Docs: allowDowngrade, allowPrerelease and channel JSDoc: setting channel turns allowDowngrade on, allowPrerelease does not, and a signed update manifest does not stop a downgrade #10670 caab5b2
  • Fix: end the unsigned-manifest, invalid-signature and missing web-package checksum errors, the no-key warning and the warning for a full installer downloaded while disableWebInstaller is set to false (logged once per updater instance) with a migration-doc link; the nsis-web installer's abort for an update started without --package-file no longer prints a link #10671 e9481ec
  • Fix(updater): with allowPrerelease, private GitHub repositories now pick the highest release eligible for the current channel, as public GitHub repositories do, instead of the first pre-release in the API list, so a pre-release user gets a newer stable release, a beta user is not offered alpha builds, and setting channel no longer installs an older pre-release; with a custom tagNamePrefix, tags without the prefix are skipped, and releases whose tags are not versions keep the list-order pick. On both public and private GitHub, a numbered pre-release (such as 1.0.1-1) is no longer treated as a channel named 1, so it is offered 1.0.1-2 and 1.0.1. The channel's own channel file (such as beta.yml) is read when the release has it, and a release list with no eligible release, or a malformed /releases/latest response, fails with an ERR_UPDATER_* code instead of a TypeError #10519 b84d440
  • Fix(updater): pick the update file for the app's arch by name instead of by its position in the update manifest; when no file names the app's arch, prefer one that names no other arch. With nsis.buildUniversalInstaller: false, an x64 app no longer installs the ia32 or arm64 installer listed before its own, and an app built with defaultArch no longer installs another arch's installer #10518 f675d75

Don't miss a new electron-builder release

NewReleases is sending notifications on new releases.