@serfab/cadre-core 1.5.0 → 1.7.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-node.d.ts +206 -67
- package/dist/cadre-node.js +399 -98
- package/dist/cadre-node.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/dist/joined-strand-store.d.ts +112 -0
- package/dist/joined-strand-store.js +263 -0
- package/dist/joined-strand-store.js.map +1 -0
- package/dist/key-store.d.ts +6 -0
- package/dist/key-store.js.map +1 -1
- package/dist/link-budget.d.ts +95 -53
- package/dist/link-budget.js +97 -53
- package/dist/link-budget.js.map +1 -1
- package/dist/node-local-snapshot.d.ts +5 -4
- package/dist/node-local-snapshot.js +6 -3
- package/dist/node-local-snapshot.js.map +1 -1
- package/dist/peer-dial.d.ts +3 -3
- package/dist/peer-dial.js +3 -3
- package/dist/peer-join-backfill.d.ts +35 -16
- package/dist/peer-join-backfill.js +117 -57
- package/dist/peer-join-backfill.js.map +1 -1
- package/dist/relay-reservation.d.ts +2 -2
- package/dist/relay-reservation.js +2 -2
- package/dist/seed-bootstrap.js +1 -1
- package/dist/strand-first-sync-gate.d.ts +88 -43
- package/dist/strand-first-sync-gate.js +92 -46
- package/dist/strand-first-sync-gate.js.map +1 -1
- package/dist/strand-instance-manager.d.ts +39 -0
- package/dist/strand-instance-manager.js +80 -3
- package/dist/strand-instance-manager.js.map +1 -1
- package/dist/strand-peer-book-file.d.ts +12 -0
- package/dist/strand-peer-book-file.js +37 -0
- package/dist/strand-peer-book-file.js.map +1 -0
- package/dist/strand-peer-book-protocol.d.ts +159 -0
- package/dist/strand-peer-book-protocol.js +360 -0
- package/dist/strand-peer-book-protocol.js.map +1 -0
- package/dist/strand-peer-book-swap.d.ts +104 -0
- package/dist/strand-peer-book-swap.js +284 -0
- package/dist/strand-peer-book-swap.js.map +1 -0
- package/dist/strand-peer-book.d.ts +159 -0
- package/dist/strand-peer-book.js +354 -0
- package/dist/strand-peer-book.js.map +1 -0
- package/dist/strand-peer-observer.d.ts +88 -0
- package/dist/strand-peer-observer.js +180 -0
- package/dist/strand-peer-observer.js.map +1 -0
- package/dist/types.d.ts +84 -17
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -1
- package/package.json +11 -7
- package/src/cadre-node.ts +7776 -7445
- package/src/index.ts +68 -0
- package/src/joined-strand-store.ts +308 -0
- package/src/key-store.ts +6 -0
- package/src/link-budget.ts +100 -53
- package/src/node-local-snapshot.ts +293 -289
- package/src/peer-dial.ts +3 -3
- package/src/peer-join-backfill.ts +709 -647
- package/src/relay-reservation.ts +2 -2
- package/src/seed-bootstrap.ts +1 -1
- package/src/strand-first-sync-gate.ts +352 -306
- package/src/strand-instance-manager.ts +106 -3
- package/src/strand-peer-book-file.ts +39 -0
- package/src/strand-peer-book-protocol.ts +463 -0
- package/src/strand-peer-book-swap.ts +338 -0
- package/src/strand-peer-book.ts +468 -0
- package/src/strand-peer-observer.ts +235 -0
- package/src/types.ts +86 -17
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,11 @@ export { MemoryTrustedOwnerStore, PersistentTrustedOwnerStore, type TrustedOwner
|
|
|
13
13
|
export type { DurableSlot } from './node-local-snapshot.js';
|
|
14
14
|
export { MemoryBootstrapPeerStore, PersistentBootstrapPeerStore, type BootstrapPeerStore, type BootstrapPeerEntry } from './bootstrap-peer-store.js';
|
|
15
15
|
export { MemoryEnrolledMachineStore, PersistentEnrolledMachineStore, type EnrolledMachineStore } from './enrolled-machine-store.js';
|
|
16
|
+
export { MemoryJoinedStrandStore, KeyStoreJoinedStrandStore, type JoinedStrandStore, type JoinedStrandRecord } from './joined-strand-store.js';
|
|
17
|
+
export { MemoryStrandPeerBookStore, PersistentStrandPeerBookStore, mergeStrandPeerEntry, sanitizeStrandPeerEntry, strandPeerFreshness, MAX_STRAND_PEERS, STRAND_PEER_MAX_AGE_MS, type StrandPeerBookStore, type StrandPeerBookOptions, type StrandPeerEntry } from './strand-peer-book.js';
|
|
18
|
+
export { StrandPeerObserver, dialableAddrs, connectedIdentifiedPeers, STRAND_PEER_OBSERVE_THROTTLE_MS, type StrandPeerObservation, type StrandPeerObserverDeps, type StrandPeerObserverOptions, type ConnectedIdentifiedPeer } from './strand-peer-observer.js';
|
|
19
|
+
export { STRAND_PEER_BOOK_PROTOCOL, SIGNED_STRAND_PEER_ENTRY_VERSION, STRAND_PEER_ISSUED_AT_SKEW_MS, MAX_BOOK_FRAME_SIZE, StrandPeerBookService, exchangeStrandPeerBook, signStrandPeerEntry, signedStrandPeerEntryPayload, verifySignedStrandPeerEntry, verifyStrandPeerBookFrame, trimBookFrameToFit, assertBookFrameFits, type SignedStrandPeerEntry, type StrandPeerBookFrame, type StrandPeerEntryVerdict, type StrandPeerBookServiceDeps, type ExchangeStrandPeerBookOptions } from './strand-peer-book-protocol.js';
|
|
20
|
+
export { StrandPeerBookSwap, STRAND_PEER_BOOK_SWAP_THROTTLE_MS, OWN_ENTRY_RESIGN_DEBOUNCE_MS, type StrandPeerBookSwapDeps, type StrandPeerBookSwapOptions } from './strand-peer-book-swap.js';
|
|
16
21
|
export { controlStorageScope, isControlStorageScope, isValidStrandScopeKey, assertStrandScopeKey, InvalidStrandIdError } from './storage-scope.js';
|
|
17
22
|
export { StrandDatabase, type StrandDatabaseConfig } from './strand-database.js';
|
|
18
23
|
export { StrandWatcher, type StrandWatcherCallbacks, type StrandQueryable, type SAppIdLookup, type StrandRowWithApp } from './strand-watcher.js';
|
|
@@ -44,7 +49,7 @@ export { validatePushCredentials, redactPushCredentials, REDACTED } from './push
|
|
|
44
49
|
export { PushFanoutService, DEFAULT_PUSH_COOLDOWN_MS, DEFAULT_PUSH_DEBOUNCE_MS, type PushFanoutOptions, type FanoutMember } from './push-fanout.js';
|
|
45
50
|
export { selectControlCohortDials, DEFAULT_CONTROL_COHORT_RECONCILE_MS, DEFAULT_CONTROL_COHORT_TARGET_DEGREE, type ControlCohortSelection, type ControlCohortReconcileResult } from './control-cohort.js';
|
|
46
51
|
export { dialPeerAddrs, tryAddrsInTurn, directBeforeRelayed, DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS, DEFAULT_CONTROL_COHORT_PER_ADDRESS_DIAL_TIMEOUT_MS, CONTROL_COHORT_DIAL_ADDRESS_ATTEMPTS, DEFAULT_PEER_DIAL_BUDGET, type PeerDialBudget, type AddrDialer } from './peer-dial.js';
|
|
47
|
-
export { DECLARED_LINK_ROUND_TRIP_MS, RELAYED_DIAL_ROUND_TRIPS, RELAY_RESERVATION_ROUND_TRIPS, CIRCUIT_REQUEST_ROUND_TRIPS, PUSH_TRANSFER_ALLOWANCE_MS, resolveLinkRoundTripMs, relayedDialBudgetMs, relayReservationBudgetMs, circuitRequestBudgetMs, peerJoinPushBudget, type PeerJoinPushBudget } from './link-budget.js';
|
|
52
|
+
export { DECLARED_LINK_ROUND_TRIP_MS, RELAYED_DIAL_ROUND_TRIPS, RELAY_RESERVATION_ROUND_TRIPS, CIRCUIT_REQUEST_ROUND_TRIPS, PUSH_TRANSFER_ALLOWANCE_MS, resolveLinkRoundTripMs, relayedDialBudgetMs, connectionManagerTimeouts, relayReservationBudgetMs, circuitRequestBudgetMs, peerJoinPushBudget, type PeerJoinPushBudget } from './link-budget.js';
|
|
48
53
|
export { anchoredTrustPolicy, pinnedKeyTrustPolicy, tofuTrustPolicy, type SeedTrustPolicy, type SeedTrustContext, type SeedTrustDecision } from './seed-trust-policy.js';
|
|
49
54
|
export { signSchema, verifySchema, assertSchemaSignature, SchemaVerificationError } from './schema-verification.js';
|
|
50
55
|
export { FormationListener, dialFormation, isValidResponderCreatesResult, isWellFormedMembershipInvite, sanitizeStrandAddrs, FORMATION_PROTOCOL, type FormationParty, type FormationContactMessage, type FormationResultMessage, type FormationProvisionResult, type FormationStrandInfo, type FormationDbConnectionInfo, type FormationListenerOptions, type FormationDialOptions, type FormationDialResult, type ResponderProvisionOutcome } from './strand-formation-protocol.js';
|
package/dist/index.js
CHANGED
|
@@ -49,6 +49,22 @@ export { MemoryBootstrapPeerStore, PersistentBootstrapPeerStore } from './bootst
|
|
|
49
49
|
// DIVERGES from theirs (an unreadable slot cold-starts rather than throwing) —
|
|
50
50
|
// see the module comment before unifying the three.
|
|
51
51
|
export { MemoryEnrolledMachineStore, PersistentEnrolledMachineStore } from './enrolled-machine-store.js';
|
|
52
|
+
// Node-local record of the strands this node joined from ANOTHER party, re-offered on
|
|
53
|
+
// every start as `strand:discovered`. Cross-platform: its durable form rides the
|
|
54
|
+
// KeyStore seam above (the record carries a closed strand's read secret), so there is
|
|
55
|
+
// no file-backed subpath.
|
|
56
|
+
export { MemoryJoinedStrandStore, KeyStoreJoinedStrandStore } from './joined-strand-store.js';
|
|
57
|
+
// Node-local strand peer book: per strand, the strand peers this node has met and
|
|
58
|
+
// their last-known addresses, dialed first on every launch so a restarted machine
|
|
59
|
+
// re-finds the other parties. Same cross-platform split as the bootstrap-peer store
|
|
60
|
+
// above — interface + in-memory + slot-backed stores here, Node-only file backend
|
|
61
|
+
// behind the subpath '@serfab/cadre-core/strand-peer-book-file'.
|
|
62
|
+
export { MemoryStrandPeerBookStore, PersistentStrandPeerBookStore, mergeStrandPeerEntry, sanitizeStrandPeerEntry, strandPeerFreshness, MAX_STRAND_PEERS, STRAND_PEER_MAX_AGE_MS } from './strand-peer-book.js';
|
|
63
|
+
export { StrandPeerObserver, dialableAddrs, connectedIdentifiedPeers, STRAND_PEER_OBSERVE_THROTTLE_MS } from './strand-peer-observer.js';
|
|
64
|
+
// The signed book SWAP between strand peers (`/sereus/strand-peers/1.0.0`): the wire
|
|
65
|
+
// protocol, signing and verification, and the per-strand driver that arms it.
|
|
66
|
+
export { STRAND_PEER_BOOK_PROTOCOL, SIGNED_STRAND_PEER_ENTRY_VERSION, STRAND_PEER_ISSUED_AT_SKEW_MS, MAX_BOOK_FRAME_SIZE, StrandPeerBookService, exchangeStrandPeerBook, signStrandPeerEntry, signedStrandPeerEntryPayload, verifySignedStrandPeerEntry, verifyStrandPeerBookFrame, trimBookFrameToFit, assertBookFrameFits } from './strand-peer-book-protocol.js';
|
|
67
|
+
export { StrandPeerBookSwap, STRAND_PEER_BOOK_SWAP_THROTTLE_MS, OWN_ENTRY_RESIGN_DEBOUNCE_MS } from './strand-peer-book-swap.js';
|
|
52
68
|
// Storage scope keys — what `CadreNodeConfig.storage.provider` is called with. A
|
|
53
69
|
// strand's key is its strand id; the control database's key carries the party id,
|
|
54
70
|
// so two parties on one device never share a control store. Every key stays within
|
|
@@ -139,7 +155,7 @@ export { selectControlCohortDials, DEFAULT_CONTROL_COHORT_RECONCILE_MS, DEFAULT_
|
|
|
139
155
|
export { dialPeerAddrs, tryAddrsInTurn, directBeforeRelayed, DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS, DEFAULT_CONTROL_COHORT_PER_ADDRESS_DIAL_TIMEOUT_MS, CONTROL_COHORT_DIAL_ADDRESS_ATTEMPTS, DEFAULT_PEER_DIAL_BUDGET } from './peer-dial.js';
|
|
140
156
|
// Dial and reservation budgets counted in link round trips rather than fixed milliseconds, so
|
|
141
157
|
// one declared assumption about the link moves them all — see `NetworkConfig.linkRoundTripMs`.
|
|
142
|
-
export { DECLARED_LINK_ROUND_TRIP_MS, RELAYED_DIAL_ROUND_TRIPS, RELAY_RESERVATION_ROUND_TRIPS, CIRCUIT_REQUEST_ROUND_TRIPS, PUSH_TRANSFER_ALLOWANCE_MS, resolveLinkRoundTripMs, relayedDialBudgetMs, relayReservationBudgetMs, circuitRequestBudgetMs, peerJoinPushBudget } from './link-budget.js';
|
|
158
|
+
export { DECLARED_LINK_ROUND_TRIP_MS, RELAYED_DIAL_ROUND_TRIPS, RELAY_RESERVATION_ROUND_TRIPS, CIRCUIT_REQUEST_ROUND_TRIPS, PUSH_TRANSFER_ALLOWANCE_MS, resolveLinkRoundTripMs, relayedDialBudgetMs, connectionManagerTimeouts, relayReservationBudgetMs, circuitRequestBudgetMs, peerJoinPushBudget } from './link-budget.js';
|
|
143
159
|
// Seed trust policy (trust anchor for incoming seeds)
|
|
144
160
|
export { anchoredTrustPolicy, pinnedKeyTrustPolicy, tofuTrustPolicy } from './seed-trust-policy.js';
|
|
145
161
|
// Schema Verification
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,cAAc,YAAY,CAAC;AAE3B,+DAA+D;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,uBAAuB;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,mBAAmB;AACnB,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,eAAe,EAAwO,MAAM,uBAAuB,CAAC;AAElZ,+EAA+E;AAC/E,qFAAqF;AACrF,yCAAyC;AACzC,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,oBAAoB,EACpB,wBAAwB,EACxB,8BAA8B,EAC9B,4BAA4B,EAC5B,iBAAiB,EAElB,MAAM,0BAA0B,CAAC;AAElC,gFAAgF;AAChF,yFAAyF;AACzF,OAAO,EACL,qBAAqB,EACrB,4BAA4B,EAC5B,4BAA4B,EAC5B,6BAA6B,EAC7B,gBAAgB,EAEjB,MAAM,yBAAyB,CAAC;AAWjC,2FAA2F;AAC3F,OAAO,EAAE,0BAA0B,EAA0C,MAAM,4BAA4B,CAAC;AAEhH,2DAA2D;AAC3D,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,0BAA0B,EAAuB,MAAM,kBAAkB,CAAC;AAE1I,2EAA2E;AAC3E,gFAAgF;AAChF,8EAA8E;AAC9E,+EAA+E;AAC/E,2BAA2B;AAC3B,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EAGxB,MAAM,gBAAgB,CAAC;AAEx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
import type { KeyStore } from './key-store.js';
|
|
2
|
+
import type { StrandRow } from './types.js';
|
|
3
|
+
/** One strand this node joined from ANOTHER party — nothing in this party's control DB names it. */
|
|
4
|
+
export interface JoinedStrandRecord {
|
|
5
|
+
/** The strand id (a valid scope key, see storage-scope.ts). */
|
|
6
|
+
Id: string;
|
|
7
|
+
Type: 'o' | 'c';
|
|
8
|
+
/** The closed strand's shared read secret the formation delivered; null for an open strand. */
|
|
9
|
+
MemberPrivateKey: string | null;
|
|
10
|
+
/** Wall-clock ms this node first recorded the join. Diagnostics only. */
|
|
11
|
+
joinedAt: number;
|
|
12
|
+
}
|
|
13
|
+
export interface JoinedStrandStore {
|
|
14
|
+
/** Party this store is scoped to. */
|
|
15
|
+
readonly partyId: string;
|
|
16
|
+
/** Every remembered join. A call reflects every {@link record}/{@link forget} that resolved before it was made. */
|
|
17
|
+
list(): Promise<JoinedStrandRecord[]>;
|
|
18
|
+
/** Remember a join, REPLACING any record with the same `Id`. */
|
|
19
|
+
record(record: JoinedStrandRecord): Promise<void>;
|
|
20
|
+
/** Forget a join. A no-op when there is no record for `strandId`. */
|
|
21
|
+
forget(strandId: string): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The {@link StrandRow} a record stands for — the shape `addStrand` and `strand:discovered`
|
|
25
|
+
* carry. `FounderOwnerKey` is null because a joiner never founds; `CadreNode.launchStrand`
|
|
26
|
+
* reads null as "not mine" and joins.
|
|
27
|
+
*/
|
|
28
|
+
export declare function joinedStrandRow(record: JoinedStrandRecord): StrandRow;
|
|
29
|
+
/**
|
|
30
|
+
* Ephemeral store for a node without a `keyStore`. Warns once, at the first join it is
|
|
31
|
+
* asked to remember, because a join held only here is not re-offered after a restart —
|
|
32
|
+
* exactly the gotchoices/sereus#18 shape, and it should show in a log rather than pass
|
|
33
|
+
* silently.
|
|
34
|
+
*/
|
|
35
|
+
export declare class MemoryJoinedStrandStore implements JoinedStrandStore {
|
|
36
|
+
readonly partyId: string;
|
|
37
|
+
private readonly records;
|
|
38
|
+
private warned;
|
|
39
|
+
constructor(partyId: string);
|
|
40
|
+
list(): Promise<JoinedStrandRecord[]>;
|
|
41
|
+
record(record: JoinedStrandRecord): Promise<void>;
|
|
42
|
+
forget(strandId: string): Promise<void>;
|
|
43
|
+
private warnOnce;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Durable store over a {@link KeyStore}: one slot per join, id
|
|
47
|
+
* `cadre/joined-strand/<base64url party id>/<strand id>`, holding the record's UTF-8 JSON.
|
|
48
|
+
* The party segment is base64url for the reason `controlStorageScope` gives: a party id is
|
|
49
|
+
* arbitrary text, and base64url never contains the `/` that ends the segment.
|
|
50
|
+
*
|
|
51
|
+
* Loads every slot once, at the first {@link list}, then answers from memory and writes
|
|
52
|
+
* through, so the strand watcher's five-second poll does not read the enclave on every
|
|
53
|
+
* pass. A load that fails — `KeyStoreAccessError` from a refused unlock prompt, say —
|
|
54
|
+
* is rethrown rather than read as "no joins" and retried at the next call, exactly as
|
|
55
|
+
* `loadOrCreateIdentityKey` treats the identity slot. A slot that does not parse as a
|
|
56
|
+
* record for its own id is dropped with a log and its siblings kept: refusing to start
|
|
57
|
+
* repairs nothing, and the other joins are still good.
|
|
58
|
+
*/
|
|
59
|
+
export declare class KeyStoreJoinedStrandStore implements JoinedStrandStore {
|
|
60
|
+
private readonly keyStore;
|
|
61
|
+
readonly partyId: string;
|
|
62
|
+
private readonly slotPrefix;
|
|
63
|
+
/** The loaded records; null until a load succeeds. */
|
|
64
|
+
private records;
|
|
65
|
+
/** Runs every KeyStore access in call order, so a load never interleaves with a write. */
|
|
66
|
+
private queue;
|
|
67
|
+
constructor(keyStore: KeyStore, partyId: string);
|
|
68
|
+
list(): Promise<JoinedStrandRecord[]>;
|
|
69
|
+
/** Throws `InvalidStrandIdError` for an id that could never load back, before anything is written. */
|
|
70
|
+
record(record: JoinedStrandRecord): Promise<void>;
|
|
71
|
+
forget(strandId: string): Promise<void>;
|
|
72
|
+
private slotId;
|
|
73
|
+
private inOrder;
|
|
74
|
+
private loaded;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* What the strand watcher sees of the joined-strand store: the control rows plus one row per
|
|
78
|
+
* remembered join, which is how a join comes back as `strand:discovered` (or auto-launches)
|
|
79
|
+
* after a restart with no second offer path. One instance per node session.
|
|
80
|
+
*
|
|
81
|
+
* Holds the two pieces of state a plain union would get wrong, both of which would otherwise
|
|
82
|
+
* make the watcher detach running strands, since a joined row missing from a poll reads to it
|
|
83
|
+
* as a removal:
|
|
84
|
+
* - the last list the store answered, reused when a later list fails, so a read failure is
|
|
85
|
+
* not "every join was forgotten";
|
|
86
|
+
* - joins forgotten because this party was removed from the strand
|
|
87
|
+
* ({@link forgetAfterThisSession}): gone from the store, so the next start does not
|
|
88
|
+
* re-attach them, but still offered until this session ends, because `strand:revoked`
|
|
89
|
+
* promises that nothing is torn down for the app.
|
|
90
|
+
*/
|
|
91
|
+
export declare class JoinedStrandRows {
|
|
92
|
+
private readonly store;
|
|
93
|
+
private lastListed;
|
|
94
|
+
private readonly keptForSession;
|
|
95
|
+
constructor(store: JoinedStrandStore);
|
|
96
|
+
/**
|
|
97
|
+
* `control` plus a row for every remembered join. A control row wins an id collision: the
|
|
98
|
+
* strand is this party's own now (its founding party enrolled this machine, say), the
|
|
99
|
+
* control database remembers it, and the record is stale — so it is forgotten here.
|
|
100
|
+
*/
|
|
101
|
+
withControlRows(control: readonly StrandRow[]): Promise<StrandRow[]>;
|
|
102
|
+
/** Forget a join for good: the app is leaving the strand. */
|
|
103
|
+
forget(strandId: string): Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* Forget a join durably, but keep offering it until this session ends. For a strand this
|
|
106
|
+
* party was removed from: it must not re-attach on every launch, and it must not be torn
|
|
107
|
+
* down underneath the app either. A no-op for a strand with no record.
|
|
108
|
+
*/
|
|
109
|
+
forgetAfterThisSession(strandId: string): Promise<void>;
|
|
110
|
+
private listed;
|
|
111
|
+
private forgetSuperseded;
|
|
112
|
+
}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node-local record of the strands this node joined from ANOTHER party.
|
|
3
|
+
*
|
|
4
|
+
* A party's own strands come back after a restart through its control database: the
|
|
5
|
+
* `Strand` table holds their rows, the strand watcher polls it, and each row no sApp
|
|
6
|
+
* config claims is offered as `strand:discovered`. A strand joined through formation with
|
|
7
|
+
* another party (`CadreNode.formStrand`) has no row there — the other party's control
|
|
8
|
+
* database holds it — so nothing re-offered it after a restart, and every embedding app
|
|
9
|
+
* kept its own list of joins, read secret included (gotchoices/sereus#18).
|
|
10
|
+
*
|
|
11
|
+
* `CadreNode` records each such join here, hands the records to its strand watcher beside
|
|
12
|
+
* the control rows ({@link JoinedStrandRows}), and forgets one on `forgetJoinedStrand` or
|
|
13
|
+
* when this party is removed from the strand.
|
|
14
|
+
*
|
|
15
|
+
* Two implementations:
|
|
16
|
+
* - {@link MemoryJoinedStrandStore} — joins die with the process. The default only for a
|
|
17
|
+
* node configured with no `keyStore`.
|
|
18
|
+
* - {@link KeyStoreJoinedStrandStore} — one {@link KeyStore} slot per join. A record holds
|
|
19
|
+
* the closed strand's shared read secret, and the KeyStore is the one seam every
|
|
20
|
+
* platform already routes secrets through (the platform enclave on React Native, the
|
|
21
|
+
* state directory for `FileKeyStore`), so the record goes there rather than into a
|
|
22
|
+
* `DurableSlot` like the bootstrap-peer store.
|
|
23
|
+
*
|
|
24
|
+
* Party-scoped like every other node-local store, because one KeyStore can serve several
|
|
25
|
+
* parties: the React Native app keeps one per device and lets the user switch party. A
|
|
26
|
+
* join made for one party must never be offered to a node started for another.
|
|
27
|
+
*
|
|
28
|
+
* Dependency-free beyond the KeyStore seam, so safe in every entry graph.
|
|
29
|
+
*/
|
|
30
|
+
import debug from 'debug';
|
|
31
|
+
import { toString as uint8ArrayToString, fromString as uint8ArrayFromString } from 'uint8arrays';
|
|
32
|
+
import { assertStrandScopeKey, isValidStrandScopeKey } from './storage-scope.js';
|
|
33
|
+
const log = debug('sereus:cadre:joined-strand-store');
|
|
34
|
+
/**
|
|
35
|
+
* The {@link StrandRow} a record stands for — the shape `addStrand` and `strand:discovered`
|
|
36
|
+
* carry. `FounderOwnerKey` is null because a joiner never founds; `CadreNode.launchStrand`
|
|
37
|
+
* reads null as "not mine" and joins.
|
|
38
|
+
*/
|
|
39
|
+
export function joinedStrandRow(record) {
|
|
40
|
+
return { Id: record.Id, Type: record.Type, MemberPrivateKey: record.MemberPrivateKey, FounderOwnerKey: null };
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Ephemeral store for a node without a `keyStore`. Warns once, at the first join it is
|
|
44
|
+
* asked to remember, because a join held only here is not re-offered after a restart —
|
|
45
|
+
* exactly the gotchoices/sereus#18 shape, and it should show in a log rather than pass
|
|
46
|
+
* silently.
|
|
47
|
+
*/
|
|
48
|
+
export class MemoryJoinedStrandStore {
|
|
49
|
+
constructor(partyId) {
|
|
50
|
+
this.partyId = partyId;
|
|
51
|
+
this.records = new Map();
|
|
52
|
+
this.warned = false;
|
|
53
|
+
}
|
|
54
|
+
async list() {
|
|
55
|
+
return [...this.records.values()];
|
|
56
|
+
}
|
|
57
|
+
async record(record) {
|
|
58
|
+
this.warnOnce();
|
|
59
|
+
this.records.set(record.Id, { ...record });
|
|
60
|
+
}
|
|
61
|
+
async forget(strandId) {
|
|
62
|
+
this.records.delete(strandId);
|
|
63
|
+
}
|
|
64
|
+
warnOnce() {
|
|
65
|
+
if (this.warned) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
this.warned = true;
|
|
69
|
+
console.warn('CadreNode has no keyStore and no joinedStrands.store, so strands joined from another party ' +
|
|
70
|
+
'are remembered in memory only and will NOT be re-offered after a restart. Configure a keyStore, ' +
|
|
71
|
+
'or inject joinedStrands: { store: new KeyStoreJoinedStrandStore(<a durable KeyStore>, partyId) }.');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** Slot id prefix for every joined-strand record; the party segment and the strand id follow. */
|
|
75
|
+
const SLOT_PREFIX = 'cadre/joined-strand/';
|
|
76
|
+
/**
|
|
77
|
+
* Durable store over a {@link KeyStore}: one slot per join, id
|
|
78
|
+
* `cadre/joined-strand/<base64url party id>/<strand id>`, holding the record's UTF-8 JSON.
|
|
79
|
+
* The party segment is base64url for the reason `controlStorageScope` gives: a party id is
|
|
80
|
+
* arbitrary text, and base64url never contains the `/` that ends the segment.
|
|
81
|
+
*
|
|
82
|
+
* Loads every slot once, at the first {@link list}, then answers from memory and writes
|
|
83
|
+
* through, so the strand watcher's five-second poll does not read the enclave on every
|
|
84
|
+
* pass. A load that fails — `KeyStoreAccessError` from a refused unlock prompt, say —
|
|
85
|
+
* is rethrown rather than read as "no joins" and retried at the next call, exactly as
|
|
86
|
+
* `loadOrCreateIdentityKey` treats the identity slot. A slot that does not parse as a
|
|
87
|
+
* record for its own id is dropped with a log and its siblings kept: refusing to start
|
|
88
|
+
* repairs nothing, and the other joins are still good.
|
|
89
|
+
*/
|
|
90
|
+
export class KeyStoreJoinedStrandStore {
|
|
91
|
+
constructor(keyStore, partyId) {
|
|
92
|
+
this.keyStore = keyStore;
|
|
93
|
+
this.partyId = partyId;
|
|
94
|
+
/** The loaded records; null until a load succeeds. */
|
|
95
|
+
this.records = null;
|
|
96
|
+
/** Runs every KeyStore access in call order, so a load never interleaves with a write. */
|
|
97
|
+
this.queue = Promise.resolve();
|
|
98
|
+
this.slotPrefix = SLOT_PREFIX + uint8ArrayToString(uint8ArrayFromString(partyId, 'utf8'), 'base64url') + '/';
|
|
99
|
+
}
|
|
100
|
+
list() {
|
|
101
|
+
return this.inOrder(async () => [...(await this.loaded()).values()]);
|
|
102
|
+
}
|
|
103
|
+
/** Throws `InvalidStrandIdError` for an id that could never load back, before anything is written. */
|
|
104
|
+
record(record) {
|
|
105
|
+
assertStrandScopeKey(record.Id);
|
|
106
|
+
const stored = { ...record };
|
|
107
|
+
return this.inOrder(async () => {
|
|
108
|
+
await this.keyStore.set(this.slotId(record.Id), uint8ArrayFromString(JSON.stringify(stored), 'utf8'));
|
|
109
|
+
this.records?.set(record.Id, stored);
|
|
110
|
+
log('joined strand remembered (party=%s, strand=%s, type=%s)', this.partyId, record.Id, record.Type);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
forget(strandId) {
|
|
114
|
+
return this.inOrder(async () => {
|
|
115
|
+
await this.keyStore.delete(this.slotId(strandId));
|
|
116
|
+
this.records?.delete(strandId);
|
|
117
|
+
log('joined strand forgotten (party=%s, strand=%s)', this.partyId, strandId);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
slotId(strandId) {
|
|
121
|
+
return this.slotPrefix + strandId;
|
|
122
|
+
}
|
|
123
|
+
inOrder(op) {
|
|
124
|
+
const result = this.queue.then(op);
|
|
125
|
+
// The caller receives `result`, rejection included; the queue only needs to know it settled.
|
|
126
|
+
this.queue = result.catch(() => undefined);
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
// NOTE: a failed load is retried at the next list(), which is every strand-watcher poll;
|
|
130
|
+
// over a backend that gates reads behind an unlock prompt the user keeps declining, that
|
|
131
|
+
// is a prompt every five seconds. Every KeyStore shipped today is ungated for this reason
|
|
132
|
+
// (see `SecureStoreKeyStoreOptions.requireAuthentication`); if one is ever gated, back
|
|
133
|
+
// off the retry here.
|
|
134
|
+
async loaded() {
|
|
135
|
+
if (this.records) {
|
|
136
|
+
return this.records;
|
|
137
|
+
}
|
|
138
|
+
const records = new Map();
|
|
139
|
+
for (const slot of await this.keyStore.list()) {
|
|
140
|
+
if (!slot.startsWith(this.slotPrefix)) {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const strandId = slot.slice(this.slotPrefix.length);
|
|
144
|
+
const bytes = await this.keyStore.get(slot);
|
|
145
|
+
if (!bytes) {
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
const record = parseRecord(strandId, bytes);
|
|
149
|
+
if (record) {
|
|
150
|
+
records.set(strandId, record);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
this.records = records;
|
|
154
|
+
log('joined strands loaded (party=%s, count=%d)', this.partyId, records.size);
|
|
155
|
+
return records;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/** The record a slot holds, or undefined (logged) when it is not one for `strandId`. */
|
|
159
|
+
function parseRecord(strandId, bytes) {
|
|
160
|
+
let parsed;
|
|
161
|
+
try {
|
|
162
|
+
parsed = JSON.parse(uint8ArrayToString(bytes, 'utf8'));
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
log('dropping joined-strand slot for %s: not JSON (%o)', strandId, error);
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
const { Id, Type, MemberPrivateKey, joinedAt } = (typeof parsed === 'object' && parsed !== null ? parsed : {});
|
|
169
|
+
const valid = Id === strandId
|
|
170
|
+
&& isValidStrandScopeKey(strandId)
|
|
171
|
+
&& (Type === 'o' || Type === 'c')
|
|
172
|
+
&& (MemberPrivateKey === null || typeof MemberPrivateKey === 'string')
|
|
173
|
+
&& typeof joinedAt === 'number';
|
|
174
|
+
if (!valid) {
|
|
175
|
+
log('dropping joined-strand slot for %s: not a joined-strand record for that id', strandId);
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
return { Id: strandId, Type: Type, MemberPrivateKey: MemberPrivateKey, joinedAt: joinedAt };
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* What the strand watcher sees of the joined-strand store: the control rows plus one row per
|
|
182
|
+
* remembered join, which is how a join comes back as `strand:discovered` (or auto-launches)
|
|
183
|
+
* after a restart with no second offer path. One instance per node session.
|
|
184
|
+
*
|
|
185
|
+
* Holds the two pieces of state a plain union would get wrong, both of which would otherwise
|
|
186
|
+
* make the watcher detach running strands, since a joined row missing from a poll reads to it
|
|
187
|
+
* as a removal:
|
|
188
|
+
* - the last list the store answered, reused when a later list fails, so a read failure is
|
|
189
|
+
* not "every join was forgotten";
|
|
190
|
+
* - joins forgotten because this party was removed from the strand
|
|
191
|
+
* ({@link forgetAfterThisSession}): gone from the store, so the next start does not
|
|
192
|
+
* re-attach them, but still offered until this session ends, because `strand:revoked`
|
|
193
|
+
* promises that nothing is torn down for the app.
|
|
194
|
+
*/
|
|
195
|
+
export class JoinedStrandRows {
|
|
196
|
+
constructor(store) {
|
|
197
|
+
this.store = store;
|
|
198
|
+
this.lastListed = [];
|
|
199
|
+
this.keptForSession = new Map();
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* `control` plus a row for every remembered join. A control row wins an id collision: the
|
|
203
|
+
* strand is this party's own now (its founding party enrolled this machine, say), the
|
|
204
|
+
* control database remembers it, and the record is stale — so it is forgotten here.
|
|
205
|
+
*/
|
|
206
|
+
async withControlRows(control) {
|
|
207
|
+
const controlIds = new Set(control.map((row) => row.Id));
|
|
208
|
+
const joined = new Map(this.keptForSession);
|
|
209
|
+
for (const record of await this.listed()) {
|
|
210
|
+
joined.set(record.Id, record);
|
|
211
|
+
}
|
|
212
|
+
const rows = [...control];
|
|
213
|
+
for (const record of joined.values()) {
|
|
214
|
+
if (controlIds.has(record.Id)) {
|
|
215
|
+
await this.forgetSuperseded(record.Id);
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
rows.push(joinedStrandRow(record));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return rows;
|
|
222
|
+
}
|
|
223
|
+
/** Forget a join for good: the app is leaving the strand. */
|
|
224
|
+
async forget(strandId) {
|
|
225
|
+
this.keptForSession.delete(strandId);
|
|
226
|
+
await this.store.forget(strandId);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Forget a join durably, but keep offering it until this session ends. For a strand this
|
|
230
|
+
* party was removed from: it must not re-attach on every launch, and it must not be torn
|
|
231
|
+
* down underneath the app either. A no-op for a strand with no record.
|
|
232
|
+
*/
|
|
233
|
+
async forgetAfterThisSession(strandId) {
|
|
234
|
+
const record = (await this.listed()).find((listed) => listed.Id === strandId);
|
|
235
|
+
if (!record) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
// Kept BEFORE the store forgets, so no poll can list the store without it and union
|
|
239
|
+
// without the kept copy.
|
|
240
|
+
this.keptForSession.set(strandId, record);
|
|
241
|
+
await this.store.forget(strandId);
|
|
242
|
+
}
|
|
243
|
+
async listed() {
|
|
244
|
+
try {
|
|
245
|
+
this.lastListed = await this.store.list();
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
log('joined-strand store list failed; offering the last list it answered (%d join(s)): %o', this.lastListed.length, error);
|
|
249
|
+
}
|
|
250
|
+
return this.lastListed;
|
|
251
|
+
}
|
|
252
|
+
async forgetSuperseded(strandId) {
|
|
253
|
+
this.keptForSession.delete(strandId);
|
|
254
|
+
try {
|
|
255
|
+
await this.store.forget(strandId);
|
|
256
|
+
log('joined strand %s now has a control row — record forgotten', strandId);
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
log('forgetting superseded joined strand %s failed; the next poll retries: %o', strandId, error);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
//# sourceMappingURL=joined-strand-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"joined-strand-store.js","sourceRoot":"","sources":["../src/joined-strand-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEjG,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAGjF,MAAM,GAAG,GAAG,KAAK,CAAC,kCAAkC,CAAC,CAAC;AA2BtD;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,MAA0B;IACz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EY_ID: KeyId;
|
|
|
29
29
|
* Key material is raw bytes (e.g. libp2p protobuf-serialized private keys).
|
|
30
30
|
* Text-only backends encode/decode (base64) internally; byte-native backends
|
|
31
31
|
* (LevelDB) store as-is.
|
|
32
|
+
*
|
|
33
|
+
* Not only keys: `KeyStoreJoinedStrandStore` keeps one small UTF-8 JSON record
|
|
34
|
+
* (about 200 bytes, a closed strand's read secret among its fields) per strand
|
|
35
|
+
* this node joined from another party, under ids beginning
|
|
36
|
+
* `cadre/joined-strand/`. {@link list} therefore returns those ids too, and a
|
|
37
|
+
* backend must accept `/` in an id and values of that size.
|
|
32
38
|
*/
|
|
33
39
|
export interface KeyStore {
|
|
34
40
|
/** Resolves to the stored material, or undefined if the slot is empty. */
|
package/dist/key-store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key-store.js","sourceRoot":"","sources":["../src/key-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAU,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"key-store.js","sourceRoot":"","sources":["../src/key-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAU,gBAAgB,CAAC;AAgC/D;;;;;;;;;;GAUG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAG7C,YAAY,KAAY,EAAE,OAAe,EAAE,OAA6B;QACvE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,CAAC;CACD;AAED;;;;;;;;GAQG;AACH,MAAM,OAAO,gBAAgB;IAA7B;QACkB,UAAK,GAAG,IAAI,GAAG,EAAqB,CAAC;IAkBvD,CAAC;IAhBA,KAAK,CAAC,GAA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