{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://fingertrackid.dev/schemas/integration-manifest.v1.schema.json",
  "title": "IntegrationManifestV1",
  "description": "fingertrackid.integration.json (D209): the issued public values of one application, generated by the console from reads the signed-in member already makes and saved in the repository that integrates FingerTrackID. Public identifiers only and closed at every level; the HMAC secret appears only as the name of the environment variable the backend reads it from, never as a value.",
  "type": "object",
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "integration-manifest.v1"
    },
    "generated_at": {
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$"
    },
    "api_origin": {
      "type": "string",
      "const": "https://api.fingertrackid.com"
    },
    "documentation": {
      "type": "string",
      "const": "https://docs.fingertrackid.com/llms-full.txt"
    },
    "request_profile": {
      "type": "string",
      "const": "event-assessment-request.v1.1"
    },
    "secret": {
      "type": "object",
      "properties": {
        "env_var": {
          "type": "string",
          "const": "FTID_HMAC_SECRET_HEX"
        },
        "encoding": {
          "type": "string",
          "const": "hex"
        }
      },
      "required": ["env_var", "encoding"],
      "additionalProperties": false,
      "description": "Where the backend reads the HMAC secret: an environment variable holding the 64 lowercase hexadecimal characters received once in the console. Never the value."
    },
    "application": {
      "type": "object",
      "properties": {
        "application_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        },
        "slug": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "environment": {
          "type": "string",
          "enum": ["development", "staging", "production"]
        },
        "public_key": {
          "type": "string",
          "pattern": "^pub_app_[A-Za-z0-9_-]{1,128}$"
        },
        "allowed_origins": {
          "maxItems": 32,
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "pattern": "^https:\\/\\/[a-z0-9]([a-z0-9.-]*[a-z0-9])?(:[1-9][0-9]{0,4})?$"
          }
        }
      },
      "required": [
        "application_id",
        "slug",
        "name",
        "environment",
        "public_key",
        "allowed_origins"
      ],
      "additionalProperties": false
    },
    "collection": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "origin": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255,
              "pattern": "^https:\\/\\/[a-z0-9]([a-z0-9.-]*[a-z0-9])?(:[1-9][0-9]{0,4})?$"
            }
          },
          "required": ["origin"],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ],
      "description": "The active first-party collection origin, or null while the console cannot confirm one."
    },
    "server_credentials": {
      "maxItems": 8,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "client_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,128}$"
          },
          "key_id": {
            "type": "string",
            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
          },
          "capabilities": {
            "minItems": 1,
            "maxItems": 3,
            "type": "array",
            "items": {
              "type": "string",
              "enum": ["assessment:write", "action:write", "outcome:write"]
            }
          },
          "rate_limit_rps": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 1,
                "maximum": 1000
              },
              {
                "type": "null"
              }
            ]
          },
          "burst": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 1,
                "maximum": 10000
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": ["client_id", "key_id", "capabilities", "rate_limit_rps", "burst"],
        "additionalProperties": false
      },
      "description": "Every credential version in the CURRENT state, of every active server client. key_id is the only public locator of a credential."
    },
    "sdk_package": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "package_name": {
              "type": "string",
              "const": "@ftid/sdk-web"
            },
            "version": {
              "type": "string",
              "maxLength": 64,
              "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(?:-[A-Za-z0-9.-]+)?$"
            },
            "sha256": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "sha512": {
              "type": "string",
              "pattern": "^[0-9a-f]{128}$"
            }
          },
          "required": ["package_name", "version", "sha256", "sha512"],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ],
      "description": "The approved private Web SDK archive downloaded in the console (D84), or null when none is available."
    }
  },
  "required": [
    "schema_version",
    "generated_at",
    "api_origin",
    "documentation",
    "request_profile",
    "secret",
    "application",
    "collection",
    "server_credentials",
    "sdk_package"
  ],
  "additionalProperties": false
}
