{
  "$id": "https://sessionpipe.org/schema/v1/control-paired.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "status": {
      "type": "string",
      "enum": [
        "pending",
        "paired",
        "expired"
      ]
    },
    "key": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 16,
              "maxLength": 1400,
              "pattern": "^[A-Za-z0-9_-]*$"
            },
            "alg": {
              "anyOf": [
                {
                  "type": "number",
                  "const": -7
                },
                {
                  "type": "number",
                  "const": -257
                }
              ]
            },
            "spki": {
              "type": "string",
              "minLength": 1,
              "pattern": "^[A-Za-z0-9_-]*$"
            }
          },
          "required": [
            "id",
            "alg",
            "spki"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{43}$"
            },
            "alg": {
              "type": "number",
              "const": -7
            },
            "spki": {
              "type": "string",
              "minLength": 1,
              "pattern": "^[A-Za-z0-9_-]*$"
            },
            "type": {
              "type": "string",
              "const": "device"
            },
            "store": {
              "type": "string",
              "const": "hardware"
            },
            "uv": {
              "type": "string",
              "const": "each-use"
            }
          },
          "required": [
            "id",
            "alg",
            "spki",
            "type",
            "store",
            "uv"
          ],
          "additionalProperties": false
        }
      ]
    },
    "proof": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "cred": {
              "type": "string",
              "minLength": 1,
              "pattern": "^[A-Za-z0-9_-]*$"
            },
            "ad": {
              "type": "string",
              "minLength": 1,
              "pattern": "^[A-Za-z0-9_-]*$"
            },
            "cd": {
              "type": "string",
              "minLength": 1,
              "pattern": "^[A-Za-z0-9_-]*$"
            },
            "sig": {
              "type": "string",
              "minLength": 1,
              "pattern": "^[A-Za-z0-9_-]*$"
            }
          },
          "required": [
            "cred",
            "ad",
            "cd",
            "sig"
          ]
        },
        {
          "type": "object",
          "properties": {
            "cred": {
              "type": "string",
              "minLength": 1,
              "pattern": "^[A-Za-z0-9_-]*$"
            },
            "sig": {
              "type": "string",
              "minLength": 1,
              "pattern": "^[A-Za-z0-9_-]*$"
            }
          },
          "required": [
            "cred",
            "sig"
          ],
          "additionalProperties": false
        }
      ]
    },
    "token": {
      "type": "string",
      "minLength": 16,
      "maxLength": 256
    },
    "sink_token": {
      "type": "string",
      "minLength": 16,
      "maxLength": 256
    },
    "account": {
      "type": "string",
      "maxLength": 200
    }
  },
  "required": [
    "status"
  ]
}
