@fedify/fedify 2.1.0-dev.565 → 2.1.0-dev.592

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 (96) hide show
  1. package/dist/accept-D7sAxyNa.js +143 -0
  2. package/dist/{assert_rejects-Ce45JcFg.js → assert_rejects-0h7I2Esa.js} +1 -1
  3. package/dist/{builder-Deoi2N2z.js → builder-B24i8eYp.js} +3 -3
  4. package/dist/compat/mod.d.cts +3 -3
  5. package/dist/compat/mod.d.ts +3 -3
  6. package/dist/compat/transformers.test.js +17 -16
  7. package/dist/{context-DL0cPpPV.d.cts → context-BcqA-0BL.d.cts} +52 -2
  8. package/dist/{context--RwChtri.d.ts → context-DyJjQQ_H.d.ts} +52 -2
  9. package/dist/{deno-CEdy89j9.js → deno-OR506Yti.js} +1 -2
  10. package/dist/{docloader-CL1QPJzN.js → docloader-BG_pP2fW.js} +2 -2
  11. package/dist/federation/builder.test.js +7 -7
  12. package/dist/federation/collection.test.js +5 -5
  13. package/dist/federation/handler.test.js +806 -26
  14. package/dist/federation/idempotency.test.js +22 -21
  15. package/dist/federation/inbox.test.js +3 -3
  16. package/dist/federation/keycache.test.js +1 -1
  17. package/dist/federation/kv.test.js +4 -4
  18. package/dist/federation/middleware.test.js +22 -21
  19. package/dist/federation/mod.cjs +4 -4
  20. package/dist/federation/mod.d.cts +4 -4
  21. package/dist/federation/mod.d.ts +4 -4
  22. package/dist/federation/mod.js +4 -4
  23. package/dist/federation/mq.test.js +4 -4
  24. package/dist/federation/negotiation.test.js +5 -5
  25. package/dist/federation/retry.test.js +2 -2
  26. package/dist/federation/router.test.js +4 -4
  27. package/dist/federation/send.test.js +11 -10
  28. package/dist/federation/webfinger.test.js +22 -21
  29. package/dist/{http-Dm9n1mRe.js → http-BUCxbGks.js} +144 -49
  30. package/dist/{http-DsqqmkXi.d.cts → http-BudnHZE2.d.cts} +229 -1
  31. package/dist/{http-iDlaLy8a.cjs → http-CaXARmaJ.cjs} +307 -50
  32. package/dist/{http-BbfOqHGG.d.ts → http-Dax_FIBo.d.ts} +229 -1
  33. package/dist/{http-VpqmUjje.js → http-DePHjWKP.js} +278 -51
  34. package/dist/{inbox-CMtnW0RE.js → inbox-D_LU1opv.js} +1 -1
  35. package/dist/{key-B0yADkL8.js → key-Cx3Tx_In.js} +1 -1
  36. package/dist/{kv-cache-551Om14-.cjs → kv-cache-CYTDBChd.cjs} +1 -1
  37. package/dist/{kv-cache-BSATpUtX.js → kv-cache-DizRqYX4.js} +1 -1
  38. package/dist/{ld-BBmbv1nb.js → ld-CLMJw_iX.js} +3 -3
  39. package/dist/{middleware-Cx0tTbX1.js → middleware--uATyG9i.js} +95 -18
  40. package/dist/{middleware-DpdPMZII.js → middleware-4fo4pEtA.js} +4 -4
  41. package/dist/{middleware-D11GYoP-.cjs → middleware-9YDezkYJ.cjs} +94 -17
  42. package/dist/middleware-C2PqSUaA.js +27 -0
  43. package/dist/middleware-DNY45l5T.cjs +12 -0
  44. package/dist/{middleware-Cldp2YSv.js → middleware-DzICTgdC.js} +113 -34
  45. package/dist/{mod-DE8MYisy.d.cts → mod-B7QkWzrL.d.cts} +1 -1
  46. package/dist/{mod-DKG0ovjR.d.cts → mod-Bx9jcLB8.d.cts} +1 -1
  47. package/dist/{mod-CFBU2OT3.d.cts → mod-Coe7KEgX.d.cts} +1 -1
  48. package/dist/{mod-BugwI0JN.d.ts → mod-Cs2dYEwI.d.ts} +1 -1
  49. package/dist/{mod-DcfFNgYf.d.ts → mod-D6MdymW7.d.ts} +1 -1
  50. package/dist/{mod-CvxylbuV.d.ts → mod-D6dOd--H.d.ts} +1 -1
  51. package/dist/{mod-Z7lIaCfo.d.ts → mod-SMHOMNpZ.d.ts} +1 -1
  52. package/dist/{mod-Dp0kK0hO.d.cts → mod-em2Il1eD.d.cts} +1 -1
  53. package/dist/mod.cjs +12 -4
  54. package/dist/mod.d.cts +8 -8
  55. package/dist/mod.d.ts +8 -8
  56. package/dist/mod.js +9 -5
  57. package/dist/nodeinfo/client.test.js +4 -4
  58. package/dist/nodeinfo/handler.test.js +22 -21
  59. package/dist/nodeinfo/types.test.js +4 -4
  60. package/dist/otel/exporter.test.js +4 -4
  61. package/dist/{owner-C1ZyG4NL.js → owner-D5J299vd.js} +1 -1
  62. package/dist/{proof-wclcUq0C.js → proof-BBLHhWMC.js} +2 -2
  63. package/dist/{proof-CgK60TcQ.cjs → proof-BVl5IgbN.cjs} +3 -3
  64. package/dist/{proof-DnRq8s8f.js → proof-CiCp_mCG.js} +2 -2
  65. package/dist/{send-DNJyYRVU.js → send-2b0Fn9cn.js} +2 -2
  66. package/dist/sig/accept.test.d.ts +3 -0
  67. package/dist/sig/accept.test.js +451 -0
  68. package/dist/sig/http.test.js +452 -27
  69. package/dist/sig/key.test.js +7 -7
  70. package/dist/sig/ld.test.js +6 -6
  71. package/dist/sig/mod.cjs +6 -2
  72. package/dist/sig/mod.d.cts +3 -3
  73. package/dist/sig/mod.d.ts +3 -3
  74. package/dist/sig/mod.js +3 -3
  75. package/dist/sig/owner.test.js +8 -8
  76. package/dist/sig/proof.test.js +8 -8
  77. package/dist/testing/mod.js +1 -1
  78. package/dist/utils/docloader.test.js +10 -9
  79. package/dist/utils/kv-cache.test.js +1 -1
  80. package/dist/utils/mod.cjs +2 -2
  81. package/dist/utils/mod.d.cts +2 -2
  82. package/dist/utils/mod.d.ts +2 -2
  83. package/dist/utils/mod.js +2 -2
  84. package/package.json +6 -7
  85. package/dist/middleware-BDr0P6dx.cjs +0 -12
  86. package/dist/middleware-BZ8WpBo6.js +0 -26
  87. /package/dist/{assert_not_equals-C80BG-_5.js → assert_not_equals-f3m3epl3.js} +0 -0
  88. /package/dist/{assert_throws-BNXdRGWP.js → assert_throws-rjdMBf31.js} +0 -0
  89. /package/dist/{collection-CcnIw1qY.js → collection-CSzG2j1P.js} +0 -0
  90. /package/dist/{context-pa9aIrwp.js → context-Aqenou7c.js} +0 -0
  91. /package/dist/{keycache-C7k8s1Bk.js → keycache-CpGWAUbj.js} +0 -0
  92. /package/dist/{keys-ZbcByPg9.js → keys-BFve7QQv.js} +0 -0
  93. /package/dist/{kv-cache-El7We5sy.js → kv-cache-Bw2F2ABq.js} +0 -0
  94. /package/dist/{negotiation-5NPJL6zp.js → negotiation-BlAuS_nr.js} +0 -0
  95. /package/dist/{retry-D4GJ670a.js → retry-mqLf4b-R.js} +0 -0
  96. /package/dist/{std__assert-DWivtrGR.js → std__assert-X-_kMxKM.js} +0 -0
@@ -153,6 +153,194 @@ interface KeyCache {
153
153
  set(keyId: URL, key: CryptographicKey | Multikey | null): Promise<void>;
154
154
  }
155
155
  //#endregion
156
+ //#region src/sig/accept.d.ts
157
+ /**
158
+ * Signature metadata parameters that may appear in an
159
+ * `Accept-Signature` member, as defined in
160
+ * [RFC 9421 §5.1](https://www.rfc-editor.org/rfc/rfc9421#section-5.1).
161
+ *
162
+ * @since 2.1.0
163
+ */
164
+ interface AcceptSignatureParameters {
165
+ /**
166
+ * If present, the signer is requested to use the indicated key
167
+ * material to create the target signature.
168
+ */
169
+ keyid?: string;
170
+ /**
171
+ * If present, the signer is requested to use the indicated algorithm
172
+ * from the HTTP Signature Algorithms registry.
173
+ */
174
+ alg?: string;
175
+ /**
176
+ * If `true`, the signer is requested to generate and include a
177
+ * creation timestamp. This parameter has no associated value in the
178
+ * wire format.
179
+ */
180
+ created?: true;
181
+ /**
182
+ * If `true`, the signer is requested to generate and include an
183
+ * expiration timestamp. This parameter has no associated value in
184
+ * the wire format.
185
+ */
186
+ expires?: true;
187
+ /**
188
+ * If present, the signer is requested to include this value as the
189
+ * signature nonce in the target signature.
190
+ */
191
+ nonce?: string;
192
+ /**
193
+ * If present, the signer is requested to include this value as the
194
+ * signature tag in the target signature.
195
+ */
196
+ tag?: string;
197
+ }
198
+ /**
199
+ * A single covered component identifier from an `Accept-Signature` inner list,
200
+ * as defined in [RFC 9421 §2.1](https://www.rfc-editor.org/rfc/rfc9421#section-2.1)
201
+ * and [§5.1](https://www.rfc-editor.org/rfc/rfc9421#section-5.1).
202
+ *
203
+ * RFC 9421 §5.1 requires that the list of component identifiers includes
204
+ * *all applicable component parameters*. Parameters such as `;sf`, `;bs`,
205
+ * `;req`, `;tr`, `;name`, and `;key` narrow the meaning of a component
206
+ * identifier and MUST be preserved exactly as received so that the signer
207
+ * can cover the same components the verifier requested.
208
+ *
209
+ * Examples:
210
+ * - `{ value: "@method", params: {} }`
211
+ * - `{ value: "content-type", params: { sf: true } }`
212
+ * - `{ value: "@query-param", params: { name: "foo" } }`
213
+ *
214
+ * @since 2.1.0
215
+ */
216
+ interface AcceptSignatureComponent {
217
+ /**
218
+ * The component identifier name (e.g., `"@method"`, `"content-digest"`,
219
+ * `"@query-param"`).
220
+ */
221
+ value: string;
222
+ /**
223
+ * Component parameters attached to this identifier (e.g., `{ sf: true }`,
224
+ * `{ name: "foo" }`). An empty object means no parameters were present.
225
+ * Parameters MUST NOT be dropped; doing so would cause the signer to cover
226
+ * a different component than the verifier requested.
227
+ */
228
+ params: Record<string, unknown>;
229
+ }
230
+ /**
231
+ * Represents a single member of the `Accept-Signature` Dictionary
232
+ * Structured Field, as defined in
233
+ * [RFC 9421 §5.1](https://www.rfc-editor.org/rfc/rfc9421#section-5.1).
234
+ *
235
+ * @since 2.1.0
236
+ */
237
+ interface AcceptSignatureMember {
238
+ /**
239
+ * The label that uniquely identifies the requested message signature
240
+ * within the context of the target HTTP message (e.g., `"sig1"`).
241
+ */
242
+ label: string;
243
+ /**
244
+ * The exact list of covered component identifiers requested for the target
245
+ * signature, including all applicable component parameters, as required by
246
+ * [RFC 9421 §5.1](https://www.rfc-editor.org/rfc/rfc9421#section-5.1).
247
+ *
248
+ * Each element is an {@link AcceptSignatureComponent} that preserves
249
+ * both the identifier name and any parameters (e.g., `;sf`, `;name="foo"`).
250
+ * The signer MUST cover exactly these components—with their parameters—when
251
+ * fulfilling the challenge.
252
+ */
253
+ components: AcceptSignatureComponent[];
254
+ /**
255
+ * Optional signature metadata parameters requested by the verifier.
256
+ */
257
+ parameters: AcceptSignatureParameters;
258
+ }
259
+ /**
260
+ * Parses an `Accept-Signature` header value (RFC 9421 §5.1) into an
261
+ * array of {@link AcceptSignatureMember} objects.
262
+ *
263
+ * The `Accept-Signature` field is a Dictionary Structured Field
264
+ * (RFC 8941 §3.2). Each dictionary member describes a single
265
+ * requested message signature.
266
+ *
267
+ * On parse failure (malformed or empty header), returns an empty array.
268
+ *
269
+ * @param header The raw `Accept-Signature` header value string.
270
+ * @returns An array of parsed members. Empty if the header is
271
+ * malformed or empty.
272
+ * @since 2.1.0
273
+ */
274
+ declare function parseAcceptSignature(header: string): AcceptSignatureMember[];
275
+ /**
276
+ * Serializes an array of {@link AcceptSignatureMember} objects into an
277
+ * `Accept-Signature` header value string (RFC 9421 §5.1).
278
+ *
279
+ * The output is a Dictionary Structured Field (RFC 8941 §3.2).
280
+ *
281
+ * @param members The members to serialize.
282
+ * @returns The serialized header value string.
283
+ * @since 2.1.0
284
+ */
285
+ declare function formatAcceptSignature(members: AcceptSignatureMember[]): string;
286
+ /**
287
+ * Filters out {@link AcceptSignatureMember} entries whose covered
288
+ * components include response-only identifiers (`@status`) that are
289
+ * not applicable to request-target messages, as required by
290
+ * [RFC 9421 §5](https://www.rfc-editor.org/rfc/rfc9421#section-5).
291
+ *
292
+ * A warning is logged for each discarded entry.
293
+ *
294
+ * @param members The parsed `Accept-Signature` entries to validate.
295
+ * @returns Only entries that are valid for request-target messages.
296
+ * @since 2.1.0
297
+ */
298
+ declare function validateAcceptSignature(members: AcceptSignatureMember[]): AcceptSignatureMember[];
299
+ /**
300
+ * The result of {@link fulfillAcceptSignature}. This can be used directly
301
+ * as the `rfc9421` option of {@link SignRequestOptions}.
302
+ * @since 2.1.0
303
+ */
304
+ interface FulfillAcceptSignatureResult {
305
+ /** The label for the signature. */
306
+ label: string;
307
+ /**
308
+ * The merged set of covered component identifiers, including all component
309
+ * parameters, ready to be passed to the signer.
310
+ */
311
+ components: AcceptSignatureComponent[];
312
+ /** The nonce requested by the challenge, if any. */
313
+ nonce?: string;
314
+ /** The tag requested by the challenge, if any. */
315
+ tag?: string;
316
+ /**
317
+ * If `true`, the challenger requested that the signer generate and include
318
+ * an expiration timestamp in the signature parameters.
319
+ */
320
+ expires?: true;
321
+ }
322
+ /**
323
+ * Attempts to translate an {@link AcceptSignatureMember} challenge into
324
+ * RFC 9421 signing options that the local signer can fulfill.
325
+ *
326
+ * Returns `null` if the challenge cannot be fulfilled—for example, if
327
+ * the requested `alg` or `keyid` is incompatible with the local key.
328
+ *
329
+ * Safety constraints:
330
+ * - `alg`: only honored if it matches `localAlg`.
331
+ * - `keyid`: only honored if it matches `localKeyId`.
332
+ * - `components`: passed through exactly as requested, per RFC 9421 §5.2.
333
+ * - `nonce`, `tag`, and `expires` are passed through directly.
334
+ *
335
+ * @param entry The challenge entry from the `Accept-Signature` header.
336
+ * @param localKeyId The local key identifier (e.g., the actor key URL).
337
+ * @param localAlg The algorithm of the local private key
338
+ * (e.g., `"rsa-v1_5-sha256"`).
339
+ * @returns Signing options if the challenge can be fulfilled, or `null`.
340
+ * @since 2.1.0
341
+ */
342
+ declare function fulfillAcceptSignature(entry: AcceptSignatureMember, localKeyId: string, localAlg: string): FulfillAcceptSignatureResult | null;
343
+ //#endregion
156
344
  //#region src/sig/http.d.ts
157
345
  /**
158
346
  * The standard to use for signing and verifying HTTP signatures.
@@ -186,6 +374,45 @@ interface SignRequestOptions {
186
374
  * is used.
187
375
  */
188
376
  tracerProvider?: TracerProvider;
377
+ /**
378
+ * Options specific to the RFC 9421 signing path. These options are
379
+ * ignored when `spec` is `"draft-cavage-http-signatures-12"`.
380
+ * @since 2.1.0
381
+ */
382
+ rfc9421?: Rfc9421SignRequestOptions;
383
+ }
384
+ /**
385
+ * Options for customizing the RFC 9421 signature label, covered components,
386
+ * and metadata parameters. These are typically derived from an
387
+ * `Accept-Signature` challenge.
388
+ * @since 2.1.0
389
+ */
390
+ interface Rfc9421SignRequestOptions {
391
+ /**
392
+ * The label for the signature in `Signature-Input` and `Signature` headers.
393
+ * @default `"sig1"`
394
+ */
395
+ label?: string;
396
+ /**
397
+ * The covered component identifiers. When omitted, the default set
398
+ * `["@method", "@target-uri", "@authority", "host", "date"]`
399
+ * (plus `"content-digest"` when a body is present) is used.
400
+ */
401
+ components?: AcceptSignatureComponent[];
402
+ /**
403
+ * A nonce value to include in the signature parameters.
404
+ */
405
+ nonce?: string;
406
+ /**
407
+ * A tag value to include in the signature parameters.
408
+ */
409
+ tag?: string;
410
+ /**
411
+ * If `true`, an expiration timestamp is generated and included in the
412
+ * signature parameters. The expiration time defaults to one hour after
413
+ * the signature creation time.
414
+ */
415
+ expires?: true;
189
416
  }
190
417
  /**
191
418
  * Signs a request using the given private key.
@@ -261,6 +488,7 @@ type VerifyRequestFailureReason = {
261
488
  type VerifyRequestDetailedResult = {
262
489
  readonly verified: true;
263
490
  readonly key: CryptographicKey;
491
+ readonly signatureLabel?: string;
264
492
  } | {
265
493
  readonly verified: false;
266
494
  readonly reason: VerifyRequestFailureReason;
@@ -315,4 +543,4 @@ interface HttpMessageSignaturesSpecDeterminer {
315
543
  * @since 1.6.0
316
544
  */
317
545
  //#endregion
318
- export { FetchKeyDetailedResult, FetchKeyErrorResult, FetchKeyOptions, FetchKeyResult, HttpMessageSignaturesSpec, HttpMessageSignaturesSpecDeterminer, KeyCache, SignRequestOptions, VerifyRequestDetailedResult, VerifyRequestFailureReason, VerifyRequestOptions, exportJwk, fetchKey, fetchKeyDetailed, generateCryptoKeyPair, importJwk, signRequest, verifyRequest, verifyRequestDetailed };
546
+ export { AcceptSignatureMember, AcceptSignatureParameters, FetchKeyDetailedResult, FetchKeyErrorResult, FetchKeyOptions, FetchKeyResult, FulfillAcceptSignatureResult, HttpMessageSignaturesSpec, HttpMessageSignaturesSpecDeterminer, KeyCache, Rfc9421SignRequestOptions, SignRequestOptions, VerifyRequestDetailedResult, VerifyRequestFailureReason, VerifyRequestOptions, exportJwk, fetchKey, fetchKeyDetailed, formatAcceptSignature, fulfillAcceptSignature, generateCryptoKeyPair, importJwk, parseAcceptSignature, signRequest, validateAcceptSignature, verifyRequest, verifyRequestDetailed };