Ghép đôi
Kiểm tra app.capabilities để biết tính năng và app.access cùng quyền máy chủ để xác định quyền truy cập. Thay giá trị mẫu trước khi gọi.
plainapp://pair?request=<URL-encoded JSON>QR
signature = Base64(Ed25519-Sign(Device A private key, signed))Ed25519-Verify(Device A public key, signed, Base64Decode(signature))Mở đoạn JSON để xem toàn bộ đầu vào được ký của ví dụ giả lập này; bên nhận xác minh bằng khóa công khai của bên ký.verificationCode = 73939800digest = SHA256(request.signature encoded as UTF-8)digest (hex) = ff44f60497bc235899f050f272165ec094a2f2c685e776d153a0711424b85dc0number = first 8 digest bytes as an unsigned big-endian integerverificationCode = number mod 100000000, padded to 8 decimal digitsQR: A hiển thị, B quét. c-id LAN xác định bên gửi; BLE dùng kênh truyền riêng. PAIR_CANCEL là tùy chọn.
Ảnh chụp giả lập tại thời điểm cố định; chữ ký và requestIds khớp. 192.0.2.0/24 dành riêng cho tài liệu. 8443 là cổng HTTPS mặc định; dùng cổng khám phá được trong yêu cầu thật. Các yêu cầu giới hạn thời gian này không thể phát lại nguyên dạng.
Trong PlainApp Desktop, trước khi quản lý thiết bị mới hoặc thiết bị đã đổi khóa công khai, hãy xác nhận rõ rằng bạn tin cậy thiết bị đó. Bước này không hiện mã đối chiếu và sẽ cảnh báo nếu khóa đã thay đổi. Nếu không dùng mật khẩu, hãy đối chiếu mã hiển thị trên cả hai thiết bị rồi mới chấp thuận trên thiết bị còn lại. Khi xác thực bằng mật khẩu, thiết bị còn lại vẫn có thể yêu cầu chấp thuận mà không hiện mã.
Định nghĩa kiểu
type Subscription {
peersChanged: Boolean!
pairingRequested: PairingRequestNotice!
pairingCompleted: PairingCompletedNotice!
pairingStarted: PairingProgressNotice!
pairingFailed: PairingProgressNotice!
pairingCanceled: PairingProgressNotice!
}
type Mutation {
cancelPairing(peerId: ID!): Boolean!
deletePeer(peerId: ID!): Boolean!
pairPeer(peerId: ID!, input: PairPeerInput!): Boolean!
respondToPairing(peerId: ID!, accepted: Boolean!): Boolean!
unpairPeer(peerId: ID!): Boolean!
}
type Query {
peerFileUrl(peerId: ID!, fileId: String!): String!
peers: [Peer!]!
}
enum DeviceType {
COMPUTER
PHONE
TABLET
TV
NAS
OTHER
}
scalar Instant
input PairPeerInput {
mode: PairingMode!
password: String
}
type PairingCompletedNotice {
deviceId: ID!
deviceName: String!
ip: String!
port: Int
deviceType: DeviceType
requestId: String
}
enum PairingErrorCode {
TIMEOUT
REJECTED
PASSWORD_REQUIRED
INVALID_PASSWORD
PEER_IDENTITY_CHANGED
TOO_MANY_LOGIN_ATTEMPTS
INTERNAL_ERROR
}
enum PairingMode {
CHAT
MANAGE
}
type PairingProgressNotice {
verificationCode: String
deviceId: ID!
deviceName: String!
error: PairingErrorCode
}
type PairingRequestNotice {
fromIp: String!
fromId: ID!
fromName: String!
deviceType: DeviceType!
verificationCode: String!
identityChanged: Boolean!
}
type Peer {
id: ID!
name: String!
ip: String!
status: PeerStatus!
port: Int
deviceType: DeviceType!
createdAt: Instant!
updatedAt: Instant!
online: Boolean!
managed: Boolean!
key: String!
publicKey: String!
token: String!
}
enum PeerStatus {
PAIRED
UNPAIRED
CHANNEL
}Thao tác
peersChanged
Nhận tín hiệu khi bản ghi thiết bị ngang hàng thay đổi.
subscription peersChanged {
peersChanged
}pairingRequested
Nhận yêu cầu ghép đôi đến đang chờ quyết định.
subscription pairingRequested {
pairingRequested { fromIp fromId fromName deviceType verificationCode identityChanged }
}pairingCompleted
Nhận thông báo ghép đôi thiết bị hoàn tất.
subscription pairingCompleted {
pairingCompleted { deviceId deviceName ip port deviceType requestId }
}pairingStarted
Nhận thông báo bắt đầu lần ghép đôi.
subscription pairingStarted {
pairingStarted { verificationCode deviceId deviceName error }
}pairingFailed
Nhận thông báo lần ghép đôi thất bại.
subscription pairingFailed {
pairingFailed { verificationCode deviceId deviceName error }
}pairingCanceled
Nhận thông báo lần ghép đôi bị hủy.
subscription pairingCanceled {
pairingCanceled { verificationCode deviceId deviceName error }
}cancelPairing
Hủy ghép nối đang diễn ra của thiết bị được chỉ định.
mutation cancelPairing($peerId: ID!) {
cancelPairing(peerId: $peerId)
}deletePeer
Xóa thiết bị và lịch sử trò chuyện riêng; giữ bản ghi nếu kênh vẫn tham chiếu đến thiết bị.
mutation deletePeer($peerId: ID!) {
deletePeer(peerId: $peerId)
}pairPeer
Bắt đầu ghép nối trò chuyện hoặc đăng nhập quản lý; true cho biết yêu cầu đã được tiếp nhận.
mutation pairPeer($peerId: ID!, $input: PairPeerInput!) {
pairPeer(peerId: $peerId, input: $input)
}respondToPairing
Chấp nhận hoặc từ chối yêu cầu ghép nối hay xác nhận tin cậy đang chờ của thiết bị.
mutation respondToPairing($peerId: ID!, $accepted: Boolean!) {
respondToPairing(peerId: $peerId, accepted: $accepted)
}unpairPeer
Hủy ghép nối cục bộ và xóa quyền quản lý, giữ lại lịch sử trò chuyện.
mutation unpairPeer($peerId: ID!) {
unpairPeer(peerId: $peerId)
}peerFileUrl
Tạo URL tải tệp bằng địa chỉ hiện được lưu của thiết bị.
query peerFileUrl($peerId: ID!, $fileId: String!) {
peerFileUrl(peerId: $peerId, fileId: $fileId)
}peers
Liệt kê mọi thiết bị đã lưu, gồm đã ghép nối, chưa ghép nối và chỉ được kênh tham chiếu.
query peers {
peers { id name ip status port deviceType createdAt updatedAt }
}