Pubky
Rust implementation of Pubky client.
Quick Start
use pubky_testnet::EphemeralTestnet;
use pubky::Keypair;
#[tokio::main]
async fn main () {
let testnet = EphemeralTestnet::start().await.unwrap();
let client = testnet.pubky_client_builder().build().unwrap();
let homeserver = testnet.homeserver_suite();
let keypair = Keypair::random();
let keypair = Keypair::random();
client.signup(&keypair, &homeserver.public_key(), None).await.unwrap();
let url = format!("pubky://{}/pub/foo.txt", keypair.public_key());
let url = url.as_str();
let data = [0, 1, 2, 3, 4].to_vec();
client.put(url).body(data.clone()).send().await.unwrap();
let response = client.get(url).send().await.unwrap();
let response_data = response.bytes().await.unwrap();
assert_eq!(response_data, data);
client.delete(url).send().await.unwrap();
let response = client.get(url).send().await.unwrap();
assert_eq!(response.status(), 404);
}
Example code
Check more examples for using the Pubky client.
JS bindings
Find a wrapper of this crate using wasm_bindgen in pubky-client/bindings/js