API संदर्भ

Pairing

इस डिवाइस को खोजे गए peer के साथ पेयर करें ताकि दोनों LAN / Wi-Fi Aware पर एन्क्रिप्टेड चैट संदेश और फ़ाइलें एक्सचेंज कर सकें। पेयरिंग दोनों पक्षों पर पुष्टि की जानी चाहिए — यहाँ pairDevice कॉल करें, फिर रिमोट डिवाइस को respondToPairing कॉल करने दें।

प्रकार परिभाषाएँ

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 }

ऑपरेशन

mutation

pairDevice

खोजे गए LAN डिवाइस के साथ पेयरिंग शुरू करें। रिमोट डिवाइस को पेयरिंग अनुरोध भेजता है; सुरक्षित चैनल स्थापित होने से पहले रिमोट डिवाइस को respondToPairing के माध्यम से स्वीकार करना होगा।

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

cancelPairing

इस डिवाइस द्वारा शुरू की गई चल रही पेयरिंग रद्द करें। discovery स्कैन द्वारा लौटाए गए रिमोट deviceId को पास करें।

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

respondToPairing

आने वाले पेयरिंग अनुरोध का उत्तर दें — स्वीकार (true) या अस्वीकार (false)। स्वीकार पर, डिवाइस साझा ECDH key निकालता है और एन्क्रिप्टेड चैट के लिए peer पंजीकृत करता है।

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