@macula-io/ts 0.16.0 → 0.18.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/binding.js CHANGED
@@ -1,133 +1,16 @@
1
- // Loads the compiled N-API addon (addon/binding.cc) and re-exports its
2
- // typed functions. Unlike the koffi-era version of this file, there is
3
- // no runtime signature declaration here -- the addon's C++ glue already
4
- // knows its own shapes, throws real JS errors on failure (no more
5
- // manual errOut-array/checkErr dance), and is a single self-contained
6
- // .node file (cabi/'s Go code is statically linked in via
7
- // -buildmode=c-archive, not loaded separately at runtime).
1
+ // Loads the compiled N-API addon (addon/binding.cc) and types its functions.
2
+ // cabi/'s Go code is linked into the addon statically, so it is one
3
+ // self-contained .node file. node-gyp-build picks, at require time, a local
4
+ // build (build/Release/*.node) or the published prebuild for this platform
5
+ // (prebuilds/<platform>-<arch>/*.node), so a consumer installing from npm
6
+ // never runs a compiler.
8
7
  //
9
- // node-gyp-build picks, at require time, whichever of these exists:
10
- // build/Release/*.node (a local dev build via `npm run build:addon:dev`)
11
- // or prebuilds/<platform>-<arch>/*.node (baked in by `npm run
12
- // build:prebuilds` / prebuildify, and published as part of the npm
13
- // package) -- this is the whole point: a consumer installing this
14
- // package from npm never runs a compiler or fetches anything, because
15
- // the matching prebuild is already sitting in the downloaded tarball.
8
+ // Internal to the package: the public API is key.ts, pool.ts and stream.ts.
16
9
  import { createRequire } from "node:module";
17
10
  import { fileURLToPath } from "node:url";
18
11
  import { dirname, join } from "node:path";
19
12
  const require = createRequire(import.meta.url);
20
13
  const repoRoot = join(dirname(fileURLToPath(import.meta.url)), "..");
21
14
  // eslint-disable-next-line @typescript-eslint/no-var-requires
