@serfab/cadre-core 0.8.1 → 0.9.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 (93) hide show
  1. package/README.md +2 -2
  2. package/dist/cadre-node.d.ts +101 -61
  3. package/dist/cadre-node.js +165 -124
  4. package/dist/cadre-node.js.map +1 -1
  5. package/dist/control-cohort.d.ts +15 -15
  6. package/dist/control-cohort.js +14 -14
  7. package/dist/control-cohort.js.map +1 -1
  8. package/dist/control-database.d.ts +51 -34
  9. package/dist/control-database.js +72 -56
  10. package/dist/control-database.js.map +1 -1
  11. package/dist/control-formation-recorder.d.ts +2 -2
  12. package/dist/control-formation-recorder.js +2 -2
  13. package/dist/control-schema.d.ts +1 -1
  14. package/dist/control-schema.js +57 -33
  15. package/dist/control-schema.js.map +1 -1
  16. package/dist/device-token.d.ts +1 -1
  17. package/dist/device-token.js +1 -1
  18. package/dist/{authority-key.d.ts → ed25519-key.d.ts} +11 -10
  19. package/dist/{authority-key.js → ed25519-key.js} +9 -10
  20. package/dist/ed25519-key.js.map +1 -0
  21. package/dist/index.d.ts +3 -3
  22. package/dist/index.js +8 -8
  23. package/dist/index.js.map +1 -1
  24. package/dist/key-store.d.ts +1 -1
  25. package/dist/key-store.js +1 -1
  26. package/dist/peer-authorization.d.ts +28 -6
  27. package/dist/peer-authorization.js +33 -7
  28. package/dist/peer-authorization.js.map +1 -1
  29. package/dist/peer-record.d.ts +3 -3
  30. package/dist/peer-record.js +3 -3
  31. package/dist/push-node.d.ts +38 -0
  32. package/dist/push-node.js +48 -0
  33. package/dist/push-node.js.map +1 -0
  34. package/dist/push-notifier-apns.d.ts +10 -2
  35. package/dist/push-notifier-apns.js +14 -10
  36. package/dist/push-notifier-apns.js.map +1 -1
  37. package/dist/push-notifier-fcm.d.ts +7 -1
  38. package/dist/push-notifier-fcm.js +9 -10
  39. package/dist/push-notifier-fcm.js.map +1 -1
  40. package/dist/push-notifier.d.ts +16 -35
  41. package/dist/push-notifier.js +16 -44
  42. package/dist/push-notifier.js.map +1 -1
  43. package/dist/seed-bootstrap.d.ts +70 -51
  44. package/dist/seed-bootstrap.js +168 -106
  45. package/dist/seed-bootstrap.js.map +1 -1
  46. package/dist/seed-trust-policy.d.ts +11 -11
  47. package/dist/seed-trust-policy.js +11 -11
  48. package/dist/seed-trust-policy.js.map +1 -1
  49. package/dist/strand-database.d.ts +5 -5
  50. package/dist/strand-database.js +4 -4
  51. package/dist/strand-database.js.map +1 -1
  52. package/dist/strand-formation-protocol.d.ts +1 -1
  53. package/dist/strand-formation-protocol.js +1 -1
  54. package/dist/strand-instance-manager.d.ts +1 -1
  55. package/dist/strand-instance-manager.js +1 -1
  56. package/dist/strand-instance-manager.js.map +1 -1
  57. package/dist/strand-member-key.d.ts +6 -6
  58. package/dist/strand-member-key.js +6 -6
  59. package/dist/strand-member-key.js.map +1 -1
  60. package/dist/strand-member-registry.d.ts +7 -7
  61. package/dist/strand-member-registry.js +5 -5
  62. package/dist/strand-member-registry.js.map +1 -1
  63. package/dist/strand-membership-writer.d.ts +84 -84
  64. package/dist/strand-membership-writer.js +90 -90
  65. package/dist/strand-membership-writer.js.map +1 -1
  66. package/dist/types.d.ts +52 -32
  67. package/dist/types.js.map +1 -1
  68. package/package.json +7 -3
  69. package/src/cadre-node.ts +170 -126
  70. package/src/control-cohort.ts +17 -17
  71. package/src/control-database.ts +76 -59
  72. package/src/control-formation-recorder.ts +2 -2
  73. package/src/control-schema.ts +57 -33
  74. package/src/device-token.ts +1 -1
  75. package/src/{authority-key.ts → ed25519-key.ts} +12 -11
  76. package/src/index.ts +21 -19
  77. package/src/key-store.ts +1 -1
  78. package/src/peer-authorization.ts +35 -7
  79. package/src/peer-record.ts +3 -3
  80. package/src/push-node.ts +64 -0
  81. package/src/push-notifier-apns.ts +16 -12
  82. package/src/push-notifier-fcm.ts +9 -10
  83. package/src/push-notifier.ts +16 -57
  84. package/src/seed-bootstrap.ts +179 -115
  85. package/src/seed-trust-policy.ts +18 -18
  86. package/src/strand-database.ts +6 -6
  87. package/src/strand-formation-protocol.ts +1 -1
  88. package/src/strand-instance-manager.ts +2 -2
  89. package/src/strand-member-key.ts +7 -7
  90. package/src/strand-member-registry.ts +10 -10
  91. package/src/strand-membership-writer.ts +127 -127
  92. package/src/types.ts +52 -32
  93. package/dist/authority-key.js.map +0 -1
