@fedify/fedify 2.2.0-dev.610 → 2.2.0-dev.622
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.
- package/README.md +2 -5
- package/dist/{accept-D7sAxyNa.js → accept-Dd__NiUL.mjs} +10 -8
- package/dist/{assert-MZs1qjMx.js → assert-ddO5KLpe.mjs} +5 -9
- package/dist/{assert_equals-DSbWqCm3.js → assert_equals-Ew3jOFa3.mjs} +55 -69
- package/dist/{assert_instance_of-DHz7EHNU.js → assert_instance_of-C4Ri6VuN.mjs} +5 -9
- package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals--wG9hV7u.mjs} +6 -13
- package/dist/{assert_rejects-0h7I2Esa.js → assert_rejects-B-qJtC9Z.mjs} +6 -11
- package/dist/{assert_throws-rjdMBf31.js → assert_throws-4NwKEy2q.mjs} +5 -10
- package/dist/{builder-Bkqx5fo0.js → builder-DcSpny3g.mjs} +32 -41
- package/dist/{chunk-CGaQZ11T.cjs → chunk-DDcVe30Y.cjs} +23 -24
- package/dist/{chunk-DJNbSFdH.js → chunk-nlSIicah.js} +8 -8
- package/dist/{client-BxMZiQaD.d.ts → client-AtlibPOU.d.ts} +1 -1
- package/dist/{client-CoCIaTNO.js → client-DEpOVgY1.mjs} +9 -13
- package/dist/{client-C97KOq3x.d.cts → client-z-8dc-e1.d.cts} +1 -1
- package/dist/{collection-CSzG2j1P.js → collection-BD6-SZ6O.mjs} +7 -12
- package/dist/compat/mod.cjs +5 -8
- package/dist/compat/mod.d.cts +78 -6
- package/dist/compat/mod.d.ts +78 -6
- package/dist/compat/mod.js +4 -8
- package/dist/compat/transformers.test.mjs +62 -0
- package/dist/{context-DyJjQQ_H.d.ts → context-BOiMZBu5.d.ts} +9 -18
- package/dist/{context-BcqA-0BL.d.cts → context-BhZVy7RB.d.cts} +9 -18
- package/dist/{context-Aqenou7c.js → context-Juj6bdHC.mjs} +7 -11
- package/dist/deno-D682wzlW.mjs +8 -0
- package/dist/{docloader-ORTT1bPi.js → docloader-CCWf4tNV.mjs} +8 -14
- package/dist/{esm-nLm00z9V.js → esm-DVILvP5e.mjs} +50 -89
- package/dist/federation/builder.test.d.mts +2 -0
- package/dist/federation/{builder.test.js → builder.test.mjs} +21 -44
- package/dist/federation/collection.test.d.mts +2 -0
- package/dist/federation/collection.test.mjs +21 -0
- package/dist/federation/handler.test.d.mts +2 -0
- package/dist/federation/{handler.test.js → handler.test.mjs} +69 -131
- package/dist/federation/idempotency.test.d.mts +2 -0
- package/dist/federation/{idempotency.test.js → idempotency.test.mjs} +31 -63
- package/dist/federation/inbox.test.d.mts +2 -0
- package/dist/federation/{inbox.test.js → inbox.test.mjs} +8 -12
- package/dist/federation/keycache.test.d.mts +2 -0
- package/dist/federation/{keycache.test.js → keycache.test.mjs} +13 -19
- package/dist/federation/kv.test.d.mts +2 -0
- package/dist/federation/{kv.test.js → kv.test.mjs} +11 -22
- package/dist/federation/middleware.test.d.mts +2 -0
- package/dist/federation/{middleware.test.js → middleware.test.mjs} +173 -262
- package/dist/federation/mod.cjs +327 -16
- package/dist/federation/mod.d.cts +3 -6
- package/dist/federation/mod.d.ts +3 -6
- package/dist/federation/mod.js +322 -13
- package/dist/federation/mq.test.d.mts +2 -0
- package/dist/federation/{mq.test.js → mq.test.mjs} +21 -35
- package/dist/federation/negotiation.test.d.mts +2 -0
- package/dist/federation/{negotiation.test.js → negotiation.test.mjs} +9 -16
- package/dist/federation/retry.test.d.mts +2 -0
- package/dist/federation/{retry.test.js → retry.test.mjs} +8 -11
- package/dist/federation/router.test.d.mts +2 -0
- package/dist/federation/{router.test.js → router.test.mjs} +11 -16
- package/dist/federation/send.test.d.mts +2 -0
- package/dist/federation/{send.test.js → send.test.mjs} +22 -30
- package/dist/federation/webfinger.test.d.mts +2 -0
- package/dist/federation/{webfinger.test.js → webfinger.test.mjs} +22 -56
- package/dist/{http-BDf1pBmE.cjs → http-BQccxQlj.cjs} +177 -302
- package/dist/{http-By9CCocC.js → http-CNsnyqrO.mjs} +23 -43
- package/dist/{http-BudnHZE2.d.cts → http-CrGuipxe.d.cts} +1 -6
- package/dist/{http-DLQMXj_1.js → http-DhwEMhtv.js} +53 -184
- package/dist/{http-Dax_FIBo.d.ts → http-aQzN9Ayi.d.ts} +1 -6
- package/dist/{inbox-CTJeEur6.js → inbox-DegXbbbS.mjs} +18 -26
- package/dist/{key-OaS_196P.js → key-vL60OvqM.mjs} +29 -37
- package/dist/{keycache-CpGWAUbj.js → keycache-CCSwkQcY.mjs} +5 -10
- package/dist/{keys-BFve7QQv.js → keys-BAK-tUlf.mjs} +5 -9
- package/dist/{kv-BL4nlICN.d.cts → kv-CbLNp3zQ.d.cts} +1 -1
- package/dist/{kv-DXEUEP6z.d.ts → kv-GFYnFoOl.d.ts} +1 -1
- package/dist/{kv-cache-Bw2F2ABq.js → kv-cache-B01V7s3h.mjs} +4 -8
- package/dist/{kv-cache-COnBmjEC.js → kv-cache-CTj3iCix.js} +6 -13
- package/dist/{kv-cache-DG491NbS.cjs → kv-cache-DxdXJNbj.cjs} +27 -34
- package/dist/{kv-QzKcOQgP.js → kv-tL2TOE9X.mjs} +6 -10
- package/dist/{ld-5udwE1JY.js → ld-C3CO00YY.mjs} +17 -31
- package/dist/{middleware-3FSu2a2W.js → middleware-BmsVSOeS.js} +335 -382
- package/dist/middleware-C7shNcsp.cjs +4 -0
- package/dist/{middleware-CFuio6Y_.cjs → middleware-Cx0Ny6_7.cjs} +532 -587
- package/dist/middleware-DqVGYk56.mjs +5 -0
- package/dist/{middleware-DRWIaDqh.js → middleware-Du-vh7I_.mjs} +282 -317
- package/dist/{mod-em2Il1eD.d.cts → mod-Bp_CzKd4.d.cts} +2 -2
- package/dist/{mod-DCbh1JQ5.d.ts → mod-CLgIXe9w.d.ts} +3 -3
- package/dist/{mod-jfnweK2w.d.cts → mod-CMEbIaNh.d.cts} +3 -3
- package/dist/{mod-D6MdymW7.d.ts → mod-DKOAow7a.d.ts} +2 -2
- package/dist/{mod-Coe7KEgX.d.cts → mod-DoJBjjnO.d.cts} +2 -2
- package/dist/{mod-D6dOd--H.d.ts → mod-DvxszxXC.d.ts} +2 -2
- package/dist/mod.cjs +29 -74
- package/dist/mod.d.cts +11 -14
- package/dist/mod.d.ts +11 -15
- package/dist/mod.js +17 -71
- package/dist/{negotiation-BlAuS_nr.js → negotiation-DnsfFF8I.mjs} +7 -11
- package/dist/nodeinfo/client.test.d.mts +2 -0
- package/dist/nodeinfo/{client.test.js → client.test.mjs} +22 -40
- package/dist/nodeinfo/handler.test.d.mts +2 -0
- package/dist/nodeinfo/{handler.test.js → handler.test.mjs} +13 -43
- package/dist/nodeinfo/mod.cjs +5 -8
- package/dist/nodeinfo/mod.d.cts +2 -3
- package/dist/nodeinfo/mod.d.ts +2 -3
- package/dist/nodeinfo/mod.js +4 -8
- package/dist/nodeinfo/types.test.d.mts +2 -0
- package/dist/nodeinfo/{types.test.js → types.test.mjs} +9 -16
- package/dist/otel/exporter.test.d.mts +2 -0
- package/dist/otel/{exporter.test.js → exporter.test.mjs} +124 -178
- package/dist/otel/mod.cjs +15 -20
- package/dist/otel/mod.d.cts +2 -2
- package/dist/otel/mod.d.ts +2 -2
- package/dist/otel/mod.js +8 -14
- package/dist/{owner-gd0Q9FuU.d.ts → owner-74ARJ5TL.d.ts} +1 -1
- package/dist/{owner-1AbPBOOZ.d.cts → owner-CptqhsOy.d.cts} +1 -1
- package/dist/{owner-DuRG_QYg.js → owner-DF320w6K.mjs} +11 -16
- package/dist/{proof-DG0_Hm4d.js → proof-BCWk5oas.js} +32 -58
- package/dist/{proof-DFffIwhK.js → proof-IyDwwmzL.mjs} +21 -33
- package/dist/{proof-WJjJMjvC.cjs → proof-WhNxSv_N.cjs} +133 -157
- package/dist/{retry-mqLf4b-R.js → retry-B_E3V_Dx.mjs} +4 -7
- package/dist/{router-D9eI0s4b.js → router-CrMLXoOr.mjs} +4 -8
- package/dist/runtime/mod.cjs +11 -13
- package/dist/runtime/mod.d.cts +6 -2
- package/dist/runtime/mod.d.ts +0 -1
- package/dist/runtime/mod.js +4 -7
- package/dist/{send-CJAMZwWu.js → send-CJQubr5t.mjs} +8 -13
- package/dist/sig/accept.test.d.mts +2 -0
- package/dist/sig/{accept.test.js → accept.test.mjs} +35 -70
- package/dist/sig/http.test.d.mts +2 -0
- package/dist/sig/{http.test.js → http.test.mjs} +166 -280
- package/dist/sig/key.test.d.mts +2 -0
- package/dist/sig/{key.test.js → key.test.mjs} +11 -18
- package/dist/sig/ld.test.d.mts +2 -0
- package/dist/sig/{ld.test.js → ld.test.mjs} +22 -35
- package/dist/sig/mod.cjs +6 -9
- package/dist/sig/mod.d.cts +3 -3
- package/dist/sig/mod.d.ts +3 -3
- package/dist/sig/mod.js +5 -9
- package/dist/sig/owner.test.d.mts +2 -0
- package/dist/sig/{owner.test.js → owner.test.mjs} +19 -34
- package/dist/sig/proof.test.d.mts +2 -0
- package/dist/sig/{proof.test.js → proof.test.mjs} +16 -27
- package/dist/{std__assert-X-_kMxKM.js → std__assert-Duiq_YC9.mjs} +12 -24
- package/dist/testing/{mod.d.ts → mod.d.mts} +26 -90
- package/dist/testing/mod.mjs +6 -0
- package/dist/{transformers-3g8GZwkZ.cjs → transformers-NeAONrAq.cjs} +20 -25
- package/dist/{transformers-C3FLHUd6.js → transformers-ve6e2xcg.js} +3 -7
- package/dist/{types-CPz01LGH.js → types-DCP0WLdt.mjs} +4 -7
- package/dist/{types-Cd_hszr_.cjs → types-KC4QAoxe.cjs} +29 -34
- package/dist/{types-C93Ob9cU.js → types-hvL8ElAs.js} +8 -13
- package/dist/utils/docloader.test.d.mts +2 -0
- package/dist/utils/{docloader.test.js → docloader.test.mjs} +14 -25
- package/dist/utils/kv-cache.test.d.mts +2 -0
- package/dist/utils/{kv-cache.test.js → kv-cache.test.mjs} +25 -40
- package/dist/utils/mod.cjs +5 -9
- package/dist/utils/mod.d.cts +1 -3
- package/dist/utils/mod.d.ts +1 -3
- package/dist/utils/mod.js +4 -9
- package/dist/vocab/cjs.test.d.mts +2 -0
- package/dist/vocab/cjs.test.mjs +14 -0
- package/dist/vocab/mod.cjs +10 -12
- package/dist/vocab/mod.js +3 -5
- package/package.json +8 -8
- package/dist/compat/transformers.test.d.ts +0 -3
- package/dist/compat/transformers.test.js +0 -88
- package/dist/compat-Bb4NuTUO.js +0 -4
- package/dist/compat-DmDDELst.cjs +0 -4
- package/dist/deno-CMcbjYDs.js +0 -121
- package/dist/federation/builder.test.d.ts +0 -3
- package/dist/federation/collection.test.d.ts +0 -3
- package/dist/federation/collection.test.js +0 -32
- package/dist/federation/handler.test.d.ts +0 -3
- package/dist/federation/idempotency.test.d.ts +0 -3
- package/dist/federation/inbox.test.d.ts +0 -3
- package/dist/federation/keycache.test.d.ts +0 -3
- package/dist/federation/kv.test.d.ts +0 -3
- package/dist/federation/middleware.test.d.ts +0 -3
- package/dist/federation/mq.test.d.ts +0 -3
- package/dist/federation/negotiation.test.d.ts +0 -3
- package/dist/federation/retry.test.d.ts +0 -3
- package/dist/federation/router.test.d.ts +0 -3
- package/dist/federation/send.test.d.ts +0 -3
- package/dist/federation/webfinger.test.d.ts +0 -3
- package/dist/federation-Bp3HI26G.cjs +0 -350
- package/dist/federation-DaMfqRm4.js +0 -332
- package/dist/middleware-BzcyJjau.js +0 -12
- package/dist/middleware-HlNnBIDX.js +0 -27
- package/dist/middleware-i-8IYJwY.cjs +0 -12
- package/dist/mod-B7QkWzrL.d.cts +0 -80
- package/dist/mod-Bh8mqlYw.d.cts +0 -9
- package/dist/mod-D6HodEq7.d.ts +0 -7
- package/dist/mod-SMHOMNpZ.d.ts +0 -82
- package/dist/mod-gq_Xfdz8.d.cts +0 -1
- package/dist/nodeinfo/client.test.d.ts +0 -3
- package/dist/nodeinfo/handler.test.d.ts +0 -3
- package/dist/nodeinfo/types.test.d.ts +0 -3
- package/dist/nodeinfo-DoESQxq5.js +0 -4
- package/dist/nodeinfo-DuMYTpbZ.cjs +0 -4
- package/dist/otel/exporter.test.d.ts +0 -3
- package/dist/runtime-c2Njxsry.cjs +0 -17
- package/dist/runtime-poamPCMb.js +0 -13
- package/dist/sig/accept.test.d.ts +0 -3
- package/dist/sig/http.test.d.ts +0 -3
- package/dist/sig/key.test.d.ts +0 -3
- package/dist/sig/ld.test.d.ts +0 -3
- package/dist/sig/owner.test.d.ts +0 -3
- package/dist/sig/proof.test.d.ts +0 -3
- package/dist/sig-BNhspNOf.js +0 -4
- package/dist/sig-vX39WyWI.cjs +0 -4
- package/dist/testing/mod.js +0 -10
- package/dist/utils/docloader.test.d.ts +0 -3
- package/dist/utils/kv-cache.test.d.ts +0 -3
- package/dist/utils-BQ9KqEK9.cjs +0 -4
- package/dist/utils-Dn5OPdSW.js +0 -4
- /package/dist/{mod-AGjRfPjT.d.ts → compat/transformers.test.d.mts} +0 -0
package/dist/federation/mod.js
CHANGED
|
@@ -1,13 +1,322 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
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-BmsVSOeS.js";
|
|
4
|
+
import { isEqual } from "es-toolkit";
|
|
5
|
+
//#region src/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
|
+
* {@inheritDoc KvStore.cas}
|
|
50
|
+
*/
|
|
51
|
+
cas(key, expectedValue, newValue, options) {
|
|
52
|
+
const encodedKey = this.#encodeKey(key);
|
|
53
|
+
const entry = this.#values[encodedKey];
|
|
54
|
+
let currentValue;
|
|
55
|
+
if (entry == null) currentValue = void 0;
|
|
56
|
+
else {
|
|
57
|
+
const [value, expiration] = entry;
|
|
58
|
+
if (expiration != null && Temporal.Now.instant().until(expiration).sign < 0) {
|
|
59
|
+
delete this.#values[encodedKey];
|
|
60
|
+
currentValue = void 0;
|
|
61
|
+
} else currentValue = value;
|
|
62
|
+
}
|
|
63
|
+
if (!isEqual(currentValue, expectedValue)) return Promise.resolve(false);
|
|
64
|
+
const expiration = options?.ttl == null ? null : Temporal.Now.instant().add(options.ttl.round({ largestUnit: "hour" }));
|
|
65
|
+
this.#values[encodedKey] = [newValue, expiration];
|
|
66
|
+
return Promise.resolve(true);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* {@inheritDoc KvStore.list}
|
|
70
|
+
*/
|
|
71
|
+
async *list(prefix) {
|
|
72
|
+
const now = Temporal.Now.instant();
|
|
73
|
+
for (const [encodedKey, entry] of Object.entries(this.#values)) {
|
|
74
|
+
const key = JSON.parse(encodedKey);
|
|
75
|
+
if (prefix != null) {
|
|
76
|
+
if (key.length < prefix.length) continue;
|
|
77
|
+
if (!prefix.every((p, i) => key[i] === p)) continue;
|
|
78
|
+
}
|
|
79
|
+
const [value, expiration] = entry;
|
|
80
|
+
if (expiration != null && now.until(expiration).sign < 0) {
|
|
81
|
+
delete this.#values[encodedKey];
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
yield {
|
|
85
|
+
key,
|
|
86
|
+
value
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/federation/mq.ts
|
|
93
|
+
/**
|
|
94
|
+
* A message queue that processes messages in the same process.
|
|
95
|
+
* Do not use this in production as it does neither persist messages nor
|
|
96
|
+
* distribute them across multiple processes.
|
|
97
|
+
*
|
|
98
|
+
* @since 0.5.0
|
|
99
|
+
*/
|
|
100
|
+
var InProcessMessageQueue = class {
|
|
101
|
+
#messages;
|
|
102
|
+
#monitors;
|
|
103
|
+
#pollIntervalMs;
|
|
104
|
+
/**
|
|
105
|
+
* Tracks which ordering keys are currently being processed to ensure
|
|
106
|
+
* sequential processing for messages with the same key.
|
|
107
|
+
*/
|
|
108
|
+
#processingKeys;
|
|
109
|
+
/**
|
|
110
|
+
* In-process message queue does not provide native retry mechanisms.
|
|
111
|
+
* @since 1.7.0
|
|
112
|
+
*/
|
|
113
|
+
nativeRetrial = false;
|
|
114
|
+
/**
|
|
115
|
+
* Constructs a new {@link InProcessMessageQueue} with the given options.
|
|
116
|
+
* @param options Additional options for the in-process message queue.
|
|
117
|
+
*/
|
|
118
|
+
constructor(options = {}) {
|
|
119
|
+
this.#messages = [];
|
|
120
|
+
this.#monitors = {};
|
|
121
|
+
this.#pollIntervalMs = Temporal.Duration.from(options.pollInterval ?? { seconds: 5 }).total("millisecond");
|
|
122
|
+
this.#processingKeys = /* @__PURE__ */ new Set();
|
|
123
|
+
}
|
|
124
|
+
enqueue(message, options) {
|
|
125
|
+
const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
|
|
126
|
+
if (delay > 0) {
|
|
127
|
+
setTimeout(() => this.enqueue(message, {
|
|
128
|
+
...options,
|
|
129
|
+
delay: void 0
|
|
130
|
+
}), delay);
|
|
131
|
+
return Promise.resolve();
|
|
132
|
+
}
|
|
133
|
+
const orderingKey = options?.orderingKey ?? null;
|
|
134
|
+
this.#messages.push({
|
|
135
|
+
message,
|
|
136
|
+
orderingKey
|
|
137
|
+
});
|
|
138
|
+
for (const monitorId in this.#monitors) this.#monitors[monitorId]();
|
|
139
|
+
return Promise.resolve();
|
|
140
|
+
}
|
|
141
|
+
enqueueMany(messages, options) {
|
|
142
|
+
if (messages.length === 0) return Promise.resolve();
|
|
143
|
+
const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
|
|
144
|
+
if (delay > 0) {
|
|
145
|
+
setTimeout(() => this.enqueueMany(messages, {
|
|
146
|
+
...options,
|
|
147
|
+
delay: void 0
|
|
148
|
+
}), delay);
|
|
149
|
+
return Promise.resolve();
|
|
150
|
+
}
|
|
151
|
+
const orderingKey = options?.orderingKey ?? null;
|
|
152
|
+
for (const message of messages) this.#messages.push({
|
|
153
|
+
message,
|
|
154
|
+
orderingKey
|
|
155
|
+
});
|
|
156
|
+
for (const monitorId in this.#monitors) this.#monitors[monitorId]();
|
|
157
|
+
return Promise.resolve();
|
|
158
|
+
}
|
|
159
|
+
async listen(handler, options = {}) {
|
|
160
|
+
const signal = options.signal;
|
|
161
|
+
while (signal == null || !signal.aborted) {
|
|
162
|
+
const idx = this.#messages.findIndex((m) => m.orderingKey == null || !this.#processingKeys.has(m.orderingKey));
|
|
163
|
+
if (idx >= 0) {
|
|
164
|
+
const { message, orderingKey } = this.#messages.splice(idx, 1)[0];
|
|
165
|
+
if (orderingKey != null) this.#processingKeys.add(orderingKey);
|
|
166
|
+
try {
|
|
167
|
+
await handler(message);
|
|
168
|
+
} finally {
|
|
169
|
+
if (orderingKey != null) this.#processingKeys.delete(orderingKey);
|
|
170
|
+
}
|
|
171
|
+
} else if (this.#messages.length === 0) await this.#wait(this.#pollIntervalMs, signal);
|
|
172
|
+
else await this.#wait(10, signal);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
#wait(ms, signal) {
|
|
176
|
+
let timer = null;
|
|
177
|
+
return Promise.any([new Promise((resolve) => {
|
|
178
|
+
signal?.addEventListener("abort", () => {
|
|
179
|
+
if (timer != null) clearTimeout(timer);
|
|
180
|
+
resolve();
|
|
181
|
+
}, { once: true });
|
|
182
|
+
const monitorId = crypto.randomUUID();
|
|
183
|
+
this.#monitors[monitorId] = () => {
|
|
184
|
+
delete this.#monitors[monitorId];
|
|
185
|
+
if (timer != null) clearTimeout(timer);
|
|
186
|
+
resolve();
|
|
187
|
+
};
|
|
188
|
+
}), new Promise((resolve) => timer = setTimeout(resolve, ms))]);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* A message queue that processes messages in parallel. It takes another
|
|
193
|
+
* {@link MessageQueue}, and processes messages in parallel up to a certain
|
|
194
|
+
* number of workers.
|
|
195
|
+
*
|
|
196
|
+
* Actually, it's rather a decorator than a queue itself.
|
|
197
|
+
*
|
|
198
|
+
* Note that the workers do not run in truly parallel, in the sense that they
|
|
199
|
+
* are not running in separate threads or processes. They are running in the
|
|
200
|
+
* same process, but are scheduled to run in parallel. Hence, this is useful
|
|
201
|
+
* for I/O-bound tasks, but not for CPU-bound tasks, which is okay for Fedify's
|
|
202
|
+
* workloads.
|
|
203
|
+
*
|
|
204
|
+
* When using `ParallelMessageQueue`, the ordering guarantee is preserved
|
|
205
|
+
* *only if* the underlying queue implementation delivers messages in a wrapper
|
|
206
|
+
* format that includes the `__fedify_ordering_key__` property. Currently,
|
|
207
|
+
* only `DenoKvMessageQueue` and `WorkersMessageQueue` use this format.
|
|
208
|
+
* For other queue implementations (e.g., `InProcessMessageQueue`,
|
|
209
|
+
* `RedisMessageQueue`, `PostgresMessageQueue`, `SqliteMessageQueue`,
|
|
210
|
+
* `AmqpMessageQueue`), the ordering key cannot be detected by
|
|
211
|
+
* `ParallelMessageQueue`, so ordering guarantees are handled by those
|
|
212
|
+
* implementations directly rather than at the `ParallelMessageQueue` level.
|
|
213
|
+
*
|
|
214
|
+
* Messages with the same ordering key will never be processed concurrently
|
|
215
|
+
* by different workers, ensuring sequential processing within each key.
|
|
216
|
+
* Messages with different ordering keys (or no ordering key) can still be
|
|
217
|
+
* processed in parallel.
|
|
218
|
+
*
|
|
219
|
+
* @since 1.0.0
|
|
220
|
+
*/
|
|
221
|
+
var ParallelMessageQueue = class ParallelMessageQueue {
|
|
222
|
+
queue;
|
|
223
|
+
workers;
|
|
224
|
+
/**
|
|
225
|
+
* Inherits the native retry capability from the wrapped queue.
|
|
226
|
+
* @since 1.7.0
|
|
227
|
+
*/
|
|
228
|
+
nativeRetrial;
|
|
229
|
+
/**
|
|
230
|
+
* Tracks which ordering keys are currently being processed to ensure
|
|
231
|
+
* sequential processing for messages with the same key.
|
|
232
|
+
*/
|
|
233
|
+
#processingKeys = /* @__PURE__ */ new Set();
|
|
234
|
+
/**
|
|
235
|
+
* Pending messages waiting for their ordering key to become available.
|
|
236
|
+
*/
|
|
237
|
+
#pendingMessages = [];
|
|
238
|
+
/**
|
|
239
|
+
* Constructs a new {@link ParallelMessageQueue} with the given queue and
|
|
240
|
+
* number of workers.
|
|
241
|
+
* @param queue The message queue to use under the hood. Note that
|
|
242
|
+
* {@link ParallelMessageQueue} cannot be nested.
|
|
243
|
+
* @param workers The number of workers to process messages in parallel.
|
|
244
|
+
* @throws {TypeError} If the given queue is an instance of
|
|
245
|
+
* {@link ParallelMessageQueue}.
|
|
246
|
+
*/
|
|
247
|
+
constructor(queue, workers) {
|
|
248
|
+
if (queue instanceof ParallelMessageQueue) throw new TypeError("Cannot nest ParallelMessageQueue.");
|
|
249
|
+
this.queue = queue;
|
|
250
|
+
this.workers = workers;
|
|
251
|
+
this.nativeRetrial = queue.nativeRetrial;
|
|
252
|
+
}
|
|
253
|
+
enqueue(message, options) {
|
|
254
|
+
return this.queue.enqueue(message, options);
|
|
255
|
+
}
|
|
256
|
+
async enqueueMany(messages, options) {
|
|
257
|
+
if (this.queue.enqueueMany == null) {
|
|
258
|
+
const errors = (await Promise.allSettled(messages.map((message) => this.queue.enqueue(message, options)))).filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
259
|
+
if (errors.length > 1) throw new AggregateError(errors, "Failed to enqueue messages.");
|
|
260
|
+
else if (errors.length === 1) throw errors[0];
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
await this.queue.enqueueMany(messages, options);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Extracts ordering key from a message if present.
|
|
267
|
+
*
|
|
268
|
+
* This method only works for queue implementations that deliver messages
|
|
269
|
+
* in the wrapper format with `__fedify_ordering_key__` property. Currently,
|
|
270
|
+
* only `DenoKvMessageQueue` and `WorkersMessageQueue` use this format.
|
|
271
|
+
*
|
|
272
|
+
* For other queue implementations (`InProcessMessageQueue`,
|
|
273
|
+
* `RedisMessageQueue`, `PostgresMessageQueue`, `SqliteMessageQueue`,
|
|
274
|
+
* `AmqpMessageQueue`), messages are delivered as raw payloads without the
|
|
275
|
+
* wrapper, so the ordering key cannot be detected here. Those
|
|
276
|
+
* implementations handle ordering guarantees internally.
|
|
277
|
+
*/
|
|
278
|
+
#extractOrderingKey(message) {
|
|
279
|
+
if (message != null && typeof message === "object") {
|
|
280
|
+
if ("__fedify_ordering_key__" in message) return message.__fedify_ordering_key__;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
listen(handler, options = {}) {
|
|
284
|
+
const workers = /* @__PURE__ */ new Map();
|
|
285
|
+
return this.queue.listen(async (message) => {
|
|
286
|
+
while (workers.size >= this.workers) {
|
|
287
|
+
const consumedId = await Promise.any(workers.values());
|
|
288
|
+
workers.delete(consumedId);
|
|
289
|
+
}
|
|
290
|
+
const workerId = crypto.randomUUID();
|
|
291
|
+
const orderingKey = this.#extractOrderingKey(message);
|
|
292
|
+
if (orderingKey != null && this.#processingKeys.has(orderingKey)) await new Promise((resolve) => {
|
|
293
|
+
this.#pendingMessages.push({
|
|
294
|
+
message,
|
|
295
|
+
orderingKey,
|
|
296
|
+
resolve
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
if (orderingKey != null) this.#processingKeys.add(orderingKey);
|
|
300
|
+
const promise = this.#work(workerId, handler, message, orderingKey);
|
|
301
|
+
workers.set(workerId, promise);
|
|
302
|
+
}, options);
|
|
303
|
+
}
|
|
304
|
+
async #work(workerId, handler, message, orderingKey) {
|
|
305
|
+
await this.#sleep(0);
|
|
306
|
+
try {
|
|
307
|
+
await handler(message);
|
|
308
|
+
} finally {
|
|
309
|
+
if (orderingKey != null) {
|
|
310
|
+
this.#processingKeys.delete(orderingKey);
|
|
311
|
+
const pendingIdx = this.#pendingMessages.findIndex((p) => p.orderingKey === orderingKey);
|
|
312
|
+
if (pendingIdx >= 0) this.#pendingMessages.splice(pendingIdx, 1)[0].resolve();
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return workerId;
|
|
316
|
+
}
|
|
317
|
+
#sleep(ms) {
|
|
318
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
//#endregion
|
|
322
|
+
export { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue, Router, RouterError, SendActivityError, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, handleWebFinger, respondWithObject, respondWithObjectIfAcceptable };
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import { assert } from "../assert-
|
|
8
|
-
import "../assert_instance_of-DHz7EHNU.js";
|
|
9
|
-
import { assertGreater, assertGreaterOrEqual } from "../std__assert-X-_kMxKM.js";
|
|
10
|
-
import { assertFalse } from "../assert_rejects-0h7I2Esa.js";
|
|
11
|
-
import "../assert_throws-rjdMBf31.js";
|
|
12
|
-
import "../assert_not_equals-f3m3epl3.js";
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
|
+
import { i as assertGreaterOrEqual, r as assertGreater } from "../std__assert-Duiq_YC9.mjs";
|
|
6
|
+
import { n as assertFalse } from "../assert_rejects-B-qJtC9Z.mjs";
|
|
7
|
+
import { t as assert } from "../assert-ddO5KLpe.mjs";
|
|
13
8
|
import { test } from "@fedify/fixture";
|
|
14
9
|
import { delay } from "es-toolkit";
|
|
15
|
-
|
|
16
10
|
//#region src/federation/mq.ts
|
|
17
11
|
/**
|
|
18
12
|
* A message queue that processes messages in the same process.
|
|
@@ -46,12 +40,12 @@ var InProcessMessageQueue = class {
|
|
|
46
40
|
this.#processingKeys = /* @__PURE__ */ new Set();
|
|
47
41
|
}
|
|
48
42
|
enqueue(message, options) {
|
|
49
|
-
const delay
|
|
50
|
-
if (delay
|
|
43
|
+
const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
|
|
44
|
+
if (delay > 0) {
|
|
51
45
|
setTimeout(() => this.enqueue(message, {
|
|
52
46
|
...options,
|
|
53
47
|
delay: void 0
|
|
54
|
-
}), delay
|
|
48
|
+
}), delay);
|
|
55
49
|
return Promise.resolve();
|
|
56
50
|
}
|
|
57
51
|
const orderingKey = options?.orderingKey ?? null;
|
|
@@ -64,12 +58,12 @@ var InProcessMessageQueue = class {
|
|
|
64
58
|
}
|
|
65
59
|
enqueueMany(messages, options) {
|
|
66
60
|
if (messages.length === 0) return Promise.resolve();
|
|
67
|
-
const delay
|
|
68
|
-
if (delay
|
|
61
|
+
const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
|
|
62
|
+
if (delay > 0) {
|
|
69
63
|
setTimeout(() => this.enqueueMany(messages, {
|
|
70
64
|
...options,
|
|
71
65
|
delay: void 0
|
|
72
|
-
}), delay
|
|
66
|
+
}), delay);
|
|
73
67
|
return Promise.resolve();
|
|
74
68
|
}
|
|
75
69
|
const orderingKey = options?.orderingKey ?? null;
|
|
@@ -85,8 +79,7 @@ var InProcessMessageQueue = class {
|
|
|
85
79
|
while (signal == null || !signal.aborted) {
|
|
86
80
|
const idx = this.#messages.findIndex((m) => m.orderingKey == null || !this.#processingKeys.has(m.orderingKey));
|
|
87
81
|
if (idx >= 0) {
|
|
88
|
-
const
|
|
89
|
-
const { message, orderingKey } = queued;
|
|
82
|
+
const { message, orderingKey } = this.#messages.splice(idx, 1)[0];
|
|
90
83
|
if (orderingKey != null) this.#processingKeys.add(orderingKey);
|
|
91
84
|
try {
|
|
92
85
|
await handler(message);
|
|
@@ -180,8 +173,7 @@ var ParallelMessageQueue = class ParallelMessageQueue {
|
|
|
180
173
|
}
|
|
181
174
|
async enqueueMany(messages, options) {
|
|
182
175
|
if (this.queue.enqueueMany == null) {
|
|
183
|
-
const
|
|
184
|
-
const errors = results.filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
176
|
+
const errors = (await Promise.allSettled(messages.map((message) => this.queue.enqueue(message, options)))).filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
185
177
|
if (errors.length > 1) throw new AggregateError(errors, "Failed to enqueue messages.");
|
|
186
178
|
else if (errors.length === 1) throw errors[0];
|
|
187
179
|
return;
|
|
@@ -205,7 +197,6 @@ var ParallelMessageQueue = class ParallelMessageQueue {
|
|
|
205
197
|
if (message != null && typeof message === "object") {
|
|
206
198
|
if ("__fedify_ordering_key__" in message) return message.__fedify_ordering_key__;
|
|
207
199
|
}
|
|
208
|
-
return void 0;
|
|
209
200
|
}
|
|
210
201
|
listen(handler, options = {}) {
|
|
211
202
|
const workers = /* @__PURE__ */ new Map();
|
|
@@ -236,10 +227,7 @@ var ParallelMessageQueue = class ParallelMessageQueue {
|
|
|
236
227
|
if (orderingKey != null) {
|
|
237
228
|
this.#processingKeys.delete(orderingKey);
|
|
238
229
|
const pendingIdx = this.#pendingMessages.findIndex((p) => p.orderingKey === orderingKey);
|
|
239
|
-
if (pendingIdx >= 0)
|
|
240
|
-
const pending = this.#pendingMessages.splice(pendingIdx, 1)[0];
|
|
241
|
-
pending.resolve();
|
|
242
|
-
}
|
|
230
|
+
if (pendingIdx >= 0) this.#pendingMessages.splice(pendingIdx, 1)[0].resolve();
|
|
243
231
|
}
|
|
244
232
|
}
|
|
245
233
|
return workerId;
|
|
@@ -248,7 +236,6 @@ var ParallelMessageQueue = class ParallelMessageQueue {
|
|
|
248
236
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
249
237
|
}
|
|
250
238
|
};
|
|
251
|
-
|
|
252
239
|
//#endregion
|
|
253
240
|
//#region src/federation/mq.test.ts
|
|
254
241
|
test("InProcessMessageQueue", async (t) => {
|
|
@@ -410,8 +397,7 @@ test("MessageQueue.nativeRetrial", async (t) => {
|
|
|
410
397
|
throw new TypeError("WorkersMessageQueue does not support listen()");
|
|
411
398
|
}
|
|
412
399
|
}
|
|
413
|
-
|
|
414
|
-
assert(mq.nativeRetrial);
|
|
400
|
+
assert(new TestWorkersMessageQueue(new MockQueue()).nativeRetrial);
|
|
415
401
|
});
|
|
416
402
|
});
|
|
417
403
|
const queues = { InProcessMessageQueue: () => Promise.resolve(new InProcessMessageQueue()) };
|
|
@@ -455,8 +441,8 @@ for (const mqName in queues) test({
|
|
|
455
441
|
await waitFor(() => messages.length >= 20, 15e3);
|
|
456
442
|
while (messages.length > 0) messages.pop();
|
|
457
443
|
await t.step("enqueueMany()", async () => {
|
|
458
|
-
const messages
|
|
459
|
-
await workers.enqueueMany(messages
|
|
444
|
+
const messages = Array.from({ length: 20 }, (_, i) => `Hello, ${i}!`);
|
|
445
|
+
await workers.enqueueMany(messages);
|
|
460
446
|
});
|
|
461
447
|
await t.step("listen() [multiple]", async () => {
|
|
462
448
|
await delay(3e3);
|
|
@@ -480,5 +466,5 @@ async function waitFor(predicate, timeoutMs) {
|
|
|
480
466
|
if (Date.now() - started > timeoutMs) throw new Error("Timeout");
|
|
481
467
|
}
|
|
482
468
|
}
|
|
483
|
-
|
|
484
|
-
|
|
469
|
+
//#endregion
|
|
470
|
+
export {};
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import "../
|
|
7
|
-
import {
|
|
8
|
-
import "../assert_instance_of-DHz7EHNU.js";
|
|
9
|
-
import { acceptsJsonLd } from "../negotiation-BlAuS_nr.js";
|
|
10
|
-
import "../std__assert-X-_kMxKM.js";
|
|
11
|
-
import { assertFalse } from "../assert_rejects-0h7I2Esa.js";
|
|
12
|
-
import "../assert_throws-rjdMBf31.js";
|
|
13
|
-
import "../assert_not_equals-f3m3epl3.js";
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import "../std__assert-Duiq_YC9.mjs";
|
|
5
|
+
import { n as assertFalse } from "../assert_rejects-B-qJtC9Z.mjs";
|
|
6
|
+
import { t as assert } from "../assert-ddO5KLpe.mjs";
|
|
7
|
+
import { t as acceptsJsonLd } from "../negotiation-DnsfFF8I.mjs";
|
|
14
8
|
import { test } from "@fedify/fixture";
|
|
15
|
-
|
|
16
9
|
//#region src/federation/negotiation.test.ts
|
|
17
10
|
test("acceptsJsonLd()", () => {
|
|
18
11
|
assert(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/activity+json" } })));
|
|
@@ -21,5 +14,5 @@ test("acceptsJsonLd()", () => {
|
|
|
21
14
|
assertFalse(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/ld+json; q=0.5, text/html; q=0.8" } })));
|
|
22
15
|
assertFalse(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/ld+json; q=0.4, application/xhtml+xml; q=0.9" } })));
|
|
23
16
|
});
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
//#endregion
|
|
18
|
+
export {};
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import { createExponentialBackoffPolicy } from "../retry-mqLf4b-R.js";
|
|
8
|
-
import { assertNotEquals } from "../assert_not_equals-f3m3epl3.js";
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { l as AssertionError, t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
|
+
import { t as assertNotEquals } from "../assert_not_equals--wG9hV7u.mjs";
|
|
6
|
+
import { t as createExponentialBackoffPolicy } from "../retry-B_E3V_Dx.mjs";
|
|
9
7
|
import { test } from "@fedify/fixture";
|
|
10
|
-
|
|
11
8
|
//#region src/federation/retry.test.ts
|
|
12
9
|
test("createExponentialBackoffPolicy()", () => {
|
|
13
10
|
const policy = createExponentialBackoffPolicy({ maxAttempts: 4 });
|
|
@@ -40,5 +37,5 @@ function assertDurationRange(actual, min, max) {
|
|
|
40
37
|
const maxDuration = Temporal.Duration.from(max);
|
|
41
38
|
if (Temporal.Duration.compare(actual, minDuration) < 0 || Temporal.Duration.compare(actual, maxDuration) > 0) throw new AssertionError(`Expected ${actual} to be between ${min} and ${max}`);
|
|
42
39
|
}
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
//#endregion
|
|
41
|
+
export {};
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import "../
|
|
9
|
-
import {
|
|
10
|
-
import "../std__assert-X-_kMxKM.js";
|
|
11
|
-
import { assertFalse } from "../assert_rejects-0h7I2Esa.js";
|
|
12
|
-
import { assertThrows } from "../assert_throws-rjdMBf31.js";
|
|
13
|
-
import "../assert_not_equals-f3m3epl3.js";
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { n as RouterError, t as Router } from "../router-CrMLXoOr.mjs";
|
|
5
|
+
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
6
|
+
import "../std__assert-Duiq_YC9.mjs";
|
|
7
|
+
import { n as assertFalse } from "../assert_rejects-B-qJtC9Z.mjs";
|
|
8
|
+
import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
|
|
9
|
+
import { t as assert } from "../assert-ddO5KLpe.mjs";
|
|
14
10
|
import { test } from "@fedify/fixture";
|
|
15
|
-
|
|
16
11
|
//#region src/federation/router.test.ts
|
|
17
12
|
function setUp(options = {}) {
|
|
18
13
|
const router = new Router(options);
|
|
@@ -93,5 +88,5 @@ test("Router.build()", () => {
|
|
|
93
88
|
postId: "123"
|
|
94
89
|
}), "/users/alice/posts/123");
|
|
95
90
|
});
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
//#endregion
|
|
92
|
+
export {};
|
|
@@ -1,26 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import "../
|
|
11
|
-
import "../
|
|
12
|
-
import "../
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { SendActivityError, extractInboxes, sendActivity } from "../send-CJAMZwWu.js";
|
|
16
|
-
import "../std__assert-X-_kMxKM.js";
|
|
17
|
-
import { assertFalse, assertRejects } from "../assert_rejects-0h7I2Esa.js";
|
|
18
|
-
import "../assert_throws-rjdMBf31.js";
|
|
19
|
-
import { assertNotEquals } from "../assert_not_equals-f3m3epl3.js";
|
|
20
|
-
import { ed25519Multikey, ed25519PrivateKey, rsaPrivateKey2, rsaPublicKey2 } from "../keys-BFve7QQv.js";
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { t as esm_default } from "../esm-DVILvP5e.mjs";
|
|
5
|
+
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
6
|
+
import "../std__assert-Duiq_YC9.mjs";
|
|
7
|
+
import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
|
|
8
|
+
import { t as assertInstanceOf } from "../assert_instance_of-C4Ri6VuN.mjs";
|
|
9
|
+
import { t as assertNotEquals } from "../assert_not_equals--wG9hV7u.mjs";
|
|
10
|
+
import { t as assert } from "../assert-ddO5KLpe.mjs";
|
|
11
|
+
import { l as verifyRequest } from "../http-CNsnyqrO.mjs";
|
|
12
|
+
import { i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
|
|
13
|
+
import { t as doesActorOwnKey } from "../owner-DF320w6K.mjs";
|
|
14
|
+
import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-CJQubr5t.mjs";
|
|
21
15
|
import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
22
16
|
import { Activity, Application, Endpoints, Group, Person, Service } from "@fedify/vocab";
|
|
23
|
-
|
|
24
17
|
//#region src/federation/send.test.ts
|
|
25
18
|
test("extractInboxes()", () => {
|
|
26
19
|
const recipients = [
|
|
@@ -387,14 +380,13 @@ test("sendActivity() records OpenTelemetry span events", async (t) => {
|
|
|
387
380
|
await t.step("successful send", async () => {
|
|
388
381
|
esm_default.get("https://example.com/", { status: 404 });
|
|
389
382
|
esm_default.post("https://example.com/inbox", { status: 202 });
|
|
390
|
-
const activity = {
|
|
391
|
-
"@context": "https://www.w3.org/ns/activitystreams",
|
|
392
|
-
type: "Create",
|
|
393
|
-
id: "https://example.com/activity",
|
|
394
|
-
actor: "https://example.com/person"
|
|
395
|
-
};
|
|
396
383
|
await sendActivity({
|
|
397
|
-
activity
|
|
384
|
+
activity: {
|
|
385
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
386
|
+
type: "Create",
|
|
387
|
+
id: "https://example.com/activity",
|
|
388
|
+
actor: "https://example.com/person"
|
|
389
|
+
},
|
|
398
390
|
activityId: "https://example.com/activity",
|
|
399
391
|
activityType: "https://www.w3.org/ns/activitystreams#Create",
|
|
400
392
|
keys: [{
|
|
@@ -423,5 +415,5 @@ test("sendActivity() records OpenTelemetry span events", async (t) => {
|
|
|
423
415
|
esm_default.hardReset();
|
|
424
416
|
});
|
|
425
417
|
});
|
|
426
|
-
|
|
427
|
-
|
|
418
|
+
//#endregion
|
|
419
|
+
export {};
|