Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ To be released.
[#1207]: https://github.com/fedify-dev/fedify/issues/1207
[#1208]: https://github.com/fedify-dev/fedify/pull/1208

### @fedify/vocab-runtime
Comment thread
coderabbitai[bot] marked this conversation as resolved.

- Added the [FEP-6757] context to the preloaded JSON-LD contexts. The default
document loader now resolves <https://w3id.org/fep/6757> locally, so
transient Codeberg Pages outages no longer prevent otherwise valid inbound
documents from being parsed or verified. [[#1211], [#1216]]

[FEP-6757]: https://w3id.org/fep/6757
[#1211]: https://github.com/fedify-dev/fedify/issues/1211
[#1216]: https://github.com/fedify-dev/fedify/pull/1216

### @fedify/vocab-tools

- Fixed generated constructors and `clone()` methods to copy property
Expand Down
11 changes: 11 additions & 0 deletions changes.d/vocab-runtime/fep-6757-context.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
links:
'#1211': https://github.com/fedify-dev/fedify/issues/1211
'#1216': https://github.com/fedify-dev/fedify/pull/1216
---
- Added the [FEP-6757] context to the preloaded JSON-LD contexts. The default
document loader now resolves <https://w3id.org/fep/6757> locally, so
transient Codeberg Pages outages no longer prevent otherwise valid inbound
documents from being parsed or verified. [[#1211], [#1216]]

[FEP-6757]: https://w3id.org/fep/6757
8 changes: 8 additions & 0 deletions packages/vocab-runtime/src/contexts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// cSpell: disable

import cidV1Context from "./contexts/cid-v1.json" with { type: "json" };
import fep6757 from "./contexts/fep-6757.json" with { type: "json" };
import fep7aa9 from "./contexts/fep-7aa9.json" with { type: "json" };
import fepEf61 from "./contexts/fep-ef61.json" with { type: "json" };
import joinLemmyContext from "./contexts/join-lemmy.json" with { type: "json" };
Expand Down Expand Up @@ -4345,6 +4346,13 @@ const preloadedContexts: Record<string, unknown> = {
// https://github.com/fedify-dev/fedify/issues/1078
"https://w3id.org/fep/7aa9": fep7aa9,

// The FEP-6757 context is hosted on Codeberg Pages, whose outages can
// prevent documents with license metadata from being parsed. Resolve it
// locally so parsing does not depend on the remote context server.
// See: https://w3id.org/fep/6757
// https://github.com/fedify-dev/fedify/issues/1211
"https://w3id.org/fep/6757": fep6757,

// Lemmy's context document is served as application/json without the JSON-LD
// context Link header. The default document loader treats that as a regular
// JSON response instead of a JSON-LD context, so every Lemmy activity that
Expand Down
12 changes: 12 additions & 0 deletions packages/vocab-runtime/src/contexts/fep-6757.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"@context": {
"license": {
"@id": "http://purl.org/dc/terms/license",
"@type": "@id"
},
"preferredLicense": {
"@id": "https://w3id.org/fep/6757#preferredLicense",
"@type": "@id"
}
}
}
42 changes: 42 additions & 0 deletions packages/vocab-runtime/src/docloader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { gzipSync } from "node:zlib";
import preloadedContexts from "./contexts.ts";
import cidV1Context from "./contexts/cid-v1.json" with { type: "json" };
import { getDocumentLoader, getRemoteDocument } from "./docloader.ts";
import jsonld from "./jsonld.ts";
import { FetchError } from "./request.ts";
import { UrlError } from "./url.ts";

Expand Down Expand Up @@ -367,6 +368,47 @@ test("getDocumentLoader()", async (t) => {
deepStrictEqual(fetchMock.callHistory.calls(url).length, 0);
});

// A Codeberg Pages outage must not prevent loading or expanding FEP-6757.
// See: https://github.com/fedify-dev/fedify/issues/1211
fetchMock.get("https://w3id.org/fep/6757", { status: 502 });
await t.test("preloaded FEP-6757 context", async () => {
const url = "https://w3id.org/fep/6757";
deepStrictEqual(await fetchDocumentLoader(url), {
contextUrl: null,
documentUrl: url,
document: {
"@context": {
license: {
"@id": "http://purl.org/dc/terms/license",
"@type": "@id",
},
preferredLicense: {
"@id": "https://w3id.org/fep/6757#preferredLicense",
"@type": "@id",
},
},
},
});
deepStrictEqual(
await jsonld.expand({
"@context": ["https://www.w3.org/ns/activitystreams", url],
type: "Person",
license: "https://creativecommons.org/licenses/by/4.0/",
preferredLicense: "https://creativecommons.org/licenses/by-nc/4.0/",
}, { documentLoader: fetchDocumentLoader }),
[{
"@type": ["https://www.w3.org/ns/activitystreams#Person"],
"http://purl.org/dc/terms/license": [{
"@id": "https://creativecommons.org/licenses/by/4.0/",
}],
"https://w3id.org/fep/6757#preferredLicense": [{
"@id": "https://creativecommons.org/licenses/by-nc/4.0/",
}],
}],
);
deepStrictEqual(fetchMock.callHistory.calls(url).length, 0);
});

await t.test("deny non-HTTP/HTTPS", async () => {
await rejects(
() => fetchDocumentLoader("ftp://localhost"),
Expand Down
1 change: 1 addition & 0 deletions packages/vocab-runtime/src/docloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ export interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
* - <https://w3id.org/security/multikey/v1>
* - <https://w3id.org/fep/ef61>
* - <https://w3id.org/fep/7aa9>
* - <https://w3id.org/fep/6757>
* - <https://purl.archive.org/socialweb/webfinger>
* - <http://schema.org/>
* @param options Options for the document loader.
Expand Down
Loading