@serfab/cadre-core 1.13.0 → 1.14.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/dist/cadre-invite-protocol.d.ts +348 -0
- package/dist/cadre-invite-protocol.js +605 -0
- package/dist/cadre-invite-protocol.js.map +1 -0
- package/dist/cadre-node.d.ts +523 -180
- package/dist/cadre-node.js +921 -293
- package/dist/cadre-node.js.map +1 -1
- package/dist/claim-proof.d.ts +45 -0
- package/dist/claim-proof.js +132 -0
- package/dist/claim-proof.js.map +1 -0
- package/dist/control-authorization.d.ts +80 -19
- package/dist/control-authorization.js +55 -13
- package/dist/control-authorization.js.map +1 -1
- package/dist/control-cohort.js +1 -1
- package/dist/control-cohort.js.map +1 -1
- package/dist/control-database.d.ts +514 -97
- package/dist/control-database.js +1033 -195
- package/dist/control-database.js.map +1 -1
- package/dist/control-protocol-guard.d.ts +142 -0
- package/dist/control-protocol-guard.js +293 -0
- package/dist/control-protocol-guard.js.map +1 -0
- package/dist/control-schema.d.ts +1 -1
- package/dist/control-schema.js +801 -1067
- package/dist/control-schema.js.map +1 -1
- package/dist/control-stream.d.ts +4 -0
- package/dist/control-stream.js +22 -7
- package/dist/control-stream.js.map +1 -1
- package/dist/delegate-admission.d.ts +1 -1
- package/dist/delegate-admission.js +1 -1
- package/dist/device-token.d.ts +11 -9
- package/dist/device-token.js +14 -12
- package/dist/device-token.js.map +1 -1
- package/dist/ed25519-key.d.ts +15 -0
- package/dist/ed25519-key.js +28 -1
- package/dist/ed25519-key.js.map +1 -1
- package/dist/index.d.ts +14 -9
- package/dist/index.js +27 -9
- package/dist/index.js.map +1 -1
- package/dist/link-budget.d.ts +16 -29
- package/dist/link-budget.js +16 -31
- package/dist/link-budget.js.map +1 -1
- package/dist/membership-connection-gater.d.ts +190 -151
- package/dist/membership-connection-gater.js +235 -173
- package/dist/membership-connection-gater.js.map +1 -1
- package/dist/node-claim-payload.d.ts +19 -0
- package/dist/node-claim-payload.js +120 -0
- package/dist/node-claim-payload.js.map +1 -0
- package/dist/owner-anchor-sync.d.ts +22 -0
- package/dist/owner-anchor-sync.js +143 -0
- package/dist/owner-anchor-sync.js.map +1 -0
- package/dist/peer-authorization.d.ts +113 -18
- package/dist/peer-authorization.js +225 -29
- package/dist/peer-authorization.js.map +1 -1
- package/dist/peer-dial.d.ts +19 -0
- package/dist/peer-dial.js +22 -1
- package/dist/peer-dial.js.map +1 -1
- package/dist/peer-join-backfill.d.ts +26 -2
- package/dist/peer-join-backfill.js +54 -12
- package/dist/peer-join-backfill.js.map +1 -1
- package/dist/peer-record.d.ts +13 -9
- package/dist/peer-record.js +16 -12
- package/dist/peer-record.js.map +1 -1
- package/dist/pending-join-runner.d.ts +66 -58
- package/dist/pending-join-runner.js +136 -145
- package/dist/pending-join-runner.js.map +1 -1
- package/dist/push-fanout.d.ts +8 -2
- package/dist/push-fanout.js +8 -2
- package/dist/push-fanout.js.map +1 -1
- package/dist/seed-bootstrap.d.ts +147 -122
- package/dist/seed-bootstrap.js +284 -269
- package/dist/seed-bootstrap.js.map +1 -1
- package/dist/seed-trust-policy.d.ts +98 -37
- package/dist/seed-trust-policy.js +188 -2
- package/dist/seed-trust-policy.js.map +1 -1
- package/dist/strand-addr-protocol.d.ts +24 -26
- package/dist/strand-addr-protocol.js +19 -26
- package/dist/strand-addr-protocol.js.map +1 -1
- package/dist/strand-formation-protocol.js +1 -1
- package/dist/strand-formation-protocol.js.map +1 -1
- package/dist/strand-revocation-enforcer.d.ts +11 -11
- package/dist/strand-revocation-enforcer.js +11 -11
- package/dist/strand-wake-protocol.d.ts +13 -16
- package/dist/strand-wake-protocol.js +13 -20
- package/dist/strand-wake-protocol.js.map +1 -1
- package/dist/trusted-owner-store.d.ts +35 -5
- package/dist/trusted-owner-store.js +50 -8
- package/dist/trusted-owner-store.js.map +1 -1
- package/dist/types.d.ts +302 -87
- package/dist/types.js.map +1 -1
- package/package.json +8 -7
- package/src/cadre-invite-protocol.ts +864 -0
- package/src/cadre-node.ts +9381 -8686
- package/src/claim-proof.ts +147 -0
- package/src/control-authorization.ts +203 -117
- package/src/control-cohort.ts +1 -1
- package/src/control-database.ts +1216 -218
- package/src/control-protocol-guard.ts +348 -0
- package/src/control-schema.ts +812 -1078
- package/src/control-stream.ts +26 -7
- package/src/delegate-admission.ts +1 -1
- package/src/device-token.ts +14 -10
- package/src/ed25519-key.ts +28 -1
- package/src/index.ts +84 -10
- package/src/link-budget.ts +16 -32
- package/src/membership-connection-gater.ts +637 -570
- package/src/node-claim-payload.ts +125 -0
- package/src/owner-anchor-sync.ts +171 -0
- package/src/peer-authorization.ts +258 -29
- package/src/peer-dial.ts +22 -1
- package/src/peer-join-backfill.ts +56 -11
- package/src/peer-record.ts +16 -11
- package/src/pending-join-runner.ts +729 -735
- package/src/push-fanout.ts +8 -2
- package/src/seed-bootstrap.ts +344 -321
- package/src/seed-trust-policy.ts +353 -140
- package/src/strand-addr-protocol.ts +26 -35
- package/src/strand-formation-protocol.ts +1 -1
- package/src/strand-revocation-enforcer.ts +11 -11
- package/src/strand-wake-protocol.ts +13 -23
- package/src/trusted-owner-store.ts +242 -171
- package/src/types.ts +2471 -2242
|
@@ -1,121 +1,159 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Control-network inbound admission gates
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
2
|
+
* Control-network inbound admission gates: the encrypted-connection checkpoint
|
|
3
|
+
* and the circuit-relay reservation checkpoint.
|
|
4
|
+
*
|
|
5
|
+
* The fail-closed layer of the membership enforcement chain is per-stream: the
|
|
6
|
+
* control node's protocol guard (`control-protocol-guard.ts`) refuses a peer that
|
|
7
|
+
* is not an authorized member on every protocol not declared open to strangers,
|
|
8
|
+
* before its handler runs, and the replicated rows an outsider *can* still write
|
|
9
|
+
* are disbelieved at read time. This module is NOT a stranger boundary on an
|
|
10
|
+
* enrolled node — outside the bring-up quiet period it admits every inbound
|
|
11
|
+
* connection. Its jobs are:
|
|
12
|
+
*
|
|
13
|
+
* - the bring-up quiet period (below), the one state in which it denies;
|
|
14
|
+
* - deciding which admitted peers carry a deadline: a peer the policy cannot
|
|
15
|
+
* place is admitted PROVISIONALLY, and its connection is closed at the
|
|
16
|
+
* deadline unless the policy admits it by then (see "Provisional admission");
|
|
17
|
+
* - handing circuit-relay reservations to the reservation policy (see "The
|
|
18
|
+
* relay-reservation seam").
|
|
19
|
+
*
|
|
20
|
+
* Why a stranger's connection is admitted at all: the gate sees only a peer id,
|
|
21
|
+
* after the encrypted handshake and before any protocol, so it cannot tell an
|
|
22
|
+
* outsider from a device carrying a cadre invitation this node has not received
|
|
23
|
+
* yet, or from a sibling whose membership row is still replicating. Refusing
|
|
24
|
+
* would fail those at the connection; admitting costs a mute connection for a
|
|
25
|
+
* bounded time, because the protocol guard refuses it every members-only protocol.
|
|
26
|
+
*
|
|
27
|
+
* ## Admitted outright
|
|
28
|
+
*
|
|
29
|
+
* A peer the policy CAN place gets no deadline. Besides members, configured
|
|
30
|
+
* infrastructure and an un-enrolled node's whole world (empty anchor or empty
|
|
31
|
+
* authorized set), that covers the stranger windows: states in which this node
|
|
32
|
+
* expects a stranger on one of the `stranger-open` protocols declared in
|
|
33
|
+
* `controlProtocolClasses` (`control-protocol-guard.ts`):
|
|
34
|
+
*
|
|
35
|
+
* - `/sereus/seed/1.0.0` — enrollment seed delivery.
|
|
27
36
|
* An owner dials a brand-new node to seed it (the new node has no members
|
|
28
|
-
* yet, so
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
37
|
+
* yet, so it admits everyone outright). The handler's own trust decision is the
|
|
38
|
+
* anchored seed-trust policy — or, on a node started with a claim secret
|
|
39
|
+
* (`CadreNodeConfig.claim`), the claim-secret policy. Such a node is the one
|
|
40
|
+
* stranger-facing state that is NOT "admit the connection and let the
|
|
41
|
+
* per-stream gates sort it out": while it waits to be claimed
|
|
42
|
+
* (`CadreNode.isAwaitingClaim`) its connection is admitted, because the claim
|
|
43
|
+
* seed has to ride one, but its control-DB streams and relay reservations are
|
|
44
|
+
* refused ahead of every admission below, the empty-anchor one included. An
|
|
45
|
+
* unclaimed node has no siblings to replicate from, and one on a public
|
|
46
|
+
* address must not relay for anyone. The claim anchors the owner, after which
|
|
47
|
+
* the ordinary rules apply.
|
|
48
|
+
* - `/sereus/formation/1.0.0` — cross-party
|
|
32
49
|
* strand formation via open invitations. Stranger-facing BY DESIGN: the
|
|
33
50
|
* initiator is another party, and its token is only checkable inside the
|
|
34
|
-
* protocol. The
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
51
|
+
* protocol. The window is keyed on EXPECTATION of a stranger, not capability
|
|
52
|
+
* to serve one: it is open only while this node has at least one UNEXPIRED,
|
|
53
|
+
* NOT-FULLY-CONSUMED open invitation outstanding
|
|
54
|
+
* (`StrandSolicitationService.hasOutstandingInvitation` — the tokens this
|
|
55
|
+
* process minted or published, plus any still-redeemable `FormationInvite`
|
|
56
|
+
* row the usage recorder can see). Registering the responder does NOT open
|
|
57
|
+
* it, so on every node — each registers one at `CadreNode.start` — a stranger
|
|
58
|
+
* with no invitation in play stays on the provisional deadline. The
|
|
42
59
|
* handler's own trust decision remains the per-token check, which is
|
|
43
60
|
* strictly finer than this one: a peer admitted here can still be rejected
|
|
44
61
|
* in-protocol for a bogus or spent token.
|
|
62
|
+
* - `/sereus/cadre-invite/1.0.0` — redemption
|
|
63
|
+
* of a cadre invitation at any member machine. Stranger-facing BY DESIGN:
|
|
64
|
+
* the device is not a member until the redemption writes its row, and its
|
|
65
|
+
* proof of possession (a signature with the invitation's private key) is
|
|
66
|
+
* only checkable inside the protocol. Keyed on expectation, as formation's
|
|
67
|
+
* is: open only while this node holds at least one LIVE `CadreInvite` row
|
|
68
|
+
* (`ControlDatabase.hasLiveCadreInvite`: not withdrawn, unexpired, uses left,
|
|
69
|
+
* issuer still an owner). A member that has not yet received the device's
|
|
70
|
+
* row by replication admits the device provisionally instead, seats the row
|
|
71
|
+
* from the invitation bundle during the redemption, and so admits it at the
|
|
72
|
+
* deadline's re-check.
|
|
45
73
|
*
|
|
46
74
|
* There is one further connection-level carve-out, which is NOT a protocol
|
|
47
|
-
*
|
|
75
|
+
* window:
|
|
48
76
|
*
|
|
49
77
|
* - **Announced delegate peers** (`delegate-admission.ts`). A member's strand
|
|
50
78
|
* node runs as a separate libp2p identity whose peerId no sibling can
|
|
51
79
|
* recompute. Before starting a strand node, a member's control node
|
|
52
80
|
* announces that peerId over the already-authenticated strand-addr RPC, and
|
|
53
81
|
* the receiver holds a short-lived grant for it
|
|
54
|
-
* (`CadreNode.grantDelegateAdmission`). The grant admits the CONNECTION
|
|
55
|
-
* admits the peer's RESERVATION at the seam below (without
|
|
56
|
-
* unauthorized budget), and nothing else — it is deliberately
|
|
57
|
-
* the
|
|
82
|
+
* (`CadreNode.grantDelegateAdmission`). The grant admits the CONNECTION
|
|
83
|
+
* outright, admits the peer's RESERVATION at the seam below (without
|
|
84
|
+
* spending the unauthorized budget), and nothing else — it is deliberately
|
|
85
|
+
* invisible to the protocol guard, so a delegate still gets refused on every
|
|
58
86
|
* members-only protocol.
|
|
59
87
|
*
|
|
88
|
+
* ## Provisional admission
|
|
89
|
+
*
|
|
90
|
+
* A peer the policy cannot place (`'admit-provisionally'`) gets its connection
|
|
91
|
+
* and a deadline — {@link PROVISIONAL_ADMISSION_DEADLINE_MS} at the default
|
|
92
|
+
* declaration; `CadreNode` passes the one derived from its OWN declared link,
|
|
93
|
+
* because the member is the machine that decides. At the deadline the gate asks
|
|
94
|
+
* the policy again:
|
|
95
|
+
*
|
|
96
|
+
* - `'admit'` — the peer has since become a member, holds a delegate grant, or
|
|
97
|
+
* this node now holds a live invitation (a redeeming device's row was
|
|
98
|
+
* seated): the connection stays, and nothing is re-armed;
|
|
99
|
+
* - `'admit-provisionally'` — the connection is closed (a bounded graceful
|
|
100
|
+
* close, with an abort only as the escalation);
|
|
101
|
+
* - the question throws or outlasts the decision deadline — the connection
|
|
102
|
+
* stays (see "Fail-open, deliberately").
|
|
103
|
+
*
|
|
104
|
+
* A connection that is already gone by then costs no question. One peer may hold
|
|
105
|
+
* several provisional connections; each deadline re-asks on its own.
|
|
106
|
+
*
|
|
107
|
+
* NOTE: the gate does not stop a provisionally admitted stranger from being
|
|
108
|
+
* counted into this node's FRET ring and control-database cohort by opening or
|
|
109
|
+
* advertising the party's protocols — FRET and Optimystic decide that from the
|
|
110
|
+
* protocols libp2p records the peer as serving. Ticket
|
|
111
|
+
* `stranger-joins-the-control-cohort-by-advertising-protocols` (blocked).
|
|
112
|
+
*
|
|
60
113
|
* ## The relay-reservation seam
|
|
61
114
|
*
|
|
62
115
|
* A circuit-relay reservation is established by the reserving peer DIALING the
|
|
63
|
-
* relay, so at the relay it
|
|
116
|
+
* relay, so at the relay it rides an inbound connection — and closing that
|
|
64
117
|
* connection kills the reservation. For a genuine member whose `CadrePeer` row
|
|
65
|
-
* has not yet replicated to this node
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* relay
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* flight always finds a slot under any sane cap, while outsiders cannot
|
|
88
|
-
* annex the party's relay capacity. COUNT and lifetime are the only bounds
|
|
89
|
-
* on such a peer: a party-run relay forwards without libp2p's per-connection
|
|
90
|
-
* data and duration limit by default (`relay-server.ts`), so what a granted
|
|
91
|
-
* slot carries is not capped.
|
|
92
|
-
* - An `'admit-for-relay'` connection that is NOT reserving is dropped: it has
|
|
93
|
-
* {@link RELAY_ADMISSION_RESERVE_DEADLINE_MS} to get a reservation ADMITTED
|
|
94
|
-
* at that hook, after which the gate CLOSES the underlying connection so
|
|
95
|
-
* both ends let go of the socket. The guarantee above thus weakens on
|
|
96
|
-
* relay-enabled nodes from "never in the conversation" to "in it briefly,
|
|
97
|
-
* and can speak nothing".
|
|
118
|
+
* has not yet replicated to this node that would NOT be self-healing the way a
|
|
119
|
+
* data connection's close is: an outbound reconcile dial re-establishes a data
|
|
120
|
+
* link, but no outbound dial can grant the REMOTE peer a reservation, and a
|
|
121
|
+
* relay-only peer has no address of its own to dial back — the reservation IS
|
|
122
|
+
* its address. Boot ordering makes the window ordinary (a node reserves at the
|
|
123
|
+
* end of its own `start()`, before its row could have replicated anywhere), and
|
|
124
|
+
* a stalled replication makes it unbounded. So the reservation is decided on its
|
|
125
|
+
* own terms, not by the connection's:
|
|
126
|
+
*
|
|
127
|
+
* - It is decided at libp2p's `denyInboundRelayReservation` hook (the
|
|
128
|
+
* circuit-relay server consults it per RESERVE request): the policy admits
|
|
129
|
+
* members, delegates and configured infra outright, and admits peers it
|
|
130
|
+
* cannot place only within a bounded budget
|
|
131
|
+
* ({@link UnauthorizedReservationBudget}) — a member whose row is in flight
|
|
132
|
+
* always finds a slot under any sane cap, while outsiders cannot annex the
|
|
133
|
+
* party's relay capacity. COUNT and lifetime are the only bounds on such a
|
|
134
|
+
* peer: a party-run relay forwards without libp2p's per-connection data and
|
|
135
|
+
* duration limit by default (`relay-server.ts`), so what a granted slot
|
|
136
|
+
* carries is not capped.
|
|
137
|
+
* - An ADMITTED reservation disarms every provisional deadline the peer holds
|
|
138
|
+
* here, so its connection outlives the deadline even while the peer is still
|
|
139
|
+
* unplaced. A refused one disarms nothing.
|
|
98
140
|
*
|
|
99
141
|
* The deadline clears on reservation ADMISSION, not on the reservation's own
|
|
100
142
|
* success: this gate cannot observe the server-side `reserve()` outcome, so a
|
|
101
143
|
* peer whose admitted reservation is then refused for server capacity keeps its
|
|
102
144
|
* connection until either side closes it — bounded and mute, so harmless.
|
|
103
145
|
*
|
|
104
|
-
* Everything else a control node
|
|
105
|
-
* (
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
* gate is fail-open over a live DB read (deny only on positive proof of an
|
|
116
|
-
* outsider), the stream gate is fail-closed over the snapshot and has NO
|
|
117
|
-
* stranger carve-outs — an enrollment window admits a stranger's connection
|
|
118
|
-
* for seed delivery, yet its repo streams are still refused.
|
|
146
|
+
* Everything else a control node serves is either libp2p plumbing open to any
|
|
147
|
+
* connection (identify, ping, hole punching, AutoNAT, the relay protocols) or
|
|
148
|
+
* members-only — wake, strand-addr, the Optimystic control-DB protocols and FRET —
|
|
149
|
+
* and the fail-closed layer for all of it is the protocol guard
|
|
150
|
+
* (`control-protocol-guard.ts`), one seam that wraps every handler at dispatch,
|
|
151
|
+
* with a protocol nobody classed treated as members-only. The two layers
|
|
152
|
+
* complement, not duplicate: this connection gate is fail-open over a live DB
|
|
153
|
+
* read and decides only how long a connection lasts, the protocol guard is
|
|
154
|
+
* fail-closed and has NO stranger carve-outs — a live invitation admits a
|
|
155
|
+
* stranger's connection outright for redemption, yet its repo and FRET streams
|
|
156
|
+
* are still refused.
|
|
119
157
|
*
|
|
120
158
|
* ## The bring-up quiet period
|
|
121
159
|
*
|
|
@@ -151,62 +189,54 @@
|
|
|
151
189
|
*
|
|
152
190
|
* ## Fail-open, deliberately
|
|
153
191
|
*
|
|
154
|
-
* Outside that window this layer
|
|
155
|
-
*
|
|
156
|
-
* dependency, or ambiguous state admits the connection
|
|
157
|
-
*
|
|
158
|
-
*
|
|
192
|
+
* Outside that window this layer never denies, and it closes a provisional
|
|
193
|
+
* connection only on a positive answer that the peer is still unplaced. Any
|
|
194
|
+
* error, missing dependency, timeout or ambiguous state admits the connection
|
|
195
|
+
* outright (and the reservation), or keeps a provisional connection at its
|
|
196
|
+
* deadline, and defers to the fail-closed stream gates — a DB hiccup must not
|
|
197
|
+
* partition a legitimate cadre.
|
|
159
198
|
*/
|
|
160
199
|
import debug from 'debug';
|
|
161
|
-
import { SEED_PROTOCOL } from './seed-bootstrap.js';
|
|
162
|
-
import { FORMATION_PROTOCOL } from './strand-formation-protocol.js';
|
|
163
200
|
import { withDeadline } from './control-stream.js';
|
|
164
201
|
import { PARTY_RELAY_RESERVATION_TTL_MS } from './relay-server.js';
|
|
165
|
-
import { ADMISSION_DECISION_TIMEOUT_MS,
|
|
202
|
+
import { ADMISSION_DECISION_TIMEOUT_MS, relayedRequestBudgetMs } from './link-budget.js';
|
|
166
203
|
const log = debug('sereus:cadre:connection-gater');
|
|
167
204
|
/**
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
* does the same from inside its own `listen()`), so a connection idle past this
|
|
189
|
-
* deadline is not reserving.
|
|
190
|
-
*
|
|
191
|
-
* Derived from the link ({@link relayAdmissionReserveDeadlineMs}): one link round trip for the
|
|
192
|
-
* request to arrive plus one admission decision on it. This is the value at the default
|
|
193
|
-
* declaration; `CadreNode` passes the one derived from the relay's OWN declaration, because the
|
|
194
|
-
* relay is the machine that decides.
|
|
205
|
+
* How long a provisionally admitted connection lasts before the gate re-asks the
|
|
206
|
+
* policy and closes it unless the peer is admissible by then (see the module
|
|
207
|
+
* doc's "Provisional admission").
|
|
208
|
+
*
|
|
209
|
+
* {@link relayedRequestBudgetMs}: 28 500 ms at the default declaration. The
|
|
210
|
+
* longest exchange a stranger legitimately starts on a fresh connection is a
|
|
211
|
+
* cadre invitation redemption, and the device abandons each member address after
|
|
212
|
+
* that same budget of its own declared link (`redeemAtMembers`): it covers the
|
|
213
|
+
* dial, the request, the member's catch-up push, the seat and the redemption. So
|
|
214
|
+
* a member never cuts an exchange the device is still waiting on, and a
|
|
215
|
+
* reservation request lands well inside it. This is the value at the default
|
|
216
|
+
* declaration; `CadreNode` passes the one derived from its OWN declaration.
|
|
217
|
+
*
|
|
218
|
+
* NOTE: accepted tradeoff — any stranger can hold a mute connection to any
|
|
219
|
+
* enrolled member for this long, weighed against letting a device redeem an
|
|
220
|
+
* invitation at a member that has not yet received its row (maintainer,
|
|
221
|
+
* 2026-10-07, plan `cadre-invite-redeemable-before-the-row-replicates`). It can
|
|
222
|
+
* open only stranger-open and transport streams (the protocol guard), and
|
|
223
|
+
* libp2p's connection-manager limits bound how many it holds. Revisit if stranger
|
|
224
|
+
* connections show up as load on a member.
|
|
195
225
|
*/
|
|
196
|
-
export const
|
|
226
|
+
export const PROVISIONAL_ADMISSION_DEADLINE_MS = relayedRequestBudgetMs();
|
|
197
227
|
/**
|
|
198
|
-
* Bound on the graceful close of an expired
|
|
228
|
+
* Bound on the graceful close of an expired provisional connection. It exists
|
|
199
229
|
* because `AbstractMultiaddrConnection.close()` awaits an `idle`/`drain` event
|
|
200
230
|
* when the connection still has unsent bytes, and that wait has no timeout of
|
|
201
231
|
* its own — an unsignalled one never ends. This gate writes nothing to a
|
|
202
|
-
* stranger, so the wait is not reachable
|
|
232
|
+
* stranger, so the wait is not reachable from here; the bound is here so a timer
|
|
203
233
|
* callback can never hold an unending await.
|
|
204
234
|
*
|
|
205
235
|
* Applied through {@link withDeadline}, not `AbortSignal.timeout`: the latter is
|
|
206
236
|
* not reliably present on React Native/Hermes, which loads this same module.
|
|
207
237
|
*/
|
|
208
238
|
// eslint-disable-next-line no-restricted-syntax -- link-independent: bounds a local connection close inside a timer callback, and expiry aborts the connection instead
|
|
209
|
-
export const
|
|
239
|
+
export const PROVISIONAL_ADMISSION_CLOSE_TIMEOUT_MS = 2000;
|
|
210
240
|
/**
|
|
211
241
|
* Default cap on concurrent relay reservations held by peers the membership
|
|
212
242
|
* check could not place (see {@link UnauthorizedReservationBudget}). Small on
|
|
@@ -293,27 +323,30 @@ export class UnauthorizedReservationBudget {
|
|
|
293
323
|
* membership — this node decides for itself who to talk to.
|
|
294
324
|
*
|
|
295
325
|
* Composition semantics: every hook of `base` is preserved as-is; on the three
|
|
296
|
-
* composed hooks a deny from
|
|
297
|
-
* denies. A policy error — or a
|
|
298
|
-
* takes the fail-open outcome
|
|
299
|
-
*
|
|
326
|
+
* composed hooks a deny from the base gater denies, and so does the quiet
|
|
327
|
+
* period. The admission policy never denies a connection. A policy error — or a
|
|
328
|
+
* decision slower than `decisionTimeoutMs` — takes the fail-open outcome
|
|
329
|
+
* (connection admitted outright / reservation admitted, see module doc); the
|
|
330
|
+
* base gater's verdict is still honored first.
|
|
300
331
|
*
|
|
301
|
-
* An `'admit-
|
|
302
|
-
* `
|
|
303
|
-
*
|
|
304
|
-
*
|
|
332
|
+
* An `'admit-provisionally'` verdict admits the connection and arms a
|
|
333
|
+
* `provisionalDeadlineMs` timer against it. When the timer fires the policy is
|
|
334
|
+
* asked again, and the underlying `MultiaddrConnection` is closed unless it now
|
|
335
|
+
* answers `'admit'`; a reservation for that peer ADMITTED at the reservation
|
|
336
|
+
* hook disarms the timer first.
|
|
305
337
|
*
|
|
306
338
|
* NOTE: `base` is spread, so a gater passed as a CLASS INSTANCE would lose its
|
|
307
339
|
* prototype methods; every caller in this repo (and libp2p's own default)
|
|
308
340
|
* supplies a plain object. If a class-based gater ever shows up, delegate
|
|
309
341
|
* per-hook instead of spreading.
|
|
310
342
|
*
|
|
311
|
-
* Deny timing, as observed by the denied dialer
|
|
312
|
-
* the security handshake's early data, so
|
|
313
|
-
* (its `dial()` resolves) before this
|
|
314
|
-
* aborts the receiver's upgrade — the
|
|
315
|
-
* and never creates its muxer, so no
|
|
316
|
-
* dialer sees its "open" connection
|
|
343
|
+
* Deny timing, as observed by the denied dialer (a quiet-period or base-gater
|
|
344
|
+
* deny): noise negotiates the muxer in the security handshake's early data, so
|
|
345
|
+
* the DIALER's upgrade may complete (its `dial()` resolves) before this
|
|
346
|
+
* receiver-side hook runs. The deny then aborts the receiver's upgrade — the
|
|
347
|
+
* receiver never registers the connection and never creates its muxer, so no
|
|
348
|
+
* protocol can ever be negotiated — and the dialer sees its "open" connection
|
|
349
|
+
* close moments later.
|
|
317
350
|
*
|
|
318
351
|
* Control node only: strand cohort nodes legitimately connect cross-party
|
|
319
352
|
* peers, so cadre membership never gates them. An OPEN strand's node receives
|
|
@@ -322,8 +355,9 @@ export class UnauthorizedReservationBudget {
|
|
|
322
355
|
* evidence, not this module's membership admission — see
|
|
323
356
|
* `strand-revocation-enforcer.ts`.
|
|
324
357
|
*/
|
|
325
|
-
export function createMembershipConnectionGater(policy, base, decisionTimeoutMs = ADMISSION_DECISION_TIMEOUT_MS,
|
|
326
|
-
const
|
|
358
|
+
export function createMembershipConnectionGater(policy, base, decisionTimeoutMs = ADMISSION_DECISION_TIMEOUT_MS, provisionalDeadlineMs = PROVISIONAL_ADMISSION_DEADLINE_MS) {
|
|
359
|
+
const decideInbound = (remotePeerId) => decideWithinDeadline(() => policy.admitInbound(remotePeerId), 'admit', decisionTimeoutMs, `admitInbound(${remotePeerId})`);
|
|
360
|
+
const provisional = new ProvisionalAdmissions(provisionalDeadlineMs, decideInbound);
|
|
327
361
|
const quiet = () => policy.bringUpInFlight?.() ?? false;
|
|
328
362
|
return {
|
|
329
363
|
...base,
|
|
@@ -348,17 +382,16 @@ export function createMembershipConnectionGater(policy, base, decisionTimeoutMs
|
|
|
348
382
|
const remotePeerId = peerId.toString();
|
|
349
383
|
let verdict;
|
|
350
384
|
try {
|
|
351
|
-
verdict = await
|
|
385
|
+
verdict = await decideInbound(remotePeerId);
|
|
352
386
|
}
|
|
353
387
|
catch (error) {
|
|
354
388
|
log('admitInbound threw for %s — admitting (fail-open; stream gates decide): %o', remotePeerId, error);
|
|
355
389
|
return false;
|
|
356
390
|
}
|
|
357
|
-
if (verdict === 'admit-
|
|
358
|
-
|
|
359
|
-
return false;
|
|
391
|
+
if (verdict === 'admit-provisionally') {
|
|
392
|
+
provisional.arm(remotePeerId, maConn);
|
|
360
393
|
}
|
|
361
|
-
return
|
|
394
|
+
return false;
|
|
362
395
|
},
|
|
363
396
|
denyInboundRelayReservation: async (peerId) => {
|
|
364
397
|
if (await base?.denyInboundRelayReservation?.(peerId)) {
|
|
@@ -374,7 +407,7 @@ export function createMembershipConnectionGater(policy, base, decisionTimeoutMs
|
|
|
374
407
|
admitted = true;
|
|
375
408
|
}
|
|
376
409
|
if (admitted) {
|
|
377
|
-
|
|
410
|
+
provisional.disarm(remotePeerId);
|
|
378
411
|
}
|
|
379
412
|
return !admitted;
|
|
380
413
|
}
|
|
@@ -407,13 +440,12 @@ export async function decideWithinDeadline(decide, fallback, timeoutMs, what) {
|
|
|
407
440
|
}
|
|
408
441
|
}
|
|
409
442
|
/**
|
|
410
|
-
* The
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
* (called when a reservation for that peer is admitted) cancels
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
* a no-op (`close()` returns at once on any status but `open`).
|
|
443
|
+
* The deadlines of `'admit-provisionally'` connections, keyed by remote peerId
|
|
444
|
+
* (a Set per peer — one peer can hold several in-flight connections). `arm`
|
|
445
|
+
* starts a timer that re-asks the policy and closes the connection unless it now
|
|
446
|
+
* admits; `disarm` (called when a reservation for that peer is admitted) cancels
|
|
447
|
+
* every pending deadline for the peer, one whose question is already out
|
|
448
|
+
* included. Timers are unref'd so an armed deadline never holds a process open.
|
|
417
449
|
*
|
|
418
450
|
* Disarming is final for the connections it cancelled: a peer that reserved
|
|
419
451
|
* once and then lets its reservation lapse keeps a mute connection (the
|
|
@@ -421,15 +453,16 @@ export async function decideWithinDeadline(decide, fallback, timeoutMs, what) {
|
|
|
421
453
|
* side closes it. Bounded — only a peer the reservation policy already admitted
|
|
422
454
|
* can reach that state, so unplaceable peers are bounded by the budget cap.
|
|
423
455
|
*/
|
|
424
|
-
class
|
|
425
|
-
constructor(deadlineMs) {
|
|
456
|
+
class ProvisionalAdmissions {
|
|
457
|
+
constructor(deadlineMs, decide) {
|
|
426
458
|
this.deadlineMs = deadlineMs;
|
|
459
|
+
this.decide = decide;
|
|
427
460
|
this.byPeer = new Map();
|
|
428
461
|
}
|
|
429
462
|
arm(remotePeerId, maConn) {
|
|
430
463
|
const entry = {
|
|
431
464
|
maConn,
|
|
432
|
-
timer: setTimeout(() => this.expire(remotePeerId, entry), this.deadlineMs)
|
|
465
|
+
timer: setTimeout(() => void this.expire(remotePeerId, entry), this.deadlineMs)
|
|
433
466
|
};
|
|
434
467
|
entry.timer.unref?.();
|
|
435
468
|
let entries = this.byPeer.get(remotePeerId);
|
|
@@ -438,7 +471,7 @@ class PendingReserveDeadlines {
|
|
|
438
471
|
this.byPeer.set(remotePeerId, entries);
|
|
439
472
|
}
|
|
440
473
|
entries.add(entry);
|
|
441
|
-
log('Admitted %s
|
|
474
|
+
log('Admitted %s provisionally — closing the connection in %dms unless it is admissible by then', remotePeerId, this.deadlineMs);
|
|
442
475
|
}
|
|
443
476
|
disarm(remotePeerId) {
|
|
444
477
|
const entries = this.byPeer.get(remotePeerId);
|
|
@@ -450,17 +483,46 @@ class PendingReserveDeadlines {
|
|
|
450
483
|
clearTimeout(entry.timer);
|
|
451
484
|
}
|
|
452
485
|
}
|
|
453
|
-
expire(remotePeerId, entry) {
|
|
486
|
+
async expire(remotePeerId, entry) {
|
|
487
|
+
if (entry.maConn.status !== 'open') {
|
|
488
|
+
this.release(remotePeerId, entry);
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
const verdict = await this.recheck(remotePeerId);
|
|
492
|
+
// False when a reservation admitted while the question was out disarmed this deadline.
|
|
493
|
+
if (!this.release(remotePeerId, entry)) {
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
if (verdict === 'admit') {
|
|
497
|
+
log('%s is admissible at its provisional deadline — keeping the connection', remotePeerId);
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
log('Provisional admission expired for %s — still unplaced after %dms, closing the connection', remotePeerId, this.deadlineMs);
|
|
501
|
+
await this.drop(remotePeerId, entry.maConn);
|
|
502
|
+
}
|
|
503
|
+
/** The policy's answer at the deadline; a throw keeps the connection (fail-open). */
|
|
504
|
+
async recheck(remotePeerId) {
|
|
505
|
+
try {
|
|
506
|
+
return await this.decide(remotePeerId);
|
|
507
|
+
}
|
|
508
|
+
catch (error) {
|
|
509
|
+
log('admitInbound threw for %s at its provisional deadline — keeping the connection (fail-open): %o', remotePeerId, error);
|
|
510
|
+
return 'admit';
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
/** Forget `entry`; false when a `disarm` already took it. */
|
|
514
|
+
release(remotePeerId, entry) {
|
|
454
515
|
const entries = this.byPeer.get(remotePeerId);
|
|
455
|
-
entries?.delete(entry)
|
|
456
|
-
|
|
516
|
+
if (!entries?.delete(entry)) {
|
|
517
|
+
return false;
|
|
518
|
+
}
|
|
519
|
+
if (entries.size === 0) {
|
|
457
520
|
this.byPeer.delete(remotePeerId);
|
|
458
521
|
}
|
|
459
|
-
|
|
460
|
-
void this.drop(remotePeerId, entry.maConn);
|
|
522
|
+
return true;
|
|
461
523
|
}
|
|
462
524
|
/**
|
|
463
|
-
* End an expired
|
|
525
|
+
* End an expired provisional connection: a bounded graceful close, with
|
|
464
526
|
* `abort()` only as the escalation. The order cannot be reversed — `abort()`
|
|
465
527
|
* marks the connection `aborted`, and `close()` returns immediately on any
|
|
466
528
|
* status that is not `open`, so aborting first would make the close a silent
|
|
@@ -469,11 +531,11 @@ class PendingReserveDeadlines {
|
|
|
469
531
|
*/
|
|
470
532
|
async drop(remotePeerId, maConn) {
|
|
471
533
|
try {
|
|
472
|
-
await withDeadline(
|
|
534
|
+
await withDeadline(PROVISIONAL_ADMISSION_CLOSE_TIMEOUT_MS, `provisional close for ${remotePeerId}`, (signal) => maConn.close({ signal }));
|
|
473
535
|
return;
|
|
474
536
|
}
|
|
475
537
|
catch (error) {
|
|
476
|
-
log('Closing the expired
|
|
538
|
+
log('Closing the expired provisional connection from %s failed — aborting: %o', remotePeerId, error);
|
|
477
539
|
}
|
|
478
540
|
// NOTE: this fallback cannot actually free a WebSocket. `@libp2p/websockets`'
|
|
479
541
|
// `sendReset()` calls `websocket.close(1006)`, and 1006 is a reserved code
|
|
@@ -485,10 +547,10 @@ class PendingReserveDeadlines {
|
|
|
485
547
|
// far as this layer can go. Revisit — drop the fallback, or go back to a
|
|
486
548
|
// plain `abort()` — once that transport sends a legal reset code.
|
|
487
549
|
try {
|
|
488
|
-
maConn.abort(new Error(`
|
|
550
|
+
maConn.abort(new Error(`provisional admission expired: still unplaced after ${this.deadlineMs}ms`));
|
|
489
551
|
}
|
|
490
552
|
catch (error) {
|
|
491
|
-
log('Aborting the expired
|
|
553
|
+
log('Aborting the expired provisional connection from %s threw: %o', remotePeerId, error);
|
|
492
554
|
}
|
|
493
555
|
}
|
|
494
556
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"membership-connection-gater.js","sourceRoot":"","sources":["../src/membership-connection-gater.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"membership-connection-gater.js","sourceRoot":"","sources":["../src/membership-connection-gater.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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