{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://protocol.proxypay.invalid/open-request/v1/issuer-metadata-schema.json",
  "title": "ProxyPay Open Request v1 Issuer Metadata",
  "description": "Exact bounded issuer metadata containing public Ed25519 OKP JWKs only.",
  "type": "object",
  "additionalProperties": false,
  "required": ["issuer", "fetched_at", "expires_at", "keys"],
  "properties": {
    "issuer": {
      "type": "string",
      "format": "uri",
      "pattern": "^https://",
      "maxLength": 256
    },
    "fetched_at": {
      "type": "string",
      "minLength": 20,
      "maxLength": 20,
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
    },
    "expires_at": {
      "type": "string",
      "minLength": 20,
      "maxLength": 20,
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
    },
    "keys": {
      "type": "array",
      "maxItems": 8,
      "uniqueItems": true,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "key_id",
          "kty",
          "crv",
          "x",
          "status",
          "not_before",
          "not_after"
        ],
        "properties": {
          "key_id": {
            "type": "string",
            "minLength": 3,
            "maxLength": 64,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{2,63}$"
          },
          "kty": { "const": "OKP" },
          "crv": { "const": "Ed25519" },
          "x": {
            "type": "string",
            "minLength": 43,
            "maxLength": 43,
            "pattern": "^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$"
          },
          "status": { "enum": ["active", "revoked"] },
          "not_before": {
            "type": "string",
            "minLength": 20,
            "maxLength": 20,
            "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$",
            "format": "date-time"
          },
          "not_after": {
            "type": "string",
            "minLength": 20,
            "maxLength": 20,
            "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$",
            "format": "date-time"
          },
          "revoked_at": {
            "type": "string",
            "minLength": 20,
            "maxLength": 20,
            "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": "active" } },
              "required": ["status"]
            },
            "then": { "properties": { "revoked_at": false } }
          },
          {
            "if": {
              "properties": { "status": { "const": "revoked" } },
              "required": ["status"]
            },
            "then": {
              "properties": {
                "revoked_at": {
                  "type": "string",
                  "minLength": 20,
                  "maxLength": 20,
                  "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
                }
              },
              "required": ["revoked_at"]
            }
          }
        ]
      }
    }
  }
}
