@fedify/fedify 2.4.2 → 2.4.4

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 (83) hide show
  1. package/dist/{builder-9ovCSqLp.mjs → builder-DdY0E0w9.mjs} +2 -2
  2. package/dist/compat/transformers.test.mjs +1 -1
  3. package/dist/{compound-proof-G2J_bU0u.mjs → compound-proof-fxkyiXYM.mjs} +2 -2
  4. package/dist/{deno-BZ4z-lJJ.mjs → deno-CO1X_K_q.mjs} +1 -1
  5. package/dist/{docloader-DUXXI-7G.mjs → docloader-DFB_TNVp.mjs} +6 -2
  6. package/dist/federation/builder.test.mjs +1 -1
  7. package/dist/federation/compound-fanout.test.mjs +3 -3
  8. package/dist/federation/handler-compound-proof.test.mjs +5 -5
  9. package/dist/federation/handler.test.mjs +258 -5
  10. package/dist/federation/hashlink-media.test.mjs +2 -2
  11. package/dist/federation/idempotency.test.mjs +2 -2
  12. package/dist/federation/inbox-report.test.mjs +5 -5
  13. package/dist/federation/inbox.test.mjs +43 -0
  14. package/dist/federation/keycache.test.mjs +20 -9
  15. package/dist/federation/metrics.test.mjs +1 -1
  16. package/dist/federation/middleware.test.mjs +173 -11
  17. package/dist/federation/mod.cjs +1 -1
  18. package/dist/federation/mod.js +1 -1
  19. package/dist/federation/outgoing-proof.test.mjs +4 -4
  20. package/dist/federation/portable-actor.test.mjs +3 -3
  21. package/dist/federation/portable-chain.test.mjs +3 -3
  22. package/dist/federation/portable-collection.test.mjs +4 -4
  23. package/dist/federation/portable-delivery.test.mjs +2 -2
  24. package/dist/federation/portable-gateway-keys.test.mjs +5 -5
  25. package/dist/federation/portable-inbox.test.mjs +4 -4
  26. package/dist/federation/portable-parse-uri.test.mjs +1 -1
  27. package/dist/federation/portable-route-activity.test.mjs +2 -2
  28. package/dist/federation/portable.test.mjs +3 -3
  29. package/dist/federation/send.test.mjs +3 -3
  30. package/dist/federation/tasks/enqueue.test.mjs +1 -1
  31. package/dist/federation/tasks/tasks.test.mjs +2 -2
  32. package/dist/federation/temporal.test.mjs +1 -1
  33. package/dist/federation/webfinger.test.mjs +1 -1
  34. package/dist/{federation-DpT8bDM6.cjs → federation-Bf4FEork.cjs} +122 -21
  35. package/dist/{http-Qq7jR2rC.js → http-D_AGUmSq.js} +17 -3
  36. package/dist/{http-B5w_qcIg.mjs → http-DkLKT8Vp.mjs} +4 -4
  37. package/dist/{http-x1satM4y.cjs → http-g5f1D2tm.cjs} +17 -3
  38. package/dist/inbox-Di1-EKqa.mjs +188 -0
  39. package/dist/{keycache-D-MNltOk.mjs → keycache-N2opu4-3.mjs} +1 -1
  40. package/dist/{kv-cache-BgQMAKIg.mjs → kv-cache-BxfOpUP9.mjs} +1 -1
  41. package/dist/{kv-cache-B0SZfzFb.js → kv-cache-C0AsMZ4U.js} +5 -1
  42. package/dist/{kv-cache-D4throaQ.cjs → kv-cache-HsXADkl9.cjs} +5 -1
  43. package/dist/{ld-Dkkyk65e.mjs → ld-Cy86r-Ty.mjs} +18 -4
  44. package/dist/{metrics-CRv6_IBg.mjs → metrics-BguhdXt-.mjs} +1 -1
  45. package/dist/{middleware-BqefXH6B.js → middleware-BOBF7req.js} +122 -21
  46. package/dist/{middleware-DFtNaBcH.mjs → middleware-BYojyPi4.mjs} +1 -1
  47. package/dist/{middleware-C-swet0z.mjs → middleware-C_gtR3fV.mjs} +104 -180
  48. package/dist/mod.cjs +4 -4
  49. package/dist/mod.js +4 -4
  50. package/dist/nodeinfo/handler.test.mjs +1 -1
  51. package/dist/{owner-BHUhedVc.mjs → owner-Dc-Lg_Xn.mjs} +3 -3
  52. package/dist/{portable-collection-DL-1Wy1s.cjs → portable-collection-Bl2UkqcO.cjs} +1 -1
  53. package/dist/{portable-collection-CfIc190c.js → portable-collection-CjdP7fQ4.js} +1 -1
  54. package/dist/{portable-collection-DONEPTXV.mjs → portable-collection-DSKqMgvr.mjs} +2 -2
  55. package/dist/{portable-key-Cdw3vfl-.mjs → portable-key-ClXZ25LT.mjs} +1 -1
  56. package/dist/{proof-DuSE1ABD.mjs → proof-kJtQ49gr.mjs} +3 -3
  57. package/dist/{send-D9oTjA6A.mjs → send-D6hcL5qf.mjs} +3 -3
  58. package/dist/sig/compound-proof-discovery.test.mjs +1 -1
  59. package/dist/sig/compound-proof-producer.test.mjs +1 -1
  60. package/dist/sig/compound-proof-verification.test.mjs +2 -2
  61. package/dist/sig/compound-proof.test.mjs +2 -2
  62. package/dist/sig/http.test.mjs +3 -3
  63. package/dist/sig/key.test.mjs +196 -1
  64. package/dist/sig/ld.test.mjs +46 -1
  65. package/dist/sig/mitra-receive-interop.test.mjs +4 -4
  66. package/dist/sig/mitra-send-interop.test.mjs +3 -3
  67. package/dist/sig/mod.cjs +2 -2
  68. package/dist/sig/mod.js +2 -2
  69. package/dist/sig/owner.test.mjs +46 -1
  70. package/dist/sig/portable-collection.test.mjs +1 -1
  71. package/dist/sig/portable-interop.test.mjs +3 -3
  72. package/dist/sig/portable-key.test.mjs +6 -6
  73. package/dist/sig/proof.test.mjs +54 -3
  74. package/dist/sig/tootik-request-interop.test.mjs +4 -4
  75. package/dist/sig/tootik-send-interop.test.mjs +3 -3
  76. package/dist/sig/verification.test.mjs +3 -3
  77. package/dist/{temporal-iyAxBq0I.mjs → temporal-C8WqyM34.mjs} +1 -1
  78. package/dist/testing/kv.test.mjs +1 -1
  79. package/dist/utils/docloader.test.mjs +176 -37
  80. package/dist/utils/kv-cache.test.mjs +1 -1
  81. package/dist/utils/mod.cjs +1 -1
  82. package/dist/utils/mod.js +1 -1
  83. package/package.json +6 -6
@@ -5,7 +5,7 @@ import { r as createRequestContext } from "../context-8Tu9kea0.mjs";
5
5
  import { t as MemoryKvStore } from "../kv-DCHkaJ9-.mjs";
6
6
  import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
7
7
  import "../std__assert-DvMDRPes.mjs";
8
- import { D as handleNodeInfoJrd, E as handleNodeInfo, o as createFederation } from "../middleware-C-swet0z.mjs";
8
+ import { D as handleNodeInfoJrd, E as handleNodeInfo, o as createFederation } from "../middleware-C_gtR3fV.mjs";
9
9
  import { test } from "@fedify/fixture";
10
10
  //#region src/nodeinfo/handler.test.ts
11
11
  test("handleNodeInfo()", async () => {
@@ -2,10 +2,10 @@ import "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { d as isPortableUri, l as isPortableId, n as getCanonicalPortableId, p as isSamePublicKey$1, s as isCompatibleKeyId } from "./portable-key-id-Ca30-hOa.mjs";
5
- import { n as version, t as name } from "./deno-BZ4z-lJJ.mjs";
5
+ import { n as version, t as name } from "./deno-CO1X_K_q.mjs";
6
6
  import { i as parseKeyOwnerEvidence, r as getVerifiedKeyOwnerEvidence } from "./key-owner-evidence-APB6NpSk.mjs";
7
- import { E as verifyKeyOwnership, b as fetchActorDocument, y as exportJwk } from "./ld-Dkkyk65e.mjs";
8
- import { n as resolvePortableActorKey, t as fetchPortableGatewayKey } from "./portable-key-Cdw3vfl-.mjs";
7
+ import { E as verifyKeyOwnership, b as fetchActorDocument, y as exportJwk } from "./ld-Cy86r-Ty.mjs";
8
+ import { n as resolvePortableActorKey, t as fetchPortableGatewayKey } from "./portable-key-ClXZ25LT.mjs";
9
9
  import { getLogger } from "@logtape/logtape";
10
10
  import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
11
11
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
@@ -1,5 +1,5 @@
1
1
  const { URLPattern } = require("urlpattern-polyfill");
2
- const require_http = require("./http-x1satM4y.cjs");
2
+ const require_http = require("./http-g5f1D2tm.cjs");
3
3
  let _logtape_logtape = require("@logtape/logtape");
4
4
  let _fedify_vocab = require("@fedify/vocab");
5
5
  let _opentelemetry_api = require("@opentelemetry/api");
@@ -1,6 +1,6 @@
1
1
  import { Temporal } from "temporal-polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { At as isPortableUri, B as fetchActorDocument, Dt as isCompatibleKeyId, J as getVerifiedKeyOwnerEvidence, K as verifyKeyOwnership, Mt as isSamePublicKey$1, Nt as name, Ot as isPortableId, Pt as version, St as getCanonicalPortableId, Y as parseKeyOwnerEvidence, b as verifyPortableObjectProofWithRoot, l as fetchPortableGatewayKey, u as resolvePortableActorKey, v as verifyPortableObjectProof, z as exportJwk } from "./http-Qq7jR2rC.js";
3
+ import { At as isPortableUri, B as fetchActorDocument, Dt as isCompatibleKeyId, J as getVerifiedKeyOwnerEvidence, K as verifyKeyOwnership, Mt as isSamePublicKey$1, Nt as name, Ot as isPortableId, Pt as version, St as getCanonicalPortableId, Y as parseKeyOwnerEvidence, b as verifyPortableObjectProofWithRoot, l as fetchPortableGatewayKey, u as resolvePortableActorKey, v as verifyPortableObjectProof, z as exportJwk } from "./http-D_AGUmSq.js";
4
4
  import { getLogger } from "@logtape/logtape";
5
5
  import { CollectionPage, CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
6
6
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
@@ -1,8 +1,8 @@
1
1
  import "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-BZ4z-lJJ.mjs";
5
- import { c as verifyPortableObjectProof, u as verifyPortableObjectProofWithRoot } from "./proof-DuSE1ABD.mjs";
4
+ import { n as version, t as name } from "./deno-CO1X_K_q.mjs";
5
+ import { c as verifyPortableObjectProof, u as verifyPortableObjectProofWithRoot } from "./proof-kJtQ49gr.mjs";
6
6
  import { getLogger } from "@logtape/logtape";
7
7
  import { CollectionPage, Object as Object$1, isActor } from "@fedify/vocab";
8
8
  import { trace } from "@opentelemetry/api";
@@ -2,7 +2,7 @@ import "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { a as getRawCanonicalPortableId, c as isPortableActorDocument, d as isPortableUri, n as getCanonicalPortableId, p as isSamePublicKey } from "./portable-key-id-Ca30-hOa.mjs";
5
- import { u as verifyPortableObjectProofWithRoot } from "./proof-DuSE1ABD.mjs";
5
+ import { u as verifyPortableObjectProofWithRoot } from "./proof-kJtQ49gr.mjs";
6
6
  import { getLogger } from "@logtape/logtape";
7
7
  import { CryptographicKey, Multikey, Object as Object$1 } from "@fedify/vocab";
8
8
  import { FetchError, formatIri, getDocumentLoader, isGatewayUrl, parseIri, toCompatibleEf61Id } from "@fedify/vocab-runtime";
@@ -3,9 +3,9 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { i as getPortableDid, l as isPortableId } from "./portable-key-id-Ca30-hOa.mjs";
5
5
  import { a as verificationObservation, i as triedKey, n as observeCheck, t as observeAttempt } from "./verification-Dpfcw8ml.mjs";
6
- import { n as version, t as name } from "./deno-BZ4z-lJJ.mjs";
7
- import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-CRv6_IBg.mjs";
8
- import { T as validateCryptoKey, c as getNormalizationContextLoader, v as bypassKeyCacheReads, x as fetchKey } from "./ld-Dkkyk65e.mjs";
6
+ import { n as version, t as name } from "./deno-CO1X_K_q.mjs";
7
+ import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-BguhdXt-.mjs";
8
+ import { T as validateCryptoKey, c as getNormalizationContextLoader, v as bypassKeyCacheReads, x as fetchKey } from "./ld-Cy86r-Ty.mjs";
9
9
  import { n as preloadedOnlyDocumentLoader } from "./public-audience--klBIOk1.mjs";
10
10
  import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-4IJqPYos.mjs";
11
11
  import { getLogger } from "@logtape/logtape";
@@ -2,9 +2,9 @@ import "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { d as isPortableUri } from "./portable-key-id-Ca30-hOa.mjs";
5
- import { n as version, t as name } from "./deno-BZ4z-lJJ.mjs";
6
- import { n as getDurationMs, r as getFederationMetrics } from "./metrics-CRv6_IBg.mjs";
7
- import { n as doubleKnock } from "./http-B5w_qcIg.mjs";
5
+ import { n as version, t as name } from "./deno-CO1X_K_q.mjs";
6
+ import { n as getDurationMs, r as getFederationMetrics } from "./metrics-BguhdXt-.mjs";
7
+ import { n as doubleKnock } from "./http-DkLKT8Vp.mjs";
8
8
  import { getLogger } from "@logtape/logtape";
9
9
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
10
10
  import { FetchError, UrlError, canonicalizePortableUri, getFe34Origin, isGatewayUrl, toCompatibleEf61Id, validatePublicUrl } from "@fedify/vocab-runtime";
@@ -3,7 +3,7 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
5
5
  import "../std__assert-DvMDRPes.mjs";
6
- import { a as inspectCompoundPortableObjectApplicability, n as discoverCompoundProofDocuments } from "../compound-proof-G2J_bU0u.mjs";
6
+ import { a as inspectCompoundPortableObjectApplicability, n as discoverCompoundProofDocuments } from "../compound-proof-fxkyiXYM.mjs";
7
7
  import { t as map_local_create_note_default } from "../map-local-create-note-B0SeXJms.mjs";
8
8
  import { test } from "@fedify/fixture";
9
9
  //#region src/sig/compound-proof-discovery.test.ts
@@ -3,7 +3,7 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
5
5
  import "../std__assert-DvMDRPes.mjs";
6
- import { a as inspectCompoundPortableObjectApplicability, i as findUnsupportedCompoundProofShape, t as containsCompoundPortableObject } from "../compound-proof-G2J_bU0u.mjs";
6
+ import { a as inspectCompoundPortableObjectApplicability, i as findUnsupportedCompoundProofShape, t as containsCompoundPortableObject } from "../compound-proof-fxkyiXYM.mjs";
7
7
  import { test } from "@fedify/fixture";
8
8
  //#region src/sig/compound-proof-producer.test.ts
9
9
  const portableId = "ap+ef61://did:key:z6MkAlice/objects/1";
@@ -4,9 +4,9 @@ globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
5
5
  import "../std__assert-DvMDRPes.mjs";
6
6
  import { t as assert } from "../assert-D1Eafmd_.mjs";
7
- import { l as verifyPortableObjectProofPolicy, o as verifyMapLocalProof } from "../proof-DuSE1ABD.mjs";
7
+ import { l as verifyPortableObjectProofPolicy, o as verifyMapLocalProof } from "../proof-kJtQ49gr.mjs";
8
8
  import { n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2 } from "../keys-DIJNHW-Y.mjs";
9
- import { a as inspectCompoundPortableObjectApplicability, o as verifyCompoundPortableObjectProofs, s as verifyCompoundProofDocuments, t as containsCompoundPortableObject } from "../compound-proof-G2J_bU0u.mjs";
9
+ import { a as inspectCompoundPortableObjectApplicability, o as verifyCompoundPortableObjectProofs, s as verifyCompoundProofDocuments, t as containsCompoundPortableObject } from "../compound-proof-fxkyiXYM.mjs";
10
10
  import { t as map_local_create_note_default } from "../map-local-create-note-B0SeXJms.mjs";
11
11
  import { t as map_local_context_conflict_default } from "../map-local-context-conflict-DOYEEJ3u.mjs";
12
12
  import { CryptographicKey, Multikey, Person } from "@fedify/vocab";
@@ -6,9 +6,9 @@ import "../std__assert-DvMDRPes.mjs";
6
6
  import { t as assert } from "../assert-D1Eafmd_.mjs";
7
7
  import { n as preloadedOnlyDocumentLoader } from "../public-audience--klBIOk1.mjs";
8
8
  import { r as normalizeOutgoingActivityJsonLd } from "../outgoing-jsonld-4IJqPYos.mjs";
9
- import { a as signObject, d as verifyProof } from "../proof-DuSE1ABD.mjs";
9
+ import { a as signObject, d as verifyProof } from "../proof-kJtQ49gr.mjs";
10
10
  import { n as ed25519PrivateKey, r as ed25519PublicKey } from "../keys-DIJNHW-Y.mjs";
11
- import { s as verifyCompoundProofDocuments } from "../compound-proof-G2J_bU0u.mjs";
11
+ import { s as verifyCompoundProofDocuments } from "../compound-proof-fxkyiXYM.mjs";
12
12
  import { t as map_local_create_note_default } from "../map-local-create-note-B0SeXJms.mjs";
13
13
  import { t as map_local_context_conflict_default } from "../map-local-context-conflict-DOYEEJ3u.mjs";
14
14
  import { Create, DataIntegrityProof, Note, Question } from "@fedify/vocab";
@@ -12,10 +12,10 @@ import { t as assertThrows } from "../assert_throws-BYITOvPO.mjs";
12
12
  import "../std__assert-DvMDRPes.mjs";
13
13
  import { t as assertRejects } from "../assert_rejects-CTptdYck.mjs";
14
14
  import { t as assert } from "../assert-D1Eafmd_.mjs";
15
- import { y as exportJwk } from "../ld-Dkkyk65e.mjs";
16
- import { a as listRequestSignatures, c as selectRequestSignature, f as verifyRequest, i as formatRfc9421SignatureParameters, l as signRequest, n as doubleKnock, o as parseRfc9421Signature, p as verifyRequestDetailed, r as formatRfc9421Signature, s as parseRfc9421SignatureInput, t as createRfc9421SignatureBase, u as timingSafeEqual } from "../http-B5w_qcIg.mjs";
15
+ import { y as exportJwk } from "../ld-Cy86r-Ty.mjs";
16
+ import { a as listRequestSignatures, c as selectRequestSignature, f as verifyRequest, i as formatRfc9421SignatureParameters, l as signRequest, n as doubleKnock, o as parseRfc9421Signature, p as verifyRequestDetailed, r as formatRfc9421Signature, s as parseRfc9421SignatureInput, t as createRfc9421SignatureBase, u as timingSafeEqual } from "../http-DkLKT8Vp.mjs";
17
17
  import { a as rsaPrivateKey3, i as rsaPrivateKey2, l as rsaPublicKey5, n as ed25519PrivateKey, o as rsaPublicKey1, r as ed25519PublicKey, s as rsaPublicKey2 } from "../keys-DIJNHW-Y.mjs";
18
- import { t as KvKeyCache } from "../keycache-D-MNltOk.mjs";
18
+ import { t as KvKeyCache } from "../keycache-N2opu4-3.mjs";
19
19
  import { FetchError, UrlError, exportSpki, getDocumentLoader } from "@fedify/vocab-runtime";
20
20
  import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
21
21
  import { encodeBase64 } from "byte-encodings/base64";
@@ -2,12 +2,13 @@ import "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
5
+ import { t as assertFalse } from "../assert_false-CPdRnc3E.mjs";
5
6
  import { t as assertThrows } from "../assert_throws-BYITOvPO.mjs";
6
7
  import "../std__assert-DvMDRPes.mjs";
7
8
  import { t as assertRejects } from "../assert_rejects-CTptdYck.mjs";
8
9
  import { t as assertStrictEquals } from "../assert_strict_equals-CYvBmkpC.mjs";
9
10
  import { t as assert } from "../assert-D1Eafmd_.mjs";
10
- import { C as generateCryptoKeyPair, S as fetchKeyDetailed, T as validateCryptoKey, _ as wrapContextLoaderForJsonLd, w as importJwk, x as fetchKey, y as exportJwk } from "../ld-Dkkyk65e.mjs";
11
+ import { C as generateCryptoKeyPair, S as fetchKeyDetailed, T as validateCryptoKey, _ as wrapContextLoaderForJsonLd, w as importJwk, x as fetchKey, y as exportJwk } from "../ld-Cy86r-Ty.mjs";
11
12
  import { c as rsaPublicKey3, i as rsaPrivateKey2, o as rsaPublicKey1, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DIJNHW-Y.mjs";
12
13
  import { CryptographicKey, Multikey, Person } from "@fedify/vocab";
13
14
  import { FetchError, UrlError, exportDidKey, getDocumentLoader } from "@fedify/vocab-runtime";
@@ -1051,5 +1052,199 @@ test("fetchKey() records the controller an actor document establishes", async ()
1051
1052
  assertEquals(key?.controllerId, new URL(actorId));
1052
1053
  assert(key?.publicKey != null);
1053
1054
  });
1055
+ test("fetchKey() rejects a key whose owner redirects to another actor", async () => {
1056
+ const keyId = "https://evil.example/keys/1";
1057
+ const victim = "https://victim.example/users/alice";
1058
+ const mallory = "https://evil.example/users/mallory";
1059
+ const { publicKeyPem } = await rsaPublicKey3.toJsonLd({ contextLoader: mockDocumentLoader });
1060
+ const cache = {};
1061
+ assertEquals(await fetchKey(keyId, CryptographicKey, {
1062
+ documentLoader(resource) {
1063
+ if (resource === keyId) return Promise.resolve({
1064
+ contextUrl: null,
1065
+ documentUrl: resource,
1066
+ document: {
1067
+ "@context": "https://w3id.org/security/v1",
1068
+ id: keyId,
1069
+ type: "CryptographicKey",
1070
+ owner: victim,
1071
+ publicKeyPem
1072
+ }
1073
+ });
1074
+ if (resource === victim || resource === mallory) return Promise.resolve({
1075
+ contextUrl: null,
1076
+ documentUrl: mallory,
1077
+ document: {
1078
+ "@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
1079
+ id: mallory,
1080
+ type: "Person",
1081
+ publicKey: keyId
1082
+ }
1083
+ });
1084
+ return mockDocumentLoader(resource);
1085
+ },
1086
+ contextLoader: mockDocumentLoader,
1087
+ keyCache: {
1088
+ get(keyId) {
1089
+ return Promise.resolve(cache[keyId.href]);
1090
+ },
1091
+ set(keyId, key) {
1092
+ cache[keyId.href] = key;
1093
+ return Promise.resolve();
1094
+ }
1095
+ }
1096
+ }), {
1097
+ key: null,
1098
+ cached: false
1099
+ });
1100
+ assertEquals(cache, { [keyId]: null });
1101
+ });
1102
+ test("fetchKey() rejects a key whose owner resolves to another actor on the same origin", async () => {
1103
+ const keyId = "https://victim.example/keys/bob";
1104
+ const victim = "https://victim.example/users/alice";
1105
+ const bob = "https://victim.example/users/bob";
1106
+ const { publicKeyPem } = await rsaPublicKey3.toJsonLd({ contextLoader: mockDocumentLoader });
1107
+ assertEquals(await fetchKey(keyId, CryptographicKey, {
1108
+ documentLoader(resource) {
1109
+ if (resource === keyId) return Promise.resolve({
1110
+ contextUrl: null,
1111
+ documentUrl: resource,
1112
+ document: {
1113
+ "@context": "https://w3id.org/security/v1",
1114
+ id: keyId,
1115
+ type: "CryptographicKey",
1116
+ owner: victim,
1117
+ publicKeyPem
1118
+ }
1119
+ });
1120
+ if (resource === victim || resource === bob) return Promise.resolve({
1121
+ contextUrl: null,
1122
+ documentUrl: resource,
1123
+ document: {
1124
+ "@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
1125
+ id: bob,
1126
+ type: "Person",
1127
+ publicKey: keyId
1128
+ }
1129
+ });
1130
+ return mockDocumentLoader(resource);
1131
+ },
1132
+ contextLoader: mockDocumentLoader
1133
+ }), {
1134
+ key: null,
1135
+ cached: false
1136
+ });
1137
+ });
1138
+ test("fetchKey() rejects a Multikey whose controller redirects to another actor", async () => {
1139
+ const keyId = "https://evil.example/keys/ed25519";
1140
+ const victim = "https://victim.example/users/alice";
1141
+ const mallory = "https://evil.example/users/mallory";
1142
+ const multikeyDocument = await ed25519Multikey.toJsonLd({ contextLoader: mockDocumentLoader });
1143
+ assertEquals(await fetchKey(keyId, Multikey, {
1144
+ documentLoader(resource) {
1145
+ if (resource === keyId) return Promise.resolve({
1146
+ contextUrl: null,
1147
+ documentUrl: resource,
1148
+ document: {
1149
+ ...multikeyDocument,
1150
+ id: keyId,
1151
+ controller: victim
1152
+ }
1153
+ });
1154
+ if (resource === victim || resource === mallory) return Promise.resolve({
1155
+ contextUrl: null,
1156
+ documentUrl: mallory,
1157
+ document: {
1158
+ "@context": [
1159
+ "https://www.w3.org/ns/activitystreams",
1160
+ "https://w3id.org/security/v1",
1161
+ "https://w3id.org/security/multikey/v1",
1162
+ "https://w3id.org/security/data-integrity/v1",
1163
+ "https://www.w3.org/ns/did/v1"
1164
+ ],
1165
+ id: mallory,
1166
+ type: "Person",
1167
+ assertionMethod: [keyId]
1168
+ }
1169
+ });
1170
+ return mockDocumentLoader(resource);
1171
+ },
1172
+ contextLoader: mockDocumentLoader
1173
+ }), {
1174
+ key: null,
1175
+ cached: false
1176
+ });
1177
+ });
1178
+ test("fetchKey() accepts an owner whose document URL differs from its id", async () => {
1179
+ const keyId = "https://victim.example/keys/alice";
1180
+ const alice = "https://victim.example/users/alice";
1181
+ const { publicKeyPem } = await rsaPublicKey3.toJsonLd({ contextLoader: mockDocumentLoader });
1182
+ const { key, cached } = await fetchKey(keyId, CryptographicKey, {
1183
+ documentLoader(resource) {
1184
+ if (resource === keyId) return Promise.resolve({
1185
+ contextUrl: null,
1186
+ documentUrl: resource,
1187
+ document: {
1188
+ "@context": "https://w3id.org/security/v1",
1189
+ id: keyId,
1190
+ type: "CryptographicKey",
1191
+ owner: alice,
1192
+ publicKeyPem
1193
+ }
1194
+ });
1195
+ if (resource === alice) return Promise.resolve({
1196
+ contextUrl: null,
1197
+ documentUrl: `${alice}.json`,
1198
+ document: {
1199
+ "@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
1200
+ id: alice,
1201
+ type: "Person",
1202
+ publicKey: keyId
1203
+ }
1204
+ });
1205
+ return mockDocumentLoader(resource);
1206
+ },
1207
+ contextLoader: mockDocumentLoader
1208
+ });
1209
+ assertFalse(cached);
1210
+ assertEquals(key?.id, new URL(keyId));
1211
+ assertEquals(key?.ownerId, new URL(alice));
1212
+ });
1213
+ test("fetchKey() rejects an owner reached through a normalization redirect", async () => {
1214
+ const keyId = "https://victim.example/keys/alice";
1215
+ const canonical = "https://victim.example/users/alice";
1216
+ const nonCanonical = "https://victim.example/users/Alice";
1217
+ const { publicKeyPem } = await rsaPublicKey3.toJsonLd({ contextLoader: mockDocumentLoader });
1218
+ assertEquals(await fetchKey(keyId, CryptographicKey, {
1219
+ documentLoader(resource) {
1220
+ if (resource === keyId) return Promise.resolve({
1221
+ contextUrl: null,
1222
+ documentUrl: resource,
1223
+ document: {
1224
+ "@context": "https://w3id.org/security/v1",
1225
+ id: keyId,
1226
+ type: "CryptographicKey",
1227
+ owner: nonCanonical,
1228
+ publicKeyPem
1229
+ }
1230
+ });
1231
+ if (resource === canonical || resource === nonCanonical) return Promise.resolve({
1232
+ contextUrl: null,
1233
+ documentUrl: canonical,
1234
+ document: {
1235
+ "@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
1236
+ id: canonical,
1237
+ type: "Person",
1238
+ publicKey: keyId
1239
+ }
1240
+ });
1241
+ return mockDocumentLoader(resource);
1242
+ },
1243
+ contextLoader: mockDocumentLoader
1244
+ }), {
1245
+ key: null,
1246
+ cached: false
1247
+ });
1248
+ });
1054
1249
  //#endregion
1055
1250
  export {};
@@ -8,7 +8,7 @@ import { t as assertInstanceOf } from "../assert_instance_of-mrXWWNY-.mjs";
8
8
  import { t as assertThrows } from "../assert_throws-BYITOvPO.mjs";
9
9
  import { t as assertRejects } from "../assert_rejects-CTptdYck.mjs";
10
10
  import { t as assert } from "../assert-D1Eafmd_.mjs";
11
- import { C as generateCryptoKeyPair, a as compactJsonLd, f as isInvalidUrlTypeError, g as verifySignature, h as verifyJsonLd, i as attachSignature, n as UnsafeJsonLdError, o as createSignature, p as signJsonLd, s as detachSignature, u as hasSignatureLike } from "../ld-Dkkyk65e.mjs";
11
+ import { C as generateCryptoKeyPair, a as compactJsonLd, f as isInvalidUrlTypeError, g as verifySignature, h as verifyJsonLd, i as attachSignature, n as UnsafeJsonLdError, o as createSignature, p as signJsonLd, s as detachSignature, u as hasSignatureLike } from "../ld-Cy86r-Ty.mjs";
12
12
  import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DIJNHW-Y.mjs";
13
13
  import { CryptographicKey } from "@fedify/vocab";
14
14
  import { createTestMeterProvider, mockDocumentLoader, test } from "@fedify/fixture";
@@ -995,5 +995,50 @@ test("verifyJsonLd() rejects a key that claims a forged owner", async () => {
995
995
  contextLoader: mockDocumentLoader
996
996
  }));
997
997
  });
