hono 4.13.13 → 5.0.0-rc.1

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 (516) hide show
  1. package/README.md +2 -2
  2. package/dist/client/fetch-result-please.js +0 -22
  3. package/dist/client/utils.js +0 -7
  4. package/dist/{types/compose.d.ts → compose.d.ts} +5 -3
  5. package/dist/compose.js +18 -31
  6. package/dist/context/constants.d.ts +3 -0
  7. package/dist/context/constants.js +4 -0
  8. package/dist/{types/context.d.ts → context.d.ts} +56 -15
  9. package/dist/context.js +83 -277
  10. package/dist/helper/accepts/accepts.js +0 -13
  11. package/dist/helper/css/common.js +0 -10
  12. package/dist/helper/css/index.js +0 -38
  13. package/dist/{types/helper → helper}/dev/index.d.ts +5 -2
  14. package/dist/helper/dev/index.js +3 -3
  15. package/dist/helper/factory/define-handler.d.ts +150 -0
  16. package/dist/helper/factory/define-handler.js +117 -0
  17. package/dist/{types/helper → helper}/factory/index.d.ts +30 -1
  18. package/dist/helper/factory/index.js +7 -7
  19. package/dist/helper/html/index.js +0 -4
  20. package/dist/helper/proxy/index.js +0 -49
  21. package/dist/helper/route/index.js +0 -90
  22. package/dist/{types/helper → helper}/ssg/middleware.d.ts +0 -6
  23. package/dist/helper/ssg/middleware.js +1 -34
  24. package/dist/helper/ssg/plugins.js +0 -24
  25. package/dist/{types/helper → helper}/ssg/ssg.d.ts +0 -12
  26. package/dist/helper/ssg/ssg.js +0 -18
  27. package/dist/helper/ssg/utils.js +0 -5
  28. package/dist/helper/testing/index.js +0 -4
  29. package/dist/helper/websocket/index.js +0 -6
  30. package/dist/{types/hono-base.d.ts → hono-base.d.ts} +47 -95
  31. package/dist/hono-base.js +63 -228
  32. package/dist/{types/hono.d.ts → hono.d.ts} +1 -1
  33. package/dist/hono.js +0 -13
  34. package/dist/http-exception.js +0 -36
  35. package/dist/index.js +0 -15
  36. package/dist/jsx/components.js +0 -5
  37. package/dist/jsx/context.js +0 -34
  38. package/dist/jsx/dom/client.js +0 -14
  39. package/dist/jsx/dom/css.js +0 -34
  40. package/dist/jsx/dom/hooks/index.js +0 -21
  41. package/dist/jsx/dom/index.js +0 -4
  42. package/dist/jsx/dom/server.js +0 -12
  43. package/dist/jsx/index.js +0 -4
  44. package/dist/jsx/streaming.js +0 -26
  45. package/dist/{types/middleware → middleware}/basic-auth/index.d.ts +4 -3
  46. package/dist/middleware/basic-auth/index.js +0 -49
  47. package/dist/{types/middleware → middleware}/bearer-auth/index.d.ts +4 -27
  48. package/dist/middleware/bearer-auth/index.js +3 -39
  49. package/dist/middleware/body-limit/index.js +0 -32
  50. package/dist/middleware/cache/index.js +0 -31
  51. package/dist/middleware/combine/index.js +0 -80
  52. package/dist/middleware/compress/index.js +0 -24
  53. package/dist/middleware/context-storage/index.js +0 -35
  54. package/dist/middleware/cors/index.js +0 -39
  55. package/dist/middleware/csrf/index.js +0 -62
  56. package/dist/middleware/etag/index.js +0 -29
  57. package/dist/middleware/ip-restriction/index.js +0 -41
  58. package/dist/middleware/jsx-renderer/index.js +0 -58
  59. package/dist/middleware/jwk/jwk.js +0 -31
  60. package/dist/middleware/jwt/jwt.js +0 -32
  61. package/dist/middleware/language/language.js +0 -60
  62. package/dist/middleware/logger/index.js +6 -24
  63. package/dist/middleware/method-not-allowed/index.js +1 -36
  64. package/dist/middleware/method-override/index.js +0 -25
  65. package/dist/middleware/mount/index.js +0 -32
  66. package/dist/middleware/powered-by/index.js +0 -15
  67. package/dist/middleware/pretty-json/index.js +0 -18
  68. package/dist/middleware/request-id/request-id.js +0 -22
  69. package/dist/middleware/secure-headers/secure-headers.js +0 -32
  70. package/dist/{types/middleware → middleware}/serve-static/index.d.ts +0 -4
  71. package/dist/middleware/serve-static/index.js +0 -3
  72. package/dist/middleware/serve-static/path.js +0 -4
  73. package/dist/middleware/timeout/index.js +0 -22
  74. package/dist/middleware/timing/timing.js +0 -95
  75. package/dist/middleware/trailing-slash/index.js +0 -50
  76. package/dist/{types/preset → preset}/quick.d.ts +1 -1
  77. package/dist/preset/quick.js +0 -4
  78. package/dist/{types/preset → preset}/tiny.d.ts +1 -1
  79. package/dist/preset/tiny.js +0 -4
  80. package/dist/{types/request.d.ts → request.d.ts} +3 -48
  81. package/dist/request.js +0 -205
  82. package/dist/router/linear-router/router.js +19 -13
  83. package/dist/router/pattern-router/router.js +3 -3
  84. package/dist/router/reg-exp-router/node.js +9 -11
  85. package/dist/router/reg-exp-router/trie.js +0 -5
  86. package/dist/router/trie-router/node.js +5 -5
  87. package/dist/router.js +0 -19
  88. package/dist/{types/types.d.ts → types.d.ts} +33 -2
  89. package/dist/utils/body.js +0 -30
  90. package/dist/utils/buffer.d.ts +11 -0
  91. package/dist/utils/buffer.js +1 -12
  92. package/dist/utils/color.d.ts +16 -0
  93. package/dist/utils/color.js +4 -33
  94. package/dist/utils/compress.js +0 -7
  95. package/dist/utils/concurrent.js +0 -4
  96. package/dist/utils/constants.js +0 -3
  97. package/dist/utils/cookie.js +0 -4
  98. package/dist/utils/encode.js +0 -4
  99. package/dist/utils/handler.js +0 -4
  100. package/dist/utils/html.js +0 -4
  101. package/dist/{types/utils → utils}/http-status.d.ts +1 -9
  102. package/dist/utils/ipaddr.js +0 -39
  103. package/dist/utils/jwt/index.js +0 -4
  104. package/dist/utils/jwt/jwa.js +0 -5
  105. package/dist/utils/jwt/jws.js +0 -5
  106. package/dist/utils/jwt/jwt.js +0 -5
  107. package/dist/utils/jwt/types.js +0 -4
  108. package/dist/utils/jwt/utf8.js +0 -4
  109. package/dist/utils/mime.js +0 -4
  110. package/dist/utils/stream.js +0 -14
  111. package/dist/{types/utils → utils}/url.d.ts +0 -5
  112. package/dist/utils/url.js +1 -30
  113. package/dist/{types/validator → validator}/validator.d.ts +5 -0
  114. package/dist/validator/validator.js +42 -49
  115. package/package.json +142 -488
  116. package/dist/adapter/aws-lambda/conninfo.js +0 -43
  117. package/dist/adapter/aws-lambda/handler.js +0 -342
  118. package/dist/adapter/aws-lambda/index.js +0 -3
  119. package/dist/adapter/aws-lambda/types.js +0 -1
  120. package/dist/adapter/bun/conninfo.js +0 -22
  121. package/dist/adapter/bun/index.js +0 -6
  122. package/dist/adapter/bun/serve-static.js +0 -30
  123. package/dist/adapter/bun/server.js +0 -11
  124. package/dist/adapter/bun/ssg.js +0 -27
  125. package/dist/adapter/bun/websocket.js +0 -66
  126. package/dist/adapter/cloudflare-pages/conninfo.js +0 -24
  127. package/dist/adapter/cloudflare-pages/handler.js +0 -64
  128. package/dist/adapter/cloudflare-pages/index.js +0 -3
  129. package/dist/adapter/cloudflare-workers/conninfo.js +0 -7
  130. package/dist/adapter/cloudflare-workers/index.js +0 -4
  131. package/dist/adapter/cloudflare-workers/serve-static-module.js +0 -7
  132. package/dist/adapter/cloudflare-workers/serve-static.js +0 -28
  133. package/dist/adapter/cloudflare-workers/utils.js +0 -22
  134. package/dist/adapter/cloudflare-workers/websocket.js +0 -33
  135. package/dist/adapter/deno/conninfo.js +0 -17
  136. package/dist/adapter/deno/deno.d.js +0 -1
  137. package/dist/adapter/deno/index.js +0 -5
  138. package/dist/adapter/deno/serve-static.js +0 -35
  139. package/dist/adapter/deno/ssg.js +0 -29
  140. package/dist/adapter/deno/websocket.js +0 -32
  141. package/dist/adapter/lambda-edge/conninfo.js +0 -7
  142. package/dist/adapter/lambda-edge/handler.js +0 -111
  143. package/dist/adapter/lambda-edge/index.js +0 -3
  144. package/dist/adapter/netlify/conninfo.js +0 -24
  145. package/dist/adapter/netlify/handler.js +0 -11
  146. package/dist/adapter/netlify/index.js +0 -3
  147. package/dist/adapter/netlify/mod.js +0 -3
  148. package/dist/adapter/service-worker/handler.js +0 -16
  149. package/dist/adapter/service-worker/index.js +0 -25
  150. package/dist/adapter/service-worker/types.js +0 -1
  151. package/dist/adapter/vercel/conninfo.js +0 -7
  152. package/dist/adapter/vercel/handler.js +0 -9
  153. package/dist/adapter/vercel/index.js +0 -3
  154. package/dist/cjs/_virtual/_rolldown/runtime.js +0 -33
  155. package/dist/cjs/adapter/aws-lambda/conninfo.js +0 -44
  156. package/dist/cjs/adapter/aws-lambda/handler.js +0 -352
  157. package/dist/cjs/adapter/aws-lambda/index.js +0 -7
  158. package/dist/cjs/adapter/aws-lambda/types.js +0 -0
  159. package/dist/cjs/adapter/bun/conninfo.js +0 -23
  160. package/dist/cjs/adapter/bun/index.js +0 -14
  161. package/dist/cjs/adapter/bun/serve-static.js +0 -31
  162. package/dist/cjs/adapter/bun/server.js +0 -12
  163. package/dist/cjs/adapter/bun/ssg.js +0 -29
  164. package/dist/cjs/adapter/bun/websocket.js +0 -70
  165. package/dist/cjs/adapter/cloudflare-pages/conninfo.js +0 -25
  166. package/dist/cjs/adapter/cloudflare-pages/handler.js +0 -67
  167. package/dist/cjs/adapter/cloudflare-pages/index.js +0 -7
  168. package/dist/cjs/adapter/cloudflare-workers/conninfo.js +0 -8
  169. package/dist/cjs/adapter/cloudflare-workers/index.js +0 -7
  170. package/dist/cjs/adapter/cloudflare-workers/serve-static-module.js +0 -8
  171. package/dist/cjs/adapter/cloudflare-workers/serve-static.js +0 -29
  172. package/dist/cjs/adapter/cloudflare-workers/utils.js +0 -23
  173. package/dist/cjs/adapter/cloudflare-workers/websocket.js +0 -34
  174. package/dist/cjs/adapter/deno/conninfo.js +0 -18
  175. package/dist/cjs/adapter/deno/deno.d.js +0 -0
  176. package/dist/cjs/adapter/deno/index.js +0 -10
  177. package/dist/cjs/adapter/deno/serve-static.js +0 -36
  178. package/dist/cjs/adapter/deno/ssg.js +0 -31
  179. package/dist/cjs/adapter/deno/websocket.js +0 -33
  180. package/dist/cjs/adapter/lambda-edge/conninfo.js +0 -8
  181. package/dist/cjs/adapter/lambda-edge/handler.js +0 -116
  182. package/dist/cjs/adapter/lambda-edge/index.js +0 -5
  183. package/dist/cjs/adapter/netlify/conninfo.js +0 -25
  184. package/dist/cjs/adapter/netlify/handler.js +0 -12
  185. package/dist/cjs/adapter/netlify/index.js +0 -5
  186. package/dist/cjs/adapter/netlify/mod.js +0 -5
  187. package/dist/cjs/adapter/service-worker/handler.js +0 -17
  188. package/dist/cjs/adapter/service-worker/index.js +0 -27
  189. package/dist/cjs/adapter/service-worker/types.js +0 -0
  190. package/dist/cjs/adapter/vercel/conninfo.js +0 -8
  191. package/dist/cjs/adapter/vercel/handler.js +0 -10
  192. package/dist/cjs/adapter/vercel/index.js +0 -5
  193. package/dist/cjs/client/client.js +0 -145
  194. package/dist/cjs/client/fetch-result-please.js +0 -67
  195. package/dist/cjs/client/index.js +0 -7
  196. package/dist/cjs/client/types.js +0 -0
  197. package/dist/cjs/client/utils.js +0 -70
  198. package/dist/cjs/compose.js +0 -51
  199. package/dist/cjs/context.js +0 -383
  200. package/dist/cjs/helper/accepts/accepts.js +0 -54
  201. package/dist/cjs/helper/accepts/index.js +0 -3
  202. package/dist/cjs/helper/adapter/index.js +0 -41
  203. package/dist/cjs/helper/conninfo/index.js +0 -0
  204. package/dist/cjs/helper/conninfo/types.js +0 -0
  205. package/dist/cjs/helper/cookie/index.js +0 -89
  206. package/dist/cjs/helper/css/common.js +0 -194
  207. package/dist/cjs/helper/css/index.js +0 -142
  208. package/dist/cjs/helper/dev/index.js +0 -53
  209. package/dist/cjs/helper/factory/index.js +0 -33
  210. package/dist/cjs/helper/html/index.js +0 -34
  211. package/dist/cjs/helper/proxy/index.js +0 -122
  212. package/dist/cjs/helper/route/index.js +0 -128
  213. package/dist/cjs/helper/ssg/index.js +0 -19
  214. package/dist/cjs/helper/ssg/middleware.js +0 -65
  215. package/dist/cjs/helper/ssg/plugins.js +0 -68
  216. package/dist/cjs/helper/ssg/ssg.js +0 -220
  217. package/dist/cjs/helper/ssg/utils.js +0 -70
  218. package/dist/cjs/helper/streaming/index.js +0 -8
  219. package/dist/cjs/helper/streaming/sse.js +0 -59
  220. package/dist/cjs/helper/streaming/stream.js +0 -26
  221. package/dist/cjs/helper/streaming/text.js +0 -12
  222. package/dist/cjs/helper/streaming/utils.js +0 -16
  223. package/dist/cjs/helper/testing/index.js +0 -18
  224. package/dist/cjs/helper/websocket/index.js +0 -56
  225. package/dist/cjs/hono-base.js +0 -351
  226. package/dist/cjs/hono.js +0 -29
  227. package/dist/cjs/http-exception.js +0 -56
  228. package/dist/cjs/index.js +0 -22
  229. package/dist/cjs/jsx/base.js +0 -266
  230. package/dist/cjs/jsx/children.js +0 -19
  231. package/dist/cjs/jsx/components.js +0 -147
  232. package/dist/cjs/jsx/constants.js +0 -15
  233. package/dist/cjs/jsx/context.js +0 -170
  234. package/dist/cjs/jsx/dom/client.js +0 -56
  235. package/dist/cjs/jsx/dom/components.js +0 -26
  236. package/dist/cjs/jsx/dom/context.js +0 -43
  237. package/dist/cjs/jsx/dom/css.js +0 -153
  238. package/dist/cjs/jsx/dom/hooks/index.js +0 -65
  239. package/dist/cjs/jsx/dom/index.js +0 -122
  240. package/dist/cjs/jsx/dom/intrinsic-element/components.js +0 -306
  241. package/dist/cjs/jsx/dom/jsx-dev-runtime.js +0 -17
  242. package/dist/cjs/jsx/dom/jsx-runtime.js +0 -5
  243. package/dist/cjs/jsx/dom/render.js +0 -525
  244. package/dist/cjs/jsx/dom/server.js +0 -44
  245. package/dist/cjs/jsx/dom/utils.js +0 -9
  246. package/dist/cjs/jsx/hooks/index.js +0 -280
  247. package/dist/cjs/jsx/index.js +0 -89
  248. package/dist/cjs/jsx/intrinsic-element/common.js +0 -27
  249. package/dist/cjs/jsx/intrinsic-element/components.js +0 -138
  250. package/dist/cjs/jsx/intrinsic-elements.js +0 -0
  251. package/dist/cjs/jsx/jsx-dev-runtime.js +0 -16
  252. package/dist/cjs/jsx/jsx-runtime.js +0 -37
  253. package/dist/cjs/jsx/streaming.js +0 -135
  254. package/dist/cjs/jsx/types.js +0 -0
  255. package/dist/cjs/jsx/utils.js +0 -116
  256. package/dist/cjs/middleware/basic-auth/index.js +0 -100
  257. package/dist/cjs/middleware/bearer-auth/index.js +0 -97
  258. package/dist/cjs/middleware/body-limit/index.js +0 -69
  259. package/dist/cjs/middleware/cache/index.js +0 -173
  260. package/dist/cjs/middleware/combine/index.js +0 -141
  261. package/dist/cjs/middleware/compress/index.js +0 -82
  262. package/dist/cjs/middleware/context-storage/index.js +0 -55
  263. package/dist/cjs/middleware/cors/index.js +0 -109
  264. package/dist/cjs/middleware/csrf/index.js +0 -106
  265. package/dist/cjs/middleware/etag/digest.js +0 -62
  266. package/dist/cjs/middleware/etag/index.js +0 -79
  267. package/dist/cjs/middleware/ip-restriction/index.js +0 -168
  268. package/dist/cjs/middleware/jsx-renderer/index.js +0 -104
  269. package/dist/cjs/middleware/jwk/index.js +0 -3
  270. package/dist/cjs/middleware/jwk/jwk.js +0 -122
  271. package/dist/cjs/middleware/jwt/index.js +0 -9
  272. package/dist/cjs/middleware/jwt/jwt.js +0 -124
  273. package/dist/cjs/middleware/language/index.js +0 -7
  274. package/dist/cjs/middleware/language/language.js +0 -208
  275. package/dist/cjs/middleware/logger/index.js +0 -51
  276. package/dist/cjs/middleware/method-not-allowed/index.js +0 -84
  277. package/dist/cjs/middleware/method-override/index.js +0 -105
  278. package/dist/cjs/middleware/mount/index.js +0 -71
  279. package/dist/cjs/middleware/powered-by/index.js +0 -25
  280. package/dist/cjs/middleware/pretty-json/index.js +0 -41
  281. package/dist/cjs/middleware/request-id/index.js +0 -3
  282. package/dist/cjs/middleware/request-id/request-id.js +0 -35
  283. package/dist/cjs/middleware/secure-headers/index.js +0 -4
  284. package/dist/cjs/middleware/secure-headers/permissions-policy.js +0 -0
  285. package/dist/cjs/middleware/secure-headers/secure-headers.js +0 -166
  286. package/dist/cjs/middleware/serve-static/index.js +0 -62
  287. package/dist/cjs/middleware/serve-static/path.js +0 -17
  288. package/dist/cjs/middleware/timeout/index.js +0 -42
  289. package/dist/cjs/middleware/timing/index.js +0 -7
  290. package/dist/cjs/middleware/timing/timing.js +0 -189
  291. package/dist/cjs/middleware/trailing-slash/index.js +0 -89
  292. package/dist/cjs/package.json +0 -3
  293. package/dist/cjs/preset/quick.js +0 -19
  294. package/dist/cjs/preset/tiny.js +0 -16
  295. package/dist/cjs/request/constants.js +0 -5
  296. package/dist/cjs/request.js +0 -337
  297. package/dist/cjs/router/linear-router/index.js +0 -3
  298. package/dist/cjs/router/linear-router/router.js +0 -97
  299. package/dist/cjs/router/pattern-router/index.js +0 -3
  300. package/dist/cjs/router/pattern-router/router.js +0 -42
  301. package/dist/cjs/router/reg-exp-router/index.js +0 -7
  302. package/dist/cjs/router/reg-exp-router/matcher.js +0 -21
  303. package/dist/cjs/router/reg-exp-router/node.js +0 -96
  304. package/dist/cjs/router/reg-exp-router/prepared-router.js +0 -97
  305. package/dist/cjs/router/reg-exp-router/router.js +0 -102
  306. package/dist/cjs/router/reg-exp-router/trie.js +0 -74
  307. package/dist/cjs/router/smart-router/index.js +0 -3
  308. package/dist/cjs/router/smart-router/router.js +0 -50
  309. package/dist/cjs/router/trie-router/index.js +0 -3
  310. package/dist/cjs/router/trie-router/node.js +0 -135
  311. package/dist/cjs/router/trie-router/router.js +0 -16
  312. package/dist/cjs/router/utils.js +0 -5
  313. package/dist/cjs/router.js +0 -40
  314. package/dist/cjs/types.js +0 -5
  315. package/dist/cjs/utils/accept.js +0 -194
  316. package/dist/cjs/utils/basic-auth.js +0 -21
  317. package/dist/cjs/utils/body.js +0 -97
  318. package/dist/cjs/utils/buffer.js +0 -55
  319. package/dist/cjs/utils/color.js +0 -39
  320. package/dist/cjs/utils/compress.js +0 -12
  321. package/dist/cjs/utils/concurrent.js +0 -31
  322. package/dist/cjs/utils/constants.js +0 -8
  323. package/dist/cjs/utils/cookie.js +0 -129
  324. package/dist/cjs/utils/crypto.js +0 -38
  325. package/dist/cjs/utils/encode.js +0 -37
  326. package/dist/cjs/utils/filepath.js +0 -27
  327. package/dist/cjs/utils/handler.js +0 -14
  328. package/dist/cjs/utils/headers.js +0 -0
  329. package/dist/cjs/utils/html.js +0 -109
  330. package/dist/cjs/utils/http-status.js +0 -0
  331. package/dist/cjs/utils/ipaddr.js +0 -247
  332. package/dist/cjs/utils/jwt/index.js +0 -15
  333. package/dist/cjs/utils/jwt/jwa.js +0 -25
  334. package/dist/cjs/utils/jwt/jws.js +0 -135
  335. package/dist/cjs/utils/jwt/jwt.js +0 -136
  336. package/dist/cjs/utils/jwt/types.js +0 -124
  337. package/dist/cjs/utils/jwt/utf8.js +0 -11
  338. package/dist/cjs/utils/mime.js +0 -80
  339. package/dist/cjs/utils/stream.js +0 -89
  340. package/dist/cjs/utils/types.js +0 -0
  341. package/dist/cjs/utils/url.js +0 -215
  342. package/dist/cjs/validator/index.js +0 -3
  343. package/dist/cjs/validator/utils.js +0 -0
  344. package/dist/cjs/validator/validator.js +0 -65
  345. package/dist/types/adapter/aws-lambda/conninfo.d.ts +0 -30
  346. package/dist/types/adapter/aws-lambda/handler.d.ts +0 -230
  347. package/dist/types/adapter/aws-lambda/index.d.ts +0 -4
  348. package/dist/types/adapter/aws-lambda/types.d.ts +0 -183
  349. package/dist/types/adapter/bun/conninfo.d.ts +0 -10
  350. package/dist/types/adapter/bun/index.d.ts +0 -6
  351. package/dist/types/adapter/bun/serve-static.d.ts +0 -8
  352. package/dist/types/adapter/bun/server.d.ts +0 -11
  353. package/dist/types/adapter/bun/ssg.d.ts +0 -17
  354. package/dist/types/adapter/bun/websocket.d.ts +0 -54
  355. package/dist/types/adapter/cloudflare-pages/conninfo.d.ts +0 -24
  356. package/dist/types/adapter/cloudflare-pages/handler.d.ts +0 -45
  357. package/dist/types/adapter/cloudflare-pages/index.d.ts +0 -3
  358. package/dist/types/adapter/cloudflare-workers/conninfo.d.ts +0 -7
  359. package/dist/types/adapter/cloudflare-workers/index.d.ts +0 -4
  360. package/dist/types/adapter/cloudflare-workers/serve-static-module.d.ts +0 -7
  361. package/dist/types/adapter/cloudflare-workers/serve-static.d.ts +0 -21
  362. package/dist/types/adapter/cloudflare-workers/utils.d.ts +0 -13
  363. package/dist/types/adapter/cloudflare-workers/websocket.d.ts +0 -7
  364. package/dist/types/adapter/deno/conninfo.d.ts +0 -10
  365. package/dist/types/adapter/deno/deno.d.ts +0 -1
  366. package/dist/types/adapter/deno/index.d.ts +0 -5
  367. package/dist/types/adapter/deno/serve-static.d.ts +0 -8
  368. package/dist/types/adapter/deno/ssg.d.ts +0 -17
  369. package/dist/types/adapter/deno/websocket.d.ts +0 -7
  370. package/dist/types/adapter/lambda-edge/conninfo.d.ts +0 -7
  371. package/dist/types/adapter/lambda-edge/handler.d.ts +0 -113
  372. package/dist/types/adapter/lambda-edge/index.d.ts +0 -3
  373. package/dist/types/adapter/netlify/conninfo.d.ts +0 -24
  374. package/dist/types/adapter/netlify/handler.d.ts +0 -7
  375. package/dist/types/adapter/netlify/index.d.ts +0 -3
  376. package/dist/types/adapter/netlify/mod.d.ts +0 -3
  377. package/dist/types/adapter/service-worker/handler.d.ts +0 -18
  378. package/dist/types/adapter/service-worker/index.d.ts +0 -26
  379. package/dist/types/adapter/service-worker/types.d.ts +0 -17
  380. package/dist/types/adapter/vercel/conninfo.d.ts +0 -7
  381. package/dist/types/adapter/vercel/handler.d.ts +0 -7
  382. package/dist/types/adapter/vercel/index.d.ts +0 -3
  383. package/dist/types/package.json +0 -3
  384. package/dist/types/utils/buffer.d.ts +0 -19
  385. package/dist/types/utils/color.d.ts +0 -23
  386. package/dist/{types/client → client}/client.d.ts +0 -0
  387. package/dist/{types/client → client}/fetch-result-please.d.ts +0 -0
  388. package/dist/{types/client → client}/index.d.ts +0 -0
  389. package/dist/{types/client → client}/types.d.ts +1 -1
  390. /package/dist/{types/client → client}/utils.d.ts +0 -0
  391. /package/dist/{types/helper → helper}/accepts/accepts.d.ts +0 -0
  392. /package/dist/{types/helper → helper}/accepts/index.d.ts +0 -0
  393. /package/dist/{types/helper → helper}/adapter/index.d.ts +0 -0
  394. /package/dist/{types/helper → helper}/conninfo/index.d.ts +0 -0
  395. /package/dist/{types/helper → helper}/conninfo/types.d.ts +0 -0
  396. /package/dist/{types/helper → helper}/cookie/index.d.ts +0 -0
  397. /package/dist/{types/helper → helper}/css/common.d.ts +0 -0
  398. /package/dist/{types/helper → helper}/css/index.d.ts +0 -0
  399. /package/dist/{types/helper → helper}/html/index.d.ts +0 -0
  400. /package/dist/{types/helper → helper}/proxy/index.d.ts +0 -0
  401. /package/dist/{types/helper → helper}/route/index.d.ts +0 -0
  402. /package/dist/{types/helper → helper}/ssg/index.d.ts +0 -0
  403. /package/dist/{types/helper → helper}/ssg/plugins.d.ts +0 -0
  404. /package/dist/{types/helper → helper}/ssg/utils.d.ts +0 -0
  405. /package/dist/{types/helper → helper}/streaming/index.d.ts +0 -0
  406. /package/dist/{types/helper → helper}/streaming/sse.d.ts +0 -0
  407. /package/dist/{types/helper → helper}/streaming/stream.d.ts +0 -0
  408. /package/dist/{types/helper → helper}/streaming/text.d.ts +0 -0
  409. /package/dist/{types/helper → helper}/streaming/utils.d.ts +0 -0
  410. /package/dist/{types/helper → helper}/testing/index.d.ts +0 -0
  411. /package/dist/{types/helper → helper}/websocket/index.d.ts +0 -0
  412. /package/dist/{types/http-exception.d.ts → http-exception.d.ts} +0 -0
  413. /package/dist/{types/index.d.ts → index.d.ts} +0 -0
  414. /package/dist/{types/jsx → jsx}/base.d.ts +0 -0
  415. /package/dist/{types/jsx → jsx}/children.d.ts +0 -0
  416. /package/dist/{types/jsx → jsx}/components.d.ts +0 -0
  417. /package/dist/{types/jsx → jsx}/constants.d.ts +0 -0
  418. /package/dist/{types/jsx → jsx}/context.d.ts +0 -0
  419. /package/dist/{types/jsx → jsx}/dom/client.d.ts +0 -0
  420. /package/dist/{types/jsx → jsx}/dom/components.d.ts +0 -0
  421. /package/dist/{types/jsx → jsx}/dom/context.d.ts +0 -0
  422. /package/dist/{types/jsx → jsx}/dom/css.d.ts +0 -0
  423. /package/dist/{types/jsx → jsx}/dom/hooks/index.d.ts +0 -0
  424. /package/dist/{types/jsx → jsx}/dom/index.d.ts +0 -0
  425. /package/dist/{types/jsx → jsx}/dom/intrinsic-element/components.d.ts +0 -0
  426. /package/dist/{types/jsx → jsx}/dom/jsx-dev-runtime.d.ts +0 -0
  427. /package/dist/{types/jsx → jsx}/dom/jsx-runtime.d.ts +0 -0
  428. /package/dist/{types/jsx → jsx}/dom/render.d.ts +0 -0
  429. /package/dist/{types/jsx → jsx}/dom/server.d.ts +0 -0
  430. /package/dist/{types/jsx → jsx}/dom/utils.d.ts +0 -0
  431. /package/dist/{types/jsx → jsx}/hooks/index.d.ts +0 -0
  432. /package/dist/{types/jsx → jsx}/index.d.ts +0 -0
  433. /package/dist/{types/jsx → jsx}/intrinsic-element/common.d.ts +0 -0
  434. /package/dist/{types/jsx → jsx}/intrinsic-element/components.d.ts +0 -0
  435. /package/dist/{types/jsx → jsx}/intrinsic-elements.d.ts +0 -0
  436. /package/dist/{types/jsx → jsx}/jsx-dev-runtime.d.ts +0 -0
  437. /package/dist/{types/jsx → jsx}/jsx-runtime.d.ts +0 -0
  438. /package/dist/{types/jsx → jsx}/streaming.d.ts +0 -0
  439. /package/dist/{types/jsx → jsx}/types.d.ts +0 -0
  440. /package/dist/{types/jsx → jsx}/utils.d.ts +0 -0
  441. /package/dist/{types/middleware → middleware}/body-limit/index.d.ts +0 -0
  442. /package/dist/{types/middleware → middleware}/cache/index.d.ts +0 -0
  443. /package/dist/{types/middleware → middleware}/combine/index.d.ts +0 -0
  444. /package/dist/{types/middleware → middleware}/compress/index.d.ts +0 -0
  445. /package/dist/{types/middleware → middleware}/context-storage/index.d.ts +0 -0
  446. /package/dist/{types/middleware → middleware}/cors/index.d.ts +0 -0
  447. /package/dist/{types/middleware → middleware}/csrf/index.d.ts +0 -0
  448. /package/dist/{types/middleware → middleware}/etag/digest.d.ts +0 -0
  449. /package/dist/{types/middleware → middleware}/etag/index.d.ts +0 -0
  450. /package/dist/{types/middleware → middleware}/ip-restriction/index.d.ts +0 -0
  451. /package/dist/{types/middleware → middleware}/jsx-renderer/index.d.ts +0 -0
  452. /package/dist/{types/middleware → middleware}/jwk/index.d.ts +0 -0
  453. /package/dist/{types/middleware → middleware}/jwk/jwk.d.ts +0 -0
  454. /package/dist/{types/middleware → middleware}/jwt/index.d.ts +0 -0
  455. /package/dist/{types/middleware → middleware}/jwt/jwt.d.ts +0 -0
  456. /package/dist/{types/middleware → middleware}/language/index.d.ts +0 -0
  457. /package/dist/{types/middleware → middleware}/language/language.d.ts +0 -0
  458. /package/dist/{types/middleware → middleware}/logger/index.d.ts +0 -0
  459. /package/dist/{types/middleware → middleware}/method-not-allowed/index.d.ts +0 -0
  460. /package/dist/{types/middleware → middleware}/method-override/index.d.ts +0 -0
  461. /package/dist/{types/middleware → middleware}/mount/index.d.ts +0 -0
  462. /package/dist/{types/middleware → middleware}/powered-by/index.d.ts +0 -0
  463. /package/dist/{types/middleware → middleware}/pretty-json/index.d.ts +0 -0
  464. /package/dist/{types/middleware → middleware}/request-id/index.d.ts +0 -0
  465. /package/dist/{types/middleware → middleware}/request-id/request-id.d.ts +0 -0
  466. /package/dist/{types/middleware → middleware}/secure-headers/index.d.ts +0 -0
  467. /package/dist/{types/middleware → middleware}/secure-headers/permissions-policy.d.ts +0 -0
  468. /package/dist/{types/middleware → middleware}/secure-headers/secure-headers.d.ts +0 -0
  469. /package/dist/{types/middleware → middleware}/serve-static/path.d.ts +0 -0
  470. /package/dist/{types/middleware → middleware}/timeout/index.d.ts +0 -0
  471. /package/dist/{types/middleware → middleware}/timing/index.d.ts +0 -0
  472. /package/dist/{types/middleware → middleware}/timing/timing.d.ts +0 -0
  473. /package/dist/{types/middleware → middleware}/trailing-slash/index.d.ts +0 -0
  474. /package/dist/{types/request → request}/constants.d.ts +0 -0
  475. /package/dist/{types/router → router}/linear-router/index.d.ts +0 -0
  476. /package/dist/{types/router → router}/linear-router/router.d.ts +0 -0
  477. /package/dist/{types/router → router}/pattern-router/index.d.ts +0 -0
  478. /package/dist/{types/router → router}/pattern-router/router.d.ts +0 -0
  479. /package/dist/{types/router → router}/reg-exp-router/index.d.ts +0 -0
  480. /package/dist/{types/router → router}/reg-exp-router/matcher.d.ts +0 -0
  481. /package/dist/{types/router → router}/reg-exp-router/node.d.ts +0 -0
  482. /package/dist/{types/router → router}/reg-exp-router/prepared-router.d.ts +0 -0
  483. /package/dist/{types/router → router}/reg-exp-router/router.d.ts +0 -0
  484. /package/dist/{types/router → router}/reg-exp-router/trie.d.ts +0 -0
  485. /package/dist/{types/router → router}/smart-router/index.d.ts +0 -0
  486. /package/dist/{types/router → router}/smart-router/router.d.ts +0 -0
  487. /package/dist/{types/router → router}/trie-router/index.d.ts +0 -0
  488. /package/dist/{types/router → router}/trie-router/node.d.ts +0 -0
  489. /package/dist/{types/router → router}/trie-router/router.d.ts +0 -0
  490. /package/dist/{types/router → router}/utils.d.ts +0 -0
  491. /package/dist/{types/router.d.ts → router.d.ts} +0 -0
  492. /package/dist/{types/utils → utils}/accept.d.ts +0 -0
  493. /package/dist/{types/utils → utils}/basic-auth.d.ts +0 -0
  494. /package/dist/{types/utils → utils}/body.d.ts +0 -0
  495. /package/dist/{types/utils → utils}/compress.d.ts +0 -0
  496. /package/dist/{types/utils → utils}/concurrent.d.ts +0 -0
  497. /package/dist/{types/utils → utils}/constants.d.ts +0 -0
  498. /package/dist/{types/utils → utils}/cookie.d.ts +0 -0
  499. /package/dist/{types/utils → utils}/crypto.d.ts +0 -0
  500. /package/dist/{types/utils → utils}/encode.d.ts +0 -0
  501. /package/dist/{types/utils → utils}/filepath.d.ts +0 -0
  502. /package/dist/{types/utils → utils}/handler.d.ts +0 -0
  503. /package/dist/{types/utils → utils}/headers.d.ts +0 -0
  504. /package/dist/{types/utils → utils}/html.d.ts +0 -0
  505. /package/dist/{types/utils → utils}/ipaddr.d.ts +0 -0
  506. /package/dist/{types/utils → utils}/jwt/index.d.ts +0 -0
  507. /package/dist/{types/utils → utils}/jwt/jwa.d.ts +0 -0
  508. /package/dist/{types/utils → utils}/jwt/jws.d.ts +0 -0
  509. /package/dist/{types/utils → utils}/jwt/jwt.d.ts +0 -0
  510. /package/dist/{types/utils → utils}/jwt/types.d.ts +0 -0
  511. /package/dist/{types/utils → utils}/jwt/utf8.d.ts +0 -0
  512. /package/dist/{types/utils → utils}/mime.d.ts +0 -0
  513. /package/dist/{types/utils → utils}/stream.d.ts +0 -0
  514. /package/dist/{types/utils → utils}/types.d.ts +0 -0
  515. /package/dist/{types/validator → validator}/index.d.ts +0 -0
  516. /package/dist/{types/validator → validator}/utils.d.ts +0 -0
@@ -3,34 +3,6 @@ import "../../router.js";
3
3
  import { TrieRouter } from "../../router/trie-router/router.js";
4
4
  import "../../router/trie-router/index.js";
5
5
  //#region src/middleware/combine/index.ts
6
- /**
7
- * @module
8
- * Combine Middleware for Hono.
9
- */
10
- /**
11
- * Create a composed middleware that runs the first middleware that returns true.
12
- *
13
- * @param middleware - An array of MiddlewareHandler or Condition functions.
14
- * Middleware is applied in the order it is passed, and if any middleware exits without returning
15
- * an exception first, subsequent middleware will not be executed.
16
- * You can also pass a condition function that returns a boolean value. If returns true
17
- * the evaluation will be halted, and rest of the middleware will not be executed.
18
- * @returns A composed middleware.
19
- *
20
- * @example
21
- * ```ts
22
- * import { some } from 'hono/combine'
23
- * import { bearerAuth } from 'hono/bearer-auth'
24
- * import { myRateLimit } from '@/rate-limit'
25
- *
26
- * // If client has a valid token, then skip rate limiting.
27
- * // Otherwise, apply rate limiting.
28
- * app.use('/api/*', some(
29
- * bearerAuth({ token }),
30
- * myRateLimit({ limit: 100 }),
31
- * ));
32
- * ```
33
- */
34
6
  const some = (...middleware) => {
35
7
  return async function some(c, next) {
36
8
  let isNextCalled = false;
@@ -57,34 +29,6 @@ const some = (...middleware) => {
57
29
  return response;
58
30
  };
59
31
  };
60
- /**
61
- * Create a composed middleware that runs all middleware and throws an error if any of them fail.
62
- *
63
- * @param middleware - An array of MiddlewareHandler or Condition functions.
64
- * Middleware is applied in the order it is passed, and if any middleware throws an error,
65
- * subsequent middleware will not be executed.
66
- * You can also pass a condition function that returns a boolean value. If returns false
67
- * the evaluation will be halted, and rest of the middleware will not be executed.
68
- * @returns A composed middleware.
69
- *
70
- * @example
71
- * ```ts
72
- * import { some, every } from 'hono/combine'
73
- * import { bearerAuth } from 'hono/bearer-auth'
74
- * import { myCheckLocalNetwork } from '@/check-local-network'
75
- * import { myRateLimit } from '@/rate-limit'
76
- *
77
- * // If client is in local network, then skip authentication and rate limiting.
78
- * // Otherwise, apply authentication and rate limiting.
79
- * app.use('/api/*', some(
80
- * myCheckLocalNetwork(),
81
- * every(
82
- * bearerAuth({ token }),
83
- * myRateLimit({ limit: 100 }),
84
- * ),
85
- * ));
86
- * ```
87
- */
88
32
  const every = (...middleware) => {
89
33
  return async function every(c, next) {
90
34
  const currentRouteIndex = c.req.routeIndex;
@@ -96,30 +40,6 @@ const every = (...middleware) => {
96
40
  }]]))(c, next);
