@fedify/fedify 2.4.0-pr.936.41 → 2.5.0-dev.2271

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 (244) hide show
  1. package/README.md +50 -39
  2. package/dist/{assert-CJ1KXcvv.mjs → assert-D1Eafmd_.mjs} +1 -1
  3. package/dist/{assert_equals-BV7oLMxm.mjs → assert_equals-Z6IcEbWU.mjs} +2 -28
  4. package/dist/assert_exists-cffSpJ7X.mjs +28 -0
  5. package/dist/assert_false-CPdRnc3E.mjs +23 -0
  6. package/dist/assert_greater_or_equal-BlafOF4-.mjs +31 -0
  7. package/dist/{assert_instance_of-Q9KTBnrf.mjs → assert_instance_of-mrXWWNY-.mjs} +1 -1
  8. package/dist/{assert_not_equals-EPJPoxuf.mjs → assert_not_equals-CpPK2t89.mjs} +2 -1
  9. package/dist/assert_rejects-CTptdYck.mjs +39 -0
  10. package/dist/{assert_strict_equals-Ec20AUwa.mjs → assert_strict_equals-CYvBmkpC.mjs} +2 -1
  11. package/dist/{assert_throws-NiFfqbnH.mjs → assert_throws-BYITOvPO.mjs} +2 -1
  12. package/dist/assertion_error-B-cx0fFA.mjs +31 -0
  13. package/dist/audience-CHQ-FlLD.mjs +95 -0
  14. package/dist/{builder-DonuxRl_.mjs → builder-Bda6LK7A.mjs} +169 -14
  15. package/dist/{circuit-breaker-CBGyz5F7.mjs → circuit-breaker-XJ53md4S.mjs} +224 -17
  16. package/dist/circuit-breaker-test-utils-DW6YC_Pe.mjs +14 -0
  17. package/dist/{client-CjF5IYQS.mjs → client-CEnNz8O7.mjs} +144 -8
  18. package/dist/{codec-BBga-FWI.mjs → codec-C6rTrpIp.mjs} +26 -3
  19. package/dist/{collection-BIhlldqK.mjs → collection-CnnP1UAv.mjs} +1 -1
  20. package/dist/compat/mod.cjs +1 -1
  21. package/dist/compat/mod.d.cts +1 -1
  22. package/dist/compat/mod.d.ts +1 -1
  23. package/dist/compat/mod.js +1 -1
  24. package/dist/compat/outgoing-jsonld.test.mjs +71 -3
  25. package/dist/compat/public-audience.test.mjs +14 -5
  26. package/dist/compat/secured-document.test.d.mts +2 -0
  27. package/dist/compat/secured-document.test.mjs +58 -0
  28. package/dist/compat/transformers.test.mjs +5 -5
  29. package/dist/compound-proof-B-9mXxFW.mjs +989 -0
  30. package/dist/{context-Zii1f5xS.d.ts → context-7NyiqIcg.d.ts} +1600 -25
  31. package/dist/{context-BJXxPElm.mjs → context-8Tu9kea0.mjs} +21 -63
  32. package/dist/{context-lxX6I7as.d.cts → context-tsYPJ2Ew.d.cts} +1600 -25
  33. package/dist/{deno-BHzKn9Ig.mjs → deno-oR5aJKpU.mjs} +1 -1
  34. package/dist/dist-DJQM4u7i.mjs +189 -0
  35. package/dist/docloader-DBoYbvYW.mjs +87 -0
  36. package/dist/{esm-yYQfPhIY.mjs → esm-BHXXx4Wx.mjs} +13 -6
  37. package/dist/federation/audience.test.d.mts +2 -0
  38. package/dist/federation/audience.test.mjs +130 -0
  39. package/dist/federation/builder.test.mjs +54 -5
  40. package/dist/federation/circuit-breaker.test.mjs +838 -7
  41. package/dist/federation/collection.test.mjs +3 -3
  42. package/dist/federation/compound-fanout.test.d.mts +2 -0
  43. package/dist/federation/compound-fanout.test.mjs +228 -0
  44. package/dist/federation/handler-compound-proof.test.d.mts +2 -0
  45. package/dist/federation/handler-compound-proof.test.mjs +384 -0
  46. package/dist/federation/handler.test.mjs +385 -15
  47. package/dist/federation/hashlink-media.test.d.mts +2 -0
  48. package/dist/federation/hashlink-media.test.mjs +422 -0
  49. package/dist/federation/idempotency.test.mjs +6 -6
  50. package/dist/federation/inbox-report.test.d.mts +2 -0
  51. package/dist/federation/inbox-report.test.mjs +475 -0
  52. package/dist/federation/inbox.test.mjs +3 -3
  53. package/dist/federation/keycache.test.mjs +215 -14
  54. package/dist/federation/kv.test.mjs +3 -3
  55. package/dist/federation/metrics.test.mjs +5 -5
  56. package/dist/federation/middleware.test.mjs +967 -35
  57. package/dist/federation/mod.cjs +18 -261
  58. package/dist/federation/mod.d.cts +5 -5
  59. package/dist/federation/mod.d.ts +5 -5
  60. package/dist/federation/mod.js +279 -1
  61. package/dist/federation/mq.test.mjs +123 -47
  62. package/dist/federation/negotiation.test.mjs +4 -4
  63. package/dist/federation/outgoing-proof.test.d.mts +2 -0
  64. package/dist/federation/outgoing-proof.test.mjs +931 -0
  65. package/dist/federation/portable-actor.test.d.mts +2 -0
  66. package/dist/federation/portable-actor.test.mjs +496 -0
  67. package/dist/federation/portable-chain.test.d.mts +2 -0
  68. package/dist/federation/portable-chain.test.mjs +370 -0
  69. package/dist/federation/portable-collection.test.d.mts +2 -0
  70. package/dist/federation/portable-collection.test.mjs +832 -0
  71. package/dist/federation/portable-delivery.test.d.mts +2 -0
  72. package/dist/federation/portable-delivery.test.mjs +746 -0
  73. package/dist/federation/portable-gateway-keys.test.d.mts +2 -0
  74. package/dist/federation/portable-gateway-keys.test.mjs +686 -0
  75. package/dist/federation/portable-inbox.test.d.mts +2 -0
  76. package/dist/federation/portable-inbox.test.mjs +1535 -0
  77. package/dist/federation/portable-parse-uri.test.d.mts +2 -0
  78. package/dist/federation/portable-parse-uri.test.mjs +348 -0
  79. package/dist/federation/portable-route-activity.test.d.mts +2 -0
  80. package/dist/federation/portable-route-activity.test.mjs +259 -0
  81. package/dist/federation/portable.test.d.mts +2 -0
  82. package/dist/federation/portable.test.mjs +1072 -0
  83. package/dist/federation/retry.test.mjs +4 -3
  84. package/dist/federation/router.test.mjs +9 -159
  85. package/dist/federation/send.test.mjs +245 -27
  86. package/dist/federation/tasks/codec.test.mjs +4 -4
  87. package/dist/federation/tasks/enqueue.test.mjs +42 -4
  88. package/dist/federation/tasks/tasks.test.mjs +7 -6
  89. package/dist/federation/temporal.test.mjs +4 -4
  90. package/dist/federation/webfinger.test.mjs +275 -12
  91. package/dist/{middleware-FrSMAYEx.cjs → federation-CkZiAcWY.cjs} +8640 -3722
  92. package/dist/http-B5JT115n.cjs +10630 -0
  93. package/dist/http-DydWCB7R.js +6527 -0
  94. package/dist/{http-CPVMUgsW.mjs → http-siciWkmx.mjs} +397 -168
  95. package/dist/key-BspPiXqn.mjs +951 -0
  96. package/dist/key-C1nv7_jD.d.ts +1125 -0
  97. package/dist/key-DYxuyd-s.d.cts +1125 -0
  98. package/dist/key-owner-evidence-APB6NpSk.mjs +108 -0
  99. package/dist/keycache-Da8A8mZa.mjs +200 -0
  100. package/dist/{kv-D6hNiMTK.d.ts → kv-B2mzK5tl.d.cts} +3 -2
  101. package/dist/{kv-gJ8LYbxX.d.cts → kv-B2mzK5tl.d.ts} +3 -2
  102. package/dist/kv-DBRWVx3Q.mjs +104 -0
  103. package/dist/{kv-cache-KyGqJqSp.mjs → kv-cache-BF1hnW65.mjs} +1 -1
  104. package/dist/{kv-cache-5bnX3-Jq.js → kv-cache-CTQr1tbn.js} +54 -16
  105. package/dist/{kv-cache-DQ29C4XL.cjs → kv-cache-DCac1nEU.cjs} +55 -19
  106. package/dist/{ld-Cj9F_5AP.mjs → ld-CzaP-hJl.mjs} +44 -12
  107. package/dist/map-local-context-conflict-DOYEEJ3u.mjs +204 -0
  108. package/dist/map-local-create-note-B0SeXJms.mjs +214 -0
  109. package/dist/{metrics-DMk-nTxI.mjs → metrics-CYg9yxBL.mjs} +3 -2
  110. package/dist/metrics-DVKYY6K1.d.cts +36 -0
  111. package/dist/metrics-DoRtI0qU.d.ts +36 -0
  112. package/dist/{middleware-Y-kpsp6S.js → middleware-CsDDXKuL.js} +5493 -1103
  113. package/dist/{middleware-CvwTUgnP.mjs → middleware-D7_LO-Vs.mjs} +3157 -272
  114. package/dist/{middleware-CEctxBN6.mjs → middleware-DWjrfpcz.mjs} +1 -1
  115. package/dist/{mod-gOlPDuT8.d.cts → mod-BojP2Bw3.d.cts} +1 -1
  116. package/dist/mod-CavhAgLw.d.cts +320 -0
  117. package/dist/mod-CtpF2BU5.d.ts +320 -0
  118. package/dist/{mod-BtEaIEcD.d.cts → mod-DEZXwV6J.d.ts} +10 -4
  119. package/dist/{mod-UMmveiO0.d.ts → mod-Dw-nPxQh.d.cts} +10 -4
  120. package/dist/{mod-DLc2Ot6f.d.ts → mod-Xj5P4s4d.d.ts} +1 -1
  121. package/dist/mod.cjs +40 -39
  122. package/dist/mod.d.cts +10 -11
  123. package/dist/mod.d.ts +10 -11
  124. package/dist/mod.js +9 -9
  125. package/dist/{mq-llHKivST.mjs → mq-Dm1Wmtm-.mjs} +6 -0
  126. package/dist/nodeinfo/client.test.mjs +139 -4
  127. package/dist/nodeinfo/handler.test.mjs +5 -5
  128. package/dist/nodeinfo/mod.cjs +1 -1
  129. package/dist/nodeinfo/mod.d.cts +1 -1
  130. package/dist/nodeinfo/mod.d.ts +1 -1
  131. package/dist/nodeinfo/mod.js +1 -1
  132. package/dist/nodeinfo/types.test.mjs +4 -4
  133. package/dist/otel/exporter.test.mjs +3 -3
  134. package/dist/otel/mod.cjs +0 -1
  135. package/dist/otel/mod.d.cts +1 -1
  136. package/dist/otel/mod.d.ts +1 -1
  137. package/dist/{outgoing-jsonld-URuqsICz.mjs → outgoing-jsonld-4IJqPYos.mjs} +12 -10
  138. package/dist/{owner-DEvZuyOE.d.cts → owner-BF0L9cMt.d.cts} +11 -0
  139. package/dist/{owner-CnngXDNJ.d.ts → owner-BSzr5-I8.d.ts} +11 -0
  140. package/dist/owner-DYgfTFHy.mjs +267 -0
  141. package/dist/portable-collection-BpsVsRov.js +670 -0
  142. package/dist/portable-collection-C74P1vtC.mjs +418 -0
  143. package/dist/portable-collection-DZd2bm7M.cjs +686 -0
  144. package/dist/portable-key-BIMLrAP4.mjs +549 -0
  145. package/dist/portable-key-id-Ca30-hOa.mjs +248 -0
  146. package/dist/proof-Dxy6ByqI.mjs +1299 -0
  147. package/dist/{public-audience-Cr5MsnMq.mjs → public-audience--klBIOk1.mjs} +15 -10
  148. package/dist/router-u5O5KCQr.mjs +156 -0
  149. package/dist/runtime/mod.cjs +1 -1
  150. package/dist/runtime/mod.js +1 -1
  151. package/dist/secured-document-CxzZZ9nL.mjs +35 -0
  152. package/dist/send-C4dDpAxm.mjs +495 -0
  153. package/dist/sig/accept.test.mjs +1 -1
  154. package/dist/sig/compound-proof-discovery.test.d.mts +2 -0
  155. package/dist/sig/compound-proof-discovery.test.mjs +331 -0
  156. package/dist/sig/compound-proof-producer.test.d.mts +2 -0
  157. package/dist/sig/compound-proof-producer.test.mjs +107 -0
  158. package/dist/sig/compound-proof-verification.test.d.mts +2 -0
  159. package/dist/sig/compound-proof-verification.test.mjs +833 -0
  160. package/dist/sig/compound-proof.test.d.mts +2 -0
  161. package/dist/sig/compound-proof.test.mjs +411 -0
  162. package/dist/sig/http.test.mjs +702 -31
  163. package/dist/sig/key-owner-evidence.test.d.mts +2 -0
  164. package/dist/sig/key-owner-evidence.test.mjs +100 -0
  165. package/dist/sig/key.test.mjs +220 -8
  166. package/dist/sig/ld.test.mjs +65 -7
  167. package/dist/sig/mitra-receive-interop.test.d.mts +2 -0
  168. package/dist/sig/mitra-receive-interop.test.mjs +260 -0
  169. package/dist/sig/mitra-send-interop.test.d.mts +2 -0
  170. package/dist/sig/mitra-send-interop.test.mjs +461 -0
  171. package/dist/sig/mod.cjs +18 -16
  172. package/dist/sig/mod.d.cts +4 -4
  173. package/dist/sig/mod.d.ts +4 -4
  174. package/dist/sig/mod.js +3 -3
  175. package/dist/sig/owner.test.mjs +108 -9
  176. package/dist/sig/portable-collection.test.d.mts +2 -0
  177. package/dist/sig/portable-collection.test.mjs +697 -0
  178. package/dist/sig/portable-interop.test.d.mts +2 -0
  179. package/dist/sig/portable-interop.test.mjs +156 -0
  180. package/dist/sig/portable-key-id.test.d.mts +2 -0
  181. package/dist/sig/portable-key-id.test.mjs +67 -0
  182. package/dist/sig/portable-key.test.d.mts +2 -0
  183. package/dist/sig/portable-key.test.mjs +1439 -0
  184. package/dist/sig/proof.test.mjs +1753 -16
  185. package/dist/sig/tootik-request-interop.test.d.mts +2 -0
  186. package/dist/sig/tootik-request-interop.test.mjs +190 -0
  187. package/dist/sig/tootik-send-interop.test.d.mts +2 -0
  188. package/dist/sig/tootik-send-interop.test.mjs +331 -0
  189. package/dist/sig/verification.test.d.mts +2 -0
  190. package/dist/sig/verification.test.mjs +310 -0
  191. package/dist/std__assert-DvMDRPes.mjs +8 -0
  192. package/dist/{testing-CO7ftO8A.mjs → tasks-IG3pHfvZ.mjs} +2 -2
  193. package/dist/{temporal-fsXO5IvD.mjs → temporal-D0KJI4NF.mjs} +3 -3
  194. package/dist/testing/context.test.d.mts +2 -0
  195. package/dist/testing/context.test.mjs +19 -0
  196. package/dist/testing/kv.test.d.mts +2 -0
  197. package/dist/testing/kv.test.mjs +101 -0
  198. package/dist/testing/mod.d.mts +1617 -48
  199. package/dist/testing/mod.mjs +6 -3
  200. package/dist/testing-t8xDeJZ5.mjs +8 -0
  201. package/dist/{transformers-DGwl-hD1.cjs → transformers-BalCrSsr.cjs} +0 -1
  202. package/dist/{types-DC1pNgJA.js → types-_S2_MeLF.js} +144 -8
  203. package/dist/{types-CPym83zc.cjs → types-poIao40f.cjs} +160 -7
  204. package/dist/utils/docloader.test.mjs +530 -8
  205. package/dist/utils/kv-cache.test.mjs +2 -2
  206. package/dist/utils/mod.cjs +1 -1
  207. package/dist/utils/mod.d.cts +1 -1
  208. package/dist/utils/mod.d.ts +1 -1
  209. package/dist/utils/mod.js +1 -1
  210. package/dist/verification-C3954hQh.mjs +5 -0
  211. package/dist/verification-Dpfcw8ml.mjs +105 -0
  212. package/dist/vocab/cjs.test.mjs +1 -1
  213. package/package.json +8 -8
  214. package/dist/assert_rejects-EgstcQy5.mjs +0 -82
  215. package/dist/docloader-e1khNUKy.mjs +0 -49
  216. package/dist/http-CsmQ-BQ4.js +0 -2483
  217. package/dist/http-VyDTd4G3.d.cts +0 -553
  218. package/dist/http-hlIjmewS.cjs +0 -2694
  219. package/dist/http-lf8Hsd91.d.ts +0 -553
  220. package/dist/key-DfPsX8hv.mjs +0 -453
  221. package/dist/keycache-_DHqz5z_.mjs +0 -97
  222. package/dist/metrics-CoUJLQhZ.d.cts +0 -276
  223. package/dist/metrics-Dc4jR-IC.d.ts +0 -276
  224. package/dist/mod-B0hW12_O.d.cts +0 -307
  225. package/dist/mod-COIAjwRS.d.ts +0 -307
  226. package/dist/owner-Br9YYzn_.mjs +0 -120
  227. package/dist/proof-B4ngoaNQ.mjs +0 -316
  228. package/dist/proof-B6E0XUXJ.js +0 -1415
  229. package/dist/proof-NN4xCQGL.cjs +0 -1562
  230. package/dist/send-CxHKUNzv.mjs +0 -239
  231. package/dist/std__assert-B2NnY9bq.mjs +0 -79
  232. package/dist/temporal-polyfill-BCdTHexd.cjs +0 -3565
  233. /package/dist/{accept-8PiolDP7.mjs → accept-CPVqki78.mjs} +0 -0
  234. /package/dist/{activity-listener-BtTSxZWA.mjs → activity-listener-C-BSbKI7.mjs} +0 -0
  235. /package/dist/{client-CAM_bQXx.d.cts → client-D-XP_Ccb.d.cts} +0 -0
  236. /package/dist/{client-CSddvgWN.d.ts → client-D-XP_Ccb.d.ts} +0 -0
  237. /package/dist/{keys-Dbyd7bhl.mjs → keys-DIJNHW-Y.mjs} +0 -0
  238. /package/dist/{kv-CXBAok3k.mjs → kv-DCHkaJ9-.mjs} +0 -0
  239. /package/dist/{negotiation-RuwrPFqi.mjs → negotiation-CCocWT_N.mjs} +0 -0
  240. /package/dist/{retry-DgFqeS5k.mjs → retry-zX5xw5e0.mjs} +0 -0
  241. /package/dist/{chunk-D5IdezsZ.js → rolldown-runtime-BC-Eo5Mj.js} +0 -0
  242. /package/dist/{chunk-Czpeue4M.cjs → rolldown-runtime-Dmm3t92W.cjs} +0 -0
  243. /package/dist/{transformers-DXze6FUB.js → transformers-DAtXl_Kc.js} +0 -0
  244. /package/dist/{types-CrtdVuDP.mjs → types-DE_LV1JB.mjs} +0 -0
@@ -0,0 +1,1125 @@
1
+ /// <reference lib="esnext.temporal" />
2
+ import { Actor, CryptographicKey, DataIntegrityProof, Multikey, Object as Object$1 } from "@fedify/vocab";
3
+ import { MeterProvider, TracerProvider } from "@opentelemetry/api";
4
+ import { DocumentLoader, PortableObjectVerifier } from "@fedify/vocab-runtime";
5
+
6
+ //#region src/sig/proof.d.ts
7
+ /**
8
+ * Checks if the given JSON-LD document has a DataIntegrityProof-like object,
9
+ * without fully deserializing it into vocabulary classes.
10
+ * @param jsonLd The JSON-LD document to check.
11
+ * @returns `true` if the document has a proof-like object; `false` otherwise.
12
+ * @since 2.2.0
13
+ */
14
+ declare function hasProofLike(jsonLd: unknown): boolean;
15
+ /**
16
+ * Options for {@link createProof}.
17
+ * @since 0.10.0
18
+ */
19
+ interface CreateProofOptions {
20
+ /**
21
+ * The context loader for loading remote JSON-LD contexts.
22
+ */
23
+ contextLoader?: DocumentLoader;
24
+ /**
25
+ * The JSON-LD context to use for serializing the object to sign.
26
+ */
27
+ context?: string | Record<string, string> | (string | Record<string, string>)[];
28
+ /**
29
+ * The time when the proof was created. If not specified, the current time
30
+ * will be used.
31
+ */
32
+ created?: Temporal.Instant;
33
+ }
34
+ /**
35
+ * Creates a proof for the given object.
36
+ * @param object The object to create a proof for.
37
+ * @param privateKey The private key to sign the proof with.
38
+ * @param keyId The key ID to use in the proof. It will be used by the verifier.
39
+ * @param options Additional options. See also {@link CreateProofOptions}.
40
+ * @returns The created proof.
41
+ * @throws {TypeError} If the private key is invalid or unsupported.
42
+ * @since 0.10.0
43
+ */
44
+ declare function createProof(object: Object$1, privateKey: CryptoKey, keyId: URL, options?: CreateProofOptions): Promise<DataIntegrityProof>;
45
+ /**
46
+ * Options for {@link signObject}.
47
+ * @since 0.10.0
48
+ */
49
+ interface SignObjectOptions extends CreateProofOptions {
50
+ /**
51
+ * The document loader for loading remote JSON-LD documents.
52
+ */
53
+ documentLoader?: DocumentLoader;
54
+ /**
55
+ * The OpenTelemetry tracer provider. If omitted, the global tracer provider
56
+ * is used.
57
+ * @since 1.3.0
58
+ */
59
+ tracerProvider?: TracerProvider;
60
+ }
61
+ /**
62
+ * Signs the given object with the private key and returns the signed object.
63
+ * @param object The object to create a proof for.
64
+ * @param privateKey The private key to sign the proof with.
65
+ * @param keyId The key ID to use in the proof. It will be used by the verifier.
66
+ * @param options Additional options. See also {@link SignObjectOptions}.
67
+ * @returns The signed object.
68
+ * @throws {TypeError} If the private key is invalid or unsupported.
69
+ * @since 0.10.0
70
+ */
71
+ declare function signObject<T extends Object$1>(object: T, privateKey: CryptoKey, keyId: URL, options?: SignObjectOptions): Promise<T>;
72
+ /**
73
+ * Options for {@link verifyProof}.
74
+ * @since 0.10.0
75
+ */
76
+ interface VerifyProofOptions extends VerificationObservationOptions {
77
+ /**
78
+ * The security domain expected by the verifier. When specified, it must
79
+ * contain the same strings as the proof's `domain` option.
80
+ * @since 2.4.0
81
+ */
82
+ domain?: string | readonly string[];
83
+ /**
84
+ * The challenge expected by the verifier. When specified, it must exactly
85
+ * match the proof's `challenge` option.
86
+ * @since 2.4.0
87
+ */
88
+ challenge?: string;
89
+ /**
90
+ * The context loader for loading remote JSON-LD contexts.
91
+ */
92
+ contextLoader?: DocumentLoader;
93
+ /**
94
+ * The document loader for loading remote JSON-LD documents.
95
+ */
96
+ documentLoader?: DocumentLoader;
97
+ /**
98
+ * The key cache to use for caching public keys.
99
+ * @since 0.12.0
100
+ */
101
+ keyCache?: KeyCache;
102
+ /**
103
+ * The OpenTelemetry tracer provider. If omitted, the global tracer provider
104
+ * is used.
105
+ * @since 1.3.0
106
+ */
107
+ tracerProvider?: TracerProvider;
108
+ /**
109
+ * The OpenTelemetry meter provider. If omitted, the global meter provider
110
+ * is used.
111
+ * @since 2.3.0
112
+ */
113
+ meterProvider?: MeterProvider;
114
+ }
115
+ /**
116
+ * Options for {@link verifyPortableObjectProof}.
117
+ * @since 2.4.0
118
+ */
119
+ interface VerifyPortableObjectProofOptions extends VerifyProofOptions {}
120
+ /**
121
+ * The reason why {@link verifyPortableObjectProof} could not verify a portable
122
+ * object proof.
123
+ * @since 2.4.0
124
+ */
125
+ type VerifyPortableObjectProofFailureReason = {
126
+ /**
127
+ * The document has neither a portable `ap:` or `ap+ef61:` ID nor an
128
+ * FEP-ef61 compatible identifier.
129
+ */
130
+ readonly type: "notPortableObject";
131
+ } | {
132
+ /**
133
+ * The document is a portable collection without an Object Integrity
134
+ * Proof. Its trust policy is outside this verifier.
135
+ */
136
+ readonly type: "unsecuredCollection";
137
+ } | {
138
+ /** The portable document is a core type outside FEP-ef61 proof policy. */readonly type: "unsupportedObjectType"; /** The FEP-2277 core type of the document. */
139
+ readonly objectType: "verificationMethod" | "publicKey" | "link";
140
+ } | {
141
+ /** A portable actor, activity, or object has no proof. */readonly type: "missingProof";
142
+ } | {
143
+ /**
144
+ * A portable actor's `gateways` is missing or empty, or has an item that
145
+ * is not an HTTP(S) URI with an empty path, query, and fragment.
146
+ * The document is rejected before its proofs are verified, so this
147
+ * reason does not mean that the proofs are valid.
148
+ */
149
+ readonly type: "invalidGateways";
150
+ } | {
151
+ /** The proof is malformed, unsupported, or cryptographically invalid. */readonly type: "invalidProof"; /** The zero-based index of the invalid proof. */
152
+ readonly proofIndex: number;
153
+ } | {
154
+ /** The proof's verification method is not a valid DID URL. */readonly type: "unsupportedVerificationMethod"; /** The zero-based index of the proof. */
155
+ readonly proofIndex: number; /** The unsupported verification method. */
156
+ readonly verificationMethod: URL;
157
+ } | {
158
+ /** The verification method DID does not match the portable ID authority. */readonly type: "verificationMethodMismatch"; /** The zero-based index of the proof. */
159
+ readonly proofIndex: number; /** The portable object ID. */
160
+ readonly objectId: URL; /** The mismatching verification method. */
161
+ readonly verificationMethod: URL;
162
+ };
163
+ /**
164
+ * The detailed result of {@link verifyPortableObjectProof}.
165
+ * @since 2.4.0
166
+ */
167
+ type VerifyPortableObjectProofResult = {
168
+ /** Whether every Object Integrity Proof was verified. */readonly verified: true; /** The public keys used by the verified proofs, in proof order. */
169
+ readonly keys: readonly Multikey[];
170
+ } | {
171
+ /** Whether every Object Integrity Proof was verified. */readonly verified: false; /** Why portable proof verification did not succeed. */
172
+ readonly reason: VerifyPortableObjectProofFailureReason;
173
+ };
174
+ /**
175
+ * Verifies the given proof for the object.
176
+ * @param jsonLd The JSON-LD object to verify the proof for. Its proof
177
+ * properties are excluded from the message, but matching proof
178
+ * occurrences are used to authenticate the received proof
179
+ * configuration.
180
+ * @param proof The proof to verify.
181
+ * @param options Additional options. See also {@link VerifyProofOptions}.
182
+ * @returns The public key that was used to sign the proof, or `null` if the
183
+ * proof is invalid.
184
+ * @since 0.10.0
185
+ * @since 2.4.0 Matching proof configurations are authenticated.
186
+ */
187
+ declare function verifyProof(jsonLd: unknown, proof: DataIntegrityProof, options?: VerifyProofOptions): Promise<Multikey | null>;
188
+ /**
189
+ * Verifies the FEP-ef61 Object Integrity Proof policy for a portable object.
190
+ *
191
+ * This applies the FEP-2277 core-type classification to the top-level JSON-LD
192
+ * node. Portable actors, activities, and objects require proofs. A portable
193
+ * collection without a proof is reported separately so a caller can apply a
194
+ * gateway trust policy. Embedded portable objects are not traversed.
195
+ *
196
+ * A portable object is a document whose ID is an `ap:` or `ap+ef61:` URI, or
197
+ * an [FEP-ef61] compatible identifier such as
198
+ * `https://gw.example/.well-known/apgateway/did:key:z6Mk…/actor`, which
199
+ * stands for the portable ID `ap+ef61://did:key:z6Mk…/actor`.
200
+ *
201
+ * Every proof must use a DID URL whose DID matches the portable object's
202
+ * authority, i.e., the DID of its canonical portable ID, and every proof must
203
+ * pass {@link verifyProof}. A portable actor must also have a non-empty
204
+ * `gateways` list whose items are all HTTP(S) URIs with an empty path, query,
205
+ * and fragment; otherwise, it is rejected with the `invalidGateways` reason
206
+ * before its proofs are verified. The proofs are verified over the document as
207
+ * given; a compatible identifier is never rewritten into a portable ID.
208
+ * An unmapped literal `gateways` property is also accepted when every proof
209
+ * uses `eddsa-jcs-2022`, which authenticates the original JSON properties.
210
+ *
211
+ * [FEP-ef61]: https://w3id.org/fep/ef61
212
+ *
213
+ * @param jsonLd The JSON-LD document to verify.
214
+ * @param options Additional options. See also
215
+ * {@link VerifyPortableObjectProofOptions}.
216
+ * @returns The detailed portable proof-policy result.
217
+ * @throws {TypeError} If the input is not a single JSON-LD object or has a
218
+ * malformed portable ID or compatible identifier.
219
+ * @since 2.4.0
220
+ */
221
+ declare function verifyPortableObjectProof(jsonLd: unknown, options?: VerifyPortableObjectProofOptions): Promise<VerifyPortableObjectProofResult>;
222
+ /**
223
+ * Options for {@link verifyObject}.
224
+ * @since 0.10.0
225
+ */
226
+ interface VerifyObjectOptions extends VerifyProofOptions {
227
+ /**
228
+ * The default [FEP-ef61] portable object verifier for the property
229
+ * accessors of the returned object and the objects obtained from it, e.g.,
230
+ * `Context.verifyPortableObject`. It is not used to verify the given
231
+ * object itself.
232
+ *
233
+ * [FEP-ef61]: https://w3id.org/fep/ef61
234
+ * @since 2.4.0
235
+ */
236
+ verifyPortableObject?: PortableObjectVerifier;
237
+ }
238
+ /**
239
+ * Verifies the given object. It will verify all the proofs in the object,
240
+ * and succeed only if all the proofs are valid and all attributions and
241
+ * actors are authenticated by the proofs.
242
+ * @template T The type of the object to verify.
243
+ * @param cls The class of the object to verify. It must be a subclass of
244
+ * the {@link Object}.
245
+ * @param jsonLd The JSON-LD object to verify. It's assumed that the object
246
+ * is a compacted JSON-LD representation of a `T` with `@context`.
247
+ * @param options Additional options. See also {@link VerifyObjectOptions}.
248
+ * @returns The object if it's verified, or `null` if it's not.
249
+ * @throws {TypeError} If the object is invalid or unsupported.
250
+ * @since 0.10.0
251
+ */
252
+ declare function verifyObject<T extends Object$1>(cls: (new (...args: any[]) => T) & {
253
+ fromJsonLd(jsonLd: unknown, options: VerifyObjectOptions): Promise<T>;
254
+ }, jsonLd: unknown, options?: VerifyObjectOptions): Promise<T | null>;
255
+ //#endregion
256
+ //#region src/sig/compound-proof.d.ts
257
+ /** Why compound-proof discovery could not produce an atomic result. */
258
+ type CompoundProofDiscoveryFailureReason = {
259
+ readonly type: "invalidJsonTree";
260
+ readonly path: string;
261
+ } | {
262
+ readonly type: "unsupportedProofShape";
263
+ readonly path: string;
264
+ } | {
265
+ readonly type: "limitExceeded";
266
+ readonly limit: "depth" | "maps" | "proofs" | "bytes";
267
+ readonly maximum: number;
268
+ readonly actual: number;
269
+ readonly path: string;
270
+ };
271
+ /** Why a discovered map-local proof did not verify. */
272
+ type CompoundProofVerificationFailureReason = {
273
+ /** A nested secured map does not carry its own JSON-LD context. */readonly type: "missingContext";
274
+ } | {
275
+ /** The direct proof is malformed, unsupported, or invalid. */readonly type: "invalidProof";
276
+ };
277
+ /** Why one portable map did not pass compound proof policy. */
278
+ type CompoundPortableObjectFailureReason = CompoundProofVerificationFailureReason | VerifyPortableObjectProofFailureReason | {
279
+ /** The portable map could not be interpreted by the policy layer. */readonly type: "invalidPortableObject";
280
+ };
281
+ //#endregion
282
+ //#region src/sig/accept.d.ts
283
+ /**
284
+ * Signature metadata parameters that may appear in an
285
+ * `Accept-Signature` member, as defined in
286
+ * [RFC 9421 §5.1](https://www.rfc-editor.org/rfc/rfc9421#section-5.1).
287
+ *
288
+ * @since 2.1.0
289
+ */
290
+ interface AcceptSignatureParameters {
291
+ /**
292
+ * If present, the signer is requested to use the indicated key
293
+ * material to create the target signature.
294
+ */
295
+ keyid?: string;
296
+ /**
297
+ * If present, the signer is requested to use the indicated algorithm
298
+ * from the HTTP Signature Algorithms registry.
299
+ */
300
+ alg?: string;
301
+ /**
302
+ * If `true`, the signer is requested to generate and include a
303
+ * creation timestamp. This parameter has no associated value in the
304
+ * wire format.
305
+ */
306
+ created?: true;
307
+ /**
308
+ * If `true`, the signer is requested to generate and include an
309
+ * expiration timestamp. This parameter has no associated value in
310
+ * the wire format.
311
+ */
312
+ expires?: true;
313
+ /**
314
+ * If present, the signer is requested to include this value as the
315
+ * signature nonce in the target signature.
316
+ */
317
+ nonce?: string;
318
+ /**
319
+ * If present, the signer is requested to include this value as the
320
+ * signature tag in the target signature.
321
+ */
322
+ tag?: string;
323
+ }
324
+ /**
325
+ * A single covered component identifier from an `Accept-Signature` inner list,
326
+ * as defined in [RFC 9421 §2.1](https://www.rfc-editor.org/rfc/rfc9421#section-2.1)
327
+ * and [§5.1](https://www.rfc-editor.org/rfc/rfc9421#section-5.1).
328
+ *
329
+ * RFC 9421 §5.1 requires that the list of component identifiers includes
330
+ * *all applicable component parameters*. Parameters such as `;sf`, `;bs`,
331
+ * `;req`, `;tr`, `;name`, and `;key` narrow the meaning of a component
332
+ * identifier and MUST be preserved exactly as received so that the signer
333
+ * can cover the same components the verifier requested.
334
+ *
335
+ * Examples:
336
+ * - `{ value: "@method", params: {} }`
337
+ * - `{ value: "content-type", params: { sf: true } }`
338
+ * - `{ value: "@query-param", params: { name: "foo" } }`
339
+ *
340
+ * @since 2.1.0
341
+ */
342
+ interface AcceptSignatureComponent {
343
+ /**
344
+ * The component identifier name (e.g., `"@method"`, `"content-digest"`,
345
+ * `"@query-param"`).
346
+ */
347
+ value: string;
348
+ /**
349
+ * Component parameters attached to this identifier (e.g., `{ sf: true }`,
350
+ * `{ name: "foo" }`). An empty object means no parameters were present.
351
+ * Parameters MUST NOT be dropped; doing so would cause the signer to cover
352
+ * a different component than the verifier requested.
353
+ */
354
+ params: Record<string, unknown>;
355
+ }
356
+ /**
357
+ * Represents a single member of the `Accept-Signature` Dictionary
358
+ * Structured Field, as defined in
359
+ * [RFC 9421 §5.1](https://www.rfc-editor.org/rfc/rfc9421#section-5.1).
360
+ *
361
+ * @since 2.1.0
362
+ */
363
+ interface AcceptSignatureMember {
364
+ /**
365
+ * The label that uniquely identifies the requested message signature
366
+ * within the context of the target HTTP message (e.g., `"sig1"`).
367
+ */
368
+ label: string;
369
+ /**
370
+ * The exact list of covered component identifiers requested for the target
371
+ * signature, including all applicable component parameters, as required by
372
+ * [RFC 9421 §5.1](https://www.rfc-editor.org/rfc/rfc9421#section-5.1).
373
+ *
374
+ * Each element is an {@link AcceptSignatureComponent} that preserves
375
+ * both the identifier name and any parameters (e.g., `;sf`, `;name="foo"`).
376
+ * The signer MUST cover exactly these components—with their parameters—when
377
+ * fulfilling the challenge.
378
+ */
379
+ components: AcceptSignatureComponent[];
380
+ /**
381
+ * Optional signature metadata parameters requested by the verifier.
382
+ */
383
+ parameters: AcceptSignatureParameters;
384
+ }
385
+ /**
386
+ * Parses an `Accept-Signature` header value (RFC 9421 §5.1) into an
387
+ * array of {@link AcceptSignatureMember} objects.
388
+ *
389
+ * The `Accept-Signature` field is a Dictionary Structured Field
390
+ * (RFC 8941 §3.2). Each dictionary member describes a single
391
+ * requested message signature.
392
+ *
393
+ * On parse failure (malformed or empty header), returns an empty array.
394
+ *
395
+ * @param header The raw `Accept-Signature` header value string.
396
+ * @returns An array of parsed members. Empty if the header is
397
+ * malformed or empty.
398
+ * @since 2.1.0
399
+ */
400
+ declare function parseAcceptSignature(header: string): AcceptSignatureMember[];
401
+ /**
402
+ * Serializes an array of {@link AcceptSignatureMember} objects into an
403
+ * `Accept-Signature` header value string (RFC 9421 §5.1).
404
+ *
405
+ * The output is a Dictionary Structured Field (RFC 8941 §3.2).
406
+ *
407
+ * @param members The members to serialize.
408
+ * @returns The serialized header value string.
409
+ * @since 2.1.0
410
+ */
411
+ declare function formatAcceptSignature(members: AcceptSignatureMember[]): string;
412
+ /**
413
+ * Filters out {@link AcceptSignatureMember} entries whose covered
414
+ * components include response-only identifiers (`@status`) that are
415
+ * not applicable to request-target messages, as required by
416
+ * [RFC 9421 §5](https://www.rfc-editor.org/rfc/rfc9421#section-5).
417
+ *
418
+ * A warning is logged for each discarded entry.
419
+ *
420
+ * @param members The parsed `Accept-Signature` entries to validate.
421
+ * @returns Only entries that are valid for request-target messages.
422
+ * @since 2.1.0
423
+ */
424
+ declare function validateAcceptSignature(members: AcceptSignatureMember[]): AcceptSignatureMember[];
425
+ /**
426
+ * The result of {@link fulfillAcceptSignature}. This can be used directly
427
+ * as the `rfc9421` option of {@link SignRequestOptions}.
428
+ * @since 2.1.0
429
+ */
430
+ interface FulfillAcceptSignatureResult {
431
+ /** The label for the signature. */
432
+ label: string;
433
+ /**
434
+ * The merged set of covered component identifiers, including all component
435
+ * parameters, ready to be passed to the signer.
436
+ */
437
+ components: AcceptSignatureComponent[];
438
+ /** The nonce requested by the challenge, if any. */
439
+ nonce?: string;
440
+ /** The tag requested by the challenge, if any. */
441
+ tag?: string;
442
+ /**
443
+ * If `true`, the challenger requested that the signer generate and include
444
+ * an expiration timestamp in the signature parameters.
445
+ */
446
+ expires?: true;
447
+ }
448
+ /**
449
+ * Attempts to translate an {@link AcceptSignatureMember} challenge into
450
+ * RFC 9421 signing options that the local signer can fulfill.
451
+ *
452
+ * Returns `null` if the challenge cannot be fulfilled—for example, if
453
+ * the requested `alg` or `keyid` is incompatible with the local key.
454
+ *
455
+ * Safety constraints:
456
+ * - `alg`: only honored if it matches `localAlg`.
457
+ * - `keyid`: only honored if it matches `localKeyId`.
458
+ * - `components`: passed through exactly as requested, per RFC 9421 §5.2.
459
+ * - `nonce`, `tag`, and `expires` are passed through directly.
460
+ *
461
+ * @param entry The challenge entry from the `Accept-Signature` header.
462
+ * @param localKeyId The local key identifier (e.g., the actor key URL).
463
+ * @param localAlg The algorithm of the local private key
464
+ * (e.g., `"rsa-v1_5-sha256"`).
465
+ * @returns Signing options if the challenge can be fulfilled, or `null`.
466
+ * @since 2.1.0
467
+ */
468
+ declare function fulfillAcceptSignature(entry: AcceptSignatureMember, localKeyId: string, localAlg: string): FulfillAcceptSignatureResult | null;
469
+ //#endregion
470
+ //#region src/sig/http.d.ts
471
+ /**
472
+ * The standard to use for signing and verifying HTTP signatures.
473
+ * @since 1.6.0
474
+ */
475
+ type HttpMessageSignaturesSpec = "draft-cavage-http-signatures-12" | "rfc9421";
476
+ /**
477
+ * Options for {@link signRequest}.
478
+ * @since 1.3.0
479
+ */
480
+ interface SignRequestOptions {
481
+ /**
482
+ * The HTTP message signatures specification to use for signing.
483
+ * @default `"draft-cavage-http-signatures-12"`
484
+ * @since 1.6.0
485
+ */
486
+ spec?: HttpMessageSignaturesSpec;
487
+ /**
488
+ * The current time. If not specified, the current time is used. This is
489
+ * useful for testing.
490
+ * @since 1.6.0
491
+ */
492
+ currentTime?: Temporal.Instant;
493
+ /**
494
+ * The request body as ArrayBuffer. If provided, avoids cloning the request body.
495
+ * @since 1.7.7
496
+ */
497
+ body?: ArrayBuffer | null;
498
+ /**
499
+ * The OpenTelemetry tracer provider. If omitted, the global tracer provider
500
+ * is used.
501
+ */
502
+ tracerProvider?: TracerProvider;
503
+ /**
504
+ * Options specific to the RFC 9421 signing path. These options are
505
+ * ignored when `spec` is `"draft-cavage-http-signatures-12"`.
506
+ * @since 2.1.0
507
+ */
508
+ rfc9421?: Rfc9421SignRequestOptions;
509
+ }
510
+ /**
511
+ * Options for customizing the RFC 9421 signature label, covered components,
512
+ * and metadata parameters. These are typically derived from an
513
+ * `Accept-Signature` challenge.
514
+ * @since 2.1.0
515
+ */
516
+ interface Rfc9421SignRequestOptions {
517
+ /**
518
+ * The label for the signature in `Signature-Input` and `Signature` headers.
519
+ * @default `"sig1"`
520
+ */
521
+ label?: string;
522
+ /**
523
+ * The covered component identifiers. When omitted, the default set
524
+ * `["@method", "@target-uri", "@authority", "host", "date"]`
525
+ * (plus `"content-digest"` when a body is present) is used.
526
+ */
527
+ components?: AcceptSignatureComponent[];
528
+ /**
529
+ * A nonce value to include in the signature parameters.
530
+ */
531
+ nonce?: string;
532
+ /**
533
+ * A tag value to include in the signature parameters.
534
+ */
535
+ tag?: string;
536
+ /**
537
+ * If `true`, an expiration timestamp is generated and included in the
538
+ * signature parameters. The expiration time defaults to one hour after
539
+ * the signature creation time.
540
+ */
541
+ expires?: true;
542
+ }
543
+ /**
544
+ * Signs a request using the given private key.
545
+ * @param request The request to sign.
546
+ * @param privateKey The private key to use for signing.
547
+ * @param keyId The key ID to use for the signature. It will be used by the
548
+ * verifier.
549
+ * @returns The signed request.
550
+ * @throws {TypeError} If the private key is invalid or unsupported.
551
+ */
552
+ declare function signRequest(request: Request, privateKey: CryptoKey, keyId: URL, options?: SignRequestOptions): Promise<Request>;
553
+ /**
554
+ * Options for {@link verifyRequest}.
555
+ */
556
+ interface VerifyRequestOptions extends VerificationObservationOptions {
557
+ /**
558
+ * The document loader to use for fetching the public key.
559
+ */
560
+ documentLoader?: DocumentLoader;
561
+ /**
562
+ * The context loader to use for JSON-LD context retrieval.
563
+ */
564
+ contextLoader?: DocumentLoader;
565
+ /**
566
+ * The time window to allow for the request date. The actual time window is
567
+ * twice the value of this option, with the current time as the center.
568
+ * Or if it is `false`, no time check is performed.
569
+ *
570
+ * An hour by default.
571
+ */
572
+ timeWindow?: Temporal.Duration | Temporal.DurationLike | false;
573
+ /**
574
+ * The current time. If not specified, the current time is used. This is
575
+ * useful for testing.
576
+ */
577
+ currentTime?: Temporal.Instant;
578
+ /**
579
+ * The key cache to use for caching public keys.
580
+ * @since 0.12.0
581
+ */
582
+ keyCache?: KeyCache;
583
+ /**
584
+ * The HTTP message signatures specification to use for verifying.
585
+ * @default `"draft-cavage-http-signatures-12"`
586
+ * @since 1.6.0
587
+ */
588
+ spec?: HttpMessageSignaturesSpec;
589
+ /**
590
+ * The maximum number of [RFC 9421] signatures of a request to verify.
591
+ * A request can carry several signatures, each of which may make Fedify
592
+ * fetch the key that it names, so only the first ones in the order of
593
+ * the `Signature-Input` header are verified, and the rest are ignored as
594
+ * if they were absent. Every signature among the first ones counts, even
595
+ * if it fails before its key is fetched, e.g., because it is too old, or
596
+ * names the same key as another one. The key of a key ID is looked up
597
+ * only once for all the signatures that name it.
598
+ *
599
+ * It has to be a positive integer, or `Infinity` to verify every
600
+ * signature, which lets a single request make Fedify fetch any number of
601
+ * keys. Draft-cavage HTTP Signatures carry a single signature, so this
602
+ * option does not affect them.
603
+ *
604
+ * Three by default.
605
+ *
606
+ * [RFC 9421]: https://www.rfc-editor.org/rfc/rfc9421
607
+ * @throws {RangeError} Thrown by {@link verifyRequest} and
608
+ * {@link verifyRequestDetailed} if the value is not a positive
609
+ * integer or `Infinity`.
610
+ * @since 2.4.0
611
+ */
612
+ maxSignatures?: number;
613
+ /**
614
+ * The OpenTelemetry tracer provider. If omitted, the global tracer provider
615
+ * is used.
616
+ * @since 1.3.0
617
+ */
618
+ tracerProvider?: TracerProvider;
619
+ /**
620
+ * The OpenTelemetry meter provider. If omitted, the global meter provider
621
+ * is used.
622
+ * @since 2.3.0
623
+ */
624
+ meterProvider?: MeterProvider;
625
+ }
626
+ /**
627
+ * The reason why {@link verifyRequestDetailed} could not verify a request.
628
+ * @since 2.1.0
629
+ */
630
+ type VerifyRequestFailureReason = {
631
+ readonly type: "keyFetchError";
632
+ readonly keyId: URL;
633
+ readonly result: FetchKeyErrorResult;
634
+ } | {
635
+ readonly type: "invalidSignature";
636
+ readonly keyId?: URL;
637
+ } | {
638
+ readonly type: "noSignature";
639
+ };
640
+ /**
641
+ * The detailed result of {@link verifyRequestDetailed}.
642
+ * @since 2.1.0
643
+ */
644
+ type VerifyRequestDetailedResult = {
645
+ readonly verified: true;
646
+ readonly key: CryptographicKey;
647
+ readonly signatureLabel?: string;
648
+ } | {
649
+ readonly verified: false;
650
+ readonly reason: VerifyRequestFailureReason;
651
+ };
652
+ /**
653
+ * Verifies the signature of a request.
654
+ *
655
+ * Note that this function consumes the request body, so it should not be used
656
+ * if the request body is already consumed. Consuming the request body after
657
+ * calling this function is okay, since this function clones the request
658
+ * under the hood.
659
+ *
660
+ * @param request The request to verify.
661
+ * @param options Options for verifying the request.
662
+ * @returns The public key of the verified signature, or `null` if the signature
663
+ * could not be verified.
664
+ * @throws {RangeError} Thrown if {@link VerifyRequestOptions.maxSignatures}
665
+ * is not a positive integer or `Infinity`.
666
+ */
667
+ declare function verifyRequest(request: Request, options?: VerifyRequestOptions): Promise<CryptographicKey | null>;
668
+ /**
669
+ * Verifies the signature of a request and returns a structured failure reason
670
+ * when verification does not succeed.
671
+ *
672
+ * @param request The request to verify.
673
+ * @param options Options for verifying the request.
674
+ * @returns The verified public key, or a structured verification failure.
675
+ * @throws {RangeError} Thrown if {@link VerifyRequestOptions.maxSignatures}
676
+ * is not a positive integer or `Infinity`.
677
+ * @since 2.1.0
678
+ */
679
+ declare function verifyRequestDetailed(request: Request, options?: VerifyRequestOptions): Promise<VerifyRequestDetailedResult>;
680
+ /**
681
+ * A spec determiner for HTTP Message Signatures.
682
+ * It determines the spec to use for signing requests.
683
+ * It is used for double-knocking
684
+ * (see <https://swicg.github.io/activitypub-http-signature/#how-to-upgrade-supported-versions>).
685
+ * @since 1.6.0
686
+ */
687
+ interface HttpMessageSignaturesSpecDeterminer {
688
+ /**
689
+ * Determines the spec to use for signing requests.
690
+ * @param origin The origin of the URL to make the request to.
691
+ * @returns The spec to use for signing requests.
692
+ */
693
+ determineSpec(origin: string): HttpMessageSignaturesSpec | Promise<HttpMessageSignaturesSpec>;
694
+ /**
695
+ * Remembers the successfully used spec for the given origin.
696
+ * @param origin The origin of the URL that was requested.
697
+ * @param spec The spec to remember.
698
+ */
699
+ rememberSpec(origin: string, spec: HttpMessageSignaturesSpec): void | Promise<void>;
700
+ }
701
+ //#endregion
702
+ //#region src/sig/verification.d.ts
703
+ /**
704
+ * A snapshot of a key actually used to check a signature.
705
+ * @since 2.4.0
706
+ */
707
+ type InboxVerificationKey = {
708
+ readonly type: "cryptographicKey";
709
+ readonly id: URL | null;
710
+ readonly ownerId: URL | null;
711
+ readonly publicKey: CryptoKey;
712
+ } | {
713
+ readonly type: "multikey";
714
+ readonly id: URL | null;
715
+ readonly controllerId: URL | null;
716
+ readonly publicKey: CryptoKey;
717
+ };
718
+ /**
719
+ * Why a cryptographic check failed.
720
+ * @since 2.4.0
721
+ */
722
+ type InboxSignatureFailureReason = {
723
+ readonly type: "invalidSignature";
724
+ } | {
725
+ readonly type: "keyFetchError";
726
+ readonly keyId: URL;
727
+ readonly result: FetchKeyErrorResult;
728
+ };
729
+ /**
730
+ * The signature or proof being checked.
731
+ * @since 2.4.0
732
+ */
733
+ type InboxSignatureIdentity = {
734
+ readonly mechanism: "http";
735
+ readonly spec: HttpMessageSignaturesSpec;
736
+ readonly label: string | null;
737
+ } | {
738
+ readonly mechanism: "linkedData";
739
+ } | {
740
+ readonly mechanism: "objectIntegrity";
741
+ readonly proofId: string | null; /** Index within this evaluation, not a global proof identifier. */
742
+ readonly proofIndex: number | null;
743
+ };
744
+ /**
745
+ * Evidence from one signature/proof, including cached-key retries.
746
+ * @since 2.4.0
747
+ */
748
+ type InboxSignatureCheck = InboxSignatureIdentity & {
749
+ /** The declaration as received, including invalid IRIs. */readonly declaredKeyId: string | null; /** Keys actually tried, in use order; refresh details are not a retry API. */
750
+ readonly triedKeys: readonly InboxVerificationKey[];
751
+ } & ({
752
+ readonly status: "verified";
753
+ readonly key: InboxVerificationKey;
754
+ } | {
755
+ readonly status: "rejected";
756
+ readonly reason: InboxSignatureFailureReason;
757
+ } | {
758
+ readonly status: "error";
759
+ readonly error: unknown;
760
+ });
761
+ /**
762
+ * A bounded proof-policy diagnostic.
763
+ * @since 2.4.0
764
+ */
765
+ type InboxProofPolicyFailureReason = VerifyPortableObjectProofFailureReason | CompoundPortableObjectFailureReason | CompoundProofDiscoveryFailureReason | {
766
+ readonly type: "invalidObjectId" | "invalidDocument" | "subjectMismatch";
767
+ };
768
+ /**
769
+ * Why a complete verification evaluation was rejected.
770
+ * @since 2.4.0
771
+ */
772
+ type InboxVerificationFailureReason = {
773
+ readonly type: "noSignature";
774
+ } | {
775
+ readonly type: "signatureVerificationFailed";
776
+ } | {
777
+ readonly type: "uncoveredAttribution";
778
+ readonly attributionIds: readonly URL[];
779
+ } | {
780
+ readonly type: "missingOwner";
781
+ } | {
782
+ readonly type: "proofPolicy";
783
+ readonly reason: InboxProofPolicyFailureReason;
784
+ };
785
+ /**
786
+ * A logical verification evaluation, separate from inbox authentication.
787
+ * @since 2.4.0
788
+ */
789
+ type InboxVerificationAttempt = {
790
+ readonly mechanism: "http" | "linkedData" | "objectIntegrity";
791
+ readonly subject: {
792
+ readonly id: URL | null; /** RFC 6901 pointer; empty for the root, null when unavailable. */
793
+ readonly pointer: string | null;
794
+ };
795
+ readonly checks: readonly InboxSignatureCheck[];
796
+ } & ({
797
+ readonly status: "verified"; /** Direct references to successful members of checks. */
798
+ readonly signatures: readonly Extract<InboxSignatureCheck, {
799
+ status: "verified";
800
+ }>[];
801
+ } | {
802
+ readonly status: "rejected";
803
+ readonly reason: InboxVerificationFailureReason;
804
+ } | {
805
+ readonly status: "error";
806
+ readonly error: unknown;
807
+ });
808
+ declare const verificationObservation: unique symbol;
809
+ interface VerificationObservationOptions {
810
+ [verificationObservation]?: VerificationObservation;
811
+ }
812
+ interface VerificationObservation {
813
+ readonly attempts: InboxVerificationAttempt[];
814
+ /** False for internal telemetry collectors; observers capture raw IDs by default. */
815
+ readonly captureRawKeyIds?: boolean;
816
+ readonly parsedObject?: (object: unknown) => void;
817
+ readonly subject?: {
818
+ id: URL | null;
819
+ pointer: string | null;
820
+ };
821
+ readonly attempt?: AttemptBuilder;
822
+ readonly check?: CheckBuilder;
823
+ }
824
+ interface AttemptBuilder {
825
+ checks: InboxSignatureCheck[];
826
+ reason?: InboxVerificationFailureReason;
827
+ }
828
+ interface CheckBuilder {
829
+ identity: InboxSignatureIdentity;
830
+ declaredKeyId: string | null;
831
+ triedKeys: InboxVerificationKey[];
832
+ reason?: InboxSignatureFailureReason;
833
+ }
834
+ //#endregion
835
+ //#region src/sig/portable-key.d.ts
836
+ /**
837
+ * The result of resolving a gateway key of a portable actor.
838
+ * @internal
839
+ */
840
+ type PortableGatewayKeyResolution = {
841
+ /**
842
+ * The document at the key ID is not a portable actor, so the key is
843
+ * resolved as usual.
844
+ */
845
+ readonly type: "legacy";
846
+ } | {
847
+ /** The document is a portable actor, but it does not vouch for the key. */readonly type: "rejected";
848
+ readonly reason: string;
849
+ } | {
850
+ /** The portable actor's signed document vouches for the key. */readonly type: "verified";
851
+ readonly actor: Actor;
852
+ readonly key: CryptographicKey & {
853
+ publicKey: CryptoKey;
854
+ };
855
+ /**
856
+ * The expanded root node of the actor's document whose proof was
857
+ * verified, from which {@link actor} was parsed.
858
+ */
859
+ readonly document: Record<string, unknown>;
860
+ /**
861
+ * When the proof of the actor's document expires, if it does. The
862
+ * document does not vouch for the key after that.
863
+ */
864
+ readonly expires?: Temporal.Instant;
865
+ };
866
+ /**
867
+ * The result of resolving a key of a portable actor at an `ap:` or
868
+ * `ap+ef61:` key ID.
869
+ * @internal
870
+ */
871
+ type PortableActorKeyResolution = Exclude<PortableGatewayKeyResolution, {
872
+ readonly type: "legacy";
873
+ }> | {
874
+ /**
875
+ * Whether the actor's document vouches for the key could not be
876
+ * determined, e.g., because no gateway could be reached.
877
+ */
878
+ readonly type: "unavailable";
879
+ readonly error: unknown;
880
+ /**
881
+ * Whether the failure can be cached as a failure to fetch the key, i.e.,
882
+ * every gateway failed to serve the actor's document at all. A failure
883
+ * that is not cacheable comes with an error that has no HTTP status,
884
+ * since none of the statuses describes the lookup as a whole.
885
+ */
886
+ readonly cacheable: boolean;
887
+ };
888
+ //#endregion
889
+ //#region src/sig/key.d.ts
890
+ /**
891
+ * Generates a key pair which is appropriate for Fedify.
892
+ * @param algorithm The algorithm to use. Currently only RSASSA-PKCS1-v1_5 and
893
+ * Ed25519 are supported.
894
+ * @returns The generated key pair.
895
+ * @throws {TypeError} If the algorithm is unsupported.
896
+ */
897
+ declare function generateCryptoKeyPair(algorithm?: "RSASSA-PKCS1-v1_5" | "Ed25519"): Promise<CryptoKeyPair>;
898
+ /**
899
+ * Exports a key in JWK format.
900
+ * @param key The key to export. Either public or private key.
901
+ * @returns The exported key in JWK format. The key is suitable for
902
+ * serialization and storage.
903
+ * @throws {TypeError} If the key is invalid or unsupported.
904
+ */
905
+ declare function exportJwk(key: CryptoKey): Promise<JsonWebKey>;
906
+ /**
907
+ * Imports a key from JWK format.
908
+ * @param jwk The key in JWK format.
909
+ * @param type Which type of key to import, either `"public"` or `"private"`.
910
+ * @returns The imported key.
911
+ * @throws {TypeError} If the key is invalid or unsupported.
912
+ */
913
+ declare function importJwk(jwk: JsonWebKey, type: "public" | "private"): Promise<CryptoKey>;
914
+ /**
915
+ * Options for {@link fetchKey}.
916
+ * @since 1.3.0
917
+ */
918
+ interface FetchKeyOptions extends VerificationObservationOptions {
919
+ /**
920
+ * The document loader for loading remote JSON-LD documents.
921
+ */
922
+ documentLoader?: DocumentLoader;
923
+ /**
924
+ * The context loader for loading remote JSON-LD contexts.
925
+ */
926
+ contextLoader?: DocumentLoader;
927
+ /**
928
+ * The key cache to use for caching public keys.
929
+ * @since 0.12.0
930
+ */
931
+ keyCache?: KeyCache;
932
+ /**
933
+ * The OpenTelemetry tracer provider to use for tracing. If omitted,
934
+ * the global tracer provider is used.
935
+ * @since 1.3.0
936
+ */
937
+ tracerProvider?: TracerProvider;
938
+ /**
939
+ * The OpenTelemetry meter provider to use for recording
940
+ * `activitypub.key.lookup` and `activitypub.key.lookup.duration`. If
941
+ * omitted, the global meter provider is used.
942
+ * @since 2.3.0
943
+ */
944
+ meterProvider?: MeterProvider;
945
+ /**
946
+ * An assertion by the caller that it has already bound this key's id to
947
+ * whoever the key will be treated as speaking for, by means of its own that
948
+ * key resolution cannot see.
949
+ *
950
+ * Key resolution normally settles ownership itself: it dereferences the
951
+ * `owner`/`controller` a key claims and requires that actor's own document
952
+ * to link back to the key, because the claim and the key document come from
953
+ * the same host and so the claim proves nothing on its own. See
954
+ * GHSA-q9f8-5hc7-898f.
955
+ *
956
+ * That check presumes the ActivityPub shape of ownership, where the owner
957
+ * is an actor carrying a `publicKey`/`assertionMethod` list. It does not
958
+ * fit every caller. Portable objects (FEP-ef61) bind a key to an object
959
+ * structurally instead: {@link verifyPortableObjectProof} requires the
960
+ * verification method's FEP-ef34 origin to equal the object id's own
961
+ * authority, so the signer is pinned by the identifier being verified,
962
+ * before any key is fetched. Demanding the ActivityPub check as well would
963
+ * be impossible rather than merely redundant, since a DID dereferences to
964
+ * a DID document, which is not an actor.
965
+ *
966
+ * This is not a way to accept whatever a key says about itself. The claim
967
+ * still has to be corroborated, just from the key id rather than from
968
+ * a second document: a key may name an owner only when the key id is that
969
+ * owner's own (a `did:…#fragment` belongs to the DID it is a fragment of,
970
+ * exactly as a key embedded in an actor document belongs to that actor).
971
+ * A key naming anyone else falls back to the ordinary check and is rejected
972
+ * if it cannot pass it, so a key admitted here is as sound as any other and
973
+ * is cached like any other.
974
+ * @internal
975
+ */
976
+ keyIdBoundByCaller?: boolean;
977
+ /**
978
+ * Resolves keys of [FEP-ef61] portable actors, which only HTTP Signature
979
+ * verification passes, so that only it accepts them. Object Integrity
980
+ * Proofs and Linked Data Signatures never do: such a key is rejected if
981
+ * this is omitted.
982
+ *
983
+ * [FEP-ef61]: https://w3id.org/fep/ef61
984
+ * @internal
985
+ */
986
+ portableKeyResolvers?: PortableKeyResolvers;
987
+ }
988
+ /**
989
+ * Resolves keys of [FEP-ef61] portable actors for HTTP Signature
990
+ * verification. See {@link FetchKeyOptions.portableKeyResolvers}.
991
+ *
992
+ * [FEP-ef61]: https://w3id.org/fep/ef61
993
+ * @internal
994
+ */
995
+ interface PortableKeyResolvers {
996
+ /**
997
+ * Resolves a gateway key, i.e., a key whose ID is a compatible identifier
998
+ * and dereferences to a portable actor's document.
999
+ */
1000
+ gatewayKey(document: unknown, actor: Actor, keyId: URL): Promise<PortableGatewayKeyResolution>;
1001
+ /**
1002
+ * Resolves a key of a portable actor itself, i.e., a key whose ID is an
1003
+ * `ap:` or `ap+ef61:` URI.
1004
+ */
1005
+ actorKey(keyId: URL): Promise<PortableActorKeyResolution>;
1006
+ }
1007
+ /**
1008
+ * The result of {@link fetchKey}.
1009
+ * @since 1.3.0
1010
+ */
1011
+ interface FetchKeyResult<T extends CryptographicKey | Multikey> {
1012
+ /**
1013
+ * The fetched (or cached) key.
1014
+ */
1015
+ readonly key: T & {
1016
+ publicKey: CryptoKey;
1017
+ } | null;
1018
+ /**
1019
+ * Whether the key is fetched from the cache.
1020
+ */
1021
+ readonly cached: boolean;
1022
+ }
1023
+ /**
1024
+ * Detailed fetch failure information from {@link fetchKeyDetailed}.
1025
+ * @since 2.1.0
1026
+ */
1027
+ type FetchKeyErrorResult = {
1028
+ readonly status: number;
1029
+ readonly response: Response;
1030
+ } | {
1031
+ readonly error: Error;
1032
+ };
1033
+ /**
1034
+ * The result of {@link fetchKeyDetailed}.
1035
+ * @since 2.1.0
1036
+ */
1037
+ interface FetchKeyDetailedResult<T extends CryptographicKey | Multikey> extends FetchKeyResult<T> {
1038
+ /**
1039
+ * The error that occurred while fetching the key, if fetching failed before
1040
+ * a document could be parsed.
1041
+ */
1042
+ readonly fetchError?: FetchKeyErrorResult;
1043
+ }
1044
+ type FetchableKeyClass<T extends CryptographicKey | Multikey> = (new (...args: any[]) => T) & {
1045
+ fromJsonLd(jsonLd: unknown, options: {
1046
+ documentLoader?: DocumentLoader;
1047
+ contextLoader?: DocumentLoader;
1048
+ tracerProvider?: TracerProvider;
1049
+ }): Promise<T>;
1050
+ };
1051
+ /**
1052
+ * Fetches a {@link CryptographicKey} or {@link Multikey} from the given URL.
1053
+ * If the given URL contains an {@link Actor} object, it tries to find
1054
+ * the corresponding key in the `publicKey` or `assertionMethod` property. *
1055
+ * Gateway keys of [FEP-ef61] portable actors, i.e., keys whose IDs are
1056
+ * compatible identifiers that dereference to portable actor documents, are
1057
+ * not resolved by this function, as they only authenticate HTTP requests;
1058
+ * use `verifyRequest()` or `getKeyOwner()` for them instead. Nor are keys
1059
+ * of portable actors whose IDs are `ap:` or `ap+ef61:` URIs, for the same
1060
+ * reason. Keys whose IDs are compatible identifiers or `ap:` or `ap+ef61:`
1061
+ * URIs are never read from or written to the key cache under their IDs,
1062
+ * except for failures to fetch them.
1063
+ *
1064
+ * [FEP-ef61]: https://w3id.org/fep/ef61
1065
+ * @template T The type of the key to fetch. Either {@link CryptographicKey}
1066
+ * or {@link Multikey}.
1067
+ * @param keyId The URL of the key.
1068
+ * @param cls The class of the key to fetch. Either {@link CryptographicKey}
1069
+ * or {@link Multikey}.
1070
+ * @param options Options for fetching the key. See {@link FetchKeyOptions}.
1071
+ * @returns The fetched key or `null` if the key is not found.
1072
+ * @since 1.3.0
1073
+ */
1074
+ declare function fetchKey<T extends CryptographicKey | Multikey>(keyId: URL | string, cls: FetchableKeyClass<T>, options?: FetchKeyOptions): Promise<FetchKeyResult<T>>;
1075
+ /**
1076
+ * Fetches a {@link CryptographicKey} or {@link Multikey} from the given URL,
1077
+ * preserving transport-level fetch failures for callers that need to inspect
1078
+ * why the key could not be loaded. *
1079
+ * Gateway keys of [FEP-ef61] portable actors, i.e., keys whose IDs are
1080
+ * compatible identifiers that dereference to portable actor documents, are
1081
+ * not resolved by this function, as they only authenticate HTTP requests;
1082
+ * use `verifyRequest()` or `getKeyOwner()` for them instead. Nor are keys
1083
+ * of portable actors whose IDs are `ap:` or `ap+ef61:` URIs, for the same
1084
+ * reason. Keys whose IDs are compatible identifiers or `ap:` or `ap+ef61:`
1085
+ * URIs are never read from or written to the key cache under their IDs,
1086
+ * except for failures to fetch them.
1087
+ *
1088
+ * [FEP-ef61]: https://w3id.org/fep/ef61
1089
+ *
1090
+ * @template T The type of the key to fetch. Either {@link CryptographicKey}
1091
+ * or {@link Multikey}.
1092
+ * @param keyId The URL of the key.
1093
+ * @param cls The class of the key to fetch. Either {@link CryptographicKey}
1094
+ * or {@link Multikey}.
1095
+ * @param options Options for fetching the key.
1096
+ * @returns The fetched key, or detailed fetch failure information.
1097
+ * @since 2.1.0
1098
+ */
1099
+ declare function fetchKeyDetailed<T extends CryptographicKey | Multikey>(keyId: URL | string, cls: FetchableKeyClass<T>, options?: FetchKeyOptions): Promise<FetchKeyDetailedResult<T>>;
1100
+ /**
1101
+ * A cache for storing cryptographic keys.
1102
+ * @since 0.12.0
1103
+ */
1104
+ interface KeyCache {
1105
+ /**
1106
+ * Gets a key from the cache.
1107
+ * @param keyId The key ID.
1108
+ * @returns The key if found, `null` if the key is not available (e.g.,
1109
+ * fetching the key was tried but failed), or `undefined`
1110
+ * if the cache is not available.
1111
+ */
1112
+ get(keyId: URL): Promise<CryptographicKey | Multikey | null | undefined>;
1113
+ /**
1114
+ * Sets a key to the cache.
1115
+ *
1116
+ * Note that this caches unavailable keys (i.e., `null`) as well,
1117
+ * and it is recommended to make unavailable keys expire after a short period.
1118
+ * @param keyId The key ID.
1119
+ * @param key The key to cache. `null` means the key is not available
1120
+ * (e.g., fetching the key was tried but failed).
1121
+ */
1122
+ set(keyId: URL, key: CryptographicKey | Multikey | null): Promise<void>;
1123
+ }
1124
+ //#endregion
1125
+ export { AcceptSignatureParameters as A, VerifyPortableObjectProofOptions as B, VerifyRequestDetailedResult as C, verifyRequest as D, signRequest as E, validateAcceptSignature as F, signObject as G, VerifyProofOptions as H, CreateProofOptions as I, verifyProof as J, verifyObject as K, SignObjectOptions as L, formatAcceptSignature as M, fulfillAcceptSignature as N, verifyRequestDetailed as O, parseAcceptSignature as P, VerifyObjectOptions as R, SignRequestOptions as S, VerifyRequestOptions as T, createProof as U, VerifyPortableObjectProofResult as V, hasProofLike as W, InboxVerificationKey as _, KeyCache as a, HttpMessageSignaturesSpecDeterminer as b, fetchKeyDetailed as c, InboxProofPolicyFailureReason as d, InboxSignatureCheck as f, InboxVerificationFailureReason as g, InboxVerificationAttempt as h, FetchKeyResult as i, FulfillAcceptSignatureResult as j, AcceptSignatureMember as k, generateCryptoKeyPair as l, InboxSignatureIdentity as m, FetchKeyErrorResult as n, exportJwk as o, InboxSignatureFailureReason as p, verifyPortableObjectProof as q, FetchKeyOptions as r, fetchKey as s, FetchKeyDetailedResult as t, importJwk as u, VerificationObservationOptions as v, VerifyRequestFailureReason as w, Rfc9421SignRequestOptions as x, HttpMessageSignaturesSpec as y, VerifyPortableObjectProofFailureReason as z };