From aeaf57c748af0f0997e8da9dc86686a5a3b9848b Mon Sep 17 00:00:00 2001 From: Aaron Dewes Date: Fri, 28 Feb 2025 17:05:35 +0100 Subject: [PATCH] Update to base64 0.22.1 This is just simple dependency update to avoid people having duplicate (old) versions of base64 in their dependency tree if they use this crate --- jsonrpc/Cargo.toml | 2 +- jsonrpc/src/http/minreq_http.rs | 7 +++++-- jsonrpc/src/http/simple_http.rs | 7 +++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/jsonrpc/Cargo.toml b/jsonrpc/Cargo.toml index e51394b..98fc705 100644 --- a/jsonrpc/Cargo.toml +++ b/jsonrpc/Cargo.toml @@ -33,7 +33,7 @@ proxy = ["socks"] serde = { version = "1", features = ["derive"] } serde_json = { version = "1", features = [ "raw_value" ] } -base64 = { version = "0.13.0", optional = true } +base64 = { version = "0.22.1", optional = true } minreq = { version = "2.7.0", features = ["json-using-serde"], optional = true } socks = { version = "0.3.4", optional = true} diff --git a/jsonrpc/src/http/minreq_http.rs b/jsonrpc/src/http/minreq_http.rs index de1a5e1..1a96288 100644 --- a/jsonrpc/src/http/minreq_http.rs +++ b/jsonrpc/src/http/minreq_http.rs @@ -13,6 +13,9 @@ use std::{error, fmt}; use crate::client::Transport; use crate::{Request, Response}; +use base64::engine::general_purpose::STANDARD as BASE64; +use base64::Engine; + const DEFAULT_URL: &str = "http://localhost"; const DEFAULT_PORT: u16 = 8332; // the default RPC port for bitcoind. #[cfg(not(jsonrpc_fuzz))] @@ -123,7 +126,7 @@ impl Builder { if let Some(ref pass) = pass { s.push_str(pass.as_ref()); } - self.tp.basic_auth = Some(format!("Basic {}", &base64::encode(s.as_bytes()))); + self.tp.basic_auth = Some(format!("Basic {}", &BASE64.encode(s.as_bytes()))); self } @@ -144,7 +147,7 @@ impl Builder { /// let client = MinreqHttpTransport::builder().cookie_auth(cookie); /// ``` pub fn cookie_auth>(mut self, cookie: S) -> Self { - self.tp.basic_auth = Some(format!("Basic {}", &base64::encode(cookie.as_ref().as_bytes()))); + self.tp.basic_auth = Some(format!("Basic {}", &BASE64.encode(cookie.as_ref().as_bytes()))); self } diff --git a/jsonrpc/src/http/simple_http.rs b/jsonrpc/src/http/simple_http.rs index 75ad67b..86a615c 100644 --- a/jsonrpc/src/http/simple_http.rs +++ b/jsonrpc/src/http/simple_http.rs @@ -14,6 +14,9 @@ use std::sync::{Arc, Mutex, MutexGuard}; use std::time::Duration; use std::{error, fmt, io, net, num}; +use base64::engine::general_purpose::STANDARD as BASE64; +use base64::Engine; + #[cfg(feature = "proxy")] use socks::Socks5Stream; @@ -377,13 +380,13 @@ impl Builder { if let Some(ref pass) = pass { auth.push_str(pass.as_ref()); } - self.tp.basic_auth = Some(format!("Basic {}", &base64::encode(auth.as_bytes()))); + self.tp.basic_auth = Some(format!("Basic {}", &BASE64.encode(auth.as_bytes()))); self } /// Adds authentication information to the transport using a cookie string ('user:pass'). pub fn cookie_auth>(mut self, cookie: S) -> Self { - self.tp.basic_auth = Some(format!("Basic {}", &base64::encode(cookie.as_ref().as_bytes()))); + self.tp.basic_auth = Some(format!("Basic {}", &BASE64.encode(cookie.as_ref().as_bytes()))); self }