@serfab/cadre-host 0.12.0 → 1.0.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 (70) hide show
  1. package/README.md +6 -4
  2. package/dist/bin/host.js +9 -1
  3. package/dist/bin/host.js.map +1 -1
  4. package/dist/donation/__tests__/fake-orchestrator.js +1 -1
  5. package/dist/donation/__tests__/fake-orchestrator.js.map +1 -1
  6. package/dist/donation/donation-service.d.ts +7 -2
  7. package/dist/donation/donation-service.js +16 -2
  8. package/dist/donation/donation-service.js.map +1 -1
  9. package/dist/donation/donation-supervisor.d.ts +12 -2
  10. package/dist/donation/donation-supervisor.js +25 -2
  11. package/dist/donation/donation-supervisor.js.map +1 -1
  12. package/dist/donation/types.d.ts +2 -1
  13. package/dist/donation/types.js.map +1 -1
  14. package/dist/installer/index.d.ts +9 -1
  15. package/dist/installer/index.js +5 -1
  16. package/dist/installer/index.js.map +1 -1
  17. package/dist/orchestrator/host-process-orchestrator.d.ts +71 -11
  18. package/dist/orchestrator/host-process-orchestrator.js +173 -75
  19. package/dist/orchestrator/host-process-orchestrator.js.map +1 -1
  20. package/dist/orchestrator/port-allocator.d.ts +44 -2
  21. package/dist/orchestrator/port-allocator.js +63 -5
  22. package/dist/orchestrator/port-allocator.js.map +1 -1
  23. package/dist/orchestrator/port-probe.d.ts +15 -0
  24. package/dist/orchestrator/port-probe.js +22 -0
  25. package/dist/orchestrator/port-probe.js.map +1 -0
  26. package/dist/orchestrator/types.d.ts +13 -1
  27. package/dist/orchestrator/types.js.map +1 -1
  28. package/dist/server/routes/bootstrap-node-validation.d.ts +115 -0
  29. package/dist/server/routes/bootstrap-node-validation.js +197 -0
  30. package/dist/server/routes/bootstrap-node-validation.js.map +1 -0
  31. package/dist/server/routes/grants.js +8 -25
  32. package/dist/server/routes/grants.js.map +1 -1
  33. package/dist/server/routes/provision-request-validation.d.ts +45 -0
  34. package/dist/server/routes/provision-request-validation.js +97 -0
  35. package/dist/server/routes/provision-request-validation.js.map +1 -0
  36. package/dist/server/server.d.ts +4 -1
  37. package/dist/server/server.js +36 -2
  38. package/dist/server/server.js.map +1 -1
  39. package/dist/ui/assets/{index-C-iks41M.js → index-CEoNRwM_.js} +3 -3
  40. package/dist/ui/assets/{index-C-iks41M.js.map → index-CEoNRwM_.js.map} +1 -1
  41. package/dist/ui/index.html +1 -1
  42. package/package.json +5 -4
  43. package/src/__tests__/orchestrator-env-scrub.test.ts +22 -0
  44. package/src/__tests__/orchestrator-node-identity.test.ts +4 -4
  45. package/src/__tests__/orchestrator-owner.test.ts +45 -2
  46. package/src/__tests__/orchestrator-ports.test.ts +172 -0
  47. package/src/__tests__/orchestrator.test.ts +1062 -951
  48. package/src/bin/host.ts +9 -1
  49. package/src/donation/__tests__/donation-service.test.ts +94 -7
  50. package/src/donation/__tests__/donation-supervisor.test.ts +50 -12
  51. package/src/donation/__tests__/fake-orchestrator.test.ts +168 -168
  52. package/src/donation/__tests__/fake-orchestrator.ts +1 -1
  53. package/src/donation/donation-service.ts +22 -3
  54. package/src/donation/donation-supervisor.ts +25 -2
  55. package/src/donation/types.ts +2 -1
  56. package/src/installer/__tests__/installer.smoke.test.ts +263 -218
  57. package/src/installer/index.ts +327 -314
  58. package/src/orchestrator/host-process-orchestrator.ts +1250 -1138
  59. package/src/orchestrator/port-allocator.ts +148 -91
  60. package/src/orchestrator/port-probe.ts +31 -0
  61. package/src/orchestrator/types.ts +13 -1
  62. package/src/server/__tests__/bootstrap-node-validation.test.ts +138 -0
  63. package/src/server/__tests__/grants-route.test.ts +394 -263
  64. package/src/server/__tests__/nodes-route.test.ts +2 -2
  65. package/src/server/__tests__/publishers.test.ts +1 -1
  66. package/src/server/__tests__/status-route.test.ts +1 -1
  67. package/src/server/routes/bootstrap-node-validation.ts +206 -0
  68. package/src/server/routes/grants.ts +9 -26
  69. package/src/server/routes/provision-request-validation.ts +105 -0
  70. package/src/server/server.ts +157 -122
