Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
@coolgk/jwt
Advanced tools
a javascript / typescript module
npm install @coolgk/jwt
a simple jwt token class
Report bugs here: https://github.com/coolgk/node-utils/issues
import { Jwt } from '@coolgk/jwt';
// OR
// const { Jwt } = require('@coolgk/jwt');
const jwt = new Jwt({secret: 'abc'});
const string = 'http://example.com/a/b/c?a=1';
const token = jwt.generate(string);
console.log(
jwt.verify(token), // { exp: 0, iat: 1512307492763, rng: 0.503008668963175, data: 'http://example.com/a/b/c?a=1' }
jwt.verify(token+'1') // false
);
const token2 = jwt.generate(string, 200);
console.log(
jwt.verify(token2), // { exp: 1512307493026, iat: 1512307492826, rng: 0.5832258275608753, data: 'http://example.com/a/b/c?a=1' }
jwt.verify(token+'1') // false
);
setTimeout(() => {
console.log(jwt.verify(token2)); // false
}, 250);
Kind: global class
string
boolean
| object
Param | Type | Description |
---|---|---|
options | object | |
options.secret | string | for encryption |
string
Kind: instance method of Jwt
Param | Type | Default | Description |
---|---|---|---|
data | * | any data can be JSON.stringify'ed | |
[expiry] | number | 0 | in milliseconds 0 = never expire |
boolean
| object
Kind: instance method of Jwt
Returns: boolean
| object
- - false or the payload of the token
Param | Type | Description |
---|---|---|
token | string | token to verify |
FAQs
a simple jwt token class
The npm package @coolgk/jwt receives a total of 40 weekly downloads. As such, @coolgk/jwt popularity was classified as not popular.
We found that @coolgk/jwt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.