@fedify/fedify 2.0.0-dev.1641 → 2.0.0-dev.1726

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 (147) hide show
  1. package/dist/{actor-CP03csrm.cjs → actor-Bn2RCpws.cjs} +7263 -2440
  2. package/dist/{actor-DMgu-ZjT.d.cts → actor-D6K058Tb.d.cts} +1 -1
  3. package/dist/{actor-C22bXuuC.d.ts → actor-T6RyhRgk.d.ts} +1 -1
  4. package/dist/{actor-DVpsNXhn.js → actor-dO7jHa6A.js} +1 -1
  5. package/dist/{actor-DU511yTk.js → actor-menZmmiI.js} +7263 -2440
  6. package/dist/{assert_rejects-7UF4R_Qs.js → assert_rejects-DiIiJbZn.js} +1 -1
  7. package/dist/{assert_throws-53_pKeP3.js → assert_throws-BOO88avQ.js} +1 -1
  8. package/dist/{authdocloader-BnsFSERg.cjs → authdocloader-CEqdZdT7.cjs} +3 -3
  9. package/dist/{authdocloader-DCgMyo82.js → authdocloader-CZsCIRLV.js} +3 -3
  10. package/dist/{authdocloader-BkIZCKQv.js → authdocloader-DevmXsTo.js} +3 -3
  11. package/dist/{builder-E2Icrl_a.js → builder-CGF1vv7G.js} +14 -8
  12. package/dist/{client-BW4V0OJx.js → client-BfzV3u96.js} +1 -1
  13. package/dist/compat/mod.d.cts +7 -7
  14. package/dist/compat/mod.d.ts +7 -7
  15. package/dist/compat/transformers.test.js +18 -17
  16. package/dist/{context-CDSZdQHD.d.ts → context-B1X8-X33.d.ts} +185 -98
  17. package/dist/{context-Dq8aCtMH.d.cts → context-DYCJXr7J.d.cts} +185 -98
  18. package/dist/{docloader-kae6M-GI.cjs → docloader-Buh0Ah9G.cjs} +2 -2
  19. package/dist/{docloader-BtqIh1OE.js → docloader-DOmINJ1U.js} +2 -2
  20. package/dist/{esm-mtx3XJAD.js → esm-BODOj_Oi.js} +1 -1
  21. package/dist/federation/builder.test.js +10 -10
  22. package/dist/federation/collection.test.js +8 -8
  23. package/dist/federation/handler.test.js +26 -145
  24. package/dist/federation/idempotency.test.d.ts +3 -0
  25. package/dist/federation/idempotency.test.js +202 -0
  26. package/dist/federation/inbox.test.js +6 -6
  27. package/dist/federation/keycache.test.js +4 -4
  28. package/dist/federation/kv.test.js +8 -8
  29. package/dist/federation/middleware.test.js +238 -44
  30. package/dist/federation/mod.cjs +10 -10
  31. package/dist/federation/mod.d.cts +7 -7
  32. package/dist/federation/mod.d.ts +7 -7
  33. package/dist/federation/mod.js +10 -10
  34. package/dist/federation/mq.test.js +10 -10
  35. package/dist/federation/negotiation.test.d.ts +3 -0
  36. package/dist/federation/negotiation.test.js +28 -0
  37. package/dist/federation/retry.test.js +5 -5
  38. package/dist/federation/router.test.js +8 -8
  39. package/dist/federation/send.test.js +15 -15
  40. package/dist/fixtures/media.example.com/avatars/test-avatar.jpg.json +6 -0
  41. package/dist/{http-ZhcoaYEa.cjs → http-BmbMWfmh.cjs} +3 -3
  42. package/dist/{http-BS6766zs.d.cts → http-D-e6AFwR.d.cts} +1 -1
  43. package/dist/{http-DqSNLFNY.d.ts → http-D6Uj2x2y.d.ts} +1 -1
  44. package/dist/{http-Cox5GsED.js → http-Danw_xTY.js} +2 -2
  45. package/dist/{http-C7uYFcBo.js → http-gHyCrTrX.js} +3 -3
  46. package/dist/{inbox-BDdRbWNI.js → inbox-Blp5F74G.js} +24 -7
  47. package/dist/{key-CgwCzDC4.js → key-B2cp5-JF.js} +3 -3
  48. package/dist/{key-HqzOCwDc.cjs → key-BR1W25rw.cjs} +2 -2
  49. package/dist/{key-Cc0JlcKe.js → key-BnjofJ4e.js} +2 -2
  50. package/dist/{key-CfiBDu3o.js → key-CIIkeide.js} +2 -2
  51. package/dist/key-DhflzsBJ.cjs +10 -0
  52. package/dist/{key-B9Z5ZuX9.js → key-WES6wszI.js} +4 -4
  53. package/dist/{keycache-CVBjz3xi.js → keycache-Covv8lvK.js} +1 -1
  54. package/dist/{keys-CBKbYaJA.js → keys-DZ1bqhJz.js} +1 -1
  55. package/dist/{ld-CxgmnSO3.js → ld-C7KL1MK2.js} +2 -2
  56. package/dist/{lookup-QHjmy4Og.cjs → lookup-CDOxr8vw.cjs} +1 -1
  57. package/dist/{lookup-NuT9cCSl.js → lookup-D8tCnUj2.js} +1 -1
  58. package/dist/{lookup-CiU3QxQz.js → lookup-VSVPBU3J.js} +21 -12
  59. package/dist/middleware-9KSLASn7.js +17 -0
  60. package/dist/{middleware-LyCG_YVM.cjs → middleware-C60xXvWx.cjs} +99 -108
  61. package/dist/middleware-CH0PNtaj.cjs +17 -0
  62. package/dist/middleware-CrzCnpdt.js +26 -0
  63. package/dist/{middleware-DXidHY4N.js → middleware-DXOZ6_ST.js} +99 -108
  64. package/dist/{middleware-ByPnvMMS.js → middleware-HKKY6sAX.js} +69 -165
  65. package/dist/{mod-Drmz72EK.d.ts → mod-BhUKmBJD.d.ts} +2 -2
  66. package/dist/{mod-TFoH2Ql8.d.ts → mod-CerN_Sza.d.ts} +1 -1
  67. package/dist/{mod-Dc_-mf8s.d.cts → mod-Cj1tHXBR.d.cts} +1 -1
  68. package/dist/{mod-evzlRVZq.d.cts → mod-CxkWO3Mg.d.cts} +19 -1
  69. package/dist/{mod-RI3-KvUI.d.ts → mod-DcKxhFQ8.d.ts} +2 -2
  70. package/dist/{mod-BClfg3ej.d.cts → mod-Djzcw2ry.d.cts} +2 -2
  71. package/dist/{mod-Cxt4Kpf6.d.ts → mod-DlU8ISoa.d.ts} +19 -1
  72. package/dist/{mod-BhMnAkFX.d.cts → mod-twdvV2hR.d.cts} +2 -2
  73. package/dist/mod.cjs +10 -10
  74. package/dist/mod.d.cts +10 -10
  75. package/dist/mod.d.ts +10 -10
  76. package/dist/mod.js +10 -10
  77. package/dist/negotiation-5NPJL6zp.js +71 -0
  78. package/dist/nodeinfo/client.test.js +10 -10
  79. package/dist/nodeinfo/handler.test.js +23 -22
  80. package/dist/nodeinfo/mod.cjs +2 -2
  81. package/dist/nodeinfo/mod.js +2 -2
  82. package/dist/nodeinfo/types.test.js +8 -8
  83. package/dist/{owner-B-7Ptt_m.d.cts → owner-BN_tO3cY.d.cts} +2 -2
  84. package/dist/{owner-Cxob5_PK.js → owner-COcyel6J.js} +2 -2
  85. package/dist/{owner-CQPnQVtf.d.ts → owner-hd9lvQcP.d.ts} +2 -2
  86. package/dist/{proof-2Gcor0_N.cjs → proof-CMJcrQoM.cjs} +3 -3
  87. package/dist/{proof-BiSQNUmQ.js → proof-Cpk853lc.js} +2 -2
  88. package/dist/{proof-DkxwMaWE.js → proof-D6pbnNx2.js} +3 -3
  89. package/dist/runtime/authdocloader.test.js +14 -14
  90. package/dist/runtime/docloader.test.js +9 -9
  91. package/dist/runtime/key.test.js +10 -10
  92. package/dist/runtime/langstr.test.js +8 -8
  93. package/dist/runtime/link.test.js +3 -3
  94. package/dist/runtime/mod.cjs +6 -6
  95. package/dist/runtime/mod.d.cts +3 -3
  96. package/dist/runtime/mod.d.ts +3 -3
  97. package/dist/runtime/mod.js +6 -6
  98. package/dist/runtime/multibase/multibase.test.js +8 -8
  99. package/dist/runtime/url.test.js +5 -5
  100. package/dist/{send-DSEhWIYD.js → send-C7A7_big.js} +2 -2
  101. package/dist/sig/http.test.js +13 -13
  102. package/dist/sig/key.test.js +11 -11
  103. package/dist/sig/ld.test.js +10 -10
  104. package/dist/sig/mod.cjs +6 -6
  105. package/dist/sig/mod.d.cts +5 -5
  106. package/dist/sig/mod.d.ts +5 -5
  107. package/dist/sig/mod.js +6 -6
  108. package/dist/sig/owner.test.js +12 -12
  109. package/dist/sig/proof.test.js +12 -12
  110. package/dist/testing/docloader.test.js +8 -8
  111. package/dist/testing/mod.d.ts +391 -86
  112. package/dist/testing/mod.js +3 -3
  113. package/dist/{testing-ByQmUvf-.js → testing-e8Kpb1uV.js} +2 -2
  114. package/dist/{type-B4NJkfVg.js → type-D_8QzkEn.js} +6944 -2121
  115. package/dist/{types-l2uh_ZhP.js → types-Db4ukgX8.js} +1 -1
  116. package/dist/{types-Bqt2EgP0.cjs → types-LjTL4QMx.cjs} +1 -1
  117. package/dist/vocab/actor.test.js +10 -10
  118. package/dist/vocab/lookup.test.js +259 -9
  119. package/dist/vocab/mod.cjs +4 -4
  120. package/dist/vocab/mod.d.cts +3 -3
  121. package/dist/vocab/mod.d.ts +3 -3
  122. package/dist/vocab/mod.js +4 -4
  123. package/dist/vocab/type.test.js +3 -3
  124. package/dist/vocab/vocab.test.js +402 -13
  125. package/dist/{vocab-SOE1ifCr.d.ts → vocab-BI0Ak5lL.d.ts} +290 -0
  126. package/dist/{vocab-lBFcVxVF.js → vocab-CJHF7Q71.js} +23 -14
  127. package/dist/{vocab-B0-5a8pw.cjs → vocab-DLHpZwOW.cjs} +23 -14
  128. package/dist/{vocab-DJTYMqyU.d.cts → vocab-Dw1-yVGg.d.cts} +290 -0
  129. package/dist/webfinger/handler.test.js +23 -22
  130. package/dist/webfinger/lookup.test.js +9 -9
  131. package/dist/webfinger/mod.cjs +2 -2
  132. package/dist/webfinger/mod.js +2 -2
  133. package/dist/x/cfworkers.test.js +8 -8
  134. package/dist/x/hono.d.cts +6 -6
  135. package/dist/x/hono.d.ts +6 -6
  136. package/dist/x/sveltekit.d.cts +6 -6
  137. package/dist/x/sveltekit.d.ts +6 -6
  138. package/package.json +1 -1
  139. package/dist/key-D-7DPHNl.cjs +0 -10
  140. package/dist/middleware-BHboQ4BE.js +0 -25
  141. package/dist/middleware-Bp3I9z8r.js +0 -17
  142. package/dist/middleware-oYqSU5ky.cjs +0 -17
  143. /package/dist/{assert_is_error-B035L3om.js → assert_is_error-BPGph1Jx.js} +0 -0
  144. /package/dist/{assert_not_equals-C80BG-_5.js → assert_not_equals-f3m3epl3.js} +0 -0
  145. /package/dist/{denokv-jZ0Z2h0M.js → denokv-Bv33Xxea.js} +0 -0
  146. /package/dist/{retry-CfF8Gn4d.js → retry-D4GJ670a.js} +0 -0
  147. /package/dist/{std__assert-DWivtrGR.js → std__assert-X-_kMxKM.js} +0 -0
