@fedify/fedify 2.4.0-dev.1668 → 2.4.0-dev.1727

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 (150) hide show
  1. package/README.md +1 -1
  2. package/dist/{assert-CJ1KXcvv.mjs → assert-CebeUf0C.mjs} +1 -1
  3. package/dist/assert_exists-DtzkXC47.mjs +28 -0
  4. package/dist/assert_false-3pLLLsO4.mjs +23 -0
  5. package/dist/assert_greater_or_equal-BApOTh1h.mjs +30 -0
  6. package/dist/{assert_instance_of-Q9KTBnrf.mjs → assert_instance_of-g3WcyYNR.mjs} +1 -1
  7. package/dist/{assert_not_equals-EPJPoxuf.mjs → assert_not_equals-BN7yDMWe.mjs} +1 -1
  8. package/dist/assert_rejects-wFbSPn1O.mjs +39 -0
  9. package/dist/{assert_strict_equals-Ec20AUwa.mjs → assert_strict_equals-Bpjl4Psw.mjs} +1 -1
  10. package/dist/{assert_throws-NiFfqbnH.mjs → assert_throws-BJ5wuvR2.mjs} +1 -1
  11. package/dist/{builder-iXZ5jNVg.mjs → builder-f5-YwHfj.mjs} +5 -3
  12. package/dist/{circuit-breaker-CBGyz5F7.mjs → circuit-breaker-BT7CiPbz.mjs} +191 -9
  13. package/dist/circuit-breaker-test-utils-BYIHoliq.mjs +14 -0
  14. package/dist/{client-CjF5IYQS.mjs → client-CtxvmazV.mjs} +63 -5
  15. package/dist/{collection-BIhlldqK.mjs → collection-CnnP1UAv.mjs} +1 -1
  16. package/dist/compat/mod.cjs +1 -1
  17. package/dist/compat/mod.d.cts +1 -1
  18. package/dist/compat/mod.d.ts +1 -1
  19. package/dist/compat/mod.js +1 -1
  20. package/dist/compat/outgoing-jsonld.test.mjs +3 -3
  21. package/dist/compat/public-audience.test.mjs +3 -3
  22. package/dist/compat/transformers.test.mjs +5 -5
  23. package/dist/{context-C05Rgxmu.d.cts → context-B-dsBjZ9.d.cts} +281 -7
  24. package/dist/{context-Cjnr0ig1.d.ts → context-DrLXudbA.d.ts} +281 -7
  25. package/dist/{deno-DtHcfB0f.mjs → deno-Deyoxesx.mjs} +1 -1
  26. package/dist/{docloader-0vAfF6XW.mjs → docloader-B3kuDBg9.mjs} +2 -2
  27. package/dist/{esm-yYQfPhIY.mjs → esm-BHXXx4Wx.mjs} +13 -6
  28. package/dist/federation/builder.test.mjs +18 -5
  29. package/dist/federation/circuit-breaker.test.mjs +626 -7
  30. package/dist/federation/collection.test.mjs +3 -3
  31. package/dist/federation/handler.test.mjs +14 -13
  32. package/dist/federation/idempotency.test.mjs +6 -6
  33. package/dist/federation/inbox.test.mjs +3 -3
  34. package/dist/federation/keycache.test.mjs +5 -5
  35. package/dist/federation/kv.test.mjs +3 -3
  36. package/dist/federation/metrics.test.mjs +4 -4
  37. package/dist/federation/middleware.test.mjs +37 -28
  38. package/dist/federation/mod.cjs +18 -540
  39. package/dist/federation/mod.d.cts +3 -4
  40. package/dist/federation/mod.d.ts +3 -4
  41. package/dist/federation/mod.js +1 -1
  42. package/dist/federation/mq.test.mjs +32 -5
  43. package/dist/federation/negotiation.test.mjs +4 -4
  44. package/dist/federation/retry.test.mjs +3 -3
  45. package/dist/federation/router.test.mjs +7 -7
  46. package/dist/federation/send.test.mjs +28 -26
  47. package/dist/federation/tasks/codec.test.mjs +4 -4
  48. package/dist/federation/tasks/enqueue.test.mjs +4 -4
  49. package/dist/federation/tasks/tasks.test.mjs +6 -6
  50. package/dist/federation/temporal.test.mjs +4 -4
  51. package/dist/federation/webfinger.test.mjs +74 -12
  52. package/dist/{middleware-DzIUFRO2.cjs → federation-BzRjeOky.cjs} +855 -114
  53. package/dist/{temporal-polyfill-BCdTHexd.cjs → http-AyKngJ_h.cjs} +2801 -104
  54. package/dist/{http-BbnOMQoy.js → http-Bw6s_dOB.js} +3 -3
  55. package/dist/{http-DUmWq5Pw.mjs → http-TjhZfiSN.mjs} +5 -5
  56. package/dist/{key-CM7wDnZG.mjs → key-b4kf4yZT.mjs} +2 -2
  57. package/dist/{kv-cache-zmgG1HUp.cjs → kv-cache-BTVaZrf-.cjs} +2 -4
  58. package/dist/{kv-cache-ZQ22hm44.js → kv-cache-CQsh-KUw.js} +1 -1
  59. package/dist/{kv-cache-DEXKemJ9.mjs → kv-cache-CpILvhUV.mjs} +1 -1
  60. package/dist/{ld-BttH_-8K.mjs → ld-CKujkAfG.mjs} +5 -5
  61. package/dist/{metrics-DT-CnD1g.mjs → metrics-AlCGTDrr.mjs} +2 -2
  62. package/dist/metrics-DVKYY6K1.d.cts +36 -0
  63. package/dist/metrics-DoRtI0qU.d.ts +36 -0
  64. package/dist/{middleware-DrroX3aD.mjs → middleware-C9Y5lLZN.mjs} +60 -43
  65. package/dist/{middleware-D3IAVMcT.js → middleware-CZcuedl-.js} +241 -40
  66. package/dist/{middleware-ChlYS0Af.mjs → middleware-LPbZz6-1.mjs} +1 -1
  67. package/dist/{mod-BrpVsSfY.d.cts → mod-CLHkCwLm.d.cts} +3 -3
  68. package/dist/{mod-B0hW12_O.d.cts → mod-CuDDaIIt.d.cts} +1 -1
  69. package/dist/{mod-COIAjwRS.d.ts → mod-D-IhOEOP.d.ts} +1 -1
  70. package/dist/{mod-DdONo-ep.d.cts → mod-D-abvu2C.d.cts} +1 -1
  71. package/dist/{mod-BsCE5Ihq.d.ts → mod-D6O8C7eN.d.ts} +1 -1
  72. package/dist/{mod-CNef4in0.d.ts → mod-DypxPS9H.d.ts} +3 -3
  73. package/dist/mod.cjs +24 -25
  74. package/dist/mod.d.cts +8 -9
  75. package/dist/mod.d.ts +8 -9
  76. package/dist/mod.js +7 -7
  77. package/dist/nodeinfo/client.test.mjs +64 -4
  78. package/dist/nodeinfo/handler.test.mjs +5 -5
  79. package/dist/nodeinfo/mod.cjs +1 -1
  80. package/dist/nodeinfo/mod.d.cts +1 -1
  81. package/dist/nodeinfo/mod.d.ts +1 -1
  82. package/dist/nodeinfo/mod.js +1 -1
  83. package/dist/nodeinfo/types.test.mjs +4 -4
  84. package/dist/otel/exporter.test.mjs +3 -3
  85. package/dist/otel/mod.cjs +0 -1
  86. package/dist/otel/mod.d.cts +1 -1
  87. package/dist/otel/mod.d.ts +1 -1
  88. package/dist/{outgoing-jsonld-URuqsICz.mjs → outgoing-jsonld-BQSHRLhg.mjs} +2 -2
  89. package/dist/{owner-DZALmhdl.mjs → owner-D1O8v8FB.mjs} +2 -2
  90. package/dist/{proof-CqA-2nfW.js → proof-BTBolSnd.js} +6 -6
  91. package/dist/{proof-a60oVJ_4.cjs → proof-DcSm-2eG.cjs} +10 -11
  92. package/dist/{proof-DiQ0uBal.mjs → proof-DeMR7Akd.mjs} +6 -6
  93. package/dist/{public-audience-Cr5MsnMq.mjs → public-audience--9hx7IGx.mjs} +1 -1
  94. package/dist/runtime/mod.cjs +1 -1
  95. package/dist/runtime/mod.js +1 -1
  96. package/dist/{send-DcwZnQWG.mjs → send-DG7JG280.mjs} +3 -3
  97. package/dist/sig/accept.test.mjs +1 -1
  98. package/dist/sig/http.test.mjs +37 -11
  99. package/dist/sig/key.test.mjs +6 -6
  100. package/dist/sig/ld.test.mjs +9 -7
  101. package/dist/sig/mod.cjs +2 -2
  102. package/dist/sig/mod.d.cts +3 -3
  103. package/dist/sig/mod.d.ts +3 -3
  104. package/dist/sig/mod.js +2 -2
  105. package/dist/sig/owner.test.mjs +6 -6
  106. package/dist/sig/proof.test.mjs +10 -8
  107. package/dist/std__assert-CxFT0MNt.mjs +8 -0
  108. package/dist/{temporal-Bpxpsl2k.mjs → temporal-DA3jx8x1.mjs} +3 -3
  109. package/dist/testing/mod.d.mts +10 -0
  110. package/dist/testing/mod.mjs +2 -2
  111. package/dist/{testing-CO7ftO8A.mjs → testing-BX0Nicyq.mjs} +2 -2
  112. package/dist/{transformers-DGwl-hD1.cjs → transformers-BalCrSsr.cjs} +0 -1
  113. package/dist/{types-DC1pNgJA.js → types-Dtyf8lVj.js} +63 -5
  114. package/dist/{types-CPym83zc.cjs → types-RXm5YxpC.cjs} +62 -5
  115. package/dist/utils/docloader.test.mjs +7 -7
  116. package/dist/utils/kv-cache.test.mjs +1 -1
  117. package/dist/utils/mod.cjs +1 -1
  118. package/dist/utils/mod.d.cts +1 -1
  119. package/dist/utils/mod.d.ts +1 -1
  120. package/dist/utils/mod.js +1 -1
  121. package/package.json +7 -7
  122. package/skills/fedify/SKILL.md +462 -0
  123. package/dist/assert_rejects-EgstcQy5.mjs +0 -82
  124. package/dist/http-BpT5cE6r.cjs +0 -2694
  125. package/dist/metrics-DN13mCAw.d.cts +0 -294
  126. package/dist/metrics-v_e0n5GQ.d.ts +0 -294
  127. package/dist/std__assert-B2NnY9bq.mjs +0 -79
  128. /package/dist/{accept-8PiolDP7.mjs → accept-CPVqki78.mjs} +0 -0
  129. /package/dist/{activity-listener-BtTSxZWA.mjs → activity-listener-C-BSbKI7.mjs} +0 -0
  130. /package/dist/{assert_equals-BV7oLMxm.mjs → assert_equals-CBlRfA-_.mjs} +0 -0
  131. /package/dist/{client-CAM_bQXx.d.cts → client-D-XP_Ccb.d.cts} +0 -0
  132. /package/dist/{client-CSddvgWN.d.ts → client-D-XP_Ccb.d.ts} +0 -0
  133. /package/dist/{codec-BBga-FWI.mjs → codec-peqOdBaE.mjs} +0 -0
  134. /package/dist/{context-BJXxPElm.mjs → context-Dt36KFEJ.mjs} +0 -0
  135. /package/dist/{http-VyDTd4G3.d.cts → http-6TI0tI03.d.cts} +0 -0
  136. /package/dist/{http-lf8Hsd91.d.ts → http-CdrSn2ip.d.ts} +0 -0
  137. /package/dist/{keycache-_DHqz5z_.mjs → keycache-0Jk78XmB.mjs} +0 -0
  138. /package/dist/{keys-Dbyd7bhl.mjs → keys-DIJNHW-Y.mjs} +0 -0
  139. /package/dist/{kv-D6hNiMTK.d.ts → kv-BhNbN8Ed.d.cts} +0 -0
  140. /package/dist/{kv-gJ8LYbxX.d.cts → kv-BhNbN8Ed.d.ts} +0 -0
  141. /package/dist/{kv-CXBAok3k.mjs → kv-DCHkaJ9-.mjs} +0 -0
  142. /package/dist/{mq-Bo7Etgh6.mjs → mq-Dm1Wmtm-.mjs} +0 -0
  143. /package/dist/{negotiation-RuwrPFqi.mjs → negotiation-CCocWT_N.mjs} +0 -0
  144. /package/dist/{owner-CnngXDNJ.d.ts → owner-DGSfntI-.d.ts} +0 -0
  145. /package/dist/{owner-DEvZuyOE.d.cts → owner-r_waTiQj.d.cts} +0 -0
  146. /package/dist/{retry-DgFqeS5k.mjs → retry-zX5xw5e0.mjs} +0 -0
  147. /package/dist/{chunk-D5IdezsZ.js → rolldown-runtime-BC-Eo5Mj.js} +0 -0
  148. /package/dist/{chunk-Czpeue4M.cjs → rolldown-runtime-Dmm3t92W.cjs} +0 -0
  149. /package/dist/{transformers-DXze6FUB.js → transformers-DAtXl_Kc.js} +0 -0
  150. /package/dist/{types-CrtdVuDP.mjs → types-DE_LV1JB.mjs} +0 -0
@@ -10,7 +10,7 @@ import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } fro
10
10
  import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
11
11
  //#region deno.json
12
12
  var name = "@fedify/fedify";
13
- var version = "2.4.0-dev.1668+90797b01";
13
+ var version = "2.4.0-dev.1727+1eadcb04";
14
14
  //#endregion
15
15
  //#region src/sig/accept.ts
16
16
  /**
@@ -917,7 +917,7 @@ function isAbortError$1(error) {
917
917
  const name = error.name;
918
918
  return typeof name === "string" && name === "AbortError";
919
919
  }
920
- const KNOWN_HTTP_METHODS = new Set([
920
+ const KNOWN_HTTP_METHODS = /* @__PURE__ */ new Set([
921
921
  "CONNECT",
922
922
  "DELETE",
923
923
  "GET",
@@ -1716,7 +1716,7 @@ function getKeyFetchErrorName(error) {
1716
1716
  * algorithm, so unknown values are dropped from the metric to prevent
1717
1717
  * cardinality blow-up.
1718
1718
  */
1719
- const DRAFT_KNOWN_ALGORITHMS = new Set([
1719
+ const DRAFT_KNOWN_ALGORITHMS = /* @__PURE__ */ new Set([
1720
1720
  "ecdsa-sha256",
1721
1721
  "ecdsa-sha384",
1722
1722
  "ecdsa-sha512",
@@ -1,10 +1,10 @@
1
1
  import { Temporal } from "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-DtHcfB0f.mjs";
5
- import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-DT-CnD1g.mjs";
6
- import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature } from "./accept-8PiolDP7.mjs";
7
- import { o as validateCryptoKey, r as fetchKeyDetailed } from "./key-CM7wDnZG.mjs";
4
+ import { n as version, t as name } from "./deno-Deyoxesx.mjs";
5
+ import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-AlCGTDrr.mjs";
6
+ import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature } from "./accept-CPVqki78.mjs";
7
+ import { o as validateCryptoKey, r as fetchKeyDetailed } from "./key-b4kf4yZT.mjs";
8
8
  import { getLogger } from "@logtape/logtape";
9
9
  import { CryptographicKey } from "@fedify/vocab";
10
10
  import { SpanStatusCode, trace } from "@opentelemetry/api";
@@ -325,7 +325,7 @@ function getKeyFetchErrorName(error) {
325
325
  * algorithm, so unknown values are dropped from the metric to prevent
326
326
  * cardinality blow-up.
327
327
  */
328
- const DRAFT_KNOWN_ALGORITHMS = new Set([
328
+ const DRAFT_KNOWN_ALGORITHMS = /* @__PURE__ */ new Set([
329
329
  "ecdsa-sha256",
330
330
  "ecdsa-sha384",
331
331
  "ecdsa-sha512",
@@ -1,8 +1,8 @@
1
1
  import "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-DtHcfB0f.mjs";
5
- import { _ as recordKeyLookup, n as getDurationMs, t as classifyFetchError } from "./metrics-DT-CnD1g.mjs";
4
+ import { n as version, t as name } from "./deno-Deyoxesx.mjs";
5
+ import { _ as recordKeyLookup, n as getDurationMs, t as classifyFetchError } from "./metrics-AlCGTDrr.mjs";
6
6
  import { getLogger } from "@logtape/logtape";
7
7
  import { CryptographicKey, Multikey, Object as Object$1, isActor } from "@fedify/vocab";
8
8
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
@@ -1,7 +1,5 @@
1
1
  const { URLPattern } = require("urlpattern-polyfill");
2
- require("./chunk-Czpeue4M.cjs");
3
- const require_http = require("./http-BpT5cE6r.cjs");
4
- const require_temporal_polyfill = require("./temporal-polyfill-BCdTHexd.cjs");
2
+ const require_http = require("./http-AyKngJ_h.cjs");
5
3
  let _logtape_logtape = require("@logtape/logtape");
6
4
  let es_toolkit = require("es-toolkit");
7
5
  let _fedify_vocab_runtime = require("@fedify/vocab-runtime");
@@ -46,7 +44,7 @@ function getAuthenticatedDocumentLoader(identity, { allowPrivateAddress, maxRedi
46
44
  }
47
45
  //#endregion
48
46
  //#region src/utils/kv-cache.ts
49
- const Temporal = require_temporal_polyfill.Temporal;
47
+ const Temporal = require_http.Temporal;
50
48
  const logger = (0, _logtape_logtape.getLogger)([
51
49
  "fedify",
52
50
  "utils",
@@ -1,6 +1,6 @@
1
1
  import { Temporal } from "temporal-polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { C as recordDocumentCache, d as validateCryptoKey, t as doubleKnock } from "./http-BbnOMQoy.js";
3
+ import { C as recordDocumentCache, d as validateCryptoKey, t as doubleKnock } from "./http-Bw6s_dOB.js";
4
4
  import { getLogger } from "@logtape/logtape";
5
5
  import { curry } from "es-toolkit";
6
6
  import { UrlError, createActivityPubRequest, getRemoteDocument, logRequest, preloadedContexts, validatePublicUrl } from "@fedify/vocab-runtime";
@@ -1,7 +1,7 @@
1
1
  import { Temporal } from "temporal-polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { p as recordDocumentCache } from "./metrics-DT-CnD1g.mjs";
4
+ import { p as recordDocumentCache } from "./metrics-AlCGTDrr.mjs";
5
5
  import { getLogger } from "@logtape/logtape";
6
6
  import { preloadedContexts } from "@fedify/vocab-runtime";
7
7
  //#region src/utils/kv-cache.ts
@@ -1,9 +1,9 @@
1
1
  import "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-DtHcfB0f.mjs";
5
- import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-DT-CnD1g.mjs";
6
- import { n as fetchKey, o as validateCryptoKey } from "./key-CM7wDnZG.mjs";
4
+ import { n as version, t as name } from "./deno-Deyoxesx.mjs";
5
+ import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-AlCGTDrr.mjs";
6
+ import { n as fetchKey, o as validateCryptoKey } from "./key-b4kf4yZT.mjs";
7
7
  import { getLogger } from "@logtape/logtape";
8
8
  import { Activity, CryptographicKey, Object as Object$1, getTypeId } from "@fedify/vocab";
9
9
  import { SpanStatusCode, trace } from "@opentelemetry/api";
@@ -25,7 +25,7 @@ const localContext = [
25
25
  ];
26
26
  const localContextUrls = new Set(localContext);
27
27
  const builtInContextLoader = getDocumentLoader();
28
- const disallowedJsonLdKeywords = new Set([
28
+ const disallowedJsonLdKeywords = /* @__PURE__ */ new Set([
29
29
  "@graph",
30
30
  "@included",
31
31
  "@reverse"
@@ -525,7 +525,7 @@ async function verifySignature(jsonLd, options = {}) {
525
525
  * only from external documents and are dropped from the metric attribute to
526
526
  * avoid attacker-controlled cardinality.
527
527
  */
528
- const LD_KNOWN_SIGNATURE_TYPES = new Set(["RsaSignature2017"]);
528
+ const LD_KNOWN_SIGNATURE_TYPES = /* @__PURE__ */ new Set(["RsaSignature2017"]);
529
529
  /**
530
530
  * Reports only whether a `signature` key is present on the document, with
531
531
  * no shape check on its value. This is intentionally looser than
@@ -1,7 +1,7 @@
1
1
  import "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-DtHcfB0f.mjs";
4
+ import { n as version, t as name } from "./deno-Deyoxesx.mjs";
5
5
  import { metrics } from "@opentelemetry/api";
6
6
  import { FetchError } from "@fedify/vocab-runtime";
7
7
  //#region src/federation/metrics.ts
@@ -770,7 +770,7 @@ function isAbortError(error) {
770
770
  const name = error.name;
771
771
  return typeof name === "string" && name === "AbortError";
772
772
  }
773
- const KNOWN_HTTP_METHODS = new Set([
773
+ const KNOWN_HTTP_METHODS = /* @__PURE__ */ new Set([
774
774
  "CONNECT",
775
775
  "DELETE",
776
776
  "GET",
@@ -0,0 +1,36 @@
1
+ /// <reference lib="esnext.temporal" />
2
+ import { DocumentLoader } from "@fedify/vocab-runtime";
3
+ import { MeterProvider } from "@opentelemetry/api";
4
+
5
+ //#region src/federation/metrics.d.ts
6
+ /**
7
+ * The kind of remote ActivityPub lookup, recorded as
8
+ * `activitypub.lookup.kind` on the public-key lookup and remote document
9
+ * fetch metric families.
10
+ *
11
+ * - `public_key`: a public key lookup performed by `fetchKey` /
12
+ * `fetchKeyDetailed` (always recorded on `activitypub.key.lookup*`).
13
+ * - `actor`: a document fetch whose resolved value is an Actor. The
14
+ * bucket exists in the taxonomy for future actor-aware call sites;
15
+ * today, actor documents fetched through Fedify's generic document
16
+ * loader are still classified as `object` because the kind is decided
17
+ * at the loader boundary, before the response is parsed.
18
+ * - `object`: a generic ActivityPub object fetch through Fedify's
19
+ * document loader. This is the default classification for
20
+ * `documentLoader` invocations that do not match a more specific
21
+ * bucket.
22
+ * - `context`: a JSON-LD `@context` document fetch through Fedify's
23
+ * context loader.
24
+ * - `other`: a fetch that does not fit any of the above classifications.
25
+ * @since 2.3.0
26
+ */
27
+ type LookupKind = "public_key" | "actor" | "object" | "context" | "other";
28
+ /**
29
+ * The {@link LookupKind} values that can appear on remote document fetch
30
+ * metrics. `public_key` lookups are reported on the
31
+ * `activitypub.key.lookup` metric family instead, so it is excluded here.
32
+ * @since 2.3.0
33
+ */
34
+ type DocumentFetchKind = Exclude<LookupKind, "public_key">;
35
+ //#endregion
36
+ export { DocumentFetchKind as t };
@@ -0,0 +1,36 @@
1
+ /// <reference lib="esnext.temporal" />
2
+ import { MeterProvider } from "@opentelemetry/api";
3
+ import { DocumentLoader } from "@fedify/vocab-runtime";
4
+
5
+ //#region src/federation/metrics.d.ts
6
+ /**
7
+ * The kind of remote ActivityPub lookup, recorded as
8
+ * `activitypub.lookup.kind` on the public-key lookup and remote document
9
+ * fetch metric families.
10
+ *
11
+ * - `public_key`: a public key lookup performed by `fetchKey` /
12
+ * `fetchKeyDetailed` (always recorded on `activitypub.key.lookup*`).
13
+ * - `actor`: a document fetch whose resolved value is an Actor. The
14
+ * bucket exists in the taxonomy for future actor-aware call sites;
15
+ * today, actor documents fetched through Fedify's generic document
16
+ * loader are still classified as `object` because the kind is decided
17
+ * at the loader boundary, before the response is parsed.
18
+ * - `object`: a generic ActivityPub object fetch through Fedify's
19
+ * document loader. This is the default classification for
20
+ * `documentLoader` invocations that do not match a more specific
21
+ * bucket.
22
+ * - `context`: a JSON-LD `@context` document fetch through Fedify's
23
+ * context loader.
24
+ * - `other`: a fetch that does not fit any of the above classifications.
25
+ * @since 2.3.0
26
+ */
27
+ type LookupKind = "public_key" | "actor" | "object" | "context" | "other";
28
+ /**
29
+ * The {@link LookupKind} values that can appear on remote document fetch
30
+ * metrics. `public_key` lookups are reported on the
31
+ * `activitypub.key.lookup` metric family instead, so it is excluded here.
32
+ * @since 2.3.0
33
+ */
34
+ type DocumentFetchKind = Exclude<LookupKind, "public_key">;
35
+ //#endregion
36
+ export { DocumentFetchKind as t };
@@ -1,28 +1,28 @@
1
1
  import { Temporal } from "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-DtHcfB0f.mjs";
5
- import { a as instrumentDocumentLoader, b as recordWebFingerHandle, c as recordCircuitBreakerStateChange, d as recordCollectionRequest, f as recordCollectionTotalItems, g as recordInboxActivity, h as recordFanoutRecipients, i as getRemoteHost, l as recordCollectionDispatchDuration, n as getDurationMs, o as isAbortError, r as getFederationMetrics, u as recordCollectionPageItems, v as recordOutboxActivity, x as registerQueueDepthGauge, y as recordOutboxEnqueue } from "./metrics-DT-CnD1g.mjs";
6
- import { t as formatAcceptSignature } from "./accept-8PiolDP7.mjs";
7
- import { a as importJwk, o as validateCryptoKey, t as exportJwk } from "./key-CM7wDnZG.mjs";
8
- import { l as verifyRequest, o as parseRfc9421SignatureInput, u as verifyRequestDetailed } from "./http-DUmWq5Pw.mjs";
9
- import { t as getAuthenticatedDocumentLoader } from "./docloader-0vAfF6XW.mjs";
10
- import { n as kvCache } from "./kv-cache-DEXKemJ9.mjs";
11
- import { _ as wrapContextLoaderForJsonLd, a as compactJsonLd, c as getNormalizationContextLoader, d as isClearlyMalformedContextReference, f as isInvalidUrlTypeError, l as hasSignature, m as verifyCompactJsonLd, p as signJsonLd, r as assertSafeJsonLd, s as detachSignature, t as InvalidContextReferenceError, u as hasSignatureLike } from "./ld-BttH_-8K.mjs";
12
- import { n as getKeyOwner, t as doesActorOwnKey } from "./owner-DZALmhdl.mjs";
13
- import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-URuqsICz.mjs";
14
- import { i as verifyObject, n as hasProofLike, r as signObject } from "./proof-DiQ0uBal.mjs";
15
- import { t as getNodeInfo } from "./client-CjF5IYQS.mjs";
16
- import { t as nodeInfoToJson } from "./types-CrtdVuDP.mjs";
17
- import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "./send-DcwZnQWG.mjs";
18
- import { n as FederationBuilderImpl, t as ACTOR_ALIAS_PREFIX } from "./builder-iXZ5jNVg.mjs";
19
- import { t as CircuitBreaker } from "./circuit-breaker-CBGyz5F7.mjs";
20
- import { t as buildCollectionSynchronizationHeader } from "./collection-BIhlldqK.mjs";
21
- import { t as KvKeyCache } from "./keycache-_DHqz5z_.mjs";
22
- import { t as acceptsJsonLd } from "./negotiation-RuwrPFqi.mjs";
23
- import { t as hasMalformedKnownTemporalLiteral } from "./temporal-Bpxpsl2k.mjs";
24
- import { t as createExponentialBackoffPolicy } from "./retry-DgFqeS5k.mjs";
25
- import { t as TaskCodec } from "./codec-BBga-FWI.mjs";
4
+ import { n as version, t as name } from "./deno-Deyoxesx.mjs";
5
+ import { a as instrumentDocumentLoader, b as recordWebFingerHandle, c as recordCircuitBreakerStateChange, d as recordCollectionRequest, f as recordCollectionTotalItems, g as recordInboxActivity, h as recordFanoutRecipients, i as getRemoteHost, l as recordCollectionDispatchDuration, n as getDurationMs, o as isAbortError, r as getFederationMetrics, u as recordCollectionPageItems, v as recordOutboxActivity, x as registerQueueDepthGauge, y as recordOutboxEnqueue } from "./metrics-AlCGTDrr.mjs";
6
+ import { t as formatAcceptSignature } from "./accept-CPVqki78.mjs";
7
+ import { a as importJwk, o as validateCryptoKey, t as exportJwk } from "./key-b4kf4yZT.mjs";
8
+ import { l as verifyRequest, o as parseRfc9421SignatureInput, u as verifyRequestDetailed } from "./http-TjhZfiSN.mjs";
9
+ import { t as getAuthenticatedDocumentLoader } from "./docloader-B3kuDBg9.mjs";
10
+ import { n as kvCache } from "./kv-cache-CpILvhUV.mjs";
11
+ import { _ as wrapContextLoaderForJsonLd, a as compactJsonLd, c as getNormalizationContextLoader, d as isClearlyMalformedContextReference, f as isInvalidUrlTypeError, l as hasSignature, m as verifyCompactJsonLd, p as signJsonLd, r as assertSafeJsonLd, s as detachSignature, t as InvalidContextReferenceError, u as hasSignatureLike } from "./ld-CKujkAfG.mjs";
12
+ import { n as getKeyOwner, t as doesActorOwnKey } from "./owner-D1O8v8FB.mjs";
13
+ import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-BQSHRLhg.mjs";
14
+ import { i as verifyObject, n as hasProofLike, r as signObject } from "./proof-DeMR7Akd.mjs";
15
+ import { t as getNodeInfo } from "./client-CtxvmazV.mjs";
16
+ import { t as nodeInfoToJson } from "./types-DE_LV1JB.mjs";
17
+ import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "./send-DG7JG280.mjs";
18
+ import { n as FederationBuilderImpl, t as ACTOR_ALIAS_PREFIX } from "./builder-f5-YwHfj.mjs";
19
+ import { t as CircuitBreaker } from "./circuit-breaker-BT7CiPbz.mjs";
20
+ import { t as buildCollectionSynchronizationHeader } from "./collection-CnnP1UAv.mjs";
21
+ import { t as KvKeyCache } from "./keycache-0Jk78XmB.mjs";
22
+ import { t as acceptsJsonLd } from "./negotiation-CCocWT_N.mjs";
23
+ import { t as hasMalformedKnownTemporalLiteral } from "./temporal-DA3jx8x1.mjs";
24
+ import { t as createExponentialBackoffPolicy } from "./retry-zX5xw5e0.mjs";
25
+ import { t as TaskCodec } from "./codec-peqOdBaE.mjs";
26
26
  import { getLogger, withContext } from "@logtape/logtape";
27
27
  import { RouterError } from "@fedify/uri-template";
28
28
  import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, Tombstone, getTypeId, lookupObject, traverseCollection } from "@fedify/vocab";
@@ -600,7 +600,7 @@ async function handleObject(request, { values, context, objectDispatcher, author
600
600
  Vary: "Accept"
601
601
  } });
602
602
  }
603
- const BUILT_IN_COLLECTION_METRIC_KINDS = new Set([
603
+ const BUILT_IN_COLLECTION_METRIC_KINDS = /* @__PURE__ */ new Set([
604
604
  "inbox",
605
605
  "outbox",
606
606
  "following",
@@ -2211,7 +2211,7 @@ async function respondWithObjectIfAcceptable(object, request, options) {
2211
2211
  return response;
2212
2212
  }
2213
2213
  function generateNonce() {
2214
- const bytes = new Uint8Array(16);
2214
+ const bytes = /* @__PURE__ */ new Uint8Array(16);
2215
2215
  crypto.getRandomValues(bytes);
2216
2216
  return btoa(String.fromCharCode(...bytes)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
2217
2217
  }
@@ -2480,6 +2480,24 @@ const logger = getLogger([
2480
2480
  "webfinger",
2481
2481
  "server"
2482
2482
  ]);
2483
+ function getWebFingerSubjectAndAliases({ resourceUrl, actorUri, preferredUsername, acctUsername, host, contextHost }) {
2484
+ const aliases = [];
2485
+ let subject = resourceUrl.href;
2486
+ if (resourceUrl.protocol != "acct:" && preferredUsername != null) {
2487
+ aliases.push(`acct:${preferredUsername}@${host ?? contextHost}`);
2488
+ if (host != null && host !== contextHost) aliases.push(`acct:${preferredUsername}@${contextHost}`);
2489
+ }
2490
+ if (resourceUrl.href !== actorUri.href) aliases.push(actorUri.href);
2491
+ if (resourceUrl.protocol === "acct:" && host != null && host !== contextHost && !resourceUrl.href.endsWith(`@${host}`)) {
2492
+ subject = `acct:${preferredUsername ?? acctUsername}@${host}`;
2493
+ aliases.push(resourceUrl.href);
2494
+ if (preferredUsername != null && preferredUsername !== "" && preferredUsername !== acctUsername) aliases.push(`acct:${preferredUsername}@${contextHost}`);
2495
+ }
2496
+ return {
2497
+ subject,
2498
+ aliases
2499
+ };
2500
+ }
2483
2501
  /**
2484
2502
  * Handles a WebFinger request. You would not typically call this function
2485
2503
  * directly, but instead use {@link Federation.fetch} method.
@@ -2528,7 +2546,7 @@ async function handleWebFinger(request, options) {
2528
2546
  });
2529
2547
  }
2530
2548
  }
2531
- const WEBFINGER_HANDLE_SCHEME_WHITELIST = new Set([
2549
+ const WEBFINGER_HANDLE_SCHEME_WHITELIST = /* @__PURE__ */ new Set([
2532
2550
  "acct",
2533
2551
  "http",
2534
2552
  "https",
@@ -2584,6 +2602,7 @@ async function handleWebFingerInternal(request, { context, host, actorDispatcher
2584
2602
  return identifier;
2585
2603
  }
2586
2604
  let identifier = null;
2605
+ let acctUsername = null;
2587
2606
  const uriParsed = context.parseUri(resourceUrl);
2588
2607
  if (uriParsed?.type != "actor") {
2589
2608
  const match = /^acct:([^@]+)@([^@]+)$/.exec(resource);
@@ -2597,8 +2616,9 @@ async function handleWebFingerInternal(request, { context, host, actorDispatcher
2597
2616
  const normalizedHost = portMatch == null ? domainToASCII(match[2].toLowerCase()) : domainToASCII(match[2].substring(0, portMatch.index).toLowerCase()) + portMatch[0];
2598
2617
  if (normalizedHost != context.url.host && normalizedHost != host) return await onNotFound(request);
2599
2618
  else {
2600
- identifier = await mapUsernameToIdentifier(match[1]);
2601
- resourceUrl = new URL(`acct:${match[1]}@${normalizedHost}`);
2619
+ acctUsername = match[1];
2620
+ identifier = await mapUsernameToIdentifier(acctUsername);
2621
+ resourceUrl = new URL(`acct:${acctUsername}@${normalizedHost}`);
2602
2622
  }
2603
2623
  }
2604
2624
  } else identifier = uriParsed.identifier;
@@ -2612,9 +2632,10 @@ async function handleWebFingerInternal(request, { context, host, actorDispatcher
2612
2632
  status: 410,
2613
2633
  headers: { "Access-Control-Allow-Origin": "*" }
2614
2634
  });
2635
+ const actorUri = context.getActorUri(identifier);
2615
2636
  const links = [{
2616
2637
  rel: "self",
2617
- href: context.getActorUri(identifier).href,
2638
+ href: actorUri.href,
2618
2639
  type: "application/activity+json"
2619
2640
  }];
2620
2641
  for (const url of actor.urls) if (url instanceof Link && url.href != null) links.push({
@@ -2638,23 +2659,19 @@ async function handleWebFingerInternal(request, { context, host, actorDispatcher
2638
2659
  const customLinks = await webFingerLinksDispatcher(context, resourceUrl);
2639
2660
  if (customLinks != null) for (const link of customLinks) links.push(link);
2640
2661
  }
2641
- const aliases = [];
2642
- const preferredUsername = actor.preferredUsername;
2643
- if (resourceUrl.protocol != "acct:" && preferredUsername != null) {
2644
- aliases.push(`acct:${preferredUsername}@${host ?? context.url.host}`);
2645
- if (host != null && host !== context.url.host) aliases.push(`acct:${preferredUsername}@${context.url.host}`);
2646
- }
2647
- if (resourceUrl.href !== context.getActorUri(identifier).href) aliases.push(context.getActorUri(identifier).href);
2648
- if (resourceUrl.protocol === "acct:" && host != null && host !== context.url.host && !resourceUrl.href.endsWith(`@${host}`)) {
2649
- const username = resourceUrl.href.replace(/^acct:/, "").replace(/@.*$/, "");
2650
- aliases.push(`acct:${username}@${host}`);
2651
- }
2652
- const jrd = {
2653
- subject: resourceUrl.href,
2662
+ const { subject, aliases } = getWebFingerSubjectAndAliases({
2663
+ resourceUrl,
2664
+ actorUri,
2665
+ preferredUsername: actor.preferredUsername,
2666
+ acctUsername,
2667
+ host,
2668
+ contextHost: context.url.host
2669
+ });
2670
+ return new Response(JSON.stringify({
2671
+ subject,
2654
2672
  aliases,
2655
2673
  links
2656
- };
2657
- return new Response(JSON.stringify(jrd), { headers: {
2674
+ }), { headers: {
2658
2675
  "Content-Type": "application/jrd+json",
2659
2676
  "Access-Control-Allow-Origin": "*"
2660
2677
  } });