@procedures/http 0.68.9 → 0.68.11

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @procedures/http
2
2
 
3
+ ## 0.68.11
4
+
5
+ ### Patch Changes
6
+
7
+ - @procedures/client@0.68.11
8
+
9
+ ## 0.68.10
10
+
11
+ ### Patch Changes
12
+
13
+ - a47f3df: A POST that only reads, for a service that takes its query only in the body of a POST.
14
+
15
+ - `createHostFetch()` of `@procedures/http` takes the new option `readOnlyPost`: the hosts that take a POST with a body. The default is no host, so the default fetch sends no POST. An entry is one host name or IP address, with a port or without one. It has no wildcard and no range. A POST follows no redirect.
16
+ - The new procedure `geo.soilAtPoint` of `@procedures/geo` gives the soil at a point, from USDA Soil Data Access (SSURGO). Its POST goes only to the endpoint of that service. The transport of `@procedures/geo` sends a POST only for a request that tells that it only reads.
17
+ - `geo.soilAtPoint` is a tool of `@procedures/bundle-assistant`. The `fetch` of `geo` in `mcpHostModules` takes a POST only for the host `sdmdataaccess.sc.egov.usda.gov`.
18
+ - @procedures/client@0.68.10
19
+
3
20
  ## 0.68.9
4
21
 
5
22
  ### Patch Changes
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * A `fetch` for GET and HEAD requests that goes through the host policy (audit pass 2, O55).
3
+ * It also sends a POST that only reads, to a host that the options name.
3
4
  *
4
5
  * A procedure of another package uses this function in place of the global `fetch` for a URL of
5
6
  * its caller. `weather.forecast` uses it, and so do the modules of `@procedures/geo` and
@@ -12,19 +13,38 @@
12
13
  * - A `HEAD` request reads only the headers. Thus a caller that needs the headers of a large page,
13
14
  * for example for `frameRefusal`, does not read its body.
14
15
  *
16
+ * - A POST goes only to a host of `readOnlyPost`: a service that takes a query only in the body of
17
+ * a POST, for example USDA Soil Data Access. The default list is empty, so the default fetch sends no POST.
18
+ * A POST follows no redirect: the response of a redirect is the result.
19
+ *
15
20
  * A refusal is `FORBIDDEN` with the reason `host-not-allowed` (`isHostNotAllowed`). When the
16
21
  * signal of the caller aborts, the function throws the reason of the signal, as `fetch` does.
17
22
  */
18
23
  import type { HttpModuleOptions } from "./module.js";
19
24
  /** The options of one request. */
20
25
  export interface HostFetchInit {
21
- /** The method of the request. The default is `GET`. */
22
- readonly method?: "GET" | "HEAD" | undefined;
26
+ /**
27
+ * The method of the request. The default is `GET`. A `POST` goes only to a host of
28
+ * `readOnlyPost` of the options.
29
+ */
30
+ readonly method?: "GET" | "HEAD" | "POST" | undefined;
23
31
  /** The headers of the request. */
24
32
  readonly headers?: Readonly<Record<string, string>> | undefined;
33
+ /** The body of a `POST`, as text. The headers give its type, for example `content-type: application/json`. */
34
+ readonly body?: string | undefined;
25
35
  /** The signal that stops the request. */
26
36
  readonly signal?: AbortSignal | undefined;
27
37
  }
38
+ /** The options of `createHostFetch()`: the options of `createHttpModule()`, and the hosts of a POST that only reads. */
39
+ export interface HostFetchOptions extends HttpModuleOptions {
40
+ /**
41
+ * The hosts that take a POST that only reads, for example `sdmdataaccess.sc.egov.usda.gov`.
42
+ * An entry is a host name or an IP address, with a port or without one (each port). It has no
43
+ * wildcard and no range: each host is a rule of its own. The default is no host. The host
44
+ * policy examines a host of this list as it examines each other host.
45
+ */
46
+ readonly readOnlyPost?: readonly string[] | undefined;
47
+ }
28
48
  /** The response of a request: the parts of a `Response` of `fetch` that the procedures use. */
