@fedify/fedify 2.2.0-dev.613 → 2.2.0-dev.622

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 (207) hide show
  1. package/dist/{accept-D7sAxyNa.js → accept-Dd__NiUL.mjs} +10 -8
  2. package/dist/{assert-MZs1qjMx.js → assert-ddO5KLpe.mjs} +5 -9
  3. package/dist/{assert_equals-DSbWqCm3.js → assert_equals-Ew3jOFa3.mjs} +55 -69
  4. package/dist/{assert_instance_of-DHz7EHNU.js → assert_instance_of-C4Ri6VuN.mjs} +5 -9
  5. package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals--wG9hV7u.mjs} +6 -13
  6. package/dist/{assert_rejects-0h7I2Esa.js → assert_rejects-B-qJtC9Z.mjs} +6 -11
  7. package/dist/{assert_throws-rjdMBf31.js → assert_throws-4NwKEy2q.mjs} +5 -10
  8. package/dist/{builder-OscY92PK.js → builder-DcSpny3g.mjs} +32 -41
  9. package/dist/{chunk-CGaQZ11T.cjs → chunk-DDcVe30Y.cjs} +23 -24
  10. package/dist/{chunk-DJNbSFdH.js → chunk-nlSIicah.js} +8 -8
  11. package/dist/{client-BxMZiQaD.d.ts → client-AtlibPOU.d.ts} +1 -1
  12. package/dist/{client-CoCIaTNO.js → client-DEpOVgY1.mjs} +9 -13
  13. package/dist/{client-C97KOq3x.d.cts → client-z-8dc-e1.d.cts} +1 -1
  14. package/dist/{collection-CSzG2j1P.js → collection-BD6-SZ6O.mjs} +7 -12
  15. package/dist/compat/mod.cjs +5 -8
  16. package/dist/compat/mod.d.cts +78 -6
  17. package/dist/compat/mod.d.ts +78 -6
  18. package/dist/compat/mod.js +4 -8
  19. package/dist/compat/transformers.test.mjs +62 -0
  20. package/dist/{context-DyJjQQ_H.d.ts → context-BOiMZBu5.d.ts} +9 -18
  21. package/dist/{context-BcqA-0BL.d.cts → context-BhZVy7RB.d.cts} +9 -18
  22. package/dist/{context-Aqenou7c.js → context-Juj6bdHC.mjs} +7 -11
  23. package/dist/deno-D682wzlW.mjs +8 -0
  24. package/dist/{docloader-JiZmL7BP.js → docloader-CCWf4tNV.mjs} +8 -14
  25. package/dist/{esm-nLm00z9V.js → esm-DVILvP5e.mjs} +50 -89
  26. package/dist/federation/builder.test.d.mts +2 -0
  27. package/dist/federation/{builder.test.js → builder.test.mjs} +21 -44
  28. package/dist/federation/collection.test.d.mts +2 -0
  29. package/dist/federation/collection.test.mjs +21 -0
  30. package/dist/federation/handler.test.d.mts +2 -0
  31. package/dist/federation/{handler.test.js → handler.test.mjs} +69 -131
  32. package/dist/federation/idempotency.test.d.mts +2 -0
  33. package/dist/federation/{idempotency.test.js → idempotency.test.mjs} +31 -63
  34. package/dist/federation/inbox.test.d.mts +2 -0
  35. package/dist/federation/{inbox.test.js → inbox.test.mjs} +8 -12
  36. package/dist/federation/keycache.test.d.mts +2 -0
  37. package/dist/federation/{keycache.test.js → keycache.test.mjs} +13 -19
  38. package/dist/federation/kv.test.d.mts +2 -0
  39. package/dist/federation/{kv.test.js → kv.test.mjs} +11 -22
  40. package/dist/federation/middleware.test.d.mts +2 -0
  41. package/dist/federation/{middleware.test.js → middleware.test.mjs} +173 -262
  42. package/dist/federation/mod.cjs +327 -16
  43. package/dist/federation/mod.d.cts +3 -6
  44. package/dist/federation/mod.d.ts +3 -6
  45. package/dist/federation/mod.js +322 -13
  46. package/dist/federation/mq.test.d.mts +2 -0
  47. package/dist/federation/{mq.test.js → mq.test.mjs} +21 -35
  48. package/dist/federation/negotiation.test.d.mts +2 -0
  49. package/dist/federation/{negotiation.test.js → negotiation.test.mjs} +9 -16
  50. package/dist/federation/retry.test.d.mts +2 -0
  51. package/dist/federation/{retry.test.js → retry.test.mjs} +8 -11
  52. package/dist/federation/router.test.d.mts +2 -0
  53. package/dist/federation/{router.test.js → router.test.mjs} +11 -16
  54. package/dist/federation/send.test.d.mts +2 -0
  55. package/dist/federation/{send.test.js → send.test.mjs} +22 -30
  56. package/dist/federation/webfinger.test.d.mts +2 -0
  57. package/dist/federation/{webfinger.test.js → webfinger.test.mjs} +22 -56
  58. package/dist/{http-BnsR906R.cjs → http-BQccxQlj.cjs} +177 -302
  59. package/dist/{http-CKaqhjvP.js → http-CNsnyqrO.mjs} +23 -43
  60. package/dist/{http-BudnHZE2.d.cts → http-CrGuipxe.d.cts} +1 -6
  61. package/dist/{http-IFqEftoZ.js → http-DhwEMhtv.js} +53 -184
  62. package/dist/{http-Dax_FIBo.d.ts → http-aQzN9Ayi.d.ts} +1 -6
  63. package/dist/{inbox-Bd91CVJP.js → inbox-DegXbbbS.mjs} +18 -26
  64. package/dist/{key-DFLFXKER.js → key-vL60OvqM.mjs} +29 -37
  65. package/dist/{keycache-CpGWAUbj.js → keycache-CCSwkQcY.mjs} +5 -10
  66. package/dist/{keys-BFve7QQv.js → keys-BAK-tUlf.mjs} +5 -9
  67. package/dist/{kv-BL4nlICN.d.cts → kv-CbLNp3zQ.d.cts} +1 -1
  68. package/dist/{kv-DXEUEP6z.d.ts → kv-GFYnFoOl.d.ts} +1 -1
  69. package/dist/{kv-cache-Bw2F2ABq.js → kv-cache-B01V7s3h.mjs} +4 -8
  70. package/dist/{kv-cache-Drlz6O_Y.js → kv-cache-CTj3iCix.js} +6 -13
  71. package/dist/{kv-cache-BLXcQvyb.cjs → kv-cache-DxdXJNbj.cjs} +27 -34
  72. package/dist/{kv-QzKcOQgP.js → kv-tL2TOE9X.mjs} +6 -10
  73. package/dist/{ld-CGGXZJK0.js → ld-C3CO00YY.mjs} +17 -31
  74. package/dist/{middleware-DcpBikad.js → middleware-BmsVSOeS.js} +335 -382
  75. package/dist/middleware-C7shNcsp.cjs +4 -0
  76. package/dist/{middleware-B51dB75z.cjs → middleware-Cx0Ny6_7.cjs} +532 -587
  77. package/dist/middleware-DqVGYk56.mjs +5 -0
  78. package/dist/{middleware-B53r4pdM.js → middleware-Du-vh7I_.mjs} +282 -317
  79. package/dist/{mod-em2Il1eD.d.cts → mod-Bp_CzKd4.d.cts} +2 -2
  80. package/dist/{mod-DCbh1JQ5.d.ts → mod-CLgIXe9w.d.ts} +3 -3
  81. package/dist/{mod-jfnweK2w.d.cts → mod-CMEbIaNh.d.cts} +3 -3
  82. package/dist/{mod-D6MdymW7.d.ts → mod-DKOAow7a.d.ts} +2 -2
  83. package/dist/{mod-Coe7KEgX.d.cts → mod-DoJBjjnO.d.cts} +2 -2
  84. package/dist/{mod-D6dOd--H.d.ts → mod-DvxszxXC.d.ts} +2 -2
  85. package/dist/mod.cjs +29 -74
  86. package/dist/mod.d.cts +11 -14
  87. package/dist/mod.d.ts +11 -15
  88. package/dist/mod.js +17 -71
  89. package/dist/{negotiation-BlAuS_nr.js → negotiation-DnsfFF8I.mjs} +7 -11
  90. package/dist/nodeinfo/client.test.d.mts +2 -0
  91. package/dist/nodeinfo/{client.test.js → client.test.mjs} +22 -40
  92. package/dist/nodeinfo/handler.test.d.mts +2 -0
  93. package/dist/nodeinfo/{handler.test.js → handler.test.mjs} +13 -43
  94. package/dist/nodeinfo/mod.cjs +5 -8
  95. package/dist/nodeinfo/mod.d.cts +2 -3
  96. package/dist/nodeinfo/mod.d.ts +2 -3
  97. package/dist/nodeinfo/mod.js +4 -8
  98. package/dist/nodeinfo/types.test.d.mts +2 -0
  99. package/dist/nodeinfo/{types.test.js → types.test.mjs} +9 -16
  100. package/dist/otel/exporter.test.d.mts +2 -0
  101. package/dist/otel/{exporter.test.js → exporter.test.mjs} +124 -178
  102. package/dist/otel/mod.cjs +15 -20
  103. package/dist/otel/mod.d.cts +2 -2
  104. package/dist/otel/mod.d.ts +2 -2
  105. package/dist/otel/mod.js +8 -14
  106. package/dist/{owner-gd0Q9FuU.d.ts → owner-74ARJ5TL.d.ts} +1 -1
  107. package/dist/{owner-1AbPBOOZ.d.cts → owner-CptqhsOy.d.cts} +1 -1
  108. package/dist/{owner-Cye0yQB_.js → owner-DF320w6K.mjs} +11 -16
  109. package/dist/{proof-DdGGXVWM.js → proof-BCWk5oas.js} +32 -58
  110. package/dist/{proof-DV5lC_Bw.js → proof-IyDwwmzL.mjs} +21 -33
  111. package/dist/{proof-CN5iR1tW.cjs → proof-WhNxSv_N.cjs} +133 -157
  112. package/dist/{retry-mqLf4b-R.js → retry-B_E3V_Dx.mjs} +4 -7
  113. package/dist/{router-D9eI0s4b.js → router-CrMLXoOr.mjs} +4 -8
  114. package/dist/runtime/mod.cjs +11 -13
  115. package/dist/runtime/mod.d.cts +6 -2
  116. package/dist/runtime/mod.d.ts +0 -1
  117. package/dist/runtime/mod.js +4 -7
  118. package/dist/{send-C2a_3YAF.js → send-CJQubr5t.mjs} +8 -13
  119. package/dist/sig/accept.test.d.mts +2 -0
  120. package/dist/sig/{accept.test.js → accept.test.mjs} +35 -70
  121. package/dist/sig/http.test.d.mts +2 -0
  122. package/dist/sig/{http.test.js → http.test.mjs} +166 -280
  123. package/dist/sig/key.test.d.mts +2 -0
  124. package/dist/sig/{key.test.js → key.test.mjs} +11 -18
  125. package/dist/sig/ld.test.d.mts +2 -0
  126. package/dist/sig/{ld.test.js → ld.test.mjs} +22 -35
  127. package/dist/sig/mod.cjs +6 -9
  128. package/dist/sig/mod.d.cts +3 -3
  129. package/dist/sig/mod.d.ts +3 -3
  130. package/dist/sig/mod.js +5 -9
  131. package/dist/sig/owner.test.d.mts +2 -0
  132. package/dist/sig/{owner.test.js → owner.test.mjs} +19 -34
  133. package/dist/sig/proof.test.d.mts +2 -0
  134. package/dist/sig/{proof.test.js → proof.test.mjs} +16 -27
  135. package/dist/{std__assert-X-_kMxKM.js → std__assert-Duiq_YC9.mjs} +12 -24
  136. package/dist/testing/{mod.d.ts → mod.d.mts} +26 -90
  137. package/dist/testing/mod.mjs +6 -0
  138. package/dist/{transformers-3g8GZwkZ.cjs → transformers-NeAONrAq.cjs} +20 -25
  139. package/dist/{transformers-C3FLHUd6.js → transformers-ve6e2xcg.js} +3 -7
  140. package/dist/{types-CPz01LGH.js → types-DCP0WLdt.mjs} +4 -7
  141. package/dist/{types-Cd_hszr_.cjs → types-KC4QAoxe.cjs} +29 -34
  142. package/dist/{types-C93Ob9cU.js → types-hvL8ElAs.js} +8 -13
  143. package/dist/utils/docloader.test.d.mts +2 -0
  144. package/dist/utils/{docloader.test.js → docloader.test.mjs} +14 -25
  145. package/dist/utils/kv-cache.test.d.mts +2 -0
  146. package/dist/utils/{kv-cache.test.js → kv-cache.test.mjs} +25 -40
  147. package/dist/utils/mod.cjs +5 -9
  148. package/dist/utils/mod.d.cts +1 -3
  149. package/dist/utils/mod.d.ts +1 -3
  150. package/dist/utils/mod.js +4 -9
  151. package/dist/vocab/cjs.test.d.mts +2 -0
  152. package/dist/vocab/cjs.test.mjs +14 -0
  153. package/dist/vocab/mod.cjs +10 -12
  154. package/dist/vocab/mod.js +3 -5
  155. package/package.json +8 -8
  156. package/dist/compat/transformers.test.d.ts +0 -3
  157. package/dist/compat/transformers.test.js +0 -88
  158. package/dist/compat-Bb4NuTUO.js +0 -4
  159. package/dist/compat-DmDDELst.cjs +0 -4
  160. package/dist/deno-CnMqla6T.js +0 -121
  161. package/dist/federation/builder.test.d.ts +0 -3
  162. package/dist/federation/collection.test.d.ts +0 -3
  163. package/dist/federation/collection.test.js +0 -32
  164. package/dist/federation/handler.test.d.ts +0 -3
  165. package/dist/federation/idempotency.test.d.ts +0 -3
  166. package/dist/federation/inbox.test.d.ts +0 -3
  167. package/dist/federation/keycache.test.d.ts +0 -3
  168. package/dist/federation/kv.test.d.ts +0 -3
  169. package/dist/federation/middleware.test.d.ts +0 -3
  170. package/dist/federation/mq.test.d.ts +0 -3
  171. package/dist/federation/negotiation.test.d.ts +0 -3
  172. package/dist/federation/retry.test.d.ts +0 -3
  173. package/dist/federation/router.test.d.ts +0 -3
  174. package/dist/federation/send.test.d.ts +0 -3
  175. package/dist/federation/webfinger.test.d.ts +0 -3
  176. package/dist/federation-Bp3HI26G.cjs +0 -350
  177. package/dist/federation-DaMfqRm4.js +0 -332
  178. package/dist/middleware-B0kNQMO0.js +0 -27
  179. package/dist/middleware-BYQL9cdV.js +0 -12
  180. package/dist/middleware-DfNqksSs.cjs +0 -12
  181. package/dist/mod-B7QkWzrL.d.cts +0 -80
  182. package/dist/mod-Bh8mqlYw.d.cts +0 -9
  183. package/dist/mod-D6HodEq7.d.ts +0 -7
  184. package/dist/mod-SMHOMNpZ.d.ts +0 -82
  185. package/dist/mod-gq_Xfdz8.d.cts +0 -1
  186. package/dist/nodeinfo/client.test.d.ts +0 -3
  187. package/dist/nodeinfo/handler.test.d.ts +0 -3
  188. package/dist/nodeinfo/types.test.d.ts +0 -3
  189. package/dist/nodeinfo-DoESQxq5.js +0 -4
  190. package/dist/nodeinfo-DuMYTpbZ.cjs +0 -4
  191. package/dist/otel/exporter.test.d.ts +0 -3
  192. package/dist/runtime-c2Njxsry.cjs +0 -17
  193. package/dist/runtime-poamPCMb.js +0 -13
  194. package/dist/sig/accept.test.d.ts +0 -3
  195. package/dist/sig/http.test.d.ts +0 -3
  196. package/dist/sig/key.test.d.ts +0 -3
  197. package/dist/sig/ld.test.d.ts +0 -3
  198. package/dist/sig/owner.test.d.ts +0 -3
  199. package/dist/sig/proof.test.d.ts +0 -3
  200. package/dist/sig-BNhspNOf.js +0 -4
  201. package/dist/sig-vX39WyWI.cjs +0 -4
  202. package/dist/testing/mod.js +0 -10
  203. package/dist/utils/docloader.test.d.ts +0 -3
  204. package/dist/utils/kv-cache.test.d.ts +0 -3
  205. package/dist/utils-BQ9KqEK9.cjs +0 -4
  206. package/dist/utils-Dn5OPdSW.js +0 -4
  207. /package/dist/{mod-AGjRfPjT.d.ts → compat/transformers.test.d.mts} +0 -0
