@fedify/fedify 2.4.0-dev.1422 → 2.4.0-dev.1488

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 (105) hide show
  1. package/README.md +4 -3
  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-DQP-q39h.mjs → assert_rejects-DN60FHPX.mjs} +2 -2
  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-Gef_ZeDE.mjs → builder-Dcr6y6XD.mjs} +3 -23
  9. package/dist/compat/mod.d.cts +1 -1
  10. package/dist/compat/mod.d.ts +1 -1
  11. package/dist/compat/outgoing-jsonld.test.mjs +3 -3
  12. package/dist/compat/public-audience.test.mjs +3 -3
  13. package/dist/compat/transformers.test.mjs +5 -5
  14. package/dist/{context-BuGH_Vft.d.cts → context-BBVLF7lx.d.cts} +70 -286
  15. package/dist/{context-CLtZxCu6.d.ts → context-BU6jSQdo.d.ts} +70 -285
  16. package/dist/{context-BrIOaBSs.mjs → context-DVoTs_wM.mjs} +1 -7
  17. package/dist/{deno-BmD7XRaO.mjs → deno-BCFGf8NR.mjs} +1 -1
  18. package/dist/{docloader-B8AJowCx.mjs → docloader-DWEwaGqF.mjs} +2 -2
  19. package/dist/federation/builder.test.mjs +5 -5
  20. package/dist/federation/circuit-breaker.test.mjs +5 -5
  21. package/dist/federation/collection.test.mjs +3 -3
  22. package/dist/federation/handler.test.mjs +13 -13
  23. package/dist/federation/idempotency.test.mjs +6 -6
  24. package/dist/federation/inbox.test.mjs +3 -3
  25. package/dist/federation/keycache.test.mjs +5 -5
  26. package/dist/federation/kv.test.mjs +3 -3
  27. package/dist/federation/metrics.test.mjs +4 -4
  28. package/dist/federation/middleware.test.mjs +19 -200
  29. package/dist/federation/mod.cjs +1 -1
  30. package/dist/federation/mod.d.cts +3 -3
  31. package/dist/federation/mod.d.ts +3 -3
  32. package/dist/federation/mod.js +1 -1
  33. package/dist/federation/mq.test.mjs +260 -5
  34. package/dist/federation/negotiation.test.mjs +4 -4
  35. package/dist/federation/retry.test.mjs +3 -3
  36. package/dist/federation/router.test.mjs +5 -5
  37. package/dist/federation/send.test.mjs +10 -10
  38. package/dist/federation/temporal.test.mjs +4 -4
  39. package/dist/federation/webfinger.test.mjs +6 -6
  40. package/dist/{http-BCSQJ_gv.cjs → http-DLqxhQg1.cjs} +17 -7
  41. package/dist/{http-CJ0WNyqA.js → http-DaVoLyyA.js} +17 -7
  42. package/dist/{http-GQoPA_YT.mjs → http-RriziGDE.mjs} +4 -4
  43. package/dist/{key-BLy_TeTg.mjs → key-Bkg8Zg36.mjs} +18 -8
  44. package/dist/{kv-cache-pw-kBdVz.mjs → kv-cache-BR--9V4L.mjs} +1 -1
  45. package/dist/{kv-cache-CjEcb9qH.js → kv-cache-DxlFLMiU.js} +1 -1
  46. package/dist/{kv-cache-DXwu7BtY.cjs → kv-cache-Fw-iwKjy.cjs} +1 -1
  47. package/dist/{ld-CWgxPlZq.mjs → ld-BjsmbqO7.mjs} +3 -3
  48. package/dist/{metrics-DUKoLd_E.mjs → metrics-BLoa2pab.mjs} +1 -1
  49. package/dist/{middleware-PZaroDUk.mjs → middleware-D3kuDjvb.mjs} +44 -186
  50. package/dist/{middleware-Dq-HhJHd.mjs → middleware-DNR3YBCi.mjs} +1 -1
  51. package/dist/{middleware-BiCk4wGY.cjs → middleware-V-r1QH5Z.cjs} +31 -281
  52. package/dist/{middleware-2Us0G3Iy.js → middleware-_9t5HVBi.js} +31 -281
  53. package/dist/{mod-DRokcHeU.d.cts → mod-C0F6kvgS.d.cts} +1 -1
  54. package/dist/{mod-r-1xOW_C.d.ts → mod-vPYVoa5n.d.ts} +1 -1
  55. package/dist/mod.cjs +4 -4
  56. package/dist/mod.d.cts +4 -4
  57. package/dist/mod.d.ts +4 -4
  58. package/dist/mod.js +4 -4
  59. package/dist/nodeinfo/client.test.mjs +3 -3
  60. package/dist/nodeinfo/handler.test.mjs +5 -5
  61. package/dist/nodeinfo/types.test.mjs +4 -4
  62. package/dist/otel/exporter.test.mjs +3 -3
  63. package/dist/{outgoing-jsonld-BgFLCJQ_.mjs → outgoing-jsonld-L_DbOaFe.mjs} +1 -1
  64. package/dist/{owner-U0Z8Ex6i.mjs → owner-NK2p1ihR.mjs} +2 -2
  65. package/dist/{proof-DA3hLGSO.cjs → proof-2WI6mMbC.cjs} +1 -1
  66. package/dist/{proof-nb5tfciW.mjs → proof-CRXqo703.mjs} +5 -5
  67. package/dist/{proof-f7K32nz7.js → proof-D7WVwQzs.js} +1 -1
  68. package/dist/{send-CLfW5Fdf.mjs → send-CTaPzl8L.mjs} +3 -3
  69. package/dist/sig/accept.test.mjs +1 -1
  70. package/dist/sig/http.test.mjs +8 -8
  71. package/dist/sig/key.test.mjs +56 -6
  72. package/dist/sig/ld.test.mjs +7 -7
  73. package/dist/sig/mod.cjs +2 -2
  74. package/dist/sig/mod.js +2 -2
  75. package/dist/sig/owner.test.mjs +6 -6
  76. package/dist/sig/proof.test.mjs +8 -8
  77. package/dist/{std__assert-BTEgfoJo.mjs → std__assert-BBjXFNOb.mjs} +4 -4
  78. package/dist/{temporal-2ry_jdCK.mjs → temporal-C8M0Y7v9.mjs} +1 -1
  79. package/dist/testing/mod.d.mts +7 -378
  80. package/dist/testing/mod.mjs +2 -3
  81. package/dist/utils/docloader.test.mjs +6 -6
  82. package/dist/utils/kv-cache.test.mjs +1 -1
  83. package/dist/utils/mod.cjs +1 -1
  84. package/dist/utils/mod.js +1 -1
  85. package/package.json +8 -13
  86. package/dist/codec-Bf-rTqks.mjs +0 -94
  87. package/dist/federation/tasks/codec.test.d.mts +0 -2
  88. package/dist/federation/tasks/codec.test.mjs +0 -292
  89. package/dist/federation/tasks/tasks.test.d.mts +0 -2
  90. package/dist/federation/tasks/tasks.test.mjs +0 -651
  91. package/dist/mq-CvJAzRz5.mjs +0 -260
  92. package/dist/testing-CjYPStvE.mjs +0 -55
  93. /package/dist/{accept-CceiKpCy.mjs → accept-CPkZzmGN.mjs} +0 -0
  94. /package/dist/{activity-listener-BeTGV3wc.mjs → activity-listener-tztVvlNb.mjs} +0 -0
  95. /package/dist/{assert_equals-Ew3jOFa3.mjs → assert_equals-C-ZRDbaf.mjs} +0 -0
  96. /package/dist/{circuit-breaker-hJBB6jwA.mjs → circuit-breaker-CSWsyoef.mjs} +0 -0
  97. /package/dist/{client-B_A6mfn3.mjs → client-ByXmQhYD.mjs} +0 -0
  98. /package/dist/{collection-Dp5ky45w.mjs → collection-Cc3DVAhE.mjs} +0 -0
  99. /package/dist/{keycache-CaOR6NYg.mjs → keycache-BeU0LCII.mjs} +0 -0
  100. /package/dist/{keys-C3kae-6B.mjs → keys-DGu1NFwu.mjs} +0 -0
  101. /package/dist/{kv-x2IvBUyq.mjs → kv-rV3vodCc.mjs} +0 -0
  102. /package/dist/{negotiation-m_L2nyS3.mjs → negotiation-DDstyBvc.mjs} +0 -0
  103. /package/dist/{public-audience-N3pyOx2p.mjs → public-audience-Cvbr2Gzt.mjs} +0 -0
  104. /package/dist/{retry-DI4O-zYl.mjs → retry-CXg_MBI-.mjs} +0 -0
  105. /package/dist/{types-BFowWFTT.mjs → types-J53Kw7so.mjs} +0 -0
@@ -2,16 +2,16 @@ import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as esm_default } from "../esm-vrlUxr60.mjs";
5
- import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
- import "../std__assert-BTEgfoJo.mjs";
7
- import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-DQP-q39h.mjs";
8
- import { t as assertInstanceOf } from "../assert_instance_of-C4Ri6VuN.mjs";
9
- import { t as assertNotEquals } from "../assert_not_equals--wG9hV7u.mjs";
10
- import { t as assert } from "../assert-DikXweDx.mjs";
11
- import { l as verifyRequest } from "../http-GQoPA_YT.mjs";
12
- import { i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-C3kae-6B.mjs";
13
- import { t as doesActorOwnKey } from "../owner-U0Z8Ex6i.mjs";
14
- import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-CLfW5Fdf.mjs";
5
+ import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
6
+ import "../std__assert-BBjXFNOb.mjs";
7
+ import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-DN60FHPX.mjs";
8
+ import { t as assertInstanceOf } from "../assert_instance_of-DBC5X09g.mjs";
9
+ import { t as assertNotEquals } from "../assert_not_equals-DkVK8oqV.mjs";
10
+ import { t as assert } from "../assert-OguE97r2.mjs";
11
+ import { l as verifyRequest } from "../http-RriziGDE.mjs";
12
+ import { i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DGu1NFwu.mjs";
13
+ import { t as doesActorOwnKey } from "../owner-NK2p1ihR.mjs";
14
+ import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-CTaPzl8L.mjs";
15
15
  import { Activity, Application, Endpoints, Group, Person, Service } from "@fedify/vocab";
16
16
  import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
17
17
  import { FetchError } from "@fedify/vocab-runtime";
@@ -1,10 +1,10 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import "../std__assert-BTEgfoJo.mjs";
5
- import { r as assertFalse } from "../assert_rejects-DQP-q39h.mjs";
6
- import { t as assert } from "../assert-DikXweDx.mjs";
7
- import { t as hasMalformedKnownTemporalLiteral } from "../temporal-2ry_jdCK.mjs";
4
+ import "../std__assert-BBjXFNOb.mjs";
5
+ import { r as assertFalse } from "../assert_rejects-DN60FHPX.mjs";
6
+ import { t as assert } from "../assert-OguE97r2.mjs";
7
+ import { t as hasMalformedKnownTemporalLiteral } from "../temporal-C8M0Y7v9.mjs";
8
8
  import { test } from "@fedify/fixture";
9
9
  //#region src/federation/temporal.test.ts
10
10
  test("hasMalformedKnownTemporalLiteral() detects expanded proof timestamps", async () => {
@@ -1,12 +1,12 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { r as createRequestContext } from "../context-BrIOaBSs.mjs";
5
- import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
- import "../std__assert-BTEgfoJo.mjs";
7
- import { t as assertNotEquals } from "../assert_not_equals--wG9hV7u.mjs";
8
- import { t as MemoryKvStore } from "../kv-x2IvBUyq.mjs";
9
- import { o as createFederation, s as handleWebFinger } from "../middleware-PZaroDUk.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
+ import { t as assertNotEquals } from "../assert_not_equals-DkVK8oqV.mjs";
8
+ import { t as MemoryKvStore } from "../kv-rV3vodCc.mjs";
9
+ import { o as createFederation, s as handleWebFinger } from "../middleware-D3kuDjvb.mjs";
10
10
  import { Image, Link, Person, Tombstone } from "@fedify/vocab";
11
11
  import { createTestMeterProvider, test } from "@fedify/fixture";
12
12
  //#region src/federation/webfinger.test.ts
@@ -11,7 +11,7 @@ let _opentelemetry_semantic_conventions = require("@opentelemetry/semantic-conve
11
11
  let byte_encodings_base64 = require("byte-encodings/base64");
12
12
  //#region deno.json
13
13
  var name = "@fedify/fedify";
14
- var version = "2.4.0-dev.1422+7668da16";
14
+ var version = "2.4.0-dev.1488+a9fe1094";
15
15
  //#endregion
16
16
  //#region src/sig/accept.ts
17
17
  /**
@@ -1201,21 +1201,31 @@ async function resolveFetchedKey(document, cacheKey, keyId, cls, { documentLoade
1201
1201
  const keys = cls === _fedify_vocab.CryptographicKey ? object.getPublicKeys({
1202
1202
  documentLoader,
1203
1203
  contextLoader,
1204
+ suppressError: true,
1204
1205
  tracerProvider
1205
1206
  }) : object.getAssertionMethods({
1206
1207
  documentLoader,
1207
1208
  contextLoader,
1209
+ suppressError: true,
1208
1210
  tracerProvider
1209
1211
  });
1210
1212
  let length = 0;
1211
1213
  let lastKey = null;
1212
- for await (const k of keys) {
1213
- length++;
1214
- lastKey = k;
1215
- if (k.id?.href === keyId) {
1216
- key = k;
1217
- break;
1214
+ try {
1215
+ for await (const k of keys) {
1216
+ length++;
1217
+ lastKey = k;
1218
+ if (k.id?.href === keyId) {
1219
+ key = k;
1220
+ break;
1221
+ }
1218
1222
  }
1223
+ } catch (e) {
1224
+ if (!(e instanceof TypeError)) throw e;
1225
+ logger.debug("Failed to verify; a malformed key was encountered while iterating the keys of {keyId}; treating it as a missing key: {error}", {
1226
+ keyId,
1227
+ error: e
1228
+ });
1219
1229
  }
1220
1230
  const keyIdUrl = new URL(keyId);
1221
1231
  if (key == null && keyIdUrl.hash === "" && length === 1) key = lastKey;
@@ -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.1422+7668da16";
13
+ var version = "2.4.0-dev.1488+a9fe1094";
14
14
  //#endregion
15
15
  //#region src/sig/accept.ts
16
16
  /**
@@ -1200,21 +1200,31 @@ async function resolveFetchedKey(document, cacheKey, keyId, cls, { documentLoade
1200
1200
  const keys = cls === CryptographicKey ? object.getPublicKeys({
1201
1201
  documentLoader,
1202
1202
  contextLoader,
1203
+ suppressError: true,
1203
1204
  tracerProvider
1204
1205
  }) : object.getAssertionMethods({
1205
1206
  documentLoader,
1206
1207
  contextLoader,
1208
+ suppressError: true,
1207
1209
  tracerProvider
1208
1210
  });
1209
1211
  let length = 0;
1210
1212
  let lastKey = null;
1211
- for await (const k of keys) {
1212
- length++;
1213
- lastKey = k;
1214
- if (k.id?.href === keyId) {
1215
- key = k;
1216
- break;
1213
+ try {
1214
+ for await (const k of keys) {
1215
+ length++;
1216
+ lastKey = k;
1217
+ if (k.id?.href === keyId) {
1218
+ key = k;
1219
+ break;
1220
+ }
1217
1221
  }
1222
+ } catch (e) {
1223
+ if (!(e instanceof TypeError)) throw e;
1224
+ logger.debug("Failed to verify; a malformed key was encountered while iterating the keys of {keyId}; treating it as a missing key: {error}", {
1225
+ keyId,
1226
+ error: e
1227
+ });
1218
1228
  }
1219
1229
  const keyIdUrl = new URL(keyId);
1220
1230
  if (key == null && keyIdUrl.hash === "" && length === 1) key = lastKey;
@@ -1,10 +1,10 @@
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-BmD7XRaO.mjs";
5
- import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-DUKoLd_E.mjs";
6
- import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature } from "./accept-CceiKpCy.mjs";
7
- import { o as validateCryptoKey, r as fetchKeyDetailed } from "./key-BLy_TeTg.mjs";
4
+ import { n as version, t as name } from "./deno-BCFGf8NR.mjs";
5
+ import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-BLoa2pab.mjs";
6
+ import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature } from "./accept-CPkZzmGN.mjs";
7
+ import { o as validateCryptoKey, r as fetchKeyDetailed } from "./key-Bkg8Zg36.mjs";
8
8
  import { getLogger } from "@logtape/logtape";
9
9
  import { CryptographicKey } from "@fedify/vocab";
10
10
  import { SpanStatusCode, trace } from "@opentelemetry/api";
@@ -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-BmD7XRaO.mjs";
5
- import { _ as recordKeyLookup, n as getDurationMs, t as classifyFetchError } from "./metrics-DUKoLd_E.mjs";
4
+ import { n as version, t as name } from "./deno-BCFGf8NR.mjs";
5
+ import { _ as recordKeyLookup, n as getDurationMs, t as classifyFetchError } from "./metrics-BLoa2pab.mjs";
6
6
  import { getLogger } from "@logtape/logtape";
7
7
  import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
8
8
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
@@ -248,21 +248,31 @@ async function resolveFetchedKey(document, cacheKey, keyId, cls, { documentLoade
248
248
  const keys = cls === CryptographicKey ? object.getPublicKeys({
249
249
  documentLoader,
250
250
  contextLoader,
251
+ suppressError: true,
251
252
  tracerProvider
252
253
  }) : object.getAssertionMethods({
253
254
  documentLoader,
254
255
  contextLoader,
256
+ suppressError: true,
255
257
  tracerProvider
256
258
  });
257
259
  let length = 0;
258
260
  let lastKey = null;
259
- for await (const k of keys) {
260
- length++;
261
- lastKey = k;
262
- if (k.id?.href === keyId) {
263
- key = k;
264
- break;
261
+ try {
262
+ for await (const k of keys) {
263
+ length++;
264
+ lastKey = k;
265
+ if (k.id?.href === keyId) {
266
+ key = k;
267
+ break;
268
+ }
265
269
  }
270
+ } catch (e) {
271
+ if (!(e instanceof TypeError)) throw e;
272
+ logger.debug("Failed to verify; a malformed key was encountered while iterating the keys of {keyId}; treating it as a missing key: {error}", {
273
+ keyId,
274
+ error: e
275
+ });
266
276
  }
267
277
  const keyIdUrl = new URL(keyId);
268
278
  if (key == null && keyIdUrl.hash === "" && length === 1) key = lastKey;
@@ -1,7 +1,7 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { p as recordDocumentCache } from "./metrics-DUKoLd_E.mjs";
4
+ import { p as recordDocumentCache } from "./metrics-BLoa2pab.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,6 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { C as recordDocumentCache, d as validateCryptoKey, t as doubleKnock } from "./http-CJ0WNyqA.js";
3
+ import { C as recordDocumentCache, d as validateCryptoKey, t as doubleKnock } from "./http-DaVoLyyA.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
  const { Temporal } = require("@js-temporal/polyfill");
2
2
  const { URLPattern } = require("urlpattern-polyfill");
3
3
  require("./chunk-DDcVe30Y.cjs");
4
- const require_http = require("./http-BCSQJ_gv.cjs");
4
+ const require_http = require("./http-DLqxhQg1.cjs");
5
5
  let _logtape_logtape = require("@logtape/logtape");
6
6
  let es_toolkit = require("es-toolkit");
7
7
  let _fedify_vocab_runtime = require("@fedify/vocab-runtime");
@@ -1,9 +1,9 @@
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-BmD7XRaO.mjs";
5
- import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-DUKoLd_E.mjs";
6
- import { n as fetchKey, o as validateCryptoKey } from "./key-BLy_TeTg.mjs";
4
+ import { n as version, t as name } from "./deno-BCFGf8NR.mjs";
5
+ import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-BLoa2pab.mjs";
6
+ import { n as fetchKey, o as validateCryptoKey } from "./key-Bkg8Zg36.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";
@@ -1,7 +1,7 @@
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-BmD7XRaO.mjs";
4
+ import { n as version, t as name } from "./deno-BCFGf8NR.mjs";
5
5
  import { metrics } from "@opentelemetry/api";
6
6
  import { FetchError } from "@fedify/vocab-runtime";
7
7
  //#region src/federation/metrics.ts
@@ -1,28 +1,27 @@
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-BmD7XRaO.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-DUKoLd_E.mjs";
6
- import { t as formatAcceptSignature } from "./accept-CceiKpCy.mjs";
7
- import { a as importJwk, o as validateCryptoKey, t as exportJwk } from "./key-BLy_TeTg.mjs";
8
- import { l as verifyRequest, o as parseRfc9421SignatureInput, u as verifyRequestDetailed } from "./http-GQoPA_YT.mjs";
9
- import { t as getAuthenticatedDocumentLoader } from "./docloader-B8AJowCx.mjs";
10
- import { n as kvCache } from "./kv-cache-pw-kBdVz.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-CWgxPlZq.mjs";
12
- import { n as getKeyOwner, t as doesActorOwnKey } from "./owner-U0Z8Ex6i.mjs";
13
- import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-BgFLCJQ_.mjs";
14
- import { i as verifyObject, n as hasProofLike, r as signObject } from "./proof-nb5tfciW.mjs";
15
- import { t as getNodeInfo } from "./client-B_A6mfn3.mjs";
16
- import { t as nodeInfoToJson } from "./types-BFowWFTT.mjs";
17
- import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "./send-CLfW5Fdf.mjs";
18
- import { n as FederationBuilderImpl, t as ACTOR_ALIAS_PREFIX } from "./builder-Gef_ZeDE.mjs";
19
- import { t as CircuitBreaker } from "./circuit-breaker-hJBB6jwA.mjs";
20
- import { t as buildCollectionSynchronizationHeader } from "./collection-Dp5ky45w.mjs";
21
- import { t as KvKeyCache } from "./keycache-CaOR6NYg.mjs";
22
- import { t as acceptsJsonLd } from "./negotiation-m_L2nyS3.mjs";
23
- import { t as hasMalformedKnownTemporalLiteral } from "./temporal-2ry_jdCK.mjs";
24
- import { t as createExponentialBackoffPolicy } from "./retry-DI4O-zYl.mjs";
25
- import { t as TaskCodec } from "./codec-Bf-rTqks.mjs";
4
+ import { n as version, t as name } from "./deno-BCFGf8NR.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-BLoa2pab.mjs";
6
+ import { t as formatAcceptSignature } from "./accept-CPkZzmGN.mjs";
7
+ import { a as importJwk, o as validateCryptoKey, t as exportJwk } from "./key-Bkg8Zg36.mjs";
8
+ import { l as verifyRequest, o as parseRfc9421SignatureInput, u as verifyRequestDetailed } from "./http-RriziGDE.mjs";
9
+ import { t as getAuthenticatedDocumentLoader } from "./docloader-DWEwaGqF.mjs";
10
+ import { n as kvCache } from "./kv-cache-BR--9V4L.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-BjsmbqO7.mjs";
12
+ import { n as getKeyOwner, t as doesActorOwnKey } from "./owner-NK2p1ihR.mjs";
13
+ import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-L_DbOaFe.mjs";
14
+ import { i as verifyObject, n as hasProofLike, r as signObject } from "./proof-CRXqo703.mjs";
15
+ import { t as getNodeInfo } from "./client-ByXmQhYD.mjs";
16
+ import { t as nodeInfoToJson } from "./types-J53Kw7so.mjs";
17
+ import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "./send-CTaPzl8L.mjs";
18
+ import { n as FederationBuilderImpl, t as ACTOR_ALIAS_PREFIX } from "./builder-Dcr6y6XD.mjs";
19
+ import { t as CircuitBreaker } from "./circuit-breaker-CSWsyoef.mjs";
20
+ import { t as buildCollectionSynchronizationHeader } from "./collection-Cc3DVAhE.mjs";
21
+ import { t as KvKeyCache } from "./keycache-BeU0LCII.mjs";
22
+ import { t as acceptsJsonLd } from "./negotiation-DDstyBvc.mjs";
23
+ import { t as hasMalformedKnownTemporalLiteral } from "./temporal-C8M0Y7v9.mjs";
24
+ import { t as createExponentialBackoffPolicy } from "./retry-CXg_MBI-.mjs";
26
25
  import { getLogger, withContext } from "@logtape/logtape";
27
26
  import { RouterError } from "@fedify/uri-template";
28
27
  import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, Tombstone, getTypeId, lookupObject, traverseCollection } from "@fedify/vocab";
@@ -2393,6 +2392,15 @@ function isPermanentRemoteContextError(error) {
2393
2392
  function isPermanentInboxParseError(error) {
2394
2393
  return error instanceof Error && (error.name === "UnsafeJsonLdError" || error instanceof InvalidContextReferenceError || isPermanentRemoteContextError(error) || error.name === "jsonld.SyntaxError" && !isRemoteContextLoadingFailure(error)) || error instanceof TypeError && (/^(Invalid JSON-LD:|Invalid type:|Unexpected type:|Invalid @id:)/.test(error.message) || isInvalidUrlTypeError(error));
2395
2394
  }
2395
+ function hasLinkedDataSignatureJsonLdProcessingError(error) {
2396
+ if (error.message.startsWith("Maximum deep iterations exceeded")) return true;
2397
+ const cause = error.cause instanceof Error ? error.cause : error.details?.cause;
2398
+ if (error.name === "jsonld.InvalidUrl" && error.details?.code === "loading remote context failed" && cause instanceof Error) return cause.message.startsWith("Maximum deep iterations exceeded") || cause.name.startsWith("jsonld.");
2399
+ return error.name !== "jsonld.InvalidUrl" && error.name.startsWith("jsonld.");
2400
+ }
2401
+ function isLinkedDataSignatureJsonLdProcessingError(error) {
2402
+ return error instanceof Error && hasLinkedDataSignatureJsonLdProcessingError(error);
2403
+ }
2396
2404
  /**
2397
2405
  * Create a new {@link Federation} instance.
2398
2406
  * @param options Parameters for initializing the instance.
@@ -2410,12 +2418,9 @@ var FederationImpl = class extends FederationBuilderImpl {
2410
2418
  inboxQueue;
2411
2419
  outboxQueue;
2412
2420
  fanoutQueue;
2413
- taskQueue;
2414
2421
  inboxQueueStarted;
2415
2422
  outboxQueueStarted;
2416
2423
  fanoutQueueStarted;
2417
- taskQueueStarted;
2418
- startedTaskQueues;
2419
2424
  manuallyStartQueue;
2420
2425
  origin;
2421
2426
  documentLoaderFactory;
@@ -2429,8 +2434,6 @@ var FederationImpl = class extends FederationBuilderImpl {
2429
2434
  skipSignatureVerification;
2430
2435
  outboxRetryPolicy;
2431
2436
  inboxRetryPolicy;
2432
- taskRetryPolicy;
2433
- taskQueueResolution;
2434
2437
  circuitBreaker;
2435
2438
  activityTransformers;
2436
2439
  _tracerProvider;
@@ -2476,17 +2479,14 @@ var FederationImpl = class extends FederationBuilderImpl {
2476
2479
  this.inboxQueue = void 0;
2477
2480
  this.outboxQueue = void 0;
2478
2481
  this.fanoutQueue = void 0;
2479
- this.taskQueue = void 0;
2480
2482
  } else if ("enqueue" in options.queue && "listen" in options.queue) {
2481
2483
  this.inboxQueue = options.queue;
2482
2484
  this.outboxQueue = options.queue;
2483
2485
  this.fanoutQueue = options.queue;
2484
- this.taskQueue = void 0;
2485
2486
  } else {
2486
2487
  this.inboxQueue = options.queue.inbox;
2487
2488
  this.outboxQueue = options.queue.outbox;
2488
2489
  this.fanoutQueue = options.queue.fanout;
2489
- this.taskQueue = options.queue.task;
2490
2490
  }
2491
2491
  if (options.circuitBreaker !== false && this.outboxQueue != null) {
2492
2492
  this.circuitBreaker = new CircuitBreaker({
@@ -2510,8 +2510,6 @@ var FederationImpl = class extends FederationBuilderImpl {
2510
2510
  this.inboxQueueStarted = false;
2511
2511
  this.outboxQueueStarted = false;
2512
2512
  this.fanoutQueueStarted = false;
2513
- this.taskQueueStarted = false;
2514
- this.startedTaskQueues = /* @__PURE__ */ new Set();
2515
2513
  this.manuallyStartQueue = options.manuallyStartQueue ?? false;
2516
2514
  if (options.origin != null) if (typeof options.origin === "string") {
2517
2515
  if (!URL.canParse(options.origin) || !options.origin.match(/^https?:\/\//)) throw new TypeError(`Invalid origin: ${JSON.stringify(options.origin)}`);
@@ -2593,8 +2591,6 @@ var FederationImpl = class extends FederationBuilderImpl {
2593
2591
  this.inboxChallengePolicy = options.inboxChallengePolicy;
2594
2592
  this.outboxRetryPolicy = options.outboxRetryPolicy ?? createExponentialBackoffPolicy();
2595
2593
  this.inboxRetryPolicy = options.inboxRetryPolicy ?? createExponentialBackoffPolicy();
2596
- this.taskRetryPolicy = options.taskRetryPolicy ?? createExponentialBackoffPolicy();
2597
- this.taskQueueResolution = options.taskQueueResolution ?? "fallback";
2598
2594
  this.activityTransformers = options.activityTransformers ?? getDefaultActivityTransformers();
2599
2595
  this._tracerProvider = options.tracerProvider;
2600
2596
  if (benchmarkMode) {
@@ -2643,14 +2639,8 @@ var FederationImpl = class extends FederationBuilderImpl {
2643
2639
  _getTracer() {
2644
2640
  return this.tracerProvider.getTracer(name, version);
2645
2641
  }
2646
- resolveTaskQueue(taskName) {
2647
- const resolved = this.taskDefinitions.get(taskName)?.queue ?? this.taskQueue;
2648
- if (resolved != null) return resolved;
2649
- return this.taskQueueResolution === "strict" ? void 0 : this.outboxQueue;
2650
- }
2651
2642
  async _startQueueInternal(ctxData, signal, queue) {
2652
- const hasDedicatedTaskQueue = [...this.taskDefinitions.values()].some((def) => def.queue != null);
2653
- if (this.inboxQueue == null && this.outboxQueue == null && this.fanoutQueue == null && this.taskQueue == null && !hasDedicatedTaskQueue) return;
2643
+ if (this.inboxQueue == null && this.outboxQueue == null) return;
2654
2644
  const logger = getLogger([
2655
2645
  "fedify",
2656
2646
  "federation",
@@ -2672,26 +2662,6 @@ var FederationImpl = class extends FederationBuilderImpl {
2672
2662
  this.fanoutQueueStarted = true;
2673
2663
  promises.push(this.fanoutQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
2674
2664
  }
2675
- if (this.taskQueue != null && this.taskQueue !== this.inboxQueue && this.taskQueue !== this.outboxQueue && this.taskQueue !== this.fanoutQueue && (queue == null || queue === "task") && !this.taskQueueStarted) {
2676
- logger.debug("Starting a task worker.");
2677
- this.taskQueueStarted = true;
2678
- promises.push(this.taskQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
2679
- }
2680
- if (queue == null || queue === "task") {
2681
- const standardQueues = new Set([
2682
- this.inboxQueue,
2683
- this.outboxQueue,
2684
- this.fanoutQueue,
2685
- this.taskQueue
2686
- ].filter((q) => q != null));
2687
- for (const def of this.taskDefinitions.values()) {
2688
- const taskQueue = def.queue;
2689
- if (taskQueue == null || standardQueues.has(taskQueue) || this.startedTaskQueues.has(taskQueue)) continue;
2690
- logger.debug("Starting a worker for a dedicated per-task queue.");
2691
- this.startedTaskQueues.add(taskQueue);
2692
- promises.push(taskQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
2693
- }
2694
- }
2695
2665
  await Promise.all(promises);
2696
2666
  }
2697
2667
  processQueuedTask(contextData, message) {
@@ -2813,7 +2783,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2813
2783
  }
2814
2784
  });
2815
2785
  });
2816
- } else if (message.type === "task") await this.#listenTaskMessage(contextData, message);
2786
+ }
2817
2787
  });
2818
2788
  }
2819
2789
  async #listenFanoutMessage(data, message) {
@@ -3377,77 +3347,6 @@ var FederationImpl = class extends FederationBuilderImpl {
3377
3347
  listenerSpan.end();
3378
3348
  });
3379
3349
  }
3380
- async #listenTaskMessage(contextData, message) {
3381
- const logger = getLogger([
3382
- "fedify",
3383
- "federation",
3384
- "task"
3385
- ]);
3386
- const def = this.taskDefinitions.get(message.taskName);
3387
- if (def == null) {
3388
- logger.warn("Received a custom task {taskName} with no registered handler; dropping.", { taskName: message.taskName });
3389
- return;
3390
- }
3391
- const context = this.#createContext(new URL(message.baseUrl), contextData);
3392
- let data;
3393
- try {
3394
- data = await context.codec.decode(def.schema, message.data);
3395
- } catch (error) {
3396
- logger.error("Custom task {taskName} payload could not be decoded or validated; dropping:\n{error}", {
3397
- taskName: message.taskName,
3398
- error
3399
- });
3400
- return;
3401
- }
3402
- try {
3403
- await def.handler(context, data);
3404
- } catch (error) {
3405
- if (def.onError != null) try {
3406
- await def.onError(context, error, data);
3407
- } catch (onErrorError) {
3408
- logger.error("onError for custom task {taskName} threw:\n{error}", {
3409
- taskName: message.taskName,
3410
- error: onErrorError
3411
- });
3412
- }
3413
- const queue = this.resolveTaskQueue(def.name);
3414
- if (queue?.nativeRetrial) throw error;
3415
- const retryPolicy = def.retryPolicy ?? this.taskRetryPolicy;
3416
- let elapsedTime = Temporal.Duration.from({ seconds: 0 });
3417
- try {
3418
- elapsedTime = Temporal.Instant.from(message.started).until(Temporal.Now.instant());
3419
- } catch (parseError) {
3420
- logger.error("Custom task {taskName} has an unparsable started time {started}; treating elapsedTime as zero:\n{error}", {
3421
- taskName: message.taskName,
3422
- started: message.started,
3423
- error: parseError
3424
- });
3425
- }
3426
- const delay = retryPolicy({
3427
- elapsedTime,
3428
- attempts: message.attempt
3429
- });
3430
- if (delay != null && queue != null) {
3431
- logger.error("Custom task {taskName} failed (attempt #{attempt}); retry...:\n{error}", {
3432
- taskName: message.taskName,
3433
- attempt: message.attempt,
3434
- error
3435
- });
3436
- const retryMessage = {
3437
- ...message,
3438
- attempt: message.attempt + 1
3439
- };
3440
- await queue.enqueue(retryMessage, {
3441
- delay: clampNegativeDelay(delay),
3442
- orderingKey: message.orderingKey
3443
- });
3444
- } else logger.error("Custom task {taskName} failed after {attempt} attempts; giving up:\n{error}", {
3445
- taskName: message.taskName,
3446
- attempt: message.attempt,
3447
- error
3448
- });
3449
- }
3450
- }
3451
3350
  startQueue(contextData, options = {}) {
3452
3351
  return this._startQueueInternal(contextData, options.signal, options.queue);
3453
3352
  }
@@ -3536,10 +3435,18 @@ var FederationImpl = class extends FederationBuilderImpl {
3536
3435
  privateKey: pair.privateKey
3537
3436
  }))
3538
3437
  });
3539
- else jsonLd = await signJsonLd(jsonLd, rsaKey.privateKey, rsaKey.keyId, {
3540
- contextLoader,
3541
- tracerProvider: this.tracerProvider
3542
- });
3438
+ else try {
3439
+ jsonLd = await signJsonLd(jsonLd, rsaKey.privateKey, rsaKey.keyId, {
3440
+ contextLoader,
3441
+ tracerProvider: this.tracerProvider
3442
+ });
3443
+ } catch (error) {
3444
+ if (!isLinkedDataSignatureJsonLdProcessingError(error)) throw error;
3445
+ logger.warn("Failed to create a Linked Data signature for the activity {activityId}. The activity will be sent without a Linked Data signature.", {
3446
+ activityId,
3447
+ error
3448
+ });
3449
+ }
3543
3450
  if (!hasProof) logger.warn("No supported key found to create a proof for the activity {activityId}. The activity will be sent without a proof. In order to create a proof, at least one Ed25519 key must be provided.", {
3544
3451
  activityId,
3545
3452
  keys: keys.map((pair) => ({
@@ -4024,7 +3931,6 @@ var ContextImpl = class ContextImpl {
4024
3931
  documentLoader;
4025
3932
  contextLoader;
4026
3933
  invokedFromActorKeyPairsDispatcher;
4027
- #codec;
4028
3934
  constructor({ url, federation, data, documentLoader, contextLoader, invokedFromActorKeyPairsDispatcher }) {
4029
3935
  this.url = url;
4030
3936
  this.federation = federation;
@@ -4033,15 +3939,6 @@ var ContextImpl = class ContextImpl {
4033
3939
  this.contextLoader = contextLoader;
4034
3940
  this.invokedFromActorKeyPairsDispatcher = invokedFromActorKeyPairsDispatcher;
4035
3941
  }
4036
- /**
4037
- * A {@link TaskCodec} bound to this context's loaders, used to encode
4038
- * and decode custom task payloads. Lazily created and cached so a context
4039
- * that never enqueues or dispatches a task pays nothing.
4040
- * @internal
4041
- */
4042
- get codec() {
4043
- return this.#codec ??= new TaskCodec(this);
4044
- }
4045
3942
  clone(data) {
4046
3943
  return new ContextImpl({
4047
3944
  url: this.url,
@@ -4360,45 +4257,6 @@ var ContextImpl = class ContextImpl {
4360
4257
  allowPrivateAddress: this.federation.allowPrivateAddress
4361
4258
  });
4362
4259
  }
4363
- async enqueueTask(task, data, options = {}) {
4364
- await this.#enqueueTasks(task, [data], options);
4365
- }
4366
- async enqueueTaskMany(task, payloads, options = {}) {
4367
- await this.#enqueueTasks(task, payloads, options);
4368
- }
4369
- async #enqueueTasks(task, items, options) {
4370
- const def = this.federation.taskDefinitions.get(task.name);
4371
- if (def == null || def.handle !== task) throw new TypeError(`Task ${JSON.stringify(task.name)} is not defined on this federation; pass a handle returned by its defineTask().`);
4372
- const queue = this.federation.resolveTaskQueue(task.name);
4373
- if (queue == null) throw new TypeError("No message queue is configured for tasks; pass `queue` to createFederation() or to defineTask().");
4374
- if (items.length < 1) return;
4375
- const delay = options.delay == null ? void 0 : Temporal.Duration.from(options.delay);
4376
- const messages = await Promise.all(items.map(this.#encodeTaskMessage(task, options)));
4377
- if (!this.federation.manuallyStartQueue) this.federation._startQueueInternal(this.data);
4378
- const enqueueOptions = {
4379
- delay,
4380
- orderingKey: options.orderingKey
4381
- };
4382
- if (messages.length === 1) await queue.enqueue(messages[0], enqueueOptions);
4383
- else if (queue.enqueueMany != null) await queue.enqueueMany(messages, enqueueOptions);
4384
- else await Promise.all(messages.map((m) => queue.enqueue(m, enqueueOptions)));
4385
- }
4386
- #encodeTaskMessage = (task, options) => async (data) => {
4387
- const encoded = await this.codec.encode(task.schema, data);
4388
- const carrier = {};
4389
- propagation.inject(context.active(), carrier);
4390
- return {
4391
- type: "task",
4392
- id: crypto.randomUUID(),
4393
- baseUrl: this.origin,
4394
- taskName: task.name,
4395
- data: encoded,
4396
- started: Temporal.Now.instant().toString(),
4397
- attempt: 0,
4398
- orderingKey: options.orderingKey,
4399
- traceContext: carrier
4400
- };
4401
- };
4402
4260
  sendActivity(sender, recipients, activity, options = {}) {
4403
4261
  return this.tracerProvider.getTracer(name, version).startActiveSpan(this.federation.outboxQueue == null || options.immediate ? "activitypub.outbox" : "activitypub.fanout", {
4404
4262
  kind: this.federation.outboxQueue == null || options.immediate ? SpanKind.CLIENT : SpanKind.PRODUCER,
@@ -1,5 +1,5 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as FederationImpl } from "./middleware-PZaroDUk.mjs";
4
+ import { n as FederationImpl } from "./middleware-D3kuDjvb.mjs";
5
5
  export { FederationImpl };