Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yuri2peter/yl-jwt
Easy jwt tools.
https://github.com/yuri2peter/yl-jwt
Last synced: 6 days ago
JSON representation
Easy jwt tools.
- Host: GitHub
- URL: https://github.com/yuri2peter/yl-jwt
- Owner: yuri2peter
- License: apache-2.0
- Created: 2019-09-19T09:45:17.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-10T15:19:28.000Z (over 3 years ago)
- Last Synced: 2024-11-17T00:33:46.153Z (2 months ago)
- Language: JavaScript
- Size: 46.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# yl-jwt
Simplified version of JWT.
# Deprecated
This project is not longer maintained.
Please take a look at [easy-jwt](https://github.com/yuri2peter/easy-jwt/).
# Usage
```javascript
const { jwtResolve, jwtGenerate } = require('yl-jwt');const data = 'test'; // any data that can be serialized
const cert = 'key'; // secrets
const expire = 2; // expired in 2s
const jwt = jwtGenerate(data, cert, expire);setTimeout(() => {
const rel1 = jwtResolve(jwt, cert);
console.log('1: ' + rel1) // should be 'test'
}, 1000)setTimeout(() => {
const rel2 = jwtResolve(jwt, 'wrong key');
console.log('2: ' + rel2) // wrong key, should be null
}, 1500)setTimeout(() => {
const rel3 = jwtResolve(jwt, cert);
console.log('3: ' + rel3) // expired, should be null
}, 3000)```