@fedify/fedify 2.5.0-dev.2327 → 2.5.0-dev.2339

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 (82) hide show
  1. package/dist/{builder-D1OTD3--.mjs → builder-4z5McYcY.mjs} +2 -2
  2. package/dist/compat/transformers.test.mjs +1 -1
  3. package/dist/{compound-proof-DML23ZA8.mjs → compound-proof-B6xZTnTr.mjs} +2 -2
  4. package/dist/{deno-CzjcjZ80.mjs → deno-BnX-hlO-.mjs} +1 -1
  5. package/dist/{docloader-tMR7o09T.mjs → docloader-_tslGlJv.mjs} +2 -2
  6. package/dist/exporter-DThFfe7P.mjs +257 -0
  7. package/dist/federation/builder.test.mjs +1 -1
  8. package/dist/federation/compound-fanout.test.mjs +3 -3
  9. package/dist/federation/handler-compound-proof.test.mjs +3 -3
  10. package/dist/federation/handler.test.mjs +224 -5
  11. package/dist/federation/hashlink-media.test.mjs +2 -2
  12. package/dist/federation/idempotency.test.mjs +2 -2
  13. package/dist/federation/inbox-report.test.mjs +5 -5
  14. package/dist/federation/metrics.test.mjs +1 -1
  15. package/dist/federation/middleware.test.mjs +101 -8
  16. package/dist/federation/mod.cjs +1 -1
  17. package/dist/federation/mod.js +1 -1
  18. package/dist/federation/outgoing-proof.test.mjs +5 -5
  19. package/dist/federation/portable-actor.test.mjs +3 -3
  20. package/dist/federation/portable-chain.test.mjs +3 -3
  21. package/dist/federation/portable-collection.test.mjs +4 -4
  22. package/dist/federation/portable-delivery.test.mjs +2 -2
  23. package/dist/federation/portable-gateway-keys.test.mjs +4 -4
  24. package/dist/federation/portable-inbox.test.mjs +4 -4
  25. package/dist/federation/portable-parse-uri.test.mjs +1 -1
  26. package/dist/federation/portable-route-activity.test.mjs +2 -2
  27. package/dist/federation/portable.test.mjs +3 -3
  28. package/dist/federation/send.test.mjs +199 -3
  29. package/dist/federation/tasks/enqueue.test.mjs +1 -1
  30. package/dist/federation/tasks/tasks.test.mjs +2 -2
  31. package/dist/federation/temporal.test.mjs +1 -1
  32. package/dist/federation/webfinger.test.mjs +1 -1
  33. package/dist/{federation-BHOSHFCr.cjs → federation-CV-CkIIZ.cjs} +22 -14
  34. package/dist/{http-CUhaXRsy.cjs → http-BJrxYYP3.cjs} +1 -1
  35. package/dist/{http-DzBwbsDL.mjs → http-BSmcgoaq.mjs} +4 -4
  36. package/dist/{http-gbfMWXuK.js → http-CVT3OEmZ.js} +1 -1
  37. package/dist/{key-CfJ7MJmp.mjs → key-DRLFC1um.mjs} +2 -2
  38. package/dist/{kv-cache-B3HjvmZE.mjs → kv-cache-DTY50c-3.mjs} +1 -1
  39. package/dist/{kv-cache-Y18nY4gZ.cjs → kv-cache-DnCGPsXH.cjs} +1 -1
  40. package/dist/{kv-cache-CyCsAOR6.js → kv-cache-Dv3joZCp.js} +1 -1
  41. package/dist/{ld-BzvgaYZi.mjs → ld-BiFf-T9F.mjs} +3 -3
  42. package/dist/{metrics-Dwkct8jJ.mjs → metrics-BuC9-u1Z.mjs} +1 -1
  43. package/dist/{middleware-BURmMr0W.mjs → middleware-A02EGx8T.mjs} +1 -1
  44. package/dist/{middleware-BFr_zLaE.mjs → middleware-BBSxgV0Y.mjs} +27 -23
  45. package/dist/{middleware-vJzuhHEr.js → middleware-CKEoEiBw.js} +22 -14
  46. package/dist/mod.cjs +4 -4
  47. package/dist/mod.js +4 -4
  48. package/dist/nodeinfo/handler.test.mjs +1 -1
  49. package/dist/otel/exporter.test.mjs +1 -253
  50. package/dist/{owner-CGXm_YAa.mjs → owner-BsgoTcNb.mjs} +3 -3
  51. package/dist/{portable-collection-DBAMRYNa.mjs → portable-collection-BiBpObws.mjs} +2 -2
  52. package/dist/{portable-collection-Cnl40K17.js → portable-collection-BzUoU2gg.js} +1 -1
  53. package/dist/{portable-collection-to2aHmLK.cjs → portable-collection-D3c6LAHN.cjs} +1 -1
  54. package/dist/{portable-key-DqFNrfnc.mjs → portable-key-CF6z6v-f.mjs} +1 -1
  55. package/dist/{proof-CImybMS5.mjs → proof-vlRUtAdS.mjs} +4 -4
  56. package/dist/{send-oReIfAwd.mjs → send-D5aMlvJH.mjs} +10 -6
  57. package/dist/sig/compound-proof-discovery.test.mjs +1 -1
  58. package/dist/sig/compound-proof-producer.test.mjs +1 -1
  59. package/dist/sig/compound-proof-verification.test.mjs +2 -2
  60. package/dist/sig/compound-proof.test.mjs +2 -2
  61. package/dist/sig/http.test.mjs +2 -2
  62. package/dist/sig/key.test.mjs +1 -1
  63. package/dist/sig/ld.test.mjs +2 -2
  64. package/dist/sig/mitra-receive-interop.test.mjs +4 -4
  65. package/dist/sig/mitra-send-interop.test.mjs +3 -3
  66. package/dist/sig/mod.cjs +2 -2
  67. package/dist/sig/mod.js +2 -2
  68. package/dist/sig/owner.test.mjs +1 -1
  69. package/dist/sig/portable-collection.test.mjs +1 -1
  70. package/dist/sig/portable-interop.test.mjs +3 -3
  71. package/dist/sig/portable-key.test.mjs +6 -6
  72. package/dist/sig/proof.test.mjs +3 -3
  73. package/dist/sig/tootik-request-interop.test.mjs +4 -4
  74. package/dist/sig/tootik-send-interop.test.mjs +3 -3
  75. package/dist/sig/verification.test.mjs +3 -3
  76. package/dist/{temporal-DLaPDeOv.mjs → temporal-BE3xoktR.mjs} +1 -1
  77. package/dist/testing/kv.test.mjs +1 -1
  78. package/dist/utils/docloader.test.mjs +2 -2
  79. package/dist/utils/kv-cache.test.mjs +1 -1
  80. package/dist/utils/mod.cjs +1 -1
  81. package/dist/utils/mod.js +1 -1
  82. package/package.json +6 -6
