![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Simple JWT creation and verification package with build in Asymmetric key generation and use build on top of the jsonwebtoken package.
jwts is a package for Signing/Creating and Verifying JWTs, more specifically JWS', with build in asymmetric key pair generation support for the digital signature using the native crypto module.
The package name "jwts" is made by combining both JWT and JWS.
JWT is the JSON Web Token specification, while JWS is the specification where a digital Signature of the JWT is included at the end of the JWT, to act as an anti-tamper measure. This package helps you to easily create JWS by dealing with the generation of Public/Private key pair, so you can just focus on writing the options and tokens to sign and verify.
This project follows Semantic Versioning
Please view the documentation of latest changes in this CHANGELOG.md file on the Github repository to see what has changed in the latest versions!
Please visit the Github repo for latest and most updated commits/changes. Versions published on NPM are more or less stable for use and are not updated as often as the remote repo.
If you plan on using this package in production, or share code that uses this package as dependency with others, always make sure that your code is working fine with the package using your tests, before locking the version you used in your dependency list. This is to prevent the package from being updated causing errors due to any possible breaking changes across the different versions, which may break your application, causing pain and tears.
Note that this package is in currently in the beta phase, although it is mostly stable. Once all the tests has been written and a CI/CD pipeline is built out for this package, I will create a new Major version for release that will be marked as "Production Ready". If you have any issues, please open them on the Github page, contributions or comments are all welcomed too. My email is here if you would like to reach out. Thanks for giving this a try!
# Install into node_modules/ and save as dependency in package.json
npm i jwts
# Install package to use in production without installing the package's development dependencies
npm i jwts --production
This package, when installed using npm, contains only the required source files, README and CHANGELOG files in the distribution package without all the tests and example codes.
To view the full implementation with tests and example codes, clone this repository from Github instead.
git clone https://github.com/Jaimeloeuf/jwts
Node Versions Compatibility:
This package should work with most modern Node JS versions, but this has only been tested on Node v10.
Will be building automated tests to run this package on different versions of node, to get a bigger picture for compatibility.
// Note all import statements here are synchronous & blocking. Lazy loading is recommended if the use is optional.
// Require jwts to use the methods without using automated Key generation and binding
const jwt = require('jwts');
/* Assuming you got the publicKey from a secret management service. Create
a verification function by partially applying in the publicKey and the
default verification options. */
const verify = jwt.verifyToken(publicKey)({
issuer: "auth-backend",
audience: "my_service" // Enter your default verify token options
})
/* Assuming the "jwt" is the jwt you want to verify
"verify" will return a Promise, that will resolve with the verified and decoded token,
else it will reject with an error if the verification failed. */
verify(jwt);
// Assuming you want to verify the jwt, with a different set of options
verify(jwt, {
audience: "admin_service" // Optional options to override your default options
});
/* Directly call the "applyKeys" method if you want to both create and verify the
tokens with automatically generated RSA key pair binded into the functions. */
const jwt = require('jwts').applyKeys();
jwt.getPublicKey(); // Get the generated publicKey
/* Apply default options object into the create and verify functions */
const create = jwt.createToken({
issuer: "auth-backend",
audience: "my_service" // Enter your default verify token options
});
const verify = jwt.verifyToken({
issuer: "auth-backend",
audience: "my_service" // Enter your default verify token options
});
// Self invoked async function to use await on the Promises
(async function() {
/* "create" returns a Promise,
that will resolve with the signed and encoded token,
else it will reject with an error. */
const token = await create({
user: "james",
roles: "admin"
});
/* "verify" returns a Promise, that will resolve with the verified and decoded token,
else it will reject with an error if the verification failed. */
const decoded_token = await verify(token);
})()
A good resource is on the jwt.io website.
From here on out, the client browser who holds the JWT, or a service or whatever that holds the JWT, will be referred to as the bearer.
In a JWT, especially one used as identity validator, it is suggested that you include the following key:value pairs:
{
// Token headers
"typ": "JWT",
"alg": "HS256" // The algorithm used for the signature is HMAC SHA-256
}
{
// These below declarations are known as Claims, because the token creator claims a set of assertions that can be used to ‘know’ things about the subject. Because the token is signed with a secret key, you can verify its signature and implicitly trust what is claimed.
"exp": ,
"iat": ,
"expiresIn": ,
"tokenType": "Bearer",
"sub":
"subject": "retrieve data", // What is the purpose of this token/request?
"usrID": 578ec9,
"usr": "john@gmail.com",
"iss": "bookings.com", // Issuer of the token
"aud": "bookings.com/", // Intended audience that should acccept the token
"account type": "consumer", // The type of account that the user has
"roles": {
// The things/roles that the user is allowed to do
"role": "consumer"
"booking": "create"
}
"scope": ["read", "write", "update", "del"]
}
This package is made under the MIT license, feel free to use it however you like.
Feel free to fork and contribute to this project! If you need help or have any queries, feel free to reach out to me here, or simply create an issue on the Github page.
2019 - Jaime Loeuf
[2.0.0] - 16/03/20
FAQs
Simple JWT creation and verification package with build in Asymmetric key generation and use build on top of the jsonwebtoken package.
The npm package jwts receives a total of 5 weekly downloads. As such, jwts popularity was classified as not popular.
We found that jwts 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.