@fedify/fedify 2.5.0-dev.2440 → 2.5.0-dev.2448

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 (117) hide show
  1. package/dist/{activity-listener-C-BSbKI7.mjs → activity-listener-CELFAodc.mjs} +8 -4
  2. package/dist/{builder-CTasaZgj.mjs → builder-DbC8bn6k.mjs} +5 -5
  3. package/dist/compat/mod.d.cts +1 -1
  4. package/dist/compat/mod.d.ts +1 -1
  5. package/dist/compat/transformers.test.mjs +1 -1
  6. package/dist/{compound-proof-D5r-dQMr.mjs → compound-proof-heeXW2_A.mjs} +2 -2
  7. package/dist/{context-DPocjp1l.d.cts → context-BazwQrHn.d.cts} +307 -5
  8. package/dist/{context-8Tu9kea0.mjs → context-COHd1Rsh.mjs} +2 -0
  9. package/dist/{context-2wLkQrjb.d.ts → context-GlHrzdSP.d.ts} +307 -5
  10. package/dist/{deno-DR1uYWpm.mjs → deno-Dpewt_jJ.mjs} +1 -1
  11. package/dist/{docloader-BpCJ2dHm.mjs → docloader-CpsDyqVN.mjs} +2 -2
  12. package/dist/federation/builder.test.mjs +1 -1
  13. package/dist/federation/compound-fanout.test.mjs +3 -3
  14. package/dist/federation/handler-compound-proof.test.mjs +5 -5
  15. package/dist/federation/handler.test.mjs +21 -6
  16. package/dist/federation/hashlink-media.test.mjs +2 -2
  17. package/dist/federation/idempotency.test.mjs +2 -2
  18. package/dist/federation/inbox-actorless.test.d.mts +2 -0
  19. package/dist/federation/inbox-actorless.test.mjs +487 -0
  20. package/dist/federation/inbox-authentication.test.d.mts +2 -0
  21. package/dist/federation/inbox-authentication.test.mjs +116 -0
  22. package/dist/federation/inbox-report.test.mjs +5 -5
  23. package/dist/federation/inbox-view.test.d.mts +2 -0
  24. package/dist/federation/inbox-view.test.mjs +369 -0
  25. package/dist/federation/inbox.test.mjs +22 -12
  26. package/dist/federation/metrics.test.mjs +1 -1
  27. package/dist/federation/middleware.test.mjs +24 -9
  28. package/dist/federation/mod.cjs +2 -1
  29. package/dist/federation/mod.d.cts +3 -3
  30. package/dist/federation/mod.d.ts +3 -3
  31. package/dist/federation/mod.js +8 -2
  32. package/dist/federation/mq.test.mjs +36 -1
  33. package/dist/federation/outgoing-proof.test.mjs +4 -4
  34. package/dist/federation/portable-actor.test.mjs +3 -3
  35. package/dist/federation/portable-chain.test.mjs +3 -3
  36. package/dist/federation/portable-collection.test.mjs +4 -4
  37. package/dist/federation/portable-delivery.test.mjs +2 -2
  38. package/dist/federation/portable-gateway-keys.test.mjs +6 -6
  39. package/dist/federation/portable-inbox.test.mjs +4 -4
  40. package/dist/federation/portable-parse-uri.test.mjs +1 -1
  41. package/dist/federation/portable-route-activity.test.mjs +2 -2
  42. package/dist/federation/portable.test.mjs +3 -3
  43. package/dist/federation/send.test.mjs +3 -3
  44. package/dist/federation/tasks/enqueue.test.mjs +3 -3
  45. package/dist/federation/tasks/tasks.test.mjs +4 -4
  46. package/dist/federation/temporal.test.mjs +1 -1
  47. package/dist/federation/webfinger.test.mjs +2 -2
  48. package/dist/{federation-eYRUxkUW.cjs → federation-D8YexkP1.cjs} +1174 -132
  49. package/dist/{http-CgaoFGXV.js → http-BBr-VLil.js} +143 -16
  50. package/dist/{http-CRrg14tX.mjs → http-BZkyQIkb.mjs} +4 -4
  51. package/dist/{http-CmFHJm6o.cjs → http-CAl7Num5.cjs} +161 -16
  52. package/dist/inbox-authentication-DflPYlLL.mjs +171 -0
  53. package/dist/inbox-view-NE9wXdLo.mjs +385 -0
  54. package/dist/inbox-wDuMKaFW.mjs +312 -0
  55. package/dist/{kv-cache-MxJrD9gD.mjs → kv-cache-CTQSfkmp.mjs} +1 -1
  56. package/dist/{kv-cache-DvVRGOMw.cjs → kv-cache-CjgCOz3i.cjs} +1 -1
  57. package/dist/{kv-cache-DeagaIIB.js → kv-cache-U7uz5nx4.js} +1 -1
  58. package/dist/{ld-CUM16-EE.mjs → ld-CQFuiah9.mjs} +52 -9
  59. package/dist/ld-CcuZ4NZa.d.ts +250 -0
  60. package/dist/ld-Cel1RRZ5.d.cts +250 -0
  61. package/dist/{metrics-DIM8ZCKq.mjs → metrics-B-QxRSSR.mjs} +1 -1
  62. package/dist/{middleware-Bx_QxJ0s.mjs → middleware-BdlNa8BD.mjs} +1 -1
  63. package/dist/{middleware-CDdFG6xf.mjs → middleware-CuVa0UuS.mjs} +461 -99
  64. package/dist/{middleware-CGfFooYv.js → middleware-P-AZEQMn.js} +1171 -142
  65. package/dist/mod-B2783_3v.d.cts +154 -0
  66. package/dist/mod-BHQE-7WQ.d.ts +154 -0
  67. package/dist/{mod-Dm-7RdhR.d.ts → mod-DjZfJj9R.d.ts} +1 -1
  68. package/dist/{mod-DKGoPoQC.d.cts → mod-DvWOv2Ho.d.cts} +1 -1
  69. package/dist/mod.cjs +5 -4
  70. package/dist/mod.d.cts +6 -6
  71. package/dist/mod.d.ts +6 -6
  72. package/dist/mod.js +5 -5
  73. package/dist/{mq-Dm1Wmtm-.mjs → mq-eF96QxUT.mjs} +6 -0
  74. package/dist/nodeinfo/handler.test.mjs +2 -2
  75. package/dist/{owner-DoQDS_g0.mjs → owner-ccKkQOAf.mjs} +3 -3
  76. package/dist/{portable-collection-DiBqtGSM.mjs → portable-collection-CndnpXfo.mjs} +2 -2
  77. package/dist/{portable-collection-BVKSWfBe.js → portable-collection-DUlQ3s2M.js} +1 -1
  78. package/dist/{portable-collection-C-etRRF0.cjs → portable-collection-TC-kvkVI.cjs} +1 -1
  79. package/dist/{portable-key-DSRuCUpF.mjs → portable-key-D5tFOoV-.mjs} +1 -1
  80. package/dist/{proof-DWpruPWs.mjs → proof-DPoF06nz.mjs} +98 -10
  81. package/dist/{send-H0z9Ey5l.mjs → send-CF44O1Df.mjs} +3 -3
  82. package/dist/sig/compound-proof-discovery.test.mjs +1 -1
  83. package/dist/sig/compound-proof-producer.test.mjs +1 -1
  84. package/dist/sig/compound-proof-verification.test.mjs +2 -2
  85. package/dist/sig/compound-proof.test.mjs +2 -2
  86. package/dist/sig/http.test.mjs +2 -2
  87. package/dist/sig/key.test.mjs +1 -1
  88. package/dist/sig/ld.test.mjs +1 -1
  89. package/dist/sig/mitra-receive-interop.test.mjs +4 -4
  90. package/dist/sig/mitra-send-interop.test.mjs +3 -3
  91. package/dist/sig/mod.cjs +2 -2
  92. package/dist/sig/mod.d.cts +2 -2
  93. package/dist/sig/mod.d.ts +2 -2
  94. package/dist/sig/mod.js +2 -2
  95. package/dist/sig/owner.test.mjs +1 -1
  96. package/dist/sig/portable-collection.test.mjs +1 -1
  97. package/dist/sig/portable-interop.test.mjs +3 -3
  98. package/dist/sig/portable-key.test.mjs +5 -5
  99. package/dist/sig/proof.test.mjs +44 -4
  100. package/dist/sig/tootik-request-interop.test.mjs +4 -4
  101. package/dist/sig/tootik-send-interop.test.mjs +3 -3
  102. package/dist/sig/verification.test.mjs +3 -3
  103. package/dist/{temporal-BiSBCImA.mjs → temporal-XlZ4Wb94.mjs} +1 -1
  104. package/dist/testing/kv.test.mjs +1 -1
  105. package/dist/testing/mod.d.mts +265 -3
  106. package/dist/testing/mod.mjs +2 -2
  107. package/dist/{testing-t8xDeJZ5.mjs → testing-Dbr21vZk.mjs} +1 -1
  108. package/dist/utils/docloader.test.mjs +2 -2
  109. package/dist/utils/kv-cache.test.mjs +1 -1
  110. package/dist/utils/mod.cjs +1 -1
  111. package/dist/utils/mod.js +1 -1
  112. package/package.json +7 -7
  113. package/dist/inbox-BwPoSUEv.mjs +0 -188
  114. package/dist/mod-BRpER-B0.d.ts +0 -320
  115. package/dist/mod-xAfaLS4T.d.cts +0 -320
  116. package/dist/owner-BF0L9cMt.d.cts +0 -78
  117. package/dist/owner-BSzr5-I8.d.ts +0 -78
