@fedify/fedify 2.0.0-pr.412.1559 → 2.0.0-pr.412.1794
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/README.md +3 -0
- package/dist/{actor-Cc6B76eG.js → actor-BXHc5r-q.js} +1 -1
- package/dist/actor-Ba9Z1eNJ.cjs +42079 -0
- package/dist/{actor-C22bXuuC.d.ts → actor-DqFajh9s.d.ts} +2 -2
- package/dist/{actor-CTAuCsWy.js → actor-DzhunPC_.js} +7058 -2722
- package/dist/actor-f2NtjyCg.d.cts +128 -0
- package/dist/{assert_rejects-DiIiJbZn.js → assert_rejects-Ce45JcFg.js} +1 -1
- package/dist/{assert_is_error-BPGph1Jx.js → assert_throws-BNXdRGWP.js} +31 -1
- package/dist/{builder-BOEBObR8.js → builder-u7usRsT3.js} +13 -8
- package/dist/chunk-DqRYRqnO.cjs +34 -0
- package/dist/client-94iWEfQa.d.cts +222 -0
- package/dist/{client-DF8anIB5.d.ts → client-BsGzbnV-.d.ts} +3 -75
- package/dist/{client-De-z2UnN.js → client-pY7-3icS.js} +3 -22
- package/dist/compat/mod.cjs +10 -0
- package/dist/compat/mod.d.cts +12 -0
- package/dist/compat/mod.d.ts +11 -12
- package/dist/compat/mod.js +5 -5
- package/dist/compat/transformers.test.js +20 -20
- package/dist/compat-DmDDELst.cjs +4 -0
- package/dist/compat-nxUqe4Z-.js +4 -0
- package/dist/{context-9gCpIkiz.d.ts → context-DG0huGW-.d.ts} +184 -127
- package/dist/context-DJ8aSy2Q.d.cts +2312 -0
- package/dist/{authdocloader-CLgDGafZ.js → docloader-CrbAy9Oc.js} +17 -8
- package/dist/{esm-CHdxdkuH.js → esm-C-Qa1zEM.js} +11 -11
- package/dist/federation/builder.test.js +9 -12
- package/dist/federation/collection.test.js +7 -9
- package/dist/federation/handler.test.js +27 -148
- package/dist/federation/idempotency.test.js +201 -0
- package/dist/federation/inbox.test.js +4 -6
- package/dist/federation/keycache.test.js +3 -4
- package/dist/federation/kv.test.js +7 -8
- package/dist/federation/middleware.test.js +242 -64
- package/dist/federation/mod.cjs +27 -0
- package/dist/federation/mod.d.cts +12 -0
- package/dist/federation/mod.d.ts +12 -13
- package/dist/federation/mod.js +13 -15
- package/dist/federation/mq.test.js +8 -10
- package/dist/federation/negotiation.test.js +26 -0
- package/dist/federation/retry.test.js +4 -5
- package/dist/federation/router.test.js +6 -8
- package/dist/federation/send.test.js +13 -15
- package/dist/federation-CRpdnOMS.cjs +244 -0
- package/dist/{federation-CMX7WzeL.js → federation-jcR8-ZxP.js} +3 -3
- package/dist/fixtures/media.example.com/avatars/test-avatar.jpg.json +6 -0
- package/dist/{http-DqSNLFNY.d.ts → http-BbO0ejuk.d.ts} +2 -2
- package/dist/{http-l0TEupZK.js → http-CUVx-vzb.js} +260 -10
- package/dist/{http-CcdM1brU.js → http-D2kIm9la.js} +3 -3
- package/dist/http-Dofes42e.cjs +1106 -0
- package/dist/http-M8k5mKc0.d.cts +253 -0
- package/dist/{inbox-B6DZbGNf.js → inbox-HjG5peXY.js} +24 -7
- package/dist/{key-CzLv1phF.js → key-CxdLUFS6.js} +3 -2
- package/dist/{keycache-B8HdZJSt.js → keycache-bU7COwsh.js} +1 -1
- package/dist/{keys-zZwiKkfx.js → keys-DMHs8XNn.js} +2 -1
- package/dist/kv-Bxr0Q87_.d.cts +81 -0
- package/dist/kv-cache-CGXcDejL.js +122 -0
- package/dist/kv-cache-DN9pfMBe.js +94 -0
- package/dist/kv-cache-Dkvbn6rg.cjs +134 -0
- package/dist/{ld-CBcQdZ6N.js → ld-CIhvSCCr.js} +5 -4
- package/dist/lookup-CHkCVZTU.js +260 -0
- package/dist/lookup-CfFkONZD.cjs +272 -0
- package/dist/{type-SK-d7Tbw.js → lookup-DQRtjvb1.js} +7266 -7087
- package/dist/middleware-Bot7EEwV.js +26 -0
- package/dist/middleware-CFJgmUMW.cjs +15 -0
- package/dist/{middleware-BRgu1IH8.js → middleware-CJlj5Olw.js} +86 -181
- package/dist/middleware-CjHl2NHA.js +15 -0
- package/dist/middleware-D74TgW2E.cjs +4225 -0
- package/dist/{middleware-CxEkcFW0.js → middleware-DMk2Mdn9.js} +117 -127
- package/dist/mod-0noXw66R.d.cts +107 -0
- package/dist/mod-B-hUPT2N.d.cts +1 -0
- package/dist/{mod-Drmz72EK.d.ts → mod-B2iOw50L.d.ts} +3 -3
- package/dist/mod-B9M-8jm2.d.ts +109 -0
- package/dist/{mod-Cxt4Kpf6.d.ts → mod-BlVovdcy.d.ts} +20 -2
- package/dist/{mod-Bqxcp7eN.d.ts → mod-BoHnwOCs.d.ts} +2 -2
- package/dist/mod-BxRCHTz-.d.cts +307 -0
- package/dist/mod-C2tOeRkN.d.cts +1 -0
- package/dist/mod-C58MZ7Wx.d.cts +113 -0
- package/dist/mod-DJcZDvjA.d.cts +80 -0
- package/dist/mod-DgdBYYa0.d.cts +266 -0
- package/dist/{mod-DBzN0aCM.d.ts → mod-Ds0mpFZU.d.ts} +1 -1
- package/dist/mod.cjs +137 -0
- package/dist/mod.d.cts +16 -0
- package/dist/mod.d.ts +16 -17
- package/dist/mod.js +19 -21
- package/dist/mq-DcJPkXD5.d.cts +140 -0
- package/dist/negotiation-C4nFufNk.js +71 -0
- package/dist/nodeinfo/client.test.js +30 -111
- package/dist/nodeinfo/handler.test.js +25 -26
- package/dist/nodeinfo/mod.cjs +10 -0
- package/dist/nodeinfo/mod.d.cts +3 -0
- package/dist/nodeinfo/mod.d.ts +3 -5
- package/dist/nodeinfo/mod.js +6 -7
- package/dist/nodeinfo/types.test.js +8 -15
- package/dist/nodeinfo-BnthBobC.js +4 -0
- package/dist/nodeinfo-CdN0rEnZ.cjs +4 -0
- package/dist/owner-B4HbyP8s.d.cts +67 -0
- package/dist/{owner-VEIjmR8r.js → owner-Dvh7mBvr.js} +3 -2
- package/dist/{owner-CQPnQVtf.d.ts → owner-kQRGVXG1.d.ts} +3 -3
- package/dist/proof-D0uThUvD.cjs +674 -0
- package/dist/{proof-DoSQAGkE.js → proof-Dgy35fzc.js} +3 -3
- package/dist/{proof-tgUlT8hw.js → proof-fqzaMJ4g.js} +11 -10
- package/dist/{send-BzS7w-QF.js → send-Drp20VO9.js} +2 -2
- package/dist/sig/http.test.js +13 -14
- package/dist/sig/key.test.js +9 -11
- package/dist/sig/ld.test.js +8 -10
- package/dist/sig/mod.cjs +28 -0
- package/dist/sig/mod.d.cts +6 -0
- package/dist/sig/mod.d.ts +5 -7
- package/dist/sig/mod.js +8 -10
- package/dist/sig/owner.test.js +10 -12
- package/dist/sig/proof.test.js +13 -14
- package/dist/sig-C34-oHBl.js +4 -0
- package/dist/sig-YYj5tCnr.cjs +4 -0
- package/dist/testing/docloader.test.js +6 -8
- package/dist/testing/mod.d.ts +387 -224
- package/dist/testing/mod.js +2 -3
- package/dist/{testing-Z2omCvKy.js → testing-g4UC4liW.js} +1 -2
- package/dist/{transformers-Dna8Fg7k.js → transformers-BFT6d7J5.js} +3 -3
- package/dist/transformers-CoBS-oFG.cjs +116 -0
- package/dist/{types-DgPvoUWN.js → types-BtUjyi5y.js} +8 -169
- package/dist/{types-BIgY6c-l.js → types-C2XVl6gj.js} +1 -3
- package/dist/types-CWgzGaqk.cjs +315 -0
- package/dist/{runtime/authdocloader.test.js → utils/docloader.test.js} +14 -15
- package/dist/utils/kv-cache.test.js +209 -0
- package/dist/utils/mod.cjs +12 -0
- package/dist/utils/mod.d.cts +5 -0
- package/dist/utils/mod.d.ts +7 -0
- package/dist/utils/mod.js +11 -0
- package/dist/utils-D-Va7aXC.js +4 -0
- package/dist/utils-DyRU1gdZ.cjs +4 -0
- package/dist/vocab/actor.test.js +8 -10
- package/dist/vocab/lookup.test.js +257 -9
- package/dist/vocab/mod.cjs +86 -0
- package/dist/vocab/mod.d.cts +4 -0
- package/dist/vocab/mod.d.ts +3 -5
- package/dist/vocab/mod.js +6 -7
- package/dist/vocab/type.test.js +2 -3
- package/dist/vocab/vocab.test.js +438 -15
- package/dist/{vocab-SOE1ifCr.d.ts → vocab-BCWe1Ih5.d.ts} +292 -21
- package/dist/{vocab-CvD6Vbml.js → vocab-BnR3nIU9.js} +26 -17
- package/dist/vocab-CeDBzu-f.d.cts +14903 -0
- package/dist/{lookup-Bn_HEC_d.js → vocab-DFaWWYDn.cjs} +108 -139
- package/dist/webfinger/handler.test.js +24 -25
- package/dist/webfinger/lookup.test.js +7 -9
- package/dist/webfinger/mod.cjs +8 -0
- package/dist/webfinger/mod.d.cts +2 -0
- package/dist/webfinger/mod.d.ts +1 -3
- package/dist/webfinger/mod.js +5 -6
- package/dist/webfinger-C72Y8lrh.js +4 -0
- package/dist/webfinger-vAtLmxOF.cjs +4 -0
- package/dist/x/cfworkers.cjs +100 -0
- package/dist/x/cfworkers.d.cts +59 -0
- package/dist/x/cfworkers.d.ts +2 -2
- package/dist/x/cfworkers.js +3 -3
- package/dist/x/cfworkers.test.js +6 -8
- package/dist/x/hono.cjs +61 -0
- package/dist/x/hono.d.cts +53 -0
- package/dist/x/hono.d.ts +10 -11
- package/dist/x/hono.js +3 -3
- package/dist/x/sveltekit.cjs +69 -0
- package/dist/x/sveltekit.d.cts +45 -0
- package/dist/x/sveltekit.d.ts +10 -11
- package/dist/x/sveltekit.js +3 -3
- package/package.json +79 -23
- package/dist/assert_throws-BOO88avQ.js +0 -39
- package/dist/authdocloader-BFVqUbyo.js +0 -52
- package/dist/compat-Bb5myD13.js +0 -4
- package/dist/docloader-CxWcuWqQ.d.ts +0 -221
- package/dist/docloader-DEhniCVa.js +0 -4615
- package/dist/key-CUZQgVlf.js +0 -10
- package/dist/key-Deb0_wWL.js +0 -10
- package/dist/key-DxA6xRtZ.js +0 -260
- package/dist/lookup-dtdr2ftf.js +0 -131
- package/dist/middleware-BE_geSiJ.js +0 -17
- package/dist/middleware-BnU6hzVp.js +0 -26
- package/dist/mod-TFoH2Ql8.d.ts +0 -104
- package/dist/nodeinfo/semver.test.js +0 -143
- package/dist/nodeinfo-CyEbLjHs.js +0 -4
- package/dist/runtime/docloader.test.js +0 -522
- package/dist/runtime/key.test.js +0 -103
- package/dist/runtime/langstr.test.d.ts +0 -3
- package/dist/runtime/langstr.test.js +0 -39
- package/dist/runtime/mod.d.ts +0 -8
- package/dist/runtime/mod.js +0 -13
- package/dist/runtime/multibase/multibase.test.d.ts +0 -3
- package/dist/runtime/multibase/multibase.test.js +0 -358
- package/dist/runtime/url.test.d.ts +0 -3
- package/dist/runtime/url.test.js +0 -45
- package/dist/runtime-BSkOVUWM.js +0 -4
- package/dist/semver-dArNLkR9.js +0 -149
- package/dist/sig-BXJO--F9.js +0 -4
- package/dist/webfinger-C3GIyXIg.js +0 -4
- /package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals-C80BG-_5.js} +0 -0
- /package/dist/{collection-CSzG2j1P.js → collection-BzWsN9pB.js} +0 -0
- /package/dist/{denokv-Bv33Xxea.js → denokv-CCssOzMJ.js} +0 -0
- /package/dist/{nodeinfo/semver.test.d.ts → federation/idempotency.test.d.ts} +0 -0
- /package/dist/{runtime/authdocloader.test.d.ts → federation/negotiation.test.d.ts} +0 -0
- /package/dist/{kv-C7sopW2E.d.ts → kv-BKNZ-Tb-.d.ts} +0 -0
- /package/dist/{mod-1pDWKvUL.d.ts → mod-CVgZgliM.d.ts} +0 -0
- /package/dist/{mod-g0xFzAP9.d.ts → mod-xIj-IT58.d.ts} +0 -0
- /package/dist/{mq-CRGm1e_F.d.ts → mq-CUKlBw08.d.ts} +0 -0
- /package/dist/{retry-D4GJ670a.js → retry-CfF8Gn4d.js} +0 -0
- /package/dist/{std__assert-X-_kMxKM.js → std__assert-DWivtrGR.js} +0 -0
- /package/dist/{runtime → utils}/docloader.test.d.ts +0 -0
- /package/dist/{runtime/key.test.d.ts → utils/kv-cache.test.d.ts} +0 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
globalThis.addEventListener = () => {};
|
5
|
+
|
6
|
+
import "./lookup-DQRtjvb1.js";
|
7
|
+
import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "./middleware-CJlj5Olw.js";
|
8
|
+
import "./client-pY7-3icS.js";
|
9
|
+
import "./types-C2XVl6gj.js";
|
10
|
+
import "./actor-BXHc5r-q.js";
|
11
|
+
import "./key-CxdLUFS6.js";
|
12
|
+
import "./http-D2kIm9la.js";
|
13
|
+
import "./ld-CIhvSCCr.js";
|
14
|
+
import "./owner-Dvh7mBvr.js";
|
15
|
+
import "./proof-Dgy35fzc.js";
|
16
|
+
import "./docloader-CrbAy9Oc.js";
|
17
|
+
import "./kv-cache-DN9pfMBe.js";
|
18
|
+
import "./inbox-HjG5peXY.js";
|
19
|
+
import "./builder-u7usRsT3.js";
|
20
|
+
import "./collection-BzWsN9pB.js";
|
21
|
+
import "./keycache-bU7COwsh.js";
|
22
|
+
import "./negotiation-C4nFufNk.js";
|
23
|
+
import "./retry-CfF8Gn4d.js";
|
24
|
+
import "./send-Drp20VO9.js";
|
25
|
+
|
26
|
+
export { FederationImpl };
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
3
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
4
|
+
|
5
|
+
require('./transformers-CoBS-oFG.cjs');
|
6
|
+
require('./lookup-CfFkONZD.cjs');
|
7
|
+
require('./actor-Ba9Z1eNJ.cjs');
|
8
|
+
const require_middleware = require('./middleware-D74TgW2E.cjs');
|
9
|
+
require('./http-Dofes42e.cjs');
|
10
|
+
require('./proof-D0uThUvD.cjs');
|
11
|
+
require('./types-CWgzGaqk.cjs');
|
12
|
+
require('./kv-cache-Dkvbn6rg.cjs');
|
13
|
+
require('./vocab-DFaWWYDn.cjs');
|
14
|
+
|
15
|
+
exports.FederationImpl = require_middleware.FederationImpl;
|
@@ -3,22 +3,24 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage,
|
7
|
-
import { getNodeInfo } from "./client-
|
8
|
-
import {
|
9
|
-
import {
|
10
|
-
import {
|
11
|
-
import {
|
12
|
-
import {
|
13
|
-
import {
|
14
|
-
import {
|
15
|
-
import {
|
16
|
-
import { routeActivity } from "./inbox-
|
17
|
-
import { FederationBuilderImpl } from "./builder-
|
18
|
-
import { buildCollectionSynchronizationHeader } from "./collection-
|
19
|
-
import { KvKeyCache } from "./keycache-
|
20
|
-
import {
|
21
|
-
import {
|
6
|
+
import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, RouterError, deno_default, getTypeId, lookupObject, lookupWebFinger, traverseCollection } from "./lookup-DQRtjvb1.js";
|
7
|
+
import { getNodeInfo } from "./client-pY7-3icS.js";
|
8
|
+
import { nodeInfoToJson } from "./types-C2XVl6gj.js";
|
9
|
+
import { exportJwk, importJwk, validateCryptoKey } from "./key-CxdLUFS6.js";
|
10
|
+
import { verifyRequest } from "./http-D2kIm9la.js";
|
11
|
+
import { detachSignature, hasSignature, signJsonLd, verifyJsonLd } from "./ld-CIhvSCCr.js";
|
12
|
+
import { doesActorOwnKey, getKeyOwner } from "./owner-Dvh7mBvr.js";
|
13
|
+
import { signObject, verifyObject } from "./proof-Dgy35fzc.js";
|
14
|
+
import { getAuthenticatedDocumentLoader } from "./docloader-CrbAy9Oc.js";
|
15
|
+
import { kvCache } from "./kv-cache-DN9pfMBe.js";
|
16
|
+
import { routeActivity } from "./inbox-HjG5peXY.js";
|
17
|
+
import { FederationBuilderImpl } from "./builder-u7usRsT3.js";
|
18
|
+
import { buildCollectionSynchronizationHeader } from "./collection-BzWsN9pB.js";
|
19
|
+
import { KvKeyCache } from "./keycache-bU7COwsh.js";
|
20
|
+
import { acceptsJsonLd } from "./negotiation-C4nFufNk.js";
|
21
|
+
import { createExponentialBackoffPolicy } from "./retry-CfF8Gn4d.js";
|
22
|
+
import { extractInboxes, sendActivity } from "./send-Drp20VO9.js";
|
23
|
+
import { getDocumentLoader } from "@fedify/vocab-runtime";
|
22
24
|
import { getLogger, withContext } from "@logtape/logtape";
|
23
25
|
import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
|
24
26
|
import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_RESPONSE_HEADER, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_URL_FULL } from "@opentelemetry/semantic-conventions";
|
@@ -297,73 +299,8 @@ async function handleWebFingerInternal(request, { context: context$1, host, acto
|
|
297
299
|
} });
|
298
300
|
}
|
299
301
|
|
300
|
-
//#endregion
|
301
|
-
//#region src/federation/negotiation.ts
|
302
|
-
function compareSpecs(a, b) {
|
303
|
-
return b.q - a.q || (b.s ?? 0) - (a.s ?? 0) || (a.o ?? 0) - (b.o ?? 0) || a.i - b.i || 0;
|
304
|
-
}
|
305
|
-
function isQuality(spec) {
|
306
|
-
return spec.q > 0;
|
307
|
-
}
|
308
|
-
const simpleMediaTypeRegExp = /^\s*([^\s\/;]+)\/([^;\s]+)\s*(?:;(.*))?$/;
|
309
|
-
function splitKeyValuePair(str) {
|
310
|
-
const [key, value] = str.split("=");
|
311
|
-
return [key.toLowerCase(), value];
|
312
|
-
}
|
313
|
-
function parseMediaType(str, i) {
|
314
|
-
const match = simpleMediaTypeRegExp.exec(str);
|
315
|
-
if (!match) return;
|
316
|
-
const [, type, subtype, parameters] = match;
|
317
|
-
if (!type || !subtype) return;
|
318
|
-
const params = Object.create(null);
|
319
|
-
let q = 1;
|
320
|
-
if (parameters) {
|
321
|
-
const kvps = parameters.split(";").map((p) => p.trim()).map(splitKeyValuePair);
|
322
|
-
for (const [key, val] of kvps) {
|
323
|
-
const value = val && val[0] === `"` && val[val.length - 1] === `"` ? val.slice(1, val.length - 1) : val;
|
324
|
-
if (key === "q" && value) {
|
325
|
-
q = parseFloat(value);
|
326
|
-
break;
|
327
|
-
}
|
328
|
-
params[key] = value;
|
329
|
-
}
|
330
|
-
}
|
331
|
-
return {
|
332
|
-
type,
|
333
|
-
subtype,
|
334
|
-
params,
|
335
|
-
i,
|
336
|
-
o: void 0,
|
337
|
-
q,
|
338
|
-
s: void 0
|
339
|
-
};
|
340
|
-
}
|
341
|
-
function parseAccept(accept) {
|
342
|
-
const accepts = accept.split(",").map((p) => p.trim());
|
343
|
-
const mediaTypes = [];
|
344
|
-
for (const [index, accept$1] of accepts.entries()) {
|
345
|
-
const mediaType = parseMediaType(accept$1.trim(), index);
|
346
|
-
if (mediaType) mediaTypes.push(mediaType);
|
347
|
-
}
|
348
|
-
return mediaTypes;
|
349
|
-
}
|
350
|
-
function getFullType(spec) {
|
351
|
-
return `${spec.type}/${spec.subtype}`;
|
352
|
-
}
|
353
|
-
function preferredMediaTypes(accept) {
|
354
|
-
const accepts = parseAccept(accept === void 0 ? "*/*" : accept ?? "");
|
355
|
-
return accepts.filter(isQuality).sort(compareSpecs).map(getFullType);
|
356
|
-
}
|
357
|
-
|
358
302
|
//#endregion
|
359
303
|
//#region src/federation/handler.ts
|
360
|
-
function acceptsJsonLd(request) {
|
361
|
-
const accept = request.headers.get("Accept");
|
362
|
-
const types = accept ? preferredMediaTypes(accept) : ["*/*"];
|
363
|
-
if (types == null) return true;
|
364
|
-
if (types[0] === "text/html" || types[0] === "application/xhtml+xml") return false;
|
365
|
-
return types.includes("application/activity+json") || types.includes("application/ld+json") || types.includes("application/json");
|
366
|
-
}
|
367
304
|
/**
|
368
305
|
* Handles an actor request.
|
369
306
|
* @template TContextData The context data to pass to the context.
|
@@ -371,7 +308,7 @@ function acceptsJsonLd(request) {
|
|
371
308
|
* @param parameters The parameters for handling the actor.
|
372
309
|
* @returns A promise that resolves to an HTTP response.
|
373
310
|
*/
|
374
|
-
async function handleActor(request, { identifier, context: context$1, actorDispatcher, authorizePredicate, onNotFound,
|
311
|
+
async function handleActor(request, { identifier, context: context$1, actorDispatcher, authorizePredicate, onNotFound, onUnauthorized }) {
|
375
312
|
const logger$2 = getLogger([
|
376
313
|
"fedify",
|
377
314
|
"federation",
|
@@ -386,7 +323,6 @@ async function handleActor(request, { identifier, context: context$1, actorDispa
|
|
386
323
|
logger$2.debug("Actor {identifier} not found.", { identifier });
|
387
324
|
return await onNotFound(request);
|
388
325
|
}
|
389
|
-
if (!acceptsJsonLd(request)) return await onNotAcceptable(request);
|
390
326
|
if (authorizePredicate != null) {
|
391
327
|
let key = await context$1.getSignedKey();
|
392
328
|
key = key?.clone({}, { $warning: {
|
@@ -421,11 +357,10 @@ async function handleActor(request, { identifier, context: context$1, actorDispa
|
|
421
357
|
* @param parameters The parameters for handling the object.
|
422
358
|
* @returns A promise that resolves to an HTTP response.
|
423
359
|
*/
|
424
|
-
async function handleObject(request, { values, context: context$1, objectDispatcher, authorizePredicate, onNotFound,
|
360
|
+
async function handleObject(request, { values, context: context$1, objectDispatcher, authorizePredicate, onNotFound, onUnauthorized }) {
|
425
361
|
if (objectDispatcher == null) return await onNotFound(request);
|
426
362
|
const object = await objectDispatcher(context$1, values);
|
427
363
|
if (object == null) return await onNotFound(request);
|
428
|
-
if (!acceptsJsonLd(request)) return await onNotAcceptable(request);
|
429
364
|
if (authorizePredicate != null) {
|
430
365
|
let key = await context$1.getSignedKey();
|
431
366
|
key = key?.clone({}, { $warning: {
|
@@ -463,7 +398,7 @@ async function handleObject(request, { values, context: context$1, objectDispatc
|
|
463
398
|
* @param parameters The parameters for handling the collection.
|
464
399
|
* @returns A promise that resolves to an HTTP response.
|
465
400
|
*/
|
466
|
-
async function handleCollection(request, { name, identifier, uriGetter, filter, filterPredicate, context: context$1, collectionCallbacks, tracerProvider, onUnauthorized, onNotFound
|
401
|
+
async function handleCollection(request, { name, identifier, uriGetter, filter, filterPredicate, context: context$1, collectionCallbacks, tracerProvider, onUnauthorized, onNotFound }) {
|
467
402
|
const spanName = name.trim().replace(/\s+/g, "_");
|
468
403
|
tracerProvider = tracerProvider ?? trace.getTracerProvider();
|
469
404
|
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
@@ -576,7 +511,6 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
|
|
576
511
|
partOf
|
577
512
|
});
|
578
513
|
}
|
579
|
-
if (!acceptsJsonLd(request)) return await onNotAcceptable(request);
|
580
514
|
if (collectionCallbacks.authorizePredicate != null) {
|
581
515
|
let key = await context$1.getSignedKey();
|
582
516
|
key = key?.clone({}, { $warning: {
|
@@ -671,7 +605,8 @@ async function handleInbox(request, options) {
|
|
671
605
|
* @param span The OpenTelemetry span for tracing.
|
672
606
|
* @returns A promise that resolves to an HTTP response.
|
673
607
|
*/
|
674
|
-
async function handleInboxInternal(request,
|
608
|
+
async function handleInboxInternal(request, parameters, span) {
|
609
|
+
const { recipient, context: ctx, inboxContextFactory, kv, kvPrefixes, queue, actorDispatcher, inboxListeners, inboxErrorHandler, onNotFound, signatureTimeWindow, skipSignatureVerification, tracerProvider } = parameters;
|
675
610
|
const logger$2 = getLogger([
|
676
611
|
"fedify",
|
677
612
|
"federation",
|
@@ -873,7 +808,8 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
|
|
873
808
|
kvPrefixes,
|
874
809
|
queue,
|
875
810
|
span,
|
876
|
-
tracerProvider
|
811
|
+
tracerProvider,
|
812
|
+
idempotencyStrategy: parameters.idempotencyStrategy
|
877
813
|
});
|
878
814
|
if (routeResult === "alreadyProcessed") return new Response(`Activity <${activity.id}> has already been processed.`, {
|
879
815
|
status: 202,
|
@@ -903,7 +839,7 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
|
|
903
839
|
/**
|
904
840
|
* Handles a custom collection request.
|
905
841
|
* @template TItem The type of items in the collection.
|
906
|
-
* @template
|
842
|
+
* @template TParam The parameter names of the requested URL.
|
907
843
|
* @template TContext The type of the context, extending {@link RequestContext}.
|
908
844
|
* @template TContextData The context data to pass to the `TContext`.
|
909
845
|
* @param request The HTTP request.
|
@@ -914,7 +850,6 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
|
|
914
850
|
const handleCustomCollection = exceptWrapper(_handleCustomCollection);
|
915
851
|
async function _handleCustomCollection(request, { name, values, context: context$1, tracerProvider, collectionCallbacks: callbacks, filterPredicate }) {
|
916
852
|
verifyDefined(callbacks);
|
917
|
-
verifyJsonLdRequest(request);
|
918
853
|
await authIfNeeded(context$1, values, callbacks);
|
919
854
|
const cursor = new URL(request.url).searchParams.get("cursor");
|
920
855
|
return await new CustomCollectionHandler(name, values, context$1, callbacks, tracerProvider, Collection, CollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
|
@@ -922,7 +857,7 @@ async function _handleCustomCollection(request, { name, values, context: context
|
|
922
857
|
/**
|
923
858
|
* Handles an ordered collection request.
|
924
859
|
* @template TItem The type of items in the collection.
|
925
|
-
* @template
|
860
|
+
* @template TParam The parameter names of the requested URL.
|
926
861
|
* @template TContext The type of the context, extending {@link RequestContext}.
|
927
862
|
* @template TContextData The context data to pass to the `TContext`.
|
928
863
|
* @param request The HTTP request.
|
@@ -933,7 +868,6 @@ async function _handleCustomCollection(request, { name, values, context: context
|
|
933
868
|
const handleOrderedCollection = exceptWrapper(_handleOrderedCollection);
|
934
869
|
async function _handleOrderedCollection(request, { name, values, context: context$1, tracerProvider, collectionCallbacks: callbacks, filterPredicate }) {
|
935
870
|
verifyDefined(callbacks);
|
936
|
-
verifyJsonLdRequest(request);
|
937
871
|
await authIfNeeded(context$1, values, callbacks);
|
938
872
|
const cursor = new URL(request.url).searchParams.get("cursor");
|
939
873
|
return await new CustomCollectionHandler(name, values, context$1, callbacks, tracerProvider, OrderedCollection, OrderedCollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
|
@@ -943,7 +877,7 @@ async function _handleOrderedCollection(request, { name, values, context: contex
|
|
943
877
|
* The main flow is on `getCollection`, `dispatch`.
|
944
878
|
*
|
945
879
|
* @template TItem The type of items in the collection.
|
946
|
-
* @template
|
880
|
+
* @template TParam The parameter names of the requested URL.
|
947
881
|
* @template TContext The type of the context. {@link Context} or {@link RequestContext}.
|
948
882
|
* @template TContextData The context data to pass to the `TContext`.
|
949
883
|
* @template TCollection The type of the collection, extending {@link Collection}.
|
@@ -977,14 +911,14 @@ var CustomCollectionHandler = class {
|
|
977
911
|
#collection = null;
|
978
912
|
/**
|
979
913
|
* Creates a new CustomCollection instance.
|
980
|
-
* @param
|
981
|
-
* @param
|
982
|
-
* @param
|
983
|
-
* @param
|
984
|
-
* @param
|
985
|
-
* @param
|
986
|
-
* @param
|
987
|
-
* @param
|
914
|
+
* @param name The name of the collection.
|
915
|
+
* @param values The parameter values for the collection.
|
916
|
+
* @param context The request context.
|
917
|
+
* @param callbacks The collection callbacks.
|
918
|
+
* @param tracerProvider The tracer provider for telemetry.
|
919
|
+
* @param Collection The Collection constructor.
|
920
|
+
* @param CollectionPage The CollectionPage constructor.
|
921
|
+
* @param filterPredicate Optional filter predicate for items.
|
988
922
|
*/
|
989
923
|
constructor(name, values, context$1, callbacks, tracerProvider = trace.getTracerProvider(), Collection$1, CollectionPage$1, filterPredicate) {
|
990
924
|
this.name = name;
|
@@ -1109,7 +1043,7 @@ var CustomCollectionHandler = class {
|
|
1109
1043
|
/**
|
1110
1044
|
* Creates a function to wrap the dispatcher so tracing can be applied.
|
1111
1045
|
* @param params Parameters including cursor and total items.
|
1112
|
-
* @returns
|
1046
|
+
* @returns A function that handles the span operation.
|
1113
1047
|
*/
|
1114
1048
|
spanPages = ({ totalItems = null, cursor = null }) => async (span) => {
|
1115
1049
|
try {
|
@@ -1130,23 +1064,23 @@ var CustomCollectionHandler = class {
|
|
1130
1064
|
};
|
1131
1065
|
/**
|
1132
1066
|
* Dispatches the collection request to get items.
|
1133
|
-
* @param
|
1134
|
-
* @returns
|
1067
|
+
* @param cursor The cursor for pagination, or null for the first page.
|
1068
|
+
* @returns A promise that resolves to the page items.
|
1135
1069
|
*/
|
1136
1070
|
async dispatch(cursor = null) {
|
1137
1071
|
return await this.#dispatcher(this.context, this.values, cursor) ?? new ItemsNotFoundError().throw();
|
1138
1072
|
}
|
1139
1073
|
/**
|
1140
1074
|
* Filters the items in the collection.
|
1141
|
-
* @param
|
1142
|
-
* @returns
|
1075
|
+
* @param items The items to filter.
|
1076
|
+
* @returns The filtered items.
|
1143
1077
|
*/
|
1144
1078
|
filterItems(items) {
|
1145
1079
|
return filterCollectionItems(items, this.name, this.filterPredicate);
|
1146
1080
|
}
|
1147
1081
|
/**
|
1148
1082
|
* Appends a cursor to the URL if it exists.
|
1149
|
-
* @param
|
1083
|
+
* @param cursor The cursor to append, or null/undefined.
|
1150
1084
|
* @returns The URL with cursor appended, or null if cursor is null/undefined.
|
1151
1085
|
*/
|
1152
1086
|
appendToUrl(cursor) {
|
@@ -1154,8 +1088,7 @@ var CustomCollectionHandler = class {
|
|
1154
1088
|
}
|
1155
1089
|
/**
|
1156
1090
|
* Gets the stored collection or collection page.
|
1157
|
-
* @returns
|
1158
|
-
the collection or collection page.
|
1091
|
+
* @returns A promise that resolves to the collection or collection page.
|
1159
1092
|
*/
|
1160
1093
|
get collection() {
|
1161
1094
|
if (this.#collection === null) this.#collection = this.getCollection();
|
@@ -1163,8 +1096,8 @@ var CustomCollectionHandler = class {
|
|
1163
1096
|
}
|
1164
1097
|
/**
|
1165
1098
|
* Gets the total number of items in the collection.
|
1166
|
-
* @returns
|
1167
|
-
|
1099
|
+
* @returns A promise that resolves to the total items count,
|
1100
|
+
* or null if not available.
|
1168
1101
|
*/
|
1169
1102
|
get totalItems() {
|
1170
1103
|
if (this.#totalItems === void 0) this.totalItems = this.callbacks.counter?.(this.context, this.values);
|
@@ -1180,8 +1113,8 @@ var CustomCollectionHandler = class {
|
|
1180
1113
|
}
|
1181
1114
|
/**
|
1182
1115
|
* Gets the first cursor for pagination.
|
1183
|
-
* @returns
|
1184
|
-
or null if not available.
|
1116
|
+
* @returns A promise that resolves to the first cursor,
|
1117
|
+
* or null if not available.
|
1185
1118
|
*/
|
1186
1119
|
get firstCursor() {
|
1187
1120
|
const cursor = this.callbacks.firstCursor?.(this.context, this.values);
|
@@ -1211,10 +1144,9 @@ function exceptWrapper(handler) {
|
|
1211
1144
|
try {
|
1212
1145
|
return await handler(request, handlerParams);
|
1213
1146
|
} catch (error) {
|
1214
|
-
const { onNotFound,
|
1147
|
+
const { onNotFound, onUnauthorized } = handlerParams;
|
1215
1148
|
switch (error?.constructor) {
|
1216
1149
|
case ItemsNotFoundError: return await onNotFound(request);
|
1217
|
-
case NotAcceptableError: return await onNotAcceptable(request);
|
1218
1150
|
case UnauthorizedError: return await onUnauthorized(request);
|
1219
1151
|
default: throw error;
|
1220
1152
|
}
|
@@ -1232,15 +1164,6 @@ const verifyDefined = (callbacks) => {
|
|
1232
1164
|
if (callbacks === void 0) throw new ItemsNotFoundError();
|
1233
1165
|
};
|
1234
1166
|
/**
|
1235
|
-
* Verifies that a request accepts JSON-LD content type.
|
1236
|
-
* @param request The HTTP request to verify.
|
1237
|
-
* @throws {NotAcceptableError} If the request doesn't accept JSON-LD.
|
1238
|
-
* @since 1.8.0
|
1239
|
-
*/
|
1240
|
-
const verifyJsonLdRequest = (request) => {
|
1241
|
-
if (!acceptsJsonLd(request)) throw new NotAcceptableError();
|
1242
|
-
};
|
1243
|
-
/**
|
1244
1167
|
* Performs authorization if needed based on the authorization predicate.
|
1245
1168
|
* @template TContextData The context data type.
|
1246
1169
|
* @param {RequestContext<TContextData>} context The request context.
|
@@ -1324,15 +1247,6 @@ var ItemsNotFoundError = class extends HandlerError {
|
|
1324
1247
|
}
|
1325
1248
|
};
|
1326
1249
|
/**
|
1327
|
-
* Error thrown when the request is not acceptable (e.g., wrong content type).
|
1328
|
-
* @since 1.8.0
|
1329
|
-
*/
|
1330
|
-
var NotAcceptableError = class extends HandlerError {
|
1331
|
-
constructor() {
|
1332
|
-
super("The request is not acceptable.");
|
1333
|
-
}
|
1334
|
-
};
|
1335
|
-
/**
|
1336
1250
|
* Error thrown when access to a collection is unauthorized.
|
1337
1251
|
* @since 1.8.0
|
1338
1252
|
*/
|
@@ -1405,7 +1319,6 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
1405
1319
|
firstKnock;
|
1406
1320
|
constructor(options) {
|
1407
1321
|
super();
|
1408
|
-
const logger$2 = getLogger(["fedify", "federation"]);
|
1409
1322
|
this.kv = options.kv;
|
1410
1323
|
this.kvPrefixes = {
|
1411
1324
|
activityIdempotence: ["_fedify", "activityIdempotence"],
|
@@ -1453,8 +1366,9 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
1453
1366
|
this.router.trailingSlashInsensitive = options.trailingSlashInsensitive ?? false;
|
1454
1367
|
this._initializeRouter();
|
1455
1368
|
if (options.allowPrivateAddress || options.userAgent != null) {
|
1456
|
-
if (options.
|
1457
|
-
|
1369
|
+
if (options.documentLoaderFactory != null) throw new TypeError("Cannot set documentLoaderFactory with allowPrivateAddress or userAgent options.");
|
1370
|
+
if (options.contextLoaderFactory != null) throw new TypeError("Cannot set contextLoaderFactory with allowPrivateAddress or userAgent options.");
|
1371
|
+
if (options.authenticatedDocumentLoaderFactory != null) throw new TypeError("Cannot set authenticatedDocumentLoaderFactory with allowPrivateAddress or userAgent options.");
|
1458
1372
|
}
|
1459
1373
|
const { allowPrivateAddress, userAgent } = options;
|
1460
1374
|
this.allowPrivateAddress = allowPrivateAddress ?? false;
|
@@ -1468,11 +1382,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
1468
1382
|
prefix: this.kvPrefixes.remoteDocument
|
1469
1383
|
});
|
1470
1384
|
});
|
1471
|
-
|
1472
|
-
if (options.contextLoaderFactory != null) throw new TypeError("Cannot set both contextLoader and contextLoaderFactory options at a time; use contextLoaderFactory only.");
|
1473
|
-
this.contextLoaderFactory = () => options.contextLoader;
|
1474
|
-
logger$2.warn("The contextLoader option is deprecated; use contextLoaderFactory option instead.");
|
1475
|
-
} else this.contextLoaderFactory = options.contextLoaderFactory ?? this.documentLoaderFactory;
|
1385
|
+
this.contextLoaderFactory = options.contextLoaderFactory ?? this.documentLoaderFactory;
|
1476
1386
|
this.authenticatedDocumentLoaderFactory = options.authenticatedDocumentLoaderFactory ?? ((identity) => getAuthenticatedDocumentLoader(identity, {
|
1477
1387
|
allowPrivateAddress,
|
1478
1388
|
userAgent,
|
@@ -2011,6 +1921,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2011
1921
|
span,
|
2012
1922
|
tracer
|
2013
1923
|
});
|
1924
|
+
if (acceptsJsonLd(request)) response.headers.set("Vary", "Accept");
|
2014
1925
|
} catch (error) {
|
2015
1926
|
span.setStatus({
|
2016
1927
|
code: SpanStatusCode.ERROR,
|
@@ -2074,6 +1985,9 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2074
1985
|
context: context$1,
|
2075
1986
|
nodeInfoDispatcher: this.nodeInfoDispatcher
|
2076
1987
|
});
|
1988
|
+
}
|
1989
|
+
if (request.method !== "POST" && !acceptsJsonLd(request)) return await onNotAcceptable(request);
|
1990
|
+
switch (routeName) {
|
2077
1991
|
case "actor":
|
2078
1992
|
context$1 = this.#createContext(request, contextData, { invokedFromActorDispatcher: { identifier: route.values.identifier ?? route.values.handle } });
|
2079
1993
|
return await handleActor(request, {
|
@@ -2082,8 +1996,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2082
1996
|
actorDispatcher: this.actorCallbacks?.dispatcher,
|
2083
1997
|
authorizePredicate: this.actorCallbacks?.authorizePredicate,
|
2084
1998
|
onUnauthorized,
|
2085
|
-
onNotFound
|
2086
|
-
onNotAcceptable
|
1999
|
+
onNotFound
|
2087
2000
|
});
|
2088
2001
|
case "object": {
|
2089
2002
|
const typeId = route.name.replace(/^object:/, "");
|
@@ -2099,8 +2012,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2099
2012
|
objectDispatcher: callbacks?.dispatcher,
|
2100
2013
|
authorizePredicate: callbacks?.authorizePredicate,
|
2101
2014
|
onUnauthorized,
|
2102
|
-
onNotFound
|
2103
|
-
onNotAcceptable
|
2015
|
+
onNotFound
|
2104
2016
|
});
|
2105
2017
|
}
|
2106
2018
|
case "outbox": return await handleCollection(request, {
|
@@ -2111,8 +2023,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2111
2023
|
collectionCallbacks: this.outboxCallbacks,
|
2112
2024
|
tracerProvider: this.tracerProvider,
|
2113
2025
|
onUnauthorized,
|
2114
|
-
onNotFound
|
2115
|
-
onNotAcceptable
|
2026
|
+
onNotFound
|
2116
2027
|
});
|
2117
2028
|
case "inbox":
|
2118
2029
|
if (request.method !== "POST") return await handleCollection(request, {
|
@@ -2123,8 +2034,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2123
2034
|
collectionCallbacks: this.inboxCallbacks,
|
2124
2035
|
tracerProvider: this.tracerProvider,
|
2125
2036
|
onUnauthorized,
|
2126
|
-
onNotFound
|
2127
|
-
onNotAcceptable
|
2037
|
+
onNotFound
|
2128
2038
|
});
|
2129
2039
|
context$1 = this.#createContext(request, contextData, { documentLoader: await context$1.getDocumentLoader({ identifier: route.values.identifier ?? route.values.handle }) });
|
2130
2040
|
case "sharedInbox":
|
@@ -2146,7 +2056,8 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2146
2056
|
onNotFound,
|
2147
2057
|
signatureTimeWindow: this.signatureTimeWindow,
|
2148
2058
|
skipSignatureVerification: this.skipSignatureVerification,
|
2149
|
-
tracerProvider: this.tracerProvider
|
2059
|
+
tracerProvider: this.tracerProvider,
|
2060
|
+
idempotencyStrategy: this.idempotencyStrategy
|
2150
2061
|
});
|
2151
2062
|
case "following": return await handleCollection(request, {
|
2152
2063
|
name: "following",
|
@@ -2156,8 +2067,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2156
2067
|
collectionCallbacks: this.followingCallbacks,
|
2157
2068
|
tracerProvider: this.tracerProvider,
|
2158
2069
|
onUnauthorized,
|
2159
|
-
onNotFound
|
2160
|
-
onNotAcceptable
|
2070
|
+
onNotFound
|
2161
2071
|
});
|
2162
2072
|
case "followers": {
|
2163
2073
|
let baseUrl = url.searchParams.get("base-url");
|
@@ -2180,8 +2090,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2180
2090
|
collectionCallbacks: this.followersCallbacks,
|
2181
2091
|
tracerProvider: this.tracerProvider,
|
2182
2092
|
onUnauthorized,
|
2183
|
-
onNotFound
|
2184
|
-
onNotAcceptable
|
2093
|
+
onNotFound
|
2185
2094
|
});
|
2186
2095
|
}
|
2187
2096
|
case "liked": return await handleCollection(request, {
|
@@ -2192,8 +2101,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2192
2101
|
collectionCallbacks: this.likedCallbacks,
|
2193
2102
|
tracerProvider: this.tracerProvider,
|
2194
2103
|
onUnauthorized,
|
2195
|
-
onNotFound
|
2196
|
-
onNotAcceptable
|
2104
|
+
onNotFound
|
2197
2105
|
});
|
2198
2106
|
case "featured": return await handleCollection(request, {
|
2199
2107
|
name: "featured",
|
@@ -2203,8 +2111,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2203
2111
|
collectionCallbacks: this.featuredCallbacks,
|
2204
2112
|
tracerProvider: this.tracerProvider,
|
2205
2113
|
onUnauthorized,
|
2206
|
-
onNotFound
|
2207
|
-
onNotAcceptable
|
2114
|
+
onNotFound
|
2208
2115
|
});
|
2209
2116
|
case "featuredTags": return await handleCollection(request, {
|
2210
2117
|
name: "featured tags",
|
@@ -2214,8 +2121,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2214
2121
|
collectionCallbacks: this.featuredTagsCallbacks,
|
2215
2122
|
tracerProvider: this.tracerProvider,
|
2216
2123
|
onUnauthorized,
|
2217
|
-
onNotFound
|
2218
|
-
onNotAcceptable
|
2124
|
+
onNotFound
|
2219
2125
|
});
|
2220
2126
|
case "collection": {
|
2221
2127
|
const name = route.name.replace(/^collection:/, "");
|
@@ -2227,8 +2133,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2227
2133
|
collectionCallbacks: callbacks,
|
2228
2134
|
tracerProvider: this.tracerProvider,
|
2229
2135
|
onUnauthorized,
|
2230
|
-
onNotFound
|
2231
|
-
onNotAcceptable
|
2136
|
+
onNotFound
|
2232
2137
|
});
|
2233
2138
|
}
|
2234
2139
|
case "orderedCollection": {
|
@@ -2241,8 +2146,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2241
2146
|
collectionCallbacks: callbacks,
|
2242
2147
|
tracerProvider: this.tracerProvider,
|
2243
2148
|
onUnauthorized,
|
2244
|
-
onNotFound
|
2245
|
-
onNotAcceptable
|
2149
|
+
onNotFound
|
2246
2150
|
});
|
2247
2151
|
}
|
2248
2152
|
default: {
|
@@ -2537,15 +2441,16 @@ var ContextImpl = class ContextImpl {
|
|
2537
2441
|
"actor"
|
2538
2442
|
]);
|
2539
2443
|
if (this.federation.actorCallbacks?.keyPairsDispatcher == null) throw new Error("No actor key pairs dispatcher registered.");
|
2540
|
-
|
2541
|
-
|
2542
|
-
|
2543
|
-
})
|
2544
|
-
|
2545
|
-
|
2546
|
-
|
2444
|
+
let actorUri;
|
2445
|
+
try {
|
2446
|
+
actorUri = this.getActorUri(identifier);
|
2447
|
+
} catch (error) {
|
2448
|
+
if (error instanceof RouterError) {
|
2449
|
+
logger$2.warn(error.message);
|
2450
|
+
return [];
|
2451
|
+
}
|
2452
|
+
throw error;
|
2547
2453
|
}
|
2548
|
-
const actorUri = new URL(path, this.canonicalOrigin);
|
2549
2454
|
const keyPairs = await this.federation.actorCallbacks?.keyPairsDispatcher(new ContextImpl({
|
2550
2455
|
...this,
|
2551
2456
|
invokedFromActorKeyPairsDispatcher: { identifier }
|
@@ -2706,12 +2611,11 @@ var ContextImpl = class ContextImpl {
|
|
2706
2611
|
if (identifier == null) throw new Error("If recipients is \"followers\", sender must be an actor identifier or username.");
|
2707
2612
|
expandedRecipients = [];
|
2708
2613
|
for await (const recipient of this.getFollowers(identifier)) expandedRecipients.push(recipient);
|
2709
|
-
if (options.syncCollection) {
|
2710
|
-
|
2711
|
-
|
2712
|
-
|
2713
|
-
|
2714
|
-
opts.collectionSync = collectionId == null ? void 0 : new URL(collectionId, this.canonicalOrigin).href;
|
2614
|
+
if (options.syncCollection) try {
|
2615
|
+
opts.collectionSync = this.getFollowersUri(identifier).href;
|
2616
|
+
} catch (error) {
|
2617
|
+
if (error instanceof RouterError) opts.collectionSync = void 0;
|
2618
|
+
else throw error;
|
2715
2619
|
}
|
2716
2620
|
} else expandedRecipients = [recipients];
|
2717
2621
|
span.setAttribute("activitypub.inboxes", expandedRecipients.length);
|
@@ -2896,7 +2800,8 @@ var ContextImpl = class ContextImpl {
|
|
2896
2800
|
kvPrefixes: this.federation.kvPrefixes,
|
2897
2801
|
queue: this.federation.inboxQueue,
|
2898
2802
|
span,
|
2899
|
-
tracerProvider: options.tracerProvider ?? this.tracerProvider
|
2803
|
+
tracerProvider: options.tracerProvider ?? this.tracerProvider,
|
2804
|
+
idempotencyStrategy: this.federation.idempotencyStrategy
|
2900
2805
|
});
|
2901
2806
|
return routeResult === "alreadyProcessed" || routeResult === "enqueued" || routeResult === "unsupportedActivity" || routeResult === "success";
|
2902
2807
|
}
|
@@ -3210,4 +3115,4 @@ function getRequestId(request) {
|
|
3210
3115
|
}
|
3211
3116
|
|
3212
3117
|
//#endregion
|
3213
|
-
export { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer,
|
3118
|
+
export { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, actorDehydrator, autoIdAssigner, createFederation, handleActor, handleCollection, handleCustomCollection, handleInbox, handleNodeInfo, handleNodeInfoJrd, handleObject, handleWebFinger, respondWithObject, respondWithObjectIfAcceptable };
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
|
5
|
+
import "./transformers-BFT6d7J5.js";
|
6
|
+
import "./lookup-CHkCVZTU.js";
|
7
|
+
import "./actor-DzhunPC_.js";
|
8
|
+
import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "./middleware-DMk2Mdn9.js";
|
9
|
+
import "./http-CUVx-vzb.js";
|
10
|
+
import "./proof-fqzaMJ4g.js";
|
11
|
+
import "./types-BtUjyi5y.js";
|
12
|
+
import "./kv-cache-CGXcDejL.js";
|
13
|
+
import "./vocab-BnR3nIU9.js";
|
14
|
+
|
15
|
+
export { FederationImpl };
|