Tham chiếu API

Pairing

Ghép nối thiết bị này với một peer được khám phá để hai thiết bị có thể trao đổi tin nhắn chat mã hóa và tệp qua LAN / Wi-Fi Aware. Ghép nối phải được xác nhận ở cả hai phía — gọi pairDevice tại đây, sau đó yêu cầu thiết bị từ xa gọi respondToPairing.

Định nghĩa kiểu

bash
input PairingDeviceInput {
  id: String!                 # remote device id (from discovery)
  name: String!               # remote display name
  ips: [String!]              # known IP addresses
  port: Int!                  # remote HTTP port
  deviceType: DeviceType!     # PHONE | TABLET | DESKTOP | WEB | ...
  version: String!
  platform: String!
  lastSeen: String!           # ISO 8601
  discoveryMethods: [String!] # LAN | AWARE | BLE | ...
}

input PairingRequestInput {
  fromId: String!
  fromName: String!
  port: Int!
  deviceType: DeviceType!
  ecdhPublicKey: String!      # base64 ECDH public key for key exchange
  signaturePublicKey: String! # base64 Ed25519 signing key
  timestamp: Long!            # request creation time (millis)
  ips: [String!]
  signature: String           # signature over the request body
  fromIp: String
  isQrInitiated: Boolean      # true when triggered by QR scan
  awareSupported: Boolean     # remote supports Wi-Fi Aware
}

enum DeviceType { PHONE TABLET DESKTOP WEB OTHER }

Thao tác

mutation

pairDevice

Khởi tạo ghép nối với một thiết bị LAN được khám phá. Gửi yêu cầu ghép nối đến thiết bị từ xa; thiết bị từ xa phải chấp nhận qua respondToPairing trước khi kênh bảo mật được thiết lập.

bash
mutation PairDevice($input: PairingDeviceInput!) {
  pairDevice(input: $input)
}
mutation

cancelPairing

Hủy một ghép nối đang tiến hành được khởi tạo bởi thiết bị này. Truyền deviceId từ xa được trả về bởi quét khám phá.

bash
mutation CancelPairing($deviceId: String!) {
  cancelPairing(deviceId: $deviceId)
}
mutation

respondToPairing

Phản hồi một yêu cầu ghép nối đến — chấp nhận (true) hoặc từ chối (false). Khi chấp nhận, thiết bị dẫn xuất khóa ECDH dùng chung và đăng ký peer cho chat mã hóa.

bash
mutation RespondToPairing($input: PairingRequestInput!, $accepted: Boolean!) {
  respondToPairing(input: $input, accepted: $accepted)
}