feat: optionally serve installers with a filename tag - #3
Merged
Conversation
GitHub's signed asset URLs carry `response-content-disposition` inside the signature, so a redirect cannot control the filename the browser saves. This adds an optional mirror: each release asset is copied once to an S3-compatible bucket, and `/download` and `/download/:platform` accept `?t=<tag>` to serve the Windows installer through a presigned URL that forces `<asset> [<prefix><tag>].exe`. Lets an installed client correlate the download it came from. Still no bytes through this server — both paths are redirects. Degrades quietly: mirror not configured, malformed tag, or release not copied yet all fall back to the plain redirect, so the download never fails. With no bucket configured every route behaves exactly as before, which makes it safe to deploy ahead of the infrastructure. `?t=` is ignored for `?update=true`, since a Squirrel update must keep the canonical filename. The object key includes the repository so several deployments can share one bucket. The tag prefix is configurable, and the tag itself is opaque here — it may carry sensitive caller data, so it is never logged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The first version of these tests only exercised pure helpers and the mirror-disabled path, so several mutations survived: dropping `ResponseContentDisposition`, dropping tag validation, widening the presigned URL lifetime, turning the `&&` in `isConfigured` into `||`, and inverting the concurrency guard. Now covers the tagged filename, the object key, the short signature lifetime, the fallback when an asset has not been copied yet, 20 concurrent calls resulting in a single download, and GitHub/upload failures not taking the process down. All five mutations above now fail. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
jlcarvalho
force-pushed
the
feat/tokenized-download
branch
from
July 28, 2026 21:16
cc8d380 to
14dee23
Compare
Pedro-Souza
approved these changes
Jul 31, 2026
Pedro-Souza
requested review from
Pedro-Souza,
WillianSugiyama,
joaom00,
renanbianchi and
victorhurchella
July 31, 2026 14:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional release mirror so the Windows installer can be served with a caller-supplied tag in its filename.
GitHub's signed asset URLs carry
response-content-dispositioninside the signature, so a redirect cannot control the filename the browser saves. With the asset copied to a bucket we control, a presigned URL can — and it does so without any bytes flowing through this server, which is the design principle the service is built on.This resolves the
// TODO: armazenar no S3 e gerar link de download de láthat was already sitting inproxyPrivateDownload.What it does
src/lib/mirror.ts— copies each release asset to an S3-compatible bucket. One copy per release, not per download. Kicked off in the background from traffic the service already receives, including the update poll, so a new release is usually mirrored before anyone clicks download.?t=<tag>on/downloadand/download/:platform— responds302to a presigned URL withResponseContentDisposition, forcing<asset> [<prefix><tag>].exe.Design notes
?t=is ignored when?update=true. A Squirrel update must keep the canonical filename or the protocol stops recognising the package.<prefix>/<REPOSITORY>/<version>/<asset>), so several deployments reading different release repos can share one bucket.INSTALLER_TAG_PREFIX). Whatever client reads the filename must be configured with the same value; keeping it out of the code lets the pair be rotated without a release.console.log(latest.platforms)indownloadPlatformwas removed for that reason. Callers should prefer a short-lived, single-use value.Configuration
All optional; the mirror stays off unless the first three are present. Documented in the README.
New dependencies:
@aws-sdk/client-s3,@aws-sdk/lib-storage,@aws-sdk/s3-request-presigner.Tests
40 passing. The mirror is covered against a stubbed S3 client: the tagged filename, the object key, the short signature lifetime, the fallback when an asset has not been copied, 20 concurrent calls resulting in a single download, and GitHub/upload failures not taking the process down.
A first version of these tests only exercised pure helpers and the disabled path — five mutations survived it (dropping
ResponseContentDisposition, dropping tag validation, widening the presigned URL lifetime,&&→||inisConfigured, inverting the concurrency guard). All five now fail.Not exercised against a real bucket. On the first deploy, watch the log for
[mirror] espelhado …and confirm the downloaded file arrives with the expected name.🤖 Generated with Claude Code