@@ -0,0 +1,197 @@
1
+ /**
2
+ * Shape validation for the requester-supplied `bootstrapNodes` of `POST /grants`
3
+ * — the requester's control-network addresses the donated node is started with
4
+ * (written into the child's `cadre.json` as `controlNetwork.bootstrapNodes` by
5
+ * `orchestrator/host-process-orchestrator.ts`) and hands to `@libp2p/bootstrap`.
6
+ *
7
+ * Its own module rather than part of `grants.ts`: the per-entry rule is a duplicate
8
+ * of cadre-provider's copy (`packages/cadre-provider/src/server/bootstrap-node-validation.ts`)
9
+ * and must stay identical to it, so it is worth reading, testing and changing on
10
+ * its own, without a routing file around it — the same arrangement cadre-provider
11
+ * uses for its restatement of cadre-core's owner-key rule.
12
+ *
13
+ * ## An empty list is accepted — where this copy differs, on purpose
14
+ *
15
+ * The field may be absent or `[]`; cadre-provider's copy still requires at least one
16
+ * address. A lent node's requester is typically a phone, and a phone has no address
17
+ * to give — its node listens on nothing and can only dial out. Such a requester sends
18
+ * no addresses and dials the node itself, at the WebSocket address
19
+ * `GET /grants/:id/peer` reports. The node starts with no bootstrap peers and waits,
20
+ * and admits that first inbound connection because it holds no authorized members
21
+ * yet (`admitInboundControlConnection` / `authorizeInboundControlStream` in
22
+ * `cadre-core/src/cadre-node.ts`). A provider container has no such requester yet, so
23
+ * there an empty list is still the node-comes-up-alone failure described below
24
+ * (`backlog/feat-provider-drone-reachable-by-phone`).
25
+ *
26
+ * The difference is at the list level only: every entry that IS given must pass the
27
+ * rule below, which is identical in both packages.
28
+ *
29
+ * ## The rule, and why each clause is there
30
+ *
31
+ * An entry is usable exactly when it is a string, parses as a multiaddr, carries
32
+ * a `/p2p/<peerId>` component whose peer id decodes, and says where that peer is.
33
+ * Each clause corresponds to a distinct downstream failure the caller would
34
+ * otherwise never be told about — the value is forwarded verbatim into the spawned
35
+ * child, so every one of these surfaces where the caller cannot see it:
36
+ *
37
+ * - **Not parsable as a multiaddr → the child dies at boot.** `@libp2p/bootstrap`'s
38
+ * constructor maps `multiaddr()` over the whole list *before* filtering anything,
39
+ * and `multiaddr()` throws on a string that does not start with `/` (and on a
40
+ * non-string outright). libp2p construction throws and the node never starts.
41
+ * - **No `/p2p/<peerId>` → the node starts and never joins.** The quiet one.
42
+ * `/ip4/127.0.0.1/tcp/4001` parses fine, then `@libp2p/bootstrap` filters it out
43
+ * ("invalid bootstrap multiaddr without peer id", logged inside the child) and
44
+ * the node comes up with *zero* bootstrap peers: healthy-looking, permanently
45
+ * alone, never reaching the party it was created for. cadre-core's
46
+ * `getBootstrapPeerIds` (`packages/cadre-core/src/cadre-node.ts`) skips such an
47
+ * entry silently for the same reason.
48
+ * - **Malformed peer id → the child dies at boot.** `multiaddr()` does *not*
49
+ * validate the `/p2p/` value — parsing `/ip4/1.2.3.4/tcp/1/p2p/12D3KooReq` yields
50
+ * a `p2p` component whose value is the junk string unchanged — but
51
+ * `@libp2p/bootstrap` then calls `peerIdFromString` on it, unguarded, and it
52
+ * throws `Incorrect length`. A truncated copy-paste of a 52-character peer id is
53
+ * the likeliest human typo in this field.
54
+ * - **No location at all → the node starts and never joins.** `/p2p/<peerId>` (and
55
+ * `/p2p/<relay>/p2p-circuit/p2p/<target>`) parses and names a decodable peer, and
56
+ * `@libp2p/bootstrap` keeps it — but it says nothing about *where* the peer is, so
57
+ * libp2p finds no transport for it and the dial fails with no valid addresses.
58
+ * The node comes up with a bootstrap peer it can never reach, which looks the same
59
+ * from outside as having none. Only the total absence of a location is rejected:
60
+ * which transports the child can actually dial is the embedder's choice
61
+ * (`NetworkConfig.transports`), invisible from here, so a partial address like
62
+ * `/ip4/1.2.3.4/p2p/<peerId>` is deliberately left to the child.
63
+ *
64
+ * The peer id is read the way `@libp2p/bootstrap` reads it — the `p2p` components
65
+ * of `getComponents()` — rather than through the deprecated `getPeerId()`, so the
66
+ * two cannot disagree about which part of the address is the peer. Bootstrap uses
67
+ * only the *last* `p2p` component; this checks **every** one, so the relay half of
68
+ * a `…/p2p/<relay>/p2p-circuit/p2p/<target>` address must decode too. An address
69
+ * naming an undecodable relay is not dialable either, and bootstrap's own
70
+ * `P2P.matches` filter accepts any address carrying a `p2p` component, so nothing
71
+ * this accepts is dropped there.
72
+ *
73
+ * Requiring a multiaddr also closes a downstream ambiguity on the *other* side of
74
+ * this rule: cadre-provider joins its list with `,` into `CADRE_BOOTSTRAP_NODES`
75
+ * and cadre-cli's env loader splits it back on `,`, so an entry containing a comma
76
+ * would silently become two addresses there. This host writes JSON rather than an
77
+ * env var and so is not exposed to that, but the two per-entry rules are kept
78
+ * identical — see the note about manual upkeep below.
79
+ *
80
+ * Reachability is deliberately NOT checked: a well-formed address for a peer that
81
+ * happens to be down is indistinguishable here from one that is up, and no
82
+ * boundary check can tell them apart. This validates the *shape* the child must be
83
+ * able to parse, nothing more.
84
+ *
85
+ * Keeping the two per-entry rules in step is **manual** — neither package can see
86
+ * the other's rule, so no test can compare them. What the tests give instead is a
87
+ * tripwire on each side: `../__tests__/bootstrap-node-validation.test.ts` here and
88
+ * `packages/cadre-provider/src/server/__tests__/bootstrap-node-validation.test.ts`
89
+ * there each pin their own copy to the same per-entry accept/reject table (the
90
+ * empty-list row is the one that differs), so changing either rule fails that
91
+ * package's own suite — and the comment above the rule you just changed is what
92
+ * points at the other copy.
93
+ */
94
+ import debug from 'debug';
95
+ import { CODE_P2P, CODE_P2P_CIRCUIT, multiaddr } from '@multiformats/multiaddr';
96
+ import { peerIdFromString } from '@libp2p/peer-id';
97
+ const log = debug('cadre:host:bootstrap-nodes');
98
+ /**
99
+ * Longest rejected address echoed back in an error message. Generous compared to
100
+ * the owner-key limit because a legitimate address is long: a plain
101
+ * `/ip4/…/tcp/…/p2p/<52 chars>` runs ~80 characters and a relayed
102
+ * `…/p2p-circuit/p2p/<52 chars>` about 150, so a smaller cap would truncate the
103
+ * very values an operator needs to read back.
104
+ */
105
+ const REJECTED_ADDRESS_ECHO_LIMIT = 192;
106
+ /**
107
+ * Render a rejected address for an error message, capped: `bootstrapNodes`
108
+ * arrives from a caller over the network, so an unbounded echo would let one junk
109
+ * string become a megabyte of log line.
110
+ */
111
+ function describeRejectedAddress(value) {
112
+ return value.length <= REJECTED_ADDRESS_ECHO_LIMIT
113
+ ? value
114
+ : `${value.slice(0, REJECTED_ADDRESS_ECHO_LIMIT)}… (${value.length} chars)`;
115
+ }
116
+ /** The message of a thrown parse/decode failure, whatever the thrower used. */
117
+ function reasonOf(error) {
118
+ return error instanceof Error ? error.message : String(error);
119
+ }
120
+ /**
121
+ * Apply the rule above to one entry. Returns the trimmed value, so the create
122
+ * provision request carries exactly what was validated.
123
+ */
124
+ function validateBootstrapNode(value) {
125
+ const trimmed = value.trim();
126
+ if (trimmed.length === 0) {
127
+ return { error: 'bootstrapNodes entries must not be empty or whitespace-only' };
128
+ }
129
+ let address;
130
+ try {
131
+ address = multiaddr(trimmed);
132
+ }
133
+ catch (error) {
134
+ log('rejecting bootstrapNodes entry: %s', reasonOf(error));
135
+ return {
136
+ error: `bootstrapNodes entries must be multiaddrs (could not parse "${describeRejectedAddress(trimmed)}": ${reasonOf(error)})`,
137
+ };
138
+ }
139
+ const components = address.getComponents();
140
+ const peerIds = components.filter(component => component.code === CODE_P2P);
141
+ if (peerIds.length === 0) {
142
+ return {
143
+ error: `bootstrapNodes entries must include a /p2p/<peerId> component ("${describeRejectedAddress(trimmed)}" names no peer, so the node would drop it and start with no bootstrap peers)`,
144
+ };
145
+ }
146
+ if (!components.some(component => component.code !== CODE_P2P && component.code !== CODE_P2P_CIRCUIT)) {
147
+ return {
148
+ error: `bootstrapNodes entries must name where to reach the peer ("${describeRejectedAddress(trimmed)}" names only peer ids, so no transport can dial it and the node would start with no reachable bootstrap peers)`,
149
+ };
150
+ }
151
+ for (const { value } of peerIds) {
152
+ try {
153
+ peerIdFromString(value ?? '');
154
+ }
155
+ catch (error) {
156
+ log('rejecting bootstrapNodes peer id: %s', reasonOf(error));
157
+ return {
158
+ error: `bootstrapNodes entries must carry a decodable peer id ("${describeRejectedAddress(trimmed)}" names peer "${describeRejectedAddress(value ?? '')}", which does not decode: ${reasonOf(error)})`,
159
+ };
160
+ }
161
+ }
162
+ return { node: trimmed };
163
+ }
164
+ /**
165
+ * Validate the optional `bootstrapNodes` field of a provision request: absent, or an
166
+ * array of dialable control-network addresses (see {@link validateBootstrapNode}).
167
+ * Absent and `[]` alike mean the requester dials the node itself — see "An empty list
168
+ * is accepted" in the module comment.
169
+ *
170
+ * Provisioning is the last point at which the requester can still fix a typo, so
171
+ * the shape is checked here: without it a bad address is answered 201 and then
172
+ * produces a donated node that either dies at boot or comes up permanently alone
173
+ * — the requester learning about it, if ever, from donation status rather than
174
+ * from a 400 naming the bad address.
175
+ *
176
+ * Every rejection names the offending entry: with several addresses in one
177
+ * request the message is the only thing that says WHICH one.
178
+ *
179
+ * @returns the trimmed addresses (`[]` when none were given), so the provision request carries exactly what was validated.
180
+ */
181
+ export function validateBootstrapNodes(value) {
182
+ if (value === undefined) {
183
+ return { nodes: [] };
184
+ }
185
+ if (!Array.isArray(value) || !value.every((entry) => typeof entry === 'string')) {
186
+ return { error: 'bootstrapNodes must be an array of strings' };
187
+ }
188
+ const nodes = [];
189
+ for (const entry of value) {
190
+ const checked = validateBootstrapNode(entry);
191
+ if ('error' in checked)
192
+ return checked;
193
+ nodes.push(checked.node);
194
+ }
195
+ return { nodes };
196
+ }
197
+ //# sourceMappingURL=bootstrap-node-validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap-node-validation.js","sourceRoot":"","sources":["../../../src/server/routes/bootstrap-node-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,EAAkB,MAAM,yBAAyB,CAAC;AAChG,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,GAAG,GAAG,KAAK,CAAC,4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AE,CAAC;IACjE,CAAC;IAED,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE,CAAC;QAC1B,MAAM,OAAO,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,OAAO,IAAI,OAAO;YAAE,OAAO,OAAO,CAAC;QACvC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,CAAC;AACnB,CAAC"}
@@ -17,6 +17,7 @@
17
17
  * `DonationError`, which `server/error-handler.ts` maps to the matching HTTP
