@fedify/fedify 1.7.13 → 1.7.15

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 (138) hide show
  1. package/dist/{actor-CPpvuBKU.d.ts → actor.d.ts} +3 -3
  2. package/dist/{actor-BVilnhZ3.js → actor.js} +6 -6
  3. package/dist/{assert-LOEeCUK5.js → assert.js} +2 -2
  4. package/dist/{assert_equals-B44MxcIj.js → assert_equals.js} +16 -16
  5. package/dist/{assert_instance_of-XtuFevV_.js → assert_instance_of.js} +2 -2
  6. package/dist/{assert_is_error-BTlryvT0.js → assert_is_error.js} +2 -2
  7. package/dist/{assert_not_equals-C685gKx6.js → assert_not_equals.js} +3 -6
  8. package/dist/{assert_rejects-DWQ4jaf9.js → assert_rejects.js} +3 -3
  9. package/dist/{assert_throws-YetpVSc-.js → assert_throws.js} +3 -3
  10. package/dist/{authdocloader-DqCINL6u.js → authdocloader.js} +8 -8
  11. package/dist/{builder-CKUAOfcL.js → builder.js} +7 -7
  12. package/dist/{chunk-Cx8LTkjm.js → chunk.js} +22 -15
  13. package/dist/{client-DvtwXO7t.d.ts → client.d.ts} +2 -2
  14. package/dist/{client-C5xUY491.js → client.js} +3 -3
  15. package/dist/{collection-Dfb0TPno.js → collection.js} +2 -3
  16. package/dist/compat/mod.d.ts +79 -12
  17. package/dist/compat/mod.js +1 -2
  18. package/dist/compat/transformers.test.js +34 -38
  19. package/dist/{context-OBWjptjU.d.ts → context.d.ts} +11 -11
  20. package/dist/{context-aglzx1Ww.js → context.js} +5 -5
  21. package/dist/{docloader-Q42SMRIB.d.ts → docloader.d.ts} +2 -2
  22. package/dist/{docloader-Qfs9nPiy.js → docloader.js} +32 -152
  23. package/dist/{docloader-09nVWLAZ.js → docloader2.js} +1 -1
  24. package/dist/{esm-DO9PrujO.js → esm.js} +36 -22
  25. package/dist/federation/builder.test.js +20 -26
  26. package/dist/federation/collection.test.js +11 -16
  27. package/dist/federation/handler.test.js +41 -48
  28. package/dist/federation/inbox.test.js +11 -11
  29. package/dist/federation/keycache.test.js +12 -11
  30. package/dist/federation/kv.test.js +8 -10
  31. package/dist/federation/middleware.test.js +105 -134
  32. package/dist/federation/mod.d.ts +4 -13
  33. package/dist/federation/mod.js +206 -12
  34. package/dist/federation/mq.test.js +12 -17
  35. package/dist/federation/retry.test.js +5 -4
  36. package/dist/federation/router.test.js +9 -10
  37. package/dist/federation/send.test.js +23 -24
  38. package/dist/{http-DMTrO3Ye.d.ts → http.d.ts} +3 -3
  39. package/dist/{http-CjDwMreH.js → http.js} +25 -31
  40. package/dist/{inbox-ApPO50Ma.js → inbox.js} +5 -5
  41. package/dist/key.js +16 -0
  42. package/dist/{key-BPUM0v_S.js → key2.js} +5 -5
  43. package/dist/{keycache-B7Urghlu.js → keycache.js} +2 -2
  44. package/dist/{keys-DGJec4-R.js → keys.js} +2 -2
  45. package/dist/{kv-DRaeSXco.d.ts → kv.d.ts} +1 -1
  46. package/dist/{kv-BMY6Qf_A.js → kv.js} +1 -1
  47. package/dist/{langstr-DbWheeIS.js → langstr.js} +1 -1
  48. package/dist/{ld-DJTavNY3.js → ld.js} +9 -12
  49. package/dist/{lookup-Bf-K85bV.d.ts → lookup.d.ts} +2 -2
  50. package/dist/{lookup-CkOdKyYR.js → lookup.js} +4 -4
  51. package/dist/{lookup-CnkkF4Rf.js → lookup2.js} +6 -6
  52. package/dist/{middleware-BxHcZC4p.js → middleware.js} +35 -39
  53. package/dist/middleware2.js +32 -0
  54. package/dist/mod.d.ts +17 -17
  55. package/dist/mod.js +17 -17
  56. package/dist/{mod-CDzlVCUF.d.ts → mod2.d.ts} +3 -3
  57. package/dist/{mod-CCL2cvnI.d.ts → mod3.d.ts} +4 -4
  58. package/dist/{mq-DYKDDJmp.d.ts → mq.d.ts} +1 -1
  59. package/dist/{multibase-CnLHszip.js → multibase.js} +1 -1
  60. package/dist/nodeinfo/client.test.js +19 -28
  61. package/dist/nodeinfo/handler.test.js +37 -44
  62. package/dist/nodeinfo/mod.d.ts +2 -5
  63. package/dist/nodeinfo/mod.js +2 -3
  64. package/dist/nodeinfo/semver.test.js +13 -21
  65. package/dist/nodeinfo/types.test.js +9 -11
  66. package/dist/{owner-D0cOz8R5.d.ts → owner.d.ts} +4 -4
  67. package/dist/{owner-qKULzrkx.js → owner.js} +4 -4
  68. package/dist/{proof-d5P09-xk.js → proof.js} +11 -13
  69. package/dist/{retry-BiIhZWgD.js → retry.js} +1 -1
  70. package/dist/{router-D_aVZZUc.js → router.js} +1 -1
  71. package/dist/runtime/authdocloader.test.js +22 -26
  72. package/dist/runtime/docloader.test.js +56 -56
  73. package/dist/runtime/key.test.js +31 -53
  74. package/dist/runtime/langstr.test.js +8 -10
  75. package/dist/runtime/mod.d.ts +103 -6
  76. package/dist/runtime/mod.js +6 -7
  77. package/dist/runtime/multibase/multibase.test.js +12 -18
  78. package/dist/runtime/url.test.js +7 -6
  79. package/dist/{semver-BNrOOAs9.js → semver.js} +7 -17
  80. package/dist/{send-BnMY3Qxa.js → send.js} +4 -4
  81. package/dist/sig/http.test.js +104 -168
  82. package/dist/sig/key.test.js +17 -20
  83. package/dist/sig/ld.test.js +28 -35
  84. package/dist/sig/mod.d.ts +3 -7
  85. package/dist/sig/mod.js +6 -7
  86. package/dist/sig/owner.test.js +24 -30
  87. package/dist/sig/proof.test.js +24 -29
  88. package/dist/{std__assert-o_r9vqm1.js → std__assert.js} +7 -13
  89. package/dist/testing/docloader.test.js +9 -12
  90. package/dist/testing/mod.js +2 -1
  91. package/dist/{testing-DLyvtiiW.js → testing.js} +2 -2
  92. package/dist/{transformers-ghwJuzGY.js → transformers.js} +1 -1
  93. package/dist/{type-CFuiGLz9.js → type.js} +1 -1
  94. package/dist/{types-CJHS5pXl.js → types.js} +2 -2
  95. package/dist/{url-C2xuoQD1.js → url.js} +1 -1
  96. package/dist/vocab/actor.test.js +76 -128
  97. package/dist/vocab/lookup.test.js +19 -23
  98. package/dist/vocab/mod.d.ts +3 -5
  99. package/dist/vocab/mod.js +4 -4
  100. package/dist/vocab/type.test.js +10 -10
  101. package/dist/vocab/vocab.test.js +90 -109
  102. package/dist/{vocab-CzEfWQk2.d.ts → vocab.d.ts} +2 -2
  103. package/dist/{vocab-S7fEn6XO.js → vocab.js} +318 -454
  104. package/dist/webfinger/handler.test.js +40 -48
  105. package/dist/webfinger/lookup.test.js +12 -15
  106. package/dist/webfinger/mod.d.ts +1 -4
  107. package/dist/webfinger/mod.js +2 -3
  108. package/dist/x/cfworkers.d.ts +2 -2
  109. package/dist/x/cfworkers.test.js +7 -9
  110. package/dist/x/hono.d.ts +2 -11
  111. package/dist/x/sveltekit.d.ts +2 -11
  112. package/package.json +1 -1
  113. package/dist/actor-CsmPeeHG.js +0 -34925
  114. package/dist/authdocloader-9g6RkEcR.js +0 -53
  115. package/dist/compat-Bb5myD13.js +0 -4
  116. package/dist/docloader-CchlnLWb.js +0 -4598
  117. package/dist/federation-B0aljx0V.js +0 -203
  118. package/dist/http-CP3h1SLi.js +0 -796
  119. package/dist/key--l6NVKdl.js +0 -257
  120. package/dist/key-1Fv7reaM.js +0 -16
  121. package/dist/key-DD37RpoD.js +0 -10
  122. package/dist/lookup-CN-LpF5e.js +0 -127
  123. package/dist/middleware-BQHe0X6Y.js +0 -17
  124. package/dist/middleware-C3TZ3P-v.js +0 -33
  125. package/dist/middleware-CEpilAEY.js +0 -3524
  126. package/dist/mod-1pDWKvUL.d.ts +0 -2
  127. package/dist/mod-DFncUgcE.d.ts +0 -82
  128. package/dist/mod-GIh5OYxW.d.ts +0 -2
  129. package/dist/mod-g0xFzAP9.d.ts +0 -2
  130. package/dist/mod-qFMzZ3iF.d.ts +0 -104
  131. package/dist/nodeinfo-CyEbLjHs.js +0 -4
  132. package/dist/proof-BfeWBNrY.js +0 -582
  133. package/dist/runtime-BSkOVUWM.js +0 -4
  134. package/dist/sig-BXJO--F9.js +0 -4
  135. package/dist/types-BZUzjGS0.js +0 -455
  136. package/dist/vocab-C_pE4SvE.js +0 -168
  137. package/dist/webfinger-C3GIyXIg.js +0 -4
  138. /package/dist/{denokv-CvROlGYX.js → denokv.js} +0 -0
