@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.
Files changed (64) hide show
  1. package/lib/anchor.d.ts +6 -2
  2. package/lib/anchor.js +1 -1
  3. package/lib/authentication.d.ts +8 -3
  4. package/lib/authentication.js +139 -46
  5. package/lib/capability.js +16 -7
  6. package/lib/controller-ingest.d.ts +14 -2
  7. package/lib/controller-ingest.js +15 -8
  8. package/lib/controller-log.d.ts +12 -6
  9. package/lib/controller-log.js +29 -15
  10. package/lib/device-proof.d.ts +2 -1
  11. package/lib/device-proof.js +2 -1
  12. package/lib/embedded-resolver.d.ts +7 -2
  13. package/lib/embedded-resolver.js +16 -6
  14. package/lib/envelope-fold.d.ts +3 -2
  15. package/lib/envelope-fold.js +14 -6
  16. package/lib/fold.d.ts +17 -3
  17. package/lib/fold.js +9 -3
  18. package/lib/group-commit.d.ts +11 -2
  19. package/lib/group-commit.js +76 -32
  20. package/lib/group-context.d.ts +3 -2
  21. package/lib/group-context.js +6 -2
  22. package/lib/group-create.d.ts +5 -1
  23. package/lib/group-create.js +36 -14
  24. package/lib/group-credential.d.ts +13 -3
  25. package/lib/group-credential.js +17 -6
  26. package/lib/group-device.d.ts +32 -22
  27. package/lib/group-device.js +66 -51
  28. package/lib/group-handle.d.ts +84 -30
  29. package/lib/group-handle.js +368 -154
  30. package/lib/group-lifecycle.d.ts +44 -11
  31. package/lib/group-lifecycle.js +193 -85
  32. package/lib/group-membership.d.ts +6 -1
  33. package/lib/group-membership.js +2 -2
  34. package/lib/group-welcome.d.ts +5 -1
  35. package/lib/group-welcome.js +34 -10
  36. package/lib/head.d.ts +25 -5
  37. package/lib/head.js +17 -8
  38. package/lib/history.d.ts +14 -3
  39. package/lib/history.js +8 -5
  40. package/lib/index.d.ts +27 -1
  41. package/lib/key-package-codec.d.ts +4 -1
  42. package/lib/key-package-codec.js +1 -1
  43. package/lib/ledger.d.ts +14 -6
  44. package/lib/ledger.js +56 -19
  45. package/lib/lifecycle-proof.d.ts +5 -4
  46. package/lib/lifecycle-proof.js +111 -51
  47. package/lib/lifecycle.d.ts +18 -9
  48. package/lib/lifecycle.js +184 -81
  49. package/lib/member-root.d.ts +54 -15
  50. package/lib/member-root.js +115 -53
  51. package/lib/policy.d.ts +5 -1
  52. package/lib/policy.js +1 -1
  53. package/lib/recovery-verdict.d.ts +12 -3
  54. package/lib/recovery-verdict.js +56 -22
  55. package/lib/recovery.d.ts +20 -5
  56. package/lib/recovery.js +117 -46
  57. package/lib/registry.d.ts +46 -10
  58. package/lib/registry.js +64 -38
  59. package/lib/roster.d.ts +7 -1
  60. package/lib/roster.js +18 -7
  61. package/lib/secret-tree.d.ts +5 -1
  62. package/lib/secret-tree.js +1 -1
  63. package/lib/types.d.ts +3 -0
  64. package/package.json +9 -5
@@ -10,7 +10,7 @@ import { GroupHandle } from './group-handle.js';
10
10
  import { buildLedgerHeadExtension, extendHead, genesisHead } from './head.js';
11
11
  import { ledgerEntryDigest, signLedgerEntry } from './ledger.js';
12
12
  import { DEVICE_ENTRY_TYPE, registryForLog } from './registry.js';
13
- /** Create a new MLS group. The identity becomes the sole member and admin. */ export async function createGroup(identity, groupID, options) {
13
+ /** Create a new MLS group. The identity becomes the sole member and admin. */ export async function createGroup({ identity, groupID, ...options }) {
14
14
  assertBindingAuthorTime(options?.controller);
15
15
  // A binding enriches a supplied anchor before genesis; standard anchor bytes stay untouched.
16
16
  // Existing lifecycle fields must agree with the authored policy before the tree is validated.
@@ -45,7 +45,9 @@ import { DEVICE_ENTRY_TYPE, registryForLog } from './registry.js';
45
45
  }
46
46
  }
