@fedify/fedify 2.4.0-dev.1504 → 2.4.0-dev.1528

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 (109) hide show
  1. package/README.md +10 -7
  2. package/dist/{assert-DvVHoIZ0.mjs → assert-OguE97r2.mjs} +1 -1
  3. package/dist/{assert_instance_of-CxoC8bVq.mjs → assert_instance_of-DBC5X09g.mjs} +1 -1
  4. package/dist/{assert_not_equals-C8vcTTA3.mjs → assert_not_equals-DkVK8oqV.mjs} +1 -1
  5. package/dist/{assert_rejects-DAdaaIWM.mjs → assert_rejects-DN60FHPX.mjs} +2 -2
  6. package/dist/{assert_strict_equals-BzqyKuYL.mjs → assert_strict_equals-XEgZAlrj.mjs} +1 -1
  7. package/dist/{assert_throws-zN79lgIC.mjs → assert_throws-BOkhLGYc.mjs} +1 -1
  8. package/dist/{builder-Ck0Fl_a5.mjs → builder-B6myMguW.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-CYF8X0ft.d.cts → context-BBVLF7lx.d.cts} +272 -543
  15. package/dist/{context-BF5B4ZDk.d.ts → context-BU6jSQdo.d.ts} +272 -542
  16. package/dist/{context-BBRTgkrs.mjs → context-DVoTs_wM.mjs} +2 -8
  17. package/dist/{deno-D3gb4X9v.mjs → deno-CVNsRJe9.mjs} +1 -1
  18. package/dist/{docloader-DUKu0GzG.mjs → docloader-CB8AGpw3.mjs} +3 -3
  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 +259 -3
  30. package/dist/federation/mod.d.cts +4 -4
  31. package/dist/federation/mod.d.ts +4 -4
  32. package/dist/federation/mod.js +257 -1
  33. package/dist/federation/mq.test.mjs +261 -103
  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-CrZzUAtV.js → http-B0-9u_1F.js} +17 -7
  41. package/dist/{http-D9p2_d2X.cjs → http-EkV7OslM.cjs} +17 -7
  42. package/dist/{http-BNFQkiEZ.mjs → http-L7wqkbZR.mjs} +4 -4
  43. package/dist/{key-BM_SRwBV.mjs → key-Ct8zNgGk.mjs} +18 -8
  44. package/dist/{kv-cache-BE1QIPdL.mjs → kv-cache-CUT9OGpX.mjs} +1 -1
  45. package/dist/{kv-cache-Cna211RR.cjs → kv-cache-CbB50co6.cjs} +1 -1
  46. package/dist/{kv-cache-Ch_Zv5Yq.js → kv-cache-Dh8ZoQfC.js} +1 -1
  47. package/dist/{ld-ubkf03eb.mjs → ld-D6I7H18J.mjs} +3 -3
  48. package/dist/{metrics-BXR36qzu.mjs → metrics-DvClPYaE.mjs} +1 -1
  49. package/dist/{middleware-DUNeIkXN.cjs → middleware-B0ujKP-0.cjs} +51 -694
  50. package/dist/{middleware-pzCP79He.mjs → middleware-CGqUj4XY.mjs} +1 -1
  51. package/dist/{middleware-lB4vtShP.js → middleware-DX9Fd37u.js} +52 -683
  52. package/dist/{middleware-iP9VRMus.mjs → middleware-RxFBNV2C.mjs} +67 -310
  53. package/dist/{mod-BHEB3xhE.d.cts → mod-C0F6kvgS.d.cts} +1 -1
  54. package/dist/{mod-4WGAuR6X.d.ts → mod-vPYVoa5n.d.ts} +1 -1
  55. package/dist/mod.cjs +6 -6
  56. package/dist/mod.d.cts +5 -5
  57. package/dist/mod.d.ts +5 -5
  58. package/dist/mod.js +5 -5
  59. package/dist/{mq-DXMt_qCY.d.cts → mq-D-nlpY04.d.ts} +0 -34
  60. package/dist/{mq-B5_hohs7.d.ts → mq-D8uSFzxe.d.cts} +0 -34
  61. package/dist/nodeinfo/client.test.mjs +3 -3
  62. package/dist/nodeinfo/handler.test.mjs +5 -5
  63. package/dist/nodeinfo/types.test.mjs +4 -4
  64. package/dist/otel/exporter.test.mjs +3 -3
  65. package/dist/{outgoing-jsonld-BNL8AC14.mjs → outgoing-jsonld-L_DbOaFe.mjs} +1 -1
  66. package/dist/{owner-Bf1KkncT.mjs → owner-BqPUA8Z6.mjs} +2 -2
  67. package/dist/{proof-Q781Ks5q.mjs → proof-BJKoRFBc.mjs} +5 -5
  68. package/dist/{proof-BMcsi8q_.js → proof-DCCmmEuJ.js} +1 -1
  69. package/dist/{proof-yeAU1MyT.cjs → proof-eZme7HYR.cjs} +1 -1
  70. package/dist/{send-DFV0S_n9.mjs → send-DVtEjoJ6.mjs} +3 -3
  71. package/dist/sig/accept.test.mjs +1 -1
  72. package/dist/sig/http.test.mjs +8 -8
  73. package/dist/sig/key.test.mjs +56 -6
  74. package/dist/sig/ld.test.mjs +7 -7
  75. package/dist/sig/mod.cjs +2 -2
  76. package/dist/sig/mod.js +2 -2
  77. package/dist/sig/owner.test.mjs +6 -6
  78. package/dist/sig/proof.test.mjs +8 -8
  79. package/dist/{std__assert-Dh6uLf_q.mjs → std__assert-BBjXFNOb.mjs} +4 -4
  80. package/dist/{temporal-CyOjsqPj.mjs → temporal-B06FcmVK.mjs} +1 -1
  81. package/dist/testing/mod.d.mts +8 -1037
  82. package/dist/testing/mod.mjs +2 -3
  83. package/dist/utils/docloader.test.mjs +6 -6
  84. package/dist/utils/kv-cache.test.mjs +1 -1
  85. package/dist/utils/mod.cjs +1 -1
  86. package/dist/utils/mod.js +1 -1
  87. package/package.json +7 -12
  88. package/dist/codec-CmlPqjNX.mjs +0 -103
  89. package/dist/federation/tasks/codec.test.d.mts +0 -2
  90. package/dist/federation/tasks/codec.test.mjs +0 -292
  91. package/dist/federation/tasks/enqueue.test.d.mts +0 -2
  92. package/dist/federation/tasks/enqueue.test.mjs +0 -992
  93. package/dist/federation/tasks/tasks.test.d.mts +0 -2
  94. package/dist/federation/tasks/tasks.test.mjs +0 -555
  95. package/dist/mq-03vS-C9P.mjs +0 -276
  96. package/dist/testing-Dy-WhqpN.mjs +0 -77
  97. /package/dist/{accept-CgDcxvjV.mjs → accept-CPkZzmGN.mjs} +0 -0
  98. /package/dist/{activity-listener-BeTGV3wc.mjs → activity-listener-tztVvlNb.mjs} +0 -0
  99. /package/dist/{assert_equals-PBVKNMJd.mjs → assert_equals-C-ZRDbaf.mjs} +0 -0
  100. /package/dist/{circuit-breaker-hJBB6jwA.mjs → circuit-breaker-CSWsyoef.mjs} +0 -0
  101. /package/dist/{client-B_A6mfn3.mjs → client-ByXmQhYD.mjs} +0 -0
  102. /package/dist/{collection-Dp5ky45w.mjs → collection-Cc3DVAhE.mjs} +0 -0
  103. /package/dist/{keycache-CaOR6NYg.mjs → keycache-BeU0LCII.mjs} +0 -0
  104. /package/dist/{keys-CSYsOMFG.mjs → keys-DGu1NFwu.mjs} +0 -0
  105. /package/dist/{kv-CIvR3Non.mjs → kv-rV3vodCc.mjs} +0 -0
  106. /package/dist/{negotiation-m_L2nyS3.mjs → negotiation-DDstyBvc.mjs} +0 -0
  107. /package/dist/{public-audience-c9zmYKgA.mjs → public-audience-Cvbr2Gzt.mjs} +0 -0
  108. /package/dist/{retry-DI4O-zYl.mjs → retry-CXg_MBI-.mjs} +0 -0
  109. /package/dist/{types-BFowWFTT.mjs → types-J53Kw7so.mjs} +0 -0
