@serfab/cadre-core 0.10.0 → 0.12.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 (145) hide show
  1. package/README.md +255 -255
  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 +484 -58
  6. package/dist/cadre-node.js +953 -182
  7. package/dist/cadre-node.js.map +1 -1
  8. package/dist/control-cohort.d.ts +26 -0
  9. package/dist/control-cohort.js +26 -0
  10. package/dist/control-cohort.js.map +1 -1
  11. package/dist/control-database.d.ts +222 -125
  12. package/dist/control-database.js +356 -266
  13. package/dist/control-database.js.map +1 -1
  14. package/dist/control-formation-recorder.d.ts +8 -7
  15. package/dist/control-formation-recorder.js +8 -7
  16. package/dist/control-formation-recorder.js.map +1 -1
  17. package/dist/control-read-retry.d.ts +103 -0
  18. package/dist/control-read-retry.js +145 -0
  19. package/dist/control-read-retry.js.map +1 -0
  20. package/dist/control-retry.d.ts +101 -0
  21. package/dist/control-retry.js +108 -0
  22. package/dist/control-retry.js.map +1 -0
  23. package/dist/control-schema.d.ts +1 -1
  24. package/dist/control-schema.js +805 -774
  25. package/dist/control-schema.js.map +1 -1
  26. package/dist/control-write-retry.d.ts +65 -31
  27. package/dist/control-write-retry.js +33 -103
  28. package/dist/control-write-retry.js.map +1 -1
  29. package/dist/delegate-admission.d.ts +17 -15
  30. package/dist/delegate-admission.js +17 -15
  31. package/dist/delegate-admission.js.map +1 -1
  32. package/dist/index.d.ts +7 -5
  33. package/dist/index.js +18 -9
  34. package/dist/index.js.map +1 -1
  35. package/dist/membership-connection-gater.d.ts +211 -25
  36. package/dist/membership-connection-gater.js +309 -29
  37. package/dist/membership-connection-gater.js.map +1 -1
  38. package/dist/peer-addr-book.d.ts +92 -0
  39. package/dist/peer-addr-book.js +220 -0
  40. package/dist/peer-addr-book.js.map +1 -0
  41. package/dist/peer-record.d.ts +26 -0
  42. package/dist/peer-record.js +32 -0
  43. package/dist/peer-record.js.map +1 -1
  44. package/dist/relay-addrs.d.ts +76 -26
  45. package/dist/relay-addrs.js +115 -27
  46. package/dist/relay-addrs.js.map +1 -1
  47. package/dist/relay-reservation.d.ts +20 -15
  48. package/dist/relay-reservation.js +18 -14
  49. package/dist/relay-reservation.js.map +1 -1
  50. package/dist/seed-bootstrap.d.ts +7 -0
  51. package/dist/seed-bootstrap.js +15 -13
  52. package/dist/seed-bootstrap.js.map +1 -1
  53. package/dist/strand-addr-protocol.js +16 -0
  54. package/dist/strand-addr-protocol.js.map +1 -1
  55. package/dist/strand-backfill.js +13 -4
  56. package/dist/strand-backfill.js.map +1 -1
  57. package/dist/strand-cohort.d.ts +4 -37
  58. package/dist/strand-cohort.js +4 -15
  59. package/dist/strand-cohort.js.map +1 -1
  60. package/dist/strand-database.d.ts +11 -16
  61. package/dist/strand-database.js +19 -7
  62. package/dist/strand-database.js.map +1 -1
  63. package/dist/strand-formation-manager.d.ts +18 -17
  64. package/dist/strand-formation-manager.js +25 -27
  65. package/dist/strand-formation-manager.js.map +1 -1
  66. package/dist/strand-formation-protocol.d.ts +7 -7
  67. package/dist/strand-formation-protocol.js +8 -8
  68. package/dist/strand-formation-protocol.js.map +1 -1
  69. package/dist/strand-instance-manager.d.ts +53 -21
  70. package/dist/strand-instance-manager.js +128 -37
  71. package/dist/strand-instance-manager.js.map +1 -1
  72. package/dist/strand-membership-writer.d.ts +113 -19
  73. package/dist/strand-membership-writer.js +219 -51
  74. package/dist/strand-membership-writer.js.map +1 -1
  75. package/dist/strand-solicitation.d.ts +3 -3
  76. package/dist/strand-solicitation.js +4 -5
  77. package/dist/strand-solicitation.js.map +1 -1
  78. package/dist/strand-wake-protocol.d.ts +47 -2
  79. package/dist/strand-wake-protocol.js +76 -6
  80. package/dist/strand-wake-protocol.js.map +1 -1
  81. package/dist/types.d.ts +107 -54
  82. package/dist/types.js.map +1 -1
  83. package/package.json +8 -7
  84. package/src/announce-addrs.ts +93 -0
  85. package/src/arachnode-stub.ts +159 -159
  86. package/src/bootstrap-peer-store-file.ts +44 -44
  87. package/src/bootstrap-peer-store.ts +172 -172
  88. package/src/cadre-node.ts +1026 -194
  89. package/src/canonical-json.ts +30 -30
  90. package/src/control-authorization.ts +114 -114
  91. package/src/control-cohort.ts +130 -103
  92. package/src/control-database.ts +376 -298
  93. package/src/control-formation-recorder.ts +305 -304
  94. package/src/control-read-retry.ts +167 -0
  95. package/src/control-retry.ts +190 -0
  96. package/src/control-schema.ts +817 -786
  97. package/src/control-stream.ts +205 -205
  98. package/src/control-write-retry.ts +383 -473
  99. package/src/delegate-admission.ts +304 -302
  100. package/src/device-token.ts +94 -94
  101. package/src/diagnostics/connection-path.ts +277 -277
  102. package/src/diagnostics/webrtc-turn-tracker.ts +222 -222
  103. package/src/ed25519-key.ts +134 -134
  104. package/src/enrollment.ts +199 -199
  105. package/src/file-durable-slot.ts +61 -61
  106. package/src/formation-approval.ts +604 -604
  107. package/src/fs-atomic.ts +107 -107
  108. package/src/hibernation-manager.ts +437 -437
  109. package/src/identity-key.ts +109 -109
  110. package/src/index.ts +435 -406
  111. package/src/key-store-file.ts +132 -132
  112. package/src/key-store.ts +99 -99
  113. package/src/membership-connection-gater.ts +368 -39
  114. package/src/node-local-snapshot.ts +260 -260
  115. package/src/peer-addr-book.ts +250 -0
  116. package/src/peer-authorization.ts +259 -259
  117. package/src/peer-record.ts +197 -164
  118. package/src/push-credentials.ts +84 -84
  119. package/src/push-node.ts +64 -64
  120. package/src/push-notifier-apns.ts +247 -247
  121. package/src/push-notifier-fcm.ts +220 -220
  122. package/src/push-notifier-shared.ts +28 -28
  123. package/src/push-notifier.ts +52 -52
  124. package/src/relay-addrs.ts +134 -27
  125. package/src/relay-reservation.ts +22 -17
  126. package/src/seed-bootstrap.ts +15 -15
  127. package/src/seed-trust-policy.ts +140 -140
  128. package/src/strand-addr-protocol.ts +458 -441
  129. package/src/strand-backfill.ts +28 -5
  130. package/src/strand-cohort.ts +38 -77
  131. package/src/strand-database.ts +202 -204
  132. package/src/strand-formation-manager.ts +26 -28
  133. package/src/strand-formation-protocol.ts +692 -692
  134. package/src/strand-instance-manager.ts +636 -553
  135. package/src/strand-member-key.ts +39 -39
  136. package/src/strand-member-registry.ts +182 -182
  137. package/src/strand-membership-writer.ts +1627 -1430
  138. package/src/strand-solicitation.ts +471 -472
  139. package/src/strand-transport-key.ts +58 -58
  140. package/src/strand-wake-payload.ts +32 -32
  141. package/src/strand-wake-protocol.ts +400 -314
  142. package/src/strand-watcher.ts +314 -314
  143. package/src/trusted-owner-store-file.ts +41 -41
  144. package/src/trusted-owner-store.ts +171 -171
  145. package/src/types.ts +1354 -1303
package/src/index.ts CHANGED
@@ -1,406 +1,435 @@
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_RECONCILE_MS,
321
- DEFAULT_CONTROL_COHORT_TARGET_DEGREE,
322
- type ControlCohortSelection
323
- } from './control-cohort.js';
324
-
325
- // Seed trust policy (trust anchor for incoming seeds)
326
- export {
327
- anchoredTrustPolicy,
328
- pinnedKeyTrustPolicy,
329
- tofuTrustPolicy,
330
- type SeedTrustPolicy,
331
- type SeedTrustContext,
332
- type SeedTrustDecision
333
- } from './seed-trust-policy.js';
334
-
335
- // Schema Verification
336
- export {
337
- signSchema,
338
- verifySchema,
339
- assertSchemaSignature,
340
- SchemaVerificationError
341
- } from './schema-verification.js';
342
-
343
- // Strand Formation transport (native cadre-core protocol)
344
- export {
345
- FormationListener,
346
- dialFormation,
347
- isValidResponderCreatesResult,
348
- FORMATION_PROTOCOL,
349
- type FormationParty,
350
- type FormationContactMessage,
351
- type FormationResultMessage,
352
- type FormationProvisionResult,
353
- type FormationStrandInfo,
354
- type FormationDbConnectionInfo,
355
- type FormationListenerOptions,
356
- type FormationDialOptions,
357
- type ResponderProvisionOutcome
358
- } from './strand-formation-protocol.js';
359
-
360
- // Strand Formation manager (drives the native transport)
361
- export {
362
- StrandFormationManager,
363
- createStrandFormationManager,
364
- type StrandFormationManagerConfig,
365
- type StrandFormationManagerOptions
366
- } from './strand-formation-manager.js';
367
-
368
- // Control-network inbound connection gate (membership defense-in-depth)
369
- export {
370
- createMembershipConnectionGater,
371
- STRANGER_OPEN_PROTOCOLS,
372
- DEFAULT_ENROLLMENT_WINDOW_MS,
373
- ADMISSION_DECISION_TIMEOUT_MS,
374
- type InboundAdmissionPolicy
375
- } from './membership-connection-gater.js';
376
-
377
- // Relay reservation via the bare `/p2p-circuit` search listener (fail-soft;
378
- // the fail-fast alternative is `network.relayAddrs`, see relay-reservation.ts)
379
- export {
380
- circuitMultiaddrs,
381
- superviseRelayReservation,
382
- DEFAULT_RELAY_RESERVE_TIMEOUT_MS,
383
- DEFAULT_RELAY_RESERVE_POLL_MS,
384
- DEFAULT_RELAY_CHECK_MS,
385
- DEFAULT_RELAY_MIN_BACKOFF_MS,
386
- DEFAULT_RELAY_MAX_BACKOFF_MS,
387
- type RelayReservationStatus,
388
- type RelayReservationState,
389
- type RelayReserveOptions,
390
- type RelayReservationSupervisor,
391
- type RelayReservationSupervisorOptions
392
- } from './relay-reservation.js';
393
-
394
- // Connection-path diagnostics (relayed vs direct classification + summary)
395
- export {
396
- classifyTransport,
397
- classifyConnectionPath,
398
- summarizeConnectionPaths,
399
- emptyConnectionPathSummary,
400
- DEFAULT_SETTLE_WINDOW_MS,
401
- type ConnectionPathKind,
402
- type ConnectionTransport,
403
- type ConnectionPath,
404
- type ConnectionPathSummary,
405
- type ConnectionLike
406
- } 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
+ // Strand database
98
+ export { StrandDatabase, type StrandDatabaseConfig } from './strand-database.js';
99
+
100
+ // Strand management
101
+ export {
102
+ StrandWatcher,
103
+ type StrandWatcherCallbacks,
104
+ type StrandQueryable,
105
+ type SAppIdLookup,
106
+ type StrandRowWithApp
107
+ } from './strand-watcher.js';
108
+ export {
109
+ StrandInstanceManager,
110
+ type StartStrandConfig,
111
+ type ResumeStrandOverrides,
112
+ getStrandStoragePath
113
+ } from './strand-instance-manager.js';
114
+
115
+ // Strand peer-join block catch-up (push this strand's own blocks to each newly
116
+ // connected strand peer, so a late joiner physically holds pre-join blocks).
117
+ export {
118
+ StrandBackfill,
119
+ DEFAULT_STRAND_BACKFILL,
120
+ MAX_BLOCK_MESSAGE_BYTES,
121
+ type StrandBackfillConfig,
122
+ type StrandBackfillDeps,
123
+ type StrandBackfillResult,
124
+ type StrandBackfillPushClient
125
+ } from './strand-backfill.js';
126
+
127
+ // Hibernation
128
+ export {
129
+ HibernationManager,
130
+ type HibernationCallbacks
131
+ } from './hibernation-manager.js';
132
+
133
+ // Arachnode (stub)
134
+ export {
135
+ ArachnodeStub,
136
+ createArachnodeStub,
137
+ type RingConfig
138
+ } from './arachnode-stub.js';
139
+
140
+ // Enrollment
141
+ export {
142
+ EnrollmentService,
143
+ type MemberVerifier,
144
+ type MemberRegistry
145
+ } from './enrollment.js';
146
+
147
+ // Strand Solicitation
148
+ export {
149
+ StrandSolicitationService,
150
+ createDefaultFormationResponseValidator,
151
+ type DisclosureValidator,
152
+ type FormationUsageRecorder,
153
+ type ResolvedHostStrand,
154
+ type StrandProvisioner,
155
+ type FormationResponseValidator,
156
+ type StrandSolicitationServiceOptions
157
+ } from './strand-solicitation.js';
158
+
159
+ // Formation approval client: asks an invite's ValidationUrl hook whether ONE redemption
160
+ // may proceed, and checks the answer against the bytes the control database will verify.
161
+ export {
162
+ createHttpFormationApprover,
163
+ signFormationApproval,
164
+ verifyFormationApproval,
165
+ FormationApprovalError,
166
+ type FormationApprovalRequest,
167
+ type FormationVouchFields,
168
+ type FormationApproval,
169
+ type FormationApprover,
170
+ type FormationApprovalFailure
171
+ } from './formation-approval.js';
172
+
173
+ // DB-backed FormationUsageRecorder (reads/writes the real CadreControl tables)
174
+ export { ControlFormationUsageRecorder } from './control-formation-recorder.js';
175
+
176
+ // Closed-strand member key generation (ed25519 protobuf, base64) + the
177
+ // protobuf->base64url bridge that derives the founding Member/Manager key.
178
+ export { generateStrandMemberKey, strandMemberKeyPair } from './strand-member-key.js';
179
+
180
+ // Strand membership writer (founder bootstrap, invite issuance/consumption,
181
+ // manager-admit, member-peer registration, manager rotation, sealing — the sole
182
+ // manager permanently freezing admission — + shared signing primitives reused
183
+ // across the flows).
184
+ export {
185
+ signStrandPayload,
186
+ verifyStrandPayload,
187
+ signStrandApproval,
188
+ generateStrandStampId,
189
+ bootstrapFounderMembership,
190
+ issueInvite,
191
+ consumeInvite,
192
+ cancelInvite,
193
+ listOutstandingInvites,
194
+ addMemberByManager,
195
+ revokeMember,
196
+ leaveStrand,
197
+ registerMemberPeer,
198
+ listMemberPeers,
199
+ removeMemberPeer,
200
+ addManager,
201
+ admitManager,
202
+ removeManager,
203
+ sealStrand,
204
+ isStrandSealed,
205
+ STRAND_ENGINE,
206
+ STRAND_ENGINE_VERSION,
207
+ type FounderBootstrapParams,
208
+ type IssueInviteParams,
209
+ type IssuedInvite,
210
+ type ConsumeInviteParams,
211
+ type CancelInviteParams,
212
+ type OutstandingInvite,
213
+ type AddMemberByManagerParams,
214
+ type RevokeMemberParams,
215
+ type LeaveStrandParams,
216
+ type RegisterMemberPeerParams,
217
+ type RemoveOwnPeerParams,
218
+ type RemoveMemberPeerByManagerParams,
219
+ type RemoveMemberPeerParams,
220
+ type AddManagerParams,
221
+ type AdmitManagerParams,
222
+ type RemoveManagerParams,
223
+ type SealStrandParams
224
+ } from './strand-membership-writer.js';
225
+
226
+ // Engine-canonical datetime helper (shared by control + strand signed-write flows
227
+ // so a signed timestamp byte-matches the datetime-coerced column the CHECK sees).
228
+ export { canonicalDatetime } from './canonical-datetime.js';
229
+
230
+ // Strand-DB-backed EnrollmentService backing: concrete MemberRegistry +
231
+ // MemberVerifier that write/read the real Strand.* membership tables.
232
+ export {
233
+ StrandMemberRegistry,
234
+ StrandMemberVerifier,
235
+ memberRegistrationPayload,
236
+ type StrandAdmission
237
+ } from './strand-member-registry.js';
238
+
239
+ // Seed Bootstrap
240
+ export {
241
+ SeedBootstrapService,
242
+ SEED_PROTOCOL,
243
+ ed25519PublicKeyB64FromPeerId,
244
+ type SeedBootstrapConfig,
245
+ type SeedEventCallbacks
246
+ } from './seed-bootstrap.js';
247
+
248
+ // Peer Authorization (shared owner-signature digest + offline verifier)
249
+ export {
250
+ peerAuthorizationDigest,
251
+ cadrePeerVoucherDigest,
252
+ cadrePeerRemoveDigest,
253
+ deviceTokenAddDigest,
254
+ deviceTokenRemoveDigest,
255
+ formationConsentDigest,
256
+ verifyPeerAuthorization,
257
+ verifyCadrePeerVoucher,
258
+ verifyFormationConsent,
259
+ type DeviceTokenAuthorizedRow
260
+ } from './peer-authorization.js';
261
+
262
+ // Strand Wake (control-network push-wake protocol)
263
+ export {
264
+ StrandWakeService,
265
+ dialWake,
266
+ WAKE_PROTOCOL,
267
+ DEFAULT_WAKE_DIAL_BUDGET_MS,
268
+ type StrandWakeServiceOptions,
269
+ type DialWakeOptions
270
+ } from './strand-wake-protocol.js';
271
+
272
+ // Strand Address (control-network strand-address RPC) — wire types come via
273
+ // `export * from './types.js'` (StrandAddrRequest / StrandAddrResponse).
274
+ export {
275
+ StrandAddrService,
276
+ collectStrandAddrs,
277
+ STRAND_ADDR_PROTOCOL,
278
+ type StrandAddrServiceOptions,
279
+ type StrandAddrPeer,
280
+ type CollectStrandAddrsOptions
281
+ } from './strand-addr-protocol.js';
282
+
283
+ // Peer-address record (self-published, signed, freshness-stamped CadrePeer row)
284
+ export {
285
+ peerRecordSignedPayload,
286
+ signPeerRecord,
287
+ verifyPeerRecordSignature,
288
+ isPeerRecordFresh,
289
+ isSignalingAddr,
290
+ orderSignalingFirst,
291
+ withTrailingPeerId,
292
+ currentMemberTrustPolicy,
293
+ DEFAULT_PEER_RECORD_MAX_AGE_MS,
294
+ DEFAULT_PEER_RECORD_HEARTBEAT_MS
295
+ } from './peer-record.js';
296
+
297
+ // Device-token record (self-published, signed FCM/APNs push token — CadrePeer sibling)
298
+ export {
299
+ deviceTokenSignedPayload,
300
+ signDeviceTokenRecord,
301
+ verifyDeviceTokenSignature,
302
+ isPushPlatform
303
+ } from './device-token.js';
304
+
305
+ // Strand-wake payload contract (canonical; shared by the server sender + RN receiver)
306
+ export { STRAND_WAKE_TYPE, type StrandWakePayload } from './strand-wake-payload.js';
307
+
308
+ // Platform push delivery — the cross-platform `PushNotifier` *contract* only.
309
+ // The FCM/APNs implementations (node:http2/node:crypto) and the
310
+ // `createPushNotifier` router that builds them live behind the Node-only subpath
311
+ // `@serfab/cadre-core/push-node` (`push-node.ts`), never in this graph. A Node
312
+ // host constructs a notifier from that subpath and injects the instance into
313
+ // `CadreNodeConfig.push.notifier`. These re-exports are type-only (erased at
314
+ // emit), so the RN/browser entry graph never pulls the Node modules in.
315
+ export type { PushNotifier, PushMessage, PushSendResult } from './push-notifier.js';
316
+
317
+ // Push-credential validation + log redaction. Dependency-free (type-only imports),
318
+ // so a provisioner (cadre-host / cadre-provider) can reject a partial credential
319
+ // set and produce a key-safe log view without pulling the FCM/APNs sender graph.
320
+ export { validatePushCredentials, redactPushCredentials, REDACTED } from './push-credentials.js';
321
+
322
+ // Server-side push-wake trigger policy + fan-out (who/when to wake). Cross-platform
323
+ // clean — it imports only the PushNotifier *type*, so exporting it as a runtime
324
+ // value pulls no node:http2/node:crypto edge into the RN/browser graph.
325
+ export {
326
+ PushFanoutService,
327
+ DEFAULT_PUSH_COOLDOWN_MS,
328
+ DEFAULT_PUSH_DEBOUNCE_MS,
329
+ type PushFanoutOptions,
330
+ type FanoutMember
331
+ } from './push-fanout.js';
332
+
333
+ // Control-cohort dial selection (backbone-preferential, bounded out-degree) +
334
+ // the cadence/degree defaults the proactive reconcile routine reads.
335
+ export {
336
+ selectControlCohortDials,
337
+ DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS,
338
+ DEFAULT_CONTROL_COHORT_RECONCILE_MS,
339
+ DEFAULT_CONTROL_COHORT_TARGET_DEGREE,
340
+ type ControlCohortSelection
341
+ } from './control-cohort.js';
342
+
343
+ // Seed trust policy (trust anchor for incoming seeds)
344
+ export {
345
+ anchoredTrustPolicy,
346
+ pinnedKeyTrustPolicy,
347
+ tofuTrustPolicy,
348
+ type SeedTrustPolicy,
349
+ type SeedTrustContext,
350
+ type SeedTrustDecision
351
+ } from './seed-trust-policy.js';
352
+
353
+ // Schema Verification
354
+ export {
355
+ signSchema,
356
+ verifySchema,
357
+ assertSchemaSignature,
358
+ SchemaVerificationError
359
+ } from './schema-verification.js';
360
+
361
+ // Strand Formation transport (native cadre-core protocol)
362
+ export {
363
+ FormationListener,
364
+ dialFormation,
365
+ isValidResponderCreatesResult,
366
+ FORMATION_PROTOCOL,
367
+ type FormationParty,
368
+ type FormationContactMessage,
369
+ type FormationResultMessage,
370
+ type FormationProvisionResult,
371
+ type FormationStrandInfo,
372
+ type FormationDbConnectionInfo,
373
+ type FormationListenerOptions,
374
+ type FormationDialOptions,
375
+ type ResponderProvisionOutcome
376
+ } from './strand-formation-protocol.js';
377
+
378
+ // Strand Formation manager (drives the native transport)
379
+ export {
380
+ StrandFormationManager,
381
+ createStrandFormationManager,
382
+ type StrandFormationManagerConfig,
383
+ type StrandFormationManagerOptions
384
+ } from './strand-formation-manager.js';
385
+
386
+ // Control-network inbound connection gate (membership defense-in-depth)
387
+ export {
388
+ createMembershipConnectionGater,
389
+ STRANGER_OPEN_PROTOCOLS,
390
+ DEFAULT_ENROLLMENT_WINDOW_MS,
391
+ ADMISSION_DECISION_TIMEOUT_MS,
392
+ RELAY_ADMISSION_RESERVE_DEADLINE_MS,
393
+ MAX_UNAUTHORIZED_RELAY_RESERVATIONS,
394
+ UNAUTHORIZED_RESERVATION_TTL_MS,
395
+ UnauthorizedReservationBudget,
396
+ type InboundAdmissionPolicy,
397
+ type InboundConnectionVerdict
398
+ } from './membership-connection-gater.js';
399
+
400
+ // Thrown out of `CadreNode.start()` when a `network.relayAddrs` reservation does
401
+ // not land on its first attempt — the fail-fast posture of that config field now
402
+ // that the control node reserves AFTER control-database bring-up (relay-addrs.ts).
403
+ export { RelayReservationFailedError, RELAY_SEARCH_LISTEN_ADDR } from './relay-addrs.js';
404
+
405
+ // Relay reservation via the bare `/p2p-circuit` search listener — the one route
406
+ // every control node takes; `network.relayAddrs` is its fail-fast posture
407
+ // (see relay-reservation.ts)
408
+ export {
409
+ circuitMultiaddrs,
410
+ superviseRelayReservation,
411
+ DEFAULT_RELAY_RESERVE_TIMEOUT_MS,
412
+ DEFAULT_RELAY_RESERVE_POLL_MS,
413
+ DEFAULT_RELAY_CHECK_MS,
414
+ DEFAULT_RELAY_MIN_BACKOFF_MS,
415
+ DEFAULT_RELAY_MAX_BACKOFF_MS,
416
+ type RelayReservationStatus,
417
+ type RelayReservationState,
418
+ type RelayReserveOptions,
419
+ type RelayReservationSupervisor,
420
+ type RelayReservationSupervisorOptions
421
+ } from './relay-reservation.js';
422
+
423
+ // Connection-path diagnostics (relayed vs direct classification + summary)
424
+ export {
425
+ classifyTransport,
426
+ classifyConnectionPath,
427
+ summarizeConnectionPaths,
428
+ emptyConnectionPathSummary,
429
+ DEFAULT_SETTLE_WINDOW_MS,
430
+ type ConnectionPathKind,
431
+ type ConnectionTransport,
432
+ type ConnectionPath,
433
+ type ConnectionPathSummary,
434
+ type ConnectionLike
435
+ } from './diagnostics/connection-path.js';