jws
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
jwa | 1.4.1 | 4.45 kB | MIT | prod | |
safe-buffer | 5.2.1 | 9.74 kB | MIT | prod |
JWS or JSON Web Signatures is a popular npm package used for creating and verifying JSON Web Signatures as per the draft-ietf-jose-json-web-signature-08 specification. This comprehensive tool supports various digital signature or MAC algorithms including but not limited to HS256, RS256, PS384, ES512, and more, providing both synchronous and streaming APIs for better functionality.
JWS can be used by first installing it via npm using the command npm install jws
. The package provides multiple functions for different purposes.
To sign a header and payload, you can use:
const jws = require('jws');
const signature = jws.sign({
header: { alg: 'HS256' },
payload: 'h. jon benjamin',
secret: 'has a van',
});
To verify if a signature matches a secret or key:
const jws = require('jws');
const isVerified = jws.verify(signature, 'HS256', 'has a van');
To decode a JWS signature:
const jws = require('jws');
const decodedSignature = jws.decode(signature);
Creation of 'SignStream' and 'VerifyStream' objects is also allowed which come with their specific functions.
Convenience options and APIs for defining the algorithm is currently under development.
Detailed documentation for JWS can be found directly in the readme file of the package's GitHub page at the url git://github.com/brianloveswords/node-jws.git
, providing a comprehensive guide on its installation and usage. This includes the available APIs, installation, usage, and the list of the supported algorithms. More functions may be added over time or with different versions, it's recommended to always check the latest documentation for updated information.