@fairfox/polly 0.70.0 → 0.72.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 (38) hide show
  1. package/dist/src/client/index.js +2 -2
  2. package/dist/src/client/index.js.map +2 -2
  3. package/dist/src/mesh.js +407 -156
  4. package/dist/src/mesh.js.map +9 -8
  5. package/dist/src/peer.js +92 -5
  6. package/dist/src/peer.js.map +4 -4
  7. package/dist/src/polly-ui/ActionInput.d.ts +10 -1
  8. package/dist/src/polly-ui/ActionSelect.d.ts +35 -0
  9. package/dist/src/polly-ui/Cluster.d.ts +35 -0
  10. package/dist/src/polly-ui/Code.d.ts +17 -0
  11. package/dist/src/polly-ui/Text.d.ts +31 -0
  12. package/dist/src/polly-ui/index.css +278 -185
  13. package/dist/src/polly-ui/index.d.ts +5 -1
  14. package/dist/src/polly-ui/index.js +480 -284
  15. package/dist/src/polly-ui/index.js.map +11 -6
  16. package/dist/src/polly-ui/internal/dispatch-action.d.ts +13 -0
  17. package/dist/src/polly-ui/markdown.js +3 -3
  18. package/dist/src/polly-ui/markdown.js.map +2 -2
  19. package/dist/src/polly-ui/styles.css +288 -185
  20. package/dist/src/shared/lib/mesh-client.d.ts +29 -0
  21. package/dist/src/shared/lib/mesh-diagnostics.d.ts +31 -0
  22. package/dist/src/shared/lib/mesh-network-adapter.d.ts +91 -0
  23. package/dist/src/shared/lib/revocation-summary.d.ts +54 -0
  24. package/dist/tools/quality/src/cli.js +6 -2
  25. package/dist/tools/quality/src/cli.js.map +3 -3
  26. package/dist/tools/quality/src/index.js +6 -2
  27. package/dist/tools/quality/src/index.js.map +3 -3
  28. package/dist/tools/test/src/browser/run.js +75 -44
  29. package/dist/tools/test/src/browser/run.js.map +3 -3
  30. package/dist/tools/test/src/e2e-mesh/index.d.ts +1 -1
  31. package/dist/tools/test/src/e2e-mesh/index.js +95 -1
  32. package/dist/tools/test/src/e2e-mesh/index.js.map +4 -4
  33. package/dist/tools/test/src/e2e-mesh/launch-peer.d.ts +29 -1
  34. package/dist/tools/test/src/visual/index.js +24 -24
  35. package/dist/tools/test/src/visual/index.js.map +2 -2
  36. package/dist/tools/verify/src/cli.js +82 -51
  37. package/dist/tools/verify/src/cli.js.map +7 -6
  38. package/package.json +2 -2
@@ -66,6 +66,16 @@
66
66
  line-height: var(--polly-line-height-tight);
67
67
  }
68
68
 
69
+ /* Monospace baseline for inline code, keyboard, and sample text so a
70
+ * bare <code> reads correctly without a consumer class. The <Code>
71
+ * component layers the tinted-pill treatment on top; this rule only
72
+ * guarantees the font. :where() keeps specificity at zero so any
73
+ * class or id wins. */
74
+ :where(code, kbd, samp, pre) {
75
+ font-family: var(--polly-font-mono);
76
+ font-size: var(--polly-text-sm);
77
+ }
78
+
69
79
  /* Text overflow utilities. Both are opt-in: any element receives the
70
80
  * behaviour by carrying the data attribute. They stay compatible with
71
81
  * Layout (a grid) because the utilities change the element's OWN display,
@@ -210,6 +220,191 @@
210
220
  }
211
221
  }
212
222
 
223
+ /* src/polly-ui/Dropdown.module.css */
224
+ @layer polly-components {
225
+ .dropdown_HX48zA {
226
+ position: relative;
227
+ display: inline-block;
228
+ }
229
+
230
+ .trigger_HX48zA {
231
+ display: inline-block;
232
+ }
233
+
234
+ .menu_HX48zA {
235
+ position: absolute;
236
+ inset: unset;
237
+ z-index: var(--polly-z-raised);
238
+ margin: var(--polly-space-xs) 0 0;
239
+ padding: var(--polly-space-xs) 0;
240
+ border: var(--polly-border-width-default) solid var(--polly-border);
241
+ border-radius: var(--polly-radius-md);
242
+ background-color: var(--polly-surface);
243
+ box-shadow: var(--polly-shadow-md);
244
+ box-sizing: border-box;
245
+ overflow-y: auto;
246
+ min-width: 160px;
247
+ max-height: 280px;
248
+ top: 100%;
249
+ left: 0;
250
+ }
251
+
252
+ .alignRight_HX48zA {
253
+ left: auto;
254
+ right: 0;
255
+ }
256
+ }
257
+
258
+ /* src/polly-ui/Layout.module.css */
259
+ @layer polly-components {
260
+ .layout_QgwWPg {
261
+ --l-cols: none;
262
+ --l-rows: none;
263
+ --l-gap: 0;
264
+ --l-p: 0;
265
+ --l-h: auto;
266
+ --l-mh: auto;
267
+ --l-mis: none;
268
+ --l-ji: stretch;
269
+ --l-ai: start;
270
+ --l-jc: normal;
271
+ --l-ac: normal;
272
+ --l-js: auto;
273
+ --l-as: auto;
274
+ --l-flow: row;
275
+ --l-arows: auto;
276
+ --l-acols: auto;
277
+ --l-col: auto;
278
+ display: grid;
279
+ box-sizing: border-box;
280
+ max-inline-size: var(--l-mis);
281
+ grid-template-columns: var(--l-cols);
282
+ grid-template-rows: var(--l-rows);
283
+ gap: var(--l-gap);
284
+ padding: var(--l-p);
285
+ height: var(--l-h);
286
+ min-height: var(--l-mh);
287
+ justify-items: var(--l-ji);
288
+ align-items: var(--l-ai);
289
+ justify-content: var(--l-jc);
290
+ align-content: var(--l-ac);
291
+ justify-self: var(--l-js);
292
+ align-self: var(--l-as);
293
+ grid-auto-flow: var(--l-flow);
294
+ grid-auto-rows: var(--l-arows);
295
+ grid-auto-columns: var(--l-acols);
296
+ grid-column: var(--l-col);
297
+ inline-size: 100%;
298
+ margin-inline-start: auto;
299
+ margin-inline-end: auto;
300
+ }
301
+
302
+ .inline_QgwWPg {
303
+ display: inline-grid;
304
+ inline-size: auto;
305
+ }
306
+
307
+ @media (max-width: 640px) {
308
+ .stackOnMobile_QgwWPg {
309
+ grid-template-columns: 1fr;
310
+ grid-auto-flow: row;
311
+ grid-column: auto;
312
+ }
313
+ }
314
+ }
315
+
316
+ /* src/polly-ui/Select.module.css */
317
+ @layer polly-components {
318
+ .select_daofbw {
319
+ display: inline-block;
320
+ }
321
+
322
+ .label_daofbw {
323
+ display: block;
324
+ margin-bottom: var(--polly-space-xs);
325
+ font-size: var(--polly-text-sm);
326
+ font-weight: var(--polly-weight-medium);
327
+ color: var(--polly-text-muted);
328
+ }
329
+
330
+ .trigger_daofbw {
331
+ display: inline-block;
332
+ padding: var(--polly-space-sm) var(--polly-space-md);
333
+ border: var(--polly-border-width-default) solid var(--polly-border);
334
+ border-radius: var(--polly-radius-sm);
335
+ background-color: var(--polly-surface);
336
+ font-family: inherit;
337
+ font-size: var(--polly-text-md);
338
+ color: var(--polly-text);
339
+ text-align: left;
340
+ cursor: pointer;
341
+ white-space: nowrap;
342
+ overflow: hidden;
343
+ text-overflow: ellipsis;
344
+ min-width: 140px;
345
+ }
346
+
347
+ .trigger_daofbw:disabled {
348
+ opacity: var(--polly-opacity-disabled);
349
+ cursor: not-allowed;
350
+ }
351
+
352
+ .placeholder_daofbw {
353
+ color: var(--polly-text-muted);
354
+ }
355
+
356
+ .actions_daofbw {
357
+ padding: var(--polly-space-xs) var(--polly-space-sm);
358
+ border-bottom: var(--polly-border-width-default) solid var(--polly-border);
359
+ }
360
+
361
+ .actionBtn_daofbw {
362
+ display: inline-block;
363
+ padding: var(--polly-space-xs) var(--polly-space-sm);
364
+ border-radius: var(--polly-radius-sm);
365
+ font-family: inherit;
366
+ font-size: var(--polly-text-xs);
367
+ color: var(--polly-accent);
368
+ cursor: pointer;
369
+ text-align: center;
370
+ background: none;
371
+ border: none;
372
+ width: 100%;
373
+ }
374
+
375
+ .actionBtn_daofbw:hover {
376
+ background-color: var(--polly-surface-sunken);
377
+ }
378
+
379
+ .option_daofbw {
380
+ display: block;
381
+ padding: var(--polly-space-sm) var(--polly-space-md);
382
+ font-family: inherit;
383
+ font-size: var(--polly-text-sm);
384
+ color: var(--polly-text);
385
+ text-align: left;
386
+ cursor: pointer;
387
+ background: none;
388
+ border: none;
389
+ width: 100%;
390
+ }
391
+
392
+ .option_daofbw:hover {
393
+ background-color: var(--polly-surface-sunken);
394
+ }
395
+
396
+ .optionSelected_daofbw {
397
+ background-color: color-mix(in srgb, var(--polly-accent) 8%, var(--polly-surface));
398
+ }
399
+
400
+ .optionCheck_daofbw {
401
+ accent-color: var(--polly-accent);
402
+ margin-right: var(--polly-space-sm);
403
+ vertical-align: middle;
404
+ pointer-events: none;
405
+ }
406
+ }
407
+
213
408
  /* src/polly-ui/Badge.module.css */
