You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pnpm add @feelinglovelynow/jwt
pnpm add buffer # only necessary if @ browser or edge (cloudflare workers)
🤓 Unit Tests
🙏 Description
Node and/or Edge helper functions to create JWK's, create JWT's, decode JWT's and verify JWT's with the subtle crypto api's ECDSA: SHA-512 algorithm
First we create JWK's which give us a private and public JWK (I love to put them in my .env file)
Then with the private JWK we may create JWT's
With the public JWK we may verify JWT's
And with no JWK required we may decode JWT's
💚 Create public and private JWK's
This function will log the public & private JWK's in the terminal
Calling this function is only necessary when we first create the JWK's. Once we store the pulic and private JWK's this code may be removed. So place this code locally somewhere server side, call it for the number of JWK's you'd love and then remove it when they're in your .env file. The same private JWK can create many JWT's.
if(!jwt||typeofjwt!=='string'||jwt.split('.').length!==3){throw{id: 'fln__decode__invalid-jwt',message: 'Please provide a string token, with 3 parts, seperated by a dot',_errorData: { jwt }}}
if(!jwt||typeofjwt!=='string'||jwt.split('.').length!==3){throw{id: 'fln__verify__bad-format',message: 'Please provide a string token, with 3 parts, seperated by a dot',_errorData: { jwt }}}if(expiresInAsSeconds<=now()){throw{id: 'fln__verify__expired',message: 'Token has expired',_errorData: { jwt }}}if(!isValid)throw{id: 'fln__verify__invalid',message: 'Token is invalid',_errorData: { jwt }}