@fedify/fedify 2.4.0-dev.2065 → 2.4.0-dev.2071

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 (93) hide show
  1. package/dist/{builder-CMkrnYbY.mjs → builder-DVQ0yhKJ.mjs} +6 -2
  2. package/dist/compat/mod.d.cts +1 -1
  3. package/dist/compat/mod.d.ts +1 -1
  4. package/dist/compat/transformers.test.mjs +1 -1
  5. package/dist/{compound-proof-Dj3DCsoj.mjs → compound-proof-KmXDfWFp.mjs} +1 -1
  6. package/dist/{context-b36TpPoG.d.cts → context-DijrgHDe.d.cts} +45 -2
  7. package/dist/{context-D_gg4M0n.d.ts → context-DsB9kF6q.d.ts} +45 -2
  8. package/dist/{deno-BuRFI7wk.mjs → deno-B-NtYZVW.mjs} +1 -1
  9. package/dist/{docloader-_aSNLA90.mjs → docloader-C6yOVoaF.mjs} +2 -2
  10. package/dist/federation/builder.test.mjs +1 -1
  11. package/dist/federation/compound-fanout.test.mjs +4 -4
  12. package/dist/federation/handler-compound-proof.test.mjs +3 -3
  13. package/dist/federation/handler.test.mjs +5 -5
  14. package/dist/federation/hashlink-media.test.mjs +2 -2
  15. package/dist/federation/idempotency.test.mjs +2 -2
  16. package/dist/federation/metrics.test.mjs +1 -1
  17. package/dist/federation/middleware.test.mjs +8 -8
  18. package/dist/federation/mod.cjs +1 -1
  19. package/dist/federation/mod.d.cts +3 -3
  20. package/dist/federation/mod.d.ts +3 -3
  21. package/dist/federation/mod.js +1 -1
  22. package/dist/federation/outgoing-proof.test.mjs +6 -6
  23. package/dist/federation/portable-gateway-keys.test.d.mts +2 -0
  24. package/dist/federation/portable-gateway-keys.test.mjs +363 -0
  25. package/dist/federation/portable.test.mjs +3 -3
  26. package/dist/federation/send.test.mjs +3 -3
  27. package/dist/federation/tasks/enqueue.test.mjs +1 -1
  28. package/dist/federation/tasks/tasks.test.mjs +2 -2
  29. package/dist/federation/temporal.test.mjs +1 -1
  30. package/dist/federation/webfinger.test.mjs +1 -1
  31. package/dist/{federation-Coi_bg12.cjs → federation-CUiHc7dP.cjs} +182 -76
  32. package/dist/http-BoWBwC0g.js +5087 -0
  33. package/dist/{http-BGShIsd6.cjs → http-CuLWIJdf.cjs} +2684 -48
  34. package/dist/{http-f1qaBtOh.mjs → http-DKWi8RjI.mjs} +20 -5
  35. package/dist/{http-65PYi9jY.d.ts → http-n2v6DPxu.d.ts} +52 -2
  36. package/dist/{http-CP-7OdSq.d.cts → http-xlG-jRdB.d.cts} +52 -2
  37. package/dist/{key-BxHsA1s9.mjs → key-lfcx_NaE.mjs} +147 -7
  38. package/dist/{kv-cache-Cgj-kpQS.js → kv-cache-BdnmnAVc.js} +1 -1
  39. package/dist/{kv-cache-CY6pDNoS.cjs → kv-cache-DE8kSNQU.cjs} +1 -1
  40. package/dist/{kv-cache-C9IY-FMN.mjs → kv-cache-d8EjO29d.mjs} +1 -1
  41. package/dist/{ld-CqJq5erX.mjs → ld-jyjdrWjG.mjs} +3 -3
  42. package/dist/{metrics-DOqknlZd.mjs → metrics-B5Rei-HC.mjs} +1 -1
  43. package/dist/{middleware-1h_LgwXC.js → middleware-CAObohey.js} +149 -43
  44. package/dist/{middleware-s-AZzx4r.mjs → middleware-CPx4ZWwt.mjs} +155 -53
  45. package/dist/{middleware-VOCZN3SO.mjs → middleware-CdVnCDXD.mjs} +1 -1
  46. package/dist/{mod-Dhm7SqyE.d.ts → mod-C9WSpZWm.d.ts} +1 -1
  47. package/dist/{mod-C0BYc0OU.d.ts → mod-CVZrXSdm.d.ts} +1 -1
  48. package/dist/{mod-BhMvsgdF.d.ts → mod-DMkflQdF.d.ts} +1 -1
  49. package/dist/{mod-Bfenkg_c.d.cts → mod-DTAaBwiY.d.cts} +1 -1
  50. package/dist/{mod-pLbeNwcC.d.cts → mod-HDSvS-ww.d.cts} +1 -1
  51. package/dist/{mod-CyiSjRkk.d.cts → mod-xGFCHqq_.d.cts} +1 -1
  52. package/dist/mod.cjs +18 -18
  53. package/dist/mod.d.cts +7 -7
  54. package/dist/mod.d.ts +7 -7
  55. package/dist/mod.js +5 -5
  56. package/dist/nodeinfo/handler.test.mjs +1 -1
  57. package/dist/owner-1TFakcTF.js +215 -0
  58. package/dist/owner-BXufwAzm.cjs +225 -0
  59. package/dist/{owner-D_F22lfM.mjs → owner-ByqNQVaa.mjs} +45 -2
  60. package/dist/portable-key-Cw_ow5vn.mjs +194 -0
  61. package/dist/{proof-B03JXhrk.mjs → proof-B6gwdhN5.mjs} +5 -5
  62. package/dist/{send-NNkfKtVN.mjs → send-DsK7xevO.mjs} +3 -3
  63. package/dist/sig/compound-proof-discovery.test.mjs +1 -1
  64. package/dist/sig/compound-proof-producer.test.mjs +1 -1
  65. package/dist/sig/compound-proof-verification.test.mjs +2 -2
  66. package/dist/sig/compound-proof.test.mjs +3 -3
  67. package/dist/sig/http.test.mjs +2 -2
  68. package/dist/sig/key.test.mjs +1 -1
  69. package/dist/sig/ld.test.mjs +2 -2
  70. package/dist/sig/mod.cjs +16 -16
  71. package/dist/sig/mod.d.cts +2 -2
  72. package/dist/sig/mod.d.ts +2 -2
  73. package/dist/sig/mod.js +3 -3
  74. package/dist/sig/owner.test.mjs +1 -1
  75. package/dist/sig/portable-collection.test.mjs +3 -3
  76. package/dist/sig/portable-key.test.d.mts +2 -0
  77. package/dist/sig/portable-key.test.mjs +275 -0
  78. package/dist/sig/proof.test.mjs +4 -4
  79. package/dist/{sig-Bb20Pyrd.js → sig-BR_Z6mpY.js} +2 -2
  80. package/dist/{sig-B1E2uyhQ.cjs → sig-TTn9wYrE.cjs} +4 -4
  81. package/dist/{temporal-VVVSuruq.mjs → temporal-Bw5jtrBY.mjs} +1 -1
  82. package/dist/testing/kv.test.mjs +1 -1
  83. package/dist/testing/mod.d.mts +43 -0
  84. package/dist/utils/docloader.test.mjs +2 -2
  85. package/dist/utils/kv-cache.test.mjs +1 -1
  86. package/dist/utils/mod.cjs +1 -1
  87. package/dist/utils/mod.d.cts +1 -1
  88. package/dist/utils/mod.d.ts +1 -1
  89. package/dist/utils/mod.js +1 -1
  90. package/package.json +6 -6
  91. package/dist/http-z5n7chWw.js +0 -2647
  92. package/dist/owner-BLBWXCNt.js +0 -2276
  93. package/dist/owner-D8ZpRusc.cjs +0 -2446
package/dist/mod.d.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  /// <reference lib="esnext.temporal" />
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
- 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-65PYi9jY.js";
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-n2v6DPxu.js";
4
4
  import { i as getKeyOwner, n as GetKeyOwnerOptions, r as doesActorOwnKey, t as DoesActorOwnKeyOptions } from "./owner-BSzr5-I8.js";
5
- import { $ as MessageQueue, A as ObjectCallbackSetters, At as InboxListener, B as TaskDefinitionOptions, Bt as UnverifiedActivityHandler, C as FederationOptions, Ct as CollectionDispatcher, D as InboxChallengePolicy, Dt as HashlinkMediaDispatcher, E as IdempotencyStrategy, Et as CustomCollectionDispatcher, F as FederationQueueOptions, Ft as OutboxErrorHandler, G as RetryContext, Gt as PageItems, H as TaskHandler, Ht as WebFingerLinksDispatcher, I as createFederation, It as OutboxListener, J as RespondWithObjectOptions, Jt as ActivityTransformer, K as RetryPolicy, Kt as buildCollectionSynchronizationHeader, L as Message, Lt as OutboxListenerErrorHandler, M as Rfc6570Expression, Mt as NodeInfoDispatcher, N as FederationKvPrefixes, Nt as ObjectAuthorizePredicate, O as InboxListenerSetters, Ot as HashlinkMediaRequest, P as FederationOrigin, Pt as ObjectDispatcher, Q as InProcessMessageQueueOptions, R as createFederationBuilder, Rt as OutboxPermanentFailureHandler, S as FederationFetchOptions, St as CollectionCursor, T as IdempotencyKeyCallback, Tt as CustomCollectionCursor, U as TaskRegistry, Ut as SendActivityError, V as TaskEnqueueOptions, Vt as UnverifiedActivityReason, W as CreateExponentialBackoffPolicyOptions, Wt as SenderKeyPair, X as respondWithObjectIfAcceptable, Y as respondWithObject, Z as InProcessMessageQueue, _ as CustomCollectionCallbackSetters, _t as ActorDispatcher, a as GetSignedKeyOptions, at as CircuitBreakerActivityDrop, b as FederationBenchmarkOptions, bt as AuthorizePredicate, c as ParseUriResult, ct as CircuitBreakerFailurePolicy, d as RouteActivityOptions, dt as CircuitBreakerState, et as MessageQueueDepth, f as SendActivityOptions, ft as CircuitBreakerStateChange, g as ConstructorWithTypeId, gt as ActorAliasMapper, h as CollectionCallbackSetters, ht as parseCircuitBreakerKvState, i as GetActorOptions, it as CircuitBreaker, j as OutboxListenerSetters, jt as MediaUploaderCallback, k as MediaUploaderSetters, kt as InboxErrorHandler, l as PortableRequest, lt as CircuitBreakerKvState, m as ActorCallbackSetters, mt as normalizeCircuitBreakerOptions, n as Context, nt as MessageQueueListenOptions, o as InboxContext, ot as CircuitBreakerBeforeSendDecision, p as SendActivityOptionsForCollection, pt as NormalizedCircuitBreakerOptions, q as createExponentialBackoffPolicy, qt as digest, r as ForwardActivityOptions, rt as ParallelMessageQueue, s as OutboxContext, st as CircuitBreakerCreateOptions, t as ActorKeyPair, tt as MessageQueueEnqueueOptions, u as RequestContext, ut as CircuitBreakerOptions, v as Federatable, vt as ActorHandleMapper, w as FederationStartQueueOptions, wt as CustomCollectionCounter, x as FederationBuilder, xt as CollectionCounter, y as Federation, yt as ActorKeyPairsDispatcher, z as TaskDefinition, zt as SharedInboxKeyDispatcher } from "./context-D_gg4M0n.js";
5
+ import { $ as MessageQueue, A as ObjectCallbackSetters, At as InboxListener, B as TaskDefinitionOptions, Bt as SharedInboxKeyDispatcher, C as FederationOptions, Ct as CollectionDispatcher, D as InboxChallengePolicy, Dt as HashlinkMediaDispatcher, E as IdempotencyStrategy, Et as CustomCollectionDispatcher, F as FederationQueueOptions, Ft as OutboxErrorHandler, G as RetryContext, Gt as SenderKeyPair, H as TaskHandler, Ht as UnverifiedActivityReason, I as createFederation, It as OutboxListener, J as RespondWithObjectOptions, Jt as digest, K as RetryPolicy, Kt as PageItems, L as Message, Lt as OutboxListenerErrorHandler, M as Rfc6570Expression, Mt as NodeInfoDispatcher, N as FederationKvPrefixes, Nt as ObjectAuthorizePredicate, O as InboxListenerSetters, Ot as HashlinkMediaRequest, P as FederationOrigin, Pt as ObjectDispatcher, Q as InProcessMessageQueueOptions, R as createFederationBuilder, Rt as OutboxPermanentFailureHandler, S as FederationFetchOptions, St as CollectionCursor, T as IdempotencyKeyCallback, Tt as CustomCollectionCursor, U as TaskRegistry, Ut as WebFingerLinksDispatcher, V as TaskEnqueueOptions, Vt as UnverifiedActivityHandler, W as CreateExponentialBackoffPolicyOptions, Wt as SendActivityError, X as respondWithObjectIfAcceptable, Y as respondWithObject, Yt as ActivityTransformer, Z as InProcessMessageQueue, _ as CustomCollectionCallbackSetters, _t as ActorDispatcher, a as GetSignedKeyOptions, at as CircuitBreakerActivityDrop, b as FederationBenchmarkOptions, bt as AuthorizePredicate, c as ParseUriResult, ct as CircuitBreakerFailurePolicy, d as RouteActivityOptions, dt as CircuitBreakerState, et as MessageQueueDepth, f as SendActivityOptions, ft as CircuitBreakerStateChange, g as ConstructorWithTypeId, gt as ActorAliasMapper, h as CollectionCallbackSetters, ht as parseCircuitBreakerKvState, i as GetActorOptions, it as CircuitBreaker, j as OutboxListenerSetters, jt as MediaUploaderCallback, k as MediaUploaderSetters, kt as InboxErrorHandler, l as PortableRequest, lt as CircuitBreakerKvState, m as ActorCallbackSetters, mt as normalizeCircuitBreakerOptions, n as Context, nt as MessageQueueListenOptions, o as InboxContext, ot as CircuitBreakerBeforeSendDecision, p as SendActivityOptionsForCollection, pt as NormalizedCircuitBreakerOptions, q as createExponentialBackoffPolicy, qt as buildCollectionSynchronizationHeader, r as ForwardActivityOptions, rt as ParallelMessageQueue, s as OutboxContext, st as CircuitBreakerCreateOptions, t as ActorKeyPair, tt as MessageQueueEnqueueOptions, u as RequestContext, ut as CircuitBreakerOptions, v as Federatable, vt as ActorHandleMapper, w as FederationStartQueueOptions, wt as CustomCollectionCounter, x as FederationBuilder, xt as CollectionCounter, y as Federation, yt as ActorKeyPairsDispatcher, z as TaskDefinition, zt as PortableActorIdMapper } from "./context-DsB9kF6q.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-BhMvsgdF.js";
9
- import { C as createSignature, D as verifyJsonLd, E as signJsonLd, O as verifySignature, S as attachSignature, T as hasSignatureLike, _ as verifyProof, a as CreateProofOptions, b as VerifyJsonLdOptions, c as VerifyPortableObjectProofFailureReason, d as VerifyProofOptions, f as createProof, g as verifyPortableObjectProof, h as verifyObject, i as verifyPortableObject, l as VerifyPortableObjectProofOptions, m as signObject, n as VerifyPortableObjectOptions, o as SignObjectOptions, p as hasProofLike, r as VerifyPortableObjectResult, s as VerifyObjectOptions, t as VerifyPortableObjectFailureReason, u as VerifyPortableObjectProofResult, v as CreateSignatureOptions, w as detachSignature, x as VerifySignatureOptions, y as SignJsonLdOptions } from "./mod-Dhm7SqyE.js";
10
- import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./mod-C0BYc0OU.js";
8
+ import { a as RouterOptions, i as RouterError, n as handleWebFinger, o as RouterRouteResult, r as Router, t as WebFingerHandlerParameters } from "./mod-DMkflQdF.js";
9
+ import { C as createSignature, D as verifyJsonLd, E as signJsonLd, O as verifySignature, S as attachSignature, T as hasSignatureLike, _ as verifyProof, a as CreateProofOptions, b as VerifyJsonLdOptions, c as VerifyPortableObjectProofFailureReason, d as VerifyProofOptions, f as createProof, g as verifyPortableObjectProof, h as verifyObject, i as verifyPortableObject, l as VerifyPortableObjectProofOptions, m as signObject, n as VerifyPortableObjectOptions, o as SignObjectOptions, p as hasProofLike, r as VerifyPortableObjectResult, s as VerifyObjectOptions, t as VerifyPortableObjectFailureReason, u as VerifyPortableObjectProofResult, v as CreateSignatureOptions, w as detachSignature, x as VerifySignatureOptions, y as SignJsonLdOptions } from "./mod-C9WSpZWm.js";
10
+ import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./mod-CVZrXSdm.js";
11
11
  export * from "@fedify/vocab-runtime";
12
12
 
13
13
  //#region src/mod.d.ts
14
14
  declare namespace mod_d_exports {
15
- export { AcceptSignatureMember, AcceptSignatureParameters, ActivityTransformer, ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CircuitBreaker, CircuitBreakerActivityDrop, CircuitBreakerBeforeSendDecision, CircuitBreakerCreateOptions, CircuitBreakerFailurePolicy, CircuitBreakerKvState, CircuitBreakerOptions, CircuitBreakerState, CircuitBreakerStateChange, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CreateProofOptions, CreateSignatureOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, DoesActorOwnKeyOptions, Federatable, Federation, FederationBenchmarkOptions, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, FetchKeyDetailedResult, FetchKeyErrorResult, FetchKeyOptions, FetchKeyResult, ForwardActivityOptions, FulfillAcceptSignatureResult, GetActorOptions, GetKeyOwnerOptions, GetNodeInfoOptions, GetSignedKeyOptions, HashlinkMediaDispatcher, HashlinkMediaRequest, HttpMessageSignaturesSpec, HttpMessageSignaturesSpecDeterminer, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboundService, InboxChallengePolicy, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, JsonValue, KeyCache, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MediaUploaderCallback, MediaUploaderSetters, MemoryKvStore, Message, MessageQueue, MessageQueueDepth, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfo, NodeInfoDispatcher, NormalizedCircuitBreakerOptions, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboundService, OutboxContext, OutboxErrorHandler, OutboxListener, OutboxListenerErrorHandler, OutboxListenerSetters, OutboxPermanentFailureHandler, PageItems, ParallelMessageQueue, ParseNodeInfoOptions, ParseUriResult, PortableRequest, Protocol, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, Rfc9421SignRequestOptions, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityError, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, Services, SharedInboxKeyDispatcher, SignJsonLdOptions, SignObjectOptions, SignRequestOptions, Software, TaskDefinition, TaskDefinitionOptions, TaskEnqueueOptions, TaskHandler, TaskRegistry, UnverifiedActivityHandler, UnverifiedActivityReason, Usage, VerifyJsonLdOptions, VerifyObjectOptions, VerifyPortableObjectFailureReason, VerifyPortableObjectOptions, VerifyPortableObjectProofFailureReason, VerifyPortableObjectProofOptions, VerifyPortableObjectProofResult, VerifyPortableObjectResult, VerifyProofOptions, VerifyRequestDetailedResult, VerifyRequestFailureReason, VerifyRequestOptions, VerifySignatureOptions, WebFingerHandlerParameters, WebFingerLinksDispatcher, actorDehydrator, attachSignature, autoIdAssigner, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, createProof, createSignature, detachSignature, digest, doesActorOwnKey, exportJwk, fetchKey, fetchKeyDetailed, formatAcceptSignature, fulfillAcceptSignature, generateCryptoKeyPair, getAuthenticatedDocumentLoader, getDefaultActivityTransformers, getKeyOwner, getNodeInfo, handleWebFinger, hasProofLike, hasSignatureLike, importJwk, kvCache, nodeInfoToJson, normalizeCircuitBreakerOptions, parseAcceptSignature, parseCircuitBreakerKvState, parseNodeInfo, respondWithObject, respondWithObjectIfAcceptable, signJsonLd, signObject, signRequest, validateAcceptSignature, verifyJsonLd, verifyObject, verifyPortableObject, verifyPortableObjectProof, verifyProof, verifyRequest, verifyRequestDetailed, verifySignature };
15
+ export { AcceptSignatureMember, AcceptSignatureParameters, ActivityTransformer, ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CircuitBreaker, CircuitBreakerActivityDrop, CircuitBreakerBeforeSendDecision, CircuitBreakerCreateOptions, CircuitBreakerFailurePolicy, CircuitBreakerKvState, CircuitBreakerOptions, CircuitBreakerState, CircuitBreakerStateChange, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CreateProofOptions, CreateSignatureOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, DoesActorOwnKeyOptions, Federatable, Federation, FederationBenchmarkOptions, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, FetchKeyDetailedResult, FetchKeyErrorResult, FetchKeyOptions, FetchKeyResult, ForwardActivityOptions, FulfillAcceptSignatureResult, GetActorOptions, GetKeyOwnerOptions, GetNodeInfoOptions, GetSignedKeyOptions, HashlinkMediaDispatcher, HashlinkMediaRequest, HttpMessageSignaturesSpec, HttpMessageSignaturesSpecDeterminer, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboundService, InboxChallengePolicy, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, JsonValue, KeyCache, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MediaUploaderCallback, MediaUploaderSetters, MemoryKvStore, Message, MessageQueue, MessageQueueDepth, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfo, NodeInfoDispatcher, NormalizedCircuitBreakerOptions, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboundService, OutboxContext, OutboxErrorHandler, OutboxListener, OutboxListenerErrorHandler, OutboxListenerSetters, OutboxPermanentFailureHandler, PageItems, ParallelMessageQueue, ParseNodeInfoOptions, ParseUriResult, PortableActorIdMapper, PortableRequest, Protocol, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, Rfc9421SignRequestOptions, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityError, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, Services, SharedInboxKeyDispatcher, SignJsonLdOptions, SignObjectOptions, SignRequestOptions, Software, TaskDefinition, TaskDefinitionOptions, TaskEnqueueOptions, TaskHandler, TaskRegistry, UnverifiedActivityHandler, UnverifiedActivityReason, Usage, VerifyJsonLdOptions, VerifyObjectOptions, VerifyPortableObjectFailureReason, VerifyPortableObjectOptions, VerifyPortableObjectProofFailureReason, VerifyPortableObjectProofOptions, VerifyPortableObjectProofResult, VerifyPortableObjectResult, VerifyProofOptions, VerifyRequestDetailedResult, VerifyRequestFailureReason, VerifyRequestOptions, VerifySignatureOptions, WebFingerHandlerParameters, WebFingerLinksDispatcher, actorDehydrator, attachSignature, autoIdAssigner, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, createProof, createSignature, detachSignature, digest, doesActorOwnKey, exportJwk, fetchKey, fetchKeyDetailed, formatAcceptSignature, fulfillAcceptSignature, generateCryptoKeyPair, getAuthenticatedDocumentLoader, getDefaultActivityTransformers, getKeyOwner, getNodeInfo, handleWebFinger, hasProofLike, hasSignatureLike, importJwk, kvCache, nodeInfoToJson, normalizeCircuitBreakerOptions, parseAcceptSignature, parseCircuitBreakerKvState, parseNodeInfo, respondWithObject, respondWithObjectIfAcceptable, signJsonLd, signObject, signRequest, validateAcceptSignature, verifyJsonLd, verifyObject, verifyPortableObject, verifyPortableObjectProof, verifyProof, verifyRequest, verifyRequestDetailed, verifySignature };
16
16
  }
17
17
  //#endregion
18
- export { AcceptSignatureMember, AcceptSignatureParameters, ActivityTransformer, ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CircuitBreaker, CircuitBreakerActivityDrop, CircuitBreakerBeforeSendDecision, CircuitBreakerCreateOptions, CircuitBreakerFailurePolicy, CircuitBreakerKvState, CircuitBreakerOptions, CircuitBreakerState, CircuitBreakerStateChange, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CreateProofOptions, CreateSignatureOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, DoesActorOwnKeyOptions, Federatable, Federation, FederationBenchmarkOptions, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, FetchKeyDetailedResult, FetchKeyErrorResult, FetchKeyOptions, FetchKeyResult, ForwardActivityOptions, FulfillAcceptSignatureResult, GetActorOptions, GetKeyOwnerOptions, GetNodeInfoOptions, GetSignedKeyOptions, HashlinkMediaDispatcher, HashlinkMediaRequest, HttpMessageSignaturesSpec, HttpMessageSignaturesSpecDeterminer, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboundService, InboxChallengePolicy, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, JsonValue, KeyCache, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MediaUploaderCallback, MediaUploaderSetters, MemoryKvStore, Message, MessageQueue, MessageQueueDepth, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfo, NodeInfoDispatcher, NormalizedCircuitBreakerOptions, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboundService, OutboxContext, OutboxErrorHandler, OutboxListener, OutboxListenerErrorHandler, OutboxListenerSetters, OutboxPermanentFailureHandler, PageItems, ParallelMessageQueue, ParseNodeInfoOptions, ParseUriResult, PortableRequest, Protocol, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, Rfc9421SignRequestOptions, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityError, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, Services, SharedInboxKeyDispatcher, SignJsonLdOptions, SignObjectOptions, SignRequestOptions, Software, TaskDefinition, TaskDefinitionOptions, TaskEnqueueOptions, TaskHandler, TaskRegistry, UnverifiedActivityHandler, UnverifiedActivityReason, Usage, VerifyJsonLdOptions, VerifyObjectOptions, VerifyPortableObjectFailureReason, VerifyPortableObjectOptions, VerifyPortableObjectProofFailureReason, VerifyPortableObjectProofOptions, VerifyPortableObjectProofResult, VerifyPortableObjectResult, VerifyProofOptions, VerifyRequestDetailedResult, VerifyRequestFailureReason, VerifyRequestOptions, VerifySignatureOptions, WebFingerHandlerParameters, WebFingerLinksDispatcher, actorDehydrator, attachSignature, autoIdAssigner, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, createProof, createSignature, detachSignature, digest, doesActorOwnKey, exportJwk, fetchKey, fetchKeyDetailed, formatAcceptSignature, fulfillAcceptSignature, generateCryptoKeyPair, getAuthenticatedDocumentLoader, getDefaultActivityTransformers, getKeyOwner, getNodeInfo, handleWebFinger, hasProofLike, hasSignatureLike, importJwk, kvCache, nodeInfoToJson, normalizeCircuitBreakerOptions, parseAcceptSignature, parseCircuitBreakerKvState, parseNodeInfo, respondWithObject, respondWithObjectIfAcceptable, signJsonLd, signObject, signRequest, validateAcceptSignature, verifyJsonLd, verifyObject, verifyPortableObject, verifyPortableObjectProof, verifyProof, verifyRequest, verifyRequestDetailed, verifySignature };
18
+ export { AcceptSignatureMember, AcceptSignatureParameters, ActivityTransformer, ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CircuitBreaker, CircuitBreakerActivityDrop, CircuitBreakerBeforeSendDecision, CircuitBreakerCreateOptions, CircuitBreakerFailurePolicy, CircuitBreakerKvState, CircuitBreakerOptions, CircuitBreakerState, CircuitBreakerStateChange, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CreateProofOptions, CreateSignatureOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, DoesActorOwnKeyOptions, Federatable, Federation, FederationBenchmarkOptions, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, FetchKeyDetailedResult, FetchKeyErrorResult, FetchKeyOptions, FetchKeyResult, ForwardActivityOptions, FulfillAcceptSignatureResult, GetActorOptions, GetKeyOwnerOptions, GetNodeInfoOptions, GetSignedKeyOptions, HashlinkMediaDispatcher, HashlinkMediaRequest, HttpMessageSignaturesSpec, HttpMessageSignaturesSpecDeterminer, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboundService, InboxChallengePolicy, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, JsonValue, KeyCache, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MediaUploaderCallback, MediaUploaderSetters, MemoryKvStore, Message, MessageQueue, MessageQueueDepth, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfo, NodeInfoDispatcher, NormalizedCircuitBreakerOptions, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboundService, OutboxContext, OutboxErrorHandler, OutboxListener, OutboxListenerErrorHandler, OutboxListenerSetters, OutboxPermanentFailureHandler, PageItems, ParallelMessageQueue, ParseNodeInfoOptions, ParseUriResult, PortableActorIdMapper, PortableRequest, Protocol, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, Rfc9421SignRequestOptions, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityError, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, Services, SharedInboxKeyDispatcher, SignJsonLdOptions, SignObjectOptions, SignRequestOptions, Software, TaskDefinition, TaskDefinitionOptions, TaskEnqueueOptions, TaskHandler, TaskRegistry, UnverifiedActivityHandler, UnverifiedActivityReason, Usage, VerifyJsonLdOptions, VerifyObjectOptions, VerifyPortableObjectFailureReason, VerifyPortableObjectOptions, VerifyPortableObjectProofFailureReason, VerifyPortableObjectProofOptions, VerifyPortableObjectProofResult, VerifyPortableObjectResult, VerifyProofOptions, VerifyRequestDetailedResult, VerifyRequestFailureReason, VerifyRequestOptions, VerifySignatureOptions, WebFingerHandlerParameters, WebFingerLinksDispatcher, actorDehydrator, attachSignature, autoIdAssigner, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, createProof, createSignature, detachSignature, digest, doesActorOwnKey, exportJwk, fetchKey, fetchKeyDetailed, formatAcceptSignature, fulfillAcceptSignature, generateCryptoKeyPair, getAuthenticatedDocumentLoader, getDefaultActivityTransformers, getKeyOwner, getNodeInfo, handleWebFinger, hasProofLike, hasSignatureLike, importJwk, kvCache, nodeInfoToJson, normalizeCircuitBreakerOptions, parseAcceptSignature, parseCircuitBreakerKvState, parseNodeInfo, respondWithObject, respondWithObjectIfAcceptable, signJsonLd, signObject, signRequest, validateAcceptSignature, verifyJsonLd, verifyObject, verifyPortableObject, verifyPortableObjectProof, verifyProof, verifyRequest, verifyRequestDetailed, verifySignature };
package/dist/mod.js CHANGED
@@ -3,15 +3,15 @@ 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 { F as validateAcceptSignature, M as formatAcceptSignature, N as fulfillAcceptSignature, P as parseAcceptSignature, a as verifyRequestDetailed, c as fetchKey, d as importJwk, i as verifyRequest, l as fetchKeyDetailed, o as exportJwk, r as signRequest, u as generateCryptoKeyPair } from "./http-z5n7chWw.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-1h_LgwXC.js";
6
+ import { A as verifySignature, D as signJsonLd, F as fetchKeyDetailed, I as generateCryptoKeyPair, L as importJwk, M as exportJwk, P as fetchKey, a as verifyRequestDetailed, b as createSignature, c as hasProofLike, d as verifyObject, dt as fulfillAcceptSignature, f as verifyPortableObjectProof, ft as parseAcceptSignature, h as verifyProof, i as verifyRequest, k as verifyJsonLd, l as signObject, pt as validateAcceptSignature, r as signRequest, s as createProof, ut as formatAcceptSignature, v as attachSignature, w as hasSignatureLike, x as detachSignature } from "./http-BoWBwC0g.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-CAObohey.js";
8
8
  import { n as getNodeInfo, r as parseNodeInfo, t as nodeInfoToJson } from "./types-C_cNlNVK.js";
9
- import { C as signJsonLd, E as verifySignature, T as verifyJsonLd, _ as detachSignature, a as signObject, b as hasSignatureLike, c as verifyPortableObjectProof, d as verifyProof, g as createSignature, i as hasProofLike, m as attachSignature, n as getKeyOwner, r as createProof, s as verifyObject, t as doesActorOwnKey } from "./owner-BLBWXCNt.js";
10
- import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-Cgj-kpQS.js";
9
+ import { n as getKeyOwner, t as doesActorOwnKey } from "./owner-1TFakcTF.js";
10
+ import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-BdnmnAVc.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";
14
- import { t as verifyPortableObject } from "./sig-Bb20Pyrd.js";
14
+ import { t as verifyPortableObject } from "./sig-BR_Z6mpY.js";
15
15
  import "./utils/mod.js";
16
16
  export * from "@fedify/vocab-runtime";
17
17
  //#endregion
@@ -5,7 +5,7 @@ import { r as createRequestContext } from "../context-DG5QeQ8W.mjs";
5
5
  import { t as MemoryKvStore } from "../kv-DCHkaJ9-.mjs";
6
6
  import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
7
7
  import "../std__assert-DvMDRPes.mjs";
8
- import { b as handleNodeInfoJrd, o as createFederation, y as handleNodeInfo } from "../middleware-s-AZzx4r.mjs";
8
+ import { b as handleNodeInfoJrd, o as createFederation, y as handleNodeInfo } from "../middleware-CPx4ZWwt.mjs";
9
9
  import { test } from "@fedify/fixture";
10
10
  //#region src/nodeinfo/handler.test.ts