29
49
  export interface HostFetchResponse {
30
50
  readonly ok: boolean;
@@ -36,16 +56,21 @@ export interface HostFetchResponse {
36
56
  text(): Promise<string>;
37
57
  json(): Promise<unknown>;
38
58
  }
39
- /** A `fetch` for GET and HEAD requests through the host policy. */
59
+ /** A `fetch` for GET and HEAD requests, and for a POST that only reads, through the host policy. */
40
60
  export type HostFetch = (url: string, init?: HostFetchInit) => Promise<HostFetchResponse>;
41
61
  /**
42
62
  * This function gives a `fetch` for GET and HEAD requests through the host policy of the options. The
43
63
  * options are the options of `createHttpModule()`. Without options, the policy is the default
44
- * policy: each public host, and no other host. A bad entry of `allow` throws here.
64
+ * policy: each public host, and no other host. A POST goes only to a host of `readOnlyPost`. A bad
65
+ * entry of `allow` or of `readOnlyPost` throws here.
66
+ *
67
+ * - The fetch throws `FORBIDDEN` with the reason `host-not-allowed` for a POST to a host that is not in `readOnlyPost`.
68
+ * - The fetch throws an `Error` for a body with a method other than POST.
45
69
  *
46
70
  * ```ts
47
71
  * const forecast = createWeatherModule({ fetch: createHostFetch({ allow: ["localhost:8080"] }) });
72
+ * const soil = createGeoModule({ fetch: createHostFetch({ readOnlyPost: ["sdmdataaccess.sc.egov.usda.gov"] }) });
48
73
  * ```
49
74
  */
50
- export declare function createHostFetch(options?: HttpModuleOptions): HostFetch;
75
+ export declare function createHostFetch(options?: HostFetchOptions): HostFetch;
51
76
  //# sourceMappingURL=host-fetch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"host-fetch.d.ts","sourceRoot":"","sources":["../src/host-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAOrD,kCAAkC;AAClC,MAAM,WAAW,aAAa;IAC5B,uDAAuD;IACvD,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;IAC7C,kCAAkC;IAClC,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;IAChE,yCAAyC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CAC3C;AAED,+FAA+F;AAC/F,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,iEAAiE;IACjE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,wH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BAAiB;IAChC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,iEAAiE;IACjE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,wHAAwH;IACxH,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;IACvE,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACxB,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1B;AAED,oGAAoG;AACpG,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE1F;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,gBAAqB,GAAG,SAAS,CA+CzE"}
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * A `fetch` for GET and HEAD requests that goes through the host policy (audit pass 2, O55).
3
+ * It also sends a POST that only reads, to a host that the options name.
3
4
  *
4
5
  * A procedure of another package uses this function in place of the global `fetch` for a URL of
5
6
  * its caller. `weather.forecast` uses it, and so do the modules of `@procedures/geo` and
@@ -12,28 +13,94 @@
12
13
  * - A `HEAD` request reads only the headers. Thus a caller that needs the headers of a large page,
13
14
  * for example for `frameRefusal`, does not read its body.
14
15
  *
16
+ * - A POST goes only to a host of `readOnlyPost`: a service that takes a query only in the body of
17
+ * a POST, for example USDA Soil Data Access. The default list is empty, so the default fetch sends no POST.
18
+ * A POST follows no redirect: the response of a redirect is the result.
19
+ *
15
20
  * A refusal is `FORBIDDEN` with the reason `host-not-allowed` (`isHostNotAllowed`). When the
16
21
  * signal of the caller aborts, the function throws the reason of the signal, as `fetch` does.
17
22
  */
18
23
  import { httpSettings } from "./module.js";
24
+ import { hostNotAllowed, portOf } from "./policy.js";
19
25
  import { httpRequest } from "./procedures/http/request.js";
20
26
  /** The longest time of a request of `http.request`: the signal of the caller is the real limit. */
21
27
  const LONGEST_MS = 86_400_000;
28
+ /** This function gives the host name of a URL without brackets and without a final dot, in lowercase. */
29
+ function bareHostname(url) {
30
+ const name = url.hostname.startsWith("[") ? url.hostname.slice(1, -1) : url.hostname;
31
+ return name.toLowerCase().replace(/\.$/, "");
32
+ }
33
+ /** This function parses one entry of `readOnlyPost`. A bad entry throws, so a host finds it at the start. */
34
+ function parsePostEntry(text) {
35
+ const entry = text.trim().toLowerCase();
36
+ const withPort = /^(.*[^:]):([0-9]{1,5})$/.exec(entry);
37
+ const head = withPort && (!withPort[1].includes(":") || withPort[1].endsWith("]")) ? withPort[1] : entry;
38
+ const port = head === entry ? undefined : Number(withPort[2]);
39
+ let url;
40
+ if (head !== "" && !/[*/@?#\\%\s]/.test(head)) {
41
+ try {
42
+ url = new URL(`http://${head.includes(":") && !head.startsWith("[") ? `[${head}]` : head}/`);
43
+ }
44
+ catch {
45
+ url = undefined;
46
+ }
47
+ }
48
+ if (url === undefined || (port !== undefined && (port < 1 || port > 65535))) {
49
+ throw new Error(`The readOnlyPost entry "${text}" is not a host name or an IP address, with a port or without one`);
50
+ }
51
+ return { hostname: bareHostname(url), port };
52
+ }
53
+ /** True when an entry of the list names the host and the port of the URL. */
54
+ function takesPost(entries, url) {
55
+ const hostname = bareHostname(url);
56
+ const port = portOf(url);
57
+ return entries.some((entry) => entry.hostname === hostname && (entry.port === undefined || entry.port === port));
58
+ }
22
59
  /**
23
60
  * This function gives a `fetch` for GET and HEAD requests through the host policy of the options. The
24
61
  * options are the options of `createHttpModule()`. Without options, the policy is the default
25
- * policy: each public host, and no other host. A bad entry of `allow` throws here.
62
+ * policy: each public host, and no other host. A POST goes only to a host of `readOnlyPost`. A bad
63
+ * entry of `allow` or of `readOnlyPost` throws here.
64
+ *
65
+ * - The fetch throws `FORBIDDEN` with the reason `host-not-allowed` for a POST to a host that is not in `readOnlyPost`.
66
+ * - The fetch throws an `Error` for a body with a method other than POST.
26
67
  *
27
68
  * ```ts
28
69
  * const forecast = createWeatherModule({ fetch: createHostFetch({ allow: ["localhost:8080"] }) });
70
+ * const soil = createGeoModule({ fetch: createHostFetch({ readOnlyPost: ["sdmdataaccess.sc.egov.usda.gov"] }) });
29
71
  * ```
30
72
  */
31
73
  export function createHostFetch(options = {}) {
32
74
  const settings = httpSettings(options);
75
+ const postEntries = (options.readOnlyPost ?? []).map(parsePostEntry);
33
76
  return async (url, init = {}) => {
77
+ const method = init.method ?? "GET";
78
+ if (init.body !== undefined && method !== "POST")
79
+ throw new Error(`A ${method} request of createHostFetch has no body: a body needs the method POST`);
80
+ if (method === "POST") {
81
+ let target;
82
+ try {
83
+ target = new URL(url);
84
+ }
85
+ catch (error) {
86
+ throw new Error(`The URL ${JSON.stringify(url)} of the POST is not a URL`, { cause: error });
87
+ }
88
+ if (!takesPost(postEntries, target)) {
89
+ throw hostNotAllowed(["http", "request"], `the host ${bareHostname(target)}:${portOf(target)} takes no POST: it is not in readOnlyPost of createHostFetch`);
90
+ }
91
+ }
34
92
  let output;
35
93
  try {
36
- output = await httpRequest({ url, method: init.method ?? "GET", ...(init.headers !== undefined ? { headers: { ...init.headers } } : {}), responseType: "text", timeoutMs: LONGEST_MS }, { signal: init.signal }, settings);
94
+ output = await httpRequest({
95
+ url,
96
+ method,
97
+ ...(init.headers !== undefined ? { headers: { ...init.headers } } : {}),
98
+ ...(init.body !== undefined ? { body: init.body } : {}),
99
+ // A POST stays on its host: the fetch gives the response of a redirect, and does not follow it
100
+ ...(method === "POST" ? { redirect: "manual" } : {}),
101
+ responseType: "text",
102
+ timeoutMs: LONGEST_MS,
103
+ }, { signal: init.signal }, settings);
37
104
  }
38
105
  catch (error) {
39
106
  if (init.signal?.aborted)
@@ -1 +1 @@
1
- {"version":3,"file":"host-fetch.js","sourceRoot":"","sources":["../src/host-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;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son, httpSse } from "./procedures/http/index.js";
4
4
  export { HOST_NOT_ALLOWED, DEFAULT_HOST_POLICY, createHostPolicy, checkHost, isHostNotAllowed, systemResolver } from "./policy.js";
5
- export { createHostFetch, type HostFetch, type HostFetchInit, type HostFetchResponse } from "./host-fetch.js";
5
+ export { createHostFetch, type HostFetch, type HostFetchInit, type HostFetchOptions, type HostFetchResponse } from "./host-fetch.js";
6
6
  export type { AllowedTarget, HostPolicy, HostPolicyOptions, HostResolver, ResolvedAddress } from "./policy.js";
7
7
  export { MAX_PROXY_REFUSALS, PROXY_HOST, startPolicyProxy, type PolicyProxy, type PolicyProxyOptions, type ProxyRefusal } from "./proxy.js";
8
8
  export { isLocalName, isPublicAddress, parseAddress, specialClass } from "./address.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAExF,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,SAAS,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEnI,OAAO,EAAE,eAAe,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC9G,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE/G,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,gBAAgB,EAAE,KAAK,WAAW,EAAE,KAAK,kBAAkB,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAC5I,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACxF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,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAC/H,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAE7F,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACpF,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ export * from "./types.js";
4
4
  export { httpRequest, httpJson, httpNdjson, httpSse } from "./procedures/http/index.js";
5
5
  // The host policy (roadmap R38)
6
6
  export { HOST_NOT_ALLOWED, DEFAULT_HOST_POLICY, createHostPolicy, checkHost, isHostNotAllowed, systemResolver } from "./policy.js";
7
- // A fetch for GET requests through the host policy, for the procedures of other packages (O55)
7
+ // A fetch for GET requests, and for a POST that only reads, through the host policy, for the procedures of other packages (O55)
8
8
  export { createHostFetch } from "./host-fetch.js";
9
9
  // A local forward proxy that applies the host policy to each request of another program, for example a headless browser
10
10
  export { MAX_PROXY_REFUSALS, PROXY_HOST, startPolicyProxy } from "./proxy.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACxF,gCAAgC;AAChC,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,SAAS,EAAE,gBAAgB,EAAE,cAA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5D,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,gBAAgB,EAAqB,MAAM,eAAe,CAAC;AAC/H,OAAO,EAAE,WAAW,EAAE,SAAS,EAAyC,MAAM,cAAc,CAAC;AAC7F,6EAA6E;AAC7E,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@procedures/http",
4
- "version": "0.68.9",
4
+ "version": "0.68.11",
5
5
  "description": "HTTP as procedures: request, JSON, NDJSON and server-sent events, with a host allowlist that refuses private addresses, size limits and the deadline of the call.",
6
6
  "keywords": [
7
7
  "procedures",
@@ -74,7 +74,7 @@
74
74
  "procedures": "./dist/register.js"
75
75
  },
76
76
  "dependencies": {
77
- "@procedures/client": "0.68.9",
77
+ "@procedures/client": "0.68.11",
78
78
  "zod": "^4.6.5"
79
79
  },
80
80
  "scripts": {
package/src/host-fetch.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * A `fetch` for GET and HEAD requests that goes through the host policy (audit pass 2, O55).
3
+ * It also sends a POST that only reads, to a host that the options name.
3
4
  *
4
5
  * A procedure of another package uses this function in place of the global `fetch` for a URL of
5
6
  * its caller. `weather.forecast` uses it, and so do the modules of `@procedures/geo` and
@@ -12,12 +13,17 @@
12
13
  * - A `HEAD` request reads only the headers. Thus a caller that needs the headers of a large page,
13
14
  * for example for `frameRefusal`, does not read its body.
14
15
  *
16
+ * - A POST goes only to a host of `readOnlyPost`: a service that takes a query only in the body of
17
+ * a POST, for example USDA Soil Data Access. The default list is empty, so the default fetch sends no POST.
18
+ * A POST follows no redirect: the response of a redirect is the result.
19
+ *
15
20
  * A refusal is `FORBIDDEN` with the reason `host-not-allowed` (`isHostNotAllowed`). When the
16
21
  * signal of the caller aborts, the function throws the reason of the signal, as `fetch` does.
17
22
  */
18
23
 
19
24
  import type { HttpModuleOptions } from "./module.js";
20
25
  import { httpSettings } from "./module.js";
26
+ import { hostNotAllowed, portOf } from "./policy.js";
21
27
  import { httpRequest } from "./procedures/http/request.js";
22
28
 
23
29
  /** The longest time of a request of `http.request`: the signal of the caller is the real limit. */
@@ -25,14 +31,69 @@ const LONGEST_MS = 86_400_000;
25
31
 
26
32
  /** The options of one request. */
27
33
  export interface HostFetchInit {
28
- /** The method of the request. The default is `GET`. */
29
- readonly method?: "GET" | "HEAD" | undefined;
34
+ /**
35
+ * The method of the request. The default is `GET`. A `POST` goes only to a host of
36
+ * `readOnlyPost` of the options.
37
+ */
38
+ readonly method?: "GET" | "HEAD" | "POST" | undefined;
30
39
  /** The headers of the request. */
31
40
  readonly headers?: Readonly<Record<string, string>> | undefined;
41
+ /** The body of a `POST`, as text. The headers give its type, for example `content-type: application/json`. */
42
+ readonly body?: string | undefined;
32
43
  /** The signal that stops the request. */
33
44
  readonly signal?: AbortSignal | undefined;
34
45
  }
35
46
 
47
+ /** The options of `createHostFetch()`: the options of `createHttpModule()`, and the hosts of a POST that only reads. */
48
+ export interface HostFetchOptions extends HttpModuleOptions {
49
+ /**
50
+ * The hosts that take a POST that only reads, for example `sdmdataaccess.sc.egov.usda.gov`.
51
+ * An entry is a host name or an IP address, with a port or without one (each port). It has no
52
+ * wildcard and no range: each host is a rule of its own. The default is no host. The host
53
+ * policy examines a host of this list as it examines each other host.
54
+ */
55
+ readonly readOnlyPost?: readonly string[] | undefined;
56
+ }
57
+
58
+ /** One entry of `readOnlyPost`. */
59
+ interface PostEntry {
60
+ readonly hostname: string;
61
+ readonly port: number | undefined;
62
+ }
63
+
64
+ /** This function gives the host name of a URL without brackets and without a final dot, in lowercase. */
65
+ function bareHostname(url: URL): string {
66
+ const name = url.hostname.startsWith("[") ? url.hostname.slice(1, -1) : url.hostname;
67
+ return name.toLowerCase().replace(/\.$/, "");
68
+ }
69
+
70
+ /** This function parses one entry of `readOnlyPost`. A bad entry throws, so a host finds it at the start. */
71
+ function parsePostEntry(text: string): PostEntry {
72
+ const entry = text.trim().toLowerCase();
73
+ const withPort = /^(.*[^:]):([0-9]{1,5})$/.exec(entry);
74
+ const head = withPort && (!withPort[1]!.includes(":") || withPort[1]!.endsWith("]")) ? withPort[1]! : entry;
75
+ const port = head === entry ? undefined : Number(withPort![2]);
76
+ let url: URL | undefined;
77
+ if (head !== "" && !/[*/@?#\\%\s]/.test(head)) {
78
+ try {
79
+ url = new URL(`http://${head.includes(":") && !head.startsWith("[") ? `[${head}]` : head}/`);
80
+ } catch {
81
+ url = undefined;
82
+ }
83
+ }
84
+ if (url === undefined || (port !== undefined && (port < 1 || port > 65535))) {
85
+ throw new Error(`The readOnlyPost entry "${text}" is not a host name or an IP address, with a port or without one`);
86
+ }
87
+ return { hostname: bareHostname(url), port };
88
+ }
89
+
90
+ /** True when an entry of the list names the host and the port of the URL. */
91
+ function takesPost(entries: readonly PostEntry[], url: URL): boolean {
92
+ const hostname = bareHostname(url);
93
+ const port = portOf(url);
94
+ return entries.some((entry) => entry.hostname === hostname && (entry.port === undefined || entry.port === port));
95
+ }
96
+
36
97
  /** The response of a request: the parts of a `Response` of `fetch` that the procedures use. */
37
98
  export interface HostFetchResponse {
38
99
  readonly ok: boolean;
@@ -45,25 +106,53 @@ export interface HostFetchResponse {
45
106
  json(): Promise<unknown>;
46
107
  }
47
108
 
48
- /** A `fetch` for GET and HEAD requests through the host policy. */
109
+ /** A `fetch` for GET and HEAD requests, and for a POST that only reads, through the host policy. */
49
110
  export type HostFetch = (url: string, init?: HostFetchInit) => Promise<HostFetchResponse>;
50
111
 
51
112
  /**
52
113
  * This function gives a `fetch` for GET and HEAD requests through the host policy of the options. The
53
114
  * options are the options of `createHttpModule()`. Without options, the policy is the default
54
- * policy: each public host, and no other host. A bad entry of `allow` throws here.
115
+ * policy: each public host, and no other host. A POST goes only to a host of `readOnlyPost`. A bad
116
+ * entry of `allow` or of `readOnlyPost` throws here.
117
+ *
118
+ * - The fetch throws `FORBIDDEN` with the reason `host-not-allowed` for a POST to a host that is not in `readOnlyPost`.
119
+ * - The fetch throws an `Error` for a body with a method other than POST.
55
120
  *
56
121
  * ```ts
57
122
  * const forecast = createWeatherModule({ fetch: createHostFetch({ allow: ["localhost:8080"] }) });
123
+ * const soil = createGeoModule({ fetch: createHostFetch({ readOnlyPost: ["sdmdataaccess.sc.egov.usda.gov"] }) });
58
124
  * ```
59
125
  */
60
- export function createHostFetch(options: HttpModuleOptions = {}): HostFetch {
126
+ export function createHostFetch(options: HostFetchOptions = {}): HostFetch {
61
127
  const settings = httpSettings(options);
128
+ const postEntries = (options.readOnlyPost ?? []).map(parsePostEntry);
62
129
  return async (url, init = {}) => {
130
+ const method = init.method ?? "GET";
131
+ if (init.body !== undefined && method !== "POST") throw new Error(`A ${method} request of createHostFetch has no body: a body needs the method POST`);
132
+ if (method === "POST") {
133
+ let target: URL;
134
+ try {
135
+ target = new URL(url);
136
+ } catch (error) {
137
+ throw new Error(`The URL ${JSON.stringify(url)} of the POST is not a URL`, { cause: error });
138
+ }
139
+ if (!takesPost(postEntries, target)) {
140
+ throw hostNotAllowed(["http", "request"], `the host ${bareHostname(target)}:${portOf(target)} takes no POST: it is not in readOnlyPost of createHostFetch`);
141
+ }
142
+ }
63
143
  let output;
64
144
  try {
65
145
  output = await httpRequest(
66
- { url, method: init.method ?? "GET", ...(init.headers !== undefined ? { headers: { ...init.headers } } : {}), responseType: "text", timeoutMs: LONGEST_MS },
146
+ {
147
+ url,
148
+ method,
149
+ ...(init.headers !== undefined ? { headers: { ...init.headers } } : {}),
150
+ ...(init.body !== undefined ? { body: init.body } : {}),
151
+ // A POST stays on its host: the fetch gives the response of a redirect, and does not follow it
152
+ ...(method === "POST" ? { redirect: "manual" as const } : {}),
153
+ responseType: "text",
154
+ timeoutMs: LONGEST_MS,
155
+ },
67
156
  { signal: init.signal },
68
157
  settings,
69
158
  );
package/src/index.ts CHANGED
@@ -4,8 +4,8 @@ export * from "./types.js";
4
4
  export { httpRequest, httpJson, httpNdjson, httpSse } from "./procedures/http/index.js";
5
5
  // The host policy (roadmap R38)
6
6
  export { HOST_NOT_ALLOWED, DEFAULT_HOST_POLICY, createHostPolicy, checkHost, isHostNotAllowed, systemResolver } from "./policy.js";
7
- // A fetch for GET requests through the host policy, for the procedures of other packages (O55)
8
- export { createHostFetch, type HostFetch, type HostFetchInit, type HostFetchResponse } from "./host-fetch.js";
7
+ // A fetch for GET requests, and for a POST that only reads, through the host policy, for the procedures of other packages (O55)
8
+ export { createHostFetch, type HostFetch, type HostFetchInit, type HostFetchOptions, type HostFetchResponse } from "./host-fetch.js";
9
9
  export type { AllowedTarget, HostPolicy, HostPolicyOptions, HostResolver, ResolvedAddress } from "./policy.js";
10
10
  // A local forward proxy that applies the host policy to each request of another program, for example a headless browser
11
11
  export { MAX_PROXY_REFUSALS, PROXY_HOST, startPolicyProxy, type PolicyProxy, type PolicyProxyOptions, type ProxyRefusal } from "./proxy.js";