Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
N

node-steam-session

> 编程语言
Open source

Node.js module for authenticating with the Steam auth server. Allows for generating refresh tokens and web auth cookies for use with steam-user and other packag

193 stars0 likes2 views
WebsiteGitHub

About

Node.js module for authenticating with the Steam auth server. Allows for generating refresh tokens and web auth cookies for use with steam-user and other packag

Steam Session Manager

This module enables you to negotiate Steam tokens by authenticating with the Steam login server. This is for use with your own accounts. This is not to be used to authenticate other Steam users or to gain access to their accounts. For that use-case, please use the Steam OpenID service (you may want to consider using steam-signin) and the many available WebAPIs.

Node.js v12.22.0 or later is required to use this module.

  • Concepts
  • Example Code
  • Exports
    • Enums
      • EAuthSessionSecurityHistory
      • EAuthSessionGuardType
      • EAuthTokenPlatformType
      • EResult
      • ESessionPersistence
    • Custom Transports
  • LoginSession
    • Properties
      • steamID
      • loginTimeout
      • accountName
      • accessToken
      • refreshToken
      • steamGuardMachineToken
    • Methods
      • Constructor(platformType[, options])
      • startWithCredentials(details)
      • startWithQR()
      • submitSteamGuardCode(authCode)
      • forcePoll()
      • cancelLoginAttempt()
      • getWebCookies()
      • refreshAccessToken()
      • renewRefreshToken()
    • Events
      • polling
      • timeout
      • remoteInteraction
      • steamGuardMachineToken
      • authenticated
      • error
  • LoginApprover
    • Properties
      • steamID
      • accessToken
      • sharedSecret
    • Methods
      • Constructor(accessToken, sharedSecret[, options])
      • getAuthSessionInfo(qrChallengeUrl)
      • approveAuthSession(details)

Concepts

Logging into Steam is a two-step process.

  1. You start a login session either using your account credentials (username and password) or by generating a QR code
    • Use startWithCredentials to start a login session using your account credentials
    • Use startWithQR to start a QR login session
  2. Assuming any credentials you provided when you started the session were correct, Steam replies with a list of login guards
    • See EAuthSessionGuardType
    • If your account doesn't have Steam Guard enabled or you provided a valid code upfront, there may be 0 guards required
    • Only one guard must be satisfied to complete the login. For example, you might be given a choice of providing a TOTP code or confirming the login in your Steam mobile app
  3. When you satisfy any guards, Steam sends back an access token and a refresh token. These can be used to:
    • Log on with node-steam-user
    • Obtain web session cookies
    • Authenticate with WebAPI methods used by the mobile app

Example Code

See the examples directory on GitHub for example code.

Exports

When using CommonJS (require()), steam-session exports an object. When using ES6 modules (import), steam-session does not offer a default export and you will need to import specific things.

The majority of steam-session consumers will only care about enums, and the LoginSession and potentially LoginApprover classes.

Enums

EAuthSessionSecurityHistory

javascript
const {EAuthSessionSecurityHistory} = require('steam-session');
import {EAuthSessionSecurityHistory} from 'steam-session';

View on GitHub

EAuthSessionGuardType

javascript
const {EAuthSessionGuardType} = require('steam-session');
import {EAuthSessionGuardType} from 'steam-session';

View on GitHub

Contains the possible auth session guards.

EAuthTokenPlatformType

javascript
const {EAuthTokenPlatformType} = require('steam-session');
import {EAuthTokenPlatformType} from 'steam-session';

View on GitHub

Contains the different platform types that can be authenticated for. You should specify the correct platform type when you instantiate a LoginSession object.

Audiences present in tokens issued for the different platform types:

  • SteamClient - ['web', 'client']
  • WebBrowser - ['web']
  • MobileApp - ['web', 'mobile']

EResult

javascript
const {EResult} = require('steam-session');
import {EResult} from 'steam-session';

View on GitHub

Contains possible result codes. This is a very large enum that used throughout Steam, so most values in this enum will not be relevant when authenticating.

ESessionPersistence

javascript
const {ESessionPersistence} = require('steam-session');
import {ESessionPersistence} from 'steam-session';

View on GitHub

Contains possible persistence levels for auth sessions.

Custom Transports

It's possible to define a custom transport to be used when interacting with the Steam login server. The default transport used to interact with the Steam login server is chosen depending on your provided EAuthTokenPlatformType. For the SteamClient platform type, a WebSocketCMTransport will be used to communicate with a CM server using a WebSocket. For other platform types, a WebApiTransport will be used to interact with the Steam login server using api.steampowered.com. It is very likely that you won't need to mess with this.

Everything in this category is TypeScript interfaces, so even if you're implementing a custom transport, you don't need these unless you're using TypeScript.

javascript
const {ITransport, ApiRequest, ApiResponse} = require('steam-session');
import {ITransport, ApiRequest, ApiResponse} from 'steam-session';

View on GitHub

LoginSession

javascript
const {LoginSession} = require('steam-session');
import {LoginSession} from 'steam-session';

The LoginSession class is the primary way to interact with steam-session.

Properties

steamID

Read-only. A SteamID instance containing the SteamID for the currently-authenticated account. Populated immediately after startWithCredentials resolves, or immediately after accessToken or refreshToken are set (meaning that this is always populated when authenticated fires).

loginTimeout

A number specifying the time, in milliseconds, before a login attempt will timeout. The timer begins after polling begins.

If you attempt to set this property after polling has already been emitted, an Error will be thrown since setting this property after that point has no effect.

accountName

Read-only. A string containing your account name. This is populated just before the authenticated event is fired.

accessToken

A string containing your access token.

As of 2023-09-12, Steam does not return an access token in response to successful authentication, so this won't be set when the authenticated event is fired. (this behavior has been reverted)

This will be set after you call refreshAccessToken() or renewRefreshToken(). Also, since getWebCookies() calls refreshAccessToken() internally for EAuthTokenPlatformType SteamClient or MobileApp, this will also be set after calling getWebCookies() for those platform types.

You can also assign an access token to this property if you already have one, although at present that wouldn't do anything useful.

Setting this property will throw an Error if:

  • You set it to a token that isn't well-formed, or
  • You set it to a refresh token rather than an access token, or
  • You have already called startWithCredentials and you set it to a token that doesn't belong to the same account, or
  • You have already set refreshToken and you set this to a token that doesn't belong to the same account as the refresh token

Access tokens can't be used for much. You can use them with a few undocumented WebAPIs like IFriendsListService/GetFriendsList by passing the access token as an access_token query string parameter. For example:

https://api.steampowered.com/IFriendsListService/GetFriendsList/v1/?access_token=eyAidHlwIjogIkpXVCIsICJhbGciOiAiRWREU0EiIH0.eyJpc3MiOiJ...

As of time of writing (2023-04-24), it appears that you can also use access tokens with regular published API methods, for example:

https://api.steampowered.com/ISteamUserStats/GetNumberOfCurrentPlayers/v1/?appid=440&access_token=eyAidHlwIjogIkpXVCIsICJhbGciOiAiRWREU0EiIH0.eyJpc3MiOiJ...

refreshToken

A string containing your refresh token. This is populated just before the authenticated event is fired. You can also assign a refresh token to this property if you already have one.

Setting this property will throw an Error if:

  • You set it to a token that isn't well-formed, or
  • You set it to an access token rather than a refresh token, or
  • You have already called startWithCredentials and you set it to a token that doesn't belong to the same account, or
  • You have already set accessToken and you set this to a token that doesn't belong to the same account as the access token

steamGuardMachineToken

Read-only. A string containing your Steam Guard machine token. This is populated when you pass a steamGuardMachineToken to startWithCredentials, or just before the steamGuardMachineToken event is emitted.

Methods

Constructor(platformType[, options])

  • platformType - A value from EAuthTokenPlatformType. You should set this to the appropriate platform type for your desired usage.
  • options - An object with zero or more of these properties:
    • userAgent - Pass a user-agent string if you want to override the default user-agent. This is only effective when using EAuthTokenPlatformType.WebBrowser.
    • transport - An ITransport instance, if you need to specify a custom transport. If omitted, defaults to a WebSocketCMTransport instance for SteamClient platf

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptjavascriptnodejssteamtypescript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言