Minor tweaks

This commit is contained in:
Alex Corn
2017-12-26 16:39:23 -05:00
parent b5f50a6614
commit 0b57b47ecb

View File

@@ -72,7 +72,7 @@ SteamCommunity.prototype.login = function(details, callback) {
// headers required to convince steam that we're logging in from a mobile device so that we can get the oAuth data
var mobileHeaders = {};
if(!disableMobile){
if (!disableMobile) {
mobileHeaders = {
"X-Requested-With": "com.valvesoftware.android.steam.community",
"Referer": "https://steamcommunity.com/mobilelogin?oauth_client_id=DE45CD61&oauth_scope=read_profile%20write_profile%20read_client%20write_client",
@@ -82,6 +82,8 @@ SteamCommunity.prototype.login = function(details, callback) {
this._setCookie(Request.cookie("mobileClientVersion=0 (2.1.3)"));
this._setCookie(Request.cookie("mobileClient=android"));
} else {
mobileHeaders = {"Referer": "https://steamcommunity.com/login"};
}
this.httpRequestPost("https://steamcommunity.com/login/getrsakey/", {
@@ -96,7 +98,7 @@ SteamCommunity.prototype.login = function(details, callback) {
return;
}
if(!body.publickey_mod || !body.publickey_exp) {
if (!body.publickey_mod || !body.publickey_exp) {
deleteMobileCookies();
callback(new Error("Invalid RSA key received"));
return;
@@ -115,13 +117,14 @@ SteamCommunity.prototype.login = function(details, callback) {
"rsatimestamp": body.timestamp,
"twofactorcode": details.twoFactorCode || "",
"username": details.accountName,
"loginfriendlyname": "#login_emailauth_friendlyname_mobile",
"loginfriendlyname": "",
"donotcache": Date.now()
};
if(!disableMobile){
formObj.oauth_client_id = "DE45CD61";
formObj.oauth_scope = "read_profile write_profile read_client write_client";
formObj.loginfriendlyname = "#login_emailauth_friendlyname_mobile";
}
self.httpRequestPost({
@@ -138,36 +141,37 @@ SteamCommunity.prototype.login = function(details, callback) {
}
var error;
if(!body.success && body.emailauth_needed) {
if (!body.success && body.emailauth_needed) {
// Steam Guard (email)
error = new Error("SteamGuard");
error.emaildomain = body.emaildomain;
callback(error);
} else if(!body.success && body.requires_twofactor) {
} else if (!body.success && body.requires_twofactor) {
// Steam Guard (app)
callback(new Error("SteamGuardMobile"));
} else if(!body.success && body.captcha_needed && body.message.match(/Please verify your humanity/)) {
} else if (!body.success && body.captcha_needed && body.message.match(/Please verify your humanity/)) {
error = new Error("CAPTCHA");
error.captchaurl = "https://steamcommunity.com/login/rendercaptcha/?gid=" + body.captcha_gid;
self._captchaGid = body.captcha_gid;
callback(error);
} else if(!body.success) {
} else if (!body.success) {
callback(new Error(body.message || "Unknown error"));
} else if(!disableMobile && !body.oauth) {
} else if (!disableMobile && !body.oauth) {
callback(new Error("Malformed response"));
} else {
var sessionID = generateSessionID(), oAuth;
var sessionID = generateSessionID();
var oAuth;
self._setCookie(Request.cookie('sessionid=' + sessionID));
var cookies = self._jar.getCookieString("https://steamcommunity.com").split(';').map(function(cookie) {
return cookie.trim();
});
if(!disableMobile){
oAuth = JSON.parse( body.oauth );
if (!disableMobile){
oAuth = JSON.parse(body.oauth);
self.steamID = new SteamID(oAuth.steamid);
self.oAuthToken = oAuth.oauth_token;
}else{