@@ -4,15 +4,15 @@
4
4
 
5
5
  const require_chunk = require('./chunk-DqRYRqnO.cjs');
6
6
  const require_transformers = require('./transformers-CoBS-oFG.cjs');
7
- const require_docloader = require('./docloader-kae6M-GI.cjs');
8
- const require_actor = require('./actor-CP03csrm.cjs');
9
- const require_lookup = require('./lookup-QHjmy4Og.cjs');
10
- const require_key = require('./key-HqzOCwDc.cjs');
11
- const require_http = require('./http-ZhcoaYEa.cjs');
12
- const require_proof = require('./proof-2Gcor0_N.cjs');
13
- const require_types = require('./types-Bqt2EgP0.cjs');
14
- const require_authdocloader = require('./authdocloader-BnsFSERg.cjs');
15
- const require_vocab = require('./vocab-B0-5a8pw.cjs');
7
+ const require_docloader = require('./docloader-Buh0Ah9G.cjs');
8
+ const require_actor = require('./actor-Bn2RCpws.cjs');
9
+ const require_lookup = require('./lookup-CDOxr8vw.cjs');
10
+ const require_key = require('./key-BR1W25rw.cjs');
11
+ const require_http = require('./http-BmbMWfmh.cjs');
12
+ const require_proof = require('./proof-CMJcrQoM.cjs');
13
+ const require_types = require('./types-LjTL4QMx.cjs');
14
+ const require_authdocloader = require('./authdocloader-CEqdZdT7.cjs');
15
+ const require_vocab = require('./vocab-DLHpZwOW.cjs');
16
16
  const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
