@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.
- package/README.md +255 -255
- package/dist/announce-addrs.d.ts +49 -0
- package/dist/announce-addrs.js +78 -0
- package/dist/announce-addrs.js.map +1 -0
- package/dist/cadre-node.d.ts +484 -58
- package/dist/cadre-node.js +953 -182
- package/dist/cadre-node.js.map +1 -1
- package/dist/control-cohort.d.ts +26 -0
- package/dist/control-cohort.js +26 -0
- package/dist/control-cohort.js.map +1 -1
- package/dist/control-database.d.ts +222 -125
- package/dist/control-database.js +356 -266
- package/dist/control-database.js.map +1 -1
- package/dist/control-formation-recorder.d.ts +8 -7
- package/dist/control-formation-recorder.js +8 -7
- package/dist/control-formation-recorder.js.map +1 -1
- package/dist/control-read-retry.d.ts +103 -0
- package/dist/control-read-retry.js +145 -0
- package/dist/control-read-retry.js.map +1 -0
- package/dist/control-retry.d.ts +101 -0
- package/dist/control-retry.js +108 -0
- package/dist/control-retry.js.map +1 -0
- package/dist/control-schema.d.ts +1 -1
- package/dist/control-schema.js +805 -774
- package/dist/control-schema.js.map +1 -1
- package/dist/control-write-retry.d.ts +65 -31
- package/dist/control-write-retry.js +33 -103
- package/dist/control-write-retry.js.map +1 -1
- package/dist/delegate-admission.d.ts +17 -15
- package/dist/delegate-admission.js +17 -15
- package/dist/delegate-admission.js.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.js +18 -9
- package/dist/index.js.map +1 -1
- package/dist/membership-connection-gater.d.ts +211 -25
- package/dist/membership-connection-gater.js +309 -29
- package/dist/membership-connection-gater.js.map +1 -1
- package/dist/peer-addr-book.d.ts +92 -0
- package/dist/peer-addr-book.js +220 -0
- package/dist/peer-addr-book.js.map +1 -0
- package/dist/peer-record.d.ts +26 -0
- package/dist/peer-record.js +32 -0
- package/dist/peer-record.js.map +1 -1
- package/dist/relay-addrs.d.ts +76 -26
- package/dist/relay-addrs.js +115 -27
- package/dist/relay-addrs.js.map +1 -1
- package/dist/relay-reservation.d.ts +20 -15
- package/dist/relay-reservation.js +18 -14
- package/dist/relay-reservation.js.map +1 -1
- package/dist/seed-bootstrap.d.ts +7 -0
- package/dist/seed-bootstrap.js +15 -13
- package/dist/seed-bootstrap.js.map +1 -1
- package/dist/strand-addr-protocol.js +16 -0
- package/dist/strand-addr-protocol.js.map +1 -1
- package/dist/strand-backfill.js +13 -4
- package/dist/strand-backfill.js.map +1 -1
- package/dist/strand-cohort.d.ts +4 -37
- package/dist/strand-cohort.js +4 -15
- package/dist/strand-cohort.js.map +1 -1
- package/dist/strand-database.d.ts +11 -16
- package/dist/strand-database.js +19 -7
- package/dist/strand-database.js.map +1 -1
- package/dist/strand-formation-manager.d.ts +18 -17
- package/dist/strand-formation-manager.js +25 -27
- package/dist/strand-formation-manager.js.map +1 -1
- package/dist/strand-formation-protocol.d.ts +7 -7
- package/dist/strand-formation-protocol.js +8 -8
- package/dist/strand-formation-protocol.js.map +1 -1
- package/dist/strand-instance-manager.d.ts +53 -21
- package/dist/strand-instance-manager.js +128 -37
- package/dist/strand-instance-manager.js.map +1 -1
- package/dist/strand-membership-writer.d.ts +113 -19
- package/dist/strand-membership-writer.js +219 -51
- package/dist/strand-membership-writer.js.map +1 -1
- package/dist/strand-solicitation.d.ts +3 -3
- package/dist/strand-solicitation.js +4 -5
- package/dist/strand-solicitation.js.map +1 -1
- package/dist/strand-wake-protocol.d.ts +47 -2
- package/dist/strand-wake-protocol.js +76 -6
- package/dist/strand-wake-protocol.js.map +1 -1
- package/dist/types.d.ts +107 -54
- package/dist/types.js.map +1 -1
- package/package.json +8 -7
- package/src/announce-addrs.ts +93 -0
- package/src/arachnode-stub.ts +159 -159
- package/src/bootstrap-peer-store-file.ts +44 -44
- package/src/bootstrap-peer-store.ts +172 -172
- package/src/cadre-node.ts +1026 -194
- package/src/canonical-json.ts +30 -30
- package/src/control-authorization.ts +114 -114
- package/src/control-cohort.ts +130 -103
- package/src/control-database.ts +376 -298
- package/src/control-formation-recorder.ts +305 -304
- package/src/control-read-retry.ts +167 -0
- package/src/control-retry.ts +190 -0
- package/src/control-schema.ts +817 -786
- package/src/control-stream.ts +205 -205
- package/src/control-write-retry.ts +383 -473
- package/src/delegate-admission.ts +304 -302
- package/src/device-token.ts +94 -94
- package/src/diagnostics/connection-path.ts +277 -277
- package/src/diagnostics/webrtc-turn-tracker.ts +222 -222
- package/src/ed25519-key.ts +134 -134
- package/src/enrollment.ts +199 -199
- package/src/file-durable-slot.ts +61 -61
- package/src/formation-approval.ts +604 -604
- package/src/fs-atomic.ts +107 -107
- package/src/hibernation-manager.ts +437 -437
- package/src/identity-key.ts +109 -109
- package/src/index.ts +435 -406
- package/src/key-store-file.ts +132 -132
- package/src/key-store.ts +99 -99
- package/src/membership-connection-gater.ts +368 -39
- package/src/node-local-snapshot.ts +260 -260
- package/src/peer-addr-book.ts +250 -0
- package/src/peer-authorization.ts +259 -259
- package/src/peer-record.ts +197 -164
- package/src/push-credentials.ts +84 -84
- package/src/push-node.ts +64 -64
- package/src/push-notifier-apns.ts +247 -247
- package/src/push-notifier-fcm.ts +220 -220
- package/src/push-notifier-shared.ts +28 -28
- package/src/push-notifier.ts +52 -52
- package/src/relay-addrs.ts +134 -27
- package/src/relay-reservation.ts +22 -17
- package/src/seed-bootstrap.ts +15 -15
- package/src/seed-trust-policy.ts +140 -140
- package/src/strand-addr-protocol.ts +458 -441
- package/src/strand-backfill.ts +28 -5
- package/src/strand-cohort.ts +38 -77
- package/src/strand-database.ts +202 -204
- package/src/strand-formation-manager.ts +26 -28
- package/src/strand-formation-protocol.ts +692 -692
- package/src/strand-instance-manager.ts +636 -553
- package/src/strand-member-key.ts +39 -39
- package/src/strand-member-registry.ts +182 -182
- package/src/strand-membership-writer.ts +1627 -1430
- package/src/strand-solicitation.ts +471 -472
- package/src/strand-transport-key.ts +58 -58
- package/src/strand-wake-payload.ts +32 -32
- package/src/strand-wake-protocol.ts +400 -314
- package/src/strand-watcher.ts +314 -314
- package/src/trusted-owner-store-file.ts +41 -41
- package/src/trusted-owner-store.ts +171 -171
- package/src/types.ts +1354 -1303
|
@@ -299,14 +299,14 @@ export class StrandFormationManager {
|
|
|
299
299
|
* Defense-in-depth: known provisioning/redeem failures are caught and mapped to a logged
|
|
300
300
|
* protocol rejection rather than a thrown insert + a silently-closed stream. The mapping is
|
|
301
301
|
* per-failure, NOT blanket retry-suggesting: an exhausted invitation
|
|
302
|
-
* ({@link InvitationExhaustedError}, raised by `ControlDatabase`
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
* token'`, because retrying it can never succeed.
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
302
|
+
* ({@link InvitationExhaustedError}, raised by `ControlDatabase` when the count of recorded
|
|
303
|
+
* uses has reached the invite's seat budget — which is how the loser of a same-node race
|
|
304
|
+
* surfaces, the local write queue having serialized the two writes) is reported as
|
|
305
|
+
* `'Invalid token'`, because retrying it can never succeed. Concurrent redemptions never
|
|
306
|
+
* contend for a shared row key — each writes under its own `UsageStampId` — so there is no
|
|
307
|
+
* key collision to surface here at all. The LOG-before-reject keeps this a deliberate
|
|
308
|
+
* internal-error→protocol-rejection conversion (AGENTS.md: don't eat exceptions silently),
|
|
309
|
+
* not control-flow-by-exception.
|
|
310
310
|
*/
|
|
311
311
|
private async provisionAsResponder(
|
|
312
312
|
contact: FormationContactMessage,
|
|
@@ -366,26 +366,23 @@ export class StrandFormationManager {
|
|
|
366
366
|
}
|
|
367
367
|
if (err instanceof InvitationExhaustedError) {
|
|
368
368
|
// Shares `INVALID_TOKEN_REASON` with the up-front `validateToken` rejection so the loser
|
|
369
|
-
// of the race that exposed the spent invite
|
|
370
|
-
//
|
|
369
|
+
// of the race that exposed the spent invite sees exactly what a non-racing latecomer
|
|
370
|
+
// sees. No wire-visible distinction between "invalid" and "exhausted" — the
|
|
371
371
|
// operator signal lives in this log line instead.
|
|
372
372
|
// NOTE: if a joining client ever has to tell "never valid" from "used up" WITHOUT node
|
|
373
373
|
// logs, that is a new protocol reason string, not a local change here.
|
|
374
374
|
log(
|
|
375
|
-
'invitation exhausted for token %s:
|
|
375
|
+
'invitation exhausted for token %s: %d of %d use(s) already recorded',
|
|
376
376
|
err.token,
|
|
377
|
-
err.
|
|
377
|
+
err.usesRecorded,
|
|
378
378
|
err.totalUses
|
|
379
379
|
);
|
|
380
380
|
return { approved: false, reason: INVALID_TOKEN_REASON };
|
|
381
381
|
}
|
|
382
|
-
// An approval
|
|
383
|
-
//
|
|
384
|
-
//
|
|
385
|
-
//
|
|
386
|
-
// `ControlDatabase.withUseNumberRetry`). Reaching this catch-all means either that retry
|
|
387
|
-
// ran out (surfaced above as `InvitationExhaustedError`) or the failure was never
|
|
388
|
-
// retryable to begin with.
|
|
382
|
+
// An approval is never discarded to a lost key race: each redemption writes under its
|
|
383
|
+
// own `UsageStampId`, so no other writer can take its row key. Reaching this catch-all
|
|
384
|
+
// means the failure was never retryable at the database layer to begin with (or the
|
|
385
|
+
// transient-cluster retry inside `ControlDatabase.lockedWithRetry` ran out).
|
|
389
386
|
log('provisionAsResponder failed for token %s: %o', token, err);
|
|
390
387
|
return { approved: false, reason: 'Formation conflict, retry' };
|
|
391
388
|
}
|
|
@@ -397,20 +394,21 @@ export class StrandFormationManager {
|
|
|
397
394
|
* 1. `recorder.provisionAndRecord` present (a real DB recorder) → atomic create-strand +
|
|
398
395
|
* record-consent, so the unbound redemption is single-use just like the bound path.
|
|
399
396
|
* Returns the new strand (+ key, null for an open responder-provisioned strand).
|
|
400
|
-
* 2. else `strandProvisioner` present → the
|
|
401
|
-
* NO inline usage write (those callers record usage explicitly via
|
|
397
|
+
* 2. else `strandProvisioner` present → the mock/transport-test contract: provision a bare
|
|
398
|
+
* strand, NO inline usage write (those callers record usage explicitly via
|
|
402
399
|
* `recordFormationComplete`, or assert transport invariants only). Threads the invite's
|
|
403
400
|
* REAL `sAppId`.
|
|
404
401
|
* 3. else → a structural placeholder (no recorder + no provisioner ⇒ no single-use semantics
|
|
405
402
|
* exist to enforce).
|
|
406
403
|
*
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
* — `cadre-web.ts` /
|
|
412
|
-
*
|
|
413
|
-
*
|
|
404
|
+
* NOTE: accepted tradeoff — the plan chose (a) "record usage on the fallback" over (b)
|
|
405
|
+
* "remove the fallback", so arm 2 (`strandProvisioner`, no recorder) is kept. (a) closes the
|
|
406
|
+
* single-use hole with a targeted atomic create+record and leaves the `StrandProvisioner`
|
|
407
|
+
* mock-transport tests untouched; (b) would delete the provisioner surface and churn ~6 unit
|
|
408
|
+
* + ~6 integration sites for ZERO production benefit (production — `cadre-web.ts` /
|
|
409
|
+
* `cadre-phone.ts` — always publishes strand-BOUND invites and treats the
|
|
410
|
+
* responder-provisions placeholder as failure). Revisit if production starts publishing
|
|
411
|
+
* unbound invites, or the mock-transport tests go away.
|
|
414
412
|
*/
|
|
415
413
|
private async provisionUnbound(
|
|
416
414
|
contact: FormationContactMessage,
|