998
+ test("verifyJsonLd() rejects a key whose owner redirects to another actor", async () => {
999
+ const keyId = new URL("https://evil.example/keys/1");
1000
+ const victim = "https://victim.example/users/alice";
1001
+ const mallory = "https://evil.example/users/mallory";
1002
+ const { publicKeyPem } = await rsaPublicKey3.toJsonLd({ contextLoader: mockDocumentLoader });
1003
+ const signed = await signJsonLd({
1004
+ "@context": "https://www.w3.org/ns/activitystreams",
1005
+ id: "https://victim.example/activities/forged",
1006
+ type: "Create",
1007
+ actor: victim,
1008
+ object: {
1009
+ type: "Note",
1010
+ content: "forged"
1011
+ }
1012
+ }, rsaPrivateKey3, keyId, { contextLoader: mockDocumentLoader });
1013
+ const options = {
1014
+ documentLoader(resource) {
1015
+ if (resource === keyId.href) return Promise.resolve({
1016
+ contextUrl: null,
1017
+ documentUrl: resource,
1018
+ document: {
1019
+ "@context": "https://w3id.org/security/v1",
1020
+ id: keyId.href,
1021
+ type: "CryptographicKey",
1022
+ owner: victim,
1023
+ publicKeyPem
1024
+ }
1025
+ });
1026
+ if (resource === victim || resource === mallory) return Promise.resolve({
1027
+ contextUrl: null,
1028
+ documentUrl: mallory,
1029
+ document: {
1030
+ "@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
1031
+ id: mallory,
1032
+ type: "Person",
1033
+ publicKey: keyId.href
1034
+ }
1035
+ });
1036
+ return mockDocumentLoader(resource);
1037
+ },
1038
+ contextLoader: mockDocumentLoader
1039
+ };
1040
+ assertEquals(await verifySignature(signed, options), null);
1041
+ assertFalse(await verifyJsonLd(signed, options));
1042
+ });
998
1043
  //#endregion
