@akai-workflow-builder/cli-sdk 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 (44) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +57 -3
  3. package/dist/ctx/build-ctx.d.ts +10 -0
  4. package/dist/ctx/build-ctx.d.ts.map +1 -1
  5. package/dist/ctx/build-ctx.js +9 -0
  6. package/dist/ctx/private-egress.d.ts +81 -0
  7. package/dist/ctx/private-egress.d.ts.map +1 -0
  8. package/dist/ctx/private-egress.js +252 -0
  9. package/dist/ctx/safe-fetch.d.ts +54 -0
  10. package/dist/ctx/safe-fetch.d.ts.map +1 -1
  11. package/dist/ctx/safe-fetch.js +130 -15
  12. package/dist/ctx/trusted-ca.d.ts +60 -0
  13. package/dist/ctx/trusted-ca.d.ts.map +1 -0
  14. package/dist/ctx/trusted-ca.js +190 -0
  15. package/dist/define-connection.d.ts +3 -0
  16. package/dist/define-connection.d.ts.map +1 -1
  17. package/dist/define-connection.js +40 -0
  18. package/dist/index.d.ts +1 -0
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/manifest/json-schema.d.ts +5 -0
  21. package/dist/manifest/json-schema.d.ts.map +1 -1
  22. package/dist/manifest/json-schema.js +36 -0
  23. package/dist/manifest/types.d.ts +6 -0
  24. package/dist/manifest/types.d.ts.map +1 -1
  25. package/dist/runtime/executor/index.d.ts +9 -0
  26. package/dist/runtime/executor/index.d.ts.map +1 -1
  27. package/dist/runtime/executor/index.js +2 -1
  28. package/dist/runtime/index.d.ts +1 -0
  29. package/dist/runtime/index.d.ts.map +1 -1
  30. package/dist/runtime/registry/connection-manifest.d.ts.map +1 -1
  31. package/dist/runtime/registry/connection-manifest.js +1 -0
  32. package/dist/runtime/registry/loader.js +34 -6
  33. package/dist/runtime/registry/manifest-wire.d.ts.map +1 -1
  34. package/dist/runtime/registry/manifest-wire.js +2 -1
  35. package/dist/runtime/registry/types.d.ts +7 -0
  36. package/dist/runtime/registry/types.d.ts.map +1 -1
  37. package/dist/runtime/registry/wire.d.ts +17 -0
  38. package/dist/runtime/registry/wire.d.ts.map +1 -1
  39. package/dist/runtime/registry/wire.js +13 -0
  40. package/dist/tool.d.ts.map +1 -1
  41. package/dist/tool.js +19 -0
  42. package/dist/types.d.ts +36 -2
  43. package/dist/types.d.ts.map +1 -1
  44. package/package.json +3 -2
package/CHANGELOG.md CHANGED
@@ -4,6 +4,28 @@ All notable changes to `@akai-workflow-builder/cli-sdk` are documented here.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
6
 
