📅  最后修改于: 2022-03-11 14:48:14.091000             🧑  作者: Mango
const isValidJwt = (jwtToken: string): boolean => {
try {
if (!assert.isString(jwtToken) || assert.isUndefined(process.version as any)) return false
const jwtValidToken: string[] = jwtToken.split('.')
if (jwtValidToken.length !== 3) return false
JSON.parse(Buffer.from(jwtValidToken[0], 'base64').toString())
JSON.parse(Buffer.from(jwtValidToken[1], 'base64').toString())
return true
} catch (e) {
return false
}
}