999
1044
  export {};
@@ -5,10 +5,10 @@ import { t as MemoryKvStore } from "../kv-DCHkaJ9-.mjs";
5
5
  import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
6
6
  import "../std__assert-DvMDRPes.mjs";
7
7
  import { t as assert } from "../assert-D1Eafmd_.mjs";
8
- import { c as verifyPortableObjectProof } from "../proof-DuSE1ABD.mjs";
9
- import { p as verifyRequestDetailed } from "../http-B5w_qcIg.mjs";
10
- import { o as createFederation } from "../middleware-C-swet0z.mjs";
11
- import { t as doesActorOwnKey } from "../owner-BHUhedVc.mjs";
8
+ import { c as verifyPortableObjectProof } from "../proof-kJtQ49gr.mjs";
9
+ import { p as verifyRequestDetailed } from "../http-DkLKT8Vp.mjs";
10
+ import { o as createFederation } from "../middleware-C_gtR3fV.mjs";
11
+ import { t as doesActorOwnKey } from "../owner-Dc-Lg_Xn.mjs";
12
12
  import { Create, Person } from "@fedify/vocab";
13
13
  import { canonicalizePortableUri, decodeMultibase, importDidKey } from "@fedify/vocab-runtime";
14
14
  import { mockDocumentLoader, test } from "@fedify/fixture";
