@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,10 +2,10 @@ const { Temporal } = require("@js-temporal/polyfill");
2
2
  const { URLPattern } = require("urlpattern-polyfill");
3
3
  const require_chunk = require("./chunk-DDcVe30Y.cjs");
4
4
  const require_transformers = require("./transformers-NeAONrAq.cjs");
5
- const require_http = require("./http-BCSQJ_gv.cjs");
6
- const require_proof = require("./proof-DA3hLGSO.cjs");
5
+ const require_http = require("./http-DLqxhQg1.cjs");
6
+ const require_proof = require("./proof-2WI6mMbC.cjs");
7
7
  const require_types = require("./types-KC4QAoxe.cjs");
8
- const require_kv_cache = require("./kv-cache-DXwu7BtY.cjs");
8
+ const require_kv_cache = require("./kv-cache-Fw-iwKjy.cjs");
9
9
  let _logtape_logtape = require("@logtape/logtape");
10
10
  let _fedify_uri_template = require("@fedify/uri-template");
11
11
  let _fedify_vocab = require("@fedify/vocab");
@@ -18,7 +18,6 @@ let _fedify_vocab_runtime_jsonld = require("@fedify/vocab-runtime/jsonld");
18
18
  _fedify_vocab_runtime_jsonld = require_chunk.__toESM(_fedify_vocab_runtime_jsonld, 1);
19
19
  let _fedify_webfinger = require("@fedify/webfinger");
20
20
  let _opentelemetry_sdk_metrics = require("@opentelemetry/sdk-metrics");
21
- let devalue = require("devalue");
22
21
  let node_url = require("node:url");
23
22
  //#region src/federation/activity-listener.ts
