@fedify/fedify 2.1.0 → 2.1.2

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 (207) hide show
  1. package/dist/{accept-D7sAxyNa.js → accept-Dd__NiUL.mjs} +10 -8
  2. package/dist/{assert-MZs1qjMx.js → assert-ddO5KLpe.mjs} +5 -9
  3. package/dist/{assert_equals-DSbWqCm3.js → assert_equals-Ew3jOFa3.mjs} +55 -69
  4. package/dist/{assert_instance_of-DHz7EHNU.js → assert_instance_of-C4Ri6VuN.mjs} +5 -9
  5. package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals--wG9hV7u.mjs} +6 -13
  6. package/dist/{assert_rejects-0h7I2Esa.js → assert_rejects-B-qJtC9Z.mjs} +6 -11
  7. package/dist/{assert_throws-rjdMBf31.js → assert_throws-4NwKEy2q.mjs} +5 -10
  8. package/dist/{builder-WiHhZvjW.js → builder-DkJDAzes.mjs} +32 -41
  9. package/dist/{chunk-CGaQZ11T.cjs → chunk-DDcVe30Y.cjs} +23 -24
  10. package/dist/{chunk-DJNbSFdH.js → chunk-nlSIicah.js} +8 -8
  11. package/dist/{client-BxMZiQaD.d.ts → client-AtlibPOU.d.ts} +1 -1
  12. package/dist/{client-CoCIaTNO.js → client-DEpOVgY1.mjs} +9 -13
  13. package/dist/{client-C97KOq3x.d.cts → client-z-8dc-e1.d.cts} +1 -1
  14. package/dist/{collection-CSzG2j1P.js → collection-BD6-SZ6O.mjs} +7 -12
  15. package/dist/compat/mod.cjs +5 -8
  16. package/dist/compat/mod.d.cts +78 -6
  17. package/dist/compat/mod.d.ts +78 -6
  18. package/dist/compat/mod.js +4 -8
  19. package/dist/compat/transformers.test.mjs +62 -0
  20. package/dist/{context-DyJjQQ_H.d.ts → context-BOiMZBu5.d.ts} +9 -18
  21. package/dist/{context-BcqA-0BL.d.cts → context-BhZVy7RB.d.cts} +9 -18
  22. package/dist/{context-Aqenou7c.js → context-Juj6bdHC.mjs} +7 -11
  23. package/dist/deno-C5VMwnFV.mjs +8 -0
  24. package/dist/{docloader-bVO2EvL9.js → docloader-X9mcJ9Tz.mjs} +8 -14
  25. package/dist/{esm-nLm00z9V.js → esm-DVILvP5e.mjs} +50 -89
  26. package/dist/federation/builder.test.d.mts +2 -0
  27. package/dist/federation/{builder.test.js → builder.test.mjs} +21 -44
  28. package/dist/federation/collection.test.d.mts +2 -0
  29. package/dist/federation/collection.test.mjs +21 -0
  30. package/dist/federation/handler.test.d.mts +2 -0
  31. package/dist/federation/{handler.test.js → handler.test.mjs} +69 -131
  32. package/dist/federation/idempotency.test.d.mts +2 -0
  33. package/dist/federation/{idempotency.test.js → idempotency.test.mjs} +31 -63
  34. package/dist/federation/inbox.test.d.mts +2 -0
  35. package/dist/federation/{inbox.test.js → inbox.test.mjs} +8 -12
  36. package/dist/federation/keycache.test.d.mts +2 -0
  37. package/dist/federation/{keycache.test.js → keycache.test.mjs} +13 -19
  38. package/dist/federation/kv.test.d.mts +2 -0
  39. package/dist/federation/{kv.test.js → kv.test.mjs} +11 -22
  40. package/dist/federation/middleware.test.d.mts +2 -0
  41. package/dist/federation/{middleware.test.js → middleware.test.mjs} +173 -262
  42. package/dist/federation/mod.cjs +327 -16
  43. package/dist/federation/mod.d.cts +3 -6
  44. package/dist/federation/mod.d.ts +3 -6
  45. package/dist/federation/mod.js +322 -13
  46. package/dist/federation/mq.test.d.mts +2 -0
  47. package/dist/federation/{mq.test.js → mq.test.mjs} +21 -35
  48. package/dist/federation/negotiation.test.d.mts +2 -0
  49. package/dist/federation/{negotiation.test.js → negotiation.test.mjs} +9 -16
  50. package/dist/federation/retry.test.d.mts +2 -0
  51. package/dist/federation/{retry.test.js → retry.test.mjs} +8 -11
  52. package/dist/federation/router.test.d.mts +2 -0
  53. package/dist/federation/{router.test.js → router.test.mjs} +11 -16
  54. package/dist/federation/send.test.d.mts +2 -0
  55. package/dist/federation/{send.test.js → send.test.mjs} +22 -30
  56. package/dist/federation/webfinger.test.d.mts +2 -0
  57. package/dist/federation/{webfinger.test.js → webfinger.test.mjs} +22 -56
  58. package/dist/{http-DhH623ma.js → http-BLZWcpzg.js} +67 -187
  59. package/dist/{http-CKDim8Tw.js → http-BTLPIzFa.mjs} +37 -45
  60. package/dist/{http-BudnHZE2.d.cts → http-CrGuipxe.d.cts} +1 -6
  61. package/dist/{http-gvnJbMS1.cjs → http-CxodXLwi.cjs} +186 -300
  62. package/dist/{http-Dax_FIBo.d.ts → http-aQzN9Ayi.d.ts} +1 -6
  63. package/dist/{inbox-CA9AUEGa.js → inbox-mcbmhjTW.mjs} +18 -26
  64. package/dist/{key-BsSCz8Z_.js → key-1MaItIGc.mjs} +29 -37
  65. package/dist/{keycache-CpGWAUbj.js → keycache-CCSwkQcY.mjs} +5 -10
  66. package/dist/{keys-BFve7QQv.js → keys-BAK-tUlf.mjs} +5 -9
  67. package/dist/{kv-BL4nlICN.d.cts → kv-CbLNp3zQ.d.cts} +1 -1
  68. package/dist/{kv-DXEUEP6z.d.ts → kv-GFYnFoOl.d.ts} +1 -1
  69. package/dist/{kv-cache-Bw2F2ABq.js → kv-cache-B01V7s3h.mjs} +4 -8
  70. package/dist/{kv-cache-DK4GFVWx.cjs → kv-cache-DjC82_4n.cjs} +27 -34
  71. package/dist/{kv-cache-CxoHCR44.js → kv-cache-GIDK1oLs.js} +6 -13
  72. package/dist/{kv-QzKcOQgP.js → kv-tL2TOE9X.mjs} +6 -10
  73. package/dist/{ld-Bo_Rx0Fc.js → ld-94uHZ1eO.mjs} +17 -31
  74. package/dist/{middleware-BkrUA3da.js → middleware-B5Er10wE.js} +336 -383
  75. package/dist/middleware-CDuHbSVE.mjs +5 -0
  76. package/dist/middleware-CTyq5KB0.cjs +4 -0
  77. package/dist/{middleware-CpAnWzjC.cjs → middleware-CqDJSLoG.cjs} +532 -587
  78. package/dist/{middleware-CZ8jOOa3.js → middleware-DMZGXHm3.mjs} +282 -317
  79. package/dist/{mod-Bx9jcLB8.d.cts → mod-B505FZBC.d.cts} +3 -3
  80. package/dist/{mod-em2Il1eD.d.cts → mod-Bp_CzKd4.d.cts} +2 -2
  81. package/dist/{mod-Cs2dYEwI.d.ts → mod-D7PAuO6k.d.ts} +3 -3
  82. package/dist/{mod-D6MdymW7.d.ts → mod-DKOAow7a.d.ts} +2 -2
  83. package/dist/{mod-Coe7KEgX.d.cts → mod-DoJBjjnO.d.cts} +2 -2
  84. package/dist/{mod-D6dOd--H.d.ts → mod-DvxszxXC.d.ts} +2 -2
  85. package/dist/mod.cjs +29 -74
  86. package/dist/mod.d.cts +11 -14
  87. package/dist/mod.d.ts +11 -15
  88. package/dist/mod.js +17 -71
  89. package/dist/{negotiation-BlAuS_nr.js → negotiation-DnsfFF8I.mjs} +7 -11
  90. package/dist/nodeinfo/client.test.d.mts +2 -0
  91. package/dist/nodeinfo/{client.test.js → client.test.mjs} +22 -40
  92. package/dist/nodeinfo/handler.test.d.mts +2 -0
  93. package/dist/nodeinfo/{handler.test.js → handler.test.mjs} +13 -43
  94. package/dist/nodeinfo/mod.cjs +5 -8
  95. package/dist/nodeinfo/mod.d.cts +2 -3
  96. package/dist/nodeinfo/mod.d.ts +2 -3
  97. package/dist/nodeinfo/mod.js +4 -8
  98. package/dist/nodeinfo/types.test.d.mts +2 -0
  99. package/dist/nodeinfo/{types.test.js → types.test.mjs} +9 -16
  100. package/dist/otel/exporter.test.d.mts +2 -0
  101. package/dist/otel/{exporter.test.js → exporter.test.mjs} +124 -178
  102. package/dist/otel/mod.cjs +15 -20
  103. package/dist/otel/mod.d.cts +2 -2
  104. package/dist/otel/mod.d.ts +2 -2
  105. package/dist/otel/mod.js +8 -14
  106. package/dist/{owner-gd0Q9FuU.d.ts → owner-74ARJ5TL.d.ts} +1 -1
  107. package/dist/{owner-Bj_IbwIT.js → owner-B4aIDhg_.mjs} +11 -16
  108. package/dist/{owner-1AbPBOOZ.d.cts → owner-CptqhsOy.d.cts} +1 -1
  109. package/dist/{proof-u6Y358J-.js → proof-DYZWMWOC.mjs} +21 -33
  110. package/dist/{proof-BhFF_JVj.cjs → proof-DqCjiFwb.cjs} +133 -157
  111. package/dist/{proof-D5BQTIcU.js → proof-j-of9m5W.js} +33 -59
  112. package/dist/{retry-mqLf4b-R.js → retry-B_E3V_Dx.mjs} +4 -7
  113. package/dist/{router-D9eI0s4b.js → router-CrMLXoOr.mjs} +4 -8
  114. package/dist/runtime/mod.cjs +11 -13
  115. package/dist/runtime/mod.d.cts +6 -2
  116. package/dist/runtime/mod.d.ts +0 -1
  117. package/dist/runtime/mod.js +4 -7
  118. package/dist/{send-CE8h59oe.js → send-uLjD0uAe.mjs} +8 -13
  119. package/dist/sig/accept.test.d.mts +2 -0
  120. package/dist/sig/{accept.test.js → accept.test.mjs} +35 -70
  121. package/dist/sig/http.test.d.mts +2 -0
  122. package/dist/sig/{http.test.js → http.test.mjs} +209 -280
  123. package/dist/sig/key.test.d.mts +2 -0
  124. package/dist/sig/{key.test.js → key.test.mjs} +11 -18
  125. package/dist/sig/ld.test.d.mts +2 -0
  126. package/dist/sig/{ld.test.js → ld.test.mjs} +22 -35
  127. package/dist/sig/mod.cjs +6 -9
  128. package/dist/sig/mod.d.cts +3 -3
  129. package/dist/sig/mod.d.ts +3 -3
  130. package/dist/sig/mod.js +5 -9
  131. package/dist/sig/owner.test.d.mts +2 -0
  132. package/dist/sig/{owner.test.js → owner.test.mjs} +19 -34
  133. package/dist/sig/proof.test.d.mts +2 -0
  134. package/dist/sig/{proof.test.js → proof.test.mjs} +16 -27
  135. package/dist/{std__assert-X-_kMxKM.js → std__assert-Duiq_YC9.mjs} +12 -24
  136. package/dist/testing/{mod.d.ts → mod.d.mts} +26 -90
  137. package/dist/testing/mod.mjs +6 -0
  138. package/dist/{transformers-3g8GZwkZ.cjs → transformers-NeAONrAq.cjs} +20 -25
  139. package/dist/{transformers-C3FLHUd6.js → transformers-ve6e2xcg.js} +3 -7
  140. package/dist/{types-CPz01LGH.js → types-DCP0WLdt.mjs} +4 -7
  141. package/dist/{types-Cd_hszr_.cjs → types-KC4QAoxe.cjs} +29 -34
  142. package/dist/{types-C93Ob9cU.js → types-hvL8ElAs.js} +8 -13
  143. package/dist/utils/docloader.test.d.mts +2 -0
  144. package/dist/utils/{docloader.test.js → docloader.test.mjs} +14 -25
  145. package/dist/utils/kv-cache.test.d.mts +2 -0
  146. package/dist/utils/{kv-cache.test.js → kv-cache.test.mjs} +25 -40
  147. package/dist/utils/mod.cjs +5 -9
  148. package/dist/utils/mod.d.cts +1 -3
  149. package/dist/utils/mod.d.ts +1 -3
  150. package/dist/utils/mod.js +4 -9
  151. package/dist/vocab/cjs.test.d.mts +2 -0
  152. package/dist/vocab/cjs.test.mjs +14 -0
  153. package/dist/vocab/mod.cjs +10 -12
  154. package/dist/vocab/mod.js +3 -5
  155. package/package.json +7 -7
  156. package/dist/compat/transformers.test.d.ts +0 -3
  157. package/dist/compat/transformers.test.js +0 -88
  158. package/dist/compat-Bb4NuTUO.js +0 -4
  159. package/dist/compat-DmDDELst.cjs +0 -4
  160. package/dist/deno-BRMCYThi.js +0 -121
  161. package/dist/federation/builder.test.d.ts +0 -3
  162. package/dist/federation/collection.test.d.ts +0 -3
  163. package/dist/federation/collection.test.js +0 -32
  164. package/dist/federation/handler.test.d.ts +0 -3
  165. package/dist/federation/idempotency.test.d.ts +0 -3
  166. package/dist/federation/inbox.test.d.ts +0 -3
  167. package/dist/federation/keycache.test.d.ts +0 -3
  168. package/dist/federation/kv.test.d.ts +0 -3
  169. package/dist/federation/middleware.test.d.ts +0 -3
  170. package/dist/federation/mq.test.d.ts +0 -3
  171. package/dist/federation/negotiation.test.d.ts +0 -3
  172. package/dist/federation/retry.test.d.ts +0 -3
  173. package/dist/federation/router.test.d.ts +0 -3
  174. package/dist/federation/send.test.d.ts +0 -3
  175. package/dist/federation/webfinger.test.d.ts +0 -3
  176. package/dist/federation-Bp3HI26G.cjs +0 -350
  177. package/dist/federation-DaMfqRm4.js +0 -332
  178. package/dist/middleware-BtT_mKsB.cjs +0 -12
  179. package/dist/middleware-CUMoHNCA.js +0 -12
  180. package/dist/middleware-CzeVJTA1.js +0 -27
  181. package/dist/mod-B7QkWzrL.d.cts +0 -80
  182. package/dist/mod-Bh8mqlYw.d.cts +0 -9
  183. package/dist/mod-D6HodEq7.d.ts +0 -7
  184. package/dist/mod-SMHOMNpZ.d.ts +0 -82
  185. package/dist/mod-gq_Xfdz8.d.cts +0 -1
  186. package/dist/nodeinfo/client.test.d.ts +0 -3
  187. package/dist/nodeinfo/handler.test.d.ts +0 -3
  188. package/dist/nodeinfo/types.test.d.ts +0 -3
  189. package/dist/nodeinfo-DoESQxq5.js +0 -4
  190. package/dist/nodeinfo-DuMYTpbZ.cjs +0 -4
  191. package/dist/otel/exporter.test.d.ts +0 -3
  192. package/dist/runtime-c2Njxsry.cjs +0 -17
  193. package/dist/runtime-poamPCMb.js +0 -13
  194. package/dist/sig/accept.test.d.ts +0 -3
  195. package/dist/sig/http.test.d.ts +0 -3
  196. package/dist/sig/key.test.d.ts +0 -3
  197. package/dist/sig/ld.test.d.ts +0 -3
  198. package/dist/sig/owner.test.d.ts +0 -3
  199. package/dist/sig/proof.test.d.ts +0 -3
  200. package/dist/sig-BNhspNOf.js +0 -4
  201. package/dist/sig-vX39WyWI.cjs +0 -4
  202. package/dist/testing/mod.js +0 -10
  203. package/dist/utils/docloader.test.d.ts +0 -3
  204. package/dist/utils/kv-cache.test.d.ts +0 -3
  205. package/dist/utils-BQ9KqEK9.cjs +0 -4
  206. package/dist/utils-Dn5OPdSW.js +0 -4
  207. /package/dist/{mod-AGjRfPjT.d.ts → compat/transformers.test.d.mts} +0 -0
@@ -1,25 +1,22 @@
1
-
2
- const { Temporal } = require("@js-temporal/polyfill");
3
- const { URLPattern } = require("urlpattern-polyfill");
4
-
5
- const require_chunk = require('./chunk-CGaQZ11T.cjs');
6
- const require_transformers = require('./transformers-3g8GZwkZ.cjs');
7
- const require_http = require('./http-gvnJbMS1.cjs');
8
- const require_proof = require('./proof-BhFF_JVj.cjs');
9
- const require_types = require('./types-Cd_hszr_.cjs');
10
- const require_kv_cache = require('./kv-cache-DK4GFVWx.cjs');
11
- const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
12
- const __fedify_vocab = require_chunk.__toESM(require("@fedify/vocab"));
13
- const __opentelemetry_api = require_chunk.__toESM(require("@opentelemetry/api"));
14
- const es_toolkit = require_chunk.__toESM(require("es-toolkit"));
15
- const uri_template_router = require_chunk.__toESM(require("uri-template-router"));
16
- const url_template = require_chunk.__toESM(require("url-template"));
17
- const byte_encodings_hex = require_chunk.__toESM(require("byte-encodings/hex"));
18
- const __opentelemetry_semantic_conventions = require_chunk.__toESM(require("@opentelemetry/semantic-conventions"));
19
- const __fedify_vocab_runtime = require_chunk.__toESM(require("@fedify/vocab-runtime"));
20
- const __fedify_webfinger = require_chunk.__toESM(require("@fedify/webfinger"));
21
- const node_url = require_chunk.__toESM(require("node:url"));
22
-
1
+ const { Temporal } = require("@js-temporal/polyfill");
2
+ const { URLPattern } = require("urlpattern-polyfill");
3
+ require("./chunk-DDcVe30Y.cjs");
4
+ const require_transformers = require("./transformers-NeAONrAq.cjs");
5
+ const require_http = require("./http-CxodXLwi.cjs");
6
+ const require_proof = require("./proof-DqCjiFwb.cjs");
7
+ const require_types = require("./types-KC4QAoxe.cjs");
8
+ const require_kv_cache = require("./kv-cache-DjC82_4n.cjs");
9
+ let _logtape_logtape = require("@logtape/logtape");
10
+ let _fedify_vocab = require("@fedify/vocab");
11
+ let _opentelemetry_api = require("@opentelemetry/api");
12
+ let es_toolkit = require("es-toolkit");
13
+ let uri_template_router = require("uri-template-router");
14
+ let url_template = require("url-template");
15
+ let byte_encodings_hex = require("byte-encodings/hex");
16
+ let _fedify_vocab_runtime = require("@fedify/vocab-runtime");
17
+ let _opentelemetry_semantic_conventions = require("@opentelemetry/semantic-conventions");
18
+ let _fedify_webfinger = require("@fedify/webfinger");
19
+ let node_url = require("node:url");
23
20
  //#region src/federation/inbox.ts
24
21
  var InboxListenerSet = class InboxListenerSet {
25
22
  #listeners;
@@ -41,7 +38,7 @@ var InboxListenerSet = class InboxListenerSet {
41
38
  if (inboxListeners == null) return null;
42
39
  while (true) {
43
40
  if (inboxListeners.has(cls)) break;
44
- if (cls === __fedify_vocab.Activity) return null;
41
+ if (cls === _fedify_vocab.Activity) return null;
45
42
  cls = globalThis.Object.getPrototypeOf(cls);
46
43
  }
47
44
  const listener = inboxListeners.get(cls);
@@ -55,20 +52,18 @@ var InboxListenerSet = class InboxListenerSet {
55
52
  }
56
53
  };
57
54
  async function routeActivity({ context: ctx, json, activity, recipient, inboxListeners, inboxContextFactory, inboxErrorHandler, kv, kvPrefixes, queue, span, tracerProvider, idempotencyStrategy }) {
58
- const logger$1 = (0, __logtape_logtape.getLogger)([
55
+ const logger = (0, _logtape_logtape.getLogger)([
59
56
  "fedify",
60
57
  "federation",
61
58
  "inbox"
62
59
  ]);
63
60
  let cacheKey = null;
64
61
  if (activity.id != null) {
65
- const inboxContext = inboxContextFactory(recipient, json, activity.id?.href, (0, __fedify_vocab.getTypeId)(activity).href);
62
+ const inboxContext = inboxContextFactory(recipient, json, activity.id?.href, (0, _fedify_vocab.getTypeId)(activity).href);
66
63
  const strategy = idempotencyStrategy ?? "per-inbox";
67
64
  let keyString;
68
- if (typeof strategy === "function") {
69
- const result = await strategy(inboxContext, activity);
70
- keyString = result;
71
- } else switch (strategy) {
65
+ if (typeof strategy === "function") keyString = await strategy(inboxContext, activity);
66
+ else switch (strategy) {
72
67
  case "global":
73
68
  keyString = activity.id.href;
74
69
  break;
@@ -83,24 +78,23 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
83
78
  if (keyString != null) cacheKey = [...kvPrefixes.activityIdempotence, keyString];
84
79
  }
85
80
  if (cacheKey != null) {
86
- const cached = await kv.get(cacheKey);
87
- if (cached === true) {
88
- logger$1.debug("Activity {activityId} has already been processed.", {
81
+ if (await kv.get(cacheKey) === true) {
82
+ logger.debug("Activity {activityId} has already been processed.", {
89
83
  activityId: activity.id?.href,
90
84
  activity: json,
91
85
  recipient
92
86
  });
93
87
  span.setStatus({
94
- code: __opentelemetry_api.SpanStatusCode.UNSET,
88
+ code: _opentelemetry_api.SpanStatusCode.UNSET,
95
89
  message: `Activity ${activity.id?.href} has already been processed.`
96
90
  });
97
91
  return "alreadyProcessed";
98
92
  }
99
93
  }
100
94
  if (activity.actorId == null) {
101
- logger$1.error("Missing actor.", { activity: json });
95
+ logger.error("Missing actor.", { activity: json });
102
96
  span.setStatus({
103
- code: __opentelemetry_api.SpanStatusCode.ERROR,
97
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
104
98
  message: "Missing actor."
105
99
  });
106
100
  return "missingActor";
@@ -108,7 +102,7 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
108
102
  span.setAttribute("activitypub.actor.id", activity.actorId.href);
109
103
  if (queue != null) {
110
104
  const carrier = {};
111
- __opentelemetry_api.propagation.inject(__opentelemetry_api.context.active(), carrier);
105
+ _opentelemetry_api.propagation.inject(_opentelemetry_api.context.active(), carrier);
112
106
  try {
113
107
  await queue.enqueue({
114
108
  type: "inbox",
@@ -121,80 +115,78 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
121
115
  traceContext: carrier
122
116
  });
123
117
  } catch (error) {
124
- logger$1.error("Failed to enqueue the incoming activity {activityId}:\n{error}", {
118
+ logger.error("Failed to enqueue the incoming activity {activityId}:\n{error}", {
125
119
  error,
126
120
  activityId: activity.id?.href,
127
121
  activity: json,
128
122
  recipient
129
123
  });
130
124
  span.setStatus({
131
- code: __opentelemetry_api.SpanStatusCode.ERROR,
125
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
132
126
  message: `Failed to enqueue the incoming activity ${activity.id?.href}.`
133
127
  });
134
128
  throw error;
135
129
  }
136
- logger$1.info("Activity {activityId} is enqueued.", {
130
+ logger.info("Activity {activityId} is enqueued.", {
137
131
  activityId: activity.id?.href,
138
132
  activity: json,
139
133
  recipient
140
134
  });
141
135
  return "enqueued";
142
136
  }
143
- tracerProvider = tracerProvider ?? __opentelemetry_api.trace.getTracerProvider();
144
- const tracer = tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
145
- return await tracer.startActiveSpan("activitypub.dispatch_inbox_listener", { kind: __opentelemetry_api.SpanKind.INTERNAL }, async (span$1) => {
137
+ tracerProvider = tracerProvider ?? _opentelemetry_api.trace.getTracerProvider();
138
+ return await tracerProvider.getTracer(require_http.name, require_http.version).startActiveSpan("activitypub.dispatch_inbox_listener", { kind: _opentelemetry_api.SpanKind.INTERNAL }, async (span) => {
146
139
  const dispatched = inboxListeners?.dispatchWithClass(activity);
147
140
  if (dispatched == null) {
148
- logger$1.error("Unsupported activity type:\n{activity}", {
141
+ logger.error("Unsupported activity type:\n{activity}", {
149
142
  activity: json,
150
143
  recipient
151
144
  });
152
- span$1.setStatus({
153
- code: __opentelemetry_api.SpanStatusCode.UNSET,
154
- message: `Unsupported activity type: ${(0, __fedify_vocab.getTypeId)(activity).href}`
145
+ span.setStatus({
146
+ code: _opentelemetry_api.SpanStatusCode.UNSET,
147
+ message: `Unsupported activity type: ${(0, _fedify_vocab.getTypeId)(activity).href}`
155
148
  });
156
- span$1.end();
149
+ span.end();
157
150
  return "unsupportedActivity";
158
151
  }
159
152
  const { class: cls, listener } = dispatched;
160
- span$1.updateName(`activitypub.dispatch_inbox_listener ${cls.name}`);
153
+ span.updateName(`activitypub.dispatch_inbox_listener ${cls.name}`);
161
154
  try {
162
- await listener(inboxContextFactory(recipient, json, activity?.id?.href, (0, __fedify_vocab.getTypeId)(activity).href), activity);
155
+ await listener(inboxContextFactory(recipient, json, activity?.id?.href, (0, _fedify_vocab.getTypeId)(activity).href), activity);
163
156
  } catch (error) {
164
157
  try {
165
158
  await inboxErrorHandler?.(ctx, error);
166
- } catch (error$1) {
167
- logger$1.error("An unexpected error occurred in inbox error handler:\n{error}", {
168
- error: error$1,
159
+ } catch (error) {
160
+ logger.error("An unexpected error occurred in inbox error handler:\n{error}", {
161
+ error,
169
162
  activityId: activity.id?.href,
170
163
  activity: json,
171
164
  recipient
172
165
  });
173
166
  }
174
- logger$1.error("Failed to process the incoming activity {activityId}:\n{error}", {
167
+ logger.error("Failed to process the incoming activity {activityId}:\n{error}", {
175
168
  error,
176
169
  activityId: activity.id?.href,
177
170
  activity: json,
178
171
  recipient
179
172
  });
180
- span$1.setStatus({
181
- code: __opentelemetry_api.SpanStatusCode.ERROR,
173
+ span.setStatus({
174
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
182
175
  message: String(error)
183
176
  });
184
- span$1.end();
177
+ span.end();
185
178
  return "error";
186
179
  }
187
180
  if (cacheKey != null) await kv.set(cacheKey, true, { ttl: Temporal.Duration.from({ days: 1 }) });
188
- logger$1.info("Activity {activityId} has been processed.", {
181
+ logger.info("Activity {activityId} has been processed.", {
189
182
  activityId: activity.id?.href,
190
183
  activity: json,
191
184
  recipient
192
185
  });
193
- span$1.end();
186
+ span.end();
194
187
  return "success";
195
188
  });
196
189
  }
197
-
198
190
  //#endregion
199
191
  //#region src/federation/router.ts
200
192
  function cloneInnerRouter(router) {
@@ -302,7 +294,6 @@ var RouterError = class extends Error {
302
294
  this.name = "RouterError";
303
295
  }
304
296
  };
305
-
306
297
  //#endregion
307
298
  //#region src/federation/builder.ts
308
299
  var FederationBuilderImpl = class {
@@ -340,8 +331,8 @@ var FederationBuilderImpl = class {
340
331
  this.collectionTypeIds = {};
341
332
  }
342
333
  async build(options) {
343
- const { FederationImpl: FederationImpl$1 } = await Promise.resolve().then(() => require("./middleware-BtT_mKsB.cjs"));
344
- const f = new FederationImpl$1(options);
334
+ const { FederationImpl } = await Promise.resolve().then(() => require("./middleware-CTyq5KB0.cjs"));
335
+ const f = new FederationImpl(options);
345
336
  const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
346
337
  f.router = this.router.clone();
347
338
  f.router.trailingSlashInsensitive = trailingSlashInsensitiveValue;
@@ -368,26 +359,26 @@ var FederationBuilderImpl = class {
368
359
  return f;
369
360
  }
370
361
  _getTracer() {
371
- return __opentelemetry_api.trace.getTracer(require_http.deno_default.name, require_http.deno_default.version);
362
+ return _opentelemetry_api.trace.getTracer(require_http.name, require_http.version);
372
363
  }
373
364
  setActorDispatcher(path, dispatcher) {
374
365
  if (this.router.has("actor")) throw new RouterError("Actor dispatcher already set.");
375
366
  const variables = this.router.add(path, "actor");
376
367
  if (variables.size !== 1 || !variables.has("identifier")) throw new RouterError("Path for actor dispatcher must have one variable: {identifier}");
377
- const callbacks = { dispatcher: async (context$2, identifier) => {
368
+ const callbacks = { dispatcher: async (context, identifier) => {
378
369
  const actor = await this._getTracer().startActiveSpan("activitypub.dispatch_actor", {
379
- kind: __opentelemetry_api.SpanKind.SERVER,
370
+ kind: _opentelemetry_api.SpanKind.SERVER,
380
371
  attributes: { "fedify.actor.identifier": identifier }
381
372
  }, async (span) => {
382
373
  try {
383
- const actor$1 = await dispatcher(context$2, identifier);
384
- span.setAttribute("activitypub.actor.id", (actor$1?.id ?? context$2.getActorUri(identifier)).href);
385
- if (actor$1 == null) span.setStatus({ code: __opentelemetry_api.SpanStatusCode.ERROR });
386
- else span.setAttribute("activitypub.actor.type", (0, __fedify_vocab.getTypeId)(actor$1).href);
387
- return actor$1;
374
+ const actor = await dispatcher(context, identifier);
375
+ span.setAttribute("activitypub.actor.id", (actor?.id ?? context.getActorUri(identifier)).href);
376
+ if (actor == null) span.setStatus({ code: _opentelemetry_api.SpanStatusCode.ERROR });
377
+ else span.setAttribute("activitypub.actor.type", (0, _fedify_vocab.getTypeId)(actor).href);
378
+ return actor;
388
379
  } catch (error) {
389
380
  span.setStatus({
390
- code: __opentelemetry_api.SpanStatusCode.ERROR,
381
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
391
382
  message: String(error)
392
383
  });
393
384
  throw error;
@@ -396,64 +387,64 @@ var FederationBuilderImpl = class {
396
387
  }
397
388
  });
398
389
  if (actor == null) return null;
399
- const logger$1 = (0, __logtape_logtape.getLogger)([
390
+ const logger = (0, _logtape_logtape.getLogger)([
400
391
  "fedify",
401
392
  "federation",
402
393
  "actor"
403
394
  ]);
404
- if (actor.id == null) logger$1.warn("Actor dispatcher returned an actor without an id property. Set the property with Context.getActorUri(identifier).");
405
- else if (actor.id.href != context$2.getActorUri(identifier).href) logger$1.warn("Actor dispatcher returned an actor with an id property that does not match the actor URI. Set the property with Context.getActorUri(identifier).");
395
+ if (actor.id == null) logger.warn("Actor dispatcher returned an actor without an id property. Set the property with Context.getActorUri(identifier).");
396
+ else if (actor.id.href != context.getActorUri(identifier).href) logger.warn("Actor dispatcher returned an actor with an id property that does not match the actor URI. Set the property with Context.getActorUri(identifier).");
406
397
  if (this.followingCallbacks != null && this.followingCallbacks.dispatcher != null) {
407
- if (actor.followingId == null) logger$1.warn("You configured a following collection dispatcher, but the actor does not have a following property. Set the property with Context.getFollowingUri(identifier).");
408
- else if (actor.followingId.href != context$2.getFollowingUri(identifier).href) logger$1.warn("You configured a following collection dispatcher, but the actor's following property does not match the following collection URI. Set the property with Context.getFollowingUri(identifier).");
398
+ if (actor.followingId == null) logger.warn("You configured a following collection dispatcher, but the actor does not have a following property. Set the property with Context.getFollowingUri(identifier).");
399
+ else if (actor.followingId.href != context.getFollowingUri(identifier).href) logger.warn("You configured a following collection dispatcher, but the actor's following property does not match the following collection URI. Set the property with Context.getFollowingUri(identifier).");
409
400
  }
410
401
  if (this.followersCallbacks != null && this.followersCallbacks.dispatcher != null) {
411
- if (actor.followersId == null) logger$1.warn("You configured a followers collection dispatcher, but the actor does not have a followers property. Set the property with Context.getFollowersUri(identifier).");
412
- else if (actor.followersId.href != context$2.getFollowersUri(identifier).href) logger$1.warn("You configured a followers collection dispatcher, but the actor's followers property does not match the followers collection URI. Set the property with Context.getFollowersUri(identifier).");
402
+ if (actor.followersId == null) logger.warn("You configured a followers collection dispatcher, but the actor does not have a followers property. Set the property with Context.getFollowersUri(identifier).");
403
+ else if (actor.followersId.href != context.getFollowersUri(identifier).href) logger.warn("You configured a followers collection dispatcher, but the actor's followers property does not match the followers collection URI. Set the property with Context.getFollowersUri(identifier).");
413
404
  }
414
405
  if (this.outboxCallbacks != null && this.outboxCallbacks.dispatcher != null) {
415
- if (actor?.outboxId == null) logger$1.warn("You configured an outbox collection dispatcher, but the actor does not have an outbox property. Set the property with Context.getOutboxUri(identifier).");
416
- else if (actor.outboxId.href != context$2.getOutboxUri(identifier).href) logger$1.warn("You configured an outbox collection dispatcher, but the actor's outbox property does not match the outbox collection URI. Set the property with Context.getOutboxUri(identifier).");
406
+ if (actor?.outboxId == null) logger.warn("You configured an outbox collection dispatcher, but the actor does not have an outbox property. Set the property with Context.getOutboxUri(identifier).");
407
+ else if (actor.outboxId.href != context.getOutboxUri(identifier).href) logger.warn("You configured an outbox collection dispatcher, but the actor's outbox property does not match the outbox collection URI. Set the property with Context.getOutboxUri(identifier).");
417
408
  }
418
409
  if (this.likedCallbacks != null && this.likedCallbacks.dispatcher != null) {
419
- if (actor?.likedId == null) logger$1.warn("You configured a liked collection dispatcher, but the actor does not have a liked property. Set the property with Context.getLikedUri(identifier).");
420
- else if (actor.likedId.href != context$2.getLikedUri(identifier).href) logger$1.warn("You configured a liked collection dispatcher, but the actor's liked property does not match the liked collection URI. Set the property with Context.getLikedUri(identifier).");
410
+ if (actor?.likedId == null) logger.warn("You configured a liked collection dispatcher, but the actor does not have a liked property. Set the property with Context.getLikedUri(identifier).");
411
+ else if (actor.likedId.href != context.getLikedUri(identifier).href) logger.warn("You configured a liked collection dispatcher, but the actor's liked property does not match the liked collection URI. Set the property with Context.getLikedUri(identifier).");
421
412
  }
422
413
  if (this.featuredCallbacks != null && this.featuredCallbacks.dispatcher != null) {
423
- if (actor?.featuredId == null) logger$1.warn("You configured a featured collection dispatcher, but the actor does not have a featured property. Set the property with Context.getFeaturedUri(identifier).");
424
- else if (actor.featuredId.href != context$2.getFeaturedUri(identifier).href) logger$1.warn("You configured a featured collection dispatcher, but the actor's featured property does not match the featured collection URI. Set the property with Context.getFeaturedUri(identifier).");
414
+ if (actor?.featuredId == null) logger.warn("You configured a featured collection dispatcher, but the actor does not have a featured property. Set the property with Context.getFeaturedUri(identifier).");
415
+ else if (actor.featuredId.href != context.getFeaturedUri(identifier).href) logger.warn("You configured a featured collection dispatcher, but the actor's featured property does not match the featured collection URI. Set the property with Context.getFeaturedUri(identifier).");
425
416
  }
426
417
  if (this.featuredTagsCallbacks != null && this.featuredTagsCallbacks.dispatcher != null) {
427
- if (actor?.featuredTagsId == null) logger$1.warn("You configured a featured tags collection dispatcher, but the actor does not have a featuredTags property. Set the property with Context.getFeaturedTagsUri(identifier).");
428
- else if (actor.featuredTagsId.href != context$2.getFeaturedTagsUri(identifier).href) logger$1.warn("You configured a featured tags collection dispatcher, but the actor's featuredTags property does not match the featured tags collection URI. Set the property with Context.getFeaturedTagsUri(identifier).");
418
+ if (actor?.featuredTagsId == null) logger.warn("You configured a featured tags collection dispatcher, but the actor does not have a featuredTags property. Set the property with Context.getFeaturedTagsUri(identifier).");
419
+ else if (actor.featuredTagsId.href != context.getFeaturedTagsUri(identifier).href) logger.warn("You configured a featured tags collection dispatcher, but the actor's featuredTags property does not match the featured tags collection URI. Set the property with Context.getFeaturedTagsUri(identifier).");
429
420
  }
430
421
  if (this.router.has("inbox")) {
431
- if (actor.inboxId == null) logger$1.warn("You configured inbox listeners, but the actor does not have an inbox property. Set the property with Context.getInboxUri(identifier).");
432
- else if (actor.inboxId.href != context$2.getInboxUri(identifier).href) logger$1.warn("You configured inbox listeners, but the actor's inbox property does not match the inbox URI. Set the property with Context.getInboxUri(identifier).");
433
- if (actor.endpoints == null || actor.endpoints.sharedInbox == null) logger$1.warn("You configured inbox listeners, but the actor does not have a endpoints.sharedInbox property. Set the property with Context.getInboxUri().");
434
- else if (actor.endpoints.sharedInbox.href != context$2.getInboxUri().href) logger$1.warn("You configured inbox listeners, but the actor's endpoints.sharedInbox property does not match the shared inbox URI. Set the property with Context.getInboxUri().");
422
+ if (actor.inboxId == null) logger.warn("You configured inbox listeners, but the actor does not have an inbox property. Set the property with Context.getInboxUri(identifier).");
423
+ else if (actor.inboxId.href != context.getInboxUri(identifier).href) logger.warn("You configured inbox listeners, but the actor's inbox property does not match the inbox URI. Set the property with Context.getInboxUri(identifier).");
424
+ if (actor.endpoints == null || actor.endpoints.sharedInbox == null) logger.warn("You configured inbox listeners, but the actor does not have a endpoints.sharedInbox property. Set the property with Context.getInboxUri().");
425
+ else if (actor.endpoints.sharedInbox.href != context.getInboxUri().href) logger.warn("You configured inbox listeners, but the actor's endpoints.sharedInbox property does not match the shared inbox URI. Set the property with Context.getInboxUri().");
435
426
  }
436
427
  if (callbacks.keyPairsDispatcher != null) {
437
- if (actor.publicKeyId == null) logger$1.warn("You configured a key pairs dispatcher, but the actor does not have a publicKey property. Set the property with Context.getActorKeyPairs(identifier).");
438
- if (actor.assertionMethodId == null) logger$1.warn("You configured a key pairs dispatcher, but the actor does not have an assertionMethod property. Set the property with Context.getActorKeyPairs(identifier).");
428
+ if (actor.publicKeyId == null) logger.warn("You configured a key pairs dispatcher, but the actor does not have a publicKey property. Set the property with Context.getActorKeyPairs(identifier).");
429
+ if (actor.assertionMethodId == null) logger.warn("You configured a key pairs dispatcher, but the actor does not have an assertionMethod property. Set the property with Context.getActorKeyPairs(identifier).");
439
430
  }
440
431
  return actor;
441
432
  } };
442
433
  this.actorCallbacks = callbacks;
443
434
  const setters = {
444
- setKeyPairsDispatcher: (dispatcher$1) => {
435
+ setKeyPairsDispatcher: (dispatcher) => {
445
436
  callbacks.keyPairsDispatcher = (ctx, identifier) => this._getTracer().startActiveSpan("activitypub.dispatch_actor_key_pairs", {
446
- kind: __opentelemetry_api.SpanKind.SERVER,
437
+ kind: _opentelemetry_api.SpanKind.SERVER,
447
438
  attributes: {
448
439
  "activitypub.actor.id": ctx.getActorUri(identifier).href,
449
440
  "fedify.actor.identifier": identifier
450
441
  }
451
442
  }, async (span) => {
452
443
  try {
453
- return await dispatcher$1(ctx, identifier);
444
+ return await dispatcher(ctx, identifier);
454
445
  } catch (e) {
455
446
  span.setStatus({
456
- code: __opentelemetry_api.SpanStatusCode.ERROR,
447
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
457
448
  message: String(e)
458
449
  });
459
450
  throw e;
@@ -480,8 +471,7 @@ var FederationBuilderImpl = class {
480
471
  }
481
472
  setNodeInfoDispatcher(path, dispatcher) {
482
473
  if (this.router.has("nodeInfo")) throw new RouterError("NodeInfo dispatcher already set.");
483
- const variables = this.router.add(path, "nodeInfo");
484
- if (variables.size !== 0) throw new RouterError("Path for NodeInfo dispatcher must have no variables.");
474
+ if (this.router.add(path, "nodeInfo").size !== 0) throw new RouterError("Path for NodeInfo dispatcher must have no variables.");
485
475
  this.nodeInfoDispatcher = dispatcher;
486
476
  }
487
477
  setWebFingerLinksDispatcher(dispatcher) {
@@ -494,9 +484,8 @@ var FederationBuilderImpl = class {
494
484
  if (variables.size < 1) throw new RouterError("Path for object dispatcher must have at least one variable.");
495
485
  const callbacks = {
496
486
  dispatcher: (ctx, values) => {
497
- const tracer = this._getTracer();
498
- return tracer.startActiveSpan("activitypub.dispatch_object", {
499
- kind: __opentelemetry_api.SpanKind.SERVER,
487
+ return this._getTracer().startActiveSpan("activitypub.dispatch_object", {
488
+ kind: _opentelemetry_api.SpanKind.SERVER,
500
489
  attributes: {
501
490
  "fedify.object.type": cls.typeId.href,
502
491
  ...globalThis.Object.fromEntries(globalThis.Object.entries(values).map(([k, v]) => [`fedify.object.values.${k}`, v]))
@@ -505,12 +494,12 @@ var FederationBuilderImpl = class {
505
494
  try {
506
495
  const object = await dispatcher(ctx, values);
507
496
  span.setAttribute("activitypub.object.id", (object?.id ?? ctx.getObjectUri(cls, values)).href);
508
- if (object == null) span.setStatus({ code: __opentelemetry_api.SpanStatusCode.ERROR });
509
- else span.setAttribute("activitypub.object.type", (0, __fedify_vocab.getTypeId)(object).href);
497
+ if (object == null) span.setStatus({ code: _opentelemetry_api.SpanStatusCode.ERROR });
498
+ else span.setAttribute("activitypub.object.type", (0, _fedify_vocab.getTypeId)(object).href);
510
499
  return object;
511
500
  } catch (e) {
512
501
  span.setStatus({
513
- code: __opentelemetry_api.SpanStatusCode.ERROR,
502
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
514
503
  message: String(e)
515
504
  });
516
505
  throw e;
@@ -726,8 +715,7 @@ var FederationBuilderImpl = class {
726
715
  this.inboxPath = inboxPath;
727
716
  }
728
717
  if (sharedInboxPath != null) {
729
- const siVars = this.router.add(sharedInboxPath, "sharedInbox");
730
- if (siVars.size !== 0) throw new RouterError("Path for shared inbox must have no variables.");
718
+ if (this.router.add(sharedInboxPath, "sharedInbox").size !== 0) throw new RouterError("Path for shared inbox must have no variables.");
731
719
  }
732
720
  const listeners = this.inboxListeners = new InboxListenerSet();
733
721
  const setters = {
@@ -765,8 +753,7 @@ var FederationBuilderImpl = class {
765
753
  const routeName = `${collectionType}:${this.#uniqueCollectionId(name)}`;
766
754
  if (this.router.has(routeName)) throw new RouterError(`Collection dispatcher for ${strName} already set.`);
767
755
  if (this.collectionCallbacks[name] != null) throw new RouterError(`Collection dispatcher for ${strName} already set.`);
768
- const variables = this.router.add(path, routeName);
769
- if (variables.size < 1) throw new RouterError("Path for collection dispatcher must have at least one variable.");
756
+ if (this.router.add(path, routeName).size < 1) throw new RouterError("Path for collection dispatcher must have at least one variable.");
770
757
  const callbacks = { dispatcher };
771
758
  this.collectionCallbacks[name] = callbacks;
772
759
  this.collectionTypeIds[name] = itemType;
@@ -801,8 +788,7 @@ var FederationBuilderImpl = class {
801
788
  getCollectionPath(name, values) {
802
789
  if (!(name in this.collectionCallbacks)) return null;
803
790
  const routeName = this.#uniqueCollectionId(name);
804
- const path = this.router.build(`collection:${routeName}`, values) ?? this.router.build(`orderedCollection:${routeName}`, values);
805
- return path;
791
+ return this.router.build(`collection:${routeName}`, values) ?? this.router.build(`orderedCollection:${routeName}`, values);
806
792
  }
807
793
  setOutboxPermanentFailureHandler(handler) {
808
794
  this.outboxPermanentFailureHandler = handler;
@@ -828,7 +814,6 @@ var FederationBuilderImpl = class {
828
814
  function createFederationBuilder() {
829
815
  return new FederationBuilderImpl();
830
816
  }
831
-
832
817
  //#endregion
833
818
  //#region src/federation/collection.ts
834
819
  /**
@@ -847,8 +832,8 @@ async function digest(uris) {
847
832
  if (processed.has(u)) continue;
848
833
  processed.add(u);
849
834
  const encoded = encoder.encode(u);
850
- const digest$1 = new Uint8Array(await crypto.subtle.digest("SHA-256", encoded));
851
- for (let i = 0; i < 32; i++) result[i] ^= digest$1[i];
835
+ const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", encoded));
836
+ for (let i = 0; i < 32; i++) result[i] ^= digest[i];
852
837
  }
853
838
  return result;
854
839
  }
@@ -866,10 +851,8 @@ async function buildCollectionSynchronizationHeader(collectionId, actorIds) {
866
851
  const baseUrl = new URL(anyActorId);
867
852
  const url = new URL(collectionId);
868
853
  url.searchParams.set("base-url", `${baseUrl.origin}/`);
869
- const hash = (0, byte_encodings_hex.encodeHex)(await digest(actorIds));
870
- return `collectionId="${collectionId}", url="${url}", digest="${hash}"`;
854
+ return `collectionId="${collectionId}", url="${url}", digest="${(0, byte_encodings_hex.encodeHex)(await digest(actorIds))}"`;
871
855
  }
872
-
873
856
  //#endregion
874
857
  //#region src/federation/keycache.ts
875
858
  var KvKeyCache = class {
@@ -905,13 +888,13 @@ var KvKeyCache = class {
905
888
  return null;
906
889
  }
907
890
  try {
908
- return await __fedify_vocab.CryptographicKey.fromJsonLd(serialized, this.options);
891
+ return await _fedify_vocab.CryptographicKey.fromJsonLd(serialized, this.options);
909
892
  } catch {
910
893
  try {
911
- return await __fedify_vocab.Multikey.fromJsonLd(serialized, this.options);
894
+ return await _fedify_vocab.Multikey.fromJsonLd(serialized, this.options);
912
895
  } catch {
913
896
  await this.kv.delete([...this.prefix, keyId.href]);
914
- return void 0;
897
+ return;
915
898
  }
916
899
  }
917
900
  }
@@ -941,7 +924,6 @@ var KvKeyCache = class {
941
924
  error.name = cached.errorName;
942
925
  return { error };
943
926
  }
944
- return void 0;
945
927
  }
946
928
  async setFetchError(keyId, error) {
947
929
  if (error == null) {
@@ -963,7 +945,6 @@ var KvKeyCache = class {
963
945
  }, { ttl: this.unavailableKeyTtl });
964
946
  }
965
947
  };
966
-
967
948
  //#endregion
968
949
  //#region src/federation/negotiation.ts
969
950
  function compareSpecs(a, b) {
@@ -1008,8 +989,8 @@ function parseMediaType(str, i) {
1008
989
  function parseAccept(accept) {
1009
990
  const accepts = accept.split(",").map((p) => p.trim());
1010
991
  const mediaTypes = [];
1011
- for (const [index, accept$1] of accepts.entries()) {
1012
- const mediaType = parseMediaType(accept$1.trim(), index);
992
+ for (const [index, accept] of accepts.entries()) {
993
+ const mediaType = parseMediaType(accept.trim(), index);
1013
994
  if (mediaType) mediaTypes.push(mediaType);
1014
995
  }
1015
996
  return mediaTypes;
@@ -1018,8 +999,7 @@ function getFullType(spec) {
1018
999
  return `${spec.type}/${spec.subtype}`;
1019
1000
  }
1020
1001
  function preferredMediaTypes(accept) {
1021
- const accepts = parseAccept(accept === void 0 ? "*/*" : accept ?? "");
1022
- return accepts.filter(isQuality).sort(compareSpecs).map(getFullType);
1002
+ return parseAccept(accept === void 0 ? "*/*" : accept ?? "").filter(isQuality).sort(compareSpecs).map(getFullType);
1023
1003
  }
1024
1004
  function acceptsJsonLd(request) {
1025
1005
  const accept = request.headers.get("Accept");
@@ -1028,7 +1008,6 @@ function acceptsJsonLd(request) {
1028
1008
  if (types[0] === "text/html" || types[0] === "application/xhtml+xml") return false;
1029
1009
  return types.includes("application/activity+json") || types.includes("application/ld+json") || types.includes("application/json");
1030
1010
  }
1031
-
1032
1011
  //#endregion
1033
1012
  //#region src/federation/handler.ts
1034
1013
  /**
@@ -1038,25 +1017,25 @@ function acceptsJsonLd(request) {
1038
1017
  * @param parameters The parameters for handling the actor.
1039
1018
  * @returns A promise that resolves to an HTTP response.
1040
1019
  */
1041
- async function handleActor(request, { identifier, context: context$2, actorDispatcher, authorizePredicate, onNotFound, onUnauthorized }) {
1042
- const logger$1 = (0, __logtape_logtape.getLogger)([
1020
+ async function handleActor(request, { identifier, context, actorDispatcher, authorizePredicate, onNotFound, onUnauthorized }) {
1021
+ const logger = (0, _logtape_logtape.getLogger)([
1043
1022
  "fedify",
1044
1023
  "federation",
1045
1024
  "actor"
1046
1025
  ]);
1047
1026
  if (actorDispatcher == null) {
1048
- logger$1.debug("Actor dispatcher is not set.", { identifier });
1027
+ logger.debug("Actor dispatcher is not set.", { identifier });
1049
1028
  return await onNotFound(request);
1050
1029
  }
1051
- const actor = await actorDispatcher(context$2, identifier);
1030
+ const actor = await actorDispatcher(context, identifier);
1052
1031
  if (actor == null) {
1053
- logger$1.debug("Actor {identifier} not found.", { identifier });
1032
+ logger.debug("Actor {identifier} not found.", { identifier });
1054
1033
  return await onNotFound(request);
1055
1034
  }
1056
1035
  if (authorizePredicate != null) {
1057
- if (!await authorizePredicate(context$2, identifier)) return await onUnauthorized(request);
1036
+ if (!await authorizePredicate(context, identifier)) return await onUnauthorized(request);
1058
1037
  }
1059
- const jsonLd = await actor.toJsonLd(context$2);
1038
+ const jsonLd = await actor.toJsonLd(context);
1060
1039
  return new Response(JSON.stringify(jsonLd), { headers: {
1061
1040
  "Content-Type": "application/activity+json",
1062
1041
  Vary: "Accept"
@@ -1069,14 +1048,14 @@ async function handleActor(request, { identifier, context: context$2, actorDispa
1069
1048
  * @param parameters The parameters for handling the object.
1070
1049
  * @returns A promise that resolves to an HTTP response.
1071
1050
  */
1072
- async function handleObject(request, { values, context: context$2, objectDispatcher, authorizePredicate, onNotFound, onUnauthorized }) {
1051
+ async function handleObject(request, { values, context, objectDispatcher, authorizePredicate, onNotFound, onUnauthorized }) {
1073
1052
  if (objectDispatcher == null) return await onNotFound(request);
1074
- const object = await objectDispatcher(context$2, values);
1053
+ const object = await objectDispatcher(context, values);
1075
1054
  if (object == null) return await onNotFound(request);
1076
1055
  if (authorizePredicate != null) {
1077
- if (!await authorizePredicate(context$2, values)) return await onUnauthorized(request);
1056
+ if (!await authorizePredicate(context, values)) return await onUnauthorized(request);
1078
1057
  }
1079
- const jsonLd = await object.toJsonLd(context$2);
1058
+ const jsonLd = await object.toJsonLd(context);
1080
1059
  return new Response(JSON.stringify(jsonLd), { headers: {
1081
1060
  "Content-Type": "application/activity+json",
1082
1061
  Vary: "Accept"
@@ -1092,31 +1071,30 @@ async function handleObject(request, { values, context: context$2, objectDispatc
1092
1071
  * @param parameters The parameters for handling the collection.
1093
1072
  * @returns A promise that resolves to an HTTP response.
1094
1073
  */
1095
- async function handleCollection(request, { name, identifier, uriGetter, filter, filterPredicate, context: context$2, collectionCallbacks, tracerProvider, onUnauthorized, onNotFound }) {
1096
- const spanName = name.trim().replace(/\s+/g, "_");
1097
- tracerProvider = tracerProvider ?? __opentelemetry_api.trace.getTracerProvider();
1098
- const tracer = tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
1099
- const url = new URL(request.url);
1100
- const cursor = url.searchParams.get("cursor");
1074
+ async function handleCollection(request, { name: name$2, identifier, uriGetter, filter, filterPredicate, context, collectionCallbacks, tracerProvider, onUnauthorized, onNotFound }) {
1075
+ const spanName = name$2.trim().replace(/\s+/g, "_");
1076
+ tracerProvider = tracerProvider ?? _opentelemetry_api.trace.getTracerProvider();
1077
+ const tracer = tracerProvider.getTracer(require_http.name, require_http.version);
1078
+ const cursor = new URL(request.url).searchParams.get("cursor");
1101
1079
  if (collectionCallbacks == null) return await onNotFound(request);
1102
1080
  let collection;
1103
1081
  const baseUri = uriGetter(identifier);
1104
1082
  if (cursor == null) {
1105
- const firstCursor = await collectionCallbacks.firstCursor?.(context$2, identifier);
1106
- const totalItems = filter == null ? await collectionCallbacks.counter?.(context$2, identifier) : void 0;
1083
+ const firstCursor = await collectionCallbacks.firstCursor?.(context, identifier);
1084
+ const totalItems = filter == null ? await collectionCallbacks.counter?.(context, identifier) : void 0;
1107
1085
  if (firstCursor == null) {
1108
1086
  const itemsOrResponse = await tracer.startActiveSpan(`activitypub.dispatch_collection ${spanName}`, {
1109
- kind: __opentelemetry_api.SpanKind.SERVER,
1087
+ kind: _opentelemetry_api.SpanKind.SERVER,
1110
1088
  attributes: {
1111
1089
  "activitypub.collection.id": baseUri.href,
1112
- "activitypub.collection.type": __fedify_vocab.OrderedCollection.typeId.href
1090
+ "activitypub.collection.type": _fedify_vocab.OrderedCollection.typeId.href
1113
1091
  }
1114
1092
  }, async (span) => {
1115
1093
  if (totalItems != null) span.setAttribute("activitypub.collection.total_items", Number(totalItems));
1116
1094
  try {
1117
- const page = await collectionCallbacks.dispatcher(context$2, identifier, null, filter);
1095
+ const page = await collectionCallbacks.dispatcher(context, identifier, null, filter);
1118
1096
  if (page == null) {
1119
- span.setStatus({ code: __opentelemetry_api.SpanStatusCode.ERROR });
1097
+ span.setStatus({ code: _opentelemetry_api.SpanStatusCode.ERROR });
1120
1098
  return await onNotFound(request);
1121
1099
  }
1122
1100
  const { items } = page;
@@ -1124,7 +1102,7 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
1124
1102
  return items;
1125
1103
  } catch (e) {
1126
1104
  span.setStatus({
1127
- code: __opentelemetry_api.SpanStatusCode.ERROR,
1105
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
1128
1106
  message: String(e)
1129
1107
  });
1130
1108
  throw e;
@@ -1133,21 +1111,21 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
1133
1111
  }
1134
1112
  });
1135
1113
  if (itemsOrResponse instanceof Response) return itemsOrResponse;
1136
- collection = new __fedify_vocab.OrderedCollection({
1114
+ collection = new _fedify_vocab.OrderedCollection({
1137
1115
  id: baseUri,
1138
1116
  totalItems: totalItems == null ? null : Number(totalItems),
1139
- items: filterCollectionItems(itemsOrResponse, name, filterPredicate)
1117
+ items: filterCollectionItems(itemsOrResponse, name$2, filterPredicate)
1140
1118
  });
1141
1119
  } else {
1142
- const lastCursor = await collectionCallbacks.lastCursor?.(context$2, identifier);
1143
- const first = new URL(context$2.url);
1120
+ const lastCursor = await collectionCallbacks.lastCursor?.(context, identifier);
1121
+ const first = new URL(context.url);
1144
1122
  first.searchParams.set("cursor", firstCursor);
1145
1123
  let last = null;
1146
1124
  if (lastCursor != null) {
1147
- last = new URL(context$2.url);
1125
+ last = new URL(context.url);
1148
1126
  last.searchParams.set("cursor", lastCursor);
1149
1127
  }
1150
- collection = new __fedify_vocab.OrderedCollection({
1128
+ collection = new _fedify_vocab.OrderedCollection({
1151
1129
  id: baseUri,
1152
1130
  totalItems: totalItems == null ? null : Number(totalItems),
1153
1131
  first,
@@ -1157,25 +1135,25 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
1157
1135
  } else {
1158
1136
  const uri = new URL(baseUri);
1159
1137
  uri.searchParams.set("cursor", cursor);
1160
- const pageOrResponse = await tracer.startActiveSpan(`activitypub.dispatch_collection_page ${name}`, {
1161
- kind: __opentelemetry_api.SpanKind.SERVER,
1138
+ const pageOrResponse = await tracer.startActiveSpan(`activitypub.dispatch_collection_page ${name$2}`, {
1139
+ kind: _opentelemetry_api.SpanKind.SERVER,
1162
1140
  attributes: {
1163
1141
  "activitypub.collection.id": uri.href,
1164
- "activitypub.collection.type": __fedify_vocab.OrderedCollectionPage.typeId.href,
1142
+ "activitypub.collection.type": _fedify_vocab.OrderedCollectionPage.typeId.href,
1165
1143
  "fedify.collection.cursor": cursor
1166
1144
  }
1167
1145
  }, async (span) => {
1168
1146
  try {
1169
- const page = await collectionCallbacks.dispatcher(context$2, identifier, cursor, filter);
1147
+ const page = await collectionCallbacks.dispatcher(context, identifier, cursor, filter);
1170
1148
  if (page == null) {
1171
- span.setStatus({ code: __opentelemetry_api.SpanStatusCode.ERROR });
1149
+ span.setStatus({ code: _opentelemetry_api.SpanStatusCode.ERROR });
1172
1150
  return await onNotFound(request);
1173
1151
  }
1174
1152
  span.setAttribute("fedify.collection.items", page.items.length);
1175
1153
  return page;
1176
1154
  } catch (e) {
1177
1155
  span.setStatus({
1178
- code: __opentelemetry_api.SpanStatusCode.ERROR,
1156
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
1179
1157
  message: String(e)
1180
1158
  });
1181
1159
  throw e;
@@ -1187,28 +1165,28 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
1187
1165
  const { items, prevCursor, nextCursor } = pageOrResponse;
1188
1166
  let prev = null;
1189
1167
  if (prevCursor != null) {
1190
- prev = new URL(context$2.url);
1168
+ prev = new URL(context.url);
1191
1169
  prev.searchParams.set("cursor", prevCursor);
1192
1170
  }
1193
1171
  let next = null;
1194
1172
  if (nextCursor != null) {
1195
- next = new URL(context$2.url);
1173
+ next = new URL(context.url);
1196
1174
  next.searchParams.set("cursor", nextCursor);
1197
1175
  }
1198
- const partOf = new URL(context$2.url);
1176
+ const partOf = new URL(context.url);
1199
1177
  partOf.searchParams.delete("cursor");
1200
- collection = new __fedify_vocab.OrderedCollectionPage({
1178
+ collection = new _fedify_vocab.OrderedCollectionPage({
1201
1179
  id: uri,
1202
1180
  prev,
1203
1181
  next,
1204
- items: filterCollectionItems(items, name, filterPredicate),
1182
+ items: filterCollectionItems(items, name$2, filterPredicate),
1205
1183
  partOf
1206
1184
  });
1207
1185
  }
1208
1186
  if (collectionCallbacks.authorizePredicate != null) {
1209
- if (!await collectionCallbacks.authorizePredicate(context$2, identifier)) return await onUnauthorized(request);
1187
+ if (!await collectionCallbacks.authorizePredicate(context, identifier)) return await onUnauthorized(request);
1210
1188
  }
1211
- const jsonLd = await collection.toJsonLd(context$2);
1189
+ const jsonLd = await collection.toJsonLd(context);
1212
1190
  return new Response(JSON.stringify(jsonLd), { headers: {
1213
1191
  "Content-Type": "application/activity+json",
1214
1192
  Vary: "Accept"
@@ -1227,12 +1205,12 @@ function filterCollectionItems(items, collectionName, filterPredicate) {
1227
1205
  let logged = false;
1228
1206
  for (const item of items) {
1229
1207
  let mappedItem;
1230
- if (item instanceof __fedify_vocab.Object || item instanceof __fedify_vocab.Link || item instanceof URL) mappedItem = item;
1208
+ if (item instanceof _fedify_vocab.Object || item instanceof _fedify_vocab.Link || item instanceof URL) mappedItem = item;
1231
1209
  else if (item.id == null) continue;
1232
1210
  else mappedItem = item.id;
1233
1211
  if (filterPredicate != null && !filterPredicate(item)) {
1234
1212
  if (!logged) {
1235
- (0, __logtape_logtape.getLogger)([
1213
+ (0, _logtape_logtape.getLogger)([
1236
1214
  "fedify",
1237
1215
  "federation",
1238
1216
  "collection"
@@ -1253,10 +1231,8 @@ function filterCollectionItems(items, collectionName, filterPredicate) {
1253
1231
  * @returns A promise that resolves to an HTTP response.
1254
1232
  */
1255
1233
  async function handleInbox(request, options) {
1256
- const tracerProvider = options.tracerProvider ?? __opentelemetry_api.trace.getTracerProvider();
1257
- const tracer = tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
1258
- return await tracer.startActiveSpan("activitypub.inbox", {
1259
- kind: options.queue == null ? __opentelemetry_api.SpanKind.SERVER : __opentelemetry_api.SpanKind.PRODUCER,
1234
+ return await (options.tracerProvider ?? _opentelemetry_api.trace.getTracerProvider()).getTracer(require_http.name, require_http.version).startActiveSpan("activitypub.inbox", {
1235
+ kind: options.queue == null ? _opentelemetry_api.SpanKind.SERVER : _opentelemetry_api.SpanKind.PRODUCER,
1260
1236
  attributes: { "activitypub.shared_inbox": options.recipient == null }
1261
1237
  }, async (span) => {
1262
1238
  if (options.recipient != null) span.setAttribute("fedify.inbox.recipient", options.recipient);
@@ -1264,7 +1240,7 @@ async function handleInbox(request, options) {
1264
1240
  return await handleInboxInternal(request, options, span);
1265
1241
  } catch (e) {
1266
1242
  span.setStatus({
1267
- code: __opentelemetry_api.SpanStatusCode.ERROR,
1243
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
1268
1244
  message: String(e)
1269
1245
  });
1270
1246
  throw e;
@@ -1283,33 +1259,32 @@ async function handleInbox(request, options) {
1283
1259
  */
1284
1260
  async function handleInboxInternal(request, parameters, span) {
1285
1261
  const { recipient, context: ctx, inboxContextFactory, kv, kvPrefixes, queue, actorDispatcher, inboxListeners, inboxErrorHandler, unverifiedActivityHandler, onNotFound, signatureTimeWindow, skipSignatureVerification, inboxChallengePolicy, tracerProvider } = parameters;
1286
- const logger$1 = (0, __logtape_logtape.getLogger)([
1262
+ const logger = (0, _logtape_logtape.getLogger)([
1287
1263
  "fedify",
1288
1264
  "federation",
1289
1265
  "inbox"
1290
1266
  ]);
1291
1267
  if (actorDispatcher == null) {
1292
- logger$1.error("Actor dispatcher is not set.", { recipient });
1268
+ logger.error("Actor dispatcher is not set.", { recipient });
1293
1269
  span.setStatus({
1294
- code: __opentelemetry_api.SpanStatusCode.ERROR,
1270
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
1295
1271
  message: "Actor dispatcher is not set."
1296
1272
  });
1297
1273
  return await onNotFound(request);
1298
1274
  } else if (recipient != null) {
1299
- const actor = await actorDispatcher(ctx, recipient);
1300
- if (actor == null) {
1301
- logger$1.error("Actor {recipient} not found.", { recipient });
1275
+ if (await actorDispatcher(ctx, recipient) == null) {
1276
+ logger.error("Actor {recipient} not found.", { recipient });
1302
1277
  span.setStatus({
1303
- code: __opentelemetry_api.SpanStatusCode.ERROR,
1278
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
1304
1279
  message: `Actor ${recipient} not found.`
1305
1280
  });
1306
1281
  return await onNotFound(request);
1307
1282
  }
1308
1283
  }
1309
1284
  if (request.bodyUsed) {
1310
- logger$1.error("Request body has already been read.", { recipient });
1285
+ logger.error("Request body has already been read.", { recipient });
1311
1286
  span.setStatus({
1312
- code: __opentelemetry_api.SpanStatusCode.ERROR,
1287
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
1313
1288
  message: "Request body has already been read."
1314
1289
  });
1315
1290
  return new Response("Internal server error.", {
@@ -1317,9 +1292,9 @@ async function handleInboxInternal(request, parameters, span) {
1317
1292
  headers: { "Content-Type": "text/plain; charset=utf-8" }
1318
1293
  });
1319
1294
  } else if (request.body?.locked) {
1320
- logger$1.error("Request body is locked.", { recipient });
1295
+ logger.error("Request body is locked.", { recipient });
1321
1296
  span.setStatus({
1322
- code: __opentelemetry_api.SpanStatusCode.ERROR,
1297
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
1323
1298
  message: "Request body is locked."
1324
1299
  });
1325
1300
  return new Response("Internal server error.", {
@@ -1331,21 +1306,21 @@ async function handleInboxInternal(request, parameters, span) {
1331
1306
  try {
1332
1307
  json = await request.clone().json();
1333
1308
  } catch (error) {
1334
- logger$1.error("Failed to parse JSON:\n{error}", {
1309
+ logger.error("Failed to parse JSON:\n{error}", {
1335
1310
  recipient,
1336
1311
  error
1337
1312
  });
1338
1313
  try {
1339
1314
  await inboxErrorHandler?.(ctx, error);
1340
- } catch (error$1) {
1341
- logger$1.error("An unexpected error occurred in inbox error handler:\n{error}", {
1342
- error: error$1,
1315
+ } catch (error) {
1316
+ logger.error("An unexpected error occurred in inbox error handler:\n{error}", {
1317
+ error,
1343
1318
  activity: json,
1344
1319
  recipient
1345
1320
  });
1346
1321
  }
1347
1322
  span.setStatus({
1348
- code: __opentelemetry_api.SpanStatusCode.ERROR,
1323
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
1349
1324
  message: `Failed to parse JSON:\n${error}`
1350
1325
  });
1351
1326
  return new Response("Invalid JSON.", {
@@ -1364,7 +1339,7 @@ async function handleInboxInternal(request, parameters, span) {
1364
1339
  });
1365
1340
  } catch (error) {
1366
1341
  if (error instanceof Error && error.name === "jsonld.SyntaxError") {
1367
- logger$1.error("Failed to parse JSON-LD:\n{error}", {
1342
+ logger.error("Failed to parse JSON-LD:\n{error}", {
1368
1343
  recipient,
1369
1344
  error
1370
1345
  });
@@ -1379,41 +1354,41 @@ async function handleInboxInternal(request, parameters, span) {
1379
1354
  let activity = null;
1380
1355
  let activityVerified = false;
1381
1356
  if (ldSigVerified) {
1382
- logger$1.debug("Linked Data Signatures are verified.", {
1357
+ logger.debug("Linked Data Signatures are verified.", {
1383
1358
  recipient,
1384
1359
  json
1385
1360
  });
1386
- activity = await __fedify_vocab.Activity.fromJsonLd(jsonWithoutSig, ctx);
1361
+ activity = await _fedify_vocab.Activity.fromJsonLd(jsonWithoutSig, ctx);
1387
1362
  activityVerified = true;
1388
1363
  } else {
1389
- logger$1.debug("Linked Data Signatures are not verified.", {
1364
+ logger.debug("Linked Data Signatures are not verified.", {
1390
1365
  recipient,
1391
1366
  json
1392
1367
  });
1393
1368
  try {
1394
- activity = await require_proof.verifyObject(__fedify_vocab.Activity, jsonWithoutSig, {
1369
+ activity = await require_proof.verifyObject(_fedify_vocab.Activity, jsonWithoutSig, {
1395
1370
  contextLoader: ctx.contextLoader,
1396
1371
  documentLoader: ctx.documentLoader,
1397
1372
  keyCache,
1398
1373
  tracerProvider
1399
1374
  });
1400
1375
  } catch (error) {
1401
- logger$1.error("Failed to parse activity:\n{error}", {
1376
+ logger.error("Failed to parse activity:\n{error}", {
1402
1377
  recipient,
1403
1378
  activity: json,
1404
1379
  error
1405
1380
  });
1406
1381
  try {
1407
1382
  await inboxErrorHandler?.(ctx, error);
1408
- } catch (error$1) {
1409
- logger$1.error("An unexpected error occurred in inbox error handler:\n{error}", {
1410
- error: error$1,
1383
+ } catch (error) {
1384
+ logger.error("An unexpected error occurred in inbox error handler:\n{error}", {
1385
+ error,
1411
1386
  activity: json,
1412
1387
  recipient
1413
1388
  });
1414
1389
  }
1415
1390
  span.setStatus({
1416
- code: __opentelemetry_api.SpanStatusCode.ERROR,
1391
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
1417
1392
  message: `Failed to parse activity:\n${error}`
1418
1393
  });
1419
1394
  return new Response("Invalid activity.", {
@@ -1421,12 +1396,12 @@ async function handleInboxInternal(request, parameters, span) {
1421
1396
  headers: { "Content-Type": "text/plain; charset=utf-8" }
1422
1397
  });
1423
1398
  }
1424
- if (activity == null) logger$1.debug("Object Integrity Proofs are not verified.", {
1399
+ if (activity == null) logger.debug("Object Integrity Proofs are not verified.", {
1425
1400
  recipient,
1426
1401
  activity: json
1427
1402
  });
1428
1403
  else {
1429
- logger$1.debug("Object Integrity Proofs are verified.", {
1404
+ logger.debug("Object Integrity Proofs are verified.", {
1430
1405
  recipient,
1431
1406
  activity: json
1432
1407
  });
@@ -1446,29 +1421,29 @@ async function handleInboxInternal(request, parameters, span) {
1446
1421
  });
1447
1422
  if (verification.verified === false) {
1448
1423
  const reason = verification.reason;
1449
- logger$1.error("Failed to verify the request's HTTP Signatures.", {
1424
+ logger.error("Failed to verify the request's HTTP Signatures.", {
1450
1425
  recipient,
1451
1426
  reason: reason.type,
1452
1427
  keyId: "keyId" in reason ? reason.keyId?.href : void 0
1453
1428
  });
1454
1429
  span.setStatus({
1455
- code: __opentelemetry_api.SpanStatusCode.ERROR,
1430
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
1456
1431
  message: `Failed to verify the request's HTTP Signatures.`
1457
1432
  });
1458
1433
  if (unverifiedActivityHandler == null) return await getFailedSignatureResponse(inboxChallengePolicy, kv, kvPrefixes);
1459
1434
  try {
1460
- activity = await __fedify_vocab.Activity.fromJsonLd(jsonWithoutSig, ctx);
1435
+ activity = await _fedify_vocab.Activity.fromJsonLd(jsonWithoutSig, ctx);
1461
1436
  } catch (error) {
1462
- logger$1.error("Failed to parse activity:\n{error}", {
1437
+ logger.error("Failed to parse activity:\n{error}", {
1463
1438
  recipient,
1464
1439
  activity: json,
1465
1440
  error
1466
1441
  });
1467
1442
  try {
1468
1443
  await inboxErrorHandler?.(ctx, error);
1469
- } catch (error$1) {
1470
- logger$1.error("An unexpected error occurred in inbox error handler:\n{error}", {
1471
- error: error$1,
1444
+ } catch (error) {
1445
+ logger.error("An unexpected error occurred in inbox error handler:\n{error}", {
1446
+ error,
1472
1447
  activity: json,
1473
1448
  recipient
1474
1449
  });
@@ -1479,7 +1454,7 @@ async function handleInboxInternal(request, parameters, span) {
1479
1454
  });
1480
1455
  }
1481
1456
  if (activity.id != null) span.setAttribute("activitypub.activity.id", activity.id.href);
1482
- span.setAttribute("activitypub.activity.type", (0, __fedify_vocab.getTypeId)(activity).href);
1457
+ span.setAttribute("activitypub.activity.type", (0, _fedify_vocab.getTypeId)(activity).href);
1483
1458
  const eventAttributes = {
1484
1459
  "activitypub.activity.json": JSON.stringify(json),
1485
1460
  "activitypub.activity.verified": false,
@@ -1495,16 +1470,16 @@ async function handleInboxInternal(request, parameters, span) {
1495
1470
  try {
1496
1471
  response = await unverifiedActivityHandler(ctx, activity, reason);
1497
1472
  } catch (error) {
1498
- logger$1.error("An unexpected error occurred in unverified activity handler:\n{error}", {
1473
+ logger.error("An unexpected error occurred in unverified activity handler:\n{error}", {
1499
1474
  error,
1500
1475
  activity: json,
1501
1476
  recipient
1502
1477
  });
1503
1478
  try {
1504
1479
  await inboxErrorHandler?.(ctx, error);
1505
- } catch (error$1) {
1506
- logger$1.error("An unexpected error occurred in inbox error handler:\n{error}", {
1507
- error: error$1,
1480
+ } catch (error) {
1481
+ logger.error("An unexpected error occurred in inbox error handler:\n{error}", {
1482
+ error,
1508
1483
  activity: json,
1509
1484
  recipient
1510
1485
  });
@@ -1515,15 +1490,15 @@ async function handleInboxInternal(request, parameters, span) {
1515
1490
  return await getFailedSignatureResponse(inboxChallengePolicy, kv, kvPrefixes);
1516
1491
  } else {
1517
1492
  if (inboxChallengePolicy?.enabled && inboxChallengePolicy.requestNonce) pendingNonceLabel = verification.signatureLabel;
1518
- logger$1.debug("HTTP Signatures are verified.", { recipient });
1493
+ logger.debug("HTTP Signatures are verified.", { recipient });
1519
1494
  activityVerified = true;
1520
1495
  }
1521
1496
  httpSigKey = verification.key;
1522
1497
  }
1523
- activity = await __fedify_vocab.Activity.fromJsonLd(jsonWithoutSig, ctx);
1498
+ activity = await _fedify_vocab.Activity.fromJsonLd(jsonWithoutSig, ctx);
1524
1499
  }
1525
1500
  if (activity.id != null) span.setAttribute("activitypub.activity.id", activity.id.href);
1526
- span.setAttribute("activitypub.activity.type", (0, __fedify_vocab.getTypeId)(activity).href);
1501
+ span.setAttribute("activitypub.activity.type", (0, _fedify_vocab.getTypeId)(activity).href);
1527
1502
  span.addEvent("activitypub.activity.received", {
1528
1503
  "activitypub.activity.json": JSON.stringify(json),
1529
1504
  "activitypub.activity.verified": activityVerified,
@@ -1532,14 +1507,14 @@ async function handleInboxInternal(request, parameters, span) {
1532
1507
  "http_signatures.key_id": httpSigKey?.id?.href ?? ""
1533
1508
  });
1534
1509
  if (httpSigKey != null && !await require_proof.doesActorOwnKey(activity, httpSigKey, ctx)) {
1535
- logger$1.error("The signer ({keyId}) and the actor ({actorId}) do not match.", {
1510
+ logger.error("The signer ({keyId}) and the actor ({actorId}) do not match.", {
1536
1511
  activity: json,
1537
1512
  recipient,
1538
1513
  keyId: httpSigKey.id?.href,
1539
1514
  actorId: activity.actorId?.href
1540
1515
  });
1541
1516
  span.setStatus({
1542
- code: __opentelemetry_api.SpanStatusCode.ERROR,
1517
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
1543
1518
  message: `The signer (${httpSigKey.id?.href}) and the actor (${activity.actorId?.href}) do not match.`
1544
1519
  });
1545
1520
  return new Response("The signer and the actor do not match.", {
@@ -1548,9 +1523,8 @@ async function handleInboxInternal(request, parameters, span) {
1548
1523
  });
1549
1524
  }
1550
1525
  if (pendingNonceLabel != null) {
1551
- const nonceValid = await verifySignatureNonce(request, kv, kvPrefixes.acceptSignatureNonce, pendingNonceLabel);
1552
- if (!nonceValid) {
1553
- logger$1.error("Signature nonce verification failed (missing, expired, or replayed).", { recipient });
1526
+ if (!await verifySignatureNonce(request, kv, kvPrefixes.acceptSignatureNonce, pendingNonceLabel)) {
1527
+ logger.error("Signature nonce verification failed (missing, expired, or replayed).", { recipient });
1554
1528
  return await getFailedSignatureResponse(inboxChallengePolicy, kv, kvPrefixes);
1555
1529
  }
1556
1530
  }
@@ -1606,11 +1580,11 @@ async function handleInboxInternal(request, parameters, span) {
1606
1580
  * @since 1.8.0
1607
1581
  */
1608
1582
  const handleCustomCollection = exceptWrapper(_handleCustomCollection);
1609
- async function _handleCustomCollection(request, { name, values, context: context$2, tracerProvider, collectionCallbacks: callbacks, filterPredicate }) {
1583
+ async function _handleCustomCollection(request, { name, values, context, tracerProvider, collectionCallbacks: callbacks, filterPredicate }) {
1610
1584
  verifyDefined(callbacks);
1611
- await authIfNeeded(context$2, values, callbacks);
1585
+ await authIfNeeded(context, values, callbacks);
1612
1586
  const cursor = new URL(request.url).searchParams.get("cursor");
1613
- return await new CustomCollectionHandler(name, values, context$2, callbacks, tracerProvider, __fedify_vocab.Collection, __fedify_vocab.CollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
1587
+ return await new CustomCollectionHandler(name, values, context, callbacks, tracerProvider, _fedify_vocab.Collection, _fedify_vocab.CollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
1614
1588
  }
1615
1589
  /**
1616
1590
  * Handles an ordered collection request.
@@ -1624,11 +1598,11 @@ async function _handleCustomCollection(request, { name, values, context: context
1624
1598
  * @since 1.8.0
1625
1599
  */
1626
1600
  const handleOrderedCollection = exceptWrapper(_handleOrderedCollection);
1627
- async function _handleOrderedCollection(request, { name, values, context: context$2, tracerProvider, collectionCallbacks: callbacks, filterPredicate }) {
1601
+ async function _handleOrderedCollection(request, { name, values, context, tracerProvider, collectionCallbacks: callbacks, filterPredicate }) {
1628
1602
  verifyDefined(callbacks);
1629
- await authIfNeeded(context$2, values, callbacks);
1603
+ await authIfNeeded(context, values, callbacks);
1630
1604
  const cursor = new URL(request.url).searchParams.get("cursor");
1631
- return await new CustomCollectionHandler(name, values, context$2, callbacks, tracerProvider, __fedify_vocab.OrderedCollection, __fedify_vocab.OrderedCollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
1605
+ return await new CustomCollectionHandler(name, values, context, callbacks, tracerProvider, _fedify_vocab.OrderedCollection, _fedify_vocab.OrderedCollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
1632
1606
  }
1633
1607
  /**
1634
1608
  * Handling custom collections with support for pagination and filtering.
@@ -1678,17 +1652,17 @@ var CustomCollectionHandler = class {
1678
1652
  * @param CollectionPage The CollectionPage constructor.
1679
1653
  * @param filterPredicate Optional filter predicate for items.
1680
1654
  */
1681
- constructor(name, values, context$2, callbacks, tracerProvider = __opentelemetry_api.trace.getTracerProvider(), Collection$1, CollectionPage$1, filterPredicate) {
1682
- this.name = name;
1655
+ constructor(name$1, values, context, callbacks, tracerProvider = _opentelemetry_api.trace.getTracerProvider(), Collection, CollectionPage, filterPredicate) {
1656
+ this.name = name$1;
1683
1657
  this.values = values;
1684
- this.context = context$2;
1658
+ this.context = context;
1685
1659
  this.callbacks = callbacks;
1686
1660
  this.tracerProvider = tracerProvider;
1687
- this.Collection = Collection$1;
1688
- this.CollectionPage = CollectionPage$1;
1661
+ this.Collection = Collection;
1662
+ this.CollectionPage = CollectionPage;
1689
1663
  this.filterPredicate = filterPredicate;
1690
1664
  this.name = this.name.trim().replace(/\s+/g, "_");
1691
- this.#tracer = this.tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
1665
+ this.#tracer = this.tracerProvider.getTracer(require_http.name, require_http.version);
1692
1666
  this.#id = new URL(this.context.url);
1693
1667
  this.#dispatcher = callbacks.dispatcher.bind(callbacks);
1694
1668
  }
@@ -1717,8 +1691,8 @@ var CustomCollectionHandler = class {
1717
1691
  */
1718
1692
  async getCollection(cursor = null) {
1719
1693
  if (cursor !== null) {
1720
- const props$1 = await this.getPageProps(cursor);
1721
- return new this.CollectionPage(props$1);
1694
+ const props = await this.getPageProps(cursor);
1695
+ return new this.CollectionPage(props);
1722
1696
  }
1723
1697
  const firstCursor = await this.firstCursor;
1724
1698
  const props = typeof firstCursor === "string" ? await this.getProps(firstCursor) : await this.getPropsWithoutCursor();
@@ -1779,7 +1753,7 @@ var CustomCollectionHandler = class {
1779
1753
  * @returns A promise that resolves to the page items.
1780
1754
  */
1781
1755
  async getPages({ cursor = null, totalItems = null }) {
1782
- return await this.#tracer.startActiveSpan(`${this.ATTRS.DISPATCH_COLLECTION} ${this.name}`, this.spanOptions(__opentelemetry_api.SpanKind.SERVER, cursor), this.spanPages({
1756
+ return await this.#tracer.startActiveSpan(`${this.ATTRS.DISPATCH_COLLECTION} ${this.name}`, this.spanOptions(_opentelemetry_api.SpanKind.SERVER, cursor), this.spanPages({
1783
1757
  cursor,
1784
1758
  totalItems
1785
1759
  }));
@@ -1812,7 +1786,7 @@ var CustomCollectionHandler = class {
1812
1786
  } catch (e) {
1813
1787
  const message = e instanceof Error ? e.message : String(e);
1814
1788
  span.setStatus({
1815
- code: __opentelemetry_api.SpanStatusCode.ERROR,
1789
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
1816
1790
  message
1817
1791
  });
1818
1792
  throw e;
@@ -1866,7 +1840,7 @@ var CustomCollectionHandler = class {
1866
1840
  * @param value The total items count or a promise that resolves to it.
1867
1841
  */
1868
1842
  set totalItems(value) {
1869
- const toNumber = (value$1) => value$1 == null ? null : Number(value$1);
1843
+ const toNumber = (value) => value == null ? null : Number(value);
1870
1844
  this.#totalItems = value instanceof Promise ? value.then(toNumber) : Promise.resolve(toNumber(value));
1871
1845
  }
1872
1846
  /**
@@ -1930,9 +1904,9 @@ const verifyDefined = (callbacks) => {
1930
1904
  * @throws {UnauthorizedError} If authorization fails.
1931
1905
  * @since 1.8.0
1932
1906
  */
1933
- const authIfNeeded = async (context$2, values, { authorizePredicate: authorize = void 0 }) => {
1907
+ const authIfNeeded = async (context, values, { authorizePredicate: authorize = void 0 }) => {
1934
1908
  if (authorize === void 0) return;
1935
- if (!await authorize(context$2, values)) throw new UnauthorizedError();
1909
+ if (!await authorize(context, values)) throw new UnauthorizedError();
1936
1910
  };
1937
1911
  /**
1938
1912
  * Appends a cursor parameter to a URL if the cursor exists.
@@ -2034,8 +2008,7 @@ async function verifySignatureNonce(request, kv, noncePrefix, verifiedLabel) {
2034
2008
  if (nonce == null) return false;
2035
2009
  const key = [...noncePrefix, nonce];
2036
2010
  if (kv.cas != null) return await kv.cas(key, true, void 0);
2037
- const stored = await kv.get(key);
2038
- if (stored != null) {
2011
+ if (await kv.get(key) != null) {
2039
2012
  await kv.delete(key);
2040
2013
  return true;
2041
2014
  }
@@ -2060,18 +2033,16 @@ async function buildAcceptSignatureHeader(policy, kv, noncePrefix) {
2060
2033
  const parameters = { created: true };
2061
2034
  if (policy.requestNonce) {
2062
2035
  const nonce = generateNonce();
2063
- const key = [...noncePrefix, nonce];
2064
- await setKey(kv, key, policy);
2036
+ await setKey(kv, [...noncePrefix, nonce], policy);
2065
2037
  parameters.nonce = nonce;
2066
2038
  }
2067
2039
  const baseComponents = policy.components ?? DEF_COMPONENTS;
2068
- const components = (0, es_toolkit.uniq)(MIN_COMPONENTS.concat(baseComponents)).filter((c) => c !== "@status").map((v) => ({
2069
- value: v,
2070
- params: {}
2071
- }));
2072
2040
  return require_http.formatAcceptSignature([{
2073
2041
  label: "sig1",
2074
- components,
2042
+ components: (0, es_toolkit.uniq)(MIN_COMPONENTS.concat(baseComponents)).filter((c) => c !== "@status").map((v) => ({
2043
+ value: v,
2044
+ params: {}
2045
+ })),
2075
2046
  parameters
2076
2047
  }]);
2077
2048
  }
@@ -2091,7 +2062,6 @@ const MIN_COMPONENTS = [
2091
2062
  "@target-uri",
2092
2063
  "@authority"
2093
2064
  ];
2094
-
2095
2065
  //#endregion
2096
2066
  //#region src/nodeinfo/handler.ts
2097
2067
  /**
@@ -2101,10 +2071,9 @@ const MIN_COMPONENTS = [
2101
2071
  * @param parameters The parameters for handling the request.
2102
2072
  * @returns The response to the request.
2103
2073
  */
2104
- async function handleNodeInfo(_request, { context: context$2, nodeInfoDispatcher }) {
2105
- const promise = nodeInfoDispatcher(context$2);
2106
- const nodeInfo = promise instanceof Promise ? await promise : promise;
2107
- const json = require_types.nodeInfoToJson(nodeInfo);
2074
+ async function handleNodeInfo(_request, { context, nodeInfoDispatcher }) {
2075
+ const promise = nodeInfoDispatcher(context);
2076
+ const json = require_types.nodeInfoToJson(promise instanceof Promise ? await promise : promise);
2108
2077
  return new Response(JSON.stringify(json), { headers: { "Content-Type": "application/json; profile=\"http://nodeinfo.diaspora.software/ns/schema/2.1#\"" } });
2109
2078
  }
2110
2079
  /**
@@ -2114,22 +2083,20 @@ async function handleNodeInfo(_request, { context: context$2, nodeInfoDispatcher
2114
2083
  * @param context The request context.
2115
2084
  * @returns The response to the request.
2116
2085
  */
2117
- function handleNodeInfoJrd(_request, context$2) {
2086
+ function handleNodeInfoJrd(_request, context) {
2118
2087
  const links = [];
2119
2088
  try {
2120
2089
  links.push({
2121
2090
  rel: "http://nodeinfo.diaspora.software/ns/schema/2.1",
2122
- href: context$2.getNodeInfoUri().href,
2091
+ href: context.getNodeInfoUri().href,
2123
2092
  type: "application/json; profile=\"http://nodeinfo.diaspora.software/ns/schema/2.1#\""
2124
2093
  });
2125
2094
  } catch (e) {
2126
2095
  if (!(e instanceof RouterError)) throw e;
2127
2096
  }
2128
- const jrd = { links };
2129
- const response = new Response(JSON.stringify(jrd), { headers: { "Content-Type": "application/jrd+json" } });
2097
+ const response = new Response(JSON.stringify({ links }), { headers: { "Content-Type": "application/jrd+json" } });
2130
2098
  return Promise.resolve(response);
2131
2099
  }
2132
-
2133
2100
  //#endregion
2134
2101
  //#region src/federation/retry.ts
2135
2102
  /**
@@ -2160,7 +2127,6 @@ function createExponentialBackoffPolicy(options = {}) {
2160
2127
  return Temporal.Duration.compare(delay, maxDelay) > 0 ? maxDelay : delay;
2161
2128
  };
2162
2129
  }
2163
-
2164
2130
  //#endregion
2165
2131
  //#region src/federation/send.ts
2166
2132
  /**
@@ -2197,10 +2163,9 @@ function extractInboxes({ recipients, preferSharedInbox, excludeBaseUris }) {
2197
2163
  * @throws {Error} If the activity fails to send.
2198
2164
  */
2199
2165
  function sendActivity(options) {
2200
- const tracerProvider = options.tracerProvider ?? __opentelemetry_api.trace.getTracerProvider();
2201
- const tracer = tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
2202
- return tracer.startActiveSpan("activitypub.send_activity", {
2203
- kind: __opentelemetry_api.SpanKind.CLIENT,
2166
+ const tracerProvider = options.tracerProvider ?? _opentelemetry_api.trace.getTracerProvider();
2167
+ return tracerProvider.getTracer(require_http.name, require_http.version).startActiveSpan("activitypub.send_activity", {
2168
+ kind: _opentelemetry_api.SpanKind.CLIENT,
2204
2169
  attributes: { "activitypub.shared_inbox": options.sharedInbox ?? false }
2205
2170
  }, async (span) => {
2206
2171
  if (options.activityId != null) span.setAttribute("activitypub.activity.id", options.activityId);
@@ -2212,7 +2177,7 @@ function sendActivity(options) {
2212
2177
  }, span);
2213
2178
  } catch (e) {
2214
2179
  span.setStatus({
2215
- code: __opentelemetry_api.SpanStatusCode.ERROR,
2180
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
2216
2181
  message: String(e)
2217
2182
  });
2218
2183
  throw e;
@@ -2250,7 +2215,7 @@ async function readLimitedResponseBody(response, maxBytes) {
2250
2215
  return result;
2251
2216
  }
2252
2217
  async function sendActivityInternal({ activity, activityId, keys, inbox, headers, specDeterminer, tracerProvider }, span) {
2253
- const logger$1 = (0, __logtape_logtape.getLogger)([
2218
+ const logger = (0, _logtape_logtape.getLogger)([
2254
2219
  "fedify",
2255
2220
  "federation",
2256
2221
  "outbox"
@@ -2267,7 +2232,7 @@ async function sendActivityInternal({ activity, activityId, keys, inbox, headers
2267
2232
  rsaKey = key;
2268
2233
  break;
2269
2234
  }
2270
- if (rsaKey == null) logger$1.warn("No supported key found to sign the request to {inbox}. The request will be sent without a signature. In order to sign the request, at least one RSASSA-PKCS1-v1_5 key must be provided.", {
2235
+ if (rsaKey == null) logger.warn("No supported key found to sign the request to {inbox}. The request will be sent without a signature. In order to sign the request, at least one RSASSA-PKCS1-v1_5 key must be provided.", {
2271
2236
  inbox: inbox.href,
2272
2237
  keys: keys.map((pair) => ({
2273
2238
  keyId: pair.keyId.href,
@@ -2281,7 +2246,7 @@ async function sendActivityInternal({ activity, activityId, keys, inbox, headers
2281
2246
  specDeterminer
2282
2247
  });
2283
2248
  } catch (error) {
2284
- logger$1.error("Failed to send activity {activityId} to {inbox}:\n{error}", {
2249
+ logger.error("Failed to send activity {activityId} to {inbox}:\n{error}", {
2285
2250
  activityId,
2286
2251
  inbox: inbox.href,
2287
2252
  error
@@ -2295,7 +2260,7 @@ async function sendActivityInternal({ activity, activityId, keys, inbox, headers
2295
2260
  } catch (_) {
2296
2261
  error = "";
2297
2262
  }
2298
- logger$1.error("Failed to send activity {activityId} to {inbox} ({status} {statusText}):\n{error}", {
2263
+ logger.error("Failed to send activity {activityId} to {inbox} ({status} {statusText}):\n{error}", {
2299
2264
  activityId,
2300
2265
  inbox: inbox.href,
2301
2266
  status: response.status,
@@ -2347,10 +2312,9 @@ var SendActivityError = class extends Error {
2347
2312
  this.responseBody = responseBody;
2348
2313
  }
2349
2314
  };
2350
-
2351
2315
  //#endregion
2352
2316
  //#region src/federation/webfinger.ts
2353
- const logger = (0, __logtape_logtape.getLogger)([
2317
+ const logger = (0, _logtape_logtape.getLogger)([
2354
2318
  "fedify",
2355
2319
  "webfinger",
2356
2320
  "server"
@@ -2364,14 +2328,14 @@ const logger = (0, __logtape_logtape.getLogger)([
2364
2328
  */
2365
2329
  async function handleWebFinger(request, options) {
2366
2330
  if (options.tracer == null) return await handleWebFingerInternal(request, options);
2367
- return await options.tracer.startActiveSpan("webfinger.handle", { kind: __opentelemetry_api.SpanKind.SERVER }, async (span) => {
2331
+ return await options.tracer.startActiveSpan("webfinger.handle", { kind: _opentelemetry_api.SpanKind.SERVER }, async (span) => {
2368
2332
  try {
2369
2333
  const response = await handleWebFingerInternal(request, options);
2370
- span.setStatus({ code: response.ok ? __opentelemetry_api.SpanStatusCode.UNSET : __opentelemetry_api.SpanStatusCode.ERROR });
2334
+ span.setStatus({ code: response.ok ? _opentelemetry_api.SpanStatusCode.UNSET : _opentelemetry_api.SpanStatusCode.ERROR });
2371
2335
  return response;
2372
2336
  } catch (error) {
2373
2337
  span.setStatus({
2374
- code: __opentelemetry_api.SpanStatusCode.ERROR,
2338
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
2375
2339
  message: String(error)
2376
2340
  });
2377
2341
  throw error;
@@ -2380,12 +2344,12 @@ async function handleWebFinger(request, options) {
2380
2344
  }
2381
2345
  });
2382
2346
  }
2383
- async function handleWebFingerInternal(request, { context: context$2, host, actorDispatcher, actorHandleMapper, actorAliasMapper, onNotFound, span, webFingerLinksDispatcher }) {
2347
+ async function handleWebFingerInternal(request, { context, host, actorDispatcher, actorHandleMapper, actorAliasMapper, onNotFound, span, webFingerLinksDispatcher }) {
2384
2348
  if (actorDispatcher == null) {
2385
2349
  logger.error("Actor dispatcher is not set.");
2386
2350
  return await onNotFound(request);
2387
2351
  }
2388
- const resource = context$2.url.searchParams.get("resource");
2352
+ const resource = context.url.searchParams.get("resource");
2389
2353
  if (resource == null) return new Response("Missing resource parameter.", { status: 400 });
2390
2354
  span?.setAttribute("webfinger.resource", resource);
2391
2355
  let resourceUrl;
@@ -2401,26 +2365,26 @@ async function handleWebFingerInternal(request, { context: context$2, host, acto
2401
2365
  logger.error("No actor handle mapper is set; use the WebFinger username {username} as the actor's internal identifier.", { username });
2402
2366
  return username;
2403
2367
  }
2404
- const identifier$1 = await actorHandleMapper(context$2, username);
2405
- if (identifier$1 == null) {
2368
+ const identifier = await actorHandleMapper(context, username);
2369
+ if (identifier == null) {
2406
2370
  logger.error("Actor {username} not found.", { username });
2407
2371
  return null;
2408
2372
  }
2409
- return identifier$1;
2373
+ return identifier;
2410
2374
  }
2411
2375
  let identifier = null;
2412
- const uriParsed = context$2.parseUri(resourceUrl);
2376
+ const uriParsed = context.parseUri(resourceUrl);
2413
2377
  if (uriParsed?.type != "actor") {
2414
2378
  const match = /^acct:([^@]+)@([^@]+)$/.exec(resource);
2415
2379
  if (match == null) {
2416
- const result = await actorAliasMapper?.(context$2, resourceUrl);
2380
+ const result = await actorAliasMapper?.(context, resourceUrl);
2417
2381
  if (result == null) return await onNotFound(request);
2418
2382
  if ("identifier" in result) identifier = result.identifier;
2419
2383
  else identifier = await mapUsernameToIdentifier(result.username);
2420
2384
  } else {
2421
2385
  const portMatch = /:\d+$/.exec(match[2]);
2422
2386
  const normalizedHost = portMatch == null ? (0, node_url.domainToASCII)(match[2].toLowerCase()) : (0, node_url.domainToASCII)(match[2].substring(0, portMatch.index).toLowerCase()) + portMatch[0];
2423
- if (normalizedHost != context$2.url.host && normalizedHost != host) return await onNotFound(request);
2387
+ if (normalizedHost != context.url.host && normalizedHost != host) return await onNotFound(request);
2424
2388
  else {
2425
2389
  identifier = await mapUsernameToIdentifier(match[1]);
2426
2390
  resourceUrl = new URL(`acct:${match[1]}@${normalizedHost}`);
@@ -2428,17 +2392,17 @@ async function handleWebFingerInternal(request, { context: context$2, host, acto
2428
2392
  }
2429
2393
  } else identifier = uriParsed.identifier;
2430
2394
  if (identifier == null) return await onNotFound(request);
2431
- const actor = await actorDispatcher(context$2, identifier);
2395
+ const actor = await actorDispatcher(context, identifier);
2432
2396
  if (actor == null) {
2433
2397
  logger.error("Actor {identifier} not found.", { identifier });
2434
2398
  return await onNotFound(request);
2435
2399
  }
2436
2400
  const links = [{
2437
2401
  rel: "self",
2438
- href: context$2.getActorUri(identifier).href,
2402
+ href: context.getActorUri(identifier).href,
2439
2403
  type: "application/activity+json"
2440
2404
  }];
2441
- for (const url of actor.urls) if (url instanceof __fedify_vocab.Link && url.href != null) links.push({
2405
+ for (const url of actor.urls) if (url instanceof _fedify_vocab.Link && url.href != null) links.push({
2442
2406
  rel: url.rel ?? "http://webfinger.net/rel/profile-page",
2443
2407
  href: url.href.href,
2444
2408
  type: url.mediaType == null ? void 0 : url.mediaType
@@ -2456,16 +2420,16 @@ async function handleWebFingerInternal(request, { context: context$2, host, acto
2456
2420
  });
2457
2421
  }
2458
2422
  if (webFingerLinksDispatcher != null) {
2459
- const customLinks = await webFingerLinksDispatcher(context$2, resourceUrl);
2423
+ const customLinks = await webFingerLinksDispatcher(context, resourceUrl);
2460
2424
  if (customLinks != null) for (const link of customLinks) links.push(link);
2461
2425
  }
2462
2426
  const aliases = [];
2463
2427
  if (resourceUrl.protocol != "acct:" && actor.preferredUsername != null) {
2464
- aliases.push(`acct:${actor.preferredUsername}@${host ?? context$2.url.host}`);
2465
- if (host != null && host !== context$2.url.host) aliases.push(`acct:${actor.preferredUsername}@${context$2.url.host}`);
2428
+ aliases.push(`acct:${actor.preferredUsername}@${host ?? context.url.host}`);
2429
+ if (host != null && host !== context.url.host) aliases.push(`acct:${actor.preferredUsername}@${context.url.host}`);
2466
2430
  }
2467
- if (resourceUrl.href !== context$2.getActorUri(identifier).href) aliases.push(context$2.getActorUri(identifier).href);
2468
- if (resourceUrl.protocol === "acct:" && host != null && host !== context$2.url.host && !resourceUrl.href.endsWith(`@${host}`)) {
2431
+ if (resourceUrl.href !== context.getActorUri(identifier).href) aliases.push(context.getActorUri(identifier).href);
2432
+ if (resourceUrl.protocol === "acct:" && host != null && host !== context.url.host && !resourceUrl.href.endsWith(`@${host}`)) {
2469
2433
  const username = resourceUrl.href.replace(/^acct:/, "").replace(/@.*$/, "");
2470
2434
  aliases.push(`acct:${username}@${host}`);
2471
2435
  }
@@ -2479,7 +2443,6 @@ async function handleWebFingerInternal(request, { context: context$2, host, acto
2479
2443
  "Access-Control-Allow-Origin": "*"
2480
2444
  } });
2481
2445
  }
2482
-
2483
2446
  //#endregion
2484
2447
  //#region src/federation/middleware.ts
2485
2448
  /**
@@ -2575,7 +2538,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2575
2538
  this.allowPrivateAddress = allowPrivateAddress ?? false;
2576
2539
  this.documentLoaderFactory = options.documentLoaderFactory ?? ((opts) => {
2577
2540
  return require_kv_cache.kvCache({
2578
- loader: (0, __fedify_vocab_runtime.getDocumentLoader)({
2541
+ loader: (0, _fedify_vocab_runtime.getDocumentLoader)({
2579
2542
  allowPrivateAddress: opts?.allowPrivateAddress ?? allowPrivateAddress,
2580
2543
  userAgent: opts?.userAgent ?? userAgent
2581
2544
  }),
@@ -2603,35 +2566,35 @@ var FederationImpl = class extends FederationBuilderImpl {
2603
2566
  this.firstKnock = options.firstKnock;
2604
2567
  }
2605
2568
  get tracerProvider() {
2606
- return this._tracerProvider ?? __opentelemetry_api.trace.getTracerProvider();
2569
+ return this._tracerProvider ?? _opentelemetry_api.trace.getTracerProvider();
2607
2570
  }
2608
2571
  _initializeRouter() {
2609
2572
  this.router.add("/.well-known/webfinger", "webfinger");
2610
2573
  this.router.add("/.well-known/nodeinfo", "nodeInfoJrd");
2611
2574
  }
2612
2575
  _getTracer() {
2613
- return this.tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
2576
+ return this.tracerProvider.getTracer(require_http.name, require_http.version);
2614
2577
  }
2615
2578
  async _startQueueInternal(ctxData, signal, queue) {
2616
2579
  if (this.inboxQueue == null && this.outboxQueue == null) return;
2617
- const logger$1 = (0, __logtape_logtape.getLogger)([
2580
+ const logger = (0, _logtape_logtape.getLogger)([
2618
2581
  "fedify",
2619
2582
  "federation",
2620
2583
  "queue"
2621
2584
  ]);
2622
2585
  const promises = [];
2623
2586
  if (this.inboxQueue != null && (queue == null || queue === "inbox") && !this.inboxQueueStarted) {
2624
- logger$1.debug("Starting an inbox task worker.");
2587
+ logger.debug("Starting an inbox task worker.");
2625
2588
  this.inboxQueueStarted = true;
2626
2589
  promises.push(this.inboxQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
2627
2590
  }
2628
2591
  if (this.outboxQueue != null && this.outboxQueue !== this.inboxQueue && (queue == null || queue === "outbox") && !this.outboxQueueStarted) {
2629
- logger$1.debug("Starting an outbox task worker.");
2592
+ logger.debug("Starting an outbox task worker.");
2630
2593
  this.outboxQueueStarted = true;
2631
2594
  promises.push(this.outboxQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
2632
2595
  }
2633
2596
  if (this.fanoutQueue != null && this.fanoutQueue !== this.inboxQueue && this.fanoutQueue !== this.outboxQueue && (queue == null || queue === "fanout") && !this.fanoutQueueStarted) {
2634
- logger$1.debug("Starting a fanout task worker.");
2597
+ logger.debug("Starting a fanout task worker.");
2635
2598
  this.fanoutQueueStarted = true;
2636
2599
  promises.push(this.fanoutQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
2637
2600
  }
@@ -2639,14 +2602,14 @@ var FederationImpl = class extends FederationBuilderImpl {
2639
2602
  }
2640
2603
  processQueuedTask(contextData, message) {
2641
2604
  const tracer = this._getTracer();
2642
- const extractedContext = __opentelemetry_api.propagation.extract(__opentelemetry_api.context.active(), message.traceContext);
2643
- return (0, __logtape_logtape.withContext)({ messageId: message.id }, async () => {
2605
+ const extractedContext = _opentelemetry_api.propagation.extract(_opentelemetry_api.context.active(), message.traceContext);
2606
+ return (0, _logtape_logtape.withContext)({ messageId: message.id }, async () => {
2644
2607
  if (message.type === "fanout") await tracer.startActiveSpan("activitypub.fanout", {
2645
- kind: __opentelemetry_api.SpanKind.CONSUMER,
2608
+ kind: _opentelemetry_api.SpanKind.CONSUMER,
2646
2609
  attributes: { "activitypub.activity.type": message.activityType }
2647
2610
  }, extractedContext, async (span) => {
2648
2611
  const spanCtx = span.spanContext();
2649
- return await (0, __logtape_logtape.withContext)({
2612
+ return await (0, _logtape_logtape.withContext)({
2650
2613
  traceId: spanCtx.traceId,
2651
2614
  spanId: spanCtx.spanId
2652
2615
  }, async () => {
@@ -2655,7 +2618,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2655
2618
  await this.#listenFanoutMessage(contextData, message);
2656
2619
  } catch (e) {
2657
2620
  span.setStatus({
2658
- code: __opentelemetry_api.SpanStatusCode.ERROR,
2621
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
2659
2622
  message: String(e)
2660
2623
  });
2661
2624
  throw e;
@@ -2665,14 +2628,14 @@ var FederationImpl = class extends FederationBuilderImpl {
2665
2628
  });
2666
2629
  });
2667
2630
  else if (message.type === "outbox") await tracer.startActiveSpan("activitypub.outbox", {
2668
- kind: __opentelemetry_api.SpanKind.CONSUMER,
2631
+ kind: _opentelemetry_api.SpanKind.CONSUMER,
2669
2632
  attributes: {
2670
2633
  "activitypub.activity.type": message.activityType,
2671
2634
  "activitypub.activity.retries": message.attempt
2672
2635
  }
2673
2636
  }, extractedContext, async (span) => {
2674
2637
  const spanCtx = span.spanContext();
2675
- return await (0, __logtape_logtape.withContext)({
2638
+ return await (0, _logtape_logtape.withContext)({
2676
2639
  traceId: spanCtx.traceId,
2677
2640
  spanId: spanCtx.spanId
2678
2641
  }, async () => {
@@ -2681,7 +2644,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2681
2644
  await this.#listenOutboxMessage(contextData, message, span);
2682
2645
  } catch (e) {
2683
2646
  span.setStatus({
2684
- code: __opentelemetry_api.SpanStatusCode.ERROR,
2647
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
2685
2648
  message: String(e)
2686
2649
  });
2687
2650
  throw e;
@@ -2691,11 +2654,11 @@ var FederationImpl = class extends FederationBuilderImpl {
2691
2654
  });
2692
2655
  });
2693
2656
  else if (message.type === "inbox") await tracer.startActiveSpan("activitypub.inbox", {
2694
- kind: __opentelemetry_api.SpanKind.CONSUMER,
2657
+ kind: _opentelemetry_api.SpanKind.CONSUMER,
2695
2658
  attributes: { "activitypub.shared_inbox": message.identifier == null }
2696
2659
  }, extractedContext, async (span) => {
2697
2660
  const spanCtx = span.spanContext();
2698
- return await (0, __logtape_logtape.withContext)({
2661
+ return await (0, _logtape_logtape.withContext)({
2699
2662
  traceId: spanCtx.traceId,
2700
2663
  spanId: spanCtx.spanId
2701
2664
  }, async () => {
@@ -2703,7 +2666,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2703
2666
  await this.#listenInboxMessage(contextData, message, span);
2704
2667
  } catch (e) {
2705
2668
  span.setStatus({
2706
- code: __opentelemetry_api.SpanStatusCode.ERROR,
2669
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
2707
2670
  message: String(e)
2708
2671
  });
2709
2672
  throw e;
@@ -2715,12 +2678,11 @@ var FederationImpl = class extends FederationBuilderImpl {
2715
2678
  });
2716
2679
  }
2717
2680
  async #listenFanoutMessage(data, message) {
2718
- const logger$1 = (0, __logtape_logtape.getLogger)([
2681
+ (0, _logtape_logtape.getLogger)([
2719
2682
  "fedify",
2720
2683
  "federation",
2721
2684
  "fanout"
2722
- ]);
2723
- logger$1.debug("Fanning out activity {activityId} to {inboxes} inbox(es)...", {
2685
+ ]).debug("Fanning out activity {activityId} to {inboxes} inbox(es)...", {
2724
2686
  activityId: message.activityId,
2725
2687
  inboxes: globalThis.Object.keys(message.inboxes).length
2726
2688
  });
@@ -2728,7 +2690,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2728
2690
  keyId: new URL(keyId),
2729
2691
  privateKey: await require_http.importJwk(privateKey, "private")
2730
2692
  })));
2731
- const activity = await __fedify_vocab.Activity.fromJsonLd(message.activity, {
2693
+ const activity = await _fedify_vocab.Activity.fromJsonLd(message.activity, {
2732
2694
  contextLoader: this.contextLoaderFactory({
2733
2695
  allowPrivateAddress: this.allowPrivateAddress,
2734
2696
  userAgent: this.userAgent
@@ -2739,18 +2701,18 @@ var FederationImpl = class extends FederationBuilderImpl {
2739
2701
  }),
2740
2702
  tracerProvider: this.tracerProvider
2741
2703
  });
2742
- const context$2 = this.#createContext(new URL(message.baseUrl), data, { documentLoader: this.documentLoaderFactory({
2704
+ const context = this.#createContext(new URL(message.baseUrl), data, { documentLoader: this.documentLoaderFactory({
2743
2705
  allowPrivateAddress: this.allowPrivateAddress,
2744
2706
  userAgent: this.userAgent
2745
2707
  }) });
2746
2708
  await this.sendActivity(keys, message.inboxes, activity, {
2747
2709
  collectionSync: message.collectionSync,
2748
2710
  orderingKey: message.orderingKey,
2749
- context: context$2
2711
+ context
2750
2712
  });
2751
2713
  }
2752
2714
  async #listenOutboxMessage(_, message, span) {
2753
- const logger$1 = (0, __logtape_logtape.getLogger)([
2715
+ const logger = (0, _logtape_logtape.getLogger)([
2754
2716
  "fedify",
2755
2717
  "federation",
2756
2718
  "outbox"
@@ -2787,25 +2749,25 @@ var FederationImpl = class extends FederationBuilderImpl {
2787
2749
  });
2788
2750
  } catch (error) {
2789
2751
  span.setStatus({
2790
- code: __opentelemetry_api.SpanStatusCode.ERROR,
2752
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
2791
2753
  message: String(error)
2792
2754
  });
2793
2755
  const loaderOptions = this.#getLoaderOptions(message.baseUrl);
2794
- const activity = await __fedify_vocab.Activity.fromJsonLd(message.activity, {
2756
+ const activity = await _fedify_vocab.Activity.fromJsonLd(message.activity, {
2795
2757
  contextLoader: this.contextLoaderFactory(loaderOptions),
2796
2758
  documentLoader: rsaKeyPair == null ? this.documentLoaderFactory(loaderOptions) : this.authenticatedDocumentLoaderFactory(rsaKeyPair, loaderOptions),
2797
2759
  tracerProvider: this.tracerProvider
2798
2760
  });
2799
2761
  try {
2800
2762
  await this.onOutboxError?.(error, activity);
2801
- } catch (error$1) {
2802
- logger$1.error("An unexpected error occurred in onError handler:\n{error}", {
2763
+ } catch (error) {
2764
+ logger.error("An unexpected error occurred in onError handler:\n{error}", {
2803
2765
  ...logData,
2804
- error: error$1
2766
+ error
2805
2767
  });
2806
2768
  }
2807
2769
  if (error instanceof SendActivityError && this.permanentFailureStatusCodes.includes(error.statusCode)) {
2808
- logger$1.warn("Permanent delivery failure for activity {activityId} to {inbox} ({status}); not retrying.", {
2770
+ logger.warn("Permanent delivery failure for activity {activityId} to {inbox} ({status}); not retrying.", {
2809
2771
  ...logData,
2810
2772
  status: error.statusCode
2811
2773
  });
@@ -2821,13 +2783,13 @@ var FederationImpl = class extends FederationBuilderImpl {
2821
2783
  try {
2822
2784
  return [new URL(id)];
2823
2785
  } catch {
2824
- logger$1.warn("Invalid actorId URL in OutboxMessage: {id}", { id });
2786
+ logger.warn("Invalid actorId URL in OutboxMessage: {id}", { id });
2825
2787
  return [];
2826
2788
  }
2827
2789
  })
2828
2790
  });
2829
2791
  } catch (handlerError) {
2830
- logger$1.error("An unexpected error occurred in outboxPermanentFailureHandler:\n{error}", {
2792
+ logger.error("An unexpected error occurred in outboxPermanentFailureHandler:\n{error}", {
2831
2793
  ...logData,
2832
2794
  error: handlerError
2833
2795
  });
@@ -2836,7 +2798,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2836
2798
  return;
2837
2799
  }
2838
2800
  if (this.outboxQueue?.nativeRetrial) {
2839
- logger$1.error("Failed to send activity {activityId} to {inbox}; backend will handle retry:\n{error}", {
2801
+ logger.error("Failed to send activity {activityId} to {inbox}; backend will handle retry:\n{error}", {
2840
2802
  ...logData,
2841
2803
  error
2842
2804
  });
@@ -2847,7 +2809,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2847
2809
  attempts: message.attempt
2848
2810
  });
2849
2811
  if (delay != null) {
2850
- logger$1.error("Failed to send activity {activityId} to {inbox} (attempt #{attempt}); retry...:\n{error}", {
2812
+ logger.error("Failed to send activity {activityId} to {inbox} (attempt #{attempt}); retry...:\n{error}", {
2851
2813
  ...logData,
2852
2814
  error
2853
2815
  });
@@ -2855,39 +2817,38 @@ var FederationImpl = class extends FederationBuilderImpl {
2855
2817
  ...message,
2856
2818
  attempt: message.attempt + 1
2857
2819
  }, { delay: Temporal.Duration.compare(delay, { seconds: 0 }) < 0 ? Temporal.Duration.from({ seconds: 0 }) : delay });
2858
- } else logger$1.error("Failed to send activity {activityId} to {inbox} after {attempt} attempts; giving up:\n{error}", {
2820
+ } else logger.error("Failed to send activity {activityId} to {inbox} after {attempt} attempts; giving up:\n{error}", {
2859
2821
  ...logData,
2860
2822
  error
2861
2823
  });
2862
2824
  return;
2863
2825
  }
2864
- logger$1.info("Successfully sent activity {activityId} to {inbox}.", { ...logData });
2826
+ logger.info("Successfully sent activity {activityId} to {inbox}.", { ...logData });
2865
2827
  }
2866
2828
  async #listenInboxMessage(ctxData, message, span) {
2867
- const logger$1 = (0, __logtape_logtape.getLogger)([
2829
+ const logger = (0, _logtape_logtape.getLogger)([
2868
2830
  "fedify",
2869
2831
  "federation",
2870
2832
  "inbox"
2871
2833
  ]);
2872
2834
  const baseUrl = new URL(message.baseUrl);
2873
- let context$2 = this.#createContext(baseUrl, ctxData);
2874
- if (message.identifier != null) context$2 = this.#createContext(baseUrl, ctxData, { documentLoader: await context$2.getDocumentLoader({ identifier: message.identifier }) });
2835
+ let context = this.#createContext(baseUrl, ctxData);
2836
+ if (message.identifier != null) context = this.#createContext(baseUrl, ctxData, { documentLoader: await context.getDocumentLoader({ identifier: message.identifier }) });
2875
2837
  else if (this.sharedInboxKeyDispatcher != null) {
2876
- const identity = await this.sharedInboxKeyDispatcher(context$2);
2877
- if (identity != null) context$2 = this.#createContext(baseUrl, ctxData, { documentLoader: "identifier" in identity || "username" in identity ? await context$2.getDocumentLoader(identity) : context$2.getDocumentLoader(identity) });
2838
+ const identity = await this.sharedInboxKeyDispatcher(context);
2839
+ if (identity != null) context = this.#createContext(baseUrl, ctxData, { documentLoader: "identifier" in identity || "username" in identity ? await context.getDocumentLoader(identity) : context.getDocumentLoader(identity) });
2878
2840
  }
2879
- const activity = await __fedify_vocab.Activity.fromJsonLd(message.activity, context$2);
2880
- span.setAttribute("activitypub.activity.type", (0, __fedify_vocab.getTypeId)(activity).href);
2841
+ const activity = await _fedify_vocab.Activity.fromJsonLd(message.activity, context);
2842
+ span.setAttribute("activitypub.activity.type", (0, _fedify_vocab.getTypeId)(activity).href);
2881
2843
  if (activity.id != null) span.setAttribute("activitypub.activity.id", activity.id.href);
2882
2844
  const cacheKey = activity.id == null ? null : [
2883
2845
  ...this.kvPrefixes.activityIdempotence,
2884
- context$2.origin,
2846
+ context.origin,
2885
2847
  activity.id.href
2886
2848
  ];
2887
2849
  if (cacheKey != null) {
2888
- const cached = await this.kv.get(cacheKey);
2889
- if (cached === true) {
2890
- logger$1.debug("Activity {activityId} has already been processed.", {
2850
+ if (await this.kv.get(cacheKey) === true) {
2851
+ logger.debug("Activity {activityId} has already been processed.", {
2891
2852
  activityId: activity.id?.href,
2892
2853
  activity: message.activity,
2893
2854
  recipient: message.identifier
@@ -2895,32 +2856,32 @@ var FederationImpl = class extends FederationBuilderImpl {
2895
2856
  return;
2896
2857
  }
2897
2858
  }
2898
- await this._getTracer().startActiveSpan("activitypub.dispatch_inbox_listener", { kind: __opentelemetry_api.SpanKind.INTERNAL }, async (span$1) => {
2859
+ await this._getTracer().startActiveSpan("activitypub.dispatch_inbox_listener", { kind: _opentelemetry_api.SpanKind.INTERNAL }, async (span) => {
2899
2860
  const dispatched = this.inboxListeners?.dispatchWithClass(activity);
2900
2861
  if (dispatched == null) {
2901
- logger$1.error("Unsupported activity type:\n{activity}", {
2862
+ logger.error("Unsupported activity type:\n{activity}", {
2902
2863
  activityId: activity.id?.href,
2903
2864
  activity: message.activity,
2904
2865
  recipient: message.identifier,
2905
2866
  trial: message.attempt
2906
2867
  });
2907
- span$1.setStatus({
2908
- code: __opentelemetry_api.SpanStatusCode.ERROR,
2909
- message: `Unsupported activity type: ${(0, __fedify_vocab.getTypeId)(activity).href}`
2868
+ span.setStatus({
2869
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
2870
+ message: `Unsupported activity type: ${(0, _fedify_vocab.getTypeId)(activity).href}`
2910
2871
  });
2911
- span$1.end();
2872
+ span.end();
2912
2873
  return;
2913
2874
  }
2914
2875
  const { class: cls, listener } = dispatched;
2915
- span$1.updateName(`activitypub.dispatch_inbox_listener ${cls.name}`);
2876
+ span.updateName(`activitypub.dispatch_inbox_listener ${cls.name}`);
2916
2877
  try {
2917
- await listener(context$2.toInboxContext(message.identifier, message.activity, activity.id?.href, (0, __fedify_vocab.getTypeId)(activity).href), activity);
2878
+ await listener(context.toInboxContext(message.identifier, message.activity, activity.id?.href, (0, _fedify_vocab.getTypeId)(activity).href), activity);
2918
2879
  } catch (error) {
2919
2880
  try {
2920
- await this.inboxErrorHandler?.(context$2, error);
2921
- } catch (error$1) {
2922
- logger$1.error("An unexpected error occurred in inbox error handler:\n{error}", {
2923
- error: error$1,
2881
+ await this.inboxErrorHandler?.(context, error);
2882
+ } catch (error) {
2883
+ logger.error("An unexpected error occurred in inbox error handler:\n{error}", {
2884
+ error,
2924
2885
  trial: message.attempt,
2925
2886
  activityId: activity.id?.href,
2926
2887
  activity: message.activity,
@@ -2928,17 +2889,17 @@ var FederationImpl = class extends FederationBuilderImpl {
2928
2889
  });
2929
2890
  }
2930
2891
  if (this.inboxQueue?.nativeRetrial) {
2931
- logger$1.error("Failed to process the incoming activity {activityId}; backend will handle retry:\n{error}", {
2892
+ logger.error("Failed to process the incoming activity {activityId}; backend will handle retry:\n{error}", {
2932
2893
  error,
2933
2894
  activityId: activity.id?.href,
2934
2895
  activity: message.activity,
2935
2896
  recipient: message.identifier
2936
2897
  });
2937
- span$1.setStatus({
2938
- code: __opentelemetry_api.SpanStatusCode.ERROR,
2898
+ span.setStatus({
2899
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
2939
2900
  message: String(error)
2940
2901
  });
2941
- span$1.end();
2902
+ span.end();
2942
2903
  throw error;
2943
2904
  }
2944
2905
  const delay = this.inboxRetryPolicy({
@@ -2946,7 +2907,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2946
2907
  attempts: message.attempt
2947
2908
  });
2948
2909
  if (delay != null) {
2949
- logger$1.error("Failed to process the incoming activity {activityId} (attempt #{attempt}); retry...:\n{error}", {
2910
+ logger.error("Failed to process the incoming activity {activityId} (attempt #{attempt}); retry...:\n{error}", {
2950
2911
  error,
2951
2912
  attempt: message.attempt,
2952
2913
  activityId: activity.id?.href,
@@ -2957,26 +2918,26 @@ var FederationImpl = class extends FederationBuilderImpl {
2957
2918
  ...message,
2958
2919
  attempt: message.attempt + 1
2959
2920
  }, { delay: Temporal.Duration.compare(delay, { seconds: 0 }) < 0 ? Temporal.Duration.from({ seconds: 0 }) : delay });
2960
- } else logger$1.error("Failed to process the incoming activity {activityId} after {trial} attempts; giving up:\n{error}", {
2921
+ } else logger.error("Failed to process the incoming activity {activityId} after {trial} attempts; giving up:\n{error}", {
2961
2922
  error,
2962
2923
  activityId: activity.id?.href,
2963
2924
  activity: message.activity,
2964
2925
  recipient: message.identifier
2965
2926
  });
2966
- span$1.setStatus({
2967
- code: __opentelemetry_api.SpanStatusCode.ERROR,
2927
+ span.setStatus({
2928
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
2968
2929
  message: String(error)
2969
2930
  });
2970
- span$1.end();
2931
+ span.end();
2971
2932
  return;
2972
2933
  }
2973
2934
  if (cacheKey != null) await this.kv.set(cacheKey, true, { ttl: Temporal.Duration.from({ days: 1 }) });
2974
- logger$1.info("Activity {activityId} has been processed.", {
2935
+ logger.info("Activity {activityId} has been processed.", {
2975
2936
  activityId: activity.id?.href,
2976
2937
  activity: message.activity,
2977
2938
  recipient: message.identifier
2978
2939
  });
2979
- span$1.end();
2940
+ span.end();
2980
2941
  });
2981
2942
  }
2982
2943
  startQueue(contextData, options = {}) {
@@ -3020,7 +2981,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3020
2981
  };
3021
2982
  }
3022
2983
  async sendActivity(keys, inboxes, activity, options) {
3023
- const logger$1 = (0, __logtape_logtape.getLogger)([
2984
+ const logger = (0, _logtape_logtape.getLogger)([
3024
2985
  "fedify",
3025
2986
  "federation",
3026
2987
  "outbox"
@@ -3054,7 +3015,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3054
3015
  format: "compact",
3055
3016
  contextLoader
3056
3017
  });
3057
- if (rsaKey == null) logger$1.warn("No supported key found to create a Linked Data signature for the activity {activityId}. The activity will be sent without a Linked Data signature. In order to create a Linked Data signature, at least one RSASSA-PKCS1-v1_5 key must be provided.", {
3018
+ if (rsaKey == null) logger.warn("No supported key found to create a Linked Data signature for the activity {activityId}. The activity will be sent without a Linked Data signature. In order to create a Linked Data signature, at least one RSASSA-PKCS1-v1_5 key must be provided.", {
3058
3019
  activityId,
3059
3020
  keys: keys.map((pair) => ({
3060
3021
  keyId: pair.keyId.href,
@@ -3065,7 +3026,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3065
3026
  contextLoader,
3066
3027
  tracerProvider: this.tracerProvider
3067
3028
  });
3068
- if (!proofCreated) logger$1.warn("No supported key found to create a proof for the activity {activityId}. The activity will be sent without a proof. In order to create a proof, at least one Ed25519 key must be provided.", {
3029
+ if (!proofCreated) logger.warn("No supported key found to create a proof for the activity {activityId}. The activity will be sent without a proof. In order to create a proof, at least one Ed25519 key must be provided.", {
3069
3030
  activityId,
3070
3031
  keys: keys.map((pair) => ({
3071
3032
  keyId: pair.keyId.href,
@@ -3073,11 +3034,11 @@ var FederationImpl = class extends FederationBuilderImpl {
3073
3034
  }))
3074
3035
  });
3075
3036
  if (immediate || this.outboxQueue == null) {
3076
- if (immediate) logger$1.debug("Sending activity immediately without queue since immediate option is set.", {
3037
+ if (immediate) logger.debug("Sending activity immediately without queue since immediate option is set.", {
3077
3038
  activityId: activity.id.href,
3078
3039
  activity: jsonLd
3079
3040
  });
3080
- else logger$1.debug("Sending activity immediately without queue since queue is not set.", {
3041
+ else logger.debug("Sending activity immediately without queue since queue is not set.", {
3081
3042
  activityId: activity.id.href,
3082
3043
  activity: jsonLd
3083
3044
  });
@@ -3086,7 +3047,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3086
3047
  keys,
3087
3048
  activity: jsonLd,
3088
3049
  activityId: activity.id?.href,
3089
- activityType: (0, __fedify_vocab.getTypeId)(activity).href,
3050
+ activityType: (0, _fedify_vocab.getTypeId)(activity).href,
3090
3051
  inbox: new URL(inbox),
3091
3052
  sharedInbox: inboxes[inbox].sharedInbox,
3092
3053
  headers: collectionSync == null ? void 0 : new Headers({ "Collection-Synchronization": await buildCollectionSynchronizationHeader(collectionSync, inboxes[inbox].actorIds) }),
@@ -3096,7 +3057,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3096
3057
  await Promise.all(promises);
3097
3058
  return;
3098
3059
  }
3099
- logger$1.debug("Enqueuing activity {activityId} to send later.", {
3060
+ logger.debug("Enqueuing activity {activityId} to send later.", {
3100
3061
  activityId: activity.id.href,
3101
3062
  activity: jsonLd
3102
3063
  });
@@ -3110,7 +3071,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3110
3071
  }
3111
3072
  if (!this.manuallyStartQueue) this._startQueueInternal(ctx.data);
3112
3073
  const carrier = {};
3113
- __opentelemetry_api.propagation.inject(__opentelemetry_api.context.active(), carrier);
3074
+ _opentelemetry_api.propagation.inject(_opentelemetry_api.context.active(), carrier);
3114
3075
  const messages = [];
3115
3076
  for (const inbox in inboxes) {
3116
3077
  const inboxOrigin = new URL(inbox).origin;
@@ -3122,7 +3083,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3122
3083
  keys: keyJwkPairs,
3123
3084
  activity: jsonLd,
3124
3085
  activityId: activity.id?.href,
3125
- activityType: (0, __fedify_vocab.getTypeId)(activity).href,
3086
+ activityType: (0, _fedify_vocab.getTypeId)(activity).href,
3126
3087
  inbox,
3127
3088
  sharedInbox: inboxes[inbox].sharedInbox,
3128
3089
  actorIds: [...inboxes[inbox].actorIds],
@@ -3140,10 +3101,9 @@ var FederationImpl = class extends FederationBuilderImpl {
3140
3101
  const { outboxQueue } = this;
3141
3102
  if (outboxQueue.enqueueMany == null) {
3142
3103
  const promises = messages.map((m) => outboxQueue.enqueue(m.message, { orderingKey: m.orderingKey }));
3143
- const results = await Promise.allSettled(promises);
3144
- const errors = results.filter((r) => r.status === "rejected").map((r) => r.reason);
3104
+ const errors = (await Promise.allSettled(promises)).filter((r) => r.status === "rejected").map((r) => r.reason);
3145
3105
  if (errors.length > 0) {
3146
- logger$1.error("Failed to enqueue activity {activityId} to send later: {errors}", {
3106
+ logger.error("Failed to enqueue activity {activityId} to send later: {errors}", {
3147
3107
  activityId: activity.id.href,
3148
3108
  errors
3149
3109
  });
@@ -3152,10 +3112,9 @@ var FederationImpl = class extends FederationBuilderImpl {
3152
3112
  }
3153
3113
  } else if (orderingKey != null) {
3154
3114
  const promises = messages.map((m) => outboxQueue.enqueue(m.message, { orderingKey: m.orderingKey }));
3155
- const results = await Promise.allSettled(promises);
3156
- const errors = results.filter((r) => r.status === "rejected").map((r) => r.reason);
3115
+ const errors = (await Promise.allSettled(promises)).filter((r) => r.status === "rejected").map((r) => r.reason);
3157
3116
  if (errors.length > 0) {
3158
- logger$1.error("Failed to enqueue activity {activityId} to send later: {errors}", {
3117
+ logger.error("Failed to enqueue activity {activityId} to send later: {errors}", {
3159
3118
  activityId: activity.id.href,
3160
3119
  errors
3161
3120
  });
@@ -3165,7 +3124,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3165
3124
  } else try {
3166
3125
  await outboxQueue.enqueueMany(messages.map((m) => m.message));
3167
3126
  } catch (error) {
3168
- logger$1.error("Failed to enqueue activity {activityId} to send later: {error}", {
3127
+ logger.error("Failed to enqueue activity {activityId} to send later: {error}", {
3169
3128
  activityId: activity.id.href,
3170
3129
  error
3171
3130
  });
@@ -3173,27 +3132,26 @@ var FederationImpl = class extends FederationBuilderImpl {
3173
3132
  }
3174
3133
  }
3175
3134
  fetch(request, options) {
3176
- const requestId = getRequestId(request);
3177
- return (0, __logtape_logtape.withContext)({ requestId }, async () => {
3135
+ return (0, _logtape_logtape.withContext)({ requestId: getRequestId(request) }, async () => {
3178
3136
  const tracer = this._getTracer();
3179
3137
  return await tracer.startActiveSpan(request.method, {
3180
- kind: __opentelemetry_api.SpanKind.SERVER,
3138
+ kind: _opentelemetry_api.SpanKind.SERVER,
3181
3139
  attributes: {
3182
- [__opentelemetry_semantic_conventions.ATTR_HTTP_REQUEST_METHOD]: request.method,
3183
- [__opentelemetry_semantic_conventions.ATTR_URL_FULL]: request.url
3140
+ [_opentelemetry_semantic_conventions.ATTR_HTTP_REQUEST_METHOD]: request.method,
3141
+ [_opentelemetry_semantic_conventions.ATTR_URL_FULL]: request.url
3184
3142
  }
3185
3143
  }, async (span) => {
3186
3144
  const spanCtx = span.spanContext();
3187
- return await (0, __logtape_logtape.withContext)({
3145
+ return await (0, _logtape_logtape.withContext)({
3188
3146
  traceId: spanCtx.traceId,
3189
3147
  spanId: spanCtx.spanId
3190
3148
  }, async () => {
3191
- const logger$1 = (0, __logtape_logtape.getLogger)([
3149
+ const logger = (0, _logtape_logtape.getLogger)([
3192
3150
  "fedify",
3193
3151
  "federation",
3194
3152
  "http"
3195
3153
  ]);
3196
- if (span.isRecording()) for (const [k, v] of request.headers) span.setAttribute((0, __opentelemetry_semantic_conventions.ATTR_HTTP_REQUEST_HEADER)(k), [v]);
3154
+ if (span.isRecording()) for (const [k, v] of request.headers) span.setAttribute((0, _opentelemetry_semantic_conventions.ATTR_HTTP_REQUEST_HEADER)(k), [v]);
3197
3155
  let response;
3198
3156
  try {
3199
3157
  response = await this.#fetch(request, {
@@ -3204,11 +3162,11 @@ var FederationImpl = class extends FederationBuilderImpl {
3204
3162
  if (acceptsJsonLd(request)) response.headers.set("Vary", "Accept");
3205
3163
  } catch (error) {
3206
3164
  span.setStatus({
3207
- code: __opentelemetry_api.SpanStatusCode.ERROR,
3165
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
3208
3166
  message: `${error}`
3209
3167
  });
3210
3168
  span.end();
3211
- logger$1.error("An error occurred while serving request {method} {url}: {error}", {
3169
+ logger.error("An error occurred while serving request {method} {url}: {error}", {
3212
3170
  method: request.method,
3213
3171
  url: request.url,
3214
3172
  error
@@ -3216,10 +3174,10 @@ var FederationImpl = class extends FederationBuilderImpl {
3216
3174
  throw error;
3217
3175
  }
3218
3176
  if (span.isRecording()) {
3219
- span.setAttribute(__opentelemetry_semantic_conventions.ATTR_HTTP_RESPONSE_STATUS_CODE, response.status);
3220
- for (const [k, v] of response.headers) span.setAttribute((0, __opentelemetry_semantic_conventions.ATTR_HTTP_RESPONSE_HEADER)(k), [v]);
3177
+ span.setAttribute(_opentelemetry_semantic_conventions.ATTR_HTTP_RESPONSE_STATUS_CODE, response.status);
3178
+ for (const [k, v] of response.headers) span.setAttribute((0, _opentelemetry_semantic_conventions.ATTR_HTTP_RESPONSE_HEADER)(k), [v]);
3221
3179
  span.setStatus({
3222
- code: response.status >= 500 ? __opentelemetry_api.SpanStatusCode.ERROR : __opentelemetry_api.SpanStatusCode.UNSET,
3180
+ code: response.status >= 500 ? _opentelemetry_api.SpanStatusCode.ERROR : _opentelemetry_api.SpanStatusCode.UNSET,
3223
3181
  message: response.statusText
3224
3182
  });
3225
3183
  }
@@ -3232,9 +3190,9 @@ var FederationImpl = class extends FederationBuilderImpl {
3232
3190
  url: request.url,
3233
3191
  status: response.status
3234
3192
  };
3235
- if (response.status >= 500) logger$1.error(logTpl, values);
3236
- else if (response.status >= 400) logger$1.warn(logTpl, values);
3237
- else logger$1.info(logTpl, values);
3193
+ if (response.status >= 500) logger.error(logTpl, values);
3194
+ else if (response.status >= 400) logger.warn(logTpl, values);
3195
+ else logger.info(logTpl, values);
3238
3196
  return response;
3239
3197
  });
3240
3198
  });
@@ -3248,11 +3206,11 @@ var FederationImpl = class extends FederationBuilderImpl {
3248
3206
  const route = this.router.route(url.pathname);
3249
3207
  if (route == null) return await onNotFound(request);
3250
3208
  span.updateName(`${request.method} ${route.template}`);
3251
- let context$2 = this.#createContext(request, contextData);
3209
+ let context = this.#createContext(request, contextData);
3252
3210
  const routeName = route.name.replace(/:.*$/, "");
3253
3211
  switch (routeName) {
3254
3212
  case "webfinger": return await handleWebFinger(request, {
3255
- context: context$2,
3213
+ context,
3256
3214
  host: this.origin?.handleHost,
3257
3215
  actorDispatcher: this.actorCallbacks?.dispatcher,
3258
3216
  actorHandleMapper: this.actorCallbacks?.handleMapper,
@@ -3261,19 +3219,19 @@ var FederationImpl = class extends FederationBuilderImpl {
3261
3219
  onNotFound,
3262
3220
  tracer
3263
3221
  });
3264
- case "nodeInfoJrd": return await handleNodeInfoJrd(request, context$2);
3222
+ case "nodeInfoJrd": return await handleNodeInfoJrd(request, context);
3265
3223
  case "nodeInfo": return await handleNodeInfo(request, {
3266
- context: context$2,
3224
+ context,
3267
3225
  nodeInfoDispatcher: this.nodeInfoDispatcher
3268
3226
  });
3269
3227
  }
3270
3228
  if (request.method !== "POST" && !acceptsJsonLd(request)) return await onNotAcceptable(request);
3271
3229
  switch (routeName) {
3272
3230
  case "actor":
3273
- context$2 = this.#createContext(request, contextData, { invokedFromActorDispatcher: { identifier: route.values.identifier } });
3231
+ context = this.#createContext(request, contextData, { invokedFromActorDispatcher: { identifier: route.values.identifier } });
3274
3232
  return await handleActor(request, {
3275
3233
  identifier: route.values.identifier,
3276
- context: context$2,
3234
+ context,
3277
3235
  actorDispatcher: this.actorCallbacks?.dispatcher,
3278
3236
  authorizePredicate: this.actorCallbacks?.authorizePredicate,
3279
3237
  onUnauthorized,
@@ -3283,13 +3241,13 @@ var FederationImpl = class extends FederationBuilderImpl {
3283
3241
  const typeId = route.name.replace(/^object:/, "");
3284
3242
  const callbacks = this.objectCallbacks[typeId];
3285
3243
  const cls = this.objectTypeIds[typeId];
3286
- context$2 = this.#createContext(request, contextData, { invokedFromObjectDispatcher: {
3244
+ context = this.#createContext(request, contextData, { invokedFromObjectDispatcher: {
3287
3245
  cls,
3288
3246
  values: route.values
3289
3247
  } });
3290
3248
  return await handleObject(request, {
3291
3249
  values: route.values,
3292
- context: context$2,
3250
+ context,
3293
3251
  objectDispatcher: callbacks?.dispatcher,
3294
3252
  authorizePredicate: callbacks?.authorizePredicate,
3295
3253
  onUnauthorized,
@@ -3299,8 +3257,8 @@ var FederationImpl = class extends FederationBuilderImpl {
3299
3257
  case "outbox": return await handleCollection(request, {
3300
3258
  name: "outbox",
3301
3259
  identifier: route.values.identifier,
3302
- uriGetter: context$2.getOutboxUri.bind(context$2),
3303
- context: context$2,
3260
+ uriGetter: context.getOutboxUri.bind(context),
3261
+ context,
3304
3262
  collectionCallbacks: this.outboxCallbacks,
3305
3263
  tracerProvider: this.tracerProvider,
3306
3264
  onUnauthorized,
@@ -3310,24 +3268,24 @@ var FederationImpl = class extends FederationBuilderImpl {
3310
3268
  if (request.method !== "POST") return await handleCollection(request, {
3311
3269
  name: "inbox",
3312
3270
  identifier: route.values.identifier,
3313
- uriGetter: context$2.getInboxUri.bind(context$2),
3314
- context: context$2,
3271
+ uriGetter: context.getInboxUri.bind(context),
3272
+ context,
3315
3273
  collectionCallbacks: this.inboxCallbacks,
3316
3274
  tracerProvider: this.tracerProvider,
3317
3275
  onUnauthorized,
3318
3276
  onNotFound
3319
3277
  });
3320
- context$2 = this.#createContext(request, contextData, { documentLoader: await context$2.getDocumentLoader({ identifier: route.values.identifier }) });
3278
+ context = this.#createContext(request, contextData, { documentLoader: await context.getDocumentLoader({ identifier: route.values.identifier }) });
3321
3279
  case "sharedInbox":
3322
3280
  if (routeName !== "inbox" && this.sharedInboxKeyDispatcher != null) {
3323
- const identity = await this.sharedInboxKeyDispatcher(context$2);
3324
- if (identity != null) context$2 = this.#createContext(request, contextData, { documentLoader: "identifier" in identity || "username" in identity ? await context$2.getDocumentLoader(identity) : context$2.getDocumentLoader(identity) });
3281
+ const identity = await this.sharedInboxKeyDispatcher(context);
3282
+ if (identity != null) context = this.#createContext(request, contextData, { documentLoader: "identifier" in identity || "username" in identity ? await context.getDocumentLoader(identity) : context.getDocumentLoader(identity) });
3325
3283
  }
3326
3284
  if (!this.manuallyStartQueue) this._startQueueInternal(contextData);
3327
3285
  return await handleInbox(request, {
3328
3286
  recipient: route.values.identifier ?? null,
3329
- context: context$2,
3330
- inboxContextFactory: context$2.toInboxContext.bind(context$2),
3287
+ context,
3288
+ inboxContextFactory: context.toInboxContext.bind(context),
3331
3289
  kv: this.kv,
3332
3290
  kvPrefixes: this.kvPrefixes,
3333
3291
  queue: this.inboxQueue,
@@ -3345,8 +3303,8 @@ var FederationImpl = class extends FederationBuilderImpl {
3345
3303
  case "following": return await handleCollection(request, {
3346
3304
  name: "following",
3347
3305
  identifier: route.values.identifier,
3348
- uriGetter: context$2.getFollowingUri.bind(context$2),
3349
- context: context$2,
3306
+ uriGetter: context.getFollowingUri.bind(context),
3307
+ context,
3350
3308
  collectionCallbacks: this.followingCallbacks,
3351
3309
  tracerProvider: this.tracerProvider,
3352
3310
  onUnauthorized,
@@ -3362,14 +3320,14 @@ var FederationImpl = class extends FederationBuilderImpl {
3362
3320
  return await handleCollection(request, {
3363
3321
  name: "followers",
3364
3322
  identifier: route.values.identifier,
3365
- uriGetter: baseUrl == null ? context$2.getFollowersUri.bind(context$2) : (identifier) => {
3366
- const uri = context$2.getFollowersUri(identifier);
3323
+ uriGetter: baseUrl == null ? context.getFollowersUri.bind(context) : (identifier) => {
3324
+ const uri = context.getFollowersUri(identifier);
3367
3325
  uri.searchParams.set("base-url", baseUrl);
3368
3326
  return uri;
3369
3327
  },
3370
- context: context$2,
3328
+ context,
3371
3329
  filter: baseUrl != null ? new URL(baseUrl) : void 0,
3372
- filterPredicate: baseUrl != null ? (i) => (i instanceof URL ? i.href : i.id?.href ?? "").startsWith(baseUrl) : void 0,
3330
+ filterPredicate: baseUrl != null ? ((i) => (i instanceof URL ? i.href : i.id?.href ?? "").startsWith(baseUrl)) : void 0,
3373
3331
  collectionCallbacks: this.followersCallbacks,
3374
3332
  tracerProvider: this.tracerProvider,
3375
3333
  onUnauthorized,
@@ -3379,8 +3337,8 @@ var FederationImpl = class extends FederationBuilderImpl {
3379
3337
  case "liked": return await handleCollection(request, {
3380
3338
  name: "liked",
3381
3339
  identifier: route.values.identifier,
3382
- uriGetter: context$2.getLikedUri.bind(context$2),
3383
- context: context$2,
3340
+ uriGetter: context.getLikedUri.bind(context),
3341
+ context,
3384
3342
  collectionCallbacks: this.likedCallbacks,
3385
3343
  tracerProvider: this.tracerProvider,
3386
3344
  onUnauthorized,
@@ -3389,8 +3347,8 @@ var FederationImpl = class extends FederationBuilderImpl {
3389
3347
  case "featured": return await handleCollection(request, {
3390
3348
  name: "featured",
3391
3349
  identifier: route.values.identifier,
3392
- uriGetter: context$2.getFeaturedUri.bind(context$2),
3393
- context: context$2,
3350
+ uriGetter: context.getFeaturedUri.bind(context),
3351
+ context,
3394
3352
  collectionCallbacks: this.featuredCallbacks,
3395
3353
  tracerProvider: this.tracerProvider,
3396
3354
  onUnauthorized,
@@ -3399,8 +3357,8 @@ var FederationImpl = class extends FederationBuilderImpl {
3399
3357
  case "featuredTags": return await handleCollection(request, {
3400
3358
  name: "featured tags",
3401
3359
  identifier: route.values.identifier,
3402
- uriGetter: context$2.getFeaturedTagsUri.bind(context$2),
3403
- context: context$2,
3360
+ uriGetter: context.getFeaturedTagsUri.bind(context),
3361
+ context,
3404
3362
  collectionCallbacks: this.featuredTagsCallbacks,
3405
3363
  tracerProvider: this.tracerProvider,
3406
3364
  onUnauthorized,
@@ -3411,7 +3369,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3411
3369
  const callbacks = this.collectionCallbacks[name];
3412
3370
  return await handleCustomCollection(request, {
3413
3371
  name,
3414
- context: context$2,
3372
+ context,
3415
3373
  values: route.values,
3416
3374
  collectionCallbacks: callbacks,
3417
3375
  tracerProvider: this.tracerProvider,
@@ -3424,7 +3382,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3424
3382
  const callbacks = this.collectionCallbacks[name];
3425
3383
  return await handleOrderedCollection(request, {
3426
3384
  name,
3427
- context: context$2,
3385
+ context,
3428
3386
  values: route.values,
3429
3387
  collectionCallbacks: callbacks,
3430
3388
  tracerProvider: this.tracerProvider,
@@ -3515,9 +3473,9 @@ var ContextImpl = class ContextImpl {
3515
3473
  }
3516
3474
  getInboxUri(identifier) {
3517
3475
  if (identifier == null) {
3518
- const path$1 = this.federation.router.build("sharedInbox", {});
3519
- if (path$1 == null) throw new RouterError("No shared inbox path registered.");
3520
- return new URL(path$1, this.canonicalOrigin);
3476
+ const path = this.federation.router.build("sharedInbox", {});
3477
+ if (path == null) throw new RouterError("No shared inbox path registered.");
3478
+ return new URL(path, this.canonicalOrigin);
3521
3479
  }
3522
3480
  const path = this.federation.router.build("inbox", { identifier });
3523
3481
  if (path == null) throw new RouterError("No inbox path registered.");
@@ -3603,8 +3561,7 @@ var ContextImpl = class ContextImpl {
3603
3561
  type: "featuredTags",
3604
3562
  identifier
3605
3563
  };
3606
- const collectionTypes = ["collection", "orderedCollection"];
3607
- const collectionRegex = /* @__PURE__ */ new RegExp(`^(${collectionTypes.join("|")}):(.*)$`);
3564
+ const collectionRegex = new RegExp(`^(${["collection", "orderedCollection"].join("|")}):(.*)$`);
3608
3565
  const match = route.name.match(collectionRegex);
3609
3566
  if (match !== null) {
3610
3567
  const [, type, name] = match;
@@ -3620,12 +3577,12 @@ var ContextImpl = class ContextImpl {
3620
3577
  return null;
3621
3578
  }
3622
3579
  async getActorKeyPairs(identifier) {
3623
- const logger$1 = (0, __logtape_logtape.getLogger)([
3580
+ const logger = (0, _logtape_logtape.getLogger)([
3624
3581
  "fedify",
3625
3582
  "federation",
3626
3583
  "actor"
3627
3584
  ]);
3628
- if (this.invokedFromActorKeyPairsDispatcher != null) logger$1.warn("Context.getActorKeyPairs({getActorKeyPairsIdentifier}) method is invoked from the actor key pairs dispatcher ({actorKeyPairsDispatcherIdentifier}); this may cause an infinite loop.", {
3585
+ if (this.invokedFromActorKeyPairsDispatcher != null) logger.warn("Context.getActorKeyPairs({getActorKeyPairsIdentifier}) method is invoked from the actor key pairs dispatcher ({actorKeyPairsDispatcherIdentifier}); this may cause an infinite loop.", {
3629
3586
  getActorKeyPairsIdentifier: identifier,
3630
3587
  actorKeyPairsDispatcherIdentifier: this.invokedFromActorKeyPairsDispatcher.identifier
3631
3588
  });
@@ -3633,7 +3590,7 @@ var ContextImpl = class ContextImpl {
3633
3590
  try {
3634
3591
  keyPairs = await this.getKeyPairsFromIdentifier(identifier);
3635
3592
  } catch (_) {
3636
- logger$1.warn("No actor key pairs dispatcher registered.");
3593
+ logger.warn("No actor key pairs dispatcher registered.");
3637
3594
  return [];
3638
3595
  }
3639
3596
  const owner = this.getActorUri(identifier);
@@ -3641,12 +3598,12 @@ var ContextImpl = class ContextImpl {
3641
3598
  for (const keyPair of keyPairs) {
3642
3599
  const newPair = {
3643
3600
  ...keyPair,
3644
- cryptographicKey: new __fedify_vocab.CryptographicKey({
3601
+ cryptographicKey: new _fedify_vocab.CryptographicKey({
3645
3602
  id: keyPair.keyId,
3646
3603
  owner,
3647
3604
  publicKey: keyPair.publicKey
3648
3605
  }),
3649
- multikey: new __fedify_vocab.Multikey({
3606
+ multikey: new _fedify_vocab.Multikey({
3650
3607
  id: keyPair.keyId,
3651
3608
  controller: owner,
3652
3609
  publicKey: keyPair.publicKey
@@ -3657,7 +3614,7 @@ var ContextImpl = class ContextImpl {
3657
3614
  return result;
3658
3615
  }
3659
3616
  async getKeyPairsFromIdentifier(identifier) {
3660
- const logger$1 = (0, __logtape_logtape.getLogger)([
3617
+ const logger = (0, _logtape_logtape.getLogger)([
3661
3618
  "fedify",
3662
3619
  "federation",
3663
3620
  "actor"
@@ -3668,7 +3625,7 @@ var ContextImpl = class ContextImpl {
3668
3625
  actorUri = this.getActorUri(identifier);
3669
3626
  } catch (error) {
3670
3627
  if (error instanceof RouterError) {
3671
- logger$1.warn(error.message);
3628
+ logger.warn(error.message);
3672
3629
  return [];
3673
3630
  }
3674
3631
  throw error;
@@ -3677,7 +3634,7 @@ var ContextImpl = class ContextImpl {
3677
3634
  ...this,
3678
3635
  invokedFromActorKeyPairsDispatcher: { identifier }
3679
3636
  }), identifier);
3680
- if (keyPairs.length < 1) logger$1.warn("No key pairs found for actor {identifier}.", { identifier });
3637
+ if (keyPairs.length < 1) logger.warn("No key pairs found for actor {identifier}.", { identifier });
3681
3638
  let i = 0;
3682
3639
  const result = [];
3683
3640
  for (const keyPair of keyPairs) {
@@ -3695,7 +3652,7 @@ var ContextImpl = class ContextImpl {
3695
3652
  const { privateKey } = keyPair;
3696
3653
  if (privateKey.algorithm.name === "RSASSA-PKCS1-v1_5" && privateKey.algorithm.hash.name === "SHA-256") return keyPair;
3697
3654
  }
3698
- (0, __logtape_logtape.getLogger)([
3655
+ (0, _logtape_logtape.getLogger)([
3699
3656
  "fedify",
3700
3657
  "federation",
3701
3658
  "actor"
@@ -3716,14 +3673,13 @@ var ContextImpl = class ContextImpl {
3716
3673
  } else identifierPromise = Promise.resolve(identity.identifier);
3717
3674
  return identifierPromise.then((identifier) => {
3718
3675
  if (identifier == null) return this.documentLoader;
3719
- const keyPair = this.getRsaKeyPairFromIdentifier(identifier);
3720
- return keyPair.then((pair) => pair == null ? this.documentLoader : this.federation.authenticatedDocumentLoaderFactory(pair));
3676
+ return this.getRsaKeyPairFromIdentifier(identifier).then((pair) => pair == null ? this.documentLoader : this.federation.authenticatedDocumentLoaderFactory(pair));
3721
3677
  });
3722
3678
  }
3723
3679
  return this.federation.authenticatedDocumentLoaderFactory(identity);
3724
3680
  }
3725
3681
  lookupObject(identifier, options = {}) {
3726
- return (0, __fedify_vocab.lookupObject)(identifier, {
3682
+ return (0, _fedify_vocab.lookupObject)(identifier, {
3727
3683
  ...options,
3728
3684
  documentLoader: options.documentLoader ?? this.documentLoader,
3729
3685
  contextLoader: options.contextLoader ?? this.contextLoader,
@@ -3733,7 +3689,7 @@ var ContextImpl = class ContextImpl {
3733
3689
  });
3734
3690
  }
3735
3691
  traverseCollection(collection, options = {}) {
3736
- return (0, __fedify_vocab.traverseCollection)(collection, {
3692
+ return (0, _fedify_vocab.traverseCollection)(collection, {
3737
3693
  ...options,
3738
3694
  documentLoader: options.documentLoader ?? this.documentLoader,
3739
3695
  contextLoader: options.contextLoader ?? this.contextLoader
@@ -3751,7 +3707,7 @@ var ContextImpl = class ContextImpl {
3751
3707
  });
3752
3708
  }
3753
3709
  lookupWebFinger(resource, options = {}) {
3754
- return (0, __fedify_webfinger.lookupWebFinger)(resource, {
3710
+ return (0, _fedify_webfinger.lookupWebFinger)(resource, {
3755
3711
  ...options,
3756
3712
  userAgent: options.userAgent ?? this.federation.userAgent,
3757
3713
  tracerProvider: options.tracerProvider ?? this.tracerProvider,
@@ -3759,11 +3715,10 @@ var ContextImpl = class ContextImpl {
3759
3715
  });
3760
3716
  }
3761
3717
  sendActivity(sender, recipients, activity, options = {}) {
3762
- const tracer = this.tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
3763
- return tracer.startActiveSpan(this.federation.outboxQueue == null || options.immediate ? "activitypub.outbox" : "activitypub.fanout", {
3764
- kind: this.federation.outboxQueue == null || options.immediate ? __opentelemetry_api.SpanKind.CLIENT : __opentelemetry_api.SpanKind.PRODUCER,
3718
+ return this.tracerProvider.getTracer(require_http.name, require_http.version).startActiveSpan(this.federation.outboxQueue == null || options.immediate ? "activitypub.outbox" : "activitypub.fanout", {
3719
+ kind: this.federation.outboxQueue == null || options.immediate ? _opentelemetry_api.SpanKind.CLIENT : _opentelemetry_api.SpanKind.PRODUCER,
3765
3720
  attributes: {
3766
- "activitypub.activity.type": (0, __fedify_vocab.getTypeId)(activity).href,
3721
+ "activitypub.activity.type": (0, _fedify_vocab.getTypeId)(activity).href,
3767
3722
  "activitypub.activity.to": activity.toIds.map((to) => to.href),
3768
3723
  "activitypub.activity.cc": activity.toIds.map((cc) => cc.href),
3769
3724
  "activitypub.activity.bto": activity.btoIds.map((bto) => bto.href),
@@ -3775,7 +3730,7 @@ var ContextImpl = class ContextImpl {
3775
3730
  await this.sendActivityInternal(sender, recipients, activity, options, span);
3776
3731
  } catch (e) {
3777
3732
  span.setStatus({
3778
- code: __opentelemetry_api.SpanStatusCode.ERROR,
3733
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
3779
3734
  message: String(e)
3780
3735
  });
3781
3736
  throw e;
@@ -3785,7 +3740,7 @@ var ContextImpl = class ContextImpl {
3785
3740
  });
3786
3741
  }
3787
3742
  async sendActivityInternal(sender, recipients, activity, options, span) {
3788
- const logger$1 = (0, __logtape_logtape.getLogger)([
3743
+ const logger = (0, _logtape_logtape.getLogger)([
3789
3744
  "fedify",
3790
3745
  "federation",
3791
3746
  "outbox"
@@ -3835,7 +3790,7 @@ var ContextImpl = class ContextImpl {
3835
3790
  for (const activityTransformer of this.federation.activityTransformers) activity = activityTransformer(activity, this);
3836
3791
  span?.setAttribute("activitypub.activity.id", activity?.id?.href ?? "");
3837
3792
  if (activity.actorId == null) {
3838
- logger$1.error("Activity {activityId} to send does not have an actor.", {
3793
+ logger.error("Activity {activityId} to send does not have an actor.", {
3839
3794
  activity,
3840
3795
  activityId: activity?.id?.href
3841
3796
  });
@@ -3846,7 +3801,7 @@ var ContextImpl = class ContextImpl {
3846
3801
  preferSharedInbox: options.preferSharedInbox,
3847
3802
  excludeBaseUris: options.excludeBaseUris
3848
3803
  });
3849
- logger$1.debug("Sending activity {activityId} to inboxes:\n{inboxes}", {
3804
+ logger.debug("Sending activity {activityId} to inboxes:\n{inboxes}", {
3850
3805
  inboxes: globalThis.Object.keys(inboxes),
3851
3806
  activityId: activity.id?.href,
3852
3807
  activity
@@ -3860,7 +3815,7 @@ var ContextImpl = class ContextImpl {
3860
3815
  privateKey: await require_http.exportJwk(privateKey)
3861
3816
  })));
3862
3817
  const carrier = {};
3863
- __opentelemetry_api.propagation.inject(__opentelemetry_api.context.active(), carrier);
3818
+ _opentelemetry_api.propagation.inject(_opentelemetry_api.context.active(), carrier);
3864
3819
  const message = {
3865
3820
  type: "fanout",
3866
3821
  id: crypto.randomUUID(),
@@ -3875,7 +3830,7 @@ var ContextImpl = class ContextImpl {
3875
3830
  contextLoader: this.contextLoader
3876
3831
  }),
3877
3832
  activityId: activity.id?.href,
3878
- activityType: (0, __fedify_vocab.getTypeId)(activity).href,
3833
+ activityType: (0, _fedify_vocab.getTypeId)(activity).href,
3879
3834
  collectionSync: opts.collectionSync,
3880
3835
  orderingKey: options.orderingKey,
3881
3836
  traceContext: carrier
@@ -3892,24 +3847,22 @@ var ContextImpl = class ContextImpl {
3892
3847
  }
3893
3848
  if (this.federation.followersCallbacks.firstCursor == null) throw new Error("No first cursor dispatcher registered for followers collection.");
3894
3849
  let cursor = await this.federation.followersCallbacks.firstCursor(this, identifier);
3895
- if (cursor != null) (0, __logtape_logtape.getLogger)([
3850
+ if (cursor != null) (0, _logtape_logtape.getLogger)([
3896
3851
  "fedify",
3897
3852
  "federation",
3898
3853
  "outbox"
3899
3854
  ]).warn("Since the followers collection dispatcher returned null for no cursor (i.e., one-shot dispatcher), the pagination is used to fetch \"followers\". However, it is recommended to implement the one-shot dispatcher for better performance.", { identifier });
3900
3855
  while (cursor != null) {
3901
- const result$1 = await this.federation.followersCallbacks.dispatcher(this, identifier, cursor);
3902
- if (result$1 == null) break;
3903
- for (const recipient of result$1.items) yield recipient;
3904
- cursor = result$1.nextCursor ?? null;
3856
+ const result = await this.federation.followersCallbacks.dispatcher(this, identifier, cursor);
3857
+ if (result == null) break;
3858
+ for (const recipient of result.items) yield recipient;
3859
+ cursor = result.nextCursor ?? null;
3905
3860
  }
3906
3861
  }
3907
3862
  routeActivity(recipient, activity, options = {}) {
3908
- const tracerProvider = this.tracerProvider ?? this.tracerProvider;
3909
- const tracer = tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
3910
- return tracer.startActiveSpan("activitypub.inbox", {
3911
- kind: this.federation.inboxQueue == null || options.immediate ? __opentelemetry_api.SpanKind.INTERNAL : __opentelemetry_api.SpanKind.PRODUCER,
3912
- attributes: { "activitypub.activity.type": (0, __fedify_vocab.getTypeId)(activity).href }
3863
+ return (this.tracerProvider ?? this.tracerProvider).getTracer(require_http.name, require_http.version).startActiveSpan("activitypub.inbox", {
3864
+ kind: this.federation.inboxQueue == null || options.immediate ? _opentelemetry_api.SpanKind.INTERNAL : _opentelemetry_api.SpanKind.PRODUCER,
3865
+ attributes: { "activitypub.activity.type": (0, _fedify_vocab.getTypeId)(activity).href }
3913
3866
  }, async (span) => {
3914
3867
  if (activity.id != null) span.setAttribute("activitypub.activity.id", activity.id.href);
3915
3868
  if (activity.toIds.length > 0) span.setAttribute("activitypub.activity.to", activity.toIds.map((to) => to.href));
@@ -3921,11 +3874,11 @@ var ContextImpl = class ContextImpl {
3921
3874
  if (ok) {
3922
3875
  span.setAttribute("activitypub.shared_inbox", recipient == null);
3923
3876
  if (recipient != null) span.setAttribute("fedify.inbox.recipient", recipient);
3924
- } else span.setStatus({ code: __opentelemetry_api.SpanStatusCode.ERROR });
3877
+ } else span.setStatus({ code: _opentelemetry_api.SpanStatusCode.ERROR });
3925
3878
  return ok;
3926
3879
  } catch (e) {
3927
3880
  span.setStatus({
3928
- code: __opentelemetry_api.SpanStatusCode.ERROR,
3881
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
3929
3882
  message: String(e)
3930
3883
  });
3931
3884
  throw e;
@@ -3935,7 +3888,7 @@ var ContextImpl = class ContextImpl {
3935
3888
  });
3936
3889
  }
3937
3890
  async routeActivityInternal(recipient, activity, options = {}, span) {
3938
- const logger$1 = (0, __logtape_logtape.getLogger)([
3891
+ const logger = (0, _logtape_logtape.getLogger)([
3939
3892
  "fedify",
3940
3893
  "federation",
3941
3894
  "inbox"
@@ -3943,19 +3896,18 @@ var ContextImpl = class ContextImpl {
3943
3896
  const contextLoader = options.contextLoader ?? this.contextLoader;
3944
3897
  const json = await activity.toJsonLd({ contextLoader });
3945
3898
  const keyCache = new KvKeyCache(this.federation.kv, this.federation.kvPrefixes.publicKey, this);
3946
- const verified = await require_proof.verifyObject(__fedify_vocab.Activity, json, {
3899
+ if (await require_proof.verifyObject(_fedify_vocab.Activity, json, {
3947
3900
  contextLoader,
3948
3901
  documentLoader: options.documentLoader ?? this.documentLoader,
3949
3902
  tracerProvider: options.tracerProvider ?? this.tracerProvider,
3950
3903
  keyCache
3951
- });
3952
- if (verified == null) {
3953
- logger$1.debug("Object Integrity Proofs are not verified.", {
3904
+ }) == null) {
3905
+ logger.debug("Object Integrity Proofs are not verified.", {
3954
3906
  recipient,
3955
3907
  activity: json
3956
3908
  });
3957
3909
  if (activity.id == null) {
3958
- logger$1.debug("Activity is missing an ID; unable to fetch.", {
3910
+ logger.debug("Activity is missing an ID; unable to fetch.", {
3959
3911
  recipient,
3960
3912
  activity: json
3961
3913
  });
@@ -3963,26 +3915,26 @@ var ContextImpl = class ContextImpl {
3963
3915
  }
3964
3916
  const fetched = await this.lookupObject(activity.id, options);
3965
3917
  if (fetched == null) {
3966
- logger$1.debug("Failed to fetch the remote activity object {activityId}.", {
3918
+ logger.debug("Failed to fetch the remote activity object {activityId}.", {
3967
3919
  recipient,
3968
3920
  activity: json,
3969
3921
  activityId: activity.id.href
3970
3922
  });
3971
3923
  return false;
3972
- } else if (!(fetched instanceof __fedify_vocab.Activity)) {
3973
- logger$1.debug("Fetched object is not an Activity.", {
3924
+ } else if (!(fetched instanceof _fedify_vocab.Activity)) {
3925
+ logger.debug("Fetched object is not an Activity.", {
3974
3926
  recipient,
3975
3927
  activity: await fetched.toJsonLd({ contextLoader })
3976
3928
  });
3977
3929
  return false;
3978
3930
  } else if (fetched.id?.href !== activity.id.href) {
3979
- logger$1.debug("Fetched activity object has a different ID; failed to verify.", {
3931
+ logger.debug("Fetched activity object has a different ID; failed to verify.", {
3980
3932
  recipient,
3981
3933
  activity: await fetched.toJsonLd({ contextLoader })
3982
3934
  });
3983
3935
  return false;
3984
3936
  } else if (fetched.actorIds.length < 1) {
3985
- logger$1.debug("Fetched activity object is missing an actor; unable to verify.", {
3937
+ logger.debug("Fetched activity object is missing an actor; unable to verify.", {
3986
3938
  recipient,
3987
3939
  activity: await fetched.toJsonLd({ contextLoader })
3988
3940
  });
@@ -3990,15 +3942,15 @@ var ContextImpl = class ContextImpl {
3990
3942
  }
3991
3943
  const activityId = fetched.id;
3992
3944
  if (!fetched.actorIds.every((actor) => actor.origin === activityId.origin)) {
3993
- logger$1.debug("Fetched activity object has actors from different origins; unable to verify.", {
3945
+ logger.debug("Fetched activity object has actors from different origins; unable to verify.", {
3994
3946
  recipient,
3995
3947
  activity: await fetched.toJsonLd({ contextLoader })
3996
3948
  });
3997
3949
  return false;
3998
3950
  }
3999
- logger$1.debug("Successfully fetched the remote activity object {activityId}; ignore the original activity and use the fetched one, which is trustworthy.");
3951
+ logger.debug("Successfully fetched the remote activity object {activityId}; ignore the original activity and use the fetched one, which is trustworthy.");
4000
3952
  activity = fetched;
4001
- } else logger$1.debug("Object Integrity Proofs are verified.", {
3953
+ } else logger.debug("Object Integrity Proofs are verified.", {
4002
3954
  recipient,
4003
3955
  activity: json
4004
3956
  });
@@ -4047,7 +3999,7 @@ var RequestContextImpl = class RequestContextImpl extends ContextImpl {
4047
3999
  }
4048
4000
  async getActor(identifier) {
4049
4001
  if (this.federation.actorCallbacks == null || this.federation.actorCallbacks.dispatcher == null) throw new Error("No actor dispatcher registered.");
4050
- if (this.#invokedFromActorDispatcher != null) (0, __logtape_logtape.getLogger)([
4002
+ if (this.#invokedFromActorDispatcher != null) (0, _logtape_logtape.getLogger)([
4051
4003
  "fedify",
4052
4004
  "federation",
4053
4005
  "actor"
@@ -4064,7 +4016,7 @@ var RequestContextImpl = class RequestContextImpl extends ContextImpl {
4064
4016
  const callbacks = this.federation.objectCallbacks[cls.typeId.href];
4065
4017
  if (callbacks == null) throw new Error("No object dispatcher registered.");
4066
4018
  for (const param of callbacks.parameters) if (!(param in values)) throw new TypeError(`Missing parameter: ${param}`);
4067
- if (this.#invokedFromObjectDispatcher != null) (0, __logtape_logtape.getLogger)(["fedify", "federation"]).warn("RequestContext.getObject({getObjectClass}, {getObjectValues}) is invoked from the object dispatcher ({actorDispatcherClass}, {actorDispatcherValues}); this may cause an infinite loop.", {
4019
+ if (this.#invokedFromObjectDispatcher != null) (0, _logtape_logtape.getLogger)(["fedify", "federation"]).warn("RequestContext.getObject({getObjectClass}, {getObjectValues}) is invoked from the object dispatcher ({actorDispatcherClass}, {actorDispatcherValues}); this may cause an infinite loop.", {
4068
4020
  getObjectClass: cls.name,
4069
4021
  getObjectValues: values,
4070
4022
  actorDispatcherClass: this.#invokedFromObjectDispatcher.cls.name,
@@ -4101,8 +4053,8 @@ var RequestContextImpl = class RequestContextImpl extends ContextImpl {
4101
4053
  tracerProvider: options.tracerProvider ?? this.tracerProvider
4102
4054
  });
4103
4055
  } catch (error) {
4104
- if (error instanceof __fedify_vocab_runtime.FetchError) {
4105
- (0, __logtape_logtape.getLogger)([
4056
+ if (error instanceof _fedify_vocab_runtime.FetchError) {
4057
+ (0, _logtape_logtape.getLogger)([
4106
4058
  "fedify",
4107
4059
  "federation",
4108
4060
  "actor"
@@ -4140,9 +4092,8 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
4140
4092
  });
4141
4093
  }
4142
4094
  forwardActivity(forwarder, recipients, options) {
4143
- const tracer = this.tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
4144
- return tracer.startActiveSpan("activitypub.outbox", {
4145
- kind: this.federation.outboxQueue == null || options?.immediate ? __opentelemetry_api.SpanKind.CLIENT : __opentelemetry_api.SpanKind.PRODUCER,
4095
+ return this.tracerProvider.getTracer(require_http.name, require_http.version).startActiveSpan("activitypub.outbox", {
4096
+ kind: this.federation.outboxQueue == null || options?.immediate ? _opentelemetry_api.SpanKind.CLIENT : _opentelemetry_api.SpanKind.PRODUCER,
4146
4097
  attributes: { "activitypub.activity.type": this.activityType }
4147
4098
  }, async (span) => {
4148
4099
  try {
@@ -4150,7 +4101,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
4150
4101
  await this.forwardActivityInternal(forwarder, recipients, options);
4151
4102
  } catch (e) {
4152
4103
  span.setStatus({
4153
- code: __opentelemetry_api.SpanStatusCode.ERROR,
4104
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
4154
4105
  message: String(e)
4155
4106
  });
4156
4107
  throw e;
@@ -4160,7 +4111,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
4160
4111
  });
4161
4112
  }
4162
4113
  async forwardActivityInternal(forwarder, recipients, options) {
4163
- const logger$1 = (0, __logtape_logtape.getLogger)([
4114
+ const logger = (0, _logtape_logtape.getLogger)([
4164
4115
  "fedify",
4165
4116
  "federation",
4166
4117
  "inbox"
@@ -4187,14 +4138,13 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
4187
4138
  if (!require_proof.hasSignature(this.activity)) {
4188
4139
  let hasProof;
4189
4140
  try {
4190
- const activity = await __fedify_vocab.Activity.fromJsonLd(this.activity, this);
4191
- hasProof = await activity.getProof() != null;
4141
+ hasProof = await (await _fedify_vocab.Activity.fromJsonLd(this.activity, this)).getProof() != null;
4192
4142
  } catch {
4193
4143
  hasProof = false;
4194
4144
  }
4195
4145
  if (!hasProof) {
4196
4146
  if (options?.skipIfUnsigned) return;
4197
- logger$1.warn("The received activity {activityId} is not signed; even if it is forwarded to other servers as is, it may not be accepted by them due to the lack of a signature/proof.");
4147
+ logger.warn("The received activity {activityId} is not signed; even if it is forwarded to other servers as is, it may not be accepted by them due to the lack of a signature/proof.");
4198
4148
  }
4199
4149
  }
4200
4150
  if (recipients === "followers") {
@@ -4208,14 +4158,14 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
4208
4158
  preferSharedInbox: options?.preferSharedInbox,
4209
4159
  excludeBaseUris: options?.excludeBaseUris
4210
4160
  });
4211
- logger$1.debug("Forwarding activity {activityId} to inboxes:\n{inboxes}", {
4161
+ logger.debug("Forwarding activity {activityId} to inboxes:\n{inboxes}", {
4212
4162
  inboxes: globalThis.Object.keys(inboxes),
4213
4163
  activityId: this.activityId,
4214
4164
  activity: this.activity
4215
4165
  });
4216
4166
  if (options?.immediate || this.federation.outboxQueue == null) {
4217
- if (options?.immediate) logger$1.debug("Forwarding activity immediately without queue since immediate option is set.");
4218
- else logger$1.debug("Forwarding activity immediately without queue since queue is not set.");
4167
+ if (options?.immediate) logger.debug("Forwarding activity immediately without queue since immediate option is set.");
4168
+ else logger.debug("Forwarding activity immediately without queue since queue is not set.");
4219
4169
  const promises = [];
4220
4170
  for (const inbox in inboxes) promises.push(sendActivity({
4221
4171
  keys,
@@ -4230,7 +4180,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
4230
4180
  await Promise.all(promises);
4231
4181
  return;
4232
4182
  }
4233
- logger$1.debug("Enqueuing activity {activityId} to forward later.", {
4183
+ logger.debug("Enqueuing activity {activityId} to forward later.", {
4234
4184
  activityId: this.activityId,
4235
4185
  activity: this.activity
4236
4186
  });
@@ -4243,7 +4193,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
4243
4193
  });
4244
4194
  }
4245
4195
  const carrier = {};
4246
- __opentelemetry_api.propagation.inject(__opentelemetry_api.context.active(), carrier);
4196
+ _opentelemetry_api.propagation.inject(_opentelemetry_api.context.active(), carrier);
4247
4197
  const orderingKey = options?.orderingKey;
4248
4198
  const messages = [];
4249
4199
  for (const inbox in inboxes) {
@@ -4272,10 +4222,9 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
4272
4222
  const { outboxQueue } = this.federation;
4273
4223
  if (outboxQueue.enqueueMany == null) {
4274
4224
  const promises = messages.map((m) => outboxQueue.enqueue(m.message, { orderingKey: m.orderingKey }));
4275
- const results = await Promise.allSettled(promises);
4276
- const errors = results.filter((r) => r.status === "rejected").map((r) => r.reason);
4225
+ const errors = (await Promise.allSettled(promises)).filter((r) => r.status === "rejected").map((r) => r.reason);
4277
4226
  if (errors.length > 0) {
4278
- logger$1.error("Failed to enqueue activity {activityId} to forward later:\n{errors}", {
4227
+ logger.error("Failed to enqueue activity {activityId} to forward later:\n{errors}", {
4279
4228
  activityId: this.activityId,
4280
4229
  errors
4281
4230
  });
@@ -4284,10 +4233,9 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
4284
4233
  }
4285
4234
  } else if (orderingKey != null) {
4286
4235
  const promises = messages.map((m) => outboxQueue.enqueue(m.message, { orderingKey: m.orderingKey }));
4287
- const results = await Promise.allSettled(promises);
4288
- const errors = results.filter((r) => r.status === "rejected").map((r) => r.reason);
4236
+ const errors = (await Promise.allSettled(promises)).filter((r) => r.status === "rejected").map((r) => r.reason);
4289
4237
  if (errors.length > 0) {
4290
- logger$1.error("Failed to enqueue activity {activityId} to forward later:\n{errors}", {
4238
+ logger.error("Failed to enqueue activity {activityId} to forward later:\n{errors}", {
4291
4239
  activityId: this.activityId,
4292
4240
  errors
4293
4241
  });
@@ -4297,7 +4245,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
4297
4245
  } else try {
4298
4246
  await outboxQueue.enqueueMany(messages.map((m) => m.message));
4299
4247
  } catch (error) {
4300
- logger$1.error("Failed to enqueue activity {activityId} to forward later:\n{error}", {
4248
+ logger.error("Failed to enqueue activity {activityId} to forward later:\n{error}", {
4301
4249
  activityId: this.activityId,
4302
4250
  error
4303
4251
  });
@@ -4352,99 +4300,96 @@ function unauthorized(_request) {
4352
4300
  function getRequestId(request) {
4353
4301
  const traceId = request.headers.get("X-Request-Id") || request.headers.get("X-Correlation-Id") || request.headers.get("Traceparent")?.split("-")[1];
4354
4302
  if (traceId != null) return traceId;
4355
- const timestamp = Date.now().toString(36);
4356
- const random = Math.random().toString(36).slice(2, 8);
4357
- return `req_${timestamp}${random}`;
4303
+ return `req_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
4358
4304
  }
4359
-
4360
4305
  //#endregion
4361
- Object.defineProperty(exports, 'ContextImpl', {
4362
- enumerable: true,
4363
- get: function () {
4364
- return ContextImpl;
4365
- }
4306
+ Object.defineProperty(exports, "ContextImpl", {
4307
+ enumerable: true,
4308
+ get: function() {
4309
+ return ContextImpl;
4310
+ }
4366
4311
  });
4367
- Object.defineProperty(exports, 'FederationImpl', {
4368
- enumerable: true,
4369
- get: function () {
4370
- return FederationImpl;
4371
- }
4312
+ Object.defineProperty(exports, "FederationImpl", {
4313
+ enumerable: true,
4314
+ get: function() {
4315
+ return FederationImpl;
4316
+ }
4317
+ });
4318
+ Object.defineProperty(exports, "InboxContextImpl", {
4319
+ enumerable: true,
4320
+ get: function() {
4321
+ return InboxContextImpl;
4322
+ }
4372
4323
  });
4373
- Object.defineProperty(exports, 'InboxContextImpl', {
4374
- enumerable: true,
4375
- get: function () {
4376
- return InboxContextImpl;
4377
- }
4324
+ Object.defineProperty(exports, "KvSpecDeterminer", {
4325
+ enumerable: true,
4326
+ get: function() {
4327
+ return KvSpecDeterminer;
4328
+ }
4378
4329
  });
4379
- Object.defineProperty(exports, 'KvSpecDeterminer', {
4380
- enumerable: true,
4381
- get: function () {
4382
- return KvSpecDeterminer;
4383
- }
4330
+ Object.defineProperty(exports, "Router", {
4331
+ enumerable: true,
4332
+ get: function() {
4333
+ return Router;
4334
+ }
4384
4335
  });
4385
- Object.defineProperty(exports, 'Router', {
4386
- enumerable: true,
4387
- get: function () {
4388
- return Router;
4389
- }
4336
+ Object.defineProperty(exports, "RouterError", {
4337
+ enumerable: true,
4338
+ get: function() {
4339
+ return RouterError;
4340
+ }
4390
4341
  });
4391
- Object.defineProperty(exports, 'RouterError', {
4392
- enumerable: true,
4393
- get: function () {
4394
- return RouterError;
4395
- }
4342
+ Object.defineProperty(exports, "SendActivityError", {
4343
+ enumerable: true,
4344
+ get: function() {
4345
+ return SendActivityError;
4346
+ }
4396
4347
  });
4397
- Object.defineProperty(exports, 'SendActivityError', {
4398
- enumerable: true,
4399
- get: function () {
4400
- return SendActivityError;
4401
- }
4348
+ Object.defineProperty(exports, "buildCollectionSynchronizationHeader", {
4349
+ enumerable: true,
4350
+ get: function() {
4351
+ return buildCollectionSynchronizationHeader;
4352
+ }
4402
4353
  });
4403
- Object.defineProperty(exports, 'buildCollectionSynchronizationHeader', {
4404
- enumerable: true,
4405
- get: function () {
4406
- return buildCollectionSynchronizationHeader;
4407
- }
4354
+ Object.defineProperty(exports, "createExponentialBackoffPolicy", {
4355
+ enumerable: true,
4356
+ get: function() {
4357
+ return createExponentialBackoffPolicy;
4358
+ }
4408
4359
  });
4409
- Object.defineProperty(exports, 'createExponentialBackoffPolicy', {
4410
- enumerable: true,
4411
- get: function () {
4412
- return createExponentialBackoffPolicy;
4413
- }
4360
+ Object.defineProperty(exports, "createFederation", {
4361
+ enumerable: true,
4362
+ get: function() {
4363
+ return createFederation;
4364
+ }
4414
4365
  });
4415
- Object.defineProperty(exports, 'createFederation', {
4416
- enumerable: true,
4417
- get: function () {
4418
- return createFederation;
4419
- }
4366
+ Object.defineProperty(exports, "createFederationBuilder", {
4367
+ enumerable: true,
4368
+ get: function() {
4369
+ return createFederationBuilder;
4370
+ }
4420
4371
  });
4421
- Object.defineProperty(exports, 'createFederationBuilder', {
4422
- enumerable: true,
4423
- get: function () {
4424
- return createFederationBuilder;
4425
- }
4372
+ Object.defineProperty(exports, "digest", {
4373
+ enumerable: true,
4374
+ get: function() {
4375
+ return digest;
4376
+ }
4426
4377
  });
4427
- Object.defineProperty(exports, 'digest', {
4428
- enumerable: true,
4429
- get: function () {
4430
- return digest;
4431
- }
4378
+ Object.defineProperty(exports, "handleWebFinger", {
4379
+ enumerable: true,
4380
+ get: function() {
4381
+ return handleWebFinger;
4382
+ }
4432
4383
  });
4433
- Object.defineProperty(exports, 'handleWebFinger', {
4434
- enumerable: true,
4435
- get: function () {
4436
- return handleWebFinger;
4437
- }
4384
+ Object.defineProperty(exports, "respondWithObject", {
4385
+ enumerable: true,
4386
+ get: function() {
4387
+ return respondWithObject;
4388
+ }
4438
4389
  });
4439
- Object.defineProperty(exports, 'respondWithObject', {
4440
- enumerable: true,
4441
- get: function () {
4442
- return respondWithObject;
4443
- }
4390
+ Object.defineProperty(exports, "respondWithObjectIfAcceptable", {
4391
+ enumerable: true,
4392
+ get: function() {
4393
+ return respondWithObjectIfAcceptable;
4394
+ }
4444
4395
  });
4445
- Object.defineProperty(exports, 'respondWithObjectIfAcceptable', {
4446
- enumerable: true,
4447
- get: function () {
4448
- return respondWithObjectIfAcceptable;
4449
- }
4450
- });