@serfab/cadre-core 0.11.0 → 0.13.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 (121) hide show
  1. package/README.md +3 -2
  2. package/dist/announce-addrs.d.ts +49 -0
  3. package/dist/announce-addrs.js +78 -0
  4. package/dist/announce-addrs.js.map +1 -0
  5. package/dist/cadre-node.d.ts +607 -53
  6. package/dist/cadre-node.js +1268 -157
  7. package/dist/cadre-node.js.map +1 -1
  8. package/dist/control-database.d.ts +174 -23
  9. package/dist/control-database.js +317 -107
  10. package/dist/control-database.js.map +1 -1
  11. package/dist/control-read-retry.d.ts +103 -0
  12. package/dist/control-read-retry.js +145 -0
  13. package/dist/control-read-retry.js.map +1 -0
  14. package/dist/control-retry.d.ts +101 -0
  15. package/dist/control-retry.js +108 -0
  16. package/dist/control-retry.js.map +1 -0
  17. package/dist/control-schema.d.ts +1 -1
  18. package/dist/control-schema.js +50 -6
  19. package/dist/control-schema.js.map +1 -1
  20. package/dist/control-write-retry.d.ts +59 -35
  21. package/dist/control-write-retry.js +21 -92
  22. package/dist/control-write-retry.js.map +1 -1
  23. package/dist/delegate-admission.d.ts +17 -15
  24. package/dist/delegate-admission.js +17 -15
  25. package/dist/delegate-admission.js.map +1 -1
  26. package/dist/enrolled-machine-store-file.d.ts +13 -0
  27. package/dist/enrolled-machine-store-file.js +41 -0
  28. package/dist/enrolled-machine-store-file.js.map +1 -0
  29. package/dist/enrolled-machine-store.d.ts +81 -0
  30. package/dist/enrolled-machine-store.js +225 -0
  31. package/dist/enrolled-machine-store.js.map +1 -0
  32. package/dist/file-durable-slot.js +5 -3
  33. package/dist/file-durable-slot.js.map +1 -1
  34. package/dist/index.d.ts +10 -6
  35. package/dist/index.js +39 -12
  36. package/dist/index.js.map +1 -1
  37. package/dist/membership-connection-gater.d.ts +226 -26
  38. package/dist/membership-connection-gater.js +316 -30
  39. package/dist/membership-connection-gater.js.map +1 -1
  40. package/dist/node-local-snapshot.d.ts +6 -0
  41. package/dist/node-local-snapshot.js +7 -1
  42. package/dist/node-local-snapshot.js.map +1 -1
  43. package/dist/{strand-backfill.d.ts → peer-join-backfill.d.ts} +49 -20
  44. package/dist/{strand-backfill.js → peer-join-backfill.js} +146 -56
  45. package/dist/peer-join-backfill.js.map +1 -0
  46. package/dist/peer-record.d.ts +26 -0
  47. package/dist/peer-record.js +32 -0
  48. package/dist/peer-record.js.map +1 -1
  49. package/dist/relay-addrs.d.ts +145 -22
  50. package/dist/relay-addrs.js +314 -31
  51. package/dist/relay-addrs.js.map +1 -1
  52. package/dist/relay-reservation.d.ts +20 -15
  53. package/dist/relay-reservation.js +18 -14
  54. package/dist/relay-reservation.js.map +1 -1
  55. package/dist/strand-addr-protocol.js +16 -0
  56. package/dist/strand-addr-protocol.js.map +1 -1
  57. package/dist/strand-database.d.ts +12 -0
  58. package/dist/strand-database.js +16 -0
  59. package/dist/strand-database.js.map +1 -1
  60. package/dist/strand-formation-manager.d.ts +22 -9
  61. package/dist/strand-formation-manager.js +20 -12
  62. package/dist/strand-formation-manager.js.map +1 -1
  63. package/dist/strand-formation-protocol.d.ts +83 -9
  64. package/dist/strand-formation-protocol.js +86 -10
  65. package/dist/strand-formation-protocol.js.map +1 -1
  66. package/dist/strand-instance-manager.d.ts +151 -17
  67. package/dist/strand-instance-manager.js +237 -32
  68. package/dist/strand-instance-manager.js.map +1 -1
  69. package/dist/strand-membership-writer.d.ts +118 -14
  70. package/dist/strand-membership-writer.js +203 -15
  71. package/dist/strand-membership-writer.js.map +1 -1
  72. package/dist/strand-network-config.d.ts +84 -0
  73. package/dist/strand-network-config.js +136 -0
  74. package/dist/strand-network-config.js.map +1 -0
  75. package/dist/strand-revocation-enforcer.d.ts +392 -0
  76. package/dist/strand-revocation-enforcer.js +533 -0
  77. package/dist/strand-revocation-enforcer.js.map +1 -0
  78. package/dist/strand-solicitation.d.ts +10 -3
  79. package/dist/strand-solicitation.js +12 -7
  80. package/dist/strand-solicitation.js.map +1 -1
  81. package/dist/strand-wake-protocol.d.ts +47 -2
  82. package/dist/strand-wake-protocol.js +76 -6
  83. package/dist/strand-wake-protocol.js.map +1 -1
  84. package/dist/strand-watcher.js +6 -1
  85. package/dist/strand-watcher.js.map +1 -1
  86. package/dist/types.d.ts +282 -43
  87. package/dist/types.js +7 -1
  88. package/dist/types.js.map +1 -1
  89. package/package.json +16 -8
  90. package/src/announce-addrs.ts +93 -0
  91. package/src/cadre-node.ts +1366 -171
  92. package/src/control-database.ts +2628 -2406
  93. package/src/control-read-retry.ts +167 -0
  94. package/src/control-retry.ts +190 -0
  95. package/src/control-schema.ts +50 -6
  96. package/src/control-write-retry.ts +30 -130
  97. package/src/delegate-admission.ts +17 -15
  98. package/src/enrolled-machine-store-file.ts +43 -0
  99. package/src/enrolled-machine-store.ts +280 -0
  100. package/src/file-durable-slot.ts +5 -3
  101. package/src/index.ts +477 -407
  102. package/src/membership-connection-gater.ts +539 -204
  103. package/src/node-local-snapshot.ts +13 -1
  104. package/src/peer-addr-book.ts +251 -250
  105. package/src/{strand-backfill.ts → peer-join-backfill.ts} +187 -75
  106. package/src/peer-record.ts +33 -0
  107. package/src/relay-addrs.ts +436 -111
  108. package/src/relay-reservation.ts +828 -823
  109. package/src/strand-addr-protocol.ts +17 -0
  110. package/src/strand-database.ts +17 -0
  111. package/src/strand-formation-manager.ts +511 -491
  112. package/src/strand-formation-protocol.ts +808 -692
  113. package/src/strand-instance-manager.ts +899 -611
  114. package/src/strand-membership-writer.ts +232 -15
  115. package/src/strand-network-config.ts +172 -0
  116. package/src/strand-revocation-enforcer.ts +653 -0
  117. package/src/strand-solicitation.ts +484 -472
  118. package/src/strand-wake-protocol.ts +94 -8
  119. package/src/strand-watcher.ts +319 -314
  120. package/src/types.ts +1554 -1309
  121. package/dist/strand-backfill.js.map +0 -1
