@fedify/fedify 2.3.0-dev.1021 → 2.3.0-dev.1034
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-Nn2r1dKd.mjs → builder-y06Dq5bp.mjs} +3 -3
- package/dist/chunk-QSgtlS85.mjs +29 -0
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/outgoing-jsonld.test.mjs +1 -1
- package/dist/compat/public-audience.test.mjs +1 -1
- package/dist/compat/transformers.test.mjs +2 -2
- package/dist/{context-Dk_tacqz.mjs → context-7Azky82W.mjs} +3 -2
- package/dist/{context-Bxs4cdIZ.d.cts → context-BKLGj9QO.d.cts} +12 -1
- package/dist/{context-CVNXcFHR.d.ts → context-DrNqYkPw.d.ts} +12 -1
- package/dist/{deno-BnQyJ03o.mjs → deno-DB1H1VHx.mjs} +1 -1
- package/dist/{docloader-mEJ3hsMB.mjs → docloader-3HwiWeYL.mjs} +2 -2
- package/dist/{esm-DVILvP5e.mjs → esm-DhnRLoG9.mjs} +1 -24
- package/dist/execAsync-eck5rbtb.mjs +13 -0
- package/dist/federation/builder.test.mjs +2 -2
- package/dist/federation/collection.test.mjs +1 -1
- package/dist/federation/handler.test.mjs +48 -11
- package/dist/federation/idempotency.test.mjs +4 -4
- package/dist/federation/inbox.test.mjs +1 -1
- package/dist/federation/keycache.test.mjs +2 -2
- package/dist/federation/kv.test.mjs +1 -1
- package/dist/federation/middleware.test.mjs +103 -12
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.d.cts +2 -2
- package/dist/federation/mod.d.ts +2 -2
- package/dist/federation/mod.js +1 -1
- package/dist/federation/negotiation.test.mjs +1 -1
- package/dist/federation/retry.test.mjs +1 -1
- package/dist/federation/send.test.mjs +4540 -11
- package/dist/federation/webfinger.test.mjs +3 -3
- package/dist/getMachineId-bsd-DqZ4QRFp.mjs +29 -0
- package/dist/getMachineId-darwin-DMbbW3m7.mjs +26 -0
- package/dist/getMachineId-linux-lyeD2ug3.mjs +22 -0
- package/dist/getMachineId-unsupported-JuKr57jY.mjs +17 -0
- package/dist/getMachineId-win-Dxyf5pJq.mjs +28 -0
- package/dist/{http-BJ-t29n_.js → http-BUr93aO6.js} +1 -1
- package/dist/{http-CfToB_iu.mjs → http-D9zG-L9N.mjs} +3 -3
- package/dist/{http-D4xMqSqO.cjs → http-FnUTcdMf.cjs} +1 -1
- package/dist/{key-CeANlo1H.mjs → key-CV57mOYH.mjs} +1 -1
- package/dist/{kv-cache-DRwOjOkl.cjs → kv-cache-BG9O8wVV.cjs} +1 -1
- package/dist/{kv-cache-B142kDZL.js → kv-cache-C3esyJFP.js} +1 -1
- package/dist/{ld-CUlVC-TS.mjs → ld-sUf94RJ8.mjs} +2 -2
- package/dist/{middleware-I5XEZ_pZ.cjs → middleware-CKkBrsOD.cjs} +185 -27
- package/dist/{middleware-Cgy7UwfR.mjs → middleware-cMxbPxDe.mjs} +1 -1
- package/dist/{middleware-CysDkaXo.js → middleware-fAuUxD9-.js} +185 -27
- package/dist/{middleware-ASvK22Do.cjs → middleware-ohzkLsW4.cjs} +1 -1
- package/dist/{middleware-BPZEcrMG.mjs → middleware-pb2EqN_r.mjs} +67 -22
- package/dist/{mod-Bc6p4npy.d.ts → mod-B8Z8mBLk.d.ts} +1 -1
- package/dist/{mod-zA6NZHUG.d.cts → mod-DClCOv0M.d.cts} +1 -1
- package/dist/mod.cjs +4 -4
- package/dist/mod.d.cts +2 -2
- package/dist/mod.d.ts +2 -2
- package/dist/mod.js +4 -4
- package/dist/nodeinfo/client.test.mjs +2 -2
- package/dist/nodeinfo/handler.test.mjs +3 -3
- package/dist/nodeinfo/types.test.mjs +1 -1
- package/dist/otel/exporter.test.mjs +25 -22
- package/dist/otel/mod.cjs +6 -5
- package/dist/otel/mod.d.cts +3 -2
- package/dist/otel/mod.d.ts +3 -2
- package/dist/otel/mod.js +6 -5
- package/dist/{outgoing-jsonld-CNmZLixq.mjs → outgoing-jsonld-Bi7n-dEy.mjs} +1 -1
- package/dist/{owner-CuW0S2XY.mjs → owner-DsPgl527.mjs} +2 -2
- package/dist/{proof-oGiWJkX0.cjs → proof-BhJpq_J9.cjs} +1 -1
- package/dist/{proof-CFPGr1xC.mjs → proof-iVfYyJpY.mjs} +4 -4
- package/dist/{proof-CtMmqa09.js → proof-k4mEvvdS.js} +1 -1
- package/dist/send-D-vYdfC6.mjs +306 -0
- package/dist/sig/accept.test.mjs +1 -1
- package/dist/sig/http.test.mjs +4 -4
- package/dist/sig/key.test.mjs +2 -2
- package/dist/sig/ld.test.mjs +3 -3
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +2 -2
- package/dist/sig/proof.test.mjs +3 -3
- package/dist/testing/mod.d.mts +6 -1
- package/dist/testing/mod.mjs +1 -1
- package/dist/utils/docloader.test.mjs +4 -4
- 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 +7 -6
- package/dist/send-dhl-s8G0.mjs +0 -193
- /package/dist/{accept-CPkZzmGN.mjs → accept-CceiKpCy.mjs} +0 -0
- /package/dist/{activity-listener-ell7W1s9.mjs → activity-listener-tztVvlNb.mjs} +0 -0
- /package/dist/{client-D_1QpnWt.mjs → client-CIiz1WX7.mjs} +0 -0
- /package/dist/{collection-D-HqUuA2.mjs → collection-CA3V5zyK.mjs} +0 -0
- /package/dist/{keycache-EGATflN-.mjs → keycache-BeU0LCII.mjs} +0 -0
- /package/dist/{keys-DGu1NFwu.mjs → keys-C3kae-6B.mjs} +0 -0
- /package/dist/{kv-cache-U__xU4qR.mjs → kv-cache-Bmv7tUzz.mjs} +0 -0
- /package/dist/{kv-rV3vodCc.mjs → kv-x2IvBUyq.mjs} +0 -0
- /package/dist/{negotiation-SQvQgUqe.mjs → negotiation-VnHNB0Q5.mjs} +0 -0
- /package/dist/{public-audience-DYFHzm_c.mjs → public-audience-PVTwU_Ex.mjs} +0 -0
- /package/dist/{retry-bMXBL97A.mjs → retry-_VvV0h9f.mjs} +0 -0
- /package/dist/{types-J53Kw7so.mjs → types-BFowWFTT.mjs} +0 -0
package/dist/mod.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ import { URLPattern } from "urlpattern-polyfill";
|
|
|
3
3
|
import { a as InboundService, c as OutboundService, d as Software, f as Usage, i as parseNodeInfo, l as Protocol, n as ParseNodeInfoOptions, o as JsonValue, p as nodeInfoToJson, r as getNodeInfo, s as NodeInfo, t as GetNodeInfoOptions, u as Services } from "./client-AtlibPOU.js";
|
|
4
4
|
import { C as exportJwk, D as importJwk, E as generateCryptoKeyPair, S as KeyCache, T as fetchKeyDetailed, _ as validateAcceptSignature, a as VerifyRequestDetailedResult, b as FetchKeyOptions, c as signRequest, d as AcceptSignatureMember, f as AcceptSignatureParameters, g as parseAcceptSignature, h as fulfillAcceptSignature, i as SignRequestOptions, l as verifyRequest, m as formatAcceptSignature, n as HttpMessageSignaturesSpecDeterminer, o as VerifyRequestFailureReason, p as FulfillAcceptSignatureResult, r as Rfc9421SignRequestOptions, s as VerifyRequestOptions, t as HttpMessageSignaturesSpec, u as verifyRequestDetailed, v as FetchKeyDetailedResult, w as fetchKey, x as FetchKeyResult, y as FetchKeyErrorResult } from "./http-aQzN9Ayi.js";
|
|
5
5
|
import { i as getKeyOwner, n as GetKeyOwnerOptions, r as doesActorOwnKey, t as DoesActorOwnKeyOptions } from "./owner-74ARJ5TL.js";
|
|
6
|
-
import { $ as ParallelMessageQueue, A as FederationKvPrefixes, B as Router, C as IdempotencyKeyCallback, Ct as WebFingerLinksDispatcher, D as ObjectCallbackSetters, Dt as buildCollectionSynchronizationHeader, E as InboxListenerSetters, Et as PageItems, F as RetryContext, G as respondWithObject, H as RouterOptions, I as RetryPolicy, J as InProcessMessageQueueOptions, K as respondWithObjectIfAcceptable, L as createExponentialBackoffPolicy, M as FederationQueueOptions, N as createFederation, O as OutboxListenerSetters, Ot as digest, P as CreateExponentialBackoffPolicyOptions, Q as MessageQueueListenOptions, R as Message, S as FederationStartQueueOptions, St as UnverifiedActivityReason, T as InboxChallengePolicy, Tt as SenderKeyPair, U as RouterRouteResult, V as RouterError, W as RespondWithObjectOptions, X as MessageQueueDepth, Y as MessageQueue, Z as MessageQueueEnqueueOptions, _ as Federatable, _t as OutboxListener, a as GetSignedKeyOptions, at as CollectionCounter, b as FederationFetchOptions, bt as SharedInboxKeyDispatcher, c as ParseUriResult, ct as CustomCollectionCounter, d as SendActivityOptions, dt as InboxErrorHandler, et as ActorAliasMapper, f as SendActivityOptionsForCollection, ft as InboxListener, g as CustomCollectionCallbackSetters, gt as OutboxErrorHandler, h as ConstructorWithTypeId, ht as ObjectDispatcher, i as GetActorOptions, it as AuthorizePredicate, j as FederationOrigin, k as Rfc6570Expression, kt as ActivityTransformer, l as RequestContext, lt as CustomCollectionCursor, m as CollectionCallbackSetters, mt as ObjectAuthorizePredicate, n as Context, nt as ActorHandleMapper, o as InboxContext, ot as CollectionCursor, p as ActorCallbackSetters, pt as NodeInfoDispatcher, q as InProcessMessageQueue, r as ForwardActivityOptions, rt as ActorKeyPairsDispatcher, s as OutboxContext, st as CollectionDispatcher, t as ActorKeyPair, tt as ActorDispatcher, u as RouteActivityOptions, ut as CustomCollectionDispatcher, v as Federation, vt as OutboxListenerErrorHandler, w as IdempotencyStrategy, wt as SendActivityError, x as FederationOptions, xt as UnverifiedActivityHandler, y as FederationBuilder, yt as OutboxPermanentFailureHandler, z as createFederationBuilder } from "./context-
|
|
6
|
+
import { $ as ParallelMessageQueue, A as FederationKvPrefixes, B as Router, C as IdempotencyKeyCallback, Ct as WebFingerLinksDispatcher, D as ObjectCallbackSetters, Dt as buildCollectionSynchronizationHeader, E as InboxListenerSetters, Et as PageItems, F as RetryContext, G as respondWithObject, H as RouterOptions, I as RetryPolicy, J as InProcessMessageQueueOptions, K as respondWithObjectIfAcceptable, L as createExponentialBackoffPolicy, M as FederationQueueOptions, N as createFederation, O as OutboxListenerSetters, Ot as digest, P as CreateExponentialBackoffPolicyOptions, Q as MessageQueueListenOptions, R as Message, S as FederationStartQueueOptions, St as UnverifiedActivityReason, T as InboxChallengePolicy, Tt as SenderKeyPair, U as RouterRouteResult, V as RouterError, W as RespondWithObjectOptions, X as MessageQueueDepth, Y as MessageQueue, Z as MessageQueueEnqueueOptions, _ as Federatable, _t as OutboxListener, a as GetSignedKeyOptions, at as CollectionCounter, b as FederationFetchOptions, bt as SharedInboxKeyDispatcher, c as ParseUriResult, ct as CustomCollectionCounter, d as SendActivityOptions, dt as InboxErrorHandler, et as ActorAliasMapper, f as SendActivityOptionsForCollection, ft as InboxListener, g as CustomCollectionCallbackSetters, gt as OutboxErrorHandler, h as ConstructorWithTypeId, ht as ObjectDispatcher, i as GetActorOptions, it as AuthorizePredicate, j as FederationOrigin, k as Rfc6570Expression, kt as ActivityTransformer, l as RequestContext, lt as CustomCollectionCursor, m as CollectionCallbackSetters, mt as ObjectAuthorizePredicate, n as Context, nt as ActorHandleMapper, o as InboxContext, ot as CollectionCursor, p as ActorCallbackSetters, pt as NodeInfoDispatcher, q as InProcessMessageQueue, r as ForwardActivityOptions, rt as ActorKeyPairsDispatcher, s as OutboxContext, st as CollectionDispatcher, t as ActorKeyPair, tt as ActorDispatcher, u as RouteActivityOptions, ut as CustomCollectionDispatcher, v as Federation, vt as OutboxListenerErrorHandler, w as IdempotencyStrategy, wt as SendActivityError, x as FederationOptions, xt as UnverifiedActivityHandler, y as FederationBuilder, yt as OutboxPermanentFailureHandler, z as createFederationBuilder } from "./context-DrNqYkPw.js";
|
|
7
7
|
import { a as MemoryKvStore, i as KvStoreSetOptions, n as KvStore, r as KvStoreListEntry, t as KvKey } from "./kv-GFYnFoOl.js";
|
|
8
8
|
import { actorDehydrator, autoIdAssigner, getDefaultActivityTransformers } from "./compat/mod.js";
|
|
9
|
-
import { n as handleWebFinger, t as WebFingerHandlerParameters } from "./mod-
|
|
9
|
+
import { n as handleWebFinger, t as WebFingerHandlerParameters } from "./mod-B8Z8mBLk.js";
|
|
10
10
|
import { _ as hasSignatureLike, a as createProof, b as verifySignature, c as verifyObject, d as SignJsonLdOptions, f as VerifyJsonLdOptions, g as detachSignature, h as createSignature, i as VerifyProofOptions, l as verifyProof, m as attachSignature, n as SignObjectOptions, o as hasProofLike, p as VerifySignatureOptions, r as VerifyObjectOptions, s as signObject, t as CreateProofOptions, u as CreateSignatureOptions, v as signJsonLd, y as verifyJsonLd } from "./mod-CR8soWa9.js";
|
|
11
11
|
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./mod-CLgIXe9w.js";
|
|
12
12
|
export * from "@fedify/vocab-runtime";
|
package/dist/mod.js
CHANGED
|
@@ -3,11 +3,11 @@ import "urlpattern-polyfill";
|
|
|
3
3
|
import "./chunk-nlSIicah.js";
|
|
4
4
|
import { n as autoIdAssigner, r as getDefaultActivityTransformers, t as actorDehydrator } from "./transformers-ve6e2xcg.js";
|
|
5
5
|
import "./compat/mod.js";
|
|
6
|
-
import { a as verifyRequestDetailed, c as fetchKeyDetailed, f as formatAcceptSignature, h as validateAcceptSignature, i as verifyRequest, l as generateCryptoKeyPair, m as parseAcceptSignature, o as exportJwk, p as fulfillAcceptSignature, r as signRequest, s as fetchKey, u as importJwk } from "./http-
|
|
7
|
-
import { a as createExponentialBackoffPolicy, c as buildCollectionSynchronizationHeader, d as Router, f as RouterError, i as SendActivityError, l as digest, o as respondWithObject, r as handleWebFinger, s as respondWithObjectIfAcceptable, t as createFederation, u as createFederationBuilder } from "./middleware-
|
|
8
|
-
import { a as verifyProof, c as getKeyOwner, d as detachSignature, f as hasSignatureLike, h as verifySignature, i as verifyObject, l as attachSignature, m as verifyJsonLd, n as hasProofLike, p as signJsonLd, r as signObject, s as doesActorOwnKey, t as createProof, u as createSignature } from "./proof-
|
|
6
|
+
import { a as verifyRequestDetailed, c as fetchKeyDetailed, f as formatAcceptSignature, h as validateAcceptSignature, i as verifyRequest, l as generateCryptoKeyPair, m as parseAcceptSignature, o as exportJwk, p as fulfillAcceptSignature, r as signRequest, s as fetchKey, u as importJwk } from "./http-BUr93aO6.js";
|
|
7
|
+
import { a as createExponentialBackoffPolicy, c as buildCollectionSynchronizationHeader, d as Router, f as RouterError, i as SendActivityError, l as digest, o as respondWithObject, r as handleWebFinger, s as respondWithObjectIfAcceptable, t as createFederation, u as createFederationBuilder } from "./middleware-fAuUxD9-.js";
|
|
8
|
+
import { a as verifyProof, c as getKeyOwner, d as detachSignature, f as hasSignatureLike, h as verifySignature, i as verifyObject, l as attachSignature, m as verifyJsonLd, n as hasProofLike, p as signJsonLd, r as signObject, s as doesActorOwnKey, t as createProof, u as createSignature } from "./proof-k4mEvvdS.js";
|
|
9
9
|
import { n as getNodeInfo, r as parseNodeInfo, t as nodeInfoToJson } from "./types-hvL8ElAs.js";
|
|
10
|
-
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-
|
|
10
|
+
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-C3esyJFP.js";
|
|
11
11
|
import { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue } from "./federation/mod.js";
|
|
12
12
|
import "./nodeinfo/mod.js";
|
|
13
13
|
import "./runtime/mod.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as esm_default } from "../esm-DVILvP5e.mjs";
|
|
5
4
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
6
5
|
import "../std__assert-CRDpx_HF.mjs";
|
|
7
|
-
import {
|
|
6
|
+
import { t as esm_default } from "../esm-DhnRLoG9.mjs";
|
|
7
|
+
import { a as parseProtocol, c as parseUsage, i as parseOutboundService, n as parseInboundService, o as parseServices, r as parseNodeInfo, s as parseSoftware, t as getNodeInfo } from "../client-CIiz1WX7.mjs";
|
|
8
8
|
import { test } from "@fedify/fixture";
|
|
9
9
|
//#region src/nodeinfo/client.test.ts
|
|
10
10
|
test("getNodeInfo()", async (t) => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { r as createRequestContext } from "../context-
|
|
4
|
+
import { r as createRequestContext } from "../context-7Azky82W.mjs";
|
|
5
5
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
6
6
|
import "../std__assert-CRDpx_HF.mjs";
|
|
7
|
-
import { t as MemoryKvStore } from "../kv-
|
|
8
|
-
import { _ as handleNodeInfoJrd, g as handleNodeInfo, o as createFederation } from "../middleware-
|
|
7
|
+
import { t as MemoryKvStore } from "../kv-x2IvBUyq.mjs";
|
|
8
|
+
import { _ as handleNodeInfoJrd, g as handleNodeInfo, o as createFederation } from "../middleware-pb2EqN_r.mjs";
|
|
9
9
|
import { test } from "@fedify/fixture";
|
|
10
10
|
//#region src/nodeinfo/handler.test.ts
|
|
11
11
|
test("handleNodeInfo()", async () => {
|
|
@@ -4,7 +4,7 @@ globalThis.addEventListener = () => {};
|
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
5
|
import "../std__assert-CRDpx_HF.mjs";
|
|
6
6
|
import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
|
|
7
|
-
import { t as nodeInfoToJson } from "../types-
|
|
7
|
+
import { t as nodeInfoToJson } from "../types-BFowWFTT.mjs";
|
|
8
8
|
import { test } from "@fedify/fixture";
|
|
9
9
|
//#region src/nodeinfo/types.test.ts
|
|
10
10
|
test("nodeInfoToJson()", () => {
|
|
@@ -3,7 +3,7 @@ import "urlpattern-polyfill";
|
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
5
|
import "../std__assert-CRDpx_HF.mjs";
|
|
6
|
-
import { t as MemoryKvStore } from "../kv-
|
|
6
|
+
import { t as MemoryKvStore } from "../kv-x2IvBUyq.mjs";
|
|
7
7
|
import { test } from "@fedify/fixture";
|
|
8
8
|
import { SpanKind, SpanStatusCode, TraceFlags } from "@opentelemetry/api";
|
|
9
9
|
import { getLogger } from "@logtape/logtape";
|
|
@@ -159,11 +159,10 @@ var FedifySpanExporter = class {
|
|
|
159
159
|
const attrs = event.attributes;
|
|
160
160
|
if (attrs == null) return null;
|
|
161
161
|
const activityJson = attrs["activitypub.activity.json"];
|
|
162
|
-
if (typeof activityJson !== "string") return null;
|
|
163
162
|
let activityType = "Unknown";
|
|
164
163
|
let activityId;
|
|
165
164
|
let actorId;
|
|
166
|
-
try {
|
|
165
|
+
if (typeof activityJson === "string") try {
|
|
167
166
|
const activity = JSON.parse(activityJson);
|
|
168
167
|
activityType = activity.type ?? "Unknown";
|
|
169
168
|
activityId = activity.id;
|
|
@@ -172,15 +171,17 @@ var FedifySpanExporter = class {
|
|
|
172
171
|
} catch {}
|
|
173
172
|
const inboxUrl = attrs["activitypub.inbox.url"];
|
|
174
173
|
const explicitActivityId = attrs["activitypub.activity.id"];
|
|
174
|
+
const explicitActivityType = attrs["activitypub.activity.type"];
|
|
175
|
+
const explicitActorId = attrs["activitypub.actor.id"];
|
|
175
176
|
return {
|
|
176
177
|
traceId,
|
|
177
178
|
spanId,
|
|
178
179
|
parentSpanId,
|
|
179
180
|
direction: "outbound",
|
|
180
|
-
activityType,
|
|
181
|
+
activityType: typeof explicitActivityType === "string" && explicitActivityType !== "" ? explicitActivityType : activityType,
|
|
181
182
|
activityId: activityId ?? (typeof explicitActivityId === "string" && explicitActivityId !== "" ? explicitActivityId : void 0),
|
|
182
|
-
actorId,
|
|
183
|
-
activityJson,
|
|
183
|
+
actorId: typeof explicitActorId === "string" && explicitActorId !== "" ? explicitActorId : actorId,
|
|
184
|
+
...typeof activityJson === "string" ? { activityJson } : {},
|
|
184
185
|
timestamp: (/* @__PURE__ */ new Date(event.time[0] * 1e3 + event.time[1] / 1e6)).toISOString(),
|
|
185
186
|
inboxUrl: typeof inboxUrl === "string" ? inboxUrl : void 0
|
|
186
187
|
};
|
|
@@ -316,14 +317,17 @@ function createActivityReceivedEvent(options) {
|
|
|
316
317
|
};
|
|
317
318
|
}
|
|
318
319
|
function createActivitySentEvent(options) {
|
|
320
|
+
const attributes = {
|
|
321
|
+
"activitypub.inbox.url": options.inboxUrl,
|
|
322
|
+
"activitypub.activity.id": options.activityId ?? ""
|
|
323
|
+
};
|
|
324
|
+
if (options.activityType != null) attributes["activitypub.activity.type"] = options.activityType;
|
|
325
|
+
if (options.actorId != null) attributes["activitypub.actor.id"] = options.actorId;
|
|
326
|
+
if (options.activityJson != null) attributes["activitypub.activity.json"] = options.activityJson;
|
|
319
327
|
return {
|
|
320
328
|
name: "activitypub.activity.sent",
|
|
321
329
|
time: [17e8, 5e8],
|
|
322
|
-
attributes
|
|
323
|
-
"activitypub.activity.json": options.activityJson,
|
|
324
|
-
"activitypub.inbox.url": options.inboxUrl,
|
|
325
|
-
"activitypub.activity.id": options.activityId ?? ""
|
|
326
|
-
}
|
|
330
|
+
attributes
|
|
327
331
|
};
|
|
328
332
|
}
|
|
329
333
|
test("FedifySpanExporter", async (t) => {
|
|
@@ -376,21 +380,18 @@ test("FedifySpanExporter", async (t) => {
|
|
|
376
380
|
const traceId = "trace789";
|
|
377
381
|
const spanId = "span012";
|
|
378
382
|
const inboxUrl = "https://example.com/users/alice/inbox";
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
id: "https://myserver.com/activities/789",
|
|
383
|
-
actor: "https://myserver.com/users/bob",
|
|
384
|
-
object: "https://example.com/users/alice"
|
|
385
|
-
};
|
|
383
|
+
const activityId = "https://myserver.com/activities/789";
|
|
384
|
+
const activityType = "https://www.w3.org/ns/activitystreams#Accept";
|
|
385
|
+
const actorId = "https://myserver.com/users/bob";
|
|
386
386
|
const span = createMockSpan({
|
|
387
387
|
traceId,
|
|
388
388
|
spanId,
|
|
389
389
|
name: "activitypub.send_activity",
|
|
390
390
|
events: [createActivitySentEvent({
|
|
391
|
-
activityJson: JSON.stringify(activity),
|
|
392
391
|
inboxUrl,
|
|
393
|
-
activityId
|
|
392
|
+
activityId,
|
|
393
|
+
activityType,
|
|
394
|
+
actorId
|
|
394
395
|
})]
|
|
395
396
|
});
|
|
396
397
|
await new Promise((resolve) => {
|
|
@@ -404,8 +405,10 @@ test("FedifySpanExporter", async (t) => {
|
|
|
404
405
|
assertEquals(activities[0].traceId, traceId);
|
|
405
406
|
assertEquals(activities[0].spanId, spanId);
|
|
406
407
|
assertEquals(activities[0].direction, "outbound");
|
|
407
|
-
assertEquals(activities[0].activityType,
|
|
408
|
-
assertEquals(activities[0].activityId,
|
|
408
|
+
assertEquals(activities[0].activityType, activityType);
|
|
409
|
+
assertEquals(activities[0].activityId, activityId);
|
|
410
|
+
assertEquals(activities[0].actorId, actorId);
|
|
411
|
+
assertEquals(activities[0].activityJson, void 0);
|
|
409
412
|
assertEquals(activities[0].inboxUrl, inboxUrl);
|
|
410
413
|
});
|
|
411
414
|
await t.step("export() ignores spans without activity events", async () => {
|
package/dist/otel/mod.cjs
CHANGED
|
@@ -155,11 +155,10 @@ var FedifySpanExporter = class {
|
|
|
155
155
|
const attrs = event.attributes;
|
|
156
156
|
if (attrs == null) return null;
|
|
157
157
|
const activityJson = attrs["activitypub.activity.json"];
|
|
158
|
-
if (typeof activityJson !== "string") return null;
|
|
159
158
|
let activityType = "Unknown";
|
|
160
159
|
let activityId;
|
|
161
160
|
let actorId;
|
|
162
|
-
try {
|
|
161
|
+
if (typeof activityJson === "string") try {
|
|
163
162
|
const activity = JSON.parse(activityJson);
|
|
164
163
|
activityType = activity.type ?? "Unknown";
|
|
165
164
|
activityId = activity.id;
|
|
@@ -168,15 +167,17 @@ var FedifySpanExporter = class {
|
|
|
168
167
|
} catch {}
|
|
169
168
|
const inboxUrl = attrs["activitypub.inbox.url"];
|
|
170
169
|
const explicitActivityId = attrs["activitypub.activity.id"];
|
|
170
|
+
const explicitActivityType = attrs["activitypub.activity.type"];
|
|
171
|
+
const explicitActorId = attrs["activitypub.actor.id"];
|
|
171
172
|
return {
|
|
172
173
|
traceId,
|
|
173
174
|
spanId,
|
|
174
175
|
parentSpanId,
|
|
175
176
|
direction: "outbound",
|
|
176
|
-
activityType,
|
|
177
|
+
activityType: typeof explicitActivityType === "string" && explicitActivityType !== "" ? explicitActivityType : activityType,
|
|
177
178
|
activityId: activityId ?? (typeof explicitActivityId === "string" && explicitActivityId !== "" ? explicitActivityId : void 0),
|
|
178
|
-
actorId,
|
|
179
|
-
activityJson,
|
|
179
|
+
actorId: typeof explicitActorId === "string" && explicitActorId !== "" ? explicitActorId : actorId,
|
|
180
|
+
...typeof activityJson === "string" ? { activityJson } : {},
|
|
180
181
|
timestamp: (/* @__PURE__ */ new Date(event.time[0] * 1e3 + event.time[1] / 1e6)).toISOString(),
|
|
181
182
|
inboxUrl: typeof inboxUrl === "string" ? inboxUrl : void 0
|
|
182
183
|
};
|
package/dist/otel/mod.d.cts
CHANGED
|
@@ -77,9 +77,10 @@ interface TraceActivityRecord {
|
|
|
77
77
|
*/
|
|
78
78
|
readonly actorId?: string;
|
|
79
79
|
/**
|
|
80
|
-
* The full JSON representation of the activity
|
|
80
|
+
* The full JSON representation of the activity, if the span event included
|
|
81
|
+
* it.
|
|
81
82
|
*/
|
|
82
|
-
readonly activityJson
|
|
83
|
+
readonly activityJson?: string;
|
|
83
84
|
/**
|
|
84
85
|
* Whether the activity was verified (for inbound activities).
|
|
85
86
|
*/
|
package/dist/otel/mod.d.ts
CHANGED
|
@@ -79,9 +79,10 @@ interface TraceActivityRecord {
|
|
|
79
79
|
*/
|
|
80
80
|
readonly actorId?: string;
|
|
81
81
|
/**
|
|
82
|
-
* The full JSON representation of the activity
|
|
82
|
+
* The full JSON representation of the activity, if the span event included
|
|
83
|
+
* it.
|
|
83
84
|
*/
|
|
84
|
-
readonly activityJson
|
|
85
|
+
readonly activityJson?: string;
|
|
85
86
|
/**
|
|
86
87
|
* Whether the activity was verified (for inbound activities).
|
|
87
88
|
*/
|
package/dist/otel/mod.js
CHANGED
|
@@ -153,11 +153,10 @@ var FedifySpanExporter = class {
|
|
|
153
153
|
const attrs = event.attributes;
|
|
154
154
|
if (attrs == null) return null;
|
|
155
155
|
const activityJson = attrs["activitypub.activity.json"];
|
|
156
|
-
if (typeof activityJson !== "string") return null;
|
|
157
156
|
let activityType = "Unknown";
|
|
158
157
|
let activityId;
|
|
159
158
|
let actorId;
|
|
160
|
-
try {
|
|
159
|
+
if (typeof activityJson === "string") try {
|
|
161
160
|
const activity = JSON.parse(activityJson);
|
|
162
161
|
activityType = activity.type ?? "Unknown";
|
|
163
162
|
activityId = activity.id;
|
|
@@ -166,15 +165,17 @@ var FedifySpanExporter = class {
|
|
|
166
165
|
} catch {}
|
|
167
166
|
const inboxUrl = attrs["activitypub.inbox.url"];
|
|
168
167
|
const explicitActivityId = attrs["activitypub.activity.id"];
|
|
168
|
+
const explicitActivityType = attrs["activitypub.activity.type"];
|
|
169
|
+
const explicitActorId = attrs["activitypub.actor.id"];
|
|
169
170
|
return {
|
|
170
171
|
traceId,
|
|
171
172
|
spanId,
|
|
172
173
|
parentSpanId,
|
|
173
174
|
direction: "outbound",
|
|
174
|
-
activityType,
|
|
175
|
+
activityType: typeof explicitActivityType === "string" && explicitActivityType !== "" ? explicitActivityType : activityType,
|
|
175
176
|
activityId: activityId ?? (typeof explicitActivityId === "string" && explicitActivityId !== "" ? explicitActivityId : void 0),
|
|
176
|
-
actorId,
|
|
177
|
-
activityJson,
|
|
177
|
+
actorId: typeof explicitActorId === "string" && explicitActorId !== "" ? explicitActorId : actorId,
|
|
178
|
+
...typeof activityJson === "string" ? { activityJson } : {},
|
|
178
179
|
timestamp: (/* @__PURE__ */ new Date(event.time[0] * 1e3 + event.time[1] / 1e6)).toISOString(),
|
|
179
180
|
inboxUrl: typeof inboxUrl === "string" ? inboxUrl : void 0
|
|
180
181
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as preloadedOnlyDocumentLoader, t as normalizePublicAudience } from "./public-audience-
|
|
4
|
+
import { n as preloadedOnlyDocumentLoader, t as normalizePublicAudience } from "./public-audience-PVTwU_Ex.mjs";
|
|
5
5
|
import { preloadedContexts } from "@fedify/vocab-runtime";
|
|
6
6
|
import { getLogger } from "@logtape/logtape";
|
|
7
7
|
import jsonld from "@fedify/vocab-runtime/jsonld";
|
|
@@ -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 "./key-
|
|
4
|
+
import { n as version, t as name } from "./deno-DB1H1VHx.mjs";
|
|
5
|
+
import "./key-CV57mOYH.mjs";
|
|
6
6
|
import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
|
|
7
7
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
8
8
|
import { getDocumentLoader } 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
|
const require_chunk = require("./chunk-DDcVe30Y.cjs");
|
|
4
|
-
const require_http = require("./http-
|
|
4
|
+
const require_http = require("./http-FnUTcdMf.cjs");
|
|
5
5
|
let _logtape_logtape = require("@logtape/logtape");
|
|
6
6
|
let _fedify_vocab = require("@fedify/vocab");
|
|
7
7
|
let _opentelemetry_api = require("@opentelemetry/api");
|
|
@@ -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 fetchKey, o as validateCryptoKey } from "./key-
|
|
6
|
-
import { n as preloadedOnlyDocumentLoader } from "./public-audience-
|
|
7
|
-
import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-
|
|
4
|
+
import { n as version, t as name } from "./deno-DB1H1VHx.mjs";
|
|
5
|
+
import { n as fetchKey, o as validateCryptoKey } from "./key-CV57mOYH.mjs";
|
|
6
|
+
import { n as preloadedOnlyDocumentLoader } from "./public-audience-PVTwU_Ex.mjs";
|
|
7
|
+
import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-Bi7n-dEy.mjs";
|
|
8
8
|
import { Activity, DataIntegrityProof, Multikey, getTypeId } from "@fedify/vocab";
|
|
9
9
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
10
10
|
import { getLogger } from "@logtape/logtape";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
|
-
import { _ as version, d as validateCryptoKey, g as name, s as fetchKey } from "./http-
|
|
3
|
+
import { _ as version, d as validateCryptoKey, g as name, s as fetchKey } from "./http-BUr93aO6.js";
|
|
4
4
|
import { getLogger } from "@logtape/logtape";
|
|
5
5
|
import { Activity, CryptographicKey, DataIntegrityProof, Multikey, Object as Object$1, PUBLIC_COLLECTION, getTypeId, isActor } from "@fedify/vocab";
|
|
6
6
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { n as version, t as name } from "./deno-DB1H1VHx.mjs";
|
|
5
|
+
import { n as doubleKnock } from "./http-D9zG-L9N.mjs";
|
|
6
|
+
import { SpanKind, SpanStatusCode, metrics, trace } from "@opentelemetry/api";
|
|
7
|
+
import { getLogger } from "@logtape/logtape";
|
|
8
|
+
//#region src/federation/metrics.ts
|
|
9
|
+
var FederationMetrics = class {
|
|
10
|
+
deliverySent;
|
|
11
|
+
deliveryPermanentFailure;
|
|
12
|
+
signatureVerificationFailure;
|
|
13
|
+
deliveryDuration;
|
|
14
|
+
inboxProcessingDuration;
|
|
15
|
+
constructor(meterProvider) {
|
|
16
|
+
const meter = meterProvider.getMeter(name, version);
|
|
17
|
+
this.deliverySent = meter.createCounter("activitypub.delivery.sent", {
|
|
18
|
+
description: "ActivityPub delivery attempts.",
|
|
19
|
+
unit: "{attempt}"
|
|
20
|
+
});
|
|
21
|
+
this.deliveryPermanentFailure = meter.createCounter("activitypub.delivery.permanent_failure", {
|
|
22
|
+
description: "ActivityPub deliveries abandoned as permanent failures.",
|
|
23
|
+
unit: "{failure}"
|
|
24
|
+
});
|
|
25
|
+
this.signatureVerificationFailure = meter.createCounter("activitypub.signature.verification_failure", {
|
|
26
|
+
description: "ActivityPub signature verification failures.",
|
|
27
|
+
unit: "{failure}"
|
|
28
|
+
});
|
|
29
|
+
this.deliveryDuration = meter.createHistogram("activitypub.delivery.duration", {
|
|
30
|
+
description: "Duration of ActivityPub delivery attempts.",
|
|
31
|
+
unit: "ms"
|
|
32
|
+
});
|
|
33
|
+
this.inboxProcessingDuration = meter.createHistogram("activitypub.inbox.processing_duration", {
|
|
34
|
+
description: "Duration of ActivityPub inbox listener processing.",
|
|
35
|
+
unit: "ms"
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
recordDelivery(inbox, durationMs, success, activityType) {
|
|
39
|
+
const deliveryAttributes = {
|
|
40
|
+
"activitypub.remote.host": getRemoteHost(inbox),
|
|
41
|
+
"activitypub.delivery.success": success
|
|
42
|
+
};
|
|
43
|
+
if (activityType != null) deliveryAttributes["activitypub.activity.type"] = activityType;
|
|
44
|
+
this.deliverySent.add(1, deliveryAttributes);
|
|
45
|
+
this.deliveryDuration.record(durationMs, deliveryAttributes);
|
|
46
|
+
}
|
|
47
|
+
recordPermanentFailure(inbox, statusCode) {
|
|
48
|
+
this.deliveryPermanentFailure.add(1, {
|
|
49
|
+
"activitypub.remote.host": getRemoteHost(inbox),
|
|
50
|
+
"http.response.status_code": statusCode
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
recordSignatureVerificationFailure(reason, remoteHost) {
|
|
54
|
+
const attributes = { "activitypub.verification.failure_reason": reason };
|
|
55
|
+
if (remoteHost != null) attributes["activitypub.remote.host"] = remoteHost;
|
|
56
|
+
this.signatureVerificationFailure.add(1, attributes);
|
|
57
|
+
}
|
|
58
|
+
recordInboxProcessingDuration(activityType, durationMs) {
|
|
59
|
+
this.inboxProcessingDuration.record(durationMs, { "activitypub.activity.type": activityType });
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const federationMetrics = /* @__PURE__ */ new WeakMap();
|
|
63
|
+
/**
|
|
64
|
+
* Gets the cached Fedify metric instruments for a meter provider.
|
|
65
|
+
* @since 2.3.0
|
|
66
|
+
*/
|
|
67
|
+
function getFederationMetrics(meterProvider = metrics.getMeterProvider()) {
|
|
68
|
+
let instruments = federationMetrics.get(meterProvider);
|
|
69
|
+
if (instruments == null) {
|
|
70
|
+
instruments = new FederationMetrics(meterProvider);
|
|
71
|
+
federationMetrics.set(meterProvider, instruments);
|
|
72
|
+
}
|
|
73
|
+
return instruments;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Gets the bounded remote host attribute value for a URL.
|
|
77
|
+
* @since 2.3.0
|
|
78
|
+
*/
|
|
79
|
+
function getRemoteHost(url) {
|
|
80
|
+
return url.hostname;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Gets an elapsed duration in milliseconds from a `performance.now()` value.
|
|
84
|
+
* @since 2.3.0
|
|
85
|
+
*/
|
|
86
|
+
function getDurationMs(start) {
|
|
87
|
+
return Math.max(0, performance.now() - start);
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/federation/send.ts
|
|
91
|
+
/**
|
|
92
|
+
* Extracts the inbox URLs from recipients.
|
|
93
|
+
* @param parameters The parameters to extract the inboxes.
|
|
94
|
+
* See also {@link ExtractInboxesParameters}.
|
|
95
|
+
* @returns The inboxes as a map of inbox URL to actor URIs.
|
|
96
|
+
*/
|
|
97
|
+
function extractInboxes({ recipients, preferSharedInbox, excludeBaseUris }) {
|
|
98
|
+
const inboxes = {};
|
|
99
|
+
for (const recipient of recipients) {
|
|
100
|
+
let inbox;
|
|
101
|
+
let sharedInbox = false;
|
|
102
|
+
if (preferSharedInbox && recipient.endpoints?.sharedInbox != null) {
|
|
103
|
+
inbox = recipient.endpoints.sharedInbox;
|
|
104
|
+
sharedInbox = true;
|
|
105
|
+
} else inbox = recipient.inboxId;
|
|
106
|
+
if (inbox != null && recipient.id != null) {
|
|
107
|
+
if (excludeBaseUris != null && excludeBaseUris.some((u) => u.origin === inbox?.origin)) continue;
|
|
108
|
+
inboxes[inbox.href] ??= {
|
|
109
|
+
actorIds: /* @__PURE__ */ new Set(),
|
|
110
|
+
sharedInbox
|
|
111
|
+
};
|
|
112
|
+
inboxes[inbox.href].actorIds.add(recipient.id.href);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return inboxes;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Sends an {@link Activity} to an inbox.
|
|
119
|
+
*
|
|
120
|
+
* @param parameters The parameters for sending the activity.
|
|
121
|
+
* See also {@link SendActivityParameters}.
|
|
122
|
+
* @throws {Error} If the activity fails to send.
|
|
123
|
+
*/
|
|
124
|
+
function sendActivity(options) {
|
|
125
|
+
const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
|
|
126
|
+
return tracerProvider.getTracer(name, version).startActiveSpan("activitypub.send_activity", {
|
|
127
|
+
kind: SpanKind.CLIENT,
|
|
128
|
+
attributes: { "activitypub.shared_inbox": options.sharedInbox ?? false }
|
|
129
|
+
}, async (span) => {
|
|
130
|
+
if (options.activityId != null) span.setAttribute("activitypub.activity.id", options.activityId);
|
|
131
|
+
if (options.activityType != null) span.setAttribute("activitypub.activity.type", options.activityType);
|
|
132
|
+
try {
|
|
133
|
+
await sendActivityInternal({
|
|
134
|
+
...options,
|
|
135
|
+
tracerProvider
|
|
136
|
+
}, span);
|
|
137
|
+
} catch (e) {
|
|
138
|
+
span.setStatus({
|
|
139
|
+
code: SpanStatusCode.ERROR,
|
|
140
|
+
message: String(e)
|
|
141
|
+
});
|
|
142
|
+
throw e;
|
|
143
|
+
} finally {
|
|
144
|
+
span.end();
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
const MAX_ERROR_RESPONSE_BODY_BYTES = 1024;
|
|
149
|
+
function getActivityActorId(activity) {
|
|
150
|
+
if (!isRecord(activity)) return void 0;
|
|
151
|
+
return getIdValue(activity.actor);
|
|
152
|
+
}
|
|
153
|
+
function getIdValue(value) {
|
|
154
|
+
if (typeof value === "string" && value !== "") return value;
|
|
155
|
+
if (value instanceof URL) return value.href;
|
|
156
|
+
if (Array.isArray(value)) {
|
|
157
|
+
for (const item of value) {
|
|
158
|
+
const id = getIdValue(item);
|
|
159
|
+
if (id != null) return id;
|
|
160
|
+
}
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (isRecord(value)) return getIdValue(value.id);
|
|
164
|
+
}
|
|
165
|
+
function isRecord(value) {
|
|
166
|
+
return typeof value === "object" && value != null;
|
|
167
|
+
}
|
|
168
|
+
async function readLimitedResponseBody(response, maxBytes) {
|
|
169
|
+
if (response.body == null) return "";
|
|
170
|
+
const reader = response.body.getReader();
|
|
171
|
+
const decoder = new TextDecoder();
|
|
172
|
+
const chunks = [];
|
|
173
|
+
let totalBytes = 0;
|
|
174
|
+
let truncated = false;
|
|
175
|
+
try {
|
|
176
|
+
while (true) {
|
|
177
|
+
const { done, value } = await reader.read();
|
|
178
|
+
if (done) break;
|
|
179
|
+
if (totalBytes + value.length > maxBytes) {
|
|
180
|
+
const remaining = maxBytes - totalBytes;
|
|
181
|
+
if (remaining > 0) chunks.push(decoder.decode(value.slice(0, remaining), { stream: true }));
|
|
182
|
+
truncated = true;
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
chunks.push(decoder.decode(value, { stream: true }));
|
|
186
|
+
totalBytes += value.length;
|
|
187
|
+
}
|
|
188
|
+
} finally {
|
|
189
|
+
reader.releaseLock();
|
|
190
|
+
}
|
|
191
|
+
let result = chunks.join("");
|
|
192
|
+
if (truncated) result += "… (truncated)";
|
|
193
|
+
return result;
|
|
194
|
+
}
|
|
195
|
+
async function sendActivityInternal({ activity, activityId, activityType, keys, inbox, headers, specDeterminer, meterProvider, tracerProvider }, span) {
|
|
196
|
+
const logger = getLogger([
|
|
197
|
+
"fedify",
|
|
198
|
+
"federation",
|
|
199
|
+
"outbox"
|
|
200
|
+
]);
|
|
201
|
+
const federationMetrics = getFederationMetrics(meterProvider);
|
|
202
|
+
const started = performance.now();
|
|
203
|
+
let deliverySuccess = false;
|
|
204
|
+
headers = new Headers(headers);
|
|
205
|
+
headers.set("Content-Type", "application/activity+json");
|
|
206
|
+
const request = new Request(inbox, {
|
|
207
|
+
method: "POST",
|
|
208
|
+
headers,
|
|
209
|
+
body: JSON.stringify(activity)
|
|
210
|
+
});
|
|
211
|
+
let rsaKey = null;
|
|
212
|
+
for (const key of keys) if (key.privateKey.algorithm.name === "RSASSA-PKCS1-v1_5") {
|
|
213
|
+
rsaKey = key;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
if (rsaKey == null) logger.warn("No supported key found to sign the request to {inbox}. The request will be sent without a signature. In order to sign the request, at least one RSASSA-PKCS1-v1_5 key must be provided.", {
|
|
217
|
+
inbox: inbox.href,
|
|
218
|
+
keys: keys.map((pair) => ({
|
|
219
|
+
keyId: pair.keyId.href,
|
|
220
|
+
privateKey: pair.privateKey
|
|
221
|
+
}))
|
|
222
|
+
});
|
|
223
|
+
let response;
|
|
224
|
+
try {
|
|
225
|
+
response = rsaKey == null ? await fetch(request) : await doubleKnock(request, rsaKey, {
|
|
226
|
+
tracerProvider,
|
|
227
|
+
specDeterminer
|
|
228
|
+
});
|
|
229
|
+
} catch (error) {
|
|
230
|
+
logger.error("Failed to send activity {activityId} to {inbox}:\n{error}", {
|
|
231
|
+
activityId,
|
|
232
|
+
inbox: inbox.href,
|
|
233
|
+
error
|
|
234
|
+
});
|
|
235
|
+
federationMetrics.recordDelivery(inbox, getDurationMs(started), false, activityType);
|
|
236
|
+
throw error;
|
|
237
|
+
}
|
|
238
|
+
try {
|
|
239
|
+
if (!response.ok) {
|
|
240
|
+
let error;
|
|
241
|
+
try {
|
|
242
|
+
error = await readLimitedResponseBody(response, MAX_ERROR_RESPONSE_BODY_BYTES);
|
|
243
|
+
} catch (_) {
|
|
244
|
+
error = "";
|
|
245
|
+
}
|
|
246
|
+
logger.error("Failed to send activity {activityId} to {inbox} ({status} {statusText}):\n{error}", {
|
|
247
|
+
activityId,
|
|
248
|
+
inbox: inbox.href,
|
|
249
|
+
status: response.status,
|
|
250
|
+
statusText: response.statusText,
|
|
251
|
+
error
|
|
252
|
+
});
|
|
253
|
+
throw new SendActivityError(inbox, response.status, `Failed to send activity ${activityId} to ${inbox.href} (${response.status} ${response.statusText}):\n${error}`, error);
|
|
254
|
+
}
|
|
255
|
+
deliverySuccess = true;
|
|
256
|
+
const eventAttributes = {
|
|
257
|
+
"activitypub.inbox.url": inbox.href,
|
|
258
|
+
"activitypub.activity.id": activityId ?? ""
|
|
259
|
+
};
|
|
260
|
+
if (activityType != null) eventAttributes["activitypub.activity.type"] = activityType;
|
|
261
|
+
const actorId = getActivityActorId(activity);
|
|
262
|
+
if (actorId != null) eventAttributes["activitypub.actor.id"] = actorId;
|
|
263
|
+
span.addEvent("activitypub.activity.sent", eventAttributes);
|
|
264
|
+
} finally {
|
|
265
|
+
federationMetrics.recordDelivery(inbox, getDurationMs(started), deliverySuccess, activityType);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* An error that is thrown when an activity fails to send to a remote inbox.
|
|
270
|
+
* It contains structured information about the failure, including the HTTP
|
|
271
|
+
* status code, the inbox URL, and the response body.
|
|
272
|
+
* @since 2.0.0
|
|
273
|
+
*/
|
|
274
|
+
var SendActivityError = class extends Error {
|
|
275
|
+
/**
|
|
276
|
+
* The inbox URL that the activity was being sent to.
|
|
277
|
+
*/
|
|
278
|
+
inbox;
|
|
279
|
+
/**
|
|
280
|
+
* The HTTP status code returned by the inbox.
|
|
281
|
+
*/
|
|
282
|
+
statusCode;
|
|
283
|
+
/**
|
|
284
|
+
* The response body from the inbox, if any. Note that this may be
|
|
285
|
+
* truncated to a maximum of 1 KiB to prevent excessive memory consumption
|
|
286
|
+
* when remote servers return large error pages (e.g., Cloudflare error pages).
|
|
287
|
+
* If truncated, the string will end with `"… (truncated)"`.
|
|
288
|
+
*/
|
|
289
|
+
responseBody;
|
|
290
|
+
/**
|
|
291
|
+
* Creates a new {@link SendActivityError}.
|
|
292
|
+
* @param inbox The inbox URL.
|
|
293
|
+
* @param statusCode The HTTP status code.
|
|
294
|
+
* @param message The error message.
|
|
295
|
+
* @param responseBody The response body.
|
|
296
|
+
*/
|
|
297
|
+
constructor(inbox, statusCode, message, responseBody) {
|
|
298
|
+
super(message);
|
|
299
|
+
this.name = "SendActivityError";
|
|
300
|
+
this.inbox = inbox;
|
|
301
|
+
this.statusCode = statusCode;
|
|
302
|
+
this.responseBody = responseBody;
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
//#endregion
|
|
306
|
+
export { getFederationMetrics as a, getDurationMs as i, extractInboxes as n, getRemoteHost as o, sendActivity as r, SendActivityError as t };
|
package/dist/sig/accept.test.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature, t as formatAcceptSignature } from "../accept-
|
|
4
|
+
import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature, t as formatAcceptSignature } from "../accept-CceiKpCy.mjs";
|
|
5
5
|
import { test } from "@fedify/fixture";
|
|
6
6
|
import { deepStrictEqual, strictEqual } from "node:assert/strict";
|
|
7
7
|
//#region src/sig/accept.test.ts
|