{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openmobiledocumentagent.org/schemas/v0.1/evidence-credential.schema.json",
  "title": "OMDA evidence credential, unsecured payload (§11)",
  "description": "VC 2.0 data model, secured with SD-JWT. Claims that an attested runtime read these values and these checks passed; not that the document is genuine unless status is issuer_signed.",
  "type": "object",
  "required": ["@context", "type", "issuer", "validFrom", "validUntil", "credentialSubject"],
  "properties": {
    "@context": {
      "type": "array",
      "prefixItems": [{ "const": "https://www.w3.org/ns/credentials/v2" }],
      "contains": { "const": "https://openmobiledocumentagent.org/ns/v0.1" }
    },
    "type": {
      "type": "array",
      "allOf": [
        { "contains": { "const": "VerifiableCredential" } },
        { "contains": { "const": "OMDAEvidenceCredential" } }
      ]
    },
    "issuer": {
      "type": "object",
      "required": ["id", "attestation"],
      "properties": {
        "id": { "type": "string", "description": "did:jwk or similar for the device-bound runtime key." },
        "attestation": { "enum": ["android_key_attestation", "ios_app_attest"] },
        "runtime": { "type": "string" }
      }
    },
    "validFrom": { "$ref": "common.schema.json#/$defs/timestamp" },
    "validUntil": { "$ref": "common.schema.json#/$defs/timestamp" },
    "credentialSubject": {
      "type": "object",
      "required": ["purpose", "audience", "disclosures"],
      "properties": {
        "purpose": { "type": "string" },
        "audience": { "type": "string" },
        "disclosures": {
          "type": "array",
          "minItems": 1,
          "items": { "oneOf": [{ "$ref": "#/$defs/fieldDisclosure" }, { "$ref": "#/$defs/predicateDisclosure" }] }
        }
      }
    }
  },
  "$defs": {
    "exportStatus": { "enum": ["issuer_signed", "confirmed", "verified", "unverified", "candidate"] },
    "fieldDisclosure": {
      "type": "object",
      "required": ["field", "value", "type", "status", "checks", "method"],
      "additionalProperties": false,
      "description": "Never carries quote, region or page hash (OD-007).",
      "properties": {
        "field": { "$ref": "common.schema.json#/$defs/fieldName" },
        "value": {},
        "type": { "type": "string" },
        "status": { "$ref": "#/$defs/exportStatus" },
        "checks": { "type": "array", "items": { "$ref": "common.schema.json#/$defs/checkResult" } },
        "method": {
          "type": "object",
          "required": ["kind", "location"],
          "additionalProperties": false,
          "properties": {
            "kind": { "$ref": "common.schema.json#/$defs/methodKind" },
            "location": { "$ref": "common.schema.json#/$defs/location" }
          }
        }
      }
    },
    "predicateDisclosure": {
      "type": "object",
      "required": ["predicate", "result", "basis"],
      "additionalProperties": false,
      "description": "Result only; the underlying values are never disclosed (OD-030).",
      "properties": {
        "predicate": { "type": "string", "pattern": "^[a-z][a-z0-9_]*(:.+)?$" },
        "result": { "type": "boolean" },
        "basis": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": ["field", "status", "checks"],
            "additionalProperties": false,
            "properties": {
              "field": { "$ref": "common.schema.json#/$defs/fieldName" },
              "status": { "$ref": "#/$defs/exportStatus" },
              "checks": { "type": "array", "items": { "$ref": "common.schema.json#/$defs/checkResult" } }
            }
          }
        }
      }
    }
  }
}
