public static void AlignTime(IWebRequest web, BCallback callback) { long currentTime = Util.GetSystemUnixTime(); web.Request(ApiEndpoints.TWO_FACTOR_TIME_QUERY, "POST", (response, code) => { if (response != null && code == HttpStatusCode.OK) { var query = JsonConvert.DeserializeObject <WebResponse <TimeQueryResponse> >(response); timeDifference = (int)(query.Response.ServerTime - currentTime); aligned = true; callback(true); } else { callback(false); } }); }
private void _addPhoneNumber(IWebRequest web, BCallback callback) { var postData = new Dictionary <string, string> { ["op"] = "add_phone_number", ["arg"] = this.PhoneNumber, ["sessionid"] = this.session.SessionID }; web.Request(ApiEndpoints.COMMUNITY_BASE + "/steamguard/phoneajax", "POST", postData, this.cookies, (response, code) => { if (response == null || code != HttpStatusCode.OK) { callback(false); return; } var addPhoneNumberResponse = JsonConvert.DeserializeObject <SuccessResponse>(response); callback(addPhoneNumberResponse.Success); }); }
private void UnlockFamilyView(IWebRequest web, BCallback callback) { var postData = new Dictionary <string, string> { ["pin"] = this.Pin }; web.Request(ApiEndpoints.STORE_BASE + "/parental/ajaxunlock", "POST", postData, this.cookies, (response, code) => { this.Pin = string.Empty; // Make sure we don't try again unless we fail if (response == null || code != HttpStatusCode.OK) { callback(false); return; } var successResponse = JsonConvert.DeserializeObject <SuccessResponse>(response); callback(successResponse.Success); }); }
public void DeactivateAuthenticator(SteamWeb web, int scheme, BCallback callback) { var postData = new Dictionary <string, string>(); postData.Add("steamid", this.Session.SteamID.ToString()); postData.Add("steamguard_scheme", scheme.ToString()); postData.Add("revocation_code", this.RevocationCode); postData.Add("access_token", this.Session.OAuthToken); web.MobileLoginRequest(ApiEndpoints.STEAMAPI_BASE + "/ITwoFactorService/RemoveAuthenticator/v0001", "POST", postData, (res, code) => { try { var removeResponse = JsonConvert.DeserializeObject <WebResponse <UnlinkResponse> >(res); callback(removeResponse?.Response != null && (removeResponse.Response.Success || removeResponse.Response.AttemptsRemaining > 0)); } catch (Exception) { callback(false); } }); }
public void AddAuthenticator(IWebRequest web, LinkCallback callback) { HasPhoneCallback hasPhoneCallback = hasPhone => { if (hasPhone == PhoneStatus.FamilyView) { callback(LinkResult.FamilyViewEnabled); return; } bool settingNumber = !string.IsNullOrEmpty(this.PhoneNumber); if (hasPhone == PhoneStatus.Attached && settingNumber) { callback(LinkResult.MustRemovePhoneNumber); return; } if (hasPhone == PhoneStatus.Detatched && !settingNumber) { callback(LinkResult.MustProvidePhoneNumber); return; } BCallback numberAddedCallback = numberAdded => { if (!numberAdded) { callback(LinkResult.GeneralFailure); return; } var postData = new Dictionary <string, string>(); postData["access_token"] = this.session.OAuthToken; postData["steamid"] = this.session.SteamID.ToString(); postData["authenticator_type"] = "1"; postData["device_identifier"] = this.DeviceID; postData["sms_phone_id"] = "1"; web.MobileLoginRequest(ApiEndpoints.STEAMAPI_BASE + "/ITwoFactorService/AddAuthenticator/v0001", "POST", postData, (response, code) => { if (response == null || code != HttpStatusCode.OK) { callback(LinkResult.GeneralFailure); return; } var addAuthenticatorResponse = JsonConvert.DeserializeObject <WebResponse <SteamGuardAccount> >(response); if (addAuthenticatorResponse?.Response == null) { callback(LinkResult.GeneralFailure); return; } if (addAuthenticatorResponse.Response.Status == 29) { callback(LinkResult.AuthenticatorPresent); return; } if (addAuthenticatorResponse.Response.Status != 1) { callback(LinkResult.GeneralFailure); return; } this.LinkedAccount = addAuthenticatorResponse.Response; // Force not enrolled at this stage this.LinkedAccount.FullyEnrolled = false; this.LinkedAccount.Session = this.session; this.LinkedAccount.DeviceID = this.DeviceID; callback(LinkResult.AwaitingFinalization); }); }; if (hasPhone == PhoneStatus.Detatched) { this._addPhoneNumber(web, numberAddedCallback); } else { numberAddedCallback(true); } }; if (string.IsNullOrEmpty(this.Pin)) { this._hasPhoneAttached(web, hasPhoneCallback); } else { this.UnlockFamilyView(web, success => { if (success) { this._hasPhoneAttached(web, hasPhoneCallback); } else { callback(LinkResult.FamilyViewEnabled); } }); } }
private void _sendConfirmationAjax(SteamWeb web, Confirmation conf, string op, BCallback callback) { this.GenerateConfirmationQueryParams(web, op, queryParams => { string url = ApiEndpoints.COMMUNITY_BASE + "/mobileconf/ajaxop"; string queryString = "?op=" + op + "&"; queryString += queryParams; queryString += "&cid=" + conf.ID + "&ck=" + conf.Key; url += queryString; var cookies = new CookieContainer(); this.Session.AddCookies(cookies); web.Request(url, "GET", null, cookies, (response, code) => { if (response == null || code != HttpStatusCode.OK) { callback(false); return; } var confResponse = JsonConvert.DeserializeObject <SuccessResponse>(response); callback(confResponse.Success); }); }); }
public void DenyConfirmation(SteamWeb web, Confirmation conf, BCallback callback) { this._sendConfirmationAjax(web, conf, "cancel", callback); }
public void AcceptConfirmation(SteamWeb web, Confirmation conf, BCallback callback) { this._sendConfirmationAjax(web, conf, "allow", callback); }
public void DeactivateAuthenticator(SteamWeb web, BCallback callback) { // Default scheme = 2 this.DeactivateAuthenticator(web, 2, callback); }