Signed wire protocol
@getcortexlabs/ota-protocol defines the server-agnostic HTTP contract and state schemas shared by the CLI, the on-device SDK, and any update server (including ota-ns serve and Otto).
Three distinct concepts
- Release manifest (
ReleaseManifest) — an immutable, signed inventory of every file belonging to a release (protocolVersion,appId,platform,targetBuild,runtimeContract,releaseId,entry,createdAt,files). - Update directive (
UpdateDirective) — a signed server decision (updateorrollback_to_embedded) stamped with a strictly monotonicdirectiveSeq. - Local activation (
BootState) — the on-device state persisted atomically instate.json.
Why rollbacks use a newer directiveSeq
To prevent downgrade and replay attacks, clients reject any directive whose directiveSeq <= lastDirectiveSeq (unless directiveSeq === lastDirectiveSeq for an identical idempotent check).
When rolling back from ota-105 (directiveSeq: 12) to ota-104, the server issues a new signed directive with directiveSeq: 13 pointing at ota-104 (or action: "rollback_to_embedded"). Clients never weaken replay protection to roll back.
Domain-separated canonical signing
Signatures cover UTF-8 domain-separated canonical JSON (RFC 8785 lexicographical object-key sorting, no insignificant whitespace):
- Manifests:
ota-nativescript:manifest:v1\n+canonicalizeJson(manifest) - Directives:
ota-nativescript:directive:v1\n+canonicalizeJson(directive)
Domain separation guarantees a signed manifest can never be reinterpreted as a signed directive even under the same keypair.
HTTP endpoints
| Method & Path | Purpose |
|---|---|
POST /check | Client sends UpdateCheckRequest (appId, platform, binaryVersion, targetBuild, runtimeContract, channel, currentReleaseId, currentDirectiveSeq); server returns { protocolVersion: 1, status: "none" } or { protocolVersion: 1, status: "directive", signedDirective }. |
GET <manifestUrl> | Returns SignedManifest ({ manifest, signature }). |
GET <assetBaseUrl>/<path> | Streams exact immutable bytes for each file listed in manifest.files. |
POST /events (optional) | Receives best-effort OtaLifecycleEvent telemetry (download_completed, validation_failed, staged, startup_confirmed, recovered_fallback). |
Cross-platform golden vectors
packages/protocol/test/vectors.json holds RFC 8032 Ed25519 golden vectors verified identically across Node.js crypto, Apple CryptoKit (iOS) and Google Tink Ed25519Verify (Android).
Optional observation fields
UpdateCheckRequest may include installId, a UTC timestamp, nullable confirmedReleaseId and nullable stagedReleaseId. Lifecycle events may include the same app-scoped installId; recovery events may include the actual native recoveredAt. Missing fields are left unknown. These extensions do not alter signed manifests/directives or protocol version 1. Treat client reports as untrusted operational observations, never attestation.
Otto exposes this contract under /api/check?app=<console-app-id> and /api/events?app=<console-app-id>. The protocol paths above describe the portable contract; use the endpoints generated for your app.