@@ -4,9 +4,9 @@ globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
5
5
  import "../std__assert-DvMDRPes.mjs";
6
6
  import { t as assert } from "../assert-D1Eafmd_.mjs";
7
- import { c as verifyPortableObjectProof } from "../proof-DuSE1ABD.mjs";
8
- import { p as verifyRequestDetailed } from "../http-B5w_qcIg.mjs";
9
- import { t as doesActorOwnKey } from "../owner-BHUhedVc.mjs";
7
+ import { c as verifyPortableObjectProof } from "../proof-kJtQ49gr.mjs";
8
+ import { p as verifyRequestDetailed } from "../http-DkLKT8Vp.mjs";
9
+ import { t as doesActorOwnKey } from "../owner-Dc-Lg_Xn.mjs";
10
10
  import { Create } from "@fedify/vocab";
11
11
  import { canonicalizePortableUri, decodeMultibase, fromCompatibleEf61Id, importDidKey } from "@fedify/vocab-runtime";
12
12
  import { mockDocumentLoader, test } from "@fedify/fixture";
package/dist/sig/mod.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  const { URLPattern } = require("urlpattern-polyfill");
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const require_http = require("../http-x1satM4y.cjs");
4
- const require_portable_collection = require("../portable-collection-DL-1Wy1s.cjs");
3
+ const require_http = require("../http-g5f1D2tm.cjs");
4
+ const require_portable_collection = require("../portable-collection-Bl2UkqcO.cjs");
5
5
  exports.attachSignature = require_http.attachSignature;
6
6
  exports.createProof = require_http.createProof;
7
7
  exports.createSignature = require_http.createSignature;
package/dist/sig/mod.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Temporal } from "temporal-polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { D as createSignature, H as fetchKeyDetailed, I as verifyJsonLd, L as verifySignature, O as detachSignature, P as signJsonLd, T as attachSignature, U as generateCryptoKeyPair, V as fetchKey, W as importJwk, _ as verifyObject, _t as validateAcceptSignature, a as signRequest, c as verifyRequestDetailed, gt as parseAcceptSignature, h as signObject, ht as fulfillAcceptSignature, j as hasSignatureLike, m as hasProofLike, mt as formatAcceptSignature, p as createProof, s as verifyRequest, v as verifyPortableObjectProof, x as verifyProof, z as exportJwk } from "../http-Qq7jR2rC.js";
4
- import { n as doesActorOwnKey, r as getKeyOwner, t as verifyPortableObject } from "../portable-collection-CfIc190c.js";
3
+ import { D as createSignature, H as fetchKeyDetailed, I as verifyJsonLd, L as verifySignature, O as detachSignature, P as signJsonLd, T as attachSignature, U as generateCryptoKeyPair, V as fetchKey, W as importJwk, _ as verifyObject, _t as validateAcceptSignature, a as signRequest, c as verifyRequestDetailed, gt as parseAcceptSignature, h as signObject, ht as fulfillAcceptSignature, j as hasSignatureLike, m as hasProofLike, mt as formatAcceptSignature, p as createProof, s as verifyRequest, v as verifyPortableObjectProof, x as verifyProof, z as exportJwk } from "../http-D_AGUmSq.js";
4
+ import { n as doesActorOwnKey, r as getKeyOwner, t as verifyPortableObject } from "../portable-collection-CjdP7fQ4.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, verifyPortableObject, verifyPortableObjectProof, verifyProof, verifyRequest, verifyRequestDetailed, verifySignature };
@@ -6,7 +6,7 @@ import { t as assertFalse } from "../assert_false-CPdRnc3E.mjs";
6
6
  import "../std__assert-DvMDRPes.mjs";
