@macula-io/ts 0.18.0 → 0.19.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/README.md CHANGED
@@ -19,11 +19,12 @@
19
19
 
20
20
  ---
21
21
 
22
- > **Status, 2026-09-24:** on the **macula 12** wire (post-quantum: ML-DSA-87
22
+ > **Status, 2026-09-26:** on the **macula 12** wire (post-quantum: ML-DSA-87
23
23
  > identities, ML-KEM hybrid key exchange, signed requests), over macula-go's
24
- > pool. Calls and streams by direct dial, serving, publish/subscribe and the
25
- > DHT are tested against in-process macula 12 stations on every `npm test`.
26
- > Content transfer and UCAN-gated calls are not here yet; see [Not yet
24
+ > pool. Calls and streams by direct dial, serving (under an org or in a node's
25
+ > own namespace), publish/subscribe, the DHT and node-served content are
26
+ > tested against in-process macula 12 stations on every `npm test`.
27
+ > UCAN-gated calls are not here yet; see [Not yet
27
28
  > implemented](#not-yet-implemented). Releases before 0.18.0 speak the retired
28
29
  > 10.x wire and cannot reach the current fleet.
29
30
 
@@ -160,17 +161,13 @@ a Promise; events, served calls and served streams reach JavaScript through a
160
161
  | Streams (`openStream`, `serveStream`) | ✅ | ✅ | Server, client and bidi; a QUIC stream per session, released on every path |
161
162
  | Publish/subscribe | ✅ | ✅ | Signed publications, delivered once across links |
162
163
  | DHT (`findRecord`, `findRecords`, `findRecordsByType`, `putRecord`) | ✅ | — | Records verified before they are handed on |
164
+ | Node-served content (`shareContent`, `unshareContent`, `getContent`) | ✅ | ✅ | macula 12.6.0 (D27): shared on the node's own `~<node_id>/content_v1` and announced; a fetch checks the block, the manifest and every chunk against the content id, bounded, with no realm key; `NotSharedError` / `ContentUnavailableError` |
163
165
 
164
166
  ## Not yet implemented
165
167
 
166
- - **Content transfer.** In macula 12 a station keeps no content; the node
167
- that shares it serves it. That protocol is being defined in macula
168
- (macula#35) and comes here with macula-go.
169
168
  - **UCAN-gated calls and serving.** macula 12 uses post-quantum UCANs
170
169
  (macula-go#2). Calls carry no token yet, and a gated procedure cannot be
171
170
  served.
172
- - **Serving without an org.** Self-named procedures (`~<node id>/<name>`),
173
- decided for macula 12, are not in macula or the stations yet.
174
171
 
175
172
  ## Testing
176
173
 
package/dist/binding.d.ts CHANGED
@@ -31,6 +31,9 @@ export declare const native: {
31
31
  poolFindRecords(pool: Handle, key: Uint8Array, timeoutMs: number, bytesMode: number): Promise<string>;
32
32
  poolFindRecordsByType(pool: Handle, type: number, timeoutMs: number, bytesMode: number): Promise<string>;
33
33
  poolPutRecord(pool: Handle, wire: Uint8Array, timeoutMs: number): Promise<void>;
34
+ poolShareContent(pool: Handle, realm: Uint8Array, data: Uint8Array, name: string, timeoutMs: number): Promise<Uint8Array>;
35
+ poolUnshareContent(pool: Handle, realm: Uint8Array, mcid: Uint8Array, timeoutMs: number): Promise<void>;
36
+ poolGetContent(pool: Handle, realm: Uint8Array, mcid: Uint8Array, maxBytes: number, maxChunks: number, parallel: number, chunkTimeoutMs: number, timeoutMs: number): Promise<Uint8Array>;
34
37
  poolServe(pool: Handle, realm: Uint8Array, procedure: string, bytesMode: number, listener: Listener): Promise<Handle>;
35
38
  poolServeStream(pool: Handle, realm: Uint8Array, procedure: string, mode: number, bytesMode: number, listener: Listener): Promise<Handle>;
36
39
  pendingReply(pending: Handle, resultJson: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"binding.js","sourceRoot":"","sources":["../src/binding.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,oEAAoE;AACpE,4EAA4E;AAC5E,2EAA2E;AAC3E,0EAA0E;AAC1E,yBAAyB;AACzB,EAAE;AACF,4EAA4E;AAC5E,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,CAAC,CAAC;AAgBrE,8DAA8D;AAC9D,MAAM,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CA2CvD,CAAC"}
1
+ {"version":3,"file":"binding.js","sourceRoot":"","sources":["../src/binding.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,oEAAoE;AACpE,4EAA4E;AAC5E,2EAA2E;AAC3E,0EAA0E;AAC1E,yBAAyB;AACzB,EAAE;AACF,4EAA4E;AAC5E,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,CAAC,CAAC;AAgBrE,8DAA8D;AAC9D,MAAM,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CA+CvD,CAAC"}
package/dist/content.d.ts CHANGED
@@ -1,14 +1,33 @@
1
- /** Thrown by Session.getContent() when the station reports the content
2
- * isn't known to it (macula-go's content.ErrNotFound) -- an expected,
3
- * routine outcome for a transfer mechanism with no durability
4
- * guarantee, not a transport failure. Unlike DhtRecord's findRecord()
5
- * (which resolves `null` for its own equivalent "not found" case),
6
- * getContent() throws instead: its whole contract is "hand back the
7
- * bytes or fail", and there is no sensible non-throwing value to return
8
- * in place of the `Uint8Array` a caller asked for. */
9
- export declare class ContentNotFoundError extends Error {
10
- /** The mcid that produced this error, hex-encoded (the same string
11
- * that was passed to getContent()). */
12
- readonly mcid: string;
13
- constructor(mcid: string);
1
+ /** A content id (MCID): 50 bytes, tag 2 (SHA-384), a codec byte (0x55 a raw
2
+ * block of at most 256 KiB, 0x56 a manifest over 256 KiB chunks) and the
3
+ * 48-byte hash. Given as 100 hex characters or 50 bytes. */
4
+ export type Mcid = string | Uint8Array;
5
+ /** A content id as the 50 bytes the native layer takes. */
6
+ export declare function mcid50(mcid: Mcid): Uint8Array;
7
+ /** Bounds on one fetch; each defaults as macula's does. */
8
+ export interface ContentOptions {
9
+ /** Largest content accepted, 256 MiB by default. */
10
+ readonly maxBytes?: number;
11
+ /** Most chunks a manifest may have, 16,384 by default. */
12
+ readonly maxChunks?: number;
13
+ /** Chunk streams open at once, 4 by default. */
14
+ readonly parallel?: number;
15
+ /** Deadline of one stream, 15 s by default. */
16
+ readonly chunkTimeoutMs?: number;
17
+ /** Deadline of the whole fetch, 5 minutes by default. */
18
+ readonly timeoutMs?: number;
14
19
  }
20
+ /** Content no node announces in the realm. */
21
+ export declare class NotSharedError extends Error {
22
+ constructor();
23
+ }
24
+ /** Content every announcing node failed to give; `detail` names each failure
25
+ * (unreachable, not the content asked for, over the bounds, ...). */
26
+ export declare class ContentUnavailableError extends Error {
27
+ readonly detail: string;
28
+ constructor(detail: string);
29
+ }
30
+ /** The native layer's content errors, as the classes they name. */
31
+ export declare function contentError(e: unknown): Error;
32
+ /** How long a whole fetch waits when not told: 5 minutes. */
33
+ export declare const DEFAULT_CONTENT_TIMEOUT_MS = 300000;
package/dist/content.js CHANGED
@@ -1,45 +1,46 @@
1
- // Content transfer -- macula-go's content package (Put/Get), thin
2
- // CALL/RESULT wrappers to reserved `_content.*` procedures sent on
3
- // their OWN dedicated QUIC stream (Session.OpenDedicatedStream on the
4
- // Go side), NOT the shared control stream call()/serve()/the DHT
5
- // methods/subscribe() all read from -- see cabi/content.go's own doc
6
- // for why Session.putContent()/getContent() (session.ts) are, unlike
7
- // those, never subject to Session's same-Session exclusivity guard, and
8
- // why two concurrent putContent()/getContent() calls on one Session
9
- // don't race each other either (each gets its own fresh dedicated
10
- // stream).
11
- //
12
- // IMPORTANT: this is a one-time TRANSFER mechanism, not durable object
13
- // storage. A station may forget content after serving it, there is no
14
- // "list what's stored here" operation, and there is no "delete"
15
- // operation -- putContent()/getContent() hand a blob to a peer once,
16
- // they do not give you a key-value store. Do not build anything on this
17
- // SDK that assumes content survives indefinitely, or that a station is
18
- // obligated to keep serving something it once accepted.
19
- //
20
- // mcid crosses the FFI boundary as a lowercase hex string (68 hex
21
- // chars = 34 bytes: <<Version:8, Codec:8, Hash:32/binary>>, macula-go's
22
- // manifest.Mcid) -- the same "raw byte identifier -> hex string"
23
- // convention DhtRecord's key/version/signature already use (dht.ts),
24
- // deliberately NOT rpc.ts's own "0x"-prefixed convention for bytes
25
- // embedded *inside* a JSON payload -- an mcid stands on its own here,
26
- // it isn't a payload field.
27
- /** Thrown by Session.getContent() when the station reports the content
28
- * isn't known to it (macula-go's content.ErrNotFound) -- an expected,
29
- * routine outcome for a transfer mechanism with no durability
30
- * guarantee, not a transport failure. Unlike DhtRecord's findRecord()
31
- * (which resolves `null` for its own equivalent "not found" case),
32
- * getContent() throws instead: its whole contract is "hand back the
33
- * bytes or fail", and there is no sensible non-throwing value to return
34
- * in place of the `Uint8Array` a caller asked for. */
35
- export class ContentNotFoundError extends Error {
36
- /** The mcid that produced this error, hex-encoded (the same string
37
- * that was passed to getContent()). */
38
- mcid;
39
- constructor(mcid) {
40
- super(`macula-ts: no content found for mcid ${mcid}`);
41
- this.name = "ContentNotFoundError";
42
- this.mcid = mcid;
1
+ // Node-served content (macula 12.6.0, D27): a node shares content by serving
2
+ // it on its own ~<node_id>/content_v1 and announcing it in the DHT; a fetch
3
+ // finds the announcements, dials each sharer through the station it names, and
4
+ // checks the block, the manifest and every chunk against the content id it
5
+ // asked for, so it trusts no sharer and needs no realm key.
6
+ /** A content id as the 50 bytes the native layer takes. */
7
+ export function mcid50(mcid) {
8
+ if (typeof mcid === "string") {
9
+ if (!/^[0-9a-fA-F]{100}$/.test(mcid))
10
+ throw new Error("macula-ts: a content id is 100 hex characters (50 bytes)");
11
+ return Uint8Array.from(Buffer.from(mcid, "hex"));
43
12
  }
13
+ if (mcid.length !== 50)
14
+ throw new Error(`macula-ts: a content id is 50 bytes, got ${mcid.length}`);
15
+ return mcid;
44
16
  }
17
+ /** Content no node announces in the realm. */
18
+ export class NotSharedError extends Error {
19
+ constructor() {
20
+ super("macula-ts: no node shares that content in that realm");
21
+ this.name = "NotSharedError";
22
+ }
23
+ }
24
+ /** Content every announcing node failed to give; `detail` names each failure
25
+ * (unreachable, not the content asked for, over the bounds, ...). */
26
+ export class ContentUnavailableError extends Error {
27
+ detail;
28
+ constructor(detail) {
29
+ super(`macula-ts: no sharer gave the content: ${detail}`);
30
+ this.detail = detail;
31
+ this.name = "ContentUnavailableError";
32
+ }
33
+ }
34
+ /** The native layer's content errors, as the classes they name. */
35
+ export function contentError(e) {
36
+ const message = e instanceof Error ? e.message : String(e);
37
+ if (message === "not_shared")
38
+ return new NotSharedError();
39
+ const unavailable = /^unavailable:([\s\S]*)$/.exec(message);
40
+ if (unavailable)
41
+ return new ContentUnavailableError(unavailable[1] ?? "");
42
+ return e instanceof Error ? e : new Error(message);
43
+ }
44
+ /** How long a whole fetch waits when not told: 5 minutes. */
45
+ export const DEFAULT_CONTENT_TIMEOUT_MS = 300_000;
45
46
  //# sourceMappingURL=content.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"content.js","sourceRoot":"","sources":["../src/content.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,mEAAmE;AACnE,sEAAsE;AACtE,iEAAiE;AACjE,qEAAqE;AACrE,qEAAqE;AACrE,wEAAwE;AACxE,oEAAoE;AACpE,kEAAkE;AAClE,WAAW;AACX,EAAE;AACF,uEAAuE;AACvE,sEAAsE;AACtE,gEAAgE;AAChE,qEAAqE;AACrE,wEAAwE;AACxE,uEAAuE;AACvE,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B,YAAqB,MAAc;QACjC,KAAK,CAAC,0CAA0C,MAAM,EAAE,CAAC,CAAC;sBADvC,MAAM;QAEzB,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF;AAED,mEAAmE;AACnE,MAAM,UAAU,YAAY,CAAC,CAAU;IACrC,MAAM,OAAO,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC3D,IAAI,OAAO,KAAK,YAAY;QAAE,OAAO,IAAI,cAAc,EAAE,CAAC;IAC1D,MAAM,WAAW,GAAG,yBAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5D,IAAI,WAAW;QAAE,OAAO,IAAI,uBAAuB,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1E,OAAO,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AACrD,CAAC;AAED,6DAA6D;AAC7D,MAAM,CAAC,MAAM,0BAA0B,GAAG,OAAO,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { NodeKey, type Profile } from "./key.js";
2
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 { NotSharedError, ContentUnavailableError, DEFAULT_CONTENT_TIMEOUT_MS, type ContentOptions, type Mcid, } from "./content.js";
3
4
  export { Stream, StreamMode, type StreamEvent, type StreamRequest } from "./stream.js";
4
5
  export { ProviderError, RelayError, StreamError, DEFAULT_CALL_TIMEOUT_MS, type JsonValue, type BytesOutput, type Id, } from "./wire.js";
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // @macula-io/ts: the macula 12 mesh from TypeScript, over macula-go.
2
2
  export { NodeKey } from "./key.js";
3
3
  export { Pool, Subscription, Served, RecordType, } from "./pool.js";
4
+ export { NotSharedError, ContentUnavailableError, DEFAULT_CONTENT_TIMEOUT_MS, } from "./content.js";
4
5
  export { Stream, StreamMode } from "./stream.js";
5
6
  export { ProviderError, RelayError, StreamError, DEFAULT_CALL_TIMEOUT_MS, } from "./wire.js";
6
7
  //# 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,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"}
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,EACL,cAAc,EACd,uBAAuB,EACvB,0BAA0B,GAG3B,MAAM,cAAc,CAAC;AACtB,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/pool.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { type Handle } from "./binding.js";
2
2
  import { NodeKey } from "./key.js";
3
3
  import { Stream, StreamMode, type StreamRequest } from "./stream.js";
4
+ import { type ContentOptions, type Mcid } from "./content.js";
4
5
  import { type BytesOutput, type Id, type JsonValue } from "./wire.js";
5
6
  /** A station to link to, pinned by the node_id it must prove. */
6
7
  export interface Seed {
@@ -172,6 +173,23 @@ export declare class Pool {
172
173
  records: DhtRecord[];
173
174
  dropped: number;
174
175
  }>;
176
+ /** Shares data in realm: this node keeps it, serves it on its own
177
+ * `~<node_id>/content_v1` and announces it, renewing the announcement until
178
+ * unshareContent or close. Data of at most 256 KiB is one raw block; larger
179
+ * data a manifest over 256 KiB chunks, named name. Resolves to the content
180
+ * id as hex. Serving needs stations that admit a node's own namespace. */
181
+ shareContent(realm: Id, data: Uint8Array, name?: string, options?: {
182
+ timeoutMs?: number;
183
+ }): Promise<string>;
184
+ /** Stops sharing mcid in realm and withdraws its announcement. */
185
+ unshareContent(realm: Id, mcid: Mcid, options?: {
186
+ timeoutMs?: number;
187
+ }): Promise<void>;
188
+ /** Fetches the content mcid names in realm from a node that shares it,
189
+ * checked against mcid; no realm key is needed. Content nobody announces is
190
+ * a NotSharedError, content every sharer failed to give a
191
+ * ContentUnavailableError. */
192
+ getContent(realm: Id, mcid: Mcid, options?: ContentOptions): Promise<Uint8Array>;
175
193
  /** Puts a signed record's wire bytes in the DHT. */
176
194
  putRecord(wire: Uint8Array, options?: {
177
195
  timeoutMs?: number;
package/dist/pool.js CHANGED
@@ -7,6 +7,7 @@
7
7
  // pinned.
8
8
  import { native } from "./binding.js";
9
9
  import { Stream } from "./stream.js";
10
+ import { DEFAULT_CONTENT_TIMEOUT_MS, contentError, mcid50 } from "./content.js";
10
11
  import { DEFAULT_CALL_TIMEOUT_MS, bytesModeFor, callError, hex, id32, } from "./wire.js";
11
12
  /** macula 12's record types. */
12
13
  export var RecordType;
@@ -178,6 +179,31 @@ export class Pool {
178
179
  async findRecordsByType(type, options = {}) {
179
180
  return toRecords(JSON.parse(await native.poolFindRecordsByType(this.live(), type, options.timeoutMs ?? DEFAULT_CALL_TIMEOUT_MS, bytesModeFor(options.bytes))));
180
181
  }
182
+ /** Shares data in realm: this node keeps it, serves it on its own
183
+ * `~<node_id>/content_v1` and announces it, renewing the announcement until
184
+ * unshareContent or close. Data of at most 256 KiB is one raw block; larger
185
+ * data a manifest over 256 KiB chunks, named name. Resolves to the content
186
+ * id as hex. Serving needs stations that admit a node's own namespace. */
187
+ async shareContent(realm, data, name = "", options = {}) {
188
+ return hex(await native.poolShareContent(this.live(), id32(realm, "realm"), data, name, options.timeoutMs ?? DEFAULT_CALL_TIMEOUT_MS));
189
+ }
190
+ /** Stops sharing mcid in realm and withdraws its announcement. */
191
+ async unshareContent(realm, mcid, options = {}) {
192
+ await native.poolUnshareContent(this.live(), id32(realm, "realm"), mcid50(mcid), options.timeoutMs ?? DEFAULT_CALL_TIMEOUT_MS);
193
+ }
194
+ /** Fetches the content mcid names in realm from a node that shares it,
195
+ * checked against mcid; no realm key is needed. Content nobody announces is
196
+ * a NotSharedError, content every sharer failed to give a
197
+ * ContentUnavailableError. */
198
+ async getContent(realm, mcid, options = {}) {
199
+ const asked = mcid50(mcid);
200
+ try {
201
+ return await native.poolGetContent(this.live(), id32(realm, "realm"), asked, options.maxBytes ?? 0, options.maxChunks ?? 0, options.parallel ?? 0, options.chunkTimeoutMs ?? 0, options.timeoutMs ?? DEFAULT_CONTENT_TIMEOUT_MS);
202
+ }
203
+ catch (e) {
204
+ throw contentError(e);
205
+ }
206
+ }
181
207
  /** Puts a signed record's wire bytes in the DHT. */
182
208
  async putRecord(wire, options = {}) {
183
209
  await native.poolPutRecord(this.live(), wire, options.timeoutMs ?? DEFAULT_CALL_TIMEOUT_MS);
package/dist/pool.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pool.js","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,6EAA6E;AAC7E,8EAA8E;AAC9E,yEAAyE;AACzE,4EAA4E;AAC5E,0EAA0E;AAC1E,UAAU;AACV,OAAO,EAAE,MAAM,EAA8B,MAAM,cAAc,CAAC;AAElE,OAAO,EAAE,MAAM,EAA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C;AAED,SAAS,QAAQ,CAAC,CAAM;IACtB,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO;QAC1G,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC;AAED,SAAS,SAAS,CAAC,GAAQ;IACzB,OAAO,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,CAAC,EAAE,CAAC;AACnF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@macula-io/ts",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "TypeScript SDK for the Macula mesh (FFI over macula-go)",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -44,7 +44,8 @@
44
44
  "build:go": "go env -w CGO_ENABLED=1 && cd cabi && go mod tidy && go build -trimpath -buildvcs=false -buildmode=c-archive -o build/libmacula.a .",
45
45
  "build:addon:dev": "npm run build:go && node-gyp rebuild",
46
46
  "build:prebuilds": "npm run build:go && prebuildify --napi --strip && npm pkg delete scripts.install",
47
- "build": "npm run build:addon:dev && tsc",
47
+ "build:ts": "rm -rf dist && tsc",
48
+ "build": "npm run build:addon:dev && npm run build:ts",
48
49
  "test": "npm run build:teststation && vitest run",
49
50
  "test:live": "MACULA_TS_LIVE=1 vitest run src/fleet.live.test.ts",
50
51
  "typecheck": "tsc --noEmit",
package/dist/dht.d.ts DELETED
@@ -1,55 +0,0 @@
1
- import type { JsonValue } from "./rpc.js";
2
- /** Record type tags -- macula-go's dht.Type* constants (dht/record.go).
3
- * There is no client-side constructor for StationEndpoint in macula-go
4
- * (stations publish those themselves, not clients) -- it's listed here
5
- * because Session.findRecord/findRecords/findRecordsByType can still
6
- * return one, not because a Session.putRecord* method can build one. */
7
- export declare enum DhtRecordType {
8
- ProcedureAdvertisement = 6,
9
- ContentAnnouncement = 17,
10
- StationEndpoint = 18
11
- }
12
- /** A signed, TTL'd DHT record envelope -- mirrors macula-go's dht.Record
13
- * (dht/record.go). `key`/`version`/`signature` are raw bytes with no
14
- * native JSON shape, so they cross the FFI boundary as lowercase hex
15
- * strings -- deliberately NOT rpc.ts's own "0x"-prefixed convention for
16
- * bytes embedded inside a payload (see cabi/dht.go's own doc for why:
17
- * these three fields never go through jsonToCbor/cborToJSON at all,
18
- * wirevalue.go's "0x"-hex convention is specifically for bytes found
19
- * *inside* a cbor.Value payload, which these aren't). `payload` DID go
20
- * through that conversion (it's the record's own cbor.Value map) and
21
- * follows rpc.ts's JsonValue rules exactly like a CALL payload does --
22
- * no boolean, embedded bytes always as "0x"-prefixed hex (the DHT
23
- * methods take no `bytes` option). Note that a
24
- * procedure_advertisement/content_announcement's own advertiser_node/
25
- * serving_station/announcer_node/mcid payload fields are themselves raw
26
- * bytes on the wire (CBOR byte strings) but surface here as the SAME
27
- * "0x"-prefixed hex JsonValue strings cborToJSON gives any embedded
28
- * bytes -- consistent with every other payload field this SDK decodes,
29
- * just called out since they look similar to this record's own
30
- * top-level key/version/signature while following the other convention.
31
- *
32
- * This SDK does not verify a record's signature or check its expiry on
33
- * the caller's behalf (matching macula-go's own FindRecord/FindRecords/
34
- * FindRecordsByType, which say the same in their own doc comments) --
35
- * a caller that needs to trust a record's payload must check both
36
- * itself (against `key`, `signature`, and `expiresAt`) before relying
37
- * on it. */
38
- export interface DhtRecord {
39
- readonly type: DhtRecordType | number;
40
- /** Hex-encoded, 32 bytes: the envelope signer's Ed25519 public key. */
41
- readonly key: string;
42
- /** Hex-encoded, 16 bytes: a UUIDv7. */
43
- readonly version: string;
44
- /** Milliseconds since epoch. */
45
- readonly createdAt: number;
46
- /** Milliseconds since epoch. */
47
- readonly expiresAt: number;
48
- readonly payload: JsonValue;
49
- /** Hex-encoded, 64 bytes. */
50
- readonly signature: string;
51
- }
52
- /** Default TTL for a record built by Session.putProcedureAdvertisement()/
53
- * putContentAnnouncement() when the caller doesn't specify one --
54
- * matches macula-go's dht.DefaultTTL (48h). */
55
- export declare const DHT_DEFAULT_TTL_MS: number;
package/dist/dht.js DELETED
@@ -1,25 +0,0 @@
1
- // DHT record shapes -- macula-go's dht package (FindRecord/FindRecords/
2
- // FindRecordsByType/PutRecord), thin CALL wrappers to the mesh's own
3
- // reserved `_dht.*` procedures under the DHT's own all-zero realm
4
- // (threaded internally by macula-go's dht package, never passed from
5
- // here -- see cabi/dht.go). Session (session.ts) is the actual FFI
6
- // entry point for these, matching call()/serve()'s own shape (a
7
- // Session-bound method, using that Session's own retained Identity to
8
- // sign); this file holds the shapes both directions share, the same
9
- // split rpc.ts has for call()/serve().
10
- /** Record type tags -- macula-go's dht.Type* constants (dht/record.go).
11
- * There is no client-side constructor for StationEndpoint in macula-go
12
- * (stations publish those themselves, not clients) -- it's listed here
13
- * because Session.findRecord/findRecords/findRecordsByType can still
14
- * return one, not because a Session.putRecord* method can build one. */
15
- export var DhtRecordType;
16
- (function (DhtRecordType) {
17
- DhtRecordType[DhtRecordType["ProcedureAdvertisement"] = 6] = "ProcedureAdvertisement";
18
- DhtRecordType[DhtRecordType["ContentAnnouncement"] = 17] = "ContentAnnouncement";
19
- DhtRecordType[DhtRecordType["StationEndpoint"] = 18] = "StationEndpoint";
20
- })(DhtRecordType || (DhtRecordType = {}));
21
- /** Default TTL for a record built by Session.putProcedureAdvertisement()/
22
- * putContentAnnouncement() when the caller doesn't specify one --
23
- * matches macula-go's dht.DefaultTTL (48h). */
24
- export const DHT_DEFAULT_TTL_MS = 48 * 60 * 60 * 1000;
25
- //# sourceMappingURL=dht.js.map
package/dist/dht.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"dht.js","sourceRoot":"","sources":["../src/dht.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,qEAAqE;AACrE,kEAAkE;AAClE,qEAAqE;AACrE,mEAAmE;AACnE,gEAAgE;AAChE,sEAAsE;AACtE,oEAAoE;AACpE,uCAAuC;AAIvC;;;;wEAIwE;AACxE,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,qFAA6B,CAAA;IAC7B,gFAA0B,CAAA;IAC1B,wEAAsB,CAAA;AACxB,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AA2CD;;+CAE+C;AAC/C,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC"}
@@ -1,79 +0,0 @@
1
- import type { CallOptions, Session } from "./session.js";
2
- /** What Session.resolveDirect() resolves with: `procedure`'s
3
- * currently-advertised serving station and its dialable host/port
4
- * (macula-go's `directdial.Resolve`). */
5
- export interface DirectDialTarget {
6
- /** Hex-encoded, 32 bytes: the resolved station's NodeID (Ed25519
7
- * public key) -- the SAME identity Session.callDirect()/
8
- * callDirectWithUcan() pin the one-hop dial against internally before
9
- * trusting it. */
10
- readonly station: string;
11
- readonly host: string;
12
- readonly port: number;
13
- }
14
- /** Options for Session.advertiseDirect(). */
15
- export interface AdvertiseDirectOptions {
16
- /** Same 64-character hex realm convention as CallOptions.realm --
17
- * MUST match whatever realm resolveDirect()/callDirect()/
18
- * callDirectWithUcan() (or the Erlang/Rust/Go equivalent) resolve
19
- * under, or the two sides derive a different discovery URI and resolve
20
- * comes back exactly as if this was never called at all (see
21
- * directdial.go's own DiscoveryURI note). Omitted means the all-zero
22
- * realm, this SDK's sole default before this option existed. */
23
- realm?: string;
24
- /** Milliseconds. Defaults to DHT_DEFAULT_TTL_MS (48h) -- matches
25
- * macula-go's own dht.DefaultTTL, applied Go-side for ttlMs<=0 (not
26
- * duplicated as a second default here; this SDK's default is threaded
27
- * through explicitly instead, matching putProcedureAdvertisement's own
28
- * convention). */
29
- ttlMs?: number;
30
- }
31
- /** How long keepAdvertisedDirect() waits between re-advertise ticks, in
32
- * milliseconds, when opts.intervalMs is left unset. This is a real
33
- * production margin against AdvertiseDirectOptions' own 48h default TTL
34
- * actually expiring between ticks -- not chosen to match macula-go's own
35
- * KeepAdvertisedDirect live-test interval (1s there, only to keep that
36
- * particular test fast). A caller passing a much shorter `ttlMs` should
37
- * pass a correspondingly shorter `intervalMs` too; this constant does not
38
- * scale itself to `opts.ttlMs`. */
39
- export declare const KEEP_ADVERTISED_DIRECT_INTERVAL_MS: number;
40
- /** Options for keepAdvertisedDirect(). */
41
- export interface KeepAdvertisedDirectOptions extends AdvertiseDirectOptions {
42
- /** Milliseconds between re-advertise ticks. Defaults to
43
- * KEEP_ADVERTISED_DIRECT_INTERVAL_MS. */
44
- intervalMs?: number;
45
- /** Called with a tick's own thrown error when a re-advertise tick
46
- * fails -- a network blip, a genuinely dead session, etc. Matches
47
- * macula-go's own KeepAdvertisedDirect: a failed tick is reported, not
48
- * fatal -- this loop tries again at the next interval regardless, and
49
- * cannot detect or repair a dead Session on its own (a separate, larger
50
- * concern this does not attempt to solve). Omit to drop the error
51
- * silently. */
52
- onError?: (err: unknown) => void;
53
- }
54
- /** Re-advertises `procedure` as direct-dial-reachable on `session` (via
55
- * `session.advertiseDirect()`) immediately, then again every
56
- * `opts.intervalMs`, until the returned `stop()` is called -- macula-go's
57
- * own `KeepAdvertisedDirect` free function, ported here as a standalone
58
- * helper rather than a Session method for the identical reason
59
- * macula-go's own is a free function taking a `*connection.Session`
60
- * rather than a method on one: a station's registration for a procedure
61
- * does not survive the connection that sent it being replaced, so a
62
- * long-lived provider needs to call `AdvertiseDirect` again on its own
63
- * schedule, and it is this function's CALLER's job to decide WHICH
64
- * Session that runs on. See `Session.advertiseDirect()`'s own doc for why
65
- * that must NOT be a Session with an active `serve()` on it
66
- * (`advertiseDirect()`'s own `PutRecord` CALL would race `serve()`'s own
67
- * reads of the same shared control stream): a long-lived provider that
68
- * also serves `procedure` needs a SEPARATE Session (and identity -- this
69
- * fleet enforces one connection per identity, kicking whichever connects
70
- * second) for that, passed here instead of the serving Session.
71
- *
72
- * The returned `stop()` is synchronous -- unlike `Session.serve()`'s own
73
- * async `stop()`, there is no pending tick to wait out and no unadvertise
74
- * step: `advertiseDirect()`'s own DHT record simply expires on its own
75
- * TTL once ticks stop, matching macula-go's own `KeepAdvertisedDirect`,
76
- * which has no corresponding "undo" either. Calling `stop()` more than
77
- * once is a no-op. */
78
- export declare function keepAdvertisedDirect(session: Session, procedure: string, opts?: KeepAdvertisedDirectOptions): () => void;
79
- export type { CallOptions };
@@ -1,76 +0,0 @@
1
- // Direct-dial: caller-side resolve+one-hop-call and provider-side
2
- // advertise-direct, built on macula-go's directdial package (see
3
- // cabi/directdial.go's own doc for the trust model -- every candidate
4
- // procedure_advertisement must carry a valid signature before its
5
- // serving_station is trusted at all, the resolved station_endpoint must
6
- // be signed by the station itself, and after the one-hop dial -- which
7
- // trusts neither the TLS certificate nor nothing -- the freshly connected
8
- // peer's own HELLO-proven identity is checked against the exact pubkey
9
- // the signed DHT chain resolved, application-layer pinning instead of
10
- // relying on the dial's own TLS -- and for why AdvertiseDirect publishes
11
- // BOTH a plain ADVERTISE and a signed procedure_advertisement DHT record:
12
- // skipping the plain ADVERTISE lets resolve+dial complete cleanly against
13
- // a station with nothing registered to route the CALL to, a real bug
14
- // macula-go fixed live 2026-08-30). The actual FFI plumbing lives on
15
- // Session (session.ts's resolveDirect/callDirect/callDirectWithUcan/
16
- // advertiseDirect), matching this SDK's own call()/serve() split; this
17
- // file holds the shapes those share, plus keepAdvertisedDirect -- a
18
- // standalone helper mirroring macula-go's own free-function
19
- // KeepAdvertisedDirect, not a Session method (see its own doc for why).
20
- /** How long keepAdvertisedDirect() waits between re-advertise ticks, in
21
- * milliseconds, when opts.intervalMs is left unset. This is a real
22
- * production margin against AdvertiseDirectOptions' own 48h default TTL
23
- * actually expiring between ticks -- not chosen to match macula-go's own
24
- * KeepAdvertisedDirect live-test interval (1s there, only to keep that
25
- * particular test fast). A caller passing a much shorter `ttlMs` should
26
- * pass a correspondingly shorter `intervalMs` too; this constant does not
27
- * scale itself to `opts.ttlMs`. */
28
- export const KEEP_ADVERTISED_DIRECT_INTERVAL_MS = 15 * 60 * 1000;
29
- /** Re-advertises `procedure` as direct-dial-reachable on `session` (via
30
- * `session.advertiseDirect()`) immediately, then again every
31
- * `opts.intervalMs`, until the returned `stop()` is called -- macula-go's
32
- * own `KeepAdvertisedDirect` free function, ported here as a standalone
33
- * helper rather than a Session method for the identical reason
34
- * macula-go's own is a free function taking a `*connection.Session`
35
- * rather than a method on one: a station's registration for a procedure
36
- * does not survive the connection that sent it being replaced, so a
37
- * long-lived provider needs to call `AdvertiseDirect` again on its own
38
- * schedule, and it is this function's CALLER's job to decide WHICH
39
- * Session that runs on. See `Session.advertiseDirect()`'s own doc for why
40
- * that must NOT be a Session with an active `serve()` on it
41
- * (`advertiseDirect()`'s own `PutRecord` CALL would race `serve()`'s own
42
- * reads of the same shared control stream): a long-lived provider that
43
- * also serves `procedure` needs a SEPARATE Session (and identity -- this
44
- * fleet enforces one connection per identity, kicking whichever connects
45
- * second) for that, passed here instead of the serving Session.
46
- *
47
- * The returned `stop()` is synchronous -- unlike `Session.serve()`'s own
48
- * async `stop()`, there is no pending tick to wait out and no unadvertise
49
- * step: `advertiseDirect()`'s own DHT record simply expires on its own
50
- * TTL once ticks stop, matching macula-go's own `KeepAdvertisedDirect`,
51
- * which has no corresponding "undo" either. Calling `stop()` more than
52
- * once is a no-op. */
53
- export function keepAdvertisedDirect(session, procedure, opts = {}) {
54
- const intervalMs = opts.intervalMs ?? KEEP_ADVERTISED_DIRECT_INTERVAL_MS;
55
- let stopped = false;
56
- const tick = () => {
57
- session.advertiseDirect(procedure, { realm: opts.realm, ttlMs: opts.ttlMs }).catch((err) => {
58
- opts.onError?.(err);
59
- });
60
- };
61
- tick();
62
- const timer = setInterval(tick, intervalMs);
63
- // Node keeps the event loop alive for a pending timer by default --
64
- // unref() so a program that starts this loop with nothing else keeping
65
- // it running (no active serve()/subscribe()/etc. elsewhere) can still
66
- // exit on its own; a real, still-open Session doing other work keeps
67
- // the process alive on its own merits regardless, unaffected by this.
68
- timer.unref?.();
69
- return () => {
70
- if (stopped)
71
- return;
72
- stopped = true;
73
- clearInterval(timer);
74
- };
75
- }
76
- //# sourceMappingURL=directdial.js.map