214
409
  @layer polly-components {
215
410
  .badge_cZd0Aw {
@@ -358,64 +553,6 @@
358
553
  }
359
554
  }
360
555
 
361
- /* src/polly-ui/Layout.module.css */
362
- @layer polly-components {
363
- .layout_QgwWPg {
364
- --l-cols: none;
365
- --l-rows: none;
366
- --l-gap: 0;
367
- --l-p: 0;
368
- --l-h: auto;
369
- --l-mh: auto;
370
- --l-mis: none;
371
- --l-ji: stretch;
372
- --l-ai: start;
373
- --l-jc: normal;
374
- --l-ac: normal;
375
- --l-js: auto;
376
- --l-as: auto;
377
- --l-flow: row;
378
- --l-arows: auto;
379
- --l-acols: auto;
380
- --l-col: auto;
381
- display: grid;
382
- box-sizing: border-box;
383
- max-inline-size: var(--l-mis);
384
- grid-template-columns: var(--l-cols);
385
- grid-template-rows: var(--l-rows);
386
- gap: var(--l-gap);
387
- padding: var(--l-p);
388
- height: var(--l-h);
389
- min-height: var(--l-mh);
390
- justify-items: var(--l-ji);
391
- align-items: var(--l-ai);
392
- justify-content: var(--l-jc);
393
- align-content: var(--l-ac);
394
- justify-self: var(--l-js);
395
- align-self: var(--l-as);
396
- grid-auto-flow: var(--l-flow);
397
- grid-auto-rows: var(--l-arows);
398
- grid-auto-columns: var(--l-acols);
399
- grid-column: var(--l-col);
400
- inline-size: 100%;
401
- margin-inline-start: auto;
402
- margin-inline-end: auto;
403
- }
404
-
405
- .inline_QgwWPg {
406
- display: inline-grid;
407
- inline-size: auto;
408
- }
409
-
410
- @media (max-width: 640px) {
411
- .stackOnMobile_QgwWPg {
412
- grid-template-columns: 1fr;
413
- grid-auto-flow: row;
414
- grid-column: auto;
415
- }
416
- }
417
- }
418
-
419
556
  /* src/polly-ui/Surface.module.css */
420
557
  @layer polly-components {
421
558
  .surface_pQCFqA {
@@ -516,6 +653,55 @@
516
653
  }
517
654
  }
518
655
 
656
+ /* src/polly-ui/Cluster.module.css */
657
+ @layer polly-components {
658
+ .cluster_pNLz5g {
659
+ --c-gap: 0;
660
+ --c-p: 0;
661
+ --c-jc: flex-start;
662
+ --c-ai: center;
663
+ display: flex;
664
+ box-sizing: border-box;
665
+ gap: var(--c-gap);
666
+ padding: var(--c-p);
667
+ justify-content: var(--c-jc);
668
+ align-items: var(--c-ai);
669
+ flex-wrap: wrap;
670
+ }
671
+
672
+ .inline_pNLz5g {
673
+ display: inline-flex;
674
+ }
675
+ }
676
+
677
+ /* src/polly-ui/Code.module.css */
678
+ @layer polly-components {
679
+ .code_Vc8yiw {
680
+ font-family: var(--polly-font-mono);
681
+ font-size: var(--polly-text-sm);
682
+ padding: .1em var(--polly-space-xs);
683
+ border-radius: var(--polly-radius-sm);
684
+ background-color: var(--polly-surface-sunken);
685
+ color: var(--polly-text);
686
+ word-break: break-word;
687
+ }
688
+
689
+ .block_Vc8yiw {
690
+ padding: var(--polly-space-md);
691
+ border-radius: var(--polly-radius-md);
692
+ background-color: var(--polly-surface-sunken);
693
+ overflow-x: auto;
694
+ margin: 0;
695
+ }
696
+
697
+ .block_Vc8yiw code {
698
+ font-family: var(--polly-font-mono);
699
+ font-size: var(--polly-text-sm);
700
+ color: var(--polly-text);
701
+ white-space: pre;
702
+ }
703
+ }
704
+
519
705
  /* src/polly-ui/Collapsible.module.css */
520
706
  @layer polly-components {
521
707
  .collapsible_sEhnPw {
@@ -685,133 +871,6 @@
685
871
  }
686
872
  }
687
873
 
688
- /* src/polly-ui/Dropdown.module.css */
689
- @layer polly-components {
690
- .dropdown_HX48zA {
691
- position: relative;
692
- display: inline-block;
693
- }
694
-
695
- .trigger_HX48zA {
696
- display: inline-block;
697
- }
698
-
699
- .menu_HX48zA {
700
- position: absolute;
701
- inset: unset;
702
- z-index: var(--polly-z-raised);
703
- margin: var(--polly-space-xs) 0 0;
704
- padding: var(--polly-space-xs) 0;
705
- border: var(--polly-border-width-default) solid var(--polly-border);
706
- border-radius: var(--polly-radius-md);
707
- background-color: var(--polly-surface);
708
- box-shadow: var(--polly-shadow-md);
709
- box-sizing: border-box;
710
- overflow-y: auto;
711
- min-width: 160px;
712
- max-height: 280px;
713
- top: 100%;
714
- left: 0;
715
- }
716
-
717
- .alignRight_HX48zA {
718
- left: auto;
719
- right: 0;
720
- }
721
- }
722
-
723
- /* src/polly-ui/Select.module.css */
724
- @layer polly-components {
725
- .select_daofbw {
726
- display: inline-block;
727
- }
728
-
729
- .label_daofbw {
730
- display: block;
731
- margin-bottom: var(--polly-space-xs);
732
- font-size: var(--polly-text-sm);
733
- font-weight: var(--polly-weight-medium);
734
- color: var(--polly-text-muted);
735
- }
736
-
737
- .trigger_daofbw {
738
- display: inline-block;
739
- padding: var(--polly-space-sm) var(--polly-space-md);
740
- border: var(--polly-border-width-default) solid var(--polly-border);
741
- border-radius: var(--polly-radius-sm);
742
- background-color: var(--polly-surface);
743
- font-family: inherit;
744
- font-size: var(--polly-text-md);
745
- color: var(--polly-text);
746
- text-align: left;
747
- cursor: pointer;
748
- white-space: nowrap;
749
- overflow: hidden;
750
- text-overflow: ellipsis;
751
- min-width: 140px;
752
- }
753
-
754
- .trigger_daofbw:disabled {
755
- opacity: var(--polly-opacity-disabled);
756
- cursor: not-allowed;
757
- }
758
-
759
- .placeholder_daofbw {
760
- color: var(--polly-text-muted);
761
- }
762
-
763
- .actions_daofbw {
764
- padding: var(--polly-space-xs) var(--polly-space-sm);
765
- border-bottom: var(--polly-border-width-default) solid var(--polly-border);
766
- }
767
-
768
- .actionBtn_daofbw {
769
- display: inline-block;
770
- padding: var(--polly-space-xs) var(--polly-space-sm);
771
- border-radius: var(--polly-radius-sm);
772
- font-family: inherit;
773
- font-size: var(--polly-text-xs);
774
- color: var(--polly-accent);
775
- cursor: pointer;
776
- text-align: center;
777
- background: none;
778
- border: none;
779
- width: 100%;
780
- }
781
-
782
- .actionBtn_daofbw:hover {
783
- background-color: var(--polly-surface-sunken);
784
- }
785
-
786
- .option_daofbw {
787
- display: block;
788
- padding: var(--polly-space-sm) var(--polly-space-md);
789
- font-family: inherit;
790
- font-size: var(--polly-text-sm);
791
- color: var(--polly-text);
792
- text-align: left;
793
- cursor: pointer;
794
- background: none;
795
- border: none;
796
- width: 100%;
797
- }
798
-
799
- .option_daofbw:hover {
800
- background-color: var(--polly-surface-sunken);
801
- }
802
-
803
- .optionSelected_daofbw {
804
- background-color: color-mix(in srgb, var(--polly-accent) 8%, var(--polly-surface));
805
- }
806
-
807
- .optionCheck_daofbw {
808
- accent-color: var(--polly-accent);
809
- margin-right: var(--polly-space-sm);
810
- vertical-align: middle;
811
- pointer-events: none;
812
- }
813
- }
814
-
815
874
  /* src/polly-ui/Skeleton.module.css */
816
875
  @layer polly-components {
817
876
  @keyframes pollyShimmer_gpBHJA {
@@ -891,6 +950,50 @@
891
950
  }
892
951
  }
893
952
 
953
+ /* src/polly-ui/Text.module.css */
954
+ @layer polly-components {
955
+ .text_75HKdQ {
956
+ color: var(--polly-text);
957
+ font-family: inherit;
958
+ }
959
+
960
+ .muted_75HKdQ {
961
+ color: var(--polly-text-muted);
962
+ }
963
+
964
+ .xs_75HKdQ {
965
+ font-size: var(--polly-text-xs);
966
+ }
967
+
968
+ .sm_75HKdQ {
969
+ font-size: var(--polly-text-sm);
970
+ }
971
+
972
+ .md_75HKdQ {
973
+ font-size: var(--polly-text-md);
974
+ }
975
+
976
+ .lg_75HKdQ {
977
+ font-size: var(--polly-text-lg);
978
+ }
979
+
980
+ .xl_75HKdQ {
981
+ font-size: var(--polly-text-xl);
982
+ }
983
+
984
+ .normal_75HKdQ {
985
+ font-weight: var(--polly-weight-normal);
986
+ }
987
+
988
+ .medium_75HKdQ {
989
+ font-weight: var(--polly-weight-medium);
990
+ }
991
+
992
+ .bold_75HKdQ {
993
+ font-weight: var(--polly-weight-bold);
994
+ }
995
+ }
996
+
894
997
  /* src/polly-ui/TextInput.module.css */
