hono 4.13.13 → 5.0.0-rc.0
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.
- package/README.md +2 -2
- package/dist/{types/compose.d.ts → compose.d.ts} +1 -0
- package/dist/compose.js +10 -5
- package/dist/{types/context.d.ts → context.d.ts} +15 -15
- package/dist/context.js +79 -47
- package/dist/helper/factory/define-handler.d.ts +150 -0
- package/dist/helper/factory/define-handler.js +165 -0
- package/dist/{types/helper → helper}/factory/index.d.ts +30 -1
- package/dist/helper/factory/index.js +31 -3
- package/dist/{types/helper → helper}/ssg/middleware.d.ts +0 -6
- package/dist/helper/ssg/middleware.js +1 -16
- package/dist/{types/helper → helper}/ssg/ssg.d.ts +0 -12
- package/dist/helper/ssg/ssg.js +0 -3
- package/dist/{types/hono-base.d.ts → hono-base.d.ts} +3 -60
- package/dist/hono-base.js +6 -97
- package/dist/{types/hono.d.ts → hono.d.ts} +1 -1
- package/dist/{types/middleware → middleware}/basic-auth/index.d.ts +4 -3
- package/dist/middleware/basic-auth/index.js +1 -1
- package/dist/{types/middleware → middleware}/bearer-auth/index.d.ts +4 -27
- package/dist/middleware/bearer-auth/index.js +4 -4
- package/dist/middleware/language/language.js +1 -1
- package/dist/middleware/logger/index.js +6 -8
- package/dist/{types/middleware → middleware}/serve-static/index.d.ts +0 -4
- package/dist/{types/preset → preset}/quick.d.ts +1 -1
- package/dist/{types/preset → preset}/tiny.d.ts +1 -1
- package/dist/{types/request.d.ts → request.d.ts} +3 -48
- package/dist/request.js +0 -49
- package/dist/router/linear-router/router.js +4 -6
- package/dist/router/pattern-router/router.js +2 -2
- package/dist/router/reg-exp-router/node.js +1 -1
- package/dist/router/trie-router/node.js +3 -3
- package/dist/utils/buffer.d.ts +11 -0
- package/dist/utils/buffer.js +1 -8
- package/dist/utils/color.d.ts +16 -0
- package/dist/utils/color.js +7 -23
- package/dist/{types/utils → utils}/http-status.d.ts +1 -9
- package/dist/{types/utils → utils}/url.d.ts +0 -5
- package/dist/utils/url.js +1 -11
- package/dist/{types/validator → validator}/validator.d.ts +5 -0
- package/dist/validator/validator.js +46 -49
- package/package.json +209 -350
- package/dist/adapter/aws-lambda/conninfo.js +0 -43
- package/dist/adapter/aws-lambda/handler.js +0 -342
- package/dist/adapter/aws-lambda/index.js +0 -3
- package/dist/adapter/aws-lambda/types.js +0 -1
- package/dist/adapter/bun/conninfo.js +0 -22
- package/dist/adapter/bun/index.js +0 -6
- package/dist/adapter/bun/serve-static.js +0 -30
- package/dist/adapter/bun/server.js +0 -11
- package/dist/adapter/bun/ssg.js +0 -27
- package/dist/adapter/bun/websocket.js +0 -66
- package/dist/adapter/cloudflare-pages/conninfo.js +0 -24
- package/dist/adapter/cloudflare-pages/handler.js +0 -64
- package/dist/adapter/cloudflare-pages/index.js +0 -3
- package/dist/adapter/cloudflare-workers/conninfo.js +0 -7
- package/dist/adapter/cloudflare-workers/index.js +0 -4
- package/dist/adapter/cloudflare-workers/serve-static-module.js +0 -7
- package/dist/adapter/cloudflare-workers/serve-static.js +0 -28
- package/dist/adapter/cloudflare-workers/utils.js +0 -22
- package/dist/adapter/cloudflare-workers/websocket.js +0 -33
- package/dist/adapter/deno/conninfo.js +0 -17
- package/dist/adapter/deno/deno.d.js +0 -1
- package/dist/adapter/deno/index.js +0 -5
- package/dist/adapter/deno/serve-static.js +0 -35
- package/dist/adapter/deno/ssg.js +0 -29
- package/dist/adapter/deno/websocket.js +0 -32
- package/dist/adapter/lambda-edge/conninfo.js +0 -7
- package/dist/adapter/lambda-edge/handler.js +0 -111
- package/dist/adapter/lambda-edge/index.js +0 -3
- package/dist/adapter/netlify/conninfo.js +0 -24
- package/dist/adapter/netlify/handler.js +0 -11
- package/dist/adapter/netlify/index.js +0 -3
- package/dist/adapter/netlify/mod.js +0 -3
- package/dist/adapter/service-worker/handler.js +0 -16
- package/dist/adapter/service-worker/index.js +0 -25
- package/dist/adapter/service-worker/types.js +0 -1
- package/dist/adapter/vercel/conninfo.js +0 -7
- package/dist/adapter/vercel/handler.js +0 -9
- package/dist/adapter/vercel/index.js +0 -3
- package/dist/cjs/_virtual/_rolldown/runtime.js +0 -33
- package/dist/cjs/adapter/aws-lambda/conninfo.js +0 -44
- package/dist/cjs/adapter/aws-lambda/handler.js +0 -352
- package/dist/cjs/adapter/aws-lambda/index.js +0 -7
- package/dist/cjs/adapter/aws-lambda/types.js +0 -0
- package/dist/cjs/adapter/bun/conninfo.js +0 -23
- package/dist/cjs/adapter/bun/index.js +0 -14
- package/dist/cjs/adapter/bun/serve-static.js +0 -31
- package/dist/cjs/adapter/bun/server.js +0 -12
- package/dist/cjs/adapter/bun/ssg.js +0 -29
- package/dist/cjs/adapter/bun/websocket.js +0 -70
- package/dist/cjs/adapter/cloudflare-pages/conninfo.js +0 -25
- package/dist/cjs/adapter/cloudflare-pages/handler.js +0 -67
- package/dist/cjs/adapter/cloudflare-pages/index.js +0 -7
- package/dist/cjs/adapter/cloudflare-workers/conninfo.js +0 -8
- package/dist/cjs/adapter/cloudflare-workers/index.js +0 -7
- package/dist/cjs/adapter/cloudflare-workers/serve-static-module.js +0 -8
- package/dist/cjs/adapter/cloudflare-workers/serve-static.js +0 -29
- package/dist/cjs/adapter/cloudflare-workers/utils.js +0 -23
- package/dist/cjs/adapter/cloudflare-workers/websocket.js +0 -34
- package/dist/cjs/adapter/deno/conninfo.js +0 -18
- package/dist/cjs/adapter/deno/deno.d.js +0 -0
- package/dist/cjs/adapter/deno/index.js +0 -10
- package/dist/cjs/adapter/deno/serve-static.js +0 -36
- package/dist/cjs/adapter/deno/ssg.js +0 -31
- package/dist/cjs/adapter/deno/websocket.js +0 -33
- package/dist/cjs/adapter/lambda-edge/conninfo.js +0 -8
- package/dist/cjs/adapter/lambda-edge/handler.js +0 -116
- package/dist/cjs/adapter/lambda-edge/index.js +0 -5
- package/dist/cjs/adapter/netlify/conninfo.js +0 -25
- package/dist/cjs/adapter/netlify/handler.js +0 -12
- package/dist/cjs/adapter/netlify/index.js +0 -5
- package/dist/cjs/adapter/netlify/mod.js +0 -5
- package/dist/cjs/adapter/service-worker/handler.js +0 -17
- package/dist/cjs/adapter/service-worker/index.js +0 -27
- package/dist/cjs/adapter/service-worker/types.js +0 -0
- package/dist/cjs/adapter/vercel/conninfo.js +0 -8
- package/dist/cjs/adapter/vercel/handler.js +0 -10
- package/dist/cjs/adapter/vercel/index.js +0 -5
- package/dist/cjs/client/client.js +0 -145
- package/dist/cjs/client/fetch-result-please.js +0 -67
- package/dist/cjs/client/index.js +0 -7
- package/dist/cjs/client/types.js +0 -0
- package/dist/cjs/client/utils.js +0 -70
- package/dist/cjs/compose.js +0 -51
- package/dist/cjs/context.js +0 -383
- package/dist/cjs/helper/accepts/accepts.js +0 -54
- package/dist/cjs/helper/accepts/index.js +0 -3
- package/dist/cjs/helper/adapter/index.js +0 -41
- package/dist/cjs/helper/conninfo/index.js +0 -0
- package/dist/cjs/helper/conninfo/types.js +0 -0
- package/dist/cjs/helper/cookie/index.js +0 -89
- package/dist/cjs/helper/css/common.js +0 -194
- package/dist/cjs/helper/css/index.js +0 -142
- package/dist/cjs/helper/dev/index.js +0 -53
- package/dist/cjs/helper/factory/index.js +0 -33
- package/dist/cjs/helper/html/index.js +0 -34
- package/dist/cjs/helper/proxy/index.js +0 -122
- package/dist/cjs/helper/route/index.js +0 -128
- package/dist/cjs/helper/ssg/index.js +0 -19
- package/dist/cjs/helper/ssg/middleware.js +0 -65
- package/dist/cjs/helper/ssg/plugins.js +0 -68
- package/dist/cjs/helper/ssg/ssg.js +0 -220
- package/dist/cjs/helper/ssg/utils.js +0 -70
- package/dist/cjs/helper/streaming/index.js +0 -8
- package/dist/cjs/helper/streaming/sse.js +0 -59
- package/dist/cjs/helper/streaming/stream.js +0 -26
- package/dist/cjs/helper/streaming/text.js +0 -12
- package/dist/cjs/helper/streaming/utils.js +0 -16
- package/dist/cjs/helper/testing/index.js +0 -18
- package/dist/cjs/helper/websocket/index.js +0 -56
- package/dist/cjs/hono-base.js +0 -351
- package/dist/cjs/hono.js +0 -29
- package/dist/cjs/http-exception.js +0 -56
- package/dist/cjs/index.js +0 -22
- package/dist/cjs/jsx/base.js +0 -266
- package/dist/cjs/jsx/children.js +0 -19
- package/dist/cjs/jsx/components.js +0 -147
- package/dist/cjs/jsx/constants.js +0 -15
- package/dist/cjs/jsx/context.js +0 -170
- package/dist/cjs/jsx/dom/client.js +0 -56
- package/dist/cjs/jsx/dom/components.js +0 -26
- package/dist/cjs/jsx/dom/context.js +0 -43
- package/dist/cjs/jsx/dom/css.js +0 -153
- package/dist/cjs/jsx/dom/hooks/index.js +0 -65
- package/dist/cjs/jsx/dom/index.js +0 -122
- package/dist/cjs/jsx/dom/intrinsic-element/components.js +0 -306
- package/dist/cjs/jsx/dom/jsx-dev-runtime.js +0 -17
- package/dist/cjs/jsx/dom/jsx-runtime.js +0 -5
- package/dist/cjs/jsx/dom/render.js +0 -525
- package/dist/cjs/jsx/dom/server.js +0 -44
- package/dist/cjs/jsx/dom/utils.js +0 -9
- package/dist/cjs/jsx/hooks/index.js +0 -280
- package/dist/cjs/jsx/index.js +0 -89
- package/dist/cjs/jsx/intrinsic-element/common.js +0 -27
- package/dist/cjs/jsx/intrinsic-element/components.js +0 -138
- package/dist/cjs/jsx/intrinsic-elements.js +0 -0
- package/dist/cjs/jsx/jsx-dev-runtime.js +0 -16
- package/dist/cjs/jsx/jsx-runtime.js +0 -37
- package/dist/cjs/jsx/streaming.js +0 -135
- package/dist/cjs/jsx/types.js +0 -0
- package/dist/cjs/jsx/utils.js +0 -116
- package/dist/cjs/middleware/basic-auth/index.js +0 -100
- package/dist/cjs/middleware/bearer-auth/index.js +0 -97
- package/dist/cjs/middleware/body-limit/index.js +0 -69
- package/dist/cjs/middleware/cache/index.js +0 -173
- package/dist/cjs/middleware/combine/index.js +0 -141
- package/dist/cjs/middleware/compress/index.js +0 -82
- package/dist/cjs/middleware/context-storage/index.js +0 -55
- package/dist/cjs/middleware/cors/index.js +0 -109
- package/dist/cjs/middleware/csrf/index.js +0 -106
- package/dist/cjs/middleware/etag/digest.js +0 -62
- package/dist/cjs/middleware/etag/index.js +0 -79
- package/dist/cjs/middleware/ip-restriction/index.js +0 -168
- package/dist/cjs/middleware/jsx-renderer/index.js +0 -104
- package/dist/cjs/middleware/jwk/index.js +0 -3
- package/dist/cjs/middleware/jwk/jwk.js +0 -122
- package/dist/cjs/middleware/jwt/index.js +0 -9
- package/dist/cjs/middleware/jwt/jwt.js +0 -124
- package/dist/cjs/middleware/language/index.js +0 -7
- package/dist/cjs/middleware/language/language.js +0 -208
- package/dist/cjs/middleware/logger/index.js +0 -51
- package/dist/cjs/middleware/method-not-allowed/index.js +0 -84
- package/dist/cjs/middleware/method-override/index.js +0 -105
- package/dist/cjs/middleware/mount/index.js +0 -71
- package/dist/cjs/middleware/powered-by/index.js +0 -25
- package/dist/cjs/middleware/pretty-json/index.js +0 -41
- package/dist/cjs/middleware/request-id/index.js +0 -3
- package/dist/cjs/middleware/request-id/request-id.js +0 -35
- package/dist/cjs/middleware/secure-headers/index.js +0 -4
- package/dist/cjs/middleware/secure-headers/permissions-policy.js +0 -0
- package/dist/cjs/middleware/secure-headers/secure-headers.js +0 -166
- package/dist/cjs/middleware/serve-static/index.js +0 -62
- package/dist/cjs/middleware/serve-static/path.js +0 -17
- package/dist/cjs/middleware/timeout/index.js +0 -42
- package/dist/cjs/middleware/timing/index.js +0 -7
- package/dist/cjs/middleware/timing/timing.js +0 -189
- package/dist/cjs/middleware/trailing-slash/index.js +0 -89
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/preset/quick.js +0 -19
- package/dist/cjs/preset/tiny.js +0 -16
- package/dist/cjs/request/constants.js +0 -5
- package/dist/cjs/request.js +0 -337
- package/dist/cjs/router/linear-router/index.js +0 -3
- package/dist/cjs/router/linear-router/router.js +0 -97
- package/dist/cjs/router/pattern-router/index.js +0 -3
- package/dist/cjs/router/pattern-router/router.js +0 -42
- package/dist/cjs/router/reg-exp-router/index.js +0 -7
- package/dist/cjs/router/reg-exp-router/matcher.js +0 -21
- package/dist/cjs/router/reg-exp-router/node.js +0 -96
- package/dist/cjs/router/reg-exp-router/prepared-router.js +0 -97
- package/dist/cjs/router/reg-exp-router/router.js +0 -102
- package/dist/cjs/router/reg-exp-router/trie.js +0 -74
- package/dist/cjs/router/smart-router/index.js +0 -3
- package/dist/cjs/router/smart-router/router.js +0 -50
- package/dist/cjs/router/trie-router/index.js +0 -3
- package/dist/cjs/router/trie-router/node.js +0 -135
- package/dist/cjs/router/trie-router/router.js +0 -16
- package/dist/cjs/router/utils.js +0 -5
- package/dist/cjs/router.js +0 -40
- package/dist/cjs/types.js +0 -5
- package/dist/cjs/utils/accept.js +0 -194
- package/dist/cjs/utils/basic-auth.js +0 -21
- package/dist/cjs/utils/body.js +0 -97
- package/dist/cjs/utils/buffer.js +0 -55
- package/dist/cjs/utils/color.js +0 -39
- package/dist/cjs/utils/compress.js +0 -12
- package/dist/cjs/utils/concurrent.js +0 -31
- package/dist/cjs/utils/constants.js +0 -8
- package/dist/cjs/utils/cookie.js +0 -129
- package/dist/cjs/utils/crypto.js +0 -38
- package/dist/cjs/utils/encode.js +0 -37
- package/dist/cjs/utils/filepath.js +0 -27
- package/dist/cjs/utils/handler.js +0 -14
- package/dist/cjs/utils/headers.js +0 -0
- package/dist/cjs/utils/html.js +0 -109
- package/dist/cjs/utils/http-status.js +0 -0
- package/dist/cjs/utils/ipaddr.js +0 -247
- package/dist/cjs/utils/jwt/index.js +0 -15
- package/dist/cjs/utils/jwt/jwa.js +0 -25
- package/dist/cjs/utils/jwt/jws.js +0 -135
- package/dist/cjs/utils/jwt/jwt.js +0 -136
- package/dist/cjs/utils/jwt/types.js +0 -124
- package/dist/cjs/utils/jwt/utf8.js +0 -11
- package/dist/cjs/utils/mime.js +0 -80
- package/dist/cjs/utils/stream.js +0 -89
- package/dist/cjs/utils/types.js +0 -0
- package/dist/cjs/utils/url.js +0 -215
- package/dist/cjs/validator/index.js +0 -3
- package/dist/cjs/validator/utils.js +0 -0
- package/dist/cjs/validator/validator.js +0 -65
- package/dist/types/adapter/aws-lambda/conninfo.d.ts +0 -30
- package/dist/types/adapter/aws-lambda/handler.d.ts +0 -230
- package/dist/types/adapter/aws-lambda/index.d.ts +0 -4
- package/dist/types/adapter/aws-lambda/types.d.ts +0 -183
- package/dist/types/adapter/bun/conninfo.d.ts +0 -10
- package/dist/types/adapter/bun/index.d.ts +0 -6
- package/dist/types/adapter/bun/serve-static.d.ts +0 -8
- package/dist/types/adapter/bun/server.d.ts +0 -11
- package/dist/types/adapter/bun/ssg.d.ts +0 -17
- package/dist/types/adapter/bun/websocket.d.ts +0 -54
- package/dist/types/adapter/cloudflare-pages/conninfo.d.ts +0 -24
- package/dist/types/adapter/cloudflare-pages/handler.d.ts +0 -45
- package/dist/types/adapter/cloudflare-pages/index.d.ts +0 -3
- package/dist/types/adapter/cloudflare-workers/conninfo.d.ts +0 -7
- package/dist/types/adapter/cloudflare-workers/index.d.ts +0 -4
- package/dist/types/adapter/cloudflare-workers/serve-static-module.d.ts +0 -7
- package/dist/types/adapter/cloudflare-workers/serve-static.d.ts +0 -21
- package/dist/types/adapter/cloudflare-workers/utils.d.ts +0 -13
- package/dist/types/adapter/cloudflare-workers/websocket.d.ts +0 -7
- package/dist/types/adapter/deno/conninfo.d.ts +0 -10
- package/dist/types/adapter/deno/deno.d.ts +0 -1
- package/dist/types/adapter/deno/index.d.ts +0 -5
- package/dist/types/adapter/deno/serve-static.d.ts +0 -8
- package/dist/types/adapter/deno/ssg.d.ts +0 -17
- package/dist/types/adapter/deno/websocket.d.ts +0 -7
- package/dist/types/adapter/lambda-edge/conninfo.d.ts +0 -7
- package/dist/types/adapter/lambda-edge/handler.d.ts +0 -113
- package/dist/types/adapter/lambda-edge/index.d.ts +0 -3
- package/dist/types/adapter/netlify/conninfo.d.ts +0 -24
- package/dist/types/adapter/netlify/handler.d.ts +0 -7
- package/dist/types/adapter/netlify/index.d.ts +0 -3
- package/dist/types/adapter/netlify/mod.d.ts +0 -3
- package/dist/types/adapter/service-worker/handler.d.ts +0 -18
- package/dist/types/adapter/service-worker/index.d.ts +0 -26
- package/dist/types/adapter/service-worker/types.d.ts +0 -17
- package/dist/types/adapter/vercel/conninfo.d.ts +0 -7
- package/dist/types/adapter/vercel/handler.d.ts +0 -7
- package/dist/types/adapter/vercel/index.d.ts +0 -3
- package/dist/types/package.json +0 -3
- package/dist/types/utils/buffer.d.ts +0 -19
- package/dist/types/utils/color.d.ts +0 -23
- package/dist/{types/client → client}/client.d.ts +0 -0
- package/dist/{types/client → client}/fetch-result-please.d.ts +0 -0
- package/dist/{types/client → client}/index.d.ts +0 -0
- package/dist/{types/client → client}/types.d.ts +1 -1
- package/dist/{types/client → client}/utils.d.ts +0 -0
- package/dist/{types/helper → helper}/accepts/accepts.d.ts +0 -0
- package/dist/{types/helper → helper}/accepts/index.d.ts +0 -0
- package/dist/{types/helper → helper}/adapter/index.d.ts +0 -0
- package/dist/{types/helper → helper}/conninfo/index.d.ts +0 -0
- package/dist/{types/helper → helper}/conninfo/types.d.ts +0 -0
- package/dist/{types/helper → helper}/cookie/index.d.ts +0 -0
- package/dist/{types/helper → helper}/css/common.d.ts +0 -0
- package/dist/{types/helper → helper}/css/index.d.ts +0 -0
- package/dist/{types/helper → helper}/dev/index.d.ts +0 -0
- package/dist/{types/helper → helper}/html/index.d.ts +0 -0
- package/dist/{types/helper → helper}/proxy/index.d.ts +0 -0
- package/dist/{types/helper → helper}/route/index.d.ts +0 -0
- package/dist/{types/helper → helper}/ssg/index.d.ts +0 -0
- package/dist/{types/helper → helper}/ssg/plugins.d.ts +0 -0
- package/dist/{types/helper → helper}/ssg/utils.d.ts +0 -0
- package/dist/{types/helper → helper}/streaming/index.d.ts +0 -0
- package/dist/{types/helper → helper}/streaming/sse.d.ts +0 -0
- package/dist/{types/helper → helper}/streaming/stream.d.ts +0 -0
- package/dist/{types/helper → helper}/streaming/text.d.ts +0 -0
- package/dist/{types/helper → helper}/streaming/utils.d.ts +0 -0
- package/dist/{types/helper → helper}/testing/index.d.ts +0 -0
- package/dist/{types/helper → helper}/websocket/index.d.ts +0 -0
- package/dist/{types/http-exception.d.ts → http-exception.d.ts} +0 -0
- package/dist/{types/index.d.ts → index.d.ts} +0 -0
- package/dist/{types/jsx → jsx}/base.d.ts +0 -0
- package/dist/{types/jsx → jsx}/children.d.ts +0 -0
- package/dist/{types/jsx → jsx}/components.d.ts +0 -0
- package/dist/{types/jsx → jsx}/constants.d.ts +0 -0
- package/dist/{types/jsx → jsx}/context.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/client.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/components.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/context.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/css.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/hooks/index.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/index.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/intrinsic-element/components.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/jsx-dev-runtime.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/jsx-runtime.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/render.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/server.d.ts +0 -0
- package/dist/{types/jsx → jsx}/dom/utils.d.ts +0 -0
- package/dist/{types/jsx → jsx}/hooks/index.d.ts +0 -0
- package/dist/{types/jsx → jsx}/index.d.ts +0 -0
- package/dist/{types/jsx → jsx}/intrinsic-element/common.d.ts +0 -0
- package/dist/{types/jsx → jsx}/intrinsic-element/components.d.ts +0 -0
- package/dist/{types/jsx → jsx}/intrinsic-elements.d.ts +0 -0
- package/dist/{types/jsx → jsx}/jsx-dev-runtime.d.ts +0 -0
- package/dist/{types/jsx → jsx}/jsx-runtime.d.ts +0 -0
- package/dist/{types/jsx → jsx}/streaming.d.ts +0 -0
- package/dist/{types/jsx → jsx}/types.d.ts +0 -0
- package/dist/{types/jsx → jsx}/utils.d.ts +0 -0
- package/dist/{types/middleware → middleware}/body-limit/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/cache/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/combine/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/compress/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/context-storage/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/cors/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/csrf/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/etag/digest.d.ts +0 -0
- package/dist/{types/middleware → middleware}/etag/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/ip-restriction/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/jsx-renderer/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/jwk/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/jwk/jwk.d.ts +0 -0
- package/dist/{types/middleware → middleware}/jwt/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/jwt/jwt.d.ts +0 -0
- package/dist/{types/middleware → middleware}/language/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/language/language.d.ts +0 -0
- package/dist/{types/middleware → middleware}/logger/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/method-not-allowed/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/method-override/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/mount/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/powered-by/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/pretty-json/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/request-id/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/request-id/request-id.d.ts +0 -0
- package/dist/{types/middleware → middleware}/secure-headers/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/secure-headers/permissions-policy.d.ts +0 -0
- package/dist/{types/middleware → middleware}/secure-headers/secure-headers.d.ts +0 -0
- package/dist/{types/middleware → middleware}/serve-static/path.d.ts +0 -0
- package/dist/{types/middleware → middleware}/timeout/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/timing/index.d.ts +0 -0
- package/dist/{types/middleware → middleware}/timing/timing.d.ts +0 -0
- package/dist/{types/middleware → middleware}/trailing-slash/index.d.ts +0 -0
- package/dist/{types/request → request}/constants.d.ts +0 -0
- package/dist/{types/router → router}/linear-router/index.d.ts +0 -0
- package/dist/{types/router → router}/linear-router/router.d.ts +0 -0
- package/dist/{types/router → router}/pattern-router/index.d.ts +0 -0
- package/dist/{types/router → router}/pattern-router/router.d.ts +0 -0
- package/dist/{types/router → router}/reg-exp-router/index.d.ts +0 -0
- package/dist/{types/router → router}/reg-exp-router/matcher.d.ts +0 -0
- package/dist/{types/router → router}/reg-exp-router/node.d.ts +0 -0
- package/dist/{types/router → router}/reg-exp-router/prepared-router.d.ts +0 -0
- package/dist/{types/router → router}/reg-exp-router/router.d.ts +0 -0
- package/dist/{types/router → router}/reg-exp-router/trie.d.ts +0 -0
- package/dist/{types/router → router}/smart-router/index.d.ts +0 -0
- package/dist/{types/router → router}/smart-router/router.d.ts +0 -0
- package/dist/{types/router → router}/trie-router/index.d.ts +0 -0
- package/dist/{types/router → router}/trie-router/node.d.ts +0 -0
- package/dist/{types/router → router}/trie-router/router.d.ts +0 -0
- package/dist/{types/router → router}/utils.d.ts +0 -0
- package/dist/{types/router.d.ts → router.d.ts} +0 -0
- package/dist/{types/types.d.ts → types.d.ts} +1 -1
- /package/dist/{types/utils → utils}/accept.d.ts +0 -0
- /package/dist/{types/utils → utils}/basic-auth.d.ts +0 -0
- /package/dist/{types/utils → utils}/body.d.ts +0 -0
- /package/dist/{types/utils → utils}/compress.d.ts +0 -0
- /package/dist/{types/utils → utils}/concurrent.d.ts +0 -0
- /package/dist/{types/utils → utils}/constants.d.ts +0 -0
- /package/dist/{types/utils → utils}/cookie.d.ts +0 -0
- /package/dist/{types/utils → utils}/crypto.d.ts +0 -0
- /package/dist/{types/utils → utils}/encode.d.ts +0 -0
- /package/dist/{types/utils → utils}/filepath.d.ts +0 -0
- /package/dist/{types/utils → utils}/handler.d.ts +0 -0
- /package/dist/{types/utils → utils}/headers.d.ts +0 -0
- /package/dist/{types/utils → utils}/html.d.ts +0 -0
- /package/dist/{types/utils → utils}/ipaddr.d.ts +0 -0
- /package/dist/{types/utils → utils}/jwt/index.d.ts +0 -0
- /package/dist/{types/utils → utils}/jwt/jwa.d.ts +0 -0
- /package/dist/{types/utils → utils}/jwt/jws.d.ts +0 -0
- /package/dist/{types/utils → utils}/jwt/jwt.d.ts +0 -0
- /package/dist/{types/utils → utils}/jwt/types.d.ts +0 -0
- /package/dist/{types/utils → utils}/jwt/utf8.d.ts +0 -0
- /package/dist/{types/utils → utils}/mime.d.ts +0 -0
- /package/dist/{types/utils → utils}/stream.d.ts +0 -0
- /package/dist/{types/utils → utils}/types.d.ts +0 -0
- /package/dist/{types/validator → validator}/index.d.ts +0 -0
- /package/dist/{types/validator → validator}/utils.d.ts +0 -0
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_utils_crypto = require("../../utils/crypto.js");
|
|
3
|
-
const require_request = require("../../request.js");
|
|
4
|
-
//#region src/middleware/cache/index.ts
|
|
5
|
-
/**
|
|
6
|
-
* status codes that can be cached by default.
|
|
7
|
-
*/
|
|
8
|
-
const defaultCacheableStatusCodes = [200];
|
|
9
|
-
const defaultMaxQueryBodySize = 65536;
|
|
10
|
-
const cacheKeyPath = "/.hono/cache";
|
|
11
|
-
const cacheKeyParameter = "__hono_cache_key";
|
|
12
|
-
const cacheMethodKeyParameter = "__hono_cache_method";
|
|
13
|
-
const queryDigestKeyParameter = "__hono_query_digest";
|
|
14
|
-
const cacheVaryKeyParameter = "__hono_cache_vary";
|
|
15
|
-
const queryRepresentationMetadataHeaders = [
|
|
16
|
-
"content-type",
|
|
17
|
-
"content-encoding",
|
|
18
|
-
"content-language",
|
|
19
|
-
"content-location"
|
|
20
|
-
];
|
|
21
|
-
const shouldSkipCacheControl = (cacheControl) => !!cacheControl && /(?:^|,\s*)(?:private|no-(?:store|cache))(?:\s*(?:=|,|$))/i.test(cacheControl);
|
|
22
|
-
const parseVaryDirectives = (vary) => {
|
|
23
|
-
if (vary == null) return [];
|
|
24
|
-
return (Array.isArray(vary) ? vary : vary.split(",")).map((directive) => directive.trim().toLowerCase()).filter(Boolean);
|
|
25
|
-
};
|
|
26
|
-
const createCacheKey = (key, requestUrl, request, varyHeaders) => {
|
|
27
|
-
const url = new URL(cacheKeyPath, requestUrl);
|
|
28
|
-
url.searchParams.append(cacheKeyParameter, key);
|
|
29
|
-
url.searchParams.append(cacheMethodKeyParameter, request.method);
|
|
30
|
-
if (request.method === "QUERY") url.searchParams.append(queryDigestKeyParameter, request.digest);
|
|
31
|
-
for (const header of varyHeaders) url.searchParams.append(cacheVaryKeyParameter, JSON.stringify(header));
|
|
32
|
-
return url.href;
|
|
33
|
-
};
|
|
34
|
-
const shouldSkipCache = (res, optionsVaryDirectives, responseVary) => responseVary.length && (!optionsVaryDirectives || responseVary.some((name) => !optionsVaryDirectives.has(name))) || shouldSkipCacheControl(res.headers.get("Cache-Control")) || res.headers.has("Set-Cookie");
|
|
35
|
-
const reportCacheNotAvailable = (onCacheNotAvailable, reason) => {
|
|
36
|
-
if (onCacheNotAvailable === false) {} else if (onCacheNotAvailable) onCacheNotAvailable(reason);
|
|
37
|
-
else console.log(reason);
|
|
38
|
-
};
|
|
39
|
-
const createQueryDigest = async (c, maxQueryBodySize) => {
|
|
40
|
-
if (!globalThis.crypto?.subtle) return;
|
|
41
|
-
if (c.req.raw.bodyUsed && Object.keys(c.req.bodyCache)[0] === "formData") return;
|
|
42
|
-
try {
|
|
43
|
-
const requestHeaders = c.req.raw.headers;
|
|
44
|
-
const metadata = new TextEncoder().encode(JSON.stringify(queryRepresentationMetadataHeaders.map((header) => [header, requestHeaders.get(header)])));
|
|
45
|
-
const body = (await require_request.cloneRawRequest(c.req)).body;
|
|
46
|
-
const chunks = [];
|
|
47
|
-
let bodySize = 0;
|
|
48
|
-
if (body) {
|
|
49
|
-
const reader = body.getReader();
|
|
50
|
-
for (;;) {
|
|
51
|
-
const { done, value } = await reader.read();
|
|
52
|
-
if (done) break;
|
|
53
|
-
bodySize += value.byteLength;
|
|
54
|
-
if (bodySize > maxQueryBodySize) {
|
|
55
|
-
reader.cancel().catch(() => {});
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
chunks.push(value);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
const data = new Uint8Array(metadata.byteLength + bodySize);
|
|
62
|
-
data.set(metadata);
|
|
63
|
-
let offset = metadata.byteLength;
|
|
64
|
-
for (const chunk of chunks) {
|
|
65
|
-
data.set(chunk, offset);
|
|
66
|
-
offset += chunk.byteLength;
|
|
67
|
-
}
|
|
68
|
-
return await require_utils_crypto.sha256(data) ?? void 0;
|
|
69
|
-
} catch {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* Cache Middleware for Hono.
|
|
75
|
-
*
|
|
76
|
-
* @see {@link https://hono.dev/docs/middleware/builtin/cache}
|
|
77
|
-
*
|
|
78
|
-
* @param {Object} options - The options for the cache middleware.
|
|
79
|
-
* @param {string | Function} options.cacheName - The name of the cache. Can be used to store multiple caches with different identifiers.
|
|
80
|
-
* @param {boolean} [options.wait=false] - A boolean indicating if Hono should wait for the Promise of the `cache.put` function to resolve before continuing with the request. Required to be true for the Deno environment.
|
|
81
|
-
* @param {string} [options.cacheControl] - A string of directives for the `Cache-Control` header.
|
|
82
|
-
* @param {string | string[]} [options.vary] - Adds the configured request headers to the cache key variants and sets the `Vary` header in the response. If the original response header already contains a `Vary` header, the values are merged, removing any duplicates.
|
|
83
|
-
* @param {Function} [options.keyGenerator] - Generates keys for every request in the `cacheName` store. This can be used to cache data based on request parameters or context parameters. QUERY keys additionally include a digest of the request content and its representation metadata.
|
|
84
|
-
* @param {number} [options.maxQueryBodySize=65536] - The maximum QUERY request body size in bytes that can be cached. Larger QUERY requests bypass the cache.
|
|
85
|
-
* @param {number[]} [options.cacheableStatusCodes=[200]] - An array of status codes that can be cached.
|
|
86
|
-
* @param {Function | false} [options.onCacheNotAvailable] - A callback invoked with the reason when `globalThis.caches` is not available or QUERY caching cannot use Web Crypto. By default, the reason is logged to the console. Set to `false` to suppress the log, or provide a custom function.
|
|
87
|
-
* @returns {MiddlewareHandler} The middleware handler function.
|
|
88
|
-
* @throws {Error} If the `vary` option includes "*".
|
|
89
|
-
*
|
|
90
|
-
* @example
|
|
91
|
-
* ```ts
|
|
92
|
-
* app.use(
|
|
93
|
-
* '*',
|
|
94
|
-
* cache({
|
|
95
|
-
* cacheName: 'my-app',
|
|
96
|
-
* cacheControl: 'max-age=3600',
|
|
97
|
-
* })
|
|
98
|
-
* )
|
|
99
|
-
* ```
|
|
100
|
-
*/
|
|
101
|
-
const cache = (options) => {
|
|
102
|
-
if (!globalThis.caches) {
|
|
103
|
-
reportCacheNotAvailable(options.onCacheNotAvailable, "Cache Middleware is not enabled because caches is not defined.");
|
|
104
|
-
return async (_c, next) => await next();
|
|
105
|
-
}
|
|
106
|
-
if (!globalThis.crypto?.subtle) reportCacheNotAvailable(options.onCacheNotAvailable, "Cache Middleware cannot cache QUERY requests because Web Crypto is not available.");
|
|
107
|
-
if (options.wait === void 0) options.wait = false;
|
|
108
|
-
const cacheControlDirectives = options.cacheControl?.split(",").map((directive) => directive.toLowerCase());
|
|
109
|
-
const optionsVaryList = parseVaryDirectives(options.vary);
|
|
110
|
-
const varyDirectives = optionsVaryList.length ? new Set(optionsVaryList) : void 0;
|
|
111
|
-
if (varyDirectives?.has("*")) throw new Error("Middleware vary configuration cannot include \"*\", as it disallows effective caching.");
|
|
112
|
-
const cacheableStatusCodes = new Set(options.cacheableStatusCodes ?? defaultCacheableStatusCodes);
|
|
113
|
-
const maxQueryBodySize = options.maxQueryBodySize ?? defaultMaxQueryBodySize;
|
|
114
|
-
const addHeader = (c, responseVary) => {
|
|
115
|
-
if (cacheControlDirectives) {
|
|
116
|
-
const existingDirectives = c.res.headers.get("Cache-Control")?.split(",").map((d) => d.trim().split("=", 1)[0].toLowerCase()) ?? [];
|
|
117
|
-
for (const directive of cacheControlDirectives) {
|
|
118
|
-
let [name, value] = directive.trim().split("=", 2);
|
|
119
|
-
name = name.toLowerCase();
|
|
120
|
-
if (!existingDirectives.includes(name)) c.header("Cache-Control", `${name}${value ? `=${value}` : ""}`, { append: true });
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
if (varyDirectives) {
|
|
124
|
-
if (responseVary.length === 0) c.header("Vary", Array.from(varyDirectives).join(", "));
|
|
125
|
-
else {
|
|
126
|
-
const merged = new Set(varyDirectives);
|
|
127
|
-
for (const directive of responseVary) merged.add(directive);
|
|
128
|
-
if (merged.has("*")) c.header("Vary", "*");
|
|
129
|
-
else c.header("Vary", Array.from(merged).join(", "));
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
return async function cache(c, next) {
|
|
134
|
-
if (c.req.method !== "GET" && c.req.method !== "QUERY" || c.req.raw.headers.has("Authorization")) {
|
|
135
|
-
await next();
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
let cacheKeyRequest = { method: "GET" };
|
|
139
|
-
if (c.req.method === "QUERY") {
|
|
140
|
-
const digest = await createQueryDigest(c, maxQueryBodySize);
|
|
141
|
-
if (digest === void 0) {
|
|
142
|
-
await next();
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
cacheKeyRequest = {
|
|
146
|
-
method: "QUERY",
|
|
147
|
-
digest
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
let key = c.req.url;
|
|
151
|
-
if (options.keyGenerator) key = await options.keyGenerator(c);
|
|
152
|
-
const varyHeaders = [];
|
|
153
|
-
if (varyDirectives) for (const directive of varyDirectives) {
|
|
154
|
-
const value = c.req.raw.headers.get(directive) ?? "";
|
|
155
|
-
varyHeaders.push([directive, value]);
|
|
156
|
-
}
|
|
157
|
-
key = createCacheKey(key, c.req.url, cacheKeyRequest, varyHeaders);
|
|
158
|
-
const cacheName = typeof options.cacheName === "function" ? await options.cacheName(c) : options.cacheName;
|
|
159
|
-
const cache = await caches.open(cacheName);
|
|
160
|
-
const response = await cache.match(key);
|
|
161
|
-
if (response) return new Response(response.body, response);
|
|
162
|
-
await next();
|
|
163
|
-
if (!cacheableStatusCodes.has(c.res.status)) return;
|
|
164
|
-
const responseVary = parseVaryDirectives(c.res.headers.get("Vary"));
|
|
165
|
-
addHeader(c, responseVary);
|
|
166
|
-
if (shouldSkipCache(c.res, varyDirectives, responseVary)) return;
|
|
167
|
-
const res = c.res.clone();
|
|
168
|
-
if (options.wait) await cache.put(key, res);
|
|
169
|
-
else c.executionCtx.waitUntil(cache.put(key, res));
|
|
170
|
-
};
|
|
171
|
-
};
|
|
172
|
-
//#endregion
|
|
173
|
-
exports.cache = cache;
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_compose = require("../../compose.js");
|
|
3
|
-
require("../../router.js");
|
|
4
|
-
const require_router_trie_router_router = require("../../router/trie-router/router.js");
|
|
5
|
-
require("../../router/trie-router/index.js");
|
|
6
|
-
//#region src/middleware/combine/index.ts
|
|
7
|
-
/**
|
|
8
|
-
* @module
|
|
9
|
-
* Combine Middleware for Hono.
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Create a composed middleware that runs the first middleware that returns true.
|
|
13
|
-
*
|
|
14
|
-
* @param middleware - An array of MiddlewareHandler or Condition functions.
|
|
15
|
-
* Middleware is applied in the order it is passed, and if any middleware exits without returning
|
|
16
|
-
* an exception first, subsequent middleware will not be executed.
|
|
17
|
-
* You can also pass a condition function that returns a boolean value. If returns true
|
|
18
|
-
* the evaluation will be halted, and rest of the middleware will not be executed.
|
|
19
|
-
* @returns A composed middleware.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```ts
|
|
23
|
-
* import { some } from 'hono/combine'
|
|
24
|
-
* import { bearerAuth } from 'hono/bearer-auth'
|
|
25
|
-
* import { myRateLimit } from '@/rate-limit'
|
|
26
|
-
*
|
|
27
|
-
* // If client has a valid token, then skip rate limiting.
|
|
28
|
-
* // Otherwise, apply rate limiting.
|
|
29
|
-
* app.use('/api/*', some(
|
|
30
|
-
* bearerAuth({ token }),
|
|
31
|
-
* myRateLimit({ limit: 100 }),
|
|
32
|
-
* ));
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
const some = (...middleware) => {
|
|
36
|
-
return async function some(c, next) {
|
|
37
|
-
let isNextCalled = false;
|
|
38
|
-
const wrappedNext = () => {
|
|
39
|
-
isNextCalled = true;
|
|
40
|
-
return next();
|
|
41
|
-
};
|
|
42
|
-
let lastError;
|
|
43
|
-
let response;
|
|
44
|
-
for (const handler of middleware) try {
|
|
45
|
-
const result = await handler(c, wrappedNext);
|
|
46
|
-
if (result === true && !c.finalized) await wrappedNext();
|
|
47
|
-
else if (result === false) {
|
|
48
|
-
lastError = /* @__PURE__ */ new Error("No successful middleware found");
|
|
49
|
-
continue;
|
|
50
|
-
} else if (result && result !== true) response = result;
|
|
51
|
-
lastError = void 0;
|
|
52
|
-
break;
|
|
53
|
-
} catch (error) {
|
|
54
|
-
lastError = error;
|
|
55
|
-
if (isNextCalled) break;
|
|
56
|
-
}
|
|
57
|
-
if (lastError) throw lastError;
|
|
58
|
-
return response;
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* Create a composed middleware that runs all middleware and throws an error if any of them fail.
|
|
63
|
-
*
|
|
64
|
-
* @param middleware - An array of MiddlewareHandler or Condition functions.
|
|
65
|
-
* Middleware is applied in the order it is passed, and if any middleware throws an error,
|
|
66
|
-
* subsequent middleware will not be executed.
|
|
67
|
-
* You can also pass a condition function that returns a boolean value. If returns false
|
|
68
|
-
* the evaluation will be halted, and rest of the middleware will not be executed.
|
|
69
|
-
* @returns A composed middleware.
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* ```ts
|
|
73
|
-
* import { some, every } from 'hono/combine'
|
|
74
|
-
* import { bearerAuth } from 'hono/bearer-auth'
|
|
75
|
-
* import { myCheckLocalNetwork } from '@/check-local-network'
|
|
76
|
-
* import { myRateLimit } from '@/rate-limit'
|
|
77
|
-
*
|
|
78
|
-
* // If client is in local network, then skip authentication and rate limiting.
|
|
79
|
-
* // Otherwise, apply authentication and rate limiting.
|
|
80
|
-
* app.use('/api/*', some(
|
|
81
|
-
* myCheckLocalNetwork(),
|
|
82
|
-
* every(
|
|
83
|
-
* bearerAuth({ token }),
|
|
84
|
-
* myRateLimit({ limit: 100 }),
|
|
85
|
-
* ),
|
|
86
|
-
* ));
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
const every = (...middleware) => {
|
|
90
|
-
return async function every(c, next) {
|
|
91
|
-
const currentRouteIndex = c.req.routeIndex;
|
|
92
|
-
await require_compose.compose(middleware.map((m) => [[async (c, next) => {
|
|
93
|
-
c.req.routeIndex = currentRouteIndex;
|
|
94
|
-
const res = await m(c, next);
|
|
95
|
-
if (res === false) throw new Error("Unmet condition");
|
|
96
|
-
return res;
|
|
97
|
-
}]]))(c, next);
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* Create a composed middleware that runs all middleware except when the condition is met.
|
|
102
|
-
*
|
|
103
|
-
* @param condition - A string or Condition function.
|
|
104
|
-
* If there are multiple targets to match any of them, they can be passed as an array.
|
|
105
|
-
* If a string is passed, it will be treated as a path pattern to match.
|
|
106
|
-
* If a Condition function is passed, it will be evaluated against the request context.
|
|
107
|
-
* @param middleware - Middleware to run when the condition is not met.
|
|
108
|
-
* Multiple middleware can be passed, and they are applied in the order they are passed.
|
|
109
|
-
* @returns A composed middleware.
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* ```ts
|
|
113
|
-
* import { except } from 'hono/combine'
|
|
114
|
-
* import { bearerAuth } from 'hono/bearer-auth'
|
|
115
|
-
*
|
|
116
|
-
* // If client is accessing public API, then skip authentication.
|
|
117
|
-
* // Otherwise, require a valid token.
|
|
118
|
-
* app.use('/api/*', except(
|
|
119
|
-
* '/api/public/*',
|
|
120
|
-
* bearerAuth({ token }),
|
|
121
|
-
* ));
|
|
122
|
-
* ```
|
|
123
|
-
*/
|
|
124
|
-
const except = (condition, ...middleware) => {
|
|
125
|
-
let router = void 0;
|
|
126
|
-
const conditions = (Array.isArray(condition) ? condition : [condition]).map((condition) => {
|
|
127
|
-
if (typeof condition === "string") {
|
|
128
|
-
router ||= new require_router_trie_router_router.TrieRouter();
|
|
129
|
-
router.add("ALL", condition, true);
|
|
130
|
-
} else return condition;
|
|
131
|
-
}).filter(Boolean);
|
|
132
|
-
if (router) conditions.unshift((c) => !!router?.match("ALL", c.req.path)?.[0]?.[0]?.[0]);
|
|
133
|
-
const handler = some((c) => conditions.some((cond) => cond(c)), every(...middleware));
|
|
134
|
-
return async function except(c, next) {
|
|
135
|
-
await handler(c, next);
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
//#endregion
|
|
139
|
-
exports.every = every;
|
|
140
|
-
exports.except = except;
|
|
141
|
-
exports.some = some;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_utils_accept = require("../../utils/accept.js");
|
|
3
|
-
const require_utils_compress = require("../../utils/compress.js");
|
|
4
|
-
//#region src/middleware/compress/index.ts
|
|
5
|
-
const ENCODING_TYPES = ["gzip", "deflate"];
|
|
6
|
-
const cacheControlNoTransformRegExp = /(?:^|,)\s*?no-transform\s*?(?:,|$)/i;
|
|
7
|
-
const selectEncoding = (header, candidates) => {
|
|
8
|
-
if (header === void 0) return;
|
|
9
|
-
const accepts = require_utils_accept.parseAccept(header);
|
|
10
|
-
const wildcardQ = accepts.find((a) => a.type === "*")?.q;
|
|
11
|
-
let best;
|
|
12
|
-
for (const enc of candidates) {
|
|
13
|
-
const explicit = accepts.find((a) => a.type.toLowerCase() === enc);
|
|
14
|
-
const q = explicit ? explicit.q : wildcardQ ?? 0;
|
|
15
|
-
if (q === 1) return enc;
|
|
16
|
-
else if (q > 0 && (!best || q > best.q)) best = {
|
|
17
|
-
encoding: enc,
|
|
18
|
-
q
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
return best?.encoding;
|
|
22
|
-
};
|
|
23
|
-
const varyAcceptEncodingRegExp = /(?:^|,)\s*accept-encoding\s*(?:,|$)/i;
|
|
24
|
-
/**
|
|
25
|
-
* Compress Middleware for Hono.
|
|
26
|
-
*
|
|
27
|
-
* @see {@link https://hono.dev/docs/middleware/builtin/compress}
|
|
28
|
-
*
|
|
29
|
-
* @param {CompressionOptions} [options] - The options for the compress middleware.
|
|
30
|
-
* @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.
|
|
31
|
-
* @param {number} [options.threshold=1024] - The minimum size in bytes to compress. Defaults to 1024 bytes.
|
|
32
|
-
* @param {RegExp | Function} [options.contentTypeFilter=COMPRESSIBLE_CONTENT_TYPE_REGEX] - A RegExp or function to determine if the response Content-Type should be compressed.
|
|
33
|
-
* @returns {MiddlewareHandler} The middleware handler function.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```ts
|
|
37
|
-
* const app = new Hono()
|
|
38
|
-
*
|
|
39
|
-
* app.use(compress())
|
|
40
|
-
*
|
|
41
|
-
* // Compress only JSON responses
|
|
42
|
-
* app.use(compress({ contentTypeFilter: /^application\/json/ }))
|
|
43
|
-
*
|
|
44
|
-
* // Compress based on custom Content-Type logic
|
|
45
|
-
* app.use(compress({ contentTypeFilter: (type) => COMPRESSIBLE_CONTENT_TYPE_REGEX.test(type) || type === "application/x-myformat" }))
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
const compress = (options) => {
|
|
49
|
-
const threshold = options?.threshold ?? 1024;
|
|
50
|
-
const candidates = options?.encoding ? [options.encoding] : ENCODING_TYPES;
|
|
51
|
-
const contentTypeFilter = options?.contentTypeFilter ?? require_utils_compress.COMPRESSIBLE_CONTENT_TYPE_REGEX;
|
|
52
|
-
const shouldCompress = typeof contentTypeFilter === "function" ? (res) => {
|
|
53
|
-
const type = res.headers.get("Content-Type");
|
|
54
|
-
return type && contentTypeFilter(type);
|
|
55
|
-
} : (res) => {
|
|
56
|
-
const type = res.headers.get("Content-Type");
|
|
57
|
-
return type && contentTypeFilter.test(type);
|
|
58
|
-
};
|
|
59
|
-
return async function compress(ctx, next) {
|
|
60
|
-
await next();
|
|
61
|
-
const contentLength = ctx.res.headers.get("Content-Length");
|
|
62
|
-
if (ctx.res.status === 206 || ctx.res.headers.has("Content-Encoding") || ctx.res.headers.has("Transfer-Encoding") || ctx.req.method === "HEAD" || contentLength && Number(contentLength) < threshold || !shouldCompress(ctx.res) || !shouldTransform(ctx.res)) return;
|
|
63
|
-
const current = ctx.res.headers.get("Vary");
|
|
64
|
-
if (current !== "*" && !(current && varyAcceptEncodingRegExp.test(current))) ctx.header("Vary", current ? `${current}, Accept-Encoding` : "Accept-Encoding");
|
|
65
|
-
const accepted = ctx.req.header("Accept-Encoding");
|
|
66
|
-
const encoding = selectEncoding(accepted, candidates);
|
|
67
|
-
if (!encoding || !ctx.res.body) return;
|
|
68
|
-
const stream = new CompressionStream(encoding);
|
|
69
|
-
ctx.res = new Response(ctx.res.body.pipeThrough(stream), ctx.res);
|
|
70
|
-
ctx.res.headers.delete("Content-Length");
|
|
71
|
-
ctx.res.headers.set("Content-Encoding", encoding);
|
|
72
|
-
const etag = ctx.res.headers.get("ETag");
|
|
73
|
-
if (etag && !etag.startsWith("W/")) ctx.res.headers.set("ETag", `W/${etag}`);
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
const shouldTransform = (res) => {
|
|
77
|
-
const cacheControl = res.headers.get("Cache-Control");
|
|
78
|
-
return !cacheControl || !cacheControlNoTransformRegExp.test(cacheControl);
|
|
79
|
-
};
|
|
80
|
-
//#endregion
|
|
81
|
-
exports.COMPRESSIBLE_CONTENT_TYPE_REGEX = require_utils_compress.COMPRESSIBLE_CONTENT_TYPE_REGEX;
|
|
82
|
-
exports.compress = compress;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
//#region src/middleware/context-storage/index.ts
|
|
3
|
-
/**
|
|
4
|
-
* @module
|
|
5
|
-
* Context Storage Middleware for Hono.
|
|
6
|
-
*/
|
|
7
|
-
const asyncLocalStorage = new (require("node:async_hooks")).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
|
-
const contextStorage = () => {
|
|
40
|
-
return async function contextStorage(c, next) {
|
|
41
|
-
await asyncLocalStorage.run(c, next);
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
const tryGetContext = () => {
|
|
45
|
-
return asyncLocalStorage.getStore();
|
|
46
|
-
};
|
|
47
|
-
const getContext = () => {
|
|
48
|
-
const context = tryGetContext();
|
|
49
|
-
if (!context) throw new Error("Context is not available");
|
|
50
|
-
return context;
|
|
51
|
-
};
|
|
52
|
-
//#endregion
|
|
53
|
-
exports.contextStorage = contextStorage;
|
|
54
|
-
exports.getContext = getContext;
|
|
55
|
-
exports.tryGetContext = tryGetContext;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
//#region src/middleware/cors/index.ts
|
|
3
|
-
/**
|
|
4
|
-
* CORS Middleware for Hono.
|
|
5
|
-
*
|
|
6
|
-
* @see {@link https://hono.dev/docs/middleware/builtin/cors}
|
|
7
|
-
*
|
|
8
|
-
* @param {CORSOptions} [options] - The options for the CORS middleware.
|
|
9
|
-
* @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.
|
|
10
|
-
* @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.
|
|
11
|
-
* @param {string[]} [options.allowHeaders=[]] - The value of "Access-Control-Allow-Headers" CORS header.
|
|
12
|
-
* @param {number} [options.maxAge] - The value of "Access-Control-Max-Age" CORS header.
|
|
13
|
-
* @param {boolean} [options.credentials] - The value of "Access-Control-Allow-Credentials" CORS header.
|
|
14
|
-
* @param {string[]} [options.exposeHeaders=[]] - The value of "Access-Control-Expose-Headers" CORS header.
|
|
15
|
-
* @returns {MiddlewareHandler} The middleware handler function.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```ts
|
|
19
|
-
* const app = new Hono()
|
|
20
|
-
*
|
|
21
|
-
* app.use('/api/*', cors())
|
|
22
|
-
* app.use(
|
|
23
|
-
* '/api2/*',
|
|
24
|
-
* cors({
|
|
25
|
-
* origin: 'http://example.com',
|
|
26
|
-
* allowHeaders: ['X-Custom-Header', 'Upgrade-Insecure-Requests'],
|
|
27
|
-
* allowMethods: ['POST', 'GET', 'OPTIONS'],
|
|
28
|
-
* exposeHeaders: ['Content-Length', 'X-Kuma-Revision'],
|
|
29
|
-
* maxAge: 600,
|
|
30
|
-
* credentials: true,
|
|
31
|
-
* })
|
|
32
|
-
* )
|
|
33
|
-
*
|
|
34
|
-
* app.all('/api/abc', (c) => {
|
|
35
|
-
* return c.json({ success: true })
|
|
36
|
-
* })
|
|
37
|
-
* app.all('/api2/abc', (c) => {
|
|
38
|
-
* return c.json({ success: true })
|
|
39
|
-
* })
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
const cors = (options) => {
|
|
43
|
-
const opts = {
|
|
44
|
-
origin: "*",
|
|
45
|
-
allowMethods: [
|
|
46
|
-
"GET",
|
|
47
|
-
"HEAD",
|
|
48
|
-
"PUT",
|
|
49
|
-
"POST",
|
|
50
|
-
"DELETE",
|
|
51
|
-
"PATCH",
|
|
52
|
-
"QUERY"
|
|
53
|
-
],
|
|
54
|
-
allowHeaders: [],
|
|
55
|
-
exposeHeaders: [],
|
|
56
|
-
...options
|
|
57
|
-
};
|
|
58
|
-
const exposeHeadersStr = opts.exposeHeaders?.length ? opts.exposeHeaders.join(",") : void 0;
|
|
59
|
-
const allowHeadersStr = opts.allowHeaders?.length ? opts.allowHeaders.join(",") : void 0;
|
|
60
|
-
const findAllowOrigin = ((optsOrigin) => {
|
|
61
|
-
if (typeof optsOrigin === "string") {
|
|
62
|
-
if (optsOrigin === "*") return () => optsOrigin;
|
|
63
|
-
else return (origin) => optsOrigin === origin ? origin : null;
|
|
64
|
-
} else if (typeof optsOrigin === "function") return optsOrigin;
|
|
65
|
-
else return (origin) => optsOrigin.includes(origin) ? origin : null;
|
|
66
|
-
})(opts.origin);
|
|
67
|
-
const findAllowMethods = ((optsAllowMethods) => {
|
|
68
|
-
if (typeof optsAllowMethods === "function") return async (origin, c) => (await optsAllowMethods(origin, c)).join(",");
|
|
69
|
-
else if (Array.isArray(optsAllowMethods)) {
|
|
70
|
-
const methodsStr = optsAllowMethods.join(",");
|
|
71
|
-
return () => methodsStr;
|
|
72
|
-
} else return () => "";
|
|
73
|
-
})(opts.allowMethods);
|
|
74
|
-
return async function cors(c, next) {
|
|
75
|
-
function set(key, value) {
|
|
76
|
-
c.res.headers.set(key, value);
|
|
77
|
-
}
|
|
78
|
-
const allowOrigin = await findAllowOrigin(c.req.header("origin") || "", c);
|
|
79
|
-
if (allowOrigin) set("Access-Control-Allow-Origin", allowOrigin);
|
|
80
|
-
if (opts.credentials) set("Access-Control-Allow-Credentials", "true");
|
|
81
|
-
if (exposeHeadersStr) set("Access-Control-Expose-Headers", exposeHeadersStr);
|
|
82
|
-
if (c.req.method === "OPTIONS") {
|
|
83
|
-
if (opts.origin !== "*") c.res.headers.append("Vary", "Origin");
|
|
84
|
-
if (opts.maxAge != null) set("Access-Control-Max-Age", opts.maxAge.toString());
|
|
85
|
-
const allowMethods = await findAllowMethods(c.req.header("origin") || "", c);
|
|
86
|
-
if (allowMethods) set("Access-Control-Allow-Methods", allowMethods);
|
|
87
|
-
let headersStr = allowHeadersStr;
|
|
88
|
-
if (!headersStr) {
|
|
89
|
-
const requestHeaders = c.req.header("Access-Control-Request-Headers");
|
|
90
|
-
if (requestHeaders) headersStr = requestHeaders.split(",").map((h) => h.trim()).join(",");
|
|
91
|
-
}
|
|
92
|
-
if (headersStr) {
|
|
93
|
-
set("Access-Control-Allow-Headers", headersStr);
|
|
94
|
-
c.res.headers.append("Vary", "Access-Control-Request-Headers");
|
|
95
|
-
}
|
|
96
|
-
c.res.headers.delete("Content-Length");
|
|
97
|
-
c.res.headers.delete("Content-Type");
|
|
98
|
-
return new Response(null, {
|
|
99
|
-
headers: c.res.headers,
|
|
100
|
-
status: 204,
|
|
101
|
-
statusText: "No Content"
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
await next();
|
|
105
|
-
if (opts.origin !== "*") c.header("Vary", "Origin", { append: true });
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
//#endregion
|
|
109
|
-
exports.cors = cors;
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_http_exception = require("../../http-exception.js");
|
|
3
|
-
//#region src/middleware/csrf/index.ts
|
|
4
|
-
const secFetchSiteValues = [
|
|
5
|
-
"same-origin",
|
|
6
|
-
"same-site",
|
|
7
|
-
"none",
|
|
8
|
-
"cross-site"
|
|
9
|
-
];
|
|
10
|
-
const isSecFetchSite = (value) => secFetchSiteValues.includes(value);
|
|
11
|
-
const isSafeMethodRe = /^(GET|HEAD|OPTIONS)$/;
|
|
12
|
-
const isRequestedByFormElementRe = /^\b(application\/x-www-form-urlencoded|multipart\/form-data|text\/plain)\b/i;
|
|
13
|
-
/**
|
|
14
|
-
* CSRF Protection Middleware for Hono.
|
|
15
|
-
*
|
|
16
|
-
* Protects against Cross-Site Request Forgery attacks by validating request origins
|
|
17
|
-
* and sec-fetch-site headers. The request is allowed if either validation passes.
|
|
18
|
-
*
|
|
19
|
-
* @see {@link https://hono.dev/docs/middleware/builtin/csrf}
|
|
20
|
-
*
|
|
21
|
-
* @param {CSRFOptions} [options] - The options for the CSRF protection middleware.
|
|
22
|
-
* @param {string|string[]|(origin: string, context: Context) => boolean} [options.origin] -
|
|
23
|
-
* Allowed origins for requests.
|
|
24
|
-
* - string: Single allowed origin (e.g., 'https://example.com')
|
|
25
|
-
* - string[]: Multiple allowed origins
|
|
26
|
-
* - function: Custom validation logic
|
|
27
|
-
* - Default: Only same origin as the request URL
|
|
28
|
-
* @param {string|string[]|(secFetchSite: string, context: Context) => boolean} [options.secFetchSite] -
|
|
29
|
-
* Sec-Fetch-Site header validation. Standard values include 'same-origin', 'same-site', 'cross-site', 'none'.
|
|
30
|
-
* - string: Single allowed value (e.g., 'same-origin')
|
|
31
|
-
* - string[]: Multiple allowed values (e.g., ['same-origin', 'same-site'])
|
|
32
|
-
* - function: Custom validation with access to context
|
|
33
|
-
* - Default: Only allows 'same-origin'
|
|
34
|
-
* @returns {MiddlewareHandler} The middleware handler function.
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```ts
|
|
38
|
-
* const app = new Hono()
|
|
39
|
-
*
|
|
40
|
-
* // Default: both origin and sec-fetch-site validation
|
|
41
|
-
* app.use('*', csrf())
|
|
42
|
-
*
|
|
43
|
-
* // Allow specific origins
|
|
44
|
-
* app.use('*', csrf({ origin: 'https://example.com' }))
|
|
45
|
-
* app.use('*', csrf({ origin: ['https://app.com', 'https://api.com'] }))
|
|
46
|
-
*
|
|
47
|
-
* // Allow specific sec-fetch-site values
|
|
48
|
-
* app.use('*', csrf({ secFetchSite: 'same-origin' }))
|
|
49
|
-
* app.use('*', csrf({ secFetchSite: ['same-origin', 'same-site'] }))
|
|
50
|
-
*
|
|
51
|
-
* // Dynamic sec-fetch-site validation
|
|
52
|
-
* app.use('*', csrf({
|
|
53
|
-
* secFetchSite: (secFetchSite, c) => {
|
|
54
|
-
* // Always allow same-origin
|
|
55
|
-
* if (secFetchSite === 'same-origin') return true
|
|
56
|
-
* // Allow cross-site for webhook endpoints
|
|
57
|
-
* if (secFetchSite === 'cross-site' && c.req.path.startsWith('/webhook/')) {
|
|
58
|
-
* return true
|
|
59
|
-
* }
|
|
60
|
-
* return false
|
|
61
|
-
* }
|
|
62
|
-
* }))
|
|
63
|
-
*
|
|
64
|
-
* // Dynamic origin validation
|
|
65
|
-
* app.use('*', csrf({
|
|
66
|
-
* origin: (origin, c) => {
|
|
67
|
-
* // Allow same origin
|
|
68
|
-
* if (origin === new URL(c.req.url).origin) return true
|
|
69
|
-
* // Allow specific trusted domains
|
|
70
|
-
* return ['https://app.example.com', 'https://admin.example.com'].includes(origin)
|
|
71
|
-
* }
|
|
72
|
-
* }))
|
|
73
|
-
* ```
|
|
74
|
-
*/
|
|
75
|
-
const csrf = (options) => {
|
|
76
|
-
const originHandler = ((optsOrigin) => {
|
|
77
|
-
if (!optsOrigin) return (origin, c) => origin === new URL(c.req.url).origin;
|
|
78
|
-
else if (typeof optsOrigin === "string") return (origin) => origin === optsOrigin;
|
|
79
|
-
else if (typeof optsOrigin === "function") return optsOrigin;
|
|
80
|
-
else return (origin) => optsOrigin.includes(origin);
|
|
81
|
-
})(options?.origin);
|
|
82
|
-
const isAllowedOrigin = async (origin, c) => {
|
|
83
|
-
if (origin === void 0) return false;
|
|
84
|
-
return await originHandler(origin, c);
|
|
85
|
-
};
|
|
86
|
-
const secFetchSiteHandler = ((optsSecFetchSite) => {
|
|
87
|
-
if (!optsSecFetchSite) return (secFetchSite) => secFetchSite === "same-origin";
|
|
88
|
-
else if (typeof optsSecFetchSite === "string") return (secFetchSite) => secFetchSite === optsSecFetchSite;
|
|
89
|
-
else if (typeof optsSecFetchSite === "function") return optsSecFetchSite;
|
|
90
|
-
else return (secFetchSite) => optsSecFetchSite.includes(secFetchSite);
|
|
91
|
-
})(options?.secFetchSite);
|
|
92
|
-
const isAllowedSecFetchSite = async (secFetchSite, c) => {
|
|
93
|
-
if (secFetchSite === void 0) return false;
|
|
94
|
-
if (!isSecFetchSite(secFetchSite)) return false;
|
|
95
|
-
return await secFetchSiteHandler(secFetchSite, c);
|
|
96
|
-
};
|
|
97
|
-
return async function csrf(c, next) {
|
|
98
|
-
if (!isSafeMethodRe.test(c.req.method) && isRequestedByFormElementRe.test(c.req.header("content-type") || "text/plain") && !await isAllowedSecFetchSite(c.req.header("sec-fetch-site"), c) && !await isAllowedOrigin(c.req.header("origin"), c)) {
|
|
99
|
-
const res = new Response("Forbidden", { status: 403 });
|
|
100
|
-
throw new require_http_exception.HTTPException(403, { res });
|
|
101
|
-
}
|
|
102
|
-
await next();
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
//#endregion
|
|
106
|
-
exports.csrf = csrf;
|