2.0.0 • Published 7 months ago
@tinyhttp/jwt v2.0.0
@tinyhttp/jwt
JWT middleware for HTTP servers.
Install
bun i @tinyhttp/jwt
API
import { jwt } from '@tinyhttp/jwt'
Options
jwt(options)
secret
: can be an array of strings (in case you are using private / public key encryption), or just a string if you are using basic HMAC signing (see the examples below)algorithm? ("HS256")
: the algorithm used to sign and verify the tokenaudience?
: the expected "audience" of the jwt tokenissuer?
: who issued this tokenexpiresIn?
: expiration time of the token (ex:1d
for 1 day)notBefore?
: not before date of the token (ex:20m
for 20 minutes)requestHeaderName? ("Authorization")
: the name of the header contaning the Bearer tokenresponseHeaderName? ("X-Token")
: the name of the response header containing the new signed token that will be used later ongetToken(string)?: string
: the method used for ex
Example
Basic secret
import { App } from '@tinyhttp/app'
import { jwt } from '@tinyhttp/jwt'
new App()
.use(jwt({ secret: 'secret', algorithm: 'HS256' }))
.get('/', (req, res) => res.send(`Data inside the payload: ${req['user']}`))
.listen(8080)
Private / Public key
import { App } from '@tinyhttp/app'
import { jwt } from '@tinyhttp/jwt'
new App()
.use(jwt({ secret: ['PRIVATE KEY', 'PUBLIC KEY'], algorithm: 'RS256' }))
.get('/', (req, res) => res.send(`Data inside the payload: ${req['user']}`))
.listen(8080)
2.0.0
7 months ago
1.3.1
3 years ago
1.3.0
3 years ago
1.2.2
3 years ago
1.2.1
3 years ago
1.2.0
3 years ago
1.1.1
3 years ago
1.1.0
3 years ago
1.0.7
3 years ago
1.0.6
3 years ago
1.0.5
3 years ago
1.0.4
3 years ago
1.0.2
3 years ago
1.0.3
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago
0.5.3
3 years ago
0.5.2
3 years ago
0.5.1
4 years ago
0.5.0
4 years ago
0.4.1
4 years ago
0.4.0
4 years ago
0.2.1
4 years ago
0.2.2
4 years ago
0.2.0
4 years ago
0.1.20
4 years ago
0.1.19
4 years ago
0.1.18
4 years ago
0.1.16
4 years ago
0.1.15
4 years ago
0.1.14
4 years ago
0.1.13
4 years ago
0.1.11
4 years ago
0.1.12
4 years ago
0.1.10
4 years ago
0.1.8
4 years ago
0.1.9
4 years ago
0.1.7
4 years ago
0.1.6
4 years ago
0.1.5
4 years ago
0.1.4
4 years ago
0.1.3
4 years ago
0.1.1
4 years ago
0.1.0
4 years ago
0.0.2
4 years ago
0.0.1
4 years ago