API রেফারেন্স

পিয়ার GraphQL

পেয়ার করা ডিভাইসগুলোর মধ্যে স্বাক্ষরিত ও এনক্রিপ্ট করা অনুরোধ।

key = Base64Decode(peer.key)জোড়া লাগানো পিয়ার; c-id = senderClientId

ক্লায়েন্ট
https://<host>:<port>/peer_graphql
সার্ভার

POST /peer_graphql

c-id: 706c6169-3b80-8f42-9a61-4e312e54d001

HTTP · binary

JSON({ signature, requestId, query, variables })

অনুরোধ চালানোর আগে ডিভাইসের স্বাক্ষর যাচাই করুন। UUIDv7-এর গ্রহণযোগ্য সময়: ±60 সেকেন্ড, স্থায়ী পুনরাবৃত্তি বর্জনসহ।

XChaCha20-Poly1305 · ক্ষেত্রে মাউস রাখুন বা স্পর্শ করুন
1 / 2

রিপ্লে প্রতিরোধ

requestId = UUIDv7()JSON { signature, requestId, query, variables } → authenticated encryption
↓ POST /peer_graphql
প্রমাণীকরণ ও ডিক্রিপ্ট করুনpeer.key / channel.key + Ed25519✕ → প্রত্যাখ্যান করুন
↓
UUIDv7-এর সময় যাচাই করুন|serverTime − requestId timestamp| ≤ 60 s✕ → প্রত্যাখ্যান করুন
↓
চালানোর আগে requestId সংরক্ষণ করুনSQLite: peer_graphql:channelId + senderClientId + requestId
✓ ↓GraphQL চালান
✕ ↓পুনর্ব্যবহৃত requestId প্রত্যাখ্যান করুন
লাইব্রেরি কল

Core-এর অংশ, সরাসরি জোড়া লাগানো পিয়ার মোড (c-cid ছাড়া)।

text
// plain-rs/src/infrastructure/transport/contract.rs
let payload = contract::signed_request(&signing_keypair, query, variables, "")?;
let request_body = http_request::encrypt_raw(
    &peer_key, "POST", "/peer_graphql", payload.as_bytes(),
).ok_or("encrypt failed")?;
let response = transport.post(url, &client_id, None, &request_body).await?;
let plaintext = http_response::Context::new(&request_body)
    .decrypt(&peer_key, &response).ok_or("invalid response")?;

HTTP 403: পিয়ার জোড়া লাগানো নয়। 401: অজানা পিয়ার, ডিক্রিপশন বা স্বাক্ষর ব্যর্থ। 400: ভুল বিন্যাসের, মেয়াদোত্তীর্ণ বা পুনরাবৃত্ত এনভেলপ।

টাইপ ডেফিনিশন

graphql
enum ChannelSystemMessageType {
	INVITE
	INVITE_ACCEPT
	INVITE_DECLINE
	UPDATE
	KICK
	LEAVE
}

type ChatAttachment {
	id: ID!
	uri: String!
	size: Long!
	durationMs: Long!
	width: Int!
	height: Int!
	summary: String!
	fileName: String!
}

enum ChatAttachmentType {
	IMAGE
	FILE
}

union ChatContent = ChatMessageContent | ChatShareContent

type ChatDeliveryResult {
	peerId: ID!
	peerName: String!
	error: String
}

type ChatItem {
	"""
	`me` when this device created the item, otherwise the client id of
	the originating peer.
	"""
	fromId: ID!
	"""
	Peer id for direct messages; empty for channel messages —
	`channelId` is authoritative there.
	"""
	toId: ID!
	"""
	Null for direct messages: the store keeps "" and the contract says
	null, because "" is not a channel a client can query.
	"""
	channelId: ID
	id: ID!
	content: ChatContent!
	createdAt: Instant!
	updatedAt: Instant!
	status: ChatStatus!
	deliveryResults: [ChatDeliveryResult!]!
}

type ChatLinkPreview {
	url: String!
	title: String
	description: String
	image: String
	imageWidth: Int!
	imageHeight: Int!
	siteName: String
	domain: String
	createdAt: Instant!
}

type ChatMessageAttachment {
	type: ChatAttachmentType!
	attachment: ChatAttachment!
}

type ChatMessageContent {
	text: String
	format: ChatTextFormat!
	items: [ChatMessageAttachment!]!
	linkPreviews: [ChatLinkPreview!]!
}

type ChatShareContent {
	shareId: ID!
	urlToken: String!
	peerInfo: ChatSharePeer!
	name: String!
	itemCount: Long!
	totalSize: Long!
	expiresAt: Instant
}

type ChatSharePeer {
	id: ID!
	ip: String!
	port: Int!
}

enum ChatStatus {
	SENT
	FAILED
	PARTIAL
	PENDING
}

enum ChatTextFormat {
	PLAIN
	MARKDOWN
}

scalar Instant

scalar Long

type Mutation {
	createChatItem(content: String!): [ChatItem!]!
	channelSystemMessage(type: ChannelSystemMessageType!, payload: String!): Boolean!
	startAware: Boolean!
}

enum PeerStatus {
	PAIRED
	UNPAIRED
	CHANNEL
}

type Query {
}

"""
Directs the executor to include this field or fragment only when the `if` argument is true.
"""
directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
"""
Directs the executor to skip this field or fragment when the `if` argument is true.
"""
directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
schema {
	query: Query
	mutation: Mutation
}