@fedify/fedify 2.4.0-dev.2149 → 2.4.0-dev.2157
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/dist/{builder-W2fIPRjv.mjs → builder-CLaS4-yA.mjs} +56 -3
- package/dist/{client-DpnpgjyX.mjs → client-CEnNz8O7.mjs} +7 -3
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/transformers.test.mjs +1 -1
- package/dist/{compound-proof-B1QH25S6.mjs → compound-proof-D7K94KPz.mjs} +216 -4
- package/dist/{context-DfSVPcJ8.mjs → context-B2rlkkyJ.mjs} +9 -2
- package/dist/{context-CrDDVrbF.d.cts → context-BMggDR-l.d.cts} +394 -5
- package/dist/{context-B2C8nuN3.d.ts → context-exYu7gDU.d.ts} +394 -5
- package/dist/{deno-yXpYZm4K.mjs → deno-D1gcWWqB.mjs} +1 -1
- package/dist/{dist-BQvArojP.mjs → dist-DJQM4u7i.mjs} +2 -1
- package/dist/docloader-BMqr3hji.mjs +79 -0
- package/dist/federation/builder.test.mjs +1 -1
- package/dist/federation/compound-fanout.test.mjs +3 -3
- package/dist/federation/handler-compound-proof.test.mjs +4 -4
- package/dist/federation/handler.test.mjs +6 -6
- package/dist/federation/hashlink-media.test.mjs +2 -2
- package/dist/federation/idempotency.test.mjs +2 -2
- package/dist/federation/metrics.test.mjs +1 -1
- package/dist/federation/middleware.test.mjs +187 -10
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.d.cts +3 -3
- package/dist/federation/mod.d.ts +3 -3
- package/dist/federation/mod.js +1 -1
- package/dist/federation/mq.test.mjs +98 -69
- package/dist/federation/outgoing-proof.test.mjs +5 -5
- package/dist/federation/portable-actor.test.mjs +3 -3
- package/dist/federation/portable-chain.test.mjs +3 -3
- package/dist/federation/portable-collection.test.d.mts +2 -0
- package/dist/federation/portable-collection.test.mjs +768 -0
- package/dist/federation/portable-gateway-keys.test.mjs +4 -4
- package/dist/federation/portable-inbox.test.mjs +4 -4
- package/dist/federation/portable.test.mjs +4 -4
- package/dist/federation/send.test.mjs +84 -3
- package/dist/federation/tasks/enqueue.test.mjs +3 -3
- package/dist/federation/tasks/tasks.test.mjs +4 -4
- package/dist/federation/temporal.test.mjs +1 -1
- package/dist/federation/webfinger.test.mjs +2 -2
- package/dist/{federation-D4j-ZXUN.cjs → federation-2e8XrN7q.cjs} +700 -70
- package/dist/{http-C_jobbLz.cjs → http-BObQoB0j.cjs} +18 -3
- package/dist/{http-BoH-e8sR.mjs → http-CGcLv8rh.mjs} +9 -5
- package/dist/{http-CBRurnlR.js → http-Dgtt45-K.js} +13 -4
- package/dist/{key-BtO7WCfP.mjs → key-CPM4r6tP.mjs} +2 -2
- package/dist/{kv-cache-E0es0w4R.js → kv-cache-BweyIZTb.js} +35 -9
- package/dist/{kv-cache-BxUqVENn.cjs → kv-cache-D2fnB8qu.cjs} +34 -8
- package/dist/{kv-cache-CMuTXrkC.mjs → kv-cache-bdPqTR1k.mjs} +1 -1
- package/dist/{ld-YYBfDbe_.mjs → ld-lU_ZqzsQ.mjs} +4 -4
- package/dist/{metrics-DMqdDud_.mjs → metrics-B41pRPfd.mjs} +1 -1
- package/dist/{middleware-D6uiL1Tw.js → middleware-BYWyYjmX.js} +702 -72
- package/dist/{middleware-C97UJpkA.mjs → middleware-TrCVULgs.mjs} +1 -1
- package/dist/{middleware-CBGR92fz.mjs → middleware-xdukzV3x.mjs} +432 -81
- package/dist/{mod-C06GoL5Z.d.ts → mod-CnGtADvO.d.ts} +1 -1
- package/dist/{mod-CZetqT5h.d.ts → mod-DaiBrWDW.d.ts} +2 -0
- package/dist/{mod-B7SfEqIP.d.cts → mod-Decmur1U.d.cts} +1 -1
- package/dist/{mod-D4g9ffEn.d.cts → mod-Mt4aO3DX.d.cts} +2 -0
- package/dist/mod.cjs +5 -5
- package/dist/mod.d.cts +5 -5
- package/dist/mod.d.ts +5 -5
- package/dist/mod.js +5 -5
- package/dist/nodeinfo/client.test.mjs +49 -1
- package/dist/nodeinfo/handler.test.mjs +2 -2
- package/dist/nodeinfo/mod.cjs +1 -1
- package/dist/nodeinfo/mod.js +1 -1
- package/dist/{owner-Cn6CFYBy.mjs → owner-D63yPo_i.mjs} +3 -3
- package/dist/{portable-collection-CWgXwOdR.cjs → portable-collection-B8ojoQ50.cjs} +1 -1
- package/dist/{portable-collection-CyhFWEB-.js → portable-collection-C3xEzYri.js} +1 -1
- package/dist/{portable-collection-B3swTTja.mjs → portable-collection-_lZg-osX.mjs} +2 -2
- package/dist/{portable-key-HM5Siym0.mjs → portable-key-D8uWZF7b.mjs} +1 -1
- package/dist/{proof-DWkXfZIU.mjs → proof-C2YwD8a_.mjs} +10 -5
- package/dist/{send-BQDT_8bc.mjs → send-D9SGhxTB.mjs} +18 -4
- package/dist/sig/compound-proof-discovery.test.mjs +1 -1
- package/dist/sig/compound-proof-producer.test.mjs +1 -1
- package/dist/sig/compound-proof-verification.test.mjs +2 -2
- package/dist/sig/compound-proof.test.mjs +2 -2
- package/dist/sig/http.test.mjs +42 -2
- package/dist/sig/key.test.mjs +1 -1
- package/dist/sig/ld.test.mjs +5 -2
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +1 -1
- package/dist/sig/portable-collection.test.mjs +2 -2
- package/dist/sig/portable-key.test.mjs +6 -6
- package/dist/sig/proof.test.mjs +3 -3
- package/dist/{tasks-dbCShlCb.mjs → tasks-IG3pHfvZ.mjs} +1 -1
- package/dist/{temporal-CFI__wjQ.mjs → temporal-q6FSekcN.mjs} +1 -1
- package/dist/testing/context.test.mjs +1 -1
- package/dist/testing/kv.test.mjs +3 -3
- package/dist/testing/mod.d.mts +393 -4
- package/dist/testing/mod.mjs +4 -4
- package/dist/{testing-otQhu4aD.mjs → testing-C1itIjqW.mjs} +3 -3
- package/dist/{types-C_cNlNVK.js → types-_S2_MeLF.js} +7 -3
- package/dist/{types-Be2zbyeG.cjs → types-poIao40f.cjs} +7 -3
- package/dist/utils/docloader.test.mjs +297 -2
- package/dist/utils/kv-cache.test.mjs +1 -1
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.d.cts +1 -1
- package/dist/utils/mod.d.ts +1 -1
- package/dist/utils/mod.js +1 -1
- package/dist/vocab/cjs.test.mjs +1 -1
- package/package.json +7 -7
- package/dist/docloader-C4h6PL7m.mjs +0 -53
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Temporal } from "temporal-polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as createOutboxContext, r as createRequestContext, t as createInboxContext } from "../context-
|
|
4
|
+
import { n as createOutboxContext, r as createRequestContext, t as createInboxContext } from "../context-B2rlkkyJ.mjs";
|
|
5
5
|
import { t as MemoryKvStore } from "../kv-DCHkaJ9-.mjs";
|
|
6
6
|
import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
|
|
7
7
|
import { t as assertGreaterOrEqual } from "../assert_greater_or_equal-BlafOF4-.mjs";
|
|
@@ -10,12 +10,12 @@ import "../std__assert-DvMDRPes.mjs";
|
|
|
10
10
|
import { t as assertRejects } from "../assert_rejects-CTptdYck.mjs";
|
|
11
11
|
import { t as assert } from "../assert-D1Eafmd_.mjs";
|
|
12
12
|
import { r as parseAcceptSignature } from "../accept-CPVqki78.mjs";
|
|
13
|
-
import { o as generateCryptoKeyPair } from "../key-
|
|
14
|
-
import { a as compactJsonLd, p as signJsonLd } from "../ld-
|
|
15
|
-
import {
|
|
16
|
-
import { l as signRequest } from "../http-
|
|
13
|
+
import { o as generateCryptoKeyPair } from "../key-CPM4r6tP.mjs";
|
|
14
|
+
import { a as compactJsonLd, p as signJsonLd } from "../ld-lU_ZqzsQ.mjs";
|
|
15
|
+
import { a as signObject } from "../proof-C2YwD8a_.mjs";
|
|
16
|
+
import { l as signRequest } from "../http-CGcLv8rh.mjs";
|
|
17
17
|
import { a as rsaPrivateKey3, c as rsaPublicKey3, s as rsaPublicKey2 } from "../keys-DIJNHW-Y.mjs";
|
|
18
|
-
import { d as handleCustomCollection, f as handleInbox, g as respondWithObjectIfAcceptable, h as respondWithObject, l as handleActor, m as handleOutbox, o as createFederation, p as handleObject, u as handleCollection } from "../middleware-
|
|
18
|
+
import { d as handleCustomCollection, f as handleInbox, g as respondWithObjectIfAcceptable, h as respondWithObject, l as handleActor, m as handleOutbox, o as createFederation, p as handleObject, u as handleCollection } from "../middleware-xdukzV3x.mjs";
|
|
19
19
|
import { t as ActivityListenerSet } from "../activity-listener-C-BSbKI7.mjs";
|
|
20
20
|
import { Activity, Create, CryptographicKey, Multikey, Note, Person, Tombstone } from "@fedify/vocab";
|
|
21
21
|
import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
@@ -10,8 +10,8 @@ import "../std__assert-DvMDRPes.mjs";
|
|
|
10
10
|
import { t as assertStrictEquals } from "../assert_strict_equals-CYvBmkpC.mjs";
|
|
11
11
|
import { t as assert } from "../assert-D1Eafmd_.mjs";
|
|
12
12
|
import { r as ed25519PublicKey } from "../keys-DIJNHW-Y.mjs";
|
|
13
|
-
import { o as createFederation, x as parseHashlinkGatewayRequest } from "../middleware-
|
|
14
|
-
import { r as createFederationBuilder } from "../builder-
|
|
13
|
+
import { o as createFederation, x as parseHashlinkGatewayRequest } from "../middleware-xdukzV3x.mjs";
|
|
14
|
+
import { r as createFederationBuilder } from "../builder-CLaS4-yA.mjs";
|
|
15
15
|
import { n as RouterError } from "../router-u5O5KCQr.mjs";
|
|
16
16
|
import { Note } from "@fedify/vocab";
|
|
17
17
|
import { createTestMeterProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
@@ -4,9 +4,9 @@ globalThis.addEventListener = () => {};
|
|
|
4
4
|
import { t as MemoryKvStore } from "../kv-DCHkaJ9-.mjs";
|
|
5
5
|
import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
|
|
6
6
|
import "../std__assert-DvMDRPes.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { a as signObject } from "../proof-C2YwD8a_.mjs";
|
|
8
8
|
import { n as ed25519PrivateKey, r as ed25519PublicKey, t as ed25519Multikey } from "../keys-DIJNHW-Y.mjs";
|
|
9
|
-
import { o as createFederation } from "../middleware-
|
|
9
|
+
import { o as createFederation } from "../middleware-xdukzV3x.mjs";
|
|
10
10
|
import { Create, Follow, Person } from "@fedify/vocab";
|
|
11
11
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
12
12
|
//#region src/federation/idempotency.test.ts
|
|
@@ -4,7 +4,7 @@ globalThis.addEventListener = () => {};
|
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
|
|
5
5
|
import "../std__assert-DvMDRPes.mjs";
|
|
6
6
|
import { t as assertRejects } from "../assert_rejects-CTptdYck.mjs";
|
|
7
|
-
import { _ as recordKeyLookup, a as instrumentDocumentLoader, b as recordWebFingerHandle, c as recordCircuitBreakerStateChange, d as recordCollectionRequest, f as recordCollectionTotalItems, g as recordInboxActivity, h as recordFanoutRecipients, i as getRemoteHost, l as recordCollectionDispatchDuration, m as recordDocumentFetch, p as recordDocumentCache, r as getFederationMetrics, t as classifyFetchError, u as recordCollectionPageItems, v as recordOutboxActivity, x as registerQueueDepthGauge, y as recordOutboxEnqueue } from "../metrics-
|
|
7
|
+
import { _ as recordKeyLookup, a as instrumentDocumentLoader, b as recordWebFingerHandle, c as recordCircuitBreakerStateChange, d as recordCollectionRequest, f as recordCollectionTotalItems, g as recordInboxActivity, h as recordFanoutRecipients, i as getRemoteHost, l as recordCollectionDispatchDuration, m as recordDocumentFetch, p as recordDocumentCache, r as getFederationMetrics, t as classifyFetchError, u as recordCollectionPageItems, v as recordOutboxActivity, x as registerQueueDepthGauge, y as recordOutboxEnqueue } from "../metrics-B41pRPfd.mjs";
|
|
8
8
|
import { createTestMeterProvider, test } from "@fedify/fixture";
|
|
9
9
|
import { FetchError } from "@fedify/vocab-runtime";
|
|
10
10
|
import { DataPointType, MeterProvider, MetricReader } from "@opentelemetry/sdk-metrics";
|
|
@@ -4,8 +4,8 @@ globalThis.addEventListener = () => {};
|
|
|
4
4
|
import { t as esm_default } from "../esm-BHXXx4Wx.mjs";
|
|
5
5
|
import { t as MemoryKvStore } from "../kv-DCHkaJ9-.mjs";
|
|
6
6
|
import { t as ManualClockKvStore } from "../kv-DBRWVx3Q.mjs";
|
|
7
|
-
import { a as numberSchema, r as envelopeSchema, t as MockQueue } from "../tasks-
|
|
8
|
-
import "../testing-
|
|
7
|
+
import { a as numberSchema, r as envelopeSchema, t as MockQueue } from "../tasks-IG3pHfvZ.mjs";
|
|
8
|
+
import "../testing-C1itIjqW.mjs";
|
|
9
9
|
import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
|
|
10
10
|
import { t as assertExists } from "../assert_exists-cffSpJ7X.mjs";
|
|
11
11
|
import { t as assertFalse } from "../assert_false-CPdRnc3E.mjs";
|
|
@@ -16,14 +16,14 @@ import "../std__assert-DvMDRPes.mjs";
|
|
|
16
16
|
import { t as assertRejects } from "../assert_rejects-CTptdYck.mjs";
|
|
17
17
|
import { t as assertStrictEquals } from "../assert_strict_equals-CYvBmkpC.mjs";
|
|
18
18
|
import { t as assert } from "../assert-D1Eafmd_.mjs";
|
|
19
|
-
import { g as recordInboxActivity } from "../metrics-
|
|
20
|
-
import { a as compactJsonLd, h as verifyJsonLd, p as signJsonLd, s as detachSignature } from "../ld-
|
|
21
|
-
import {
|
|
22
|
-
import { d as verifyRequest, l as signRequest } from "../http-
|
|
19
|
+
import { g as recordInboxActivity } from "../metrics-B41pRPfd.mjs";
|
|
20
|
+
import { a as compactJsonLd, h as verifyJsonLd, p as signJsonLd, s as detachSignature } from "../ld-lU_ZqzsQ.mjs";
|
|
21
|
+
import { a as signObject, s as verifyObject } from "../proof-C2YwD8a_.mjs";
|
|
22
|
+
import { d as verifyRequest, l as signRequest } from "../http-CGcLv8rh.mjs";
|
|
23
23
|
import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DIJNHW-Y.mjs";
|
|
24
|
-
import { t as getAuthenticatedDocumentLoader } from "../docloader-
|
|
25
|
-
import { S as handleBenchmarkTrigger, i as KvSpecDeterminer, n as FederationImpl, o as createFederation, r as InboxContextImpl, t as ContextImpl } from "../middleware-
|
|
26
|
-
import { t as doesActorOwnKey } from "../owner-
|
|
24
|
+
import { t as getAuthenticatedDocumentLoader } from "../docloader-BMqr3hji.mjs";
|
|
25
|
+
import { S as handleBenchmarkTrigger, i as KvSpecDeterminer, n as FederationImpl, o as createFederation, r as InboxContextImpl, t as ContextImpl } from "../middleware-xdukzV3x.mjs";
|
|
26
|
+
import { t as doesActorOwnKey } from "../owner-D63yPo_i.mjs";
|
|
27
27
|
import { t as CircuitBreaker } from "../circuit-breaker-C5NqoLBJ.mjs";
|
|
28
28
|
import { t as TaskCodec } from "../codec-C6rTrpIp.mjs";
|
|
29
29
|
import { t as markCircuitBreakerLegacySweepDone } from "../circuit-breaker-test-utils-DW6YC_Pe.mjs";
|
|
@@ -34,8 +34,9 @@ import { Create, Note, Offer, Person, getTypeId, lookupObject } from "@fedify/vo
|
|
|
34
34
|
import { SpanStatusCode, metrics } from "@opentelemetry/api";
|
|
35
35
|
import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
36
36
|
import { FetchError, UrlError, getDocumentLoader } from "@fedify/vocab-runtime";
|
|
37
|
-
import
|
|
37
|
+
import dns from "node:dns/promises";
|
|
38
38
|
import { deepStrictEqual, ok, rejects, strictEqual } from "node:assert/strict";
|
|
39
|
+
import serialize from "json-canon";
|
|
39
40
|
import { DataPointType, MeterProvider as MeterProvider$1, MetricReader } from "@opentelemetry/sdk-metrics";
|
|
40
41
|
//#region ../fixture/src/fixtures/example.com/create.json
|
|
41
42
|
var create_default = {
|
|
@@ -1175,6 +1176,31 @@ test({
|
|
|
1175
1176
|
esm_default.hardReset();
|
|
1176
1177
|
}
|
|
1177
1178
|
});
|
|
1179
|
+
test("Federation.fetch() [rfc9421] multiple POST signatures", async (t) => {
|
|
1180
|
+
for (const validSecond of [true, false]) await t.step(validSecond ? "valid second signature" : "both signatures invalid", async () => {
|
|
1181
|
+
const inbox = [];
|
|
1182
|
+
const federation = createFederation({
|
|
1183
|
+
kv: new MemoryKvStore(),
|
|
1184
|
+
documentLoaderFactory: () => mockDocumentLoader,
|
|
1185
|
+
contextLoaderFactory: () => mockDocumentLoader
|
|
1186
|
+
});
|
|
1187
|
+
federation.setActorDispatcher("/users/{identifier}", (ctx, identifier) => new vocab.Person({ id: ctx.getActorUri(identifier) }));
|
|
1188
|
+
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, (_ctx, activity) => {
|
|
1189
|
+
inbox.push(activity.id.href);
|
|
1190
|
+
});
|
|
1191
|
+
const signed = await signRequest(new Request("https://example.com/inbox", {
|
|
1192
|
+
method: "POST",
|
|
1193
|
+
headers: { "Content-Type": "application/activity+json" },
|
|
1194
|
+
body: JSON.stringify(create_default)
|
|
1195
|
+
}), rsaPrivateKey2, rsaPublicKey2.id, { spec: "rfc9421" });
|
|
1196
|
+
const input = signed.headers.get("Signature-Input");
|
|
1197
|
+
const signature = signed.headers.get("Signature");
|
|
1198
|
+
signed.headers.set("Signature-Input", `${input}, ${input.replace(/^sig1=/, "sig2=")}`);
|
|
1199
|
+
signed.headers.set("Signature", `sig1=:AAAAAA==:, ${validSecond ? signature.replace(/^sig1=/, "sig2=") : "sig2=:AAAAAA==:"}`);
|
|
1200
|
+
assertEquals((await federation.fetch(signed, { contextData: void 0 })).status, validSecond ? 202 : 401);
|
|
1201
|
+
assertEquals(inbox, validSecond ? [create_default.id] : []);
|
|
1202
|
+
});
|
|
1203
|
+
});
|
|
1178
1204
|
test("Federation.fetch()", async (t) => {
|
|
1179
1205
|
esm_default.spyGlobal();
|
|
1180
1206
|
esm_default.get("https://example.com/key2", {
|
|
@@ -4943,6 +4969,157 @@ test("FederationImpl.processQueuedTask()", async (t) => {
|
|
|
4943
4969
|
assertEquals(queuedMessages, []);
|
|
4944
4970
|
});
|
|
4945
4971
|
});
|
|
4972
|
+
test({
|
|
4973
|
+
name: "FederationImpl.processQueuedTask() accounts for destination validation failures",
|
|
4974
|
+
ignore: "Deno" in globalThis && (await Deno.permissions.query({ name: "net" })).state !== "granted",
|
|
4975
|
+
async fn(t) {
|
|
4976
|
+
for (const result of [
|
|
4977
|
+
"throws",
|
|
4978
|
+
"empty",
|
|
4979
|
+
"private"
|
|
4980
|
+
]) for (const failureThreshold of [1, 5]) for (const redirected of [false, true]) await t.step(`${result}, threshold: ${failureThreshold}, redirected: ${redirected}`, async () => {
|
|
4981
|
+
const destination = "https://delivery.invalid/inbox";
|
|
4982
|
+
const publicInbox = "https://8.8.8.8/inbox";
|
|
4983
|
+
const queuedMessages = [];
|
|
4984
|
+
const delays = [];
|
|
4985
|
+
const errors = [];
|
|
4986
|
+
const activities = [];
|
|
4987
|
+
const attempts = [];
|
|
4988
|
+
const delay = Temporal.Duration.from({ seconds: 5 });
|
|
4989
|
+
const kv = new MemoryKvStore();
|
|
4990
|
+
await markCircuitBreakerLegacySweepDone(kv);
|
|
4991
|
+
const [meterProvider, recorder] = createTestMeterProvider();
|
|
4992
|
+
const recoveryDelay = Temporal.Duration.from({ minutes: 30 });
|
|
4993
|
+
const federation = new FederationImpl({
|
|
4994
|
+
kv,
|
|
4995
|
+
meterProvider,
|
|
4996
|
+
circuitBreaker: {
|
|
4997
|
+
failureThreshold,
|
|
4998
|
+
recoveryDelay
|
|
4999
|
+
},
|
|
5000
|
+
queue: {
|
|
5001
|
+
enqueue(message, options) {
|
|
5002
|
+
queuedMessages.push(message);
|
|
5003
|
+
delays.push(options?.delay);
|
|
5004
|
+
return Promise.resolve();
|
|
5005
|
+
},
|
|
5006
|
+
listen() {
|
|
5007
|
+
return Promise.resolve();
|
|
5008
|
+
}
|
|
5009
|
+
},
|
|
5010
|
+
documentLoaderFactory: () => mockDocumentLoader,
|
|
5011
|
+
contextLoaderFactory: () => mockDocumentLoader,
|
|
5012
|
+
onOutboxError(error, activity) {
|
|
5013
|
+
errors.push(error);
|
|
5014
|
+
activities.push(activity);
|
|
5015
|
+
},
|
|
5016
|
+
outboxRetryPolicy(options) {
|
|
5017
|
+
attempts.push(options.attempts);
|
|
5018
|
+
return delay;
|
|
5019
|
+
}
|
|
5020
|
+
});
|
|
5021
|
+
const message = {
|
|
5022
|
+
type: "outbox",
|
|
5023
|
+
id: crypto.randomUUID(),
|
|
5024
|
+
baseUrl: "https://example.com",
|
|
5025
|
+
keys: [],
|
|
5026
|
+
activity: {
|
|
5027
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
5028
|
+
type: "Create",
|
|
5029
|
+
id: "https://example.com/activities/dns-failure",
|
|
5030
|
+
actor: "https://example.com/users/alice",
|
|
5031
|
+
object: {
|
|
5032
|
+
type: "Note",
|
|
5033
|
+
content: "test"
|
|
5034
|
+
}
|
|
5035
|
+
},
|
|
5036
|
+
activityType: "https://www.w3.org/ns/activitystreams#Create",
|
|
5037
|
+
inbox: redirected ? publicInbox : destination,
|
|
5038
|
+
sharedInbox: false,
|
|
5039
|
+
started: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5040
|
+
attempt: 0,
|
|
5041
|
+
headers: {},
|
|
5042
|
+
traceContext: {}
|
|
5043
|
+
};
|
|
5044
|
+
const originalLookup = dns.lookup;
|
|
5045
|
+
const resolverError = /* @__PURE__ */ new Error("Resolver unavailable");
|
|
5046
|
+
const lookups = [];
|
|
5047
|
+
dns.lookup = ((hostname) => {
|
|
5048
|
+
lookups.push(hostname);
|
|
5049
|
+
assertEquals(hostname, "delivery.invalid");
|
|
5050
|
+
if (result === "throws") return Promise.reject(resolverError);
|
|
5051
|
+
return Promise.resolve(result === "empty" ? [] : [{
|
|
5052
|
+
address: "127.0.0.1",
|
|
5053
|
+
family: 4
|
|
5054
|
+
}]);
|
|
5055
|
+
});
|
|
5056
|
+
try {
|
|
5057
|
+
esm_default.mockGlobal().catch(202);
|
|
5058
|
+
if (redirected) esm_default.route(publicInbox, {
|
|
5059
|
+
status: 307,
|
|
5060
|
+
headers: { Location: destination }
|
|
5061
|
+
});
|
|
5062
|
+
await federation.processQueuedTask(void 0, message);
|
|
5063
|
+
assertEquals(errors.length, 1);
|
|
5064
|
+
const error = errors[0];
|
|
5065
|
+
if (result === "private") {
|
|
5066
|
+
assertInstanceOf(error, UrlError);
|
|
5067
|
+
assertEquals(error.reason, "disallowed");
|
|
5068
|
+
} else {
|
|
5069
|
+
assertInstanceOf(error, FetchError);
|
|
5070
|
+
assertEquals(error.url.href, destination);
|
|
5071
|
+
assertInstanceOf(error.cause, UrlError);
|
|
5072
|
+
assertEquals(error.cause.reason, "dns");
|
|
5073
|
+
assertStrictEquals(error.cause.cause, result === "throws" ? resolverError : void 0);
|
|
5074
|
+
}
|
|
5075
|
+
assertEquals(activities.length, 1);
|
|
5076
|
+
assertInstanceOf(activities[0], Create);
|
|
5077
|
+
assertEquals(activities[0].id?.href, "https://example.com/activities/dns-failure");
|
|
5078
|
+
assertEquals(attempts, [0]);
|
|
5079
|
+
const host = new URL(message.inbox).host;
|
|
5080
|
+
const state = await kv.get([
|
|
5081
|
+
"_fedify",
|
|
5082
|
+
"circuit",
|
|
5083
|
+
host
|
|
5084
|
+
]);
|
|
5085
|
+
if (result === "private") assertEquals(state, void 0);
|
|
5086
|
+
else {
|
|
5087
|
+
assertExists(state);
|
|
5088
|
+
assertEquals(state.failures.length, 1);
|
|
5089
|
+
assertEquals(state.state, failureThreshold === 1 ? "open" : "closed");
|
|
5090
|
+
}
|
|
5091
|
+
if (result !== "private" && failureThreshold === 1) {
|
|
5092
|
+
assertEquals(queuedMessages.length, 1);
|
|
5093
|
+
const held = queuedMessages[0];
|
|
5094
|
+
assertEquals(held.attempt, 0);
|
|
5095
|
+
assertEquals(held.circuitHeld, true);
|
|
5096
|
+
assertExists(held.circuitHeldSince);
|
|
5097
|
+
assertEquals(delays, [recoveryDelay]);
|
|
5098
|
+
} else {
|
|
5099
|
+
assertEquals(queuedMessages, [{
|
|
5100
|
+
...message,
|
|
5101
|
+
attempt: 1
|
|
5102
|
+
}]);
|
|
5103
|
+
assertEquals(delays, [delay]);
|
|
5104
|
+
}
|
|
5105
|
+
const expectedCount = result === "private" && !redirected ? 0 : 1;
|
|
5106
|
+
const sent = recorder.getMeasurements("activitypub.delivery.sent");
|
|
5107
|
+
assertEquals(sent.length, expectedCount);
|
|
5108
|
+
if (expectedCount === 1) {
|
|
5109
|
+
assertEquals(sent[0].value, 1);
|
|
5110
|
+
assertEquals(sent[0].attributes["activitypub.delivery.success"], false);
|
|
5111
|
+
assertEquals(sent[0].attributes["activitypub.remote.host"], host);
|
|
5112
|
+
}
|
|
5113
|
+
assertEquals(lookups, ["delivery.invalid"]);
|
|
5114
|
+
assertEquals(esm_default.callHistory.calls(destination).length, 0);
|
|
5115
|
+
assertEquals(esm_default.callHistory.calls().length, redirected ? 1 : 0);
|
|
5116
|
+
} finally {
|
|
5117
|
+
dns.lookup = originalLookup;
|
|
5118
|
+
esm_default.hardReset();
|
|
5119
|
+
}
|
|
5120
|
+
});
|
|
5121
|
+
}
|
|
5122
|
+
});
|
|
4946
5123
|
test("FederationImpl.processQueuedTask() permanent failure", async (t) => {
|
|
4947
5124
|
esm_default.spyGlobal();
|
|
4948
5125
|
esm_default.post("https://gone.example/inbox", {
|
package/dist/federation/mod.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const require_federation = require("../federation-
|
|
3
|
+
const require_federation = require("../federation-2e8XrN7q.cjs");
|
|
4
4
|
exports.CircuitBreaker = require_federation.CircuitBreaker;
|
|
5
5
|
exports.InProcessMessageQueue = require_federation.InProcessMessageQueue;
|
|
6
6
|
exports.MemoryKvStore = require_federation.MemoryKvStore;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { $ as InProcessMessageQueue, A as MediaUploaderSetters, At as HashlinkMediaRequest, B as createFederationBuilder, Bt as OutboxPermanentFailureHandler, C as FederationFetchOptions, Ct as CollectionCounter, D as IdempotencyStrategy, Dt as CustomCollectionCursor, E as IdempotencyKeyCallback, Et as CustomCollectionCounter, F as FederationKvPrefixes, Ft as ObjectAuthorizePredicate, G as TaskRegistry, Gt as
|
|
2
|
+
import { $ as InProcessMessageQueue, A as MediaUploaderSetters, At as HashlinkMediaRequest, B as createFederationBuilder, Bt as OutboxPermanentFailureHandler, C as FederationFetchOptions, Ct as CollectionCounter, D as IdempotencyStrategy, Dt as CustomCollectionCursor, E as IdempotencyKeyCallback, Et as CustomCollectionCounter, F as FederationKvPrefixes, Ft as ObjectAuthorizePredicate, G as TaskRegistry, Gt as UnverifiedActivityReason, H as TaskDefinitionOptions, Ht as PortableCollectionOwnerMapper, I as FederationOrigin, It as ObjectDispatcher, J as RetryPolicy, Jt as SenderKeyPair, K as CreateExponentialBackoffPolicyOptions, Kt as WebFingerLinksDispatcher, L as FederationQueueOptions, Lt as OutboxErrorHandler, M as OutboxListenerSetters, Mt as InboxListener, N as PortableInboxForwardingOptions, Nt as MediaUploaderCallback, O as InboxChallengePolicy, Ot as CustomCollectionDispatcher, P as Rfc6570Expression, Pt as NodeInfoDispatcher, Q as respondWithObjectIfAcceptable, R as createFederation, Rt as OutboxListener, S as FederationBuilder, St as AuthorizePredicate, T as FederationStartQueueOptions, Tt as CollectionDispatcher, U as TaskEnqueueOptions, Ut as SharedInboxKeyDispatcher, V as TaskDefinition, Vt as PortableActorIdMapper, W as TaskHandler, Wt as UnverifiedActivityHandler, X as RespondWithObjectOptions, Xt as buildCollectionSynchronizationHeader, Y as createExponentialBackoffPolicy, Yt as PageItems, Z as respondWithObject, Zt as digest, _ as ConstructorWithTypeId, _t as parseCircuitBreakerKvState, a as GetObjectOptions, at as ParallelMessageQueue, b as Federation, bt as ActorHandleMapper, c as OutboxContext, ct as CircuitBreakerBeforeSendDecision, d as RequestContext, dt as CircuitBreakerKvState, et as InProcessMessageQueueOptions, f as RouteActivityOptions, ft as CircuitBreakerOptions, g as CollectionCallbackSetters, gt as normalizeCircuitBreakerOptions, h as ActorCallbackSetters, ht as NormalizedCircuitBreakerOptions, i as GetActorOptions, it as MessageQueueListenOptions, j as ObjectCallbackSetters, jt as InboxErrorHandler, k as InboxListenerSetters, kt as HashlinkMediaDispatcher, l as ParseUriResult, lt as CircuitBreakerCreateOptions, m as SendActivityOptionsForCollection, mt as CircuitBreakerStateChange, n as Context, nt as MessageQueueDepth, o as GetSignedKeyOptions, ot as CircuitBreaker, p as SendActivityOptions, pt as CircuitBreakerState, q as RetryContext, qt as SendActivityError, r as ForwardActivityOptions, rt as MessageQueueEnqueueOptions, s as InboxContext, st as CircuitBreakerActivityDrop, t as ActorKeyPair, tt as MessageQueue, u as PortableRequest, ut as CircuitBreakerFailurePolicy, v as CustomCollectionCallbackSetters, vt as ActorAliasMapper, w as FederationOptions, wt as CollectionCursor, x as FederationBenchmarkOptions, xt as ActorKeyPairsDispatcher, y as Federatable, yt as ActorDispatcher, z as Message, zt as OutboxListenerErrorHandler } from "../context-BMggDR-l.cjs";
|
|
3
3
|
import { a as MemoryKvStore, i as KvStoreSetOptions, n as KvStore, r as KvStoreListEntry, t as KvKey } from "../kv-BhNbN8Ed.cjs";
|
|
4
|
-
import { a as RouterOptions, i as RouterError, n as handleWebFinger, o as RouterRouteResult, r as Router, t as WebFingerHandlerParameters } from "../mod-
|
|
5
|
-
export { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CircuitBreaker, CircuitBreakerActivityDrop, CircuitBreakerBeforeSendDecision, CircuitBreakerCreateOptions, CircuitBreakerFailurePolicy, CircuitBreakerKvState, CircuitBreakerOptions, CircuitBreakerState, CircuitBreakerStateChange, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBenchmarkOptions, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetActorOptions, GetObjectOptions, GetSignedKeyOptions, HashlinkMediaDispatcher, HashlinkMediaRequest, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxChallengePolicy, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MediaUploaderCallback, MediaUploaderSetters, MemoryKvStore, Message, MessageQueue, MessageQueueDepth, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, NormalizedCircuitBreakerOptions, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxContext, OutboxErrorHandler, OutboxListener, OutboxListenerErrorHandler, OutboxListenerSetters, OutboxPermanentFailureHandler, PageItems, ParallelMessageQueue, ParseUriResult, PortableActorIdMapper, PortableInboxForwardingOptions, PortableRequest, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityError, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, TaskDefinition, TaskDefinitionOptions, TaskEnqueueOptions, TaskHandler, TaskRegistry, UnverifiedActivityHandler, UnverifiedActivityReason, WebFingerHandlerParameters, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, handleWebFinger, normalizeCircuitBreakerOptions, parseCircuitBreakerKvState, respondWithObject, respondWithObjectIfAcceptable };
|
|
4
|
+
import { a as RouterOptions, i as RouterError, n as handleWebFinger, o as RouterRouteResult, r as Router, t as WebFingerHandlerParameters } from "../mod-Decmur1U.cjs";
|
|
5
|
+
export { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CircuitBreaker, CircuitBreakerActivityDrop, CircuitBreakerBeforeSendDecision, CircuitBreakerCreateOptions, CircuitBreakerFailurePolicy, CircuitBreakerKvState, CircuitBreakerOptions, CircuitBreakerState, CircuitBreakerStateChange, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBenchmarkOptions, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetActorOptions, GetObjectOptions, GetSignedKeyOptions, HashlinkMediaDispatcher, HashlinkMediaRequest, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxChallengePolicy, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MediaUploaderCallback, MediaUploaderSetters, MemoryKvStore, Message, MessageQueue, MessageQueueDepth, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, NormalizedCircuitBreakerOptions, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxContext, OutboxErrorHandler, OutboxListener, OutboxListenerErrorHandler, OutboxListenerSetters, OutboxPermanentFailureHandler, PageItems, ParallelMessageQueue, ParseUriResult, PortableActorIdMapper, PortableCollectionOwnerMapper, PortableInboxForwardingOptions, PortableRequest, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityError, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, TaskDefinition, TaskDefinitionOptions, TaskEnqueueOptions, TaskHandler, TaskRegistry, UnverifiedActivityHandler, UnverifiedActivityReason, WebFingerHandlerParameters, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, handleWebFinger, normalizeCircuitBreakerOptions, parseCircuitBreakerKvState, respondWithObject, respondWithObjectIfAcceptable };
|
package/dist/federation/mod.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { $ as InProcessMessageQueue, A as MediaUploaderSetters, At as HashlinkMediaRequest, B as createFederationBuilder, Bt as OutboxPermanentFailureHandler, C as FederationFetchOptions, Ct as CollectionCounter, D as IdempotencyStrategy, Dt as CustomCollectionCursor, E as IdempotencyKeyCallback, Et as CustomCollectionCounter, F as FederationKvPrefixes, Ft as ObjectAuthorizePredicate, G as TaskRegistry, Gt as
|
|
2
|
+
import { $ as InProcessMessageQueue, A as MediaUploaderSetters, At as HashlinkMediaRequest, B as createFederationBuilder, Bt as OutboxPermanentFailureHandler, C as FederationFetchOptions, Ct as CollectionCounter, D as IdempotencyStrategy, Dt as CustomCollectionCursor, E as IdempotencyKeyCallback, Et as CustomCollectionCounter, F as FederationKvPrefixes, Ft as ObjectAuthorizePredicate, G as TaskRegistry, Gt as UnverifiedActivityReason, H as TaskDefinitionOptions, Ht as PortableCollectionOwnerMapper, I as FederationOrigin, It as ObjectDispatcher, J as RetryPolicy, Jt as SenderKeyPair, K as CreateExponentialBackoffPolicyOptions, Kt as WebFingerLinksDispatcher, L as FederationQueueOptions, Lt as OutboxErrorHandler, M as OutboxListenerSetters, Mt as InboxListener, N as PortableInboxForwardingOptions, Nt as MediaUploaderCallback, O as InboxChallengePolicy, Ot as CustomCollectionDispatcher, P as Rfc6570Expression, Pt as NodeInfoDispatcher, Q as respondWithObjectIfAcceptable, R as createFederation, Rt as OutboxListener, S as FederationBuilder, St as AuthorizePredicate, T as FederationStartQueueOptions, Tt as CollectionDispatcher, U as TaskEnqueueOptions, Ut as SharedInboxKeyDispatcher, V as TaskDefinition, Vt as PortableActorIdMapper, W as TaskHandler, Wt as UnverifiedActivityHandler, X as RespondWithObjectOptions, Xt as buildCollectionSynchronizationHeader, Y as createExponentialBackoffPolicy, Yt as PageItems, Z as respondWithObject, Zt as digest, _ as ConstructorWithTypeId, _t as parseCircuitBreakerKvState, a as GetObjectOptions, at as ParallelMessageQueue, b as Federation, bt as ActorHandleMapper, c as OutboxContext, ct as CircuitBreakerBeforeSendDecision, d as RequestContext, dt as CircuitBreakerKvState, et as InProcessMessageQueueOptions, f as RouteActivityOptions, ft as CircuitBreakerOptions, g as CollectionCallbackSetters, gt as normalizeCircuitBreakerOptions, h as ActorCallbackSetters, ht as NormalizedCircuitBreakerOptions, i as GetActorOptions, it as MessageQueueListenOptions, j as ObjectCallbackSetters, jt as InboxErrorHandler, k as InboxListenerSetters, kt as HashlinkMediaDispatcher, l as ParseUriResult, lt as CircuitBreakerCreateOptions, m as SendActivityOptionsForCollection, mt as CircuitBreakerStateChange, n as Context, nt as MessageQueueDepth, o as GetSignedKeyOptions, ot as CircuitBreaker, p as SendActivityOptions, pt as CircuitBreakerState, q as RetryContext, qt as SendActivityError, r as ForwardActivityOptions, rt as MessageQueueEnqueueOptions, s as InboxContext, st as CircuitBreakerActivityDrop, t as ActorKeyPair, tt as MessageQueue, u as PortableRequest, ut as CircuitBreakerFailurePolicy, v as CustomCollectionCallbackSetters, vt as ActorAliasMapper, w as FederationOptions, wt as CollectionCursor, x as FederationBenchmarkOptions, xt as ActorKeyPairsDispatcher, y as Federatable, yt as ActorDispatcher, z as Message, zt as OutboxListenerErrorHandler } from "../context-exYu7gDU.js";
|
|
3
3
|
import { a as MemoryKvStore, i as KvStoreSetOptions, n as KvStore, r as KvStoreListEntry, t as KvKey } from "../kv-BhNbN8Ed.js";
|
|
4
|
-
import { a as RouterOptions, i as RouterError, n as handleWebFinger, o as RouterRouteResult, r as Router, t as WebFingerHandlerParameters } from "../mod-
|
|
5
|
-
export { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CircuitBreaker, CircuitBreakerActivityDrop, CircuitBreakerBeforeSendDecision, CircuitBreakerCreateOptions, CircuitBreakerFailurePolicy, CircuitBreakerKvState, CircuitBreakerOptions, CircuitBreakerState, CircuitBreakerStateChange, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBenchmarkOptions, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetActorOptions, GetObjectOptions, GetSignedKeyOptions, HashlinkMediaDispatcher, HashlinkMediaRequest, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxChallengePolicy, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MediaUploaderCallback, MediaUploaderSetters, MemoryKvStore, Message, MessageQueue, MessageQueueDepth, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, NormalizedCircuitBreakerOptions, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxContext, OutboxErrorHandler, OutboxListener, OutboxListenerErrorHandler, OutboxListenerSetters, OutboxPermanentFailureHandler, PageItems, ParallelMessageQueue, ParseUriResult, PortableActorIdMapper, PortableInboxForwardingOptions, PortableRequest, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityError, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, TaskDefinition, TaskDefinitionOptions, TaskEnqueueOptions, TaskHandler, TaskRegistry, UnverifiedActivityHandler, UnverifiedActivityReason, WebFingerHandlerParameters, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, handleWebFinger, normalizeCircuitBreakerOptions, parseCircuitBreakerKvState, respondWithObject, respondWithObjectIfAcceptable };
|
|
4
|
+
import { a as RouterOptions, i as RouterError, n as handleWebFinger, o as RouterRouteResult, r as Router, t as WebFingerHandlerParameters } from "../mod-CnGtADvO.js";
|
|
5
|
+
export { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CircuitBreaker, CircuitBreakerActivityDrop, CircuitBreakerBeforeSendDecision, CircuitBreakerCreateOptions, CircuitBreakerFailurePolicy, CircuitBreakerKvState, CircuitBreakerOptions, CircuitBreakerState, CircuitBreakerStateChange, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBenchmarkOptions, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetActorOptions, GetObjectOptions, GetSignedKeyOptions, HashlinkMediaDispatcher, HashlinkMediaRequest, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxChallengePolicy, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MediaUploaderCallback, MediaUploaderSetters, MemoryKvStore, Message, MessageQueue, MessageQueueDepth, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, NormalizedCircuitBreakerOptions, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxContext, OutboxErrorHandler, OutboxListener, OutboxListenerErrorHandler, OutboxListenerSetters, OutboxPermanentFailureHandler, PageItems, ParallelMessageQueue, ParseUriResult, PortableActorIdMapper, PortableCollectionOwnerMapper, PortableInboxForwardingOptions, PortableRequest, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityError, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, TaskDefinition, TaskDefinitionOptions, TaskEnqueueOptions, TaskHandler, TaskRegistry, UnverifiedActivityHandler, UnverifiedActivityReason, WebFingerHandlerParameters, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, handleWebFinger, normalizeCircuitBreakerOptions, parseCircuitBreakerKvState, respondWithObject, respondWithObjectIfAcceptable };
|
package/dist/federation/mod.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "temporal-polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { a as respondWithObjectIfAcceptable, c as digest, d as parseCircuitBreakerKvState, f as createFederationBuilder, i as respondWithObject, l as CircuitBreaker, n as handleWebFinger, o as SendActivityError, r as createExponentialBackoffPolicy, s as buildCollectionSynchronizationHeader, t as createFederation, u as normalizeCircuitBreakerOptions } from "../middleware-
|
|
3
|
+
import { a as respondWithObjectIfAcceptable, c as digest, d as parseCircuitBreakerKvState, f as createFederationBuilder, i as respondWithObject, l as CircuitBreaker, n as handleWebFinger, o as SendActivityError, r as createExponentialBackoffPolicy, s as buildCollectionSynchronizationHeader, t as createFederation, u as normalizeCircuitBreakerOptions } from "../middleware-BYWyYjmX.js";
|
|
4
4
|
import { getLogger } from "@logtape/logtape";
|
|
5
5
|
import { Router as Router$1, RouterError as RouterError$1, assertPath, isPath } from "@fedify/uri-template";
|
|
6
6
|
import { isEqual } from "es-toolkit";
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Temporal } from "temporal-polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as
|
|
5
|
-
import { s as format, t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
|
|
4
|
+
import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
|
|
6
5
|
import { t as assertFalse } from "../assert_false-CPdRnc3E.mjs";
|
|
7
6
|
import { t as assertGreaterOrEqual } from "../assert_greater_or_equal-BlafOF4-.mjs";
|
|
8
7
|
import "../std__assert-DvMDRPes.mjs";
|
|
@@ -11,31 +10,6 @@ import { t as assert } from "../assert-D1Eafmd_.mjs";
|
|
|
11
10
|
import { n as ParallelMessageQueue, t as InProcessMessageQueue } from "../mq-Dm1Wmtm-.mjs";
|
|
12
11
|
import { delay } from "es-toolkit";
|
|
13
12
|
import { test } from "@fedify/fixture";
|
|
14
|
-
//#region ../../node_modules/.pnpm/@jsr+std__assert@0.226.0/node_modules/@jsr/std__assert/assert_greater.js
|
|
15
|
-
/**
|
|
16
|
-
* Make an assertion that `actual` is greater than `expected`.
|
|
17
|
-
* If not then throw.
|
|
18
|
-
*
|
|
19
|
-
* @example Usage
|
|
20
|
-
* ```ts no-eval
|
|
21
|
-
* import { assertGreater } from "@std/assert/assert-greater";
|
|
22
|
-
*
|
|
23
|
-
* assertGreater(2, 1); // Doesn't throw
|
|
24
|
-
* assertGreater(1, 1); // Throws
|
|
25
|
-
* assertGreater(0, 1); // Throws
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @typeParam T The type of the values to compare.
|
|
29
|
-
* @param actual The actual value to compare.
|
|
30
|
-
* @param expected The expected value to compare.
|
|
31
|
-
* @param msg The optional message to display if the assertion fails.
|
|
32
|
-
*/ function assertGreater(actual, expected, msg) {
|
|
33
|
-
if (actual > expected) return;
|
|
34
|
-
const actualString = format(actual);
|
|
35
|
-
const expectedString = format(expected);
|
|
36
|
-
throw new AssertionError(msg ?? `Expect ${actualString} > ${expectedString}`);
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
13
|
//#region src/federation/mq.test.ts
|
|
40
14
|
async function disposeMessageQueue(mq) {
|
|
41
15
|
if (Symbol.asyncDispose in mq) {
|
|
@@ -70,50 +44,105 @@ test("InProcessMessageQueue", async (t) => {
|
|
|
70
44
|
const listening = mq.listen((message) => {
|
|
71
45
|
messages.push(message);
|
|
72
46
|
}, controller);
|
|
73
|
-
|
|
74
|
-
await
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
47
|
+
try {
|
|
48
|
+
await t.step("enqueue()", async () => {
|
|
49
|
+
await mq.enqueue("Hello, world!");
|
|
50
|
+
});
|
|
51
|
+
await waitFor(() => messages.length > 0, 15e3);
|
|
52
|
+
await t.step("listen()", () => {
|
|
53
|
+
assertEquals(messages, ["Hello, world!"]);
|
|
54
|
+
});
|
|
55
|
+
await t.step("enqueue() with delay", async () => {
|
|
56
|
+
const { timers, enqueued } = captureTimers(() => mq.enqueue("Delayed message", { delay: Temporal.Duration.from({ seconds: 3 }) }));
|
|
57
|
+
await enqueued;
|
|
58
|
+
assertEquals(timers.length, 1);
|
|
59
|
+
assertEquals(timers[0].delay, 3e3);
|
|
60
|
+
await mq.enqueue("Single delay marker");
|
|
61
|
+
await waitFor(() => messages.includes("Single delay marker"), 15e3);
|
|
62
|
+
assertEquals(messages, ["Hello, world!", "Single delay marker"]);
|
|
63
|
+
timers[0].callback();
|
|
64
|
+
});
|
|
65
|
+
await waitFor(() => messages.length >= 3, 15e3);
|
|
66
|
+
await t.step("listen() with delay", () => {
|
|
67
|
+
assertEquals(messages, [
|
|
68
|
+
"Hello, world!",
|
|
69
|
+
"Single delay marker",
|
|
70
|
+
"Delayed message"
|
|
71
|
+
]);
|
|
72
|
+
});
|
|
73
|
+
while (messages.length > 0) messages.pop();
|
|
74
|
+
await t.step("enqueueMany()", async () => {
|
|
75
|
+
const testMessages = Array.from({ length: 5 }, (_, i) => `Batch message ${i}!`);
|
|
76
|
+
await mq.enqueueMany(testMessages);
|
|
77
|
+
});
|
|
78
|
+
await waitFor(() => messages.length >= 5, 15e3);
|
|
79
|
+
await t.step("listen() [multiple]", () => {
|
|
80
|
+
assertEquals(messages.length, 5);
|
|
81
|
+
for (let i = 0; i < 5; i++) assertEquals(messages[i], `Batch message ${i}!`);
|
|
82
|
+
});
|
|
83
|
+
while (messages.length > 0) messages.pop();
|
|
84
|
+
await t.step("enqueueMany() with delay", async () => {
|
|
85
|
+
const testMessages = Array.from({ length: 3 }, (_, i) => `Delayed batch ${i}!`);
|
|
86
|
+
const { timers, enqueued } = captureTimers(() => mq.enqueueMany(testMessages, { delay: Temporal.Duration.from({ seconds: 2 }) }));
|
|
87
|
+
await enqueued;
|
|
88
|
+
assertEquals(timers.length, 1);
|
|
89
|
+
assertEquals(timers[0].delay, 2e3);
|
|
90
|
+
await mq.enqueue("Batch delay marker");
|
|
91
|
+
await waitFor(() => messages.includes("Batch delay marker"), 15e3);
|
|
92
|
+
assertEquals(messages, ["Batch delay marker"]);
|
|
93
|
+
timers[0].callback();
|
|
94
|
+
});
|
|
95
|
+
await waitFor(() => messages.length >= 4, 15e3);
|
|
96
|
+
await t.step("listen() [delayed multiple]", () => {
|
|
97
|
+
assertEquals(messages.length, 4);
|
|
98
|
+
assertEquals(messages[0], "Batch delay marker");
|
|
99
|
+
for (let i = 0; i < 3; i++) assertEquals(messages[i + 1], `Delayed batch ${i}!`);
|
|
100
|
+
});
|
|
101
|
+
} finally {
|
|
102
|
+
controller.abort();
|
|
103
|
+
await listening;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
function captureTimers(enqueue) {
|
|
107
|
+
const timers = [];
|
|
108
|
+
const original = globalThis.setTimeout;
|
|
109
|
+
globalThis.setTimeout = ((callback, delay) => {
|
|
110
|
+
timers.push({
|
|
111
|
+
callback,
|
|
112
|
+
delay
|
|
113
|
+
});
|
|
114
|
+
return 0;
|
|
108
115
|
});
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
116
|
+
try {
|
|
117
|
+
return {
|
|
118
|
+
timers,
|
|
119
|
+
enqueued: enqueue()
|
|
120
|
+
};
|
|
121
|
+
} finally {
|
|
122
|
+
globalThis.setTimeout = original;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
test("InProcessMessageQueue real delay", async (t) => {
|
|
126
|
+
for (const batch of [false, true]) await t.step(batch ? "enqueueMany()" : "enqueue()", async () => {
|
|
127
|
+
const mq = new InProcessMessageQueue();
|
|
128
|
+
const messages = [];
|
|
129
|
+
const controller = new AbortController();
|
|
130
|
+
const listening = mq.listen((message) => {
|
|
131
|
+
messages.push(message);
|
|
132
|
+
}, controller);
|
|
133
|
+
try {
|
|
134
|
+
const delayed = batch ? ["Delayed 1", "Delayed 2"] : ["Delayed"];
|
|
135
|
+
const options = { delay: Temporal.Duration.from({ milliseconds: 100 }) };
|
|
136
|
+
if (batch) await mq.enqueueMany(delayed, options);
|
|
137
|
+
else await mq.enqueue(delayed[0], options);
|
|
138
|
+
await mq.enqueue("Immediate");
|
|
139
|
+
await waitFor(() => messages.length >= delayed.length + 1, 15e3);
|
|
140
|
+
assertEquals(messages, ["Immediate", ...delayed]);
|
|
141
|
+
} finally {
|
|
142
|
+
controller.abort();
|
|
143
|
+
await listening;
|
|
144
|
+
}
|
|
114
145
|
});
|
|
115
|
-
controller.abort();
|
|
116
|
-
await listening;
|
|
117
146
|
});
|
|
118
147
|
test("InProcessMessageQueue.getDepth()", async () => {
|
|
119
148
|
const mq = new InProcessMessageQueue();
|
|
@@ -7,12 +7,12 @@ import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
|
|
|
7
7
|
import "../std__assert-DvMDRPes.mjs";
|
|
8
8
|
import { t as assertRejects } from "../assert_rejects-CTptdYck.mjs";
|
|
9
9
|
import { t as assert } from "../assert-D1Eafmd_.mjs";
|
|
10
|
-
import { n as exportJwk } from "../key-
|
|
11
|
-
import { s as detachSignature } from "../ld-
|
|
12
|
-
import {
|
|
10
|
+
import { n as exportJwk } from "../key-CPM4r6tP.mjs";
|
|
11
|
+
import { s as detachSignature } from "../ld-lU_ZqzsQ.mjs";
|
|
12
|
+
import { a as signObject } from "../proof-C2YwD8a_.mjs";
|
|
13
13
|
import { i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2 } from "../keys-DIJNHW-Y.mjs";
|
|
14
|
-
import { c as assertPortableActorActivity, n as FederationImpl, o as createFederation } from "../middleware-
|
|
15
|
-
import { a as verifyCompoundPortableObjectProofs } from "../compound-proof-
|
|
14
|
+
import { c as assertPortableActorActivity, n as FederationImpl, o as createFederation } from "../middleware-xdukzV3x.mjs";
|
|
15
|
+
import { a as verifyCompoundPortableObjectProofs } from "../compound-proof-D7K94KPz.mjs";
|
|
16
16
|
import { configure, reset } from "@logtape/logtape";
|
|
17
17
|
import { Create, Note, Person } from "@fedify/vocab";
|
|
18
18
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
@@ -8,10 +8,10 @@ import { t as assertInstanceOf } from "../assert_instance_of-mrXWWNY-.mjs";
|
|
|
8
8
|
import { t as assertThrows } from "../assert_throws-BYITOvPO.mjs";
|
|
9
9
|
import "../std__assert-DvMDRPes.mjs";
|
|
10
10
|
import { t as assert } from "../assert-D1Eafmd_.mjs";
|
|
11
|
-
import {
|
|
12
|
-
import { d as verifyRequest, l as signRequest } from "../http-
|
|
11
|
+
import { a as signObject, c as verifyPortableObjectProof } from "../proof-C2YwD8a_.mjs";
|
|
12
|
+
import { d as verifyRequest, l as signRequest } from "../http-CGcLv8rh.mjs";
|
|
13
13
|
import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2 } from "../keys-DIJNHW-Y.mjs";
|
|
14
|
-
import { b as PORTABLE_OBJECT_CONTENT_TYPE, o as createFederation } from "../middleware-
|
|
14
|
+
import { b as PORTABLE_OBJECT_CONTENT_TYPE, o as createFederation } from "../middleware-xdukzV3x.mjs";
|
|
15
15
|
import { n as RouterError } from "../router-u5O5KCQr.mjs";
|
|
16
16
|
import { configure, reset } from "@logtape/logtape";
|
|
17
17
|
import { Note, Person, Tombstone, lookupObject } from "@fedify/vocab";
|
|
@@ -7,10 +7,10 @@ import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
|
|
|
7
7
|
import { t as assertInstanceOf } from "../assert_instance_of-mrXWWNY-.mjs";
|
|
8
8
|
import "../std__assert-DvMDRPes.mjs";
|
|
9
9
|
import { t as assert } from "../assert-D1Eafmd_.mjs";
|
|
10
|
-
import { n as exportJwk } from "../key-
|
|
11
|
-
import {
|
|
10
|
+
import { n as exportJwk } from "../key-CPM4r6tP.mjs";
|
|
11
|
+
import { c as verifyPortableObjectProof, s as verifyObject } from "../proof-C2YwD8a_.mjs";
|
|
12
12
|
import { i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2 } from "../keys-DIJNHW-Y.mjs";
|
|
13
|
-
import { n as FederationImpl } from "../middleware-
|
|
13
|
+
import { n as FederationImpl } from "../middleware-xdukzV3x.mjs";
|
|
14
14
|
import { Create, DataIntegrityProof, Note, OrderedCollection, Person, traverseCollection } from "@fedify/vocab";
|
|
15
15
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
16
16
|
import { FetchError, encodeMultibase, exportDidKey } from "@fedify/vocab-runtime";
|