Offline
Keep working without the network, and catch up afterwards.
With offline: true, an Account keeps what this device needs to unlock and open vaults without the
network, and keeps edits made offline until they can be uploaded.
import { Account, isUnreachable } from "@openvireo/sdk";
const account = await Account.connect({ issuer, device: { name: "Web", platform: "web" }, storage: browserStorage(), offline: true,});await account.unlock(password); // works offline from the cached wrapped keysetconst vault = await account.openVault(id); // offline: the local copyaccount.offline; // true while the servers can't be reached
await vault.write("ov://Home/Wifi/password", "new").catch((e) => { if (!isUnreachable(e)) throw e; // offline: the edit is kept and merges in later});
const { vaults, dropped } = await account.reconnect(); // back online; revoked vaults are forgottenawait vault.sync(); // uploads the kept editWhat falls back
Section titled “What falls back”connect, unlock, listVaults and openVault use the cache when a server can’t be reached:
isUnreachable(e) is true, meaning no network or a 502, 503 or 504 from a gateway. Any other error,
such as a wrong password or a revoked session, still throws. account.offline and vault.offline say
which state you are in.
A vault that was never synced on this device can’t be opened offline (not_available_offline).
What is cached
Section titled “What is cached”Only what the servers store too, so the cache is no weaker than the server’s copy:
- the discovery document;
- the wrapped keyset and its KDF parameters;
- the vault list as the server returned it (encrypted names, sealed keys);
- per vault, the sync state, whose base copy is the server’s encrypted
.kdbx; - per vault, local edits not yet uploaded, as a
.kdbxencrypted with the vault key.
Unlocking offline still needs the master password and the Secret Key (kept on trusted devices). Signing out,
and a session the server revoked or refused, drop the whole cache. A session that ended by accident
(onSignedOut reports session_expired or token_reused) keeps each vault’s unsynced edits, still encrypted
with the vault key, and they merge in on the next sync after the same user signs in again. The vault list,
keyset, sync states and server copies go either way, and so does everything when a different user signs in. reconnect() drops vaults the account can no longer
open and returns their ids in dropped.