@fedify/fedify 2.0.8 → 2.0.10

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 (203) hide show
  1. package/dist/{assert-MZs1qjMx.js → assert-ddO5KLpe.mjs} +5 -9
  2. package/dist/{assert_equals-DSbWqCm3.js → assert_equals-Ew3jOFa3.mjs} +55 -69
  3. package/dist/{assert_instance_of-DHz7EHNU.js → assert_instance_of-C4Ri6VuN.mjs} +5 -9
  4. package/dist/{assert_not_equals-C80BG-_5.js → assert_not_equals--wG9hV7u.mjs} +6 -13
  5. package/dist/{assert_rejects-Ce45JcFg.js → assert_rejects-B-qJtC9Z.mjs} +6 -11
  6. package/dist/{assert_throws-BNXdRGWP.js → assert_throws-4NwKEy2q.mjs} +5 -10
  7. package/dist/{builder-B5cKln9v.js → builder-opzCVeXZ.mjs} +32 -41
  8. package/dist/{chunk-CGaQZ11T.cjs → chunk-DDcVe30Y.cjs} +23 -24
  9. package/dist/{chunk-DJNbSFdH.js → chunk-nlSIicah.js} +8 -8
  10. package/dist/{client-CoCIaTNO.js → client-A1UrnX6I.mjs} +9 -13
  11. package/dist/{client-BxMZiQaD.d.ts → client-AtlibPOU.d.ts} +1 -1
  12. package/dist/{client-C97KOq3x.d.cts → client-z-8dc-e1.d.cts} +1 -1
  13. package/dist/{collection-CcnIw1qY.js → collection-ChgDTHLz.mjs} +7 -12
  14. package/dist/compat/mod.cjs +5 -8
  15. package/dist/compat/mod.d.cts +78 -6
  16. package/dist/compat/mod.d.ts +78 -6
  17. package/dist/compat/mod.js +4 -8
  18. package/dist/compat/transformers.test.mjs +62 -0
  19. package/dist/{context-D3QkEtZd.d.cts → context-CNIt-Qn7.d.cts} +9 -18
  20. package/dist/{context-DZJhUmzF.d.ts → context-Dyg7P1qW.d.ts} +9 -18
  21. package/dist/{context-pa9aIrwp.js → context-Juj6bdHC.mjs} +7 -11
  22. package/dist/deno-CrjRl2cm.mjs +8 -0
  23. package/dist/{docloader-CBHh0rC5.js → docloader-35wi0JO1.mjs} +8 -14
  24. package/dist/{esm-nLm00z9V.js → esm-DVILvP5e.mjs} +50 -89
  25. package/dist/federation/builder.test.d.mts +2 -0
  26. package/dist/federation/{builder.test.js → builder.test.mjs} +19 -38
  27. package/dist/federation/collection.test.d.mts +2 -0
  28. package/dist/federation/collection.test.mjs +21 -0
  29. package/dist/federation/handler.test.d.mts +2 -0
  30. package/dist/federation/{handler.test.js → handler.test.mjs} +26 -56
  31. package/dist/federation/idempotency.test.d.mts +2 -0
  32. package/dist/federation/{idempotency.test.js → idempotency.test.mjs} +31 -62
  33. package/dist/federation/inbox.test.d.mts +2 -0
  34. package/dist/federation/{inbox.test.js → inbox.test.mjs} +8 -12
  35. package/dist/federation/keycache.test.d.mts +2 -0
  36. package/dist/federation/{keycache.test.js → keycache.test.mjs} +11 -15
  37. package/dist/federation/kv.test.d.mts +2 -0
  38. package/dist/federation/{kv.test.js → kv.test.mjs} +11 -22
  39. package/dist/federation/middleware.test.d.mts +2 -0
  40. package/dist/federation/{middleware.test.js → middleware.test.mjs} +146 -225
  41. package/dist/federation/mod.cjs +327 -16
  42. package/dist/federation/mod.d.cts +3 -6
  43. package/dist/federation/mod.d.ts +3 -6
  44. package/dist/federation/mod.js +322 -13
  45. package/dist/federation/mq.test.d.mts +2 -0
  46. package/dist/federation/{mq.test.js → mq.test.mjs} +21 -35
  47. package/dist/federation/negotiation.test.d.mts +2 -0
  48. package/dist/federation/{negotiation.test.js → negotiation.test.mjs} +9 -16
  49. package/dist/federation/retry.test.d.mts +2 -0
  50. package/dist/federation/{retry.test.js → retry.test.mjs} +8 -11
  51. package/dist/federation/router.test.d.mts +2 -0
  52. package/dist/federation/{router.test.js → router.test.mjs} +11 -16
  53. package/dist/federation/send.test.d.mts +2 -0
  54. package/dist/federation/{send.test.js → send.test.mjs} +22 -29
  55. package/dist/federation/webfinger.test.d.mts +2 -0
  56. package/dist/federation/{webfinger.test.js → webfinger.test.mjs} +22 -55
  57. package/dist/{http-DkHdFfrc.d.ts → http-B2wiNmSo.d.ts} +1 -6
  58. package/dist/{http-C_RwU_oN.js → http-BGjkvEDc.js} +25 -156
  59. package/dist/{http-Cz3MlXAZ.d.cts → http-C_tEAiZj.d.cts} +1 -6
  60. package/dist/{http-DGs_78tx.cjs → http-DLnqzOtY.cjs} +110 -235
  61. package/dist/{http-Br3-1dRf.js → http-VQAKycaZ.mjs} +17 -33
  62. package/dist/{inbox-3bZUqDLE.js → inbox-B6DfJ3h9.mjs} +18 -26
  63. package/dist/{key-D7Y_J9kt.js → key-C9oV7wk8.mjs} +12 -19
  64. package/dist/{keycache-BASM0rrX.js → keycache-DaQ3ndaJ.mjs} +5 -9
  65. package/dist/{keys-ZbcByPg9.js → keys-CtZLJq76.mjs} +5 -9
  66. package/dist/{kv-QzKcOQgP.js → kv-BrZHNugx.mjs} +6 -10
  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-9PANi4tA.cjs → kv-cache-BAEaVRvi.cjs} +27 -34
  70. package/dist/{kv-cache-El7We5sy.js → kv-cache-OWmRLHir.mjs} +4 -8
  71. package/dist/{kv-cache-CMM5VJsc.js → kv-cache-QxhhotWv.js} +6 -13
  72. package/dist/{ld-Bjq9Z4St.js → ld-BfEccFSP.mjs} +17 -31
  73. package/dist/{middleware-Bj30TZll.js → middleware-Bc4sY_YW.js} +320 -363
  74. package/dist/middleware-CGkdTPmX.mjs +5 -0
  75. package/dist/{middleware-CQeA5yF7.cjs → middleware-Dj7uT9F8.cjs} +513 -564
  76. package/dist/middleware-DuFvBMT2.cjs +4 -0
  77. package/dist/{middleware-DozhKfB6.js → middleware-ReZIkikn.mjs} +260 -292
  78. package/dist/{mod-DPkRU3EK.d.cts → mod-1xhgsHef.d.cts} +2 -2
  79. package/dist/{mod-DUWcVv49.d.ts → mod-BGtYJZKu.d.ts} +2 -2
  80. package/dist/{mod-DXsQakeS.d.cts → mod-Bld7oeqf.d.cts} +3 -3
  81. package/dist/{mod-DnSsduJF.d.ts → mod-BnAKGh2w.d.ts} +2 -2
  82. package/dist/{mod-CwZXZJ9d.d.ts → mod-DTOUyCce.d.ts} +3 -3
  83. package/dist/{mod-Di3W5OdP.d.cts → mod-DWoQffTD.d.cts} +2 -2
  84. package/dist/mod.cjs +29 -68
  85. package/dist/mod.d.cts +11 -14
  86. package/dist/mod.d.ts +11 -15
  87. package/dist/mod.js +17 -65
  88. package/dist/{negotiation-5NPJL6zp.js → negotiation-BehA2uul.mjs} +7 -11
  89. package/dist/nodeinfo/client.test.d.mts +2 -0
  90. package/dist/nodeinfo/{client.test.js → client.test.mjs} +22 -40
  91. package/dist/nodeinfo/handler.test.d.mts +2 -0
  92. package/dist/nodeinfo/{handler.test.js → handler.test.mjs} +13 -42
  93. package/dist/nodeinfo/mod.cjs +5 -8
  94. package/dist/nodeinfo/mod.d.cts +2 -3
  95. package/dist/nodeinfo/mod.d.ts +2 -3
  96. package/dist/nodeinfo/mod.js +4 -8
  97. package/dist/nodeinfo/types.test.d.mts +2 -0
  98. package/dist/nodeinfo/{types.test.js → types.test.mjs} +9 -16
  99. package/dist/otel/exporter.test.d.mts +2 -0
  100. package/dist/otel/{exporter.test.js → exporter.test.mjs} +117 -169
  101. package/dist/otel/mod.cjs +15 -20
  102. package/dist/otel/mod.d.cts +2 -2
  103. package/dist/otel/mod.d.ts +2 -2
  104. package/dist/otel/mod.js +8 -14
  105. package/dist/{owner-gd0Q9FuU.d.ts → owner-74ARJ5TL.d.ts} +1 -1
  106. package/dist/{owner-CImU2dKz.js → owner-CRLqJlP_.mjs} +11 -16
  107. package/dist/{owner-1AbPBOOZ.d.cts → owner-CptqhsOy.d.cts} +1 -1
  108. package/dist/{proof-DLL0MLmV.js → proof-9SGtq4tE.mjs} +21 -33
  109. package/dist/{proof-UhA5do8k.cjs → proof-B4SaJCmK.cjs} +133 -157
  110. package/dist/{proof-BygvN4r5.js → proof-DvQ28mUJ.js} +32 -58
  111. package/dist/{retry-D4GJ670a.js → retry-Ddbq3AcK.mjs} +4 -7
  112. package/dist/{router-D9eI0s4b.js → router-CrMLXoOr.mjs} +4 -8
  113. package/dist/runtime/mod.cjs +11 -13
  114. package/dist/runtime/mod.d.cts +6 -2
  115. package/dist/runtime/mod.d.ts +0 -1
  116. package/dist/runtime/mod.js +4 -7
  117. package/dist/{send-DbW03azY.js → send-DN2ywoe8.mjs} +8 -13
  118. package/dist/sig/http.test.d.mts +2 -0
  119. package/dist/sig/{http.test.js → http.test.mjs} +117 -199
  120. package/dist/sig/key.test.d.mts +2 -0
  121. package/dist/sig/{key.test.js → key.test.mjs} +11 -18
  122. package/dist/sig/ld.test.d.mts +2 -0
  123. package/dist/sig/{ld.test.js → ld.test.mjs} +22 -35
  124. package/dist/sig/mod.cjs +6 -9
  125. package/dist/sig/mod.d.cts +3 -3
  126. package/dist/sig/mod.d.ts +3 -3
  127. package/dist/sig/mod.js +5 -9
  128. package/dist/sig/owner.test.d.mts +2 -0
  129. package/dist/sig/{owner.test.js → owner.test.mjs} +19 -34
  130. package/dist/sig/proof.test.d.mts +2 -0
  131. package/dist/sig/{proof.test.js → proof.test.mjs} +16 -27
  132. package/dist/{std__assert-DWivtrGR.js → std__assert-Duiq_YC9.mjs} +12 -24
  133. package/dist/testing/{mod.d.ts → mod.d.mts} +26 -78
  134. package/dist/testing/mod.mjs +6 -0
  135. package/dist/{transformers-3g8GZwkZ.cjs → transformers-NeAONrAq.cjs} +20 -25
  136. package/dist/{transformers-C3FLHUd6.js → transformers-ve6e2xcg.js} +3 -7
  137. package/dist/{types-CPz01LGH.js → types-C37hquWI.mjs} +4 -7
  138. package/dist/{types-Cd_hszr_.cjs → types-KC4QAoxe.cjs} +29 -34
  139. package/dist/{types-C93Ob9cU.js → types-hvL8ElAs.js} +8 -13
  140. package/dist/utils/docloader.test.d.mts +2 -0
  141. package/dist/utils/{docloader.test.js → docloader.test.mjs} +14 -24
  142. package/dist/utils/kv-cache.test.d.mts +2 -0
  143. package/dist/utils/{kv-cache.test.js → kv-cache.test.mjs} +25 -40
  144. package/dist/utils/mod.cjs +5 -9
  145. package/dist/utils/mod.d.cts +1 -3
  146. package/dist/utils/mod.d.ts +1 -3
  147. package/dist/utils/mod.js +4 -9
  148. package/dist/vocab/cjs.test.d.mts +2 -0
  149. package/dist/vocab/cjs.test.mjs +14 -0
  150. package/dist/vocab/mod.cjs +10 -12
  151. package/dist/vocab/mod.js +3 -5
  152. package/package.json +8 -8
  153. package/dist/compat/transformers.test.d.ts +0 -3
  154. package/dist/compat/transformers.test.js +0 -87
  155. package/dist/compat-Bb4NuTUO.js +0 -4
  156. package/dist/compat-DmDDELst.cjs +0 -4
  157. package/dist/deno-4w047OFk.js +0 -121
  158. package/dist/federation/builder.test.d.ts +0 -3
  159. package/dist/federation/collection.test.d.ts +0 -3
  160. package/dist/federation/collection.test.js +0 -32
  161. package/dist/federation/handler.test.d.ts +0 -3
  162. package/dist/federation/idempotency.test.d.ts +0 -3
  163. package/dist/federation/inbox.test.d.ts +0 -3
  164. package/dist/federation/keycache.test.d.ts +0 -3
  165. package/dist/federation/kv.test.d.ts +0 -3
  166. package/dist/federation/middleware.test.d.ts +0 -3
  167. package/dist/federation/mq.test.d.ts +0 -3
  168. package/dist/federation/negotiation.test.d.ts +0 -3
  169. package/dist/federation/retry.test.d.ts +0 -3
  170. package/dist/federation/router.test.d.ts +0 -3
  171. package/dist/federation/send.test.d.ts +0 -3
  172. package/dist/federation/webfinger.test.d.ts +0 -3
  173. package/dist/federation-Bp3HI26G.cjs +0 -350
  174. package/dist/federation-DaMfqRm4.js +0 -332
  175. package/dist/middleware-B73ZyDmk.js +0 -12
  176. package/dist/middleware-Dr61i4Jo.cjs +0 -12
  177. package/dist/middleware-_1PYruC5.js +0 -26
  178. package/dist/mod-Bh8mqlYw.d.cts +0 -9
  179. package/dist/mod-D6HodEq7.d.ts +0 -7
  180. package/dist/mod-DVwHUI_x.d.cts +0 -80
  181. package/dist/mod-DosD6NsG.d.ts +0 -82
  182. package/dist/mod-gq_Xfdz8.d.cts +0 -1
  183. package/dist/nodeinfo/client.test.d.ts +0 -3
  184. package/dist/nodeinfo/handler.test.d.ts +0 -3
  185. package/dist/nodeinfo/types.test.d.ts +0 -3
  186. package/dist/nodeinfo-DoESQxq5.js +0 -4
  187. package/dist/nodeinfo-DuMYTpbZ.cjs +0 -4
  188. package/dist/otel/exporter.test.d.ts +0 -3
  189. package/dist/runtime-c2Njxsry.cjs +0 -17
  190. package/dist/runtime-poamPCMb.js +0 -13
  191. package/dist/sig/http.test.d.ts +0 -3
  192. package/dist/sig/key.test.d.ts +0 -3
  193. package/dist/sig/ld.test.d.ts +0 -3
  194. package/dist/sig/owner.test.d.ts +0 -3
  195. package/dist/sig/proof.test.d.ts +0 -3
  196. package/dist/sig-BNhspNOf.js +0 -4
  197. package/dist/sig-vX39WyWI.cjs +0 -4
  198. package/dist/testing/mod.js +0 -10
  199. package/dist/utils/docloader.test.d.ts +0 -3
  200. package/dist/utils/kv-cache.test.d.ts +0 -3
  201. package/dist/utils-BQ9KqEK9.cjs +0 -4
  202. package/dist/utils-Dn5OPdSW.js +0 -4
  203. /package/dist/{mod-AGjRfPjT.d.ts → compat/transformers.test.d.mts} +0 -0
