@fedify/fedify 2.3.9-dev.2048 → 2.3.10
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/dist/{builder-BfY2wZ4V.mjs → builder-Bal9bfuM.mjs} +10 -2
- package/dist/{client-DYDoDpMa.mjs → client-Ccbsek6u.mjs} +7 -3
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/transformers.test.mjs +1 -1
- package/dist/{context-CAKnQy1x.d.ts → context-BWbdE_MZ.d.ts} +1 -1
- package/dist/{context-BepjCFHN.mjs → context-CxbCIptr.mjs} +2 -1
- package/dist/{context-CSIggG9_.d.cts → context-MOrCC7yl.d.cts} +1 -1
- package/dist/{deno-ayal9buz.mjs → deno-DUgFsCmM.mjs} +1 -1
- package/dist/docloader-w72ipM49.mjs +79 -0
- package/dist/federation/builder.test.mjs +38 -2
- package/dist/federation/circuit-breaker.test.mjs +1 -1
- package/dist/federation/collection.test.mjs +1 -1
- package/dist/federation/handler.test.mjs +7 -7
- package/dist/federation/idempotency.test.mjs +3 -3
- package/dist/federation/kv.test.mjs +1 -1
- package/dist/federation/metrics.test.mjs +2 -2
- package/dist/federation/middleware.test.mjs +302 -8
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.d.cts +3 -3
- package/dist/federation/mod.d.ts +3 -3
- package/dist/federation/mod.js +1 -1
- package/dist/federation/mq.test.mjs +98 -43
- package/dist/federation/negotiation.test.mjs +1 -1
- package/dist/federation/router.test.mjs +1 -1
- package/dist/federation/send.test.mjs +85 -4
- package/dist/federation/temporal.test.mjs +2 -2
- package/dist/federation/webfinger.test.mjs +3 -3
- package/dist/{http-B2u6PvNX.mjs → http-BNDHRNJP.mjs} +8 -4
- package/dist/{http-BPPCh0xN.js → http-BY8PpQzP.js} +6 -2
- package/dist/{http-BGP2QCbe.cjs → http-CTYio50W.cjs} +6 -2
- package/dist/{key-C9DkrWwb.mjs → key-BbuFo4CW.mjs} +2 -2
- package/dist/{kv-D6hNiMTK.d.ts → kv-CZKl1IUS.d.cts} +3 -2
- package/dist/{kv-gJ8LYbxX.d.cts → kv-CxaI4eGo.d.ts} +3 -2
- package/dist/{kv-cache-qJSjfLGm.mjs → kv-cache-CNZOaZYq.mjs} +1 -1
- package/dist/{kv-cache-C1TC_e9y.cjs → kv-cache-CrcqGkT-.cjs} +34 -8
- package/dist/{kv-cache-Cl1q1aA9.js → kv-cache-DNnjnc9t.js} +35 -9
- package/dist/{ld-DNl7KwLY.mjs → ld-BYV2Luge.mjs} +4 -4
- package/dist/{metrics-Ce55disp.mjs → metrics-QrVsKSG9.mjs} +1 -1
- package/dist/{middleware-C96wm_7x.mjs → middleware-54KSGAQA.mjs} +1 -1
- package/dist/{middleware-C_utyVa_.js → middleware-B4FNnN3W.js} +36 -11
- package/dist/{middleware-BCG2BX1n.mjs → middleware-Bj9s3J_0.mjs} +22 -19
- package/dist/{middleware-BZojifnF.cjs → middleware-Dv-L7Plm.cjs} +36 -11
- package/dist/{mod-PVR75MeU.d.cts → mod-B6PwkUMU.d.cts} +1 -1
- package/dist/{mod-DHgc4ygG.d.ts → mod-Br8yJNcE.d.ts} +3 -1
- package/dist/{mod-1TuoXkGs.d.cts → mod-Co1M3Ux0.d.cts} +3 -1
- package/dist/{mod-CFuyfw3c.d.ts → mod-LmD03uRA.d.ts} +1 -1
- package/dist/mod.cjs +5 -5
- package/dist/mod.d.cts +4 -4
- package/dist/mod.d.ts +4 -4
- package/dist/mod.js +5 -5
- package/dist/nodeinfo/client.test.mjs +50 -2
- package/dist/nodeinfo/handler.test.mjs +3 -3
- package/dist/nodeinfo/mod.cjs +1 -1
- package/dist/nodeinfo/mod.js +1 -1
- package/dist/nodeinfo/types.test.mjs +1 -1
- package/dist/otel/exporter.test.mjs +1 -1
- package/dist/otel/mod.d.cts +1 -1
- package/dist/otel/mod.d.ts +1 -1
- package/dist/{owner-DqqDBw-l.mjs → owner-BsBzJADO.mjs} +2 -2
- package/dist/{proof-Dz9ObvUq.js → proof-BxS2Xa8B.js} +2 -2
- package/dist/{proof-I6YcKRRq.cjs → proof-CGKQFT2M.cjs} +2 -2
- package/dist/{proof-D5vP7VIN.mjs → proof-cXVkPBIU.mjs} +3 -3
- package/dist/{send-CBtR8DQK.mjs → send-omt23uTA.mjs} +18 -4
- package/dist/sig/http.test.mjs +43 -3
- package/dist/sig/key.test.mjs +2 -2
- package/dist/sig/ld.test.mjs +5 -2
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +2 -2
- package/dist/sig/proof.test.mjs +2 -2
- package/dist/{std__assert-BBjXFNOb.mjs → std__assert-BvGuO4xO.mjs} +2 -27
- package/dist/{temporal-B9t2tY9A.mjs → temporal-ZUAQe754.mjs} +1 -1
- package/dist/testing/mod.mjs +1 -1
- package/dist/{types-DWs-qZaY.cjs → types-DRPjmHVV.cjs} +7 -3
- package/dist/{types-sXITXcWa.js → types-miAYfiGO.js} +7 -3
- package/dist/utils/docloader.test.mjs +299 -3
- package/dist/utils/kv-cache.test.mjs +1 -1
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.d.cts +1 -1
- package/dist/utils/mod.d.ts +1 -1
- package/dist/utils/mod.js +1 -1
- package/dist/vocab/cjs.test.mjs +1 -1
- package/package.json +7 -7
- package/dist/docloader-C-JrNL14.mjs +0 -53
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
4
|
+
import { n as version, t as name } from "./deno-DUgFsCmM.mjs";
|
|
5
5
|
import { t as ActivityListenerSet } from "./activity-listener-ell7W1s9.mjs";
|
|
6
6
|
import { getLogger } from "@logtape/logtape";
|
|
7
7
|
import { Router, RouterError, assertPath } from "@fedify/uri-template";
|
|
@@ -65,6 +65,7 @@ var FederationBuilderImpl = class {
|
|
|
65
65
|
* Symbol registry for unique identification of unnamed symbols.
|
|
66
66
|
*/
|
|
67
67
|
#symbolRegistry = /* @__PURE__ */ new Map();
|
|
68
|
+
#collectionNames = /* @__PURE__ */ new Map();
|
|
68
69
|
constructor() {
|
|
69
70
|
this.router = new Router();
|
|
70
71
|
this.objectCallbacks = {};
|
|
@@ -80,7 +81,7 @@ var FederationBuilderImpl = class {
|
|
|
80
81
|
* specified.
|
|
81
82
|
*/
|
|
82
83
|
async build(options) {
|
|
83
|
-
const { FederationImpl } = await import("./middleware-
|
|
84
|
+
const { FederationImpl } = await import("./middleware-54KSGAQA.mjs");
|
|
84
85
|
const f = new FederationImpl(options);
|
|
85
86
|
const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
|
|
86
87
|
f.router = this.router.clone();
|
|
@@ -93,6 +94,8 @@ var FederationBuilderImpl = class {
|
|
|
93
94
|
f.objectTypeIds = { ...this.objectTypeIds };
|
|
94
95
|
f.collectionCallbacks = { ...this.collectionCallbacks };
|
|
95
96
|
f.collectionTypeIds = { ...this.collectionTypeIds };
|
|
97
|
+
f.#symbolRegistry = new Map(this.#symbolRegistry);
|
|
98
|
+
f.#collectionNames = new Map(this.#collectionNames);
|
|
96
99
|
f.inboxPath = this.inboxPath;
|
|
97
100
|
f.outboxPath = this.outboxPath;
|
|
98
101
|
f.inboxCallbacks = this.inboxCallbacks == null ? void 0 : { ...this.inboxCallbacks };
|
|
@@ -572,6 +575,7 @@ var FederationBuilderImpl = class {
|
|
|
572
575
|
if (this.collectionCallbacks[name] != null) throw new RouterError(`Collection dispatcher for ${strName} already set.`);
|
|
573
576
|
assertPath(path);
|
|
574
577
|
if (Router.variables(path).size < 1) throw new RouterError("Path for collection dispatcher must have at least one variable.");
|
|
578
|
+
this.#collectionNames.set(routeName, name);
|
|
575
579
|
this.router.add(path, routeName);
|
|
576
580
|
const callbacks = { dispatcher };
|
|
577
581
|
this.collectionCallbacks[name] = callbacks;
|
|
@@ -609,6 +613,10 @@ var FederationBuilderImpl = class {
|
|
|
609
613
|
const routeName = this.#uniqueCollectionId(name);
|
|
610
614
|
return this.router.build(`collection:${routeName}`, values) ?? this.router.build(`orderedCollection:${routeName}`, values);
|
|
611
615
|
}
|
|
616
|
+
/** Resolves a custom collection route to its original name. */
|
|
617
|
+
getCollectionName(routeName) {
|
|
618
|
+
return this.#collectionNames.get(routeName) ?? routeName.replace(/^(collection|orderedCollection):/, "");
|
|
619
|
+
}
|
|
612
620
|
setOutboxPermanentFailureHandler(handler) {
|
|
613
621
|
this.outboxPermanentFailureHandler = handler;
|
|
614
622
|
}
|
|
@@ -93,8 +93,8 @@ const DEFAULT_MAX_REDIRECTION = 5;
|
|
|
93
93
|
* bounce the request to an internal address.
|
|
94
94
|
* @param url The URL to fetch.
|
|
95
95
|
* @param headers The request headers.
|
|
96
|
-
* @returns The final response, or `null` if the URL is disallowed
|
|
97
|
-
* are too many redirects.
|
|
96
|
+
* @returns The final response, or `null` if the URL is disallowed, its
|
|
97
|
+
* hostname cannot be resolved, or there are too many redirects.
|
|
98
98
|
*/
|
|
99
99
|
async function fetchPublicUrl(url, headers) {
|
|
100
100
|
let current = url instanceof URL ? url : new URL(url);
|
|
@@ -104,7 +104,11 @@ async function fetchPublicUrl(url, headers) {
|
|
|
104
104
|
await validatePublicUrl(current.href);
|
|
105
105
|
} catch (e) {
|
|
106
106
|
if (e instanceof UrlError) {
|
|
107
|
-
logger.error("
|
|
107
|
+
if (e.reason === "dns") logger.error("DNS lookup failed for {url}: {error}", {
|
|
108
|
+
url: current.href,
|
|
109
|
+
error: e
|
|
110
|
+
});
|
|
111
|
+
else logger.error("Refused to fetch a private or invalid URL {url}: {error}", {
|
|
108
112
|
url: current.href,
|
|
109
113
|
error: e
|
|
110
114
|
});
|
package/dist/compat/mod.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { jt as ActivityTransformer, n as Context } from "../context-
|
|
2
|
+
import { jt as ActivityTransformer, n as Context } from "../context-MOrCC7yl.cjs";
|
|
3
3
|
import { Activity } from "@fedify/vocab";
|
|
4
4
|
|
|
5
5
|
//#region src/compat/transformers.d.ts
|
package/dist/compat/mod.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { jt as ActivityTransformer, n as Context } from "../context-
|
|
2
|
+
import { jt as ActivityTransformer, n as Context } from "../context-BWbdE_MZ.js";
|
|
3
3
|
import { Activity } from "@fedify/vocab";
|
|
4
4
|
|
|
5
5
|
//#region src/compat/transformers.d.ts
|
|
@@ -4,7 +4,7 @@ globalThis.addEventListener = () => {};
|
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
5
5
|
import { n as assertInstanceOf, t as assert } from "../assert-jSdZMYam.mjs";
|
|
6
6
|
import { t as MemoryKvStore } from "../kv-CX8qfaad.mjs";
|
|
7
|
-
import { b as autoIdAssigner, n as FederationImpl, y as actorDehydrator } from "../middleware-
|
|
7
|
+
import { b as autoIdAssigner, n as FederationImpl, y as actorDehydrator } from "../middleware-Bj9s3J_0.mjs";
|
|
8
8
|
import { Follow, Person } from "@fedify/vocab";
|
|
9
9
|
import { test } from "@fedify/fixture";
|
|
10
10
|
//#region src/compat/transformers.test.ts
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { o as JsonValue, s as NodeInfo, t as GetNodeInfoOptions } from "./client-CSddvgWN.js";
|
|
3
3
|
import { o as VerifyRequestFailureReason, t as HttpMessageSignaturesSpec } from "./http-DQmNpfym.js";
|
|
4
4
|
import { n as GetKeyOwnerOptions } from "./owner-CiBPcC6F.js";
|
|
5
|
-
import { n as KvStore, t as KvKey } from "./kv-
|
|
5
|
+
import { n as KvStore, t as KvKey } from "./kv-CxaI4eGo.js";
|
|
6
6
|
import { r as MessageQueue } from "./mq-D-nlpY04.js";
|
|
7
7
|
import { Router } from "@fedify/uri-template";
|
|
8
8
|
import { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey, Object as Object$1, Recipient, Tombstone, TraverseCollectionOptions } from "@fedify/vocab";
|
|
@@ -10,6 +10,7 @@ import { lookupObject, traverseCollection } from "@fedify/vocab";
|
|
|
10
10
|
import { lookupWebFinger } from "@fedify/webfinger";
|
|
11
11
|
import { metrics, trace } from "@opentelemetry/api";
|
|
12
12
|
//#region ../fixture/dist/mod.js
|
|
13
|
+
const fixtureFetch = globalThis.fetch.bind(globalThis);
|
|
13
14
|
const logger = getLogger(["fixture", "docloader"]);
|
|
14
15
|
/**
|
|
15
16
|
* A mock of the document loader. This does not make any actual HTTP requests
|
|
@@ -24,7 +25,7 @@ async function mockDocumentLoader(resource, _options) {
|
|
|
24
25
|
if ("navigator" in globalThis && navigator.userAgent === "Cloudflare-Workers") {
|
|
25
26
|
const testUrl = new URL(url);
|
|
26
27
|
testUrl.hostname += ".test";
|
|
27
|
-
const resp = await
|
|
28
|
+
const resp = await fixtureFetch(testUrl);
|
|
28
29
|
if (resp.ok) {
|
|
29
30
|
const document = await resp.json();
|
|
30
31
|
logger.debug("Successfully fetched fixture {resource}: {status} {statusText}\n{body}", {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { o as JsonValue, s as NodeInfo, t as GetNodeInfoOptions } from "./client-CAM_bQXx.cjs";
|
|
3
3
|
import { o as VerifyRequestFailureReason, t as HttpMessageSignaturesSpec } from "./http-DiWQB8Mr.cjs";
|
|
4
4
|
import { n as GetKeyOwnerOptions } from "./owner-B3hNQCG8.cjs";
|
|
5
|
-
import { n as KvStore, t as KvKey } from "./kv-
|
|
5
|
+
import { n as KvStore, t as KvKey } from "./kv-CZKl1IUS.cjs";
|
|
6
6
|
import { r as MessageQueue } from "./mq-D8uSFzxe.cjs";
|
|
7
7
|
import { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey, Object as Object$1, Recipient, Tombstone, TraverseCollectionOptions } from "@fedify/vocab";
|
|
8
8
|
import { AuthenticatedDocumentLoaderFactory, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions } from "@fedify/vocab-runtime";
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { s as validateCryptoKey } from "./key-BbuFo4CW.mjs";
|
|
5
|
+
import { n as doubleKnock } from "./http-BNDHRNJP.mjs";
|
|
6
|
+
import { getLogger } from "@logtape/logtape";
|
|
7
|
+
import { FetchError, UrlError, createActivityPubRequest, getRemoteDocument, logRequest, validatePublicUrl } from "@fedify/vocab-runtime";
|
|
8
|
+
import { curry } from "es-toolkit";
|
|
9
|
+
//#region src/utils/docloader.ts
|
|
10
|
+
const logger = getLogger([
|
|
11
|
+
"fedify",
|
|
12
|
+
"utils",
|
|
13
|
+
"docloader"
|
|
14
|
+
]);
|
|
15
|
+
const DEFAULT_MAX_REDIRECTION = 20;
|
|
16
|
+
/**
|
|
17
|
+
* Gets an authenticated {@link DocumentLoader} for the given identity.
|
|
18
|
+
* Note that an authenticated document loader intentionally does not cache
|
|
19
|
+
* the fetched documents.
|
|
20
|
+
* At most 20 HTTP redirects and alternate document links are followed in total
|
|
21
|
+
* per call. Revisiting a URL within that chain throws a {@link FetchError}.
|
|
22
|
+
* @param identity The identity to get the document loader for.
|
|
23
|
+
* The actor's key pair.
|
|
24
|
+
* @param options The options for the document loader.
|
|
25
|
+
* @returns The authenticated document loader.
|
|
26
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
|
27
|
+
* @since 0.4.0
|
|
28
|
+
*/
|
|
29
|
+
function getAuthenticatedDocumentLoader(identity, { allowPrivateAddress, maxRedirection, userAgent, specDeterminer, tracerProvider } = {}) {
|
|
30
|
+
validateCryptoKey(identity.privateKey);
|
|
31
|
+
async function load(url, options, redirected = 0, visited = /* @__PURE__ */ new Set()) {
|
|
32
|
+
options?.signal?.throwIfAborted();
|
|
33
|
+
let currentUrl = new URL(url).href;
|
|
34
|
+
await validateUrl(currentUrl);
|
|
35
|
+
visited.add(currentUrl);
|
|
36
|
+
const originalRequest = createActivityPubRequest(currentUrl, { userAgent });
|
|
37
|
+
function follow(nextUrl) {
|
|
38
|
+
options?.signal?.throwIfAborted();
|
|
39
|
+
if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(currentUrl, `Too many redirections (${redirected + 1})`);
|
|
40
|
+
if (visited.has(nextUrl)) throw new FetchError(currentUrl, `Redirect loop detected: ${nextUrl}`);
|
|
41
|
+
redirected++;
|
|
42
|
+
}
|
|
43
|
+
const response = await doubleKnock(originalRequest, identity, {
|
|
44
|
+
maxRedirection,
|
|
45
|
+
specDeterminer,
|
|
46
|
+
log: curry(logRequest)(logger),
|
|
47
|
+
tracerProvider,
|
|
48
|
+
signal: options?.signal,
|
|
49
|
+
validateRedirect: async (nextUrl) => {
|
|
50
|
+
follow(nextUrl);
|
|
51
|
+
await validateUrl(nextUrl);
|
|
52
|
+
visited.add(nextUrl);
|
|
53
|
+
currentUrl = nextUrl;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return getRemoteDocument(currentUrl, response, (alternateUrl) => {
|
|
57
|
+
follow(alternateUrl);
|
|
58
|
+
return load(alternateUrl, options, redirected, visited);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
async function validateUrl(url) {
|
|
62
|
+
if (!allowPrivateAddress) try {
|
|
63
|
+
await validatePublicUrl(url);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
if (error instanceof UrlError) if (error.reason === "dns") logger.debug("DNS lookup failed for {url}", {
|
|
66
|
+
url,
|
|
67
|
+
error
|
|
68
|
+
});
|
|
69
|
+
else logger.error("Disallowed private URL: {url}", {
|
|
70
|
+
url,
|
|
71
|
+
error
|
|
72
|
+
});
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return (url, options) => load(url, options);
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
export { getAuthenticatedDocumentLoader as t };
|
|
@@ -2,10 +2,11 @@ import "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { n as assertExists } from "../std__assert-BvGuO4xO.mjs";
|
|
6
6
|
import { t as assertThrows } from "../assert_throws-BOkhLGYc.mjs";
|
|
7
|
+
import { t as assertStrictEquals } from "../assert_strict_equals-XEgZAlrj.mjs";
|
|
7
8
|
import { t as MemoryKvStore } from "../kv-CX8qfaad.mjs";
|
|
8
|
-
import { r as createFederationBuilder } from "../builder-
|
|
9
|
+
import { r as createFederationBuilder } from "../builder-Bal9bfuM.mjs";
|
|
9
10
|
import { DisallowedOperatorError, DisallowedVarSpecModifierError, DuplicateRouteVariableError, RouteTemplateOptionsNotMatchedError, RouterError } from "@fedify/uri-template";
|
|
10
11
|
import { Activity, Note, Person } from "@fedify/vocab";
|
|
11
12
|
import { test } from "@fedify/fixture";
|
|
@@ -344,6 +345,41 @@ test("FederationBuilder", async (t) => {
|
|
|
344
345
|
assertEquals(impl.collectionTypeIds["test"], Note);
|
|
345
346
|
assertEquals((await impl.fetch(new Request("https://example.com/c/x", { headers: { accept: "application/activity+json" } }), { contextData: void 0 })).status, 200);
|
|
346
347
|
});
|
|
348
|
+
await t.step("preserves symbol-named collections through build()", async () => {
|
|
349
|
+
const builder = createFederationBuilder();
|
|
350
|
+
const collection = Symbol("saved");
|
|
351
|
+
const ordered = Symbol("saved");
|
|
352
|
+
builder.setCollectionDispatcher(collection, Note, "/users/{identifier}/saved", () => ({ items: [] }));
|
|
353
|
+
builder.setOrderedCollectionDispatcher(ordered, Note, "/users/{identifier}/ordered-saved", () => ({ items: [] }));
|
|
354
|
+
for (let build = 0; build < 2; build++) {
|
|
355
|
+
const federation = await builder.build({ kv: new MemoryKvStore() });
|
|
356
|
+
const ctx = federation.createContext(new URL("https://example.com/"));
|
|
357
|
+
for (const [name, path, type] of [[
|
|
358
|
+
collection,
|
|
359
|
+
"/users/alice/saved",
|
|
360
|
+
"collection"
|
|
361
|
+
], [
|
|
362
|
+
ordered,
|
|
363
|
+
"/users/alice/ordered-saved",
|
|
364
|
+
"orderedCollection"
|
|
365
|
+
]]) {
|
|
366
|
+
const uri = ctx.getCollectionUri(name, { identifier: "alice" });
|
|
367
|
+
assertEquals(uri.pathname, path);
|
|
368
|
+
const parsed = ctx.parseUri(uri);
|
|
369
|
+
assertEquals(parsed?.type, type);
|
|
370
|
+
if (parsed?.type !== "collection" && parsed?.type !== "orderedCollection") throw new Error("Expected a custom collection URI");
|
|
371
|
+
assertStrictEquals(parsed.name, name);
|
|
372
|
+
assertStrictEquals(parsed.class, Note);
|
|
373
|
+
assertEquals(parsed.values, { identifier: "alice" });
|
|
374
|
+
for (const cursor of [null, "next"]) {
|
|
375
|
+
const pageUri = new URL(uri);
|
|
376
|
+
if (cursor != null) pageUri.searchParams.set("cursor", cursor);
|
|
377
|
+
assertEquals((await federation.fetch(new Request(pageUri, { headers: { accept: "application/activity+json" } }), { contextData: void 0 })).status, 200);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
assertThrows(() => federation.setCollectionDispatcher(collection, Note, "/users/{identifier}/duplicate", () => ({ items: [] })));
|
|
381
|
+
}
|
|
382
|
+
});
|
|
347
383
|
});
|
|
348
384
|
//#endregion
|
|
349
385
|
export {};
|
|
@@ -2,7 +2,7 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
5
|
-
import "../std__assert-
|
|
5
|
+
import "../std__assert-BvGuO4xO.mjs";
|
|
6
6
|
import { t as assertThrows } from "../assert_throws-BOkhLGYc.mjs";
|
|
7
7
|
import { t as MemoryKvStore } from "../kv-CX8qfaad.mjs";
|
|
8
8
|
import { n as normalizeCircuitBreakerOptions, r as parseCircuitBreakerKvState, t as CircuitBreaker } from "../circuit-breaker-CDABzqVf.mjs";
|
|
@@ -2,7 +2,7 @@ import "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
5
|
-
import "../std__assert-
|
|
5
|
+
import "../std__assert-BvGuO4xO.mjs";
|
|
6
6
|
import { n as digest, t as buildCollectionSynchronizationHeader } from "../collection-CA3V5zyK.mjs";
|
|
7
7
|
import { test } from "@fedify/fixture";
|
|
8
8
|
import { decodeHex } from "byte-encodings/hex";
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as createOutboxContext, r as createRequestContext, t as createInboxContext } from "../context-
|
|
4
|
+
import { n as createOutboxContext, r as createRequestContext, t as createInboxContext } from "../context-CxbCIptr.mjs";
|
|
5
5
|
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
6
|
-
import "../std__assert-
|
|
6
|
+
import "../std__assert-BvGuO4xO.mjs";
|
|
7
7
|
import { n as assertGreaterOrEqual, t as assertRejects } from "../assert_rejects-DN60FHPX.mjs";
|
|
8
8
|
import { n as assertInstanceOf, t as assert } from "../assert-jSdZMYam.mjs";
|
|
9
9
|
import { r as parseAcceptSignature } from "../accept-Dd__NiUL.mjs";
|
|
10
|
-
import { a as generateCryptoKeyPair } from "../key-
|
|
11
|
-
import { s as signRequest } from "../http-
|
|
10
|
+
import { a as generateCryptoKeyPair } from "../key-BbuFo4CW.mjs";
|
|
11
|
+
import { s as signRequest } from "../http-BNDHRNJP.mjs";
|
|
12
12
|
import { a as rsaPrivateKey3, c as rsaPublicKey3, s as rsaPublicKey2 } from "../keys-BAK-tUlf.mjs";
|
|
13
|
-
import { a as compactJsonLd, p as signJsonLd } from "../ld-
|
|
14
|
-
import { r as signObject } from "../proof-
|
|
13
|
+
import { a as compactJsonLd, p as signJsonLd } from "../ld-BYV2Luge.mjs";
|
|
14
|
+
import { r as signObject } from "../proof-cXVkPBIU.mjs";
|
|
15
15
|
import { t as MemoryKvStore } from "../kv-CX8qfaad.mjs";
|
|
16
|
-
import { c as handleActor, d as handleInbox, f as handleObject, h as respondWithObjectIfAcceptable, l as handleCollection, m as respondWithObject, o as createFederation, p as handleOutbox, u as handleCustomCollection } from "../middleware-
|
|
16
|
+
import { c as handleActor, d as handleInbox, f as handleObject, h as respondWithObjectIfAcceptable, l as handleCollection, m as respondWithObject, o as createFederation, p as handleOutbox, u as handleCustomCollection } from "../middleware-Bj9s3J_0.mjs";
|
|
17
17
|
import { t as ActivityListenerSet } from "../activity-listener-ell7W1s9.mjs";
|
|
18
18
|
import { Activity, Create, CryptographicKey, Multikey, Note, Person, Tombstone } from "@fedify/vocab";
|
|
19
19
|
import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
@@ -2,11 +2,11 @@ import "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
5
|
-
import "../std__assert-
|
|
5
|
+
import "../std__assert-BvGuO4xO.mjs";
|
|
6
6
|
import { n as ed25519PrivateKey, r as ed25519PublicKey, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
|
|
7
|
-
import { r as signObject } from "../proof-
|
|
7
|
+
import { r as signObject } from "../proof-cXVkPBIU.mjs";
|
|
8
8
|
import { t as MemoryKvStore } from "../kv-CX8qfaad.mjs";
|
|
9
|
-
import { o as createFederation } from "../middleware-
|
|
9
|
+
import { o as createFederation } from "../middleware-Bj9s3J_0.mjs";
|
|
10
10
|
import { Create, Follow, Person } from "@fedify/vocab";
|
|
11
11
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
12
12
|
//#region src/federation/idempotency.test.ts
|
|
@@ -2,7 +2,7 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
5
|
-
import "../std__assert-
|
|
5
|
+
import "../std__assert-BvGuO4xO.mjs";
|
|
6
6
|
import { t as MemoryKvStore } from "../kv-CX8qfaad.mjs";
|
|
7
7
|
import { test } from "@fedify/fixture";
|
|
8
8
|
//#region src/federation/kv.test.ts
|
|
@@ -2,9 +2,9 @@ import "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
5
|
-
import "../std__assert-
|
|
5
|
+
import "../std__assert-BvGuO4xO.mjs";
|
|
6
6
|
import { t as assertRejects } from "../assert_rejects-DN60FHPX.mjs";
|
|
7
|
-
import { _ as recordKeyLookup, a as instrumentDocumentLoader, b as recordWebFingerHandle, c as recordCircuitBreakerStateChange, d as recordCollectionRequest, f as recordCollectionTotalItems, g as recordInboxActivity, h as recordFanoutRecipients, i as getRemoteHost, l as recordCollectionDispatchDuration, m as recordDocumentFetch, p as recordDocumentCache, r as getFederationMetrics, t as classifyFetchError, u as recordCollectionPageItems, v as recordOutboxActivity, x as registerQueueDepthGauge, y as recordOutboxEnqueue } from "../metrics-
|
|
7
|
+
import { _ as recordKeyLookup, a as instrumentDocumentLoader, b as recordWebFingerHandle, c as recordCircuitBreakerStateChange, d as recordCollectionRequest, f as recordCollectionTotalItems, g as recordInboxActivity, h as recordFanoutRecipients, i as getRemoteHost, l as recordCollectionDispatchDuration, m as recordDocumentFetch, p as recordDocumentCache, r as getFederationMetrics, t as classifyFetchError, u as recordCollectionPageItems, v as recordOutboxActivity, x as registerQueueDepthGauge, y as recordOutboxEnqueue } from "../metrics-QrVsKSG9.mjs";
|
|
8
8
|
import { createTestMeterProvider, test } from "@fedify/fixture";
|
|
9
9
|
import { FetchError } from "@fedify/vocab-runtime";
|
|
10
10
|
import { DataPointType, MeterProvider, MetricReader } from "@opentelemetry/sdk-metrics";
|