diff --git a/docs/Auto Update.md b/docs/Auto Update.md index abb3cd46450..bcdcd4842ed 100644 --- a/docs/Auto Update.md +++ b/docs/Auto Update.md @@ -328,7 +328,9 @@ Emitted on progress. Only supported over Windows build, since `Squirrel.Mac` [do | Name | Type | Description | | --- | --- | --- | -| autoDownload = true| boolean | Automatically download an update when it is found. | +| autoDownload = true| boolean | Whether to automatically download an update when it is found. | +| allowPrerelease| boolean | *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`.

If `true`, downgrade will be allowed (`allowDowngrade` will be set to `true`). | +| allowDowngrade| boolean | Whether to allow version downgrade (when a user from the beta channel wants to go back to the stable channel). Defaults to `true` if application version contains prerelease components (e.g. `0.12.1-alpha.1`, here `alpha` is a prerelease component), otherwise `false`. | | requestHeaders| [RequestHeaders](electron-builder-http#RequestHeaders) \| null | The request headers. | | logger = (<any>global).__test_app ? null : console| [Logger](#Logger) \| null | 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() }`. Set it to `null` if you would like to disable a logging feature. | | signals = new UpdaterSignal(this)| [UpdaterSignal](#UpdaterSignal) | For type safety you can use signals, e.g. `autoUpdater.signals.updateDownloaded(() => {})` instead of `autoUpdater.on('update-available', () => {})` | diff --git a/packages/electron-builder-http/src/httpExecutor.ts b/packages/electron-builder-http/src/httpExecutor.ts index ff9a51e14df..6f5f26eb683 100644 --- a/packages/electron-builder-http/src/httpExecutor.ts +++ b/packages/electron-builder-http/src/httpExecutor.ts @@ -110,7 +110,7 @@ export abstract class HttpExecutor { } const newUrl = parseUrl(redirectUrl) - this.doApiRequest(removeAuthHeader(Object.assign({}, options, newUrl)), cancellationToken, requestProcessor, redirectCount) + this.doApiRequest(Object.assign({}, options, newUrl), cancellationToken, requestProcessor, redirectCount) .then(resolve) .catch(reject) return @@ -161,11 +161,11 @@ export abstract class HttpExecutor { if (redirectUrl != null) { if (redirectCount < this.maxRedirects) { const parsedUrl = parseUrl(redirectUrl) - this.doDownload(removeAuthHeader(Object.assign({}, requestOptions, { + this.doDownload(Object.assign({}, requestOptions, { hostname: parsedUrl.hostname, path: parsedUrl.path, port: parsedUrl.port == null ? undefined : parsedUrl.port - })), destination, redirectCount++, options, callback, onCancel) + }), destination, redirectCount++, options, callback, onCancel) } else { callback(new Error(`Too many redirects (> ${this.maxRedirects})`)) @@ -310,14 +310,4 @@ export function dumpRequestOptions(options: RequestOptions): string { safe.headers.authorization = "" } return JSON.stringify(safe, null, 2) -} - -// requestOptions should be cloned already, modified in place -function removeAuthHeader(requestOptions: RequestOptions): RequestOptions { - // github redirect to amazon s3 - avoid error "Only one auth mechanism allowed" - if (requestOptions.headers != null && (requestOptions.hostname || "").includes(".amazonaws.") && requestOptions.headers.Authorization != null && requestOptions.headers.Authorization.startsWith("token ")) { - requestOptions.headers = Object.assign({}, requestOptions.headers) - delete requestOptions.headers.Authorization - } - return requestOptions } \ No newline at end of file