Allows to programatically perform actions found in the Steam client for the purpose of automatization. This module will not manage anything for you.
New JWT auth system (QR Code, mobile confirmation, credential auth) is fully supported. The old system by login key and sentry files is unsupported.
$ npm i @fcastrocs/steamclient
Main class:
This module is organized into services. Naming is as in the Protos
Steam ^
- isLoggedIn: boolean
- steamId: Long
event: "disconnected" - listener: (error: SteamClientError) event: "accountLoggedOff" - listener (eresult: string) event: "waitingForConfirmation"- listener (confirmation: Confirmation) event: "personaStateChanged" - listener: (state: Friend) event: "playingStateChanged" - listener: (state: PlayingSessionState)
- options is an object that must at least have the following properties:
- steamCM
Establish connection with Steam server.
Disconnect from Steam server. (Will not cause 'disconnected' event to emit)
- options is an object that must at least have the following properties:
- accountName, refreshToken
const steamCM = { host: steamIP, port: steamPort };
// you can also pass a socks proxy, checkout ConnectionOptions
const options: ConnectionOptions = { steamCM };
const steam = new Steam(options);
await steam.connect();
Auth ^
A service to obtain authentication tokens (refresh and access JWT tokens)
- when "terminal" is passed, the QR code will be printed to the console.
- when "image" is passsed, an img url will be returned.
Login with credentials.
Confirm auth with steam guard code.
// connect to steam first
// QR code authentication
steam.once('waitingForConfirmation', (res) => console.log(res.qrCode));
// promise will reject after 2 minutes if QR is not scanned.
const authTokens = await steam.service.auth.getAuthTokensViaQR('terminal'); // can be "image"
// Credential authentication
steam.once('waitingForConfirmation', (res) => console.log(res.guardType));
// promise will reject after 2 minutes if authentication is not confirmed.
const authTokens = await steam.service.auth.getAuthTokensViaCredentials(accountName, password);
// you must handle the logic within your app to be able to submit the steam guard code
// After this is called, then getAuthTokensViaCredentials will resolve with authTokens.
await steam.service.auth.updateWithSteamGuardCode(steamGuardCode);
// after getting authTokens, then you can login to steam
await steam.login({ refreshToken: authtokens.refreshToken });