22
- const addon = require("node-gyp-build")(repoRoot);
23
- export const native = {
24
- identityGenerate() {
25
- return addon.identityGenerate();
26
- },
27
- identityFromSeedBytes(seed32) {
28
- if (seed32.length !== 32) {
29
- throw new Error(`macula-ts: seed must be exactly 32 bytes, got ${seed32.length}`);
30
- }
31
- return addon.identityFromSeedBytes(seed32);
32
- },
33
- identityNodeId(handle) {
34
- return addon.identityNodeId(handle);
35
- },
36
- identityPrivateBytes(handle) {
37
- return addon.identityPrivateBytes(handle);
38
- },
39
- identityFree(handle) {
40
- addon.identityFree(handle);
41
- },
42
- identitySign(handle, data) {
43
- return addon.identitySign(handle, data);
44
- },
45
- sessionConnect(host, port, identityHandle) {
46
- return addon.sessionConnect(host, port, identityHandle);
47
- },
48
- sessionRemoteAddr(handle) {
49
- return addon.sessionRemoteAddr(handle);
50
- },
51
- sessionStationNodeId(handle) {
52
- return addon.sessionStationNodeId(handle);
53
- },
54
- sessionClose(handle, identityHandle, reason) {
55
- return addon.sessionClose(handle, identityHandle, reason);
56
- },
57
- sessionCall(sessionHandle, identityHandle, procedure, realm, payloadJson, timeoutMs, bytesMode) {
58
- return addon.sessionCall(sessionHandle, identityHandle, procedure, realm, payloadJson, timeoutMs, bytesMode);
59
- },
60
- ucanMint(identityHandle, issuer, audience, capabilitiesJson, expiresAt, notBefore, nonce, factsJson, proofsJson) {
61
- return addon.ucanMint(identityHandle, issuer, audience, capabilitiesJson, expiresAt, notBefore, nonce, factsJson, proofsJson);
62
- },
63
- ucanDecode(token) {
64
- return addon.ucanDecode(token);
65
- },
66
- sessionCallWithUcan(sessionHandle, identityHandle, procedure, realm, payloadJson, timeoutMs, ucanToken, bytesMode) {
67
- return addon.sessionCallWithUcan(sessionHandle, identityHandle, procedure, realm, payloadJson, timeoutMs, ucanToken, bytesMode);
68
- },
69
- sessionAdvertise(sessionHandle, identityHandle, realm, procedure) {
70
- return addon.sessionAdvertise(sessionHandle, identityHandle, realm, procedure);
71
- },
72
- sessionUnadvertise(sessionHandle, identityHandle, realm, procedure) {
73
- return addon.sessionUnadvertise(sessionHandle, identityHandle, realm, procedure);
74
- },
75
- serveWaitForCall(sessionHandle, identityHandle, realm, procedure, timeoutMs) {
76
- return addon.serveWaitForCall(sessionHandle, identityHandle, realm, procedure, timeoutMs);
77
- },
78
- pendingCallProcedure(pendingHandle) {
79
- return addon.pendingCallProcedure(pendingHandle);
80
- },
81
- pendingCallPayloadJson(pendingHandle, bytesMode) {
82
- return addon.pendingCallPayloadJson(pendingHandle, bytesMode);
83
- },
84
- pendingCallReplyResult(pendingHandle, resultJson) {
85
- return addon.pendingCallReplyResult(pendingHandle, resultJson);
86
- },
87
- pendingCallReplyError(pendingHandle, detail) {
88
- return addon.pendingCallReplyError(pendingHandle, detail);
89
- },
90
- dhtFindRecordsByType(sessionHandle, identityHandle, recordType) {
91
- return addon.dhtFindRecordsByType(sessionHandle, identityHandle, recordType);
92
- },
93
- dhtFindRecords(sessionHandle, identityHandle, key32) {
94
- return addon.dhtFindRecords(sessionHandle, identityHandle, key32);
95
- },
96
- dhtFindRecord(sessionHandle, identityHandle, key32) {
97
- return addon.dhtFindRecord(sessionHandle, identityHandle, key32);
98
- },
99
- dhtPutProcedureAdvertisement(sessionHandle, identityHandle, realm, procedure, servingStation32, ttlMs) {
100
- return addon.dhtPutProcedureAdvertisement(sessionHandle, identityHandle, realm, procedure, servingStation32, ttlMs);
101
- },
102
- dhtPutContentAnnouncement(sessionHandle, identityHandle, mcid34, endpoint, ttlMs) {
103
- return addon.dhtPutContentAnnouncement(sessionHandle, identityHandle, mcid34, endpoint, ttlMs);
104
- },
105
- sessionPublish(sessionHandle, identityHandle, realm, topic, payloadJson, ttlMs) {
106
- return addon.sessionPublish(sessionHandle, identityHandle, realm, topic, payloadJson, ttlMs);
107
- },
108
- sessionSubscribeStart(sessionHandle, identityHandle, realm, topic, onEvent, bytesMode) {
109
- return addon.sessionSubscribeStart(sessionHandle, identityHandle, realm, topic, onEvent, bytesMode);
110
- },
111
- sessionSubscribeStop(subscriptionHandle) {
112
- return addon.sessionSubscribeStop(subscriptionHandle);
113
- },
114
- contentPut(sessionHandle, identityHandle, data, name) {
115
- return addon.contentPut(sessionHandle, identityHandle, data, name);
116
- },
117
- contentGet(sessionHandle, identityHandle, mcidHex) {
118
- return addon.contentGet(sessionHandle, identityHandle, mcidHex);
119
- },
120
- directdialResolve(sessionHandle, identityHandle, realm, procedure, timeoutMs) {
121
- return addon.directdialResolve(sessionHandle, identityHandle, realm, procedure, timeoutMs);
122
- },
123
- directdialCall(sessionHandle, identityHandle, procedure, realm, payloadJson, timeoutMs, bytesMode) {
124
- return addon.directdialCall(sessionHandle, identityHandle, procedure, realm, payloadJson, timeoutMs, bytesMode);
125
- },
126
- directdialCallWithUcan(sessionHandle, identityHandle, procedure, realm, payloadJson, timeoutMs, ucanToken, bytesMode) {
127
- return addon.directdialCallWithUcan(sessionHandle, identityHandle, procedure, realm, payloadJson, timeoutMs, ucanToken, bytesMode);
128
- },
129
- directdialAdvertise(sessionHandle, identityHandle, realm, procedure, ttlMs) {
130
- return addon.directdialAdvertise(sessionHandle, identityHandle, realm, procedure, ttlMs);
131
- },
132
- };
15
+ export const native = require("node-gyp-build")(repoRoot);
133
16
  //# sourceMappingURL=binding.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"binding.js","sourceRoot":"","sources":["../src/binding.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,uEAAuE;AACvE,wEAAwE;AACxE,kEAAkE;AAClE,sEAAsE;AACtE,0DAA0D;AAC1D,2DAA2D;AAC3D,EAAE;AACF,oEAAoE;AACpE,yEAAyE;AACzE,8DAA8D;AAC9D,mEAAmE;AACnE,kEAAkE;AAClE,sEAAsE;AACtE,sEAAsE;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CA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CAAC;AAE1C,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AAgBrE,8DAA8D;AAC9D,MAAM,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CA2CvD,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,4 @@
