aboutsummaryrefslogtreecommitdiffstats
path: root/atuin-client/src/api_client.rs
diff options
context:
space:
mode:
authorConrad Ludgate <conradludgate@gmail.com>2023-06-21 08:45:23 +0100
committerGitHub <noreply@github.com>2023-06-21 08:45:23 +0100
commita75e516986ab2ba8b0997dd93271b58fa1986637 (patch)
tree7f624df14403a3bbfe889247e1a2f989981452d1 /atuin-client/src/api_client.rs
parentAdd RecordIndex data structure (#1059) (diff)
downloadatuin-a75e516986ab2ba8b0997dd93271b58fa1986637.zip
remove decryption from api-client (#1063)
Diffstat (limited to '')
-rw-r--r--atuin-client/src/api_client.rs33
1 files changed, 3 insertions, 30 deletions
diff --git a/atuin-client/src/api_client.rs b/atuin-client/src/api_client.rs
index 2510d197..350c419d 100644
--- a/atuin-client/src/api_client.rs
+++ b/atuin-client/src/api_client.rs
@@ -1,5 +1,4 @@
use std::collections::HashMap;
-use std::collections::HashSet;
use std::env;
use chrono::Utc;
@@ -14,22 +13,13 @@ use atuin_common::api::{
LoginRequest, LoginResponse, RegisterResponse, StatusResponse, SyncHistoryResponse,
};
use semver::Version;
-use xsalsa20poly1305::Key;
-use crate::{
- encryption::{decode_key, decrypt},
- history::History,
- sync::hash_str,
-};
+use crate::{history::History, sync::hash_str};
static APP_USER_AGENT: &str = concat!("atuin/", env!("CARGO_PKG_VERSION"),);
-// TODO: remove all references to the encryption key from this
-// It should be handled *elsewhere*
-
pub struct Client<'a> {
sync_addr: &'a str,
- key: Key,
client: reqwest::Client,
}
@@ -111,13 +101,12 @@ pub async fn latest_version() -> Result<Version> {
}
impl<'a> Client<'a> {
- pub fn new(sync_addr: &'a str, session_token: &'a str, key: String) -> Result<Self> {
+ pub fn new(sync_addr: &'a str, session_token: &'a str) -> Result<Self> {
let mut headers = HeaderMap::new();
headers.insert(AUTHORIZATION, format!("Token {session_token}").parse()?);
Ok(Client {
sync_addr,
- key: decode_key(key)?,
client: reqwest::Client::builder()
.user_agent(APP_USER_AGENT)
.default_headers(headers)
@@ -160,8 +149,7 @@ impl<'a> Client<'a> {
sync_ts: chrono::DateTime<Utc>,
history_ts: chrono::DateTime<Utc>,
host: Option<String>,
- deleted: HashSet<String>,
- ) -> Result<Vec<History>> {
+ ) -> Result<SyncHistoryResponse> {
let host = host.unwrap_or_else(|| {
hash_str(&format!(
"{}:{}",
@@ -181,21 +169,6 @@ impl<'a> Client<'a> {
let resp = self.client.get(url).send().await?;
let history = resp.json::<SyncHistoryResponse>().await?;
- let history = history
- .history
- .iter()
- // TODO: handle deletion earlier in this chain
- .map(|h| serde_json::from_str(h).expect("invalid base64"))
- .map(|h| decrypt(h, &self.key).expect("failed to decrypt history! check your key"))
- .map(|mut h| {
- if deleted.contains(&h.id) {
- h.deleted_at = Some(chrono::Utc::now());
- h.command = String::from("");
- }
-
- h
- })
- .collect();
Ok(history)
}