1.0.2 • Published 5 years ago

node-verify-token v1.0.2

Weekly downloads
4
License
ISC
Repository
-
Last release
5 years ago

怎么安装(how to install)

npm i node-verify-token --save
或者(or)
yarn add node-verify-token

使用方法(how to use)

const Token = require('node-verify-token');

1.签发token(sign token)

const payload = {
    key: 'value',
    date: Date.now()
};
const secret = 'token secret';
const options = {
    expiresIn: '1 day'
};
const token = Token.getToken(payload,secret,options);
//token 就是得到的token字符串
// you will get token in this way
关于options更多可选属性,可以去查找jsonwebtoken库的options可选属性
for more about options?
You can search jsonwebtoken in npmjs.com.This options is based on jsonwebtoken's options;

2.验证token(verify token)

async function a(){
   const result = await Token.verify(token,secret);  
} 

返回值(will return an object)

//data 表示获取token时加密的原始数据
//this means allow to access.The data means the payload for this token
return { status: 1, message: 'allowed', data: paylaod};
//this means forbidden to access
return { status: 0, message: 'not permission'};

如果有什么问题和建议,请给我发邮件到664930912@qq.com 或者 lfb15666280558@gmail.com If you have some issues , send email to 664930912@qq.com or lfb15666280558@gmail.com

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago