https://github.com/everettmorgan/jwt
My implementation of the JWT rfc spec.
https://github.com/everettmorgan/jwt
jwt node
Last synced: 4 months ago
JSON representation
My implementation of the JWT rfc spec.
- Host: GitHub
- URL: https://github.com/everettmorgan/jwt
- Owner: everettmorgan
- Created: 2021-11-29T00:01:10.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-29T04:06:22.000Z (over 4 years ago)
- Last Synced: 2026-01-14T11:15:44.254Z (6 months ago)
- Topics: jwt, node
- Language: TypeScript
- Homepage:
- Size: 95.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ejmorgan-jwt
A simple implementation of the JWT rfc spec.
## Usage
```javascript
const JWT = require("ejmorgan-jwt");
const jwt = JWT.New({
key: 'my-key',
header: {
alg: "sha256",
},
payload: {
aud: "audience",
custom: "my-key",
},
});
const str = jwt.toString();
console.log(str);
// eyJhbGciOiJzaGEyNTYifQ.eyJhdWQiOiJhdWRpZW5jZSIsImN1c3RvbSI6Im15LWtleSJ9.bY7PCElW5f245tSaLVkiGIfLBISU7kdyfCniJ62FsDM=
const [err, ajwt]= JWT.Read(str, 'my-key');
console.log(ajwt);
// JSONWebToken {
// header: { alg: 'sha256' },
// payload: { aud: 'audience', custom: 'my-key' },
// signature: 'bY7PCElW5f245tSaLVkiGIfLBISU7kdyfCniJ62FsDM='
// }
ajwt.payload.aud = 'hehehe';
const ok = JWT.Validate(ajwt, 'my-key');
console.log(ok);
// false
```