1
- export { Identity } from "./identity.js";
2
- export { Session, type CallOptions, type ServeOptions } from "./session.js";
3
- export { Pool, NoHealthyStationError, type Seed, type PoolOptions, type PoolStatus } from "./pool.js";
4
- export { MaculaCallError, type JsonValue, type Bolt4ErrorInfo, type BytesOutput } from "./rpc.js";
5
- export { DhtRecordType, DHT_DEFAULT_TTL_MS, type DhtRecord } from "./dht.js";
6
- export type { PublishOptions, PubsubEvent, SubscribeOptions } from "./pubsub.js";
7
- export { ContentNotFoundError } from "./content.js";
8
- export { Ucan, type UcanCapability, type UcanFactValue, type UcanMintOptions } from "./ucan.js";
9
- export { keepAdvertisedDirect, KEEP_ADVERTISED_DIRECT_INTERVAL_MS, type DirectDialTarget, type AdvertiseDirectOptions, type KeepAdvertisedDirectOptions, } from "./directdial.js";
1
+ export { NodeKey, type Profile } from "./key.js";
2
+ export { Pool, Subscription, Served, RecordType, type Seed, type PoolOptions, type LinkStatus, type Provider, type Event, type Request, type DhtRecord, } from "./pool.js";
3
+ export { Stream, StreamMode, type StreamEvent, type StreamRequest } from "./stream.js";
4
+ export { ProviderError, RelayError, StreamError, DEFAULT_CALL_TIMEOUT_MS, type JsonValue, type BytesOutput, type Id, } from "./wire.js";
package/dist/index.js CHANGED
@@ -1,9 +1,6 @@
1
- export { Identity } from "./identity.js";
2
- export { Session } from "./session.js";
3
- export { Pool, NoHealthyStationError } from "./pool.js";
4
- export { MaculaCallError } from "./rpc.js";
5
- export { DhtRecordType, DHT_DEFAULT_TTL_MS } from "./dht.js";
6
- export { ContentNotFoundError } from "./content.js";
7
- export { Ucan } from "./ucan.js";
8
- export { keepAdvertisedDirect, KEEP_ADVERTISED_DIRECT_INTERVAL_MS, } from "./directdial.js";
1
+ // @macula-io/ts: the macula 12 mesh from TypeScript, over macula-go.
2
+ export { NodeKey } from "./key.js";
3
+ export { Pool, Subscription, Served, RecordType, } from "./pool.js";
4
+ export { Stream, StreamMode } from "./stream.js";
5
+ export { ProviderError, RelayError, StreamError, DEFAULT_CALL_TIMEOUT_MS, } from "./wire.js";
9
6
  //# 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,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,OAAO,EAAuC,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,qBAAqB,EAAgD,MAAM,WAAW,CAAC;AACtG,OAAO,EAAE,eAAe,EAAyD,MAAM,UAAU,CAAC;AAClG,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAkB,MAAM,UAAU,CAAC;AAE7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,IAAI,EAAiE,MAAM,WAAW,CAAC;AAChG,OAAO,EACL,oBAAoB,EACpB,kCAAkC,GAInC,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EAAE,OAAO,EAAgB,MAAM,UAAU,CAAC;AACjD,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,UAAU,GAQX,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAwC,MAAM,aAAa,CAAC;AACvF,OAAO,EACL,aAAa,EACb,UAAU,EACV,WAAW,EACX,uBAAuB,GAIxB,MAAM,WAAW,CAAC"}
