{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://empower-x.io/schemas/membership-credential/1.0.json",
  "title": "EMPOWER-X membership credential",
  "description": "W3C Verifiable Credential issued by the Governance Authority when a participant is admitted (R1.4, R5.1).",
  "type": "object",
  "required": [
    "@context",
    "type",
    "issuer",
    "validFrom",
    "credentialSubject",
    "credentialStatus"
  ],
  "properties": {
    "@context": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "contains": {
        "const": "https://www.w3.org/ns/credentials/v2"
      }
    },
    "id": {
      "type": "string",
      "format": "uri"
    },
    "type": {
      "type": "array",
      "allOf": [
        {
          "contains": {
            "const": "VerifiableCredential"
          }
        },
        {
          "contains": {
            "const": "EmpowerXMembershipCredential"
          }
        }
      ]
    },
    "issuer": {
      "type": "string",
      "pattern": "^did:web:"
    },
    "validFrom": {
      "type": "string",
      "format": "date-time"
    },
    "validUntil": {
      "type": "string",
      "format": "date-time"
    },
    "credentialSubject": {
      "type": "object",
      "required": [
        "id",
        "legalName",
        "registrationNumber",
        "roles",
        "membershipStatus",
        "memberSince",
        "gaiaxParticipantCredential"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^did:web:",
          "description": "The participant DID (did:web on a domain the organisation controls)."
        },
        "legalName": {
          "type": "string",
          "minLength": 2
        },
        "registrationNumber": {
          "type": "string",
          "minLength": 2
        },
        "roles": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "enum": [
              "DataProvider",
              "DataConsumer",
              "ServiceProvider",
              "ComputeProvider",
              "DataSpaceOperator",
              "TechnologyProvider",
              "FederationPartner"
            ]
          }
        },
        "membershipStatus": {
          "enum": [
            "Active",
            "Suspended"
          ]
        },
        "memberSince": {
          "type": "string",
          "format": "date"
        },
        "gaiaxParticipantCredential": {
          "type": "string",
          "format": "uri",
          "description": "Where the Gaia-X legal participant credential is hosted (production domain)."
        },
        "rulebookVersion": {
          "type": "string",
          "pattern": "^\\d+\\.\\d+$"
        }
      },
      "additionalProperties": false
    },
    "credentialStatus": {
      "type": "object",
      "required": [
        "type",
        "statusPurpose",
        "statusListIndex",
        "statusListCredential"
      ],
      "properties": {
        "type": {
          "const": "BitstringStatusListEntry"
        },
        "statusPurpose": {
          "const": "revocation"
        },
        "statusListIndex": {
          "type": "string",
          "pattern": "^\\d+$"
        },
        "statusListCredential": {
          "type": "string",
          "format": "uri"
        }
      }
    },
    "proof": {
      "type": "object"
    }
  }
}
