@fedify/fedify 2.0.0-pr.559.6 → 2.0.0

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 (65) hide show
  1. package/README.md +8 -0
  2. package/dist/{builder-DFgILDcG.js → builder-DIwRDV19.js} +12 -57
  3. package/dist/compat/mod.d.cts +2 -2
  4. package/dist/compat/mod.d.ts +2 -2
  5. package/dist/compat/transformers.test.js +11 -11
  6. package/dist/{context-Cf0-LmZC.d.cts → context-BdNW_8a3.d.cts} +19 -46
  7. package/dist/{context-liIe6DFH.d.ts → context-C-GVKcJR.d.ts} +19 -46
  8. package/dist/{deno-Dssbv2qD.js → deno-CJgVX6Dr.js} +1 -4
  9. package/dist/{docloader-DLiT1bFg.js → docloader-BMecQIi-.js} +4 -12
  10. package/dist/federation/builder.test.js +3 -3
  11. package/dist/federation/handler.test.js +45 -45
  12. package/dist/federation/idempotency.test.js +11 -11
  13. package/dist/federation/inbox.test.js +2 -2
  14. package/dist/federation/middleware.test.js +43 -68
  15. package/dist/federation/mod.cjs +4 -4
  16. package/dist/federation/mod.d.cts +3 -3
  17. package/dist/federation/mod.d.ts +3 -3
  18. package/dist/federation/mod.js +4 -4
  19. package/dist/federation/send.test.js +90 -5
  20. package/dist/federation/webfinger.test.js +12 -15
  21. package/dist/{http-CfrdWdLH.js → http-CMTBVAxQ.js} +2 -2
  22. package/dist/{http-BP6_JjsL.cjs → http-CowIBMKY.cjs} +1 -4
  23. package/dist/{http-BaPyHVQ7.js → http-DoLgvgZ3.js} +1 -4
  24. package/dist/{inbox-CW8E414g.js → inbox-BrQMunLn.js} +1 -1
  25. package/dist/{key-DJI5G1Ub.js → key-BQD4Ef_6.js} +1 -1
  26. package/dist/{kv-cache-yGgfNuY5.cjs → kv-cache-174yQHE6.cjs} +1 -3
  27. package/dist/{kv-cache-CuA9rQF1.js → kv-cache-CFlvozMZ.js} +2 -4
  28. package/dist/{ld-Cu0jmueI.js → ld-DNdCEe6l.js} +2 -2
  29. package/dist/{middleware-D227KuaF.js → middleware-BN-t5M_R.js} +157 -210
  30. package/dist/middleware-BYNnNj-3.cjs +12 -0
  31. package/dist/{middleware-RxA4Ghbe.js → middleware-D5JdOwAE.js} +193 -260
  32. package/dist/{middleware-CBWnYv0h.js → middleware-UqzNuf3o.js} +11 -11
  33. package/dist/{middleware-Ddt9Yu31.cjs → middleware-aQr0yVne.cjs} +193 -260
  34. package/dist/{middleware-CjoXj45O.js → middleware-dO1Uzsiv.js} +4 -4
  35. package/dist/{mod-H3ScYaOb.d.cts → mod-5PNty1K9.d.cts} +1 -1
  36. package/dist/{mod-Do_sZWAA.d.cts → mod-BcpEGTWV.d.cts} +1 -1
  37. package/dist/{mod-CvhyLrjX.d.ts → mod-CevNbUol.d.ts} +0 -18
  38. package/dist/{mod-Dquroqiv.d.ts → mod-CtO31FCx.d.ts} +1 -1
  39. package/dist/{mod-B9_l3te3.d.ts → mod-Da9fNDyC.d.ts} +1 -1
  40. package/dist/{mod-DWaA45ef.d.cts → mod-ErTjUJs9.d.cts} +0 -18
  41. package/dist/mod.cjs +4 -4
  42. package/dist/mod.d.cts +6 -6
  43. package/dist/mod.d.ts +6 -6
  44. package/dist/mod.js +4 -4
  45. package/dist/nodeinfo/handler.test.js +11 -11
  46. package/dist/{owner-8nrupc6V.js → owner-DbymvgVI.js} +1 -1
  47. package/dist/{proof-CUhWCefd.js → proof-C85CNL5a.js} +1 -1
  48. package/dist/{proof-BrTneuEN.cjs → proof-DQFAjOse.cjs} +1 -1
  49. package/dist/{proof-RhBPHpn0.js → proof-DVBdddim.js} +2 -2
  50. package/dist/{send-CnI-Brh9.js → send-CkvEc-Tx.js} +35 -4
  51. package/dist/sig/http.test.js +3 -3
  52. package/dist/sig/key.test.js +2 -2
  53. package/dist/sig/ld.test.js +3 -3
  54. package/dist/sig/mod.cjs +2 -2
  55. package/dist/sig/mod.js +2 -2
  56. package/dist/sig/owner.test.js +3 -3
  57. package/dist/sig/proof.test.js +3 -3
  58. package/dist/testing/mod.d.ts +13 -33
  59. package/dist/utils/docloader.test.js +4 -4
  60. package/dist/utils/mod.cjs +2 -2
  61. package/dist/utils/mod.d.cts +1 -1
  62. package/dist/utils/mod.d.ts +1 -1
  63. package/dist/utils/mod.js +2 -2
  64. package/package.json +8 -8
  65. package/dist/middleware-ACS5M4fZ.cjs +0 -12
@@ -4,10 +4,10 @@
4
4
 
5
5
  const require_chunk = require('./chunk-CGaQZ11T.cjs');
6
6
  const require_transformers = require('./transformers-3g8GZwkZ.cjs');
7
- const require_http = require('./http-BP6_JjsL.cjs');
8
- const require_proof = require('./proof-BrTneuEN.cjs');
7
+ const require_http = require('./http-CowIBMKY.cjs');
8
+ const require_proof = require('./proof-DQFAjOse.cjs');
9
9
  const require_types = require('./types-Cd_hszr_.cjs');
