@procedures/http 0.52.2 → 0.53.1

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,47 @@
1
1
  # @procedures/http
2
2
 
3
+ ## 0.53.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [84f0c78]
8
+ - Updated dependencies [abf290c]
9
+ - @procedures/client@0.53.1
10
+
11
+ ## 0.53.0
12
+
13
+ ### Patch Changes
14
+
15
+ - 5072370: `frameRefusal` tells if a browser refuses to show a page in a frame, from the headers `Content-Security-Policy` (`frame-ancestors`) and `X-Frame-Options`. `parseCsp`, `sourceAllows` and `sourceListAllows` give the parts of the CSP3 rules.
16
+ - d84a98c: `createHostFetch` gives the `headers` of the response, and takes the option `method: "HEAD"`. A `HEAD` request reads only the headers. Thus a caller of `frameRefusal` does not read the body of a large page.
17
+ - Updated dependencies [bc98f77]
18
+ - Updated dependencies [11d9084]
19
+ - Updated dependencies [d28ccb5]
20
+ - Updated dependencies [735cfcf]
21
+ - Updated dependencies
22
+ - Updated dependencies [556d0a8]
23
+ - @procedures/client@0.53.0
24
+
25
+ ## 0.52.5
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies [25a5f44]
30
+ - @procedures/client@0.52.5
31
+
32
+ ## 0.52.4
33
+
34
+ ### Patch Changes
35
+
36
+ - @procedures/client@0.52.4
37
+
38
+ ## 0.52.3
39
+
40
+ ### Patch Changes
41
+
42
+ - Updated dependencies [db1bcaa]
43
+ - @procedures/client@0.52.3
44
+
3
45
  ## 0.52.2
4
46
 
5
47
  ### Patch Changes
package/README.md CHANGED
@@ -92,7 +92,7 @@ const registry = createRegistry(createHttpModule({ allow: ["localhost:11434", "1
92
92
 
93
93
  ### The host policy in other packages
94
94
 
95
- `createHostFetch(options)` gives a `fetch` for GET requests through the same checks. Its options are the options of `createHttpModule()`. A procedure of another package uses it for a URL of its caller:
95
+ `createHostFetch(options)` gives a `fetch` for GET and HEAD requests through the same checks. Its options are the options of `createHttpModule()`. A procedure of another package uses it for a URL of its caller:
96
96
 
97
97
  - `weather.forecast` uses it by default.
98
98
  - `createGeoModule({ fetch })` and `createIcsModule({ fetch })` take it. Their default stays the global `fetch`, because their roots run in a browser.
@@ -107,6 +107,13 @@ const registry = createRegistry(createGeoModule({ fetch: createHostFetch({ allow
107
107
 
108
108
  A refusal is `FORBIDDEN` with the reason `host-not-allowed`. When the signal of the caller aborts, the function throws the reason of the signal, as `fetch` does.
109
109
 
110
+ The response has `headers`, with names in lowercase. The option `method: "HEAD"` reads only the headers of a page, for example for `frameRefusal`:
111
+
112
+ ```ts
113
+ const response = await hostFetch(url, { method: "HEAD", signal: AbortSignal.timeout(5_000) });
114
+ const decision = frameRefusal(response.headers, { ancestor: "http://127.0.0.1:3000", page: response.url });
115
+ ```
116
+
110
117
  ## Limits and time
111
118
 
112
119
  - Each input of `http.request` and `http.json` has `timeoutMs`. The default is 30 seconds.
@@ -148,6 +155,23 @@ A refusal is `FORBIDDEN` with the reason `host-not-allowed`. When the signal of
148
155
  - The procedure does not connect again after the end of the stream. To continue, a caller sends the last ID in `lastEventId`.
149
156
  - A redirect of a POST obeys the rules of the redirects. A 303, or a 301 or 302, continues with a GET without the body.
150
157
 
158
+ ## The frame rules of a response
159
+
160
+ A page can refuse to show in a frame of another page. `frameRefusal(headers, { ancestor, page })` gives the decision of a browser. It uses no network.
161
+
162
+ ```ts
163
+ import { frameRefusal } from "@procedures/http";
164
+
165
+ const decision = frameRefusal(response.headers, { ancestor: "https://a.example", page: response.url });
166
+ // { refused: true, by: "x-frame-options", detail: "X-Frame-Options is SAMEORIGIN, and https://a.example is another origin." }
167
+ ```
168
+
169
+ - An enforced policy with `frame-ancestors` decides. Then the function ignores `X-Frame-Options`. Each such policy must accept the ancestor.
170
+ - Else `X-Frame-Options` decides, by the rules of the HTML standard. `DENY` refuses, and `SAMEORIGIN` refuses an ancestor of another origin.
171
+ - Values of `X-Frame-Options` that do not agree refuse each frame. `ALLOW-FROM` and unknown values do not refuse, as in a browser.
172
+ - `Content-Security-Policy-Report-Only` does not refuse.
173
+ - `parseCsp`, `sourceAllows` and `sourceListAllows` give the parts of the CSP3 rules: the policies of the headers, and the match of a source expression.
174
+
151
175
  ## Limits of this package
152
176
 
153
177
  - The procedures do not use a proxy.