@fedify/fedify 2.0.0-pr.435.1667 → 2.0.0-pr.445.1694
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-C3gJhZJj.cjs → actor-CwZ2m5rG.cjs} +7263 -2440
- package/dist/{actor-DMgu-ZjT.d.cts → actor-D6K058Tb.d.cts} +1 -1
- package/dist/{actor-Cpal85xW.js → actor-D8gCwLzv.js} +1 -1
- package/dist/{actor-CnVfp1Hp.js → actor-DoMcqXsW.js} +7263 -2440
- package/dist/{actor-C22bXuuC.d.ts → actor-T6RyhRgk.d.ts} +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-DWnwkjvZ.js → authdocloader-Cv_qEn1G.js} +3 -3
- package/dist/{authdocloader-Df2BFefL.js → authdocloader-DYTNpaMA.js} +3 -3
- package/dist/{authdocloader-DPCGwidE.cjs → authdocloader-bsmVF6eO.cjs} +3 -3
- package/dist/{builder-CMxichO9.js → builder-1_skw-d2.js} +10 -4
- package/dist/{client-BqyuOGiQ.js → client-D5CBsPrc.js} +1 -1
- package/dist/compat/mod.d.cts +7 -7
- package/dist/compat/mod.d.ts +7 -7
- package/dist/compat/transformers.test.js +18 -17
- package/dist/{context-CDSZdQHD.d.ts → context-DBKpNBnc.d.ts} +66 -12
- package/dist/{context-Dq8aCtMH.d.cts → context-DiqjMRef.d.cts} +66 -12
- package/dist/{docloader-B1O1Z5OK.cjs → docloader-CYnQRIXv.cjs} +2 -2
- package/dist/{docloader-xJVzq9O0.js → docloader-Czl3xV10.js} +2 -2
- package/dist/{esm-BBznxjVc.js → esm-Dl5T1RNE.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/idempotency.test.d.ts +3 -0
- package/dist/federation/idempotency.test.js +202 -0
- package/dist/federation/inbox.test.js +6 -6
- package/dist/federation/keycache.test.js +4 -4
- package/dist/federation/kv.test.js +8 -8
- package/dist/federation/middleware.test.js +238 -44
- package/dist/federation/mod.cjs +10 -10
- package/dist/federation/mod.d.cts +7 -7
- package/dist/federation/mod.d.ts +7 -7
- package/dist/federation/mod.js +10 -10
- 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/fixtures/media.example.com/avatars/test-avatar.jpg.json +6 -0
- package/dist/{http-Hw9HJp9i.cjs → http-CAusBl_3.cjs} +3 -3
- package/dist/{http-CovAm6we.js → http-C_Qc2neP.js} +3 -3
- package/dist/{http-y7khnX5Q.js → http-CuS-d4U0.js} +2 -2
- package/dist/{http-BS6766zs.d.cts → http-D-e6AFwR.d.cts} +1 -1
- package/dist/{http-DqSNLFNY.d.ts → http-D6Uj2x2y.d.ts} +1 -1
- package/dist/{inbox-DpcYOzs8.js → inbox-IETv_Qez.js} +24 -7
- package/dist/{key-BRmlopJL.js → key-BNJQQm3h.js} +2 -2
- package/dist/{key-lapZwBwG.js → key-C_ruQbbl.js} +4 -4
- package/dist/key-DIMJMxf4.cjs +10 -0
- package/dist/{key-DORX19Bl.js → key-DnqhSgAv.js} +2 -2
- package/dist/{key-jf6dIIF-.js → key-DpFjiItf.js} +3 -3
- package/dist/{key-CzF9SAEI.cjs → key-DuXv64tg.cjs} +2 -2
- package/dist/{keycache-AH1uj1j-.js → keycache-CSBkusP8.js} +1 -1
- package/dist/{keys-B3fzLXBG.js → keys-D3_MDK7n.js} +1 -1
- package/dist/{ld-D3cq9xO1.js → ld-Isot0tiW.js} +2 -2
- package/dist/{lookup-BrhURkmj.js → lookup-CbtuFbtg.js} +21 -12
- package/dist/{lookup-7u217Q3H.cjs → lookup-D6dro5Au.cjs} +1 -1
- package/dist/{lookup-CfU0DgLr.js → lookup-Dhm78GlK.js} +1 -1
- package/dist/middleware-BpR6186a.js +26 -0
- package/dist/{middleware-DXWUGrBQ.js → middleware-BuHr2fzh.js} +73 -81
- package/dist/middleware-DDMxdtWM.cjs +17 -0
- package/dist/{middleware-BDN7YoYJ.js → middleware-DQYscW90.js} +47 -142
- package/dist/{middleware-Gsxukxs5.cjs → middleware-Dgmdgrvb.cjs} +73 -81
- package/dist/middleware-T-knSMwl.js +17 -0
- package/dist/{mod-Drmz72EK.d.ts → mod-BhUKmBJD.d.ts} +2 -2
- package/dist/{mod-BhMnAkFX.d.cts → mod-Bpb5QLaZ.d.cts} +2 -2
- package/dist/{mod-TFoH2Ql8.d.ts → mod-CerN_Sza.d.ts} +1 -1
- package/dist/{mod-Dc_-mf8s.d.cts → mod-Cj1tHXBR.d.cts} +1 -1
- package/dist/{mod-evzlRVZq.d.cts → mod-CxkWO3Mg.d.cts} +19 -1
- package/dist/{mod-RI3-KvUI.d.ts → mod-D_y2y32N.d.ts} +2 -2
- package/dist/{mod-BClfg3ej.d.cts → mod-Djzcw2ry.d.cts} +2 -2
- package/dist/{mod-Cxt4Kpf6.d.ts → mod-DlU8ISoa.d.ts} +19 -1
- package/dist/mod.cjs +10 -10
- package/dist/mod.d.cts +10 -10
- package/dist/mod.d.ts +10 -10
- package/dist/mod.js +10 -10
- 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 +2 -2
- package/dist/nodeinfo/mod.js +2 -2
- package/dist/nodeinfo/types.test.js +8 -8
- package/dist/{owner-B-7Ptt_m.d.cts → owner-BN_tO3cY.d.cts} +2 -2
- package/dist/{owner-NFlQJyvM.js → owner-ChSL4aJ7.js} +2 -2
- package/dist/{owner-CQPnQVtf.d.ts → owner-hd9lvQcP.d.ts} +2 -2
- package/dist/{proof-Be1oOYEh.js → proof-BiSCuwyA.js} +3 -3
- package/dist/{proof-Gip91fK7.cjs → proof-ONNmhInb.cjs} +3 -3
- package/dist/{proof-ar9xgPWi.js → proof-x3IBewan.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.js +3 -3
- package/dist/runtime/mod.cjs +6 -6
- package/dist/runtime/mod.d.cts +3 -3
- package/dist/runtime/mod.d.ts +3 -3
- package/dist/runtime/mod.js +6 -6
- package/dist/runtime/multibase/multibase.test.js +8 -8
- package/dist/runtime/url.test.js +5 -5
- package/dist/{send-DkwkMFjJ.js → send-D5fjmUEj.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 +6 -6
- package/dist/sig/mod.d.cts +5 -5
- package/dist/sig/mod.d.ts +5 -5
- package/dist/sig/mod.js +6 -6
- package/dist/sig/owner.test.js +12 -12
- package/dist/sig/proof.test.js +12 -12
- package/dist/testing/docloader.test.js +8 -8
- package/dist/testing/mod.d.ts +272 -0
- package/dist/testing/mod.js +3 -3
- package/dist/{testing-BMBhkcz9.js → testing-tWr1VQxx.js} +2 -2
- package/dist/{type-FCer_9yh.js → type-DaUr3Il7.js} +6944 -2121
- package/dist/{types-CZ_qo9KW.cjs → types-D2Nyz0tR.cjs} +1 -1
- package/dist/{types-CNWeAz8v.js → types-DQuSDtDg.js} +1 -1
- package/dist/vocab/actor.test.js +10 -10
- package/dist/vocab/lookup.test.js +259 -9
- package/dist/vocab/mod.cjs +4 -4
- package/dist/vocab/mod.d.cts +3 -3
- package/dist/vocab/mod.d.ts +3 -3
- package/dist/vocab/mod.js +4 -4
- package/dist/vocab/type.test.js +3 -3
- package/dist/vocab/vocab.test.js +402 -13
- package/dist/{vocab-SOE1ifCr.d.ts → vocab-BI0Ak5lL.d.ts} +290 -0
- package/dist/{vocab-9MjZjuZb.cjs → vocab-Dd4VMrr0.cjs} +23 -14
- package/dist/{vocab-DJTYMqyU.d.cts → vocab-Dw1-yVGg.d.cts} +290 -0
- package/dist/{vocab-gpwUU9fc.js → vocab-w--qk7HF.js} +23 -14
- package/dist/webfinger/handler.test.js +23 -22
- package/dist/webfinger/lookup.test.js +9 -9
- package/dist/webfinger/mod.cjs +2 -2
- package/dist/webfinger/mod.js +2 -2
- package/dist/x/cfworkers.test.js +8 -8
- package/dist/x/hono.d.cts +6 -6
- package/dist/x/hono.d.ts +6 -6
- package/dist/x/sveltekit.d.cts +6 -6
- package/dist/x/sveltekit.d.ts +6 -6
- package/package.json +1 -1
- package/dist/key-CV3FT32G.cjs +0 -10
- package/dist/middleware-CV-OPMlZ.js +0 -17
- package/dist/middleware-DGqnaAbp.cjs +0 -17
- package/dist/middleware-cCdfTTMv.js +0 -25
- /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
@@ -3,15 +3,15 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
|
5
5
|
import { getDefaultActivityTransformers } from "./transformers-BFT6d7J5.js";
|
6
|
-
import { deno_default, getDocumentLoader, kvCache } from "./docloader-
|
7
|
-
import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, getTypeId } from "./actor-
|
8
|
-
import { lookupWebFinger } from "./lookup-
|
9
|
-
import { exportJwk, importJwk, validateCryptoKey } from "./key-
|
10
|
-
import { doubleKnock, verifyRequest } from "./http-
|
11
|
-
import { detachSignature, doesActorOwnKey, getKeyOwner, hasSignature, signJsonLd, signObject, verifyJsonLd, verifyObject } from "./proof-
|
12
|
-
import { getNodeInfo, nodeInfoToJson } from "./types-
|
13
|
-
import { getAuthenticatedDocumentLoader } from "./authdocloader-
|
14
|
-
import { lookupObject, traverseCollection } from "./vocab-
|
6
|
+
import { deno_default, getDocumentLoader, kvCache } from "./docloader-Czl3xV10.js";
|
7
|
+
import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, getTypeId } from "./actor-DoMcqXsW.js";
|
8
|
+
import { lookupWebFinger } from "./lookup-Dhm78GlK.js";
|
9
|
+
import { exportJwk, importJwk, validateCryptoKey } from "./key-BNJQQm3h.js";
|
10
|
+
import { doubleKnock, verifyRequest } from "./http-C_Qc2neP.js";
|
11
|
+
import { detachSignature, doesActorOwnKey, getKeyOwner, hasSignature, signJsonLd, signObject, verifyJsonLd, verifyObject } from "./proof-BiSCuwyA.js";
|
12
|
+
import { getNodeInfo, nodeInfoToJson } from "./types-DQuSDtDg.js";
|
13
|
+
import { getAuthenticatedDocumentLoader } from "./authdocloader-Cv_qEn1G.js";
|
14
|
+
import { lookupObject, traverseCollection } from "./vocab-w--qk7HF.js";
|
15
15
|
import { getLogger, withContext } from "@logtape/logtape";
|
16
16
|
import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
|
17
17
|
import { encodeHex } from "byte-encodings/hex";
|
@@ -55,17 +55,34 @@ var InboxListenerSet = class InboxListenerSet {
|
|
55
55
|
return this.dispatchWithClass(activity)?.listener ?? null;
|
56
56
|
}
|
57
57
|
};
|
58
|
-
async function routeActivity({ context: ctx, json, activity, recipient, inboxListeners, inboxContextFactory, inboxErrorHandler, kv, kvPrefixes, queue, span, tracerProvider }) {
|
58
|
+
async function routeActivity({ context: ctx, json, activity, recipient, inboxListeners, inboxContextFactory, inboxErrorHandler, kv, kvPrefixes, queue, span, tracerProvider, idempotencyStrategy }) {
|
59
59
|
const logger$1 = getLogger([
|
60
60
|
"fedify",
|
61
61
|
"federation",
|
62
62
|
"inbox"
|
63
63
|
]);
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
let cacheKey = null;
|
65
|
+
if (activity.id != null) {
|
66
|
+
const inboxContext = inboxContextFactory(recipient, json, activity.id?.href, getTypeId(activity).href);
|
67
|
+
const strategy = idempotencyStrategy ?? "per-inbox";
|
68
|
+
let keyString;
|
69
|
+
if (typeof strategy === "function") {
|
70
|
+
const result = await strategy(inboxContext, activity);
|
71
|
+
keyString = result;
|
72
|
+
} else switch (strategy) {
|
73
|
+
case "global":
|
74
|
+
keyString = activity.id.href;
|
75
|
+
break;
|
76
|
+
case "per-origin":
|
77
|
+
keyString = `${ctx.origin}\n${activity.id.href}`;
|
78
|
+
break;
|
79
|
+
case "per-inbox":
|
80
|
+
keyString = `${ctx.origin}\n${activity.id.href}\n${recipient == null ? "sharedInbox" : `inbox\n${recipient}`}`;
|
81
|
+
break;
|
82
|
+
default: keyString = `${ctx.origin}\n${activity.id.href}`;
|
83
|
+
}
|
84
|
+
if (keyString != null) cacheKey = [...kvPrefixes.activityIdempotence, keyString];
|
85
|
+
}
|
69
86
|
if (cacheKey != null) {
|
70
87
|
const cached = await kv.get(cacheKey);
|
71
88
|
if (cached === true) {
|
@@ -307,6 +324,7 @@ var FederationBuilderImpl = class {
|
|
307
324
|
inboxListeners;
|
308
325
|
inboxErrorHandler;
|
309
326
|
sharedInboxKeyDispatcher;
|
327
|
+
idempotencyStrategy;
|
310
328
|
collectionTypeIds;
|
311
329
|
collectionCallbacks;
|
312
330
|
/**
|
@@ -321,7 +339,7 @@ var FederationBuilderImpl = class {
|
|
321
339
|
this.collectionTypeIds = {};
|
322
340
|
}
|
323
341
|
async build(options) {
|
324
|
-
const { FederationImpl: FederationImpl$1 } = await import("./middleware-
|
342
|
+
const { FederationImpl: FederationImpl$1 } = await import("./middleware-T-knSMwl.js");
|
325
343
|
const f = new FederationImpl$1(options);
|
326
344
|
const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
|
327
345
|
f.router = this.router.clone();
|
@@ -343,6 +361,7 @@ var FederationBuilderImpl = class {
|
|
343
361
|
f.inboxListeners = this.inboxListeners?.clone();
|
344
362
|
f.inboxErrorHandler = this.inboxErrorHandler;
|
345
363
|
f.sharedInboxKeyDispatcher = this.sharedInboxKeyDispatcher;
|
364
|
+
f.idempotencyStrategy = this.idempotencyStrategy;
|
346
365
|
return f;
|
347
366
|
}
|
348
367
|
_getTracer() {
|
@@ -765,6 +784,10 @@ var FederationBuilderImpl = class {
|
|
765
784
|
setSharedKeyDispatcher: (dispatcher) => {
|
766
785
|
this.sharedInboxKeyDispatcher = dispatcher;
|
767
786
|
return setters;
|
787
|
+
},
|
788
|
+
withIdempotency: (strategy) => {
|
789
|
+
this.idempotencyStrategy = strategy;
|
790
|
+
return setters;
|
768
791
|
}
|
769
792
|
};
|
770
793
|
return setters;
|
@@ -979,9 +1002,6 @@ function preferredMediaTypes(accept) {
|
|
979
1002
|
const accepts = parseAccept(accept === void 0 ? "*/*" : accept ?? "");
|
980
1003
|
return accepts.filter(isQuality).sort(compareSpecs).map(getFullType);
|
981
1004
|
}
|
982
|
-
|
983
|
-
//#endregion
|
984
|
-
//#region src/federation/handler.ts
|
985
1005
|
function acceptsJsonLd(request) {
|
986
1006
|
const accept = request.headers.get("Accept");
|
987
1007
|
const types = accept ? preferredMediaTypes(accept) : ["*/*"];
|
@@ -989,6 +1009,9 @@ function acceptsJsonLd(request) {
|
|
989
1009
|
if (types[0] === "text/html" || types[0] === "application/xhtml+xml") return false;
|
990
1010
|
return types.includes("application/activity+json") || types.includes("application/ld+json") || types.includes("application/json");
|
991
1011
|
}
|
1012
|
+
|
1013
|
+
//#endregion
|
1014
|
+
//#region src/federation/handler.ts
|
992
1015
|
/**
|
993
1016
|
* Handles an actor request.
|
994
1017
|
* @template TContextData The context data to pass to the context.
|
@@ -996,7 +1019,7 @@ function acceptsJsonLd(request) {
|
|
996
1019
|
* @param parameters The parameters for handling the actor.
|
997
1020
|
* @returns A promise that resolves to an HTTP response.
|
998
1021
|
*/
|
999
|
-
async function handleActor(request, { identifier, context: context$1, actorDispatcher, authorizePredicate, onNotFound,
|
1022
|
+
async function handleActor(request, { identifier, context: context$1, actorDispatcher, authorizePredicate, onNotFound, onUnauthorized }) {
|
1000
1023
|
const logger$1 = getLogger([
|
1001
1024
|
"fedify",
|
1002
1025
|
"federation",
|
@@ -1011,7 +1034,6 @@ async function handleActor(request, { identifier, context: context$1, actorDispa
|
|
1011
1034
|
logger$1.debug("Actor {identifier} not found.", { identifier });
|
1012
1035
|
return await onNotFound(request);
|
1013
1036
|
}
|
1014
|
-
if (!acceptsJsonLd(request)) return await onNotAcceptable(request);
|
1015
1037
|
if (authorizePredicate != null) {
|
1016
1038
|
let key = await context$1.getSignedKey();
|
1017
1039
|
key = key?.clone({}, { $warning: {
|
@@ -1046,11 +1068,10 @@ async function handleActor(request, { identifier, context: context$1, actorDispa
|
|
1046
1068
|
* @param parameters The parameters for handling the object.
|
1047
1069
|
* @returns A promise that resolves to an HTTP response.
|
1048
1070
|
*/
|
1049
|
-
async function handleObject(request, { values, context: context$1, objectDispatcher, authorizePredicate, onNotFound,
|
1071
|
+
async function handleObject(request, { values, context: context$1, objectDispatcher, authorizePredicate, onNotFound, onUnauthorized }) {
|
1050
1072
|
if (objectDispatcher == null) return await onNotFound(request);
|
1051
1073
|
const object = await objectDispatcher(context$1, values);
|
1052
1074
|
if (object == null) return await onNotFound(request);
|
1053
|
-
if (!acceptsJsonLd(request)) return await onNotAcceptable(request);
|
1054
1075
|
if (authorizePredicate != null) {
|
1055
1076
|
let key = await context$1.getSignedKey();
|
1056
1077
|
key = key?.clone({}, { $warning: {
|
@@ -1088,7 +1109,7 @@ async function handleObject(request, { values, context: context$1, objectDispatc
|
|
1088
1109
|
* @param parameters The parameters for handling the collection.
|
1089
1110
|
* @returns A promise that resolves to an HTTP response.
|
1090
1111
|
*/
|
1091
|
-
async function handleCollection(request, { name, identifier, uriGetter, filter, filterPredicate, context: context$1, collectionCallbacks, tracerProvider, onUnauthorized, onNotFound
|
1112
|
+
async function handleCollection(request, { name, identifier, uriGetter, filter, filterPredicate, context: context$1, collectionCallbacks, tracerProvider, onUnauthorized, onNotFound }) {
|
1092
1113
|
const spanName = name.trim().replace(/\s+/g, "_");
|
1093
1114
|
tracerProvider = tracerProvider ?? trace.getTracerProvider();
|
1094
1115
|
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
@@ -1201,7 +1222,6 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
|
|
1201
1222
|
partOf
|
1202
1223
|
});
|
1203
1224
|
}
|
1204
|
-
if (!acceptsJsonLd(request)) return await onNotAcceptable(request);
|
1205
1225
|
if (collectionCallbacks.authorizePredicate != null) {
|
1206
1226
|
let key = await context$1.getSignedKey();
|
1207
1227
|
key = key?.clone({}, { $warning: {
|
@@ -1296,7 +1316,8 @@ async function handleInbox(request, options) {
|
|
1296
1316
|
* @param span The OpenTelemetry span for tracing.
|
1297
1317
|
* @returns A promise that resolves to an HTTP response.
|
1298
1318
|
*/
|
1299
|
-
async function handleInboxInternal(request,
|
1319
|
+
async function handleInboxInternal(request, parameters, span) {
|
1320
|
+
const { recipient, context: ctx, inboxContextFactory, kv, kvPrefixes, queue, actorDispatcher, inboxListeners, inboxErrorHandler, onNotFound, signatureTimeWindow, skipSignatureVerification, tracerProvider } = parameters;
|
1300
1321
|
const logger$1 = getLogger([
|
1301
1322
|
"fedify",
|
1302
1323
|
"federation",
|
@@ -1498,7 +1519,8 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
|
|
1498
1519
|
kvPrefixes,
|
1499
1520
|
queue,
|
1500
1521
|
span,
|
1501
|
-
tracerProvider
|
1522
|
+
tracerProvider,
|
1523
|
+
idempotencyStrategy: parameters.idempotencyStrategy
|
1502
1524
|
});
|
1503
1525
|
if (routeResult === "alreadyProcessed") return new Response(`Activity <${activity.id}> has already been processed.`, {
|
1504
1526
|
status: 202,
|
@@ -1539,7 +1561,6 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
|
|
1539
1561
|
const handleCustomCollection = exceptWrapper(_handleCustomCollection);
|
1540
1562
|
async function _handleCustomCollection(request, { name, values, context: context$1, tracerProvider, collectionCallbacks: callbacks, filterPredicate }) {
|
1541
1563
|
verifyDefined(callbacks);
|
1542
|
-
verifyJsonLdRequest(request);
|
1543
1564
|
await authIfNeeded(context$1, values, callbacks);
|
1544
1565
|
const cursor = new URL(request.url).searchParams.get("cursor");
|
1545
1566
|
return await new CustomCollectionHandler(name, values, context$1, callbacks, tracerProvider, Collection, CollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
|
@@ -1558,7 +1579,6 @@ async function _handleCustomCollection(request, { name, values, context: context
|
|
1558
1579
|
const handleOrderedCollection = exceptWrapper(_handleOrderedCollection);
|
1559
1580
|
async function _handleOrderedCollection(request, { name, values, context: context$1, tracerProvider, collectionCallbacks: callbacks, filterPredicate }) {
|
1560
1581
|
verifyDefined(callbacks);
|
1561
|
-
verifyJsonLdRequest(request);
|
1562
1582
|
await authIfNeeded(context$1, values, callbacks);
|
1563
1583
|
const cursor = new URL(request.url).searchParams.get("cursor");
|
1564
1584
|
return await new CustomCollectionHandler(name, values, context$1, callbacks, tracerProvider, OrderedCollection, OrderedCollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
|
@@ -1836,10 +1856,9 @@ function exceptWrapper(handler) {
|
|
1836
1856
|
try {
|
1837
1857
|
return await handler(request, handlerParams);
|
1838
1858
|
} catch (error) {
|
1839
|
-
const { onNotFound,
|
1859
|
+
const { onNotFound, onUnauthorized } = handlerParams;
|
1840
1860
|
switch (error?.constructor) {
|
1841
1861
|
case ItemsNotFoundError: return await onNotFound(request);
|
1842
|
-
case NotAcceptableError: return await onNotAcceptable(request);
|
1843
1862
|
case UnauthorizedError: return await onUnauthorized(request);
|
1844
1863
|
default: throw error;
|
1845
1864
|
}
|
@@ -1857,15 +1876,6 @@ const verifyDefined = (callbacks) => {
|
|
1857
1876
|
if (callbacks === void 0) throw new ItemsNotFoundError();
|
1858
1877
|
};
|
1859
1878
|
/**
|
1860
|
-
* Verifies that a request accepts JSON-LD content type.
|
1861
|
-
* @param request The HTTP request to verify.
|
1862
|
-
* @throws {NotAcceptableError} If the request doesn't accept JSON-LD.
|
1863
|
-
* @since 1.8.0
|
1864
|
-
*/
|
1865
|
-
const verifyJsonLdRequest = (request) => {
|
1866
|
-
if (!acceptsJsonLd(request)) throw new NotAcceptableError();
|
1867
|
-
};
|
1868
|
-
/**
|
1869
1879
|
* Performs authorization if needed based on the authorization predicate.
|
1870
1880
|
* @template TContextData The context data type.
|
1871
1881
|
* @param {RequestContext<TContextData>} context The request context.
|
@@ -1949,15 +1959,6 @@ var ItemsNotFoundError = class extends HandlerError {
|
|
1949
1959
|
}
|
1950
1960
|
};
|
1951
1961
|
/**
|
1952
|
-
* Error thrown when the request is not acceptable (e.g., wrong content type).
|
1953
|
-
* @since 1.8.0
|
1954
|
-
*/
|
1955
|
-
var NotAcceptableError = class extends HandlerError {
|
1956
|
-
constructor() {
|
1957
|
-
super("The request is not acceptable.");
|
1958
|
-
}
|
1959
|
-
};
|
1960
|
-
/**
|
1961
1962
|
* Error thrown when access to a collection is unauthorized.
|
1962
1963
|
* @since 1.8.0
|
1963
1964
|
*/
|
@@ -2349,7 +2350,6 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2349
2350
|
firstKnock;
|
2350
2351
|
constructor(options) {
|
2351
2352
|
super();
|
2352
|
-
const logger$1 = getLogger(["fedify", "federation"]);
|
2353
2353
|
this.kv = options.kv;
|
2354
2354
|
this.kvPrefixes = {
|
2355
2355
|
activityIdempotence: ["_fedify", "activityIdempotence"],
|
@@ -2397,8 +2397,9 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2397
2397
|
this.router.trailingSlashInsensitive = options.trailingSlashInsensitive ?? false;
|
2398
2398
|
this._initializeRouter();
|
2399
2399
|
if (options.allowPrivateAddress || options.userAgent != null) {
|
2400
|
-
if (options.
|
2401
|
-
|
2400
|
+
if (options.documentLoaderFactory != null) throw new TypeError("Cannot set documentLoaderFactory with allowPrivateAddress or userAgent options.");
|
2401
|
+
if (options.contextLoaderFactory != null) throw new TypeError("Cannot set contextLoaderFactory with allowPrivateAddress or userAgent options.");
|
2402
|
+
if (options.authenticatedDocumentLoaderFactory != null) throw new TypeError("Cannot set authenticatedDocumentLoaderFactory with allowPrivateAddress or userAgent options.");
|
2402
2403
|
}
|
2403
2404
|
const { allowPrivateAddress, userAgent } = options;
|
2404
2405
|
this.allowPrivateAddress = allowPrivateAddress ?? false;
|
@@ -2412,11 +2413,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2412
2413
|
prefix: this.kvPrefixes.remoteDocument
|
2413
2414
|
});
|
2414
2415
|
});
|
2415
|
-
|
2416
|
-
if (options.contextLoaderFactory != null) throw new TypeError("Cannot set both contextLoader and contextLoaderFactory options at a time; use contextLoaderFactory only.");
|
2417
|
-
this.contextLoaderFactory = () => options.contextLoader;
|
2418
|
-
logger$1.warn("The contextLoader option is deprecated; use contextLoaderFactory option instead.");
|
2419
|
-
} else this.contextLoaderFactory = options.contextLoaderFactory ?? this.documentLoaderFactory;
|
2416
|
+
this.contextLoaderFactory = options.contextLoaderFactory ?? this.documentLoaderFactory;
|
2420
2417
|
this.authenticatedDocumentLoaderFactory = options.authenticatedDocumentLoaderFactory ?? ((identity) => getAuthenticatedDocumentLoader(identity, {
|
2421
2418
|
allowPrivateAddress,
|
2422
2419
|
userAgent,
|
@@ -2955,6 +2952,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2955
2952
|
span,
|
2956
2953
|
tracer
|
2957
2954
|
});
|
2955
|
+
if (acceptsJsonLd(request)) response.headers.set("Vary", "Accept");
|
2958
2956
|
} catch (error) {
|
2959
2957
|
span.setStatus({
|
2960
2958
|
code: SpanStatusCode.ERROR,
|
@@ -3018,6 +3016,9 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3018
3016
|
context: context$1,
|
3019
3017
|
nodeInfoDispatcher: this.nodeInfoDispatcher
|
3020
3018
|
});
|
3019
|
+
}
|
3020
|
+
if (request.method !== "POST" && !acceptsJsonLd(request)) return await onNotAcceptable(request);
|
3021
|
+
switch (routeName) {
|
3021
3022
|
case "actor":
|
3022
3023
|
context$1 = this.#createContext(request, contextData, { invokedFromActorDispatcher: { identifier: route.values.identifier ?? route.values.handle } });
|
3023
3024
|
return await handleActor(request, {
|
@@ -3026,8 +3027,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3026
3027
|
actorDispatcher: this.actorCallbacks?.dispatcher,
|
3027
3028
|
authorizePredicate: this.actorCallbacks?.authorizePredicate,
|
3028
3029
|
onUnauthorized,
|
3029
|
-
onNotFound
|
3030
|
-
onNotAcceptable
|
3030
|
+
onNotFound
|
3031
3031
|
});
|
3032
3032
|
case "object": {
|
3033
3033
|
const typeId = route.name.replace(/^object:/, "");
|
@@ -3043,8 +3043,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3043
3043
|
objectDispatcher: callbacks?.dispatcher,
|
3044
3044
|
authorizePredicate: callbacks?.authorizePredicate,
|
3045
3045
|
onUnauthorized,
|
3046
|
-
onNotFound
|
3047
|
-
onNotAcceptable
|
3046
|
+
onNotFound
|
3048
3047
|
});
|
3049
3048
|
}
|
3050
3049
|
case "outbox": return await handleCollection(request, {
|
@@ -3055,8 +3054,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3055
3054
|
collectionCallbacks: this.outboxCallbacks,
|
3056
3055
|
tracerProvider: this.tracerProvider,
|
3057
3056
|
onUnauthorized,
|
3058
|
-
onNotFound
|
3059
|
-
onNotAcceptable
|
3057
|
+
onNotFound
|
3060
3058
|
});
|
3061
3059
|
case "inbox":
|
3062
3060
|
if (request.method !== "POST") return await handleCollection(request, {
|
@@ -3067,8 +3065,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3067
3065
|
collectionCallbacks: this.inboxCallbacks,
|
3068
3066
|
tracerProvider: this.tracerProvider,
|
3069
3067
|
onUnauthorized,
|
3070
|
-
onNotFound
|
3071
|
-
onNotAcceptable
|
3068
|
+
onNotFound
|
3072
3069
|
});
|
3073
3070
|
context$1 = this.#createContext(request, contextData, { documentLoader: await context$1.getDocumentLoader({ identifier: route.values.identifier ?? route.values.handle }) });
|
3074
3071
|
case "sharedInbox":
|
@@ -3090,7 +3087,8 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3090
3087
|
onNotFound,
|
3091
3088
|
signatureTimeWindow: this.signatureTimeWindow,
|
3092
3089
|
skipSignatureVerification: this.skipSignatureVerification,
|
3093
|
-
tracerProvider: this.tracerProvider
|
3090
|
+
tracerProvider: this.tracerProvider,
|
3091
|
+
idempotencyStrategy: this.idempotencyStrategy
|
3094
3092
|
});
|
3095
3093
|
case "following": return await handleCollection(request, {
|
3096
3094
|
name: "following",
|
@@ -3100,8 +3098,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3100
3098
|
collectionCallbacks: this.followingCallbacks,
|
3101
3099
|
tracerProvider: this.tracerProvider,
|
3102
3100
|
onUnauthorized,
|
3103
|
-
onNotFound
|
3104
|
-
onNotAcceptable
|
3101
|
+
onNotFound
|
3105
3102
|
});
|
3106
3103
|
case "followers": {
|
3107
3104
|
let baseUrl = url.searchParams.get("base-url");
|
@@ -3124,8 +3121,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3124
3121
|
collectionCallbacks: this.followersCallbacks,
|
3125
3122
|
tracerProvider: this.tracerProvider,
|
3126
3123
|
onUnauthorized,
|
3127
|
-
onNotFound
|
3128
|
-
onNotAcceptable
|
3124
|
+
onNotFound
|
3129
3125
|
});
|
3130
3126
|
}
|
3131
3127
|
case "liked": return await handleCollection(request, {
|
@@ -3136,8 +3132,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3136
3132
|
collectionCallbacks: this.likedCallbacks,
|
3137
3133
|
tracerProvider: this.tracerProvider,
|
3138
3134
|
onUnauthorized,
|
3139
|
-
onNotFound
|
3140
|
-
onNotAcceptable
|
3135
|
+
onNotFound
|
3141
3136
|
});
|
3142
3137
|
case "featured": return await handleCollection(request, {
|
3143
3138
|
name: "featured",
|
@@ -3147,8 +3142,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3147
3142
|
collectionCallbacks: this.featuredCallbacks,
|
3148
3143
|
tracerProvider: this.tracerProvider,
|
3149
3144
|
onUnauthorized,
|
3150
|
-
onNotFound
|
3151
|
-
onNotAcceptable
|
3145
|
+
onNotFound
|
3152
3146
|
});
|
3153
3147
|
case "featuredTags": return await handleCollection(request, {
|
3154
3148
|
name: "featured tags",
|
@@ -3158,8 +3152,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3158
3152
|
collectionCallbacks: this.featuredTagsCallbacks,
|
3159
3153
|
tracerProvider: this.tracerProvider,
|
3160
3154
|
onUnauthorized,
|
3161
|
-
onNotFound
|
3162
|
-
onNotAcceptable
|
3155
|
+
onNotFound
|
3163
3156
|
});
|
3164
3157
|
case "collection": {
|
3165
3158
|
const name = route.name.replace(/^collection:/, "");
|
@@ -3171,8 +3164,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3171
3164
|
collectionCallbacks: callbacks,
|
3172
3165
|
tracerProvider: this.tracerProvider,
|
3173
3166
|
onUnauthorized,
|
3174
|
-
onNotFound
|
3175
|
-
onNotAcceptable
|
3167
|
+
onNotFound
|
3176
3168
|
});
|
3177
3169
|
}
|
3178
3170
|
case "orderedCollection": {
|
@@ -3185,8 +3177,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3185
3177
|
collectionCallbacks: callbacks,
|
3186
3178
|
tracerProvider: this.tracerProvider,
|
3187
3179
|
onUnauthorized,
|
3188
|
-
onNotFound
|
3189
|
-
onNotAcceptable
|
3180
|
+
onNotFound
|
3190
3181
|
});
|
3191
3182
|
}
|
3192
3183
|
default: {
|
@@ -3840,7 +3831,8 @@ var ContextImpl = class ContextImpl {
|
|
3840
3831
|
kvPrefixes: this.federation.kvPrefixes,
|
3841
3832
|
queue: this.federation.inboxQueue,
|
3842
3833
|
span,
|
3843
|
-
tracerProvider: options.tracerProvider ?? this.tracerProvider
|
3834
|
+
tracerProvider: options.tracerProvider ?? this.tracerProvider,
|
3835
|
+
idempotencyStrategy: this.federation.idempotencyStrategy
|
3844
3836
|
});
|
3845
3837
|
return routeResult === "alreadyProcessed" || routeResult === "enqueued" || routeResult === "unsupportedActivity" || routeResult === "success";
|
3846
3838
|
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
3
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
4
|
+
|
5
|
+
require('./transformers-CoBS-oFG.cjs');
|
6
|
+
require('./docloader-CYnQRIXv.cjs');
|
7
|
+
require('./actor-CwZ2m5rG.cjs');
|
8
|
+
const require_middleware = require('./middleware-Dgmdgrvb.cjs');
|
9
|
+
require('./lookup-D6dro5Au.cjs');
|
10
|
+
require('./key-DuXv64tg.cjs');
|
11
|
+
require('./http-CAusBl_3.cjs');
|
12
|
+
require('./proof-ONNmhInb.cjs');
|
13
|
+
require('./types-D2Nyz0tR.cjs');
|
14
|
+
require('./authdocloader-bsmVF6eO.cjs');
|
15
|
+
require('./vocab-Dd4VMrr0.cjs');
|
16
|
+
|
17
|
+
exports.FederationImpl = require_middleware.FederationImpl;
|