{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tune.toys/schemas/platform/license-certificate.schema.json",
  "title": "LicenseCertificate",
  "description": "Offline license certificate payload (tunetoys.license-certificate/1), signed in a SignedEnvelope with the license key. Contains no device ID, email or handle. allowedMajor or until is absent for the all update policy.",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "schema": {
      "const": "tunetoys.license-certificate/1"
    },
    "certificateId": {
      "$ref": "common.schema.json#/$defs/EntityId"
    },
    "accountId": {
      "$ref": "common.schema.json#/$defs/EntityId"
    },
    "productId": {
      "$ref": "common.schema.json#/$defs/EntityId"
    },
    "grantIds": {
      "type": "array",
      "items": {
        "$ref": "common.schema.json#/$defs/EntityId"
      },
      "maxItems": 32,
      "minItems": 1,
      "uniqueItems": true
    },
    "allowedMajor": {
      "type": "integer",
      "minimum": 0,
      "maximum": 65535
    },
    "until": {
      "$ref": "common.schema.json#/$defs/Timestamp"
    },
    "issuedAt": {
      "$ref": "common.schema.json#/$defs/Timestamp"
    },
    "expiresAt": {
      "$ref": "common.schema.json#/$defs/Timestamp"
    },
    "graceSeconds": {
      "type": "integer",
      "minimum": 0,
      "maximum": 2592000
    },
    "keyId": {
      "$ref": "common.schema.json#/$defs/EntityId"
    }
  },
  "required": [
    "schema",
    "certificateId",
    "accountId",
    "productId",
    "grantIds",
    "issuedAt",
    "expiresAt",
    "graceSeconds",
    "keyId"
  ],
  "not": {
    "required": ["allowedMajor", "until"],
    "properties": {
      "allowedMajor": true,
      "until": true
    }
  }
}
