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
取消由本裝置發起的進行中的配對。傳入發現掃描傳回的遠端 deviceId。
bash
mutation CancelPairing($deviceId: String!) {
cancelPairing(deviceId: $deviceId)
}mutation
respondToPairing
回應傳入的配對請求——接受(true)或拒絕(false)。接受時,裝置衍生共享 ECDH 金鑰並註冊 peer 以進行加密聊天。
bash
mutation RespondToPairing($input: PairingRequestInput!, $accepted: Boolean!) {
respondToPairing(input: $input, accepted: $accepted)
}