1.0.8 • Published 2 years ago
jsonwebtoken-template v1.0.8
jsonwebtoken-template
Library that facilitates the use of jwt using reusable functions from Frontend with React.js
Installation
npm i jsonwebtoken-template
Usage
const useJwt = require ('jsonwebtoken-template')
# Define Object
const user = {
name : "Andy",
password: "Santisteban"
}
# Define time expired
const expired={
time:"1h"
}
# Define word secret
const varEnv="secret"
# Create Token
const toker = useJwt.signJwt(user,expired,varEnv)
console.log(toker)
# Decodificed Token
const decoded = useJwt.verifyJwt(toker,varEnv)
console.log(decoded)
If you want to add it to the browser's localStorage you can use the following example
sendTokenLocalStorage(key,token)
Si deseas agregarlo al sessionStorage del navegador puedes utilizar el siguiente ejemplo (no recomendable)
sendTokenSessionStorage(key,token)
Version
1.0.6
Author
Andy Santisteban