{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:junexis:schema:sdk-trust-store:0.1",
  "title": "Magazyn zaufanych kluczy wydań Junexis SDK 0.1",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "authority", "revision", "keys"],
  "properties": {
    "schemaVersion": { "const": "junexis.sdk.trust-store/0.1" },
    "authority": { "const": "junexis-project" },
    "revision": { "type": "integer", "minimum": 1 },
    "keys": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["keyId", "algorithm", "usage", "publicKeySpki", "notBefore", "notAfter", "status"],
        "properties": {
          "keyId": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{2,63}$" },
          "algorithm": { "const": "ecdsa-p256-sha256-der" },
          "usage": { "const": "sdk-release" },
          "publicKeySpki": { "type": "string", "minLength": 1, "contentEncoding": "base64" },
          "notBefore": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$" },
          "notAfter": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$" },
          "status": { "enum": ["active", "revoked"] },
          "revokedAt": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$" }
        },
        "allOf": [
          {
            "if": { "properties": { "status": { "const": "revoked" } } },
            "then": { "required": ["revokedAt"] },
            "else": { "not": { "required": ["revokedAt"] } }
          }
        ]
      }
    }
  }
}
