git clone https://github.com/sayan404/secure-jwt-auth-test-api.git
cd secure-jwt-auth-test-api
npm install
npm run dev
Note: Although timeToLive
, audience
, issuer
is an optional parameter, we set a 1-hour validation for the token by default.
To encode a JWT, use the genToken method:
import { genToken } from 'secure-jwt-auth';
const token = genToken(SECRET, id , payload , timeToLive , audience , issuer);
To decode a JWT, use the decodeToken method:
import { decodeToken } from 'secure-jwt-auth';
const decoded = decodeToken(SECRET, token);
To validate a JWT, use the validateToken method:
import { validateToken } from 'secure-jwt-auth';
const isValid = validateToken(SECRET, token);
Explore and interact with the secure-jwt-auth
package using the API Playground set up for testing. You can experiment with encoding, decoding, and validating JWTs through the following link:
Feel free to test various endpoints and see how the package functions in different scenarios and if something weired occurs please feel free to reach out to me at [email protected].