@evolu/common 6.0.1-preview.8 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/README.md +2 -2
  2. package/dist/src/Array.d.ts +256 -12
  3. package/dist/src/Array.d.ts.map +1 -1
  4. package/dist/src/Array.js +215 -9
  5. package/dist/src/Assert.d.ts +0 -13
  6. package/dist/src/Assert.d.ts.map +1 -1
  7. package/dist/src/Assert.js +0 -15
  8. package/dist/src/Brand.d.ts +75 -0
  9. package/dist/src/Brand.d.ts.map +1 -0
  10. package/dist/src/Brand.js +1 -0
  11. package/dist/src/Buffer.d.ts +1 -1
  12. package/dist/src/Buffer.d.ts.map +1 -1
  13. package/dist/src/Buffer.js +8 -7
  14. package/dist/src/Cache.d.ts +44 -0
  15. package/dist/src/Cache.d.ts.map +1 -0
  16. package/dist/src/Cache.js +52 -0
  17. package/dist/src/Callbacks.d.ts +45 -12
  18. package/dist/src/Callbacks.d.ts.map +1 -1
  19. package/dist/src/Callbacks.js +14 -7
  20. package/dist/src/Console.d.ts +31 -6
  21. package/dist/src/Console.d.ts.map +1 -1
  22. package/dist/src/Console.js +72 -9
  23. package/dist/src/Crypto.d.ts +56 -42
  24. package/dist/src/Crypto.d.ts.map +1 -1
  25. package/dist/src/Crypto.js +40 -53
  26. package/dist/src/Evolu/Db.d.ts +162 -74
  27. package/dist/src/Evolu/Db.d.ts.map +1 -1
  28. package/dist/src/Evolu/Db.js +284 -702
  29. package/dist/src/Evolu/Diff.d.ts +3 -3
  30. package/dist/src/Evolu/Diff.d.ts.map +1 -1
  31. package/dist/src/Evolu/Diff.js +7 -5
  32. package/dist/src/Evolu/Evolu.d.ts +214 -134
  33. package/dist/src/Evolu/Evolu.d.ts.map +1 -1
  34. package/dist/src/Evolu/Evolu.js +189 -180
  35. package/dist/src/Evolu/Internal.d.ts +0 -2
  36. package/dist/src/Evolu/Internal.d.ts.map +1 -1
  37. package/dist/src/Evolu/Internal.js +0 -2
  38. package/dist/src/Evolu/LocalAuth.d.ts +150 -0
  39. package/dist/src/Evolu/LocalAuth.d.ts.map +1 -0
  40. package/dist/src/Evolu/LocalAuth.js +174 -0
  41. package/dist/src/Evolu/Owner.d.ts +273 -120
  42. package/dist/src/Evolu/Owner.d.ts.map +1 -1
  43. package/dist/src/Evolu/Owner.js +130 -104
  44. package/dist/src/Evolu/Platform.d.ts +9 -7
  45. package/dist/src/Evolu/Platform.d.ts.map +1 -1
  46. package/dist/src/Evolu/Protocol.d.ts +268 -240
  47. package/dist/src/Evolu/Protocol.d.ts.map +1 -1
  48. package/dist/src/Evolu/Protocol.js +600 -454
  49. package/dist/src/Evolu/Public.d.ts +6 -8
  50. package/dist/src/Evolu/Public.d.ts.map +1 -1
  51. package/dist/src/Evolu/Public.js +2 -3
  52. package/dist/src/Evolu/PublicKysely.d.ts.map +1 -1
  53. package/dist/src/Evolu/PublicKysely.js +3 -4
  54. package/dist/src/Evolu/Query.d.ts +2 -1
  55. package/dist/src/Evolu/Query.d.ts.map +1 -1
  56. package/dist/src/Evolu/Query.js +1 -1
  57. package/dist/src/Evolu/Relay.d.ts +91 -8
  58. package/dist/src/Evolu/Relay.d.ts.map +1 -1
  59. package/dist/src/Evolu/Relay.js +214 -88
  60. package/dist/src/Evolu/Schema.d.ts +125 -47
  61. package/dist/src/Evolu/Schema.d.ts.map +1 -1
  62. package/dist/src/Evolu/Schema.js +175 -31
  63. package/dist/src/Evolu/Storage.d.ts +249 -27
  64. package/dist/src/Evolu/Storage.d.ts.map +1 -1
  65. package/dist/src/Evolu/Storage.js +198 -92
  66. package/dist/src/Evolu/Sync.d.ts +68 -13
  67. package/dist/src/Evolu/Sync.d.ts.map +1 -1
  68. package/dist/src/Evolu/Sync.js +469 -20
  69. package/dist/src/Evolu/Timestamp.d.ts +83 -30
  70. package/dist/src/Evolu/Timestamp.d.ts.map +1 -1
  71. package/dist/src/Evolu/Timestamp.js +79 -34
  72. package/dist/src/Identicon.d.ts +35 -0
  73. package/dist/src/Identicon.d.ts.map +1 -0
  74. package/dist/src/Identicon.js +143 -0
  75. package/dist/src/Instances.d.ts +34 -0
  76. package/dist/src/Instances.d.ts.map +1 -0
  77. package/dist/src/Instances.js +44 -0
  78. package/dist/src/Number.d.ts +4 -3
  79. package/dist/src/Number.d.ts.map +1 -1
  80. package/dist/src/Number.js +5 -4
  81. package/dist/src/Object.d.ts +10 -4
  82. package/dist/src/Object.d.ts.map +1 -1
  83. package/dist/src/Object.js +9 -3
  84. package/dist/src/Platform.d.ts +20 -0
  85. package/dist/src/Platform.d.ts.map +1 -0
  86. package/dist/src/Platform.js +22 -0
  87. package/dist/src/Random.d.ts +3 -2
  88. package/dist/src/Random.d.ts.map +1 -1
  89. package/dist/src/Relation.d.ts +79 -0
  90. package/dist/src/Relation.d.ts.map +1 -0
  91. package/dist/src/Relation.js +127 -0
  92. package/dist/src/Resources.d.ts +118 -0
  93. package/dist/src/Resources.d.ts.map +1 -0
  94. package/dist/src/Resources.js +197 -0
  95. package/dist/src/Result.d.ts +184 -52
  96. package/dist/src/Result.d.ts.map +1 -1
  97. package/dist/src/Result.js +30 -241
  98. package/dist/src/Skiplist.js +2 -1
  99. package/dist/src/Sqlite.d.ts +89 -5
  100. package/dist/src/Sqlite.d.ts.map +1 -1
  101. package/dist/src/Sqlite.js +136 -9
  102. package/dist/src/Task.d.ts +586 -0
  103. package/dist/src/Task.d.ts.map +1 -0
  104. package/dist/src/Task.js +469 -0
  105. package/dist/src/Time.d.ts +66 -1
  106. package/dist/src/Time.d.ts.map +1 -1
  107. package/dist/src/Time.js +99 -5
  108. package/dist/src/Type.d.ts +676 -343
  109. package/dist/src/Type.d.ts.map +1 -1
  110. package/dist/src/Type.js +718 -467
  111. package/dist/src/Types.d.ts +1 -75
  112. package/dist/src/Types.d.ts.map +1 -1
  113. package/dist/src/WebSocket.d.ts +5 -2
  114. package/dist/src/WebSocket.d.ts.map +1 -1
  115. package/dist/src/WebSocket.js +12 -18
  116. package/dist/src/Worker.d.ts +39 -11
  117. package/dist/src/Worker.d.ts.map +1 -1
  118. package/dist/src/Worker.js +22 -4
  119. package/dist/src/index.d.ts +8 -3
  120. package/dist/src/index.d.ts.map +1 -1
  121. package/dist/src/index.js +8 -3
  122. package/package.json +15 -14
  123. package/src/Array.ts +301 -19
  124. package/src/Assert.ts +0 -21
  125. package/src/Brand.ts +75 -0
  126. package/src/Buffer.ts +7 -7
  127. package/src/Cache.ts +85 -0
  128. package/src/Callbacks.ts +62 -22
  129. package/src/Console.ts +91 -11
  130. package/src/Crypto.ts +94 -90
  131. package/src/Evolu/Db.ts +519 -1026
  132. package/src/Evolu/Diff.ts +7 -5
  133. package/src/Evolu/Evolu.ts +477 -361
  134. package/src/Evolu/Internal.ts +0 -2
  135. package/src/Evolu/LocalAuth.ts +463 -0
  136. package/src/Evolu/Owner.ts +355 -228
  137. package/src/Evolu/Platform.ts +9 -9
  138. package/src/Evolu/Protocol.ts +842 -742
  139. package/src/Evolu/Public.ts +7 -14
  140. package/src/Evolu/PublicKysely.ts +4 -5
  141. package/src/Evolu/Query.ts +3 -2
  142. package/src/Evolu/Relay.ts +406 -103
  143. package/src/Evolu/Schema.ts +323 -91
  144. package/src/Evolu/Storage.ts +559 -137
  145. package/src/Evolu/Sync.ts +819 -36
  146. package/src/Evolu/Timestamp.ts +90 -58
  147. package/src/Identicon.ts +197 -0
  148. package/src/Instances.ts +90 -0
  149. package/src/Number.ts +6 -10
  150. package/src/Object.ts +13 -5
  151. package/src/Platform.ts +26 -0
  152. package/src/Random.ts +3 -2
  153. package/src/Relation.ts +234 -0
  154. package/src/Resources.ts +367 -0
  155. package/src/Result.ts +191 -54
  156. package/src/Skiplist.ts +1 -1
  157. package/src/Sqlite.ts +152 -17
  158. package/src/Task.ts +901 -0
  159. package/src/Time.ts +180 -5
  160. package/src/Type.ts +1135 -730
  161. package/src/Types.ts +1 -77
  162. package/src/WebSocket.ts +27 -25
  163. package/src/Worker.ts +72 -23
  164. package/src/index.ts +8 -3
  165. package/dist/src/Evolu/Config.d.ts +0 -69
  166. package/dist/src/Evolu/Config.d.ts.map +0 -1
  167. package/dist/src/Evolu/Config.js +0 -9
  168. package/dist/src/Evolu/Kysely.d.ts +0 -6
  169. package/dist/src/Evolu/Kysely.d.ts.map +0 -1
  170. package/dist/src/Evolu/Kysely.js +0 -21
  171. package/dist/src/ManyToManyMap.d.ts +0 -26
  172. package/dist/src/ManyToManyMap.d.ts.map +0 -1
  173. package/dist/src/ManyToManyMap.js +0 -92
  174. package/dist/src/NanoId.d.ts +0 -27
  175. package/dist/src/NanoId.d.ts.map +0 -1
  176. package/dist/src/NanoId.js +0 -6
  177. package/dist/src/Promise.d.ts +0 -180
  178. package/dist/src/Promise.d.ts.map +0 -1
  179. package/dist/src/Promise.js +0 -176
  180. package/src/Evolu/Config.ts +0 -83
  181. package/src/Evolu/Kysely.ts +0 -38
  182. package/src/ManyToManyMap.ts +0 -140
  183. package/src/NanoId.ts +0 -39
  184. package/src/Promise.ts +0 -295