24
23
  var ActivityListenerSet = class {
@@ -109,7 +108,6 @@ var FederationBuilderImpl = class {
109
108
  idempotencyStrategy;
110
109
  collectionTypeIds;
111
110
  collectionCallbacks;
112
- taskDefinitions;
113
111
  /**
114
112
  * Symbol registry for unique identification of unnamed symbols.
115
113
  */
@@ -120,7 +118,6 @@ var FederationBuilderImpl = class {
120
118
  this.objectTypeIds = {};
121
119
  this.collectionCallbacks = {};
122
120
  this.collectionTypeIds = {};
123
- this.taskDefinitions = /* @__PURE__ */ new Map();
124
121
  }
125
122
  /**
126
123
  * Builds the federation object.
@@ -159,7 +156,6 @@ var FederationBuilderImpl = class {
159
156
  f.unverifiedActivityHandler = this.unverifiedActivityHandler;
160
157
  f.outboxPermanentFailureHandler = this.outboxPermanentFailureHandler;
161
158
  f.idempotencyStrategy = this.idempotencyStrategy;
162
- f.taskDefinitions = new Map(this.taskDefinitions);
163
159
  return f;
164
160
  }
165
161
  _getTracer() {
@@ -292,23 +288,6 @@ var FederationBuilderImpl = class {
292
288
  setWebFingerLinksDispatcher(dispatcher) {
293
289
  this.webFingerLinksDispatcher = dispatcher;
294
290
  }
295
- defineTask(name, options) {
296
- if (this.taskDefinitions.has(name)) throw new TypeError(`Task ${JSON.stringify(name)} is already defined.`);
297
- const handle = {
298
- name,
299
- schema: options.schema
300
- };
301
- this.taskDefinitions.set(name, {
302
- name,
303
- schema: options.schema,
304
- handle,
305
- handler: options.handler,
306
- onError: options.onError,
307
- retryPolicy: options.retryPolicy,
308
- queue: options.queue
309
- });
310
- return handle;
311
- }
312
291
  /**
313
292
  * The RFC 6570 template-literal `path` overloads were removed for
314
293
  * type-checking efficiency, so the URI variable types can no longer be
@@ -1414,7 +1393,7 @@ function acceptsJsonLd(request) {
1414
1393
  }
1415
1394
  //#endregion
1416
1395
  //#region src/federation/temporal.ts
1417
- function isPlainObject$1(value) {
1396
+ function isPlainObject(value) {
1418
1397
  return typeof value === "object" && value != null && !Array.isArray(value);
1419
1398
  }
1420
1399
  function normalizeDateTimeLiteral(value) {
@@ -1452,11 +1431,11 @@ const QUESTION_CLOSED_IRI = "https://www.w3.org/ns/activitystreams#closed";
1452
1431
  const XSD_DATE_TIME_IRI = "http://www.w3.org/2001/XMLSchema#dateTime";
1453
1432
  function hasMalformedExpandedDateTimeLiteral(value) {
1454
1433
  if (Array.isArray(value)) return value.some(hasMalformedExpandedDateTimeLiteral);
1455
- return isPlainObject$1(value) && "@value" in value && isMalformedDateTimeLiteral(value["@value"]);
1434
+ return isPlainObject(value) && "@value" in value && isMalformedDateTimeLiteral(value["@value"]);
1456
1435
  }
1457
1436
  function hasMalformedExpandedQuestionClosedLiteral(value) {
1458
1437
  if (Array.isArray(value)) return value.some(hasMalformedExpandedQuestionClosedLiteral);
1459
- if (!isPlainObject$1(value) || !("@value" in value)) return false;
1438
+ if (!isPlainObject(value) || !("@value" in value)) return false;
1460
1439
  const literal = value["@value"];
1461
1440
  if (typeof literal === "boolean") return false;
1462
1441
  if (typeof literal !== "string") return false;
@@ -1466,11 +1445,11 @@ function hasMalformedExpandedQuestionClosedLiteral(value) {
1466
1445
  }
1467
1446
  function hasMalformedExpandedDurationLiteral(value) {
1468
1447
  if (Array.isArray(value)) return value.some(hasMalformedExpandedDurationLiteral);
1469
- return isPlainObject$1(value) && "@value" in value && isMalformedDurationLiteral(value["@value"]);
1448
+ return isPlainObject(value) && "@value" in value && isMalformedDurationLiteral(value["@value"]);
1470
1449
  }
1471
1450
  function hasMalformedKnownTemporalLiteralInternal(value, visited) {
1472
1451
  if (Array.isArray(value)) return value.some((item) => hasMalformedKnownTemporalLiteralInternal(item, visited));
1473
- if (!isPlainObject$1(value)) return false;
1452
+ if (!isPlainObject(value)) return false;
1474
1453
  if (visited.has(value)) return false;
1475
1454
  visited.add(value);
1476
1455
  if ("@value" in value) return false;
@@ -3574,94 +3553,6 @@ function createExponentialBackoffPolicy(options = {}) {
3574
3553
  };
3575
3554
  }
3576
3555
  //#endregion
3577
- //#region src/federation/tasks/codec.ts
3578
- var TaskCodec = class TaskCodec {
3579
- options;
3580
- constructor(options) {
3581
- this.options = options;
3582
- }
3583
- serialize = (data) => (0, devalue.stringifyAsync)(data, { Vocab: this.#stringifyVocab });
3584
- deserialize = (raw) => this.#revive(/* @__PURE__ */ new Map())((0, devalue.parse)(raw, { Vocab: VocabHolder.from }));
3585
- /** Validates `data` against `schema`, then serializes it. */
3586
- encode = async (schema, data) => this.serialize(await TaskCodec.validate(schema, data));
3587
- /** Deserializes `raw`, then validates the result against `schema`. */
3588
- decode = async (schema, raw) => TaskCodec.validate(schema, await this.deserialize(raw));
3589
- static validate = async (schema, data) => getValueIfSchema(await schema["~standard"].validate(data));
3590
- #stringifyVocab = (value) => isVocab(value) && this.#toWire(value);
3591
- #toWire = async (value) => ({
3592
- kind: value instanceof _fedify_vocab.Link ? "link" : "object",
3593
- jsonLd: await value.toJsonLd({
3594
- format: "expand",
3595
- ...this.options
3596
- })
3597
- });
3598
- #revive = (seen) => {
3599
- const inner = async (node) => {
3600
- if (node === null || typeof node !== "object") return node;
3601
- if (seen.has(node)) return seen.get(node);
3602
- for (const reviver of this.#classRevivers) {
3603
- const out = reviver(seen, inner, node);
3604
- if (out !== void 0) return await out;
3605
- }
3606
- return node;
3607
- };
3608
- return inner;
3609
- };
3610
- #classRevivers = [
3611
- classReviver(isInstanceOf(VocabHolder), ({ kind, jsonLd }) => kind === "link" ? _fedify_vocab.Link.fromJsonLd(jsonLd, this.options) : _fedify_vocab.Object.fromJsonLd(jsonLd, this.options), () => {}),
3612
- classReviver(isInstanceOf(Array), () => [], async (revive, node, arr) => {
3613
- for (const item of await Array.fromAsync(node, revive)) arr.push(item);
3614
- }),
3615
- classReviver(isInstanceOf(Map), () => /* @__PURE__ */ new Map(), async (revive, node, map) => {
3616
- for (const [k, v] of node) map.set(await revive(k), await revive(v));
3617
- }),
3618
- classReviver(isInstanceOf(Set), () => /* @__PURE__ */ new Set(), async (revive, node, set) => {
3619
- for (const v of await Array.fromAsync(node, revive)) set.add(v);
3620
- }),
3621
- classReviver(isPlainObject, () => ({}), async (revive, node, obj) => {
3622
- for (const [k, v] of globalThis.Object.entries(node)) obj[k] = await revive(v);
3623
- })
3624
- ];
3625
- };
3626
- const isVocab = (value) => value instanceof _fedify_vocab.Object || value instanceof _fedify_vocab.Link;
3627
- const isPlainObject = (value) => value === null || typeof value !== "object" ? false : isObjectPrototype(globalThis.Object.getPrototypeOf(value));
3628
- const isObjectPrototype = (proto) => proto === null || proto === globalThis.Object.prototype;
3629
- const isInstanceOf = (cls) => (v) => v instanceof cls;
3630
- function getValueIfSchema(result) {
3631
- assertSchema(result);
3632
- return result.value;
3633
- }
3634
- function assertSchema(result) {
3635
- if (result.issues && result.issues.length > 0) throw new TypeError(`Task data failed schema validation: ${JSON.stringify(result.issues)}`);
3636
- }
3637
- /**
3638
- * A vocabulary object parked by the synchronous decode reviver, held until
3639
- * the async revive pass can `fromJsonLd()` it back into an instance.
3640
- */
3641
- var VocabHolder = class VocabHolder {
3642
- kind;
3643
- jsonLd;
3644
- constructor(kind, jsonLd) {
3645
- this.kind = kind;
3646
- this.jsonLd = jsonLd;
3647
- }
3648
- static from = ({ kind, jsonLd }) => new VocabHolder(kind, jsonLd);
3649
- };
3650
- /**
3651
- * Ties a container filter to its empty-shell `init` and child-filling `set`
3652
- * through one type parameter—a correlation the heterogeneous reviver list
3653
- * cannot carry, which previously forced `@ts-ignore` at the dispatch site.
3654
- */
3655
- const classReviver = (filter, init, set) => (seen, revive, node) => {
3656
- if (!filter(node)) return void 0;
3657
- return (async () => {
3658
- const out = await init(node);
3659
- seen.set(node, out);
3660
- await set(revive, node, out);
3661
- return out;
3662
- })();
3663
- };
3664
- //#endregion
3665
3556
  //#region src/federation/webfinger.ts
