I just want to encode some information from the browser and send it over to the nodejs server.
I am able to encrypt and decrypt the JWT using jsonwebtoken NPM.
But i wanted to encrypt the data from client side i.e from the browser and send it over to the server.
Is there any way to use jsonwebtoken NPM from the browser.
There’s a couple of things worth noting here, the jsonwebtoken
library supports signed JWT tokens, but it has no support for encryption/decryption. This would mean the data in the JWT would not be encrypted so from that perspective the library would not be useful.
Signing a JWT token in the browser would also be irrelevant because the signing key would need to be available to the browser, which would mean available to everyone that was also interested in obtaining it. This means using that library in the browser would not get you anything.
If you want to protect the data in-transit from the browser to the server then you should ensure you’re using HTTPS; this would mean the data (all of it) would indeed be encrypted when sent from the browser to the server.