@serfab/cadre-core 1.6.0 → 1.7.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 (51) hide show
  1. package/dist/cadre-node.d.ts +204 -65
  2. package/dist/cadre-node.js +392 -95
  3. package/dist/cadre-node.js.map +1 -1
  4. package/dist/index.d.ts +5 -0
  5. package/dist/index.js +16 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/joined-strand-store.d.ts +112 -0
  8. package/dist/joined-strand-store.js +263 -0
  9. package/dist/joined-strand-store.js.map +1 -0
  10. package/dist/key-store.d.ts +6 -0
  11. package/dist/key-store.js.map +1 -1
  12. package/dist/node-local-snapshot.d.ts +5 -4
  13. package/dist/node-local-snapshot.js +6 -3
  14. package/dist/node-local-snapshot.js.map +1 -1
  15. package/dist/peer-join-backfill.d.ts +33 -14
  16. package/dist/peer-join-backfill.js +109 -50
  17. package/dist/peer-join-backfill.js.map +1 -1
  18. package/dist/strand-instance-manager.d.ts +39 -0
  19. package/dist/strand-instance-manager.js +74 -1
  20. package/dist/strand-instance-manager.js.map +1 -1
  21. package/dist/strand-peer-book-file.d.ts +12 -0
  22. package/dist/strand-peer-book-file.js +37 -0
  23. package/dist/strand-peer-book-file.js.map +1 -0
  24. package/dist/strand-peer-book-protocol.d.ts +159 -0
  25. package/dist/strand-peer-book-protocol.js +360 -0
  26. package/dist/strand-peer-book-protocol.js.map +1 -0
  27. package/dist/strand-peer-book-swap.d.ts +104 -0
  28. package/dist/strand-peer-book-swap.js +284 -0
  29. package/dist/strand-peer-book-swap.js.map +1 -0
  30. package/dist/strand-peer-book.d.ts +159 -0
  31. package/dist/strand-peer-book.js +354 -0
  32. package/dist/strand-peer-book.js.map +1 -0
  33. package/dist/strand-peer-observer.d.ts +88 -0
  34. package/dist/strand-peer-observer.js +180 -0
  35. package/dist/strand-peer-observer.js.map +1 -0
  36. package/dist/types.d.ts +58 -0
  37. package/dist/types.js.map +1 -1
  38. package/package.json +6 -2
  39. package/src/cadre-node.ts +7776 -7449
  40. package/src/index.ts +67 -0
  41. package/src/joined-strand-store.ts +308 -0
  42. package/src/key-store.ts +6 -0
  43. package/src/node-local-snapshot.ts +293 -289
  44. package/src/peer-join-backfill.ts +112 -51
  45. package/src/strand-instance-manager.ts +100 -1
  46. package/src/strand-peer-book-file.ts +39 -0
  47. package/src/strand-peer-book-protocol.ts +463 -0
  48. package/src/strand-peer-book-swap.ts +338 -0
  49. package/src/strand-peer-book.ts +468 -0
  50. package/src/strand-peer-observer.ts +235 -0
  51. package/src/types.ts +60 -0
package/dist/types.d.ts CHANGED
@@ -10,7 +10,9 @@ import type { SeedTrustPolicy } from './seed-trust-policy.js';
10
10
  import type { KeyStore, KeyId } from './key-store.js';
11
11
  import type { TrustedOwnerStore, TrustSource } from './trusted-owner-store.js';
12
12
  import type { BootstrapPeerStore } from './bootstrap-peer-store.js';
13
+ import type { StrandPeerBookStore } from './strand-peer-book.js';
13
14
  import type { EnrolledMachineStore } from './enrolled-machine-store.js';
15
+ import type { JoinedStrandStore } from './joined-strand-store.js';
14
16
  import type { PushNotifier } from './push-notifier.js';
15
17
  import type { RevocableTable } from './control-authorization.js';
16
18
  import type { ControlRetryAbandonment } from './control-retry.js';
