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