@mcsherrylabs/evolver-mcp 0.11.0 → 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.
Files changed (137) hide show
  1. package/deploy/release.json +1 -1
  2. package/dist/application-signer.d.ts +16 -0
  3. package/dist/application-signer.d.ts.map +1 -0
  4. package/dist/application-signer.js +55 -0
  5. package/dist/application-signer.js.map +1 -0
  6. package/dist/approved-request.d.ts +30 -0
  7. package/dist/approved-request.d.ts.map +1 -0
  8. package/dist/approved-request.js +167 -0
  9. package/dist/approved-request.js.map +1 -0
  10. package/dist/attachment-tools.d.ts +3 -0
  11. package/dist/attachment-tools.d.ts.map +1 -0
  12. package/dist/attachment-tools.js +32 -0
  13. package/dist/attachment-tools.js.map +1 -0
  14. package/dist/attachments.d.ts +41 -0
  15. package/dist/attachments.d.ts.map +1 -0
  16. package/dist/attachments.js +458 -0
  17. package/dist/attachments.js.map +1 -0
  18. package/dist/content-file-tools.d.ts +3 -0
  19. package/dist/content-file-tools.d.ts.map +1 -0
  20. package/dist/content-file-tools.js +67 -0
  21. package/dist/content-file-tools.js.map +1 -0
  22. package/dist/content-files.d.ts +32 -0
  23. package/dist/content-files.d.ts.map +1 -0
  24. package/dist/content-files.js +79 -0
  25. package/dist/content-files.js.map +1 -0
  26. package/dist/content-ranges.d.ts +41 -0
  27. package/dist/content-ranges.d.ts.map +1 -0
  28. package/dist/content-ranges.js +75 -0
  29. package/dist/content-ranges.js.map +1 -0
  30. package/dist/content.d.ts +62 -19
  31. package/dist/content.d.ts.map +1 -1
  32. package/dist/content.js +180 -25
  33. package/dist/content.js.map +1 -1
  34. package/dist/files.d.ts +60 -0
  35. package/dist/files.d.ts.map +1 -0
  36. package/dist/files.js +355 -0
  37. package/dist/files.js.map +1 -0
  38. package/dist/group-crypto-tools.d.ts +3 -0
  39. package/dist/group-crypto-tools.d.ts.map +1 -0
  40. package/dist/group-crypto-tools.js +47 -0
  41. package/dist/group-crypto-tools.js.map +1 -0
  42. package/dist/group-crypto.d.ts +24 -0
  43. package/dist/group-crypto.d.ts.map +1 -0
  44. package/dist/group-crypto.js +135 -0
  45. package/dist/group-crypto.js.map +1 -0
  46. package/dist/group-key-provider.d.ts +30 -0
  47. package/dist/group-key-provider.d.ts.map +1 -0
  48. package/dist/group-key-provider.js +72 -0
  49. package/dist/group-key-provider.js.map +1 -0
  50. package/dist/group-keys.d.ts +34 -0
  51. package/dist/group-keys.d.ts.map +1 -0
  52. package/dist/group-keys.js +88 -0
  53. package/dist/group-keys.js.map +1 -0
  54. package/dist/group-ownership.d.ts +78 -0
  55. package/dist/group-ownership.d.ts.map +1 -0
  56. package/dist/group-ownership.js +324 -0
  57. package/dist/group-ownership.js.map +1 -0
  58. package/dist/group.d.ts +2 -2
  59. package/dist/group.js +3 -3
  60. package/dist/group.js.map +1 -1
  61. package/dist/http-profiles.d.ts +47 -0
  62. package/dist/http-profiles.d.ts.map +1 -0
  63. package/dist/http-profiles.js +161 -0
  64. package/dist/http-profiles.js.map +1 -0
  65. package/dist/human-approval.d.ts +14 -0
  66. package/dist/human-approval.d.ts.map +1 -0
  67. package/dist/human-approval.js +34 -0
  68. package/dist/human-approval.js.map +1 -0
  69. package/dist/index.d.ts +11 -0
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.js +94 -40
  72. package/dist/index.js.map +1 -1
  73. package/dist/login-profiles.d.ts +25 -0
  74. package/dist/login-profiles.d.ts.map +1 -0
  75. package/dist/login-profiles.js +77 -0
  76. package/dist/login-profiles.js.map +1 -0
  77. package/dist/login-tools.d.ts +3 -0
  78. package/dist/login-tools.d.ts.map +1 -0
  79. package/dist/login-tools.js +27 -0
  80. package/dist/login-tools.js.map +1 -0
  81. package/dist/login.d.ts +36 -0
  82. package/dist/login.d.ts.map +1 -0
  83. package/dist/login.js +144 -0
  84. package/dist/login.js.map +1 -0
  85. package/dist/mcp.d.ts +1 -0
  86. package/dist/mcp.d.ts.map +1 -1
  87. package/dist/mcp.js +22 -6
  88. package/dist/mcp.js.map +1 -1
  89. package/dist/node-transport.d.ts +14 -0
  90. package/dist/node-transport.d.ts.map +1 -0
  91. package/dist/node-transport.js +54 -0
  92. package/dist/node-transport.js.map +1 -0
  93. package/dist/p2p-tools.d.ts +3 -0
  94. package/dist/p2p-tools.d.ts.map +1 -0
  95. package/dist/p2p-tools.js +52 -0
  96. package/dist/p2p-tools.js.map +1 -0
  97. package/dist/p2p.d.ts +67 -0
  98. package/dist/p2p.d.ts.map +1 -0
  99. package/dist/p2p.js +326 -0
  100. package/dist/p2p.js.map +1 -0
  101. package/dist/proof-attempts.d.ts +19 -0
  102. package/dist/proof-attempts.d.ts.map +1 -0
  103. package/dist/proof-attempts.js +30 -0
  104. package/dist/proof-attempts.js.map +1 -0
  105. package/dist/read.d.ts +60 -1
  106. package/dist/read.d.ts.map +1 -1
  107. package/dist/read.js +97 -5
  108. package/dist/read.js.map +1 -1
  109. package/dist/signed-http-tools.d.ts +3 -0
  110. package/dist/signed-http-tools.d.ts.map +1 -0
  111. package/dist/signed-http-tools.js +33 -0
  112. package/dist/signed-http-tools.js.map +1 -0
  113. package/dist/signed-http.d.ts +30 -0
  114. package/dist/signed-http.d.ts.map +1 -0
  115. package/dist/signed-http.js +114 -0
  116. package/dist/signed-http.js.map +1 -0
  117. package/dist/tools.d.ts +27 -1
  118. package/dist/tools.d.ts.map +1 -1
  119. package/dist/tools.js +243 -32
  120. package/dist/tools.js.map +1 -1
  121. package/dist/transaction-interchange-tools.d.ts +3 -0
  122. package/dist/transaction-interchange-tools.d.ts.map +1 -0
  123. package/dist/transaction-interchange-tools.js +41 -0
  124. package/dist/transaction-interchange-tools.js.map +1 -0
  125. package/dist/transaction-interchange.d.ts +141 -0
  126. package/dist/transaction-interchange.d.ts.map +1 -0
  127. package/dist/transaction-interchange.js +502 -0
  128. package/dist/transaction-interchange.js.map +1 -0
  129. package/dist/transaction-policy.d.ts +32 -0
  130. package/dist/transaction-policy.d.ts.map +1 -0
  131. package/dist/transaction-policy.js +89 -0
  132. package/dist/transaction-policy.js.map +1 -0
  133. package/dist/write.d.ts +52 -13
  134. package/dist/write.d.ts.map +1 -1
  135. package/dist/write.js +95 -25
  136. package/dist/write.js.map +1 -1
  137. package/package.json +4 -3
