{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://license.aurea.software/docs/license/license-file-v1.schema.json",
  "title": "Aurea License File v1",
  "type": "object",
  "required": [
    "payload",
    "signature"
  ],
  "properties": {
    "payload": {
      "type": "object",
      "required": [
        "schemaVersion",
        "licenseId",
        "licenseType",
        "plan",
        "account",
        "organization",
        "validity",
        "entitlements"
      ],
      "properties": {
        "schemaVersion": {
          "type": "integer",
          "const": 1
        },
        "licenseId": {
          "type": "string",
          "pattern": "^lic_[a-z0-9]+$"
        },
        "licenseType": {
          "type": "string",
          "enum": [
            "subscription"
          ]
        },
        "plan": {
          "type": "string",
          "enum": [
            "standard"
          ]
        },
        "account": {
          "type": "object",
          "required": [
            "accountId",
            "name"
          ],
          "properties": {
            "accountId": {
              "type": "string",
              "pattern": "^acct_[a-z0-9]+$"
            },
            "name": {
              "type": "string",
              "minLength": 1
            }
          },
          "additionalProperties": false
        },
        "organization": {
          "type": "object",
          "required": [
            "organizationId",
            "name",
            "environmentType"
          ],
          "properties": {
            "organizationId": {
              "type": "string",
              "pattern": "^org_[a-z0-9]+$"
            },
            "name": {
              "type": "string",
              "minLength": 1
            },
            "environmentType": {
              "type": "string",
              "enum": [
                "production",
                "staging",
                "test",
                "development"
              ]
            }
          },
          "additionalProperties": false
        },
        "validity": {
          "type": "object",
          "required": [
            "issuedAt",
            "validFrom",
            "validUntil",
            "graceUntil"
          ],
          "properties": {
            "issuedAt": {
              "type": "string",
              "format": "date-time"
            },
            "validFrom": {
              "type": "string",
              "format": "date-time"
            },
            "validUntil": {
              "type": "string",
              "format": "date-time"
            },
            "graceUntil": {
              "type": "string",
              "format": "date-time"
            }
          },
          "additionalProperties": false
        },
        "entitlements": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "code",
              "type",
              "value"
            ],
            "properties": {
              "code": {
                "type": "string",
                "minLength": 1
              },
              "type": {
                "type": "string",
                "enum": [
                  "limit",
                  "feature"
                ]
              },
              "metric": {
                "type": "string",
                "minLength": 1
              },
              "value": {
                "oneOf": [
                  {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 2147483647
                  },
                  {
                    "type": "boolean"
                  }
                ]
              }
            },
            "additionalProperties": false
          }
        }
      },
      "additionalProperties": false
    },
    "signature": {
      "type": "object",
      "required": [
        "algorithm",
        "canonicalization",
        "keyId",
        "value"
      ],
      "properties": {
        "algorithm": {
          "type": "string",
          "const": "Ed25519"
        },
        "canonicalization": {
          "type": "string",
          "const": "jcs-rfc8785"
        },
        "keyId": {
          "type": "string",
          "minLength": 1
        },
        "value": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
