@fedify/fedify 2.0.0-pr.479.1922 → 2.0.0-pr.490.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +6 -0
  2. package/dist/{actor-CW8r77Iv.js → actor-BT-e5fn9.js} +1 -1
  3. package/dist/{actor-DrcbNMaD.js → actor-B_gRMloq.js} +185 -185
  4. package/dist/{actor-ChFp4IyD.cjs → actor-CBfPjuWj.cjs} +185 -185
  5. package/dist/{builder-BLmiC9Ji.js → builder-4syLV1-z.js} +3 -3
  6. package/dist/compat/transformers.test.js +14 -14
  7. package/dist/{docloader-CDku0pGl.js → docloader-DndkGj0O.js} +2 -2
  8. package/dist/{esm-gonicPuw.js → esm-VlKMJQqV.js} +32 -17
  9. package/dist/federation/builder.test.js +4 -4
  10. package/dist/federation/collection.test.js +2 -2
  11. package/dist/federation/handler.test.js +102 -15
  12. package/dist/federation/idempotency.test.js +15 -15
  13. package/dist/federation/inbox.test.js +3 -3
  14. package/dist/federation/keycache.test.js +3 -3
  15. package/dist/federation/kv.test.js +2 -2
  16. package/dist/federation/middleware.test.js +16 -16
  17. package/dist/federation/mod.cjs +7 -7
  18. package/dist/federation/mod.js +7 -7
  19. package/dist/federation/mq.test.js +2 -2
  20. package/dist/federation/negotiation.test.js +2 -2
  21. package/dist/federation/retry.test.js +2 -2
  22. package/dist/federation/router.test.js +2 -2
  23. package/dist/federation/send.test.js +52 -9
  24. package/dist/{http-B7YinGhS.js → http-DH47B-h3.js} +2 -2
  25. package/dist/{http-BhZEftgL.cjs → http-Dxpqz4hE.cjs} +2 -2
  26. package/dist/{http-B4N7PAxs.js → http-YhR_TMMQ.js} +2 -2
  27. package/dist/{inbox-DMBYq6WU.js → inbox-CEyHvxOo.js} +1 -1
  28. package/dist/{key-DX9ebN5W.js → key-x7E5PYI0.js} +2 -2
  29. package/dist/{keycache-Cd54Wo4I.js → keycache-BRXuBDuy.js} +1 -1
  30. package/dist/{keys-Dm-l-UEv.js → keys-DLk_8H-l.js} +1 -1
  31. package/dist/{kv-cache-B9mNKlfq.cjs → kv-cache-BMpfJFTx.cjs} +1 -1
  32. package/dist/{kv-cache-DntsW5WZ.js → kv-cache-HFnFIjSD.js} +1 -1
  33. package/dist/{ld-CFZBvR6L.js → ld-CRPaU6c8.js} +2 -2
  34. package/dist/{lookup-BabhiNS7.cjs → lookup-BTqtVATt.cjs} +4 -3
  35. package/dist/{lookup-BBJi-4zQ.js → lookup-DOSnR912.js} +4 -3
  36. package/dist/{lookup-BwjF-fcb.js → lookup-Dj9-mgOn.js} +193 -187
  37. package/dist/{middleware-C9Thrf4d.js → middleware-BIqFwRwI.js} +18 -11
  38. package/dist/{middleware-CC2KZVK7.cjs → middleware-Ck7O6mb0.cjs} +21 -9
  39. package/dist/middleware-CxswDtQn.js +15 -0
  40. package/dist/middleware-CyITsnX0.js +26 -0
  41. package/dist/{middleware-CyZ46GgA.js → middleware-DfLpMu7C.js} +21 -9
  42. package/dist/middleware-Z8lc_drL.cjs +15 -0
  43. package/dist/mod.cjs +7 -7
  44. package/dist/mod.js +7 -7
  45. package/dist/nodeinfo/client.test.js +3 -3
  46. package/dist/nodeinfo/handler.test.js +14 -14
  47. package/dist/nodeinfo/types.test.js +2 -2
  48. package/dist/otel-1BmGPuZc.js +64 -0
  49. package/dist/{owner-v5XRZOsn.js → owner-CIWnopkT.js} +44 -8
  50. package/dist/{proof-DOvE4smW.js → proof-C8-2l0zH.js} +45 -9
  51. package/dist/{proof-CP8PPaHI.js → proof-D-5ri6rf.js} +2 -2
  52. package/dist/{proof-BHfwU6AU.cjs → proof-fEwcA7LA.cjs} +44 -8
  53. package/dist/{send-BkxtciTj.js → send-CPGk9QKZ.js} +9 -4
  54. package/dist/sig/http.test.js +7 -7
  55. package/dist/sig/key.test.js +5 -5
  56. package/dist/sig/ld.test.js +6 -6
  57. package/dist/sig/mod.cjs +4 -4
  58. package/dist/sig/mod.js +4 -4
  59. package/dist/sig/owner.test.js +30 -6
  60. package/dist/sig/proof.test.js +6 -6
  61. package/dist/testing/docloader.test.js +2 -2
  62. package/dist/testing/mod.js +2 -2
  63. package/dist/{testing-DSh8vd8b.js → testing-BslrM_9E.js} +1 -1
  64. package/dist/utils/docloader.test.js +8 -8
  65. package/dist/utils/kv-cache.test.js +2 -2
  66. package/dist/utils/mod.cjs +4 -4
  67. package/dist/utils/mod.js +4 -4
  68. package/dist/vocab/actor.test.js +4 -4
  69. package/dist/vocab/lookup.test.js +26 -4
  70. package/dist/vocab/mod.cjs +3 -3
  71. package/dist/vocab/mod.js +3 -3
  72. package/dist/vocab/type.test.js +2 -2
  73. package/dist/vocab/vocab.test.js +157 -157
  74. package/dist/{vocab-DV_9LdI4.js → vocab-ByUp-A2_.js} +7 -2
  75. package/dist/{vocab-Ca8XeGxY.cjs → vocab-X_X5T8D3.cjs} +7 -2
  76. package/dist/webfinger/handler.test.js +14 -14
  77. package/dist/webfinger/lookup.test.js +3 -3
  78. package/dist/webfinger/mod.cjs +1 -1
  79. package/dist/webfinger/mod.js +1 -1
  80. package/package.json +9 -5
  81. package/dist/middleware-BcWGBxBO.cjs +0 -15
  82. package/dist/middleware-Cc0YUCwW.js +0 -26
  83. package/dist/middleware-ZvHPFLJQ.js +0 -15
