{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ucan.xyz/schemas/primitives.json",
  "title": "UCAN Primitive Types",
  "description": "Core primitive types used across all UCAN specifications",
  "$defs": {
    "DID": {
      "title": "Decentralized Identifier",
      "description": "A W3C Decentralized Identifier (DID) string",
      "type": "string",
      "pattern": "^did:[a-z0-9]+:[a-zA-Z0-9._%-]+(:[a-zA-Z0-9._%-]+)*([/?#].*)?$",
      "examples": [
        "did:key:z6MkiTBz1ymuepAQ4HEHYSF1H8quG5GLVVQR3djdX3mDooWp",
        "did:web:example.com"
      ]
    },
    "CID": {
      "title": "Content Identifier",
      "description": "IPLD CIDv1 with DAG-CBOR codec and SHA-256 multihash (base58btc)",
      "type": "object",
      "properties": {
        "/": {
          "type": "string",
          "pattern": "^zdpu[a-km-zA-HJ-NP-Z1-9]+$"
        }
      },
      "required": [
        "/"
      ],
      "additionalProperties": false
    },
    "Bytes": {
      "title": "Binary Data",
      "description": "Binary data in DAG-JSON format (base64 encoded)",
      "type": "object",
      "properties": {
        "/": {
          "type": "object",
          "properties": {
            "bytes": {
              "type": "string",
              "contentEncoding": "base64"
            }
          },
          "required": [
            "bytes"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "/"
      ],
      "additionalProperties": false
    },
    "Timestamp": {
      "title": "Unix Timestamp",
      "description": "Unix timestamp in seconds (53-bit integer for JS compatibility)",
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "NullableTimestamp": {
      "title": "Nullable Timestamp",
      "description": "Timestamp or null for non-expiring tokens",
      "oneOf": [
        {
          "$ref": "#/$defs/Timestamp"
        },
        {
          "type": "null"
        }
      ]
    },
    "VarsigHeader": {
      "title": "Varsig Header",
      "description": "Variable signature header with algorithm metadata",
      "allOf": [
        {
          "$ref": "#/$defs/Bytes"
        }
      ]
    },
    "Signature": {
      "title": "Cryptographic Signature",
      "description": "Raw signature bytes",
      "allOf": [
        {
          "$ref": "#/$defs/Bytes"
        }
      ]
    },
    "Command": {
      "title": "UCAN Command",
      "description": "Slash-delimited path describing an action (lowercase, starts with /)",
      "type": "string",
      "pattern": "^/([a-z0-9_\\u00C0-\\u024F]+(/[a-z0-9_\\u00C0-\\u024F]+)*)?$",
      "examples": [
        "/",
        "/crud/create",
        "/msg/send",
        "/ucan/revoke"
      ]
    },
    "Metadata": {
      "title": "Metadata",
      "description": "Arbitrary metadata map",
      "type": "object",
      "additionalProperties": true
    },
    "Arguments": {
      "title": "Command Arguments",
      "description": "Map of command arguments",
      "type": "object",
      "additionalProperties": true
    }
  }
}
