"""Webhook token verification for Azure DevOps Service Hooks."""
from __future__ import annotations

import hmac
from typing import Optional

from src.config import get_settings


def verify_azure_devops_webhook_token(token_header: Optional[str]) -> bool:
    secret = (get_settings().azure_devops_webhook_secret or "").strip()
    if not secret:
        return False
    incoming = (token_header or "").strip()
    return hmac.compare_digest(incoming, secret)
