@fedify/fedify 2.0.0-pr.412.1559 → 2.0.0-pr.412.1692

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.
Files changed (184) hide show
  1. package/dist/actor-CrTGiTZd.cjs +42609 -0
  2. package/dist/{actor-Cc6B76eG.js → actor-D5S46edz.js} +1 -1
  3. package/dist/actor-D6K058Tb.d.cts +128 -0
  4. package/dist/{actor-CTAuCsWy.js → actor-G2S5sPEA.js} +6951 -2127
  5. package/dist/{actor-C22bXuuC.d.ts → actor-T6RyhRgk.d.ts} +1 -1
  6. package/dist/{authdocloader-BFVqUbyo.js → authdocloader-C5AvdCCi.js} +6 -6
  7. package/dist/authdocloader-CQMPmpaO.cjs +58 -0
  8. package/dist/{authdocloader-CLgDGafZ.js → authdocloader-SjwloJUA.js} +3 -3
  9. package/dist/{builder-BOEBObR8.js → builder-OA47XRft.js} +10 -4
  10. package/dist/chunk-DqRYRqnO.cjs +34 -0
  11. package/dist/{client-De-z2UnN.js → client-Bmd-i8x8.js} +3 -22
  12. package/dist/client-CegPX0Rn.d.cts +222 -0
  13. package/dist/{client-DF8anIB5.d.ts → client-bgSdkFa2.d.ts} +2 -74
  14. package/dist/compat/mod.cjs +10 -0
  15. package/dist/compat/mod.d.cts +13 -0
  16. package/dist/compat/mod.d.ts +8 -8
  17. package/dist/compat/mod.js +5 -5
  18. package/dist/compat/transformers.test.js +19 -19
  19. package/dist/compat-DmDDELst.cjs +4 -0
  20. package/dist/compat-nxUqe4Z-.js +4 -0
  21. package/dist/{context-9gCpIkiz.d.ts → context-ByZprN0S.d.ts} +67 -7
  22. package/dist/context-C5BsZkDr.d.cts +2315 -0
  23. package/dist/docloader-7Ey7wNHx.cjs +4861 -0
  24. package/dist/{docloader-DEhniCVa.js → docloader-CkweNhUH.js} +189 -9
  25. package/dist/docloader-D-MrRyHl.d.cts +219 -0
  26. package/dist/{esm-CHdxdkuH.js → esm-CwHz8Y8t.js} +1 -1
  27. package/dist/federation/builder.test.js +6 -7
  28. package/dist/federation/collection.test.js +4 -4
  29. package/dist/federation/handler.test.js +23 -143
  30. package/dist/federation/idempotency.test.js +202 -0
  31. package/dist/federation/inbox.test.js +4 -4
  32. package/dist/federation/keycache.test.js +4 -4
  33. package/dist/federation/kv.test.js +4 -3
  34. package/dist/federation/middleware.test.js +231 -52
  35. package/dist/federation/mod.cjs +29 -0
  36. package/dist/federation/mod.d.cts +13 -0
  37. package/dist/federation/mod.d.ts +8 -8
  38. package/dist/federation/mod.js +15 -15
  39. package/dist/federation/mq.test.js +3 -3
  40. package/dist/federation/negotiation.test.d.ts +3 -0
  41. package/dist/federation/negotiation.test.js +28 -0
  42. package/dist/federation/retry.test.js +3 -3
  43. package/dist/federation/router.test.js +3 -3
  44. package/dist/federation/send.test.js +10 -10
  45. package/dist/{federation-CMX7WzeL.js → federation-D1U8YY9t.js} +3 -3
  46. package/dist/federation-H2_En3j5.cjs +244 -0
  47. package/dist/fixtures/media.example.com/avatars/test-avatar.jpg.json +6 -0
  48. package/dist/http-BiBofurJ.cjs +826 -0
  49. package/dist/{http-l0TEupZK.js → http-C5tC93Hn.js} +7 -7
  50. package/dist/http-D-e6AFwR.d.cts +253 -0
  51. package/dist/{http-DqSNLFNY.d.ts → http-D6Uj2x2y.d.ts} +1 -1
  52. package/dist/{http-CcdM1brU.js → http-DGjdMiLc.js} +3 -3
  53. package/dist/{inbox-B6DZbGNf.js → inbox-BoDY3z8G.js} +24 -7
  54. package/dist/key-CZR7QraT.cjs +290 -0
  55. package/dist/key-Cf8MffVe.cjs +10 -0
  56. package/dist/{key-DxA6xRtZ.js → key-CkxrAIyp.js} +5 -5
  57. package/dist/key-Dk0j88Jo.js +10 -0
  58. package/dist/{key-CUZQgVlf.js → key-Epcl5jpz.js} +3 -3
  59. package/dist/{key-CzLv1phF.js → key-IxRhZpOF.js} +2 -2
  60. package/dist/{keycache-B8HdZJSt.js → keycache-TEniXNel.js} +1 -1
  61. package/dist/{keys-zZwiKkfx.js → keys-bZxcrZ9Z.js} +1 -1
  62. package/dist/kv-63Cil1MD.d.cts +81 -0
  63. package/dist/{ld-CBcQdZ6N.js → ld-DW7A0uIc.js} +4 -4
  64. package/dist/{lookup-Bn_HEC_d.js → lookup-DhQCVVja.js} +21 -12
  65. package/dist/lookup-DiV4LFBg.cjs +137 -0
  66. package/dist/{lookup-dtdr2ftf.js → lookup-cVRa2QM-.js} +4 -4
  67. package/dist/middleware-Be1JStOx.js +17 -0
  68. package/dist/middleware-CDOK7WOb.js +26 -0
  69. package/dist/{middleware-BRgu1IH8.js → middleware-Cgr3PtaJ.js} +58 -149
  70. package/dist/{middleware-CxEkcFW0.js → middleware-DvvYAIsd.js} +87 -91
  71. package/dist/middleware-EjIW2mZB.cjs +17 -0
  72. package/dist/middleware-TfuVoceY.cjs +4231 -0
  73. package/dist/mod-8DMWKtQE.d.cts +80 -0
  74. package/dist/{mod-Drmz72EK.d.ts → mod-BhUKmBJD.d.ts} +2 -2
  75. package/dist/mod-C2tOeRkN.d.cts +1 -0
  76. package/dist/{mod-TFoH2Ql8.d.ts → mod-CerN_Sza.d.ts} +1 -1
  77. package/dist/mod-Cj1tHXBR.d.cts +102 -0
  78. package/dist/mod-CxkWO3Mg.d.cts +307 -0
  79. package/dist/{mod-Bqxcp7eN.d.ts → mod-D6hQoxC5.d.ts} +2 -2
  80. package/dist/mod-Djzcw2ry.d.cts +266 -0
  81. package/dist/{mod-Cxt4Kpf6.d.ts → mod-DlU8ISoa.d.ts} +19 -1
  82. package/dist/mod-FZd39qVq.d.cts +1 -0
  83. package/dist/mod-jQ4OODsl.d.cts +113 -0
  84. package/dist/mod.cjs +150 -0
  85. package/dist/mod.d.cts +17 -0
  86. package/dist/mod.d.ts +11 -11
  87. package/dist/mod.js +21 -21
  88. package/dist/mq-B7R1Q-M5.d.cts +140 -0
  89. package/dist/negotiation-5NPJL6zp.js +71 -0
  90. package/dist/nodeinfo/client.test.js +27 -106
  91. package/dist/nodeinfo/handler.test.js +20 -20
  92. package/dist/nodeinfo/mod.cjs +11 -0
  93. package/dist/nodeinfo/mod.d.cts +5 -0
  94. package/dist/nodeinfo/mod.d.ts +2 -2
  95. package/dist/nodeinfo/mod.js +7 -7
  96. package/dist/nodeinfo/types.test.js +5 -10
  97. package/dist/nodeinfo-Co9lJrWl.cjs +4 -0
  98. package/dist/nodeinfo-DfycQ8Wf.js +4 -0
  99. package/dist/{owner-VEIjmR8r.js → owner-6Vc3UXXE.js} +2 -2
  100. package/dist/owner-BN_tO3cY.d.cts +67 -0
  101. package/dist/{owner-CQPnQVtf.d.ts → owner-hd9lvQcP.d.ts} +2 -2
  102. package/dist/{proof-DoSQAGkE.js → proof-C1jhbeNv.js} +3 -3
  103. package/dist/proof-CRJWXFfT.cjs +673 -0
  104. package/dist/{proof-tgUlT8hw.js → proof-Chi90OXv.js} +9 -9
  105. package/dist/runtime/authdocloader.test.js +9 -9
  106. package/dist/runtime/docloader.test.js +4 -4
  107. package/dist/runtime/key.test.js +5 -5
  108. package/dist/runtime/langstr.test.js +3 -3
  109. package/dist/runtime/link.test.d.ts +3 -0
  110. package/dist/runtime/link.test.js +61 -0
  111. package/dist/runtime/mod.cjs +25 -0
  112. package/dist/runtime/mod.d.cts +6 -0
  113. package/dist/runtime/mod.d.ts +3 -3
  114. package/dist/runtime/mod.js +10 -10
  115. package/dist/runtime/multibase/multibase.test.js +3 -3
  116. package/dist/runtime/url.test.js +3 -3
  117. package/dist/runtime-C58AJWSv.cjs +4 -0
  118. package/dist/runtime-DPYEDf-o.js +4 -0
  119. package/dist/{send-BzS7w-QF.js → send-DjATl6i3.js} +2 -2
  120. package/dist/sig/http.test.js +9 -9
  121. package/dist/sig/key.test.js +6 -6
  122. package/dist/sig/ld.test.js +7 -7
  123. package/dist/sig/mod.cjs +30 -0
  124. package/dist/sig/mod.d.cts +8 -0
  125. package/dist/sig/mod.d.ts +5 -5
  126. package/dist/sig/mod.js +10 -10
  127. package/dist/sig/owner.test.js +7 -7
  128. package/dist/sig/proof.test.js +7 -7
  129. package/dist/sig-ByHXzqUi.cjs +4 -0
  130. package/dist/sig-Cj3tk-ig.js +4 -0
  131. package/dist/testing/docloader.test.js +3 -3
  132. package/dist/testing/mod.d.ts +273 -28
  133. package/dist/testing/mod.js +3 -3
  134. package/dist/{testing-Z2omCvKy.js → testing-BnfPB5T-.js} +2 -2
  135. package/dist/{transformers-Dna8Fg7k.js → transformers-BFT6d7J5.js} +3 -3
  136. package/dist/transformers-CoBS-oFG.cjs +116 -0
  137. package/dist/{type-SK-d7Tbw.js → type-NEA09tSC.js} +7262 -2258
  138. package/dist/{types-BIgY6c-l.js → types-BSuWJsOm.js} +1 -3
  139. package/dist/types-CmmUQisS.cjs +315 -0
  140. package/dist/{types-DgPvoUWN.js → types-dLXLjVLf.js} +8 -169
  141. package/dist/vocab/actor.test.js +5 -5
  142. package/dist/vocab/lookup.test.js +255 -5
  143. package/dist/vocab/mod.cjs +87 -0
  144. package/dist/vocab/mod.d.cts +6 -0
  145. package/dist/vocab/mod.d.ts +3 -3
  146. package/dist/vocab/mod.js +7 -7
  147. package/dist/vocab/type.test.js +3 -3
  148. package/dist/vocab/vocab.test.js +433 -9
  149. package/dist/{vocab-SOE1ifCr.d.ts → vocab-BI0Ak5lL.d.ts} +290 -0
  150. package/dist/vocab-C5Y-0fGj.cjs +291 -0
  151. package/dist/vocab-Dw1-yVGg.d.cts +14922 -0
  152. package/dist/{vocab-CvD6Vbml.js → vocab-rWbHpc2J.js} +26 -17
  153. package/dist/webfinger/handler.test.js +19 -19
  154. package/dist/webfinger/lookup.test.js +4 -4
  155. package/dist/webfinger/mod.cjs +9 -0
  156. package/dist/webfinger/mod.d.cts +4 -0
  157. package/dist/webfinger/mod.js +6 -6
  158. package/dist/webfinger-BjOEdFPs.cjs +4 -0
  159. package/dist/webfinger-De_bU0iE.js +4 -0
  160. package/dist/x/cfworkers.cjs +100 -0
  161. package/dist/x/cfworkers.d.cts +59 -0
  162. package/dist/x/cfworkers.js +3 -3
  163. package/dist/x/cfworkers.test.js +3 -3
  164. package/dist/x/hono.cjs +61 -0
  165. package/dist/x/hono.d.cts +54 -0
  166. package/dist/x/hono.d.ts +7 -7
  167. package/dist/x/hono.js +3 -3
  168. package/dist/x/sveltekit.cjs +69 -0
  169. package/dist/x/sveltekit.d.cts +46 -0
  170. package/dist/x/sveltekit.d.ts +7 -7
  171. package/dist/x/sveltekit.js +3 -3
  172. package/package.json +68 -13
  173. package/dist/compat-Bb5myD13.js +0 -4
  174. package/dist/key-Deb0_wWL.js +0 -10
  175. package/dist/middleware-BE_geSiJ.js +0 -17
  176. package/dist/middleware-BnU6hzVp.js +0 -26
  177. package/dist/nodeinfo/semver.test.js +0 -143
  178. package/dist/nodeinfo-CyEbLjHs.js +0 -4
  179. package/dist/runtime-BSkOVUWM.js +0 -4
  180. package/dist/semver-dArNLkR9.js +0 -149
  181. package/dist/sig-BXJO--F9.js +0 -4
  182. package/dist/webfinger-C3GIyXIg.js +0 -4
  183. /package/dist/{collection-CSzG2j1P.js → collection-CcnIw1qY.js} +0 -0
  184. /package/dist/{nodeinfo/semver.test.d.ts → federation/idempotency.test.d.ts} +0 -0