package/src/index.ts CHANGED
@@ -1,407 +1,477 @@
1
- // Core types
2
- export * from './types.js';
3
-
4
- // Canonical JSON serialization (shared signing payload format)
5
- export { canonicalJson } from './canonical-json.js';
6
-
7
- // Main CadreNode class
8
- export { CadreNode } from './cadre-node.js';
9
-
10
- // Control database
11
- export { ControlDatabase, MissingHostStrandError, buildAuthorizationMessage, formationVouchMessage, formationConsentMessage, REAPABLE_TABLES, type ReapableTable, type ControlDatabaseConfig, type ControlTable, type RevocableTable, type FormationUsageResult, type MembershipChangeListener, type GuardedDeleteListener, type RevokedRowRef } from './control-database.js';
12
-
13
- // Bounded retry for transient control-write failures (classifier + loop behind
14
- // ControlDatabase.lockedWithRetry; exported so the integration package can drive the
15
- // classifier against real engine errors)
16
- export {
17
- CONTROL_WRITE_ATTEMPTS,
18
- CONTROL_WRITE_RETRY_BUDGET_MS,
19
- SCHEMA_INIT_ATTEMPTS,
20
- SCHEMA_INIT_RETRY_POLICY,
21
- isRetriableControlWriteFailure,
22
- isRetriableSchemaInitFailure,
23
- retryControlWrite,
24
- type ControlWriteRetryOptions
25
- } from './control-write-retry.js';
26
-
27
- // Control-plane authorization field vector (the domain/action tagging every signer shares)
28
- export { controlAuthorizationFields, type ControlDomain, type ControlAction } from './control-authorization.js';
29
-
30
- // Ed25519 key bridge (libp2p Ed25519 -> base64url keypair)
31
- export { ed25519KeyPairFromLibp2p, ed25519PublicKeyFromPrivate, requireEd25519PublicKeyB64, type Ed25519KeyPair } from './ed25519-key.js';
32
-
33
- // Pluggable key store (backend-agnostic identity/owner key material seam).
34
- // Dependency-free: the interface, error, default slot id, and in-memory backend
35
- // are safe in every (RN/browser/Node) entry graph. The Node FileKeyStore is a
36
- // separate subpath module ('@serfab/cadre-core/key-store-file') so its node:fs
37
- // import never lands here.
38
- export {
39
- InMemoryKeyStore,
40
- KeyStoreAccessError,
41
- DEFAULT_IDENTITY_KEY_ID,
42
- type KeyStore,
43
- type KeyId
44
- } from './key-store.js';
45
-
46
- // The KeyStore-backed identity rule, shared with embedding apps that need the
47
- // node key BEFORE `CadreNode` exists (RN resolves it to sign its ICE-manifest
48
- // request), plus the generic "prove you hold this node key" signer built on it.
49
- export {
50
- loadOrCreateIdentityKey,
51
- peerKeySigner,
52
- type PeerKeySigner
53
- } from './identity-key.js';
54
-
55
- // Node-local trusted-owner anchor: the NON-replicated, per-party record of
56
- // out-of-band-established owner keys (the trust anchor the replicated OwnerKey
57
- // table cannot be). Cross-platform: interface + in-memory store only — the
58
- // file-backed store is the Node-only subpath
59
- // '@serfab/cadre-core/trusted-owner-store-file' (same isolation as
60
- // key-store-file) so node:fs never lands in this graph.
61
- export {
62
- MemoryTrustedOwnerStore,
63
- PersistentTrustedOwnerStore,
64
- type TrustedOwnerStore,
65
- type TrustSource
66
- } from './trusted-owner-store.js';
67
-
68
- // The one platform-specific piece of a persistent node-local store: a single
69
- // durable text slot the embedding app supplies (IndexedDB / SecureStore /
70
- // SQLite / a file). Everything else — envelope, load policy, snapshot write
71
- // chain — is cross-platform in node-local-snapshot.ts.
72
- export type { DurableSlot } from './node-local-snapshot.js';
73
-
74
- // Node-local cold-start bootstrap-peer store: the dial targets retained from an
75
- // applied seed so a node that could not connect on its first try keeps retrying
76
- // across restarts. Same cross-platform split as the trusted-owner anchor above —
77
- // interface + in-memory store here, Node-only file backend behind the subpath
78
- // '@serfab/cadre-core/bootstrap-peer-store-file'.
79
- export {
80
- MemoryBootstrapPeerStore,
81
- PersistentBootstrapPeerStore,
82
- type BootstrapPeerStore,
83
- type BootstrapPeerEntry
84
- } from './bootstrap-peer-store.js';
85
-
86
- // Strand database
87
- export { StrandDatabase, type StrandDatabaseConfig } from './strand-database.js';
88
-
89
- // Strand management
90
- export {
91
- StrandWatcher,
92
- type StrandWatcherCallbacks,
93
- type StrandQueryable,
94
- type SAppIdLookup,
95
- type StrandRowWithApp
96
- } from './strand-watcher.js';
97
- export {
98
- StrandInstanceManager,
99
- type StartStrandConfig,
100
- type ResumeStrandOverrides,
101
- getStrandStoragePath
102
- } from './strand-instance-manager.js';
103
-
104
- // Strand peer-join block catch-up (push this strand's own blocks to each newly
105
- // connected strand peer, so a late joiner physically holds pre-join blocks).
106
- export {
107
- StrandBackfill,
108
- DEFAULT_STRAND_BACKFILL,
109
- MAX_BLOCK_MESSAGE_BYTES,
110
- type StrandBackfillConfig,
111
- type StrandBackfillDeps,
112
- type StrandBackfillResult,
113
- type StrandBackfillPushClient
114
- } from './strand-backfill.js';
115
-
116
- // Hibernation
117
- export {
118
- HibernationManager,
119
- type HibernationCallbacks
120
- } from './hibernation-manager.js';
121
-
122
- // Arachnode (stub)
123
- export {
124
- ArachnodeStub,
125
- createArachnodeStub,
126
- type RingConfig
127
- } from './arachnode-stub.js';
128
-
129
- // Enrollment
130
- export {
131
- EnrollmentService,
132
- type MemberVerifier,
133
- type MemberRegistry
134
- } from './enrollment.js';
135
-
136
- // Strand Solicitation
137
- export {
138
- StrandSolicitationService,
139
- createDefaultFormationResponseValidator,
140
- type DisclosureValidator,
141
- type FormationUsageRecorder,
142
- type ResolvedHostStrand,
143
- type StrandProvisioner,
144
- type FormationResponseValidator,
145
- type StrandSolicitationServiceOptions
146
- } from './strand-solicitation.js';
147
-
148
- // Formation approval client: asks an invite's ValidationUrl hook whether ONE redemption
149
- // may proceed, and checks the answer against the bytes the control database will verify.
150
- export {
151
- createHttpFormationApprover,
152
- signFormationApproval,
153
- verifyFormationApproval,
154
- FormationApprovalError,
155
- type FormationApprovalRequest,
156
- type FormationVouchFields,
157
- type FormationApproval,
158
- type FormationApprover,
159
- type FormationApprovalFailure
160
- } from './formation-approval.js';
161
-
162
- // DB-backed FormationUsageRecorder (reads/writes the real CadreControl tables)
163
- export { ControlFormationUsageRecorder } from './control-formation-recorder.js';
164
-
165
- // Closed-strand member key generation (ed25519 protobuf, base64) + the
166
- // protobuf->base64url bridge that derives the founding Member/Manager key.
167
- export { generateStrandMemberKey, strandMemberKeyPair } from './strand-member-key.js';
168
-
169
- // Strand membership writer (founder bootstrap, invite issuance/consumption,
170
- // manager-admit, member-peer registration, manager rotation, + shared signing
171
- // primitives reused across the flows).
172
- export {
173
- signStrandPayload,
174
- verifyStrandPayload,
175
- signStrandApproval,
176
- generateStrandStampId,
177
- bootstrapFounderMembership,
178
- issueInvite,
179
- consumeInvite,
180
- cancelInvite,
181
- listOutstandingInvites,
182
- addMemberByManager,
183
- revokeMember,
184
- leaveStrand,
185
- registerMemberPeer,
186
- listMemberPeers,
187
- removeMemberPeer,
188
- addManager,
189
- admitManager,
190
- removeManager,
191
- STRAND_ENGINE,
192
- STRAND_ENGINE_VERSION,
193
- type FounderBootstrapParams,
194
- type IssueInviteParams,
195
- type IssuedInvite,
196
- type ConsumeInviteParams,
197
- type CancelInviteParams,
198
- type OutstandingInvite,
199
- type AddMemberByManagerParams,
200
- type RevokeMemberParams,
201
- type LeaveStrandParams,
202
- type RegisterMemberPeerParams,
203
- type RemoveOwnPeerParams,
204
- type RemoveMemberPeerByManagerParams,
205
- type RemoveMemberPeerParams,
206
- type AddManagerParams,
207
- type AdmitManagerParams,
208
- type RemoveManagerParams
209
- } from './strand-membership-writer.js';
210
-
211
- // Engine-canonical datetime helper (shared by control + strand signed-write flows
212
- // so a signed timestamp byte-matches the datetime-coerced column the CHECK sees).
213
- export { canonicalDatetime } from './canonical-datetime.js';
214
-
215
- // Strand-DB-backed EnrollmentService backing: concrete MemberRegistry +
216
- // MemberVerifier that write/read the real Strand.* membership tables.
217
- export {
218
- StrandMemberRegistry,
219
- StrandMemberVerifier,
220
- memberRegistrationPayload,
221
- type StrandAdmission
222
- } from './strand-member-registry.js';
223
-
224
- // Seed Bootstrap
225
- export {
226
- SeedBootstrapService,
227
- SEED_PROTOCOL,
228
- ed25519PublicKeyB64FromPeerId,
229
- type SeedBootstrapConfig,
230
- type SeedEventCallbacks
231
- } from './seed-bootstrap.js';
232
-
233
- // Peer Authorization (shared owner-signature digest + offline verifier)
234
- export {
235
- peerAuthorizationDigest,
236
- cadrePeerVoucherDigest,
237
- cadrePeerRemoveDigest,
238
- deviceTokenAddDigest,
239
- deviceTokenRemoveDigest,
240
- formationConsentDigest,
241
- verifyPeerAuthorization,
242
- verifyCadrePeerVoucher,
243
- verifyFormationConsent,
244
- type DeviceTokenAuthorizedRow
245
- } from './peer-authorization.js';
246
-
247
- // Strand Wake (control-network push-wake protocol)
248
- export {
249
- StrandWakeService,
250
- dialWake,
251
- WAKE_PROTOCOL,
252
- type StrandWakeServiceOptions,
253
- type DialWakeOptions
254
- } from './strand-wake-protocol.js';
255
-
256
- // Strand Address (control-network strand-address RPC) — wire types come via
257
- // `export * from './types.js'` (StrandAddrRequest / StrandAddrResponse).
258
- export {
259
- StrandAddrService,
260
- collectStrandAddrs,
261
- STRAND_ADDR_PROTOCOL,
262
- type StrandAddrServiceOptions,
263
- type StrandAddrPeer,
264
- type CollectStrandAddrsOptions
265
- } from './strand-addr-protocol.js';
266
-
267
- // Peer-address record (self-published, signed, freshness-stamped CadrePeer row)
268
- export {
269
- peerRecordSignedPayload,
270
- signPeerRecord,
271
- verifyPeerRecordSignature,
272
- isPeerRecordFresh,
273
- isSignalingAddr,
274
- orderSignalingFirst,
275
- currentMemberTrustPolicy,
276
- DEFAULT_PEER_RECORD_MAX_AGE_MS,
277
- DEFAULT_PEER_RECORD_HEARTBEAT_MS
278
- } from './peer-record.js';
279
-
280
- // Device-token record (self-published, signed FCM/APNs push token — CadrePeer sibling)
281
- export {
282
- deviceTokenSignedPayload,
283
- signDeviceTokenRecord,
284
- verifyDeviceTokenSignature,
285
- isPushPlatform
286
- } from './device-token.js';
287
-
288
- // Strand-wake payload contract (canonical; shared by the server sender + RN receiver)
289
- export { STRAND_WAKE_TYPE, type StrandWakePayload } from './strand-wake-payload.js';
290
-
291
- // Platform push delivery — the cross-platform `PushNotifier` *contract* only.
292
- // The FCM/APNs implementations (node:http2/node:crypto) and the
293
- // `createPushNotifier` router that builds them live behind the Node-only subpath
294
- // `@serfab/cadre-core/push-node` (`push-node.ts`), never in this graph. A Node
295
- // host constructs a notifier from that subpath and injects the instance into
296
- // `CadreNodeConfig.push.notifier`. These re-exports are type-only (erased at
297
- // emit), so the RN/browser entry graph never pulls the Node modules in.
298
- export type { PushNotifier, PushMessage, PushSendResult } from './push-notifier.js';
299
-
300
- // Push-credential validation + log redaction. Dependency-free (type-only imports),
301
- // so a provisioner (cadre-host / cadre-provider) can reject a partial credential
302
- // set and produce a key-safe log view without pulling the FCM/APNs sender graph.
303
- export { validatePushCredentials, redactPushCredentials, REDACTED } from './push-credentials.js';
304
-
305
- // Server-side push-wake trigger policy + fan-out (who/when to wake). Cross-platform
306
- // clean — it imports only the PushNotifier *type*, so exporting it as a runtime
307
- // value pulls no node:http2/node:crypto edge into the RN/browser graph.
308
- export {
309
- PushFanoutService,
310
- DEFAULT_PUSH_COOLDOWN_MS,
311
- DEFAULT_PUSH_DEBOUNCE_MS,
312
- type PushFanoutOptions,
313
- type FanoutMember
314
- } from './push-fanout.js';
315
-
316
- // Control-cohort dial selection (backbone-preferential, bounded out-degree) +
317
- // the cadence/degree defaults the proactive reconcile routine reads.
318
- export {
319
- selectControlCohortDials,
320
- DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS,
321
- DEFAULT_CONTROL_COHORT_RECONCILE_MS,
322
- DEFAULT_CONTROL_COHORT_TARGET_DEGREE,
323
- type ControlCohortSelection
324
- } from './control-cohort.js';
325
-
326
- // Seed trust policy (trust anchor for incoming seeds)
327
- export {
328
- anchoredTrustPolicy,
329
- pinnedKeyTrustPolicy,
330
- tofuTrustPolicy,
331
- type SeedTrustPolicy,
332
- type SeedTrustContext,
333
- type SeedTrustDecision
334
- } from './seed-trust-policy.js';
335
-
336
- // Schema Verification
337
- export {
338
- signSchema,
339
- verifySchema,
340
- assertSchemaSignature,
341
- SchemaVerificationError
342
- } from './schema-verification.js';
343
-
344
- // Strand Formation transport (native cadre-core protocol)
345
- export {
346
- FormationListener,
347
- dialFormation,
348
- isValidResponderCreatesResult,
349
- FORMATION_PROTOCOL,
350
- type FormationParty,
351
- type FormationContactMessage,
352
- type FormationResultMessage,
353
- type FormationProvisionResult,
354
- type FormationStrandInfo,
355
- type FormationDbConnectionInfo,
356
- type FormationListenerOptions,
357
- type FormationDialOptions,
358
- type ResponderProvisionOutcome
359
- } from './strand-formation-protocol.js';
360
-
361
- // Strand Formation manager (drives the native transport)
362
- export {
363
- StrandFormationManager,
364
- createStrandFormationManager,
365
- type StrandFormationManagerConfig,
366
- type StrandFormationManagerOptions
367
- } from './strand-formation-manager.js';
368
-
369
- // Control-network inbound connection gate (membership defense-in-depth)
370
- export {
371
- createMembershipConnectionGater,
372
- STRANGER_OPEN_PROTOCOLS,
373
- DEFAULT_ENROLLMENT_WINDOW_MS,
374
- ADMISSION_DECISION_TIMEOUT_MS,
375
- type InboundAdmissionPolicy
376
- } from './membership-connection-gater.js';
377
-
378
- // Relay reservation via the bare `/p2p-circuit` search listener (fail-soft;
379
- // the fail-fast alternative is `network.relayAddrs`, see relay-reservation.ts)
380
- export {
381
- circuitMultiaddrs,
382
- superviseRelayReservation,
383
- DEFAULT_RELAY_RESERVE_TIMEOUT_MS,
384
- DEFAULT_RELAY_RESERVE_POLL_MS,
385
- DEFAULT_RELAY_CHECK_MS,
386
- DEFAULT_RELAY_MIN_BACKOFF_MS,
387
- DEFAULT_RELAY_MAX_BACKOFF_MS,
388
- type RelayReservationStatus,
389
- type RelayReservationState,
390
- type RelayReserveOptions,
391
- type RelayReservationSupervisor,
392
- type RelayReservationSupervisorOptions
393
- } from './relay-reservation.js';
394
-
395
- // Connection-path diagnostics (relayed vs direct classification + summary)
396
- export {
397
- classifyTransport,
398
- classifyConnectionPath,
399
- summarizeConnectionPaths,
400
- emptyConnectionPathSummary,
401
- DEFAULT_SETTLE_WINDOW_MS,
402
- type ConnectionPathKind,
403
- type ConnectionTransport,
404
- type ConnectionPath,
405
- type ConnectionPathSummary,
406
- type ConnectionLike
407
- } from './diagnostics/connection-path.js';
1
+ // Core types
2
+ export * from './types.js';
3
+
4
+ // Canonical JSON serialization (shared signing payload format)
5
+ export { canonicalJson } from './canonical-json.js';
6
+
7
+ // Main CadreNode class
8
+ export { CadreNode } from './cadre-node.js';
9
+
10
+ // Control database
11
+ export { ControlDatabase, MissingHostStrandError, buildAuthorizationMessage, formationVouchMessage, formationConsentMessage, REAPABLE_TABLES, type ReapableTable, type ControlDatabaseConfig, type ControlTable, type RevocableTable, type FormationUsageResult, type MembershipChangeListener, type GuardedDeleteListener, type RevokedRowRef } from './control-database.js';
12
+
13
+ // Bounded retry for transient control-write failures (classifier + loop behind
14
+ // ControlDatabase.lockedWithRetry; exported so the integration package can drive the
15
+ // classifier against real engine errors)
16
+ export {
17
+ CONTROL_WRITE_ATTEMPTS,
18
+ CONTROL_WRITE_RETRY_BUDGET_MS,
19
+ SCHEMA_INIT_ATTEMPTS,
20
+ SCHEMA_INIT_RETRY_POLICY,
21
+ isRetriableControlWriteFailure,
22
+ isRetriableSchemaInitFailure,
23
+ retryControlWrite,
24
+ type ControlWriteRetryOptions
25
+ } from './control-write-retry.js';
26
+
27
+ // Bounded retry for transient control-read failures (classifier + policy behind
28
+ // ControlDatabase.readRows; the loop is shared with the write side via control-retry.ts)
29
+ export {
30
+ CONTROL_READ_ATTEMPTS,
31
+ CONTROL_READ_RETRY_DELAYS_MS,
32
+ CONTROL_READ_RETRY_BUDGET_MS,
33
+ isRetriableControlReadFailure,
34
+ retryControlRead,
35
+ type ControlReadRetryOptions
36
+ } from './control-read-retry.js';
37
+
38
+ // Control-plane authorization field vector (the domain/action tagging every signer shares)
39
+ export { controlAuthorizationFields, type ControlDomain, type ControlAction } from './control-authorization.js';
40
+
41
+ // Ed25519 key bridge (libp2p Ed25519 -> base64url keypair)
42
+ export { ed25519KeyPairFromLibp2p, ed25519PublicKeyFromPrivate, requireEd25519PublicKeyB64, type Ed25519KeyPair } from './ed25519-key.js';
43
+
44
+ // Pluggable key store (backend-agnostic identity/owner key material seam).
45
+ // Dependency-free: the interface, error, default slot id, and in-memory backend
46
+ // are safe in every (RN/browser/Node) entry graph. The Node FileKeyStore is a
47
+ // separate subpath module ('@serfab/cadre-core/key-store-file') so its node:fs
48
+ // import never lands here.
49
+ export {
50
+ InMemoryKeyStore,
51
+ KeyStoreAccessError,
52
+ DEFAULT_IDENTITY_KEY_ID,
53
+ type KeyStore,
54
+ type KeyId
55
+ } from './key-store.js';
56
+
57
+ // The KeyStore-backed identity rule, shared with embedding apps that need the
58
+ // node key BEFORE `CadreNode` exists (RN resolves it to sign its ICE-manifest
59
+ // request), plus the generic "prove you hold this node key" signer built on it.
60
+ export {
61
+ loadOrCreateIdentityKey,
62
+ peerKeySigner,
63
+ type PeerKeySigner
64
+ } from './identity-key.js';
65
+
66
+ // Node-local trusted-owner anchor: the NON-replicated, per-party record of
67
+ // out-of-band-established owner keys (the trust anchor the replicated OwnerKey
68
+ // table cannot be). Cross-platform: interface + in-memory store only — the
69
+ // file-backed store is the Node-only subpath
70
+ // '@serfab/cadre-core/trusted-owner-store-file' (same isolation as
71
+ // key-store-file) so node:fs never lands in this graph.
72
+ export {
73
+ MemoryTrustedOwnerStore,
74
+ PersistentTrustedOwnerStore,
75
+ type TrustedOwnerStore,
76
+ type TrustSource
77
+ } from './trusted-owner-store.js';
78
+
79
+ // The one platform-specific piece of a persistent node-local store: a single
80
+ // durable text slot the embedding app supplies (IndexedDB / SecureStore /
81
+ // SQLite / a file). Everything else — envelope, load policy, snapshot write
82
+ // chain — is cross-platform in node-local-snapshot.ts.
83
+ export type { DurableSlot } from './node-local-snapshot.js';
84
+
85
+ // Node-local cold-start bootstrap-peer store: the dial targets retained from an
86
+ // applied seed so a node that could not connect on its first try keeps retrying
87
+ // across restarts. Same cross-platform split as the trusted-owner anchor above —
88
+ // interface + in-memory store here, Node-only file backend behind the subpath
89
+ // '@serfab/cadre-core/bootstrap-peer-store-file'.
90
+ export {
91
+ MemoryBootstrapPeerStore,
92
+ PersistentBootstrapPeerStore,
93
+ type BootstrapPeerStore,
94
+ type BootstrapPeerEntry
95
+ } from './bootstrap-peer-store.js';
96
+
97
+ // Node-local enrolled-machine count: the machines this party had enrolled the
98
+ // last time this node looked, remembered across restarts so the CONTROL node can
99
+ // declare a block-repair yardstick at bring-up — which is before the database
100
+ // holding the membership rows exists. Same cross-platform split as the two
101
+ // records above; Node-only file backend behind the subpath
102
+ // '@serfab/cadre-core/enrolled-machine-store-file'. Its load policy deliberately
103
+ // DIVERGES from theirs (an unreadable slot cold-starts rather than throwing) —
104
+ // see the module comment before unifying the three.
105
+ export {
106
+ MemoryEnrolledMachineStore,
107
+ PersistentEnrolledMachineStore,
108
+ type EnrolledMachineStore
109
+ } from './enrolled-machine-store.js';
110
+
111
+ // Strand database
112
+ export { StrandDatabase, type StrandDatabaseConfig } from './strand-database.js';
113
+
114
+ // Strand management
115
+ export {
116
+ StrandWatcher,
117
+ type StrandWatcherCallbacks,
118
+ type StrandQueryable,
119
+ type SAppIdLookup,
120
+ type StrandRowWithApp
121
+ } from './strand-watcher.js';
122
+ export {
123
+ StrandInstanceManager,
124
+ type StartStrandConfig,
125
+ type ResumeStrandOverrides,
126
+ getStrandStoragePath
127
+ } from './strand-instance-manager.js';
128
+
129
+ // Peer-join block catch-up (push this network's own blocks to each newly
130
+ // connected peer, so a late joiner physically holds pre-join blocks). Shared
131
+ // by the strand networks (ungated) and the control network (membership-gated).
132
+ export {
133
+ PeerJoinBackfill,
134
+ DEFAULT_PEER_JOIN_BACKFILL,
135
+ MAX_BLOCK_MESSAGE_BYTES,
136
+ type PeerJoinBackfillConfig,
137
+ type PeerJoinBackfillDeps,
138
+ type PeerJoinBackfillResult,
139
+ type PeerJoinBackfillPushClient
140
+ } from './peer-join-backfill.js';
141
+
142
+ // Closed-strand revoked-peer enforcement (deny the network nodes of removed
143
+ // members at the stream and connection layers, and hang up the sessions they
144
+ // already hold — see the module doc for the settled deny-list design, the
145
+ // teardown seam, and the fail directions).
146
+ export {
147
+ StrandRevocationEnforcer,
148
+ createRevocationConnectionGater,
149
+ readStrandRevocationRows,
150
+ DEFAULT_REVOCATION_POLL_INTERVAL_MS,
151
+ type StrandRevocationEnforcementConfig,
152
+ type StrandRevocationEnforcerDeps,
153
+ type StrandRevocationRows,
154
+ type StrandMemberPeerBinding,
155
+ type StrandRevocationJudge,
156
+ type StrandRevocationNetwork,
157
+ type RevocationRefreshScheduler
158
+ } from './strand-revocation-enforcer.js';
159
+
160
+ // Hibernation
161
+ export {
162
+ HibernationManager,
163
+ type HibernationCallbacks
164
+ } from './hibernation-manager.js';
165
+
166
+ // Arachnode (stub)
167
+ export {
168
+ ArachnodeStub,
169
+ createArachnodeStub,
170
+ type RingConfig
171
+ } from './arachnode-stub.js';
172
+
173
+ // Enrollment
174
+ export {
175
+ EnrollmentService,
176
+ type MemberVerifier,
177
+ type MemberRegistry
178
+ } from './enrollment.js';
179
+
180
+ // Strand Solicitation
181
+ export {
182
+ StrandSolicitationService,
183
+ createDefaultFormationResponseValidator,
184
+ type DisclosureValidator,
185
+ type FormationUsageRecorder,
186
+ type ResolvedHostStrand,
187
+ type StrandProvisioner,
188
+ type FormationResponseValidator,
189
+ type StrandSolicitationServiceOptions
190
+ } from './strand-solicitation.js';
191
+
192
+ // Formation approval client: asks an invite's ValidationUrl hook whether ONE redemption
193
+ // may proceed, and checks the answer against the bytes the control database will verify.
194
+ export {
195
+ createHttpFormationApprover,
196
+ signFormationApproval,
197
+ verifyFormationApproval,
198
+ FormationApprovalError,
199
+ type FormationApprovalRequest,
200
+ type FormationVouchFields,
201
+ type FormationApproval,
202
+ type FormationApprover,
203
+ type FormationApprovalFailure
204
+ } from './formation-approval.js';
205
+
206
+ // DB-backed FormationUsageRecorder (reads/writes the real CadreControl tables)
207
+ export { ControlFormationUsageRecorder } from './control-formation-recorder.js';
208
+
209
+ // Closed-strand member key generation (ed25519 protobuf, base64) + the
210
+ // protobuf->base64url bridge that derives the founding Member/Manager key.
211
+ export { generateStrandMemberKey, strandMemberKeyPair } from './strand-member-key.js';
212
+
213
+ // Strand membership writer (founder bootstrap, invite issuance/consumption,
214
+ // manager-admit, member-peer registration, manager rotation, sealing — the sole
215
+ // manager permanently freezing admission — + shared signing primitives reused
216
+ // across the flows).
217
+ export {
218
+ signStrandPayload,
219
+ verifyStrandPayload,
220
+ signStrandApproval,
221
+ generateStrandStampId,
222
+ bootstrapFounderMembership,
223
+ issueInvite,
224
+ consumeInvite,
225
+ cancelInvite,
226
+ listOutstandingInvites,
227
+ addMemberByManager,
228
+ revokeMember,
229
+ leaveStrand,
230
+ registerMemberPeer,
231
+ listMemberPeers,
232
+ removeMemberPeer,
233
+ addManager,
234
+ admitManager,
235
+ removeManager,
236
+ sealStrand,
237
+ isStrandSealed,
238
+ STRAND_ENGINE,
239
+ STRAND_ENGINE_VERSION,
240
+ type FounderBootstrapParams,
241
+ type IssueInviteParams,
242
+ type IssuedInvite,
243
+ type ConsumeInviteParams,
244
+ type CancelInviteParams,
245
+ type OutstandingInvite,
246
+ type AddMemberByManagerParams,
247
+ type RevokeMemberParams,
248
+ type LeaveStrandParams,
249
+ type RegisterMemberPeerParams,
250
+ type RemoveOwnPeerParams,
251
+ type RemoveMemberPeerByManagerParams,
252
+ type RemoveMemberPeerParams,
253
+ type AddManagerParams,
254
+ type AdmitManagerParams,
255
+ type RemoveManagerParams,
256
+ type SealStrandParams
257
+ } from './strand-membership-writer.js';
258
+
259
+ // Engine-canonical datetime helper (shared by control + strand signed-write flows
260
+ // so a signed timestamp byte-matches the datetime-coerced column the CHECK sees).
261
+ export { canonicalDatetime } from './canonical-datetime.js';
262
+
263
+ // Strand-DB-backed EnrollmentService backing: concrete MemberRegistry +
264
+ // MemberVerifier that write/read the real Strand.* membership tables.
265
+ export {
266
+ StrandMemberRegistry,
267
+ StrandMemberVerifier,
268
+ memberRegistrationPayload,
269
+ type StrandAdmission
270
+ } from './strand-member-registry.js';
271
+
272
+ // Seed Bootstrap
273
+ export {
274
+ SeedBootstrapService,
275
+ SEED_PROTOCOL,
276
+ ed25519PublicKeyB64FromPeerId,
277
+ type SeedBootstrapConfig,
278
+ type SeedEventCallbacks
279
+ } from './seed-bootstrap.js';
280
+
281
+ // Peer Authorization (shared owner-signature digest + offline verifier)
282
+ export {
283
+ peerAuthorizationDigest,
284
+ cadrePeerVoucherDigest,
285
+ cadrePeerRemoveDigest,
286
+ deviceTokenAddDigest,
287
+ deviceTokenRemoveDigest,
288
+ formationConsentDigest,
289
+ verifyPeerAuthorization,
290
+ verifyCadrePeerVoucher,
291
+ verifyFormationConsent,
292
+ type DeviceTokenAuthorizedRow
293
+ } from './peer-authorization.js';
294
+
295
+ // Strand Wake (control-network push-wake protocol)
296
+ export {
297
+ StrandWakeService,
298
+ dialWake,
299
+ WAKE_PROTOCOL,
300
+ DEFAULT_WAKE_DIAL_BUDGET_MS,
301
+ type StrandWakeServiceOptions,
302
+ type DialWakeOptions
303
+ } from './strand-wake-protocol.js';
304
+
305
+ // Strand Address (control-network strand-address RPC) — wire types come via
306
+ // `export * from './types.js'` (StrandAddrRequest / StrandAddrResponse).
307
+ export {
308
+ StrandAddrService,
309
+ collectStrandAddrs,
310
+ STRAND_ADDR_PROTOCOL,
311
+ type StrandAddrServiceOptions,
312
+ type StrandAddrPeer,
313
+ type CollectStrandAddrsOptions
314
+ } from './strand-addr-protocol.js';
315
+
316
+ // Peer-address record (self-published, signed, freshness-stamped CadrePeer row)
317
+ export {
318
+ peerRecordSignedPayload,
319
+ signPeerRecord,
320
+ verifyPeerRecordSignature,
321
+ isPeerRecordFresh,
322
+ isSignalingAddr,
323
+ orderSignalingFirst,
324
+ withTrailingPeerId,
325
+ currentMemberTrustPolicy,
326
+ DEFAULT_PEER_RECORD_MAX_AGE_MS,
327
+ DEFAULT_PEER_RECORD_HEARTBEAT_MS
328
+ } from './peer-record.js';
329
+
330
+ // Device-token record (self-published, signed FCM/APNs push token — CadrePeer sibling)
331
+ export {
332
+ deviceTokenSignedPayload,
333
+ signDeviceTokenRecord,
334
+ verifyDeviceTokenSignature,
335
+ isPushPlatform
336
+ } from './device-token.js';
337
+
338
+ // Strand-wake payload contract (canonical; shared by the server sender + RN receiver)
339
+ export { STRAND_WAKE_TYPE, type StrandWakePayload } from './strand-wake-payload.js';
340
+
341
+ // Platform push delivery — the cross-platform `PushNotifier` *contract* only.
342
+ // The FCM/APNs implementations (node:http2/node:crypto) and the
343
+ // `createPushNotifier` router that builds them live behind the Node-only subpath
344
+ // `@serfab/cadre-core/push-node` (`push-node.ts`), never in this graph. A Node
345
+ // host constructs a notifier from that subpath and injects the instance into
346
+ // `CadreNodeConfig.push.notifier`. These re-exports are type-only (erased at
347
+ // emit), so the RN/browser entry graph never pulls the Node modules in.
348
+ export type { PushNotifier, PushMessage, PushSendResult } from './push-notifier.js';
349
+
350
+ // Push-credential validation + log redaction. Dependency-free (type-only imports),
351
+ // so a provisioner (cadre-host / cadre-provider) can reject a partial credential
352
+ // set and produce a key-safe log view without pulling the FCM/APNs sender graph.
353
+ export { validatePushCredentials, redactPushCredentials, REDACTED } from './push-credentials.js';
354
+
355
+ // Server-side push-wake trigger policy + fan-out (who/when to wake). Cross-platform
356
+ // clean — it imports only the PushNotifier *type*, so exporting it as a runtime
357
+ // value pulls no node:http2/node:crypto edge into the RN/browser graph.
358
+ export {
359
+ PushFanoutService,
360
+ DEFAULT_PUSH_COOLDOWN_MS,
361
+ DEFAULT_PUSH_DEBOUNCE_MS,
362
+ type PushFanoutOptions,
363
+ type FanoutMember
364
+ } from './push-fanout.js';
365
+
366
+ // Control-cohort dial selection (backbone-preferential, bounded out-degree) +
367
+ // the cadence/degree defaults the proactive reconcile routine reads.
368
+ export {
369
+ selectControlCohortDials,
370
+ DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS,
371
+ DEFAULT_CONTROL_COHORT_RECONCILE_MS,
372
+ DEFAULT_CONTROL_COHORT_TARGET_DEGREE,
373
+ type ControlCohortSelection
374
+ } from './control-cohort.js';
375
+
376
+ // Seed trust policy (trust anchor for incoming seeds)
377
+ export {
378
+ anchoredTrustPolicy,
379
+ pinnedKeyTrustPolicy,
380
+ tofuTrustPolicy,
381
+ type SeedTrustPolicy,
382
+ type SeedTrustContext,
383
+ type SeedTrustDecision
384
+ } from './seed-trust-policy.js';
385
+
386
+ // Schema Verification
387
+ export {
388
+ signSchema,
389
+ verifySchema,
390
+ assertSchemaSignature,
391
+ SchemaVerificationError
392
+ } from './schema-verification.js';
393
+
394
+ // Strand Formation transport (native cadre-core protocol)
395
+ export {
396
+ FormationListener,
397
+ dialFormation,
398
+ isValidResponderCreatesResult,
399
+ sanitizeStrandAddrs,
400
+ FORMATION_PROTOCOL,
401
+ type FormationParty,
402
+ type FormationContactMessage,
403
+ type FormationResultMessage,
404
+ type FormationProvisionResult,
405
+ type FormationStrandInfo,
406
+ type FormationDbConnectionInfo,
407
+ type FormationListenerOptions,
408
+ type FormationDialOptions,
409
+ type FormationDialResult,
410
+ type ResponderProvisionOutcome
411
+ } from './strand-formation-protocol.js';
412
+
413
+ // Strand Formation manager (drives the native transport)
414
+ export {
415
+ StrandFormationManager,
416
+ createStrandFormationManager,
417
+ type StrandFormationManagerConfig,
418
+ type StrandFormationManagerOptions
419
+ } from './strand-formation-manager.js';
420
+
421
+ // Control-network inbound connection gate (membership defense-in-depth)
422
+ export {
423
+ createMembershipConnectionGater,
424
+ STRANGER_OPEN_PROTOCOLS,
425
+ DEFAULT_ENROLLMENT_WINDOW_MS,
426
+ ADMISSION_DECISION_TIMEOUT_MS,
427
+ RELAY_ADMISSION_RESERVE_DEADLINE_MS,
428
+ MAX_UNAUTHORIZED_RELAY_RESERVATIONS,
429
+ UNAUTHORIZED_RESERVATION_TTL_MS,
430
+ UnauthorizedReservationBudget,
431
+ type InboundAdmissionPolicy,
432
+ type InboundConnectionVerdict
433
+ } from './membership-connection-gater.js';
434
+
435
+ // Thrown out of `CadreNode.start()` when a `network.relayAddrs` reservation does
436
+ // not land on its first attempt — the fail-fast posture of that config field now
437
+ // that the control node reserves AFTER control-database bring-up (relay-addrs.ts).
438
+ // `UnbindableListenAddressError` is the same posture for the OTHER half of the listen
439
+ // config: a `network.listenAddrs` entry whose transport the node will not have refuses
440
+ // start instead of being silently dropped by libp2p's transport manager.
441
+ export {
442
+ RelayReservationFailedError,
443
+ UnbindableListenAddressError,
444
+ RELAY_SEARCH_LISTEN_ADDR
445
+ } from './relay-addrs.js';
446
+
447
+ // Relay reservation via the bare `/p2p-circuit` search listener — the one route
448
+ // every control node takes; `network.relayAddrs` is its fail-fast posture
449
+ // (see relay-reservation.ts)
450
+ export {
451
+ circuitMultiaddrs,
452
+ superviseRelayReservation,
453
+ DEFAULT_RELAY_RESERVE_TIMEOUT_MS,
454
+ DEFAULT_RELAY_RESERVE_POLL_MS,
455
+ DEFAULT_RELAY_CHECK_MS,
456
+ DEFAULT_RELAY_MIN_BACKOFF_MS,
457
+ DEFAULT_RELAY_MAX_BACKOFF_MS,
458
+ type RelayReservationStatus,
459
+ type RelayReservationState,
460
+ type RelayReserveOptions,
461
+ type RelayReservationSupervisor,
462
+ type RelayReservationSupervisorOptions
463
+ } from './relay-reservation.js';
464
+
465
+ // Connection-path diagnostics (relayed vs direct classification + summary)
466
+ export {
467
+ classifyTransport,
468
+ classifyConnectionPath,
469
+ summarizeConnectionPaths,
470
+ emptyConnectionPathSummary,
471
+ DEFAULT_SETTLE_WINDOW_MS,
472
+ type ConnectionPathKind,
473
+ type ConnectionTransport,
474
+ type ConnectionPath,
475
+ type ConnectionPathSummary,
476
+ type ConnectionLike
477
+ } from './diagnostics/connection-path.js';