@@ -0,0 +1,250 @@
1
+ /// <reference lib="esnext.temporal" />
2
+ import { a as KeyCache, v as VerificationObservationOptions } from "./key-DhsBxxZN.js";
3
+ import { Activity, Actor, CryptographicKey } from "@fedify/vocab";
4
+ import { MeterProvider, TracerProvider } from "@opentelemetry/api";
5
+ import { DocumentLoader } from "@fedify/vocab-runtime";
6
+
7
+ //#region src/sig/owner.d.ts
8
+ /**
9
+ * Options for {@link doesActorOwnKey}.
10
+ * @since 0.8.0
11
+ */
12
+ interface DoesActorOwnKeyOptions {
13
+ /**
14
+ * The document loader to use for fetching the actor.
15
+ */
16
+ documentLoader?: DocumentLoader;
17
+ /**
18
+ * The context loader to use for JSON-LD context retrieval.
19
+ */
20
+ contextLoader?: DocumentLoader;
21
+ /**
22
+ * The OpenTelemetry tracer provider to use for tracing. If omitted,
23
+ * the global tracer provider is used.
24
+ * @since 1.3.0
25
+ */
26
+ tracerProvider?: TracerProvider;
27
+ }
28
+ /**
29
+ * Checks if the actor of the given activity owns the specified key.
30
+ *
31
+ * Ownership is never taken from what the activity or the key say about
32
+ * themselves, as both are written by whoever sent the activity. It is
33
+ * established from a document that the owner itself serves: either the key's
34
+ * claimed owner links back to the key, or the actor the activity claims lists
35
+ * the key as its own.
36
+ *
37
+ * @param activity The activity to check.
38
+ * @param key The public key to check.
39
+ * @param options Options for checking the key ownership.
40
+ * @returns Whether the actor is the owner of the key.
41
+ */
42
+ declare function doesActorOwnKey(activity: Activity, key: CryptographicKey, options: DoesActorOwnKeyOptions): Promise<boolean>;
43
+ /**
44
+ * Options for {@link getKeyOwner}.
45
+ * @since 0.8.0
46
+ */
47
+ interface GetKeyOwnerOptions {
48
+ /**
49
+ * The document loader to use for fetching the key and its owner.
50
+ */
51
+ documentLoader?: DocumentLoader;
52
+ /**
53
+ * The context loader to use for JSON-LD context retrieval.
54
+ */
55
+ contextLoader?: DocumentLoader;
56
+ /**
57
+ * The OpenTelemetry tracer provider to use for tracing. If omitted,
58
+ * the global tracer provider is used.
59
+ * @since 1.3.0
60
+ */
61
+ tracerProvider?: TracerProvider;
62
+ }
63
+ /**
64
+ * Gets the actor that owns the specified key. Returns `null` if the key has no
65
+ * known owner.
66
+ *
67
+ * The owner is only returned when the key and the owner link to each other:
68
+ * a document that merely claims to own a key is not enough, as the claim and
69
+ * the key can come from the same host.
70
+ *
71
+ * @param keyId The ID of the key to check, or the key itself.
72
+ * @param options Options for getting the key owner.
73
+ * @returns The actor that owns the key, or `null` if the key has no known
74
+ * owner.
75
+ * @since 0.7.0
76
+ */
77
+ declare function getKeyOwner(keyId: URL | CryptographicKey, options: GetKeyOwnerOptions): Promise<Actor | null>;
78
+ //#endregion
79
+ //#region src/sig/ld.d.ts
80
+ /**
81
+ * How a context loader marked by {@link markEffectiveContextLoader} already
82
+ * resolves contexts.
83
+ * @internal
84
+ */
85
+ type EffectiveContextLoaderPolicy = "standard" | "normalization";
86
+ /**
87
+ * A signature of a JSON-LD document.
88
+ * @since 1.0.0
89
+ */
90
+ interface Signature {
91
+ "@context"?: "https://w3id.org/identity/v1";
92
+ type: "RsaSignature2017";
93
+ id?: string;
94
+ creator: string;
95
+ created: string;
96
+ signatureValue: string;
97
+ }
98
+ /**
99
+ * Attaches a LD signature to the given JSON-LD document.
100
+ * @param jsonLd The JSON-LD document to attach the signature to. It is not
101
+ * modified.
102
+ * @param signature The signature to attach.
103
+ * @returns The JSON-LD document with the attached signature.
104
+ * @throws {TypeError} If the input document is not a valid JSON-LD document.
105
+ * @since 1.0.0
106
+ */
107
+ declare function attachSignature(jsonLd: unknown, signature: Signature): {
108
+ signature: Signature;
109
+ };
110
+ /**
111
+ * Options for creating Linked Data Signatures.
112
+ * @since 1.0.0
113
+ */
114
+ interface CreateSignatureOptions {
115
+ /**
116
+ * The context loader for loading remote JSON-LD contexts.
117
+ */
118
+ contextLoader?: DocumentLoader;
119
+ /**
120
+ * The time when the signature was created. If not specified, the current
121
+ * time will be used.
122
+ */
123
+ created?: Temporal.Instant;
124
+ }
125
+ /**
126
+ * Creates a LD signature for the given JSON-LD document.
127
+ * @param jsonLd The JSON-LD document to sign.
128
+ * @param privateKey The private key to sign the document.
129
+ * @param keyId The ID of the public key that corresponds to the private key.
130
+ * @param options Additional options for creating the signature.
131
+ * See also {@link CreateSignatureOptions}.
132
+ * @return The created signature.
133
+ * @throws {TypeError} If the private key is invalid or unsupported.
134
+ * @since 1.0.0
135
+ */
136
+ declare function createSignature(jsonLd: unknown, privateKey: CryptoKey, keyId: URL, {
137
+ contextLoader,
138
+ created
139
+ }?: CreateSignatureOptions): Promise<Signature>;
140
+ /**
141
+ * Options for signing JSON-LD documents.
142
+ * @since 1.0.0
143
+ */
144
+ interface SignJsonLdOptions extends CreateSignatureOptions {
145
+ /**
146
+ * The OpenTelemetry tracer provider for tracing the signing process.
147
+ * If omitted, the global tracer provider is used.
148
+ * @since 1.3.0
149
+ */
150
+ tracerProvider?: TracerProvider;
151
+ }
152
+ /**
153
+ * Signs the given JSON-LD document with the private key and returns the signed
154
+ * JSON-LD document.
155
+ * @param jsonLd The JSON-LD document to sign.
156
+ * @param privateKey The private key to sign the document.
157
+ * @param keyId The key ID to use in the signature. It will be used by the
158
+ * verifier to fetch the corresponding public key.
159
+ * @param options Additional options for signing the document.
160
+ * See also {@link SignJsonLdOptions}.
161
+ * @returns The signed JSON-LD document.
162
+ * @throws {TypeError} If the private key is invalid or unsupported.
163
+ * @since 1.0.0
164
+ */
165
+ declare function signJsonLd(jsonLd: unknown, privateKey: CryptoKey, keyId: URL, options: SignJsonLdOptions): Promise<{
166
+ signature: Signature;
167
+ }>;
168
+ /**
169
+ * Checks if the given JSON-LD document has a Linked Data Signature-like
170
+ * object, without restricting it to a single suite-specific shape.
171
+ * @param jsonLd The JSON-LD document to check.
172
+ * @returns `true` if the document has a signature-like object; `false`
173
+ * otherwise.
174
+ * @since 2.2.0
175
+ */
176
+ declare function hasSignatureLike(jsonLd: unknown): boolean;
177
+ /**
178
+ * Detaches Linked Data Signatures from the given JSON-LD document.
179
+ * @param jsonLd The JSON-LD document to modify.
180
+ * @returns The modified JSON-LD document. If the input document does not
181
+ * contain a signature, the original document is returned.
182
+ * @since 1.0.0
183
+ */
184
+ declare function detachSignature(jsonLd: unknown): unknown;
185
+ /**
186
+ * Options for verifying Linked Data Signatures.
187
+ * @since 1.0.0
188
+ */
189
+ interface VerifySignatureOptions extends VerificationObservationOptions {
190
+ /**
191
+ * The document loader to use for fetching the public key.
192
+ */
193
+ documentLoader?: DocumentLoader;
194
+ /**
195
+ * The context loader to use for JSON-LD context retrieval.
196
+ */
197
+ contextLoader?: DocumentLoader;
198
+ /**
199
+ * The key cache to use for caching public keys.
200
+ */
201
+ keyCache?: KeyCache;
202
+ /**
203
+ * The OpenTelemetry tracer provider for tracing the verification process.
204
+ * If omitted, the global tracer provider is used.
205
+ * @since 1.3.0
206
+ */
207
+ tracerProvider?: TracerProvider;
208
+ /**
209
+ * The OpenTelemetry meter provider. If omitted, the global meter provider
210
+ * is used.
211
+ * @since 2.3.0
212
+ */
213
+ meterProvider?: MeterProvider;
214
+ }
215
+ /**
216
+ * Verifies Linked Data Signatures of the given JSON-LD document.
217
+ *
218
+ * This is a low-level utility that only checks the cryptographic signature
219
+ * and (optionally) the cached key. It does not run the JSON-LD parsing,
220
+ * attribution, and owner checks that a complete inbound LD verification
221
+ * needs. For incoming activities, prefer {@link verifyJsonLd}, which is
222
+ * the public verification entry point and the one that emits the
223
+ * `activitypub.signature.verification.duration` metric for the LD path.
224
+ * `verifySignature` itself only emits
225
+ * `activitypub.signature.key_fetch.duration`, since the rest of the work
226
+ * that the verification-duration metric is meant to cover happens in
227
+ * `verifyJsonLd`.
228
+ * @param jsonLd The JSON-LD document to verify.
229
+ * @param options Options for verifying the signature.
230
+ * @returns The public key that signed the document or `null` if the signature
231
+ * is invalid or the key is not found.
232
+ * @since 1.0.0
233
+ */
234
+ declare function verifySignature(jsonLd: unknown, options?: VerifySignatureOptions): Promise<CryptographicKey | null>;
235
+ /**
236
+ * Options for verifying JSON-LD documents.
237
+ */
238
+ interface VerifyJsonLdOptions extends VerifySignatureOptions {}
239
+ /**
240
+ * Verify the authenticity of the given JSON-LD document using Linked Data
241
+ * Signatures. If the document is signed, this function verifies the signature
242
+ * and checks if the document is attributed to the owner of the public key.
243
+ * If the document is not signed, this function returns `false`.
244
+ * @param jsonLd The JSON-LD document to verify.
245
+ * @param options Options for verifying the document.
246
+ * @returns `true` if the document is authentic; `false` otherwise.
247
+ */
248
+ declare function verifyJsonLd(jsonLd: unknown, options?: VerifyJsonLdOptions): Promise<boolean>;
249
+ //#endregion
250
+ export { VerifySignatureOptions as a, detachSignature as c, verifyJsonLd as d, verifySignature as f, getKeyOwner as g, doesActorOwnKey as h, VerifyJsonLdOptions as i, hasSignatureLike as l, GetKeyOwnerOptions as m, EffectiveContextLoaderPolicy as n, attachSignature as o, DoesActorOwnKeyOptions as p, SignJsonLdOptions as r, createSignature as s, CreateSignatureOptions as t, signJsonLd as u };
@@ -0,0 +1,250 @@
1
+ /// <reference lib="esnext.temporal" />
2
+ import { a as KeyCache, v as VerificationObservationOptions } from "./key-nYGY4QB9.cjs";
3
+ import { Activity, Actor, CryptographicKey } from "@fedify/vocab";
4
+ import { DocumentLoader } from "@fedify/vocab-runtime";
5
+ import { MeterProvider, TracerProvider } from "@opentelemetry/api";
6
+
7
+ //#region src/sig/owner.d.ts
8
+ /**
9
+ * Options for {@link doesActorOwnKey}.
10
+ * @since 0.8.0
11
+ */
12
+ interface DoesActorOwnKeyOptions {
13
+ /**
14
+ * The document loader to use for fetching the actor.
15
+ */
16
+ documentLoader?: DocumentLoader;
17
+ /**
18
+ * The context loader to use for JSON-LD context retrieval.
19
+ */
20
+ contextLoader?: DocumentLoader;
21
+ /**
22
+ * The OpenTelemetry tracer provider to use for tracing. If omitted,
23
+ * the global tracer provider is used.
24
+ * @since 1.3.0
25
+ */
26
+ tracerProvider?: TracerProvider;
27
+ }
28
+ /**
29
+ * Checks if the actor of the given activity owns the specified key.
30
+ *
31
+ * Ownership is never taken from what the activity or the key say about
32
+ * themselves, as both are written by whoever sent the activity. It is
33
+ * established from a document that the owner itself serves: either the key's
34
+ * claimed owner links back to the key, or the actor the activity claims lists
35
+ * the key as its own.
36
+ *
37
+ * @param activity The activity to check.
38
+ * @param key The public key to check.
39
+ * @param options Options for checking the key ownership.
40
+ * @returns Whether the actor is the owner of the key.
41
+ */
42
+ declare function doesActorOwnKey(activity: Activity, key: CryptographicKey, options: DoesActorOwnKeyOptions): Promise<boolean>;
43
+ /**
44
+ * Options for {@link getKeyOwner}.
45
+ * @since 0.8.0
46
+ */
47
+ interface GetKeyOwnerOptions {
48
+ /**
49
+ * The document loader to use for fetching the key and its owner.
50
+ */
51
+ documentLoader?: DocumentLoader;
52
+ /**
53
+ * The context loader to use for JSON-LD context retrieval.
54
+ */
55
+ contextLoader?: DocumentLoader;
56
+ /**
57
+ * The OpenTelemetry tracer provider to use for tracing. If omitted,
58
+ * the global tracer provider is used.
59
+ * @since 1.3.0
60
+ */
61
+ tracerProvider?: TracerProvider;
62
+ }
63
+ /**
64
+ * Gets the actor that owns the specified key. Returns `null` if the key has no
65
+ * known owner.
66
+ *
67
+ * The owner is only returned when the key and the owner link to each other:
68
+ * a document that merely claims to own a key is not enough, as the claim and
69
+ * the key can come from the same host.
70
+ *
71
+ * @param keyId The ID of the key to check, or the key itself.
72
+ * @param options Options for getting the key owner.
73
+ * @returns The actor that owns the key, or `null` if the key has no known
74
+ * owner.
75
+ * @since 0.7.0
76
+ */
77
+ declare function getKeyOwner(keyId: URL | CryptographicKey, options: GetKeyOwnerOptions): Promise<Actor | null>;
78
+ //#endregion
79
+ //#region src/sig/ld.d.ts
80
+ /**
81
+ * How a context loader marked by {@link markEffectiveContextLoader} already
82
+ * resolves contexts.
83
+ * @internal
84
+ */
85
+ type EffectiveContextLoaderPolicy = "standard" | "normalization";
86
+ /**
87
+ * A signature of a JSON-LD document.
88
+ * @since 1.0.0
89
+ */
90
+ interface Signature {
91
+ "@context"?: "https://w3id.org/identity/v1";
92
+ type: "RsaSignature2017";
93
+ id?: string;
94
+ creator: string;
95
+ created: string;
96
+ signatureValue: string;
97
+ }
98
+ /**
99
+ * Attaches a LD signature to the given JSON-LD document.
100
+ * @param jsonLd The JSON-LD document to attach the signature to. It is not
101
+ * modified.
102
+ * @param signature The signature to attach.
103
+ * @returns The JSON-LD document with the attached signature.
104
+ * @throws {TypeError} If the input document is not a valid JSON-LD document.
105
+ * @since 1.0.0
106
+ */
107
+ declare function attachSignature(jsonLd: unknown, signature: Signature): {
108
+ signature: Signature;
109
+ };
110
+ /**
111
+ * Options for creating Linked Data Signatures.
112
+ * @since 1.0.0
113
+ */
114
+ interface CreateSignatureOptions {
115
+ /**
116
+ * The context loader for loading remote JSON-LD contexts.
117
+ */
118
+ contextLoader?: DocumentLoader;
119
+ /**
120
+ * The time when the signature was created. If not specified, the current
121
+ * time will be used.
122
+ */
123
+ created?: Temporal.Instant;
124
+ }
125
+ /**
126
+ * Creates a LD signature for the given JSON-LD document.
127
+ * @param jsonLd The JSON-LD document to sign.
128
+ * @param privateKey The private key to sign the document.
129
+ * @param keyId The ID of the public key that corresponds to the private key.
130
+ * @param options Additional options for creating the signature.
131
+ * See also {@link CreateSignatureOptions}.
132
+ * @return The created signature.
133
+ * @throws {TypeError} If the private key is invalid or unsupported.
134
+ * @since 1.0.0
135
+ */
136
+ declare function createSignature(jsonLd: unknown, privateKey: CryptoKey, keyId: URL, {
137
+ contextLoader,
138
+ created
139
+ }?: CreateSignatureOptions): Promise<Signature>;
140
+ /**
141
+ * Options for signing JSON-LD documents.
142
+ * @since 1.0.0
143
+ */
144
+ interface SignJsonLdOptions extends CreateSignatureOptions {
145
+ /**
146
+ * The OpenTelemetry tracer provider for tracing the signing process.
147
+ * If omitted, the global tracer provider is used.
148
+ * @since 1.3.0
149
+ */
150
+ tracerProvider?: TracerProvider;
151
+ }
152
+ /**
153
+ * Signs the given JSON-LD document with the private key and returns the signed
154
+ * JSON-LD document.
155
+ * @param jsonLd The JSON-LD document to sign.
156
+ * @param privateKey The private key to sign the document.
157
+ * @param keyId The key ID to use in the signature. It will be used by the
158
+ * verifier to fetch the corresponding public key.
159
+ * @param options Additional options for signing the document.
160
+ * See also {@link SignJsonLdOptions}.
161
+ * @returns The signed JSON-LD document.
162
+ * @throws {TypeError} If the private key is invalid or unsupported.
163
+ * @since 1.0.0
164
+ */
165
+ declare function signJsonLd(jsonLd: unknown, privateKey: CryptoKey, keyId: URL, options: SignJsonLdOptions): Promise<{
166
+ signature: Signature;
167
+ }>;
168
+ /**
169
+ * Checks if the given JSON-LD document has a Linked Data Signature-like
170
+ * object, without restricting it to a single suite-specific shape.
171
+ * @param jsonLd The JSON-LD document to check.
172
+ * @returns `true` if the document has a signature-like object; `false`
173
+ * otherwise.
174
+ * @since 2.2.0
175
+ */
176
+ declare function hasSignatureLike(jsonLd: unknown): boolean;
177
+ /**
178
+ * Detaches Linked Data Signatures from the given JSON-LD document.
179
+ * @param jsonLd The JSON-LD document to modify.
180
+ * @returns The modified JSON-LD document. If the input document does not
181
+ * contain a signature, the original document is returned.
182
+ * @since 1.0.0
183
+ */
184
+ declare function detachSignature(jsonLd: unknown): unknown;
185
+ /**
186
+ * Options for verifying Linked Data Signatures.
187
+ * @since 1.0.0
188
+ */
189
+ interface VerifySignatureOptions extends VerificationObservationOptions {
190
+ /**
191
+ * The document loader to use for fetching the public key.
192
+ */
193
+ documentLoader?: DocumentLoader;
194
+ /**
195
+ * The context loader to use for JSON-LD context retrieval.
196
+ */
197
+ contextLoader?: DocumentLoader;
198
+ /**
199
+ * The key cache to use for caching public keys.
200
+ */
201
+ keyCache?: KeyCache;
202
+ /**
203
+ * The OpenTelemetry tracer provider for tracing the verification process.
204
+ * If omitted, the global tracer provider is used.
205
+ * @since 1.3.0
206
+ */
207
+ tracerProvider?: TracerProvider;
208
+ /**
209
+ * The OpenTelemetry meter provider. If omitted, the global meter provider
210
+ * is used.
211
+ * @since 2.3.0
212
+ */
213
+ meterProvider?: MeterProvider;
214
+ }
215
+ /**
216
+ * Verifies Linked Data Signatures of the given JSON-LD document.
217
+ *
218
+ * This is a low-level utility that only checks the cryptographic signature
219
+ * and (optionally) the cached key. It does not run the JSON-LD parsing,
220
+ * attribution, and owner checks that a complete inbound LD verification
221
+ * needs. For incoming activities, prefer {@link verifyJsonLd}, which is
222
+ * the public verification entry point and the one that emits the
223
+ * `activitypub.signature.verification.duration` metric for the LD path.
224
+ * `verifySignature` itself only emits
225
+ * `activitypub.signature.key_fetch.duration`, since the rest of the work
226
+ * that the verification-duration metric is meant to cover happens in
227
+ * `verifyJsonLd`.
228
+ * @param jsonLd The JSON-LD document to verify.
229
+ * @param options Options for verifying the signature.
230
+ * @returns The public key that signed the document or `null` if the signature
231
+ * is invalid or the key is not found.
232
+ * @since 1.0.0
233
+ */
234
+ declare function verifySignature(jsonLd: unknown, options?: VerifySignatureOptions): Promise<CryptographicKey | null>;
235
+ /**
236
+ * Options for verifying JSON-LD documents.
237
+ */
238
+ interface VerifyJsonLdOptions extends VerifySignatureOptions {}
239
+ /**
240
+ * Verify the authenticity of the given JSON-LD document using Linked Data
241
+ * Signatures. If the document is signed, this function verifies the signature
242
+ * and checks if the document is attributed to the owner of the public key.
243
+ * If the document is not signed, this function returns `false`.
244
+ * @param jsonLd The JSON-LD document to verify.
245
+ * @param options Options for verifying the document.
246
+ * @returns `true` if the document is authentic; `false` otherwise.
247
+ */
248
+ declare function verifyJsonLd(jsonLd: unknown, options?: VerifyJsonLdOptions): Promise<boolean>;
249
+ //#endregion
250
+ export { VerifySignatureOptions as a, detachSignature as c, verifyJsonLd as d, verifySignature as f, getKeyOwner as g, doesActorOwnKey as h, VerifyJsonLdOptions as i, hasSignatureLike as l, GetKeyOwnerOptions as m, EffectiveContextLoaderPolicy as n, attachSignature as o, DoesActorOwnKeyOptions as p, SignJsonLdOptions as r, createSignature as s, CreateSignatureOptions as t, signJsonLd as u };
@@ -1,7 +1,7 @@
1
1
  import "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-DR1uYWpm.mjs";
4
+ import { n as version, t as name } from "./deno-Dpewt_jJ.mjs";
5
5
  import { metrics } from "@opentelemetry/api";
6
6
  import { FetchError } from "@fedify/vocab-runtime";
7
7
  //#region src/federation/metrics.ts
@@ -1,5 +1,5 @@
1
1
  import "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as FederationImpl } from "./middleware-CDdFG6xf.mjs";
4
+ import { n as FederationImpl } from "./middleware-CuVa0UuS.mjs";
5
5
  export { FederationImpl };