validate method

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

Implementation

Iterable<JoseException> validate({
  Duration expiryTolerance = const Duration(),
  Uri? issuer,
  String? clientId,
}) sync* {
  final now = clock.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}`',
    );
  }
  final aud = audience;
  if (clientId != null && (aud == null || !aud.contains(clientId))) {
    yield JoseException('Audiences does not contain clientId `$clientId`.');
  }
}