@@ -0,0 +1,324 @@
1
+ // Group OWNERSHIP transfer (issue #9) — a two-party prepare → consent → finalize → submit workflow.
2
+ // NOT a credit transfer: `evolver_sign_transfer_many` moves credit; this hands a group to a new owner.
3
+ //
4
+ // The chain applies `TransferGroupOwnershipTxBody` only when the SignedTx carries an auth whose
5
+ // `node_id` is the incoming owner (GroupLedgerOrchestrator.applyTransferOwnership), and admission
6
+ // verifies EVERY auth against the named identity's REGISTERED (node_id, key_type, key_label) key
7
+ // over the same auth-free digest (BlockPayloadValidator.admitFilter / resolveAuths). So:
8
+ //
9
+ // 1. PREPARE (outgoing owner's session) — composes the intent with the SDK body composer and the
10
+ // SDK canonical digest. Signs NOTHING and records no bytes, so `evolver_submit` cannot find it.
11
+ // 2. CONSENT (incoming owner's session, its own host-held key) — recomputes the digest from the
12
+ // structured intent, refuses a mismatching txId, signs the digest with ITS signer and returns
13
+ // one public auth. It never holds a submittable envelope.
14
+ // 3. FINALIZE (outgoing owner's session) — re-reads the chain, verifies the consent signature
15
+ // against the incoming owner's REGISTERED key, then signs as sender and assembles BOTH auths
16
+ // with the SDK `encodeSignedTx`. Recorded once, strictly, by id.
17
+ // 4. `evolver_submit` — the ordinary path and its guards, unchanged.
18
+ //
19
+ // ⚠️ THE txId IS AUTH-FREE. SDK `txId` = node `signingMaterial` = SHA-256 over the tx-auth tag,
20
+ // ledger, sender, ttl, body hash and maxToll — no auths (SignedTxOps.txId, signed_tx.proto). So the
21
+ // prepared id, the consented id and the submitted id are one value; finalize re-derives and checks
22
+ // it rather than assuming.
23
+ //
24
+ // ⚠️ ONLY Ed25519 CONSENT IS ACCEPTED BY THIS WORKFLOW. Verifying before assembly is the point;
25
+ // a BLS consent remains refused locally, never assembled blind or verified by a hand-rolled
26
+ // pairing check. Published SDK 0.22.0 `edVerify` uses strict RFC 8032 verification (`zip215:false`),
27
+ // matching the node's strict Ed25519 mode rather than the former permissive ZIP215 behavior.
28
+ // This dependency update does not broaden accepted consent algorithms or remove local guards.
29
+ //
30
+ // ⚠️ KEY MATERIAL NEVER ENTERS OR LEAVES. Arguments and results carry names, the digest-bound
31
+ // intent, key type/label and the single consent signature; never a private key or signed envelope.
32
+ //
33
+ // ⚠️ THE CONSENT IS SAFE TO HAND OVER ONLY ON A NODE THAT REQUIRES THE SENDER'S OWN AUTH. Before
34
+ // the #9 node fix, admission/validation/apply accepted ANY verified auth, so the incoming owner's
35
+ // consent alone was a submittable transfer "from" the outgoing owner: a bearer artefact that seized
36
+ // the group and charged a sender who never signed. Every step therefore refuses unless the
37
+ // connected node's /status says `senderAuthorizationRequired: true` (SDK `nodeStatus`). That is
38
+ // the connected node's assertion only: the whole chain must run compatible nodes (a deployment
39
+ // prerequisite, not something this process can verify), and the canonical digest has no chain id,
40
+ // so a consent remains replayable on another chain with the same names/keys until it expires.
41
+ import { LEDGER, encodeSignedTx, txId as txDigest, transferGroupOwnershipBody, isValidGroupName, isValidNodeId, hexToBytes, edVerify, edSpkiToRaw, } from "@mcsherrylabs/evolver-client";
42
+ import { recordAssembledOnce, recordPendingOwnership, pendingOwnershipById, dropPendingOwnership, pruneExpiredPendingOwnership, recordedById, namedInRefusal, MAX_PENDING_OWNERSHIP, } from "./write.js";
43
+ /** Rounds of life for a two-party transfer. Longer than `DEFAULT_TTL_OFFSET` (50, sized for no
44
+ * human wait) because a second party must act, but never beyond the node's default
45
+ * `max-ttl-offset` (RoutingConfig.DefaultMaxTtlOffset = 100): a longer ttl is `ttl_too_far`, and
46
+ * a long-lived co-signed envelope is a bearer artefact. The default stays 10 rounds inside that
47
+ * bound so the two parties' nodes may disagree slightly about the tip. Expiry is final. */
48
+ export const OWNERSHIP_TTL_MAX = 100;
49
+ export const OWNERSHIP_TTL_DEFAULT = 90;
50
+ /** The one key type whose consent can be verified with a published SDK primitive. */
51
+ export const CONSENT_KEY_TYPE = "Ed25519";
52
+ export const INTENT_KIND = "evolver.group_ownership_intent.v1";
53
+ export const CONSENT_KIND = "evolver.group_ownership_consent.v1";
54
+ const PURPOSE = "AUTHORIZE"; // TxAuth.purpose default; encodeSignedTx writes no other.
55
+ const MAX_LABEL = 128;
56
+ const refuse = (what, cause) => ({ kind: "partial", what, cause });
57
+ const unreachable = (e) => ({ kind: "unreachable", chain: "", cause: e instanceof Error ? e.message : String(e) });
58
+ const hex = (b) => Buffer.from(b).toString("hex");
59
+ const str = (v) => (typeof v === "string" ? v.trim() : "");
60
+ /** The canonical digest (== txId) for one transfer intent, from the SDK composer and SDK digest.
61
+ * maxToll is 0: the groups ledger charges no toll and this workflow consents to none. */
62
+ function digestFor(outgoing, groupName, incoming, ttl) {
63
+ const body = transferGroupOwnershipBody({ groupName, newOwnerNodeId: incoming });
64
+ return { body, digest: txDigest(LEDGER.groups, outgoing, ttl, body, 0n) };
65
+ }
66
+ /** Refusals shared by every step, before any read: names and the outgoing/incoming distinction. */
67
+ function validNames(groupName, outgoing, incoming) {
68
+ if (!isValidGroupName(groupName))
69
+ return refuse("groupName", "not a valid group name");
70
+ if (!isValidNodeId(outgoing))
71
+ return refuse("outgoingOwner", "not a valid identity id");
72
+ if (!isValidNodeId(incoming))
73
+ return refuse("incomingOwner", "not a valid identity id");
74
+ if (outgoing === incoming)
75
+ return refuse("incomingOwner", "the incoming owner equals the outgoing owner — the chain fines that rather than refusing it");
76
+ return null;
77
+ }
78
+ /** Chain facts the chain will itself enforce at apply (a mismatch is a FINE, too late to refuse):
79
+ * the group's committed owner, and that the incoming owner is an existing identity, not a group. */
80
+ async function checkChainFacts(reads, groupName, outgoing, incoming) {
81
+ try {
82
+ const listed = (await reads.listGroups()).find((g) => g.ledgerId === groupName);
83
+ if (listed === undefined)
84
+ return { kind: "not_found", what: `group "${groupName}"` };
85
+ if (listed.owner !== outgoing)
86
+ return refuse("outgoingOwner", `group "${groupName}" is owned by "${listed.owner}" at the node's applied state, not "${outgoing}"`);
87
+ if ((await reads.getGroup(incoming)) !== null)
88
+ return refuse("incomingOwner", `"${incoming}" is a group; only an identity can own a group`);
89
+ if ((await reads.getIdentity(incoming)) === null)
90
+ return { kind: "not_found", what: `identity "${incoming}" (incoming owner)` };
91
+ }
92
+ catch (e) {
93
+ return unreachable(e);
94
+ }
95
+ return null;
96
+ }
97
+ /** Freshness under the chain's own admit rule: `tip < ttl <= tip + max-ttl-offset`. */
98
+ function checkFresh(tip, expiresAtRound) {
99
+ if (expiresAtRound <= tip)
100
+ return refuse("expiresAtRound", `expired: round ${expiresAtRound} is not after the current round ${tip}. Expiry is final; prepare a NEW transfer (a new txId) rather than reusing this one`);
101
+ if (expiresAtRound - tip > OWNERSHIP_TTL_MAX)
102
+ return refuse("expiresAtRound", `round ${expiresAtRound} is more than ${OWNERSHIP_TTL_MAX} rounds after the current round ${tip}; refused as over-long`);
103
+ return null;
104
+ }
105
+ /** The incoming owner's REGISTERED key for (identity, Ed25519, label), raw 32 bytes. Knowing a
106
+ * public key is not authority; only the chain's registration of it for this identity is. */
107
+ async function registeredEdKey(reads, who, keyLabel) {
108
+ let rows;
109
+ try {
110
+ rows = await reads.getIdentityKeys(who);
111
+ }
112
+ catch (e) {
113
+ return unreachable(e);
114
+ }
115
+ if (rows === null)
116
+ return { kind: "not_found", what: `identity "${who}"` };
117
+ const match = rows.filter((r) => r.keyType === CONSENT_KEY_TYPE && r.label === keyLabel);
118
+ if (match.length !== 1)
119
+ return refuse("consent.auth", `"${who}" has no single registered ${CONSENT_KEY_TYPE} key labelled "${keyLabel}" at the node's applied state (unknown_key on chain)`);
120
+ try {
121
+ return edSpkiToRaw(hexToBytes(match[0].publicKeyHex));
122
+ }
123
+ catch {
124
+ return refuse("consent.auth", `the registered ${CONSENT_KEY_TYPE} key for "${who}" is not a recognisable Ed25519 public key`);
125
+ }
126
+ }
127
+ /** Fail closed unless the CONNECTED node states it requires the sender's own AUTHORIZE auth.
128
+ * Absent/null/false/non-boolean is unsupported (`partial`); a failed read is `unreachable`. */
129
+ async function requireSenderAuthorizationNode(reads) {
130
+ let flag;
131
+ try {
132
+ flag = (await reads.nodeStatus()).senderAuthorizationRequired;
133
+ }
134
+ catch (e) {
135
+ return unreachable(e);
136
+ }
137
+ if (flag === true)
138
+ return null;
139
+ return refuse("node", "the connected node does not advertise senderAuthorizationRequired: true. On such a node the " +
140
+ "incoming owner's consent alone could be submitted as a transfer the outgoing owner never signed, " +
141
+ "so nothing is prepared, signed or returned. Use a node (and a chain) running the sender-authorization fix.");
142
+ }
143
+ async function tip(reads) {
144
+ try {
145
+ return await reads.currentRound();
146
+ }
147
+ catch (e) {
148
+ return unreachable(e);
149
+ }
150
+ }
151
+ /**
152
+ * PREPARE (outgoing owner). Signs nothing; returns the public intent for the incoming owner.
153
+ */
154
+ export async function prepareOwnershipTransfer(deps, params) {
155
+ const groupName = str(params.groupName), incoming = str(params.incomingOwner), outgoing = deps.identity;
156
+ const bad = validNames(groupName, outgoing, incoming);
157
+ if (bad)
158
+ return bad;
159
+ const ttlRounds = params.ttlRounds === undefined ? OWNERSHIP_TTL_DEFAULT : params.ttlRounds;
160
+ if (typeof ttlRounds !== "number" || !Number.isSafeInteger(ttlRounds) || ttlRounds < 1 || ttlRounds > OWNERSHIP_TTL_MAX)
161
+ return refuse("ttlRounds", `must be an integer 1..${OWNERSHIP_TTL_MAX} (the node's default max-ttl-offset)`);
162
+ const policy = await requireSenderAuthorizationNode(deps.reads);
163
+ if (policy)
164
+ return policy;
165
+ const facts = await checkChainFacts(deps.reads, groupName, outgoing, incoming);
166
+ if (facts)
167
+ return facts;
168
+ const now = await tip(deps.reads);
169
+ if (typeof now !== "number")
170
+ return now;
171
+ const expiresAtRound = now + ttlRounds;
172
+ const id = hex(digestFor(outgoing, groupName, incoming, expiresAtRound).digest);
173
+ const fields = { ledgerId: LEDGER.groups, groupName, outgoingOwner: outgoing, incomingOwner: incoming, maxToll: "0" };
174
+ const pending = {
175
+ txId: id, expiresAtRound, preparedAtRound: now, verb: "group_ownership_transfer_pending", fields,
176
+ summary: { sender: outgoing, ...fields },
177
+ status: "awaiting incoming-owner consent: NOT signed by this session and NOT submittable",
178
+ };
179
+ if (recordedById(id) !== undefined || pendingOwnershipById(id) !== undefined)
180
+ return refuse("txId", `transfer ${id} is already prepared or finalized in this session`);
181
+ pruneExpiredPendingOwnership(now);
182
+ if (!recordPendingOwnership(pending))
183
+ return refuse("pending", `at most ${MAX_PENDING_OWNERSHIP} prepared transfers may await consent per session`);
184
+ return {
185
+ kind: "ok",
186
+ value: {
187
+ kind: INTENT_KIND, txId: id, ...fields, maxToll: "0", expiresAtRound, preparedAtRound: now,
188
+ next: `Send these public fields to "${incoming}". Their own MCP session calls evolver_group_ownership_consent ` +
189
+ `with them; then call evolver_group_ownership_finalize here with the returned consent before round ${expiresAtRound}.`,
190
+ },
191
+ };
192
+ }
193
+ /**
194
+ * CONSENT (incoming owner). Recomputes the intent's txId and signs it with THIS session's key.
195
+ */
196
+ export async function consentOwnershipTransfer(deps, params) {
197
+ const groupName = str(params.groupName), outgoing = str(params.outgoingOwner), incoming = str(params.incomingOwner);
198
+ const claimedId = str(params.txId).toLowerCase();
199
+ const expiresAtRound = params.expiresAtRound;
200
+ if (incoming !== deps.identity)
201
+ return refuse("incomingOwner", `this session signs as "${deps.identity}", not "${incoming || "(empty)"}"; only the incoming owner's own session can consent`);
202
+ const bad = validNames(groupName, outgoing, incoming);
203
+ if (bad)
204
+ return bad;
205
+ if (typeof expiresAtRound !== "number" || !Number.isSafeInteger(expiresAtRound) || expiresAtRound < 1)
206
+ return refuse("expiresAtRound", "must be a positive integer round");
207
+ if (!/^[0-9a-f]{64}$/.test(claimedId))
208
+ return refuse("txId", "must be the 64-character hex txId from the intent");
209
+ if (deps.signer.keyType !== CONSENT_KEY_TYPE)
210
+ return refuse("signer", `this session's key is ${deps.signer.keyType}; the outgoing owner can verify only ${CONSENT_KEY_TYPE} consent ` +
211
+ `(SDK 0.21.0 exports no BLS verify). Use a session configured with this identity's registered Ed25519 key (EVOLVER_KEY_TYPE=ed25519). Nothing was signed.`);
212
+ const { digest } = digestFor(outgoing, groupName, incoming, expiresAtRound);
213
+ if (hex(digest) !== claimedId)
214
+ return refuse("txId", `the intent's txId ${namedInRefusal(claimedId)} does not match the transfer these fields describe; nothing was signed`);
215
+ // Before signing: an old node would let this consent stand alone as the sender's transfer.
216
+ const policy = await requireSenderAuthorizationNode(deps.reads);
217
+ if (policy)
218
+ return policy;
219
+ const now = await tip(deps.reads);
220
+ if (typeof now !== "number")
221
+ return now;
222
+ const stale = checkFresh(now, expiresAtRound);
223
+ if (stale)
224
+ return stale;
225
+ const facts = await checkChainFacts(deps.reads, groupName, outgoing, incoming);
226
+ if (facts)
227
+ return facts;
228
+ // The configured key must be the one the chain will verify against: sign, then check our own
229
+ // signature against the registered key, so a wrong key file fails here rather than at admit.
230
+ const pub = await registeredEdKey(deps.reads, incoming, deps.signer.keyLabel);
231
+ if (!(pub instanceof Uint8Array))
232
+ return pub;
233
+ const signature = deps.signer.sign(digest);
234
+ if (!edVerify(digest, signature, pub))
235
+ return refuse("signer", `this session's Ed25519 key is not the key registered for "${incoming}"; the consent was discarded`);
236
+ return {
237
+ kind: "ok",
238
+ value: {
239
+ kind: CONSENT_KIND, txId: claimedId, ledgerId: LEDGER.groups, groupName, outgoingOwner: outgoing,
240
+ incomingOwner: incoming, expiresAtRound, maxToll: "0",
241
+ auth: { nodeId: incoming, keyType: deps.signer.keyType, keyLabel: deps.signer.keyLabel, purpose: PURPOSE, signatureHex: hex(signature) },
242
+ next: `Return this consent to "${outgoing}". It authorizes ONLY txId ${claimedId}, which expires at round ` +
243
+ `${expiresAtRound}; it does not submit anything and cannot be used for any other operation.`,
244
+ },
245
+ };
246
+ }
247
+ /**
248
+ * FINALIZE (outgoing owner). Verifies the consent, signs as sender, assembles both auths, records.
249
+ */
250
+ export async function finalizeOwnershipTransfer(deps, params) {
251
+ const id = str(params.txId).toLowerCase();
252
+ if (recordedById(id) !== undefined)
253
+ return refuse("txId", `transfer ${namedInRefusal(id)} is already finalized in this session; submit or reconcile that id, never finalize again`);
254
+ const pending = pendingOwnershipById(id);
255
+ if (pending === undefined)
256
+ return refuse("txId", `no transfer ${namedInRefusal(id)} was prepared by this session; only a transfer prepared here can be finalized`);
257
+ const f = pending.fields;
258
+ if (f.outgoingOwner !== deps.identity)
259
+ return refuse("txId", "prepared for a different sender");
260
+ // The consent must describe exactly the prepared intent — every field, not just the id.
261
+ const c = (typeof params.consent === "object" && params.consent !== null ? params.consent : {});
262
+ const a = (typeof c["auth"] === "object" && c["auth"] !== null ? c["auth"] : {});
263
+ if (c["kind"] !== CONSENT_KIND)
264
+ return refuse("consent.kind", `must be "${CONSENT_KIND}"`);
265
+ // Hex case carries no meaning; compare the canonical lowercase form (the id is already lowercase).
266
+ const consentId = typeof c["txId"] === "string" ? c["txId"].trim().toLowerCase() : c["txId"];
267
+ const mismatch = [
268
+ ["txId", consentId, id], ["ledgerId", c["ledgerId"], f.ledgerId], ["groupName", c["groupName"], f.groupName],
269
+ ["outgoingOwner", c["outgoingOwner"], f.outgoingOwner], ["incomingOwner", c["incomingOwner"], f.incomingOwner],
270
+ ["expiresAtRound", c["expiresAtRound"], pending.expiresAtRound], ["maxToll", c["maxToll"], f.maxToll],
271
+ ["auth.nodeId", a["nodeId"], f.incomingOwner], ["auth.purpose", a["purpose"], PURPOSE],
272
+ ].find(([, got, want]) => got !== want);
273
+ if (mismatch)
274
+ return refuse(`consent.${mismatch[0]}`, "does not match the prepared transfer (wrong intent, principal or purpose); nothing was signed");
275
+ const keyType = a["keyType"], keyLabel = a["keyLabel"], sigHex = a["signatureHex"];
276
+ if (keyType !== CONSENT_KEY_TYPE)
277
+ return refuse("consent.auth.keyType", `only ${CONSENT_KEY_TYPE} consent can be verified (SDK 0.21.0 exports no BLS verify); nothing was signed`);
278
+ if (typeof keyLabel !== "string" || keyLabel.length > MAX_LABEL)
279
+ return refuse("consent.auth.keyLabel", "must be a string of at most 128 characters");
280
+ if (typeof sigHex !== "string" || !/^[0-9a-f]{128}$/.test(sigHex))
281
+ return refuse("consent.auth.signatureHex", "must be a 64-byte Ed25519 signature as lowercase hex");
282
+ // Re-derive the digest from the prepared fields with the SDK: the id must still be the intent.
283
+ const { body, digest } = digestFor(f.outgoingOwner, f.groupName, f.incomingOwner, pending.expiresAtRound);
284
+ if (hex(digest) !== id)
285
+ return refuse("txId", "the prepared fields no longer derive this txId; refused");
286
+ // Rechecked at finalization: the session may now be pointed at (or answered by) an older node.
287
+ const policy = await requireSenderAuthorizationNode(deps.reads);
288
+ if (policy)
289
+ return policy;
290
+ const now = await tip(deps.reads);
291
+ if (typeof now !== "number")
292
+ return now;
293
+ const stale = checkFresh(now, pending.expiresAtRound);
294
+ if (stale)
295
+ return stale;
296
+ const facts = await checkChainFacts(deps.reads, f.groupName, f.outgoingOwner, f.incomingOwner);
297
+ if (facts)
298
+ return facts;
299
+ const pub = await registeredEdKey(deps.reads, f.incomingOwner, keyLabel);
300
+ if (!(pub instanceof Uint8Array))
301
+ return pub;
302
+ if (!edVerify(digest, hexToBytes(sigHex), pub))
303
+ return refuse("consent.auth.signatureHex", `does not verify for txId ${id} under "${f.incomingOwner}"'s registered ${CONSENT_KEY_TYPE} key; nothing was signed`);
304
+ // Verified. Sign as sender (empty node_id ⇒ the sender) and assemble with the SDK encoder.
305
+ const auths = [
306
+ { keyType: deps.signer.keyType, keyLabel: deps.signer.keyLabel, nodeId: "", signature: deps.signer.sign(digest) },
307
+ { keyType: CONSENT_KEY_TYPE, keyLabel, nodeId: f.incomingOwner, signature: hexToBytes(sigHex) },
308
+ ];
309
+ const bytes = encodeSignedTx({ ledgerId: LEDGER.groups, senderNodeId: f.outgoingOwner, body, ttlRound: pending.expiresAtRound, auths, maxToll: 0n });
310
+ const fields = {
311
+ groupName: f.groupName, outgoingOwner: f.outgoingOwner, incomingOwner: f.incomingOwner, maxToll: "0",
312
+ outgoingAuth: `${f.outgoingOwner} ${deps.signer.keyType} label="${deps.signer.keyLabel}"`,
313
+ incomingAuth: `${f.incomingOwner} ${CONSENT_KEY_TYPE} label="${keyLabel}" (verified against registered key at round ${now})`,
314
+ };
315
+ const signed = {
316
+ txId: id, expiresAtRound: pending.expiresAtRound, signedAtRound: now, verb: "group_ownership_transfer",
317
+ fields, summary: { sender: f.outgoingOwner, ...fields },
318
+ };
319
+ if (!recordAssembledOnce(signed, bytes))
320
+ return refuse("txId", `transfer ${id} is already recorded in this session; nothing was replaced`);
321
+ dropPendingOwnership(id);
322
+ return { kind: "ok", value: signed };
323
+ }
324
+ //# sourceMappingURL=group-ownership.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group-ownership.js","sourceRoot":"","sources":["../src/group-ownership.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,uGAAuG;AACvG,EAAE;AACF,gGAAgG;AAChG,kGAAkG;AAClG,iGAAiG;AACjG,yFAAyF;AACzF,EAAE;AACF,oGAAoG;AACpG,qGAAqG;AACrG,mGAAmG;AACnG,mGAAmG;AACnG,+DAA+D;AAC/D,gGAAgG;AAChG,kGAAkG;AAClG,sEAAsE;AACtE,uEAAuE;AACvE,EAAE;AACF,gGAAgG;AAChG,oGAAoG;AACpG,mGAAmG;AACnG,2BAA2B;AAC3B,EAAE;AACF,gGAAgG;AAChG,4FAA4F;AAC5F,qGAAqG;AACrG,6FAA6F;AAC7F,8FAA8F;AAC9F,EAAE;AACF,8FAA8F;AAC9F,mGAAmG;AACnG,EAAE;AACF,iGAAiG;AACjG,kGAAkG;AAClG,oGAAoG;AACpG,2FAA2F;AAC3F,gGAAgG;AAChG,+FAA+F;AAC/F,kGAAkG;AAClG,8FAA8F;AAE9F,OAAO,EACL,MAAM,EACN,cAAc,EACd,IAAI,IAAI,QAAQ,EAChB,0BAA0B,EAC1B,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,QAAQ,EACR,WAAW,GACZ,MAA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,MAAM,MAAM,GAAG;QACb,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC,aAAa,EAAE,aAAa,EAAE,CAAC,CAAC,aAAa,EAAE,OAAO,EAAE,GAAG;QACpG,YAAY,EAAE,GAAG,CAAC,CAAC,aAAa,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,WAAW,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG;QACzF,YAAY,EAAE,GAAG,CAAC,CAAC,aAAa,IAAI,gBAAgB,WAAW,QAAQ,+CAA+C,GAAG,GAAG;KAC7H,CAAC;IACF,MAAM,MAAM,GAAgB;QAC1B,IAAI,EAAE,EAAE,EAAE,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE,aAAa,EAAE,GAAG,EAAE,IAAI,EAAE,0BAA0B;QACtG,MAAM,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,aAAa,EAAE,GAAG,MAAM,EAAE;KACxD,CAAC;IACF,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC;QACrC,OAAO,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,4DAA4D,CAAC,CAAC;IACpG,oBAAoB,CAAC,EAAE,CAAC,CAAC;IACzB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AACvC,CAAC"}
package/dist/group.d.ts CHANGED
@@ -46,8 +46,8 @@ export declare function signRemoveMember(deps: GroupOpsDeps, params: {
46
46
  /**
47
47
  * Multi-recipient credit transfer (SIGN-02): move credit from the signing identity to 1..20
48
48
  * recipients. This is the plain `transferBody` on `LEDGER.identity` — NOT a group-membership encoder
49
- * and NOT an ownership transfer (group ownership transfer is deferred to v2; it always fines
50
- * "missing co-signer auth"). "One verb = one tx"; the multi-entry array is the ONE thing that
49
+ * and NOT an ownership transfer (that needs the incoming owner's co-signature and lives in
50
+ * `src/group-ownership.ts`). "One verb = one tx"; the multi-entry array is the ONE thing that
51
51
  * distinguishes it from the singleton `evolver_sign_transfer`. Order is significant — it decides
52
52
  * which transfer survives a short-balance apply.
53
53
  */
package/dist/group.js CHANGED
@@ -155,8 +155,8 @@ export async function signRemoveMember(deps, params) {
155
155
  /**
156
156
  * Multi-recipient credit transfer (SIGN-02): move credit from the signing identity to 1..20
157
157
  * recipients. This is the plain `transferBody` on `LEDGER.identity` — NOT a group-membership encoder
158
- * and NOT an ownership transfer (group ownership transfer is deferred to v2; it always fines
159
- * "missing co-signer auth"). "One verb = one tx"; the multi-entry array is the ONE thing that
158
+ * and NOT an ownership transfer (that needs the incoming owner's co-signature and lives in
159
+ * `src/group-ownership.ts`). "One verb = one tx"; the multi-entry array is the ONE thing that
160
160
  * distinguishes it from the singleton `evolver_sign_transfer`. Order is significant — it decides
161
161
  * which transfer survives a short-balance apply.
162
162
  */
@@ -193,7 +193,7 @@ export async function signGroupTransfer(deps, params) {
193
193
  fields[`amount.${i}`] = formatAmount(parsed[i].amount);
194
194
  }
195
195
  return composeAndSign(deps, {
196
- ledgerId: LEDGER.identity, // NOT groups — credit lives on identities (ownership transfer is deferred to v2)
196
+ ledgerId: LEDGER.identity, // NOT groups — credit lives on identities (ownership: src/group-ownership.ts)
197
197
  body: transferBody(parsed.map((e) => ({ recipient: e.recipient, amount: e.amount }))),
198
198
  ttlRound: expiresAtRound,
199
199
  signedAtRound: tip,
package/dist/group.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"group.js","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,iGAAiG;AACjG,qGAAqG;AACrG,EAAE;AACF,oGAAoG;AACpG,iGAAiG;AACjG,+FAA+F;AAC/F,qGAAqG;AACrG,mGAAmG;AACnG,kBAAkB;AAClB,EAAE;AACF,oGAAoG;AACpG,qFAAqF;AAErF,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,YAAY,EAAE,MA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@ -0,0 +1,47 @@
1
+ import type { SignedRequestParams } from "@mcsherrylabs/evolver-client";
2
+ export declare const HTTP_METHODS: readonly ["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"];
3
+ export interface HttpProfile {
4
+ readonly name: string;
5
+ readonly principal: string;
6
+ readonly keyLabel: string;
7
+ readonly audience: string;
8
+ readonly origin: string;
9
+ readonly targets: readonly {
10
+ path: string;
11
+ methods: readonly string[];
12
+ }[];
13
+ readonly maxTtlSeconds: number;
14
+ readonly challengeUrl?: string;
15
+ /** Exact trusted local addresses, validated/resolved/pinned by the published SDK transport.
16
+ * No MCP DNS/IP classification or generic allowLocal flag. Never permit metadata/link-local. */
17
+ readonly localAddresses?: readonly string[];
18
+ /** Additional exact host IP refusals; SDK checks these before any local opt-in. */
19
+ readonly denyAddresses?: readonly string[];
20
+ /** Independent public relying-service CA trust; never inherit node insecure TLS. */
21
+ readonly caPem?: string;
22
+ }
23
+ export type HttpProfilesResult = {
24
+ ok: true;
25
+ profiles: readonly HttpProfile[];
26
+ } | {
27
+ ok: false;
28
+ error: string;
29
+ };
30
+ export interface HttpHeader {
31
+ readonly name: string;
32
+ readonly value: string;
33
+ }
34
+ export declare const HTTP_MAX_TEMPLATE_BYTES = 4096;
35
+ export declare const HTTP_MAX_HEADER_BYTES = 8192;
36
+ /** Canonical EXACT endpoints only. Reject all percent encoding rather than guessing how a remote
37
+ * router, proxy or framework normalizes it. No query, fragment, placeholder, userinfo or backslash. */
38
+ export declare function httpEndpoint(raw: unknown): URL;
39
+ export declare function resolveHttpProfiles(raw: unknown): HttpProfilesResult;
40
+ export declare function loadHttpProfilesFromEnv(env: NodeJS.ProcessEnv): HttpProfilesResult;
41
+ export declare function validateHttpRequest(raw: unknown, profile: HttpProfile): {
42
+ ok: true;
43
+ request: SignedRequestParams["request"];
44
+ } | {
45
+ ok: false;
46
+ };
47
+ //# sourceMappingURL=http-profiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http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AC;AAkB1C;uGACuG;AACvG,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,CAM9C;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,kBAAkB,CAmCpE;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,kBAAkB,CASlF;AAcD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAA;CAAE,CAyB7I"}
@@ -0,0 +1,161 @@
1
+ import { readFileSync, statSync } from "node:fs";
2
+ import { isValidPrincipalName } from "@mcsherrylabs/evolver-client";
3
+ // Exact request methods admitted by the reviewed SDK approved-request transport (0d724deb).
4
+ export const HTTP_METHODS = ["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"];
5
+ export const HTTP_MAX_TEMPLATE_BYTES = 4096;
6
+ export const HTTP_MAX_HEADER_BYTES = 8192;
7
+ const object = (v) => !!v && typeof v === "object" && !Array.isArray(v);
8
+ const only = (v, allowed) => Object.keys(v).every(k => allowed.includes(k));
9
+ function addressPolicy(raw) {
10
+ if (raw === undefined)
11
+ return undefined;
12
+ if (!Array.isArray(raw) || raw.length < 1 || raw.length > 8)
13
+ throw new Error();
14
+ const addresses = raw.map(ip => {
15
+ if (typeof ip !== "string" || !ip || ip.length > 64 || /[^\x21-\x7e]/.test(ip))
16
+ throw new Error();
17
+ return ip;
18
+ });
19
+ if (new Set(addresses).size !== addresses.length)
20
+ throw new Error();
21
+ return addresses; // Exact IP syntax/classification belongs only to the public SDK factory.
22
+ }
23
+ function pathAllowed(path) {
24
+ return path.startsWith("/") && path.length <= 1024 && !path.includes("//") &&
25
+ path.split("/").every((s, i, a) => (s === "" ? i === 0 || i === a.length - 1 : /^[A-Za-z0-9_.~-]+$/.test(s) && s !== "." && s !== ".."));
26
+ }
27
+ /** Canonical EXACT endpoints only. Reject all percent encoding rather than guessing how a remote
28
+ * router, proxy or framework normalizes it. No query, fragment, placeholder, userinfo or backslash. */
29
+ export function httpEndpoint(raw) {
30
+ if (typeof raw !== "string" || raw.length > 2048 || /[^\x21-\x7e]|[%{}\\]/.test(raw))
31
+ throw new Error();
32
+ const url = new URL(raw);
33
+ if (!["https:", "http:"].includes(url.protocol) || url.username || url.password || url.search || url.hash ||
34
+ url.toString() !== raw || !pathAllowed(url.pathname))
35
+ throw new Error();
36
+ return url;
37
+ }
38
+ export function resolveHttpProfiles(raw) {
39
+ try {
40
+ if (!object(raw) || !only(raw, ["profiles"]) || !Array.isArray(raw.profiles) || raw.profiles.length > 16)
41
+ throw new Error();
42
+ const names = new Set();
43
+ const profiles = raw.profiles.map((v) => {
44
+ if (!object(v) || !only(v, ["name", "principal", "keyLabel", "audience", "origin", "targets", "maxTtlSeconds", "challengeUrl", "localAddresses", "denyAddresses", "caPem"]))
45
+ throw new Error();
46
+ if (typeof v.name !== "string" || !/^[a-z][a-z0-9-]{0,63}$/.test(v.name) || names.has(v.name))
47
+ throw new Error();
48
+ names.add(v.name);
49
+ if (typeof v.principal !== "string" || !isValidPrincipalName(v.principal) || typeof v.keyLabel !== "string" || v.keyLabel.length > 128 || /[^\x20-\x7e]/.test(v.keyLabel))
50
+ throw new Error();
51
+ if (typeof v.origin !== "string")
52
+ throw new Error();
53
+ const origin = httpEndpoint(v.origin + "/");
54
+ if (origin.origin !== v.origin || origin.pathname !== "/")
55
+ throw new Error();
56
+ if (typeof v.audience !== "string" || v.audience.length > 256 || ![origin.hostname, origin.origin].includes(v.audience))
57
+ throw new Error();
58
+ const local = addressPolicy(v.localAddresses), denied = addressPolicy(v.denyAddresses);
59
+ if (origin.protocol === "http:" && local === undefined)
60
+ throw new Error();
61
+ const caPem = v.caPem;
62
+ if (caPem !== undefined && (origin.protocol !== "https:" || typeof caPem !== "string" || Buffer.byteLength(caPem) > 16384 || !caPem.includes("-----BEGIN CERTIFICATE-----") || caPem.includes("PRIVATE KEY")))
63
+ throw new Error();
64
+ if (!Array.isArray(v.targets) || v.targets.length < 1 || v.targets.length > 16)
65
+ throw new Error();
66
+ const paths = new Set();
67
+ const targets = v.targets.map(t => {
68
+ if (!object(t) || !only(t, ["path", "methods"]) || typeof t.path !== "string" || !pathAllowed(t.path) || paths.has(t.path) ||
69
+ !Array.isArray(t.methods) || t.methods.length < 1 || t.methods.length > HTTP_METHODS.length ||
70
+ t.methods.some(m => !HTTP_METHODS.includes(m)) || new Set(t.methods).size !== t.methods.length)
71
+ throw new Error();
72
+ paths.add(t.path);
73
+ return { path: t.path, methods: [...t.methods] };
74
+ });
75
+ if (typeof v.maxTtlSeconds !== "number" || !Number.isSafeInteger(v.maxTtlSeconds) || v.maxTtlSeconds < 1 || v.maxTtlSeconds > 300)
76
+ throw new Error();
77
+ const challenge = v.challengeUrl === undefined ? undefined : httpEndpoint(v.challengeUrl);
78
+ if (challenge && challenge.origin !== origin.origin)
79
+ throw new Error();
80
+ return { name: v.name, principal: v.principal, keyLabel: v.keyLabel, audience: v.audience, origin: origin.origin,
81
+ targets, maxTtlSeconds: v.maxTtlSeconds, ...(challenge ? { challengeUrl: challenge.toString() } : {}),
82
+ ...(local ? { localAddresses: [...local] } : {}), ...(denied ? { denyAddresses: [...denied] } : {}), ...(caPem ? { caPem } : {}) };
83
+ });
84
+ return { ok: true, profiles };
85
+ }
86
+ catch {
87
+ return { ok: false, error: "Invalid host HTTP profiles: require fixed canonical origin, matching audience/identity/Ed25519 label, exact endpoint/method targets and TTL 1..300. Plain HTTP requires an exact SDK-validated localAddresses policy; no generic local/private access is granted." };
88
+ }
89
+ }
90
+ export function loadHttpProfilesFromEnv(env) {
91
+ const path = env.EVOLVER_HTTP_PROFILES_PATH;
92
+ if (!path)
93
+ return { ok: true, profiles: [] };
94
+ try {
95
+ if (!statSync(path).isFile() || statSync(path).size > 65536)
96
+ throw new Error();
97
+ const text = readFileSync(path, "utf8");
98
+ if (Buffer.byteLength(text) > 65536)
99
+ throw new Error();
100
+ return resolveHttpProfiles(JSON.parse(text));
101
+ }
102
+ catch {
103
+ return { ok: false, error: "Cannot read bounded operator HTTP profiles from EVOLVER_HTTP_PROFILES_PATH; configure host policy and reload MCP." };
104
+ }
105
+ }
106
+ // Node20+ intrinsic: reject the same lone-surrogate loss that content.ts refuses, without
107
+ // introducing a second UTF-8 encoder or changing the file owner's content module.
108
+ const wellFormed = (s) => s.isWellFormed();
109
+ function boundedJson(v, depth = 0, nodes = { count: 0 }) {
110
+ if (++nodes.count > 1024 || depth > 16)
111
+ return false;
112
+ if (typeof v === "string")
113
+ return wellFormed(v);
114
+ if (v === null || typeof v === "boolean")
115
+ return true;
116
+ if (typeof v === "number")
117
+ return Number.isFinite(v);
118
+ if (Array.isArray(v))
119
+ return v.every(x => boundedJson(x, depth + 1, nodes));
120
+ if (!object(v) || (Object.getPrototypeOf(v) !== Object.prototype && Object.getPrototypeOf(v) !== null))
121
+ return false;
122
+ return Object.entries(v).every(([k, x]) => wellFormed(k) && boundedJson(x, depth + 1, nodes));
123
+ }
124
+ export function validateHttpRequest(raw, profile) {
125
+ try {
126
+ if (!object(raw) || !only(raw, ["method", "url", "headers", "body"]) || typeof raw.method !== "string" || !HTTP_METHODS.includes(raw.method) ||
127
+ ((raw.method === "GET" || raw.method === "HEAD") && raw.body !== undefined))
128
+ throw new Error();
129
+ const url = httpEndpoint(raw.url);
130
+ if (url.origin !== profile.origin || !profile.targets.some(t => t.path === url.pathname && t.methods.includes(raw.method)))
131
+ throw new Error();
132
+ const hs = raw.headers ?? [];
133
+ if (!Array.isArray(hs) || hs.length > 16)
134
+ throw new Error();
135
+ const seen = new Set(), pairs = [];
136
+ let headerBytes = 0;
137
+ for (const h of hs) {
138
+ if (!object(h) || !only(h, ["name", "value"]) || typeof h.name !== "string" || typeof h.value !== "string" ||
139
+ !/^[!#$%&'*+.^_`|~0-9A-Za-z-]{1,128}$/.test(h.name) || !/^[\x20-\x7e]{0,1024}$/.test(h.value))
140
+ throw new Error();
141
+ const name = h.name.toLowerCase();
142
+ // Match ALL transport control/proxy refusals before approval/signing, plus host-only
143
+ // credential/referrer restrictions. DNS-only preflight cannot validate RequestInit.
144
+ if (seen.has(name) || ["__proto__", "host", "content-length", "transfer-encoding", "connection", "keep-alive", "te", "trailer", "upgrade", "expect", "http2-settings", "forwarded", "via", "accept-encoding", "cookie", "set-cookie", "origin", "referer"].includes(name) || name.startsWith("proxy-") || name.startsWith("x-forwarded-") ||
145
+ (name === "authorization" && !h.value.includes("{answer")))
146
+ throw new Error();
147
+ seen.add(name);
148
+ headerBytes += Buffer.byteLength(h.name + h.value) + 4;
149
+ pairs.push([h.name, h.value]);
150
+ }
151
+ if (headerBytes > HTTP_MAX_HEADER_BYTES)
152
+ throw new Error();
153
+ if (raw.body !== undefined && (!boundedJson(raw.body) || Buffer.byteLength(JSON.stringify(raw.body)) > HTTP_MAX_TEMPLATE_BYTES))
154
+ throw new Error();
155
+ return { ok: true, request: structuredClone({ method: raw.method, url: url.toString(), ...(pairs.length ? { headers: Object.fromEntries(pairs) } : {}), ...(raw.body === undefined ? {} : { body: raw.body }) }) };
156
+ }
157
+ catch {
158
+ return { ok: false };
159
+ }
160
+ }
161
+ //# sourceMappingURL=http-profiles.js.map