from __future__ import annotations

import hashlib
import hmac
import time


def build_signature_header(
    method: str,
    path: str,
    body: str,
    signing_secret: str,
) -> str:
    timestamp = int(time.time())
    body_hash = hashlib.sha256(body.encode()).hexdigest()
    canonical = f"{timestamp}.{method}.{path}.{body_hash}"
    sig = hmac.new(
        signing_secret.encode(),
        canonical.encode(),
        hashlib.sha256,
    ).hexdigest()
    return f"t={timestamp},v1={sig}"
