@fedify/fedify 2.5.0-dev.2664 → 2.5.0-dev.2710

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 (266) hide show
  1. package/dist/compat/mod.d.cts +1 -1
  2. package/dist/compat/mod.d.ts +1 -1
  3. package/dist/{context-xrqq4Hrq.d.ts → context-CuLvR1Os.d.ts} +2 -2
  4. package/dist/{context-C1NqcIct.d.cts → context-apq0IBg2.d.cts} +2 -2
  5. package/dist/federation/mod.cjs +1 -1
  6. package/dist/federation/mod.d.cts +3 -3
  7. package/dist/federation/mod.d.ts +3 -3
  8. package/dist/federation/mod.js +1 -1
  9. package/dist/{federation-FbwcnRHg.cjs → federation-JvzYDx0P.cjs} +5 -5
  10. package/dist/{http-DbvOPsFZ.cjs → http-BG5cDmTS.cjs} +1 -1
  11. package/dist/{http-CWn0K5jD.js → http-MUf125Jc.js} +1 -1
  12. package/dist/{key-dwwAg5bA.d.ts → key-BZw-YiK5.d.ts} +2 -2
  13. package/dist/{key-DlHT4R6k.d.cts → key-D5fbQkKM.d.cts} +2 -2
  14. package/dist/{kv-cache-B-fOrhb-.cjs → kv-cache-A2po7h0_.cjs} +1 -1
  15. package/dist/{kv-cache-BC837EqC.js → kv-cache-CbWc1BZA.js} +1 -1
  16. package/dist/{ld-CWVpo_NM.d.cts → ld-DEi9ERHf.d.cts} +1 -1
  17. package/dist/{ld-o4LnhCYY.d.ts → ld-DlC78ioJ.d.ts} +1 -1
  18. package/dist/{middleware-n2UrG62B.js → middleware-DzzdJ7Wz.js} +5 -5
  19. package/dist/{mod-D22ZsiKi.d.ts → mod-BJRtsw7l.d.ts} +1 -1
  20. package/dist/{mod-C1nT74IG.d.cts → mod-BamwZjJx.d.cts} +1 -1
  21. package/dist/{mod-DO0epJGH.d.ts → mod-BkTi19dI.d.ts} +1 -1
  22. package/dist/{mod-CQC9xlLZ.d.ts → mod-CMtF0VVy.d.ts} +1 -1
  23. package/dist/{mod-YvA4Rk8J.d.cts → mod-D2Z9MiCm.d.cts} +1 -1
  24. package/dist/{mod-TwiQgEf3.d.cts → mod-DB2NOzQF.d.cts} +1 -1
  25. package/dist/mod.cjs +4 -4
  26. package/dist/mod.d.cts +6 -6
  27. package/dist/mod.d.ts +6 -6
  28. package/dist/mod.js +4 -4
  29. package/dist/{portable-collection-DQhIkX5a.js → portable-collection-CAer9RWN.js} +1 -1
  30. package/dist/{portable-collection-DseoiPPj.cjs → portable-collection-d8w7TCn9.cjs} +1 -1
  31. package/dist/sig/mod.cjs +2 -2
  32. package/dist/sig/mod.d.cts +3 -3
  33. package/dist/sig/mod.d.ts +3 -3
  34. package/dist/sig/mod.js +2 -2
  35. package/dist/utils/mod.cjs +1 -1
  36. package/dist/utils/mod.d.cts +1 -1
  37. package/dist/utils/mod.d.ts +1 -1
  38. package/dist/utils/mod.js +1 -1
  39. package/package.json +22 -9
  40. package/skills/fedify/SKILL.md +10 -0
  41. package/dist/accept-CPVqki78.mjs +0 -145
  42. package/dist/activity-listener-CELFAodc.mjs +0 -44
  43. package/dist/assert-D1Eafmd_.mjs +0 -23
  44. package/dist/assert_equals-Z6IcEbWU.mjs +0 -987
  45. package/dist/assert_exists-cffSpJ7X.mjs +0 -28
  46. package/dist/assert_false-CPdRnc3E.mjs +0 -23
  47. package/dist/assert_greater_or_equal-BlafOF4-.mjs +0 -31
  48. package/dist/assert_instance_of-mrXWWNY-.mjs +0 -37
  49. package/dist/assert_not_equals-CpPK2t89.mjs +0 -30
  50. package/dist/assert_rejects-CTptdYck.mjs +0 -39
  51. package/dist/assert_strict_equals-CYvBmkpC.mjs +0 -42
  52. package/dist/assert_throws-BYITOvPO.mjs +0 -74
  53. package/dist/assertion_error-B-cx0fFA.mjs +0 -31
  54. package/dist/audience-CHQ-FlLD.mjs +0 -95
  55. package/dist/builder-CGJ-NXcZ.mjs +0 -911
  56. package/dist/circuit-breaker-XJ53md4S.mjs +0 -544
  57. package/dist/circuit-breaker-test-utils-DW6YC_Pe.mjs +0 -14
  58. package/dist/client-5SIFzW3q.mjs +0 -441
  59. package/dist/codec-C6rTrpIp.mjs +0 -147
  60. package/dist/collection-CnnP1UAv.mjs +0 -44
  61. package/dist/compat/outgoing-jsonld.test.d.mts +0 -2
  62. package/dist/compat/outgoing-jsonld.test.mjs +0 -257
  63. package/dist/compat/public-audience.test.d.mts +0 -2
  64. package/dist/compat/public-audience.test.mjs +0 -187
  65. package/dist/compat/secured-document.test.d.mts +0 -2
  66. package/dist/compat/secured-document.test.mjs +0 -58
  67. package/dist/compat/transformers.test.d.mts +0 -2
  68. package/dist/compat/transformers.test.mjs +0 -62
  69. package/dist/compound-proof-CnzwOddk.mjs +0 -1019
  70. package/dist/context-LgGFFSz7.mjs +0 -146
  71. package/dist/deno-eoFpPk7W.mjs +0 -8
  72. package/dist/dist-_geWsuaI.mjs +0 -189
  73. package/dist/docloader-DwkipyL1.mjs +0 -136
  74. package/dist/esm-BHXXx4Wx.mjs +0 -1233
  75. package/dist/exporter-DVG68ozH.mjs +0 -263
  76. package/dist/federation/audience.test.d.mts +0 -2
  77. package/dist/federation/audience.test.mjs +0 -130
  78. package/dist/federation/builder.test.d.mts +0 -2
  79. package/dist/federation/builder.test.mjs +0 -396
  80. package/dist/federation/circuit-breaker.test.d.mts +0 -2
  81. package/dist/federation/circuit-breaker.test.mjs +0 -1277
  82. package/dist/federation/collection.test.d.mts +0 -2
  83. package/dist/federation/collection.test.mjs +0 -21
  84. package/dist/federation/compound-fanout.test.d.mts +0 -2
  85. package/dist/federation/compound-fanout.test.mjs +0 -231
  86. package/dist/federation/handler-compound-proof.test.d.mts +0 -2
  87. package/dist/federation/handler-compound-proof.test.mjs +0 -384
  88. package/dist/federation/handler.test.d.mts +0 -2
  89. package/dist/federation/handler.test.mjs +0 -5445
  90. package/dist/federation/hashlink-media.test.d.mts +0 -2
  91. package/dist/federation/hashlink-media.test.mjs +0 -422
  92. package/dist/federation/idempotency.test.d.mts +0 -2
  93. package/dist/federation/idempotency.test.mjs +0 -207
  94. package/dist/federation/inbox-actorless.test.d.mts +0 -2
  95. package/dist/federation/inbox-actorless.test.mjs +0 -522
  96. package/dist/federation/inbox-authentication.test.d.mts +0 -2
  97. package/dist/federation/inbox-authentication.test.mjs +0 -220
  98. package/dist/federation/inbox-report.test.d.mts +0 -2
  99. package/dist/federation/inbox-report.test.mjs +0 -719
  100. package/dist/federation/inbox-view.test.d.mts +0 -2
  101. package/dist/federation/inbox-view.test.mjs +0 -369
  102. package/dist/federation/inbox.test.d.mts +0 -2
  103. package/dist/federation/inbox.test.mjs +0 -139
  104. package/dist/federation/keycache.test.d.mts +0 -2
  105. package/dist/federation/keycache.test.mjs +0 -337
  106. package/dist/federation/kv.test.d.mts +0 -2
  107. package/dist/federation/kv.test.mjs +0 -88
  108. package/dist/federation/metrics.test.d.mts +0 -2
  109. package/dist/federation/metrics.test.mjs +0 -634
  110. package/dist/federation/middleware.test.d.mts +0 -2
  111. package/dist/federation/middleware.test.mjs +0 -9314
  112. package/dist/federation/mq.test.d.mts +0 -2
  113. package/dist/federation/mq.test.mjs +0 -591
  114. package/dist/federation/negotiation.test.d.mts +0 -2
  115. package/dist/federation/negotiation.test.mjs +0 -18
  116. package/dist/federation/outbound-body.test.d.mts +0 -2
  117. package/dist/federation/outbound-body.test.mjs +0 -149
  118. package/dist/federation/outbound-capture.test.d.mts +0 -2
  119. package/dist/federation/outbound-capture.test.mjs +0 -394
  120. package/dist/federation/outbound-dispatch.test.d.mts +0 -2
  121. package/dist/federation/outbound-dispatch.test.mjs +0 -368
  122. package/dist/federation/outbound-document.test.d.mts +0 -2
  123. package/dist/federation/outbound-document.test.mjs +0 -171
  124. package/dist/federation/outbound-provenance.test.d.mts +0 -2
  125. package/dist/federation/outbound-provenance.test.mjs +0 -543
  126. package/dist/federation/outbound-report.test.d.mts +0 -2
  127. package/dist/federation/outbound-report.test.mjs +0 -5475
  128. package/dist/federation/outbound-workers.test.d.mts +0 -2
  129. package/dist/federation/outbound-workers.test.mjs +0 -64
  130. package/dist/federation/outbound-workflow.test.d.mts +0 -2
  131. package/dist/federation/outbound-workflow.test.mjs +0 -154
  132. package/dist/federation/outgoing-proof.test.d.mts +0 -2
  133. package/dist/federation/outgoing-proof.test.mjs +0 -933
  134. package/dist/federation/portable-actor.test.d.mts +0 -2
  135. package/dist/federation/portable-actor.test.mjs +0 -496
  136. package/dist/federation/portable-chain.test.d.mts +0 -2
  137. package/dist/federation/portable-chain.test.mjs +0 -370
  138. package/dist/federation/portable-collection.test.d.mts +0 -2
  139. package/dist/federation/portable-collection.test.mjs +0 -832
  140. package/dist/federation/portable-delivery.test.d.mts +0 -2
  141. package/dist/federation/portable-delivery.test.mjs +0 -845
  142. package/dist/federation/portable-gateway-keys.test.d.mts +0 -2
  143. package/dist/federation/portable-gateway-keys.test.mjs +0 -692
  144. package/dist/federation/portable-inbox.test.d.mts +0 -2
  145. package/dist/federation/portable-inbox.test.mjs +0 -1960
  146. package/dist/federation/portable-parse-uri.test.d.mts +0 -2
  147. package/dist/federation/portable-parse-uri.test.mjs +0 -348
  148. package/dist/federation/portable-route-activity.test.d.mts +0 -2
  149. package/dist/federation/portable-route-activity.test.mjs +0 -259
  150. package/dist/federation/portable.test.d.mts +0 -2
  151. package/dist/federation/portable.test.mjs +0 -1072
  152. package/dist/federation/retry.test.d.mts +0 -2
  153. package/dist/federation/retry.test.mjs +0 -42
  154. package/dist/federation/router.test.d.mts +0 -2
  155. package/dist/federation/router.test.mjs +0 -123
  156. package/dist/federation/send.test.d.mts +0 -2
  157. package/dist/federation/send.test.mjs +0 -1421
  158. package/dist/federation/tasks/codec.test.d.mts +0 -2
  159. package/dist/federation/tasks/codec.test.mjs +0 -302
  160. package/dist/federation/tasks/enqueue.test.d.mts +0 -2
  161. package/dist/federation/tasks/enqueue.test.mjs +0 -1095
  162. package/dist/federation/tasks/tasks.test.d.mts +0 -2
  163. package/dist/federation/tasks/tasks.test.mjs +0 -1229
  164. package/dist/federation/temporal.test.d.mts +0 -2
  165. package/dist/federation/temporal.test.mjs +0 -71
  166. package/dist/federation/webfinger.test.d.mts +0 -2
  167. package/dist/federation/webfinger.test.mjs +0 -944
  168. package/dist/http-l1zKGCll.mjs +0 -1449
  169. package/dist/inbox-CWX3EBTO.mjs +0 -399
  170. package/dist/inbox-authentication-CgonVRkg.mjs +0 -198
  171. package/dist/inbox-view-DkPCF71K.mjs +0 -385
  172. package/dist/key-owner-evidence-APB6NpSk.mjs +0 -108
  173. package/dist/keycache-N2opu4-3.mjs +0 -221
  174. package/dist/keys-DIJNHW-Y.mjs +0 -120
  175. package/dist/kv-DBRWVx3Q.mjs +0 -104
  176. package/dist/kv-DCHkaJ9-.mjs +0 -92
  177. package/dist/kv-cache-8eJh4Xum.mjs +0 -121
  178. package/dist/ld-Cdt8qD-r.mjs +0 -1752
  179. package/dist/map-local-context-conflict-DOYEEJ3u.mjs +0 -204
  180. package/dist/map-local-create-note-B0SeXJms.mjs +0 -214
  181. package/dist/metrics-BnfvSPj9.mjs +0 -818
  182. package/dist/middleware-CwnXJze2.mjs +0 -5
  183. package/dist/middleware-D_W_LdJN.mjs +0 -9971
  184. package/dist/mq-eF96QxUT.mjs +0 -288
  185. package/dist/negotiation-BAKO9nih.mjs +0 -96
  186. package/dist/nodeinfo/client.test.d.mts +0 -2
  187. package/dist/nodeinfo/client.test.mjs +0 -1364
  188. package/dist/nodeinfo/handler.test.d.mts +0 -2
  189. package/dist/nodeinfo/handler.test.mjs +0 -94
  190. package/dist/nodeinfo/types.test.d.mts +0 -2
  191. package/dist/nodeinfo/types.test.mjs +0 -192
  192. package/dist/otel/exporter.test.d.mts +0 -2
  193. package/dist/otel/exporter.test.mjs +0 -887
  194. package/dist/outbound-body-CckPA5gc.mjs +0 -83
  195. package/dist/outbound-capture-DVgnRzlf.mjs +0 -184
  196. package/dist/outbound-document-BMgwLXTY.mjs +0 -179
  197. package/dist/outgoing-jsonld-4IJqPYos.mjs +0 -205
  198. package/dist/owner-DukEQnv3.mjs +0 -267
  199. package/dist/portable-collection-OHaqa11n.mjs +0 -418
  200. package/dist/portable-key-BkOLJxVz.mjs +0 -549
  201. package/dist/portable-key-id-Ca30-hOa.mjs +0 -248
  202. package/dist/proof-Y7omSVvc.mjs +0 -1420
  203. package/dist/public-audience--klBIOk1.mjs +0 -197
  204. package/dist/retry-zX5xw5e0.mjs +0 -34
  205. package/dist/router-u5O5KCQr.mjs +0 -156
  206. package/dist/secured-document-CxzZZ9nL.mjs +0 -35
  207. package/dist/send-ccQynabr.mjs +0 -710
  208. package/dist/sig/accept.test.d.mts +0 -2
  209. package/dist/sig/accept.test.mjs +0 -416
  210. package/dist/sig/compound-proof-discovery.test.d.mts +0 -2
  211. package/dist/sig/compound-proof-discovery.test.mjs +0 -331
  212. package/dist/sig/compound-proof-producer.test.d.mts +0 -2
  213. package/dist/sig/compound-proof-producer.test.mjs +0 -107
  214. package/dist/sig/compound-proof-verification.test.d.mts +0 -2
  215. package/dist/sig/compound-proof-verification.test.mjs +0 -1017
  216. package/dist/sig/compound-proof.test.d.mts +0 -2
  217. package/dist/sig/compound-proof.test.mjs +0 -411
  218. package/dist/sig/http.test.d.mts +0 -2
  219. package/dist/sig/http.test.mjs +0 -3328
  220. package/dist/sig/key-owner-evidence.test.d.mts +0 -2
  221. package/dist/sig/key-owner-evidence.test.mjs +0 -100
  222. package/dist/sig/key.test.d.mts +0 -2
  223. package/dist/sig/key.test.mjs +0 -1250
  224. package/dist/sig/ld.test.d.mts +0 -2
  225. package/dist/sig/ld.test.mjs +0 -1044
  226. package/dist/sig/mitra-receive-interop.test.d.mts +0 -2
  227. package/dist/sig/mitra-receive-interop.test.mjs +0 -260
  228. package/dist/sig/mitra-send-interop.test.d.mts +0 -2
  229. package/dist/sig/mitra-send-interop.test.mjs +0 -461
  230. package/dist/sig/owner.test.d.mts +0 -2
  231. package/dist/sig/owner.test.mjs +0 -202
  232. package/dist/sig/portable-collection.test.d.mts +0 -2
  233. package/dist/sig/portable-collection.test.mjs +0 -697
  234. package/dist/sig/portable-interop.test.d.mts +0 -2
  235. package/dist/sig/portable-interop.test.mjs +0 -156
  236. package/dist/sig/portable-key-id.test.d.mts +0 -2
  237. package/dist/sig/portable-key-id.test.mjs +0 -67
  238. package/dist/sig/portable-key.test.d.mts +0 -2
  239. package/dist/sig/portable-key.test.mjs +0 -1438
  240. package/dist/sig/proof.test.d.mts +0 -2
  241. package/dist/sig/proof.test.mjs +0 -2638
  242. package/dist/sig/tootik-request-interop.test.d.mts +0 -2
  243. package/dist/sig/tootik-request-interop.test.mjs +0 -190
  244. package/dist/sig/tootik-send-interop.test.d.mts +0 -2
  245. package/dist/sig/tootik-send-interop.test.mjs +0 -331
  246. package/dist/sig/verification.test.d.mts +0 -2
  247. package/dist/sig/verification.test.mjs +0 -310
  248. package/dist/std__assert-DvMDRPes.mjs +0 -8
  249. package/dist/tasks-BCUmQbbz.mjs +0 -77
  250. package/dist/temporal-f_K4lAVR.mjs +0 -95
  251. package/dist/testing/context.test.d.mts +0 -2
  252. package/dist/testing/context.test.mjs +0 -19
  253. package/dist/testing/kv.test.d.mts +0 -2
  254. package/dist/testing/kv.test.mjs +0 -101
  255. package/dist/testing/mod.d.mts +0 -6099
  256. package/dist/testing/mod.mjs +0 -9
  257. package/dist/testing-vrnD5Uaa.mjs +0 -8
  258. package/dist/types-DE_LV1JB.mjs +0 -46
  259. package/dist/utils/docloader.test.d.mts +0 -2
  260. package/dist/utils/docloader.test.mjs +0 -1076
  261. package/dist/utils/kv-cache.test.d.mts +0 -2
  262. package/dist/utils/kv-cache.test.mjs +0 -261
  263. package/dist/verification-C3954hQh.mjs +0 -5
  264. package/dist/verification-Dpfcw8ml.mjs +0 -105
  265. package/dist/vocab/cjs.test.d.mts +0 -2
  266. package/dist/vocab/cjs.test.mjs +0 -27