97
41
  };
98
42
  };
99
- /**
100
- * Create a composed middleware that runs all middleware except when the condition is met.
101
- *
102
- * @param condition - A string or Condition function.
103
- * If there are multiple targets to match any of them, they can be passed as an array.
104
- * If a string is passed, it will be treated as a path pattern to match.
105
- * If a Condition function is passed, it will be evaluated against the request context.
106
- * @param middleware - Middleware to run when the condition is not met.
107
- * Multiple middleware can be passed, and they are applied in the order they are passed.
108
- * @returns A composed middleware.
109
- *
110
- * @example
111
- * ```ts
112
- * import { except } from 'hono/combine'
113
- * import { bearerAuth } from 'hono/bearer-auth'
114
- *
115
- * // If client is accessing public API, then skip authentication.
116
- * // Otherwise, require a valid token.
117
- * app.use('/api/*', except(
118
- * '/api/public/*',
119
- * bearerAuth({ token }),
120
- * ));
121
- * ```
122
- */
123
43
  const except = (condition, ...middleware) => {
124
44
  let router = void 0;
125
45
  const conditions = (Array.isArray(condition) ? condition : [condition]).map((condition) => {
@@ -20,30 +20,6 @@ const selectEncoding = (header, candidates) => {
20
20
  return best?.encoding;
21
21
  };
22
22
  const varyAcceptEncodingRegExp = /(?:^|,)\s*accept-encoding\s*(?:,|$)/i;
23
- /**
24
- * Compress Middleware for Hono.
25
- *
26
- * @see {@link https://hono.dev/docs/middleware/builtin/compress}
27
- *
28
- * @param {CompressionOptions} [options] - The options for the compress middleware.
29
- * @param {'gzip' | 'deflate'} [options.encoding] - The compression scheme to allow for response compression. Either 'gzip' or 'deflate'. If not defined, both are allowed and will be used based on the Accept-Encoding header. 'gzip' is prioritized if this option is not provided and the client provides both in the Accept-Encoding header.
30
- * @param {number} [options.threshold=1024] - The minimum size in bytes to compress. Defaults to 1024 bytes.
31
- * @param {RegExp | Function} [options.contentTypeFilter=COMPRESSIBLE_CONTENT_TYPE_REGEX] - A RegExp or function to determine if the response Content-Type should be compressed.
32
- * @returns {MiddlewareHandler} The middleware handler function.
33
- *
34
- * @example
35
- * ```ts
36
- * const app = new Hono()
37
- *
38
- * app.use(compress())
39
- *
40
- * // Compress only JSON responses
41
- * app.use(compress({ contentTypeFilter: /^application\/json/ }))
42
- *
43
- * // Compress based on custom Content-Type logic
44
- * app.use(compress({ contentTypeFilter: (type) => COMPRESSIBLE_CONTENT_TYPE_REGEX.test(type) || type === "application/x-myformat" }))
45
- * ```
46
- */
47
23
  const compress = (options) => {
48
24
  const threshold = options?.threshold ?? 1024;
49
25
  const candidates = options?.encoding ? [options.encoding] : ENCODING_TYPES;
@@ -1,41 +1,6 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
2
  //#region src/middleware/context-storage/index.ts
3
- /**
4
- * @module
5
- * Context Storage Middleware for Hono.
6
- */
7
3
  const asyncLocalStorage = new AsyncLocalStorage();
8
- /**
9
- * Context Storage Middleware for Hono.
10
- *
11
- * @see {@link https://hono.dev/docs/middleware/builtin/context-storage}
12
- *
13
- * @returns {MiddlewareHandler} The middleware handler function.
14
- *
15
- * @example
16
- * ```ts
17
- * type Env = {
18
- * Variables: {
19
- * message: string
20
- * }
21
- * }
22
- *
23
- * const app = new Hono<Env>()
24
- *
25
- * app.use(contextStorage())
26
- *
27
- * app.use(async (c, next) => {
28
- * c.set('message', 'Hono is hot!!')
29
- * await next()
30
- * })
31
- *
32
- * app.get('/', async (c) => c.text(getMessage()))
33
- *
34
- * const getMessage = () => {
35
- * return getContext<Env>().var.message
36
- * }
37
- * ```
38
- */
39
4
  const contextStorage = () => {
40
5
  return async function contextStorage(c, next) {
41
6
  await asyncLocalStorage.run(c, next);
@@ -1,43 +1,4 @@
1
1
  //#region src/middleware/cors/index.ts
2
- /**
3
- * CORS Middleware for Hono.
4
- *
5
- * @see {@link https://hono.dev/docs/middleware/builtin/cors}
6
- *
7
- * @param {CORSOptions} [options] - The options for the CORS middleware.
8
- * @param {string | string[] | ((origin: string, c: Context) => Promise<string | undefined | null> | string | undefined | null)} [options.origin='*'] - The value of "Access-Control-Allow-Origin" CORS header.
9
- * @param {string[] | ((origin: string, c: Context) => Promise<string[]> | string[])} [options.allowMethods=['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH', 'QUERY']] - The value of "Access-Control-Allow-Methods" CORS header.
10
- * @param {string[]} [options.allowHeaders=[]] - The value of "Access-Control-Allow-Headers" CORS header.
11
- * @param {number} [options.maxAge] - The value of "Access-Control-Max-Age" CORS header.
12
- * @param {boolean} [options.credentials] - The value of "Access-Control-Allow-Credentials" CORS header.
13
- * @param {string[]} [options.exposeHeaders=[]] - The value of "Access-Control-Expose-Headers" CORS header.
14
- * @returns {MiddlewareHandler} The middleware handler function.
15
- *
16
- * @example
17
- * ```ts
18
- * const app = new Hono()
19
- *
20
- * app.use('/api/*', cors())
21
- * app.use(
22
- * '/api2/*',
23
- * cors({
24
- * origin: 'http://example.com',
25
- * allowHeaders: ['X-Custom-Header', 'Upgrade-Insecure-Requests'],
26
- * allowMethods: ['POST', 'GET', 'OPTIONS'],
27
- * exposeHeaders: ['Content-Length', 'X-Kuma-Revision'],
28
- * maxAge: 600,
29
- * credentials: true,
30
- * })
31
- * )
32
- *
33
- * app.all('/api/abc', (c) => {
34
- * return c.json({ success: true })
35
- * })
36
- * app.all('/api2/abc', (c) => {
37
- * return c.json({ success: true })
38
- * })
39
- * ```
40
- */
41
2
  const cors = (options) => {
42
3
  const opts = {
43
4
  origin: "*",
@@ -9,68 +9,6 @@ const secFetchSiteValues = [
9
9
  const isSecFetchSite = (value) => secFetchSiteValues.includes(value);
10
10
  const isSafeMethodRe = /^(GET|HEAD|OPTIONS)$/;
11
11
  const isRequestedByFormElementRe = /^\b(application\/x-www-form-urlencoded|multipart\/form-data|text\/plain)\b/i;
12
- /**
13
- * CSRF Protection Middleware for Hono.
14
- *
15
- * Protects against Cross-Site Request Forgery attacks by validating request origins
16
- * and sec-fetch-site headers. The request is allowed if either validation passes.
17
- *
18
- * @see {@link https://hono.dev/docs/middleware/builtin/csrf}
19
- *
20
- * @param {CSRFOptions} [options] - The options for the CSRF protection middleware.
21
- * @param {string|string[]|(origin: string, context: Context) => boolean} [options.origin] -
22
- * Allowed origins for requests.
23
- * - string: Single allowed origin (e.g., 'https://example.com')
24
- * - string[]: Multiple allowed origins
25
- * - function: Custom validation logic
26
- * - Default: Only same origin as the request URL
27
- * @param {string|string[]|(secFetchSite: string, context: Context) => boolean} [options.secFetchSite] -
28
- * Sec-Fetch-Site header validation. Standard values include 'same-origin', 'same-site', 'cross-site', 'none'.
29
- * - string: Single allowed value (e.g., 'same-origin')
30
- * - string[]: Multiple allowed values (e.g., ['same-origin', 'same-site'])
31
- * - function: Custom validation with access to context
32
- * - Default: Only allows 'same-origin'
33
- * @returns {MiddlewareHandler} The middleware handler function.
34
- *
35
- * @example
36
- * ```ts
37
- * const app = new Hono()
38
- *
39
- * // Default: both origin and sec-fetch-site validation
40
- * app.use('*', csrf())
41
- *
42
- * // Allow specific origins
43
- * app.use('*', csrf({ origin: 'https://example.com' }))
44
- * app.use('*', csrf({ origin: ['https://app.com', 'https://api.com'] }))
45
- *
46
- * // Allow specific sec-fetch-site values
47
- * app.use('*', csrf({ secFetchSite: 'same-origin' }))
48
- * app.use('*', csrf({ secFetchSite: ['same-origin', 'same-site'] }))
49
- *
50
- * // Dynamic sec-fetch-site validation
51
- * app.use('*', csrf({
52
- * secFetchSite: (secFetchSite, c) => {
53
- * // Always allow same-origin
54
- * if (secFetchSite === 'same-origin') return true
55
- * // Allow cross-site for webhook endpoints
56
- * if (secFetchSite === 'cross-site' && c.req.path.startsWith('/webhook/')) {
57
- * return true
58
- * }
59
- * return false
60
- * }
61
- * }))
62
- *
63
- * // Dynamic origin validation
64
- * app.use('*', csrf({
65
- * origin: (origin, c) => {
66
- * // Allow same origin
67
- * if (origin === new URL(c.req.url).origin) return true
68
- * // Allow specific trusted domains
69
- * return ['https://app.example.com', 'https://admin.example.com'].includes(origin)
70
- * }
71
- * }))
72
- * ```
73
- */
74
12
  const csrf = (options) => {
75
13
  const originHandler = ((optsOrigin) => {
76
14
  if (!optsOrigin) return (origin, c) => origin === new URL(c.req.url).origin;
@@ -1,11 +1,5 @@
1
1
  import { generateDigest } from "./digest.js";
2
2
  //#region src/middleware/etag/index.ts
3
- /**
4
- * Default headers to pass through on 304 responses. From the spec:
5
- * > The response must not contain a body and must include the headers that
6
- * > would have been sent in an equivalent 200 OK response: Cache-Control,
7
- * > Content-Location, Date, ETag, Expires, and Vary.
8
- */
9
3
  const RETAINED_304_HEADERS = [
10
4
  "cache-control",
11
5
  "content-location",
@@ -24,29 +18,6 @@ function initializeGenerator(generator) {
24
18
  }
25
19
  return generator;
26
20
  }
27
- /**
28
- * ETag Middleware for Hono.
29
- *
30
- * @see {@link https://hono.dev/docs/middleware/builtin/etag}
31
- *
32
- * @param {ETagOptions} [options] - The options for the ETag middleware.
33
- * @param {boolean} [options.weak=false] - Define using or not using a weak validation. If true is set, then `W/` is added to the prefix of the value.
34
- * @param {string[]} [options.retainedHeaders=RETAINED_304_HEADERS] - The headers that you want to retain in the 304 Response.
35
- * @param {function(Uint8Array): ArrayBuffer | Promise<ArrayBuffer>} [options.generateDigest] -
36
- * A custom digest generation function. By default, it uses 'SHA-1'
37
- * This function is called with the response body as a `Uint8Array` and should return a hash as an `ArrayBuffer` or a Promise of one.
38
- * @returns {MiddlewareHandler} The middleware handler function.
39
- *
40
- * @example
41
- * ```ts
42
- * const app = new Hono()
43
- *
44
- * app.use('/etag/*', etag())
45
- * app.get('/etag/abc', (c) => {
46
- * return c.text('Hono is hot')
47
- * })
48
- * ```
49
- */
50
21
  const etag = (options) => {
51
22
  const retainedHeaders = new Set((options?.retainedHeaders ?? RETAINED_304_HEADERS).map((header) => header.toLowerCase()));
52
23
  const weak = options?.weak ?? false;
@@ -84,47 +84,6 @@ const buildMatcher = (rules) => {
84
84
  return false;
85
85
  };
86
86
  };
87
- /**
88
- * IP Restriction Middleware for Hono.
89
- *
90
- * @see {@link https://hono.dev/docs/middleware/builtin/ip-restriction}
91
- *
92
- * @param {GetConnInfo | ((c: Context) => string)} getIP - A function to retrieve the client IP address. Use `getConnInfo` from the appropriate runtime adapter.
93
- * @param {IPRestrictionRules} rules - An object with optional `denyList` and `allowList` arrays of IP rules. Each rule can be a static IP, a CIDR range, or a custom function.
94
- * @param {(remote: { addr: string; type: AddressType }, c: Context) => Response | Promise<Response>} [onError] - Optional custom handler invoked when a request is blocked. Defaults to returning a 403 Forbidden response.
95
- * @returns {MiddlewareHandler} The middleware handler function.
96
- *
97
- * @example
98
- * ```ts
99
- * import { Hono } from 'hono'
100
- * import { ipRestriction } from 'hono/ip-restriction'
101
- * import { getConnInfo } from 'hono/cloudflare-workers'
102
- *
103
- * const app = new Hono()
104
- *
105
- * app.use(
106
- * '*',
107
- * ipRestriction(getConnInfo, {
108
- * // Block a specific IP and an entire subnet
109
- * denyList: ['192.168.0.5', '10.0.0.0/8'],
110
- * // Only allow requests from localhost and a private range
111
- * allowList: ['127.0.0.1', '::1', '192.168.1.0/24'],
112
- * })
113
- * )
114
- *
115
- * // With a custom error handler
116
- * app.use(
117
- * '/admin/*',
118
- * ipRestriction(
119
- * getConnInfo,
120
- * { allowList: ['203.0.113.0/24'] },
121
- * (remote, c) => c.text(`Access denied for ${remote.addr}`, 403)
122
- * )
123
- * )
124
- *
125
- * app.get('/', (c) => c.text('Hello!'))
126
- * ```
127
- */
128
87
  const ipRestriction = (getIP, { denyList = [], allowList = [] }, onError) => {
129
88
  const allowLength = allowList.length;
130
89
  const denyMatcher = buildMatcher(denyList);
@@ -23,40 +23,6 @@ const createRenderer = (c, Layout, component, options) => (children, props) => {
23
23
  return c.body(renderToReadableStream(body));
24
24
  } else return c.html(body);
25
25
  };
26
- /**
27
- * JSX Renderer Middleware for hono.
28
- *
29
- * @see {@link https://hono.dev/docs/middleware/builtin/jsx-renderer}
30
- *
31
- * @param {ComponentWithChildren} [component] - The component to render, which can accept children and props.
32
- * @param {RendererOptions} [options] - The options for the JSX renderer middleware.
33
- * @param {boolean | string} [options.docType=true] - The DOCTYPE to be added at the beginning of the HTML. If set to false, no DOCTYPE will be added.
34
- * @param {boolean | Record<string, string>} [options.stream=false] - If set to true, enables streaming response with default headers. If a record is provided, custom headers will be used.
35
- * @returns {MiddlewareHandler} The middleware handler function.
36
- *
37
- * @example
38
- * ```ts
39
- * const app = new Hono()
40
- *
41
- * app.get(
42
- * '/page/*',
43
- * jsxRenderer(({ children }) => {
44
- * return (
45
- * <html>
46
- * <body>
47
- * <header>Menu</header>
48
- * <div>{children}</div>
49
- * </body>
50
- * </html>
51
- * )
52
- * })
53
- * )
54
- *
55
- * app.get('/page/about', (c) => {
56
- * return c.render(<h1>About me!</h1>)
57
- * })
58
- * ```
59
- */
60
26
  const jsxRenderer = (component, options) => function jsxRenderer(c, next) {
61
27
  const Layout = c.getLayout() ?? Fragment;
62
28
  if (component) c.setLayout((props) => {
@@ -68,30 +34,6 @@ const jsxRenderer = (component, options) => function jsxRenderer(c, next) {
68
34
  c.setRenderer(createRenderer(c, Layout, component, options));
69
35
  return next();
70
36
  };
71
- /**
72
- * useRequestContext for Hono.
73
- *
74
- * @template E - The environment type.
75
- * @template P - The parameter type.
76
- * @template I - The input type.
77
- * @returns {Context<E, P, I>} An instance of Context.
78
- *
79
- * @example
80
- * ```ts
81
- * const RequestUrlBadge: FC = () => {
82
- * const c = useRequestContext()
83
- * return <b>{c.req.url}</b>
84
- * }
85
- *
86
- * app.get('/page/info', (c) => {
87
- * return c.render(
88
- * <div>
89
- * You are accessing: <RequestUrlBadge />
90
- * </div>
91
- * )
92
- * })
93
- * ```
94
- */
95
37
  const useRequestContext = () => {
96
38
  const c = useContext(RequestContext);
97
39
  if (!c) throw new Error("RequestContext is not provided.");
@@ -2,37 +2,6 @@ import { HTTPException } from "../../http-exception.js";
2
2
  import { getCookie, getSignedCookie } from "../../helper/cookie/index.js";
3
3
  import { Jwt } from "../../utils/jwt/index.js";
4
4
  //#region src/middleware/jwk/jwk.ts
5
- /**
6
- * JWK Auth Middleware for Hono.
7
- *
8
- * @see {@link https://hono.dev/docs/middleware/builtin/jwk}
9
- *
10
- * @param {object} options - The options for the JWK middleware.
11
- * @param {HonoJsonWebKey[] | ((ctx: Context) => Promise<HonoJsonWebKey[]> | HonoJsonWebKey[])} [options.keys] - The public keys used for JWK verification, or a function that returns them.
12
- * @param {string | ((ctx: Context) => Promise<string> | string)} [options.jwks_uri] - If set to a URI string or a function that returns a URI string, attempt to fetch JWKs from it. The response must be a JSON object containing a `keys` array, which will be merged with the `keys` option.
13
- * @param {boolean} [options.allow_anon] - If set to `true`, the middleware allows requests without a token to proceed without authentication.
14
- * @param {string} [options.cookie] - If set, the middleware attempts to retrieve the token from a cookie with these options (optionally signed) only if no token is found in the header.
15
- * @param {string} [options.headerName='Authorization'] - The name of the header to look for the JWT token. Default is 'Authorization'.
16
- * @param {string} [options.realm] - The protection space described by the `realm` parameter of the returned `WWW-Authenticate` challenge header. Defaults to the request URL.
17
- * @param {AsymmetricAlgorithm[]} options.alg - An array of allowed asymmetric algorithms for JWT verification. Only tokens signed with these algorithms will be accepted.
18
- * @param {RequestInit} [init] - Optional init options for the `fetch` request when retrieving JWKS from a URI.
19
- * @param {VerifyOptions} [options.verification] - Additional options for JWK payload verification.
20
- * @returns {MiddlewareHandler} The middleware handler function.
21
- *
22
- * @example
23
- * ```ts
24
- * const app = new Hono()
25
- *
26
- * app.use("/auth/*", jwk({
27
- * jwks_uri: (c) => `https://${c.env.authServer}/.well-known/jwks.json`,
28
- * headerName: 'x-custom-auth-header', // Optional, default is 'Authorization'
29
- * }))
30
- *
31
- * app.get('/auth/page', (c) => {
32
- * return c.text('You are authorized')
33
- * })
34
- * ```
35
- */
36
5
  const jwk = (options, init) => {
37
6
  const verifyOpts = options.verification || {};
38
7
  if (!options || !(options.keys || options.jwks_uri)) throw new Error("JWK auth middleware requires options for either \"keys\" or \"jwks_uri\" or both");
@@ -2,38 +2,6 @@ import { HTTPException } from "../../http-exception.js";
2
2
  import { getCookie, getSignedCookie } from "../../helper/cookie/index.js";
3
3
  import { Jwt } from "../../utils/jwt/index.js";
4
4
  //#region src/middleware/jwt/jwt.ts
5
- /**
6
- * JWT Auth Middleware for Hono.
7
- *
8
- * @see {@link https://hono.dev/docs/middleware/builtin/jwt}
9
- *
10
- * @param {object} options - The options for the JWT middleware.
11
- * @param {SignatureKey} options.secret - A value of your secret key.
12
- * @param {string} [options.cookie] - If this value is set, then the value is retrieved from the cookie header using that value as a key, which is then validated as a token.
13
- * @param {SignatureAlgorithm} options.alg - An algorithm type that is used for verifying (required). Available types are `HS256` | `HS384` | `HS512` | `RS256` | `RS384` | `RS512` | `PS256` | `PS384` | `PS512` | `ES256` | `ES384` | `ES512` | `EdDSA`.
14
- * @param {string} [options.headerName='Authorization'] - The name of the header to look for the JWT token. Default is 'Authorization'.
15
- * @param {string} [options.realm] - The protection space described by the `realm` parameter of the returned `WWW-Authenticate` challenge header. Defaults to the request URL.
16
- * @param {VerifyOptions} [options.verification] - Additional options for JWT payload verification.
17
- * @returns {MiddlewareHandler} The middleware handler function.
18
- *
19
- * @example
20
- * ```ts
21
- * const app = new Hono()
22
- *
23
- * app.use(
24
- * '/auth/*',
25
- * jwt({
26
- * secret: 'it-is-very-secret',
27
- * alg: 'HS256',
28
- * headerName: 'x-custom-auth-header', // Optional, default is 'Authorization'
29
- * })
30
- * )
31
- *
32
- * app.get('/auth/page', (c) => {
33
- * return c.text('You are authorized')
34
- * })
35
- * ```
36
- */
37
5
  const jwt = (options) => {
38
6
  const verifyOpts = options.verification || {};
39
7
  if (!options || !options.secret) throw new Error("JWT auth middleware requires options for \"secret\"");
@@ -23,23 +23,12 @@ const DEFAULT_OPTIONS = {
23
23
  },
24
24
  debug: false
25
25
  };
26
- /**
27
- * Parse Accept-Language header values with quality scores
28
- * @param header Accept-Language header string
29
- * @returns Array of parsed languages with quality scores
30
- */
31
26
  function parseAcceptLanguage(header) {
32
27
  return parseAccept(header).map(({ type, q }) => ({
33
28
  lang: type,
34
29
  q
35
30
  }));
36
31
  }
37
- /**
38
- * Validate and normalize language codes
39
- * @param lang Language code to normalize
40
- * @param options Detector options
41
- * @returns Normalized language code or undefined
42
- */
43
32
  const normalizeLanguage = (lang, options) => {
44
33
  if (!lang) return;
45
34
  try {
@@ -64,23 +53,14 @@ const normalizeLanguage = (lang, options) => {
64
53
  return;
65
54
  }
66
55
  };
67
- /**
68
- * Detects language from query parameter
69
- */
70
56
  const detectFromQuery = (c, options) => {
71
57
  const query = c.req.query(options.lookupQueryString);
72
58
  return normalizeLanguage(query, options);
73
59
  };
74
- /**
75
- * Detects language from cookie
76
- */
77
60
  const detectFromCookie = (c, options) => {
78
61
  const cookie = getCookie(c, options.lookupCookie);
79
62
  return normalizeLanguage(cookie, options);
80
63
  };
81
- /**
82
- * Detects language from Accept-Language header
83
- */
84
64
  function detectFromHeader(c, options) {
85
65
  try {
86
66
  const acceptLanguage = c.req.header(options.lookupFromHeaderKey);
@@ -96,35 +76,21 @@ function detectFromHeader(c, options) {
96
76
  return;
97
77
  }
98
78
  }
99
- /**
100
- * Detects language from URL path
101
- */
102
79
  function detectFromPath(c, options) {
103
80
  const langSegment = new URL(c.req.url).pathname.split("/").filter(Boolean)[options.lookupFromPathIndex];
104
81
  return normalizeLanguage(langSegment, options);
105
82
  }
106
- /**
107
- * Collection of all language detection strategies
108
- */
109
83
  const detectors = {
110
84
  querystring: detectFromQuery,
111
85
  cookie: detectFromCookie,
112
86
  header: detectFromHeader,
113
87
  path: detectFromPath
114
88
  };
115
- /**
116
- * Validate detector options
117
- * @param options Detector options to validate
118
- * @throws Error if options are invalid
119
- */
120
89
  function validateOptions(options) {
121
90
  if (!options.supportedLanguages.includes(options.fallbackLanguage)) throw new Error("Fallback language must be included in supported languages");
122
91
  if (options.lookupFromPathIndex < 0) throw new Error("Path index must be non-negative");
123
92
  if (!options.order.every((detector) => Object.keys(detectors).includes(detector))) throw new Error("Invalid detector type in order array");
124
93
  }
125
- /**
126
- * Cache detected language
127
- */
128
94
  function cacheLanguage(c, language, options) {
129
95
  if (!Array.isArray(options.caches) || !options.caches.includes("cookie")) return;
130
96
  try {
@@ -133,9 +99,6 @@ function cacheLanguage(c, language, options) {
133
99
  if (options.debug) console.error("Failed to cache language:", error);
134
100
  }
135
101
  }
136
- /**
137
- * Detect language from request
138
- */
139
102
  const detectLanguage = (c, options) => {
140
103
  let detectedLang;
141
104
  for (const detectorName of options.order) {
@@ -155,29 +118,6 @@ const detectLanguage = (c, options) => {
155
118
  if (detectedLang && options.caches) cacheLanguage(c, finalLang, options);
156
119
  return finalLang;
157
120
  };
158
- /**
159
- * Language detector middleware factory
160
- * @param userOptions Configuration options for the language detector
161
- * @returns Hono middleware function
162
- *
163
- * @example
164
- * ```ts
165
- * type Variables = LanguageVariables
166
- * const app = new Hono<{ Variables: Variables }>()
167
- *
168
- * app.use(
169
- * languageDetector({
170
- * supportedLanguages: ['en', 'ja'], // Must include fallback
171
- * fallbackLanguage: 'en', // Required
172
- * })
173
- * )
174
- *
175
- * app.get('/', (c) => {
176
- * const lang = c.get('language')
177
- * return c.text(`Current language: ${lang}`)
178
- * })
179
- * ```
180
- */
181
121
  const languageDetector = (userOptions) => {
182
122
  const options = {
183
123
  ...DEFAULT_OPTIONS,