@mcsherrylabs/evolver-mcp 0.12.0 → 0.14.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.
Files changed (163) hide show
  1. package/dist/application-signer.d.ts +16 -0
  2. package/dist/application-signer.d.ts.map +1 -0
  3. package/dist/application-signer.js +55 -0
  4. package/dist/application-signer.js.map +1 -0
  5. package/dist/approved-request.d.ts +30 -0
  6. package/dist/approved-request.d.ts.map +1 -0
  7. package/dist/approved-request.js +167 -0
  8. package/dist/approved-request.js.map +1 -0
  9. package/dist/attachment-tools.d.ts +3 -0
  10. package/dist/attachment-tools.d.ts.map +1 -0
  11. package/dist/attachment-tools.js +32 -0
  12. package/dist/attachment-tools.js.map +1 -0
  13. package/dist/attachments.d.ts +41 -0
  14. package/dist/attachments.d.ts.map +1 -0
  15. package/dist/attachments.js +458 -0
  16. package/dist/attachments.js.map +1 -0
  17. package/dist/content-file-tools.d.ts +3 -0
  18. package/dist/content-file-tools.d.ts.map +1 -0
  19. package/dist/content-file-tools.js +67 -0
  20. package/dist/content-file-tools.js.map +1 -0
  21. package/dist/content-files.d.ts +32 -0
  22. package/dist/content-files.d.ts.map +1 -0
  23. package/dist/content-files.js +79 -0
  24. package/dist/content-files.js.map +1 -0
  25. package/dist/content-ranges.d.ts +41 -0
  26. package/dist/content-ranges.d.ts.map +1 -0
  27. package/dist/content-ranges.js +75 -0
  28. package/dist/content-ranges.js.map +1 -0
  29. package/dist/files.d.ts +60 -0
  30. package/dist/files.d.ts.map +1 -0
  31. package/dist/files.js +355 -0
  32. package/dist/files.js.map +1 -0
  33. package/dist/group-crypto-tools.d.ts +3 -0
  34. package/dist/group-crypto-tools.d.ts.map +1 -0
  35. package/dist/group-crypto-tools.js +47 -0
  36. package/dist/group-crypto-tools.js.map +1 -0
  37. package/dist/group-crypto.d.ts +24 -0
  38. package/dist/group-crypto.d.ts.map +1 -0
  39. package/dist/group-crypto.js +135 -0
  40. package/dist/group-crypto.js.map +1 -0
  41. package/dist/group-key-provider.d.ts +30 -0
  42. package/dist/group-key-provider.d.ts.map +1 -0
  43. package/dist/group-key-provider.js +72 -0
  44. package/dist/group-key-provider.js.map +1 -0
  45. package/dist/group-keys.d.ts +34 -0
  46. package/dist/group-keys.d.ts.map +1 -0
  47. package/dist/group-keys.js +88 -0
  48. package/dist/group-keys.js.map +1 -0
  49. package/dist/http-profiles.d.ts +47 -0
  50. package/dist/http-profiles.d.ts.map +1 -0
  51. package/dist/http-profiles.js +161 -0
  52. package/dist/http-profiles.js.map +1 -0
  53. package/dist/human-approval.d.ts +14 -0
  54. package/dist/human-approval.d.ts.map +1 -0
  55. package/dist/human-approval.js +34 -0
  56. package/dist/human-approval.js.map +1 -0
  57. package/dist/inbox.d.ts +1 -1
  58. package/dist/inbox.d.ts.map +1 -1
  59. package/dist/inbox.js +1 -1
  60. package/dist/inbox.js.map +1 -1
  61. package/dist/index.d.ts +11 -0
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +94 -41
  64. package/dist/index.js.map +1 -1
  65. package/dist/login-profiles.d.ts +25 -0
  66. package/dist/login-profiles.d.ts.map +1 -0
  67. package/dist/login-profiles.js +77 -0
  68. package/dist/login-profiles.js.map +1 -0
  69. package/dist/login-tools.d.ts +3 -0
  70. package/dist/login-tools.d.ts.map +1 -0
  71. package/dist/login-tools.js +27 -0
  72. package/dist/login-tools.js.map +1 -0
  73. package/dist/login.d.ts +36 -0
  74. package/dist/login.d.ts.map +1 -0
  75. package/dist/login.js +144 -0
  76. package/dist/login.js.map +1 -0
  77. package/dist/mcp.d.ts +2 -2
  78. package/dist/mcp.d.ts.map +1 -1
  79. package/dist/p2p-tools.d.ts +3 -0
  80. package/dist/p2p-tools.d.ts.map +1 -0
  81. package/dist/p2p-tools.js +52 -0
  82. package/dist/p2p-tools.js.map +1 -0
  83. package/dist/p2p.d.ts +67 -0
  84. package/dist/p2p.d.ts.map +1 -0
  85. package/dist/p2p.js +326 -0
  86. package/dist/p2p.js.map +1 -0
  87. package/dist/processor.d.ts +1 -1
  88. package/dist/processor.d.ts.map +1 -1
  89. package/dist/processor.js +1 -1
  90. package/dist/processor.js.map +1 -1
  91. package/dist/proof-attempts.d.ts +19 -0
  92. package/dist/proof-attempts.d.ts.map +1 -0
  93. package/dist/proof-attempts.js +30 -0
  94. package/dist/proof-attempts.js.map +1 -0
  95. package/dist/signed-http-tools.d.ts +3 -0
  96. package/dist/signed-http-tools.d.ts.map +1 -0
  97. package/dist/signed-http-tools.js +33 -0
  98. package/dist/signed-http-tools.js.map +1 -0
  99. package/dist/signed-http.d.ts +30 -0
  100. package/dist/signed-http.d.ts.map +1 -0
  101. package/dist/signed-http.js +114 -0
  102. package/dist/signed-http.js.map +1 -0
  103. package/dist/tools.d.ts +29 -4
  104. package/dist/tools.d.ts.map +1 -1
  105. package/dist/tools.js +24 -10
  106. package/dist/tools.js.map +1 -1
  107. package/dist/transaction-interchange-tools.d.ts +3 -0
  108. package/dist/transaction-interchange-tools.d.ts.map +1 -0
  109. package/dist/transaction-interchange-tools.js +41 -0
  110. package/dist/transaction-interchange-tools.js.map +1 -0
  111. package/dist/transaction-interchange.d.ts +141 -0
  112. package/dist/transaction-interchange.d.ts.map +1 -0
  113. package/dist/transaction-interchange.js +502 -0
  114. package/dist/transaction-interchange.js.map +1 -0
  115. package/dist/transaction-policy.d.ts +32 -0
  116. package/dist/transaction-policy.d.ts.map +1 -0
  117. package/dist/transaction-policy.js +89 -0
  118. package/dist/transaction-policy.js.map +1 -0
  119. package/package.json +7 -18
  120. package/dist/amount.d.ts +0 -23
  121. package/dist/amount.d.ts.map +0 -1
  122. package/dist/amount.js +0 -53
  123. package/dist/amount.js.map +0 -1
  124. package/dist/channel.d.ts +0 -77
  125. package/dist/channel.d.ts.map +0 -1
  126. package/dist/channel.js +0 -287
  127. package/dist/channel.js.map +0 -1
  128. package/dist/claim.d.ts +0 -48
  129. package/dist/claim.d.ts.map +0 -1
  130. package/dist/claim.js +0 -81
  131. package/dist/claim.js.map +0 -1
  132. package/dist/content.d.ts +0 -81
  133. package/dist/content.d.ts.map +0 -1
  134. package/dist/content.js +0 -215
  135. package/dist/content.js.map +0 -1
  136. package/dist/group-ownership.d.ts +0 -78
  137. package/dist/group-ownership.d.ts.map +0 -1
  138. package/dist/group-ownership.js +0 -325
  139. package/dist/group-ownership.js.map +0 -1
  140. package/dist/group.d.ts +0 -60
  141. package/dist/group.d.ts.map +0 -1
  142. package/dist/group.js +0 -204
  143. package/dist/group.js.map +0 -1
  144. package/dist/identity.d.ts +0 -87
  145. package/dist/identity.d.ts.map +0 -1
  146. package/dist/identity.js +0 -236
  147. package/dist/identity.js.map +0 -1
  148. package/dist/read.d.ts +0 -252
  149. package/dist/read.d.ts.map +0 -1
  150. package/dist/read.js +0 -320
  151. package/dist/read.js.map +0 -1
  152. package/dist/result.d.ts +0 -110
  153. package/dist/result.d.ts.map +0 -1
  154. package/dist/result.js +0 -97
  155. package/dist/result.js.map +0 -1
  156. package/dist/signer.d.ts +0 -37
  157. package/dist/signer.d.ts.map +0 -1
  158. package/dist/signer.js +0 -76
  159. package/dist/signer.js.map +0 -1
  160. package/dist/write.d.ts +0 -208
  161. package/dist/write.d.ts.map +0 -1
  162. package/dist/write.js +0 -385
  163. package/dist/write.js.map +0 -1
