@farm.js/core 0.1.37 → 0.1.38

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 (242) hide show
  1. package/dist/{agent-mcp-BC0bAGVF.d.mts → agent-mcp-BwKlpnc7.d.mts} +1 -1
  2. package/dist/{agent-mcp-jyDHbQKe.d.ts → agent-mcp-De1imoMS.d.ts} +1 -1
  3. package/dist/{agent-mcp-handler-SJAHFSPI.cjs → agent-mcp-handler-MRGP3WJ3.cjs} +5 -5
  4. package/dist/{agent-mcp-handler-LPJ2CADR.mjs → agent-mcp-handler-OLRMZONF.mjs} +4 -4
  5. package/dist/agent-runtime.cjs +2 -2
  6. package/dist/agent-runtime.d.mts +1 -1
  7. package/dist/agent-runtime.d.ts +1 -1
  8. package/dist/agent-runtime.mjs +1 -1
  9. package/dist/api/client.cjs +3 -3
  10. package/dist/api/client.mjs +2 -2
  11. package/dist/api/route-manager.cjs +5 -5
  12. package/dist/api/route-manager.d.mts +3 -3
  13. package/dist/api/route-manager.d.ts +3 -3
  14. package/dist/api/route-manager.mjs +4 -4
  15. package/dist/api/runtime.cjs +4 -4
  16. package/dist/api/runtime.d.mts +2 -2
  17. package/dist/api/runtime.d.ts +2 -2
  18. package/dist/api/runtime.mjs +3 -3
  19. package/dist/api.cjs +7 -7
  20. package/dist/api.d.mts +3 -3
  21. package/dist/api.d.ts +3 -3
  22. package/dist/api.mjs +6 -6
  23. package/dist/{app-Cbkj9ufe.d.mts → app-CFZt-srr.d.mts} +21 -3
  24. package/dist/{app-CKO3iN1c.d.ts → app-kT_QXTdx.d.ts} +21 -3
  25. package/dist/app-markdown.cjs +4 -4
  26. package/dist/app-markdown.d.mts +2 -2
  27. package/dist/app-markdown.d.ts +2 -2
  28. package/dist/app-markdown.mjs +3 -3
  29. package/dist/{chunk-LOFKRKO7.cjs → chunk-2DD4JMQC.cjs} +113 -22
  30. package/dist/chunk-2ZYGC6SS.cjs +576 -0
  31. package/dist/{chunk-75X755YZ.cjs → chunk-34UCJRQO.cjs} +2 -2
  32. package/dist/{chunk-CVH2BXPY.cjs → chunk-3LOLJTFV.cjs} +6 -6
  33. package/dist/{chunk-4GPOC4LN.cjs → chunk-472NCAZ7.cjs} +3 -3
  34. package/dist/{chunk-WT4TGLXT.cjs → chunk-4E5QXOCL.cjs} +6 -6
  35. package/dist/{chunk-7DWNJI73.cjs → chunk-4IE345DM.cjs} +37 -19
  36. package/dist/{chunk-O6WAEAX3.mjs → chunk-5BWWFHR2.mjs} +70 -15
  37. package/dist/{chunk-6LGFV2CQ.cjs → chunk-5OKBARDN.cjs} +2 -2
  38. package/dist/{chunk-3IP27TCG.cjs → chunk-5PWXMJOH.cjs} +19 -19
  39. package/dist/chunk-6BK3K2GB.mjs +318 -0
  40. package/dist/{chunk-HEVMCTSR.mjs → chunk-6HB6V3R7.mjs} +1 -1
  41. package/dist/{chunk-NICDYKBS.cjs → chunk-6XWDE2P2.cjs} +22 -4
  42. package/dist/{chunk-Z7LA7MHQ.mjs → chunk-7FPTZLKH.mjs} +1 -1
  43. package/dist/{chunk-JPNFPAZ4.mjs → chunk-7PEP3BUT.mjs} +1 -1
  44. package/dist/{chunk-XOPOIFTJ.mjs → chunk-A3EAIURZ.mjs} +25 -7
  45. package/dist/{chunk-LBDP3YT3.mjs → chunk-ARC7I3O2.mjs} +1 -1
  46. package/dist/{chunk-LBGILORX.mjs → chunk-B6G5CKMC.mjs} +101 -10
  47. package/dist/{chunk-MCIZVNOQ.mjs → chunk-BZHXGVMA.mjs} +1 -1
  48. package/dist/{chunk-KDTBF3UU.mjs → chunk-CNNOLE4O.mjs} +1 -1
  49. package/dist/{chunk-TDNWPAVR.mjs → chunk-CUM5NYL5.mjs} +1 -1
  50. package/dist/{chunk-HITLGIAO.cjs → chunk-CY2ZQ5C6.cjs} +7 -6
  51. package/dist/{chunk-KPFKMDM7.mjs → chunk-DRLKAXDM.mjs} +1 -1
  52. package/dist/{chunk-VR4GD5I3.cjs → chunk-EIPC3FDA.cjs} +12 -4
  53. package/dist/{chunk-K3SAEIM3.mjs → chunk-EKF7KDFD.mjs} +1 -1
  54. package/dist/{chunk-B5PFZLKV.cjs → chunk-EKN7NSZO.cjs} +25 -8
  55. package/dist/{chunk-ATWHHSY2.cjs → chunk-EMO6K4YY.cjs} +4 -4
  56. package/dist/{chunk-6SJ2KJTA.mjs → chunk-EPYU2EBL.mjs} +1 -1
  57. package/dist/{chunk-PTZ2TVNE.cjs → chunk-H5CLOUZS.cjs} +5 -5
  58. package/dist/{chunk-DTSROJ5J.mjs → chunk-HD5CF3OE.mjs} +1 -1
  59. package/dist/{chunk-IAIYV4RZ.mjs → chunk-HXRYZWTA.mjs} +1 -1
  60. package/dist/{chunk-Z5BEWYVO.mjs → chunk-IBUQWVYA.mjs} +16 -0
  61. package/dist/{chunk-HMRSWN47.mjs → chunk-INL3THCU.mjs} +1 -1
  62. package/dist/{chunk-FBOJ55OM.mjs → chunk-IVLZZZEI.mjs} +1 -1
  63. package/dist/{chunk-ENLZ4R3Y.mjs → chunk-J7K2NZD6.mjs} +7 -6
  64. package/dist/{chunk-NFMDCAOS.mjs → chunk-JCKYH4LG.mjs} +2 -2
  65. package/dist/{chunk-PMQHMWZU.cjs → chunk-JCYYXBAJ.cjs} +3 -3
  66. package/dist/{chunk-LPFV45AY.cjs → chunk-KCQBAKIY.cjs} +9 -9
  67. package/dist/{chunk-FGRYBX5X.mjs → chunk-KHKLMNI5.mjs} +1 -1
  68. package/dist/{chunk-NQ6QFZWD.cjs → chunk-KKSTAEMY.cjs} +1 -1
  69. package/dist/{chunk-7O5M4UKW.cjs → chunk-L4DD7ODZ.cjs} +2 -2
  70. package/dist/{chunk-YCKO6FRS.mjs → chunk-LI2F57NI.mjs} +1 -1
  71. package/dist/{chunk-TW4GYDBJ.mjs → chunk-MLY2RP5R.mjs} +10 -2
  72. package/dist/{chunk-5BXGGEC7.cjs → chunk-N32CC42M.cjs} +5 -5
  73. package/dist/{chunk-BHY547NB.cjs → chunk-NBBEQLOK.cjs} +9 -9
  74. package/dist/{chunk-WQ7T2263.mjs → chunk-OAHTRMIC.mjs} +3 -3
  75. package/dist/{chunk-K4I4O5TS.mjs → chunk-OCIEZME4.mjs} +790 -671
  76. package/dist/{chunk-UH6QN5NL.mjs → chunk-P664ZVTV.mjs} +2 -2
  77. package/dist/{chunk-TE2G5ION.cjs → chunk-PGZDEPTM.cjs} +88 -33
  78. package/dist/{chunk-3KGDJLJK.mjs → chunk-POSPE3IO.mjs} +19 -1
  79. package/dist/{chunk-3A4KGQYI.cjs → chunk-Q3NXS4MU.cjs} +16 -14
  80. package/dist/{chunk-TPLJVC7E.mjs → chunk-QFW2IH5E.mjs} +23 -6
  81. package/dist/{chunk-S3VWVTVA.mjs → chunk-QRKIMN7T.mjs} +13 -1
  82. package/dist/chunk-QTXBII4Z.cjs +632 -0
  83. package/dist/{chunk-CI6E3UOH.cjs → chunk-RG4A6LB2.cjs} +7 -7
  84. package/dist/{chunk-7SQ5SGYZ.cjs → chunk-RW63BOV7.cjs} +2 -2
  85. package/dist/{chunk-U6MPZ35Q.cjs → chunk-RWFLWR5J.cjs} +8 -8
  86. package/dist/{chunk-EUV4YR3V.cjs → chunk-SGBJ247Q.cjs} +18 -2
  87. package/dist/{chunk-J3ANCZKA.mjs → chunk-SKVTP5PR.mjs} +1 -1
  88. package/dist/{chunk-6TJITR2B.cjs → chunk-TGFQVLLF.cjs} +870 -751
  89. package/dist/{chunk-4P6ULFMD.mjs → chunk-TUBTR2OP.mjs} +221 -102
  90. package/dist/{chunk-EMMQ64QW.cjs → chunk-TYJALEHQ.cjs} +2 -2
  91. package/dist/{chunk-WRPHYQVY.mjs → chunk-TYMMBFN2.mjs} +1 -1
  92. package/dist/chunk-U6QLDL3G.mjs +576 -0
  93. package/dist/{chunk-OW67PDDS.cjs → chunk-ULASELLA.cjs} +13 -1
  94. package/dist/{chunk-WWIKMBRN.mjs → chunk-VNGH5MLF.mjs} +17 -1
  95. package/dist/{chunk-NNSAQX3U.mjs → chunk-VT4WFRHA.mjs} +1 -1
  96. package/dist/{chunk-UJZLSXUB.cjs → chunk-VU6AAZVY.cjs} +17 -1
  97. package/dist/{chunk-ADOAUDQ6.cjs → chunk-VXEEATVD.cjs} +2 -2
  98. package/dist/{chunk-RRMVL6CJ.mjs → chunk-W36M2BQ4.mjs} +1 -1
  99. package/dist/{chunk-4WQ6PGSJ.cjs → chunk-WEW2JVA4.cjs} +4 -4
  100. package/dist/{chunk-4E5WBPEG.mjs → chunk-WFRT7JPX.mjs} +8 -533
  101. package/dist/{chunk-VXAWRDK7.mjs → chunk-WLL43JMO.mjs} +1 -1
  102. package/dist/chunk-WW46B6HA.cjs +318 -0
  103. package/dist/{chunk-D3C5LBQY.cjs → chunk-WXJLNP33.cjs} +2 -2
  104. package/dist/{chunk-NDILNQ4L.cjs → chunk-XKG2BLFN.cjs} +2 -2
  105. package/dist/{chunk-W2YDNK66.cjs → chunk-XKVVMZP5.cjs} +2 -2
  106. package/dist/{chunk-Q5FYSK45.cjs → chunk-YR2VBEMO.cjs} +619 -500
  107. package/dist/{chunk-EXG5LD6B.mjs → chunk-ZJD2PN6Z.mjs} +10 -8
  108. package/dist/{chunk-G2TEB74S.cjs → chunk-ZXH4TS3F.cjs} +2 -2
  109. package/dist/{client-plugins-C8DjftDF.d.ts → client-plugins-BvlNhGEB.d.ts} +40 -7
  110. package/dist/{client-plugins-CV4eJ9De.d.mts → client-plugins-DUrIYX9B.d.mts} +40 -7
  111. package/dist/client-plugins.d.mts +1 -1
  112. package/dist/client-plugins.d.ts +1 -1
  113. package/dist/client.cjs +5 -5
  114. package/dist/client.d.mts +5 -5
  115. package/dist/client.d.ts +5 -5
  116. package/dist/client.mjs +4 -4
  117. package/dist/config.d.mts +1 -1
  118. package/dist/config.d.ts +1 -1
  119. package/dist/{devtools-KVOY2TCZ.mjs → devtools-JYJNOLPQ.mjs} +7 -5
  120. package/dist/{devtools-JXFQNWSH.cjs → devtools-VQWJANJV.cjs} +8 -6
  121. package/dist/docs.cjs +11 -9
  122. package/dist/docs.d.mts +20 -2
  123. package/dist/docs.d.ts +20 -2
  124. package/dist/docs.mjs +10 -8
  125. package/dist/headers.cjs +6 -4
  126. package/dist/headers.d.mts +11 -1
  127. package/dist/headers.d.ts +11 -1
  128. package/dist/headers.mjs +5 -3
  129. package/dist/index.cjs +52 -39
  130. package/dist/index.d.mts +15 -15
  131. package/dist/index.d.ts +15 -15
  132. package/dist/index.mjs +52 -39
  133. package/dist/integrations.cjs +4 -2
  134. package/dist/integrations.d.mts +1 -1
  135. package/dist/integrations.d.ts +1 -1
  136. package/dist/integrations.mjs +3 -1
  137. package/dist/internal/app-markdown-runtime.cjs +3 -3
  138. package/dist/internal/app-markdown-runtime.d.mts +2 -2
  139. package/dist/internal/app-markdown-runtime.d.ts +2 -2
  140. package/dist/internal/app-markdown-runtime.mjs +2 -2
  141. package/dist/internal/build-runtime.cjs +28 -27
  142. package/dist/internal/build-runtime.d.mts +3 -3
  143. package/dist/internal/build-runtime.d.ts +3 -3
  144. package/dist/internal/build-runtime.mjs +27 -26
  145. package/dist/internal/cli-runtime.cjs +10 -8
  146. package/dist/internal/cli-runtime.mjs +9 -7
  147. package/dist/internal/client-error-overlay.cjs +4 -4
  148. package/dist/internal/client-error-overlay.mjs +1 -1
  149. package/dist/internal/compression-runtime.d.mts +1 -1
  150. package/dist/internal/compression-runtime.d.ts +1 -1
  151. package/dist/internal/config-runtime.cjs +8 -6
  152. package/dist/internal/config-runtime.d.mts +2 -2
  153. package/dist/internal/config-runtime.d.ts +2 -2
  154. package/dist/internal/config-runtime.mjs +7 -5
  155. package/dist/internal/docs-precompiled-runtime.cjs +19 -13
  156. package/dist/internal/docs-precompiled-runtime.d.mts +5 -0
  157. package/dist/internal/docs-precompiled-runtime.d.ts +5 -0
  158. package/dist/internal/docs-precompiled-runtime.mjs +14 -8
  159. package/dist/internal/infra-analytics-runtime.cjs +5 -5
  160. package/dist/internal/infra-analytics-runtime.mjs +3 -3
  161. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  162. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  163. package/dist/internal/production-node-env.cjs +6 -2
  164. package/dist/internal/production-node-env.d.mts +10 -1
  165. package/dist/internal/production-node-env.d.ts +10 -1
  166. package/dist/internal/production-node-env.mjs +5 -1
  167. package/dist/internal/production-runtime.cjs +34 -14
  168. package/dist/internal/production-runtime.d.mts +51 -11
  169. package/dist/internal/production-runtime.d.ts +51 -11
  170. package/dist/internal/production-runtime.mjs +36 -16
  171. package/dist/markdown.cjs +8 -2
  172. package/dist/markdown.d.mts +1 -1
  173. package/dist/markdown.d.ts +1 -1
  174. package/dist/markdown.mjs +7 -1
  175. package/dist/middleware.cjs +9 -7
  176. package/dist/middleware.d.mts +24 -4
  177. package/dist/middleware.d.ts +24 -4
  178. package/dist/middleware.mjs +9 -7
  179. package/dist/navigation.cjs +4 -4
  180. package/dist/navigation.d.mts +4 -4
  181. package/dist/navigation.d.ts +4 -4
  182. package/dist/navigation.mjs +3 -3
  183. package/dist/plugin.cjs +21 -20
  184. package/dist/plugin.d.mts +1 -1
  185. package/dist/plugin.d.ts +1 -1
  186. package/dist/plugin.mjs +20 -19
  187. package/dist/{production-runtime-Du_FHb2-.d.mts → production-runtime-BQ4_WLwQ.d.mts} +1 -1
  188. package/dist/{production-runtime-C2kkrPVZ.d.ts → production-runtime-D2aMyzjr.d.ts} +1 -1
  189. package/dist/query/client.cjs +2 -2
  190. package/dist/query/client.mjs +1 -1
  191. package/dist/{render-plan-BnnPTpus.d.ts → render-plan-25p4hrj4.d.ts} +1 -1
  192. package/dist/{render-plan-Cgx7v8tJ.d.mts → render-plan-DtkXMN8D.d.mts} +1 -1
  193. package/dist/renderer-client.d.mts +3 -3
  194. package/dist/renderer-client.d.ts +3 -3
  195. package/dist/renderer.d.mts +13 -4
  196. package/dist/renderer.d.ts +13 -4
  197. package/dist/{request-sKayKcop.d.mts → request-DgCkIdcn.d.mts} +4 -2
  198. package/dist/{request-BNWr7r5e.d.ts → request-jF4jwx8f.d.ts} +4 -2
  199. package/dist/request.cjs +3 -3
  200. package/dist/request.d.mts +2 -2
  201. package/dist/request.d.ts +2 -2
  202. package/dist/request.mjs +2 -2
  203. package/dist/{route-rendering-Bx4Auw6Q.d.ts → route-rendering-Bji6S6a_.d.ts} +1 -1
  204. package/dist/{route-rendering-DWFp3Yq4.d.mts → route-rendering-CSBF78Ya.d.mts} +1 -1
  205. package/dist/{router-BK6K42Ij.d.mts → router-B09Ui3Qm.d.mts} +1 -1
  206. package/dist/{router-DnW_2tQi.d.ts → router-CPB9cXtG.d.ts} +1 -1
  207. package/dist/routes.d.mts +1 -1
  208. package/dist/routes.d.ts +1 -1
  209. package/dist/{runtime-DJDaCMd_.d.mts → runtime-CM6E6yuI.d.mts} +1 -1
  210. package/dist/{runtime-CA3Ei5k_.d.ts → runtime-EDMwLdjv.d.ts} +1 -1
  211. package/dist/server-fn.cjs +3 -3
  212. package/dist/server-fn.mjs +2 -2
  213. package/dist/server-plugins.cjs +5 -5
  214. package/dist/server-plugins.d.mts +2 -2
  215. package/dist/server-plugins.d.ts +2 -2
  216. package/dist/server-plugins.mjs +4 -4
  217. package/dist/server-query.cjs +4 -4
  218. package/dist/server-query.mjs +3 -3
  219. package/dist/server.cjs +47 -46
  220. package/dist/server.d.mts +7 -7
  221. package/dist/server.d.ts +7 -7
  222. package/dist/server.mjs +25 -24
  223. package/dist/{spa-router-Mwbd7g2L.d.ts → spa-router-B_N8XgVu.d.ts} +2 -2
  224. package/dist/{spa-router-D6fUA4Rn.d.mts → spa-router-Cgimzfbi.d.mts} +2 -2
  225. package/dist/testing.cjs +5 -5
  226. package/dist/testing.d.mts +1 -1
  227. package/dist/testing.d.ts +1 -1
  228. package/dist/testing.mjs +4 -4
  229. package/dist/theme/server.cjs +4 -4
  230. package/dist/theme/server.mjs +3 -3
  231. package/dist/{utils-BwVcAfUR.d.ts → utils-BNxAKAuT.d.ts} +1 -1
  232. package/dist/{utils-p9Hs-jCc.d.mts → utils-DZciYXYl.d.mts} +1 -1
  233. package/dist/version.cjs +2 -2
  234. package/dist/version.mjs +1 -1
  235. package/dist/vite.cjs +21 -20
  236. package/dist/vite.d.mts +1 -1
  237. package/dist/vite.d.ts +1 -1
  238. package/dist/vite.mjs +20 -19
  239. package/package.json +1 -1
  240. package/dist/chunk-655RLQQL.mjs +0 -43
  241. package/dist/chunk-MRMI32SN.cjs +0 -1157
  242. package/dist/chunk-MT763TDW.cjs +0 -43
