{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.ishare.eu/v3/party-id/schema.json",
  "title": "Verifiable Credential: Party ID Credential",
  "description": "Verifiable Credential envelope for an iSHARE party. VC 2.0 fields at the top level; party information under credentialSubject. This schema describes the unsigned VC envelope (without proof).",
  "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/party-id/context.jsonld" }
      ]
    },
    "type": {
      "type": "array",
      "minItems": 2,
      "maxItems": 2,
      "prefixItems": [
        { "const": "VerifiableCredential" },
        { "const": "PartyIdCredential" }
      ]
    },
    "id": { "type": "string", "format": "uri" },
    "issuer": {
      "oneOf": [
        { "type": "string" },
        {
          "type": "object",
          "properties": { "id": { "type": "string", "format": "uri" } },
          "required": ["id"],
          "additionalProperties": true
        }
      ]
    },
    "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",
      "description": "Credential status for checking revocation, suspension, or refresh status using bitstring status lists (BitstringStatusListEntry) as defined in W3C Bitstring Status List v1.0"
    },
    "relatedResource": {
      "description": "Required in iSHARE credentials. Lists every @context URL with its digest, plus every machine-readable, version-frozen definition the credential relies on (see related-resource.json).",
      "allOf": [
        {
          "$ref": "https://schemas.ishare.eu/v3/common/related-resource.json#/$defs/RelatedResource"
        },
        {
          "type": "array",
          "allOf": [
            {
              "contains": {
                "properties": {
                  "id": {
                    "const": "https://www.w3.org/ns/credentials/v2"
                  }
                },
                "required": [
                  "id"
                ]
              }
            },
            {
              "contains": {
                "properties": {
                  "id": {
                    "const": "https://schemas.ishare.eu/v3/party-id/context.jsonld"
                  }
                },
                "required": [
                  "id"
                ]
              }
            }
          ]
        }
      ]
    },
    "credentialSubject": { "$ref": "#/$defs/PartySubject" }
  },
  "required": ["@context", "type", "issuer", "credentialStatus", "credentialSubject", "relatedResource"],
  "additionalProperties": true,
  "$defs": {
    "IdentifierAlias": {
      "type": "object",
      "properties": {
        "identifier": { "type": "string" },
        "type": { "type": "string" }
      },
      "required": ["identifier", "type"],
      "additionalProperties": true
    },
    "PartySubject": {
      "type": "object",
      "properties": {
        "id": { "type": "string", "format": "uri" },
        "name": { "type": "string" },
        "alsoKnownAs": {
          "type": "array",
          "items": { "$ref": "#/$defs/IdentifierAlias" },
          "minItems": 1
        }
      },
      "required": ["name", "id"],
      "additionalProperties": true
    }
  }
}
  