{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://xcim.org/schemas/wd-02/0.2/receipt.schema.json",
  "title": "XCIM EVP-01 Experimental Receipt Payload 0.2",
  "description": "Explicit experimental wire family. Does not change receipt 0.1, enable EVP by default or establish external identity validation.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "xcim_version",
    "object_type",
    "issuance_profile",
    "receipt_id",
    "issuer",
    "issued_at",
    "not_before",
    "expires_at",
    "application",
    "recipient",
    "identity_evidence",
    "presentation",
    "issuer_independence",
    "permissions",
    "declared_sender_domains"
  ],
  "properties": {
    "xcim_version": {
      "const": "0.2"
    },
    "object_type": {
      "const": "xcim_receipt"
    },
    "issuance_profile": {
      "const": "evp_hosted_consent"
    },
    "receipt_id": {
      "type": "string",
      "pattern": "^urn:xcim:receipt:[A-Za-z0-9._~-]+$"
    },
    "issuer": {
      "$ref": "https://xcim.org/schemas/wd-02/0.2/identity-evidence.schema.json#/$defs/httpsUri"
    },
    "issued_at": {
      "$ref": "https://xcim.org/schemas/wd-02/0.2/identity-evidence.schema.json#/$defs/utc"
    },
    "not_before": {
      "$ref": "https://xcim.org/schemas/wd-02/0.2/identity-evidence.schema.json#/$defs/utc"
    },
    "expires_at": {
      "oneOf": [
        {
          "$ref": "https://xcim.org/schemas/wd-02/0.2/identity-evidence.schema.json#/$defs/utc"
        },
        {
          "type": "null"
        }
      ]
    },
    "application": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "app_id",
        "app_epoch",
        "app_key_id",
        "identity_profiles"
      ],
      "properties": {
        "app_id": {
          "type": "string",
          "pattern": "^urn:xcim:app:[A-Za-z0-9._~-]+$"
        },
        "app_epoch": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "app_key_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "identity_profiles": {
          "type": "array",
          "uniqueItems": true,
          "minItems": 1,
          "maxItems": 2,
          "items": {
            "enum": [
              "evp-01",
              "oidc-01"
            ]
          },
          "contains": {
            "const": "evp-01"
          }
        }
      }
    },
    "recipient": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "pairwise_id",
        "identity_assurance"
      ],
      "properties": {
        "pairwise_id": {
          "$ref": "https://xcim.org/schemas/wd-02/0.2/identity-evidence.schema.json#/$defs/hash"
        },
        "identity_assurance": {
          "const": "evp_email_control_verified"
        }
      }
    },
    "identity_evidence": {
      "$ref": "https://xcim.org/schemas/wd-02/0.2/identity-evidence.schema.json"
    },
    "presentation": {
      "allOf": [
        {
          "$ref": "https://xcim.org/schemas/0.1/receipt.schema.json#/$defs/presentation"
        },
        {
          "properties": {
            "accepted_at": {
              "$ref": "https://xcim.org/schemas/wd-02/0.2/identity-evidence.schema.json#/$defs/utc"
            }
          }
        }
      ]
    },
    "issuer_independence": {
      "enum": [
        "independent",
        "organizationally_separated",
        "vendor_controlled",
        "unknown"
      ]
    },
    "permissions": {
      "type": "array",
      "minItems": 1,
      "maxItems": 64,
      "items": {
        "allOf": [
          {
            "$ref": "https://xcim.org/schemas/0.1/receipt.schema.json#/$defs/permission"
          },
          {
            "properties": {
              "granted_at": {
                "oneOf": [
                  {
                    "$ref": "https://xcim.org/schemas/wd-02/0.2/identity-evidence.schema.json#/$defs/utc"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "expires_at": {
                "oneOf": [
                  {
                    "$ref": "https://xcim.org/schemas/wd-02/0.2/identity-evidence.schema.json#/$defs/utc"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          }
        ]
      }
    },
    "declared_sender_domains": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "$ref": "https://xcim.org/schemas/0.1/receipt.schema.json#/$defs/domain"
      }
    }
  }
}
