@fedify/fedify 2.3.0-dev.1110 → 2.3.0-dev.1114
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_rejects-B-qJtC9Z.mjs → assert_rejects-DQP-q39h.mjs} +27 -2
- package/dist/{builder-B-Y6fwSu.mjs → builder-YlEusQth.mjs} +3 -3
- 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-C0C_sRha.d.cts → context-Ch-ZLyTQ.d.cts} +1 -1
- package/dist/{context-Dqgt8saU.d.ts → context-cSUMk2da.d.ts} +1 -1
- package/dist/{deno-hqC7tKJn.mjs → deno-CF3jMgip.mjs} +1 -1
- package/dist/{docloader-BOEuuXkX.mjs → docloader-BENj6vQ4.mjs} +2 -2
- package/dist/federation/builder.test.mjs +3 -3
- package/dist/federation/collection.test.mjs +2 -2
- package/dist/federation/handler.test.mjs +8 -7
- package/dist/federation/idempotency.test.mjs +5 -5
- package/dist/federation/inbox.test.mjs +1 -1
- package/dist/federation/keycache.test.mjs +1 -1
- package/dist/federation/kv.test.mjs +2 -2
- package/dist/federation/middleware.test.mjs +10 -10
- 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/mq.test.mjs +2 -2
- package/dist/federation/negotiation.test.mjs +2 -2
- package/dist/federation/router.test.mjs +2 -2
- package/dist/federation/send.test.mjs +11 -11
- package/dist/federation/webfinger.test.mjs +3 -3
- package/dist/{getMachineId-bsd-etIyxDet.mjs → getMachineId-bsd-BY01PL1n.mjs} +1 -1
- package/dist/{getMachineId-darwin-D23zTf4g.mjs → getMachineId-darwin-Dr1gkBkp.mjs} +1 -1
- package/dist/{getMachineId-win-Dpap6v5i.mjs → getMachineId-win-QEYwcJiy.mjs} +1 -1
- package/dist/{http-BLopFpvC.mjs → http-BmOZYc-8.mjs} +86 -37
- package/dist/{http-DV0il3vk.cjs → http-CKCgOPkX.cjs} +427 -35
- package/dist/{http-O8MYWwk8.js → http-CpzZ9zsb.js} +393 -37
- package/dist/{http-BDZeS5om.d.ts → http-D6LP89UO.d.ts} +7 -1
- package/dist/{http-C87EWkO0.d.cts → http-D6aw3j2U.d.cts} +7 -1
- package/dist/{key-DW1EVmtP.mjs → key-B4I8H5Lc.mjs} +1 -1
- package/dist/{kv-cache-Dya-TWMe.cjs → kv-cache-DY-XWOqM.cjs} +1 -1
- package/dist/{kv-cache-C3NWWiTg.js → kv-cache-Wc5ezcVW.js} +1 -1
- package/dist/{ld-BNkk2Yal.mjs → ld-B5D5THhl.mjs} +60 -9
- package/dist/{send-hokVCPu6.mjs → metrics-ek3ilf6c.mjs} +53 -221
- package/dist/{middleware-CjzI3aYo.js → middleware-CuZbBw-N.js} +16 -269
- package/dist/{middleware-DA2WTBr4.mjs → middleware-DlcecZMq.mjs} +29 -23
- package/dist/{middleware-D6FbOjuK.mjs → middleware-EI7OU6BR.mjs} +1 -1
- package/dist/{middleware-DUWeXjZR.cjs → middleware-EqTYPG4F.cjs} +45 -298
- package/dist/{mod-DXY9JF28.d.cts → mod-B-Lin9Sy.d.ts} +25 -2
- package/dist/{mod-DHO9lk3D.d.ts → mod-BDhgfjP7.d.cts} +25 -2
- package/dist/{mod-B0rWmfW5.d.cts → mod-BR_BB0bh.d.cts} +1 -1
- package/dist/{mod-Dx3-hqyo.d.ts → mod-C6E8rkcz.d.ts} +1 -1
- package/dist/{mod-BhU_H1I_.d.ts → mod-DLrRb0dx.d.ts} +1 -1
- package/dist/{mod-CLPnQPsv.d.cts → mod-P9tE2WmM.d.cts} +1 -1
- package/dist/mod.cjs +4 -4
- package/dist/mod.d.cts +5 -5
- package/dist/mod.d.ts +5 -5
- 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 +2 -2
- package/dist/otel/exporter.test.mjs +2 -2
- package/dist/{outgoing-jsonld-BgFLCJQ_.mjs → outgoing-jsonld-BNL8AC14.mjs} +1 -1
- package/dist/{owner-jvJAtR5O.mjs → owner-DO810N24.mjs} +2 -2
- package/dist/{proof-mfmHH9j0.mjs → proof-BgfyWv7b.mjs} +25 -7
- package/dist/{proof-BD92WeqV.cjs → proof-DIoqrKnX.cjs} +78 -11
- package/dist/{proof-5kT7OUPV.js → proof-Vd8-1EWh.js} +78 -11
- package/dist/send-CAYXdUTk.mjs +225 -0
- package/dist/sig/accept.test.mjs +1 -1
- package/dist/sig/http.test.mjs +212 -6
- package/dist/sig/key.test.mjs +4 -4
- package/dist/sig/ld.test.mjs +138 -5
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.d.cts +2 -2
- package/dist/sig/mod.d.ts +2 -2
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +4 -4
- package/dist/sig/proof.test.mjs +167 -6
- package/dist/{std__assert-CRDpx_HF.mjs → std__assert-BTEgfoJo.mjs} +2 -27
- package/dist/utils/docloader.test.mjs +5 -5
- package/dist/utils/kv-cache.test.mjs +1 -1
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.d.cts +1 -1
- package/dist/utils/mod.d.ts +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +5 -5
- /package/dist/{accept-CceiKpCy.mjs → accept-CgDcxvjV.mjs} +0 -0
- /package/dist/{activity-listener-tztVvlNb.mjs → activity-listener-BeTGV3wc.mjs} +0 -0
- /package/dist/{client-B_A6mfn3.mjs → client-Bneh_DYR.mjs} +0 -0
- /package/dist/{collection-CA3V5zyK.mjs → collection-Cc3DVAhE.mjs} +0 -0
- /package/dist/{execAsync-DCBrgFiV.mjs → execAsync-Dxb7rNf3.mjs} +0 -0
- /package/dist/{getMachineId-linux-ObI47Hql.mjs → getMachineId-linux-Bbhofx-s.mjs} +0 -0
- /package/dist/{getMachineId-unsupported-Ddu-PFeh.mjs → getMachineId-unsupported-dIOte2Ct.mjs} +0 -0
- /package/dist/{keys-C3kae-6B.mjs → keys-CSYsOMFG.mjs} +0 -0
- /package/dist/{kv-x2IvBUyq.mjs → kv-QHE0oeM3.mjs} +0 -0
- /package/dist/{kv-cache-CiiNwT6W.mjs → kv-cache-DihufyAQ.mjs} +0 -0
- /package/dist/{public-audience-N3pyOx2p.mjs → public-audience-c9zmYKgA.mjs} +0 -0
- /package/dist/{types-BFowWFTT.mjs → types-D09GN0uZ.mjs} +0 -0
|
@@ -2,10 +2,10 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
3
|
import { t as __exportAll } from "./chunk-CRNNMoPX.js";
|
|
4
4
|
import { r as getDefaultActivityTransformers } from "./transformers-BGMIq1cs.js";
|
|
5
|
-
import {
|
|
6
|
-
import { c as getKeyOwner, d as detachSignature, f as hasSignatureLike, i as verifyObject, m as verifyJsonLd, n as hasProofLike, o as normalizeOutgoingActivityJsonLd, p as signJsonLd, r as signObject, s as doesActorOwnKey } from "./proof-
|
|
5
|
+
import { C as version, S as name, _ as recordOutboxEnqueue, a as verifyRequestDetailed, d as validateCryptoKey, f as getDurationMs, h as isAbortError, i as verifyRequest, m as getRemoteHost, n as parseRfc9421SignatureInput, o as exportJwk, p as getFederationMetrics, t as doubleKnock, u as importJwk, v as formatAcceptSignature } from "./http-CpzZ9zsb.js";
|
|
6
|
+
import { c as getKeyOwner, d as detachSignature, f as hasSignatureLike, i as verifyObject, m as verifyJsonLd, n as hasProofLike, o as normalizeOutgoingActivityJsonLd, p as signJsonLd, r as signObject, s as doesActorOwnKey } from "./proof-Vd8-1EWh.js";
|
|
7
7
|
import { n as getNodeInfo, t as nodeInfoToJson } from "./types-CAY3OdLq.js";
|
|
8
|
-
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-
|
|
8
|
+
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-Wc5ezcVW.js";
|
|
9
9
|
import { getLogger, withContext } from "@logtape/logtape";
|
|
10
10
|
import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, Tombstone, getTypeId, lookupObject, traverseCollection } from "@fedify/vocab";
|
|
11
11
|
import { SpanKind, SpanStatusCode, context, metrics, propagation, trace } from "@opentelemetry/api";
|
|
@@ -779,264 +779,6 @@ async function buildCollectionSynchronizationHeader(collectionId, actorIds) {
|
|
|
779
779
|
return `collectionId="${collectionId}", url="${url}", digest="${encodeHex(await digest(actorIds))}"`;
|
|
780
780
|
}
|
|
781
781
|
//#endregion
|
|
782
|
-
//#region src/federation/metrics.ts
|
|
783
|
-
var FederationMetrics = class {
|
|
784
|
-
deliverySent;
|
|
785
|
-
deliveryPermanentFailure;
|
|
786
|
-
signatureVerificationFailure;
|
|
787
|
-
deliveryDuration;
|
|
788
|
-
inboxProcessingDuration;
|
|
789
|
-
httpServerRequestCount;
|
|
790
|
-
httpServerRequestDuration;
|
|
791
|
-
queueTaskEnqueued;
|
|
792
|
-
queueTaskStarted;
|
|
793
|
-
queueTaskCompleted;
|
|
794
|
-
queueTaskFailed;
|
|
795
|
-
queueTaskDuration;
|
|
796
|
-
queueTaskInFlight;
|
|
797
|
-
constructor(meterProvider) {
|
|
798
|
-
const meter = meterProvider.getMeter(name, version);
|
|
799
|
-
this.deliverySent = meter.createCounter("activitypub.delivery.sent", {
|
|
800
|
-
description: "ActivityPub delivery attempts.",
|
|
801
|
-
unit: "{attempt}"
|
|
802
|
-
});
|
|
803
|
-
this.deliveryPermanentFailure = meter.createCounter("activitypub.delivery.permanent_failure", {
|
|
804
|
-
description: "ActivityPub deliveries abandoned as permanent failures.",
|
|
805
|
-
unit: "{failure}"
|
|
806
|
-
});
|
|
807
|
-
this.signatureVerificationFailure = meter.createCounter("activitypub.signature.verification_failure", {
|
|
808
|
-
description: "ActivityPub signature verification failures.",
|
|
809
|
-
unit: "{failure}"
|
|
810
|
-
});
|
|
811
|
-
this.deliveryDuration = meter.createHistogram("activitypub.delivery.duration", {
|
|
812
|
-
description: "Duration of ActivityPub delivery attempts.",
|
|
813
|
-
unit: "ms"
|
|
814
|
-
});
|
|
815
|
-
this.inboxProcessingDuration = meter.createHistogram("activitypub.inbox.processing_duration", {
|
|
816
|
-
description: "Duration of ActivityPub inbox listener processing.",
|
|
817
|
-
unit: "ms"
|
|
818
|
-
});
|
|
819
|
-
this.httpServerRequestCount = meter.createCounter("fedify.http.server.request.count", {
|
|
820
|
-
description: "HTTP requests handled by Federation.fetch().",
|
|
821
|
-
unit: "{request}"
|
|
822
|
-
});
|
|
823
|
-
this.httpServerRequestDuration = meter.createHistogram("fedify.http.server.request.duration", {
|
|
824
|
-
description: "Duration of HTTP requests handled by Federation.fetch().",
|
|
825
|
-
unit: "ms",
|
|
826
|
-
advice: { explicitBucketBoundaries: [
|
|
827
|
-
5,
|
|
828
|
-
10,
|
|
829
|
-
25,
|
|
830
|
-
50,
|
|
831
|
-
75,
|
|
832
|
-
100,
|
|
833
|
-
250,
|
|
834
|
-
500,
|
|
835
|
-
750,
|
|
836
|
-
1e3,
|
|
837
|
-
2500,
|
|
838
|
-
5e3,
|
|
839
|
-
7500,
|
|
840
|
-
1e4
|
|
841
|
-
] }
|
|
842
|
-
});
|
|
843
|
-
this.queueTaskEnqueued = meter.createCounter("fedify.queue.task.enqueued", {
|
|
844
|
-
description: "Tasks Fedify enqueued for inbox, outbox, or fanout work.",
|
|
845
|
-
unit: "{task}"
|
|
846
|
-
});
|
|
847
|
-
this.queueTaskStarted = meter.createCounter("fedify.queue.task.started", {
|
|
848
|
-
description: "Tasks Fedify began processing as a queue worker.",
|
|
849
|
-
unit: "{task}"
|
|
850
|
-
});
|
|
851
|
-
this.queueTaskCompleted = meter.createCounter("fedify.queue.task.completed", {
|
|
852
|
-
description: "Queue tasks Fedify finished processing without throwing.",
|
|
853
|
-
unit: "{task}"
|
|
854
|
-
});
|
|
855
|
-
this.queueTaskFailed = meter.createCounter("fedify.queue.task.failed", {
|
|
856
|
-
description: "Queue tasks Fedify abandoned because processing threw.",
|
|
857
|
-
unit: "{task}"
|
|
858
|
-
});
|
|
859
|
-
this.queueTaskDuration = meter.createHistogram("fedify.queue.task.duration", {
|
|
860
|
-
description: "Duration of queue task processing in Fedify workers.",
|
|
861
|
-
unit: "ms",
|
|
862
|
-
advice: { explicitBucketBoundaries: [
|
|
863
|
-
5,
|
|
864
|
-
10,
|
|
865
|
-
25,
|
|
866
|
-
50,
|
|
867
|
-
75,
|
|
868
|
-
100,
|
|
869
|
-
250,
|
|
870
|
-
500,
|
|
871
|
-
750,
|
|
872
|
-
1e3,
|
|
873
|
-
2500,
|
|
874
|
-
5e3,
|
|
875
|
-
7500,
|
|
876
|
-
1e4
|
|
877
|
-
] }
|
|
878
|
-
});
|
|
879
|
-
this.queueTaskInFlight = meter.createUpDownCounter("fedify.queue.task.in_flight", {
|
|
880
|
-
description: "Queue tasks currently being processed in this Fedify process.",
|
|
881
|
-
unit: "{task}"
|
|
882
|
-
});
|
|
883
|
-
}
|
|
884
|
-
recordDelivery(inbox, durationMs, success, activityType) {
|
|
885
|
-
const deliveryAttributes = {
|
|
886
|
-
"activitypub.remote.host": getRemoteHost(inbox),
|
|
887
|
-
"activitypub.delivery.success": success
|
|
888
|
-
};
|
|
889
|
-
if (activityType != null) deliveryAttributes["activitypub.activity.type"] = activityType;
|
|
890
|
-
this.deliverySent.add(1, deliveryAttributes);
|
|
891
|
-
this.deliveryDuration.record(durationMs, deliveryAttributes);
|
|
892
|
-
}
|
|
893
|
-
recordPermanentFailure(inbox, statusCode) {
|
|
894
|
-
this.deliveryPermanentFailure.add(1, {
|
|
895
|
-
"activitypub.remote.host": getRemoteHost(inbox),
|
|
896
|
-
"http.response.status_code": statusCode
|
|
897
|
-
});
|
|
898
|
-
}
|
|
899
|
-
recordSignatureVerificationFailure(reason, remoteHost) {
|
|
900
|
-
const attributes = { "activitypub.verification.failure_reason": reason };
|
|
901
|
-
if (remoteHost != null) attributes["activitypub.remote.host"] = remoteHost;
|
|
902
|
-
this.signatureVerificationFailure.add(1, attributes);
|
|
903
|
-
}
|
|
904
|
-
recordInboxProcessingDuration(activityType, durationMs) {
|
|
905
|
-
this.inboxProcessingDuration.record(durationMs, { "activitypub.activity.type": activityType });
|
|
906
|
-
}
|
|
907
|
-
recordHttpServerRequest(method, endpoint, durationMs, options = {}) {
|
|
908
|
-
const attributes = {
|
|
909
|
-
"http.request.method": normalizeHttpMethod(method),
|
|
910
|
-
"fedify.endpoint": endpoint
|
|
911
|
-
};
|
|
912
|
-
if (options.statusCode != null) attributes["http.response.status_code"] = options.statusCode;
|
|
913
|
-
if (options.routeTemplate != null) attributes["fedify.route.template"] = options.routeTemplate;
|
|
914
|
-
this.httpServerRequestCount.add(1, attributes);
|
|
915
|
-
this.httpServerRequestDuration.record(durationMs, attributes);
|
|
916
|
-
}
|
|
917
|
-
recordQueueTaskEnqueued(common, attempt) {
|
|
918
|
-
const attributes = buildQueueTaskAttributes(common);
|
|
919
|
-
attributes["fedify.queue.task.attempt"] = attempt;
|
|
920
|
-
this.queueTaskEnqueued.add(1, attributes);
|
|
921
|
-
}
|
|
922
|
-
recordQueueTaskStarted(common) {
|
|
923
|
-
this.queueTaskStarted.add(1, buildQueueTaskAttributes(common));
|
|
924
|
-
}
|
|
925
|
-
incrementQueueTaskInFlight(common) {
|
|
926
|
-
this.queueTaskInFlight.add(1, buildQueueTaskInFlightAttributes(common));
|
|
927
|
-
}
|
|
928
|
-
decrementQueueTaskInFlight(common) {
|
|
929
|
-
this.queueTaskInFlight.add(-1, buildQueueTaskInFlightAttributes(common));
|
|
930
|
-
}
|
|
931
|
-
recordQueueTaskOutcome(common, result, durationMs) {
|
|
932
|
-
const attributes = buildQueueTaskAttributes(common);
|
|
933
|
-
attributes["fedify.queue.task.result"] = result;
|
|
934
|
-
if (result === "completed") this.queueTaskCompleted.add(1, attributes);
|
|
935
|
-
else if (result === "failed") this.queueTaskFailed.add(1, attributes);
|
|
936
|
-
this.queueTaskDuration.record(durationMs, attributes);
|
|
937
|
-
}
|
|
938
|
-
};
|
|
939
|
-
function buildQueueTaskAttributes(common) {
|
|
940
|
-
const attributes = { "fedify.queue.role": common.role };
|
|
941
|
-
const backend = getQueueBackend(common.queue);
|
|
942
|
-
if (backend != null) attributes["fedify.queue.backend"] = backend;
|
|
943
|
-
const nativeRetrial = common.queue?.nativeRetrial;
|
|
944
|
-
if (typeof nativeRetrial === "boolean") attributes["fedify.queue.native_retrial"] = nativeRetrial;
|
|
945
|
-
if (common.activityType != null) attributes["activitypub.activity.type"] = common.activityType;
|
|
946
|
-
return attributes;
|
|
947
|
-
}
|
|
948
|
-
function buildQueueTaskInFlightAttributes(common) {
|
|
949
|
-
return buildQueueTaskAttributes({
|
|
950
|
-
role: common.role,
|
|
951
|
-
queue: common.queue
|
|
952
|
-
});
|
|
953
|
-
}
|
|
954
|
-
/**
|
|
955
|
-
* Returns the constructor name of the given message queue, when it is a
|
|
956
|
-
* meaningful identifier. Used as a best-effort `fedify.queue.backend`
|
|
957
|
-
* attribute on queue task metrics; returns `undefined` for plain object
|
|
958
|
-
* literals (whose constructor is `Object`) so the attribute does not appear
|
|
959
|
-
* with a non-informative value.
|
|
960
|
-
* @since 2.3.0
|
|
961
|
-
*/
|
|
962
|
-
function getQueueBackend(queue) {
|
|
963
|
-
const name = queue?.constructor?.name;
|
|
964
|
-
if (name == null || name === "" || name === "Object") return void 0;
|
|
965
|
-
return name;
|
|
966
|
-
}
|
|
967
|
-
/**
|
|
968
|
-
* Records `fedify.queue.task.enqueued` for an outgoing outbox enqueue.
|
|
969
|
-
*
|
|
970
|
-
* Both `Context.sendActivity()` and `OutboxContext.forwardActivity()` enqueue
|
|
971
|
-
* outbox messages with the same metric attributes (role, queue, activity
|
|
972
|
-
* type, attempt), so they share this helper rather than each defining a local
|
|
973
|
-
* closure.
|
|
974
|
-
* @since 2.3.0
|
|
975
|
-
*/
|
|
976
|
-
function recordOutboxEnqueue(meterProvider, outboxQueue, message) {
|
|
977
|
-
getFederationMetrics(meterProvider).recordQueueTaskEnqueued({
|
|
978
|
-
role: "outbox",
|
|
979
|
-
queue: outboxQueue,
|
|
980
|
-
activityType: message.activityType
|
|
981
|
-
}, message.attempt);
|
|
982
|
-
}
|
|
983
|
-
/**
|
|
984
|
-
* Whether the given thrown value is an `AbortError`.
|
|
985
|
-
*
|
|
986
|
-
* `processQueuedTask` distinguishes aborted tasks (recorded as
|
|
987
|
-
* `fedify.queue.task.result=aborted`) from other failures so that backend
|
|
988
|
-
* shutdown signals do not inflate the `fedify.queue.task.failed` counter.
|
|
989
|
-
* @since 2.3.0
|
|
990
|
-
*/
|
|
991
|
-
function isAbortError(error) {
|
|
992
|
-
if (error == null || typeof error !== "object") return false;
|
|
993
|
-
const name = error.name;
|
|
994
|
-
return typeof name === "string" && name === "AbortError";
|
|
995
|
-
}
|
|
996
|
-
const KNOWN_HTTP_METHODS = new Set([
|
|
997
|
-
"CONNECT",
|
|
998
|
-
"DELETE",
|
|
999
|
-
"GET",
|
|
1000
|
-
"HEAD",
|
|
1001
|
-
"OPTIONS",
|
|
1002
|
-
"PATCH",
|
|
1003
|
-
"POST",
|
|
1004
|
-
"PUT",
|
|
1005
|
-
"QUERY",
|
|
1006
|
-
"TRACE"
|
|
1007
|
-
]);
|
|
1008
|
-
function normalizeHttpMethod(method) {
|
|
1009
|
-
const upper = method.toUpperCase();
|
|
1010
|
-
return KNOWN_HTTP_METHODS.has(upper) ? upper : "_OTHER";
|
|
1011
|
-
}
|
|
1012
|
-
const federationMetrics = /* @__PURE__ */ new WeakMap();
|
|
1013
|
-
/**
|
|
1014
|
-
* Gets the cached Fedify metric instruments for a meter provider.
|
|
1015
|
-
* @since 2.3.0
|
|
1016
|
-
*/
|
|
1017
|
-
function getFederationMetrics(meterProvider = metrics.getMeterProvider()) {
|
|
1018
|
-
let instruments = federationMetrics.get(meterProvider);
|
|
1019
|
-
if (instruments == null) {
|
|
1020
|
-
instruments = new FederationMetrics(meterProvider);
|
|
1021
|
-
federationMetrics.set(meterProvider, instruments);
|
|
1022
|
-
}
|
|
1023
|
-
return instruments;
|
|
1024
|
-
}
|
|
1025
|
-
/**
|
|
1026
|
-
* Gets the bounded remote host attribute value for a URL.
|
|
1027
|
-
* @since 2.3.0
|
|
1028
|
-
*/
|
|
1029
|
-
function getRemoteHost(url) {
|
|
1030
|
-
return url.hostname;
|
|
1031
|
-
}
|
|
1032
|
-
/**
|
|
1033
|
-
* Gets an elapsed duration in milliseconds from a `performance.now()` value.
|
|
1034
|
-
* @since 2.3.0
|
|
1035
|
-
*/
|
|
1036
|
-
function getDurationMs(start) {
|
|
1037
|
-
return Math.max(0, performance.now() - start);
|
|
1038
|
-
}
|
|
1039
|
-
//#endregion
|
|
1040
782
|
//#region src/federation/inbox.ts
|
|
1041
783
|
async function routeActivity({ context: ctx, json, activity, recipient, inboxListeners, inboxContextFactory, inboxErrorHandler, kv, kvPrefixes, queue, span, meterProvider, tracerProvider, idempotencyStrategy }) {
|
|
1042
784
|
const logger = getLogger([
|
|
@@ -1442,8 +1184,8 @@ async function handleObject(request, { values, context, objectDispatcher, author
|
|
|
1442
1184
|
* @param parameters The parameters for handling the collection.
|
|
1443
1185
|
* @returns A promise that resolves to an HTTP response.
|
|
1444
1186
|
*/
|
|
1445
|
-
async function handleCollection(request, { name: name$
|
|
1446
|
-
const spanName = name$
|
|
1187
|
+
async function handleCollection(request, { name: name$2, identifier, uriGetter, filter, filterPredicate, context, collectionCallbacks, tracerProvider, onUnauthorized, onNotFound }) {
|
|
1188
|
+
const spanName = name$2.trim().replace(/\s+/g, "_");
|
|
1447
1189
|
tracerProvider = tracerProvider ?? trace.getTracerProvider();
|
|
1448
1190
|
const tracer = tracerProvider.getTracer(name, version);
|
|
1449
1191
|
const cursor = new URL(request.url).searchParams.get("cursor");
|
|
@@ -1485,7 +1227,7 @@ async function handleCollection(request, { name: name$1, identifier, uriGetter,
|
|
|
1485
1227
|
collection = new OrderedCollection({
|
|
1486
1228
|
id: baseUri,
|
|
1487
1229
|
totalItems: totalItems == null ? null : Number(totalItems),
|
|
1488
|
-
items: filterCollectionItems(itemsOrResponse, name$
|
|
1230
|
+
items: filterCollectionItems(itemsOrResponse, name$2, filterPredicate)
|
|
1489
1231
|
});
|
|
1490
1232
|
} else {
|
|
1491
1233
|
const lastCursor = await collectionCallbacks.lastCursor?.(context, identifier);
|
|
@@ -1506,7 +1248,7 @@ async function handleCollection(request, { name: name$1, identifier, uriGetter,
|
|
|
1506
1248
|
} else {
|
|
1507
1249
|
const uri = new URL(baseUri);
|
|
1508
1250
|
uri.searchParams.set("cursor", cursor);
|
|
1509
|
-
const pageOrResponse = await tracer.startActiveSpan(`activitypub.dispatch_collection_page ${name$
|
|
1251
|
+
const pageOrResponse = await tracer.startActiveSpan(`activitypub.dispatch_collection_page ${name$2}`, {
|
|
1510
1252
|
kind: SpanKind.SERVER,
|
|
1511
1253
|
attributes: {
|
|
1512
1254
|
"activitypub.collection.id": uri.href,
|
|
@@ -1550,7 +1292,7 @@ async function handleCollection(request, { name: name$1, identifier, uriGetter,
|
|
|
1550
1292
|
id: uri,
|
|
1551
1293
|
prev,
|
|
1552
1294
|
next,
|
|
1553
|
-
items: filterCollectionItems(items, name$
|
|
1295
|
+
items: filterCollectionItems(items, name$2, filterPredicate),
|
|
1554
1296
|
partOf
|
|
1555
1297
|
});
|
|
1556
1298
|
}
|
|
@@ -1825,7 +1567,7 @@ async function handleInbox(request, options) {
|
|
|
1825
1567
|
* @returns A promise that resolves to an HTTP response.
|
|
1826
1568
|
*/
|
|
1827
1569
|
async function handleInboxInternal(request, parameters, span) {
|
|
1828
|
-
const { recipient, context: ctx, inboxContextFactory, kv, kvPrefixes, queue, actorDispatcher, inboxListeners, inboxErrorHandler, unverifiedActivityHandler, onNotFound, signatureTimeWindow, skipSignatureVerification, inboxChallengePolicy, tracerProvider } = parameters;
|
|
1570
|
+
const { recipient, context: ctx, inboxContextFactory, kv, kvPrefixes, queue, actorDispatcher, inboxListeners, inboxErrorHandler, unverifiedActivityHandler, onNotFound, signatureTimeWindow, skipSignatureVerification, inboxChallengePolicy, meterProvider, tracerProvider } = parameters;
|
|
1829
1571
|
const logger = getLogger([
|
|
1830
1572
|
"fedify",
|
|
1831
1573
|
"federation",
|
|
@@ -1903,6 +1645,7 @@ async function handleInboxInternal(request, parameters, span) {
|
|
|
1903
1645
|
contextLoader: ctx.contextLoader,
|
|
1904
1646
|
documentLoader: ctx.documentLoader,
|
|
1905
1647
|
keyCache,
|
|
1648
|
+
meterProvider,
|
|
1906
1649
|
tracerProvider
|
|
1907
1650
|
});
|
|
1908
1651
|
} catch (error) {
|
|
@@ -1938,6 +1681,7 @@ async function handleInboxInternal(request, parameters, span) {
|
|
|
1938
1681
|
contextLoader: ctx.contextLoader,
|
|
1939
1682
|
documentLoader: ctx.documentLoader,
|
|
1940
1683
|
keyCache,
|
|
1684
|
+
meterProvider,
|
|
1941
1685
|
tracerProvider
|
|
1942
1686
|
});
|
|
1943
1687
|
} catch (error) {
|
|
@@ -1985,6 +1729,7 @@ async function handleInboxInternal(request, parameters, span) {
|
|
|
1985
1729
|
documentLoader: ctx.documentLoader,
|
|
1986
1730
|
timeWindow: signatureTimeWindow,
|
|
1987
1731
|
keyCache,
|
|
1732
|
+
meterProvider,
|
|
1988
1733
|
tracerProvider
|
|
1989
1734
|
});
|
|
1990
1735
|
if (verification.verified === false) {
|
|
@@ -2233,8 +1978,8 @@ var CustomCollectionHandler = class {
|
|
|
2233
1978
|
* @param CollectionPage The CollectionPage constructor.
|
|
2234
1979
|
* @param filterPredicate Optional filter predicate for items.
|
|
2235
1980
|
*/
|
|
2236
|
-
constructor(name$
|
|
2237
|
-
this.name = name$
|
|
1981
|
+
constructor(name$1, values, context, callbacks, tracerProvider = trace.getTracerProvider(), Collection, CollectionPage, filterPredicate) {
|
|
1982
|
+
this.name = name$1;
|
|
2238
1983
|
this.values = values;
|
|
2239
1984
|
this.context = context;
|
|
2240
1985
|
this.callbacks = callbacks;
|
|
@@ -4731,6 +4476,7 @@ var ContextImpl = class ContextImpl {
|
|
|
4731
4476
|
if (await verifyObject(Activity, json, {
|
|
4732
4477
|
contextLoader,
|
|
4733
4478
|
documentLoader: options.documentLoader ?? this.documentLoader,
|
|
4479
|
+
meterProvider: this.meterProvider,
|
|
4734
4480
|
tracerProvider: options.tracerProvider ?? this.tracerProvider,
|
|
4735
4481
|
keyCache
|
|
4736
4482
|
}) == null) {
|
|
@@ -4873,6 +4619,7 @@ var RequestContextImpl = class RequestContextImpl extends ContextImpl {
|
|
|
4873
4619
|
contextLoader: options.contextLoader ?? this.contextLoader,
|
|
4874
4620
|
documentLoader: options.documentLoader ?? this.documentLoader,
|
|
4875
4621
|
timeWindow: this.federation.signatureTimeWindow,
|
|
4622
|
+
meterProvider: this.meterProvider,
|
|
4876
4623
|
tracerProvider: options.tracerProvider ?? this.tracerProvider
|
|
4877
4624
|
});
|
|
4878
4625
|
}
|
|
@@ -2,24 +2,25 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { n as RouterError } from "./router-BT_F5748.mjs";
|
|
5
|
-
import { n as version, t as name } from "./deno-
|
|
6
|
-
import { t as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { t as
|
|
17
|
-
import {
|
|
18
|
-
import { t as
|
|
19
|
-
import {
|
|
5
|
+
import { n as version, t as name } from "./deno-CF3jMgip.mjs";
|
|
6
|
+
import { i as isAbortError, n as getFederationMetrics, o as recordOutboxEnqueue, r as getRemoteHost, t as getDurationMs } from "./metrics-ek3ilf6c.mjs";
|
|
7
|
+
import { t as formatAcceptSignature } from "./accept-CgDcxvjV.mjs";
|
|
8
|
+
import { a as importJwk, o as validateCryptoKey, t as exportJwk } from "./key-B4I8H5Lc.mjs";
|
|
9
|
+
import { l as verifyRequest, o as parseRfc9421SignatureInput, u as verifyRequestDetailed } from "./http-BmOZYc-8.mjs";
|
|
10
|
+
import { t as getAuthenticatedDocumentLoader } from "./docloader-BENj6vQ4.mjs";
|
|
11
|
+
import { n as kvCache } from "./kv-cache-DihufyAQ.mjs";
|
|
12
|
+
import { a as signJsonLd, i as hasSignatureLike, o as verifyJsonLd, r as detachSignature } from "./ld-B5D5THhl.mjs";
|
|
13
|
+
import { n as getKeyOwner, t as doesActorOwnKey } from "./owner-DO810N24.mjs";
|
|
14
|
+
import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-BNL8AC14.mjs";
|
|
15
|
+
import { i as verifyObject, n as hasProofLike, r as signObject } from "./proof-BgfyWv7b.mjs";
|
|
16
|
+
import { t as getNodeInfo } from "./client-Bneh_DYR.mjs";
|
|
17
|
+
import { t as nodeInfoToJson } from "./types-D09GN0uZ.mjs";
|
|
18
|
+
import { n as FederationBuilderImpl, t as ACTOR_ALIAS_PREFIX } from "./builder-YlEusQth.mjs";
|
|
19
|
+
import { t as buildCollectionSynchronizationHeader } from "./collection-Cc3DVAhE.mjs";
|
|
20
20
|
import { t as KvKeyCache } from "./keycache-BeU0LCII.mjs";
|
|
21
21
|
import { t as acceptsJsonLd } from "./negotiation-DDstyBvc.mjs";
|
|
22
22
|
import { t as createExponentialBackoffPolicy } from "./retry-_VvV0h9f.mjs";
|
|
23
|
+
import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "./send-CAYXdUTk.mjs";
|
|
23
24
|
import { getLogger, withContext } from "@logtape/logtape";
|
|
24
25
|
import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, Tombstone, getTypeId, lookupObject, traverseCollection } from "@fedify/vocab";
|
|
25
26
|
import { lookupWebFinger } from "@fedify/webfinger";
|
|
@@ -374,8 +375,8 @@ async function handleObject(request, { values, context, objectDispatcher, author
|
|
|
374
375
|
* @param parameters The parameters for handling the collection.
|
|
375
376
|
* @returns A promise that resolves to an HTTP response.
|
|
376
377
|
*/
|
|
377
|
-
async function handleCollection(request, { name: name$
|
|
378
|
-
const spanName = name$
|
|
378
|
+
async function handleCollection(request, { name: name$2, identifier, uriGetter, filter, filterPredicate, context, collectionCallbacks, tracerProvider, onUnauthorized, onNotFound }) {
|
|
379
|
+
const spanName = name$2.trim().replace(/\s+/g, "_");
|
|
379
380
|
tracerProvider = tracerProvider ?? trace.getTracerProvider();
|
|
380
381
|
const tracer = tracerProvider.getTracer(name, version);
|
|
381
382
|
const cursor = new URL(request.url).searchParams.get("cursor");
|
|
@@ -417,7 +418,7 @@ async function handleCollection(request, { name: name$1, identifier, uriGetter,
|
|
|
417
418
|
collection = new OrderedCollection({
|
|
418
419
|
id: baseUri,
|
|
419
420
|
totalItems: totalItems == null ? null : Number(totalItems),
|
|
420
|
-
items: filterCollectionItems(itemsOrResponse, name$
|
|
421
|
+
items: filterCollectionItems(itemsOrResponse, name$2, filterPredicate)
|
|
421
422
|
});
|
|
422
423
|
} else {
|
|
423
424
|
const lastCursor = await collectionCallbacks.lastCursor?.(context, identifier);
|
|
@@ -438,7 +439,7 @@ async function handleCollection(request, { name: name$1, identifier, uriGetter,
|
|
|
438
439
|
} else {
|
|
439
440
|
const uri = new URL(baseUri);
|
|
440
441
|
uri.searchParams.set("cursor", cursor);
|
|
441
|
-
const pageOrResponse = await tracer.startActiveSpan(`activitypub.dispatch_collection_page ${name$
|
|
442
|
+
const pageOrResponse = await tracer.startActiveSpan(`activitypub.dispatch_collection_page ${name$2}`, {
|
|
442
443
|
kind: SpanKind.SERVER,
|
|
443
444
|
attributes: {
|
|
444
445
|
"activitypub.collection.id": uri.href,
|
|
@@ -482,7 +483,7 @@ async function handleCollection(request, { name: name$1, identifier, uriGetter,
|
|
|
482
483
|
id: uri,
|
|
483
484
|
prev,
|
|
484
485
|
next,
|
|
485
|
-
items: filterCollectionItems(items, name$
|
|
486
|
+
items: filterCollectionItems(items, name$2, filterPredicate),
|
|
486
487
|
partOf
|
|
487
488
|
});
|
|
488
489
|
}
|
|
@@ -757,7 +758,7 @@ async function handleInbox(request, options) {
|
|
|
757
758
|
* @returns A promise that resolves to an HTTP response.
|
|
758
759
|
*/
|
|
759
760
|
async function handleInboxInternal(request, parameters, span) {
|
|
760
|
-
const { recipient, context: ctx, inboxContextFactory, kv, kvPrefixes, queue, actorDispatcher, inboxListeners, inboxErrorHandler, unverifiedActivityHandler, onNotFound, signatureTimeWindow, skipSignatureVerification, inboxChallengePolicy, tracerProvider } = parameters;
|
|
761
|
+
const { recipient, context: ctx, inboxContextFactory, kv, kvPrefixes, queue, actorDispatcher, inboxListeners, inboxErrorHandler, unverifiedActivityHandler, onNotFound, signatureTimeWindow, skipSignatureVerification, inboxChallengePolicy, meterProvider, tracerProvider } = parameters;
|
|
761
762
|
const logger = getLogger([
|
|
762
763
|
"fedify",
|
|
763
764
|
"federation",
|
|
@@ -835,6 +836,7 @@ async function handleInboxInternal(request, parameters, span) {
|
|
|
835
836
|
contextLoader: ctx.contextLoader,
|
|
836
837
|
documentLoader: ctx.documentLoader,
|
|
837
838
|
keyCache,
|
|
839
|
+
meterProvider,
|
|
838
840
|
tracerProvider
|
|
839
841
|
});
|
|
840
842
|
} catch (error) {
|
|
@@ -870,6 +872,7 @@ async function handleInboxInternal(request, parameters, span) {
|
|
|
870
872
|
contextLoader: ctx.contextLoader,
|
|
871
873
|
documentLoader: ctx.documentLoader,
|
|
872
874
|
keyCache,
|
|
875
|
+
meterProvider,
|
|
873
876
|
tracerProvider
|
|
874
877
|
});
|
|
875
878
|
} catch (error) {
|
|
@@ -917,6 +920,7 @@ async function handleInboxInternal(request, parameters, span) {
|
|
|
917
920
|
documentLoader: ctx.documentLoader,
|
|
918
921
|
timeWindow: signatureTimeWindow,
|
|
919
922
|
keyCache,
|
|
923
|
+
meterProvider,
|
|
920
924
|
tracerProvider
|
|
921
925
|
});
|
|
922
926
|
if (verification.verified === false) {
|
|
@@ -1165,8 +1169,8 @@ var CustomCollectionHandler = class {
|
|
|
1165
1169
|
* @param CollectionPage The CollectionPage constructor.
|
|
1166
1170
|
* @param filterPredicate Optional filter predicate for items.
|
|
1167
1171
|
*/
|
|
1168
|
-
constructor(name$
|
|
1169
|
-
this.name = name$
|
|
1172
|
+
constructor(name$1, values, context, callbacks, tracerProvider = trace.getTracerProvider(), Collection, CollectionPage, filterPredicate) {
|
|
1173
|
+
this.name = name$1;
|
|
1170
1174
|
this.values = values;
|
|
1171
1175
|
this.context = context;
|
|
1172
1176
|
this.callbacks = callbacks;
|
|
@@ -3374,6 +3378,7 @@ var ContextImpl = class ContextImpl {
|
|
|
3374
3378
|
if (await verifyObject(Activity, json, {
|
|
3375
3379
|
contextLoader,
|
|
3376
3380
|
documentLoader: options.documentLoader ?? this.documentLoader,
|
|
3381
|
+
meterProvider: this.meterProvider,
|
|
3377
3382
|
tracerProvider: options.tracerProvider ?? this.tracerProvider,
|
|
3378
3383
|
keyCache
|
|
3379
3384
|
}) == null) {
|
|
@@ -3516,6 +3521,7 @@ var RequestContextImpl = class RequestContextImpl extends ContextImpl {
|
|
|
3516
3521
|
contextLoader: options.contextLoader ?? this.contextLoader,
|
|
3517
3522
|
documentLoader: options.documentLoader ?? this.documentLoader,
|
|
3518
3523
|
timeWindow: this.federation.signatureTimeWindow,
|
|
3524
|
+
meterProvider: this.meterProvider,
|
|
3519
3525
|
tracerProvider: options.tracerProvider ?? this.tracerProvider
|
|
3520
3526
|
});
|
|
3521
3527
|
}
|