@fedify/fedify 2.3.0-dev.1361 → 2.3.0-dev.1367
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/{assert-DikXweDx.mjs → assert-OguE97r2.mjs} +1 -1
- package/dist/{assert_instance_of-C4Ri6VuN.mjs → assert_instance_of-DBC5X09g.mjs} +1 -1
- package/dist/{assert_not_equals--wG9hV7u.mjs → assert_not_equals-DkVK8oqV.mjs} +1 -1
- package/dist/{assert_rejects-DQP-q39h.mjs → assert_rejects-DN60FHPX.mjs} +2 -2
- package/dist/{assert_strict_equals-Dmjbg-bA.mjs → assert_strict_equals-XEgZAlrj.mjs} +1 -1
- package/dist/{assert_throws-4NwKEy2q.mjs → assert_throws-BOkhLGYc.mjs} +1 -1
- package/dist/{builder-Ec1dUgEm.mjs → builder-CsrxMBlC.mjs} +3 -23
- 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-BuGH_Vft.d.cts → context-BBVLF7lx.d.cts} +70 -286
- package/dist/{context-CLtZxCu6.d.ts → context-BU6jSQdo.d.ts} +70 -285
- package/dist/{context-BrIOaBSs.mjs → context-DVoTs_wM.mjs} +1 -7
- package/dist/{deno-C1j4CMgo.mjs → deno-BiUfdE9z.mjs} +1 -1
- package/dist/{docloader-DLb-Mj7i.mjs → docloader-BBJhBveN.mjs} +2 -2
- 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 +19 -200
- 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 +260 -5
- 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/temporal.test.mjs +4 -4
- package/dist/federation/webfinger.test.mjs +6 -6
- package/dist/{http-pFZqYnR0.mjs → http-B57xhg1w.mjs} +4 -4
- package/dist/{http-1oEzWsNL.js → http-BceZYwwH.js} +1 -1
- package/dist/{http-DwM39C9Q.cjs → http-CbSNQzUp.cjs} +1 -1
- package/dist/{key-E-05ikaC.mjs → key-DjYpTdy6.mjs} +2 -2
- package/dist/{kv-cache-CgchQxpw.js → kv-cache-5QIPMDoZ.js} +1 -1
- package/dist/{kv-cache-enboxEhN.cjs → kv-cache-B_Q8LGYW.cjs} +1 -1
- package/dist/{kv-cache-D-OZCnQz.mjs → kv-cache-KKf6uhtv.mjs} +1 -1
- package/dist/{ld-Bi8DPgxi.mjs → ld-OdHhWHdK.mjs} +3 -3
- package/dist/{metrics-BC8TM85p.mjs → metrics-BNeDNuTR.mjs} +1 -1
- package/dist/{middleware-TZyBWL4B.cjs → middleware-7mEPRH-T.cjs} +10 -277
- package/dist/{middleware-B81UTyWc.mjs → middleware-CH8EAw7G.mjs} +1 -1
- package/dist/{middleware-6R3zHHW0.mjs → middleware-CR1Ux5W8.mjs} +23 -182
- package/dist/{middleware-bEYsEa2y.js → middleware-x0QQLtuD.js} +10 -277
- package/dist/{mod-DRokcHeU.d.cts → mod-C0F6kvgS.d.cts} +1 -1
- package/dist/{mod-r-1xOW_C.d.ts → mod-vPYVoa5n.d.ts} +1 -1
- package/dist/mod.cjs +4 -4
- package/dist/mod.d.cts +4 -4
- package/dist/mod.d.ts +4 -4
- package/dist/mod.js +4 -4
- 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-BgFLCJQ_.mjs → outgoing-jsonld-L_DbOaFe.mjs} +1 -1
- package/dist/{owner-9bbtWYCS.mjs → owner-UhADnZlT.mjs} +2 -2
- package/dist/{proof-DS0QOtP2.mjs → proof-B5uQgIa7.mjs} +5 -5
- package/dist/{proof-B45zHTY3.cjs → proof-D7K9-olI.cjs} +1 -1
- package/dist/{proof-CA5R6h5L.js → proof-O2kSrwei.js} +1 -1
- package/dist/{send-CyGRAWkX.mjs → send-Bd2V-sji.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-BTEgfoJo.mjs → std__assert-BBjXFNOb.mjs} +4 -4
- package/dist/{temporal-B82PdoA8.mjs → temporal-BXLwWpMY.mjs} +1 -1
- package/dist/testing/mod.d.mts +7 -378
- package/dist/testing/mod.mjs +2 -3
- 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 +8 -10
- package/dist/codec-Bf-rTqks.mjs +0 -94
- package/dist/federation/tasks/codec.test.d.mts +0 -2
- package/dist/federation/tasks/codec.test.mjs +0 -292
- package/dist/federation/tasks/tasks.test.d.mts +0 -2
- package/dist/federation/tasks/tasks.test.mjs +0 -651
- package/dist/mq-CvJAzRz5.mjs +0 -260
- package/dist/testing-CjYPStvE.mjs +0 -55
- /package/dist/{accept-CceiKpCy.mjs → accept-CPkZzmGN.mjs} +0 -0
- /package/dist/{activity-listener-BeTGV3wc.mjs → activity-listener-tztVvlNb.mjs} +0 -0
- /package/dist/{assert_equals-Ew3jOFa3.mjs → assert_equals-C-ZRDbaf.mjs} +0 -0
- /package/dist/{circuit-breaker-hJBB6jwA.mjs → circuit-breaker-CSWsyoef.mjs} +0 -0
- /package/dist/{client-B_A6mfn3.mjs → client-ByXmQhYD.mjs} +0 -0
- /package/dist/{collection-Dp5ky45w.mjs → collection-Cc3DVAhE.mjs} +0 -0
- /package/dist/{keycache-CaOR6NYg.mjs → keycache-BeU0LCII.mjs} +0 -0
- /package/dist/{keys-C3kae-6B.mjs → keys-DGu1NFwu.mjs} +0 -0
- /package/dist/{kv-x2IvBUyq.mjs → kv-rV3vodCc.mjs} +0 -0
- /package/dist/{negotiation-m_L2nyS3.mjs → negotiation-DDstyBvc.mjs} +0 -0
- /package/dist/{public-audience-N3pyOx2p.mjs → public-audience-Cvbr2Gzt.mjs} +0 -0
- /package/dist/{retry-DI4O-zYl.mjs → retry-CXg_MBI-.mjs} +0 -0
- /package/dist/{types-BFowWFTT.mjs → types-J53Kw7so.mjs} +0 -0
|
@@ -2,16 +2,16 @@ import "@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 assertEquals } from "../assert_equals-
|
|
6
|
-
import "../std__assert-
|
|
7
|
-
import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-
|
|
8
|
-
import { t as assertInstanceOf } from "../assert_instance_of-
|
|
9
|
-
import { t as assertNotEquals } from "../assert_not_equals
|
|
10
|
-
import { t as assert } from "../assert-
|
|
11
|
-
import { l as verifyRequest } from "../http-
|
|
12
|
-
import { i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-
|
|
13
|
-
import { t as doesActorOwnKey } from "../owner-
|
|
14
|
-
import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-
|
|
5
|
+
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
6
|
+
import "../std__assert-BBjXFNOb.mjs";
|
|
7
|
+
import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-DN60FHPX.mjs";
|
|
8
|
+
import { t as assertInstanceOf } from "../assert_instance_of-DBC5X09g.mjs";
|
|
9
|
+
import { t as assertNotEquals } from "../assert_not_equals-DkVK8oqV.mjs";
|
|
10
|
+
import { t as assert } from "../assert-OguE97r2.mjs";
|
|
11
|
+
import { l as verifyRequest } from "../http-B57xhg1w.mjs";
|
|
12
|
+
import { i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DGu1NFwu.mjs";
|
|
13
|
+
import { t as doesActorOwnKey } from "../owner-UhADnZlT.mjs";
|
|
14
|
+
import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-Bd2V-sji.mjs";
|
|
15
15
|
import { Activity, Application, Endpoints, Group, Person, Service } from "@fedify/vocab";
|
|
16
16
|
import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
17
17
|
import { FetchError } from "@fedify/vocab-runtime";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import "../std__assert-
|
|
5
|
-
import { r as assertFalse } from "../assert_rejects-
|
|
6
|
-
import { t as assert } from "../assert-
|
|
7
|
-
import { t as hasMalformedKnownTemporalLiteral } from "../temporal-
|
|
4
|
+
import "../std__assert-BBjXFNOb.mjs";
|
|
5
|
+
import { r as assertFalse } from "../assert_rejects-DN60FHPX.mjs";
|
|
6
|
+
import { t as assert } from "../assert-OguE97r2.mjs";
|
|
7
|
+
import { t as hasMalformedKnownTemporalLiteral } from "../temporal-BXLwWpMY.mjs";
|
|
8
8
|
import { test } from "@fedify/fixture";
|
|
9
9
|
//#region src/federation/temporal.test.ts
|
|
10
10
|
test("hasMalformedKnownTemporalLiteral() detects expanded proof timestamps", async () => {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { r as createRequestContext } from "../context-
|
|
5
|
-
import { t as assertEquals } from "../assert_equals-
|
|
6
|
-
import "../std__assert-
|
|
7
|
-
import { t as assertNotEquals } from "../assert_not_equals
|
|
8
|
-
import { t as MemoryKvStore } from "../kv-
|
|
9
|
-
import { o as createFederation, s as handleWebFinger } from "../middleware-
|
|
4
|
+
import { r as createRequestContext } from "../context-DVoTs_wM.mjs";
|
|
5
|
+
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
6
|
+
import "../std__assert-BBjXFNOb.mjs";
|
|
7
|
+
import { t as assertNotEquals } from "../assert_not_equals-DkVK8oqV.mjs";
|
|
8
|
+
import { t as MemoryKvStore } from "../kv-rV3vodCc.mjs";
|
|
9
|
+
import { o as createFederation, s as handleWebFinger } from "../middleware-CR1Ux5W8.mjs";
|
|
10
10
|
import { Image, Link, Person, Tombstone } from "@fedify/vocab";
|
|
11
11
|
import { createTestMeterProvider, test } from "@fedify/fixture";
|
|
12
12
|
//#region src/federation/webfinger.test.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
-
import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-
|
|
6
|
-
import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature } from "./accept-
|
|
7
|
-
import { o as validateCryptoKey, r as fetchKeyDetailed } from "./key-
|
|
4
|
+
import { n as version, t as name } from "./deno-BiUfdE9z.mjs";
|
|
5
|
+
import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-BNeDNuTR.mjs";
|
|
6
|
+
import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature } from "./accept-CPkZzmGN.mjs";
|
|
7
|
+
import { o as validateCryptoKey, r as fetchKeyDetailed } from "./key-DjYpTdy6.mjs";
|
|
8
8
|
import { getLogger } from "@logtape/logtape";
|
|
9
9
|
import { CryptographicKey } from "@fedify/vocab";
|
|
10
10
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
@@ -10,7 +10,7 @@ import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } fro
|
|
|
10
10
|
import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
|
|
11
11
|
//#region deno.json
|
|
12
12
|
var name = "@fedify/fedify";
|
|
13
|
-
var version = "2.3.0-dev.
|
|
13
|
+
var version = "2.3.0-dev.1367+f5ef3f49";
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/sig/accept.ts
|
|
16
16
|
/**
|
|
@@ -11,7 +11,7 @@ let _opentelemetry_semantic_conventions = require("@opentelemetry/semantic-conve
|
|
|
11
11
|
let byte_encodings_base64 = require("byte-encodings/base64");
|
|
12
12
|
//#region deno.json
|
|
13
13
|
var name = "@fedify/fedify";
|
|
14
|
-
var version = "2.3.0-dev.
|
|
14
|
+
var version = "2.3.0-dev.1367+f5ef3f49";
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/sig/accept.ts
|
|
17
17
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
-
import { _ as recordKeyLookup, n as getDurationMs, t as classifyFetchError } from "./metrics-
|
|
4
|
+
import { n as version, t as name } from "./deno-BiUfdE9z.mjs";
|
|
5
|
+
import { _ as recordKeyLookup, n as getDurationMs, t as classifyFetchError } from "./metrics-BNeDNuTR.mjs";
|
|
6
6
|
import { getLogger } from "@logtape/logtape";
|
|
7
7
|
import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
|
|
8
8
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { C as recordDocumentCache, d as validateCryptoKey, t as doubleKnock } from "./http-
|
|
3
|
+
import { C as recordDocumentCache, d as validateCryptoKey, t as doubleKnock } from "./http-BceZYwwH.js";
|
|
4
4
|
import { getLogger } from "@logtape/logtape";
|
|
5
5
|
import { curry } from "es-toolkit";
|
|
6
6
|
import { UrlError, createActivityPubRequest, getRemoteDocument, logRequest, preloadedContexts, validatePublicUrl } from "@fedify/vocab-runtime";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
3
|
require("./chunk-DDcVe30Y.cjs");
|
|
4
|
-
const require_http = require("./http-
|
|
4
|
+
const require_http = require("./http-CbSNQzUp.cjs");
|
|
5
5
|
let _logtape_logtape = require("@logtape/logtape");
|
|
6
6
|
let es_toolkit = require("es-toolkit");
|
|
7
7
|
let _fedify_vocab_runtime = require("@fedify/vocab-runtime");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { p as recordDocumentCache } from "./metrics-
|
|
4
|
+
import { p as recordDocumentCache } from "./metrics-BNeDNuTR.mjs";
|
|
5
5
|
import { getLogger } from "@logtape/logtape";
|
|
6
6
|
import { preloadedContexts } from "@fedify/vocab-runtime";
|
|
7
7
|
//#region src/utils/kv-cache.ts
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
-
import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-
|
|
6
|
-
import { n as fetchKey, o as validateCryptoKey } from "./key-
|
|
4
|
+
import { n as version, t as name } from "./deno-BiUfdE9z.mjs";
|
|
5
|
+
import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-BNeDNuTR.mjs";
|
|
6
|
+
import { n as fetchKey, o as validateCryptoKey } from "./key-DjYpTdy6.mjs";
|
|
7
7
|
import { getLogger } from "@logtape/logtape";
|
|
8
8
|
import { Activity, CryptographicKey, Object as Object$1, getTypeId } from "@fedify/vocab";
|
|
9
9
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
4
|
+
import { n as version, t as name } from "./deno-BiUfdE9z.mjs";
|
|
5
5
|
import { metrics } from "@opentelemetry/api";
|
|
6
6
|
import { FetchError } from "@fedify/vocab-runtime";
|
|
7
7
|
//#region src/federation/metrics.ts
|
|
@@ -2,10 +2,10 @@ const { Temporal } = require("@js-temporal/polyfill");
|
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
3
|
const require_chunk = require("./chunk-DDcVe30Y.cjs");
|
|
4
4
|
const require_transformers = require("./transformers-NeAONrAq.cjs");
|
|
5
|
-
const require_http = require("./http-
|
|
6
|
-
const require_proof = require("./proof-
|
|
5
|
+
const require_http = require("./http-CbSNQzUp.cjs");
|
|
6
|
+
const require_proof = require("./proof-D7K9-olI.cjs");
|
|
7
7
|
const require_types = require("./types-KC4QAoxe.cjs");
|
|
8
|
-
const require_kv_cache = require("./kv-cache-
|
|
8
|
+
const require_kv_cache = require("./kv-cache-B_Q8LGYW.cjs");
|
|
9
9
|
let _logtape_logtape = require("@logtape/logtape");
|
|
10
10
|
let _fedify_uri_template = require("@fedify/uri-template");
|
|
11
11
|
let _fedify_vocab = require("@fedify/vocab");
|
|
@@ -18,7 +18,6 @@ let _fedify_vocab_runtime_jsonld = require("@fedify/vocab-runtime/jsonld");
|
|
|
18
18
|
_fedify_vocab_runtime_jsonld = require_chunk.__toESM(_fedify_vocab_runtime_jsonld, 1);
|
|
19
19
|
let _fedify_webfinger = require("@fedify/webfinger");
|
|
20
20
|
let _opentelemetry_sdk_metrics = require("@opentelemetry/sdk-metrics");
|
|
21
|
-
let devalue = require("devalue");
|
|
22
21
|
let node_url = require("node:url");
|
|
23
22
|
//#region src/federation/activity-listener.ts
|
|
24
23
|
var ActivityListenerSet = class {
|
|
@@ -109,7 +108,6 @@ var FederationBuilderImpl = class {
|
|
|
109
108
|
idempotencyStrategy;
|
|
110
109
|
collectionTypeIds;
|
|
111
110
|
collectionCallbacks;
|
|
112
|
-
taskDefinitions;
|
|
113
111
|
/**
|
|
114
112
|
* Symbol registry for unique identification of unnamed symbols.
|
|
115
113
|
*/
|
|
@@ -120,7 +118,6 @@ var FederationBuilderImpl = class {
|
|
|
120
118
|
this.objectTypeIds = {};
|
|
121
119
|
this.collectionCallbacks = {};
|
|
122
120
|
this.collectionTypeIds = {};
|
|
123
|
-
this.taskDefinitions = /* @__PURE__ */ new Map();
|
|
124
121
|
}
|
|
125
122
|
/**
|
|
126
123
|
* Builds the federation object.
|
|
@@ -159,7 +156,6 @@ var FederationBuilderImpl = class {
|
|
|
159
156
|
f.unverifiedActivityHandler = this.unverifiedActivityHandler;
|
|
160
157
|
f.outboxPermanentFailureHandler = this.outboxPermanentFailureHandler;
|
|
161
158
|
f.idempotencyStrategy = this.idempotencyStrategy;
|
|
162
|
-
f.taskDefinitions = new Map(this.taskDefinitions);
|
|
163
159
|
return f;
|
|
164
160
|
}
|
|
165
161
|
_getTracer() {
|
|
@@ -292,23 +288,6 @@ var FederationBuilderImpl = class {
|
|
|
292
288
|
setWebFingerLinksDispatcher(dispatcher) {
|
|
293
289
|
this.webFingerLinksDispatcher = dispatcher;
|
|
294
290
|
}
|
|
295
|
-
defineTask(name, options) {
|
|
296
|
-
if (this.taskDefinitions.has(name)) throw new TypeError(`Task ${JSON.stringify(name)} is already defined.`);
|
|
297
|
-
const handle = {
|
|
298
|
-
name,
|
|
299
|
-
schema: options.schema
|
|
300
|
-
};
|
|
301
|
-
this.taskDefinitions.set(name, {
|
|
302
|
-
name,
|
|
303
|
-
schema: options.schema,
|
|
304
|
-
handle,
|
|
305
|
-
handler: options.handler,
|
|
306
|
-
onError: options.onError,
|
|
307
|
-
retryPolicy: options.retryPolicy,
|
|
308
|
-
queue: options.queue
|
|
309
|
-
});
|
|
310
|
-
return handle;
|
|
311
|
-
}
|
|
312
291
|
/**
|
|
313
292
|
* The RFC 6570 template-literal `path` overloads were removed for
|
|
314
293
|
* type-checking efficiency, so the URI variable types can no longer be
|
|
@@ -1414,7 +1393,7 @@ function acceptsJsonLd(request) {
|
|
|
1414
1393
|
}
|
|
1415
1394
|
//#endregion
|
|
1416
1395
|
//#region src/federation/temporal.ts
|
|
1417
|
-
function isPlainObject
|
|
1396
|
+
function isPlainObject(value) {
|
|
1418
1397
|
return typeof value === "object" && value != null && !Array.isArray(value);
|
|
1419
1398
|
}
|
|
1420
1399
|
function normalizeDateTimeLiteral(value) {
|
|
@@ -1452,11 +1431,11 @@ const QUESTION_CLOSED_IRI = "https://www.w3.org/ns/activitystreams#closed";
|
|
|
1452
1431
|
const XSD_DATE_TIME_IRI = "http://www.w3.org/2001/XMLSchema#dateTime";
|
|
1453
1432
|
function hasMalformedExpandedDateTimeLiteral(value) {
|
|
1454
1433
|
if (Array.isArray(value)) return value.some(hasMalformedExpandedDateTimeLiteral);
|
|
1455
|
-
return isPlainObject
|
|
1434
|
+
return isPlainObject(value) && "@value" in value && isMalformedDateTimeLiteral(value["@value"]);
|
|
1456
1435
|
}
|
|
1457
1436
|
function hasMalformedExpandedQuestionClosedLiteral(value) {
|
|
1458
1437
|
if (Array.isArray(value)) return value.some(hasMalformedExpandedQuestionClosedLiteral);
|
|
1459
|
-
if (!isPlainObject
|
|
1438
|
+
if (!isPlainObject(value) || !("@value" in value)) return false;
|
|
1460
1439
|
const literal = value["@value"];
|
|
1461
1440
|
if (typeof literal === "boolean") return false;
|
|
1462
1441
|
if (typeof literal !== "string") return false;
|
|
@@ -1466,11 +1445,11 @@ function hasMalformedExpandedQuestionClosedLiteral(value) {
|
|
|
1466
1445
|
}
|
|
1467
1446
|
function hasMalformedExpandedDurationLiteral(value) {
|
|
1468
1447
|
if (Array.isArray(value)) return value.some(hasMalformedExpandedDurationLiteral);
|
|
1469
|
-
return isPlainObject
|
|
1448
|
+
return isPlainObject(value) && "@value" in value && isMalformedDurationLiteral(value["@value"]);
|
|
1470
1449
|
}
|
|
1471
1450
|
function hasMalformedKnownTemporalLiteralInternal(value, visited) {
|
|
1472
1451
|
if (Array.isArray(value)) return value.some((item) => hasMalformedKnownTemporalLiteralInternal(item, visited));
|
|
1473
|
-
if (!isPlainObject
|
|
1452
|
+
if (!isPlainObject(value)) return false;
|
|
1474
1453
|
if (visited.has(value)) return false;
|
|
1475
1454
|
visited.add(value);
|
|
1476
1455
|
if ("@value" in value) return false;
|
|
@@ -3574,94 +3553,6 @@ function createExponentialBackoffPolicy(options = {}) {
|
|
|
3574
3553
|
};
|
|
3575
3554
|
}
|
|
3576
3555
|
//#endregion
|
|
3577
|
-
//#region src/federation/tasks/codec.ts
|
|
3578
|
-
var TaskCodec = class TaskCodec {
|
|
3579
|
-
options;
|
|
3580
|
-
constructor(options) {
|
|
3581
|
-
this.options = options;
|
|
3582
|
-
}
|
|
3583
|
-
serialize = (data) => (0, devalue.stringifyAsync)(data, { Vocab: this.#stringifyVocab });
|
|
3584
|
-
deserialize = (raw) => this.#revive(/* @__PURE__ */ new Map())((0, devalue.parse)(raw, { Vocab: VocabHolder.from }));
|
|
3585
|
-
/** Validates `data` against `schema`, then serializes it. */
|
|
3586
|
-
encode = async (schema, data) => this.serialize(await TaskCodec.validate(schema, data));
|
|
3587
|
-
/** Deserializes `raw`, then validates the result against `schema`. */
|
|
3588
|
-
decode = async (schema, raw) => TaskCodec.validate(schema, await this.deserialize(raw));
|
|
3589
|
-
static validate = async (schema, data) => getValueIfSchema(await schema["~standard"].validate(data));
|
|
3590
|
-
#stringifyVocab = (value) => isVocab(value) && this.#toWire(value);
|
|
3591
|
-
#toWire = async (value) => ({
|
|
3592
|
-
kind: value instanceof _fedify_vocab.Link ? "link" : "object",
|
|
3593
|
-
jsonLd: await value.toJsonLd({
|
|
3594
|
-
format: "expand",
|
|
3595
|
-
...this.options
|
|
3596
|
-
})
|
|
3597
|
-
});
|
|
3598
|
-
#revive = (seen) => {
|
|
3599
|
-
const inner = async (node) => {
|
|
3600
|
-
if (node === null || typeof node !== "object") return node;
|
|
3601
|
-
if (seen.has(node)) return seen.get(node);
|
|
3602
|
-
for (const reviver of this.#classRevivers) {
|
|
3603
|
-
const out = reviver(seen, inner, node);
|
|
3604
|
-
if (out !== void 0) return await out;
|
|
3605
|
-
}
|
|
3606
|
-
return node;
|
|
3607
|
-
};
|
|
3608
|
-
return inner;
|
|
3609
|
-
};
|
|
3610
|
-
#classRevivers = [
|
|
3611
|
-
classReviver(isInstanceOf(VocabHolder), ({ kind, jsonLd }) => kind === "link" ? _fedify_vocab.Link.fromJsonLd(jsonLd, this.options) : _fedify_vocab.Object.fromJsonLd(jsonLd, this.options), () => {}),
|
|
3612
|
-
classReviver(isInstanceOf(Array), () => [], async (revive, node, arr) => {
|
|
3613
|
-
for (const item of await Array.fromAsync(node, revive)) arr.push(item);
|
|
3614
|
-
}),
|
|
3615
|
-
classReviver(isInstanceOf(Map), () => /* @__PURE__ */ new Map(), async (revive, node, map) => {
|
|
3616
|
-
for (const [k, v] of node) map.set(await revive(k), await revive(v));
|
|
3617
|
-
}),
|
|
3618
|
-
classReviver(isInstanceOf(Set), () => /* @__PURE__ */ new Set(), async (revive, node, set) => {
|
|
3619
|
-
for (const v of await Array.fromAsync(node, revive)) set.add(v);
|
|
3620
|
-
}),
|
|
3621
|
-
classReviver(isPlainObject, () => ({}), async (revive, node, obj) => {
|
|
3622
|
-
for (const [k, v] of globalThis.Object.entries(node)) obj[k] = await revive(v);
|
|
3623
|
-
})
|
|
3624
|
-
];
|
|
3625
|
-
};
|
|
3626
|
-
const isVocab = (value) => value instanceof _fedify_vocab.Object || value instanceof _fedify_vocab.Link;
|
|
3627
|
-
const isPlainObject = (value) => value === null || typeof value !== "object" ? false : isObjectPrototype(globalThis.Object.getPrototypeOf(value));
|
|
3628
|
-
const isObjectPrototype = (proto) => proto === null || proto === globalThis.Object.prototype;
|
|
3629
|
-
const isInstanceOf = (cls) => (v) => v instanceof cls;
|
|
3630
|
-
function getValueIfSchema(result) {
|
|
3631
|
-
assertSchema(result);
|
|
3632
|
-
return result.value;
|
|
3633
|
-
}
|
|
3634
|
-
function assertSchema(result) {
|
|
3635
|
-
if (result.issues && result.issues.length > 0) throw new TypeError(`Task data failed schema validation: ${JSON.stringify(result.issues)}`);
|
|
3636
|
-
}
|
|
3637
|
-
/**
|
|
3638
|
-
* A vocabulary object parked by the synchronous decode reviver, held until
|
|
3639
|
-
* the async revive pass can `fromJsonLd()` it back into an instance.
|
|
3640
|
-
*/
|
|
3641
|
-
var VocabHolder = class VocabHolder {
|
|
3642
|
-
kind;
|
|
3643
|
-
jsonLd;
|
|
3644
|
-
constructor(kind, jsonLd) {
|
|
3645
|
-
this.kind = kind;
|
|
3646
|
-
this.jsonLd = jsonLd;
|
|
3647
|
-
}
|
|
3648
|
-
static from = ({ kind, jsonLd }) => new VocabHolder(kind, jsonLd);
|
|
3649
|
-
};
|
|
3650
|
-
/**
|
|
3651
|
-
* Ties a container filter to its empty-shell `init` and child-filling `set`
|
|
3652
|
-
* through one type parameter—a correlation the heterogeneous reviver list
|
|
3653
|
-
* cannot carry, which previously forced `@ts-ignore` at the dispatch site.
|
|
3654
|
-
*/
|
|
3655
|
-
const classReviver = (filter, init, set) => (seen, revive, node) => {
|
|
3656
|
-
if (!filter(node)) return void 0;
|
|
3657
|
-
return (async () => {
|
|
3658
|
-
const out = await init(node);
|
|
3659
|
-
seen.set(node, out);
|
|
3660
|
-
await set(revive, node, out);
|
|
3661
|
-
return out;
|
|
3662
|
-
})();
|
|
3663
|
-
};
|
|
3664
|
-
//#endregion
|
|
3665
3556
|
//#region src/federation/webfinger.ts
|
|
3666
3557
|
const logger = (0, _logtape_logtape.getLogger)([
|
|
3667
3558
|
"fedify",
|
|
@@ -3986,12 +3877,9 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3986
3877
|
inboxQueue;
|
|
3987
3878
|
outboxQueue;
|
|
3988
3879
|
fanoutQueue;
|
|
3989
|
-
taskQueue;
|
|
3990
3880
|
inboxQueueStarted;
|
|
3991
3881
|
outboxQueueStarted;
|
|
3992
3882
|
fanoutQueueStarted;
|
|
3993
|
-
taskQueueStarted;
|
|
3994
|
-
startedTaskQueues;
|
|
3995
3883
|
manuallyStartQueue;
|
|
3996
3884
|
origin;
|
|
3997
3885
|
documentLoaderFactory;
|
|
@@ -4005,8 +3893,6 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
4005
3893
|
skipSignatureVerification;
|
|
4006
3894
|
outboxRetryPolicy;
|
|
4007
3895
|
inboxRetryPolicy;
|
|
4008
|
-
taskRetryPolicy;
|
|
4009
|
-
taskQueueResolution;
|
|
4010
3896
|
circuitBreaker;
|
|
4011
3897
|
activityTransformers;
|
|
4012
3898
|
_tracerProvider;
|
|
@@ -4052,17 +3938,14 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
4052
3938
|
this.inboxQueue = void 0;
|
|
4053
3939
|
this.outboxQueue = void 0;
|
|
4054
3940
|
this.fanoutQueue = void 0;
|
|
4055
|
-
this.taskQueue = void 0;
|
|
4056
3941
|
} else if ("enqueue" in options.queue && "listen" in options.queue) {
|
|
4057
3942
|
this.inboxQueue = options.queue;
|
|
4058
3943
|
this.outboxQueue = options.queue;
|
|
4059
3944
|
this.fanoutQueue = options.queue;
|
|
4060
|
-
this.taskQueue = void 0;
|
|
4061
3945
|
} else {
|
|
4062
3946
|
this.inboxQueue = options.queue.inbox;
|
|
4063
3947
|
this.outboxQueue = options.queue.outbox;
|
|
4064
3948
|
this.fanoutQueue = options.queue.fanout;
|
|
4065
|
-
this.taskQueue = options.queue.task;
|
|
4066
3949
|
}
|
|
4067
3950
|
if (options.circuitBreaker !== false && this.outboxQueue != null) {
|
|
4068
3951
|
this.circuitBreaker = new CircuitBreaker({
|
|
@@ -4086,8 +3969,6 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
4086
3969
|
this.inboxQueueStarted = false;
|
|
4087
3970
|
this.outboxQueueStarted = false;
|
|
4088
3971
|
this.fanoutQueueStarted = false;
|
|
4089
|
-
this.taskQueueStarted = false;
|
|
4090
|
-
this.startedTaskQueues = /* @__PURE__ */ new Set();
|
|
4091
3972
|
this.manuallyStartQueue = options.manuallyStartQueue ?? false;
|
|
4092
3973
|
if (options.origin != null) if (typeof options.origin === "string") {
|
|
4093
3974
|
if (!URL.canParse(options.origin) || !options.origin.match(/^https?:\/\//)) throw new TypeError(`Invalid origin: ${JSON.stringify(options.origin)}`);
|
|
@@ -4169,8 +4050,6 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
4169
4050
|
this.inboxChallengePolicy = options.inboxChallengePolicy;
|
|
4170
4051
|
this.outboxRetryPolicy = options.outboxRetryPolicy ?? createExponentialBackoffPolicy();
|
|
4171
4052
|
this.inboxRetryPolicy = options.inboxRetryPolicy ?? createExponentialBackoffPolicy();
|
|
4172
|
-
this.taskRetryPolicy = options.taskRetryPolicy ?? createExponentialBackoffPolicy();
|
|
4173
|
-
this.taskQueueResolution = options.taskQueueResolution ?? "fallback";
|
|
4174
4053
|
this.activityTransformers = options.activityTransformers ?? require_transformers.getDefaultActivityTransformers();
|
|
4175
4054
|
this._tracerProvider = options.tracerProvider;
|
|
4176
4055
|
if (benchmarkMode) {
|
|
@@ -4219,14 +4098,8 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
4219
4098
|
_getTracer() {
|
|
4220
4099
|
return this.tracerProvider.getTracer(require_http.name, require_http.version);
|
|
4221
4100
|
}
|
|
4222
|
-
resolveTaskQueue(taskName) {
|
|
4223
|
-
const resolved = this.taskDefinitions.get(taskName)?.queue ?? this.taskQueue;
|
|
4224
|
-
if (resolved != null) return resolved;
|
|
4225
|
-
return this.taskQueueResolution === "strict" ? void 0 : this.outboxQueue;
|
|
4226
|
-
}
|
|
4227
4101
|
async _startQueueInternal(ctxData, signal, queue) {
|
|
4228
|
-
|
|
4229
|
-
if (this.inboxQueue == null && this.outboxQueue == null && this.fanoutQueue == null && this.taskQueue == null && !hasDedicatedTaskQueue) return;
|
|
4102
|
+
if (this.inboxQueue == null && this.outboxQueue == null) return;
|
|
4230
4103
|
const logger = (0, _logtape_logtape.getLogger)([
|
|
4231
4104
|
"fedify",
|
|
4232
4105
|
"federation",
|
|
@@ -4248,26 +4121,6 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
4248
4121
|
this.fanoutQueueStarted = true;
|
|
4249
4122
|
promises.push(this.fanoutQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
|
|
4250
4123
|
}
|
|
4251
|
-
if (this.taskQueue != null && this.taskQueue !== this.inboxQueue && this.taskQueue !== this.outboxQueue && this.taskQueue !== this.fanoutQueue && (queue == null || queue === "task") && !this.taskQueueStarted) {
|
|
4252
|
-
logger.debug("Starting a task worker.");
|
|
4253
|
-
this.taskQueueStarted = true;
|
|
4254
|
-
promises.push(this.taskQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
|
|
4255
|
-
}
|
|
4256
|
-
if (queue == null || queue === "task") {
|
|
4257
|
-
const standardQueues = new Set([
|
|
4258
|
-
this.inboxQueue,
|
|
4259
|
-
this.outboxQueue,
|
|
4260
|
-
this.fanoutQueue,
|
|
4261
|
-
this.taskQueue
|
|
4262
|
-
].filter((q) => q != null));
|
|
4263
|
-
for (const def of this.taskDefinitions.values()) {
|
|
4264
|
-
const taskQueue = def.queue;
|
|
4265
|
-
if (taskQueue == null || standardQueues.has(taskQueue) || this.startedTaskQueues.has(taskQueue)) continue;
|
|
4266
|
-
logger.debug("Starting a worker for a dedicated per-task queue.");
|
|
4267
|
-
this.startedTaskQueues.add(taskQueue);
|
|
4268
|
-
promises.push(taskQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
|
|
4269
|
-
}
|
|
4270
|
-
}
|
|
4271
4124
|
await Promise.all(promises);
|
|
4272
4125
|
}
|
|
4273
4126
|
processQueuedTask(contextData, message) {
|
|
@@ -4389,7 +4242,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
4389
4242
|
}
|
|
4390
4243
|
});
|
|
4391
4244
|
});
|
|
4392
|
-
}
|
|
4245
|
+
}
|
|
4393
4246
|
});
|
|
4394
4247
|
}
|
|
4395
4248
|
async #listenFanoutMessage(data, message) {
|
|
@@ -4953,77 +4806,6 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
4953
4806
|
listenerSpan.end();
|
|
4954
4807
|
});
|
|
4955
4808
|
}
|
|
4956
|
-
async #listenTaskMessage(contextData, message) {
|
|
4957
|
-
const logger = (0, _logtape_logtape.getLogger)([
|
|
4958
|
-
"fedify",
|
|
4959
|
-
"federation",
|
|
4960
|
-
"task"
|
|
4961
|
-
]);
|
|
4962
|
-
const def = this.taskDefinitions.get(message.taskName);
|
|
4963
|
-
if (def == null) {
|
|
4964
|
-
logger.warn("Received a custom task {taskName} with no registered handler; dropping.", { taskName: message.taskName });
|
|
4965
|
-
return;
|
|
4966
|
-
}
|
|
4967
|
-
const context = this.#createContext(new URL(message.baseUrl), contextData);
|
|
4968
|
-
let data;
|
|
4969
|
-
try {
|
|
4970
|
-
data = await context.codec.decode(def.schema, message.data);
|
|
4971
|
-
} catch (error) {
|
|
4972
|
-
logger.error("Custom task {taskName} payload could not be decoded or validated; dropping:\n{error}", {
|
|
4973
|
-
taskName: message.taskName,
|
|
4974
|
-
error
|
|
4975
|
-
});
|
|
4976
|
-
return;
|
|
4977
|
-
}
|
|
4978
|
-
try {
|
|
4979
|
-
await def.handler(context, data);
|
|
4980
|
-
} catch (error) {
|
|
4981
|
-
if (def.onError != null) try {
|
|
4982
|
-
await def.onError(context, error, data);
|
|
4983
|
-
} catch (onErrorError) {
|
|
4984
|
-
logger.error("onError for custom task {taskName} threw:\n{error}", {
|
|
4985
|
-
taskName: message.taskName,
|
|
4986
|
-
error: onErrorError
|
|
4987
|
-
});
|
|
4988
|
-
}
|
|
4989
|
-
const queue = this.resolveTaskQueue(def.name);
|
|
4990
|
-
if (queue?.nativeRetrial) throw error;
|
|
4991
|
-
const retryPolicy = def.retryPolicy ?? this.taskRetryPolicy;
|
|
4992
|
-
let elapsedTime = Temporal.Duration.from({ seconds: 0 });
|
|
4993
|
-
try {
|
|
4994
|
-
elapsedTime = Temporal.Instant.from(message.started).until(Temporal.Now.instant());
|
|
4995
|
-
} catch (parseError) {
|
|
4996
|
-
logger.error("Custom task {taskName} has an unparsable started time {started}; treating elapsedTime as zero:\n{error}", {
|
|
4997
|
-
taskName: message.taskName,
|
|
4998
|
-
started: message.started,
|
|
4999
|
-
error: parseError
|
|
5000
|
-
});
|
|
5001
|
-
}
|
|
5002
|
-
const delay = retryPolicy({
|
|
5003
|
-
elapsedTime,
|
|
5004
|
-
attempts: message.attempt
|
|
5005
|
-
});
|
|
5006
|
-
if (delay != null && queue != null) {
|
|
5007
|
-
logger.error("Custom task {taskName} failed (attempt #{attempt}); retry...:\n{error}", {
|
|
5008
|
-
taskName: message.taskName,
|
|
5009
|
-
attempt: message.attempt,
|
|
5010
|
-
error
|
|
5011
|
-
});
|
|
5012
|
-
const retryMessage = {
|
|
5013
|
-
...message,
|
|
5014
|
-
attempt: message.attempt + 1
|
|
5015
|
-
};
|
|
5016
|
-
await queue.enqueue(retryMessage, {
|
|
5017
|
-
delay: clampNegativeDelay(delay),
|
|
5018
|
-
orderingKey: message.orderingKey
|
|
5019
|
-
});
|
|
5020
|
-
} else logger.error("Custom task {taskName} failed after {attempt} attempts; giving up:\n{error}", {
|
|
5021
|
-
taskName: message.taskName,
|
|
5022
|
-
attempt: message.attempt,
|
|
5023
|
-
error
|
|
5024
|
-
});
|
|
5025
|
-
}
|
|
5026
|
-
}
|
|
5027
4809
|
startQueue(contextData, options = {}) {
|
|
5028
4810
|
return this._startQueueInternal(contextData, options.signal, options.queue);
|
|
5029
4811
|
}
|
|
@@ -5600,7 +5382,6 @@ var ContextImpl = class ContextImpl {
|
|
|
5600
5382
|
documentLoader;
|
|
5601
5383
|
contextLoader;
|
|
5602
5384
|
invokedFromActorKeyPairsDispatcher;
|
|
5603
|
-
#codec;
|
|
5604
5385
|
constructor({ url, federation, data, documentLoader, contextLoader, invokedFromActorKeyPairsDispatcher }) {
|
|
5605
5386
|
this.url = url;
|
|
5606
5387
|
this.federation = federation;
|
|
@@ -5609,15 +5390,6 @@ var ContextImpl = class ContextImpl {
|
|
|
5609
5390
|
this.contextLoader = contextLoader;
|
|
5610
5391
|
this.invokedFromActorKeyPairsDispatcher = invokedFromActorKeyPairsDispatcher;
|
|
5611
5392
|
}
|
|
5612
|
-
/**
|
|
5613
|
-
* A {@link TaskCodec} bound to this context's loaders, used to encode
|
|
5614
|
-
* and decode custom task payloads. Lazily created and cached so a context
|
|
5615
|
-
* that never enqueues or dispatches a task pays nothing.
|
|
5616
|
-
* @internal
|
|
5617
|
-
*/
|
|
5618
|
-
get codec() {
|
|
5619
|
-
return this.#codec ??= new TaskCodec(this);
|
|
5620
|
-
}
|
|
5621
5393
|
clone(data) {
|
|
5622
5394
|
return new ContextImpl({
|
|
5623
5395
|
url: this.url,
|
|
@@ -5936,45 +5708,6 @@ var ContextImpl = class ContextImpl {
|
|
|
5936
5708
|
allowPrivateAddress: this.federation.allowPrivateAddress
|
|
5937
5709
|
});
|
|
5938
5710
|
}
|
|
5939
|
-
async enqueueTask(task, data, options = {}) {
|
|
5940
|
-
await this.#enqueueTasks(task, [data], options);
|
|
5941
|
-
}
|
|
5942
|
-
async enqueueTaskMany(task, payloads, options = {}) {
|
|
5943
|
-
await this.#enqueueTasks(task, payloads, options);
|
|
5944
|
-
}
|
|
5945
|
-
async #enqueueTasks(task, items, options) {
|
|
5946
|
-
const def = this.federation.taskDefinitions.get(task.name);
|
|
5947
|
-
if (def == null || def.handle !== task) throw new TypeError(`Task ${JSON.stringify(task.name)} is not defined on this federation; pass a handle returned by its defineTask().`);
|
|
5948
|
-
const queue = this.federation.resolveTaskQueue(task.name);
|
|
5949
|
-
if (queue == null) throw new TypeError("No message queue is configured for tasks; pass `queue` to createFederation() or to defineTask().");
|
|
5950
|
-
if (items.length < 1) return;
|
|
5951
|
-
const delay = options.delay == null ? void 0 : Temporal.Duration.from(options.delay);
|
|
5952
|
-
const messages = await Promise.all(items.map(this.#encodeTaskMessage(task, options)));
|
|
5953
|
-
if (!this.federation.manuallyStartQueue) this.federation._startQueueInternal(this.data);
|
|
5954
|
-
const enqueueOptions = {
|
|
5955
|
-
delay,
|
|
5956
|
-
orderingKey: options.orderingKey
|
|
5957
|
-
};
|
|
5958
|
-
if (messages.length === 1) await queue.enqueue(messages[0], enqueueOptions);
|
|
5959
|
-
else if (queue.enqueueMany != null) await queue.enqueueMany(messages, enqueueOptions);
|
|
5960
|
-
else await Promise.all(messages.map((m) => queue.enqueue(m, enqueueOptions)));
|
|
5961
|
-
}
|
|
5962
|
-
#encodeTaskMessage = (task, options) => async (data) => {
|
|
5963
|
-
const encoded = await this.codec.encode(task.schema, data);
|
|
5964
|
-
const carrier = {};
|
|
5965
|
-
_opentelemetry_api.propagation.inject(_opentelemetry_api.context.active(), carrier);
|
|
5966
|
-
return {
|
|
5967
|
-
type: "task",
|
|
5968
|
-
id: crypto.randomUUID(),
|
|
5969
|
-
baseUrl: this.origin,
|
|
5970
|
-
taskName: task.name,
|
|
5971
|
-
data: encoded,
|
|
5972
|
-
started: Temporal.Now.instant().toString(),
|
|
5973
|
-
attempt: 0,
|
|
5974
|
-
orderingKey: options.orderingKey,
|
|
5975
|
-
traceContext: carrier
|
|
5976
|
-
};
|
|
5977
|
-
};
|
|
5978
5711
|
sendActivity(sender, recipients, activity, options = {}) {
|
|
5979
5712
|
return this.tracerProvider.getTracer(require_http.name, require_http.version).startActiveSpan(this.federation.outboxQueue == null || options.immediate ? "activitypub.outbox" : "activitypub.fanout", {
|
|
5980
5713
|
kind: this.federation.outboxQueue == null || options.immediate ? _opentelemetry_api.SpanKind.CLIENT : _opentelemetry_api.SpanKind.PRODUCER,
|