@fedify/fedify 2.3.0-dev.1361 → 2.3.0-dev.1371

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 (104) hide show
  1. package/dist/{assert-DikXweDx.mjs → assert-OguE97r2.mjs} +1 -1
  2. package/dist/{assert_instance_of-C4Ri6VuN.mjs → assert_instance_of-DBC5X09g.mjs} +1 -1
  3. package/dist/{assert_not_equals--wG9hV7u.mjs → assert_not_equals-DkVK8oqV.mjs} +1 -1
  4. package/dist/{assert_rejects-DQP-q39h.mjs → assert_rejects-DN60FHPX.mjs} +2 -2
  5. package/dist/{assert_strict_equals-Dmjbg-bA.mjs → assert_strict_equals-XEgZAlrj.mjs} +1 -1
  6. package/dist/{assert_throws-4NwKEy2q.mjs → assert_throws-BOkhLGYc.mjs} +1 -1
  7. package/dist/{builder-Ec1dUgEm.mjs → builder-ByLIgi6j.mjs} +3 -23
  8. package/dist/compat/mod.d.cts +1 -1
  9. package/dist/compat/mod.d.ts +1 -1
  10. package/dist/compat/outgoing-jsonld.test.mjs +3 -3
  11. package/dist/compat/public-audience.test.mjs +3 -3
  12. package/dist/compat/transformers.test.mjs +5 -5
  13. package/dist/{context-BuGH_Vft.d.cts → context-BBVLF7lx.d.cts} +70 -286
  14. package/dist/{context-CLtZxCu6.d.ts → context-BU6jSQdo.d.ts} +70 -285
  15. package/dist/{context-BrIOaBSs.mjs → context-DVoTs_wM.mjs} +1 -7
  16. package/dist/{deno-C1j4CMgo.mjs → deno-CnoplBTQ.mjs} +1 -1
  17. package/dist/{docloader-DLb-Mj7i.mjs → docloader-xoQr5l-h.mjs} +2 -2
  18. package/dist/federation/builder.test.mjs +5 -5
  19. package/dist/federation/circuit-breaker.test.mjs +5 -5
  20. package/dist/federation/collection.test.mjs +3 -3
  21. package/dist/federation/handler.test.mjs +13 -13
  22. package/dist/federation/idempotency.test.mjs +6 -6
  23. package/dist/federation/inbox.test.mjs +3 -3
  24. package/dist/federation/keycache.test.mjs +5 -5
  25. package/dist/federation/kv.test.mjs +3 -3
  26. package/dist/federation/metrics.test.mjs +4 -4
  27. package/dist/federation/middleware.test.mjs +19 -200
  28. package/dist/federation/mod.cjs +1 -1
  29. package/dist/federation/mod.d.cts +3 -3
  30. package/dist/federation/mod.d.ts +3 -3
  31. package/dist/federation/mod.js +1 -1
  32. package/dist/federation/mq.test.mjs +260 -5
  33. package/dist/federation/negotiation.test.mjs +4 -4
  34. package/dist/federation/retry.test.mjs +3 -3
  35. package/dist/federation/router.test.mjs +5 -5
  36. package/dist/federation/send.test.mjs +10 -10
  37. package/dist/federation/temporal.test.mjs +4 -4
  38. package/dist/federation/webfinger.test.mjs +6 -6
  39. package/dist/{http-pFZqYnR0.mjs → http-BPZfwjb_.mjs} +4 -4
  40. package/dist/{http-DwM39C9Q.cjs → http-BlEsL1Hr.cjs} +1 -1
  41. package/dist/{http-1oEzWsNL.js → http-COFMk6Th.js} +1 -1
  42. package/dist/{key-E-05ikaC.mjs → key-Izax9vk5.mjs} +2 -2
  43. package/dist/{kv-cache-D-OZCnQz.mjs → kv-cache-DNTdcMna.mjs} +1 -1
  44. package/dist/{kv-cache-CgchQxpw.js → kv-cache-pE-sLsYh.js} +1 -1
  45. package/dist/{kv-cache-enboxEhN.cjs → kv-cache-s3P1dPyi.cjs} +1 -1
  46. package/dist/{ld-Bi8DPgxi.mjs → ld-eGL7f0Rm.mjs} +3 -3
  47. package/dist/{metrics-BC8TM85p.mjs → metrics-DaKX3Uz-.mjs} +1 -1
  48. package/dist/{middleware-6R3zHHW0.mjs → middleware-BpQqGfYC.mjs} +23 -182
  49. package/dist/{middleware-bEYsEa2y.js → middleware-Bue3Vz26.js} +10 -277
  50. package/dist/{middleware-B81UTyWc.mjs → middleware-D7rGhzX2.mjs} +1 -1
  51. package/dist/{middleware-TZyBWL4B.cjs → middleware-h2FrohM9.cjs} +10 -277
  52. package/dist/{mod-DRokcHeU.d.cts → mod-C0F6kvgS.d.cts} +1 -1
  53. package/dist/{mod-r-1xOW_C.d.ts → mod-vPYVoa5n.d.ts} +1 -1
  54. package/dist/mod.cjs +4 -4
  55. package/dist/mod.d.cts +4 -4
  56. package/dist/mod.d.ts +4 -4
  57. package/dist/mod.js +4 -4
  58. package/dist/nodeinfo/client.test.mjs +3 -3
  59. package/dist/nodeinfo/handler.test.mjs +5 -5
  60. package/dist/nodeinfo/types.test.mjs +4 -4
  61. package/dist/otel/exporter.test.mjs +3 -3
  62. package/dist/{outgoing-jsonld-BgFLCJQ_.mjs → outgoing-jsonld-L_DbOaFe.mjs} +1 -1
  63. package/dist/{owner-9bbtWYCS.mjs → owner-5eSnyFRM.mjs} +2 -2
  64. package/dist/{proof-DS0QOtP2.mjs → proof-C3haNOG7.mjs} +5 -5
  65. package/dist/{proof-B45zHTY3.cjs → proof-CAhd_bpY.cjs} +1 -1
  66. package/dist/{proof-CA5R6h5L.js → proof-CMRMddjN.js} +1 -1
  67. package/dist/{send-CyGRAWkX.mjs → send-DItjQTOC.mjs} +3 -3
  68. package/dist/sig/accept.test.mjs +1 -1
  69. package/dist/sig/http.test.mjs +8 -8
  70. package/dist/sig/key.test.mjs +6 -6
  71. package/dist/sig/ld.test.mjs +7 -7
  72. package/dist/sig/mod.cjs +2 -2
  73. package/dist/sig/mod.js +2 -2
  74. package/dist/sig/owner.test.mjs +6 -6
  75. package/dist/sig/proof.test.mjs +8 -8
  76. package/dist/{std__assert-BTEgfoJo.mjs → std__assert-BBjXFNOb.mjs} +4 -4
  77. package/dist/{temporal-B82PdoA8.mjs → temporal-CqIK2fCt.mjs} +1 -1
  78. package/dist/testing/mod.d.mts +7 -378
  79. package/dist/testing/mod.mjs +2 -3
  80. package/dist/utils/docloader.test.mjs +6 -6
  81. package/dist/utils/kv-cache.test.mjs +1 -1
  82. package/dist/utils/mod.cjs +1 -1
  83. package/dist/utils/mod.js +1 -1
  84. package/package.json +8 -10
  85. package/dist/codec-Bf-rTqks.mjs +0 -94
  86. package/dist/federation/tasks/codec.test.d.mts +0 -2
  87. package/dist/federation/tasks/codec.test.mjs +0 -292
  88. package/dist/federation/tasks/tasks.test.d.mts +0 -2
  89. package/dist/federation/tasks/tasks.test.mjs +0 -651
  90. package/dist/mq-CvJAzRz5.mjs +0 -260
  91. package/dist/testing-CjYPStvE.mjs +0 -55
  92. /package/dist/{accept-CceiKpCy.mjs → accept-CPkZzmGN.mjs} +0 -0
  93. /package/dist/{activity-listener-BeTGV3wc.mjs → activity-listener-tztVvlNb.mjs} +0 -0
  94. /package/dist/{assert_equals-Ew3jOFa3.mjs → assert_equals-C-ZRDbaf.mjs} +0 -0
  95. /package/dist/{circuit-breaker-hJBB6jwA.mjs → circuit-breaker-CSWsyoef.mjs} +0 -0
  96. /package/dist/{client-B_A6mfn3.mjs → client-ByXmQhYD.mjs} +0 -0
  97. /package/dist/{collection-Dp5ky45w.mjs → collection-Cc3DVAhE.mjs} +0 -0
  98. /package/dist/{keycache-CaOR6NYg.mjs → keycache-BeU0LCII.mjs} +0 -0
  99. /package/dist/{keys-C3kae-6B.mjs → keys-DGu1NFwu.mjs} +0 -0
  100. /package/dist/{kv-x2IvBUyq.mjs → kv-rV3vodCc.mjs} +0 -0
  101. /package/dist/{negotiation-m_L2nyS3.mjs → negotiation-DDstyBvc.mjs} +0 -0
  102. /package/dist/{public-audience-N3pyOx2p.mjs → public-audience-Cvbr2Gzt.mjs} +0 -0
  103. /package/dist/{retry-DI4O-zYl.mjs → retry-CXg_MBI-.mjs} +0 -0
  104. /package/dist/{types-BFowWFTT.mjs → types-J53Kw7so.mjs} +0 -0
@@ -2,10 +2,10 @@ import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
3
  import { t as __exportAll } from "./chunk-CRNNMoPX.js";
4
4
  import { r as getDefaultActivityTransformers } from "./transformers-BGMIq1cs.js";
5
- import { A as formatAcceptSignature, D as recordOutboxEnqueue, E as recordOutboxActivity, F as version, O as recordWebFingerHandle, P as name, S as recordCollectionTotalItems, T as recordInboxActivity, a as verifyRequestDetailed, b as recordCollectionPageItems, d as validateCryptoKey, f as getDurationMs, g as isAbortError, h as instrumentDocumentLoader, i as verifyRequest, k as registerQueueDepthGauge, m as getRemoteHost, n as parseRfc9421SignatureInput, o as exportJwk, p as getFederationMetrics, t as doubleKnock, u as importJwk, v as recordCircuitBreakerStateChange, w as recordFanoutRecipients, x as recordCollectionRequest, y as recordCollectionDispatchDuration } from "./http-1oEzWsNL.js";
6
- import { _ as hasSignatureLike, b as signJsonLd, c as getKeyOwner, f as compactJsonLd, g as hasSignature, h as getNormalizationContextLoader, i as verifyObject, l as InvalidContextReferenceError, m as detachSignature, n as hasProofLike, o as normalizeOutgoingActivityJsonLd, r as signObject, s as doesActorOwnKey, u as assertSafeJsonLd, v as isClearlyMalformedContextReference, w as wrapContextLoaderForJsonLd, x as verifyCompactJsonLd, y as isInvalidUrlTypeError } from "./proof-CA5R6h5L.js";
5
+ import { A as formatAcceptSignature, D as recordOutboxEnqueue, E as recordOutboxActivity, F as version, O as recordWebFingerHandle, P as name, S as recordCollectionTotalItems, T as recordInboxActivity, a as verifyRequestDetailed, b as recordCollectionPageItems, d as validateCryptoKey, f as getDurationMs, g as isAbortError, h as instrumentDocumentLoader, i as verifyRequest, k as registerQueueDepthGauge, m as getRemoteHost, n as parseRfc9421SignatureInput, o as exportJwk, p as getFederationMetrics, t as doubleKnock, u as importJwk, v as recordCircuitBreakerStateChange, w as recordFanoutRecipients, x as recordCollectionRequest, y as recordCollectionDispatchDuration } from "./http-COFMk6Th.js";
6
+ import { _ as hasSignatureLike, b as signJsonLd, c as getKeyOwner, f as compactJsonLd, g as hasSignature, h as getNormalizationContextLoader, i as verifyObject, l as InvalidContextReferenceError, m as detachSignature, n as hasProofLike, o as normalizeOutgoingActivityJsonLd, r as signObject, s as doesActorOwnKey, u as assertSafeJsonLd, v as isClearlyMalformedContextReference, w as wrapContextLoaderForJsonLd, x as verifyCompactJsonLd, y as isInvalidUrlTypeError } from "./proof-CMRMddjN.js";
7
7
  import { n as getNodeInfo, t as nodeInfoToJson } from "./types-CAY3OdLq.js";
