@timber-js/app 0.2.0-alpha.14 → 0.2.0-alpha.141

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 (801) hide show
  1. package/dist/_chunks/actions-DzFMnUAR.js +1147 -0
  2. package/dist/_chunks/actions-DzFMnUAR.js.map +1 -0
  3. package/dist/_chunks/build-output-helper-B20ZuTSA.js +102 -0
  4. package/dist/_chunks/build-output-helper-B20ZuTSA.js.map +1 -0
  5. package/dist/_chunks/cli-schema-sync-D2IpXicg.js +785 -0
  6. package/dist/_chunks/cli-schema-sync-D2IpXicg.js.map +1 -0
  7. package/dist/_chunks/cli-schema-sync-DH-M8Poy.js +2 -0
  8. package/dist/_chunks/codec-registry-oOUxugz3.js +21 -0
  9. package/dist/_chunks/codec-registry-oOUxugz3.js.map +1 -0
  10. package/dist/_chunks/define-C3RvHQPK.js +195 -0
  11. package/dist/_chunks/define-C3RvHQPK.js.map +1 -0
  12. package/dist/_chunks/define-DMVhsipD.js +112 -0
  13. package/dist/_chunks/define-DMVhsipD.js.map +1 -0
  14. package/dist/_chunks/fast-hash-D6hIVt1Y.js +36 -0
  15. package/dist/_chunks/fast-hash-D6hIVt1Y.js.map +1 -0
  16. package/dist/_chunks/format-CfwjgPz9.js +14 -0
  17. package/dist/_chunks/format-CfwjgPz9.js.map +1 -0
  18. package/dist/_chunks/handler-store-DjISKYEB.js +54 -0
  19. package/dist/_chunks/handler-store-DjISKYEB.js.map +1 -0
  20. package/dist/_chunks/href-validation-EZktELp8.js +124 -0
  21. package/dist/_chunks/href-validation-EZktELp8.js.map +1 -0
  22. package/dist/_chunks/logger-Dt-jQaBO.js +291 -0
  23. package/dist/_chunks/logger-Dt-jQaBO.js.map +1 -0
  24. package/dist/_chunks/{metadata-routes-Cjmvi3rQ.js → metadata-routes-BjepjefT.js} +32 -19
  25. package/dist/_chunks/metadata-routes-BjepjefT.js.map +1 -0
  26. package/dist/_chunks/navigation-root-DLc4s4ZC.js +103 -0
  27. package/dist/_chunks/navigation-root-DLc4s4ZC.js.map +1 -0
  28. package/dist/_chunks/registry-DbJPKoBp.js +20 -0
  29. package/dist/_chunks/registry-DbJPKoBp.js.map +1 -0
  30. package/dist/_chunks/resolve-schema-Dj8tQloi.js +77 -0
  31. package/dist/_chunks/resolve-schema-Dj8tQloi.js.map +1 -0
  32. package/dist/_chunks/router-ref-CtmF-aPv.js +28 -0
  33. package/dist/_chunks/router-ref-CtmF-aPv.js.map +1 -0
  34. package/dist/_chunks/schema-bridge-DK_89h8O.js +86 -0
  35. package/dist/_chunks/schema-bridge-DK_89h8O.js.map +1 -0
  36. package/dist/_chunks/segment-classify-CDDRVKs7.js +137 -0
  37. package/dist/_chunks/segment-classify-CDDRVKs7.js.map +1 -0
  38. package/dist/_chunks/segment-context-ZDnXDkbz.js +34 -0
  39. package/dist/_chunks/segment-context-ZDnXDkbz.js.map +1 -0
  40. package/dist/_chunks/{ssr-data-MjmprTmO.js → ssr-data-BOWsq18U.js} +1 -1
  41. package/dist/_chunks/ssr-data-BOWsq18U.js.map +1 -0
  42. package/dist/_chunks/tracing-M_zKubhk.js +358 -0
  43. package/dist/_chunks/tracing-M_zKubhk.js.map +1 -0
  44. package/dist/_chunks/{use-query-states-D5KaffOK.js → use-query-states-CbeQmext.js} +7 -20
  45. package/dist/_chunks/use-query-states-CbeQmext.js.map +1 -0
  46. package/dist/_chunks/use-segment-params-D1CzlgBo.js +151 -0
  47. package/dist/_chunks/use-segment-params-D1CzlgBo.js.map +1 -0
  48. package/dist/_chunks/validation-taUkvA4Q.js +113 -0
  49. package/dist/_chunks/validation-taUkvA4Q.js.map +1 -0
  50. package/dist/_chunks/walkers-7FBPM-hX.js +724 -0
  51. package/dist/_chunks/walkers-7FBPM-hX.js.map +1 -0
  52. package/dist/_chunks/{format-RyoGQL74.js → warnings-CNPXaypM.js} +6 -45
  53. package/dist/_chunks/warnings-CNPXaypM.js.map +1 -0
  54. package/dist/adapters/build-output-helper.d.ts +28 -0
  55. package/dist/adapters/build-output-helper.d.ts.map +1 -0
  56. package/dist/adapters/cloudflare-dev.d.ts +109 -0
  57. package/dist/adapters/cloudflare-dev.d.ts.map +1 -0
  58. package/dist/adapters/cloudflare-dev.js +73 -0
  59. package/dist/adapters/cloudflare-dev.js.map +1 -0
  60. package/dist/adapters/cloudflare-kv-cache.d.ts +64 -0
  61. package/dist/adapters/cloudflare-kv-cache.d.ts.map +1 -0
  62. package/dist/adapters/cloudflare-kv-cache.js +95 -0
  63. package/dist/adapters/cloudflare-kv-cache.js.map +1 -0
  64. package/dist/adapters/cloudflare.d.ts +148 -12
  65. package/dist/adapters/cloudflare.d.ts.map +1 -1
  66. package/dist/adapters/cloudflare.js +142 -38
  67. package/dist/adapters/cloudflare.js.map +1 -1
  68. package/dist/adapters/compress-module.d.ts.map +1 -1
  69. package/dist/adapters/nitro.d.ts +17 -1
  70. package/dist/adapters/nitro.d.ts.map +1 -1
  71. package/dist/adapters/nitro.js +154 -48
  72. package/dist/adapters/nitro.js.map +1 -1
  73. package/dist/adapters/shared.d.ts +16 -0
  74. package/dist/adapters/shared.d.ts.map +1 -0
  75. package/dist/cache/cache-api.d.ts +24 -0
  76. package/dist/cache/cache-api.d.ts.map +1 -0
  77. package/dist/cache/handler-store.d.ts +31 -0
  78. package/dist/cache/handler-store.d.ts.map +1 -0
  79. package/dist/cache/index.d.ts +23 -7
  80. package/dist/cache/index.d.ts.map +1 -1
  81. package/dist/cache/index.js +165 -117
  82. package/dist/cache/index.js.map +1 -1
  83. package/dist/cache/singleflight.d.ts +18 -1
  84. package/dist/cache/singleflight.d.ts.map +1 -1
  85. package/dist/cache/sizeof.d.ts +22 -0
  86. package/dist/cache/sizeof.d.ts.map +1 -0
  87. package/dist/cache/timber-cache.d.ts +1 -1
  88. package/dist/cache/timber-cache.d.ts.map +1 -1
  89. package/dist/cli-schema-sync.d.ts +39 -0
  90. package/dist/cli-schema-sync.d.ts.map +1 -0
  91. package/dist/cli.d.ts +14 -2
  92. package/dist/cli.d.ts.map +1 -1
  93. package/dist/cli.js +48 -6
  94. package/dist/cli.js.map +1 -1
  95. package/dist/client/browser-dev.d.ts +34 -1
  96. package/dist/client/browser-dev.d.ts.map +1 -1
  97. package/dist/client/browser-entry/action-dispatch.d.ts +17 -0
  98. package/dist/client/browser-entry/action-dispatch.d.ts.map +1 -0
  99. package/dist/client/browser-entry/hmr.d.ts +21 -0
  100. package/dist/client/browser-entry/hmr.d.ts.map +1 -0
  101. package/dist/client/browser-entry/hydrate.d.ts +46 -0
  102. package/dist/client/browser-entry/hydrate.d.ts.map +1 -0
  103. package/dist/client/browser-entry/index.d.ts +30 -0
  104. package/dist/client/browser-entry/index.d.ts.map +1 -0
  105. package/dist/client/browser-entry/post-hydration.d.ts +26 -0
  106. package/dist/client/browser-entry/post-hydration.d.ts.map +1 -0
  107. package/dist/client/browser-entry/router-init.d.ts +26 -0
  108. package/dist/client/browser-entry/router-init.d.ts.map +1 -0
  109. package/dist/client/browser-entry/rsc-stream.d.ts +24 -0
  110. package/dist/client/browser-entry/rsc-stream.d.ts.map +1 -0
  111. package/dist/client/browser-entry/scroll.d.ts +19 -0
  112. package/dist/client/browser-entry/scroll.d.ts.map +1 -0
  113. package/dist/client/error-boundary.d.ts +12 -5
  114. package/dist/client/error-boundary.d.ts.map +1 -1
  115. package/dist/client/error-boundary.js +29 -6
  116. package/dist/client/error-boundary.js.map +1 -1
  117. package/dist/client/error-reconstituter.d.ts +54 -0
  118. package/dist/client/error-reconstituter.d.ts.map +1 -0
  119. package/dist/client/form.d.ts +16 -27
  120. package/dist/client/form.d.ts.map +1 -1
  121. package/dist/client/history.d.ts +19 -4
  122. package/dist/client/history.d.ts.map +1 -1
  123. package/dist/client/index.d.ts +10 -24
  124. package/dist/client/index.d.ts.map +1 -1
  125. package/dist/client/index.js +183 -1134
  126. package/dist/client/index.js.map +1 -1
  127. package/dist/client/internal.d.ts +19 -0
  128. package/dist/client/internal.d.ts.map +1 -0
  129. package/dist/client/internal.js +925 -0
  130. package/dist/client/internal.js.map +1 -0
  131. package/dist/client/link-pending-store.d.ts +65 -0
  132. package/dist/client/link-pending-store.d.ts.map +1 -0
  133. package/dist/client/link.d.ts +69 -60
  134. package/dist/client/link.d.ts.map +1 -1
  135. package/dist/client/nav-link-store.d.ts +27 -0
  136. package/dist/client/nav-link-store.d.ts.map +1 -0
  137. package/dist/client/navigation-api-types.d.ts +90 -0
  138. package/dist/client/navigation-api-types.d.ts.map +1 -0
  139. package/dist/client/navigation-api.d.ts +115 -0
  140. package/dist/client/navigation-api.d.ts.map +1 -0
  141. package/dist/client/navigation-context.d.ts +14 -2
  142. package/dist/client/navigation-context.d.ts.map +1 -1
  143. package/dist/client/{transition-root.d.ts → navigation-root.d.ts} +46 -9
  144. package/dist/client/navigation-root.d.ts.map +1 -0
  145. package/dist/client/nuqs-adapter.d.ts.map +1 -1
  146. package/dist/client/router-ref.d.ts +1 -1
  147. package/dist/client/router.d.ts +79 -10
  148. package/dist/client/router.d.ts.map +1 -1
  149. package/dist/client/rsc-fetch.d.ts +46 -3
  150. package/dist/client/rsc-fetch.d.ts.map +1 -1
  151. package/dist/client/segment-cache.d.ts +3 -1
  152. package/dist/client/segment-cache.d.ts.map +1 -1
  153. package/dist/client/segment-outlet.d.ts +49 -0
  154. package/dist/client/segment-outlet.d.ts.map +1 -0
  155. package/dist/client/segment-update-context.d.ts +21 -0
  156. package/dist/client/segment-update-context.d.ts.map +1 -0
  157. package/dist/client/shallow-url.d.ts +10 -0
  158. package/dist/client/shallow-url.d.ts.map +1 -0
  159. package/dist/client/ssr-data.d.ts +13 -4
  160. package/dist/client/ssr-data.d.ts.map +1 -1
  161. package/dist/client/stale-reload.d.ts +15 -0
  162. package/dist/client/stale-reload.d.ts.map +1 -1
  163. package/dist/client/state.d.ts +1 -1
  164. package/dist/client/top-loader.d.ts +5 -5
  165. package/dist/client/top-loader.d.ts.map +1 -1
  166. package/dist/client/use-cookie.d.ts +12 -0
  167. package/dist/client/use-cookie.d.ts.map +1 -1
  168. package/dist/client/use-link-status.d.ts +5 -5
  169. package/dist/client/use-link-status.d.ts.map +1 -1
  170. package/dist/client/use-pathname.d.ts.map +1 -1
  171. package/dist/client/use-pending-navigation.d.ts +23 -0
  172. package/dist/client/use-pending-navigation.d.ts.map +1 -0
  173. package/dist/client/use-query-states.d.ts +1 -1
  174. package/dist/client/use-query-states.d.ts.map +1 -1
  175. package/dist/client/use-router.d.ts +1 -1
  176. package/dist/client/use-router.d.ts.map +1 -1
  177. package/dist/client/use-search-params.d.ts +7 -5
  178. package/dist/client/use-search-params.d.ts.map +1 -1
  179. package/dist/client/{use-params.d.ts → use-segment-params.d.ts} +8 -6
  180. package/dist/client/use-segment-params.d.ts.map +1 -0
  181. package/dist/codec.d.ts +69 -0
  182. package/dist/codec.d.ts.map +1 -0
  183. package/dist/codec.js +75 -0
  184. package/dist/codec.js.map +1 -0
  185. package/dist/config-types.d.ts +294 -0
  186. package/dist/config-types.d.ts.map +1 -0
  187. package/dist/config-validation.d.ts +51 -0
  188. package/dist/config-validation.d.ts.map +1 -0
  189. package/dist/content/index.d.ts +1 -10
  190. package/dist/content/index.d.ts.map +1 -1
  191. package/dist/content/index.js +0 -2
  192. package/dist/cookies/define-cookie.d.ts +58 -25
  193. package/dist/cookies/define-cookie.d.ts.map +1 -1
  194. package/dist/cookies/index.d.ts +2 -1
  195. package/dist/cookies/index.d.ts.map +1 -1
  196. package/dist/cookies/index.js +251 -36
  197. package/dist/cookies/index.js.map +1 -1
  198. package/dist/cookies/json-cookie.d.ts +64 -0
  199. package/dist/cookies/json-cookie.d.ts.map +1 -0
  200. package/dist/cookies/validation.d.ts +34 -0
  201. package/dist/cookies/validation.d.ts.map +1 -0
  202. package/dist/dev-tools/404-page.d.ts +46 -0
  203. package/dist/dev-tools/404-page.d.ts.map +1 -0
  204. package/dist/dev-tools/browser-logs.d.ts +84 -0
  205. package/dist/dev-tools/browser-logs.d.ts.map +1 -0
  206. package/dist/dev-tools/error-page.d.ts +58 -0
  207. package/dist/dev-tools/error-page.d.ts.map +1 -0
  208. package/dist/dev-tools/holding-server.d.ts +54 -0
  209. package/dist/dev-tools/holding-server.d.ts.map +1 -0
  210. package/dist/dev-tools/index.d.ts +31 -0
  211. package/dist/dev-tools/index.d.ts.map +1 -0
  212. package/dist/{server/dev-span-processor.d.ts → dev-tools/instrumentation.d.ts} +26 -6
  213. package/dist/dev-tools/instrumentation.d.ts.map +1 -0
  214. package/dist/{server/dev-logger.d.ts → dev-tools/logger.d.ts} +1 -1
  215. package/dist/dev-tools/logger.d.ts.map +1 -0
  216. package/dist/{plugins/dev-logs.d.ts → dev-tools/logs.d.ts} +2 -2
  217. package/dist/dev-tools/logs.d.ts.map +1 -0
  218. package/dist/dev-tools/overlay.d.ts +91 -0
  219. package/dist/dev-tools/overlay.d.ts.map +1 -0
  220. package/dist/dev-tools/stack-classifier.d.ts +34 -0
  221. package/dist/dev-tools/stack-classifier.d.ts.map +1 -0
  222. package/dist/dev-tools/terminal.d.ts +28 -0
  223. package/dist/dev-tools/terminal.d.ts.map +1 -0
  224. package/dist/{server/dev-warnings.d.ts → dev-tools/warnings.d.ts} +2 -22
  225. package/dist/dev-tools/warnings.d.ts.map +1 -0
  226. package/dist/fonts/ast.d.ts +98 -6
  227. package/dist/fonts/ast.d.ts.map +1 -1
  228. package/dist/fonts/bundle.d.ts +48 -0
  229. package/dist/fonts/bundle.d.ts.map +1 -0
  230. package/dist/fonts/dev-middleware.d.ts +22 -0
  231. package/dist/fonts/dev-middleware.d.ts.map +1 -0
  232. package/dist/fonts/local.d.ts +1 -1
  233. package/dist/fonts/pipeline.d.ts +172 -0
  234. package/dist/fonts/pipeline.d.ts.map +1 -0
  235. package/dist/fonts/transform.d.ts +78 -0
  236. package/dist/fonts/transform.d.ts.map +1 -0
  237. package/dist/fonts/types.d.ts +47 -1
  238. package/dist/fonts/types.d.ts.map +1 -1
  239. package/dist/fonts/virtual-modules.d.ts +94 -0
  240. package/dist/fonts/virtual-modules.d.ts.map +1 -0
  241. package/dist/index.d.ts +46 -180
  242. package/dist/index.d.ts.map +1 -1
  243. package/dist/index.js +5315 -12687
  244. package/dist/index.js.map +1 -1
  245. package/dist/params/codec-registry.d.ts +26 -0
  246. package/dist/params/codec-registry.d.ts.map +1 -0
  247. package/dist/params/define-schema.d.ts +81 -0
  248. package/dist/params/define-schema.d.ts.map +1 -0
  249. package/dist/params/index.d.ts +5 -0
  250. package/dist/params/index.d.ts.map +1 -0
  251. package/dist/params/index.js +34 -0
  252. package/dist/params/index.js.map +1 -0
  253. package/dist/params/resolve-schema.d.ts +34 -0
  254. package/dist/params/resolve-schema.d.ts.map +1 -0
  255. package/dist/plugin-context.d.ts +114 -0
  256. package/dist/plugin-context.d.ts.map +1 -0
  257. package/dist/plugins/adapter-build.d.ts +20 -1
  258. package/dist/plugins/adapter-build.d.ts.map +1 -1
  259. package/dist/plugins/build-manifest.d.ts +7 -3
  260. package/dist/plugins/build-manifest.d.ts.map +1 -1
  261. package/dist/plugins/build-report.d.ts +9 -7
  262. package/dist/plugins/build-report.d.ts.map +1 -1
  263. package/dist/plugins/cache.d.ts +31 -0
  264. package/dist/plugins/cache.d.ts.map +1 -0
  265. package/dist/plugins/client-chunks.d.ts +39 -0
  266. package/dist/plugins/client-chunks.d.ts.map +1 -0
  267. package/dist/plugins/cloudflare-wasm.d.ts +18 -0
  268. package/dist/plugins/cloudflare-wasm.d.ts.map +1 -0
  269. package/dist/plugins/content.d.ts +1 -1
  270. package/dist/plugins/content.d.ts.map +1 -1
  271. package/dist/plugins/dev-server.d.ts +1 -1
  272. package/dist/plugins/dev-server.d.ts.map +1 -1
  273. package/dist/plugins/entries.d.ts +1 -1
  274. package/dist/plugins/entries.d.ts.map +1 -1
  275. package/dist/plugins/fonts.d.ts +17 -73
  276. package/dist/plugins/fonts.d.ts.map +1 -1
  277. package/dist/plugins/mdx.d.ts +1 -1
  278. package/dist/plugins/mdx.d.ts.map +1 -1
  279. package/dist/plugins/routing.d.ts +1 -1
  280. package/dist/plugins/routing.d.ts.map +1 -1
  281. package/dist/plugins/server-bundle.d.ts.map +1 -1
  282. package/dist/plugins/shims.d.ts +6 -5
  283. package/dist/plugins/shims.d.ts.map +1 -1
  284. package/dist/plugins/static-build.d.ts +5 -26
  285. package/dist/plugins/static-build.d.ts.map +1 -1
  286. package/dist/routing/codegen-shared.d.ts +67 -0
  287. package/dist/routing/codegen-shared.d.ts.map +1 -0
  288. package/dist/routing/codegen-types.d.ts +60 -0
  289. package/dist/routing/codegen-types.d.ts.map +1 -0
  290. package/dist/routing/codegen.d.ts +7 -2
  291. package/dist/routing/codegen.d.ts.map +1 -1
  292. package/dist/routing/convention-lint.d.ts +41 -0
  293. package/dist/routing/convention-lint.d.ts.map +1 -0
  294. package/dist/routing/index.d.ts +7 -1
  295. package/dist/routing/index.d.ts.map +1 -1
  296. package/dist/routing/index.js +4 -2
  297. package/dist/routing/link-codegen.d.ts +90 -0
  298. package/dist/routing/link-codegen.d.ts.map +1 -0
  299. package/dist/routing/scanner.d.ts +1 -10
  300. package/dist/routing/scanner.d.ts.map +1 -1
  301. package/dist/routing/schema-validation.d.ts +35 -0
  302. package/dist/routing/schema-validation.d.ts.map +1 -0
  303. package/dist/routing/segment-classify.d.ts +75 -0
  304. package/dist/routing/segment-classify.d.ts.map +1 -0
  305. package/dist/routing/segment-codegen.d.ts +38 -0
  306. package/dist/routing/segment-codegen.d.ts.map +1 -0
  307. package/dist/routing/types.d.ts +77 -25
  308. package/dist/routing/types.d.ts.map +1 -1
  309. package/dist/routing/walkers.d.ts +51 -0
  310. package/dist/routing/walkers.d.ts.map +1 -0
  311. package/dist/rsc-runtime/rsc.d.ts +1 -1
  312. package/dist/rsc-runtime/rsc.d.ts.map +1 -1
  313. package/dist/rsc-runtime/ssr.d.ts +12 -0
  314. package/dist/rsc-runtime/ssr.d.ts.map +1 -1
  315. package/dist/schema-bridge.d.ts +76 -0
  316. package/dist/schema-bridge.d.ts.map +1 -0
  317. package/dist/search-params/define.d.ts +157 -0
  318. package/dist/search-params/define.d.ts.map +1 -0
  319. package/dist/search-params/index.d.ts +4 -7
  320. package/dist/search-params/index.d.ts.map +1 -1
  321. package/dist/search-params/index.js +34 -441
  322. package/dist/search-params/index.js.map +1 -1
  323. package/dist/search-params/registry.d.ts +2 -2
  324. package/dist/search-params/registry.d.ts.map +1 -1
  325. package/dist/search-params/wrappers.d.ts +53 -0
  326. package/dist/search-params/wrappers.d.ts.map +1 -0
  327. package/dist/segment-params/define.d.ts +89 -0
  328. package/dist/segment-params/define.d.ts.map +1 -0
  329. package/dist/segment-params/index.d.ts +3 -0
  330. package/dist/segment-params/index.d.ts.map +1 -0
  331. package/dist/segment-params/index.js +2 -0
  332. package/dist/server/access-gate.d.ts +8 -3
  333. package/dist/server/access-gate.d.ts.map +1 -1
  334. package/dist/server/action-client.d.ts +41 -6
  335. package/dist/server/action-client.d.ts.map +1 -1
  336. package/dist/server/action-encryption.d.ts +76 -0
  337. package/dist/server/action-encryption.d.ts.map +1 -0
  338. package/dist/server/action-handler.d.ts +35 -1
  339. package/dist/server/action-handler.d.ts.map +1 -1
  340. package/dist/server/actions.d.ts +6 -14
  341. package/dist/server/actions.d.ts.map +1 -1
  342. package/dist/server/als-registry.d.ts +70 -11
  343. package/dist/server/als-registry.d.ts.map +1 -1
  344. package/dist/server/asset-headers.d.ts +1 -15
  345. package/dist/server/asset-headers.d.ts.map +1 -1
  346. package/dist/server/body-limits.d.ts.map +1 -1
  347. package/dist/server/build-manifest.d.ts +8 -2
  348. package/dist/server/build-manifest.d.ts.map +1 -1
  349. package/dist/server/coalesce-tick.d.ts +40 -0
  350. package/dist/server/coalesce-tick.d.ts.map +1 -0
  351. package/dist/server/cookie-context.d.ts +170 -0
  352. package/dist/server/cookie-context.d.ts.map +1 -0
  353. package/dist/server/cookie-parsing.d.ts +51 -0
  354. package/dist/server/cookie-parsing.d.ts.map +1 -0
  355. package/dist/server/csrf.d.ts +3 -2
  356. package/dist/server/csrf.d.ts.map +1 -1
  357. package/dist/server/default-logger.d.ts +22 -0
  358. package/dist/server/default-logger.d.ts.map +1 -0
  359. package/dist/server/deny-boundary.d.ts +90 -0
  360. package/dist/server/deny-boundary.d.ts.map +1 -0
  361. package/dist/server/deny-renderer.d.ts +1 -1
  362. package/dist/server/deny-renderer.d.ts.map +1 -1
  363. package/dist/server/dev-source-map.d.ts +22 -0
  364. package/dist/server/dev-source-map.d.ts.map +1 -0
  365. package/dist/server/early-hints-sender.d.ts.map +1 -1
  366. package/dist/server/early-hints.d.ts +13 -11
  367. package/dist/server/early-hints.d.ts.map +1 -1
  368. package/dist/server/error-boundary-wrapper.d.ts +7 -1
  369. package/dist/server/error-boundary-wrapper.d.ts.map +1 -1
  370. package/dist/server/fallback-error.d.ts +12 -7
  371. package/dist/server/fallback-error.d.ts.map +1 -1
  372. package/dist/server/flight-injection-state.d.ts +66 -0
  373. package/dist/server/flight-injection-state.d.ts.map +1 -0
  374. package/dist/server/flight-scripts.d.ts +42 -0
  375. package/dist/server/flight-scripts.d.ts.map +1 -0
  376. package/dist/server/flush.d.ts.map +1 -1
  377. package/dist/server/form-data.d.ts +29 -0
  378. package/dist/server/form-data.d.ts.map +1 -1
  379. package/dist/server/html-injector-core.d.ts +213 -0
  380. package/dist/server/html-injector-core.d.ts.map +1 -0
  381. package/dist/server/html-injectors.d.ts +81 -41
  382. package/dist/server/html-injectors.d.ts.map +1 -1
  383. package/dist/server/index.d.ts +10 -46
  384. package/dist/server/index.d.ts.map +1 -1
  385. package/dist/server/index.js +170 -2911
  386. package/dist/server/index.js.map +1 -1
  387. package/dist/server/internal.d.ts +48 -0
  388. package/dist/server/internal.d.ts.map +1 -0
  389. package/dist/server/internal.js +3126 -0
  390. package/dist/server/internal.js.map +1 -0
  391. package/dist/server/logger.d.ts +39 -7
  392. package/dist/server/logger.d.ts.map +1 -1
  393. package/dist/server/metadata-routes.d.ts +23 -7
  394. package/dist/server/metadata-routes.d.ts.map +1 -1
  395. package/dist/server/middleware-runner.d.ts +36 -4
  396. package/dist/server/middleware-runner.d.ts.map +1 -1
  397. package/dist/server/node-stream-transforms.d.ts +112 -0
  398. package/dist/server/node-stream-transforms.d.ts.map +1 -0
  399. package/dist/server/param-coercion.d.ts +54 -0
  400. package/dist/server/param-coercion.d.ts.map +1 -0
  401. package/dist/server/pipeline-helpers.d.ts +95 -0
  402. package/dist/server/pipeline-helpers.d.ts.map +1 -0
  403. package/dist/server/pipeline-interception.d.ts +1 -1
  404. package/dist/server/pipeline-interception.d.ts.map +1 -1
  405. package/dist/server/pipeline-metadata.d.ts +6 -0
  406. package/dist/server/pipeline-metadata.d.ts.map +1 -1
  407. package/dist/server/pipeline-outcome.d.ts +49 -0
  408. package/dist/server/pipeline-outcome.d.ts.map +1 -0
  409. package/dist/server/pipeline-phases.d.ts +56 -0
  410. package/dist/server/pipeline-phases.d.ts.map +1 -0
  411. package/dist/server/pipeline.d.ts +111 -19
  412. package/dist/server/pipeline.d.ts.map +1 -1
  413. package/dist/server/port-resolution.d.ts +117 -0
  414. package/dist/server/port-resolution.d.ts.map +1 -0
  415. package/dist/server/primitives.d.ts +74 -20
  416. package/dist/server/primitives.d.ts.map +1 -1
  417. package/dist/server/render-timeout.d.ts +51 -0
  418. package/dist/server/render-timeout.d.ts.map +1 -0
  419. package/dist/server/request-context.d.ts +62 -107
  420. package/dist/server/request-context.d.ts.map +1 -1
  421. package/dist/server/route-element-builder.d.ts +28 -2
  422. package/dist/server/route-element-builder.d.ts.map +1 -1
  423. package/dist/server/route-handler.d.ts.map +1 -1
  424. package/dist/server/route-matcher.d.ts +25 -36
  425. package/dist/server/route-matcher.d.ts.map +1 -1
  426. package/dist/server/rsc-entry/action-middleware-runner.d.ts +66 -0
  427. package/dist/server/rsc-entry/action-middleware-runner.d.ts.map +1 -0
  428. package/dist/server/rsc-entry/api-handler.d.ts +12 -3
  429. package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
  430. package/dist/server/rsc-entry/error-renderer.d.ts +26 -13
  431. package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
  432. package/dist/server/rsc-entry/helpers.d.ts +50 -6
  433. package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
  434. package/dist/server/rsc-entry/index.d.ts +19 -8
  435. package/dist/server/rsc-entry/index.d.ts.map +1 -1
  436. package/dist/server/rsc-entry/render-route.d.ts +50 -0
  437. package/dist/server/rsc-entry/render-route.d.ts.map +1 -0
  438. package/dist/server/rsc-entry/revalidate-renderer.d.ts +108 -0
  439. package/dist/server/rsc-entry/revalidate-renderer.d.ts.map +1 -0
  440. package/dist/server/rsc-entry/rsc-payload.d.ts +3 -3
  441. package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
  442. package/dist/server/rsc-entry/rsc-stream.d.ts +17 -1
  443. package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
  444. package/dist/server/rsc-entry/ssr-bridge.d.ts +5 -1
  445. package/dist/server/rsc-entry/ssr-bridge.d.ts.map +1 -1
  446. package/dist/server/rsc-entry/ssr-renderer.d.ts +34 -4
  447. package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
  448. package/dist/server/rsc-entry/wrap-action-dispatch.d.ts +119 -0
  449. package/dist/server/rsc-entry/wrap-action-dispatch.d.ts.map +1 -0
  450. package/dist/server/safe-load.d.ts +46 -0
  451. package/dist/server/safe-load.d.ts.map +1 -0
  452. package/dist/server/sensitive-fields.d.ts +74 -0
  453. package/dist/server/sensitive-fields.d.ts.map +1 -0
  454. package/dist/server/sitemap-generator.d.ts +129 -0
  455. package/dist/server/sitemap-generator.d.ts.map +1 -0
  456. package/dist/server/sitemap-handler.d.ts +22 -0
  457. package/dist/server/sitemap-handler.d.ts.map +1 -0
  458. package/dist/server/slot-resolver.d.ts +1 -1
  459. package/dist/server/slot-resolver.d.ts.map +1 -1
  460. package/dist/server/ssr-bridge-types.d.ts +121 -0
  461. package/dist/server/ssr-bridge-types.d.ts.map +1 -0
  462. package/dist/server/ssr-entry.d.ts +2 -43
  463. package/dist/server/ssr-entry.d.ts.map +1 -1
  464. package/dist/server/ssr-render.d.ts +64 -21
  465. package/dist/server/ssr-render.d.ts.map +1 -1
  466. package/dist/server/ssr-wrappers.d.ts +50 -0
  467. package/dist/server/ssr-wrappers.d.ts.map +1 -0
  468. package/dist/server/state-tree-diff.d.ts +12 -5
  469. package/dist/server/state-tree-diff.d.ts.map +1 -1
  470. package/dist/server/status-code-resolver.d.ts +16 -11
  471. package/dist/server/status-code-resolver.d.ts.map +1 -1
  472. package/dist/server/stream-utils.d.ts +36 -0
  473. package/dist/server/stream-utils.d.ts.map +1 -0
  474. package/dist/server/tracing.d.ts +5 -5
  475. package/dist/server/tracing.d.ts.map +1 -1
  476. package/dist/server/tree-builder.d.ts +62 -30
  477. package/dist/server/tree-builder.d.ts.map +1 -1
  478. package/dist/server/tree-match.d.ts +49 -0
  479. package/dist/server/tree-match.d.ts.map +1 -0
  480. package/dist/server/types.d.ts +71 -6
  481. package/dist/server/types.d.ts.map +1 -1
  482. package/dist/server/utils/escape-html.d.ts +14 -0
  483. package/dist/server/utils/escape-html.d.ts.map +1 -0
  484. package/dist/server/version-skew.d.ts +61 -0
  485. package/dist/server/version-skew.d.ts.map +1 -0
  486. package/dist/shared/href-validation.d.ts +38 -0
  487. package/dist/shared/href-validation.d.ts.map +1 -0
  488. package/dist/shared/merge-search-params.d.ts +22 -0
  489. package/dist/shared/merge-search-params.d.ts.map +1 -0
  490. package/dist/shims/font-google.d.ts +1 -1
  491. package/dist/shims/font-google.d.ts.map +1 -1
  492. package/dist/shims/font-google.js +42 -0
  493. package/dist/shims/font-google.js.map +1 -0
  494. package/dist/shims/font-local.d.ts +26 -0
  495. package/dist/shims/font-local.d.ts.map +1 -0
  496. package/dist/shims/font-local.js +20 -0
  497. package/dist/shims/font-local.js.map +1 -0
  498. package/dist/shims/headers.d.ts +2 -1
  499. package/dist/shims/headers.d.ts.map +1 -1
  500. package/dist/shims/image.d.ts +1 -1
  501. package/dist/shims/navigation-client.d.ts +3 -1
  502. package/dist/shims/navigation-client.d.ts.map +1 -1
  503. package/dist/shims/navigation.d.ts +11 -5
  504. package/dist/shims/navigation.d.ts.map +1 -1
  505. package/dist/utils/state-machine.d.ts +80 -0
  506. package/dist/utils/state-machine.d.ts.map +1 -0
  507. package/package.json +63 -22
  508. package/src/adapters/build-output-helper.ts +139 -0
  509. package/src/adapters/cloudflare-dev.ts +177 -0
  510. package/src/adapters/cloudflare-kv-cache.ts +142 -0
  511. package/src/adapters/cloudflare.ts +350 -76
  512. package/src/adapters/compress-module.ts +24 -4
  513. package/src/adapters/nitro.ts +147 -60
  514. package/src/adapters/shared.ts +40 -0
  515. package/src/adapters/wrangler.d.ts +7 -0
  516. package/src/cache/cache-api.ts +39 -0
  517. package/src/cache/handler-store.ts +68 -0
  518. package/src/cache/index.ts +81 -18
  519. package/src/cache/singleflight.ts +62 -4
  520. package/src/cache/sizeof.ts +33 -0
  521. package/src/cache/timber-cache.ts +52 -24
  522. package/src/cli-schema-sync.ts +295 -0
  523. package/src/cli.ts +76 -8
  524. package/src/client/browser-dev.ts +153 -1
  525. package/src/client/browser-entry/action-dispatch.ts +125 -0
  526. package/src/client/browser-entry/hmr.ts +81 -0
  527. package/src/client/browser-entry/hydrate.ts +153 -0
  528. package/src/client/browser-entry/index.ts +151 -0
  529. package/src/client/browser-entry/post-hydration.ts +113 -0
  530. package/src/client/browser-entry/router-init.ts +219 -0
  531. package/src/client/browser-entry/rsc-stream.ts +157 -0
  532. package/src/client/browser-entry/scroll.ts +27 -0
  533. package/src/client/error-boundary.tsx +99 -22
  534. package/src/client/error-reconstituter.tsx +65 -0
  535. package/src/client/form.tsx +31 -32
  536. package/src/client/history.ts +26 -4
  537. package/src/client/index.ts +67 -45
  538. package/src/client/internal.ts +58 -0
  539. package/src/client/link-pending-store.ts +116 -0
  540. package/src/client/link.tsx +343 -150
  541. package/src/client/nav-link-store.ts +37 -0
  542. package/src/client/navigation-api-types.ts +112 -0
  543. package/src/client/navigation-api.ts +338 -0
  544. package/src/client/navigation-context.ts +35 -7
  545. package/src/client/navigation-root.tsx +347 -0
  546. package/src/client/nuqs-adapter.tsx +16 -3
  547. package/src/client/router-ref.ts +1 -1
  548. package/src/client/router.ts +418 -128
  549. package/src/client/rsc-fetch.ts +208 -10
  550. package/src/client/segment-cache.ts +6 -3
  551. package/src/client/segment-outlet.tsx +77 -0
  552. package/src/client/segment-update-context.ts +42 -0
  553. package/src/client/shallow-url.ts +22 -0
  554. package/src/client/ssr-data.ts +13 -5
  555. package/src/client/stale-reload.ts +72 -3
  556. package/src/client/state.ts +2 -2
  557. package/src/client/top-loader.tsx +11 -9
  558. package/src/client/use-cookie.ts +31 -2
  559. package/src/client/use-link-status.ts +7 -7
  560. package/src/client/use-pathname.ts +1 -0
  561. package/src/client/use-pending-navigation.ts +40 -0
  562. package/src/client/use-query-states.ts +9 -3
  563. package/src/client/use-router.ts +4 -1
  564. package/src/client/use-search-params.ts +26 -44
  565. package/src/client/{use-params.ts → use-segment-params.ts} +9 -6
  566. package/src/codec.ts +147 -0
  567. package/src/config-types.ts +292 -0
  568. package/src/config-validation.ts +303 -0
  569. package/src/content/index.ts +5 -13
  570. package/src/cookies/define-cookie.ts +233 -53
  571. package/src/cookies/index.ts +12 -1
  572. package/src/cookies/json-cookie.ts +105 -0
  573. package/src/cookies/validation.ts +192 -0
  574. package/src/dev-tools/404-page.ts +387 -0
  575. package/src/dev-tools/browser-logs.ts +291 -0
  576. package/src/dev-tools/error-page.ts +507 -0
  577. package/src/dev-tools/holding-server.ts +187 -0
  578. package/src/dev-tools/index.ts +90 -0
  579. package/src/dev-tools/instrumentation.ts +176 -0
  580. package/src/{plugins/dev-logs.ts → dev-tools/logs.ts} +9 -5
  581. package/src/dev-tools/overlay.ts +469 -0
  582. package/src/dev-tools/stack-classifier.ts +75 -0
  583. package/src/dev-tools/terminal.ts +183 -0
  584. package/src/{server/dev-warnings.ts → dev-tools/warnings.ts} +5 -50
  585. package/src/fonts/ast.ts +525 -16
  586. package/src/fonts/bundle.ts +131 -0
  587. package/src/fonts/dev-middleware.ts +74 -0
  588. package/src/fonts/local.ts +3 -3
  589. package/src/fonts/pipeline.ts +337 -0
  590. package/src/fonts/transform.ts +317 -0
  591. package/src/fonts/types.ts +52 -1
  592. package/src/fonts/virtual-modules.ts +235 -0
  593. package/src/index.ts +415 -345
  594. package/src/params/codec-registry.ts +34 -0
  595. package/src/params/define-schema.ts +115 -0
  596. package/src/params/index.ts +17 -0
  597. package/src/params/resolve-schema.ts +116 -0
  598. package/src/plugin-context.ts +247 -0
  599. package/src/plugins/adapter-build.ts +98 -4
  600. package/src/plugins/build-manifest.ts +168 -23
  601. package/src/plugins/build-report.ts +16 -25
  602. package/src/plugins/cache.ts +180 -0
  603. package/src/plugins/client-chunks.ts +113 -0
  604. package/src/plugins/cloudflare-wasm.ts +103 -0
  605. package/src/plugins/content.ts +1 -1
  606. package/src/plugins/dev-server.ts +179 -37
  607. package/src/plugins/entries.ts +110 -8
  608. package/src/plugins/fonts.ts +167 -655
  609. package/src/plugins/mdx.ts +47 -10
  610. package/src/plugins/routing.ts +386 -47
  611. package/src/plugins/server-bundle.ts +59 -3
  612. package/src/plugins/shims.ts +136 -35
  613. package/src/plugins/static-build.ts +15 -89
  614. package/src/routing/codegen-shared.ts +115 -0
  615. package/src/routing/codegen-types.ts +61 -0
  616. package/src/routing/codegen.ts +321 -177
  617. package/src/routing/convention-lint.ts +357 -0
  618. package/src/routing/index.ts +10 -1
  619. package/src/routing/interception.ts +1 -1
  620. package/src/routing/link-codegen.ts +310 -0
  621. package/src/routing/scanner.ts +165 -110
  622. package/src/routing/schema-validation.ts +149 -0
  623. package/src/routing/segment-classify.ts +188 -0
  624. package/src/routing/segment-codegen.ts +98 -0
  625. package/src/routing/types.ts +78 -25
  626. package/src/routing/walkers.ts +90 -0
  627. package/src/rsc-runtime/rsc.ts +2 -0
  628. package/src/rsc-runtime/ssr.ts +50 -0
  629. package/src/rsc-runtime/vendor-types.d.ts +7 -0
  630. package/src/{search-params/codecs.ts → schema-bridge.ts} +60 -22
  631. package/src/search-params/define.ts +538 -0
  632. package/src/search-params/index.ts +14 -20
  633. package/src/search-params/registry.ts +2 -2
  634. package/src/search-params/wrappers.ts +92 -0
  635. package/src/segment-params/define.ts +309 -0
  636. package/src/segment-params/index.ts +9 -0
  637. package/src/server/access-gate.tsx +76 -34
  638. package/src/server/action-client.ts +119 -28
  639. package/src/server/action-encryption.ts +144 -0
  640. package/src/server/action-handler.ts +112 -14
  641. package/src/server/actions.ts +34 -26
  642. package/src/server/als-registry.ts +108 -20
  643. package/src/server/asset-headers.ts +8 -34
  644. package/src/server/body-limits.ts +10 -2
  645. package/src/server/build-manifest.ts +17 -4
  646. package/src/server/coalesce-tick.ts +75 -0
  647. package/src/server/compress.ts +25 -7
  648. package/src/server/cookie-context.ts +473 -0
  649. package/src/server/cookie-parsing.ts +135 -0
  650. package/src/server/csrf.ts +39 -6
  651. package/src/server/default-logger.ts +99 -0
  652. package/src/server/deny-boundary.ts +218 -0
  653. package/src/server/deny-renderer.ts +32 -52
  654. package/src/server/dev-source-map.ts +31 -0
  655. package/src/server/early-hints-sender.ts +3 -2
  656. package/src/server/early-hints.ts +35 -27
  657. package/src/server/error-boundary-wrapper.ts +74 -22
  658. package/src/server/fallback-error.ts +74 -102
  659. package/src/server/flight-injection-state.ts +113 -0
  660. package/src/server/flight-scripts.ts +62 -0
  661. package/src/server/flush.ts +2 -1
  662. package/src/server/form-data.ts +101 -5
  663. package/src/server/html-injector-core.ts +418 -0
  664. package/src/server/html-injectors.ts +238 -223
  665. package/src/server/index.ts +29 -183
  666. package/src/server/internal.ts +182 -0
  667. package/src/server/logger.ts +67 -36
  668. package/src/server/metadata-routes.ts +44 -19
  669. package/src/server/middleware-runner.ts +75 -4
  670. package/src/server/node-stream-transforms.ts +361 -0
  671. package/src/server/param-coercion.ts +206 -0
  672. package/src/server/pipeline-helpers.ts +204 -0
  673. package/src/server/pipeline-interception.ts +32 -18
  674. package/src/server/pipeline-metadata.ts +13 -0
  675. package/src/server/pipeline-outcome.ts +197 -0
  676. package/src/server/pipeline-phases.ts +527 -0
  677. package/src/server/pipeline.ts +201 -382
  678. package/src/server/port-resolution.ts +215 -0
  679. package/src/server/primitives.ts +130 -46
  680. package/src/server/render-timeout.ts +108 -0
  681. package/src/server/request-context.ts +168 -337
  682. package/src/server/route-element-builder.ts +437 -208
  683. package/src/server/route-handler.ts +31 -4
  684. package/src/server/route-matcher.ts +128 -277
  685. package/src/server/rsc-entry/action-middleware-runner.ts +167 -0
  686. package/src/server/rsc-entry/api-handler.ts +69 -32
  687. package/src/server/rsc-entry/error-renderer.ts +316 -89
  688. package/src/server/rsc-entry/helpers.ts +155 -26
  689. package/src/server/rsc-entry/index.ts +283 -329
  690. package/src/server/rsc-entry/render-route.ts +313 -0
  691. package/src/server/rsc-entry/revalidate-renderer.ts +344 -0
  692. package/src/server/rsc-entry/rsc-payload.ts +65 -22
  693. package/src/server/rsc-entry/rsc-stream.ts +85 -13
  694. package/src/server/rsc-entry/ssr-bridge.ts +18 -5
  695. package/src/server/rsc-entry/ssr-renderer.ts +271 -41
  696. package/src/server/rsc-entry/wrap-action-dispatch.ts +449 -0
  697. package/src/server/safe-load.ts +60 -0
  698. package/src/server/sensitive-fields.ts +230 -0
  699. package/src/server/sitemap-generator.ts +338 -0
  700. package/src/server/sitemap-handler.ts +148 -0
  701. package/src/server/slot-resolver.ts +234 -246
  702. package/src/server/ssr-bridge-types.ts +124 -0
  703. package/src/server/ssr-entry.ts +217 -78
  704. package/src/server/ssr-render.ts +344 -71
  705. package/src/server/ssr-wrappers.tsx +141 -0
  706. package/src/server/state-tree-diff.ts +30 -23
  707. package/src/server/status-code-resolver.ts +112 -128
  708. package/src/server/stream-utils.ts +213 -0
  709. package/src/server/tracing.ts +21 -10
  710. package/src/server/tree-builder.ts +204 -90
  711. package/src/server/tree-match.ts +210 -0
  712. package/src/server/types.ts +78 -9
  713. package/src/server/utils/escape-html.ts +20 -0
  714. package/src/server/version-skew.ts +104 -0
  715. package/src/shared/href-validation.ts +127 -0
  716. package/src/shared/merge-search-params.ts +55 -0
  717. package/src/shims/font-google.ts +1 -1
  718. package/src/shims/font-local.ts +34 -0
  719. package/src/shims/headers.ts +5 -1
  720. package/src/shims/navigation-client.ts +4 -3
  721. package/src/shims/navigation.ts +14 -7
  722. package/src/utils/state-machine.ts +111 -0
  723. package/LICENSE +0 -8
  724. package/dist/_chunks/als-registry-B7DbZ2hS.js +0 -41
  725. package/dist/_chunks/als-registry-B7DbZ2hS.js.map +0 -1
  726. package/dist/_chunks/debug-B3Gypr3D.js +0 -108
  727. package/dist/_chunks/debug-B3Gypr3D.js.map +0 -1
  728. package/dist/_chunks/format-RyoGQL74.js.map +0 -1
  729. package/dist/_chunks/interception-BOoWmLUA.js +0 -676
  730. package/dist/_chunks/interception-BOoWmLUA.js.map +0 -1
  731. package/dist/_chunks/metadata-routes-Cjmvi3rQ.js.map +0 -1
  732. package/dist/_chunks/request-context-BQUC8PHn.js +0 -330
  733. package/dist/_chunks/request-context-BQUC8PHn.js.map +0 -1
  734. package/dist/_chunks/ssr-data-MjmprTmO.js.map +0 -1
  735. package/dist/_chunks/tracing-CemImE6h.js +0 -187
  736. package/dist/_chunks/tracing-CemImE6h.js.map +0 -1
  737. package/dist/_chunks/use-cookie-DX-l1_5E.js +0 -91
  738. package/dist/_chunks/use-cookie-DX-l1_5E.js.map +0 -1
  739. package/dist/_chunks/use-query-states-D5KaffOK.js.map +0 -1
  740. package/dist/cache/register-cached-function.d.ts +0 -17
  741. package/dist/cache/register-cached-function.d.ts.map +0 -1
  742. package/dist/client/browser-entry.d.ts +0 -21
  743. package/dist/client/browser-entry.d.ts.map +0 -1
  744. package/dist/client/link-status-provider.d.ts +0 -11
  745. package/dist/client/link-status-provider.d.ts.map +0 -1
  746. package/dist/client/segment-merger.d.ts +0 -119
  747. package/dist/client/segment-merger.d.ts.map +0 -1
  748. package/dist/client/transition-root.d.ts.map +0 -1
  749. package/dist/client/use-navigation-pending.d.ts +0 -26
  750. package/dist/client/use-navigation-pending.d.ts.map +0 -1
  751. package/dist/client/use-params.d.ts.map +0 -1
  752. package/dist/plugins/cache-transform.d.ts +0 -36
  753. package/dist/plugins/cache-transform.d.ts.map +0 -1
  754. package/dist/plugins/dev-error-overlay.d.ts +0 -60
  755. package/dist/plugins/dev-error-overlay.d.ts.map +0 -1
  756. package/dist/plugins/dev-logs.d.ts.map +0 -1
  757. package/dist/plugins/dynamic-transform.d.ts +0 -72
  758. package/dist/plugins/dynamic-transform.d.ts.map +0 -1
  759. package/dist/plugins/server-action-exports.d.ts +0 -26
  760. package/dist/plugins/server-action-exports.d.ts.map +0 -1
  761. package/dist/routing/status-file-lint.d.ts +0 -33
  762. package/dist/routing/status-file-lint.d.ts.map +0 -1
  763. package/dist/search-params/analyze.d.ts +0 -54
  764. package/dist/search-params/analyze.d.ts.map +0 -1
  765. package/dist/search-params/builtin-codecs.d.ts +0 -105
  766. package/dist/search-params/builtin-codecs.d.ts.map +0 -1
  767. package/dist/search-params/codecs.d.ts +0 -53
  768. package/dist/search-params/codecs.d.ts.map +0 -1
  769. package/dist/search-params/create.d.ts +0 -106
  770. package/dist/search-params/create.d.ts.map +0 -1
  771. package/dist/server/dev-fetch-instrumentation.d.ts +0 -22
  772. package/dist/server/dev-fetch-instrumentation.d.ts.map +0 -1
  773. package/dist/server/dev-logger.d.ts.map +0 -1
  774. package/dist/server/dev-span-processor.d.ts.map +0 -1
  775. package/dist/server/dev-warnings.d.ts.map +0 -1
  776. package/dist/server/manifest-status-resolver.d.ts +0 -58
  777. package/dist/server/manifest-status-resolver.d.ts.map +0 -1
  778. package/dist/server/prerender.d.ts +0 -77
  779. package/dist/server/prerender.d.ts.map +0 -1
  780. package/dist/utils/directive-parser.d.ts +0 -70
  781. package/dist/utils/directive-parser.d.ts.map +0 -1
  782. package/src/cache/register-cached-function.ts +0 -103
  783. package/src/client/browser-entry.ts +0 -678
  784. package/src/client/link-status-provider.tsx +0 -30
  785. package/src/client/segment-merger.ts +0 -339
  786. package/src/client/transition-root.tsx +0 -166
  787. package/src/client/use-navigation-pending.ts +0 -38
  788. package/src/plugins/cache-transform.ts +0 -199
  789. package/src/plugins/dev-error-overlay.ts +0 -230
  790. package/src/plugins/dynamic-transform.ts +0 -161
  791. package/src/plugins/server-action-exports.ts +0 -220
  792. package/src/routing/status-file-lint.ts +0 -112
  793. package/src/search-params/analyze.ts +0 -192
  794. package/src/search-params/builtin-codecs.ts +0 -228
  795. package/src/search-params/create.ts +0 -321
  796. package/src/server/dev-fetch-instrumentation.ts +0 -96
  797. package/src/server/dev-span-processor.ts +0 -78
  798. package/src/server/manifest-status-resolver.ts +0 -215
  799. package/src/server/prerender.ts +0 -139
  800. package/src/utils/directive-parser.ts +0 -529
  801. /package/src/{server/dev-logger.ts → dev-tools/logger.ts} +0 -0
