@fedify/fedify 0.15.6 → 0.15.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. package/CHANGES.md +80 -0
  2. package/esm/federation/handler.js +14 -0
  3. package/esm/runtime/key.js +1 -1
  4. package/esm/sig/http.js +9 -1
  5. package/esm/testing/fixtures/example.com/orderedcollectionpage +24 -0
  6. package/esm/vocab/application.yaml +2 -0
  7. package/esm/vocab/group.yaml +2 -0
  8. package/esm/vocab/organization.yaml +2 -0
  9. package/esm/vocab/person.yaml +2 -0
  10. package/esm/vocab/service.yaml +2 -0
  11. package/esm/vocab/vocab.js +450 -110
  12. package/package.json +1 -1
  13. package/types/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/concat.d.ts.map +1 -1
  14. package/types/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/copy.d.ts.map +1 -1
  15. package/types/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/ends_with.d.ts.map +1 -1
  16. package/types/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/equals.d.ts.map +1 -1
  17. package/types/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/includes_needle.d.ts.map +1 -1
  18. package/types/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/index_of_needle.d.ts.map +1 -1
  19. package/types/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/last_index_of_needle.d.ts.map +1 -1
  20. package/types/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/mod.d.ts.map +1 -1
  21. package/types/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/repeat.d.ts.map +1 -1
  22. package/types/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/starts_with.d.ts.map +1 -1
  23. package/types/federation/handler.d.ts.map +1 -1
  24. package/types/sig/http.d.ts.map +1 -1
  25. package/types/vocab/vocab.d.ts +30 -30
  26. package/types/vocab/vocab.d.ts.map +1 -1
  27. /package/esm/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/concat.js +0 -0
  28. /package/esm/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/copy.js +0 -0
  29. /package/esm/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/ends_with.js +0 -0
  30. /package/esm/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/equals.js +0 -0
  31. /package/esm/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/includes_needle.js +0 -0
  32. /package/esm/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/index_of_needle.js +0 -0
  33. /package/esm/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/last_index_of_needle.js +0 -0
  34. /package/esm/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/mod.js +0 -0
  35. /package/esm/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/repeat.js +0 -0
  36. /package/esm/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/starts_with.js +0 -0
  37. /package/types/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/concat.d.ts +0 -0
  38. /package/types/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/copy.d.ts +0 -0
  39. /package/types/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/ends_with.d.ts +0 -0
  40. /package/types/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/equals.d.ts +0 -0
  41. /package/types/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/includes_needle.d.ts +0 -0
  42. /package/types/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/index_of_needle.d.ts +0 -0
  43. /package/types/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/last_index_of_needle.d.ts +0 -0
  44. /package/types/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/mod.d.ts +0 -0
  45. /package/types/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/repeat.d.ts +0 -0
  46. /package/types/deps/jsr.io/@std/bytes/{1.0.3 → 1.0.4}/starts_with.d.ts +0 -0
package/CHANGES.md CHANGED
@@ -3,6 +3,86 @@
3
3
  Fedify changelog
4
4
  ================
5
5
 
