@ocap/chain-node 1.32.2 → 1.32.3

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/esm/types.d.mts CHANGED
@@ -1,9 +1,11 @@
1
1
  import { FutureTimestampGuardConfig, TChainConfigCheckMode } from "./standalone-env.mjs";
2
+ import { DidTlsAllowedIssuerPinsInput, DidTlsWireAlgorithm } from "./did-tls.mjs";
2
3
  import { CHAIN_NODE_TEST_HOOKS_TOKEN } from "./test-hooks-token.mjs";
3
4
  import { AnchorPublisher, ICheckpointSignerWallet, IHotStuffRuntimeValidatorMember, ILedgerHealth, INodeRoleConfig, ISegmentArchiveStore, IWriterLeaseConfig, Ledger, LedgerConfig } from "@arcblock/ledger-core";
4
5
  import { SqliteLedgerStorage } from "@arcblock/ledger-sqlite";
5
- import SqliteIndexDB from "@ocap/indexdb-sqlite";
6
6
  import OCAPResolver, { FollowerSyncService, HotStuffNodeRuntime, HotStuffNodeRuntimeOptions, IColdSegmentReader, INodeMaintenanceController, NodePreferencesManager, TFollowerUpstreamFetchKind } from "@ocap/resolver";
7
+ import tls from "node:tls";
8
+ import SqliteIndexDB from "@ocap/indexdb-sqlite";
7
9
  import SqliteStateDB from "@ocap/statedb-sqlite";
8
10
  import { SqliteTrustedStorage } from "@ocap/trusted-storage";
9
11
  import express from "express";
@@ -16,6 +18,8 @@ type ILedgerHealthStatus = ILedgerHealth;
16
18
  type TNodeRetentionMode = INodeRoleConfig['retentionMode'];
17
19
  type ChainNodeSegmentPublisher = NonNullable<LedgerConfig['segmentPublisher']> & {
18
20
  getArchiveStore?: () => ISegmentArchiveStore | undefined;
21
+ /** Present on `BackgroundSegmentPublisher`: DA publisher status, `null` outside DA mode (#2016) */
22
+ getDaStatus?: () => Record<string, unknown> | null;
19
23
  };
