diff --git a/pubky/src/lib.rs b/pubky/src/lib.rs index 241e3ed..2b6cf42 100644 --- a/pubky/src/lib.rs +++ b/pubky/src/lib.rs @@ -1,5 +1,3 @@ -#![allow(unused)] - mod error; mod shared; diff --git a/pubky/src/native.rs b/pubky/src/native.rs index 6f9f676..0ca2d7c 100644 --- a/pubky/src/native.rs +++ b/pubky/src/native.rs @@ -7,7 +7,7 @@ use ::pkarr::{ use bytes::Bytes; use pkarr::Keypair; use pubky_common::session::Session; -use reqwest::{Method, RequestBuilder, Response}; +use reqwest::{RequestBuilder, Response}; use url::Url; use crate::{ @@ -150,6 +150,6 @@ impl PubkyClient { self.http.request(method, url) } - pub(crate) fn store_session(&self, response: Response) {} - pub(crate) fn remove_session(&self, pubky: &PublicKey) {} + pub(crate) fn store_session(&self, _: Response) {} + pub(crate) fn remove_session(&self, _: &PublicKey) {} } diff --git a/pubky/src/shared/auth.rs b/pubky/src/shared/auth.rs index 0ee15a6..d4a6436 100644 --- a/pubky/src/shared/auth.rs +++ b/pubky/src/shared/auth.rs @@ -2,12 +2,8 @@ use reqwest::{Method, StatusCode}; use pkarr::{Keypair, PublicKey}; use pubky_common::{auth::AuthnSignature, session::Session}; -use url::Url; -use crate::{ - error::{Error, Result}, - PubkyClient, -}; +use crate::{error::Result, PubkyClient}; use super::pkarr::Endpoint; @@ -75,10 +71,7 @@ impl PubkyClient { /// Signout from a homeserver. pub(crate) async fn inner_signout(&self, pubky: &PublicKey) -> Result<()> { - let Endpoint { - public_key, - mut url, - } = self.resolve_pubky_homeserver(pubky).await?; + let Endpoint { mut url, .. } = self.resolve_pubky_homeserver(pubky).await?; url.set_path(&format!("/{}/session", pubky)); @@ -115,14 +108,11 @@ impl PubkyClient { #[cfg(test)] mod tests { - use std::time::Duration; - use crate::*; use pkarr::{mainline::Testnet, Keypair}; use pubky_common::session::Session; use pubky_homeserver::Homeserver; - use tokio::time::sleep; #[tokio::test] async fn basic_authn() { diff --git a/pubky/src/shared/list_builder.rs b/pubky/src/shared/list_builder.rs index 601f71d..0eaec77 100644 --- a/pubky/src/shared/list_builder.rs +++ b/pubky/src/shared/list_builder.rs @@ -1,4 +1,4 @@ -use reqwest::{Method, Response, StatusCode}; +use reqwest::Method; use url::Url; use crate::{error::Result, PubkyClient}; diff --git a/pubky/src/shared/pkarr.rs b/pubky/src/shared/pkarr.rs index f615de0..01cd0fb 100644 --- a/pubky/src/shared/pkarr.rs +++ b/pubky/src/shared/pkarr.rs @@ -1,4 +1,4 @@ -use url::{Origin, Url}; +use url::Url; use pkarr::{ dns::{rdata::SVCB, Packet}, @@ -128,7 +128,7 @@ impl PubkyClient { } if let Some(public_key) = homeserver_public_key { - let mut url = Url::parse(&format!( + let url = Url::parse(&format!( "{}://{}", if origin.starts_with("localhost") { "http" @@ -156,7 +156,7 @@ mod tests { use pkarr::{ dns::{rdata::SVCB, Packet}, - mainline::{dht::DhtSettings, Dht, Testnet}, + mainline::{dht::DhtSettings, Testnet}, Keypair, PkarrClient, Settings, SignedPacket, }; use pubky_homeserver::Homeserver; @@ -183,7 +183,7 @@ mod tests { let server_tld = server.public_key().to_string(); - let mut svcb = SVCB::new(0, server_tld.as_str().try_into().unwrap()); + let svcb = SVCB::new(0, server_tld.as_str().try_into().unwrap()); packet.answers.push(pkarr::dns::ResourceRecord::new( "pubky".try_into().unwrap(), diff --git a/pubky/src/shared/public.rs b/pubky/src/shared/public.rs index 82bfbd8..7dbb18e 100644 --- a/pubky/src/shared/public.rs +++ b/pubky/src/shared/public.rs @@ -1,7 +1,7 @@ use bytes::Bytes; use pkarr::PublicKey; -use reqwest::{Method, Response, StatusCode}; +use reqwest::{Method, StatusCode}; use url::Url; use crate::{ @@ -61,7 +61,7 @@ impl PubkyClient { } pub(crate) async fn pubky_to_http>(&self, url: T) -> Result { - let mut original_url: Url = url.try_into().map_err(|_| Error::InvalidUrl)?; + let original_url: Url = url.try_into().map_err(|_| Error::InvalidUrl)?; if original_url.scheme() != "pubky" { return Ok(original_url); @@ -92,21 +92,6 @@ impl PubkyClient { } } -fn normalize_path(path: &str) -> Result { - let mut path = path.to_string(); - - if path.starts_with('/') { - path = path[1..].to_string() - } - - // TODO: should we return error instead? - if path.ends_with('/') { - path = path[..path.len()].to_string() - } - - Ok(path) -} - #[cfg(test)] mod tests { @@ -177,7 +162,7 @@ mod tests { Err(Error::Reqwest(error)) => { assert!(error.status() == Some(StatusCode::UNAUTHORIZED)) } - error => { + _ => { panic!("expected error StatusCode::UNAUTHORIZED") } } @@ -200,7 +185,7 @@ mod tests { Err(Error::Reqwest(error)) => { assert!(error.status() == Some(StatusCode::UNAUTHORIZED)) } - error => { + _ => { panic!("expected error StatusCode::UNAUTHORIZED") } } diff --git a/pubky/src/shared/recovery_file.rs b/pubky/src/shared/recovery_file.rs index 5f500ff..9fff885 100644 --- a/pubky/src/shared/recovery_file.rs +++ b/pubky/src/shared/recovery_file.rs @@ -2,10 +2,7 @@ use argon2::Argon2; use pkarr::Keypair; use pubky_common::crypto::{decrypt, encrypt}; -use crate::{ - error::{Error, Result}, - PubkyClient, -}; +use crate::error::{Error, Result}; static SPEC_NAME: &str = "recovery"; static SPEC_LINE: &str = "pubky.org/recovery"; @@ -68,6 +65,8 @@ fn recovery_file_encryption_key_from_passphrase(passphrase: &str) -> Result<[u8; mod tests { use super::*; + use crate::PubkyClient; + #[test] fn encrypt_decrypt_recovery_file() { let passphrase = "very secure password";