defaultJWTHeaderCheck function

bool defaultJWTHeaderCheck(
  1. Map<String, dynamic> h
)

Default JOSE Header checker.

Returns true (header is ok) if the 'typ' Header Parameter is absent, or it is present with the exact value of 'JWT'. Otherwise, false (header is rejected).

This implementation allows verifyJwtHS256Signature to exactly replicate its previous behaviour. . Note: this check is more restrictive than what RFC 7519 requires, since the value of 'JWT' is only a recommendation and it is supposed to be case insensitive. See tools.ietf.org/html/rfc7519#section-5.1

Implementation

bool defaultJWTHeaderCheck(Map<String, dynamic?> h) {
  if (!h.containsKey('typ')) {
    return true;
  }

  final dynamic? typ = h['typ'];
  return typ == 'JWT';
}