validate method

Iterable<Exception> validate({
  1. Duration expiryTolerance = const Duration(),
  2. Uri? issuer,
  3. String? clientId,
})

Implementation

Iterable<Exception> validate(
    {Duration expiryTolerance = const Duration(),
    Uri? issuer,
    String? clientId}) sync* {
  final now = DateTime.now();
  final diff = now.difference(expiry!);
  if (diff > expiryTolerance) {
    yield JoseException(
        'JWT expired. Expiry ($expiry) is more than tolerance '
        '($expiryTolerance) before now ($now)');
  }
  if (issuer != null && this.issuer != issuer) {
    yield JoseException('Issuer does not match. Expected '
        '`$issuer`, was `${this.issuer}`');
  }
  if (clientId != null && !audience!.contains(clientId)) {
    yield JoseException('Audiences does not contain clientId `$clientId`.');
  }
}