{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://fdc3.finos.org/schemas/2.1/bridging/connectionStep3Handshake.schema.json",
  "title": "ConnectionStep3Handshake",
  "type": "object",
  "allOf": [
    {
      "$ref": "#/$defs/ConnectionStep3HandshakeBase"
    },
    {
      "$ref": "connectionStep.schema.json"
    }
  ],
  "$defs": {
    "ConnectionStep3HandshakeBase": {
      "type":"object",
      "title": "ConnectionStep3Handshake",
      "description": "Handshake message sent by the Desktop Agent to the Bridge (including requested name, channel state and authentication data)",
      "properties": {
        "type": {
          "title": "Connection Step 3 Message Type",
          "const": "handshake"
        },
        "payload": {
          "title": "Connection Step 3 Payload",
          "type": "object",
          "properties": {
            "implementationMetadata": {
              "title": "Desktop Agent ImplementationMetadata",
              "description": "Desktop Agent ImplementationMetadata trying to connect to the bridge.",
              "$ref": "../api/baseImplementationMetadata.schema.json"
            },
            "requestedName": {
              "title": "Requested name",
              "description": "The requested Desktop Agent name",
              "type": "string"
            },
            "channelsState": {
              "title": "Channel State",
              "type": "object",
              "description": "The current state of the Desktop Agent's channels, excluding any private channels, as a mapping of channel id to an array of Context objects, most recent first.",
              "additionalProperties": {
                "title": "Channel ",
                "type": "array",
                  "items": {
                    "$ref": "../context/context.schema.json"
                  }
              }
            },
            "authToken": {
              "title": "Authentication Token",
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": ["implementationMetadata", "requestedName", "channelsState"]
        },
        "meta": {
          "title": "Connection Step 3 Metadata",
          "type": "object",
          "properties": {
            "requestUuid": {
              "$ref": "common.schema.json#/$defs/RequestUuid"
            },
            "timestamp": {
              "$ref": "common.schema.json#/$defs/Timestamp"
            }
          },
          "additionalProperties": false,
          "required": ["requestUuid", "timestamp"]
        }
      },
      "required": ["type", "payload", "meta"],
      "additionalProperties": false
    }
  }
}