@@ -4,7 +4,7 @@ globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
5
5
  import "../std__assert-DvMDRPes.mjs";
6
6
  import { t as assertRejects } from "../assert_rejects-CTptdYck.mjs";
7
- import { _ as recordKeyLookup, a as instrumentDocumentLoader, b as recordWebFingerHandle, c as recordCircuitBreakerStateChange, d as recordCollectionRequest, f as recordCollectionTotalItems, g as recordInboxActivity, h as recordFanoutRecipients, i as getRemoteHost, l as recordCollectionDispatchDuration, m as recordDocumentFetch, p as recordDocumentCache, r as getFederationMetrics, t as classifyFetchError, u as recordCollectionPageItems, v as recordOutboxActivity, x as registerQueueDepthGauge, y as recordOutboxEnqueue } from "../metrics-Dwkct8jJ.mjs";
7
+ import { _ as recordKeyLookup, a as instrumentDocumentLoader, b as recordWebFingerHandle, c as recordCircuitBreakerStateChange, d as recordCollectionRequest, f as recordCollectionTotalItems, g as recordInboxActivity, h as recordFanoutRecipients, i as getRemoteHost, l as recordCollectionDispatchDuration, m as recordDocumentFetch, p as recordDocumentCache, r as getFederationMetrics, t as classifyFetchError, u as recordCollectionPageItems, v as recordOutboxActivity, x as registerQueueDepthGauge, y as recordOutboxEnqueue } from "../metrics-BuC9-u1Z.mjs";
8
8
  import { FetchError } from "@fedify/vocab-runtime";
9
9
  import { createTestMeterProvider, test } from "@fedify/fixture";
10
10
  import { DataPointType, MeterProvider, MetricReader } from "@opentelemetry/sdk-metrics";
@@ -16,18 +16,18 @@ import "../std__assert-DvMDRPes.mjs";
16
16
  import { t as assertRejects } from "../assert_rejects-CTptdYck.mjs";
17
17
  import { t as assertStrictEquals } from "../assert_strict_equals-CYvBmkpC.mjs";
18
18
  import { t as assert } from "../assert-D1Eafmd_.mjs";
19
- import { g as recordInboxActivity } from "../metrics-Dwkct8jJ.mjs";
20
- import { a as compactJsonLd, h as verifyJsonLd, p as signJsonLd, s as detachSignature } from "../ld-BzvgaYZi.mjs";
21
- import { a as signObject, s as verifyObject } from "../proof-CImybMS5.mjs";
22
- import { f as verifyRequest, l as signRequest } from "../http-DzBwbsDL.mjs";
19
+ import { g as recordInboxActivity } from "../metrics-BuC9-u1Z.mjs";
20
+ import { a as compactJsonLd, h as verifyJsonLd, p as signJsonLd, s as detachSignature } from "../ld-BiFf-T9F.mjs";
21
+ import { a as signObject, s as verifyObject } from "../proof-vlRUtAdS.mjs";
22
+ import { f as verifyRequest, l as signRequest } from "../http-BSmcgoaq.mjs";
23
23
  import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DIJNHW-Y.mjs";
24
- import { t as getAuthenticatedDocumentLoader } from "../docloader-tMR7o09T.mjs";
25
- import { T as handleBenchmarkTrigger, i as KvSpecDeterminer, n as FederationImpl, o as createFederation, r as InboxContextImpl, t as ContextImpl } from "../middleware-BFr_zLaE.mjs";
26
- import { t as doesActorOwnKey } from "../owner-CGXm_YAa.mjs";
24
+ import { t as getAuthenticatedDocumentLoader } from "../docloader-_tslGlJv.mjs";
25
+ import { T as handleBenchmarkTrigger, i as KvSpecDeterminer, n as FederationImpl, o as createFederation, r as InboxContextImpl, t as ContextImpl } from "../middleware-BBSxgV0Y.mjs";
26
+ import { t as doesActorOwnKey } from "../owner-BsgoTcNb.mjs";
27
27
  import { t as CircuitBreaker } from "../circuit-breaker-XJ53md4S.mjs";
28
28
  import { t as TaskCodec } from "../codec-C6rTrpIp.mjs";
29
29
  import { t as markCircuitBreakerLegacySweepDone } from "../circuit-breaker-test-utils-DW6YC_Pe.mjs";
30
- import { configure, reset } from "@logtape/logtape";
30
+ import { configure, reset, withContext } from "@logtape/logtape";
31
31
  import { RouterError } from "@fedify/uri-template";
32
32
  import * as vocab from "@fedify/vocab";
33
33
  import { Create, Note, Offer, Person, getTypeId, lookupObject } from "@fedify/vocab";
@@ -38,6 +38,7 @@ import dns from "node:dns/promises";
38
38
  import { deepStrictEqual, ok, rejects, strictEqual, throws } from "node:assert/strict";
39
39
  import serialize from "json-canon";
40
40
  import { DataPointType, MeterProvider as MeterProvider$1, MetricReader } from "@opentelemetry/sdk-metrics";
