Skip to content

Commit c948b5e

Browse files
committed
Merge tag '1.4.11' into 1.5-maintenance
Fedify 1.4.11
2 parents 10faa76 + 7547160 commit c948b5e

3 files changed

Lines changed: 133 additions & 6 deletions

File tree

CHANGES.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ Version 1.5.3
88

99
To be released.
1010

11+
- Fixed a bug where inbox handler had thrown a `jsonld.SyntaxError` which
12+
caused a `500 Internal Server Error` when the received activity had
13+
an invalid JSON-LD syntax. Now it logs the error and responds with
14+
a `400 Bad Request` error instead. [[#232]]
15+
16+
- The `exportJwk()` function now populates the `alg` property of a returned
17+
`JsonWebKey` object with `"Ed25519"` if the input key is an Ed25519 key.
18+
1119

1220
Version 1.5.2
1321
-------------
@@ -158,6 +166,20 @@ Released on March 28, 2025.
158166
[multibase]: https://github.com/multiformats/js-multibase
159167

160168

169+
Version 1.4.11
170+
--------------
171+
172+
Released on May 16, 2025.
173+
174+
- Fixed a bug where inbox handler had thrown a `jsonld.SyntaxError` which
175+
caused a `500 Internal Server Error` when the received activity had
176+
an invalid JSON-LD syntax. Now it logs the error and responds with
177+
a `400 Bad Request` error instead. [[#232]]
178+
179+
- The `exportJwk()` function now populates the `alg` property of a returned
180+
`JsonWebKey` object with `"Ed25519"` if the input key is an Ed25519 key.
181+
182+
161183
Version 1.4.10
162184
--------------
163185

@@ -382,6 +404,20 @@ Released on February 5, 2025.
382404
[#195]: https://github.com/fedify-dev/fedify/issues/195
383405

384406

407+
Version 1.3.18
408+
--------------
409+
410+
Released on May 16, 2025.
411+
412+
- Fixed a bug where inbox handler had thrown a `jsonld.SyntaxError` which
413+
caused a `500 Internal Server Error` when the received activity had
414+
an invalid JSON-LD syntax. Now it logs the error and responds with
415+
a `400 Bad Request` error instead. [[#232]]
416+
417+
- The `exportJwk()` function now populates the `alg` property of a returned
418+
`JsonWebKey` object with `"Ed25519"` if the input key is an Ed25519 key.
419+
420+
385421
Version 1.3.17
386422
--------------
387423

@@ -722,6 +758,20 @@ Released on November 30, 2024.
722758
[#193]: https://github.com/fedify-dev/fedify/issues/193
723759

724760

761+
Version 1.2.22
762+
--------------
763+
764+
Released on May 16, 2025.
765+
766+
- Fixed a bug where inbox handler had thrown a `jsonld.SyntaxError` which
767+
caused a `500 Internal Server Error` when the received activity had
768+
an invalid JSON-LD syntax. Now it logs the error and responds with
769+
a `400 Bad Request` error instead. [[#232]]
770+
771+
- The `exportJwk()` function now populates the `alg` property of a returned
772+
`JsonWebKey` object with `"Ed25519"` if the input key is an Ed25519 key.
773+
774+
725775
Version 1.2.21
726776
--------------
727777

@@ -1110,6 +1160,20 @@ Released on October 31, 2024.
11101160
[#118]: https://github.com/fedify-dev/fedify/issues/118
11111161

11121162

1163+
Version 1.1.22
1164+
--------------
1165+
1166+
Released on May 16, 2025.
1167+
1168+
- Fixed a bug where inbox handler had thrown a `jsonld.SyntaxError` which
1169+
caused a `500 Internal Server Error` when the received activity had
1170+
an invalid JSON-LD syntax. Now it logs the error and responds with
1171+
a `400 Bad Request` error instead. [[#232]]
1172+
1173+
- The `exportJwk()` function now populates the `alg` property of a returned
1174+
`JsonWebKey` object with `"Ed25519"` if the input key is an Ed25519 key.
1175+
1176+
11131177
Version 1.1.21
11141178
--------------
11151179

@@ -1539,6 +1603,22 @@ Released on October 20, 2024.
15391603
[#150]: https://github.com/fedify-dev/fedify/issues/150
15401604

15411605

1606+
Version 1.0.25
1607+
--------------
1608+
1609+
Released on May 16, 2025.
1610+
1611+
- Fixed a bug where inbox handler had thrown a `jsonld.SyntaxError` which
1612+
caused a `500 Internal Server Error` when the received activity had
1613+
an invalid JSON-LD syntax. Now it logs the error and responds with
1614+
a `400 Bad Request` error instead. [[#232]]
1615+
1616+
- The `exportJwk()` function now populates the `alg` property of a returned
1617+
`JsonWebKey` object with `"Ed25519"` if the input key is an Ed25519 key.
1618+
1619+
[#232]: https://github.com/fedify-dev/fedify/issues/232
1620+
1621+
15421622
Version 1.0.24
15431623
--------------
15441624

src/federation/handler.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,41 @@ test("handleInbox()", async () => {
12711271
});
12721272
assertEquals(onNotFoundCalled, null);
12731273
assertEquals(response.status, 202);
1274+
1275+
const invalidRequest = new Request("https://example.com/", {
1276+
method: "POST",
1277+
body: JSON.stringify({
1278+
"@context": [
1279+
"https://www.w3.org/ns/activitystreams",
1280+
true,
1281+
23,
1282+
],
1283+
type: "Create",
1284+
object: { type: "Note", content: "Hello, world!" },
1285+
actor: "https://example.com/users/alice",
1286+
}),
1287+
});
1288+
const signedInvalidRequest = await signRequest(
1289+
invalidRequest,
1290+
rsaPrivateKey3,
1291+
rsaPublicKey3.id!,
1292+
);
1293+
const signedInvalidContext = createRequestContext({
1294+
request: signedInvalidRequest,
1295+
url: new URL(signedInvalidRequest.url),
1296+
data: undefined,
1297+
documentLoader: mockDocumentLoader,
1298+
});
1299+
response = await handleInbox(signedInvalidRequest, {
1300+
recipient: null,
1301+
context: signedContext,
1302+
inboxContextFactory(_activity) {
1303+
return createInboxContext(signedInvalidContext);
1304+
},
1305+
...inboxOptions,
1306+
});
1307+
assertEquals(onNotFoundCalled, null);
1308+
assertEquals(response.status, 400);
12741309
});
12751310

12761311
test("respondWithObject()", async () => {

src/federation/handler.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -596,12 +596,24 @@ async function handleInboxInternal<TContextData>(
596596
});
597597
}
598598
const keyCache = new KvKeyCache(kv, kvPrefixes.publicKey, ctx);
599-
const ldSigVerified = await verifyJsonLd(json, {
600-
contextLoader: ctx.contextLoader,
601-
documentLoader: ctx.documentLoader,
602-
keyCache,
603-
tracerProvider,
604-
});
599+
let ldSigVerified: boolean;
600+
try {
601+
ldSigVerified = await verifyJsonLd(json, {
602+
contextLoader: ctx.contextLoader,
603+
documentLoader: ctx.documentLoader,
604+
keyCache,
605+
tracerProvider,
606+
});
607+
} catch (error) {
608+
if (error instanceof Error && error.name === "jsonld.SyntaxError") {
609+
logger.error("Failed to parse JSON-LD:\n{error}", { recipient, error });
610+
return new Response("Invalid JSON-LD.", {
611+
status: 400,
612+
headers: { "Content-Type": "text/plain; charset=utf-8" },
613+
});
614+
}
615+
ldSigVerified = false;
616+
}
605617
const jsonWithoutSig = detachSignature(json);
606618
let activity: Activity | null = null;
607619
if (ldSigVerified) {

0 commit comments

Comments
 (0)