@fedify/fedify 2.4.0-dev.1583 → 2.4.0-dev.1618
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/{accept-CgDcxvjV.mjs → accept-8PiolDP7.mjs} +1 -1
- package/dist/{activity-listener-BeTGV3wc.mjs → activity-listener-BtTSxZWA.mjs} +1 -1
- package/dist/{assert-DvVHoIZ0.mjs → assert-CJ1KXcvv.mjs} +2 -2
- package/dist/{assert_equals-PBVKNMJd.mjs → assert_equals-BV7oLMxm.mjs} +1 -1
- package/dist/{assert_instance_of-CxoC8bVq.mjs → assert_instance_of-Q9KTBnrf.mjs} +2 -2
- package/dist/{assert_not_equals-C8vcTTA3.mjs → assert_not_equals-EPJPoxuf.mjs} +2 -2
- package/dist/{assert_rejects-DAdaaIWM.mjs → assert_rejects-EgstcQy5.mjs} +3 -3
- package/dist/{assert_strict_equals-BzqyKuYL.mjs → assert_strict_equals-Ec20AUwa.mjs} +2 -2
- package/dist/{assert_throws-zN79lgIC.mjs → assert_throws-NiFfqbnH.mjs} +2 -2
- package/dist/{builder-Doj1FmsW.mjs → builder-C4a7TAvq.mjs} +26 -4
- package/dist/{chunk-DDcVe30Y.cjs → chunk-Czpeue4M.cjs} +0 -1
- package/dist/{chunk-CRNNMoPX.js → chunk-D5IdezsZ.js} +1 -1
- package/dist/{circuit-breaker-hJBB6jwA.mjs → circuit-breaker-CBGyz5F7.mjs} +1 -1
- package/dist/{client-B_A6mfn3.mjs → client-CjF5IYQS.mjs} +1 -1
- package/dist/{codec-nfBU4Up4.mjs → codec-BBga-FWI.mjs} +1 -1
- package/dist/{collection-Dp5ky45w.mjs → collection-BIhlldqK.mjs} +1 -1
- package/dist/compat/mod.cjs +1 -2
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/mod.js +2 -2
- package/dist/compat/outgoing-jsonld.test.d.mts +1 -1
- package/dist/compat/outgoing-jsonld.test.mjs +4 -4
- package/dist/compat/public-audience.test.d.mts +1 -1
- package/dist/compat/public-audience.test.mjs +4 -4
- package/dist/compat/transformers.test.d.mts +1 -1
- package/dist/compat/transformers.test.mjs +6 -6
- package/dist/{context-BBRTgkrs.mjs → context-BJXxPElm.mjs} +3 -2
- package/dist/{context-GfQA-CqB.d.ts → context-Zii1f5xS.d.ts} +97 -1
- package/dist/{context-BLe0NPtZ.d.cts → context-lxX6I7as.d.cts} +97 -1
- package/dist/{deno-Bkl9jNVs.mjs → deno-DepnPEgI.mjs} +2 -2
- package/dist/{docloader-f1XFaWWh.mjs → docloader-C_IefWRb.mjs} +3 -3
- package/dist/{esm-vrlUxr60.mjs → esm-yYQfPhIY.mjs} +1 -1
- package/dist/federation/builder.test.d.mts +1 -1
- package/dist/federation/builder.test.mjs +16 -6
- package/dist/federation/circuit-breaker.test.d.mts +1 -1
- package/dist/federation/circuit-breaker.test.mjs +6 -6
- package/dist/federation/collection.test.d.mts +1 -1
- package/dist/federation/collection.test.mjs +4 -4
- package/dist/federation/handler.test.d.mts +1 -1
- package/dist/federation/handler.test.mjs +14 -14
- package/dist/federation/idempotency.test.d.mts +1 -1
- package/dist/federation/idempotency.test.mjs +7 -7
- package/dist/federation/inbox.test.d.mts +1 -1
- package/dist/federation/inbox.test.mjs +4 -4
- package/dist/federation/keycache.test.d.mts +1 -1
- package/dist/federation/keycache.test.mjs +6 -6
- package/dist/federation/kv.test.d.mts +1 -1
- package/dist/federation/kv.test.mjs +4 -4
- package/dist/federation/metrics.test.d.mts +1 -1
- package/dist/federation/metrics.test.mjs +5 -5
- package/dist/federation/middleware.test.d.mts +1 -1
- package/dist/federation/middleware.test.mjs +470 -22
- package/dist/federation/mod.cjs +4 -3
- package/dist/federation/mod.d.cts +3 -3
- package/dist/federation/mod.d.ts +3 -3
- package/dist/federation/mod.js +2 -2
- package/dist/federation/mq.test.d.mts +1 -1
- package/dist/federation/mq.test.mjs +6 -6
- package/dist/federation/negotiation.test.d.mts +1 -1
- package/dist/federation/negotiation.test.mjs +5 -5
- package/dist/federation/retry.test.d.mts +1 -1
- package/dist/federation/retry.test.mjs +4 -4
- package/dist/federation/router.test.d.mts +1 -1
- package/dist/federation/router.test.mjs +6 -6
- package/dist/federation/send.test.d.mts +1 -1
- package/dist/federation/send.test.mjs +12 -12
- package/dist/federation/tasks/codec.test.d.mts +1 -1
- package/dist/federation/tasks/codec.test.mjs +2 -2
- package/dist/federation/tasks/enqueue.test.d.mts +1 -1
- package/dist/federation/tasks/enqueue.test.mjs +5 -5
- package/dist/federation/tasks/tasks.test.d.mts +1 -1
- package/dist/federation/tasks/tasks.test.mjs +7 -7
- package/dist/federation/temporal.test.d.mts +1 -1
- package/dist/federation/temporal.test.mjs +5 -5
- package/dist/federation/webfinger.test.d.mts +1 -1
- package/dist/federation/webfinger.test.mjs +7 -7
- package/dist/{http-BBkdx4Kd.mjs → http-CT7tcVBN.mjs} +5 -5
- package/dist/{http-jCq51U37.cjs → http-D5ylizT7.cjs} +4 -3
- package/dist/{http-CphHLbTC.js → http-DD07Erm7.js} +2 -2
- package/dist/{key-BBKNHoB9.mjs → key-C3t-PS3M.mjs} +3 -3
- package/dist/{keycache-CaOR6NYg.mjs → keycache-_DHqz5z_.mjs} +1 -1
- package/dist/{keys-CSYsOMFG.mjs → keys-Dbyd7bhl.mjs} +1 -1
- package/dist/{kv-CIvR3Non.mjs → kv-CXBAok3k.mjs} +1 -1
- package/dist/{kv-cache-D3KdEZAg.js → kv-cache-Bvv7Wp8h.js} +2 -2
- package/dist/{kv-cache-SVUAUYIs.mjs → kv-cache-CK273Baz.mjs} +2 -2
- package/dist/{kv-cache-B9Zvq4xB.cjs → kv-cache-DbFdquuM.cjs} +4 -3
- package/dist/{ld-DLyXLPDS.mjs → ld-D8wAPjxC.mjs} +4 -4
- package/dist/{metrics-BVRrGEXj.mjs → metrics-D1NrDWq-.mjs} +2 -2
- package/dist/{middleware-1AyOpRqz.mjs → middleware-BRunoF2v.mjs} +244 -24
- package/dist/{middleware-CzWfDAQY.mjs → middleware-CaP0k3AD.mjs} +2 -2
- package/dist/{middleware-B1jZw4xB.js → middleware-kQ-qwTDh.js} +249 -7
- package/dist/{middleware-DszmUorL.cjs → middleware-nmfhGFtV.cjs} +290 -39
- package/dist/{mod-Cmr39iWq.d.ts → mod-DLc2Ot6f.d.ts} +1 -1
- package/dist/{mod-B8Efb9qp.d.cts → mod-gOlPDuT8.d.cts} +1 -1
- package/dist/mod.cjs +7 -8
- package/dist/mod.d.cts +4 -4
- package/dist/mod.d.ts +4 -4
- package/dist/mod.js +8 -8
- package/dist/{mq-03vS-C9P.mjs → mq-llHKivST.mjs} +1 -1
- package/dist/{negotiation-m_L2nyS3.mjs → negotiation-RuwrPFqi.mjs} +1 -1
- package/dist/nodeinfo/client.test.d.mts +1 -1
- package/dist/nodeinfo/client.test.mjs +5 -5
- package/dist/nodeinfo/handler.test.d.mts +1 -1
- package/dist/nodeinfo/handler.test.mjs +6 -6
- package/dist/nodeinfo/mod.cjs +1 -2
- package/dist/nodeinfo/mod.js +2 -2
- package/dist/nodeinfo/types.test.d.mts +1 -1
- package/dist/nodeinfo/types.test.mjs +5 -5
- package/dist/otel/exporter.test.d.mts +1 -1
- package/dist/otel/exporter.test.mjs +4 -4
- package/dist/otel/mod.cjs +1 -2
- package/dist/otel/mod.js +1 -1
- package/dist/{outgoing-jsonld-BNL8AC14.mjs → outgoing-jsonld-URuqsICz.mjs} +2 -2
- package/dist/{owner-BukzQW4T.mjs → owner-BjdNNmKF.mjs} +3 -3
- package/dist/{proof-IDHRILpm.js → proof--HiDnLAE.js} +15 -4
- package/dist/{proof-BVglyYRW.mjs → proof-1Xy5Ur-T.mjs} +19 -7
- package/dist/{proof-DkeR_Fsm.cjs → proof-DcOiiLDF.cjs} +16 -4
- package/dist/{public-audience-c9zmYKgA.mjs → public-audience-Cr5MsnMq.mjs} +1 -1
- package/dist/{retry-DI4O-zYl.mjs → retry-DgFqeS5k.mjs} +1 -1
- package/dist/runtime/mod.cjs +1 -2
- package/dist/runtime/mod.js +2 -2
- package/dist/{send-D04Hz77b.mjs → send-ClJ4UcZL.mjs} +4 -4
- package/dist/sig/accept.test.d.mts +1 -1
- package/dist/sig/accept.test.mjs +2 -2
- package/dist/sig/http.test.d.mts +1 -1
- package/dist/sig/http.test.mjs +10 -10
- package/dist/sig/key.test.d.mts +1 -1
- package/dist/sig/key.test.mjs +7 -7
- package/dist/sig/ld.test.d.mts +1 -1
- package/dist/sig/ld.test.mjs +8 -8
- package/dist/sig/mod.cjs +2 -3
- package/dist/sig/mod.js +3 -3
- package/dist/sig/owner.test.d.mts +1 -1
- package/dist/sig/owner.test.mjs +7 -7
- package/dist/sig/proof.test.d.mts +1 -1
- package/dist/sig/proof.test.mjs +146 -9
- package/dist/{std__assert-Dh6uLf_q.mjs → std__assert-B2NnY9bq.mjs} +5 -5
- package/dist/temporal-polyfill-BCdTHexd.cjs +3565 -0
- package/dist/{temporal-xcPM9mxe.mjs → temporal-wA-b1IAz.mjs} +2 -2
- package/dist/testing/mod.d.mts +97 -1
- package/dist/testing/mod.mjs +3 -3
- package/dist/{testing-Dy-WhqpN.mjs → testing-CO7ftO8A.mjs} +3 -3
- package/dist/{transformers-NeAONrAq.cjs → transformers-DGwl-hD1.cjs} +1 -2
- package/dist/{transformers-BGMIq1cs.js → transformers-DXze6FUB.js} +1 -1
- package/dist/{types-KC4QAoxe.cjs → types-CPym83zc.cjs} +1 -2
- package/dist/{types-BFowWFTT.mjs → types-CrtdVuDP.mjs} +1 -1
- package/dist/{types-CAY3OdLq.js → types-DC1pNgJA.js} +1 -1
- package/dist/utils/docloader.test.d.mts +1 -1
- package/dist/utils/docloader.test.mjs +8 -8
- package/dist/utils/kv-cache.test.d.mts +1 -1
- package/dist/utils/kv-cache.test.mjs +2 -2
- package/dist/utils/mod.cjs +1 -2
- package/dist/utils/mod.js +2 -2
- package/dist/vocab/cjs.test.d.mts +1 -1
- package/dist/vocab/cjs.test.mjs +14 -1
- package/dist/vocab/mod.cjs +0 -1
- package/dist/vocab/mod.js +1 -1
- package/package.json +8 -8
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
1
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
|
-
const require_chunk = require("./chunk-
|
|
4
|
-
const require_transformers = require("./transformers-
|
|
5
|
-
const require_http = require("./http-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
2
|
+
const require_chunk = require("./chunk-Czpeue4M.cjs");
|
|
3
|
+
const require_transformers = require("./transformers-DGwl-hD1.cjs");
|
|
4
|
+
const require_http = require("./http-D5ylizT7.cjs");
|
|
5
|
+
const require_temporal_polyfill = require("./temporal-polyfill-BCdTHexd.cjs");
|
|
6
|
+
const require_proof = require("./proof-DcOiiLDF.cjs");
|
|
7
|
+
const require_types = require("./types-CPym83zc.cjs");
|
|
8
|
+
const require_kv_cache = require("./kv-cache-DbFdquuM.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");
|
|
@@ -103,6 +103,9 @@ var FederationBuilderImpl = class {
|
|
|
103
103
|
inboxErrorHandler;
|
|
104
104
|
outboxListenerErrorHandler;
|
|
105
105
|
outboxAuthorizePredicate;
|
|
106
|
+
mediaUploaderPath;
|
|
107
|
+
mediaUploaderCallback;
|
|
108
|
+
mediaUploaderAuthorizePredicate;
|
|
106
109
|
sharedInboxKeyDispatcher;
|
|
107
110
|
unverifiedActivityHandler;
|
|
108
111
|
outboxPermanentFailureHandler;
|
|
@@ -155,6 +158,9 @@ var FederationBuilderImpl = class {
|
|
|
155
158
|
f.inboxErrorHandler = this.inboxErrorHandler;
|
|
156
159
|
f.outboxListenerErrorHandler = this.outboxListenerErrorHandler;
|
|
157
160
|
f.outboxAuthorizePredicate = this.outboxAuthorizePredicate;
|
|
161
|
+
f.mediaUploaderPath = this.mediaUploaderPath;
|
|
162
|
+
f.mediaUploaderCallback = this.mediaUploaderCallback;
|
|
163
|
+
f.mediaUploaderAuthorizePredicate = this.mediaUploaderAuthorizePredicate;
|
|
158
164
|
f.sharedInboxKeyDispatcher = this.sharedInboxKeyDispatcher;
|
|
159
165
|
f.unverifiedActivityHandler = this.unverifiedActivityHandler;
|
|
160
166
|
f.outboxPermanentFailureHandler = this.outboxPermanentFailureHandler;
|
|
@@ -233,6 +239,10 @@ var FederationBuilderImpl = class {
|
|
|
233
239
|
if (actor.publicKeyId == null) logger.warn("You configured a key pairs dispatcher, but the actor does not have a publicKey property. Set the property with Context.getActorKeyPairs(identifier).");
|
|
234
240
|
if (actor.assertionMethodId == null) logger.warn("You configured a key pairs dispatcher, but the actor does not have an assertionMethod property. Set the property with Context.getActorKeyPairs(identifier).");
|
|
235
241
|
}
|
|
242
|
+
if (this.mediaUploaderCallback != null) {
|
|
243
|
+
if (actor.endpoints == null || actor.endpoints.uploadMedia == null) logger.warn("You configured a media uploader, but the actor does not have a endpoints.uploadMedia property. Set the property with Context.getMediaUploaderUri(identifier).");
|
|
244
|
+
else if (actor.endpoints.uploadMedia.href != context.getMediaUploaderUri(identifier).href) logger.warn("You configured a media uploader, but the actor's endpoints.uploadMedia property does not match the media upload endpoint URI. Set the property with Context.getMediaUploaderUri(identifier).");
|
|
245
|
+
}
|
|
236
246
|
return actor;
|
|
237
247
|
} };
|
|
238
248
|
this.actorCallbacks = callbacks;
|
|
@@ -445,6 +455,18 @@ var FederationBuilderImpl = class {
|
|
|
445
455
|
};
|
|
446
456
|
return setters;
|
|
447
457
|
}
|
|
458
|
+
setMediaUploader(path, callback) {
|
|
459
|
+
if (this.mediaUploaderCallback != null) throw new _fedify_uri_template.RouterError("Media uploader already set.");
|
|
460
|
+
(0, _fedify_uri_template.assertPath)(path);
|
|
461
|
+
this.router.add(path, "mediaUploader", identifierSingular);
|
|
462
|
+
this.mediaUploaderPath = path;
|
|
463
|
+
this.mediaUploaderCallback = callback;
|
|
464
|
+
const setters = { authorize: (predicate) => {
|
|
465
|
+
this.mediaUploaderAuthorizePredicate = predicate;
|
|
466
|
+
return setters;
|
|
467
|
+
} };
|
|
468
|
+
return setters;
|
|
469
|
+
}
|
|
448
470
|
setFollowingDispatcher(path, dispatcher) {
|
|
449
471
|
if (this.router.has("following")) throw new _fedify_uri_template.RouterError("Following collection dispatcher already set.");
|
|
450
472
|
(0, _fedify_uri_template.assertPath)(path);
|
|
@@ -701,6 +723,7 @@ function createFederationBuilder() {
|
|
|
701
723
|
}
|
|
702
724
|
//#endregion
|
|
703
725
|
//#region src/federation/circuit-breaker.ts
|
|
726
|
+
const Temporal$8 = require_temporal_polyfill.Temporal;
|
|
704
727
|
const MAX_CUSTOM_FAILURE_HISTORY = 100;
|
|
705
728
|
/**
|
|
706
729
|
* Tracks reachability state for remote outbox delivery hosts.
|
|
@@ -716,7 +739,7 @@ var CircuitBreaker = class {
|
|
|
716
739
|
this.#kv = options.kv;
|
|
717
740
|
this.#prefix = options.prefix;
|
|
718
741
|
this.#options = normalizeCircuitBreakerOptions(options.options ?? {});
|
|
719
|
-
this.#now = options.now ?? (() => Temporal.Now.instant());
|
|
742
|
+
this.#now = options.now ?? (() => Temporal$8.Now.instant());
|
|
720
743
|
this.#stateChangeObserver = options.stateChangeObserver;
|
|
721
744
|
}
|
|
722
745
|
get options() {
|
|
@@ -729,7 +752,7 @@ var CircuitBreaker = class {
|
|
|
729
752
|
async beforeSend(remoteHost, message) {
|
|
730
753
|
const heldSince = parseHeldSince(message.circuitHeldSince);
|
|
731
754
|
const now = this.#now();
|
|
732
|
-
if (heldSince != null && Temporal.Instant.compare(heldSince.add(this.#options.heldActivityTtl), now) <= 0) return {
|
|
755
|
+
if (heldSince != null && Temporal$8.Instant.compare(heldSince.add(this.#options.heldActivityTtl), now) <= 0) return {
|
|
733
756
|
type: "drop",
|
|
734
757
|
heldSince
|
|
735
758
|
};
|
|
@@ -741,12 +764,12 @@ var CircuitBreaker = class {
|
|
|
741
764
|
probe: false
|
|
742
765
|
};
|
|
743
766
|
if (oldState.state === "half-open") {
|
|
744
|
-
const halfOpened = oldState.halfOpened == null ? void 0 : Temporal.Instant.from(oldState.halfOpened);
|
|
767
|
+
const halfOpened = oldState.halfOpened == null ? void 0 : Temporal$8.Instant.from(oldState.halfOpened);
|
|
745
768
|
if (halfOpened != null) {
|
|
746
769
|
const staleAt = halfOpened.add(this.#options.recoveryDelay);
|
|
747
|
-
if (Temporal.Instant.compare(now, staleAt) < 0) {
|
|
770
|
+
if (Temporal$8.Instant.compare(now, staleAt) < 0) {
|
|
748
771
|
const releaseAt = now.add(this.#options.releaseInterval);
|
|
749
|
-
const retryAt = Temporal.Instant.compare(releaseAt, staleAt) < 0 ? releaseAt : staleAt;
|
|
772
|
+
const retryAt = Temporal$8.Instant.compare(releaseAt, staleAt) < 0 ? releaseAt : staleAt;
|
|
750
773
|
const cappedRetryAt = this.#capHeldRetryAt(now, heldSince, retryAt);
|
|
751
774
|
return {
|
|
752
775
|
type: "hold",
|
|
@@ -768,8 +791,8 @@ var CircuitBreaker = class {
|
|
|
768
791
|
lastConflictingState = "half-open";
|
|
769
792
|
continue;
|
|
770
793
|
}
|
|
771
|
-
const probeAt = (oldState.opened == null ? now : Temporal.Instant.from(oldState.opened)).add(this.#options.recoveryDelay);
|
|
772
|
-
if (Temporal.Instant.compare(now, probeAt) < 0) {
|
|
794
|
+
const probeAt = (oldState.opened == null ? now : Temporal$8.Instant.from(oldState.opened)).add(this.#options.recoveryDelay);
|
|
795
|
+
if (Temporal$8.Instant.compare(now, probeAt) < 0) {
|
|
773
796
|
const retryAt = this.#capHeldRetryAt(now, heldSince, probeAt);
|
|
774
797
|
return {
|
|
775
798
|
type: "hold",
|
|
@@ -832,7 +855,7 @@ var CircuitBreaker = class {
|
|
|
832
855
|
for (let attempt = 0; attempt < 10; attempt++) {
|
|
833
856
|
const oldState = await this.#get(remoteHost);
|
|
834
857
|
if (oldState?.state === "open") return void 0;
|
|
835
|
-
const oldFailures = oldState?.failures.map(Temporal.Instant.from) ?? [];
|
|
858
|
+
const oldFailures = oldState?.failures.map(Temporal$8.Instant.from) ?? [];
|
|
836
859
|
const failures = this.#options.pruneFailures([...oldFailures, now], now);
|
|
837
860
|
let newState;
|
|
838
861
|
let transition;
|
|
@@ -882,7 +905,7 @@ var CircuitBreaker = class {
|
|
|
882
905
|
}
|
|
883
906
|
#capHeldRetryAt(now, heldSince, retryAt) {
|
|
884
907
|
const expiresAt = (heldSince ?? now).add(this.#options.heldActivityTtl);
|
|
885
|
-
return Temporal.Instant.compare(expiresAt, retryAt) < 0 ? expiresAt : retryAt;
|
|
908
|
+
return Temporal$8.Instant.compare(expiresAt, retryAt) < 0 ? expiresAt : retryAt;
|
|
886
909
|
}
|
|
887
910
|
async #get(remoteHost) {
|
|
888
911
|
return parseCircuitBreakerKvState(await this.#kv.get(this.#key(remoteHost)));
|
|
@@ -953,13 +976,13 @@ function normalizeCircuitBreakerOptions(options) {
|
|
|
953
976
|
assertPositiveDuration(failureWindow, "failureWindow");
|
|
954
977
|
pruneFailures = (timestamps, now) => {
|
|
955
978
|
const earliest = now.subtract(failureWindow);
|
|
956
|
-
return timestamps.filter((timestamp) => Temporal.Instant.compare(timestamp, earliest) >= 0).slice(-failureThreshold);
|
|
979
|
+
return timestamps.filter((timestamp) => Temporal$8.Instant.compare(timestamp, earliest) >= 0).slice(-failureThreshold);
|
|
957
980
|
};
|
|
958
981
|
failure = (timestamps) => {
|
|
959
982
|
if (timestamps.length < failureThreshold) return false;
|
|
960
983
|
const first = timestamps[timestamps.length - failureThreshold];
|
|
961
984
|
const last = timestamps[timestamps.length - 1];
|
|
962
|
-
return Temporal.Duration.compare(first.until(last), failureWindow) <= 0;
|
|
985
|
+
return Temporal$8.Duration.compare(first.until(last), failureWindow) <= 0;
|
|
963
986
|
};
|
|
964
987
|
} else {
|
|
965
988
|
failure = options.failure;
|
|
@@ -976,19 +999,19 @@ function normalizeCircuitBreakerOptions(options) {
|
|
|
976
999
|
};
|
|
977
1000
|
}
|
|
978
1001
|
function toInstantDuration(duration) {
|
|
979
|
-
const parsed = Temporal.Duration.from(duration);
|
|
980
|
-
return Temporal.Duration.from({ milliseconds: Math.trunc(parsed.total({
|
|
1002
|
+
const parsed = Temporal$8.Duration.from(duration);
|
|
1003
|
+
return Temporal$8.Duration.from({ milliseconds: Math.trunc(parsed.total({
|
|
981
1004
|
unit: "millisecond",
|
|
982
|
-
relativeTo: Temporal.PlainDateTime.from("2026-01-01T00:00:00")
|
|
1005
|
+
relativeTo: Temporal$8.PlainDateTime.from("2026-01-01T00:00:00")
|
|
983
1006
|
})) });
|
|
984
1007
|
}
|
|
985
1008
|
function assertPositiveDuration(duration, name) {
|
|
986
|
-
if (Temporal.Duration.compare(duration, { seconds: 0 }) <= 0) throw new RangeError(`${name} must be a positive duration.`);
|
|
1009
|
+
if (Temporal$8.Duration.compare(duration, { seconds: 0 }) <= 0) throw new RangeError(`${name} must be a positive duration.`);
|
|
987
1010
|
}
|
|
988
1011
|
function parseHeldSince(value) {
|
|
989
1012
|
if (value == null) return void 0;
|
|
990
1013
|
try {
|
|
991
|
-
return Temporal.Instant.from(value);
|
|
1014
|
+
return Temporal$8.Instant.from(value);
|
|
992
1015
|
} catch (error) {
|
|
993
1016
|
(0, _logtape_logtape.getLogger)([
|
|
994
1017
|
"fedify",
|
|
@@ -1012,7 +1035,7 @@ function parseCircuitBreakerKvState(value) {
|
|
|
1012
1035
|
const isInstantString = (v) => {
|
|
1013
1036
|
if (typeof v !== "string") return false;
|
|
1014
1037
|
try {
|
|
1015
|
-
Temporal.Instant.from(v);
|
|
1038
|
+
Temporal$8.Instant.from(v);
|
|
1016
1039
|
return true;
|
|
1017
1040
|
} catch {
|
|
1018
1041
|
return false;
|
|
@@ -1072,6 +1095,7 @@ async function buildCollectionSynchronizationHeader(collectionId, actorIds) {
|
|
|
1072
1095
|
}
|
|
1073
1096
|
//#endregion
|
|
1074
1097
|
//#region src/federation/inbox.ts
|
|
1098
|
+
const Temporal$7 = require_temporal_polyfill.Temporal;
|
|
1075
1099
|
async function routeActivity({ context: ctx, json, originalJson, normalizedActivity, ldSignatureVerified, activity, recipient, inboxListeners, inboxContextFactory, listenerInboxContextFactory, inboxErrorHandler, kv, kvPrefixes, queue, span, meterProvider, tracerProvider, idempotencyStrategy }) {
|
|
1076
1100
|
const logger = (0, _logtape_logtape.getLogger)([
|
|
1077
1101
|
"fedify",
|
|
@@ -1218,7 +1242,7 @@ async function routeActivity({ context: ctx, json, originalJson, normalizedActiv
|
|
|
1218
1242
|
return "error";
|
|
1219
1243
|
}
|
|
1220
1244
|
require_http.recordInboxActivity(meterProvider, "processed", (0, _fedify_vocab.getTypeId)(activity).href);
|
|
1221
|
-
if (cacheKey != null) await kv.set(cacheKey, true, { ttl: Temporal.Duration.from({ days: 1 }) });
|
|
1245
|
+
if (cacheKey != null) await kv.set(cacheKey, true, { ttl: Temporal$7.Duration.from({ days: 1 }) });
|
|
1222
1246
|
logger.info("Activity {activityId} has been processed.", {
|
|
1223
1247
|
activityId: activity.id?.href,
|
|
1224
1248
|
activity: json,
|
|
@@ -1230,6 +1254,7 @@ async function routeActivity({ context: ctx, json, originalJson, normalizedActiv
|
|
|
1230
1254
|
}
|
|
1231
1255
|
//#endregion
|
|
1232
1256
|
//#region src/federation/keycache.ts
|
|
1257
|
+
const Temporal$6 = require_temporal_polyfill.Temporal;
|
|
1233
1258
|
var KvKeyCache = class {
|
|
1234
1259
|
kv;
|
|
1235
1260
|
prefix;
|
|
@@ -1240,7 +1265,7 @@ var KvKeyCache = class {
|
|
|
1240
1265
|
this.kv = kv;
|
|
1241
1266
|
this.prefix = prefix;
|
|
1242
1267
|
this.options = options;
|
|
1243
|
-
this.unavailableKeyTtl = options.unavailableKeyTtl ?? Temporal.Duration.from({ minutes: 10 });
|
|
1268
|
+
this.unavailableKeyTtl = options.unavailableKeyTtl ?? Temporal$6.Duration.from({ minutes: 10 });
|
|
1244
1269
|
this.nullKeys = /* @__PURE__ */ new Map();
|
|
1245
1270
|
}
|
|
1246
1271
|
#getFetchErrorKey(keyId) {
|
|
@@ -1253,13 +1278,13 @@ var KvKeyCache = class {
|
|
|
1253
1278
|
async get(keyId) {
|
|
1254
1279
|
const negativeExpiration = this.nullKeys.get(keyId.href);
|
|
1255
1280
|
if (negativeExpiration != null) {
|
|
1256
|
-
if (Temporal.Now.instant().until(negativeExpiration).sign >= 0) return null;
|
|
1281
|
+
if (Temporal$6.Now.instant().until(negativeExpiration).sign >= 0) return null;
|
|
1257
1282
|
this.nullKeys.delete(keyId.href);
|
|
1258
1283
|
}
|
|
1259
1284
|
const serialized = await this.kv.get([...this.prefix, keyId.href]);
|
|
1260
1285
|
if (serialized === void 0) return void 0;
|
|
1261
1286
|
if (serialized === null) {
|
|
1262
|
-
this.nullKeys.set(keyId.href, Temporal.Now.instant().add(this.unavailableKeyTtl));
|
|
1287
|
+
this.nullKeys.set(keyId.href, Temporal$6.Now.instant().add(this.unavailableKeyTtl));
|
|
1263
1288
|
return null;
|
|
1264
1289
|
}
|
|
1265
1290
|
try {
|
|
@@ -1275,7 +1300,7 @@ var KvKeyCache = class {
|
|
|
1275
1300
|
}
|
|
1276
1301
|
async set(keyId, key) {
|
|
1277
1302
|
if (key == null) {
|
|
1278
|
-
this.nullKeys.set(keyId.href, Temporal.Now.instant().add(this.unavailableKeyTtl));
|
|
1303
|
+
this.nullKeys.set(keyId.href, Temporal$6.Now.instant().add(this.unavailableKeyTtl));
|
|
1279
1304
|
await this.kv.set([...this.prefix, keyId.href], null, { ttl: this.unavailableKeyTtl });
|
|
1280
1305
|
return;
|
|
1281
1306
|
}
|
|
@@ -1414,6 +1439,7 @@ function acceptsJsonLd(request) {
|
|
|
1414
1439
|
}
|
|
1415
1440
|
//#endregion
|
|
1416
1441
|
//#region src/federation/temporal.ts
|
|
1442
|
+
const Temporal$5 = require_temporal_polyfill.Temporal;
|
|
1417
1443
|
function isPlainObject$1(value) {
|
|
1418
1444
|
return typeof value === "object" && value != null && !Array.isArray(value);
|
|
1419
1445
|
}
|
|
@@ -1423,7 +1449,7 @@ function normalizeDateTimeLiteral(value) {
|
|
|
1423
1449
|
function isMalformedDateTimeLiteral(value) {
|
|
1424
1450
|
if (typeof value !== "string") return false;
|
|
1425
1451
|
try {
|
|
1426
|
-
Temporal.Instant.from(normalizeDateTimeLiteral(value));
|
|
1452
|
+
Temporal$5.Instant.from(normalizeDateTimeLiteral(value));
|
|
1427
1453
|
return false;
|
|
1428
1454
|
} catch {
|
|
1429
1455
|
return true;
|
|
@@ -1432,7 +1458,7 @@ function isMalformedDateTimeLiteral(value) {
|
|
|
1432
1458
|
function isMalformedDurationLiteral(value) {
|
|
1433
1459
|
if (typeof value !== "string") return false;
|
|
1434
1460
|
try {
|
|
1435
|
-
Temporal.Duration.from(value);
|
|
1461
|
+
Temporal$5.Duration.from(value);
|
|
1436
1462
|
return false;
|
|
1437
1463
|
} catch {
|
|
1438
1464
|
return true;
|
|
@@ -1503,6 +1529,7 @@ async function hasMalformedKnownTemporalLiteral(value, contextLoader) {
|
|
|
1503
1529
|
}
|
|
1504
1530
|
//#endregion
|
|
1505
1531
|
//#region src/federation/handler.ts
|
|
1532
|
+
const Temporal$4 = require_temporal_polyfill.Temporal;
|
|
1506
1533
|
const rawInboxContextFactorySymbol = Symbol("fedify.rawInboxContextFactory");
|
|
1507
1534
|
function isRemoteContextLoadingFailure$1(error) {
|
|
1508
1535
|
return error instanceof Error && typeof error.details === "object" && error.details != null && error.details.code === "loading remote context failed";
|
|
@@ -2015,6 +2042,193 @@ async function handleOutbox(request, { identifier, context: ctx, outboxContextFa
|
|
|
2015
2042
|
headers: { "Content-Type": "text/plain; charset=utf-8" }
|
|
2016
2043
|
});
|
|
2017
2044
|
}
|
|
2045
|
+
const plainTextHeaders = { "Content-Type": "text/plain; charset=utf-8" };
|
|
2046
|
+
/**
|
|
2047
|
+
* Handles a media upload request (the [ActivityPub Media Upload
|
|
2048
|
+
* extension](https://www.w3.org/wiki/SocialCG/ActivityPub/MediaUpload)).
|
|
2049
|
+
* @template TContextData The context data to pass to the context.
|
|
2050
|
+
* @param request The HTTP request.
|
|
2051
|
+
* @param parameters The parameters for handling the request.
|
|
2052
|
+
* @returns A promise that resolves to an HTTP response.
|
|
2053
|
+
* @since 2.4.0
|
|
2054
|
+
*/
|
|
2055
|
+
async function handleMediaUpload(request, { identifier, context: ctx, mediaUploaderCallback, actorDispatcher, authorizePredicate, isRegisteredObjectUri, onUnauthorized, onNotFound }) {
|
|
2056
|
+
const logger = (0, _logtape_logtape.getLogger)([
|
|
2057
|
+
"fedify",
|
|
2058
|
+
"federation",
|
|
2059
|
+
"mediaUploader"
|
|
2060
|
+
]);
|
|
2061
|
+
if (request.bodyUsed) {
|
|
2062
|
+
logger.error("Request body has already been read.", { identifier });
|
|
2063
|
+
return new Response("Internal server error.", {
|
|
2064
|
+
status: 500,
|
|
2065
|
+
headers: plainTextHeaders
|
|
2066
|
+
});
|
|
2067
|
+
} else if (request.body?.locked) {
|
|
2068
|
+
logger.error("Request body is locked.", { identifier });
|
|
2069
|
+
return new Response("Internal server error.", {
|
|
2070
|
+
status: 500,
|
|
2071
|
+
headers: plainTextHeaders
|
|
2072
|
+
});
|
|
2073
|
+
}
|
|
2074
|
+
const contentType = request.headers.get("content-type");
|
|
2075
|
+
if (contentType == null || !contentType.toLowerCase().startsWith("multipart/form-data")) {
|
|
2076
|
+
logger.error("The media upload request is not multipart/form-data (got {contentType}).", {
|
|
2077
|
+
identifier,
|
|
2078
|
+
contentType
|
|
2079
|
+
});
|
|
2080
|
+
return new Response("Unsupported media type.", {
|
|
2081
|
+
status: 415,
|
|
2082
|
+
headers: plainTextHeaders
|
|
2083
|
+
});
|
|
2084
|
+
}
|
|
2085
|
+
if (actorDispatcher == null) {
|
|
2086
|
+
logger.error("Actor dispatcher is not set.", { identifier });
|
|
2087
|
+
return await onNotFound(request);
|
|
2088
|
+
}
|
|
2089
|
+
const actor = await actorDispatcher(ctx, identifier);
|
|
2090
|
+
if (actor == null || actor instanceof _fedify_vocab.Tombstone) {
|
|
2091
|
+
logger.error("Actor {identifier} not found.", { identifier });
|
|
2092
|
+
return await onNotFound(request);
|
|
2093
|
+
}
|
|
2094
|
+
if (authorizePredicate != null) {
|
|
2095
|
+
let body;
|
|
2096
|
+
try {
|
|
2097
|
+
body = await request.arrayBuffer();
|
|
2098
|
+
} catch (error) {
|
|
2099
|
+
logger.error("Failed to read the multipart/form-data body:\n{error}", {
|
|
2100
|
+
identifier,
|
|
2101
|
+
error
|
|
2102
|
+
});
|
|
2103
|
+
return new Response("Invalid multipart/form-data body.", {
|
|
2104
|
+
status: 400,
|
|
2105
|
+
headers: plainTextHeaders
|
|
2106
|
+
});
|
|
2107
|
+
}
|
|
2108
|
+
const rebuild = () => new Request(request.url, {
|
|
2109
|
+
method: request.method,
|
|
2110
|
+
headers: request.headers,
|
|
2111
|
+
body: body.byteLength > 0 ? body : void 0
|
|
2112
|
+
});
|
|
2113
|
+
const authorizeContext = ctx.clone(ctx.data);
|
|
2114
|
+
authorizeContext.request = rebuild();
|
|
2115
|
+
if (!await authorizePredicate(authorizeContext, identifier)) return await onUnauthorized(rebuild());
|
|
2116
|
+
request = rebuild();
|
|
2117
|
+
}
|
|
2118
|
+
let form;
|
|
2119
|
+
try {
|
|
2120
|
+
form = await request.formData();
|
|
2121
|
+
} catch (error) {
|
|
2122
|
+
logger.error("Failed to parse the multipart/form-data body:\n{error}", {
|
|
2123
|
+
identifier,
|
|
2124
|
+
error
|
|
2125
|
+
});
|
|
2126
|
+
return new Response("Invalid multipart/form-data body.", {
|
|
2127
|
+
status: 400,
|
|
2128
|
+
headers: plainTextHeaders
|
|
2129
|
+
});
|
|
2130
|
+
}
|
|
2131
|
+
const file = form.get("file");
|
|
2132
|
+
if (!(file instanceof File)) {
|
|
2133
|
+
logger.error("The media upload request has no file field.", { identifier });
|
|
2134
|
+
return new Response("Missing file field.", {
|
|
2135
|
+
status: 400,
|
|
2136
|
+
headers: plainTextHeaders
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2139
|
+
const objectField = form.get("object");
|
|
2140
|
+
if (objectField == null) {
|
|
2141
|
+
logger.error("The media upload request has no object field.", { identifier });
|
|
2142
|
+
return new Response("Missing object field.", {
|
|
2143
|
+
status: 400,
|
|
2144
|
+
headers: plainTextHeaders
|
|
2145
|
+
});
|
|
2146
|
+
}
|
|
2147
|
+
let object;
|
|
2148
|
+
try {
|
|
2149
|
+
const objectText = typeof objectField === "string" ? objectField : await objectField.text();
|
|
2150
|
+
object = await _fedify_vocab.Object.fromJsonLd(JSON.parse(objectText), ctx);
|
|
2151
|
+
} catch (error) {
|
|
2152
|
+
logger.error("Failed to parse the object field:\n{error}", {
|
|
2153
|
+
identifier,
|
|
2154
|
+
error
|
|
2155
|
+
});
|
|
2156
|
+
return new Response("Invalid object field.", {
|
|
2157
|
+
status: 400,
|
|
2158
|
+
headers: plainTextHeaders
|
|
2159
|
+
});
|
|
2160
|
+
}
|
|
2161
|
+
let result;
|
|
2162
|
+
try {
|
|
2163
|
+
result = await mediaUploaderCallback(ctx, identifier, file, object);
|
|
2164
|
+
} catch (error) {
|
|
2165
|
+
logger.error("Failed to process the media upload:\n{error}", {
|
|
2166
|
+
identifier,
|
|
2167
|
+
error
|
|
2168
|
+
});
|
|
2169
|
+
return new Response("Internal server error.", {
|
|
2170
|
+
status: 500,
|
|
2171
|
+
headers: plainTextHeaders
|
|
2172
|
+
});
|
|
2173
|
+
}
|
|
2174
|
+
if (result == null) {
|
|
2175
|
+
logger.error("The media uploader callback for {identifier} returned null or undefined; it must return an object (201 Created) or a URL (202 Accepted).", { identifier });
|
|
2176
|
+
return new Response("Internal server error.", {
|
|
2177
|
+
status: 500,
|
|
2178
|
+
headers: plainTextHeaders
|
|
2179
|
+
});
|
|
2180
|
+
}
|
|
2181
|
+
const warnUnlessRegistered = (target) => {
|
|
2182
|
+
if (isRegisteredObjectUri(target)) return;
|
|
2183
|
+
logger.warn("The media uploader callback for {identifier} returned {target}, which does not point at a registered object dispatcher route; derive the returned id/URL from Context.getObjectUri(). The upload still succeeded.", {
|
|
2184
|
+
identifier,
|
|
2185
|
+
target: target.href
|
|
2186
|
+
});
|
|
2187
|
+
};
|
|
2188
|
+
if (result instanceof URL) {
|
|
2189
|
+
warnUnlessRegistered(result);
|
|
2190
|
+
logger.info("The media upload for {identifier} is still being processed; responding 202 Accepted.", {
|
|
2191
|
+
identifier,
|
|
2192
|
+
location: result.href
|
|
2193
|
+
});
|
|
2194
|
+
return new Response(null, {
|
|
2195
|
+
status: 202,
|
|
2196
|
+
headers: { Location: result.href }
|
|
2197
|
+
});
|
|
2198
|
+
}
|
|
2199
|
+
if (result.id == null) {
|
|
2200
|
+
logger.error("The media uploader callback for {identifier} returned an object without an id, so a 201 Created response cannot include the required Location header. Set the object's id with Context.getObjectUri(), or return the eventual URL to respond 202 Accepted instead.", { identifier });
|
|
2201
|
+
return new Response("Internal server error.", {
|
|
2202
|
+
status: 500,
|
|
2203
|
+
headers: plainTextHeaders
|
|
2204
|
+
});
|
|
2205
|
+
}
|
|
2206
|
+
warnUnlessRegistered(result.id);
|
|
2207
|
+
let jsonLd;
|
|
2208
|
+
try {
|
|
2209
|
+
jsonLd = await result.toJsonLd(ctx);
|
|
2210
|
+
} catch (error) {
|
|
2211
|
+
logger.error("Failed to serialize the uploaded object to JSON-LD:\n{error}", {
|
|
2212
|
+
identifier,
|
|
2213
|
+
error
|
|
2214
|
+
});
|
|
2215
|
+
return new Response("Internal server error.", {
|
|
2216
|
+
status: 500,
|
|
2217
|
+
headers: plainTextHeaders
|
|
2218
|
+
});
|
|
2219
|
+
}
|
|
2220
|
+
logger.info("The media upload for {identifier} is ready; responding 201 Created.", {
|
|
2221
|
+
identifier,
|
|
2222
|
+
location: result.id.href
|
|
2223
|
+
});
|
|
2224
|
+
return new Response(JSON.stringify(jsonLd), {
|
|
2225
|
+
status: 201,
|
|
2226
|
+
headers: {
|
|
2227
|
+
"Content-Type": "application/activity+json",
|
|
2228
|
+
Location: result.id.href
|
|
2229
|
+
}
|
|
2230
|
+
});
|
|
2231
|
+
}
|
|
2018
2232
|
/**
|
|
2019
2233
|
* Handles an inbox request for ActivityPub activities.
|
|
2020
2234
|
* @template TContextData The context data to pass to the context.
|
|
@@ -3070,7 +3284,7 @@ async function buildAcceptSignatureHeader(policy, kv, noncePrefix) {
|
|
|
3070
3284
|
}
|
|
3071
3285
|
async function setKey(kv, key, policy) {
|
|
3072
3286
|
const seconds = policy.nonceTtlSeconds ?? 300;
|
|
3073
|
-
const ttl = Temporal.Duration.from({ seconds });
|
|
3287
|
+
const ttl = Temporal$4.Duration.from({ seconds });
|
|
3074
3288
|
await kv.set(key, true, { ttl });
|
|
3075
3289
|
}
|
|
3076
3290
|
const DEF_COMPONENTS = [
|
|
@@ -3545,6 +3759,7 @@ function serializeDataPointType(dataPointType) {
|
|
|
3545
3759
|
}
|
|
3546
3760
|
//#endregion
|
|
3547
3761
|
//#region src/federation/retry.ts
|
|
3762
|
+
const Temporal$3 = require_temporal_polyfill.Temporal;
|
|
3548
3763
|
/**
|
|
3549
3764
|
* Creates an exponential backoff retry policy. The delay between retries
|
|
3550
3765
|
* starts at the `initialDelay` and is multiplied by the `factor` for each
|
|
@@ -3556,8 +3771,8 @@ function serializeDataPointType(dataPointType) {
|
|
|
3556
3771
|
* @since 0.12.0
|
|
3557
3772
|
*/
|
|
3558
3773
|
function createExponentialBackoffPolicy(options = {}) {
|
|
3559
|
-
const initialDelay = Temporal.Duration.from(options.initialDelay ?? { seconds: 1 });
|
|
3560
|
-
const maxDelay = Temporal.Duration.from(options.maxDelay ?? { hours: 12 });
|
|
3774
|
+
const initialDelay = Temporal$3.Duration.from(options.initialDelay ?? { seconds: 1 });
|
|
3775
|
+
const maxDelay = Temporal$3.Duration.from(options.maxDelay ?? { hours: 12 });
|
|
3561
3776
|
const maxAttempts = options.maxAttempts ?? 10;
|
|
3562
3777
|
const factor = options.factor ?? 2;
|
|
3563
3778
|
const jitter = options.jitter ?? true;
|
|
@@ -3569,8 +3784,8 @@ function createExponentialBackoffPolicy(options = {}) {
|
|
|
3569
3784
|
milliseconds *= 1 + Math.random();
|
|
3570
3785
|
milliseconds = Math.round(milliseconds);
|
|
3571
3786
|
}
|
|
3572
|
-
const delay = Temporal.Duration.from({ milliseconds });
|
|
3573
|
-
return Temporal.Duration.compare(delay, maxDelay) > 0 ? maxDelay : delay;
|
|
3787
|
+
const delay = Temporal$3.Duration.from({ milliseconds });
|
|
3788
|
+
return Temporal$3.Duration.compare(delay, maxDelay) > 0 ? maxDelay : delay;
|
|
3574
3789
|
};
|
|
3575
3790
|
}
|
|
3576
3791
|
//#endregion
|
|
@@ -3693,6 +3908,7 @@ const classReviver = (filter, init, set) => (seen, revive, node) => {
|
|
|
3693
3908
|
};
|
|
3694
3909
|
//#endregion
|
|
3695
3910
|
//#region src/federation/mq.ts
|
|
3911
|
+
const Temporal$2 = require_temporal_polyfill.Temporal;
|
|
3696
3912
|
/**
|
|
3697
3913
|
* A message queue that processes messages in the same process.
|
|
3698
3914
|
* Do not use this in production as it does neither persist messages nor
|
|
@@ -3727,7 +3943,7 @@ var InProcessMessageQueue = class {
|
|
|
3727
3943
|
constructor(options = {}) {
|
|
3728
3944
|
this.#messages = [];
|
|
3729
3945
|
this.#monitors = {};
|
|
3730
|
-
this.#pollIntervalMs = Temporal.Duration.from(options.pollInterval ?? { seconds: 5 }).total("millisecond");
|
|
3946
|
+
this.#pollIntervalMs = Temporal$2.Duration.from(options.pollInterval ?? { seconds: 5 }).total("millisecond");
|
|
3731
3947
|
this.#delayedMessages = 0;
|
|
3732
3948
|
this.#processingKeys = /* @__PURE__ */ new Set();
|
|
3733
3949
|
}
|
|
@@ -3973,6 +4189,7 @@ var ParallelMessageQueue = class ParallelMessageQueue {
|
|
|
3973
4189
|
*
|
|
3974
4190
|
* @module
|
|
3975
4191
|
*/
|
|
4192
|
+
const Temporal$1 = require_temporal_polyfill.Temporal;
|
|
3976
4193
|
/**
|
|
3977
4194
|
* Validates the task handle, plans deduplication, encodes every payload, then
|
|
3978
4195
|
* dispatches the resulting messages to the queue. A single item flows through
|
|
@@ -4018,7 +4235,7 @@ const enqueueTasks = (ctx) => async function(task, items, options) {
|
|
|
4018
4235
|
throw error;
|
|
4019
4236
|
}
|
|
4020
4237
|
};
|
|
4021
|
-
const getDurationIfDefined = (item) => item == null ? void 0 : Temporal.Duration.from(item);
|
|
4238
|
+
const getDurationIfDefined = (item) => item == null ? void 0 : Temporal$1.Duration.from(item);
|
|
4022
4239
|
/**
|
|
4023
4240
|
* Decides how a `deduplicationKey` (if any) is honored: forwarded to a native
|
|
4024
4241
|
* queue, claimed via `cas`, or—when neither is available—dropped or rejected
|
|
@@ -4124,7 +4341,7 @@ const encodeTaskMessage = (codec, origin, task, options) => async (data) => {
|
|
|
4124
4341
|
baseUrl: origin,
|
|
4125
4342
|
taskName: task.name,
|
|
4126
4343
|
data: encoded,
|
|
4127
|
-
started: Temporal.Now.instant().toString(),
|
|
4344
|
+
started: Temporal$1.Now.instant().toString(),
|
|
4128
4345
|
attempt: 0,
|
|
4129
4346
|
orderingKey: options.orderingKey,
|
|
4130
4347
|
traceContext: carrier
|
|
@@ -4352,6 +4569,7 @@ var middleware_exports = /* @__PURE__ */ require_chunk.__exportAll({
|
|
|
4352
4569
|
OutboxContextImpl: () => OutboxContextImpl,
|
|
4353
4570
|
createFederation: () => createFederation
|
|
4354
4571
|
});
|
|
4572
|
+
const Temporal = require_temporal_polyfill.Temporal;
|
|
4355
4573
|
const circuitBreakerCasWarningKvStores = /* @__PURE__ */ new WeakSet();
|
|
4356
4574
|
let nextQueueDepthGaugeSourceId = 0;
|
|
4357
4575
|
const retryAfterHttpDate = /* @__PURE__ */ new RegExp("^(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \\d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \\d{4} \\d{2}:\\d{2}:\\d{2} GMT|(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), \\d{2}-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\\d{2} \\d{2}:\\d{2}:\\d{2} GMT|(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (?: \\d|\\d{2}) \\d{2}:\\d{2}:\\d{2} \\d{4})$");
|
|
@@ -4518,6 +4736,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
4518
4736
|
benchmarkMode;
|
|
4519
4737
|
benchmarkMetricReader;
|
|
4520
4738
|
benchmarkTriggerOptions;
|
|
4739
|
+
#mediaUploaderNoAuthWarned = false;
|
|
4521
4740
|
#queueDepthGaugeSourceId = `fedify-${(++nextQueueDepthGaugeSourceId).toString(36)}`;
|
|
4522
4741
|
#queueDepthGaugeEntries = [];
|
|
4523
4742
|
#queueDepthGaugeMeterProvider;
|
|
@@ -5833,6 +6052,32 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
5833
6052
|
});
|
|
5834
6053
|
case "benchmarkStats": return await handleBenchmarkStats(request, this.benchmarkMetricReader);
|
|
5835
6054
|
case "benchmarkTrigger": return await handleBenchmarkTrigger(request, context, this.benchmarkTriggerOptions);
|
|
6055
|
+
case "mediaUploader":
|
|
6056
|
+
if (request.method !== "POST" || this.mediaUploaderCallback == null) return new Response("Method not allowed.", {
|
|
6057
|
+
status: 405,
|
|
6058
|
+
headers: {
|
|
6059
|
+
Allow: "POST",
|
|
6060
|
+
"Content-Type": "text/plain; charset=utf-8"
|
|
6061
|
+
}
|
|
6062
|
+
});
|
|
6063
|
+
if (this.mediaUploaderAuthorizePredicate == null && !this.#mediaUploaderNoAuthWarned) {
|
|
6064
|
+
this.#mediaUploaderNoAuthWarned = true;
|
|
6065
|
+
(0, _logtape_logtape.getLogger)([
|
|
6066
|
+
"fedify",
|
|
6067
|
+
"federation",
|
|
6068
|
+
"mediaUploader"
|
|
6069
|
+
]).warn("The media uploader is registered without an authorize() hook, so it accepts uploads from anyone who can reach the endpoint. Protect it with .authorize() unless a public upload endpoint is intended.");
|
|
6070
|
+
}
|
|
6071
|
+
return await handleMediaUpload(request, {
|
|
6072
|
+
identifier: route.values.identifier,
|
|
6073
|
+
context,
|
|
6074
|
+
mediaUploaderCallback: this.mediaUploaderCallback,
|
|
6075
|
+
actorDispatcher: this.actorCallbacks?.dispatcher,
|
|
6076
|
+
authorizePredicate: this.mediaUploaderAuthorizePredicate,
|
|
6077
|
+
isRegisteredObjectUri: (uri) => context.parseUri(uri)?.type === "object",
|
|
6078
|
+
onUnauthorized,
|
|
6079
|
+
onNotFound
|
|
6080
|
+
});
|
|
5836
6081
|
}
|
|
5837
6082
|
if (request.method !== "POST" && !acceptsJsonLd(request)) {
|
|
5838
6083
|
metricState.endpoint = "not_acceptable";
|
|
@@ -6067,6 +6312,7 @@ function getEndpointCategory(routeName) {
|
|
|
6067
6312
|
case "inbox": return "inbox";
|
|
6068
6313
|
case "sharedInbox": return "shared_inbox";
|
|
6069
6314
|
case "outbox": return "outbox";
|
|
6315
|
+
case "mediaUploader": return "media_upload";
|
|
6070
6316
|
case "following": return "following";
|
|
6071
6317
|
case "followers": return "followers";
|
|
6072
6318
|
case "liked": return "liked";
|
|
@@ -6200,6 +6446,11 @@ var ContextImpl = class ContextImpl {
|
|
|
6200
6446
|
if (path == null) throw new _fedify_uri_template.RouterError("No outbox dispatcher registered.");
|
|
6201
6447
|
return new URL(path, this.canonicalOrigin);
|
|
6202
6448
|
}
|
|
6449
|
+
getMediaUploaderUri(identifier) {
|
|
6450
|
+
const path = this.federation.router.build("mediaUploader", { identifier });
|
|
6451
|
+
if (path == null) throw new _fedify_uri_template.RouterError("No media uploader registered.");
|
|
6452
|
+
return new URL(path, this.canonicalOrigin);
|
|
6453
|
+
}
|
|
6203
6454
|
getInboxUri(identifier) {
|
|
6204
6455
|
if (identifier == null) {
|
|
6205
6456
|
const path = this.federation.router.build("sharedInbox", {});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import {
|
|
2
|
+
import { Mt as WebFingerLinksDispatcher, ct as ActorAliasMapper, l as RequestContext, lt as ActorDispatcher, ut as ActorHandleMapper } from "./context-Zii1f5xS.js";
|
|
3
3
|
import { RouterError, RouterOptions, RouterRouteResult } from "@fedify/uri-template";
|
|
4
4
|
import { MeterProvider, Span, Tracer } from "@opentelemetry/api";
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import {
|
|
2
|
+
import { Mt as WebFingerLinksDispatcher, ct as ActorAliasMapper, l as RequestContext, lt as ActorDispatcher, ut as ActorHandleMapper } from "./context-lxX6I7as.cjs";
|
|
3
3
|
import { MeterProvider, Span, Tracer } from "@opentelemetry/api";
|
|
4
4
|
import { RouterError, RouterOptions, RouterRouteResult } from "@fedify/uri-template";
|
|
5
5
|
|
package/dist/mod.cjs
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
1
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
require("./chunk-
|
|
5
|
-
const require_transformers = require("./transformers-
|
|
3
|
+
require("./chunk-Czpeue4M.cjs");
|
|
4
|
+
const require_transformers = require("./transformers-DGwl-hD1.cjs");
|
|
6
5
|
require("./compat/mod.cjs");
|
|
7
|
-
const require_http = require("./http-
|
|
8
|
-
const require_middleware = require("./middleware-
|
|
9
|
-
const require_proof = require("./proof-
|
|
10
|
-
const require_types = require("./types-
|
|
11
|
-
const require_kv_cache = require("./kv-cache-
|
|
6
|
+
const require_http = require("./http-D5ylizT7.cjs");
|
|
7
|
+
const require_middleware = require("./middleware-nmfhGFtV.cjs");
|
|
8
|
+
const require_proof = require("./proof-DcOiiLDF.cjs");
|
|
9
|
+
const require_types = require("./types-CPym83zc.cjs");
|
|
10
|
+
const require_kv_cache = require("./kv-cache-DbFdquuM.cjs");
|
|
12
11
|
const require_federation_mod = require("./federation/mod.cjs");
|
|
13
12
|
require("./nodeinfo/mod.cjs");
|
|
14
13
|
require("./runtime/mod.cjs");
|