{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.ishare.eu/v3/framework-compliance/schema.json",
  "title": "Verifiable Credential: Framework Compliance Credential",
  "description": "Verifiable Credential envelope for iSHARE framework compliance. In the semi-modular model this credential also carries the participant's base identity (name, alsoKnownAs), since framework compliance is established at the organisation level independent of any specific dataspace. The credentialSubject carries the participant identity and a list of frameworks the participant adheres to, each with its roles, agreements, X.509 certificates, and identity provider assertions. This schema describes the unsigned VC payload that can be secured and carried as a W3C EnvelopedVerifiableCredential.",
  "type": "object",
  "properties": {
    "@context": {
      "type": "array",
      "minItems": 2,
      "maxItems": 2,
      "prefixItems": [
        {
          "const": "https://www.w3.org/ns/credentials/v2"
        },
        {
          "const": "https://schemas.ishare.eu/v3/framework-compliance/context.jsonld"
        }
      ]
    },
    "id": {
      "type": "string"
    },
    "type": {
      "type": "array",
      "contains": {
        "const": "VerifiableCredential"
      },
      "allOf": [
        {
          "contains": {
            "const": "FrameworkComplianceCredential"
          }
        }
      ],
      "minItems": 2,
      "uniqueItems": true
    },
    "issuer": {
      "$ref": "#/$defs/Issuer"
    },
    "validFrom": {
      "type": "string",
      "format": "date-time"
    },
    "validUntil": {
      "type": "string",
      "format": "date-time"
    },
    "credentialStatus": {
      "$ref": "https://schemas.ishare.eu/v3/common/credential-status.json#/$defs/CredentialStatus"
    },
    "credentialSubject": {
      "$ref": "#/$defs/FrameworkComplianceSubject"
    }
  },
  "required": [
    "@context",
    "type",
    "issuer",
    "credentialStatus",
    "credentialSubject"
  ],
  "additionalProperties": false,
  "$defs": {
    "Issuer": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "resolverUrl": {
              "type": "string",
              "format": "uri"
            }
          },
          "required": [
            "id"
          ],
          "additionalProperties": true
        }
      ]
    },
    "IdentifierAlias": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "type": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "type"
      ],
      "additionalProperties": false
    },
    "AdditionalInfo": {
      "type": "object",
      "properties": {
        "description": {
          "type": "string"
        },
        "logo": {
          "type": "string"
        },
        "website": {
          "type": "string",
          "format": "uri"
        },
        "companyPhone": {
          "type": "string"
        },
        "companyEmail": {
          "type": "string",
          "format": "email"
        },
        "publiclyPublishable": {
          "type": "boolean"
        },
        "countriesOfOperation": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "sectorIndustry": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "tags": {
          "type": "string"
        }
      },
      "required": [
        "publiclyPublishable"
      ],
      "additionalProperties": false
    },
    "FrameworkRole": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "registrarId": {
          "type": "string"
        },
        "frameworkId": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "typeName": {
          "type": "string"
        },
        "loa": {
          "type": "string",
          "enum": [
            "low",
            "substantial",
            "high"
          ]
        },
        "compliancyVerified": {
          "type": "string",
          "enum": [
            "yes",
            "no",
            "not-applicable"
          ]
        },
        "legalAdherence": {
          "type": "string",
          "enum": [
            "yes",
            "no",
            "not-applicable"
          ]
        },
        "validFrom": {
          "type": "string",
          "format": "date-time"
        },
        "validUntil": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "id",
        "type",
        "loa",
        "compliancyVerified",
        "legalAdherence"
      ],
      "additionalProperties": false
    },
    "FrameworkAgreement": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "registrarId": {
          "type": "string"
        },
        "frameworkId": {
          "type": "string"
        },
        "typeName": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "verificationHash": {
          "type": "string"
        },
        "validFrom": {
          "type": "string",
          "format": "date-time"
        },
        "validUntil": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "id",
        "typeName",
        "type",
        "title"
      ],
      "additionalProperties": false
    },
    "X509Certificate": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "registrarId": {
          "type": "string"
        },
        "subjectName": {
          "type": "string"
        },
        "certificateType": {
          "type": "string"
        },
        "x5c": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1
        },
        "x5t#s256": {
          "type": "string"
        },
        "validFrom": {
          "type": "string",
          "format": "date-time"
        },
        "validUntil": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "id",
        "subjectName",
        "certificateType",
        "x5c",
        "x5t#s256"
      ],
      "additionalProperties": false
    },
    "IdpAssertion": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "registrarId": {
          "type": "string"
        },
        "assertion": {
          "type": "string"
        },
        "verificationHash": {
          "type": "string"
        },
        "validFrom": {
          "type": "string",
          "format": "date-time"
        },
        "validUntil": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "id",
        "assertion",
        "validFrom",
        "validUntil"
      ],
      "additionalProperties": false
    },
    "Framework": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "version": {
          "type": "string"
        },
        "defUrl": {
          "type": "string",
          "format": "uri"
        },
        "capabilityUrl": {
          "type": "string",
          "format": "uri"
        },
        "additionalInfo": {
          "$ref": "#/$defs/AdditionalInfo"
        },
        "roles": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/FrameworkRole"
          },
          "minItems": 1
        },
        "agreements": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/FrameworkAgreement"
          },
          "minItems": 1
        },
        "x509Certificates": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/X509Certificate"
          },
          "minItems": 1
        },
        "idpAssertions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/IdpAssertion"
          },
          "minItems": 1
        }
      },
      "required": [
        "id"
      ],
      "additionalProperties": false
    },
    "FrameworkComplianceSubject": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "frameworks": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Framework"
          },
          "minItems": 1
        }
      },
      "required": [
        "id",
        "frameworks"
      ],
      "additionalProperties": false
    }
  }
}
