Map distribution API — https://www.orixlab.dev/maps/v1/
Status: client implemented (CatalogClient, DownloadManager in Packages/ORIXMapPackage), files generated by
orix-package catalog / orix-package publish (Infrastructure/package-builder), server not implemented here: this
document specifies what the Next.js route on the owner's node must do. The client was tested against an in-process
server and a real HTTP server on a loopback port that implement this specification; it was never run against
www.orixlab.dev.
Maps are downloaded from the ORIX Labs site the same way ORIX Astra downloads its local models: plain static files, no account, no API key.
1. Resources
Everything is a static file under one versioned base. v1 is the major version of the document schema.
| Method and path | Content | Cache-Control |
|---|---|---|
GET /maps/v1/catalog.json |
every region with the summary of its current version | public, max-age=300 |
GET /maps/v1/regions/<id>.json |
one region in detail (licences, components, zoom range) | public, max-age=300 |
GET /maps/v1/regions/<id>/versions.json |
every published version of the region | public, max-age=300 |
GET /maps/v1/files/<id>/<dataVersion>/<id>-<dataVersion>.orixmap |
the signed package (docs/ORIXMAP_FORMAT.md) |
public, max-age=31536000, immutable |
<id> is [a-z0-9-]{1,64}, <dataVersion> is a dotted decimal version (2026.11.24). Nothing else is served under
/maps/v1/ (in particular not pins.json, a publisher-side file of the distribution directory).
The distribution directory on the node has exactly this shape, so the route only maps URL paths to files:
<distribution>/catalog.json
<distribution>/regions/ca-qc-montreal.json
<distribution>/regions/ca-qc-montreal/versions.json
<distribution>/files/ca-qc-montreal/2026.11.24/ca-qc-montreal-2026.11.24.orixmap
<distribution>/pins.json (publisher state, not served)2. Server requirements
For every resource:
ETag: a strong entity tag equal to the lowercase hexadecimal SHA-256 of the file, in double quotes (ETag: "70791b6b…9e8a"). For artefacts it is thesha256of the catalog. Never a weak tag (W/…): the client refuses to resume without a strong one.Content-Lengthon 200 and 206 responses.If-None-Match→304 Not Modifiedwhen the tag matches.- No
Set-Cookie, no redirect to another host, no authentication. - Rate limit:
429 Too Many RequestswithRetry-After: <seconds>(an HTTP date is also understood). The client never retries a 429 by itself: it reports the delay to the application. - Unknown path:
404.
For artefacts (files/…):
Accept-Ranges: bytes;Range: bytes=<first>-<last>andbytes=<first>-→206 Partial ContentwithContent-Range: bytes <first>-<last>/<total>. Only single ranges are ever requested.If-Range: "<etag>": when the tag does not match the current file, ignore the range and answer200with the whole file (RFC 9110 §13.1.5). This is how the client learns that the file changed under a partial download.- A range starting at or after the end of the file →
416 Range Not Satisfiable. Content-Type: application/vnd.orix.map; noContent-Encoding(the client sendsAccept-Encoding: identity; byte ranges and digests are those of the stored file).- A published artefact is immutable: its bytes never change under a given path. New data means a new
dataVersion, hence a new path. (CryptoKit signatures are randomised, so re-running the builder on the same inputs produces different bytes: never overwrite a published file.)
For JSON documents: Content-Type: application/json; transport compression is allowed.
3. Documents
Schema version: {"major": 1, "minor": 0} in every document. Clients ignore unknown members at every level and reject a
major they do not know with a typed error (CatalogError.unsupportedSchema) that the application presents as "update
the app". A minor bump only adds members. Timestamps are YYYY-MM-DDTHH:MM:SSZ. The three documents are generated by
orix-package catalog; the examples below are the real output for the development distribution built on 2026-11-25.
3.1 catalog.json
{
"schema": { "major": 1, "minor": 0 },
"generatedAt": "2026-11-25T08:33:59Z",
"regions": [
{
"id": "ca-qc-montreal",
"names": { "en": "Greater Montréal", "fr": "Grand Montréal" },
"bbox": { "minLat": 45.15, "minLon": -74.35, "maxLat": 45.95, "maxLon": -73.15 },
"capabilities": ["map", "search", "routing"],
"latest": {
"dataVersion": "2026.11.24",
"dataTimestamp": "2026-11-24T00:00:00Z",
"buildDate": "2026-11-25T08:33:51Z",
"downloadSize": 236150784,
"installedSize": 236146599,
"sha256": "70791b6b7f431328d3c14e29ad77b5f39a11545e2264a55bd60d1685cddf9e8a",
"signingKeyId": "92853604e9033917",
"path": "files/ca-qc-montreal/2026.11.24/ca-qc-montreal-2026.11.24.orixmap",
"preambleSize": 1521
}
}
]
}| Member | Meaning |
|---|---|
generatedAt |
when the publisher generated the document; a client never replaces a cached catalog by an older one |
regions[].id, names, bbox, capabilities |
copied from the manifest of the current package |
latest.dataVersion, dataTimestamp, buildDate |
version, OSM data date and build date of the current package |
latest.downloadSize |
size of the .orixmap file |
latest.installedSize |
size of the extracted components |
latest.sha256 |
SHA-256 of the whole .orixmap file (= its ETag) |
latest.signingKeyId |
key that signed it; lets the application say "update the app" when it does not know the key |
latest.minAppVersion |
optional; oldest application version able to use the package |
latest.path |
artefact path relative to the base URL |
latest.preambleSize |
optional; bytes to request (Range: bytes=0-<preambleSize-1>) to get the signed manifest alone |
Client-side validation: a region entry that is malformed, has an invalid id, or whose path is not a plain relative
path (segments of [A-Za-z0-9._-], never . or .., no scheme, no query) is dropped and counted in
Catalog.skippedRegions; the other entries are kept. A path can therefore never leave the base URL.
3.2 regions/<id>.json
{
"schema": { "major": 1, "minor": 0 },
"generatedAt": "2026-11-25T08:33:59Z",
"region": { "id": "ca-qc-montreal", "names": { "…": "…" }, "bbox": { "…": 0 }, "capabilities": ["map", "search", "routing"],
"latest": { "…same object as in catalog.json…": 0 } },
"mapZoom": { "minZoom": 0, "maxZoom": 15 },
"languages": ["en", "fr"],
"licences": [
{ "source": "OpenStreetMap", "licence": "ODbL-1.0", "attribution": "© OpenStreetMap contributors",
"url": "https://www.openstreetmap.org/copyright" },
{ "source": "Natural Earth", "licence": "Public domain", "attribution": "Made with Natural Earth",
"url": "https://www.naturalearthdata.com/about/terms-of-use/" }
],
"components": [
{ "id": "map", "length": 96370599, "mediaType": "application/vnd.pmtiles", "formatVersion": 3,
"sha256": "2a9051192b6e6b12ebca351ba0f71c8d1ce5b57b7015a28ca9a8e2f7c87ea807" },
{ "id": "search", "length": 40460288, "mediaType": "application/vnd.sqlite3", "formatVersion": 1,
"sha256": "ad542b9daacbdb9ad418ef518976a4e4c2c9335338015a58f37793a4e740bd01" },
{ "id": "routing", "length": 99315712, "mediaType": "application/vnd.orix.graph", "formatVersion": 1,
"sha256": "aaa26d20a0f2f942f76a9b4a0566b4d873bea22872f371f6f33dd12267c30486" }
],
"builder": { "orix-package": "1.0.0" }
}The client refuses a document whose region.id is not the one it asked for.
3.3 regions/<id>/versions.json
{
"schema": { "major": 1, "minor": 0 },
"generatedAt": "2026-11-25T08:33:59Z",
"id": "ca-qc-montreal",
"latest": "2026.11.24",
"versions": [
{ "dataVersion": "2026.11.24", "dataTimestamp": "2026-11-24T00:00:00Z", "buildDate": "2026-11-25T08:33:51Z",
"downloadSize": 236150784, "installedSize": 236146599,
"sha256": "70791b6b7f431328d3c14e29ad77b5f39a11545e2264a55bd60d1685cddf9e8a", "signingKeyId": "92853604e9033917",
"path": "files/ca-qc-montreal/2026.11.24/ca-qc-montreal-2026.11.24.orixmap", "preambleSize": 1521 }
]
}versions is sorted newest first. latest is the version the catalog currently offers; after a publisher rollback it
is older than versions[0].
4. What the client sends
One kind of request: GET of one of the four resources above. Headers sent by the application code:
| Request | Headers |
|---|---|
| JSON documents | Accept: application/json, If-None-Match: "<etag>" when a cached copy exists |
| Artefact | Accept-Encoding: identity, and when resuming Range: bytes=<n>- + If-Range: "<etag>" |
| Preamble alone | Accept-Encoding: identity, Range: bytes=0-<n> |
URLSessionTransport adds only User-Agent: ORIXMaps/<version> (fixed, generic), Accept-Language: en (fixed, so the
device language is not disclosed) and what HTTP itself needs (Host, Connection, and Accept: */* when the code set
none). Measured on the loopback server: the complete header set received is host, user-agent, accept,
accept-language, accept-encoding, connection.
The session is URLSessionConfiguration.ephemeral with no cookie storage (httpCookieStorage = nil,
httpShouldSetCookies = false, accept policy never), no URL cache and no credential storage.
Never sent: coordinates, search text, the list of installed regions, any identifier of the user, the device or the installation, cookies, query strings. URLs are built from the base URL, a region identifier and a data version only.
What the server can still learn, because HTTP makes it unavoidable: the IP address of the client, the time, and which region package it downloads — hence a coarse indication of where the user is interested in. Someone watching the network sees the host name (TLS SNI) and the transfer size, which can identify the region. The application should say so in its privacy text; nothing else leaves the device.
5. Client behaviour
5.1 Catalog cache and offline use
- Each document is cached on disk with its ETag, the date it was fetched and the date it was last confirmed by the
server (
<cache>/catalog.json+catalog.meta.json,region-<id>…,versions-<id>…). The cache is tied to the base URL. catalog(refresh:):.ifOlderThan(seconds: 300)(default) answers from the cache while it is fresh, else revalidates withIf-None-Match;.always;.cacheOnly.- The result is a
CatalogSnapshotwithorigin:.network,.revalidated(304),.cache, or.staleCache(reason:)— any failure (offline, 429, 5xx, undecodable or oversized document, unknown schema major, older document) falls back to the last good document, marked stale, withfetchedAtfor the UI ("catalog from 25 November"). Without a cached copy the error is thrown. - Limits: a document larger than 8 MiB is refused; nothing invalid is ever written to the cache.
5.2 Download, resume, verification
- Space: before any request,
downloadSize − alreadyDownloaded + installedSize + margin(64 MiB by default) must be free →DownloadError.notEnoughSpace(required:available:missing:). - Transfer to
<store>/staging/downloads/<id>-<version>.orixmap.part, with a sidecar.download.jsonholding the request and the strong ETag of the first response. - Resume (after a broken connection, a pause, or an application relaunch):
Range: bytes=<size of the partial file>-andIf-Range: "<etag>".206with the expectedContent-Range→ the bytes are appended.200with the same ETag → the server does not honour ranges: the transfer restarts from zero with that response.200with another ETag,206with another total or ETag, or416→ the file changed: the partial file is discarded and the error isserverFileChanged(refresh the catalog). Bytes of two files are never mixed.- No strong ETag was received → nothing is resumed, the transfer restarts from zero.
- Early check: as soon as the partial file holds the preamble (a few kilobytes), its signature is verified and the manifest must name the requested region, version and size, and be installable (not a downgrade, application recent enough). A wrong or forged file is refused after one chunk, not after 300 MB.
- Broken transfers are retried automatically from the partial file (exponential delay, 4 attempts without progress
by default; any progress resets the count).
offline, 429 and HTTP errors are reported immediately; the partial file is kept. - End: the size and the SHA-256 of the complete file are compared with the catalog (
sizeMismatch,checksumMismatch), thenRegionStore.installverifies the signature and every component again while extracting. - Never more than the announced size is written: a server that sends more is stopped (
sizeMismatch).
DownloadManager.fetchManifest implements "manifest alone": one Range request of preambleSize bytes (16 KiB when the
catalog gives no size, a second request if the preamble is longer), signature verified, nothing written to disk.
6. Trust model
The catalog and the server are not trusted for integrity. The only root of trust is the set of Ed25519 public keys
compiled into the application. The catalog's sha256 and sizes are an early consistency check (they catch corruption
and a catalog/file mismatch cheaply); they are not a security boundary.
What an attacker who controls the server, the DNS or the network path cannot do:
| Attack | Why it fails | Test |
|---|---|---|
| Serve a modified package (and a catalog whose digest matches it) | component SHA-256 values are in the signed manifest | serverControlledByAnAttackerCannotInstallAnything (1) |
| Serve a package signed with its own key | key not in the trust store; refused when the preamble arrives | same (2) |
| Serve a genuine package of another region under this region's name | the signed regionId must equal the requested one |
same (3) |
| Serve a genuine older package labelled as the new version | the signed dataVersion must equal the requested one |
same (4) |
| Offer an older version of an installed region (rollback) | RegionStore refuses a downgrade unless the user forces it |
downgradeOfferedByTheCatalogIsRefusedEarly |
Replay an older catalog.json to a client that saw a newer one |
generatedAt older than the cached one → cached copy kept, marked stale |
replayedOlderCatalogDoesNotReplaceANewerOne |
| Make the client fetch from another site or path | path must be a plain relative path under the base URL |
forwardCompatibleDecoding, safeRelativePaths |
| Write outside the store, overwrite application files | no name or path is taken from a package or from the catalog; region ids and versions are validated before they become directory names | fuzz tests, hostileComponentIds |
| Fill the disk or the memory | announced size checked against free space and never exceeded; manifest ≤ 1 MiB; catalog ≤ 8 MiB; components streamed | notEnoughSpace, wrongChecksumAndWrongSize |
| Mix components of two packages | one signature covers all component digests | tamperedContentIsRejected |
| Splice a changed file into a resumed download | If-Range + ETag, then whole-file SHA-256, then the signature chain |
serverFileChangedDuringResume |
What such an attacker can do, and how the client limits it:
- Denial of service: refuse, slow down or truncate downloads. Installed maps keep working offline; partial files are resumed when the path works again.
- Freeze: keep serving a catalog that was current when the client first saw it, hiding newer versions. Nothing
cryptographic prevents this without a trusted clock. The client exposes
generatedAtandfetchedAtso that the application can display the age of the catalog and of each region's data (dataTimestampis signed). - Rollback at first installation: to a client that has neither a cached catalog nor the region installed, the attacker can present an old catalog and the matching old, genuine package. The user gets an authentic but outdated map; its signed data date is visible. Deleting a region also forgets the installed version (the store keeps no high-water mark after deletion).
- Lie about what is available: hide regions, announce wrong sizes or names. Wrong sizes are caught at the preamble
(4 of 5.2) or at the end; names shown before download come from the catalog and are replaced by the signed ones once
the manifest is fetched (
fetchManifest). - Observe: see section 4.
Not done and worth considering later: signing catalog.json itself (same keys, detached signature) would turn "replay
of an old catalog" from detectable-if-seen-newer into forgeable-by-nobody, and give generatedAt a signer. It would not
solve freeze attacks without a freshness limit.
7. Publishing, atomicity and rollback
On the node, in the distribution directory:
# one command: verify, copy to files/<id>/<version>/ (temporary file + rename), regenerate the three documents
orix-package publish ca-qc-montreal-2026.11.24.orixmap --dir /srv/orix-maps/v1 --trust production.trust.json
# or, after copying files by hand: verify every package under files/ and regenerate
orix-package catalog --dir /srv/orix-maps/v1 --trust production.trust.jsoncatalog fully verifies every package under files/ (signature, layout, SHA-256 of each component) and checks that
each one sits at the canonical path for its signed region and version. One invalid, misplaced or unexpected file aborts
the command and leaves the published documents untouched.
Order of writes, each one a temporary file followed by a rename (readers see the old or the new document, never a partial one):
- the artefact, into
files/(bypublish); regions/<id>/versions.json, thenregions/<id>.json, for every region;catalog.json— last, so that it never references an artefact or a document that is not in place;- documents of regions that have no package left are removed after the catalog stopped listing them.
A crash between two steps leaves a catalog that is older than some region documents but always consistent with the files on disk; re-running the command completes the publication.
Rollback (a published version is bad):
orix-package catalog --dir /srv/orix-maps/v1 --trust production.trust.json --latest ca-qc-montreal=2026.11.10latest points back to the previous version in catalog.json, regions/<id>.json and versions.json; the choice is
stored in pins.json and survives later regenerations until --unpin ca-qc-montreal (or until a newer version is
published and unpinned). The bad version stays listed in versions.json and on disk — delete its directory under
files/ and run catalog again to withdraw it completely. Clients that already installed the bad version are not
downgraded automatically (downgrade refusal): the application sees an installed version newer than the catalog's and
can offer the user an explicit, forced reinstallation, or simply wait for the fixed version, which must carry a greater
dataVersion than the bad one.
8. Not implemented / not verified
- The server (Next.js route) is not part of this work; nothing here was tested against
www.orixlab.dev. - TLS, CDN behaviour, real rate limiting and HTTP/2-3 were not exercised (the loopback server is HTTP/1.1 over TCP).
- Background
URLSessiondownloads are not implemented (seePackages/ORIXMapPackage/README.md). - The catalog is not signed (section 6).
- No delta updates, no mirrors, no per-region statistics.