{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://taips.tap.rsvp/schemas/common/didcomm-base.json",
  "title": "DIDComm Base Message",
  "description": "Base schema for DIDComm v2 messages used in TAP",
  "$defs": {
    "didcommHeader": {
      "type": "object",
      "required": ["id", "type"],
      "properties": {
        "@context": {
          "$ref": "base-types.json#/$defs/jsonLdContext",
          "description": "JSON-LD context for the message"
        },
        "id": {
          "$ref": "base-types.json#/$defs/uuid",
          "description": "Unique message identifier"
        },
        "type": {
          "type": "string",
          "pattern": "^https://tap\\.rsvp/schema/[0-9]+\\.[0-9]+#[A-Za-z]+$",
          "description": "Message type URI"
        },
        "thid": {
          "$ref": "base-types.json#/$defs/uuid",
          "description": "Thread identifier for message correlation"
        },
        "from": {
          "$ref": "base-types.json#/$defs/did",
          "description": "DID of the message sender"
        },
        "to": {
          "type": "array",
          "items": {
            "$ref": "base-types.json#/$defs/did"
          },
          "minItems": 1,
          "description": "Array of recipient DIDs"
        },
        "created_time": {
          "$ref": "base-types.json#/$defs/iso8601DateTime",
          "description": "Message creation timestamp"
        },
        "expires_time": {
          "$ref": "base-types.json#/$defs/iso8601DateTime",
          "description": "Message expiration timestamp"
        },
        "please_ack": {
          "type": "boolean",
          "description": "Request acknowledgment of message receipt"
        },
        "ack": {
          "type": "array",
          "items": {
            "$ref": "base-types.json#/$defs/uuid"
          },
          "description": "Message IDs being acknowledged"
        },
        "body": {
          "type": "object",
          "description": "Message-specific body content"
        },
        "attachments": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/attachment"
          },
          "description": "Optional message attachments"
        }
      }
    },
    "attachment": {
      "type": "object",
      "required": ["id", "data"],
      "properties": {
        "id": {
          "type": "string",
          "description": "Attachment identifier"
        },
        "description": {
          "type": "string",
          "description": "Human-readable description of the attachment"
        },
        "filename": {
          "type": "string",
          "description": "Suggested filename for the attachment"
        },
        "media_type": {
          "type": "string",
          "description": "MIME type of the attachment"
        },
        "format": {
          "type": "string",
          "enum": ["base64", "json", "links"],
          "description": "Format of the attachment data"
        },
        "lastmod_time": {
          "$ref": "base-types.json#/$defs/iso8601DateTime",
          "description": "Last modification time of the attachment"
        },
        "byte_count": {
          "type": "integer",
          "minimum": 0,
          "description": "Size of the attachment in bytes"
        },
        "data": {
          "oneOf": [
            {
              "type": "object",
              "required": ["base64"],
              "properties": {
                "base64": {
                  "$ref": "base-types.json#/$defs/base64"
                }
              }
            },
            {
              "type": "object",
              "required": ["json"],
              "properties": {
                "json": {
                  "type": "object"
                }
              }
            },
            {
              "type": "object",
              "required": ["links"],
              "properties": {
                "links": {
                  "type": "array",
                  "items": {
                    "$ref": "base-types.json#/$defs/url"
                  }
                }
              }
            }
          ]
        }
      }
    }
  }
}