@@ -874,6 +876,52 @@ export interface CadreNodeConfig {
874
876
  */
875
877
  store?: EnrolledMachineStore;
876
878
  };
879
+ /**
880
+ * Node-local record of the strands this node joined from ANOTHER party (see
881
+ * `joined-strand-store.ts`): id, type and the closed strand's read secret, recorded
882
+ * by `formStrand` and by a joining (not `founder: true`) `addStrand` whose row is
883
+ * not in this party's control database, and re-offered on every start as `strand:discovered` — so an embedding
884
+ * app keeps no list of its own.
885
+ *
886
+ * Absent ⇒ a `KeyStoreJoinedStrandStore` over {@link keyStore} when one is
887
+ * configured (the record carries a secret, and the KeyStore is where every platform
888
+ * already keeps secrets), else an in-memory store that warns once and forgets every
889
+ * join on restart. An embedder that passes {@link privateKey} rather than a
890
+ * `keyStore` injects a durable store here, e.g.
891
+ * `new KeyStoreJoinedStrandStore(new FileKeyStore(dir), partyId)`.
892
+ */
893
+ joinedStrands?: {
894
+ /** Its `partyId` must match `controlNetwork.partyId`; start() fails closed on a mismatch. */
895
+ store?: JoinedStrandStore;
896
+ };
897
+ /**
898
+ * Node-local strand peer book (see `strand-peer-book.ts`): per strand, the strand
899
+ * peers this node has met — the other parties' strand transport peers a formation
900
+ * carried back, and every strand peer observed on a live connection — with their
901
+ * last-known addresses. Read on every launch, hibernation resume and periodic
902
+ * address refresh, so a restarted machine dials the peers it was talking to before
903
+ * anything else, instead of coming back up alone (gotchoices/sereus#18). Sibling
904
+ * of {@link bootstrapPeers} — same NON-replicated, per-party, injected-backend
905
+ * shape — and, like it, nothing here is trust-bearing: dial hints only, each
906
+ * bound to its peer id. Entries age out after 14 days (`STRAND_PEER_MAX_AGE_MS`,
907
+ * overridable per store via `StrandPeerBookOptions.maxAgeMs`).
908
+ *
909
+ * Absent ⇒ an in-memory store is created at start() (ephemeral: the book dies
910
+ * with the process, and a cross-party strand whose only contact was the other
911
+ * party does not re-mesh after a restart until a fresh formation). Every
912
+ * reference embedder injects a durable backend over the same slot kind as its
913
+ * bootstrap-peer store. A new platform needs no new store class: supply a
914
+ * `DurableSlot` and inject `PersistentStrandPeerBookStore.open(slot, partyId)`.
915
+ */
916
+ strandPeers?: {
917
+ /**
918
+ * Injected store instance — e.g. a `FileStrandPeerBookStore` from the
919
+ * Node-only subpath `@serfab/cadre-core/strand-peer-book-file`, persisted in
920
+ * the node's state directory. Its `partyId` must match
921
+ * `controlNetwork.partyId`; start() fails closed on a mismatch.
922
+ */
923
+ store?: StrandPeerBookStore;
924
+ };
877
925
  /**
878
926
  * Platform push-delivery for suspended mobile peers. When present, the node's
879
927
  * server fan-out can deliver strand-wake data messages over the platform push
@@ -1296,6 +1344,10 @@ export interface CadreNodeEvents {
1296
1344
  * re-admits this party, so a second removal is reported again — and a
1297
1345
  * hibernation wake rebuilds the gate, which may re-emit for a strand still
1298
1346
  * revoked.
1347
+ *
1348
+ * For a strand joined from another party, the node also forgets its remembered
1349
+ * join (see {@link CadreNodeConfig.joinedStrands}): it keeps running this session
1350
+ * and is not re-offered after the next start.
1299
1351
  */
