{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://nocip.com/assets/api/connections.schema.json",
 "title": "NOCIP connection manifest",
 "description": "Every destination the software connects to, published by the vendor at https://<domain>/.well-known/nocip.json (criterion group I-5). The test lab compares captured traffic with it.",
 "type": "object",
 "additionalProperties": false,
 "required": [
  "schema",
  "product",
  "version",
  "connections",
  "ai_processing"
 ],
 "properties": {
  "schema": {
   "const": "nocip-connections/1"
  },
  "label": {
   "type": [
    "string",
    "null"
   ],
   "pattern": "^NOCIP-[GSB]-[0-9]{4}-[0-9]{4}$"
  },
  "domain_proof": {
   "type": "string",
   "maxLength": 100,
   "description": "the one-time code of an open case (nocip-verify=...), may be removed after the proof"
  },
  "product": {
   "type": "string",
   "maxLength": 200
  },
  "version": {
   "type": "string",
   "maxLength": 50
  },
  "connections": {
   "type": "array",
   "maxItems": 100,
   "items": {
    "type": "object",
    "additionalProperties": false,
    "required": [
     "host",
     "port",
     "purpose",
     "when"
    ],
    "properties": {
     "host": {
      "type": "string",
      "maxLength": 253,
      "description": "domain name or IP address"
     },
     "port": {
      "type": "integer",
      "minimum": 1,
      "maximum": 65535
     },
     "protocol": {
      "type": "string",
      "maxLength": 20,
      "description": "e.g. https"
     },
     "purpose": {
      "type": "string",
      "maxLength": 200,
      "description": "e.g. licence-check, update-download, ai-request, user-report, telemetry"
     },
     "when": {
      "type": "string",
      "maxLength": 200,
      "description": "how often / on which event, e.g. once a day, only when the user clicks"
     },
     "data": {
      "type": "string",
      "maxLength": 500,
      "description": "what is sent"
     },
     "volume_per_day_kb": {
      "type": "number",
      "minimum": 0,
      "description": "estimate (recommended, no points)"
     }
    }
   }
  },
  "ai_processing": {
   "type": "array",
   "minItems": 1,
   "maxItems": 50,
   "items": {
    "type": "object",
    "additionalProperties": false,
    "required": [
     "function",
     "location"
    ],
    "properties": {
     "function": {
      "type": "string",
      "maxLength": 200
     },
     "location": {
      "enum": [
       "customer",
       "vendor",
       "third-party"
      ]
     },
     "network": {
      "type": "boolean",
      "description": "does this AI function use the network"
     },
     "provider": {
      "type": "string",
      "maxLength": 200
     },
     "country": {
      "type": "string",
      "maxLength": 60
     }
    }
   }
  }
 }
}
