@fedify/fedify 0.12.0-dev.284 → 0.12.0-dev.286
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/CHANGES.md +10 -0
- package/README.md +1 -0
- package/esm/mod.js +1 -0
- package/esm/runtime/docloader.js +14 -1
- package/esm/x/astro.js +2 -0
- package/package.json +2 -1
- package/types/mod.d.ts +1 -0
- package/types/mod.d.ts.map +1 -1
- package/types/runtime/docloader.d.ts +9 -0
- package/types/runtime/docloader.d.ts.map +1 -1
- package/types/x/astro.d.ts +7 -0
- package/types/x/astro.d.ts.map +1 -1
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/README.md
CHANGED
@@ -30,6 +30,7 @@ Currently, Fedify provides the following features out of the box:
|
|
30
30
|
- [NodeInfo] protocol
|
31
31
|
- Special touch for interoperability with Mastodon and few other popular
|
32
32
|
fediverse software
|
33
|
+
- Integration with various web frameworks
|
33
34
|
- CLI toolchain for testing and debugging
|
34
35
|
|
35
36
|
If you want to know more about the project, please take a look at the following
|
package/esm/mod.js
CHANGED
@@ -19,6 +19,7 @@
|
|
19
19
|
* - [NodeInfo] protocol
|
20
20
|
* - Special touch for interoperability with Mastodon and few other popular
|
21
21
|
* fediverse software
|
22
|
+
* - Integration with various web frameworks
|
22
23
|
* - CLI toolchain for testing and debugging
|
23
24
|
*
|
24
25
|
* If you want to know more about the project, please take a look at the
|
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/esm/x/astro.js
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
* @example src/middleware.ts
|
6
6
|
* ``` typescript
|
7
7
|
* import { defineMiddleware } from "astro:middleware";
|
8
|
+
* import { createFetchOptions } from "@fedify/fedify/x/astro";
|
8
9
|
* import { federation } from "./federation"; // Import the `Federation` object
|
9
10
|
*
|
10
11
|
* export const onRequest = defineMiddleware((context, next) => {
|
@@ -56,6 +57,7 @@ export function createFetchOptions(_context, next) {
|
|
56
57
|
* @example src/middleware.ts
|
57
58
|
* ``` typescript
|
58
59
|
* import type { MiddlewareHandler } from "astro";
|
60
|
+
* import { createMiddleware } from "@fedify/fedify/x/astro";
|
59
61
|
* import { federation } from "./federation"; // Import the `Federation` object
|
60
62
|
*
|
61
63
|
* export const onRequest: MiddlewareHandler = createMiddleware(
|
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.286+6a3479e5",
|
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",
|
package/types/mod.d.ts
CHANGED
@@ -19,6 +19,7 @@
|
|
19
19
|
* - [NodeInfo] protocol
|
20
20
|
* - Special touch for interoperability with Mastodon and few other popular
|
21
21
|
* fediverse software
|
22
|
+
* - Integration with various web frameworks
|
22
23
|
* - CLI toolchain for testing and debugging
|
23
24
|
*
|
24
25
|
* If you want to know more about the project, please take a look at the
|
package/types/mod.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC"}
|
@@ -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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 -7,7 +7,12 @@
|
|
7
7
|
* This module contains some utilities for integrating Fedify with
|
8
8
|
* the [Astro] framework.
|
9
9
|
*
|
10
|
+
* > [!NOTE]
|
11
|
+
* >
|
12
|
+
* > Astro integration requires [on-demand server rendering][1].
|
13
|
+
*
|
10
14
|
* [Astro]: https://astro.build/
|
15
|
+
* [1]: https://docs.astro.build/en/guides/server-side-rendering/
|
11
16
|
*
|
12
17
|
* @module
|
13
18
|
* @since 0.12.0
|
@@ -26,6 +31,7 @@ type MiddlewareHandler<TAstroContext extends AstroContext> = (context: TAstroCon
|
|
26
31
|
* @example src/middleware.ts
|
27
32
|
* ``` typescript
|
28
33
|
* import { defineMiddleware } from "astro:middleware";
|
34
|
+
* import { createFetchOptions } from "@fedify/fedify/x/astro";
|
29
35
|
* import { federation } from "./federation"; // Import the `Federation` object
|
30
36
|
*
|
31
37
|
* export const onRequest = defineMiddleware((context, next) => {
|
@@ -61,6 +67,7 @@ export type ContextDataFactory<TContextData, TAstroContext extends AstroContext>
|
|
61
67
|
* @example src/middleware.ts
|
62
68
|
* ``` typescript
|
63
69
|
* import type { MiddlewareHandler } from "astro";
|
70
|
+
* import { createMiddleware } from "@fedify/fedify/x/astro";
|
64
71
|
* import { federation } from "./federation"; // Import the `Federation` object
|
65
72
|
*
|
66
73
|
* export const onRequest: MiddlewareHandler = createMiddleware(
|
package/types/x/astro.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"astro.d.ts","sourceRoot":"","sources":["../../src/x/astro.ts"],"names":[],"mappings":";;AAAA
|
1
|
+
{"version":3,"file":"astro.d.ts","sourceRoot":"","sources":["../../src/x/astro.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EACV,UAAU,EACV,sBAAsB,EACvB,MAAM,6BAA6B,CAAC;AAErC,UAAU,YAAY;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB;AACD,KAAK,cAAc,GAAG,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC;AAC7C,KAAK,cAAc,GAAG,CACpB,cAAc,CAAC,EAAE,cAAc,KAC5B,OAAO,CAAC,QAAQ,CAAC,CAAC;AACvB,KAAK,iBAAiB,CAAC,aAAa,SAAS,YAAY,IAAI,CAC3D,OAAO,EAAE,aAAa,EACtB,IAAI,EAAE,cAAc,KACjB,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,SAAS,YAAY,EACnE,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE,cAAc,GACnB,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,CA2BnD;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,kBAAkB,CAC5B,YAAY,EACZ,aAAa,SAAS,YAAY,IAChC,CACF,OAAO,EAAE,aAAa,KACnB,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,EACZ,aAAa,SAAS,YAAY,EAElC,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,EACpC,kBAAkB,EAAE,kBAAkB,CAAC,YAAY,EAAE,aAAa,CAAC,GAClE,iBAAiB,CAAC,aAAa,CAAC,CAQlC"}
|