11
11
  test("handleNodeInfo()", async () => {
@@ -0,0 +1,215 @@
1
+ import { Temporal } from "temporal-polyfill";
2
+ import { URLPattern } from "urlpattern-polyfill";
3
+ import { B as getCanonicalPortableId, G as isSamePublicKey$1, M as exportJwk, N as fetchActorDocument, U as isCompatibleKeyId, ht as version, mt as name, o as fetchPortableGatewayKey, z as verifyKeyOwnership } from "./http-BoWBwC0g.js";
4
+ import { getLogger } from "@logtape/logtape";
5
+ import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
6
+ import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
7
+ import { getDocumentLoader } from "@fedify/vocab-runtime";
8
+ //#region src/sig/owner.ts
9
+ const logger = getLogger([
10
+ "fedify",
11
+ "sig",
12
+ "owner"
13
+ ]);
14
+ /**
15
+ * Checks if the actor of the given activity owns the specified key.
16
+ *
17
+ * Ownership is never taken from what the activity or the key say about
18
+ * themselves, as both are written by whoever sent the activity. It is
19
+ * established from a document that the owner itself serves: either the key's
20
+ * claimed owner links back to the key, or the actor the activity claims lists
21
+ * the key as its own.
22
+ *
23
+ * @param activity The activity to check.
24
+ * @param key The public key to check.
25
+ * @param options Options for checking the key ownership.
26
+ * @returns Whether the actor is the owner of the key.
27
+ */
28
+ async function doesActorOwnKey(activity, key, options) {
29
+ return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("activitypub.verify_key_ownership", {
30
+ kind: SpanKind.INTERNAL,
31
+ attributes: {
32
+ "activitypub.actor.id": activity.actorId?.href ?? "",
33
+ "activitypub.key.id": key.id?.href ?? ""
34
+ }
35
+ }, async (span) => {
36
+ try {
37
+ const actorId = activity.actorId;
38
+ if (actorId == null) {
39
+ span.setAttribute("activitypub.key_ownership.verified", false);
40
+ span.setAttribute("activitypub.key_ownership.method", "none");
41
+ return false;
42
+ }
43
+ if (key.id != null && isCompatibleKeyId(key.id)) {
44
+ const owner = await getPortableGatewayKeyOwner(key, options);
45
+ if (owner !== void 0) {
46
+ const ownerId = owner?.id == null ? null : getCanonicalPortableId(owner.id);
47
+ const verified = ownerId != null && ownerId === getCanonicalPortableId(actorId);
48
+ span.setAttribute("activitypub.key_ownership.verified", verified);
49
+ span.setAttribute("activitypub.key_ownership.method", "portable_gateway_key");
50
+ return verified;
51
+ }
52
+ }
53
+ if (key.ownerId != null) {
54
+ const owner = await verifyKeyOwnership(key, options);
55
+ if (owner?.id != null && owner.id.href === actorId.href) {
56
+ span.setAttribute("activitypub.key_ownership.verified", true);
57
+ span.setAttribute("activitypub.key_ownership.method", "key_owner");
58
+ return true;
59
+ }
60
+ }
61
+ const actor = await fetchActorDocument(actorId, options);
62
+ if (actor != null && await doesActorListKey(actor, key, options)) {
63
+ span.setAttribute("activitypub.key_ownership.verified", true);
64
+ span.setAttribute("activitypub.key_ownership.method", "actor_fetch");
65
+ return true;
66
+ }
67
+ logger.debug("The actor {actorId} does not own key {keyId}: neither the owner the key claims nor the actor's own document links the two to each other.", {
68
+ actorId: actorId.href,
69
+ keyId: key.id?.href
70
+ });
71
+ span.setAttribute("activitypub.key_ownership.verified", false);
72
+ span.setAttribute("activitypub.key_ownership.method", "actor_fetch");
73
+ return false;
74
+ } catch (error) {
75
+ span.recordException(error);
76
+ span.setStatus({
77
+ code: SpanStatusCode.ERROR,
78
+ message: String(error)
79
+ });
80
+ throw error;
81
+ } finally {
82
+ span.end();
83
+ }
84
+ });
85
+ }
86
+ /**
87
+ * Determines whether the given actor's own document lists the given key among
88
+ * its public keys.
89
+ *
90
+ * Keys are matched by id, which is what an actor document links to. A key
91
+ * document may leave its id implicit, though, and then there is no id for the
92
+ * actor to link to; the key material itself is the only thing the two can
93
+ * have in common, so that is what gets compared.
94
+ */
95
+ async function doesActorListKey(actor, key, options) {
96
+ if (key.id != null) {
97
+ for (const publicKeyId of actor.publicKeyIds) if (publicKeyId.href === key.id.href) return true;
98
+ return false;
99
+ }
100
+ if (key.publicKey == null) return false;
101
+ const publicKeys = actor.getPublicKeys({
102
+ ...options,
103
+ suppressError: true
104
+ });
105
+ for await (const publicKey of publicKeys) {
106
+ if (publicKey.publicKey == null) continue;
107
+ if (await isSamePublicKey(publicKey.publicKey, key.publicKey)) return true;
108
+ }
109
+ return false;
110
+ }
111
+ /**
112
+ * Compares two public keys by their key material, ignoring the metadata that
113
+ * surrounds it.
114
+ */
115
+ async function isSamePublicKey(a, b) {
116
+ const [x, y] = await Promise.all([exportJwk(a), exportJwk(b)]);
117
+ return x.kty === y.kty && x.crv === y.crv && x.n === y.n && x.e === y.e && x.x === y.x && x.y === y.y;
118
+ }
119
+ /**
120
+ * Gets the actor that owns the specified key. Returns `null` if the key has no
121
+ * known owner.
122
+ *
123
+ * The owner is only returned when the key and the owner link to each other:
124
+ * a document that merely claims to own a key is not enough, as the claim and
125
+ * the key can come from the same host.
126
+ *
127
+ * @param keyId The ID of the key to check, or the key itself.
128
+ * @param options Options for getting the key owner.
129
+ * @returns The actor that owns the key, or `null` if the key has no known
130
+ * owner.
131
+ * @since 0.7.0
132
+ */
133
+ async function getKeyOwner(keyId, options) {
134
+ const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
135
+ const documentLoader = options.documentLoader ?? getDocumentLoader();
136
+ const fetchOptions = {
137
+ documentLoader,
138
+ contextLoader: options.contextLoader ?? getDocumentLoader(),
139
+ tracerProvider
140
+ };
141
+ const id = keyId instanceof CryptographicKey ? keyId.id : keyId;
142
+ if (id != null && isCompatibleKeyId(id)) {
143
+ const owner = await getPortableGatewayKeyOwner(keyId, fetchOptions);
144
+ if (owner !== void 0) return owner;
145
+ }
146
+ if (keyId instanceof CryptographicKey) return await verifyKeyOwnership(keyId, fetchOptions);
147
+ let keyDoc;
148
+ let documentUrl = keyId;
149
+ try {
150
+ const remoteDocument = await documentLoader(keyId.href);
151
+ keyDoc = remoteDocument.document;
152
+ documentUrl = new URL(remoteDocument.documentUrl ?? "", keyId);
153
+ } catch (_) {
154
+ return null;
155
+ }
156
+ let object;
157
+ try {
158
+ object = await Object$1.fromJsonLd(keyDoc, {
159
+ ...fetchOptions,
160
+ baseUrl: documentUrl
161
+ });
162
+ } catch (e) {
163
+ if (!(e instanceof TypeError)) throw e;
164
+ try {
165
+ object = await CryptographicKey.fromJsonLd(keyDoc, fetchOptions);
166
+ } catch (e) {
167
+ if (e instanceof TypeError) return null;
168
+ throw e;
169
+ }
170
+ }
171
+ if (object instanceof CryptographicKey) {
172
+ if (object.id != null && object.id.href !== keyId.href) return null;
173
+ return await verifyKeyOwnership(object.id == null ? object.clone({ id: keyId }) : object, fetchOptions);
174
+ }
175
+ if (!isActor(object)) return null;
176
+ if (object.id == null || object.id.origin !== documentUrl.origin) {
177
+ logger.debug("The document served at {documentUrl} claims to be the actor {actorId}, which belongs to another origin; refusing to treat it as the owner of key {keyId}.", {
178
+ documentUrl: documentUrl.href,
179
+ actorId: object.id?.href,
180
+ keyId: keyId.href
181
+ });
182
+ return null;
183
+ }
184
+ for (const kid of object.publicKeyIds) if (kid.href === keyId.href) return object;
185
+ return null;
186
+ }
187
+ /**
188
+ * Resolves the owner of a key at a compatible identifier, if the key turns
189
+ * out to be a gateway key of an [FEP-ef61] portable actor.
190
+ *
191
+ * [FEP-ef61]: https://w3id.org/fep/ef61
192
+ * @param key The key, or its ID, which must be a compatible identifier.
193
+ * @param options Options for fetching the key.
194
+ * @returns `undefined` if the key is not a gateway key, i.e., the document at
195
+ * the key ID is not a portable actor, so the usual checks apply.
196
+ * Otherwise, the portable actor if its signed document vouches for
197
+ * the key, and the given key, if any, has the same key material, or
198
+ * `null` if not.
199
+ */
200
+ async function getPortableGatewayKeyOwner(key, options) {
201
+ const keyId = key instanceof CryptographicKey ? key.id : key;
202
+ if (keyId == null) return void 0;
203
+ const resolution = await fetchPortableGatewayKey(keyId, options);
204
+ if (resolution.type === "legacy") return void 0;
205
+ if (resolution.type === "rejected") return null;
206
+ if (key instanceof CryptographicKey) {
207
+ if (key.publicKey == null || !await isSamePublicKey$1(key.publicKey, resolution.key.publicKey)) {
208
+ logger.debug("The key {keyId} does not have the same key material as the gateway key its portable actor vouches for.", { keyId: keyId.href });
209
+ return null;
210
+ }
211
+ }
212
+ return resolution.actor;
213
+ }
214
+ //#endregion
215
+ export { getKeyOwner as n, doesActorOwnKey as t };
@@ -0,0 +1,225 @@
1
+ const { URLPattern } = require("urlpattern-polyfill");
2
+ const require_http = require("./http-CuLWIJdf.cjs");
3
+ let _logtape_logtape = require("@logtape/logtape");
4
+ let _fedify_vocab = require("@fedify/vocab");
5
+ let _opentelemetry_api = require("@opentelemetry/api");
6
+ let _fedify_vocab_runtime = require("@fedify/vocab-runtime");
7
+ //#region src/sig/owner.ts
8
+ const logger = (0, _logtape_logtape.getLogger)([
9
+ "fedify",
10
+ "sig",
11
+ "owner"
12
+ ]);
13
+ /**
14
+ * Checks if the actor of the given activity owns the specified key.
15
+ *
16
+ * Ownership is never taken from what the activity or the key say about
17
+ * themselves, as both are written by whoever sent the activity. It is
18
+ * established from a document that the owner itself serves: either the key's
19
+ * claimed owner links back to the key, or the actor the activity claims lists
20
+ * the key as its own.
21
+ *
22
+ * @param activity The activity to check.
23
+ * @param key The public key to check.
24
+ * @param options Options for checking the key ownership.
25
+ * @returns Whether the actor is the owner of the key.
26
+ */
27
+ async function doesActorOwnKey(activity, key, options) {
28
+ return await (options.tracerProvider ?? _opentelemetry_api.trace.getTracerProvider()).getTracer(require_http.name, require_http.version).startActiveSpan("activitypub.verify_key_ownership", {
29
+ kind: _opentelemetry_api.SpanKind.INTERNAL,
30
+ attributes: {
31
+ "activitypub.actor.id": activity.actorId?.href ?? "",
32
+ "activitypub.key.id": key.id?.href ?? ""
33
+ }
34
+ }, async (span) => {
35
+ try {
36
+ const actorId = activity.actorId;
37
+ if (actorId == null) {
38
+ span.setAttribute("activitypub.key_ownership.verified", false);
39
+ span.setAttribute("activitypub.key_ownership.method", "none");
40
+ return false;
41
+ }
42
+ if (key.id != null && require_http.isCompatibleKeyId(key.id)) {
43
+ const owner = await getPortableGatewayKeyOwner(key, options);
44
+ if (owner !== void 0) {
45
+ const ownerId = owner?.id == null ? null : require_http.getCanonicalPortableId(owner.id);
46
+ const verified = ownerId != null && ownerId === require_http.getCanonicalPortableId(actorId);
47
+ span.setAttribute("activitypub.key_ownership.verified", verified);
48
+ span.setAttribute("activitypub.key_ownership.method", "portable_gateway_key");
49
+ return verified;
50
+ }
51
+ }
52
+ if (key.ownerId != null) {
53
+ const owner = await require_http.verifyKeyOwnership(key, options);
54
+ if (owner?.id != null && owner.id.href === actorId.href) {
55
+ span.setAttribute("activitypub.key_ownership.verified", true);
56
+ span.setAttribute("activitypub.key_ownership.method", "key_owner");
57
+ return true;
58
+ }
59
+ }
60
+ const actor = await require_http.fetchActorDocument(actorId, options);
61
+ if (actor != null && await doesActorListKey(actor, key, options)) {
62
+ span.setAttribute("activitypub.key_ownership.verified", true);
63
+ span.setAttribute("activitypub.key_ownership.method", "actor_fetch");
64
+ return true;
65
+ }
66
+ logger.debug("The actor {actorId} does not own key {keyId}: neither the owner the key claims nor the actor's own document links the two to each other.", {
67
+ actorId: actorId.href,
68
+ keyId: key.id?.href
69
+ });
70
+ span.setAttribute("activitypub.key_ownership.verified", false);
71
+ span.setAttribute("activitypub.key_ownership.method", "actor_fetch");
72
+ return false;
73
+ } catch (error) {
74
+ span.recordException(error);
75
+ span.setStatus({
76
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
77
+ message: String(error)
78
+ });
79
+ throw error;
80
+ } finally {
81
+ span.end();
82
+ }
83
+ });
84
+ }
85
+ /**
86
+ * Determines whether the given actor's own document lists the given key among
87
+ * its public keys.
88
+ *
89
+ * Keys are matched by id, which is what an actor document links to. A key
90
+ * document may leave its id implicit, though, and then there is no id for the
91
+ * actor to link to; the key material itself is the only thing the two can
92
+ * have in common, so that is what gets compared.
93
+ */
94
+ async function doesActorListKey(actor, key, options) {
95
+ if (key.id != null) {
96
+ for (const publicKeyId of actor.publicKeyIds) if (publicKeyId.href === key.id.href) return true;
97
+ return false;
98
+ }
99
+ if (key.publicKey == null) return false;
100
+ const publicKeys = actor.getPublicKeys({
101
+ ...options,
102
+ suppressError: true
103
+ });
104
+ for await (const publicKey of publicKeys) {
105
+ if (publicKey.publicKey == null) continue;
106
+ if (await isSamePublicKey(publicKey.publicKey, key.publicKey)) return true;
107
+ }
108
+ return false;
109
+ }
110
+ /**
111
+ * Compares two public keys by their key material, ignoring the metadata that
112
+ * surrounds it.
113
+ */
114
+ async function isSamePublicKey(a, b) {
115
+ const [x, y] = await Promise.all([require_http.exportJwk(a), require_http.exportJwk(b)]);
116
+ return x.kty === y.kty && x.crv === y.crv && x.n === y.n && x.e === y.e && x.x === y.x && x.y === y.y;
117
+ }
118
+ /**
119
+ * Gets the actor that owns the specified key. Returns `null` if the key has no
120
+ * known owner.
121
+ *
122
+ * The owner is only returned when the key and the owner link to each other:
123
+ * a document that merely claims to own a key is not enough, as the claim and
124
+ * the key can come from the same host.
125
+ *
126
+ * @param keyId The ID of the key to check, or the key itself.
127
+ * @param options Options for getting the key owner.
128
+ * @returns The actor that owns the key, or `null` if the key has no known
129
+ * owner.
130
+ * @since 0.7.0
131
+ */
132
+ async function getKeyOwner(keyId, options) {
133
+ const tracerProvider = options.tracerProvider ?? _opentelemetry_api.trace.getTracerProvider();
134
+ const documentLoader = options.documentLoader ?? (0, _fedify_vocab_runtime.getDocumentLoader)();
135
+ const fetchOptions = {
136
+ documentLoader,
137
+ contextLoader: options.contextLoader ?? (0, _fedify_vocab_runtime.getDocumentLoader)(),
138
+ tracerProvider
139
+ };
140
+ const id = keyId instanceof _fedify_vocab.CryptographicKey ? keyId.id : keyId;
141
+ if (id != null && require_http.isCompatibleKeyId(id)) {
142
+ const owner = await getPortableGatewayKeyOwner(keyId, fetchOptions);
143
+ if (owner !== void 0) return owner;
144
+ }
145
+ if (keyId instanceof _fedify_vocab.CryptographicKey) return await require_http.verifyKeyOwnership(keyId, fetchOptions);
146
+ let keyDoc;
147
+ let documentUrl = keyId;
148
+ try {
149
+ const remoteDocument = await documentLoader(keyId.href);
150
+ keyDoc = remoteDocument.document;
151
+ documentUrl = new URL(remoteDocument.documentUrl ?? "", keyId);
152
+ } catch (_) {
153
+ return null;
154
+ }
155
+ let object;
156
+ try {
157
+ object = await _fedify_vocab.Object.fromJsonLd(keyDoc, {
158
+ ...fetchOptions,
159
+ baseUrl: documentUrl
160
+ });
161
+ } catch (e) {
162
+ if (!(e instanceof TypeError)) throw e;
163
+ try {
164
+ object = await _fedify_vocab.CryptographicKey.fromJsonLd(keyDoc, fetchOptions);
165
+ } catch (e) {
166
+ if (e instanceof TypeError) return null;
167
+ throw e;
168
+ }
169
+ }
170
+ if (object instanceof _fedify_vocab.CryptographicKey) {
171
+ if (object.id != null && object.id.href !== keyId.href) return null;
172
+ return await require_http.verifyKeyOwnership(object.id == null ? object.clone({ id: keyId }) : object, fetchOptions);
173
+ }
174
+ if (!(0, _fedify_vocab.isActor)(object)) return null;
175
+ if (object.id == null || object.id.origin !== documentUrl.origin) {
176
+ logger.debug("The document served at {documentUrl} claims to be the actor {actorId}, which belongs to another origin; refusing to treat it as the owner of key {keyId}.", {
177
+ documentUrl: documentUrl.href,
178
+ actorId: object.id?.href,
179
+ keyId: keyId.href
180
+ });
181
+ return null;
182
+ }
183
+ for (const kid of object.publicKeyIds) if (kid.href === keyId.href) return object;
184
+ return null;
185
+ }
186
+ /**
187
+ * Resolves the owner of a key at a compatible identifier, if the key turns
188
+ * out to be a gateway key of an [FEP-ef61] portable actor.
189
+ *
190
+ * [FEP-ef61]: https://w3id.org/fep/ef61
191
+ * @param key The key, or its ID, which must be a compatible identifier.
192
+ * @param options Options for fetching the key.
193
+ * @returns `undefined` if the key is not a gateway key, i.e., the document at
194
+ * the key ID is not a portable actor, so the usual checks apply.
195
+ * Otherwise, the portable actor if its signed document vouches for
196
+ * the key, and the given key, if any, has the same key material, or
197
+ * `null` if not.
198
+ */
199
+ async function getPortableGatewayKeyOwner(key, options) {
200
+ const keyId = key instanceof _fedify_vocab.CryptographicKey ? key.id : key;
201
+ if (keyId == null) return void 0;
202
+ const resolution = await require_http.fetchPortableGatewayKey(keyId, options);
203
+ if (resolution.type === "legacy") return void 0;
204
+ if (resolution.type === "rejected") return null;
205
+ if (key instanceof _fedify_vocab.CryptographicKey) {
206
+ if (key.publicKey == null || !await require_http.isSamePublicKey(key.publicKey, resolution.key.publicKey)) {
207
+ logger.debug("The key {keyId} does not have the same key material as the gateway key its portable actor vouches for.", { keyId: keyId.href });
208
+ return null;
209
+ }
210
+ }
211
+ return resolution.actor;
212
+ }
213
+ //#endregion
214
+ Object.defineProperty(exports, "doesActorOwnKey", {
215
+ enumerable: true,
216
+ get: function() {
217
+ return doesActorOwnKey;
218
+ }
219
+ });
220
+ Object.defineProperty(exports, "getKeyOwner", {
221
+ enumerable: true,
222
+ get: function() {
223
+ return getKeyOwner;
224
+ }
225
+ });
@@ -1,8 +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-BuRFI7wk.mjs";
5
- import { c as verifyKeyOwnership, n as fetchActorDocument, t as exportJwk } from "./key-BxHsA1s9.mjs";
4
+ import { n as version, t as name } from "./deno-B-NtYZVW.mjs";
5
+ import { c as verifyKeyOwnership, f as isCompatibleKeyId, h as isSamePublicKey$1, l as getCanonicalPortableId, n as fetchActorDocument, t as exportJwk } from "./key-lfcx_NaE.mjs";
6
+ import { t as fetchPortableGatewayKey } from "./portable-key-Cw_ow5vn.mjs";
6
7
  import { getLogger } from "@logtape/logtape";
7
8
  import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
8
9
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
@@ -42,6 +43,16 @@ async function doesActorOwnKey(activity, key, options) {
42
43
  span.setAttribute("activitypub.key_ownership.method", "none");
43
44
  return false;
44
45
  }
46
+ if (key.id != null && isCompatibleKeyId(key.id)) {
47
+ const owner = await getPortableGatewayKeyOwner(key, options);
48
+ if (owner !== void 0) {
49
+ const ownerId = owner?.id == null ? null : getCanonicalPortableId(owner.id);
50
+ const verified = ownerId != null && ownerId === getCanonicalPortableId(actorId);
51
+ span.setAttribute("activitypub.key_ownership.verified", verified);
52
+ span.setAttribute("activitypub.key_ownership.method", "portable_gateway_key");
53
+ return verified;
54
+ }
55
+ }
45
56
  if (key.ownerId != null) {
46
57
  const owner = await verifyKeyOwnership(key, options);
47
58
  if (owner?.id != null && owner.id.href === actorId.href) {
@@ -130,6 +141,11 @@ async function getKeyOwner(keyId, options) {
130
141
  contextLoader: options.contextLoader ?? getDocumentLoader(),
131
142
  tracerProvider
132
143
  };
144
+ const id = keyId instanceof CryptographicKey ? keyId.id : keyId;
145
+ if (id != null && isCompatibleKeyId(id)) {
146
+ const owner = await getPortableGatewayKeyOwner(keyId, fetchOptions);
147
+ if (owner !== void 0) return owner;
148
+ }
133
149
  if (keyId instanceof CryptographicKey) return await verifyKeyOwnership(keyId, fetchOptions);
134
150
  let keyDoc;
135
151
  let documentUrl = keyId;
@@ -171,5 +187,32 @@ async function getKeyOwner(keyId, options) {
171
187
  for (const kid of object.publicKeyIds) if (kid.href === keyId.href) return object;
172
188
  return null;
173
189
  }
190
+ /**
191
+ * Resolves the owner of a key at a compatible identifier, if the key turns
192
+ * out to be a gateway key of an [FEP-ef61] portable actor.
193
+ *
194
+ * [FEP-ef61]: https://w3id.org/fep/ef61
195
+ * @param key The key, or its ID, which must be a compatible identifier.
196
+ * @param options Options for fetching the key.
197
+ * @returns `undefined` if the key is not a gateway key, i.e., the document at
198
+ * the key ID is not a portable actor, so the usual checks apply.
199
+ * Otherwise, the portable actor if its signed document vouches for
200
+ * the key, and the given key, if any, has the same key material, or
201
+ * `null` if not.
202
+ */
203
+ async function getPortableGatewayKeyOwner(key, options) {
204
+ const keyId = key instanceof CryptographicKey ? key.id : key;
205
+ if (keyId == null) return void 0;
206
+ const resolution = await fetchPortableGatewayKey(keyId, options);
207
+ if (resolution.type === "legacy") return void 0;
208
+ if (resolution.type === "rejected") return null;
209
+ if (key instanceof CryptographicKey) {
210
+ if (key.publicKey == null || !await isSamePublicKey$1(key.publicKey, resolution.key.publicKey)) {
211
+ logger.debug("The key {keyId} does not have the same key material as the gateway key its portable actor vouches for.", { keyId: keyId.href });
212
+ return null;
213
+ }
214
+ }
215
+ return resolution.actor;
216
+ }
174
217
  //#endregion
175
218
  export { getKeyOwner as n, doesActorOwnKey as t };