@@ -1,50 +1,23 @@
1
-
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
- globalThis.addEventListener = () => {};
5
-
6
- import { assertEquals } from "../assert_equals-DSbWqCm3.js";
7
- import "../assert-MZs1qjMx.js";
8
- import "../assert_instance_of-DHz7EHNU.js";
9
- import { MemoryKvStore } from "../kv-QzKcOQgP.js";
10
- import "../deno-4w047OFk.js";
11
- import { createFederation, handleWebFinger } from "../middleware-DozhKfB6.js";
12
- import "../client-CoCIaTNO.js";
13
- import "../router-D9eI0s4b.js";
14
- import "../types-CPz01LGH.js";
15
- import "../key-D7Y_J9kt.js";
16
- import "../http-Br3-1dRf.js";
17
- import "../ld-Bjq9Z4St.js";
18
- import "../owner-CImU2dKz.js";
19
- import "../proof-DLL0MLmV.js";
20
- import "../docloader-CBHh0rC5.js";
21
- import "../kv-cache-El7We5sy.js";
22
- import "../inbox-3bZUqDLE.js";
23
- import "../builder-B5cKln9v.js";
24
- import "../collection-CcnIw1qY.js";
25
- import "../keycache-BASM0rrX.js";
26
- import "../negotiation-5NPJL6zp.js";
27
- import "../retry-D4GJ670a.js";
28
- import "../send-DbW03azY.js";
29
- import "../std__assert-DWivtrGR.js";
30
- import "../assert_rejects-Ce45JcFg.js";
31
- import "../assert_throws-BNXdRGWP.js";
32
- import "../assert_not_equals-C80BG-_5.js";
33
- import { createRequestContext } from "../context-pa9aIrwp.js";
1
+ import "@js-temporal/polyfill";
2
+ import "urlpattern-polyfill";
3
+ globalThis.addEventListener = () => {};
4
+ import { n as createRequestContext } from "../context-Juj6bdHC.mjs";
5
+ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
+ import "../std__assert-Duiq_YC9.mjs";
7
+ import { t as MemoryKvStore } from "../kv-BrZHNugx.mjs";
8
+ import { a as createFederation, o as handleWebFinger } from "../middleware-ReZIkikn.mjs";
34
9
  import { test } from "@fedify/fixture";
