@fedify/fedify 2.3.4 → 2.3.5

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.
Files changed (61) hide show
  1. package/dist/{builder-B6H0Cu-s.mjs → builder-DXekGevh.mjs} +2 -2
  2. package/dist/{circuit-breaker-DLS_n1x5.mjs → circuit-breaker-D1fxthDI.mjs} +25 -5
  3. package/dist/{circuit-breaker-test-utils-BVnv3T76.mjs → circuit-breaker-test-utils-CAdwjgMi.mjs} +1 -1
  4. package/dist/compat/mod.d.cts +1 -1
  5. package/dist/compat/mod.d.ts +1 -1
  6. package/dist/compat/transformers.test.mjs +1 -1
  7. package/dist/{context-Bjswu3eC.d.cts → context-BpmLyiPx.d.cts} +3 -2
  8. package/dist/{context-COxc_O-c.d.ts → context-BxVVO5Ro.d.ts} +3 -2
  9. package/dist/{deno-BWT0m-C0.mjs → deno-BaUlOnHe.mjs} +1 -1
  10. package/dist/{docloader-BCb3sV46.mjs → docloader-BYH2ymPh.mjs} +13 -9
  11. package/dist/federation/builder.test.mjs +1 -1
  12. package/dist/federation/circuit-breaker.test.mjs +184 -21
  13. package/dist/federation/handler.test.mjs +3 -3
  14. package/dist/federation/idempotency.test.mjs +2 -2
  15. package/dist/federation/metrics.test.mjs +1 -1
  16. package/dist/federation/middleware.test.mjs +10 -9
  17. package/dist/federation/mod.cjs +1 -1
  18. package/dist/federation/mod.d.cts +2 -2
  19. package/dist/federation/mod.d.ts +2 -2
  20. package/dist/federation/mod.js +1 -1
  21. package/dist/federation/send.test.mjs +3 -3
  22. package/dist/federation/temporal.test.mjs +1 -1
  23. package/dist/federation/webfinger.test.mjs +1 -1
  24. package/dist/{http-j8P8VWVy.js → http-CD5pDhPT.js} +8 -6
  25. package/dist/{http-Jf2NuGZH.mjs → http-Cm7Y71lD.mjs} +9 -7
  26. package/dist/{http-Ddlr1RXX.cjs → http-ifHta2Pj.cjs} +8 -6
  27. package/dist/{key-BLT79Df7.mjs → key-BSbJc-6T.mjs} +3 -3
  28. package/dist/{kv-cache-DMlgR8dT.cjs → kv-cache-CQHLWIXt.cjs} +12 -8
  29. package/dist/{kv-cache-DcrpYM0p.js → kv-cache-DMI3h8vn.js} +12 -8
  30. package/dist/{kv-cache-CfbraOmf.mjs → kv-cache-NmAX6AF2.mjs} +1 -1
  31. package/dist/{ld-C5AeN8Mb.mjs → ld-DMY2-bQC.mjs} +3 -3
  32. package/dist/{metrics-B25b8KGp.mjs → metrics-B9nzbvNe.mjs} +1 -1
  33. package/dist/{middleware-aQn45-2Y.mjs → middleware-BogX5PzT.mjs} +13 -13
  34. package/dist/{middleware-BB_zS4N_.mjs → middleware-C3LRXUcT.mjs} +1 -1
  35. package/dist/{middleware-D88YteNC.js → middleware-bK-NpoPV.js} +28 -8
  36. package/dist/{middleware-SXjy2D6F.cjs → middleware-rf7LIZPi.cjs} +28 -8
  37. package/dist/{mod-0bIqGrKQ.d.cts → mod-CjERT09F.d.cts} +1 -1
  38. package/dist/{mod-3H9Gym5G.d.ts → mod-Rpy4Uwkk.d.ts} +1 -1
  39. package/dist/mod.cjs +4 -4
  40. package/dist/mod.d.cts +2 -2
  41. package/dist/mod.d.ts +2 -2
  42. package/dist/mod.js +4 -4
  43. package/dist/nodeinfo/handler.test.mjs +1 -1
  44. package/dist/{owner-BjvP6UU-.mjs → owner-Ci8O4Q03.mjs} +2 -2
  45. package/dist/{proof-D0gyqmlm.mjs → proof-BSlz1EIk.mjs} +3 -3
  46. package/dist/{proof-DppHZMD1.cjs → proof-Ba3iHVt9.cjs} +1 -1
  47. package/dist/{proof-BVH3Q49N.js → proof-CIOa9FCc.js} +1 -1
  48. package/dist/{send-Ww8VDONO.mjs → send--ocjLzu4.mjs} +3 -3
  49. package/dist/sig/http.test.mjs +65 -3
  50. package/dist/sig/key.test.mjs +46 -1
  51. package/dist/sig/ld.test.mjs +2 -2
  52. package/dist/sig/mod.cjs +2 -2
  53. package/dist/sig/mod.js +2 -2
  54. package/dist/sig/owner.test.mjs +1 -1
  55. package/dist/sig/proof.test.mjs +1 -1
  56. package/dist/{temporal-BJVH1-UV.mjs → temporal-C9rNBS3M.mjs} +1 -1
  57. package/dist/utils/docloader.test.mjs +35 -2
  58. package/dist/utils/kv-cache.test.mjs +1 -1
  59. package/dist/utils/mod.cjs +1 -1
  60. package/dist/utils/mod.js +1 -1
  61. 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-Ddlr1RXX.cjs");
6
- const require_proof = require("./proof-DppHZMD1.cjs");
5
+ const require_http = require("./http-ifHta2Pj.cjs");
6
+ const require_proof = require("./proof-Ba3iHVt9.cjs");
7
7
  const require_types = require("./types-m8u9L86X.cjs");
8
- const require_kv_cache = require("./kv-cache-DMlgR8dT.cjs");
8
+ const require_kv_cache = require("./kv-cache-CQHLWIXt.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");
@@ -683,10 +683,11 @@ function createFederationBuilder() {
683
683
  //#endregion
684
684
  //#region src/federation/circuit-breaker.ts
685
685
  const MAX_CUSTOM_FAILURE_HISTORY = 100;
686
- const LEGACY_SWEEP_MARKER = ["__fedify_meta", "circuit_breaker_state_ttl_sweep_v1"];
686
+ const LEGACY_SWEEP_MARKER = ["__fedify_meta", "circuit_breaker_state_ttl_sweep_v2"];
687
687
  const LEGACY_SWEEP_DELETING_MARKER = { __fedifyDeletingCircuitBreakerLegacyState: true };
688
688
  const CIRCUIT_BREAKER_STATE_VERSION = 1;
689
689
  const LEGACY_SWEEP_LOCK_TTL = Temporal.Duration.from({ minutes: 5 });
690
+ const LEGACY_SWEEP_RENEW_INTERVAL = Temporal.Duration.from({ minutes: 1 });
690
691
  const LEGACY_SWEEP_RETRY_WINDOW = Temporal.Duration.from({ hours: 168 });
691
692
  const LEGACY_SWEEP_WAIT_INTERVAL = 10;
692
693
  const LEGACY_SWEEP_CAS_ATTEMPTS = 3;
@@ -901,12 +902,20 @@ var CircuitBreaker = class {
901
902
  }
902
903
  async #sweepLegacyStatesImpl() {
903
904
  const markerKey = this.#legacySweepMarkerKey();
904
- const marker = await this.#acquireLegacySweep(markerKey);
905
- if (marker === "done") return;
905
+ const acquired = await this.#acquireLegacySweep(markerKey);
906
+ if (acquired === "done") return;
907
+ let marker = acquired;
908
+ let leaseRenewedAt = this.#now();
906
909
  try {
907
910
  for await (const { key, value } of this.#kv.list(this.#prefix)) {
908
911
  if (key.length !== this.#prefix.length + 1) continue;
909
912
  await this.#migrateLegacyState(key, value);
913
+ if (Temporal.Instant.compare(this.#now(), leaseRenewedAt.add(LEGACY_SWEEP_RENEW_INTERVAL)) >= 0) {
914
+ const renewed = await this.#renewLegacySweep(markerKey, marker);
915
+ if (renewed == null) return;
916
+ marker = renewed;
917
+ leaseRenewedAt = this.#now();
918
+ }
910
919
  }
911
920
  } catch (error) {
912
921
  await this.#deleteIfUnchanged(markerKey, marker);
@@ -915,6 +924,14 @@ var CircuitBreaker = class {
915
924
  const finishedMarker = this.#finishLegacySweepMarker(marker);
916
925
  if (await this.#kv.cas(markerKey, marker, finishedMarker)) this.#rememberLegacySweepMarker(finishedMarker);
917
926
  }
927
+ async #renewLegacySweep(markerKey, marker) {
928
+ const renewed = {
929
+ state: "sweeping",
930
+ started: this.#now().toString(),
931
+ retryUntil: getLegacySweepRetryUntil(marker) ?? this.#now().add(LEGACY_SWEEP_RETRY_WINDOW).toString()
932
+ };
933
+ if (await this.#kv.cas(markerKey, marker, renewed, { ttl: LEGACY_SWEEP_LOCK_TTL })) return renewed;
934
+ }
918
935
  #finishLegacySweepMarker(marker) {
919
936
  const retryUntil = getLegacySweepRetryUntil(marker);
920
937
  if (retryUntil != null && Temporal.Instant.compare(this.#now(), Temporal.Instant.from(retryUntil)) < 0) return {
@@ -924,7 +941,10 @@ var CircuitBreaker = class {
924
941
  return { state: "final" };
925
942
  }
926
943
  async #migrateLegacyState(key, value) {
927
- if (isCurrentCircuitBreakerState(value)) return;
944
+ if (isCurrentCircuitBreakerState(value)) {
945
+ await this.#kv.cas(key, value, value, this.#setOptions());
946
+ return;
947
+ }
928
948
  const state = parseCircuitBreakerKvState(value);
929
949
  if (state != null) {
930
950
  await this.#kv.cas(key, value, markCircuitBreakerState(state), this.#setOptions());
@@ -1061,7 +1081,7 @@ function normalizeCircuitBreakerOptions(options) {
1061
1081
  } else {
1062
1082
  failure = options.failure;
1063
1083
  pruneFailures = (timestamps) => timestamps.slice(-MAX_CUSTOM_FAILURE_HISTORY);
1064
- stateTtl = configuredStateTtl;
1084
+ stateTtl = configuredStateTtl ?? recoveryDelay.add(heldActivityTtl);
1065
1085
  }
1066
1086
  return {
1067
1087
  failure,
@@ -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-Bjswu3eC.cjs";
2
+ import { G as ActorDispatcher, K as ActorHandleMapper, W as ActorAliasMapper, l as RequestContext, pt as WebFingerLinksDispatcher } from "./context-BpmLyiPx.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-COxc_O-c.js";
2
+ import { G as ActorDispatcher, K as ActorHandleMapper, W as ActorAliasMapper, l as RequestContext, pt as WebFingerLinksDispatcher } from "./context-BxVVO5Ro.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-Ddlr1RXX.cjs");
8
- const require_middleware = require("./middleware-SXjy2D6F.cjs");
9
- const require_proof = require("./proof-DppHZMD1.cjs");
7
+ const require_http = require("./http-ifHta2Pj.cjs");
8
+ const require_middleware = require("./middleware-rf7LIZPi.cjs");
9
+ const require_proof = require("./proof-Ba3iHVt9.cjs");
10
10
  const require_types = require("./types-m8u9L86X.cjs");
11
- const require_kv_cache = require("./kv-cache-DMlgR8dT.cjs");
11
+ const require_kv_cache = require("./kv-cache-CQHLWIXt.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-Bjswu3eC.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-BpmLyiPx.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-0bIqGrKQ.cjs";
9
+ import { a as RouterOptions, i as RouterError, n as handleWebFinger, o as RouterRouteResult, r as Router, t as WebFingerHandlerParameters } from "./mod-CjERT09F.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-COxc_O-c.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-BxVVO5Ro.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-3H9Gym5G.js";
9
+ import { a as RouterOptions, i as RouterError, n as handleWebFinger, o as RouterRouteResult, r as Router, t as WebFingerHandlerParameters } from "./mod-Rpy4Uwkk.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-j8P8VWVy.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-D88YteNC.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-BVH3Q49N.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-CD5pDhPT.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-bK-NpoPV.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-CIOa9FCc.js";
9
9
  import { n as getNodeInfo, r as parseNodeInfo, t as nodeInfoToJson } from "./types-DTONwNqL.js";
10
- import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-DcrpYM0p.js";
10
+ import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-DMI3h8vn.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-aQn45-2Y.mjs";
8
+ import { _ as handleNodeInfo, o as createFederation, v as handleNodeInfoJrd } from "../middleware-BogX5PzT.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-BWT0m-C0.mjs";
5
- import "./key-BLT79Df7.mjs";
4
+ import { n as version, t as name } from "./deno-BaUlOnHe.mjs";
5
+ import "./key-BSbJc-6T.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,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-BWT0m-C0.mjs";
5
- import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-B25b8KGp.mjs";
6
- import { n as fetchKey, o as validateCryptoKey } from "./key-BLT79Df7.mjs";
4
+ import { n as version, t as name } from "./deno-BaUlOnHe.mjs";
5
+ import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-B9nzbvNe.mjs";
6
+ import { n as fetchKey, o as validateCryptoKey } from "./key-BSbJc-6T.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,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-Ddlr1RXX.cjs");
4
+ const require_http = require("./http-ifHta2Pj.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,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-j8P8VWVy.js";
3
+ import { F as version, P as name, _ as measureSignatureKeyFetch, d as validateCryptoKey, f as getDurationMs, p as getFederationMetrics, s as fetchKey } from "./http-CD5pDhPT.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-BWT0m-C0.mjs";
5
- import { n as getDurationMs, r as getFederationMetrics } from "./metrics-B25b8KGp.mjs";
6
- import { n as doubleKnock } from "./http-Jf2NuGZH.mjs";
4
+ import { n as version, t as name } from "./deno-BaUlOnHe.mjs";
5
+ import { n as getDurationMs, r as getFederationMetrics } from "./metrics-B9nzbvNe.mjs";
6
+ import { n as doubleKnock } from "./http-Cm7Y71lD.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";
@@ -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-BLT79Df7.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-Jf2NuGZH.mjs";
10
+ import { t as exportJwk } from "../key-BSbJc-6T.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-Cm7Y71lD.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";
@@ -1001,6 +1001,7 @@ test("doubleKnock() function with redirect handling", async () => {
1001
1001
  esm_default.spyGlobal();
1002
1002
  const requestedUrls = [];
1003
1003
  const responseCodes = [];
1004
+ const validatedRedirects = [];
1004
1005
  esm_default.post("https://example.com/redirect-endpoint", (cl) => {
1005
1006
  requestedUrls.push(cl.url);
1006
1007
  responseCodes.push(302);
@@ -1018,11 +1019,41 @@ test("doubleKnock() function with redirect handling", async () => {
1018
1019
  }), {
1019
1020
  keyId: rsaPublicKey2.id,
1020
1021
  privateKey: rsaPrivateKey2
1021
- })).status, 202, "Final response status should be 202 Accepted");
1022
+ }, { validateRedirect(url) {
1023
+ validatedRedirects.push(url);
1024
+ } })).status, 202, "Final response status should be 202 Accepted");
1022
1025
  assertEquals(requestedUrls.length, 2, "Two URLs should have been requested");
1023
1026
  assertEquals(requestedUrls[0], "https://example.com/redirect-endpoint", "First request should be to redirect-endpoint");
1024
1027
  assertEquals(requestedUrls[1], "https://example.com/final-endpoint", "Second request should be to final-endpoint");
1025
1028
  assertEquals(responseCodes, [302, 202], "Response status codes should match expected sequence");
1029
+ assertEquals(validatedRedirects, ["https://example.com/final-endpoint"]);
1030
+ esm_default.hardReset();
1031
+ });
1032
+ test("doubleKnock() validates redirects after signature fallback", async () => {
1033
+ esm_default.spyGlobal();
1034
+ let requestCount = 0;
1035
+ let privateRequestCount = 0;
1036
+ esm_default.post("https://example.com/redirect-after-fallback", (cl) => {
1037
+ requestCount++;
1038
+ if (cl.request.headers.has("Signature-Input")) return new Response("Unauthorized", { status: 401 });
1039
+ return Response.redirect("http://localhost/private", 302);
1040
+ });
1041
+ esm_default.post("http://localhost/private", () => {
1042
+ privateRequestCount++;
1043
+ return new Response("", { status: 202 });
1044
+ });
1045
+ const request = new Request("https://example.com/redirect-after-fallback", {
1046
+ method: "POST",
1047
+ body: "Test message"
1048
+ });
1049
+ await assertRejects(() => doubleKnock(request, {
1050
+ keyId: rsaPublicKey2.id,
1051
+ privateKey: rsaPrivateKey2
1052
+ }, { validateRedirect(url) {
1053
+ throw new Error(`Disallowed redirect: ${url}`);
1054
+ } }), Error, "Disallowed redirect: http://localhost/private");
1055
+ assertEquals(requestCount, 2);
1056
+ assertEquals(privateRequestCount, 0);
1026
1057
  esm_default.hardReset();
1027
1058
  });
1028
1059
  test("doubleKnock() function with both specs rejected", async () => {
@@ -1813,6 +1844,37 @@ test("doubleKnock(): Accept-Signature challenge retry succeeds", async () => {
1813
1844
  assertEquals(requestCount, 2);
1814
1845
  esm_default.hardReset();
1815
1846
  });
1847
+ test("doubleKnock(): validates redirects after Accept-Signature challenge retry", async () => {
1848
+ esm_default.spyGlobal();
1849
+ let requestCount = 0;
1850
+ let privateRequestCount = 0;
1851
+ esm_default.post("https://example.com/inbox-challenge-redirect", () => {
1852
+ requestCount++;
1853
+ if (requestCount === 1) return new Response("Not Authorized", {
1854
+ status: 401,
1855
+ headers: { "Accept-Signature": "sig1=(\"@method\" \"@target-uri\" \"@authority\" \"content-digest\");created;nonce=\"challenge-nonce-redirect\"" }
1856
+ });
1857
+ return Response.redirect("http://localhost/private", 302);
1858
+ });
1859
+ esm_default.post("http://localhost/private", () => {
1860
+ privateRequestCount++;
1861
+ return new Response("", { status: 202 });
1862
+ });
1863
+ const request = new Request("https://example.com/inbox-challenge-redirect", {
1864
+ method: "POST",
1865
+ body: "Test message",
1866
+ headers: { "Content-Type": "text/plain" }
1867
+ });
1868
+ await assertRejects(() => doubleKnock(request, {
1869
+ keyId: rsaPublicKey2.id,
1870
+ privateKey: rsaPrivateKey2
1871
+ }, { validateRedirect(url) {
1872
+ throw new Error(`Disallowed redirect: ${url}`);
1873
+ } }), Error, "Disallowed redirect: http://localhost/private");
1874
+ assertEquals(requestCount, 2);
1875
+ assertEquals(privateRequestCount, 0);
1876
+ esm_default.hardReset();
1877
+ });
1816
1878
  test("doubleKnock(): unfulfillable Accept-Signature falls to legacy fallback", async () => {
1817
1879
  esm_default.spyGlobal();
1818
1880
  let requestCount = 0;
@@ -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-BLT79Df7.mjs";
8
+ import { a as importJwk, i as generateCryptoKeyPair, n as fetchKey, o as validateCryptoKey, r as fetchKeyDetailed, t as exportJwk } from "../key-BSbJc-6T.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,6 +400,51 @@ test("fetchKey() works when meterProvider is omitted", async () => {
400
400
  contextLoader: mockDocumentLoader
401
401
  })).cached, false);
402
402
  });
403
+ test("fetchKey() rejects standalone keys with a mismatched id", async () => {
404
+ for (const { keyId, standaloneKey, fetch } of [{
405
+ keyId: "https://example.com/key",
406
+ standaloneKey: rsaPublicKey1,
407
+ fetch: (keyId, options) => fetchKey(keyId, CryptographicKey, options)
408
+ }, {
409
+ keyId: "https://example.com/multikey",
410
+ standaloneKey: ed25519Multikey,
411
+ fetch: (keyId, options) => fetchKey(keyId, Multikey, options)
412
+ }]) {
413
+ const cache = {};
414
+ const options = {
415
+ async documentLoader(resource) {
416
+ if (resource === keyId) return {
417
+ contextUrl: null,
418
+ documentUrl: resource,
419
+ document: {
420
+ ...await standaloneKey.toJsonLd({ contextLoader: mockDocumentLoader }),
421
+ id: "https://example.com/different-key"
422
+ }
423
+ };
424
+ return await mockDocumentLoader(resource);
425
+ },
426
+ contextLoader: mockDocumentLoader,
427
+ keyCache: {
428
+ get(keyId) {
429
+ return Promise.resolve(cache[keyId.href]);
430
+ },
431
+ set(keyId, key) {
432
+ cache[keyId.href] = key;
433
+ return Promise.resolve();
434
+ }
435
+ }
436
+ };
437
+ assertEquals(await fetch(keyId, options), {
438
+ key: null,
439
+ cached: false
440
+ });
441
+ assertEquals(cache, { [keyId]: null });
442
+ assertEquals(await fetch(keyId, options), {
443
+ key: null,
444
+ cached: true
445
+ });
446
+ }
447
+ });
403
448
  test("fetchKey() returns null for a malformed actor publicKey", async () => {
404
449
  const actorId = "https://example.com/malformed-public-key";
405
450
  const keyId = "https://example.com/malformed-public-key#main-key";
@@ -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-BLT79Df7.mjs";
8
+ import { i as generateCryptoKeyPair } from "../key-BSbJc-6T.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-C5AeN8Mb.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-DMY2-bQC.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-Ddlr1RXX.cjs");
5
- const require_proof = require("../proof-DppHZMD1.cjs");
4
+ const require_http = require("../http-ifHta2Pj.cjs");
5
+ const require_proof = require("../proof-Ba3iHVt9.cjs");
6
6
  exports.attachSignature = require_proof.attachSignature;
7
7
  exports.createProof = require_proof.createProof;
8
8
  exports.createSignature = require_proof.createSignature;
package/dist/sig/mod.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- 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-j8P8VWVy.js";
4
- 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-BVH3Q49N.js";
3
+ 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-CD5pDhPT.js";
4
+ 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-CIOa9FCc.js";
5
5
  export { attachSignature, createProof, createSignature, detachSignature, doesActorOwnKey, exportJwk, fetchKey, fetchKeyDetailed, formatAcceptSignature, fulfillAcceptSignature, generateCryptoKeyPair, getKeyOwner, hasProofLike, hasSignatureLike, importJwk, parseAcceptSignature, signJsonLd, signObject, signRequest, validateAcceptSignature, verifyJsonLd, verifyObject, verifyProof, verifyRequest, verifyRequestDetailed, verifySignature };
@@ -6,7 +6,7 @@ import "../std__assert-BBjXFNOb.mjs";
6
6
  import { r as assertFalse } from "../assert_rejects-DN60FHPX.mjs";
7
7
  import { t as assert } from "../assert-OguE97r2.mjs";
8
8
  import { o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-DGu1NFwu.mjs";
9
- import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-BjvP6UU-.mjs";
9
+ import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-Ci8O4Q03.mjs";
10
10
  import { Create, CryptographicKey, lookupObject } from "@fedify/vocab";
11
11
  import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
12
12
  //#region src/sig/owner.test.ts
@@ -8,7 +8,7 @@ import { t as assertInstanceOf } from "../assert_instance_of-DBC5X09g.mjs";
8
8
  import { t as assert } from "../assert-OguE97r2.mjs";
9
9
  import { i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DGu1NFwu.mjs";
10
10
  import { r as normalizeOutgoingActivityJsonLd } from "../outgoing-jsonld-L_DbOaFe.mjs";
11
- import { a as verifyProof, i as verifyObject, n as hasProofLike, r as signObject, t as createProof } from "../proof-D0gyqmlm.mjs";
11
+ import { a as verifyProof, i as verifyObject, n as hasProofLike, r as signObject, t as createProof } from "../proof-BSlz1EIk.mjs";
12
12
  import { Create, DataIntegrityProof, Document, Multikey, Note, PUBLIC_COLLECTION, Place } from "@fedify/vocab";
13
13
  import { createTestMeterProvider, mockDocumentLoader, test } from "@fedify/fixture";
14
14
  import { decodeMultibase, importMultibaseKey } from "@fedify/vocab-runtime";
@@ -1,7 +1,7 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { c as getNormalizationContextLoader } from "./ld-C5AeN8Mb.mjs";
4
+ import { c as getNormalizationContextLoader } from "./ld-DMY2-bQC.mjs";
5
5
  import jsonld from "@fedify/vocab-runtime/jsonld";
6
6
  //#region src/federation/temporal.ts
7
7
  function isPlainObject(value) {
@@ -5,9 +5,9 @@ import { t as esm_default } from "../esm-vrlUxr60.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 assertRejects } from "../assert_rejects-DN60FHPX.mjs";
8
- import { l as verifyRequest } from "../http-Jf2NuGZH.mjs";
8
+ import { l as verifyRequest } from "../http-Cm7Y71lD.mjs";
9
9
  import { i as rsaPrivateKey2 } from "../keys-DGu1NFwu.mjs";
10
- import { t as getAuthenticatedDocumentLoader } from "../docloader-BCb3sV46.mjs";
10
+ import { t as getAuthenticatedDocumentLoader } from "../docloader-BYH2ymPh.mjs";
11
11
  import { mockDocumentLoader, test } from "@fedify/fixture";
12
12
  import { UrlError } from "@fedify/vocab-runtime";
13
13
  //#region src/utils/docloader.test.ts
@@ -63,6 +63,39 @@ test("getAuthenticatedDocumentLoader()", async (t) => {
63
63
  esm_default.hardReset();
64
64
  });
65
65
  });
66
+ test("getAuthenticatedDocumentLoader() validates redirects", async (t) => {
67
+ esm_default.spyGlobal();
68
+ let privateRequestCount = 0;
69
+ esm_default.get("https://example.com/redirect-to-private", () => Response.redirect("http://localhost/private", 302));
70
+ esm_default.get("http://localhost/private", () => {
71
+ privateRequestCount++;
72
+ return Response.json({ private: true });
73
+ });
74
+ await t.step("deny public-to-private redirects", async () => {
75
+ const loader = getAuthenticatedDocumentLoader({
76
+ keyId: new URL("https://example.com/key2"),
77
+ privateKey: rsaPrivateKey2
78
+ });
79
+ await assertRejects(() => loader("https://example.com/redirect-to-private"), UrlError);
80
+ assertEquals(privateRequestCount, 0);
81
+ });
82
+ esm_default.get("https://example.com/redirect-to-public", () => Response.redirect("https://www.example.com/document", 302));
83
+ esm_default.get("https://www.example.com/document", () => Response.json({ public: true }));
84
+ await t.step("allow public-to-public redirects", async () => {
85
+ assertEquals((await getAuthenticatedDocumentLoader({
86
+ keyId: new URL("https://example.com/key2"),
87
+ privateKey: rsaPrivateKey2
88
+ })("https://example.com/redirect-to-public")).document, { public: true });
89
+ });
90
+ await t.step("allow private redirects when explicitly enabled", async () => {
91
+ assertEquals((await getAuthenticatedDocumentLoader({
92
+ keyId: new URL("https://example.com/key2"),
93
+ privateKey: rsaPrivateKey2
94
+ }, { allowPrivateAddress: true })("https://example.com/redirect-to-private")).document, { private: true });
95
+ assertEquals(privateRequestCount, 1);
96
+ });
97
+ esm_default.hardReset();
98
+ });
66
99
  test("getAuthenticatedDocumentLoader() cancellation", {
67
100
  sanitizeResources: false,
68
101
  sanitizeOps: false
@@ -1,7 +1,7 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as kvCache, t as MockKvStore } from "../kv-cache-CfbraOmf.mjs";
4
+ import { n as kvCache, t as MockKvStore } from "../kv-cache-NmAX6AF2.mjs";
5
5
  import { deepStrictEqual, throws } from "node:assert";
6
6
  import { createTestMeterProvider, mockDocumentLoader, test } from "@fedify/fixture";
7
7
  import { preloadedContexts } from "@fedify/vocab-runtime";
@@ -1,6 +1,6 @@
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_kv_cache = require("../kv-cache-DMlgR8dT.cjs");
4
+ const require_kv_cache = require("../kv-cache-CQHLWIXt.cjs");
5
5
  exports.getAuthenticatedDocumentLoader = require_kv_cache.getAuthenticatedDocumentLoader;
6
6
  exports.kvCache = require_kv_cache.kvCache;
package/dist/utils/mod.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../kv-cache-DcrpYM0p.js";
3
+ import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../kv-cache-DMI3h8vn.js";
4
4
  export { getAuthenticatedDocumentLoader, kvCache };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/fedify",
3
- "version": "2.3.4",
3
+ "version": "2.3.5",
4
4
  "description": "An ActivityPub server framework",
5
5
  "keywords": [
6
6
  "ActivityPub",
@@ -152,10 +152,10 @@
152
152
  "jsonld": "^9.0.0",
153
153
  "structured-field-values": "^2.0.4",
154
154
  "urlpattern-polyfill": "^10.1.0",
155
- "@fedify/vocab": "2.3.4",
156
- "@fedify/vocab-runtime": "2.3.4",
157
- "@fedify/uri-template": "2.3.4",
158
- "@fedify/webfinger": "2.3.4"
155
+ "@fedify/vocab": "2.3.5",
156
+ "@fedify/vocab-runtime": "2.3.5",
157
+ "@fedify/webfinger": "2.3.5",
158
+ "@fedify/uri-template": "2.3.5"
159
159
  },
160
160
  "devDependencies": {
161
161
  "@std/assert": "npm:@jsr/std__assert@^0.226.0",
@@ -168,7 +168,7 @@
168
168
  "typescript": "^6.0.0",
169
169
  "wrangler": "^4.17.0",
170
170
  "@fedify/fixture": "2.0.0",
171
- "@fedify/vocab-tools": "^2.3.4"
171
+ "@fedify/vocab-tools": "^2.3.5"
172
172
  },
173
173
  "scripts": {
174
174
  "build:self": "tsdown",