@fedify/fedify 2.0.0-pr.433.1601 → 2.0.0-pr.434.1659
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/actor-BODH8--e.cjs +37786 -0
- package/dist/{actor-BYk33gpL.js → actor-DJS2ne1f.js} +200 -200
- package/dist/actor-DMgu-ZjT.d.cts +128 -0
- package/dist/{actor-DhgsJz-4.js → actor-WgMDAZc5.js} +1 -1
- package/dist/{assert_rejects-7UF4R_Qs.js → assert_rejects-DiIiJbZn.js} +1 -1
- package/dist/{assert_throws-53_pKeP3.js → assert_throws-BOO88avQ.js} +1 -1
- package/dist/authdocloader-C8Eqv2Kg.cjs +58 -0
- package/dist/{authdocloader-Bnyhgo9N.js → authdocloader-FA-VNPvw.js} +3 -3
- package/dist/{authdocloader-Dcu0wNV2.js → authdocloader-SW1oQJ7q.js} +6 -6
- package/dist/{builder-QxLyGSq9.js → builder-Cp2PpvmH.js} +4 -4
- package/dist/chunk-DqRYRqnO.cjs +34 -0
- package/dist/client-CegPX0Rn.d.cts +222 -0
- package/dist/{client-apb-XuqD.js → client-D_BQdihX.js} +2 -7
- package/dist/compat/mod.cjs +10 -0
- package/dist/compat/mod.d.cts +13 -0
- package/dist/compat/mod.d.ts +2 -2
- package/dist/compat/mod.js +5 -5
- package/dist/compat/transformers.test.js +18 -17
- package/dist/compat-DmDDELst.cjs +4 -0
- package/dist/compat-nxUqe4Z-.js +4 -0
- package/dist/{context-CDSZdQHD.d.ts → context-CQsAT7xk.d.ts} +0 -1
- package/dist/context-tVOQ76fi.d.cts +2254 -0
- package/dist/docloader-D-MrRyHl.d.cts +219 -0
- package/dist/{docloader-C5a95do5.js → docloader-DrPHprgh.js} +188 -8
- package/dist/docloader-dZO9fPIT.cjs +4861 -0
- package/dist/{esm-Bgz4xida.js → esm-CjcCcZ6s.js} +1 -1
- package/dist/federation/builder.test.js +10 -10
- package/dist/federation/collection.test.js +8 -8
- package/dist/federation/handler.test.js +26 -145
- package/dist/federation/inbox.test.js +6 -6
- package/dist/federation/keycache.test.js +4 -4
- package/dist/federation/kv.test.js +9 -8
- package/dist/federation/middleware.test.js +255 -38
- package/dist/federation/mod.cjs +29 -0
- package/dist/federation/mod.d.cts +13 -0
- package/dist/federation/mod.d.ts +1 -1
- package/dist/federation/mod.js +15 -15
- package/dist/federation/mq.test.js +10 -10
- package/dist/federation/negotiation.test.d.ts +3 -0
- package/dist/federation/negotiation.test.js +28 -0
- package/dist/federation/retry.test.js +5 -5
- package/dist/federation/router.test.js +8 -8
- package/dist/federation/send.test.js +15 -15
- package/dist/{federation-CMX7WzeL.js → federation-D1U8YY9t.js} +3 -3
- package/dist/federation-H2_En3j5.cjs +244 -0
- package/dist/{http-DNI66-5x.js → http-BPkuNd26.js} +2 -2
- package/dist/http-BS6766zs.d.cts +253 -0
- package/dist/{http-JY6wHpzI.js → http-BgQ07Ja_.js} +6 -6
- package/dist/http-CZJRJ0Pv.cjs +826 -0
- package/dist/{inbox-DQ8L0DJL.js → inbox-CCB1CbWJ.js} +1 -1
- package/dist/{key-5IrrMBg5.js → key-B_P3wH2F.js} +5 -5
- package/dist/{key-Be6l1ofa.js → key-BstbqwrH.js} +3 -3
- package/dist/{key-BPlyixfT.js → key-C0k2A_bI.js} +2 -2
- package/dist/key-C8TOf6mh.cjs +290 -0
- package/dist/key-CtA7xiw_.js +10 -0
- package/dist/key-hknDPZ-z.cjs +10 -0
- package/dist/{keycache-C4ahXsL4.js → keycache-DvDW8JPA.js} +1 -1
- package/dist/{keys-DJSYNKDA.js → keys-DzXrG_sX.js} +1 -1
- package/dist/kv-63Cil1MD.d.cts +81 -0
- package/dist/{ld-CWJxBIBV.js → ld-BcKcM_o9.js} +2 -2
- package/dist/{lookup-BnXYO054.js → lookup-C3BC8XO-.js} +4 -4
- package/dist/lookup-C3BGNQTz.cjs +137 -0
- package/dist/{lookup-C7LsgCJN.js → lookup-DbTBDJcT.js} +1 -1
- package/dist/{middleware-exe_8YIh.js → middleware-B3crRaK-.js} +50 -81
- package/dist/middleware-BWXHJSkY.cjs +17 -0
- package/dist/middleware-C4A4GTtX.cjs +4204 -0
- package/dist/middleware-CGlIdSyy.js +17 -0
- package/dist/middleware-CUWXMbGt.js +26 -0
- package/dist/{middleware-DfHez8_s.js → middleware-CXRqw8n4.js} +49 -144
- package/dist/{mod-RI3-KvUI.d.ts → mod-B26zRlH1.d.ts} +1 -1
- package/dist/mod-BClfg3ej.d.cts +266 -0
- package/dist/mod-C2tOeRkN.d.cts +1 -0
- package/dist/mod-DBQAI4v9.d.cts +80 -0
- package/dist/mod-Dc_-mf8s.d.cts +102 -0
- package/dist/mod-FZd39qVq.d.cts +1 -0
- package/dist/mod-evzlRVZq.d.cts +289 -0
- package/dist/mod-jQ4OODsl.d.cts +113 -0
- package/dist/mod.cjs +150 -0
- package/dist/mod.d.cts +17 -0
- package/dist/mod.d.ts +2 -2
- package/dist/mod.js +20 -20
- package/dist/mq-B7R1Q-M5.d.cts +140 -0
- package/dist/negotiation-5NPJL6zp.js +71 -0
- package/dist/nodeinfo/client.test.js +10 -10
- package/dist/nodeinfo/handler.test.js +23 -22
- package/dist/nodeinfo/mod.cjs +11 -0
- package/dist/nodeinfo/mod.d.cts +5 -0
- package/dist/nodeinfo/mod.js +6 -6
- package/dist/nodeinfo/types.test.js +8 -8
- package/dist/nodeinfo-Co9lJrWl.cjs +4 -0
- package/dist/nodeinfo-DfycQ8Wf.js +4 -0
- package/dist/owner-B-7Ptt_m.d.cts +67 -0
- package/dist/{owner-CM_3htrf.js → owner-BcEciLTD.js} +2 -2
- package/dist/{proof-WqatqDcH.js → proof-DAEfR6xA.js} +6 -6
- package/dist/proof-ZBmKo2zb.cjs +673 -0
- package/dist/{proof-B13S28BP.js → proof-vGquXXR6.js} +2 -2
- package/dist/runtime/authdocloader.test.js +14 -14
- package/dist/runtime/docloader.test.js +9 -9
- package/dist/runtime/key.test.js +10 -10
- package/dist/runtime/langstr.test.js +8 -8
- package/dist/runtime/link.test.d.ts +3 -0
- package/dist/runtime/link.test.js +61 -0
- package/dist/runtime/mod.cjs +25 -0
- package/dist/runtime/mod.d.cts +6 -0
- package/dist/runtime/mod.js +10 -10
- package/dist/runtime/multibase/multibase.test.js +8 -8
- package/dist/runtime/url.test.js +5 -5
- package/dist/runtime-C58AJWSv.cjs +4 -0
- package/dist/runtime-DPYEDf-o.js +4 -0
- package/dist/{send-BcaNFUhd.js → send-svmMjAUr.js} +2 -2
- package/dist/sig/http.test.js +13 -13
- package/dist/sig/key.test.js +11 -11
- package/dist/sig/ld.test.js +10 -10
- package/dist/sig/mod.cjs +30 -0
- package/dist/sig/mod.d.cts +8 -0
- package/dist/sig/mod.js +10 -10
- package/dist/sig/owner.test.js +12 -12
- package/dist/sig/proof.test.js +12 -12
- package/dist/sig-ByHXzqUi.cjs +4 -0
- package/dist/sig-Cj3tk-ig.js +4 -0
- package/dist/testing/docloader.test.js +8 -8
- package/dist/testing/mod.js +3 -3
- package/dist/{testing-CakwOL23.js → testing-y9ueu9Aj.js} +2 -2
- package/dist/{transformers-Dna8Fg7k.js → transformers-BFT6d7J5.js} +3 -3
- package/dist/transformers-CoBS-oFG.cjs +116 -0
- package/dist/{type-BKY_LVaq.js → type-9o78PXlX.js} +381 -201
- package/dist/{types-zVT9nODh.js → types-DTCqX5HE.js} +5 -10
- package/dist/types-K5btoOl6.cjs +315 -0
- package/dist/vocab/actor.test.js +10 -10
- package/dist/vocab/lookup.test.js +9 -9
- package/dist/vocab/mod.cjs +87 -0
- package/dist/vocab/mod.d.cts +6 -0
- package/dist/vocab/mod.js +7 -7
- package/dist/vocab/type.test.js +3 -3
- package/dist/vocab/vocab.test.js +45 -10
- package/dist/vocab-CJ0jQMQV.cjs +282 -0
- package/dist/{vocab-ClXayeh5.js → vocab-C_Pm3NG3.js} +6 -6
- package/dist/vocab-DJTYMqyU.d.cts +14632 -0
- package/dist/webfinger/handler.test.js +23 -22
- package/dist/webfinger/lookup.test.js +9 -9
- package/dist/webfinger/mod.cjs +9 -0
- package/dist/webfinger/mod.d.cts +4 -0
- package/dist/webfinger/mod.js +6 -6
- package/dist/webfinger-BjOEdFPs.cjs +4 -0
- package/dist/webfinger-De_bU0iE.js +4 -0
- package/dist/x/cfworkers.cjs +100 -0
- package/dist/x/cfworkers.d.cts +59 -0
- package/dist/x/cfworkers.js +3 -3
- package/dist/x/cfworkers.test.js +8 -8
- package/dist/x/hono.cjs +61 -0
- package/dist/x/hono.d.cts +54 -0
- package/dist/x/hono.d.ts +1 -1
- package/dist/x/hono.js +3 -3
- package/dist/x/sveltekit.cjs +69 -0
- package/dist/x/sveltekit.d.cts +46 -0
- package/dist/x/sveltekit.d.ts +1 -1
- package/dist/x/sveltekit.js +3 -3
- package/package.json +68 -13
- package/dist/compat-Bb5myD13.js +0 -4
- package/dist/key-BLStGL0R.js +0 -10
- package/dist/middleware-D2diREI8.js +0 -17
- package/dist/middleware-D5PCuUVh.js +0 -25
- package/dist/nodeinfo-CyEbLjHs.js +0 -4
- package/dist/runtime-BSkOVUWM.js +0 -4
- package/dist/sig-BXJO--F9.js +0 -4
- package/dist/webfinger-C3GIyXIg.js +0 -4
- /package/dist/{assert_is_error-B035L3om.js → assert_is_error-BPGph1Jx.js} +0 -0
- /package/dist/{assert_not_equals-C80BG-_5.js → assert_not_equals-f3m3epl3.js} +0 -0
- /package/dist/{denokv-jZ0Z2h0M.js → denokv-Bv33Xxea.js} +0 -0
- /package/dist/{retry-CfF8Gn4d.js → retry-D4GJ670a.js} +0 -0
- /package/dist/{std__assert-DWivtrGR.js → std__assert-X-_kMxKM.js} +0 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
|
5
|
+
import "./transformers-BFT6d7J5.js";
|
6
|
+
import "./docloader-DrPHprgh.js";
|
7
|
+
import "./actor-DJS2ne1f.js";
|
8
|
+
import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "./middleware-B3crRaK-.js";
|
9
|
+
import "./lookup-C3BC8XO-.js";
|
10
|
+
import "./key-B_P3wH2F.js";
|
11
|
+
import "./http-BgQ07Ja_.js";
|
12
|
+
import "./proof-DAEfR6xA.js";
|
13
|
+
import "./types-DTCqX5HE.js";
|
14
|
+
import "./authdocloader-SW1oQJ7q.js";
|
15
|
+
import "./vocab-C_Pm3NG3.js";
|
16
|
+
|
17
|
+
export { FederationImpl };
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
globalThis.addEventListener = () => {};
|
5
|
+
|
6
|
+
import "./type-9o78PXlX.js";
|
7
|
+
import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "./middleware-CXRqw8n4.js";
|
8
|
+
import "./client-D_BQdihX.js";
|
9
|
+
import "./lookup-DbTBDJcT.js";
|
10
|
+
import "./types-BSuWJsOm.js";
|
11
|
+
import "./actor-WgMDAZc5.js";
|
12
|
+
import "./key-C0k2A_bI.js";
|
13
|
+
import "./http-BPkuNd26.js";
|
14
|
+
import "./authdocloader-FA-VNPvw.js";
|
15
|
+
import "./ld-BcKcM_o9.js";
|
16
|
+
import "./owner-BcEciLTD.js";
|
17
|
+
import "./proof-vGquXXR6.js";
|
18
|
+
import "./inbox-CCB1CbWJ.js";
|
19
|
+
import "./builder-Cp2PpvmH.js";
|
20
|
+
import "./collection-CcnIw1qY.js";
|
21
|
+
import "./keycache-DvDW8JPA.js";
|
22
|
+
import "./negotiation-5NPJL6zp.js";
|
23
|
+
import "./retry-D4GJ670a.js";
|
24
|
+
import "./send-svmMjAUr.js";
|
25
|
+
|
26
|
+
export { FederationImpl };
|
@@ -3,22 +3,23 @@
|
|
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, deno_default, getDocumentLoader, getTypeId, kvCache, lookupWebFinger } from "./type-
|
7
|
-
import { getNodeInfo } from "./client-
|
8
|
-
import { RouterError, lookupObject, traverseCollection } from "./lookup-
|
6
|
+
import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, deno_default, getDocumentLoader, getTypeId, kvCache, lookupWebFinger } from "./type-9o78PXlX.js";
|
7
|
+
import { getNodeInfo } from "./client-D_BQdihX.js";
|
8
|
+
import { RouterError, lookupObject, traverseCollection } from "./lookup-DbTBDJcT.js";
|
9
9
|
import { nodeInfoToJson } from "./types-BSuWJsOm.js";
|
10
|
-
import { exportJwk, importJwk, validateCryptoKey } from "./key-
|
11
|
-
import { verifyRequest } from "./http-
|
12
|
-
import { getAuthenticatedDocumentLoader } from "./authdocloader-
|
13
|
-
import { detachSignature, hasSignature, signJsonLd, verifyJsonLd } from "./ld-
|
14
|
-
import { doesActorOwnKey, getKeyOwner } from "./owner-
|
15
|
-
import { signObject, verifyObject } from "./proof-
|
16
|
-
import { routeActivity } from "./inbox-
|
17
|
-
import { FederationBuilderImpl } from "./builder-
|
10
|
+
import { exportJwk, importJwk, validateCryptoKey } from "./key-C0k2A_bI.js";
|
11
|
+
import { verifyRequest } from "./http-BPkuNd26.js";
|
12
|
+
import { getAuthenticatedDocumentLoader } from "./authdocloader-FA-VNPvw.js";
|
13
|
+
import { detachSignature, hasSignature, signJsonLd, verifyJsonLd } from "./ld-BcKcM_o9.js";
|
14
|
+
import { doesActorOwnKey, getKeyOwner } from "./owner-BcEciLTD.js";
|
15
|
+
import { signObject, verifyObject } from "./proof-vGquXXR6.js";
|
16
|
+
import { routeActivity } from "./inbox-CCB1CbWJ.js";
|
17
|
+
import { FederationBuilderImpl } from "./builder-Cp2PpvmH.js";
|
18
18
|
import { buildCollectionSynchronizationHeader } from "./collection-CcnIw1qY.js";
|
19
|
-
import { KvKeyCache } from "./keycache-
|
20
|
-
import {
|
21
|
-
import {
|
19
|
+
import { KvKeyCache } from "./keycache-DvDW8JPA.js";
|
20
|
+
import { acceptsJsonLd } from "./negotiation-5NPJL6zp.js";
|
21
|
+
import { createExponentialBackoffPolicy } from "./retry-D4GJ670a.js";
|
22
|
+
import { extractInboxes, sendActivity } from "./send-svmMjAUr.js";
|
22
23
|
import { getLogger, withContext } from "@logtape/logtape";
|
23
24
|
import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
|
24
25
|
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 +298,8 @@ async function handleWebFingerInternal(request, { context: context$1, host, acto
|
|
297
298
|
} });
|
298
299
|
}
|
299
300
|
|
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
301
|
//#endregion
|
359
302
|
//#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
303
|
/**
|
368
304
|
* Handles an actor request.
|
369
305
|
* @template TContextData The context data to pass to the context.
|
@@ -371,7 +307,7 @@ function acceptsJsonLd(request) {
|
|
371
307
|
* @param parameters The parameters for handling the actor.
|
372
308
|
* @returns A promise that resolves to an HTTP response.
|
373
309
|
*/
|
374
|
-
async function handleActor(request, { identifier, context: context$1, actorDispatcher, authorizePredicate, onNotFound,
|
310
|
+
async function handleActor(request, { identifier, context: context$1, actorDispatcher, authorizePredicate, onNotFound, onUnauthorized }) {
|
375
311
|
const logger$2 = getLogger([
|
376
312
|
"fedify",
|
377
313
|
"federation",
|
@@ -386,7 +322,6 @@ async function handleActor(request, { identifier, context: context$1, actorDispa
|
|
386
322
|
logger$2.debug("Actor {identifier} not found.", { identifier });
|
387
323
|
return await onNotFound(request);
|
388
324
|
}
|
389
|
-
if (!acceptsJsonLd(request)) return await onNotAcceptable(request);
|
390
325
|
if (authorizePredicate != null) {
|
391
326
|
let key = await context$1.getSignedKey();
|
392
327
|
key = key?.clone({}, { $warning: {
|
@@ -421,11 +356,10 @@ async function handleActor(request, { identifier, context: context$1, actorDispa
|
|
421
356
|
* @param parameters The parameters for handling the object.
|
422
357
|
* @returns A promise that resolves to an HTTP response.
|
423
358
|
*/
|
424
|
-
async function handleObject(request, { values, context: context$1, objectDispatcher, authorizePredicate, onNotFound,
|
359
|
+
async function handleObject(request, { values, context: context$1, objectDispatcher, authorizePredicate, onNotFound, onUnauthorized }) {
|
425
360
|
if (objectDispatcher == null) return await onNotFound(request);
|
426
361
|
const object = await objectDispatcher(context$1, values);
|
427
362
|
if (object == null) return await onNotFound(request);
|
428
|
-
if (!acceptsJsonLd(request)) return await onNotAcceptable(request);
|
429
363
|
if (authorizePredicate != null) {
|
430
364
|
let key = await context$1.getSignedKey();
|
431
365
|
key = key?.clone({}, { $warning: {
|
@@ -463,7 +397,7 @@ async function handleObject(request, { values, context: context$1, objectDispatc
|
|
463
397
|
* @param parameters The parameters for handling the collection.
|
464
398
|
* @returns A promise that resolves to an HTTP response.
|
465
399
|
*/
|
466
|
-
async function handleCollection(request, { name, identifier, uriGetter, filter, filterPredicate, context: context$1, collectionCallbacks, tracerProvider, onUnauthorized, onNotFound
|
400
|
+
async function handleCollection(request, { name, identifier, uriGetter, filter, filterPredicate, context: context$1, collectionCallbacks, tracerProvider, onUnauthorized, onNotFound }) {
|
467
401
|
const spanName = name.trim().replace(/\s+/g, "_");
|
468
402
|
tracerProvider = tracerProvider ?? trace.getTracerProvider();
|
469
403
|
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
@@ -576,7 +510,6 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
|
|
576
510
|
partOf
|
577
511
|
});
|
578
512
|
}
|
579
|
-
if (!acceptsJsonLd(request)) return await onNotAcceptable(request);
|
580
513
|
if (collectionCallbacks.authorizePredicate != null) {
|
581
514
|
let key = await context$1.getSignedKey();
|
582
515
|
key = key?.clone({}, { $warning: {
|
@@ -914,7 +847,6 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
|
|
914
847
|
const handleCustomCollection = exceptWrapper(_handleCustomCollection);
|
915
848
|
async function _handleCustomCollection(request, { name, values, context: context$1, tracerProvider, collectionCallbacks: callbacks, filterPredicate }) {
|
916
849
|
verifyDefined(callbacks);
|
917
|
-
verifyJsonLdRequest(request);
|
918
850
|
await authIfNeeded(context$1, values, callbacks);
|
919
851
|
const cursor = new URL(request.url).searchParams.get("cursor");
|
920
852
|
return await new CustomCollectionHandler(name, values, context$1, callbacks, tracerProvider, Collection, CollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
|
@@ -933,7 +865,6 @@ async function _handleCustomCollection(request, { name, values, context: context
|
|
933
865
|
const handleOrderedCollection = exceptWrapper(_handleOrderedCollection);
|
934
866
|
async function _handleOrderedCollection(request, { name, values, context: context$1, tracerProvider, collectionCallbacks: callbacks, filterPredicate }) {
|
935
867
|
verifyDefined(callbacks);
|
936
|
-
verifyJsonLdRequest(request);
|
937
868
|
await authIfNeeded(context$1, values, callbacks);
|
938
869
|
const cursor = new URL(request.url).searchParams.get("cursor");
|
939
870
|
return await new CustomCollectionHandler(name, values, context$1, callbacks, tracerProvider, OrderedCollection, OrderedCollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
|
@@ -1211,10 +1142,9 @@ function exceptWrapper(handler) {
|
|
1211
1142
|
try {
|
1212
1143
|
return await handler(request, handlerParams);
|
1213
1144
|
} catch (error) {
|
1214
|
-
const { onNotFound,
|
1145
|
+
const { onNotFound, onUnauthorized } = handlerParams;
|
1215
1146
|
switch (error?.constructor) {
|
1216
1147
|
case ItemsNotFoundError: return await onNotFound(request);
|
1217
|
-
case NotAcceptableError: return await onNotAcceptable(request);
|
1218
1148
|
case UnauthorizedError: return await onUnauthorized(request);
|
1219
1149
|
default: throw error;
|
1220
1150
|
}
|
@@ -1232,15 +1162,6 @@ const verifyDefined = (callbacks) => {
|
|
1232
1162
|
if (callbacks === void 0) throw new ItemsNotFoundError();
|
1233
1163
|
};
|
1234
1164
|
/**
|
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
1165
|
* Performs authorization if needed based on the authorization predicate.
|
1245
1166
|
* @template TContextData The context data type.
|
1246
1167
|
* @param {RequestContext<TContextData>} context The request context.
|
@@ -1324,15 +1245,6 @@ var ItemsNotFoundError = class extends HandlerError {
|
|
1324
1245
|
}
|
1325
1246
|
};
|
1326
1247
|
/**
|
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
1248
|
* Error thrown when access to a collection is unauthorized.
|
1337
1249
|
* @since 1.8.0
|
1338
1250
|
*/
|
@@ -2011,6 +1923,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2011
1923
|
span,
|
2012
1924
|
tracer
|
2013
1925
|
});
|
1926
|
+
if (acceptsJsonLd(request)) response.headers.set("Vary", "Accept");
|
2014
1927
|
} catch (error) {
|
2015
1928
|
span.setStatus({
|
2016
1929
|
code: SpanStatusCode.ERROR,
|
@@ -2074,6 +1987,9 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2074
1987
|
context: context$1,
|
2075
1988
|
nodeInfoDispatcher: this.nodeInfoDispatcher
|
2076
1989
|
});
|
1990
|
+
}
|
1991
|
+
if (!acceptsJsonLd(request)) return await onNotAcceptable(request);
|
1992
|
+
switch (routeName) {
|
2077
1993
|
case "actor":
|
2078
1994
|
context$1 = this.#createContext(request, contextData, { invokedFromActorDispatcher: { identifier: route.values.identifier ?? route.values.handle } });
|
2079
1995
|
return await handleActor(request, {
|
@@ -2082,8 +1998,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2082
1998
|
actorDispatcher: this.actorCallbacks?.dispatcher,
|
2083
1999
|
authorizePredicate: this.actorCallbacks?.authorizePredicate,
|
2084
2000
|
onUnauthorized,
|
2085
|
-
onNotFound
|
2086
|
-
onNotAcceptable
|
2001
|
+
onNotFound
|
2087
2002
|
});
|
2088
2003
|
case "object": {
|
2089
2004
|
const typeId = route.name.replace(/^object:/, "");
|
@@ -2099,8 +2014,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2099
2014
|
objectDispatcher: callbacks?.dispatcher,
|
2100
2015
|
authorizePredicate: callbacks?.authorizePredicate,
|
2101
2016
|
onUnauthorized,
|
2102
|
-
onNotFound
|
2103
|
-
onNotAcceptable
|
2017
|
+
onNotFound
|
2104
2018
|
});
|
2105
2019
|
}
|
2106
2020
|
case "outbox": return await handleCollection(request, {
|
@@ -2111,8 +2025,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2111
2025
|
collectionCallbacks: this.outboxCallbacks,
|
2112
2026
|
tracerProvider: this.tracerProvider,
|
2113
2027
|
onUnauthorized,
|
2114
|
-
onNotFound
|
2115
|
-
onNotAcceptable
|
2028
|
+
onNotFound
|
2116
2029
|
});
|
2117
2030
|
case "inbox":
|
2118
2031
|
if (request.method !== "POST") return await handleCollection(request, {
|
@@ -2123,8 +2036,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2123
2036
|
collectionCallbacks: this.inboxCallbacks,
|
2124
2037
|
tracerProvider: this.tracerProvider,
|
2125
2038
|
onUnauthorized,
|
2126
|
-
onNotFound
|
2127
|
-
onNotAcceptable
|
2039
|
+
onNotFound
|
2128
2040
|
});
|
2129
2041
|
context$1 = this.#createContext(request, contextData, { documentLoader: await context$1.getDocumentLoader({ identifier: route.values.identifier ?? route.values.handle }) });
|
2130
2042
|
case "sharedInbox":
|
@@ -2156,8 +2068,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2156
2068
|
collectionCallbacks: this.followingCallbacks,
|
2157
2069
|
tracerProvider: this.tracerProvider,
|
2158
2070
|
onUnauthorized,
|
2159
|
-
onNotFound
|
2160
|
-
onNotAcceptable
|
2071
|
+
onNotFound
|
2161
2072
|
});
|
2162
2073
|
case "followers": {
|
2163
2074
|
let baseUrl = url.searchParams.get("base-url");
|
@@ -2180,8 +2091,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2180
2091
|
collectionCallbacks: this.followersCallbacks,
|
2181
2092
|
tracerProvider: this.tracerProvider,
|
2182
2093
|
onUnauthorized,
|
2183
|
-
onNotFound
|
2184
|
-
onNotAcceptable
|
2094
|
+
onNotFound
|
2185
2095
|
});
|
2186
2096
|
}
|
2187
2097
|
case "liked": return await handleCollection(request, {
|
@@ -2192,8 +2102,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2192
2102
|
collectionCallbacks: this.likedCallbacks,
|
2193
2103
|
tracerProvider: this.tracerProvider,
|
2194
2104
|
onUnauthorized,
|
2195
|
-
onNotFound
|
2196
|
-
onNotAcceptable
|
2105
|
+
onNotFound
|
2197
2106
|
});
|
2198
2107
|
case "featured": return await handleCollection(request, {
|
2199
2108
|
name: "featured",
|
@@ -2203,8 +2112,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2203
2112
|
collectionCallbacks: this.featuredCallbacks,
|
2204
2113
|
tracerProvider: this.tracerProvider,
|
2205
2114
|
onUnauthorized,
|
2206
|
-
onNotFound
|
2207
|
-
onNotAcceptable
|
2115
|
+
onNotFound
|
2208
2116
|
});
|
2209
2117
|
case "featuredTags": return await handleCollection(request, {
|
2210
2118
|
name: "featured tags",
|
@@ -2214,8 +2122,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2214
2122
|
collectionCallbacks: this.featuredTagsCallbacks,
|
2215
2123
|
tracerProvider: this.tracerProvider,
|
2216
2124
|
onUnauthorized,
|
2217
|
-
onNotFound
|
2218
|
-
onNotAcceptable
|
2125
|
+
onNotFound
|
2219
2126
|
});
|
2220
2127
|
case "collection": {
|
2221
2128
|
const name = route.name.replace(/^collection:/, "");
|
@@ -2227,8 +2134,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2227
2134
|
collectionCallbacks: callbacks,
|
2228
2135
|
tracerProvider: this.tracerProvider,
|
2229
2136
|
onUnauthorized,
|
2230
|
-
onNotFound
|
2231
|
-
onNotAcceptable
|
2137
|
+
onNotFound
|
2232
2138
|
});
|
2233
2139
|
}
|
2234
2140
|
case "orderedCollection": {
|
@@ -2241,8 +2147,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2241
2147
|
collectionCallbacks: callbacks,
|
2242
2148
|
tracerProvider: this.tracerProvider,
|
2243
2149
|
onUnauthorized,
|
2244
|
-
onNotFound
|
2245
|
-
onNotAcceptable
|
2150
|
+
onNotFound
|
2246
2151
|
});
|
2247
2152
|
}
|
2248
2153
|
default: {
|
@@ -2537,15 +2442,16 @@ var ContextImpl = class ContextImpl {
|
|
2537
2442
|
"actor"
|
2538
2443
|
]);
|
2539
2444
|
if (this.federation.actorCallbacks?.keyPairsDispatcher == null) throw new Error("No actor key pairs dispatcher registered.");
|
2540
|
-
|
2541
|
-
|
2542
|
-
|
2543
|
-
})
|
2544
|
-
|
2545
|
-
|
2546
|
-
|
2445
|
+
let actorUri;
|
2446
|
+
try {
|
2447
|
+
actorUri = this.getActorUri(identifier);
|
2448
|
+
} catch (error) {
|
2449
|
+
if (error instanceof RouterError) {
|
2450
|
+
logger$2.warn(error.message);
|
2451
|
+
return [];
|
2452
|
+
}
|
2453
|
+
throw error;
|
2547
2454
|
}
|
2548
|
-
const actorUri = new URL(path, this.canonicalOrigin);
|
2549
2455
|
const keyPairs = await this.federation.actorCallbacks?.keyPairsDispatcher(new ContextImpl({
|
2550
2456
|
...this,
|
2551
2457
|
invokedFromActorKeyPairsDispatcher: { identifier }
|
@@ -2706,12 +2612,11 @@ var ContextImpl = class ContextImpl {
|
|
2706
2612
|
if (identifier == null) throw new Error("If recipients is \"followers\", sender must be an actor identifier or username.");
|
2707
2613
|
expandedRecipients = [];
|
2708
2614
|
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;
|
2615
|
+
if (options.syncCollection) try {
|
2616
|
+
opts.collectionSync = this.getFollowersUri(identifier).href;
|
2617
|
+
} catch (error) {
|
2618
|
+
if (error instanceof RouterError) opts.collectionSync = void 0;
|
2619
|
+
else throw error;
|
2715
2620
|
}
|
2716
2621
|
} else expandedRecipients = [recipients];
|
2717
2622
|
span.setAttribute("activitypub.inboxes", expandedRecipients.length);
|
@@ -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 };
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
3
3
|
import { Activity } from "./vocab-SOE1ifCr.js";
|
4
|
-
import { ActivityTransformer, Context } from "./context-
|
4
|
+
import { ActivityTransformer, Context } from "./context-CQsAT7xk.js";
|
5
5
|
|
6
6
|
//#region src/compat/transformers.d.ts
|
7
7
|
|