{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:sitla:wire:1:schema:service-assertion",
  "title": "service-assertion",
  "$comment": "SPDX-License-Identifier: CC0-1.0; structural validity is not authorization",
  "type": "object",
  "properties": {
    "payload": {
      "type": "object",
      "properties": {
        "protocol": {
          "const": "sitla-wire/1"
        },
        "operator_id": {
          "type": "string",
          "pattern": "^https://[^/?#]+(?:/[^?#]*)?$"
        },
        "request_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2048
        },
        "request_digest": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "audience": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2048
        },
        "purpose": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2048
        },
        "challenge": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]+$",
          "minLength": 43,
          "maxLength": 86
        },
        "issued_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "expires_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
        },
        "policy_digest": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "type": {
          "const": "ServiceAssertion"
        },
        "domain": {
          "const": "SITLA/service/1"
        },
        "data_digest": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        }
      },
      "required": [
        "protocol",
        "operator_id",
        "request_id",
        "request_digest",
        "audience",
        "purpose",
        "challenge",
        "issued_at",
        "expires_at",
        "policy_digest",
        "type",
        "domain",
        "data_digest"
      ],
      "additionalProperties": false
    },
    "signature": {
      "type": "object",
      "properties": {
        "suite": {
          "const": "Ed25519"
        },
        "key_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2048
        },
        "value": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{86}$"
        }
      },
      "required": [
        "suite",
        "key_id",
        "value"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "payload",
    "signature"
  ],
  "additionalProperties": false
}
