{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.ishare.eu/v3/claims/dataspace-agreement/schema.json",
  "title": "Verifiable Credential: iSHARE Dataspace Agreement Claim",
  "description": "Verifiable Credential envelope for an iSHARE Dataspace Agreement Claim. VC 2.0 fields at the top level; domain-specific claims 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/claims/dataspace-agreement/context.jsonld"
        }
      ]
    },
    "type": {
      "type": "array",
      "minItems": 2,
      "maxItems": 2,
      "prefixItems": [
        {
          "const": "VerifiableCredential"
        },
        {
          "const": "DataspaceAgreementCredential"
        }
      ]
    },
    "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/claims/dataspace-agreement/context.jsonld"
                  }
                },
                "required": [
                  "id"
                ]
              }
            }
          ]
        }
      ]
    },
    "credentialSubject": {
      "$ref": "#/$defs/DataspaceAgreementClaimSubject"
    }
  },
  "required": [
    "@context",
    "type",
    "issuer",
    "credentialStatus",
    "credentialSubject",
    "relatedResource"
  ],
  "additionalProperties": true,
  "$defs": {
    "DataspaceAgreementClaimSubject": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uri"
        },
        "registrarId": {
          "type": "string"
        },
        "dataspaceId": {
          "type": "string",
          "description": "ID of the dataspace",
          "examples": ["DSP.EU.NL.DutchMobility"]
        },
        "typeName": {
          "type": "string",
          "description": "Descriptive type of the agreement. Framework or dataspace may define agreement types.",
          "examples": ["Terms of Use"]
        },
        "type": {
          "type": "string",
          "description": "Agreement code: a term of the iSHARE vocabulary (for example TermsOfUse) or, for a dataspace-specific agreement, an absolute IRI in the dataspace's own namespace.",
          "examples": ["https://www.ceads.com/v2/rulebook#DataspaceParticipationAgreement"]
        },
        "title": {
          "type": "string",
          "description": "The name of the agreement or agreement file",
          "examples": ["terms-of-use"]
        },
        "verificationHash": {
          "type": "string",
          "description": "The calculated hash of the agreement file that has been uploaded. Note agreements are not stored in the ledger, but only their hash. The verificationHash must be calculated using the SHA256 hashing algorithm.",
          "examples": ["aef5bb5e3ab49150a53b89628ab8593315b6686f3f96497277feb9d658527acb"]
        }
      },
      "required": [
        "id",
        "registrarId",
        "typeName",
        "type",
        "title"
      ],
      "additionalProperties": true
    }
  }
}