8
- import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-CgchQxpw.js";
8
+ import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-pE-sLsYh.js";
9
9
  import { getLogger, withContext } from "@logtape/logtape";
10
10
  import { Router, RouterError, assertPath } from "@fedify/uri-template";
11
11
  import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, Tombstone, getTypeId, lookupObject, traverseCollection } from "@fedify/vocab";
@@ -17,7 +17,6 @@ import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_RESPONSE_
17
17
  import jsonld from "@fedify/vocab-runtime/jsonld";
18
18
  import { lookupWebFinger } from "@fedify/webfinger";
19
19
  import { DataPointType, MeterProvider as MeterProvider$1, MetricReader } from "@opentelemetry/sdk-metrics";
20
- import { parse, stringifyAsync } from "devalue";
21
20
  import { domainToASCII } from "node:url";
22
21
  //#region src/federation/activity-listener.ts
23
22
  var ActivityListenerSet = class {
@@ -108,7 +107,6 @@ var FederationBuilderImpl = class {
108
107
  idempotencyStrategy;
109
108
  collectionTypeIds;
110
109
  collectionCallbacks;
111
- taskDefinitions;
112
110
  /**
113
111
  * Symbol registry for unique identification of unnamed symbols.
114
112
  */
@@ -119,7 +117,6 @@ var FederationBuilderImpl = class {
119
117
  this.objectTypeIds = {};
120
118
  this.collectionCallbacks = {};
121
119
  this.collectionTypeIds = {};
122
- this.taskDefinitions = /* @__PURE__ */ new Map();
123
120
  }
124
121
  /**
125
122
  * Builds the federation object.
@@ -158,7 +155,6 @@ var FederationBuilderImpl = class {
158
155
  f.unverifiedActivityHandler = this.unverifiedActivityHandler;
159
156
  f.outboxPermanentFailureHandler = this.outboxPermanentFailureHandler;
160
157
  f.idempotencyStrategy = this.idempotencyStrategy;
161
- f.taskDefinitions = new Map(this.taskDefinitions);
162
158
  return f;
163
159
  }
164
160
  _getTracer() {
@@ -291,23 +287,6 @@ var FederationBuilderImpl = class {
291
287
  setWebFingerLinksDispatcher(dispatcher) {
292
288
  this.webFingerLinksDispatcher = dispatcher;
293
289
  }
294
- defineTask(name, options) {
295
- if (this.taskDefinitions.has(name)) throw new TypeError(`Task ${JSON.stringify(name)} is already defined.`);
296
- const handle = {
297
- name,
298
- schema: options.schema
299
- };
300
- this.taskDefinitions.set(name, {
301
- name,
302
- schema: options.schema,
303
- handle,
304
- handler: options.handler,
305
- onError: options.onError,
306
- retryPolicy: options.retryPolicy,
307
- queue: options.queue
308
- });
309
- return handle;
310
- }
311
290
  /**
312
291
  * The RFC 6570 template-literal `path` overloads were removed for
313
292
  * type-checking efficiency, so the URI variable types can no longer be
@@ -1413,7 +1392,7 @@ function acceptsJsonLd(request) {
1413
1392
  }
1414
1393
  //#endregion
1415
1394
  //#region src/federation/temporal.ts
1416
- function isPlainObject$1(value) {
1395
+ function isPlainObject(value) {
1417
1396
  return typeof value === "object" && value != null && !Array.isArray(value);
1418
1397
  }
1419
1398
  function normalizeDateTimeLiteral(value) {
@@ -1451,11 +1430,11 @@ const QUESTION_CLOSED_IRI = "https://www.w3.org/ns/activitystreams#closed";
1451
1430
  const XSD_DATE_TIME_IRI = "http://www.w3.org/2001/XMLSchema#dateTime";
1452
1431
  function hasMalformedExpandedDateTimeLiteral(value) {
1453
1432
  if (Array.isArray(value)) return value.some(hasMalformedExpandedDateTimeLiteral);
1454
- return isPlainObject$1(value) && "@value" in value && isMalformedDateTimeLiteral(value["@value"]);
1433
+ return isPlainObject(value) && "@value" in value && isMalformedDateTimeLiteral(value["@value"]);
1455
1434
  }
1456
1435
  function hasMalformedExpandedQuestionClosedLiteral(value) {
1457
1436
  if (Array.isArray(value)) return value.some(hasMalformedExpandedQuestionClosedLiteral);
1458
- if (!isPlainObject$1(value) || !("@value" in value)) return false;
1437
+ if (!isPlainObject(value) || !("@value" in value)) return false;
1459
1438
  const literal = value["@value"];
1460
1439
  if (typeof literal === "boolean") return false;
1461
1440
  if (typeof literal !== "string") return false;
@@ -1465,11 +1444,11 @@ function hasMalformedExpandedQuestionClosedLiteral(value) {
1465
1444
  }
1466
1445
  function hasMalformedExpandedDurationLiteral(value) {
1467
1446
  if (Array.isArray(value)) return value.some(hasMalformedExpandedDurationLiteral);
1468
- return isPlainObject$1(value) && "@value" in value && isMalformedDurationLiteral(value["@value"]);
1447
+ return isPlainObject(value) && "@value" in value && isMalformedDurationLiteral(value["@value"]);
1469
1448
  }
1470
1449
  function hasMalformedKnownTemporalLiteralInternal(value, visited) {
1471
1450
  if (Array.isArray(value)) return value.some((item) => hasMalformedKnownTemporalLiteralInternal(item, visited));
1472
- if (!isPlainObject$1(value)) return false;
1451
+ if (!isPlainObject(value)) return false;
1473
1452
  if (visited.has(value)) return false;
1474
1453
  visited.add(value);
1475
1454
  if ("@value" in value) return false;
@@ -3573,94 +3552,6 @@ function createExponentialBackoffPolicy(options = {}) {
3573
3552
  };
3574
3553
  }
3575
3554
  //#endregion
3576
- //#region src/federation/tasks/codec.ts
3577
- var TaskCodec = class TaskCodec {
3578
- options;
3579
- constructor(options) {
3580
- this.options = options;
3581
- }
3582
- serialize = (data) => stringifyAsync(data, { Vocab: this.#stringifyVocab });
3583
- deserialize = (raw) => this.#revive(/* @__PURE__ */ new Map())(parse(raw, { Vocab: VocabHolder.from }));
3584
- /** Validates `data` against `schema`, then serializes it. */
3585
- encode = async (schema, data) => this.serialize(await TaskCodec.validate(schema, data));
3586
- /** Deserializes `raw`, then validates the result against `schema`. */
3587
- decode = async (schema, raw) => TaskCodec.validate(schema, await this.deserialize(raw));
3588
- static validate = async (schema, data) => getValueIfSchema(await schema["~standard"].validate(data));
3589
- #stringifyVocab = (value) => isVocab(value) && this.#toWire(value);
3590
- #toWire = async (value) => ({
3591
- kind: value instanceof Link ? "link" : "object",
3592
- jsonLd: await value.toJsonLd({
3593
- format: "expand",
3594
- ...this.options
3595
- })
3596
- });
3597
- #revive = (seen) => {
3598
- const inner = async (node) => {
3599
- if (node === null || typeof node !== "object") return node;
3600
- if (seen.has(node)) return seen.get(node);
3601
- for (const reviver of this.#classRevivers) {
3602
- const out = reviver(seen, inner, node);
3603
- if (out !== void 0) return await out;
3604
- }
3605
- return node;
3606
- };
3607
- return inner;
3608
- };
3609
- #classRevivers = [
3610
- classReviver(isInstanceOf(VocabHolder), ({ kind, jsonLd }) => kind === "link" ? Link.fromJsonLd(jsonLd, this.options) : Object$1.fromJsonLd(jsonLd, this.options), () => {}),
3611
- classReviver(isInstanceOf(Array), () => [], async (revive, node, arr) => {
3612
- for (const item of await Array.fromAsync(node, revive)) arr.push(item);
3613
- }),
3614
- classReviver(isInstanceOf(Map), () => /* @__PURE__ */ new Map(), async (revive, node, map) => {
3615
- for (const [k, v] of node) map.set(await revive(k), await revive(v));
3616
- }),
3617
- classReviver(isInstanceOf(Set), () => /* @__PURE__ */ new Set(), async (revive, node, set) => {
3618
- for (const v of await Array.fromAsync(node, revive)) set.add(v);
3619
- }),
3620
- classReviver(isPlainObject, () => ({}), async (revive, node, obj) => {
3621
- for (const [k, v] of globalThis.Object.entries(node)) obj[k] = await revive(v);
3622
- })
3623
- ];
3624
- };
3625
- const isVocab = (value) => value instanceof Object$1 || value instanceof Link;
3626
- const isPlainObject = (value) => value === null || typeof value !== "object" ? false : isObjectPrototype(globalThis.Object.getPrototypeOf(value));
3627
- const isObjectPrototype = (proto) => proto === null || proto === globalThis.Object.prototype;
3628
- const isInstanceOf = (cls) => (v) => v instanceof cls;
3629
- function getValueIfSchema(result) {
3630
- assertSchema(result);
3631
- return result.value;
3632
- }
3633
- function assertSchema(result) {
3634
- if (result.issues && result.issues.length > 0) throw new TypeError(`Task data failed schema validation: ${JSON.stringify(result.issues)}`);
3635
- }
3636
- /**
3637
- * A vocabulary object parked by the synchronous decode reviver, held until
3638
- * the async revive pass can `fromJsonLd()` it back into an instance.
3639
- */
3640
- var VocabHolder = class VocabHolder {
3641
- kind;
3642
- jsonLd;
3643
- constructor(kind, jsonLd) {
3644
- this.kind = kind;
3645
- this.jsonLd = jsonLd;
3646
- }
3647
- static from = ({ kind, jsonLd }) => new VocabHolder(kind, jsonLd);
3648
- };
3649
- /**
3650
- * Ties a container filter to its empty-shell `init` and child-filling `set`
3651
- * through one type parameter—a correlation the heterogeneous reviver list
3652
- * cannot carry, which previously forced `@ts-ignore` at the dispatch site.
3653
- */
3654
- const classReviver = (filter, init, set) => (seen, revive, node) => {
3655
- if (!filter(node)) return void 0;
3656
- return (async () => {
3657
- const out = await init(node);
3658
- seen.set(node, out);
3659
- await set(revive, node, out);
3660
- return out;
3661
- })();
3662
- };
3663
- //#endregion
3664
3555
  //#region src/federation/webfinger.ts
3665
3556
  const logger = getLogger([
3666
3557
  "fedify",
@@ -3985,12 +3876,9 @@ var FederationImpl = class extends FederationBuilderImpl {
3985
3876
  inboxQueue;
3986
3877
  outboxQueue;
3987
3878
  fanoutQueue;
3988
- taskQueue;
3989
3879
  inboxQueueStarted;
3990
3880
  outboxQueueStarted;
3991
3881
  fanoutQueueStarted;
3992
- taskQueueStarted;
3993
- startedTaskQueues;
3994
3882
  manuallyStartQueue;
3995
3883
  origin;
3996
3884
  documentLoaderFactory;
@@ -4004,8 +3892,6 @@ var FederationImpl = class extends FederationBuilderImpl {
4004
3892
  skipSignatureVerification;
4005
3893
  outboxRetryPolicy;
4006
3894
  inboxRetryPolicy;
4007
- taskRetryPolicy;
4008
- taskQueueResolution;
4009
3895
  circuitBreaker;
4010
3896
  activityTransformers;
4011
3897
  _tracerProvider;
@@ -4051,17 +3937,14 @@ var FederationImpl = class extends FederationBuilderImpl {
4051
3937
  this.inboxQueue = void 0;
4052
3938
  this.outboxQueue = void 0;
4053
3939
  this.fanoutQueue = void 0;
4054
- this.taskQueue = void 0;
4055
3940
  } else if ("enqueue" in options.queue && "listen" in options.queue) {
4056
3941
  this.inboxQueue = options.queue;
4057
3942
  this.outboxQueue = options.queue;
4058
3943
  this.fanoutQueue = options.queue;
4059
- this.taskQueue = void 0;
4060
3944
  } else {
4061
3945
  this.inboxQueue = options.queue.inbox;
4062
3946
  this.outboxQueue = options.queue.outbox;
4063
3947
  this.fanoutQueue = options.queue.fanout;
4064
- this.taskQueue = options.queue.task;
4065
3948
  }
4066
3949
  if (options.circuitBreaker !== false && this.outboxQueue != null) {
4067
3950
  this.circuitBreaker = new CircuitBreaker({
@@ -4085,8 +3968,6 @@ var FederationImpl = class extends FederationBuilderImpl {
4085
3968
  this.inboxQueueStarted = false;
4086
3969
  this.outboxQueueStarted = false;
4087
3970
  this.fanoutQueueStarted = false;
4088
- this.taskQueueStarted = false;
4089
- this.startedTaskQueues = /* @__PURE__ */ new Set();
4090
3971
  this.manuallyStartQueue = options.manuallyStartQueue ?? false;
4091
3972
  if (options.origin != null) if (typeof options.origin === "string") {
4092
3973
  if (!URL.canParse(options.origin) || !options.origin.match(/^https?:\/\//)) throw new TypeError(`Invalid origin: ${JSON.stringify(options.origin)}`);
@@ -4168,8 +4049,6 @@ var FederationImpl = class extends FederationBuilderImpl {
4168
4049
  this.inboxChallengePolicy = options.inboxChallengePolicy;
4169
4050
  this.outboxRetryPolicy = options.outboxRetryPolicy ?? createExponentialBackoffPolicy();
4170
4051
  this.inboxRetryPolicy = options.inboxRetryPolicy ?? createExponentialBackoffPolicy();
4171
- this.taskRetryPolicy = options.taskRetryPolicy ?? createExponentialBackoffPolicy();
4172
- this.taskQueueResolution = options.taskQueueResolution ?? "fallback";
4173
4052
  this.activityTransformers = options.activityTransformers ?? getDefaultActivityTransformers();
4174
4053
  this._tracerProvider = options.tracerProvider;
4175
4054
  if (benchmarkMode) {
@@ -4218,14 +4097,8 @@ var FederationImpl = class extends FederationBuilderImpl {
4218
4097
  _getTracer() {
4219
4098
  return this.tracerProvider.getTracer(name, version);
4220
4099
  }
4221
- resolveTaskQueue(taskName) {
4222
- const resolved = this.taskDefinitions.get(taskName)?.queue ?? this.taskQueue;
4223
- if (resolved != null) return resolved;
4224
- return this.taskQueueResolution === "strict" ? void 0 : this.outboxQueue;
4225
- }
4226
4100
  async _startQueueInternal(ctxData, signal, queue) {
4227
- const hasDedicatedTaskQueue = [...this.taskDefinitions.values()].some((def) => def.queue != null);
4228
- if (this.inboxQueue == null && this.outboxQueue == null && this.fanoutQueue == null && this.taskQueue == null && !hasDedicatedTaskQueue) return;
4101
+ if (this.inboxQueue == null && this.outboxQueue == null) return;
4229
4102
  const logger = getLogger([
4230
4103
  "fedify",
4231
4104
  "federation",
@@ -4247,26 +4120,6 @@ var FederationImpl = class extends FederationBuilderImpl {
4247
4120
  this.fanoutQueueStarted = true;
4248
4121
  promises.push(this.fanoutQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
4249
4122
  }
4250
- if (this.taskQueue != null && this.taskQueue !== this.inboxQueue && this.taskQueue !== this.outboxQueue && this.taskQueue !== this.fanoutQueue && (queue == null || queue === "task") && !this.taskQueueStarted) {
4251
- logger.debug("Starting a task worker.");
4252
- this.taskQueueStarted = true;
4253
- promises.push(this.taskQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
4254
- }
4255
- if (queue == null || queue === "task") {
4256
- const standardQueues = new Set([
4257
- this.inboxQueue,
4258
- this.outboxQueue,
4259
- this.fanoutQueue,
4260
- this.taskQueue
4261
- ].filter((q) => q != null));
4262
- for (const def of this.taskDefinitions.values()) {
4263
- const taskQueue = def.queue;
4264
- if (taskQueue == null || standardQueues.has(taskQueue) || this.startedTaskQueues.has(taskQueue)) continue;
4265
- logger.debug("Starting a worker for a dedicated per-task queue.");
4266
- this.startedTaskQueues.add(taskQueue);
4267
- promises.push(taskQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
4268
- }
4269
- }
4270
4123
  await Promise.all(promises);
4271
4124
  }
4272
4125
  processQueuedTask(contextData, message) {
@@ -4388,7 +4241,7 @@ var FederationImpl = class extends FederationBuilderImpl {
4388
4241
  }
4389
4242
  });
4390
4243
  });
4391
- } else if (message.type === "task") await this.#listenTaskMessage(contextData, message);
4244
+ }
4392
4245
  });
4393
4246
  }
4394
4247
  async #listenFanoutMessage(data, message) {
@@ -4952,77 +4805,6 @@ var FederationImpl = class extends FederationBuilderImpl {
4952
4805
  listenerSpan.end();
4953
4806
  });
4954
4807
  }
4955
- async #listenTaskMessage(contextData, message) {
4956
- const logger = getLogger([
4957
- "fedify",
4958
- "federation",
4959
- "task"
4960
- ]);
4961
- const def = this.taskDefinitions.get(message.taskName);
4962
- if (def == null) {
4963
- logger.warn("Received a custom task {taskName} with no registered handler; dropping.", { taskName: message.taskName });
4964
- return;
4965
- }
4966
- const context = this.#createContext(new URL(message.baseUrl), contextData);
4967
- let data;
4968
- try {
4969
- data = await context.codec.decode(def.schema, message.data);
4970
- } catch (error) {
4971
- logger.error("Custom task {taskName} payload could not be decoded or validated; dropping:\n{error}", {
4972
- taskName: message.taskName,
4973
- error
4974
- });
4975
- return;
4976
- }
4977
- try {
4978
- await def.handler(context, data);
4979
- } catch (error) {
4980
- if (def.onError != null) try {
4981
- await def.onError(context, error, data);
4982
- } catch (onErrorError) {
4983
- logger.error("onError for custom task {taskName} threw:\n{error}", {
4984
- taskName: message.taskName,
4985
- error: onErrorError
4986
- });
4987
- }
4988
- const queue = this.resolveTaskQueue(def.name);
4989
- if (queue?.nativeRetrial) throw error;
4990
- const retryPolicy = def.retryPolicy ?? this.taskRetryPolicy;
4991
- let elapsedTime = Temporal.Duration.from({ seconds: 0 });
4992
- try {
4993
- elapsedTime = Temporal.Instant.from(message.started).until(Temporal.Now.instant());
4994
- } catch (parseError) {
4995
- logger.error("Custom task {taskName} has an unparsable started time {started}; treating elapsedTime as zero:\n{error}", {
4996
- taskName: message.taskName,
4997
- started: message.started,
4998
- error: parseError
4999
- });
5000
- }
5001
- const delay = retryPolicy({
5002
- elapsedTime,
5003
- attempts: message.attempt
5004
- });
5005
- if (delay != null && queue != null) {
5006
- logger.error("Custom task {taskName} failed (attempt #{attempt}); retry...:\n{error}", {
5007
- taskName: message.taskName,
5008
- attempt: message.attempt,
5009
- error
5010
- });
5011
- const retryMessage = {
5012
- ...message,
5013
- attempt: message.attempt + 1
5014
- };
5015
- await queue.enqueue(retryMessage, {
5016
- delay: clampNegativeDelay(delay),
5017
- orderingKey: message.orderingKey
5018
- });
5019
- } else logger.error("Custom task {taskName} failed after {attempt} attempts; giving up:\n{error}", {
5020
- taskName: message.taskName,
5021
- attempt: message.attempt,
5022
- error
5023
- });
5024
- }
5025
- }
5026
4808
  startQueue(contextData, options = {}) {
5027
4809
  return this._startQueueInternal(contextData, options.signal, options.queue);
5028
4810
  }
@@ -5599,7 +5381,6 @@ var ContextImpl = class ContextImpl {
5599
5381
  documentLoader;
5600
5382
  contextLoader;
5601
5383
  invokedFromActorKeyPairsDispatcher;
5602
- #codec;
5603
5384
  constructor({ url, federation, data, documentLoader, contextLoader, invokedFromActorKeyPairsDispatcher }) {
5604
5385
  this.url = url;
5605
5386
  this.federation = federation;
@@ -5608,15 +5389,6 @@ var ContextImpl = class ContextImpl {
5608
5389
  this.contextLoader = contextLoader;
5609
5390
  this.invokedFromActorKeyPairsDispatcher = invokedFromActorKeyPairsDispatcher;
5610
5391
  }
5611
- /**
5612
- * A {@link TaskCodec} bound to this context's loaders, used to encode
5613
- * and decode custom task payloads. Lazily created and cached so a context
5614
- * that never enqueues or dispatches a task pays nothing.
5615
- * @internal
5616
- */
5617
- get codec() {
5618
- return this.#codec ??= new TaskCodec(this);
5619
- }
5620
5392
  clone(data) {
5621
5393
  return new ContextImpl({
5622
5394
  url: this.url,
@@ -5935,45 +5707,6 @@ var ContextImpl = class ContextImpl {
5935
5707
  allowPrivateAddress: this.federation.allowPrivateAddress
5936
5708
  });
5937
5709
  }
5938
- async enqueueTask(task, data, options = {}) {
5939
- await this.#enqueueTasks(task, [data], options);
5940
- }
5941
- async enqueueTaskMany(task, payloads, options = {}) {
5942
- await this.#enqueueTasks(task, payloads, options);
5943
- }
5944
- async #enqueueTasks(task, items, options) {
5945
- const def = this.federation.taskDefinitions.get(task.name);
5946
- 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().`);
5947
- const queue = this.federation.resolveTaskQueue(task.name);
5948
- if (queue == null) throw new TypeError("No message queue is configured for tasks; pass `queue` to createFederation() or to defineTask().");
5949
- if (items.length < 1) return;
5950
- const delay = options.delay == null ? void 0 : Temporal.Duration.from(options.delay);
5951
- const messages = await Promise.all(items.map(this.#encodeTaskMessage(task, options)));
5952
- if (!this.federation.manuallyStartQueue) this.federation._startQueueInternal(this.data);
5953
- const enqueueOptions = {
5954
- delay,
5955
- orderingKey: options.orderingKey
5956
- };
5957
- if (messages.length === 1) await queue.enqueue(messages[0], enqueueOptions);
5958
- else if (queue.enqueueMany != null) await queue.enqueueMany(messages, enqueueOptions);
5959
- else await Promise.all(messages.map((m) => queue.enqueue(m, enqueueOptions)));
5960
- }
5961
- #encodeTaskMessage = (task, options) => async (data) => {
5962
- const encoded = await this.codec.encode(task.schema, data);
5963
- const carrier = {};
5964
- propagation.inject(context.active(), carrier);
5965
- return {
5966
- type: "task",
5967
- id: crypto.randomUUID(),
5968
- baseUrl: this.origin,
5969
- taskName: task.name,
5970
- data: encoded,
5971
- started: Temporal.Now.instant().toString(),
5972
- attempt: 0,
5973
- orderingKey: options.orderingKey,
5974
- traceContext: carrier
5975
- };
5976
- };
5977
5710
  sendActivity(sender, recipients, activity, options = {}) {
5978
5711
  return this.tracerProvider.getTracer(name, version).startActiveSpan(this.federation.outboxQueue == null || options.immediate ? "activitypub.outbox" : "activitypub.fanout", {
5979
5712
  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-6R3zHHW0.mjs";
4
+ import { n as FederationImpl } from "./middleware-BpQqGfYC.mjs";
5
5
  export { FederationImpl };