@macula-io/ts 0.13.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,kEAAkE;AAClE,uEAAuE;AACvE,oEAAoE;AACpE,sEAAsE;AACtE,uBAAuB;AACvB,EAAE;AACF,sEAAsE;AACtE,qEAAqE;AACrE,uEAAuE;AACvE,sEAAsE;AACtE,QAAQ;AACR,OAAO,EAAE,MAAM,EAAe,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAiC,MAAM,UAAU,CAAC;AAI7E,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,aAAa,EAAqC,MAAM,UAAU,CAAC;AA+BtH,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAE9C;;;;;;;;;;;;oEAYoE;AACpE,SAAS,iBAAiB,CAAC,KAAyB;IAClD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,sEAAsE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACjH,CAAC;IACD,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AACnD,CAAC;AAyBD,MAAM,OAAO,OAAO;IAClB,OAAO,CAAgB;IACvB,gEAAgE;IAChE,oEAAoE;IACpE,oEAAoE;IACpE,2DAA2D;IAC3D,gEAAgE;IAChE,+DAA+D;IAC/D,kEAAkE;IAClE,iEAAiE;IACjE,+DAA+D;IAC/D,SAAS,CAAW;IACpB,YAAY,GAAuB,IAAI,C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CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;uCAuBmC;IACnC,KAAK,CAAC,UAAU,CAAC,IAAgB,EAAE,IAAI,GAAG,EAAE;QAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QACrC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACxF,OAAO,EAAE,IAAI,EAAE,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;;;;mEAgB+D;IAC/D,KAAK,CAAC,UAAU,CAAC,IAAY;QAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QACrC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,EAAE,IAAI,CAAC,CAAC;QAClF,IAAI,IAAI,KAAK,IAAI;YAAE,MAAM,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAC;QACxD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED,SAAS,YAAY,CAAC,GAAe;IACnC,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,oDAAoD,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IACpF,CAAC;AACH,CAAC"}
package/dist/ucan.d.ts ADDED
@@ -0,0 +1,108 @@
1
+ import type { Identity } from "./identity.js";
2
+ /** One entry in a UCAN token's capability list -- mirrors macula-go's
3
+ * ucan.Capability (`with`/`can` json tags) exactly; this module doesn't
4
+ * interpret `with`/`can` in any way, it only carries them. */
5
+ export interface UcanCapability {
6
+ readonly with: string;
7
+ readonly can: string;
8
+ }
9
+ /** Arbitrary JSON value for a UCAN token's `fct` (facts) claim.
10
+ * Deliberately DIFFERENT from rpc.ts's JsonValue: a UCAN token's payload
11
+ * crosses this boundary as plain JSON (Go's encoding/json) over the
12
+ * token's own base64url-encoded JWT body, never macula's CBOR mesh wire
13
+ * -- so, unlike an RPC payload, a JSON boolean here is valid and is
14
+ * NOT rejected (rpc.ts's "no bool on the wire" rule is about the CBOR
15
+ * wire specifically, not about JSON in general). */
16
+ export type UcanFactValue = string | number | boolean | null | UcanFactValue[] | {
17
+ [key: string]: UcanFactValue;
18
+ };
19
+ /** Optional claims for Ucan.mint() -- mirrors macula-go's ucan.CreateOpts. */
20
+ export interface UcanMintOptions {
21
+ /** Unix seconds. Omit for a token with no expiry claim at all (never
22
+ * expires, per ucan.IsExpired's own "no exp claim = never expired"
23
+ * rule) -- NOT the same as passing an already-past timestamp. */
24
+ expiresAt?: number;
25
+ /** Unix seconds; the token is not valid before this instant. */
26
+ notBefore?: number;
27
+ /** An arbitrary nonce string, omitted from the token entirely if left
28
+ * unset (matching ucan.CreateOpts.Nonce's own ""-means-absent rule --
29
+ * there is no way to mint a token with an explicit empty-string nonce
30
+ * claim, since macula-go's own Create() cannot express that either). */
31
+ nonce?: string;
32
+ /** Arbitrary application-defined facts, carried in the token's `fct`
33
+ * claim (Go's `map[string]interface{}`, plain JSON -- see
34
+ * UcanFactValue's own doc on why booleans are fine here specifically). */
35
+ facts?: Record<string, UcanFactValue>;
36
+ /** CIDs (Ucan.token's own ucan.ComputeCID shape) of parent tokens this
37
+ * one delegates from. Not computed or validated by this module --
38
+ * carried through as opaque strings. */
39
+ proofs?: string[];
40
+ }
41
+ /** A decoded (never verified -- see this module's own doc) UCAN token:
42
+ * its raw wire text plus every claim cabi/ucan.go's macula_ucan_decode
43
+ * exposes. Both Ucan.mint() and Ucan.decode() return this same shape --
44
+ * mint() mints via cabi/ucan.go's macula_ucan_mint, then decodes its own
45
+ * freshly-minted token through the identical Decode path Ucan.decode()
46
+ * uses, rather than duplicating the claims-JSON shape a second time on
47
+ * the Go side. */
48
+ export declare class Ucan {
49
+ /** The raw token text: "header.payload.signature", base64url,
50
+ * dot-joined -- what Session.callWithUcan actually attaches to a CALL,
51
+ * and what a real macula peer/station would carry over the wire in a
52
+ * `ucan_token` frame field. */
53
+ readonly token: string;
54
+ /** The `iss` claim -- an opaque DID string (see didFromNodeId's own
55
+ * doc: not parsed or resolved by this module, carried through as-is). */
56
+ readonly issuer: string;
57
+ /** The `aud` claim. NOT checked against any local identity by this
58
+ * module or by Session.callWithUcan -- see this module's own doc on
59
+ * why: the real gate is bearer-token, not audience-matched. */
60
+ readonly audience: string;
61
+ readonly capabilities: readonly UcanCapability[];
62
+ /** The `exp` claim, unix seconds, or `null` if this token has none
63
+ * (never expires). */
64
+ readonly expiresAt: number | null;
65
+ /** The `nbf` claim, unix seconds, or `null` if absent. */
66
+ readonly notBefore: number | null;
67
+ /** The `nnc` claim, or `""` if absent (mirrors ucan.Payload.Nonce's
68
+ * own "" -- absent convention; there is no way to distinguish an
69
+ * explicit empty-string nonce from a wholly absent one, since
70
+ * macula-go's own Decode can't either). */
71
+ readonly nonce: string;
72
+ /** The `fct` claim, or `null` if absent. */
73
+ readonly facts: Readonly<Record<string, UcanFactValue>> | null;
74
+ /** The `prf` claim -- CIDs of parent tokens this one delegates from. */
75
+ readonly proofs: readonly string[];
76
+ private constructor();
77
+ /** Whether this token's `exp` claim is in the past. A token with no
78
+ * `exp` claim at all (`expiresAt === null`) is never expired --
79
+ * mirrors macula-go's `ucan.IsExpired` exactly, including its strict
80
+ * `now > exp` comparison (computed here, not cached, so this reflects
81
+ * the current instant on every read): a token expiring at exactly this
82
+ * second is NOT YET expired. This is purely a local claims check, same
83
+ * as `ucan.IsExpired` itself -- it does not verify the token's
84
+ * signature (see this module's own doc: verification is out of
85
+ * scope). */
86
+ get isExpired(): boolean;
87
+ /** Mints a fresh UCAN token, self-issued and signed by `issuer`'s own
88
+ * private key (macula-go's `ucan.Create`) -- the resulting token
89
+ * verifies against `issuer`'s own public key (NodeID), matching
90
+ * `ucan.Create`'s documented convention. `issuer`'s and `audience`'s
91
+ * DID strings are both built automatically as
92
+ * `did:macula:<hex NodeID>` (see `didFromNodeId`'s own doc for why:
93
+ * this ecosystem's own established convention, not invented here) --
94
+ * there is no way to mint with a custom DID string through this
95
+ * method.
96
+ *
97
+ * No network I/O -- this never touches a Session or a station; a
98
+ * token can be minted entirely offline given only an `Identity`. */
99
+ static mint(issuer: Identity, audience: Uint8Array, capabilities?: UcanCapability[], opts?: UcanMintOptions): Ucan;
100
+ /** Decodes `token`'s claims WITHOUT verifying its signature or
101
+ * checking expiration (macula-go's `ucan.Decode`) -- `isExpired`
102
+ * above is a local claims check only, never use this (or any field on
103
+ * the result) for an authorization decision; this module deliberately
104
+ * does not expose `ucan.Verify` (see this module's own doc). Throws if
105
+ * `token` isn't a well-formed `header.payload.signature` triple or its
106
+ * payload isn't valid JSON (mirrors `ucan.ErrInvalidToken`). */
107
+ static decode(token: string): Ucan;
108
+ }
package/dist/ucan.js ADDED
@@ -0,0 +1,142 @@
1
+ // UCAN (User Controlled Authorization Networks) tokens -- macula's
2
+ // JWT-shaped capability tokens (header.payload.signature, base64url,
3
+ // EdDSA over Ed25519, UCAN spec version "0.10.0" -- the older JWT-based
4
+ // draft, NOT the current non-JWT/IPLD UCAN 1.0 spec; see macula-go's
5
+ // ucan/ucan.go for why: no existing library implements 0.10.0, so
6
+ // macula-go hand-rolls it to match the Erlang reference SDK and its Rust
7
+ // NIF exactly). Minting (Ucan.mint) and decoding/inspecting (Ucan.decode)
8
+ // are both pure local operations -- no network I/O, no station involved
9
+ // -- reached through cabi/ucan.go's macula_ucan_mint/macula_ucan_decode.
10
+ // Session.callWithUcan (session.ts) attaches a minted token to an
11
+ // outgoing CALL, for invoking a procedure a provider has gated behind a
12
+ // ucan.Policy.Required policy on its own side (macula-go's
13
+ // connection.Session.CallWithUCAN).
14
+ //
15
+ // This module deliberately does NOT expose verification or
16
+ // gate-enforcement -- macula-go's ucan.Verify and ucan.Policy (serving a
17
+ // procedure gated behind a required issuer) are provider-side concerns,
18
+ // out of scope for this slice. See README.md's "What's explicitly not
19
+ // yet implemented" section.
20
+ //
21
+ // CRITICAL, established finding this module's design respects: macula's
22
+ // UCAN gate is a BEARER-token check. The real verify chain (Erlang's
23
+ // authorize_policy + macula_ucan_nif:verify/2, identical across every
24
+ // SDK port including this one's macula-go dependency) checks ONLY the
25
+ // token's signature and expiry against its own issuer -- it never checks
26
+ // the calling identity against the token's `aud` claim. Ucan.mint()
27
+ // therefore places NO restriction relating `issuer`'s identity to
28
+ // `audience` (any 32-byte NodeID is accepted, including one with no
29
+ // relationship to the minting identity at all), and Session.callWithUcan
30
+ // (session.ts) attaches whatever token it is given with no local
31
+ // "does my identity match this token's audience" guard. Adding either
32
+ // would reject configurations the real wire-level gate accepts fine, and
33
+ // would misrepresent a security property the mesh does not actually
34
+ // enforce.
35
+ import { native } from "./binding.js";
36
+ /** Builds this ecosystem's own DID convention for a raw NodeID --
37
+ * "did:macula:<lowercase hex NodeID>" -- matching macula-go's own tests
38
+ * (ucan/ucan_test.go, connection/serve_ucan_test.go) and its
39
+ * examples/ucan/main.go exactly, rather than inventing a different
40
+ * scheme here. This is bookkeeping only: macula-go's ucan package treats
41
+ * `iss`/`aud` as opaque strings it never parses or resolves (that's
42
+ * macula_did_nif's job on the Erlang reference, out of scope for both
43
+ * SDKs) -- the actual cryptographic verification a relying party performs
44
+ * is keyed by a raw public key it already has out of band (ucan.Verify's
45
+ * own `publicKey []byte` parameter, ucan/policy.go's
46
+ * `Required(issuerPublicKey []byte)`), never by parsing this string. */
47
+ function didFromNodeId(nodeId) {
48
+ return `did:macula:${Buffer.from(nodeId).toString("hex")}`;
49
+ }
50
+ /** A decoded (never verified -- see this module's own doc) UCAN token:
51
+ * its raw wire text plus every claim cabi/ucan.go's macula_ucan_decode
52
+ * exposes. Both Ucan.mint() and Ucan.decode() return this same shape --
53
+ * mint() mints via cabi/ucan.go's macula_ucan_mint, then decodes its own
54
+ * freshly-minted token through the identical Decode path Ucan.decode()
55
+ * uses, rather than duplicating the claims-JSON shape a second time on
56
+ * the Go side. */
57
+ export class Ucan {
58
+ /** The raw token text: "header.payload.signature", base64url,
59
+ * dot-joined -- what Session.callWithUcan actually attaches to a CALL,
60
+ * and what a real macula peer/station would carry over the wire in a
61
+ * `ucan_token` frame field. */
62
+ token;
63
+ /** The `iss` claim -- an opaque DID string (see didFromNodeId's own
64
+ * doc: not parsed or resolved by this module, carried through as-is). */
65
+ issuer;
66
+ /** The `aud` claim. NOT checked against any local identity by this
67
+ * module or by Session.callWithUcan -- see this module's own doc on
68
+ * why: the real gate is bearer-token, not audience-matched. */
69
+ audience;
70
+ capabilities;
71
+ /** The `exp` claim, unix seconds, or `null` if this token has none
72
+ * (never expires). */
73
+ expiresAt;
74
+ /** The `nbf` claim, unix seconds, or `null` if absent. */
75
+ notBefore;
76
+ /** The `nnc` claim, or `""` if absent (mirrors ucan.Payload.Nonce's
77
+ * own "" -- absent convention; there is no way to distinguish an
78
+ * explicit empty-string nonce from a wholly absent one, since
79
+ * macula-go's own Decode can't either). */
80
+ nonce;
81
+ /** The `fct` claim, or `null` if absent. */
82
+ facts;
83
+ /** The `prf` claim -- CIDs of parent tokens this one delegates from. */
84
+ proofs;
85
+ constructor(token, payload) {
86
+ this.token = token;
87
+ this.issuer = payload.issuer;
88
+ this.audience = payload.audience;
89
+ this.capabilities = payload.capabilities;
90
+ this.expiresAt = payload.expiresAt;
91
+ this.notBefore = payload.notBefore;
92
+ this.nonce = payload.nonce;
93
+ this.facts = payload.facts;
94
+ this.proofs = payload.proofs;
95
+ }
96
+ /** Whether this token's `exp` claim is in the past. A token with no
97
+ * `exp` claim at all (`expiresAt === null`) is never expired --
98
+ * mirrors macula-go's `ucan.IsExpired` exactly, including its strict
99
+ * `now > exp` comparison (computed here, not cached, so this reflects
100
+ * the current instant on every read): a token expiring at exactly this
101
+ * second is NOT YET expired. This is purely a local claims check, same
102
+ * as `ucan.IsExpired` itself -- it does not verify the token's
103
+ * signature (see this module's own doc: verification is out of
104
+ * scope). */
105
+ get isExpired() {
106
+ if (this.expiresAt === null)
107
+ return false;
108
+ return Math.floor(Date.now() / 1000) > this.expiresAt;
109
+ }
110
+ /** Mints a fresh UCAN token, self-issued and signed by `issuer`'s own
111
+ * private key (macula-go's `ucan.Create`) -- the resulting token
112
+ * verifies against `issuer`'s own public key (NodeID), matching
113
+ * `ucan.Create`'s documented convention. `issuer`'s and `audience`'s
114
+ * DID strings are both built automatically as
115
+ * `did:macula:<hex NodeID>` (see `didFromNodeId`'s own doc for why:
116
+ * this ecosystem's own established convention, not invented here) --
117
+ * there is no way to mint with a custom DID string through this
118
+ * method.
119
+ *
120
+ * No network I/O -- this never touches a Session or a station; a
121
+ * token can be minted entirely offline given only an `Identity`. */
122
+ static mint(issuer, audience, capabilities = [], opts = {}) {
123
+ if (audience.length !== 32) {
124
+ throw new Error(`macula-ts: UCAN audience NodeID must be exactly 32 bytes, got ${audience.length}`);
125
+ }
126
+ const token = native.ucanMint(issuer.handleForFfi(), didFromNodeId(issuer.nodeId), didFromNodeId(audience), JSON.stringify(capabilities ?? []), opts.expiresAt, opts.notBefore, opts.nonce ?? "", opts.facts !== undefined ? JSON.stringify(opts.facts) : undefined, opts.proofs !== undefined ? JSON.stringify(opts.proofs) : undefined);
127
+ return Ucan.decode(token);
128
+ }
129
+ /** Decodes `token`'s claims WITHOUT verifying its signature or
130
+ * checking expiration (macula-go's `ucan.Decode`) -- `isExpired`
131
+ * above is a local claims check only, never use this (or any field on
132
+ * the result) for an authorization decision; this module deliberately
133
+ * does not expose `ucan.Verify` (see this module's own doc). Throws if
134
+ * `token` isn't a well-formed `header.payload.signature` triple or its
135
+ * payload isn't valid JSON (mirrors `ucan.ErrInvalidToken`). */
136
+ static decode(token) {
137
+ const json = native.ucanDecode(token);
138
+ const payload = JSON.parse(json);
139
+ return new Ucan(token, payload);
140
+ }
141
+ }
142
+ //# sourceMappingURL=ucan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ucan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,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EACjE,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CACpE,CAAC;QACF,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;;;;oEAMgE;IAChE,MAAM,CAAC,MAAM,CAAC,KAAa;QACzB,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAoB,CAAC;QACpD,OAAO,IAAI,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAClC,CAAC;CACF"}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@macula-io/ts",
3
+ "version": "0.13.0",
4
+ "description": "TypeScript SDK for the Macula mesh (FFI over macula-go)",
5
+ "license": "Apache-2.0",
6
+ "keywords": ["macula", "mesh", "quic", "rpc", "pubsub", "ffi", "wire-protocol", "typescript", "p2p"],
7
+ "type": "module",
8
+ "sideEffects": false,
9
+ "homepage": "https://github.com/macula-io/macula-ts#readme",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/macula-io/macula-ts.git"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/macula-io/macula-ts/issues"
16
+ },
17
+ "author": {
18
+ "name": "Macula",
19
+ "email": "raf.lefever@erlef.org"
20
+ },
21
+ "main": "dist/index.js",
22
+ "types": "dist/index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "default": "./dist/index.js"
27
+ }
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "prebuilds"
32
+ ],
33
+ "scripts": {
34
+ "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 .",
35
+ "build:addon:dev": "npm run build:go && node-gyp rebuild",
36
+ "build:prebuilds": "npm run build:go && prebuildify --napi --strip",
37
+ "build": "npm run build:addon:dev && tsc",
38
+ "test": "vitest run",
39
+ "test:live": "MACULA_TS_LIVE=1 vitest run src/session.live.test.ts src/rpc.live.test.ts src/dht.live.test.ts src/pubsub.live.test.ts src/content.live.test.ts src/ucan.live.test.ts src/directdial.live.test.ts",
40
+ "typecheck": "tsc --noEmit",
41
+ "prepublishOnly": "npm run build:prebuilds && tsc"
42
+ },
43
+ "dependencies": {
44
+ "node-addon-api": "^8.9.2",
45
+ "node-gyp-build": "^4.8.4"
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "^24.0.0",
49
+ "node-gyp": "^13.0.2",
50
+ "prebuildify": "^6.0.1",
51
+ "typescript": "^5.4.0",
52
+ "vitest": "^3.2.7"
53
+ },
54
+ "engines": {
55
+ "node": ">=24.18.1"
56
+ }
57
+ }