-
Notifications
You must be signed in to change notification settings - Fork 0
/
JWT.js
35 lines (30 loc) · 849 Bytes
/
JWT.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';
const jwt = require('jsonwebtoken');
const serverTokenSecret = "GoodGoodStudyDayDayUp";
exports.signServerToken = function signServerToken (tokenInfo) {
let token = ""
try {
token = jwt.sign(tokenInfo, serverTokenSecret, {"issuer": "ttangServer"});
}catch (err) {
// console.error("signServerToken err...", err)
}
return token;
}
exports.verifyServerToken = function verifyServerToken (token) {
let tokenInfo = ""
try {
tokenInfo = jwt.verify(token, serverTokenSecret);
}catch (err) {
// console.error("verifyServerToken err serverToken illegal..", err);
}
return tokenInfo
}
exports.verifyClientToken = function verifyClientToken (token) {
let tokenInfo = ""
try {
tokenInfo = jwt.verify(token, clientTokenSecret);
} catch(err) {
console.error("illegal client token....", err);
}
return tokenInfo
}