@@ -1,160 +1,313 @@
1
+ import { NonEmptyReadonlyArray } from "../Array.js";
2
+ import { EncryptionKey, RandomBytesDep } from "../Crypto.js";
3
+ import { Mnemonic, NonNegativeInt } from "../Type.js";
4
+ import { TimestampBytes } from "./Timestamp.js";
1
5
  /**
2
- * TODO:
6
+ * The Owner represents ownership of data in Evolu. Every database change is
7
+ * assigned to an owner, enabling sync functionality and access control.
3
8
  *
4
- * @module
5
- */
6
- import { CreateMnemonicDep, CreateRandomBytesDep, EncryptionKey, MnemonicSeed } from "../Crypto.js";
7
- import { NanoIdLibDep } from "../NanoId.js";
8
- import { TimeDep } from "../Time.js";
9
- import { DateIsoString, Mnemonic, NonNegativeInt } from "../Type.js";
10
- import { TimestampString } from "./Timestamp.js";
11
- /**
12
- * `Owner` is an entity in Evolu that owns data, meaning it is locally stored on
13
- * a device under the user’s control. Data can be personal private, peer-to-peer
14
- * shared, or aggregated from multiple owners.
15
- *
16
- * An owner has a {@link Mnemonic} from which {@link OwnerId} and
17
- * {@link EncryptionKey} are deterministically derived using SLIP-21, and an
18
- * optional {@link WriteKey} that, when present, enables writing to the Evolu
19
- * Relay or peers. The {@link WriteKey} can be rotated.
20
- *
21
- * Variants include {@link AppOwner}, {@link ShardOwner}, {@link SharedOwner}, and
22
- * {@link SharedReadonlyOwner}, each with specific roles and properties detailed
23
- * in their respective definitions.
24
- *
25
- * Public-key cryptography isn’t included here as it belongs to app and varies
26
- * by use case. An Evolu app without collaboration doesn’t need it, while a
27
- * Nostr-like app can leverage Nostr NIPs, or a super-safe app can use
28
- * post-quantum cryptography.
9
+ * Owners enable **partial sync** - applications can choose which owners to
10
+ * sync, allowing selective data synchronization based on specific needs.
11
+ *
12
+ * Owners also provide **real data deletion** - while individual changes in
13
+ * local-first/distributed systems can only be marked as deleted, entire owners
14
+ * can be completely deleted from both relays and devices (except for
15
+ * {@link AppOwner}, which must be preserved for sync coordination).
16
+ *
17
+ * Evolu provides different owner types depending on their use case:
18
+ *
19
+ * - **Coordination**: {@link AppOwner} for sync coordination and long-term
20
+ * persistence
21
+ * - **Data partitioning**: {@link ShardOwner} for partitioning application data
22
+ * - **Collaboration**: {@link SharedOwner} for collaborative write access
23
+ * - **Data sharing**: {@link SharedReadonlyOwner} for read-only access to shared
24
+ * data
25
+ *
26
+ * Owners are cryptographically derived from an {@link OwnerSecret} using
27
+ * SLIP-21, ensuring secure and deterministic key generation:
28
+ *
29
+ * - {@link OwnerId}: Globally unique public identifier
30
+ * - {@link EncryptionKey}: Symmetric encryption key for data protection
31
+ * - {@link OwnerWriteKey}: Authentication token for write operations (rotatable)
32
+ *
33
+ * @see {@link createOwner}
29
34
  */
