0.1.0 • Published 3 years ago

@sqrtthree/koa-jwt v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

koa-jwt

A jwt middleware for Koa

Install

npm install @sqrtthree/koa-jwt

Usage

import * as Koa from 'koa'
import { jwtMiddleware } from '@sqrtthree/koa-jwt'

const app = new Koa()

app.use(
  jwtMiddleware({
    subject: 'identity_authentication',
  })
)

Options

subject: string

Target subject of jwt.

issuer: ?string

Target issuer of jwt.

secret: ?string | (tokenPayload) => Promise<string>

A string or function containing either the secret for HMAC algorithms.

stateName: ?string

Attribute name extended to ctx.state, the value is jwt payload. It will be jwtPayload by default.


sqrtthree.com  ·  GitHub @sqrthree  ·  Twitter @sqrtthree