cargo fmt
This commit is contained in:
parent
eeded86641
commit
1a6ad62a2e
6 changed files with 72 additions and 26 deletions
|
@ -7,7 +7,7 @@ use std::fs::File;
|
|||
use std::io::{BufReader, Read, Write};
|
||||
use std::path::Path;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use steamguard::{SteamGuardAccount, ExposeSecret};
|
||||
use steamguard::{ExposeSecret, SteamGuardAccount};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
|
@ -169,7 +169,10 @@ impl Manifest {
|
|||
|
||||
pub fn add_account(&mut self, account: SteamGuardAccount) {
|
||||
debug!("adding account to manifest: {}", account.account_name);
|
||||
let steamid = account.session.as_ref().map_or(0, |s| s.expose_secret().steam_id);
|
||||
let steamid = account
|
||||
.session
|
||||
.as_ref()
|
||||
.map_or(0, |s| s.expose_secret().steam_id);
|
||||
self.entries.push(ManifestEntry {
|
||||
filename: format!("{}.maFile", &account.account_name),
|
||||
steam_id: steamid,
|
||||
|
@ -420,7 +423,8 @@ use tempdir::TempDir;
|
|||
.get_account(&account_name)?
|
||||
.lock()
|
||||
.unwrap()
|
||||
.revocation_code.expose_secret(),
|
||||
.revocation_code
|
||||
.expose_secret(),
|
||||
"R12345"
|
||||
);
|
||||
assert_eq!(
|
||||
|
@ -480,7 +484,8 @@ use tempdir::TempDir;
|
|||
.get_account(&account_name)?
|
||||
.lock()
|
||||
.unwrap()
|
||||
.revocation_code.expose_secret(),
|
||||
.revocation_code
|
||||
.expose_secret(),
|
||||
"R12345"
|
||||
);
|
||||
assert_eq!(
|
||||
|
@ -540,7 +545,8 @@ use tempdir::TempDir;
|
|||
.get_account(&account_name)?
|
||||
.lock()
|
||||
.unwrap()
|
||||
.revocation_code.expose_secret(),
|
||||
.revocation_code
|
||||
.expose_secret(),
|
||||
"R12345"
|
||||
);
|
||||
assert_eq!(
|
||||
|
@ -604,7 +610,8 @@ use tempdir::TempDir;
|
|||
.get_account(&account_name)?
|
||||
.lock()
|
||||
.unwrap()
|
||||
.revocation_code.expose_secret(),
|
||||
.revocation_code
|
||||
.expose_secret(),
|
||||
"R12345"
|
||||
);
|
||||
assert_eq!(
|
||||
|
@ -675,7 +682,14 @@ use tempdir::TempDir;
|
|||
let account = manifest.get_account(&account_name)?;
|
||||
assert_eq!(account_name, account.lock().unwrap().account_name);
|
||||
assert_eq!(
|
||||
account.lock().unwrap().session.as_ref().unwrap().expose_secret().web_cookie,
|
||||
account
|
||||
.lock()
|
||||
.unwrap()
|
||||
.session
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.expose_secret()
|
||||
.web_cookie,
|
||||
None
|
||||
);
|
||||
Ok(())
|
||||
|
@ -691,18 +705,38 @@ use tempdir::TempDir;
|
|||
let account_name = manifest.entries[0].account_name.clone();
|
||||
let account = manifest.get_account(&account_name)?;
|
||||
assert_eq!(account_name, account.lock().unwrap().account_name);
|
||||
assert_eq!(account.lock().unwrap().revocation_code.expose_secret(), "R12345");
|
||||
assert_eq!(
|
||||
account.lock().unwrap().session.as_ref().unwrap().expose_secret().steam_id,
|
||||
account.lock().unwrap().revocation_code.expose_secret(),
|
||||
"R12345"
|
||||
);
|
||||
assert_eq!(
|
||||
account
|
||||
.lock()
|
||||
.unwrap()
|
||||
.session
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.expose_secret()
|
||||
.steam_id,
|
||||
1234
|
||||
);
|
||||
|
||||
let account_name = manifest.entries[1].account_name.clone();
|
||||
let account = manifest.get_account(&account_name)?;
|
||||
assert_eq!(account_name, account.lock().unwrap().account_name);
|
||||
assert_eq!(account.lock().unwrap().revocation_code.expose_secret(), "R56789");
|
||||
assert_eq!(
|
||||
account.lock().unwrap().session.as_ref().unwrap().expose_secret().steam_id,
|
||||
account.lock().unwrap().revocation_code.expose_secret(),
|
||||
"R56789"
|
||||
);
|
||||
assert_eq!(
|
||||
account
|
||||
.lock()
|
||||
.unwrap()
|
||||
.session
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.expose_secret()
|
||||
.steam_id,
|
||||
5678
|
||||
);
|
||||
Ok(())
|
||||
|
|
|
@ -7,8 +7,8 @@ use std::{
|
|||
sync::{Arc, Mutex},
|
||||
};
|
||||
use steamguard::{
|
||||
steamapi, AccountLinkError, AccountLinker, Confirmation, FinalizeLinkError, LoginError,
|
||||
SteamGuardAccount, UserLogin, ExposeSecret,
|
||||
steamapi, AccountLinkError, AccountLinker, Confirmation, ExposeSecret, FinalizeLinkError,
|
||||
LoginError, SteamGuardAccount, UserLogin,
|
||||
};
|
||||
|
||||
use crate::accountmanager::ManifestAccountLoadError;
|
||||
|
|
|
@ -11,9 +11,9 @@ use reqwest::{
|
|||
Url,
|
||||
};
|
||||
use scraper::{Html, Selector};
|
||||
pub use secrecy::{ExposeSecret, SecretString};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{collections::HashMap, convert::TryInto};
|
||||
pub use secrecy::{ExposeSecret, SecretString};
|
||||
use steamapi::SteamApiClient;
|
||||
pub use userlogin::{LoginError, UserLogin};
|
||||
#[macro_use]
|
||||
|
@ -25,10 +25,10 @@ extern crate maplit;
|
|||
|
||||
mod accountlinker;
|
||||
mod confirmation;
|
||||
mod secret_string;
|
||||
pub mod steamapi;
|
||||
pub mod token;
|
||||
mod userlogin;
|
||||
mod secret_string;
|
||||
|
||||
// const STEAMAPI_BASE: String = "https://api.steampowered.com";
|
||||
// const COMMUNITY_BASE: String = "https://steamcommunity.com";
|
||||
|
@ -41,7 +41,6 @@ extern crate base64;
|
|||
extern crate cookie;
|
||||
extern crate hmacsha1;
|
||||
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct SteamGuardAccount {
|
||||
pub account_name: String,
|
||||
|
@ -240,8 +239,9 @@ impl SteamGuardAccount {
|
|||
"Revocation code not provided."
|
||||
);
|
||||
let client: SteamApiClient = SteamApiClient::new(self.session.clone());
|
||||
let resp =
|
||||
client.remove_authenticator(revocation_code.unwrap_or(self.revocation_code.expose_secret().to_owned()))?;
|
||||
let resp = client.remove_authenticator(
|
||||
revocation_code.unwrap_or(self.revocation_code.expose_secret().to_owned()),
|
||||
)?;
|
||||
Ok(resp.success)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,19 @@
|
|||
use serde::{Deserialize, Serialize, Serializer, Deserializer};
|
||||
use secrecy::{SecretString, ExposeSecret};
|
||||
use secrecy::{ExposeSecret, SecretString};
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
|
||||
/// Helper to allow serializing a [secrecy::SecretString] as a [String]
|
||||
pub(crate) fn serialize<S>(secret_string: &SecretString, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer {
|
||||
pub(crate) fn serialize<S>(secret_string: &SecretString, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
serializer.serialize_str(secret_string.expose_secret())
|
||||
}
|
||||
|
||||
/// Helper to allow deserializing a [String] as a [secrecy::SecretString]
|
||||
pub(crate) fn deserialize<'de, D>(d: D) -> Result<secrecy::SecretString, D::Error> where D: Deserializer<'de> {
|
||||
pub(crate) fn deserialize<'de, D>(d: D) -> Result<secrecy::SecretString, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let s = String::deserialize(d)?;
|
||||
Ok(SecretString::new(s))
|
||||
}
|
||||
|
|
|
@ -8,13 +8,13 @@ use reqwest::{
|
|||
header::{HeaderMap, HeaderName, HeaderValue, SET_COOKIE},
|
||||
Url,
|
||||
};
|
||||
use secrecy::{SerializableSecret, CloneableSecret, DebugSecret, ExposeSecret};
|
||||
use zeroize::Zeroize;
|
||||
use secrecy::{CloneableSecret, DebugSecret, ExposeSecret, SerializableSecret};
|
||||
use serde::{Deserialize, Deserializer, Serialize};
|
||||
use serde_json::Value;
|
||||
use std::iter::FromIterator;
|
||||
use std::str::FromStr;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
use zeroize::Zeroize;
|
||||
|
||||
lazy_static! {
|
||||
static ref STEAM_COOKIE_URL: Url = "https://steamcommunity.com".parse::<Url>().unwrap();
|
||||
|
|
|
@ -155,7 +155,13 @@ impl UserLogin {
|
|||
self.client.transfer_login(login_resp)?;
|
||||
}
|
||||
|
||||
return Ok(self.client.session.as_ref().unwrap().expose_secret().to_owned());
|
||||
return Ok(self
|
||||
.client
|
||||
.session
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.expose_secret()
|
||||
.to_owned());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue