@kumiai/mls 0.11.0 → 0.12.1
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 +30 -1
- package/lib/authentication.d.ts +6 -2
- package/lib/authentication.js +207 -51
- package/lib/capability.d.ts +4 -0
- package/lib/capability.js +22 -10
- package/lib/controller-ingest.d.ts +19 -0
- package/lib/controller-ingest.js +117 -0
- package/lib/controller-log.d.ts +6 -3
- package/lib/controller-log.js +52 -13
- package/lib/credential.d.ts +8 -5
- package/lib/credential.js +32 -3
- package/lib/device-proof.d.ts +5 -0
- package/lib/embedded-resolver.d.ts +8 -18
- package/lib/embedded-resolver.js +52 -24
- package/lib/errors.d.ts +8 -2
- package/lib/errors.js +11 -0
- package/lib/group-commit.d.ts +11 -2
- package/lib/group-commit.js +154 -46
- package/lib/group-context.d.ts +4 -2
- package/lib/group-context.js +30 -6
- package/lib/group-create.js +44 -16
- package/lib/group-credential.js +22 -1
- package/lib/group-device.js +5 -15
- package/lib/group-handle.d.ts +12 -1
- package/lib/group-handle.js +89 -12
- package/lib/group-lifecycle.d.ts +31 -5
- package/lib/group-lifecycle.js +253 -155
- package/lib/group-membership.js +1 -1
- package/lib/group-welcome.d.ts +4 -0
- package/lib/group-welcome.js +14 -2
- package/lib/history.d.ts +6 -0
- package/lib/history.js +20 -1
- package/lib/index.d.ts +12 -7
- package/lib/index.js +11 -6
- package/lib/lifecycle-proof.d.ts +15 -6
- package/lib/lifecycle-proof.js +195 -126
- package/lib/lifecycle.d.ts +9 -6
- package/lib/lifecycle.js +194 -84
- package/lib/member-root.d.ts +88 -0
- package/lib/member-root.js +480 -0
- package/lib/recovery-verdict.d.ts +1 -1
- package/lib/recovery-verdict.js +30 -13
- package/lib/registry.d.ts +17 -6
- package/lib/registry.js +206 -20
- package/lib/stale-leaf.d.ts +2 -0
- package/lib/stale-leaf.js +9 -4
- package/lib/types.d.ts +3 -0
- package/package.json +4 -4
package/lib/controller-log.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { foldLog } from '@kokuin/controller';
|
|
1
|
+
import { deviceRevokeIndices, digestOf, foldLog, pruneLog } from '@kokuin/controller';
|
|
2
2
|
import { normalizeDID } from '@kokuin/token';
|
|
3
3
|
export const CHAIN_REVOKE_REFUSED = 'chain revoke refused';
|
|
4
4
|
export function asControllerLog(chain) {
|
|
@@ -17,9 +17,12 @@ export function hasChainRevoke(chain) {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
export function foldChain(did, chain) {
|
|
20
|
+
return foldControllerLog(did, asControllerLog(chain));
|
|
21
|
+
}
|
|
22
|
+
export function foldControllerLog(did, log) {
|
|
20
23
|
// Kokuin 0.2 skips unsigned crit:false events, but a chain rev must never fold.
|
|
21
|
-
if (hasChainRevoke(chain)) {
|
|
22
|
-
const index = chain.findIndex((signed)=>hasChainRevoke([
|
|
24
|
+
if (hasChainRevoke(log.chain)) {
|
|
25
|
+
const index = log.chain.findIndex((signed)=>hasChainRevoke([
|
|
23
26
|
signed
|
|
24
27
|
]));
|
|
25
28
|
return {
|
|
@@ -28,17 +31,53 @@ export function foldChain(did, chain) {
|
|
|
28
31
|
index
|
|
29
32
|
};
|
|
30
33
|
}
|
|
31
|
-
return foldLog(did,
|
|
34
|
+
return foldLog(did, log);
|
|
35
|
+
}
|
|
36
|
+
export function revokeIndices(did, chain, subject) {
|
|
37
|
+
return deviceRevokeIndices(did, [
|
|
38
|
+
...chain
|
|
39
|
+
], subject);
|
|
40
|
+
}
|
|
41
|
+
export function memberDropIndices(did, chain, add) {
|
|
42
|
+
const folded = foldChain(did, chain);
|
|
43
|
+
if (!folded.ok) return [];
|
|
44
|
+
const indices = [];
|
|
45
|
+
for(let index = 1; index < chain.length; index++){
|
|
46
|
+
const state = folded.states[index];
|
|
47
|
+
const prior = folded.states[index - 1];
|
|
48
|
+
if (chain[index]?.event.t === 'rot' && state != null && prior != null && state.gen === prior.gen && prior.members.has(add) && !prior.members.get(add)?.removed && !state.members.has(add)) indices.push(index);
|
|
49
|
+
}
|
|
50
|
+
return indices;
|
|
51
|
+
}
|
|
52
|
+
/** Same-generation `rot` indices whose snapshot newly carries `add` as `member`'s removed incarnation. */ export function memberTombstoneIndices(did, chain, add, member) {
|
|
53
|
+
const folded = foldChain(did, chain);
|
|
54
|
+
if (!folded.ok) return [];
|
|
55
|
+
const indices = [];
|
|
56
|
+
for(let index = 1; index < chain.length; index++){
|
|
57
|
+
const state = folded.states[index];
|
|
58
|
+
const prior = folded.states[index - 1];
|
|
59
|
+
if (chain[index]?.event.t === 'rot' && state != null && prior != null && state.gen === prior.gen && prior.tombstones?.has(add) !== true && normalizeDID(state.tombstones?.get(add)?.did ?? '') === normalizeDID(member)) indices.push(index);
|
|
60
|
+
}
|
|
61
|
+
return indices;
|
|
62
|
+
}
|
|
63
|
+
export function closureOf(did, log, targets) {
|
|
64
|
+
const folded = foldControllerLog(did, log);
|
|
65
|
+
if (!folded.ok || folded.head.saturated) return undefined;
|
|
66
|
+
const applied = new Set(folded.applied);
|
|
67
|
+
if (targets.some((digest)=>!applied.has(digest))) return undefined;
|
|
68
|
+
const needed = new Set(targets);
|
|
69
|
+
const events = [];
|
|
70
|
+
// Applied copies are topologically ordered and closed under ancestry in an unsaturated epoch.
|
|
71
|
+
for (const signed of pruneLog(did, log).events.toReversed()){
|
|
72
|
+
if (!needed.has(digestOf(signed.event))) continue;
|
|
73
|
+
events.push(signed);
|
|
74
|
+
for (const parent of signed.event.p)needed.add(parent);
|
|
75
|
+
}
|
|
76
|
+
return structuredClone({
|
|
77
|
+
chain: log.chain,
|
|
78
|
+
events: events.reverse()
|
|
79
|
+
});
|
|
32
80
|
}
|
|
33
81
|
export function isDetachedFoldReason(reason) {
|
|
34
82
|
return /sequence|digest/.test(reason);
|
|
35
83
|
}
|
|
36
|
-
/** Requires a normalised subject DID. */ export function revokesSubject(chain, states, index, subject) {
|
|
37
|
-
const state = states[index];
|
|
38
|
-
const prior = states[index - 1];
|
|
39
|
-
if (index <= 0 || chain[index]?.event.t !== 'rot' || state == null || prior == null) return false;
|
|
40
|
-
const denies = (state)=>[
|
|
41
|
-
...state.deny
|
|
42
|
-
].some((did)=>normalizeDID(did) === subject);
|
|
43
|
-
return state.gen === prior.gen && denies(state) && !denies(prior);
|
|
44
|
-
}
|
package/lib/credential.d.ts
CHANGED
|
@@ -24,17 +24,20 @@ export type MemberCredential = {
|
|
|
24
24
|
* can stop honoring it without refusing leaves nothing is wrong with.
|
|
25
25
|
*/
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* verify the delegation; `capability` is the delegation token binding this device under the profile.
|
|
30
|
-
* All three are verification inputs — only the profile `id` is surfaced into `GroupMember`.
|
|
27
|
+
* Binds a leaf to a controller through a capability or its own membership incarnation.
|
|
28
|
+
* The prefix supplies controller authority. Membership `iat` orders bindings, never tree time.
|
|
31
29
|
*/
|
|
32
30
|
export type ControllerBinding = {
|
|
33
31
|
id: string;
|
|
34
32
|
prefix: Array<SignedEvent>;
|
|
35
|
-
capability
|
|
33
|
+
capability?: string;
|
|
36
34
|
/** The leaf holder's direct controller grant, required for chained capabilities. */
|
|
37
35
|
holderGrant?: string;
|
|
36
|
+
member?: {
|
|
37
|
+
add: string;
|
|
38
|
+
g: number;
|
|
39
|
+
};
|
|
40
|
+
iat?: number;
|
|
38
41
|
};
|
|
39
42
|
export type MLSCredentialIdentity = {
|
|
40
43
|
v?: 1;
|
package/lib/credential.js
CHANGED
|
@@ -17,7 +17,8 @@ export function parseMLSCredentialIdentity(identity) {
|
|
|
17
17
|
// Absent `v` is v1, permanently — not a default that will one day stop applying. Leaves
|
|
18
18
|
// written before this field existed are signed and can never be rewritten to add it.
|
|
19
19
|
if ('v' in candidate && candidate.v !== 1) {
|
|
20
|
-
|
|
20
|
+
const version = candidate.v !== null && typeof candidate.v === 'object' ? 'object' : String(candidate.v);
|
|
21
|
+
throw new Error(`Invalid MLS credential: unsupported identity version ${version}`);
|
|
21
22
|
}
|
|
22
23
|
if (typeof candidate.id !== 'string') {
|
|
23
24
|
throw new Error('Invalid MLS credential: id must be a string');
|
|
@@ -44,9 +45,29 @@ export function parseMLSCredentialIdentity(identity) {
|
|
|
44
45
|
if (typeof cc.id !== 'string') {
|
|
45
46
|
throw new Error('Invalid MLS credential: controller.id must be a string');
|
|
46
47
|
}
|
|
47
|
-
if (
|
|
48
|
+
if ('capability' in cc === 'member' in cc) {
|
|
49
|
+
throw new Error('Invalid MLS credential: controller requires exactly one binding form');
|
|
50
|
+
}
|
|
51
|
+
if ('capability' in cc && typeof cc.capability !== 'string') {
|
|
48
52
|
throw new Error('Invalid MLS credential: controller.capability must be a string');
|
|
49
53
|
}
|
|
54
|
+
let member;
|
|
55
|
+
if ('member' in cc) {
|
|
56
|
+
const claim = cc.member;
|
|
57
|
+
if (claim == null || typeof claim !== 'object' || Array.isArray(claim) || Object.keys(claim).length !== 2 || typeof claim.add !== 'string' || claim.add.length === 0 || typeof claim.g !== 'number' || !Number.isSafeInteger(claim.g) || claim.g < 0) {
|
|
58
|
+
throw new Error('Invalid MLS credential: controller.member must be a member claim');
|
|
59
|
+
}
|
|
60
|
+
member = {
|
|
61
|
+
add: claim.add,
|
|
62
|
+
g: claim.g
|
|
63
|
+
};
|
|
64
|
+
if (!('iat' in cc) || 'holderGrant' in cc) {
|
|
65
|
+
throw new Error('Invalid MLS credential: membership requires iat and no holderGrant');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if ('iat' in cc && (typeof cc.iat !== 'number' || !Number.isFinite(cc.iat))) {
|
|
69
|
+
throw new Error('Invalid MLS credential: controller.iat must be a finite number');
|
|
70
|
+
}
|
|
50
71
|
if (!Array.isArray(cc.prefix)) {
|
|
51
72
|
throw new Error('Invalid MLS credential: controller.prefix must be an array');
|
|
52
73
|
}
|
|
@@ -58,9 +79,17 @@ export function parseMLSCredentialIdentity(identity) {
|
|
|
58
79
|
result.controller = {
|
|
59
80
|
id: cc.id,
|
|
60
81
|
prefix: cc.prefix,
|
|
61
|
-
|
|
82
|
+
...typeof cc.capability === 'string' ? {
|
|
83
|
+
capability: cc.capability
|
|
84
|
+
} : {},
|
|
62
85
|
...typeof cc.holderGrant === 'string' ? {
|
|
63
86
|
holderGrant: cc.holderGrant
|
|
87
|
+
} : {},
|
|
88
|
+
...member == null ? {} : {
|
|
89
|
+
member
|
|
90
|
+
},
|
|
91
|
+
...typeof cc.iat === 'number' ? {
|
|
92
|
+
iat: cc.iat
|
|
64
93
|
} : {}
|
|
65
94
|
};
|
|
66
95
|
}
|
package/lib/device-proof.d.ts
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
import { type SignedEvent } from '@kokuin/controller';
|
|
2
|
-
import type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* `undefined` for any other DID, so no code path can reach a sidecar. `resolveDenySet` is overridden
|
|
7
|
-
* to answer from the injected group-folded set (freshness), rather than the prefix's frozen head.
|
|
8
|
-
*
|
|
9
|
-
* Member grants are unsupported: the prefix carries no epoch events, so members could only come
|
|
10
|
-
* from a stale snapshot.
|
|
11
|
-
*
|
|
12
|
-
* A per-leaf, one-shot instance: the prefix is small, verification is single-pass, and no `history`
|
|
13
|
-
* store is configured. This is the adapter the Slice 1 spike verified to run with zero external I/O.
|
|
14
|
-
*/
|
|
15
|
-
export declare function createEmbeddedControllerResolver(params: {
|
|
1
|
+
import { type ControllerLog, type ControllerResolver, type SignedEvent } from '@kokuin/controller';
|
|
2
|
+
import { type DeviceRegistry } from './registry.js';
|
|
3
|
+
export declare function prefixRelation(recorded: ControllerLog | undefined, prefix: ReadonlyArray<SignedEvent>): 'contained' | 'ahead' | 'forked' | 'none';
|
|
4
|
+
/** Root keys come from the leaf prefix; member authority comes from the recorded epoch. */
|
|
5
|
+
export declare function createRegistryControllerResolver(params: {
|
|
16
6
|
controllerID: string;
|
|
17
|
-
prefix:
|
|
18
|
-
|
|
19
|
-
}):
|
|
7
|
+
prefix: ReadonlyArray<SignedEvent>;
|
|
8
|
+
registry?: DeviceRegistry;
|
|
9
|
+
}): ControllerResolver;
|
package/lib/embedded-resolver.js
CHANGED
|
@@ -1,30 +1,58 @@
|
|
|
1
|
-
import { createControllerResolver } from '@kokuin/controller';
|
|
1
|
+
import { createControllerResolver, digestOf } from '@kokuin/controller';
|
|
2
|
+
import { normalizeDID } from '@kokuin/token';
|
|
2
3
|
import { asControllerLog, hasChainRevoke } from './controller-log.js';
|
|
4
|
+
import { denySetOf, recordedLogOf } from './registry.js';
|
|
3
5
|
const EMPTY = new Set();
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
6
|
+
export function prefixRelation(recorded, prefix) {
|
|
7
|
+
const held = recorded?.chain.at(-1);
|
|
8
|
+
const carried = prefix.at(-1);
|
|
9
|
+
if (recorded == null || held == null || carried == null) return 'none';
|
|
10
|
+
const carriedDigest = digestOf(carried.event);
|
|
11
|
+
if (recorded.chain.some((signed)=>digestOf(signed.event) === carriedDigest)) return 'contained';
|
|
12
|
+
const heldDigest = digestOf(held.event);
|
|
13
|
+
return prefix.some((signed)=>digestOf(signed.event) === heldDigest) ? 'ahead' : 'forked';
|
|
14
|
+
}
|
|
15
|
+
/** Root keys come from the leaf prefix; member authority comes from the recorded epoch. */ export function createRegistryControllerResolver(params) {
|
|
16
|
+
const controller = normalizeDID(params.controllerID);
|
|
17
|
+
const recorded = params.registry == null ? undefined : recordedLogOf(params.registry, controller);
|
|
18
|
+
const denied = params.registry == null ? EMPTY : denySetOf(params.registry);
|
|
19
|
+
const prefix = asControllerLog(params.prefix);
|
|
20
|
+
const resolverFor = (log)=>{
|
|
21
|
+
return createControllerResolver({
|
|
22
|
+
loadLog: async (did)=>normalizeDID(did) === controller && !hasChainRevoke(log.chain) ? log : undefined
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
const keys = resolverFor(prefix);
|
|
26
|
+
const members = recorded == null ? keys : resolverFor(recorded);
|
|
27
|
+
function view(keys, members) {
|
|
28
|
+
const { method, resolve, resolveHistoric, resolveAgreementKey } = keys;
|
|
29
|
+
return {
|
|
30
|
+
method,
|
|
31
|
+
resolve,
|
|
32
|
+
resolveHistoric,
|
|
33
|
+
resolveAgreementKey,
|
|
34
|
+
async resolveDenySet (did) {
|
|
35
|
+
if (normalizeDID(did) !== controller) throw new Error(`Unknown DID: ${did}`);
|
|
36
|
+
// Check saturation before substituting the group-folded denials.
|
|
37
|
+
await members.resolveDenySet?.(did);
|
|
38
|
+
return denied;
|
|
39
|
+
},
|
|
40
|
+
...params.registry == null ? {} : {
|
|
41
|
+
async resolveMember (did, query) {
|
|
42
|
+
if (normalizeDID(did) !== controller) throw new Error(`Unknown DID: ${did}`);
|
|
43
|
+
if (prefixRelation(recorded, params.prefix) !== 'contained') throw new Error('Recorded controller log does not contain the leaf prefix');
|
|
44
|
+
const member = await members.resolveMember?.(did, query);
|
|
45
|
+
if (member == null) throw new Error('Controller member resolution is unavailable');
|
|
46
|
+
return member;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
21
51
|
return {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
async resolveDenySet (_did) {
|
|
27
|
-
return params.denySet ?? EMPTY;
|
|
52
|
+
...view(keys, members),
|
|
53
|
+
frozen () {
|
|
54
|
+
const frozenKeys = keys.frozen();
|
|
55
|
+
return view(frozenKeys, members === keys ? frozenKeys : members.frozen());
|
|
28
56
|
}
|
|
29
57
|
};
|
|
30
58
|
}
|
package/lib/errors.d.ts
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
export type LeafBindingReason = 'missing-holder-evidence' | 'holder-evidence-mismatch' | 'issuer-mismatch' | 'audience-mismatch' | 'permission-denied' | 'signature-invalid' | 'confirmation-invalid' | 'subject-mismatch' | 'chain-depth' | 'self-issued' | 'child-outlives-parent' | 'denied-issuer' | 'denied-id' | 'renewal-order' | 'lifetime-cap' | 'generation-floor' | 'identity-change' | 'controller-mismatch' | 'floating-refused' | 'history-horizon';
|
|
1
|
+
export type LeafBindingReason = 'missing-holder-evidence' | 'holder-evidence-mismatch' | 'issuer-mismatch' | 'audience-mismatch' | 'permission-denied' | 'signature-invalid' | 'confirmation-invalid' | 'subject-mismatch' | 'chain-depth' | 'self-issued' | 'child-outlives-parent' | 'denied-issuer' | 'denied-id' | 'renewal-order' | 'lifetime-cap' | 'generation-floor' | 'identity-change' | 'controller-mismatch' | 'floating-refused' | 'history-horizon' | 'member-removed' | 'member-unavailable' | 'epoch-cap';
|
|
2
2
|
export declare class LeafBindingError extends Error {
|
|
3
3
|
#private;
|
|
4
4
|
constructor(reason: LeafBindingReason);
|
|
5
5
|
get reason(): LeafBindingReason;
|
|
6
6
|
}
|
|
7
7
|
export type LeafLapsedReason = 'lapsed';
|
|
8
|
+
export type RecoveryKnowledgeReason = 'revocation' | 'removal' | 'epoch-event' | 'attestation' | 'floor' | 'forked';
|
|
9
|
+
export declare class RecoveryKnowledgeError extends Error {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(reason: RecoveryKnowledgeReason);
|
|
12
|
+
get reason(): RecoveryKnowledgeReason;
|
|
13
|
+
}
|
|
8
14
|
export declare class LeafLapsedError extends Error {
|
|
9
15
|
#private;
|
|
10
16
|
constructor(reason: LeafLapsedReason);
|
|
11
17
|
get reason(): LeafLapsedReason;
|
|
12
18
|
}
|
|
13
|
-
export type RevokeProofReason = 'no-rev' | 'wrong-controller' | 'not-authority-signed' | 'generation-floor' | 'too-large' | 'detached' | 'needs-reset' | 'time-regression' | 'effects-mismatch' | 'removes-mismatch';
|
|
19
|
+
export type RevokeProofReason = 'no-rev' | 'wrong-controller' | 'not-authority-signed' | 'not-endorsed' | 'generation-floor' | 'too-large' | 'detached' | 'needs-reset' | 'time-regression' | 'effects-mismatch' | 'removes-mismatch';
|
|
14
20
|
export declare class RevokeProofError extends Error {
|
|
15
21
|
#private;
|
|
16
22
|
constructor(reason: RevokeProofReason);
|
package/lib/errors.js
CHANGED
|
@@ -9,6 +9,17 @@ export class LeafBindingError extends Error {
|
|
|
9
9
|
return this.#reason;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
+
export class RecoveryKnowledgeError extends Error {
|
|
13
|
+
#reason;
|
|
14
|
+
constructor(reason){
|
|
15
|
+
super(`Recovery drops known lifecycle knowledge: ${reason}`);
|
|
16
|
+
this.name = 'RecoveryKnowledgeError';
|
|
17
|
+
this.#reason = reason;
|
|
18
|
+
}
|
|
19
|
+
get reason() {
|
|
20
|
+
return this.#reason;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
12
23
|
export class LeafLapsedError extends Error {
|
|
13
24
|
#reason;
|
|
14
25
|
constructor(reason){
|
package/lib/group-commit.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { ControllerLog } from '@kokuin/controller';
|
|
1
2
|
import { type SigningIdentity } from '@kokuin/token';
|
|
2
|
-
import { type ClientState, createCommit, type DefaultProposal, type KeyPackage, type UnappliedProposals } from 'ts-mls';
|
|
3
|
+
import { type ClientState, createCommit, type DefaultProposal, type KeyPackage, type ProposalWithSender, type UnappliedProposals } from 'ts-mls';
|
|
3
4
|
import { type GroupHandle } from './group-handle.js';
|
|
4
5
|
import { type GroupPermission } from './roster.js';
|
|
5
6
|
import type { Invite } from './types.js';
|
|
@@ -22,6 +23,7 @@ export type CreateInviteParams = {
|
|
|
22
23
|
group: GroupHandle;
|
|
23
24
|
identity: SigningIdentity;
|
|
24
25
|
recipientDID: string;
|
|
26
|
+
controllerLog?: ControllerLog;
|
|
25
27
|
} & ({
|
|
26
28
|
permission: GroupPermission;
|
|
27
29
|
entries?: never;
|
|
@@ -34,6 +36,7 @@ export type CreateInviteResult = {
|
|
|
34
36
|
};
|
|
35
37
|
/** Create an invite without adding its recipient; commitInvite enacts the admission. */
|
|
36
38
|
export declare function createInvite(params: CreateInviteParams): Promise<CreateInviteResult>;
|
|
39
|
+
export declare function proposedTree(state: ClientState, proposals: Array<ProposalWithSender>): ClientState['ratchetTree'];
|
|
37
40
|
export type CommitWithEntriesParams = {
|
|
38
41
|
group: GroupHandle;
|
|
39
42
|
extraProposals: Array<DefaultProposal>;
|
|
@@ -65,7 +68,9 @@ export type CommitWithEntriesParams = {
|
|
|
65
68
|
* proposal advancing the head by exactly those ids, in envelope order. An empty list
|
|
66
69
|
* moves no head and carries no envelope.
|
|
67
70
|
*/
|
|
68
|
-
export declare function commitWithEntries(params: CommitWithEntriesParams): Promise<Awaited<ReturnType<typeof createCommit
|
|
71
|
+
export declare function commitWithEntries(params: CommitWithEntriesParams): Promise<Awaited<ReturnType<typeof createCommit>> & {
|
|
72
|
+
enacted: Array<string>;
|
|
73
|
+
}>;
|
|
69
74
|
export type CommitLedgerEntriesResult = {
|
|
70
75
|
/** Framed MLSMessage bytes. Broadcast to existing members via the DS. */
|
|
71
76
|
commitMessage: Uint8Array;
|
|
@@ -94,6 +99,8 @@ export type CommitLedgerEntriesResult = {
|
|
|
94
99
|
*/
|
|
95
100
|
export declare function commitLedgerEntries(group: GroupHandle, tokens: Array<string>): Promise<CommitLedgerEntriesResult>;
|
|
96
101
|
export type CommitInviteResult = {
|
|
102
|
+
/** The input invite, updated with the complete ledger, including any preservation clock. */
|
|
103
|
+
invite: Invite;
|
|
97
104
|
/** Framed MLSMessage bytes. Broadcast to existing members via the DS. */
|
|
98
105
|
commitMessage: Uint8Array;
|
|
99
106
|
/** Framed MLSMessage(Welcome) bytes. Delivered to the new member. */
|
|
@@ -118,6 +125,8 @@ export type CommitInviteResult = {
|
|
|
118
125
|
* The invite carries the group's whole history (a joiner has nothing to fold it onto),
|
|
119
126
|
* but only the entries beyond that history ride the commit — see
|
|
120
127
|
* {@link entriesAddedByInvite} and {@link commitWithEntries}.
|
|
128
|
+
* On success, updates the input invite with the complete ledger for delivery with the Welcome.
|
|
129
|
+
* Failed attempts leave it unchanged. Retries always build from its original ledger entries.
|
|
121
130
|
*
|
|
122
131
|
* Reads `group` and returns a NEW derived handle (`newGroup`); it never advances
|
|
123
132
|
* `group`. The caller MUST adopt `newGroup` — never reuse `group` — before the next
|