3666
3557
  const logger = (0, _logtape_logtape.getLogger)([
3667
3558
  "fedify",
@@ -3969,6 +3860,15 @@ function isPermanentRemoteContextError(error) {
3969
3860
  function isPermanentInboxParseError(error) {
3970
3861
  return error instanceof Error && (error.name === "UnsafeJsonLdError" || error instanceof require_proof.InvalidContextReferenceError || isPermanentRemoteContextError(error) || error.name === "jsonld.SyntaxError" && !isRemoteContextLoadingFailure(error)) || error instanceof TypeError && (/^(Invalid JSON-LD:|Invalid type:|Unexpected type:|Invalid @id:)/.test(error.message) || require_proof.isInvalidUrlTypeError(error));
3971
3862
  }
3863
+ function hasLinkedDataSignatureJsonLdProcessingError(error) {
3864
+ if (error.message.startsWith("Maximum deep iterations exceeded")) return true;
3865
+ const cause = error.cause instanceof Error ? error.cause : error.details?.cause;
3866
+ 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.");
3867
+ return error.name !== "jsonld.InvalidUrl" && error.name.startsWith("jsonld.");
3868
+ }
3869
+ function isLinkedDataSignatureJsonLdProcessingError(error) {
3870
+ return error instanceof Error && hasLinkedDataSignatureJsonLdProcessingError(error);
3871
+ }
3972
3872
  /**
3973
3873
  * Create a new {@link Federation} instance.
3974
3874
  * @param options Parameters for initializing the instance.
@@ -3986,12 +3886,9 @@ var FederationImpl = class extends FederationBuilderImpl {
3986
3886
  inboxQueue;
3987
3887
  outboxQueue;
3988
3888
  fanoutQueue;
3989
- taskQueue;
3990
3889
  inboxQueueStarted;
3991
3890
  outboxQueueStarted;
3992
3891
  fanoutQueueStarted;
3993
- taskQueueStarted;
3994
- startedTaskQueues;
3995
3892
  manuallyStartQueue;
3996
3893
  origin;
3997
3894
  documentLoaderFactory;
@@ -4005,8 +3902,6 @@ var FederationImpl = class extends FederationBuilderImpl {
4005
3902
  skipSignatureVerification;
4006
3903
  outboxRetryPolicy;
4007
3904
  inboxRetryPolicy;
4008
- taskRetryPolicy;
4009
- taskQueueResolution;
4010
3905
  circuitBreaker;
4011
3906
  activityTransformers;
4012
3907
  _tracerProvider;
@@ -4052,17 +3947,14 @@ var FederationImpl = class extends FederationBuilderImpl {
4052
3947
  this.inboxQueue = void 0;
4053
3948
  this.outboxQueue = void 0;
4054
3949
  this.fanoutQueue = void 0;
4055
- this.taskQueue = void 0;
4056
3950
  } else if ("enqueue" in options.queue && "listen" in options.queue) {
4057
3951
  this.inboxQueue = options.queue;
4058
3952
  this.outboxQueue = options.queue;
4059
3953
  this.fanoutQueue = options.queue;
4060
- this.taskQueue = void 0;
4061
3954
  } else {
4062
3955
  this.inboxQueue = options.queue.inbox;
4063
3956
  this.outboxQueue = options.queue.outbox;
4064
3957
  this.fanoutQueue = options.queue.fanout;
4065
- this.taskQueue = options.queue.task;
4066
3958
  }
4067
3959
  if (options.circuitBreaker !== false && this.outboxQueue != null) {
4068
3960
  this.circuitBreaker = new CircuitBreaker({
@@ -4086,8 +3978,6 @@ var FederationImpl = class extends FederationBuilderImpl {
4086
3978
  this.inboxQueueStarted = false;
4087
3979
  this.outboxQueueStarted = false;
4088
3980
  this.fanoutQueueStarted = false;
4089
- this.taskQueueStarted = false;
4090
- this.startedTaskQueues = /* @__PURE__ */ new Set();
4091
3981
  this.manuallyStartQueue = options.manuallyStartQueue ?? false;
4092
3982
  if (options.origin != null) if (typeof options.origin === "string") {
4093
3983
  if (!URL.canParse(options.origin) || !options.origin.match(/^https?:\/\//)) throw new TypeError(`Invalid origin: ${JSON.stringify(options.origin)}`);
@@ -4169,8 +4059,6 @@ var FederationImpl = class extends FederationBuilderImpl {
4169
4059
  this.inboxChallengePolicy = options.inboxChallengePolicy;
4170
4060
  this.outboxRetryPolicy = options.outboxRetryPolicy ?? createExponentialBackoffPolicy();
4171
4061
  this.inboxRetryPolicy = options.inboxRetryPolicy ?? createExponentialBackoffPolicy();
4172
- this.taskRetryPolicy = options.taskRetryPolicy ?? createExponentialBackoffPolicy();
4173
- this.taskQueueResolution = options.taskQueueResolution ?? "fallback";
4174
4062
  this.activityTransformers = options.activityTransformers ?? require_transformers.getDefaultActivityTransformers();
4175
4063
  this._tracerProvider = options.tracerProvider;
4176
4064
  if (benchmarkMode) {
@@ -4219,14 +4107,8 @@ var FederationImpl = class extends FederationBuilderImpl {
4219
4107
  _getTracer() {
4220
4108
  return this.tracerProvider.getTracer(require_http.name, require_http.version);
4221
4109
  }
4222
- resolveTaskQueue(taskName) {
4223
- const resolved = this.taskDefinitions.get(taskName)?.queue ?? this.taskQueue;
4224
- if (resolved != null) return resolved;
4225
- return this.taskQueueResolution === "strict" ? void 0 : this.outboxQueue;
4226
- }
4227
4110
  async _startQueueInternal(ctxData, signal, queue) {
4228
- const hasDedicatedTaskQueue = [...this.taskDefinitions.values()].some((def) => def.queue != null);
4229
- if (this.inboxQueue == null && this.outboxQueue == null && this.fanoutQueue == null && this.taskQueue == null && !hasDedicatedTaskQueue) return;
4111
+ if (this.inboxQueue == null && this.outboxQueue == null) return;
4230
4112
  const logger = (0, _logtape_logtape.getLogger)([
4231
4113
  "fedify",
4232
4114
  "federation",
@@ -4248,26 +4130,6 @@ var FederationImpl = class extends FederationBuilderImpl {
4248
4130
  this.fanoutQueueStarted = true;
4249
4131
  promises.push(this.fanoutQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
4250
4132
  }
4251
- if (this.taskQueue != null && this.taskQueue !== this.inboxQueue && this.taskQueue !== this.outboxQueue && this.taskQueue !== this.fanoutQueue && (queue == null || queue === "task") && !this.taskQueueStarted) {
4252
- logger.debug("Starting a task worker.");
4253
- this.taskQueueStarted = true;
4254
- promises.push(this.taskQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
4255
- }
4256
- if (queue == null || queue === "task") {
4257
- const standardQueues = new Set([
4258
- this.inboxQueue,
4259
- this.outboxQueue,
4260
- this.fanoutQueue,
4261
- this.taskQueue
4262
- ].filter((q) => q != null));
4263
- for (const def of this.taskDefinitions.values()) {
4264
- const taskQueue = def.queue;
4265
- if (taskQueue == null || standardQueues.has(taskQueue) || this.startedTaskQueues.has(taskQueue)) continue;
4266
- logger.debug("Starting a worker for a dedicated per-task queue.");
4267
- this.startedTaskQueues.add(taskQueue);
4268
- promises.push(taskQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
4269
- }
4270
- }
4271
4133
  await Promise.all(promises);
4272
4134
  }
4273
4135
  processQueuedTask(contextData, message) {
@@ -4389,7 +4251,7 @@ var FederationImpl = class extends FederationBuilderImpl {
4389
4251
  }
4390
4252
  });
4391
4253
  });
4392
- } else if (message.type === "task") await this.#listenTaskMessage(contextData, message);
4254
+ }
4393
4255
  });
4394
4256
  }
4395
4257
  async #listenFanoutMessage(data, message) {
@@ -4953,77 +4815,6 @@ var FederationImpl = class extends FederationBuilderImpl {
4953
4815
  listenerSpan.end();
4954
4816
  });
4955
4817
  }
4956
- async #listenTaskMessage(contextData, message) {
4957
- const logger = (0, _logtape_logtape.getLogger)([
4958
- "fedify",
4959
- "federation",
4960
- "task"
4961
- ]);
4962
- const def = this.taskDefinitions.get(message.taskName);
4963
- if (def == null) {
4964
- logger.warn("Received a custom task {taskName} with no registered handler; dropping.", { taskName: message.taskName });
4965
- return;
4966
- }
4967
- const context = this.#createContext(new URL(message.baseUrl), contextData);
4968
- let data;
4969
- try {
4970
- data = await context.codec.decode(def.schema, message.data);
4971
- } catch (error) {
4972
- logger.error("Custom task {taskName} payload could not be decoded or validated; dropping:\n{error}", {
4973
- taskName: message.taskName,
4974
- error
4975
- });
4976
- return;
4977
- }
4978
- try {
4979
- await def.handler(context, data);
4980
- } catch (error) {
4981
- if (def.onError != null) try {
4982
- await def.onError(context, error, data);
4983
- } catch (onErrorError) {
4984
- logger.error("onError for custom task {taskName} threw:\n{error}", {
4985
- taskName: message.taskName,
4986
- error: onErrorError
4987
- });
4988
- }
4989
- const queue = this.resolveTaskQueue(def.name);
4990
- if (queue?.nativeRetrial) throw error;
4991
- const retryPolicy = def.retryPolicy ?? this.taskRetryPolicy;
4992
- let elapsedTime = Temporal.Duration.from({ seconds: 0 });
4993
- try {
4994
- elapsedTime = Temporal.Instant.from(message.started).until(Temporal.Now.instant());
4995
- } catch (parseError) {
4996
- logger.error("Custom task {taskName} has an unparsable started time {started}; treating elapsedTime as zero:\n{error}", {
4997
- taskName: message.taskName,
4998
- started: message.started,
4999
- error: parseError
5000
- });
5001
- }
5002
- const delay = retryPolicy({
5003
- elapsedTime,
5004
- attempts: message.attempt
5005
- });
5006
- if (delay != null && queue != null) {
5007
- logger.error("Custom task {taskName} failed (attempt #{attempt}); retry...:\n{error}", {
5008
- taskName: message.taskName,
5009
- attempt: message.attempt,
5010
- error
5011
- });
5012
- const retryMessage = {
5013
- ...message,
5014
- attempt: message.attempt + 1
5015
- };
5016
- await queue.enqueue(retryMessage, {
5017
- delay: clampNegativeDelay(delay),
5018
- orderingKey: message.orderingKey
5019
- });
5020
- } else logger.error("Custom task {taskName} failed after {attempt} attempts; giving up:\n{error}", {
5021
- taskName: message.taskName,
5022
- attempt: message.attempt,
5023
- error
5024
- });
5025
- }
5026
- }
5027
4818
  startQueue(contextData, options = {}) {
5028
4819
  return this._startQueueInternal(contextData, options.signal, options.queue);
5029
4820
  }
@@ -5112,10 +4903,18 @@ var FederationImpl = class extends FederationBuilderImpl {
5112
4903
  privateKey: pair.privateKey
5113
4904
  }))
5114
4905
  });
