decodeAndVerify static method

Future<JsonWebToken> decodeAndVerify(
  1. String serialization,
  2. JsonWebKeyStore keyStore, {
  3. List<String>? allowedArguments,
})

Decodes and verifies/decrypts a JWT string from a JWE or JWS compact serialization

Implementation

static Future<JsonWebToken> decodeAndVerify(
    String serialization, JsonWebKeyStore keyStore,
    {List<String>? allowedArguments}) async {
  var joseObject = JoseObject.fromCompactSerialization(serialization);
  var content = await joseObject.getPayload(keyStore,
      allowedAlgorithms: allowedArguments);
  JsonWebTokenClaims claims;
  if (content.mediaType == 'JWT') {
    claims = (await decodeAndVerify(content.stringContent, keyStore,
            allowedArguments: allowedArguments))
        .claims;
  } else {
    claims = JsonWebTokenClaims.fromJson(content.jsonContent);
  }
  return JsonWebToken._(joseObject, claims, true);
}