@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,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-DaUr3Il7.js";
|
7
|
+
import { getNodeInfo } from "./client-D5CBsPrc.js";
|
8
|
+
import { RouterError, lookupObject, traverseCollection } from "./lookup-CbtuFbtg.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-DnqhSgAv.js";
|
11
|
+
import { verifyRequest } from "./http-CuS-d4U0.js";
|
12
|
+
import { getAuthenticatedDocumentLoader } from "./authdocloader-DYTNpaMA.js";
|
13
|
+
import { detachSignature, hasSignature, signJsonLd, verifyJsonLd } from "./ld-Isot0tiW.js";
|
14
|
+
import { doesActorOwnKey, getKeyOwner } from "./owner-ChSL4aJ7.js";
|
15
|
+
import { signObject, verifyObject } from "./proof-x3IBewan.js";
|
16
|
+
import { routeActivity } from "./inbox-IETv_Qez.js";
|
17
|
+
import { FederationBuilderImpl } from "./builder-1_skw-d2.js";
|
18
18
|
import { buildCollectionSynchronizationHeader } from "./collection-CcnIw1qY.js";
|
19
|
-
import { KvKeyCache } from "./keycache-
|
20
|
-
import {
|
21
|
-
import {
|
19
|
+
import { KvKeyCache } from "./keycache-CSBkusP8.js";
|
20
|
+
import { acceptsJsonLd } from "./negotiation-5NPJL6zp.js";
|
21
|
+
import { createExponentialBackoffPolicy } from "./retry-D4GJ670a.js";
|
22
|
+
import { extractInboxes, sendActivity } from "./send-D5fjmUEj.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: {
|
@@ -671,7 +604,8 @@ async function handleInbox(request, options) {
|
|
671
604
|
* @param span The OpenTelemetry span for tracing.
|
672
605
|
* @returns A promise that resolves to an HTTP response.
|
673
606
|
*/
|
674
|
-
async function handleInboxInternal(request,
|
607
|
+
async function handleInboxInternal(request, parameters, span) {
|
608
|
+
const { recipient, context: ctx, inboxContextFactory, kv, kvPrefixes, queue, actorDispatcher, inboxListeners, inboxErrorHandler, onNotFound, signatureTimeWindow, skipSignatureVerification, tracerProvider } = parameters;
|
675
609
|
const logger$2 = getLogger([
|
676
610
|
"fedify",
|
677
611
|
"federation",
|
@@ -873,7 +807,8 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
|
|
873
807
|
kvPrefixes,
|
874
808
|
queue,
|
875
809
|
span,
|
876
|
-
tracerProvider
|
810
|
+
tracerProvider,
|
811
|
+
idempotencyStrategy: parameters.idempotencyStrategy
|
877
812
|
});
|
878
813
|
if (routeResult === "alreadyProcessed") return new Response(`Activity <${activity.id}> has already been processed.`, {
|
879
814
|
status: 202,
|
@@ -914,7 +849,6 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
|
|
914
849
|
const handleCustomCollection = exceptWrapper(_handleCustomCollection);
|
915
850
|
async function _handleCustomCollection(request, { name, values, context: context$1, tracerProvider, collectionCallbacks: callbacks, filterPredicate }) {
|
916
851
|
verifyDefined(callbacks);
|
917
|
-
verifyJsonLdRequest(request);
|
918
852
|
await authIfNeeded(context$1, values, callbacks);
|
919
853
|
const cursor = new URL(request.url).searchParams.get("cursor");
|
920
854
|
return await new CustomCollectionHandler(name, values, context$1, callbacks, tracerProvider, Collection, CollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
|
@@ -933,7 +867,6 @@ async function _handleCustomCollection(request, { name, values, context: context
|
|
933
867
|
const handleOrderedCollection = exceptWrapper(_handleOrderedCollection);
|
934
868
|
async function _handleOrderedCollection(request, { name, values, context: context$1, tracerProvider, collectionCallbacks: callbacks, filterPredicate }) {
|
935
869
|
verifyDefined(callbacks);
|
936
|
-
verifyJsonLdRequest(request);
|
937
870
|
await authIfNeeded(context$1, values, callbacks);
|
938
871
|
const cursor = new URL(request.url).searchParams.get("cursor");
|
939
872
|
return await new CustomCollectionHandler(name, values, context$1, callbacks, tracerProvider, OrderedCollection, OrderedCollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
|
@@ -1211,10 +1144,9 @@ function exceptWrapper(handler) {
|
|
1211
1144
|
try {
|
1212
1145
|
return await handler(request, handlerParams);
|
1213
1146
|
} catch (error) {
|
1214
|
-
const { onNotFound,
|
1147
|
+
const { onNotFound, onUnauthorized } = handlerParams;
|
1215
1148
|
switch (error?.constructor) {
|
1216
1149
|
case ItemsNotFoundError: return await onNotFound(request);
|
1217
|
-
case NotAcceptableError: return await onNotAcceptable(request);
|
1218
1150
|
case UnauthorizedError: return await onUnauthorized(request);
|
1219
1151
|
default: throw error;
|
1220
1152
|
}
|
@@ -1232,15 +1164,6 @@ const verifyDefined = (callbacks) => {
|
|
1232
1164
|
if (callbacks === void 0) throw new ItemsNotFoundError();
|
1233
1165
|
};
|
1234
1166
|
/**
|
1235
|
-
* Verifies that a request accepts JSON-LD content type.
|
1236
|
-
* @param request The HTTP request to verify.
|
1237
|
-
* @throws {NotAcceptableError} If the request doesn't accept JSON-LD.
|
1238
|
-
* @since 1.8.0
|
1239
|
-
*/
|
1240
|
-
const verifyJsonLdRequest = (request) => {
|
1241
|
-
if (!acceptsJsonLd(request)) throw new NotAcceptableError();
|
1242
|
-
};
|
1243
|
-
/**
|
1244
1167
|
* Performs authorization if needed based on the authorization predicate.
|
1245
1168
|
* @template TContextData The context data type.
|
1246
1169
|
* @param {RequestContext<TContextData>} context The request context.
|
@@ -1324,15 +1247,6 @@ var ItemsNotFoundError = class extends HandlerError {
|
|
1324
1247
|
}
|
1325
1248
|
};
|
1326
1249
|
/**
|
1327
|
-
* Error thrown when the request is not acceptable (e.g., wrong content type).
|
1328
|
-
* @since 1.8.0
|
1329
|
-
*/
|
1330
|
-
var NotAcceptableError = class extends HandlerError {
|
1331
|
-
constructor() {
|
1332
|
-
super("The request is not acceptable.");
|
1333
|
-
}
|
1334
|
-
};
|
1335
|
-
/**
|
1336
1250
|
* Error thrown when access to a collection is unauthorized.
|
1337
1251
|
* @since 1.8.0
|
1338
1252
|
*/
|
@@ -1405,7 +1319,6 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
1405
1319
|
firstKnock;
|
1406
1320
|
constructor(options) {
|
1407
1321
|
super();
|
1408
|
-
const logger$2 = getLogger(["fedify", "federation"]);
|
1409
1322
|
this.kv = options.kv;
|
1410
1323
|
this.kvPrefixes = {
|
1411
1324
|
activityIdempotence: ["_fedify", "activityIdempotence"],
|
@@ -1453,8 +1366,9 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
1453
1366
|
this.router.trailingSlashInsensitive = options.trailingSlashInsensitive ?? false;
|
1454
1367
|
this._initializeRouter();
|
1455
1368
|
if (options.allowPrivateAddress || options.userAgent != null) {
|
1456
|
-
if (options.
|
1457
|
-
|
1369
|
+
if (options.documentLoaderFactory != null) throw new TypeError("Cannot set documentLoaderFactory with allowPrivateAddress or userAgent options.");
|
1370
|
+
if (options.contextLoaderFactory != null) throw new TypeError("Cannot set contextLoaderFactory with allowPrivateAddress or userAgent options.");
|
1371
|
+
if (options.authenticatedDocumentLoaderFactory != null) throw new TypeError("Cannot set authenticatedDocumentLoaderFactory with allowPrivateAddress or userAgent options.");
|
1458
1372
|
}
|
1459
1373
|
const { allowPrivateAddress, userAgent } = options;
|
1460
1374
|
this.allowPrivateAddress = allowPrivateAddress ?? false;
|
@@ -1468,11 +1382,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
1468
1382
|
prefix: this.kvPrefixes.remoteDocument
|
1469
1383
|
});
|
1470
1384
|
});
|
1471
|
-
|
1472
|
-
if (options.contextLoaderFactory != null) throw new TypeError("Cannot set both contextLoader and contextLoaderFactory options at a time; use contextLoaderFactory only.");
|
1473
|
-
this.contextLoaderFactory = () => options.contextLoader;
|
1474
|
-
logger$2.warn("The contextLoader option is deprecated; use contextLoaderFactory option instead.");
|
1475
|
-
} else this.contextLoaderFactory = options.contextLoaderFactory ?? this.documentLoaderFactory;
|
1385
|
+
this.contextLoaderFactory = options.contextLoaderFactory ?? this.documentLoaderFactory;
|
1476
1386
|
this.authenticatedDocumentLoaderFactory = options.authenticatedDocumentLoaderFactory ?? ((identity) => getAuthenticatedDocumentLoader(identity, {
|
1477
1387
|
allowPrivateAddress,
|
1478
1388
|
userAgent,
|
@@ -2011,6 +1921,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2011
1921
|
span,
|
2012
1922
|
tracer
|
2013
1923
|
});
|
1924
|
+
if (acceptsJsonLd(request)) response.headers.set("Vary", "Accept");
|
2014
1925
|
} catch (error) {
|
2015
1926
|
span.setStatus({
|
2016
1927
|
code: SpanStatusCode.ERROR,
|
@@ -2074,6 +1985,9 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2074
1985
|
context: context$1,
|
2075
1986
|
nodeInfoDispatcher: this.nodeInfoDispatcher
|
2076
1987
|
});
|
1988
|
+
}
|
1989
|
+
if (request.method !== "POST" && !acceptsJsonLd(request)) return await onNotAcceptable(request);
|
1990
|
+
switch (routeName) {
|
2077
1991
|
case "actor":
|
2078
1992
|
context$1 = this.#createContext(request, contextData, { invokedFromActorDispatcher: { identifier: route.values.identifier ?? route.values.handle } });
|
2079
1993
|
return await handleActor(request, {
|
@@ -2082,8 +1996,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2082
1996
|
actorDispatcher: this.actorCallbacks?.dispatcher,
|
2083
1997
|
authorizePredicate: this.actorCallbacks?.authorizePredicate,
|
2084
1998
|
onUnauthorized,
|
2085
|
-
onNotFound
|
2086
|
-
onNotAcceptable
|
1999
|
+
onNotFound
|
2087
2000
|
});
|
2088
2001
|
case "object": {
|
2089
2002
|
const typeId = route.name.replace(/^object:/, "");
|
@@ -2099,8 +2012,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2099
2012
|
objectDispatcher: callbacks?.dispatcher,
|
2100
2013
|
authorizePredicate: callbacks?.authorizePredicate,
|
2101
2014
|
onUnauthorized,
|
2102
|
-
onNotFound
|
2103
|
-
onNotAcceptable
|
2015
|
+
onNotFound
|
2104
2016
|
});
|
2105
2017
|
}
|
2106
2018
|
case "outbox": return await handleCollection(request, {
|
@@ -2111,8 +2023,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2111
2023
|
collectionCallbacks: this.outboxCallbacks,
|
2112
2024
|
tracerProvider: this.tracerProvider,
|
2113
2025
|
onUnauthorized,
|
2114
|
-
onNotFound
|
2115
|
-
onNotAcceptable
|
2026
|
+
onNotFound
|
2116
2027
|
});
|
2117
2028
|
case "inbox":
|
2118
2029
|
if (request.method !== "POST") return await handleCollection(request, {
|
@@ -2123,8 +2034,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2123
2034
|
collectionCallbacks: this.inboxCallbacks,
|
2124
2035
|
tracerProvider: this.tracerProvider,
|
2125
2036
|
onUnauthorized,
|
2126
|
-
onNotFound
|
2127
|
-
onNotAcceptable
|
2037
|
+
onNotFound
|
2128
2038
|
});
|
2129
2039
|
context$1 = this.#createContext(request, contextData, { documentLoader: await context$1.getDocumentLoader({ identifier: route.values.identifier ?? route.values.handle }) });
|
2130
2040
|
case "sharedInbox":
|
@@ -2146,7 +2056,8 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2146
2056
|
onNotFound,
|
2147
2057
|
signatureTimeWindow: this.signatureTimeWindow,
|
2148
2058
|
skipSignatureVerification: this.skipSignatureVerification,
|
2149
|
-
tracerProvider: this.tracerProvider
|
2059
|
+
tracerProvider: this.tracerProvider,
|
2060
|
+
idempotencyStrategy: this.idempotencyStrategy
|
2150
2061
|
});
|
2151
2062
|
case "following": return await handleCollection(request, {
|
2152
2063
|
name: "following",
|
@@ -2156,8 +2067,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2156
2067
|
collectionCallbacks: this.followingCallbacks,
|
2157
2068
|
tracerProvider: this.tracerProvider,
|
2158
2069
|
onUnauthorized,
|
2159
|
-
onNotFound
|
2160
|
-
onNotAcceptable
|
2070
|
+
onNotFound
|
2161
2071
|
});
|
2162
2072
|
case "followers": {
|
2163
2073
|
let baseUrl = url.searchParams.get("base-url");
|
@@ -2180,8 +2090,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2180
2090
|
collectionCallbacks: this.followersCallbacks,
|
2181
2091
|
tracerProvider: this.tracerProvider,
|
2182
2092
|
onUnauthorized,
|
2183
|
-
onNotFound
|
2184
|
-
onNotAcceptable
|
2093
|
+
onNotFound
|
2185
2094
|
});
|
2186
2095
|
}
|
2187
2096
|
case "liked": return await handleCollection(request, {
|
@@ -2192,8 +2101,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2192
2101
|
collectionCallbacks: this.likedCallbacks,
|
2193
2102
|
tracerProvider: this.tracerProvider,
|
2194
2103
|
onUnauthorized,
|
2195
|
-
onNotFound
|
2196
|
-
onNotAcceptable
|
2104
|
+
onNotFound
|
2197
2105
|
});
|
2198
2106
|
case "featured": return await handleCollection(request, {
|
2199
2107
|
name: "featured",
|
@@ -2203,8 +2111,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2203
2111
|
collectionCallbacks: this.featuredCallbacks,
|
2204
2112
|
tracerProvider: this.tracerProvider,
|
2205
2113
|
onUnauthorized,
|
2206
|
-
onNotFound
|
2207
|
-
onNotAcceptable
|
2114
|
+
onNotFound
|
2208
2115
|
});
|
2209
2116
|
case "featuredTags": return await handleCollection(request, {
|
2210
2117
|
name: "featured tags",
|
@@ -2214,8 +2121,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2214
2121
|
collectionCallbacks: this.featuredTagsCallbacks,
|
2215
2122
|
tracerProvider: this.tracerProvider,
|
2216
2123
|
onUnauthorized,
|
2217
|
-
onNotFound
|
2218
|
-
onNotAcceptable
|
2124
|
+
onNotFound
|
2219
2125
|
});
|
2220
2126
|
case "collection": {
|
2221
2127
|
const name = route.name.replace(/^collection:/, "");
|
@@ -2227,8 +2133,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2227
2133
|
collectionCallbacks: callbacks,
|
2228
2134
|
tracerProvider: this.tracerProvider,
|
2229
2135
|
onUnauthorized,
|
2230
|
-
onNotFound
|
2231
|
-
onNotAcceptable
|
2136
|
+
onNotFound
|
2232
2137
|
});
|
2233
2138
|
}
|
2234
2139
|
case "orderedCollection": {
|
@@ -2241,8 +2146,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
2241
2146
|
collectionCallbacks: callbacks,
|
2242
2147
|
tracerProvider: this.tracerProvider,
|
2243
2148
|
onUnauthorized,
|
2244
|
-
onNotFound
|
2245
|
-
onNotAcceptable
|
2149
|
+
onNotFound
|
2246
2150
|
});
|
2247
2151
|
}
|
2248
2152
|
default: {
|
@@ -2896,7 +2800,8 @@ var ContextImpl = class ContextImpl {
|
|
2896
2800
|
kvPrefixes: this.federation.kvPrefixes,
|
2897
2801
|
queue: this.federation.inboxQueue,
|
2898
2802
|
span,
|
2899
|
-
tracerProvider: options.tracerProvider ?? this.tracerProvider
|
2803
|
+
tracerProvider: options.tracerProvider ?? this.tracerProvider,
|
2804
|
+
idempotencyStrategy: this.federation.idempotencyStrategy
|
2900
2805
|
});
|
2901
2806
|
return routeResult === "alreadyProcessed" || routeResult === "enqueued" || routeResult === "unsupportedActivity" || routeResult === "success";
|
2902
2807
|
}
|
@@ -3210,4 +3115,4 @@ function getRequestId(request) {
|
|
3210
3115
|
}
|
3211
3116
|
|
3212
3117
|
//#endregion
|
3213
|
-
export { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer,
|
3118
|
+
export { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, actorDehydrator, autoIdAssigner, createFederation, handleActor, handleCollection, handleCustomCollection, handleInbox, handleNodeInfo, handleNodeInfoJrd, handleObject, handleWebFinger, respondWithObject, respondWithObjectIfAcceptable };
|