Skip to content

Signed Updates

Updates are opt-in. The application pins an HTTPS feed, a channel, an Ed25519 public key and a policy in pam-desktop.json; the private signing key never ships with the application. A release is accepted only when its feed was signed by the holder of that key and the downloaded archive has the signed size and SHA-256. Installation swaps whole bundles, verifies every file, and rolls back on any failure.

pam-desktop.json
{
"applicationId": "com.example.notes",
"version": "1.0.0",
"updates": {
"endpoint": "https://updates.example.com/notes/stable.json",
"publicKey": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"channel": "stable",
"policy": "notify"
}
}
Field Default Rules
endpoint required HTTPS URL of the feed, without credentials or fragment.
publicKey required The 32-byte Ed25519 public key as 64 lowercase hex characters.
channel stable Starts with a letter; letters, digits, ., -, _.
policy manual manual, notify or automatic.
Policy Behavior
manual Nothing happens until the application calls Updates::check().
notify The host checks the feed at startup and reports what it found.
automatic The host checks, downloads, verifies, installs and restarts the application.

Policies act at startup of an installed bundle, never under pam desktop dev. An invalid updates block stops build; a running application with an invalid block logs the problem and runs with updates disabled. The feed is fetched once per start: no requests and no CPU while the application runs.

Generate the key once, on an offline or tightly controlled machine:

Terminal window
pam desktop update-key --output /secure/notes-update.key

The command writes a 32-byte Ed25519 seed with mode 0600, refuses to overwrite a file, and prints only the public key: put that value in updates.publicKey. Keep the key file in a secret manager.

Build the portable artifacts on each system, collect them in the release job, and sign one feed listing every target:

Terminal window
pam desktop build --format portable
pam desktop publish-update \
--key /secure/notes-update.key \
--output dist/stable.json \
--published-at 2026-12-01T14:00:00Z \
--notes-url https://example.com/releases/1.1.0 \
--expires-in 30 \
--artifact linux,x86_64,portable,dist/notes-1.1.0-linux-x86_64.tar.gz,https://cdn.example.com/notes-1.1.0-linux-x86_64.tar.gz \
--artifact macos,aarch64,portable,dist/notes-1.1.0-macos-aarch64.zip,https://cdn.example.com/notes-1.1.0-macos-aarch64.zip

Each --artifact is platform,architecture,kind,local-path,HTTPS-URL: platforms are linux, macos and windows, kinds are portable and installer. The updater installs portable archives; installers can be listed for download pages. The publisher computes sizes and hashes itself and refuses an existing destination without --force. Upload stable.json to the endpoint and the archives to their URLs.

A signature proves who published a feed, not when:

  • Expiry (opt-in). --expires-in DAYS (1 to 366) signs an expiry time into the feed. The updater refuses an expired feed, so re-sign it on a schedule. Hosts older than this feature reject feeds that carry it.
  • No going back (always). The updater records the newest version each channel offered and refuses a later feed that offers an older one.
use Pam\Desktop\Updates;
use Pam\Desktop\UpdateState;
public function mount(): void
{
Updates::onChange(function (UpdateState $state): void {
match ($state->status) {
UpdateState::AVAILABLE => $this->available = $state->availableVersion,
UpdateState::DOWNLOADING => $this->progress = $state->progress(),
UpdateState::READY => $this->canRestart = true,
UpdateState::FAILED => $this->error = $state->error,
default => null,
};
});
Updates::check();
}
public function download(): void
{
Updates::download();
}
public function restart(): void
{
Updates::install(); // the application closes and starts again on the new version
}
Method Effect
Updates::state($completed) Reads the current UpdateState.
Updates::check($completed) Asks the feed for a newer release.
Updates::download($completed) Downloads and verifies the available release.
Updates::install($completed) Applies it: the application closes and restarts.
Updates::onChange($listener), offChange($id) Every change, whoever caused it.

UpdateState has status, currentVersion, availableVersion, downloadedBytes, totalBytes, notesUrl, error and policy, plus isAvailable(), isReady(), isFailed(), isBusy() and progress(). A refused operation completes with a FAILED state carrying the reason.

install starts a copy of the host as a helper and the application exits. The helper:

  1. verifies the archive against the signed SHA-256 again;
  2. waits for the application to exit;
  3. extracts the archive, which must hold exactly one bundle;
  4. verifies every file against the new bundle’s manifest.json, and that it is the same application (on macOS, also the code signature);
  5. moves the installed bundle aside as .previous, moves the new one into place and verifies it again, rolling back if anything fails;
  6. starts the new version.

Any failure restarts the installed (or restored) version and records the refused archive, so the automatic policy does not loop on a broken release. A journal makes an interrupted swap recoverable on the next attempt.

Only applications that run from a bundle they may replace update themselves: the portable bundle (extracted or installed with install.sh) and the macOS .app. .deb, .rpm, AppImage and MSIX installations report a failure at download and are updated by their package managers.

The full flow (signature, tampered feed, wrong key, replaced archive, modified bundle, rollback and replay) was verified on Linux with portable bundles installed by install.sh. The macOS and Windows helpers are written and type-checked but not verified end to end.