@@ -1,17 +1,17 @@
1
1
 
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
-
5
- import { getDefaultActivityTransformers } from "./transformers-Dna8Fg7k.js";
6
- import { deno_default, getDocumentLoader, kvCache } from "./docloader-DEhniCVa.js";
7
- import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, getTypeId } from "./actor-CTAuCsWy.js";
8
- import { lookupWebFinger } from "./lookup-dtdr2ftf.js";
9
- import { exportJwk, importJwk, validateCryptoKey } from "./key-DxA6xRtZ.js";
10
- import { doubleKnock, verifyRequest } from "./http-l0TEupZK.js";
11
- import { detachSignature, doesActorOwnKey, getKeyOwner, hasSignature, signJsonLd, signObject, verifyJsonLd, verifyObject } from "./proof-tgUlT8hw.js";
12
- import { getNodeInfo, nodeInfoToJson } from "./types-DgPvoUWN.js";
13
- import { getAuthenticatedDocumentLoader } from "./authdocloader-BFVqUbyo.js";
14
- import { lookupObject, traverseCollection } from "./vocab-CvD6Vbml.js";
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ import { getDefaultActivityTransformers } from "./transformers-BFT6d7J5.js";
6
+ import { deno_default, getDocumentLoader, kvCache } from "./docloader-CkweNhUH.js";
7
+ import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, getTypeId } from "./actor-G2S5sPEA.js";
8
+ import { lookupWebFinger } from "./lookup-cVRa2QM-.js";
9
+ import { exportJwk, importJwk, validateCryptoKey } from "./key-CkxrAIyp.js";
10
+ import { doubleKnock, verifyRequest } from "./http-C5tC93Hn.js";
11
+ import { detachSignature, doesActorOwnKey, getKeyOwner, hasSignature, signJsonLd, signObject, verifyJsonLd, verifyObject } from "./proof-Chi90OXv.js";
12
+ import { getNodeInfo, nodeInfoToJson } from "./types-dLXLjVLf.js";
13
+ import { getAuthenticatedDocumentLoader } from "./authdocloader-C5AvdCCi.js";
14
+ import { lookupObject, traverseCollection } from "./vocab-rWbHpc2J.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
- const cacheKey = activity.id == null ? null : [
65
- ...kvPrefixes.activityIdempotence,
66
- ctx.origin,
67
- activity.id.href
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-BE_geSiJ.js");
342
+ const { FederationImpl: FederationImpl$1 } = await import("./middleware-Be1JStOx.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, onNotAcceptable, onUnauthorized }) {
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, onNotAcceptable, onUnauthorized }) {
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, onNotAcceptable }) {
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, { recipient, context: ctx, inboxContextFactory, kv, kvPrefixes, queue, actorDispatcher, inboxListeners, inboxErrorHandler, onNotFound, signatureTimeWindow, skipSignatureVerification, tracerProvider }, span) {
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, onNotAcceptable, onUnauthorized } = handlerParams;
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: {
@@ -3481,15 +3476,16 @@ var ContextImpl = class ContextImpl {
3481
3476
  "actor"
3482
3477
  ]);
