@fedify/fedify 0.8.0-dev.144 → 0.8.0-dev.148

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of @fedify/fedify might be problematic. Click here for more details.

package/CHANGES.md CHANGED
@@ -8,6 +8,9 @@ Version 0.8.0
8
8
 
9
9
  To be released.
10
10
 
11
+ - The CLI toolchain is now available on JSR: [@fedify/cli]. You can install
12
+ it with `deno install -A -n fedify jsr:@fedify/cli`.
13
+
11
14
  - Implemented [followers collection synchronization mechanism][FEP-8fcf].
12
15
 
13
16
  - Added `RequestContext.sendActivity()` overload that takes `"followers"`
@@ -21,7 +24,7 @@ To be released.
21
24
  - Added the second type parameter to `CollectionCursor` type.
22
25
  - Added the third parameter to `CollectionCursor` type.
23
26
 
24
- - Relaxed the required type for activity recipients.
27
+ - Relaxed the required type for activity recipients.
25
28
 
26
29
  - Added `Recipient` interface.
27
30
  - The type of the second parameter of `Context.sendActivity()` method
@@ -40,6 +43,13 @@ To be released.
40
43
  requires `--unstable-temporal` flag. On other runtime, it still depends
41
44
  on *@js-temporal/polyfill*.
42
45
 
46
+ - Added more log messages using the [LogTape] library. Currently the below
47
+ logger categories are used:
48
+
49
+ - `["fedify", "federation", "collection"]`
50
+ - `["fedify", "runtime", "docloader"]`
51
+
52
+ [@fedify/cli]: https://jsr.io/@fedify/cli
43
53
  [FEP-8fcf]: https://codeberg.org/fediverse/fep/src/branch/main/fep/8fcf/fep-8fcf.md
44
54
 
45
55
 
@@ -1,6 +1,8 @@
1
1
  import * as dntShim from "../_dnt.shims.js";
2
+ import { getLogger } from "@logtape/logtape";
2
3
  import { validateCryptoKey } from "../httpsig/key.js";
3
4
  import { sign } from "../httpsig/mod.js";
5
+ const logger = getLogger(["fedify", "runtime", "docloader"]);
4
6
  /**
5
7
  * Error thrown when fetching a JSON-LD document failed.
6
8
  */
@@ -29,11 +31,28 @@ function createRequest(url) {
29
31
  redirect: "follow",
30
32
  });
31
33
  }
34
+ function logRequest(request) {
35
+ logger.debug("Fetching document: {method} {url} {headers}", {
36
+ method: request.method,
37
+ url: request.url,
38
+ headers: Object.fromEntries(request.headers.entries()),
39
+ });
40
+ }
32
41
  async function getRemoteDocument(url, response) {
33
42
  const documentUrl = response.url === "" ? url : response.url;
34
43
  if (!response.ok) {
44
+ logger.error("Failed to fetch document: {status} {url} {headers}", {
45
+ status: response.status,
46
+ url: documentUrl,
47
+ headers: Object.fromEntries(response.headers.entries()),
48
+ });
35
49
  throw new FetchError(documentUrl, `HTTP ${response.status}: ${documentUrl}`);
36
50
  }
51
+ logger.error("Fetched document: {status} {url} {headers}", {
52
+ status: response.status,
53
+ url: documentUrl,
54
+ headers: Object.fromEntries(response.headers.entries()),
55
+ });
37
56
  return {
38
57
  contextUrl: null,
39
58
  document: await response.json(),
@@ -46,7 +65,9 @@ async function getRemoteDocument(url, response) {
46
65
  * @returns The remote document.
47
66
  */
48
67
  export async function fetchDocumentLoader(url) {
49
- const response = await fetch(createRequest(url));
68
+ const request = createRequest(url);
69
+ logRequest(request);
70
+ const response = await fetch(request);
50
71
  return getRemoteDocument(url, response);
51
72
  }
52
73
  /**
@@ -64,6 +85,7 @@ export function getAuthenticatedDocumentLoader(identity) {
64
85
  return async (url) => {
65
86
  let request = createRequest(url);
66
87
  request = await sign(request, identity.privateKey, identity.keyId);
88
+ logRequest(request);
67
89
  const response = await fetch(request);
68
90
  return getRemoteDocument(url, response);
69
91
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/fedify",
3
- "version": "0.8.0-dev.144+0f08fd72",
3
+ "version": "0.8.0-dev.148+31108ea9",
4
4
  "description": "An ActivityPub server framework",
5
5
  "keywords": [
6
6
  "ActivityPub",
@@ -1 +1 @@
1
- {"version":3,"file":"docloader.d.ts","sourceRoot":"","sources":["../../src/runtime/docloader.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,qBA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