Closed LCozzoli closed 1 year ago
A lot of functions and data are actually empty using this connection way.
Hi LCozzoli, assuming you're running this in a Node project can you check the package.json file and make sure your version is higher than 4.25.0?
You'll be looking for a section like this:
"dependencies": {
"node": "^16.7.1",
"steam-session": "^0.0.3-alpha",
"steam-user": "^4.26.1"
}
As noted in the docs for steam-user,
v4.25.0 or later is required to use refreshToken.
To upgrade, you can do the following:
NPM:
npm update steam-user
YARN:
yarn upgrade steam-user
The issue is that you're logging in successfully with node-session (I assume) and then when you pass your refresh token into steam-user via client.logOn({refreshToken: session.refreshToken})
you're passing in an option that doesn't exist, RE: client.details.refreshToken
OR
You need to specify within steam-session
the client type you are using, which looks like this in the example
let session = new LoginSession(EAuthTokenPlatformType.Mobile);
but to use with steam-user you'll likely want to use this instead
let session = new LoginSession(EAuthTokenPlatformType.SteamClient);
Hope this helps, I had the same issue forgetting that I hadn't updated my dependencies in months when I returned to an old project. Note for next time, include your code and a bit of actual information(expected behaviour, errors, etc), otherwise it just looks like you're complaining and don't have any idea what you're doing.
Hi Whats-A-MattR,
The version I was using during those tests was "steam-user": "^4.25.0"
and "steam-session": "^0.0.2-alpha"
I used the example code, and no I'm not complaining don't worry ahah, I used the old way of connection.
This was my session handler:
import { LoginSession, EAuthTokenPlatformType } from "steam-session";
import decode from "jwt-decode";
import { sleep } from "src/shared/utils";
import { Logger } from "../core.log";
import Totp from "steam-totp";
import { singleton } from "tsyringe";
import { EBotActions } from "src/enums";
import { ICredential, ISessionResult } from "src/interfaces";
@singleton()
export class Session {
constructor(private readonly logger: Logger) {}
async process(credentials: ICredential): Promise<ISessionResult> {
const session = new LoginSession(EAuthTokenPlatformType.SteamClient);
return new Promise<ISessionResult>(async (resolve) => {
let result = {
cookies: [],
refreshToken: credentials.refreshToken,
};
while (true) {
result = await this.login(session, credentials, result.refreshToken);
if (result.cookies.length) return resolve(result);
await sleep(5000);
}
});
}
async login(session: LoginSession, credentials: ICredential, refreshToken: string): Promise<ISessionResult> {
return new Promise<ISessionResult>(async (resolve, reject) => {
if (refreshToken) {
const decoded = decode(refreshToken);
if (decoded) {
const { exp } = decoded as any;
if (exp > Date.now() / 1000) {
try {
if (session.refreshToken != refreshToken) session.refreshToken = refreshToken;
const cookies = await session.getWebCookies();
this.logger.debug(EBotActions.GetWebCookiesSuccess);
return resolve({
cookies,
refreshToken,
});
} catch (err) {
this.logger.error(EBotActions.GetWebCookiesFailed, err.message, {
result: err,
});
}
} else this.logger.debug(EBotActions.RefreshTokenExpired);
}
}
session
.startWithCredentials({
accountName: credentials.username,
password: credentials.password,
steamGuardCode: Totp.generateAuthCode(credentials.sharedSecret),
})
.then((startSession) => {
if (startSession.actionRequired) return reject(startSession.validActions);
session.once("error", (err) => {
reject(err);
});
session.once("authenticated", () => {
this.logger.debug(EBotActions.SessionAuthenticated);
resolve({
cookies: [],
refreshToken: session.refreshToken,
});
});
})
.catch(reject);
});
}
}
Could you also share where you're using the steam-user module?
Then I was setting my session like this:
const session = await this.session.process(this.credentials);
(this.steam.client as any).logOn({
refreshToken: session.refreshToken,
clientOS: 16,
});
And it was emitting steamLogon event but nothing was set
I will try with latest packages
From what I experienced, when logging into an 'anonymous' account (which is generally what's used for game servers etc.) you get a loggedOn
event emitted, but you don't get an accountInfo
event or anything, which might explain the behaviour you're seeing.
Can you try printing your client.steamID
, checking the 'universe' property and the 'accountid' property to make sure it's yours? I believe a universe value of 10 represents an anonymous account.
If that's the case, I had the same thing happen with an outdated steam-user package, but you might be losing the refreshToken somewhere? Since refreshToken
didn't exist I wasn't actually passing any data to the logOn
method and logging in anonymously.
Have you instantiated the session class properly? I haven't spent as much time as I probably should learning TypeScript but it looooooooooooooks okay? I'd just be checking that the values are getting passed around as expected logging to console at each step.
It seems to be fixed with the 4.26, I don't changed anything to my original code
Describe the bug
accountInfo
event is not emitted andclient.accountInfo
is null when using a refreshToken to login, despite the fact that I receivedloggedOn
event correctly and cookies fromgetWebCookies()
(node-steam-session) are working on SteamCommunity.Versions
Latest