isJwtStructure function

bool isJwtStructure(
  1. String token
)

Returns true if token looks like a JWT (three base64url parts separated by .).

Implementation

bool isJwtStructure(String token) {
  final List<String> parts = token.split('.');
  return parts.length == _jwtPartCount &&
      parts.every((String p) => p.isNotEmpty && RegExp(r'^[A-Za-z0-9_-]+$').hasMatch(p));
}