Node.js 模块用于与 Steam 身份验证服务器进行身份验证。可生成刷新令牌和 Web 身份验证 Cookie,用于与 steam-user 和其他包使用。
Node.js 模块用于与 Steam 身份验证服务器进行身份验证。可生成刷新令牌和 Web 身份验证 Cookie,用于与 steam-user 和其他包使用。
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.
Logging into Steam is a two-step process.
startWithCredentials to start a login session using your account credentialsstartWithQR to start a QR login sessionSee the examples directory on GitHub for example code.
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.
const {EAuthSessionSecurityHistory} = require('steam-session');
import {EAuthSessionSecurityHistory} from 'steam-session';const {EAuthSessionGuardType} = require('steam-session');
import {EAuthSessionGuardType} from 'steam-session';Contains the possible auth session guards.
const {EAuthTokenPlatformType} = require('steam-session');
import {EAuthTokenPlatformType} from 'steam-session';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']const {EResult} = require('steam-session');
import {EResult} from 'steam-session';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.
const {ESessionPersistence} = require('steam-session');
import {ESessionPersistence} from 'steam-session';Contains possible persistence levels for auth sessions.
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.
const {ITransport, ApiRequest, ApiResponse} = require('steam-session');
import {ITransport, ApiRequest, ApiResponse} from 'steam-session';const {LoginSession} = require('steam-session');
import {LoginSession} from 'steam-session';The LoginSession class is the primary way to interact with steam-session.
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).
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.
Read-only. A string containing your account name. This is populated just before the authenticated
event is fired.
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 (this behavior has been reverted)authenticated event is fired.
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:
startWithCredentials and you set it to a token that doesn't belong to the same account, orrefreshToken and you set this to a token that doesn't belong to the same account as the refresh tokenAccess 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...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:
startWithCredentials and you set it to a token that doesn't belong to the same account, oraccessToken and you set this to a token that doesn't belong to the same account as the access tokenRead-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.
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,或尚未同步最近议题。