7
+ ## [0.15.0](https://github.com/akai-workflow-builder/akai-cli-sdk/compare/cli-sdk-v0.14.0...cli-sdk-v0.15.0) (2026-10-22)
8
+
9
+
10
+ ### Features
11
+
12
+ * **connections:** declare a hosted MCP server on a connection (mcpServer) ([8f5a5b7](https://github.com/akai-workflow-builder/akai-cli-sdk/commit/8f5a5b7ef9856614ae893440d8adc6ad56cc655f))
13
+
14
+ ## [0.14.0](https://github.com/akai-workflow-builder/akai-cli-sdk/compare/cli-sdk-v0.13.0...cli-sdk-v0.14.0) (2026-10-16)
15
+
16
+
17
+ ### Features
18
+
19
+ * **network:** let a tool trust an intermediate for an incomplete TLS chain (AKAI-3302) ([d01e906](https://github.com/akai-workflow-builder/akai-cli-sdk/commit/d01e906904a7a27b0f12c7426e0f78d20fa5dd29))
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * **network:** accept only first-level intermediates in trustedCa ([c6d936a](https://github.com/akai-workflow-builder/akai-cli-sdk/commit/c6d936a2e4ef86d79b2f7f5384ec6828964e9c39))
25
+ * **network:** check the CA list itself for the OpenSSL store, prune expired additions (AKAI-3302) ([5bba1de](https://github.com/akai-workflow-builder/akai-cli-sdk/commit/5bba1deecfb6adab15a115bc74fa1c7396034361))
26
+ * **network:** judge trustedCa validity dates at install, not at tool() (AKAI-3302) ([4636741](https://github.com/akai-workflow-builder/akai-cli-sdk/commit/463674169ae11c7fe659fe2dca6ea03ec1ac023f))
27
+ * **network:** keep invalid certificates and the OpenSSL store out of trustedCa (AKAI-3302) ([7ea26bd](https://github.com/akai-workflow-builder/akai-cli-sdk/commit/7ea26bdca82de31f9afc14f6572701c5cfaf545c))
28
+
7
29
  ## [0.13.0](https://github.com/akai-workflow-builder/akai-cli-sdk/compare/cli-sdk-v0.12.0...cli-sdk-v0.13.0) (2026-10-12)
8
30
 
9
31
 
package/README.md CHANGED
@@ -21,7 +21,7 @@ npm install @akai-workflow-builder/cli-sdk zod
21
21
  | Node | `≥ 24` |
22
22
  | TypeScript | `≥ 5.0` (uses `const` type parameters for literal-key inference) |
23
23
  | `zod` | `^4.4.1` (peer dependency) |
24
- | `tsconfig.json` | needs `Response` / `RequestInit` / `AbortSignal`. Either add `"DOM"` to your existing `lib` entries (e.g. `"lib": ["ES2023", "DOM"]`) or include `@types/node@^18+` |
24
+ | `tsconfig.json` | needs `Response` / `RequestInit` / `AbortSignal`. Either add `"DOM"` to your existing `lib` entries (e.g. `"lib": ["ES2023", "DOM"]`) or install `@types/node@^18+` and list it in `"types"` (e.g. `"types": ["node"]`) — TypeScript 6 no longer loads `@types/*` packages that `types` does not name |
25
25
 
26
26
  ---
27
27
 
@@ -147,6 +147,26 @@ oauth: {
147
147
 
148
148
  See the `connection-identity` and `define-connection-oauth` migration specs (akai-app `app/connections/migration-specs/`) for per-field guidance.
149
149
 
150
+ ### Hosted MCP server connections
151
+
152
+ A connection can stand for a vendor's **hosted MCP server** (Notion, Linear, Stripe, …) instead of a set of CLIs. Set `mcpServer`:
153
+
154
+ ```ts
155
+ export default defineConnection({
156
+ slug: 'notion-mcp',
157
+ name: 'Notion',
158
+ vendor: 'Notion',
159
+ blurb: 'Search and edit Notion pages through the Notion MCP server.',
160
+ longDesc: 'Sign in with Notion. Akai talks to the server directly; no CLI tools are involved.',
161
+ authKind: 'oauth2', // or 'none' for an open server
162
+ mcpServer: { url: 'https://mcp.notion.com/mcp' }, // must be https
163
+ });
164
+ ```
165
+
166
+ - The host (akai-app) turns the connection into an MCP connection. With `authKind: 'oauth2'` it discovers the server's OAuth metadata at sign-in and registers itself through RFC 7591 dynamic client registration, so there is **no static OAuth client and no admin fields**: `oauth` must not be set.
167
+ - `authKind` must be `oauth2` or `none` (`apiKey` is not supported yet). `secrets`, `apiKeyHeader` and `jwtRefresh` must not be set, and `nativeBuiltin` must not be `true`.
168
+ - It is standalone: no `defineCLI` links to its slug, and the registry still lists it. On `/tools/list` it appears in `connections` with `mcpServer: { url }` (the field is omitted on every other connection).
169
+
150
170
  ---
151
171
 
152
172
  ## Core concepts
@@ -348,7 +368,7 @@ options: {
348
368
 
349
369
  - **Protocol** — HTTPS-only in production. HTTP allowed only when `NODE_ENV === 'development'`.
350
370
  - **Host** — exact-or-suffix-with-dot. `api.example.com` matches itself and `*.api.example.com`; `evil.api.example.com.attacker.tld` does not.
351
- - **DNS preflight** — hostname resolved before the request. In production, addresses in private (RFC 1918), loopback, link-local, or unique-local IPv6 ranges are refused (IPv4, IPv6, v4-mapped, and canonicalized forms). In development the private-IP refusal is skipped so handlers can target local services.
371
+ - **DNS preflight** — hostname resolved before the request. In production, addresses in private (RFC 1918), loopback, link-local, or unique-local IPv6 ranges are refused (IPv4, IPv6, v4-mapped, and canonicalized forms). In development the private-IP refusal is skipped so handlers can target local services. The one production exception is an operator pin passed by the host runtime — see [Operator-pinned private egress](#operator-pinned-private-egress-host-runtime-only).
352
372
  - **Redirects** — the SDK never follows a redirect, so a `Location:` to another host cannot smuggle a request past the egress check. `redirect: 'error'` is the default and `'follow'` is refused (it is downgraded to `'error'`), because following is the one mode that could leave the allowlisted host after the check has passed. `redirect: 'manual'` is honoured: it follows nothing, so the handler receives the 3xx itself — which is how a form-post portal reports success — and reaching the `Location:` costs a fresh `ctx.fetch` that re-runs the whole preflight.
353
373
  - **Identity headers** — `user-agent`, `x-akai-cli`, `x-akai-tool`, `x-akai-request-id` are stamped on every request. `x-akai-tenant` is stamped only when the host runtime passes a tenant id to `buildCtx`; otherwise it is removed even if a handler tried to set it. Handler-supplied values for any of these are always overwritten.
354
374
 
@@ -356,6 +376,40 @@ Protocol, host, and DNS-preflight failures reject with `AkaiEgressError` before
356
376
 
357
377
  Spec validation also rejects egress hosts that don't pass a syntactic DNS-hostname check — `localhost` (single label), IP literals, hosts with spaces or slashes — so they can't be declared in the first place. The check is shape-only; it doesn't verify the name is publicly resolvable, so internal DNS zones still pass the spec and are then handled at DNS-preflight time.
358
378
 
379
+ ### Operator-pinned private egress (host runtime only)
380
+
381
+ The DNS preflight refuses every private address, because a tool's host can come from a connection secret that a tenant user controls. A host runtime that deploys next to one platform-owned internal service can open exactly one exception for it. It passes `privateEgress` to `executeTool` (or `buildCtx`, or `createSafeFetch`):
382
+
383
+ ```ts
384
+ import { executeTool } from '@akai-workflow-builder/cli-sdk/runtime';
385
+
386
+ await executeTool({
387
+ /* …registry, body, logger, signal, workdir… */
388
+ privateEgress: [
389
+ {
390
+ cli: 'grafana', // the CLI id; no other CLI may use this entry
391
+ host: 'grafana.shared.akai', // exact hostname; no suffix match, never an IP literal
392
+ cidrs: ['10.33.0.0/16'], // the host must resolve inside these (each at most /16)
393
+ port: 443, // optional, default 443
394
+ caPem: '-----BEGIN CERTIFICATE-----…', // optional CA for this connection; default trust store otherwise
395
+ },
396
+ ],
397
+ });
398
+ ```
399
+
400
+ It is off by default: with no `privateEgress` the behaviour is exactly what is described above. The value comes from the host runtime's own configuration and from nowhere else — a tool definition, its options, secrets, properties, the request body and the process environment are never read as a pin.
401
+
402
+ A pin allows a call to reach a private address only when ALL of these hold; otherwise the unchanged `resolved to private address` error is thrown:
403
+
404
+ - the calling CLI id equals `cli`;
405
+ - the URL host equals `host` exactly (case-insensitive; `x.host` and `evilhost` do not match) and is also on the tool's own egress allowlist;
406
+ - the scheme is `https:` and the port equals `port`;
407
+ - EVERY resolved address is inside `cidrs`, and none is loopback, link-local (including the cloud metadata address) or unspecified. IPv4-mapped IPv6 forms (`::ffff:127.0.0.1`, `::ffff:7f00:1`) are judged as the IPv4 address they are.
408
+
409
+ The allowed call goes over `node:https`, held to what the check saw: the socket connects only to the addresses that passed (a later DNS answer cannot redirect it), the TLS name is the pinned host, `caPem` — when set — replaces the trust store for that connection, certificate verification stays on, and the `Host` header is forced to the pinned host whatever the handler set. Redirects follow the usual rule: refused unless `redirect: 'manual'`, and following a `Location:` is a fresh `ctx.fetch` with the full check.
410
+
411
+ An entry is ignored (and logged once through `logger.warn`) rather than half-applied when its `cli` is not a CLI id, its `host` is an IP literal or not a fully qualified name, `cidrs` is empty or malformed, a CIDR is wider than /16 or overlaps loopback, link-local or unspecified space (`127.0.0.0/8`, `169.254.0.0/16`, `0.0.0.0/8`, `::1`, `fe80::/10`, the IPv6 metadata address), `port` is not 1–65535, or `caPem` is not a PEM certificate.
412
+
359
413
  ### `isReadonly`
360
414
 
361
415
  Every tool must declare whether it mutates remote state:
@@ -448,7 +502,7 @@ Untyped throws are classified generically (a 500 with a derived message).
448
502
 
449
503
  ## Troubleshooting
450
504
 
451
- **`Cannot find name 'Response'`** — `tsconfig.json` is missing web-platform types. Add `"DOM"` to your existing `lib` entries (e.g. `"lib": ["ES2023", "DOM"]`) — setting `lib` overrides the target's defaults, so include both — or use `@types/node@^18+`.
505
+ **`Cannot find name 'Response'`** — `tsconfig.json` is missing web-platform types. Add `"DOM"` to your existing `lib` entries (e.g. `"lib": ["ES2023", "DOM"]`) — setting `lib` overrides the target's defaults, so include both — or install `@types/node@^18+` and add `"types": ["node"]` (TypeScript 6 defaults `types` to `[]`, so installing it alone is not enough).
452
506
 
453
507
  **`AkaiSpecError: undeclared secret 'X'`** — a `secretKeys` entry references a key that isn't in `defineCLI({ secrets: [...] })`.
454
508
 
@@ -1,3 +1,4 @@
1
+ import type { PrivateEgressPin } from './private-egress.js';
1
2
  import { type PropertyValues, type SecretValues } from './secrets.js';
2
3
  import type { CLIDef, ToolCtx, ToolLogger } from '../types.js';
3
4
  /**
@@ -34,6 +35,15 @@ export interface BuildCtxParams {
34
35
  readonly oauthAccessToken?: string;
35
36
  /** Surfaced as `ctx.appToken.accessToken`. */
36
37
  readonly appTokenAccessToken?: string;
38
+ /**
39
+ * Operator-pinned private egress, from the host runtime's own configuration.
40
+ * Each entry lets ONE CLI reach ONE exact host on a private address (see
41
+ * {@link PrivateEgressPin}); everything else stays refused. This argument is
42
+ * the only source: nothing a tool, its options, a secret or a property says
43
+ * is ever read as a pin. Omitted (the default) means no private address is
44
+ * reachable. Invalid entries are ignored and logged through `logger.warn`.
45
+ */
46
+ readonly privateEgress?: readonly PrivateEgressPin[];
37
47
  }
38
48
  /**
39
49
  * Assemble a frozen {@link ToolCtx} for one tool invocation: resolves
@@ -1 +1 @@
1
- {"version":3,"file":"build-ctx.d.ts","sourceRoot":"","sources":["../../src/ctx/build-ctx.ts"],"names":[],"mappings":"AAQA,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AAItB,OAAO,KAAK,EAAc,MAAM,EAAiB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAK1F;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,6GAA6G;IAC7G,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,sGAAsG;IACtG,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACzC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAA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AE,MAAM,CAAC;IAC5B,2CAA2C;IAC3C,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,8CAA8C;IAC9C,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IACtC;;;;;;;OAOG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACtD;AAoFD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAiFxD"}
@@ -110,6 +110,15 @@ export function buildCtx(params) {
110
110
  ...(tool.options.network.userAgent !== undefined
111
111
  ? { userAgent: tool.options.network.userAgent }
112
112
  : {}),
113
+ ...(params.privateEgress !== undefined
114
+ ? {
115
+ privateEgress: params.privateEgress,
116
+ onPrivateEgressInvalid: (message) => params.logger.warn(message),
117
+ }
118
+ : {}),
119
+ ...(tool.options.network.trustedCa !== undefined
120
+ ? { trustedCa: tool.options.network.trustedCa }
121
+ : {}),
113
122
  });
114
123
  const safePath = createSafePath([
115
124
  params.workdir,
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Operator-pinned private egress: the vocabulary behind `SafeFetchBinding.privateEgress`.
3
+ *
4
+ * safe-fetch refuses every private address, because a tool's host can come from
5
+ * a connection secret a tenant user controls (dynamic egress). One platform
6
+ * service is the exception — an Akai-owned, internal Grafana that only an
7
+ * operator can name. A *pin* lets the host runtime (never a tool, a secret or a
8
+ * property) open exactly one door: one CLI id, one exact hostname, one port,
9
+ * and the CIDR(s) that hostname must resolve into.
10
+ *
11
+ * This module holds the parts that need no network: the entry shape, the
12
+ * strict validation that decides which entries are honoured, and a small
13
+ * IPv4/IPv6 CIDR matcher. The request-time rule (`matchPrivatePin`) and the
14
+ * pinned transport live in ./safe-fetch.ts.
15
+ *
16
+ * Validation is fail-closed: an entry that breaks any rule is dropped — never
17
+ * repaired, never partially applied — and reported once. Dropping an entry only
18
+ * ever narrows what safe-fetch allows back to today's behaviour.
19
+ */
20
+ /**
21
+ * One operator-pinned private egress entry, as the host runtime passes it to
22
+ * `executeTool({ privateEgress })`. Plain data, so the host can `JSON.parse` it
23
+ * straight out of its deployment env.
24
+ */
25
+ export interface PrivateEgressPin {
26
+ /** CLI id (`defineCLI({ id })`) the pin applies to. No other CLI may use it. */
27
+ readonly cli: string;
28
+ /**
29
+ * Exact hostname the request URL must carry (compared case-insensitively; no
30
+ * suffix or wildcard match, never an IP literal). It must also be on the
31
+ * tool's own egress allowlist — a pin relaxes the private-address check, not
32
+ * the allowlist.
33
+ */
34
+ readonly host: string;
35
+ /**
36
+ * CIDRs the host must resolve into. EVERY resolved address has to fall inside
37
+ * one of them. Each CIDR may be at most as wide as /16 and may not touch
38
+ * loopback, link-local (incl. the cloud metadata address) or unspecified space.
39
+ */
40
+ readonly cidrs: readonly string[];
41
+ /** TCP port the URL must use. Defaults to 443. */
42
+ readonly port?: number;
43
+ /**
44
+ * PEM CA certificate(s) that sign the host's TLS certificate. Replaces the
45
+ * default trust store for this connection only; when absent the default store
46
+ * is used. TLS verification is never disabled.
47
+ */
48
+ readonly caPem?: string;
49
+ }
50
+ /** A parsed CIDR: the address bytes (4 for IPv4, 16 for IPv6) and the prefix length. */
51
+ export interface ParsedCidr {
52
+ readonly bytes: Uint8Array;
53
+ readonly prefix: number;
54
+ }
55
+ /** A {@link PrivateEgressPin} that passed validation, with the host lowercased and the CIDRs parsed. */
56
+ export interface NormalizedPrivateEgressPin {
57
+ readonly cli: string;
58
+ readonly host: string;
59
+ readonly port: number;
60
+ readonly cidrs: readonly ParsedCidr[];
61
+ readonly caPem?: string;
62
+ }
63
+ /**
64
+ * Address bytes with IPv4-mapped IPv6 peeled to plain IPv4, so every spelling
65
+ * of one address (`::ffff:127.0.0.1`, `::ffff:7f00:1`, `0:0:0:0:0:ffff:7f00:1`)
66
+ * compares equal to `127.0.0.1`. Null when `text` is not an IP address.
67
+ */
68
+ export declare function canonicalIp(text: string): Uint8Array | null;
69
+ /** `address/prefix`, with the prefix in range for the address family. No width limit — see {@link MIN_CIDR_PREFIX}. */
70
+ export declare function parseCidr(text: string): ParsedCidr | null;
71
+ export declare function cidrContains(cidr: ParsedCidr, ip: Uint8Array): boolean;
72
+ /** True for an address (as {@link canonicalIp} returns it) that no pin may ever allow. */
73
+ export declare function isForbiddenPinAddress(ip: Uint8Array): boolean;
74
+ /**
75
+ * Turn the host runtime's raw `privateEgress` value into the entries safe-fetch
76
+ * may honour. Fail-closed: anything that is not a well-formed entry is dropped
77
+ * and `onInvalid` hears about it once (the reason names the entry's index, never
78
+ * its contents). A value that is not an array drops them all.
79
+ */
80
+ export declare function normalizePrivateEgress(raw: unknown, onInvalid?: (message: string) => void): readonly NormalizedPrivateEgressPin[];
81
+ //# sourceMappingURL=private-egress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private-egress.d.ts","sourceRoot":"","sources":["../../src/ctx/private-egress.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,gFAAgF;IAChF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,kDAAkD;IAClD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wFAAwF;AACxF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,wGAAwG;AACxG,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,CAAC;IACtC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAsED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAI3D;AAED,uHAAuH;AACvH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAQzD;AAaD,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,GAAG,OAAO,CAEtE;AAiCD,0FAA0F;AAC1F,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,UAAU,GAAG,OAAO,CAE7D;AA+DD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,OAAO,EACZ,SAAS,GAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAe,GAC9C,SAAS,0BAA0B,EAAE,CAgBvC"}
@@ -0,0 +1,252 @@
1
+ /**
2
+ * Operator-pinned private egress: the vocabulary behind `SafeFetchBinding.privateEgress`.
3
+ *
4
+ * safe-fetch refuses every private address, because a tool's host can come from
5
+ * a connection secret a tenant user controls (dynamic egress). One platform
6
+ * service is the exception — an Akai-owned, internal Grafana that only an
7
+ * operator can name. A *pin* lets the host runtime (never a tool, a secret or a
8
+ * property) open exactly one door: one CLI id, one exact hostname, one port,
9
+ * and the CIDR(s) that hostname must resolve into.
10
+ *
11
+ * This module holds the parts that need no network: the entry shape, the
12
+ * strict validation that decides which entries are honoured, and a small
13
+ * IPv4/IPv6 CIDR matcher. The request-time rule (`matchPrivatePin`) and the
14
+ * pinned transport live in ./safe-fetch.ts.
15
+ *
16
+ * Validation is fail-closed: an entry that breaks any rule is dropped — never
17
+ * repaired, never partially applied — and reported once. Dropping an entry only
18
+ * ever narrows what safe-fetch allows back to today's behaviour.
19
+ */
20
+ import { isIPv4, isIPv6 } from 'node:net';
21
+ import { normalizePem } from './pem.js';
22
+ const DEFAULT_PORT = 443;
23
+ /**
24
+ * Widest CIDR an operator may pin (as a prefix length). A pin names where ONE
25
+ * platform host lives — a VPC subnet or a load balancer's addresses — so
26
+ * anything wider than a /16 is a mistake, not a configuration. The same bound
27
+ * applies to IPv6.
28
+ */
29
+ const MIN_CIDR_PREFIX = 16;
30
+ const CLI_ID_RE = /^[a-z][a-z0-9_-]*$/;
31
+ const HOSTNAME_RE = /^(?=.{1,253}$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+$/;
32
+ /** WHATWG URL reads a host whose last label is a number (`127.1`, `0x7f.1`) as an IPv4 address. */
33
+ const NUMERIC_LABEL_RE = /^(?:\d+|0x[0-9a-f]*)$/i;
34
+ const PREFIX_RE = /^(?:0|[1-9]\d{0,2})$/;
35
+ function parseIPv4(text) {
36
+ if (!isIPv4(text))
37
+ return null;
38
+ return Uint8Array.from(text.split('.').map(Number));
39
+ }
40
+ function parseIPv6(text) {
41
+ // A zone id (`fe80::1%eth0`) is scope, not address; `dns.lookup` does not
42
+ // produce one for a name, so refuse it rather than guess.
43
+ if (!isIPv6(text) || text.includes('%'))
44
+ return null;
45
+ // Fold an embedded dotted quad (`::ffff:127.0.0.1`) into two hextets first.
46
+ let normalized = text;
47
+ const dotted = text.match(/(\d{1,3}(?:\.\d{1,3}){3})$/);
48
+ if (dotted) {
49
+ const v4 = parseIPv4(dotted[1]);
50
+ if (v4 === null)
51
+ return null;
52
+ const hi = ((v4[0] << 8) | v4[1]).toString(16);
53
+ const lo = ((v4[2] << 8) | v4[3]).toString(16);
54
+ normalized = `${text.slice(0, -dotted[1].length)}${hi}:${lo}`;
55
+ }
56
+ const halves = normalized.split('::');
57
+ if (halves.length > 2)
58
+ return null;
59
+ const head = halves[0] === '' ? [] : halves[0].split(':');
60
+ const tail = halves.length === 2 && halves[1] !== '' ? halves[1].split(':') : [];
61
+ const fill = halves.length === 2 ? 8 - head.length - tail.length : 0;
62
+ if (fill < 0 || (halves.length === 1 && head.length !== 8))
63
+ return null;
64
+ const hextets = [...head, ...new Array(fill).fill('0'), ...tail];
65
+ if (hextets.length !== 8)
66
+ return null;
67
+ const bytes = new Uint8Array(16);
68
+ for (let i = 0; i < 8; i++) {
69
+ const value = parseInt(hextets[i], 16);
70
+ if (Number.isNaN(value) || value < 0 || value > 0xffff)
71
+ return null;
72
+ bytes[i * 2] = value >> 8;
73
+ bytes[i * 2 + 1] = value & 0xff;
74
+ }
75
+ return bytes;
76
+ }
77
+ /** Raw address bytes: 4 for IPv4, 16 for IPv6 (an IPv4-mapped one stays 16), or null for anything else. */
78
+ function parseIp(text) {
79
+ return isIPv4(text) ? parseIPv4(text) : parseIPv6(text);
80
+ }
81
+ function isV4Mapped(bytes) {
82
+ if (bytes.length !== 16 || bytes[10] !== 0xff || bytes[11] !== 0xff)
83
+ return false;
84
+ for (let i = 0; i < 10; i++)
85
+ if (bytes[i] !== 0)
86
+ return false;
87
+ return true;
88
+ }
89
+ /**
90
+ * Address bytes with IPv4-mapped IPv6 peeled to plain IPv4, so every spelling
91
+ * of one address (`::ffff:127.0.0.1`, `::ffff:7f00:1`, `0:0:0:0:0:ffff:7f00:1`)
92
+ * compares equal to `127.0.0.1`. Null when `text` is not an IP address.
93
+ */
94
+ export function canonicalIp(text) {
95
+ const bytes = parseIp(text);
96
+ if (bytes === null)
97
+ return null;
98
+ return isV4Mapped(bytes) ? bytes.slice(12) : bytes;
99
+ }
100
+ /** `address/prefix`, with the prefix in range for the address family. No width limit — see {@link MIN_CIDR_PREFIX}. */
101
+ export function parseCidr(text) {
102
+ const parts = text.split('/');
103
+ if (parts.length !== 2 || !PREFIX_RE.test(parts[1]))
104
+ return null;
105
+ const bytes = parseIp(parts[0]);
106
+ if (bytes === null)
107
+ return null;
108
+ const prefix = Number(parts[1]);
109
+ if (prefix > bytes.length * 8)
110
+ return null;
111
+ return { bytes, prefix };
112
+ }
113
+ /** True when the first `bits` bits of `a` and `b` are equal (and both are the same address family). */
114
+ function samePrefix(a, b, bits) {
115
+ if (a.length !== b.length)
116
+ return false;
117
+ const whole = bits >> 3;
118
+ for (let i = 0; i < whole; i++)
119
+ if (a[i] !== b[i])
120
+ return false;
121
+ const rest = bits & 7;
122
+ if (rest === 0)
123
+ return true;
124
+ const mask = (0xff << (8 - rest)) & 0xff;
125
+ return (a[whole] & mask) === (b[whole] & mask);
126
+ }
127
+ export function cidrContains(cidr, ip) {
128
+ return samePrefix(cidr.bytes, ip, cidr.prefix);
129
+ }
130
+ function cidrsOverlap(a, b) {
131
+ return samePrefix(a.bytes, b.bytes, Math.min(a.prefix, b.prefix));
132
+ }
133
+ /**
134
+ * Space a pin may never reach, whatever the operator wrote. It is checked twice:
135
+ * a CIDR that overlaps any of it is rejected when the entry is validated, and an
136
+ * address inside it is refused when a request is matched (defence in depth — a
137
+ * hand-built entry that skipped validation still cannot open these).
138
+ *
139
+ * - 127.0.0.0/8, ::1 loopback: the worker pod itself
140
+ * - 169.254.0.0/16, fe80::/10 link-local, incl. the IPv4 cloud metadata address
141
+ * - fd00:ec2::254 the IPv6 cloud metadata address
142
+ * - 0.0.0.0/8, :: unspecified: "this host" on some stacks
143
+ * - ::ffff:0:0/96 IPv4-mapped IPv6: write the IPv4 CIDR instead
144
+ */
145
+ const FORBIDDEN_RANGES = [
146
+ '127.0.0.0/8',
147
+ '169.254.0.0/16',
148
+ '0.0.0.0/8',
149
+ '::1/128',
150
+ '::/128',
151
+ 'fe80::/10',
152
+ 'fd00:ec2::254/128',
153
+ '::ffff:0:0/96',
154
+ ].map((text) => {
155
+ const cidr = parseCidr(text);
156
+ if (cidr === null)
157
+ throw new Error(`private-egress: bad built-in range ${text}`);
158
+ return cidr;
159
+ });
160
+ /** True for an address (as {@link canonicalIp} returns it) that no pin may ever allow. */
161
+ export function isForbiddenPinAddress(ip) {
162
+ return FORBIDDEN_RANGES.some((range) => cidrContains(range, ip));
163
+ }
164
+ function isPlainObject(value) {
165
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
166
+ }
167
+ /** Validate one entry. Returns the normalized pin, or the reason it is refused. */
168
+ function validatePin(raw) {
169
+ if (!isPlainObject(raw))
170
+ return 'entry is not an object';
171
+ const { cli, host, cidrs, port, caPem } = raw;
172
+ if (typeof cli !== 'string' || !CLI_ID_RE.test(cli))
173
+ return 'cli is not a valid CLI id';
174
+ if (typeof host !== 'string')
175
+ return 'host is not a string';
176
+ const hostname = host.toLowerCase();
177
+ if (isIPv4(hostname) || isIPv6(hostname) || hostname.startsWith('['))
178
+ return 'host is an IP literal';
179
+ if (!HOSTNAME_RE.test(hostname))
180
+ return 'host is not a fully qualified hostname';
181
+ if (NUMERIC_LABEL_RE.test(hostname.slice(hostname.lastIndexOf('.') + 1)))
182
+ return 'host is an IP literal';
183
+ if (!Array.isArray(cidrs) || cidrs.length === 0)
184
+ return 'cidrs is empty';
185
+ const parsed = [];
186
+ for (const text of cidrs) {
187
+ const cidr = typeof text === 'string' ? parseCidr(text) : null;
188
+ if (cidr === null)
189
+ return 'cidrs holds an entry that is not an address/prefix CIDR';
190
+ if (cidr.prefix < MIN_CIDR_PREFIX)
191
+ return `a CIDR is wider than /${MIN_CIDR_PREFIX}`;
192
+ if (FORBIDDEN_RANGES.some((range) => cidrsOverlap(cidr, range))) {
193
+ return 'a CIDR overlaps loopback, link-local, unspecified or metadata address space';
194
+ }
195
+ parsed.push(cidr);
196
+ }
197
+ let resolvedPort = DEFAULT_PORT;
198
+ if (port !== undefined) {
199
+ if (typeof port !== 'number' || !Number.isInteger(port) || port < 1 || port > 65535) {
200
+ return 'port is not an integer from 1 to 65535';
201
+ }
202
+ resolvedPort = port;
203
+ }
204
+ let ca;
205
+ if (caPem !== undefined) {
206
+ if (typeof caPem !== 'string')
207
+ return 'caPem is not a string';
208
+ try {
209
+ ca = normalizePem(caPem, {
210
+ secretKey: 'caPem',
211
+ cliId: cli,
212
+ toolName: 'privateEgress',
213
+ kind: 'certificate',
214
+ });
215
+ }
216
+ catch {
217
+ return 'caPem is not a PEM certificate';
218
+ }
219
+ }
220
+ return {
221
+ cli,
222
+ host: hostname,
223
+ port: resolvedPort,
224
+ cidrs: parsed,
225
+ ...(ca !== undefined ? { caPem: ca } : {}),
226
+ };
227
+ }
228
+ /**
229
+ * Turn the host runtime's raw `privateEgress` value into the entries safe-fetch
230
+ * may honour. Fail-closed: anything that is not a well-formed entry is dropped
231
+ * and `onInvalid` hears about it once (the reason names the entry's index, never
232
+ * its contents). A value that is not an array drops them all.
233
+ */
234
+ export function normalizePrivateEgress(raw, onInvalid = () => { }) {
235
+ if (raw === undefined)
236
+ return [];
237
+ if (!Array.isArray(raw)) {
238
+ onInvalid('private-egress: ignoring all entries: expected an array');
239
+ return [];
240
+ }
241
+ const pins = [];
242
+ raw.forEach((entry, index) => {
243
+ const result = validatePin(entry);
244
+ if (typeof result === 'string') {
245
+ onInvalid(`private-egress: ignoring entry ${index}: ${result}`);
246
+ }
247
+ else {
248
+ pins.push(result);
249
+ }
250
+ });
251
+ return pins;
252
+ }
@@ -1,3 +1,5 @@
1
+ import { type LookupFunction } from 'node:net';
2
+ import { type NormalizedPrivateEgressPin, type PrivateEgressPin } from './private-egress.js';
1
3
  /**
2
4
  * Default per-response byte cap for JSON/text `ctx.fetch` calls (override via
3
5
  * {@link SafeFetchBinding.maxResponseBytes}). Grounded in prod trace data
@@ -43,10 +45,55 @@ export interface SafeFetchBinding {
43
45
  * handler is still stripped, so this is the only sanctioned override.
44
46
  */
45
47
  readonly userAgent?: string;
48
+ /**
49
+ * Extra CA certificates from the tool's `network.trustedCa` (validated,
50
+ * normalised PEM), added to Node's default CA list before the first https
51
+ * request. See `ctx/trusted-ca.ts`.
52
+ */
53
+ readonly trustedCa?: readonly string[];
46
54
  /** Overrides {@link DEFAULT_MAX_RESPONSE_BYTES} for this tool. */
47
55
  readonly maxResponseBytes?: number;
56
+ /**
57
+ * Operator-pinned private egress: the only way a call may reach a private
58
+ * address (see {@link matchPrivatePin} for the exact rule). It comes from the
59
+ * host runtime's own configuration, never from a tool definition, its options,
60
+ * secrets or properties — so a tenant user who controls a connection secret
61
+ * cannot widen it. Empty or absent means today's behaviour, unchanged: every
62
+ * private address is refused. Invalid entries are ignored (fail closed) and
63
+ * reported through {@link onPrivateEgressInvalid}.
64
+ */
65
+ readonly privateEgress?: readonly PrivateEgressPin[];
66
+ /** One call per ignored {@link privateEgress} entry, with a human-readable reason. */
67
+ readonly onPrivateEgressInvalid?: (message: string) => void;
48
68
  }
49
69
  export type SafeFetch = (url: string, init?: RequestInit) => Promise<Response>;
70
+ /** What {@link matchPrivatePin} found: the pin that allows the call, and the addresses it is pinned to. */
71
+ export interface PrivatePinMatch {
72
+ readonly pin: NormalizedPrivateEgressPin;
73
+ /** Every address the lookup returned — all of them passed. The connection may go to these and nowhere else. */
74
+ readonly addresses: readonly string[];
75
+ }
76
+ /**
77
+ * Decide whether an operator pin allows a request whose host resolved to a
78
+ * private address. Returns the pin and the checked addresses, or `null` — and
79
+ * on `null` the caller throws the same refusal it always has, word for word.
80
+ *
81
+ * A pin allows the call only when ALL of these hold:
82
+ * - the calling CLI is the pin's CLI (`cliId === pin.cli`);
83
+ * - the URL host is the pin's host, exactly: `url.hostname` is already
84
+ * lowercased by WHATWG URL, and there is no suffix or wildcard match, so
85
+ * `x.host`, `evilhost` and `host.evil.com` all fail;
86
+ * - the scheme is `https:` and the port is the pin's (443 by default);
87
+ * - EVERY resolved address is inside one of the pin's CIDRs and none of them
88
+ * is loopback, link-local (incl. the metadata address) or unspecified.
89
+ * Addresses are canonicalized first, so `::ffff:127.0.0.1` and `::ffff:7f00:1`
90
+ * are judged as the `127.0.0.1` they are. A mixed answer — one address in the
91
+ * CIDR, one outside it — fails: a single bad record is enough.
92
+ *
93
+ * Several pins may share a CLI and host; the first that satisfies all of the
94
+ * above wins.
95
+ */
96
+ export declare function matchPrivatePin(pins: readonly NormalizedPrivateEgressPin[], cliId: string, url: URL, addresses: readonly string[]): PrivatePinMatch | null;
50
97
  /** The redirect modes a caller may ask for (lib.dom's `RequestRedirect`). */
51
98
  type RedirectMode = 'error' | 'follow' | 'manual';
52
99
  /**
@@ -66,5 +113,12 @@ type RedirectMode = 'error' | 'follow' | 'manual';
66
113
  */
67
114
  export declare function resolveRedirect(requested: RedirectMode | undefined): RedirectMode;
68
115
  export declare function createSafeFetch(binding: SafeFetchBinding): SafeFetch;
116
+ /**
117
+ * A `lookup` that answers with the addresses safe-fetch already checked, so the
118
+ * socket cannot be sent anywhere a second DNS answer might point. Node calls it
119
+ * in either shape — `all: true` (happy-eyeballs, the default since Node 20) wants
120
+ * a list, the legacy form wants one address and its family.
121
+ */
122
+ export declare function pinnedLookup(addresses: readonly string[]): LookupFunction;
69
123
  export {};
70
124
  //# sourceMappingURL=safe-fetch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"safe-fetch.d.ts","sourceRoot":"","sources":["../../src/ctx/safe-fetch.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,0BAA0B,QAAkB,CAAC;AAE1D;;;;;;;;GAQG;AACH,eAAO,MAAM,iCAAiC,QAAoB,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,kBAA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