47
47
  if (suppliedAnchorExtension == null) {
48
- extensions.push(options?.controller == null ? buildCurrentGroupAnchorExtension(identity.id) : buildGroupAnchorExtension({
48
+ extensions.push(options?.controller == null ? buildCurrentGroupAnchorExtension({
49
+ creatorDID: identity.id
50
+ }) : buildGroupAnchorExtension({
49
51
  creatorDID: identity.id,
50
52
  version: 1,
51
53
  controller: options.controller.id,
@@ -66,23 +68,38 @@ import { DEVICE_ENTRY_TYPE, registryForLog } from './registry.js';
66
68
  throw new LeafBindingError('controller-mismatch');
67
69
  }
68
70
  if (anchor.controller != null && options?.controllerLog == null) throw new LeafBindingError('member-unavailable');
69
- const registry = anchor.controller == null || options?.controllerLog == null ? undefined : registryForLog(anchor.controller, options.controllerLog);
71
+ const registry = anchor.controller == null || options?.controllerLog == null ? undefined : await registryForLog({
72
+ controller: anchor.controller,
73
+ log: options.controllerLog,
74
+ crypto: options.crypto
75
+ });
70
76
  const tokens = [];
71
77
  if (anchor.controller != null && options?.controllerLog != null) {
72
- tokens.push(await signLedgerEntry(identity, {
73
- type: DEVICE_ENTRY_TYPE,
74
- groupID,
75
- subject: anchor.controller,
76
- value: {
77
- op: 'seed',
78
- proof: pruneLog(anchor.controller, options.controllerLog)
78
+ tokens.push(await signLedgerEntry({
79
+ identity,
80
+ entry: {
81
+ type: DEVICE_ENTRY_TYPE,
82
+ groupID,
83
+ subject: anchor.controller,
84
+ value: {
85
+ op: 'seed',
86
+ proof: await pruneLog({
87
+ crypto: options.crypto,
88
+ did: anchor.controller,
89
+ input: options.controllerLog
90
+ })
91
+ }
79
92
  }
80
93
  }));
81
94
  }
82
95
  const context = await resolveMlsContext(options, anchor);
83
- const mlsCredential = makeMLSCredential(identity, options?.controller);
96
+ const mlsCredential = makeMLSCredential({
97
+ identity,
98
+ controller: options?.controller
99
+ });
84
100
  if (options?.controller != null) {
85
101
  await verifyLeafCredential(mlsCredential, identity.publicKey, {
102
+ crypto: options.crypto,
86
103
  judging: ()=>({
87
104
  registry,
88
105
  stage: 'full',
@@ -92,7 +109,10 @@ import { DEVICE_ENTRY_TYPE, registryForLog } from './registry.js';
92
109
  trustedGrantLifetime: ()=>anchor.trustedGrantLifetime ?? 2_592_000
93
110
  });
94
111
  }
95
- const head = buildLedgerHeadExtension(extendHead(genesisHead(groupID), tokens.map(ledgerEntryDigest)));
112
+ const head = buildLedgerHeadExtension(extendHead({
113
+ head: genesisHead(groupID),
114
+ entryIDs: tokens.map(ledgerEntryDigest)
115
+ }));
96
116
  const headIndex = extensions.findIndex((ext)=>ext.extensionType === LEDGER_HEAD_EXTENSION_TYPE);
97
117
  if (tokens.length > 0 && headIndex >= 0) extensions[headIndex] = head;
98
118
  else if (headIndex < 0) extensions.push(head);
@@ -122,7 +142,8 @@ import { DEVICE_ENTRY_TYPE, registryForLog } from './registry.js';
122
142
  id: identity.id,
123
143
  groupID
124
144
  };
125
- const group = new GroupHandle({
145
+ const group = await GroupHandle.create({
146
+ crypto: options?.crypto,
126
147
  state,
127
148
  credential,
128
149
  context,
@@ -139,7 +160,8 @@ import { DEVICE_ENTRY_TYPE, registryForLog } from './registry.js';
139
160
  export async function restoreGroup(params) {
140
161
  // Construction reseeds control authority from the anchor in the restored state;
141
162
  // an anchorless state throws (the same fail-closed guard).
142
- const group = new GroupHandle({
163
+ const group = await GroupHandle.create({
164
+ crypto: params.options?.crypto,
143
165
  state: params.state,
144
166
  credential: params.credential,
145
167
  context: await resolveMlsContext(params.options),
@@ -2,7 +2,11 @@ import { type OwnIdentity } from '@kokuin/token';
2
2
  import { type Credential } from 'ts-mls';
3
3
  import type { ControllerBinding } from './credential.js';
4
4
  import type { GroupOptions, KeyPackageBundle } from './types.js';
5
- export declare function makeMLSCredential(identity: OwnIdentity, controller?: ControllerBinding): Credential;
5
+ export type MakeMLSCredentialParams = {
6
+ identity: OwnIdentity;
7
+ controller?: ControllerBinding;
8
+ };
9
+ export declare function makeMLSCredential({ identity, controller }: MakeMLSCredentialParams): Credential;
6
10
  export declare function assertBindingAuthorTime(controller?: ControllerBinding): void;
7
11
  /**
8
12
  * How long an ordinary, single-use key package stays valid, in days.
@@ -13,8 +17,11 @@ export declare function assertBindingAuthorTime(controller?: ControllerBinding):
13
17
  * declares, and makes a weekly top-up comfortable rather than marginal.
14
18
  */
15
19
  export declare const ORDINARY_KEY_PACKAGE_LIFETIME_DAYS = 30;
20
+ export type CreateKeyPackageBundleParams = {
21
+ identity: OwnIdentity;
22
+ } & GroupOptions;
16
23
  /** Generate a key package for joining groups. */
17
- export declare function createKeyPackageBundle(identity: OwnIdentity, options?: GroupOptions): Promise<KeyPackageBundle>;
24
+ export declare function createKeyPackageBundle({ identity, ...options }: CreateKeyPackageBundleParams): Promise<KeyPackageBundle>;
18
25
  /**
19
26
  * The `last_resort` KeyPackage extension from draft-ietf-mls-extensions (NOT RFC 9420, which has
20
27
  * no such extension). Its presence marks a key package as reusable by design; its data is empty.
@@ -44,6 +51,9 @@ export declare const LAST_RESORT_EXTENSION_TYPE = 10;
44
51
  * floor disappears exactly when it is needed.
45
52
  */
46
53
  export declare const LAST_RESORT_LIFETIME_DAYS = 90;
54
+ export type CreateLastResortKeyPackageBundleParams = {
55
+ identity: OwnIdentity;
56
+ } & GroupOptions;
47
57
  /**
48
58
  * Generate a reusable last-resort key package for joining groups.
49
59
  *
@@ -61,4 +71,4 @@ export declare const LAST_RESORT_LIFETIME_DAYS = 90;
61
71
  * package stops working while the hub still reports the slot as full and keeps serving it. Both
62
72
  * obligations fail the same way: silently, and precisely when the floor is needed.
63
73
  */
64
- export declare function createLastResortKeyPackageBundle(identity: OwnIdentity, options?: GroupOptions): Promise<KeyPackageBundle>;
74
+ export declare function createLastResortKeyPackageBundle({ identity, ...options }: CreateLastResortKeyPackageBundleParams): Promise<KeyPackageBundle>;
@@ -7,7 +7,7 @@ import { LeafBindingError } from './errors.js';
7
7
  import { resolveMlsContext } from './group-context.js';
8
8
  import { memberRootsOf } from './member-root.js';
9
9
  import { registryForLog } from './registry.js';
10
- export function makeMLSCredential(identity, controller) {
10
+ export function makeMLSCredential({ identity, controller }) {
11
11
  const id = identity.id;
12
12
  const isPeer = isPeer4(id);
13
13
  if (isPeer && !('longForm' in identity && typeof identity.longForm === 'string')) {
@@ -51,12 +51,23 @@ export function assertBindingAuthorTime(controller) {
51
51
  * applies for the ordinary path.
52
52
  */ async function buildBundle(identity, options, overrides = {}) {
53
53
  assertBindingAuthorTime(options?.controller);
54
- const credential = makeMLSCredential(identity, options?.controller);
54
+ const credential = makeMLSCredential({
55
+ identity,
56
+ controller: options?.controller
57
+ });
55
58
  if (options?.controller != null) {
56
- const memberRooted = memberRootsOf(options.controller, identity.id).some(({ root })=>root.kind === 'member');
59
+ const memberRooted = memberRootsOf({
60
+ binding: options.controller,
61
+ leafDID: identity.id
62
+ }).some(({ root })=>root.kind === 'member');
57
63
  if (memberRooted && options.controllerLog == null) throw new LeafBindingError('member-unavailable');
58
- const registry = memberRooted && options.controllerLog != null ? registryForLog(options.controller.id, options.controllerLog) : undefined;
64
+ const registry = memberRooted && options.controllerLog != null ? await registryForLog({
65
+ controller: options.controller.id,
66
+ log: options.controllerLog,
67
+ crypto: options.crypto
68
+ }) : undefined;
59
69
  await verifyLeafCredential(credential, identity.publicKey, {
70
+ crypto: options.crypto,
60
71
  judging: ()=>({
61
72
  registry,
62
73
  stage: 'full',
@@ -101,7 +112,7 @@ export function assertBindingAuthorTime(controller) {
101
112
  notAfter: BigInt(nowSeconds + ORDINARY_KEY_PACKAGE_LIFETIME_DAYS * 86_400)
102
113
  };
103
114
  }
104
- /** Generate a key package for joining groups. */ export async function createKeyPackageBundle(identity, options) {
115
+ /** Generate a key package for joining groups. */ export async function createKeyPackageBundle({ identity, ...options }) {
105
116
  return buildBundle(identity, options, {
106
117
  lifetime: ordinaryLifetime()
107
118
  });
@@ -156,7 +167,7 @@ export function assertBindingAuthorTime(controller) {
156
167
  * carries an MLS lifetime, and an inviter validates it when building the Add — so an unrotated
157
168
  * package stops working while the hub still reports the slot as full and keeps serving it. Both
158
169
  * obligations fail the same way: silently, and precisely when the floor is needed.
159
- */ export async function createLastResortKeyPackageBundle(identity, options) {
170
+ */ export async function createLastResortKeyPackageBundle({ identity, ...options }) {
160
171
  return buildBundle(identity, options, {
161
172
  // Supplying `extensions` at all suppresses ts-mls's own default of
162
173
  // `greaseExtensions(defaultGreaseConfig)`. `defaultGreaseConfig` is not exported, so its 0.1
@@ -8,40 +8,51 @@ export type DeviceWriteResult = {
8
8
  /** Post-commit epoch (== newGroup.epoch). */
9
9
  epoch: bigint;
10
10
  };
11
+ type GroupSigner = {
12
+ group: GroupHandle;
13
+ identity: SigningIdentity;
14
+ };
15
+ export type RegisterDeviceParams = GroupSigner & {
16
+ device: string;
17
+ controller: string;
18
+ capability?: string;
19
+ };
11
20
  /**
12
21
  * Record a `device -> controller` binding: self-attested (leaf) when `device` is the caller's own,
13
22
  * or management-capability-authorized (`capability`) when recording a co-device already in the
14
23
  * group. Proof gating runs in `commitWithEntries` (authoring side) and every receiver's pipeline —
15
24
  * no admin role is required. Returns the commit bytes to broadcast.
16
25
  */
17
- export declare function registerDevice(group: GroupHandle, identity: SigningIdentity, params: {
26
+ export declare function registerDevice({ group, identity, ...params }: RegisterDeviceParams): Promise<DeviceWriteResult>;
27
+ export type LabelDeviceParams = GroupSigner & {
18
28
  device: string;
19
- controller: string;
20
- capability?: string;
21
- }): Promise<DeviceWriteResult>;
29
+ label: string;
30
+ capability: string;
31
+ };
22
32
  /**
23
33
  * Rename a device already bound in the registry. A manage op — authorized by the profile's
24
34
  * management capability (the issuer is a device of `controllerOf(device)`); no admin role required.
25
35
  */
26
- export declare function labelDevice(group: GroupHandle, identity: SigningIdentity, params: {
36
+ export declare function labelDevice({ group, identity, ...params }: LabelDeviceParams): Promise<DeviceWriteResult>;
37
+ export type AddDeviceParams = GroupSigner & {
38
+ keyPackage: KeyPackage;
27
39
  device: string;
28
- label: string;
40
+ controller: string;
29
41
  capability: string;
30
- }): Promise<DeviceWriteResult>;
42
+ };
31
43
  /**
32
44
  * Bring a co-device into the group WITHOUT a group admin: an MLS Add of the new device's key
33
45
  * package plus a `kumiai.device` `add` entry, both authorized by the profile's management
34
46
  * capability. Binds the added leaf to `device`/`controller` (the key package must present `device`).
35
47
  * Returns the Commit + Welcome bytes.
36
48
  */
37
- export declare function addDevice(group: GroupHandle, identity: SigningIdentity, params: {
38
- keyPackage: KeyPackage;
39
- device: string;
40
- controller: string;
41
- capability: string;
42
- }): Promise<DeviceWriteResult & {
49
+ export declare function addDevice({ group, identity, ...params }: AddDeviceParams): Promise<DeviceWriteResult & {
43
50
  welcomeMessage: Uint8Array;
44
51
  }>;
52
+ export type RevokeDeviceParams = GroupSigner & {
53
+ device: string;
54
+ capability: string;
55
+ };
45
56
  /**
46
57
  * Revoke a device: ONE commit, TWO effects, matching the two surfaces the kokuin security doc
47
58
  * sanctions. (1) a `kumiai.device` `revoke` entry — folds the subject to `revoked`, so the derived
@@ -50,18 +61,17 @@ export declare function addDevice(group: GroupHandle, identity: SigningIdentity,
50
61
  * stale leaf; the Remove alone lets it rejoin on its still-valid bound-leaf capability). Both are
51
62
  * required. Authorized by the profile's management capability; no admin role.
52
63
  */
53
- export declare function revokeDevice(group: GroupHandle, identity: SigningIdentity, params: {
54
- device: string;
55
- capability: string;
56
- }): Promise<DeviceWriteResult>;
64
+ export declare function revokeDevice({ group, identity, ...params }: RevokeDeviceParams): Promise<DeviceWriteResult>;
65
+ export type AnnounceControllerBeaconParams = GroupSigner & {
66
+ controller: string;
67
+ logLength: number;
68
+ headDigest: string;
69
+ };
57
70
  /**
58
71
  * Announce the controller's FULL log head into the group as folded, cross-peer-consistent state.
59
72
  * Advisory only — it gates nothing. Authored by any bound device of `controller` (self-scoped, no
60
73
  * management capability). Publish only-on-change and only when the log meaningfully advances: each
61
74
  * call is a permanent ledger entry (replayed at every welcome, no compaction).
62
75
  */
63
- export declare function announceControllerBeacon(group: GroupHandle, identity: SigningIdentity, params: {
64
- controller: string;
65
- logLength: number;
66
- headDigest: string;
67
- }): Promise<DeviceWriteResult>;
76
+ export declare function announceControllerBeacon({ group, identity, ...params }: AnnounceControllerBeaconParams): Promise<DeviceWriteResult>;
77
+ export {};
@@ -10,18 +10,21 @@ import { DEVICE_ENTRY_TYPE } from './registry.js';
10
10
  * or management-capability-authorized (`capability`) when recording a co-device already in the
11
11
  * group. Proof gating runs in `commitWithEntries` (authoring side) and every receiver's pipeline —
12
12
  * no admin role is required. Returns the commit bytes to broadcast.
13
- */ export async function registerDevice(group, identity, params) {
13
+ */ export async function registerDevice({ group, identity, ...params }) {
14
14
  return mutexFor(group).run(async ()=>{
15
- const token = await signLedgerEntry(identity, {
16
- type: DEVICE_ENTRY_TYPE,
17
- groupID: group.groupID,
18
- subject: params.device,
19
- value: {
20
- op: 'register',
21
- controller: params.controller,
22
- ...params.capability != null ? {
23
- capability: params.capability
24
- } : {}
15
+ const token = await signLedgerEntry({
16
+ identity,
17
+ entry: {
18
+ type: DEVICE_ENTRY_TYPE,
19
+ groupID: group.groupID,
20
+ subject: params.device,
21
+ value: {
22
+ op: 'register',
23
+ controller: params.controller,
24
+ ...params.capability != null ? {
25
+ capability: params.capability
26
+ } : {}
27
+ }
25
28
  }
26
29
  });
27
30
  const result = await commitWithEntries({
@@ -32,7 +35,7 @@ import { DEVICE_ENTRY_TYPE } from './registry.js';
32
35
  ],
33
36
  requireAdmin: false
34
37
  });
35
- const newGroup = deriveGroup(group, result.newState);
38
+ const newGroup = await deriveGroup(group, result.newState);
36
39
  await newGroup.applyLedgerEntries(result.enacted);
37
40
  return {
38
41
  commitMessage: encode(mlsMessageEncoder, result.commit),
@@ -44,16 +47,19 @@ import { DEVICE_ENTRY_TYPE } from './registry.js';
44
47
  /**
45
48
  * Rename a device already bound in the registry. A manage op — authorized by the profile's
46
49
  * management capability (the issuer is a device of `controllerOf(device)`); no admin role required.
47
- */ export async function labelDevice(group, identity, params) {
50
+ */ export async function labelDevice({ group, identity, ...params }) {
48
51
  return mutexFor(group).run(async ()=>{
49
- const token = await signLedgerEntry(identity, {
50
- type: DEVICE_ENTRY_TYPE,
51
- groupID: group.groupID,
52
- subject: params.device,
53
- value: {
54
- op: 'label',
55
- label: params.label,
56
- capability: params.capability
52
+ const token = await signLedgerEntry({
53
+ identity,
54
+ entry: {
55
+ type: DEVICE_ENTRY_TYPE,
56
+ groupID: group.groupID,
57
+ subject: params.device,
58
+ value: {
59
+ op: 'label',
60
+ label: params.label,
61
+ capability: params.capability
62
+ }
57
63
  }
58
64
  });
59
65
  const result = await commitWithEntries({
@@ -64,7 +70,7 @@ import { DEVICE_ENTRY_TYPE } from './registry.js';
64
70
  ],
65
71
  requireAdmin: false
66
72
  });
67
- const newGroup = deriveGroup(group, result.newState);
73
+ const newGroup = await deriveGroup(group, result.newState);
68
74
  await newGroup.applyLedgerEntries(result.enacted);
69
75
  return {
70
76
  commitMessage: encode(mlsMessageEncoder, result.commit),
@@ -78,7 +84,7 @@ import { DEVICE_ENTRY_TYPE } from './registry.js';
78
84
  * package plus a `kumiai.device` `add` entry, both authorized by the profile's management
79
85
  * capability. Binds the added leaf to `device`/`controller` (the key package must present `device`).
80
86
  * Returns the Commit + Welcome bytes.
81
- */ export async function addDevice(group, identity, params) {
87
+ */ export async function addDevice({ group, identity, ...params }) {
82
88
  return mutexFor(group).run(async ()=>{
83
89
  // Bind the added leaf to the entry's subject — the key package must present `device`.
84
90
  const credential = params.keyPackage.leafNode.credential;
@@ -89,14 +95,17 @@ import { DEVICE_ENTRY_TYPE } from './registry.js';
89
95
  if (presentedDID !== normalizeDID(params.device)) {
90
96
  throw new Error(`addDevice: the key package presents ${presentedDID}, not the device ${normalizeDID(params.device)}`);
91
97
  }
92
- const token = await signLedgerEntry(identity, {
93
- type: DEVICE_ENTRY_TYPE,
94
- groupID: group.groupID,
95
- subject: params.device,
96
- value: {
97
- op: 'add',
98
- controller: params.controller,
99
- capability: params.capability
98
+ const token = await signLedgerEntry({
99
+ identity,
100
+ entry: {
101
+ type: DEVICE_ENTRY_TYPE,
102
+ groupID: group.groupID,
103
+ subject: params.device,
104
+ value: {
105
+ op: 'add',
106
+ controller: params.controller,
107
+ capability: params.capability
108
+ }
100
109
  }
101
110
  });
102
111
  const addProposal = {
@@ -119,7 +128,7 @@ import { DEVICE_ENTRY_TYPE } from './registry.js';
119
128
  if (result.welcome == null) {
120
129
  throw new Error('addDevice: expected a Welcome message for the add proposal');
121
130
  }
122
- const newGroup = deriveGroup(group, result.newState);
131
+ const newGroup = await deriveGroup(group, result.newState);
123
132
  await newGroup.applyLedgerEntries(result.enacted);
124
133
  return {
125
134
  commitMessage: encode(mlsMessageEncoder, result.commit),
@@ -136,15 +145,18 @@ import { DEVICE_ENTRY_TYPE } from './registry.js';
136
145
  * subject currently holds a leaf, an MLS Remove of it in the SAME commit (the deny set alone leaves a
137
146
  * stale leaf; the Remove alone lets it rejoin on its still-valid bound-leaf capability). Both are
138
147
  * required. Authorized by the profile's management capability; no admin role.
139
- */ export async function revokeDevice(group, identity, params) {
148
+ */ export async function revokeDevice({ group, identity, ...params }) {
140
149
  return mutexFor(group).run(async ()=>{
141
- const token = await signLedgerEntry(identity, {
142
- type: DEVICE_ENTRY_TYPE,
143
- groupID: group.groupID,
144
- subject: params.device,
145
- value: {
146
- op: 'revoke',
147
- capability: params.capability
150
+ const token = await signLedgerEntry({
151
+ identity,
152
+ entry: {
153
+ type: DEVICE_ENTRY_TYPE,
154
+ groupID: group.groupID,
155
+ subject: params.device,
156
+ value: {
157
+ op: 'revoke',
158
+ capability: params.capability
159
+ }
148
160
  }
149
161
  });
150
162
  const leafIndex = group.findMemberLeafIndex(params.device);
@@ -164,7 +176,7 @@ import { DEVICE_ENTRY_TYPE } from './registry.js';
164
176
  ],
165
177
  requireAdmin: false
166
178
  });
167
- const newGroup = deriveGroup(group, result.newState);
179
+ const newGroup = await deriveGroup(group, result.newState);
168
180
  await newGroup.applyLedgerEntries(result.enacted);
169
181
  return {
170
182
  commitMessage: encode(mlsMessageEncoder, result.commit),
@@ -178,16 +190,19 @@ import { DEVICE_ENTRY_TYPE } from './registry.js';
178
190
  * Advisory only — it gates nothing. Authored by any bound device of `controller` (self-scoped, no
179
191
  * management capability). Publish only-on-change and only when the log meaningfully advances: each
180
192
  * call is a permanent ledger entry (replayed at every welcome, no compaction).
181
- */ export async function announceControllerBeacon(group, identity, params) {
193
+ */ export async function announceControllerBeacon({ group, identity, ...params }) {
182
194
  return mutexFor(group).run(async ()=>{
183
- const token = await signLedgerEntry(identity, {
184
- type: DEVICE_ENTRY_TYPE,
185
- groupID: group.groupID,
186
- subject: params.controller,
187
- value: {
188
- op: 'beacon',
189
- logLength: params.logLength,
190
- headDigest: params.headDigest
195
+ const token = await signLedgerEntry({
196
+ identity,
197
+ entry: {
198
+ type: DEVICE_ENTRY_TYPE,
199
+ groupID: group.groupID,
200
+ subject: params.controller,
201
+ value: {
202
+ op: 'beacon',
203
+ logLength: params.logLength,
204
+ headDigest: params.headDigest
205
+ }
191
206
  }
192
207
  });
193
208
  const result = await commitWithEntries({
@@ -198,7 +213,7 @@ import { DEVICE_ENTRY_TYPE } from './registry.js';
198
213
  ],
199
214
  requireAdmin: false
200
215
  });
201
- const newGroup = deriveGroup(group, result.newState);
216
+ const newGroup = await deriveGroup(group, result.newState);
202
217
  await newGroup.applyLedgerEntries(result.enacted);
203
218
  return {
204
219
  commitMessage: encode(mlsMessageEncoder, result.commit),