0.6.0 • Published 1 year ago

@mhio/jwt v0.6.0

Weekly downloads
6
License
MIT
Repository
github
Last release
1 year ago

JWT - @mhio/jwt

Do JWT things for koa

Install

yarn add @mhio/jwt
npm install @mhio/jwt

Usage

import { Jwt } from '@mhio/jwt'

const jwt = new Jwt({ jwt_sign_secret: 'SomeStrongPasswordForJwt' })

Auto generated private/public key

import { Jwt } from '@mhio/jwt'
import Koa from 'koa'
import Router from '@koa/router'

const jwt = new Jwt({ jwt_algorithm: 'RS256' })
const app = new Koa()
const router = new Router()

router.get('/jwt', async function(ctx) {
  const token = await jwt.jwtSign({ role: 'admin' })
  ctx.body = token
})
router.use(jwt.koaMiddleware())
router.get('/protected', async function(ctx) {
  ctx.body = ok
})

app.use(router.routes())
 .use(router.allowedMethods())

Links

https://github.com/mhio/node-jwt

https://www.npmjs.com/package/@mhio/jwt

0.6.0

1 year ago

0.5.0-1

3 years ago

0.5.0

3 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.1

6 years ago

0.3.1-1

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago