valid jwt

The solution for “valid jwt” can be found here. The following code will assist you in solving the problem.

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

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

inline scripts encapsulated in