Let's assume we got a JWT as string. Firstly we need to ensure that it has the right format.
import { isJwt, ensureJwt } from '@aeternity/aepp-sdk';
if (!isJwt(jwt)) throw new Error('Invalid JWT');
// alternatively,
ensureJwt(jwt);
After that we can pass JWT to other SDK's methods, for example to get JWT payload and signer address in case JWT has the signer public key included in "sub_jwk".
If we need to a get signer address based on JWT payload then we need to unpack it without checking the signature. Don't forget to check signature after that using verifyJwt.
import { verifyJwt } from '@aeternity/aepp-sdk';
const { payload, signer } = unpackJwt(jwt);
console.log(payload); // { address: 'ak_21A27UVVt3hDkBE5J7rhhqnH5YNb4Y1dqo4PnSybrH85pnWo7E' }
console.log(signer); // undefined
if (!verifyJwt(jwt, payload.address)) throw new Error('JWT signature is invalid');