Updates and download links
This guide adds an update check to your application and puts download links on your download page. At the end, your application finds, downloads and verifies a new release. Each link on your download page leads to the newest release.
Before you start
- A product with a published release that has a file for each platform. See Publish a release.
- Your application verifies signed responses. It embeds your public key and has the
verifyResponsefunction. See Verify signed responses. - For a product with the
licenseddistribution setting, your application stores the license key. See Add your application. Anopenproduct does not need a license key.
The examples call https://dist.seatify.dev. In curl, the product ID, the license key and the key ID of your signing key are the variables $PRODUCT_ID, $LICENSE_KEY and $SEATIFY_SIGNING_KEY_ID. In the other languages, they are variables of your application.
Update your application
Check for an update
Send the version that your application runs, with its platform and its architecture. The version is a semantic version without a v prefix. Send the platform and the architecture together, or leave out both. See Platforms and architectures.
If a release has several files for one platform, such as a .dmg and a .zip, add filetype, such as filetype=dmg.
Send the nonce and the key ID too, and verify the answer before your application uses it. Your application trusts the SHA-256 of the file only from a verified answer.
curl "https://dist.seatify.dev/v1/products/$PRODUCT_ID/update?version=1.1.0&platform=darwin&arch=arm64" \
-H "Seatify-License-Key: $LICENSE_KEY" \
-H "Seatify-Signing-Key: $SEATIFY_SIGNING_KEY_ID" \
-H "Seatify-Nonce: $(uuidgen)"The answer offers the newer release in update. See Check the update for a full answer. Your application uses these fields:
| Field | Description |
|---|---|
update.version | The version to install. |
update.name, update.notes | The name and the release notes. Your application can show them to the user. |
update.artifact | The file for the platform, the architecture and the file type of the check. It is null when several files of the release match. A check without a platform matches every file. Then choose a file from update.artifacts. |
update.artifact.url | The address to download the file from. |
update.artifact.sha256, update.artifact.signature, update.artifact.signing_key_id | The values that verify the file. |
When your application runs the newest version that it can install, update is null:
{
"valid": true,
"reason": null,
"current": "1.2.0",
"update": null
}Download the file
Request update.artifact.url with the license key. The answer is a redirect with the status 303 to a signed download link. Your HTTP client follows the redirect.
Check the status before you save the file. A refused download answers a status other than 200. See Handle the answer.
curl --fail --location --remote-name \
-H "Seatify-License-Key: $LICENSE_KEY" \
"https://dist.seatify.dev/v1/products/$PRODUCT_ID/releases/1.2.0/artifacts/BEACON-1.2.0-universal.dmg"The redirect is not signed. Your application checks the file itself in the next step.
Verify the file
Verify the file before your application installs it. If a check fails, delete the file.
- Compute the SHA-256 of the file in lower-case hex. It must equal
update.artifact.sha256. - Find the embedded public key that has the key ID in
signing_key_id. - Check the Ed25519 signature in
signaturewith this key. The signed message is the textartifact/followed by the SHA-256 from check 1. The signature is in standard Base64.
If no embedded key has the key ID, the SHA-256 check is enough. The SHA-256 came in an answer that your application verified. This happens after you rotate signing keys. See Updates across a rotation.
Install the update
Install the file only after both checks pass. The installation depends on your platform and your installer.
Handle the answer
The update check answers every licensing outcome with the status 200, a refusal too. A download answers a refusal with an HTTP status instead. An HTTP client that follows a download would otherwise save the refusal as the file.
| Answer | Answered by | What your application does |
|---|---|---|
update is null | Update check | No action is needed. Your application runs the newest version that it can install. |
update.artifact is null | Update check | Add filetype to the check, or choose a file from update.artifacts. |
suspended | Update check, and download with the status 403 | Tell the user that the license is suspended. |
expired | Update check, and download with the status 403 | Tell the user that the license has expired. The After expiry rule of the policy ends access to releases. |
product_mismatch | Update check, and download with the status 403 | The key belongs to another product. Ask the user for the right key. |
release_not_covered | Download with the status 403 | The license has expired, and the release was published after the expiry date. The update check never offers such a release. |
The reason is in the reason field of the answer, also for a 403. Other statuses mean that the request itself is wrong:
| Status | Cause |
|---|---|
| 400 | The query is not valid. The errors field names each field that is wrong. |
| 401 | The license key is missing on a licensed product, or the key is not valid. |
| 404 | Download only. The release or the file does not exist, or the release is a draft or yanked. |
| 429 | Your application sent too many requests. Try again later. |
Beta and version lines
The update check stays in the channel of the version that your application runs. A beta build sees beta, release candidate and stable releases. A stable build sees only stable releases. See Channels.
- To let the user join the beta, send
channel=betawith the check. - To let the user leave the beta, send
channel=stable. Your application keeps its beta build until a stable release with a higher version is published. For example,1.3.0is higher than1.3.0-beta.2. - To keep your application on one major version, send
constraint=2. The check then offers only2.x.yversions. Use it when version 3 needs a new license. See Newest release.
Resume a download
The signed download link accepts a Range header, so your application can resume a download that stopped. The link expires. Request update.artifact.url again for a new link.
Each request of update.artifact.url counts as a download.
Update frameworks
Seatify serves update endpoints for Tauri, Sparkle, WinSparkle and electron-updater. An application that uses one of these frameworks reads its endpoint instead of the update check. See Update a Tauri application, Update a Sparkle application, Update a WinSparkle application and Update an Electron application.
For another update framework, your application calls the update check and downloads the file itself. If your framework checks its own signature of the file, add this signature to the file in the dashboard. The update check returns it unchanged in vendor_signature. Seatify does not check it.
Put download links on your page
A stable download link names a platform, an architecture and a file type. It names no version and no filename. So the link stays the same when you publish a new release.
A browser sends no header when it follows a link. So a stable download link works on a web page only for an open product. For a licensed product, see Licensed products.
Copy the links
Copy the links from the Download links section of the product in the dashboard. The dashboard shows one link for each file of the newest release.
| File | Link |
|---|---|
| macOS | https://dist.seatify.dev/v1/products/<product id>/download?platform=darwin&arch=universal&filetype=dmg |
| Windows | https://dist.seatify.dev/v1/products/<product id>/download?platform=windows&arch=amd64&filetype=exe |
| Linux | https://dist.seatify.dev/v1/products/<product id>/download?platform=linux&arch=amd64&filetype=tar.gz |
Add the links to your page
<a href="https://dist.seatify.dev/v1/products/<product id>/download?platform=darwin&arch=universal&filetype=dmg">Download for macOS</a>
<a href="https://dist.seatify.dev/v1/products/<product id>/download?platform=windows&arch=amd64&filetype=exe">Download for Windows</a>
<a href="https://dist.seatify.dev/v1/products/<product id>/download?platform=linux&arch=amd64&filetype=tar.gz">Download for Linux</a>A click answers a redirect to a signed download link. The browser saves the file under its filename.
Test the links
Download each link once. The file must be the file of the newest release.
curl --fail --location --remote-name --remote-header-name \
"https://dist.seatify.dev/v1/products/$PRODUCT_ID/download?platform=darwin&arch=universal&filetype=dmg"Link rules
- A link leads to the newest release in the
stablechannel that has a matching file. A release without a matching file is skipped. A fix for Windows only then does not change the macOS link. - A
universalbuild matches a link for any architecture. A build for the exact architecture wins over auniversalbuild. - If several files of one release match, the link fails with the status 404. Add
filetypeto the link. The links from the dashboard already name the file type. - A link for a platform that no release has a file for fails with the status 404.
- Add
channel=betato a link for the newest beta. Addconstraint=2to keep a link on version 2. The dashboard adds both when you choose a channel and a version line. - Each download through a link counts as a download.
Licensed products
A download of a licensed product needs a valid license key for the product. A browser cannot send the key, so your server requests the link instead. Your server must know the license key of the customer, for example from the account of the customer.
Request the link
Request the stable download link with the license key in the Seatify-License-Key header. Do not follow the redirect. The answer has the status 303, and its Location header is a signed download link.
A refused request answers a status other than 303. See Handle the answer.
curl --silent --output /dev/null --write-out "%{http_code} %{redirect_url}\n" \
-H "Seatify-License-Key: $LICENSE_KEY" \
"https://dist.seatify.dev/v1/products/$PRODUCT_ID/download?platform=darwin&arch=universal&filetype=dmg"The JavaScript example runs on a server, such as Node.js. A browser hides the Location header of a redirect that it does not follow.
Send the browser to the file
Answer the request of the browser with a redirect to location. The browser saves the file under its filename.
The signed download link expires. Anyone who has the link can use it until it expires. So request a new link for each download, and do not store it.
Each request of the link counts as a download in the activity of the license.