electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box
https://www.electron.build
MIT License
13.72k stars 1.74k forks source link

Ability to change `requestHeaders` on AutoUpdater for both blockmap requests #6605

Open FreeBishop opened 2 years ago

FreeBishop commented 2 years ago

I currently have an app that I am able to upload to my private S3 bucket and can properly check for updates and download them. While my app is able to download and install updates, in my logs I can see this error that other developers seem to face:

Cannot download differentially, fallback to full download: Error: Cannot download "https://<MY_BUCKET>.s3.amazonaws.com/<MY_APP>1.0.0.exe.blockmap", status 403: Forbidden

// Start of Context \\ Ideally, I want to use differential downloading with blockmaps to reduce the download payload. Right now it works, but users have to reinstall the entire app.

I've configured my own signing for AWS API Requests so that I can take my Authorization headers and change the autoUpdater.requestHeaders for the outgoing request for the .exe and latest.yml.

When I call autoUpdater.downloadUpdate() I see it makes a call to download both the old and new blockmap of the app version:

Download block maps (old: "https://<MY_BUCKET>.s3.amazonaws.com/<MY_APP>1.0.0.exe.blockmap", new: https://<MY_BUCKET>.s3.amazonaws.com/<MY_APP>1.0.1.exe.blockmap)

The function I use to create my AWS signature and attach the request headers is called before autoUpdater.checkForUpdates() and autoUpdater.downloadUpdate(). Since the downloading portion will ping my S3 bucket twice for the blockmaps, I understand that I would need to make two separate AWS signatures to allow access to those resources. However, I can only change the autoUpdater.requestHeaders for one resource at a time before it makes the fetch call to both blockmaps in the bucket.

I checked through electron-updater files and can see in NsisUpdater.ts that this function is responsible for downloading the blockmaps: https://github.com/electron-userland/electron-builder/blob/70c35176e452ee3159196edabaf685337a09cb82/packages/electron-updater/src/NsisUpdater.ts#L142-L147

It will use the same request header that is set for both blockmap calls. // End of Context \\

My question is if it's possible to change the request headers of the autoUpdater, for both blockmaps, before their respective fetch call is made. I can currently only sign for one blockmap, but then differential downloading ultimately fails since that same AWS signature is invalid for the other blockmap.

Please let me know if any more context is needed and thank you all for your time.

NoumanSaleem commented 2 years ago

Also ran into this issue. Ideally the updater would implement a single callback to allow request signing across all HTTP requests.

stale[bot] commented 2 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.