Loading CHANGES.md +52 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,14 @@ Version 1.3.18 To be released. - Fixed a bug where inbox handler had thrown a `jsonld.SyntaxError` which caused a `500 Internal Server Error` when the received activity had an invalid JSON-LD syntax. Now it logs the error and responds with a `400 Bad Request` error instead. [[#232]] - The `exportJwk()` function now populates the `alg` property of a returned `JsonWebKey` object with `"Ed25519"` if the input key is an Ed25519 key. Version 1.3.17 -------------- Loading Loading @@ -349,6 +357,20 @@ Released on November 30, 2024. [#193]: https://github.com/fedify-dev/fedify/issues/193 Version 1.2.22 -------------- Released on May 16, 2025. - Fixed a bug where inbox handler had thrown a `jsonld.SyntaxError` which caused a `500 Internal Server Error` when the received activity had an invalid JSON-LD syntax. Now it logs the error and responds with a `400 Bad Request` error instead. [[#232]] - The `exportJwk()` function now populates the `alg` property of a returned `JsonWebKey` object with `"Ed25519"` if the input key is an Ed25519 key. Version 1.2.21 -------------- Loading Loading @@ -737,6 +759,20 @@ Released on October 31, 2024. [#118]: https://github.com/fedify-dev/fedify/issues/118 Version 1.1.22 -------------- Released on May 16, 2025. - Fixed a bug where inbox handler had thrown a `jsonld.SyntaxError` which caused a `500 Internal Server Error` when the received activity had an invalid JSON-LD syntax. Now it logs the error and responds with a `400 Bad Request` error instead. [[#232]] - The `exportJwk()` function now populates the `alg` property of a returned `JsonWebKey` object with `"Ed25519"` if the input key is an Ed25519 key. Version 1.1.21 -------------- Loading Loading @@ -1166,6 +1202,22 @@ Released on October 20, 2024. [#150]: https://github.com/fedify-dev/fedify/issues/150 Version 1.0.25 -------------- Released on May 16, 2025. - Fixed a bug where inbox handler had thrown a `jsonld.SyntaxError` which caused a `500 Internal Server Error` when the received activity had an invalid JSON-LD syntax. Now it logs the error and responds with a `400 Bad Request` error instead. [[#232]] - The `exportJwk()` function now populates the `alg` property of a returned `JsonWebKey` object with `"Ed25519"` if the input key is an Ed25519 key. [#232]: https://github.com/fedify-dev/fedify/issues/232 Version 1.0.24 -------------- Loading src/codegen/__snapshots__/class.test.ts.snap +132 −0 File changed.Preview size limit exceeded, changes collapsed. Show changes src/codegen/inspector.ts +2 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ export async function* generateInspector( return proxy; } // @ts-ignore: suppressing TS4127 ${emitOverride(typeUri, types)} [Symbol.for("Deno.customInspect")]( inspect: typeof Deno.inspect, options: Deno.InspectOptions, Loading @@ -81,6 +82,7 @@ export async function* generateInspector( return ${JSON.stringify(type.name + " ")} + inspect(proxy, options); } // @ts-ignore: suppressing TS4127 ${emitOverride(typeUri, types)} [Symbol.for("nodejs.util.inspect.custom")]( _depth: number, options: unknown, Loading src/federation/handler.test.ts +35 −0 Original line number Diff line number Diff line Loading @@ -1204,6 +1204,41 @@ test("handleInbox()", async () => { }); assertEquals(onNotFoundCalled, null); assertEquals(response.status, 202); const invalidRequest = new Request("https://example.com/", { method: "POST", body: JSON.stringify({ "@context": [ "https://www.w3.org/ns/activitystreams", true, 23, ], type: "Create", object: { type: "Note", content: "Hello, world!" }, actor: "https://example.com/users/alice", }), }); const signedInvalidRequest = await signRequest( invalidRequest, rsaPrivateKey3, rsaPublicKey3.id!, ); const signedInvalidContext = createRequestContext({ request: signedInvalidRequest, url: new URL(signedInvalidRequest.url), data: undefined, documentLoader: mockDocumentLoader, }); response = await handleInbox(signedInvalidRequest, { recipient: null, context: signedContext, inboxContextFactory(_activity) { return createInboxContext(signedInvalidContext); }, ...inboxOptions, }); assertEquals(onNotFoundCalled, null); assertEquals(response.status, 400); }); test("respondWithObject()", async () => { Loading src/federation/handler.ts +18 −6 Original line number Diff line number Diff line Loading @@ -541,12 +541,24 @@ async function handleInboxInternal<TContextData>( }); } const keyCache = new KvKeyCache(kv, kvPrefixes.publicKey, ctx); const ldSigVerified = await verifyJsonLd(json, { let ldSigVerified: boolean; try { ldSigVerified = await verifyJsonLd(json, { contextLoader: ctx.contextLoader, documentLoader: ctx.documentLoader, keyCache, tracerProvider, }); } catch (error) { if (error instanceof Error && error.name === "jsonld.SyntaxError") { logger.error("Failed to parse JSON-LD:\n{error}", { recipient, error }); return new Response("Invalid JSON-LD.", { status: 400, headers: { "Content-Type": "text/plain; charset=utf-8" }, }); } ldSigVerified = false; } const jsonWithoutSig = detachSignature(json); let activity: Activity | null = null; if (ldSigVerified) { Loading Loading
CHANGES.md +52 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,14 @@ Version 1.3.18 To be released. - Fixed a bug where inbox handler had thrown a `jsonld.SyntaxError` which caused a `500 Internal Server Error` when the received activity had an invalid JSON-LD syntax. Now it logs the error and responds with a `400 Bad Request` error instead. [[#232]] - The `exportJwk()` function now populates the `alg` property of a returned `JsonWebKey` object with `"Ed25519"` if the input key is an Ed25519 key. Version 1.3.17 -------------- Loading Loading @@ -349,6 +357,20 @@ Released on November 30, 2024. [#193]: https://github.com/fedify-dev/fedify/issues/193 Version 1.2.22 -------------- Released on May 16, 2025. - Fixed a bug where inbox handler had thrown a `jsonld.SyntaxError` which caused a `500 Internal Server Error` when the received activity had an invalid JSON-LD syntax. Now it logs the error and responds with a `400 Bad Request` error instead. [[#232]] - The `exportJwk()` function now populates the `alg` property of a returned `JsonWebKey` object with `"Ed25519"` if the input key is an Ed25519 key. Version 1.2.21 -------------- Loading Loading @@ -737,6 +759,20 @@ Released on October 31, 2024. [#118]: https://github.com/fedify-dev/fedify/issues/118 Version 1.1.22 -------------- Released on May 16, 2025. - Fixed a bug where inbox handler had thrown a `jsonld.SyntaxError` which caused a `500 Internal Server Error` when the received activity had an invalid JSON-LD syntax. Now it logs the error and responds with a `400 Bad Request` error instead. [[#232]] - The `exportJwk()` function now populates the `alg` property of a returned `JsonWebKey` object with `"Ed25519"` if the input key is an Ed25519 key. Version 1.1.21 -------------- Loading Loading @@ -1166,6 +1202,22 @@ Released on October 20, 2024. [#150]: https://github.com/fedify-dev/fedify/issues/150 Version 1.0.25 -------------- Released on May 16, 2025. - Fixed a bug where inbox handler had thrown a `jsonld.SyntaxError` which caused a `500 Internal Server Error` when the received activity had an invalid JSON-LD syntax. Now it logs the error and responds with a `400 Bad Request` error instead. [[#232]] - The `exportJwk()` function now populates the `alg` property of a returned `JsonWebKey` object with `"Ed25519"` if the input key is an Ed25519 key. [#232]: https://github.com/fedify-dev/fedify/issues/232 Version 1.0.24 -------------- Loading
src/codegen/__snapshots__/class.test.ts.snap +132 −0 File changed.Preview size limit exceeded, changes collapsed. Show changes
src/codegen/inspector.ts +2 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ export async function* generateInspector( return proxy; } // @ts-ignore: suppressing TS4127 ${emitOverride(typeUri, types)} [Symbol.for("Deno.customInspect")]( inspect: typeof Deno.inspect, options: Deno.InspectOptions, Loading @@ -81,6 +82,7 @@ export async function* generateInspector( return ${JSON.stringify(type.name + " ")} + inspect(proxy, options); } // @ts-ignore: suppressing TS4127 ${emitOverride(typeUri, types)} [Symbol.for("nodejs.util.inspect.custom")]( _depth: number, options: unknown, Loading
src/federation/handler.test.ts +35 −0 Original line number Diff line number Diff line Loading @@ -1204,6 +1204,41 @@ test("handleInbox()", async () => { }); assertEquals(onNotFoundCalled, null); assertEquals(response.status, 202); const invalidRequest = new Request("https://example.com/", { method: "POST", body: JSON.stringify({ "@context": [ "https://www.w3.org/ns/activitystreams", true, 23, ], type: "Create", object: { type: "Note", content: "Hello, world!" }, actor: "https://example.com/users/alice", }), }); const signedInvalidRequest = await signRequest( invalidRequest, rsaPrivateKey3, rsaPublicKey3.id!, ); const signedInvalidContext = createRequestContext({ request: signedInvalidRequest, url: new URL(signedInvalidRequest.url), data: undefined, documentLoader: mockDocumentLoader, }); response = await handleInbox(signedInvalidRequest, { recipient: null, context: signedContext, inboxContextFactory(_activity) { return createInboxContext(signedInvalidContext); }, ...inboxOptions, }); assertEquals(onNotFoundCalled, null); assertEquals(response.status, 400); }); test("respondWithObject()", async () => { Loading
src/federation/handler.ts +18 −6 Original line number Diff line number Diff line Loading @@ -541,12 +541,24 @@ async function handleInboxInternal<TContextData>( }); } const keyCache = new KvKeyCache(kv, kvPrefixes.publicKey, ctx); const ldSigVerified = await verifyJsonLd(json, { let ldSigVerified: boolean; try { ldSigVerified = await verifyJsonLd(json, { contextLoader: ctx.contextLoader, documentLoader: ctx.documentLoader, keyCache, tracerProvider, }); } catch (error) { if (error instanceof Error && error.name === "jsonld.SyntaxError") { logger.error("Failed to parse JSON-LD:\n{error}", { recipient, error }); return new Response("Invalid JSON-LD.", { status: 400, headers: { "Content-Type": "text/plain; charset=utf-8" }, }); } ldSigVerified = false; } const jsonWithoutSig = detachSignature(json); let activity: Activity | null = null; if (ldSigVerified) { Loading