@fedify/fedify 2.3.0 → 2.3.2-dev.1556
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -7
- package/dist/{builder-DYXTKqvC.mjs → builder-DosLp_w5.mjs} +2 -2
- package/dist/{circuit-breaker-CSWsyoef.mjs → circuit-breaker-DLS_n1x5.mjs} +190 -7
- package/dist/circuit-breaker-test-utils-BVnv3T76.mjs +14 -0
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/transformers.test.mjs +1 -1
- package/dist/{context-BBVLF7lx.d.cts → context-Bjswu3eC.d.cts} +18 -1
- package/dist/{context-BU6jSQdo.d.ts → context-COxc_O-c.d.ts} +18 -1
- package/dist/{deno-ChfuM30K.mjs → deno-Bg8I1L40.mjs} +1 -1
- package/dist/{docloader-Bu-Oecom.mjs → docloader-Dxsk3R8v.mjs} +2 -2
- package/dist/federation/builder.test.mjs +1 -1
- package/dist/federation/circuit-breaker.test.mjs +622 -3
- package/dist/federation/handler.test.mjs +3 -3
- package/dist/federation/idempotency.test.mjs +2 -2
- package/dist/federation/metrics.test.mjs +1 -1
- package/dist/federation/middleware.test.mjs +16 -8
- 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/send.test.mjs +3 -3
- package/dist/federation/temporal.test.mjs +1 -1
- package/dist/federation/webfinger.test.mjs +1 -1
- package/dist/{http-Cm_e9dY7.mjs → http-BaUm6xbz.mjs} +3 -3
- package/dist/{http-CiPBp7Ax.js → http-Bw8wN_Uk.js} +17 -7
- package/dist/{http-Q2nW0DHO.cjs → http-y8Cigpuq.cjs} +17 -7
- package/dist/{key-nrqRBwjx.mjs → key-DOnwUeY9.mjs} +18 -8
- package/dist/{kv-cache-QkLiue07.cjs → kv-cache-B9AAXEOS.cjs} +1 -1
- package/dist/{kv-cache-B3Na5DMI.mjs → kv-cache-CE_QUNa6.mjs} +1 -1
- package/dist/{kv-cache-BQLjC1KN.js → kv-cache-DilyIIfz.js} +1 -1
- package/dist/{ld-CaRoGhYH.mjs → ld-CiONXo2U.mjs} +3 -3
- package/dist/{metrics-BSUZSyQU.mjs → metrics-CmX7KEfY.mjs} +1 -1
- package/dist/{middleware-BIj0BBxb.js → middleware-BEhF8uxY.js} +214 -14
- package/dist/{middleware-BIctkZ9S.mjs → middleware-CRMohX8-.mjs} +1 -1
- package/dist/{middleware-CwJv5KxX.mjs → middleware-Cf0dFqr9.mjs} +34 -17
- package/dist/{middleware-DXLo-UOS.cjs → middleware-DZf3vcun.cjs} +214 -14
- package/dist/{mod-C0F6kvgS.d.cts → mod-0bIqGrKQ.d.cts} +1 -1
- package/dist/{mod-vPYVoa5n.d.ts → mod-3H9Gym5G.d.ts} +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/handler.test.mjs +1 -1
- package/dist/{owner-CyK8YW7-.mjs → owner-C7h5_D1P.mjs} +2 -2
- package/dist/{proof-CIUSLcHg.cjs → proof-BKOUYRRh.cjs} +1 -1
- package/dist/{proof-DXHo4Yon.mjs → proof-BVuILGqP.mjs} +3 -3
- package/dist/{proof-Ba14ORbL.js → proof-DNlVt3rz.js} +1 -1
- package/dist/{send-B4Ld91pX.mjs → send-7kSXrsl4.mjs} +3 -3
- package/dist/sig/http.test.mjs +2 -2
- package/dist/sig/key.test.mjs +51 -1
- package/dist/sig/ld.test.mjs +2 -2
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +1 -1
- package/dist/sig/proof.test.mjs +1 -1
- package/dist/{temporal-E7cF2Hsh.mjs → temporal-D3Bspq6d.mjs} +1 -1
- package/dist/utils/docloader.test.mjs +2 -2
- 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 +6 -6
|
@@ -2,10 +2,10 @@ const { Temporal } = require("@js-temporal/polyfill");
|
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
3
|
const require_chunk = require("./chunk-DDcVe30Y.cjs");
|
|
4
4
|
const require_transformers = require("./transformers-NeAONrAq.cjs");
|
|
5
|
-
const require_http = require("./http-
|
|
6
|
-
const require_proof = require("./proof-
|
|
5
|
+
const require_http = require("./http-y8Cigpuq.cjs");
|
|
6
|
+
const require_proof = require("./proof-BKOUYRRh.cjs");
|
|
7
7
|
const require_types = require("./types-KC4QAoxe.cjs");
|
|
8
|
-
const require_kv_cache = require("./kv-cache-
|
|
8
|
+
const require_kv_cache = require("./kv-cache-B9AAXEOS.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");
|
|
@@ -681,6 +681,13 @@ function createFederationBuilder() {
|
|
|
681
681
|
//#endregion
|
|
682
682
|
//#region src/federation/circuit-breaker.ts
|
|
683
683
|
const MAX_CUSTOM_FAILURE_HISTORY = 100;
|
|
684
|
+
const LEGACY_SWEEP_MARKER = ["__fedify_meta", "circuit_breaker_state_ttl_sweep_v1"];
|
|
685
|
+
const LEGACY_SWEEP_DELETING_MARKER = { __fedifyDeletingCircuitBreakerLegacyState: true };
|
|
686
|
+
const CIRCUIT_BREAKER_STATE_VERSION = 1;
|
|
687
|
+
const LEGACY_SWEEP_LOCK_TTL = Temporal.Duration.from({ minutes: 5 });
|
|
688
|
+
const LEGACY_SWEEP_RETRY_WINDOW = Temporal.Duration.from({ hours: 168 });
|
|
689
|
+
const LEGACY_SWEEP_WAIT_INTERVAL = 10;
|
|
690
|
+
const LEGACY_SWEEP_CAS_ATTEMPTS = 3;
|
|
684
691
|
/**
|
|
685
692
|
* Tracks reachability state for remote outbox delivery hosts.
|
|
686
693
|
* @since 2.3.0
|
|
@@ -690,6 +697,8 @@ var CircuitBreaker = class {
|
|
|
690
697
|
#prefix;
|
|
691
698
|
#options;
|
|
692
699
|
#now;
|
|
700
|
+
#legacySweep;
|
|
701
|
+
#legacySweepDone;
|
|
693
702
|
#stateChangeObserver;
|
|
694
703
|
constructor(options) {
|
|
695
704
|
this.#kv = options.kv;
|
|
@@ -706,6 +715,7 @@ var CircuitBreaker = class {
|
|
|
706
715
|
return now.until(this.#capHeldRetryAt(now, heldSince, now.add(delay)));
|
|
707
716
|
}
|
|
708
717
|
async beforeSend(remoteHost, message) {
|
|
718
|
+
this.#sweepLegacyStates();
|
|
709
719
|
const heldSince = parseHeldSince(message.circuitHeldSince);
|
|
710
720
|
const now = this.#now();
|
|
711
721
|
if (heldSince != null && Temporal.Instant.compare(heldSince.add(this.#options.heldActivityTtl), now) <= 0) return {
|
|
@@ -787,6 +797,7 @@ var CircuitBreaker = class {
|
|
|
787
797
|
throw new Error(`Failed to update circuit breaker state for ${remoteHost}`);
|
|
788
798
|
}
|
|
789
799
|
async recordSuccess(remoteHost) {
|
|
800
|
+
this.#sweepLegacyStates();
|
|
790
801
|
for (let attempt = 0; attempt < 10; attempt++) {
|
|
791
802
|
const oldState = await this.#get(remoteHost);
|
|
792
803
|
if (oldState == null) return void 0;
|
|
@@ -807,6 +818,7 @@ var CircuitBreaker = class {
|
|
|
807
818
|
return await this.recordSuccess(remoteHost);
|
|
808
819
|
}
|
|
809
820
|
async recordFailure(remoteHost) {
|
|
821
|
+
this.#sweepLegacyStates();
|
|
810
822
|
const now = this.#now();
|
|
811
823
|
for (let attempt = 0; attempt < 10; attempt++) {
|
|
812
824
|
const oldState = await this.#get(remoteHost);
|
|
@@ -854,26 +866,122 @@ var CircuitBreaker = class {
|
|
|
854
866
|
}
|
|
855
867
|
}
|
|
856
868
|
async getState(remoteHost) {
|
|
857
|
-
|
|
869
|
+
this.#sweepLegacyStates();
|
|
870
|
+
return stripStoredCircuitBreakerState(await this.#get(remoteHost));
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* The currently running background legacy sweep, if any.
|
|
874
|
+
* @internal
|
|
875
|
+
*/
|
|
876
|
+
get pendingSweep() {
|
|
877
|
+
return this.#legacySweep;
|
|
858
878
|
}
|
|
859
879
|
#key(remoteHost) {
|
|
860
880
|
return [...this.#prefix, remoteHost];
|
|
861
881
|
}
|
|
882
|
+
#legacySweepMarkerKey() {
|
|
883
|
+
return [...this.#prefix, ...LEGACY_SWEEP_MARKER];
|
|
884
|
+
}
|
|
885
|
+
#sweepLegacyStates() {
|
|
886
|
+
if (this.#kv.cas == null) return;
|
|
887
|
+
if (this.#options.stateTtl == null) return;
|
|
888
|
+
if (this.#legacySweep != null) return;
|
|
889
|
+
if (this.#isLegacySweepDone()) return;
|
|
890
|
+
this.#legacySweep = this.#sweepLegacyStatesImpl().catch((error) => {
|
|
891
|
+
(0, _logtape_logtape.getLogger)([
|
|
892
|
+
"fedify",
|
|
893
|
+
"federation",
|
|
894
|
+
"circuit"
|
|
895
|
+
]).warn("Failed to sweep legacy circuit breaker state:\n{error}", { error });
|
|
896
|
+
}).finally(() => {
|
|
897
|
+
this.#legacySweep = void 0;
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
async #sweepLegacyStatesImpl() {
|
|
901
|
+
const markerKey = this.#legacySweepMarkerKey();
|
|
902
|
+
const marker = await this.#acquireLegacySweep(markerKey);
|
|
903
|
+
if (marker === "done") return;
|
|
904
|
+
try {
|
|
905
|
+
for await (const { key, value } of this.#kv.list(this.#prefix)) {
|
|
906
|
+
if (key.length !== this.#prefix.length + 1) continue;
|
|
907
|
+
await this.#migrateLegacyState(key, value);
|
|
908
|
+
}
|
|
909
|
+
} catch (error) {
|
|
910
|
+
await this.#deleteIfUnchanged(markerKey, marker);
|
|
911
|
+
throw error;
|
|
912
|
+
}
|
|
913
|
+
const finishedMarker = this.#finishLegacySweepMarker(marker);
|
|
914
|
+
if (await this.#kv.cas(markerKey, marker, finishedMarker)) this.#rememberLegacySweepMarker(finishedMarker);
|
|
915
|
+
}
|
|
916
|
+
#finishLegacySweepMarker(marker) {
|
|
917
|
+
const retryUntil = getLegacySweepRetryUntil(marker);
|
|
918
|
+
if (retryUntil != null && Temporal.Instant.compare(this.#now(), Temporal.Instant.from(retryUntil)) < 0) return {
|
|
919
|
+
state: "done",
|
|
920
|
+
retryUntil
|
|
921
|
+
};
|
|
922
|
+
return { state: "final" };
|
|
923
|
+
}
|
|
924
|
+
async #migrateLegacyState(key, value) {
|
|
925
|
+
if (isCurrentCircuitBreakerState(value)) return;
|
|
926
|
+
const state = parseCircuitBreakerKvState(value);
|
|
927
|
+
if (state != null) {
|
|
928
|
+
await this.#kv.cas(key, value, markCircuitBreakerState(state), this.#setOptions());
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
await this.#deleteIfUnchanged(key, value);
|
|
932
|
+
}
|
|
933
|
+
async #deleteIfUnchanged(key, value) {
|
|
934
|
+
if (await this.#kv.cas(key, value, LEGACY_SWEEP_DELETING_MARKER, { ttl: LEGACY_SWEEP_LOCK_TTL })) await this.#kv.delete(key);
|
|
935
|
+
}
|
|
936
|
+
async #acquireLegacySweep(markerKey) {
|
|
937
|
+
for (let attempt = 0; attempt < LEGACY_SWEEP_CAS_ATTEMPTS; attempt++) {
|
|
938
|
+
const marker = await this.#kv.get(markerKey);
|
|
939
|
+
const now = this.#now();
|
|
940
|
+
if (isLegacySweepActive(marker, now)) {
|
|
941
|
+
this.#rememberLegacySweepMarker(marker);
|
|
942
|
+
return "done";
|
|
943
|
+
}
|
|
944
|
+
const retryUntil = isLegacySweepRetryDue(marker, now) ? marker.retryUntil : getLegacySweepRetryUntil(marker) ?? now.add(LEGACY_SWEEP_RETRY_WINDOW).toString();
|
|
945
|
+
const sweeping = {
|
|
946
|
+
state: "sweeping",
|
|
947
|
+
started: now.toString(),
|
|
948
|
+
retryUntil
|
|
949
|
+
};
|
|
950
|
+
if (await this.#kv.cas(markerKey, marker ?? void 0, sweeping, { ttl: LEGACY_SWEEP_LOCK_TTL })) return sweeping;
|
|
951
|
+
await delay(LEGACY_SWEEP_WAIT_INTERVAL);
|
|
952
|
+
}
|
|
953
|
+
return "done";
|
|
954
|
+
}
|
|
955
|
+
#isLegacySweepDone() {
|
|
956
|
+
if (this.#legacySweepDone === "final") return true;
|
|
957
|
+
if (this.#legacySweepDone == null) return false;
|
|
958
|
+
if (Temporal.Instant.compare(this.#now(), this.#legacySweepDone) < 0) return true;
|
|
959
|
+
this.#legacySweepDone = void 0;
|
|
960
|
+
return false;
|
|
961
|
+
}
|
|
962
|
+
#rememberLegacySweepMarker(marker) {
|
|
963
|
+
const doneUntil = getLegacySweepDoneUntil(marker, this.#now());
|
|
964
|
+
if (doneUntil != null) this.#legacySweepDone = doneUntil;
|
|
965
|
+
}
|
|
862
966
|
#capHeldRetryAt(now, heldSince, retryAt) {
|
|
863
967
|
const expiresAt = (heldSince ?? now).add(this.#options.heldActivityTtl);
|
|
864
968
|
return Temporal.Instant.compare(expiresAt, retryAt) < 0 ? expiresAt : retryAt;
|
|
865
969
|
}
|
|
866
970
|
async #get(remoteHost) {
|
|
867
|
-
return
|
|
971
|
+
return parseStoredCircuitBreakerKvState(await this.#kv.get(this.#key(remoteHost)));
|
|
868
972
|
}
|
|
869
973
|
async #replace(remoteHost, oldState, newState) {
|
|
870
974
|
const key = this.#key(remoteHost);
|
|
975
|
+
const storedState = newState == null ? void 0 : markCircuitBreakerState(newState);
|
|
871
976
|
if (this.#kv.cas == null) {
|
|
872
|
-
if (
|
|
873
|
-
else await this.#kv.set(key,
|
|
977
|
+
if (storedState == null) await this.#kv.delete(key);
|
|
978
|
+
else await this.#kv.set(key, storedState, this.#setOptions());
|
|
874
979
|
return true;
|
|
875
980
|
}
|
|
876
|
-
return await this.#kv.cas(key, oldState,
|
|
981
|
+
return await this.#kv.cas(key, oldState, storedState, storedState == null ? void 0 : this.#setOptions());
|
|
982
|
+
}
|
|
983
|
+
#setOptions() {
|
|
984
|
+
return this.#options.stateTtl == null ? void 0 : { ttl: this.#options.stateTtl };
|
|
877
985
|
}
|
|
878
986
|
async #notifyStateChange(remoteHost, previousState, newState) {
|
|
879
987
|
try {
|
|
@@ -913,18 +1021,25 @@ var CircuitBreaker = class {
|
|
|
913
1021
|
* @param options The public circuit breaker options supplied to Fedify.
|
|
914
1022
|
* @returns The normalized failure predicate, failure pruning function,
|
|
915
1023
|
* duration values, and optional callbacks with defaults applied.
|
|
916
|
-
* @throws {RangeError} If any configured duration is not positive
|
|
1024
|
+
* @throws {RangeError} If any configured duration is not positive, or if
|
|
1025
|
+
* `stateTtl` is shorter than `recoveryDelay`.
|
|
917
1026
|
* @throws {TypeError} If `failureThreshold` is not a positive integer.
|
|
918
1027
|
*/
|
|
919
1028
|
function normalizeCircuitBreakerOptions(options) {
|
|
920
1029
|
const recoveryDelay = toInstantDuration(options.recoveryDelay ?? { minutes: 30 });
|
|
921
1030
|
const heldActivityTtl = toInstantDuration(options.heldActivityTtl ?? { hours: 168 });
|
|
922
1031
|
const releaseInterval = toInstantDuration(options.releaseInterval ?? { seconds: 1 });
|
|
1032
|
+
const configuredStateTtl = options.stateTtl == null ? void 0 : toInstantDuration(options.stateTtl);
|
|
923
1033
|
assertPositiveDuration(recoveryDelay, "recoveryDelay");
|
|
924
1034
|
assertPositiveDuration(heldActivityTtl, "heldActivityTtl");
|
|
925
1035
|
assertPositiveDuration(releaseInterval, "releaseInterval");
|
|
1036
|
+
if (configuredStateTtl != null) {
|
|
1037
|
+
assertPositiveDuration(configuredStateTtl, "stateTtl");
|
|
1038
|
+
if (Temporal.Duration.compare(configuredStateTtl, recoveryDelay) < 0) throw new RangeError("stateTtl must be at least recoveryDelay.");
|
|
1039
|
+
}
|
|
926
1040
|
let failure;
|
|
927
1041
|
let pruneFailures;
|
|
1042
|
+
let stateTtl;
|
|
928
1043
|
if (options.failure == null) {
|
|
929
1044
|
const failureThreshold = options.failureThreshold ?? 5;
|
|
930
1045
|
if (!Number.isInteger(failureThreshold) || failureThreshold <= 0) throw new TypeError("failureThreshold must be a positive integer.");
|
|
@@ -940,9 +1055,11 @@ function normalizeCircuitBreakerOptions(options) {
|
|
|
940
1055
|
const last = timestamps[timestamps.length - 1];
|
|
941
1056
|
return Temporal.Duration.compare(first.until(last), failureWindow) <= 0;
|
|
942
1057
|
};
|
|
1058
|
+
stateTtl = configuredStateTtl ?? maxDuration(recoveryDelay.add(failureWindow), recoveryDelay.add(heldActivityTtl));
|
|
943
1059
|
} else {
|
|
944
1060
|
failure = options.failure;
|
|
945
1061
|
pruneFailures = (timestamps) => timestamps.slice(-MAX_CUSTOM_FAILURE_HISTORY);
|
|
1062
|
+
stateTtl = configuredStateTtl;
|
|
946
1063
|
}
|
|
947
1064
|
return {
|
|
948
1065
|
failure,
|
|
@@ -950,10 +1067,72 @@ function normalizeCircuitBreakerOptions(options) {
|
|
|
950
1067
|
recoveryDelay,
|
|
951
1068
|
heldActivityTtl,
|
|
952
1069
|
releaseInterval,
|
|
1070
|
+
stateTtl,
|
|
953
1071
|
onStateChange: options.onStateChange,
|
|
954
1072
|
onActivityDrop: options.onActivityDrop
|
|
955
1073
|
};
|
|
956
1074
|
}
|
|
1075
|
+
function maxDuration(duration, ...durations) {
|
|
1076
|
+
return durations.reduce((max, candidate) => Temporal.Duration.compare(candidate, max) > 0 ? candidate : max, duration);
|
|
1077
|
+
}
|
|
1078
|
+
function isLegacySweepDone(value, now) {
|
|
1079
|
+
return getLegacySweepDoneUntil(value, now) != null;
|
|
1080
|
+
}
|
|
1081
|
+
function getLegacySweepDoneUntil(value, now) {
|
|
1082
|
+
if (typeof value !== "object" || value == null || !("state" in value)) return;
|
|
1083
|
+
if (value.state === "final") return "final";
|
|
1084
|
+
if (value.state === "done" && "retryUntil" in value && typeof value.retryUntil === "string") try {
|
|
1085
|
+
const retryUntil = Temporal.Instant.from(value.retryUntil);
|
|
1086
|
+
return Temporal.Instant.compare(now, retryUntil) < 0 ? retryUntil : void 0;
|
|
1087
|
+
} catch {
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
function isLegacySweepRetryDue(value, now) {
|
|
1092
|
+
if (typeof value !== "object" || value == null || !("state" in value) || value.state !== "done" || !("retryUntil" in value) || typeof value.retryUntil !== "string") return false;
|
|
1093
|
+
try {
|
|
1094
|
+
return Temporal.Instant.compare(now, Temporal.Instant.from(value.retryUntil)) >= 0;
|
|
1095
|
+
} catch {
|
|
1096
|
+
return false;
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
function isLegacySweepActive(value, now) {
|
|
1100
|
+
return isLegacySweepDone(value, now) || isLegacySweepInProgress(value, now);
|
|
1101
|
+
}
|
|
1102
|
+
function isLegacySweepInProgress(value, now) {
|
|
1103
|
+
if (typeof value !== "object" || value == null || !("state" in value) || value.state !== "sweeping" || !("started" in value) || typeof value.started !== "string") return false;
|
|
1104
|
+
try {
|
|
1105
|
+
return Temporal.Instant.compare(now, Temporal.Instant.from(value.started).add(LEGACY_SWEEP_LOCK_TTL)) < 0;
|
|
1106
|
+
} catch {
|
|
1107
|
+
return false;
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
function getLegacySweepRetryUntil(value) {
|
|
1111
|
+
if (typeof value !== "object" || value == null || !("retryUntil" in value) || typeof value.retryUntil !== "string") return;
|
|
1112
|
+
try {
|
|
1113
|
+
Temporal.Instant.from(value.retryUntil);
|
|
1114
|
+
return value.retryUntil;
|
|
1115
|
+
} catch {
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
function isCurrentCircuitBreakerState(value) {
|
|
1120
|
+
return typeof value === "object" && value != null && "__fedifyCircuitBreakerStateVersion" in value && value.__fedifyCircuitBreakerStateVersion === CIRCUIT_BREAKER_STATE_VERSION;
|
|
1121
|
+
}
|
|
1122
|
+
function markCircuitBreakerState(state) {
|
|
1123
|
+
return {
|
|
1124
|
+
...state,
|
|
1125
|
+
__fedifyCircuitBreakerStateVersion: CIRCUIT_BREAKER_STATE_VERSION
|
|
1126
|
+
};
|
|
1127
|
+
}
|
|
1128
|
+
function stripStoredCircuitBreakerState(state) {
|
|
1129
|
+
if (state == null) return void 0;
|
|
1130
|
+
const { __fedifyCircuitBreakerStateVersion: _, ...publicState } = state;
|
|
1131
|
+
return publicState;
|
|
1132
|
+
}
|
|
1133
|
+
function delay(milliseconds) {
|
|
1134
|
+
return new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
1135
|
+
}
|
|
957
1136
|
function toInstantDuration(duration) {
|
|
958
1137
|
const parsed = Temporal.Duration.from(duration);
|
|
959
1138
|
return Temporal.Duration.from({ milliseconds: Math.trunc(parsed.total({
|
|
@@ -988,6 +1167,9 @@ function parseHeldSince(value) {
|
|
|
988
1167
|
* valid instant strings, or `undefined` when the stored value is malformed.
|
|
989
1168
|
*/
|
|
990
1169
|
function parseCircuitBreakerKvState(value) {
|
|
1170
|
+
return stripStoredCircuitBreakerState(parseStoredCircuitBreakerKvState(value));
|
|
1171
|
+
}
|
|
1172
|
+
function parseStoredCircuitBreakerKvState(value) {
|
|
991
1173
|
const isInstantString = (v) => {
|
|
992
1174
|
if (typeof v !== "string") return false;
|
|
993
1175
|
try {
|
|
@@ -1007,7 +1189,8 @@ function parseCircuitBreakerKvState(value) {
|
|
|
1007
1189
|
state: record.state,
|
|
1008
1190
|
failures: record.failures,
|
|
1009
1191
|
...record.opened == null ? {} : { opened: record.opened },
|
|
1010
|
-
...record.halfOpened == null ? {} : { halfOpened: record.halfOpened }
|
|
1192
|
+
...record.halfOpened == null ? {} : { halfOpened: record.halfOpened },
|
|
1193
|
+
...record.__fedifyCircuitBreakerStateVersion === CIRCUIT_BREAKER_STATE_VERSION ? { __fedifyCircuitBreakerStateVersion: CIRCUIT_BREAKER_STATE_VERSION } : {}
|
|
1011
1194
|
};
|
|
1012
1195
|
}
|
|
1013
1196
|
//#endregion
|
|
@@ -3860,6 +4043,15 @@ function isPermanentRemoteContextError(error) {
|
|
|
3860
4043
|
function isPermanentInboxParseError(error) {
|
|
3861
4044
|
return error instanceof Error && (error.name === "UnsafeJsonLdError" || error instanceof require_proof.InvalidContextReferenceError || isPermanentRemoteContextError(error) || error.name === "jsonld.SyntaxError" && !isRemoteContextLoadingFailure(error)) || error instanceof TypeError && (/^(Invalid JSON-LD:|Invalid type:|Unexpected type:|Invalid @id:)/.test(error.message) || require_proof.isInvalidUrlTypeError(error));
|
|
3862
4045
|
}
|
|
4046
|
+
function hasLinkedDataSignatureJsonLdProcessingError(error) {
|
|
4047
|
+
if (error.message.startsWith("Maximum deep iterations exceeded")) return true;
|
|
4048
|
+
const cause = error.cause instanceof Error ? error.cause : error.details?.cause;
|
|
4049
|
+
if (error.name === "jsonld.InvalidUrl" && error.details?.code === "loading remote context failed" && cause instanceof Error) return cause.message.startsWith("Maximum deep iterations exceeded") || cause.name.startsWith("jsonld.");
|
|
4050
|
+
return error.name !== "jsonld.InvalidUrl" && error.name.startsWith("jsonld.");
|
|
4051
|
+
}
|
|
4052
|
+
function isLinkedDataSignatureJsonLdProcessingError(error) {
|
|
4053
|
+
return error instanceof Error && hasLinkedDataSignatureJsonLdProcessingError(error);
|
|
4054
|
+
}
|
|
3863
4055
|
/**
|
|
3864
4056
|
* Create a new {@link Federation} instance.
|
|
3865
4057
|
* @param options Parameters for initializing the instance.
|
|
@@ -4894,10 +5086,18 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
4894
5086
|
privateKey: pair.privateKey
|
|
4895
5087
|
}))
|
|
4896
5088
|
});
|
|
4897
|
-
else
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
5089
|
+
else try {
|
|
5090
|
+
jsonLd = await require_proof.signJsonLd(jsonLd, rsaKey.privateKey, rsaKey.keyId, {
|
|
5091
|
+
contextLoader,
|
|
5092
|
+
tracerProvider: this.tracerProvider
|
|
5093
|
+
});
|
|
5094
|
+
} catch (error) {
|
|
5095
|
+
if (!isLinkedDataSignatureJsonLdProcessingError(error)) throw error;
|
|
5096
|
+
logger.warn("Failed to create a Linked Data signature for the activity {activityId}. The activity will be sent without a Linked Data signature.", {
|
|
5097
|
+
activityId,
|
|
5098
|
+
error
|
|
5099
|
+
});
|
|
5100
|
+
}
|
|
4901
5101
|
if (!hasProof) logger.warn("No supported key found to create a proof for the activity {activityId}. The activity will be sent without a proof. In order to create a proof, at least one Ed25519 key must be provided.", {
|
|
4902
5102
|
activityId,
|
|
4903
5103
|
keys: keys.map((pair) => ({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { G as ActorDispatcher, K as ActorHandleMapper, W as ActorAliasMapper, l as RequestContext, pt as WebFingerLinksDispatcher } from "./context-
|
|
2
|
+
import { G as ActorDispatcher, K as ActorHandleMapper, W as ActorAliasMapper, l as RequestContext, pt as WebFingerLinksDispatcher } from "./context-Bjswu3eC.cjs";
|
|
3
3
|
import { MeterProvider, Span, Tracer } from "@opentelemetry/api";
|
|
4
4
|
import { RouterError, RouterOptions, RouterRouteResult } from "@fedify/uri-template";
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { G as ActorDispatcher, K as ActorHandleMapper, W as ActorAliasMapper, l as RequestContext, pt as WebFingerLinksDispatcher } from "./context-
|
|
2
|
+
import { G as ActorDispatcher, K as ActorHandleMapper, W as ActorAliasMapper, l as RequestContext, pt as WebFingerLinksDispatcher } from "./context-COxc_O-c.js";
|
|
3
3
|
import { RouterError, RouterOptions, RouterRouteResult } from "@fedify/uri-template";
|
|
4
4
|
import { MeterProvider, Span, Tracer } from "@opentelemetry/api";
|
|
5
5
|
|
package/dist/mod.cjs
CHANGED
|
@@ -4,11 +4,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
4
4
|
require("./chunk-DDcVe30Y.cjs");
|
|
5
5
|
const require_transformers = require("./transformers-NeAONrAq.cjs");
|
|
6
6
|
require("./compat/mod.cjs");
|
|
7
|
-
const require_http = require("./http-
|
|
8
|
-
const require_middleware = require("./middleware-
|
|
9
|
-
const require_proof = require("./proof-
|
|
7
|
+
const require_http = require("./http-y8Cigpuq.cjs");
|
|
8
|
+
const require_middleware = require("./middleware-DZf3vcun.cjs");
|
|
9
|
+
const require_proof = require("./proof-BKOUYRRh.cjs");
|
|
10
10
|
const require_types = require("./types-KC4QAoxe.cjs");
|
|
11
|
-
const require_kv_cache = require("./kv-cache-
|
|
11
|
+
const require_kv_cache = require("./kv-cache-B9AAXEOS.cjs");
|
|
12
12
|
const require_federation_mod = require("./federation/mod.cjs");
|
|
13
13
|
require("./nodeinfo/mod.cjs");
|
|
14
14
|
require("./runtime/mod.cjs");
|
package/dist/mod.d.cts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
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-CAM_bQXx.cjs";
|
|
3
3
|
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-VyDTd4G3.cjs";
|
|
4
4
|
import { i as getKeyOwner, n as GetKeyOwnerOptions, r as doesActorOwnKey, t as DoesActorOwnKeyOptions } from "./owner-DEvZuyOE.cjs";
|
|
5
|
-
import { $ as CustomCollectionCursor, A as Rfc6570Expression, At as parseCircuitBreakerKvState, B as createFederationBuilder, C as FederationStartQueueOptions, Ct as CircuitBreakerFailurePolicy, D as InboxListenerSetters, Dt as CircuitBreakerStateChange, E as InboxChallengePolicy, Et as CircuitBreakerState, F as CreateExponentialBackoffPolicyOptions, G as ActorDispatcher, H as respondWithObject, I as RetryContext, J as AuthorizePredicate, K as ActorHandleMapper, L as RetryPolicy, M as FederationOrigin, N as FederationQueueOptions, O as ObjectCallbackSetters, Ot as NormalizedCircuitBreakerOptions, P as createFederation, Q as CustomCollectionCounter, R as createExponentialBackoffPolicy, S as FederationOptions, St as CircuitBreakerCreateOptions, T as IdempotencyStrategy, Tt as CircuitBreakerOptions, U as respondWithObjectIfAcceptable, V as RespondWithObjectOptions, W as ActorAliasMapper, X as CollectionCursor, Y as CollectionCounter, Z as CollectionDispatcher, _ as Federatable, _t as buildCollectionSynchronizationHeader, a as GetSignedKeyOptions, at as ObjectDispatcher, b as FederationBuilder, bt as CircuitBreakerActivityDrop, c as ParseUriResult, ct as OutboxListenerErrorHandler, d as SendActivityOptions, dt as UnverifiedActivityHandler, et as CustomCollectionDispatcher, f as SendActivityOptionsForCollection, ft as UnverifiedActivityReason, g as CustomCollectionCallbackSetters, gt as PageItems, h as ConstructorWithTypeId, ht as SenderKeyPair, i as GetActorOptions, it as ObjectAuthorizePredicate, j as FederationKvPrefixes, jt as ActivityTransformer, k as OutboxListenerSetters, kt as normalizeCircuitBreakerOptions, l as RequestContext, lt as OutboxPermanentFailureHandler, m as CollectionCallbackSetters, mt as SendActivityError, n as Context, nt as InboxListener, o as InboxContext, ot as OutboxErrorHandler, p as ActorCallbackSetters, pt as WebFingerLinksDispatcher, q as ActorKeyPairsDispatcher, r as ForwardActivityOptions, rt as NodeInfoDispatcher, s as OutboxContext, st as OutboxListener, t as ActorKeyPair, tt as InboxErrorHandler, u as RouteActivityOptions, ut as SharedInboxKeyDispatcher, v as Federation, vt as digest, w as IdempotencyKeyCallback, wt as CircuitBreakerKvState, x as FederationFetchOptions, xt as CircuitBreakerBeforeSendDecision, y as FederationBenchmarkOptions, yt as CircuitBreaker, z as Message } from "./context-
|
|
5
|
+
import { $ as CustomCollectionCursor, A as Rfc6570Expression, At as parseCircuitBreakerKvState, B as createFederationBuilder, C as FederationStartQueueOptions, Ct as CircuitBreakerFailurePolicy, D as InboxListenerSetters, Dt as CircuitBreakerStateChange, E as InboxChallengePolicy, Et as CircuitBreakerState, F as CreateExponentialBackoffPolicyOptions, G as ActorDispatcher, H as respondWithObject, I as RetryContext, J as AuthorizePredicate, K as ActorHandleMapper, L as RetryPolicy, M as FederationOrigin, N as FederationQueueOptions, O as ObjectCallbackSetters, Ot as NormalizedCircuitBreakerOptions, P as createFederation, Q as CustomCollectionCounter, R as createExponentialBackoffPolicy, S as FederationOptions, St as CircuitBreakerCreateOptions, T as IdempotencyStrategy, Tt as CircuitBreakerOptions, U as respondWithObjectIfAcceptable, V as RespondWithObjectOptions, W as ActorAliasMapper, X as CollectionCursor, Y as CollectionCounter, Z as CollectionDispatcher, _ as Federatable, _t as buildCollectionSynchronizationHeader, a as GetSignedKeyOptions, at as ObjectDispatcher, b as FederationBuilder, bt as CircuitBreakerActivityDrop, c as ParseUriResult, ct as OutboxListenerErrorHandler, d as SendActivityOptions, dt as UnverifiedActivityHandler, et as CustomCollectionDispatcher, f as SendActivityOptionsForCollection, ft as UnverifiedActivityReason, g as CustomCollectionCallbackSetters, gt as PageItems, h as ConstructorWithTypeId, ht as SenderKeyPair, i as GetActorOptions, it as ObjectAuthorizePredicate, j as FederationKvPrefixes, jt as ActivityTransformer, k as OutboxListenerSetters, kt as normalizeCircuitBreakerOptions, l as RequestContext, lt as OutboxPermanentFailureHandler, m as CollectionCallbackSetters, mt as SendActivityError, n as Context, nt as InboxListener, o as InboxContext, ot as OutboxErrorHandler, p as ActorCallbackSetters, pt as WebFingerLinksDispatcher, q as ActorKeyPairsDispatcher, r as ForwardActivityOptions, rt as NodeInfoDispatcher, s as OutboxContext, st as OutboxListener, t as ActorKeyPair, tt as InboxErrorHandler, u as RouteActivityOptions, ut as SharedInboxKeyDispatcher, v as Federation, vt as digest, w as IdempotencyKeyCallback, wt as CircuitBreakerKvState, x as FederationFetchOptions, xt as CircuitBreakerBeforeSendDecision, y as FederationBenchmarkOptions, yt as CircuitBreaker, z as Message } from "./context-Bjswu3eC.cjs";
|
|
6
6
|
import { a as MemoryKvStore, i as KvStoreSetOptions, n as KvStore, r as KvStoreListEntry, t as KvKey } from "./kv-gJ8LYbxX.cjs";
|
|
7
7
|
import { a as MessageQueueEnqueueOptions, i as MessageQueueDepth, n as InProcessMessageQueueOptions, o as MessageQueueListenOptions, r as MessageQueue, s as ParallelMessageQueue, t as InProcessMessageQueue } from "./mq-D8uSFzxe.cjs";
|
|
8
8
|
import { actorDehydrator, autoIdAssigner, getDefaultActivityTransformers } from "./compat/mod.cjs";
|
|
9
|
-
import { a as RouterOptions, i as RouterError, n as handleWebFinger, o as RouterRouteResult, r as Router, t as WebFingerHandlerParameters } from "./mod-
|
|
9
|
+
import { a as RouterOptions, i as RouterError, n as handleWebFinger, o as RouterRouteResult, r as Router, t as WebFingerHandlerParameters } from "./mod-0bIqGrKQ.cjs";
|
|
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-B0hW12_O.cjs";
|
|
11
11
|
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./mod-yvIXFAEi.cjs";
|
|
12
12
|
export * from "@fedify/vocab-runtime";
|
package/dist/mod.d.ts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
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-CSddvgWN.js";
|
|
3
3
|
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-lf8Hsd91.js";
|
|
4
4
|
import { i as getKeyOwner, n as GetKeyOwnerOptions, r as doesActorOwnKey, t as DoesActorOwnKeyOptions } from "./owner-CnngXDNJ.js";
|
|
5
|
-
import { $ as CustomCollectionCursor, A as Rfc6570Expression, At as parseCircuitBreakerKvState, B as createFederationBuilder, C as FederationStartQueueOptions, Ct as CircuitBreakerFailurePolicy, D as InboxListenerSetters, Dt as CircuitBreakerStateChange, E as InboxChallengePolicy, Et as CircuitBreakerState, F as CreateExponentialBackoffPolicyOptions, G as ActorDispatcher, H as respondWithObject, I as RetryContext, J as AuthorizePredicate, K as ActorHandleMapper, L as RetryPolicy, M as FederationOrigin, N as FederationQueueOptions, O as ObjectCallbackSetters, Ot as NormalizedCircuitBreakerOptions, P as createFederation, Q as CustomCollectionCounter, R as createExponentialBackoffPolicy, S as FederationOptions, St as CircuitBreakerCreateOptions, T as IdempotencyStrategy, Tt as CircuitBreakerOptions, U as respondWithObjectIfAcceptable, V as RespondWithObjectOptions, W as ActorAliasMapper, X as CollectionCursor, Y as CollectionCounter, Z as CollectionDispatcher, _ as Federatable, _t as buildCollectionSynchronizationHeader, a as GetSignedKeyOptions, at as ObjectDispatcher, b as FederationBuilder, bt as CircuitBreakerActivityDrop, c as ParseUriResult, ct as OutboxListenerErrorHandler, d as SendActivityOptions, dt as UnverifiedActivityHandler, et as CustomCollectionDispatcher, f as SendActivityOptionsForCollection, ft as UnverifiedActivityReason, g as CustomCollectionCallbackSetters, gt as PageItems, h as ConstructorWithTypeId, ht as SenderKeyPair, i as GetActorOptions, it as ObjectAuthorizePredicate, j as FederationKvPrefixes, jt as ActivityTransformer, k as OutboxListenerSetters, kt as normalizeCircuitBreakerOptions, l as RequestContext, lt as OutboxPermanentFailureHandler, m as CollectionCallbackSetters, mt as SendActivityError, n as Context, nt as InboxListener, o as InboxContext, ot as OutboxErrorHandler, p as ActorCallbackSetters, pt as WebFingerLinksDispatcher, q as ActorKeyPairsDispatcher, r as ForwardActivityOptions, rt as NodeInfoDispatcher, s as OutboxContext, st as OutboxListener, t as ActorKeyPair, tt as InboxErrorHandler, u as RouteActivityOptions, ut as SharedInboxKeyDispatcher, v as Federation, vt as digest, w as IdempotencyKeyCallback, wt as CircuitBreakerKvState, x as FederationFetchOptions, xt as CircuitBreakerBeforeSendDecision, y as FederationBenchmarkOptions, yt as CircuitBreaker, z as Message } from "./context-
|
|
5
|
+
import { $ as CustomCollectionCursor, A as Rfc6570Expression, At as parseCircuitBreakerKvState, B as createFederationBuilder, C as FederationStartQueueOptions, Ct as CircuitBreakerFailurePolicy, D as InboxListenerSetters, Dt as CircuitBreakerStateChange, E as InboxChallengePolicy, Et as CircuitBreakerState, F as CreateExponentialBackoffPolicyOptions, G as ActorDispatcher, H as respondWithObject, I as RetryContext, J as AuthorizePredicate, K as ActorHandleMapper, L as RetryPolicy, M as FederationOrigin, N as FederationQueueOptions, O as ObjectCallbackSetters, Ot as NormalizedCircuitBreakerOptions, P as createFederation, Q as CustomCollectionCounter, R as createExponentialBackoffPolicy, S as FederationOptions, St as CircuitBreakerCreateOptions, T as IdempotencyStrategy, Tt as CircuitBreakerOptions, U as respondWithObjectIfAcceptable, V as RespondWithObjectOptions, W as ActorAliasMapper, X as CollectionCursor, Y as CollectionCounter, Z as CollectionDispatcher, _ as Federatable, _t as buildCollectionSynchronizationHeader, a as GetSignedKeyOptions, at as ObjectDispatcher, b as FederationBuilder, bt as CircuitBreakerActivityDrop, c as ParseUriResult, ct as OutboxListenerErrorHandler, d as SendActivityOptions, dt as UnverifiedActivityHandler, et as CustomCollectionDispatcher, f as SendActivityOptionsForCollection, ft as UnverifiedActivityReason, g as CustomCollectionCallbackSetters, gt as PageItems, h as ConstructorWithTypeId, ht as SenderKeyPair, i as GetActorOptions, it as ObjectAuthorizePredicate, j as FederationKvPrefixes, jt as ActivityTransformer, k as OutboxListenerSetters, kt as normalizeCircuitBreakerOptions, l as RequestContext, lt as OutboxPermanentFailureHandler, m as CollectionCallbackSetters, mt as SendActivityError, n as Context, nt as InboxListener, o as InboxContext, ot as OutboxErrorHandler, p as ActorCallbackSetters, pt as WebFingerLinksDispatcher, q as ActorKeyPairsDispatcher, r as ForwardActivityOptions, rt as NodeInfoDispatcher, s as OutboxContext, st as OutboxListener, t as ActorKeyPair, tt as InboxErrorHandler, u as RouteActivityOptions, ut as SharedInboxKeyDispatcher, v as Federation, vt as digest, w as IdempotencyKeyCallback, wt as CircuitBreakerKvState, x as FederationFetchOptions, xt as CircuitBreakerBeforeSendDecision, y as FederationBenchmarkOptions, yt as CircuitBreaker, z as Message } from "./context-COxc_O-c.js";
|
|
6
6
|
import { a as MemoryKvStore, i as KvStoreSetOptions, n as KvStore, r as KvStoreListEntry, t as KvKey } from "./kv-D6hNiMTK.js";
|
|
7
7
|
import { a as MessageQueueEnqueueOptions, i as MessageQueueDepth, n as InProcessMessageQueueOptions, o as MessageQueueListenOptions, r as MessageQueue, s as ParallelMessageQueue, t as InProcessMessageQueue } from "./mq-D-nlpY04.js";
|
|
8
8
|
import { actorDehydrator, autoIdAssigner, getDefaultActivityTransformers } from "./compat/mod.js";
|
|
9
|
-
import { a as RouterOptions, i as RouterError, n as handleWebFinger, o as RouterRouteResult, r as Router, t as WebFingerHandlerParameters } from "./mod-
|
|
9
|
+
import { a as RouterOptions, i as RouterError, n as handleWebFinger, o as RouterRouteResult, r as Router, t as WebFingerHandlerParameters } from "./mod-3H9Gym5G.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-COIAjwRS.js";
|
|
11
11
|
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./mod-DFvNJcNb.js";
|
|
12
12
|
export * from "@fedify/vocab-runtime";
|
package/dist/mod.js
CHANGED
|
@@ -3,11 +3,11 @@ import { URLPattern } from "urlpattern-polyfill";
|
|
|
3
3
|
import "./chunk-CRNNMoPX.js";
|
|
4
4
|
import { n as autoIdAssigner, r as getDefaultActivityTransformers, t as actorDehydrator } from "./transformers-BGMIq1cs.js";
|
|
5
5
|
import "./compat/mod.js";
|
|
6
|
-
import { A as formatAcceptSignature, M as parseAcceptSignature, N as validateAcceptSignature, a as verifyRequestDetailed, c as fetchKeyDetailed, i as verifyRequest, j as fulfillAcceptSignature, l as generateCryptoKeyPair, o as exportJwk, r as signRequest, s as fetchKey, u as importJwk } from "./http-
|
|
7
|
-
import { a as SendActivityError, c as buildCollectionSynchronizationHeader, d as normalizeCircuitBreakerOptions, f as parseCircuitBreakerKvState, i as createExponentialBackoffPolicy, l as digest, o as respondWithObject, p as createFederationBuilder, r as handleWebFinger, s as respondWithObjectIfAcceptable, t as createFederation, u as CircuitBreaker } from "./middleware-
|
|
8
|
-
import { C as verifySignature, S as verifyJsonLd, _ as hasSignatureLike, a as verifyProof, b as signJsonLd, c as getKeyOwner, d as attachSignature, i as verifyObject, m as detachSignature, n as hasProofLike, p as createSignature, r as signObject, s as doesActorOwnKey, t as createProof } from "./proof-
|
|
6
|
+
import { A as formatAcceptSignature, M as parseAcceptSignature, N as validateAcceptSignature, a as verifyRequestDetailed, c as fetchKeyDetailed, i as verifyRequest, j as fulfillAcceptSignature, l as generateCryptoKeyPair, o as exportJwk, r as signRequest, s as fetchKey, u as importJwk } from "./http-Bw8wN_Uk.js";
|
|
7
|
+
import { a as SendActivityError, c as buildCollectionSynchronizationHeader, d as normalizeCircuitBreakerOptions, f as parseCircuitBreakerKvState, i as createExponentialBackoffPolicy, l as digest, o as respondWithObject, p as createFederationBuilder, r as handleWebFinger, s as respondWithObjectIfAcceptable, t as createFederation, u as CircuitBreaker } from "./middleware-BEhF8uxY.js";
|
|
8
|
+
import { C as verifySignature, S as verifyJsonLd, _ as hasSignatureLike, a as verifyProof, b as signJsonLd, c as getKeyOwner, d as attachSignature, i as verifyObject, m as detachSignature, n as hasProofLike, p as createSignature, r as signObject, s as doesActorOwnKey, t as createProof } from "./proof-DNlVt3rz.js";
|
|
9
9
|
import { n as getNodeInfo, r as parseNodeInfo, t as nodeInfoToJson } from "./types-CAY3OdLq.js";
|
|
10
|
-
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-
|
|
10
|
+
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-DilyIIfz.js";
|
|
11
11
|
import { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue, Router, RouterError } from "./federation/mod.js";
|
|
12
12
|
import "./nodeinfo/mod.js";
|
|
13
13
|
import "./runtime/mod.js";
|
|
@@ -5,7 +5,7 @@ import { r as createRequestContext } from "../context-DVoTs_wM.mjs";
|
|
|
5
5
|
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
6
6
|
import "../std__assert-BBjXFNOb.mjs";
|
|
7
7
|
import { t as MemoryKvStore } from "../kv-rV3vodCc.mjs";
|
|
8
|
-
import { _ as handleNodeInfo, o as createFederation, v as handleNodeInfoJrd } from "../middleware-
|
|
8
|
+
import { _ as handleNodeInfo, o as createFederation, v as handleNodeInfoJrd } from "../middleware-Cf0dFqr9.mjs";
|
|
9
9
|
import { test } from "@fedify/fixture";
|
|
10
10
|
//#region src/nodeinfo/handler.test.ts
|
|
11
11
|
test("handleNodeInfo()", async () => {
|
|
@@ -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-Bg8I1L40.mjs";
|
|
5
|
+
import "./key-DOnwUeY9.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-y8Cigpuq.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,9 +1,9 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
-
import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-
|
|
6
|
-
import { n as fetchKey, o as validateCryptoKey } from "./key-
|
|
4
|
+
import { n as version, t as name } from "./deno-Bg8I1L40.mjs";
|
|
5
|
+
import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-CmX7KEfY.mjs";
|
|
6
|
+
import { n as fetchKey, o as validateCryptoKey } from "./key-DOnwUeY9.mjs";
|
|
7
7
|
import { n as preloadedOnlyDocumentLoader } from "./public-audience-Cvbr2Gzt.mjs";
|
|
8
8
|
import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-L_DbOaFe.mjs";
|
|
9
9
|
import { getLogger } from "@logtape/logtape";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { F as version, P as name, _ as measureSignatureKeyFetch, d as validateCryptoKey, f as getDurationMs, p as getFederationMetrics, s as fetchKey } from "./http-
|
|
3
|
+
import { F as version, P as name, _ as measureSignatureKeyFetch, d as validateCryptoKey, f as getDurationMs, p as getFederationMetrics, s as fetchKey } from "./http-Bw8wN_Uk.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";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
-
import { n as getDurationMs, r as getFederationMetrics } from "./metrics-
|
|
6
|
-
import { n as doubleKnock } from "./http-
|
|
4
|
+
import { n as version, t as name } from "./deno-Bg8I1L40.mjs";
|
|
5
|
+
import { n as getDurationMs, r as getFederationMetrics } from "./metrics-CmX7KEfY.mjs";
|
|
6
|
+
import { n as doubleKnock } from "./http-BaUm6xbz.mjs";
|
|
7
7
|
import { getLogger } from "@logtape/logtape";
|
|
8
8
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
9
9
|
import { FetchError } from "@fedify/vocab-runtime";
|
package/dist/sig/http.test.mjs
CHANGED
|
@@ -7,8 +7,8 @@ import { r as assertExists, t as assertStringIncludes } from "../std__assert-BBj
|
|
|
7
7
|
import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-DN60FHPX.mjs";
|
|
8
8
|
import { t as assertThrows } from "../assert_throws-BOkhLGYc.mjs";
|
|
9
9
|
import { t as assert } from "../assert-OguE97r2.mjs";
|
|
10
|
-
import { t as exportJwk } from "../key-
|
|
11
|
-
import { a as parseRfc9421Signature, c as timingSafeEqual, i as formatRfc9421SignatureParameters, l as verifyRequest, n as doubleKnock, o as parseRfc9421SignatureInput, r as formatRfc9421Signature, s as signRequest, t as createRfc9421SignatureBase, u as verifyRequestDetailed } from "../http-
|
|
10
|
+
import { t as exportJwk } from "../key-DOnwUeY9.mjs";
|
|
11
|
+
import { a as parseRfc9421Signature, c as timingSafeEqual, i as formatRfc9421SignatureParameters, l as verifyRequest, n as doubleKnock, o as parseRfc9421SignatureInput, r as formatRfc9421Signature, s as signRequest, t as createRfc9421SignatureBase, u as verifyRequestDetailed } from "../http-BaUm6xbz.mjs";
|
|
12
12
|
import { i as rsaPrivateKey2, l as rsaPublicKey5, o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-DGu1NFwu.mjs";
|
|
13
13
|
import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
14
14
|
import { FetchError, exportSpki } from "@fedify/vocab-runtime";
|
package/dist/sig/key.test.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
|
5
5
|
import "../std__assert-BBjXFNOb.mjs";
|
|
6
6
|
import { t as assertRejects } from "../assert_rejects-DN60FHPX.mjs";
|
|
7
7
|
import { t as assertThrows } from "../assert_throws-BOkhLGYc.mjs";
|
|
8
|
-
import { a as importJwk, i as generateCryptoKeyPair, n as fetchKey, o as validateCryptoKey, r as fetchKeyDetailed, t as exportJwk } from "../key-
|
|
8
|
+
import { a as importJwk, i as generateCryptoKeyPair, n as fetchKey, o as validateCryptoKey, r as fetchKeyDetailed, t as exportJwk } from "../key-DOnwUeY9.mjs";
|
|
9
9
|
import { c as rsaPublicKey3, i as rsaPrivateKey2, o as rsaPublicKey1, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DGu1NFwu.mjs";
|
|
10
10
|
import { CryptographicKey, Multikey } from "@fedify/vocab";
|
|
11
11
|
import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
@@ -400,5 +400,55 @@ test("fetchKey() works when meterProvider is omitted", async () => {
|
|
|
400
400
|
contextLoader: mockDocumentLoader
|
|
401
401
|
})).cached, false);
|
|
402
402
|
});
|
|
403
|
+
test("fetchKey() returns null for a malformed actor publicKey", async () => {
|
|
404
|
+
const actorId = "https://example.com/malformed-public-key";
|
|
405
|
+
const keyId = "https://example.com/malformed-public-key#main-key";
|
|
406
|
+
const cache = {};
|
|
407
|
+
const options = {
|
|
408
|
+
async documentLoader(resource) {
|
|
409
|
+
if (resource === actorId) return {
|
|
410
|
+
contextUrl: null,
|
|
411
|
+
documentUrl: resource,
|
|
412
|
+
document: {
|
|
413
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
|
414
|
+
id: actorId,
|
|
415
|
+
type: "Person",
|
|
416
|
+
publicKey: keyId
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
if (resource === keyId) return {
|
|
420
|
+
contextUrl: null,
|
|
421
|
+
documentUrl: resource,
|
|
422
|
+
document: {
|
|
423
|
+
"@context": "https://w3id.org/security/v1",
|
|
424
|
+
id: keyId,
|
|
425
|
+
type: "Key",
|
|
426
|
+
owner: actorId,
|
|
427
|
+
publicKeyPem: "not a public key"
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
return await mockDocumentLoader(resource);
|
|
431
|
+
},
|
|
432
|
+
contextLoader: mockDocumentLoader,
|
|
433
|
+
keyCache: {
|
|
434
|
+
get(keyId) {
|
|
435
|
+
return Promise.resolve(cache[keyId.href]);
|
|
436
|
+
},
|
|
437
|
+
set(keyId, key) {
|
|
438
|
+
cache[keyId.href] = key;
|
|
439
|
+
return Promise.resolve();
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
assertEquals(await fetchKey(actorId, CryptographicKey, options), {
|
|
444
|
+
key: null,
|
|
445
|
+
cached: false
|
|
446
|
+
});
|
|
447
|
+
assertEquals(cache, { [actorId]: null });
|
|
448
|
+
assertEquals(await fetchKey(actorId, CryptographicKey, options), {
|
|
449
|
+
key: null,
|
|
450
|
+
cached: true
|
|
451
|
+
});
|
|
452
|
+
});
|
|
403
453
|
//#endregion
|
|
404
454
|
export {};
|
package/dist/sig/ld.test.mjs
CHANGED
|
@@ -5,9 +5,9 @@ import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
|
5
5
|
import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-DN60FHPX.mjs";
|
|
6
6
|
import { t as assertThrows } from "../assert_throws-BOkhLGYc.mjs";
|
|
7
7
|
import { t as assert } from "../assert-OguE97r2.mjs";
|
|
8
|
-
import { i as generateCryptoKeyPair } from "../key-
|
|
8
|
+
import { i as generateCryptoKeyPair } from "../key-DOnwUeY9.mjs";
|
|
9
9
|
import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DGu1NFwu.mjs";
|
|
10
|
-
import { a as compactJsonLd, f as isInvalidUrlTypeError, g as verifySignature, h as verifyJsonLd, i as attachSignature, n as UnsafeJsonLdError, o as createSignature, p as signJsonLd, s as detachSignature, u as hasSignatureLike } from "../ld-
|
|
10
|
+
import { a as compactJsonLd, f as isInvalidUrlTypeError, g as verifySignature, h as verifyJsonLd, i as attachSignature, n as UnsafeJsonLdError, o as createSignature, p as signJsonLd, s as detachSignature, u as hasSignatureLike } from "../ld-CiONXo2U.mjs";
|
|
11
11
|
import { CryptographicKey } from "@fedify/vocab";
|
|
12
12
|
import { createTestMeterProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
13
13
|
import { encodeBase64 } from "byte-encodings/base64";
|
package/dist/sig/mod.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const require_http = require("../http-
|
|
5
|
-
const require_proof = require("../proof-
|
|
4
|
+
const require_http = require("../http-y8Cigpuq.cjs");
|
|
5
|
+
const require_proof = require("../proof-BKOUYRRh.cjs");
|
|
6
6
|
exports.attachSignature = require_proof.attachSignature;
|
|
7
7
|
exports.createProof = require_proof.createProof;
|
|
8
8
|
exports.createSignature = require_proof.createSignature;
|