Hi! We also had legacy code that used steam-weblogon, which was layered on top of steam-client. Replacing them with steam-user for session handling is quite simple. Here's a part of my code, hope this helps.
let WebSession = false
const SteamUser = require('steam-user');
const SteamTradeOffers = require('steam-tradeoffers');
const getSteamAPIKey = require('steam-web-api-key');
const SteamTotp = require('steam-totp');
const SteamCommunity = require('node-steamcommunity');
const community = new SteamCommunity(config.ip);
const offers = new SteamTradeOffers();
const steamUser = new SteamUser({ localAddress: config.ip })
SteamTotp.generateAuthCode(user.shared, (err, code, offset, latency) => {
const details = {
accountName: user.username,
password: user.password,
twoFactorCode: code
};
steamUser.logOn(details);
})
steamUser.on('loggedOn', function(details) {
steamUser.setPersona(SteamUser.EPersonaState.Online)
});
steamUser.on('webSession', (sessionID, cookies) => {
console.log('WEBSESSION STARTED')
getSteamAPIKey({
sessionID: sessionID,
webCookie: cookies
}, function (err, APIKey) {
if (!APIKey) APIKey = config.apikey;
const sessionData = {
sessionID: sessionID,
webCookie: cookies,
APIKey: APIKey,
localAddress: config.ip
}
offers.setup(sessionData)
WebSession = true;
startConfirmations(cookies)
});
})
function startConfirmations (cookies) {
community.setCookies(cookies)
community.startConfirmationChecker(20000, user.identity)
}
steamUser.on('tradeOffers', function (count) {
if (!count || !WebSession) return
handleOffers();
});
The latest version of steam-user is being used, so I had to update npm and node to version 14.