The Vault package implements the device role of Remote Vault Connect inside the mobile app. It is a port of the Go daemon's vault behaviour (backend/storage/vault), written in TypeScript because the app has no daemon. It keeps every identity in one encrypted file, can link that file to a person's remote vault through a browser approval, and then syncs so identities created on any device appear on all of them.
Responsibility
Hold identities in an encrypted envelope on the device, keyed from the Keychain.
Run the connect ceremony: mint a token, open the vault's browser page, poll for the approval, adopt the remote data key.
Sync with optimistic concurrency: fetch, merge, upload, retry on conflict.
Mirror identities between the vault state and the seed-keys Keychain map that the rest of the app signs with (Identity).
Lock, unlock, switch back to local, and log out.
Files
File | Role | Page |
|---|---|---|
| ||
The three | ||
Token, connect URL, mailbox payload, finishing a connection | ||
HTTP client and error classes | ||
One sync pass | ||
State merge and equality | ||
| Screens, tasks, actions, Contract tests | |
27 Bun tests against the mock vault | all of the above |
The byte formats (envelope JSON, state codec, AEAD) live in Crypto: vault envelope and state codec.
How the pieces relate
flowchart TB
UI["vault.contract screens and root tasks"] --> SRC["sources.ts: vaultRead, vaultStart, vaultCommand"]
SRC --> ST["VaultStore in store.ts"]
ST --> CN[connect.ts]
ST --> SY[sync.ts]
CN --> MG[merge.ts]
SY --> MG
CN --> API[api.ts]
SY --> API
API --> SRV[Vault server]
ST --> FILE[("app:/data/vault/envelope.json")]
ST --> KEK[("Keychain secret seed-vault-kek")]
ST -->|publishes| KEYS[("Keychain secret seed-keys")]
KEYS -->|reconciled into| ST
ME[Me package] -->|edits| KEYSTwo copies of the identities
There are two stores, and understanding their order explains most of the design:
The vault state (encrypted file) is the source of truth. It carries seeds, names, delegations, tombstones and fields from newer clients.
The Keychain map seed-keys is the copy the app signs with. The vault publishes into it after the state is written.
Because the map is written second, it can be behind. The package therefore never infers a deletion from a missing key: only an explicit {removed: true} marker left by Me becomes a tombstone. This rule was introduced after an incident on 2026-11-26, recorded in the test file, where "a phone whose Keychain map was behind its vault state tombstoned 34 identities and, on the next completed connection, deleted them from the remote vault and every other device".
Grants and limits
Grants in app.ts: secret.keep seed-vault-kek, fs.read app:/data/vault/envelope.json, fs.write app:/data/vault, plus the general network grants (Grants and capabilities).
There is no master password: the vault opens with a Keychain key, because Argon2id needs WASM (Current limits and known gaps).
Work that scales with the number of identities yields between items for the 100 ms turn budget.
Testing
Three layers cover the package: the Bun tests against the mock vault, three Contract tests, and the real vault compatibility suite against the repository's actual vault server and web UI.
In this section
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime