@fedify/fedify 2.3.0-dev.1021 → 2.3.0-dev.1034

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 (95) hide show
  1. package/dist/{builder-Nn2r1dKd.mjs → builder-y06Dq5bp.mjs} +3 -3
  2. package/dist/chunk-QSgtlS85.mjs +29 -0
  3. package/dist/compat/mod.d.cts +1 -1
  4. package/dist/compat/mod.d.ts +1 -1
  5. package/dist/compat/outgoing-jsonld.test.mjs +1 -1
  6. package/dist/compat/public-audience.test.mjs +1 -1
  7. package/dist/compat/transformers.test.mjs +2 -2
  8. package/dist/{context-Dk_tacqz.mjs → context-7Azky82W.mjs} +3 -2
  9. package/dist/{context-Bxs4cdIZ.d.cts → context-BKLGj9QO.d.cts} +12 -1
  10. package/dist/{context-CVNXcFHR.d.ts → context-DrNqYkPw.d.ts} +12 -1
  11. package/dist/{deno-BnQyJ03o.mjs → deno-DB1H1VHx.mjs} +1 -1
  12. package/dist/{docloader-mEJ3hsMB.mjs → docloader-3HwiWeYL.mjs} +2 -2
  13. package/dist/{esm-DVILvP5e.mjs → esm-DhnRLoG9.mjs} +1 -24
  14. package/dist/execAsync-eck5rbtb.mjs +13 -0
  15. package/dist/federation/builder.test.mjs +2 -2
  16. package/dist/federation/collection.test.mjs +1 -1
  17. package/dist/federation/handler.test.mjs +48 -11
  18. package/dist/federation/idempotency.test.mjs +4 -4
  19. package/dist/federation/inbox.test.mjs +1 -1
  20. package/dist/federation/keycache.test.mjs +2 -2
  21. package/dist/federation/kv.test.mjs +1 -1
  22. package/dist/federation/middleware.test.mjs +103 -12
  23. package/dist/federation/mod.cjs +1 -1
  24. package/dist/federation/mod.d.cts +2 -2
  25. package/dist/federation/mod.d.ts +2 -2
  26. package/dist/federation/mod.js +1 -1
  27. package/dist/federation/negotiation.test.mjs +1 -1
  28. package/dist/federation/retry.test.mjs +1 -1
  29. package/dist/federation/send.test.mjs +4540 -11
  30. package/dist/federation/webfinger.test.mjs +3 -3
  31. package/dist/getMachineId-bsd-DqZ4QRFp.mjs +29 -0
  32. package/dist/getMachineId-darwin-DMbbW3m7.mjs +26 -0
  33. package/dist/getMachineId-linux-lyeD2ug3.mjs +22 -0
  34. package/dist/getMachineId-unsupported-JuKr57jY.mjs +17 -0
  35. package/dist/getMachineId-win-Dxyf5pJq.mjs +28 -0
  36. package/dist/{http-BJ-t29n_.js → http-BUr93aO6.js} +1 -1
  37. package/dist/{http-CfToB_iu.mjs → http-D9zG-L9N.mjs} +3 -3
  38. package/dist/{http-D4xMqSqO.cjs → http-FnUTcdMf.cjs} +1 -1
  39. package/dist/{key-CeANlo1H.mjs → key-CV57mOYH.mjs} +1 -1
  40. package/dist/{kv-cache-DRwOjOkl.cjs → kv-cache-BG9O8wVV.cjs} +1 -1
  41. package/dist/{kv-cache-B142kDZL.js → kv-cache-C3esyJFP.js} +1 -1
  42. package/dist/{ld-CUlVC-TS.mjs → ld-sUf94RJ8.mjs} +2 -2
  43. package/dist/{middleware-I5XEZ_pZ.cjs → middleware-CKkBrsOD.cjs} +185 -27
  44. package/dist/{middleware-Cgy7UwfR.mjs → middleware-cMxbPxDe.mjs} +1 -1
  45. package/dist/{middleware-CysDkaXo.js → middleware-fAuUxD9-.js} +185 -27
  46. package/dist/{middleware-ASvK22Do.cjs → middleware-ohzkLsW4.cjs} +1 -1
  47. package/dist/{middleware-BPZEcrMG.mjs → middleware-pb2EqN_r.mjs} +67 -22
  48. package/dist/{mod-Bc6p4npy.d.ts → mod-B8Z8mBLk.d.ts} +1 -1
  49. package/dist/{mod-zA6NZHUG.d.cts → mod-DClCOv0M.d.cts} +1 -1
  50. package/dist/mod.cjs +4 -4
  51. package/dist/mod.d.cts +2 -2
  52. package/dist/mod.d.ts +2 -2
  53. package/dist/mod.js +4 -4
  54. package/dist/nodeinfo/client.test.mjs +2 -2
  55. package/dist/nodeinfo/handler.test.mjs +3 -3
  56. package/dist/nodeinfo/types.test.mjs +1 -1
  57. package/dist/otel/exporter.test.mjs +25 -22
  58. package/dist/otel/mod.cjs +6 -5
  59. package/dist/otel/mod.d.cts +3 -2
  60. package/dist/otel/mod.d.ts +3 -2
  61. package/dist/otel/mod.js +6 -5
  62. package/dist/{outgoing-jsonld-CNmZLixq.mjs → outgoing-jsonld-Bi7n-dEy.mjs} +1 -1
  63. package/dist/{owner-CuW0S2XY.mjs → owner-DsPgl527.mjs} +2 -2
  64. package/dist/{proof-oGiWJkX0.cjs → proof-BhJpq_J9.cjs} +1 -1
  65. package/dist/{proof-CFPGr1xC.mjs → proof-iVfYyJpY.mjs} +4 -4
  66. package/dist/{proof-CtMmqa09.js → proof-k4mEvvdS.js} +1 -1
  67. package/dist/send-D-vYdfC6.mjs +306 -0
  68. package/dist/sig/accept.test.mjs +1 -1
  69. package/dist/sig/http.test.mjs +4 -4
  70. package/dist/sig/key.test.mjs +2 -2
  71. package/dist/sig/ld.test.mjs +3 -3
  72. package/dist/sig/mod.cjs +2 -2
  73. package/dist/sig/mod.js +2 -2
  74. package/dist/sig/owner.test.mjs +2 -2
  75. package/dist/sig/proof.test.mjs +3 -3
  76. package/dist/testing/mod.d.mts +6 -1
  77. package/dist/testing/mod.mjs +1 -1
  78. package/dist/utils/docloader.test.mjs +4 -4
  79. package/dist/utils/kv-cache.test.mjs +1 -1
  80. package/dist/utils/mod.cjs +1 -1
  81. package/dist/utils/mod.js +1 -1
  82. package/package.json +7 -6
  83. package/dist/send-dhl-s8G0.mjs +0 -193
  84. /package/dist/{accept-CPkZzmGN.mjs → accept-CceiKpCy.mjs} +0 -0
  85. /package/dist/{activity-listener-ell7W1s9.mjs → activity-listener-tztVvlNb.mjs} +0 -0
  86. /package/dist/{client-D_1QpnWt.mjs → client-CIiz1WX7.mjs} +0 -0
  87. /package/dist/{collection-D-HqUuA2.mjs → collection-CA3V5zyK.mjs} +0 -0
  88. /package/dist/{keycache-EGATflN-.mjs → keycache-BeU0LCII.mjs} +0 -0
  89. /package/dist/{keys-DGu1NFwu.mjs → keys-C3kae-6B.mjs} +0 -0
  90. /package/dist/{kv-cache-U__xU4qR.mjs → kv-cache-Bmv7tUzz.mjs} +0 -0
  91. /package/dist/{kv-rV3vodCc.mjs → kv-x2IvBUyq.mjs} +0 -0
  92. /package/dist/{negotiation-SQvQgUqe.mjs → negotiation-VnHNB0Q5.mjs} +0 -0
  93. /package/dist/{public-audience-DYFHzm_c.mjs → public-audience-PVTwU_Ex.mjs} +0 -0
  94. /package/dist/{retry-bMXBL97A.mjs → retry-_VvV0h9f.mjs} +0 -0
  95. /package/dist/{types-J53Kw7so.mjs → types-BFowWFTT.mjs} +0 -0
@@ -1,15 +1,15 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { t as esm_default } from "../esm-DVILvP5e.mjs";
5
4
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
5
  import { i as assertExists, t as assertStringIncludes } from "../std__assert-CRDpx_HF.mjs";
7
6
  import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
8
7
  import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
9
8
  import { t as assert } from "../assert-DikXweDx.mjs";
10
- import { t as exportJwk } from "../key-CeANlo1H.mjs";
11
- import { a as parseRfc9421Signature, c as timingSafeEqual, i as formatRfc9421SignatureParameters, l as verifyRequest, n as doubleKnock, o as parseRfc9421SignatureInput, r as formatRfc9421Signature, s as signRequest, t as createRfc9421SignatureBase, u as verifyRequestDetailed } from "../http-CfToB_iu.mjs";
12
- import { i as rsaPrivateKey2, l as rsaPublicKey5, o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-DGu1NFwu.mjs";
9
+ import { t as esm_default } from "../esm-DhnRLoG9.mjs";
10
+ import { t as exportJwk } from "../key-CV57mOYH.mjs";
11
+ import { a as parseRfc9421Signature, c as timingSafeEqual, i as formatRfc9421SignatureParameters, l as verifyRequest, n as doubleKnock, o as parseRfc9421SignatureInput, r as formatRfc9421Signature, s as signRequest, t as createRfc9421SignatureBase, u as verifyRequestDetailed } from "../http-D9zG-L9N.mjs";
12
+ import { i as rsaPrivateKey2, l as rsaPublicKey5, o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-C3kae-6B.mjs";
13
13
  import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
14
14
  import { FetchError, exportSpki } from "@fedify/vocab-runtime";
15
15
  import { encodeBase64 } from "byte-encodings/base64";
@@ -5,8 +5,8 @@ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
5
  import "../std__assert-CRDpx_HF.mjs";
6
6
  import { t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
7
7
  import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
8
- import { a as importJwk, i as generateCryptoKeyPair, n as fetchKey, o as validateCryptoKey, r as fetchKeyDetailed, t as exportJwk } from "../key-CeANlo1H.mjs";
9
- import { c as rsaPublicKey3, i as rsaPrivateKey2, o as rsaPublicKey1, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DGu1NFwu.mjs";
8
+ import { a as importJwk, i as generateCryptoKeyPair, n as fetchKey, o as validateCryptoKey, r as fetchKeyDetailed, t as exportJwk } from "../key-CV57mOYH.mjs";
9
+ import { c as rsaPublicKey3, i as rsaPrivateKey2, o as rsaPublicKey1, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-C3kae-6B.mjs";
10
10
  import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
11
11
  import { CryptographicKey, Multikey } from "@fedify/vocab";
12
12
  import { FetchError } from "@fedify/vocab-runtime";
@@ -5,9 +5,9 @@ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
5
  import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
6
6
  import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
7
7
  import { t as assert } from "../assert-DikXweDx.mjs";
8
- import { i as generateCryptoKeyPair } from "../key-CeANlo1H.mjs";
9
- import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DGu1NFwu.mjs";
10
- import { a as signJsonLd, i as hasSignatureLike, n as createSignature, o as verifyJsonLd, r as detachSignature, s as verifySignature, t as attachSignature } from "../ld-CUlVC-TS.mjs";
8
+ import { i as generateCryptoKeyPair } from "../key-CV57mOYH.mjs";
9
+ import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-C3kae-6B.mjs";
10
+ import { a as signJsonLd, i as hasSignatureLike, n as createSignature, o as verifyJsonLd, r as detachSignature, s as verifySignature, t as attachSignature } from "../ld-sUf94RJ8.mjs";
11
11
  import { mockDocumentLoader, test } from "@fedify/fixture";
12
12
  import { CryptographicKey } from "@fedify/vocab";
13
13
  import { encodeBase64 } from "byte-encodings/base64";
package/dist/sig/mod.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  const { Temporal } = require("@js-temporal/polyfill");
2
2
  const { URLPattern } = require("urlpattern-polyfill");
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const require_http = require("../http-D4xMqSqO.cjs");
5
- const require_proof = require("../proof-oGiWJkX0.cjs");
4
+ const require_http = require("../http-FnUTcdMf.cjs");
5
+ const require_proof = require("../proof-BhJpq_J9.cjs");
6
6
  exports.attachSignature = require_proof.attachSignature;
7
7
  exports.createProof = require_proof.createProof;
8
8
  exports.createSignature = require_proof.createSignature;
package/dist/sig/mod.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
- import { a as verifyRequestDetailed, c as fetchKeyDetailed, f as formatAcceptSignature, h as validateAcceptSignature, i as verifyRequest, l as generateCryptoKeyPair, m as parseAcceptSignature, o as exportJwk, p as fulfillAcceptSignature, r as signRequest, s as fetchKey, u as importJwk } from "../http-BJ-t29n_.js";
4
- import { a as verifyProof, c as getKeyOwner, d as detachSignature, f as hasSignatureLike, h as verifySignature, i as verifyObject, l as attachSignature, m as verifyJsonLd, n as hasProofLike, p as signJsonLd, r as signObject, s as doesActorOwnKey, t as createProof, u as createSignature } from "../proof-CtMmqa09.js";
3
+ import { a as verifyRequestDetailed, c as fetchKeyDetailed, f as formatAcceptSignature, h as validateAcceptSignature, i as verifyRequest, l as generateCryptoKeyPair, m as parseAcceptSignature, o as exportJwk, p as fulfillAcceptSignature, r as signRequest, s as fetchKey, u as importJwk } from "../http-BUr93aO6.js";
4
+ import { a as verifyProof, c as getKeyOwner, d as detachSignature, f as hasSignatureLike, h as verifySignature, i as verifyObject, l as attachSignature, m as verifyJsonLd, n as hasProofLike, p as signJsonLd, r as signObject, s as doesActorOwnKey, t as createProof, u as createSignature } from "../proof-k4mEvvdS.js";
5
5
  export { attachSignature, createProof, createSignature, detachSignature, doesActorOwnKey, exportJwk, fetchKey, fetchKeyDetailed, formatAcceptSignature, fulfillAcceptSignature, generateCryptoKeyPair, getKeyOwner, hasProofLike, hasSignatureLike, importJwk, parseAcceptSignature, signJsonLd, signObject, signRequest, validateAcceptSignature, verifyJsonLd, verifyObject, verifyProof, verifyRequest, verifyRequestDetailed, verifySignature };
@@ -5,8 +5,8 @@ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
5
  import "../std__assert-CRDpx_HF.mjs";
6
6
  import { n as assertFalse } from "../assert_rejects-B-qJtC9Z.mjs";
7
7
  import { t as assert } from "../assert-DikXweDx.mjs";
8
- import { o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-DGu1NFwu.mjs";
9
- import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-CuW0S2XY.mjs";
8
+ import { o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-C3kae-6B.mjs";
9
+ import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-DsPgl527.mjs";
10
10
  import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
11
11
  import { Create, CryptographicKey, lookupObject } from "@fedify/vocab";
12
12
  //#region src/sig/owner.test.ts
@@ -6,9 +6,9 @@ import "../std__assert-CRDpx_HF.mjs";
6
6
  import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
7
7
  import { t as assertInstanceOf } from "../assert_instance_of-C4Ri6VuN.mjs";
8
8
  import { t as assert } from "../assert-DikXweDx.mjs";
9
- import { i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DGu1NFwu.mjs";
10
- import { r as normalizeOutgoingActivityJsonLd } from "../outgoing-jsonld-CNmZLixq.mjs";
11
- import { a as verifyProof, i as verifyObject, n as hasProofLike, r as signObject, t as createProof } from "../proof-CFPGr1xC.mjs";
9
+ import { i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-C3kae-6B.mjs";
10
+ import { r as normalizeOutgoingActivityJsonLd } from "../outgoing-jsonld-Bi7n-dEy.mjs";
11
+ import { a as verifyProof, i as verifyObject, n as hasProofLike, r as signObject, t as createProof } from "../proof-iVfYyJpY.mjs";
12
12
  import { mockDocumentLoader, test } from "@fedify/fixture";
13
13
  import { Create, DataIntegrityProof, Document, Multikey, Note, PUBLIC_COLLECTION, Place } from "@fedify/vocab";
14
14
  import { decodeMultibase, importMultibaseKey } from "@fedify/vocab-runtime";
@@ -3,7 +3,7 @@ import { URLPattern } from "urlpattern-polyfill";
3
3
  import { testDefinitions } from "@fedify/fixture";
4
4
  import { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey, Object as Object$1, Recipient, Tombstone, TraverseCollectionOptions } from "@fedify/vocab";
5
5
  import { Link as Link$1, LookupWebFingerOptions, ResourceDescriptor } from "@fedify/webfinger";
6
- import { TracerProvider } from "@opentelemetry/api";
6
+ import { MeterProvider, TracerProvider } from "@opentelemetry/api";
7
7
  import { DocumentLoader, GetUserAgentOptions } from "@fedify/vocab-runtime";
8
8
 
9
9
  //#region src/nodeinfo/types.d.ts
@@ -1507,6 +1507,11 @@ interface Context<TContextData> {
1507
1507
  * @since 1.3.0
1508
1508
  */
1509
1509
  readonly tracerProvider: TracerProvider;
1510
+ /**
1511
+ * The OpenTelemetry meter provider.
1512
+ * @since 2.3.0
1513
+ */
1514
+ readonly meterProvider?: MeterProvider;
1510
1515
  /**
1511
1516
  * The document loader for loading remote JSON-LD documents.
1512
1517
  */
@@ -1,6 +1,6 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as createOutboxContext, r as createRequestContext, t as createInboxContext } from "../context-Dk_tacqz.mjs";
4
+ import { n as createOutboxContext, r as createRequestContext, t as createInboxContext } from "../context-7Azky82W.mjs";
5
5
  import { testDefinitions } from "@fedify/fixture";
6
6
  export { createInboxContext, createOutboxContext, createRequestContext, testDefinitions };
@@ -1,13 +1,13 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { t as esm_default } from "../esm-DVILvP5e.mjs";
5
4
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
5
  import "../std__assert-CRDpx_HF.mjs";
7
6
  import { t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
8
- import { l as verifyRequest } from "../http-CfToB_iu.mjs";
9
- import { i as rsaPrivateKey2 } from "../keys-DGu1NFwu.mjs";
10
- import { t as getAuthenticatedDocumentLoader } from "../docloader-mEJ3hsMB.mjs";
7
+ import { t as esm_default } from "../esm-DhnRLoG9.mjs";
8
+ import { l as verifyRequest } from "../http-D9zG-L9N.mjs";
9
+ import { i as rsaPrivateKey2 } from "../keys-C3kae-6B.mjs";
10
+ import { t as getAuthenticatedDocumentLoader } from "../docloader-3HwiWeYL.mjs";
11
11
  import { mockDocumentLoader, test } from "@fedify/fixture";
12
12
  import { UrlError } from "@fedify/vocab-runtime";
13
13
  //#region src/utils/docloader.test.ts
@@ -1,7 +1,7 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as kvCache, t as MockKvStore } from "../kv-cache-U__xU4qR.mjs";
4
+ import { n as kvCache, t as MockKvStore } from "../kv-cache-Bmv7tUzz.mjs";
5
5
  import { mockDocumentLoader, test } from "@fedify/fixture";
6
6
  import { deepStrictEqual, throws } from "node:assert";
7
7
  import { preloadedContexts } from "@fedify/vocab-runtime";
@@ -1,6 +1,6 @@
1
1
  const { Temporal } = require("@js-temporal/polyfill");
2
2
  const { URLPattern } = require("urlpattern-polyfill");
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const require_kv_cache = require("../kv-cache-DRwOjOkl.cjs");
4
+ const require_kv_cache = require("../kv-cache-BG9O8wVV.cjs");
5
5
  exports.getAuthenticatedDocumentLoader = require_kv_cache.getAuthenticatedDocumentLoader;
6
6
  exports.kvCache = require_kv_cache.kvCache;
package/dist/utils/mod.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
- import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../kv-cache-B142kDZL.js";
3
+ import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../kv-cache-C3esyJFP.js";
4
4
  export { getAuthenticatedDocumentLoader, kvCache };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/fedify",
3
- "version": "2.3.0-dev.1021+ab2fa4a9",
3
+ "version": "2.3.0-dev.1034+b85b5daa",
4
4
  "description": "An ActivityPub server framework",
5
5
  "keywords": [
6
6
  "ActivityPub",
@@ -153,11 +153,12 @@
153
153
  "uri-template-router": "^1.0.0",
154
154
  "url-template": "^3.1.1",
155
155
  "urlpattern-polyfill": "^10.1.0",
156
- "@fedify/vocab-runtime": "2.3.0-dev.1021+ab2fa4a9",
157
- "@fedify/webfinger": "2.3.0-dev.1021+ab2fa4a9",
158
- "@fedify/vocab": "2.3.0-dev.1021+ab2fa4a9"
156
+ "@fedify/vocab-runtime": "2.3.0-dev.1034+b85b5daa",
157
+ "@fedify/vocab": "2.3.0-dev.1034+b85b5daa",
158
+ "@fedify/webfinger": "2.3.0-dev.1034+b85b5daa"
159
159
  },
160
160
  "devDependencies": {
161
+ "@opentelemetry/sdk-metrics": "2.5.0",
161
162
  "@std/assert": "npm:@jsr/std__assert@^0.226.0",
162
163
  "@std/path": "npm:@jsr/std__path@^1.0.6",
163
164
  "@types/node": "^24.2.1",
@@ -167,8 +168,8 @@
167
168
  "tsx": "^4.19.4",
168
169
  "typescript": "^5.9.2",
169
170
  "wrangler": "^4.17.0",
170
- "@fedify/vocab-tools": "^2.3.0-dev.1021+ab2fa4a9",
171
- "@fedify/fixture": "2.0.0"
171
+ "@fedify/fixture": "2.0.0",
172
+ "@fedify/vocab-tools": "^2.3.0-dev.1034+b85b5daa"
172
173
  },
173
174
  "scripts": {
174
175
  "build:self": "tsdown",
@@ -1,193 +0,0 @@
1
- import "@js-temporal/polyfill";
2
- import "urlpattern-polyfill";
3
- globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-BnQyJ03o.mjs";
5
- import { n as doubleKnock } from "./http-CfToB_iu.mjs";
6
- import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
7
- import { getLogger } from "@logtape/logtape";
8
- //#region src/federation/send.ts
9
- /**
10
- * Extracts the inbox URLs from recipients.
11
- * @param parameters The parameters to extract the inboxes.
12
- * See also {@link ExtractInboxesParameters}.
13
- * @returns The inboxes as a map of inbox URL to actor URIs.
14
- */
15
- function extractInboxes({ recipients, preferSharedInbox, excludeBaseUris }) {
16
- const inboxes = {};
17
- for (const recipient of recipients) {
18
- let inbox;
19
- let sharedInbox = false;
20
- if (preferSharedInbox && recipient.endpoints?.sharedInbox != null) {
21
- inbox = recipient.endpoints.sharedInbox;
22
- sharedInbox = true;
23
- } else inbox = recipient.inboxId;
24
- if (inbox != null && recipient.id != null) {
25
- if (excludeBaseUris != null && excludeBaseUris.some((u) => u.origin === inbox?.origin)) continue;
26
- inboxes[inbox.href] ??= {
27
- actorIds: /* @__PURE__ */ new Set(),
28
- sharedInbox
29
- };
30
- inboxes[inbox.href].actorIds.add(recipient.id.href);
31
- }
32
- }
33
- return inboxes;
34
- }
35
- /**
36
- * Sends an {@link Activity} to an inbox.
37
- *
38
- * @param parameters The parameters for sending the activity.
39
- * See also {@link SendActivityParameters}.
40
- * @throws {Error} If the activity fails to send.
41
- */
42
- function sendActivity(options) {
43
- const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
44
- return tracerProvider.getTracer(name, version).startActiveSpan("activitypub.send_activity", {
45
- kind: SpanKind.CLIENT,
46
- attributes: { "activitypub.shared_inbox": options.sharedInbox ?? false }
47
- }, async (span) => {
48
- if (options.activityId != null) span.setAttribute("activitypub.activity.id", options.activityId);
49
- if (options.activityType != null) span.setAttribute("activitypub.activity.type", options.activityType);
50
- try {
51
- await sendActivityInternal({
52
- ...options,
53
- tracerProvider
54
- }, span);
55
- } catch (e) {
56
- span.setStatus({
57
- code: SpanStatusCode.ERROR,
58
- message: String(e)
59
- });
60
- throw e;
61
- } finally {
62
- span.end();
63
- }
64
- });
65
- }
66
- const MAX_ERROR_RESPONSE_BODY_BYTES = 1024;
67
- async function readLimitedResponseBody(response, maxBytes) {
68
- if (response.body == null) return "";
69
- const reader = response.body.getReader();
70
- const decoder = new TextDecoder();
71
- const chunks = [];
72
- let totalBytes = 0;
73
- let truncated = false;
74
- try {
75
- while (true) {
76
- const { done, value } = await reader.read();
77
- if (done) break;
78
- if (totalBytes + value.length > maxBytes) {
79
- const remaining = maxBytes - totalBytes;
80
- if (remaining > 0) chunks.push(decoder.decode(value.slice(0, remaining), { stream: true }));
81
- truncated = true;
82
- break;
83
- }
84
- chunks.push(decoder.decode(value, { stream: true }));
85
- totalBytes += value.length;
86
- }
87
- } finally {
88
- reader.releaseLock();
89
- }
90
- let result = chunks.join("");
91
- if (truncated) result += "… (truncated)";
92
- return result;
93
- }
94
- async function sendActivityInternal({ activity, activityId, keys, inbox, headers, specDeterminer, tracerProvider }, span) {
95
- const logger = getLogger([
96
- "fedify",
97
- "federation",
98
- "outbox"
99
- ]);
100
- headers = new Headers(headers);
101
- headers.set("Content-Type", "application/activity+json");
102
- const request = new Request(inbox, {
103
- method: "POST",
104
- headers,
105
- body: JSON.stringify(activity)
106
- });
107
- let rsaKey = null;
108
- for (const key of keys) if (key.privateKey.algorithm.name === "RSASSA-PKCS1-v1_5") {
109
- rsaKey = key;
110
- break;
111
- }
112
- if (rsaKey == null) logger.warn("No supported key found to sign the request to {inbox}. The request will be sent without a signature. In order to sign the request, at least one RSASSA-PKCS1-v1_5 key must be provided.", {
113
- inbox: inbox.href,
114
- keys: keys.map((pair) => ({
115
- keyId: pair.keyId.href,
116
- privateKey: pair.privateKey
117
- }))
118
- });
119
- let response;
120
- try {
121
- response = rsaKey == null ? await fetch(request) : await doubleKnock(request, rsaKey, {
122
- tracerProvider,
123
- specDeterminer
124
- });
125
- } catch (error) {
126
- logger.error("Failed to send activity {activityId} to {inbox}:\n{error}", {
127
- activityId,
128
- inbox: inbox.href,
129
- error
130
- });
131
- throw error;
132
- }
133
- if (!response.ok) {
134
- let error;
135
- try {
136
- error = await readLimitedResponseBody(response, MAX_ERROR_RESPONSE_BODY_BYTES);
137
- } catch (_) {
138
- error = "";
139
- }
140
- logger.error("Failed to send activity {activityId} to {inbox} ({status} {statusText}):\n{error}", {
141
- activityId,
142
- inbox: inbox.href,
143
- status: response.status,
144
- statusText: response.statusText,
145
- error
146
- });
147
- throw new SendActivityError(inbox, response.status, `Failed to send activity ${activityId} to ${inbox.href} (${response.status} ${response.statusText}):\n${error}`, error);
148
- }
149
- span.addEvent("activitypub.activity.sent", {
150
- "activitypub.activity.json": JSON.stringify(activity),
151
- "activitypub.inbox.url": inbox.href,
152
- "activitypub.activity.id": activityId ?? ""
153
- });
154
- }
155
- /**
156
- * An error that is thrown when an activity fails to send to a remote inbox.
157
- * It contains structured information about the failure, including the HTTP
158
- * status code, the inbox URL, and the response body.
159
- * @since 2.0.0
160
- */
161
- var SendActivityError = class extends Error {
162
- /**
163
- * The inbox URL that the activity was being sent to.
164
- */
165
- inbox;
166
- /**
167
- * The HTTP status code returned by the inbox.
168
- */
169
- statusCode;
170
- /**
171
- * The response body from the inbox, if any. Note that this may be
172
- * truncated to a maximum of 1 KiB to prevent excessive memory consumption
173
- * when remote servers return large error pages (e.g., Cloudflare error pages).
174
- * If truncated, the string will end with `"… (truncated)"`.
175
- */
176
- responseBody;
177
- /**
178
- * Creates a new {@link SendActivityError}.
179
- * @param inbox The inbox URL.
180
- * @param statusCode The HTTP status code.
181
- * @param message The error message.
182
- * @param responseBody The response body.
183
- */
184
- constructor(inbox, statusCode, message, responseBody) {
185
- super(message);
186
- this.name = "SendActivityError";
187
- this.inbox = inbox;
188
- this.statusCode = statusCode;
189
- this.responseBody = responseBody;
190
- }
191
- };
192
- //#endregion
193
- export { extractInboxes as n, sendActivity as r, SendActivityError as t };
File without changes
File without changes
File without changes
File without changes