
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
@funkybob/jwt
Advanced tools
Using nothing but what modern browsers provide, this package can decode and validate JWT, even those signed using RS256.
Note: RS algorithms only support keys in JWK format, currently.
import {decode, verify} from "@funkybob/jwt"
let jwt = decode(token);
let valid;
try {
valid = await verify(jwt, options)
} catch(err) {
valid = false;
};
If you are using the RS family of signing algorithms, you will need to provide a map of kid to JWK objects (see https://tools.ietf.org/html/rfc7517).
If your issuer provides their JWK at well known URI ("/.well-known/jwks.json") you can use the "fetchKeys" function to retrieve them once. This returns a Promise:
options.keys = await fetchKeys('hostname.myissuer.com')
or
fetchKeys('hostname').then(keys => options.keys = keys);
Remember to not try to validate a token before this promise is resolved.
"Unsupported algorithm"
The 'alg' specified in the Header does not match that specified in options, or is not supported by this library.
"Unknown key"
The 'kid' specified in the Header could not be found in the list of known keys. If options.hostname was specified, the list of keys retrieved did not contain the matching kid.
"Invalid signature"
The signing algorithm returned a negative result.
"Unrecognised issuer"
The 'iss' field in the Message did not match that specified in options.
"Invalid audience"
The 'aud' specified in options was not found in the 'aud' list in the Message.
"Token has expired"
The tokens 'exp' claim is in the past.
"Token not yet valid"
The tokens 'nbf' claim is in the future.
Decodes a JWT string into an Object:
Check if a jwt is valid.
Fetches keys from https://${hostname}/.well-known/jwks.json, then assembles them into
an Object by Key ID (kid).
Imports the key matter as appropriate for the specified algorithm.
base64url decode 'v'
base64url encode 'v'
Converts 'v' from a String to a Uint8Array.
Converts 'v' from a Uint8Array to a String
FAQs
Native JWT validation without deps
The npm package @funkybob/jwt receives a total of 2 weekly downloads. As such, @funkybob/jwt popularity was classified as not popular.
We found that @funkybob/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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.