@@ -1,13 +1,268 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
5
- import { n as assertGreater } from "../std__assert-Dh6uLf_q.mjs";
6
- import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-DAdaaIWM.mjs";
7
- import { t as assert } from "../assert-DvVHoIZ0.mjs";
8
- import { n as ParallelMessageQueue, t as InProcessMessageQueue } from "../mq-03vS-C9P.mjs";
9
- import { delay } from "es-toolkit";
4
+ import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
5
+ import { n as assertGreater } from "../std__assert-BBjXFNOb.mjs";
6
+ import { n as assertGreaterOrEqual, r as assertFalse } from "../assert_rejects-DN60FHPX.mjs";
7
+ import { t as assert } from "../assert-OguE97r2.mjs";
10
8
  import { test } from "@fedify/fixture";
9
+ import { delay } from "es-toolkit";
10
+ //#region src/federation/mq.ts
11
+ /**
12
+ * A message queue that processes messages in the same process.
13
+ * Do not use this in production as it does neither persist messages nor
14
+ * distribute them across multiple processes.
15
+ *
16
+ * @since 0.5.0
17
+ */
18
+ var InProcessMessageQueue = class {
19
+ #messages;
20
+ #monitors;
21
+ #pollIntervalMs;
22
+ #delayedMessages;
23
+ /**
24
+ * Tracks which ordering keys are currently being processed to ensure
25
+ * sequential processing for messages with the same key.
26
+ */
27
+ #processingKeys;
28
+ /**
29
+ * In-process message queue does not provide native retry mechanisms.
30
+ * @since 1.7.0
31
+ */
32
+ nativeRetrial = false;
33
+ /**
34
+ * Constructs a new {@link InProcessMessageQueue} with the given options.
35
+ * @param options Additional options for the in-process message queue.
36
+ */
37
+ constructor(options = {}) {
38
+ this.#messages = [];
39
+ this.#monitors = {};
40
+ this.#pollIntervalMs = Temporal.Duration.from(options.pollInterval ?? { seconds: 5 }).total("millisecond");
41
+ this.#delayedMessages = 0;
42
+ this.#processingKeys = /* @__PURE__ */ new Set();
43
+ }
44
+ enqueue(message, options) {
45
+ const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
46
+ if (delay > 0) {
47
+ this.#delayedMessages++;
48
+ setTimeout(() => {
49
+ this.#delayedMessages--;
50
+ this.#enqueueReady(message, options);
51
+ }, delay);
52
+ return Promise.resolve();
53
+ }
54
+ this.#enqueueReady(message, options);
55
+ return Promise.resolve();
56
+ }
57
+ #enqueueReady(message, options) {
58
+ const orderingKey = options?.orderingKey ?? null;
59
+ this.#messages.push({
60
+ message,
61
+ orderingKey
62
+ });
63
+ this.#notifyMonitors();
64
+ }
65
+ #notifyMonitors() {
66
+ for (const monitorId in this.#monitors) this.#monitors[monitorId]();
67
+ }
68
+ enqueueMany(messages, options) {
69
+ if (messages.length === 0) return Promise.resolve();
70
+ const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
71
+ if (delay > 0) {
72
+ const delayedCount = messages.length;
73
+ const deferredMessages = [...messages];
74
+ this.#delayedMessages += delayedCount;
75
+ setTimeout(() => {
76
+ this.#delayedMessages -= delayedCount;
77
+ this.#enqueueManyReady(deferredMessages, options);
78
+ }, delay);
79
+ return Promise.resolve();
80
+ }
81
+ this.#enqueueManyReady(messages, options);
82
+ return Promise.resolve();
83
+ }
84
+ #enqueueManyReady(messages, options) {
85
+ const orderingKey = options?.orderingKey ?? null;
86
+ for (const message of messages) this.#messages.push({
87
+ message,
88
+ orderingKey
89
+ });
90
+ this.#notifyMonitors();
91
+ }
92
+ async listen(handler, options = {}) {
93
+ const signal = options.signal;
94
+ while (signal == null || !signal.aborted) {
95
+ const idx = this.#messages.findIndex((m) => m.orderingKey == null || !this.#processingKeys.has(m.orderingKey));
96
+ if (idx >= 0) {
97
+ const { message, orderingKey } = this.#messages.splice(idx, 1)[0];
98
+ if (orderingKey != null) this.#processingKeys.add(orderingKey);
99
+ try {
100
+ await handler(message);
101
+ } finally {
102
+ if (orderingKey != null) this.#processingKeys.delete(orderingKey);
103
+ }
104
+ } else if (this.#messages.length === 0) await this.#wait(this.#pollIntervalMs, signal);
105
+ else await this.#wait(10, signal);
106
+ }
107
+ }
108
+ getDepth() {
109
+ const ready = this.#messages.length;
110
+ const delayed = this.#delayedMessages;
111
+ return Promise.resolve({
112
+ queued: ready + delayed,
113
+ ready,
114
+ delayed
115
+ });
116
+ }
117
+ #wait(ms, signal) {
118
+ let timer = null;
119
+ return Promise.any([new Promise((resolve) => {
120
+ signal?.addEventListener("abort", () => {
121
+ if (timer != null) clearTimeout(timer);
122
+ resolve();
123
+ }, { once: true });
124
+ const monitorId = crypto.randomUUID();
125
+ this.#monitors[monitorId] = () => {
126
+ delete this.#monitors[monitorId];
127
+ if (timer != null) clearTimeout(timer);
128
+ resolve();
129
+ };
130
+ }), new Promise((resolve) => timer = setTimeout(resolve, ms))]);
131
+ }
132
+ };
133
+ /**
134
+ * A message queue that processes messages in parallel. It takes another
135
+ * {@link MessageQueue}, and processes messages in parallel up to a certain
136
+ * number of workers.
137
+ *
138
+ * Actually, it's rather a decorator than a queue itself.
139
+ *
140
+ * Note that the workers do not run in truly parallel, in the sense that they
141
+ * are not running in separate threads or processes. They are running in the
142
+ * same process, but are scheduled to run in parallel. Hence, this is useful
143
+ * for I/O-bound tasks, but not for CPU-bound tasks, which is okay for Fedify's
144
+ * workloads.
145
+ *
146
+ * When using `ParallelMessageQueue`, the ordering guarantee is preserved
147
+ * *only if* the underlying queue implementation delivers messages in a wrapper
148
+ * format that includes the `__fedify_ordering_key__` property. Currently,
149
+ * only `DenoKvMessageQueue` and `WorkersMessageQueue` use this format.
150
+ * For other queue implementations (e.g., `InProcessMessageQueue`,
151
+ * `RedisMessageQueue`, `PostgresMessageQueue`, `SqliteMessageQueue`,
152
+ * `AmqpMessageQueue`), the ordering key cannot be detected by
153
+ * `ParallelMessageQueue`, so ordering guarantees are handled by those
154
+ * implementations directly rather than at the `ParallelMessageQueue` level.
155
+ *
156
+ * Messages with the same ordering key will never be processed concurrently
157
+ * by different workers, ensuring sequential processing within each key.
158
+ * Messages with different ordering keys (or no ordering key) can still be
159
+ * processed in parallel.
160
+ *
161
+ * @since 1.0.0
162
+ */
163
+ var ParallelMessageQueue = class ParallelMessageQueue {
164
+ queue;
165
+ workers;
166
+ /**
167
+ * Inherits the native retry capability from the wrapped queue.
168
+ * @since 1.7.0
169
+ */
170
+ nativeRetrial;
171
+ getDepth;
172
+ /**
173
+ * Tracks which ordering keys are currently being processed to ensure
174
+ * sequential processing for messages with the same key.
175
+ */
176
+ #processingKeys = /* @__PURE__ */ new Set();
177
+ /**
178
+ * Pending messages waiting for their ordering key to become available.
179
+ */
180
+ #pendingMessages = [];
181
+ /**
182
+ * Constructs a new {@link ParallelMessageQueue} with the given queue and
183
+ * number of workers.
184
+ * @param queue The message queue to use under the hood. Note that
185
+ * {@link ParallelMessageQueue} cannot be nested.
186
+ * @param workers The number of workers to process messages in parallel.
187
+ * @throws {TypeError} If the given queue is an instance of
188
+ * {@link ParallelMessageQueue}.
189
+ */
190
+ constructor(queue, workers) {
191
+ if (queue instanceof ParallelMessageQueue) throw new TypeError("Cannot nest ParallelMessageQueue.");
192
+ this.queue = queue;
193
+ this.workers = workers;
194
+ this.nativeRetrial = queue.nativeRetrial;
195
+ if (queue.getDepth != null) this.getDepth = () => queue.getDepth();
196
+ }
197
+ enqueue(message, options) {
198
+ return this.queue.enqueue(message, options);
199
+ }
200
+ async enqueueMany(messages, options) {
201
+ if (this.queue.enqueueMany == null) {
202
+ const errors = (await Promise.allSettled(messages.map((message) => this.queue.enqueue(message, options)))).filter((r) => r.status === "rejected").map((r) => r.reason);
203
+ if (errors.length > 1) throw new AggregateError(errors, "Failed to enqueue messages.");
204
+ else if (errors.length === 1) throw errors[0];
205
+ return;
206
+ }
207
+ await this.queue.enqueueMany(messages, options);
208
+ }
209
+ /**
210
+ * Extracts ordering key from a message if present.
211
+ *
212
+ * This method only works for queue implementations that deliver messages
213
+ * in the wrapper format with `__fedify_ordering_key__` property. Currently,
214
+ * only `DenoKvMessageQueue` and `WorkersMessageQueue` use this format.
215
+ *
216
+ * For other queue implementations (`InProcessMessageQueue`,
217
+ * `RedisMessageQueue`, `PostgresMessageQueue`, `SqliteMessageQueue`,
218
+ * `AmqpMessageQueue`), messages are delivered as raw payloads without the
219
+ * wrapper, so the ordering key cannot be detected here. Those
220
+ * implementations handle ordering guarantees internally.
221
+ */
222
+ #extractOrderingKey(message) {
223
+ if (message != null && typeof message === "object") {
224
+ if ("__fedify_ordering_key__" in message) return message.__fedify_ordering_key__;
225
+ }
226
+ }
227
+ listen(handler, options = {}) {
228
+ const workers = /* @__PURE__ */ new Map();
229
+ return this.queue.listen(async (message) => {
230
+ while (workers.size >= this.workers) {
231
+ const consumedId = await Promise.any(workers.values());
232
+ workers.delete(consumedId);
233
+ }
234
+ const workerId = crypto.randomUUID();
235
+ const orderingKey = this.#extractOrderingKey(message);
236
+ if (orderingKey != null && this.#processingKeys.has(orderingKey)) await new Promise((resolve) => {
237
+ this.#pendingMessages.push({
238
+ message,
239
+ orderingKey,
240
+ resolve
241
+ });
242
+ });
243
+ if (orderingKey != null) this.#processingKeys.add(orderingKey);
244
+ const promise = this.#work(workerId, handler, message, orderingKey);
245
+ workers.set(workerId, promise);
246
+ }, options);
247
+ }
248
+ async #work(workerId, handler, message, orderingKey) {
249
+ await this.#sleep(0);
250
+ try {
251
+ await handler(message);
252
+ } finally {
253
+ if (orderingKey != null) {
254
+ this.#processingKeys.delete(orderingKey);
255
+ const pendingIdx = this.#pendingMessages.findIndex((p) => p.orderingKey === orderingKey);
256
+ if (pendingIdx >= 0) this.#pendingMessages.splice(pendingIdx, 1)[0].resolve();
257
+ }
258
+ }
259
+ return workerId;
260
+ }
261
+ #sleep(ms) {
262
+ return new Promise((resolve) => setTimeout(resolve, ms));
263
+ }
264
+ };
265
+ //#endregion
11
266
  //#region src/federation/mq.test.ts
