@kumiai/mls-rpc 0.10.1 → 0.10.3
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/README.md +43 -10
- package/lib/mls.js +6 -0
- package/lib/recovery.d.ts +1 -1
- package/lib/recovery.js +6 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -36,7 +36,33 @@ Both factories take the same `access` instance. The adapter reads the current ha
|
|
|
36
36
|
adopts an authored commit through `access.replace(next)` after acceptance. The adapter saves before
|
|
37
37
|
publishing the replacement and publishes its synchronous epoch hint after a successful save.
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
Before every host commit build, `createGroupMLS` persists a handshake reservation through `access.mutate`.
|
|
40
|
+
The epoch and application ratchet stay unchanged, including when a discarded CAS winner never applies.
|
|
41
|
+
A durable unconsumed reservation is reused after a non-framing failure or restart.
|
|
42
|
+
After a builder returns, `commitBuildFramed` persists consumption before the peer writes its journal or publishes.
|
|
43
|
+
An ambiguous reservation burns a fresh generation. Journal replay republishes the existing frame.
|
|
44
|
+
Builders must return their frame to the peer before any publication.
|
|
45
|
+
Direct publishers must call `group.consumeHandshakeReservation(persist)` after the build and before any journalling or publication.
|
|
46
|
+
Calling reserve alone reuses an unconsumed generation.
|
|
47
|
+
The peer requires both `prepareCommitBuild` and `commitBuildFramed`, or neither, and rejects incomplete pairs with `CommitBuildHooksError`.
|
|
48
|
+
|
|
49
|
+
`HandshakeWindowError` rejects the operation before another reservation exceeds half the receiver window, capped at 100 generations.
|
|
50
|
+
It does not strand the peer or request recovery. A received epoch advance permits new reservations.
|
|
51
|
+
The baseline is epoch start: every accepted MLS handshake commit advances the epoch, resetting this budget.
|
|
52
|
+
The deadline and attempt ceiling still apply.
|
|
53
|
+
|
|
54
|
+
In ts-mls 2.0.0-rc.13, `defaultKeyRetentionConfig.maximumForwardRatchetSteps` is 200.
|
|
55
|
+
Its configuration path is `MlsContext.clientConfig.keyRetentionConfig.maximumForwardRatchetSteps`.
|
|
56
|
+
The sender uses half the smaller of its configured window and that default. Members must use compatible receiver windows.
|
|
57
|
+
Missing key retention configuration uses the default window. A window below 2 throws `HandshakeWindowConfigError` on reservation.
|
|
58
|
+
Consuming a stale reservation throws `HandshakeReservationError`, including after an epoch advance.
|
|
59
|
+
Reservation checkpoints use client-state format v3. The decoder accepts v1, whose missing evidence never permits reservation reuse.
|
|
60
|
+
The decoder refuses v2, which belongs to an incompatible layout, and unknown versions. Older decoders refuse v3 checkpoints.
|
|
61
|
+
Each framed attempt adds a consumption save before journalling.
|
|
62
|
+
Durable hosts must supply `simpleHandleAccess.persist` or an equivalent transactional `HandleAccess`.
|
|
63
|
+
Persistence must resolve after a durable write and reject without changing storage.
|
|
64
|
+
|
|
65
|
+
For a _received_ commit there is nothing to adopt: ts-mls's `processMessage` advances the handle in
|
|
40
66
|
place. A host that treated every commit as adopt-later would double-apply received ones.
|
|
41
67
|
|
|
42
68
|
Migrating from 0.9: build one adapter from the old `handle` / `adopt` / `persist` parameters and pass
|
|
@@ -51,10 +77,9 @@ const mls = createGroupMLS({ access, identity, entrySlot })
|
|
|
51
77
|
### A host's own `HandleAccess`
|
|
52
78
|
|
|
53
79
|
A host with its own handle store implements the port instead:
|
|
54
|
-
|
|
55
80
|
- `read(fn)` lends the handle for the callback only. `mutate(fn)` serialises with every other
|
|
56
81
|
operation and resolves after the state is stored; `fn`'s `persist` argument goes to
|
|
57
|
-
`processMessage` and `
|
|
82
|
+
`processMessage`, `bootstrapLedger` and `reserveHandshakeGeneration`. `replace(next)` stores before publishing. A transactional
|
|
58
83
|
host may restore a fresh handle per mutation, discard it on rollback, and publish on commit.
|
|
59
84
|
- `epoch()` is a synchronous hint. Publish it only after the outermost successful commit, and restore
|
|
60
85
|
it on rollback. No port decision reads it: every one uses an epoch read under the lock.
|
|
@@ -77,7 +102,9 @@ record and resolves for an unknown id. Deduplicate inserts by `record.frame.id`.
|
|
|
77
102
|
```ts
|
|
78
103
|
const access = simpleHandleAccess({
|
|
79
104
|
handle: () => handle,
|
|
80
|
-
adopt: (next) => {
|
|
105
|
+
adopt: (next) => {
|
|
106
|
+
handle = next
|
|
107
|
+
},
|
|
81
108
|
persist: (current) => store.save(current),
|
|
82
109
|
})
|
|
83
110
|
const crypto = createGroupCrypto({
|
|
@@ -118,10 +145,15 @@ with 0.10 peers. See the `@kumiai/rpc` README for the delivery and retention bou
|
|
|
118
145
|
`GroupMLS.processCommit` is handed a `resolveLedgerEntries` scoped to **one** commit's frame — the
|
|
119
146
|
signed ledger-entry bodies ride that frame and nowhere else. But `GroupHandle` takes its resolver
|
|
120
147
|
once, in `GroupOptions`, and offers no way to change it afterwards. So the indirection has to be
|
|
121
|
-
installed when the group is
|
|
148
|
+
installed when the group is _built_:
|
|
122
149
|
|
|
123
150
|
```ts
|
|
124
|
-
import {
|
|
151
|
+
import {
|
|
152
|
+
createGroupCrypto,
|
|
153
|
+
createGroupMLS,
|
|
154
|
+
createLedgerEntrySlot,
|
|
155
|
+
simpleHandleAccess,
|
|
156
|
+
} from '@kumiai/mls-rpc'
|
|
125
157
|
|
|
126
158
|
const entrySlot = createLedgerEntrySlot()
|
|
127
159
|
// Every construction site: createGroup / processWelcome / restoreGroup.
|
|
@@ -132,7 +164,9 @@ const { group } = await createGroup(identity, groupID, {
|
|
|
132
164
|
let handle = group
|
|
133
165
|
const access = simpleHandleAccess({
|
|
134
166
|
handle: () => handle,
|
|
135
|
-
adopt: (next) => {
|
|
167
|
+
adopt: (next) => {
|
|
168
|
+
handle = next
|
|
169
|
+
},
|
|
136
170
|
persist: (current) => store.save(current),
|
|
137
171
|
})
|
|
138
172
|
const crypto = createGroupCrypto({ access })
|
|
@@ -199,15 +233,14 @@ The two use different exporter labels deliberately: the topic secret names a top
|
|
|
199
233
|
anything that derives one, while the entry key opens the group's control-ledger bodies.
|
|
200
234
|
|
|
201
235
|
The sealed blob is `[ VERSION(1) | NONCE(24) | CIPHERTEXT ]`, XChaCha20-Poly1305. The version byte
|
|
202
|
-
sits inside the blob rather than in the frame header so that an unknown version fails the
|
|
203
|
-
survivable, the commit is filed as poison and stepped over — rather than the
|
|
236
|
+
sits inside the blob rather than in the frame header so that an unknown version fails the _open_ —
|
|
237
|
+
survivable, the commit is filed as poison and stepped over — rather than the _decode_, which would
|
|
204
238
|
leave a peer stepping over frames without ever classifying one and never learning the group moved on.
|
|
205
239
|
|
|
206
240
|
## Where this diverges from the doubles
|
|
207
241
|
|
|
208
242
|
Documented on the factories themselves; the conformance suite in `@kumiai/rpc-conformance` pins each
|
|
209
243
|
one. The ones a host is most likely to trip on:
|
|
210
|
-
|
|
211
244
|
- **`unwrap` opens only at the current epoch.** A readable frame at any other epoch throws
|
|
212
245
|
`FrameEpochError` before decryption, under the handle lock. ts-mls could open a few past epochs,
|
|
213
246
|
but `GroupHandle.decrypt` resolves senders at the current epoch, so such a frame never had a
|
package/lib/mls.js
CHANGED
|
@@ -157,6 +157,12 @@ export async function deriveRecoverySecret(handle) {
|
|
|
157
157
|
async readEpoch () {
|
|
158
158
|
return await access.read((group)=>Number(group.epoch));
|
|
159
159
|
},
|
|
160
|
+
async commitBuildFramed () {
|
|
161
|
+
await access.mutate((group, persist)=>group.consumeHandshakeReservation(persist));
|
|
162
|
+
},
|
|
163
|
+
async prepareCommitBuild () {
|
|
164
|
+
await access.mutate((group, persist)=>group.reserveHandshakeGeneration(persist));
|
|
165
|
+
},
|
|
160
166
|
sendAdmission: ()=>access.admission(),
|
|
161
167
|
async rosterEntries () {
|
|
162
168
|
return await access.read((group)=>group.listMembers().map((member)=>({
|
package/lib/recovery.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare function createRecoveryBindingState(identity: OwnIdentity, host?:
|
|
|
34
34
|
markBindingUnusable: () => void;
|
|
35
35
|
commitMessage: Uint8Array;
|
|
36
36
|
group: GroupHandle;
|
|
37
|
-
sourceTree: ClientState["ratchetTree"];
|
|
37
|
+
sourceTree: import("ts-mls").ClientState["ratchetTree"];
|
|
38
38
|
sourceRegistry: DeviceRegistry;
|
|
39
39
|
} | {
|
|
40
40
|
readonly renewalRequired: true;
|
package/lib/recovery.js
CHANGED
|
@@ -27,7 +27,8 @@ export function createRecoveryBindingState(identity, host) {
|
|
|
27
27
|
const bindingID = (value)=>JSON.stringify([
|
|
28
28
|
value.id,
|
|
29
29
|
value.prefix,
|
|
30
|
-
value.capability
|
|
30
|
+
value.capability,
|
|
31
|
+
value.holderGrant
|
|
31
32
|
]);
|
|
32
33
|
function markBindingUnusable(id) {
|
|
33
34
|
if (id == null) return;
|
|
@@ -56,7 +57,10 @@ export function createRecoveryBindingState(identity, host) {
|
|
|
56
57
|
return leaf?.controller == null || leaf.prefix == null || leaf.capability == null ? undefined : {
|
|
57
58
|
id: leaf.controller,
|
|
58
59
|
prefix: leaf.prefix,
|
|
59
|
-
capability: leaf.capability
|
|
60
|
+
capability: leaf.capability,
|
|
61
|
+
...leaf.holderGrant == null ? {} : {
|
|
62
|
+
holderGrant: leaf.holderGrant
|
|
63
|
+
}
|
|
60
64
|
};
|
|
61
65
|
}
|
|
62
66
|
async function request(group) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kumiai/mls-rpc",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"description": "The @kumiai/rpc consumer ports (GroupCrypto, GroupMLS) implemented over @kumiai/mls",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mls",
|
|
@@ -25,16 +25,16 @@
|
|
|
25
25
|
"lib/*"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@kokuin/token": "^0.5.
|
|
29
|
-
"@kumiai/mls": "^0.10.
|
|
30
|
-
"@kumiai/rpc": "^0.10.
|
|
28
|
+
"@kokuin/token": "^0.5.1",
|
|
29
|
+
"@kumiai/mls": "^0.10.6",
|
|
30
|
+
"@kumiai/rpc": "^0.10.8",
|
|
31
31
|
"@noble/ciphers": "^2.4.0",
|
|
32
32
|
"@sozai/runtime": "^0.1.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@kumiai/rpc-conformance": "^0.10.
|
|
35
|
+
"@kumiai/rpc-conformance": "^0.10.2",
|
|
36
36
|
"ts-mls": "2.0.0-rc.13",
|
|
37
|
-
"vitest": "^5.0.
|
|
37
|
+
"vitest": "^5.0.5"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|