@serfab/cadre-core 0.9.0 → 0.10.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 +4 -2
- package/dist/bootstrap-peer-store-file.d.ts +13 -0
- package/dist/bootstrap-peer-store-file.js +42 -0
- package/dist/bootstrap-peer-store-file.js.map +1 -0
- package/dist/bootstrap-peer-store.d.ts +73 -0
- package/dist/bootstrap-peer-store.js +128 -0
- package/dist/bootstrap-peer-store.js.map +1 -0
- package/dist/cadre-node.d.ts +918 -53
- package/dist/cadre-node.js +1843 -190
- package/dist/cadre-node.js.map +1 -1
- package/dist/control-authorization.d.ts +93 -0
- package/dist/control-authorization.js +57 -0
- package/dist/control-authorization.js.map +1 -0
- package/dist/control-database.d.ts +990 -50
- package/dist/control-database.js +1459 -108
- package/dist/control-database.js.map +1 -1
- package/dist/control-formation-recorder.d.ts +89 -10
- package/dist/control-formation-recorder.js +129 -14
- package/dist/control-formation-recorder.js.map +1 -1
- package/dist/control-schema.d.ts +1 -1
- package/dist/control-schema.js +774 -210
- package/dist/control-schema.js.map +1 -1
- package/dist/control-stream.d.ts +38 -4
- package/dist/control-stream.js +70 -4
- package/dist/control-stream.js.map +1 -1
- package/dist/control-write-retry.d.ts +151 -0
- package/dist/control-write-retry.js +411 -0
- package/dist/control-write-retry.js.map +1 -0
- package/dist/delegate-admission.d.ts +134 -0
- package/dist/delegate-admission.js +244 -0
- package/dist/delegate-admission.js.map +1 -0
- package/dist/device-token.d.ts +11 -11
- package/dist/device-token.js +14 -13
- package/dist/device-token.js.map +1 -1
- package/dist/ed25519-key.d.ts +26 -0
- package/dist/ed25519-key.js +56 -1
- package/dist/ed25519-key.js.map +1 -1
- package/dist/file-durable-slot.d.ts +20 -0
- package/dist/file-durable-slot.js +53 -0
- package/dist/file-durable-slot.js.map +1 -0
- package/dist/formation-approval.d.ts +157 -0
- package/dist/formation-approval.js +375 -0
- package/dist/formation-approval.js.map +1 -0
- package/dist/fs-atomic.d.ts +38 -0
- package/dist/fs-atomic.js +97 -0
- package/dist/fs-atomic.js.map +1 -0
- package/dist/identity-key.d.ts +49 -0
- package/dist/identity-key.js +81 -0
- package/dist/identity-key.js.map +1 -0
- package/dist/index.d.ts +16 -6
- package/dist/index.js +39 -5
- package/dist/index.js.map +1 -1
- package/dist/key-store-file.d.ts +2 -24
- package/dist/key-store-file.js +10 -77
- package/dist/key-store-file.js.map +1 -1
- package/dist/membership-connection-gater.d.ts +146 -0
- package/dist/membership-connection-gater.js +180 -0
- package/dist/membership-connection-gater.js.map +1 -0
- package/dist/node-local-snapshot.d.ts +109 -0
- package/dist/node-local-snapshot.js +182 -0
- package/dist/node-local-snapshot.js.map +1 -0
- package/dist/peer-authorization.d.ts +135 -18
- package/dist/peer-authorization.js +152 -21
- package/dist/peer-authorization.js.map +1 -1
- package/dist/peer-record.d.ts +21 -8
- package/dist/peer-record.js +26 -10
- package/dist/peer-record.js.map +1 -1
- package/dist/relay-addrs.d.ts +45 -0
- package/dist/relay-addrs.js +103 -0
- package/dist/relay-addrs.js.map +1 -0
- package/dist/relay-reservation.d.ts +266 -0
- package/dist/relay-reservation.js +613 -0
- package/dist/relay-reservation.js.map +1 -0
- package/dist/seed-bootstrap.d.ts +221 -56
- package/dist/seed-bootstrap.js +328 -188
- package/dist/seed-bootstrap.js.map +1 -1
- package/dist/seed-trust-policy.d.ts +47 -21
- package/dist/seed-trust-policy.js +24 -15
- package/dist/seed-trust-policy.js.map +1 -1
- package/dist/strand-addr-protocol.d.ts +42 -13
- package/dist/strand-addr-protocol.js +58 -52
- package/dist/strand-addr-protocol.js.map +1 -1
- package/dist/strand-backfill.d.ts +109 -0
- package/dist/strand-backfill.js +279 -0
- package/dist/strand-backfill.js.map +1 -0
- package/dist/strand-formation-manager.d.ts +38 -9
- package/dist/strand-formation-manager.js +120 -17
- package/dist/strand-formation-manager.js.map +1 -1
- package/dist/strand-formation-protocol.d.ts +103 -4
- package/dist/strand-formation-protocol.js +232 -4
- package/dist/strand-formation-protocol.js.map +1 -1
- package/dist/strand-instance-manager.d.ts +39 -1
- package/dist/strand-instance-manager.js +92 -14
- package/dist/strand-instance-manager.js.map +1 -1
- package/dist/strand-member-registry.d.ts +5 -5
- package/dist/strand-member-registry.js +18 -10
- package/dist/strand-member-registry.js.map +1 -1
- package/dist/strand-membership-writer.d.ts +482 -88
- package/dist/strand-membership-writer.js +757 -136
- package/dist/strand-membership-writer.js.map +1 -1
- package/dist/strand-solicitation.d.ts +99 -33
- package/dist/strand-solicitation.js +100 -52
- package/dist/strand-solicitation.js.map +1 -1
- package/dist/strand-transport-key.d.ts +40 -0
- package/dist/strand-transport-key.js +56 -0
- package/dist/strand-transport-key.js.map +1 -0
- package/dist/strand-wake-protocol.d.ts +9 -7
- package/dist/strand-wake-protocol.js +22 -46
- package/dist/strand-wake-protocol.js.map +1 -1
- package/dist/strand-watcher.d.ts +17 -2
- package/dist/strand-watcher.js +47 -3
- package/dist/strand-watcher.js.map +1 -1
- package/dist/trusted-owner-store-file.d.ts +12 -0
- package/dist/trusted-owner-store-file.js +39 -0
- package/dist/trusted-owner-store-file.js.map +1 -0
- package/dist/trusted-owner-store.d.ts +64 -0
- package/dist/trusted-owner-store.js +126 -0
- package/dist/trusted-owner-store.js.map +1 -0
- package/dist/types.d.ts +275 -20
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -1
- package/package.json +19 -8
- package/src/bootstrap-peer-store-file.ts +44 -0
- package/src/bootstrap-peer-store.ts +172 -0
- package/src/cadre-node.ts +1992 -202
- package/src/control-authorization.ts +114 -0
- package/src/control-database.ts +1704 -146
- package/src/control-formation-recorder.ts +172 -19
- package/src/control-schema.ts +786 -222
- package/src/control-stream.ts +81 -4
- package/src/control-write-retry.ts +473 -0
- package/src/delegate-admission.ts +302 -0
- package/src/device-token.ts +18 -13
- package/src/ed25519-key.ts +134 -69
- package/src/file-durable-slot.ts +61 -0
- package/src/formation-approval.ts +604 -0
- package/src/fs-atomic.ts +107 -0
- package/src/identity-key.ts +109 -0
- package/src/index.ts +136 -5
- package/src/key-store-file.ts +10 -81
- package/src/membership-connection-gater.ts +204 -0
- package/src/node-local-snapshot.ts +260 -0
- package/src/peer-authorization.ts +199 -21
- package/src/peer-record.ts +28 -10
- package/src/relay-addrs.ts +111 -0
- package/src/relay-reservation.ts +823 -0
- package/src/seed-bootstrap.ts +397 -197
- package/src/seed-trust-policy.ts +58 -25
- package/src/strand-addr-protocol.ts +84 -53
- package/src/strand-backfill.ts +366 -0
- package/src/strand-formation-manager.ts +145 -19
- package/src/strand-formation-protocol.ts +309 -8
- package/src/strand-instance-manager.ts +111 -14
- package/src/strand-member-registry.ts +18 -13
- package/src/strand-membership-writer.ts +1430 -640
- package/src/strand-solicitation.ts +155 -90
- package/src/strand-transport-key.ts +58 -0
- package/src/strand-wake-protocol.ts +29 -46
- package/src/strand-watcher.ts +66 -3
- package/src/trusted-owner-store-file.ts +41 -0
- package/src/trusted-owner-store.ts +171 -0
- package/src/types.ts +292 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strand-membership-writer.js","sourceRoot":"","sources":["../src/strand-membership-writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAG3G,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,MAAM,GAAG,GAAG,KAAK,CAAC,gCAAgC,CAAC,CAAC;AAEpD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe,EAAE,aAAqB;IACtE,MAAM,SAAS,GAAG,MAAM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AG,gBAAgB,CAAC,YAAY,KAAK,gBAAgB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;IACrF,MAAM,SAAS,GAAG,kBAAkB,CAClC,CAAC,gBAAgB,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,CAAC,OAAO,CAAC,EACzD,gBAAgB,CAAC,aAAa,CAC/B,CAAC;IACF,MAAM,mBAAmB,CAAC,EAAE,EAAE,KAAK,IAAI,EAAE;QACvC,MAAM,EAAE,CAAC,IAAI,CACX;;6BAEuB,EACvB,CAAC,gBAAgB,CAAC,YAAY,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAC7D,CAAC;QACF,MAAM,gBAAgB,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,0BAA0B,EAAE,gBAAgB,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACnF,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Libp2p } from '@libp2p/interface';
|
|
2
|
-
import type { OpenInvitation, FormStrandResult,
|
|
2
|
+
import type { OpenInvitation, FormStrandResult, StrandFormationDisclosure } from './types.js';
|
|
3
3
|
import { type StrandFormationManagerConfig } from './strand-formation-manager.js';
|
|
4
4
|
import { type FormationResultMessage } from './strand-formation-protocol.js';
|
|
5
5
|
/**
|
|
@@ -28,6 +28,10 @@ export interface DisclosureValidator {
|
|
|
28
28
|
*
|
|
29
29
|
* Replaces the older `{ strandId, memberPrivateKey } | null` shape, which conflated `bound`
|
|
30
30
|
* and `missing` (both produced a non-null result whenever the invite had a `StrandId`).
|
|
31
|
+
*
|
|
32
|
+
* The invite's `ValidationUrl` (the outside approval hook) is deliberately NOT surfaced here:
|
|
33
|
+
* the recorder that performs the write reads it itself, so the choice of which hook to trust
|
|
34
|
+
* never travels through a caller.
|
|
31
35
|
*/
|
|
32
36
|
export type ResolvedHostStrand = {
|
|
33
37
|
kind: 'unbound';
|
|
@@ -46,7 +50,20 @@ export interface FormationUsageRecorder {
|
|
|
46
50
|
/**
|
|
47
51
|
* Record that a formation invite was used
|
|
48
52
|
*/
|
|
49
|
-
recordUsage(
|
|
53
|
+
recordUsage(params: {
|
|
54
|
+
token: string;
|
|
55
|
+
/** The joining peer's own ed25519 public key — written to `FormationUsage.PeerKey` and inside BOTH signed digests. */
|
|
56
|
+
peerKey: string;
|
|
57
|
+
/** The joiner's signature over the `'consent'` digest — written to `FormationUsage.PeerSig`. */
|
|
58
|
+
peerSignature: string;
|
|
59
|
+
/** Joiner-minted single-use nonce; both signed digests cover it. */
|
|
60
|
+
usageStampId: string;
|
|
61
|
+
strandId: string;
|
|
62
|
+
/** Exact text to write to `FormationUsage.Disclosure`; joiner and approver both sign these bytes. */
|
|
63
|
+
disclosure: string;
|
|
64
|
+
/** Aborted when the caller has given up; observed BEFORE any write so the invite stays unspent. */
|
|
65
|
+
signal?: AbortSignal;
|
|
66
|
+
}): Promise<void>;
|
|
50
67
|
/**
|
|
51
68
|
* Check if a token has already been used (for single-use invites)
|
|
52
69
|
*/
|
|
@@ -71,13 +88,34 @@ export interface FormationUsageRecorder {
|
|
|
71
88
|
* ATOMICALLY (single `FormationUsage` row → single-use enforced on the next redemption).
|
|
72
89
|
* Optional: a recorder that only supports provision-then-record omits it, and the
|
|
73
90
|
* manager falls back to its {@link StrandProvisioner}. Mirrors the create-strand-by-consent
|
|
74
|
-
* path the schema's `Strand.
|
|
91
|
+
* path the schema's `Strand.AuthorizedInsert` `FormationUsage` branch authorizes. Returns the
|
|
75
92
|
* minted strand id plus its membership key (null for an open responder-provisioned strand).
|
|
76
93
|
*/
|
|
77
|
-
provisionAndRecord?(
|
|
94
|
+
provisionAndRecord?(params: {
|
|
95
|
+
token: string;
|
|
96
|
+
/** The joining peer's own ed25519 public key — written to `FormationUsage.PeerKey` and inside BOTH signed digests. */
|
|
97
|
+
peerKey: string;
|
|
98
|
+
/** The joiner's signature over the `'consent'` digest — written to `FormationUsage.PeerSig`. */
|
|
99
|
+
peerSignature: string;
|
|
100
|
+
/** Joiner-minted single-use nonce; both signed digests cover it. */
|
|
101
|
+
usageStampId: string;
|
|
102
|
+
sAppId: string;
|
|
103
|
+
/** Exact text to write to `FormationUsage.Disclosure`; joiner and approver both sign these bytes. */
|
|
104
|
+
disclosure: string;
|
|
105
|
+
/** Aborted when the caller has given up; observed BEFORE any write so the invite stays unspent. */
|
|
106
|
+
signal?: AbortSignal;
|
|
107
|
+
}): Promise<{
|
|
78
108
|
strandId: string;
|
|
79
109
|
memberPrivateKey: string | null;
|
|
80
110
|
}>;
|
|
111
|
+
/**
|
|
112
|
+
* Is ANY invitation this recorder knows about unexpired and not fully
|
|
113
|
+
* consumed? Optional: a recorder that cannot enumerate invitations omits it,
|
|
114
|
+
* and only locally-minted invitations hold the connection gate's formation
|
|
115
|
+
* exemption open. Distinct from the per-token {@link isTokenValid} /
|
|
116
|
+
* {@link isTokenUsed} pair — the connection gate has no token to ask about.
|
|
117
|
+
*/
|
|
118
|
+
hasOutstandingInvitation?(): Promise<boolean>;
|
|
81
119
|
}
|
|
82
120
|
/**
|
|
83
121
|
* Interface for strand provisioning during formation
|
|
@@ -90,18 +128,6 @@ export interface StrandProvisioner {
|
|
|
90
128
|
strandId: string;
|
|
91
129
|
}>;
|
|
92
130
|
}
|
|
93
|
-
/**
|
|
94
|
-
* Interface for signing formation approvals
|
|
95
|
-
*/
|
|
96
|
-
export interface FormationSigner {
|
|
97
|
-
/**
|
|
98
|
-
* Sign a formation approval
|
|
99
|
-
*/
|
|
100
|
-
signFormation(token: string, disclosure: StrandFormationDisclosure): Promise<{
|
|
101
|
-
validationKey: string;
|
|
102
|
-
validationSignature: string;
|
|
103
|
-
}>;
|
|
104
|
-
}
|
|
105
131
|
/**
|
|
106
132
|
* Interface for validating the responder's formation result on the initiator side.
|
|
107
133
|
*
|
|
@@ -132,7 +158,6 @@ export interface StrandSolicitationServiceOptions {
|
|
|
132
158
|
disclosureValidator?: DisclosureValidator;
|
|
133
159
|
formationUsageRecorder?: FormationUsageRecorder;
|
|
134
160
|
strandProvisioner?: StrandProvisioner;
|
|
135
|
-
formationSigner?: FormationSigner;
|
|
136
161
|
/** Validates the responder's result on the initiator side (defaults to a structural check) */
|
|
137
162
|
formationResponseValidator?: FormationResponseValidator;
|
|
138
163
|
/** Party ID for this node (used in protocol messages) */
|
|
@@ -147,7 +172,10 @@ export interface StrandSolicitationServiceOptions {
|
|
|
147
172
|
*
|
|
148
173
|
* This service handles the high-level API defined in api.md:
|
|
149
174
|
* - formStrand(invitation, disclosure, node) - called by initiator
|
|
150
|
-
*
|
|
175
|
+
*
|
|
176
|
+
* Outside approval of a redemption (an invite's `ValidationUrl`) is NOT here: it belongs to
|
|
177
|
+
* the redeeming node, which alone mints the nonce the approval is bound to. See
|
|
178
|
+
* `formation-approval.ts`.
|
|
151
179
|
*
|
|
152
180
|
* When a libp2p node is provided, the underlying protocol is handled by the
|
|
153
181
|
* native cadre-core formation transport via StrandFormationManager.
|
|
@@ -156,12 +184,23 @@ export declare class StrandSolicitationService {
|
|
|
156
184
|
private readonly disclosureValidator?;
|
|
157
185
|
private readonly formationUsageRecorder?;
|
|
158
186
|
private readonly strandProvisioner?;
|
|
159
|
-
private readonly formationSigner?;
|
|
160
187
|
private readonly formationResponseValidator?;
|
|
161
188
|
private readonly partyId;
|
|
162
189
|
private readonly cadrePeerAddrs;
|
|
163
190
|
private formationManager?;
|
|
164
191
|
private readonly formationConfig?;
|
|
192
|
+
/**
|
|
193
|
+
* Tokens this process has minted (or published), mapped to their expiry
|
|
194
|
+
* epoch-ms — the in-memory half of {@link hasOutstandingInvitation}. Dies with
|
|
195
|
+
* the process, exactly like `CadreNode`'s enrollment window; a token that also
|
|
196
|
+
* reached the durable `FormationInvite` table survives via the recorder.
|
|
197
|
+
*
|
|
198
|
+
* NOTE: pruned only while {@link hasOutstandingInvitation} runs, so a node that
|
|
199
|
+
* mints steadily and never receives an inbound stranger retains every entry for
|
|
200
|
+
* the process's life. Bounded by mint rate today; if a host ever mints at scale,
|
|
201
|
+
* prune on a timer (or cap the map) instead of only on read.
|
|
202
|
+
*/
|
|
203
|
+
private readonly mintedInvitations;
|
|
165
204
|
constructor(options?: StrandSolicitationServiceOptions);
|
|
166
205
|
/**
|
|
167
206
|
* Get or create the StrandFormationManager.
|
|
@@ -190,19 +229,6 @@ export declare class StrandSolicitationService {
|
|
|
190
229
|
* @returns The member key and strand info if successful
|
|
191
230
|
*/
|
|
192
231
|
formStrand(invitation: OpenInvitation | string, disclosure: StrandFormationDisclosure, node?: Libp2p): Promise<FormStrandResult>;
|
|
193
|
-
/**
|
|
194
|
-
* Validate a strand formation request.
|
|
195
|
-
*
|
|
196
|
-
* Called by the responder (the party who created the open invitation) when
|
|
197
|
-
* an initiator contacts them to form a strand. Validates the disclosure
|
|
198
|
-
* and returns a signed approval.
|
|
199
|
-
*
|
|
200
|
-
* @param token The invitation token being used
|
|
201
|
-
* @param disclosure The disclosure from the initiator
|
|
202
|
-
* @returns Validation key and signature if approved
|
|
203
|
-
* @throws If validation fails or token is invalid
|
|
204
|
-
*/
|
|
205
|
-
validateStrandFormation(token: string, disclosure: StrandFormationDisclosure): Promise<ValidateFormationResult>;
|
|
206
232
|
/**
|
|
207
233
|
* Create an open invitation for others to form strands with this party.
|
|
208
234
|
*
|
|
@@ -212,9 +238,49 @@ export declare class StrandSolicitationService {
|
|
|
212
238
|
* @returns The open invitation to share out-of-band
|
|
213
239
|
*/
|
|
214
240
|
createOpenInvitation(sAppId: string, expirationMs: number, bootstrap: string[]): Promise<OpenInvitation>;
|
|
241
|
+
/**
|
|
242
|
+
* Remember a token this node minted (or published) so
|
|
243
|
+
* {@link hasOutstandingInvitation} can answer "yes" before the durable
|
|
244
|
+
* `FormationInvite` row is readable — or when there is no durable store at
|
|
245
|
+
* all. `expiresAtMs` may be `Number.POSITIVE_INFINITY` for an invitation that
|
|
246
|
+
* never expires.
|
|
247
|
+
*/
|
|
248
|
+
registerMintedInvitation(token: string, expiresAtMs: number): void;
|
|
249
|
+
/**
|
|
250
|
+
* Does this node currently expect a stranger — i.e. is at least one open
|
|
251
|
+
* invitation unexpired and not yet fully consumed? Sole input to the
|
|
252
|
+
* control-network connection gate's formation exemption.
|
|
253
|
+
*
|
|
254
|
+
* Two sources, in order:
|
|
255
|
+
*
|
|
256
|
+
* 1. The local mint registry ({@link registerMintedInvitation}), which is
|
|
257
|
+
* in-memory and dies with the process. Expired entries are dropped. With
|
|
258
|
+
* no {@link FormationUsageRecorder} configured there is no consumption
|
|
259
|
+
* oracle, so an unexpired minted token counts as outstanding by
|
|
260
|
+
* construction; with one, a token it reports used is deleted (consumption
|
|
261
|
+
* is permanent, so the registry never reconsiders it).
|
|
262
|
+
* 2. The recorder's optional {@link FormationUsageRecorder.hasOutstandingInvitation},
|
|
263
|
+
* which survives restarts and sees invitations replicated in from siblings.
|
|
264
|
+
*
|
|
265
|
+
* Re-entrant: concurrent inbound connections each call this independently and
|
|
266
|
+
* the only mutation is deleting expired/consumed entries, which is monotonic.
|
|
267
|
+
*/
|
|
268
|
+
hasOutstandingInvitation(): Promise<boolean>;
|
|
215
269
|
/**
|
|
216
270
|
* Record that a formation was completed successfully.
|
|
217
271
|
* Called after strand provisioning to track usage.
|
|
272
|
+
*
|
|
273
|
+
* `consent` carries the joiner-signed fields `recordUsage` now requires
|
|
274
|
+
* (see {@link FormationUsageRecorder.recordUsage}); this helper only passes them through.
|
|
275
|
+
*
|
|
276
|
+
* NOTE: this reaches `recordUsage` without passing through
|
|
277
|
+
* `StrandFormationManager.provisionAsResponder`, so `disclosure` skips that path's
|
|
278
|
+
* `MAX_DISCLOSURE_BYTES` cap. Harmless today — its only callers are integration-test mocks
|
|
279
|
+
* that all default to `''` — but if a production caller ever passes a real disclosure here,
|
|
280
|
+
* cap it too (the approver signs those bytes verbatim).
|
|
218
281
|
*/
|
|
219
|
-
recordFormationComplete(token: string,
|
|
282
|
+
recordFormationComplete(token: string, peerKey: string, strandId: string, consent: {
|
|
283
|
+
usageStampId: string;
|
|
284
|
+
peerSignature: string;
|
|
285
|
+
}, disclosure?: string): Promise<void>;
|
|
220
286
|
}
|
|
@@ -2,6 +2,11 @@ import debug from 'debug';
|
|
|
2
2
|
import { toString as uint8ArrayToString } from 'uint8arrays';
|
|
3
3
|
import { generateKeyPair, privateKeyToProtobuf } from '@libp2p/crypto/keys';
|
|
4
4
|
import { peerIdFromPrivateKey } from '@libp2p/peer-id';
|
|
5
|
+
import { sign } from '@optimystic/quereus-plugin-crypto';
|
|
6
|
+
// control-database does not import this service, so these imports introduce no cycle.
|
|
7
|
+
import { generateStampId, formationConsentMessage } from './control-database.js';
|
|
8
|
+
import { canonicalJson } from './canonical-json.js';
|
|
9
|
+
import { ed25519KeyPairFromLibp2p } from './ed25519-key.js';
|
|
5
10
|
import { StrandFormationManager } from './strand-formation-manager.js';
|
|
6
11
|
import { isValidResponderCreatesResult } from './strand-formation-protocol.js';
|
|
7
12
|
const log = debug('sereus:cadre:solicitation');
|
|
@@ -25,17 +30,31 @@ export function createDefaultFormationResponseValidator() {
|
|
|
25
30
|
*
|
|
26
31
|
* This service handles the high-level API defined in api.md:
|
|
27
32
|
* - formStrand(invitation, disclosure, node) - called by initiator
|
|
28
|
-
*
|
|
33
|
+
*
|
|
34
|
+
* Outside approval of a redemption (an invite's `ValidationUrl`) is NOT here: it belongs to
|
|
35
|
+
* the redeeming node, which alone mints the nonce the approval is bound to. See
|
|
36
|
+
* `formation-approval.ts`.
|
|
29
37
|
*
|
|
30
38
|
* When a libp2p node is provided, the underlying protocol is handled by the
|
|
31
39
|
* native cadre-core formation transport via StrandFormationManager.
|
|
32
40
|
*/
|
|
33
41
|
export class StrandSolicitationService {
|
|
34
42
|
constructor(options) {
|
|
43
|
+
/**
|
|
44
|
+
* Tokens this process has minted (or published), mapped to their expiry
|
|
45
|
+
* epoch-ms — the in-memory half of {@link hasOutstandingInvitation}. Dies with
|
|
46
|
+
* the process, exactly like `CadreNode`'s enrollment window; a token that also
|
|
47
|
+
* reached the durable `FormationInvite` table survives via the recorder.
|
|
48
|
+
*
|
|
49
|
+
* NOTE: pruned only while {@link hasOutstandingInvitation} runs, so a node that
|
|
50
|
+
* mints steadily and never receives an inbound stranger retains every entry for
|
|
51
|
+
* the process's life. Bounded by mint rate today; if a host ever mints at scale,
|
|
52
|
+
* prune on a timer (or cap the map) instead of only on read.
|
|
53
|
+
*/
|
|
54
|
+
this.mintedInvitations = new Map();
|
|
35
55
|
this.disclosureValidator = options?.disclosureValidator;
|
|
36
56
|
this.formationUsageRecorder = options?.formationUsageRecorder;
|
|
37
57
|
this.strandProvisioner = options?.strandProvisioner;
|
|
38
|
-
this.formationSigner = options?.formationSigner;
|
|
39
58
|
this.formationResponseValidator = options?.formationResponseValidator;
|
|
40
59
|
this.partyId = options?.partyId ?? `party-${Date.now()}`;
|
|
41
60
|
this.cadrePeerAddrs = options?.cadrePeerAddrs ?? [];
|
|
@@ -101,7 +120,19 @@ export class StrandSolicitationService {
|
|
|
101
120
|
// If we have a full invitation and a node, use the real protocol
|
|
102
121
|
if (typeof invitation !== 'string' && node) {
|
|
103
122
|
log('Using native cadre-core formation transport');
|
|
104
|
-
const
|
|
123
|
+
const { privateKeyB64, publicKeyB64 } = ed25519KeyPairFromLibp2p(privateKey);
|
|
124
|
+
const usageStampId = generateStampId(memberKey);
|
|
125
|
+
// Built ONCE, AFTER the partyId override: this exact object travels to the
|
|
126
|
+
// responder, and its canonical serialization is the disclosure text the consent
|
|
127
|
+
// signature covers and the responder writes to `FormationUsage.Disclosure`.
|
|
128
|
+
const fullDisclosure = { ...disclosure, partyId: memberKey };
|
|
129
|
+
const peerSignature = sign(formationConsentMessage({
|
|
130
|
+
token,
|
|
131
|
+
usageStampId,
|
|
132
|
+
peerKey: publicKeyB64,
|
|
133
|
+
disclosure: canonicalJson(fullDisclosure)
|
|
134
|
+
}), privateKeyB64, 'ed25519', 'bytes', 'base64url', 'base64url');
|
|
135
|
+
const result = await this.getFormationManager().formStrand(invitation, fullDisclosure, { peerKey: publicKeyB64, usageStampId, peerSignature }, node);
|
|
105
136
|
return {
|
|
106
137
|
memberKey,
|
|
107
138
|
invitePrivateKey,
|
|
@@ -120,53 +151,6 @@ export class StrandSolicitationService {
|
|
|
120
151
|
strandId
|
|
121
152
|
};
|
|
122
153
|
}
|
|
123
|
-
/**
|
|
124
|
-
* Validate a strand formation request.
|
|
125
|
-
*
|
|
126
|
-
* Called by the responder (the party who created the open invitation) when
|
|
127
|
-
* an initiator contacts them to form a strand. Validates the disclosure
|
|
128
|
-
* and returns a signed approval.
|
|
129
|
-
*
|
|
130
|
-
* @param token The invitation token being used
|
|
131
|
-
* @param disclosure The disclosure from the initiator
|
|
132
|
-
* @returns Validation key and signature if approved
|
|
133
|
-
* @throws If validation fails or token is invalid
|
|
134
|
-
*/
|
|
135
|
-
async validateStrandFormation(token, disclosure) {
|
|
136
|
-
log('Validating strand formation for token: %s', token);
|
|
137
|
-
// Check token validity
|
|
138
|
-
if (this.formationUsageRecorder) {
|
|
139
|
-
const tokenCheck = await this.formationUsageRecorder.isTokenValid(token);
|
|
140
|
-
if (!tokenCheck.valid) {
|
|
141
|
-
log('Token invalid or expired: %s', token);
|
|
142
|
-
throw new Error('Invalid or expired token');
|
|
143
|
-
}
|
|
144
|
-
// Check if already used (for single-use tokens)
|
|
145
|
-
const isUsed = await this.formationUsageRecorder.isTokenUsed(token);
|
|
146
|
-
if (isUsed) {
|
|
147
|
-
log('Token already used: %s', token);
|
|
148
|
-
throw new Error('Token has already been used');
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
// Validate the disclosure
|
|
152
|
-
if (this.disclosureValidator) {
|
|
153
|
-
const isValid = await this.disclosureValidator.validateDisclosure(token, disclosure);
|
|
154
|
-
if (!isValid) {
|
|
155
|
-
log('Disclosure validation failed for token: %s', token);
|
|
156
|
-
throw new Error('Disclosure validation failed');
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
// Sign the formation approval
|
|
160
|
-
if (!this.formationSigner) {
|
|
161
|
-
throw new Error('FormationSigner not configured');
|
|
162
|
-
}
|
|
163
|
-
const { validationKey, validationSignature } = await this.formationSigner.signFormation(token, disclosure);
|
|
164
|
-
log('Formation validated, key: %s', validationKey);
|
|
165
|
-
return {
|
|
166
|
-
validationKey,
|
|
167
|
-
validationSignature
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
154
|
/**
|
|
171
155
|
* Create an open invitation for others to form strands with this party.
|
|
172
156
|
*
|
|
@@ -179,6 +163,7 @@ export class StrandSolicitationService {
|
|
|
179
163
|
// Generate a unique token
|
|
180
164
|
const token = `invite-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
|
|
181
165
|
const expiration = new Date(Date.now() + expirationMs);
|
|
166
|
+
this.registerMintedInvitation(token, expiration.getTime());
|
|
182
167
|
log('Created open invitation: %s (expires %s)', token, expiration.toISOString());
|
|
183
168
|
return {
|
|
184
169
|
token,
|
|
@@ -187,13 +172,76 @@ export class StrandSolicitationService {
|
|
|
187
172
|
bootstrap
|
|
188
173
|
};
|
|
189
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Remember a token this node minted (or published) so
|
|
177
|
+
* {@link hasOutstandingInvitation} can answer "yes" before the durable
|
|
178
|
+
* `FormationInvite` row is readable — or when there is no durable store at
|
|
179
|
+
* all. `expiresAtMs` may be `Number.POSITIVE_INFINITY` for an invitation that
|
|
180
|
+
* never expires.
|
|
181
|
+
*/
|
|
182
|
+
registerMintedInvitation(token, expiresAtMs) {
|
|
183
|
+
this.mintedInvitations.set(token, expiresAtMs);
|
|
184
|
+
log('Registered minted invitation %s (expires %d)', token, expiresAtMs);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Does this node currently expect a stranger — i.e. is at least one open
|
|
188
|
+
* invitation unexpired and not yet fully consumed? Sole input to the
|
|
189
|
+
* control-network connection gate's formation exemption.
|
|
190
|
+
*
|
|
191
|
+
* Two sources, in order:
|
|
192
|
+
*
|
|
193
|
+
* 1. The local mint registry ({@link registerMintedInvitation}), which is
|
|
194
|
+
* in-memory and dies with the process. Expired entries are dropped. With
|
|
195
|
+
* no {@link FormationUsageRecorder} configured there is no consumption
|
|
196
|
+
* oracle, so an unexpired minted token counts as outstanding by
|
|
197
|
+
* construction; with one, a token it reports used is deleted (consumption
|
|
198
|
+
* is permanent, so the registry never reconsiders it).
|
|
199
|
+
* 2. The recorder's optional {@link FormationUsageRecorder.hasOutstandingInvitation},
|
|
200
|
+
* which survives restarts and sees invitations replicated in from siblings.
|
|
201
|
+
*
|
|
202
|
+
* Re-entrant: concurrent inbound connections each call this independently and
|
|
203
|
+
* the only mutation is deleting expired/consumed entries, which is monotonic.
|
|
204
|
+
*/
|
|
205
|
+
async hasOutstandingInvitation() {
|
|
206
|
+
const now = Date.now();
|
|
207
|
+
for (const [token, expiresAtMs] of this.mintedInvitations) {
|
|
208
|
+
if (expiresAtMs <= now) {
|
|
209
|
+
this.mintedInvitations.delete(token);
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
if (!this.formationUsageRecorder) {
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
if (!(await this.formationUsageRecorder.isTokenUsed(token))) {
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
this.mintedInvitations.delete(token);
|
|
219
|
+
}
|
|
220
|
+
return (await this.formationUsageRecorder?.hasOutstandingInvitation?.()) ?? false;
|
|
221
|
+
}
|
|
190
222
|
/**
|
|
191
223
|
* Record that a formation was completed successfully.
|
|
192
224
|
* Called after strand provisioning to track usage.
|
|
225
|
+
*
|
|
226
|
+
* `consent` carries the joiner-signed fields `recordUsage` now requires
|
|
227
|
+
* (see {@link FormationUsageRecorder.recordUsage}); this helper only passes them through.
|
|
228
|
+
*
|
|
229
|
+
* NOTE: this reaches `recordUsage` without passing through
|
|
230
|
+
* `StrandFormationManager.provisionAsResponder`, so `disclosure` skips that path's
|
|
231
|
+
* `MAX_DISCLOSURE_BYTES` cap. Harmless today — its only callers are integration-test mocks
|
|
232
|
+
* that all default to `''` — but if a production caller ever passes a real disclosure here,
|
|
233
|
+
* cap it too (the approver signs those bytes verbatim).
|
|
193
234
|
*/
|
|
194
|
-
async recordFormationComplete(token,
|
|
235
|
+
async recordFormationComplete(token, peerKey, strandId, consent, disclosure = '') {
|
|
195
236
|
if (this.formationUsageRecorder) {
|
|
196
|
-
await this.formationUsageRecorder.recordUsage(
|
|
237
|
+
await this.formationUsageRecorder.recordUsage({
|
|
238
|
+
token,
|
|
239
|
+
peerKey,
|
|
240
|
+
peerSignature: consent.peerSignature,
|
|
241
|
+
usageStampId: consent.usageStampId,
|
|
242
|
+
strandId,
|
|
243
|
+
disclosure
|
|
244
|
+
});
|
|
197
245
|
log('Recorded formation usage: token=%s strand=%s', token, strandId);
|
|
198
246
|
}
|
|
199
247
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strand-solicitation.js","sourceRoot":"","sources":["../src/strand-solicitation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"strand-solicitation.js","sourceRoot":"","sources":["../src/strand-solicitation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EAAE,IAAI,EAA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CAAC;YAC1D,IAAI,WAAW,IAAI,GAAG,EAAE,CAAC;gBACvB,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACrC,SAAS;YACX,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC;gBACjC,OAAO,IAAI,CAAC;YACd,CAAC;YACD,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;gBAC5D,OAAO,IAAI,CAAC;YACd,CAAC;YACD,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;QACD,OAAO,CAAC,MAAM,IAAI,CAAC,sBAAsB,EAAE,wBAAwB,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC;IACpF,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,uBAAuB,CAC3B,KAAa,EACb,OAAe,EACf,QAAgB,EAChB,OAAwD,EACxD,UAAU,GAAG,EAAE;QAEf,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAChC,MAAM,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC;gBAC5C,KAAK;gBACL,OAAO;gBACP,aAAa,EAAE,OAAO,CAAC,aAAa;gBACpC,YAAY,EAAE,OAAO,CAAC,YAAY;gBAClC,QAAQ;gBACR,UAAU;aACX,CAAC,CAAC;YACH,GAAG,CAAC,8CAA8C,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { PrivateKey } from '@libp2p/interface';
|
|
2
|
+
/**
|
|
3
|
+
* Derive a strand node's libp2p transport key from the cadre identity key and
|
|
4
|
+
* the strand id.
|
|
5
|
+
*
|
|
6
|
+
* A `CadreNode` runs its control node and each strand node as separate libp2p
|
|
7
|
+
* instances. Handing them all the same private key gives them all the same
|
|
8
|
+
* peerId, and `@libp2p/circuit-relay-v2` keys reservations and hop-connects by
|
|
9
|
+
* peerId — so a control node and a strand node reserving through one shared
|
|
10
|
+
* relay collide, and relayed streams for one land on the other
|
|
11
|
+
* (https://github.com/gotchoices/sereus/issues/1). Each strand node therefore
|
|
12
|
+
* gets its own transport identity. Cadre *authority* is untouched: the control
|
|
13
|
+
* node keeps the identity key, and every peerId→authority derivation
|
|
14
|
+
* (`ed25519PublicKeyB64FromPeerId`) is a control-network path.
|
|
15
|
+
*
|
|
16
|
+
* The derivation is deterministic — `sha256(domain, identity seed, strandId)`
|
|
17
|
+
* as an Ed25519 seed — rather than a fresh random key per launch, so the
|
|
18
|
+
* strand's transport peerId survives restarts. The identity *private* seed is
|
|
19
|
+
* an input (not the public key) so that no third party can enumerate a member's
|
|
20
|
+
* strand peerIds from public data; only the key holder can compute them.
|
|
21
|
+
*
|
|
22
|
+
* NOTE: the derived peerId *is* attested at runtime: before a strand node
|
|
23
|
+
* starts, its control node announces it over the strand-addr RPC, and a
|
|
24
|
+
* membership-gated relay (a party control node running the relay server) holds
|
|
25
|
+
* a short-lived delegate admission grant for it (`delegate-admission.ts`) —
|
|
26
|
+
* without that grant the relay denies the strand node's reservation and
|
|
27
|
+
* `libp2p.start()` fails. The strand *mesh* itself still does not gate
|
|
28
|
+
* admission by peerId (strand peers are legitimately cross-party); if
|
|
29
|
+
* strand-mesh admission control is ever added, the durable binding it needs is
|
|
30
|
+
* a `MemberPeer(MemberKey, PeerId)` row: the table and its self-signed
|
|
31
|
+
* `Authorized` constraint already exist in `schemas/strand.qsql`; production
|
|
32
|
+
* code simply never writes one.
|
|
33
|
+
*
|
|
34
|
+
* @param identityKey - The cadre's Ed25519 identity key (the control node's key).
|
|
35
|
+
* @param strandId - The strand whose transport key to derive.
|
|
36
|
+
* @returns A stable, per-strand Ed25519 libp2p private key, distinct from the
|
|
37
|
+
* identity key and from every other strand's.
|
|
38
|
+
* @throws If the identity key is not Ed25519.
|
|
39
|
+
*/
|
|
40
|
+
export declare function strandTransportKey(identityKey: PrivateKey, strandId: string): Promise<PrivateKey>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { generateKeyPairFromSeed } from '@libp2p/crypto/keys';
|
|
2
|
+
import { digest } from '@optimystic/quereus-plugin-crypto';
|
|
3
|
+
import { ed25519KeyPairFromLibp2p } from './ed25519-key.js';
|
|
4
|
+
/**
|
|
5
|
+
* Domain-separation tag for the strand-transport-key derivation. Versioned so a
|
|
6
|
+
* future change to the derivation (different KDF, different inputs) can bump to
|
|
7
|
+
* `.v2` and be recognized as a deliberate identity migration rather than silent
|
|
8
|
+
* peerId churn — a strand node's transport peerId must stay stable across
|
|
9
|
+
* process restarts, or any peer-store entry or `MemberPeer` row that names it
|
|
10
|
+
* goes stale on every boot.
|
|
11
|
+
*/
|
|
12
|
+
const STRAND_TRANSPORT_KEY_DOMAIN = 'sereus.strand-transport-key.v1';
|
|
13
|
+
/**
|
|
14
|
+
* Derive a strand node's libp2p transport key from the cadre identity key and
|
|
15
|
+
* the strand id.
|
|
16
|
+
*
|
|
17
|
+
* A `CadreNode` runs its control node and each strand node as separate libp2p
|
|
18
|
+
* instances. Handing them all the same private key gives them all the same
|
|
19
|
+
* peerId, and `@libp2p/circuit-relay-v2` keys reservations and hop-connects by
|
|
20
|
+
* peerId — so a control node and a strand node reserving through one shared
|
|
21
|
+
* relay collide, and relayed streams for one land on the other
|
|
22
|
+
* (https://github.com/gotchoices/sereus/issues/1). Each strand node therefore
|
|
23
|
+
* gets its own transport identity. Cadre *authority* is untouched: the control
|
|
24
|
+
* node keeps the identity key, and every peerId→authority derivation
|
|
25
|
+
* (`ed25519PublicKeyB64FromPeerId`) is a control-network path.
|
|
26
|
+
*
|
|
27
|
+
* The derivation is deterministic — `sha256(domain, identity seed, strandId)`
|
|
28
|
+
* as an Ed25519 seed — rather than a fresh random key per launch, so the
|
|
29
|
+
* strand's transport peerId survives restarts. The identity *private* seed is
|
|
30
|
+
* an input (not the public key) so that no third party can enumerate a member's
|
|
31
|
+
* strand peerIds from public data; only the key holder can compute them.
|
|
32
|
+
*
|
|
33
|
+
* NOTE: the derived peerId *is* attested at runtime: before a strand node
|
|
34
|
+
* starts, its control node announces it over the strand-addr RPC, and a
|
|
35
|
+
* membership-gated relay (a party control node running the relay server) holds
|
|
36
|
+
* a short-lived delegate admission grant for it (`delegate-admission.ts`) —
|
|
37
|
+
* without that grant the relay denies the strand node's reservation and
|
|
38
|
+
* `libp2p.start()` fails. The strand *mesh* itself still does not gate
|
|
39
|
+
* admission by peerId (strand peers are legitimately cross-party); if
|
|
40
|
+
* strand-mesh admission control is ever added, the durable binding it needs is
|
|
41
|
+
* a `MemberPeer(MemberKey, PeerId)` row: the table and its self-signed
|
|
42
|
+
* `Authorized` constraint already exist in `schemas/strand.qsql`; production
|
|
43
|
+
* code simply never writes one.
|
|
44
|
+
*
|
|
45
|
+
* @param identityKey - The cadre's Ed25519 identity key (the control node's key).
|
|
46
|
+
* @param strandId - The strand whose transport key to derive.
|
|
47
|
+
* @returns A stable, per-strand Ed25519 libp2p private key, distinct from the
|
|
48
|
+
* identity key and from every other strand's.
|
|
49
|
+
* @throws If the identity key is not Ed25519.
|
|
50
|
+
*/
|
|
51
|
+
export async function strandTransportKey(identityKey, strandId) {
|
|
52
|
+
const { privateKeyB64 } = ed25519KeyPairFromLibp2p(identityKey);
|
|
53
|
+
const seed = digest([STRAND_TRANSPORT_KEY_DOMAIN, privateKeyB64, strandId], 'sha256', 'bytes');
|
|
54
|
+
return generateKeyPairFromSeed('Ed25519', seed);
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=strand-transport-key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strand-transport-key.js","sourceRoot":"","sources":["../src/strand-transport-key.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,2BAA2B,GAAG,gCAAgC,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,WAAuB,EAAE,QAAgB;IAChF,MAAM,EAAE,aAAa,EAAE,GAAG,wBAAwB,CAAC,WAAW,CAAC,CAAC;IAChE,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,2BAA2B,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAe,CAAC;IAC7G,OAAO,uBAAuB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -14,13 +14,15 @@
|
|
|
14
14
|
* stream (like seed delivery), so each side reads to EOF (under a read timeout)
|
|
15
15
|
* and decodes one frame via the shared {@link decodeLengthPrefixedFrame} guard.
|
|
16
16
|
*
|
|
17
|
-
* **Authorization (v1):**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
17
|
+
* **Authorization (v1):** a wake is low-risk — it only causes the receiver to
|
|
18
|
+
* spend resources coming online for a strand it already participates in — so the
|
|
19
|
+
* receiver carries no per-request signature and instead defers entirely to the
|
|
20
|
+
* injected `isMember` predicate. `CadreNode` injects its AUTHORIZED-membership
|
|
21
|
+
* predicate there (`isAuthorizedMember`: the sender's `CadrePeer` row must carry
|
|
22
|
+
* a voucher that verifies against an owner key in the receiver's node-local
|
|
23
|
+
* trusted-owner anchor), so a peer that merely published rows into the replicated
|
|
24
|
+
* control DB is refused. This module stays agnostic: it enforces whatever
|
|
25
|
+
* predicate it is given.
|
|
24
26
|
*/
|
|
25
27
|
import type { Libp2p } from '@libp2p/interface';
|
|
26
28
|
import type { Multiaddr } from '@multiformats/multiaddr';
|