mirror of
https://github.com/aljazceru/pubky-core.git
synced 2026-01-22 23:44:21 +01:00
chore(pubky): remove unused
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
#![allow(unused)]
|
||||
|
||||
mod error;
|
||||
mod shared;
|
||||
|
||||
|
||||
@@ -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) {}
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use reqwest::{Method, Response, StatusCode};
|
||||
use reqwest::Method;
|
||||
use url::Url;
|
||||
|
||||
use crate::{error::Result, PubkyClient};
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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<T: TryInto<Url>>(&self, url: T) -> Result<Url> {
|
||||
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<String> {
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user