{
  "openapi": "3.0.3",
  "info": {
    "title": "SignApi",
    "version": "1.0.0",
    "description": "Linux QQ NT 签名服务，离线纯计算。两代算法不通用：46494 出 64 hex 字符（32 B），53644 出 96 个（48 B）；未命中版本拒绝签名。"
  },
  "servers": [{ "url": "/" }],
  "paths": {
    "/api/sign/sec-sign": {
      "post": {
        "operationId": "secSign",
        "summary": "生成 sec_sign",
        "security": [{ "bearerAuth": [] }, {}],
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": { "$ref": "#/components/schemas/SecSignRequest" } } }
        },
        "responses": {
          "200": { "description": "成功", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/SecSignResponse" } } } },
          "400": { "$ref": "#/components/responses/Err" },
          "401": { "$ref": "#/components/responses/Err" },
          "405": { "$ref": "#/components/responses/Err" }
        }
      }
    },
    "/46494/api/sign/sec-sign": { "$ref": "#/paths/~1api~1sign~1sec-sign" },
    "/53644/api/sign/sec-sign": { "$ref": "#/paths/~1api~1sign~1sec-sign" },
    "/healthz": {
      "get": {
        "operationId": "healthz",
        "summary": "存活探测（不鉴权）",
        "responses": { "200": { "description": "正常", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Health" } } } } }
      }
    },
    "/openapi.json": {
      "get": {
        "operationId": "openapi",
        "summary": "本接口文档（不鉴权）",
        "responses": { "200": { "description": "OpenAPI 3.0 文档" } }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": { "type": "http", "scheme": "bearer", "description": "配了 -token 白名单时必填（Authorization: Bearer <token>）；未配置则放行全部" }
    },
    "responses": {
      "Err": {
        "description": "400 请求非法/未知版本/签名失败（1、3、4）· 401 鉴权失败（2）· 405 非 POST",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } }
      }
    },
    "schemas": {
      "SecSignRequest": {
        "type": "object",
        "required": ["body", "guid"],
        "properties": {
          "body": { "type": "string", "description": "hex 载荷，上限 16 MiB" },
          "guid": { "type": "string", "pattern": "^[0-9a-fA-F]{32}$", "description": "设备 ID，hex32；46494 强依赖" },
          "qua": { "type": "string", "description": "版本路由依据，如 V1_LNX_NQ_3.2.34_53644_GW_B；走 /<版本>/ 前缀时可省" },
          "token": { "type": "string", "description": "hex 会话凭证；46494 登录态必传" },
          "extra": { "type": "string", "description": "hex SecExtra；缺省用内置值" },
          "command": { "oneOf": [{ "type": "integer" }, { "type": "string" }], "description": "仅用于日志，不参与签名" },
          "us": { "type": "integer", "format": "int64", "description": "微秒时间戳；0/缺省用当前时钟" },
          "t": { "type": "integer", "format": "int64", "description": "秒时间戳；0/缺省用当前时钟" },
          "uin": { "description": "服务端不读" },
          "seq": { "description": "服务端不读" }
        }
      },
      "SecSignResponse": {
        "type": "object",
        "required": ["code", "message", "value"],
        "properties": {
          "code": { "type": "integer", "enum": [0] },
          "message": { "type": "string", "enum": ["success"] },
          "value": {
            "type": "object",
            "required": ["sec_sign", "sec_token", "sec_extra"],
            "properties": {
              "sec_sign": { "type": "string", "description": "hex：46494 64 字符，53644 96 字符" },
              "sec_token": { "type": "string", "description": "hex；未传 token 时为空串（非 null）" },
              "sec_extra": { "type": "string", "description": "hex：0x12 0x1b 后接 27 字节 QUA" }
            }
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": ["code", "message", "value"],
        "properties": {
          "code": { "type": "integer", "enum": [0, 1, 2, 3, 4], "description": "0 成功 · 1 请求非法 · 2 鉴权失败 · 3 未知版本 · 4 签名失败" },
          "message": { "type": "string", "description": "与日志 ERROR 行正文同串" },
          "value": { "nullable": true, "description": "恒为 null" }
        }
      },
      "Health": {
        "type": "object",
        "properties": {
          "status": { "type": "string", "enum": ["ok"] },
          "lines": { "type": "array", "items": { "type": "string" } }
        }
      }
    }
  },
  "x-signapi-errors": ["服务出错：<err>", "路由出错：未找到 <path>", "路由出错：未知版本 \"<qua>\"", "请求出错：非 POST", "鉴权出错：非白名单", "解析出错：<err>", "Body 出错：非法字段", "签名出错：<err>"]
}
