@fedify/fedify 2.0.0-pr.410.1558 → 2.0.0-pr.412.1692

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 (184) hide show
  1. package/dist/actor-CrTGiTZd.cjs +42609 -0
  2. package/dist/{actor-CkjTCNqi.js → actor-D5S46edz.js} +1 -1
  3. package/dist/actor-D6K058Tb.d.cts +128 -0
  4. package/dist/{actor-DmsbGzXS.js → actor-G2S5sPEA.js} +6951 -2127
  5. package/dist/{actor-C22bXuuC.d.ts → actor-T6RyhRgk.d.ts} +1 -1
  6. package/dist/{authdocloader-BwV2NPfz.js → authdocloader-C5AvdCCi.js} +6 -6
  7. package/dist/authdocloader-CQMPmpaO.cjs +58 -0
  8. package/dist/{authdocloader-BJxkviIL.js → authdocloader-SjwloJUA.js} +3 -3
  9. package/dist/{builder-DbOVAz8i.js → builder-OA47XRft.js} +10 -4
  10. package/dist/chunk-DqRYRqnO.cjs +34 -0
  11. package/dist/{client-DrNZd6r_.js → client-Bmd-i8x8.js} +3 -22
  12. package/dist/client-CegPX0Rn.d.cts +222 -0
  13. package/dist/{client-DF8anIB5.d.ts → client-bgSdkFa2.d.ts} +2 -74
  14. package/dist/compat/mod.cjs +10 -0
  15. package/dist/compat/mod.d.cts +13 -0
  16. package/dist/compat/mod.d.ts +8 -8
  17. package/dist/compat/mod.js +5 -5
  18. package/dist/compat/transformers.test.js +19 -19
  19. package/dist/compat-DmDDELst.cjs +4 -0
  20. package/dist/compat-nxUqe4Z-.js +4 -0
  21. package/dist/{context-9gCpIkiz.d.ts → context-ByZprN0S.d.ts} +67 -7
  22. package/dist/context-C5BsZkDr.d.cts +2315 -0
  23. package/dist/docloader-7Ey7wNHx.cjs +4861 -0
  24. package/dist/{docloader-DnepZfu_.js → docloader-CkweNhUH.js} +189 -9
  25. package/dist/docloader-D-MrRyHl.d.cts +219 -0
  26. package/dist/{esm-D1HqBE3n.js → esm-CwHz8Y8t.js} +1 -1
  27. package/dist/federation/builder.test.js +6 -7
  28. package/dist/federation/collection.test.js +4 -4
  29. package/dist/federation/handler.test.js +23 -143
  30. package/dist/federation/idempotency.test.js +202 -0
  31. package/dist/federation/inbox.test.js +4 -4
  32. package/dist/federation/keycache.test.js +4 -4
  33. package/dist/federation/kv.test.js +4 -3
  34. package/dist/federation/middleware.test.js +231 -52
  35. package/dist/federation/mod.cjs +29 -0
  36. package/dist/federation/mod.d.cts +13 -0
  37. package/dist/federation/mod.d.ts +8 -8
  38. package/dist/federation/mod.js +15 -15
  39. package/dist/federation/mq.test.js +3 -3
  40. package/dist/federation/negotiation.test.d.ts +3 -0
  41. package/dist/federation/negotiation.test.js +28 -0
  42. package/dist/federation/retry.test.js +3 -3
  43. package/dist/federation/router.test.js +3 -3
  44. package/dist/federation/send.test.js +10 -10
  45. package/dist/{federation-CMX7WzeL.js → federation-D1U8YY9t.js} +3 -3
  46. package/dist/federation-H2_En3j5.cjs +244 -0
  47. package/dist/fixtures/media.example.com/avatars/test-avatar.jpg.json +6 -0
  48. package/dist/http-BiBofurJ.cjs +826 -0
  49. package/dist/{http-BEJUSX6j.js → http-C5tC93Hn.js} +7 -7
  50. package/dist/http-D-e6AFwR.d.cts +253 -0
  51. package/dist/{http-DqSNLFNY.d.ts → http-D6Uj2x2y.d.ts} +1 -1
  52. package/dist/{http-BgCF3jDs.js → http-DGjdMiLc.js} +3 -3
  53. package/dist/{inbox-Bq4EChoK.js → inbox-BoDY3z8G.js} +24 -7
  54. package/dist/key-CZR7QraT.cjs +290 -0
  55. package/dist/key-Cf8MffVe.cjs +10 -0
  56. package/dist/{key-D-0OLe9C.js → key-CkxrAIyp.js} +5 -5
  57. package/dist/key-Dk0j88Jo.js +10 -0
  58. package/dist/{key-BD3lpBWw.js → key-Epcl5jpz.js} +3 -3
  59. package/dist/{key-BYNqWXyu.js → key-IxRhZpOF.js} +2 -2
  60. package/dist/{keycache-yZDAc3-e.js → keycache-TEniXNel.js} +1 -1
  61. package/dist/{keys-Dtc-g6xq.js → keys-bZxcrZ9Z.js} +1 -1
  62. package/dist/kv-63Cil1MD.d.cts +81 -0
  63. package/dist/{ld-BJ484qSg.js → ld-DW7A0uIc.js} +4 -4
  64. package/dist/{lookup-Cj0sX50U.js → lookup-DhQCVVja.js} +21 -12
  65. package/dist/lookup-DiV4LFBg.cjs +137 -0
  66. package/dist/{lookup-BzogF2gp.js → lookup-cVRa2QM-.js} +4 -4
  67. package/dist/middleware-Be1JStOx.js +17 -0
  68. package/dist/middleware-CDOK7WOb.js +26 -0
  69. package/dist/{middleware-CiH0ptqy.js → middleware-Cgr3PtaJ.js} +58 -149
  70. package/dist/{middleware-DIZ1dnwT.js → middleware-DvvYAIsd.js} +87 -91
  71. package/dist/middleware-EjIW2mZB.cjs +17 -0
  72. package/dist/middleware-TfuVoceY.cjs +4231 -0
  73. package/dist/mod-8DMWKtQE.d.cts +80 -0
  74. package/dist/{mod-Drmz72EK.d.ts → mod-BhUKmBJD.d.ts} +2 -2
  75. package/dist/mod-C2tOeRkN.d.cts +1 -0
  76. package/dist/{mod-TFoH2Ql8.d.ts → mod-CerN_Sza.d.ts} +1 -1
  77. package/dist/mod-Cj1tHXBR.d.cts +102 -0
  78. package/dist/mod-CxkWO3Mg.d.cts +307 -0
  79. package/dist/{mod-Bqxcp7eN.d.ts → mod-D6hQoxC5.d.ts} +2 -2
  80. package/dist/mod-Djzcw2ry.d.cts +266 -0
  81. package/dist/{mod-Cxt4Kpf6.d.ts → mod-DlU8ISoa.d.ts} +19 -1
  82. package/dist/mod-FZd39qVq.d.cts +1 -0
  83. package/dist/mod-jQ4OODsl.d.cts +113 -0
  84. package/dist/mod.cjs +150 -0
  85. package/dist/mod.d.cts +17 -0
  86. package/dist/mod.d.ts +11 -11
  87. package/dist/mod.js +21 -21
  88. package/dist/mq-B7R1Q-M5.d.cts +140 -0
  89. package/dist/negotiation-5NPJL6zp.js +71 -0
  90. package/dist/nodeinfo/client.test.js +27 -106
  91. package/dist/nodeinfo/handler.test.js +20 -20
  92. package/dist/nodeinfo/mod.cjs +11 -0
  93. package/dist/nodeinfo/mod.d.cts +5 -0
  94. package/dist/nodeinfo/mod.d.ts +2 -2
  95. package/dist/nodeinfo/mod.js +7 -7
  96. package/dist/nodeinfo/types.test.js +5 -10
  97. package/dist/nodeinfo-Co9lJrWl.cjs +4 -0
  98. package/dist/nodeinfo-DfycQ8Wf.js +4 -0
  99. package/dist/{owner-9FMX4wQT.js → owner-6Vc3UXXE.js} +2 -2
  100. package/dist/owner-BN_tO3cY.d.cts +67 -0
  101. package/dist/{owner-CQPnQVtf.d.ts → owner-hd9lvQcP.d.ts} +2 -2
  102. package/dist/{proof-Arx4Q9Q6.js → proof-C1jhbeNv.js} +3 -3
  103. package/dist/proof-CRJWXFfT.cjs +673 -0
  104. package/dist/{proof-DnTD0avk.js → proof-Chi90OXv.js} +9 -9
  105. package/dist/runtime/authdocloader.test.js +9 -9
  106. package/dist/runtime/docloader.test.js +4 -4
  107. package/dist/runtime/key.test.js +5 -5
  108. package/dist/runtime/langstr.test.js +3 -3
  109. package/dist/runtime/link.test.d.ts +3 -0
  110. package/dist/runtime/link.test.js +61 -0
  111. package/dist/runtime/mod.cjs +25 -0
  112. package/dist/runtime/mod.d.cts +6 -0
  113. package/dist/runtime/mod.d.ts +3 -3
  114. package/dist/runtime/mod.js +10 -10
  115. package/dist/runtime/multibase/multibase.test.js +3 -3
  116. package/dist/runtime/url.test.js +3 -3
  117. package/dist/runtime-C58AJWSv.cjs +4 -0
  118. package/dist/runtime-DPYEDf-o.js +4 -0
  119. package/dist/{send-CcxHe0p3.js → send-DjATl6i3.js} +2 -2
  120. package/dist/sig/http.test.js +9 -9
  121. package/dist/sig/key.test.js +6 -6
  122. package/dist/sig/ld.test.js +7 -7
  123. package/dist/sig/mod.cjs +30 -0
  124. package/dist/sig/mod.d.cts +8 -0
  125. package/dist/sig/mod.d.ts +5 -5
  126. package/dist/sig/mod.js +10 -10
  127. package/dist/sig/owner.test.js +7 -7
  128. package/dist/sig/proof.test.js +7 -7
  129. package/dist/sig-ByHXzqUi.cjs +4 -0
  130. package/dist/sig-Cj3tk-ig.js +4 -0
  131. package/dist/testing/docloader.test.js +3 -3
  132. package/dist/testing/mod.d.ts +273 -28
  133. package/dist/testing/mod.js +3 -3
  134. package/dist/{testing-DFgpNAI6.js → testing-BnfPB5T-.js} +2 -2
  135. package/dist/{transformers-Dna8Fg7k.js → transformers-BFT6d7J5.js} +3 -3
  136. package/dist/transformers-CoBS-oFG.cjs +116 -0
  137. package/dist/{type-B2h-NRAo.js → type-NEA09tSC.js} +7262 -2258
  138. package/dist/{types-BIgY6c-l.js → types-BSuWJsOm.js} +1 -3
  139. package/dist/types-CmmUQisS.cjs +315 -0
  140. package/dist/{types-B1QuBj5L.js → types-dLXLjVLf.js} +8 -169
  141. package/dist/vocab/actor.test.js +5 -5
  142. package/dist/vocab/lookup.test.js +255 -5
  143. package/dist/vocab/mod.cjs +87 -0
  144. package/dist/vocab/mod.d.cts +6 -0
  145. package/dist/vocab/mod.d.ts +3 -3
  146. package/dist/vocab/mod.js +7 -7
  147. package/dist/vocab/type.test.js +3 -3
  148. package/dist/vocab/vocab.test.js +433 -9
  149. package/dist/{vocab-SOE1ifCr.d.ts → vocab-BI0Ak5lL.d.ts} +290 -0
  150. package/dist/vocab-C5Y-0fGj.cjs +291 -0
  151. package/dist/vocab-Dw1-yVGg.d.cts +14922 -0
  152. package/dist/{vocab-BREfYr1a.js → vocab-rWbHpc2J.js} +26 -17
  153. package/dist/webfinger/handler.test.js +19 -19
  154. package/dist/webfinger/lookup.test.js +4 -4
  155. package/dist/webfinger/mod.cjs +9 -0
  156. package/dist/webfinger/mod.d.cts +4 -0
  157. package/dist/webfinger/mod.js +6 -6
  158. package/dist/webfinger-BjOEdFPs.cjs +4 -0
  159. package/dist/webfinger-De_bU0iE.js +4 -0
  160. package/dist/x/cfworkers.cjs +100 -0
  161. package/dist/x/cfworkers.d.cts +59 -0
  162. package/dist/x/cfworkers.js +3 -3
  163. package/dist/x/cfworkers.test.js +3 -3
  164. package/dist/x/hono.cjs +61 -0
  165. package/dist/x/hono.d.cts +54 -0
  166. package/dist/x/hono.d.ts +7 -7
  167. package/dist/x/hono.js +3 -3
  168. package/dist/x/sveltekit.cjs +69 -0
  169. package/dist/x/sveltekit.d.cts +46 -0
  170. package/dist/x/sveltekit.d.ts +7 -7
  171. package/dist/x/sveltekit.js +3 -3
  172. package/package.json +68 -13
  173. package/dist/compat-Bb5myD13.js +0 -4
  174. package/dist/key-BmFoI4_J.js +0 -10
  175. package/dist/middleware-D2W4gwdv.js +0 -17
  176. package/dist/middleware-LmK3pQ2z.js +0 -26
  177. package/dist/nodeinfo/semver.test.js +0 -143
  178. package/dist/nodeinfo-CyEbLjHs.js +0 -4
  179. package/dist/runtime-BSkOVUWM.js +0 -4
  180. package/dist/semver-dArNLkR9.js +0 -149
  181. package/dist/sig-BXJO--F9.js +0 -4
  182. package/dist/webfinger-C3GIyXIg.js +0 -4
  183. /package/dist/{collection-CSzG2j1P.js → collection-CcnIw1qY.js} +0 -0
  184. /package/dist/{nodeinfo/semver.test.d.ts → federation/idempotency.test.d.ts} +0 -0
