{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://qrtrust.local/contracts/verifier-profile.schema.json",
  "title": "QR Trust verifier profile",
  "type": "object",
  "required": [
    "artifact_type",
    "profile_id",
    "profile_version",
    "profile_fingerprint",
    "root_program_id",
    "accepted_delegated_authority_ids",
    "verifier_id",
    "scanner_decision_endpoint",
    "runtime_safety_policy_id",
    "cache_freshness_budget_seconds",
    "decision_color_policy",
    "hold_to_open_policy",
    "valid_from",
    "valid_until",
    "signing_key_id",
    "signature",
    "distribution"
  ],
  "properties": {
    "artifact_type": {
      "const": "verifier_profile"
    },
    "profile_id": {
      "type": "string",
      "minLength": 1
    },
    "profile_version": {
      "type": "integer",
      "minimum": 1
    },
    "profile_fingerprint": {
      "type": "string",
      "pattern": "^sha256:[a-f0-9]{64}$"
    },
    "root_program_id": {
      "type": "string",
      "minLength": 1
    },
    "accepted_delegated_authority_ids": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "verifier_id": {
      "type": "string",
      "minLength": 1
    },
    "scanner_decision_endpoint": {
      "type": "string",
      "pattern": "^https://"
    },
    "runtime_safety_policy_id": {
      "type": "string",
      "minLength": 1
    },
    "cache_freshness_budget_seconds": {
      "type": "integer",
      "minimum": 1
    },
    "decision_color_policy": {
      "type": "object",
      "required": [
        "green_requires",
        "orange_conditions",
        "red_conditions"
      ],
      "properties": {
        "green_requires": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "orange_conditions": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "red_conditions": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "additionalProperties": false
    },
    "hold_to_open_policy": {
      "type": "object",
      "required": [
        "enabled",
        "duration_ms",
        "trigger_conditions"
      ],
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "duration_ms": {
          "type": "integer",
          "minimum": 0
        },
        "trigger_conditions": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "additionalProperties": false
    },
    "valid_from": {
      "type": "string",
      "format": "date-time"
    },
    "valid_until": {
      "type": "string",
      "format": "date-time"
    },
    "signing_key_id": {
      "type": "string",
      "minLength": 1
    },
    "signature": {
      "type": "string",
      "minLength": 1
    },
    "distribution": {
      "type": "object",
      "required": [
        "channel",
        "publisher",
        "scanner_build_constraint"
      ],
      "properties": {
        "channel": {
          "enum": [
            "mdm",
            "enterprise_app_configuration",
            "signed_app_bundle",
            "signed_remote_profile",
            "browser_managed_profile",
            "scanner_sdk_configuration"
          ]
        },
        "publisher": {
          "type": "string",
          "minLength": 1
        },
        "scanner_build_constraint": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
