decodeJwt function

Jwt decodeJwt(
  1. String jwt
)

Returns the decoded Jwt based on jwt.

Implementation

Jwt decodeJwt(final String jwt) {
  try {
    return Jwt.fromJson(
      jsonDecode(
        utf8.decode(base64.decode(base64.normalize(jwt.split('.')[1]))),
      ),
    );
  } catch (_) {
    throw const FormatException('Invalid JWT.');
  }
}