@@ -1,10 +1,10 @@
1
1
 
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
-
5
- import { deno_default, getDocumentLoader } from "./docloader-DnepZfu_.js";
6
- import { Object as Object$1, getTypeId } from "./actor-DmsbGzXS.js";
7
- import { lookupWebFinger } from "./lookup-BzogF2gp.js";
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ import { deno_default, getDocumentLoader } from "./docloader-CkweNhUH.js";
6
+ import { Object as Object$1, getTypeId } from "./actor-G2S5sPEA.js";
7
+ import { lookupWebFinger } from "./lookup-cVRa2QM-.js";
8
8
  import { getLogger } from "@logtape/logtape";
9
9
  import { SpanStatusCode, trace } from "@opentelemetry/api";
10
10
  import { delay } from "es-toolkit";
@@ -152,14 +152,13 @@ async function lookupObject(identifier, options = {}) {
152
152
  async function lookupObjectInternal(identifier, options = {}) {
153
153
  const documentLoader = options.documentLoader ?? getDocumentLoader({ userAgent: options.userAgent });
154
154
  if (typeof identifier === "string") identifier = toAcctUrl(identifier) ?? new URL(identifier);
155
- let document = null;
155
+ let remoteDoc = null;
156
156
  if (identifier.protocol === "http:" || identifier.protocol === "https:") try {
157
- const remoteDoc = await documentLoader(identifier.href, { signal: options.signal });
158
- document = remoteDoc.document;
157
+ remoteDoc = await documentLoader(identifier.href, { signal: options.signal });
159
158
  } catch (error) {
160
159
  logger.debug("Failed to fetch remote document:\n{error}", { error });
161
160
  }
162
- if (document == null) {
161
+ if (remoteDoc == null) {
163
162
  const jrd = await lookupWebFinger(identifier, {
164
163
  userAgent: options.userAgent,
165
164
  tracerProvider: options.tracerProvider,
@@ -170,8 +169,7 @@ async function lookupObjectInternal(identifier, options = {}) {
170
169
  for (const l of jrd.links) {
171
170
  if (l.type !== "application/activity+json" && !l.type?.match(/application\/ld\+json;\s*profile="https:\/\/www.w3.org\/ns\/activitystreams"/) || l.rel !== "self" || l.href == null) continue;
172
171
  try {
173
- const remoteDoc = await documentLoader(l.href, { signal: options.signal });
174
- document = remoteDoc.document;
172
+ remoteDoc = await documentLoader(l.href, { signal: options.signal });
175
173
  break;
176
174
  } catch (error) {
177
175
  logger.debug("Failed to fetch remote document:\n{error}", { error });
@@ -179,23 +177,34 @@ async function lookupObjectInternal(identifier, options = {}) {
179
177
  }
180
178
  }
181
179
  }
182
- if (document == null) return null;
180
+ if (remoteDoc == null) return null;
181
+ let object;
183
182
  try {
184
- return await Object$1.fromJsonLd(document, {
183
+ object = await Object$1.fromJsonLd(remoteDoc.document, {
185
184
  documentLoader,
186
185
  contextLoader: options.contextLoader,
187
- tracerProvider: options.tracerProvider
186
+ tracerProvider: options.tracerProvider,
187
+ baseUrl: new URL(remoteDoc.documentUrl)
188
188
  });
189
189
  } catch (error) {
190
190
  if (error instanceof TypeError) {
191
191
  logger.debug("Failed to parse JSON-LD document: {error}\n{document}", {
192
- error,
193
- document
192
+ ...remoteDoc,
193
+ error
194
194
  });
195
195
  return null;
196
196
  }
197
197
  throw error;
198
198
  }
199
+ if (options.crossOrigin !== "trust" && object.id != null && object.id.origin !== new URL(remoteDoc.documentUrl).origin) {
200
+ if (options.crossOrigin === "throw") throw new Error(`The object's @id (${object.id.href}) has a different origin than the document URL (${remoteDoc.documentUrl}); refusing to return the object. If you want to bypass this check and are aware of the security implications, set the crossOrigin option to "trust".`);
201
+ logger.warn("The object's @id ({objectId}) has a different origin than the document URL ({documentUrl}); refusing to return the object. If you want to bypass this check and are aware of the security implications, set the crossOrigin option to \"trust\".", {
202
+ ...remoteDoc,
203
+ objectId: object.id.href
204
+ });
205
+ return null;
206
+ }
207
+ return object;
199
208
  }
200
209
  /**
201
210
  * Traverses a collection, yielding each item in the collection.
@@ -3,30 +3,30 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { Image, Link, Person } from "../type-B2h-NRAo.js";
6
+ import { Image, Link, Person } from "../type-NEA09tSC.js";
7
7
  import { assertEquals } from "../assert_equals-DSbWqCm3.js";
8
8
  import "../assert-MZs1qjMx.js";
9
9
  import "../assert_instance_of-DHz7EHNU.js";
10
10
  import { MemoryKvStore } from "../kv-CRZrzyXm.js";
11
- import { createFederation, handleWebFinger } from "../middleware-CiH0ptqy.js";
12
- import "../semver-dArNLkR9.js";
13
- import "../client-DrNZd6r_.js";
14
- import "../lookup-Cj0sX50U.js";
15
- import "../types-BIgY6c-l.js";
16
- import "../actor-CkjTCNqi.js";
17
- import "../key-BYNqWXyu.js";
18
- import "../http-BgCF3jDs.js";
19
- import "../authdocloader-BJxkviIL.js";
20
- import "../ld-BJ484qSg.js";
21
- import "../owner-9FMX4wQT.js";
22
- import "../proof-Arx4Q9Q6.js";
23
- import "../inbox-Bq4EChoK.js";
24
- import "../builder-DbOVAz8i.js";
25
- import "../collection-CSzG2j1P.js";
26
- import "../keycache-yZDAc3-e.js";
11
+ import { createFederation, handleWebFinger } from "../middleware-Cgr3PtaJ.js";
12
+ import "../client-Bmd-i8x8.js";
13
+ import "../lookup-DhQCVVja.js";
14
+ import "../types-BSuWJsOm.js";
15
+ import "../actor-D5S46edz.js";
16
+ import "../key-IxRhZpOF.js";
17
+ import "../http-DGjdMiLc.js";
18
+ import "../authdocloader-SjwloJUA.js";
19
+ import "../ld-DW7A0uIc.js";
20
+ import "../owner-6Vc3UXXE.js";
21
+ import "../proof-C1jhbeNv.js";
22
+ import "../inbox-BoDY3z8G.js";
23
+ import "../builder-OA47XRft.js";
24
+ import "../collection-CcnIw1qY.js";
25
+ import "../keycache-TEniXNel.js";
26
+ import "../negotiation-5NPJL6zp.js";
27
27
  import "../retry-D4GJ670a.js";
28
- import "../send-CcxHe0p3.js";
29
- import { createRequestContext, test } from "../testing-DFgpNAI6.js";
28
+ import "../send-DjATl6i3.js";
29
+ import { createRequestContext, test } from "../testing-BnfPB5T-.js";
30
30
  import "../std__assert-X-_kMxKM.js";
31
31
  import "../assert_rejects-DiIiJbZn.js";
32
32
  import "../assert_is_error-BPGph1Jx.js";
@@ -3,18 +3,18 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { lookupWebFinger } from "../type-B2h-NRAo.js";
6
+ import { lookupWebFinger } from "../type-NEA09tSC.js";
7
7
  import { assertEquals } from "../assert_equals-DSbWqCm3.js";
8
8
  import "../assert-MZs1qjMx.js";
9
9
  import "../assert_instance_of-DHz7EHNU.js";
10
- import "../lookup-Cj0sX50U.js";
11
- import { test } from "../testing-DFgpNAI6.js";
10
+ import "../lookup-DhQCVVja.js";
11
+ import { test } from "../testing-BnfPB5T-.js";
12
12
  import "../std__assert-X-_kMxKM.js";
13
13
  import "../assert_rejects-DiIiJbZn.js";
14
14
  import "../assert_is_error-BPGph1Jx.js";
15
15
  import "../assert_not_equals-f3m3epl3.js";
16
16
  import "../assert_throws-BOO88avQ.js";
17
- import { esm_default } from "../esm-D1HqBE3n.js";
17
+ import { esm_default } from "../esm-CwHz8Y8t.js";
18
18
  import { withTimeout } from "es-toolkit";
19
19
 
20
20
  //#region src/webfinger/lookup.test.ts
@@ -0,0 +1,9 @@
1
+
2
+ const { Temporal } = require("@js-temporal/polyfill");
3
+ const { URLPattern } = require("urlpattern-polyfill");
4
+
5
+ require('../docloader-7Ey7wNHx.cjs');
6
+ const require_lookup = require('../lookup-DiV4LFBg.cjs');
7
+ require('../webfinger-BjOEdFPs.cjs');
8
+
9
+ exports.lookupWebFinger = require_lookup.lookupWebFinger;
@@ -0,0 +1,4 @@
1
+ import "../kv-63Cil1MD.cjs";
2
+ import "../docloader-D-MrRyHl.cjs";
3
+ import { Link, LookupWebFingerOptions, ResourceDescriptor, lookupWebFinger } from "../mod-jQ4OODsl.cjs";
4
+ export { Link, LookupWebFingerOptions, ResourceDescriptor, lookupWebFinger };
@@ -1,9 +1,9 @@
1
1
 
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
-
5
- import "../docloader-DnepZfu_.js";
6
- import { lookupWebFinger } from "../lookup-BzogF2gp.js";
7
- import "../webfinger-C3GIyXIg.js";
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ import "../docloader-CkweNhUH.js";
6
+ import { lookupWebFinger } from "../lookup-cVRa2QM-.js";
7
+ import "../webfinger-De_bU0iE.js";
8
8
 
9
9
  export { lookupWebFinger };
@@ -0,0 +1,4 @@
1
+
2
+ const { Temporal } = require("@js-temporal/polyfill");
3
+ const { URLPattern } = require("urlpattern-polyfill");
4
+
@@ -0,0 +1,4 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
@@ -0,0 +1,100 @@
1
+
2
+ const { Temporal } = require("@js-temporal/polyfill");
3
+ const { URLPattern } = require("urlpattern-polyfill");
4
+
5
+ const require_chunk = require('../chunk-DqRYRqnO.cjs');
6
+ const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
7
+
8
+ //#region src/x/cfworkers.ts
9
+ /**
10
+ * Implementation of the {@link KvStore} interface for Cloudflare Workers KV
11
+ * binding. This class provides a wrapper around Cloudflare's KV namespace to
12
+ * store and retrieve JSON-serializable values using structured keys.
13
+ *
14
+ * Note that this implementation does not support the {@link KvStore.cas}
15
+ * operation, as Cloudflare Workers KV does not support atomic compare-and-swap
16
+ * operations. If you need this functionality, consider using a different
17
+ * key–value store that supports atomic operations.
18
+ *
19
+ * @deprecated This class has been moved to `@fedify/cfworkers` package.
20
+ * Import `WorkersKvStore` from `@fedify/cfworkers` instead.
21
+ * This class will be removed in Fedify v2.0.
22
+ * @since 1.6.0
23
+ */
24
+ var WorkersKvStore = class {
25
+ #namespace;
26
+ constructor(namespace) {
27
+ const logger = (0, __logtape_logtape.getLogger)(["fedify", "cfworkers"]);
28
+ logger.warn("The `@fedify/fedify/x/cfworkers` module is deprecated; use `WorkersKvStore` from `@fedify/cfworkers` package instead.");
29
+ this.#namespace = namespace;
30
+ }
31
+ #encodeKey(key) {
32
+ return JSON.stringify(key);
33
+ }
34
+ async get(key) {
35
+ const encodedKey = this.#encodeKey(key);
36
+ const { value, metadata } = await this.#namespace.getWithMetadata(encodedKey, "json");
37
+ return metadata == null || metadata.expires < Date.now() ? void 0 : value;
38
+ }
39
+ async set(key, value, options) {
40
+ const encodedKey = this.#encodeKey(key);
41
+ const metadata = options?.ttl == null ? {} : { expires: Date.now() + options.ttl.total("milliseconds") };
42
+ await this.#namespace.put(encodedKey, JSON.stringify(value), options?.ttl == null ? { metadata } : {
43
+ expirationTtl: Math.max(options.ttl.total("seconds"), 60),
44
+ metadata
45
+ });
46
+ }
47
+ delete(key) {
48
+ return this.#namespace.delete(this.#encodeKey(key));
49
+ }
50
+ };
51
+ /**
52
+ * Implementation of the {@link MessageQueue} interface for Cloudflare
53
+ * Workers Queues binding. This class provides a wrapper around Cloudflare's
54
+ * Queues to send messages to a queue.
55
+ *
56
+ * Note that this implementation does not support the `listen()` method,
57
+ * as Cloudflare Workers Queues do not support message consumption in the same
58
+ * way as other message queue systems. Instead, you should use
59
+ * the {@link Federation.processQueuedTask} method to process messages
60
+ * passed to the queue.
61
+ *
62
+ * @deprecated This class has been moved to `@fedify/cfworkers` package.
63
+ * Import `WorkersMessageQueue` from `@fedify/cfworkers` instead.
64
+ * This class will be removed in Fedify v2.0.
65
+ * @since 1.6.0
66
+ */
67
+ var WorkersMessageQueue = class {
68
+ #queue;
69
+ /**
70
+ * Cloudflare Queues provide automatic retry with exponential backoff
71
+ * and Dead Letter Queues.
72
+ * @since 1.7.0
73
+ */
74
+ nativeRetrial = true;
75
+ constructor(queue) {
76
+ const logger = (0, __logtape_logtape.getLogger)(["fedify", "cfworkers"]);
77
+ logger.warn("The `@fedify/fedify/x/cfworkers` module is deprecated; use `WorkersMessageQueue` from `@fedify/cfworkers` package instead.");
78
+ this.#queue = queue;
79
+ }
80
+ enqueue(message, options) {
81
+ return this.#queue.send(message, {
82
+ contentType: "json",
83
+ delaySeconds: options?.delay?.total("seconds") ?? 0
84
+ });
85
+ }
86
+ enqueueMany(messages, options) {
87
+ const requests = messages.map((msg) => ({
88
+ body: msg,
89
+ contentType: "json"
90
+ }));
91
+ return this.#queue.sendBatch(requests, { delaySeconds: options?.delay?.total("seconds") ?? 0 });
92
+ }
93
+ listen(_handler, _options) {
94
+ throw new TypeError("WorkersMessageQueue does not support listen(). Use Federation.processQueuedTask() method instead.");
95
+ }
96
+ };
97
+
98
+ //#endregion
99
+ exports.WorkersKvStore = WorkersKvStore;
100
+ exports.WorkersMessageQueue = WorkersMessageQueue;
@@ -0,0 +1,59 @@
1
+ import { KvKey, KvStore, KvStoreSetOptions } from "../kv-63Cil1MD.cjs";
2
+ import { MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions } from "../mq-B7R1Q-M5.cjs";
3
+ import { KVNamespace, Queue } from "@cloudflare/workers-types/experimental";
4
+
5
+ //#region src/x/cfworkers.d.ts
6
+
7
+ /**
8
+ * Implementation of the {@link KvStore} interface for Cloudflare Workers KV
9
+ * binding. This class provides a wrapper around Cloudflare's KV namespace to
10
+ * store and retrieve JSON-serializable values using structured keys.
11
+ *
12
+ * Note that this implementation does not support the {@link KvStore.cas}
13
+ * operation, as Cloudflare Workers KV does not support atomic compare-and-swap
14
+ * operations. If you need this functionality, consider using a different
15
+ * key–value store that supports atomic operations.
16
+ *
17
+ * @deprecated This class has been moved to `@fedify/cfworkers` package.
18
+ * Import `WorkersKvStore` from `@fedify/cfworkers` instead.
19
+ * This class will be removed in Fedify v2.0.
20
+ * @since 1.6.0
21
+ */
22
+ declare class WorkersKvStore implements KvStore {
23
+ #private;
24
+ constructor(namespace: KVNamespace<string>);
25
+ get<T = unknown>(key: KvKey): Promise<T | undefined>;
26
+ set(key: KvKey, value: unknown, options?: KvStoreSetOptions): Promise<void>;
27
+ delete(key: KvKey): Promise<void>;
28
+ }
29
+ /**
30
+ * Implementation of the {@link MessageQueue} interface for Cloudflare
31
+ * Workers Queues binding. This class provides a wrapper around Cloudflare's
32
+ * Queues to send messages to a queue.
33
+ *
34
+ * Note that this implementation does not support the `listen()` method,
35
+ * as Cloudflare Workers Queues do not support message consumption in the same
36
+ * way as other message queue systems. Instead, you should use
37
+ * the {@link Federation.processQueuedTask} method to process messages
38
+ * passed to the queue.
39
+ *
40
+ * @deprecated This class has been moved to `@fedify/cfworkers` package.
41
+ * Import `WorkersMessageQueue` from `@fedify/cfworkers` instead.
42
+ * This class will be removed in Fedify v2.0.
43
+ * @since 1.6.0
44
+ */
45
+ declare class WorkersMessageQueue implements MessageQueue {
46
+ #private;
47
+ /**
48
+ * Cloudflare Queues provide automatic retry with exponential backoff
49
+ * and Dead Letter Queues.
50
+ * @since 1.7.0
51
+ */
52
+ readonly nativeRetrial = true;
53
+ constructor(queue: Queue);
54
+ enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
55
+ enqueueMany(messages: any[], options?: MessageQueueEnqueueOptions): Promise<void>;
56
+ listen(_handler: (message: any) => Promise<void> | void, _options?: MessageQueueListenOptions): Promise<void>;
57
+ }
58
+ //#endregion
59
+ export { WorkersKvStore, WorkersMessageQueue };
@@ -1,7 +1,7 @@
1
1
 
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
-
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
5
  import { getLogger } from "@logtape/logtape";
6
6
 
7
7
  //#region src/x/cfworkers.ts
@@ -3,12 +3,12 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import "../type-B2h-NRAo.js";
6
+ import "../type-NEA09tSC.js";
7
7
  import { assertEquals } from "../assert_equals-DSbWqCm3.js";
8
8
  import "../assert-MZs1qjMx.js";
9
9
  import "../assert_instance_of-DHz7EHNU.js";
10
- import "../lookup-Cj0sX50U.js";
11
- import { test } from "../testing-DFgpNAI6.js";
10
+ import "../lookup-DhQCVVja.js";
11
+ import { test } from "../testing-BnfPB5T-.js";
12
12
  import "../std__assert-X-_kMxKM.js";
13
13
  import "../assert_rejects-DiIiJbZn.js";
14
14
  import "../assert_is_error-BPGph1Jx.js";
@@ -0,0 +1,61 @@
1
+
2
+ const { Temporal } = require("@js-temporal/polyfill");
3
+ const { URLPattern } = require("urlpattern-polyfill");
4
+
5
+ const require_chunk = require('../chunk-DqRYRqnO.cjs');
6
+ const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
7
+
8
+ //#region src/x/hono.ts
9
+ /**
10
+ * Create a Hono middleware to integrate with the {@link Federation} object.
11
+ *
12
+ * @deprecated This function has been moved to `@fedify/hono` package.
13
+ * Import `federation` from `@fedify/hono` instead.
14
+ * This function will be removed in Fedify v2.0.
15
+ *
16
+ * @template TContextData A type of the context data for the {@link Federation}
17
+ * object.
18
+ * @template THonoContext A type of the Hono context.
19
+ * @param federation A {@link Federation} object to integrate with Hono.
20
+ * @param contextDataFactory A function to create a context data for the
21
+ * {@link Federation} object.
22
+ * @returns A Hono middleware.
23
+ */
24
+ function federation(federation$1, contextDataFactory) {
25
+ const logger = (0, __logtape_logtape.getLogger)([
26
+ "fedify",
27
+ "federation",
28
+ "hono"
29
+ ]);
30
+ logger.warn("The `@fedify/fedify/x/hono` module is deprecated; use `federation` from `@fedify/hono` package instead.");
31
+ return async (ctx, next) => {
32
+ let contextData = contextDataFactory(ctx);
33
+ if (contextData instanceof Promise) contextData = await contextData;
34
+ return await federation$1.fetch(ctx.req.raw, {
35
+ contextData,
36
+ ...integrateFetchOptions(ctx, next)
37
+ });
38
+ };
39
+ }
40
+ function integrateFetchOptions(ctx, next) {
41
+ return {
42
+ async onNotFound(_req) {
43
+ await next();
44
+ return ctx.res;
45
+ },
46
+ async onNotAcceptable(_req) {
47
+ await next();
48
+ if (ctx.res.status !== 404) return ctx.res;
49
+ return new Response("Not acceptable", {
50
+ status: 406,
51
+ headers: {
52
+ "Content-Type": "text/plain",
53
+ Vary: "Accept"
54
+ }
55
+ });
56
+ }
57
+ };
58
+ }
59
+
60
+ //#endregion
61
+ exports.federation = federation;
@@ -0,0 +1,54 @@
1
+ import "../kv-63Cil1MD.cjs";
2
+ import "../docloader-D-MrRyHl.cjs";
3
+ import "../client-CegPX0Rn.cjs";
4
+ import "../vocab-Dw1-yVGg.cjs";
5
+ import "../actor-D6K058Tb.cjs";
6
+ import "../http-D-e6AFwR.cjs";
7
+ import "../owner-BN_tO3cY.cjs";
8
+ import "../mod-CxkWO3Mg.cjs";
9
+ import "../mod-jQ4OODsl.cjs";
10
+ import { Federation } from "../context-C5BsZkDr.cjs";
11
+ import "../mq-B7R1Q-M5.cjs";
12
+
13
+ //#region src/x/hono.d.ts
14
+ interface HonoRequest {
15
+ raw: Request;
16
+ }
17
+ interface HonoContext {
18
+ req: HonoRequest;
19
+ res: Response;
20
+ }
21
+ type HonoMiddleware<THonoContext extends HonoContext> = (ctx: THonoContext, next: () => Promise<void>) => Promise<Response | void>;
22
+ /**
23
+ * A factory function to create a context data for the {@link Federation}
24
+ * object.
25
+ *
26
+ * @deprecated This type has been moved to `@fedify/hono` package.
27
+ * Import `ContextDataFactory` from `@fedify/hono` instead.
28
+ * This type will be removed in Fedify v2.0.
29
+ *
30
+ * @template TContextData A type of the context data for the {@link Federation}
31
+ * object.
32
+ * @template THonoContext A type of the Hono context.
33
+ * @param context A Hono context object.
34
+ * @returns A context data for the {@link Federation} object.
35
+ */
36
+ type ContextDataFactory<TContextData, THonoContext> = (context: THonoContext) => TContextData | Promise<TContextData>;
37
+ /**
38
+ * Create a Hono middleware to integrate with the {@link Federation} object.
39
+ *
40
+ * @deprecated This function has been moved to `@fedify/hono` package.
41
+ * Import `federation` from `@fedify/hono` instead.
42
+ * This function will be removed in Fedify v2.0.
43
+ *
44
+ * @template TContextData A type of the context data for the {@link Federation}
45
+ * object.
46
+ * @template THonoContext A type of the Hono context.
47
+ * @param federation A {@link Federation} object to integrate with Hono.
48
+ * @param contextDataFactory A function to create a context data for the
49
+ * {@link Federation} object.
50
+ * @returns A Hono middleware.
51
+ */
52
+ declare function federation<TContextData, THonoContext extends HonoContext>(federation: Federation<TContextData>, contextDataFactory: ContextDataFactory<TContextData, THonoContext>): HonoMiddleware<THonoContext>;
53
+ //#endregion
54
+ export { ContextDataFactory, federation };
package/dist/x/hono.d.ts CHANGED
@@ -2,14 +2,14 @@ import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
3
  import "../kv-C7sopW2E.js";
4
4
  import "../docloader-CxWcuWqQ.js";
5
- import "../client-DF8anIB5.js";
6
- import "../vocab-SOE1ifCr.js";
7
- import "../actor-C22bXuuC.js";
8
- import "../http-DqSNLFNY.js";
9
- import "../owner-CQPnQVtf.js";
10
- import "../mod-Cxt4Kpf6.js";
5
+ import "../client-bgSdkFa2.js";
6
+ import "../vocab-BI0Ak5lL.js";
7
+ import "../actor-T6RyhRgk.js";
8
+ import "../http-D6Uj2x2y.js";
9
+ import "../owner-hd9lvQcP.js";
10
+ import "../mod-DlU8ISoa.js";
11
11
  import "../mod-DBzN0aCM.js";
12
- import { Federation } from "../context-9gCpIkiz.js";
12
+ import { Federation } from "../context-ByZprN0S.js";
13
13
  import "../mq-CRGm1e_F.js";
14
14
 
15
15
  //#region src/x/hono.d.ts
package/dist/x/hono.js CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
-
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
5
  import { getLogger } from "@logtape/logtape";
6
6
 
7
7
  //#region src/x/hono.ts
@@ -0,0 +1,69 @@
1
+
2
+ const { Temporal } = require("@js-temporal/polyfill");
3
+ const { URLPattern } = require("urlpattern-polyfill");
4
+
5
+ const require_chunk = require('../chunk-DqRYRqnO.cjs');
6
+ const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
7
+
8
+ //#region src/x/sveltekit.ts
9
+ /**
10
+ * Create a SvelteKit hook handler to integrate with the {@link Federation}
11
+ * object.
12
+ *
13
+ * @deprecated This function has been moved to `@fedify/sveltekit` package.
14
+ * Import `fedifyHook` from `@fedify/sveltekit` instead.
15
+ * This function will be removed in Fedify v2.0.
16
+ *
17
+ * @example hooks.server.ts
18
+ * ``` typescript
19
+ * import { federation } from "./federation"; // Import the `Federation` object
20
+ *
21
+ * export const handle = fedifyHook(federation, () => undefined);
22
+ * ```
23
+ *
24
+ * @template TContextData A type of the context data for the {@link Federation}
25
+ * object.
26
+ * @param federation A {@link Federation} object to integrate with SvelteKit.
27
+ * @param createContextData A function to create a context data for the
28
+ * {@link Federation} object.
29
+ * @returns A SvelteKit hook handler.
30
+ * @since 1.3.0
31
+ */
32
+ function fedifyHook(federation, createContextData) {
33
+ const logger = (0, __logtape_logtape.getLogger)([
34
+ "fedify",
35
+ "federation",
36
+ "sveltekit"
37
+ ]);
38
+ logger.warn("The `@fedify/fedify/x/sveltekit` module is deprecated; use `fedifyHook` from `@fedify/sveltekit` package instead.");
39
+ return async ({ event, resolve }) => {
40
+ return await federation.fetch(event.request, {
41
+ contextData: await createContextData(event),
42
+ ...integrateFetchOptions({
43
+ event,
44
+ resolve
45
+ })
46
+ });
47
+ };
48
+ }
49
+ function integrateFetchOptions({ event, resolve }) {
50
+ return {
51
+ async onNotFound() {
52
+ return await resolve(event);
53
+ },
54
+ async onNotAcceptable() {
55
+ const res = await resolve(event);
56
+ if (res.status !== 404) return res;
57
+ return new Response("Not acceptable", {
58
+ status: 406,
59
+ headers: {
60
+ "Content-Type": "text/plain",
61
+ Vary: "Accept"
62
+ }
63
+ });
64
+ }
65
+ };
66
+ }
67
+
68
+ //#endregion
69
+ exports.fedifyHook = fedifyHook;
@@ -0,0 +1,46 @@
1
+ import "../kv-63Cil1MD.cjs";
2
+ import "../docloader-D-MrRyHl.cjs";
3
+ import "../client-CegPX0Rn.cjs";
4
+ import "../vocab-Dw1-yVGg.cjs";
5
+ import "../actor-D6K058Tb.cjs";
6
+ import "../http-D-e6AFwR.cjs";
7
+ import "../owner-BN_tO3cY.cjs";
8
+ import "../mod-CxkWO3Mg.cjs";
9
+ import "../mod-jQ4OODsl.cjs";
10
+ import { Federation } from "../context-C5BsZkDr.cjs";
11
+ import "../mq-B7R1Q-M5.cjs";
12
+
13
+ //#region src/x/sveltekit.d.ts
14
+ type RequestEvent = {
15
+ request: Request;
16
+ };
17
+ type HookParams = {
18
+ event: RequestEvent;
19
+ resolve: (event: RequestEvent) => Promise<Response>;
20
+ };
21
+ /**
22
+ * Create a SvelteKit hook handler to integrate with the {@link Federation}
23
+ * object.
24
+ *
25
+ * @deprecated This function has been moved to `@fedify/sveltekit` package.
26
+ * Import `fedifyHook` from `@fedify/sveltekit` instead.
27
+ * This function will be removed in Fedify v2.0.
28
+ *
29
+ * @example hooks.server.ts
30
+ * ``` typescript
31
+ * import { federation } from "./federation"; // Import the `Federation` object
32
+ *
33
+ * export const handle = fedifyHook(federation, () => undefined);
34
+ * ```
35
+ *
36
+ * @template TContextData A type of the context data for the {@link Federation}
37
+ * object.
38
+ * @param federation A {@link Federation} object to integrate with SvelteKit.
39
+ * @param createContextData A function to create a context data for the
40
+ * {@link Federation} object.
41
+ * @returns A SvelteKit hook handler.
42
+ * @since 1.3.0
43
+ */
44
+ declare function fedifyHook<TContextData>(federation: Federation<TContextData>, createContextData: (event: RequestEvent) => TContextData | Promise<TContextData>): (params: HookParams) => Promise<Response>;
45
+ //#endregion
46
+ export { fedifyHook };