refactor(pubky): refactor modules

This commit is contained in:
nazeh
2024-07-26 21:10:19 +03:00
parent 42156b10f5
commit cdfd6c30ff
8 changed files with 25 additions and 31 deletions

View File

@@ -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 {

View File

@@ -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.

View File

@@ -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<()> {

View File

@@ -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);

View File

@@ -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;

View File

@@ -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,
}

View File

@@ -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 {

View File

@@ -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;