Fixed Node.js process being kept running unnecessarily

This commit is contained in:
Alex Corn 2018-04-01 03:15:13 -04:00
parent 8846082f60
commit f6c7c74ab6

View File

@ -86,7 +86,7 @@ SteamCommunity.prototype.login = function(details, callback) {
} else { } else {
mobileHeaders = {"Referer": "https://steamcommunity.com/login"}; mobileHeaders = {"Referer": "https://steamcommunity.com/login"};
} }
this.httpRequestPost("https://steamcommunity.com/login/getrsakey/", { this.httpRequestPost("https://steamcommunity.com/login/getrsakey/", {
"form": {"username": details.accountName}, "form": {"username": details.accountName},
"headers": mobileHeaders, "headers": mobileHeaders,
@ -104,7 +104,7 @@ SteamCommunity.prototype.login = function(details, callback) {
callback(new Error("Invalid RSA key received")); callback(new Error("Invalid RSA key received"));
return; return;
} }
var key = new RSA(); var key = new RSA();
key.setPublic(body.publickey_mod, body.publickey_exp); key.setPublic(body.publickey_mod, body.publickey_exp);
@ -146,7 +146,7 @@ SteamCommunity.prototype.login = function(details, callback) {
// Steam Guard (email) // Steam Guard (email)
error = new Error("SteamGuard"); error = new Error("SteamGuard");
error.emaildomain = body.emaildomain; error.emaildomain = body.emaildomain;
callback(error); callback(error);
} else if (!body.success && body.requires_twofactor) { } else if (!body.success && body.requires_twofactor) {
// Steam Guard (app) // Steam Guard (app)
@ -154,9 +154,9 @@ SteamCommunity.prototype.login = function(details, callback) {
} 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 = new Error("CAPTCHA");
error.captchaurl = "https://steamcommunity.com/login/rendercaptcha/?gid=" + body.captcha_gid; error.captchaurl = "https://steamcommunity.com/login/rendercaptcha/?gid=" + body.captcha_gid;
self._captchaGid = body.captcha_gid; self._captchaGid = body.captcha_gid;
callback(error); callback(error);
} else if (!body.success) { } else if (!body.success) {
callback(new Error(body.message || "Unknown error")); callback(new Error(body.message || "Unknown error"));
@ -170,7 +170,7 @@ SteamCommunity.prototype.login = function(details, callback) {
var cookies = self._jar.getCookieString("https://steamcommunity.com").split(';').map(function(cookie) { var cookies = self._jar.getCookieString("https://steamcommunity.com").split(';').map(function(cookie) {
return cookie.trim(); return cookie.trim();
}); });
if (!disableMobile){ if (!disableMobile){
oAuth = JSON.parse(body.oauth); oAuth = JSON.parse(body.oauth);
self.steamID = new SteamID(oAuth.steamid); self.steamID = new SteamID(oAuth.steamid);
@ -198,7 +198,7 @@ SteamCommunity.prototype.login = function(details, callback) {
} }
self.setCookies(cookies); self.setCookies(cookies);
callback(null, sessionID, cookies, steamguard, disableMobile ? null : oAuth.oauth_token); callback(null, sessionID, cookies, steamguard, disableMobile ? null : oAuth.oauth_token);
} }
}, "steamcommunity"); }, "steamcommunity");
@ -278,7 +278,7 @@ SteamCommunity.prototype.getSessionID = function() {
return decodeURIComponent(match[2]); return decodeURIComponent(match[2]);
} }
} }
var sessionID = generateSessionID(); var sessionID = generateSessionID();
this._setCookie(Request.cookie('sessionid=' + sessionID)); this._setCookie(Request.cookie('sessionid=' + sessionID));
return sessionID; return sessionID;
@ -300,17 +300,17 @@ SteamCommunity.prototype.parentalUnlock = function(pin, callback) {
if(!callback) { if(!callback) {
return; return;
} }
if (err) { if (err) {
callback(err); callback(err);
return; return;
} }
if (!body || typeof body.success !== 'boolean') { if (!body || typeof body.success !== 'boolean') {
callback("Invalid response"); callback("Invalid response");
return; return;
} }
if (!body.success) { if (!body.success) {
switch (body.eresult) { switch (body.eresult) {
case 15: case 15:
@ -327,7 +327,7 @@ SteamCommunity.prototype.parentalUnlock = function(pin, callback) {
return; return;
} }
callback(); callback();
}.bind(this), "steamcommunity"); }.bind(this), "steamcommunity");
}; };
@ -347,7 +347,7 @@ SteamCommunity.prototype.getNotifications = function(callback) {
callback(new Error("Malformed response")); callback(new Error("Malformed response"));
return; return;
} }
var notifications = { var notifications = {
"trades": body.notifications[1] || 0, "trades": body.notifications[1] || 0,
"gameTurns": body.notifications[2] || 0, "gameTurns": body.notifications[2] || 0,
@ -387,12 +387,12 @@ SteamCommunity.prototype.loggedIn = function(callback) {
callback(err || new Error("HTTP error " + response.statusCode)); callback(err || new Error("HTTP error " + response.statusCode));
return; return;
} }
if(response.statusCode == 403) { if(response.statusCode == 403) {
callback(null, true, true); callback(null, true, true);
return; return;
} }
callback(null, !!response.headers.location.match(/steamcommunity\.com(\/(id|profiles)\/[^\/]+)\/?/), false); callback(null, !!response.headers.location.match(/steamcommunity\.com(\/(id|profiles)\/[^\/]+)\/?/), false);
}, "steamcommunity"); }, "steamcommunity");
}; };
@ -451,7 +451,7 @@ SteamCommunity.prototype._myProfile = function(endpoint, form, callback) {
self._profileURL = match[1]; self._profileURL = match[1];
setTimeout(function () { setTimeout(function () {
delete self._profileURL; // delete the cache delete self._profileURL; // delete the cache
}, 60000); }, 60000).unref();
completeRequest(match[1]); completeRequest(match[1]);
}, "steamcommunity"); }, "steamcommunity");