npm.io
1.0.10 • Published 7 years ago

mares-jwt

Licence
ISC
Version
1.0.10
Deps
1
Size
4 kB
Vulns
3
Weekly
0

mares-jwt

슬로그업 ddd에서 presentaion layer 에서 jwt token 을 암호화,복호화 하는 모듈입니다.

Installation

npm install --save mares-jwt

Example

//register middleware
const app = require('express')
const maresJwt = require('mares-jwt')

//토큰의 위치, 토큰 이름, 만료시간, 시크릿값
app.use(maresJwt.binder(location, 'tokenName', 'expiresIn', 'secret'))

const middle = (req, res , next) => {
	// 암호화
	const payload = {
		_id: 1
	}
	const token = req.sign(payload)
	
	// 복호화
	const decodeJwt = req.verify()
	next()
}

Keywords