@fedify/fedify 2.4.0-dev.1848 → 2.4.0-dev.1867

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 (64) hide show
  1. package/dist/{builder-8WyrrBSI.mjs → builder-jhGmiXB5.mjs} +2 -2
  2. package/dist/{circuit-breaker-BT7CiPbz.mjs → circuit-breaker-C5NqoLBJ.mjs} +25 -5
  3. package/dist/{circuit-breaker-test-utils-BYIHoliq.mjs → circuit-breaker-test-utils-DW6YC_Pe.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-B-dsBjZ9.d.cts → context-BOnn653X.d.cts} +3 -2
  8. package/dist/{context-DrLXudbA.d.ts → context-CmjP-cgJ.d.ts} +3 -2
  9. package/dist/{deno-CNYW2Ig8.mjs → deno-B5Jy0IH5.mjs} +1 -1
  10. package/dist/{docloader-Dzbz3Js2.mjs → docloader-RO5dmEG1.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/tasks/enqueue.test.mjs +1 -1
  23. package/dist/federation/tasks/tasks.test.mjs +2 -2
  24. package/dist/federation/temporal.test.mjs +1 -1
  25. package/dist/federation/webfinger.test.mjs +1 -1
  26. package/dist/{federation-CChOD4m8.cjs → federation-D4wc67AQ.cjs} +28 -8
  27. package/dist/{http-CqXnYPxh.js → http-ByQYBoMk.js} +8 -6
  28. package/dist/{http-DpXPu64P.mjs → http-CI_W79n9.mjs} +9 -7
  29. package/dist/{http-DcSh3Nkc.cjs → http-DaCIe27S.cjs} +8 -6
  30. package/dist/{key-hmby7gn5.mjs → key-Dx1gDplp.mjs} +3 -3
  31. package/dist/{kv-cache-AbW4Zb7B.js → kv-cache-C3ffIesH.js} +12 -8
  32. package/dist/{kv-cache-Nl-t79NZ.mjs → kv-cache-D6L7jCkB.mjs} +1 -1
  33. package/dist/{kv-cache-BJ67yD69.cjs → kv-cache-LBXR3jN5.cjs} +12 -8
  34. package/dist/{ld-B8i_nYpF.mjs → ld-jRq6FLRU.mjs} +3 -3
  35. package/dist/{metrics-Pf5DoomU.mjs → metrics-DB_aJ3d7.mjs} +1 -1
  36. package/dist/{middleware-DRGoAGNP.mjs → middleware-BZGAqnv7.mjs} +13 -13
  37. package/dist/{middleware-Hgkr-t3e.js → middleware-DXabWqen.js} +28 -8
  38. package/dist/{middleware-kc0OTJOB.mjs → middleware-FSACqVKD.mjs} +1 -1
  39. package/dist/{mod-D6O8C7eN.d.ts → mod-BYuZ0WXt.d.ts} +1 -1
  40. package/dist/{mod-D-abvu2C.d.cts → mod-kUSY5n3f.d.cts} +1 -1
  41. package/dist/mod.cjs +4 -4
  42. package/dist/mod.d.cts +2 -2
  43. package/dist/mod.d.ts +2 -2
  44. package/dist/mod.js +4 -4
  45. package/dist/nodeinfo/handler.test.mjs +1 -1
  46. package/dist/{owner-Bq-aDUI1.mjs → owner-B8wSl5D1.mjs} +2 -2
  47. package/dist/{proof-CKKqEWUg.js → proof-CCnQdjNX.js} +1 -1
  48. package/dist/{proof-BJ6kqGDQ.mjs → proof-Dwx8Yb1A.mjs} +4 -4
  49. package/dist/{proof-Y3u5gsyU.cjs → proof-FLTH3GQo.cjs} +1 -1
  50. package/dist/{send-DxAijVhs.mjs → send-DoVP-yHD.mjs} +3 -3
  51. package/dist/sig/http.test.mjs +65 -3
  52. package/dist/sig/key.test.mjs +46 -1
  53. package/dist/sig/ld.test.mjs +2 -2
  54. package/dist/sig/mod.cjs +2 -2
  55. package/dist/sig/mod.js +2 -2
  56. package/dist/sig/owner.test.mjs +1 -1
  57. package/dist/sig/proof.test.mjs +1 -1
  58. package/dist/{temporal-BB26MWBu.mjs → temporal-BRO-1oR_.mjs} +1 -1
  59. package/dist/testing/mod.d.mts +3 -2
  60. package/dist/utils/docloader.test.mjs +35 -2
  61. package/dist/utils/kv-cache.test.mjs +1 -1
  62. package/dist/utils/mod.cjs +1 -1
  63. package/dist/utils/mod.js +1 -1
  64. package/package.json +6 -6
@@ -2,10 +2,10 @@ import { Temporal } from "temporal-polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
3
  import { t as __exportAll } from "./rolldown-runtime-BC-Eo5Mj.js";
4
4
  import { r as getDefaultActivityTransformers } from "./transformers-DAtXl_Kc.js";
5
- import { A as formatAcceptSignature, D as recordOutboxEnqueue, E as recordOutboxActivity, F as version, O as recordWebFingerHandle, P as name, S as recordCollectionTotalItems, T as recordInboxActivity, a as verifyRequestDetailed, b as recordCollectionPageItems, d as validateCryptoKey, f as getDurationMs, g as isAbortError, h as instrumentDocumentLoader, i as verifyRequest, k as registerQueueDepthGauge, m as getRemoteHost, n as parseRfc9421SignatureInput, o as exportJwk, p as getFederationMetrics, t as doubleKnock, u as importJwk, v as recordCircuitBreakerStateChange, w as recordFanoutRecipients, x as recordCollectionRequest, y as recordCollectionDispatchDuration } from "./http-CqXnYPxh.js";
6
- import { S as verifyCompactJsonLd, T as wrapContextLoaderForJsonLd, _ as hasSignature, b as isInvalidUrlTypeError, c as doesActorOwnKey, d as assertSafeJsonLd, g as getNormalizationContextLoader, h as detachSignature, i as verifyObject, l as getKeyOwner, n as hasProofLike, p as compactJsonLd, r as signObject, s as normalizeOutgoingActivityJsonLd, u as InvalidContextReferenceError, v as hasSignatureLike, x as signJsonLd, y as isClearlyMalformedContextReference } from "./proof-CKKqEWUg.js";
5
+ import { A as formatAcceptSignature, D as recordOutboxEnqueue, E as recordOutboxActivity, F as version, O as recordWebFingerHandle, P as name, S as recordCollectionTotalItems, T as recordInboxActivity, a as verifyRequestDetailed, b as recordCollectionPageItems, d as validateCryptoKey, f as getDurationMs, g as isAbortError, h as instrumentDocumentLoader, i as verifyRequest, k as registerQueueDepthGauge, m as getRemoteHost, n as parseRfc9421SignatureInput, o as exportJwk, p as getFederationMetrics, t as doubleKnock, u as importJwk, v as recordCircuitBreakerStateChange, w as recordFanoutRecipients, x as recordCollectionRequest, y as recordCollectionDispatchDuration } from "./http-ByQYBoMk.js";
6
+ import { S as verifyCompactJsonLd, T as wrapContextLoaderForJsonLd, _ as hasSignature, b as isInvalidUrlTypeError, c as doesActorOwnKey, d as assertSafeJsonLd, g as getNormalizationContextLoader, h as detachSignature, i as verifyObject, l as getKeyOwner, n as hasProofLike, p as compactJsonLd, r as signObject, s as normalizeOutgoingActivityJsonLd, u as InvalidContextReferenceError, v as hasSignatureLike, x as signJsonLd, y as isClearlyMalformedContextReference } from "./proof-CCnQdjNX.js";
7
7
  import { n as getNodeInfo, t as nodeInfoToJson } from "./types-Dtyf8lVj.js";
8
- import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-AbW4Zb7B.js";
8
+ import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-C3ffIesH.js";
9
9
  import { getLogger, withContext } from "@logtape/logtape";
10
10
  import { Router, RouterError, assertPath } from "@fedify/uri-template";
11
11
  import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, Tombstone, getTypeId, lookupObject, traverseCollection } from "@fedify/vocab";
@@ -724,10 +724,11 @@ function createFederationBuilder() {
724
724
  }
725
725
  //#endregion
726
726
  //#region src/federation/circuit-breaker.ts
727
- const LEGACY_SWEEP_MARKER = ["__fedify_meta", "circuit_breaker_state_ttl_sweep_v1"];
727
+ const LEGACY_SWEEP_MARKER = ["__fedify_meta", "circuit_breaker_state_ttl_sweep_v2"];
728
728
  const LEGACY_SWEEP_DELETING_MARKER = { __fedifyDeletingCircuitBreakerLegacyState: true };
729
729
  const CIRCUIT_BREAKER_STATE_VERSION = 1;
730
730
  const LEGACY_SWEEP_LOCK_TTL = Temporal.Duration.from({ minutes: 5 });
731
+ const LEGACY_SWEEP_RENEW_INTERVAL = Temporal.Duration.from({ minutes: 1 });
731
732
  const LEGACY_SWEEP_RETRY_WINDOW = Temporal.Duration.from({ hours: 168 });
732
733
  const LEGACY_SWEEP_WAIT_INTERVAL = 10;
733
734
  const LEGACY_SWEEP_CAS_ATTEMPTS = 3;
@@ -942,12 +943,20 @@ var CircuitBreaker = class {
942
943
  }
943
944
  async #sweepLegacyStatesImpl() {
944
945
  const markerKey = this.#legacySweepMarkerKey();