@@ -13,7 +13,7 @@ var _chunkFWE7LEQCcjs = require('./chunk-FWE7LEQC.cjs');
13
13
  var _chunkS6FJO323cjs = require('./chunk-S6FJO323.cjs');
14
14
 
15
15
 
16
- var _chunkOW67PDDScjs = require('./chunk-OW67PDDS.cjs');
16
+ var _chunkULASELLAcjs = require('./chunk-ULASELLA.cjs');
17
17
 
18
18
 
19
19
  var _chunkBIDYX3SLcjs = require('./chunk-BIDYX3SL.cjs');
@@ -213,7 +213,7 @@ function readCurrentUrl() {
213
213
  return void 0;
214
214
  }
215
215
  }
216
- const request = _chunkOW67PDDScjs._resolveCurrentRequest.call(void 0, );
216
+ const request = _chunkULASELLAcjs._resolveCurrentRequest.call(void 0, );
217
217
  if (!request) return void 0;
218
218
  try {
219
219
  return new URL(request.url);
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  getRouteGroupScope,
9
9
  isInRouteGroupScope
10
- } from "./chunk-LBGILORX.mjs";
10
+ } from "./chunk-B6G5CKMC.mjs";
11
11
  import {
12
12
  __name
13
13
  } from "./chunk-LPEX4YW6.mjs";