package/src/types.ts CHANGED
@@ -4,6 +4,7 @@ import type { IRepo } from '@optimystic/db-core';
4
4
  import type { StrandDatabase } from './strand-database.js';
5
5
  import type { SeedTrustPolicy } from './seed-trust-policy.js';
6
6
  import type { KeyStore, KeyId } from './key-store.js';
7
+ import type { PushNotifier } from './push-notifier.js';
7
8
 
8
9
  /**
9
10
  * Extended Libp2p node with the coordinatedRepo attached by db-p2p's
@@ -165,7 +166,7 @@ export interface NetworkConfig {
165
166
  transports?: Libp2pTransports;
166
167
  /**
167
168
  * Optional async resolver returning the multiaddrs to embed in invites
168
- * (and other authority-address contexts). When unset, `libp2pNode.getMultiaddrs()`
169
+ * (and other owner-address contexts). When unset, `libp2pNode.getMultiaddrs()`
169
170
  * is used. Hosts behind NAT supply this to substitute their DDNS hostname
170
171
  * and externally-mapped port — see `@serfab/cadre-host`'s NatService.
171
172
  */
@@ -190,8 +191,8 @@ export interface NetworkConfig {
190
191
  */
191
192
  controlCohort?: {
192
193
  /**
193
- * Cap on the number of NON-authority siblings dialed per reconcile pass
194
- * (backbone/authority members are always dialed and do not count). Defaults
194
+ * Cap on the number of NON-owner siblings dialed per reconcile pass
195
+ * (backbone/owner members are always dialed and do not count). Defaults
195
196
  * to {@link DEFAULT_CONTROL_COHORT_TARGET_DEGREE}.
196
197
  */
197
198
  targetDegree?: number;
@@ -254,10 +255,10 @@ export interface CadreNodeConfig {
254
255
  * form). Mutually exclusive with {@link privateKey}. Absent ⇒ legacy behavior
255
256
  * (use `privateKey`, else libp2p generates an ephemeral key).
256
257
  *
257
- * In the single-key reference model the authority signing key is *derived from*
258
- * the node identity (see {@link CadreNode.getIdentityAuthorityKey}), so
259
- * protecting the identity in a secure enclave protects the authority key too.
260
- * A future separate-authority slot (`authorityKeyId`) is anticipated but not
258
+ * In the single-key reference model the owner signing key is *derived from*
259
+ * the node identity (see {@link CadreNode.getIdentityOwnerKey}), so
260
+ * protecting the identity in a secure enclave protects the owner key too.
261
+ * A future separate-owner slot (`ownerKeyId`) is anticipated but not
261
262
  * built here.
262
263
  */
263
264
  keyStore?: KeyStore;
@@ -296,7 +297,7 @@ export interface CadreNodeConfig {
296
297
 
297
298
  /**
298
299
  * Node-wide default trust anchor for INBOUND control-network seeds. Forwarded
299
- * into every SeedBootstrapService this node constructs (authority, receive-only
300
+ * into every SeedBootstrapService this node constructs (owner, receive-only
300
301
  * listener, and the temp service used by applySeed when no service exists), and
301
302
  * used as the service-level default the libp2p seed-protocol handler relies on
302
303
  * (that path has no per-call override seam). Defaults to dbAnchoredTrustPolicy()
@@ -308,13 +309,32 @@ export interface CadreNodeConfig {
308
309
  seedTrustPolicy?: SeedTrustPolicy;
309
310
 
310
311
  /**
311
- * Platform push-delivery credentials (FCM and/or APNs). When present, the node
312
- * can deliver strand-wake data messages to suspended mobile peers over the
313
- * platform push channel — the server fan-out constructs a `PushNotifier` from
314
- * this. Absent ⇒ no platform push (control-network push-wake only). Injected
315
- * per node by `cadre-host`; `privateKey` fields are secrets and are never logged.
312
+ * Platform push-delivery for suspended mobile peers. When present, the node's
313
+ * server fan-out can deliver strand-wake data messages over the platform push
314
+ * channel (FCM/APNs). Absent ⇒ no platform push (control-network push-wake only).
315
+ *
316
+ * The `notifier` is **injected**, not constructed here: a Node host builds it
317
+ * from `@serfab/cadre-core/push-node` (`createPushNotifier(credentials)`) and
318
+ * passes the instance, so the FCM/APNs modules (`node:crypto`/`node:http2`)
319
+ * stay out of the cross-platform core graph. Ownership transfers to the node on
320
+ * injection — `CadreNode.stop` closes the notifier (via `PushFanoutService`),
321
+ * releasing its APNs HTTP/2 session; a host must NOT also close an injected
322
+ * notifier itself. `cooldownMs`/`debounceMs` carry the fan-out anti-spam policy.
316
323
  */
317
- push?: PushCredentials;
324
+ push?: {
325
+ /** The Node-constructed push router (see `@serfab/cadre-core/push-node`). */
326
+ notifier: PushNotifier;
327
+ /**
328
+ * Per-`(peer, strand)` minimum gap between push-wakes the fan-out emits.
329
+ * Default {@link DEFAULT_PUSH_COOLDOWN_MS} (5 min).
330
+ */
331
+ cooldownMs?: number;
332
+ /**
333
+ * Per-strand burst-coalescing window: a second trigger within it is dropped.
334
+ * Default {@link DEFAULT_PUSH_DEBOUNCE_MS} (10 s).
335
+ */
336
+ debounceMs?: number;
337
+ };
318
338
  }
319
339
 
320
340
  /**
@@ -458,7 +478,7 @@ export interface StrandConfig {
458
478
  * published the strand (the responder in formation, the creator in host/solo
459
479
  * paths; the same party that calls {@link CadreNode.publishStrand}). The founder
460
480
  * runs the one-time membership bootstrap at bring-up (writes `Strand.Header`, and
461
- * for a closed strand the founding `Member`+`Authority`). A joiner leaves this
481
+ * for a closed strand the founding `Member`+`Manager`). A joiner leaves this
462
482
  * `false`/unset and writes nothing — it receives those rows via Optimystic sync.
463
483
  * Defaults to `false`.
464
484
  */
@@ -638,11 +658,11 @@ export interface PeerAddressRecord {
638
658
 
639
659
  /**
640
660
  * Outcome of {@link CadreNode.registerSelf}, surfaced so callers (e.g. the CLI
641
- * `--authority` branch) can log what happened:
642
- * - `inserted` — the first authority-signed INSERT of this node's `CadrePeer` row.
661
+ * `--owner` branch) can log what happened:
662
+ * - `inserted` — the first owner-signed INSERT of this node's `CadrePeer` row.
643
663
  * - `refreshed` — a self-signed UPDATE of an existing row (heartbeat / addr change).
644
664
  * - `skipped` — nothing written (no self-signing key, or not yet a member with no
645
- * authority service to self-insert).
665
+ * owner service to self-insert).
646
666
  */
647
667
  export type SelfRegistrationOutcome = 'inserted' | 'refreshed' | 'skipped';
648
668
 
@@ -661,7 +681,7 @@ export interface ResolveOpts {
661
681
  /**
662
682
  * Pluggable trust gate, evaluated after signature + freshness pass. Defaults
663
683
  * to {@link currentMemberTrustPolicy} (any existing — therefore
664
- * authority-vouched — CadrePeer member is trusted). Inject a stricter policy
684
+ * owner-vouched — CadrePeer member is trusted). Inject a stricter policy
665
685
  * (e.g. from `seed-signerkey-trust-policy`) to reject otherwise-valid records
666
686
  * before dialing.
667
687
  */
@@ -809,9 +829,9 @@ export interface SeedPeer {
809
829
  peerId: string;
810
830
  /** Multiaddrs for connecting to this peer */
811
831
  multiaddrs: string[];
812
- /** Whether this peer holds an authority key */
813
- isAuthority: boolean;
814
- /** ed25519 public key (base64url) — present on authority peers for signerKey verification */
832
+ /** Whether this peer holds an owner key */
833
+ isOwner: boolean;
834
+ /** ed25519 public key (base64url) — present on owner peers for signerKey verification */
815
835
  publicKey?: string;
816
836
  }
817
837
 
@@ -826,9 +846,9 @@ export interface ControlNetworkSeed {
826
846
  partyId: string;
827
847
  /** Known peers in the cadre */
828
848
  peers: SeedPeer[];
829
- /** Signature over the seed by an authority key */
849
+ /** Signature over the seed by an owner key */
830
850
  signature: string;
831
- /** The authority key that signed this seed */
851
+ /** The owner key that signed this seed */
832
852
  signerKey: string;
833
853
  }
834
854
 
@@ -841,9 +861,9 @@ export interface SeedMessage {
841
861
  partyId: string;
842
862
  /** Known peers in the cadre */
843
863
  peers: SeedPeer[];
844
- /** Signature by an authority key */
864
+ /** Signature by an owner key */
845
865
  signature: string;
846
- /** The authority key that signed this message */
866
+ /** The owner key that signed this message */
847
867
  signerKey: string;
848
868
  }
849
869
 
@@ -953,15 +973,15 @@ export type NodeTopology = 'public' | 'nat';
953
973
  export interface CadreInvite {
954
974
  /** Party ID of the cadre */
955
975
  partyId: string;
956
- /** Multiaddrs to dial the authority */
957
- authorityAddrs: string[];
976
+ /** Multiaddrs to dial the owner */
977
+ ownerAddrs: string[];
958
978
  /**
959
- * Authority ed25519 public keys (base64url) of the cadre, carried out-of-band
960
- * so a cold-start invitee can pin the trusted authority set before applying
979
+ * Owner ed25519 public keys (base64url) of the cadre, carried out-of-band
980
+ * so a cold-start invitee can pin the trusted owner set before applying
961
981
  * any seed (the seed itself cannot vouch for its own signer). Populated by
962
- * `createInvite` from the issuer's `AuthorityKey` table.
982
+ * `createInvite` from the issuer's `OwnerKey` table.
963
983
  */
964
- authorityKeys?: string[];
984
+ ownerKeys?: string[];
965
985
  /** Optional invite token for validation */
966
986
  token?: string;
967
987
  /** Timestamp when invite was created */
@@ -1 +0,0 @@
1
- {"version":3,"file":"authority-key.js","sourceRoot":"","sources":["../src/authority-key.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAcjE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,sBAAsB,CAAC,UAAsB;IAC3D,IAAI,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,uDAAuD,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5F,CAAC;IAED,MAAM,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC;IAC3B,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,kEAAkE,GAAG,CAAC,MAAM,QAAQ,CAAC,CAAC;IACxG,CAAC;IAED,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACjC,MAAM,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC;IAC9C,IAAI,YAAY,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,8CAA8C,YAAY,CAAC,MAAM,QAAQ,CAAC,CAAC;IAC7F,CAAC;IAED,OAAO;QACL,aAAa,EAAE,kBAAkB,CAAC,IAAI,EAAE,WAAW,CAAC;QACpD,YAAY,EAAE,kBAAkB,CAAC,YAAY,EAAE,WAAW,CAAC;KAC5D,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,6BAA6B,CAAC,aAAqB;IACjE,OAAO,YAAY,CAAC,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,CAAW,CAAC;AACpF,CAAC"}