945
- const marker = await this.#acquireLegacySweep(markerKey);
946
- if (marker === "done") return;
946
+ const acquired = await this.#acquireLegacySweep(markerKey);
947
+ if (acquired === "done") return;
948
+ let marker = acquired;
949
+ let leaseRenewedAt = this.#now();
947
950
  try {
948
951
  for await (const { key, value } of this.#kv.list(this.#prefix)) {
949
952
  if (key.length !== this.#prefix.length + 1) continue;
950
953
  await this.#migrateLegacyState(key, value);
954
+ if (Temporal.Instant.compare(this.#now(), leaseRenewedAt.add(LEGACY_SWEEP_RENEW_INTERVAL)) >= 0) {
955
+ const renewed = await this.#renewLegacySweep(markerKey, marker);
956
+ if (renewed == null) return;
957
+ marker = renewed;
958
+ leaseRenewedAt = this.#now();
959
+ }
951
960
  }
952
961
  } catch (error) {
953
962
  await this.#deleteIfUnchanged(markerKey, marker);
@@ -956,6 +965,14 @@ var CircuitBreaker = class {
956
965
  const finishedMarker = this.#finishLegacySweepMarker(marker);
957
966
  if (await this.#kv.cas(markerKey, marker, finishedMarker)) this.#rememberLegacySweepMarker(finishedMarker);
958
967
  }
968
+ async #renewLegacySweep(markerKey, marker) {
969
+ const renewed = {
970
+ state: "sweeping",
971
+ started: this.#now().toString(),
972
+ retryUntil: getLegacySweepRetryUntil(marker) ?? this.#now().add(LEGACY_SWEEP_RETRY_WINDOW).toString()
973
+ };
974
+ if (await this.#kv.cas(markerKey, marker, renewed, { ttl: LEGACY_SWEEP_LOCK_TTL })) return renewed;
975
+ }
959
976
  #finishLegacySweepMarker(marker) {
960
977
  const retryUntil = getLegacySweepRetryUntil(marker);
961
978
  if (retryUntil != null && Temporal.Instant.compare(this.#now(), Temporal.Instant.from(retryUntil)) < 0) return {
@@ -965,7 +982,10 @@ var CircuitBreaker = class {
965
982
  return { state: "final" };
966
983
  }
967
984
  async #migrateLegacyState(key, value) {
968
- if (isCurrentCircuitBreakerState(value)) return;
985
+ if (isCurrentCircuitBreakerState(value)) {
986
+ await this.#kv.cas(key, value, value, this.#setOptions());
987
+ return;
988
+ }
969
989
  const state = parseCircuitBreakerKvState(value);
970
990
  if (state != null) {
971
991
  await this.#kv.cas(key, value, markCircuitBreakerState(state), this.#setOptions());
@@ -1102,7 +1122,7 @@ function normalizeCircuitBreakerOptions(options) {
1102
1122
  } else {
1103
1123
  failure = options.failure;
1104
1124
  pruneFailures = (timestamps) => timestamps.slice(-100);
1105
- stateTtl = configuredStateTtl;
1125
+ stateTtl = configuredStateTtl ?? recoveryDelay.add(heldActivityTtl);
1106
1126
  }
1107
1127
  return {
1108
1128
  failure,
@@ -1,5 +1,5 @@
1
1
  import "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as FederationImpl } from "./middleware-DRGoAGNP.mjs";
4
+ import { n as FederationImpl } from "./middleware-BZGAqnv7.mjs";
5
5
  export { FederationImpl };
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { _t as ActorHandleMapper, gt as ActorDispatcher, ht as ActorAliasMapper, l as RequestContext, zt as WebFingerLinksDispatcher } from "./context-DrLXudbA.js";
2
+ import { _t as ActorHandleMapper, gt as ActorDispatcher, ht as ActorAliasMapper, l as RequestContext, zt as WebFingerLinksDispatcher } from "./context-CmjP-cgJ.js";
3
3
  import { RouterError, RouterOptions, RouterRouteResult } from "@fedify/uri-template";
4
4
  import { MeterProvider, Span, Tracer } from "@opentelemetry/api";
5
5
 
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { _t as ActorHandleMapper, gt as ActorDispatcher, ht as ActorAliasMapper, l as RequestContext, zt as WebFingerLinksDispatcher } from "./context-B-dsBjZ9.cjs";
2
+ import { _t as ActorHandleMapper, gt as ActorDispatcher, ht as ActorAliasMapper, l as RequestContext, zt as WebFingerLinksDispatcher } from "./context-BOnn653X.cjs";
3
3
  import { MeterProvider, Span, Tracer } from "@opentelemetry/api";
4
4
  import { RouterError, RouterOptions, RouterRouteResult } from "@fedify/uri-template";
5
5
 
package/dist/mod.cjs CHANGED
@@ -3,11 +3,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  require("./rolldown-runtime-Dmm3t92W.cjs");
4
4
  const require_transformers = require("./transformers-BalCrSsr.cjs");
5
5
  require("./compat/mod.cjs");
6
- const require_http = require("./http-DcSh3Nkc.cjs");
7
- const require_federation = require("./federation-CChOD4m8.cjs");
8
- const require_proof = require("./proof-Y3u5gsyU.cjs");
6
+ const require_http = require("./http-DaCIe27S.cjs");
7
+ const require_federation = require("./federation-D4wc67AQ.cjs");
8
+ const require_proof = require("./proof-FLTH3GQo.cjs");
9
9
  const require_types = require("./types-RXm5YxpC.cjs");
10
- const require_kv_cache = require("./kv-cache-BJ67yD69.cjs");
10
+ const require_kv_cache = require("./kv-cache-LBXR3jN5.cjs");
11
11
  require("./nodeinfo/mod.cjs");
12
12
  require("./runtime/mod.cjs");
13
13
  require("./sig/mod.cjs");
package/dist/mod.d.cts CHANGED
@@ -2,10 +2,10 @@
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-D-XP_Ccb.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-6TI0tI03.cjs";
4
4
  import { i as getKeyOwner, n as GetKeyOwnerOptions, r as doesActorOwnKey, t as DoesActorOwnKeyOptions } from "./owner-r_waTiQj.cjs";
5
- import { $ as MessageQueueDepth, A as OutboxListenerSetters, At as ObjectAuthorizePredicate, B as TaskEnqueueOptions, Bt as SendActivityError, C as FederationStartQueueOptions, Ct as CustomCollectionCounter, D as InboxListenerSetters, Dt as InboxListener, E as InboxChallengePolicy, Et as InboxErrorHandler, F as createFederation, Ft as OutboxPermanentFailureHandler, G as RetryPolicy, Gt as ActivityTransformer, H as TaskRegistry, Ht as PageItems, I as Message, It as SharedInboxKeyDispatcher, J as respondWithObject, K as createExponentialBackoffPolicy, L as createFederationBuilder, Lt as UnverifiedActivityHandler, M as FederationKvPrefixes, Mt as OutboxErrorHandler, N as FederationOrigin, Nt as OutboxListener, O as MediaUploaderSetters, Ot as MediaUploaderCallback, P as FederationQueueOptions, Pt as OutboxListenerErrorHandler, Q as MessageQueue, R as TaskDefinition, Rt as UnverifiedActivityReason, S as FederationOptions, St as CollectionDispatcher, T as IdempotencyStrategy, Tt as CustomCollectionDispatcher, U as CreateExponentialBackoffPolicyOptions, Ut as buildCollectionSynchronizationHeader, V as TaskHandler, Vt as SenderKeyPair, W as RetryContext, Wt as digest, X as InProcessMessageQueue, Y as respondWithObjectIfAcceptable, Z as InProcessMessageQueueOptions, _ as Federatable, _t as ActorHandleMapper, a as GetSignedKeyOptions, at as CircuitBreakerBeforeSendDecision, b as FederationBuilder, bt as CollectionCounter, c as ParseUriResult, ct as CircuitBreakerKvState, d as SendActivityOptions, dt as CircuitBreakerStateChange, et as MessageQueueEnqueueOptions, f as SendActivityOptionsForCollection, ft as NormalizedCircuitBreakerOptions, g as CustomCollectionCallbackSetters, gt as ActorDispatcher, h as ConstructorWithTypeId, ht as ActorAliasMapper, i as GetActorOptions, it as CircuitBreakerActivityDrop, j as Rfc6570Expression, jt as ObjectDispatcher, k as ObjectCallbackSetters, kt as NodeInfoDispatcher, l as RequestContext, lt as CircuitBreakerOptions, m as CollectionCallbackSetters, mt as parseCircuitBreakerKvState, n as Context, nt as ParallelMessageQueue, o as InboxContext, ot as CircuitBreakerCreateOptions, p as ActorCallbackSetters, pt as normalizeCircuitBreakerOptions, q as RespondWithObjectOptions, r as ForwardActivityOptions, rt as CircuitBreaker, s as OutboxContext, st as CircuitBreakerFailurePolicy, t as ActorKeyPair, tt as MessageQueueListenOptions, u as RouteActivityOptions, ut as CircuitBreakerState, v as Federation, vt as ActorKeyPairsDispatcher, w as IdempotencyKeyCallback, wt as CustomCollectionCursor, x as FederationFetchOptions, xt as CollectionCursor, y as FederationBenchmarkOptions, yt as AuthorizePredicate, z as TaskDefinitionOptions, zt as WebFingerLinksDispatcher } from "./context-B-dsBjZ9.cjs";
5
+ import { $ as MessageQueueDepth, A as OutboxListenerSetters, At as ObjectAuthorizePredicate, B as TaskEnqueueOptions, Bt as SendActivityError, C as FederationStartQueueOptions, Ct as CustomCollectionCounter, D as InboxListenerSetters, Dt as InboxListener, E as InboxChallengePolicy, Et as InboxErrorHandler, F as createFederation, Ft as OutboxPermanentFailureHandler, G as RetryPolicy, Gt as ActivityTransformer, H as TaskRegistry, Ht as PageItems, I as Message, It as SharedInboxKeyDispatcher, J as respondWithObject, K as createExponentialBackoffPolicy, L as createFederationBuilder, Lt as UnverifiedActivityHandler, M as FederationKvPrefixes, Mt as OutboxErrorHandler, N as FederationOrigin, Nt as OutboxListener, O as MediaUploaderSetters, Ot as MediaUploaderCallback, P as FederationQueueOptions, Pt as OutboxListenerErrorHandler, Q as MessageQueue, R as TaskDefinition, Rt as UnverifiedActivityReason, S as FederationOptions, St as CollectionDispatcher, T as IdempotencyStrategy, Tt as CustomCollectionDispatcher, U as CreateExponentialBackoffPolicyOptions, Ut as buildCollectionSynchronizationHeader, V as TaskHandler, Vt as SenderKeyPair, W as RetryContext, Wt as digest, X as InProcessMessageQueue, Y as respondWithObjectIfAcceptable, Z as InProcessMessageQueueOptions, _ as Federatable, _t as ActorHandleMapper, a as GetSignedKeyOptions, at as CircuitBreakerBeforeSendDecision, b as FederationBuilder, bt as CollectionCounter, c as ParseUriResult, ct as CircuitBreakerKvState, d as SendActivityOptions, dt as CircuitBreakerStateChange, et as MessageQueueEnqueueOptions, f as SendActivityOptionsForCollection, ft as NormalizedCircuitBreakerOptions, g as CustomCollectionCallbackSetters, gt as ActorDispatcher, h as ConstructorWithTypeId, ht as ActorAliasMapper, i as GetActorOptions, it as CircuitBreakerActivityDrop, j as Rfc6570Expression, jt as ObjectDispatcher, k as ObjectCallbackSetters, kt as NodeInfoDispatcher, l as RequestContext, lt as CircuitBreakerOptions, m as CollectionCallbackSetters, mt as parseCircuitBreakerKvState, n as Context, nt as ParallelMessageQueue, o as InboxContext, ot as CircuitBreakerCreateOptions, p as ActorCallbackSetters, pt as normalizeCircuitBreakerOptions, q as RespondWithObjectOptions, r as ForwardActivityOptions, rt as CircuitBreaker, s as OutboxContext, st as CircuitBreakerFailurePolicy, t as ActorKeyPair, tt as MessageQueueListenOptions, u as RouteActivityOptions, ut as CircuitBreakerState, v as Federation, vt as ActorKeyPairsDispatcher, w as IdempotencyKeyCallback, wt as CustomCollectionCursor, x as FederationFetchOptions, xt as CollectionCursor, y as FederationBenchmarkOptions, yt as AuthorizePredicate, z as TaskDefinitionOptions, zt as WebFingerLinksDispatcher } from "./context-BOnn653X.cjs";
6
6
  import { a as MemoryKvStore, i as KvStoreSetOptions, n as KvStore, r as KvStoreListEntry, t as KvKey } from "./kv-BhNbN8Ed.cjs";
7
7
  import { actorDehydrator, autoIdAssigner, getDefaultActivityTransformers } from "./compat/mod.cjs";
8
- import { a as RouterOptions, i as RouterError, n as handleWebFinger, o as RouterRouteResult, r as Router, t as WebFingerHandlerParameters } from "./mod-D-abvu2C.cjs";
8
+ import { a as RouterOptions, i as RouterError, n as handleWebFinger, o as RouterRouteResult, r as Router, t as WebFingerHandlerParameters } from "./mod-kUSY5n3f.cjs";
9
9
  import { C as verifyJsonLd, S as signJsonLd, _ as VerifySignatureOptions, a as VerifyPortableObjectProofOptions, b as detachSignature, c as createProof, d as verifyObject, f as verifyPortableObjectProof, g as VerifyJsonLdOptions, h as SignJsonLdOptions, i as VerifyPortableObjectProofFailureReason, l as hasProofLike, m as CreateSignatureOptions, n as SignObjectOptions, o as VerifyPortableObjectProofResult, p as verifyProof, r as VerifyObjectOptions, s as VerifyProofOptions, t as CreateProofOptions, u as signObject, v as attachSignature, w as verifySignature, x as hasSignatureLike, y as createSignature } from "./mod-CnGLNoVw.cjs";
10
10
  import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./mod-CLHkCwLm.cjs";
11
11
  export * from "@fedify/vocab-runtime";
package/dist/mod.d.ts CHANGED
@@ -2,10 +2,10 @@
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-D-XP_Ccb.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-CdrSn2ip.js";
4
4
  import { i as getKeyOwner, n as GetKeyOwnerOptions, r as doesActorOwnKey, t as DoesActorOwnKeyOptions } from "./owner-DGSfntI-.js";
5
- import { $ as MessageQueueDepth, A as OutboxListenerSetters, At as ObjectAuthorizePredicate, B as TaskEnqueueOptions, Bt as SendActivityError, C as FederationStartQueueOptions, Ct as CustomCollectionCounter, D as InboxListenerSetters, Dt as InboxListener, E as InboxChallengePolicy, Et as InboxErrorHandler, F as createFederation, Ft as OutboxPermanentFailureHandler, G as RetryPolicy, Gt as ActivityTransformer, H as TaskRegistry, Ht as PageItems, I as Message, It as SharedInboxKeyDispatcher, J as respondWithObject, K as createExponentialBackoffPolicy, L as createFederationBuilder, Lt as UnverifiedActivityHandler, M as FederationKvPrefixes, Mt as OutboxErrorHandler, N as FederationOrigin, Nt as OutboxListener, O as MediaUploaderSetters, Ot as MediaUploaderCallback, P as FederationQueueOptions, Pt as OutboxListenerErrorHandler, Q as MessageQueue, R as TaskDefinition, Rt as UnverifiedActivityReason, S as FederationOptions, St as CollectionDispatcher, T as IdempotencyStrategy, Tt as CustomCollectionDispatcher, U as CreateExponentialBackoffPolicyOptions, Ut as buildCollectionSynchronizationHeader, V as TaskHandler, Vt as SenderKeyPair, W as RetryContext, Wt as digest, X as InProcessMessageQueue, Y as respondWithObjectIfAcceptable, Z as InProcessMessageQueueOptions, _ as Federatable, _t as ActorHandleMapper, a as GetSignedKeyOptions, at as CircuitBreakerBeforeSendDecision, b as FederationBuilder, bt as CollectionCounter, c as ParseUriResult, ct as CircuitBreakerKvState, d as SendActivityOptions, dt as CircuitBreakerStateChange, et as MessageQueueEnqueueOptions, f as SendActivityOptionsForCollection, ft as NormalizedCircuitBreakerOptions, g as CustomCollectionCallbackSetters, gt as ActorDispatcher, h as ConstructorWithTypeId, ht as ActorAliasMapper, i as GetActorOptions, it as CircuitBreakerActivityDrop, j as Rfc6570Expression, jt as ObjectDispatcher, k as ObjectCallbackSetters, kt as NodeInfoDispatcher, l as RequestContext, lt as CircuitBreakerOptions, m as CollectionCallbackSetters, mt as parseCircuitBreakerKvState, n as Context, nt as ParallelMessageQueue, o as InboxContext, ot as CircuitBreakerCreateOptions, p as ActorCallbackSetters, pt as normalizeCircuitBreakerOptions, q as RespondWithObjectOptions, r as ForwardActivityOptions, rt as CircuitBreaker, s as OutboxContext, st as CircuitBreakerFailurePolicy, t as ActorKeyPair, tt as MessageQueueListenOptions, u as RouteActivityOptions, ut as CircuitBreakerState, v as Federation, vt as ActorKeyPairsDispatcher, w as IdempotencyKeyCallback, wt as CustomCollectionCursor, x as FederationFetchOptions, xt as CollectionCursor, y as FederationBenchmarkOptions, yt as AuthorizePredicate, z as TaskDefinitionOptions, zt as WebFingerLinksDispatcher } from "./context-DrLXudbA.js";
5
+ import { $ as MessageQueueDepth, A as OutboxListenerSetters, At as ObjectAuthorizePredicate, B as TaskEnqueueOptions, Bt as SendActivityError, C as FederationStartQueueOptions, Ct as CustomCollectionCounter, D as InboxListenerSetters, Dt as InboxListener, E as InboxChallengePolicy, Et as InboxErrorHandler, F as createFederation, Ft as OutboxPermanentFailureHandler, G as RetryPolicy, Gt as ActivityTransformer, H as TaskRegistry, Ht as PageItems, I as Message, It as SharedInboxKeyDispatcher, J as respondWithObject, K as createExponentialBackoffPolicy, L as createFederationBuilder, Lt as UnverifiedActivityHandler, M as FederationKvPrefixes, Mt as OutboxErrorHandler, N as FederationOrigin, Nt as OutboxListener, O as MediaUploaderSetters, Ot as MediaUploaderCallback, P as FederationQueueOptions, Pt as OutboxListenerErrorHandler, Q as MessageQueue, R as TaskDefinition, Rt as UnverifiedActivityReason, S as FederationOptions, St as CollectionDispatcher, T as IdempotencyStrategy, Tt as CustomCollectionDispatcher, U as CreateExponentialBackoffPolicyOptions, Ut as buildCollectionSynchronizationHeader, V as TaskHandler, Vt as SenderKeyPair, W as RetryContext, Wt as digest, X as InProcessMessageQueue, Y as respondWithObjectIfAcceptable, Z as InProcessMessageQueueOptions, _ as Federatable, _t as ActorHandleMapper, a as GetSignedKeyOptions, at as CircuitBreakerBeforeSendDecision, b as FederationBuilder, bt as CollectionCounter, c as ParseUriResult, ct as CircuitBreakerKvState, d as SendActivityOptions, dt as CircuitBreakerStateChange, et as MessageQueueEnqueueOptions, f as SendActivityOptionsForCollection, ft as NormalizedCircuitBreakerOptions, g as CustomCollectionCallbackSetters, gt as ActorDispatcher, h as ConstructorWithTypeId, ht as ActorAliasMapper, i as GetActorOptions, it as CircuitBreakerActivityDrop, j as Rfc6570Expression, jt as ObjectDispatcher, k as ObjectCallbackSetters, kt as NodeInfoDispatcher, l as RequestContext, lt as CircuitBreakerOptions, m as CollectionCallbackSetters, mt as parseCircuitBreakerKvState, n as Context, nt as ParallelMessageQueue, o as InboxContext, ot as CircuitBreakerCreateOptions, p as ActorCallbackSetters, pt as normalizeCircuitBreakerOptions, q as RespondWithObjectOptions, r as ForwardActivityOptions, rt as CircuitBreaker, s as OutboxContext, st as CircuitBreakerFailurePolicy, t as ActorKeyPair, tt as MessageQueueListenOptions, u as RouteActivityOptions, ut as CircuitBreakerState, v as Federation, vt as ActorKeyPairsDispatcher, w as IdempotencyKeyCallback, wt as CustomCollectionCursor, x as FederationFetchOptions, xt as CollectionCursor, y as FederationBenchmarkOptions, yt as AuthorizePredicate, z as TaskDefinitionOptions, zt as WebFingerLinksDispatcher } from "./context-CmjP-cgJ.js";
6
6
  import { a as MemoryKvStore, i as KvStoreSetOptions, n as KvStore, r as KvStoreListEntry, t as KvKey } from "./kv-BhNbN8Ed.js";
7
7
  import { actorDehydrator, autoIdAssigner, getDefaultActivityTransformers } from "./compat/mod.js";
8
- import { a as RouterOptions, i as RouterError, n as handleWebFinger, o as RouterRouteResult, r as Router, t as WebFingerHandlerParameters } from "./mod-D6O8C7eN.js";
8
+ import { a as RouterOptions, i as RouterError, n as handleWebFinger, o as RouterRouteResult, r as Router, t as WebFingerHandlerParameters } from "./mod-BYuZ0WXt.js";
9
9
  import { C as verifyJsonLd, S as signJsonLd, _ as VerifySignatureOptions, a as VerifyPortableObjectProofOptions, b as detachSignature, c as createProof, d as verifyObject, f as verifyPortableObjectProof, g as VerifyJsonLdOptions, h as SignJsonLdOptions, i as VerifyPortableObjectProofFailureReason, l as hasProofLike, m as CreateSignatureOptions, n as SignObjectOptions, o as VerifyPortableObjectProofResult, p as verifyProof, r as VerifyObjectOptions, s as VerifyProofOptions, t as CreateProofOptions, u as signObject, v as attachSignature, w as verifySignature, x as hasSignatureLike, y as createSignature } from "./mod-DzRXACM5.js";
10
10
  import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./mod-DypxPS9H.js";
11
11
  export * from "@fedify/vocab-runtime";
package/dist/mod.js CHANGED
@@ -3,11 +3,11 @@ import { URLPattern } from "urlpattern-polyfill";
3
3
  import "./rolldown-runtime-BC-Eo5Mj.js";
4
4
  import { n as autoIdAssigner, r as getDefaultActivityTransformers, t as actorDehydrator } from "./transformers-DAtXl_Kc.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-CqXnYPxh.js";
7
- import { a as respondWithObject, c as digest, d as parseCircuitBreakerKvState, f as createFederationBuilder, i as SendActivityError, l as CircuitBreaker, n as handleWebFinger, o as respondWithObjectIfAcceptable, r as createExponentialBackoffPolicy, s as buildCollectionSynchronizationHeader, t as createFederation, u as normalizeCircuitBreakerOptions } from "./middleware-Hgkr-t3e.js";
8
- import { C as verifyJsonLd, a as verifyPortableObjectProof, c as doesActorOwnKey, f as attachSignature, h as detachSignature, i as verifyObject, l as getKeyOwner, m as createSignature, n as hasProofLike, o as verifyProof, r as signObject, t as createProof, v as hasSignatureLike, w as verifySignature, x as signJsonLd } from "./proof-CKKqEWUg.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-ByQYBoMk.js";
7
+ import { a as respondWithObject, c as digest, d as parseCircuitBreakerKvState, f as createFederationBuilder, i as SendActivityError, l as CircuitBreaker, n as handleWebFinger, o as respondWithObjectIfAcceptable, r as createExponentialBackoffPolicy, s as buildCollectionSynchronizationHeader, t as createFederation, u as normalizeCircuitBreakerOptions } from "./middleware-DXabWqen.js";
8
+ import { C as verifyJsonLd, a as verifyPortableObjectProof, c as doesActorOwnKey, f as attachSignature, h as detachSignature, i as verifyObject, l as getKeyOwner, m as createSignature, n as hasProofLike, o as verifyProof, r as signObject, t as createProof, v as hasSignatureLike, w as verifySignature, x as signJsonLd } from "./proof-CCnQdjNX.js";
9
9
  import { n as getNodeInfo, r as parseNodeInfo, t as nodeInfoToJson } from "./types-Dtyf8lVj.js";
10
- import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-AbW4Zb7B.js";
10
+ import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-C3ffIesH.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-Dt36KFEJ.mjs";
5
5
  import { t as MemoryKvStore } from "../kv-DCHkaJ9-.mjs";
6
6
  import { t as assertEquals } from "../assert_equals-CBlRfA-_.mjs";
7
7
  import "../std__assert-CxFT0MNt.mjs";
8
- import { _ as handleNodeInfo, o as createFederation, v as handleNodeInfoJrd } from "../middleware-DRGoAGNP.mjs";
8
+ import { _ as handleNodeInfo, o as createFederation, v as handleNodeInfoJrd } from "../middleware-BZGAqnv7.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 "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-CNYW2Ig8.mjs";
5
- import "./key-hmby7gn5.mjs";
4
+ import { n as version, t as name } from "./deno-B5Jy0IH5.mjs";
5
+ import "./key-Dx1gDplp.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,6 +1,6 @@
1
1
  import { Temporal } from "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-CqXnYPxh.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-ByQYBoMk.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,10 +1,10 @@
1
1
  import { Temporal } from "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-CNYW2Ig8.mjs";
5
- import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-Pf5DoomU.mjs";
6
- import { n as fetchKey, o as validateCryptoKey } from "./key-hmby7gn5.mjs";
7
- import { c as getNormalizationContextLoader } from "./ld-B8i_nYpF.mjs";
4
+ import { n as version, t as name } from "./deno-B5Jy0IH5.mjs";
5
+ import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-DB_aJ3d7.mjs";
6
+ import { n as fetchKey, o as validateCryptoKey } from "./key-Dx1gDplp.mjs";
7
+ import { c as getNormalizationContextLoader } from "./ld-jRq6FLRU.mjs";
8
8
  import { n as preloadedOnlyDocumentLoader } from "./public-audience--9hx7IGx.mjs";
9
9
  import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-BQSHRLhg.mjs";
10
10
  import { getLogger } from "@logtape/logtape";
@@ -1,6 +1,6 @@
1
1
  const { URLPattern } = require("urlpattern-polyfill");
2
2
  const require_rolldown_runtime = require("./rolldown-runtime-Dmm3t92W.cjs");
3
- const require_http = require("./http-DcSh3Nkc.cjs");
3
+ const require_http = require("./http-DaCIe27S.cjs");
4
4
  let _logtape_logtape = require("@logtape/logtape");
5
5
  let _fedify_vocab = require("@fedify/vocab");
6
6
  let _opentelemetry_api = require("@opentelemetry/api");
@@ -1,9 +1,9 @@
1
1
  import "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-CNYW2Ig8.mjs";
5
- import { n as getDurationMs, r as getFederationMetrics } from "./metrics-Pf5DoomU.mjs";
6
- import { n as doubleKnock } from "./http-DpXPu64P.mjs";
4
+ import { n as version, t as name } from "./deno-B5Jy0IH5.mjs";
5
+ import { n as getDurationMs, r as getFederationMetrics } from "./metrics-DB_aJ3d7.mjs";
6
+ import { n as doubleKnock } from "./http-CI_W79n9.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";
@@ -10,8 +10,8 @@ import { t as assertThrows } from "../assert_throws-BJ5wuvR2.mjs";
10
10
  import "../std__assert-CxFT0MNt.mjs";
11
11
  import { t as assertRejects } from "../assert_rejects-wFbSPn1O.mjs";
12
12
  import { t as assert } from "../assert-CebeUf0C.mjs";
13
- import { t as exportJwk } from "../key-hmby7gn5.mjs";
14
- 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-DpXPu64P.mjs";
13
+ import { t as exportJwk } from "../key-Dx1gDplp.mjs";
14
+ 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-CI_W79n9.mjs";
15
15
  import { i as rsaPrivateKey2, l as rsaPublicKey5, o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-DIJNHW-Y.mjs";
16
16
  import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
17
17
  import { FetchError, exportSpki } from "@fedify/vocab-runtime";
@@ -1027,6 +1027,7 @@ test("doubleKnock() function with redirect handling", async () => {
1027
1027
  esm_default.spyGlobal();
1028
1028
  const requestedUrls = [];
1029
1029
  const responseCodes = [];
1030
+ const validatedRedirects = [];
1030
1031
  esm_default.post("https://example.com/redirect-endpoint", (cl) => {
1031
1032
  requestedUrls.push(cl.url);
1032
1033
  responseCodes.push(302);
@@ -1044,11 +1045,41 @@ test("doubleKnock() function with redirect handling", async () => {
1044
1045
  }), {
1045
1046
  keyId: rsaPublicKey2.id,
1046
1047
  privateKey: rsaPrivateKey2
1047
- })).status, 202, "Final response status should be 202 Accepted");
1048
+ }, { validateRedirect(url) {
1049
+ validatedRedirects.push(url);
1050
+ } })).status, 202, "Final response status should be 202 Accepted");
1048
1051
  assertEquals(requestedUrls.length, 2, "Two URLs should have been requested");
1049
1052
  assertEquals(requestedUrls[0], "https://example.com/redirect-endpoint", "First request should be to redirect-endpoint");
1050
1053
  assertEquals(requestedUrls[1], "https://example.com/final-endpoint", "Second request should be to final-endpoint");
1051
1054
  assertEquals(responseCodes, [302, 202], "Response status codes should match expected sequence");
1055
+ assertEquals(validatedRedirects, ["https://example.com/final-endpoint"]);
1056
+ esm_default.hardReset();
1057
+ });
1058
+ test("doubleKnock() validates redirects after signature fallback", async () => {
1059
+ esm_default.spyGlobal();
1060
+ let requestCount = 0;
1061
+ let privateRequestCount = 0;
1062
+ esm_default.post("https://example.com/redirect-after-fallback", (cl) => {
1063
+ requestCount++;
1064
+ if (cl.request.headers.has("Signature-Input")) return new Response("Unauthorized", { status: 401 });
1065
+ return Response.redirect("http://localhost/private", 302);
1066
+ });
1067
+ esm_default.post("http://localhost/private", () => {
1068
+ privateRequestCount++;
1069
+ return new Response("", { status: 202 });
1070
+ });
1071
+ const request = new Request("https://example.com/redirect-after-fallback", {
1072
+ method: "POST",
1073
+ body: "Test message"
1074
+ });
1075
+ await assertRejects(() => doubleKnock(request, {
1076
+ keyId: rsaPublicKey2.id,
1077
+ privateKey: rsaPrivateKey2
1078
+ }, { validateRedirect(url) {
1079
+ throw new Error(`Disallowed redirect: ${url}`);
1080
+ } }), Error, "Disallowed redirect: http://localhost/private");
1081
+ assertEquals(requestCount, 2);
1082
+ assertEquals(privateRequestCount, 0);
1052
1083
  esm_default.hardReset();
1053
1084
  });
1054
1085
  test("doubleKnock() function with both specs rejected", async () => {
@@ -1839,6 +1870,37 @@ test("doubleKnock(): Accept-Signature challenge retry succeeds", async () => {
1839
1870
  assertEquals(requestCount, 2);
1840
1871
  esm_default.hardReset();
1841
1872
  });
1873
+ test("doubleKnock(): validates redirects after Accept-Signature challenge retry", async () => {
1874
+ esm_default.spyGlobal();
1875
+ let requestCount = 0;
1876
+ let privateRequestCount = 0;
1877
+ esm_default.post("https://example.com/inbox-challenge-redirect", () => {
1878
+ requestCount++;
1879
+ if (requestCount === 1) return new Response("Not Authorized", {
1880
+ status: 401,
1881
+ headers: { "Accept-Signature": "sig1=(\"@method\" \"@target-uri\" \"@authority\" \"content-digest\");created;nonce=\"challenge-nonce-redirect\"" }
1882
+ });
1883
+ return Response.redirect("http://localhost/private", 302);
1884
+ });
1885
+ esm_default.post("http://localhost/private", () => {
1886
+ privateRequestCount++;
1887
+ return new Response("", { status: 202 });
1888
+ });
1889
+ const request = new Request("https://example.com/inbox-challenge-redirect", {
1890
+ method: "POST",
1891
+ body: "Test message",
1892
+ headers: { "Content-Type": "text/plain" }
1893
+ });
1894
+ await assertRejects(() => doubleKnock(request, {
1895
+ keyId: rsaPublicKey2.id,
1896
+ privateKey: rsaPrivateKey2
1897
+ }, { validateRedirect(url) {
1898
+ throw new Error(`Disallowed redirect: ${url}`);
1899
+ } }), Error, "Disallowed redirect: http://localhost/private");
1900
+ assertEquals(requestCount, 2);
1901
+ assertEquals(privateRequestCount, 0);
1902
+ esm_default.hardReset();
1903
+ });
1842
1904
  test("doubleKnock(): unfulfillable Accept-Signature falls to legacy fallback", async () => {
1843
1905
  esm_default.spyGlobal();
1844
1906
  let requestCount = 0;
@@ -5,7 +5,7 @@ import { t as assertEquals } from "../assert_equals-CBlRfA-_.mjs";
5
5
  import { t as assertThrows } from "../assert_throws-BJ5wuvR2.mjs";
6
6
  import "../std__assert-CxFT0MNt.mjs";
7
7
  import { t as assertRejects } from "../assert_rejects-wFbSPn1O.mjs";
8
- import { a as importJwk, i as generateCryptoKeyPair, n as fetchKey, o as validateCryptoKey, r as fetchKeyDetailed, t as exportJwk } from "../key-hmby7gn5.mjs";
8
+ import { a as importJwk, i as generateCryptoKeyPair, n as fetchKey, o as validateCryptoKey, r as fetchKeyDetailed, t as exportJwk } from "../key-Dx1gDplp.mjs";
9
9
  import { c as rsaPublicKey3, i as rsaPrivateKey2, o as rsaPublicKey1, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DIJNHW-Y.mjs";
10
10
  import { CryptographicKey, Multikey } from "@fedify/vocab";
11
11
  import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
@@ -584,6 +584,51 @@ test("fetchKey() works when meterProvider is omitted", async () => {
584
584
  contextLoader: mockDocumentLoader
585
585
  })).cached, false);
586
586
  });
587
+ test("fetchKey() rejects standalone keys with a mismatched id", async () => {
588
+ for (const { keyId, standaloneKey, fetch } of [{
589
+ keyId: "https://example.com/key",
590
+ standaloneKey: rsaPublicKey1,
591
+ fetch: (keyId, options) => fetchKey(keyId, CryptographicKey, options)
592
+ }, {
593
+ keyId: "https://example.com/multikey",
594
+ standaloneKey: ed25519Multikey,
595
+ fetch: (keyId, options) => fetchKey(keyId, Multikey, options)
596
+ }]) {
597
+ const cache = {};
598
+ const options = {
599
+ async documentLoader(resource) {
600
+ if (resource === keyId) return {
601
+ contextUrl: null,
602
+ documentUrl: resource,
603
+ document: {
604
+ ...await standaloneKey.toJsonLd({ contextLoader: mockDocumentLoader }),
605
+ id: "https://example.com/different-key"
606
+ }
607
+ };
608
+ return await mockDocumentLoader(resource);
609
+ },
610
+ contextLoader: mockDocumentLoader,
611
+ keyCache: {
612
+ get(keyId) {
613
+ return Promise.resolve(cache[keyId.href]);
614
+ },
615
+ set(keyId, key) {
616
+ cache[keyId.href] = key;
617
+ return Promise.resolve();
618
+ }
619
+ }
620
+ };
621
+ assertEquals(await fetch(keyId, options), {
622
+ key: null,
623
+ cached: false
624
+ });
625
+ assertEquals(cache, { [keyId]: null });
626
+ assertEquals(await fetch(keyId, options), {
627
+ key: null,
628
+ cached: true
629
+ });
630
+ }
631
+ });
587
632
  test("fetchKey() returns null for a malformed actor publicKey", async () => {
588
633
  const actorId = "https://example.com/malformed-public-key";
589
634
  const keyId = "https://example.com/malformed-public-key#main-key";
@@ -7,9 +7,9 @@ import { t as assertGreaterOrEqual } from "../assert_greater_or_equal-BApOTh1h.m
7
7
  import { t as assertThrows } from "../assert_throws-BJ5wuvR2.mjs";
8
8
  import { t as assertRejects } from "../assert_rejects-wFbSPn1O.mjs";
9
9
  import { t as assert } from "../assert-CebeUf0C.mjs";
10
- import { i as generateCryptoKeyPair } from "../key-hmby7gn5.mjs";
10
+ import { i as generateCryptoKeyPair } from "../key-Dx1gDplp.mjs";
11
11
  import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DIJNHW-Y.mjs";
12
- 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-B8i_nYpF.mjs";
12
+ 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-jRq6FLRU.mjs";
13
13
  import { CryptographicKey } from "@fedify/vocab";
14
14
  import { createTestMeterProvider, mockDocumentLoader, test } from "@fedify/fixture";
15
15
  import { encodeBase64 } from "byte-encodings/base64";
package/dist/sig/mod.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  const { URLPattern } = require("urlpattern-polyfill");
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const require_http = require("../http-DcSh3Nkc.cjs");
4
- const require_proof = require("../proof-Y3u5gsyU.cjs");
3
+ const require_http = require("../http-DaCIe27S.cjs");
4
+ const require_proof = require("../proof-FLTH3GQo.cjs");
5
5
  exports.attachSignature = require_proof.attachSignature;
6
6
  exports.createProof = require_proof.createProof;
7
7
  exports.createSignature = require_proof.createSignature;
package/dist/sig/mod.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Temporal } from "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-CqXnYPxh.js";
4
- import { C as verifyJsonLd, a as verifyPortableObjectProof, c as doesActorOwnKey, f as attachSignature, h as detachSignature, i as verifyObject, l as getKeyOwner, m as createSignature, n as hasProofLike, o as verifyProof, r as signObject, t as createProof, v as hasSignatureLike, w as verifySignature, x as signJsonLd } from "../proof-CKKqEWUg.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-ByQYBoMk.js";
4
+ import { C as verifyJsonLd, a as verifyPortableObjectProof, c as doesActorOwnKey, f as attachSignature, h as detachSignature, i as verifyObject, l as getKeyOwner, m as createSignature, n as hasProofLike, o as verifyProof, r as signObject, t as createProof, v as hasSignatureLike, w as verifySignature, x as signJsonLd } from "../proof-CCnQdjNX.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, verifyPortableObjectProof, verifyProof, verifyRequest, verifyRequestDetailed, verifySignature };
@@ -6,7 +6,7 @@ import { t as assertFalse } from "../assert_false-3pLLLsO4.mjs";
6
6
  import "../std__assert-CxFT0MNt.mjs";
7
7
  import { t as assert } from "../assert-CebeUf0C.mjs";
8
8
  import { o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-DIJNHW-Y.mjs";
9
- import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-Bq-aDUI1.mjs";
9
+ import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-B8wSl5D1.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
@@ -10,7 +10,7 @@ import { t as assertRejects } from "../assert_rejects-wFbSPn1O.mjs";
10
10
  import { t as assert } from "../assert-CebeUf0C.mjs";
11
11
  import { i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DIJNHW-Y.mjs";
12
12
  import { r as normalizeOutgoingActivityJsonLd } from "../outgoing-jsonld-BQSHRLhg.mjs";
13
- import { a as verifyPortableObjectProof, i as verifyObject, n as hasProofLike, o as verifyProof, r as signObject, t as createProof } from "../proof-BJ6kqGDQ.mjs";
13
+ import { a as verifyPortableObjectProof, i as verifyObject, n as hasProofLike, o as verifyProof, r as signObject, t as createProof } from "../proof-Dwx8Yb1A.mjs";
14
14
  import { Create, DataIntegrityProof, Document, Multikey, Note, PUBLIC_COLLECTION, Place } from "@fedify/vocab";
15
15
  import { createTestMeterProvider, mockDocumentLoader, test } from "@fedify/fixture";
16
16
  import { decodeMultibase, encodeMultibase, exportDidKey, exportMultibaseKey, formatIri, importMultibaseKey, parseIri } from "@fedify/vocab-runtime";
@@ -1,7 +1,7 @@
1
1
  import { Temporal } from "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { c as getNormalizationContextLoader } from "./ld-B8i_nYpF.mjs";
4
+ import { c as getNormalizationContextLoader } from "./ld-jRq6FLRU.mjs";
5
5
  import jsonld from "@fedify/vocab-runtime/jsonld";
6
6
  //#region src/federation/temporal.ts
7
7
  function isPlainObject(value) {
@@ -788,8 +788,9 @@ type CircuitBreakerOptions = CircuitBreakerFailurePolicy & {
788
788
  *
789
789
  * When omitted, Fedify derives this from `failureWindow`, `recoveryDelay`, and
790
790
  * `heldActivityTtl` for the default numeric failure policy. Custom `failure`
791
- * callbacks do not have an inspectable time window, so custom policies do not
792
- * expire their stored state unless this option is provided.
791
+ * callbacks do not have an inspectable time window, so their state expires
792
+ * after `recoveryDelay` plus `heldActivityTtl` unless this option overrides
793
+ * it.
793
794
  */
794
795
  readonly stateTtl?: Temporal.Duration | Temporal.DurationLike;
795
796
  /**
@@ -5,9 +5,9 @@ import { t as esm_default } from "../esm-BHXXx4Wx.mjs";
5
5
  import { t as assertEquals } from "../assert_equals-CBlRfA-_.mjs";
6
6
  import "../std__assert-CxFT0MNt.mjs";
7
7
  import { t as assertRejects } from "../assert_rejects-wFbSPn1O.mjs";
8
- import { l as verifyRequest } from "../http-DpXPu64P.mjs";
8
+ import { l as verifyRequest } from "../http-CI_W79n9.mjs";
9
9
  import { i as rsaPrivateKey2 } from "../keys-DIJNHW-Y.mjs";
10
- import { t as getAuthenticatedDocumentLoader } from "../docloader-Dzbz3Js2.mjs";
10
+ import { t as getAuthenticatedDocumentLoader } from "../docloader-RO5dmEG1.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 "temporal-polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as kvCache, t as MockKvStore } from "../kv-cache-Nl-t79NZ.mjs";
4
+ import { n as kvCache, t as MockKvStore } from "../kv-cache-D6L7jCkB.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,5 +1,5 @@
1
1
  const { URLPattern } = require("urlpattern-polyfill");
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const require_kv_cache = require("../kv-cache-BJ67yD69.cjs");
3
+ const require_kv_cache = require("../kv-cache-LBXR3jN5.cjs");
4
4
  exports.getAuthenticatedDocumentLoader = require_kv_cache.getAuthenticatedDocumentLoader;
5
5
  exports.kvCache = require_kv_cache.kvCache;
package/dist/utils/mod.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import { Temporal } from "temporal-polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../kv-cache-AbW4Zb7B.js";
3
+ import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../kv-cache-C3ffIesH.js";
4
4
  export { getAuthenticatedDocumentLoader, kvCache };