{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://qrtrust.local/contracts/root-manifest.schema.json",
  "title": "QR Trust root manifest",
  "type": "object",
  "required": [
    "artifact_type",
    "schema_version",
    "root_program_id",
    "name",
    "program_scope",
    "accepted_algorithm_ids",
    "policy_constraints",
    "delegated_authorities",
    "publication"
  ],
  "properties": {
    "artifact_type": {
      "const": "root_manifest"
    },
    "schema_version": {
      "type": "string",
      "minLength": 1
    },
    "fixture_notice": {
      "type": "string"
    },
    "root_program_id": {
      "type": "string",
      "pattern": "^root:"
    },
    "name": {
      "type": "string",
      "minLength": 1
    },
    "program_scope": {
      "type": "string",
      "minLength": 1
    },
    "accepted_algorithm_ids": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "trust_keys": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/trust_key"
      }
    },
    "policy_constraints": {
      "type": "object",
      "required": [
        "requires_root_scoped_issuer_namespace",
        "requires_destination_policy",
        "requires_cache_freshness_metadata",
        "requires_scanner_visible_decision_state"
      ],
      "properties": {
        "allows_unenrolled_qr_as_unverified": {
          "type": "boolean"
        },
        "requires_root_scoped_issuer_namespace": {
          "type": "boolean"
        },
        "requires_destination_policy": {
          "type": "boolean"
        },
        "requires_cache_freshness_metadata": {
          "type": "boolean"
        },
        "requires_scanner_visible_decision_state": {
          "type": "boolean"
        }
      },
      "additionalProperties": true
    },
    "delegated_authorities": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "delegated_authority_id",
          "name",
          "manifest_ref",
          "status"
        ],
        "properties": {
          "delegated_authority_id": {
            "type": "string",
            "pattern": "^authority:"
          },
          "name": {
            "type": "string",
            "minLength": 1
          },
          "manifest_ref": {
            "type": "string",
            "minLength": 1
          },
          "status": {
            "enum": [
              "active",
              "suspended",
              "revoked"
            ]
          }
        },
        "additionalProperties": true
      }
    },
    "publication": {
      "$ref": "#/$defs/publication"
    }
  },
  "additionalProperties": false,
  "$defs": {
    "trust_key": {
      "type": "object",
      "required": [
        "key_id",
        "signer_id",
        "algorithm_id",
        "public_key_material_ref",
        "status"
      ],
      "properties": {
        "key_id": {
          "type": "string",
          "minLength": 1
        },
        "signer_id": {
          "type": "string",
          "minLength": 1
        },
        "algorithm_id": {
          "type": "string",
          "minLength": 1
        },
        "public_key_material_ref": {
          "type": "string",
          "minLength": 1
        },
        "status": {
          "enum": [
            "active",
            "suspended",
            "revoked"
          ]
        }
      },
      "additionalProperties": true
    },
    "publication": {
      "type": "object",
      "required": [
        "published_at",
        "valid_until",
        "signature_status"
      ],
      "properties": {
        "published_at": {
          "type": "string",
          "format": "date-time"
        },
        "valid_until": {
          "type": "string",
          "format": "date-time"
        },
        "signed_by": {
          "type": "string",
          "minLength": 1
        },
        "signature_status": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": true
    }
  }
}