@@ -3,23 +3,23 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, RouterError, deno_default, getTypeId, lookupObject, lookupWebFinger, traverseCollection } from "./lookup-BwjF-fcb.js";
6
+ import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, RouterError, deno_default, getTypeId, lookupObject, lookupWebFinger, traverseCollection } from "./lookup-Dj9-mgOn.js";
7
7
  import { getNodeInfo } from "./client-pY7-3icS.js";
8
8
  import { nodeInfoToJson } from "./types-C2XVl6gj.js";
9
- import { exportJwk, importJwk, validateCryptoKey } from "./key-DX9ebN5W.js";
10
- import { verifyRequest } from "./http-B7YinGhS.js";
11
- import { detachSignature, hasSignature, signJsonLd, verifyJsonLd } from "./ld-CFZBvR6L.js";
12
- import { doesActorOwnKey, getKeyOwner } from "./owner-v5XRZOsn.js";
13
- import { signObject, verifyObject } from "./proof-CP8PPaHI.js";
14
- import { getAuthenticatedDocumentLoader } from "./docloader-CDku0pGl.js";
9
+ import { exportJwk, importJwk, validateCryptoKey } from "./key-x7E5PYI0.js";
10
+ import { verifyRequest } from "./http-DH47B-h3.js";
11
+ import { detachSignature, hasSignature, signJsonLd, verifyJsonLd } from "./ld-CRPaU6c8.js";
12
+ import { doesActorOwnKey, getKeyOwner } from "./owner-CIWnopkT.js";
13
+ import { signObject, verifyObject } from "./proof-D-5ri6rf.js";
14
+ import { getAuthenticatedDocumentLoader } from "./docloader-DndkGj0O.js";
15
15
  import { kvCache } from "./kv-cache-DN9pfMBe.js";
16
- import { routeActivity } from "./inbox-DMBYq6WU.js";
17
- import { FederationBuilderImpl } from "./builder-BLmiC9Ji.js";
16
+ import { routeActivity } from "./inbox-CEyHvxOo.js";
17
+ import { FederationBuilderImpl } from "./builder-4syLV1-z.js";
18
18
  import { buildCollectionSynchronizationHeader } from "./collection-BzWsN9pB.js";
19
- import { KvKeyCache } from "./keycache-Cd54Wo4I.js";
19
+ import { KvKeyCache } from "./keycache-BRXuBDuy.js";
20
20
  import { acceptsJsonLd } from "./negotiation-C4nFufNk.js";
21
21
  import { createExponentialBackoffPolicy } from "./retry-CfF8Gn4d.js";
22
- import { extractInboxes, sendActivity } from "./send-BkxtciTj.js";
22
+ import { extractInboxes, sendActivity } from "./send-CPGk9QKZ.js";
23
23
  import { getDocumentLoader } from "@fedify/vocab-runtime";
24
24
  import { getLogger, withContext } from "@logtape/logtape";
25
25
  import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
@@ -780,6 +780,13 @@ async function handleInboxInternal(request, parameters, span) {
780
780
  }
781
781
  if (activity.id != null) span.setAttribute("activitypub.activity.id", activity.id.href);
782
782
  span.setAttribute("activitypub.activity.type", getTypeId(activity).href);
