@fedify/fedify 2.4.0-dev.1490 → 2.4.0-dev.1508
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 +7 -5
- package/dist/{assert-OguE97r2.mjs → assert-DvVHoIZ0.mjs} +1 -1
- package/dist/{assert_instance_of-DBC5X09g.mjs → assert_instance_of-CxoC8bVq.mjs} +1 -1
- package/dist/{assert_not_equals-DkVK8oqV.mjs → assert_not_equals-C8vcTTA3.mjs} +1 -1
- package/dist/{assert_rejects-DN60FHPX.mjs → assert_rejects-DAdaaIWM.mjs} +2 -2
- package/dist/{assert_strict_equals-XEgZAlrj.mjs → assert_strict_equals-BzqyKuYL.mjs} +1 -1
- package/dist/{assert_throws-BOkhLGYc.mjs → assert_throws-zN79lgIC.mjs} +1 -1
- package/dist/{builder-CwwQRArg.mjs → builder-DlWCek6Z.mjs} +23 -3
- package/dist/codec-CmlPqjNX.mjs +103 -0
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/outgoing-jsonld.test.mjs +3 -3
- package/dist/compat/public-audience.test.mjs +3 -3
- package/dist/compat/transformers.test.mjs +5 -5
- package/dist/{context-DVoTs_wM.mjs → context-BBRTgkrs.mjs} +8 -2
- package/dist/{context-BU6jSQdo.d.ts → context-BF5B4ZDk.d.ts} +529 -259
- package/dist/{context-BBVLF7lx.d.cts → context-CYF8X0ft.d.cts} +530 -259
- package/dist/{deno-Yohf1ISx.mjs → deno-nexucTAX.mjs} +1 -1
- package/dist/{docloader-B6DFWEOx.mjs → docloader-DAdEN549.mjs} +3 -3
- package/dist/federation/builder.test.mjs +5 -5
- package/dist/federation/circuit-breaker.test.mjs +5 -5
- package/dist/federation/collection.test.mjs +3 -3
- package/dist/federation/handler.test.mjs +13 -13
- package/dist/federation/idempotency.test.mjs +6 -6
- package/dist/federation/inbox.test.mjs +3 -3
- package/dist/federation/keycache.test.mjs +5 -5
- package/dist/federation/kv.test.mjs +3 -3
- package/dist/federation/metrics.test.mjs +4 -4
- package/dist/federation/middleware.test.mjs +200 -19
- package/dist/federation/mod.cjs +3 -259
- package/dist/federation/mod.d.cts +4 -4
- package/dist/federation/mod.d.ts +4 -4
- package/dist/federation/mod.js +1 -257
- package/dist/federation/mq.test.mjs +103 -261
- package/dist/federation/negotiation.test.mjs +4 -4
- package/dist/federation/retry.test.mjs +3 -3
- package/dist/federation/router.test.mjs +5 -5
- package/dist/federation/send.test.mjs +10 -10
- package/dist/federation/tasks/codec.test.d.mts +2 -0
- package/dist/federation/tasks/codec.test.mjs +292 -0
- package/dist/federation/tasks/enqueue.test.d.mts +2 -0
- package/dist/federation/tasks/enqueue.test.mjs +992 -0
- package/dist/federation/tasks/tasks.test.d.mts +2 -0
- package/dist/federation/tasks/tasks.test.mjs +555 -0
- package/dist/federation/temporal.test.mjs +4 -4
- package/dist/federation/webfinger.test.mjs +6 -6
- package/dist/{http-C3eJp_Ha.cjs → http-BCj9dlA_.cjs} +1 -1
- package/dist/{http-BqSm-f2G.js → http-Dv3147TL.js} +1 -1
- package/dist/{http-BeDlAH97.mjs → http-inQqS3yx.mjs} +4 -4
- package/dist/{key-DNBTcjuV.mjs → key-CGrr6-I2.mjs} +2 -2
- package/dist/{kv-cache-Crq8nvSV.js → kv-cache-C2oTEXyb.js} +1 -1
- package/dist/{kv-cache-b2HaCLC-.mjs → kv-cache-C3qkFkbt.mjs} +1 -1
- package/dist/{kv-cache-CGJMNSs-.cjs → kv-cache-c8X6svwE.cjs} +1 -1
- package/dist/{ld-CQlFhsU6.mjs → ld-fnWaNT8y.mjs} +3 -3
- package/dist/{metrics-B6RKtTLt.mjs → metrics-C5hMINAa.mjs} +1 -1
- package/dist/{middleware-CQygcRYE.mjs → middleware-CQlq6ykI.mjs} +1 -1
- package/dist/{middleware-CBM9vGYg.cjs → middleware-DeVzbg1I.cjs} +690 -30
- package/dist/{middleware-CsxoclmN.mjs → middleware-Dl2nyVgB.mjs} +306 -46
- package/dist/{middleware-B3vFLcCh.js → middleware-vQ_ZpgcX.js} +679 -31
- package/dist/{mod-vPYVoa5n.d.ts → mod-4WGAuR6X.d.ts} +1 -1
- package/dist/{mod-C0F6kvgS.d.cts → mod-BHEB3xhE.d.cts} +1 -1
- package/dist/mod.cjs +6 -6
- package/dist/mod.d.cts +5 -5
- package/dist/mod.d.ts +5 -5
- package/dist/mod.js +5 -5
- package/dist/mq-03vS-C9P.mjs +276 -0
- package/dist/{mq-D8uSFzxe.d.cts → mq-B5_hohs7.d.ts} +34 -0
- package/dist/{mq-D-nlpY04.d.ts → mq-DXMt_qCY.d.cts} +34 -0
- package/dist/nodeinfo/client.test.mjs +3 -3
- package/dist/nodeinfo/handler.test.mjs +5 -5
- package/dist/nodeinfo/types.test.mjs +4 -4
- package/dist/otel/exporter.test.mjs +3 -3
- package/dist/{outgoing-jsonld-L_DbOaFe.mjs → outgoing-jsonld-BNL8AC14.mjs} +1 -1
- package/dist/{owner-B1FnbZ1w.mjs → owner-Bq2eZyO_.mjs} +2 -2
- package/dist/{proof-ChmZL5rY.cjs → proof-Buz7I8wj.cjs} +1 -1
- package/dist/{proof-BhNTn0HE.js → proof-CTG9azxN.js} +1 -1
- package/dist/{proof-BUuvq0ia.mjs → proof-DZCjcFCd.mjs} +5 -5
- package/dist/{send-Dq-Ofquk.mjs → send-B253S5gN.mjs} +3 -3
- package/dist/sig/accept.test.mjs +1 -1
- package/dist/sig/http.test.mjs +8 -8
- package/dist/sig/key.test.mjs +6 -6
- package/dist/sig/ld.test.mjs +7 -7
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +6 -6
- package/dist/sig/proof.test.mjs +8 -8
- package/dist/{std__assert-BBjXFNOb.mjs → std__assert-Dh6uLf_q.mjs} +4 -4
- package/dist/{temporal-C-vrfOld.mjs → temporal-d6TshGjq.mjs} +1 -1
- package/dist/testing/mod.d.mts +1037 -8
- package/dist/testing/mod.mjs +3 -2
- package/dist/testing-Dy-WhqpN.mjs +77 -0
- package/dist/utils/docloader.test.mjs +6 -6
- package/dist/utils/kv-cache.test.mjs +1 -1
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +9 -7
- /package/dist/{accept-CPkZzmGN.mjs → accept-CgDcxvjV.mjs} +0 -0
- /package/dist/{activity-listener-tztVvlNb.mjs → activity-listener-BeTGV3wc.mjs} +0 -0
- /package/dist/{assert_equals-C-ZRDbaf.mjs → assert_equals-PBVKNMJd.mjs} +0 -0
- /package/dist/{circuit-breaker-CSWsyoef.mjs → circuit-breaker-hJBB6jwA.mjs} +0 -0
- /package/dist/{client-ByXmQhYD.mjs → client-B_A6mfn3.mjs} +0 -0
- /package/dist/{collection-Cc3DVAhE.mjs → collection-Dp5ky45w.mjs} +0 -0
- /package/dist/{keycache-BeU0LCII.mjs → keycache-CaOR6NYg.mjs} +0 -0
- /package/dist/{keys-DGu1NFwu.mjs → keys-CSYsOMFG.mjs} +0 -0
- /package/dist/{kv-rV3vodCc.mjs → kv-CIvR3Non.mjs} +0 -0
- /package/dist/{negotiation-DDstyBvc.mjs → negotiation-m_L2nyS3.mjs} +0 -0
- /package/dist/{public-audience-Cvbr2Gzt.mjs → public-audience-c9zmYKgA.mjs} +0 -0
- /package/dist/{retry-CXg_MBI-.mjs → retry-DI4O-zYl.mjs} +0 -0
- /package/dist/{types-J53Kw7so.mjs → types-BFowWFTT.mjs} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { o as validateCryptoKey } from "./key-
|
|
5
|
-
import { n as doubleKnock } from "./http-
|
|
4
|
+
import { o as validateCryptoKey } from "./key-CGrr6-I2.mjs";
|
|
5
|
+
import { n as doubleKnock } from "./http-inQqS3yx.mjs";
|
|
6
6
|
import { getLogger } from "@logtape/logtape";
|
|
7
|
-
import { UrlError, createActivityPubRequest, getRemoteDocument, logRequest, validatePublicUrl } from "@fedify/vocab-runtime";
|
|
8
7
|
import { curry } from "es-toolkit";
|
|
8
|
+
import { UrlError, createActivityPubRequest, getRemoteDocument, logRequest, validatePublicUrl } from "@fedify/vocab-runtime";
|
|
9
9
|
//#region src/utils/docloader.ts
|
|
10
10
|
const logger = getLogger([
|
|
11
11
|
"fedify",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { t as
|
|
8
|
-
import { r as createFederationBuilder } from "../builder-
|
|
4
|
+
import { t as MemoryKvStore } from "../kv-CIvR3Non.mjs";
|
|
5
|
+
import { t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
|
|
6
|
+
import { r as assertExists } from "../std__assert-Dh6uLf_q.mjs";
|
|
7
|
+
import { t as assertThrows } from "../assert_throws-zN79lgIC.mjs";
|
|
8
|
+
import { r as createFederationBuilder } from "../builder-DlWCek6Z.mjs";
|
|
9
9
|
import { DisallowedOperatorError, DisallowedVarSpecModifierError, DuplicateRouteVariableError, RouteTemplateOptionsNotMatchedError, RouterError } from "@fedify/uri-template";
|
|
10
10
|
import { Activity, Note, Person } from "@fedify/vocab";
|
|
11
11
|
import { test } from "@fedify/fixture";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as
|
|
5
|
-
import "../
|
|
6
|
-
import
|
|
7
|
-
import { t as
|
|
8
|
-
import { n as normalizeCircuitBreakerOptions, r as parseCircuitBreakerKvState, t as CircuitBreaker } from "../circuit-breaker-
|
|
4
|
+
import { t as MemoryKvStore } from "../kv-CIvR3Non.mjs";
|
|
5
|
+
import { t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
|
|
6
|
+
import "../std__assert-Dh6uLf_q.mjs";
|
|
7
|
+
import { t as assertThrows } from "../assert_throws-zN79lgIC.mjs";
|
|
8
|
+
import { n as normalizeCircuitBreakerOptions, r as parseCircuitBreakerKvState, t as CircuitBreaker } from "../circuit-breaker-hJBB6jwA.mjs";
|
|
9
9
|
import { test } from "@fedify/fixture";
|
|
10
10
|
//#region src/federation/circuit-breaker.test.ts
|
|
11
11
|
var AlwaysConflictingKvStore = class extends MemoryKvStore {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as assertEquals } from "../assert_equals-
|
|
5
|
-
import "../std__assert-
|
|
6
|
-
import { n as digest, t as buildCollectionSynchronizationHeader } from "../collection-
|
|
4
|
+
import { t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
|
|
5
|
+
import "../std__assert-Dh6uLf_q.mjs";
|
|
6
|
+
import { n as digest, t as buildCollectionSynchronizationHeader } from "../collection-Dp5ky45w.mjs";
|
|
7
7
|
import { test } from "@fedify/fixture";
|
|
8
8
|
import { decodeHex } from "byte-encodings/hex";
|
|
9
9
|
//#region src/federation/collection.test.ts
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as createOutboxContext, r as createRequestContext, t as createInboxContext } from "../context-
|
|
5
|
-
import { t as
|
|
6
|
-
import "../
|
|
7
|
-
import
|
|
8
|
-
import { t as
|
|
9
|
-
import { t as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { a as
|
|
14
|
-
import {
|
|
15
|
-
import { c as handleActor, d as handleInbox, f as handleObject, h as respondWithObjectIfAcceptable, l as handleCollection, m as respondWithObject, o as createFederation, p as handleOutbox, u as handleCustomCollection } from "../middleware-
|
|
16
|
-
import { t as ActivityListenerSet } from "../activity-listener-
|
|
4
|
+
import { n as createOutboxContext, r as createRequestContext, t as createInboxContext } from "../context-BBRTgkrs.mjs";
|
|
5
|
+
import { t as MemoryKvStore } from "../kv-CIvR3Non.mjs";
|
|
6
|
+
import { t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
|
|
7
|
+
import "../std__assert-Dh6uLf_q.mjs";
|
|
8
|
+
import { n as assertGreaterOrEqual, t as assertRejects } from "../assert_rejects-DAdaaIWM.mjs";
|
|
9
|
+
import { t as assertInstanceOf } from "../assert_instance_of-CxoC8bVq.mjs";
|
|
10
|
+
import { t as assert } from "../assert-DvVHoIZ0.mjs";
|
|
11
|
+
import { r as parseAcceptSignature } from "../accept-CgDcxvjV.mjs";
|
|
12
|
+
import { s as signRequest } from "../http-inQqS3yx.mjs";
|
|
13
|
+
import { a as rsaPrivateKey3, c as rsaPublicKey3, s as rsaPublicKey2 } from "../keys-CSYsOMFG.mjs";
|
|
14
|
+
import { a as compactJsonLd, p as signJsonLd } from "../ld-fnWaNT8y.mjs";
|
|
15
|
+
import { c as handleActor, d as handleInbox, f as handleObject, h as respondWithObjectIfAcceptable, l as handleCollection, m as respondWithObject, o as createFederation, p as handleOutbox, u as handleCustomCollection } from "../middleware-Dl2nyVgB.mjs";
|
|
16
|
+
import { t as ActivityListenerSet } from "../activity-listener-BeTGV3wc.mjs";
|
|
17
17
|
import { Activity, Create, Note, Person, Tombstone } from "@fedify/vocab";
|
|
18
18
|
import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
19
19
|
import { FetchError } from "@fedify/vocab-runtime";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as
|
|
5
|
-
import "../
|
|
6
|
-
import
|
|
7
|
-
import { r as
|
|
8
|
-
import {
|
|
9
|
-
import { o as createFederation } from "../middleware-
|
|
4
|
+
import { t as MemoryKvStore } from "../kv-CIvR3Non.mjs";
|
|
5
|
+
import { t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
|
|
6
|
+
import "../std__assert-Dh6uLf_q.mjs";
|
|
7
|
+
import { n as ed25519PrivateKey, r as ed25519PublicKey, t as ed25519Multikey } from "../keys-CSYsOMFG.mjs";
|
|
8
|
+
import { r as signObject } from "../proof-DZCjcFCd.mjs";
|
|
9
|
+
import { o as createFederation } from "../middleware-Dl2nyVgB.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
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as assertEquals } from "../assert_equals-
|
|
5
|
-
import { t as assertThrows } from "../assert_throws-
|
|
6
|
-
import { t as ActivityListenerSet } from "../activity-listener-
|
|
4
|
+
import { t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
|
|
5
|
+
import { t as assertThrows } from "../assert_throws-zN79lgIC.mjs";
|
|
6
|
+
import { t as ActivityListenerSet } from "../activity-listener-BeTGV3wc.mjs";
|
|
7
7
|
import { Activity, Create, Invite, Offer, Update } from "@fedify/vocab";
|
|
8
8
|
import { test } from "@fedify/fixture";
|
|
9
9
|
//#region src/federation/inbox.test.ts
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as
|
|
5
|
-
import { t as
|
|
6
|
-
import { t as
|
|
7
|
-
import { t as
|
|
8
|
-
import { t as KvKeyCache } from "../keycache-
|
|
4
|
+
import { t as MemoryKvStore } from "../kv-CIvR3Non.mjs";
|
|
5
|
+
import { t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
|
|
6
|
+
import { t as assertInstanceOf } from "../assert_instance_of-CxoC8bVq.mjs";
|
|
7
|
+
import { t as assert } from "../assert-DvVHoIZ0.mjs";
|
|
8
|
+
import { t as KvKeyCache } from "../keycache-CaOR6NYg.mjs";
|
|
9
9
|
import { CryptographicKey, Multikey } from "@fedify/vocab";
|
|
10
10
|
import { test } from "@fedify/fixture";
|
|
11
11
|
//#region src/federation/keycache.test.ts
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as
|
|
5
|
-
import "../
|
|
6
|
-
import
|
|
4
|
+
import { t as MemoryKvStore } from "../kv-CIvR3Non.mjs";
|
|
5
|
+
import { t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
|
|
6
|
+
import "../std__assert-Dh6uLf_q.mjs";
|
|
7
7
|
import { test } from "@fedify/fixture";
|
|
8
8
|
//#region src/federation/kv.test.ts
|
|
9
9
|
test("MemoryKvStore", async (t) => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as assertEquals } from "../assert_equals-
|
|
5
|
-
import "../std__assert-
|
|
6
|
-
import { t as assertRejects } from "../assert_rejects-
|
|
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-
|
|
4
|
+
import { t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
|
|
5
|
+
import "../std__assert-Dh6uLf_q.mjs";
|
|
6
|
+
import { t as assertRejects } from "../assert_rejects-DAdaaIWM.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-C5hMINAa.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";
|
|
@@ -2,31 +2,34 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as esm_default } from "../esm-vrlUxr60.mjs";
|
|
5
|
-
import { t as
|
|
6
|
-
import { r as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { t as
|
|
10
|
-
import { t as
|
|
11
|
-
import { t as
|
|
12
|
-
import { t as
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { a as
|
|
18
|
-
import { t as
|
|
19
|
-
import {
|
|
20
|
-
import { t as
|
|
21
|
-
import {
|
|
22
|
-
import { t as
|
|
5
|
+
import { t as MemoryKvStore } from "../kv-CIvR3Non.mjs";
|
|
6
|
+
import { a as numberSchema, r as envelopeSchema, t as MockQueue } from "../testing-Dy-WhqpN.mjs";
|
|
7
|
+
import { t as assertEquals } from "../assert_equals-PBVKNMJd.mjs";
|
|
8
|
+
import { r as assertExists } from "../std__assert-Dh6uLf_q.mjs";
|
|
9
|
+
import { r as assertFalse, t as assertRejects } from "../assert_rejects-DAdaaIWM.mjs";
|
|
10
|
+
import { t as assertInstanceOf } from "../assert_instance_of-CxoC8bVq.mjs";
|
|
11
|
+
import { t as assertThrows } from "../assert_throws-zN79lgIC.mjs";
|
|
12
|
+
import { t as assertNotEquals } from "../assert_not_equals-C8vcTTA3.mjs";
|
|
13
|
+
import { t as assertStrictEquals } from "../assert_strict_equals-BzqyKuYL.mjs";
|
|
14
|
+
import { t as assert } from "../assert-DvVHoIZ0.mjs";
|
|
15
|
+
import { g as recordInboxActivity } from "../metrics-C5hMINAa.mjs";
|
|
16
|
+
import { l as verifyRequest, s as signRequest } from "../http-inQqS3yx.mjs";
|
|
17
|
+
import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-CSYsOMFG.mjs";
|
|
18
|
+
import { t as getAuthenticatedDocumentLoader } from "../docloader-DAdEN549.mjs";
|
|
19
|
+
import { a as compactJsonLd, h as verifyJsonLd, p as signJsonLd, s as detachSignature } from "../ld-fnWaNT8y.mjs";
|
|
20
|
+
import { t as doesActorOwnKey } from "../owner-Bq2eZyO_.mjs";
|
|
21
|
+
import { i as verifyObject, r as signObject } from "../proof-DZCjcFCd.mjs";
|
|
22
|
+
import { g as handleBenchmarkTrigger, i as KvSpecDeterminer, n as FederationImpl, o as createFederation, r as InboxContextImpl, t as ContextImpl } from "../middleware-Dl2nyVgB.mjs";
|
|
23
|
+
import { t as CircuitBreaker } from "../circuit-breaker-hJBB6jwA.mjs";
|
|
24
|
+
import { t as TaskCodec } from "../codec-CmlPqjNX.mjs";
|
|
23
25
|
import { configure, reset } from "@logtape/logtape";
|
|
24
26
|
import { RouterError } from "@fedify/uri-template";
|
|
25
27
|
import * as vocab from "@fedify/vocab";
|
|
26
|
-
import { Create, Offer, Person, getTypeId, lookupObject } from "@fedify/vocab";
|
|
28
|
+
import { Create, Note, Offer, Person, getTypeId, lookupObject } from "@fedify/vocab";
|
|
27
29
|
import { SpanStatusCode, metrics } from "@opentelemetry/api";
|
|
28
30
|
import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
29
31
|
import { FetchError, getDocumentLoader } from "@fedify/vocab-runtime";
|
|
32
|
+
import { deepStrictEqual, ok, rejects, strictEqual } from "node:assert/strict";
|
|
30
33
|
import serialize from "json-canon";
|
|
31
34
|
import { DataPointType, MeterProvider as MeterProvider$1, MetricReader } from "@opentelemetry/sdk-metrics";
|
|
32
35
|
//#region ../fixture/src/fixtures/example.com/create.json
|
|
@@ -6956,5 +6959,183 @@ test("createFederation() omits instrumentation when no meterProvider is set", ()
|
|
|
6956
6959
|
assertStrictEquals(ctx.documentLoader, mockDocumentLoader);
|
|
6957
6960
|
assertStrictEquals(ctx.contextLoader, mockDocumentLoader);
|
|
6958
6961
|
});
|
|
6962
|
+
const taskCodec = new TaskCodec({ contextLoader: mockDocumentLoader });
|
|
6963
|
+
const decodeEnvelope = (message) => taskCodec.decode(envelopeSchema, message.data);
|
|
6964
|
+
const envelope = (title) => ({
|
|
6965
|
+
note: new Note({ content: title }),
|
|
6966
|
+
title
|
|
6967
|
+
});
|
|
6968
|
+
var RendezvousQueue = class {
|
|
6969
|
+
expected;
|
|
6970
|
+
enqueued = [];
|
|
6971
|
+
#count = 0;
|
|
6972
|
+
#markDispatched;
|
|
6973
|
+
#openGate;
|
|
6974
|
+
dispatched;
|
|
6975
|
+
#gate;
|
|
6976
|
+
constructor(expected) {
|
|
6977
|
+
this.expected = expected;
|
|
6978
|
+
this.dispatched = new Promise((resolve) => {
|
|
6979
|
+
this.#markDispatched = resolve;
|
|
6980
|
+
});
|
|
6981
|
+
this.#gate = new Promise((resolve) => {
|
|
6982
|
+
this.#openGate = resolve;
|
|
6983
|
+
});
|
|
6984
|
+
}
|
|
6985
|
+
release() {
|
|
6986
|
+
this.#openGate();
|
|
6987
|
+
}
|
|
6988
|
+
enqueue(message, options) {
|
|
6989
|
+
this.enqueued.push({
|
|
6990
|
+
message,
|
|
6991
|
+
options
|
|
6992
|
+
});
|
|
6993
|
+
if (++this.#count >= this.expected) this.#markDispatched();
|
|
6994
|
+
return this.#gate;
|
|
6995
|
+
}
|
|
6996
|
+
listen(_handler, _options) {
|
|
6997
|
+
return new Promise(() => {});
|
|
6998
|
+
}
|
|
6999
|
+
};
|
|
7000
|
+
const withTimeout = (promise, ms, message) => {
|
|
7001
|
+
let timer;
|
|
7002
|
+
const timeout = new Promise((_, reject) => {
|
|
7003
|
+
timer = setTimeout(() => reject(new Error(message)), ms);
|
|
7004
|
+
});
|
|
7005
|
+
return Promise.race([promise, timeout]).finally(() => clearTimeout(timer));
|
|
7006
|
+
};
|
|
7007
|
+
const mockOptions = () => ({
|
|
7008
|
+
kv: new MemoryKvStore(),
|
|
7009
|
+
documentLoaderFactory: () => mockDocumentLoader,
|
|
7010
|
+
contextLoaderFactory: () => mockDocumentLoader,
|
|
7011
|
+
manuallyStartQueue: true
|
|
7012
|
+
});
|
|
7013
|
+
test("ContextImpl.enqueueTask()", async (t) => {
|
|
7014
|
+
await t.step("builds the task message envelope and round-trips a vocab payload", async () => {
|
|
7015
|
+
const queue = new MockQueue({ supportsEnqueueMany: true });
|
|
7016
|
+
const federation = createFederation({
|
|
7017
|
+
...mockOptions(),
|
|
7018
|
+
queue: { task: queue }
|
|
7019
|
+
});
|
|
7020
|
+
const task = federation.defineTask("greet", {
|
|
7021
|
+
schema: envelopeSchema,
|
|
7022
|
+
handler: () => {}
|
|
7023
|
+
});
|
|
7024
|
+
const ctx = federation.createContext(new URL("https://example.com/"), void 0);
|
|
7025
|
+
ok(ctx instanceof ContextImpl);
|
|
7026
|
+
await ctx.enqueueTask(task, envelope("greeting"));
|
|
7027
|
+
strictEqual(queue.enqueuedMany.length, 0);
|
|
7028
|
+
strictEqual(queue.enqueued.length, 1);
|
|
7029
|
+
const { message } = queue.enqueued[0];
|
|
7030
|
+
strictEqual(message.type, "task");
|
|
7031
|
+
strictEqual(message.taskName, "greet");
|
|
7032
|
+
strictEqual(message.baseUrl, "https://example.com");
|
|
7033
|
+
strictEqual(message.attempt, 0);
|
|
7034
|
+
ok(/^[0-9a-f-]{36}$/i.test(message.id));
|
|
7035
|
+
ok(Temporal.Instant.from(message.started) instanceof Temporal.Instant);
|
|
7036
|
+
strictEqual(typeof message.traceContext, "object");
|
|
7037
|
+
ok(message.traceContext != null);
|
|
7038
|
+
const decoded = await decodeEnvelope(message);
|
|
7039
|
+
ok(decoded.note instanceof Note);
|
|
7040
|
+
strictEqual(decoded.note.content?.toString(), "greeting");
|
|
7041
|
+
strictEqual(decoded.title, "greeting");
|
|
7042
|
+
});
|
|
7043
|
+
});
|
|
7044
|
+
test("ContextImpl.enqueueTaskMany()", async (t) => {
|
|
7045
|
+
await t.step("round-trips every payload through enqueueMany in order, forwarding options", async () => {
|
|
7046
|
+
const queue = new MockQueue({ supportsEnqueueMany: true });
|
|
7047
|
+
const federation = createFederation({
|
|
7048
|
+
...mockOptions(),
|
|
7049
|
+
queue: { task: queue }
|
|
7050
|
+
});
|
|
7051
|
+
const task = federation.defineTask("bulk", {
|
|
7052
|
+
schema: envelopeSchema,
|
|
7053
|
+
handler: () => {}
|
|
7054
|
+
});
|
|
7055
|
+
const ctx = federation.createContext(new URL("https://example.com/"), void 0);
|
|
7056
|
+
const payloads = [
|
|
7057
|
+
envelope("a"),
|
|
7058
|
+
envelope("b"),
|
|
7059
|
+
envelope("c")
|
|
7060
|
+
];
|
|
7061
|
+
await ctx.enqueueTaskMany(task, payloads, {
|
|
7062
|
+
delay: { seconds: 30 },
|
|
7063
|
+
orderingKey: "batch"
|
|
7064
|
+
});
|
|
7065
|
+
strictEqual(queue.enqueued.length, 0);
|
|
7066
|
+
strictEqual(queue.enqueuedMany.length, 1);
|
|
7067
|
+
const { messages, options } = queue.enqueuedMany[0];
|
|
7068
|
+
ok(options?.delay instanceof Temporal.Duration);
|
|
7069
|
+
strictEqual(options.delay.total("second"), 30);
|
|
7070
|
+
strictEqual(options.orderingKey, "batch");
|
|
7071
|
+
deepStrictEqual((await Promise.all(messages.map(decodeEnvelope))).map((d) => d.title), [
|
|
7072
|
+
"a",
|
|
7073
|
+
"b",
|
|
7074
|
+
"c"
|
|
7075
|
+
]);
|
|
7076
|
+
for (const message of messages) strictEqual(message.orderingKey, "batch");
|
|
7077
|
+
});
|
|
7078
|
+
await t.step("with a single payload uses enqueue() instead of enqueueMany", async () => {
|
|
7079
|
+
const queue = new MockQueue({ supportsEnqueueMany: true });
|
|
7080
|
+
const federation = createFederation({
|
|
7081
|
+
...mockOptions(),
|
|
7082
|
+
queue: { task: queue }
|
|
7083
|
+
});
|
|
7084
|
+
const task = federation.defineTask("bulk-single", {
|
|
7085
|
+
schema: envelopeSchema,
|
|
7086
|
+
handler: () => {}
|
|
7087
|
+
});
|
|
7088
|
+
await federation.createContext(new URL("https://example.com/"), void 0).enqueueTaskMany(task, [envelope("solo")]);
|
|
7089
|
+
strictEqual(queue.enqueuedMany.length, 0);
|
|
7090
|
+
strictEqual(queue.enqueued.length, 1);
|
|
7091
|
+
});
|
|
7092
|
+
await t.step("falls back to concurrent single enqueues, preserving order and options", async () => {
|
|
7093
|
+
const queue = new RendezvousQueue(2);
|
|
7094
|
+
const federation = createFederation({
|
|
7095
|
+
...mockOptions(),
|
|
7096
|
+
queue: { task: queue }
|
|
7097
|
+
});
|
|
7098
|
+
const task = federation.defineTask("bulk-fallback", {
|
|
7099
|
+
schema: envelopeSchema,
|
|
7100
|
+
handler: () => {}
|
|
7101
|
+
});
|
|
7102
|
+
const ctx = federation.createContext(new URL("https://example.com/"), void 0);
|
|
7103
|
+
const payloads = [envelope("x"), envelope("y")];
|
|
7104
|
+
const pending = ctx.enqueueTaskMany(task, payloads, { orderingKey: "batch" });
|
|
7105
|
+
try {
|
|
7106
|
+
await withTimeout(queue.dispatched, 2e3, "fallback did not dispatch enqueues concurrently");
|
|
7107
|
+
strictEqual(queue.enqueued.length, 2);
|
|
7108
|
+
} finally {
|
|
7109
|
+
queue.release();
|
|
7110
|
+
await pending;
|
|
7111
|
+
}
|
|
7112
|
+
deepStrictEqual((await Promise.all(queue.enqueued.map(({ message }) => decodeEnvelope(message)))).map((d) => d.title), ["x", "y"]);
|
|
7113
|
+
for (const { message, options } of queue.enqueued) {
|
|
7114
|
+
strictEqual(message.orderingKey, "batch");
|
|
7115
|
+
strictEqual(options?.orderingKey, "batch");
|
|
7116
|
+
}
|
|
7117
|
+
});
|
|
7118
|
+
await t.step("fallback path aborts the whole batch when one payload is invalid", async () => {
|
|
7119
|
+
const queue = new MockQueue();
|
|
7120
|
+
const federation = createFederation({
|
|
7121
|
+
...mockOptions(),
|
|
7122
|
+
queue: { task: queue }
|
|
7123
|
+
});
|
|
7124
|
+
const task = federation.defineTask("bulk-typed", {
|
|
7125
|
+
schema: numberSchema,
|
|
7126
|
+
handler: () => {}
|
|
7127
|
+
});
|
|
7128
|
+
const ctx = federation.createContext(new URL("https://example.com/"), void 0);
|
|
7129
|
+
await rejects(() => ctx.enqueueTaskMany(task, [
|
|
7130
|
+
1,
|
|
7131
|
+
"two",
|
|
7132
|
+
3
|
|
7133
|
+
]), {
|
|
7134
|
+
name: "TypeError",
|
|
7135
|
+
message: /Task data failed schema validation/
|
|
7136
|
+
});
|
|
7137
|
+
strictEqual(queue.enqueued.length, 0);
|
|
7138
|
+
});
|
|
7139
|
+
});
|
|
6959
7140
|
//#endregion
|
|
6960
7141
|
export {};
|