{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tltv.tv/schemas/v1/defs.json",
  "title": "TLTV Shared Definitions",
  "description": "Reusable type definitions for TLTV protocol schemas.",
  "$defs": {
    "channelId": {
      "type": "string",
      "pattern": "^TV[1-9A-HJ-NP-Za-km-z]{44}$",
      "description": "Base58-encoded channel ID: 'TV' prefix + 44 base58 characters (2-byte version prefix 0x1433 + 32-byte Ed25519 public key)."
    },
    "base58Signature": {
      "type": "string",
      "pattern": "^[1-9A-HJ-NP-Za-km-z]{86,88}$",
      "description": "Base58-encoded Ed25519 signature (64 bytes, encodes to 86-88 base58 characters)."
    },
    "timestampUTC": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$",
      "description": "ISO 8601 timestamp in UTC with Z suffix. Second precision, no fractional seconds."
    },
    "ianaTimezone": {
      "type": "string",
      "pattern": "^[A-Za-z_]+/[A-Za-z_]+(/[A-Za-z_]+)?$|^UTC$",
      "description": "IANA timezone name (e.g., 'America/New_York', 'Europe/London', 'UTC')."
    },
    "hostPort": {
      "type": "string",
      "pattern": "^(\\[[:0-9a-fA-F]+\\]|[a-zA-Z0-9._-]+):\\d{1,5}$",
      "description": "Host and port: DNS hostname, IPv4 address, or bracketed IPv6 address, with required port."
    },
    "errorResponse": {
      "type": "object",
      "required": ["error"],
      "properties": {
        "error": {
          "type": "string",
          "enum": [
            "invalid_request",
            "access_denied",
            "channel_not_found",
            "invalid_document",
            "stream_unavailable",
            "service_unavailable"
          ],
          "description": "Machine-readable error code."
        },
        "message": {
          "type": "string",
          "description": "Optional human-readable explanation. Clients MUST NOT parse this programmatically."
        }
      },
      "additionalProperties": true
    }
  }
}
