@kumiai/mls 0.12.4 → 0.13.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.
- package/lib/anchor.d.ts +6 -2
- package/lib/anchor.js +1 -1
- package/lib/authentication.d.ts +8 -3
- package/lib/authentication.js +139 -46
- package/lib/capability.js +16 -7
- package/lib/controller-ingest.d.ts +14 -2
- package/lib/controller-ingest.js +15 -8
- package/lib/controller-log.d.ts +12 -6
- package/lib/controller-log.js +29 -15
- package/lib/device-proof.d.ts +2 -1
- package/lib/device-proof.js +2 -1
- package/lib/embedded-resolver.d.ts +7 -2
- package/lib/embedded-resolver.js +16 -6
- package/lib/envelope-fold.d.ts +3 -2
- package/lib/envelope-fold.js +14 -6
- package/lib/fold.d.ts +17 -3
- package/lib/fold.js +9 -3
- package/lib/group-commit.d.ts +11 -2
- package/lib/group-commit.js +76 -32
- package/lib/group-context.d.ts +3 -2
- package/lib/group-context.js +6 -2
- package/lib/group-create.d.ts +5 -1
- package/lib/group-create.js +36 -14
- package/lib/group-credential.d.ts +13 -3
- package/lib/group-credential.js +17 -6
- package/lib/group-device.d.ts +32 -22
- package/lib/group-device.js +66 -51
- package/lib/group-handle.d.ts +84 -30
- package/lib/group-handle.js +368 -154
- package/lib/group-lifecycle.d.ts +44 -11
- package/lib/group-lifecycle.js +193 -85
- package/lib/group-membership.d.ts +6 -1
- package/lib/group-membership.js +2 -2
- package/lib/group-welcome.d.ts +5 -1
- package/lib/group-welcome.js +34 -10
- package/lib/head.d.ts +25 -5
- package/lib/head.js +17 -8
- package/lib/history.d.ts +14 -3
- package/lib/history.js +8 -5
- package/lib/index.d.ts +27 -1
- package/lib/key-package-codec.d.ts +4 -1
- package/lib/key-package-codec.js +1 -1
- package/lib/ledger.d.ts +14 -6
- package/lib/ledger.js +56 -19
- package/lib/lifecycle-proof.d.ts +5 -4
- package/lib/lifecycle-proof.js +111 -51
- package/lib/lifecycle.d.ts +18 -9
- package/lib/lifecycle.js +184 -81
- package/lib/member-root.d.ts +54 -15
- package/lib/member-root.js +115 -53
- package/lib/policy.d.ts +5 -1
- package/lib/policy.js +1 -1
- package/lib/recovery-verdict.d.ts +12 -3
- package/lib/recovery-verdict.js +56 -22
- package/lib/recovery.d.ts +20 -5
- package/lib/recovery.js +117 -46
- package/lib/registry.d.ts +46 -10
- package/lib/registry.js +64 -38
- package/lib/roster.d.ts +7 -1
- package/lib/roster.js +18 -7
- package/lib/secret-tree.d.ts +5 -1
- package/lib/secret-tree.js +1 -1
- package/lib/types.d.ts +3 -0
- package/package.json +9 -5
package/lib/group-handle.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { CryptoProvider } from '@kokuin/crypto';
|
|
2
|
+
import { type CryptoOptions } from '@kokuin/token';
|
|
1
3
|
import { EventEmitter, type EventsSource } from '@sozai/event';
|
|
2
4
|
import { type IncomingMessageCallback, type MlsContext, type MlsFramedMessage, type ProposalWithSender } from 'ts-mls';
|
|
3
5
|
import { type GroupAnchor } from './anchor.js';
|
|
@@ -11,7 +13,25 @@ import { type Mutex } from './mutex.js';
|
|
|
11
13
|
import { type CommitPolicyContext } from './policy.js';
|
|
12
14
|
import { type DeviceOp, type DeviceRegistry } from './registry.js';
|
|
13
15
|
import type { RosterState } from './roster.js';
|
|
14
|
-
|
|
16
|
+
declare const CLONE_SOURCE: unique symbol;
|
|
17
|
+
type CloneGroupHandleParams = GroupHandleParams & {
|
|
18
|
+
[CLONE_SOURCE]: GroupHandle;
|
|
19
|
+
};
|
|
20
|
+
declare const FOLDED_CONTROL: unique symbol;
|
|
21
|
+
type FoldedControl = {
|
|
22
|
+
anchor: GroupAnchor;
|
|
23
|
+
roster: RosterState;
|
|
24
|
+
registry: DeviceRegistry;
|
|
25
|
+
admission: SendAdmission;
|
|
26
|
+
};
|
|
27
|
+
type FoldedGroupHandleParams = GroupHandleParams & {
|
|
28
|
+
[FOLDED_CONTROL]: FoldedControl;
|
|
29
|
+
};
|
|
30
|
+
export type RegistryAtParams = {
|
|
31
|
+
group: GroupHandle;
|
|
32
|
+
head: Uint8Array;
|
|
33
|
+
};
|
|
34
|
+
export declare function registryAt({ group, head }: RegistryAtParams): Promise<DeviceRegistry>;
|
|
15
35
|
export declare function mutexFor(handle: GroupHandle): Mutex;
|
|
16
36
|
/** Events a GroupHandle emits. Advisory notifications derived from the folded ledger; never
|
|
17
37
|
* a protocol input. Delivered via `fire` (a throwing listener never breaks a fold). */
|
|
@@ -47,11 +67,16 @@ export type SendAdmission = {
|
|
|
47
67
|
};
|
|
48
68
|
/** The full emitter for a handle — module-internal, for deriveGroup to share it onward. */
|
|
49
69
|
export declare function emitterOf(group: GroupHandle): EventEmitter<GroupHandleEvents>;
|
|
70
|
+
export type CommitRejectedErrorParams = {
|
|
71
|
+
proposals: Array<ProposalWithSender>;
|
|
72
|
+
senderLeafIndex?: number;
|
|
73
|
+
reason?: CommitRejectionReason;
|
|
74
|
+
};
|
|
50
75
|
/** Thrown by GroupHandle.processMessage when the commit policy rejects an incoming
|
|
51
76
|
* commit. The handle is left at its pre-commit epoch. */
|
|
52
77
|
export declare class CommitRejectedError extends Error {
|
|
53
78
|
#private;
|
|
54
|
-
constructor(proposals
|
|
79
|
+
constructor({ proposals, senderLeafIndex, reason }: CommitRejectedErrorParams);
|
|
55
80
|
get reason(): CommitRejectionReason;
|
|
56
81
|
get proposals(): Array<ProposalWithSender>;
|
|
57
82
|
get senderLeafIndex(): number | undefined;
|
|
@@ -71,7 +96,7 @@ export type LedgerLogEntry = HeldLedgerEntry & {
|
|
|
71
96
|
entryID: string;
|
|
72
97
|
};
|
|
73
98
|
export declare const VERIFIED_LEDGER_TOKEN_CACHE_SIZE = 4096;
|
|
74
|
-
export type GroupHandleParams = {
|
|
99
|
+
export type GroupHandleParams = CryptoOptions & {
|
|
75
100
|
state: ClientState;
|
|
76
101
|
credential: MemberCredential;
|
|
77
102
|
context: MlsContext;
|
|
@@ -90,10 +115,53 @@ export type GroupHandleParams = {
|
|
|
90
115
|
/** Defer authored control notifications until adoption. */
|
|
91
116
|
speculative?: boolean;
|
|
92
117
|
};
|
|
118
|
+
export type GroupHandleBootstrapLedgerParams = {
|
|
119
|
+
tokens: Array<string>;
|
|
120
|
+
persist?: (handle: GroupHandle) => Promise<void> | void;
|
|
121
|
+
};
|
|
122
|
+
export type GroupHandleExportSecretParams = {
|
|
123
|
+
label: string;
|
|
124
|
+
context: Uint8Array;
|
|
125
|
+
length?: number;
|
|
126
|
+
};
|
|
127
|
+
export type GroupHandleEncryptParams = {
|
|
128
|
+
plaintext: Uint8Array;
|
|
129
|
+
aad?: Uint8Array;
|
|
130
|
+
};
|
|
131
|
+
export type GroupHandleAdvanceSenderGenerationParams = {
|
|
132
|
+
target: number;
|
|
133
|
+
maxSteps?: number;
|
|
134
|
+
};
|
|
135
|
+
export type GroupHandleDecryptParams = {
|
|
136
|
+
message: Uint8Array;
|
|
137
|
+
expectedAAD?: Uint8Array;
|
|
138
|
+
};
|
|
139
|
+
export type GroupHandleDecryptStagedParams = {
|
|
140
|
+
message: Uint8Array;
|
|
141
|
+
opts: {
|
|
142
|
+
expectedAAD?: Uint8Array;
|
|
143
|
+
};
|
|
144
|
+
persist: (stagedState: Uint8Array, opened: {
|
|
145
|
+
payload: Uint8Array;
|
|
146
|
+
senderDID: string;
|
|
147
|
+
aad: Uint8Array;
|
|
148
|
+
}) => Promise<void>;
|
|
149
|
+
};
|
|
150
|
+
export type GroupHandleProcessMessageParams = {
|
|
151
|
+
message: Uint8Array | MlsFramedMessage;
|
|
152
|
+
commitPolicy?: IncomingMessageCallback;
|
|
153
|
+
persist?: (handle: GroupHandle) => Promise<void> | void;
|
|
154
|
+
};
|
|
93
155
|
/** Mutable wrapper around MLS group state + Enkaku credential. */
|
|
94
156
|
export declare class GroupHandle {
|
|
95
157
|
#private;
|
|
96
|
-
|
|
158
|
+
/**
|
|
159
|
+
* Seed control state from the genesis anchor in the group's GroupContext. This is the single
|
|
160
|
+
* choke no anchorless handle slips through: an absent anchor fails closed rather than
|
|
161
|
+
* installing a permissive roster.
|
|
162
|
+
*/
|
|
163
|
+
static create(params: GroupHandleParams): Promise<GroupHandle>;
|
|
164
|
+
constructor(params: CloneGroupHandleParams | FoldedGroupHandleParams);
|
|
97
165
|
/** Copy the current checkpoint without replaying ledger tokens or sharing mutable state.
|
|
98
166
|
* Pending adoption notifications belong to the source; the copy starts non-speculative. */
|
|
99
167
|
clone(options?: {
|
|
@@ -108,6 +176,8 @@ export declare class GroupHandle {
|
|
|
108
176
|
get credential(): MemberCredential;
|
|
109
177
|
get state(): ClientState;
|
|
110
178
|
get context(): MlsContext;
|
|
179
|
+
/** The kokuin provider this handle verifies with; carried onto clones and derived handles. */
|
|
180
|
+
get crypto(): CryptoProvider | undefined;
|
|
111
181
|
/** The commit policy enforced by processMessage, if any. Carried onto
|
|
112
182
|
* handles derived from this one (commitInvite/removeMember). */
|
|
113
183
|
get commitPolicy(): IncomingMessageCallback | undefined;
|
|
@@ -129,7 +199,7 @@ export declare class GroupHandle {
|
|
|
129
199
|
get roster(): RosterState;
|
|
130
200
|
/** The device registry folded from the anchor and every applied ledger entry. */
|
|
131
201
|
get registry(): DeviceRegistry;
|
|
132
|
-
settleAdvisory(): 'ok' | 'prompt' | 'blocked'
|
|
202
|
+
settleAdvisory(): Promise<'ok' | 'prompt' | 'blocked'>;
|
|
133
203
|
/**
|
|
134
204
|
* The device deny set the auth service consumes: the DIDs revoked in the CURRENTLY folded
|
|
135
205
|
* registry (pre-commit). Matched, never enumerated by consumers. A revoke takes deny-effect from
|
|
@@ -215,9 +285,7 @@ export declare class GroupHandle {
|
|
|
215
285
|
* call back into it. It must write atomically: rejection means nothing was stored.
|
|
216
286
|
* Host callbacks run after successful persist; a callback throw does not undo bootstrap.
|
|
217
287
|
*/
|
|
218
|
-
bootstrapLedger(tokens:
|
|
219
|
-
persist?: (handle: GroupHandle) => Promise<void> | void;
|
|
220
|
-
}): Promise<void>;
|
|
288
|
+
bootstrapLedger({ tokens, ...opts }: GroupHandleBootstrapLedgerParams): Promise<void>;
|
|
221
289
|
get memberCount(): number;
|
|
222
290
|
findMemberLeafIndex(id: string): number | undefined;
|
|
223
291
|
/**
|
|
@@ -273,7 +341,7 @@ export declare class GroupHandle {
|
|
|
273
341
|
* exporter secret, which is the epoch the blob being opened was sealed under. Both are silent
|
|
274
342
|
* consequences of this method's plainness; wrapping it "for consistency" breaks both.
|
|
275
343
|
*/
|
|
276
|
-
exportSecret(label
|
|
344
|
+
exportSecret({ label, context, length, }: GroupHandleExportSecretParams): Promise<Uint8Array>;
|
|
277
345
|
/**
|
|
278
346
|
* Author and retain an authenticated self-removal proposal under the handle mutex.
|
|
279
347
|
* Once a member processes a pending self-removal, application encrypt throws until
|
|
@@ -294,9 +362,7 @@ export declare class GroupHandle {
|
|
|
294
362
|
* carried in the clear, so a caller reading it back (or comparing via `decrypt`'s
|
|
295
363
|
* `expectedAAD`) needs no key. Defaults to empty.
|
|
296
364
|
*/
|
|
297
|
-
encrypt(plaintext
|
|
298
|
-
aad?: Uint8Array;
|
|
299
|
-
}): Promise<Uint8Array>;
|
|
365
|
+
encrypt({ plaintext, ...opts }: GroupHandleEncryptParams): Promise<Uint8Array>;
|
|
300
366
|
/**
|
|
301
367
|
* Move this member's own application ratchet forward so the next {@link encrypt} uses
|
|
302
368
|
* generation `target` — the generation read from
|
|
@@ -322,9 +388,7 @@ export declare class GroupHandle {
|
|
|
322
388
|
* removed or suspended member. `target` must be below 0xffffffff, the last generation.
|
|
323
389
|
* On any throw the handle state is unchanged and the secrets derived so far are zeroed.
|
|
324
390
|
*/
|
|
325
|
-
advanceSenderGeneration(target
|
|
326
|
-
maxSteps?: number;
|
|
327
|
-
}): Promise<void>;
|
|
391
|
+
advanceSenderGeneration({ target, ...opts }: GroupHandleAdvanceSenderGenerationParams): Promise<void>;
|
|
328
392
|
/**
|
|
329
393
|
* Reserve a handshake generation before building a commit from this handle.
|
|
330
394
|
* Reuse only a persisted, unconsumed reservation at the current epoch and generation.
|
|
@@ -363,9 +427,7 @@ export declare class GroupHandle {
|
|
|
363
427
|
* no ratchet generation, so a wrong-topic frame costs nothing to reject. The frame's AAD
|
|
364
428
|
* is always returned, whether or not `expectedAAD` was given.
|
|
365
429
|
*/
|
|
366
|
-
decrypt(message
|
|
367
|
-
expectedAAD?: Uint8Array;
|
|
368
|
-
}): Promise<{
|
|
430
|
+
decrypt({ message, ...opts }: GroupHandleDecryptParams): Promise<{
|
|
369
431
|
payload: Uint8Array;
|
|
370
432
|
senderDID?: string;
|
|
371
433
|
aad: Uint8Array;
|
|
@@ -376,13 +438,7 @@ export declare class GroupHandle {
|
|
|
376
438
|
* group's handle state. It must not call this handle or the peer. If opening or
|
|
377
439
|
* persistence fails, the live state and its ratchet secrets remain untouched.
|
|
378
440
|
*/
|
|
379
|
-
decryptStaged(message
|
|
380
|
-
expectedAAD?: Uint8Array;
|
|
381
|
-
}, persist: (stagedState: Uint8Array, opened: {
|
|
382
|
-
payload: Uint8Array;
|
|
383
|
-
senderDID: string;
|
|
384
|
-
aad: Uint8Array;
|
|
385
|
-
}) => Promise<void>): Promise<{
|
|
441
|
+
decryptStaged({ message, opts, persist }: GroupHandleDecryptStagedParams): Promise<{
|
|
386
442
|
payload: Uint8Array;
|
|
387
443
|
senderDID: string;
|
|
388
444
|
aad: Uint8Array;
|
|
@@ -443,10 +499,7 @@ export declare class GroupHandle {
|
|
|
443
499
|
* It must write atomically: rejection means nothing was stored. Host callbacks run
|
|
444
500
|
* after successful persist; a callback throw does not undo an advance.
|
|
445
501
|
*/
|
|
446
|
-
processMessage(message: Uint8Array |
|
|
447
|
-
commitPolicy?: IncomingMessageCallback;
|
|
448
|
-
persist?: (handle: GroupHandle) => Promise<void> | void;
|
|
449
|
-
}): Promise<Uint8Array | null>;
|
|
502
|
+
processMessage({ message, ...opts }: GroupHandleProcessMessageParams): Promise<Uint8Array | null>;
|
|
450
503
|
}
|
|
451
504
|
/** Build policy inputs shared by author and receiver gates. Entry ids drive the expected head. */
|
|
452
505
|
export declare function buildCommitPolicyContext(handle: GroupHandle, args: {
|
|
@@ -460,4 +513,5 @@ export declare function buildCommitPolicyContext(handle: GroupHandle, args: {
|
|
|
460
513
|
externalCommitDID?: string;
|
|
461
514
|
}): CommitPolicyContext;
|
|
462
515
|
/** Build the handle a commit hands back: the post-commit state, everything else inherited. */
|
|
463
|
-
export declare function deriveGroup(group: GroupHandle, state: ClientState): GroupHandle
|
|
516
|
+
export declare function deriveGroup(group: GroupHandle, state: ClientState): Promise<GroupHandle>;
|
|
517
|
+
export {};
|