@fedify/fedify 2.0.0-dev.1641 → 2.0.0-dev.1690
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-CP03csrm.cjs → actor-Be0ThtXy.cjs} +7263 -2440
- package/dist/{actor-DU511yTk.js → actor-ChbPLm6n.js} +7263 -2440
- package/dist/{actor-DMgu-ZjT.d.cts → actor-D6K058Tb.d.cts} +1 -1
- package/dist/{actor-DVpsNXhn.js → actor-DuCeRiNh.js} +1 -1
- 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-BkIZCKQv.js → authdocloader-Brax1A32.js} +3 -3
- package/dist/{authdocloader-DCgMyo82.js → authdocloader-CrxhFL8e.js} +3 -3
- package/dist/{authdocloader-BnsFSERg.cjs → authdocloader-OSn_teLV.cjs} +3 -3
- package/dist/{builder-E2Icrl_a.js → builder-CYOcDUkj.js} +10 -4
- package/dist/{client-BW4V0OJx.js → client-CnOdwLLN.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-ByZprN0S.d.ts} +66 -6
- package/dist/{context-Dq8aCtMH.d.cts → context-C5BsZkDr.d.cts} +66 -6
- package/dist/{docloader-kae6M-GI.cjs → docloader-CCqXeagZ.cjs} +2 -2
- package/dist/{docloader-BtqIh1OE.js → docloader-XK3y2jn5.js} +2 -2
- package/dist/{esm-mtx3XJAD.js → esm-DnIzfEj0.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 +232 -38
- 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-Cox5GsED.js → http-BNOYnVsU.js} +2 -2
- package/dist/{http-C7uYFcBo.js → http-BxbM8sEy.js} +3 -3
- package/dist/{http-ZhcoaYEa.cjs → http-C7vbQwbz.cjs} +3 -3
- 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-BDdRbWNI.js → inbox-BRru9pX3.js} +24 -7
- package/dist/{key-CfiBDu3o.js → key-1KXru8Ug.js} +2 -2
- package/dist/{key-B9Z5ZuX9.js → key-B3uag-rz.js} +4 -4
- package/dist/key-BiBmb1Yy.cjs +10 -0
- package/dist/{key-CgwCzDC4.js → key-DK_nfU4I.js} +3 -3
- package/dist/{key-HqzOCwDc.cjs → key-Z6ceKnZC.cjs} +2 -2
- package/dist/{key-Cc0JlcKe.js → key-jyNTxCvK.js} +2 -2
- package/dist/{keycache-CVBjz3xi.js → keycache-CN61iGVj.js} +1 -1
- package/dist/{keys-CBKbYaJA.js → keys-BPdFKgiy.js} +1 -1
- package/dist/{ld-CxgmnSO3.js → ld-Dv8DNNAT.js} +2 -2
- package/dist/{lookup-NuT9cCSl.js → lookup-BPviO8ij.js} +1 -1
- package/dist/{lookup-QHjmy4Og.cjs → lookup-hnMAAU5r.cjs} +1 -1
- package/dist/{lookup-CiU3QxQz.js → lookup-pV0JOsuV.js} +21 -12
- package/dist/{middleware-LyCG_YVM.cjs → middleware-BmoOlgc1.cjs} +69 -73
- package/dist/{middleware-DXidHY4N.js → middleware-Bz_A2jeJ.js} +69 -73
- package/dist/middleware-CI0-zw4U.js +26 -0
- package/dist/{middleware-ByPnvMMS.js → middleware-DY9B2lL8.js} +43 -134
- package/dist/middleware-QNK-W-jE.cjs +17 -0
- package/dist/middleware-_vjt6FWU.js +17 -0
- package/dist/{mod-BhMnAkFX.d.cts → mod-8DMWKtQE.d.cts} +2 -2
- package/dist/{mod-Drmz72EK.d.ts → mod-BhUKmBJD.d.ts} +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-D6hQoxC5.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-Cxob5_PK.js → owner-e3FYDhsk.js} +2 -2
- package/dist/{owner-CQPnQVtf.d.ts → owner-hd9lvQcP.d.ts} +2 -2
- package/dist/{proof-BiSQNUmQ.js → proof-6gFMwMNJ.js} +2 -2
- package/dist/{proof-2Gcor0_N.cjs → proof-B-eqv0Ug.cjs} +3 -3
- package/dist/{proof-DkxwMaWE.js → proof-DfgvA3al.js} +3 -3
- 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-DSEhWIYD.js → send-Tl9NOnmO.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-ByQmUvf-.js → testing-BWNCAbL-.js} +2 -2
- package/dist/{type-B4NJkfVg.js → type-C69ZBu7f.js} +6944 -2121
- package/dist/{types-l2uh_ZhP.js → types-DqxyTxOf.js} +1 -1
- package/dist/{types-Bqt2EgP0.cjs → types-zqdWZh4O.cjs} +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-B0-5a8pw.cjs → vocab-B39-pFl9.cjs} +23 -14
- package/dist/{vocab-SOE1ifCr.d.ts → vocab-BI0Ak5lL.d.ts} +290 -0
- package/dist/{vocab-lBFcVxVF.js → vocab-BWoeZsME.js} +23 -14
- package/dist/{vocab-DJTYMqyU.d.cts → vocab-Dw1-yVGg.d.cts} +290 -0
- 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-D-7DPHNl.cjs +0 -10
- package/dist/middleware-BHboQ4BE.js +0 -25
- package/dist/middleware-Bp3I9z8r.js +0 -17
- package/dist/middleware-oYqSU5ky.cjs +0 -17
- /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-XK3y2jn5.js";
|
7
|
+
import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, getTypeId } from "./actor-ChbPLm6n.js";
|
8
|
+
import { lookupWebFinger } from "./lookup-BPviO8ij.js";
|
9
|
+
import { exportJwk, importJwk, validateCryptoKey } from "./key-jyNTxCvK.js";
|
10
|
+
import { doubleKnock, verifyRequest } from "./http-BxbM8sEy.js";
|
11
|
+
import { detachSignature, doesActorOwnKey, getKeyOwner, hasSignature, signJsonLd, signObject, verifyJsonLd, verifyObject } from "./proof-DfgvA3al.js";
|
12
|
+
import { getNodeInfo, nodeInfoToJson } from "./types-DqxyTxOf.js";
|
13
|
+
import { getAuthenticatedDocumentLoader } from "./authdocloader-CrxhFL8e.js";
|
14
|
+
import { lookupObject, traverseCollection } from "./vocab-BWoeZsME.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-_vjt6FWU.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
|
*/
|
@@ -2955,6 +2956,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2955
2956
|
span,
|
2956
2957
|
tracer
|
2957
2958
|
});
|
2959
|
+
if (acceptsJsonLd(request)) response.headers.set("Vary", "Accept");
|
2958
2960
|
} catch (error) {
|
2959
2961
|
span.setStatus({
|
2960
2962
|
code: SpanStatusCode.ERROR,
|
@@ -3018,6 +3020,9 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3018
3020
|
context: context$1,
|
3019
3021
|
nodeInfoDispatcher: this.nodeInfoDispatcher
|
3020
3022
|
});
|
3023
|
+
}
|
3024
|
+
if (request.method !== "POST" && !acceptsJsonLd(request)) return await onNotAcceptable(request);
|
3025
|
+
switch (routeName) {
|
3021
3026
|
case "actor":
|
3022
3027
|
context$1 = this.#createContext(request, contextData, { invokedFromActorDispatcher: { identifier: route.values.identifier ?? route.values.handle } });
|
3023
3028
|
return await handleActor(request, {
|
@@ -3026,8 +3031,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3026
3031
|
actorDispatcher: this.actorCallbacks?.dispatcher,
|
3027
3032
|
authorizePredicate: this.actorCallbacks?.authorizePredicate,
|
3028
3033
|
onUnauthorized,
|
3029
|
-
onNotFound
|
3030
|
-
onNotAcceptable
|
3034
|
+
onNotFound
|
3031
3035
|
});
|
3032
3036
|
case "object": {
|
3033
3037
|
const typeId = route.name.replace(/^object:/, "");
|
@@ -3043,8 +3047,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3043
3047
|
objectDispatcher: callbacks?.dispatcher,
|
3044
3048
|
authorizePredicate: callbacks?.authorizePredicate,
|
3045
3049
|
onUnauthorized,
|
3046
|
-
onNotFound
|
3047
|
-
onNotAcceptable
|
3050
|
+
onNotFound
|
3048
3051
|
});
|
3049
3052
|
}
|
3050
3053
|
case "outbox": return await handleCollection(request, {
|
@@ -3055,8 +3058,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3055
3058
|
collectionCallbacks: this.outboxCallbacks,
|
3056
3059
|
tracerProvider: this.tracerProvider,
|
3057
3060
|
onUnauthorized,
|
3058
|
-
onNotFound
|
3059
|
-
onNotAcceptable
|
3061
|
+
onNotFound
|
3060
3062
|
});
|
3061
3063
|
case "inbox":
|
3062
3064
|
if (request.method !== "POST") return await handleCollection(request, {
|
@@ -3067,8 +3069,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3067
3069
|
collectionCallbacks: this.inboxCallbacks,
|
3068
3070
|
tracerProvider: this.tracerProvider,
|
3069
3071
|
onUnauthorized,
|
3070
|
-
onNotFound
|
3071
|
-
onNotAcceptable
|
3072
|
+
onNotFound
|
3072
3073
|
});
|
3073
3074
|
context$1 = this.#createContext(request, contextData, { documentLoader: await context$1.getDocumentLoader({ identifier: route.values.identifier ?? route.values.handle }) });
|
3074
3075
|
case "sharedInbox":
|
@@ -3090,7 +3091,8 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3090
3091
|
onNotFound,
|
3091
3092
|
signatureTimeWindow: this.signatureTimeWindow,
|
3092
3093
|
skipSignatureVerification: this.skipSignatureVerification,
|
3093
|
-
tracerProvider: this.tracerProvider
|
3094
|
+
tracerProvider: this.tracerProvider,
|
3095
|
+
idempotencyStrategy: this.idempotencyStrategy
|
3094
3096
|
});
|
3095
3097
|
case "following": return await handleCollection(request, {
|
3096
3098
|
name: "following",
|
@@ -3100,8 +3102,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3100
3102
|
collectionCallbacks: this.followingCallbacks,
|
3101
3103
|
tracerProvider: this.tracerProvider,
|
3102
3104
|
onUnauthorized,
|
3103
|
-
onNotFound
|
3104
|
-
onNotAcceptable
|
3105
|
+
onNotFound
|
3105
3106
|
});
|
3106
3107
|
case "followers": {
|
3107
3108
|
let baseUrl = url.searchParams.get("base-url");
|
@@ -3124,8 +3125,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3124
3125
|
collectionCallbacks: this.followersCallbacks,
|
3125
3126
|
tracerProvider: this.tracerProvider,
|
3126
3127
|
onUnauthorized,
|
3127
|
-
onNotFound
|
3128
|
-
onNotAcceptable
|
3128
|
+
onNotFound
|
3129
3129
|
});
|
3130
3130
|
}
|
3131
3131
|
case "liked": return await handleCollection(request, {
|
@@ -3136,8 +3136,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3136
3136
|
collectionCallbacks: this.likedCallbacks,
|
3137
3137
|
tracerProvider: this.tracerProvider,
|
3138
3138
|
onUnauthorized,
|
3139
|
-
onNotFound
|
3140
|
-
onNotAcceptable
|
3139
|
+
onNotFound
|
3141
3140
|
});
|
3142
3141
|
case "featured": return await handleCollection(request, {
|
3143
3142
|
name: "featured",
|
@@ -3147,8 +3146,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3147
3146
|
collectionCallbacks: this.featuredCallbacks,
|
3148
3147
|
tracerProvider: this.tracerProvider,
|
3149
3148
|
onUnauthorized,
|
3150
|
-
onNotFound
|
3151
|
-
onNotAcceptable
|
3149
|
+
onNotFound
|
3152
3150
|
});
|
3153
3151
|
case "featuredTags": return await handleCollection(request, {
|
3154
3152
|
name: "featured tags",
|
@@ -3158,8 +3156,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3158
3156
|
collectionCallbacks: this.featuredTagsCallbacks,
|
3159
3157
|
tracerProvider: this.tracerProvider,
|
3160
3158
|
onUnauthorized,
|
3161
|
-
onNotFound
|
3162
|
-
onNotAcceptable
|
3159
|
+
onNotFound
|
3163
3160
|
});
|
3164
3161
|
case "collection": {
|
3165
3162
|
const name = route.name.replace(/^collection:/, "");
|
@@ -3171,8 +3168,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3171
3168
|
collectionCallbacks: callbacks,
|
3172
3169
|
tracerProvider: this.tracerProvider,
|
3173
3170
|
onUnauthorized,
|
3174
|
-
onNotFound
|
3175
|
-
onNotAcceptable
|
3171
|
+
onNotFound
|
3176
3172
|
});
|
3177
3173
|
}
|
3178
3174
|
case "orderedCollection": {
|
@@ -3185,8 +3181,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3185
3181
|
collectionCallbacks: callbacks,
|
3186
3182
|
tracerProvider: this.tracerProvider,
|
3187
3183
|
onUnauthorized,
|
3188
|
-
onNotFound
|
3189
|
-
onNotAcceptable
|
3184
|
+
onNotFound
|
3190
3185
|
});
|
3191
3186
|
}
|
3192
3187
|
default: {
|
@@ -3840,7 +3835,8 @@ var ContextImpl = class ContextImpl {
|
|
3840
3835
|
kvPrefixes: this.federation.kvPrefixes,
|
3841
3836
|
queue: this.federation.inboxQueue,
|
3842
3837
|
span,
|
3843
|
-
tracerProvider: options.tracerProvider ?? this.tracerProvider
|
3838
|
+
tracerProvider: options.tracerProvider ?? this.tracerProvider,
|
3839
|
+
idempotencyStrategy: this.federation.idempotencyStrategy
|
3844
3840
|
});
|
3845
3841
|
return routeResult === "alreadyProcessed" || routeResult === "enqueued" || routeResult === "unsupportedActivity" || routeResult === "success";
|
3846
3842
|
}
|
@@ -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-C69ZBu7f.js";
|
7
|
+
import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "./middleware-DY9B2lL8.js";
|
8
|
+
import "./client-CnOdwLLN.js";
|
9
|
+
import "./lookup-pV0JOsuV.js";
|
10
|
+
import "./types-BSuWJsOm.js";
|
11
|
+
import "./actor-DuCeRiNh.js";
|
12
|
+
import "./key-1KXru8Ug.js";
|
13
|
+
import "./http-BNOYnVsU.js";
|
14
|
+
import "./authdocloader-Brax1A32.js";
|
15
|
+
import "./ld-Dv8DNNAT.js";
|
16
|
+
import "./owner-e3FYDhsk.js";
|
17
|
+
import "./proof-6gFMwMNJ.js";
|
18
|
+
import "./inbox-BRru9pX3.js";
|
19
|
+
import "./builder-CYOcDUkj.js";
|
20
|
+
import "./collection-CcnIw1qY.js";
|
21
|
+
import "./keycache-CN61iGVj.js";
|
22
|
+
import "./negotiation-5NPJL6zp.js";
|
23
|
+
import "./retry-D4GJ670a.js";
|
24
|
+
import "./send-Tl9NOnmO.js";
|
25
|
+
|
26
|
+
export { FederationImpl };
|