When creating jsonwebtoken rather than signing and verifying tokens with a secret key use Asymetric encryption instead using pubic and private key pairs
cd
into jwt-authentication folder in your terminal runmkdir certs
, then typecd certs
.- Generate a public and private key for both access and refresh tokens:
/** To generate a public and private key for access tokens */
// Private Key
>> openssl genrsa -out accessTokenPrivatekey.pem 4096
// Public Key
>> openssl rsa -pubout -in accessTokenPrivatekey.pem -out accessTokenPublickey.pem
/** To generate a public and private key for refresh tokens */
// Private Key
>> openssl genrsa -out refreshTokenPrivatekey.pem 4096
// Public Key
>> openssl rsa -pubout -in refreshTokenPrivatekey.pem -out refreshTokenPublickey.pem