@kumiai/mls 0.3.1 → 0.4.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/lib/policy.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { normalizeDID } from '@kokuin/token';
2
2
  import { defaultProposalTypes, isDefaultProposal } from 'ts-mls';
3
- import { LEDGER_HEAD_EXTENSION_TYPE } from './anchor.js';
3
+ import { LEDGER_HEAD_EXTENSION_TYPE, RESERVED_EXTENSION_TYPE } from './anchor.js';
4
4
  function bytesEqual(a, b) {
5
5
  if (a.length !== b.length) {
6
6
  return false;
@@ -13,9 +13,8 @@ function bytesEqual(a, b) {
13
13
  return true;
14
14
  }
15
15
  /**
16
- * Fail-closed admin check: a leaf that resolves to no DID, or a DID absent from
17
- * the roster, or one holding any role but `admin`, is not an admin. An undefined
18
- * leaf (external commit with no committer leaf) is never an admin.
16
+ * Fail-closed admin check: no DID, a DID absent from the roster, or any role but `admin`, is
17
+ * not admin. An undefined leaf (external commit with no committer) is never admin.
19
18
  */ function isAdmin(context, leafIndex) {
20
19
  if (leafIndex === undefined) {
21
20
  return false;
@@ -27,37 +26,48 @@ function bytesEqual(a, b) {
27
26
  return context.baseRoster.roles.get(normalizeDID(did)) === 'admin';
28
27
  }
29
28
  /**
30
- * The group-context-extensions rule: an admin may replace the extension list
31
- * only to move the ledger-head extension to the head this commit's envelope
32
- * accounts for. A GCE proposal replaces the *entire* list, so the proposed list
33
- * must positionally equal the current list — same length, same extension types in
34
- * the same positions, byte-identical data — with the single exception of the
35
- * ledger_head entry, whose data must equal the expected head. This pins the anchor
36
- * and every other extension: an admin cannot inject or strip an extension (e.g.
37
- * external_senders, which grants a non-member the ability to inject proposals)
38
- * inside an otherwise-valid head move.
29
+ * The group-context-extensions rule: an admin may replace the extension list only to move the
30
+ * ledger-head to the head this commit's envelope accounts for, or to also install
31
+ * {@link RESERVED_EXTENSION_TYPE} empty. A GCE proposal replaces the *entire* list, so the
32
+ * proposed list must positionally equal the current one — same length, types, positions,
33
+ * byte-identical data — except the ledger_head entry (must equal the expected head) and at
34
+ * most one added `RESERVED_EXTENSION_TYPE` entry with empty data. This pins every other
35
+ * extension, so an admin can't inject or strip one (e.g. external_senders, which lets a
36
+ * non-member inject proposals) inside a head move, nor install the reserved type with
37
+ * non-empty data — it isn't consumed by anything yet, so no policy exists for its data.
39
38
  *
40
- * The head must equal the current head extended by the envelope's entry ids, in
41
- * envelope order. A head moved to anything else — including moved at all by a
42
- * commit that enacts nothing — would stop proving which entries the group has
43
- * enacted, which is the omission hole the head exists to close.
39
+ * The head must equal the current head extended by the envelope's entry ids in order; moved to
40
+ * anything else, or moved by a commit enacting nothing, and it stops proving what the group
41
+ * enacted.
44
42
  */ function evaluateGroupContextExtensions(extensions, context) {
45
43
  const expected = context.currentExtensions.map((ext)=>ext.extensionType === LEDGER_HEAD_EXTENSION_TYPE ? {
46
44
  extensionType: LEDGER_HEAD_EXTENSION_TYPE,
47
45
  extensionData: context.expectedHeadExtensionData
48
46
  } : ext);
49
- if (extensions.length !== expected.length) return 'reject';
47
+ // The only freedom beyond the head move: one added RESERVED_EXTENSION_TYPE entry with empty
48
+ // data, and only if not already installed — an install, not a second copy. Strip it, if
49
+ // present, before the positional compare below; every other difference falls through and is
50
+ // rejected as before.
51
+ let candidate = extensions;
52
+ const reservedAlreadyInstalled = expected.some((ext)=>ext.extensionType === RESERVED_EXTENSION_TYPE);
53
+ if (!reservedAlreadyInstalled && extensions.length === expected.length + 1) {
54
+ const reservedIndex = extensions.findIndex((ext)=>{
55
+ return ext.extensionType === RESERVED_EXTENSION_TYPE && ext.extensionData instanceof Uint8Array && ext.extensionData.length === 0;
56
+ });
57
+ if (reservedIndex !== -1) {
58
+ candidate = extensions.slice(0, reservedIndex).concat(extensions.slice(reservedIndex + 1));
59
+ }
60
+ }
61
+ if (candidate.length !== expected.length) return 'reject';
50
62
  for(let i = 0; i < expected.length; i++){
51
- const got = extensions[i];
63
+ const got = candidate[i];
52
64
  const want = expected[i];
53
65
  if (got.extensionType !== want.extensionType) return 'reject';
54
- // Both sides must be raw bytes to byte-compare. ts-mls's own extensionsEqual
55
- // is not re-exported, so this hand-rolled compare only handles Uint8Array
56
- // extensionData; a default-typed (decoded-object) extension — e.g.
57
- // external_senders or required_capabilities — fails the instanceof guard and
58
- // is rejected even when it is an honest, unmodified carry-over. That is
59
- // fail-closed liveness, not a security gap: no group in this repo anchors
60
- // such an extension today. Revisit this compare if one is introduced.
66
+ // Both sides must be raw bytes to compare. ts-mls's extensionsEqual isn't re-exported, so
67
+ // this hand-rolled compare only handles Uint8Array data; a decoded-object extension (e.g.
68
+ // external_senders, required_capabilities) fails the instanceof guard and is rejected even
69
+ // if unmodified — fail-closed liveness, not a security gap, since no group here anchors one
70
+ // today. Revisit if one is introduced.
61
71
  if (!(got.extensionData instanceof Uint8Array) || !(want.extensionData instanceof Uint8Array) || !bytesEqual(got.extensionData, want.extensionData)) {
62
72
  return 'reject';
63
73
  }
@@ -65,10 +75,8 @@ function bytesEqual(a, b) {
65
75
  return 'accept';
66
76
  }
67
77
  /**
68
- * Apply one proposal's row using the given effective sender. Unknown or custom
69
- * proposal types fail closed. `external_init` is evaluated at the commit level,
70
- * never here, so it rejects if it reaches a per-proposal row (a standalone
71
- * external_init).
78
+ * Apply one proposal's row for the given effective sender. Unknown/custom types fail closed.
79
+ * `external_init` is judged at the commit level, never here — a standalone one rejects.
72
80
  */ function evaluateProposal(proposal, effectiveSender, context) {
73
81
  if (!isDefaultProposal(proposal)) {
74
82
  return 'reject';
@@ -80,10 +88,9 @@ function bytesEqual(a, b) {
80
88
  return isAdmin(context, effectiveSender) ? 'accept' : 'reject';
81
89
  case defaultProposalTypes.remove:
82
90
  {
83
- // A removed admin must have been demoted in this same envelope: the candidate
84
- // roster then shows them `member`. Still `admin` here means no demotion rode the
85
- // commit. Checked before the self-removal shortcut, so an admin cannot self-remove
86
- // without demoting itself.
91
+ // A removed admin must have been demoted in this same envelope — still `admin` in the
92
+ // candidate roster means no demotion rode the commit. Checked before the self-removal
93
+ // shortcut, so an admin can't self-remove without demoting itself.
87
94
  const removedDID = context.didOfLeaf(proposal.remove.removed);
88
95
  if (removedDID !== undefined && context.candidateRoster.roles.get(normalizeDID(removedDID)) === 'admin') {
89
96
  return 'reject';
@@ -102,11 +109,10 @@ function bytesEqual(a, b) {
102
109
  }
103
110
  }
104
111
  /**
105
- * The whole-commit external-init rule. An external commit joins by proving
106
- * control of a roster DID's key and removing that DID's stale leaf, so it is
107
- * accepted only when `externalCommitDID` is a roster member and the commit's
108
- * proposals are exactly one `external_init` plus one `remove` of the leaf whose
109
- * DID equals `externalCommitDID` — nothing else.
112
+ * The whole-commit external-init rule. An external commit joins by proving control of a
113
+ * roster DID's key and removing that DID's stale leaf: accepted only when `externalCommitDID`
114
+ * is a roster member and the proposals are exactly one `external_init` plus one `remove` of the
115
+ * leaf whose DID matches — nothing else.
110
116
  */ function evaluateExternalCommit(proposals, context) {
111
117
  const did = context.externalCommitDID;
112
118
  if (did === undefined || !context.baseRoster.roles.has(normalizeDID(did))) {
@@ -135,21 +141,18 @@ function bytesEqual(a, b) {
135
141
  return context.didOfLeaf(removeTarget) === did ? 'accept' : 'reject';
136
142
  }
137
143
  /**
138
- * Pure receiving-side commit policy. Given the resolved context, decides whether
139
- * an incoming commit or standalone proposal is admissible. Never throws.
144
+ * Pure receiving-side commit policy: given the resolved context, decides whether an incoming
145
+ * commit or standalone proposal is admissible. Never throws.
140
146
  *
141
- * Per proposal the effective sender is the proposal's own `senderLeafIndex` when
142
- * present, else the committer's — a commit may carry by-reference proposals
143
- * authored by other members, so checking only the committer would let an admin
144
- * launder a member's Remove. A commit is accepted only when every proposal
145
- * passes its row; the first failing proposal rejects the whole commit. A commit
146
- * with no proposals is a key rotation any member may make. When any proposal is
147
- * an `external_init`, the whole commit is judged by the external-init rule rather
148
- * than the per-proposal loop.
147
+ * Per proposal, the effective sender is its own `senderLeafIndex` if present, else the
148
+ * committer's — a commit may carry by-reference proposals from other members, so checking only
149
+ * the committer would let an admin launder a member's Remove. Every proposal must pass its row
150
+ * or the whole commit rejects; no proposals is a key rotation any member may make. An
151
+ * `external_init` anywhere routes the whole commit to the external-init rule instead of the
152
+ * per-proposal loop.
149
153
  *
150
- * One rule is not a proposal's own: a commit that enacts ledger entries must carry
151
- * a group-context-extensions proposal, or it would enact entries without moving the
152
- * head, and the head would stop covering the ledger.
154
+ * One rule isn't a proposal's own: a commit enacting ledger entries must carry a
155
+ * group-context-extensions proposal, or entries would be enacted without moving the head.
153
156
  */ export function defaultCommitPolicy(incoming, context) {
154
157
  if (incoming.kind === 'proposal') {
155
158
  const { proposal, senderLeafIndex } = incoming.proposal;
@@ -174,10 +177,9 @@ function bytesEqual(a, b) {
174
177
  return 'accept';
175
178
  }
176
179
  /**
177
- * Thrown by the caller's resolver path when the entry bodies an envelope names
178
- * cannot be resolved from the ledger. Carries the unresolved ids. Defined here
179
- * because it belongs to the commit-policy resolution boundary, but it is never
180
- * thrown by {@link defaultCommitPolicy}, which is pure and total.
180
+ * Thrown by the caller's resolver when an envelope names entry ids the ledger can't resolve.
181
+ * Belongs to the commit-policy resolution boundary, but {@link defaultCommitPolicy} itself is
182
+ * pure and total, and never throws it.
181
183
  */ export class MissingLedgerEntriesError extends Error {
182
184
  #ids;
183
185
  constructor(ids){
package/lib/recovery.d.ts CHANGED
@@ -2,10 +2,10 @@ import { type SigningIdentity } from '@kokuin/token';
2
2
  import { type GroupHandle } from './group.js';
3
3
  /** `type` tag on every recovery-request token. Domain-separates it, so a token
4
4
  * minted for another purpose can never pose as a request for group state. */
5
- export declare const RECOVERY_REQUEST_TYPE = "group.recovery-request";
5
+ export declare const RECOVERY_REQUEST_TYPE = "kumiai.recovery-request";
6
6
  /** `type` tag on a responder's GroupInfo attestation. Domain-separates the
7
7
  * membership proof, so no token minted elsewhere can stand in for it. */
8
- export declare const RECOVERY_GROUPINFO_TYPE = "group.recovery-groupinfo";
8
+ export declare const RECOVERY_GROUPINFO_TYPE = "kumiai.recovery-groupinfo";
9
9
  /** The only sealed-reply format this build produces or opens. */
10
10
  export declare const SEALED_GROUP_INFO_VERSION = 1;
11
11
  /** The sealed ledger reply shares the frame — `[version][enc][ct]` — and nothing
@@ -51,7 +51,7 @@ export type RecoveryRequestRejection = 'unverified' | 'malformed' | 'group-misma
51
51
  * returning an empty reply; a responder that wants to stay silent catches this. */
52
52
  export declare class RecoveryRequestError extends Error {
53
53
  #private;
54
- constructor(reason: RecoveryRequestRejection, message: string);
54
+ constructor(reason: RecoveryRequestRejection, message: string, options?: ErrorOptions);
55
55
  get reason(): RecoveryRequestRejection;
56
56
  }
57
57
  /**
@@ -86,7 +86,7 @@ export type SealedLedgerRejection = SealedReplyRejection;
86
86
  * "corrupt", so a peer sifting a shared lane drops the former quietly. */
87
87
  export declare class SealedGroupInfoError extends Error {
88
88
  #private;
89
- constructor(reason: SealedGroupInfoRejection, message: string);
89
+ constructor(reason: SealedGroupInfoRejection, message: string, options?: ErrorOptions);
90
90
  get reason(): SealedGroupInfoRejection;
91
91
  }
92
92
  /** Thrown by {@link openSealedLedger}, read like its GroupInfo sibling: a requester
@@ -94,7 +94,7 @@ export declare class SealedGroupInfoError extends Error {
94
94
  * every other request looks like this) and shouts about `malformed`. */
95
95
  export declare class SealedLedgerError extends Error {
96
96
  #private;
97
- constructor(reason: SealedReplyRejection, message: string);
97
+ constructor(reason: SealedReplyRejection, message: string, options?: ErrorOptions);
98
98
  get reason(): SealedReplyRejection;
99
99
  }
100
100
  export type CreateRecoveryRequestParams = {
package/lib/recovery.js CHANGED
@@ -4,9 +4,9 @@ import { readGroupAnchorExtension } from './anchor.js';
4
4
  import { exportGroupInfo, inspectGroupInfo, readGroupInfoBinding } from './group.js';
5
5
  const utf8 = new TextEncoder();
6
6
  /** `type` tag on every recovery-request token. Domain-separates it, so a token
7
- * minted for another purpose can never pose as a request for group state. */ export const RECOVERY_REQUEST_TYPE = 'group.recovery-request';
7
+ * minted for another purpose can never pose as a request for group state. */ export const RECOVERY_REQUEST_TYPE = 'kumiai.recovery-request';
8
8
  /** `type` tag on a responder's GroupInfo attestation. Domain-separates the
9
- * membership proof, so no token minted elsewhere can stand in for it. */ export const RECOVERY_GROUPINFO_TYPE = 'group.recovery-groupinfo';
9
+ * membership proof, so no token minted elsewhere can stand in for it. */ export const RECOVERY_GROUPINFO_TYPE = 'kumiai.recovery-groupinfo';
10
10
  /** The only sealed-reply format this build produces or opens. */ export const SEALED_GROUP_INFO_VERSION = 1;
11
11
  /** The sealed ledger reply shares the frame — `[version][enc][ct]` — and nothing
12
12
  * else: see {@link LEDGER_REPLY}. */ export const SEALED_LEDGER_VERSION = 1;
@@ -22,19 +22,19 @@ const GROUP_INFO_REPLY = {
22
22
  hpkeInfo: utf8.encode('kumiai/mls/recovery/v1'),
23
23
  aadDomain: utf8.encode('kumiai/mls/recovery-aad/v1'),
24
24
  version: SEALED_GROUP_INFO_VERSION,
25
- fail: (reason, message)=>new SealedGroupInfoError(reason, message)
25
+ fail: (reason, message, options)=>new SealedGroupInfoError(reason, message, options)
26
26
  };
27
27
  const LEDGER_REPLY = {
28
28
  hpkeInfo: utf8.encode('kumiai/mls/recovery-ledger/v1'),
29
29
  aadDomain: utf8.encode('kumiai/mls/recovery-ledger-aad/v1'),
30
30
  version: SEALED_LEDGER_VERSION,
31
- fail: (reason, message)=>new SealedLedgerError(reason, message)
31
+ fail: (reason, message, options)=>new SealedLedgerError(reason, message, options)
32
32
  };
33
33
  /** Thrown by {@link sealGroupInfo}. The primitive refuses loudly rather than
34
34
  * returning an empty reply; a responder that wants to stay silent catches this. */ export class RecoveryRequestError extends Error {
35
35
  #reason;
36
- constructor(reason, message){
37
- super(message);
36
+ constructor(reason, message, options){
37
+ super(message, options);
38
38
  this.name = 'RecoveryRequestError';
39
39
  this.#reason = reason;
40
40
  }
@@ -45,8 +45,8 @@ const LEDGER_REPLY = {
45
45
  /** Thrown by {@link openSealedGroupInfo}. Distinguishes "not addressed to me" from
46
46
  * "corrupt", so a peer sifting a shared lane drops the former quietly. */ export class SealedGroupInfoError extends Error {
47
47
  #reason;
48
- constructor(reason, message){
49
- super(message);
48
+ constructor(reason, message, options){
49
+ super(message, options);
50
50
  this.name = 'SealedGroupInfoError';
51
51
  this.#reason = reason;
52
52
  }
@@ -58,8 +58,8 @@ const LEDGER_REPLY = {
58
58
  * sifting a shared lane drops `not-for-me` quietly (every other member's reply to
59
59
  * every other request looks like this) and shouts about `malformed`. */ export class SealedLedgerError extends Error {
60
60
  #reason;
61
- constructor(reason, message){
62
- super(message);
61
+ constructor(reason, message, options){
62
+ super(message, options);
63
63
  this.name = 'SealedLedgerError';
64
64
  this.#reason = reason;
65
65
  }
@@ -136,8 +136,11 @@ function unframeAttestedGroupInfo(bytes) {
136
136
  let verified;
137
137
  try {
138
138
  verified = await verifyToken(token);
139
- } catch {
140
- throw new RecoveryRequestError('unverified', 'recovery request signature did not verify');
139
+ } catch (cause) {
140
+ // biome-ignore lint/style/useErrorCause: cause IS passed; the rule only reads argument 1, and these take (reason, message, options).
141
+ throw new RecoveryRequestError('unverified', 'recovery request signature did not verify', {
142
+ cause
143
+ });
141
144
  }
142
145
  if (!isVerifiedToken(verified)) {
143
146
  throw new RecoveryRequestError('unverified', 'recovery request is not signed');
@@ -149,8 +152,11 @@ function unframeAttestedGroupInfo(bytes) {
149
152
  let ephemeralPublicKey;
150
153
  try {
151
154
  ephemeralPublicKey = decodeMultibase(ephemeralKey);
152
- } catch {
153
- throw new RecoveryRequestError('malformed', 'recovery request ephemeral key is not multibase');
155
+ } catch (cause) {
156
+ // biome-ignore lint/style/useErrorCause: cause IS passed; the rule only reads argument 1, and these take (reason, message, options).
157
+ throw new RecoveryRequestError('malformed', 'recovery request ephemeral key is not multibase', {
158
+ cause
159
+ });
154
160
  }
155
161
  if (ephemeralPublicKey.length !== KEM_OUTPUT_LENGTH) {
156
162
  throw new RecoveryRequestError('malformed', `recovery request ephemeral key must be ${KEM_OUTPUT_LENGTH} bytes`);
@@ -249,8 +255,10 @@ function unframeAttestedGroupInfo(bytes) {
249
255
  const privateKey = await hpke.importPrivateKey(ephemeralPrivateKey);
250
256
  try {
251
257
  return await hpke.open(privateKey, enc, ct, kind.hpkeInfo, aad);
252
- } catch {
253
- throw kind.fail('not-for-me', 'sealed reply does not open for this member and request');
258
+ } catch (cause) {
259
+ throw kind.fail('not-for-me', 'sealed reply does not open for this member and request', {
260
+ cause
261
+ });
254
262
  }
255
263
  }
256
264
  /**
@@ -305,8 +313,11 @@ function unframeAttestedGroupInfo(bytes) {
305
313
  let verified;
306
314
  try {
307
315
  verified = await verifyToken(attestation);
308
- } catch {
309
- throw new SealedGroupInfoError('unauthenticated', 'responder attestation signature did not verify');
316
+ } catch (cause) {
317
+ // biome-ignore lint/style/useErrorCause: cause IS passed; the rule only reads argument 1, and these take (reason, message, options).
318
+ throw new SealedGroupInfoError('unauthenticated', 'responder attestation signature did not verify', {
319
+ cause
320
+ });
310
321
  }
311
322
  if (!isVerifiedToken(verified)) {
312
323
  throw new SealedGroupInfoError('unauthenticated', 'responder attestation is not signed');
@@ -352,14 +363,20 @@ function unframeAttestedGroupInfo(bytes) {
352
363
  try {
353
364
  ;
354
365
  ({ attestation, groupInfo } = unframeAttestedGroupInfo(plaintext));
355
- } catch {
356
- throw new SealedGroupInfoError('malformed', 'sealed plaintext is not a framed, attested GroupInfo');
366
+ } catch (cause) {
367
+ // biome-ignore lint/style/useErrorCause: cause IS passed; the rule only reads argument 1, and these take (reason, message, options).
368
+ throw new SealedGroupInfoError('malformed', 'sealed plaintext is not a framed, attested GroupInfo', {
369
+ cause
370
+ });
357
371
  }
358
372
  // Parse as a GroupInfo before anything trusts its fields.
359
373
  try {
360
374
  inspectGroupInfo(groupInfo);
361
- } catch {
362
- throw new SealedGroupInfoError('malformed', 'sealed plaintext is not a framed MLSMessage(GroupInfo)');
375
+ } catch (cause) {
376
+ // biome-ignore lint/style/useErrorCause: cause IS passed; the rule only reads argument 1, and these take (reason, message, options).
377
+ throw new SealedGroupInfoError('malformed', 'sealed plaintext is not a framed MLSMessage(GroupInfo)', {
378
+ cause
379
+ });
363
380
  }
364
381
  // Authenticate the responder, then bind the GroupInfo to this group.
365
382
  await assertResponderIsMember(attestation, group, requestID, groupInfo);
@@ -450,7 +467,10 @@ function decodeLedgerTokens(bytes) {
450
467
  const plaintext = await openSealedReply(LEDGER_REPLY, group, sealed, requestID, ephemeralPrivateKey);
451
468
  try {
452
469
  return decodeLedgerTokens(plaintext);
453
- } catch {
454
- throw new SealedLedgerError('malformed', 'sealed plaintext is not a framed ledger');
470
+ } catch (cause) {
471
+ // biome-ignore lint/style/useErrorCause: cause IS passed; the rule only reads argument 1, and these take (reason, message, options).
472
+ throw new SealedLedgerError('malformed', 'sealed plaintext is not a framed ledger', {
473
+ cause
474
+ });
455
475
  }
456
476
  }
package/lib/roster.d.ts CHANGED
@@ -3,7 +3,7 @@ import { type FoldDrop, type FoldInput, type LedgerReducer } from './fold.js';
3
3
  /** The permission a DID holds in the group: full control, or membership only. */
4
4
  export type GroupPermission = 'admin' | 'member';
5
5
  /** The ledger entry `type` the roster projects. */
6
- export declare const ROLE_ENTRY_TYPE = "group.role";
6
+ export declare const ROLE_ENTRY_TYPE = "kumiai.role";
7
7
  /** A role claim's value: the permission the subject is granted. */
8
8
  export type RoleValue = GroupPermission;
9
9
  /**
@@ -30,7 +30,7 @@ export declare function adminCount(state: RosterState): number;
30
30
  */
31
31
  export declare const roleReducer: LedgerReducer<RoleValue, RosterState>;
32
32
  /**
33
- * Fold a group's `group.role` ledger into the current roster.
33
+ * Fold a group's `kumiai.role` ledger into the current roster.
34
34
  *
35
35
  * The reducer cannot filter by `groupID` on its own — the anchor carries no
36
36
  * group id — so the group is passed explicitly and closed over here: an entry
package/lib/roster.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { normalizeDID } from '@kokuin/token';
2
2
  import { foldLedger } from './fold.js';
3
- /** The ledger entry `type` the roster projects. */ export const ROLE_ENTRY_TYPE = 'group.role';
3
+ /** The ledger entry `type` the roster projects. */ export const ROLE_ENTRY_TYPE = 'kumiai.role';
4
4
  /** Count the admins in a roster state. */ export function adminCount(state) {
5
5
  let count = 0;
6
6
  for (const permission of state.roles.values()){
@@ -41,7 +41,7 @@ import { foldLedger } from './fold.js';
41
41
  }
42
42
  };
43
43
  /**
44
- * Fold a group's `group.role` ledger into the current roster.
44
+ * Fold a group's `kumiai.role` ledger into the current roster.
45
45
  *
46
46
  * The reducer cannot filter by `groupID` on its own — the anchor carries no
47
47
  * group id — so the group is passed explicitly and closed over here: an entry
package/lib/types.d.ts CHANGED
@@ -39,8 +39,8 @@ export type GroupOptions = {
39
39
  */
40
40
  resolveLedgerEntries?: (ids: Array<string>) => Promise<Array<string>>;
41
41
  /**
42
- * Surface the notarized non-`group.role` ledger entries an accepted commit
43
- * carried, in envelope order. Never read by kumiai — `group.role` entries fold
42
+ * Surface the notarized non-`kumiai.role` ledger entries an accepted commit
43
+ * carried, in envelope order. Never read by kumiai — `kumiai.role` entries fold
44
44
  * into the roster, everything else is handed to the consumer here.
45
45
  */
46
46
  onLedgerEntries?: (entries: Array<VerifiedLedgerEntry>) => void;
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@kumiai/mls",
3
- "version": "0.3.1",
4
- "license": "MIT",
3
+ "version": "0.4.1",
5
4
  "description": "E2EE group identity and membership for Enkaku using MLS",
6
5
  "keywords": [
7
6
  "mls",
@@ -14,31 +13,32 @@
14
13
  "url": "https://github.com/TairuFramework/kumiai",
15
14
  "directory": "packages/mls"
16
15
  },
16
+ "license": "MIT",
17
+ "sideEffects": false,
17
18
  "type": "module",
18
- "main": "lib/index.js",
19
- "types": "lib/index.d.ts",
20
19
  "exports": {
21
20
  ".": "./lib/index.js"
22
21
  },
22
+ "main": "lib/index.js",
23
+ "types": "lib/index.d.ts",
23
24
  "files": [
24
25
  "lib/*"
25
26
  ],
26
- "sideEffects": false,
27
27
  "dependencies": {
28
- "@sozai/runtime": "^0.1.0",
29
- "@kokuin/token": "^0.2.0",
28
+ "@kokuin/token": "^0.3.0",
30
29
  "@noble/ciphers": "^2.1.1",
31
30
  "@noble/curves": "^2.0.1",
32
31
  "@noble/hashes": "^2.0.0",
32
+ "@sozai/runtime": "^0.1.0",
33
33
  "ts-mls": "2.0.0-rc.13"
34
34
  },
35
35
  "scripts": {
36
+ "build": "pnpm run build:clean && pnpm run build:js && pnpm run build:types",
36
37
  "build:clean": "del lib",
37
38
  "build:js": "swc src -d ./lib --config-file ../../node_modules/@kigu/dev/swc.json --strip-leading-paths",
38
39
  "build:types": "tsc --emitDeclarationOnly --skipLibCheck",
39
- "build": "pnpm run build:clean && pnpm run build:js && pnpm run build:types",
40
+ "test": "pnpm run test:types && pnpm run test:unit",
40
41
  "test:types": "tsc --noEmit --skipLibCheck -p tsconfig.test.json",
41
- "test:unit": "vitest run",
42
- "test": "pnpm run test:types && pnpm run test:unit"
42
+ "test:unit": "vitest run"
43
43
  }
44
44
  }