35
10
  import { Image, Link, Person } from "@fedify/vocab";
36
-
37
11
  //#region src/federation/webfinger.test.ts
38
12
  test("handleWebFinger()", async (t) => {
39
13
  const url = new URL("https://example.com/.well-known/webfinger");
40
- function createContext(url$1) {
41
- const federation = createFederation({ kv: new MemoryKvStore() });
14
+ function createContext(url) {
42
15
  const context = createRequestContext({
43
- federation,
44
- url: url$1,
16
+ federation: createFederation({ kv: new MemoryKvStore() }),
17
+ url,
45
18
  data: void 0,
46
19
  getActorUri(identifier) {
47
- return new URL(`${url$1.origin}/users/${identifier}`);
20
+ return new URL(`${url.origin}/users/${identifier}`);
48
21
  },
49
22
  async getActor(handle) {
50
23
  return await actorDispatcher(context, handle);
@@ -54,10 +27,9 @@ test("handleWebFinger()", async (t) => {
54
27
  if (uri.protocol === "acct:") return null;
55
28
  if (!uri.pathname.startsWith("/users/")) return null;
56
29
  const paths = uri.pathname.split("/");
57
- const identifier = paths[paths.length - 1];
58
30
  return {
59
31
  type: "actor",
60
- identifier
32
+ identifier: paths[paths.length - 1]
61
33
  };
62
34
  }
63
35
  });
@@ -89,11 +61,10 @@ test("handleWebFinger()", async (t) => {
89
61
  await t.step("no actor dispatcher", async () => {
90
62
  const context = createContext(url);
91
63
  const request = context.request;
92
- const response = await handleWebFinger(request, {
64
+ assertEquals((await handleWebFinger(request, {
93
65
  context,
94
66
  onNotFound
95
- });
96
- assertEquals(response.status, 404);
67
+ })).status, 404);
97
68
  assertEquals(onNotFoundCalled, request);
98
69
  });
99
70
  onNotFoundCalled = null;
@@ -113,8 +84,7 @@ test("handleWebFinger()", async (t) => {
113
84
  const u = new URL(url);
114
85
  u.searchParams.set("resource", " invalid ");
115
86
  const context = createContext(u);
116
- const request = new Request(u);
117
- const response = await handleWebFinger(request, {
87
+ const response = await handleWebFinger(new Request(u), {
118
88
  context,
119
89
  actorDispatcher,
120
90
  onNotFound
@@ -220,12 +190,11 @@ test("handleWebFinger()", async (t) => {
220
190
  u.searchParams.set("resource", "acct:no-one@example.com");
221
191
  const context = createContext(u);
222
192
  const request = context.request;
223
- const response = await handleWebFinger(request, {
193
+ assertEquals((await handleWebFinger(request, {
224
194
  context,
225
195
  actorDispatcher,
226
196
  onNotFound
227
- });
228
- assertEquals(response.status, 404);
197
+ })).status, 404);
229
198
  assertEquals(onNotFoundCalled, request);
230
199
  });
231
200
  onNotFoundCalled = null;
@@ -521,16 +490,14 @@ test("handleWebFinger()", async (t) => {
521
490
  onNotFound
522
491
  });
523
492
  assertEquals(response.status, 200);
524
- const result = await response.json();
525
- const expectedWithCustomLinks = {
493
+ assertEquals(await response.json(), {
526
494
  ...expected,
527
495
  links: [...expected.links, {
528
496
  rel: "http://ostatus.org/schema/1.0/subscribe",
529
497
  template: "https://example.com/follow?acct={uri}"
530
498
  }]
531
- };
532
- assertEquals(result, expectedWithCustomLinks);
499
+ });
533
500
  });
534
501
  });
535
-
536
- //#endregion
502
+ //#endregion
503
+ export {};
@@ -5,7 +5,6 @@ import { TracerProvider } from "@opentelemetry/api";
5
5
  import { DocumentLoader } from "@fedify/vocab-runtime";
6
6
 
7
7
  //#region src/sig/key.d.ts
8
-
9
8
  /**
10
9
  * Generates a key pair which is appropriate for Fedify.
11
10
  * @param algorithm The algorithm to use. Currently only RSASSA-PKCS1-v1_5 and
@@ -238,9 +237,5 @@ interface HttpMessageSignaturesSpecDeterminer {
238
237
  */
239
238
  rememberSpec(origin: string, spec: HttpMessageSignaturesSpec): void | Promise<void>;
240
239
  }
241
- /**
242
- * The options for double-knock requests.
243
- * @since 1.6.0
244
- */
245
240
  //#endregion
246
- export { FetchKeyOptions, FetchKeyResult, HttpMessageSignaturesSpec, HttpMessageSignaturesSpecDeterminer, KeyCache, SignRequestOptions, VerifyRequestOptions, exportJwk, fetchKey, generateCryptoKeyPair, importJwk, signRequest, verifyRequest };
241
+ export { signRequest as a, FetchKeyResult as c, fetchKey as d, generateCryptoKeyPair as f, VerifyRequestOptions as i, KeyCache as l, HttpMessageSignaturesSpecDeterminer as n, verifyRequest as o, importJwk as p, SignRequestOptions as r, FetchKeyOptions as s, HttpMessageSignaturesSpec as t, exportJwk as u };
@@ -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,121 +8,9 @@ import { FetchError, getDocumentLoader } from "@fedify/vocab-runtime";
10
8
  import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } from "@opentelemetry/semantic-conventions";
11
9
  import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
12
10
  import { Item, decodeDict, encodeItem } from "structured-field-values";
13
-
14
11
  //#region deno.json
15
12
  var name = "@fedify/fedify";
16
- var version = "2.0.8";
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.0.10";
128
14
  //#endregion
129
15
  //#region src/sig/key.ts
130
16
  /**
@@ -140,8 +26,7 @@ function validateCryptoKey(key, type) {
140
26
  if (!key.extractable) throw new TypeError("The key is not extractable.");
141
27
  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!");
142
28
  if (key.algorithm.name === "RSASSA-PKCS1-v1_5") {
143
- const algorithm = key.algorithm;
144
- 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.");
29
+ 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.");
145
30
  }
146
31
  }
147
32
  /**
@@ -220,8 +105,7 @@ async function importJwk(jwk, type) {
220
105
  * @since 1.3.0
221
106
  */
222
107
  function fetchKey(keyId, cls, options = {}) {
223
- const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
224
- const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
108
+ const tracer = (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version);
225
109
  keyId = typeof keyId === "string" ? new URL(keyId) : keyId;
226
110
  return tracer.startActiveSpan("activitypub.fetch_key", {
227
111
  kind: SpanKind.CLIENT,
@@ -277,8 +161,7 @@ async function fetchKeyInternal(keyId, cls, { documentLoader, contextLoader, key
277
161
  logger.debug("Fetching key {keyId} to verify signature...", { keyId });
278
162
  let document;
279
163
  try {
280
- const remoteDocument = await (documentLoader ?? getDocumentLoader())(keyId);
281
- document = remoteDocument.document;
164
+ document = (await (documentLoader ?? getDocumentLoader())(keyId)).document;
282
165
  } catch (_) {
283
166
  logger.debug("Failed to fetch key {keyId}.", { keyId });
284
167
  await keyCache?.set(cacheKey, null);
@@ -302,8 +185,8 @@ async function fetchKeyInternal(keyId, cls, { documentLoader, contextLoader, key
302
185
  contextLoader,
303
186
  tracerProvider
304
187
  });
305
- } catch (e$1) {
306
- if (e$1 instanceof TypeError) {
188
+ } catch (e) {
189
+ if (e instanceof TypeError) {
307
190
  logger.debug("Failed to verify; key {keyId} returned an invalid object.", { keyId });
308
191
  await keyCache?.set(cacheKey, null);
309
192
  return {
@@ -311,7 +194,7 @@ async function fetchKeyInternal(keyId, cls, { documentLoader, contextLoader, key
311
194
  cached: false
312
195
  };
313
196
  }
314
- throw e$1;
197
+ throw e;
315
198
  }
316
199
  }
317
200
  let key = null;
@@ -374,7 +257,6 @@ async function fetchKeyInternal(keyId, cls, { documentLoader, contextLoader, key
374
257
  cached: false
375
258
  };
376
259
  }
377
-
378
260
  //#endregion
379
261
  //#region src/sig/http.ts
380
262
  const DEFAULT_MAX_REDIRECTION = 20;
@@ -389,9 +271,7 @@ const DEFAULT_MAX_REDIRECTION = 20;
389
271
  */
390
272
  async function signRequest(request, privateKey, keyId, options = {}) {
391
273
  validateCryptoKey(privateKey, "private");
392
- const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
393
- const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
394
- return await tracer.startActiveSpan("http_signatures.sign", async (span) => {
274
+ return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("http_signatures.sign", async (span) => {
395
275
  try {
396
276
  const spec = options.spec ?? "draft-cavage-http-signatures-12";
397
277
  let signed;
@@ -400,7 +280,7 @@ async function signRequest(request, privateKey, keyId, options = {}) {
400
280
  if (span.isRecording()) {
401
281
  span.setAttribute(ATTR_HTTP_REQUEST_METHOD, signed.method);
402
282
  span.setAttribute(ATTR_URL_FULL, signed.url);
403
- for (const [name$1, value] of signed.headers) span.setAttribute(ATTR_HTTP_REQUEST_HEADER(name$1), value);
283
+ for (const [name, value] of signed.headers) span.setAttribute(ATTR_HTTP_REQUEST_HEADER(name), value);
404
284
  span.setAttribute("http_signatures.key_id", keyId.href);
405
285
  }
406
286
  return signed;
@@ -428,8 +308,8 @@ async function signRequestDraft(request, privateKey, keyId, span, currentTime, b
428
308
  }
429
309
  if (!headers.has("Date")) headers.set("Date", currentTime == null ? (/* @__PURE__ */ new Date()).toUTCString() : new Date(currentTime.toString()).toUTCString());
430
310
  const serialized = [["(request-target)", `${request.method.toLowerCase()} ${url.pathname}`], ...headers];
431
- const headerNames = serialized.map(([name$1]) => name$1);
432
- const message = serialized.map(([name$1, value]) => `${name$1}: ${value.trim()}`).join("\n");
311
+ const headerNames = serialized.map(([name]) => name);
312
+ const message = serialized.map(([name, value]) => `${name}: ${value.trim()}`).join("\n");
433
313
  const signature = await crypto.subtle.sign("RSASSA-PKCS1-v1_5", privateKey, new TextEncoder().encode(message));
434
314
  const sigHeader = `keyId="${keyId.href}",algorithm="rsa-sha256",headers="${headerNames.join(" ")}",signature="${encodeBase64(signature)}"`;
435
315
  headers.set("Signature", sigHeader);
@@ -486,9 +366,7 @@ function createRfc9421SignatureBase(request, components, parameters) {
486
366
  * @returns The formatted signature string.
487
367
  */
488
368
  function formatRfc9421Signature(signature, components, parameters) {
489
- const signatureInputValue = `sig1=("${components.join("\" \"")}");${parameters}`;
490
- const signatureValue = `sig1=:${encodeBase64(signature)}:`;
491
- return [signatureInputValue, signatureValue];
369
+ return [`sig1=("${components.join("\" \"")}");${parameters}`, `sig1=:${encodeBase64(signature)}:`];
492
370
  }
493
371
  /**
494
372
  * Parse RFC 9421 Signature-Input header.
@@ -618,13 +496,11 @@ const supportedHashAlgorithms = {
618
496
  * could not be verified.
619
497
  */
620
498
  async function verifyRequest(request, options = {}) {
621
- const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
622
- const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
623
- return await tracer.startActiveSpan("http_signatures.verify", async (span) => {
499
+ return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("http_signatures.verify", async (span) => {
624
500
  if (span.isRecording()) {
625
501
  span.setAttribute(ATTR_HTTP_REQUEST_METHOD, request.method);
626
502
  span.setAttribute(ATTR_URL_FULL, request.url);
627
- for (const [name$1, value] of request.headers) span.setAttribute(ATTR_HTTP_REQUEST_HEADER(name$1), value);
503
+ for (const [name, value] of request.headers) span.setAttribute(ATTR_HTTP_REQUEST_HEADER(name), value);
628
504
  }
629
505
  try {
630
506
  let spec = options.spec;
@@ -807,11 +683,10 @@ async function verifyRequestDraft(request, span, { documentLoader, contextLoader
807
683
  logger.debug("Failed to verify; required headers missing in the Signature header: {headers}.", { headers });
808
684
  return null;
809
685
  }
810
- 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");
686
+ 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");
811
687
  const sig = decodeBase64(signature);
812
688
  span?.setAttribute("http_signatures.signature", encodeHex(sig));
813
- const verified = await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key.publicKey, sig, new TextEncoder().encode(message));
814
- if (!verified) {
689
+ if (!await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key.publicKey, sig, new TextEncoder().encode(message))) {
815
690
  if (cached) {
816
691
  logger.debug("Failed to verify with the cached key {keyId}; signature {signature} is invalid. Retrying with the freshly fetched key...", {
817
692
  keyId,
@@ -825,7 +700,7 @@ async function verifyRequestDraft(request, span, { documentLoader, contextLoader
825
700
  currentTime,
826
701
  keyCache: {
827
702
  get: () => Promise.resolve(void 0),
828
- set: async (keyId$1, key$1) => await keyCache?.set(keyId$1, key$1)
703
+ set: async (keyId, key) => await keyCache?.set(keyId, key)
829
704
  }
830
705
  });
831
706
  }
@@ -975,9 +850,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
975
850
  logger.debug("Failed to verify; Content-Digest header required but not found.", { components: sigInput.components });
976
851
  continue;
977
852
  }
978
- const body = await request.arrayBuffer();
979
- const digestValid = await verifyRfc9421ContentDigest(contentDigestHeader, body);
980
- if (!digestValid) {
853
+ if (!await verifyRfc9421ContentDigest(contentDigestHeader, await request.arrayBuffer())) {
981
854
  logger.debug("Failed to verify; Content-Digest verification failed.", { contentDigest: contentDigestHeader });
982
855
  continue;
983
856
  }
@@ -1023,8 +896,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
1023
896
  const signatureBaseBytes = new TextEncoder().encode(signatureBase);
1024
897
  span?.setAttribute("http_signatures.signature", encodeHex(sigBytes));
1025
898
  try {
1026
- const verified = await crypto.subtle.verify(algorithm, key.publicKey, sigBytes.slice(), signatureBaseBytes);
1027
- if (verified) {
899
+ if (await crypto.subtle.verify(algorithm, key.publicKey, sigBytes.slice(), signatureBaseBytes)) {
1028
900
  validKey = key;
1029
901
  break;
1030
902
  } else if (cached) {
@@ -1036,7 +908,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
1036
908
  currentTime,
1037
909
  keyCache: {
1038
910
  get: () => Promise.resolve(void 0),
1039
- set: async (keyId, key$1) => await keyCache?.set(keyId, key$1)
911
+ set: async (keyId, key) => await keyCache?.set(keyId, key)
1040
912
  },
1041
913
  spec: "rfc9421"
1042
914
  });
@@ -1109,8 +981,7 @@ async function doubleKnockInternal(request, identity, options, redirected = 0, v
1109
981
  });
1110
982
  if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
1111
983
  if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(request.url, `Too many redirections (${redirected + 1})`);
1112
- const location = response.headers.get("Location");
1113
- const redirectRequest = createRedirectRequest(request, location, body);
984
+ const redirectRequest = createRedirectRequest(request, response.headers.get("Location"), body);
1114
985
  if (visited.has(redirectRequest.url)) throw new FetchError(request.url, `Redirect loop detected: ${redirectRequest.url}`);
1115
986
  return doubleKnockInternal(redirectRequest, identity, {
1116
987
  ...options,
@@ -1140,8 +1011,7 @@ async function doubleKnockInternal(request, identity, options, redirected = 0, v
1140
1011
  });
1141
1012
  if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
1142
1013
  if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(request.url, `Too many redirections (${redirected + 1})`);
1143
- const location = response.headers.get("Location");
1144
- const redirectRequest = createRedirectRequest(request, location, body);
1014
+ const redirectRequest = createRedirectRequest(request, response.headers.get("Location"), body);
1145
1015
  if (visited.has(redirectRequest.url)) throw new FetchError(request.url, `Redirect loop detected: ${redirectRequest.url}`);
1146
1016
  return doubleKnockInternal(redirectRequest, identity, {
1147
1017
  ...options,
@@ -1178,6 +1048,5 @@ function timingSafeEqual(a, b) {
1178
1048
  result |= lenA ^ lenB;
1179
1049
  return result === 0;
1180
1050
  }
1181
-
1182
1051
  //#endregion
1183
- export { deno_default, doubleKnock, exportJwk, fetchKey, generateCryptoKeyPair, importJwk, signRequest, validateCryptoKey, verifyRequest };
1052
+ export { fetchKey as a, validateCryptoKey as c, exportJwk as i, name as l, signRequest as n, generateCryptoKeyPair as o, verifyRequest as r, importJwk as s, doubleKnock as t, version 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
@@ -236,9 +235,5 @@ interface HttpMessageSignaturesSpecDeterminer {
236
235
  */
237
236
  rememberSpec(origin: string, spec: HttpMessageSignaturesSpec): void | Promise<void>;
238
237
  }
239
- /**
240
- * The options for double-knock requests.
241
- * @since 1.6.0
242
- */
243
238
  //#endregion
244
- export { FetchKeyOptions, FetchKeyResult, HttpMessageSignaturesSpec, HttpMessageSignaturesSpecDeterminer, KeyCache, SignRequestOptions, VerifyRequestOptions, exportJwk, fetchKey, generateCryptoKeyPair, importJwk, signRequest, verifyRequest };
239
+ export { signRequest as a, FetchKeyResult as c, fetchKey as d, generateCryptoKeyPair as f, VerifyRequestOptions as i, KeyCache as l, HttpMessageSignaturesSpecDeterminer as n, verifyRequest as o, importJwk as p, SignRequestOptions as r, FetchKeyOptions as s, HttpMessageSignaturesSpec as t, exportJwk as u };