Jump to content
McKay Development

sessionExpired does not seem to be fired


Vizzy

Recommended Posts

I've made a thread about this a few months ago but back then I managed to get it working. However, I now need to implement the same thing and I cannot get it to work. I'm simply trying to refresh the session after it has expired. I'm attempting this by manually invalidating the cookies, the event is never called.

Code

const SteamUser = require('steam-user');
const SteamCommunity = require('steamcommunity');
const SteamTotp = require('steam-totp');
const TradeOfferManager = require('steam-tradeoffer-manager');

const client = new SteamUser();
const community = new SteamCommunity();
const manager = new TradeOfferManager({
  community: this.community,
  language: 'en',
});

client.logOn({ ... })

client.on('loggedOn', () => {
  console.log('bot has logged into steam.');
  client.setPersona(SteamUser.EPersonaState.Online);
});

client.on('webSession', (session, cookies) => {
  manager.setCookies(cookies);
  community.setCookies(cookies);

  console.log('websession established');
});

client.on('error', (err) => console.log(err));

community.on('sessionExpired', () => {
  console.log('session has expired');
});

setTimeout(function () {
  console.log('attempting to kill session');
  community.setCookies(['sessionid=1||invalid', 'steamLogin=1||invalid', 'steamLoginSecure=1||invalid']);
  manager.setCookies(['sessionid=1||invalid', 'steamLogin=1||invalid', 'steamLoginSecure=1||invalid']);

  // make void call to trigger sessionExpired
  community.getNotifications((err, notifications) => console.log(err ? 'sessionExpired should be triggered now' : notifications));
}, 10 * 1000);

What am I missing? I would presume after calling getNotifications (for testing purposes) the sessionExpired event would be fired.

Link to comment
Share on other sites

There are a few different criteria that are checked when determining if an error warrants emitting the sessionExpired event. As a general rule, it gets emitted if a page redirects to /login.

Valve being Valve, they're incredibly inconsistent as to how they communicate that you aren't logged in. The request for getting notifications returns 401, which isn't one of the criteria that emits sessionExpired. It probably should be, but I'll have to check to see if there are any other edge cases that might arise by adding 401 responses as an indicator to emit sessionExpired.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...