package/dist/key.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ import { type Handle } from "./binding.js";
2
+ /** A crypto profile: "pq_hybrid" (the fleet's) or "pq_pure". */
3
+ export type Profile = "pq_hybrid" | "pq_pure";
4
+ export declare class NodeKey {
5
+ private handle;
6
+ private constructor();
7
+ /** A new key whose node_id solves the admission puzzle; takes a second or
8
+ * so, off the event loop. */
9
+ static generate(profile?: Profile): Promise<NodeKey>;
10
+ /** The key in the key file at path. A file its group or others can read,
11
+ * or holding a key of another profile, is refused. */
12
+ static load(path: string, profile?: Profile): Promise<NodeKey>;
13
+ /** The key at path, or a new one saved there when the file does not exist. */
14
+ static loadOrCreate(path: string, profile?: Profile): Promise<NodeKey>;
15
+ /** Writes the key to path, readable by its owner only. */
16
+ save(path: string): Promise<void>;
17
+ /** The key's 32-byte node_id. */
18
+ nodeId(): Uint8Array;
19
+ /** The node_id as lowercase hex. */
20
+ nodeIdHex(): string;
21
+ /** The public key as carried on the wire. */
22
+ publicKey(): Uint8Array;
23
+ /** The key's profile. */
24
+ profile(): Profile;
25
+ /** Signs data as given. */
26
+ sign(data: Uint8Array): Promise<Uint8Array>;
27
+ /** Frees the native key. The NodeKey is unusable after. */
28
+ free(): void;
29
+ /** @internal */
30
+ live(): Handle;
31
+ }
package/dist/key.js ADDED
@@ -0,0 +1,72 @@
1
+ // A node's identity key, as macula 12 has it: ML-DSA-87 (pq_pure) or the LAMPS
2
+ // composite ML-DSA-87 + RSA-4096-PSS (pq_hybrid, the fleet's profile), whose
3
+ // node_id solves the admission puzzle. Stored in a key file readable by its
4
+ // owner only.
5
+ import { access } from "node:fs/promises";
6
+ import { native } from "./binding.js";
7
+ import { hex } from "./wire.js";
8
+ export class NodeKey {
9
+ handle;
10
+ constructor(handle) {
11
+ this.handle = handle;
12
+ }
13
+ /** A new key whose node_id solves the admission puzzle; takes a second or
14
+ * so, off the event loop. */
15
+ static async generate(profile = "pq_hybrid") {
16
+ return new NodeKey(await native.keyGenerate(profile));
17
+ }
18
+ /** The key in the key file at path. A file its group or others can read,
19
+ * or holding a key of another profile, is refused. */
20
+ static async load(path, profile = "pq_hybrid") {
21
+ return new NodeKey(await native.keyLoad(path, profile));
22
+ }
23
+ /** The key at path, or a new one saved there when the file does not exist. */
24
+ static async loadOrCreate(path, profile = "pq_hybrid") {
25
+ try {
26
+ await access(path);
27
+ }
28
+ catch {
29
+ const key = await NodeKey.generate(profile);
30
+ await key.save(path);
31
+ return key;
32
+ }
33
+ return NodeKey.load(path, profile);
34
+ }
35
+ /** Writes the key to path, readable by its owner only. */
36
+ async save(path) {
37
+ await native.keySave(this.live(), path);
38
+ }
39
+ /** The key's 32-byte node_id. */
40
+ nodeId() {
41
+ return native.keyNodeId(this.live());
42
+ }
43
+ /** The node_id as lowercase hex. */
44
+ nodeIdHex() {
45
+ return hex(this.nodeId());
46
+ }
47
+ /** The public key as carried on the wire. */
48
+ publicKey() {
49
+ return native.keyPublicKey(this.live());
50
+ }
51
+ /** The key's profile. */
52
+ profile() {
53
+ return native.keyProfile(this.live());
54
+ }
55
+ /** Signs data as given. */
56
+ async sign(data) {
57
+ return native.keySign(this.live(), data);
58
+ }
59
+ /** Frees the native key. The NodeKey is unusable after. */
60
+ free() {
61
+ if (this.handle !== null)
62
+ native.keyFree(this.handle);
63
+ this.handle = null;
64
+ }
65
+ /** @internal */
66
+ live() {
67
+ if (this.handle === null)
68
+ throw new Error("macula-ts: this NodeKey was freed");
69
+ return this.handle;
70
+ }
71
+ }
72
+ //# sourceMappingURL=key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key.js","sourceRoot":"","sources":["../src/key.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,6EAA6E;AAC7E,4EAA4E;AAC5E,cAAc;AACd,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAe,MAAM,c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IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED,6CAA6C;IAC7C,SAAS;QACP,OAAO,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,yBAAyB;IACzB,OAAO;QACL,OAAO,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAY,CAAC;IACnD,CAAC;IAED,2BAA2B;IAC3B,KAAK,CAAC,IAAI,CAAC,IAAgB;QACzB,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,2DAA2D;IAC3D,IAAI;QACF,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI;YAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;IAED,gBAAgB;IAChB,IAAI;QACF,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QAC/E,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF"}
package/dist/pool.d.ts CHANGED
@@ -1,146 +1,182 @@
1
- import { Identity } from "./identity.js";
2
- import type { PubsubEvent } from "./pubsub.js";
3
- import { type BytesOutput, type JsonValue } from "./rpc.js";
4
- /** One configured connection target. */
1
+ import { type Handle } from "./binding.js";
2
+ import { NodeKey } from "./key.js";
3
+ import { Stream, StreamMode, type StreamRequest } from "./stream.js";
4
+ import { type BytesOutput, type Id, type JsonValue } from "./wire.js";
5
+ /** A station to link to, pinned by the node_id it must prove. */
5
6
  export interface Seed {
6
- host: string;
7
- port: number;
7
+ readonly host: string;
8
+ readonly port: number;
9
+ readonly nodeId: Id;
8
10
  }
9
11
  export interface PoolOptions {
10
- /** How many currently-live control links a publish() fans out to
11
- * before resolving -- partial success counts as success, matching
12
- * macula_client:publish/5's own documented semantics. Default 1.
13
- * NOT YET FULLY AT PARITY above 1: the Erlang reference stamps ONE
14
- * seq across every replica specifically so a receiver's own
15
- * (publisher, seq, topic) dedup collapses the redundant copies into
16
- * one event. This SDK's Session.publish() has no caller-supplied-seq
17
- * parameter to do the same (each call mints its own fresh seq), so
18
- * setting this above 1 would deliver N distinct, non-deduplicable
19
- * copies to every subscriber -- clamped to 1 until that's fixed. */
20
- replicationFactor?: number;
21
- /** How long a recorded (realm, publisher, seq, topic) key is treated
22
- * as a duplicate before it ages out. Default 60_000, matching the
23
- * Erlang reference's own `dedup_window_ms` default. */
24
- dedupWindowMs?: number;
25
- /** How often the dedup table is swept for expired entries. Default
26
- * 30_000, matching the Erlang reference's own `dedup_sweep_ms`. */
27
- dedupSweepMs?: number;
28
- /** How often a live control link is health-checked (see
29
- * #armHealthCheck's own doc for why publish() alone can't be trusted
30
- * to ever notice a dead connection). Default 10_000. */
31
- healthCheckIntervalMs?: number;
12
+ /** Each realm's key as carried (hex or bytes), by realm id: an
13
+ * advertisement in a realm is trusted only when its authorization verifies
14
+ * against it, and a procedure is served only in a realm it names. */
15
+ readonly realmTrust?: ReadonlyArray<{
16
+ readonly realm: Id;
17
+ readonly key: string | Uint8Array;
18
+ }>;
19
+ readonly replicationFactor?: number;
20
+ readonly maxDirectLinks?: number;
21
+ readonly respawnDelayMs?: number;
22
+ /** How long connect waits for a first link, 30 s by default. */
23
+ readonly timeoutMs?: number;
32
24
  }
33
- export interface PoolStatus {
34
- /** Seeds whose control link is currently connected. */
35
- healthyLinks: number;
36
- /** Seeds whose control link is not currently connected (connecting
37
- * or backing off). Every configured seed is exactly one or the
38
- * other -- a link backs off and retries forever, it is never given
39
- * up on and dropped from the pool, same as the Erlang reference. */
40
- failedLinks: number;
25
+ /** One of the pool's links. */
26
+ export interface LinkStatus {
27
+ readonly station: string;
28
+ readonly host: string;
29
+ readonly port: number;
30
+ readonly direct: boolean;
31
+ readonly up: boolean;
41
32
  }
42
- /** Thrown by publish()/call() when the pool has zero live control links
43
- * to try -- a distinct, identifiable condition from any one link's own
44
- * transient error, matching macula_client:publish/5's own `{error,
45
- * {transient, no_healthy_station}}`. */
46
- export declare class NoHealthyStationError extends Error {
47
- constructor();
33
+ /** A trusted provider of a procedure and the station it serves from. */
34
+ export interface Provider {
35
+ readonly node: string;
36
+ readonly station: string;
37
+ }
38
+ /** An event a subscription heard, verified. */
39
+ export interface Event {
40
+ readonly publisher: string;
41
+ readonly realm: string;
42
+ readonly topic: string;
43
+ readonly seq: number;
44
+ readonly publishedAt: number;
45
+ readonly payload: JsonValue;
46
+ readonly deliveredVia: string;
47
+ }
48
+ /** A served call's request. */
49
+ export interface Request {
50
+ readonly caller: string;
51
+ readonly realm: string;
52
+ readonly procedure: string;
53
+ readonly payload: JsonValue;
54
+ readonly deadlineMs: number;
55
+ }
56
+ /** A verified DHT record: its type, signer's key id, times, payload, and wire
57
+ * bytes (tagged). */
58
+ export interface DhtRecord {
59
+ readonly type: number;
60
+ readonly keyId: string;
61
+ readonly createdAt: number;
62
+ readonly expiresAt: number;
63
+ readonly payload: JsonValue;
64
+ readonly wire: JsonValue;
65
+ }
66
+ /** macula 12's record types. */
67
+ export declare enum RecordType {
68
+ NodeRecord = 1,
69
+ ProcedureAdvertisement = 6,
70
+ Tombstone = 12,
71
+ ContentAnnouncement = 17,
72
+ StationEndpoint = 18,
73
+ OrgDirectory = 21,
74
+ ProcedureDelegation = 22
75
+ }
76
+ /** A subscription, until stop() or the pool closes. */
77
+ export declare class Subscription {
78
+ private readonly handle;
79
+ readonly closed: Promise<string | null>;
80
+ /** @internal */
81
+ constructor(handle: Handle, closed: Promise<string | null>);
82
+ /** Ends the subscription on every link. */
83
+ stop(): Promise<void>;
84
+ }
85
+ /** A served procedure, until stop(). */
86
+ export declare class Served {
87
+ private readonly handle;
88
+ private stopped;
89
+ /** @internal */
90
+ constructor(handle: Handle);
91
+ /** Withdraws the procedure on every link. */
92
+ stop(): Promise<void>;
48
93
  }
49
- /**
50
- * A resilient multi-station client: live connections to every configured
51
- * seed held concurrently, each independently monitored and respawned
52
- * with backoff on disconnect, every tracked subscription re-established
53
- * automatically when its own link reconnects. See this module's own
54
- * header doc for the full design, why a "link" is a small role-scoped
55
- * session set rather than one Session, and its one deliberate deviation
56
- * from the Erlang reference (topic-scoped dedup).
57
- */
58
94
  export declare class Pool {
59
- #private;
95
+ private readonly handle;
96
+ private closed;
60
97
  private constructor();
61
- /** Dials the control role against every seed concurrently under
62
- * `controlIdentity` (the caller's own identity -- publish()/call()
63
- * are attributed to it on the wire) and resolves once every seed's
64
- * FIRST connect attempt has settled (success or a logged failure
65
- * headed into backoff) -- matches tapRoom()'s own "await the first
66
- * attempt, not the eventual outcome" reasoning (macula-mcp's
67
- * lobby_observer.ts): a caller that publishes/calls immediately
68
- * after connect() must not race links still mid-handshake. */
69
- static connect(seeds: Seed[], controlIdentity: Identity, opts?: PoolOptions): Promise<Pool>;
70
- /** Publishes to `replicationFactor` currently-live control links
71
- * (default 1); partial success counts as success. A link whose
72
- * publish attempt fails is marked for respawn immediately -- this is
73
- * this v1's only liveness signal for the control role, since it
74
- * cannot also carry a liveness-only subscribe (see this module's own
75
- * header doc). Throws NoHealthyStationError if zero links are live.
76
- *
77
- * `realm`/`payload` are validated before any link is touched. Found
78
- * live 2026-09-05: a malformed realm or an unserializable payload
79
- * throws inside session.publish() itself, well before any wire I/O --
80
- * treating that throw as evidence of a dead connection (the pre-fix
81
- * behavior) tore down a perfectly healthy link over a caller-side
82
- * argument bug. */
83
- publish(realm: string | undefined, topic: string, payload: JsonValue, opts?: {
98
+ /** Links the key's node to every seed, and resolves once one link is up. */
99
+ static connect(key: NodeKey, seeds: readonly Seed[], options?: PoolOptions): Promise<Pool>;
100
+ /** The node_id the pool links as. */
101
+ nodeId(): string;
102
+ /** name in this node's own namespace, `~<node_id>/<name>`: a procedure it
103
+ * serves with no org and no realm key, authorized by its advertisement's
104
+ * signature alone, and that any node calls with no realm key pinned. */
105
+ ownProcedure(name: string): string;
106
+ /** Every link the pool holds. */
107
+ status(): LinkStatus[];
108
+ /** Calls procedure in realm at a provider (any trusted one unless
109
+ * `provider` names one) by direct dial. A provider's ERROR is thrown as a
110
+ * ProviderError, a station's relay error as a RelayError. */
111
+ call(realm: Id, procedure: string, payload?: JsonValue, options?: {
112
+ provider?: Id;
113
+ timeoutMs?: number;
114
+ bytes?: BytesOutput;
115
+ }): Promise<JsonValue>;
116
+ /** The procedure's trusted providers, freshest first. */
117
+ providers(realm: Id, procedure: string, options?: {
118
+ timeoutMs?: number;
119
+ }): Promise<Provider[]>;
120
+ /** Publishes payload on topic in realm. Topics name a kind of fact; ids go
121
+ * in the payload. */
122
+ publish(realm: Id, topic: string, payload: JsonValue, options?: {
84
123
  ttlMs?: number;
85
124
  }): Promise<void>;
86
- /** Calls `procedure` against the pool's live control links in order
87
- * until one succeeds or all have been tried. Throws
88
- * NoHealthyStationError if zero links are live.
89
- *
90
- * `realm`/`payload`/`opts.bytes` are validated before any link is
91
- * touched, for the
92
- * same reason as publish() -- a malformed realm is a caller bug, not
93
- * evidence of a dead connection, and must never be attributed to one.
94
- *
95
- * A `MaculaCallError` (a real BOLT#4 response -- e.g.
96
- * unknown_next_peer, unauthorized, a procedure nobody serves, a gated
97
- * call this identity isn't authorized for) does NOT mark its link for
98
- * respawn: the connection plainly worked, it answered. call() still
99
- * falls through to the next link either way, matching the Erlang
100
- * reference's own keep_or_next (macula_client.erl) -- a non-idempotent
101
- * provider handler genuinely can be re-invoked on each live link this
102
- * reaches; that is parity with the reference, not a bug this fixes.
103
- *
104
- * Any OTHER thrown error (never a wire-level answer at all) is
105
- * ambiguous, not automatically a dead link: session.call()'s own
106
- * deadlineMs elapsing looks identical to a genuinely severed
107
- * connection, but means the far end is merely slow, not gone. Found
108
- * live 2026-09-05: treating every such error as a dead link meant one
109
- * slow provider response tore down and reconnected EVERY live control
110
- * link in turn as call() moved through them re-trying the same call.
111
- * #probeLiveness's own dedicated liveness call is the tiebreaker --
112
- * only a link that ALSO fails to get a wire-level answer on that
113
- * fresh probe is scheduled for reconnect. Each link's own `session`
114
- * reference is re-checked both before probing and before scheduling a
115
- * reconnect, in case a concurrent operation already superseded it. */
116
- call(realm: string | undefined, procedure: string, payload: JsonValue, opts?: {
125
+ /** Subscribes to topic in realm: onEvent hears each verified event once,
126
+ * however many links deliver it. `closed` resolves when the subscription
127
+ * ends, with why or null. */
128
+ subscribe(realm: Id, topic: string, onEvent: (event: Event) => void, options?: {
129
+ bytes?: BytesOutput;
130
+ }): Promise<Subscription>;
131
+ /** Serves procedure in realm: handler answers each call, and its thrown
132
+ * error goes back as a handler_error with its message. An org procedure
133
+ * needs the realm's key pinned and the org's delegation to this node in the
134
+ * DHT; a procedure in this node's own namespace (ownProcedure) needs
135
+ * neither, and another node's namespace is refused. */
136
+ serve(realm: Id, procedure: string, handler: (request: Request) => JsonValue | Promise<JsonValue>, options?: {
137
+ bytes?: BytesOutput;
138
+ }): Promise<Served>;
139
+ /** Serves procedure in realm as a stream of mode: handler drives each
140
+ * session. The stream is closed when the handler returns without ending
141
+ * it, aborted with code error when it throws, and released either way. */
142
+ serveStream(realm: Id, procedure: string, mode: StreamMode, handler: (stream: Stream, request: StreamRequest) => void | Promise<void>, options?: {
143
+ bytes?: BytesOutput;
144
+ }): Promise<Served>;
145
+ /** Opens a stream of mode on procedure in realm at a provider, by direct
146
+ * dial. A refusal arrives on its first recv(). */
147
+ openStream(realm: Id, procedure: string, mode: StreamMode, payload?: JsonValue, options?: {
148
+ provider?: Id;
117
149
  deadlineMs?: number;
150
+ timeoutMs?: number;
118
151
  bytes?: BytesOutput;
119
- }): Promise<JsonValue>;
120
- /** Subscribes `handler` to `(realm, topic)`: opens one subscribe-only
121
- * session against every configured seed, replayed automatically on
122
- * every future respawn. Mints a dedicated identity for this topic by
123
- * default (disposed on unsubscribe); pass `identity` to supply the
124
- * pool's own instead (e.g. for a stable, caller-controlled identity
125
- * across restarts, matching macula-mcp's own observeRoomIdentityPath
126
- * pattern) -- the pool never disposes an identity it didn't mint.
127
- * `opts.bytes` picks how bytes in each event's payload reach `handler`
128
- * (rpc.ts's BytesOutput), on every seed and after every respawn.
129
- * Returns an unsubscribe function. */
130
- subscribe(realm: string | undefined, topic: string, handler: (evt: PubsubEvent) => void, identity?: Identity, opts?: {
152
+ }): Promise<Stream>;
153
+ /** The verified record under key, or null when there is none. */
154
+ findRecord(key: Id, options?: {
155
+ timeoutMs?: number;
131
156
  bytes?: BytesOutput;
132
- }): Promise<() => Promise<void>>;
133
- /** Live/backing-off CONTROL link counts (publish/call reachability).
134
- * Every configured seed is exactly one or the other. Per-topic
135
- * subscription link health is not reflected here -- inspect a
136
- * specific subscription's own behavior (events arriving or not)
137
- * instead; exposing N independent per-topic health vectors here
138
- * would not simplify what a caller actually needs to know. */
139
- status(): PoolStatus;
140
- /** Closes every control and subscription link and disposes every
141
- * identity this pool owns (the caller-supplied control identity
142
- * included). Awaits each link's in-flight connect/reconnect first,
143
- * so a still-connecting link never has its identity yanked out from
144
- * under it. */
157
+ }): Promise<DhtRecord | null>;
158
+ /** Every verified record under key, and how many did not verify. */
159
+ findRecords(key: Id, options?: {
160
+ timeoutMs?: number;
161
+ bytes?: BytesOutput;
162
+ }): Promise<{
163
+ records: DhtRecord[];
164
+ dropped: number;
165
+ }>;
166
+ /** Every verified record of type the station holds, and how many did not
167
+ * verify. */
168
+ findRecordsByType(type: RecordType | number, options?: {
169
+ timeoutMs?: number;
170
+ bytes?: BytesOutput;
171
+ }): Promise<{
172
+ records: DhtRecord[];
173
+ dropped: number;
174
+ }>;
175
+ /** Puts a signed record's wire bytes in the DHT. */
176
+ putRecord(wire: Uint8Array, options?: {
177
+ timeoutMs?: number;
178
+ }): Promise<void>;
179
+ /** Closes every link and subscription. */
145
180
  close(): Promise<void>;
181
+ private live;
146
182
  }