@@ -1,263 +0,0 @@
1
- import "temporal-polyfill";
2
- import "urlpattern-polyfill";
3
- globalThis.addEventListener = () => {};
4
- import { getLogger } from "@logtape/logtape";
5
- import { ExportResultCode } from "@opentelemetry/core";
6
- //#region src/otel/exporter.ts
7
- /**
8
- * A SpanExporter that persists ActivityPub activity traces to a
9
- * {@link KvStore}. This enables distributed tracing across multiple
10
- * nodes in a Fedify deployment.
11
- *
12
- * The exporter captures activity data from OpenTelemetry span events
13
- * (`activitypub.activity.received` and `activitypub.activity.sent`)
14
- * and stores them in the KvStore with trace context preserved.
15
- *
16
- * @example Basic usage with MemoryKvStore
17
- * ```typescript ignore
18
- * import { MemoryKvStore } from "@fedify/fedify";
19
- * import { FedifySpanExporter } from "@fedify/fedify/otel";
20
- * import {
21
- * BasicTracerProvider,
22
- * SimpleSpanProcessor,
23
- * } from "@opentelemetry/sdk-trace-base";
24
- *
25
- * const kv = new MemoryKvStore();
26
- * const exporter = new FedifySpanExporter(kv, {
27
- * ttl: Temporal.Duration.from({ hours: 1 }),
28
- * });
29
- *
30
- * const provider = new BasicTracerProvider({
31
- * spanProcessors: [new SimpleSpanProcessor(exporter)],
32
- * });
33
- * ```
34
- *
35
- * @example Querying stored traces
36
- * ```typescript ignore
37
- * import { MemoryKvStore } from "@fedify/fedify";
38
- * import { FedifySpanExporter } from "@fedify/fedify/otel";
39
- *
40
- * const kv = new MemoryKvStore();
41
- * const exporter = new FedifySpanExporter(kv);
42
- * const traceId = "abc123";
43
- *
44
- * // Get all activities for a specific trace
45
- * const activities = await exporter.getActivitiesByTraceId(traceId);
46
- *
47
- * // Get recent traces
48
- * const recentTraces = await exporter.getRecentTraces({ limit: 100 });
49
- * ```
50
- *
51
- * @since 1.10.0
52
- */
53
- var FedifySpanExporter = class {
54
- #kv;
55
- #ttl;
56
- #keyPrefix;
57
- /**
58
- * Creates a new FedifySpanExporter.
59
- *
60
- * @param kv The KvStore to persist trace data to.
61
- * @param options Configuration options.
62
- */
63
- constructor(kv, options) {
64
- this.#kv = kv;
65
- this.#ttl = options?.ttl;
66
- this.#keyPrefix = options?.keyPrefix ?? ["fedify", "traces"];
67
- }
68
- /**
69
- * Exports spans to the KvStore.
70
- *
71
- * @param spans The spans to export.
72
- * @param resultCallback Callback to invoke with the export result.
73
- */
74
- export(spans, resultCallback) {
75
- this.#exportAsync(spans).then(() => resultCallback({ code: ExportResultCode.SUCCESS })).catch((error) => {
76
- getLogger([
77
- "fedify",
78
- "otel",
79
- "exporter"
80
- ]).error("Failed to export spans to KvStore: {error}", { error });
81
- resultCallback({ code: ExportResultCode.FAILED });
82
- });
83
- }
84
- async #exportAsync(spans) {
85
- const storeOperations = [];
86
- for (const span of spans) {
87
- const records = this.#extractRecords(span);
88
- for (const record of records) storeOperations.push(this.#storeRecord(record));
89
- }
90
- const rejected = (await Promise.allSettled(storeOperations)).filter((r) => r.status === "rejected");
91
- if (rejected.length > 0) throw new AggregateError(rejected.map((r) => r.reason), "Failed to store one or more trace activity records.");
92
- }
93
- #extractRecords(span) {
94
- const records = [];
95
- const spanContext = span.spanContext();
96
- const traceId = spanContext.traceId;
97
- const spanId = spanContext.spanId;
98
- const parentSpanId = span.parentSpanContext?.spanId;
99
- for (const event of span.events) if (event.name === "activitypub.activity.received") {
100
- const record = this.#extractInboundRecord(event, traceId, spanId, parentSpanId);
101
- if (record != null) records.push(record);
102
- } else if (event.name === "activitypub.activity.sent") {
103
- const record = this.#extractOutboundRecord(event, traceId, spanId, parentSpanId);
104
- if (record != null) records.push(record);
105
- }
106
- return records;
107
- }
108
- #extractInboundRecord(event, traceId, spanId, parentSpanId) {
109
- const attrs = event.attributes;
110
- if (attrs == null) return null;
111
- const activityJson = attrs["activitypub.activity.json"];
112
- if (typeof activityJson !== "string") return null;
113
- let activityType = "Unknown";
114
- let activityId;
115
- let actorId;
116
- try {
117
- const activity = JSON.parse(activityJson);
118
- activityType = activity.type ?? "Unknown";
119
- activityId = activity.id;
120
- if (typeof activity.actor === "string") actorId = activity.actor;
121
- else if (activity.actor != null && typeof activity.actor.id === "string") actorId = activity.actor.id;
122
- } catch {}
123
- const verified = attrs["activitypub.activity.verified"];
124
- const httpSigVerified = attrs["http_signatures.verified"];
125
- const httpSigKeyId = attrs["http_signatures.key_id"];
126
- const httpSigFailureReason = attrs["http_signatures.failure_reason"];
127
- const httpSigKeyFetchStatus = attrs["http_signatures.key_fetch_status"];
128
- const httpSigKeyFetchError = attrs["http_signatures.key_fetch_error"];
129
- const ldSigVerified = attrs["ld_signatures.verified"];
130
- let signatureDetails;
131
- if (typeof httpSigVerified === "boolean" || typeof ldSigVerified === "boolean" || typeof httpSigFailureReason === "string") signatureDetails = {
132
- httpSignaturesVerified: httpSigVerified === true,
133
- httpSignaturesKeyId: typeof httpSigKeyId === "string" && httpSigKeyId !== "" ? httpSigKeyId : void 0,
134
- httpSignaturesFailureReason: typeof httpSigFailureReason === "string" && httpSigFailureReason !== "" ? httpSigFailureReason : void 0,
135
- httpSignaturesKeyFetchStatus: typeof httpSigKeyFetchStatus === "number" ? httpSigKeyFetchStatus : void 0,
136
- httpSignaturesKeyFetchError: typeof httpSigKeyFetchError === "string" && httpSigKeyFetchError !== "" ? httpSigKeyFetchError : void 0,
137
- ldSignaturesVerified: ldSigVerified === true
138
- };
139
- return {
140
- traceId,
141
- spanId,
142
- parentSpanId,
143
- direction: "inbound",
144
- activityType,
145
- activityId,
146
- actorId,
147
- activityJson,
148
- verified: typeof verified === "boolean" ? verified : void 0,
149
- signatureDetails,
150
- timestamp: (/* @__PURE__ */ new Date(event.time[0] * 1e3 + event.time[1] / 1e6)).toISOString()
151
- };
152
- }
153
- #extractOutboundRecord(event, traceId, spanId, parentSpanId) {
154
- const attrs = event.attributes;
155
- if (attrs == null) return null;
156
- const activityJson = attrs["activitypub.activity.json"];
157
- let activityType = "Unknown";
158
- let activityId;
159
- let actorId;
160
- if (typeof activityJson === "string") try {
161
- const activity = JSON.parse(activityJson);
162
- activityType = activity.type ?? "Unknown";
163
- activityId = activity.id;
164
- if (typeof activity.actor === "string") actorId = activity.actor;
165
- else if (activity.actor != null && typeof activity.actor.id === "string") actorId = activity.actor.id;
166
- } catch {}
167
- const inboxUrl = attrs["activitypub.inbox.url"];
168
- const explicitActivityId = attrs["activitypub.activity.id"];
169
- const explicitActivityType = attrs["activitypub.activity.type"];
170
- const explicitActorId = attrs["activitypub.actor.id"];
171
- return {
172
- traceId,
173
- spanId,
174
- parentSpanId,
175
- direction: "outbound",
176
- activityType: typeof explicitActivityType === "string" && explicitActivityType !== "" ? explicitActivityType : activityType,
177
- activityId: activityId ?? (typeof explicitActivityId === "string" && explicitActivityId !== "" ? explicitActivityId : void 0),
178
- actorId: typeof explicitActorId === "string" && explicitActorId !== "" ? explicitActorId : actorId,
179
- ...typeof activityJson === "string" ? { activityJson } : {},
180
- timestamp: (/* @__PURE__ */ new Date(event.time[0] * 1e3 + event.time[1] / 1e6)).toISOString(),
181
- inboxUrl: typeof inboxUrl === "string" ? inboxUrl : void 0
182
- };
183
- }
184
- async #storeRecord(record) {
185
- const options = this.#ttl != null ? { ttl: this.#ttl } : void 0;
186
- const key = [
187
- ...this.#keyPrefix,
188
- record.traceId,
189
- record.spanId
190
- ];
191
- await this.#kv.set(key, record, options);
192
- }
193
- /**
194
- * Gets all activity records for a specific trace ID.
195
- *
196
- * @param traceId The trace ID to query.
197
- * @returns An array of activity records belonging to the trace.
198
- */
199
- async getActivitiesByTraceId(traceId) {
200
- const prefix = [...this.#keyPrefix, traceId];
201
- const records = [];
202
- for await (const entry of this.#kv.list(prefix)) records.push(entry.value);
203
- return records;
204
- }
205
- /**
206
- * Gets recent traces with summary information.
207
- *
208
- * Each summary is computed directly from the activity records currently
209
- * stored for each trace, rather than from a separately maintained
210
- * counter. This guarantees that a trace is discoverable, and its
211
- * `activityCount` accurate, as soon as its records are stored, even if
212
- * an earlier attempt at summarizing it (in a previous version of this
213
- * exporter) never completed, and that the count always reflects
214
- * records that have not expired. It costs a full scan of every stored
215
- * record on every call, including full inbound activity JSON. The
216
- * `limit` option only truncates the returned summaries and does not
217
- * reduce the scan. Callers that poll this method frequently should
218
- * account for the total retained data when choosing a TTL and polling
219
- * interval.
220
- *
221
- * @param options Options for the query.
222
- * @returns An array of trace summaries.
223
- */
224
- async getRecentTraces(options) {
225
- const aggregates = /* @__PURE__ */ new Map();
226
- const traceIdIndex = this.#keyPrefix.length;
227
- for await (const entry of this.#kv.list(this.#keyPrefix)) {
228
- const traceId = entry.key[traceIdIndex];
229
- if (traceId == null || traceId === "_summaries") continue;
230
- const record = entry.value;
231
- if (record == null || typeof record.timestamp !== "string") continue;
232
- const aggregate = aggregates.get(traceId);
233
- if (aggregate == null) aggregates.set(traceId, {
234
- timestamp: record.timestamp,
235
- activityCount: 1,
236
- activityTypes: [record.activityType]
237
- });
238
- else {
239
- aggregate.activityCount++;
240
- if (record.timestamp < aggregate.timestamp) aggregate.timestamp = record.timestamp;
241
- if (!aggregate.activityTypes.includes(record.activityType)) aggregate.activityTypes.push(record.activityType);
242
- }
243
- }
244
- const summaries = [...aggregates].map(([traceId, aggregate]) => ({
245
- traceId,
246
- ...aggregate
247
- }));
248
- summaries.sort((a, b) => b.timestamp.localeCompare(a.timestamp));
249
- if (options?.limit != null) return summaries.slice(0, options.limit);
250
- return summaries;
251
- }
252
- /**
253
- * Forces the exporter to flush any buffered data.
254
- * This is a no-op because we write directly to the KvStore without buffering.
255
- */
256
- async forceFlush() {}
257
- /**
258
- * Shuts down the exporter.
259
- */
260
- async shutdown() {}
261
- };
262
- //#endregion
263
- export { FedifySpanExporter as t };
@@ -1,2 +0,0 @@
1
- import { Temporal } from "temporal-polyfill";
2
- import { URLPattern } from "urlpattern-polyfill";
@@ -1,130 +0,0 @@
1
- import "temporal-polyfill";
2
- import "urlpattern-polyfill";
3
- globalThis.addEventListener = () => {};
4
- import { n as isPubliclyAddressedNode, t as isInAudience } from "../audience-CHQ-FlLD.mjs";
5
- import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
6
- import "../std__assert-DvMDRPes.mjs";
7
- import { Note, PUBLIC_COLLECTION, Person } from "@fedify/vocab";
8
- import { parseIri, toCompatibleEf61Id } from "@fedify/vocab-runtime";
9
- import { mockDocumentLoader, test } from "@fedify/fixture";
10
- import jsonld from "@fedify/vocab-runtime/jsonld";
11
- //#region src/federation/audience.test.ts
12
- const did = "did:key:z6MkrJVnaZkeFzdQyMZu1cgjg7k1pZZ6pvBQ7XJPt4swbTQ2";
13
- async function expand(document) {
14
- const [node] = await jsonld.expand({
15
- "@context": "https://www.w3.org/ns/activitystreams",
16
- id: "https://example.com/notes/1",
17
- type: "Note",
18
- ...document
19
- }, { documentLoader: mockDocumentLoader });
20
- return node;
21
- }
22
- test("isPubliclyAddressedNode()", async (t) => {
23
- for (const property of [
24
- "to",
25
- "cc",
26
- "bto",
27
- "bcc",
28
- "audience"
29
- ]) for (const value of [
30
- PUBLIC_COLLECTION.href,
31
- "as:Public",
32
- "Public",
33
- ["https://example.com/person", "as:Public"]
34
- ]) await t.step(`${JSON.stringify(value)} in ${property}`, async () => {
35
- assertEquals(isPubliclyAddressedNode(await expand({ [property]: value })), true);
36
- });
37
- await t.step("not addressed", async () => {
38
- assertEquals(isPubliclyAddressedNode(await expand({})), false);
39
- });
40
- await t.step("addressed to other recipients", async () => {
41
- assertEquals(isPubliclyAddressedNode(await expand({
42
- to: "https://example.com/person",
43
- cc: "https://example.com/person/followers"
44
- })), false);
45
- });
46
- await t.step("Public in other properties", async () => {
47
- assertEquals(isPubliclyAddressedNode(await expand({ tag: PUBLIC_COLLECTION.href })), false);
48
- });
49
- await t.step("a Public literal rather than an ID", async () => {
50
- assertEquals(isPubliclyAddressedNode(await expand({ to: { "@value": PUBLIC_COLLECTION.href } })), false);
51
- });
52
- await t.step("Public that the context maps elsewhere", async () => {
53
- for (const [context, to] of [[{ as: "https://example.com/ns#" }, "as:Public"], [{ "@base": "https://example.com/" }, "Public"]]) {
54
- const [node] = await jsonld.expand({
55
- "@context": ["https://www.w3.org/ns/activitystreams", context],
56
- id: "https://example.com/notes/1",
57
- type: "Note",
58
- to
59
- }, { documentLoader: mockDocumentLoader });
60
- assertEquals(isPubliclyAddressedNode(node), false, JSON.stringify(context));
61
- }
62
- });
63
- await t.step("only the node itself is checked", async () => {
64
- assertEquals(isPubliclyAddressedNode(await expand({
65
- type: "Create",
66
- actor: "https://example.com/person",
67
- object: {
68
- type: "Note",
69
- id: "https://example.com/notes/2",
70
- to: PUBLIC_COLLECTION.href
71
- }
72
- })), false);
73
- });
74
- });
75
- test("isInAudience()", async (t) => {
76
- const person = new Person({ id: new URL("https://example.com/person") });
77
- const portableId = parseIri(`ap+ef61://${did}/actor`);
78
- const portable = new Person({ id: toCompatibleEf61Id(portableId, "https://other.example") });
79
- const followers = new URL("https://example.com/person2/followers");
80
- await t.step("publicly addressed", async () => {
81
- for (const actor of [null, person]) assertEquals(await isInAudience(new Note({ cc: PUBLIC_COLLECTION }), actor), true);
82
- });
83
- await t.step("no actor", async () => {
84
- assertEquals(await isInAudience(new Note({ to: person.id }), null), false);
85
- assertEquals(await isInAudience(new Note({}), null), false);
86
- });
87
- await t.step("directly addressed", async () => {
88
- for (const property of [
89
- "to",
90
- "cc",
91
- "bto",
92
- "bcc",
93
- "audience"
94
- ]) assertEquals(await isInAudience(new Note({ [property]: person.id }), person), true, property);
95
- });
96
- await t.step("not addressed", async () => {
97
- assertEquals(await isInAudience(new Note({ to: new URL("https://example.com/other") }), person), false);
98
- assertEquals(await isInAudience(new Note({ to: person.id }), new Person({})), false);
99
- });
100
- await t.step("portable IDs are compared canonically", async () => {
101
- for (const addressee of [
102
- portableId,
103
- parseIri(`ap://${did}/actor`),
104
- parseIri(`ap+ef61://${did.replaceAll(":", "%3A")}/actor`),
105
- toCompatibleEf61Id(portableId, "https://example.com")
106
- ]) assertEquals(await isInAudience(new Note({ to: addressee }), portable), true, addressee.href);
107
- assertEquals(await isInAudience(new Note({ to: parseIri(`ap+ef61://${did}/other`) }), portable), false);
108
- assertEquals(await isInAudience(new Note({ to: new URL(`https://other.example/${did}/actor`) }), portable), false);
109
- });
110
- await t.step("isMember()", async () => {
111
- const calls = [];
112
- const isMember = (addressee, actor) => {
113
- calls.push(`${addressee.href} ${actor.id?.href}`);
114
- return addressee.href === followers.href;
115
- };
116
- const note = new Note({
117
- to: new URL("https://example.com/other"),
118
- cc: followers
119
- });
120
- assertEquals(await isInAudience(note, person, { isMember }), true);
121
- assertEquals(calls, [`https://example.com/other ${person.id?.href}`, `${followers.href} ${person.id?.href}`]);
122
- calls.length = 0;
123
- assertEquals(await isInAudience(new Note({ to: person.id }), person, { isMember }), true);
124
- assertEquals(await isInAudience(note, null, { isMember }), false);
125
- assertEquals(calls, []);
126
- assertEquals(await isInAudience(note, person, { isMember: () => false }), false);
127
- });
128
- });
129
- //#endregion
130
- export {};
@@ -1,2 +0,0 @@
1
- import { Temporal } from "temporal-polyfill";
2
- import { URLPattern } from "urlpattern-polyfill";