Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Snyk has created this PR to upgrade multiple dependencies.
👯♂ The following dependencies are linked and will therefore be updated together.ℹ️ Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.
hono
⚠️ This is a major version upgrade, and may be a breaking change | 23 days ago
⚠️ This is a major version upgrade, and may be a breaking change | 2 months ago
from 2.7.8 to 4.5.9 | 201 versions ahead of your current version
on 2024-08-26
typescript
from 4.9.5 to 5.5.4 | 595 versions ahead of your current version
on 2024-07-22
Issues fixed by the recommended upgrade:
SNYK-JS-HONO-6129070
Release notes
Package name: hono
What's Changed
NO_COLOR
by @ ryuapp in #3306type
(MIME) attribute types by @ ssssota in #3305Full Changelog: v4.5.8...v4.5.9
Security Fix for CSRF Protection Middleware
Before this release, in versions 4.5.7 and below, the CSRF Protection Middleware did not treat requests including
Content-Types
with uppercase letters (e.g.,Application/x-www-form-urlencoded
) as potential attacks, allowing them to pass.This could cause unexpected behavior, leading to a vulnerability. If you are using the CSRF Protection Middleware, please upgrade to version 4.5.8 or higher immediately.
For more details, see the report here: GHSA-rpfr-3m35-5vx5
What's Changed
target
andformtarget
attribute types by @ ssssota in #3299New Contributors
Full Changelog: v4.5.6...v4.5.7
What's Changed
New Contributors
Full Changelog: v4.5.5...v4.5.6
What's Changed
c.header
by @ nakasyou in #3221c.header
by @ nakasyou in #3255.
and not end/
by @ yusukebe in #3256Full Changelog: v4.5.4...v4.5.5
What's Changed
param
inValidationTargets
supports optional param by @ yusukebe in #3229New Contributors
Full Changelog: v4.5.3...v4.5.4
What's Changed
application/json
with a charset as JSON by @ yusukebe in #3199self.fetch
correctly by @ yusukebe in #3200New Contributors
Full Changelog: v4.5.2...v4.5.3
What's Changed
navigator
isundefined
by @ yusukebe in #3171navigator
isundefined
by @ yusukebe in #3173Full Changelog: v4.5.1...v4.5.2
What's Changed
@ experimental
fromcreateApp
by @ yusukebe in #3164query
inws
by @ yusukebe in #3169New Contributors
Full Changelog: v4.5.0...v4.5.1
Hono v4.5.0 is now available!
We have added three new built-in middleware. Now Hono is bringing 20 built-in middleware!
Amazing! These truly make Hono batteries-included framework.
Let's go through the new features in this release.
IP Restrict Middleware
Introducing IP Restrict Middleware. This middleware limits access to resources based on the IP address of the user.
import { getConnInfo } from 'hono/bun'
import { ipRestriction } from 'hono/ip-restriction'
const app = new Hono()
app.use(
'*',
ipRestriction(getConnInfo, {
denyList: [],
allowList: ['127.0.0.1', '::1']
})
)
Thanks @ nakasyou!
Combine Middleware
Introducing Combine Middleware. This middleware combines multiple middleware functions into a single middleware, allowing you to create complex access controls by combining it with middleware like IP Restriction.
import { bearerAuth } from 'hono/bearer-auth'
import { getConnInfo } from 'hono/cloudflare-workers'
import { every, some } from 'hono/combine'
import { ipRestriction } from 'hono/ip-restriction'
import { rateLimit } from '@/my-rate-limit'
const app = new Hono()
app.use(
'*',
some(
every(ipRestriction(getConnInfo, { allowList: ['192.168.0.2'] }), bearerAuth({ token })),
// If both conditions are met, rateLimit will not execute.
rateLimit()
)
)
app.get('/', (c) => c.text('Hello Hono!'))
Thanks @ usualoma!
Request ID Middleware
Introducing Request ID Middleware. This middleware generates a unique ID for each request, which you can use in your handlers.
import { requestId } from 'hono/request-id'
const app = new Hono()
app.use('*', requestId())
app.get('/', (c) => {
return c.text(
Your request id is <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">c</span><span class="pl-kos">.</span><span class="pl-en">get</span><span class="pl-kos">(</span><span class="pl-s">'requestId'</span><span class="pl-kos">)</span><span class="pl-kos">}</span></span>
)})
Thanks @ ryuapp!
Service Worker Adapter
A Service Worker adapter has been added, making it easier to run Hono applications as Service Workers.
For example, the following code works perfectly in a browser!
import { handle } from 'hono/service-worker'
const app = new Hono().basePath('/sw')
app.get('/', (c) => c.text('Hello World'))
self.addEventListener('fetch', handle(app))
Thanks @ nakasyou!
Cloudflare Pages Middleware
The Cloudflare Pages adapter now includes a
handleMiddleware
function, allowing many Hono middleware to run as Cloudflare Pages middleware.For example, to apply basic authentication, you can use the built-in middleware as shown below.
import { handleMiddleware } from 'hono/cloudflare-pages'
import { basicAuth } from 'hono/basic-auth'
export const onRequest = handleMiddleware(
basicAuth({
username: 'hono',
password: 'acoolproject'
})
)
Thanks @ BarryThePenguin!
React 19 Compatibility
Hono JSX now supports React 19 compatible APIs.
For example, the following hooks have been added:
useFormStatus()
useActionState()
useOptimistic()
Additionally, rendering metadata within the
<head />
tag is now supported. You can include elements like<title>
,<meta>
, and<link>
within your components.<h1>Top Page</h1>
<p>Hono is a great framework!</p>
</article>
)
})">
The above will render the following HTML:
See all changes in this PR: #2960
Thanks @ usualoma!
@ hono/react-compat
Plus, with the new
@ hono/react-compat
, you can alias thereact
orreact-dom
used in your project to hono/jsx without any configuration.Passing
interface
asBindings
/Variables
You can now pass
interface
toBindings
orVariables
. This allows you to use the type definitions generated by thewrangler types
command directly.Previously, only type definitions using
type
could be passed toBindings
. Now, interfaces like theEnv
example above can be used with generics.Thanks @ ottomated!
Other features
getConnInfo
for Vercel Adapter #3085getConnInfo
helper for Lambda@Edge #3099All Updates
jsx/dom/server
module for compatibility withreact-dom/server
by @ usualoma in