6
+ Version 0.15.8
7
+ --------------
8
+
9
+ Released on November 159, 2024.
10
+
11
+ - Fix a bug where `Actor`'s `inbox` and `outbox` properties had not been
12
+ able to be set to an `OrderedCollectionPage` object, even though it is
13
+ a subtype of `OrderedCollection` according to Activity Vocabulary
14
+ specification. [[#165]]
15
+
16
+ - The type of `Application()` constructor's `inbox` and `outbox` options
17
+ is now `OrderedCollection | OrderedCollectionPage | null | undefined`
18
+ (was `OrderedCollection | null | undefined`).
19
+ - The type of `Application.clone()` method's `inbox` and `outbox` options
20
+ is now `OrderedCollection | OrderedCollectionPage | null | undefined`
21
+ (was `OrderedCollection | null | undefined`).
22
+ - The return type of `Application.getInbox()` and
23
+ `Application.getOutbox()` methods is now `OrderedCollection |
24
+ OrderedCollectionPage | null` (was `OrderedCollection | null`).
25
+ - The type of `Group()` constructor's `inbox` and `outbox` options is
26
+ now `OrderedCollection | OrderedCollectionPage | null | undefined` (was
27
+ `OrderedCollection | null | undefined`).
28
+ - The type of `Group.clone()` method's `inbox` and `outbox` options is
29
+ now `OrderedCollection | OrderedCollectionPage | null | undefined` (was
30
+ `OrderedCollection | null | undefined`).
31
+ - The return type of `Group.getInbox()` and `Group.getOutbox()` methods
32
+ is now `OrderedCollection | OrderedCollectionPage | null` (was
33
+ `OrderedCollection | null`).
34
+ - The type of `Organization()` constructor's `inbox` and `outbox` options
35
+ is now `OrderedCollection | OrderedCollectionPage | null | undefined`
36
+ (was `OrderedCollection | null | undefined`).
37
+ - The type of `Organization.clone()` method's `inbox` and `outbox` options
38
+ is now `OrderedCollection | OrderedCollectionPage | null | undefined`
39
+ (was `OrderedCollection | null | undefined`).
40
+ - The return type of `Organization.getInbox()` and
41
+ `Organization.getOutbox()` methods is now `OrderedCollection |
42
+ OrderedCollectionPage | null` (was `OrderedCollection | null`).
43
+ - The type of `Person()` constructor's `inbox` and `outbox` options is
44
+ now `OrderedCollection | OrderedCollectionPage | null | undefined` (was
45
+ `OrderedCollection | null | undefined`).
46
+ - The type of `Person.clone()` method's `inbox` and `outbox` options is
47
+ now `OrderedCollection | OrderedCollectionPage | null | undefined` (was
48
+ `OrderedCollection | null | undefined`).
49
+ - The return type of `Person.getInbox()` and `Person.getOutbox()` methods
50
+ is now `OrderedCollection | OrderedCollectionPage | null` (was
51
+ `OrderedCollection | null`).
52
+ - The type of `Service()` constructor's `inbox` and `outbox` options is
53
+ now `OrderedCollection | OrderedCollectionPage | null | undefined` (was
54
+ `OrderedCollection | null | undefined`).
55
+ - The type of `Service.clone()` method's `inbox` and `outbox` options is
56
+ now `OrderedCollection | OrderedCollectionPage | null | undefined` (was
57
+ `OrderedCollection | null | undefined`).
58
+ - The return type of `Service.getInbox()` and `Service.getOutbox()`
59
+ methods is now `OrderedCollection | OrderedCollectionPage | null` (was
60
+ `OrderedCollection | null`).
61
+
62
+ [#165]: https://github.com/dahlia/fedify/issues/165
63
+
64
+
65
+ Version 0.15.7
66
+ --------------
67
+
68
+ Released on November 14, 2024.
69
+
70
+ - Suppressed a `TypeError` with a message <q>unusable</q> due to Node.js's
71
+ mysterious behavior. [[#159]]
72
+
73
+ - The `verifyRequest()` function no longer throws a `TypeError`
74
+ when a given `Request` object's body is already consumed or locked.
75
+ Instead, it logs an error message to the `["fedify", "sig", "http"]`
76
+ logger category and returns `null`.
77
+ - The `Federation.fetch()` method no longer throws a `TypeError`
78
+ when a given `Request` object's body is already consumed or locked.
79
+ Instead, it logs an error message to the `["fedify", "federation",
80
+ "inbox"]` logger category and responds with a `500 Internal Server
81
+ Error`.
82
+
83
+ [#159]: https://github.com/dahlia/fedify/issues/159
84
+
85
+
6
86
  Version 0.15.6
7
87
  --------------
8
88
 
@@ -187,6 +187,20 @@ export async function handleInbox(request, { handle, context, kv, kvPrefixes, qu
187
187
  return await onNotFound(request);
188
188
  }
189
189
  }
190
+ if (request.bodyUsed) {
191
+ logger.error("Request body has already been read.", { handle });
192
+ return new Response("Internal server error.", {
193
+ status: 500,
194
+ headers: { "Content-Type": "text/plain; charset=utf-8" },
195
+ });
196
+ }
197
+ else if (request.body?.locked) {
198
+ logger.error("Request body is locked.", { handle });
199
+ return new Response("Internal server error.", {
200
+ status: 500,
201
+ headers: { "Content-Type": "text/plain; charset=utf-8" },
202
+ });
203
+ }
190
204
  let json;
191
205
  try {
192
206
  json = await request.clone().json();
@@ -1,6 +1,6 @@
1
1
  import * as dntShim from "../_dnt.shims.js";
2
2
  import { createPublicKey } from "node:crypto";
3
- import { concat } from "../deps/jsr.io/@std/bytes/1.0.3/concat.js";
3
+ import { concat } from "../deps/jsr.io/@std/bytes/1.0.4/concat.js";
4
4
  import { decodeBase64, encodeBase64 } from "../deps/jsr.io/@std/encoding/0.224.3/base64.js";
5
5
  import { decodeBase64Url } from "../deps/jsr.io/@std/encoding/0.224.3/base64url.js";
6
6
  import { decodeHex } from "../deps/jsr.io/@std/encoding/0.224.3/hex.js";
package/esm/sig/http.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as dntShim from "../_dnt.shims.js";
2
2
  import { getLogger } from "@logtape/logtape";
3
- import { equals } from "../deps/jsr.io/@std/bytes/1.0.3/mod.js";
3
+ import { equals } from "../deps/jsr.io/@std/bytes/1.0.4/mod.js";
4
4
  import { decodeBase64, encodeBase64 } from "../deps/jsr.io/@std/encoding/0.224.3/base64.js";
5
5
  import { CryptographicKey } from "../vocab/vocab.js";
6
6
  import { fetchKey, validateCryptoKey } from "./key.js";
@@ -69,6 +69,14 @@ const supportedHashAlgorithms = {
69
69
  */
70
70
  export async function verifyRequest(request, { documentLoader, contextLoader, timeWindow, currentTime, keyCache } = {}) {
71
71
  const logger = getLogger(["fedify", "sig", "http"]);
72
+ if (request.bodyUsed) {
73
+ logger.error("Failed to verify; the request body is already consumed.", { url: request.url });
74
+ return null;
75
+ }
76
+ else if (request.body?.locked) {
77
+ logger.error("Failed to verify; the request body is locked.", { url: request.url });
78
+ return null;
79
+ }
72
80
  const originalRequest = request;
73
81
  request = request.clone();
74
82
  const dateHeader = request.headers.get("Date");
@@ -0,0 +1,24 @@
1
+ {
2
+ "@context": "https://www.w3.org/ns/activitystreams",
3
+ "id": "https://example.com/orderedcollectionpage",
4
+ "type": "OrderedCollectionPage",
5
+ "partOf": "https://example.com/orderedcollectionpage",
6
+ "totalItems": 1,
7
+ "orderedItems": [
8
+ {
9
+ "id": "https://example.com/activities/1",
10
+ "type": "Create",
11
+ "published": "2024-11-19T15:24:56Z",
12
+ "actor": "https://example.com/users/1",
13
+ "to": "https://www.w3.org/ns/activitystreams#Public",
14
+ "object": {
15
+ "id": "https://example.com/notes/1",
16
+ "type": "Note",
17
+ "content": "This is a simple note",
18
+ "attributedTo": "https://example.com/users/1",
19
+ "to": "https://www.w3.org/ns/activitystreams#Public",
20
+ "published": "2024-11-19T15:24:56Z"
21
+ }
22
+ }
23
+ ]
24
+ }
@@ -97,6 +97,7 @@ properties:
97
97
  and dropping any activities already seen.
98
98
  range:
99
99
  - "https://www.w3.org/ns/activitystreams#OrderedCollection"
100
+ - "https://www.w3.org/ns/activitystreams#OrderedCollectionPage"
100
101
 
101
102
  - singularName: outbox
102
103
  functional: true
@@ -115,6 +116,7 @@ properties:
115
116
  implementing and deploying the server.
116
117
  range:
117
118
  - "https://www.w3.org/ns/activitystreams#OrderedCollection"
119
+ - "https://www.w3.org/ns/activitystreams#OrderedCollectionPage"
118
120
 
119
121
  - singularName: following
120
122
  functional: true
@@ -97,6 +97,7 @@ properties:
97
97
  and dropping any activities already seen.
98
98
  range:
99
99
  - "https://www.w3.org/ns/activitystreams#OrderedCollection"
100
+ - "https://www.w3.org/ns/activitystreams#OrderedCollectionPage"
100
101
 
101
102
  - singularName: outbox
102
103
  functional: true
@@ -115,6 +116,7 @@ properties:
115
116
  implementing and deploying the server.
116
117
  range:
117
118
  - "https://www.w3.org/ns/activitystreams#OrderedCollection"
119
+ - "https://www.w3.org/ns/activitystreams#OrderedCollectionPage"
118
120
 
119
121
  - singularName: following
120
122
  functional: true
@@ -97,6 +97,7 @@ properties:
97
97
  and dropping any activities already seen.
98
98
  range:
99
99
  - "https://www.w3.org/ns/activitystreams#OrderedCollection"
100
+ - "https://www.w3.org/ns/activitystreams#OrderedCollectionPage"
100
101
 
101
102
  - singularName: outbox
102
103
  functional: true
@@ -115,6 +116,7 @@ properties:
115
116
  implementing and deploying the server.
116
117
  range:
117
118
  - "https://www.w3.org/ns/activitystreams#OrderedCollection"
119
+ - "https://www.w3.org/ns/activitystreams#OrderedCollectionPage"
118
120
 
119
121
  - singularName: following
120
122
  functional: true
@@ -97,6 +97,7 @@ properties:
97
97
  and dropping any activities already seen.
98
98
  range:
99
99
  - "https://www.w3.org/ns/activitystreams#OrderedCollection"
100
+ - "https://www.w3.org/ns/activitystreams#OrderedCollectionPage"
100
101
 
101
102
  - singularName: outbox
102
103
  functional: true
@@ -115,6 +116,7 @@ properties:
115
116
  implementing and deploying the server.
116
117
  range:
117
118
  - "https://www.w3.org/ns/activitystreams#OrderedCollection"
119
+ - "https://www.w3.org/ns/activitystreams#OrderedCollectionPage"
118
120
 
119
121
  - singularName: following
120
122
  functional: true
@@ -97,6 +97,7 @@ properties:
97
97
  and dropping any activities already seen.
98
98
  range:
99
99
  - "https://www.w3.org/ns/activitystreams#OrderedCollection"
100
+ - "https://www.w3.org/ns/activitystreams#OrderedCollectionPage"
100
101
 
101
102
  - singularName: outbox
102
103
  functional: true
@@ -115,6 +116,7 @@ properties:
115
116
  implementing and deploying the server.
116
117
  range:
117
118
  - "https://www.w3.org/ns/activitystreams#OrderedCollection"
119
+ - "https://www.w3.org/ns/activitystreams#OrderedCollectionPage"
118
120
 
119
121
  - singularName: following
120
122
  functional: true