@mcsherrylabs/evolver-mcp 0.13.0 → 0.15.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 (118) hide show
  1. package/deploy/docker-compose.http.yml +45 -0
  2. package/deploy/docker-compose.yml +4 -1
  3. package/dist/application-signer.d.ts +1 -1
  4. package/dist/application-signer.d.ts.map +1 -1
  5. package/dist/attachments.d.ts +1 -1
  6. package/dist/attachments.d.ts.map +1 -1
  7. package/dist/attachments.js +2 -2
  8. package/dist/attachments.js.map +1 -1
  9. package/dist/bootstrap.d.ts +36 -4
  10. package/dist/bootstrap.d.ts.map +1 -1
  11. package/dist/bootstrap.js +35 -11
  12. package/dist/bootstrap.js.map +1 -1
  13. package/dist/content-file-tools.js +1 -1
  14. package/dist/content-file-tools.js.map +1 -1
  15. package/dist/content-files.d.ts +1 -1
  16. package/dist/content-files.d.ts.map +1 -1
  17. package/dist/content-files.js +1 -1
  18. package/dist/content-files.js.map +1 -1
  19. package/dist/content-ranges.d.ts +1 -1
  20. package/dist/content-ranges.d.ts.map +1 -1
  21. package/dist/group-crypto-tools.js +1 -1
  22. package/dist/group-crypto-tools.js.map +1 -1
  23. package/dist/group-crypto.d.ts +2 -2
  24. package/dist/group-crypto.d.ts.map +1 -1
  25. package/dist/group-crypto.js +1 -1
  26. package/dist/group-crypto.js.map +1 -1
  27. package/dist/http-transport.d.ts +87 -0
  28. package/dist/http-transport.d.ts.map +1 -0
  29. package/dist/http-transport.js +359 -0
  30. package/dist/http-transport.js.map +1 -0
  31. package/dist/inbox.d.ts +1 -1
  32. package/dist/inbox.d.ts.map +1 -1
  33. package/dist/inbox.js +1 -1
  34. package/dist/inbox.js.map +1 -1
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +254 -115
  37. package/dist/index.js.map +1 -1
  38. package/dist/install-http.d.ts +27 -0
  39. package/dist/install-http.d.ts.map +1 -0
  40. package/dist/install-http.js +192 -0
  41. package/dist/install-http.js.map +1 -0
  42. package/dist/install.d.ts +18 -0
  43. package/dist/install.d.ts.map +1 -1
  44. package/dist/install.js +128 -22
  45. package/dist/install.js.map +1 -1
  46. package/dist/login.d.ts +1 -1
  47. package/dist/login.d.ts.map +1 -1
  48. package/dist/mcp.d.ts +2 -2
  49. package/dist/mcp.d.ts.map +1 -1
  50. package/dist/p2p.d.ts +1 -1
  51. package/dist/p2p.d.ts.map +1 -1
  52. package/dist/p2p.js +1 -1
  53. package/dist/p2p.js.map +1 -1
  54. package/dist/processor.d.ts +1 -1
  55. package/dist/processor.d.ts.map +1 -1
  56. package/dist/processor.js +1 -1
  57. package/dist/processor.js.map +1 -1
  58. package/dist/signed-http.d.ts +1 -1
  59. package/dist/signed-http.d.ts.map +1 -1
  60. package/dist/tools.d.ts +5 -3
  61. package/dist/tools.d.ts.map +1 -1
  62. package/dist/tools.js +34 -34
  63. package/dist/tools.js.map +1 -1
  64. package/dist/transaction-interchange-tools.js +1 -1
  65. package/dist/transaction-interchange-tools.js.map +1 -1
  66. package/dist/transaction-interchange.d.ts +5 -2
  67. package/dist/transaction-interchange.d.ts.map +1 -1
  68. package/dist/transaction-interchange.js +10 -10
  69. package/dist/transaction-interchange.js.map +1 -1
  70. package/package.json +10 -16
  71. package/dist/amount.d.ts +0 -23
  72. package/dist/amount.d.ts.map +0 -1
  73. package/dist/amount.js +0 -53
  74. package/dist/amount.js.map +0 -1
  75. package/dist/channel.d.ts +0 -77
  76. package/dist/channel.d.ts.map +0 -1
  77. package/dist/channel.js +0 -287
  78. package/dist/channel.js.map +0 -1
  79. package/dist/claim.d.ts +0 -48
  80. package/dist/claim.d.ts.map +0 -1
  81. package/dist/claim.js +0 -81
  82. package/dist/claim.js.map +0 -1
  83. package/dist/content.d.ts +0 -94
  84. package/dist/content.d.ts.map +0 -1
  85. package/dist/content.js +0 -215
  86. package/dist/content.js.map +0 -1
  87. package/dist/group-ownership.d.ts +0 -78
  88. package/dist/group-ownership.d.ts.map +0 -1
  89. package/dist/group-ownership.js +0 -324
  90. package/dist/group-ownership.js.map +0 -1
  91. package/dist/group.d.ts +0 -60
  92. package/dist/group.d.ts.map +0 -1
  93. package/dist/group.js +0 -204
  94. package/dist/group.js.map +0 -1
  95. package/dist/identity.d.ts +0 -87
  96. package/dist/identity.d.ts.map +0 -1
  97. package/dist/identity.js +0 -236
  98. package/dist/identity.js.map +0 -1
  99. package/dist/node-transport.d.ts +0 -14
  100. package/dist/node-transport.d.ts.map +0 -1
  101. package/dist/node-transport.js +0 -54
  102. package/dist/node-transport.js.map +0 -1
  103. package/dist/read.d.ts +0 -252
  104. package/dist/read.d.ts.map +0 -1
  105. package/dist/read.js +0 -320
  106. package/dist/read.js.map +0 -1
  107. package/dist/result.d.ts +0 -110
  108. package/dist/result.d.ts.map +0 -1
  109. package/dist/result.js +0 -97
  110. package/dist/result.js.map +0 -1
  111. package/dist/signer.d.ts +0 -37
  112. package/dist/signer.d.ts.map +0 -1
  113. package/dist/signer.js +0 -76
  114. package/dist/signer.js.map +0 -1
  115. package/dist/write.d.ts +0 -214
  116. package/dist/write.d.ts.map +0 -1
  117. package/dist/write.js +0 -399
  118. package/dist/write.js.map +0 -1
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,2B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AAM,CAAC,MAAM,YAAY,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,a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iBAAiB,CAAC,CAmB5B;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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,SAAS,EAAE,KAAK,EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACjG,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACzC,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC;IACxC,MAAM,cAAc,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,SAAS,IAAI,kBAAkB,CAAC,CAAC;IAEpE,MAAM,MAAM,GAA2B,EAAE,OAAO,EAAE,CAAC;IACnD,IAAI,OAAO;QAAE,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;IACtC,IAAI,YAAY,KAAK,SAAS;QAAE,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;IAE3E,OAAO,cAAc,CAAC,IAAI,EAAE;QAC1B,QAAQ,EAAE,MAAM,CAAC,MAAM;QACvB,IAAI;QACJ,QAAQ,EAAE,cAAc;QACxB,aAAa,EAAE,GAAG;QAClB,IAAI,EAAE,YAAY;QAClB,MAAM;KACP,CAAsB,CAAC;AAC1B,CAAC"}
package/dist/claim.d.ts DELETED
@@ -1,48 +0,0 @@
1
- import type { ClaimResult } from "@mcsherrylabs/evolver-client";
2
- import type { ToolResult } from "./result.js";
3
- /** What `claimIdentity` needs from the world: exactly the SDK's claim affordance, injected so the
4
- * whole flow is exercisable against a structural fake rather than a live node. */
5
- export interface ClaimFn {
6
- (args: {
7
- nodeId: string;
8
- blsPublicKey: Uint8Array;
9
- blsPop: Uint8Array;
10
- ed25519PublicKey: Uint8Array;
11
- ed25519Pop: Uint8Array;
12
- }): Promise<ClaimResult>;
13
- }
14
- /** What a successful claim answers. `committed` carries the block height it committed at; `exists`
15
- * means the identity was already on-chain (an idempotent rerun). No key bytes, no proofs, no
16
- * `txId` — the claim has nothing to submit later. */
17
- export type ClaimSummary = {
18
- name: string;
19
- outcome: "committed";
20
- blockHeight: number;
21
- } | {
22
- name: string;
23
- outcome: "exists";
24
- };
25
- /**
26
- * Claim a FRESH identity via the node-sponsored faucet (SIGN-08).
27
- *
28
- * ⚠️ NOT A SIGNING VERB. The holder produced both proofs elsewhere; this MCP holds neither key, so
29
- * it forwards the holder's proofs to the SDK and the node sponsors + pays. Nothing is recorded in
30
- * the session stores, no `txId` is returned, and nothing reaches `evolver_submit`.
31
- *
32
- * ⚠️ THE DIGEST IS NEVER RECOMPUTED HERE. The SDK's `claimIdentityWithProofs` recomputes the claim
33
- * digest locally and refuses `digest_mismatch` before the sponsored `create`, so a claim whose
34
- * proofs cover the wrong bytes aborts rather than signing server-chosen bytes.
35
- *
36
- * An empty `blsPop`/`ed25519Pop` (hex-decodes to zero bytes) is refused BEFORE any `claim` call:
37
- * the holder must prove possession, and this MCP forwards for no key it does not hold (T-03-10).
38
- */
39
- export declare function claimIdentity(deps: {
40
- claim: ClaimFn;
41
- }, params: {
42
- nodeId: string;
43
- blsPublicKey: string;
44
- blsPop: string;
45
- ed25519PublicKey: string;
46
- ed25519Pop: string;
47
- }): Promise<ToolResult<ClaimSummary>>;
48
- //# sourceMappingURL=claim.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"claim.d.ts","sourceRoot":"","sources":["../src/claim.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;mFACmF;AACnF,MAAM,WAAW,OAAO;IACtB,CAAC,IAAI,EAAE;QACL,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,EAAE,UAAU,CAAC;QACzB,MAAM,EAAE,UAAU,CAAC;QACnB,gBAAgB,EAAE,UAAU,CAAC;QAC7B,UAAU,EAAE,UAAU,CAAC;KACxB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CAC1B;AAED;;sDAEsD;AACtD,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAC3D;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;AAaxC;;;;;;;;;;;;;GAaG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,EACxB,MAAM,EAAE;IACN,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;CACpB,GACA,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CA8CnC"}
package/dist/claim.js DELETED
@@ -1,81 +0,0 @@
1
- // The faucet identity claim (SIGN-08) — the ONE deliberate asymmetry from the "every verb signs
2
- // and returns a txId" rule. It is NOT a signing verb: it is a DIRECT node call through
3
- // `NodeClient.claimIdentityWithProofs`, because the MCP holds NEITHER key of the identity being
4
- // claimed (both proofs are produced by the holder), the node sponsors and pays a fixed credit, and
5
- // the SDK already recomputes the proof-of-possession digest locally and refuses on mismatch.
6
- import { hexToBytes } from "@mcsherrylabs/evolver-client";
7
- /** Decode one hex field, refusing on non-hex/odd-length input. The refusal names the FIELD, never
8
- * the bytes (T-03-09). The SDK's `hexToBytes` throws a precise reason on bad input, which is what
9
- * the `partial` cause carries. */
10
- function parseHex(field, raw) {
11
- try {
12
- return hexToBytes(String(raw ?? "").trim());
13
- }
14
- catch (e) {
15
- return { field, cause: e instanceof Error ? e.message : String(e) };
16
- }
17
- }
18
- /**
19
- * Claim a FRESH identity via the node-sponsored faucet (SIGN-08).
20
- *
21
- * ⚠️ NOT A SIGNING VERB. The holder produced both proofs elsewhere; this MCP holds neither key, so
22
- * it forwards the holder's proofs to the SDK and the node sponsors + pays. Nothing is recorded in
23
- * the session stores, no `txId` is returned, and nothing reaches `evolver_submit`.
24
- *
25
- * ⚠️ THE DIGEST IS NEVER RECOMPUTED HERE. The SDK's `claimIdentityWithProofs` recomputes the claim
26
- * digest locally and refuses `digest_mismatch` before the sponsored `create`, so a claim whose
27
- * proofs cover the wrong bytes aborts rather than signing server-chosen bytes.
28
- *
29
- * An empty `blsPop`/`ed25519Pop` (hex-decodes to zero bytes) is refused BEFORE any `claim` call:
30
- * the holder must prove possession, and this MCP forwards for no key it does not hold (T-03-10).
31
- */
32
- export async function claimIdentity(deps, params) {
33
- const name = String(params.nodeId ?? "").trim();
34
- if (name.length === 0)
35
- return { kind: "partial", what: "nodeId", cause: "the new identity needs a name" };
36
- const blsPublicKey = parseHex("blsPublicKey", params.blsPublicKey);
37
- if ("field" in blsPublicKey)
38
- return { kind: "partial", what: blsPublicKey.field, cause: blsPublicKey.cause };
39
- const blsPop = parseHex("blsPop", params.blsPop);
40
- if ("field" in blsPop)
41
- return { kind: "partial", what: blsPop.field, cause: blsPop.cause };
42
- const ed25519PublicKey = parseHex("ed25519PublicKey", params.ed25519PublicKey);
43
- if ("field" in ed25519PublicKey)
44
- return { kind: "partial", what: ed25519PublicKey.field, cause: ed25519PublicKey.cause };
45
- const ed25519Pop = parseHex("ed25519Pop", params.ed25519Pop);
46
- if ("field" in ed25519Pop)
47
- return { kind: "partial", what: ed25519Pop.field, cause: ed25519Pop.cause };
48
- // Empty-PoP refusal: the holder must prove possession, and this MCP signs/forwards for no key it
49
- // does not hold. Named by FIELD, never by bytes.
50
- if (blsPop.length === 0)
51
- return {
52
- kind: "partial",
53
- what: "blsPop",
54
- cause: "both keys need a proof of possession from their holder — this agent holds neither key",
55
- };
56
- if (ed25519Pop.length === 0)
57
- return {
58
- kind: "partial",
59
- what: "ed25519Pop",
60
- cause: "both keys need a proof of possession from their holder — this agent holds neither key",
61
- };
62
- try {
63
- const r = await deps.claim({ nodeId: name, blsPublicKey, blsPop, ed25519PublicKey, ed25519Pop });
64
- if (r.kind === "committed")
65
- return { kind: "ok", value: { name, outcome: "committed", blockHeight: r.blockHeight } };
66
- if (r.kind === "exists")
67
- return { kind: "ok", value: { name, outcome: "exists" } };
68
- // ⚠️ A refusal from the node is an ANSWER, not a transport failure, and names the node's own
69
- // reason — including `digest_mismatch`, which means the bytes those proofs cover are not the
70
- // bytes this chain wants signed. `error`/`message` surface verbatim.
71
- return {
72
- kind: "partial",
73
- what: "claim",
74
- cause: `${r.error ?? "refused"}: ${r.message ?? ""}`,
75
- };
76
- }
77
- catch (e) {
78
- return { kind: "unreachable", chain: "", cause: e instanceof Error ? e.message : String(e) };
79
- }
80
- }
81
- //# sourceMappingURL=claim.js.map
package/dist/claim.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"claim.js","sourceRoot":"","sources":["../src/claim.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,uFAAuF;AACvF,gGAAgG;AAChG,mGAAmG;AACnG,6FAA6F;AAE7F,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAuB1D;;mCAEmC;AACnC,SAAS,QAAQ,CAAC,KAAa,EAAE,GAAW;IAC1C,IAAI,CAAC;QACH,OAAO,UAAU,CAAC,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACtE,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,IAAwB,EACxB,MAMC;IAED,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,C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