@kumiai/mls-rpc 0.9.0 → 0.10.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.
@@ -0,0 +1,19 @@
1
+ import { type GroupHandle, type RevokeBuildResult, type RevokeWithProofParams } from '@kumiai/mls';
2
+ import type { GroupMLS, GroupPeer, GroupProtocolDefinition } from '@kumiai/rpc';
3
+ export type RevokeJournalOptions = {
4
+ /** Must restore the derived handle INCLUDING its ledger through the host's adoptJournalled. */
5
+ serializeJournal: (derived: GroupHandle) => Promise<Uint8Array> | Uint8Array;
6
+ };
7
+ export type PublishRevokeResult = {
8
+ status: 'committed';
9
+ epoch: number;
10
+ } | Exclude<RevokeBuildResult, {
11
+ status: 'built';
12
+ }>;
13
+ export type PublishRevokeProofParams<Protocols extends Record<string, GroupProtocolDefinition>> = {
14
+ peer: GroupPeer<Protocols>;
15
+ mls: GroupMLS;
16
+ input: RevokeWithProofParams;
17
+ options: RevokeJournalOptions;
18
+ };
19
+ export declare function publishRevokeProof<Protocols extends Record<string, GroupProtocolDefinition>>(params: PublishRevokeProofParams<Protocols>): Promise<PublishRevokeResult>;
package/lib/revoke.js ADDED
@@ -0,0 +1,45 @@
1
+ import { revokeWithProof } from '@kumiai/mls';
2
+ import { groupHandleAccess } from './mls.js';
3
+ export async function publishRevokeProof(params) {
4
+ const { peer, mls, input, options } = params;
5
+ const access = groupHandleAccess.get(mls);
6
+ if (access == null) throw new Error('publishRevokeProof requires an adapter-created GroupMLS');
7
+ const finished = Symbol('proof needs no commit');
8
+ let outcome;
9
+ try {
10
+ await peer.commit(async ()=>{
11
+ const built = await access.read(async (group)=>{
12
+ const result = await revokeWithProof(group, input);
13
+ return {
14
+ result,
15
+ priorTokens: new Set(group.ledgerTokens)
16
+ };
17
+ });
18
+ if (built.result.status !== 'built') {
19
+ outcome = built.result;
20
+ throw finished;
21
+ }
22
+ const { newGroup, commitMessage, epoch } = built.result.result;
23
+ const journal = await options.serializeJournal(newGroup);
24
+ return {
25
+ commit: commitMessage,
26
+ bodies: newGroup.ledgerTokens.filter((token)=>!built.priorTokens.has(token)),
27
+ kind: 'ledger',
28
+ journal,
29
+ onAccepted: async ()=>{
30
+ await access.replace(newGroup);
31
+ outcome = {
32
+ status: 'committed',
33
+ epoch: Number(epoch)
34
+ };
35
+ }
36
+ };
37
+ }, {
38
+ holdLogSends: true
39
+ });
40
+ } catch (error) {
41
+ if (error !== finished) throw error;
42
+ }
43
+ if (outcome == null) throw new Error('Proof commit completed without an outcome');
44
+ return outcome;
45
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kumiai/mls-rpc",
3
- "version": "0.9.0",
3
+ "version": "0.10.1",
4
4
  "description": "The @kumiai/rpc consumer ports (GroupCrypto, GroupMLS) implemented over @kumiai/mls",
5
5
  "keywords": [
6
6
  "mls",
@@ -26,15 +26,15 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "@kokuin/token": "^0.5.0",
29
- "@kumiai/mls": "^0.9.0",
30
- "@kumiai/rpc": "^0.9.0",
29
+ "@kumiai/mls": "^0.10.1",
30
+ "@kumiai/rpc": "^0.10.3",
31
31
  "@noble/ciphers": "^2.4.0",
32
32
  "@sozai/runtime": "^0.1.0"
33
33
  },
34
34
  "devDependencies": {
35
- "@kumiai/rpc-conformance": "^0.9.0",
35
+ "@kumiai/rpc-conformance": "^0.10.1",
36
36
  "ts-mls": "2.0.0-rc.13",
37
- "vitest": "^4.1.11"
37
+ "vitest": "^5.0.3"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public"
@@ -42,8 +42,8 @@
42
42
  "scripts": {
43
43
  "build": "pnpm run build:clean && pnpm run build:js && pnpm run build:types",
44
44
  "build:clean": "del lib",
45
- "build:js": "swc src -d ./lib --config-file ../../node_modules/@kigu/dev/swc.json --strip-leading-paths",
46
- "build:types": "tsc --emitDeclarationOnly --skipLibCheck",
45
+ "build:js": "del 'lib/**/*.js' && swc src -d ./lib --config-file ../../node_modules/@kigu/dev/swc.json --strip-leading-paths",
46
+ "build:types": "del 'lib/**/*.d.ts' 'lib/**/*.d.ts.map' && tsc --emitDeclarationOnly --skipLibCheck",
47
47
  "test": "pnpm run test:types && pnpm run test:unit",
48
48
  "test:types": "tsc --noEmit --skipLibCheck -p tsconfig.test.json",
49
49
  "test:unit": "vitest run"