@macula-io/ts 0.18.0 → 0.20.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,13 @@
19
19
 
20
20
  ---
21
21
 
22
- > **Status, 2026-09-24:** on the **macula 12** wire (post-quantum: ML-DSA-87
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
22
+ > **Status, 2026-09-26:** on the **macula 12** wire (post-quantum: ML-DSA-87
23
+ > identities, as the ML-DSA-87 + RSA-PSS-4096 composite in `pq_hybrid`, the
24
+ > fleet's profile; ML-KEM hybrid key exchange; signed requests), over macula-go's
25
+ > pool. Calls and streams by direct dial, serving (under an org or in a node's
26
+ > own namespace), publish/subscribe, the DHT and node-served content are
27
+ > tested against in-process macula 12 stations on every `npm test`.
28
+ > UCAN-gated calls are not here yet; see [Not yet
27
29
  > implemented](#not-yet-implemented). Releases before 0.18.0 speak the retired
28
30
  > 10.x wire and cannot reach the current fleet.
29
31
 
@@ -59,7 +61,7 @@ that's actually usable for this today:
59
61
 
60
62
  macula-go, macula-rust, macula-dotnet, and macula-php have all already
61
63
  proven this protocol works and are actively maintained. Rather than
62
- reimplement QUIC, post-quantum TLS, deterministic CBOR and signed frames a fifth time in a
64
+ reimplement QUIC, TLS 1.3 with a hybrid post-quantum key exchange, deterministic CBOR and signed frames a fifth time in a
63
65
  language with no mature QUIC story of its own, macula-ts reuses macula-go's
64
66
  already-proven implementation through FFI — the same tradeoff
65
67
  [macula-php](https://github.com/macula-io/macula-php) already made
@@ -153,24 +155,20 @@ a Promise; events, served calls and served streams reach JavaScript through a
153
155
 
154
156
  | Primitive | Caller | Provider | Notes |
155
157
  |---|---|---|---|
156
- | Node keys (`NodeKey`) | ✅ | ✅ | `pq_hybrid` (the fleet's) or `pq_pure`; key files readable by the owner only |
158
+ | Node keys (`NodeKey`) | ✅ | ✅ | `pq_hybrid` (the fleet's) or `pq_pure`; key files readable by the owner only; `sign` and `NodeKey.verify`, pq_hybrid checked against the LAMPS draft's own vector and cross-verified with macula 12.7.0 |
157
159
  | Pool of station links (`Pool.connect`) | ✅ | ✅ | Seeds pinned by node_id; realm keys pinned; links redialed with subscriptions and served procedures replayed |
158
160
  | Calls by direct dial (`call`, `providers`) | ✅ | ✅ | `serve`: a thrown error goes back as `handler_error`; errors arrive as `ProviderError` / `RelayError` |
159
161
  | A node's own namespace (`ownProcedure`) | ✅ | ✅ | `~<node_id>/<name>`: served and called with no org and no realm key; the node's signature authorizes it |
160
162
  | Streams (`openStream`, `serveStream`) | ✅ | ✅ | Server, client and bidi; a QUIC stream per session, released on every path |
161
163
  | Publish/subscribe | ✅ | ✅ | Signed publications, delivered once across links |
162
164
  | DHT (`findRecord`, `findRecords`, `findRecordsByType`, `putRecord`) | ✅ | — | Records verified before they are handed on |
165
+ | 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
166
 
164
167
  ## Not yet implemented
165
168
 
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
169
  - **UCAN-gated calls and serving.** macula 12 uses post-quantum UCANs
170
170
  (macula-go#2). Calls carry no token yet, and a gated procedure cannot be
171
171
  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
172
 
175
173
  ## Testing
176
174
 
@@ -186,6 +184,13 @@ keys, calls by direct dial and their errors, providers, server and client
186
184
  streams (and that no stream is left unreleased), pubsub and the DHT, through
187
185
  the real addon. No network is needed.
188
186
 
187
+ `src/lamps.test.ts` holds pq_hybrid, the LAMPS composite
188
+ id-MLDSA87-RSA4096-PSS-SHA512, to `draft-ietf-lamps-pq-composite-sigs`' own
189
+ vector (the one macula and macula-go check), and to composites that crossed
190
+ both ways with macula 12.x. `scripts/cross-verify-macula.sh` renews those: this
191
+ SDK signs, macula (from hex, in the image macula's own CI runs in) verifies
192
+ and signs its own, and this SDK verifies it.
193
+
189
194
  `src/fleet.live.test.ts` runs against one real station and is not part of
190
195
  `npm test`. It needs `MACULA_TS_LIVE_SEED` (host:port), `MACULA_TS_LIVE_STATION_ID`
191
196
  (the station's node_id), `MACULA_TS_LIVE_REALM` and `MACULA_TS_LIVE_REALM_KEY`;
package/dist/binding.d.ts CHANGED
@@ -18,6 +18,7 @@ export declare const native: {
18
18
  keyProfile(key: Handle): string;
19
19
  keySign(key: Handle, data: Uint8Array): Promise<Uint8Array>;
20
20
  keyFree(key: Handle): void;
21
+ verify(data: Uint8Array, signature: Uint8Array, publicKey: Uint8Array, profile: string): boolean;
21
22
  poolConnect(key: Handle, seedsJson: string, optionsJson: string): Promise<Handle>;
22
23
  poolClose(pool: Handle): Promise<void>;
23
24
  poolNodeId(pool: Handle): Uint8Array;
@@ -31,6 +32,9 @@ export declare const native: {
31
32
  poolFindRecords(pool: Handle, key: Uint8Array, timeoutMs: number, bytesMode: number): Promise<string>;
32
33
  poolFindRecordsByType(pool: Handle, type: number, timeoutMs: number, bytesMode: number): Promise<string>;
33
34
  poolPutRecord(pool: Handle, wire: Uint8Array, timeoutMs: number): Promise<void>;
35
+ poolShareContent(pool: Handle, realm: Uint8Array, data: Uint8Array, name: string, timeoutMs: number): Promise<Uint8Array>;
36
+ poolUnshareContent(pool: Handle, realm: Uint8Array, mcid: Uint8Array, timeoutMs: number): Promise<void>;
37
+ poolGetContent(pool: Handle, realm: Uint8Array, mcid: Uint8Array, maxBytes: number, maxChunks: number, parallel: number, chunkTimeoutMs: number, timeoutMs: number): Promise<Uint8Array>;
34
38
  poolServe(pool: Handle, realm: Uint8Array, procedure: string, bytesMode: number, listener: Listener): Promise<Handle>;
35
39
  poolServeStream(pool: Handle, realm: Uint8Array, procedure: string, mode: number, bytesMode: number, listener: Listener): Promise<Handle>;
36
40
  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,CAgDvD,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,wDAAwD;AACxD,EAAE;AACF,kEAAkE;AAClE,wEAAwE;AACxE,iEAAiE;AACjE,qEAAqE;AACrE,mEAAmE;AACnE,sEAAsE;AACtE,4BAA4B;AAE5B;;;;;;;sDAOsD;AACtD,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C;2CACuC;IAC9B,IAAI,CAAS;IAEtB,YAAY,IAAY;QACtB,KAAK,CAAC,wCAAwC,IAAI,EAAE,CAAC,CAAC;QACtD,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
1
+ {"version":3,"file":"content.js","sourceRoot":"","sources":["../src/content.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,4EAA4E;AAC5E,+EAA+E;AAC/E,2EAA2E;AAC3E,4DAA4D;AAO5D,2DAA2D;AAC3D,MAAM,UAAU,MAAM,CAAC,IAAU;IAC/B,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,IAAI,CA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O,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/key.d.ts CHANGED
@@ -24,6 +24,11 @@ export declare class NodeKey {
24
24
  profile(): Profile;
25
25
  /** Signs data as given. */
26
26
  sign(data: Uint8Array): Promise<Uint8Array>;
27
+ /** Whether signature is valid over data for a public key as carried on the
28
+ * wire (publicKey()), under profile: ML-DSA-87 in pq_pure, and in pq_hybrid
29
+ * the LAMPS composite id-MLDSA87-RSA4096-PSS-SHA512 with the empty context,
30
+ * both halves verified. Anything malformed is false. */
31
+ static verify(data: Uint8Array, signature: Uint8Array, publicKey: Uint8Array, profile?: Profile): boolean;
27
32
  /** Frees the native key. The NodeKey is unusable after. */
28
33
  free(): void;
29
34
  /** @internal */
package/dist/key.js CHANGED
@@ -56,6 +56,13 @@ export class NodeKey {
56
56
  async sign(data) {
57
57
  return native.keySign(this.live(), data);
58
58
  }
59
+ /** Whether signature is valid over data for a public key as carried on the
60
+ * wire (publicKey()), under profile: ML-DSA-87 in pq_pure, and in pq_hybrid
61
+ * the LAMPS composite id-MLDSA87-RSA4096-PSS-SHA512 with the empty context,
62
+ * both halves verified. Anything malformed is false. */
63
+ static verify(data, signature, publicKey, profile = "pq_hybrid") {
64
+ return native.verify(data, signature, publicKey, profile);
65
+ }
59
66
  /** Frees the native key. The NodeKey is unusable after. */
60
67
  free() {
61
68
  if (this.handle !== null)
package/dist/key.js.map CHANGED
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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;;;4DAGwD;IACxD,MAAM,CAAC,MAAM,CAAC,IAAgB,EAAE,SAAqB,EAAE,SAAqB,EAAE,OAAO,GAAY,WAAW;QAC1G,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAC5D,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,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,EAAkC,MAAM,aAAa,CAAC;AACrE,OAAO,EACL,uBAAuB,EACvB,YAAY,EACZ,SAAS,EACT,GAAG,EACH,IAAI,GAIL,MAA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C,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.20.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"}