30
35
  export interface Owner {
31
- readonly mnemonic: Mnemonic;
32
- readonly createdAt: DateIsoString;
33
36
  readonly id: OwnerId;
34
- readonly encryptionKey: EncryptionKey;
35
- readonly writeKey: WriteKey;
36
- }
37
- export interface OwnerWithWriteAccess {
38
- readonly id: OwnerId;
39
- readonly encryptionKey: EncryptionKey;
40
- readonly writeKey: WriteKey;
37
+ readonly encryptionKey: OwnerEncryptionKey;
38
+ readonly writeKey: OwnerWriteKey;
41
39
  }
42
40
  /**
43
- * The unique identifier of {@link Owner} derived from the {@link Mnemonic}.
44
- *
45
- * This branded {@link Id} type, generated by {@link createSlip21Id}, is a
46
- * 21-character {@link Base64Url} string (126 bits of entropy), providing a
47
- * compact, shareable, and secure identifier for UI use, tied to the owner's
48
- * mnemonic and derivation path.
41
+ * OwnerId is a branded {@link Id} that uniquely identifies an {@link Owner}.
42
+ * Branded from {@link Id} to leverage existing helpers like {@link idToIdBytes}.
49
43
  */
50
- export declare const OwnerId: import("../Type.js").BrandType<import("../Type.js").BrandType<import("../Type.js").Type<"String", string, string, import("../Type.js").StringError, string, import("../Type.js").StringError>, "Id", import("../Type.js").RegexError<"Id">, import("../Type.js").StringError>, "OwnerId", import("../Type.js").BrandWithoutRefineError<"OwnerId", import("../Type.js").StringError | import("../Type.js").RegexError<"Id">>, never>;
44
+ export declare const OwnerId: import("../Type.js").BrandType<import("../Type.js").BrandType<import("../Type.js").Type<"String", string, string, import("../Type.js").StringError, string, import("../Type.js").StringError>, "Id", import("../Type.js").IdError, import("../Type.js").StringError>, "OwnerId", import("../Type.js").BrandWithoutRefineError<"OwnerId", import("../Type.js").StringError | import("../Type.js").IdError>, never>;
51
45
  export type OwnerId = typeof OwnerId.Type;
52
- export declare const writeKeyLength: NonNegativeInt;
46
+ /** Bytes representation of {@link OwnerId}. */
47
+ export declare const OwnerIdBytes: import("../Type.js").BrandType<import("../Type.js").BrandType<import("../Type.js").BrandType<import("../Type.js").Type<"Uint8Array", Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>, import("../Type.js").Uint8ArrayError, Uint8Array<ArrayBufferLike>, import("../Type.js").Uint8ArrayError>, "Length16", import("../Type.js").LengthError<16>, import("../Type.js").Uint8ArrayError>, "IdBytes", import("../Type.js").BrandWithoutRefineError<"IdBytes", import("../Type.js").LengthError<16> | import("../Type.js").Uint8ArrayError>, never>, "OwnerIdBytes", import("../Type.js").BrandWithoutRefineError<"OwnerIdBytes", import("../Type.js").BrandWithoutRefineError<"IdBytes", import("../Type.js").LengthError<16> | import("../Type.js").Uint8ArrayError>>, never>;
48
+ export type OwnerIdBytes = typeof OwnerIdBytes.Type;
49
+ export declare const ownerIdToOwnerIdBytes: (ownerId: OwnerId) => OwnerIdBytes;
50
+ export declare const ownerIdBytesToOwnerId: (ownerIdBytes: OwnerIdBytes) => OwnerId;
51
+ export declare const ownerWriteKeyLength: number & import("../Brand.js").Brand<"Int"> & import("../Brand.js").Brand<"NonNegative">;
52
+ export declare const OwnerEncryptionKey: import("../Type.js").BrandType<import("../Type.js").BrandType<import("../Type.js").BrandType<import("../Type.js").Type<"Brand", Uint8Array<ArrayBufferLike> & import("../Brand.js").Brand<"Entropy">, Uint8Array<ArrayBufferLike>, import("../Type.js").BrandWithoutRefineError<"Entropy", import("../Type.js").Uint8ArrayError>, Uint8Array<ArrayBufferLike>, never>, "Length32", import("../Type.js").LengthError<32>, import("../Type.js").BrandWithoutRefineError<"Entropy", import("../Type.js").Uint8ArrayError>>, "EncryptionKey", import("../Type.js").BrandWithoutRefineError<"EncryptionKey", import("../Type.js").BrandWithoutRefineError<"Entropy", import("../Type.js").Uint8ArrayError> | import("../Type.js").LengthError<32>>, never>, "OwnerEncryptionKey", import("../Type.js").BrandWithoutRefineError<"OwnerEncryptionKey", import("../Type.js").BrandWithoutRefineError<"EncryptionKey", import("../Type.js").BrandWithoutRefineError<"Entropy", import("../Type.js").Uint8ArrayError> | import("../Type.js").LengthError<32>>>, never>;
53
+ export type OwnerEncryptionKey = typeof OwnerEncryptionKey.Type;
53
54
  /**
54
- * A secure token proving the initiator can write changes. Derived from a
55
- * mnemonic or randomly generated. It's rotatable.
55
+ * A secure token for write operations. It's derived from {@link OwnerSecret} by
56
+ * default and can be rotated via {@link createOwnerWriteKey}.
56
57
  */
