@serfab/cadre-core 0.13.0 → 1.1.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 +20 -6
- package/dist/bootstrap-peer-store-file.js +2 -2
- package/dist/bootstrap-peer-store.d.ts +32 -12
- package/dist/bootstrap-peer-store.js +41 -15
- package/dist/bootstrap-peer-store.js.map +1 -1
- package/dist/cadre-node.d.ts +558 -80
- package/dist/cadre-node.js +1060 -170
- package/dist/cadre-node.js.map +1 -1
- package/dist/control-authorization.d.ts +2 -2
- package/dist/control-authorization.js +1 -0
- package/dist/control-authorization.js.map +1 -1
- package/dist/control-cohort.d.ts +13 -26
- package/dist/control-cohort.js +0 -26
- package/dist/control-cohort.js.map +1 -1
- package/dist/control-database.d.ts +299 -44
- package/dist/control-database.js +469 -69
- package/dist/control-database.js.map +1 -1
- package/dist/control-read-retry.d.ts +40 -11
- package/dist/control-read-retry.js +48 -15
- package/dist/control-read-retry.js.map +1 -1
- package/dist/control-retry.d.ts +58 -3
- package/dist/control-retry.js +58 -3
- package/dist/control-retry.js.map +1 -1
- package/dist/control-schema.d.ts +1 -1
- package/dist/control-schema.js +103 -19
- package/dist/control-schema.js.map +1 -1
- package/dist/control-write-retry.d.ts +80 -11
- package/dist/control-write-retry.js +176 -29
- package/dist/control-write-retry.js.map +1 -1
- package/dist/enrolled-machine-store.js +2 -2
- package/dist/index.d.ts +14 -7
- package/dist/index.js +33 -6
- package/dist/index.js.map +1 -1
- package/dist/node-local-snapshot.d.ts +15 -7
- package/dist/node-local-snapshot.js +23 -8
- package/dist/node-local-snapshot.js.map +1 -1
- package/dist/peer-dial.d.ts +143 -0
- package/dist/peer-dial.js +176 -0
- package/dist/peer-dial.js.map +1 -0
- package/dist/relay-addrs.d.ts +90 -52
- package/dist/relay-addrs.js +91 -59
- package/dist/relay-addrs.js.map +1 -1
- package/dist/relay-reservation.d.ts +71 -3
- package/dist/relay-reservation.js +116 -8
- package/dist/relay-reservation.js.map +1 -1
- package/dist/seed-bootstrap.d.ts +30 -1
- package/dist/seed-bootstrap.js +62 -17
- package/dist/seed-bootstrap.js.map +1 -1
- package/dist/storage-scope.d.ts +62 -0
- package/dist/storage-scope.js +75 -0
- package/dist/storage-scope.js.map +1 -0
- package/dist/strand-database.d.ts +34 -16
- package/dist/strand-database.js +38 -24
- package/dist/strand-database.js.map +1 -1
- package/dist/strand-first-sync-gate.d.ts +152 -0
- package/dist/strand-first-sync-gate.js +208 -0
- package/dist/strand-first-sync-gate.js.map +1 -0
- package/dist/strand-formation-manager.d.ts +87 -5
- package/dist/strand-formation-manager.js +109 -5
- package/dist/strand-formation-manager.js.map +1 -1
- package/dist/strand-formation-protocol.d.ts +21 -1
- package/dist/strand-formation-protocol.js +30 -0
- package/dist/strand-formation-protocol.js.map +1 -1
- package/dist/strand-instance-manager.d.ts +243 -6
- package/dist/strand-instance-manager.js +470 -37
- package/dist/strand-instance-manager.js.map +1 -1
- package/dist/strand-member-key.d.ts +20 -12
- package/dist/strand-member-key.js +20 -12
- package/dist/strand-member-key.js.map +1 -1
- package/dist/strand-member-registry.js +3 -0
- package/dist/strand-member-registry.js.map +1 -1
- package/dist/strand-membership-reconciler.d.ts +361 -0
- package/dist/strand-membership-reconciler.js +548 -0
- package/dist/strand-membership-reconciler.js.map +1 -0
- package/dist/strand-membership-writer.d.ts +131 -11
- package/dist/strand-membership-writer.js +396 -134
- package/dist/strand-membership-writer.js.map +1 -1
- package/dist/strand-network-config.d.ts +46 -14
- package/dist/strand-network-config.js +79 -23
- package/dist/strand-network-config.js.map +1 -1
- package/dist/strand-solicitation.d.ts +10 -1
- package/dist/strand-solicitation.js +5 -0
- package/dist/strand-solicitation.js.map +1 -1
- package/dist/strand-wake-protocol.d.ts +11 -7
- package/dist/strand-wake-protocol.js +20 -52
- package/dist/strand-wake-protocol.js.map +1 -1
- package/dist/strand-watcher.js +6 -0
- package/dist/strand-watcher.js.map +1 -1
- package/dist/timed-step.d.ts +12 -0
- package/dist/timed-step.js +28 -0
- package/dist/timed-step.js.map +1 -0
- package/dist/timeout-scheduler.d.ts +19 -0
- package/dist/timeout-scheduler.js +22 -0
- package/dist/timeout-scheduler.js.map +1 -0
- package/dist/types.d.ts +262 -30
- package/dist/types.js.map +1 -1
- package/package.json +8 -8
- package/src/bootstrap-peer-store-file.ts +2 -2
- package/src/bootstrap-peer-store.ts +69 -27
- package/src/cadre-node.ts +7301 -6353
- package/src/control-authorization.ts +2 -1
- package/src/control-cohort.ts +122 -130
- package/src/control-database.ts +537 -69
- package/src/control-read-retry.ts +202 -167
- package/src/control-retry.ts +297 -190
- package/src/control-schema.ts +103 -19
- package/src/control-write-retry.ts +533 -383
- package/src/enrolled-machine-store.ts +2 -2
- package/src/index.ts +83 -6
- package/src/node-local-snapshot.ts +25 -8
- package/src/peer-dial.ts +215 -0
- package/src/relay-addrs.ts +458 -436
- package/src/relay-reservation.ts +951 -828
- package/src/seed-bootstrap.ts +76 -18
- package/src/storage-scope.ts +78 -0
- package/src/strand-database.ts +50 -27
- package/src/strand-first-sync-gate.ts +258 -0
- package/src/strand-formation-manager.ts +140 -5
- package/src/strand-formation-protocol.ts +43 -1
- package/src/strand-instance-manager.ts +577 -37
- package/src/strand-member-key.ts +20 -12
- package/src/strand-member-registry.ts +3 -0
- package/src/strand-membership-reconciler.ts +680 -0
- package/src/strand-membership-writer.ts +527 -189
- package/src/strand-network-config.ts +102 -24
- package/src/strand-solicitation.ts +16 -1
- package/src/strand-wake-protocol.ts +21 -66
- package/src/strand-watcher.ts +6 -0
- package/src/timed-step.ts +28 -0
- package/src/timeout-scheduler.ts +28 -0
- package/src/types.ts +1789 -1554
package/src/strand-member-key.ts
CHANGED
|
@@ -5,11 +5,16 @@ import { ed25519KeyPairFromLibp2p, type Ed25519KeyPair } from './ed25519-key.js'
|
|
|
5
5
|
/**
|
|
6
6
|
* Mint a fresh ed25519 strand member private key, encoded as base64 protobuf.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
8
|
+
* Used for BOTH closed-strand key roles, which share this encoding but are
|
|
9
|
+
* deliberately different keys:
|
|
10
|
+
* - the strand-wide read secret (`Strand.MemberPrivateKey`), which formation
|
|
11
|
+
* hands to every joining party — the SAME encoding
|
|
12
|
+
* {@link StrandSolicitationService.formStrand} uses for its `invitePrivateKey`,
|
|
13
|
+
* so a host-minted key and a formation-issued key are interchangeable when
|
|
14
|
+
* attaching a closed strand;
|
|
15
|
+
* - a single party's own membership identity (the control-layer `StrandPartyKey`
|
|
16
|
+
* row, minted by `CadreNode.ensureStrandPartyKey`), never shared outside the
|
|
17
|
+
* party.
|
|
13
18
|
*/
|
|
14
19
|
export async function generateStrandMemberKey(): Promise<string> {
|
|
15
20
|
const privateKey = await generateKeyPair('Ed25519');
|
|
@@ -17,20 +22,23 @@ export async function generateStrandMemberKey(): Promise<string> {
|
|
|
17
22
|
}
|
|
18
23
|
|
|
19
24
|
/**
|
|
20
|
-
* Bridge a strand
|
|
25
|
+
* Bridge a strand membership private key (base64 protobuf libp2p ed25519 key, as
|
|
21
26
|
* minted by {@link generateStrandMemberKey} or issued by formation) into the
|
|
22
27
|
* base64url keypair the strand RBAC constraints consume.
|
|
23
28
|
*
|
|
24
|
-
* The
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
29
|
+
* The founding `Member.Key`/`Manager.MemberKey` (the strand RBAC layer) are the
|
|
30
|
+
* `publicKeyB64` of the keypair this returns, derived from the PARTY's own
|
|
31
|
+
* `StrandPartyKey.PrivateKey` — deliberately NOT from the strand row's
|
|
32
|
+
* `MemberPrivateKey`, which is the strand-wide read secret every joining party
|
|
33
|
+
* receives (an identity derived from it is one every joiner can forge —
|
|
34
|
+
* gotchoices/sereus#4). Both keys share this encoding, so this decoder serves
|
|
35
|
+
* either. Decode the protobuf to a libp2p private key, then reuse
|
|
28
36
|
* {@link ed25519KeyPairFromLibp2p} so the same seed→public derivation used for node
|
|
29
37
|
* owner keys yields a stable `{ privateKeyB64, publicKeyB64 }` whose public
|
|
30
38
|
* key a later strand signature verifies against.
|
|
31
39
|
*
|
|
32
|
-
* @param memberPrivateKey -
|
|
33
|
-
* @returns The base64url seed/public-key pair for
|
|
40
|
+
* @param memberPrivateKey - A strand membership private key (base64 protobuf).
|
|
41
|
+
* @returns The base64url seed/public-key pair for strand membership signing.
|
|
34
42
|
* @throws If the decoded key is not Ed25519 or the raw bytes are malformed.
|
|
35
43
|
*/
|
|
36
44
|
export function strandMemberKeyPair(memberPrivateKey: string): Ed25519KeyPair {
|
|
@@ -148,6 +148,9 @@ export class StrandMemberRegistry implements MemberRegistry {
|
|
|
148
148
|
);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
+
// NOTE: both writers run in default (joining) mode. Nothing in cadre-core wires this
|
|
152
|
+
// registry to a live strand today; if a network handler ever drives it on a database
|
|
153
|
+
// the app also holds, pass `{ joinOpenTransaction: false }` as the reconciler does.
|
|
151
154
|
if (this.admission.mode === 'invite') {
|
|
152
155
|
await consumeInvite(this.db, {
|
|
153
156
|
inviteKey: this.admission.inviteKey,
|