17
17
  const __opentelemetry_api = require_chunk.__toESM(require("@opentelemetry/api"));
18
18
  const byte_encodings_hex = require_chunk.__toESM(require("byte-encodings/hex"));
@@ -56,17 +56,34 @@ var InboxListenerSet = class InboxListenerSet {
56
56
  return this.dispatchWithClass(activity)?.listener ?? null;
57
57
  }
58
58
  };
59
- async function routeActivity({ context: ctx, json, activity, recipient, inboxListeners, inboxContextFactory, inboxErrorHandler, kv, kvPrefixes, queue, span, tracerProvider }) {
59
+ async function routeActivity({ context: ctx, json, activity, recipient, inboxListeners, inboxContextFactory, inboxErrorHandler, kv, kvPrefixes, queue, span, tracerProvider, idempotencyStrategy }) {
60
60
  const logger$1 = (0, __logtape_logtape.getLogger)([
61
61
  "fedify",
62
62
  "federation",
63
63
  "inbox"
64
64
  ]);
65
- const cacheKey = activity.id == null ? null : [
66
- ...kvPrefixes.activityIdempotence,
67
- ctx.origin,
68
- activity.id.href
69
- ];
65
+ let cacheKey = null;
66
+ if (activity.id != null) {
67
+ const inboxContext = inboxContextFactory(recipient, json, activity.id?.href, require_actor.getTypeId(activity).href);
68
+ const strategy = idempotencyStrategy ?? "per-inbox";
69
+ let keyString;
70
+ if (typeof strategy === "function") {
71
+ const result = await strategy(inboxContext, activity);
72
+ keyString = result;
73
+ } else switch (strategy) {
74
+ case "global":
75
+ keyString = activity.id.href;
76
+ break;
77
+ case "per-origin":
78
+ keyString = `${ctx.origin}\n${activity.id.href}`;
79
+ break;
80
+ case "per-inbox":
81
+ keyString = `${ctx.origin}\n${activity.id.href}\n${recipient == null ? "sharedInbox" : `inbox\n${recipient}`}`;
82
+ break;
83
+ default: keyString = `${ctx.origin}\n${activity.id.href}`;
84
+ }
85
+ if (keyString != null) cacheKey = [...kvPrefixes.activityIdempotence, keyString];
86
+ }
70
87
  if (cacheKey != null) {
71
88
  const cached = await kv.get(cacheKey);
72
89
  if (cached === true) {
@@ -308,6 +325,7 @@ var FederationBuilderImpl = class {
308
325
  inboxListeners;
309
326
  inboxErrorHandler;
310
327
  sharedInboxKeyDispatcher;
328
+ idempotencyStrategy;
311
329
  collectionTypeIds;
312
330
  collectionCallbacks;
313
331
  /**
@@ -322,7 +340,7 @@ var FederationBuilderImpl = class {
322
340
  this.collectionTypeIds = {};
323
341
  }
324
342
  async build(options) {
325
- const { FederationImpl: FederationImpl$1 } = await Promise.resolve().then(() => require("./middleware-oYqSU5ky.cjs"));
343
+ const { FederationImpl: FederationImpl$1 } = await Promise.resolve().then(() => require("./middleware-CH0PNtaj.cjs"));
326
344
  const f = new FederationImpl$1(options);
327
345
  const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
328
346
  f.router = this.router.clone();
@@ -344,6 +362,7 @@ var FederationBuilderImpl = class {
344
362
  f.inboxListeners = this.inboxListeners?.clone();
345
363
  f.inboxErrorHandler = this.inboxErrorHandler;
346
364
  f.sharedInboxKeyDispatcher = this.sharedInboxKeyDispatcher;
365
+ f.idempotencyStrategy = this.idempotencyStrategy;
347
366
  return f;
348
367
  }
349
368
  _getTracer() {
@@ -766,15 +785,19 @@ var FederationBuilderImpl = class {
766
785
  setSharedKeyDispatcher: (dispatcher) => {
767
786
  this.sharedInboxKeyDispatcher = dispatcher;
768
787
  return setters;
788
+ },
789
+ withIdempotency: (strategy) => {
790
+ this.idempotencyStrategy = strategy;
791
+ return setters;
769
792
  }
770
793
  };
771
794
  return setters;
772
795
  }
773
- setCollectionDispatcher(name, ...args) {
774
- return this.#setCustomCollectionDispatcher(name, "collection", ...args);
796
+ setCollectionDispatcher(name, itemType, path, dispatcher) {
797
+ return this.#setCustomCollectionDispatcher(name, "collection", itemType, path, dispatcher);
775
798
  }
776
- setOrderedCollectionDispatcher(name, ...args) {
777
- return this.#setCustomCollectionDispatcher(name, "orderedCollection", ...args);
799
+ setOrderedCollectionDispatcher(name, itemType, path, dispatcher) {
800
+ return this.#setCustomCollectionDispatcher(name, "orderedCollection", itemType, path, dispatcher);
778
801
  }
779
802
  #setCustomCollectionDispatcher(name, collectionType, itemType, path, dispatcher) {
780
803
  const strName = String(name);
@@ -980,9 +1003,6 @@ function preferredMediaTypes(accept) {
980
1003
  const accepts = parseAccept(accept === void 0 ? "*/*" : accept ?? "");
981
1004
  return accepts.filter(isQuality).sort(compareSpecs).map(getFullType);
982
1005
  }
983
-
984
- //#endregion
985
- //#region src/federation/handler.ts
986
1006
  function acceptsJsonLd(request) {
987
1007
  const accept = request.headers.get("Accept");
988
1008
  const types = accept ? preferredMediaTypes(accept) : ["*/*"];
@@ -990,6 +1010,9 @@ function acceptsJsonLd(request) {
990
1010
  if (types[0] === "text/html" || types[0] === "application/xhtml+xml") return false;
991
1011
  return types.includes("application/activity+json") || types.includes("application/ld+json") || types.includes("application/json");
992
1012
  }
1013
+
1014
+ //#endregion
1015
+ //#region src/federation/handler.ts
993
1016
  /**
994
1017
  * Handles an actor request.
995
1018
  * @template TContextData The context data to pass to the context.
@@ -997,7 +1020,7 @@ function acceptsJsonLd(request) {
997
1020
  * @param parameters The parameters for handling the actor.
998
1021
  * @returns A promise that resolves to an HTTP response.
999
1022
  */
1000
- async function handleActor(request, { identifier, context: context$2, actorDispatcher, authorizePredicate, onNotFound, onNotAcceptable, onUnauthorized }) {
1023
+ async function handleActor(request, { identifier, context: context$2, actorDispatcher, authorizePredicate, onNotFound, onUnauthorized }) {
1001
1024
  const logger$1 = (0, __logtape_logtape.getLogger)([
1002
1025
  "fedify",
1003
1026
  "federation",
@@ -1012,7 +1035,6 @@ async function handleActor(request, { identifier, context: context$2, actorDispa
1012
1035
  logger$1.debug("Actor {identifier} not found.", { identifier });
1013
1036
  return await onNotFound(request);
1014
1037
  }
1015
- if (!acceptsJsonLd(request)) return await onNotAcceptable(request);
1016
1038
  if (authorizePredicate != null) {
1017
1039
  let key = await context$2.getSignedKey();
1018
1040
  key = key?.clone({}, { $warning: {
@@ -1047,11 +1069,10 @@ async function handleActor(request, { identifier, context: context$2, actorDispa
1047
1069
  * @param parameters The parameters for handling the object.
1048
1070
  * @returns A promise that resolves to an HTTP response.
1049
1071
  */
1050
- async function handleObject(request, { values, context: context$2, objectDispatcher, authorizePredicate, onNotFound, onNotAcceptable, onUnauthorized }) {
1072
+ async function handleObject(request, { values, context: context$2, objectDispatcher, authorizePredicate, onNotFound, onUnauthorized }) {
1051
1073
  if (objectDispatcher == null) return await onNotFound(request);
1052
1074
  const object = await objectDispatcher(context$2, values);
1053
1075
  if (object == null) return await onNotFound(request);
1054
- if (!acceptsJsonLd(request)) return await onNotAcceptable(request);
1055
1076
  if (authorizePredicate != null) {
1056
1077
  let key = await context$2.getSignedKey();
1057
1078
  key = key?.clone({}, { $warning: {
@@ -1089,7 +1110,7 @@ async function handleObject(request, { values, context: context$2, objectDispatc
1089
1110
  * @param parameters The parameters for handling the collection.
1090
1111
  * @returns A promise that resolves to an HTTP response.
1091
1112
  */
1092
- async function handleCollection(request, { name, identifier, uriGetter, filter, filterPredicate, context: context$2, collectionCallbacks, tracerProvider, onUnauthorized, onNotFound, onNotAcceptable }) {
1113
+ async function handleCollection(request, { name, identifier, uriGetter, filter, filterPredicate, context: context$2, collectionCallbacks, tracerProvider, onUnauthorized, onNotFound }) {
1093
1114
  const spanName = name.trim().replace(/\s+/g, "_");
1094
1115
  tracerProvider = tracerProvider ?? __opentelemetry_api.trace.getTracerProvider();
1095
1116
  const tracer = tracerProvider.getTracer(require_docloader.deno_default.name, require_docloader.deno_default.version);
@@ -1202,7 +1223,6 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
1202
1223
  partOf
1203
1224
  });
1204
1225
  }
1205
- if (!acceptsJsonLd(request)) return await onNotAcceptable(request);
1206
1226
  if (collectionCallbacks.authorizePredicate != null) {
1207
1227
  let key = await context$2.getSignedKey();
1208
1228
  key = key?.clone({}, { $warning: {
@@ -1297,7 +1317,8 @@ async function handleInbox(request, options) {
1297
1317
  * @param span The OpenTelemetry span for tracing.
1298
1318
  * @returns A promise that resolves to an HTTP response.
1299
1319
  */
1300
- async function handleInboxInternal(request, { recipient, context: ctx, inboxContextFactory, kv, kvPrefixes, queue, actorDispatcher, inboxListeners, inboxErrorHandler, onNotFound, signatureTimeWindow, skipSignatureVerification, tracerProvider }, span) {
1320
+ async function handleInboxInternal(request, parameters, span) {
1321
+ const { recipient, context: ctx, inboxContextFactory, kv, kvPrefixes, queue, actorDispatcher, inboxListeners, inboxErrorHandler, onNotFound, signatureTimeWindow, skipSignatureVerification, tracerProvider } = parameters;
1301
1322
  const logger$1 = (0, __logtape_logtape.getLogger)([
1302
1323
  "fedify",
1303
1324
  "federation",
@@ -1499,7 +1520,8 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
1499
1520
  kvPrefixes,
1500
1521
  queue,
1501
1522
  span,
1502
- tracerProvider
1523
+ tracerProvider,
1524
+ idempotencyStrategy: parameters.idempotencyStrategy
1503
1525
  });
1504
1526
  if (routeResult === "alreadyProcessed") return new Response(`Activity <${activity.id}> has already been processed.`, {
1505
1527
  status: 202,
@@ -1529,7 +1551,7 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
1529
1551
  /**
1530
1552
  * Handles a custom collection request.
1531
1553
  * @template TItem The type of items in the collection.
1532
- * @template TParams The parameter names of the requested URL.
1554
+ * @template TParam The parameter names of the requested URL.
1533
1555
  * @template TContext The type of the context, extending {@link RequestContext}.
1534
1556
  * @template TContextData The context data to pass to the `TContext`.
1535
1557
  * @param request The HTTP request.
@@ -1540,7 +1562,6 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
1540
1562
  const handleCustomCollection = exceptWrapper(_handleCustomCollection);
1541
1563
  async function _handleCustomCollection(request, { name, values, context: context$2, tracerProvider, collectionCallbacks: callbacks, filterPredicate }) {
1542
1564
  verifyDefined(callbacks);
1543
- verifyJsonLdRequest(request);
1544
1565
  await authIfNeeded(context$2, values, callbacks);
1545
1566
  const cursor = new URL(request.url).searchParams.get("cursor");
1546
1567
  return await new CustomCollectionHandler(name, values, context$2, callbacks, tracerProvider, require_actor.Collection, require_actor.CollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
@@ -1548,7 +1569,7 @@ async function _handleCustomCollection(request, { name, values, context: context
1548
1569
  /**
1549
1570
  * Handles an ordered collection request.
1550
1571
  * @template TItem The type of items in the collection.
1551
- * @template TParams The parameter names of the requested URL.
1572
+ * @template TParam The parameter names of the requested URL.
1552
1573
  * @template TContext The type of the context, extending {@link RequestContext}.
1553
1574
  * @template TContextData The context data to pass to the `TContext`.
1554
1575
  * @param request The HTTP request.
@@ -1559,7 +1580,6 @@ async function _handleCustomCollection(request, { name, values, context: context
1559
1580
  const handleOrderedCollection = exceptWrapper(_handleOrderedCollection);
1560
1581
  async function _handleOrderedCollection(request, { name, values, context: context$2, tracerProvider, collectionCallbacks: callbacks, filterPredicate }) {
1561
1582
  verifyDefined(callbacks);
1562
- verifyJsonLdRequest(request);
1563
1583
  await authIfNeeded(context$2, values, callbacks);
1564
1584
  const cursor = new URL(request.url).searchParams.get("cursor");
1565
1585
  return await new CustomCollectionHandler(name, values, context$2, callbacks, tracerProvider, require_actor.OrderedCollection, require_actor.OrderedCollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
@@ -1569,7 +1589,7 @@ async function _handleOrderedCollection(request, { name, values, context: contex
1569
1589
  * The main flow is on `getCollection`, `dispatch`.
1570
1590
  *
1571
1591
  * @template TItem The type of items in the collection.
1572
- * @template TParams The parameter names of the requested URL.
1592
+ * @template TParam The parameter names of the requested URL.
1573
1593
  * @template TContext The type of the context. {@link Context} or {@link RequestContext}.
1574
1594
  * @template TContextData The context data to pass to the `TContext`.
1575
1595
  * @template TCollection The type of the collection, extending {@link Collection}.
@@ -1603,14 +1623,14 @@ var CustomCollectionHandler = class {
1603
1623
  #collection = null;
1604
1624
  /**
1605
1625
  * Creates a new CustomCollection instance.
1606
- * @param {string} name The name of the collection.
1607
- * @param {TParams} values The parameter values for the collection.
1608
- * @param {TContext} context The request context.
1609
- * @param {CustomCollectionCallbacks} callbacks The collection callbacks.
1610
- * @param {TracerProvider} tracerProvider The tracer provider for telemetry.
1611
- * @param {ConstructorWithTypeId<TCollection>} Collection The Collection constructor.
1612
- * @param {ConstructorWithTypeId<TCollectionPage>} CollectionPage The CollectionPage constructor.
1613
- * @param {(item: TItem) => boolean} filterPredicate Optional filter predicate for items.
1626
+ * @param name The name of the collection.
1627
+ * @param values The parameter values for the collection.
1628
+ * @param context The request context.
1629
+ * @param callbacks The collection callbacks.
1630
+ * @param tracerProvider The tracer provider for telemetry.
1631
+ * @param Collection The Collection constructor.
1632
+ * @param CollectionPage The CollectionPage constructor.
1633
+ * @param filterPredicate Optional filter predicate for items.
1614
1634
  */
1615
1635
  constructor(name, values, context$2, callbacks, tracerProvider = __opentelemetry_api.trace.getTracerProvider(), Collection$1, CollectionPage$1, filterPredicate) {
1616
1636
  this.name = name;
@@ -1735,7 +1755,7 @@ var CustomCollectionHandler = class {
1735
1755
  /**
1736
1756
  * Creates a function to wrap the dispatcher so tracing can be applied.
1737
1757
  * @param params Parameters including cursor and total items.
1738
- * @returns {(span: Span) => Promise<PageItems<TItem>>} A function that handles the span operation.
1758
+ * @returns A function that handles the span operation.
1739
1759
  */
1740
1760
  spanPages = ({ totalItems = null, cursor = null }) => async (span) => {
1741
1761
  try {
@@ -1756,23 +1776,23 @@ var CustomCollectionHandler = class {
1756
1776
  };
1757
1777
  /**
1758
1778
  * Dispatches the collection request to get items.
1759
- * @param {string | null} cursor The cursor for pagination, or null for the first page.
1760
- * @returns {Promise<PageItems<TItem>>} A promise that resolves to the page items.
1779
+ * @param cursor The cursor for pagination, or null for the first page.
1780
+ * @returns A promise that resolves to the page items.
1761
1781
  */
1762
1782
  async dispatch(cursor = null) {
1763
1783
  return await this.#dispatcher(this.context, this.values, cursor) ?? new ItemsNotFoundError().throw();
1764
1784
  }
1765
1785
  /**
1766
1786
  * Filters the items in the collection.
1767
- * @param {TItem[]} items The items to filter.
1768
- * @returns {(Object | Link | URL)[]} The filtered items.
1787
+ * @param items The items to filter.
1788
+ * @returns The filtered items.
1769
1789
  */
1770
1790
  filterItems(items) {
1771
1791
  return filterCollectionItems(items, this.name, this.filterPredicate);
1772
1792
  }
1773
1793
  /**
1774
1794
  * Appends a cursor to the URL if it exists.
1775
- * @param {string | null | undefined} cursor The cursor to append, or null/undefined.
1795
+ * @param cursor The cursor to append, or null/undefined.
1776
1796
  * @returns The URL with cursor appended, or null if cursor is null/undefined.
1777
1797
  */
1778
1798
  appendToUrl(cursor) {
@@ -1780,8 +1800,7 @@ var CustomCollectionHandler = class {
1780
1800
  }
1781
1801
  /**
1782
1802
  * Gets the stored collection or collection page.
1783
- * @returns {Promise<TCollection | TCollectionPage>} A promise that resolves to
1784
- the collection or collection page.
1803
+ * @returns A promise that resolves to the collection or collection page.
1785
1804
  */
1786
1805
  get collection() {
1787
1806
  if (this.#collection === null) this.#collection = this.getCollection();
@@ -1789,8 +1808,8 @@ var CustomCollectionHandler = class {
1789
1808
  }
1790
1809
  /**
1791
1810
  * Gets the total number of items in the collection.
1792
- * @returns {Promise<number | null>} A promise that
1793
- resolves to the total items count, or null if not available.
1811
+ * @returns A promise that resolves to the total items count,
1812
+ * or null if not available.
1794
1813
  */
1795
1814
  get totalItems() {
1796
1815
  if (this.#totalItems === void 0) this.totalItems = this.callbacks.counter?.(this.context, this.values);
@@ -1806,8 +1825,8 @@ var CustomCollectionHandler = class {
1806
1825
  }
1807
1826
  /**
1808
1827
  * Gets the first cursor for pagination.
1809
- * @returns {Promise<string | null>} A promise that resolves to the first cursor,
1810
- or null if not available.
1828
+ * @returns A promise that resolves to the first cursor,
1829
+ * or null if not available.
1811
1830
  */
1812
1831
  get firstCursor() {
1813
1832
  const cursor = this.callbacks.firstCursor?.(this.context, this.values);
@@ -1837,10 +1856,9 @@ function exceptWrapper(handler) {
1837
1856
  try {
1838
1857
  return await handler(request, handlerParams);
1839
1858
  } catch (error) {
1840
- const { onNotFound, onNotAcceptable, onUnauthorized } = handlerParams;
1859
+ const { onNotFound, onUnauthorized } = handlerParams;
1841
1860
  switch (error?.constructor) {
1842
1861
  case ItemsNotFoundError: return await onNotFound(request);
1843
- case NotAcceptableError: return await onNotAcceptable(request);
1844
1862
  case UnauthorizedError: return await onUnauthorized(request);
1845
1863
  default: throw error;
1846
1864
  }
@@ -1858,15 +1876,6 @@ const verifyDefined = (callbacks) => {
1858
1876
  if (callbacks === void 0) throw new ItemsNotFoundError();
1859
1877
  };
1860
1878
  /**
1861
- * Verifies that a request accepts JSON-LD content type.
1862
- * @param request The HTTP request to verify.
1863
- * @throws {NotAcceptableError} If the request doesn't accept JSON-LD.
1864
- * @since 1.8.0
1865
- */
1866
- const verifyJsonLdRequest = (request) => {
1867
- if (!acceptsJsonLd(request)) throw new NotAcceptableError();
1868
- };
1869
- /**
1870
1879
  * Performs authorization if needed based on the authorization predicate.
1871
1880
  * @template TContextData The context data type.
1872
1881
  * @param {RequestContext<TContextData>} context The request context.
@@ -1950,15 +1959,6 @@ var ItemsNotFoundError = class extends HandlerError {
1950
1959
  }
1951
1960
  };
1952
1961
  /**
1953
- * Error thrown when the request is not acceptable (e.g., wrong content type).
1954
- * @since 1.8.0
1955
- */
1956
- var NotAcceptableError = class extends HandlerError {
1957
- constructor() {
1958
- super("The request is not acceptable.");
1959
- }
1960
- };
1961
- /**
1962
1962
  * Error thrown when access to a collection is unauthorized.
1963
1963
  * @since 1.8.0
1964
1964
  */
@@ -2350,7 +2350,6 @@ var FederationImpl = class extends FederationBuilderImpl {
2350
2350
  firstKnock;
2351
2351
  constructor(options) {
2352
2352
  super();
2353
- const logger$1 = (0, __logtape_logtape.getLogger)(["fedify", "federation"]);
2354
2353
  this.kv = options.kv;
2355
2354
  this.kvPrefixes = {
2356
2355
  activityIdempotence: ["_fedify", "activityIdempotence"],
@@ -2398,8 +2397,9 @@ var FederationImpl = class extends FederationBuilderImpl {
2398
2397
  this.router.trailingSlashInsensitive = options.trailingSlashInsensitive ?? false;
2399
2398
  this._initializeRouter();
2400
2399
  if (options.allowPrivateAddress || options.userAgent != null) {
2401
- if (options.contextLoader != null) throw new TypeError("Cannot set contextLoader with allowPrivateAddress or userAgent options.");
2402
- else if (options.authenticatedDocumentLoaderFactory != null) throw new TypeError("Cannot set authenticatedDocumentLoaderFactory with allowPrivateAddress or userAgent options.");
2400
+ if (options.documentLoaderFactory != null) throw new TypeError("Cannot set documentLoaderFactory with allowPrivateAddress or userAgent options.");
2401
+ if (options.contextLoaderFactory != null) throw new TypeError("Cannot set contextLoaderFactory with allowPrivateAddress or userAgent options.");
2402
+ if (options.authenticatedDocumentLoaderFactory != null) throw new TypeError("Cannot set authenticatedDocumentLoaderFactory with allowPrivateAddress or userAgent options.");
2403
2403
  }
2404
2404
  const { allowPrivateAddress, userAgent } = options;
2405
2405
  this.allowPrivateAddress = allowPrivateAddress ?? false;
@@ -2413,11 +2413,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2413
2413
  prefix: this.kvPrefixes.remoteDocument
2414
2414
  });
2415
2415
  });
2416
- if (options.contextLoader != null) {
2417
- if (options.contextLoaderFactory != null) throw new TypeError("Cannot set both contextLoader and contextLoaderFactory options at a time; use contextLoaderFactory only.");
2418
- this.contextLoaderFactory = () => options.contextLoader;
2419
- logger$1.warn("The contextLoader option is deprecated; use contextLoaderFactory option instead.");
2420
- } else this.contextLoaderFactory = options.contextLoaderFactory ?? this.documentLoaderFactory;
2416
+ this.contextLoaderFactory = options.contextLoaderFactory ?? this.documentLoaderFactory;
2421
2417
  this.authenticatedDocumentLoaderFactory = options.authenticatedDocumentLoaderFactory ?? ((identity) => require_authdocloader.getAuthenticatedDocumentLoader(identity, {
2422
2418
  allowPrivateAddress,
2423
2419
  userAgent,
@@ -2956,6 +2952,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2956
2952
  span,
2957
2953
  tracer
2958
2954
  });
2955
+ if (acceptsJsonLd(request)) response.headers.set("Vary", "Accept");
2959
2956
  } catch (error) {
2960
2957
  span.setStatus({
2961
2958
  code: __opentelemetry_api.SpanStatusCode.ERROR,
@@ -3019,6 +3016,9 @@ var FederationImpl = class extends FederationBuilderImpl {
3019
3016
  context: context$2,
3020
3017
  nodeInfoDispatcher: this.nodeInfoDispatcher
3021
3018
  });
3019
+ }
3020
+ if (request.method !== "POST" && !acceptsJsonLd(request)) return await onNotAcceptable(request);
3021
+ switch (routeName) {
3022
3022
  case "actor":
3023
3023
  context$2 = this.#createContext(request, contextData, { invokedFromActorDispatcher: { identifier: route.values.identifier ?? route.values.handle } });
3024
3024
  return await handleActor(request, {
@@ -3027,8 +3027,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3027
3027
  actorDispatcher: this.actorCallbacks?.dispatcher,
3028
3028
  authorizePredicate: this.actorCallbacks?.authorizePredicate,
3029
3029
  onUnauthorized,
3030
- onNotFound,
3031
- onNotAcceptable
3030
+ onNotFound
3032
3031
  });
3033
3032
  case "object": {
3034
3033
  const typeId = route.name.replace(/^object:/, "");
@@ -3044,8 +3043,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3044
3043
  objectDispatcher: callbacks?.dispatcher,
3045
3044
  authorizePredicate: callbacks?.authorizePredicate,
3046
3045
  onUnauthorized,
3047
- onNotFound,
3048
- onNotAcceptable
3046
+ onNotFound
3049
3047
  });
3050
3048
  }
3051
3049
  case "outbox": return await handleCollection(request, {
@@ -3056,8 +3054,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3056
3054
  collectionCallbacks: this.outboxCallbacks,
3057
3055
  tracerProvider: this.tracerProvider,
3058
3056
  onUnauthorized,
3059
- onNotFound,
3060
- onNotAcceptable
3057
+ onNotFound
3061
3058
  });
3062
3059
  case "inbox":
3063
3060
  if (request.method !== "POST") return await handleCollection(request, {
@@ -3068,8 +3065,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3068
3065
  collectionCallbacks: this.inboxCallbacks,
3069
3066
  tracerProvider: this.tracerProvider,
3070
3067
  onUnauthorized,
3071
- onNotFound,
3072
- onNotAcceptable
3068
+ onNotFound
3073
3069
  });
3074
3070
  context$2 = this.#createContext(request, contextData, { documentLoader: await context$2.getDocumentLoader({ identifier: route.values.identifier ?? route.values.handle }) });
3075
3071
  case "sharedInbox":
@@ -3091,7 +3087,8 @@ var FederationImpl = class extends FederationBuilderImpl {
3091
3087
  onNotFound,
3092
3088
  signatureTimeWindow: this.signatureTimeWindow,
3093
3089
  skipSignatureVerification: this.skipSignatureVerification,
3094
- tracerProvider: this.tracerProvider
3090
+ tracerProvider: this.tracerProvider,
3091
+ idempotencyStrategy: this.idempotencyStrategy
3095
3092
  });
3096
3093
  case "following": return await handleCollection(request, {
3097
3094
  name: "following",
@@ -3101,8 +3098,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3101
3098
  collectionCallbacks: this.followingCallbacks,
3102
3099
  tracerProvider: this.tracerProvider,
3103
3100
  onUnauthorized,
3104
- onNotFound,
3105
- onNotAcceptable
3101
+ onNotFound
3106
3102
  });
3107
3103
  case "followers": {
3108
3104
  let baseUrl = url.searchParams.get("base-url");
@@ -3125,8 +3121,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3125
3121
  collectionCallbacks: this.followersCallbacks,
3126
3122
  tracerProvider: this.tracerProvider,
3127
3123
  onUnauthorized,
3128
- onNotFound,
3129
- onNotAcceptable
3124
+ onNotFound
3130
3125
  });
3131
3126
  }
3132
3127
  case "liked": return await handleCollection(request, {
@@ -3137,8 +3132,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3137
3132
  collectionCallbacks: this.likedCallbacks,
3138
3133
  tracerProvider: this.tracerProvider,
3139
3134
  onUnauthorized,
3140
- onNotFound,
3141
- onNotAcceptable
3135
+ onNotFound
3142
3136
  });
3143
3137
  case "featured": return await handleCollection(request, {
3144
3138
  name: "featured",
@@ -3148,8 +3142,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3148
3142
  collectionCallbacks: this.featuredCallbacks,
3149
3143
  tracerProvider: this.tracerProvider,
3150
3144
  onUnauthorized,
3151
- onNotFound,
3152
- onNotAcceptable
3145
+ onNotFound
3153
3146
  });
3154
3147
  case "featuredTags": return await handleCollection(request, {
3155
3148
  name: "featured tags",
@@ -3159,8 +3152,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3159
3152
  collectionCallbacks: this.featuredTagsCallbacks,
3160
3153
  tracerProvider: this.tracerProvider,
3161
3154
  onUnauthorized,
3162
- onNotFound,
3163
- onNotAcceptable
3155
+ onNotFound
3164
3156
  });
3165
3157
  case "collection": {
3166
3158
  const name = route.name.replace(/^collection:/, "");
@@ -3172,8 +3164,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3172
3164
  collectionCallbacks: callbacks,
3173
3165
  tracerProvider: this.tracerProvider,
3174
3166
  onUnauthorized,
3175
- onNotFound,
3176
- onNotAcceptable
3167
+ onNotFound
3177
3168
  });
3178
3169
  }
3179
3170
  case "orderedCollection": {
@@ -3186,8 +3177,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3186
3177
  collectionCallbacks: callbacks,
3187
3178
  tracerProvider: this.tracerProvider,
3188
3179
  onUnauthorized,
3189
- onNotFound,
3190
- onNotAcceptable
3180
+ onNotFound
3191
3181
  });
3192
3182
  }
3193
3183
  default: {
@@ -3841,7 +3831,8 @@ var ContextImpl = class ContextImpl {
3841
3831
  kvPrefixes: this.federation.kvPrefixes,
3842
3832
  queue: this.federation.inboxQueue,
3843
3833
  span,
3844
- tracerProvider: options.tracerProvider ?? this.tracerProvider
3834
+ tracerProvider: options.tracerProvider ?? this.tracerProvider,
3835
+ idempotencyStrategy: this.federation.idempotencyStrategy
3845
3836
  });
3846
3837
  return routeResult === "alreadyProcessed" || routeResult === "enqueued" || routeResult === "unsupportedActivity" || routeResult === "success";
3847
3838
  }
@@ -0,0 +1,17 @@
1
+
2
+ const { Temporal } = require("@js-temporal/polyfill");
3
+ const { URLPattern } = require("urlpattern-polyfill");
4
+
5
+ require('./transformers-CoBS-oFG.cjs');
6
+ require('./docloader-Buh0Ah9G.cjs');
7
+ require('./actor-Bn2RCpws.cjs');
8
+ const require_middleware = require('./middleware-C60xXvWx.cjs');
9
+ require('./lookup-CDOxr8vw.cjs');
10
+ require('./key-BR1W25rw.cjs');
11
+ require('./http-BmbMWfmh.cjs');
12
+ require('./proof-CMJcrQoM.cjs');
13
+ require('./types-LjTL4QMx.cjs');
14
+ require('./authdocloader-CEqdZdT7.cjs');
15
+ require('./vocab-DLHpZwOW.cjs');
16
+
17
+ exports.FederationImpl = require_middleware.FederationImpl;
@@ -0,0 +1,26 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+ globalThis.addEventListener = () => {};
5
+
6
+ import "./type-D_8QzkEn.js";
7
+ import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "./middleware-HKKY6sAX.js";
8
+ import "./client-BfzV3u96.js";
9
+ import "./lookup-VSVPBU3J.js";
10
+ import "./types-BSuWJsOm.js";
11
+ import "./actor-dO7jHa6A.js";
12
+ import "./key-CIIkeide.js";
13
+ import "./http-Danw_xTY.js";
14
+ import "./authdocloader-DevmXsTo.js";
15
+ import "./ld-C7KL1MK2.js";
16
+ import "./owner-COcyel6J.js";
17
+ import "./proof-Cpk853lc.js";
18
+ import "./inbox-Blp5F74G.js";
19
+ import "./builder-CGF1vv7G.js";
20
+ import "./collection-CcnIw1qY.js";
21
+ import "./keycache-Covv8lvK.js";
22
+ import "./negotiation-5NPJL6zp.js";
23
+ import "./retry-D4GJ670a.js";
24
+ import "./send-C7A7_big.js";
25
+
26
+ export { FederationImpl };