Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let SteamUser = require('steam-user');
module.exports = SteamUser;
SteamUser.prototype.setWebSocket = function (webSocket) {
this.webSocket = webSocket;
};
/**
* overrides _steamGuardPrompt method to support WebSocket
* @param domain
* @param lastCodeWrong
* @param {steamGuardCallback} callback
*/
SteamUser.prototype._steamGuardPrompt = function (domain, lastCodeWrong, callback) {
if (this.options.promptSteamGuardCode) {
this.authCode = null;
try {
this.webSocket.send(JSON.stringify({action: 'authCode'}));
} catch (err) {
// TODO
}
this.once('inputAuthCode', code => callback(code));
} else {
this.emit('steamGuard', domain, callback, lastCodeWrong);
}
};
/**
* @callback steamGuardCallback
exports.onLogin = function () {
if (exports.isReady()) {
// We have relogged, set game and online
this.gamesPlayed(package.name);
this.setPersona(SteamUser.EPersonaState.Online);
}
};
function loginResponse (err) {
if (err) {
if (!lastLoginFailed && err.eresult !== SteamUser.EFriendRelationship.RateLimitExceeded && err.eresult !== SteamUser.EFriendRelationship.InvalidPassword) {
lastLoginFailed = true;
// Try and sign in without login key
log.warn('Failed to sign in to Steam, retrying without login key...');
login(null, loginResponse);
} else {
log.warn('Failed to sign in to Steam');
handler.onLoginFailure(err);
}
return;
}
checkAccountLimitations(function (err) {
if (err) {
throw err;
}
steam.on("loggedOn", () => {
steam.setPersona(Steam.EPersonaState.Online);
console.log("Logged on to Steam.");
ensureCommunityLoggedIn(() => {});
});
.then(() => {
this.client.setPersona(SteamUser.EPersonaState.Offline)
this.client.gamesPlayed(this.games !== null ? this.games : [10, 730])
return console.log(`${this.logheader()} Starting to boost games!`)
})
.catch(err => console.error(`${this.logheader()} ${err}`))
client.on('loggedOn', function(details) {
console.log("Logged into Steam as " + client.steamID.getSteam3RenderedID());
client.setPersona(SteamUser.EPersonaState.Invisible);
});
.then(() => {
this.client.setPersona(SteamUser.EPersonaState.Offline)
this.client.gamesPlayed(this.games !== null ? this.games : [10, 730])
return console.log(`${this.logheader()} Starting to boost games!`)
})
.catch(err => console.error(`${this.logheader()} ${err}`))
client.on("loggedOn", function(response) {
console.log("Logged into Steam as " + client.steamID.getSteam3RenderedID());
client.setPersona(SteamUser.EPersonaState.Online);
});
client.on("error", function(error) {
client.on('loggedOn', () => {
client.setPersona(SteamUser.Steam.EPersonaState.LookingToTrade, config.botName);
client.gamesPlayed(440);
console.log(colours.bgGreen(config.botName) + ' is online and looking for trade.'.green);
});
client.on('webSession', (sessionid, cookies) => {
constructor(name, password, sentry, secret, games, indent = 0) {
super()
this.name = name
this.password = password
this.sentry = sentry
this.secret = secret
this.games = games
this.indent = indent
const options = {
promptSteamGuardCode: false,
dataDirectory: null
}
this.client = new SteamUser(null, options)
if (this.sentry) this.client.setSentry(Buffer.from(this.sentry, "base64"))
this.client.on("error", err => this.emit("clientError", err))
this.client.on("steamGuard", () => this.emit("clientSteamGuard"))
this.client.once("steamGuard", () => (this.steamGuardRequested = true))
}