API reference@evolu/common › local‑first/Owner

Cryptographic identities that define ownership, encryption, sync, and deletion boundaries for Evolu data.

Every database change belongs to an Owner and is encrypted with its OwnerEncryptionKey. Owners also make sync selective: only the AppOwner is synced by default, while other owners can be synced when needed.

Individual changes in an append-only local-first history can only be marked as deleted. An entire owner, however, can be removed from devices and relays together with all of its data. The AppOwner must remain because it coordinates the deletion of other owners across devices.

Choose an owner by how its data should live and be shared:

  • AppOwner coordinates sync and persists for the lifetime of the app identity.
  • ShardOwner partitions application data so it can be synced and deleted independently.
  • SharedOwner grants collaborative read and write access.
  • SharedReadonlyOwner grants read-only access to shared data.

An OwnerSecret deterministically derives three independent values using SLIP-21:

Core

NameDescription
OwnerAn ReadonlyOwner with an OwnerWriteKey for authorizing writes.
OwnerErrorCommon interface implemented by all owner domain errors.
OwnerUsageStorage usage and timestamp bounds for an Owner.
ReadonlyOwnerOwner without a OwnerWriteKey.
OwnerEncryptionKeySymmetric encryption key for Owner data protection.
OwnerIdA branded Id that uniquely identifies an Owner.
OwnerIdBytesBinary representation of OwnerId.
OwnerSecret32 bytes of cryptographic entropy used to derive Owner keys.
OwnerWriteKeyA token that authorizes write operations for an Owner.
OwnerEncryptionKeySymmetric encryption key for Owner data protection.
OwnerIdA branded Id that uniquely identifies an Owner.
OwnerIdBytesBinary representation of OwnerId.
OwnerSecret32 bytes of cryptographic entropy used to derive Owner keys.
OwnerWriteKeyA token that authorizes write operations for an Owner.
ownerWriteKeyLengthLength of an OwnerWriteKey in bytes.
createOwnerSecretCreates a cryptographically random OwnerSecret.
createOwnerWriteKeyCreates a random OwnerWriteKey for rotating write access.
mnemonicToOwnerSecretConverts a Mnemonic to an OwnerSecret.
ownerIdBytesToOwnerIdConverts OwnerIdBytes to OwnerId.
ownerIdToOwnerIdBytesConverts OwnerId to OwnerIdBytes.
ownerSecretToMnemonicConverts an OwnerSecret to a Mnemonic.

Variants

NameDescription
AppOwnerThe AppOwner represents the application owner. It's created using a cryptographically secure random generator or derived from an external source, e.g., mnemonic stored securely in a hardware device.
DeviceAppOwnerAn AppOwner for encrypting device-only data.
ShardOwnerAn Owner for sharding data.
SharedOwnerAn Owner for collaborative data with write access.
SharedReadonlyOwnerRead-only version of a SharedOwner for data sharing. Contains only the OwnerId and EncryptionKey needed for others to read the shared data without write access.
createAppOwnerCreates an AppOwner from an OwnerSecret.
createShardOwnerCreates a ShardOwner from an OwnerSecret.
createSharedOwnerCreates a SharedOwner from an OwnerSecret for collaborative write access.
createSharedReadonlyOwnerCreates a SharedReadonlyOwner from a SharedOwner.
deriveShardOwnerDerives a ShardOwner from an AppOwner using the specified path.

Transport

NameDescription
OwnerWebSocketTransportWebSocket transport configuration.
SyncOwnerAn ReadonlyOwner or Owner with non-empty OwnerTransports so it can be synced.
OwnerTransportTransport configuration for connecting to relays.
createOwnerWebSocketTransportCreates an OwnerWebSocketTransport for the given relay URL and OwnerId.
parseOwnerIdFromOwnerWebSocketTransportUrlExtracts OwnerId from an OwnerWebSocketTransport URL query string.

Testing

VariableDescription
testAppOwnerDeterministic AppOwner for tests.
testOwnerSecretDeterministic OwnerSecret for tests.