@fedify/fedify 2.0.0-dev.335 → 2.0.0-dev.372

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 (48) hide show
  1. package/README.md +8 -0
  2. package/dist/{builder-RHW0dkbP.js → builder-BxlBAtuD.js} +3 -3
  3. package/dist/compat/transformers.test.js +11 -11
  4. package/dist/{deno-Dhe5E7NK.js → deno-CDo9j5Hk.js} +1 -4
  5. package/dist/{docloader-D6VuU143.js → docloader-Cl-iMQFP.js} +2 -2
  6. package/dist/federation/builder.test.js +3 -3
  7. package/dist/federation/handler.test.js +11 -11
  8. package/dist/federation/idempotency.test.js +11 -11
  9. package/dist/federation/inbox.test.js +2 -2
  10. package/dist/federation/middleware.test.js +11 -11
  11. package/dist/federation/mod.cjs +4 -4
  12. package/dist/federation/mod.js +4 -4
  13. package/dist/federation/send.test.js +5 -5
  14. package/dist/federation/webfinger.test.js +11 -11
  15. package/dist/{http-ChlQCtql.cjs → http-B8cUSIVv.cjs} +1 -4
  16. package/dist/{http-CSqVEUdE.js → http-BQhAaO-e.js} +2 -2
  17. package/dist/{http-DZrrJD77.js → http-C_qj3I7F.js} +1 -4
  18. package/dist/{inbox-9F91oWJU.js → inbox-B4kgSsVH.js} +1 -1
  19. package/dist/{key-DFPkYar3.js → key-DtVs0UwP.js} +1 -1
  20. package/dist/{kv-cache-1TNWtgx7.js → kv-cache-CibadbOC.js} +1 -1
  21. package/dist/{kv-cache-DwcKE9EQ.cjs → kv-cache-CkfpyCN5.cjs} +1 -1
  22. package/dist/{ld-kAhyoO55.js → ld-BLHZlaWL.js} +2 -2
  23. package/dist/{middleware-BgurYNZ4.js → middleware-BDQ8PDFx.js} +4 -4
  24. package/dist/{middleware-DebYvXJs.js → middleware-BQigFVlt.js} +11 -11
  25. package/dist/{middleware-zvH5O0zk.js → middleware-C5W9b9D9.js} +119 -92
  26. package/dist/{middleware-DQriD-Kq.js → middleware-CEcrmJf2.js} +113 -86
  27. package/dist/middleware-COrE1spG.cjs +12 -0
  28. package/dist/{middleware-CULfPNt-.cjs → middleware-DfAuhaf7.cjs} +113 -86
  29. package/dist/mod.cjs +4 -4
  30. package/dist/mod.js +4 -4
  31. package/dist/nodeinfo/handler.test.js +11 -11
  32. package/dist/{owner-DcyH0sQg.js → owner-BwS4q7BU.js} +1 -1
  33. package/dist/{proof-JtZEQaKw.js → proof-Cq8LNpQ3.js} +1 -1
  34. package/dist/{proof-_Rz8hNBt.cjs → proof-EVy7shg_.cjs} +1 -1
  35. package/dist/{proof-D7C8ouBO.js → proof-N5F9c402.js} +2 -2
  36. package/dist/{send-mAsnzegg.js → send-DpOe6hgL.js} +2 -2
  37. package/dist/sig/http.test.js +3 -3
  38. package/dist/sig/key.test.js +2 -2
  39. package/dist/sig/ld.test.js +3 -3
  40. package/dist/sig/mod.cjs +2 -2
  41. package/dist/sig/mod.js +2 -2
  42. package/dist/sig/owner.test.js +3 -3
  43. package/dist/sig/proof.test.js +3 -3
  44. package/dist/utils/docloader.test.js +4 -4
  45. package/dist/utils/mod.cjs +2 -2
  46. package/dist/utils/mod.js +2 -2
  47. package/package.json +8 -8
  48. package/dist/middleware-ChlsNVu2.cjs +0 -12
@@ -3,24 +3,24 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { deno_default } from "./deno-Dhe5E7NK.js";
6
+ import { deno_default } from "./deno-CDo9j5Hk.js";
7
7
  import { getNodeInfo } from "./client-Dg7OfUDA.js";
8
8
  import { RouterError } from "./router-D9eI0s4b.js";
