This commit is contained in:
robin
2022-07-07 22:16:39 +08:00
parent 264ab8d979
commit a9a4bd0981
86 changed files with 1198 additions and 310 deletions
+17
View File
@@ -0,0 +1,17 @@
const jwt = require("jsonwebtoken");
const config = require("./config.js");
module.exports = {
/**
* 签发token
* @param {object} data 加入到签名里的数据.
* @return {string} token 令牌.
*/
sign: (data) => jwt.sign(data, config.secret, {algorithm: config.algorithm, expiresIn: config.expiresIn}),
/**
* 验证token
* @param {string} token 令牌.
* @return {boolean} 验证通过返回true.
*/
verify: (token) => jwt.verify(token, config.secret, {algorithm: config.algorithm, expiresIn: config.expiresIn}),
}