@fedify/fedify 2.2.15 → 2.2.17

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 (62) hide show
  1. package/dist/{builder-CcReUrBQ.mjs → builder-a-kl29PE.mjs} +3 -3
  2. package/dist/compat/outgoing-jsonld.test.mjs +1 -1
  3. package/dist/compat/public-audience.test.mjs +1 -1
  4. package/dist/compat/transformers.test.mjs +2 -2
  5. package/dist/{deno-duAPwAHH.mjs → deno-Cya0rbEr.mjs} +1 -1
  6. package/dist/{docloader-DI88Lx6y.mjs → docloader-Dz0Z1Y07.mjs} +2 -2
  7. package/dist/federation/builder.test.mjs +2 -2
  8. package/dist/federation/collection.test.mjs +1 -1
  9. package/dist/federation/handler.test.mjs +7 -7
  10. package/dist/federation/idempotency.test.mjs +3 -3
  11. package/dist/federation/inbox.test.mjs +1 -1
  12. package/dist/federation/keycache.test.mjs +33 -2
  13. package/dist/federation/kv.test.mjs +1 -1
  14. package/dist/federation/middleware.test.mjs +7 -7
  15. package/dist/federation/mod.cjs +1 -1
  16. package/dist/federation/mod.js +1 -1
  17. package/dist/federation/send.test.mjs +3 -3
  18. package/dist/federation/temporal.test.mjs +1 -1
  19. package/dist/federation/webfinger.test.mjs +2 -2
  20. package/dist/{http-CJuCjxWI.cjs → http-C_aA2Zx1.cjs} +103 -9
  21. package/dist/{http-DlBFaZ7A.js → http-DkzPSl5o.js} +104 -10
  22. package/dist/{http-DytBXprv.mjs → http-dobCLGG2.mjs} +2 -2
  23. package/dist/{key-5QlWv3sx.mjs → key-BMHNd0gP.mjs} +104 -10
  24. package/dist/{keycache-C1aVprwy.mjs → keycache-Dkc_sflV.mjs} +23 -2
  25. package/dist/{kv-cache-K6z1D4HS.cjs → kv-cache-Btp4kC_U.cjs} +1 -1
  26. package/dist/{kv-cache-DJ3q30Nl.js → kv-cache-DVhfMtqE.js} +1 -1
  27. package/dist/{ld-D-oK3e4r.mjs → ld-B_m0qw8j.mjs} +2 -2
  28. package/dist/{middleware-DTIhauqW.mjs → middleware-5qLdPLro.mjs} +15 -15
  29. package/dist/{middleware-ROzi4oVa.mjs → middleware-BYxKsDHj.mjs} +1 -1
  30. package/dist/{middleware-CYAtT9KB.js → middleware-BchkzbpG.js} +25 -5
  31. package/dist/{middleware-IHStfDZ2.cjs → middleware-C7mI18WE.cjs} +26 -6
  32. package/dist/{middleware-RmEidCmR.cjs → middleware-ZKHfZ7zj.cjs} +1 -1
  33. package/dist/mod.cjs +4 -4
  34. package/dist/mod.js +4 -4
  35. package/dist/nodeinfo/client.test.mjs +1 -1
  36. package/dist/nodeinfo/handler.test.mjs +2 -2
  37. package/dist/nodeinfo/types.test.mjs +1 -1
  38. package/dist/otel/exporter.test.mjs +1 -1
  39. package/dist/{outgoing-jsonld-Dc2OXyB-.mjs → outgoing-jsonld-amccRMrV.mjs} +1 -1
  40. package/dist/{owner-CHkNw8Fk.mjs → owner-Dk85kXZz.mjs} +2 -2
  41. package/dist/{proof-BJ_pqvov.js → proof-Bz6IdT2p.js} +1 -1
  42. package/dist/{proof-DC3IlY_8.cjs → proof-ClpE9zhD.cjs} +1 -1
  43. package/dist/{proof-o8Ly9XSp.mjs → proof-DrGrnZVE.mjs} +4 -4
  44. package/dist/{send-Ck74ndlE.mjs → send-Co-E7yJn.mjs} +2 -2
  45. package/dist/sig/http.test.mjs +62 -3
  46. package/dist/sig/key.test.mjs +198 -3
  47. package/dist/sig/ld.test.mjs +2 -2
  48. package/dist/sig/mod.cjs +2 -2
  49. package/dist/sig/mod.js +2 -2
  50. package/dist/sig/owner.test.mjs +1 -1
  51. package/dist/sig/proof.test.mjs +2 -2
  52. package/dist/{temporal-8bTjf1mO.mjs → temporal-Bnwa_2NC.mjs} +1 -1
  53. package/dist/utils/docloader.test.mjs +2 -2
  54. package/dist/utils/mod.cjs +1 -1
  55. package/dist/utils/mod.js +1 -1
  56. package/package.json +5 -5
  57. /package/dist/{activity-listener-IojJ9SVl.mjs → activity-listener-ell7W1s9.mjs} +0 -0
  58. /package/dist/{client-CJ4Y0keQ.mjs → client-9F_u23dc.mjs} +0 -0
  59. /package/dist/{collection-DnoYNwBC.mjs → collection-D-HqUuA2.mjs} +0 -0
  60. /package/dist/{kv-CX8qfaad.mjs → kv-mI4Ix2EU.mjs} +0 -0
  61. /package/dist/{public-audience-CS1udGkN.mjs → public-audience-DpJqzPuh.mjs} +0 -0
  62. /package/dist/{types-s4mCTGkT.mjs → types-J53Kw7so.mjs} +0 -0
@@ -2,8 +2,8 @@ import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { n as RouterError, t as Router } from "./router-CrMLXoOr.mjs";
5
- import { n as version, t as name } from "./deno-duAPwAHH.mjs";
6
- import { t as ActivityListenerSet } from "./activity-listener-IojJ9SVl.mjs";
5
+ import { n as version, t as name } from "./deno-Cya0rbEr.mjs";
6
+ import { t as ActivityListenerSet } from "./activity-listener-ell7W1s9.mjs";
7
7
  import { Tombstone, getTypeId } from "@fedify/vocab";
8
8
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
9
9
  import { getLogger } from "@logtape/logtape";
@@ -59,7 +59,7 @@ var FederationBuilderImpl = class {
59
59
  this.collectionTypeIds = {};
60
60
  }
61
61
  async build(options) {
62
- const { FederationImpl } = await import("./middleware-ROzi4oVa.mjs");
62
+ const { FederationImpl } = await import("./middleware-BYxKsDHj.mjs");
63
63
  const f = new FederationImpl(options);
64
64
  const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
65
65
  f.router = this.router.clone();
@@ -3,7 +3,7 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
5
  import { t as assertStrictEquals } from "../assert_strict_equals-Dmjbg-bA.mjs";
6
- import { n as normalizeAttachmentArrays, r as normalizeOutgoingActivityJsonLd, t as isPreloadedContextAttachmentSafe } from "../outgoing-jsonld-Dc2OXyB-.mjs";
6
+ import { n as normalizeAttachmentArrays, r as normalizeOutgoingActivityJsonLd, t as isPreloadedContextAttachmentSafe } from "../outgoing-jsonld-amccRMrV.mjs";
7
7
  import { mockDocumentLoader, test } from "@fedify/fixture";
8
8
  import { Create, Document, Note, PUBLIC_COLLECTION } from "@fedify/vocab";
9
9
  //#region src/compat/outgoing-jsonld.test.ts
@@ -3,7 +3,7 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
5
  import { t as assertNotEquals } from "../assert_not_equals--wG9hV7u.mjs";
6
- import { t as normalizePublicAudience } from "../public-audience-CS1udGkN.mjs";
6
+ import { t as normalizePublicAudience } from "../public-audience-DpJqzPuh.mjs";
7
7
  import { test } from "@fedify/fixture";
8
8
  import { Create, Follow, Note, PUBLIC_COLLECTION } from "@fedify/vocab";
9
9
  import { getDocumentLoader, preloadedContexts } from "@fedify/vocab-runtime";
@@ -3,8 +3,8 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
5
  import { n as assertInstanceOf, t as assert } from "../assert-BhQd8QHP.mjs";
6
- import { t as MemoryKvStore } from "../kv-CX8qfaad.mjs";
7
- import { n as FederationImpl, v as actorDehydrator, y as autoIdAssigner } from "../middleware-DTIhauqW.mjs";
6
+ import { t as MemoryKvStore } from "../kv-mI4Ix2EU.mjs";
7
+ import { n as FederationImpl, v as actorDehydrator, y as autoIdAssigner } from "../middleware-5qLdPLro.mjs";
8
8
  import { test } from "@fedify/fixture";
9
9
  import { Follow, Person } from "@fedify/vocab";
10
10
  //#region src/compat/transformers.test.ts
@@ -3,6 +3,6 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  //#region deno.json
5
5
  var name = "@fedify/fedify";
6
- var version = "2.2.15";
6
+ var version = "2.2.17";
7
7
  //#endregion
8
8
  export { version as n, name as t };
@@ -1,8 +1,8 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { s as validateCryptoKey } from "./key-5QlWv3sx.mjs";
5
- import { n as doubleKnock } from "./http-DytBXprv.mjs";
4
+ import { s as validateCryptoKey } from "./key-BMHNd0gP.mjs";
5
+ import { n as doubleKnock } from "./http-dobCLGG2.mjs";
6
6
  import { curry } from "es-toolkit";
7
7
  import { FetchError, UrlError, createActivityPubRequest, getRemoteDocument, logRequest, validatePublicUrl } from "@fedify/vocab-runtime";
8
8
  import { getLogger } from "@logtape/logtape";
@@ -6,8 +6,8 @@ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
6
  import { r as assertExists } from "../std__assert-BVFj8-_V.mjs";
7
7
  import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
8
8
  import { t as assertStrictEquals } from "../assert_strict_equals-Dmjbg-bA.mjs";
9
- import { t as MemoryKvStore } from "../kv-CX8qfaad.mjs";
10
- import { n as createFederationBuilder } from "../builder-CcReUrBQ.mjs";
9
+ import { t as MemoryKvStore } from "../kv-mI4Ix2EU.mjs";
10
+ import { n as createFederationBuilder } from "../builder-a-kl29PE.mjs";
11
11
  import { test } from "@fedify/fixture";
12
12
  import { Activity, Note, Person } from "@fedify/vocab";
13
13
  //#region src/federation/builder.test.ts
@@ -3,7 +3,7 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
5
  import "../std__assert-BVFj8-_V.mjs";
6
- import { n as digest, t as buildCollectionSynchronizationHeader } from "../collection-DnoYNwBC.mjs";
6
+ import { n as digest, t as buildCollectionSynchronizationHeader } from "../collection-D-HqUuA2.mjs";
7
7
  import { test } from "@fedify/fixture";
8
8
  import { decodeHex } from "byte-encodings/hex";
9
9
  //#region src/federation/collection.test.ts
@@ -7,14 +7,14 @@ import "../std__assert-BVFj8-_V.mjs";
7
7
  import { t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
8
8
  import { n as assertInstanceOf, t as assert } from "../assert-BhQd8QHP.mjs";
9
9
  import { r as parseAcceptSignature } from "../accept-Dd__NiUL.mjs";
10
- import { a as generateCryptoKeyPair } from "../key-5QlWv3sx.mjs";
11
- import { s as signRequest } from "../http-DytBXprv.mjs";
10
+ import { a as generateCryptoKeyPair } from "../key-BMHNd0gP.mjs";
11
+ import { s as signRequest } from "../http-dobCLGG2.mjs";
12
12
  import { a as rsaPrivateKey3, c as rsaPublicKey3, s as rsaPublicKey2 } from "../keys-BAK-tUlf.mjs";
13
- import { a as compactJsonLd, p as signJsonLd } from "../ld-D-oK3e4r.mjs";
14
- import { r as signObject } from "../proof-o8Ly9XSp.mjs";
15
- import { t as MemoryKvStore } from "../kv-CX8qfaad.mjs";
16
- import { c as handleActor, d as handleInbox, f as handleObject, h as respondWithObjectIfAcceptable, l as handleCollection, m as respondWithObject, o as createFederation, p as handleOutbox, u as handleCustomCollection } from "../middleware-DTIhauqW.mjs";
17
- import { t as ActivityListenerSet } from "../activity-listener-IojJ9SVl.mjs";
13
+ import { t as MemoryKvStore } from "../kv-mI4Ix2EU.mjs";
14
+ import { a as compactJsonLd, p as signJsonLd } from "../ld-B_m0qw8j.mjs";
15
+ import { r as signObject } from "../proof-DrGrnZVE.mjs";
16
+ import { c as handleActor, d as handleInbox, f as handleObject, h as respondWithObjectIfAcceptable, l as handleCollection, m as respondWithObject, o as createFederation, p as handleOutbox, u as handleCustomCollection } from "../middleware-5qLdPLro.mjs";
17
+ import { t as ActivityListenerSet } from "../activity-listener-ell7W1s9.mjs";
18
18
  import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
19
19
  import { Activity, Create, CryptographicKey, Multikey, Note, Person, Tombstone } from "@fedify/vocab";
20
20
  import { FetchError } from "@fedify/vocab-runtime";
@@ -4,9 +4,9 @@ globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
5
  import "../std__assert-BVFj8-_V.mjs";
6
6
  import { n as ed25519PrivateKey, r as ed25519PublicKey, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
7
- import { r as signObject } from "../proof-o8Ly9XSp.mjs";
8
- import { t as MemoryKvStore } from "../kv-CX8qfaad.mjs";
9
- import { o as createFederation } from "../middleware-DTIhauqW.mjs";
7
+ import { t as MemoryKvStore } from "../kv-mI4Ix2EU.mjs";
8
+ import { r as signObject } from "../proof-DrGrnZVE.mjs";
9
+ import { o as createFederation } from "../middleware-5qLdPLro.mjs";
10
10
  import { mockDocumentLoader, test } from "@fedify/fixture";
11
11
  import { Create, Follow, Person } from "@fedify/vocab";
12
12
  //#region src/federation/idempotency.test.ts
@@ -3,7 +3,7 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
5
  import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
6
- import { t as ActivityListenerSet } from "../activity-listener-IojJ9SVl.mjs";
6
+ import { t as ActivityListenerSet } from "../activity-listener-ell7W1s9.mjs";
7
7
  import { test } from "@fedify/fixture";
8
8
  import { Activity, Create, Invite, Offer, Update } from "@fedify/vocab";
9
9
  //#region src/federation/inbox.test.ts
@@ -3,8 +3,8 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
5
  import { n as assertInstanceOf, t as assert } from "../assert-BhQd8QHP.mjs";
6
- import { t as MemoryKvStore } from "../kv-CX8qfaad.mjs";
7
- import { t as KvKeyCache } from "../keycache-C1aVprwy.mjs";
6
+ import { t as KvKeyCache } from "../keycache-Dkc_sflV.mjs";
7
+ import { t as MemoryKvStore } from "../kv-mI4Ix2EU.mjs";
8
8
  import { test } from "@fedify/fixture";
9
9
  import { CryptographicKey, Multikey } from "@fedify/vocab";
10
10
  //#region src/federation/keycache.test.ts
@@ -101,6 +101,37 @@ test("KvKeyCache fetch error metadata", async () => {
101
101
  await cache.setFetchError(keyId, null);
102
102
  assertEquals(await cache.getFetchError(keyId), void 0);
103
103
  });
104
+ test("KvKeyCache reads legacy fetch errors", async () => {
105
+ const kv = new MemoryKvStore();
106
+ const keyId = new URL("https://example.com/key");
107
+ await kv.set([
108
+ "pk",
109
+ "__fetchError",
110
+ keyId.href
111
+ ], {
112
+ errorName: "FetchError",
113
+ errorMessage: "Legacy failure"
114
+ });
115
+ const result = await new KvKeyCache(kv, ["pk"]).getFetchError(keyId);
116
+ assert(result != null && "error" in result);
117
+ assertEquals(result.error.constructor, Error);
118
+ assertEquals(result.error.name, "FetchError");
119
+ assertEquals(result.error.message, "Legacy failure");
120
+ assertEquals(result.error.cause, void 0);
121
+ });
122
+ test("KvKeyCache keeps unknown error types generic", async () => {
123
+ class CustomError extends Error {}
124
+ const kv = new MemoryKvStore();
125
+ const keyId = new URL("https://example.com/key");
126
+ const error = new CustomError("Custom failure");
127
+ error.name = "FetchError";
128
+ await new KvKeyCache(kv, ["pk"]).setFetchError(keyId, { error });
129
+ const result = await new KvKeyCache(kv, ["pk"]).getFetchError(keyId);
130
+ assert(result != null && "error" in result);
131
+ assertEquals(result.error.constructor, Error);
132
+ assertEquals(result.error.name, "FetchError");
133
+ assertEquals(result.error.message, "Custom failure");
134
+ });
104
135
  test("KvKeyCache unavailable entries expire", async () => {
105
136
  const cache = new KvKeyCache(new MemoryKvStore(), ["pk"], { unavailableKeyTtl: Temporal.Duration.from({ milliseconds: 1 }) });
106
137
  const keyId = new URL("https://example.com/expired");
@@ -3,7 +3,7 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
5
  import "../std__assert-BVFj8-_V.mjs";
6
- import { t as MemoryKvStore } from "../kv-CX8qfaad.mjs";
6
+ import { t as MemoryKvStore } from "../kv-mI4Ix2EU.mjs";
7
7
  import { test } from "@fedify/fixture";
8
8
  //#region src/federation/kv.test.ts
9
9
  test("MemoryKvStore", async (t) => {
@@ -10,14 +10,14 @@ import { n as assertInstanceOf, t as assert } from "../assert-BhQd8QHP.mjs";
10
10
  import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
11
11
  import { t as assertNotEquals } from "../assert_not_equals--wG9hV7u.mjs";
12
12
  import { t as assertStrictEquals } from "../assert_strict_equals-Dmjbg-bA.mjs";
13
- import { l as verifyRequest, s as signRequest } from "../http-DytBXprv.mjs";
13
+ import { l as verifyRequest, s as signRequest } from "../http-dobCLGG2.mjs";
14
14
  import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
15
- import { t as getAuthenticatedDocumentLoader } from "../docloader-DI88Lx6y.mjs";
16
- import { a as compactJsonLd, h as verifyJsonLd, p as signJsonLd, s as detachSignature } from "../ld-D-oK3e4r.mjs";
17
- import { t as doesActorOwnKey } from "../owner-CHkNw8Fk.mjs";
18
- import { i as verifyObject, r as signObject } from "../proof-o8Ly9XSp.mjs";
19
- import { t as MemoryKvStore } from "../kv-CX8qfaad.mjs";
20
- import { i as KvSpecDeterminer, n as FederationImpl, o as createFederation, r as InboxContextImpl, t as ContextImpl } from "../middleware-DTIhauqW.mjs";
15
+ import { t as getAuthenticatedDocumentLoader } from "../docloader-Dz0Z1Y07.mjs";
16
+ import { t as MemoryKvStore } from "../kv-mI4Ix2EU.mjs";
17
+ import { a as compactJsonLd, h as verifyJsonLd, p as signJsonLd, s as detachSignature } from "../ld-B_m0qw8j.mjs";
18
+ import { t as doesActorOwnKey } from "../owner-Dk85kXZz.mjs";
19
+ import { i as verifyObject, r as signObject } from "../proof-DrGrnZVE.mjs";
20
+ import { i as KvSpecDeterminer, n as FederationImpl, o as createFederation, r as InboxContextImpl, t as ContextImpl } from "../middleware-5qLdPLro.mjs";
21
21
  import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
22
22
  import * as vocab from "@fedify/vocab";
23
23
  import { Create, Offer, Person, getTypeId, lookupObject } from "@fedify/vocab";
@@ -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-IHStfDZ2.cjs");
5
+ const require_middleware = require("../middleware-C7mI18WE.cjs");
6
6
  let es_toolkit = require("es-toolkit");
7
7
  //#region src/federation/kv.ts
8
8
  /**
@@ -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-CYAtT9KB.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-BchkzbpG.js";
4
4
  import { isEqual } from "es-toolkit";
5
5
  //#region src/federation/kv.ts
6
6
  /**
@@ -7,10 +7,10 @@ import "../std__assert-BVFj8-_V.mjs";
7
7
  import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
8
8
  import { n as assertInstanceOf, t as assert } from "../assert-BhQd8QHP.mjs";
9
9
  import { t as assertNotEquals } from "../assert_not_equals--wG9hV7u.mjs";
10
- import { l as verifyRequest } from "../http-DytBXprv.mjs";
10
+ import { l as verifyRequest } from "../http-dobCLGG2.mjs";
11
11
  import { i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
12
- import { t as doesActorOwnKey } from "../owner-CHkNw8Fk.mjs";
13
- import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-Ck74ndlE.mjs";
12
+ import { t as doesActorOwnKey } from "../owner-Dk85kXZz.mjs";
13
+ import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-Co-E7yJn.mjs";
14
14
  import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
15
15
  import { Activity, Application, Endpoints, Group, Person, Service } from "@fedify/vocab";
16
16
  import { FetchError, UrlError } from "@fedify/vocab-runtime";
@@ -4,7 +4,7 @@ globalThis.addEventListener = () => {};
4
4
  import "../std__assert-BVFj8-_V.mjs";
5
5
  import { n as assertFalse } from "../assert_rejects-B-qJtC9Z.mjs";
6
6
  import { t as assert } from "../assert-BhQd8QHP.mjs";
7
- import { t as hasMalformedKnownTemporalLiteral } from "../temporal-8bTjf1mO.mjs";
7
+ import { t as hasMalformedKnownTemporalLiteral } from "../temporal-Bnwa_2NC.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 () => {
@@ -4,8 +4,8 @@ globalThis.addEventListener = () => {};
4
4
  import { r as createRequestContext } from "../context-Dk_tacqz.mjs";
5
5
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
6
  import "../std__assert-BVFj8-_V.mjs";
7
- import { t as MemoryKvStore } from "../kv-CX8qfaad.mjs";
8
- import { o as createFederation, s as handleWebFinger } from "../middleware-DTIhauqW.mjs";
7
+ import { t as MemoryKvStore } from "../kv-mI4Ix2EU.mjs";
8
+ import { o as createFederation, s as handleWebFinger } from "../middleware-5qLdPLro.mjs";
9
9
  import { test } from "@fedify/fixture";
10
10
  import { Image, Link, Person, Tombstone } from "@fedify/vocab";
11
11
  //#region src/federation/webfinger.test.ts
@@ -11,7 +11,7 @@ let _opentelemetry_semantic_conventions = require("@opentelemetry/semantic-conve
11
11
  let byte_encodings_base64 = require("byte-encodings/base64");
12
12
  //#region deno.json
13
13
  var name = "@fedify/fedify";
14
- var version = "2.2.15";
14
+ var version = "2.2.17";
15
15
  //#endregion
16
16
  //#region src/sig/accept.ts
17
17
  /**
@@ -153,6 +153,64 @@ function fulfillAcceptSignature(entry, localKeyId, localAlg) {
153
153
  }
154
154
  //#endregion
155
155
  //#region src/sig/key.ts
156
+ /** Classifies decoding failures without hiding unexpected loader errors. */
157
+ function classifyKeyJsonLdError(error, seen = /* @__PURE__ */ new Set()) {
158
+ if (!(error instanceof Error) || !error.name.startsWith("jsonld.")) return null;
159
+ if (seen.has(error)) throw error;
160
+ seen.add(error);
161
+ const details = error.details;
162
+ if (typeof details?.code !== "string") return null;
163
+ if (details.code !== "loading remote context failed" || !("cause" in details) && !("cause" in error)) return "invalid";
164
+ const cause = "cause" in details ? details.cause : error.cause;
165
+ const nestedFailure = classifyKeyJsonLdError(cause, seen);
166
+ if (nestedFailure != null) return nestedFailure;
167
+ if (cause instanceof SyntaxError) return "invalid";
168
+ if (cause instanceof _fedify_vocab_runtime.FetchError || cause instanceof _fedify_vocab_runtime.UrlError) return "fetch";
169
+ if (cause instanceof Error && [
170
+ "AbortError",
171
+ "TimeoutError",
172
+ "NetworkError"
173
+ ].includes(cause.name)) return "fetch";
174
+ if (cause instanceof TypeError) {
175
+ const urlCode = cause.code;
176
+ if (cause.name === "InvalidContextReferenceError") return "invalid";
177
+ if (urlCode === "ERR_INVALID_URL" || cause.message === "Invalid URL string." || /^Invalid URL(?::|$)/.test(cause.message) || / cannot be parsed as a URL\.?$/.test(cause.message)) return typeof details.url === "string" && /^[A-Za-z][A-Za-z0-9+.-]*:/.test(details.url) && !URL.canParse(details.url) ? "invalid" : "fetch";
178
+ const networkCause = cause.cause;
179
+ const code = cause.code ?? networkCause?.code;
180
+ if (typeof code === "string" && [
181
+ "ECONNREFUSED",
182
+ "ECONNRESET",
183
+ "ECONNABORTED",
184
+ "ETIMEDOUT",
185
+ "EHOSTUNREACH",
186
+ "ENETUNREACH",
187
+ "ENOTFOUND",
188
+ "EAI_AGAIN",
189
+ "UND_ERR_CONNECT_TIMEOUT",
190
+ "UND_ERR_HEADERS_TIMEOUT",
191
+ "UND_ERR_BODY_TIMEOUT",
192
+ "UND_ERR_SOCKET"
193
+ ].includes(code) || /^(fetch failed|Failed to fetch|error sending request|error reading a body from connection|Unable to connect|ConnectionRefused|Network connection lost|The socket connection was closed unexpectedly)/.test(cause.message)) return "fetch";
194
+ }
195
+ throw cause;
196
+ }
197
+ /** Carries a context transport failure through the key decoding boundary. */
198
+ var KeyContextFetchError = class extends Error {
199
+ constructor(error) {
200
+ super("Failed to fetch a key's JSON-LD context.", { cause: error });
201
+ this.error = error;
202
+ }
203
+ };
204
+ function contextFetchError(error) {
205
+ const seen = /* @__PURE__ */ new Set();
206
+ while (error instanceof Error && !seen.has(error)) {
207
+ seen.add(error);
208
+ const details = error.details;
209
+ if (!error.name.startsWith("jsonld.") || details?.code !== "loading remote context failed") break;
210
+ error = "cause" in details ? details.cause : error.cause;
211
+ }
212
+ return new KeyContextFetchError(error);
213
+ }
156
214
  /**
157
215
  * Checks if the given key is valid and supported. No-op if the key is valid,
158
216
  * otherwise throws an error.
@@ -247,6 +305,9 @@ async function importJwk(jwk, type) {
247
305
  * @internal
248
306
  */
249
307
  async function fetchActorDocument(actorId, options = {}) {
308
+ return await fetchActorDocumentInternal(actorId, options, false);
309
+ }
310
+ async function fetchActorDocumentInternal(actorId, options, propagateContextFetchErrors) {
250
311
  const logger = (0, _logtape_logtape.getLogger)([
251
312
  "fedify",
252
313
  "sig",
@@ -277,9 +338,12 @@ async function fetchActorDocument(actorId, options = {}) {
277
338
  baseUrl: documentUrl
278
339
  });
279
340
  } catch (error) {
280
- if (!(error instanceof TypeError)) throw error;
281
- logger.debug("The document served at {documentUrl} is not a valid object: {error}", {
341
+ const failure = classifyKeyJsonLdError(error);
342
+ if (failure === "fetch" && propagateContextFetchErrors) throw contextFetchError(error);
343
+ if (failure == null && !(error instanceof TypeError)) throw error;
344
+ logger.debug("Failed to decode the actor document at {documentUrl}: {error}", {
282
345
  documentUrl: documentUrl.href,
346
+ failure: failure ?? "invalid",
283
347
  error
284
348
  });
285
349
  return null;
@@ -318,6 +382,9 @@ async function fetchActorDocument(actorId, options = {}) {
318
382
  * @internal
319
383
  */
320
384
  async function verifyKeyOwnership(key, options = {}) {
385
+ return await verifyKeyOwnershipInternal(key, options, false);
386
+ }
387
+ async function verifyKeyOwnershipInternal(key, options, propagateContextFetchErrors) {
321
388
  const logger = (0, _logtape_logtape.getLogger)([
322
389
  "fedify",
323
390
  "sig",
@@ -327,7 +394,7 @@ async function verifyKeyOwnership(key, options = {}) {
327
394
  if (keyId == null) return null;
328
395
  const claimedOwnerId = key instanceof _fedify_vocab.CryptographicKey ? key.ownerId : key.controllerId;
329
396
  if (claimedOwnerId == null) return null;
330
- const owner = await fetchActorDocument(claimedOwnerId, options);
397
+ const owner = await fetchActorDocumentInternal(claimedOwnerId, options, propagateContextFetchErrors);
331
398
  if (owner == null) {
332
399
  logger.debug("The owner ({claimedOwnerId}) that key {keyId} claims could not be resolved.", {
333
400
  keyId: keyId.href,
@@ -479,6 +546,21 @@ async function resolveFetchedKey(document, cacheKey, documentUrl, keyId, cls, {
479
546
  tracerProvider
480
547
  });
481
548
  } catch (e) {
549
+ const failure = classifyKeyJsonLdError(e);
550
+ if (failure === "fetch") throw contextFetchError(e);
551
+ if (failure != null) {
552
+ logger.debug("Failed to decode key {keyId}: {error}", {
553
+ keyId,
554
+ failure,
555
+ error: e
556
+ });
557
+ await keyCache?.set(cacheKey, null);
558
+ await clearFetchErrorMetadata(cacheKey, keyCache);
559
+ return {
560
+ key: null,
561
+ cached: false
562
+ };
563
+ }
482
564
  if (!(e instanceof TypeError)) throw e;
483
565
  try {
484
566
  object = await cls.fromJsonLd(document, {
@@ -487,8 +569,14 @@ async function resolveFetchedKey(document, cacheKey, documentUrl, keyId, cls, {
487
569
  tracerProvider
488
570
  });
489
571
  } catch (e) {
490
- if (e instanceof TypeError) {
491
- logger.debug("Failed to verify; key {keyId} returned an invalid object.", { keyId });
572
+ const failure = classifyKeyJsonLdError(e);
573
+ if (failure === "fetch") throw contextFetchError(e);
574
+ if (failure != null || e instanceof TypeError) {
575
+ logger.debug("Failed to decode key {keyId}: {error}", {
576
+ keyId,
577
+ failure: failure ?? "invalid",
578
+ error: e
579
+ });
492
580
  await keyCache?.set(cacheKey, null);
493
581
  await clearFetchErrorMetadata(cacheKey, keyCache);
494
582
  return {
@@ -580,16 +668,17 @@ async function resolveFetchedKey(document, cacheKey, documentUrl, keyId, cls, {
580
668
  const claimedOwnerId = key instanceof _fedify_vocab.CryptographicKey ? key.ownerId : key.controllerId;
581
669
  if (ownerDocument != null && claimedOwnerId == null) key = key instanceof _fedify_vocab.CryptographicKey ? key.clone({ owner: ownerDocument.id }) : key.clone({ controller: ownerDocument.id });
582
670
  else if (claimedOwnerId != null && claimedOwnerId.href !== ownerDocument?.id?.href) {
583
- if (await verifyKeyOwnership(key, {
671
+ if (await verifyKeyOwnershipInternal(key, {
584
672
  documentLoader,
585
673
  contextLoader,
586
674
  tracerProvider
587
- }) == null) {
675
+ }, true) == null) {
588
676
  logger.debug("Failed to verify; the owner {claimedOwnerId} that key {keyId} claims does not list the key as its own.", {
589
677
  keyId,
590
678
  claimedOwnerId: claimedOwnerId.href
591
679
  });
592
680
  await keyCache?.set(cacheKey, null);
681
+ await clearFetchErrorMetadata(cacheKey, keyCache);
593
682
  return {
594
683
  key: null,
595
684
  cached: false
@@ -627,7 +716,12 @@ async function fetchKeyWithResult(cacheKey, cls, options, onCachedUnavailable, o
627
716
  } catch (error) {
628
717
  return await onFetchError(error, cacheKey, keyId, keyCache, logger);
629
718
  }
630
- return await resolveFetchedKey(document, cacheKey, documentUrl, keyId, cls, options, logger);
719
+ try {
720
+ return await resolveFetchedKey(document, cacheKey, documentUrl, keyId, cls, options, logger);
721
+ } catch (error) {
722
+ if (!(error instanceof KeyContextFetchError)) throw error;
723
+ return await onFetchError(error.error, cacheKey, keyId, keyCache, logger);
724
+ }
631
725
  }
632
726
  async function fetchKeyInternal(keyId, cls, options = {}) {
633
727
  return await fetchKeyWithResult(typeof keyId === "string" ? new URL(keyId) : keyId, cls, options, (_cacheKey, _keyId, _keyCache, _logger) => {