@fedify/fedify 0.8.0-dev.142 → 0.8.0-dev.148
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.
Potentially problematic release.
This version of @fedify/fedify might be problematic. Click here for more details.
- package/CHANGES.md +11 -1
- package/README.md +12 -15
- package/esm/runtime/docloader.js +23 -1
- package/package.json +1 -1
- package/types/runtime/docloader.d.ts.map +1 -1
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
|
|
package/README.md
CHANGED
@@ -105,15 +105,20 @@ via the following command:
|
|
105
105
|
deno add @fedify/fedify
|
106
106
|
~~~~
|
107
107
|
|
108
|
-
|
109
|
-
|
108
|
+
Since Fedify requires [`Temporal`] API, which is an unstable feature in Deno as
|
109
|
+
of April 2024, you need to add the `"temporal"` to the `"unstable"` field of
|
110
|
+
the *deno.json* file:
|
111
|
+
|
112
|
+
~~~~ json
|
113
|
+
{
|
114
|
+
"imports": {
|
115
|
+
"@fedify/fedify": "jsr:@fedify/fedify"
|
116
|
+
},
|
117
|
+
"unstable": ["temporal"]
|
118
|
+
}
|
110
119
|
~~~~
|
111
120
|
|
112
|
-
|
113
|
-
|
114
|
-
~~~~ typescript
|
115
|
-
import { Federation } from "jsr:@fedify/fedify";
|
116
|
-
~~~~
|
121
|
+
[`Temporal`]: https://tc39.es/proposal-temporal/docs/
|
117
122
|
|
118
123
|
### Node.js
|
119
124
|
|
@@ -125,10 +130,6 @@ the following command:
|
|
125
130
|
npm add @fedify/fedify
|
126
131
|
~~~~
|
127
132
|
|
128
|
-
~~~~ typescript
|
129
|
-
import { Federation } from "@fedify/fedify";
|
130
|
-
~~~~
|
131
|
-
|
132
133
|
### Bun
|
133
134
|
|
134
135
|
Fedify can also be used in Bun. You can install it via the following
|
@@ -137,7 +138,3 @@ command:
|
|
137
138
|
~~~~ sh
|
138
139
|
bun add @fedify/fedify
|
139
140
|
~~~~
|
140
|
-
|
141
|
-
~~~~ typescript
|
142
|
-
import { Federation } from "@fedify/fedify";
|
143
|
-
~~~~
|
package/esm/runtime/docloader.js
CHANGED
@@ -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
|
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 +1 @@
|
|
1
|
-
{"version":3,"file":"docloader.d.ts","sourceRoot":"","sources":["../../src/runtime/docloader.ts"],"names":[],"mappings":";AA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