API reference / @evolu/common / Evolu/Owner
Evolu/Owner
TODO:
Interfaces
Interface | Description |
---|---|
AppOwner | The root owner of an Evolu app, created from a mnemonic safely generated on a device when the app is initialized or restored on another device using an existing mnemonic. It manages the app's core data, including the storage of other owners' mnemonics in an encrypted app table. Its writeKey is deterministic and rotatable. Never share the AppOwner mnemonic with anyone. |
Owner | Owner is an entity in Evolu that owns data, meaning it is locally stored on a device under the user’s control. Data can be personal private, peer-to-peer shared, or aggregated from multiple owners. |
OwnerWithWriteAccess | - |
ShardOwner | Used to shard data within an app for partial or deferred sync. Created in the Evolu initialData function or dynamically as needed. Its mnemonic is stored in an app table (encrypted by AppOwner ) and synced between devices. Its writeKey is deterministic and rotatable, enabling selective syncing of data subsets. Not intended for sharing outside the app. |
SharedOwner | Used to share data among one or more users, enabling collaboration or controlled access. Its writeKey is random (not derived from the mnemonic, stored alongside it in the app table) and rotatable, ensuring it cannot be regenerated by others if shared. Share the mnemonic alone for read-only access (as SharedReadonlyOwner ) or share SharedOwner itself for write access. |
SharedReadonlyOwner | Used for sharing data that can only be read, such as with followers or peers in a read-only sync scenario. It lacks a writeKey , containing only the mnemonic from which id and encryptionKey are derived by Evolu. Typically derived from a SharedOwner by sharing its mnemonic without the writeKey . |
Type Aliases
Type Alias | Description |
---|---|
OwnerId | - |
OwnerRow | An OwnerRow represents a row in the evolu_owner table, based on an Owner with an added timestamp (TimestampString) for CRDT sync. It supports all Owner variants with an optional writeKey ; use createOwnerRow to align it with a specific Owner. |
WriteKey | - |
Variables
Variable | Description |
---|---|
OwnerId | The unique identifier of Owner derived from the Mnemonic. |
WriteKey | A secure token proving the initiator can write changes. Derived from a mnemonic or randomly generated. It's rotatable. |
writeKeyLength | - |
Functions
Function | Description |
---|---|
createAppOwner | Creates an AppOwner, optionally from an existing mnemonic to restore it on another device; otherwise, generates a new mnemonic. |
createOwner | Creates an Owner with optional mnemonic and writeKey . |
createOwnerRow | Creates an OwnerRow from any Owner variant for the evolu_owner table, adding a timestamp (TimestampString) for CRDT sync. |
createShardOwner | Creates a ShardOwner for sharding app data with a freshly generated mnemonic. Unlike createAppOwner, it doesn’t accept an existing mnemonic because ShardOwner mnemonics are always generated and restored automatically via database sync. |
createSharedOwner | Creates a fresh SharedOwner for sharing data with write access. Takes no arguments as both mnemonic and rotatable writeKey are newly generated; when shared, recipients use the provided mnemonic and writeKey directly as a SharedOwner without needing to recreate it. |
createSharedReadonlyOwner | Creates a SharedReadonlyOwner from a SharedOwner for read-only data sharing. Extracts the mnemonic from the provided SharedOwner, omitting its writeKey to ensure read-only access. |
createWriteKey | - |
rotateWriteKey | Rotates the WriteKey for an AppOwner, ShardOwner, or SharedOwner, returning a new instance with the updated key. |