41
+ import { AsyncLocalStorage } from "node:async_hooks";
41
42
  //#region ../fixture/src/fixtures/example.com/create.json
42
43
  var create_default = {
43
44
  "@context": "https://www.w3.org/ns/activitystreams",
@@ -5436,6 +5437,98 @@ test("FederationImpl.processQueuedTask() permanent failure", async (t) => {
5436
5437
  });
5437
5438
  esm_default.hardReset();
5438
5439
  });
5440
+ test("FederationImpl.processQueuedTask() aligns the LogTape context with the delivery span inside the outbox worker", async () => {
5441
+ await withLogtapeLock(async () => {
5442
+ esm_default.spyGlobal();
5443
+ esm_default.post("https://example.com/inbox-queue-failing", {
5444
+ status: 500,
5445
+ body: "Internal Server Error"
5446
+ });
5447
+ const records = [];
5448
+ await reset();
5449
+ try {
5450
+ await configure({
5451
+ sinks: { buffer: (record) => records.push(record) },
5452
+ filters: {},
5453
+ loggers: [{
5454
+ category: [],
5455
+ sinks: ["buffer"],
5456
+ lowestLevel: "debug"
5457
+ }, {
5458
+ category: ["logtape", "meta"],
5459
+ sinks: []
5460
+ }],
5461
+ contextLocalStorage: new AsyncLocalStorage()
5462
+ });
5463
+ const [tracerProvider, exporter] = createTestTracerProvider();
5464
+ const queuedMessages = [];
5465
+ const federation = new FederationImpl({
5466
+ kv: new MemoryKvStore(),
5467
+ queue: {
5468
+ enqueue(message, _options) {
5469
+ queuedMessages.push(message);
5470
+ return Promise.resolve();
5471
+ },
5472
+ listen(_handler, _options) {
5473
+ return Promise.resolve();
5474
+ }
5475
+ },
5476
+ allowPrivateAddress: true,
5477
+ tracerProvider
5478
+ });
5479
+ const message = {
5480
+ type: "outbox",
5481
+ id: crypto.randomUUID(),
5482
+ baseUrl: "https://example.com",
5483
+ keys: [],
5484
+ activity: {
5485
+ "@context": "https://www.w3.org/ns/activitystreams",
5486
+ type: "Create",
5487
+ id: "https://example.com/activity/queue-failing",
5488
+ actor: "https://example.com/users/alice",
5489
+ object: {
5490
+ type: "Note",
5491
+ content: "test"
5492
+ }
5493
+ },
5494
+ activityType: "https://www.w3.org/ns/activitystreams#Create",
5495
+ inbox: "https://example.com/inbox-queue-failing",
5496
+ sharedInbox: false,
5497
+ started: (/* @__PURE__ */ new Date()).toISOString(),
5498
+ attempt: 0,
5499
+ headers: {},
5500
+ traceContext: {}
5501
+ };
5502
+ await withContext({ batchId: "outer-batch" }, async () => {
5503
+ await federation.processQueuedTask(void 0, message);
5504
+ });
5505
+ assertEquals(queuedMessages.length, 1);
5506
+ const deliverySpan = exporter.getSpan("activitypub.send_activity");
5507
+ assert(deliverySpan != null);
5508
+ const deliveryCtx = deliverySpan.spanContext();
5509
+ const workerSpan = exporter.getSpan("activitypub.outbox");
5510
+ assert(workerSpan != null);
5511
+ const workerCtx = workerSpan.spanContext();
5512
+ assertNotEquals(deliveryCtx.spanId, workerCtx.spanId);
5513
+ const deliveryLog = records.find((r) => String(r.rawMessage).startsWith("Failed to send activity {activityId} to {inbox} ({status}"));
5514
+ assert(deliveryLog != null);
5515
+ assertEquals(deliveryLog.properties.spanId, deliveryCtx.spanId);
5516
+ assertEquals(deliveryLog.properties.traceId, deliveryCtx.traceId);
5517
+ assertEquals(deliveryLog.properties.messageId, message.id);
5518
+ assertEquals(deliveryLog.properties.batchId, "outer-batch");
5519
+ const retryLog = records.find((r) => String(r.rawMessage).startsWith("Failed to send activity {activityId} to {inbox} (attempt"));
5520
+ assert(retryLog != null);
5521
+ assertEquals(retryLog.properties.spanId, workerCtx.spanId);
5522
+ assertEquals(retryLog.properties.traceId, workerCtx.traceId);
5523
+ assertNotEquals(retryLog.properties.spanId, deliveryCtx.spanId);
5524
+ assertEquals(retryLog.properties.messageId, message.id);
5525
+ assertEquals(retryLog.properties.batchId, "outer-batch");
5526
+ } finally {
5527
+ await reset();
5528
+ esm_default.hardReset();
5529
+ }
5530
+ });
5531
+ });
5439
5532
  test("FederationImpl.processQueuedTask() circuit breaker", async (t) => {
5440
5533
  esm_default.spyGlobal();
5441
5534
  function setup(options, federationOptions = {}, queueOptions = {}) {
@@ -1,6 +1,6 @@
1
1
  const { URLPattern } = require("urlpattern-polyfill");
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const require_federation = require("../federation-BHOSHFCr.cjs");
3
+ const require_federation = require("../federation-CV-CkIIZ.cjs");
4
4
  exports.CircuitBreaker = require_federation.CircuitBreaker;
5
5
  exports.InProcessMessageQueue = require_federation.InProcessMessageQueue;
6
6
  exports.MemoryKvStore = require_federation.MemoryKvStore;
@@ -1,6 +1,6 @@
1
1
  import { Temporal } from "temporal-polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { a as respondWithObjectIfAcceptable, c as digest, d as parseCircuitBreakerKvState, f as createFederationBuilder, i as respondWithObject, l as CircuitBreaker, n as handleWebFinger, o as SendActivityError, r as createExponentialBackoffPolicy, s as buildCollectionSynchronizationHeader, t as createFederation, u as normalizeCircuitBreakerOptions } from "../middleware-vJzuhHEr.js";
3
+ import { a as respondWithObjectIfAcceptable, c as digest, d as parseCircuitBreakerKvState, f as createFederationBuilder, i as respondWithObject, l as CircuitBreaker, n as handleWebFinger, o as SendActivityError, r as createExponentialBackoffPolicy, s as buildCollectionSynchronizationHeader, t as createFederation, u as normalizeCircuitBreakerOptions } from "../middleware-CKEoEiBw.js";
4
4
  import { getLogger } from "@logtape/logtape";
5
5
  import { Router as Router$1, RouterError as RouterError$1, assertPath, isPath } from "@fedify/uri-template";
6
6
  import { isEqual } from "es-toolkit";
@@ -7,12 +7,12 @@ import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
7
7
  import "../std__assert-DvMDRPes.mjs";
8
8
  import { t as assertRejects } from "../assert_rejects-CTptdYck.mjs";
9
9
  import { t as assert } from "../assert-D1Eafmd_.mjs";
10
- import { n as exportJwk } from "../key-CfJ7MJmp.mjs";
11
- import { s as detachSignature } from "../ld-BzvgaYZi.mjs";
12
- import { a as signObject } from "../proof-CImybMS5.mjs";
10
+ import { n as exportJwk } from "../key-DRLFC1um.mjs";
11
+ import { s as detachSignature } from "../ld-BiFf-T9F.mjs";
12
+ import { a as signObject } from "../proof-vlRUtAdS.mjs";
13
13
  import { i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2 } from "../keys-DIJNHW-Y.mjs";
14
- import { C as getEmbeddedFirstGateway, S as getCompactRootId, c as assertPortableActorActivity, n as FederationImpl, o as createFederation, w as warnCompatibleIdsInJson } from "../middleware-BFr_zLaE.mjs";
15
- import { o as verifyCompoundPortableObjectProofs } from "../compound-proof-DML23ZA8.mjs";
14
+ import { C as getEmbeddedFirstGateway, S as getCompactRootId, c as assertPortableActorActivity, n as FederationImpl, o as createFederation, w as warnCompatibleIdsInJson } from "../middleware-BBSxgV0Y.mjs";
15
+ import { o as verifyCompoundPortableObjectProofs } from "../compound-proof-B6xZTnTr.mjs";
16
16
  import { configure, reset } from "@logtape/logtape";
17
17
  import { Accept, Announce, Create, Follow, Note, Person } from "@fedify/vocab";
18
18
  import { exportDidKey, parseIri } from "@fedify/vocab-runtime";
@@ -8,10 +8,10 @@ import { t as assertInstanceOf } from "../assert_instance_of-mrXWWNY-.mjs";
8
8
  import { t as assertThrows } from "../assert_throws-BYITOvPO.mjs";
9
9
  import "../std__assert-DvMDRPes.mjs";
10
10
  import { t as assert } from "../assert-D1Eafmd_.mjs";
11
- import { a as signObject, c as verifyPortableObjectProof } from "../proof-CImybMS5.mjs";
12
- import { f as verifyRequest, l as signRequest } from "../http-DzBwbsDL.mjs";
11
+ import { a as signObject, c as verifyPortableObjectProof } from "../proof-vlRUtAdS.mjs";
12
+ import { f as verifyRequest, l as signRequest } from "../http-BSmcgoaq.mjs";
13
13
  import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2 } from "../keys-DIJNHW-Y.mjs";
14
- import { b as PORTABLE_OBJECT_CONTENT_TYPE, o as createFederation } from "../middleware-BFr_zLaE.mjs";
14
+ import { b as PORTABLE_OBJECT_CONTENT_TYPE, o as createFederation } from "../middleware-BBSxgV0Y.mjs";
15
15
  import { n as RouterError } from "../router-u5O5KCQr.mjs";
16
16
  import { configure, reset } from "@logtape/logtape";
17
17
  import { Note, Person, Tombstone, lookupObject } from "@fedify/vocab";
@@ -7,10 +7,10 @@ import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
7
7
  import { t as assertInstanceOf } from "../assert_instance_of-mrXWWNY-.mjs";
8
8
  import "../std__assert-DvMDRPes.mjs";
9
9
  import { t as assert } from "../assert-D1Eafmd_.mjs";
10
- import { n as exportJwk } from "../key-CfJ7MJmp.mjs";
11
- import { c as verifyPortableObjectProof, s as verifyObject } from "../proof-CImybMS5.mjs";
10
+ import { n as exportJwk } from "../key-DRLFC1um.mjs";
11
+ import { c as verifyPortableObjectProof, s as verifyObject } from "../proof-vlRUtAdS.mjs";
12
12
  import { i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2 } from "../keys-DIJNHW-Y.mjs";
13
- import { n as FederationImpl } from "../middleware-BFr_zLaE.mjs";
13
+ import { n as FederationImpl } from "../middleware-BBSxgV0Y.mjs";
14
14
  import { Create, DataIntegrityProof, Note, OrderedCollection, Person, traverseCollection } from "@fedify/vocab";
15
15
  import { FetchError, encodeMultibase, exportDidKey } from "@fedify/vocab-runtime";
16
16
  import { mockDocumentLoader, test } from "@fedify/fixture";
@@ -7,11 +7,11 @@ import { t as assertFalse } from "../assert_false-CPdRnc3E.mjs";
7
7
  import { t as assertThrows } from "../assert_throws-BYITOvPO.mjs";
8
8
  import "../std__assert-DvMDRPes.mjs";
9
9
  import { t as assert } from "../assert-D1Eafmd_.mjs";
10
- import { a as signObject, c as verifyPortableObjectProof } from "../proof-CImybMS5.mjs";
10
+ import { a as signObject, c as verifyPortableObjectProof } from "../proof-vlRUtAdS.mjs";
11
11
  import { n as ed25519PrivateKey, r as ed25519PublicKey } from "../keys-DIJNHW-Y.mjs";
12
- import { b as PORTABLE_OBJECT_CONTENT_TYPE, o as createFederation } from "../middleware-BFr_zLaE.mjs";
13
- import { t as verifyPortableObject } from "../portable-collection-DBAMRYNa.mjs";
14
- import { c as verifyServedPortableObjects } from "../compound-proof-DML23ZA8.mjs";
12
+ import { b as PORTABLE_OBJECT_CONTENT_TYPE, o as createFederation } from "../middleware-BBSxgV0Y.mjs";
13
+ import { t as verifyPortableObject } from "../portable-collection-BiBpObws.mjs";
14
+ import { c as verifyServedPortableObjects } from "../compound-proof-B6xZTnTr.mjs";
15
15
  import { n as RouterError } from "../router-u5O5KCQr.mjs";
16
16
  import { configure, reset } from "@logtape/logtape";
17
17
  import { Create, Note, Object as Object$1, OrderedCollection, PUBLIC_COLLECTION, Person, Tombstone, lookupObject, traverseCollection } from "@fedify/vocab";
@@ -4,8 +4,8 @@ globalThis.addEventListener = () => {};
4
4
  import { t as esm_default } from "../esm-BHXXx4Wx.mjs";
5
5
  import { t as MemoryKvStore } from "../kv-DCHkaJ9-.mjs";
6
6
  import { i as rsaPrivateKey2, s as rsaPublicKey2 } from "../keys-DIJNHW-Y.mjs";
7
- import { n as FederationImpl, r as InboxContextImpl } from "../middleware-BFr_zLaE.mjs";
8
- import { n as extractInboxes, t as SendActivityError } from "../send-oReIfAwd.mjs";
7
+ import { n as FederationImpl, r as InboxContextImpl } from "../middleware-BBSxgV0Y.mjs";
8
+ import { n as extractInboxes, t as SendActivityError } from "../send-D5aMlvJH.mjs";
9
9
  import { Create, Endpoints, Note, Person } from "@fedify/vocab";
10
10
  import { parseIri } from "@fedify/vocab-runtime";
11
11
  import { mockDocumentLoader, test } from "@fedify/fixture";
@@ -8,11 +8,11 @@ import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
8
8
  import "../std__assert-DvMDRPes.mjs";
9
9
  import { t as assertRejects } from "../assert_rejects-CTptdYck.mjs";
10
10
  import { r as getVerifiedKeyOwnerEvidence } from "../key-owner-evidence-APB6NpSk.mjs";
11
- import { p as signJsonLd } from "../ld-BzvgaYZi.mjs";
12
- import { f as verifyRequest, l as signRequest, p as verifyRequestDetailed } from "../http-DzBwbsDL.mjs";
11
+ import { p as signJsonLd } from "../ld-BiFf-T9F.mjs";
12
+ import { f as verifyRequest, l as signRequest, p as verifyRequestDetailed } from "../http-BSmcgoaq.mjs";
13
13
  import { a as rsaPrivateKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2 } from "../keys-DIJNHW-Y.mjs";
14
- import { f as handleInbox, n as FederationImpl, o as createFederation } from "../middleware-BFr_zLaE.mjs";
15
- import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-CGXm_YAa.mjs";
14
+ import { f as handleInbox, n as FederationImpl, o as createFederation } from "../middleware-BBSxgV0Y.mjs";
15
+ import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-BsgoTcNb.mjs";
16
16
  import { t as ActivityListenerSet } from "../activity-listener-C-BSbKI7.mjs";
17
17
  import { t as KvKeyCache } from "../keycache-D-MNltOk.mjs";
18
18
  import { Create, CryptographicKey, Person } from "@fedify/vocab";
@@ -8,11 +8,11 @@ import { t as assertFalse } from "../assert_false-CPdRnc3E.mjs";
8
8
  import { t as assertThrows } from "../assert_throws-BYITOvPO.mjs";
9
9
  import "../std__assert-DvMDRPes.mjs";
10
10
  import { t as assert } from "../assert-D1Eafmd_.mjs";
11
- import { p as signJsonLd } from "../ld-BzvgaYZi.mjs";
12
- import { a as signObject } from "../proof-CImybMS5.mjs";
13
- import { l as signRequest, p as verifyRequestDetailed } from "../http-DzBwbsDL.mjs";
11
+ import { p as signJsonLd } from "../ld-BiFf-T9F.mjs";
12
+ import { a as signObject } from "../proof-vlRUtAdS.mjs";
13
+ import { l as signRequest, p as verifyRequestDetailed } from "../http-BSmcgoaq.mjs";
14
14
  import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2 } from "../keys-DIJNHW-Y.mjs";
15
- import { _ as coversDelivery, o as createFederation, v as forwardPortableInboxActivity, y as resolvePortableInboxForwardingOptions } from "../middleware-BFr_zLaE.mjs";
15
+ import { _ as coversDelivery, o as createFederation, v as forwardPortableInboxActivity, y as resolvePortableInboxForwardingOptions } from "../middleware-BBSxgV0Y.mjs";
16
16
  import { Create, CryptographicKey, Follow, Note, Person, Tombstone } from "@fedify/vocab";
17
17
  import { exportDidKey, formatIri, parseIri } from "@fedify/vocab-runtime";
18
18
  import { mockDocumentLoader, test } from "@fedify/fixture";
@@ -7,7 +7,7 @@ import { t as assertFalse } from "../assert_false-CPdRnc3E.mjs";
7
7
  import "../std__assert-DvMDRPes.mjs";
8
8
  import { t as assert } from "../assert-D1Eafmd_.mjs";
9
9
  import { r as ed25519PublicKey } from "../keys-DIJNHW-Y.mjs";
10
- import { o as createFederation } from "../middleware-BFr_zLaE.mjs";
10
+ import { o as createFederation } from "../middleware-BBSxgV0Y.mjs";
11
11
  import { Note, Object as Object$1, Person } from "@fedify/vocab";
12
12
  import { exportDidKey, parseIri } from "@fedify/vocab-runtime";
13
13
  import { test } from "@fedify/fixture";
@@ -6,9 +6,9 @@ import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
6
6
  import { t as assertFalse } from "../assert_false-CPdRnc3E.mjs";
7
7
  import "../std__assert-DvMDRPes.mjs";
8
8
  import { t as assert } from "../assert-D1Eafmd_.mjs";
9
- import { a as signObject } from "../proof-CImybMS5.mjs";
9
+ import { a as signObject } from "../proof-vlRUtAdS.mjs";
10
10
  import { n as ed25519PrivateKey, r as ed25519PublicKey } from "../keys-DIJNHW-Y.mjs";
11
- import { o as createFederation } from "../middleware-BFr_zLaE.mjs";
11
+ import { o as createFederation } from "../middleware-BBSxgV0Y.mjs";
12
12
  import { Create, Note } from "@fedify/vocab";
13
13
  import { exportDidKey, formatIri, parseIri, toCompatibleEf61Id } from "@fedify/vocab-runtime";
14
14
  import { mockDocumentLoader, test } from "@fedify/fixture";
@@ -8,10 +8,10 @@ import { t as assertThrows } from "../assert_throws-BYITOvPO.mjs";
8
8
  import "../std__assert-DvMDRPes.mjs";
9
9
  import { t as assertStrictEquals } from "../assert_strict_equals-CYvBmkpC.mjs";
10
10
  import { t as assert } from "../assert-D1Eafmd_.mjs";
11
- import { a as signObject, c as verifyPortableObjectProof } from "../proof-CImybMS5.mjs";
12
- import { l as signRequest } from "../http-DzBwbsDL.mjs";
11
+ import { a as signObject, c as verifyPortableObjectProof } from "../proof-vlRUtAdS.mjs";
12
+ import { l as signRequest } from "../http-BSmcgoaq.mjs";
13
13
  import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2 } from "../keys-DIJNHW-Y.mjs";
