@kumiai/mls 0.13.4 → 0.13.5

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.
@@ -49,6 +49,12 @@ export type CommitWithEntriesParams = YieldOptions & {
49
49
  requireAdmin?: boolean;
50
50
  /** State to commit from instead of the live one, e.g. a tree with a renewed own leaf. */
51
51
  commitState?: ClientState;
52
+ /**
53
+ * Clock for the author-time check of each added leaf's binding. Required when
54
+ * `extraProposals` carry an Add; the check runs after the fold and gate, so a leaf
55
+ * lapsed at tree time rejects as lapsed first.
56
+ */
57
+ now?: Now;
52
58
  };
53
59
  /**
54
60
  * The one place a commit carrying control-ledger entries is built: `commitInvite`,
@@ -341,6 +341,13 @@ export function proposedTree(state, proposals) {
341
341
  for (const proposal of proposals){
342
342
  if (proposal.proposalType === defaultProposalTypes.add) {
343
343
  const leaf = proposal.add.keyPackage.leafNode;
344
+ if (isDefaultCredential(leaf.credential) && leaf.credential.credentialType === defaultCredentialTypes.basic) {
345
+ if (params.now == null) throw new Error('commitWithEntries: an Add needs a clock');
346
+ assertBindingAuthorTime({
347
+ controller: parseMLSCredentialIdentity(leaf.credential.identity).controller,
348
+ nowSeconds: Math.floor(params.now() / 1000)
349
+ });
350
+ }
344
351
  await validateEntry(group, leaf, undefined, {
345
352
  registry: fold.registry,
346
353
  stage: 'full',
@@ -528,14 +535,11 @@ export function proposedTree(state, proposals) {
528
535
  keyPackage
529
536
  }
530
537
  };
531
- assertBindingAuthorTime({
532
- controller: parseMLSCredentialIdentity(credential.identity).controller,
533
- nowSeconds: Math.floor(now() / 1000)
534
- });
535
538
  // A lifecycle group re-admitting a device replaces the leaf it still holds for that DID.
536
539
  const stale = group.anchor.controller == null ? undefined : staleLeafIndex(group.state.ratchetTree, keyPackage.leafNode);
537
540
  const result = await commitWithEntries({
538
541
  yield: options.yield,
542
+ now,
539
543
  group,
540
544
  extraProposals: stale == null ? [
541
545
  addProposal
@@ -2,7 +2,6 @@ import { normalizeDID } from '@kokuin/token';
2
2
  import { defaultCredentialTypes, defaultProposalTypes, encode, isDefaultCredential, mlsMessageEncoder } from 'ts-mls';
3
3
  import { parseMLSCredentialIdentity } from './credential.js';
4
4
  import { commitWithEntries } from './group-commit.js';
5
- import { assertBindingAuthorTime } from './group-credential.js';
6
5
  import { deriveGroup, mutexFor } from './group-handle.js';
7
6
  import { signLedgerEntry } from './ledger.js';
8
7
  import { DEVICE_ENTRY_TYPE } from './registry.js';
@@ -114,10 +113,6 @@ import { DEVICE_ENTRY_TYPE } from './registry.js';
114
113
  }
115
114
  }
116
115
  });
117
- assertBindingAuthorTime({
118
- controller: parseMLSCredentialIdentity(credential.identity).controller,
119
- nowSeconds: Math.floor(now() / 1000)
120
- });
121
116
  const addProposal = {
122
117
  proposalType: defaultProposalTypes.add,
123
118
  add: {
@@ -127,6 +122,7 @@ import { DEVICE_ENTRY_TYPE } from './registry.js';
127
122
  const result = await commitWithEntries({
128
123
  yield: params.yield,
129
124
  group,
125
+ now,
130
126
  extraProposals: [
131
127
  addProposal
132
128
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kumiai/mls",
3
- "version": "0.13.4",
3
+ "version": "0.13.5",
4
4
  "description": "E2EE group identity and membership for Enkaku using MLS",
5
5
  "keywords": [
6
6
  "mls",