57
- export declare const WriteKey: import("../Type.js").BrandType<import("../Type.js").BrandType<import("../Type.js").Type<"Uint8Array", Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>, import("../Type.js").Uint8ArrayError, Uint8Array<ArrayBufferLike>, import("../Type.js").Uint8ArrayError>, `Length${number & import("../Types.js").Brand<"Int"> & import("../Types.js").Brand<"NonNegative">}`, import("../Type.js").LengthError<number & import("../Types.js").Brand<"Int"> & import("../Types.js").Brand<"NonNegative">>, import("../Type.js").Uint8ArrayError>, "WriteKey", import("../Type.js").BrandWithoutRefineError<"WriteKey", import("../Type.js").Uint8ArrayError | import("../Type.js").LengthError<number & import("../Types.js").Brand<"Int"> & import("../Types.js").Brand<"NonNegative">>>, never>;
58
- export type WriteKey = typeof WriteKey.Type;
58
+ export declare const OwnerWriteKey: import("../Type.js").BrandType<import("../Type.js").BrandType<import("../Type.js").Type<"Brand", Uint8Array<ArrayBufferLike> & import("../Brand.js").Brand<"Entropy">, Uint8Array<ArrayBufferLike>, import("../Type.js").BrandWithoutRefineError<"Entropy", import("../Type.js").Uint8ArrayError>, Uint8Array<ArrayBufferLike>, never>, "Length16", import("../Type.js").LengthError<16>, import("../Type.js").BrandWithoutRefineError<"Entropy", import("../Type.js").Uint8ArrayError>>, "OwnerWriteKey", import("../Type.js").BrandWithoutRefineError<"OwnerWriteKey", import("../Type.js").LengthError<16> | import("../Type.js").BrandWithoutRefineError<"Entropy", import("../Type.js").Uint8ArrayError>>, never>;
59
+ export type OwnerWriteKey = typeof OwnerWriteKey.Type;
59
60
  /**
60
- * The root owner of an Evolu app, created from a mnemonic safely generated on a
61
- * device when the app is initialized or restored on another device using an
62
- * existing mnemonic. It manages the app's core data, including the storage of
63
- * other owners' mnemonics in an encrypted app table. Its `writeKey` is
64
- * deterministic and rotatable. Never share the AppOwner mnemonic with anyone.
61
+ * 32 bytes of cryptographic entropy used to derive {@link Owner} keys.
62
+ *
63
+ * Can be created using {@link createOwnerSecret} or converted from a
64
+ * {@link Mnemonic} using {@link mnemonicToOwnerSecret}.
65
+ */
66
+ export declare const OwnerSecret: import("../Type.js").BrandType<import("../Type.js").BrandType<import("../Type.js").Type<"Brand", Uint8Array<ArrayBufferLike> & import("../Brand.js").Brand<"Entropy">, Uint8Array<ArrayBufferLike>, import("../Type.js").BrandWithoutRefineError<"Entropy", import("../Type.js").Uint8ArrayError>, Uint8Array<ArrayBufferLike>, never>, "Length32", import("../Type.js").LengthError<32>, import("../Type.js").BrandWithoutRefineError<"Entropy", import("../Type.js").Uint8ArrayError>>, "OwnerSecret", import("../Type.js").BrandWithoutRefineError<"OwnerSecret", import("../Type.js").BrandWithoutRefineError<"Entropy", import("../Type.js").Uint8ArrayError> | import("../Type.js").LengthError<32>>, never>;
67
+ export type OwnerSecret = typeof OwnerSecret.Type;
68
+ /** Creates a {@link OwnerSecret}. */
69
+ export declare const createOwnerSecret: (deps: RandomBytesDep) => OwnerSecret;
70
+ /** Converts an {@link OwnerSecret} to a {@link Mnemonic}. */
71
+ export declare const ownerSecretToMnemonic: (secret: OwnerSecret) => Mnemonic;
72
+ /** Converts a {@link Mnemonic} to an {@link OwnerSecret}. */
73
+ export declare const mnemonicToOwnerSecret: (mnemonic: Mnemonic) => OwnerSecret;
74
+ /** Creates a randomly generated {@link OwnerWriteKey}. */
75
+ export declare const createOwnerWriteKey: (deps: RandomBytesDep) => OwnerWriteKey;
76
+ /**
77
+ * Creates an {@link Owner} from a {@link OwnerSecret} using SLIP-21 key
78
+ * derivation.
79
+ *
80
+ * This is an internal helper function, use:
81
+ *
82
+ * - {@link createAppOwner}
83
+ * - {@link createShardOwner}
84
+ * - {@link createSharedOwner}
85
+ * - {@link createSharedReadonlyOwner}
86
+ */
87
+ export declare const createOwner: (secret: OwnerSecret) => Owner;
88
+ /**
89
+ * The AppOwner represents the application owner. It's created using a
90
+ * cryptographically secure random generator or derived from an external source,
91
+ * e.g., mnemonic stored securely in a hardware device.
92
+ *
93
+ * While it's possible to store all application data in AppOwner, the better
94
+ * approach is to use it only for sync coordination. Storing all app data in
95
+ * AppOwner means that data will be stored/synced forever. And that's a problem
96
+ * if we want to provide real data deletion or in-app data migration without
97
+ * data duplication. In local-first apps/distributed systems, we can't delete
98
+ * individual changes, we only mark them as deleted, otherwise sync could not
99
+ * work.
100
+ *
101
+ * If we really want to delete data or at least avoid syncing it, we must store
102
+ * it using a different owner than AppOwner, e.g. {@link ShardOwner} or
103
+ * {@link SharedOwner}, and delete that owner. The AppOwner itself must be
104
+ * preserved because it coordinates deletion information across devices. Other
105
+ * devices need to sync the information that an owner was deleted so they can
106
+ * delete their local data as well.
107
+ *
108
+ * ### Privacy Considerations
109
+ *
110
+ * AppOwner must never be shared with anyone, except for its {@link OwnerId},
111
+ * which can be used for authorization with
112
+ * {@link createOwnerWebSocketTransport}. It's safe because OwnerId is
113
+ * pseudonymous (it can't be assigned to a specific person).
114
+ *
115
+ * For data sharing scenarios, use {@link SharedOwner} and
116
+ * {@link SharedReadonlyOwner} instead, which are designed specifically for
117
+ * collaborative access.
65
118
  */
66
119
  export interface AppOwner extends Owner {
67
120
  readonly type: "AppOwner";
121
+ /**
122
+ * The mnemonic that was used to derive the AppOwner keys. Optional when the
123
+ * AppOwner is created from external keys to avoid sharing the mnemonic with
124
+ * the Evolu app.
125
+ */
126
+ readonly mnemonic?: Mnemonic | null;
68
127
  }
128
+ /** Creates an {@link AppOwner} from an {@link OwnerSecret}. */
129
+ export declare const createAppOwner: (secret: OwnerSecret) => AppOwner;
69
130
  /**
70
- * Used to shard data within an app for partial or deferred sync. Created in the
71
- * Evolu `initialData` function or dynamically as needed. Its mnemonic is stored
72
- * in an app table (encrypted by `AppOwner`) and synced between devices. Its
73
- * `writeKey` is deterministic and rotatable, enabling selective syncing of data
74
- * subsets. Not intended for sharing outside the app.
75
- *
76
- * This type omits `id`, `encryptionKey`, and `createdAt` as they are derived by
77
- * Evolu from the `mnemonic`, reducing storage overhead.
131
+ * An {@link Owner} for sharding data.
132
+ *
133
+ * ShardOwners are the recommended storage location for most application data
134
+ * because they can be completely deleted (both on relays and devices) and
135
+ * conditionally synced.
136
+ *
137
+ * Can be created from {@link OwnerSecret} via {@link createShardOwner} or
138
+ * deterministically derived from {@link AppOwner} using
139
+ * {@link deriveShardOwner}.
78
140
  */
