@fedify/fedify 2.4.0-dev.2256 → 2.4.0-dev.2260

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 (105) hide show
  1. package/dist/{builder-DvSQqk2l.mjs → builder-BK8HfSUm.mjs} +8 -2
  2. package/dist/compat/mod.d.cts +1 -1
  3. package/dist/compat/mod.d.ts +1 -1
  4. package/dist/compat/transformers.test.mjs +1 -1
  5. package/dist/{compound-proof-5bg_j_ye.mjs → compound-proof-D--HeIbV.mjs} +41 -4
  6. package/dist/{context-CtI307_A.d.ts → context-7NyiqIcg.d.ts} +111 -2
  7. package/dist/{context-B6X-t8gI.d.cts → context-tsYPJ2Ew.d.cts} +111 -2
  8. package/dist/{deno-AmcRMq5z.mjs → deno-DVP7DGJC.mjs} +1 -1
  9. package/dist/{docloader-CIP_SG39.mjs → docloader-Dv1JJl37.mjs} +2 -2
  10. package/dist/federation/builder.test.mjs +1 -1
  11. package/dist/federation/compound-fanout.test.mjs +3 -3
  12. package/dist/federation/handler-compound-proof.test.mjs +3 -3
  13. package/dist/federation/handler.test.mjs +76 -5
  14. package/dist/federation/hashlink-media.test.mjs +2 -2
  15. package/dist/federation/idempotency.test.mjs +2 -2
  16. package/dist/federation/inbox-report.test.d.mts +2 -0
  17. package/dist/federation/inbox-report.test.mjs +475 -0
  18. package/dist/federation/metrics.test.mjs +1 -1
  19. package/dist/federation/middleware.test.mjs +7 -7
  20. package/dist/federation/mod.cjs +1 -1
  21. package/dist/federation/mod.d.cts +4 -3
  22. package/dist/federation/mod.d.ts +4 -3
  23. package/dist/federation/mod.js +1 -1
  24. package/dist/federation/outgoing-proof.test.mjs +54 -10
  25. package/dist/federation/portable-actor.test.mjs +3 -3
  26. package/dist/federation/portable-chain.test.mjs +3 -3
  27. package/dist/federation/portable-collection.test.mjs +66 -4
  28. package/dist/federation/portable-delivery.test.mjs +2 -2
  29. package/dist/federation/portable-gateway-keys.test.mjs +4 -4
  30. package/dist/federation/portable-inbox.test.mjs +67 -6
  31. package/dist/federation/portable-parse-uri.test.mjs +1 -1
  32. package/dist/federation/portable-route-activity.test.mjs +2 -2
  33. package/dist/federation/portable.test.mjs +3 -3
  34. package/dist/federation/send.test.mjs +3 -3
  35. package/dist/federation/tasks/enqueue.test.mjs +1 -1
  36. package/dist/federation/tasks/tasks.test.mjs +2 -2
  37. package/dist/federation/temporal.test.mjs +1 -1
  38. package/dist/federation/webfinger.test.mjs +1 -1
  39. package/dist/{federation-BDzIgqOd.cjs → federation-Bo5z395X.cjs} +552 -122
  40. package/dist/{http-1fZ83jj7.cjs → http-BIhWdDf5.cjs} +447 -110
  41. package/dist/{http-BGb3QioZ.js → http-DRMu1C2T.js} +430 -111
  42. package/dist/{http-DkqWu-sm.mjs → http-DvpuyDJB.mjs} +141 -98
  43. package/dist/{key-CEsu7oaD.mjs → key-B7N8mNoY.mjs} +30 -3
  44. package/dist/{http-BrwKINQn.d.cts → key-C1nv7_jD.d.ts} +638 -229
  45. package/dist/{http-DGx0KOws.d.ts → key-DYxuyd-s.d.cts} +638 -229
  46. package/dist/{kv-cache-CJS4mImS.mjs → kv-cache-D0kA0rml.mjs} +1 -1
  47. package/dist/{kv-cache-CGhEgt98.js → kv-cache-DZLpqhW9.js} +1 -1
  48. package/dist/{kv-cache-BEWuZSB4.cjs → kv-cache-mF8Zmjix.cjs} +1 -1
  49. package/dist/{ld-Cf4CPWN_.mjs → ld-BDMNyM2M.mjs} +40 -5
  50. package/dist/{metrics-CocsZP0E.mjs → metrics-BbBj-VZN.mjs} +2 -1
  51. package/dist/{middleware-Cne_jMZo.mjs → middleware-CE1X7-UM.mjs} +1 -1
  52. package/dist/{middleware-Dxn0E9ES.mjs → middleware-DAA7wDdS.mjs} +520 -131
  53. package/dist/{middleware-BfYke3YQ.js → middleware-DfUWPAa-.js} +552 -122
  54. package/dist/{mod-C7_2j7VT.d.cts → mod-BojP2Bw3.d.cts} +1 -1
  55. package/dist/{mod-BlLwewYe.d.ts → mod-CavhAgLw.d.cts} +5 -255
  56. package/dist/{mod-VHYh1lTK.d.cts → mod-CtpF2BU5.d.ts} +5 -255
  57. package/dist/{mod-B8MI1mpi.d.ts → mod-DEZXwV6J.d.ts} +1 -1
  58. package/dist/{mod-DFL6IxYQ.d.cts → mod-Dw-nPxQh.d.cts} +1 -1
  59. package/dist/{mod-BhTaDR5H.d.ts → mod-Xj5P4s4d.d.ts} +1 -1
  60. package/dist/mod.cjs +4 -4
  61. package/dist/mod.d.cts +7 -7
  62. package/dist/mod.d.ts +7 -7
  63. package/dist/mod.js +4 -4
  64. package/dist/nodeinfo/handler.test.mjs +1 -1
  65. package/dist/{owner-DSJ7nFgy.mjs → owner-CzUycuhd.mjs} +3 -3
  66. package/dist/{portable-collection-BuBV6xTo.js → portable-collection-COcJxZg_.js} +1 -1
  67. package/dist/{portable-collection-qskqXJrH.mjs → portable-collection-CTcNJiAa.mjs} +2 -2
  68. package/dist/{portable-collection-r-mHg1PV.cjs → portable-collection-cPMffcHJ.cjs} +1 -1
  69. package/dist/{portable-key-woGH_1nn.mjs → portable-key-B4QN3OzR.mjs} +1 -1
  70. package/dist/{proof-8WiH_-Gq.mjs → proof-nce4pf5S.mjs} +133 -16
  71. package/dist/{send-JKzZBgPU.mjs → send-4Idpe2z0.mjs} +3 -3
  72. package/dist/sig/compound-proof-discovery.test.mjs +1 -1
  73. package/dist/sig/compound-proof-producer.test.mjs +1 -1
  74. package/dist/sig/compound-proof-verification.test.mjs +19 -2
  75. package/dist/sig/compound-proof.test.mjs +2 -2
  76. package/dist/sig/http.test.mjs +2 -2
  77. package/dist/sig/key.test.mjs +1 -1
  78. package/dist/sig/ld.test.mjs +2 -2
  79. package/dist/sig/mitra-receive-interop.test.mjs +4 -4
  80. package/dist/sig/mitra-send-interop.test.mjs +3 -3
  81. package/dist/sig/mod.cjs +2 -2
  82. package/dist/sig/mod.d.cts +2 -2
  83. package/dist/sig/mod.d.ts +2 -2
  84. package/dist/sig/mod.js +2 -2
  85. package/dist/sig/owner.test.mjs +1 -1
  86. package/dist/sig/portable-collection.test.mjs +1 -1
  87. package/dist/sig/portable-interop.test.mjs +3 -3
  88. package/dist/sig/portable-key.test.mjs +6 -6
  89. package/dist/sig/proof.test.mjs +76 -3
  90. package/dist/sig/tootik-request-interop.test.mjs +4 -4
  91. package/dist/sig/tootik-send-interop.test.mjs +3 -3
  92. package/dist/sig/verification.test.d.mts +2 -0
  93. package/dist/sig/verification.test.mjs +310 -0
  94. package/dist/{temporal-CT3fRaMH.mjs → temporal-BbjmPHYn.mjs} +1 -1
  95. package/dist/testing/kv.test.mjs +1 -1
  96. package/dist/testing/mod.d.mts +315 -28
  97. package/dist/utils/docloader.test.mjs +2 -2
  98. package/dist/utils/kv-cache.test.mjs +1 -1
  99. package/dist/utils/mod.cjs +1 -1
  100. package/dist/utils/mod.d.cts +1 -1
  101. package/dist/utils/mod.d.ts +1 -1
  102. package/dist/utils/mod.js +1 -1
  103. package/dist/verification-C3954hQh.mjs +5 -0
  104. package/dist/verification-Dpfcw8ml.mjs +105 -0
  105. package/package.json +7 -7
