Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aws-jwt-verify

Package Overview
Dependencies
Maintainers
3
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws-jwt-verify

Verify RS256/RS384/RS512 signed JSON Web Tokens (JWT)

  • 4.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
267K
decreased by-0.48%
Maintainers
3
Weekly downloads
 
Created

What is aws-jwt-verify?

The aws-jwt-verify npm package is used to verify JSON Web Tokens (JWTs) that are issued by Amazon Cognito and other AWS services. It provides a straightforward way to validate the authenticity and integrity of JWTs, ensuring that they have not been tampered with and are issued by a trusted source.

What are aws-jwt-verify's main functionalities?

Verify JWT

This feature allows you to verify a JWT issued by Amazon Cognito. The code sample demonstrates how to create a verifier instance with the necessary parameters and then use it to verify a token. If the token is valid, the payload is logged; otherwise, an error is logged.

const { CognitoJwtVerifier } = require('aws-jwt-verify');

const verifier = CognitoJwtVerifier.create({
  userPoolId: 'us-east-1_example',
  tokenUse: 'id', // or 'access'
  clientId: 'exampleclientid'
});

async function verifyToken(token) {
  try {
    const payload = await verifier.verify(token);
    console.log('Token is valid. Payload:', payload);
  } catch (err) {
    console.error('Token is invalid:', err);
  }
}

verifyToken('your-jwt-token');

Custom JWT Verification

This feature allows you to verify JWTs from custom issuers. The code sample shows how to create a verifier instance with custom issuer, audience, and JWKS URI, and then use it to verify a token. If the token is valid, the payload is logged; otherwise, an error is logged.

const { JwtRsaVerifier } = require('aws-jwt-verify');

const verifier = JwtRsaVerifier.create({
  issuer: 'https://example.com/',
  audience: 'exampleaudience',
  jwksUri: 'https://example.com/.well-known/jwks.json'
});

async function verifyCustomToken(token) {
  try {
    const payload = await verifier.verify(token);
    console.log('Token is valid. Payload:', payload);
  } catch (err) {
    console.error('Token is invalid:', err);
  }
}

verifyCustomToken('your-custom-jwt-token');

Other packages similar to aws-jwt-verify

FAQs

Package last updated on 12 Feb 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc