@evolu/common 6.0.1-preview.14 → 6.0.1-preview.16
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.
- package/dist/src/Crypto.d.ts +0 -1
- package/dist/src/Crypto.d.ts.map +1 -1
- package/dist/src/Crypto.js +2 -1
- package/dist/src/Evolu/Config.d.ts +7 -7
- package/dist/src/Evolu/Config.d.ts.map +1 -1
- package/dist/src/Evolu/Db.d.ts +4 -8
- package/dist/src/Evolu/Db.d.ts.map +1 -1
- package/dist/src/Evolu/Db.js +136 -112
- package/dist/src/Evolu/Evolu.d.ts.map +1 -1
- package/dist/src/Evolu/Evolu.js +5 -4
- package/dist/src/Evolu/Owner.d.ts +84 -105
- package/dist/src/Evolu/Owner.d.ts.map +1 -1
- package/dist/src/Evolu/Owner.js +78 -89
- package/dist/src/Evolu/Protocol.d.ts +6 -2
- package/dist/src/Evolu/Protocol.d.ts.map +1 -1
- package/dist/src/Evolu/Protocol.js +15 -1
- package/dist/src/Evolu/Schema.d.ts +0 -7
- package/dist/src/Evolu/Schema.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Crypto.ts +6 -4
- package/src/Evolu/Config.ts +7 -7
- package/src/Evolu/Db.ts +204 -159
- package/src/Evolu/Evolu.ts +6 -4
- package/src/Evolu/Owner.ts +128 -203
- package/src/Evolu/Protocol.ts +18 -8
- package/src/Evolu/Schema.ts +6 -7
|
@@ -1,40 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Evolu Owner - Data Ownership and Collaboration
|
|
3
|
+
*
|
|
4
|
+
* An {@link Owner} is an entity that represents ownership of data in Evolu. It
|
|
5
|
+
* consists of cryptographic keys derived from a {@link Mnemonic} via SLIP-21:
|
|
6
|
+
*
|
|
7
|
+
* - **{@link OwnerId}**: Globally unique public identifier
|
|
8
|
+
* - **{@link EncryptionKey}**: Symmetric encryption key for data protection
|
|
9
|
+
* - **{@link WriteKey}**: Authentication token for write operations
|
|
10
|
+
*
|
|
11
|
+
* Every Evolu app has at least one owner, the {@link AppOwner}. There are
|
|
12
|
+
* several owner variants for different use cases:
|
|
13
|
+
*
|
|
14
|
+
* **{@link ShardOwner}**: Derived from {@link AppOwner} for partitioning data and
|
|
15
|
+
* selective synchronization using {@link createShardOwner}
|
|
16
|
+
*
|
|
17
|
+
* **{@link SharedOwner}**: Created for collaboration with write access, not
|
|
18
|
+
* meant to be shared directly
|
|
19
|
+
*
|
|
20
|
+
* **{@link SharedReadonlyOwner}**: Read-only version for safe data sharing,
|
|
21
|
+
* created from {@link SharedOwner} using {@link createSharedReadonlyOwner}
|
|
22
|
+
*
|
|
23
|
+
* Owners are designed for data synchronization and backup. Authentication
|
|
24
|
+
* systems built on public/private key cryptography use these primitives. This
|
|
25
|
+
* design ensures Evolu Relay knows as little as possible - it only sees
|
|
26
|
+
* Timestamp, OwnerId, and EncryptedDbChange.
|
|
3
27
|
*
|
|
4
28
|
* @module
|
|
5
29
|
*/
|
|
30
|
+
import { NonEmptyReadonlyArray } from "../Array.js";
|
|
6
31
|
import { CreateMnemonicDep, CreateRandomBytesDep, EncryptionKey, MnemonicSeed } from "../Crypto.js";
|
|
7
|
-
import {
|
|
8
|
-
import { TimeDep } from "../Time.js";
|
|
9
|
-
import { DateIsoString, Mnemonic, NonNegativeInt } from "../Type.js";
|
|
10
|
-
import { TimestampString } from "./Timestamp.js";
|
|
32
|
+
import { Mnemonic, NonNegativeInt } from "../Type.js";
|
|
11
33
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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.
|
|
34
|
+
* Represents ownership of data in Evolu. Created from a {@link Mnemonic} via
|
|
35
|
+
* SLIP-21 key derivation using {@link createOwner}, providing cryptographic keys
|
|
36
|
+
* for data access and authentication.
|
|
20
37
|
*
|
|
21
|
-
*
|
|
22
|
-
* {@link
|
|
23
|
-
*
|
|
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.
|
|
38
|
+
* - {@link OwnerId}: Globally unique public identifier
|
|
39
|
+
* - {@link EncryptionKey}: Symmetric encryption key for data protection
|
|
40
|
+
* - {@link WriteKey}: Authentication token for write operations (rotatable)
|
|
29
41
|
*/
|
|
30
42
|
export interface Owner {
|
|
31
|
-
readonly mnemonic: Mnemonic;
|
|
32
|
-
readonly createdAt: DateIsoString;
|
|
33
|
-
readonly id: OwnerId;
|
|
34
|
-
readonly encryptionKey: EncryptionKey;
|
|
35
|
-
readonly writeKey: WriteKey;
|
|
36
|
-
}
|
|
37
|
-
export interface OwnerWithWriteAccess {
|
|
38
43
|
readonly id: OwnerId;
|
|
39
44
|
readonly encryptionKey: EncryptionKey;
|
|
40
45
|
readonly writeKey: WriteKey;
|
|
@@ -51,107 +56,81 @@ export declare const OwnerId: import("../Type.js").BrandType<import("../Type.js"
|
|
|
51
56
|
export type OwnerId = typeof OwnerId.Type;
|
|
52
57
|
export declare const writeKeyLength: NonNegativeInt;
|
|
53
58
|
/**
|
|
54
|
-
* A secure token proving the initiator can write changes. Derived from a
|
|
55
|
-
* mnemonic or randomly generated. It
|
|
59
|
+
* A secure token proving that the initiator can write changes. Derived from a
|
|
60
|
+
* mnemonic or randomly generated via {@link createWriteKey}. It is rotatable.
|
|
56
61
|
*/
|
|
57
62
|
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
63
|
export type WriteKey = typeof WriteKey.Type;
|
|
64
|
+
/** Creates a randomly generated {@link WriteKey}. */
|
|
65
|
+
export declare const createWriteKey: (deps: CreateRandomBytesDep) => WriteKey;
|
|
66
|
+
/** Creates an {@link Owner} from a {@link Mnemonic} using SLIP-21 key derivation. */
|
|
67
|
+
export declare const createOwner: (mnemonic: Mnemonic) => Owner;
|
|
59
68
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
* Creates an {@link Owner} from a {@link MnemonicSeed} using SLIP-21 key
|
|
70
|
+
* derivation.
|
|
71
|
+
*/
|
|
72
|
+
export declare const createOwnerFromMnemonicSeed: (seed: MnemonicSeed) => Owner;
|
|
73
|
+
/**
|
|
74
|
+
* The owner representing app data. Can be created from a {@link Mnemonic} or
|
|
75
|
+
* from external keys when the mnemonic should not be shared with the Evolu
|
|
76
|
+
* app.
|
|
65
77
|
*/
|
|
66
78
|
export interface AppOwner extends Owner {
|
|
67
79
|
readonly type: "AppOwner";
|
|
80
|
+
/**
|
|
81
|
+
* The mnemonic that was used to derive the AppOwner keys. Optional when the
|
|
82
|
+
* AppOwner is created from external keys to avoid sharing the mnemonic with
|
|
83
|
+
* the Evolu app.
|
|
84
|
+
*/
|
|
85
|
+
readonly mnemonic?: Mnemonic | null;
|
|
68
86
|
}
|
|
87
|
+
export declare const createAppOwner: (mnemonic: Mnemonic) => AppOwner;
|
|
69
88
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
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.
|
|
89
|
+
* Owner for sharding app data. Allows partitioning of database changes for
|
|
90
|
+
* selective synchronization.
|
|
78
91
|
*/
|
|
79
|
-
export interface ShardOwner {
|
|
92
|
+
export interface ShardOwner extends Owner {
|
|
80
93
|
readonly type: "ShardOwner";
|
|
81
|
-
readonly mnemonic: Mnemonic;
|
|
82
|
-
readonly writeKey: WriteKey;
|
|
83
94
|
}
|
|
84
95
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
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.
|
|
96
|
+
* Creates a {@link ShardOwner} derived from an {@link AppOwner} using the
|
|
97
|
+
* specified path.
|
|
91
98
|
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
99
|
+
* ### Example
|
|
100
|
+
*
|
|
101
|
+
* ```ts
|
|
102
|
+
* const contactsShard = createShardOwner(appOwner, ["contacts"]);
|
|
103
|
+
* const projectShard = createShardOwner(appOwner, [
|
|
104
|
+
* "projects",
|
|
105
|
+
* "project-1",
|
|
106
|
+
* ]);
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export declare const createShardOwner: (appOwner: AppOwner, path: NonEmptyReadonlyArray<string>) => ShardOwner;
|
|
110
|
+
/**
|
|
111
|
+
* Owner for collaborative data with write access. Created by a user for their
|
|
112
|
+
* own use, not meant to be shared directly. To share data, use
|
|
113
|
+
* {@link createSharedReadonlyOwner} to create a {@link SharedReadonlyOwner} for
|
|
114
|
+
* read-only access.
|
|
94
115
|
*/
|
|
95
|
-
export interface SharedOwner {
|
|
116
|
+
export interface SharedOwner extends Owner {
|
|
96
117
|
readonly type: "SharedOwner";
|
|
97
118
|
readonly mnemonic: Mnemonic;
|
|
98
|
-
readonly writeKey: WriteKey;
|
|
99
119
|
}
|
|
120
|
+
/** Creates a {@link SharedOwner} with a freshly generated {@link Mnemonic}. */
|
|
121
|
+
export declare const createSharedOwner: (deps: CreateMnemonicDep) => SharedOwner;
|
|
100
122
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* Typically derived from a `SharedOwner` by sharing its `mnemonic` without the
|
|
105
|
-
* `writeKey`.
|
|
123
|
+
* Read-only version of a {@link SharedOwner} for data sharing. Contains only the
|
|
124
|
+
* {@link OwnerId} and {@link EncryptionKey} needed for others to read the shared
|
|
125
|
+
* data without write access.
|
|
106
126
|
*/
|
|
107
127
|
export interface SharedReadonlyOwner {
|
|
108
128
|
readonly type: "SharedReadonlyOwner";
|
|
109
|
-
readonly
|
|
129
|
+
readonly id: OwnerId;
|
|
130
|
+
readonly encryptionKey: EncryptionKey;
|
|
110
131
|
}
|
|
111
|
-
/**
|
|
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.
|
|
128
|
-
*/
|
|
129
|
-
export declare const createSharedOwner: (deps: CreateRandomBytesDep & CreateMnemonicDep) => SharedOwner;
|
|
130
|
-
/**
|
|
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.
|
|
134
|
-
*/
|
|
132
|
+
/** Creates a {@link SharedReadonlyOwner} from a {@link SharedOwner}. */
|
|
135
133
|
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;
|
|
139
|
-
/**
|
|
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}.
|
|
144
|
-
*/
|
|
145
|
-
export type OwnerRow = Omit<Owner, "writeKey"> & {
|
|
146
|
-
readonly writeKey: WriteKey | null;
|
|
147
|
-
readonly timestamp: TimestampString;
|
|
148
|
-
};
|
|
149
|
-
/**
|
|
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.
|
|
153
|
-
*/
|
|
154
|
-
export declare const createOwnerRow: (deps: TimeDep & CreateRandomBytesDep & CreateMnemonicDep & NanoIdLibDep) => (owner: AppOwner | ShardOwner | SharedOwner | SharedReadonlyOwner) => OwnerRow;
|
|
155
134
|
/**
|
|
156
135
|
* Rotates the {@link WriteKey} for an {@link AppOwner}, {@link ShardOwner}, or
|
|
157
136
|
* {@link SharedOwner}, returning a new instance with the updated key.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Owner.d.ts","sourceRoot":"","sources":["../../../src/Evolu/Owner.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Owner.d.ts","sourceRoot":"","sources":["../../../src/Evolu/Owner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EAGpB,aAAa,EACb,YAAY,EAEb,MAAM,cAAc,CAAC;AACtB,OAAO,EAKL,QAAQ,EACR,cAAc,EAEf,MAAM,YAAY,CAAC;AAEpB;;;;;;;;GAQG;AACH,MAAM,WAAW,KAAK;IACpB,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,MAAM,MAAM,OAAO,GAAG,OA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AE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;CACvC;AAED,wEAAwE;AACxE,eAAO,MAAM,yBAAyB,GACpC,aAAa,WAAW,KACvB,mBAID,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,QAAQ,GAAG,UAAU,GAAG,WAAW,EAC1E,OAAO,CAAC,EACR,aAAa,QAAQ,KACpB,CAKF,CAAC"}
|
package/dist/src/Evolu/Owner.js
CHANGED
|
@@ -1,12 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Evolu Owner - Data Ownership and Collaboration
|
|
3
|
+
*
|
|
4
|
+
* An {@link Owner} is an entity that represents ownership of data in Evolu. It
|
|
5
|
+
* consists of cryptographic keys derived from a {@link Mnemonic} via SLIP-21:
|
|
6
|
+
*
|
|
7
|
+
* - **{@link OwnerId}**: Globally unique public identifier
|
|
8
|
+
* - **{@link EncryptionKey}**: Symmetric encryption key for data protection
|
|
9
|
+
* - **{@link WriteKey}**: Authentication token for write operations
|
|
10
|
+
*
|
|
11
|
+
* Every Evolu app has at least one owner, the {@link AppOwner}. There are
|
|
12
|
+
* several owner variants for different use cases:
|
|
13
|
+
*
|
|
14
|
+
* **{@link ShardOwner}**: Derived from {@link AppOwner} for partitioning data and
|
|
15
|
+
* selective synchronization using {@link createShardOwner}
|
|
16
|
+
*
|
|
17
|
+
* **{@link SharedOwner}**: Created for collaboration with write access, not
|
|
18
|
+
* meant to be shared directly
|
|
19
|
+
*
|
|
20
|
+
* **{@link SharedReadonlyOwner}**: Read-only version for safe data sharing,
|
|
21
|
+
* created from {@link SharedOwner} using {@link createSharedReadonlyOwner}
|
|
22
|
+
*
|
|
23
|
+
* Owners are designed for data synchronization and backup. Authentication
|
|
24
|
+
* systems built on public/private key cryptography use these primitives. This
|
|
25
|
+
* design ensures Evolu Relay knows as little as possible - it only sees
|
|
26
|
+
* Timestamp, OwnerId, and EncryptedDbChange.
|
|
3
27
|
*
|
|
4
28
|
* @module
|
|
5
29
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { brand, DateIso, Id, length, Uint8Array, } from "../Type.js";
|
|
9
|
-
import { createInitialTimestamp, timestampToTimestampString, } from "./Timestamp.js";
|
|
30
|
+
import { createSlip21, createSlip21Id, mnemonicToMnemonicSeed, } from "../Crypto.js";
|
|
31
|
+
import { brand, Id, length, Uint8Array, } from "../Type.js";
|
|
10
32
|
/**
|
|
11
33
|
* The unique identifier of {@link Owner} derived from the {@link Mnemonic}.
|
|
12
34
|
*
|
|
@@ -18,107 +40,74 @@ import { createInitialTimestamp, timestampToTimestampString, } from "./Timestamp
|
|
|
18
40
|
export const OwnerId = brand("OwnerId", Id);
|
|
19
41
|
export const writeKeyLength = 16;
|
|
20
42
|
/**
|
|
21
|
-
* A secure token proving the initiator can write changes. Derived from a
|
|
22
|
-
* mnemonic or randomly generated. It
|
|
43
|
+
* A secure token proving that the initiator can write changes. Derived from a
|
|
44
|
+
* mnemonic or randomly generated via {@link createWriteKey}. It is rotatable.
|
|
23
45
|
*/
|
|
24
46
|
export const WriteKey = brand("WriteKey", length(writeKeyLength)(Uint8Array));
|
|
47
|
+
/** Creates a randomly generated {@link WriteKey}. */
|
|
48
|
+
export const createWriteKey = (deps) => deps.createRandomBytes(16);
|
|
49
|
+
/** Creates an {@link Owner} from a {@link Mnemonic} using SLIP-21 key derivation. */
|
|
50
|
+
export const createOwner = (mnemonic) => {
|
|
51
|
+
const seed = mnemonicToMnemonicSeed(mnemonic);
|
|
52
|
+
return createOwnerFromMnemonicSeed(seed);
|
|
53
|
+
};
|
|
25
54
|
/**
|
|
26
|
-
* Creates an {@link
|
|
27
|
-
*
|
|
55
|
+
* Creates an {@link Owner} from a {@link MnemonicSeed} using SLIP-21 key
|
|
56
|
+
* derivation.
|
|
28
57
|
*/
|
|
29
|
-
export const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
58
|
+
export const createOwnerFromMnemonicSeed = (seed) => ({
|
|
59
|
+
id: createSlip21Id(seed, ["Evolu", "Owner Id"]),
|
|
60
|
+
encryptionKey: createSlip21(seed, [
|
|
61
|
+
"Evolu",
|
|
62
|
+
"Encryption Key",
|
|
63
|
+
]),
|
|
64
|
+
writeKey: createSlip21(seed, ["Evolu", "Write Key"]).slice(0, 16),
|
|
65
|
+
});
|
|
66
|
+
export const createAppOwner = (mnemonic) => ({
|
|
67
|
+
type: "AppOwner",
|
|
68
|
+
mnemonic,
|
|
69
|
+
...createOwner(mnemonic),
|
|
70
|
+
});
|
|
33
71
|
/**
|
|
34
|
-
* Creates a {@link ShardOwner}
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
72
|
+
* Creates a {@link ShardOwner} derived from an {@link AppOwner} using the
|
|
73
|
+
* specified path.
|
|
74
|
+
*
|
|
75
|
+
* ### Example
|
|
76
|
+
*
|
|
77
|
+
* ```ts
|
|
78
|
+
* const contactsShard = createShardOwner(appOwner, ["contacts"]);
|
|
79
|
+
* const projectShard = createShardOwner(appOwner, [
|
|
80
|
+
* "projects",
|
|
81
|
+
* "project-1",
|
|
82
|
+
* ]);
|
|
83
|
+
* ```
|
|
38
84
|
*/
|
|
39
|
-
export const createShardOwner = (
|
|
40
|
-
|
|
85
|
+
export const createShardOwner = (appOwner, path) => {
|
|
86
|
+
/**
|
|
87
|
+
* The shardSeed is never shared or persisted, only used for SLIP-21
|
|
88
|
+
* derivation to create shard-specific keys.
|
|
89
|
+
*/
|
|
90
|
+
const shardSeed = createSlip21(appOwner.encryptionKey, path);
|
|
41
91
|
return {
|
|
42
92
|
type: "ShardOwner",
|
|
43
|
-
|
|
44
|
-
writeKey: owner.writeKey,
|
|
93
|
+
...createOwnerFromMnemonicSeed(shardSeed),
|
|
45
94
|
};
|
|
46
95
|
};
|
|
47
|
-
/**
|
|
48
|
-
* Creates a fresh {@link SharedOwner} for sharing data with write access. Takes
|
|
49
|
-
* no arguments as both `mnemonic` and rotatable `writeKey` are newly generated;
|
|
50
|
-
* when shared, recipients use the provided `mnemonic` and `writeKey` directly
|
|
51
|
-
* as a {@link SharedOwner} without needing to recreate it.
|
|
52
|
-
*/
|
|
96
|
+
/** Creates a {@link SharedOwner} with a freshly generated {@link Mnemonic}. */
|
|
53
97
|
export const createSharedOwner = (deps) => {
|
|
54
98
|
const mnemonic = deps.createMnemonic();
|
|
55
|
-
const writeKey = createWriteKey(deps)(); // Random, no seed
|
|
56
99
|
return {
|
|
57
100
|
type: "SharedOwner",
|
|
58
101
|
mnemonic,
|
|
59
|
-
|
|
102
|
+
...createOwner(mnemonic),
|
|
60
103
|
};
|
|
61
104
|
};
|
|
62
|
-
/**
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
type: "SharedReadonlyOwner",
|
|
70
|
-
mnemonic: sharedOwner.mnemonic,
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
/** Creates an {@link Owner} with optional `mnemonic` and `writeKey`. */
|
|
74
|
-
export const createOwner = (deps) => (mnemonic = deps.createMnemonic(), writeKey) => {
|
|
75
|
-
const seed = mnemonicToMnemonicSeed(mnemonic);
|
|
76
|
-
const id = createSlip21Id(seed, ["Evolu", "Owner Id"]);
|
|
77
|
-
const encryptionKey = createEncryptionKey(seed);
|
|
78
|
-
const createdAt = DateIso.fromParent(new Date(deps.time.now()));
|
|
79
|
-
assert(createdAt.ok, "Invalid DateIso: bad system clock");
|
|
80
|
-
return {
|
|
81
|
-
mnemonic,
|
|
82
|
-
createdAt: createdAt.value,
|
|
83
|
-
id,
|
|
84
|
-
encryptionKey,
|
|
85
|
-
writeKey: writeKey ?? createWriteKey(deps)(seed),
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
export const createWriteKey = (deps) => (seed) => {
|
|
89
|
-
const key = seed
|
|
90
|
-
? createSlip21(seed, ["Evolu", "Write Key"]).slice(0, 16)
|
|
91
|
-
: deps.createRandomBytes(16);
|
|
92
|
-
const writeKey = WriteKey.from(key);
|
|
93
|
-
assert(writeKey.ok, "Ensure valid WriteKey");
|
|
94
|
-
return writeKey.value;
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Creates an {@link OwnerRow} from any {@link Owner} variant for the
|
|
98
|
-
* `evolu_owner` table, adding a `timestamp` ({@link TimestampString}) for CRDT
|
|
99
|
-
* sync.
|
|
100
|
-
*/
|
|
101
|
-
export const createOwnerRow = (deps) => (owner) => {
|
|
102
|
-
const timestamp = timestampToTimestampString(createInitialTimestamp(deps));
|
|
103
|
-
switch (owner.type) {
|
|
104
|
-
case "AppOwner": {
|
|
105
|
-
const { type, ...rest } = owner;
|
|
106
|
-
return { ...rest, timestamp };
|
|
107
|
-
}
|
|
108
|
-
case "ShardOwner":
|
|
109
|
-
case "SharedOwner":
|
|
110
|
-
return {
|
|
111
|
-
...createOwner(deps)(owner.mnemonic, owner.writeKey),
|
|
112
|
-
timestamp,
|
|
113
|
-
};
|
|
114
|
-
case "SharedReadonlyOwner":
|
|
115
|
-
return {
|
|
116
|
-
...createOwner(deps)(owner.mnemonic),
|
|
117
|
-
writeKey: null,
|
|
118
|
-
timestamp,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
};
|
|
105
|
+
/** Creates a {@link SharedReadonlyOwner} from a {@link SharedOwner}. */
|
|
106
|
+
export const createSharedReadonlyOwner = (sharedOwner) => ({
|
|
107
|
+
type: "SharedReadonlyOwner",
|
|
108
|
+
id: sharedOwner.id,
|
|
109
|
+
encryptionKey: sharedOwner.encryptionKey,
|
|
110
|
+
});
|
|
122
111
|
/**
|
|
123
112
|
* Rotates the {@link WriteKey} for an {@link AppOwner}, {@link ShardOwner}, or
|
|
124
113
|
* {@link SharedOwner}, returning a new instance with the updated key.
|
|
@@ -61,6 +61,10 @@
|
|
|
61
61
|
* if further sync is needed or possible, continuing until both sides are
|
|
62
62
|
* synchronized.
|
|
63
63
|
*
|
|
64
|
+
* The **non-initiator always responds** to provide sync completion feedback,
|
|
65
|
+
* even with empty messages containing only the header and no error. This allows
|
|
66
|
+
* the initiator to reliably detect when synchronization is complete.
|
|
67
|
+
*
|
|
64
68
|
* Both **Messages** and **Ranges** are optional, allowing each side to send,
|
|
65
69
|
* sync, or only subscribe data as needed.
|
|
66
70
|
*
|
|
@@ -145,7 +149,7 @@ import { Result } from "../Result.js";
|
|
|
145
149
|
import { SqliteValue } from "../Sqlite.js";
|
|
146
150
|
import { Id, NanoId, NonNegativeInt, PositiveInt } from "../Type.js";
|
|
147
151
|
import { Brand } from "../Types.js";
|
|
148
|
-
import {
|
|
152
|
+
import { Owner, OwnerId, WriteKey } from "./Owner.js";
|
|
149
153
|
import { BinaryTimestamp, NodeId, Timestamp } from "./Timestamp.js";
|
|
150
154
|
/** Maximum size of the entire protocol message in bytes. */
|
|
151
155
|
export declare const maxProtocolMessageSize: PositiveInt;
|
|
@@ -335,7 +339,7 @@ export interface ProtocolTimestampMismatchError {
|
|
|
335
339
|
* ensures all messages will be sent in the next round(s) even over
|
|
336
340
|
* unidirectional and stateless transports.
|
|
337
341
|
*/
|
|
338
|
-
export declare const createProtocolMessageFromCrdtMessages: (deps: SymmetricCryptoDep & CreateRandomBytesDep) => (owner:
|
|
342
|
+
export declare const createProtocolMessageFromCrdtMessages: (deps: SymmetricCryptoDep & CreateRandomBytesDep) => (owner: Owner, messages: NonEmptyReadonlyArray<CrdtMessage>, maxSize?: PositiveInt) => ProtocolMessage;
|
|
339
343
|
/** Creates a {@link ProtocolMessage} for sync. */
|
|
340
344
|
export declare const createProtocolMessageForSync: (deps: StorageDep) => (ownerId: OwnerId) => ProtocolMessage | null;
|
|
341
345
|
/** Creates a ProtocolMessage for {@link WriteKey} rotation. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Protocol.d.ts","sourceRoot":"","sources":["../../../src/Evolu/Protocol.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":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;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,MAAM,KAAG,cAiBrD,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,EAAE,OAAO,SAAS,CAAC,GAAG,CAAC,KAAG,IAEpE,CAAC;AAEF,eAAO,MAAM,YAAY,WAvBoB,MAAM,KAAG,cAuBN,CAAC;AAEjD,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,EAAE,OAAO,MAAM,KAAG,IAI5D,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,KAAG,MAI7C,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,KAAG,IAE7D,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,KAAG,MAG7C,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,MAAM,EACd,QAAQ,mBAAmB,KAC1B,IAGF,CAAC;AAEF,eAAO,MAAM,4BAA4B,GAAI,QAAQ,MAAM,KAAG,YAG7D,CAAC;AAMF,eAAO,MAAM,iBAAiB;qBAId,cAAc;qBACd,cAAc;mBAChB,cAAc;qBACZ,cAAc;iBAIlB,cAAc;2BACJ,cAAc;6BACZ,cAAc;mBACxB,cAAc;yCAKQ,cAAc;sCACjB,cAAc;CAIrC,CAAC;AAEX,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,EAAE,OAAO,WAAW,KAAG,IAwEtE,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,KAAG,WA8ClD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,GACtC,kBAAkB,eAAe,EACjC,cAAc,OAAO,KACpB,OAOF,CAAC"}
|
|
@@ -61,6 +61,10 @@
|
|
|
61
61
|
* if further sync is needed or possible, continuing until both sides are
|
|
62
62
|
* synchronized.
|
|
63
63
|
*
|
|
64
|
+
* The **non-initiator always responds** to provide sync completion feedback,
|
|
65
|
+
* even with empty messages containing only the header and no error. This allows
|
|
66
|
+
* the initiator to reliably detect when synchronization is complete.
|
|
67
|
+
*
|
|
64
68
|
* Both **Messages** and **Ranges** are optional, allowing each side to send,
|
|
65
69
|
* sync, or only subscribe data as needed.
|
|
66
70
|
*
|
|
@@ -150,7 +154,7 @@ import { objectToEntries } from "../Object.js";
|
|
|
150
154
|
import { err, ok } from "../Result.js";
|
|
151
155
|
import { SqliteValue } from "../Sqlite.js";
|
|
152
156
|
import { Base64Url, base64UrlAlphabet, DateIsoString, Id, idTypeValueLength, JsonValueFromString, maxLength, NonNegativeInt, Number, object, record, } from "../Type.js";
|
|
153
|
-
import { writeKeyLength
|
|
157
|
+
import { writeKeyLength } from "./Owner.js";
|
|
154
158
|
import { binaryTimestampLength, binaryTimestampToTimestamp, Counter, eqTimestamp, Millis, timestampToBinaryTimestamp, } from "./Timestamp.js";
|
|
155
159
|
/** Maximum size of the entire protocol message in bytes. */
|
|
156
160
|
export const maxProtocolMessageSize = 1_000_000;
|
|
@@ -648,6 +652,11 @@ const decodeMessages = (buffer) => {
|
|
|
648
652
|
const sync = (deps) => (role, input, output, ownerId) => {
|
|
649
653
|
const ranges = decodeRanges(input);
|
|
650
654
|
if (!isNonEmptyReadonlyArray(ranges)) {
|
|
655
|
+
// Non-initiators always respond to provide sync completion feedback,
|
|
656
|
+
// even when there's nothing to sync.
|
|
657
|
+
if (role === "non-initiator") {
|
|
658
|
+
return ok(output.unwrap());
|
|
659
|
+
}
|
|
651
660
|
// Nothing to sync.
|
|
652
661
|
return ok(null);
|
|
653
662
|
}
|
|
@@ -808,6 +817,11 @@ const sync = (deps) => (role, input, output, ownerId) => {
|
|
|
808
817
|
}
|
|
809
818
|
// If all ranges were skipped, there are no changes and sync is complete.
|
|
810
819
|
const hasChange = output.getSize() > outputInitialSize;
|
|
820
|
+
// Non-initiators always respond to provide sync completion feedback,
|
|
821
|
+
// even with empty messages. This allows clients to detect sync completion.
|
|
822
|
+
if (role === "non-initiator" && !hasChange) {
|
|
823
|
+
return ok(output.unwrap());
|
|
824
|
+
}
|
|
811
825
|
return ok(hasChange ? output.unwrap() : null);
|
|
812
826
|
};
|
|
813
827
|
const splitRange = (deps) => (ownerId, lower, upper, upperBound, buffer) => {
|
|
@@ -6,7 +6,6 @@ import { AnyType, BrandType, DateIso, IdType, InferErrors, InferInput, InferType
|
|
|
6
6
|
import { Simplify } from "../Types.js";
|
|
7
7
|
import { DbSchema } from "./Db.js";
|
|
8
8
|
import { DbIndexesBuilder } from "./Kysely.js";
|
|
9
|
-
import { ShardOwner, SharedOwner } from "./Owner.js";
|
|
10
9
|
import { BinaryId } from "./Protocol.js";
|
|
11
10
|
import { Query, Row } from "./Query.js";
|
|
12
11
|
import { BinaryTimestamp } from "./Timestamp.js";
|
|
@@ -109,12 +108,6 @@ export interface MutationOptions {
|
|
|
109
108
|
* `onlyValidate: true`.
|
|
110
109
|
*/
|
|
111
110
|
readonly onlyValidate?: boolean;
|
|
112
|
-
/**
|
|
113
|
-
* The owner to use for this mutation. Can be a {@link ShardOwner} for sharding
|
|
114
|
-
* app data or a {@link SharedOwner} for collaborative write access. If
|
|
115
|
-
* omitted, defaults to the app's {@link AppOwner}.
|
|
116
|
-
*/
|
|
117
|
-
readonly owner?: ShardOwner | SharedOwner;
|
|
118
111
|
}
|
|
119
112
|
/**
|
|
120
113
|
* Evolu has to limit the maximum mutation size. Otherwise, sync couldn't use
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../../../src/Evolu/Schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAGpD,OAAO,EAA8B,cAAc,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAW,MAAM,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc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