@@ -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-8WiH_-Gq.mjs";
9
+ import { a as signObject, d as verifyProof } from "../proof-nce4pf5S.mjs";
10
10
  import { n as ed25519PrivateKey, r as ed25519PublicKey } from "../keys-DIJNHW-Y.mjs";
11
- import { o as verifyCompoundProofDocuments } from "../compound-proof-5bg_j_ye.mjs";
11
+ import { s as verifyCompoundProofDocuments } from "../compound-proof-D--HeIbV.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,8 +12,8 @@ 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 { n as exportJwk } from "../key-CEsu7oaD.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-DkqWu-sm.mjs";
15
+ import { n as exportJwk } from "../key-B7N8mNoY.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-DvpuyDJB.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
18
  import { t as KvKeyCache } from "../keycache-Da8A8mZa.mjs";
19
19
  import { FetchError, exportSpki, getDocumentLoader } from "@fedify/vocab-runtime";
@@ -6,7 +6,7 @@ import { t as assertThrows } from "../assert_throws-BYITOvPO.mjs";
6
6
  import "../std__assert-DvMDRPes.mjs";
7
7
  import { t as assertRejects } from "../assert_rejects-CTptdYck.mjs";
8
8
  import { t as assert } from "../assert-D1Eafmd_.mjs";
9
- import { a as fetchKeyDetailed, c as validateCryptoKey, i as fetchKey, n as exportJwk, o as generateCryptoKeyPair, s as importJwk } from "../key-CEsu7oaD.mjs";
9
+ import { a as fetchKeyDetailed, c as validateCryptoKey, i as fetchKey, n as exportJwk, o as generateCryptoKeyPair, s as importJwk } from "../key-B7N8mNoY.mjs";
10
10
  import { c as rsaPublicKey3, i as rsaPrivateKey2, o as rsaPublicKey1, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DIJNHW-Y.mjs";
11
11
  import { CryptographicKey, Multikey } from "@fedify/vocab";
12
12
  import { FetchError, exportDidKey } from "@fedify/vocab-runtime";
@@ -8,8 +8,8 @@ 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 { o as generateCryptoKeyPair } from "../key-CEsu7oaD.mjs";
12
- import { 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-Cf4CPWN_.mjs";
11
+ import { o as generateCryptoKeyPair } from "../key-B7N8mNoY.mjs";
12
+ import { 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-BDMNyM2M.mjs";
13
13
  import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DIJNHW-Y.mjs";
14
14
  import { CryptographicKey } from "@fedify/vocab";
15
15
  import { createTestMeterProvider, mockDocumentLoader, test } from "@fedify/fixture";
@@ -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-8WiH_-Gq.mjs";
9
- import { p as verifyRequestDetailed } from "../http-DkqWu-sm.mjs";
10
- import { o as createFederation } from "../middleware-Dxn0E9ES.mjs";
11
- import { t as doesActorOwnKey } from "../owner-DSJ7nFgy.mjs";
8
+ import { c as verifyPortableObjectProof } from "../proof-nce4pf5S.mjs";
9
+ import { p as verifyRequestDetailed } from "../http-DvpuyDJB.mjs";
10
+ import { o as createFederation } from "../middleware-DAA7wDdS.mjs";
11
+ import { t as doesActorOwnKey } from "../owner-CzUycuhd.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-8WiH_-Gq.mjs";
8
- import { p as verifyRequestDetailed } from "../http-DkqWu-sm.mjs";
9
- import { t as doesActorOwnKey } from "../owner-DSJ7nFgy.mjs";
7
+ import { c as verifyPortableObjectProof } from "../proof-nce4pf5S.mjs";
8
+ import { p as verifyRequestDetailed } from "../http-DvpuyDJB.mjs";
9
+ import { t as doesActorOwnKey } from "../owner-CzUycuhd.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-1fZ83jj7.cjs");
4
- const require_portable_collection = require("../portable-collection-r-mHg1PV.cjs");
3
+ const require_http = require("../http-BIhWdDf5.cjs");
4
+ const require_portable_collection = require("../portable-collection-cPMffcHJ.cjs");
5
5
  exports.attachSignature = require_http.attachSignature;
6
6
  exports.createProof = require_http.createProof;
7
7
  exports.createSignature = require_http.createSignature;
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { C as exportJwk, D as importJwk, E as generateCryptoKeyPair, S as KeyCache, T as fetchKeyDetailed, _ as validateAcceptSignature, a as VerifyRequestDetailedResult, b as FetchKeyOptions, c as signRequest, d as AcceptSignatureMember, f as AcceptSignatureParameters, g as parseAcceptSignature, h as fulfillAcceptSignature, i as SignRequestOptions, l as verifyRequest, m as formatAcceptSignature, n as HttpMessageSignaturesSpecDeterminer, o as VerifyRequestFailureReason, p as FulfillAcceptSignatureResult, r as Rfc9421SignRequestOptions, s as VerifyRequestOptions, t as HttpMessageSignaturesSpec, u as verifyRequestDetailed, v as FetchKeyDetailedResult, w as fetchKey, x as FetchKeyResult, y as FetchKeyErrorResult } from "../http-BrwKINQn.cjs";
2
+ import { A as AcceptSignatureParameters, B as VerifyPortableObjectProofOptions, C as VerifyRequestDetailedResult, D as verifyRequest, E as signRequest, F as validateAcceptSignature, G as signObject, H as VerifyProofOptions, I as CreateProofOptions, J as verifyProof, K as verifyObject, L as SignObjectOptions, M as formatAcceptSignature, N as fulfillAcceptSignature, O as verifyRequestDetailed, P as parseAcceptSignature, R as VerifyObjectOptions, S as SignRequestOptions, T as VerifyRequestOptions, U as createProof, V as VerifyPortableObjectProofResult, W as hasProofLike, a as KeyCache, b as HttpMessageSignaturesSpecDeterminer, c as fetchKeyDetailed, i as FetchKeyResult, j as FulfillAcceptSignatureResult, k as AcceptSignatureMember, l as generateCryptoKeyPair, n as FetchKeyErrorResult, o as exportJwk, q as verifyPortableObjectProof, r as FetchKeyOptions, s as fetchKey, t as FetchKeyDetailedResult, u as importJwk, w as VerifyRequestFailureReason, x as Rfc9421SignRequestOptions, y as HttpMessageSignaturesSpec, z as VerifyPortableObjectProofFailureReason } from "../key-DYxuyd-s.cjs";
3
3
  import { i as getKeyOwner, n as GetKeyOwnerOptions, r as doesActorOwnKey, t as DoesActorOwnKeyOptions } from "../owner-BF0L9cMt.cjs";
4
- import { C as createSignature, D as verifyJsonLd, E as signJsonLd, O as verifySignature, S as attachSignature, T as hasSignatureLike, _ as verifyProof, a as CreateProofOptions, b as VerifyJsonLdOptions, c as VerifyPortableObjectProofFailureReason, d as VerifyProofOptions, f as createProof, g as verifyPortableObjectProof, h as verifyObject, i as verifyPortableObject, l as VerifyPortableObjectProofOptions, m as signObject, n as VerifyPortableObjectOptions, o as SignObjectOptions, p as hasProofLike, r as VerifyPortableObjectResult, s as VerifyObjectOptions, t as VerifyPortableObjectFailureReason, u as VerifyPortableObjectProofResult, v as CreateSignatureOptions, w as detachSignature, x as VerifySignatureOptions, y as SignJsonLdOptions } from "../mod-VHYh1lTK.cjs";
4
+ import { a as CreateSignatureOptions, c as VerifySignatureOptions, d as detachSignature, f as hasSignatureLike, h as verifySignature, i as verifyPortableObject, l as attachSignature, m as verifyJsonLd, n as VerifyPortableObjectOptions, o as SignJsonLdOptions, p as signJsonLd, r as VerifyPortableObjectResult, s as VerifyJsonLdOptions, t as VerifyPortableObjectFailureReason, u as createSignature } from "../mod-CavhAgLw.cjs";
5
5
  export { AcceptSignatureMember, AcceptSignatureParameters, CreateProofOptions, CreateSignatureOptions, DoesActorOwnKeyOptions, FetchKeyDetailedResult, FetchKeyErrorResult, FetchKeyOptions, FetchKeyResult, FulfillAcceptSignatureResult, GetKeyOwnerOptions, HttpMessageSignaturesSpec, HttpMessageSignaturesSpecDeterminer, KeyCache, Rfc9421SignRequestOptions, SignJsonLdOptions, SignObjectOptions, SignRequestOptions, VerifyJsonLdOptions, VerifyObjectOptions, VerifyPortableObjectFailureReason, VerifyPortableObjectOptions, VerifyPortableObjectProofFailureReason, VerifyPortableObjectProofOptions, VerifyPortableObjectProofResult, VerifyPortableObjectResult, VerifyProofOptions, VerifyRequestDetailedResult, VerifyRequestFailureReason, VerifyRequestOptions, VerifySignatureOptions, 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 };
package/dist/sig/mod.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { C as exportJwk, D as importJwk, E as generateCryptoKeyPair, S as KeyCache, T as fetchKeyDetailed, _ as validateAcceptSignature, a as VerifyRequestDetailedResult, b as FetchKeyOptions, c as signRequest, d as AcceptSignatureMember, f as AcceptSignatureParameters, g as parseAcceptSignature, h as fulfillAcceptSignature, i as SignRequestOptions, l as verifyRequest, m as formatAcceptSignature, n as HttpMessageSignaturesSpecDeterminer, o as VerifyRequestFailureReason, p as FulfillAcceptSignatureResult, r as Rfc9421SignRequestOptions, s as VerifyRequestOptions, t as HttpMessageSignaturesSpec, u as verifyRequestDetailed, v as FetchKeyDetailedResult, w as fetchKey, x as FetchKeyResult, y as FetchKeyErrorResult } from "../http-DGx0KOws.js";
2
+ import { A as AcceptSignatureParameters, B as VerifyPortableObjectProofOptions, C as VerifyRequestDetailedResult, D as verifyRequest, E as signRequest, F as validateAcceptSignature, G as signObject, H as VerifyProofOptions, I as CreateProofOptions, J as verifyProof, K as verifyObject, L as SignObjectOptions, M as formatAcceptSignature, N as fulfillAcceptSignature, O as verifyRequestDetailed, P as parseAcceptSignature, R as VerifyObjectOptions, S as SignRequestOptions, T as VerifyRequestOptions, U as createProof, V as VerifyPortableObjectProofResult, W as hasProofLike, a as KeyCache, b as HttpMessageSignaturesSpecDeterminer, c as fetchKeyDetailed, i as FetchKeyResult, j as FulfillAcceptSignatureResult, k as AcceptSignatureMember, l as generateCryptoKeyPair, n as FetchKeyErrorResult, o as exportJwk, q as verifyPortableObjectProof, r as FetchKeyOptions, s as fetchKey, t as FetchKeyDetailedResult, u as importJwk, w as VerifyRequestFailureReason, x as Rfc9421SignRequestOptions, y as HttpMessageSignaturesSpec, z as VerifyPortableObjectProofFailureReason } from "../key-C1nv7_jD.js";
3
3
  import { i as getKeyOwner, n as GetKeyOwnerOptions, r as doesActorOwnKey, t as DoesActorOwnKeyOptions } from "../owner-BSzr5-I8.js";
4
- import { C as createSignature, D as verifyJsonLd, E as signJsonLd, O as verifySignature, S as attachSignature, T as hasSignatureLike, _ as verifyProof, a as CreateProofOptions, b as VerifyJsonLdOptions, c as VerifyPortableObjectProofFailureReason, d as VerifyProofOptions, f as createProof, g as verifyPortableObjectProof, h as verifyObject, i as verifyPortableObject, l as VerifyPortableObjectProofOptions, m as signObject, n as VerifyPortableObjectOptions, o as SignObjectOptions, p as hasProofLike, r as VerifyPortableObjectResult, s as VerifyObjectOptions, t as VerifyPortableObjectFailureReason, u as VerifyPortableObjectProofResult, v as CreateSignatureOptions, w as detachSignature, x as VerifySignatureOptions, y as SignJsonLdOptions } from "../mod-BlLwewYe.js";
4
+ import { a as CreateSignatureOptions, c as VerifySignatureOptions, d as detachSignature, f as hasSignatureLike, h as verifySignature, i as verifyPortableObject, l as attachSignature, m as verifyJsonLd, n as VerifyPortableObjectOptions, o as SignJsonLdOptions, p as signJsonLd, r as VerifyPortableObjectResult, s as VerifyJsonLdOptions, t as VerifyPortableObjectFailureReason, u as createSignature } from "../mod-CtpF2BU5.js";
5
5
  export { AcceptSignatureMember, AcceptSignatureParameters, CreateProofOptions, CreateSignatureOptions, DoesActorOwnKeyOptions, FetchKeyDetailedResult, FetchKeyErrorResult, FetchKeyOptions, FetchKeyResult, FulfillAcceptSignatureResult, GetKeyOwnerOptions, HttpMessageSignaturesSpec, HttpMessageSignaturesSpecDeterminer, KeyCache, Rfc9421SignRequestOptions, SignJsonLdOptions, SignObjectOptions, SignRequestOptions, VerifyJsonLdOptions, VerifyObjectOptions, VerifyPortableObjectFailureReason, VerifyPortableObjectOptions, VerifyPortableObjectProofFailureReason, VerifyPortableObjectProofOptions, VerifyPortableObjectProofResult, VerifyPortableObjectResult, VerifyProofOptions, VerifyRequestDetailedResult, VerifyRequestFailureReason, VerifyRequestOptions, VerifySignatureOptions, 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 };
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-BGb3QioZ.js";
4
- import { n as doesActorOwnKey, r as getKeyOwner, t as verifyPortableObject } from "../portable-collection-BuBV6xTo.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-DRMu1C2T.js";
4
+ import { n as doesActorOwnKey, r as getKeyOwner, t as verifyPortableObject } from "../portable-collection-COcJxZg_.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-DSJ7nFgy.mjs";
9
+ import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-CzUycuhd.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
@@ -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-qskqXJrH.mjs";
5
+ import { t as verifyPortableObject } from "../portable-collection-CTcNJiAa.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-8WiH_-Gq.mjs";
8
- import { n as getKeyOwner } from "../owner-DSJ7nFgy.mjs";
9
- import { t as verifyPortableObject } from "../portable-collection-qskqXJrH.mjs";
7
+ import { c as verifyPortableObjectProof, d as verifyProof } from "../proof-nce4pf5S.mjs";
8
+ import { n as getKeyOwner } from "../owner-CzUycuhd.mjs";
9
+ import { t as verifyPortableObject } from "../portable-collection-CTcNJiAa.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 { a as fetchKeyDetailed, i as fetchKey } from "../key-CEsu7oaD.mjs";
6
- import { h as verifyJsonLd, p as signJsonLd } from "../ld-Cf4CPWN_.mjs";
7
- import { d as verifyProof, r as createProof } from "../proof-8WiH_-Gq.mjs";
8
- import { n as resolvePortableActorKey } from "../portable-key-woGH_1nn.mjs";
9
- import { f as verifyRequest, l as signRequest, p as verifyRequestDetailed } from "../http-DkqWu-sm.mjs";
5
+ import { a as fetchKeyDetailed, i as fetchKey } from "../key-B7N8mNoY.mjs";
6
+ import { h as verifyJsonLd, p as signJsonLd } from "../ld-BDMNyM2M.mjs";
7
+ import { d as verifyProof, r as createProof } from "../proof-nce4pf5S.mjs";
8
+ import { n as resolvePortableActorKey } from "../portable-key-B4QN3OzR.mjs";
9
+ import { f as verifyRequest, l as signRequest, p as verifyRequestDetailed } from "../http-DvpuyDJB.mjs";
10
10
  import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2 } from "../keys-DIJNHW-Y.mjs";
11
- import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-DSJ7nFgy.mjs";
11
+ import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-CzUycuhd.mjs";
12
12
  import { t as KvKeyCache } from "../keycache-Da8A8mZa.mjs";
13
13
  import { Create, CryptographicKey, Multikey, Note, Person } from "@fedify/vocab";
14
14
  import { FetchError, encodeMultibase, exportDidKey, exportSpki, parseIri, preloadedContexts } from "@fedify/vocab-runtime";
@@ -9,15 +9,17 @@ import { t as assertInstanceOf } from "../assert_instance_of-mrXWWNY-.mjs";
9
9
  import "../std__assert-DvMDRPes.mjs";
10
10
  import { t as assertRejects } from "../assert_rejects-CTptdYck.mjs";
11
11
  import { t as assert } from "../assert-D1Eafmd_.mjs";
12
+ import { a as verificationObservation } from "../verification-Dpfcw8ml.mjs";
12
13
  import { r as normalizeOutgoingActivityJsonLd } from "../outgoing-jsonld-4IJqPYos.mjs";
13
- import { a as signObject, c as verifyPortableObjectProof, d as verifyProof, i as hasProofLike, r as createProof, s as verifyObject } from "../proof-8WiH_-Gq.mjs";
14
- import { f as verifyRequest } from "../http-DkqWu-sm.mjs";
14
+ import { a as signObject, c as verifyPortableObjectProof, d as verifyProof, i as hasProofLike, o as verifyMapLocalProof, r as createProof, s as verifyObject } from "../proof-nce4pf5S.mjs";
15
+ import { f as verifyRequest } from "../http-DvpuyDJB.mjs";
15
16
  import { i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DIJNHW-Y.mjs";
16
- import { t as getAuthenticatedDocumentLoader } from "../docloader-CIP_SG39.mjs";
17
+ import { t as getAuthenticatedDocumentLoader } from "../docloader-Dv1JJl37.mjs";
17
18
  import { Create, DataIntegrityProof, Document, Multikey, Note, PUBLIC_COLLECTION, Place, Translation } from "@fedify/vocab";
18
19
  import { decodeMultibase, encodeMultibase, exportDidKey, exportMultibaseKey, formatIri, importMultibaseKey, parseIri } from "@fedify/vocab-runtime";
19
20
  import { createTestMeterProvider, mockDocumentLoader, test } from "@fedify/fixture";
20
21
  import { decodeHex } from "byte-encodings/hex";
22
+ import jsonld from "@fedify/vocab-runtime/jsonld";
21
23
  import serialize from "json-canon";
22
24
  //#region src/sig/proof.test.ts
23
25
  const fep8b32TestVectorPrivateKey = await crypto.subtle.importKey("jwk", {
@@ -797,6 +799,77 @@ test("verifyProof() records verification duration metric", async (t) => {
797
799
  assertFalse("object_integrity_proofs.cryptosuite" in measurements[0].attributes);
798
800
  });
799
801
  });
802
+ test("proof verification processes raw declaration contexts only for observers", async (t) => {
803
+ const options = {
804
+ documentLoader: mockDocumentLoader,
805
+ contextLoader: mockDocumentLoader
806
+ };
807
+ const proofUrl = `ap://did:key:${portableDidMethod}/proofs/diagnostics`;
808
+ const signed = await signPortableJsonLd({
809
+ "@context": portableContext,
810
+ id: `ap://did:key:${portableDidMethod}/objects/diagnostics`,
811
+ type: "Note",
812
+ attributedTo: `ap://did:key:${portableDidMethod}/actor`,
813
+ content: "Observed proof"
814
+ }, { proofOptions: { id: proofUrl } });
815
+ const rawProof = signed.proof;
816
+ const proof = await DataIntegrityProof.fromJsonLd(rawProof, options);
817
+ const referenced = { ...signed };
818
+ delete referenced.proof;
819
+ referenced["https://w3id.org/security#proof"] = { "@graph": [{ "@id": proofUrl }] };
820
+ const cases = [
821
+ {
822
+ name: "object",
823
+ verify: async (options) => await verifyObject(Note, structuredClone(signed), options) != null
824
+ },
825
+ {
826
+ name: "portable",
827
+ verify: async (options) => (await verifyPortableObjectProof(structuredClone(signed), options)).verified
828
+ },
829
+ {
830
+ name: "map-local",
831
+ verify: async (options) => await verifyMapLocalProof(structuredClone(signed), options) != null
832
+ },
833
+ {
834
+ name: "proof",
835
+ verify: async (options) => await verifyProof(structuredClone(signed), proof, options) != null
836
+ },
837
+ {
838
+ name: "remote proof",
839
+ verify: async (options) => await verifyObject(Note, structuredClone(referenced), {
840
+ ...options,
841
+ documentLoader: (url) => Promise.resolve({
842
+ contextUrl: null,
843
+ documentUrl: url,
844
+ document: structuredClone(rawProof)
845
+ })
846
+ }) != null
847
+ }
848
+ ];
849
+ for (const { name, verify } of cases) await t.step(name, async () => {
850
+ const original = jsonld.processContext;
851
+ let calls = 0;
852
+ jsonld.processContext = (...args) => {
853
+ calls++;
854
+ return original(...args);
855
+ };
856
+ try {
857
+ assert(await verify(options));
858
+ const unobservedCalls = calls;
859
+ calls = 0;
860
+ assert(await verify({
861
+ ...options,
862
+ [verificationObservation]: {
863
+ attempts: [],
864
+ attempt: { checks: [] }
865
+ }
866
+ }));
867
+ assert(calls > unobservedCalls, "Raw declaration processing should be absent from unobserved verification");
868
+ } finally {
869
+ jsonld.processContext = original;
870
+ }
871
+ });
872
+ });
800
873
  test("verifyPortableObjectProof()", async (t) => {
801
874
  const options = {
802
875
  documentLoader() {
@@ -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-8WiH_-Gq.mjs";
9
- import { p as verifyRequestDetailed } from "../http-DkqWu-sm.mjs";
10
- import { o as createFederation } from "../middleware-Dxn0E9ES.mjs";
11
- import { t as doesActorOwnKey } from "../owner-DSJ7nFgy.mjs";
8
+ import { c as verifyPortableObjectProof } from "../proof-nce4pf5S.mjs";
9
+ import { p as verifyRequestDetailed } from "../http-DvpuyDJB.mjs";
10
+ import { o as createFederation } from "../middleware-DAA7wDdS.mjs";
11
+ import { t as doesActorOwnKey } from "../owner-CzUycuhd.mjs";
12
12
  import { Follow, Person } from "@fedify/vocab";
13
13
  import { mockDocumentLoader, test } from "@fedify/fixture";
14
14
  import { encodeHex } from "byte-encodings/hex";
@@ -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-8WiH_-Gq.mjs";
8
- import { p as verifyRequestDetailed } from "../http-DkqWu-sm.mjs";
9
- import { t as doesActorOwnKey } from "../owner-DSJ7nFgy.mjs";
7
+ import { c as verifyPortableObjectProof } from "../proof-nce4pf5S.mjs";
8
+ import { p as verifyRequestDetailed } from "../http-DvpuyDJB.mjs";
9
+ import { t as doesActorOwnKey } from "../owner-CzUycuhd.mjs";
10
10
  import { Create } from "@fedify/vocab";
11
11
  import { decodeMultibase, importDidKey } from "@fedify/vocab-runtime";
12
12
  import { mockDocumentLoader, test } from "@fedify/fixture";
@@ -0,0 +1,2 @@
1
+ import { Temporal } from "temporal-polyfill";
2
+ import { URLPattern } from "urlpattern-polyfill";
@@ -0,0 +1,310 @@
1
+ import "temporal-polyfill";
2
+ import "urlpattern-polyfill";
3
+ globalThis.addEventListener = () => {};
4
+ import { a as verificationObservation } from "../verification-Dpfcw8ml.mjs";
5
+ import { h as verifyJsonLd, p as signJsonLd } from "../ld-BDMNyM2M.mjs";
6
+ import { a as signObject, s as verifyObject } from "../proof-nce4pf5S.mjs";
7
+ import { l as signRequest, p as verifyRequestDetailed } from "../http-DvpuyDJB.mjs";
8
+ import { i as rsaPrivateKey2, n as ed25519PrivateKey, o as rsaPublicKey1, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DIJNHW-Y.mjs";
9
+ import { Activity, Create, CryptographicKey, Multikey } from "@fedify/vocab";
10
+ import { FetchError } from "@fedify/vocab-runtime";
11
+ import { mockDocumentLoader, test } from "@fedify/fixture";
12
+ import { deepStrictEqual, ok, strictEqual } from "node:assert/strict";
13
+ //#region src/sig/verification.test.ts
14
+ const loaders = {
15
+ documentLoader: mockDocumentLoader,
16
+ contextLoader: mockDocumentLoader
17
+ };
18
+ function observation() {
19
+ return { attempts: [] };
20
+ }
21
+ test("LDS evidence has no checks for absent or malformed signatures", async () => {
22
+ const json = await new Create({ actor: rsaPublicKey2.ownerId }).toJsonLd(loaders);
23
+ for (const signature of [
24
+ void 0,
25
+ null,
26
+ "invalid",
27
+ [],
28
+ {}
29
+ ]) {
30
+ const evidence = observation();
31
+ strictEqual(await verifyJsonLd(signature === void 0 ? json : {
32
+ ...json,
33
+ signature
34
+ }, {
35
+ ...loaders,
36
+ [verificationObservation]: evidence
37
+ }), false);
38
+ const attempt = evidence.attempts[0];
39
+ ok(attempt.status === "rejected");
40
+ strictEqual(attempt.reason.type, signature === void 0 ? "noSignature" : "signatureVerificationFailed");
41
+ deepStrictEqual(attempt.checks, []);
42
+ }
43
+ });
44
+ test("signature evidence preserves stale and fresh HTTP keys for both specs", async () => {
45
+ for (const spec of ["draft-cavage-http-signatures-12", "rfc9421"]) {
46
+ const evidence = observation();
47
+ const signed = await signRequest(new Request("https://example.com/inbox", {
48
+ method: "POST",
49
+ body: "{}"
50
+ }), rsaPrivateKey2, rsaPublicKey2.id, { spec });
51
+ const stale = rsaPublicKey1.clone({ id: rsaPublicKey2.id });
52
+ strictEqual((await verifyRequestDetailed(signed, {
53
+ ...loaders,
54
+ [verificationObservation]: evidence,
55
+ keyCache: {
56
+ get: () => Promise.resolve(stale),
57
+ set: () => Promise.resolve()
58
+ }
59
+ })).verified, true);
60
+ const attempt = evidence.attempts[0];
61
+ ok(attempt.status === "verified");
62
+ strictEqual(attempt.checks.length, 1);
63
+ const check = attempt.checks[0];
64
+ ok(check.status === "verified");
65
+ strictEqual(check.triedKeys.length, 2);
66
+ strictEqual(check.triedKeys[0].publicKey, rsaPublicKey1.publicKey);
67
+ deepStrictEqual(await crypto.subtle.exportKey("jwk", check.triedKeys[1].publicKey), await crypto.subtle.exportKey("jwk", rsaPublicKey2.publicKey));
68
+ strictEqual(check.key, check.triedKeys[1]);
69
+ strictEqual(attempt.signatures[0], check);
70
+ }
71
+ });
72
+ test("signature evidence retains the failed key when HTTP refresh cannot load", async () => {
73
+ for (const spec of ["draft-cavage-http-signatures-12", "rfc9421"]) {
74
+ const evidence = observation();
75
+ const signed = await signRequest(new Request("https://example.com/inbox", {
76
+ method: "POST",
77
+ body: "{}"
78
+ }), rsaPrivateKey2, rsaPublicKey2.id, { spec });
79
+ const response = new Response(null, { status: 410 });
80
+ strictEqual((await verifyRequestDetailed(signed, {
81
+ ...loaders,
82
+ [verificationObservation]: evidence,
83
+ documentLoader: () => Promise.reject(new FetchError(rsaPublicKey2.id, "gone", response)),
84
+ keyCache: {
85
+ get: () => Promise.resolve(rsaPublicKey1.clone({ id: rsaPublicKey2.id })),
86
+ set: () => Promise.resolve()
87
+ }
88
+ })).verified, false);
89
+ const check = evidence.attempts[0].checks[0];
90
+ ok(check.status === "rejected");
91
+ strictEqual(check.reason.type, "keyFetchError");
92
+ strictEqual(check.triedKeys[0].publicKey, rsaPublicKey1.publicKey);
93
+ }
94
+ });
95
+ test("signature evidence preserves failed LDS keys and successful stale-key refresh", async () => {
96
+ const signed = await signJsonLd(await new Create({ actor: new URL("https://example.com/person") }).toJsonLd(loaders), rsaPrivateKey2, rsaPublicKey2.id, loaders);
97
+ const evidence = observation();
98
+ strictEqual(await verifyJsonLd(signed, {
99
+ ...loaders,
100
+ [verificationObservation]: evidence,
101
+ keyCache: {
102
+ get: () => Promise.resolve(rsaPublicKey1.clone({ id: rsaPublicKey2.id })),
103
+ set: () => Promise.resolve()
104
+ }
105
+ }), false);
106
+ const attempt = evidence.attempts[0];
107
+ ok(attempt.status === "rejected");
108
+ strictEqual(attempt.reason.type, "missingOwner");
109
+ strictEqual(attempt.checks[0].status, "verified");
110
+ strictEqual(attempt.checks[0].triedKeys.length, 2);
111
+ const bad = observation();
112
+ strictEqual(await verifyJsonLd(signed, {
113
+ ...loaders,
114
+ [verificationObservation]: bad,
115
+ documentLoader: async () => ({
116
+ contextUrl: null,
117
+ documentUrl: rsaPublicKey2.id.href,
118
+ document: await new CryptographicKey({
119
+ id: rsaPublicKey2.id,
120
+ publicKey: rsaPublicKey1.publicKey
121
+ }).toJsonLd(loaders)
122
+ })
123
+ }), false);
124
+ strictEqual(bad.attempts[0].checks[0].status, "rejected");
125
+ strictEqual(bad.attempts[0].checks[0].triedKeys.length, 1);
126
+ });
127
+ test("signature evidence preserves multiple valid proofs despite uncovered attribution", async () => {
128
+ const second = await signObject(await signObject(new Create({ actor: new URL("https://example.com/person") }), ed25519PrivateKey, ed25519Multikey.id, loaders), ed25519PrivateKey, ed25519Multikey.id, loaders);
129
+ const evidence = observation();
130
+ strictEqual(await verifyObject(Activity, await second.toJsonLd(loaders), {
131
+ ...loaders,
132
+ [verificationObservation]: evidence
133
+ }), null);
134
+ const attempt = evidence.attempts[0];
135
+ ok(attempt.status === "rejected");
136
+ strictEqual(attempt.reason.type, "uncoveredAttribution");
137
+ strictEqual(attempt.checks.length, 2);
138
+ ok(attempt.checks.every((check) => check.status === "verified"));
139
+ });
140
+ test("signature evidence preserves OIP stale keys when fresh verification fails", async () => {
141
+ const signed = await signObject(new Create({ actor: ed25519Multikey.controllerId }), ed25519PrivateKey, ed25519Multikey.id, loaders);
142
+ const pair = await crypto.subtle.generateKey("Ed25519", true, ["sign", "verify"]);
143
+ const stale = new Multikey({
144
+ id: ed25519Multikey.id,
145
+ controller: null,
146
+ publicKey: pair.publicKey
147
+ });
148
+ const evidence = observation();
149
+ strictEqual(await verifyObject(Activity, await signed.toJsonLd(loaders), {
150
+ ...loaders,
151
+ [verificationObservation]: evidence,
152
+ keyCache: {
153
+ get: () => Promise.resolve(stale),
154
+ set: () => Promise.resolve()
155
+ },
156
+ documentLoader: async () => ({
157
+ contextUrl: null,
158
+ documentUrl: ed25519Multikey.id.href,
159
+ document: await stale.toJsonLd(loaders)
160
+ })
161
+ }), null);
162
+ const check = evidence.attempts[0].checks[0];
163
+ strictEqual(check.status, "rejected");
164
+ strictEqual(check.triedKeys.length, 2);
165
+ strictEqual(check.triedKeys[0].publicKey, pair.publicKey);
166
+ });
167
+ test("OIP check preserves the literal declared key ID", async () => {
168
+ const json = await (await signObject(new Create({ actor: ed25519Multikey.controllerId }), ed25519PrivateKey, ed25519Multikey.id, loaders)).toJsonLd(loaders);
169
+ const proof = json.proof;
170
+ const declaredKeyId = "https://EXAMPLE.com/person2#key4";
171
+ proof.verificationMethod = declaredKeyId;
172
+ const evidence = observation();
173
+ await verifyObject(Activity, json, {
174
+ ...loaders,
175
+ [verificationObservation]: evidence
176
+ });
177
+ strictEqual(evidence.attempts[0].checks[0].declaredKeyId, declaredKeyId);
178
+ });
179
+ test("signature observation cannot turn a cached miss into a metadata exception", async () => {
180
+ const json = await signJsonLd(await new Create({ actor: new URL("https://example.com/person") }).toJsonLd(loaders), rsaPrivateKey2, rsaPublicKey2.id, loaders);
181
+ const evidence = observation();
182
+ const cache = {
183
+ get: () => Promise.resolve(null),
184
+ set: () => Promise.resolve(),
185
+ getFetchError: () => Promise.reject(/* @__PURE__ */ new Error("diagnostic unavailable"))
186
+ };
187
+ strictEqual(await verifyJsonLd(json, {
188
+ ...loaders,
189
+ keyCache: cache,
190
+ [verificationObservation]: evidence
191
+ }), false);
192
+ strictEqual(evidence.attempts[0].checks[0].status, "rejected");
193
+ });
194
+ test("signature observation preserves rejection for consumed fetch-error responses", async () => {
195
+ const json = await signJsonLd(await new Create({ actor: new URL("https://example.com/person") }).toJsonLd(loaders), rsaPrivateKey2, rsaPublicKey2.id, loaders);
196
+ const response = new Response("gone", { status: 410 });
197
+ await response.text();
198
+ const error = new FetchError(rsaPublicKey2.id, "gone", response);
199
+ const options = {
200
+ ...loaders,
201
+ documentLoader: () => Promise.reject(error)
202
+ };
203
+ strictEqual(await verifyJsonLd(json, options), false);
204
+ const evidence = observation();
205
+ strictEqual(await verifyJsonLd(json, {
206
+ ...options,
207
+ [verificationObservation]: evidence
208
+ }), false);
209
+ const check = evidence.attempts[0].checks[0];
210
+ ok(check.status === "rejected" && check.reason.type === "keyFetchError");
211
+ let cloneThrows = false;
212
+ try {
213
+ response.clone();
214
+ } catch {
215
+ cloneThrows = true;
216
+ }
217
+ if (cloneThrows) {
218
+ ok("error" in check.reason.result);
219
+ strictEqual(check.reason.result.error, error);
220
+ } else {
221
+ ok("status" in check.reason.result);
222
+ strictEqual(check.reason.result.status, 410);
223
+ }
224
+ });
225
+ test("OIP check retains aliased declarations without extra context fetches", async () => {
226
+ const json = await (await signObject(new Create({ actor: ed25519Multikey.controllerId }), ed25519PrivateKey, ed25519Multikey.id, loaders)).toJsonLd(loaders);
227
+ const proof = json.proof;
228
+ const context = { vm: {
229
+ "@id": "https://w3id.org/security#verificationMethod",
230
+ "@type": "@id"
231
+ } };
232
+ const contextUrl = "https://example.com/custom-proof-context";
233
+ json["@context"] = [...json["@context"], contextUrl];
234
+ proof["@context"] = [...proof["@context"], contextUrl];
235
+ const declaredKeyId = "https://EXAMPLE.com/person2#key4";
236
+ proof.vm = declaredKeyId;
237
+ delete proof.verificationMethod;
238
+ const run = async (evidence) => {
239
+ let fetches = 0;
240
+ await verifyObject(Activity, structuredClone(json), {
241
+ ...loaders,
242
+ contextLoader: async (url, options) => {
243
+ fetches++;
244
+ if (url === contextUrl) return {
245
+ contextUrl: null,
246
+ documentUrl: url,
247
+ document: { "@context": context }
248
+ };
249
+ return await mockDocumentLoader(url, options);
250
+ },
251
+ ...evidence == null ? {} : { [verificationObservation]: evidence }
252
+ });
253
+ return fetches;
254
+ };
255
+ const baselineFetches = await run();
256
+ const evidence = observation();
257
+ strictEqual(await run(evidence), baselineFetches);
258
+ strictEqual(evidence.attempts[0].checks[0].declaredKeyId, declaredKeyId);
259
+ });
260
+ test("OIP check preserves compact node identifiers and their aliases", async () => {
261
+ for (const idProperty of [
262
+ "id",
263
+ "rawId",
264
+ "scopedId"
265
+ ]) {
266
+ const json = await (await signObject(new Create({ actor: ed25519Multikey.controllerId }), ed25519PrivateKey, ed25519Multikey.id, loaders)).toJsonLd(loaders);
267
+ const proof = json.proof;
268
+ const context = {
269
+ rawId: "@id",
270
+ vm: {
271
+ "@id": "https://w3id.org/security#verificationMethod",
272
+ "@type": "@id",
273
+ "@context": { scopedId: "@id" }
274
+ }
275
+ };
276
+ json["@context"] = [...json["@context"], context];
277
+ proof["@context"] = [...proof["@context"], context];
278
+ const declaredKeyId = "https://EXAMPLE.com/person2#key4";
279
+ if (idProperty === "scopedId") {
280
+ proof.vm = { [idProperty]: declaredKeyId };
281
+ delete proof.verificationMethod;
282
+ } else proof.verificationMethod = { [idProperty]: declaredKeyId };
283
+ const evidence = observation();
284
+ await verifyObject(Activity, json, {
285
+ ...loaders,
286
+ [verificationObservation]: evidence
287
+ });
288
+ strictEqual(evidence.attempts[0].checks[0].declaredKeyId, declaredKeyId);
289
+ }
290
+ });
291
+ test("signature evidence excludes keys loaded before canonicalization errors", async () => {
292
+ const json = await (await signObject(new Create({ actor: ed25519Multikey.controllerId }), ed25519PrivateKey, ed25519Multikey.id, loaders)).toJsonLd(loaders);
293
+ json.extra = JSON.parse("1e400");
294
+ const evidence = observation();
295
+ let thrown = false;
296
+ try {
297
+ await verifyObject(Activity, json, {
298
+ ...loaders,
299
+ [verificationObservation]: evidence
300
+ });
301
+ } catch {
302
+ thrown = true;
303
+ }
304
+ strictEqual(thrown, true);
305
+ const check = evidence.attempts[0].checks[0];
306
+ strictEqual(check.status, "error");
307
+ deepStrictEqual(check.triedKeys, []);
308
+ });
309
+ //#endregion
310
+ export {};