public Task <bool> SaveAsync(byte[] tokenSeed)
        {
            var newTokenRecord = new JwtToken
            {
                Id = ToTokenId(tokenSeed),
                // _jwtTokenRepository.RemoveExpiredTokens() assumes DateTime.Now (not .UtcNow)
                ExpirationTime = DateTime.Now + _config.KeyRotationInterval
            };

            _jwtTokenRepository.InsertValidToken(newTokenRecord);

            return(Task.FromResult(true));
        }
        public void ValidateReplyAttack(SecurityToken token)
        {
            _jwtTokenRepository.RemoveExpiredTokens();

            var hasTokenBeenUsed = _jwtTokenRepository.HasTokenBeenUsed(token.Id);

            if (hasTokenBeenUsed)
            {
                throw new SecurityTokenReplayDetectedException($"The same token cannot be used again. Token Id: {token.Id}");
            }

            _jwtTokenRepository.InsertValidToken(new JwtToken
            {
                ExpirationTime = token.ValidTo,
                Id             = token.Id
            });
        }