@rmdes/indiekit-endpoint-activitypub 2.0.0 → 2.0.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/lib/federation-bridge.js +20 -5
- package/package.json +1 -1
package/lib/federation-bridge.js
CHANGED
|
@@ -28,14 +28,29 @@ export function fromExpressRequest(req) {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
let body;
|
|
32
|
+
if (req.method === "GET" || req.method === "HEAD") {
|
|
33
|
+
body = undefined;
|
|
34
|
+
} else if (!req.readable && req.body) {
|
|
35
|
+
// Express body parser already consumed the stream — reconstruct
|
|
36
|
+
// so downstream handlers (e.g. @fedify/debugger login) can read it.
|
|
37
|
+
const ct = req.headers["content-type"] || "";
|
|
38
|
+
if (ct.includes("application/json")) {
|
|
39
|
+
body = JSON.stringify(req.body);
|
|
40
|
+
} else if (ct.includes("application/x-www-form-urlencoded")) {
|
|
41
|
+
body = new URLSearchParams(req.body).toString();
|
|
42
|
+
} else {
|
|
43
|
+
body = undefined;
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
body = Readable.toWeb(req);
|
|
47
|
+
}
|
|
48
|
+
|
|
31
49
|
return new Request(url, {
|
|
32
50
|
method: req.method,
|
|
33
51
|
headers,
|
|
34
52
|
duplex: "half",
|
|
35
|
-
body
|
|
36
|
-
req.method === "GET" || req.method === "HEAD"
|
|
37
|
-
? undefined
|
|
38
|
-
: Readable.toWeb(req),
|
|
53
|
+
body,
|
|
39
54
|
});
|
|
40
55
|
}
|
|
41
56
|
|
|
@@ -52,7 +67,7 @@ async function sendFedifyResponse(res, response, request) {
|
|
|
52
67
|
res.setHeader(key, value);
|
|
53
68
|
});
|
|
54
69
|
|
|
55
|
-
if (!response.body) {
|
|
70
|
+
if (!response.body || response.bodyUsed) {
|
|
56
71
|
res.end();
|
|
57
72
|
return;
|
|
58
73
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rmdes/indiekit-endpoint-activitypub",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"indiekit",
|