14
- import { b as PORTABLE_OBJECT_CONTENT_TYPE, o as createFederation } from "../middleware-BFr_zLaE.mjs";
14
+ import { b as PORTABLE_OBJECT_CONTENT_TYPE, o as createFederation } from "../middleware-BBSxgV0Y.mjs";
15
15
  import { configure, reset } from "@logtape/logtape";
16
16
  import { Collection, Create, Note, Object as Object$1, PUBLIC_COLLECTION, Person, Tombstone, lookupObject } from "@fedify/vocab";
17
17
  import { exportDidKey, formatIri, parseIri, toCompatibleEf61Id } from "@fedify/vocab-runtime";
@@ -2,6 +2,7 @@ import "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as esm_default } from "../esm-BHXXx4Wx.mjs";
5
+ import { t as MemoryKvStore } from "../kv-DCHkaJ9-.mjs";
5
6
  import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
6
7
  import { t as assertFalse } from "../assert_false-CPdRnc3E.mjs";
7
8
  import { t as assertGreaterOrEqual } from "../assert_greater_or_equal-BlafOF4-.mjs";
@@ -10,15 +11,18 @@ import { t as assertNotEquals } from "../assert_not_equals-CpPK2t89.mjs";
10
11
  import "../std__assert-DvMDRPes.mjs";
