@fedify/fedify 1.2.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGES.md CHANGED
@@ -3,6 +3,22 @@
3
3
  Fedify changelog
4
4
  ================
5
5
 
6
+ Version 1.2.4
7
+ -------------
8
+
9
+ Released on November 12, 2024.
10
+
11
+ - Fixed a bug where default document loaders had thrown a `TypeError`
12
+ with a message <q>Body is unusable: Body has already been read</q> or
13
+ <q>Body already consumed</q> when the content type of the response was
14
+ an HTML document and there's no link to a JSON-LD document.
15
+
16
+ - Fixed a bug where `verifySignature()` and `verifyJsonLd()` functions
17
+ sometimes had thrown a `jsonld.ValidationError` error. Now such errors
18
+ are caught and logged as warnings, and the signature to verify is considered
19
+ as invalid.
20
+
21
+
6
22
  Version 1.2.3
7
23
  -------------
8
24
 
@@ -92,6 +108,22 @@ Released on October 31, 2024.
92
108
  [#118]: https://github.com/dahlia/fedify/issues/118
93
109
 
94
110
 
111
+ Version 1.1.4
112
+ -------------
113
+
114
+ Released on November 12, 2024.
115
+
116
+ - Fixed a bug where default document loaders had thrown a `TypeError`
117
+ with a message <q>Body is unusable: Body has already been read</q> or
118
+ <q>Body already consumed</q> when the content type of the response was
119
+ an HTML document and there's no link to a JSON-LD document.
120
+
121
+ - Fixed a bug where `verifySignature()` and `verifyJsonLd()` functions
122
+ sometimes had thrown a `jsonld.ValidationError` error. Now such errors
123
+ are caught and logged as warnings, and the signature to verify is considered
124
+ as invalid.
125
+
126
+
95
127
  Version 1.1.3
96
128
  -------------
97
129
 
@@ -222,6 +254,22 @@ Released on October 20, 2024.
222
254
  [#150]: https://github.com/dahlia/fedify/issues/150
223
255
 
224
256
 
257
+ Version 1.0.8
258
+ -------------
259
+
260
+ Released on November 12, 2024.
261
+
262
+ - Fixed a bug where default document loaders had thrown a `TypeError`
263
+ with a message <q>Body is unusable: Body has already been read</q> or
264
+ <q>Body already consumed</q> when the content type of the response was
265
+ an HTML document and there's no link to a JSON-LD document.
266
+
267
+ - Fixed a bug where `verifySignature()` and `verifyJsonLd()` functions
268
+ sometimes had thrown a `jsonld.ValidationError` error. Now such errors
269
+ are caught and logged as warnings, and the signature to verify is considered
270
+ as invalid.
271
+
272
+
225
273
  Version 1.0.7
226
274
  -------------
227
275
 
@@ -471,6 +519,17 @@ Released on September 26, 2024.
471
519
  [#137]: https://github.com/dahlia/fedify/issues/137
472
520
 
473
521
 
522
+ Version 0.15.6
523
+ --------------
524
+
525
+ Released on November 12, 2024.
526
+
527
+ - Fixed a bug where default document loaders had thrown a `TypeError`
528
+ with a message <q>Body is unusable: Body has already been read</q> or
529
+ <q>Body already consumed</q> when the content type of the response was
530
+ an HTML document and there's no link to a JSON-LD document.
531
+
532
+
474
533
  Version 0.15.5
475
534
  --------------
476
535
 
@@ -86,6 +86,7 @@ async function getRemoteDocument(url, response, fetch) {
86
86
  }
87
87
  }
88
88
  }
89
+ let document;
89
90
  if (!jsonLd &&
90
91
  (contentType === "text/html" || contentType?.startsWith("text/html;") ||
91
92
  contentType === "application/xhtml+xml" ||
@@ -113,17 +114,17 @@ async function getRemoteDocument(url, response, fetch) {
113
114
  return await fetch(new URL(attribs.href, docUrl).href);
114
115
  }
115
116
  }
117
+ document = JSON.parse(html);
118
+ }
119
+ else {
120
+ document = await response.json();
116
121
  }
117
122
  logger.debug("Fetched document: {status} {url} {headers}", {
118
123
  status: response.status,
119
124
  url: documentUrl,
120
125
  headers: Object.fromEntries(response.headers.entries()),
121
126
  });
122
- return {
123
- contextUrl,
124
- document: await response.json(),
125
- documentUrl,
126
- };
127
+ return { contextUrl, document, documentUrl };
127
128
  }
128
129
  /**
129
130
  * A JSON-LD document loader that utilizes the browser's `fetch` API.
package/esm/sig/ld.js CHANGED
@@ -139,10 +139,24 @@ export async function verifySignature(jsonLd, options = {}) {
139
139
  delete sigOpts.type;
140
140
  delete sigOpts.id;
141
141
  delete sigOpts.signatureValue;
142
- const sigOptsHash = await hashJsonLd(sigOpts, options.contextLoader);
142
+ let sigOptsHash;
143
+ try {
144
+ sigOptsHash = await hashJsonLd(sigOpts, options.contextLoader);
145
+ }
146
+ catch (error) {
147
+ logger.warn("Failed to verify; failed to hash the signature options: {signatureOptions}\n{error}", { signatureOptions: sigOpts, error });
148
+ return null;
149
+ }
143
150
  const document = { ...jsonLd };
144
151
  delete document.signature;
145
- const docHash = await hashJsonLd(document, options.contextLoader);
152
+ let docHash;
153
+ try {
154
+ docHash = await hashJsonLd(document, options.contextLoader);
155
+ }
156
+ catch (error) {
157
+ logger.warn("Failed to verify; failed to hash the document: {document}\n{error}", { document, error });
158
+ return null;
159
+ }
146
160
  const encoder = new TextEncoder();
147
161
  const message = sigOptsHash + docHash;
148
162
  const messageBytes = encoder.encode(message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/fedify",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "An ActivityPub server framework",
5
5
  "keywords": [
6
6
  "ActivityPub",
@@ -1 +1 @@
1
- {"version":3,"file":"ld.d.ts","sourceRoot":"","sources":["../../src/sig/ld.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAM5C,OAAO,EACL,KAAK,cAAc,EAEpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAY,gBAAgB,EAAU,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAY,KAAK,QAAQ,EAAqB,MAAM,UAAU,CAAC;AAItE;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,UAAU,CAAC,EAAE,8BAA8B,CAAC;IAC5C,IAAI,EAAE,kBAAkB,CAAC;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,SAAS,GACnB;IAAE,SAAS,EAAE,SAAS,C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