9
9
  import { nodeInfoToJson } from "./types-CPz01LGH.js";
10
- import { exportJwk, importJwk, validateCryptoKey } from "./key-DFPkYar3.js";
11
- import { verifyRequest } from "./http-CSqVEUdE.js";
12
- import { detachSignature, hasSignature, signJsonLd, verifyJsonLd } from "./ld-kAhyoO55.js";
13
- import { doesActorOwnKey, getKeyOwner } from "./owner-DcyH0sQg.js";
14
- import { signObject, verifyObject } from "./proof-D7C8ouBO.js";
15
- import { getAuthenticatedDocumentLoader } from "./docloader-D6VuU143.js";
10
+ import { exportJwk, importJwk, validateCryptoKey } from "./key-DtVs0UwP.js";
11
+ import { verifyRequest } from "./http-BQhAaO-e.js";
12
+ import { detachSignature, hasSignature, signJsonLd, verifyJsonLd } from "./ld-BLHZlaWL.js";
13
+ import { doesActorOwnKey, getKeyOwner } from "./owner-BwS4q7BU.js";
14
+ import { signObject, verifyObject } from "./proof-N5F9c402.js";
15
+ import { getAuthenticatedDocumentLoader } from "./docloader-Cl-iMQFP.js";
16
16
  import { kvCache } from "./kv-cache-B__dHl7g.js";
17
- import { routeActivity } from "./inbox-9F91oWJU.js";
18
- import { FederationBuilderImpl } from "./builder-RHW0dkbP.js";
17
+ import { routeActivity } from "./inbox-B4kgSsVH.js";
18
+ import { FederationBuilderImpl } from "./builder-BxlBAtuD.js";
19
19
  import { buildCollectionSynchronizationHeader } from "./collection-CcnIw1qY.js";
20
20
  import { KvKeyCache } from "./keycache-DRxpZ5r9.js";
21
21
  import { acceptsJsonLd } from "./negotiation-5NPJL6zp.js";
22
22
  import { createExponentialBackoffPolicy } from "./retry-D4GJ670a.js";
23
- import { SendActivityError, extractInboxes, sendActivity } from "./send-mAsnzegg.js";
23
+ import { SendActivityError, extractInboxes, sendActivity } from "./send-DpOe6hgL.js";
24
24
  import { getLogger, withContext } from "@logtape/logtape";
25
25
  import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, getTypeId, lookupObject, traverseCollection } from "@fedify/vocab";
26
26
  import { getDocumentLoader } from "@fedify/vocab-runtime";
