@serfab/cadre-core 1.10.0 → 1.12.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 +0 -27
- package/dist/cadre-node.js +3 -94
- package/dist/cadre-node.js.map +1 -1
- package/dist/control-schema.js +1066 -1066
- package/dist/diagnostics/connection-path.d.ts +1 -18
- package/dist/diagnostics/connection-path.js +1 -20
- package/dist/diagnostics/connection-path.js.map +1 -1
- package/dist/identity-key.d.ts +0 -30
- package/dist/identity-key.js +7 -40
- package/dist/identity-key.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/dist/relay-stun.d.ts +24 -0
- package/dist/relay-stun.js +51 -0
- package/dist/relay-stun.js.map +1 -0
- package/dist/seed-bootstrap.js +4 -4
- package/dist/strand-instance-manager.d.ts +8 -0
- package/dist/strand-instance-manager.js +8 -1
- package/dist/strand-instance-manager.js.map +1 -1
- package/dist/strand-membership-writer.js +32 -32
- package/dist/strand-reactivity.d.ts +41 -0
- package/dist/strand-reactivity.js +41 -0
- package/dist/strand-reactivity.js.map +1 -0
- package/dist/types.d.ts +19 -0
- package/dist/types.js.map +1 -1
- package/package.json +7 -7
- package/src/cadre-node.ts +8655 -8753
- package/src/control-authorization.ts +117 -117
- package/src/control-cohort.ts +128 -128
- package/src/control-formation-recorder.ts +353 -353
- package/src/control-read-retry.ts +216 -216
- package/src/control-schema.ts +1078 -1078
- package/src/control-write-retry.ts +567 -567
- package/src/diagnostics/connection-path.ts +1 -29
- package/src/formation-approval.ts +610 -610
- package/src/hibernation-manager.ts +638 -638
- package/src/identity-key.ts +7 -62
- package/src/index.ts +648 -647
- package/src/invitation-bootstrap.ts +40 -40
- package/src/joined-strand-store.ts +498 -498
- package/src/link-budget.ts +684 -684
- package/src/membership-connection-gater.ts +570 -570
- package/src/node-local-snapshot.ts +298 -298
- package/src/peer-dial.ts +315 -315
- package/src/peer-join-backfill.ts +710 -710
- package/src/pending-join-runner.ts +735 -735
- package/src/relay-reservation.ts +1121 -1121
- package/src/relay-server.ts +98 -98
- package/src/relay-stun.ts +58 -0
- package/src/seed-bootstrap.ts +1448 -1448
- package/src/strand-addr-protocol.ts +547 -547
- package/src/strand-database.ts +287 -287
- package/src/strand-first-sync-gate.ts +391 -391
- package/src/strand-formation-deadlines.ts +227 -227
- package/src/strand-formation-manager.ts +725 -725
- package/src/strand-fret-addrs.ts +145 -145
- package/src/strand-instance-manager.ts +1804 -1789
- package/src/strand-membership-writer.ts +1974 -1974
- package/src/strand-network-state-file.ts +40 -40
- package/src/strand-network-state.ts +243 -243
- package/src/strand-reactivity.ts +53 -0
- package/src/strand-revocation-enforcer.ts +654 -654
- package/src/strand-solicitation.ts +532 -532
- package/src/strand-wake-protocol.ts +401 -401
- package/src/types.ts +2242 -2222
- package/dist/diagnostics/webrtc-turn-tracker.d.ts +0 -50
- package/dist/diagnostics/webrtc-turn-tracker.js +0 -196
- package/dist/diagnostics/webrtc-turn-tracker.js.map +0 -1
- package/src/diagnostics/webrtc-turn-tracker.ts +0 -222
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* multiaddr string alone — no I/O, no events, no stateful observer.
|
|
9
9
|
*/
|
|
10
10
|
export type ConnectionPathKind = 'relayed' | 'direct';
|
|
11
|
-
export type ConnectionTransport = 'circuit-relay' | 'webrtc' | 'webrtc-
|
|
11
|
+
export type ConnectionTransport = 'circuit-relay' | 'webrtc' | 'webrtc-direct' | 'websocket' | 'tcp' | 'unknown';
|
|
12
12
|
export interface ConnectionPath {
|
|
13
13
|
/** remotePeer.toString() */
|
|
14
14
|
peerId: string;
|
|
@@ -50,13 +50,6 @@ export interface ConnectionLike {
|
|
|
50
50
|
timeline?: {
|
|
51
51
|
open?: number;
|
|
52
52
|
};
|
|
53
|
-
/**
|
|
54
|
-
* Set externally (by {@link CadreNode}, from a {@link TurnRelayTracker}
|
|
55
|
-
* observation) when ICE selected a TURN relay candidate for this `/webrtc`
|
|
56
|
-
* session. `undefined` = unknown (the multiaddr alone cannot reveal it). Only
|
|
57
|
-
* honoured for the `webrtc` transport — see {@link classifyConnectionPath}.
|
|
58
|
-
*/
|
|
59
|
-
turnRelayed?: boolean;
|
|
60
53
|
}
|
|
61
54
|
export declare const DEFAULT_SETTLE_WINDOW_MS = 10000;
|
|
62
55
|
interface TransportClass {
|
|
@@ -85,16 +78,6 @@ interface TransportClass {
|
|
|
85
78
|
* `/p2p-circuit` (`…/p2p-circuit/p2p/…`) is genuinely relay-carried.
|
|
86
79
|
*/
|
|
87
80
|
export declare function classifyTransport(remoteAddr: string): TransportClass;
|
|
88
|
-
/**
|
|
89
|
-
* Per-connection classifier. Starts from the pure multiaddr classification, then
|
|
90
|
-
* applies the TURN override: a `/webrtc` session whose ICE selected a TURN relay
|
|
91
|
-
* candidate (`conn.turnRelayed === true`, set externally — the multiaddr alone
|
|
92
|
-
* cannot reveal it) is reclassified `relayed`/`webrtc-turn`. The
|
|
93
|
-
* `transport === 'webrtc'` guard means a `webrtc-direct` connection is never
|
|
94
|
-
* promoted (it uses no ICE and so can never be TURN-relayed), and `undefined`
|
|
95
|
-
* (unknown) degrades safely to the multiaddr result — not relayed.
|
|
96
|
-
*/
|
|
97
|
-
export declare function classifyConnectionPath(conn: ConnectionLike): TransportClass;
|
|
98
81
|
/** An all-zero summary, used when no node/connections are available. */
|
|
99
82
|
export declare function emptyConnectionPathSummary(settleWindowMs?: number): ConnectionPathSummary;
|
|
100
83
|
/**
|
|
@@ -11,7 +11,6 @@ export const DEFAULT_SETTLE_WINDOW_MS = 10000;
|
|
|
11
11
|
const ALL_TRANSPORTS = [
|
|
12
12
|
'circuit-relay',
|
|
13
13
|
'webrtc',
|
|
14
|
-
'webrtc-turn',
|
|
15
14
|
'webrtc-direct',
|
|
16
15
|
'websocket',
|
|
17
16
|
'tcp',
|
|
@@ -61,22 +60,6 @@ function addrString(conn) {
|
|
|
61
60
|
return '';
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Per-connection classifier. Starts from the pure multiaddr classification, then
|
|
66
|
-
* applies the TURN override: a `/webrtc` session whose ICE selected a TURN relay
|
|
67
|
-
* candidate (`conn.turnRelayed === true`, set externally — the multiaddr alone
|
|
68
|
-
* cannot reveal it) is reclassified `relayed`/`webrtc-turn`. The
|
|
69
|
-
* `transport === 'webrtc'` guard means a `webrtc-direct` connection is never
|
|
70
|
-
* promoted (it uses no ICE and so can never be TURN-relayed), and `undefined`
|
|
71
|
-
* (unknown) degrades safely to the multiaddr result — not relayed.
|
|
72
|
-
*/
|
|
73
|
-
export function classifyConnectionPath(conn) {
|
|
74
|
-
const { kind, transport } = classifyTransport(addrString(conn));
|
|
75
|
-
if (transport === 'webrtc' && conn.turnRelayed === true) {
|
|
76
|
-
return { kind: 'relayed', transport: 'webrtc-turn' };
|
|
77
|
-
}
|
|
78
|
-
return { kind, transport };
|
|
79
|
-
}
|
|
80
63
|
/**
|
|
81
64
|
* Best-effort per-connection byte counter. The stock libp2p `Connection`
|
|
82
65
|
* interface carries no byte counter, so unless a metrics implementation is
|
|
@@ -132,9 +115,7 @@ export function summarizeConnectionPaths(conns, settleWindowMs = DEFAULT_SETTLE_
|
|
|
132
115
|
// least one direct connection.
|
|
133
116
|
const classified = list.map((conn) => {
|
|
134
117
|
const remoteAddr = addrString(conn);
|
|
135
|
-
|
|
136
|
-
// turnRelayed hint promotes webrtc → webrtc-turn (relayed).
|
|
137
|
-
const { kind, transport } = classifyConnectionPath(conn);
|
|
118
|
+
const { kind, transport } = classifyTransport(remoteAddr);
|
|
138
119
|
const openedAtMs = typeof conn.timeline?.open === 'number' ? conn.timeline.open : null;
|
|
139
120
|
const ageMs = openedAtMs != null ? Math.max(0, now - openedAtMs) : null;
|
|
140
121
|
const peerId = safePeerId(conn);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-path.js","sourceRoot":"","sources":["../../src/diagnostics/connection-path.ts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;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,KAAK,EAAE,IAAI,CAAC,MAAM;QAClB,OAAO;QACP,MAAM;QACN,YAAY,EAAE,UAAU;QACxB,WAAW;QACX,cAAc;QACd,KAAK;QACL,cAAc;KACf,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,IAAoB;IACtC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
package/dist/identity-key.d.ts
CHANGED
|
@@ -17,33 +17,3 @@ import { type KeyId, type KeyStore } from './key-store.js';
|
|
|
17
17
|
* @returns The resolved libp2p private key.
|
|
18
18
|
*/
|
|
19
19
|
export declare function loadOrCreateIdentityKey(keyStore: KeyStore, keyId?: KeyId): Promise<PrivateKey>;
|
|
20
|
-
/**
|
|
21
|
-
* Proof-of-possession signer for a node key, for out-of-band HTTP services that
|
|
22
|
-
* want to attribute a request to a peer id.
|
|
23
|
-
*
|
|
24
|
-
* Deliberately generic — it carries no ICE/TURN vocabulary, and the message it
|
|
25
|
-
* signs is the caller's business. The one consumer today is the reference apps'
|
|
26
|
-
* `loadIceConfig`, which signs the TURN credential issuer's peer assertion; those
|
|
27
|
-
* files mirror this interface structurally rather than importing it, so they stay
|
|
28
|
-
* dependency-free.
|
|
29
|
-
*/
|
|
30
|
-
export interface PeerKeySigner {
|
|
31
|
-
/** base58btc peer id — the same string libp2p reports for this node. */
|
|
32
|
-
readonly peerId: string;
|
|
33
|
-
/** base64url of the libp2p protobuf-encoded public key. */
|
|
34
|
-
readonly publicKeyB64: string;
|
|
35
|
-
/** Sign the UTF-8 bytes of `message`; resolves to a base64url signature. */
|
|
36
|
-
sign(message: string): Promise<string>;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Wrap a libp2p private key as a {@link PeerKeySigner}.
|
|
40
|
-
*
|
|
41
|
-
* Ed25519 only: the peer id is derived as an identity multihash (so
|
|
42
|
-
* `publicKey.toString()` already *is* the base58btc peer id — no `@libp2p/peer-id`
|
|
43
|
-
* round trip needed), and verifiers of this proof accept nothing else.
|
|
44
|
-
*
|
|
45
|
-
* @param privateKey - The node's libp2p Ed25519 private key.
|
|
46
|
-
* @returns A signer exposing the peer id, the encoded public key, and `sign`.
|
|
47
|
-
* @throws If the key is not Ed25519.
|
|
48
|
-
*/
|
|
49
|
-
export declare function peerKeySigner(privateKey: PrivateKey): PeerKeySigner;
|
package/dist/identity-key.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* identity-key — the load-or-create rule for a {@link KeyStore}-backed node
|
|
3
|
-
* identity, plus the "prove you hold this node key" signer built on top of it.
|
|
4
|
-
*
|
|
5
|
-
* Both live here because both are needed *outside* `CadreNode`: an embedding app
|
|
6
|
-
* (the React Native reference app) has to resolve its identity key before the node
|
|
7
|
-
* is constructed, so it can sign an out-of-band HTTP request with the same key the
|
|
8
|
-
* node will then load. Keeping one copy of the load-or-create rule is load-bearing
|
|
9
|
-
* — a second copy that drifted could generate a fresh key and orphan the real
|
|
10
3
|
* identity.
|
|
11
4
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
5
|
+
* Exported beyond `CadreNode` because an embedding app may need its identity key
|
|
6
|
+
* before the node is constructed. Keeping one copy of the rule is load-bearing — a
|
|
7
|
+
* second copy that drifted could generate a fresh key and orphan the real identity.
|
|
8
|
+
*
|
|
9
|
+
* Dependency-free beyond `@libp2p/crypto` (already a core dependency), so this
|
|
10
|
+
* module is safe in every (RN / browser / Node) entry graph.
|
|
14
11
|
*/
|
|
15
12
|
import debug from 'debug';
|
|
16
|
-
import { generateKeyPair, privateKeyToProtobuf, privateKeyFromProtobuf
|
|
17
|
-
import { toString as uint8ArrayToString } from 'uint8arrays';
|
|
13
|
+
import { generateKeyPair, privateKeyToProtobuf, privateKeyFromProtobuf } from '@libp2p/crypto/keys';
|
|
18
14
|
import { DEFAULT_IDENTITY_KEY_ID } from './key-store.js';
|
|
19
15
|
const log = debug('sereus:cadre:identity-key');
|
|
20
16
|
/**
|
|
@@ -49,33 +45,4 @@ export async function loadOrCreateIdentityKey(keyStore, keyId = DEFAULT_IDENTITY
|
|
|
49
45
|
log('Identity key generated and persisted to key store (first run)');
|
|
50
46
|
return generated;
|
|
51
47
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Wrap a libp2p private key as a {@link PeerKeySigner}.
|
|
54
|
-
*
|
|
55
|
-
* Ed25519 only: the peer id is derived as an identity multihash (so
|
|
56
|
-
* `publicKey.toString()` already *is* the base58btc peer id — no `@libp2p/peer-id`
|
|
57
|
-
* round trip needed), and verifiers of this proof accept nothing else.
|
|
58
|
-
*
|
|
59
|
-
* @param privateKey - The node's libp2p Ed25519 private key.
|
|
60
|
-
* @returns A signer exposing the peer id, the encoded public key, and `sign`.
|
|
61
|
-
* @throws If the key is not Ed25519.
|
|
62
|
-
*/
|
|
63
|
-
export function peerKeySigner(privateKey) {
|
|
64
|
-
if (privateKey.type !== 'Ed25519') {
|
|
65
|
-
throw new Error(`peerKeySigner requires an Ed25519 key, got ${privateKey.type}`);
|
|
66
|
-
}
|
|
67
|
-
const publicKey = privateKey.publicKey;
|
|
68
|
-
// For Ed25519 the public key's digest is an identity multihash, so its string
|
|
69
|
-
// form is the peer id itself — the same value `peerIdFromPrivateKey` produces.
|
|
70
|
-
const peerId = publicKey.toString();
|
|
71
|
-
const publicKeyB64 = uint8ArrayToString(publicKeyToProtobuf(publicKey), 'base64url');
|
|
72
|
-
return {
|
|
73
|
-
peerId,
|
|
74
|
-
publicKeyB64,
|
|
75
|
-
async sign(message) {
|
|
76
|
-
const signature = await privateKey.sign(new TextEncoder().encode(message));
|
|
77
|
-
return uint8ArrayToString(signature, 'base64url');
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
48
|
//# sourceMappingURL=identity-key.js.map
|
package/dist/identity-key.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity-key.js","sourceRoot":"","sources":["../src/identity-key.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"identity-key.js","sourceRoot":"","sources":["../src/identity-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAEpG,OAAO,EAAE,uBAAuB,EAA6B,MAAM,gBAAgB,CAAC;AAEpF,MAAM,GAAG,GAAG,KAAK,CAAC,2BAA2B,CAAC,CAAC;AAE/C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,QAAkB,EAClB,QAAe,uBAAuB;IAEtC,2EAA2E;IAC3E,4EAA4E;IAC5E,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACxC,IAAI,KAAK,EAAE,CAAC;QACV,+DAA+D;QAC/D,uDAAuD;QACvD,MAAM,MAAM,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC;QAC7C,GAAG,CAAC,mDAAmD,CAAC,CAAC;QACzD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,eAAe,CAAC,SAAS,CAAC,CAAC;IACnD,MAAM,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC,CAAC;IAC3D,GAAG,CAAC,+DAA+D,CAAC,CAAC;IACrE,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type { ControlRetryAbandonment, ControlRetryAbandonReason, ControlRetryAb
|
|
|
8
8
|
export { controlAuthorizationFields, type ControlDomain, type ControlAction } from './control-authorization.js';
|
|
9
9
|
export { ed25519KeyPairFromLibp2p, ed25519PublicKeyFromPrivate, requireEd25519PublicKeyB64, type Ed25519KeyPair } from './ed25519-key.js';
|
|
10
10
|
export { InMemoryKeyStore, KeyStoreAccessError, DEFAULT_IDENTITY_KEY_ID, type KeyStore, type KeyId } from './key-store.js';
|
|
11
|
-
export { loadOrCreateIdentityKey
|
|
11
|
+
export { loadOrCreateIdentityKey } from './identity-key.js';
|
|
12
12
|
export { MemoryTrustedOwnerStore, PersistentTrustedOwnerStore, type TrustedOwnerStore, type TrustSource } from './trusted-owner-store.js';
|
|
13
13
|
export type { DurableSlot } from './node-local-snapshot.js';
|
|
14
14
|
export { MemoryBootstrapPeerStore, PersistentBootstrapPeerStore, type BootstrapPeerStore, type BootstrapPeerEntry } from './bootstrap-peer-store.js';
|
|
@@ -22,6 +22,7 @@ export { StrandWatcher, type StrandWatcherCallbacks, type StrandQueryable, type
|
|
|
22
22
|
export { StrandInstanceManager, type StartStrandConfig, type ResumeStrandOverrides, getStrandStoragePath, isAwaitingFirstSync, liveStrandStatus } from './strand-instance-manager.js';
|
|
23
23
|
export { StrandAwaitingFirstSyncError, DEFAULT_STRAND_FIRST_SYNC_TIMEOUT_MS, DEFAULT_STRAND_FIRST_SYNC_POLL_MS, strandHeaderHeld, appTablesReadable, strandFirstSyncComplete, type StrandFirstSyncConfig } from './strand-first-sync-gate.js';
|
|
24
24
|
export { PeerJoinBackfill, DEFAULT_PEER_JOIN_BACKFILL, MAX_BLOCK_MESSAGE_BYTES, PEER_JOIN_BACKFILL_WARN_AFTER_FAILURES, type PeerJoinBackfillConfig, type PeerJoinBackfillDeps, type PeerJoinBackfillResult, type PeerJoinBackfillPushClient } from './peer-join-backfill.js';
|
|
25
|
+
export { strandCohortTopicOption, type StrandReactivityConfig } from './strand-reactivity.js';
|
|
25
26
|
export { StrandRevocationEnforcer, createRevocationConnectionGater, readStrandRevocationRows, DEFAULT_REVOCATION_POLL_INTERVAL_MS, type StrandRevocationEnforcementConfig, type StrandRevocationEnforcerDeps, type StrandRevocationRows, type StrandMemberPeerBinding, type StrandRevocationJudge, type StrandRevocationNetwork, type RevocationRefreshScheduler } from './strand-revocation-enforcer.js';
|
|
26
27
|
export { StrandMembershipReconciler, IDLE_PASSES_BEFORE_ESCALATION, INITIAL_JOIN_RETRY_INTERVAL_MS, type StrandMembershipReconcilerDeps, type StrandMembershipReconciliationConfig, type PendingMembershipInviteSource } from './strand-membership-reconciler.js';
|
|
27
28
|
export { defaultTimeoutScheduler, type TimeoutScheduler } from './timeout-scheduler.js';
|
|
@@ -58,6 +59,7 @@ export { StrandFormationManager, createStrandFormationManager, MEMBERSHIP_INVITE
|
|
|
58
59
|
export { createMembershipConnectionGater, STRANGER_OPEN_PROTOCOLS, DEFAULT_ENROLLMENT_WINDOW_MS, RELAY_ADMISSION_RESERVE_DEADLINE_MS, RELAY_ADMISSION_CLOSE_TIMEOUT_MS, MAX_UNAUTHORIZED_RELAY_RESERVATIONS, UnauthorizedReservationBudget, type InboundAdmissionPolicy, type InboundConnectionVerdict } from './membership-connection-gater.js';
|
|
59
60
|
export { RelayReservationFailedError, UnbindableListenAddressError, RELAY_SEARCH_LISTEN_ADDR, resolveListenAddrs } from './relay-addrs.js';
|
|
60
61
|
export { strandNodeAddrs, type StrandNodeAddrs } from './strand-network-config.js';
|
|
62
|
+
export { RELAY_STUN_PORT, relayStunUrl, resolveStunServers, type StunServer } from './relay-stun.js';
|
|
61
63
|
export { resolveRelayServer, PARTY_RELAY_MAX_RESERVATIONS, PARTY_RELAY_RESERVATION_TTL_MS, type ResolvedRelayServer, type ResolvedRelayReservations } from './relay-server.js';
|
|
62
64
|
export { circuitMultiaddrs, superviseRelayReservation, DEFAULT_RELAY_RESERVE_TIMEOUT_MS, DEFAULT_RELAY_RESERVE_POLL_MS, DEFAULT_RELAY_CHECK_MS, DEFAULT_RELAY_MIN_BACKOFF_MS, DEFAULT_RELAY_MAX_BACKOFF_MS, type RelayReservationStatus, type RelayReservationState, type RelayReserveOptions, type RelayReservationSupervisor, type RelayReservationSupervisorOptions } from './relay-reservation.js';
|
|
63
|
-
export { classifyTransport,
|
|
65
|
+
export { classifyTransport, summarizeConnectionPaths, emptyConnectionPathSummary, DEFAULT_SETTLE_WINDOW_MS, type ConnectionPathKind, type ConnectionTransport, type ConnectionPath, type ConnectionPathSummary, type ConnectionLike } from './diagnostics/connection-path.js';
|
package/dist/index.js
CHANGED
|
@@ -24,9 +24,8 @@ export { ed25519KeyPairFromLibp2p, ed25519PublicKeyFromPrivate, requireEd25519Pu
|
|
|
24
24
|
// import never lands here.
|
|
25
25
|
export { InMemoryKeyStore, KeyStoreAccessError, DEFAULT_IDENTITY_KEY_ID } from './key-store.js';
|
|
26
26
|
// The KeyStore-backed identity rule, shared with embedding apps that need the
|
|
27
|
-
// node key BEFORE `CadreNode` exists
|
|
28
|
-
|
|
29
|
-
export { loadOrCreateIdentityKey, peerKeySigner } from './identity-key.js';
|
|
27
|
+
// node key BEFORE `CadreNode` exists.
|
|
28
|
+
export { loadOrCreateIdentityKey } from './identity-key.js';
|
|
30
29
|
// Node-local trusted-owner anchor: the NON-replicated, per-party record of
|
|
31
30
|
// out-of-band-established owner keys (the trust anchor the replicated OwnerKey
|
|
32
31
|
// table cannot be). Cross-platform: interface + in-memory store only — the
|
|
@@ -84,6 +83,9 @@ export { StrandAwaitingFirstSyncError, DEFAULT_STRAND_FIRST_SYNC_TIMEOUT_MS, DEF
|
|
|
84
83
|
// connected peer, so a late joiner physically holds pre-join blocks). Shared
|
|
85
84
|
// by the strand networks (ungated) and the control network (membership-gated).
|
|
86
85
|
export { PeerJoinBackfill, DEFAULT_PEER_JOIN_BACKFILL, MAX_BLOCK_MESSAGE_BYTES, PEER_JOIN_BACKFILL_WARN_AFTER_FAILURES } from './peer-join-backfill.js';
|
|
86
|
+
// Operator opt-in to Optimystic change notifications on chosen strand nodes
|
|
87
|
+
// (`CadreNodeConfig.strandReactivity`).
|
|
88
|
+
export { strandCohortTopicOption } from './strand-reactivity.js';
|
|
87
89
|
// Closed-strand revoked-peer enforcement (deny the network nodes of removed
|
|
88
90
|
// members at the stream and connection layers, and hang up the sessions they
|
|
89
91
|
// already hold — see the module doc for the settled deny-list design, the
|
|
@@ -186,6 +188,9 @@ export { createMembershipConnectionGater, STRANGER_OPEN_PROTOCOLS, DEFAULT_ENROL
|
|
|
186
188
|
// spelling.
|
|
187
189
|
export { RelayReservationFailedError, UnbindableListenAddressError, RELAY_SEARCH_LISTEN_ADDR, resolveListenAddrs } from './relay-addrs.js';
|
|
188
190
|
export { strandNodeAddrs } from './strand-network-config.js';
|
|
191
|
+
// STUN for an embedder's WebRTC transport, derived from the relays it already uses: each
|
|
192
|
+
// Sereus relay also answers STUN (`ops/docs/ice-servers.md`).
|
|
193
|
+
export { RELAY_STUN_PORT, relayStunUrl, resolveStunServers } from './relay-stun.js';
|
|
189
194
|
// The circuit-relay SERVER a node runs, and with which init — one resolution shared by the
|
|
190
195
|
// control node and every strand node. Exported alongside the listen derivations above for the
|
|
191
196
|
// same reason: an embedder can assert on what its `network` block resolves to.
|
|
@@ -195,5 +200,5 @@ export { resolveRelayServer, PARTY_RELAY_MAX_RESERVATIONS, PARTY_RELAY_RESERVATI
|
|
|
195
200
|
// (see relay-reservation.ts)
|
|
196
201
|
export { circuitMultiaddrs, superviseRelayReservation, DEFAULT_RELAY_RESERVE_TIMEOUT_MS, DEFAULT_RELAY_RESERVE_POLL_MS, DEFAULT_RELAY_CHECK_MS, DEFAULT_RELAY_MIN_BACKOFF_MS, DEFAULT_RELAY_MAX_BACKOFF_MS } from './relay-reservation.js';
|
|
197
202
|
// Connection-path diagnostics (relayed vs direct classification + summary)
|
|
198
|
-
export { classifyTransport,
|
|
203
|
+
export { classifyTransport, summarizeConnectionPaths, emptyConnectionPathSummary, DEFAULT_SETTLE_WINDOW_MS } from './diagnostics/connection-path.js';
|
|
199
204
|
//# sourceMappingURL=index.js.map
|
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;AAExB,8EAA8E;AAC9E,
|
|
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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AAC/E,OAAO,EACL,kBAAkB,EAClB,4BAA4B,EAC5B,8BAA8B,EAG/B,MAAM,mBAAmB,CAAC;AAE3B,gFAAgF;AAChF,0EAA0E;AAC1E,6BAA6B;AAC7B,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,gCAAgC,EAChC,6BAA6B,EAC7B,sBAAsB,EACtB,4BAA4B,EAC5B,4BAA4B,EAM7B,MAAM,wBAAwB,CAAC;AAEhC,2EAA2E;AAC3E,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EAMzB,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The UDP port a Sereus relay answers STUN on (`STUN_PORT` in `ops/docker/libp2p-infra`).
|
|
3
|
+
* Fixed rather than discovered: a relay advertises only its libp2p listeners, so a relay
|
|
4
|
+
* that publishes STUN elsewhere needs the app's explicit override.
|
|
5
|
+
*/
|
|
6
|
+
export declare const RELAY_STUN_PORT = 3478;
|
|
7
|
+
/** A STUN-only `RTCIceServer`, declared structurally so non-DOM builds can use it. */
|
|
8
|
+
export interface StunServer {
|
|
9
|
+
urls: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The `stun:` URL for the relay at `relayAddr`, or `undefined` when the address names no
|
|
13
|
+
* host. An unparsable address only logs: `CadreNode.start()` rejects the same `relayAddrs`
|
|
14
|
+
* entry with an error naming it.
|
|
15
|
+
*/
|
|
16
|
+
export declare function relayStunUrl(relayAddr: string): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* The STUN servers for a node's WebRTC transport: the comma-separated `override` URLs when
|
|
19
|
+
* it names any, otherwise one per distinct relay host — each Sereus relay also answers
|
|
20
|
+
* STUN. Empty with no relay and no override, which leaves host/LAN candidates only and
|
|
21
|
+
* tells no third party who this node talks to. No TURN: a WebRTC upgrade that fails stays
|
|
22
|
+
* on the circuit relay.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveStunServers(relayAddrs: readonly string[], override?: string): StunServer[];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { multiaddr } from '@multiformats/multiaddr';
|
|
3
|
+
const log = debug('sereus:cadre:relay-stun');
|
|
4
|
+
/**
|
|
5
|
+
* The UDP port a Sereus relay answers STUN on (`STUN_PORT` in `ops/docker/libp2p-infra`).
|
|
6
|
+
* Fixed rather than discovered: a relay advertises only its libp2p listeners, so a relay
|
|
7
|
+
* that publishes STUN elsewhere needs the app's explicit override.
|
|
8
|
+
*/
|
|
9
|
+
export const RELAY_STUN_PORT = 3478;
|
|
10
|
+
/**
|
|
11
|
+
* Multiaddr protocols that name a host a `stun:` URL can carry. For `dnsaddr` that is the
|
|
12
|
+
* name the TXT records sit under, which is the relay's own host when one relay publishes
|
|
13
|
+
* `_dnsaddr.<host>` for itself (`ops/docs/dnsaddr.md`). A pool published under one name
|
|
14
|
+
* (`relay-1.…`, `relay-2.…`) needs that name to resolve to one of its relays, or the
|
|
15
|
+
* embedder's override.
|
|
16
|
+
*/
|
|
17
|
+
const HOST_PROTOCOLS = new Set(['dns', 'dns4', 'dns6', 'dnsaddr', 'ip4', 'ip6']);
|
|
18
|
+
/**
|
|
19
|
+
* The `stun:` URL for the relay at `relayAddr`, or `undefined` when the address names no
|
|
20
|
+
* host. An unparsable address only logs: `CadreNode.start()` rejects the same `relayAddrs`
|
|
21
|
+
* entry with an error naming it.
|
|
22
|
+
*/
|
|
23
|
+
export function relayStunUrl(relayAddr) {
|
|
24
|
+
let first;
|
|
25
|
+
try {
|
|
26
|
+
first = multiaddr(relayAddr).getComponents()[0];
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
log('no STUN server for unparsable relay address %s: %o', relayAddr, err);
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
if (first?.value === undefined || !HOST_PROTOCOLS.has(first.name))
|
|
33
|
+
return undefined;
|
|
34
|
+
const host = first.name === 'ip6' ? `[${first.value}]` : first.value;
|
|
35
|
+
return `stun:${host}:${RELAY_STUN_PORT}`;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The STUN servers for a node's WebRTC transport: the comma-separated `override` URLs when
|
|
39
|
+
* it names any, otherwise one per distinct relay host — each Sereus relay also answers
|
|
40
|
+
* STUN. Empty with no relay and no override, which leaves host/LAN candidates only and
|
|
41
|
+
* tells no third party who this node talks to. No TURN: a WebRTC upgrade that fails stays
|
|
42
|
+
* on the circuit relay.
|
|
43
|
+
*/
|
|
44
|
+
export function resolveStunServers(relayAddrs, override) {
|
|
45
|
+
const overrideUrls = (override ?? '').split(',').map((s) => s.trim()).filter((s) => s.length > 0);
|
|
46
|
+
const urls = overrideUrls.length > 0
|
|
47
|
+
? overrideUrls
|
|
48
|
+
: relayAddrs.map(relayStunUrl).filter((url) => url !== undefined);
|
|
49
|
+
return [...new Set(urls)].map((url) => ({ urls: url }));
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=relay-stun.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay-stun.js","sourceRoot":"","sources":["../src/relay-stun.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,MAAM,GAAG,GAAG,KAAK,CAAC,yBAAyB,CAAC,CAAC;AAE7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC;AAOpC;;;;;;GAMG;AACH,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAEjF;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,SAAiB;IAC5C,IAAI,KAAK,CAAC;IACV,IAAI,CAAC;QACH,KAAK,GAAG,SA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AAC1D,CAAC"}
|
package/dist/seed-bootstrap.js
CHANGED
|
@@ -272,10 +272,10 @@ export class SeedBootstrapService {
|
|
|
272
272
|
if (!this.controlDatabase) {
|
|
273
273
|
throw new Error('Control database not initialized');
|
|
274
274
|
}
|
|
275
|
-
await this.controlDatabase.execWrite(`
|
|
276
|
-
insert into CadreControl.DeviceToken (PeerId, Platform, Token, UpdatedAt, Sig, StampId)
|
|
277
|
-
with context OwnerKey = ?, Signature = ?
|
|
278
|
-
values (?, ?, ?, ?, ?, ?)
|
|
275
|
+
await this.controlDatabase.execWrite(`
|
|
276
|
+
insert into CadreControl.DeviceToken (PeerId, Platform, Token, UpdatedAt, Sig, StampId)
|
|
277
|
+
with context OwnerKey = ?, Signature = ?
|
|
278
|
+
values (?, ?, ?, ?, ?, ?)
|
|
279
279
|
`, [this.ownerPublicKey, signature, record.peerId, record.platform, record.token, record.updatedAt, record.sig, stampId], 'device-token-insert');
|
|
280
280
|
log('Device token inserted (owner-signed): %s', record.peerId);
|
|
281
281
|
}
|
|
@@ -5,6 +5,7 @@ import { type StrandRevocationEnforcementConfig } from './strand-revocation-enfo
|
|
|
5
5
|
import { type PendingMembershipInviteSource, type StrandMembershipReconciliationConfig } from './strand-membership-reconciler.js';
|
|
6
6
|
import { type StrandFirstSyncConfig } from './strand-first-sync-gate.js';
|
|
7
7
|
import type { StrandInstance, StrandRow, StorageConfig, NetworkConfig, LatencyHint, NodeProfile, SAppConfig } from './types.js';
|
|
8
|
+
import { type StrandReactivityConfig } from './strand-reactivity.js';
|
|
8
9
|
/**
|
|
9
10
|
* Whether a tracked instance is launched but waiting for its first sync: the runtime is
|
|
10
11
|
* up (`libp2pNode` set) while the database is still withheld (`database` unset). That
|
|
@@ -126,6 +127,13 @@ export interface StartStrandConfig {
|
|
|
126
127
|
* no-backfill behaviour.
|
|
127
128
|
*/
|
|
128
129
|
backfill?: PeerJoinBackfillConfig;
|
|
130
|
+
/**
|
|
131
|
+
* Whether this strand's libp2p node is built with Optimystic's change notifications,
|
|
132
|
+
* forwarded from {@link CadreNodeConfig.strandReactivity} and resolved per strand by
|
|
133
|
+
* `strandCohortTopicOption`. Retained with the launch config, so a hibernation wake
|
|
134
|
+
* rebuilds the node with the same setting.
|
|
135
|
+
*/
|
|
136
|
+
reactivity?: StrandReactivityConfig;
|
|
129
137
|
/**
|
|
130
138
|
* Tuning for the CLOSED-strand revoked-peer gate
|
|
131
139
|
* ({@link StrandRevocationEnforcer}), forwarded from
|
|
@@ -14,6 +14,7 @@ import { StrandFirstSyncGate, StrandAwaitingFirstSyncError, strandFirstSyncCompl
|
|
|
14
14
|
import { DEFAULT_CONNECTION_MONITOR, resolveStrandClusterSize, strandClusterPolicy } from './types.js';
|
|
15
15
|
import { strandNodeAddrs } from './strand-network-config.js';
|
|
16
16
|
import { resolveRelayServer } from './relay-server.js';
|
|
17
|
+
import { strandCohortTopicOption } from './strand-reactivity.js';
|
|
17
18
|
import { superviseRelayReservation } from './relay-reservation.js';
|
|
18
19
|
import { declaredCohortReadDeadlineMs, optimysticDialLimits, peerJoinPushBudget, relayReservationBudgetMs, resolveLinkRoundTripMs } from './link-budget.js';
|
|
19
20
|
const log = debug('sereus:cadre:strand-manager');
|
|
@@ -447,6 +448,10 @@ export class StrandInstanceManager {
|
|
|
447
448
|
: config.network?.connectionGater
|
|
448
449
|
? { connectionGater: config.network.connectionGater }
|
|
449
450
|
: {};
|
|
451
|
+
const reactivityOption = strandCohortTopicOption(config.reactivity, strandId);
|
|
452
|
+
if (reactivityOption.cohortTopic) {
|
|
453
|
+
log('strand %s: change notifications on', strandId);
|
|
454
|
+
}
|
|
450
455
|
try {
|
|
451
456
|
// Bound once: the breadth is also the ceiling on the repair yardstick below, and the
|
|
452
457
|
// two must be derived from the same resolution. Inside the `try` deliberately — a
|
|
@@ -526,7 +531,9 @@ export class StrandInstanceManager {
|
|
|
526
531
|
// The raw configured gater (open strands), or the revocation-composed
|
|
527
532
|
// gater plus the fail-closed per-stream revoked-peer gate (closed
|
|
528
533
|
// strands) — resolved above, before the try.
|
|
529
|
-
...revocationGateOptions
|
|
534
|
+
...revocationGateOptions,
|
|
535
|
+
// `{}` unless the operator enabled change notifications for this strand (`strand-reactivity.ts`).
|
|
536
|
+
...reactivityOption
|
|
530
537
|
});
|
|
531
538
|
timing('[buildStrandRuntime:%s] createLibp2pNode: %dms', strandId, Math.round(performance.now() - t0));
|
|
532
539
|
instance.libp2pNode = node;
|