@fedify/fedify 2.0.36-dev.2551 → 2.0.36-dev.2637

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/{builder-Dndt590h.mjs → builder-BC3eRIbe.mjs} +3 -3
  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/{context-lxjaUTAI.d.ts → context-C00pWP8x.d.ts} +6 -0
  6. package/dist/{context-CnoWxuoB.d.cts → context-ao-qb3eP.d.cts} +6 -0
  7. package/dist/{deno-D_rTMbAD.mjs → deno-Dv6PIwH_.mjs} +1 -1
  8. package/dist/{docloader-DpTrZ5sA.mjs → docloader-BgHM-JLc.mjs} +2 -2
  9. package/dist/federation/builder.test.mjs +1 -1
  10. package/dist/federation/handler.test.mjs +8 -8
  11. package/dist/federation/idempotency.test.mjs +2 -2
  12. package/dist/federation/inbox.test.mjs +1 -1
  13. package/dist/federation/middleware.test.mjs +696 -8
  14. package/dist/federation/mod.cjs +1 -1
  15. package/dist/federation/mod.d.cts +2 -2
  16. package/dist/federation/mod.d.ts +2 -2
  17. package/dist/federation/mod.js +1 -1
  18. package/dist/federation/send.test.mjs +3 -3
  19. package/dist/federation/temporal.test.mjs +1 -1
  20. package/dist/federation/webfinger.test.mjs +1 -1
  21. package/dist/{http-DGD9d8-A.mjs → http-BWoAqky4.mjs} +2 -2
  22. package/dist/{http-BS1CmlZ6.js → http-CrEB4I8A.js} +1 -1
  23. package/dist/{http-DbDnj-Q7.cjs → http-D69BMfAn.cjs} +1 -1
  24. package/dist/{inbox-BwpBTbhH.mjs → inbox-0Dbv0QVc.mjs} +1 -1
  25. package/dist/{key-1Gf85RN1.mjs → key-ChKDZfvS.mjs} +1 -1
  26. package/dist/{kv-cache-BdA7HpfF.cjs → kv-cache-B0JZ30EF.cjs} +1 -1
  27. package/dist/{kv-cache-BARiicPE.js → kv-cache-CDvE8__9.js} +1 -1
  28. package/dist/{ld-BuuOR_Ms.mjs → ld-DbSNiv8Q.mjs} +99 -10
  29. package/dist/{middleware-C5Nypx4Z.mjs → middleware-BA9cM-vz.mjs} +1 -1
  30. package/dist/{middleware-DDM0j-X6.mjs → middleware-C849kmHB.mjs} +160 -29
  31. package/dist/{middleware-CQRCnFB4.js → middleware-CEufJR5k.js} +152 -21
  32. package/dist/{middleware-DThg01d8.cjs → middleware-C_fDk_dx.cjs} +153 -22
  33. package/dist/{middleware-D9TWYyT_.cjs → middleware-DCtCNota.cjs} +1 -1
  34. package/dist/{mod-w1oyHseQ.d.cts → mod-6uJWdCc0.d.cts} +1 -1
  35. package/dist/{mod-DVPS4yam.d.cts → mod-BA6vqC2S.d.cts} +19 -7
  36. package/dist/{mod-BS-jg3Wx.d.ts → mod-CL9Ep0uo.d.ts} +19 -7
  37. package/dist/{mod-I-34OMN3.d.ts → mod-DtRh015i.d.ts} +1 -1
  38. package/dist/mod.cjs +4 -4
  39. package/dist/mod.d.cts +3 -3
  40. package/dist/mod.d.ts +3 -3
  41. package/dist/mod.js +4 -4
  42. package/dist/nodeinfo/handler.test.mjs +1 -1
  43. package/dist/{owner-BI33UeIv.mjs → owner-BJeJfxnT.mjs} +2 -2
  44. package/dist/{proof-GM73LJjx.mjs → proof-CaMBdk_x.mjs} +36 -12
  45. package/dist/{proof-vVwkNRv4.cjs → proof-DNgQwz9E.cjs} +131 -18
  46. package/dist/{proof-BBHUW8ev.js → proof-DwooE8kV.js} +132 -19
  47. package/dist/{send-nImUK91D.mjs → send-CYrAOC1K.mjs} +2 -2
  48. package/dist/sig/http.test.mjs +2 -2
  49. package/dist/sig/key.test.mjs +2 -2
  50. package/dist/sig/ld.test.mjs +198 -4
  51. package/dist/sig/mod.cjs +2 -2
  52. package/dist/sig/mod.d.cts +1 -1
  53. package/dist/sig/mod.d.ts +1 -1
  54. package/dist/sig/mod.js +2 -2
  55. package/dist/sig/owner.test.mjs +1 -1
  56. package/dist/sig/proof.test.mjs +71 -2
  57. package/dist/{temporal-CfNFB7M_.mjs → temporal-BJoGKOXy.mjs} +1 -1
  58. package/dist/utils/docloader.test.mjs +2 -2
  59. package/dist/utils/mod.cjs +1 -1
  60. package/dist/utils/mod.js +1 -1
  61. package/package.json +5 -5
@@ -2,7 +2,7 @@ const { Temporal } = require("@js-temporal/polyfill");
2
2
  const { URLPattern } = require("urlpattern-polyfill");
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  require("../chunk-DDcVe30Y.cjs");
5
- const require_middleware = require("../middleware-DThg01d8.cjs");
5
+ const require_middleware = require("../middleware-C_fDk_dx.cjs");
6
6
  let es_toolkit = require("es-toolkit");
7
7
  //#region src/federation/kv.ts
8
8
  /**
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { $ as AuthorizePredicate, A as CreateExponentialBackoffPolicyOptions, B as RespondWithObjectOptions, C as InboxListenerSetters, D as FederationOrigin, E as FederationKvPrefixes, F as createFederationBuilder, G as MessageQueue, H as respondWithObjectIfAcceptable, I as Router, J as ParallelMessageQueue, K as MessageQueueEnqueueOptions, L as RouterError, M as RetryPolicy, N as createExponentialBackoffPolicy, O as FederationQueueOptions, P as Message, Q as ActorKeyPairsDispatcher, R as RouterOptions, S as IdempotencyStrategy, T as Rfc6570Expression, U as InProcessMessageQueue, V as respondWithObject, W as InProcessMessageQueueOptions, X as ActorDispatcher, Y as ActorAliasMapper, Z as ActorHandleMapper, _ as FederationBuilder, _t as PageItems, a as InboxContext, at as CustomCollectionDispatcher, b as FederationStartQueueOptions, c as RouteActivityOptions, ct as NodeInfoDispatcher, d as ActorCallbackSetters, dt as OutboxErrorHandler, et as CollectionCounter, f as CollectionCallbackSetters, ft as OutboxPermanentFailureHandler, g as Federation, gt as SenderKeyPair, h as Federatable, ht as SendActivityError, i as GetSignedKeyOptions, it as CustomCollectionCursor, j as RetryContext, k as createFederation, l as SendActivityOptions, lt as ObjectAuthorizePredicate, m as CustomCollectionCallbackSetters, mt as WebFingerLinksDispatcher, n as Context, nt as CollectionDispatcher, o as ParseUriResult, ot as InboxErrorHandler, p as ConstructorWithTypeId, pt as SharedInboxKeyDispatcher, q as MessageQueueListenOptions, r as ForwardActivityOptions, rt as CustomCollectionCounter, s as RequestContext, st as InboxListener, t as ActorKeyPair, tt as CollectionCursor, u as SendActivityOptionsForCollection, ut as ObjectDispatcher, v as FederationFetchOptions, vt as buildCollectionSynchronizationHeader, w as ObjectCallbackSetters, x as IdempotencyKeyCallback, y as FederationOptions, yt as digest, z as RouterRouteResult } from "../context-CnoWxuoB.cjs";
2
+ import { $ as AuthorizePredicate, A as CreateExponentialBackoffPolicyOptions, B as RespondWithObjectOptions, C as InboxListenerSetters, D as FederationOrigin, E as FederationKvPrefixes, F as createFederationBuilder, G as MessageQueue, H as respondWithObjectIfAcceptable, I as Router, J as ParallelMessageQueue, K as MessageQueueEnqueueOptions, L as RouterError, M as RetryPolicy, N as createExponentialBackoffPolicy, O as FederationQueueOptions, P as Message, Q as ActorKeyPairsDispatcher, R as RouterOptions, S as IdempotencyStrategy, T as Rfc6570Expression, U as InProcessMessageQueue, V as respondWithObject, W as InProcessMessageQueueOptions, X as ActorDispatcher, Y as ActorAliasMapper, Z as ActorHandleMapper, _ as FederationBuilder, _t as PageItems, a as InboxContext, at as CustomCollectionDispatcher, b as FederationStartQueueOptions, c as RouteActivityOptions, ct as NodeInfoDispatcher, d as ActorCallbackSetters, dt as OutboxErrorHandler, et as CollectionCounter, f as CollectionCallbackSetters, ft as OutboxPermanentFailureHandler, g as Federation, gt as SenderKeyPair, h as Federatable, ht as SendActivityError, i as GetSignedKeyOptions, it as CustomCollectionCursor, j as RetryContext, k as createFederation, l as SendActivityOptions, lt as ObjectAuthorizePredicate, m as CustomCollectionCallbackSetters, mt as WebFingerLinksDispatcher, n as Context, nt as CollectionDispatcher, o as ParseUriResult, ot as InboxErrorHandler, p as ConstructorWithTypeId, pt as SharedInboxKeyDispatcher, q as MessageQueueListenOptions, r as ForwardActivityOptions, rt as CustomCollectionCounter, s as RequestContext, st as InboxListener, t as ActorKeyPair, tt as CollectionCursor, u as SendActivityOptionsForCollection, ut as ObjectDispatcher, v as FederationFetchOptions, vt as buildCollectionSynchronizationHeader, w as ObjectCallbackSetters, x as IdempotencyKeyCallback, y as FederationOptions, yt as digest, z as RouterRouteResult } from "../context-ao-qb3eP.cjs";
3
3
  import { a as MemoryKvStore, i as KvStoreSetOptions, n as KvStore, r as KvStoreListEntry, t as KvKey } from "../kv-CZKl1IUS.cjs";
4
- import { n as handleWebFinger, t as WebFingerHandlerParameters } from "../mod-w1oyHseQ.cjs";
4
+ import { n as handleWebFinger, t as WebFingerHandlerParameters } from "../mod-6uJWdCc0.cjs";
5
5
  export { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore, Message, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxErrorHandler, OutboxPermanentFailureHandler, PageItems, ParallelMessageQueue, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityError, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, WebFingerHandlerParameters, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, handleWebFinger, respondWithObject, respondWithObjectIfAcceptable };
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { $ as AuthorizePredicate, A as CreateExponentialBackoffPolicyOptions, B as RespondWithObjectOptions, C as InboxListenerSetters, D as FederationOrigin, E as FederationKvPrefixes, F as createFederationBuilder, G as MessageQueue, H as respondWithObjectIfAcceptable, I as Router, J as ParallelMessageQueue, K as MessageQueueEnqueueOptions, L as RouterError, M as RetryPolicy, N as createExponentialBackoffPolicy, O as FederationQueueOptions, P as Message, Q as ActorKeyPairsDispatcher, R as RouterOptions, S as IdempotencyStrategy, T as Rfc6570Expression, U as InProcessMessageQueue, V as respondWithObject, W as InProcessMessageQueueOptions, X as ActorDispatcher, Y as ActorAliasMapper, Z as ActorHandleMapper, _ as FederationBuilder, _t as PageItems, a as InboxContext, at as CustomCollectionDispatcher, b as FederationStartQueueOptions, c as RouteActivityOptions, ct as NodeInfoDispatcher, d as ActorCallbackSetters, dt as OutboxErrorHandler, et as CollectionCounter, f as CollectionCallbackSetters, ft as OutboxPermanentFailureHandler, g as Federation, gt as SenderKeyPair, h as Federatable, ht as SendActivityError, i as GetSignedKeyOptions, it as CustomCollectionCursor, j as RetryContext, k as createFederation, l as SendActivityOptions, lt as ObjectAuthorizePredicate, m as CustomCollectionCallbackSetters, mt as WebFingerLinksDispatcher, n as Context, nt as CollectionDispatcher, o as ParseUriResult, ot as InboxErrorHandler, p as ConstructorWithTypeId, pt as SharedInboxKeyDispatcher, q as MessageQueueListenOptions, r as ForwardActivityOptions, rt as CustomCollectionCounter, s as RequestContext, st as InboxListener, t as ActorKeyPair, tt as CollectionCursor, u as SendActivityOptionsForCollection, ut as ObjectDispatcher, v as FederationFetchOptions, vt as buildCollectionSynchronizationHeader, w as ObjectCallbackSetters, x as IdempotencyKeyCallback, y as FederationOptions, yt as digest, z as RouterRouteResult } from "../context-lxjaUTAI.js";
2
+ import { $ as AuthorizePredicate, A as CreateExponentialBackoffPolicyOptions, B as RespondWithObjectOptions, C as InboxListenerSetters, D as FederationOrigin, E as FederationKvPrefixes, F as createFederationBuilder, G as MessageQueue, H as respondWithObjectIfAcceptable, I as Router, J as ParallelMessageQueue, K as MessageQueueEnqueueOptions, L as RouterError, M as RetryPolicy, N as createExponentialBackoffPolicy, O as FederationQueueOptions, P as Message, Q as ActorKeyPairsDispatcher, R as RouterOptions, S as IdempotencyStrategy, T as Rfc6570Expression, U as InProcessMessageQueue, V as respondWithObject, W as InProcessMessageQueueOptions, X as ActorDispatcher, Y as ActorAliasMapper, Z as ActorHandleMapper, _ as FederationBuilder, _t as PageItems, a as InboxContext, at as CustomCollectionDispatcher, b as FederationStartQueueOptions, c as RouteActivityOptions, ct as NodeInfoDispatcher, d as ActorCallbackSetters, dt as OutboxErrorHandler, et as CollectionCounter, f as CollectionCallbackSetters, ft as OutboxPermanentFailureHandler, g as Federation, gt as SenderKeyPair, h as Federatable, ht as SendActivityError, i as GetSignedKeyOptions, it as CustomCollectionCursor, j as RetryContext, k as createFederation, l as SendActivityOptions, lt as ObjectAuthorizePredicate, m as CustomCollectionCallbackSetters, mt as WebFingerLinksDispatcher, n as Context, nt as CollectionDispatcher, o as ParseUriResult, ot as InboxErrorHandler, p as ConstructorWithTypeId, pt as SharedInboxKeyDispatcher, q as MessageQueueListenOptions, r as ForwardActivityOptions, rt as CustomCollectionCounter, s as RequestContext, st as InboxListener, t as ActorKeyPair, tt as CollectionCursor, u as SendActivityOptionsForCollection, ut as ObjectDispatcher, v as FederationFetchOptions, vt as buildCollectionSynchronizationHeader, w as ObjectCallbackSetters, x as IdempotencyKeyCallback, y as FederationOptions, yt as digest, z as RouterRouteResult } from "../context-C00pWP8x.js";
3
3
  import { a as MemoryKvStore, i as KvStoreSetOptions, n as KvStore, r as KvStoreListEntry, t as KvKey } from "../kv-CxaI4eGo.js";
4
- import { n as handleWebFinger, t as WebFingerHandlerParameters } from "../mod-I-34OMN3.js";
4
+ import { n as handleWebFinger, t as WebFingerHandlerParameters } from "../mod-DtRh015i.js";
5
5
  export { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore, Message, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxErrorHandler, OutboxPermanentFailureHandler, PageItems, ParallelMessageQueue, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityError, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, WebFingerHandlerParameters, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, handleWebFinger, respondWithObject, respondWithObjectIfAcceptable };
@@ -1,6 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { a as createExponentialBackoffPolicy, c as buildCollectionSynchronizationHeader, d as Router, f as RouterError, i as SendActivityError, l as digest, o as respondWithObject, r as handleWebFinger, s as respondWithObjectIfAcceptable, t as createFederation, u as createFederationBuilder } from "../middleware-CQRCnFB4.js";
3
+ import { a as createExponentialBackoffPolicy, c as buildCollectionSynchronizationHeader, d as Router, f as RouterError, i as SendActivityError, l as digest, o as respondWithObject, r as handleWebFinger, s as respondWithObjectIfAcceptable, t as createFederation, u as createFederationBuilder } from "../middleware-CEufJR5k.js";
4
4
  import { isEqual } from "es-toolkit";
5
5
  //#region src/federation/kv.ts
6
6
  /**
@@ -8,10 +8,10 @@ import { r as assertFalse } from "../assert_throws-D4DNWrux.mjs";
8
8
  import { n as assertInstanceOf, t as assert } from "../assert-BhQd8QHP.mjs";
9
9
  import { t as assertNotEquals } from "../assert_not_equals-BkxW5QJI.mjs";
10
10
  import { t as assertRejects } from "../assert_rejects-WyYSTDDX.mjs";
11
- import { u as verifyRequest } from "../http-DGD9d8-A.mjs";
11
+ import { u as verifyRequest } from "../http-BWoAqky4.mjs";
12
12
  import { i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-CCxRJhWa.mjs";
13
- import { t as doesActorOwnKey } from "../owner-BI33UeIv.mjs";
14
- import { i as sendActivity, n as extractInboxes, r as fetchWithValidatedRedirects, t as SendActivityError } from "../send-nImUK91D.mjs";
13
+ import { t as doesActorOwnKey } from "../owner-BJeJfxnT.mjs";
14
+ import { i as sendActivity, n as extractInboxes, r as fetchWithValidatedRedirects, t as SendActivityError } from "../send-CYrAOC1K.mjs";
15
15
  import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
16
16
  import { Activity, Application, Endpoints, Group, Person, Service } from "@fedify/vocab";
17
17
  import { FetchError, UrlError } from "@fedify/vocab-runtime";
@@ -4,7 +4,7 @@ globalThis.addEventListener = () => {};
4
4
  import "../std__assert-DflMZha5.mjs";
5
5
  import { r as assertFalse } from "../assert_throws-D4DNWrux.mjs";
6
6
  import { t as assert } from "../assert-BhQd8QHP.mjs";
7
- import { t as hasMalformedKnownTemporalLiteral } from "../temporal-CfNFB7M_.mjs";
7
+ import { t as hasMalformedKnownTemporalLiteral } from "../temporal-BJoGKOXy.mjs";
8
8
  import { test } from "@fedify/fixture";
9
9
  //#region src/federation/temporal.test.ts
10
10
  test("hasMalformedKnownTemporalLiteral() detects expanded proof timestamps", async () => {
@@ -5,7 +5,7 @@ import { n as createRequestContext } from "../context-Juj6bdHC.mjs";
5
5
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
6
  import "../std__assert-DflMZha5.mjs";
7
7
  import { t as MemoryKvStore } from "../kv-mI4Ix2EU.mjs";
8
- import { a as createFederation, o as handleWebFinger } from "../middleware-DDM0j-X6.mjs";
8
+ import { a as createFederation, o as handleWebFinger } from "../middleware-C849kmHB.mjs";
9
9
  import { test } from "@fedify/fixture";
10
10
  import { Image, Link, Person } from "@fedify/vocab";
11
11
  //#region src/federation/webfinger.test.ts
@@ -1,8 +1,8 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-D_rTMbAD.mjs";
5
- import { o as validateCryptoKey, r as fetchKey } from "./key-1Gf85RN1.mjs";
4
+ import { n as version, t as name } from "./deno-Dv6PIwH_.mjs";
5
+ import { o as validateCryptoKey, r as fetchKey } from "./key-ChKDZfvS.mjs";
6
6
  import { CryptographicKey } from "@fedify/vocab";
7
7
  import { SpanStatusCode, trace } from "@opentelemetry/api";
8
8
  import { FetchError } from "@fedify/vocab-runtime";
@@ -10,7 +10,7 @@ import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
10
10
  import { Item, decodeDict, encodeItem } from "structured-field-values";
11
11
  //#region deno.json
12
12
  var name = "@fedify/fedify";
13
- var version = "2.0.36-dev.2551+8b012df4";
13
+ var version = "2.0.36-dev.2637+cc2cd6fb";
14
14
  //#endregion
15
15
  //#region src/sig/key.ts
16
16
  /** Classifies decoding failures without hiding unexpected loader errors. */
@@ -11,7 +11,7 @@ let byte_encodings_base64 = require("byte-encodings/base64");
11
11
  let structured_field_values = require("structured-field-values");
12
12
  //#region deno.json
13
13
  var name = "@fedify/fedify";
14
- var version = "2.0.36-dev.2551+8b012df4";
14
+ var version = "2.0.36-dev.2637+cc2cd6fb";
15
15
  //#endregion
16
16
  //#region src/sig/key.ts
17
17
  /** Classifies decoding failures without hiding unexpected loader errors. */
@@ -1,7 +1,7 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-D_rTMbAD.mjs";
4
+ import { n as version, t as name } from "./deno-Dv6PIwH_.mjs";
5
5
  import { Activity, getTypeId } from "@fedify/vocab";
6
6
  import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
7
7
  import { getLogger } from "@logtape/logtape";
@@ -1,7 +1,7 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-D_rTMbAD.mjs";
4
+ import { n as version, t as name } from "./deno-Dv6PIwH_.mjs";
5
5
  import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
6
6
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
7
7
  import { FetchError, UrlError, getDocumentLoader } from "@fedify/vocab-runtime";
@@ -1,7 +1,7 @@
1
1
  const { Temporal } = require("@js-temporal/polyfill");
2
2
  const { URLPattern } = require("urlpattern-polyfill");
3
3
  require("./chunk-DDcVe30Y.cjs");
4
- const require_http = require("./http-DbDnj-Q7.cjs");
4
+ const require_http = require("./http-D69BMfAn.cjs");
5
5
  let _logtape_logtape = require("@logtape/logtape");
6
6
  let es_toolkit = require("es-toolkit");
7
7
  let _fedify_vocab_runtime = require("@fedify/vocab-runtime");
@@ -1,6 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { l as validateCryptoKey, t as doubleKnockScoped } from "./http-BS1CmlZ6.js";
3
+ import { l as validateCryptoKey, t as doubleKnockScoped } from "./http-CrEB4I8A.js";
4
4
  import { getLogger } from "@logtape/logtape";
5
5
  import { curry } from "es-toolkit";
6
6
  import { FetchError, UrlError, createActivityPubRequest, getRemoteDocument, logRequest, preloadedContexts } from "@fedify/vocab-runtime";
@@ -1,11 +1,11 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-D_rTMbAD.mjs";
5
- import { o as validateCryptoKey, r as fetchKey } from "./key-1Gf85RN1.mjs";
4
+ import { n as version, t as name } from "./deno-Dv6PIwH_.mjs";
5
+ import { o as validateCryptoKey, r as fetchKey } from "./key-ChKDZfvS.mjs";
6
6
  import { Activity, CryptographicKey, Object as Object$1, getTypeId } from "@fedify/vocab";
7
7
  import { SpanStatusCode, trace } from "@opentelemetry/api";
8
- import { getDocumentLoader } from "@fedify/vocab-runtime";
8
+ import { getDocumentLoader, preloadedContexts } from "@fedify/vocab-runtime";
9
9
  import { getLogger } from "@logtape/logtape";
10
10
  import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
11
11
  import { encodeHex } from "byte-encodings/hex";
@@ -298,24 +298,110 @@ function assertSafeJsonLd(jsonLd) {
298
298
  }
299
299
  }
300
300
  }
301
+ const signatureTermDefinition = { "signature": "https://w3id.org/security#signature" };
302
+ const signatureDefiningContexts = new Set(["https://w3id.org/identity/v1", "https://w3id.org/security/v1"]);
303
+ const signatureFreeContexts = getSignatureFreeContexts();
304
+ function getSignatureFreeContexts() {
305
+ const urls = /* @__PURE__ */ new Set();
306
+ for (const [url, document] of globalThis.Object.entries(preloadedContexts)) {
307
+ if (typeof document !== "object" || document == null) continue;
308
+ const context = document["@context"];
309
+ if (typeof context !== "object" || context == null || Array.isArray(context)) continue;
310
+ const record = context;
311
+ if (!globalThis.Object.prototype.hasOwnProperty.call(record, "signature")) urls.add(url);
312
+ }
313
+ return urls;
314
+ }
315
+ function getContextEntryEffect(entry) {
316
+ if (entry == null) return "resets";
317
+ if (typeof entry === "string") {
318
+ if (signatureDefiningContexts.has(entry)) return "defines";
319
+ if (signatureFreeContexts.has(entry)) return "absent";
320
+ return "unknown";
321
+ }
322
+ if (typeof entry !== "object") return "absent";
323
+ const record = entry;
324
+ if (globalThis.Object.prototype.hasOwnProperty.call(record, "signature")) {
325
+ const definition = record["signature"];
326
+ const contextProtected = record["@protected"] === true;
327
+ const imported = globalThis.Object.prototype.hasOwnProperty.call(record, "@import");
328
+ if (definition == null) {
329
+ if (contextProtected) return "defines";
330
+ return imported ? "unknown" : "resets";
331
+ }
332
+ if (typeof definition === "object" && !Array.isArray(definition)) {
333
+ const term = definition;
334
+ const protectedTerm = contextProtected || term["@protected"] === true;
335
+ if (globalThis.Object.prototype.hasOwnProperty.call(term, "@id") && term["@id"] == null) {
336
+ if (protectedTerm) return "defines";
337
+ return imported ? "unknown" : "resets";
338
+ }
339
+ }
340
+ return "defines";
341
+ }
342
+ if (globalThis.Object.prototype.hasOwnProperty.call(record, "@import")) return "unknown";
343
+ return "absent";
344
+ }
345
+ function getSignatureTermState(context) {
346
+ if (context == null) return "absent";
347
+ if (!Array.isArray(context)) {
348
+ const effect = getContextEntryEffect(context);
349
+ return effect === "defines" ? "defined" : effect === "unknown" ? "unknown" : "absent";
350
+ }
351
+ let state = "absent";
352
+ for (const entry of context) {
353
+ const effect = getContextEntryEffect(entry);
354
+ if (effect === "defines") state = "defined";
355
+ else if (effect === "resets") state = "absent";
356
+ else if (effect === "unknown" && state !== "defined") state = "unknown";
357
+ }
358
+ return state;
359
+ }
360
+ function prepareSignatureDocument(jsonLd) {
361
+ if (typeof jsonLd !== "object" || jsonLd == null || Array.isArray(jsonLd)) return jsonLd;
362
+ const document = jsonLd;
363
+ if (document["proof"] != null) return { ...document };
364
+ const context = document["@context"];
365
+ if (getSignatureTermState(context) !== "absent") return { ...document };
366
+ const definition = { ...signatureTermDefinition };
367
+ return {
368
+ ...document,
369
+ "@context": context == null ? [definition] : Array.isArray(context) ? [...context, definition] : [context, definition]
370
+ };
371
+ }
301
372
  /**
302
373
  * Attaches a LD signature to the given JSON-LD document.
374
+ *
375
+ * When the document's context does not already define the `signature`
376
+ * property, the returned document adds a minimal inline context for it.
377
+ * Without that definition, expanding the attached signature would produce a
378
+ * blank node predicate, which is not valid RDF. Documents that already carry
379
+ * a `proof` are left unchanged, since a new context definition would invalidate
380
+ * the proof. Documents whose context includes an unrecognized remote context
381
+ * are also left unchanged, since that context may already define `signature`.
303
382
  * @param jsonLd The JSON-LD document to attach the signature to. It is not
304
383
  * modified.
305
384
  * @param signature The signature to attach.
306
385
  * @returns The JSON-LD document with the attached signature.
307
386
  * @throws {TypeError} If the input document is not a valid JSON-LD document.
387
+ * Top-level arrays are rejected, since a Linked Data
388
+ * Signature is attached to a single node.
308
389
  * @since 1.0.0
309
390
  */
310
391
  function attachSignature(jsonLd, signature) {
311
- if (typeof jsonLd !== "object" || jsonLd == null) throw new TypeError("Failed to attach signature; invalid JSON-LD document.");
312
- return {
313
- ...jsonLd,
314
- signature
315
- };
392
+ if (typeof jsonLd !== "object" || jsonLd == null || Array.isArray(jsonLd)) throw new TypeError("Failed to attach signature; invalid JSON-LD document.");
393
+ const output = prepareSignatureDocument(jsonLd);
394
+ output.signature = signature;
395
+ return output;
316
396
  }
317
397
  /**
318
398
  * Creates a LD signature for the given JSON-LD document.
399
+ *
400
+ * If the document's context does not define the `signature` property, the
401
+ * signature is computed over the document with a minimal inline definition
402
+ * added. Use {@link attachSignature} to attach the signature to that exact
403
+ * document. Documents that already carry a `proof`, or whose context includes
404
+ * an unrecognized remote context, are hashed unchanged.
319
405
  * @param jsonLd The JSON-LD document to sign.
320
406
  * @param privateKey The private key to sign the document.
321
407
  * @param keyId The ID of the public key that corresponds to the private key.
@@ -329,14 +415,17 @@ async function createSignature(jsonLd, privateKey, keyId, { contextLoader, creat
329
415
  validateCryptoKey(privateKey, "private");
330
416
  if (privateKey.algorithm.name !== "RSASSA-PKCS1-v1_5") throw new TypeError("Unsupported algorithm: " + privateKey.algorithm.name);
331
417
  const options = {
332
- "@context": "https://w3id.org/identity/v1",
333
418
  creator: keyId.href,
334
419
  created: created?.toString() ?? (/* @__PURE__ */ new Date()).toISOString()
335
420
  };
336
- const message = await hashJsonLd(options, contextLoader) + await hashJsonLd(jsonLd, contextLoader);
421
+ const message = await hashJsonLd({
422
+ "@context": "https://w3id.org/identity/v1",
423
+ ...options
424
+ }, contextLoader) + await hashJsonLd(prepareSignatureDocument(jsonLd), contextLoader);
337
425
  const messageBytes = new TextEncoder().encode(message);
338
426
  const signature = await crypto.subtle.sign("RSASSA-PKCS1-v1_5", privateKey, messageBytes);
339
427
  return {
428
+ "@context": "https://w3id.org/security/v1",
340
429
  ...options,
341
430
  type: "RsaSignature2017",
342
431
  signatureValue: encodeBase64(signature)
@@ -1,5 +1,5 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as FederationImpl } from "./middleware-DDM0j-X6.mjs";
4
+ import { n as FederationImpl } from "./middleware-C849kmHB.mjs";
5
5
  export { FederationImpl };
@@ -2,24 +2,24 @@ import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { n as RouterError } from "./router-CrMLXoOr.mjs";
5
- import { n as version, t as name } from "./deno-D_rTMbAD.mjs";
6
- import { a as importJwk, o as validateCryptoKey, t as exportJwk } from "./key-1Gf85RN1.mjs";
7
- import { u as verifyRequest } from "./http-DGD9d8-A.mjs";
8
- import { n as getAuthenticatedDocumentLoader } from "./docloader-DpTrZ5sA.mjs";
5
+ import { n as version, t as name } from "./deno-Dv6PIwH_.mjs";
6
+ import { a as importJwk, o as validateCryptoKey, t as exportJwk } from "./key-ChKDZfvS.mjs";
7
+ import { u as verifyRequest } from "./http-BWoAqky4.mjs";
8
+ import { n as getAuthenticatedDocumentLoader } from "./docloader-BgHM-JLc.mjs";
9
9
  import { n as kvCache } from "./kv-cache-BrjuJue8.mjs";
10
- import { a as compactJsonLd, c as getNormalizationContextLoader, d as isInvalidUrlTypeError, f as signJsonLd, g as wrapContextLoaderForJsonLd, l as hasSignature, p as verifyCompactJsonLd, r as assertSafeJsonLd, s as detachSignature, t as InvalidContextReferenceError, u as isClearlyMalformedContextReference } from "./ld-BuuOR_Ms.mjs";
11
- import { n as getKeyOwner, t as doesActorOwnKey } from "./owner-BI33UeIv.mjs";
12
- import { n as signObject, r as verifyObject } from "./proof-GM73LJjx.mjs";
10
+ import { a as compactJsonLd, c as getNormalizationContextLoader, d as isInvalidUrlTypeError, f as signJsonLd, g as wrapContextLoaderForJsonLd, l as hasSignature, p as verifyCompactJsonLd, r as assertSafeJsonLd, s as detachSignature, t as InvalidContextReferenceError, u as isClearlyMalformedContextReference } from "./ld-DbSNiv8Q.mjs";
11
+ import { n as getKeyOwner, t as doesActorOwnKey } from "./owner-BJeJfxnT.mjs";
12
+ import { n as signObject, r as verifyObject } from "./proof-CaMBdk_x.mjs";
13
13
  import { d as MAX_BODY_SIZE, f as readBoundedText, t as getNodeInfo, u as BodyTooLargeError } from "./client-DGNacEx_.mjs";
14
14
  import { t as nodeInfoToJson } from "./types-MNlFfxjv.mjs";
15
- import { n as actorsHaveSameOrigin, r as routeActivity } from "./inbox-BwpBTbhH.mjs";
16
- import { t as FederationBuilderImpl } from "./builder-Dndt590h.mjs";
15
+ import { n as actorsHaveSameOrigin, r as routeActivity } from "./inbox-0Dbv0QVc.mjs";
16
+ import { t as FederationBuilderImpl } from "./builder-BC3eRIbe.mjs";
17
17
  import { t as buildCollectionSynchronizationHeader } from "./collection-DI6YzYpd.mjs";
18
18
  import { t as KvKeyCache } from "./keycache-DBD6fzl1.mjs";
19
19
  import { t as acceptsJsonLd } from "./negotiation-TWEs6Cl8.mjs";
20
- import { t as hasMalformedKnownTemporalLiteral } from "./temporal-CfNFB7M_.mjs";
20
+ import { t as hasMalformedKnownTemporalLiteral } from "./temporal-BJoGKOXy.mjs";
21
21
  import { t as createExponentialBackoffPolicy } from "./retry-Ddbq3AcK.mjs";
22
- import { i as sendActivity, n as extractInboxes, t as SendActivityError } from "./send-nImUK91D.mjs";
22
+ import { i as sendActivity, n as extractInboxes, t as SendActivityError } from "./send-CYrAOC1K.mjs";
23
23
  import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, getTypeId, lookupObject, traverseCollection } from "@fedify/vocab";
24
24
  import { lookupWebFinger } from "@fedify/webfinger";
25
25
  import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
@@ -1532,6 +1532,23 @@ var FederationImpl = class extends FederationBuilderImpl {
1532
1532
  _getTracer() {
1533
1533
  return this.tracerProvider.getTracer(name, version);
1534
1534
  }
1535
+ /**
1536
+ * Starts listening on a queue, converting a synchronous throw into
1537
+ * a rejected promise.
1538
+ *
1539
+ * `MessageQueue.listen()` is documented to never reject, but some
1540
+ * implementations (e.g., `WorkersMessageQueue`) throw synchronously. Without
1541
+ * this normalization, one such throw aborts {@link _startQueueInternal} while
1542
+ * it is still collecting listener promises, so listeners started earlier are
1543
+ * never awaited and later queues are never started.
1544
+ */
1545
+ #listenQueue(queue, ctxData, signal) {
1546
+ try {
1547
+ return queue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal });
1548
+ } catch (error) {
1549
+ return Promise.reject(error);
1550
+ }
1551
+ }
1535
1552
  async _startQueueInternal(ctxData, signal, queue) {
1536
1553
  if (this.inboxQueue == null && this.outboxQueue == null) return;
1537
1554
  const logger = getLogger([
@@ -1543,20 +1560,38 @@ var FederationImpl = class extends FederationBuilderImpl {
1543
1560
  if (this.inboxQueue != null && (queue == null || queue === "inbox") && !this.inboxQueueStarted) {
1544
1561
  logger.debug("Starting an inbox task worker.");
1545
1562
  this.inboxQueueStarted = true;
1546
- promises.push(this.inboxQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
1563
+ promises.push(this.#listenQueue(this.inboxQueue, ctxData, signal));
1547
1564
  }
1548
1565
  if (this.outboxQueue != null && this.outboxQueue !== this.inboxQueue && (queue == null || queue === "outbox") && !this.outboxQueueStarted) {
1549
1566
  logger.debug("Starting an outbox task worker.");
1550
1567
  this.outboxQueueStarted = true;
1551
- promises.push(this.outboxQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
1568
+ promises.push(this.#listenQueue(this.outboxQueue, ctxData, signal));
1552
1569
  }
1553
1570
  if (this.fanoutQueue != null && this.fanoutQueue !== this.inboxQueue && this.fanoutQueue !== this.outboxQueue && (queue == null || queue === "fanout") && !this.fanoutQueueStarted) {
1554
1571
  logger.debug("Starting a fanout task worker.");
1555
1572
  this.fanoutQueueStarted = true;
1556
- promises.push(this.fanoutQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
1573
+ promises.push(this.#listenQueue(this.fanoutQueue, ctxData, signal));
1557
1574
  }
1558
1575
  await Promise.all(promises);
1559
1576
  }
1577
+ /**
1578
+ * Starts the queue workers automatically, reporting a failure instead of
1579
+ * leaving the returned promise unobserved.
1580
+ *
1581
+ * Automatic startup is best-effort: call sites cannot await it, so a failing
1582
+ * listener (e.g., `WorkersMessageQueue`, whose `listen()` throws) must not
1583
+ * become an unhandled rejection. {@link startQueue} keeps rejecting for
1584
+ * callers that start workers deliberately.
1585
+ */
1586
+ _startQueueAutomatically(ctxData) {
1587
+ this._startQueueInternal(ctxData).catch((error) => {
1588
+ getLogger([
1589
+ "fedify",
1590
+ "federation",
1591
+ "queue"
1592
+ ]).warn("Failed to start queue workers automatically: {error}", { error });
1593
+ });
1594
+ }
1560
1595
  processQueuedTask(contextData, message) {
1561
1596
  const tracer = this._getTracer();
1562
1597
  const extractedContext = propagation.extract(context.active(), message.traceContext);
@@ -1665,7 +1700,8 @@ var FederationImpl = class extends FederationBuilderImpl {
1665
1700
  await this.sendActivity(keys, message.inboxes, activity, {
1666
1701
  collectionSync: message.collectionSync,
1667
1702
  orderingKey: message.orderingKey,
1668
- context
1703
+ context,
1704
+ activityJsonLd: hasTopLevelProof(message.activity) ? message.activity : void 0
1669
1705
  });
1670
1706
  }
1671
1707
  async #listenOutboxMessage(_, message, span) {
@@ -2072,7 +2108,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2072
2108
  proofCreated = true;
2073
2109
  }
2074
2110
  }
2075
- let jsonLd = await activity.toJsonLd({
2111
+ let jsonLd = options.activityJsonLd != null ? detachSignature(options.activityJsonLd) : await activity.toJsonLd({
2076
2112
  format: "compact",
2077
2113
  contextLoader
2078
2114
  });
@@ -2139,7 +2175,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2139
2175
  privateKey: privateKeyJwk
2140
2176
  });
2141
2177
  }
2142
- if (!this.manuallyStartQueue) this._startQueueInternal(ctx.data);
2178
+ if (!this.manuallyStartQueue) this._startQueueAutomatically(ctx.data);
2143
2179
  const carrier = {};
2144
2180
  propagation.inject(context.active(), carrier);
2145
2181
  const messages = [];
@@ -2351,7 +2387,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2351
2387
  const identity = await this.sharedInboxKeyDispatcher(context);
2352
2388
  if (identity != null) context = this.#createContext(request, contextData, { documentLoader: "identifier" in identity || "username" in identity ? await context.getDocumentLoader(identity) : context.getDocumentLoader(identity) });
2353
2389
  }
2354
- if (!this.manuallyStartQueue) this._startQueueInternal(contextData);
2390
+ if (!this.manuallyStartQueue) this._startQueueAutomatically(contextData);
2355
2391
  const inboxContextFactory = context.toInboxContext.bind(context);
2356
2392
  inboxContextFactory[rawInboxContextFactorySymbol] = context.toInboxContext.bind(context);
2357
2393
  return await handleInbox(request, {
@@ -2789,7 +2825,17 @@ var ContextImpl = class ContextImpl {
2789
2825
  allowPrivateAddress: this.federation.allowPrivateAddress
2790
2826
  });
2791
2827
  }
2792
- sendActivity(sender, recipients, activity, options = {}) {
2828
+ async sendActivity(sender, recipients, activity, options = {}) {
2829
+ let activityJsonLd = void 0;
2830
+ let hasProof = activity.proofIds.length > 0;
2831
+ if (!hasProof) for await (const _ of activity.getProofs({ contextLoader: this.contextLoader })) {
2832
+ hasProof = true;
2833
+ break;
2834
+ }
2835
+ if (hasProof) {
2836
+ activityJsonLd = await activity.toJsonLd({ contextLoader: this.contextLoader });
2837
+ if (!hasTopLevelProof(activityJsonLd)) activityJsonLd = void 0;
2838
+ }
2793
2839
  return this.tracerProvider.getTracer(name, version).startActiveSpan(this.federation.outboxQueue == null || options.immediate ? "activitypub.outbox" : "activitypub.fanout", {
2794
2840
  kind: this.federation.outboxQueue == null || options.immediate ? SpanKind.CLIENT : SpanKind.PRODUCER,
2795
2841
  attributes: {
@@ -2802,7 +2848,7 @@ var ContextImpl = class ContextImpl {
2802
2848
  }, async (span) => {
2803
2849
  try {
2804
2850
  if (activity.id != null) span.setAttribute("activitypub.activity.id", activity.id.href);
2805
- await this.sendActivityInternal(sender, recipients, activity, options, span);
2851
+ await this.sendActivityInternal(sender, recipients, activity, options, span, activityJsonLd);
2806
2852
  } catch (e) {
2807
2853
  span.setStatus({
2808
2854
  code: SpanStatusCode.ERROR,
@@ -2814,7 +2860,7 @@ var ContextImpl = class ContextImpl {
2814
2860
  }
2815
2861
  });
2816
2862
  }
2817
- async sendActivityInternal(sender, recipients, activity, options, span) {
2863
+ async sendActivityInternal(sender, recipients, activity, options, span, activityJsonLd) {
2818
2864
  const logger = getLogger([
2819
2865
  "fedify",
2820
2866
  "federation",
@@ -2861,14 +2907,23 @@ var ContextImpl = class ContextImpl {
2861
2907
  if (!(error instanceof RouterError)) throw error;
2862
2908
  }
2863
2909
  } else expandedRecipients = [recipients];
2864
- const opts = {
2865
- context: this,
2866
- orderingKey: options.orderingKey,
2867
- collectionSync,
2868
- immediate: options.immediate
2869
- };
2870
2910
  span.setAttribute("activitypub.inboxes", expandedRecipients.length);
2871
2911
  for (const activityTransformer of this.federation.activityTransformers) activity = activityTransformer(activity, this);
2912
+ let contextMatches = false;
2913
+ if (activityJsonLd != null) {
2914
+ const capturedJsonLd = activityJsonLd;
2915
+ const transformedJsonLd = await activity.toJsonLd({
2916
+ format: "compact",
2917
+ contextLoader: this.contextLoader
2918
+ });
2919
+ const contentChanged = getContentFields(transformedJsonLd) !== getContentFields(capturedJsonLd);
2920
+ contextMatches = getContextFields(transformedJsonLd) === getContextFields(capturedJsonLd);
2921
+ const proofsChanged = getProofFields(transformedJsonLd) !== getProofFields(capturedJsonLd);
2922
+ if (contentChanged || !contextMatches && proofsChanged) {
2923
+ activity = activity.clone({ proofs: await getUncapturedProofs(activity, capturedJsonLd, this.contextLoader) });
2924
+ activityJsonLd = void 0;
2925
+ } else if (proofsChanged) activityJsonLd = void 0;
2926
+ }
2872
2927
  span?.setAttribute("activitypub.activity.id", activity?.id?.href ?? "");
2873
2928
  if (activity.actorId == null) {
2874
2929
  logger.error("Activity {activityId} to send does not have an actor.", {
@@ -2879,14 +2934,27 @@ var ContextImpl = class ContextImpl {
2879
2934
  }
2880
2935
  if (actorKeyPairs != null) {
2881
2936
  const contextLoader = this.contextLoader;
2937
+ if (actorKeyPairs.some((kp) => kp.privateKey.algorithm.name === "Ed25519" && kp.multikey.id != null)) {
2938
+ if (activityJsonLd != null && !contextMatches) activity = activity.clone({ proofs: [] });
2939
+ }
2940
+ let proofAdded = false;
2882
2941
  for (const kp of actorKeyPairs) {
2883
2942
  if (kp.privateKey.algorithm.name !== "Ed25519" || kp.multikey.id == null) continue;
2884
2943
  activity = await signObject(activity, kp.privateKey, kp.multikey.id, {
2885
2944
  contextLoader,
2886
2945
  tracerProvider: this.tracerProvider
2887
2946
  });
2947
+ proofAdded = true;
2888
2948
  }
2949
+ if (proofAdded) activityJsonLd = void 0;
2889
2950
  }
2951
+ const opts = {
2952
+ context: this,
2953
+ orderingKey: options.orderingKey,
2954
+ collectionSync,
2955
+ immediate: options.immediate,
2956
+ activityJsonLd
2957
+ };
2890
2958
  const inboxes = extractInboxes({
2891
2959
  recipients: expandedRecipients,
2892
2960
  preferSharedInbox: options.preferSharedInbox,
@@ -2916,7 +2984,7 @@ var ContextImpl = class ContextImpl {
2916
2984
  actorIds: [...actorIds],
2917
2985
  sharedInbox
2918
2986
  }])),
2919
- activity: await activity.toJsonLd({
2987
+ activity: activityJsonLd != null ? detachSignature(activityJsonLd) : await activity.toJsonLd({
2920
2988
  format: "compact",
2921
2989
  contextLoader: this.contextLoader
2922
2990
  }),
@@ -2926,7 +2994,7 @@ var ContextImpl = class ContextImpl {
2926
2994
  orderingKey: options.orderingKey,
2927
2995
  traceContext: carrier
2928
2996
  };
2929
- if (!this.federation.manuallyStartQueue) this.federation._startQueueInternal(this.data);
2997
+ if (!this.federation.manuallyStartQueue) this.federation._startQueueAutomatically(this.data);
2930
2998
  await this.federation.fanoutQueue.enqueue(message, { orderingKey: options.orderingKey });
2931
2999
  }
2932
3000
  async *getFollowers(identifier) {
@@ -3402,6 +3470,69 @@ var KvSpecDeterminer = class {
3402
3470
  function notFound(_request) {
3403
3471
  return new Response("Not Found", { status: 404 });
3404
3472
  }
3473
+ function hasTopLevelProof(value) {
3474
+ return typeof value === "object" && value != null && !Array.isArray(value) && globalThis.Object.prototype.hasOwnProperty.call(value, "proof");
3475
+ }
3476
+ function getContentFields(value) {
3477
+ if (typeof value !== "object" || value == null || Array.isArray(value)) return JSON.stringify(sortJsonKeys(value));
3478
+ const record = { ...value };
3479
+ delete record["@context"];
3480
+ delete record.proof;
3481
+ delete record.signature;
3482
+ return JSON.stringify(sortJsonKeys(record));
3483
+ }
3484
+ function getContextFields(value) {
3485
+ if (typeof value !== "object" || value == null || Array.isArray(value)) return JSON.stringify(sortJsonKeys(value));
3486
+ const context = value["@context"];
3487
+ return JSON.stringify(sortJsonKeys(context ?? null));
3488
+ }
3489
+ function getProofEntries(value) {
3490
+ if (typeof value !== "object" || value == null || Array.isArray(value)) return [];
3491
+ const proof = value.proof;
3492
+ if (proof == null) return [];
3493
+ return Array.isArray(proof) ? proof : [proof];
3494
+ }
3495
+ function normalizeProofEntry(proof) {
3496
+ const stripped = stripContexts(proof);
3497
+ if (typeof stripped !== "object" || stripped == null || Array.isArray(stripped)) return stripped;
3498
+ const record = { ...stripped };
3499
+ if (typeof record.created === "string") try {
3500
+ record.created = Temporal.Instant.from(record.created).toString();
3501
+ } catch {}
3502
+ return record;
3503
+ }
3504
+ function getProofEntryFields(proof) {
3505
+ return JSON.stringify(sortJsonKeys(normalizeProofEntry(proof)));
3506
+ }
3507
+ function getProofFields(value) {
3508
+ return JSON.stringify(getProofEntries(value).map(getProofEntryFields).sort());
3509
+ }
3510
+ async function getUncapturedProofs(activity, capturedJsonLd, contextLoader) {
3511
+ const capturedProofs = new Set(getProofEntries(capturedJsonLd).map(getProofEntryFields));
3512
+ const retainedProofs = [];
3513
+ for await (const proof of activity.getProofs({ contextLoader })) {
3514
+ const proofJsonLd = await proof.toJsonLd({
3515
+ format: "compact",
3516
+ contextLoader
3517
+ });
3518
+ if (!capturedProofs.has(getProofEntryFields(proofJsonLd))) retainedProofs.push(proof);
3519
+ }
3520
+ return retainedProofs;
3521
+ }
3522
+ function stripContexts(value) {
3523
+ if (Array.isArray(value)) return value.map(stripContexts);
3524
+ if (typeof value !== "object" || value == null) return value;
3525
+ const record = { ...value };
3526
+ delete record["@context"];
3527
+ delete record.signature;
3528
+ for (const key of globalThis.Object.keys(record)) record[key] = stripContexts(record[key]);
3529
+ return record;
3530
+ }
3531
+ function sortJsonKeys(value) {
3532
+ if (Array.isArray(value)) return value.map(sortJsonKeys);
3533
+ if (typeof value !== "object" || value == null) return value;
3534
+ return globalThis.Object.fromEntries(globalThis.Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, item]) => [key, sortJsonKeys(item)]));
3535
+ }
3405
3536
  function notAcceptable(_request) {
3406
3537
  return new Response("Not Acceptable", {
3407
3538
  status: 406,