11
12
  import { t as assertRejects } from "../assert_rejects-CTptdYck.mjs";
12
13
  import { t as assert } from "../assert-D1Eafmd_.mjs";
13
- import { f as verifyRequest } from "../http-DzBwbsDL.mjs";
14
+ import { f as verifyRequest } from "../http-BSmcgoaq.mjs";
14
15
  import { i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DIJNHW-Y.mjs";
15
- import { t as doesActorOwnKey } from "../owner-CGXm_YAa.mjs";
16
- import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-oReIfAwd.mjs";
16
+ import { t as doesActorOwnKey } from "../owner-BsgoTcNb.mjs";
17
+ import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-D5aMlvJH.mjs";
18
+ import { t as FedifySpanExporter } from "../exporter-DThFfe7P.mjs";
19
+ import { configure, getLogger, reset, withContext } from "@logtape/logtape";
17
20
  import { Activity, Application, Endpoints, Group, Person, Service } from "@fedify/vocab";
18
21
  import { FetchError, UrlError } from "@fedify/vocab-runtime";
19
22
  import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
20
23
  import dns from "node:dns/promises";
21
24
  import { AggregationTemporality, InMemoryMetricExporter, MeterProvider, PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
25
+ import { AsyncLocalStorage } from "node:async_hooks";
22
26
  //#region src/federation/send.test.ts
23
27
  test("extractInboxes()", () => {
24
28
  const recipients = [
@@ -451,6 +455,198 @@ test("sendActivity() records OpenTelemetry span events", async (t) => {
451
455
  esm_default.hardReset();
452
456
  });
453
457
  });
458
+ function createActivity(id) {
459
+ return {
460
+ "@context": "https://www.w3.org/ns/activitystreams",
461
+ type: "Create",
462
+ id,
463
+ actor: "https://example.com/person"
464
+ };
465
+ }
466
+ function deliveryParams(activityId, inbox, tracerProvider) {
467
+ return {
468
+ activity: createActivity(activityId),
469
+ activityId,
470
+ activityType: "https://www.w3.org/ns/activitystreams#Create",
471
+ keys: [{
472
+ keyId: new URL("https://example.com/person#key"),
473
+ privateKey: rsaPrivateKey2
474
+ }],
475
+ inbox: new URL(inbox),
476
+ tracerProvider
477
+ };
478
+ }
479
+ test("sendActivity() aligns the LogTape context with its own span", async (t) => {
480
+ const [tracerProvider, exporter] = createTestTracerProvider();
481
+ esm_default.spyGlobal();
482
+ const records = [];
483
+ await reset();
484
+ try {
485
+ await configure({
486
+ sinks: { buffer: (record) => records.push(record) },
487
+ filters: {},
488
+ loggers: [{
489
+ category: [],
490
+ sinks: ["buffer"],
491
+ lowestLevel: "debug"
492
+ }, {
493
+ category: ["logtape", "meta"],
494
+ sinks: []
495
+ }],
496
+ contextLocalStorage: new AsyncLocalStorage()
497
+ });
498
+ const outerContext = {
499
+ requestId: "outer-request",
500
+ traceId: "outer0000000000000000000000sentinel",
501
+ spanId: "outer00000sentinel"
502
+ };
503
+ await t.step("a warning logged during a successful send matches the resulting TraceActivityRecord", async () => {
504
+ try {
505
+ esm_default.post("https://example.com/inbox-warn", { status: 202 });
506
+ await withContext({ requestId: "outer-request-warn" }, async () => {
507
+ await sendActivity({
508
+ ...deliveryParams("https://example.com/activity/warn", "https://example.com/inbox-warn", tracerProvider),
509
+ keys: [{
510
+ keyId: ed25519Multikey.id,
511
+ privateKey: ed25519PrivateKey
512
+ }]
513
+ });
514
+ });
515
+ const span = exporter.getSpan("activitypub.send_activity");
516
+ assert(span != null);
517
+ const { traceId, spanId } = span.spanContext();
518
+ const fedifyExporter = new FedifySpanExporter(new MemoryKvStore());
519
+ await new Promise((resolve) => {
520
+ fedifyExporter.export([span], () => resolve());
521
+ });
522
+ const [record] = await fedifyExporter.getActivitiesByTraceId(traceId);
523
+ assert(record != null);
524
+ assertEquals(record.direction, "outbound");
525
+ assertEquals(record.spanId, spanId);
526
+ const warnLog = records.find((r) => String(r.rawMessage).startsWith("No supported key found to sign"));
527
+ assert(warnLog != null);
528
+ assertEquals(warnLog.properties.spanId, record.spanId);
529
+ assertEquals(warnLog.properties.traceId, record.traceId);
530
+ assertEquals(warnLog.properties.requestId, "outer-request-warn");
531
+ } finally {
532
+ exporter.clear();
533
+ records.length = 0;
534
+ esm_default.hardReset();
535
+ esm_default.spyGlobal();
536
+ }
537
+ });
538
+ await t.step("a failed delivery's error log matches its own span, and the outer context is restored once the rejection propagates", async () => {
539
+ try {
540
+ esm_default.post("https://example.com/inbox-failing", {
541
+ status: 500,
542
+ body: "Internal Server Error"
543
+ });
544
+ await withContext(outerContext, async () => {
545
+ await assertRejects(() => sendActivity(deliveryParams("https://example.com/activity/failing", "https://example.com/inbox-failing", tracerProvider)), SendActivityError);
546
+ getLogger([
547
+ "fedify",
548
+ "federation",
549
+ "send.test"
550
+ ]).info("after failure");
551
+ });
552
+ const span = exporter.getSpan("activitypub.send_activity");
553
+ assert(span != null);
554
+ const { traceId, spanId } = span.spanContext();
555
+ const fedifyExporter = new FedifySpanExporter(new MemoryKvStore());
556
+ await new Promise((resolve) => {
557
+ fedifyExporter.export([span], () => resolve());
558
+ });
559
+ assertEquals(await fedifyExporter.getActivitiesByTraceId(traceId), []);
560
+ const failureLog = records.find((r) => String(r.rawMessage).startsWith("Failed to send activity {activityId} to {inbox} ({status}"));
561
+ assert(failureLog != null);
562
+ assertEquals(failureLog.properties.spanId, spanId);
563
+ assertEquals(failureLog.properties.traceId, traceId);
564
+ assertEquals(failureLog.properties.requestId, outerContext.requestId);
565
+ const afterLog = records.find((r) => r.rawMessage === "after failure");
566
+ assert(afterLog != null);
567
+ assertEquals(afterLog.properties.requestId, outerContext.requestId);
568
+ assertEquals(afterLog.properties.traceId, outerContext.traceId);
569
+ assertEquals(afterLog.properties.spanId, outerContext.spanId);
570
+ } finally {
571
+ exporter.clear();
572
+ records.length = 0;
573
+ esm_default.hardReset();
574
+ esm_default.spyGlobal();
575
+ }
576
+ });
577
+ await t.step("outer context is restored after a successful send", async () => {
578
+ try {
579
+ esm_default.post("https://example.com/inbox-ok", { status: 202 });
580
+ await withContext(outerContext, async () => {
581
+ await sendActivity(deliveryParams("https://example.com/activity/ok", "https://example.com/inbox-ok", tracerProvider));
582
+ getLogger([
583
+ "fedify",
584
+ "federation",
585
+ "send.test"
586
+ ]).info("after success");
587
+ });
588
+ const span = exporter.getSpan("activitypub.send_activity");
589
+ assert(span != null);
590
+ const { spanId } = span.spanContext();
591
+ const afterLog = records.find((r) => r.rawMessage === "after success");
592
+ assert(afterLog != null);
593
+ assertNotEquals(afterLog.properties.spanId, spanId);
594
+ assertEquals(afterLog.properties.requestId, outerContext.requestId);
595
+ assertEquals(afterLog.properties.traceId, outerContext.traceId);
596
+ assertEquals(afterLog.properties.spanId, outerContext.spanId);
597
+ } finally {
598
+ exporter.clear();
599
+ records.length = 0;
600
+ esm_default.hardReset();
601
+ esm_default.spyGlobal();
602
+ }
603
+ });
604
+ await t.step("concurrent deliveries do not leak context into each other", async () => {
605
+ try {
606
+ let arrived = 0;
607
+ let release = () => {};
608
+ const gate = new Promise((resolve) => {
609
+ release = resolve;
610
+ });
611
+ const handler = () => async () => {
612
+ arrived++;
613
+ if (arrived >= 2) release();
614
+ await gate;
615
+ return {
616
+ status: 500,
617
+ body: "Internal Server Error"
618
+ };
619
+ };
620
+ esm_default.post("https://example.com/inbox-concurrent-a", handler());
621
+ esm_default.post("https://example.com/inbox-concurrent-b", handler());
622
+ const [resultA, resultB] = await Promise.allSettled([sendActivity(deliveryParams("https://example.com/activity/a", "https://example.com/inbox-concurrent-a", tracerProvider)).finally(release), sendActivity(deliveryParams("https://example.com/activity/b", "https://example.com/inbox-concurrent-b", tracerProvider)).finally(release)]);
623
+ assertEquals(resultA.status, "rejected");
624
+ assertEquals(resultB.status, "rejected");
625
+ const spans = exporter.getSpans("activitypub.send_activity");
626
+ assertEquals(spans.length, 2);
627
+ const spanA = spans.find((s) => s.attributes["activitypub.activity.id"] === "https://example.com/activity/a");
628
+ const spanB = spans.find((s) => s.attributes["activitypub.activity.id"] === "https://example.com/activity/b");
629
+ assert(spanA != null && spanB != null);
630
+ assertNotEquals(spanA.spanContext().spanId, spanB.spanContext().spanId);
631
+ const logA = records.find((r) => r.properties.activityId === "https://example.com/activity/a" && String(r.rawMessage).startsWith("Failed to send activity"));
632
+ const logB = records.find((r) => r.properties.activityId === "https://example.com/activity/b" && String(r.rawMessage).startsWith("Failed to send activity"));
633
+ assert(logA != null && logB != null);
634
+ assertEquals(logA.properties.spanId, spanA.spanContext().spanId);
635
+ assertEquals(logB.properties.spanId, spanB.spanContext().spanId);
636
+ assertEquals(logA.properties.traceId, spanA.spanContext().traceId);
637
+ assertEquals(logB.properties.traceId, spanB.spanContext().traceId);
638
+ assertNotEquals(logA.properties.spanId, logB.properties.spanId);
639
+ } finally {
640
+ exporter.clear();
641
+ records.length = 0;
642
+ esm_default.hardReset();
643
+ }
644
+ });
645
+ } finally {
646
+ await reset();
647
+ esm_default.hardReset();
648
+ }
649
+ });
454
650
  test("sendActivity() records OpenTelemetry delivery metrics", async (t) => {
455
651
  const [meterProvider, recorder] = createTestMeterProvider();
456
652
  esm_default.spyGlobal();
@@ -4,7 +4,7 @@ globalThis.addEventListener = () => {};
4
4
  import { t as MemoryKvStore } from "../../kv-DCHkaJ9-.mjs";
5
5
  import { a as numberSchema, i as makeSchema, n as baseOptions, o as stringSchema, t as MockQueue } from "../../tasks-IG3pHfvZ.mjs";
6
6
  import "../../testing-t8xDeJZ5.mjs";
7
- import { o as createFederation } from "../../middleware-BFr_zLaE.mjs";
7
+ import { o as createFederation } from "../../middleware-BBSxgV0Y.mjs";
8
8
  import { n as ParallelMessageQueue } from "../../mq-Dm1Wmtm-.mjs";
9
9
  import { configure, reset } from "@logtape/logtape";
10
10
  import { delay } from "es-toolkit";
@@ -4,8 +4,8 @@ globalThis.addEventListener = () => {};
4
4
  import { t as MemoryKvStore } from "../../kv-DCHkaJ9-.mjs";
5
5
  import { a as numberSchema, i as makeSchema, n as baseOptions, o as stringSchema, t as MockQueue } from "../../tasks-IG3pHfvZ.mjs";
6
6
  import "../../testing-t8xDeJZ5.mjs";
7
- import { o as createFederation } from "../../middleware-BFr_zLaE.mjs";
8
- import { r as createFederationBuilder } from "../../builder-D1OTD3--.mjs";
7
+ import { o as createFederation } from "../../middleware-BBSxgV0Y.mjs";
8
+ import { r as createFederationBuilder } from "../../builder-4z5McYcY.mjs";
9
9
  import { t as TaskCodec } from "../../codec-C6rTrpIp.mjs";
10
10
  import { t as InProcessMessageQueue } from "../../mq-Dm1Wmtm-.mjs";
11
11
  import { W3CTraceContextPropagator } from "@opentelemetry/core";
@@ -4,7 +4,7 @@ globalThis.addEventListener = () => {};
4
4
  import { t as assertFalse } from "../assert_false-CPdRnc3E.mjs";
5
5
  import "../std__assert-DvMDRPes.mjs";
6
6
  import { t as assert } from "../assert-D1Eafmd_.mjs";
7
- import { t as hasMalformedKnownTemporalLiteral } from "../temporal-DLaPDeOv.mjs";
7
+ import { t as hasMalformedKnownTemporalLiteral } from "../temporal-BE3xoktR.mjs";
8
8
  import { test } from "@fedify/fixture";
9
9
  //#region src/federation/temporal.test.ts
10
10
  test("hasMalformedKnownTemporalLiteral() detects expanded proof timestamps", async () => {
@@ -6,7 +6,7 @@ import { t as MemoryKvStore } from "../kv-DCHkaJ9-.mjs";
6
6
  import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
7
7
  import { t as assertNotEquals } from "../assert_not_equals-CpPK2t89.mjs";
8
8
  import "../std__assert-DvMDRPes.mjs";
9
- import { o as createFederation, s as handleWebFinger } from "../middleware-BFr_zLaE.mjs";
9
+ import { o as createFederation, s as handleWebFinger } from "../middleware-BBSxgV0Y.mjs";
10
10
  import { Image, Link, Person, Tombstone } from "@fedify/vocab";
11
11
  import { parseIri } from "@fedify/vocab-runtime";
12
12
  import { createTestMeterProvider, test } from "@fedify/fixture";