10
- const require_kv_cache = require('./kv-cache-yGgfNuY5.cjs');
10
+ const require_kv_cache = require('./kv-cache-174yQHE6.cjs');
11
11
  const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
12
12
  const __fedify_vocab = require_chunk.__toESM(require("@fedify/vocab"));
13
13
  const __opentelemetry_api = require_chunk.__toESM(require("@opentelemetry/api"));
@@ -339,7 +339,7 @@ var FederationBuilderImpl = class {
339
339
  this.collectionTypeIds = {};
340
340
  }
341
341
  async build(options) {
342
- const { FederationImpl: FederationImpl$1 } = await Promise.resolve().then(() => require("./middleware-ACS5M4fZ.cjs"));
342
+ const { FederationImpl: FederationImpl$1 } = await Promise.resolve().then(() => require("./middleware-BYNnNj-3.cjs"));
343
343
  const f = new FederationImpl$1(options);
344
344
  const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
345
345
  f.router = this.router.clone();
@@ -371,12 +371,7 @@ var FederationBuilderImpl = class {
371
371
  setActorDispatcher(path, dispatcher) {
372
372
  if (this.router.has("actor")) throw new RouterError("Actor dispatcher already set.");
373
373
  const variables = this.router.add(path, "actor");
374
- if (variables.size !== 1 || !(variables.has("identifier") || variables.has("handle"))) throw new RouterError("Path for actor dispatcher must have one variable: {identifier}");
375
- if (variables.has("handle")) (0, __logtape_logtape.getLogger)([
376
- "fedify",
377
- "federation",
378
- "actor"
379
- ]).warn("The {{handle}} variable in the actor dispatcher path is deprecated. Use {{identifier}} instead.");
374
+ if (variables.size !== 1 || !variables.has("identifier")) throw new RouterError("Path for actor dispatcher must have one variable: {identifier}");
380
375
  const callbacks = { dispatcher: async (context$2, identifier) => {
381
376
  const actor = await this._getTracer().startActiveSpan("activitypub.dispatch_actor", {
382
377
  kind: __opentelemetry_api.SpanKind.SERVER,
@@ -538,12 +533,7 @@ var FederationBuilderImpl = class {
538
533
  if (this.inboxPath !== path) throw new RouterError("Inbox dispatcher path must match inbox listener path.");
539
534
  } else {
540
535
  const variables = this.router.add(path, "inbox");
541
- if (variables.size !== 1 || !(variables.has("identifier") || variables.has("handle"))) throw new RouterError("Path for inbox dispatcher must have one variable: {identifier}");
542
- if (variables.has("handle")) (0, __logtape_logtape.getLogger)([
543
- "fedify",
544
- "federation",
545
- "inbox"
546
- ]).warn("The {{handle}} variable in the inbox dispatcher path is deprecated. Use {{identifier}} instead.");
536
+ if (variables.size !== 1 || !variables.has("identifier")) throw new RouterError("Path for inbox dispatcher must have one variable: {identifier}");
547
537
  this.inboxPath = path;
548
538
  }
549
539
  const callbacks = { dispatcher };
@@ -571,12 +561,7 @@ var FederationBuilderImpl = class {
571
561
  setOutboxDispatcher(path, dispatcher) {
572
562
  if (this.router.has("outbox")) throw new RouterError("Outbox dispatcher already set.");
573
563
  const variables = this.router.add(path, "outbox");
574
- if (variables.size !== 1 || !(variables.has("identifier") || variables.has("handle"))) throw new RouterError("Path for outbox dispatcher must have one variable: {identifier}");
575
- if (variables.has("handle")) (0, __logtape_logtape.getLogger)([
576
- "fedify",
577
- "federation",
578
- "outbox"
579
- ]).warn("The {{handle}} variable in the outbox dispatcher path is deprecated. Use {{identifier}} instead.");
564
+ if (variables.size !== 1 || !variables.has("identifier")) throw new RouterError("Path for outbox dispatcher must have one variable: {identifier}");
580
565
  const callbacks = { dispatcher };
581
566
  this.outboxCallbacks = callbacks;
582
567
  const setters = {
@@ -602,12 +587,7 @@ var FederationBuilderImpl = class {
602
587
  setFollowingDispatcher(path, dispatcher) {
603
588
  if (this.router.has("following")) throw new RouterError("Following collection dispatcher already set.");
604
589
  const variables = this.router.add(path, "following");
605
- if (variables.size !== 1 || !(variables.has("identifier") || variables.has("handle"))) throw new RouterError("Path for following collection dispatcher must have one variable: {identifier}");
606
- if (variables.has("handle")) (0, __logtape_logtape.getLogger)([
607
- "fedify",
608
- "federation",
609
- "collection"
610
- ]).warn("The {{handle}} variable in the following collection dispatcher path is deprecated. Use {{identifier}} instead.");
590
+ if (variables.size !== 1 || !variables.has("identifier")) throw new RouterError("Path for following collection dispatcher must have one variable: {identifier}");
611
591
  const callbacks = { dispatcher };
612
592
  this.followingCallbacks = callbacks;
613
593
  const setters = {
@@ -633,12 +613,7 @@ var FederationBuilderImpl = class {
633
613
  setFollowersDispatcher(path, dispatcher) {
634
614
  if (this.router.has("followers")) throw new RouterError("Followers collection dispatcher already set.");
635
615
  const variables = this.router.add(path, "followers");
636
- if (variables.size !== 1 || !(variables.has("identifier") || variables.has("handle"))) throw new RouterError("Path for followers collection dispatcher must have one variable: {identifier}");
637
- if (variables.has("handle")) (0, __logtape_logtape.getLogger)([
638
- "fedify",
639
- "federation",
640
- "collection"
641
- ]).warn("The {{handle}} variable in the followers collection dispatcher path is deprecated. Use {{identifier}} instead.");
616
+ if (variables.size !== 1 || !variables.has("identifier")) throw new RouterError("Path for followers collection dispatcher must have one variable: {identifier}");
642
617
  const callbacks = { dispatcher };
643
618
  this.followersCallbacks = callbacks;
644
619
  const setters = {
@@ -664,12 +639,7 @@ var FederationBuilderImpl = class {
664
639
  setLikedDispatcher(path, dispatcher) {
665
640
  if (this.router.has("liked")) throw new RouterError("Liked collection dispatcher already set.");
666
641
  const variables = this.router.add(path, "liked");
667
- if (variables.size !== 1 || !(variables.has("identifier") || variables.has("handle"))) throw new RouterError("Path for liked collection dispatcher must have one variable: {identifier}");
668
- if (variables.has("handle")) (0, __logtape_logtape.getLogger)([
669
- "fedify",
670
- "federation",
671
- "collection"
672
- ]).warn("The {{handle}} variable in the liked collection dispatcher path is deprecated. Use {{identifier}} instead.");
642
+ if (variables.size !== 1 || !variables.has("identifier")) throw new RouterError("Path for liked collection dispatcher must have one variable: {identifier}");
673
643
  const callbacks = { dispatcher };
674
644
  this.likedCallbacks = callbacks;
675
645
  const setters = {
@@ -695,12 +665,7 @@ var FederationBuilderImpl = class {
695
665
  setFeaturedDispatcher(path, dispatcher) {
696
666
  if (this.router.has("featured")) throw new RouterError("Featured collection dispatcher already set.");
697
667
  const variables = this.router.add(path, "featured");
698
- if (variables.size !== 1 || !(variables.has("identifier") || variables.has("handle"))) throw new RouterError("Path for featured collection dispatcher must have one variable: {identifier}");
699
- if (variables.has("handle")) (0, __logtape_logtape.getLogger)([
700
- "fedify",
701
- "federation",
702
- "collection"
703
- ]).warn("The {{handle}} variable in the featured collection dispatcher path is deprecated. Use {{identifier}} instead.");
668
+ if (variables.size !== 1 || !variables.has("identifier")) throw new RouterError("Path for featured collection dispatcher must have one variable: {identifier}");
704
669
  const callbacks = { dispatcher };
705
670
  this.featuredCallbacks = callbacks;
706
671
  const setters = {
@@ -726,12 +691,7 @@ var FederationBuilderImpl = class {
726
691
  setFeaturedTagsDispatcher(path, dispatcher) {
727
692
  if (this.router.has("featuredTags")) throw new RouterError("Featured tags collection dispatcher already set.");
728
693
  const variables = this.router.add(path, "featuredTags");
729
- if (variables.size !== 1 || !(variables.has("identifier") || variables.has("handle"))) throw new RouterError("Path for featured tags collection dispatcher must have one variable: {identifier}");
730
- if (variables.has("handle")) (0, __logtape_logtape.getLogger)([
731
- "fedify",
732
- "federation",
733
- "collection"
734
- ]).warn("The {{handle}} variable in the featured tags collection dispatcher path is deprecated. Use {{identifier}} instead.");
694
+ if (variables.size !== 1 || !variables.has("identifier")) throw new RouterError("Path for featured tags collection dispatcher must have one variable: {identifier}");
735
695
  const callbacks = { dispatcher };
736
696
  this.featuredTagsCallbacks = callbacks;
737
697
  const setters = {
@@ -760,13 +720,8 @@ var FederationBuilderImpl = class {
760
720
  if (this.inboxPath !== inboxPath) throw new RouterError("Inbox listener path must match inbox dispatcher path.");
761
721
  } else {
762
722
  const variables = this.router.add(inboxPath, "inbox");
763
- if (variables.size !== 1 || !(variables.has("identifier") || variables.has("handle"))) throw new RouterError("Path for inbox must have one variable: {identifier}");
723
+ if (variables.size !== 1 || !variables.has("identifier")) throw new RouterError("Path for inbox must have one variable: {identifier}");
764
724
  this.inboxPath = inboxPath;
765
- if (variables.has("handle")) (0, __logtape_logtape.getLogger)([
766
- "fedify",
767
- "federation",
768
- "inbox"
769
- ]).warn("The {{handle}} variable in the inbox path is deprecated. Use {{identifier}} instead.");
770
725
  }
771
726
  if (sharedInboxPath != null) {
772
727
  const siVars = this.router.add(sharedInboxPath, "sharedInbox");
@@ -2133,6 +2088,34 @@ function sendActivity(options) {
2133
2088
  }
2134
2089
  });
2135
2090
  }
2091
+ const MAX_ERROR_RESPONSE_BODY_BYTES = 1024;
2092
+ async function readLimitedResponseBody(response, maxBytes) {
2093
+ if (response.body == null) return "";
2094
+ const reader = response.body.getReader();
2095
+ const decoder = new TextDecoder();
2096
+ const chunks = [];
2097
+ let totalBytes = 0;
2098
+ let truncated = false;
2099
+ try {
2100
+ while (true) {
2101
+ const { done, value } = await reader.read();
2102
+ if (done) break;
2103
+ if (totalBytes + value.length > maxBytes) {
2104
+ const remaining = maxBytes - totalBytes;
2105
+ if (remaining > 0) chunks.push(decoder.decode(value.slice(0, remaining), { stream: true }));
2106
+ truncated = true;
2107
+ break;
2108
+ }
2109
+ chunks.push(decoder.decode(value, { stream: true }));
2110
+ totalBytes += value.length;
2111
+ }
2112
+ } finally {
2113
+ reader.releaseLock();
2114
+ }
2115
+ let result = chunks.join("");
2116
+ if (truncated) result += "… (truncated)";
2117
+ return result;
2118
+ }
2136
2119
  async function sendActivityInternal({ activity, activityId, keys, inbox, headers, specDeterminer, tracerProvider }, span) {
2137
2120
  const logger$1 = (0, __logtape_logtape.getLogger)([
2138
2121
  "fedify",
@@ -2175,7 +2158,7 @@ async function sendActivityInternal({ activity, activityId, keys, inbox, headers
2175
2158
  if (!response.ok) {
2176
2159
  let error;
2177
2160
  try {
2178
- error = await response.text();
2161
+ error = await readLimitedResponseBody(response, MAX_ERROR_RESPONSE_BODY_BYTES);
2179
2162
  } catch (_) {
2180
2163
  error = "";
2181
2164
  }
@@ -2210,7 +2193,10 @@ var SendActivityError = class extends Error {
2210
2193
  */
2211
2194
  statusCode;
2212
2195
  /**
2213
- * The response body from the inbox, if any.
2196
+ * The response body from the inbox, if any. Note that this may be
2197
+ * truncated to a maximum of 1 KiB to prevent excessive memory consumption
2198
+ * when remote servers return large error pages (e.g., Cloudflare error pages).
2199
+ * If truncated, the string will end with `"… (truncated)"`.
2214
2200
  */
2215
2201
  responseBody;
2216
2202
  /**
@@ -2395,7 +2381,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2395
2381
  outboxRetryPolicy;
2396
2382
  inboxRetryPolicy;
2397
2383
  activityTransformers;
2398
- tracerProvider;
2384
+ _tracerProvider;
2399
2385
  firstKnock;
2400
2386
  constructor(options) {
2401
2387
  super();
@@ -2477,9 +2463,12 @@ var FederationImpl = class extends FederationBuilderImpl {
2477
2463
  this.outboxRetryPolicy = options.outboxRetryPolicy ?? createExponentialBackoffPolicy();
2478
2464
  this.inboxRetryPolicy = options.inboxRetryPolicy ?? createExponentialBackoffPolicy();
2479
2465
  this.activityTransformers = options.activityTransformers ?? require_transformers.getDefaultActivityTransformers();
2480
- this.tracerProvider = options.tracerProvider ?? __opentelemetry_api.trace.getTracerProvider();
2466
+ this._tracerProvider = options.tracerProvider;
2481
2467
  this.firstKnock = options.firstKnock;
2482
2468
  }
2469
+ get tracerProvider() {
2470
+ return this._tracerProvider ?? __opentelemetry_api.trace.getTracerProvider();
2471
+ }
2483
2472
  _initializeRouter() {
2484
2473
  this.router.add("/.well-known/webfinger", "webfinger");
2485
2474
  this.router.add("/.well-known/nodeinfo", "nodeInfoJrd");
@@ -2520,18 +2509,24 @@ var FederationImpl = class extends FederationBuilderImpl {
2520
2509
  kind: __opentelemetry_api.SpanKind.CONSUMER,
2521
2510
  attributes: { "activitypub.activity.type": message.activityType }
2522
2511
  }, extractedContext, async (span) => {
2523
- if (message.activityId != null) span.setAttribute("activitypub.activity.id", message.activityId);
2524
- try {
2525
- await this.#listenFanoutMessage(contextData, message);
2526
- } catch (e) {
2527
- span.setStatus({
2528
- code: __opentelemetry_api.SpanStatusCode.ERROR,
2529
- message: String(e)
2530
- });
2531
- throw e;
2532
- } finally {
2533
- span.end();
2534
- }
2512
+ const spanCtx = span.spanContext();
2513
+ return await (0, __logtape_logtape.withContext)({
2514
+ traceId: spanCtx.traceId,
2515
+ spanId: spanCtx.spanId
2516
+ }, async () => {
2517
+ if (message.activityId != null) span.setAttribute("activitypub.activity.id", message.activityId);
2518
+ try {
2519
+ await this.#listenFanoutMessage(contextData, message);
2520
+ } catch (e) {
2521
+ span.setStatus({
2522
+ code: __opentelemetry_api.SpanStatusCode.ERROR,
2523
+ message: String(e)
2524
+ });
2525
+ throw e;
2526
+ } finally {
2527
+ span.end();
2528
+ }
2529
+ });
2535
2530
  });
2536
2531
  else if (message.type === "outbox") await tracer.startActiveSpan("activitypub.outbox", {
2537
2532
  kind: __opentelemetry_api.SpanKind.CONSUMER,
@@ -2540,34 +2535,46 @@ var FederationImpl = class extends FederationBuilderImpl {
2540
2535
  "activitypub.activity.retries": message.attempt
2541
2536
  }
2542
2537
  }, extractedContext, async (span) => {
2543
- if (message.activityId != null) span.setAttribute("activitypub.activity.id", message.activityId);
2544
- try {
2545
- await this.#listenOutboxMessage(contextData, message, span);
2546
- } catch (e) {
2547
- span.setStatus({
2548
- code: __opentelemetry_api.SpanStatusCode.ERROR,
2549
- message: String(e)
2550
- });
2551
- throw e;
2552
- } finally {
2553
- span.end();
2554
- }
2538
+ const spanCtx = span.spanContext();
2539
+ return await (0, __logtape_logtape.withContext)({
2540
+ traceId: spanCtx.traceId,
2541
+ spanId: spanCtx.spanId
2542
+ }, async () => {
2543
+ if (message.activityId != null) span.setAttribute("activitypub.activity.id", message.activityId);
2544
+ try {
2545
+ await this.#listenOutboxMessage(contextData, message, span);
2546
+ } catch (e) {
2547
+ span.setStatus({
2548
+ code: __opentelemetry_api.SpanStatusCode.ERROR,
2549
+ message: String(e)
2550
+ });
2551
+ throw e;
2552
+ } finally {
2553
+ span.end();
2554
+ }
2555
+ });
2555
2556
  });
2556
2557
  else if (message.type === "inbox") await tracer.startActiveSpan("activitypub.inbox", {
2557
2558
  kind: __opentelemetry_api.SpanKind.CONSUMER,
2558
2559
  attributes: { "activitypub.shared_inbox": message.identifier == null }
2559
2560
  }, extractedContext, async (span) => {
2560
- try {
2561
- await this.#listenInboxMessage(contextData, message, span);
2562
- } catch (e) {
2563
- span.setStatus({
2564
- code: __opentelemetry_api.SpanStatusCode.ERROR,
2565
- message: String(e)
2566
- });
2567
- throw e;
2568
- } finally {
2569
- span.end();
2570
- }
2561
+ const spanCtx = span.spanContext();
2562
+ return await (0, __logtape_logtape.withContext)({
2563
+ traceId: spanCtx.traceId,
2564
+ spanId: spanCtx.spanId
2565
+ }, async () => {
2566
+ try {
2567
+ await this.#listenInboxMessage(contextData, message, span);
2568
+ } catch (e) {
2569
+ span.setStatus({
2570
+ code: __opentelemetry_api.SpanStatusCode.ERROR,
2571
+ message: String(e)
2572
+ });
2573
+ throw e;
2574
+ } finally {
2575
+ span.end();
2576
+ }
2577
+ });
2571
2578
  });
2572
2579
  });
2573
2580
  }
@@ -2731,7 +2738,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2731
2738
  if (message.identifier != null) context$2 = this.#createContext(baseUrl, ctxData, { documentLoader: await context$2.getDocumentLoader({ identifier: message.identifier }) });
2732
2739
  else if (this.sharedInboxKeyDispatcher != null) {
2733
2740
  const identity = await this.sharedInboxKeyDispatcher(context$2);
2734
- if (identity != null) context$2 = this.#createContext(baseUrl, ctxData, { documentLoader: "identifier" in identity || "username" in identity || "handle" in identity ? await context$2.getDocumentLoader(identity) : context$2.getDocumentLoader(identity) });
2741
+ 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) });
2735
2742
  }
2736
2743
  const activity = await __fedify_vocab.Activity.fromJsonLd(message.activity, context$2);
2737
2744
  span.setAttribute("activitypub.activity.type", (0, __fedify_vocab.getTypeId)(activity).href);
@@ -3040,54 +3047,60 @@ var FederationImpl = class extends FederationBuilderImpl {
3040
3047
  [__opentelemetry_semantic_conventions.ATTR_URL_FULL]: request.url
3041
3048
  }
3042
3049
  }, async (span) => {
3043
- const logger$1 = (0, __logtape_logtape.getLogger)([
3044
- "fedify",
3045
- "federation",
3046
- "http"
3047
- ]);
3048
- if (span.isRecording()) for (const [k, v] of request.headers) span.setAttribute((0, __opentelemetry_semantic_conventions.ATTR_HTTP_REQUEST_HEADER)(k), [v]);
3049
- let response;
3050
- try {
3051
- response = await this.#fetch(request, {
3052
- ...options,
3053
- span,
3054
- tracer
3055
- });
3056
- if (acceptsJsonLd(request)) response.headers.set("Vary", "Accept");
3057
- } catch (error) {
3058
- span.setStatus({
3059
- code: __opentelemetry_api.SpanStatusCode.ERROR,
3060
- message: `${error}`
3061
- });
3050
+ const spanCtx = span.spanContext();
3051
+ return await (0, __logtape_logtape.withContext)({
3052
+ traceId: spanCtx.traceId,
3053
+ spanId: spanCtx.spanId
3054
+ }, async () => {
3055
+ const logger$1 = (0, __logtape_logtape.getLogger)([
3056
+ "fedify",
3057
+ "federation",
3058
+ "http"
3059
+ ]);
3060
+ if (span.isRecording()) for (const [k, v] of request.headers) span.setAttribute((0, __opentelemetry_semantic_conventions.ATTR_HTTP_REQUEST_HEADER)(k), [v]);
3061
+ let response;
3062
+ try {
3063
+ response = await this.#fetch(request, {
3064
+ ...options,
3065
+ span,
3066
+ tracer
3067
+ });
3068
+ if (acceptsJsonLd(request)) response.headers.set("Vary", "Accept");
3069
+ } catch (error) {
3070
+ span.setStatus({
3071
+ code: __opentelemetry_api.SpanStatusCode.ERROR,
3072
+ message: `${error}`
3073
+ });
3074
+ span.end();
3075
+ logger$1.error("An error occurred while serving request {method} {url}: {error}", {
3076
+ method: request.method,
3077
+ url: request.url,
3078
+ error
3079
+ });
3080
+ throw error;
3081
+ }
3082
+ if (span.isRecording()) {
3083
+ span.setAttribute(__opentelemetry_semantic_conventions.ATTR_HTTP_RESPONSE_STATUS_CODE, response.status);
3084
+ for (const [k, v] of response.headers) span.setAttribute((0, __opentelemetry_semantic_conventions.ATTR_HTTP_RESPONSE_HEADER)(k), [v]);
3085
+ span.setStatus({
3086
+ code: response.status >= 500 ? __opentelemetry_api.SpanStatusCode.ERROR : __opentelemetry_api.SpanStatusCode.UNSET,
3087
+ message: response.statusText
3088
+ });
3089
+ }
3062
3090
  span.end();
3063
- logger$1.error("An error occurred while serving request {method} {url}: {error}", {
3091
+ const url = new URL(request.url);
3092
+ const logTpl = "{method} {path}: {status}";
3093
+ const values = {
3064
3094
  method: request.method,
3095
+ path: `${url.pathname}${url.search}`,
3065
3096
  url: request.url,
3066
- error
3067
- });
3068
- throw error;
3069
- }
3070
- if (span.isRecording()) {
3071
- span.setAttribute(__opentelemetry_semantic_conventions.ATTR_HTTP_RESPONSE_STATUS_CODE, response.status);
3072
- for (const [k, v] of response.headers) span.setAttribute((0, __opentelemetry_semantic_conventions.ATTR_HTTP_RESPONSE_HEADER)(k), [v]);
3073
- span.setStatus({
3074
- code: response.status >= 500 ? __opentelemetry_api.SpanStatusCode.ERROR : __opentelemetry_api.SpanStatusCode.UNSET,
3075
- message: response.statusText
3076
- });
3077
- }
3078
- span.end();
3079
- const url = new URL(request.url);
3080
- const logTpl = "{method} {path}: {status}";
3081
- const values = {
3082
- method: request.method,
3083
- path: `${url.pathname}${url.search}`,
3084
- url: request.url,
3085
- status: response.status
3086
- };
3087
- if (response.status >= 500) logger$1.error(logTpl, values);
3088
- else if (response.status >= 400) logger$1.warn(logTpl, values);
3089
- else logger$1.info(logTpl, values);
3090
- return response;
3097
+ status: response.status
3098
+ };
3099
+ if (response.status >= 500) logger$1.error(logTpl, values);
3100
+ else if (response.status >= 400) logger$1.warn(logTpl, values);
3101
+ else logger$1.info(logTpl, values);
3102
+ return response;
3103
+ });
3091
3104
  });
3092
3105
  });
3093
3106
  }
@@ -3121,9 +3134,9 @@ var FederationImpl = class extends FederationBuilderImpl {
3121
3134
  if (request.method !== "POST" && !acceptsJsonLd(request)) return await onNotAcceptable(request);
3122
3135
  switch (routeName) {
3123
3136
  case "actor":
3124
- context$2 = this.#createContext(request, contextData, { invokedFromActorDispatcher: { identifier: route.values.identifier ?? route.values.handle } });
3137
+ context$2 = this.#createContext(request, contextData, { invokedFromActorDispatcher: { identifier: route.values.identifier } });
3125
3138
  return await handleActor(request, {
3126
- identifier: route.values.identifier ?? route.values.handle,
3139
+ identifier: route.values.identifier,
3127
3140
  context: context$2,
3128
3141
  actorDispatcher: this.actorCallbacks?.dispatcher,
3129
3142
  authorizePredicate: this.actorCallbacks?.authorizePredicate,
@@ -3149,7 +3162,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3149
3162
  }
3150
3163
  case "outbox": return await handleCollection(request, {
3151
3164
  name: "outbox",
3152
- identifier: route.values.identifier ?? route.values.handle,
3165
+ identifier: route.values.identifier,
3153
3166
  uriGetter: context$2.getOutboxUri.bind(context$2),
3154
3167
  context: context$2,
3155
3168
  collectionCallbacks: this.outboxCallbacks,
@@ -3160,7 +3173,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3160
3173
  case "inbox":
3161
3174
  if (request.method !== "POST") return await handleCollection(request, {
3162
3175
  name: "inbox",
3163
- identifier: route.values.identifier ?? route.values.handle,
3176
+ identifier: route.values.identifier,
3164
3177
  uriGetter: context$2.getInboxUri.bind(context$2),
3165
3178
  context: context$2,
3166
3179
  collectionCallbacks: this.inboxCallbacks,
@@ -3168,15 +3181,15 @@ var FederationImpl = class extends FederationBuilderImpl {
3168
3181
  onUnauthorized,
3169
3182
  onNotFound
3170
3183
  });
3171
- context$2 = this.#createContext(request, contextData, { documentLoader: await context$2.getDocumentLoader({ identifier: route.values.identifier ?? route.values.handle }) });
3184
+ context$2 = this.#createContext(request, contextData, { documentLoader: await context$2.getDocumentLoader({ identifier: route.values.identifier }) });
3172
3185
  case "sharedInbox":
3173
3186
  if (routeName !== "inbox" && this.sharedInboxKeyDispatcher != null) {
3174
3187
  const identity = await this.sharedInboxKeyDispatcher(context$2);
3175
- if (identity != null) context$2 = this.#createContext(request, contextData, { documentLoader: "identifier" in identity || "username" in identity || "handle" in identity ? await context$2.getDocumentLoader(identity) : context$2.getDocumentLoader(identity) });
3188
+ 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) });
3176
3189
  }
3177
3190
  if (!this.manuallyStartQueue) this._startQueueInternal(contextData);
3178
3191
  return await handleInbox(request, {
3179
- recipient: route.values.identifier ?? route.values.handle ?? null,
3192
+ recipient: route.values.identifier ?? null,
3180
3193
  context: context$2,
3181
3194
  inboxContextFactory: context$2.toInboxContext.bind(context$2),
3182
3195
  kv: this.kv,
@@ -3193,7 +3206,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3193
3206
  });
3194
3207
  case "following": return await handleCollection(request, {
3195
3208
  name: "following",
3196
- identifier: route.values.identifier ?? route.values.handle,
3209
+ identifier: route.values.identifier,
3197
3210
  uriGetter: context$2.getFollowingUri.bind(context$2),
3198
3211
  context: context$2,
3199
3212
  collectionCallbacks: this.followingCallbacks,
@@ -3210,7 +3223,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3210
3223
  }
3211
3224
  return await handleCollection(request, {
3212
3225
  name: "followers",
3213
- identifier: route.values.identifier ?? route.values.handle,
3226
+ identifier: route.values.identifier,
3214
3227
  uriGetter: baseUrl == null ? context$2.getFollowersUri.bind(context$2) : (identifier) => {
3215
3228
  const uri = context$2.getFollowersUri(identifier);
3216
3229
  uri.searchParams.set("base-url", baseUrl);
@@ -3227,7 +3240,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3227
3240
  }
3228
3241
  case "liked": return await handleCollection(request, {
3229
3242
  name: "liked",
3230
- identifier: route.values.identifier ?? route.values.handle,
3243
+ identifier: route.values.identifier,
3231
3244
  uriGetter: context$2.getLikedUri.bind(context$2),
3232
3245
  context: context$2,
3233
3246
  collectionCallbacks: this.likedCallbacks,
@@ -3237,7 +3250,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3237
3250
  });
3238
3251
  case "featured": return await handleCollection(request, {
3239
3252
  name: "featured",
3240
- identifier: route.values.identifier ?? route.values.handle,
3253
+ identifier: route.values.identifier,
3241
3254
  uriGetter: context$2.getFeaturedUri.bind(context$2),
3242
3255
  context: context$2,
3243
3256
  collectionCallbacks: this.featuredCallbacks,
@@ -3247,7 +3260,7 @@ var FederationImpl = class extends FederationBuilderImpl {
3247
3260
  });
3248
3261
  case "featuredTags": return await handleCollection(request, {
3249
3262
  name: "featured tags",
3250
- identifier: route.values.identifier ?? route.values.handle,
3263
+ identifier: route.values.identifier,
3251
3264
  uriGetter: context$2.getFeaturedTagsUri.bind(context$2),
3252
3265
  context: context$2,
3253
3266
  collectionCallbacks: this.featuredTagsCallbacks,
@@ -3345,10 +3358,7 @@ var ContextImpl = class ContextImpl {
3345
3358
  return new URL(path, this.canonicalOrigin);
3346
3359
  }
3347
3360
  getActorUri(identifier) {
3348
- const path = this.federation.router.build("actor", {
3349
- identifier,
3350
- handle: identifier
3351
- });
3361
+ const path = this.federation.router.build("actor", { identifier });
3352
3362
  if (path == null) throw new RouterError("No actor dispatcher registered.");
3353
3363
  return new URL(path, this.canonicalOrigin);
3354
3364
  }
@@ -3361,10 +3371,7 @@ var ContextImpl = class ContextImpl {
3361
3371
  return new URL(path, this.canonicalOrigin);
3362
3372
  }
3363
3373
  getOutboxUri(identifier) {
3364
- const path = this.federation.router.build("outbox", {
3365
- identifier,
3366
- handle: identifier
3367
- });
3374
+ const path = this.federation.router.build("outbox", { identifier });
3368
3375
  if (path == null) throw new RouterError("No outbox dispatcher registered.");
3369
3376
  return new URL(path, this.canonicalOrigin);
3370
3377
  }
@@ -3374,50 +3381,32 @@ var ContextImpl = class ContextImpl {
3374
3381
  if (path$1 == null) throw new RouterError("No shared inbox path registered.");
3375
3382
  return new URL(path$1, this.canonicalOrigin);
3376
3383
  }
3377
- const path = this.federation.router.build("inbox", {
3378
- identifier,
3379
- handle: identifier
3380
- });
3384
+ const path = this.federation.router.build("inbox", { identifier });
3381
3385
  if (path == null) throw new RouterError("No inbox path registered.");
3382
3386
  return new URL(path, this.canonicalOrigin);
3383
3387
  }
3384
3388
  getFollowingUri(identifier) {
3385
- const path = this.federation.router.build("following", {
3386
- identifier,
3387
- handle: identifier
3388
- });
3389
+ const path = this.federation.router.build("following", { identifier });
3389
3390
  if (path == null) throw new RouterError("No following collection path registered.");
3390
3391
  return new URL(path, this.canonicalOrigin);
3391
3392
  }
3392
3393
  getFollowersUri(identifier) {
3393
- const path = this.federation.router.build("followers", {
3394
- identifier,
3395
- handle: identifier
3396
- });
3394
+ const path = this.federation.router.build("followers", { identifier });
3397
3395
  if (path == null) throw new RouterError("No followers collection path registered.");
3398
3396
  return new URL(path, this.canonicalOrigin);
3399
3397
  }
3400
3398
  getLikedUri(identifier) {
3401
- const path = this.federation.router.build("liked", {
3402
- identifier,
3403
- handle: identifier
3404
- });
3399
+ const path = this.federation.router.build("liked", { identifier });
3405
3400
  if (path == null) throw new RouterError("No liked collection path registered.");
3406
3401
  return new URL(path, this.canonicalOrigin);
3407
3402
  }
3408
3403
  getFeaturedUri(identifier) {
3409
- const path = this.federation.router.build("featured", {
3410
- identifier,
3411
- handle: identifier
3412
- });
3404
+ const path = this.federation.router.build("featured", { identifier });
3413
3405
  if (path == null) throw new RouterError("No featured collection path registered.");
3414
3406
  return new URL(path, this.canonicalOrigin);
3415
3407
  }
3416
3408
  getFeaturedTagsUri(identifier) {
3417
- const path = this.federation.router.build("featuredTags", {
3418
- identifier,
3419
- handle: identifier
3420
- });
3409
+ const path = this.federation.router.build("featuredTags", { identifier });
3421
3410
  if (path == null) throw new RouterError("No featured tags collection path registered.");
3422
3411
  return new URL(path, this.canonicalOrigin);
3423
3412
  }
@@ -3430,24 +3419,15 @@ var ContextImpl = class ContextImpl {
3430
3419
  if (uri == null) return null;
3431
3420
  if (uri.origin !== this.origin && uri.origin !== this.canonicalOrigin) return null;
3432
3421
  const route = this.federation.router.route(uri.pathname);
3433
- const logger$1 = (0, __logtape_logtape.getLogger)(["fedify", "federation"]);
3434
3422
  if (route == null) return null;
3435
3423
  else if (route.name === "sharedInbox") return {
3436
3424
  type: "inbox",
3437
- identifier: void 0,
3438
- get handle() {
3439
- logger$1.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
3440
- return void 0;
3441
- }
3425
+ identifier: void 0
3442
3426
  };
3443
- const identifier = "identifier" in route.values ? route.values.identifier : route.values.handle;
3427
+ const identifier = route.values.identifier;
3444
3428
  if (route.name === "actor") return {
3445
3429
  type: "actor",
3446
- identifier,
3447
- get handle() {
3448
- logger$1.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
3449
- return identifier;
3450
- }
3430
+ identifier
3451
3431
  };
3452
3432
  else if (route.name.startsWith("object:")) {
3453
3433
  const typeId = route.name.replace(/^object:/, "");
@@ -3459,59 +3439,31 @@ var ContextImpl = class ContextImpl {
3459
3439
  };
3460
3440
  } else if (route.name === "inbox") return {
3461
3441
  type: "inbox",
3462
- identifier,
3463
- get handle() {
3464
- logger$1.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
3465
- return identifier;
3466
- }
3442
+ identifier
3467
3443
  };
3468
3444
  else if (route.name === "outbox") return {
3469
3445
  type: "outbox",
3470
- identifier,
3471
- get handle() {
3472
- logger$1.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
3473
- return identifier;
3474
- }
3446
+ identifier
3475
3447
  };
3476
3448
  else if (route.name === "following") return {
3477
3449
  type: "following",
3478
- identifier,
3479
- get handle() {
3480
- logger$1.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
3481
- return identifier;
3482
- }
3450
+ identifier
3483
3451
  };
3484
3452
  else if (route.name === "followers") return {
3485
3453
  type: "followers",
3486
- identifier,
3487
- get handle() {
3488
- logger$1.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
3489
- return identifier;
3490
- }
3454
+ identifier
3491
3455
  };
3492
3456
  else if (route.name === "liked") return {
3493
3457
  type: "liked",
3494
- identifier,
3495
- get handle() {
3496
- logger$1.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
3497
- return identifier;
3498
- }
3458
+ identifier
3499
3459
  };
3500
3460
  else if (route.name === "featured") return {
3501
3461
  type: "featured",
3502
- identifier,
3503
- get handle() {
3504
- logger$1.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
3505
- return identifier;
3506
- }
3462
+ identifier
3507
3463
  };
3508
3464
  else if (route.name === "featuredTags") return {
3509
3465
  type: "featuredTags",
3510
- identifier,
3511
- get handle() {
3512
- logger$1.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
3513
- return identifier;
3514
- }
3466
+ identifier
3515
3467
  };
3516
3468
  const collectionTypes = ["collection", "orderedCollection"];
3517
3469
  const collectionRegex = /* @__PURE__ */ new RegExp(`^(${collectionTypes.join("|")}):(.*)$`);
@@ -3613,19 +3565,10 @@ var ContextImpl = class ContextImpl {
3613
3565
  return null;
3614
3566
  }
3615
3567
  getDocumentLoader(identity) {
3616
- if ("identifier" in identity || "username" in identity || "handle" in identity) {
3568
+ if ("identifier" in identity || "username" in identity) {
3617
3569
  let identifierPromise;
3618
- if ("username" in identity || "handle" in identity) {
3619
- let username;
3620
- if ("username" in identity) username = identity.username;
3621
- else {
3622
- username = identity.handle;
3623
- (0, __logtape_logtape.getLogger)([
3624
- "fedify",
3625
- "runtime",
3626
- "docloader"
3627
- ]).warn("The \"handle\" property is deprecated; use \"identifier\" or \"username\" instead.", { identity });
3628
- }
3570
+ if ("username" in identity) {
3571
+ const username = identity.username;
3629
3572
  const mapper = this.federation.actorCallbacks?.handleMapper;
3630
3573
  if (mapper == null) identifierPromise = Promise.resolve(username);
3631
3574
  else {
@@ -3711,15 +3654,10 @@ var ContextImpl = class ContextImpl {
3711
3654
  ]);
3712
3655
  let keys;
3713
3656
  let identifier = null;
3714
- if ("identifier" in sender || "username" in sender || "handle" in sender) {
3657
+ if ("identifier" in sender || "username" in sender) {
3715
3658
  if ("identifier" in sender) identifier = sender.identifier;
3716
3659
  else {
3717
- let username;
3718
- if ("username" in sender) username = sender.username;
3719
- else {
3720
- username = sender.handle;
3721
- logger$1.warn("The \"handle\" property for the sender parameter is deprecated; use \"identifier\" or \"username\" instead.", { sender });
3722
- }
3660
+ const username = sender.username;
3723
3661
  if (this.federation.actorCallbacks?.handleMapper == null) identifier = username;
3724
3662
  else {
3725
3663
  const mapped = await this.federation.actorCallbacks.handleMapper(this, username);
@@ -4075,15 +4013,10 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
4075
4013
  ]);
4076
4014
  let keys;
4077
4015
  let identifier = null;
4078
- if ("identifier" in forwarder || "username" in forwarder || "handle" in forwarder) {
4016
+ if ("identifier" in forwarder || "username" in forwarder) {
4079
4017
  if ("identifier" in forwarder) identifier = forwarder.identifier;
4080
4018
  else {
4081
- let username;
4082
- if ("username" in forwarder) username = forwarder.username;
4083
- else {
4084
- username = forwarder.handle;
4085
- logger$1.warn("The \"handle\" property for the forwarder parameter is deprecated; use \"identifier\" or \"username\" instead.", { forwarder });
4086
- }
4019
+ const username = forwarder.username;
4087
4020
  if (this.federation.actorCallbacks?.handleMapper == null) identifier = username;
4088
4021
  else {
4089
4022
  const mapped = await this.federation.actorCallbacks.handleMapper(this, username);