5115
- else jsonLd = await require_proof.signJsonLd(jsonLd, rsaKey.privateKey, rsaKey.keyId, {
5116
- contextLoader,
5117
- tracerProvider: this.tracerProvider
5118
- });
4906
+ else try {
4907
+ jsonLd = await require_proof.signJsonLd(jsonLd, rsaKey.privateKey, rsaKey.keyId, {
4908
+ contextLoader,
4909
+ tracerProvider: this.tracerProvider
4910
+ });
4911
+ } catch (error) {
4912
+ if (!isLinkedDataSignatureJsonLdProcessingError(error)) throw error;
4913
+ logger.warn("Failed to create a Linked Data signature for the activity {activityId}. The activity will be sent without a Linked Data signature.", {
4914
+ activityId,
4915
+ error
4916
+ });
4917
+ }
5119
4918
  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.", {
5120
4919
  activityId,
5121
4920
  keys: keys.map((pair) => ({
@@ -5600,7 +5399,6 @@ var ContextImpl = class ContextImpl {
5600
5399
  documentLoader;
5601
5400
  contextLoader;
5602
5401
  invokedFromActorKeyPairsDispatcher;
5603
- #codec;
5604
5402
  constructor({ url, federation, data, documentLoader, contextLoader, invokedFromActorKeyPairsDispatcher }) {
5605
5403
  this.url = url;
5606
5404
  this.federation = federation;
@@ -5609,15 +5407,6 @@ var ContextImpl = class ContextImpl {
5609
5407
  this.contextLoader = contextLoader;
5610
5408
  this.invokedFromActorKeyPairsDispatcher = invokedFromActorKeyPairsDispatcher;
5611
5409
  }
5612
- /**
5613
- * A {@link TaskCodec} bound to this context's loaders, used to encode
5614
- * and decode custom task payloads. Lazily created and cached so a context
5615
- * that never enqueues or dispatches a task pays nothing.
5616
- * @internal
5617
- */
5618
- get codec() {
5619
- return this.#codec ??= new TaskCodec(this);
5620
- }
5621
5410
  clone(data) {
5622
5411
  return new ContextImpl({
5623
5412
  url: this.url,
@@ -5936,45 +5725,6 @@ var ContextImpl = class ContextImpl {
5936
5725
  allowPrivateAddress: this.federation.allowPrivateAddress
5937
5726
  });
5938
5727
  }
5939
- async enqueueTask(task, data, options = {}) {
5940
- await this.#enqueueTasks(task, [data], options);
5941
- }
5942
- async enqueueTaskMany(task, payloads, options = {}) {
5943
- await this.#enqueueTasks(task, payloads, options);
5944
- }
5945
- async #enqueueTasks(task, items, options) {
5946
- const def = this.federation.taskDefinitions.get(task.name);
5947
- 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().`);
5948
- const queue = this.federation.resolveTaskQueue(task.name);
5949
- if (queue == null) throw new TypeError("No message queue is configured for tasks; pass `queue` to createFederation() or to defineTask().");
5950
- if (items.length < 1) return;
5951
- const delay = options.delay == null ? void 0 : Temporal.Duration.from(options.delay);
5952
- const messages = await Promise.all(items.map(this.#encodeTaskMessage(task, options)));
5953
- if (!this.federation.manuallyStartQueue) this.federation._startQueueInternal(this.data);
5954
- const enqueueOptions = {
5955
- delay,
5956
- orderingKey: options.orderingKey
5957
- };
5958
- if (messages.length === 1) await queue.enqueue(messages[0], enqueueOptions);
5959
- else if (queue.enqueueMany != null) await queue.enqueueMany(messages, enqueueOptions);
5960
- else await Promise.all(messages.map((m) => queue.enqueue(m, enqueueOptions)));
5961
- }
5962
- #encodeTaskMessage = (task, options) => async (data) => {
5963
- const encoded = await this.codec.encode(task.schema, data);
5964
- const carrier = {};
5965
- _opentelemetry_api.propagation.inject(_opentelemetry_api.context.active(), carrier);
5966
- return {
5967
- type: "task",
5968
- id: crypto.randomUUID(),
5969
- baseUrl: this.origin,
5970
- taskName: task.name,
5971
- data: encoded,
5972
- started: Temporal.Now.instant().toString(),
5973
- attempt: 0,
5974
- orderingKey: options.orderingKey,
5975
- traceContext: carrier
5976
- };
5977
- };
5978
5728
  sendActivity(sender, recipients, activity, options = {}) {
5979
5729
  return this.tracerProvider.getTracer(require_http.name, require_http.version).startActiveSpan(this.federation.outboxQueue == null || options.immediate ? "activitypub.outbox" : "activitypub.fanout", {
5980
5730
  kind: this.federation.outboxQueue == null || options.immediate ? _opentelemetry_api.SpanKind.CLIENT : _opentelemetry_api.SpanKind.PRODUCER,