79
- export interface ShardOwner {
141
+ export interface ShardOwner extends Owner {
80
142
  readonly type: "ShardOwner";
81
- readonly mnemonic: Mnemonic;
82
- readonly writeKey: WriteKey;
143
+ readonly transports?: ReadonlyArray<OwnerTransport>;
83
144
  }
145
+ /** Creates a {@link ShardOwner} from an {@link OwnerSecret}. */
146
+ export declare const createShardOwner: (secret: OwnerSecret, transports?: ReadonlyArray<OwnerTransport>) => ShardOwner;
84
147
  /**
85
- * Used to share data among one or more users, enabling collaboration or
86
- * controlled access. Its `writeKey` is random (not derived from the mnemonic,
87
- * stored alongside it in the app table) and rotatable, ensuring it cannot be
88
- * regenerated by others if shared. Share the `mnemonic` alone for read-only
89
- * access (as `SharedReadonlyOwner`) or share SharedOwner itself for write
90
- * access.
91
- *
92
- * This type omits `id`, `encryptionKey`, and `createdAt` as they are derived by
93
- * Evolu from the `mnemonic`, reducing storage overhead.
148
+ * Derives a {@link ShardOwner} from an {@link AppOwner} using the specified path.
149
+ *
150
+ * **Advantages of derived owners:**
151
+ *
152
+ * - **Deterministic**: Same path always produces the same ShardOwner across all
153
+ * devices
154
+ * - **Immediate availability**: Can be hardcoded and used before sync occurs
155
+ * - **Consistent setup**: All devices start with identical data structure
156
+ * - **Lifecycle management**: Can implement epoch patterns for clean data
157
+ * deletion and recreation
158
+ *
159
+ * **Common patterns:**
160
+ *
161
+ * - Use paths like `["shard", 1]` for versioned data lifecycle
162
+ * - Use paths like `["project", "MyApp", 1]` for named partitions with versions
163
+ * - Each device can derive the same owners and set up initial structure
94
164
  */
95
- export interface SharedOwner {
165
+ export declare const deriveShardOwner: (owner: AppOwner, path: NonEmptyReadonlyArray<string | number>, transports?: ReadonlyArray<OwnerTransport>) => ShardOwner;
166
+ /** An {@link Owner} for collaborative data with write access. */
167
+ export interface SharedOwner extends Owner {
96
168
  readonly type: "SharedOwner";
97
- readonly mnemonic: Mnemonic;
98
- readonly writeKey: WriteKey;
169
+ readonly transports?: ReadonlyArray<OwnerTransport>;
99
170
  }
100
171
  /**
101
- * Used for sharing data that can only be read, such as with followers or peers
102
- * in a read-only sync scenario. It lacks a `writeKey`, containing only the
103
- * `mnemonic` from which `id` and `encryptionKey` are derived by Evolu.
104
- * Typically derived from a `SharedOwner` by sharing its `mnemonic` without the
105
- * `writeKey`.
172
+ * Creates a {@link SharedOwner} from an {@link OwnerSecret} for collaborative
173
+ * write access.
174
+ *
175
+ * Use {@link createSharedReadonlyOwner} to create a read-only version for
176
+ * sharing.
177
+ */
178
+ export declare const createSharedOwner: (secret: OwnerSecret, transports?: ReadonlyArray<OwnerTransport>) => SharedOwner;
179
+ /**
180
+ * Read-only version of a {@link SharedOwner} for data sharing. Contains only the
181
+ * {@link OwnerId} and {@link EncryptionKey} needed for others to read the shared
182
+ * data without write access.
106
183
  */
107
184
  export interface SharedReadonlyOwner {
108
185
  readonly type: "SharedReadonlyOwner";
109
- readonly mnemonic: Mnemonic;
186
+ readonly id: OwnerId;
187
+ readonly encryptionKey: EncryptionKey;
188
+ readonly transports?: ReadonlyArray<OwnerTransport>;
110
189
  }
190
+ /** Creates a {@link SharedReadonlyOwner} from a {@link SharedOwner}. */
191
+ export declare const createSharedReadonlyOwner: (sharedOwner: SharedOwner) => SharedReadonlyOwner;
111
192
  /**
112
- * Creates an {@link AppOwner}, optionally from an existing mnemonic to restore
113
- * it on another device; otherwise, generates a new mnemonic.
114
- */
115
- export declare const createAppOwner: (deps: TimeDep & CreateRandomBytesDep & CreateMnemonicDep) => (mnemonic?: string & import("../Types.js").Brand<"Trimmed"> & import("../Types.js").Brand<"MinLength1"> & import("../Types.js").Brand<"Mnemonic">) => AppOwner;
116
- /**
117
- * Creates a {@link ShardOwner} for sharding app data with a freshly generated
118
- * mnemonic. Unlike {@link createAppOwner}, it doesn’t accept an existing
119
- * mnemonic because ShardOwner mnemonics are always generated and restored
120
- * automatically via database sync.
121
- */
122
- export declare const createShardOwner: (deps: TimeDep & CreateRandomBytesDep & CreateMnemonicDep) => ShardOwner;
123
- /**
124
- * Creates a fresh {@link SharedOwner} for sharing data with write access. Takes
125
- * no arguments as both `mnemonic` and rotatable `writeKey` are newly generated;
126
- * when shared, recipients use the provided `mnemonic` and `writeKey` directly
127
- * as a {@link SharedOwner} without needing to recreate it.
193
+ * Transport configuration for connecting to relays.
194
+ *
195
+ * Currently only WebSocket, in the future Bluetooth, LocalNetwork, etc.
128
196
  */
129
- export declare const createSharedOwner: (deps: CreateRandomBytesDep & CreateMnemonicDep) => SharedOwner;
197
+ export type OwnerTransport = OwnerWebSocketTransport;
130
198
  /**
131
- * Creates a {@link SharedReadonlyOwner} from a {@link SharedOwner} for read-only
132
- * data sharing. Extracts the `mnemonic` from the provided {@link SharedOwner},
133
- * omitting its `writeKey` to ensure read-only access.
199
+ * WebSocket transport configuration.
200
+ *
201
+ * ### Authentication via URL
202
+ *
203
+ * The {@link OwnerId} is passed as a URL query parameter. While this approach is
204
+ * generally discouraged for authentication tokens (they get logged), it's safe
205
+ * here because OwnerId is pseudonymous and used only for access verification -
206
+ * it provides no ability to read encrypted data or write changes.
207
+ *
208
+ * See: [HTTP headers in Websockets client
209
+ * API](https://stackoverflow.com/questions/4361173/http-headers-in-websockets-client-api/74564827#74564827)
210
+ *
211
+ * ### Error Handling
212
+ *
213
+ * When a relay rejects a connection (invalid OwnerId, unauthorized owner, or
214
+ * server error), the browser WebSocket API does not expose the specific HTTP
215
+ * status code or reason - it only reports a generic connection failure. The
216
+ * client automatically retries with exponential backoff and jitter, eventually
217
+ * succeeding once the configuration or server issue is resolved.
218
+ *
219
+ * Legitimate clients will be properly configured with valid credentials, so
220
+ * automatic retry is OK.
221
+ *
222
+ * @see {@link createOwnerWebSocketTransport}
223
+ * @see {@link parseOwnerIdFromOwnerWebSocketTransportUrl}
134
224
  */
135
- export declare const createSharedReadonlyOwner: (sharedOwner: SharedOwner) => SharedReadonlyOwner;
136
- /** Creates an {@link Owner} with optional `mnemonic` and `writeKey`. */
137
- export declare const createOwner: (deps: TimeDep & CreateRandomBytesDep & CreateMnemonicDep) => (mnemonic?: string & import("../Types.js").Brand<"Trimmed"> & import("../Types.js").Brand<"MinLength1"> & import("../Types.js").Brand<"Mnemonic">, writeKey?: WriteKey) => Owner;
138
- export declare const createWriteKey: (deps: CreateRandomBytesDep) => (seed?: MnemonicSeed) => WriteKey;
225
+ export interface OwnerWebSocketTransport {
226
+ readonly type: "WebSocket";
227
+ readonly url: string;
228
+ }
139
229
  /**
140
- * An `OwnerRow` represents a row in the `evolu_owner` table, based on an
141
- * {@link Owner} with an added `timestamp` ({@link TimestampString}) for CRDT
142
- * sync. It supports all {@link Owner} variants with an optional `writeKey`; use
143
- * {@link createOwnerRow} to align it with a specific {@link Owner}.
230
+ * Creates an {@link OwnerWebSocketTransport} for the given relay URL and
231
+ * {@link OwnerId}.
232
+ *
233
+ * The URL must be a WebSocket base URL without query parameters or fragments
234
+ * (e.g., `wss://relay.evolu.dev`, not `wss://relay.evolu.dev?foo=bar`). The
235
+ * function appends the `ownerId` as a query parameter.
236
+ *
237
+ * ### Example
238
+ *
239
+ * ```ts
240
+ * // Create transport "wss://relay.evolu.dev?ownerId=..."
241
+ * const transport = createOwnerWebSocketTransport({
242
+ * url: "wss://relay.evolu.dev",
243
+ * ownerId: owner.id,
244
+ * });
245
+ *
246
+ * // Use with createEvolu
247
+ * const evolu = createEvolu(deps)(Schema, {
248
+ * transports: [transport],
249
+ * });
250
+ * ```
144
251
  */
145
- export type OwnerRow = Omit<Owner, "writeKey"> & {
146
- readonly writeKey: WriteKey | null;
147
- readonly timestamp: TimestampString;
148
- };
252
+ export declare const createOwnerWebSocketTransport: (config: {
253
+ readonly url: string;
254
+ readonly ownerId: OwnerId;
255
+ }) => OwnerWebSocketTransport;
149
256
  /**
150
- * Creates an {@link OwnerRow} from any {@link Owner} variant for the
151
- * `evolu_owner` table, adding a `timestamp` ({@link TimestampString}) for CRDT
152
- * sync.
257
+ * Extracts {@link OwnerId} from an {@link OwnerWebSocketTransport} URL query
258
+ * string.
259
+ *
260
+ * Parses the query string `?ownerId=...` and validates that the extracted value
261
+ * is a valid {@link OwnerId}.
262
+ *
263
+ * ### Example
264
+ *
265
+ * ```ts
266
+ * parseOwnerIdFromOwnerWebSocketTransportUrl(
267
+ * "/sync?ownerId=_12345678abcdefgh",
268
+ * );
269
+ * // Returns: OwnerId or null
270
+ * ```
153
271
  */
154
- export declare const createOwnerRow: (deps: TimeDep & CreateRandomBytesDep & CreateMnemonicDep & NanoIdLibDep) => (owner: AppOwner | ShardOwner | SharedOwner | SharedReadonlyOwner) => OwnerRow;
272
+ export declare const parseOwnerIdFromOwnerWebSocketTransportUrl: (url: string) => OwnerId | null;
273
+ /** Base interface for all owner errors. */
274
+ export interface BaseOwnerError {
275
+ readonly ownerId: OwnerId;
276
+ }
155
277
  /**
156
- * Rotates the {@link WriteKey} for an {@link AppOwner}, {@link ShardOwner}, or
157
- * {@link SharedOwner}, returning a new instance with the updated key.
278
+ * Usage data for an {@link OwnerId}.
279
+ *
280
+ * Tracks storage usage to enforce quotas if needed, and some other stuff.
281
+ *
282
+ * TODO:
283
+ *
284
+ * - Add transferredBytes for billing and monitoring network usage.
158
285
  */
159
- export declare const rotateWriteKey: <T extends AppOwner | ShardOwner | SharedOwner>(owner: T, newWriteKey: WriteKey) => T;
286
+ export interface OwnerUsage {
287
+ /** The {@link Owner} this usage data belongs to. */
288
+ readonly ownerId: OwnerIdBytes;
289
+ /**
290
+ * Total logical data bytes stored.
291
+ *
292
+ * Measures the size of {@link EncryptedDbChange}s only, excluding
293
+ * {@link Storage} implementation overhead (with SqliteStorage: indexes,
294
+ * skiplist columns, etc.). This provides:
295
+ *
296
+ * - **Predictable measurement** - same data = same byte count across all
297
+ * instances
298
+ * - **Quota enforcement** - consistent billing/limits independent of storage
299
+ * implementation
300
+ * - **Overhead tracking** - actual Storage size can be compared against this to
301
+ * monitor efficiency
302
+ */
303
+ readonly storedBytes: NonNegativeInt;
304
+ /** Tracks the earliest timestamp for timestamp insertion strategies. */
305
+ readonly firstTimestamp: TimestampBytes | null;
306
+ /**
307
+ * Tracks the latest timestamp for timestamp insertion strategies.
308
+ *
309
+ * Free relays can use it to identify inactive accounts for cleanup.
310
+ */
311
+ readonly lastTimestamp: TimestampBytes | null;
312
+ }
160
313
  //# sourceMappingURL=Owner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Owner.d.ts","sourceRoot":"","sources":["../../../src/Evolu/Owner.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAEL,iBAAiB,EACjB,oBAAoB,EAGpB,aAAa,EACb,YAAY,EAEb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAIL,aAAa,EAGb,QAAQ,EACR,cAAc,EAEf,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,eAAe,EAEhB,MAAM,gBAAgB,CAAC;AAUxB;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;IAClC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,qaAAuB,CAAC;AAC5C,MA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