Die Entwickler-Doku gibt es nur auf Englisch.
Example updater
The SDK checks, downloads and verifies an update, but it never installs or runs a file. Installing is the job of your app's updater. crates/sdk-core/examples/updater.rs is a complete reference updater for Linux, Windows and macOS that you can copy and adapt. It uses only the Rust SDK; the same steps work with every SDK that wraps the core.
PRODUCT_ID=prod_... PUBLIC_KEY=k4.public.... API_BASE=https://... LICENSE_KEY=... \
APP_VERSION=1.0.0 cargo run -p sdk-core --example updater -- --target ./myapp
| Variable or argument | Meaning |
|---|---|
--target <path> |
The installed app to replace. Default: the running program |
APP_VERSION |
The running version, default 1.0.0 |
RELEASE_KEYS |
Your public release keys, separated by commas. Turns on the check of your signed release list |
REQUIRE_OS_SIGNATURE=1 |
Also require a valid code signature before installing (codesign on macOS, Authenticode on Windows) |
LICENSE_STORE=memory |
Keep the license state in memory instead of the system's secure storage (CI, headless Linux) |
What it does
At every start of the app:
- Finish an earlier update. If
<app>.update.jsonexists, the previous run installed a version. Is the running version that one, the update worked: the updater removes the backup and callsreport_update(version, false). Is it an older version, something put the old version back, and it callsreport_update(version, true). A report that fails because the device is offline is kept and sent at the next start. - Look for an update.
check_updateand thenrequest_downloadfor the offered version.Nonefromrequest_downloadmeans the device is outside the current rollout share or the rollout is paused; nothing to do yet. - Fetch.
download::fetchwrites the file to<app>.new, next to the app, so that the following renames stay on one file system. It checks size and SHA-256 and decrypts an encrypted file. - Install. The running app is renamed to
<app>.previous, then<app>.newtakes its name. Renaming is allowed on all three systems while the program runs: Windows refuses to overwrite a running.exebut lets you rename it, and on macOS the same works for a whole.appbundle. - Health check. The updater starts the new version with
--health-checkand waits up to 60 seconds for exit code 0. In the example, the health check isclient.check(): the new version starts, reads its stored license and finds the secure storage. Add whatever your app needs to run: its configuration, a database migration, a test window. - Roll back if needed. If the new version does not start, exits with an error or takes too long, the updater puts
<app>.previousback and reportsreport_update(version, true). The server then does not offer that version to this device again, and too many rollbacks pause the rollout for every device (protocol, section 6.10).
If the health check passes, the updater asks to restart the app. The new version finishes the update at its start, as in step 1.
Your signed release list
With RELEASE_KEYS set, the updater calls with_release_keys. From then on the SDK accepts from check_update and request_download only versions and files that your newest signed release list names and does not revoke, and never a version older than the running one (protocol, section 6.11). Even a compromised server cannot hand the updater a foreign or older file. Signing the list is described in Releases signed by you.
Per system
| Linux | Windows | macOS | |
|---|---|---|---|
| Release file | The executable, or unpack an archive into <app>.new |
The .exe, or unpack into <app>.new |
A single binary, or unpack the .app bundle into <app>.new (ditto -x -k app.zip …) |
| Replace while running | Rename | Rename (no overwrite) | Rename, also for a bundle |
| Make executable | chmod 755 |
Not needed | chmod 755 for a binary |
Code signature (REQUIRE_OS_SIGNATURE=1) |
None; SHA-256 and the signed release list are the check | Get-AuthenticodeSignature must say Valid |
codesign --verify --deep --strict |
| Rights | Install where the user may write, or let a privileged service install | Install per user, or use a service or your installer for Program Files |
Install into a folder the user may write, such as ~/Applications |
The example never asks for higher rights. If your app lives in a folder only an administrator may change, hand the checked file to your installer or a service that runs with those rights, and report the outcome from the version that runs afterwards.
Adapting it
- Archives: if your release file is an archive, fetch it to another name next to the app (such as
<app>.download), and unpack it into<app>.newonly afterfetchhas checked it. - Several files: keep the whole installation in one folder and rename that folder, the same way the example renames a single file.
- When to update: the example updates at start. Most apps should ask the user first, show
update.notes, and install at the next start.update.requiredisSome(true)when the running version was blocked or is below the minimum version; then install before the app carries on. - Test it with a canary license: mark your own license as a canary in the dashboard, and it gets every published release at once, whatever the rollout share.