@fedify/fedify 2.3.0-dev.994 → 2.3.0-pr.809.37

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 (138) hide show
  1. package/README.md +16 -7
  2. package/dist/{assert-DikXweDx.mjs → assert-OguE97r2.mjs} +1 -1
  3. package/dist/{assert_instance_of-C4Ri6VuN.mjs → assert_instance_of-DBC5X09g.mjs} +1 -1
  4. package/dist/{assert_not_equals--wG9hV7u.mjs → assert_not_equals-DkVK8oqV.mjs} +1 -1
  5. package/dist/{assert_rejects-B-qJtC9Z.mjs → assert_rejects-DN60FHPX.mjs} +28 -3
  6. package/dist/{assert_strict_equals-Dmjbg-bA.mjs → assert_strict_equals-XEgZAlrj.mjs} +1 -1
  7. package/dist/{assert_throws-4NwKEy2q.mjs → assert_throws-BOkhLGYc.mjs} +1 -1
  8. package/dist/{builder-yAlpiIqP.mjs → builder-Dl5Sdmc9.mjs} +96 -42
  9. package/dist/{chunk-nlSIicah.js → chunk-CRNNMoPX.js} +2 -2
  10. package/dist/circuit-breaker-CSWsyoef.mjs +337 -0
  11. package/dist/{client-z-8dc-e1.d.cts → client-CAM_bQXx.d.cts} +1 -0
  12. package/dist/{client-AtlibPOU.d.ts → client-CSddvgWN.d.ts} +1 -2
  13. package/dist/compat/mod.d.cts +2 -1
  14. package/dist/compat/mod.d.ts +2 -3
  15. package/dist/compat/mod.js +3 -3
  16. package/dist/compat/outgoing-jsonld.test.mjs +4 -4
  17. package/dist/compat/public-audience.test.mjs +4 -4
  18. package/dist/compat/transformers.test.mjs +5 -5
  19. package/dist/{context-BzH2-ajs.d.ts → context-BBVLF7lx.d.cts} +342 -269
  20. package/dist/{context-DJGagtNd.d.cts → context-BU6jSQdo.d.ts} +344 -266
  21. package/dist/{context-Dk_tacqz.mjs → context-DVoTs_wM.mjs} +64 -5
  22. package/dist/{deno-XBVlKnOX.mjs → deno-BID9qTPk.mjs} +1 -1
  23. package/dist/{docloader-DPp-X6gk.mjs → docloader-BYFuVwwi.mjs} +4 -4
  24. package/dist/{esm-DVILvP5e.mjs → esm-vrlUxr60.mjs} +4 -7
  25. package/dist/federation/builder.test.mjs +163 -11
  26. package/dist/federation/circuit-breaker.test.d.mts +2 -0
  27. package/dist/federation/circuit-breaker.test.mjs +446 -0
  28. package/dist/federation/collection.test.mjs +3 -3
  29. package/dist/federation/handler.test.mjs +1770 -29
  30. package/dist/federation/idempotency.test.mjs +5 -5
  31. package/dist/federation/inbox.test.mjs +4 -4
  32. package/dist/federation/keycache.test.mjs +5 -5
  33. package/dist/federation/kv.test.mjs +2 -2
  34. package/dist/federation/metrics.test.d.mts +2 -0
  35. package/dist/federation/metrics.test.mjs +634 -0
  36. package/dist/federation/middleware.test.mjs +4036 -146
  37. package/dist/federation/mod.cjs +195 -14
  38. package/dist/federation/mod.d.cts +6 -4
  39. package/dist/federation/mod.d.ts +6 -6
  40. package/dist/federation/mod.js +192 -14
  41. package/dist/federation/mq.test.mjs +176 -15
  42. package/dist/federation/negotiation.test.mjs +4 -4
  43. package/dist/federation/retry.test.mjs +3 -3
  44. package/dist/federation/router.test.mjs +190 -9
  45. package/dist/federation/send.test.mjs +153 -15
  46. package/dist/federation/temporal.test.d.mts +2 -0
  47. package/dist/federation/temporal.test.mjs +71 -0
  48. package/dist/federation/webfinger.test.mjs +150 -5
  49. package/dist/{http-B4rrzxtg.js → http-B47Jg9iX.js} +994 -64
  50. package/dist/{http-CSlLA54v.mjs → http-CO59u1Yk.mjs} +146 -47
  51. package/dist/{http-BrGqJDXL.cjs → http-CjZwUPiT.cjs} +1099 -61
  52. package/dist/{http-aQzN9Ayi.d.ts → http-VyDTd4G3.d.cts} +15 -3
  53. package/dist/{http-CrGuipxe.d.cts → http-lf8Hsd91.d.ts} +15 -1
  54. package/dist/{key-Bzx--sHD.mjs → key-Dqdlo3mG.mjs} +43 -18
  55. package/dist/{kv-CbLNp3zQ.d.cts → kv-D6hNiMTK.d.ts} +1 -0
  56. package/dist/{kv-cache-DI-Sk7-I.cjs → kv-cache-BQ1-zDKX.cjs} +20 -3
  57. package/dist/{kv-cache-EMIqoIuB.js → kv-cache-Dh2ZH9Gr.js} +20 -3
  58. package/dist/{kv-cache-U__xU4qR.mjs → kv-cache-DhLkLv0P.mjs} +21 -3
  59. package/dist/{kv-GFYnFoOl.d.ts → kv-gJ8LYbxX.d.cts} +1 -3
  60. package/dist/ld-JbCByP5P.mjs +626 -0
  61. package/dist/metrics-ColY3QKj.mjs +815 -0
  62. package/dist/{middleware-zjZ6AFCW.mjs → middleware-Buqzuiaf.mjs} +1 -1
  63. package/dist/{middleware-An4DjES4.cjs → middleware-CWQ3Yi07.cjs} +2318 -623
  64. package/dist/{middleware-K1g6bEkV.mjs → middleware-Cg4EyWsq.mjs} +1639 -373
  65. package/dist/{middleware-nidH7VZH.js → middleware-iAJY2aU-.js} +2260 -556
  66. package/dist/{mod-CR8soWa9.d.ts → mod-B0hW12_O.d.cts} +26 -4
  67. package/dist/mod-C0F6kvgS.d.cts +182 -0
  68. package/dist/{mod-Cr3f-ACa.d.cts → mod-COIAjwRS.d.ts} +26 -2
  69. package/dist/{mod-CMEbIaNh.d.cts → mod-DFvNJcNb.d.ts} +56 -4
  70. package/dist/mod-vPYVoa5n.d.ts +182 -0
  71. package/dist/{mod-CLgIXe9w.d.ts → mod-yvIXFAEi.d.cts} +56 -6
  72. package/dist/mod.cjs +9 -6
  73. package/dist/mod.d.cts +12 -10
  74. package/dist/mod.d.ts +12 -12
  75. package/dist/mod.js +11 -11
  76. package/dist/mq-D-nlpY04.d.ts +208 -0
  77. package/dist/mq-D8uSFzxe.d.cts +208 -0
  78. package/dist/{negotiation-SQvQgUqe.mjs → negotiation-DDstyBvc.mjs} +29 -0
  79. package/dist/nodeinfo/client.test.mjs +4 -4
  80. package/dist/nodeinfo/handler.test.mjs +4 -4
  81. package/dist/nodeinfo/mod.d.cts +2 -1
  82. package/dist/nodeinfo/mod.d.ts +2 -3
  83. package/dist/nodeinfo/mod.js +3 -3
  84. package/dist/nodeinfo/types.test.mjs +3 -3
  85. package/dist/otel/exporter.test.mjs +28 -25
  86. package/dist/otel/mod.cjs +6 -5
  87. package/dist/otel/mod.d.cts +5 -3
  88. package/dist/otel/mod.d.ts +5 -5
  89. package/dist/otel/mod.js +8 -7
  90. package/dist/{outgoing-jsonld-CNmZLixq.mjs → outgoing-jsonld-L_DbOaFe.mjs} +2 -2
  91. package/dist/{owner-C-tqfvxn.mjs → owner-B4LgOmzV.mjs} +2 -2
  92. package/dist/{owner-CptqhsOy.d.cts → owner-CnngXDNJ.d.ts} +2 -1
  93. package/dist/{owner-74ARJ5TL.d.ts → owner-DEvZuyOE.d.cts} +2 -3
  94. package/dist/{proof-BlmRPzrK.mjs → proof-BoSGOq9q.mjs} +26 -8
  95. package/dist/{proof-Bbbwf8_x.js → proof-CzhZuawt.js} +378 -15
  96. package/dist/{proof-BW89QMVB.cjs → proof-DvMI-3vq.cjs} +432 -15
  97. package/dist/runtime/mod.d.cts +1 -0
  98. package/dist/runtime/mod.d.ts +1 -2
  99. package/dist/runtime/mod.js +3 -3
  100. package/dist/{send-05pJLcb6.mjs → send-ByK1Q7DK.mjs} +72 -26
  101. package/dist/sig/http.test.mjs +356 -33
  102. package/dist/sig/key.test.mjs +103 -6
  103. package/dist/sig/ld.test.mjs +696 -7
  104. package/dist/sig/mod.cjs +2 -2
  105. package/dist/sig/mod.d.cts +4 -3
  106. package/dist/sig/mod.d.ts +4 -5
  107. package/dist/sig/mod.js +4 -4
  108. package/dist/sig/owner.test.mjs +6 -6
  109. package/dist/sig/proof.test.mjs +169 -8
  110. package/dist/{std__assert-CRDpx_HF.mjs → std__assert-BBjXFNOb.mjs} +5 -30
  111. package/dist/temporal-LpjyAjKb.mjs +95 -0
  112. package/dist/testing/mod.d.mts +110 -10
  113. package/dist/testing/mod.mjs +1 -2
  114. package/dist/{transformers-ve6e2xcg.js → transformers-BGMIq1cs.js} +2 -2
  115. package/dist/{types-hvL8ElAs.js → types-CAY3OdLq.js} +2 -2
  116. package/dist/utils/docloader.test.mjs +6 -6
  117. package/dist/utils/kv-cache.test.mjs +67 -2
  118. package/dist/utils/mod.cjs +1 -1
  119. package/dist/utils/mod.d.cts +2 -1
  120. package/dist/utils/mod.d.ts +2 -3
  121. package/dist/utils/mod.js +3 -3
  122. package/dist/vocab/cjs.test.mjs +1 -1
  123. package/dist/vocab/mod.d.cts +1 -0
  124. package/dist/vocab/mod.d.ts +1 -2
  125. package/dist/vocab/mod.js +2 -2
  126. package/package.json +16 -16
  127. package/dist/ld-DR78beiv.mjs +0 -279
  128. package/dist/middleware-BFBaR0mF.cjs +0 -4
  129. package/dist/mod-2d12ffz3.d.ts +0 -64
  130. package/dist/mod-D35TRn09.d.cts +0 -62
  131. package/dist/router-CrMLXoOr.mjs +0 -114
  132. package/dist/{activity-listener-ell7W1s9.mjs → activity-listener-tztVvlNb.mjs} +0 -0
  133. package/dist/{assert_equals-Ew3jOFa3.mjs → assert_equals-C-ZRDbaf.mjs} +0 -0
  134. package/dist/{client-D_1QpnWt.mjs → client-ByXmQhYD.mjs} +1 -1
  135. package/dist/{collection-D-HqUuA2.mjs → collection-Cc3DVAhE.mjs} +0 -0
  136. package/dist/{keycache-EGATflN-.mjs → keycache-BeU0LCII.mjs} +0 -0
  137. package/dist/{public-audience-DYFHzm_c.mjs → public-audience-Cvbr2Gzt.mjs} +1 -1
  138. /package/dist/{retry-bMXBL97A.mjs → retry-CXg_MBI-.mjs} +0 -0