@@ -0,0 +1,576 @@
1
+ import {
2
+ _markFarmOwnedResponse,
3
+ _withFarmResponseHeaders
4
+ } from "./chunk-Z3HATSKO.mjs";
5
+ import {
6
+ _resolveCurrentCspNonce
7
+ } from "./chunk-QRKIMN7T.mjs";
8
+ import {
9
+ __name
10
+ } from "./chunk-LPEX4YW6.mjs";
11
+
12
+ // src/security.ts
13
+ function resolveFarmSecurityConfig(input) {
14
+ if (input === void 0) return { csp: false };
15
+ if (!isPlainRecord(input)) {
16
+ throw new TypeError("security must be an object containing the csp option.");
17
+ }
18
+ if (Object.prototype.hasOwnProperty.call(input, "contentSecurityPolicy")) {
19
+ throw new TypeError(
20
+ "security.contentSecurityPolicy is not supported. Use security.csp instead."
21
+ );
22
+ }
23
+ const csp = input.csp;
24
+ if (csp === void 0 || csp === false) return { csp: false };
25
+ if (typeof csp === "string") {
26
+ return {
27
+ csp: {
28
+ value: validateSerializedCsp(csp),
29
+ reportOnly: false,
30
+ nonce: false
31
+ }
32
+ };
33
+ }
34
+ if (!isPlainRecord(csp)) {
35
+ throw new TypeError("security.csp must be a policy string, false, or an options object.");
36
+ }
37
+ const reportOnly = validateReportOnly(csp.reportOnly);
38
+ const nonce = validateNonce(csp.nonce);
39
+ if (Object.prototype.hasOwnProperty.call(csp, "value")) {
40
+ if (Object.prototype.hasOwnProperty.call(csp, "policy") || Object.prototype.hasOwnProperty.call(csp, "directives")) {
41
+ throw new TypeError(
42
+ "Resolved security.csp values cannot include policy or directives options."
43
+ );
44
+ }
45
+ return {
46
+ csp: {
47
+ value: validateSerializedCsp(csp.value),
48
+ reportOnly,
49
+ nonce
50
+ }
51
+ };
52
+ }
53
+ const { policy, directives } = csp;
54
+ if (policy !== void 0 && directives !== void 0) {
55
+ throw new TypeError("security.csp accepts either policy or directives, not both.");
56
+ }
57
+ if (policy === void 0 && directives === void 0) {
58
+ throw new TypeError("security.csp requires a policy string or directives object.");
59
+ }
60
+ return {
61
+ csp: {
62
+ value: policy !== void 0 ? validateSerializedCsp(policy) : serializeFarmCspDirectives(directives),
63
+ reportOnly,
64
+ nonce
65
+ }
66
+ };
67
+ }
68
+ __name(resolveFarmSecurityConfig, "resolveFarmSecurityConfig");
69
+ function serializeFarmCspDirectives(directives) {
70
+ if (!isPlainRecord(directives)) {
71
+ throw new TypeError("security.csp.directives must be an object.");
72
+ }
73
+ const serialized = [];
74
+ const normalizedNames = /* @__PURE__ */ new Set();
75
+ for (const [configuredName, configuredValue] of Object.entries(directives)) {
76
+ if (configuredValue === false || configuredValue === null || configuredValue === void 0) {
77
+ continue;
78
+ }
79
+ const name = normalizeDirectiveName(configuredName);
80
+ if (normalizedNames.has(name)) {
81
+ throw new TypeError(`security.csp contains the duplicate directive ${JSON.stringify(name)}.`);
82
+ }
83
+ normalizedNames.add(name);
84
+ const values = configuredValue === true ? [] : (Array.isArray(configuredValue) ? configuredValue : [configuredValue]).map(
85
+ validateDirectiveValue
86
+ );
87
+ serialized.push(values.length > 0 ? `${name} ${values.join(" ")}` : name);
88
+ }
89
+ if (serialized.length === 0) {
90
+ throw new TypeError("security.csp.directives must contain at least one enabled directive.");
91
+ }
92
+ return serialized.join("; ");
93
+ }
94
+ __name(serializeFarmCspDirectives, "serializeFarmCspDirectives");
95
+ function getFarmSecurityHeader(security, nonce) {
96
+ if (!security.csp) return void 0;
97
+ if (security.csp.nonce && !nonce) return void 0;
98
+ return {
99
+ key: security.csp.reportOnly ? "Content-Security-Policy-Report-Only" : "Content-Security-Policy",
100
+ value: nonce ? applyFarmCspNonceToPolicy(security.csp.value, nonce) : security.csp.value
101
+ };
102
+ }
103
+ __name(getFarmSecurityHeader, "getFarmSecurityHeader");
104
+ function createFarmCspNonce(security) {
105
+ if (!security.csp || !security.csp.nonce) return void 0;
106
+ const bytes = new Uint8Array(16);
107
+ globalThis.crypto.getRandomValues(bytes);
108
+ return Array.from(bytes, (value) => value.toString(16).padStart(2, "0")).join("");
109
+ }
110
+ __name(createFarmCspNonce, "createFarmCspNonce");
111
+ function applyFarmCspNonceToPolicy(policy, nonce) {
112
+ validateCspNonce(nonce);
113
+ return applyFarmCspScriptSourcesToPolicy(policy, [`'nonce-${nonce}'`]);
114
+ }
115
+ __name(applyFarmCspNonceToPolicy, "applyFarmCspNonceToPolicy");
116
+ function applyFarmCspHashesToPolicy(policy, hashes) {
117
+ const sources = hashes.map((hash) => {
118
+ if (!/^sha(?:256|384|512)-[A-Za-z0-9+/]+={0,2}$/.test(hash)) {
119
+ throw new TypeError(`Invalid CSP script hash: ${JSON.stringify(hash)}.`);
120
+ }
121
+ return `'${hash}'`;
122
+ });
123
+ return applyFarmCspScriptSourcesToPolicy(policy, sources);
124
+ }
125
+ __name(applyFarmCspHashesToPolicy, "applyFarmCspHashesToPolicy");
126
+ function applyFarmCspScriptSourcesToPolicy(policy, sources) {
127
+ const uniqueSources = [...new Set(sources)];
128
+ if (uniqueSources.length === 0) return policy;
129
+ const segments = policy.split(";").map((segment) => segment.trim()).filter(Boolean);
130
+ const names = segments.map((segment) => segment.split(/\s+/, 1)[0].toLowerCase());
131
+ const governingName = names.includes("script-src-elem") ? "script-src-elem" : names.includes("script-src") ? "script-src" : names.includes("default-src") ? "default-src" : void 0;
132
+ if (!governingName) return `${policy}; script-src ${uniqueSources.join(" ")}`;
133
+ return segments.map((segment, index) => {
134
+ if (names[index] !== governingName) return segment;
135
+ const existing = new Set(segment.split(/\s+/));
136
+ const missing = uniqueSources.filter((source) => !existing.has(source));
137
+ return missing.length > 0 ? `${segment} ${missing.join(" ")}` : segment;
138
+ }).join("; ");
139
+ }
140
+ __name(applyFarmCspScriptSourcesToPolicy, "applyFarmCspScriptSourcesToPolicy");
141
+ function addFarmCspNonceToScriptTags(html, nonce) {
142
+ validateCspNonce(nonce);
143
+ return createFarmScriptTagRewriter((tag) => stampScriptTag(tag, nonce)).write(html, true);
144
+ }
145
+ __name(addFarmCspNonceToScriptTags, "addFarmCspNonceToScriptTags");
146
+ function stampFarmCspNonce(html, nonce = _resolveCurrentCspNonce()) {
147
+ return nonce && html ? addFarmCspNonceToScriptTags(html, nonce) : html;
148
+ }
149
+ __name(stampFarmCspNonce, "stampFarmCspNonce");
150
+ function replaceFarmCspNonceMarker(html, marker, nonce = _resolveCurrentCspNonce()) {
151
+ validateCspNonce(marker);
152
+ if (nonce) validateCspNonce(nonce);
153
+ return createFarmScriptTagRewriter((tag) => {
154
+ const range = findScriptTagAttributeRange(tag, "nonce");
155
+ if (!range || readAttributeValue(tag.slice(range.start, range.end)) !== marker) return tag;
156
+ return nonce ? stampScriptTag(tag, nonce) : stripScriptNonceAttribute(tag);
157
+ }).write(html, true);
158
+ }
159
+ __name(replaceFarmCspNonceMarker, "replaceFarmCspNonceMarker");
160
+ function filterFarmCspNonces(html, nonce) {
161
+ return createFarmCspNonceRewriter(nonce).write(html, true);
162
+ }
163
+ __name(filterFarmCspNonces, "filterFarmCspNonces");
164
+ function removeFarmCspNoncesFromScriptTags(html) {
165
+ return createFarmScriptTagRewriter(stripScriptNonceAttribute).write(html, true);
166
+ }
167
+ __name(removeFarmCspNoncesFromScriptTags, "removeFarmCspNoncesFromScriptTags");
168
+ async function createFarmCspScriptHashes(html) {
169
+ const hashes = [];
170
+ const seen = /* @__PURE__ */ new Set();
171
+ for (const content of collectFarmInlineScriptContents(html)) {
172
+ const digest = await globalThis.crypto.subtle.digest(
173
+ "SHA-256",
174
+ new TextEncoder().encode(content)
175
+ );
176
+ let binary = "";
177
+ for (const byte of new Uint8Array(digest)) binary += String.fromCharCode(byte);
178
+ const hash = `sha256-${globalThis.btoa(binary)}`;
179
+ if (!seen.has(hash)) {
180
+ seen.add(hash);
181
+ hashes.push(hash);
182
+ }
183
+ }
184
+ return hashes;
185
+ }
186
+ __name(createFarmCspScriptHashes, "createFarmCspScriptHashes");
187
+ async function applyFarmCspHashesToHtml(html, security) {
188
+ if (!security.csp || !security.csp.nonce) return void 0;
189
+ const hashes = await createFarmCspScriptHashes(html);
190
+ const staticHtml = removeFarmCspNoncesFromScriptTags(html);
191
+ return {
192
+ html: staticHtml,
193
+ header: {
194
+ key: security.csp.reportOnly ? "Content-Security-Policy-Report-Only" : "Content-Security-Policy",
195
+ value: applyFarmCspHashesToPolicy(security.csp.value, hashes)
196
+ }
197
+ };
198
+ }
199
+ __name(applyFarmCspHashesToHtml, "applyFarmCspHashesToHtml");
200
+ function applyFarmCspNonceToResponse(response, security, nonce = createFarmCspNonce(security)) {
201
+ if (!security.csp || !security.csp.nonce || !nonce) return response;
202
+ if (!response.headers.get("content-type")?.toLowerCase().includes("text/html")) return response;
203
+ const securityHeader = getFarmSecurityHeader(security, nonce);
204
+ if (!response.body) {
205
+ return _withFarmResponseHeaders(response, (headers2) => {
206
+ headers2.set(securityHeader.key, securityHeader.value);
207
+ headers2.delete("content-length");
208
+ });
209
+ }
210
+ const headers = new Headers(response.headers);
211
+ headers.set(securityHeader.key, securityHeader.value);
212
+ headers.delete("content-length");
213
+ const decoder = new TextDecoder();
214
+ const encoder = new TextEncoder();
215
+ const rewriter = createFarmCspNonceRewriter(nonce);
216
+ const body = response.body.pipeThrough(
217
+ new TransformStream({
218
+ transform(chunk, controller) {
219
+ const output = rewriter.write(decoder.decode(chunk, { stream: true }));
220
+ if (output) controller.enqueue(encoder.encode(output));
221
+ },
222
+ flush(controller) {
223
+ const output = rewriter.write(decoder.decode(), true);
224
+ if (output) controller.enqueue(encoder.encode(output));
225
+ }
226
+ })
227
+ );
228
+ return _markFarmOwnedResponse(
229
+ new Response(body, {
230
+ status: response.status,
231
+ statusText: response.statusText,
232
+ headers
233
+ })
234
+ );
235
+ }
236
+ __name(applyFarmCspNonceToResponse, "applyFarmCspNonceToResponse");
237
+ function farmCspBlocksFrameworkInlineScripts(security) {
238
+ if (!security.csp) return false;
239
+ if (security.csp.nonce) return false;
240
+ const directives = parseCspDirectives(security.csp.value);
241
+ const governing = directives.get("script-src-elem") ?? directives.get("script-src") ?? directives.get("default-src");
242
+ if (!governing) return false;
243
+ const sources = governing.map((source) => source.toLowerCase());
244
+ const disablesUnsafeInline = sources.some(
245
+ (value) => value === "'strict-dynamic'" || value.startsWith("'nonce-") || value.startsWith("'sha256-") || value.startsWith("'sha384-") || value.startsWith("'sha512-")
246
+ );
247
+ return !sources.includes("'unsafe-inline'") || disablesUnsafeInline;
248
+ }
249
+ __name(farmCspBlocksFrameworkInlineScripts, "farmCspBlocksFrameworkInlineScripts");
250
+ function parseCspDirectives(value) {
251
+ const directives = /* @__PURE__ */ new Map();
252
+ for (const segment of value.split(";")) {
253
+ const parts = segment.trim().split(/\s+/).filter(Boolean);
254
+ if (parts.length === 0) continue;
255
+ const name = parts[0].toLowerCase();
256
+ if (!directives.has(name)) directives.set(name, parts.slice(1));
257
+ }
258
+ return directives;
259
+ }
260
+ __name(parseCspDirectives, "parseCspDirectives");
261
+ function normalizeDirectiveName(value) {
262
+ const name = value.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
263
+ if (!/^[a-z][a-z0-9-]*$/.test(name)) {
264
+ throw new TypeError(`Invalid security.csp directive name: ${JSON.stringify(value)}.`);
265
+ }
266
+ return name;
267
+ }
268
+ __name(normalizeDirectiveName, "normalizeDirectiveName");
269
+ function validateDirectiveValue(value) {
270
+ if (typeof value !== "string") {
271
+ throw new TypeError("security.csp directive values must be strings or booleans.");
272
+ }
273
+ const normalized = value.trim();
274
+ if (!normalized || /[;\r\n]/.test(normalized) || normalized.includes("\0")) {
275
+ throw new TypeError(`Invalid security.csp directive value: ${JSON.stringify(value)}.`);
276
+ }
277
+ return normalized;
278
+ }
279
+ __name(validateDirectiveValue, "validateDirectiveValue");
280
+ function validateSerializedCsp(value) {
281
+ if (typeof value !== "string") {
282
+ throw new TypeError("security.csp policy must be a non-empty single-line string.");
283
+ }
284
+ const normalized = value.trim().replace(/;+$/g, "").trim();
285
+ if (!normalized || /[\r\n]/.test(normalized) || normalized.includes("\0")) {
286
+ throw new TypeError("security.csp policy must be a non-empty single-line string.");
287
+ }
288
+ return normalized;
289
+ }
290
+ __name(validateSerializedCsp, "validateSerializedCsp");
291
+ function validateReportOnly(value) {
292
+ if (value === void 0) return false;
293
+ if (typeof value !== "boolean") {
294
+ throw new TypeError("security.csp.reportOnly must be a boolean.");
295
+ }
296
+ return value;
297
+ }
298
+ __name(validateReportOnly, "validateReportOnly");
299
+ function validateNonce(value) {
300
+ if (value === void 0) return false;
301
+ if (typeof value !== "boolean") {
302
+ throw new TypeError("security.csp.nonce must be a boolean.");
303
+ }
304
+ return value;
305
+ }
306
+ __name(validateNonce, "validateNonce");
307
+ function validateCspNonce(value) {
308
+ if (!/^[A-Za-z0-9+/_-]+={0,2}$/.test(value)) {
309
+ throw new TypeError("A CSP nonce must be a base64 or base64url value.");
310
+ }
311
+ }
312
+ __name(validateCspNonce, "validateCspNonce");
313
+ function createFarmCspNonceRewriter(nonce) {
314
+ validateCspNonce(nonce);
315
+ return createFarmScriptTagRewriter((tag) => keepOwnScriptNonce(tag, nonce));
316
+ }
317
+ __name(createFarmCspNonceRewriter, "createFarmCspNonceRewriter");
318
+ function createFarmScriptTagRewriter(transformScriptTag) {
319
+ let pending = "";
320
+ let rawTextElement;
321
+ return {
322
+ write(chunk, final = false) {
323
+ pending += chunk;
324
+ let output = "";
325
+ while (pending) {
326
+ if (rawTextElement) {
327
+ if (rawTextElement === "plaintext") {
328
+ output += pending;
329
+ pending = "";
330
+ break;
331
+ }
332
+ const closing = `</${rawTextElement}`;
333
+ const start2 = findRawTextEnd(pending, rawTextElement);
334
+ if (start2 === -1) {
335
+ if (final) {
336
+ output += pending;
337
+ pending = "";
338
+ } else {
339
+ const keep = matchingSuffixLength(pending, closing);
340
+ output += pending.slice(0, pending.length - keep);
341
+ pending = pending.slice(pending.length - keep);
342
+ }
343
+ break;
344
+ }
345
+ output += pending.slice(0, start2);
346
+ pending = pending.slice(start2);
347
+ const end2 = findHtmlTagEnd(pending);
348
+ if (end2 === -1) {
349
+ if (final) {
350
+ output += pending;
351
+ pending = "";
352
+ }
353
+ break;
354
+ }
355
+ output += pending.slice(0, end2 + 1);
356
+ pending = pending.slice(end2 + 1);
357
+ rawTextElement = void 0;
358
+ continue;
359
+ }
360
+ const start = pending.indexOf("<");
361
+ if (start === -1) {
362
+ output += pending;
363
+ pending = "";
364
+ break;
365
+ }
366
+ output += pending.slice(0, start);
367
+ pending = pending.slice(start);
368
+ if (pending.startsWith("<!--")) {
369
+ const end2 = pending.indexOf("-->", 4);
370
+ if (end2 === -1) {
371
+ if (final) {
372
+ output += pending;
373
+ pending = "";
374
+ }
375
+ break;
376
+ }
377
+ output += pending.slice(0, end2 + 3);
378
+ pending = pending.slice(end2 + 3);
379
+ continue;
380
+ }
381
+ if (!final && "<!--".startsWith(pending)) break;
382
+ const tagNameMatch = pending.match(/^<\/?([a-z][a-z0-9:-]*)\b/i);
383
+ if (!tagNameMatch) {
384
+ if (!final && /^<\/?[a-z][a-z0-9:-]*$/i.test(pending)) break;
385
+ output += pending[0];
386
+ pending = pending.slice(1);
387
+ continue;
388
+ }
389
+ const end = findHtmlTagEnd(pending);
390
+ if (end === -1) {
391
+ if (!final) break;
392
+ output += pending;
393
+ pending = "";
394
+ break;
395
+ }
396
+ const tag = pending.slice(0, end + 1);
397
+ const tagName = tagNameMatch[1].toLowerCase();
398
+ const isClosing = pending.startsWith("</");
399
+ const isSelfClosing = /\/\s*>$/.test(tag);
400
+ output += !isClosing && tagName === "script" ? transformScriptTag(tag) : tag;
401
+ pending = pending.slice(end + 1);
402
+ if (!isClosing && !isSelfClosing && rawTextElements.has(tagName)) {
403
+ rawTextElement = tagName;
404
+ }
405
+ }
406
+ return output;
407
+ }
408
+ };
409
+ }
410
+ __name(createFarmScriptTagRewriter, "createFarmScriptTagRewriter");
411
+ var rawTextElements = /* @__PURE__ */ new Map([
412
+ ["iframe", /<\/iframe(?=[\s/>]|$)/gi],
413
+ ["noembed", /<\/noembed(?=[\s/>]|$)/gi],
414
+ ["noframes", /<\/noframes(?=[\s/>]|$)/gi],
415
+ ["plaintext", null],
416
+ ["script", /<\/script(?=[\s/>]|$)/gi],
417
+ ["style", /<\/style(?=[\s/>]|$)/gi],
418
+ ["textarea", /<\/textarea(?=[\s/>]|$)/gi],
419
+ ["title", /<\/title(?=[\s/>]|$)/gi],
420
+ ["xmp", /<\/xmp(?=[\s/>]|$)/gi]
421
+ ]);
422
+ function stampScriptTag(tag, nonce) {
423
+ const opening = tag.match(/^<script\b/i)?.[0];
424
+ if (!opening) return tag;
425
+ const attributes = stripScriptNonceAttribute(tag).slice(opening.length, -1);
426
+ return `<script nonce="${nonce}"${attributes}>`;
427
+ }
428
+ __name(stampScriptTag, "stampScriptTag");
429
+ function keepOwnScriptNonce(tag, nonce) {
430
+ const opening = tag.match(/^<script\b/i)?.[0];
431
+ if (!opening) return tag;
432
+ const range = findScriptTagAttributeRange(tag, "nonce");
433
+ if (!range) return tag;
434
+ const stripped = stripScriptNonceAttribute(tag);
435
+ const attributes = stripped.slice(opening.length, -1);
436
+ if (/<(?:script|style)/i.test(attributes)) return stripped;
437
+ if (readAttributeValue(tag.slice(range.start, range.end)) !== nonce) return stripped;
438
+ return `<script nonce="${nonce}"${attributes}>`;
439
+ }
440
+ __name(keepOwnScriptNonce, "keepOwnScriptNonce");
441
+ function readAttributeValue(attribute) {
442
+ const equals = attribute.indexOf("=");
443
+ if (equals === -1) return void 0;
444
+ const value = attribute.slice(equals + 1).trim();
445
+ const quote = value[0];
446
+ if (quote === '"' || quote === "'") {
447
+ return value.length > 1 && value.endsWith(quote) ? value.slice(1, -1) : void 0;
448
+ }
449
+ return value;
450
+ }
451
+ __name(readAttributeValue, "readAttributeValue");
452
+ function stripScriptNonceAttribute(tag) {
453
+ let normalized = tag;
454
+ let range = findScriptTagAttributeRange(normalized, "nonce");
455
+ while (range) {
456
+ normalized = normalized.slice(0, range.start) + normalized.slice(range.end);
457
+ range = findScriptTagAttributeRange(normalized, "nonce");
458
+ }
459
+ return normalized;
460
+ }
461
+ __name(stripScriptNonceAttribute, "stripScriptNonceAttribute");
462
+ function collectFarmInlineScriptContents(html) {
463
+ const contents = [];
464
+ let offset = 0;
465
+ while (offset < html.length) {
466
+ const start = html.indexOf("<", offset);
467
+ if (start === -1) break;
468
+ if (html.startsWith("<!--", start)) {
469
+ const commentEnd = html.indexOf("-->", start + 4);
470
+ offset = commentEnd === -1 ? html.length : commentEnd + 3;
471
+ continue;
472
+ }
473
+ const remaining = html.slice(start);
474
+ const tagNameMatch = remaining.match(/^<\/?([a-z][a-z0-9:-]*)\b/i);
475
+ if (!tagNameMatch) {
476
+ offset = start + 1;
477
+ continue;
478
+ }
479
+ const tagEnd = findHtmlTagEnd(remaining);
480
+ if (tagEnd === -1) break;
481
+ const tag = remaining.slice(0, tagEnd + 1);
482
+ const tagName = tagNameMatch[1].toLowerCase();
483
+ const isClosing = remaining.startsWith("</");
484
+ const isSelfClosing = /\/\s*>$/.test(tag);
485
+ offset = start + tagEnd + 1;
486
+ if (isClosing || isSelfClosing || !rawTextElements.has(tagName)) continue;
487
+ if (tagName === "plaintext") break;
488
+ const closingStart = findRawTextEnd(html, tagName, offset);
489
+ const contentEnd = closingStart === -1 ? html.length : closingStart;
490
+ if (tagName === "script" && findScriptTagAttributeRange(tag, "nonce") && !findScriptTagAttributeRange(tag, "src")) {
491
+ contents.push(html.slice(offset, contentEnd));
492
+ }
493
+ if (closingStart === -1) break;
494
+ const closingEnd = findHtmlTagEnd(html.slice(contentEnd));
495
+ if (closingEnd === -1) break;
496
+ offset = contentEnd + closingEnd + 1;
497
+ }
498
+ return contents;
499
+ }
500
+ __name(collectFarmInlineScriptContents, "collectFarmInlineScriptContents");
501
+ function findScriptTagAttributeRange(tag, expectedName) {
502
+ const opening = tag.match(/^<script\b/i)?.[0];
503
+ if (!opening) return void 0;
504
+ let offset = opening.length;
505
+ while (offset < tag.length - 1) {
506
+ const whitespaceStart = offset;
507
+ while (/\s/.test(tag[offset] || "")) offset++;
508
+ if (tag[offset] === "/" || tag[offset] === ">" || offset >= tag.length - 1) break;
509
+ const nameStart = offset;
510
+ while (offset < tag.length && !/[\s=/>]/.test(tag[offset])) offset++;
511
+ const name = tag.slice(nameStart, offset).toLowerCase();
512
+ while (/\s/.test(tag[offset] || "")) offset++;
513
+ if (tag[offset] === "=") {
514
+ offset++;
515
+ while (/\s/.test(tag[offset] || "")) offset++;
516
+ const quote = tag[offset] === '"' || tag[offset] === "'" ? tag[offset++] : void 0;
517
+ if (quote) {
518
+ while (offset < tag.length && tag[offset] !== quote) offset++;
519
+ if (tag[offset] === quote) offset++;
520
+ } else {
521
+ while (offset < tag.length && !/[\s>]/.test(tag[offset])) offset++;
522
+ }
523
+ }
524
+ if (name === expectedName) return { start: whitespaceStart, end: offset };
525
+ }
526
+ return void 0;
527
+ }
528
+ __name(findScriptTagAttributeRange, "findScriptTagAttributeRange");
529
+ function findRawTextEnd(input, tagName, offset = 0) {
530
+ const closing = rawTextElements.get(tagName);
531
+ closing.lastIndex = offset;
532
+ return closing.exec(input)?.index ?? -1;
533
+ }
534
+ __name(findRawTextEnd, "findRawTextEnd");
535
+ function matchingSuffixLength(input, token) {
536
+ const limit = Math.min(token.length - 1, input.length);
537
+ for (let length = limit; length > 0; length--) {
538
+ if (token.startsWith(input.slice(-length).toLowerCase())) return length;
539
+ }
540
+ return 0;
541
+ }
542
+ __name(matchingSuffixLength, "matchingSuffixLength");
543
+ function findHtmlTagEnd(tag) {
544
+ let quote;
545
+ for (let index = 1; index < tag.length; index++) {
546
+ const character = tag[index];
547
+ if (quote) {
548
+ if (character === quote) quote = void 0;
549
+ } else if (character === '"' || character === "'") {
550
+ quote = character;
551
+ } else if (character === ">") {
552
+ return index;
553
+ }
554
+ }
555
+ return -1;
556
+ }
557
+ __name(findHtmlTagEnd, "findHtmlTagEnd");
558
+ function isPlainRecord(value) {
559
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
560
+ const prototype = Object.getPrototypeOf(value);
561
+ return prototype === Object.prototype || prototype === null;
562
+ }
563
+ __name(isPlainRecord, "isPlainRecord");
564
+
565
+ export {
566
+ resolveFarmSecurityConfig,
567
+ getFarmSecurityHeader,
568
+ createFarmCspNonce,
569
+ stampFarmCspNonce,
570
+ replaceFarmCspNonceMarker,
571
+ filterFarmCspNonces,
572
+ applyFarmCspHashesToHtml,
573
+ applyFarmCspNonceToResponse,
574
+ farmCspBlocksFrameworkInlineScripts,
575
+ createFarmCspNonceRewriter
576
+ };
@@ -27,10 +27,22 @@ function _resolveCurrentRequestForApp() {
27
27
  return request && view ? view(request) : request;
28
28
  }
