diff --git a/pubky/src/client.rs b/pubky/src/client.rs index 95742df..63fae96 100644 --- a/pubky/src/client.rs +++ b/pubky/src/client.rs @@ -7,10 +7,10 @@ use std::{collections::HashMap, fmt::format, time::Duration}; use ureq::{Agent, Response}; use url::Url; -use crate::error::{Error, Result}; - use pkarr::{DhtSettings, PkarrClient, Settings, Testnet}; +use crate::error::{Error, Result}; + #[derive(Debug, Clone)] pub struct PubkyClient { agent: Agent, @@ -40,8 +40,6 @@ impl PubkyClient { } } - // === Public Methods === - // === Private Methods === fn request(&self, method: HttpMethod, url: &Url) -> ureq::Request { diff --git a/pubky/src/client/auth.rs b/pubky/src/client/auth.rs index 8445640..a9f3da1 100644 --- a/pubky/src/client/auth.rs +++ b/pubky/src/client/auth.rs @@ -1,9 +1,8 @@ -use crate::PubkyClient; +use pkarr::{Keypair, PublicKey}; use pubky_common::{auth::AuthnSignature, session::Session}; -use super::{Error, HttpMethod, Result}; -use pkarr::{Keypair, PublicKey}; +use super::{Error, HttpMethod, PubkyClient, Result}; impl PubkyClient { /// Signup to a homeserver and update Pkarr accordingly. diff --git a/pubky/src/client/public.rs b/pubky/src/client/public.rs index b54cd21..68b8209 100644 --- a/pubky/src/client/public.rs +++ b/pubky/src/client/public.rs @@ -2,9 +2,7 @@ use bytes::Bytes; use pkarr::PublicKey; -use crate::PubkyClient; - -use super::Result; +use super::{PubkyClient, Result}; impl PubkyClient { pub fn put(&self, pubky: &PublicKey, path: &str, content: &[u8]) -> Result<()> { diff --git a/pubky/src/client_async.rs b/pubky/src/client_async.rs index 2fb7bd5..6fa063e 100644 --- a/pubky/src/client_async.rs +++ b/pubky/src/client_async.rs @@ -5,7 +5,7 @@ use bytes::Bytes; use pkarr::{Keypair, PublicKey}; use pubky_common::session::Session; -use crate::{error::Result, PubkyClient}; +use crate::{client::PubkyClient, error::Result}; pub struct PubkyClientAsync(PubkyClient); diff --git a/pubky/src/lib.rs b/pubky/src/lib.rs index 39955c4..87c535d 100644 --- a/pubky/src/lib.rs +++ b/pubky/src/lib.rs @@ -14,18 +14,21 @@ macro_rules! if_wasm { )*} } -mod error; -pub use error::Error; - if_not_wasm! { mod client; mod client_async; - pub use client::PubkyClient; + use pkarr::{PkarrClient}; + use ureq::{Agent, Response}; + use url::Url; } if_wasm! { mod wasm; - pub use wasm::{PubkyClient, Keypair}; + pub use wasm::keys::Keypair; + pub use wasm::PubkyClient; } + +mod error; +pub use error::Error; diff --git a/pubky/src/wasm.rs b/pubky/src/wasm.rs index 9610160..a5589d3 100644 --- a/pubky/src/wasm.rs +++ b/pubky/src/wasm.rs @@ -1,6 +1,10 @@ -mod client; -mod keys; -mod pkarr; +use wasm_bindgen::prelude::*; -pub use client::PubkyClient; -pub use keys::Keypair; +pub mod auth; +pub mod keys; +pub mod pkarr; + +#[wasm_bindgen] +pub struct PubkyClient { + pub(crate) pkarr: pkarr::PkarrRelayClient, +} diff --git a/pubky/src/wasm/client.rs b/pubky/src/wasm/auth.rs similarity index 93% rename from pubky/src/wasm/client.rs rename to pubky/src/wasm/auth.rs index e692cb8..e8bc842 100644 --- a/pubky/src/wasm/client.rs +++ b/pubky/src/wasm/auth.rs @@ -4,15 +4,7 @@ use web_sys::RequestMode; use pkarr::PkarrRelayClient; -use super::Keypair; - -#[wasm_bindgen] -pub struct Error {} - -#[wasm_bindgen] -pub struct PubkyClient { - pub(crate) pkarr: PkarrRelayClient, -} +use super::{keys::Keypair, PubkyClient}; #[wasm_bindgen] impl PubkyClient { diff --git a/pubky/src/wasm/pkarr.rs b/pubky/src/wasm/pkarr.rs index 81a5685..97d39a1 100644 --- a/pubky/src/wasm/pkarr.rs +++ b/pubky/src/wasm/pkarr.rs @@ -2,7 +2,7 @@ use wasm_bindgen::prelude::*; pub use pkarr::{ dns::{rdata::SVCB, Packet}, - Keypair, PublicKey, SignedPacket, + Keypair, PkarrRelayClient, PublicKey, SignedPacket, }; use crate::error::Result;