@@ -0,0 +1,89 @@
1
+ // Host policy is an explicit capability, not model-supplied transaction approval. No wire codec.
2
+ import { constants, openSync, fstatSync, readSync, closeSync } from "node:fs";
3
+ import { isAbsolute } from "node:path";
4
+ import { isValidPrincipalName, CORE_LEDGER_IDS, RESERVED_LEDGER_PREFIX } from "@mcsherrylabs/evolver-client";
5
+ export const TRANSACTION_BYTES = 65_536;
6
+ export const TRANSACTION_BASE64_CHARS = 4 * Math.ceil(TRANSACTION_BYTES / 3);
7
+ export const TRANSACTION_OPERATIONS = ["transfer", "create_identity", "delete_identity", "add_key", "replace_key", "delete_key",
8
+ "create_group", "add_member", "remove_member", "delete_group", "transfer_group_ownership", "claim_channel", "unclaim_channel",
9
+ "update_channel_da", "update_channel_toll", "update_channel_write_policy", "channel_write"];
10
+ const amount = (v) => typeof v === "string" && /^(0|[1-9][0-9]{0,18})$/.test(v) && BigInt(v) <= 9223372036854775807n;
11
+ const list = (v, test) => Array.isArray(v) && v.length <= 32 &&
12
+ v.every(s => typeof s === "string" && test(s)) && new Set(v).size === v.length;
13
+ export function transactionChainUrl(value) {
14
+ if (typeof value !== "string" || value.length > 2048 || /[^\x21-\x7e]/.test(value))
15
+ throw new Error();
16
+ const u = new URL(value);
17
+ if (!["http:", "https:"].includes(u.protocol) || u.username || u.password || u.search || u.hash ||
18
+ (u.pathname !== "/" && u.pathname !== ""))
19
+ throw new Error();
20
+ return u.origin;
21
+ }
22
+ export function resolveTransactionPolicy(raw) {
23
+ try {
24
+ if (!raw || typeof raw !== "object" || Array.isArray(raw))
25
+ throw new Error();
26
+ const p = raw;
27
+ const fields = ["chainUrl", "allowedSenders", "operations", "channelLedgers", "recipients", "maxAmount", "maxToll",
28
+ "maxTtlRounds", "maxSubmitBytes", "localRoles", "allowRelay", "allowDa"];
29
+ if (Object.keys(p).length !== fields.length || Object.keys(p).some(k => !fields.includes(k)))
30
+ throw new Error();
31
+ const chainUrl = transactionChainUrl(p.chainUrl);
32
+ if (!list(p.allowedSenders, isValidPrincipalName) || !list(p.recipients, isValidPrincipalName) ||
33
+ !list(p.operations, s => TRANSACTION_OPERATIONS.includes(s)) ||
34
+ !list(p.channelLedgers, s => /^[a-zA-Z0-9]+(?:\.[a-zA-Z0-9]+)*$/.test(s) && s.length <= 255 &&
35
+ !s.startsWith(RESERVED_LEDGER_PREFIX) && !CORE_LEDGER_IDS.includes(s)) ||
36
+ !list(p.localRoles, s => s === "sender" || s === "incoming_group_owner") || !amount(p.maxAmount) || !amount(p.maxToll) ||
37
+ !Number.isSafeInteger(p.maxTtlRounds) || p.maxTtlRounds < 1 || p.maxTtlRounds > 50 ||
38
+ !Number.isSafeInteger(p.maxSubmitBytes) || p.maxSubmitBytes < 1 || p.maxSubmitBytes > TRANSACTION_BYTES ||
39
+ typeof p.allowRelay !== "boolean" || typeof p.allowDa !== "boolean")
40
+ throw new Error();
41
+ const policy = structuredClone({ ...p, chainUrl });
42
+ for (const value of Object.values(policy))
43
+ if (Array.isArray(value))
44
+ Object.freeze(value);
45
+ return { ok: true, policy: Object.freeze(policy) };
46
+ }
47
+ catch {
48
+ return { ok: false };
49
+ }
50
+ }
51
+ /** Dedicated operator-owned regular file; no symlink, hardlink or group/world permissions.
52
+ * Read through the same descriptor we checked. FileRoot excludes this configuration path.
53
+ * Same-UID host processes remain trusted, as for all MCP host-held keys/policy. */
54
+ export function loadTransactionPolicyFromEnv(env) {
55
+ const path = env.EVOLVER_TRANSACTION_POLICY_PATH;
56
+ if (path === undefined)
57
+ return { ok: true };
58
+ let fd;
59
+ try {
60
+ if (!isAbsolute(path) || !process.getuid)
61
+ throw new Error();
62
+ fd = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
63
+ const st = fstatSync(fd);
64
+ if (!st.isFile() || st.nlink !== 1 || st.uid !== process.getuid() || (st.mode & 0o077) !== 0 || st.size > 16_384)
65
+ throw new Error();
66
+ const buffer = Buffer.alloc(16_385);
67
+ let count = 0;
68
+ while (count < buffer.length) {
69
+ const n = readSync(fd, buffer, count, buffer.length - count, null);
70
+ if (n === 0)
71
+ break;
72
+ count += n;
73
+ }
74
+ const after = fstatSync(fd);
75
+ if (count > 16_384 || count !== st.size || after.size !== st.size || after.mtimeMs !== st.mtimeMs ||
76
+ after.ctimeMs !== st.ctimeMs || after.nlink !== 1)
77
+ throw new Error();
78
+ const text = new TextDecoder("utf-8", { fatal: true }).decode(buffer.subarray(0, count));
79
+ return resolveTransactionPolicy(JSON.parse(text));
80
+ }
81
+ catch {
82
+ return { ok: false };
83
+ }
84
+ finally {
85
+ if (fd !== undefined)
86
+ closeSync(fd);
87
+ }
88
+ }
89
+ //# sourceMappingURL=transaction-policy.js.map
@@ -0,0 +1 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1
  {
2
2
  "name": "@mcsherrylabs/evolver-mcp",
3
- "version": "0.12.0",
4
- "description": "MCP server over a configurable Evolver node — read the chain, sign a transfer, administer what you own, write to a channel, submit a signed transaction. Wraps @mcsherrylabs/evolver-client; implements no wire format of its own.",
3
+ "version": "0.14.0",
4
+ "description": "MCP server over a configurable Evolver node \u2014 read the chain, sign a transfer, administer what you own, write to a channel, submit a signed transaction. Wraps @mcsherrylabs/evolver-client; implements no wire format of its own.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -25,23 +25,10 @@
25
25
  "build": "tsc -p tsconfig.build.json && chmod +x dist/cli.js",
26
26
  "start": "node dist/index.js",
27
27
  "typecheck": "tsc --noEmit",
28
- "check:result": "tsx test/result-checks.ts",
29
28
  "check:config": "tsx test/config-checks.ts",
30
- "check:heights": "tsx test/heights-checks.ts",
31
- "check:principal": "tsx test/principal-checks.ts",
32
29
  "check:transaction": "tsx test/transaction-checks.ts",
33
- "check:keys": "tsx test/identity-keys-checks.ts",
34
- "check:channelterms": "tsx test/channelterms-checks.ts",
35
30
  "check:surface": "tsx test/surface-checks.ts",
36
- "check:signing": "tsx test/signing-checks.ts",
37
- "check:interval": "tsx test/interval-checks.ts",
38
- "check:classify": "tsx test/classify-checks.ts",
39
- "check:identity": "tsx test/identity-checks.ts",
40
- "check:claim": "tsx test/claim-checks.ts",
41
- "check:content": "tsx test/content-checks.ts",
42
31
  "check:inbox": "tsx test/inbox-checks.ts",
43
- "check:group": "tsx test/group-checks.ts",
44
- "check:channel": "tsx test/channel-checks.ts",
45
32
  "check:channel-admin-apply": "tsx test/channel-admin-apply-checks.mjs",
46
33
  "check:bootstrap": "tsx test/bootstrap-checks.ts",
47
34
  "check:install": "tsx test/install-checks.ts",
@@ -50,12 +37,14 @@
50
37
  "check:publish": "tsx test/publish-checks.ts",
51
38
  "regression:channels": "node test/channel-subscriptions-regression.mjs",
52
39
  "check:channel-regression": "node test/channel-subscriptions-regression-checks.mjs",
53
- "test": "npm run build && npm run typecheck && npm run check:result && npm run check:config && npm run check:heights && npm run check:principal && npm run check:transaction && npm run check:keys && npm run check:channelterms && npm run check:surface && npm run check:signing && npm run check:interval && npm run check:classify && npm run check:identity && npm run check:claim && npm run check:content && npm run check:inbox && npm run check:group && npm run check:channel && npm run check:channel-admin-apply && npm run check:bootstrap && npm run check:install && npm run check:deployment && npm run check:startup && npm run check:publish && npm run check:channel-regression"
40
+ "test": "npm run build && npm run typecheck && npm run check:config && npm run check:transaction && npm run check:surface && npm run check:inbox && npm run check:channel-admin-apply && npm run check:bootstrap && npm run check:install && npm run check:deployment && npm run check:startup && npm run check:publish && npm run check:channel-regression"
54
41
  },
