@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
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
* row replicates into every peer's copy, so "is this key in `OwnerKey`?" can be
|
|
7
7
|
* made true by a stranger. This store is the anchor that CAN be trusted — a
|
|
8
8
|
* per-party, on-device record of owner keys established OUT OF BAND: founding
|
|
9
|
-
* the party (genesis self-trust), the pinned keys carried by the
|
|
10
|
-
* that enrolled this node,
|
|
11
|
-
*
|
|
9
|
+
* the party (genesis self-trust), the pinned keys carried by the cadre invitation
|
|
10
|
+
* that enrolled this node, an explicit operator pin, or the claim of a brand-new
|
|
11
|
+
* node by whoever holds its one-time claim secret. It is never written from
|
|
12
|
+
* replicated control state; that is the whole point.
|
|
12
13
|
*
|
|
13
14
|
* Three implementations:
|
|
14
15
|
* - {@link MemoryTrustedOwnerStore} (this module, cross-platform) — ephemeral;
|
|
@@ -23,8 +24,16 @@
|
|
|
23
24
|
* `@serfab/cadre-core/trusted-owner-store-file` (same isolation pattern as
|
|
24
25
|
* `key-store-file`) so `node:fs` never lands in the RN/browser entry graph.
|
|
25
26
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
27
|
+
* The anchor follows the replicated `OwnerKey` table along VERIFIABLE chains only
|
|
28
|
+
* (`CadreNode.syncOwnerAnchor`, `owner-anchor-sync.ts`): a key whose stored proof verifies
|
|
29
|
+
* against a key already anchored enters under source `chain`, and a key named by a
|
|
30
|
+
* tombstone whose stored signer is anchored leaves. The out-of-band entries are the base
|
|
31
|
+
* that derivation starts from; a replicated row can never seat itself here.
|
|
32
|
+
*
|
|
33
|
+
* Two callers remove keys: the claim-secret trust policy rolling back a claim whose
|
|
34
|
+
* persist failed (`claimSecretTrustPolicy` in `seed-trust-policy.ts`), and the anchor
|
|
35
|
+
* sync applying a verifiable `OwnerKey` tombstone or pruning a `chain` entry whose row
|
|
36
|
+
* is gone. Nothing else removes a key.
|
|
28
37
|
*/
|
|
29
38
|
import debug from 'debug';
|
|
30
39
|
import { NodeLocalSnapshot } from './node-local-snapshot.js';
|
|
@@ -45,15 +54,35 @@ export class MemoryTrustedOwnerStore {
|
|
|
45
54
|
all() {
|
|
46
55
|
return new Set(this.keys.keys());
|
|
47
56
|
}
|
|
57
|
+
sources() {
|
|
58
|
+
return new Map(this.keys);
|
|
59
|
+
}
|
|
48
60
|
async trust(ownerKey, source) {
|
|
49
|
-
if (this.keys.
|
|
61
|
+
if (!provenanceChanges(this.keys.get(ownerKey), source)) {
|
|
50
62
|
return;
|
|
51
63
|
}
|
|
52
64
|
this.keys.set(ownerKey, source);
|
|
53
65
|
log('trusted owner key anchored (party=%s, source=%s)', this.partyId, source);
|
|
54
66
|
}
|
|
67
|
+
async remove(ownerKey) {
|
|
68
|
+
if (this.keys.delete(ownerKey)) {
|
|
69
|
+
log('trusted owner key removed (party=%s)', this.partyId);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Does `trust(key, source)` write, given the key's current provenance (`undefined` when
|
|
75
|
+
* absent)? The one rule both backends share (see {@link TrustedOwnerStore.trust}): an absent
|
|
76
|
+
* key always lands; a `chain` entry is promoted by any out-of-band source; everything else
|
|
77
|
+
* keeps its original provenance.
|
|
78
|
+
*/
|
|
79
|
+
function provenanceChanges(current, source) {
|
|
80
|
+
return current === undefined || (current === 'chain' && source !== 'chain');
|
|
55
81
|
}
|
|
56
|
-
|
|
82
|
+
// Every TrustSource must be listed: under the discard-all policy below, one entry with a
|
|
83
|
+
// source this set does not know discards the WHOLE anchor on reload, so a node whose only
|
|
84
|
+
// owner was anchored by a claim would silently come back unclaimed.
|
|
85
|
+
const KNOWN_SOURCES = new Set(['genesis', 'invite', 'operator', 'claim', 'chain']);
|
|
57
86
|
/**
|
|
58
87
|
* What the anchor persists: `owners` maps ownerKey (base64url) -> provenance.
|
|
59
88
|
*
|
|
@@ -104,12 +133,15 @@ export class PersistentTrustedOwnerStore {
|
|
|
104
133
|
all() {
|
|
105
134
|
return this.snapshot.keySnapshot();
|
|
106
135
|
}
|
|
136
|
+
sources() {
|
|
137
|
+
return new Map(Array.from(this.snapshot.entrySnapshot(), ([key, entry]) => [key, entry.source]));
|
|
138
|
+
}
|
|
107
139
|
/**
|
|
108
140
|
* Anchor a key: visible via {@link has} / {@link all} synchronously, then the
|
|
109
141
|
* full snapshot is persisted (see `NodeLocalSnapshot.put`).
|
|
110
142
|
*/
|
|
111
143
|
trust(ownerKey, source) {
|
|
112
|
-
if (this.snapshot.
|
|
144
|
+
if (!provenanceChanges(this.snapshot.get(ownerKey)?.source, source)) {
|
|
113
145
|
// Idempotent: re-enrollment / restart re-seeding keeps the original
|
|
114
146
|
// provenance and skips the write entirely.
|
|
115
147
|
// NOTE: this resolves immediately rather than joining the write chain, so
|
|
@@ -122,5 +154,15 @@ export class PersistentTrustedOwnerStore {
|
|
|
122
154
|
log('trusted owner key anchored (party=%s, source=%s); persisting', this.partyId, source);
|
|
123
155
|
return this.snapshot.put(ownerKey, { source, trustedAt: Date.now() });
|
|
124
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Drop a key: gone from {@link has} / {@link all} synchronously, then the full
|
|
159
|
+
* snapshot is persisted (see `NodeLocalSnapshot.remove`).
|
|
160
|
+
*/
|
|
161
|
+
remove(ownerKey) {
|
|
162
|
+
if (this.snapshot.has(ownerKey)) {
|
|
163
|
+
log('trusted owner key removed (party=%s); persisting', this.partyId);
|
|
164
|
+
}
|
|
165
|
+
return this.snapshot.remove(ownerKey);
|
|
166
|
+
}
|
|
125
167
|
}
|
|
126
168
|
//# sourceMappingURL=trusted-owner-store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trusted-owner-store.js","sourceRoot":"","sources":["../src/trusted-owner-store.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"trusted-owner-store.js","sourceRoot":"","sources":["../src/trusted-owner-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAgD,MAAM,0BAA0B,CAAC;AAE3G,MAAM,GAAG,GAAG,KAAK,CAAC,kCAAkC,CAAC,CAAC;AAyDtD;;;;GAIG;AACH,MAAM,OAAO,uBAAuB;IAGnC,YAAqB,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;QAFnB,SAAI,GAAG,IAAI,GAAG,EAAuB,CAAC;IAEhB,CAAC;IAExC,GAAG,CAAC,QAAgB;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAED,GAAG;QACF,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAClC,CAAC;IAED,OAAO;QACN,OA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