@@ -0,0 +1,473 @@
1
+ /**
2
+ * Cookie Context — per-request cookie API and on-the-wire helpers.
3
+ *
4
+ * Split out of `request-context.ts` (TIM-853) so the cookie subsystem
5
+ * — encoding contract, options grammar, parser, serializer, RYW map,
6
+ * and rerender seed — lives in one file. The headers/scope/params APIs
7
+ * stay in `request-context.ts` and call into this module via the
8
+ * exported helpers.
9
+ *
10
+ * See design/29-cookies.md for the encoding contract and read-your-own-
11
+ * writes semantics. See ONGOING_SECURITY.md H-3 (TIM-868) for the
12
+ * smuggling primitive that the encoding contract closes.
13
+ */
14
+
15
+ import { requestContextAls, type RequestContextStore } from './als-registry.js';
16
+ import { isDebug } from './debug.js';
17
+ import {
18
+ assertValidCookieName,
19
+ assertValidCookieValue,
20
+ assertValidCookieOptions,
21
+ } from '../cookies/validation.js';
22
+ import {
23
+ parseCookieHeader,
24
+ parseSetCookie,
25
+ safeDecodeCookieValue,
26
+ serializeCookieEntry,
27
+ } from './cookie-parsing.js';
28
+
29
+ // Re-export the validators so framework-internal consumers and tests can
30
+ // import the canonical implementation from the same module that hosts
31
+ // `getCookies()`. The pure shared module lives in `cookies/validation.ts`
32
+ // so the client `useCookie` hook can use the same checks without pulling
33
+ // in the server ALS code.
34
+ export { assertValidCookieName, assertValidCookieValue, assertValidCookieOptions };
35
+
36
+ // ─── Public API ───────────────────────────────────────────────────────────
37
+
38
+ /**
39
+ * Returns a cookie accessor for the current request.
40
+ *
41
+ * Available in middleware, access checks, server components, and server actions.
42
+ * Throws if called outside a request context (security principle #2: no global fallback).
43
+ *
44
+ * Read methods (.get, .has, .getAll) are always available and reflect
45
+ * read-your-own-writes from .set() calls in the same request.
46
+ *
47
+ * Mutation methods (.set, .delete, .clear) are only available in mutable
48
+ * contexts (middleware.ts, server actions, route.ts handlers). Calling them
49
+ * in read-only contexts (access.ts, server components) throws.
50
+ *
51
+ * This is the escape hatch for direct cookie jar operations. For typed
52
+ * cookie access, use `defineCookie()` instead.
53
+ *
54
+ * See design/29-cookies.md
55
+ */
56
+ export function getCookieJar(): RequestCookies {
57
+ const store = requestContextAls.getStore();
58
+ if (!store) {
59
+ throw new Error(
60
+ '[timber] getCookieJar() called outside of a request context. ' +
61
+ 'It can only be used in middleware, access checks, server components, and server actions.'
62
+ );
63
+ }
64
+
65
+ // Parse cookies lazily on first access
66
+ if (!store.parsedCookies) {
67
+ store.parsedCookies = parseCookieHeader(store.cookieHeader);
68
+ }
69
+
70
+ const map = store.parsedCookies;
71
+ return {
72
+ get(name: string): string | undefined {
73
+ return map.get(name);
74
+ },
75
+ has(name: string): boolean {
76
+ return map.has(name);
77
+ },
78
+ getAll(): Array<{ name: string; value: string }> {
79
+ return Array.from(map.entries()).map(([name, value]) => ({ name, value }));
80
+ },
81
+ get size(): number {
82
+ return map.size;
83
+ },
84
+
85
+ set(name: string, value: string, options?: SetCookieOptions): void {
86
+ assertMutable(store, 'set');
87
+ // Validate the name first — names cannot be URL-encoded (RFC 7230
88
+ // token grammar is strict), so a bad name is always a bug.
89
+ assertValidCookieName(name);
90
+ // Type guard with a guiding error. The single most common mistake
91
+ // is passing a non-string (object, number, Date) and expecting the
92
+ // framework to JSON-encode. Point developers at jsonCookieCodec.
93
+ if (typeof value !== 'string') {
94
+ throw new Error(
95
+ `[timber] getCookieJar().set(${JSON.stringify(name)}, …): value must be a string, got ${typeof value}.\n` +
96
+ ` To store a JSON-serializable value, use defineCookie + jsonCookieCodec:\n` +
97
+ `\n` +
98
+ ` import { defineCookie, jsonCookieCodec } from '@timber-js/app/cookies';\n` +
99
+ `\n` +
100
+ ` export const ${name}Cookie = defineCookie(${JSON.stringify(name)}, {\n` +
101
+ ` codec: jsonCookieCodec(),\n` +
102
+ ` });\n` +
103
+ `\n` +
104
+ ` ${name}Cookie.set(value);\n` +
105
+ `\n` +
106
+ ` See design/29-cookies.md §"Typed Cookies with Schema Validation".`
107
+ );
108
+ }
109
+ // Encode the value so the on-the-wire bytes always satisfy
110
+ // RFC 6265 §4.1.1 cookie-octet. encodeURIComponent's output is a
111
+ // strict subset of cookie-octet (only `A-Z a-z 0-9 ! ' ( ) * - . _
112
+ // ~ %`), so the encoded form can never carry the H-3 smuggling
113
+ // primitive — `;` becomes `%3B`, CR/LF become `%0D`/`%0A`, etc.
114
+ // The round-trip is lossless: parseCookieHeader auto-decodes on
115
+ // read, so `cookies().get(name)` returns exactly `value`. See
116
+ // ONGOING_SECURITY.md H-3 (TIM-868) and design/29-cookies.md
117
+ // §"Encoding Contract".
118
+ //
119
+ // The `{ raw: true }` opt-out skips the encoder for callers who
120
+ // need exact byte control (e.g. forwarding pre-encoded cookies
121
+ // from an upstream service). The opt-out goes through the strict
122
+ // cookie-octet validator instead — the smuggling primitive cannot
123
+ // sneak in via the escape hatch.
124
+ const raw = options?.raw === true;
125
+ const wireValue = raw ? value : encodeURIComponent(value);
126
+ if (raw) {
127
+ assertValidCookieValue(name, wireValue);
128
+ }
129
+ if (store.flushed) {
130
+ if (isDebug()) {
131
+ console.warn(
132
+ `[timber] warn: getCookieJar().set('${name}') called after response headers were committed.\n` +
133
+ ` The cookie will NOT be sent. Move cookie mutations to middleware.ts, a server action,\n` +
134
+ ` or a route.ts handler.`
135
+ );
136
+ }
137
+ return;
138
+ }
139
+ // Strip the framework-only `raw` flag before persisting — it is
140
+ // not an HTTP cookie attribute and must not leak into the jar.
141
+ const { raw: _raw, ...attributeOptions } = options ?? {};
142
+ void _raw;
143
+ const opts = { ...DEFAULT_COOKIE_OPTIONS, ...attributeOptions };
144
+ assertValidCookieOptions(opts);
145
+ store.cookieJar.set(name, { name, value: wireValue, options: opts });
146
+ // Read-your-own-writes: store the DECODED logical value so that
147
+ // subsequent `cookies().get(name)` in the same request returns
148
+ // exactly what the developer wrote — never the encoded form.
149
+ // For `{ raw: true }`, the wire form IS the logical form.
150
+ map.set(name, raw ? wireValue : value);
151
+ },
152
+
153
+ setFromHeaders(headers: Headers): void {
154
+ assertMutable(store, 'setFromHeaders');
155
+ if (store.flushed) {
156
+ console.warn(
157
+ `[timber] warn: getCookieJar().setFromHeaders() called after response headers were committed.\n` +
158
+ ` The cookies will NOT be sent. Move cookie mutations to middleware.ts, a server action,\n` +
159
+ ` or a route.ts handler.`
160
+ );
161
+ return;
162
+ }
163
+ // Headers.getSetCookie() returns individual Set-Cookie strings,
164
+ // avoiding the fragile comma-splitting that raw .get() requires.
165
+ for (const raw of headers.getSetCookie()) {
166
+ const parsed = parseSetCookie(raw);
167
+ if (parsed) {
168
+ // Use setRaw to preserve the original header's attributes without
169
+ // merging DEFAULT_COOKIE_OPTIONS (parseSetCookie intentionally
170
+ // does not apply defaults — see its doc comment).
171
+ setRaw(store, map, parsed.name, parsed.value, parsed.options);
172
+ }
173
+ }
174
+ },
175
+
176
+ delete(name: string, options?: Pick<CookieOptions, 'path' | 'domain'>): void {
177
+ assertMutable(store, 'delete');
178
+ // Validate the name even though delete writes an empty value — a
179
+ // smuggled name (`;` or CR/LF) would corrupt the Set-Cookie header
180
+ // we emit. See ONGOING_SECURITY.md H-3 (TIM-868).
181
+ assertValidCookieName(name);
182
+ if (store.flushed) {
183
+ if (isDebug()) {
184
+ console.warn(
185
+ `[timber] warn: getCookieJar().delete('${name}') called after response headers were committed.\n` +
186
+ ` The cookie will NOT be deleted. Move cookie mutations to middleware.ts, a server action,\n` +
187
+ ` or a route.ts handler.`
188
+ );
189
+ }
190
+ return;
191
+ }
192
+ const opts: CookieOptions = {
193
+ ...DEFAULT_COOKIE_OPTIONS,
194
+ ...options,
195
+ maxAge: 0,
196
+ expires: new Date(0),
197
+ };
198
+ store.cookieJar.set(name, { name, value: '', options: opts });
199
+ // Remove from read view
200
+ map.delete(name);
201
+ },
202
+
203
+ clear(): void {
204
+ assertMutable(store, 'clear');
205
+ if (store.flushed) return;
206
+ // Delete every incoming cookie
207
+ for (const name of Array.from(map.keys())) {
208
+ store.cookieJar.set(name, {
209
+ name,
210
+ value: '',
211
+ options: { ...DEFAULT_COOKIE_OPTIONS, maxAge: 0, expires: new Date(0) },
212
+ });
213
+ }
214
+ map.clear();
215
+ },
216
+
217
+ toString(): string {
218
+ // Re-encode values when serializing as a Cookie header — the
219
+ // RYW map holds decoded logical values, but a Cookie header has
220
+ // to satisfy `cookie-octet`. Mirror the auto-encode contract on
221
+ // `set()` so toString() round-trips losslessly with parseCookieHeader.
222
+ return Array.from(map.entries())
223
+ .map(([name, value]) => `${name}=${encodeURIComponent(value)}`)
224
+ .join('; ');
225
+ },
226
+ };
227
+ }
228
+
229
+ /**
230
+ * Returns the value of a single cookie, or undefined if absent.
231
+ *
232
+ * @internal — not part of the public API. Use `defineCookie().get()` or `getCookieJar().get()` instead.
233
+ */
234
+ export function getCookie(name: string): string | undefined {
235
+ const jar = getCookieJar();
236
+ return jar.get(name);
237
+ }
238
+
239
+ // ─── Types ────────────────────────────────────────────────────────────────
240
+
241
+ /**
242
+ * Per-call options for `getCookies().set()`. Extends the persistent
243
+ * `CookieOptions` (HTTP cookie attributes) with framework-only flags
244
+ * that are NOT serialized into the Set-Cookie header.
245
+ *
246
+ * The `raw` flag is the escape hatch for the auto-encoding contract.
247
+ * See design/29-cookies.md §"Encoding Contract".
248
+ */
249
+ export interface SetCookieOptions extends CookieOptions {
250
+ /**
251
+ * Skip the framework's `encodeURIComponent` pass and store the value
252
+ * verbatim. The value is then validated against the strict RFC 6265
253
+ * §4.1.1 `cookie-octet` grammar — the H-3 smuggling primitive cannot
254
+ * sneak in via this opt-out.
255
+ *
256
+ * Use this when forwarding a cookie value that is already in its
257
+ * intended on-the-wire form (e.g. mirroring an upstream service's
258
+ * Set-Cookie). Default: `false` (auto-encode).
259
+ */
260
+ raw?: boolean;
261
+ }
262
+
263
+ /** Options for setting a cookie. See design/29-cookies.md. */
264
+ export interface CookieOptions {
265
+ /** Domain scope. Default: omitted (current domain only). */
266
+ domain?: string;
267
+ /** URL path scope. Default: '/'. */
268
+ path?: string;
269
+ /** Expiration date. Mutually exclusive with maxAge. */
270
+ expires?: Date;
271
+ /** Max age in seconds. Mutually exclusive with expires. */
272
+ maxAge?: number;
273
+ /** Prevent client-side JS access. Default: true. */
274
+ httpOnly?: boolean;
275
+ /** Only send over HTTPS. Default: true. */
276
+ secure?: boolean;
277
+ /** Cross-site request policy. Default: 'lax'. */
278
+ sameSite?: 'strict' | 'lax' | 'none';
279
+ /** Partitioned (CHIPS) — isolate cookie per top-level site. Default: false. */
280
+ partitioned?: boolean;
281
+ }
282
+
283
+ /**
284
+ * Cookie accessor returned by `getCookies()`.
285
+ *
286
+ * Read methods are always available. Mutation methods throw in read-only
287
+ * contexts (access.ts, server components).
288
+ */
289
+ export interface RequestCookies {
290
+ /** Get a cookie value by name. Returns undefined if not present. */
291
+ get(name: string): string | undefined;
292
+ /** Check if a cookie exists. */
293
+ has(name: string): boolean;
294
+ /** Get all cookies as an array of { name, value } pairs. */
295
+ getAll(): Array<{ name: string; value: string }>;
296
+ /** Number of cookies. */
297
+ readonly size: number;
298
+ /**
299
+ * Set a cookie. Only available in mutable contexts (middleware, actions,
300
+ * route handlers).
301
+ *
302
+ * The value is auto-encoded with `encodeURIComponent` so the on-the-wire
303
+ * bytes always satisfy RFC 6265 §4.1.1 cookie-octet — `cookies().get()`
304
+ * returns the same logical value the developer wrote. Pass `{ raw: true }`
305
+ * to skip the encoder; the raw path validates against the strict
306
+ * cookie-octet grammar instead. See design/29-cookies.md §"Encoding
307
+ * Contract" and ONGOING_SECURITY.md H-3 (TIM-868).
308
+ */
309
+ set(name: string, value: string, options?: SetCookieOptions): void;
310
+ /**
311
+ * Copy all `Set-Cookie` headers from a `Headers` object.
312
+ * Parses each header and forwards name, value, and all attributes
313
+ * (path, domain, max-age, expires, sameSite, secure, httpOnly, partitioned).
314
+ *
315
+ * Useful when forwarding cookies from an internal `fetch()` or auth handler:
316
+ * ```ts
317
+ * const response = await auth.handler(req);
318
+ * getCookies().then(c => c.setFromHeaders(response.headers));
319
+ * ```
320
+ */
321
+ setFromHeaders(headers: Headers): void;
322
+ /** Delete a cookie. Only available in mutable contexts. */
323
+ delete(name: string, options?: Pick<CookieOptions, 'path' | 'domain'>): void;
324
+ /** Delete all cookies. Only available in mutable contexts. */
325
+ clear(): void;
326
+ /** Serialize cookies as a Cookie header string. */
327
+ toString(): string;
328
+ }
329
+
330
+ const DEFAULT_COOKIE_OPTIONS: CookieOptions = {
331
+ path: '/',
332
+ httpOnly: true,
333
+ secure: true,
334
+ sameSite: 'lax',
335
+ };
336
+
337
+ // ─── Framework-Internal Helpers ───────────────────────────────────────────
338
+
339
+ /**
340
+ * Per-request seed map of cookie name → value, registered out-of-band so the
341
+ * pipeline's `runWithRequestContext` call can pick it up without changing
342
+ * the function's calling convention. Stored in a WeakMap keyed by the
343
+ * synthetic Request object built for the rerender path, so the seed lives
344
+ * exactly as long as the request and is collected with it.
345
+ *
346
+ * The seed exists to eliminate the parse/serialize round-trip on the no-JS
347
+ * form-rerender path — see ONGOING_SECURITY.md H-3 (TIM-868). The action's
348
+ * post-mutation RYW snapshot is threaded directly into the rerender scope's
349
+ * `parsedCookies` map, bypassing `parseCookieHeader` entirely.
350
+ */
351
+ const seededRequestCookies = new WeakMap<Request, Map<string, string>>();
352
+
353
+ /**
354
+ * Register a pre-parsed cookie map to use as the request context seed for
355
+ * the next `runWithRequestContext(req, …)` call with this exact `req`.
356
+ *
357
+ * Used by the no-JS form-rerender dispatcher in
358
+ * `rsc-entry/wrap-action-dispatch.ts` to thread the action's post-mutation
359
+ * cookie state into the rerender scope without serializing back through a
360
+ * `Cookie:` header. See TIM-868 / TIM-837.
361
+ *
362
+ * @internal — framework use only.
363
+ */
364
+ export function seedRequestCookies(req: Request, cookies: Map<string, string>): void {
365
+ // Defensive copy: callers must not be able to mutate the rerender scope's
366
+ // map after seeding, and the rerender scope must not mutate the snapshot
367
+ // we hand back to other observers.
368
+ seededRequestCookies.set(req, new Map(cookies));
369
+ }
370
+
371
+ /**
372
+ * Pop the seed (if any) for `req` and return it. Called from
373
+ * `runWithRequestContext` exactly once per request — the seed is consumed
374
+ * eagerly so it cannot leak into a hypothetical future re-use of the same
375
+ * Request reference.
376
+ *
377
+ * @internal — framework use only.
378
+ */
379
+ export function consumeSeededCookies(req: Request): Map<string, string> | undefined {
380
+ const seed = seededRequestCookies.get(req);
381
+ if (seed) seededRequestCookies.delete(req);
382
+ return seed;
383
+ }
384
+
385
+ /**
386
+ * Build a Map of cookie name → value reflecting the current request's
387
+ * read-your-own-writes state. Includes incoming cookies plus any
388
+ * mutations from getCookies().set() / getCookies().delete() in the same request.
389
+ *
390
+ * Used by SSR renderers to populate NavContext.cookies so that
391
+ * useCookie()'s server snapshot matches the actual response state.
392
+ *
393
+ * See design/29-cookies.md §"Read-Your-Own-Writes"
394
+ * See design/triage/TIM-441-cookie-api-triage.md §4
395
+ */
396
+ export function getCookiesForSsr(): Map<string, string> {
397
+ const store = requestContextAls.getStore();
398
+ if (!store) {
399
+ throw new Error('[timber] getCookiesForSsr() called outside of a request context.');
400
+ }
401
+
402
+ // Trigger lazy parsing if not yet done
403
+ if (!store.parsedCookies) {
404
+ store.parsedCookies = parseCookieHeader(store.cookieHeader);
405
+ }
406
+
407
+ // The parsedCookies map already reflects read-your-own-writes:
408
+ // - getCookies().set() updates the map via map.set(name, value)
409
+ // - getCookies().delete() removes from the map via map.delete(name)
410
+ // Return a copy so callers can't mutate the internal map.
411
+ return new Map(store.parsedCookies);
412
+ }
413
+
414
+ /**
415
+ * Collect all Set-Cookie headers from the cookie jar.
416
+ * Called by the framework at flush time to apply cookies to the response.
417
+ *
418
+ * Returns an array of serialized Set-Cookie header values.
419
+ */
420
+ export function getSetCookieHeaders(): string[] {
421
+ const store = requestContextAls.getStore();
422
+ if (!store) return [];
423
+ return Array.from(store.cookieJar.values()).map(serializeCookieEntry);
424
+ }
425
+
426
+ // ─── Cookie Helpers ───────────────────────────────────────────────────────
427
+
428
+ /** Throw if cookie mutation is attempted in a read-only context. */
429
+ function assertMutable(store: RequestContextStore, method: string): void {
430
+ if (!store.mutableContext) {
431
+ throw new Error(
432
+ `[timber] getCookieJar().${method}() cannot be called in this context.\n` +
433
+ ` Set cookies in middleware.ts, server actions, or route.ts handlers.`
434
+ );
435
+ }
436
+ }
437
+
438
+ /**
439
+ * Write a cookie to the jar WITHOUT merging DEFAULT_COOKIE_OPTIONS.
440
+ * Used by setFromHeaders to preserve the original header's attributes exactly.
441
+ *
442
+ * For deletion cookies (maxAge=0), the jar entry is still created so the
443
+ * Set-Cookie header is emitted, but the cookie is NOT added to the read map
444
+ * (it would be misleading — the cookie is being deleted).
445
+ */
446
+ function setRaw(
447
+ store: RequestContextStore,
448
+ readMap: Map<string, string>,
449
+ name: string,
450
+ value: string,
451
+ options: CookieOptions
452
+ ): void {
453
+ // setRaw is the forwarding path for upstream Set-Cookie headers
454
+ // (`getCookies().setFromHeaders(response.headers)`). The value comes
455
+ // out of `parseSetCookie` in its on-the-wire form — already encoded
456
+ // by whoever produced it — so we re-emit it verbatim into our jar.
457
+ // We DO validate against the strict cookie-octet grammar, both as
458
+ // defense-in-depth against a malicious upstream and to keep the
459
+ // ONGOING_SECURITY.md H-3 invariant intact at every entry point into
460
+ // the cookie jar / RYW map.
461
+ assertValidCookieName(name);
462
+ assertValidCookieValue(name, value);
463
+ store.cookieJar.set(name, { name, value, options });
464
+ // Deletion cookies (Max-Age=0) should not appear in the read map.
465
+ if (options.maxAge === 0) {
466
+ readMap.delete(name);
467
+ } else {
468
+ // Decode for the RYW map so consumers see the same logical bytes
469
+ // they would see if the upstream cookie had arrived on the next
470
+ // request. Mirrors `parseCookieHeader`'s auto-decode.
471
+ readMap.set(name, safeDecodeCookieValue(value));
472
+ }
473
+ }
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Cookie parsing and serialization helpers — pure string ↔ structure
3
+ * functions with no ALS dependency. Split out of `cookie-context.ts`
4
+ * (TIM-853) so the API surface and the wire-format codecs can each be
5
+ * read on their own.
6
+ *
7
+ * The functions in this module are total over arbitrary input. They
8
+ * never throw and never call `assertValid*` (the security validators
9
+ * live in the API surface — `cookie-context.ts` invokes them at every
10
+ * jar entry point so the smuggling-primitive invariant from TIM-868
11
+ * is enforced regardless of which path produced the bytes).
12
+ */
13
+
14
+ import type { CookieEntry } from './als-registry.js';
15
+ import type { CookieOptions } from './cookie-context.js';
16
+
17
+ /**
18
+ * Parse a Cookie header string into a Map of name → value pairs.
19
+ * Follows RFC 6265 §4.2.1: cookies are semicolon-separated key=value pairs.
20
+ *
21
+ * Values are auto-decoded with `decodeURIComponent` so they round-trip
22
+ * losslessly with `getCookies().set()` (which auto-encodes). Malformed
23
+ * `%`-escapes from third-party cookies fall back to the raw byte sequence
24
+ * — the parser must be total over arbitrary inbound headers, including
25
+ * non-conforming values from other servers, browser extensions, etc.
26
+ */
27
+ export function parseCookieHeader(header: string): Map<string, string> {
28
+ const map = new Map<string, string>();
29
+ if (!header) return map;
30
+
31
+ for (const pair of header.split(';')) {
32
+ const eqIndex = pair.indexOf('=');
33
+ if (eqIndex === -1) continue;
34
+ const name = pair.slice(0, eqIndex).trim();
35
+ const value = pair.slice(eqIndex + 1).trim();
36
+ if (name && !map.has(name)) {
37
+ map.set(name, safeDecodeCookieValue(value));
38
+ }
39
+ }
40
+
41
+ return map;
42
+ }
43
+
44
+ /**
45
+ * Decode a single cookie value with `decodeURIComponent`, falling back to
46
+ * the raw byte sequence if the input contains a malformed `%`-escape.
47
+ *
48
+ * Used by both `parseCookieHeader` (incoming Cookie: header) and the
49
+ * `setRaw` forwarding path (outgoing Set-Cookie from upstream services).
50
+ * Total — never throws.
51
+ */
52
+ export function safeDecodeCookieValue(raw: string): string {
53
+ try {
54
+ return decodeURIComponent(raw);
55
+ } catch {
56
+ return raw;
57
+ }
58
+ }
59
+
60
+ /** Serialize a CookieEntry into a Set-Cookie header value. */
61
+ export function serializeCookieEntry(entry: CookieEntry): string {
62
+ const parts = [`${entry.name}=${entry.value}`];
63
+ const opts = entry.options;
64
+
65
+ if (opts.domain) parts.push(`Domain=${opts.domain}`);
66
+ if (opts.path) parts.push(`Path=${opts.path}`);
67
+ if (opts.expires) parts.push(`Expires=${opts.expires.toUTCString()}`);
68
+ if (opts.maxAge !== undefined) parts.push(`Max-Age=${opts.maxAge}`);
69
+ if (opts.httpOnly) parts.push('HttpOnly');
70
+ if (opts.secure) parts.push('Secure');
71
+ if (opts.sameSite) {
72
+ parts.push(`SameSite=${opts.sameSite.charAt(0).toUpperCase()}${opts.sameSite.slice(1)}`);
73
+ }
74
+ if (opts.partitioned) parts.push('Partitioned');
75
+
76
+ return parts.join('; ');
77
+ }
78
+
79
+ /**
80
+ * Parse a raw `Set-Cookie` header string into name, value, and options.
81
+ * Handles all standard attributes: Path, Domain, Max-Age, Expires,
82
+ * SameSite, Secure, HttpOnly, Partitioned.
83
+ *
84
+ * Does NOT apply DEFAULT_COOKIE_OPTIONS — the caller decides whether
85
+ * to merge defaults (e.g. `set()` does, but `setRaw()` should preserve
86
+ * the original header's intent).
87
+ */
88
+ export function parseSetCookie(
89
+ header: string
90
+ ): { name: string; value: string; options: CookieOptions } | null {
91
+ const segments = header.split(';');
92
+ const nameValue = segments[0];
93
+ const eqIdx = nameValue.indexOf('=');
94
+ if (eqIdx <= 0) return null;
95
+
96
+ const name = nameValue.slice(0, eqIdx).trim();
97
+ const value = nameValue.slice(eqIdx + 1).trim();
98
+ const options: CookieOptions = {};
99
+
100
+ for (let i = 1; i < segments.length; i++) {
101
+ const seg = segments[i].trim();
102
+ if (!seg) continue;
103
+ const [attrName, ...rest] = seg.split('=');
104
+ const key = attrName.trim().toLowerCase();
105
+ const val = rest.join('=').trim();
106
+ switch (key) {
107
+ case 'path':
108
+ options.path = val || '/';
109
+ break;
110
+ case 'domain':
111
+ options.domain = val;
112
+ break;
113
+ case 'max-age':
114
+ options.maxAge = Number(val);
115
+ break;
116
+ case 'expires':
117
+ options.expires = new Date(val);
118
+ break;
119
+ case 'samesite':
120
+ options.sameSite = val.toLowerCase() as 'strict' | 'lax' | 'none';
121
+ break;
122
+ case 'secure':
123
+ options.secure = true;
124
+ break;
125
+ case 'httponly':
126
+ options.httpOnly = true;
127
+ break;
128
+ case 'partitioned':
129
+ options.partitioned = true;
130
+ break;
131
+ }
132
+ }
133
+
134
+ return { name, value, options };
135
+ }
@@ -28,12 +28,36 @@ const SAFE_METHODS = new Set(['GET', 'HEAD', 'OPTIONS']);
28
28
  // ─── Implementation ───────────────────────────────────────────────────────
29
29
 
30
30
  /**
31
- * Validate the Origin header against the request's Host.
31
+ * Derive the request's scheme from trusted sources.
32
+ *
33
+ * Priority:
34
+ * 1. X-Forwarded-Proto (set by reverse proxies / load balancers)
35
+ * 2. Request URL protocol
36
+ *
37
+ * Falls back to 'https' (fail closed) if neither is available.
38
+ */
39
+ function deriveRequestScheme(req: Request): string {
40
+ const forwarded = req.headers.get('X-Forwarded-Proto');
41
+ if (forwarded) {
42
+ const proto = forwarded.split(',')[0].trim().toLowerCase();
43
+ if (proto === 'http' || proto === 'https') return proto;
44
+ }
45
+
46
+ try {
47
+ return new URL(req.url).protocol.replace(':', '');
48
+ } catch {
49
+ return 'https';
50
+ }
51
+ }
52
+
53
+ /**
54
+ * Validate the Origin header against the request's full origin
55
+ * (scheme + host + port).
32
56
  *
33
57
  * For mutation methods (POST, PUT, PATCH, DELETE):
34
58
  * - If `csrf: false`, skip validation.
35
59
  * - If `allowedOrigins` is set, Origin must match one exactly (no wildcards).
36
- * - Otherwise, Origin's host must match the request's Host header.
60
+ * - Otherwise, Origin must match the derived request origin.
37
61
  *
38
62
  * Safe methods (GET, HEAD, OPTIONS) always pass.
39
63
  */
@@ -67,13 +91,22 @@ export function validateCsrf(req: Request, config: CsrfConfig): CsrfResult {
67
91
  return { ok: false, status: 403 };
68
92
  }
69
93
 
70
- // Extract hostname from Origin URL and compare to Host header
71
- let originHost: string;
94
+ // Compare full origins (scheme + host + port) using URL.origin for
95
+ // canonical port normalization (e.g. https://x:443 → https://x).
96
+ let originOrigin: string;
97
+ try {
98
+ originOrigin = new URL(origin).origin;
99
+ } catch {
100
+ return { ok: false, status: 403 };
101
+ }
102
+
103
+ const scheme = deriveRequestScheme(req);
104
+ let expectedOrigin: string;
72
105
  try {
73
- originHost = new URL(origin).host;
106
+ expectedOrigin = new URL(`${scheme}://${host}`).origin;
74
107
  } catch {
75
108
  return { ok: false, status: 403 };
76
109
  }
77
110
 
78
- return originHost === host ? { ok: true } : { ok: false, status: 403 };
111
+ return originOrigin === expectedOrigin ? { ok: true } : { ok: false, status: 403 };
79
112
  }