From 1f73b72371f6417fc42257eb10aa0cdd0fdc2418 Mon Sep 17 00:00:00 2001 From: nazeh Date: Sun, 22 Sep 2024 18:33:47 +0300 Subject: [PATCH] refactor(pubky): remove unused session_cookies in PubkyClient --- pubky/src/lib.rs | 8 -------- pubky/src/wasm.rs | 7 ------- pubky/src/wasm/internals/http.rs | 8 +------- 3 files changed, 1 insertion(+), 22 deletions(-) diff --git a/pubky/src/lib.rs b/pubky/src/lib.rs index 9e22a3b..56caada 100644 --- a/pubky/src/lib.rs +++ b/pubky/src/lib.rs @@ -6,11 +6,6 @@ mod native; #[cfg(target_arch = "wasm32")] mod wasm; -#[cfg(target_arch = "wasm32")] -use std::{ - collections::HashSet, - sync::{Arc, RwLock}, -}; use wasm_bindgen::prelude::*; @@ -25,9 +20,6 @@ pub struct PubkyClient { http: reqwest::Client, #[cfg(not(target_arch = "wasm32"))] pub(crate) pkarr: pkarr::Client, - /// A cookie jar for nodejs fetch. - #[cfg(target_arch = "wasm32")] - pub(crate) session_cookies: Arc>>, #[cfg(target_arch = "wasm32")] pub(crate) pkarr_relays: Vec, } diff --git a/pubky/src/wasm.rs b/pubky/src/wasm.rs index be36a0e..7cda1c5 100644 --- a/pubky/src/wasm.rs +++ b/pubky/src/wasm.rs @@ -1,8 +1,3 @@ -use std::{ - collections::HashSet, - sync::{Arc, RwLock}, -}; - use wasm_bindgen::prelude::*; use crate::PubkyClient; @@ -26,7 +21,6 @@ impl PubkyClient { pub fn new() -> Self { Self { http: reqwest::Client::builder().build().unwrap(), - session_cookies: Arc::new(RwLock::new(HashSet::new())), pkarr_relays: DEFAULT_RELAYS.into_iter().map(|s| s.to_string()).collect(), } } @@ -37,7 +31,6 @@ impl PubkyClient { pub fn testnet() -> Self { Self { http: reqwest::Client::builder().build().unwrap(), - session_cookies: Arc::new(RwLock::new(HashSet::new())), pkarr_relays: TESTNET_RELAYS.into_iter().map(|s| s.to_string()).collect(), } } diff --git a/pubky/src/wasm/internals/http.rs b/pubky/src/wasm/internals/http.rs index 83c7821..6973130 100644 --- a/pubky/src/wasm/internals/http.rs +++ b/pubky/src/wasm/internals/http.rs @@ -5,12 +5,6 @@ use url::Url; impl PubkyClient { pub(crate) fn inner_request(&self, method: Method, url: Url) -> RequestBuilder { - let mut request = self.http.request(method, url).fetch_credentials_include(); - - for cookie in self.session_cookies.read().unwrap().iter() { - request = request.header("Cookie", cookie); - } - - request + self.http.request(method, url).fetch_credentials_include() } }