jwt-ide
v1.0.1
Published
JWT tokens with id any exprire, format look like id.expire.jwt
Downloads
4
Readme
jwt-ide
jwt-ide build on top of jsonwebtoken, JWT (ide) typically looks like the following.
uuuuu.vvvvv.xxxxx.yyyyy.zzzzz
uuuuu
isid
(base64Url)vvvvv
isexpire time
(base64Url)xxxxx.yyyyy.zzzzz
is jsonwebtoken
Install
npm install jwt-ide
Use
import jwt from 'jwt-ide';
// create token
const token = jwt.sign({ id: 'uuid' }, 'super_secret_key', {
expiresIn: '15m',
});
// get token id (return string or number token id)
const tokenId = jwt.getTokenId(token);
// get expires time (return number Unix Timestamp in milliseconds)
const expiresIn = jwt.getTokenExpire(token);
// get jwt token (return jwt token)
const jwtToken = jwt.getJwtToken(token);
// get part of token
const [tokenId, expiresIn, jwtToken] = jwt.getToken(token);
// check expires only (return true or false)
const isExpire = jwt.isExpire(token);
// verify and check expires
try {
const decoded = jwt.verify(token, 'super_secret_key');
console.log(decoded);
} catch (err: any) {
console.log(err);
}
sign
and verify
can read from jsonwebtoken