55
42
  "dependencies": {
56
- "@mcsherrylabs/evolver-client": "0.21.1",
43
+ "@mcsherrylabs/evolver-client": "0.22.1",
44
+ "@mcsherrylabs/evolver-core": "0.1.0",
57
45
  "@modelcontextprotocol/sdk": "1.32.1",
58
- "typebox": "1.3.32"
46
+ "typebox": "1.3.32",
47
+ "undici": "6.29.1"
59
48
  },
60
49
  "devDependencies": {
61
50
  "@types/node": "^22.10.0",
package/dist/amount.d.ts DELETED
@@ -1,23 +0,0 @@
1
- /** The largest amount the wire format carries. Beyond this the node cannot decode the body. */
2
- export declare const MAX_AMOUNT: bigint;
3
- export type ParsedAmount = {
4
- readonly ok: true;
5
- readonly value: bigint;
6
- } | {
7
- readonly ok: false;
8
- readonly error: string;
9
- };
10
- /** Validate and convert an amount as it arrived — a string, from a model.
11
- *
12
- * Refusing here is the whole point: it happens BEFORE anything is signed, so a malformed amount
13
- * costs nothing instead of becoming a transaction that does the wrong thing. */
14
- export declare function parseAmount(input: string): ParsedAmount;
15
- /** Toll amounts/consent ceilings additionally admit exactly "0". Never use for transfers.
16
- * Supplied blank/padded values are NOT omission, and non-string values must not be coerced. */
17
- export declare function parseTollAmount(input: string): ParsedAmount;
18
- /** Render an amount for a result a model will read.
19
- *
20
- * ⚠️ `String(Number(v))` is correct below 2^53 and wrong above it, which is what makes the
21
- * mutation survivable unless a check exercises a large magnitude. */
22
- export declare const formatAmount: (value: bigint) => string;
23
- //# sourceMappingURL=amount.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"amount.d.ts","sourceRoot":"","sources":["../src/amount.ts"],"names":[],"mappings":"AAgBA,+FAA+F;AAC/F,eAAO,MAAM,UAAU,QAAmB,CAAC;AAK3C,MAAM,MAAM,YAAY,GACpB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC7C;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnD;;;iFAGiF;AACjF,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAkBvD;AAED;+FAC+F;AAC/F,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAK3D;AAED;;;sEAGsE;AACtE,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,MAA4B,CAAC"}
package/dist/amount.js DELETED
@@ -1,53 +0,0 @@
1
- // Amounts.
2
- //
3
- // `bigint` in code, decimal STRING on any wire (Constitution VIII). A tool result is JSON that a
4
- // model reads, and a JSON number is a double — everything above 2^53 is silently wrong. There is
5
- // no "small enough to be safe" exception, because the rule is about the type and not the value.
6
- //
7
- // ⚠️ Validation is on the STRING, before any conversion, and a range check is NOT enough:
8
- //
9
- // BigInt("-1") === -1n and the wire encoder loops `while (v > 0n)`, so a negative amount
10
- // does not fail to encode — it encodes as a DIFFERENT POSITIVE number
11
- // BigInt("0x10") === 16n
12
- // BigInt("") === 0n
13
- //
14
- // Each of those is a silent substitution: the caller asked for one thing and a different thing
15
- // would be signed. So the accepted form is exactly one shape — a canonical positive decimal.
16
- /** The largest amount the wire format carries. Beyond this the node cannot decode the body. */
17
- export const MAX_AMOUNT = (1n << 63n) - 1n; // 9223372036854775807
18
- /** Canonical positive decimal: no sign, no padding, no leading zero, no separators, no exponent. */
19
- const CANONICAL = /^[1-9][0-9]*$/;
20
- /** Validate and convert an amount as it arrived — a string, from a model.
21
- *
22
- * Refusing here is the whole point: it happens BEFORE anything is signed, so a malformed amount
23
- * costs nothing instead of becoming a transaction that does the wrong thing. */
24
- export function parseAmount(input) {
25
- if (typeof input !== "string")
26
- return { ok: false, error: `amount must be a decimal string, got ${typeof input}` };
27
- if (!CANONICAL.test(input))
28
- return {
29
- ok: false,
30
- error: `amount "${input}" is not a positive decimal integer. It must be digits only, with no ` +
31
- `sign, spaces, decimal point, exponent, separators or leading zeroes — a negative or ` +
32
- `hex value would not fail to encode, it would encode as a different number.`,
33
- };
34
- const value = BigInt(input);
35
- if (value > MAX_AMOUNT)
36
- return { ok: false, error: `amount ${input} exceeds the maximum the wire carries (${MAX_AMOUNT})` };
37
- return { ok: true, value };
38
- }
39
- /** Toll amounts/consent ceilings additionally admit exactly "0". Never use for transfers.
40
- * Supplied blank/padded values are NOT omission, and non-string values must not be coerced. */
41
- export function parseTollAmount(input) {
42
- if (typeof input === "string" && input !== input.trim())
43
- return { ok: false, error: "toll amount must be a canonical nonnegative decimal string with no spaces or padding" };
44
- if (input === "0")
45
- return { ok: true, value: 0n };
46
- return parseAmount(input);
47
- }
48
- /** Render an amount for a result a model will read.
49
- *
50
- * ⚠️ `String(Number(v))` is correct below 2^53 and wrong above it, which is what makes the
51
- * mutation survivable unless a check exercises a large magnitude. */
52
- export const formatAmount = (value) => value.toString(10);
53
- //# sourceMappingURL=amount.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"amount.js","sourceRoot":"","sources":["../src/amount.ts"],"names":[],"mappings":"AAAA,WAAW;AACX,EAAE;AACF,iGAAiG;AACjG,iGAAiG;AACjG,gGAAgG;AAChG,EAAE;AACF,0FAA0F;AAC1F,EAAE;AACF,gGAAgG;AAChG,kGAAkG;AAClG,2BAA2B;AAC3B,0BAA0B;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,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC"}
package/dist/channel.d.ts DELETED
@@ -1,77 +0,0 @@
1
- import type { Signer } from "@mcsherrylabs/evolver-client";
2
- import type { ChainReads } from "./read.js";
3
- import type { SignedChannel } from "./write.js";
4
- import type { ToolResult } from "./result.js";
5
- /** What the channel verbs need from the world. NO `submitTx` — deliberately: the six signing verbs
6
- * submit nothing, so the capability is not present to reach for (zero-submit is structural). */
7
- export interface ChannelOpsDeps {
8
- readonly identity: string;
9
- readonly signer: Signer;
10
- readonly ttlOffset?: number;
11
- readonly reads: ChainReads;
12
- }
13
- /** A signed channel-ledger operation, as returned by a signing verb. */
14
- export type ChannelSignResult = ToolResult<SignedChannel>;
15
- /**
16
- * Claim a channel (SIGN-14): become its owner and set its terms. Signed for `deps.identity` on
17
- * LEDGER.owners, targeting the caller's validated non-core/non-reserved channel. Does NOT submit.
18
- */
19
- export declare function signChannelClaim(deps: ChannelOpsDeps, params: {
20
- channel: string;
21
- groupOwner?: string;
22
- writePolicy?: string;
23
- daGroup?: string;
24
- daThresholdM?: number;
25
- tollAmount?: string;
26
- tollRecipient?: string;
27
- }): Promise<ChannelSignResult>;
28
- /**
29
- * Write an opaque payload to a channel (SIGN-13), carrying the toll-consent `maxToll`. The caller
30
- * chooses the bytes and the channel (never a core/reserved ledger — `writableChannelId` refuses those
31
- * FIRST); the MCP signs the ceiling the write consents to. `maxToll` is optional: omitted it signs
32
- * "consents to no toll" (0), which the node refuses with `toll_ceiling_too_low` on a tolled channel.
33
- */
34
- export declare function signChannelWrite(deps: ChannelOpsDeps, params: {
35
- channel: string;
36
- bodyHex: string;
37
- maxToll?: string;
38
- }): Promise<ChannelSignResult>;
39
- /**
40
- * Unclaim a channel (SIGN-15): `removeOwnerBody(ledgerId)` is the unclaim — it gives up ownership.
41
- * Signed on LEDGER.owners; the inner channel target is refused if core/reserved. Does NOT submit.
42
- */
43
- export declare function signChannelUnclaim(deps: ChannelOpsDeps, params: {
44
- channel: string;
45
- }): Promise<ChannelSignResult>;
46
- /**
47
- * Set a channel's write policy (SIGN-18): `"owner_or_group"` or `"open"`. The policy is ENUMERATED
48
- * locally (Pitfall 5 — `writePolicyWire` narrows a typo to the default, silently) and refused
49
- * otherwise. Does NOT submit.
50
- */
51
- export declare function signChannelWritePolicy(deps: ChannelOpsDeps, params: {
52
- channel: string;
53
- writePolicy: string;
54
- }): Promise<ChannelSignResult>;
55
- /**
56
- * Set a channel's toll (SIGN-17). A positive `tollAmount` sets the toll; `"0"`/omitted removes it
57
- * (composes `updateChannelTollBody({ ledgerId })` with no `tollAmount`, clearing the toll). A
58
- * NEGATIVE `tollAmount` is refused locally — it would encode as a different positive number, not fail.
59
- * Does NOT submit.
60
- */
61
- export declare function signChannelToll(deps: ChannelOpsDeps, params: {
62
- channel: string;
63
- tollAmount?: string;
64
- tollRecipient?: string;
65
- }): Promise<ChannelSignResult>;
66
- /**
67
- * Set a channel's data-availability policy (SIGN-16): the group that must hold (and attest for) its
68
- * bodies, and the M-of-N threshold. The SDK THROWS when `daThresholdM` is set but `daGroup` is empty,
69
- * so the encoder call is wrapped and the throw surfaced as `partial daGroup` rather than escaping.
70
- * Does NOT submit.
71
- */
72
- export declare function signChannelDa(deps: ChannelOpsDeps, params: {
73
- channel: string;
74
- daGroup?: string;
75
- daThresholdM?: number;
76
- }): Promise<ChannelSignResult>;
77
- //# sourceMappingURL=channel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,8BAA8B,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;iGAC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;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GACvE,OAAO,CAAC,iBAAiB,CAAC,CA+B5B;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GACnE,OAAO,CAAC,iBAAiB,CAAC,CA8B5B"}
package/dist/channel.js DELETED
@@ -1,287 +0,0 @@
1
- // Channel-ledger signing verbs (SIGN-13..18): sign claim/unclaim/write/set-toll/set-write-policy/
2
- // set-DA-policy. Each is a compose→sign→record→return-txId operation with ZERO submit, mirroring the
3
- // identity verbs in `src/identity.ts` and the group verbs in `src/group.ts`, and resolving in the
4
- // SAME `submitSigned`/`inspectSigned` path.
5
- //
6
- // A channel is any non-core ledger id outside the reserved `ce.evolver.` namespace. The caller
7
- // chooses that TARGET, validated by `writableChannelId` (shared with `write.ts`) before signing.
8
- // Administration uses typed SDK operation bodies on the fixed LEDGER.owners outer envelope; the
9
- // validated channel stays inside the body. Only payload writes use the channel as the outer ledger.
10
- // Never let this dedicated admin route bypass validation or enable arbitrary core-ledger bodies.
11
- //
12
- // The one new mechanism over the group/identity verbs is toll-consent: `signChannelWrite` threads
13
- // `maxToll` through `composeAndSign` → `buildSignedTx`/`txIdHex`, so the signed ceiling is folded
14
- // into the digest and carried on the wire (field 6). A write to a tolled channel MUST sign a
15
- // `maxToll >= toll.amount` or the node refuses `toll_ceiling_too_low`.
16
- //
17
- // ⚠️ KEY MATERIAL NEVER REACHES A RECORD OR A REFUSAL. Records carry the channel id, write policy,
18
- // toll-as-decimal-string and DA metadata only; refusals name the FIELD/PATH, never the bytes.
19
- import { LEDGER, claimBody, removeOwnerBody, updateChannelDaBody, updateChannelWritePolicyBody, updateChannelTollBody, channelBody, } from "@mcsherrylabs/evolver-client";
20
- import { DEFAULT_TTL_OFFSET, composeAndSign, hexToBytes, writableChannelId } from "./write.js";
21
- import { parseTollAmount, formatAmount } from "./amount.js";
22
- /** Read the chain tip to bound a transaction's life; an unreachable chain is `unreachable`, never a
23
- * submit. */
24
- async function tipOrUnreachable(deps) {
25
- try {
26
- return await deps.reads.currentRound();
27
- }
28
- catch (e) {
29
- return { kind: "unreachable", chain: "", cause: e instanceof Error ? e.message : String(e) };
30
- }
31
- }
32
- /** The largest body a channel write will sign, in bytes (mirrors `signOpaque`'s bound). */
33
- const MAX_BODY_BYTES = 65536 - 1024;
34
- /** The two write policies the wire carries. `writePolicyWire` narrows anything-but-"open" to proto
35
- * zero (default `owner_or_group`), so a typo is silently widened to the default — enumerated and
36
- * refused here (Pitfall 5). */
37
- const WRITE_POLICIES = ["owner_or_group", "open"];
38
- /** Enumerate a caller-supplied `writePolicy` against the wire's two values; refuse anything else
39
- * (a typo here would silently widen to `owner_or_group`, a data-integrity risk). */
40
- function policyOrRefusal(raw) {
41
- const p = String(raw ?? "").trim();
42
- if (WRITE_POLICIES.includes(p))
43
- return p;
44
- return {
45
- kind: "partial",
46
- what: "writePolicy",
47
- cause: `"${p}" is not a write policy — it must be "owner_or_group" or "open". Anything else is ` +
48
- `narrowed to the default and silently loses the intended policy, so it is refused here.`,
49
- };
50
- }
51
- /**
52
- * Claim a channel (SIGN-14): become its owner and set its terms. Signed for `deps.identity` on
53
- * LEDGER.owners, targeting the caller's validated non-core/non-reserved channel. Does NOT submit.
54
- */
55
- export async function signChannelClaim(deps, params) {
56
- // 1. the channel — the refusal that pays for the caller-chosen-ledger exemption.
57
- const channel = writableChannelId(params.channel);
58
- if (typeof channel !== "string")
59
- return channel;
60
- // 2. an optional write policy, enumerated (Pitfall 5) BEFORE anything reaches the wire.
61
- let writePolicy;
62
- if (params.writePolicy !== undefined && String(params.writePolicy ?? "").trim().length > 0) {
63
- const p = policyOrRefusal(params.writePolicy);
64
- if (typeof p !== "string")
65
- return p;
66
- writePolicy = p;
67
- }
68
- // 3. an optional toll, refused locally when negative (a negative amount would not fail to encode —
69
- // it would encode as a different positive number).
70
- let tollAmount;
71
- if (params.tollAmount !== undefined) {
72
- const a = parseTollAmount(params.tollAmount);
73
- if (!a.ok)
74
- return { kind: "partial", what: "tollAmount", cause: a.error };
75
- tollAmount = a.value;
76
- }
77
- const tip = await tipOrUnreachable(deps);
78
- if (typeof tip !== "number")
79
- return tip;
80
- const expiresAtRound = tip + (deps.ttlOffset ?? DEFAULT_TTL_OFFSET);
81
- const fields = { channel };
82
- if (params.groupOwner)
83
- fields.groupOwner = String(params.groupOwner);
84
- if (writePolicy)
85
- fields.writePolicy = writePolicy;
86
- if (params.daGroup)
87
- fields.daGroup = String(params.daGroup);
88
- if (params.daThresholdM !== undefined)
89
- fields.daThresholdM = String(params.daThresholdM);
90
- if (tollAmount !== undefined)
91
- fields.tollAmount = formatAmount(tollAmount);
92
- if (tollAmount !== 0n && params.tollRecipient)
93
- fields.tollRecipient = String(params.tollRecipient);
94
- return composeAndSign(deps, {
95
- ledgerId: LEDGER.owners,
96
- body: claimBody({
97
- ledgerId: channel,
98
- groupOwner: params.groupOwner ? String(params.groupOwner) : undefined,
99
- daGroup: params.daGroup ? String(params.daGroup) : undefined,
100
- daThresholdM: params.daThresholdM,
101
- tollAmount: tollAmount === 0n ? undefined : tollAmount,
102
- tollRecipient: tollAmount !== 0n && params.tollRecipient ? String(params.tollRecipient) : undefined,
103
- writePolicy,
104
- }),
105
- ttlRound: expiresAtRound,
106
- signedAtRound: tip,
107
- verb: "channel_claim",
108
- fields,
109
- });
110
- }
111
- /**
112
- * Write an opaque payload to a channel (SIGN-13), carrying the toll-consent `maxToll`. The caller
113
- * chooses the bytes and the channel (never a core/reserved ledger — `writableChannelId` refuses those
114
- * FIRST); the MCP signs the ceiling the write consents to. `maxToll` is optional: omitted it signs
115
- * "consents to no toll" (0), which the node refuses with `toll_ceiling_too_low` on a tolled channel.
116
- */
117
- export async function signChannelWrite(deps, params) {
118
- // 1. the channel — the refusal that pays for the caller-chosen-ledger exemption.
119
- const channel = writableChannelId(params.channel);
120
- if (typeof channel !== "string")
121
- return channel;
122
- // 2. the body, hex — decoded by the ONE decoder (`hexToBytes`, imported from write.ts, never a
123
- // hand-rolled second), with empty/oversized refusals before anything is signed.
124
- let body;
125
- try {
126
- body = hexToBytes(String(params.bodyHex ?? "").trim());
127
- }
128
- catch (e) {
129
- return { kind: "partial", what: "bodyHex", cause: e instanceof Error ? e.message : String(e) };
130
- }
131
- if (body.length === 0)
132
- return {
133
- kind: "partial",
134
- what: "bodyHex",
135
- cause: "no body given — a channel write carries the bytes you supply, and an empty one costs the same while conveying nothing",
136
- };
137
- if (body.length > MAX_BODY_BYTES)
138
- return {
139
- kind: "partial",
140
- what: "bodyHex",
141
- cause: `${body.length} bytes is over the ${MAX_BODY_BYTES}-byte limit this verb will sign`,
142
- };
143
- // 3. a canonical nonnegative ceiling when supplied; only omission defaults to no consent.
144
- let maxToll = 0n;
145
- if (params.maxToll !== undefined) {
146
- const m = parseTollAmount(params.maxToll);
147
- if (!m.ok)
148
- return { kind: "partial", what: "maxToll", cause: m.error };
149
- maxToll = m.value;
150
- }
151
- const tip = await tipOrUnreachable(deps);
152
- if (typeof tip !== "number")
153
- return tip;
154
- const expiresAtRound = tip + (deps.ttlOffset ?? DEFAULT_TTL_OFFSET);
155
- return composeAndSign(deps, {
156
- ledgerId: channel,
157
- body: channelBody(body),
158
- ttlRound: expiresAtRound,
159
- signedAtRound: tip,
160
- verb: "channel_write",
161
- fields: { channel, bodyBytes: String(body.length) },
162
- maxToll,
163
- });
164
- }
165
- /**
166
- * Unclaim a channel (SIGN-15): `removeOwnerBody(ledgerId)` is the unclaim — it gives up ownership.
167
- * Signed on LEDGER.owners; the inner channel target is refused if core/reserved. Does NOT submit.
168
- */
169
- export async function signChannelUnclaim(deps, params) {
170
- const channel = writableChannelId(params.channel);
171
- if (typeof channel !== "string")
172
- return channel;
173
- const tip = await tipOrUnreachable(deps);
174
- if (typeof tip !== "number")
175
- return tip;
176
- const expiresAtRound = tip + (deps.ttlOffset ?? DEFAULT_TTL_OFFSET);
177
- return composeAndSign(deps, {
178
- ledgerId: LEDGER.owners,
179
- body: removeOwnerBody(channel),
180
- ttlRound: expiresAtRound,
181
- signedAtRound: tip,
182
- verb: "channel_unclaim",
183
- fields: { channel },
184
- });
185
- }
186
- /**
187
- * Set a channel's write policy (SIGN-18): `"owner_or_group"` or `"open"`. The policy is ENUMERATED
188
- * locally (Pitfall 5 — `writePolicyWire` narrows a typo to the default, silently) and refused
189
- * otherwise. Does NOT submit.
190
- */
191
- export async function signChannelWritePolicy(deps, params) {
192
- const channel = writableChannelId(params.channel);
193
- if (typeof channel !== "string")
194
- return channel;
195
- const writePolicy = policyOrRefusal(params.writePolicy);
196
- if (typeof writePolicy !== "string")
197
- return writePolicy;
198
- const tip = await tipOrUnreachable(deps);
199
- if (typeof tip !== "number")
200
- return tip;
201
- const expiresAtRound = tip + (deps.ttlOffset ?? DEFAULT_TTL_OFFSET);
202
- return composeAndSign(deps, {
203
- ledgerId: LEDGER.owners,
204
- body: updateChannelWritePolicyBody({ ledgerId: channel, writePolicy }),
205
- ttlRound: expiresAtRound,
206
- signedAtRound: tip,
207
- verb: "channel_write_policy",
208
- fields: { channel, writePolicy },
209
- });
210
- }
211
- /**
212
- * Set a channel's toll (SIGN-17). A positive `tollAmount` sets the toll; `"0"`/omitted removes it
213
- * (composes `updateChannelTollBody({ ledgerId })` with no `tollAmount`, clearing the toll). A
214
- * NEGATIVE `tollAmount` is refused locally — it would encode as a different positive number, not fail.
215
- * Does NOT submit.
216
- */
217
- export async function signChannelToll(deps, params) {
218
- const channel = writableChannelId(params.channel);
219
- if (typeof channel !== "string")
220
- return channel;
221
- let tollAmount;
222
- if (params.tollAmount !== undefined) {
223
- const a = parseTollAmount(params.tollAmount);
224
- if (!a.ok)
225
- return { kind: "partial", what: "tollAmount", cause: a.error };
226
- tollAmount = a.value;
227
- }
228
- const tip = await tipOrUnreachable(deps);
229
- if (typeof tip !== "number")
230
- return tip;
231
- const expiresAtRound = tip + (deps.ttlOffset ?? DEFAULT_TTL_OFFSET);
232
- const fields = { channel };
233
- if (tollAmount !== undefined)
234
- fields.tollAmount = formatAmount(tollAmount);
235
- if (tollAmount !== 0n && params.tollRecipient)
236
- fields.tollRecipient = String(params.tollRecipient);
237
- return composeAndSign(deps, {
238
- ledgerId: LEDGER.owners,
239
- body: updateChannelTollBody({
240
- ledgerId: channel,
241
- tollAmount: tollAmount === 0n ? undefined : tollAmount,
242
- tollRecipient: tollAmount !== 0n && params.tollRecipient ? String(params.tollRecipient) : undefined,
243
- }),
244
- ttlRound: expiresAtRound,
245
- signedAtRound: tip,
246
- verb: "channel_toll",
247
- fields,
248
- });
249
- }
250
- /**
251
- * Set a channel's data-availability policy (SIGN-16): the group that must hold (and attest for) its
252
- * bodies, and the M-of-N threshold. The SDK THROWS when `daThresholdM` is set but `daGroup` is empty,
253
- * so the encoder call is wrapped and the throw surfaced as `partial daGroup` rather than escaping.
254
- * Does NOT submit.
255
- */
256
- export async function signChannelDa(deps, params) {
257
- const channel = writableChannelId(params.channel);
258
- if (typeof channel !== "string")
259
- return channel;
260
- const daGroup = params.daGroup !== undefined ? String(params.daGroup ?? "").trim() : undefined;
261
- const daThresholdM = params.daThresholdM;
262
- let body;
263
- try {
264
- body = updateChannelDaBody({ ledgerId: channel, daGroup, daThresholdM });
265
- }
266
- catch (e) {
267
- return { kind: "partial", what: "daGroup", cause: e instanceof Error ? e.message : String(e) };
268
- }
269
- const tip = await tipOrUnreachable(deps);
270
- if (typeof tip !== "number")
271
- return tip;
272
- const expiresAtRound = tip + (deps.ttlOffset ?? DEFAULT_TTL_OFFSET);
273
- const fields = { channel };
274
- if (daGroup)
275
- fields.daGroup = daGroup;
276
- if (daThresholdM !== undefined)
277
- fields.daThresholdM = String(daThresholdM);
278
- return composeAndSign(deps, {
279
- ledgerId: LEDGER.owners,
280
- body,
281
- ttlRound: expiresAtRound,
282
- signedAtRound: tip,
283
- verb: "channel_da",
284
- fields,
285
- });
286
- }
287
- //# sourceMappingURL=channel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"channel.js","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,qGAAqG;AACrG,kGAAkG;AAClG,4CAA4C;AAC5C,EAAE;AACF,+FAA+F;AAC/F,iGAAiG;AACjG,gGAAgG;AAChG,oGAAoG;AACpG,iGAAiG;AACjG,EAAE;AACF,kGAAkG;AAClG,kGAAkG;AAClG,6FAA6F;AAC7F,uEAAuE;AACvE,EAAE;AACF,mGAAmG;AACnG,8FAA8F;AAE9F,OAAO,EACL,MAAM,EACN,SAAS,EACT,eAAe,EACf,mBAAmB,EACnB,4BAA4B,EAC5B,qBAAqB,EACrB,WAAW,GACZ,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/F,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAe5D;cACc;AACd,KAAK,UAAU,gBAAgB,CAAC,IAAoB;IAClD,IAAI,CAAC;QACH,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;IACzC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/F,CAAC;AACH,CAAC;AAED,2FAA2F;AAC3F,MAAM,cAAc,GAAG,KA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