12
267
  async function disposeMessageQueue(mq) {
13
268
  if (Symbol.asyncDispose in mq) {
@@ -27,9 +282,6 @@ test("InProcessMessageQueue", async (t) => {
27
282
  await t.step("nativeRetrial property", () => {
28
283
  assertFalse(mq.nativeRetrial);
29
284
  });
30
- await t.step("nativeDeduplication property", () => {
31
- assertFalse(mq.nativeDeduplication);
32
- });
33
285
  await t.step("getDepth() [empty]", async () => {
34
286
  assertEquals(await mq.getDepth(), {
35
287
  queued: 0,
@@ -315,97 +567,6 @@ test("MessageQueue.nativeRetrial", async (t) => {
315
567
  assert(new TestWorkersMessageQueue(new MockQueue()).nativeRetrial);
316
568
  });
317
569
  });
318
- test("ParallelMessageQueue inherits nativeDeduplication", () => {
319
- class NativeDeduplicationQueue {
320
- nativeDeduplication = true;
321
- enqueue() {
322
- return Promise.resolve();
323
- }
324
- listen() {
325
- return Promise.resolve();
326
- }
327
- }
328
- assert(new ParallelMessageQueue(new NativeDeduplicationQueue(), 5).nativeDeduplication);
329
- });
330
- test("ParallelMessageQueue forwards deduplicationKey to the wrapped queue", async () => {
331
- class RecordingQueue {
332
- nativeDeduplication = true;
333
- singles = [];
334
- batches = [];
335
- enqueue(_message, options) {
336
- this.singles.push(options);
337
- return Promise.resolve();
338
- }
339
- enqueueMany(_messages, options) {
340
- this.batches.push(options);
341
- return Promise.resolve();
342
- }
343
- listen() {
344
- return Promise.resolve();
345
- }
346
- }
347
- const inner = new RecordingQueue();
348
- const workers = new ParallelMessageQueue(inner, 5);
349
- await workers.enqueue({ x: 1 }, { deduplicationKey: "k1" });
350
- await workers.enqueueMany([{ x: 1 }, { x: 2 }], { deduplicationKey: "k2" });
351
- assertEquals(inner.singles[0]?.deduplicationKey, "k1");
352
- assertEquals(inner.batches[0]?.deduplicationKey, "k2");
353
- });
354
- test("ParallelMessageQueue rejects a deduplicated batch when the wrapped queue lacks enqueueMany", async () => {
355
- class NoBulkQueue {
356
- nativeDeduplication = true;
357
- enqueued = [];
358
- enqueue(message) {
359
- this.enqueued.push(message);
360
- return Promise.resolve();
361
- }
362
- listen() {
363
- return Promise.resolve();
364
- }
365
- }
366
- const inner = new NoBulkQueue();
367
- const workers = new ParallelMessageQueue(inner, 5);
368
- await assertRejects(() => workers.enqueueMany([{ x: 1 }, { x: 2 }], { deduplicationKey: "k" }), TypeError, "enqueueMany");
369
- assertEquals(inner.enqueued.length, 0);
370
- });
371
- test("ParallelMessageQueue falls back to enqueue() for a single deduplicated item when the wrapped queue lacks enqueueMany", async () => {
372
- class NoBulkQueue {
373
- nativeDeduplication = true;
374
- enqueued = [];
375
- options = [];
376
- enqueue(message, options) {
377
- this.enqueued.push(message);
378
- this.options.push(options);
379
- return Promise.resolve();
380
- }
381
- listen() {
382
- return Promise.resolve();
383
- }
384
- }
385
- const inner = new NoBulkQueue();
386
- await new ParallelMessageQueue(inner, 5).enqueueMany([{ x: 1 }], { deduplicationKey: "k" });
387
- assertEquals(inner.enqueued, [{ x: 1 }]);
388
- assertEquals(inner.options[0]?.deduplicationKey, "k");
389
- });
390
- test("ParallelMessageQueue still fans out a non-deduplicated batch when the wrapped queue lacks enqueueMany", async () => {
391
- class NoBulkQueue {
392
- enqueued = [];
393
- enqueue(message) {
394
- this.enqueued.push(message);
395
- return Promise.resolve();
396
- }
397
- listen() {
398
- return Promise.resolve();
399
- }
400
- }
401
- const inner = new NoBulkQueue();
402
- await new ParallelMessageQueue(inner, 5).enqueueMany([
403
- { x: 1 },
404
- { x: 2 },
405
- { x: 3 }
406
- ]);
407
- assertEquals(inner.enqueued.length, 3);
408
- });
409
570
  const queues = { InProcessMessageQueue: () => Promise.resolve(new InProcessMessageQueue()) };
410
571
  if ("Deno" in globalThis && "openKv" in globalThis.Deno && typeof globalThis.Deno.openKv === "function") {
411
572
  const packageName = () => "@fedify/denokv";
@@ -421,9 +582,6 @@ for (const mqName in queues) test({
421
582
  await t.step("nativeRetrial property inheritance", () => {
422
583
  assertEquals(workers.nativeRetrial, mq.nativeRetrial);
423
584
  });
424
- await t.step("nativeDeduplication property inheritance", () => {
425
- assertEquals(workers.nativeDeduplication, mq.nativeDeduplication);
426
- });
427
585
  await t.step("getDepth() delegation", async () => {
428
586
  if (mq.getDepth == null) assertEquals(workers.getDepth, void 0);
429
587
  else assertEquals(await workers.getDepth?.(), await mq.getDepth());
@@ -1,10 +1,10 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import "../std__assert-Dh6uLf_q.mjs";
5
- import { r as assertFalse } from "../assert_rejects-DAdaaIWM.mjs";
6
- import { t as assert } from "../assert-DvVHoIZ0.mjs";
7
- import { t as acceptsJsonLd } from "../negotiation-m_L2nyS3.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 acceptsJsonLd } from "../negotiation-DDstyBvc.mjs";
8
8
  import { test } from "@fedify/fixture";
9
9
  //#region src/federation/negotiation.test.ts
10
10
  test("acceptsJsonLd()", () => {
@@ -1,9 +1,9 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { l as AssertionError, t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
5
- import { t as assertNotEquals } from "../assert_not_equals-C8vcTTA3.mjs";
6
- import { t as createExponentialBackoffPolicy } from "../retry-DI4O-zYl.mjs";
4
+ import { l as AssertionError, t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
5
+ import { t as assertNotEquals } from "../assert_not_equals-DkVK8oqV.mjs";
6
+ import { t as createExponentialBackoffPolicy } from "../retry-CXg_MBI-.mjs";
7
7
  import { test } from "@fedify/fixture";
8
8
  //#region src/federation/retry.test.ts
9
9
  test("createExponentialBackoffPolicy()", () => {
@@ -1,11 +1,11 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
5
- import "../std__assert-Dh6uLf_q.mjs";
6
- import { r as assertFalse } from "../assert_rejects-DAdaaIWM.mjs";
7
- import { t as assertThrows } from "../assert_throws-zN79lgIC.mjs";
8
- import { t as assert } from "../assert-DvVHoIZ0.mjs";
4
+ import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
5
+ import "../std__assert-BBjXFNOb.mjs";
6
+ import { r as assertFalse } from "../assert_rejects-DN60FHPX.mjs";
7
+ import { t as assertThrows } from "../assert_throws-BOkhLGYc.mjs";
8
+ import { t as assert } from "../assert-OguE97r2.mjs";
9
9
  import { getLogger } from "@logtape/logtape";
10
10
  import { Router, RouterError, assertPath, isPath } from "@fedify/uri-template";
11
11
  import { test } from "@fedify/fixture";
@@ -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-PBVKNMJd.mjs";
6
- import "../std__assert-Dh6uLf_q.mjs";
7
- import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-DAdaaIWM.mjs";
8
- import { t as assertInstanceOf } from "../assert_instance_of-CxoC8bVq.mjs";
9
- import { t as assertNotEquals } from "../assert_not_equals-C8vcTTA3.mjs";
10
- import { t as assert } from "../assert-DvVHoIZ0.mjs";
11
- import { l as verifyRequest } from "../http-BNFQkiEZ.mjs";
12
- import { i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-CSYsOMFG.mjs";
13
- import { t as doesActorOwnKey } from "../owner-Bf1KkncT.mjs";
14
- import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-DFV0S_n9.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-L7wqkbZR.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-BqPUA8Z6.mjs";
14
+ import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-DVtEjoJ6.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-Dh6uLf_q.mjs";
5
- import { r as assertFalse } from "../assert_rejects-DAdaaIWM.mjs";
6
- import { t as assert } from "../assert-DvVHoIZ0.mjs";
7
- import { t as hasMalformedKnownTemporalLiteral } from "../temporal-CyOjsqPj.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-B06FcmVK.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-BBRTgkrs.mjs";
5
- import { t as MemoryKvStore } from "../kv-CIvR3Non.mjs";
6
- import { t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
7
- import "../std__assert-Dh6uLf_q.mjs";
8
- import { t as assertNotEquals } from "../assert_not_equals-C8vcTTA3.mjs";
9
- import { o as createFederation, s as handleWebFinger } from "../middleware-iP9VRMus.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-RxFBNV2C.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
@@ -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.1504+756217cc";
13
+ var version = "2.4.0-dev.1528+fea670ad";
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;
@@ -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.1504+756217cc";
14
+ var version = "2.4.0-dev.1528+fea670ad";
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;
@@ -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-D3gb4X9v.mjs";
5
- import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-BXR36qzu.mjs";
6
- import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature } from "./accept-CgDcxvjV.mjs";
7
- import { o as validateCryptoKey, r as fetchKeyDetailed } from "./key-BM_SRwBV.mjs";
4
+ import { n as version, t as name } from "./deno-CVNsRJe9.mjs";
5
+ import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-DvClPYaE.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-Ct8zNgGk.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-D3gb4X9v.mjs";
5
- import { _ as recordKeyLookup, n as getDurationMs, t as classifyFetchError } from "./metrics-BXR36qzu.mjs";
4
+ import { n as version, t as name } from "./deno-CVNsRJe9.mjs";
5
+ import { _ as recordKeyLookup, n as getDurationMs, t as classifyFetchError } from "./metrics-DvClPYaE.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-BXR36qzu.mjs";
4
+ import { p as recordDocumentCache } from "./metrics-DvClPYaE.mjs";
5
5
  import { getLogger } from "@logtape/logtape";
6
6
  import { preloadedContexts } from "@fedify/vocab-runtime";
7
7
  //#region src/utils/kv-cache.ts