7
7
  import { t as assert } from "../assert-D1Eafmd_.mjs";
8
8
  import { o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-DIJNHW-Y.mjs";
9
- import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-BHUhedVc.mjs";
9
+ import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-Dc-Lg_Xn.mjs";
10
10
  import { Create, CryptographicKey, lookupObject } from "@fedify/vocab";
11
11
  import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
12
12
  //#region src/sig/owner.test.ts
@@ -153,5 +153,50 @@ test("doesActorOwnKey() matches a key that leaves its id implicit", async () =>
153
153
  publicKey: rsaPublicKey2.publicKey
154
154
  }), options));
155
155
  });
156
+ test("doesActorOwnKey() rejects an actor ID that redirects to the key's owner", async () => {
157
+ const keyId = "https://evil.example/keys/1";
158
+ const victim = "https://victim.example/users/alice";
159
+ const mallory = "https://evil.example/users/mallory";
160
+ const { publicKeyPem } = await rsaPublicKey1.toJsonLd({ contextLoader: mockDocumentLoader });
161
+ const serveKeyOwnedBy = (owner) => ({
162
+ documentLoader(resource) {
163
+ if (resource === keyId) return Promise.resolve({
164
+ contextUrl: null,
165
+ documentUrl: resource,
166
+ document: {
167
+ "@context": "https://w3id.org/security/v1",
168
+ id: keyId,
169
+ type: "CryptographicKey",
170
+ owner,
171
+ publicKeyPem
172
+ }
173
+ });
174
+ if (resource === victim || resource === mallory) return Promise.resolve({
175
+ contextUrl: null,
176
+ documentUrl: mallory,
177
+ document: {
178
+ "@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
179
+ id: mallory,
180
+ type: "Person",
181
+ publicKey: keyId
182
+ }
183
+ });
184
+ return mockDocumentLoader(resource);
185
+ },
186
+ contextLoader: mockDocumentLoader
187
+ });
188
+ const activity = new Create({ actor: new URL(victim) });
189
+ assertFalse(await doesActorOwnKey(activity, new CryptographicKey({
190
+ id: new URL(keyId),
191
+ owner: new URL(mallory),
192
+ publicKey: rsaPublicKey1.publicKey
193
+ }), serveKeyOwnedBy(mallory)));
194
+ assertFalse(await doesActorOwnKey(activity, new CryptographicKey({
195
+ id: new URL(keyId),
196
+ owner: new URL(victim),
197
+ publicKey: rsaPublicKey1.publicKey
198
+ }), serveKeyOwnedBy(victim)));
199
+ assertEquals(await getKeyOwner(new URL(keyId), serveKeyOwnedBy(victim)), null);
200
+ });
156
201
  //#endregion
157
202
  export {};
@@ -2,7 +2,7 @@ import "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { n as ed25519PrivateKey, r as ed25519PublicKey } from "../keys-DIJNHW-Y.mjs";
5
- import { t as verifyPortableObject } from "../portable-collection-DONEPTXV.mjs";
5
+ import { t as verifyPortableObject } from "../portable-collection-DSKqMgvr.mjs";
6
6
  import { Collection, CollectionPage, Note, OrderedCollection, Person, traverseCollection } from "@fedify/vocab";
7
7
  import { FetchError, encodeMultibase, exportDidKey, preloadedContexts } from "@fedify/vocab-runtime";
8
8
  import { test } from "@fedify/fixture";
@@ -4,9 +4,9 @@ globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
5
5
  import "../std__assert-DvMDRPes.mjs";
6
6
  import { t as assert } from "../assert-D1Eafmd_.mjs";
7
- import { c as verifyPortableObjectProof, d as verifyProof } from "../proof-DuSE1ABD.mjs";
8
- import { n as getKeyOwner } from "../owner-BHUhedVc.mjs";
9
- import { t as verifyPortableObject } from "../portable-collection-DONEPTXV.mjs";
7
+ import { c as verifyPortableObjectProof, d as verifyProof } from "../proof-kJtQ49gr.mjs";
8
+ import { n as getKeyOwner } from "../owner-Dc-Lg_Xn.mjs";
9
+ import { t as verifyPortableObject } from "../portable-collection-DSKqMgvr.mjs";
10
10
  import { Application, DataIntegrityProof, lookupObject } from "@fedify/vocab";
11
11
  import { mockDocumentLoader, test } from "@fedify/fixture";
12
12
  //#region test-vectors/fep-ef61/tootik-v0.25.4/actor.json
@@ -2,13 +2,13 @@ import { Temporal } from "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as MemoryKvStore } from "../kv-DCHkaJ9-.mjs";
5
- import { S as fetchKeyDetailed, h as verifyJsonLd, p as signJsonLd, x as fetchKey } from "../ld-Dkkyk65e.mjs";
6
- import { d as verifyProof, r as createProof } from "../proof-DuSE1ABD.mjs";
7
- import { n as resolvePortableActorKey } from "../portable-key-Cdw3vfl-.mjs";
8
- import { f as verifyRequest, l as signRequest, p as verifyRequestDetailed } from "../http-B5w_qcIg.mjs";
5
+ import { S as fetchKeyDetailed, h as verifyJsonLd, p as signJsonLd, x as fetchKey } from "../ld-Cy86r-Ty.mjs";
6
+ import { d as verifyProof, r as createProof } from "../proof-kJtQ49gr.mjs";
7
+ import { n as resolvePortableActorKey } from "../portable-key-ClXZ25LT.mjs";
8
+ import { f as verifyRequest, l as signRequest, p as verifyRequestDetailed } from "../http-DkLKT8Vp.mjs";
9
9
  import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2 } from "../keys-DIJNHW-Y.mjs";
10
- import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-BHUhedVc.mjs";
11
- import { t as KvKeyCache } from "../keycache-D-MNltOk.mjs";
10
+ import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-Dc-Lg_Xn.mjs";
11
+ import { t as KvKeyCache } from "../keycache-N2opu4-3.mjs";
12
12
  import { Create, CryptographicKey, Multikey, Note, Person } from "@fedify/vocab";
13
13
  import { FetchError, encodeMultibase, exportDidKey, exportSpki, parseIri, preloadedContexts } from "@fedify/vocab-runtime";
14
14
  import { test } from "@fedify/fixture";