20
24
  interface TrustedAccountConfig {
21
25
  address: string;
@@ -64,12 +68,25 @@ interface FollowerRoleConfig {
64
68
  clusterPeerUrls?: string[];
65
69
  snapshotBaseUrl?: string | null;
66
70
  snapshotPrefix?: string;
71
+ /**
72
+ * `FOLLOWER_BOOTSTRAP_SOURCE` (#2017): absent or `snapshot` = start from the sanitized snapshot (the default); `da` =
73
+ * start a fresh data dir from the G0 of the DA archive described by `da`, then follow its segments, then the hot tail.
74
+ */
75
+ bootstrapSource?: INodeRoleConfig['bootstrapSource'];
76
+ /** The pinned DA archive (`DA_BASE_URL`, `DA_GENESIS_MANIFEST_HASH`, ...); required with `bootstrapSource: 'da'` */
77
+ da?: INodeRoleConfig['da'];
78
+ /** `DA_BASE_URL` in snapshot mode (#2018): the DA archive a fresh snapshot bootstrap is cross-checked against */
79
+ daCrossCheck?: INodeRoleConfig['daCrossCheck'];
80
+ /** `DA_BASE_URL` set but incomplete in snapshot mode (#2018): enforced only when the node would bootstrap */
81
+ daCrossCheckIncomplete?: INodeRoleConfig['daCrossCheckIncomplete'];
67
82
  trustedProposer?: string | null;
68
83
  trustedProposerPublicKey?: string | null;
69
84
  hotstuffValidators?: IHotStuffRuntimeValidatorMember[];
70
85
  hotstuffQuorumThreshold?: number;
71
86
  /** Whether `127.0.0.1` / RFC1918 private peers are allowed (`false` by default for SSRF safety) */
72
87
  allowPrivatePeers?: boolean;
88
+ /** Optional local `afs-mesh` loopback egress gateway (`http://127.0.0.1:<port>` or `http://[::1]:<port>`, #2025) */
89
+ meshEgressUrl?: string;
73
90
  /** Reject cascaded keyless/unsigned follower upstreams with `UPSTREAM_CASCADED_FORBIDDEN` */
74
91
  disallowKeylessCascadedUpstream?: boolean;
75
92
  allowUnauthenticatedBootstrap?: boolean;
@@ -102,6 +119,8 @@ interface HotStuffValidatorRoleConfig {
102
119
  allowPublicConsensusBind?: boolean;
103
120
  writePolicy?: TNodeWritePolicy;
104
121
  allowPrivatePeers?: boolean;
122
+ /** Optional local `afs-mesh` loopback egress gateway (`http://127.0.0.1:<port>` or `http://[::1]:<port>`, #2025) */
123
+ meshEgressUrl?: string;
105
124
  retentionMode?: TNodeRetentionMode;
106
125
  hotWindowEntries?: number;
107
126
  hotWindowCheckpoints?: number;
@@ -122,11 +141,47 @@ interface ChainAppHookContext {
122
141
  preferencesManager: NodePreferencesManager;
123
142
  maintenanceController: INodeMaintenanceController;
124
143
  }
144
+ interface ChainHttpTlsConfig {
145
+ enabled?: boolean;
146
+ /** TLS wire key/signature algorithm (`'p256'` universal BoringSSL/OpenSSL default with Ed25519 `DIDBindingProof`, or `'ed25519'` on OpenSSL) */
147
+ wireAlgorithm?: DidTlsWireAlgorithm;
148
+ /** Optional Ed25519 DID seed / secretKey for server cert synthesis (defaults to node signer / `CHAIN_SK`) */
149
+ identitySecretKey?: string;
150
+ /** Optional explicit W3C or OCAP server DID (`did:abt:z...` or `z...`) */
151
+ subjectDid?: string;
152
+ /** Optional PEM certificate file override (`lstatSync` non-symlink verified) */
153
+ certFile?: string;
154
+ /** Optional PEM private key file override (`lstatSync` non-symlink verified) */
155
+ keyFile?: string;
156
+ /** Require client mTLS certificate (`true` by default whenever `enabled: true`) */
157
+ requireClientCert?: boolean;
158
+ /** Fail-closed pinned 32-byte Ed25519 issuer public keys (hex, `0x` hex, multibase `z...`, or `<did>=<pk>`) */
159
+ allowedIssuerPublicKeys?: DidTlsAllowedIssuerPinsInput;
160
+ /** Optional allowlist of permitted client subject DIDs */
161
+ allowedClientDids?: readonly string[];
162
+ /** Optional DNS SubjectAltName entries for synthesized server certificate */
163
+ sanDnsNames?: readonly string[];
164
+ /** Optional IPv4 / IPv6 SubjectAltName entries for synthesized server certificate */
165
+ sanIpAddresses?: readonly string[];
166
+ /** Synthesized server certificate validity duration in days (`1..3650`, default `365`) */
167
+ validityDays?: number;
168
+ /** TLS handshake timeout in milliseconds (default `10_000`) */
169
+ handshakeTimeoutMs?: number;
170
+ /** Allowed clock skew in seconds for client cert verification (default `60`) */
171
+ clockSkewSeconds?: number;
172
+ }
173
+ interface ReloadedTlsCredentialsInfo {
174
+ reloaded: boolean;
175
+ subjectDid: string | null;
176
+ spkiSha256Hex: string | null;
177
+ }
125
178
  interface ChainProfileBase {
126
179
  /** Optional explicit nodeId (otherwise loaded/persisted in `<dataDir>/.node-id`) */
127
180
  nodeId?: string;
128
181
  /** Exclusive node data directory (`statedb.sqlite`, `ledger.sqlite`, `indexdb.sqlite`, `trusted.sqlite`, `.node-id`) */
129
182
  dataDir: string;
183
+ /** Optional local `afs-mesh` loopback egress gateway (`http://127.0.0.1:<port>` or `http://[::1]:<port>`, #2025) */
184
+ meshEgressUrl?: string;
130
185
  http: {
131
186
  /** Default `'127.0.0.1'`; pass `'0.0.0.0'` explicitly to listen on all interfaces */
132
187
  host?: string;
@@ -142,6 +197,8 @@ interface ChainProfileBase {
142
197
  onGraphqlError?: (err: Error & {
143
198
  originalError?: Error;
144
199
  }) => void;
200
+ /** Optional zero-CA DID-TLS / mTLS listener configuration (#2025) */
201
+ tls?: ChainHttpTlsConfig;
145
202
  };
146
203
  storage?: {
147
204
  statedbPath?: string;
@@ -170,6 +227,8 @@ interface ChainProfileBase {
170
227
  coldArchiveReader?: IColdSegmentReader | null;
171
228
  anchorPublisher?: AnchorPublisher | null;
172
229
  env?: Record<string, string | undefined>;
230
+ /** Test seam: the `fetch` the env-built segment publisher uses (e.g. a fake R2). Unset in production. */
231
+ fetchImpl?: typeof fetch;
173
232
  };
174
233
  genesisTime?: string;
175
234
  reservedSymbols?: string[];
@@ -301,15 +360,17 @@ interface RunningChainNode {
301
360
  readonly indexdb: SqliteIndexDB;
302
361
  readonly trustedStorage: SqliteTrustedStorage;
303
362
  readonly server: http.Server;
363
+ readonly tlsServer?: tls.Server;
304
364
  readonly followerSync?: FollowerSyncService;
305
365
  readonly hotstuffRuntime?: HotStuffNodeRuntime;
306
366
  readonly preferencesManager: NodePreferencesManager;
307
367
  readonly maintenanceController: INodeMaintenanceController;
308
368
  ledgerHealth(): Promise<ILedgerHealthStatus>;
369
+ reloadTlsCredentials(): Promise<ReloadedTlsCredentialsInfo>;
309
370
  advanceClock?(seconds: number): number;
310
371
  restart(nextProfile?: Partial<ChainProfile>): Promise<RunningChainNode>;
311
372
  stop(): Promise<void>;
312
373
  }
313
374
  type ChainNodeHandle = RunningChainNode;
314
375
  //#endregion
315
- export { ChainAppHookContext, ChainNodeHandle, ChainNodeProfile, ChainNodeRoleConfig, ChainNodeSegmentPublisher, ChainNodeSignerConfig, ChainNodeTestHooks, ChainNodeTestHooksInput, ChainProfile, ChainProfileBase, FollowerRoleConfig, FollowerSyncTestController, FollowerUpstreamInterceptorContext, HotStuffValidatorRoleConfig, ILedgerHealthStatus, ILedgerLeaseOptions, PublicKeyOnlyValidatorSignerConfig, RunningChainNode, StartChainNodeOptions, TNodeRetentionMode, TrustedAccountConfig, ValidatorRoleConfig, ValidatorSignerConfig };
376
+ export { ChainAppHookContext, ChainHttpTlsConfig, ChainNodeHandle, ChainNodeProfile, ChainNodeRoleConfig, ChainNodeSegmentPublisher, ChainNodeSignerConfig, ChainNodeTestHooks, ChainNodeTestHooksInput, ChainProfile, ChainProfileBase, FollowerRoleConfig, FollowerSyncTestController, FollowerUpstreamInterceptorContext, HotStuffValidatorRoleConfig, ILedgerHealthStatus, ILedgerLeaseOptions, PublicKeyOnlyValidatorSignerConfig, ReloadedTlsCredentialsInfo, RunningChainNode, StartChainNodeOptions, TNodeRetentionMode, TrustedAccountConfig, ValidatorRoleConfig, ValidatorSignerConfig };