Decodes a Vincent JWT in string form and returns an VincentJWT decoded object for your use

The jwt in string form. It will be decoded and checked to be sure it is not malformed.

The appId that should be in the payload of the JWT. If app is not defined, or app.id is different, this method will throw.

Info Note

This method only decodes the JWT_ -- you still need to verify the JWT to be sure it is valid! If the JWT is expired, you need to use a WebAuthClient to get a new JWT.

See getWebAuthClient

  import { decode, isExpired } from '@lit-protocol/vincent-app-sdk/jwt';

const decodedVincentJWT = decode({ jwt, requiredAppId: 555 });
const isJWTExpired = isExpired(decodedVincentJWT);

if(!isJWTExpired) {
// User is logged in
// You still need to verify the JWT!
} else {
// User needs to get a new JWT
webAuthClient.redirectToConnectPage({redirectUri: window.location.href });
}