@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.
- package/README.md +2 -2
- package/dist/cadre-node.d.ts +101 -61
- package/dist/cadre-node.js +165 -124
- package/dist/cadre-node.js.map +1 -1
- package/dist/control-cohort.d.ts +15 -15
- package/dist/control-cohort.js +14 -14
- package/dist/control-cohort.js.map +1 -1
- package/dist/control-database.d.ts +51 -34
- package/dist/control-database.js +72 -56
- package/dist/control-database.js.map +1 -1
- package/dist/control-formation-recorder.d.ts +2 -2
- package/dist/control-formation-recorder.js +2 -2
- package/dist/control-schema.d.ts +1 -1
- package/dist/control-schema.js +57 -33
- package/dist/control-schema.js.map +1 -1
- package/dist/device-token.d.ts +1 -1
- package/dist/device-token.js +1 -1
- package/dist/{authority-key.d.ts → ed25519-key.d.ts} +11 -10
- package/dist/{authority-key.js → ed25519-key.js} +9 -10
- package/dist/ed25519-key.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/key-store.d.ts +1 -1
- package/dist/key-store.js +1 -1
- package/dist/peer-authorization.d.ts +28 -6
- package/dist/peer-authorization.js +33 -7
- package/dist/peer-authorization.js.map +1 -1
- package/dist/peer-record.d.ts +3 -3
- package/dist/peer-record.js +3 -3
- package/dist/push-node.d.ts +38 -0
- package/dist/push-node.js +48 -0
- package/dist/push-node.js.map +1 -0
- package/dist/push-notifier-apns.d.ts +10 -2
- package/dist/push-notifier-apns.js +14 -10
- package/dist/push-notifier-apns.js.map +1 -1
- package/dist/push-notifier-fcm.d.ts +7 -1
- package/dist/push-notifier-fcm.js +9 -10
- package/dist/push-notifier-fcm.js.map +1 -1
- package/dist/push-notifier.d.ts +16 -35
- package/dist/push-notifier.js +16 -44
- package/dist/push-notifier.js.map +1 -1
- package/dist/seed-bootstrap.d.ts +70 -51
- package/dist/seed-bootstrap.js +168 -106
- package/dist/seed-bootstrap.js.map +1 -1
- package/dist/seed-trust-policy.d.ts +11 -11
- package/dist/seed-trust-policy.js +11 -11
- package/dist/seed-trust-policy.js.map +1 -1
- package/dist/strand-database.d.ts +5 -5
- package/dist/strand-database.js +4 -4
- package/dist/strand-database.js.map +1 -1
- package/dist/strand-formation-protocol.d.ts +1 -1
- package/dist/strand-formation-protocol.js +1 -1
- package/dist/strand-instance-manager.d.ts +1 -1
- package/dist/strand-instance-manager.js +1 -1
- package/dist/strand-instance-manager.js.map +1 -1
- package/dist/strand-member-key.d.ts +6 -6
- package/dist/strand-member-key.js +6 -6
- package/dist/strand-member-key.js.map +1 -1
- package/dist/strand-member-registry.d.ts +7 -7
- package/dist/strand-member-registry.js +5 -5
- package/dist/strand-member-registry.js.map +1 -1
- package/dist/strand-membership-writer.d.ts +84 -84
- package/dist/strand-membership-writer.js +90 -90
- package/dist/strand-membership-writer.js.map +1 -1
- package/dist/types.d.ts +52 -32
- package/dist/types.js.map +1 -1
- package/package.json +7 -3
- package/src/cadre-node.ts +170 -126
- package/src/control-cohort.ts +17 -17
- package/src/control-database.ts +76 -59
- package/src/control-formation-recorder.ts +2 -2
- package/src/control-schema.ts +57 -33
- package/src/device-token.ts +1 -1
- package/src/{authority-key.ts → ed25519-key.ts} +12 -11
- package/src/index.ts +21 -19
- package/src/key-store.ts +1 -1
- package/src/peer-authorization.ts +35 -7
- package/src/peer-record.ts +3 -3
- package/src/push-node.ts +64 -0
- package/src/push-notifier-apns.ts +16 -12
- package/src/push-notifier-fcm.ts +9 -10
- package/src/push-notifier.ts +16 -57
- package/src/seed-bootstrap.ts +179 -115
- package/src/seed-trust-policy.ts +18 -18
- package/src/strand-database.ts +6 -6
- package/src/strand-formation-protocol.ts +1 -1
- package/src/strand-instance-manager.ts +2 -2
- package/src/strand-member-key.ts +7 -7
- package/src/strand-member-registry.ts +10 -10
- package/src/strand-membership-writer.ts +127 -127
- package/src/types.ts +52 -32
- 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
|
|
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-
|
|
194
|
-
* (backbone/
|
|
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
|
|
258
|
-
* the node identity (see {@link CadreNode.
|
|
259
|
-
* protecting the identity in a secure enclave protects the
|
|
260
|
-
* A future separate-
|
|
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 (
|
|
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
|
|
312
|
-
* can deliver strand-wake data messages
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
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?:
|
|
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`+`
|
|
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
|
-
* `--
|
|
642
|
-
* - `inserted` — the first
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
|
813
|
-
|
|
814
|
-
/** ed25519 public key (base64url) — present on
|
|
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
|
|
849
|
+
/** Signature over the seed by an owner key */
|
|
830
850
|
signature: string;
|
|
831
|
-
/** The
|
|
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
|
|
864
|
+
/** Signature by an owner key */
|
|
845
865
|
signature: string;
|
|
846
|
-
/** The
|
|
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
|
|
957
|
-
|
|
976
|
+
/** Multiaddrs to dial the owner */
|
|
977
|
+
ownerAddrs: string[];
|
|
958
978
|
/**
|
|
959
|
-
*
|
|
960
|
-
* so a cold-start invitee can pin the trusted
|
|
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 `
|
|
982
|
+
* `createInvite` from the issuer's `OwnerKey` table.
|
|
963
983
|
*/
|
|
964
|
-
|
|
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"}
|