@@ -1313,7 +1313,7 @@ var FederationImpl = class extends FederationBuilderImpl {
1313
1313
  outboxRetryPolicy;
1314
1314
  inboxRetryPolicy;
1315
1315
  activityTransformers;
1316
- tracerProvider;
1316
+ _tracerProvider;
1317
1317
  firstKnock;
1318
1318
  constructor(options) {
1319
1319
  super();
@@ -1395,9 +1395,12 @@ var FederationImpl = class extends FederationBuilderImpl {
1395
1395
  this.outboxRetryPolicy = options.outboxRetryPolicy ?? createExponentialBackoffPolicy();
1396
1396
  this.inboxRetryPolicy = options.inboxRetryPolicy ?? createExponentialBackoffPolicy();
1397
1397
  this.activityTransformers = options.activityTransformers ?? getDefaultActivityTransformers();
1398
- this.tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
1398
+ this._tracerProvider = options.tracerProvider;
1399
1399
  this.firstKnock = options.firstKnock;
1400
1400
  }
1401
+ get tracerProvider() {
1402
+ return this._tracerProvider ?? trace.getTracerProvider();
1403
+ }
1401
1404
  _initializeRouter() {
1402
1405
  this.router.add("/.well-known/webfinger", "webfinger");
1403
1406
  this.router.add("/.well-known/nodeinfo", "nodeInfoJrd");
@@ -1438,18 +1441,24 @@ var FederationImpl = class extends FederationBuilderImpl {
1438
1441
  kind: SpanKind.CONSUMER,
1439
1442
  attributes: { "activitypub.activity.type": message.activityType }
1440
1443
  }, extractedContext, async (span) => {
1441
- if (message.activityId != null) span.setAttribute("activitypub.activity.id", message.activityId);
1442
- try {
1443
- await this.#listenFanoutMessage(contextData, message);
1444
- } catch (e) {
1445
- span.setStatus({
1446
- code: SpanStatusCode.ERROR,
1447
- message: String(e)
1448
- });
1449
- throw e;
1450
- } finally {
1451
- span.end();
1452
- }
1444
+ const spanCtx = span.spanContext();
1445
+ return await withContext({
1446
+ traceId: spanCtx.traceId,
1447
+ spanId: spanCtx.spanId
1448
+ }, async () => {
1449
+ if (message.activityId != null) span.setAttribute("activitypub.activity.id", message.activityId);
1450
+ try {
1451
+ await this.#listenFanoutMessage(contextData, message);
1452
+ } catch (e) {
1453
+ span.setStatus({
1454
+ code: SpanStatusCode.ERROR,
1455
+ message: String(e)
1456
+ });
1457
+ throw e;
1458
+ } finally {
1459
+ span.end();
1460
+ }
1461
+ });
1453
1462
  });
1454
1463
  else if (message.type === "outbox") await tracer.startActiveSpan("activitypub.outbox", {
1455
1464
  kind: SpanKind.CONSUMER,
@@ -1458,34 +1467,46 @@ var FederationImpl = class extends FederationBuilderImpl {
1458
1467
  "activitypub.activity.retries": message.attempt
1459
1468
  }
1460
1469
  }, extractedContext, async (span) => {
1461
- if (message.activityId != null) span.setAttribute("activitypub.activity.id", message.activityId);
1462
- try {
1463
- await this.#listenOutboxMessage(contextData, message, span);
1464
- } catch (e) {
1465
- span.setStatus({
1466
- code: SpanStatusCode.ERROR,
1467
- message: String(e)
1468
- });
1469
- throw e;
1470
- } finally {
1471
- span.end();
1472
- }
1470
+ const spanCtx = span.spanContext();
1471
+ return await withContext({
1472
+ traceId: spanCtx.traceId,
1473
+ spanId: spanCtx.spanId
1474
+ }, async () => {
1475
+ if (message.activityId != null) span.setAttribute("activitypub.activity.id", message.activityId);
1476
+ try {
1477
+ await this.#listenOutboxMessage(contextData, message, span);
1478
+ } catch (e) {
1479
+ span.setStatus({
1480
+ code: SpanStatusCode.ERROR,
1481
+ message: String(e)
1482
+ });
1483
+ throw e;
1484
+ } finally {
1485
+ span.end();
1486
+ }
1487
+ });
1473
1488
  });
1474
1489
  else if (message.type === "inbox") await tracer.startActiveSpan("activitypub.inbox", {
1475
1490
  kind: SpanKind.CONSUMER,
1476
1491
  attributes: { "activitypub.shared_inbox": message.identifier == null }
1477
1492
  }, extractedContext, async (span) => {
1478
- try {
1479
- await this.#listenInboxMessage(contextData, message, span);
1480
- } catch (e) {
1481
- span.setStatus({
1482
- code: SpanStatusCode.ERROR,
1483
- message: String(e)
1484
- });
1485
- throw e;
1486
- } finally {
1487
- span.end();
1488
- }
1493
+ const spanCtx = span.spanContext();
1494
+ return await withContext({
1495
+ traceId: spanCtx.traceId,
1496
+ spanId: spanCtx.spanId
1497
+ }, async () => {
1498
+ try {
1499
+ await this.#listenInboxMessage(contextData, message, span);
1500
+ } catch (e) {
1501
+ span.setStatus({
1502
+ code: SpanStatusCode.ERROR,
1503
+ message: String(e)
1504
+ });
1505
+ throw e;
1506
+ } finally {
1507
+ span.end();
1508
+ }
1509
+ });
1489
1510
  });
1490
1511
  });
1491
1512
  }
@@ -1958,54 +1979,60 @@ var FederationImpl = class extends FederationBuilderImpl {
1958
1979
  [ATTR_URL_FULL]: request.url
1959
1980
  }
1960
1981
  }, async (span) => {
1961
- const logger$2 = getLogger([
1962
- "fedify",
1963
- "federation",
1964
- "http"
1965
- ]);
1966
- if (span.isRecording()) for (const [k, v] of request.headers) span.setAttribute(ATTR_HTTP_REQUEST_HEADER(k), [v]);
1967
- let response;
1968
- try {
1969
- response = await this.#fetch(request, {
1970
- ...options,
1971
- span,
1972
- tracer
1973
- });
1974
- if (acceptsJsonLd(request)) response.headers.set("Vary", "Accept");
1975
- } catch (error) {
1976
- span.setStatus({
1977
- code: SpanStatusCode.ERROR,
1978
- message: `${error}`
1979
- });
1982
+ const spanCtx = span.spanContext();
1983
+ return await withContext({
1984
+ traceId: spanCtx.traceId,
1985
+ spanId: spanCtx.spanId
1986
+ }, async () => {
1987
+ const logger$2 = getLogger([
1988
+ "fedify",
1989
+ "federation",
1990
+ "http"
1991
+ ]);
1992
+ if (span.isRecording()) for (const [k, v] of request.headers) span.setAttribute(ATTR_HTTP_REQUEST_HEADER(k), [v]);
1993
+ let response;
1994
+ try {
1995
+ response = await this.#fetch(request, {
1996
+ ...options,
1997
+ span,
1998
+ tracer
1999
+ });
2000
+ if (acceptsJsonLd(request)) response.headers.set("Vary", "Accept");
2001
+ } catch (error) {
2002
+ span.setStatus({
2003
+ code: SpanStatusCode.ERROR,
2004
+ message: `${error}`
2005
+ });
2006
+ span.end();
2007
+ logger$2.error("An error occurred while serving request {method} {url}: {error}", {
2008
+ method: request.method,
2009
+ url: request.url,
2010
+ error
2011
+ });
2012
+ throw error;
2013
+ }
2014
+ if (span.isRecording()) {
2015
+ span.setAttribute(ATTR_HTTP_RESPONSE_STATUS_CODE, response.status);
2016
+ for (const [k, v] of response.headers) span.setAttribute(ATTR_HTTP_RESPONSE_HEADER(k), [v]);
2017
+ span.setStatus({
2018
+ code: response.status >= 500 ? SpanStatusCode.ERROR : SpanStatusCode.UNSET,
2019
+ message: response.statusText
2020
+ });
2021
+ }
1980
2022
  span.end();
1981
- logger$2.error("An error occurred while serving request {method} {url}: {error}", {
2023
+ const url = new URL(request.url);
2024
+ const logTpl = "{method} {path}: {status}";
2025
+ const values = {
1982
2026
  method: request.method,
2027
+ path: `${url.pathname}${url.search}`,
1983
2028
  url: request.url,
1984
- error
1985
- });
1986
- throw error;
1987
- }
1988
- if (span.isRecording()) {
1989
- span.setAttribute(ATTR_HTTP_RESPONSE_STATUS_CODE, response.status);
1990
- for (const [k, v] of response.headers) span.setAttribute(ATTR_HTTP_RESPONSE_HEADER(k), [v]);
1991
- span.setStatus({
1992
- code: response.status >= 500 ? SpanStatusCode.ERROR : SpanStatusCode.UNSET,
1993
- message: response.statusText
1994
- });
1995
- }
1996
- span.end();
1997
- const url = new URL(request.url);
1998
- const logTpl = "{method} {path}: {status}";
1999
- const values = {
2000
- method: request.method,
2001
- path: `${url.pathname}${url.search}`,
2002
- url: request.url,
2003
- status: response.status
2004
- };
2005
- if (response.status >= 500) logger$2.error(logTpl, values);
2006
- else if (response.status >= 400) logger$2.warn(logTpl, values);
2007
- else logger$2.info(logTpl, values);
2008
- return response;
2029
+ status: response.status
2030
+ };
2031
+ if (response.status >= 500) logger$2.error(logTpl, values);
2032
+ else if (response.status >= 400) logger$2.warn(logTpl, values);
2033
+ else logger$2.info(logTpl, values);
2034
+ return response;
2035
+ });
2009
2036
  });
2010
2037
  });
2011
2038
  }
@@ -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-DZrrJD77.js";
7
- import { detachSignature, doesActorOwnKey, getKeyOwner, hasSignature, signJsonLd, signObject, verifyJsonLd, verifyObject } from "./proof-JtZEQaKw.js";
6
+ import { deno_default, doubleKnock, exportJwk, importJwk, validateCryptoKey, verifyRequest } from "./http-C_qj3I7F.js";
7
+ import { detachSignature, doesActorOwnKey, getKeyOwner, hasSignature, signJsonLd, signObject, verifyJsonLd, verifyObject } from "./proof-Cq8LNpQ3.js";
8
8
  import { getNodeInfo, nodeInfoToJson } from "./types-C93Ob9cU.js";
9
- import { getAuthenticatedDocumentLoader, kvCache } from "./kv-cache-1TNWtgx7.js";
9
+ import { getAuthenticatedDocumentLoader, kvCache } from "./kv-cache-CibadbOC.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-BgurYNZ4.js");
341
+ const { FederationImpl: FederationImpl$1 } = await import("./middleware-BDQ8PDFx.js");
342
342
  const f = new FederationImpl$1(options);
343
343
  const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
344
344
  f.router = this.router.clone();
@@ -2394,7 +2394,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2394
2394
  outboxRetryPolicy;
2395
2395
  inboxRetryPolicy;
2396
2396
  activityTransformers;
2397
- tracerProvider;
2397
+ _tracerProvider;
2398
2398
  firstKnock;
2399
2399
  constructor(options) {
2400
2400
  super();
@@ -2476,9 +2476,12 @@ var FederationImpl = class extends FederationBuilderImpl {
2476
2476
  this.outboxRetryPolicy = options.outboxRetryPolicy ?? createExponentialBackoffPolicy();
2477
2477
  this.inboxRetryPolicy = options.inboxRetryPolicy ?? createExponentialBackoffPolicy();
2478
2478
  this.activityTransformers = options.activityTransformers ?? getDefaultActivityTransformers();
2479
- this.tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
2479
+ this._tracerProvider = options.tracerProvider;
2480
2480
  this.firstKnock = options.firstKnock;
2481
2481
  }
2482
+ get tracerProvider() {
2483
+ return this._tracerProvider ?? trace.getTracerProvider();
2484
+ }
2482
2485
  _initializeRouter() {
2483
2486
  this.router.add("/.well-known/webfinger", "webfinger");
2484
2487
  this.router.add("/.well-known/nodeinfo", "nodeInfoJrd");
@@ -2519,18 +2522,24 @@ var FederationImpl = class extends FederationBuilderImpl {
2519
2522
  kind: SpanKind.CONSUMER,
2520
2523
  attributes: { "activitypub.activity.type": message.activityType }
2521
2524
  }, 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
- }
2525
+ const spanCtx = span.spanContext();
2526
+ return await withContext({
2527
+ traceId: spanCtx.traceId,
2528
+ spanId: spanCtx.spanId
2529
+ }, async () => {
2530
+ if (message.activityId != null) span.setAttribute("activitypub.activity.id", message.activityId);
2531
+ try {
2532
+ await this.#listenFanoutMessage(contextData, message);
2533
+ } catch (e) {
2534
+ span.setStatus({
2535
+ code: SpanStatusCode.ERROR,
2536
+ message: String(e)
2537
+ });
2538
+ throw e;
2539
+ } finally {
2540
+ span.end();
2541
+ }
2542
+ });
2534
2543
  });
2535
2544
  else if (message.type === "outbox") await tracer.startActiveSpan("activitypub.outbox", {
2536
2545
  kind: SpanKind.CONSUMER,
@@ -2539,34 +2548,46 @@ var FederationImpl = class extends FederationBuilderImpl {
2539
2548
  "activitypub.activity.retries": message.attempt
2540
2549
  }
2541
2550
  }, 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
- }
2551
+ const spanCtx = span.spanContext();
2552
+ return await withContext({
2553
+ traceId: spanCtx.traceId,
2554
+ spanId: spanCtx.spanId
2555
+ }, async () => {
2556
+ if (message.activityId != null) span.setAttribute("activitypub.activity.id", message.activityId);
2557
+ try {
2558
+ await this.#listenOutboxMessage(contextData, message, span);
2559
+ } catch (e) {
2560
+ span.setStatus({
2561
+ code: SpanStatusCode.ERROR,
2562
+ message: String(e)
2563
+ });
2564
+ throw e;
2565
+ } finally {
2566
+ span.end();
2567
+ }
2568
+ });
2554
2569
  });
