diff --git a/README.md b/README.md index fbd6615b..322975dc 100644 --- a/README.md +++ b/README.md @@ -545,6 +545,7 @@ Changes the value of an [option](#options-). - `twoFactorCode` - If you have a Steam Guard mobile two-factor authentication code, you can provide it here. You might not need to, see the [`steamGuard`](#steamguard) event. (Added in 1.9.0) - `logonID` - A 32-bit integer to identify this login. The official Steam client derives this from your machine's private IP (it's the `obfuscated_private_ip` field in `CMsgClientLogOn`). If you try to logon twice to the same account from the same public IP with the same `logonID`, the first session will be kicked with reason `SteamUser.EResult.LogonSessionReplaced`. Defaults to `0` if not specified. - As of v4.13.0, this can also be an IPv4 address as a string, in dotted-decimal notation (e.g. `"192.168.1.5"`) + - `machineId` - A Buffer containing the machine ID to use. If not specified, the machine ID will be generated automatically. - `machineName` - A string containing the name of this machine that you want to report to Steam. This will be displayed on steamcommunity.com when you view your games list (when logged in). - `clientOS` - A [number](https://github.com/DoctorMcKay/node-steam-user/blob/master/enums/EOSType.js) to identify your client OS. Auto-detected if you don't provide one. diff --git a/components/09-logon.js b/components/09-logon.js index 010914b2..f1ab892d 100644 --- a/components/09-logon.js +++ b/components/09-logon.js @@ -27,6 +27,7 @@ const PRIVATE_IP_OBFUSCATION_MASK = 0xbaadf00d; * @property {string} [refreshToken] * @property {string} [accountName] * @property {string} [password] + * @property {string} [machineId] * @property {string} [machineAuthToken] * @property {string} [webLogonToken] * @property {string|SteamID} [steamID] @@ -79,6 +80,12 @@ class SteamUserLogon extends SteamUserMachineAuth { } let anonLogin = !details.accountName && !details.refreshToken; + let machineID = details.machineId || undefined; + + if (machineID && !Buffer.isBuffer(machineID)) { + this._warn(`machineId must be a type of Buffer, but got '${typeof machineID}', it will be ignored and created internally.`); + machineID = undefined; + } this._logOnDetails = { account_name: details.accountName, @@ -89,6 +96,7 @@ class SteamUserLogon extends SteamUserMachineAuth { obfuscated_private_ip: {v4: logonId || 0}, protocol_version: PROTOCOL_VERSION, supports_rate_limit_response: !anonLogin, + machine_id: machineID, machine_name: !anonLogin ? (details.machineName || '') : '', ping_ms_from_cell_search: !anonLogin ? 4 + Math.floor(Math.random() * 30) : 0, // fake ping value client_language: !anonLogin ? 'english' : '',