3483
3478
  if (this.federation.actorCallbacks?.keyPairsDispatcher == null) throw new Error("No actor key pairs dispatcher registered.");
3484
- const path = this.federation.router.build("actor", {
3485
- identifier,
3486
- handle: identifier
3487
- });
3488
- if (path == null) {
3489
- logger$1.warn("No actor dispatcher registered.");
3490
- return [];
3479
+ let actorUri;
3480
+ try {
3481
+ actorUri = this.getActorUri(identifier);
3482
+ } catch (error) {
3483
+ if (error instanceof RouterError) {
3484
+ logger$1.warn(error.message);
3485
+ return [];
3486
+ }
3487
+ throw error;
3491
3488
  }
3492
- const actorUri = new URL(path, this.canonicalOrigin);
3493
3489
  const keyPairs = await this.federation.actorCallbacks?.keyPairsDispatcher(new ContextImpl({
3494
3490
  ...this,
3495
3491
  invokedFromActorKeyPairsDispatcher: { identifier }
@@ -3650,12 +3646,11 @@ var ContextImpl = class ContextImpl {
3650
3646
  if (identifier == null) throw new Error("If recipients is \"followers\", sender must be an actor identifier or username.");
3651
3647
  expandedRecipients = [];
3652
3648
  for await (const recipient of this.getFollowers(identifier)) expandedRecipients.push(recipient);
3653
- if (options.syncCollection) {
3654
- const collectionId = this.federation.router.build("followers", {
3655
- identifier,
3656
- handle: identifier
3657
- });
3658
- opts.collectionSync = collectionId == null ? void 0 : new URL(collectionId, this.canonicalOrigin).href;
3649
+ if (options.syncCollection) try {
3650
+ opts.collectionSync = this.getFollowersUri(identifier).href;
3651
+ } catch (error) {
3652
+ if (error instanceof RouterError) opts.collectionSync = void 0;
3653
+ else throw error;
3659
3654
  }
3660
3655
  } else expandedRecipients = [recipients];
3661
3656
  span.setAttribute("activitypub.inboxes", expandedRecipients.length);
@@ -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,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-7Ey7wNHx.cjs');
7
+ require('./actor-CrTGiTZd.cjs');
8
+ const require_middleware = require('./middleware-TfuVoceY.cjs');
9
+ require('./lookup-DiV4LFBg.cjs');
10
+ require('./key-CZR7QraT.cjs');
11
+ require('./http-BiBofurJ.cjs');
12
+ require('./proof-CRJWXFfT.cjs');
13
+ require('./types-CmmUQisS.cjs');
14
+ require('./authdocloader-CQMPmpaO.cjs');
15
+ require('./vocab-C5Y-0fGj.cjs');
16
+
17
+ exports.FederationImpl = require_middleware.FederationImpl;