Capsule format (.orixcapsule), version 1
A capsule is one file holding a selection of a user's ORIX Navigator data, for backup or for moving it to another
device by any means (AirDrop, a USB key, a file share). Module: SyncEngine (CapsuleExporter, CapsuleReader,
CapsuleImporter). No third-party library: the container is implemented in the module, compression uses Apple's
Compression framework, cryptography uses CryptoKit and CommonCrypto.
What a capsule can and cannot contain
Can, each only if the user selected it:
| Kind | Content |
|---|---|
bookmarks |
bookmarks and folders of one profile (a selected folder brings its subtree) |
notes, canvases, workflows |
the items as stored |
spaces |
per space: name, symbol, tint and the list of open tabs as (URL, title, pinned) |
archives + archiveFile |
archive descriptions and their stored files |
canvasAttachment |
image/PDF files referenced by exported canvases |
history |
visits (URL, title, time, transition) — only when the user explicitly ticks history (includeHistory), and imported only when the importing user ticks it too (importHistory) |
Cannot, by construction — the exporter has no code path that reads them and the format has no entry kind for them: cookies and website storage (they live in WebKit, never in the app's database), secrets and API keys (Keychain), settings, permission decisions, downloads, agent runs, WebKit session state of tabs, sync records and device identifiers, the memory index, workflow run logs, profile names. A test fills a database with marker values in each of these places and asserts that no marker appears in the file or in any decompressed entry.
Container layout
All integers are big-endian.
offset size field
0 8 magic: ASCII "ORIXCAPS"
8 2 container version = 1
10 2 flags: bit 0 = encrypted; all other bits must be 0
12 4 header length H (2 … 4096)
16 H header: UTF-8 JSON
16+H … bodyClear capsule (flags = 0): header is exactly {}; body = entries, followed by a 32-byte SHA-256 digest of
every byte of the file before the digest.
Encrypted capsule (flags = 1): header is
{"cipher":"AES-256-GCM","iterations":600000,"kdf":"PBKDF2-HMAC-SHA256","keyLength":32,"salt":"<base64, 16 bytes>"}and body = nonce (12) ‖ ciphertext ‖ tag (16), the AES-256-GCM encryption of entries, with the first 16 + H
bytes of the file (magic, version, flags, header length, header) as associated data.
entries:
repeat:
u16 name length N (1 … 240); 0 ends the list
N name, UTF-8
u8 compression: 0 = stored, 1 = raw DEFLATE (RFC 1951)
u64 stored length S
u64 original length L
S bytes
u32 number of entries (must equal the number read)The first entry is manifest.json. Entries are sorted by name after it. A clear capsule is deterministic: the same
selection, the same data and the same createdAt give the same bytes.
Entry names
Relative paths of at most 6 components made of A–Z a–z 0–9 . - _, no empty component, no . or .., no
component starting with . or -. Names used by version 1:
manifest.json
data/bookmarks.json data/notes.json data/canvases.json data/workflows.json
data/spaces.json data/history.json data/archives.json
files/archives/<archive UUID>/<sanitised file name>
files/canvas/<canvas UUID>/<64 hex digits>.<png|jpg|gif|webp|heic|tiff|pdf>Manifest
{
"format": "orix.capsule",
"formatVersion": 1,
"createdAt": 1800000000,
"appVersion": "1.0 (12)",
"includesHistory": false,
"items": [
{"name": "data/bookmarks.json", "kind": "bookmarks", "count": 42, "byteSize": 9120, "sha256": "…64 hex…"}
]
}One item per entry other than the manifest. byteSize and sha256 describe the uncompressed payload; count is
the number of records of a JSON entry (1 for a file). JSON payloads are arrays of the model types of NavigatorCore
(Bookmark, Note, CanvasDocument, Workflow, Archive) or of the two capsule-only shapes (space with tabs,
visit); dates are numbers of seconds since 1970; keys are sorted. Inside a capsule, Archive.relativePath is the
entry name of the archive's file.
Password protection
- Key: PBKDF2-HMAC-SHA256 (CommonCrypto
CCKeyDerivationPBKDF), 600 000 iterations, 16 random bytes of salt, 32-byte output. The password is normalised to Unicode NFC before derivation. - Cipher: AES-256-GCM (CryptoKit), random 96-bit nonce, 128-bit tag, header authenticated as associated data.
- On reading, the iteration count must be between 100 000 and 10 000 000 and the cipher/KDF names must be exactly those above, so a crafted header can neither weaken the derivation nor stall the app.
Limits, stated plainly:
- PBKDF2 is not memory-hard. An attacker with the file can test passwords on GPUs or ASICs far faster than the app derives a key. 600 000 iterations slow each guess; they do not make a weak password safe. The protection is as strong as the password. (A memory-hard function such as Argon2id or scrypt is not available in CryptoKit or CommonCrypto, and the project takes no third-party dependency.)
- An encrypted capsule hides its content and its entry names and sizes; it does not hide its total size, nor that it is an ORIX capsule (magic and header are in clear).
- A wrong password and a modified file give the same error: they cannot be told apart.
- A clear capsule has an integrity digest, not a signature: it detects corruption, but anyone can produce a valid clear capsule. Nothing authenticates who made a capsule, encrypted or not (an encrypted one proves only knowledge of the password).
- The whole capsule is built and read in memory; the default limit is 1 GiB.
Reading: validation before anything else
CapsuleReader.open(data, password:) returns a CapsuleContents or throws; it has no access to the database.
A capsule is rejected as a whole when any of these fails:
- Size ≤ the file limit; magic; container version (a higher version →
unsupportedVersion); no unknown flag; header length and content. - Integrity: the SHA-256 digest (clear) or the GCM tag (encrypted). Any flipped byte of a clear capsule fails here or at step 1 — a test flips every byte, and truncates at every length.
- Entry structure: every length is checked against the bytes that remain; no duplicate name; unknown compression refused; entry count matches; no trailing byte.
- Sizes before allocation: declared original length ≤ 256 MiB per entry and ≤ 1 GiB in total; at most 20 000 entries. A compressed entry is inflated into a buffer of exactly its declared size plus one byte, so an entry that inflates to more than it declares is detected without producing the excess ("zip bomb").
- Names: the rules above; anything else →
unsafeName. - Manifest: first entry, known format and version, and a one-to-one match with the entries (same names, same sizes, same SHA-256) — an unlisted entry, a missing one or a changed payload rejects the capsule.
- Content: record counts equal to the manifest's; unique identifiers; URLs of bookmarks, notes, tabs, visits,
archives and canvas page cards limited to
http,https,ftp,file; text sizes bounded; canvas geometry finite and connections valid; canvas attachment references are content-hash names only; every file belongs to an item of the capsule; an archive's path is its own entry name; history present only if declared.
Importing: preview, then merge
-
CapsuleImporter.preview(contents, options:)reads the destination and returns, per kind, how many items are new, identical or conflicting, plus remarks (history not ticked, archives without a folder…). It writes nothing. -
CapsuleImporter.apply(contents, options:)merges with the chosen conflict policy, applied to items whose identifier already exists with different content:Policy Effect keepBoththe incoming item is imported under a new identifier; the existing one is untouched replacethe existing item is overwritten skipthe existing item is kept, the incoming one ignored Identical items are never rewritten. Nothing is overwritten unless the policy is
replace.
Details:
- Bookmarks, spaces, archives and history go to the profile given in the options (a stored profile is required).
Parents are imported before children; a bookmark whose folder is neither in the capsule nor in the destination
goes to the top level; under
keepBothchildren follow their (possibly renamed) parent. - A space that already exists and differs is never replaced: under
replaceit is imported as a copy named "… (imported)". An imported space gets one window with dormant tabs (URL, title, pinned; nothing is loaded). - Notes and canvases keep their space if it is imported with them or already exists; otherwise they are detached.
- Files are written only under the directories passed in the options, at paths the importer chooses
(
capsule/<archive id>/<sanitised name>,<canvas id>/<hash name>); a path found in the capsule is never used as a destination. - History visits already present (same URL and time) are not duplicated.
- Importing the same capsule twice changes nothing the second time.
The import is not one transaction: each item is written atomically through the public stores, in the order spaces, bookmarks, notes, canvases, workflows, archives, history. A failure in the middle (disk full) leaves the items already imported in place; running the import again completes it.
Compatibility
- Readers reject container versions and manifest format versions they do not know.
- New optional manifest fields may be added without a version change; a new entry kind, a new compression method or a new cipher requires a new version.
Not verified
- Capsules were only produced and read by this implementation, in tests, on macOS. No capsule has been moved between two real devices or read by an independent implementation (the tests do build containers by hand from this document to check the reader).
- Behaviour with very large capsules (hundreds of megabytes) was not measured; a 64 MiB decompression bomb is covered.
- No UI exists for the export sheet, the password prompt or the import preview.
- The export of archive files and canvas attachments depends on directories the app passes in; the app-side layout of those directories is not defined yet.