yutent 2023-10-27 19:19:48 +08:00
parent 5124566355
commit 458c2b403f
1 changed files with 64 additions and 60 deletions

View File

@ -12,7 +12,8 @@ function hmac(str, secret) {
return base64encode(buf, true)
}
export const jwtPackage = {
export function createJwtModule() {
return {
name: 'jwt',
install() {
return {
@ -57,9 +58,11 @@ export const jwtPackage = {
}
}
}
}
}
export function jwtConnect(req, res, next) {
export function createJwt() {
return function (req, res, next) {
var { secret, level } = this.get('jwt')
var deviceID = ''
var ssid
@ -83,7 +86,8 @@ export function jwtConnect(req, res, next) {
deviceID = sha1(deviceID)
}
req.mixKey = secret + deviceID
req.__mix_key__ = secret + deviceID
next()
}
}