1300
1352
  'strand:revoked': {
1301
1353
  strandId: string;
@@ -1333,6 +1385,12 @@ export interface CadreNodeEvents {
1333
1385
  * Carries the full {@link StrandRow} so the app can join without re-querying
1334
1386
  * the control DB.
1335
1387
  *
1388
+ * Also emitted for a strand this node joined from ANOTHER party, which no control
1389
+ * row names: the node remembers every such join (see
1390
+ * {@link CadreNodeConfig.joinedStrands}) and offers it here on each start, as a row
1391
+ * with `FounderOwnerKey: null` carrying the closed strand's `MemberPrivateKey`. That
1392
+ * row is the product of the formation's consent, so claiming it needs no second one.
1393
+ *
1336
1394
  * **Fired once per strand per session, and it can fire before your listener is
1337
1395
  * attached.** The strand watcher's first poll runs inside `CadreNode.start()`
1338
1396
  * (100 ms after the watcher starts), so every strand already stored for this
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAgFA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAA6C;IAC5E,QAAQ,EAAE;QACR,WAAW,EAAE,QAAQ,EAAS,aAAa;QAC3C,gBAAgB,EAAE,QAAQ,EAAI,kBAAkB;QAChD,eAAe,EAAE,QAAQ,EAAK,MAAM;QACpC,oBAAoB,EAAE,CAAC;QACvB,kBAAkB,EAAE,QAAQ,CAAE,MAAM;KACrC;IACD,WAAW,EAAE;QACX,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,EAAI,YAAY;QAC1C,gBAAgB,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,wBAAwB;QAC1D,eAAe,EAAE,EAAE,GAAG,IAAI,EAAI,mBAAmB;QACjD,oBAAoB,EAAE,CAAC;QACvB,kBAAkB,EAAE,EAAE,GAAG,EAAE,GAAG,IA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IAAI,EAAG,eAAe;QACjD,oBAAoB,EAAE,CAAC;QACvB,kBAAkB,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,eAAe;KAC5D;CACF,CAAC;AA2aF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC,MAAM,CAAC;IACtD,uFAAuF;IACvF,mFAAmF;IACnF,YAAY,EAAE,KAAM;IACpB,kFAAkF;IAClF,kFAAkF;IAClF,mBAAmB;IACnB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,KAAM,EAAE,UAAU,EAAE,KAAM,EAAE,CAAC;CACjC,CAAC,CAAC;AAmBzC;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,GAAG,IAAI,CAAC;AAYnD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,2BAA2B,EAC3B,sBAAsB,EACtB,2BAA2B,EAC3B,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,+BAA+B,CAAC;AAEvC;;;;;GAKG;AACH,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serfab/cadre-core",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "type": "module",
5
5
  "description": "Core library for Sereus cadre nodes - manages control networks and strand participation",
6
6
  "main": "dist/index.js",
@@ -36,6 +36,10 @@
36
36
  "types": "./dist/enrolled-machine-store-file.d.ts",
37
37
  "import": "./dist/enrolled-machine-store-file.js"
38
38
  },
39
+ "./strand-peer-book-file": {
40
+ "types": "./dist/strand-peer-book-file.d.ts",
41
+ "import": "./dist/strand-peer-book-file.js"
42
+ },
39
43
  "./push-node": {
40
44
  "types": "./dist/push-node.d.ts",
41
45
  "import": "./dist/push-node.js"
@@ -93,7 +97,7 @@
93
97
  "@optimystic/quereus-plugin-crypto": "^1.7.0",
94
98
  "@optimystic/quereus-plugin-optimystic": "^1.7.0",
95
99
  "@quereus/quereus": "^4.20.0",
96
- "@serfab/quereus-plugin-sereus": "^1.6.0",
100
+ "@serfab/quereus-plugin-sereus": "^1.7.0",
97
101
  "debug": "^4.4.3",
98
102
  "libp2p": "^3.1.3",
99
103
  "uint8arrays": "^5.1.0"