@@ -1,10 +1,10 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { t as esm_default } from "../esm-DVILvP5e.mjs";
5
- import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
- import "../std__assert-CRDpx_HF.mjs";
7
- import { a as parseProtocol, c as parseUsage, i as parseOutboundService, n as parseInboundService, o as parseServices, r as parseNodeInfo, s as parseSoftware, t as getNodeInfo } from "../client-D_1QpnWt.mjs";
4
+ import { t as esm_default } from "../esm-vrlUxr60.mjs";
5
+ import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
6
+ import "../std__assert-BBjXFNOb.mjs";
7
+ import { a as parseProtocol, c as parseUsage, i as parseOutboundService, n as parseInboundService, o as parseServices, r as parseNodeInfo, s as parseSoftware, t as getNodeInfo } from "../client-ByXmQhYD.mjs";
8
8
  import { test } from "@fedify/fixture";
9
9
  //#region src/nodeinfo/client.test.ts
10
10
  test("getNodeInfo()", async (t) => {
@@ -1,11 +1,11 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { r as createRequestContext } from "../context-Dk_tacqz.mjs";
5
- import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
- import "../std__assert-CRDpx_HF.mjs";
4
+ import { r as createRequestContext } from "../context-DVoTs_wM.mjs";
5
+ import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
6
+ import "../std__assert-BBjXFNOb.mjs";
7
7
  import { t as MemoryKvStore } from "../kv-rV3vodCc.mjs";
8
- import { _ as handleNodeInfoJrd, g as handleNodeInfo, o as createFederation } from "../middleware-K1g6bEkV.mjs";
8
+ import { _ as handleNodeInfo, o as createFederation, v as handleNodeInfoJrd } from "../middleware-Cg4EyWsq.mjs";
9
9
  import { test } from "@fedify/fixture";
10
10
  //#region src/nodeinfo/handler.test.ts
11
11
  test("handleNodeInfo()", async () => {
@@ -1,2 +1,3 @@
1
- import { a as InboundService, c as OutboundService, d as Software, f as Usage, i as parseNodeInfo, l as Protocol, n as ParseNodeInfoOptions, o as JsonValue, p as nodeInfoToJson, r as getNodeInfo, s as NodeInfo, t as GetNodeInfoOptions, u as Services } from "../client-z-8dc-e1.cjs";
1
+ /// <reference lib="esnext.temporal" />
2
+ import { a as InboundService, c as OutboundService, d as Software, f as Usage, i as parseNodeInfo, l as Protocol, n as ParseNodeInfoOptions, o as JsonValue, p as nodeInfoToJson, r as getNodeInfo, s as NodeInfo, t as GetNodeInfoOptions, u as Services } from "../client-CAM_bQXx.cjs";
2
3
  export { type GetNodeInfoOptions, InboundService, JsonValue, NodeInfo, OutboundService, type ParseNodeInfoOptions, Protocol, Services, Software, Usage, getNodeInfo, nodeInfoToJson, parseNodeInfo };
@@ -1,4 +1,3 @@
1
- import { Temporal } from "@js-temporal/polyfill";
2
- import { URLPattern } from "urlpattern-polyfill";
3
- import { a as InboundService, c as OutboundService, d as Software, f as Usage, i as parseNodeInfo, l as Protocol, n as ParseNodeInfoOptions, o as JsonValue, p as nodeInfoToJson, r as getNodeInfo, s as NodeInfo, t as GetNodeInfoOptions, u as Services } from "../client-AtlibPOU.js";
1
+ /// <reference lib="esnext.temporal" />
2
+ import { a as InboundService, c as OutboundService, d as Software, f as Usage, i as parseNodeInfo, l as Protocol, n as ParseNodeInfoOptions, o as JsonValue, p as nodeInfoToJson, r as getNodeInfo, s as NodeInfo, t as GetNodeInfoOptions, u as Services } from "../client-CSddvgWN.js";
4
3
  export { type GetNodeInfoOptions, InboundService, JsonValue, NodeInfo, OutboundService, type ParseNodeInfoOptions, Protocol, Services, Software, Usage, getNodeInfo, nodeInfoToJson, parseNodeInfo };
@@ -1,4 +1,4 @@
1
- import "@js-temporal/polyfill";
2
- import "urlpattern-polyfill";
3
- import { n as getNodeInfo, r as parseNodeInfo, t as nodeInfoToJson } from "../types-hvL8ElAs.js";
1
+ import { Temporal } from "@js-temporal/polyfill";
2
+ import { URLPattern } from "urlpattern-polyfill";
3
+ import { n as getNodeInfo, r as parseNodeInfo, t as nodeInfoToJson } from "../types-CAY3OdLq.js";
4
4
  export { getNodeInfo, nodeInfoToJson, parseNodeInfo };
@@ -1,9 +1,9 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
- import "../std__assert-CRDpx_HF.mjs";
6
- import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
4
+ import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
5
+ import "../std__assert-BBjXFNOb.mjs";
6
+ import { t as assertThrows } from "../assert_throws-BOkhLGYc.mjs";
7
7
  import { t as nodeInfoToJson } from "../types-J53Kw7so.mjs";
8
8
  import { test } from "@fedify/fixture";
9
9
  //#region src/nodeinfo/types.test.ts
@@ -1,13 +1,13 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
- import "../std__assert-CRDpx_HF.mjs";
4
+ import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
5
+ import "../std__assert-BBjXFNOb.mjs";
6
6
  import { t as MemoryKvStore } from "../kv-rV3vodCc.mjs";
7
- import { test } from "@fedify/fixture";
8
- import { SpanKind, SpanStatusCode, TraceFlags } from "@opentelemetry/api";
9
7
  import { getLogger } from "@logtape/logtape";
10
8
  import { ExportResultCode } from "@opentelemetry/core";
9
+ import { SpanKind, SpanStatusCode, TraceFlags } from "@opentelemetry/api";
10
+ import { test } from "@fedify/fixture";
11
11
  //#region src/otel/exporter.ts
12
12
  /**
13
13
  * A SpanExporter that persists ActivityPub activity traces to a
@@ -159,11 +159,10 @@ var FedifySpanExporter = class {
159
159
  const attrs = event.attributes;
160
160
  if (attrs == null) return null;
161
161
  const activityJson = attrs["activitypub.activity.json"];
162
- if (typeof activityJson !== "string") return null;
163
162
  let activityType = "Unknown";
164
163
  let activityId;
165
164
  let actorId;
166
- try {
165
+ if (typeof activityJson === "string") try {
167
166
  const activity = JSON.parse(activityJson);
168
167
  activityType = activity.type ?? "Unknown";
169
168
  activityId = activity.id;
@@ -172,15 +171,17 @@ var FedifySpanExporter = class {
172
171
  } catch {}
173
172
  const inboxUrl = attrs["activitypub.inbox.url"];
174
173
  const explicitActivityId = attrs["activitypub.activity.id"];
174
+ const explicitActivityType = attrs["activitypub.activity.type"];
175
+ const explicitActorId = attrs["activitypub.actor.id"];
175
176
  return {
176
177
  traceId,
177
178
  spanId,
178
179
  parentSpanId,
179
180
  direction: "outbound",
180
- activityType,
181
+ activityType: typeof explicitActivityType === "string" && explicitActivityType !== "" ? explicitActivityType : activityType,
181
182
  activityId: activityId ?? (typeof explicitActivityId === "string" && explicitActivityId !== "" ? explicitActivityId : void 0),
182
- actorId,
183
- activityJson,
183
+ actorId: typeof explicitActorId === "string" && explicitActorId !== "" ? explicitActorId : actorId,
184
+ ...typeof activityJson === "string" ? { activityJson } : {},
184
185
  timestamp: (/* @__PURE__ */ new Date(event.time[0] * 1e3 + event.time[1] / 1e6)).toISOString(),
185
186
  inboxUrl: typeof inboxUrl === "string" ? inboxUrl : void 0
186
187
  };
@@ -316,14 +317,17 @@ function createActivityReceivedEvent(options) {
316
317
  };
317
318
  }
318
319
  function createActivitySentEvent(options) {
320
+ const attributes = {
321
+ "activitypub.inbox.url": options.inboxUrl,
322
+ "activitypub.activity.id": options.activityId ?? ""
323
+ };
324
+ if (options.activityType != null) attributes["activitypub.activity.type"] = options.activityType;
325
+ if (options.actorId != null) attributes["activitypub.actor.id"] = options.actorId;
326
+ if (options.activityJson != null) attributes["activitypub.activity.json"] = options.activityJson;
319
327
  return {
320
328
  name: "activitypub.activity.sent",
321
329
  time: [17e8, 5e8],
322
- attributes: {
323
- "activitypub.activity.json": options.activityJson,
324
- "activitypub.inbox.url": options.inboxUrl,
325
- "activitypub.activity.id": options.activityId ?? ""
326
- }
330
+ attributes
327
331
  };
328
332
  }
329
333
  test("FedifySpanExporter", async (t) => {
@@ -376,21 +380,18 @@ test("FedifySpanExporter", async (t) => {
376
380
  const traceId = "trace789";
377
381
  const spanId = "span012";
378
382
  const inboxUrl = "https://example.com/users/alice/inbox";
379
- const activity = {
380
- "@context": "https://www.w3.org/ns/activitystreams",
381
- type: "Follow",
382
- id: "https://myserver.com/activities/789",
383
- actor: "https://myserver.com/users/bob",
384
- object: "https://example.com/users/alice"
385
- };
383
+ const activityId = "https://myserver.com/activities/789";
384
+ const activityType = "https://www.w3.org/ns/activitystreams#Accept";
385
+ const actorId = "https://myserver.com/users/bob";
386
386
  const span = createMockSpan({
387
387
  traceId,
388
388
  spanId,
389
389
  name: "activitypub.send_activity",
390
390
  events: [createActivitySentEvent({
391
- activityJson: JSON.stringify(activity),
392
391
  inboxUrl,
393
- activityId: activity.id
392
+ activityId,
393
+ activityType,
394
+ actorId
394
395
  })]
395
396
  });
396
397
  await new Promise((resolve) => {
@@ -404,8 +405,10 @@ test("FedifySpanExporter", async (t) => {
404
405
  assertEquals(activities[0].traceId, traceId);
405
406
  assertEquals(activities[0].spanId, spanId);
406
407
  assertEquals(activities[0].direction, "outbound");
407
- assertEquals(activities[0].activityType, activity.type);
408
- assertEquals(activities[0].activityId, activity.id);
408
+ assertEquals(activities[0].activityType, activityType);
409
+ assertEquals(activities[0].activityId, activityId);
410
+ assertEquals(activities[0].actorId, actorId);
411
+ assertEquals(activities[0].activityJson, void 0);
409
412
  assertEquals(activities[0].inboxUrl, inboxUrl);
410
413
  });
411
414
  await t.step("export() ignores spans without activity events", async () => {
package/dist/otel/mod.cjs CHANGED
@@ -155,11 +155,10 @@ var FedifySpanExporter = class {
155
155
  const attrs = event.attributes;
156
156
  if (attrs == null) return null;
157
157
  const activityJson = attrs["activitypub.activity.json"];
158
- if (typeof activityJson !== "string") return null;
159
158
  let activityType = "Unknown";
160
159
  let activityId;
161
160
  let actorId;
162
- try {
161
+ if (typeof activityJson === "string") try {
163
162
  const activity = JSON.parse(activityJson);
164
163
  activityType = activity.type ?? "Unknown";
165
164
  activityId = activity.id;
@@ -168,15 +167,17 @@ var FedifySpanExporter = class {
168
167
  } catch {}
169
168
  const inboxUrl = attrs["activitypub.inbox.url"];
170
169
  const explicitActivityId = attrs["activitypub.activity.id"];
170
+ const explicitActivityType = attrs["activitypub.activity.type"];
171
+ const explicitActorId = attrs["activitypub.actor.id"];
171
172
  return {
172
173
  traceId,
173
174
  spanId,
174
175
  parentSpanId,
175
176
  direction: "outbound",
176
- activityType,
177
+ activityType: typeof explicitActivityType === "string" && explicitActivityType !== "" ? explicitActivityType : activityType,
177
178
  activityId: activityId ?? (typeof explicitActivityId === "string" && explicitActivityId !== "" ? explicitActivityId : void 0),
178
- actorId,
179
- activityJson,
179
+ actorId: typeof explicitActorId === "string" && explicitActorId !== "" ? explicitActorId : actorId,
180
+ ...typeof activityJson === "string" ? { activityJson } : {},
180
181
  timestamp: (/* @__PURE__ */ new Date(event.time[0] * 1e3 + event.time[1] / 1e6)).toISOString(),
181
182
  inboxUrl: typeof inboxUrl === "string" ? inboxUrl : void 0
182
183
  };
@@ -1,4 +1,5 @@
1
- import { n as KvStore, t as KvKey } from "../kv-CbLNp3zQ.cjs";
1
+ /// <reference lib="esnext.temporal" />
2
+ import { n as KvStore, t as KvKey } from "../kv-gJ8LYbxX.cjs";
2
3
  import { ReadableSpan, SpanExporter } from "@opentelemetry/sdk-trace-base";
3
4
  import { ExportResultCode } from "@opentelemetry/core";
4
5
 
@@ -77,9 +78,10 @@ interface TraceActivityRecord {
77
78
  */
78
79
  readonly actorId?: string;
79
80
  /**
80
- * The full JSON representation of the activity.
81
+ * The full JSON representation of the activity, if the span event included
82
+ * it.
81
83
  */
82
- readonly activityJson: string;
84
+ readonly activityJson?: string;
83
85
  /**
84
86
  * Whether the activity was verified (for inbound activities).
85
87
  */
@@ -1,6 +1,5 @@
1
- import { Temporal } from "@js-temporal/polyfill";
2
- import { URLPattern } from "urlpattern-polyfill";
3
- import { n as KvStore, t as KvKey } from "../kv-GFYnFoOl.js";
1
+ /// <reference lib="esnext.temporal" />
2
+ import { n as KvStore, t as KvKey } from "../kv-D6hNiMTK.js";
4
3
  import { ExportResultCode } from "@opentelemetry/core";
5
4
  import { ReadableSpan, SpanExporter } from "@opentelemetry/sdk-trace-base";
6
5
 
@@ -79,9 +78,10 @@ interface TraceActivityRecord {
79
78
  */
80
79
  readonly actorId?: string;
81
80
  /**
82
- * The full JSON representation of the activity.
81
+ * The full JSON representation of the activity, if the span event included
82
+ * it.
83
83
  */
84
- readonly activityJson: string;
84
+ readonly activityJson?: string;
85
85
  /**
86
86
  * Whether the activity was verified (for inbound activities).
87
87
  */
package/dist/otel/mod.js CHANGED
@@ -1,5 +1,5 @@
1
- import "@js-temporal/polyfill";
2
- import "urlpattern-polyfill";
1
+ import { Temporal } from "@js-temporal/polyfill";
2
+ import { URLPattern } from "urlpattern-polyfill";
3
3
  import { getLogger } from "@logtape/logtape";
4
4
  import { ExportResultCode } from "@opentelemetry/core";
5
5
  //#region src/otel/exporter.ts
@@ -153,11 +153,10 @@ var FedifySpanExporter = class {
153
153
  const attrs = event.attributes;
154
154
  if (attrs == null) return null;
155
155
  const activityJson = attrs["activitypub.activity.json"];
156
- if (typeof activityJson !== "string") return null;
157
156
  let activityType = "Unknown";
158
157
  let activityId;
159
158
  let actorId;
160
- try {
159
+ if (typeof activityJson === "string") try {
161
160
  const activity = JSON.parse(activityJson);
162
161
  activityType = activity.type ?? "Unknown";
163
162
  activityId = activity.id;
@@ -166,15 +165,17 @@ var FedifySpanExporter = class {
166
165
  } catch {}
167
166
  const inboxUrl = attrs["activitypub.inbox.url"];
168
167
  const explicitActivityId = attrs["activitypub.activity.id"];
168
+ const explicitActivityType = attrs["activitypub.activity.type"];
169
+ const explicitActorId = attrs["activitypub.actor.id"];
169
170
  return {
170
171
  traceId,
171
172
  spanId,
172
173
  parentSpanId,
173
174
  direction: "outbound",
174
- activityType,
175
+ activityType: typeof explicitActivityType === "string" && explicitActivityType !== "" ? explicitActivityType : activityType,
175
176
  activityId: activityId ?? (typeof explicitActivityId === "string" && explicitActivityId !== "" ? explicitActivityId : void 0),
176
- actorId,
177
- activityJson,
177
+ actorId: typeof explicitActorId === "string" && explicitActorId !== "" ? explicitActorId : actorId,
178
+ ...typeof activityJson === "string" ? { activityJson } : {},
178
179
  timestamp: (/* @__PURE__ */ new Date(event.time[0] * 1e3 + event.time[1] / 1e6)).toISOString(),
179
180
  inboxUrl: typeof inboxUrl === "string" ? inboxUrl : void 0
180
181
  };
@@ -1,9 +1,9 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as preloadedOnlyDocumentLoader, t as normalizePublicAudience } from "./public-audience-DYFHzm_c.mjs";
5
- import { preloadedContexts } from "@fedify/vocab-runtime";
4
+ import { n as preloadedOnlyDocumentLoader, t as normalizePublicAudience } from "./public-audience-Cvbr2Gzt.mjs";
6
5
  import { getLogger } from "@logtape/logtape";
6
+ import { preloadedContexts } from "@fedify/vocab-runtime";
7
7
  import jsonld from "@fedify/vocab-runtime/jsonld";
8
8
  //#region src/compat/outgoing-jsonld.ts
9
9
  const logger = getLogger([
@@ -1,8 +1,8 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-XBVlKnOX.mjs";
5
- import "./key-Bzx--sHD.mjs";
4
+ import { n as version, t as name } from "./deno-BID9qTPk.mjs";
5
+ import "./key-Dqdlo3mG.mjs";
6
6
  import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
7
7
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
8
8
  import { getDocumentLoader } from "@fedify/vocab-runtime";
@@ -1,6 +1,7 @@
1
+ /// <reference lib="esnext.temporal" />
1
2
  import { Activity, Actor, CryptographicKey } from "@fedify/vocab";
2
- import { DocumentLoader } from "@fedify/vocab-runtime";
3
3
  import { TracerProvider } from "@opentelemetry/api";
4
+ import { DocumentLoader } from "@fedify/vocab-runtime";
4
5
 
5
6
  //#region src/sig/owner.d.ts
6
7
  /**
@@ -1,8 +1,7 @@
1
- import { Temporal } from "@js-temporal/polyfill";
2
- import { URLPattern } from "urlpattern-polyfill";
1
+ /// <reference lib="esnext.temporal" />
3
2
  import { Activity, Actor, CryptographicKey } from "@fedify/vocab";
4
- import { TracerProvider } from "@opentelemetry/api";
5
3
  import { DocumentLoader } from "@fedify/vocab-runtime";
4
+ import { TracerProvider } from "@opentelemetry/api";
6
5
 
7
6
  //#region src/sig/owner.d.ts
8
7
  /**
@@ -1,16 +1,26 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-XBVlKnOX.mjs";
5
- import { n as fetchKey, o as validateCryptoKey } from "./key-Bzx--sHD.mjs";
6
- import { n as preloadedOnlyDocumentLoader } from "./public-audience-DYFHzm_c.mjs";
7
- import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-CNmZLixq.mjs";
4
+ import { n as version, t as name } from "./deno-BID9qTPk.mjs";
5
+ import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-ColY3QKj.mjs";
6
+ import { n as fetchKey, o as validateCryptoKey } from "./key-Dqdlo3mG.mjs";
7
+ import { n as preloadedOnlyDocumentLoader } from "./public-audience-Cvbr2Gzt.mjs";
8
+ import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-L_DbOaFe.mjs";
9
+ import { getLogger } from "@logtape/logtape";
8
10
  import { Activity, DataIntegrityProof, Multikey, getTypeId } from "@fedify/vocab";
9
11
  import { SpanStatusCode, trace } from "@opentelemetry/api";
10
- import { getLogger } from "@logtape/logtape";
11
12
  import { encodeHex } from "byte-encodings/hex";
12
13
  import serialize from "json-canon";
13
14
  //#region src/sig/proof.ts
15
+ /**
16
+ * Known Object Integrity Proof `cryptosuite` values, used to keep
17
+ * `object_integrity_proofs.cryptosuite` on a bounded set of spec-defined
18
+ * string values. Fedify currently signs and verifies only
19
+ * `eddsa-jcs-2022`; other values come in only from external proofs and are
20
+ * dropped from the metric attribute to avoid attacker-controlled
21
+ * cardinality.
22
+ */
23
+ const OIP_KNOWN_CRYPTOSUITES = new Set(["eddsa-jcs-2022"]);
14
24
  const logger = getLogger([
15
25
  "fedify",
16
26
  "sig",
@@ -137,6 +147,10 @@ async function signObject(object, privateKey, keyId, options = {}) {
137
147
  */
138
148
  async function verifyProof(jsonLd, proof, options = {}) {
139
149
  return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("object_integrity_proofs.verify", async (span) => {
150
+ const start = performance.now();
151
+ let verified = false;
152
+ let threw = false;
153
+ const cryptosuite = proof.cryptosuite != null && OIP_KNOWN_CRYPTOSUITES.has(proof.cryptosuite) ? proof.cryptosuite : void 0;
140
154
  if (span.isRecording()) {
141
155
  if (proof.cryptosuite != null) span.setAttribute("object_integrity_proofs.cryptosuite", proof.cryptosuite);
142
156
  if (proof.verificationMethodId != null) span.setAttribute("object_integrity_proofs.key_id", proof.verificationMethodId.href);
@@ -145,21 +159,25 @@ async function verifyProof(jsonLd, proof, options = {}) {
145
159
  try {
146
160
  const key = await verifyProofInternal(jsonLd, proof, options);
147
161
  if (key == null) span.setStatus({ code: SpanStatusCode.ERROR });
162
+ else verified = true;
148
163
  return key;
149
164
  } catch (error) {
165
+ threw = true;
150
166
  span.setStatus({
151
167
  code: SpanStatusCode.ERROR,
152
168
  message: String(error)
153
169
  });
154
170
  throw error;
155
171
  } finally {
172
+ const classified = threw ? "error" : verified ? "verified" : "rejected";
173
+ getFederationMetrics(options.meterProvider).recordSignatureVerificationDuration(getDurationMs(start), "object_integrity", classified, { cryptosuite });
156
174
  span.end();
157
175
  }
158
176
  });
159
177
  }
160
178
  async function verifyProofInternal(jsonLd, proof, options) {
161
179
  if (typeof jsonLd !== "object" || jsonLd == null || Array.isArray(jsonLd) || proof.cryptosuite !== "eddsa-jcs-2022" || proof.verificationMethodId == null || proof.proofPurpose !== "assertionMethod" || proof.proofValue == null || proof.created == null) return null;
162
- const publicKeyPromise = fetchKey(proof.verificationMethodId, Multikey, options);
180
+ const publicKeyPromise = measureSignatureKeyFetch(options.meterProvider, "object_integrity", () => fetchKey(proof.verificationMethodId, Multikey, options));
163
181
  const proofConfig = {
164
182
  "@context": jsonLd["@context"],
165
183
  type: "DataIntegrityProof",
@@ -199,7 +217,7 @@ async function verifyProofInternal(jsonLd, proof, options) {
199
217
  proof,
200
218
  keyId: proof.verificationMethodId.href
201
219
  });
202
- return await verifyProof(jsonLd, proof, {
220
+ return await verifyProofInternal(jsonLd, proof, {
203
221
  ...options,
204
222
  keyCache: {
205
223
  get: () => Promise.resolve(void 0),
@@ -230,7 +248,7 @@ async function verifyProofInternal(jsonLd, proof, options) {
230
248
  keyId: proof.verificationMethodId.href,
231
249
  proof
232
250
  });
233
- return await verifyProof(jsonLd, proof, {
251
+ return await verifyProofInternal(jsonLd, proof, {
234
252
  ...options,
235
253
  keyCache: {
236
254
  get: () => Promise.resolve(void 0),