@fedify/fedify 2.3.0-dev.1005 → 2.3.0-dev.1021

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 (55) hide show
  1. package/dist/{builder-gAB0htof.mjs → builder-Nn2r1dKd.mjs} +13 -3
  2. package/dist/compat/mod.d.cts +1 -1
  3. package/dist/compat/mod.d.ts +1 -1
  4. package/dist/compat/transformers.test.mjs +1 -1
  5. package/dist/{context-DJGagtNd.d.cts → context-Bxs4cdIZ.d.cts} +53 -1
  6. package/dist/{context-BzH2-ajs.d.ts → context-CVNXcFHR.d.ts} +53 -1
  7. package/dist/{deno-4f2FzBe9.mjs → deno-BnQyJ03o.mjs} +1 -1
  8. package/dist/{docloader-B3ZVRe6e.mjs → docloader-mEJ3hsMB.mjs} +2 -2
  9. package/dist/federation/builder.test.mjs +7 -2
  10. package/dist/federation/handler.test.mjs +2 -2
  11. package/dist/federation/idempotency.test.mjs +2 -2
  12. package/dist/federation/middleware.test.mjs +41 -9
  13. package/dist/federation/mod.cjs +38 -12
  14. package/dist/federation/mod.d.cts +3 -3
  15. package/dist/federation/mod.d.ts +3 -3
  16. package/dist/federation/mod.js +38 -12
  17. package/dist/federation/mq.test.mjs +172 -11
  18. package/dist/federation/send.test.mjs +3 -3
  19. package/dist/federation/webfinger.test.mjs +1 -1
  20. package/dist/{http-CcfcE8N4.js → http-BJ-t29n_.js} +1 -1
  21. package/dist/{http-Cy2mQS66.mjs → http-CfToB_iu.mjs} +2 -2
  22. package/dist/{http-JLLWZX_d.cjs → http-D4xMqSqO.cjs} +1 -1
  23. package/dist/{key-eKxvr-C4.mjs → key-CeANlo1H.mjs} +1 -1
  24. package/dist/{kv-cache-YWK2pfn_.js → kv-cache-B142kDZL.js} +1 -1
  25. package/dist/{kv-cache-BbFjDt5I.cjs → kv-cache-DRwOjOkl.cjs} +1 -1
  26. package/dist/{ld-D2sVtqAV.mjs → ld-CUlVC-TS.mjs} +2 -2
  27. package/dist/{middleware-cbXddGIi.cjs → middleware-ASvK22Do.cjs} +1 -1
  28. package/dist/{middleware-BjvwtKjp.mjs → middleware-BPZEcrMG.mjs} +17 -14
  29. package/dist/{middleware-DZHQpJaI.mjs → middleware-Cgy7UwfR.mjs} +1 -1
  30. package/dist/{middleware-BiLI6cmz.js → middleware-CysDkaXo.js} +21 -8
  31. package/dist/{middleware-y5r1KhBz.cjs → middleware-I5XEZ_pZ.cjs} +22 -9
  32. package/dist/{mod-2d12ffz3.d.ts → mod-Bc6p4npy.d.ts} +1 -1
  33. package/dist/{mod-D35TRn09.d.cts → mod-zA6NZHUG.d.cts} +1 -1
  34. package/dist/mod.cjs +4 -4
  35. package/dist/mod.d.cts +4 -4
  36. package/dist/mod.d.ts +4 -4
  37. package/dist/mod.js +4 -4
  38. package/dist/nodeinfo/handler.test.mjs +1 -1
  39. package/dist/{owner-B6CaBwbr.mjs → owner-CuW0S2XY.mjs} +2 -2
  40. package/dist/{proof-DV85kS2-.mjs → proof-CFPGr1xC.mjs} +2 -2
  41. package/dist/{proof-DhE_ibsB.js → proof-CtMmqa09.js} +1 -1
  42. package/dist/{proof-DCrzgogM.cjs → proof-oGiWJkX0.cjs} +1 -1
  43. package/dist/{send-BjwIELCy.mjs → send-dhl-s8G0.mjs} +2 -2
  44. package/dist/sig/http.test.mjs +2 -2
  45. package/dist/sig/key.test.mjs +1 -1
  46. package/dist/sig/ld.test.mjs +2 -2
  47. package/dist/sig/mod.cjs +2 -2
  48. package/dist/sig/mod.js +2 -2
  49. package/dist/sig/owner.test.mjs +1 -1
  50. package/dist/sig/proof.test.mjs +1 -1
  51. package/dist/testing/mod.d.mts +12 -0
  52. package/dist/utils/docloader.test.mjs +2 -2
  53. package/dist/utils/mod.cjs +1 -1
  54. package/dist/utils/mod.js +1 -1
  55. package/package.json +5 -5