783
+ span.addEvent("activitypub.activity.received", {
784
+ "activitypub.activity.json": JSON.stringify(json),
785
+ "activitypub.activity.verified": activity != null,
786
+ "ld_signatures.verified": ldSigVerified,
787
+ "http_signatures.verified": httpSigKey != null,
788
+ "http_signatures.key_id": httpSigKey?.id?.href ?? ""
789
+ });
783
790
  if (httpSigKey != null && !await doesActorOwnKey(activity, httpSigKey, ctx)) {
784
791
  logger$2.error("The signer ({keyId}) and the actor ({actorId}) do not match.", {
785
792
  activity: json,
@@ -4,13 +4,13 @@
4
4
 
5
5
  const require_chunk = require('./chunk-DqRYRqnO.cjs');
6
6
  const require_transformers = require('./transformers-CoBS-oFG.cjs');
7
- const require_lookup = require('./lookup-BabhiNS7.cjs');
8
- const require_actor = require('./actor-ChFp4IyD.cjs');
9
- const require_http = require('./http-BhZEftgL.cjs');
10
- const require_proof = require('./proof-BHfwU6AU.cjs');
7
+ const require_lookup = require('./lookup-BTqtVATt.cjs');
8
+ const require_actor = require('./actor-CBfPjuWj.cjs');
9
+ const require_http = require('./http-Dxpqz4hE.cjs');
10
+ const require_proof = require('./proof-fEwcA7LA.cjs');
11
11
  const require_types = require('./types-CWgzGaqk.cjs');
12
- const require_kv_cache = require('./kv-cache-B9mNKlfq.cjs');
13
- const require_vocab = require('./vocab-Ca8XeGxY.cjs');
12
+ const require_kv_cache = require('./kv-cache-BMpfJFTx.cjs');
13
+ const require_vocab = require('./vocab-X_X5T8D3.cjs');
14
14
  const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
15
15
  const __opentelemetry_api = require_chunk.__toESM(require("@opentelemetry/api"));
16
16
  const __fedify_vocab_runtime = require_chunk.__toESM(require("@fedify/vocab-runtime"));
@@ -339,7 +339,7 @@ var FederationBuilderImpl = class {
339
339
  this.collectionTypeIds = {};
340
340
  }
341
341
  async build(options) {
342
- const { FederationImpl: FederationImpl$1 } = await Promise.resolve().then(() => require("./middleware-BcWGBxBO.cjs"));
342
+ const { FederationImpl: FederationImpl$1 } = await Promise.resolve().then(() => require("./middleware-Z8lc_drL.cjs"));
343
343
  const f = new FederationImpl$1(options);
344
344
  const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
345
345
  f.router = this.router.clone();
@@ -1491,6 +1491,13 @@ async function handleInboxInternal(request, parameters, span) {
1491
1491
  }
1492
1492
  if (activity.id != null) span.setAttribute("activitypub.activity.id", activity.id.href);
1493
1493
  span.setAttribute("activitypub.activity.type", require_actor.getTypeId(activity).href);
1494
+ span.addEvent("activitypub.activity.received", {
1495
+ "activitypub.activity.json": JSON.stringify(json),
1496
+ "activitypub.activity.verified": activity != null,
1497
+ "ld_signatures.verified": ldSigVerified,
1498
+ "http_signatures.verified": httpSigKey != null,
1499
+ "http_signatures.key_id": httpSigKey?.id?.href ?? ""
1500
+ });
1494
1501
  if (httpSigKey != null && !await require_proof.doesActorOwnKey(activity, httpSigKey, ctx)) {
1495
1502
  logger$1.error("The signer ({keyId}) and the actor ({actorId}) do not match.", {
1496
1503
  activity: json,
@@ -2243,7 +2250,7 @@ function sendActivity(options) {
2243
2250
  await sendActivityInternal({
2244
2251
  ...options,
2245
2252
  tracerProvider
2246
- });
2253
+ }, span);
2247
2254
  } catch (e) {
2248
2255
  span.setStatus({
2249
2256
  code: __opentelemetry_api.SpanStatusCode.ERROR,
@@ -2255,7 +2262,7 @@ function sendActivity(options) {
2255
2262
  }
2256
2263
  });
2257
2264
  }
2258
- async function sendActivityInternal({ activity, activityId, keys, inbox, headers, specDeterminer, tracerProvider }) {
2265
+ async function sendActivityInternal({ activity, activityId, keys, inbox, headers, specDeterminer, tracerProvider }, span) {
2259
2266
  const logger$1 = (0, __logtape_logtape.getLogger)([
2260
2267
  "fedify",
2261
2268
  "federation",
@@ -2310,6 +2317,11 @@ async function sendActivityInternal({ activity, activityId, keys, inbox, headers
2310
2317
  });
2311
2318
  throw new Error(`Failed to send activity ${activityId} to ${inbox.href} (${response.status} ${response.statusText}):\n${error}`);
2312
2319
  }
2320
+ span.addEvent("activitypub.activity.sent", {
2321
+ "activitypub.activity.json": JSON.stringify(activity),
2322
+ "activitypub.inbox.url": inbox.href,
2323
+ "activitypub.activity.id": activityId ?? ""
2324
+ });
2313
2325
  }
2314
2326
 
2315
2327
  //#endregion
@@ -0,0 +1,15 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ import "./transformers-BFT6d7J5.js";
6
+ import "./lookup-DOSnR912.js";
7
+ import "./actor-B_gRMloq.js";
8
+ import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "./middleware-DfLpMu7C.js";
9
+ import "./http-YhR_TMMQ.js";
10
+ import "./proof-C8-2l0zH.js";
11
+ import "./types-BtUjyi5y.js";
12
+ import "./kv-cache-HFnFIjSD.js";
13
+ import "./vocab-ByUp-A2_.js";
14
+
15
+ export { FederationImpl };
@@ -0,0 +1,26 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+ globalThis.addEventListener = () => {};
5
+
6
+ import "./lookup-Dj9-mgOn.js";
7
+ import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "./middleware-BIqFwRwI.js";
8
+ import "./client-pY7-3icS.js";
9
+ import "./types-C2XVl6gj.js";
10
+ import "./actor-BT-e5fn9.js";
11
+ import "./key-x7E5PYI0.js";
12
+ import "./http-DH47B-h3.js";
13
+ import "./ld-CRPaU6c8.js";
14
+ import "./owner-CIWnopkT.js";
15
+ import "./proof-D-5ri6rf.js";
16
+ import "./docloader-DndkGj0O.js";
17
+ import "./kv-cache-DN9pfMBe.js";
18
+ import "./inbox-CEyHvxOo.js";
19
+ import "./builder-4syLV1-z.js";
20
+ import "./collection-BzWsN9pB.js";
21
+ import "./keycache-BRXuBDuy.js";
22
+ import "./negotiation-C4nFufNk.js";
23
+ import "./retry-CfF8Gn4d.js";
24
+ import "./send-CPGk9QKZ.js";
25
+
26
+ export { FederationImpl };
@@ -3,13 +3,13 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
 
5
5
  import { getDefaultActivityTransformers } from "./transformers-BFT6d7J5.js";
6
- import { deno_default, lookupWebFinger } from "./lookup-BBJi-4zQ.js";
7
- import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, getTypeId } from "./actor-DrcbNMaD.js";
8
- import { doubleKnock, exportJwk, importJwk, validateCryptoKey, verifyRequest } from "./http-B4N7PAxs.js";
9
- import { detachSignature, doesActorOwnKey, getKeyOwner, hasSignature, signJsonLd, signObject, verifyJsonLd, verifyObject } from "./proof-DOvE4smW.js";
6
+ import { deno_default, lookupWebFinger } from "./lookup-DOSnR912.js";
7
+ import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, getTypeId } from "./actor-B_gRMloq.js";
8
+ import { doubleKnock, exportJwk, importJwk, validateCryptoKey, verifyRequest } from "./http-YhR_TMMQ.js";
9
+ import { detachSignature, doesActorOwnKey, getKeyOwner, hasSignature, signJsonLd, signObject, verifyJsonLd, verifyObject } from "./proof-C8-2l0zH.js";
10
10
  import { getNodeInfo, nodeInfoToJson } from "./types-BtUjyi5y.js";
11
- import { getAuthenticatedDocumentLoader, kvCache } from "./kv-cache-DntsW5WZ.js";
12
- import { lookupObject, traverseCollection } from "./vocab-DV_9LdI4.js";
11
+ import { getAuthenticatedDocumentLoader, kvCache } from "./kv-cache-HFnFIjSD.js";
12
+ import { lookupObject, traverseCollection } from "./vocab-ByUp-A2_.js";
13
13
  import { getLogger, withContext } from "@logtape/logtape";
14
14
  import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
15
15
  import { getDocumentLoader } from "@fedify/vocab-runtime";
@@ -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-ZvHPFLJQ.js");
341
+ const { FederationImpl: FederationImpl$1 } = await import("./middleware-CxswDtQn.js");
342
342
  const f = new FederationImpl$1(options);
343
343
  const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
344
344
  f.router = this.router.clone();
@@ -1490,6 +1490,13 @@ async function handleInboxInternal(request, parameters, span) {
1490
1490
  }
1491
1491
  if (activity.id != null) span.setAttribute("activitypub.activity.id", activity.id.href);
1492
1492
  span.setAttribute("activitypub.activity.type", getTypeId(activity).href);
1493
+ span.addEvent("activitypub.activity.received", {
1494
+ "activitypub.activity.json": JSON.stringify(json),
1495
+ "activitypub.activity.verified": activity != null,
1496
+ "ld_signatures.verified": ldSigVerified,
1497
+ "http_signatures.verified": httpSigKey != null,
1498
+ "http_signatures.key_id": httpSigKey?.id?.href ?? ""
1499
+ });
1493
1500
  if (httpSigKey != null && !await doesActorOwnKey(activity, httpSigKey, ctx)) {
1494
1501
  logger$1.error("The signer ({keyId}) and the actor ({actorId}) do not match.", {
1495
1502
  activity: json,
@@ -2242,7 +2249,7 @@ function sendActivity(options) {
2242
2249
  await sendActivityInternal({
2243
2250
  ...options,
2244
2251
  tracerProvider
2245
- });
2252
+ }, span);
2246
2253
  } catch (e) {
2247
2254
  span.setStatus({
2248
2255
  code: SpanStatusCode.ERROR,
@@ -2254,7 +2261,7 @@ function sendActivity(options) {
2254
2261
  }
2255
2262
  });
2256
2263
  }
2257
- async function sendActivityInternal({ activity, activityId, keys, inbox, headers, specDeterminer, tracerProvider }) {
2264
+ async function sendActivityInternal({ activity, activityId, keys, inbox, headers, specDeterminer, tracerProvider }, span) {
2258
2265
  const logger$1 = getLogger([
2259
2266
  "fedify",
2260
2267
  "federation",
@@ -2309,6 +2316,11 @@ async function sendActivityInternal({ activity, activityId, keys, inbox, headers
2309
2316
  });
2310
2317
  throw new Error(`Failed to send activity ${activityId} to ${inbox.href} (${response.status} ${response.statusText}):\n${error}`);
2311
2318
  }
2319
+ span.addEvent("activitypub.activity.sent", {
2320
+ "activitypub.activity.json": JSON.stringify(activity),
2321
+ "activitypub.inbox.url": inbox.href,
2322
+ "activitypub.activity.id": activityId ?? ""
2323
+ });
2312
2324
  }
2313
2325
 
2314
2326
  //#endregion
@@ -0,0 +1,15 @@
1
+
2
+ const { Temporal } = require("@js-temporal/polyfill");
3
+ const { URLPattern } = require("urlpattern-polyfill");
4
+
5
+ require('./transformers-CoBS-oFG.cjs');
6
+ require('./lookup-BTqtVATt.cjs');
7
+ require('./actor-CBfPjuWj.cjs');
8
+ const require_middleware = require('./middleware-Ck7O6mb0.cjs');
9
+ require('./http-Dxpqz4hE.cjs');
10
+ require('./proof-fEwcA7LA.cjs');
11
+ require('./types-CWgzGaqk.cjs');
12
+ require('./kv-cache-BMpfJFTx.cjs');
13
+ require('./vocab-X_X5T8D3.cjs');
14
+
15
+ exports.FederationImpl = require_middleware.FederationImpl;
package/dist/mod.cjs CHANGED
@@ -4,15 +4,15 @@
4
4
 
5
5
  const require_transformers = require('./transformers-CoBS-oFG.cjs');
6
6
  require('./compat-DmDDELst.cjs');
7
- const require_lookup = require('./lookup-BabhiNS7.cjs');
8
- const require_actor = require('./actor-ChFp4IyD.cjs');
9
- const require_middleware = require('./middleware-CC2KZVK7.cjs');
10
- const require_http = require('./http-BhZEftgL.cjs');
11
- const require_proof = require('./proof-BHfwU6AU.cjs');
7
+ const require_lookup = require('./lookup-BTqtVATt.cjs');
8
+ const require_actor = require('./actor-CBfPjuWj.cjs');
9
+ const require_middleware = require('./middleware-Ck7O6mb0.cjs');
10
+ const require_http = require('./http-Dxpqz4hE.cjs');
11
+ const require_proof = require('./proof-fEwcA7LA.cjs');
12
12
  const require_federation = require('./federation-CRpdnOMS.cjs');
13
13
  const require_types = require('./types-CWgzGaqk.cjs');
14
- const require_kv_cache = require('./kv-cache-B9mNKlfq.cjs');
15
- const require_vocab = require('./vocab-Ca8XeGxY.cjs');
14
+ const require_kv_cache = require('./kv-cache-BMpfJFTx.cjs');
15
+ const require_vocab = require('./vocab-X_X5T8D3.cjs');
16
16
  require('./nodeinfo-CdN0rEnZ.cjs');
17
17
  require('./sig-YYj5tCnr.cjs');
18
18
  require('./utils-DyRU1gdZ.cjs');
package/dist/mod.js CHANGED
@@ -4,15 +4,15 @@
4
4
 
5
5
  import { actorDehydrator, autoIdAssigner, getDefaultActivityTransformers } from "./transformers-BFT6d7J5.js";
6
6
  import "./compat-nxUqe4Z-.js";
7
- import { lookupWebFinger } from "./lookup-BBJi-4zQ.js";
8
- import { Accept, Activity, Add, Announce, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, Flag, Follow, Group, Hashtag, Ignore, Image, IntransitiveActivity, Invite, Join, Leave, Like, Link, Listen, Mention, Move, Multikey, Note, Object as Object$1, Offer, OrderedCollection, OrderedCollectionPage, Organization, Page, Person, Place, Profile, PropertyValue, Question, Read, Reject, Relationship, Remove, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, Undo, Update, Video, View, getActorClassByTypeName, getActorHandle, getActorTypeName, getTypeId, isActor, normalizeActorHandle } from "./actor-DrcbNMaD.js";
9
- import { Router, RouterError, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable } from "./middleware-CyZ46GgA.js";
10
- import { exportJwk, fetchKey, generateCryptoKeyPair, importJwk, signRequest, verifyRequest } from "./http-B4N7PAxs.js";
11
- import { attachSignature, createProof, createSignature, detachSignature, doesActorOwnKey, getKeyOwner, signJsonLd, signObject, verifyJsonLd, verifyObject, verifyProof, verifySignature } from "./proof-DOvE4smW.js";
7
+ import { lookupWebFinger } from "./lookup-DOSnR912.js";
8
+ import { Accept, Activity, Add, Announce, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, Flag, Follow, Group, Hashtag, Ignore, Image, IntransitiveActivity, Invite, Join, Leave, Like, Link, Listen, Mention, Move, Multikey, Note, Object as Object$1, Offer, OrderedCollection, OrderedCollectionPage, Organization, Page, Person, Place, Profile, PropertyValue, Question, Read, Reject, Relationship, Remove, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, Undo, Update, Video, View, getActorClassByTypeName, getActorHandle, getActorTypeName, getTypeId, isActor, normalizeActorHandle } from "./actor-B_gRMloq.js";
9
+ import { Router, RouterError, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable } from "./middleware-DfLpMu7C.js";
10
+ import { exportJwk, fetchKey, generateCryptoKeyPair, importJwk, signRequest, verifyRequest } from "./http-YhR_TMMQ.js";
11
+ import { attachSignature, createProof, createSignature, detachSignature, doesActorOwnKey, getKeyOwner, signJsonLd, signObject, verifyJsonLd, verifyObject, verifyProof, verifySignature } from "./proof-C8-2l0zH.js";
12
12
  import { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue } from "./federation-jcR8-ZxP.js";
13
13
  import { getNodeInfo, nodeInfoToJson, parseNodeInfo } from "./types-BtUjyi5y.js";
14
- import { getAuthenticatedDocumentLoader, kvCache } from "./kv-cache-DntsW5WZ.js";
15
- import { PUBLIC_COLLECTION, isFediverseHandle, lookupObject, parseFediverseHandle, toAcctUrl, traverseCollection } from "./vocab-DV_9LdI4.js";
14
+ import { getAuthenticatedDocumentLoader, kvCache } from "./kv-cache-HFnFIjSD.js";
15
+ import { PUBLIC_COLLECTION, isFediverseHandle, lookupObject, parseFediverseHandle, toAcctUrl, traverseCollection } from "./vocab-ByUp-A2_.js";
16
16
  import "./nodeinfo-BnthBobC.js";
17
17
  import "./sig-C34-oHBl.js";
18
18
  import "./utils-D-Va7aXC.js";
@@ -3,17 +3,17 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import "../lookup-BwjF-fcb.js";
6
+ import "../lookup-Dj9-mgOn.js";
7
7
  import { assertEquals } from "../assert_equals-DSbWqCm3.js";
8
8
  import "../assert-MZs1qjMx.js";
9
9
  import "../assert_instance_of-DHz7EHNU.js";
10
10
  import { getNodeInfo, parseInboundService, parseNodeInfo, parseOutboundService, parseProtocol, parseServices, parseSoftware, parseUsage } from "../client-pY7-3icS.js";
11
- import { test } from "../testing-DSh8vd8b.js";
11
+ import { test } from "../testing-BslrM_9E.js";
12
12
  import "../std__assert-DWivtrGR.js";
13
13
  import "../assert_rejects-Ce45JcFg.js";
14
14
  import "../assert_throws-BNXdRGWP.js";
15
15
  import "../assert_not_equals-C80BG-_5.js";
16
- import { esm_default } from "../esm-gonicPuw.js";
16
+ import { esm_default } from "../esm-VlKMJQqV.js";
17
17
 
18
18
  //#region src/nodeinfo/client.test.ts
19
19
  test("getNodeInfo()", async (t) => {
@@ -3,30 +3,30 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import "../lookup-BwjF-fcb.js";
6
+ import "../lookup-Dj9-mgOn.js";
7
7
  import { assertEquals } from "../assert_equals-DSbWqCm3.js";
8
8
  import "../assert-MZs1qjMx.js";
9
9
  import "../assert_instance_of-DHz7EHNU.js";
10
10
  import { MemoryKvStore } from "../kv-CRZrzyXm.js";
11
- import { createFederation, handleNodeInfo, handleNodeInfoJrd } from "../middleware-C9Thrf4d.js";
11
+ import { createFederation, handleNodeInfo, handleNodeInfoJrd } from "../middleware-BIqFwRwI.js";
12
12
  import "../client-pY7-3icS.js";
13
13
  import "../types-C2XVl6gj.js";
14
- import "../actor-CW8r77Iv.js";
15
- import "../key-DX9ebN5W.js";
16
- import "../http-B7YinGhS.js";
17
- import "../ld-CFZBvR6L.js";
18
- import "../owner-v5XRZOsn.js";
19
- import "../proof-CP8PPaHI.js";
20
- import "../docloader-CDku0pGl.js";
14
+ import "../actor-BT-e5fn9.js";
15
+ import "../key-x7E5PYI0.js";
16
+ import "../http-DH47B-h3.js";
17
+ import "../ld-CRPaU6c8.js";
18
+ import "../owner-CIWnopkT.js";
19
+ import "../proof-D-5ri6rf.js";
20
+ import "../docloader-DndkGj0O.js";
21
21
  import "../kv-cache-DN9pfMBe.js";
22
- import "../inbox-DMBYq6WU.js";
23
- import "../builder-BLmiC9Ji.js";
22
+ import "../inbox-CEyHvxOo.js";
23
+ import "../builder-4syLV1-z.js";
24
24
  import "../collection-BzWsN9pB.js";
25
- import "../keycache-Cd54Wo4I.js";
25
+ import "../keycache-BRXuBDuy.js";
26
26
  import "../negotiation-C4nFufNk.js";
27
27
  import "../retry-CfF8Gn4d.js";
28
- import "../send-BkxtciTj.js";
29
- import { createRequestContext, test } from "../testing-DSh8vd8b.js";
28
+ import "../send-CPGk9QKZ.js";
29
+ import { createRequestContext, test } from "../testing-BslrM_9E.js";
30
30
  import "../std__assert-DWivtrGR.js";
31
31
  import "../assert_rejects-Ce45JcFg.js";
32
32
  import "../assert_throws-BNXdRGWP.js";
@@ -3,12 +3,12 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import "../lookup-BwjF-fcb.js";
6
+ import "../lookup-Dj9-mgOn.js";
7
7
  import { assertEquals } from "../assert_equals-DSbWqCm3.js";
8
8
  import "../assert-MZs1qjMx.js";
9
9
  import "../assert_instance_of-DHz7EHNU.js";
10
10
  import { nodeInfoToJson } from "../types-C2XVl6gj.js";
11
- import { test } from "../testing-DSh8vd8b.js";
11
+ import { test } from "../testing-BslrM_9E.js";
12
12
  import "../std__assert-DWivtrGR.js";
13
13
  import "../assert_rejects-Ce45JcFg.js";
14
14
  import { assertThrows } from "../assert_throws-BNXdRGWP.js";
@@ -0,0 +1,64 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+ globalThis.addEventListener = () => {};
5
+
6
+ import { BasicTracerProvider, SimpleSpanProcessor } from "@opentelemetry/sdk-trace-base";
7
+ import { ExportResultCode } from "@opentelemetry/core";
8
+
9
+ //#region src/testing/otel.ts
10
+ /**
11
+ * A test spy for OpenTelemetry spans that captures all spans and events.
12
+ */
13
+ var TestSpanExporter = class {
14
+ spans = [];
15
+ export(spans, resultCallback) {
16
+ this.spans.push(...spans);
17
+ resultCallback({ code: ExportResultCode.SUCCESS });
18
+ }
19
+ async forceFlush() {}
20
+ shutdown() {
21
+ this.spans = [];
22
+ return Promise.resolve();
23
+ }
24
+ /**
25
+ * Gets all spans with the given name.
26
+ */
27
+ getSpans(name) {
28
+ return this.spans.filter((span) => span.name === name);
29
+ }
30
+ /**
31
+ * Gets the first span with the given name.
32
+ */
33
+ getSpan(name) {
34
+ return this.spans.find((span) => span.name === name);
35
+ }
36
+ /**
37
+ * Gets all events from spans with the given name.
38
+ */
39
+ getEvents(spanName, eventName) {
40
+ const spans = this.getSpans(spanName);
41
+ const events = spans.flatMap((span) => span.events);
42
+ if (eventName) return events.filter((event) => event.name === eventName);
43
+ return events;
44
+ }
45
+ /**
46
+ * Clears all captured spans.
47
+ */
48
+ clear() {
49
+ this.spans = [];
50
+ }
51
+ };
52
+ /**
53
+ * Creates a test tracer provider with a test exporter.
54
+ * @returns A tuple of [tracerProvider, testExporter]
55
+ */
56
+ function createTestTracerProvider() {
57
+ const exporter = new TestSpanExporter();
58
+ const provider = new BasicTracerProvider();
59
+ provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
60
+ return [provider, exporter];
61
+ }
62
+
63
+ //#endregion
64
+ export { createTestTracerProvider };
@@ -3,10 +3,10 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { CryptographicKey, Object as Object$1 } from "./lookup-BwjF-fcb.js";
7
- import { isActor } from "./actor-CW8r77Iv.js";
6
+ import { CryptographicKey, Object as Object$1, deno_default } from "./lookup-Dj9-mgOn.js";
7
+ import { isActor } from "./actor-BT-e5fn9.js";
8
8
  import { getDocumentLoader } from "@fedify/vocab-runtime";
9
- import { trace } from "@opentelemetry/api";
9
+ import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
10
10
 
11
11
  //#region src/sig/owner.ts
12
12
  /**
@@ -17,11 +17,47 @@ import { trace } from "@opentelemetry/api";
17
17
  * @returns Whether the actor is the owner of the key.
18
18
  */
19
19
  async function doesActorOwnKey(activity, key, options) {
20
- if (key.ownerId != null) return key.ownerId.href === activity.actorId?.href;
21
- const actor = await activity.getActor(options);
22
- if (actor == null || !isActor(actor)) return false;
23
- for (const publicKeyId of actor.publicKeyIds) if (key.id != null && publicKeyId.href === key.id.href) return true;
24
- return false;
20
+ const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
21
+ const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
22
+ return await tracer.startActiveSpan("activitypub.verify_key_ownership", {
23
+ kind: SpanKind.INTERNAL,
24
+ attributes: {
25
+ "activitypub.actor.id": activity.actorId?.href ?? "",
26
+ "activitypub.key.id": key.id?.href ?? ""
27
+ }
28
+ }, async (span) => {
29
+ try {
30
+ if (key.ownerId != null) {
31
+ const owns = key.ownerId.href === activity.actorId?.href;
32
+ span.setAttribute("activitypub.key_ownership.verified", owns);
33
+ span.setAttribute("activitypub.key_ownership.method", "owner_id");
34
+ return owns;
35
+ }
36
+ const actor = await activity.getActor(options);
37
+ if (actor == null || !isActor(actor)) {
38
+ span.setAttribute("activitypub.key_ownership.verified", false);
39
+ span.setAttribute("activitypub.key_ownership.method", "actor_fetch");
40
+ return false;
41
+ }
42
+ for (const publicKeyId of actor.publicKeyIds) if (key.id != null && publicKeyId.href === key.id.href) {
43
+ span.setAttribute("activitypub.key_ownership.verified", true);
44
+ span.setAttribute("activitypub.key_ownership.method", "actor_fetch");
45
+ return true;
46
+ }
47
+ span.setAttribute("activitypub.key_ownership.verified", false);
48
+ span.setAttribute("activitypub.key_ownership.method", "actor_fetch");
49
+ return false;
50
+ } catch (error) {
51
+ span.recordException(error);
52
+ span.setStatus({
53
+ code: SpanStatusCode.ERROR,
54
+ message: String(error)
55
+ });
56
+ throw error;
57
+ } finally {
58
+ span.end();
59
+ }
60
+ });
25
61
  }
26
62
  /**
27
63
  * Gets the actor that owns the specified key. Returns `null` if the key has no
@@ -2,11 +2,11 @@
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
 
5
- import { deno_default } from "./lookup-BBJi-4zQ.js";
6
- import { Activity, CryptographicKey, DataIntegrityProof, Multikey, Object as Object$1, getTypeId, isActor } from "./actor-DrcbNMaD.js";
7
- import { fetchKey, validateCryptoKey } from "./http-B4N7PAxs.js";
5
+ import { deno_default } from "./lookup-DOSnR912.js";
6
+ import { Activity, CryptographicKey, DataIntegrityProof, Multikey, Object as Object$1, getTypeId, isActor } from "./actor-B_gRMloq.js";
7
+ import { fetchKey, validateCryptoKey } from "./http-YhR_TMMQ.js";
8
8
  import { getLogger } from "@logtape/logtape";
9
- import { SpanStatusCode, trace } from "@opentelemetry/api";
9
+ import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
10
10
  import jsonld from "jsonld";
11
11
  import { getDocumentLoader } from "@fedify/vocab-runtime";
12
12
  import { encodeHex } from "byte-encodings/hex";
@@ -276,11 +276,47 @@ async function hashJsonLd(jsonLd, contextLoader) {
276
276
  * @returns Whether the actor is the owner of the key.
277
277
  */
278
278
  async function doesActorOwnKey(activity, key, options) {
279
- if (key.ownerId != null) return key.ownerId.href === activity.actorId?.href;
280
- const actor = await activity.getActor(options);
281
- if (actor == null || !isActor(actor)) return false;
282
- for (const publicKeyId of actor.publicKeyIds) if (key.id != null && publicKeyId.href === key.id.href) return true;
283
- return false;
279
+ const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
280
+ const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
281
+ return await tracer.startActiveSpan("activitypub.verify_key_ownership", {
282
+ kind: SpanKind.INTERNAL,
283
+ attributes: {
284
+ "activitypub.actor.id": activity.actorId?.href ?? "",
285
+ "activitypub.key.id": key.id?.href ?? ""
286
+ }
287
+ }, async (span) => {
288
+ try {
289
+ if (key.ownerId != null) {
290
+ const owns = key.ownerId.href === activity.actorId?.href;
291
+ span.setAttribute("activitypub.key_ownership.verified", owns);
292
+ span.setAttribute("activitypub.key_ownership.method", "owner_id");
293
+ return owns;
294
+ }
295
+ const actor = await activity.getActor(options);
296
+ if (actor == null || !isActor(actor)) {
297
+ span.setAttribute("activitypub.key_ownership.verified", false);
298
+ span.setAttribute("activitypub.key_ownership.method", "actor_fetch");
299
+ return false;
300
+ }
301
+ for (const publicKeyId of actor.publicKeyIds) if (key.id != null && publicKeyId.href === key.id.href) {
302
+ span.setAttribute("activitypub.key_ownership.verified", true);
303
+ span.setAttribute("activitypub.key_ownership.method", "actor_fetch");
304
+ return true;
305
+ }
306
+ span.setAttribute("activitypub.key_ownership.verified", false);
307
+ span.setAttribute("activitypub.key_ownership.method", "actor_fetch");
308
+ return false;
309
+ } catch (error) {
310
+ span.recordException(error);
311
+ span.setStatus({
312
+ code: SpanStatusCode.ERROR,
313
+ message: String(error)
314
+ });
315
+ throw error;
316
+ } finally {
317
+ span.end();
318
+ }
319
+ });
284
320
  }
285
321
  /**
286
322
  * Gets the actor that owns the specified key. Returns `null` if the key has no
@@ -3,8 +3,8 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { Activity, DataIntegrityProof, Multikey, deno_default, getTypeId } from "./lookup-BwjF-fcb.js";
7
- import { fetchKey, validateCryptoKey } from "./key-DX9ebN5W.js";
6
+ import { Activity, DataIntegrityProof, Multikey, deno_default, getTypeId } from "./lookup-Dj9-mgOn.js";
7
+ import { fetchKey, validateCryptoKey } from "./key-x7E5PYI0.js";
8
8
  import { getLogger } from "@logtape/logtape";
9
9
  import { SpanStatusCode, trace } from "@opentelemetry/api";
10
10
  import { encodeHex } from "byte-encodings/hex";