29
29
  _chunkS3JO3N4Hcjs.__name.call(void 0, _resolveCurrentRequestForApp, "_resolveCurrentRequestForApp");
30
+ var CSP_NONCE_RESOLVER_KEY = /* @__PURE__ */ Symbol.for("farm.cspNonceResolver");
31
+ function _setCspNonceResolver(resolver) {
32
+ globalThis[CSP_NONCE_RESOLVER_KEY] = resolver;
33
+ }
34
+ _chunkS3JO3N4Hcjs.__name.call(void 0, _setCspNonceResolver, "_setCspNonceResolver");
35
+ function _resolveCurrentCspNonce() {
36
+ const resolver = globalThis[CSP_NONCE_RESOLVER_KEY];
37
+ return _optionalChain([resolver, 'optionalCall', _4 => _4()]);
38
+ }
39
+ _chunkS3JO3N4Hcjs.__name.call(void 0, _resolveCurrentCspNonce, "_resolveCurrentCspNonce");
40
+
41
+
30
42
 
31
43
 
32
44
 
33
45
 
34
46
 
35
47
 
36
- exports._setCurrentRequestResolver = _setCurrentRequestResolver; exports._resolveCurrentRequest = _resolveCurrentRequest; exports._setAppRequestView = _setAppRequestView; exports._resolveCurrentRequestForApp = _resolveCurrentRequestForApp;
48
+ exports._setCurrentRequestResolver = _setCurrentRequestResolver; exports._resolveCurrentRequest = _resolveCurrentRequest; exports._setAppRequestView = _setAppRequestView; exports._resolveCurrentRequestForApp = _resolveCurrentRequestForApp; exports._setCspNonceResolver = _setCspNonceResolver; exports._resolveCurrentCspNonce = _resolveCurrentCspNonce;
@@ -321,6 +321,19 @@ __name(createFarmMarkdownViewResponse, "createFarmMarkdownViewResponse");
321
321
 
322
322
  // src/markdown.ts
323
323
  var FARM_MARKDOWN_CONTENT_TYPE = "text/markdown; charset=utf-8";
324
+ var FARM_MARKDOWN_PAGE_CHECK_HEADER = "x-farm-markdown-page-check";
325
+ var MARKDOWN_PAGE_CHECK_TOKEN = /* @__PURE__ */ Symbol.for("farm.markdownPageCheckToken");
326
+ function _getFarmMarkdownPageCheckToken() {
327
+ const state = globalThis;
328
+ return state[MARKDOWN_PAGE_CHECK_TOKEN] ?? (state[MARKDOWN_PAGE_CHECK_TOKEN] = globalThis.crypto.randomUUID());
329
+ }
330
+ __name(_getFarmMarkdownPageCheckToken, "_getFarmMarkdownPageCheckToken");
331
+ function _isFarmMarkdownPageCheck(value) {
332
+ const state = globalThis;
333
+ const token = state[MARKDOWN_PAGE_CHECK_TOKEN];
334
+ return Boolean(token) && typeof value === "string" && value === token;
335
+ }
336
+ __name(_isFarmMarkdownPageCheck, "_isFarmMarkdownPageCheck");
324
337
  function farmRequestWantsMarkdown(pathname, accept) {
325
338
  return pathname.toLowerCase().endsWith(".md") || requestAcceptsMarkdown(accept);
326
339
  }
@@ -471,7 +484,7 @@ async function createMarkdownMirrorResponse(options) {
471
484
  const cache = target.route?.cache ?? options.config?.cache ?? false;
472
485
  headersOut.set(
473
486
  "Cache-Control",
474
- pageCacheControl && isPrivateCacheControl(pageCacheControl) ? pageCacheControl : createMarkdownCacheHeader(cache)
487
+ pageCacheControl && isPrivateCacheControl(pageCacheControl) ? pageCacheControl : headers.has("cookie") || headers.has("authorization") ? "private, no-store" : createMarkdownCacheHeader(cache)
475
488
  );
476
489
  preserveMarkdownResponseCookies(pageResponse.headers, headersOut);
477
490
  if (pageResponse.status >= 400) {
@@ -1345,6 +1358,9 @@ __name(decodeHtml, "decodeHtml");
1345
1358
  export {
1346
1359
  createFarmMarkdownViewResponse,
1347
1360
  FARM_MARKDOWN_CONTENT_TYPE,
1361
+ FARM_MARKDOWN_PAGE_CHECK_HEADER,
1362
+ _getFarmMarkdownPageCheckToken,
1363
+ _isFarmMarkdownPageCheck,
1348
1364
  farmRequestWantsMarkdown,
1349
1365
  createFarmMarkdownErrorBody,
1350
1366
  resolveMarkdownConfig,
@@ -7,7 +7,7 @@ import {
7
7
  isAPIRouteRef,
8
8
  resolveServerFnInvalidateTargets,
9
9
  settleServerFnOptimisticUpdates
10
- } from "./chunk-LBDP3YT3.mjs";
10
+ } from "./chunk-ARC7I3O2.mjs";
11
11
  import {
12
12
  notifyClientObserver
13
13
  } from "./chunk-72AK62H5.mjs";