"""Webhook domain constants.

Single source of truth for webhook-related defaults and HTTP headers.
"""

from typing import Final

# =============================================================================
# Webhook Default Values
# =============================================================================

DEFAULT_WEBHOOK_TIMEOUT_MS: Final[int] = 10000
"""Default HTTP request timeout in milliseconds."""

DEFAULT_WEBHOOK_MAX_RETRIES: Final[int] = 3
"""Default maximum delivery retry attempts."""

DEFAULT_WEBHOOK_BACKOFF_BASE: Final[float] = 2.0
"""Default exponential backoff base multiplier."""

DEFAULT_WEBHOOK_MAX_RESPONSE_LENGTH: Final[int] = 500
"""Default maximum response body length to log."""

# =============================================================================
# HTTP Headers
# =============================================================================

HTTP_HEADER_CONTENT_TYPE: Final[str] = "Content-Type"
"""Standard Content-Type header."""

HTTP_CONTENT_TYPE_JSON: Final[str] = "application/json"
"""JSON content type value."""

HTTP_HEADER_WEBHOOK_EVENT: Final[str] = "X-NoteFlow-Event"
"""Header containing the webhook event type."""

HTTP_HEADER_WEBHOOK_DELIVERY: Final[str] = "X-NoteFlow-Delivery"
"""Header containing the unique delivery ID."""

HTTP_HEADER_WEBHOOK_SIGNATURE: Final[str] = "X-NoteFlow-Signature"
"""Header containing the HMAC signature."""

HTTP_HEADER_WEBHOOK_TIMESTAMP: Final[str] = "X-NoteFlow-Timestamp"
"""Header containing the Unix timestamp for replay protection."""

WEBHOOK_SIGNATURE_PREFIX: Final[str] = "sha256="
"""Prefix for HMAC-SHA256 signatures."""

WEBHOOK_REPLAY_TOLERANCE_SECONDS: Final[int] = 300
"""Maximum age in seconds for webhook requests (5 minutes)."""

# =============================================================================
# Retry Policy
# =============================================================================

RETRYABLE_STATUS_CODES: Final[frozenset[int]] = frozenset({408, 429, 500, 502, 503, 504})
"""HTTP status codes that should trigger a retry."""
