Open omqmo opened 1 year ago
Same here.
Some Chinese characters face the same problem.
import jwt from 'jsonwebtoken';
// let o = { name: `大` }; // OK case
let o = { name: `使` }; // Error case
let token = jwt.sign(o, `secret`, {
expiresIn: `1h`,
});
let [, payload] = token.split(`.`);
console.log(payload);
let text = atob(payload); // throw Error
console.log(text);
The issue is not related to this library.
If you will do btoa("使")
you will have the same problem, the problem is the btoa/atob functions.
If you use jwt.verify or jwt.decode to extract the data from the jwt you will see that it is working as expected.
How to fix this example?
In terminal
npm start
stackblitz