@@ -1,20 +1,17 @@
1
-
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
- globalThis.addEventListener = () => {};
5
-
6
- import { deno_default } from "./deno-CnMqla6T.js";
7
- import { fulfillAcceptSignature, parseAcceptSignature, validateAcceptSignature } from "./accept-D7sAxyNa.js";
8
- import { fetchKeyDetailed, validateCryptoKey } from "./key-DFLFXKER.js";
1
+ import { Temporal } from "@js-temporal/polyfill";
2
+ import "urlpattern-polyfill";
3
+ globalThis.addEventListener = () => {};
4
+ import { n as version, t as name } from "./deno-D682wzlW.mjs";
5
+ import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature } from "./accept-Dd__NiUL.mjs";
6
+ import { o as validateCryptoKey, r as fetchKeyDetailed } from "./key-vL60OvqM.mjs";
9
7
  import { CryptographicKey } from "@fedify/vocab";
8
+ import { SpanStatusCode, trace } from "@opentelemetry/api";
10
9
  import { FetchError } from "@fedify/vocab-runtime";
11
10
  import { getLogger } from "@logtape/logtape";
12
- import { SpanStatusCode, trace } from "@opentelemetry/api";
13
11
  import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } from "@opentelemetry/semantic-conventions";
14
12
  import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
15
13
  import { encodeHex } from "byte-encodings/hex";
16
14
  import { Item, decodeDict, encodeItem } from "structured-field-values";
17
-
18
15
  //#region src/sig/http.ts
19
16
  const DEFAULT_MAX_REDIRECTION = 20;
20
17
  /**
@@ -28,9 +25,7 @@ const DEFAULT_MAX_REDIRECTION = 20;
28
25
  */
29
26
  async function signRequest(request, privateKey, keyId, options = {}) {
30
27
  validateCryptoKey(privateKey, "private");
31
- const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
32
- const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
33
- return await tracer.startActiveSpan("http_signatures.sign", async (span) => {
28
+ return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("http_signatures.sign", async (span) => {
34
29
  try {
35
30
  const spec = options.spec ?? "draft-cavage-http-signatures-12";
36
31
  let signed;
@@ -138,9 +133,7 @@ const derivedComponents = {
138
133
  * @returns The formatted signature string.
139
134
  */
140
135
  function formatRfc9421Signature(signature, components, parameters, label = "sig1") {
141
- const signatureInputValue = `${label}=(${components.map((c) => formatComponentId(c)).join(" ")});${parameters}`;
142
- const signatureValue = `${label}=:${encodeBase64(signature)}:`;
143
- return [signatureInputValue, signatureValue];
136
+ return [`${label}=(${components.map((c) => formatComponentId(c)).join(" ")});${parameters}`, `${label}=:${encodeBase64(signature)}:`];
144
137
  }
145
138
  /**
146
139
  * Parse RFC 9421 Signature-Input header.
@@ -246,12 +239,11 @@ async function signRequestRfc9421(request, privateKey, keyId, span, currentTime,
246
239
  value: "content-digest",
247
240
  params: {}
248
241
  }] : []];
249
- const expires = rfc9421Options?.expires === true ? (currentTime.epochMilliseconds / 1e3 | 0) + 3600 : void 0;
250
242
  const signatureParams = formatRfc9421SignatureParameters({
251
243
  algorithm: "rsa-v1_5-sha256",
252
244
  keyId,
253
245
  created,
254
- expires,
246
+ expires: rfc9421Options?.expires === true ? (currentTime.epochMilliseconds / 1e3 | 0) + 3600 : void 0,
255
247
  nonce: rfc9421Options?.nonce,
256
248
  tag: rfc9421Options?.tag
257
249
  });
@@ -361,9 +353,7 @@ async function verifyRequest(request, options = {}) {
361
353
  * @since 2.1.0
362
354
  */
363
355
  async function verifyRequestDetailed(request, options = {}) {
364
- const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
365
- const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
366
- return await tracer.startActiveSpan("http_signatures.verify", async (span) => {
356
+ return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("http_signatures.verify", async (span) => {
367
357
  if (span.isRecording()) {
368
358
  span.setAttribute(ATTR_HTTP_REQUEST_METHOD, request.method);
369
359
  span.setAttribute(ATTR_URL_FULL, request.url);
@@ -558,8 +548,7 @@ async function verifyRequestDraft(request, span, { documentLoader, contextLoader
558
548
  const message = headerNames.map((name) => `${name}: ` + (name === "(request-target)" ? `${request.method.toLowerCase()} ${new URL(request.url).pathname}` : name === "(created)" ? sigValues.created ?? "" : name === "(expires)" ? sigValues.expires ?? "" : name === "host" ? request.headers.get("host") ?? new URL(request.url).host : request.headers.get(name))).join("\n");
559
549
  const sig = decodeBase64(signature);
560
550
  span?.setAttribute("http_signatures.signature", encodeHex(sig));
561
- const verified = await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key.publicKey, sig, new TextEncoder().encode(message));
562
- if (!verified) {
551
+ if (!await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key.publicKey, sig, new TextEncoder().encode(message))) {
563
552
  if (cached) {
564
553
  logger.debug("Failed to verify with the cached key {keyId}; signature {signature} is invalid. Retrying with the freshly fetched key...", {
565
554
  keyId,
@@ -573,7 +562,7 @@ async function verifyRequestDraft(request, span, { documentLoader, contextLoader
573
562
  currentTime,
574
563
  keyCache: {
575
564
  get: () => Promise.resolve(void 0),
576
- set: async (keyId$1, key$1) => await keyCache?.set(keyId$1, key$1)
565
+ set: async (keyId, key) => await keyCache?.set(keyId, key)
577
566
  }
578
567
  });
579
568
  }
@@ -735,9 +724,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
735
724
  failure = invalidSignatureResult(keyId);
736
725
  continue;
737
726
  }
738
- const body = await request.arrayBuffer();
739
- const digestValid = await verifyRfc9421ContentDigest(contentDigestHeader, body);
740
- if (!digestValid) {
727
+ if (!await verifyRfc9421ContentDigest(contentDigestHeader, await request.arrayBuffer())) {
741
728
  logger.debug("Failed to verify; Content-Digest verification failed.", { contentDigest: contentDigestHeader });
742
729
  failure = invalidSignatureResult(keyId);
743
730
  continue;
@@ -795,8 +782,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
795
782
  const signatureBaseBytes = new TextEncoder().encode(signatureBase);
796
783
  span?.setAttribute("http_signatures.signature", encodeHex(sigBytes));
797
784
  try {
798
- const verified = await crypto.subtle.verify(algorithm, key.publicKey, sigBytes.slice(), signatureBaseBytes);
799
- if (verified) return {
785
+ if (await crypto.subtle.verify(algorithm, key.publicKey, sigBytes.slice(), signatureBaseBytes)) return {
800
786
  verified: true,
801
787
  key,
802
788
  signatureLabel: sigName
@@ -810,7 +796,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
810
796
  currentTime,
811
797
  keyCache: {
812
798
  get: () => Promise.resolve(void 0),
813
- set: async (keyId$1, key$1) => await keyCache?.set(keyId$1, key$1)
799
+ set: async (keyId, key) => await keyCache?.set(keyId, key)
814
800
  },
815
801
  spec: "rfc9421"
816
802
  });
@@ -888,8 +874,7 @@ async function doubleKnockInternal(request, identity, options, redirected = 0, v
888
874
  });
889
875
  if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
890
876
  if (redirected >= maximumRedirection) throw new FetchError(request.url, `Too many redirections (${redirected + 1})`);
891
- const location = response.headers.get("Location");
892
- const redirectRequest = createRedirectRequest(request, location, body);
877
+ const redirectRequest = createRedirectRequest(request, response.headers.get("Location"), body);
893
878
  if (visited.has(redirectRequest.url)) throw new FetchError(request.url, `Redirect loop detected: ${redirectRequest.url}`);
894
879
  return doubleKnockInternal(redirectRequest, identity, {
895
880
  ...options,
@@ -937,13 +922,10 @@ async function doubleKnockInternal(request, identity, options, redirected = 0, v
937
922
  redirect: "manual",
938
923
  signal
939
924
  });
940
- if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
941
- const location = response.headers.get("Location");
942
- return doubleKnock(createRedirectRequest(request, location, body), identity, {
943
- ...options,
944
- body
945
- });
946
- }
925
+ if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) return doubleKnock(createRedirectRequest(request, response.headers.get("Location"), body), identity, {
926
+ ...options,
927
+ body
928
+ });
947
929
  }
948
930
  if (fulfilled && response.status < 300) {
949
931
  await specDeterminer?.rememberSpec(origin, "rfc9421");
@@ -970,8 +952,7 @@ async function doubleKnockInternal(request, identity, options, redirected = 0, v
970
952
  });
971
953
  if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
972
954
  if (redirected >= maximumRedirection) throw new FetchError(request.url, `Too many redirections (${redirected + 1})`);
973
- const location = response.headers.get("Location");
974
- const redirectRequest = createRedirectRequest(request, location, body);
955
+ const redirectRequest = createRedirectRequest(request, response.headers.get("Location"), body);
975
956
  if (visited.has(redirectRequest.url)) throw new FetchError(request.url, `Redirect loop detected: ${redirectRequest.url}`);
976
957
  return doubleKnockInternal(redirectRequest, identity, {
977
958
  ...options,
@@ -1008,6 +989,5 @@ function timingSafeEqual(a, b) {
1008
989
  result |= lenA ^ lenB;
1009
990
  return result === 0;
1010
991
  }
1011
-
1012
992
  //#endregion
1013
- export { createRfc9421SignatureBase, doubleKnock, formatRfc9421Signature, formatRfc9421SignatureParameters, parseRfc9421Signature, parseRfc9421SignatureInput, signRequest, timingSafeEqual, verifyRequest, verifyRequestDetailed };
993
+ export { parseRfc9421Signature as a, timingSafeEqual as c, formatRfc9421SignatureParameters as i, verifyRequest as l, doubleKnock as n, parseRfc9421SignatureInput as o, formatRfc9421Signature as r, signRequest as s, createRfc9421SignatureBase as t, verifyRequestDetailed as u };
@@ -3,7 +3,6 @@ import { DocumentLoader } from "@fedify/vocab-runtime";
3
3
  import { TracerProvider } from "@opentelemetry/api";
4
4
 
5
5
  //#region src/sig/key.d.ts
6
-
7
6
  /**
8
7
  * Generates a key pair which is appropriate for Fedify.
9
8
  * @param algorithm The algorithm to use. Currently only RSASSA-PKCS1-v1_5 and
@@ -536,9 +535,5 @@ interface HttpMessageSignaturesSpecDeterminer {
536
535
  */
537
536
  rememberSpec(origin: string, spec: HttpMessageSignaturesSpec): void | Promise<void>;
538
537
  }
539
- /**
540
- * The options for double-knock requests.
541
- * @since 1.6.0
542
- */
543
538
  //#endregion
544
- 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 };
539
+ export { exportJwk as C, importJwk as D, generateCryptoKeyPair as E, KeyCache as S, fetchKeyDetailed as T, validateAcceptSignature as _, VerifyRequestDetailedResult as a, FetchKeyOptions as b, signRequest as c, AcceptSignatureMember as d, AcceptSignatureParameters as f, parseAcceptSignature as g, fulfillAcceptSignature as h, SignRequestOptions as i, verifyRequest as l, formatAcceptSignature as m, HttpMessageSignaturesSpecDeterminer as n, VerifyRequestFailureReason as o, FulfillAcceptSignatureResult as p, Rfc9421SignRequestOptions as r, VerifyRequestOptions as s, HttpMessageSignaturesSpec as t, verifyRequestDetailed as u, FetchKeyDetailedResult as v, fetchKey as w, FetchKeyResult as x, FetchKeyErrorResult as y };
@@ -1,7 +1,5 @@
1
-
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
-
1
+ import { Temporal } from "@js-temporal/polyfill";
2
+ import "urlpattern-polyfill";
5
3
  import { getLogger } from "@logtape/logtape";
6
4
  import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
7
5
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
@@ -10,124 +8,18 @@ import { Item, decodeDict, encodeDict, encodeItem } from "structured-field-value
10
8
  import { FetchError, getDocumentLoader } from "@fedify/vocab-runtime";
11
9
  import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } from "@opentelemetry/semantic-conventions";
12
10
  import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
13
-
14
11
  //#region deno.json
15
12
  var name = "@fedify/fedify";
16
- var version = "2.2.0-dev.613+cf8cd122";
17
- var license = "MIT";
18
- var exports = {
19
- ".": "./src/mod.ts",
20
- "./compat": "./src/compat/mod.ts",
21
- "./federation": "./src/federation/mod.ts",
22
- "./nodeinfo": "./src/nodeinfo/mod.ts",
23
- "./otel": "./src/otel/mod.ts",
24
- "./runtime": "./src/runtime/mod.ts",
25
- "./sig": "./src/sig/mod.ts",
26
- "./utils": "./src/utils/mod.ts",
27
- "./vocab": "./src/vocab/mod.ts"
28
- };
29
- var imports = {
30
- "@multiformats/base-x": "npm:@multiformats/base-x@^4.0.1",
31
- "@std/assert": "jsr:@std/assert@^0.226.0",
32
- "@std/url": "jsr:@std/url@^0.225.1",
33
- "asn1js": "npm:asn1js@^3.0.7",
34
- "fast-check": "npm:fast-check@^3.22.0",
35
- "fetch-mock": "npm:fetch-mock@^12.5.2",
36
- "json-canon": "npm:json-canon@^1.0.1",
37
- "jsonld": "npm:jsonld@^9.0.0",
38
- "pkijs": "npm:pkijs@^3.3.3",
39
- "structured-field-values": "npm:structured-field-values@^2.0.4",
40
- "uri-template-router": "npm:uri-template-router@^1.0.0",
41
- "url-template": "npm:url-template@^3.1.1"
42
- };
43
- var exclude = [
44
- ".test-report.xml",
45
- "apidoc/",
46
- "dist/",
47
- "node_modules/",
48
- "npm/",
49
- "pnpm-lock.yaml",
50
- "src/cfworkers/dist/",
51
- "src/cfworkers/fixtures/",
52
- "src/cfworkers/imports.ts",
53
- "src/cfworkers/README.md",
54
- "src/cfworkers/server.ts",
55
- "src/cfworkers/server.js",
56
- "src/cfworkers/server.js.map"
57
- ];
58
- var publish = { "exclude": [
59
- "**/*.test.ts",
60
- "src/testing/",
61
- "tsdown.config.ts",
62
- "scripts/",
63
- "wrangler.toml"
64
- ] };
65
- var tasks = {
66
- "codegen": "deno task -f @fedify/vocab compile",
67
- "cache": {
68
- "command": "deno cache src/mod.ts",
69
- "dependencies": ["codegen"]
70
- },
71
- "check": {
72
- "command": "deno fmt --check && deno lint && deno check src/**/*.ts",
73
- "dependencies": ["codegen"]
74
- },
75
- "test": {
76
- "command": "deno test --check --doc --allow-read --allow-write --allow-env --unstable-kv --trace-leaks --parallel",
77
- "dependencies": ["codegen"]
78
- },
79
- "coverage": "deno task test --clean --coverage && deno coverage --html coverage",
80
- "bench": {
81
- "command": "deno bench --allow-read --allow-write --allow-net --allow-env --allow-run --unstable-kv",
82
- "dependencies": ["codegen"]
83
- },
84
- "apidoc": {
85
- "command": "deno doc --html --name=Fedify --output=apidoc/ src/mod.ts",
86
- "dependencies": ["codegen"]
87
- },
88
- "publish": {
89
- "command": "deno publish",
90
- "dependencies": ["codegen"]
91
- },
92
- "pnpm:install": "pnpm install --silent",
93
- "pnpm:build": {
94
- "command": "pnpm exec tsdown",
95
- "dependencies": ["pnpm:build-vocab"]
96
- },
97
- "test:node": {
98
- "command": "cd dist/ && node --test",
99
- "dependencies": ["pnpm:build"]
100
- },
101
- "test:bun": {
102
- "command": "cd dist/ && bun test --timeout 60000",
103
- "dependencies": ["pnpm:build"]
104
- },
105
- "test:cfworkers": {
106
- "command": "pnpm exec wrangler deploy --dry-run --outdir src/cfworkers && node --import=tsx src/cfworkers/client.ts",
107
- "dependencies": ["pnpm:build"]
108
- },
109
- "test-all": { "dependencies": [
110
- "check",
111
- "test",
112
- "test:node",
113
- "test:bun",
114
- "test:cfworkers"
115
- ] }
116
- };
117
- var deno_default = {
118
- name,
119
- version,
120
- license,
121
- exports,
122
- imports,
123
- exclude,
124
- publish,
125
- tasks
126
- };
127
-
13
+ var version = "2.2.0-dev.622+e54cb037";
128
14
  //#endregion
129
15
  //#region src/sig/accept.ts
130
16
  /**
17
+ * `Accept-Signature` header parsing, serialization, and validation utilities
18
+ * for RFC 9421 §5 challenge-response negotiation.
19
+ *
20
+ * @module
21
+ */
22
+ /**
131
23
  * Parses an `Accept-Signature` header value (RFC 9421 §5.1) into an
132
24
  * array of {@link AcceptSignatureMember} objects.
133
25
  *
@@ -258,7 +150,6 @@ function fulfillAcceptSignature(entry, localKeyId, localAlg) {
258
150
  expires: entry.parameters.expires
259
151
  };
260
152
  }
261
-
262
153
  //#endregion
263
154
  //#region src/sig/key.ts
264
155
  /**
@@ -274,8 +165,7 @@ function validateCryptoKey(key, type) {
274
165
  if (!key.extractable) throw new TypeError("The key is not extractable.");
275
166
  if (key.algorithm.name !== "RSASSA-PKCS1-v1_5" && key.algorithm.name !== "Ed25519") throw new TypeError("Currently only RSASSA-PKCS1-v1_5 and Ed25519 keys are supported. More algorithms will be added in the future!");
276
167
  if (key.algorithm.name === "RSASSA-PKCS1-v1_5") {
277
- const algorithm = key.algorithm;
278
- if (algorithm.hash.name !== "SHA-256") throw new TypeError("For compatibility with the existing Fediverse software (e.g., Mastodon), hash algorithm for RSASSA-PKCS1-v1_5 keys must be SHA-256.");
168
+ if (key.algorithm.hash.name !== "SHA-256") throw new TypeError("For compatibility with the existing Fediverse software (e.g., Mastodon), hash algorithm for RSASSA-PKCS1-v1_5 keys must be SHA-256.");
279
169
  }
280
170
  }
281
171
  /**
@@ -342,8 +232,7 @@ async function importJwk(jwk, type) {
342
232
  }
343
233
  async function withFetchKeySpan(keyId, tracerProvider, fetcher) {
344
234
  tracerProvider ??= trace.getTracerProvider();
345
- const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
346
- return await tracer.startActiveSpan("activitypub.fetch_key", {
235
+ return await tracerProvider.getTracer(name, version).startActiveSpan("activitypub.fetch_key", {
347
236
  kind: SpanKind.CLIENT,
348
237
  attributes: {
349
238
  "http.method": "GET",
@@ -404,41 +293,41 @@ function fetchKey(keyId, cls, options = {}) {
404
293
  async function fetchKeyDetailed(keyId, cls, options = {}) {
405
294
  const cacheKey = typeof keyId === "string" ? new URL(keyId) : keyId;
406
295
  return await withFetchKeySpan(cacheKey, options.tracerProvider, async () => {
407
- return await fetchKeyWithResult(cacheKey, cls, options, async (cacheKey$1, keyId$1, keyCache, logger) => {
408
- const fetchError = await keyCache?.getFetchError?.(cacheKey$1);
296
+ return await fetchKeyWithResult(cacheKey, cls, options, async (cacheKey, keyId, keyCache, logger) => {
297
+ const fetchError = await keyCache?.getFetchError?.(cacheKey);
409
298
  if (fetchError != null) {
410
- logger.debug("Entry {keyId} found in cache with preserved fetch failure details.", { keyId: keyId$1 });
299
+ logger.debug("Entry {keyId} found in cache with preserved fetch failure details.", { keyId });
411
300
  return {
412
301
  key: null,
413
302
  cached: true,
414
303
  fetchError
415
304
  };
416
305
  }
417
- logger.debug("Entry {keyId} found in cache, but no fetch failure details are available.", { keyId: keyId$1 });
306
+ logger.debug("Entry {keyId} found in cache, but no fetch failure details are available.", { keyId });
418
307
  return {
419
308
  key: null,
420
309
  cached: true
421
310
  };
422
- }, async (error, cacheKey$1, keyId$1, keyCache, logger) => {
311
+ }, async (error, cacheKey, keyId, keyCache, logger) => {
423
312
  logger.debug("Failed to fetch key {keyId}.", {
424
- keyId: keyId$1,
313
+ keyId,
425
314
  error
426
315
  });
427
- await keyCache?.set(cacheKey$1, null);
316
+ await keyCache?.set(cacheKey, null);
428
317
  if (error instanceof FetchError && error.response != null) {
429
- const fetchError$1 = {
318
+ const fetchError = {
430
319
  status: error.response.status,
431
320
  response: error.response.clone()
432
321
  };
433
- await keyCache?.setFetchError?.(cacheKey$1, fetchError$1);
322
+ await keyCache?.setFetchError?.(cacheKey, fetchError);
434
323
  return {
435
324
  key: null,
436
325
  cached: false,
437
- fetchError: fetchError$1
326
+ fetchError
438
327
  };
439
328
  }
440
329
  const fetchError = { error: error instanceof Error ? error : new Error(String(error)) };
441
- await keyCache?.setFetchError?.(cacheKey$1, fetchError);
330
+ await keyCache?.setFetchError?.(cacheKey, fetchError);
442
331
  return {
443
332
  key: null,
444
333
  cached: false,
@@ -484,8 +373,8 @@ async function resolveFetchedKey(document, cacheKey, keyId, cls, { documentLoade
484
373
  contextLoader,
485
374
  tracerProvider
486
375
  });
487
- } catch (e$1) {
488
- if (e$1 instanceof TypeError) {
376
+ } catch (e) {
377
+ if (e instanceof TypeError) {
489
378
  logger.debug("Failed to verify; key {keyId} returned an invalid object.", { keyId });
490
379
  await keyCache?.set(cacheKey, null);
491
380
  await clearFetchErrorMetadata(cacheKey, keyCache);
@@ -494,7 +383,7 @@ async function resolveFetchedKey(document, cacheKey, keyId, cls, { documentLoade
494
383
  cached: false
495
384
  };
496
385
  }
497
- throw e$1;
386
+ throw e;
498
387
  }
499
388
  }
500
389
  let key = null;
@@ -575,38 +464,35 @@ async function fetchKeyWithResult(cacheKey, cls, options, onCachedUnavailable, o
575
464
  logger.debug("Fetching key {keyId} to verify signature...", { keyId });
576
465
  let document;
577
466
  try {
578
- const remoteDocument = await (options.documentLoader ?? getDocumentLoader())(keyId);
579
- document = remoteDocument.document;
467
+ document = (await (options.documentLoader ?? getDocumentLoader())(keyId)).document;
580
468
  } catch (error) {
581
469
  return await onFetchError(error, cacheKey, keyId, keyCache, logger);
582
470
  }
583
471
  return await resolveFetchedKey(document, cacheKey, keyId, cls, options, logger);
584
472
  }
585
473
  async function fetchKeyInternal(keyId, cls, options = {}) {
586
- const cacheKey = typeof keyId === "string" ? new URL(keyId) : keyId;
587
- return await fetchKeyWithResult(cacheKey, cls, options, (_cacheKey, _keyId, _keyCache, _logger) => {
474
+ return await fetchKeyWithResult(typeof keyId === "string" ? new URL(keyId) : keyId, cls, options, (_cacheKey, _keyId, _keyCache, _logger) => {
588
475
  return {
589
476
  key: null,
590
477
  cached: true
591
478
  };
592
- }, async (error, cacheKey$1, keyId$1, keyCache, logger) => {
479
+ }, async (error, cacheKey, keyId, keyCache, logger) => {
593
480
  logger.debug("Failed to fetch key {keyId}.", {
594
- keyId: keyId$1,
481
+ keyId,
595
482
  error
596
483
  });
597
- await keyCache?.set(cacheKey$1, null);
598
- if (error instanceof FetchError && error.response != null) await keyCache?.setFetchError?.(cacheKey$1, {
484
+ await keyCache?.set(cacheKey, null);
485
+ if (error instanceof FetchError && error.response != null) await keyCache?.setFetchError?.(cacheKey, {
599
486
  status: error.response.status,
600
487
  response: error.response.clone()
601
488
  });
602
- else await keyCache?.setFetchError?.(cacheKey$1, { error: error instanceof Error ? error : new Error(String(error)) });
489
+ else await keyCache?.setFetchError?.(cacheKey, { error: error instanceof Error ? error : new Error(String(error)) });
603
490
  return {
604
491
  key: null,
605
492
  cached: false
606
493
  };
607
494
  });
608
495
  }
609
-
610
496
  //#endregion
611
497
  //#region src/sig/http.ts
612
498
  const DEFAULT_MAX_REDIRECTION = 20;
@@ -621,9 +507,7 @@ const DEFAULT_MAX_REDIRECTION = 20;
621
507
  */
622
508
  async function signRequest(request, privateKey, keyId, options = {}) {
623
509
  validateCryptoKey(privateKey, "private");
624
- const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
625
- const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
626
- return await tracer.startActiveSpan("http_signatures.sign", async (span) => {
510
+ return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("http_signatures.sign", async (span) => {
627
511
  try {
628
512
  const spec = options.spec ?? "draft-cavage-http-signatures-12";
629
513
  let signed;
@@ -632,7 +516,7 @@ async function signRequest(request, privateKey, keyId, options = {}) {
632
516
  if (span.isRecording()) {
633
517
  span.setAttribute(ATTR_HTTP_REQUEST_METHOD, signed.method);
634
518
  span.setAttribute(ATTR_URL_FULL, signed.url);
635
- for (const [name$1, value] of signed.headers) span.setAttribute(ATTR_HTTP_REQUEST_HEADER(name$1), value);
519
+ for (const [name, value] of signed.headers) span.setAttribute(ATTR_HTTP_REQUEST_HEADER(name), value);
636
520
  span.setAttribute("http_signatures.key_id", keyId.href);
637
521
  }
638
522
  return signed;
@@ -660,8 +544,8 @@ async function signRequestDraft(request, privateKey, keyId, span, currentTime, b
660
544
  }
661
545
  if (!headers.has("Date")) headers.set("Date", currentTime == null ? (/* @__PURE__ */ new Date()).toUTCString() : new Date(currentTime.toString()).toUTCString());
662
546
  const serialized = [["(request-target)", `${request.method.toLowerCase()} ${url.pathname}`], ...headers];
663
- const headerNames = serialized.map(([name$1]) => name$1);
664
- const message = serialized.map(([name$1, value]) => `${name$1}: ${value.trim()}`).join("\n");
547
+ const headerNames = serialized.map(([name]) => name);
548
+ const message = serialized.map(([name, value]) => `${name}: ${value.trim()}`).join("\n");
665
549
  const signature = await crypto.subtle.sign("RSASSA-PKCS1-v1_5", privateKey, new TextEncoder().encode(message));
666
550
  const sigHeader = `keyId="${keyId.href}",algorithm="rsa-sha256",headers="${headerNames.join(" ")}",signature="${encodeBase64(signature)}"`;
667
551
  headers.set("Signature", sigHeader);
@@ -731,9 +615,7 @@ const derivedComponents = {
731
615
  * @returns The formatted signature string.
732
616
  */
733
617
  function formatRfc9421Signature(signature, components, parameters, label = "sig1") {
734
- const signatureInputValue = `${label}=(${components.map((c) => formatComponentId(c)).join(" ")});${parameters}`;
735
- const signatureValue = `${label}=:${encodeBase64(signature)}:`;
736
- return [signatureInputValue, signatureValue];
618
+ return [`${label}=(${components.map((c) => formatComponentId(c)).join(" ")});${parameters}`, `${label}=:${encodeBase64(signature)}:`];
737
619
  }
738
620
  /**
739
621
  * Parse RFC 9421 Signature-Input header.
@@ -839,12 +721,11 @@ async function signRequestRfc9421(request, privateKey, keyId, span, currentTime,
839
721
  value: "content-digest",
840
722
  params: {}
841
723
  }] : []];
842
- const expires = rfc9421Options?.expires === true ? (currentTime.epochMilliseconds / 1e3 | 0) + 3600 : void 0;
843
724
  const signatureParams = formatRfc9421SignatureParameters({
844
725
  algorithm: "rsa-v1_5-sha256",
845
726
  keyId,
846
727
  created,
847
- expires,
728
+ expires: rfc9421Options?.expires === true ? (currentTime.epochMilliseconds / 1e3 | 0) + 3600 : void 0,
848
729
  nonce: rfc9421Options?.nonce,
849
730
  tag: rfc9421Options?.tag
850
731
  });
@@ -954,13 +835,11 @@ async function verifyRequest(request, options = {}) {
954
835
  * @since 2.1.0
955
836
  */
956
837
  async function verifyRequestDetailed(request, options = {}) {
957
- const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
958
- const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
959
- return await tracer.startActiveSpan("http_signatures.verify", async (span) => {
838
+ return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("http_signatures.verify", async (span) => {
960
839
  if (span.isRecording()) {
961
840
  span.setAttribute(ATTR_HTTP_REQUEST_METHOD, request.method);
962
841
  span.setAttribute(ATTR_URL_FULL, request.url);
963
- for (const [name$1, value] of request.headers) span.setAttribute(ATTR_HTTP_REQUEST_HEADER(name$1), value);
842
+ for (const [name, value] of request.headers) span.setAttribute(ATTR_HTTP_REQUEST_HEADER(name), value);
964
843
  }
965
844
  try {
966
845
  let spec = options.spec;
@@ -1148,11 +1027,10 @@ async function verifyRequestDraft(request, span, { documentLoader, contextLoader
1148
1027
  logger.debug("Failed to verify; required headers missing in the Signature header: {headers}.", { headers });
1149
1028
  return invalidSignatureResult(keyIdUrl);
1150
1029
  }
1151
- const message = headerNames.map((name$1) => `${name$1}: ` + (name$1 === "(request-target)" ? `${request.method.toLowerCase()} ${new URL(request.url).pathname}` : name$1 === "(created)" ? sigValues.created ?? "" : name$1 === "(expires)" ? sigValues.expires ?? "" : name$1 === "host" ? request.headers.get("host") ?? new URL(request.url).host : request.headers.get(name$1))).join("\n");
1030
+ const message = headerNames.map((name) => `${name}: ` + (name === "(request-target)" ? `${request.method.toLowerCase()} ${new URL(request.url).pathname}` : name === "(created)" ? sigValues.created ?? "" : name === "(expires)" ? sigValues.expires ?? "" : name === "host" ? request.headers.get("host") ?? new URL(request.url).host : request.headers.get(name))).join("\n");
1152
1031
  const sig = decodeBase64(signature);
1153
1032
  span?.setAttribute("http_signatures.signature", encodeHex(sig));
1154
- const verified = await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key.publicKey, sig, new TextEncoder().encode(message));
1155
- if (!verified) {
1033
+ if (!await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key.publicKey, sig, new TextEncoder().encode(message))) {
1156
1034
  if (cached) {
1157
1035
  logger.debug("Failed to verify with the cached key {keyId}; signature {signature} is invalid. Retrying with the freshly fetched key...", {
1158
1036
  keyId,
@@ -1166,7 +1044,7 @@ async function verifyRequestDraft(request, span, { documentLoader, contextLoader
1166
1044
  currentTime,
1167
1045
  keyCache: {
1168
1046
  get: () => Promise.resolve(void 0),
1169
- set: async (keyId$1, key$1) => await keyCache?.set(keyId$1, key$1)
1047
+ set: async (keyId, key) => await keyCache?.set(keyId, key)
1170
1048
  }
1171
1049
  });
1172
1050
  }
@@ -1328,9 +1206,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
1328
1206
  failure = invalidSignatureResult(keyId);
1329
1207
  continue;
1330
1208
  }
1331
- const body = await request.arrayBuffer();
1332
- const digestValid = await verifyRfc9421ContentDigest(contentDigestHeader, body);
1333
- if (!digestValid) {
1209
+ if (!await verifyRfc9421ContentDigest(contentDigestHeader, await request.arrayBuffer())) {
1334
1210
  logger.debug("Failed to verify; Content-Digest verification failed.", { contentDigest: contentDigestHeader });
1335
1211
  failure = invalidSignatureResult(keyId);
1336
1212
  continue;
@@ -1388,8 +1264,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
1388
1264
  const signatureBaseBytes = new TextEncoder().encode(signatureBase);
1389
1265
  span?.setAttribute("http_signatures.signature", encodeHex(sigBytes));
1390
1266
  try {
1391
- const verified = await crypto.subtle.verify(algorithm, key.publicKey, sigBytes.slice(), signatureBaseBytes);
1392
- if (verified) return {
1267
+ if (await crypto.subtle.verify(algorithm, key.publicKey, sigBytes.slice(), signatureBaseBytes)) return {
1393
1268
  verified: true,
1394
1269
  key,
1395
1270
  signatureLabel: sigName
@@ -1403,7 +1278,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
1403
1278
  currentTime,
1404
1279
  keyCache: {
1405
1280
  get: () => Promise.resolve(void 0),
1406
- set: async (keyId$1, key$1) => await keyCache?.set(keyId$1, key$1)
1281
+ set: async (keyId, key) => await keyCache?.set(keyId, key)
1407
1282
  },
1408
1283
  spec: "rfc9421"
1409
1284
  });
@@ -1481,8 +1356,7 @@ async function doubleKnockInternal(request, identity, options, redirected = 0, v
1481
1356
  });
1482
1357
  if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
1483
1358
  if (redirected >= maximumRedirection) throw new FetchError(request.url, `Too many redirections (${redirected + 1})`);
1484
- const location = response.headers.get("Location");
1485
- const redirectRequest = createRedirectRequest(request, location, body);
1359
+ const redirectRequest = createRedirectRequest(request, response.headers.get("Location"), body);
1486
1360
  if (visited.has(redirectRequest.url)) throw new FetchError(request.url, `Redirect loop detected: ${redirectRequest.url}`);
1487
1361
  return doubleKnockInternal(redirectRequest, identity, {
1488
1362
  ...options,
@@ -1530,13 +1404,10 @@ async function doubleKnockInternal(request, identity, options, redirected = 0, v
1530
1404
  redirect: "manual",
1531
1405
  signal
1532
1406
  });
1533
- if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
1534
- const location = response.headers.get("Location");
1535
- return doubleKnock(createRedirectRequest(request, location, body), identity, {
1536
- ...options,
1537
- body
1538
- });
1539
- }
1407
+ if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) return doubleKnock(createRedirectRequest(request, response.headers.get("Location"), body), identity, {
1408
+ ...options,
1409
+ body
1410
+ });
1540
1411
  }
1541
1412
  if (fulfilled && response.status < 300) {
1542
1413
  await specDeterminer?.rememberSpec(origin, "rfc9421");
@@ -1563,8 +1434,7 @@ async function doubleKnockInternal(request, identity, options, redirected = 0, v
1563
1434
  });
1564
1435
  if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
1565
1436
  if (redirected >= maximumRedirection) throw new FetchError(request.url, `Too many redirections (${redirected + 1})`);
1566
- const location = response.headers.get("Location");
1567
- const redirectRequest = createRedirectRequest(request, location, body);
1437
+ const redirectRequest = createRedirectRequest(request, response.headers.get("Location"), body);
1568
1438
  if (visited.has(redirectRequest.url)) throw new FetchError(request.url, `Redirect loop detected: ${redirectRequest.url}`);
1569
1439
  return doubleKnockInternal(redirectRequest, identity, {
1570
1440
  ...options,
@@ -1601,6 +1471,5 @@ function timingSafeEqual(a, b) {
1601
1471
  result |= lenA ^ lenB;
1602
1472
  return result === 0;
1603
1473
  }
1604
-
1605
1474
  //#endregion
1606
- export { deno_default, doubleKnock, exportJwk, fetchKey, fetchKeyDetailed, formatAcceptSignature, fulfillAcceptSignature, generateCryptoKeyPair, importJwk, parseAcceptSignature, parseRfc9421SignatureInput, signRequest, validateAcceptSignature, validateCryptoKey, verifyRequest, verifyRequestDetailed };
1475
+ export { version as _, verifyRequestDetailed as a, fetchKeyDetailed as c, validateCryptoKey as d, formatAcceptSignature as f, name as g, validateAcceptSignature as h, verifyRequest as i, generateCryptoKeyPair as l, parseAcceptSignature as m, parseRfc9421SignatureInput as n, exportJwk as o, fulfillAcceptSignature as p, signRequest as r, fetchKey as s, doubleKnock as t, importJwk as u };