18
18
  * status and the same envelope.
19
19
  */
20
+ import { validateProvisionRequest } from './provision-request-validation.js';
20
21
  /** Uniform error envelope (matches `error-handler.ts` and the provider API). */
21
22
  function errorResponse(reply, code, message, status) {
22
23
  return reply.status(status).send({ ok: false, error: { code, message } });
@@ -83,32 +84,14 @@ export function registerGrantsRoutes(app, opts) {
83
84
  if (!token) {
84
85
  return errorResponse(reply, 'unauthorized', 'Missing bearer grant token', 401);
85
86
  }
86
- const body = (request.body ?? {});
87
- if (typeof body.partyId !== 'string' || body.partyId.length === 0) {
88
- return errorResponse(reply, 'invalid_request', 'partyId is required', 400);
89
- }
90
- if (!Array.isArray(body.bootstrapNodes) || body.bootstrapNodes.length === 0) {
91
- return errorResponse(reply, 'invalid_request', 'bootstrapNodes is required', 400);
92
- }
93
- if (!Array.isArray(body.ownerKeys) || body.ownerKeys.length === 0) {
94
- return errorResponse(reply, 'invalid_request', 'ownerKeys is required', 400);
95
- }
96
- // Element types too, not just the array: `provision`'s shape check trims each
97
- // entry, so a non-string reaches the caller as an internal `.trim is not a
98
- // function` rather than as a message naming what is wrong with the request.
99
- if (!body.ownerKeys.every(key => typeof key === 'string')) {
100
- return errorResponse(reply, 'invalid_request', 'ownerKeys must be an array of strings', 400);
101
- }
102
- if (body.profile !== undefined && body.profile !== 'storage' && body.profile !== 'transaction') {
103
- return errorResponse(reply, 'invalid_request', 'profile must be "storage" or "transaction"', 400);
87
+ // One validator owns the whole body — see `provision-request-validation.ts`
88
+ // for why no per-field check lives here. Nothing is provisioned on a
89
+ // rejection: this runs before the service is touched.
90
+ const validated = validateProvisionRequest(request.body ?? {}, token);
91
+ if ('error' in validated) {
92
+ return errorResponse(reply, 'invalid_request', validated.error, 400);
104
93
  }
105
- const donation = await donations.provision({
106
- grantToken: token,
107
- partyId: body.partyId,
108
- bootstrapNodes: body.bootstrapNodes,
109
- ownerKeys: body.ownerKeys,
110
- ...(body.profile ? { profile: body.profile } : {}),
111
- });
94
+ const donation = await donations.provision(validated.request);
112
95
  return reply.status(201).send({ ok: true, data: { donation } });
113
96
  });
114
97
  // GET /grants — list only the donations this grant authorized.
@@ -1 +1 @@
1
- {"version":3,"file":"grants.js","sourceRoot":"","sources":["../../../src/server/routes/grants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAaH,gFAAgF;AAChF,SAAS,aAAa,CAAC,KAAmB,EAAE,IAAY,EAAE,OAAe,EAAE,MAAc;IACvF,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;AAC5E,CAAC;AAED,qFAAqF;AACrF,SAAS,WAAW,CAAC,MAA0B;IAC7C,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,MAAM,KAAK,GAAG,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IACrD,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7C,CAAC;AAED,uEAAuE;AACvE,SAAS,UAAU,CAAC,MAA0B;IAC5C,IAAI,MAAM,KAAK,SAAS,IAAI,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SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC7C,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * The whole shape check for `POST /grants` — one call that either yields the
3
+ * typed {@link DonationProvisionRequest} the `DonationService` is handed, or the
4
+ * message the route answers 400 with.
5
+ *
6
+ * **Why a validator rather than a few more `if`s in the route.** Every field in
7
+ * this body is forwarded into a child process the requester cannot see:
8
+ * `partyId`, `bootstrapNodes` and `profile` are written into the child's
9
+ * `cadre.json` (`orchestrator/host-process-orchestrator.ts`) and `ownerKeys`
10
+ * become its cold-start seed-trust anchors. A field the route forgets to check is
11
+ * not a 400 — it is a donated node that dies at boot, or comes up subtly wrong,
12
+ * with a 201 already sent. Routing the body through one function that *constructs*
13
+ * the request object means a field can only reach the spawn path by having been
14
+ * through here; adding a field to `DonationProvisionRequest` without validating it
15
+ * stops compiling rather than silently shipping.
16
+ *
17
+ * **Division of labour with `DonationService.provision`.** The Ed25519 rule for
18
+ * `ownerKeys` stays in the service, where it is applied by cadre-core's own
19
+ * `requireEd25519PublicKeyB64` — the service is also reached by the respawn path,
20
+ * which replays a persisted record rather than an HTTP body, so the crypto rule
21
+ * has to live there to cover both. What this validator owns for `ownerKeys` is the
22
+ * *container* shape (present, non-empty, all strings), which the service's rule
23
+ * assumes: a number reaching it surfaces as an internal `.trim is not a function`
24
+ * rather than as a message naming what is wrong with the request.
25
+ *
26
+ * The multiaddr rule has no such home — it is duplicated in cadre-provider — so it
27
+ * lives in `bootstrap-node-validation.ts` next to the comment saying so.
28
+ */
29
+ import type { DonationProvisionRequest } from '../../donation/donation-service.js';
30
+ /**
31
+ * Validate a `POST /grants` body and build the request `DonationService.provision`
32
+ * is handed.
33
+ *
34
+ * `grantToken` comes from the `Authorization` bearer rather than the body — a
35
+ * requester does not get to name which grant pays for this — so it is a
36
+ * parameter, not a validated field. Whether that grant is live and within quota is
37
+ * `provision`'s call, not this function's.
38
+ *
39
+ * @returns the typed provision request, or the message to answer `invalid_request` with.
40
+ */
41
+ export declare function validateProvisionRequest(body: unknown, grantToken: string): {
42
+ request: DonationProvisionRequest;
43
+ } | {
44
+ error: string;
45
+ };
@@ -0,0 +1,97 @@
1
+ /**
2
+ * The whole shape check for `POST /grants` — one call that either yields the
3
+ * typed {@link DonationProvisionRequest} the `DonationService` is handed, or the
4
+ * message the route answers 400 with.
5
+ *
6
+ * **Why a validator rather than a few more `if`s in the route.** Every field in
7
+ * this body is forwarded into a child process the requester cannot see:
8
+ * `partyId`, `bootstrapNodes` and `profile` are written into the child's
9
+ * `cadre.json` (`orchestrator/host-process-orchestrator.ts`) and `ownerKeys`
10
+ * become its cold-start seed-trust anchors. A field the route forgets to check is
11
+ * not a 400 — it is a donated node that dies at boot, or comes up subtly wrong,
12
+ * with a 201 already sent. Routing the body through one function that *constructs*
13
+ * the request object means a field can only reach the spawn path by having been
14
+ * through here; adding a field to `DonationProvisionRequest` without validating it
15
+ * stops compiling rather than silently shipping.
16
+ *
17
+ * **Division of labour with `DonationService.provision`.** The Ed25519 rule for
18
+ * `ownerKeys` stays in the service, where it is applied by cadre-core's own
19
+ * `requireEd25519PublicKeyB64` — the service is also reached by the respawn path,
20
+ * which replays a persisted record rather than an HTTP body, so the crypto rule
21
+ * has to live there to cover both. What this validator owns for `ownerKeys` is the
22
+ * *container* shape (present, non-empty, all strings), which the service's rule
23
+ * assumes: a number reaching it surfaces as an internal `.trim is not a function`
24
+ * rather than as a message naming what is wrong with the request.
25
+ *
26
+ * The multiaddr rule has no such home — it is duplicated in cadre-provider — so it
27
+ * lives in `bootstrap-node-validation.ts` next to the comment saying so.
28
+ */
29
+ import { validateBootstrapNodes } from './bootstrap-node-validation.js';
30
+ /** `partyId` becomes `controlNetwork.partyId` in the child's config. */
31
+ function validatePartyId(value) {
32
+ if (typeof value !== 'string' || value.trim().length === 0) {
33
+ return { error: 'partyId is required' };
34
+ }
35
+ return { partyId: value.trim() };
36
+ }
37
+ /**
38
+ * Container shape only — see the module comment: the per-key Ed25519 rule is
39
+ * `DonationService.provision`'s, so the respawn path gets it too.
40
+ */
41
+ function validateOwnerKeys(value) {
42
+ if (!Array.isArray(value) || value.length === 0) {
43
+ return { error: 'ownerKeys is required' };
44
+ }
45
+ if (!value.every((key) => typeof key === 'string')) {
46
+ return { error: 'ownerKeys must be an array of strings' };
47
+ }
48
+ return { ownerKeys: value };
49
+ }
50
+ /** Absent means `storage` — see {@link DonationProvisionRequest.profile}. */
51
+ function validateProfile(value) {
52
+ if (value === undefined)
53
+ return {};
54
+ if (value !== 'storage' && value !== 'transaction') {
55
+ return { error: 'profile must be "storage" or "transaction"' };
56
+ }
57
+ return { profile: value };
58
+ }
59
+ /**
60
+ * Validate a `POST /grants` body and build the request `DonationService.provision`
61
+ * is handed.
62
+ *
63
+ * `grantToken` comes from the `Authorization` bearer rather than the body — a
64
+ * requester does not get to name which grant pays for this — so it is a
65
+ * parameter, not a validated field. Whether that grant is live and within quota is
66
+ * `provision`'s call, not this function's.
67
+ *
68
+ * @returns the typed provision request, or the message to answer `invalid_request` with.
69
+ */
70
+ export function validateProvisionRequest(body, grantToken) {
71
+ if (typeof body !== 'object' || body === null || Array.isArray(body)) {
72
+ return { error: 'request body must be a JSON object' };
73
+ }
74
+ const fields = body;
75
+ const partyId = validatePartyId(fields.partyId);
76
+ if ('error' in partyId)
77
+ return partyId;
78
+ const bootstrap = validateBootstrapNodes(fields.bootstrapNodes);
79
+ if ('error' in bootstrap)
80
+ return bootstrap;
81
+ const ownerKeys = validateOwnerKeys(fields.ownerKeys);
82
+ if ('error' in ownerKeys)
83
+ return ownerKeys;
84
+ const profile = validateProfile(fields.profile);
85
+ if ('error' in profile)
86
+ return profile;
87
+ return {
88
+ request: {
89
+ grantToken,
90
+ partyId: partyId.partyId,
91
+ bootstrapNodes: bootstrap.nodes,
92
+ ownerKeys: ownerKeys.ownerKeys,
93
+ ...(profile.profile ? { profile: profile.profile } : {}),
94
+ },
95
+ };
96
+ }
97
+ //# sourceMappingURL=provision-request-validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provision-request-validation.js","sourceRoot":"","sources":["../../../src/server/routes/provision-request-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE,wEAAwE;AACxE,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3D,OAAO,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC;IAC1C,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;AACnC,CAAC;AAED;;;GAGG;AACH,SAAS,iBAAiB,CAAC,KAAc;IACvC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChD,OAAO,EAAE,KAAK,EAAE,uBAAuB,EAAE,CAAC;IAC5C,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,EAAiB,EAAE,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,EAAE,CAAC;QAClE,OAAO,EAAE,KAAK,EAAE,uCAAuC,EAAE,CAAC;IAC5D,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AAC9B,CAAC;AAED,6EAA6E;AAC7E,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACnC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,aAAa,EAAE,CAAC;QACn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app: FastifyInstance, opts: StartServerOp
36
36
  * from a SIGINT/SIGTERM handler that may fire twice.
37
37
  */
38
38
  export declare function stopListening(app: FastifyInstance, opts?: ShutdownOptions): Promise<void>;
39
- /** Create a bare Fastify instance with the project's logging convention. */
39
+ /**
40
+ * Create a Fastify instance with the project's logging convention and the
41
+ * empty-body-tolerant JSON parser (see {@link acceptEmptyJsonBodies}).
42
+ */
40
43
  export declare function buildFastify(): FastifyInstance;
@@ -71,14 +71,48 @@ export async function stopListening(app, opts = {}) {
71
71
  log('shutdown drain timeout after %dms', drainMs);
72
72
  }
73
73
  }
74
- /** Create a bare Fastify instance with the project's logging convention. */
74
+ /**
75
+ * Create a Fastify instance with the project's logging convention and the
76
+ * empty-body-tolerant JSON parser (see {@link acceptEmptyJsonBodies}).
77
+ */
75
78
  export function buildFastify() {
76
- return Fastify({
79
+ const app = Fastify({
77
80
  // Stay quiet by default — request-level logs are noisy on a local UI.
78
81
  // Operators can opt in via the `debug` env var (cadre:host:*).
79
82
  logger: false,
80
83
  disableRequestLogging: true,
81
84
  });
85
+ acceptEmptyJsonBodies(app);
86
+ return app;
87
+ }
88
+ /**
89
+ * Treat a request that declares `application/json` but carries no body as a
90
+ * request with no body (`request.body === undefined`), instead of Fastify's
91
+ * default `400 FST_ERR_CTP_EMPTY_JSON_BODY`.
92
+ *
93
+ * `/grants` is served to other people's clients, and sending the JSON content
94
+ * type on every request, body or not, is a common client habit — the phone app
95
+ * did it, and the refused body-less `DELETE /grants/:id` left the loan and its
96
+ * node running. Every route that reads a body already reads `request.body ?? {}`,
97
+ * so a route that needs a field still answers its own `invalid_request` naming it.
98
+ * A non-empty body goes to Fastify's own parser, so malformed JSON is still a 400
99
+ * and the prototype-poisoning checks are unchanged (`'error'` is Fastify's default
100
+ * for both).
101
+ */
102
+ function acceptEmptyJsonBodies(app) {
103
+ // NOTE: 'error', 'error' mirrors Fastify's defaults for proto/constructor poisoning; if
104
+ // buildFastify ever sets `onProtoPoisoning` / `onConstructorPoisoning`, pass them here too.
105
+ const parseJson = app.getDefaultJsonParser('error', 'error');
106
+ app.removeContentTypeParser('application/json');
107
+ app.addContentTypeParser('application/json', { parseAs: 'string' }, (request, body, done) => {
108
+ if (body.length === 0) {
109
+ done(null, undefined);
110
+ return;
111
+ }
112
+ // Typed as possibly promise-returning; Fastify's default parser is the
113
+ // callback form and answers through `done`.
114
+ void parseJson(request, body, done);
115
+ });
82
116
  }
83
117
  function parsePort(address) {
84
118
  // address is e.g. http://127.0.0.1:8765
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,OAAiC,MAAM,SAAS,CAAC;AACxD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,GAAG,GAAG,KAAK,CAAC,mBAAmB,CAAC,CAAC;AAEvC,yDAAyD;AACzD,MAAM,yBAAyB,GAAG,IAAI,CAAC;AACvC,oEAAoE;AACpE,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,oDAAoD;AACpD,MAAM,aAAa,GAAG,WAAW,CAAC;AAsBlC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,GAAoB,EACpB,IAAwB;IAExB,IAAI,IAAI,CAAC,SAAS,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;QACnE,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;QAChC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,aAAa,IAAI,IAAI,EAAE,EAAE,CAAC;IAC1D,CAAC;IAED,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,OAAO,GAAiB,IAAI,CAAC;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG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