From 691d9270508326bb67c2acb822507add49fa969d Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Mon, 9 Aug 2021 21:41:20 -0400 Subject: [PATCH] adding phone numbers does not work --- src/main.rs | 5 +++-- steamguard/src/accountlinker.rs | 38 ++++++++++++++++----------------- steamguard/src/steamapi.rs | 20 ++++++++++++++++- 3 files changed, 41 insertions(+), 22 deletions(-) diff --git a/src/main.rs b/src/main.rs index f07fffb..eb6cb38 100644 --- a/src/main.rs +++ b/src/main.rs @@ -142,8 +142,9 @@ fn main() { return; } Err(AccountLinkError::MustProvidePhoneNumber) => { - print!("Enter your phone number: "); - linker.phone_number = prompt(); + println!("Enter your phone number in the following format: +1 123-456-7890"); + print!("Phone number: "); + linker.phone_number = prompt().replace(&['(', ')', '-'][..], ""); } Err(AccountLinkError::AuthenticatorPresent) => { println!("An authenticator is already present on this account."); diff --git a/steamguard/src/accountlinker.rs b/steamguard/src/accountlinker.rs index e344f22..d45e569 100644 --- a/steamguard/src/accountlinker.rs +++ b/steamguard/src/accountlinker.rs @@ -32,27 +32,27 @@ impl AccountLinker { } pub fn link(&mut self) -> anyhow::Result { - let has_phone = self.client.has_phone()?; + // let has_phone = self.client.has_phone()?; - if has_phone && !self.phone_number.is_empty() { - return Err(AccountLinkError::MustRemovePhoneNumber); - } - if !has_phone && self.phone_number.is_empty() { - return Err(AccountLinkError::MustProvidePhoneNumber); - } + // if has_phone && !self.phone_number.is_empty() { + // return Err(AccountLinkError::MustRemovePhoneNumber); + // } + // if !has_phone && self.phone_number.is_empty() { + // return Err(AccountLinkError::MustProvidePhoneNumber); + // } - if !has_phone { - if self.sent_confirmation_email { - if !self.client.check_email_confirmation()? { - return Err(anyhow!("Failed email confirmation check"))?; - } - } else if !self.client.add_phone_number(self.phone_number.clone())? { - return Err(anyhow!("Failed to add phone number"))?; - } else { - self.sent_confirmation_email = true; - return Err(AccountLinkError::MustConfirmEmail); - } - } + // if !has_phone { + // if self.sent_confirmation_email { + // if !self.client.check_email_confirmation()? { + // return Err(anyhow!("Failed email confirmation check"))?; + // } + // } else if !self.client.add_phone_number(self.phone_number.clone())? { + // return Err(anyhow!("Failed to add phone number"))?; + // } else { + // self.sent_confirmation_email = true; + // return Err(AccountLinkError::MustConfirmEmail); + // } + // } let resp: AddAuthenticatorResponse = self.client.add_authenticator(self.device_id.clone())?; diff --git a/steamguard/src/steamapi.rs b/steamguard/src/steamapi.rs index 6306265..919f6a2 100644 --- a/steamguard/src/steamapi.rs +++ b/steamguard/src/steamapi.rs @@ -301,6 +301,9 @@ impl SteamApiClient { } } + /// One of the endpoints that handles phone number things. Can check to see if phone is present on account, and maybe do some other stuff. It's not really super clear. + /// + /// Host: steamcommunity.com /// Endpoint: POST /steamguard/phoneajax /// Requires `sessionid` cookie to be set. fn phoneajax(&self, op: &str, arg: &str) -> anyhow::Result { @@ -319,6 +322,7 @@ impl SteamApiClient { .form(¶ms) .send()?; + trace!("phoneajax: status={}", resp.status()); let result: Value = resp.json()?; trace!("phoneajax: {:?}", result); if result["has_phone"] != Value::Null { @@ -350,7 +354,21 @@ impl SteamApiClient { } pub fn add_phone_number(&self, phone_number: String) -> anyhow::Result { - return self.phoneajax("add_phone_number", phone_number.as_str()); + // return self.phoneajax("add_phone_number", phone_number.as_str()); + todo!(); + } + + /// Provides lots of juicy information, like if the number is a VOIP number. + /// Host: store.steampowered.com + /// Endpoint: POST /phone/validate + /// Found on page: https://store.steampowered.com/phone/add + pub fn phone_validate(&self, phone_number: String) -> anyhow::Result { + let params = hashmap!{ + "sessionID" => "", + "phoneNumber" => "", + }; + + todo!(); } /// Starts the authenticator linking process.