{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://binaryinference.co.za/os/developers/files/bap-manifest.schema.json",
  "title": "Binary Application Package manifest (draft 0.1)",
  "description": "DRAFT. A proposal, not a specification: no verifier or installer implements it, and it will change. Describes bap.json.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema_version", "app_id", "publisher_id", "display_name", "version", "release_sequence", "target", "platform_api", "runtime", "entrypoint", "permissions", "dependencies", "files", "presentation", "licence"],
  "definitions": {
    "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
    "path": { "type": "string", "minLength": 1, "maxLength": 240, "pattern": "^(?!/)(?!.*(^|/)\\.{1,2}(/|$))(?!.*//)[^\\\\\\u0000-\\u001f]+$" }
  },
  "properties": {
    "schema_version": { "const": 1 },
    "app_id": { "type": "string", "pattern": "^[A-Za-z0-9]+(\\.[A-Za-z0-9_-]+){2,}$", "description": "Stable reverse-domain identifier. Namespace ownership comes from trusted registry data, not from this field." },
    "publisher_id": { "type": "string", "minLength": 1, "maxLength": 80 },
    "display_name": { "type": "string", "minLength": 1, "maxLength": 80 },
    "version": { "type": "string", "minLength": 1, "maxLength": 40 },
    "release_sequence": { "type": "integer", "minimum": 1 },
    "target": {
      "type": "object",
      "additionalProperties": false,
      "required": ["platform", "architecture"],
      "properties": { "platform": { "type": "string" }, "architecture": { "type": "string" } }
    },
    "platform_api": {
      "type": "object",
      "additionalProperties": false,
      "required": ["min", "max"],
      "properties": { "min": { "type": "integer", "minimum": 1 }, "max": { "type": "integer", "minimum": 1 } }
    },
    "runtime": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "version", "sha256"],
      "properties": { "id": { "type": "string" }, "version": { "type": "string" }, "sha256": { "$ref": "#/definitions/sha256" } }
    },
    "entrypoint": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 }, "description": "Argument list. Never a shell string. The first item is a path inside the payload." },
    "permissions": { "type": "array", "items": { "type": "object", "additionalProperties": true }, "description": "Capabilities from the permissions registry. Not final." },
    "dependencies": { "type": "array", "items": { "type": "object", "additionalProperties": true } },
    "files": {
      "type": "array",
      "minItems": 1,
      "maxItems": 4096,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["path", "size", "sha256", "mode"],
        "properties": {
          "path": { "$ref": "#/definitions/path" },
          "size": { "type": "integer", "minimum": 0 },
          "sha256": { "$ref": "#/definitions/sha256" },
          "mode": { "enum": ["0644", "0755"] }
        }
      }
    },
    "presentation": {
      "type": "object",
      "additionalProperties": false,
      "required": ["icon", "summary"],
      "properties": { "icon": { "$ref": "#/definitions/path" }, "summary": { "type": "string", "minLength": 1, "maxLength": 200 } }
    },
    "licence": { "type": "string", "minLength": 1 }
  }
}
