@fedify/fedify 0.12.0-dev.285 → 0.12.0-dev.287
Sign up to get free protection for your applications and to get access to all the features.
package/CHANGES.md
CHANGED
@@ -71,6 +71,15 @@ To be released.
|
|
71
71
|
- The type of `ActorKeyPairsDispatcher<TContextData>`'s first parameter
|
72
72
|
became `Context` (was `TContextData`).
|
73
73
|
|
74
|
+
- The built-in document loaders now recognize JSON-LD context provided in
|
75
|
+
an HTTP `Link` header. [[#6]]
|
76
|
+
|
77
|
+
- The `fetchDocumentLoader()` function now recognizes the `Link` header
|
78
|
+
with the `http://www.w3.org/ns/json-ld#context` link relation.
|
79
|
+
- The `getAuthenticatedDocumentLoader()` function now returns a document
|
80
|
+
loader that recognizes the `Link` header with
|
81
|
+
the `http://www.w3.org/ns/json-ld#context` link relation.
|
82
|
+
|
74
83
|
- Deprecated `Federation.sendActivity()` method. Use `Context.sendActivity()`
|
75
84
|
method instead.
|
76
85
|
|
@@ -108,6 +117,7 @@ To be released.
|
|
108
117
|
|
109
118
|
- `["fedify", "federation", "queue"]`
|
110
119
|
|
120
|
+
[#6]: https://github.com/dahlia/fedify/issues/6
|
111
121
|
[#50]: https://github.com/dahlia/fedify/issues/50
|
112
122
|
[#53]: https://github.com/dahlia/fedify/issues/53
|
113
123
|
[#66]: https://github.com/dahlia/fedify/issues/66
|
package/esm/runtime/docloader.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
2
|
+
import { HTTPHeaderLink } from "@hugoalh/http-header-link";
|
2
3
|
import { getLogger } from "@logtape/logtape";
|
3
4
|
import { signRequest } from "../sig/http.js";
|
4
5
|
import { validateCryptoKey } from "../sig/key.js";
|
@@ -50,13 +51,25 @@ async function getRemoteDocument(url, response) {
|
|
50
51
|
});
|
51
52
|
throw new FetchError(documentUrl, `HTTP ${response.status}: ${documentUrl}`);
|
52
53
|
}
|
54
|
+
const linkHeader = response.headers.get("Link");
|
55
|
+
let contextUrl = null;
|
56
|
+
if (linkHeader != null) {
|
57
|
+
const link = new HTTPHeaderLink(linkHeader);
|
58
|
+
const entries = link.getByRel("http://www.w3.org/ns/json-ld#context");
|
59
|
+
for (const [uri, params] of entries) {
|
60
|
+
if ("type" in params && params.type === "application/ld+json") {
|
61
|
+
contextUrl = uri;
|
62
|
+
break;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
53
66
|
logger.debug("Fetched document: {status} {url} {headers}", {
|
54
67
|
status: response.status,
|
55
68
|
url: documentUrl,
|
56
69
|
headers: Object.fromEntries(response.headers.entries()),
|
57
70
|
});
|
58
71
|
return {
|
59
|
-
contextUrl
|
72
|
+
contextUrl,
|
60
73
|
document: await response.json(),
|
61
74
|
documentUrl,
|
62
75
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fedify/fedify",
|
3
|
-
"version": "0.12.0-dev.
|
3
|
+
"version": "0.12.0-dev.287+9c2fcffe",
|
4
4
|
"description": "An ActivityPub server framework",
|
5
5
|
"keywords": [
|
6
6
|
"ActivityPub",
|
@@ -82,6 +82,7 @@
|
|
82
82
|
"test": "node test_runner.js"
|
83
83
|
},
|
84
84
|
"dependencies": {
|
85
|
+
"@hugoalh/http-header-link": "^1.0.2",
|
85
86
|
"@logtape/logtape": "^0.4.0",
|
86
87
|
"@phensley/language-tag": "^1.8.1",
|
87
88
|
"asn1js": "^3.0.5",
|
@@ -6,8 +6,17 @@ import type { KvKey, KvStore } from "../federation/kv.js";
|
|
6
6
|
* a {@link DocumentLoader}.
|
7
7
|
*/
|
8
8
|
export interface RemoteDocument {
|
9
|
+
/**
|
10
|
+
* The URL of the context document.
|
11
|
+
*/
|
9
12
|
contextUrl: string | null;
|
13
|
+
/**
|
14
|
+
* The fetched JSON-LD document.
|
15
|
+
*/
|
10
16
|
document: unknown;
|
17
|
+
/**
|
18
|
+
* The URL of the fetched document.
|
19
|
+
*/
|
11
20
|
documentUrl: string;
|
12
21
|
}
|
13
22
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"docloader.d.ts","sourceRoot":"","sources":["../../src/runtime/docloader.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;
|
1
|
+
{"version":3,"file":"docloader.d.ts","sourceRoot":"","sources":["../../src/runtime/docloader.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAG5C,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAQ1D;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1B;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;AAEtE;;;;;;;;GAQG;AACH,MAAM,MAAM,kCAAkC,GAAG,CAC/C,QAAQ,EAAE;IAAE,KAAK,EAAE,GAAG,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC,SAAS,CAAA;CAAE,KACpD,cAAc,CAAC;AAEpB;;GAEG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC;;OAEG;IACH,GAAG,EAAE,GAAG,CAAC;IAET;;;;;OAKG;gBACS,GAAG,EAAE,GAAG,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAKhD;AAoED;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,cAAc,CAAC,CA0BzB;AAED;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE;IAAE,KAAK,EAAE,GAAG,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC,SAAS,CAAA;CAAE,GACtD,cAAc,CAuBhB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