@@ -1,203 +0,0 @@
1
-
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
-
5
- //#region federation/kv.ts
6
- /**
7
- * A key–value store that stores values in memory.
8
- * Do not use this in production as it does not persist values.
9
- *
10
- * @since 0.5.0
11
- */
12
- var MemoryKvStore = class {
13
- #values = {};
14
- #encodeKey(key) {
15
- return JSON.stringify(key);
16
- }
17
- /**
18
- * {@inheritDoc KvStore.get}
19
- */
20
- get(key) {
21
- const encodedKey = this.#encodeKey(key);
22
- const entry = this.#values[encodedKey];
23
- if (entry == null) return Promise.resolve(void 0);
24
- const [value, expiration] = entry;
25
- if (expiration != null && Temporal.Now.instant().until(expiration).sign < 0) {
26
- delete this.#values[encodedKey];
27
- return Promise.resolve(void 0);
28
- }
29
- return Promise.resolve(value);
30
- }
31
- /**
32
- * {@inheritDoc KvStore.set}
33
- */
34
- set(key, value, options) {
35
- const encodedKey = this.#encodeKey(key);
36
- const expiration = options?.ttl == null ? null : Temporal.Now.instant().add(options.ttl.round({ largestUnit: "hour" }));
37
- this.#values[encodedKey] = [value, expiration];
38
- return Promise.resolve();
39
- }
40
- /**
41
- * {@inheritDoc KvStore.delete}
42
- */
43
- delete(key) {
44
- const encodedKey = this.#encodeKey(key);
45
- delete this.#values[encodedKey];
46
- return Promise.resolve();
47
- }
48
- };
49
-
50
- //#endregion
51
- //#region federation/mq.ts
52
- /**
53
- * A message queue that processes messages in the same process.
54
- * Do not use this in production as it does neither persist messages nor
55
- * distribute them across multiple processes.
56
- *
57
- * @since 0.5.0
58
- */
59
- var InProcessMessageQueue = class {
60
- #messages;
61
- #monitors;
62
- #pollIntervalMs;
63
- /**
64
- * In-process message queue does not provide native retry mechanisms.
65
- * @since 1.7.0
66
- */
67
- nativeRetrial = false;
68
- /**
69
- * Constructs a new {@link InProcessMessageQueue} with the given options.
70
- * @param options Additional options for the in-process message queue.
71
- */
72
- constructor(options = {}) {
73
- this.#messages = [];
74
- this.#monitors = {};
75
- this.#pollIntervalMs = Temporal.Duration.from(options.pollInterval ?? { seconds: 5 }).total("millisecond");
76
- }
77
- enqueue(message, options) {
78
- const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
79
- if (delay > 0) {
80
- setTimeout(() => this.enqueue(message, {
81
- ...options,
82
- delay: void 0
83
- }), delay);
84
- return Promise.resolve();
85
- }
86
- this.#messages.push(message);
87
- for (const monitorId in this.#monitors) this.#monitors[monitorId]();
88
- return Promise.resolve();
89
- }
90
- enqueueMany(messages, options) {
91
- if (messages.length === 0) return Promise.resolve();
92
- const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
93
- if (delay > 0) {
94
- setTimeout(() => this.enqueueMany(messages, {
95
- ...options,
96
- delay: void 0
97
- }), delay);
98
- return Promise.resolve();
99
- }
100
- this.#messages.push(...messages);
101
- for (const monitorId in this.#monitors) this.#monitors[monitorId]();
102
- return Promise.resolve();
103
- }
104
- async listen(handler, options = {}) {
105
- const signal = options.signal;
106
- while (signal == null || !signal.aborted) {
107
- while (this.#messages.length > 0) {
108
- const message = this.#messages.shift();
109
- await handler(message);
110
- }
111
- await this.#wait(this.#pollIntervalMs, signal);
112
- }
113
- }
114
- #wait(ms, signal) {
115
- let timer = null;
116
- return Promise.any([new Promise((resolve) => {
117
- signal?.addEventListener("abort", () => {
118
- if (timer != null) clearTimeout(timer);
119
- resolve();
120
- }, { once: true });
121
- const monitorId = crypto.randomUUID();
122
- this.#monitors[monitorId] = () => {
123
- delete this.#monitors[monitorId];
124
- if (timer != null) clearTimeout(timer);
125
- resolve();
126
- };
127
- }), new Promise((resolve) => timer = setTimeout(resolve, ms))]);
128
- }
129
- };
130
- /**
131
- * A message queue that processes messages in parallel. It takes another
132
- * {@link MessageQueue}, and processes messages in parallel up to a certain
133
- * number of workers.
134
- *
135
- * Actually, it's rather a decorator than a queue itself.
136
- *
137
- * Note that the workers do not run in truly parallel, in the sense that they
138
- * are not running in separate threads or processes. They are running in the
139
- * same process, but are scheduled to run in parallel. Hence, this is useful
140
- * for I/O-bound tasks, but not for CPU-bound tasks, which is okay for Fedify's
141
- * workloads.
142
- *
143
- * @since 1.0.0
144
- */
145
- var ParallelMessageQueue = class ParallelMessageQueue {
146
- queue;
147
- workers;
148
- /**
149
- * Inherits the native retry capability from the wrapped queue.
150
- * @since 1.7.0
151
- */
152
- nativeRetrial;
153
- /**
154
- * Constructs a new {@link ParallelMessageQueue} with the given queue and
155
- * number of workers.
156
- * @param queue The message queue to use under the hood. Note that
157
- * {@link ParallelMessageQueue} cannot be nested.
158
- * @param workers The number of workers to process messages in parallel.
159
- * @throws {TypeError} If the given queue is an instance of
160
- * {@link ParallelMessageQueue}.
161
- */
162
- constructor(queue, workers) {
163
- if (queue instanceof ParallelMessageQueue) throw new TypeError("Cannot nest ParallelMessageQueue.");
164
- this.queue = queue;
165
- this.workers = workers;
166
- this.nativeRetrial = queue.nativeRetrial;
167
- }
168
- enqueue(message, options) {
169
- return this.queue.enqueue(message, options);
170
- }
171
- async enqueueMany(messages, options) {
172
- if (this.queue.enqueueMany == null) {
173
- const errors = (await Promise.allSettled(messages.map((message) => this.queue.enqueue(message, options)))).filter((r) => r.status === "rejected").map((r) => r.reason);
174
- if (errors.length > 1) throw new AggregateError(errors, "Failed to enqueue messages.");
175
- else if (errors.length === 1) throw errors[0];
176
- return;
177
- }
178
- await this.queue.enqueueMany(messages, options);
179
- }
180
- listen(handler, options = {}) {
181
- const workers = /* @__PURE__ */ new Map();
182
- return this.queue.listen(async (message) => {
183
- while (workers.size >= this.workers) {
184
- const consumedId = await Promise.any(workers.values());
185
- workers.delete(consumedId);
186
- }
187
- const workerId = crypto.randomUUID();
188
- const promise = this.#work(workerId, handler, message);
189
- workers.set(workerId, promise);
190
- }, options);
191
- }
192
- async #work(workerId, handler, message) {
193
- await this.#sleep(0);
194
- await handler(message);
195
- return workerId;
196
- }
197
- #sleep(ms) {
198
- return new Promise((resolve) => setTimeout(resolve, ms));
199
- }
200
- };
201
-
202
- //#endregion
203
- export { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue };