express-api/src/utilities/decodeJWT.ts

Summary

Maintainability
A
0 mins
Test Coverage
// Decodes a Base64-encoded string to a JSON object.
export const decodeJWT = (jwt: string) => {
  try {
    return JSON.parse(Buffer.from(jwt, 'base64').toString('ascii'));
  } catch {
    throw new Error('Invalid input in decodeJWT()');
  }
};