cpclient is a simplified ffi api interface to a cypherpost server.
It handles all the complex cryptographic tasks and post segregation for clients.
Stringified JSON is used as IO.
struct S5Error{
code: u32, // HTTP STATUS CODES
message: String
}
genesis_filter
is a common field among calls that return large vector of objects.
They can be filtered by providing this field, which will only return entries made after a certain timestamp. Default is set to 0 if no value is passed.
Use a socks5 port to a local tor instance. Use 0 if communicating over clearnet.
master_root: String,
account: int,
struct SocialRoot {
social_root: String,
}
hostname: String,
socks5: int,
social_root: String,
struct ServerIdentity{
kind: String,
name: String,
}
hostname: String,
socks5: int,
social_root: String,
struct Members{
identities:Vec<Member>,
}
Member {
username: String,
pubkey: String,
}
Only applicable for an admin with a secret.
kind must be either "priv/privileged", all other string values will default to "standard".
count sets how many users a privileged user can invite. Use 0 for standard invitations.
hostname: String,
socks5: int,
admin_secret: String,
kind: String,
count: int,
struct Invitation{
invite_code: String,
}
Only applicable to privileged users created by the admin.
hostname: String,
socks5: int,
social_root: String,
invite_code: String,
The resulting invite_code
will be a standard kind, which cannot be used to invite other users.
struct Invitation{
invite_code: String,
}
hostname: String,
socks5: int,
social_root: String,
username: String,
struct ServerStatusResponse{
status: bool
}
hostname: String,
socks5: int,
social_root: String,
genesis_filter: int,
struct AllBadges{
badges: Vec<Badge>,
}
struct Badge{
genesis: String,
kind: AnnouncementKind,
by: String,
to : String,
nonce: String,
signature: String,
hash: String,
}
AnnouncementKind{
"Trust",
"Scam",
}
hostname: String,
socks5: int,
social_root: String,
to: String,
kind: AnnouncementKind,
struct ServerResponseStatus {
status: bool,
}
Users must keep track of the last used index to maintain forward secrecy. The server also keeps track of it, but this should only be used in case of recovery.
to
semi-colon separated kind:value
where kind is either "direct" where value is a pubkey OR "group" where value is a group id.
payload
semi-colon separated kind:value
where kind is either "message" where value is a message OR "secret" where value is a hash.
hostname: String,
socks5: int,
social_root: String,
index: int,
to: String,
payload: String,
}
struct PostId{
id: String,
}
Use the same index
used when sending the related post.
recipients
comma separated list of pubkeys who can view the post (for whome to make keys).
hostname: String,
socks5: int,
social_root: String,
index: int,
recipients: String,
}
struct ServerResponseStatus{
status: bool,
}
Get a single post by id. To be used as notification stream provides post_ids.
hostname: String,
socks5: int,
social_root: String,
post_id: int,
struct LocalPostModel{
id: String,
genesis: u64,
expiry: u64,
owner: String,
post: Post,
}
struct Post{
to: Recipient,
payload: Payload,
checksum: String,
signature: String,
}
struct Recipient{
kind: RecipientKind,
value: String, //pubkey for direct, gid for group
}
enum RecipientKind{
Direct,
Group,
}
struct Payload{
kind: PayloadKind,
value: String,
}
enum PayloadKind{
Message,
Secret,
}
Returns all posts for a user, organized as ChatHistory
hostname: String,
socks5: int,
social_root: String,
genesis_filter: int,
struct SortedPosts{
verified: Vec<PostsAsChat>,
corrupted: Vec<String>, // list of post_ids (where checksum verify invalid <soon + decryption failed>)
latest_genesis: u64, // use as genesis filter and index with every new added single post
}
struct PostsAsChat{
counter_party: String,
posts: Vec<LocalPostModel>
}
hostname: String,
socks5: int,
social_root: String,
struct LastIndex {
last_index: u32,
}
Removes an identity and all associated badges and posts.
{
hostname: String,
socks5: int,
social_root: String,
}
struct ServerStatusResponse{
status: bool,
}
The notification stream api must be handled by the client. To help with this use the following helper functions:
{
social_root: String,
}
{
pubkey: String,
nonce: String,
signature: String
}
Ensure that dto.rs
tests and lib.rs
use #[ignore] unless you have a local cypherpost server running or tests will fail.
Run tests on a single thread or you will face errors because dto test entries will effects lib.rs test entries.
cargo test -- --test-threads=1