This guide shows you how to manage the lifecycle of a HyperAuth vault — locking and unlocking, checking status, backing up and restoring, and persisting state to durable storage.
Check vault status
status returns the current state of the vault without modifying it:
If you only need to check the lock state:
Lock the vault
Call lock to clear the decrypted key material from memory. The returned object includes the encrypted database bytes so you can persist them before discarding:
Unlock the vault
Pass the encrypted database bytes and the encryption key derived from the user’s passkey authentication:
The encryptionKey is a hex string derived during key generation. If you did not store it separately, re-derive it by calling authenticatePasskey and passing the result through the key derivation step in the vault.
Export the vault
exportVault produces an encrypted binary backup of the entire vault — all accounts, credentials, and DID documents — protected with a user-supplied password. Returns a Uint8Array.
If the vault is locked when you call exportVault, the operation throws a PluginCallError. Unlock first.
Import a vault backup
importVault restores a vault from a backup produced by exportVault. Provide the raw bytes and the password used during export:
If the password is wrong or the file is corrupt, result.success is false and result.error describes the failure.
Check for a persisted vault
If your client was created with createClient (which sets up the core bridge), you can check whether a vault has been previously persisted to durable storage:
This method requires the core bridge. It returns false if the client was constructed without it.
Snapshot the vault to IPFS
snapshotVault pins the current vault state to IPFS via the relay service and returns a CID:
The vault background worker persists on a schedule. To force an immediate write to durable storage:
Both snapshotVault and persistNow require the core bridge. They return error objects rather than throwing if the bridge is unavailable.
Backup and restore workflow
A complete backup/restore cycle: