{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:junexis:schema:registry-revocation:0.1",
  "title": "Wycofanie Junexis Registry 0.1",
  "description": "Podpisany rekord wycofania celu w Registry: bezpieczeństwo, decyzja operacyjna albo zastąpienie nowszą wersją. Rodzaj musi mieścić się w zakresie roli revocation z magazynu zaufania.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "kind",
    "target",
    "reason",
    "revokedAt",
    "algorithm",
    "keyId",
    "signature"
  ],
  "properties": {
    "schemaVersion": { "const": "junexis.registry-revocation/0.1" },
    "kind": { "enum": ["security", "operational", "superseded"] },
    "target": { "$ref": "#/$defs/target" },
    "reason": { "type": "string", "minLength": 1, "maxLength": 2048 },
    "revokedAt": { "$ref": "#/$defs/timestamp" },
    "algorithm": { "const": "ecdsa-p256-sha256-der" },
    "keyId": { "$ref": "#/$defs/keyId" },
    "signature": { "type": "string", "minLength": 1, "contentEncoding": "base64" }
  },
  "$defs": {
    "keyId": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" },
    "timestamp": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$" },
    "identifier": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]{1,127}$" },
    "semver": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+(?:[-+][0-9A-Za-z.-]+)?$" },
    "target": {
      "type": "object",
      "additionalProperties": false,
      "required": ["type", "id"],
      "properties": {
        "type": { "enum": ["package", "provider", "platform-component", "registry-snapshot-revision"] },
        "id": { "$ref": "#/$defs/identifier" },
        "version": { "$ref": "#/$defs/semver" },
        "revision": { "type": "integer", "minimum": 1 }
      },
      "allOf": [
        {
          "if": { "properties": { "type": { "enum": ["package", "provider"] } }, "required": ["type"] },
          "then": { "required": ["version"] }
        },
        {
          "if": { "properties": { "type": { "const": "registry-snapshot-revision" } }, "required": ["type"] },
          "then": { "required": ["revision"] }
        },
        {
          "if": { "properties": { "type": { "const": "platform-component" } }, "required": ["type"] },
          "then": { "not": { "required": ["revision"] } }
        }
      ]
    }
  }
}