2555
2570
  else if (message.type === "inbox") await tracer.startActiveSpan("activitypub.inbox", {
2556
2571
  kind: SpanKind.CONSUMER,
2557
2572
  attributes: { "activitypub.shared_inbox": message.identifier == null }
2558
2573
  }, 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
- }
2574
+ const spanCtx = span.spanContext();
2575
+ return await withContext({
2576
+ traceId: spanCtx.traceId,
2577
+ spanId: spanCtx.spanId
2578
+ }, async () => {
2579
+ try {
2580
+ await this.#listenInboxMessage(contextData, message, span);
2581
+ } catch (e) {
2582
+ span.setStatus({
2583
+ code: SpanStatusCode.ERROR,
2584
+ message: String(e)
2585
+ });
2586
+ throw e;
2587
+ } finally {
2588
+ span.end();
2589
+ }
2590
+ });
2570
2591
  });
2571
2592
  });
2572
2593
  }
@@ -3039,54 +3060,60 @@ var FederationImpl = class extends FederationBuilderImpl {
3039
3060
  [ATTR_URL_FULL]: request.url
3040
3061
  }
3041
3062
  }, 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
- });
3063
+ const spanCtx = span.spanContext();
3064
+ return await withContext({
3065
+ traceId: spanCtx.traceId,
3066
+ spanId: spanCtx.spanId
3067
+ }, async () => {
3068
+ const logger$1 = getLogger([
3069
+ "fedify",
3070
+ "federation",
3071
+ "http"
3072
+ ]);
3073
+ if (span.isRecording()) for (const [k, v] of request.headers) span.setAttribute(ATTR_HTTP_REQUEST_HEADER(k), [v]);
3074
+ let response;
3075
+ try {
3076
+ response = await this.#fetch(request, {
3077
+ ...options,
3078
+ span,
3079
+ tracer
3080
+ });
3081
+ if (acceptsJsonLd(request)) response.headers.set("Vary", "Accept");
3082
+ } catch (error) {
3083
+ span.setStatus({
3084
+ code: SpanStatusCode.ERROR,
3085
+ message: `${error}`
3086
+ });
3087
+ span.end();
3088
+ logger$1.error("An error occurred while serving request {method} {url}: {error}", {
3089
+ method: request.method,
3090
+ url: request.url,
3091
+ error
3092
+ });
3093
+ throw error;
3094
+ }
3095
+ if (span.isRecording()) {
3096
+ span.setAttribute(ATTR_HTTP_RESPONSE_STATUS_CODE, response.status);
3097
+ for (const [k, v] of response.headers) span.setAttribute(ATTR_HTTP_RESPONSE_HEADER(k), [v]);
3098
+ span.setStatus({
3099
+ code: response.status >= 500 ? SpanStatusCode.ERROR : SpanStatusCode.UNSET,
3100
+ message: response.statusText
3101
+ });
3102
+ }
3061
3103
  span.end();
3062
- logger$1.error("An error occurred while serving request {method} {url}: {error}", {
3104
+ const url = new URL(request.url);
3105
+ const logTpl = "{method} {path}: {status}";
3106
+ const values = {
3063
3107
  method: request.method,
3108
+ path: `${url.pathname}${url.search}`,
3064
3109
  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;
3110
+ status: response.status
3111
+ };
3112
+ if (response.status >= 500) logger$1.error(logTpl, values);
3113
+ else if (response.status >= 400) logger$1.warn(logTpl, values);
3114
+ else logger$1.info(logTpl, values);
3115
+ return response;
3116
+ });
3090
3117
  });
3091
3118
  });
3092
3119
  }
@@ -0,0 +1,12 @@
1
+
2
+ const { Temporal } = require("@js-temporal/polyfill");
3
+ const { URLPattern } = require("urlpattern-polyfill");
4
+
5
+ require('./transformers-3g8GZwkZ.cjs');
6
+ require('./http-B8cUSIVv.cjs');
7
+ const require_middleware = require('./middleware-DfAuhaf7.cjs');
8
+ require('./proof-EVy7shg_.cjs');
9
+ require('./types-Cd_hszr_.cjs');
10
+ require('./kv-cache-CkfpyCN5.cjs');
11
+
12
+ exports.FederationImpl = require_middleware.FederationImpl;