@@ -1,6 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
- import { a as createExponentialBackoffPolicy, c as buildCollectionSynchronizationHeader, d as Router, f as RouterError, i as SendActivityError, l as digest, o as respondWithObject, r as handleWebFinger, s as respondWithObjectIfAcceptable, t as createFederation, u as createFederationBuilder } from "../middleware-BiLI6cmz.js";
3
+ import { a as createExponentialBackoffPolicy, c as buildCollectionSynchronizationHeader, d as Router, f as RouterError, i as SendActivityError, l as digest, o as respondWithObject, r as handleWebFinger, s as respondWithObjectIfAcceptable, t as createFederation, u as createFederationBuilder } from "../middleware-CysDkaXo.js";
4
4
  import { isEqual } from "es-toolkit";
5
5
  //#region src/federation/kv.ts
6
6
  /**
@@ -101,6 +101,7 @@ var InProcessMessageQueue = class {
101
101
  #messages;
102
102
  #monitors;
103
103
  #pollIntervalMs;
104
+ #delayedMessages;
104
105
  /**
105
106
  * Tracks which ordering keys are currently being processed to ensure
106
107
  * sequential processing for messages with the same key.
@@ -119,42 +120,56 @@ var InProcessMessageQueue = class {
119
120
  this.#messages = [];
120
121
  this.#monitors = {};
121
122
  this.#pollIntervalMs = Temporal.Duration.from(options.pollInterval ?? { seconds: 5 }).total("millisecond");
123
+ this.#delayedMessages = 0;
122
124
  this.#processingKeys = /* @__PURE__ */ new Set();
123
125
  }
124
126
  enqueue(message, options) {
125
127
  const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
126
128
  if (delay > 0) {
127
- setTimeout(() => this.enqueue(message, {
128
- ...options,
129
- delay: void 0
130
- }), delay);
129
+ this.#delayedMessages++;
130
+ setTimeout(() => {
131
+ this.#delayedMessages--;
132
+ this.#enqueueReady(message, options);
133
+ }, delay);
131
134
  return Promise.resolve();
132
135
  }
136
+ this.#enqueueReady(message, options);
137
+ return Promise.resolve();
138
+ }
139
+ #enqueueReady(message, options) {
133
140
  const orderingKey = options?.orderingKey ?? null;
134
141
  this.#messages.push({
135
142
  message,
136
143
  orderingKey
137
144
  });
145
+ this.#notifyMonitors();
146
+ }
147
+ #notifyMonitors() {
138
148
  for (const monitorId in this.#monitors) this.#monitors[monitorId]();
139
- return Promise.resolve();
140
149
  }
141
150
  enqueueMany(messages, options) {
142
151
  if (messages.length === 0) return Promise.resolve();
143
152
  const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
144
153
  if (delay > 0) {
145
- setTimeout(() => this.enqueueMany(messages, {
146
- ...options,
147
- delay: void 0
148
- }), delay);
154
+ const delayedCount = messages.length;
155
+ const deferredMessages = [...messages];
156
+ this.#delayedMessages += delayedCount;
157
+ setTimeout(() => {
158
+ this.#delayedMessages -= delayedCount;
159
+ this.#enqueueManyReady(deferredMessages, options);
160
+ }, delay);
149
161
  return Promise.resolve();
150
162
  }
163
+ this.#enqueueManyReady(messages, options);
164
+ return Promise.resolve();
165
+ }
166
+ #enqueueManyReady(messages, options) {
151
167
  const orderingKey = options?.orderingKey ?? null;
152
168
  for (const message of messages) this.#messages.push({
153
169
  message,
154
170
  orderingKey
155
171
  });
156
- for (const monitorId in this.#monitors) this.#monitors[monitorId]();
157
- return Promise.resolve();
172
+ this.#notifyMonitors();
158
173
  }
159
174
  async listen(handler, options = {}) {
160
175
  const signal = options.signal;
@@ -172,6 +187,15 @@ var InProcessMessageQueue = class {
172
187
  else await this.#wait(10, signal);
173
188
  }
174
189
  }
190
+ getDepth() {
191
+ const ready = this.#messages.length;
192
+ const delayed = this.#delayedMessages;
193
+ return Promise.resolve({
194
+ queued: ready + delayed,
195
+ ready,
196
+ delayed
197
+ });
198
+ }
175
199
  #wait(ms, signal) {
176
200
  let timer = null;
177
201
  return Promise.any([new Promise((resolve) => {
@@ -226,6 +250,7 @@ var ParallelMessageQueue = class ParallelMessageQueue {
226
250
  * @since 1.7.0
227
251
  */
228
252
  nativeRetrial;
253
+ getDepth;
229
254
  /**
230
255
  * Tracks which ordering keys are currently being processed to ensure
231
256
  * sequential processing for messages with the same key.
@@ -249,6 +274,7 @@ var ParallelMessageQueue = class ParallelMessageQueue {
249
274
  this.queue = queue;
250
275
  this.workers = workers;
251
276
  this.nativeRetrial = queue.nativeRetrial;
277
+ if (queue.getDepth != null) this.getDepth = () => queue.getDepth();
252
278
  }
253
279
  enqueue(message, options) {
254
280
  return this.queue.enqueue(message, options);
@@ -19,6 +19,7 @@ var InProcessMessageQueue = class {
19
19
  #messages;
20
20
  #monitors;
21
21
  #pollIntervalMs;
22
+ #delayedMessages;
22
23
  /**
23
24
  * Tracks which ordering keys are currently being processed to ensure
24
25
  * sequential processing for messages with the same key.
@@ -37,42 +38,56 @@ var InProcessMessageQueue = class {
37
38
  this.#messages = [];
38
39
  this.#monitors = {};
39
40
  this.#pollIntervalMs = Temporal.Duration.from(options.pollInterval ?? { seconds: 5 }).total("millisecond");
41
+ this.#delayedMessages = 0;
40
42
  this.#processingKeys = /* @__PURE__ */ new Set();
41
43
  }
42
44
  enqueue(message, options) {
43
45
  const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
44
46
  if (delay > 0) {
45
- setTimeout(() => this.enqueue(message, {
46
- ...options,
47
- delay: void 0
48
- }), delay);
47
+ this.#delayedMessages++;
48
+ setTimeout(() => {
49
+ this.#delayedMessages--;
50
+ this.#enqueueReady(message, options);
51
+ }, delay);
49
52
  return Promise.resolve();
50
53
  }
54
+ this.#enqueueReady(message, options);
55
+ return Promise.resolve();
56
+ }
57
+ #enqueueReady(message, options) {
51
58
  const orderingKey = options?.orderingKey ?? null;
52
59
  this.#messages.push({
53
60
  message,
54
61
  orderingKey
55
62
  });
63
+ this.#notifyMonitors();
64
+ }
65
+ #notifyMonitors() {
56
66
  for (const monitorId in this.#monitors) this.#monitors[monitorId]();
57
- return Promise.resolve();
58
67
  }
59
68
  enqueueMany(messages, options) {
60
69
  if (messages.length === 0) return Promise.resolve();
61
70
  const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
62
71
  if (delay > 0) {
63
- setTimeout(() => this.enqueueMany(messages, {
64
- ...options,
65
- delay: void 0
66
- }), delay);
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);
67
79
  return Promise.resolve();
68
80
  }
81
+ this.#enqueueManyReady(messages, options);
82
+ return Promise.resolve();
83
+ }
84
+ #enqueueManyReady(messages, options) {
69
85
  const orderingKey = options?.orderingKey ?? null;
70
86
  for (const message of messages) this.#messages.push({
71
87
  message,
72
88
  orderingKey
73
89
  });
74
- for (const monitorId in this.#monitors) this.#monitors[monitorId]();
75
- return Promise.resolve();
90
+ this.#notifyMonitors();
76
91
  }
77
92
  async listen(handler, options = {}) {
78
93
  const signal = options.signal;
@@ -90,6 +105,15 @@ var InProcessMessageQueue = class {
90
105
  else await this.#wait(10, signal);
91
106
  }
92
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
+ }
93
117
  #wait(ms, signal) {
94
118
  let timer = null;
95
119
  return Promise.any([new Promise((resolve) => {
@@ -144,6 +168,7 @@ var ParallelMessageQueue = class ParallelMessageQueue {
144
168
  * @since 1.7.0
145
169
  */
146
170
  nativeRetrial;
171
+ getDepth;
147
172
  /**
148
173
  * Tracks which ordering keys are currently being processed to ensure
149
174
  * sequential processing for messages with the same key.
@@ -167,6 +192,7 @@ var ParallelMessageQueue = class ParallelMessageQueue {
167
192
  this.queue = queue;
168
193
  this.workers = workers;
169
194
  this.nativeRetrial = queue.nativeRetrial;
195
+ if (queue.getDepth != null) this.getDepth = () => queue.getDepth();
170
196
  }
171
197
  enqueue(message, options) {
172
198
  return this.queue.enqueue(message, options);
@@ -256,6 +282,13 @@ test("InProcessMessageQueue", async (t) => {
256
282
  await t.step("nativeRetrial property", () => {
257
283
  assertFalse(mq.nativeRetrial);
258
284
  });
285
+ await t.step("getDepth() [empty]", async () => {
286
+ assertEquals(await mq.getDepth(), {
287
+ queued: 0,
288
+ ready: 0,
289
+ delayed: 0
290
+ });
291
+ });
259
292
  const messages = [];
260
293
  const controller = new AbortController();
261
294
  const listening = mq.listen((message) => {
@@ -306,6 +339,130 @@ test("InProcessMessageQueue", async (t) => {
306
339
  controller.abort();
307
340
  await listening;
308
341
  });
342
+ test("InProcessMessageQueue.getDepth()", async () => {
343
+ const mq = new InProcessMessageQueue();
344
+ assertEquals(await mq.getDepth(), {
345
+ queued: 0,
346
+ ready: 0,
347
+ delayed: 0
348
+ });
349
+ await mq.enqueue("Ready message");
350
+ await mq.enqueue("Delayed message", { delay: Temporal.Duration.from({ seconds: 1 }) });
351
+ assertEquals(await mq.getDepth(), {
352
+ queued: 2,
353
+ ready: 1,
354
+ delayed: 1
355
+ });
356
+ const messages = [];
357
+ const controller = new AbortController();
358
+ const listening = mq.listen((message) => {
359
+ messages.push(message);
360
+ if (messages.length >= 2) controller.abort();
361
+ }, { signal: controller.signal });
362
+ await waitFor(() => messages.length >= 2, 15e3);
363
+ await listening;
364
+ assertEquals(await mq.getDepth(), {
365
+ queued: 0,
366
+ ready: 0,
367
+ delayed: 0
368
+ });
369
+ });
370
+ test("InProcessMessageQueue.getDepth() snapshots delayed batches", async () => {
371
+ const mq = new InProcessMessageQueue();
372
+ const messages = ["first", "second"];
373
+ await mq.enqueueMany(messages, { delay: Temporal.Duration.from({ milliseconds: 250 }) });
374
+ messages.length = 0;
375
+ assertEquals(await mq.getDepth(), {
376
+ queued: 2,
377
+ ready: 0,
378
+ delayed: 2
379
+ });
380
+ const handled = [];
381
+ const controller = new AbortController();
382
+ const listening = mq.listen((message) => {
383
+ handled.push(message);
384
+ if (handled.length >= 2) controller.abort();
385
+ }, { signal: controller.signal });
386
+ await waitFor(() => handled.length >= 2, 15e3);
387
+ await listening;
388
+ assertEquals(handled, ["first", "second"]);
389
+ });
390
+ test("InProcessMessageQueue.getDepth() excludes in-flight messages", async () => {
391
+ const mq = new InProcessMessageQueue();
392
+ let resolveHandler;
393
+ const controller = new AbortController();
394
+ const handled = new Promise((resolve) => {
395
+ resolveHandler = resolve;
396
+ });
397
+ let notifyStarted = () => {};
398
+ const handlerStarted = new Promise((resolve) => {
399
+ notifyStarted = resolve;
400
+ });
401
+ const listening = mq.listen(async () => {
402
+ notifyStarted();
403
+ await handled;
404
+ controller.abort();
405
+ }, { signal: controller.signal });
406
+ try {
407
+ await mq.enqueue("in-flight");
408
+ await handlerStarted;
409
+ assertEquals(await mq.getDepth(), {
410
+ queued: 0,
411
+ ready: 0,
412
+ delayed: 0
413
+ });
414
+ } finally {
415
+ resolveHandler?.();
416
+ controller.abort();
417
+ await listening;
418
+ }
419
+ });
420
+ test("InProcessMessageQueue delayed enqueue uses the internal ready path", async () => {
421
+ class RejectingReadyQueue extends InProcessMessageQueue {
422
+ enqueue(message, options) {
423
+ if (options?.delay == null) return Promise.reject(/* @__PURE__ */ new Error("ready enqueue should not be called"));
424
+ return super.enqueue(message, options);
425
+ }
426
+ }
427
+ const mq = new RejectingReadyQueue({ pollInterval: { milliseconds: 10 } });
428
+ const messages = [];
429
+ const controller = new AbortController();
430
+ const listening = mq.listen((message) => {
431
+ messages.push(message);
432
+ controller.abort();
433
+ }, { signal: controller.signal });
434
+ try {
435
+ await mq.enqueue("delayed", { delay: Temporal.Duration.from({ milliseconds: 10 }) });
436
+ await waitFor(() => messages.length > 0, 2e3);
437
+ assertEquals(messages, ["delayed"]);
438
+ } finally {
439
+ controller.abort();
440
+ await listening;
441
+ }
442
+ });
443
+ test("InProcessMessageQueue delayed enqueueMany uses the internal ready path", async () => {
444
+ class RejectingReadyQueue extends InProcessMessageQueue {
445
+ enqueueMany(messages, options) {
446
+ if (options?.delay == null) return Promise.reject(/* @__PURE__ */ new Error("ready enqueueMany should not be called"));
447
+ return super.enqueueMany(messages, options);
448
+ }
449
+ }
450
+ const mq = new RejectingReadyQueue({ pollInterval: { milliseconds: 10 } });
451
+ const messages = [];
452
+ const controller = new AbortController();
453
+ const listening = mq.listen((message) => {
454
+ messages.push(message);
455
+ if (messages.length >= 2) controller.abort();
456
+ }, { signal: controller.signal });
457
+ try {
458
+ await mq.enqueueMany(["first", "second"], { delay: Temporal.Duration.from({ milliseconds: 10 }) });
459
+ await waitFor(() => messages.length >= 2, 2e3);
460
+ assertEquals(messages, ["first", "second"]);
461
+ } finally {
462
+ controller.abort();
463
+ await listening;
464
+ }
465
+ });
309
466
  test("InProcessMessageQueue orderingKey", async (t) => {
310
467
  const mq = new InProcessMessageQueue();
311
468
  const orderTracker = {
@@ -425,6 +582,10 @@ for (const mqName in queues) test({
425
582
  await t.step("nativeRetrial property inheritance", () => {
426
583
  assertEquals(workers.nativeRetrial, mq.nativeRetrial);
427
584
  });
585
+ await t.step("getDepth() delegation", async () => {
586
+ if (mq.getDepth == null) assertEquals(workers.getDepth, void 0);
587
+ else assertEquals(await workers.getDepth?.(), await mq.getDepth());
588
+ });
428
589
  const messages = [];
429
590
  const controller = new AbortController();
430
591
  const listening = workers.listen(async (message) => {
@@ -8,10 +8,10 @@ import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z
8
8
  import { t as assertInstanceOf } from "../assert_instance_of-C4Ri6VuN.mjs";
9
9
  import { t as assertNotEquals } from "../assert_not_equals--wG9hV7u.mjs";
10
10
  import { t as assert } from "../assert-DikXweDx.mjs";
11
- import { l as verifyRequest } from "../http-Cy2mQS66.mjs";
11
+ import { l as verifyRequest } from "../http-CfToB_iu.mjs";
12
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-B6CaBwbr.mjs";
14
- import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-BjwIELCy.mjs";
13
+ import { t as doesActorOwnKey } from "../owner-CuW0S2XY.mjs";
14
+ import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-dhl-s8G0.mjs";
15
15
  import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
16
16
  import { Activity, Application, Endpoints, Group, Person, Service } from "@fedify/vocab";
17
17
  //#region src/federation/send.test.ts
@@ -5,7 +5,7 @@ import { r as createRequestContext } from "../context-Dk_tacqz.mjs";
5
5
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
6
  import "../std__assert-CRDpx_HF.mjs";
7
7
  import { t as MemoryKvStore } from "../kv-rV3vodCc.mjs";
8
- import { o as createFederation, s as handleWebFinger } from "../middleware-BjvwtKjp.mjs";
8
+ import { o as createFederation, s as handleWebFinger } from "../middleware-BPZEcrMG.mjs";
9
9
  import { test } from "@fedify/fixture";
10
10
  import { Image, Link, Person, Tombstone } from "@fedify/vocab";
11
11
  //#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.3.0-dev.1005+16f9539d";
13
+ var version = "2.3.0-dev.1021+ab2fa4a9";
14
14
  //#endregion
15
15
  //#region src/sig/accept.ts
16
16
  /**
@@ -1,9 +1,9 @@
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-4f2FzBe9.mjs";
4
+ import { n as version, t as name } from "./deno-BnQyJ03o.mjs";
5
5
  import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature } from "./accept-CPkZzmGN.mjs";
6
- import { o as validateCryptoKey, r as fetchKeyDetailed } from "./key-eKxvr-C4.mjs";
6
+ import { o as validateCryptoKey, r as fetchKeyDetailed } from "./key-CeANlo1H.mjs";
7
7
  import { CryptographicKey } from "@fedify/vocab";
8
8
  import { SpanStatusCode, trace } from "@opentelemetry/api";
9
9
  import { FetchError } from "@fedify/vocab-runtime";
@@ -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.3.0-dev.1005+16f9539d";
14
+ var version = "2.3.0-dev.1021+ab2fa4a9";
15
15
  //#endregion
16
16
  //#region src/sig/accept.ts
17
17
  /**
@@ -1,7 +1,7 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-4f2FzBe9.mjs";
4
+ import { n as version, t as name } from "./deno-BnQyJ03o.mjs";
5
5
  import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
6
6
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
7
7
  import { FetchError, getDocumentLoader } from "@fedify/vocab-runtime";
@@ -1,6 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { d as validateCryptoKey, t as doubleKnock } from "./http-CcfcE8N4.js";
3
+ import { d as validateCryptoKey, t as doubleKnock } from "./http-BJ-t29n_.js";
4
4
  import { getLogger } from "@logtape/logtape";
5
5
  import { curry } from "es-toolkit";
6
6
  import { UrlError, createActivityPubRequest, getRemoteDocument, logRequest, preloadedContexts, validatePublicUrl } from "@fedify/vocab-runtime";
@@ -1,7 +1,7 @@
1
1
  const { Temporal } = require("@js-temporal/polyfill");
2
2
  const { URLPattern } = require("urlpattern-polyfill");
3
3
  require("./chunk-DDcVe30Y.cjs");
4
- const require_http = require("./http-JLLWZX_d.cjs");
4
+ const require_http = require("./http-D4xMqSqO.cjs");
5
5
  let _logtape_logtape = require("@logtape/logtape");
6
6
  let es_toolkit = require("es-toolkit");
7
7
  let _fedify_vocab_runtime = require("@fedify/vocab-runtime");
@@ -1,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-4f2FzBe9.mjs";
5
- import { n as fetchKey, o as validateCryptoKey } from "./key-eKxvr-C4.mjs";
4
+ import { n as version, t as name } from "./deno-BnQyJ03o.mjs";
5
+ import { n as fetchKey, o as validateCryptoKey } from "./key-CeANlo1H.mjs";
6
6
  import { Activity, CryptographicKey, Object as Object$1, getTypeId } from "@fedify/vocab";
7
7
  import { SpanStatusCode, trace } from "@opentelemetry/api";
8
8
  import { getDocumentLoader } from "@fedify/vocab-runtime";
@@ -1,4 +1,4 @@
1
1
  const { Temporal } = require("@js-temporal/polyfill");
2
2
  const { URLPattern } = require("urlpattern-polyfill");
3
- const require_middleware = require("./middleware-y5r1KhBz.cjs");
3
+ const require_middleware = require("./middleware-I5XEZ_pZ.cjs");
4
4
  exports.FederationImpl = require_middleware.FederationImpl;
@@ -2,24 +2,24 @@ import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { n as RouterError } from "./router-CrMLXoOr.mjs";
5
- import { n as version, t as name } from "./deno-4f2FzBe9.mjs";
5
+ import { n as version, t as name } from "./deno-BnQyJ03o.mjs";
6
6
  import { t as formatAcceptSignature } from "./accept-CPkZzmGN.mjs";
7
- import { a as importJwk, o as validateCryptoKey, t as exportJwk } from "./key-eKxvr-C4.mjs";
8
- import { l as verifyRequest, o as parseRfc9421SignatureInput, u as verifyRequestDetailed } from "./http-Cy2mQS66.mjs";
9
- import { t as getAuthenticatedDocumentLoader } from "./docloader-B3ZVRe6e.mjs";
7
+ import { a as importJwk, o as validateCryptoKey, t as exportJwk } from "./key-CeANlo1H.mjs";
8
+ import { l as verifyRequest, o as parseRfc9421SignatureInput, u as verifyRequestDetailed } from "./http-CfToB_iu.mjs";
9
+ import { t as getAuthenticatedDocumentLoader } from "./docloader-mEJ3hsMB.mjs";
10
10
  import { n as kvCache } from "./kv-cache-U__xU4qR.mjs";
11
- import { a as signJsonLd, i as hasSignatureLike, o as verifyJsonLd, r as detachSignature } from "./ld-D2sVtqAV.mjs";
12
- import { n as getKeyOwner, t as doesActorOwnKey } from "./owner-B6CaBwbr.mjs";
11
+ import { a as signJsonLd, i as hasSignatureLike, o as verifyJsonLd, r as detachSignature } from "./ld-CUlVC-TS.mjs";
12
+ import { n as getKeyOwner, t as doesActorOwnKey } from "./owner-CuW0S2XY.mjs";
13
13
  import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-CNmZLixq.mjs";
14
- import { i as verifyObject, n as hasProofLike, r as signObject } from "./proof-DV85kS2-.mjs";
14
+ import { i as verifyObject, n as hasProofLike, r as signObject } from "./proof-CFPGr1xC.mjs";
15
15
  import { t as getNodeInfo } from "./client-D_1QpnWt.mjs";
16
16
  import { t as nodeInfoToJson } from "./types-J53Kw7so.mjs";
17
- import { t as FederationBuilderImpl } from "./builder-gAB0htof.mjs";
17
+ import { n as FederationBuilderImpl, t as ACTOR_ALIAS_PREFIX } from "./builder-Nn2r1dKd.mjs";
18
18
  import { t as buildCollectionSynchronizationHeader } from "./collection-D-HqUuA2.mjs";
19
19
  import { t as KvKeyCache } from "./keycache-EGATflN-.mjs";
20
20
  import { t as acceptsJsonLd } from "./negotiation-SQvQgUqe.mjs";
21
21
  import { t as createExponentialBackoffPolicy } from "./retry-bMXBL97A.mjs";
22
- import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "./send-BjwIELCy.mjs";
22
+ import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "./send-dhl-s8G0.mjs";
23
23
  import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, Tombstone, getTypeId, lookupObject, traverseCollection } from "@fedify/vocab";
24
24
  import { lookupWebFinger } from "@fedify/webfinger";
25
25
  import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
@@ -2479,15 +2479,18 @@ var FederationImpl = class extends FederationBuilderImpl {
2479
2479
  if (request.method !== "POST" && !acceptsJsonLd(request)) return await onNotAcceptable(request);
2480
2480
  switch (routeName) {
2481
2481
  case "actor":
2482
- context = this.#createContext(request, contextData, { invokedFromActorDispatcher: { identifier: route.values.identifier } });
2482
+ case "actorAlias": {
2483
+ const identifier = route.name.startsWith("actorAlias:") ? route.name.substring(ACTOR_ALIAS_PREFIX.length) : route.values.identifier;
2484
+ context = this.#createContext(request, contextData, { invokedFromActorDispatcher: { identifier } });
2483
2485
  return await handleActor(request, {
2484
- identifier: route.values.identifier,
2486
+ identifier,
2485
2487
  context,
2486
2488
  actorDispatcher: this.actorCallbacks?.dispatcher,
2487
2489
  authorizePredicate: this.actorCallbacks?.authorizePredicate,
2488
2490
  onUnauthorized,
2489
2491
  onNotFound
2490
2492
  });
2493
+ }
2491
2494
  case "object": {
2492
2495
  const typeId = route.name.replace(/^object:/, "");
2493
2496
  const callbacks = this.objectCallbacks[typeId];
@@ -2736,7 +2739,7 @@ var ContextImpl = class ContextImpl {
2736
2739
  return new URL(path, this.canonicalOrigin);
2737
2740
  }
2738
2741
  getActorUri(identifier) {
2739
- const path = this.federation.router.build("actor", { identifier });
2742
+ const path = this.federation.router.build(`actorAlias:${identifier}`, {}) ?? this.federation.router.build("actor", { identifier });
2740
2743
  if (path == null) throw new RouterError("No actor dispatcher registered.");
2741
2744
  return new URL(path, this.canonicalOrigin);
2742
2745
  }
@@ -2802,8 +2805,8 @@ var ContextImpl = class ContextImpl {
2802
2805
  type: "inbox",
2803
2806
  identifier: void 0
2804
2807
  };
2805
- const identifier = route.values.identifier;
2806
- if (route.name === "actor") return {
2808
+ const identifier = route.name.startsWith("actorAlias:") ? route.name.substring(ACTOR_ALIAS_PREFIX.length) : route.values.identifier;
2809
+ if (route.name === "actor" || route.name.startsWith("actorAlias:")) return {
2807
2810
  type: "actor",
2808
2811
  identifier
2809
2812
  };
@@ -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-BjvwtKjp.mjs";
4
+ import { n as FederationImpl } from "./middleware-BPZEcrMG.mjs";
5
5
  export { FederationImpl };
@@ -2,10 +2,10 @@ import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  import { t as __exportAll } from "./chunk-nlSIicah.js";
4
4
  import { r as getDefaultActivityTransformers } from "./transformers-ve6e2xcg.js";
5
- import { _ as version, a as verifyRequestDetailed, d as validateCryptoKey, f as formatAcceptSignature, g as name, i as verifyRequest, n as parseRfc9421SignatureInput, o as exportJwk, t as doubleKnock, u as importJwk } from "./http-CcfcE8N4.js";
6
- import { c as getKeyOwner, d as detachSignature, f as hasSignatureLike, i as verifyObject, m as verifyJsonLd, n as hasProofLike, o as normalizeOutgoingActivityJsonLd, p as signJsonLd, r as signObject, s as doesActorOwnKey } from "./proof-DhE_ibsB.js";
5
+ import { _ as version, a as verifyRequestDetailed, d as validateCryptoKey, f as formatAcceptSignature, g as name, i as verifyRequest, n as parseRfc9421SignatureInput, o as exportJwk, t as doubleKnock, u as importJwk } from "./http-BJ-t29n_.js";
6
+ import { c as getKeyOwner, d as detachSignature, f as hasSignatureLike, i as verifyObject, m as verifyJsonLd, n as hasProofLike, o as normalizeOutgoingActivityJsonLd, p as signJsonLd, r as signObject, s as doesActorOwnKey } from "./proof-CtMmqa09.js";
7
7
  import { n as getNodeInfo, t as nodeInfoToJson } from "./types-hvL8ElAs.js";
8
- import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-YWK2pfn_.js";
8
+ import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-B142kDZL.js";
9
9
  import { getLogger, withContext } from "@logtape/logtape";
10
10
  import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, Tombstone, getTypeId, lookupObject, traverseCollection } from "@fedify/vocab";
11
11
  import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
@@ -160,6 +160,7 @@ var RouterError = class extends Error {
160
160
  };
161
161
  //#endregion
162
162
  //#region src/federation/builder.ts
163
+ const ACTOR_ALIAS_PREFIX = "actorAlias:";
163
164
  function validateSingleIdentifierVariablePath(path, errorMessage) {
164
165
  const operatorMatches = globalThis.Array.from(path.matchAll(/{([+#./;?&]?)([A-Za-z_][A-Za-z0-9_]*)}/g));
165
166
  if (operatorMatches.length !== 1 || operatorMatches[0]?.[2] !== "identifier") throw new RouterError(errorMessage);
@@ -346,6 +347,15 @@ var FederationBuilderImpl = class {
346
347
  callbacks.aliasMapper = mapper;
347
348
  return setters;
348
349
  },
350
+ mapActorAlias: (path, identifier) => {
351
+ if (identifier === "") throw new RouterError("Identifier cannot be empty.");
352
+ if (this.router.has(`actorAlias:${identifier}`)) throw new RouterError(`Actor alias for "${identifier}" already set.`);
353
+ if (new Router$1().add(path, "temp").size > 0) throw new RouterError("Path for actor alias must have no variables.");
354
+ const existingRoute = this.router.route(path);
355
+ if (existingRoute != null) throw new RouterError(`Actor alias path "${path}" conflicts with existing route "${existingRoute.name}".`);
356
+ this.router.add(path, `${ACTOR_ALIAS_PREFIX}${identifier}`);
357
+ return setters;
358
+ },
349
359
  authorize(predicate) {
350
360
  callbacks.authorizePredicate = predicate;
351
361
  return setters;
@@ -3508,15 +3518,18 @@ var FederationImpl = class extends FederationBuilderImpl {
3508
3518
  if (request.method !== "POST" && !acceptsJsonLd(request)) return await onNotAcceptable(request);
3509
3519
  switch (routeName) {
3510
3520
  case "actor":
3511
- context = this.#createContext(request, contextData, { invokedFromActorDispatcher: { identifier: route.values.identifier } });
3521
+ case "actorAlias": {
3522
+ const identifier = route.name.startsWith("actorAlias:") ? route.name.substring(11) : route.values.identifier;
3523
+ context = this.#createContext(request, contextData, { invokedFromActorDispatcher: { identifier } });
3512
3524
  return await handleActor(request, {
3513
- identifier: route.values.identifier,
3525
+ identifier,
3514
3526
  context,
3515
3527
  actorDispatcher: this.actorCallbacks?.dispatcher,
3516
3528
  authorizePredicate: this.actorCallbacks?.authorizePredicate,
3517
3529
  onUnauthorized,
3518
3530
  onNotFound
3519
3531
  });
3532
+ }
3520
3533
  case "object": {
3521
3534
  const typeId = route.name.replace(/^object:/, "");
3522
3535
  const callbacks = this.objectCallbacks[typeId];
@@ -3765,7 +3778,7 @@ var ContextImpl = class ContextImpl {
3765
3778
  return new URL(path, this.canonicalOrigin);
3766
3779
  }
3767
3780
  getActorUri(identifier) {
3768
- const path = this.federation.router.build("actor", { identifier });
3781
+ const path = this.federation.router.build(`actorAlias:${identifier}`, {}) ?? this.federation.router.build("actor", { identifier });
3769
3782
  if (path == null) throw new RouterError("No actor dispatcher registered.");
3770
3783
  return new URL(path, this.canonicalOrigin);
3771
3784
  }
@@ -3831,8 +3844,8 @@ var ContextImpl = class ContextImpl {
3831
3844
  type: "inbox",
3832
3845
  identifier: void 0
3833
3846
  };
3834
- const identifier = route.values.identifier;
3835
- if (route.name === "actor") return {
3847
+ const identifier = route.name.startsWith("actorAlias:") ? route.name.substring(11) : route.values.identifier;
3848
+ if (route.name === "actor" || route.name.startsWith("actorAlias:")) return {
3836
3849
  type: "actor",
3837
3850
  identifier
3838
3851
  };