895
998
  @layer polly-components {
896
999
  .input_ez4_Vg {
@@ -25,6 +25,7 @@ import { type MeshKeyring, MeshNetworkAdapter } from "./mesh-network-adapter";
25
25
  import { MeshSignalingClient, type MeshSignalingClientOptions } from "./mesh-signaling-client";
26
26
  import { type MeshStateLazyWrapperRecord, type MeshStateLoadedRejectionBreadcrumb, type MeshStateStorageOpenError } from "./mesh-state";
27
27
  import { MeshWebRTCAdapter, type MeshWebRTCAdapterOptions } from "./mesh-webrtc-adapter";
28
+ import { type RevocationRecord } from "./revocation";
28
29
  /** Options for {@link createMeshClient}. */
29
30
  export interface CreateMeshClientOptions {
30
31
  /** Signalling-server configuration. `peerId` must be the same identity
@@ -479,6 +480,34 @@ export interface MeshClient {
479
480
  * over per-doc reevaluations resolves. Idempotent: if every pair is
480
481
  * already syncing this is a no-op. Polly issue #107 item 7. */
481
482
  reevaluateAllSync(): Promise<void>;
483
+ /**
484
+ * Issue a revocation against `targetPeerId` (RFC-043). The local
485
+ * keyring is mutated to drop the target immediately; the encoded
486
+ * signed record is broadcast to every currently-connected peer, who
487
+ * apply it through the same path on receipt. Past contributions from
488
+ * the revoked peer stay in any document they already merged into;
489
+ * future writes are dropped at every peer's adapter once they
490
+ * receive the revocation.
491
+ *
492
+ * Resolves once the local keyring has been mutated and the broadcast
493
+ * has been handed to the base adapter. Delivery to disconnected
494
+ * peers happens via the reconnect re-broadcast scheduled by the
495
+ * next RFC-043 PR.
496
+ */
497
+ revokePeer(targetPeerId: string, reason?: string): Promise<void>;
498
+ /**
499
+ * If a remote peer has issued a revocation that names the local
500
+ * peer as its target, this field carries the parsed
501
+ * {@link RevocationRecord}. Applications observe it to render a
502
+ * "this device has been revoked by your other device on date X"
503
+ * UX. The mesh continues to receive other peers' messages so the
504
+ * application can surface further detail (more revocations from
505
+ * the same issuer, etc.); only this device's outbound writes are
506
+ * suppressed.
507
+ *
508
+ * Undefined while no self-targeted revocation has been seen.
509
+ */
510
+ readonly selfRevocation: RevocationRecord | undefined;
482
511
  /** Close the signalling WebSocket, tear down every RTCPeerConnection,
483
512
  * and shut the Repo cleanly. Idempotent. */
484
513
  close(): Promise<void>;
@@ -48,6 +48,37 @@ export type MeshDiagnostic = {
48
48
  senderId: string;
49
49
  documentId: string;
50
50
  reason?: string;
51
+ } | {
52
+ kind: "drop:unknown-control-type";
53
+ senderId: string;
54
+ tag: number;
55
+ } | {
56
+ kind: "drop:empty-control-payload";
57
+ senderId: string;
58
+ } | {
59
+ kind: "drop:control-handler-threw";
60
+ senderId: string;
61
+ tag: number;
62
+ reason: string;
63
+ } | {
64
+ kind: "ctrl:revocation-received";
65
+ senderId: string;
66
+ } | {
67
+ kind: "ctrl:revocation-summary-received";
68
+ senderId: string;
69
+ } | {
70
+ kind: "revoke:duplicate";
71
+ revokedPeerId: string;
72
+ issuerId: string;
73
+ } | {
74
+ kind: "revoke:rejected";
75
+ senderId: string;
76
+ reason: string;
77
+ } | {
78
+ kind: "revoke:self-targeted";
79
+ issuerId: string;
80
+ reason?: string;
81
+ issuedAt: number;
51
82
  } | {
52
83
  kind: "pair:invite-issued";
53
84
  peerId: string;
@@ -45,6 +45,41 @@ import { type SigningKeyPair } from "./signing";
45
45
  * encryption mode. See the file-level comment for the per-document key
46
46
  * follow-up. */
47
47
  export declare const DEFAULT_MESH_KEY_ID = "polly-mesh-default";
48
+ /**
49
+ * Control-message type tags. Every mesh message carries a single tag
50
+ * byte at the front of its plaintext payload, after decryption and
51
+ * signature verification. The tag discriminates the inner contents so
52
+ * future control flows (RFC-043 revocation propagation, future RFCs)
53
+ * can share the same encrypted-signed envelope without re-versioning.
54
+ *
55
+ * 0x00 is the default Automerge sync-message channel that polly has
56
+ * carried since the first cut. 0x01 and 0x02 are reserved for the
57
+ * revocation flow designed in RFC-043; the adapter recognises them at
58
+ * receive time but does not yet act on the payload — that lands in
59
+ * the second RFC-043 PR. Tags 0x03 and above are unassigned; a
60
+ * receiver that sees one emits `drop:unknown-control-type` and the
61
+ * message is dropped.
62
+ *
63
+ * Wire format break: polly 0.70 and earlier do not prepend the tag
64
+ * and do not strip it on receive. Mixing 0.70 and 0.71-plus peers on
65
+ * the same mesh produces garbage on both sides. The break is
66
+ * acknowledged in RFC-043 and required for the protocol-level
67
+ * revocation feature; the alternative (a separate WebRTC data
68
+ * channel) doubles transport complexity.
69
+ */
70
+ export declare const MESH_CONTROL_TYPE: {
71
+ /** Automerge sync message — the default channel. */
72
+ readonly Sync: 0;
73
+ /** A signed RevocationRecord (RFC-043). Receive-side dispatch is
74
+ * wired in this PR; the apply-and-persist behaviour lands in the
75
+ * next RFC-043 PR. */
76
+ readonly Revocation: 1;
77
+ /** A revocation-set summary exchanged on every new peer connection
78
+ * to gossip revocations to peers that were offline at issue-time
79
+ * (RFC-043). Same staging as Revocation. */
80
+ readonly RevocationSummary: 2;
81
+ };
82
+ export type MeshControlType = (typeof MESH_CONTROL_TYPE)[keyof typeof MESH_CONTROL_TYPE];
48
83
  /**
49
84
  * A mesh keyring holds the local peer's signing identity, the public keys
50
85
  * of every peer the local node will accept messages from, the symmetric
@@ -106,6 +141,22 @@ export interface MeshNetworkAdapterOptions {
106
141
  * messages. Defaults to true (encrypt + sign, the full $meshState
107
142
  * posture). */
108
143
  encryptionEnabled?: boolean;
144
+ /**
145
+ * Optional handler for non-Sync control messages (RFC-043). Called
146
+ * after signature verification and decryption with the type tag,
147
+ * the body bytes that followed the tag, and the verified senderId.
148
+ * The handler owns the apply-and-persist behaviour for whichever
149
+ * control flow the tag belongs to; the adapter routes only.
150
+ *
151
+ * The handler is called *after* the corresponding `ctrl:*-received`
152
+ * diagnostic fires, so subscribers observing the low-level signal
153
+ * see the event before the handler mutates any application state.
154
+ * Handler exceptions are swallowed by the adapter — a buggy handler
155
+ * cannot tear the network path — but a diagnostic
156
+ * `drop:control-handler-threw` is emitted so the failure is
157
+ * observable.
158
+ */
159
+ onControlMessage?: (tag: number, body: Uint8Array, senderId: string) => void;
109
160
  }
110
161
  /**
111
162
  * NetworkAdapter that wraps another adapter with Polly's mesh-transport
@@ -121,6 +172,7 @@ export declare class MeshNetworkAdapter extends NetworkAdapter {
121
172
  readonly base: NetworkAdapter;
122
173
  readonly keyringSource: () => MeshKeyring;
123
174
  readonly encryptionEnabled: boolean;
175
+ readonly onControlMessage: ((tag: number, body: Uint8Array, senderId: string) => void) | undefined;
124
176
  /** Read-only view of the current keyring. Each access calls
125
177
  * {@link MeshNetworkAdapterOptions.keyringSource}, so the value
126
178
  * reflects whatever mutations or swaps the caller has applied since
@@ -137,7 +189,46 @@ export declare class MeshNetworkAdapter extends NetworkAdapter {
137
189
  * Wrap an outgoing Automerge message in an encrypt-then-sign envelope.
138
190
  * The wrapped payload is returned as a Message with the original sender
139
191
  * and target ids and the crypto blob in the `data` field.
192
+ *
193
+ * The serialised Automerge message is prefixed with a one-byte
194
+ * control-type tag (RFC-043). For outgoing Automerge sync this is
195
+ * always {@link MESH_CONTROL_TYPE.Sync} (0x00); the tag exists so
196
+ * future control flows (revocation propagation, revocation-set
197
+ * summaries) can share the same encrypted-signed envelope without
198
+ * re-versioning the wire format.
140
199
  */
141
200
  private wrap;
142
201
  private tryUnwrap;
202
+ /**
203
+ * Dispatch a verified-and-decrypted plaintext payload based on its
204
+ * one-byte control-type tag (RFC-043). For {@link MESH_CONTROL_TYPE.Sync}
205
+ * the remainder is the serialised Automerge message and is returned
206
+ * to the caller. For revocation tags the dispatch emits a
207
+ * `ctrl:*-received` diagnostic and drops the payload at this layer
208
+ * pending the next RFC-043 PR. Unknown tags emit
209
+ * `drop:unknown-control-type` and drop.
210
+ */
211
+ private dispatchTaggedPayload;
212
+ private invokeControlHandler;
213
+ /**
214
+ * Send a control message (RFC-043) to a list of connected peers.
215
+ * The body is wrapped in the same encrypt-sign envelope Automerge
216
+ * sync uses; the type tag goes in front so receivers route it to
217
+ * {@link MeshNetworkAdapterOptions.onControlMessage}.
218
+ *
219
+ * The base adapter does not surface its connected-peer set on the
220
+ * NetworkAdapter interface, so the caller passes the targets
221
+ * explicitly. The MeshClient layer maintains that list from the
222
+ * `peer-candidate` / `peer-disconnected` events.
223
+ */
224
+ sendControlMessage(tag: MeshControlType, body: Uint8Array, targetPeerIds: ReadonlyArray<PeerId>): void;
143
225
  }
226
+ /**
227
+ * Prepend a one-byte control-type tag to a payload. The tag goes
228
+ * inside the encrypted-signed envelope (or directly inside the signed
229
+ * envelope in sign-only mode), so it is both confidential (encrypted
230
+ * when encryption is enabled) and authenticated (covered by the
231
+ * signature). Exposed so future RFC-043 issue helpers can build
232
+ * tagged payloads without rebuilding this primitive.
233
+ */
234
+ export declare function prependControlTag(tag: MeshControlType, body: Uint8Array): Uint8Array;