From 117374a4c5968df218e15538fe0d1b1b9c45eba2 Mon Sep 17 00:00:00 2001 From: Alex Corn Date: Wed, 11 Jul 2018 02:22:39 -0400 Subject: [PATCH 1/7] Updated Chrome user-agent --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index afac9ed..790717a 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,7 @@ const Request = require('request'); const RSA = require('node-bignumber').Key; const SteamID = require('steamid'); -const USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"; +const USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"; require('util').inherits(SteamCommunity, require('events').EventEmitter); From a0ad33d5eb9850e21ae1eb4cd898b92b9230bc00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=A8=EF=BD=8F=EF=BD=8E=EF=BD=87=EF=BD=81=EF=BD=92?= =?UTF-8?q?=EF=BD=83?= Date: Sat, 20 Oct 2018 13:29:52 +0700 Subject: [PATCH 2/7] Add comment group --- classes/CSteamGroup.js | 4 ++++ components/groups.js | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/classes/CSteamGroup.js b/classes/CSteamGroup.js index c18889f..8440987 100644 --- a/classes/CSteamGroup.js +++ b/classes/CSteamGroup.js @@ -123,6 +123,10 @@ CSteamGroup.prototype.deleteComment = function(cid, callback) { this._community.deleteGroupComment(this.steamID, cid, callback); }; +CSteamGroup.prototype.comment = function(message, callback) { + this._community.postGroupComment(this.steamID, message, callback); +}; + /** * Get requests to join this restricted group. * @param {function} callback - First argument is null/Error, second is array of SteamID objects diff --git a/components/groups.js b/components/groups.js index 5bd42b4..d4906de 100644 --- a/components/groups.js +++ b/components/groups.js @@ -591,6 +591,30 @@ SteamCommunity.prototype.deleteGroupComment = function(gid, cid, callback) { }, "steamcommunity"); }; +SteamCommunity.prototype.postGroupComment = function(gid, message, callback) { + if (typeof gid === 'string') { + gid = new SteamID(gid); + } + + var options = { + "uri": "https://steamcommunity.com/comment/Clan/post/" + gid.getSteamID64() + "/-1/", + "form": { + "comment": message, + "count": 6, + "sessionid": this.getSessionID() + } + }; + + var self = this; + this.httpRequestPost(options, function(err, response, body) { + if(!callback) { + return; + } + + callback(err || null); + }, "steamcommunity"); +}; + /** * Get requests to join a restricted group. * @param {SteamID|string} gid - The SteamID of the group you want to manage From 1180eb9d3fedb6607b12b6164ac9fa03490eca30 Mon Sep 17 00:00:00 2001 From: Alex Corn Date: Wed, 13 Feb 2019 17:35:39 -0500 Subject: [PATCH 3/7] Deprecated webchat methods --- .idea/.name | 1 + .idea/codeStyleSettings.xml | 13 +++++ .idea/copyright/profiles_settings.xml | 3 ++ .idea/encodings.xml | 6 +++ .idea/node-steamcommunity.iml | 8 +++ .idea/watcherTasks.xml | 4 ++ components/chat.js | 75 ++++++++++++++++++--------- components/webapi.js | 6 ++- 8 files changed, 90 insertions(+), 26 deletions(-) create mode 100644 .idea/.name create mode 100644 .idea/codeStyleSettings.xml create mode 100644 .idea/copyright/profiles_settings.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/node-steamcommunity.iml create mode 100644 .idea/watcherTasks.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..cbc09b2 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +node-steamcommunity \ No newline at end of file diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml new file mode 100644 index 0000000..7fb8ed0 --- /dev/null +++ b/.idea/codeStyleSettings.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/node-steamcommunity.iml b/.idea/node-steamcommunity.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/.idea/node-steamcommunity.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/watcherTasks.xml b/.idea/watcherTasks.xml new file mode 100644 index 0000000..9338ba6 --- /dev/null +++ b/.idea/watcherTasks.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/components/chat.js b/components/chat.js index 21e743a..ae35f6d 100644 --- a/components/chat.js +++ b/components/chat.js @@ -5,17 +5,22 @@ SteamCommunity.ChatState = require('../resources/EChatState.js'); SteamCommunity.PersonaState = require('../resources/EPersonaState.js'); SteamCommunity.PersonaStateFlag = require('../resources/EPersonaStateFlag.js'); +/** + * @deprecated No support for new Steam chat. Use steam-user instead. + * @param {int} interval + * @param {string} uiMode + */ SteamCommunity.prototype.chatLogon = function(interval, uiMode) { if(this.chatState == SteamCommunity.ChatState.LoggingOn || this.chatState == SteamCommunity.ChatState.LoggedOn) { return; } - + interval = interval || 500; uiMode = uiMode || "web"; - + this.emit('debug', 'Requesting chat WebAPI token'); this.chatState = SteamCommunity.ChatState.LoggingOn; - + var self = this; this.getWebApiOauthToken(function(err, token) { if(err) { @@ -32,7 +37,7 @@ SteamCommunity.prototype.chatLogon = function(interval, uiMode) { self.emit('debug', "Cannot get oauth token: " + err.message); return; } - + self.httpRequestPost({ "uri": "https://api.steampowered.com/ISteamWebUserPresenceOAuth/Logon/v1", "form": { @@ -48,7 +53,7 @@ SteamCommunity.prototype.chatLogon = function(interval, uiMode) { setTimeout(self.chatLogon.bind(self), 5000); return; } - + if(body.error != 'OK') { self.chatState = SteamCommunity.ChatState.LogOnFailed; self.emit('chatLogOnFailed', new Error(body.error), false); @@ -56,7 +61,7 @@ SteamCommunity.prototype.chatLogon = function(interval, uiMode) { setTimeout(self.chatLogon.bind(self), 5000); return; } - + self._chat = { "umqid": body.umqid, "message": body.message, @@ -64,9 +69,9 @@ SteamCommunity.prototype.chatLogon = function(interval, uiMode) { "interval": interval, "uiMode": uiMode }; - + self.chatFriends = {}; - + self.chatState = SteamCommunity.ChatState.LoggedOn; self.emit('chatLoggedOn'); self._chatPoll(); @@ -74,20 +79,27 @@ SteamCommunity.prototype.chatLogon = function(interval, uiMode) { }); }; +/** + * @deprecated No support for new Steam chat. Use steam-user instead. + * @param {string|SteamID} recipient + * @param {string} text + * @param {string} [type] + * @param {function} [callback] + */ SteamCommunity.prototype.chatMessage = function(recipient, text, type, callback) { if(this.chatState != SteamCommunity.ChatState.LoggedOn) { throw new Error("Chat must be logged on before messages can be sent"); } - + if(typeof recipient === 'string') { recipient = new SteamID(recipient); } - + if(typeof type === 'function') { callback = type; type = 'saytext'; } - + type = type || 'saytext'; var self = this; @@ -105,12 +117,12 @@ SteamCommunity.prototype.chatMessage = function(recipient, text, type, callback) if(!callback) { return; } - + if (err) { callback(err); return; } - + if(body.error != 'OK') { callback(new Error(body.error)); } else { @@ -119,6 +131,9 @@ SteamCommunity.prototype.chatMessage = function(recipient, text, type, callback) }, "steamcommunity"); }; +/** + * @deprecated No support for new Steam chat. Use steam-user instead. + */ SteamCommunity.prototype.chatLogoff = function() { var self = this; this.httpRequestPost({ @@ -141,9 +156,12 @@ SteamCommunity.prototype.chatLogoff = function() { }, "steamcommunity"); }; +/** + * @private + */ SteamCommunity.prototype._chatPoll = function() { this.emit('debug', 'Doing chat poll'); - + var self = this; this.httpRequestPost({ "uri": "https://api.steampowered.com/ISteamWebUserPresenceOAuth/Poll/v1", @@ -161,9 +179,9 @@ SteamCommunity.prototype._chatPoll = function() { if (self.chatState == SteamCommunity.ChatState.Offline) { return; } - + self._chat.timer = setTimeout(self._chatPoll.bind(self), self._chat.interval); - + if(err || response.statusCode != 200) { self.emit('debug', 'Error in chat poll: ' + (err ? err.message : "HTTP error " + response.statusCode)); if (err.message == "Not Logged On") { @@ -172,7 +190,7 @@ SteamCommunity.prototype._chatPoll = function() { return; } - + if(!body || body.error != 'OK') { self.emit('debug', 'Error in chat poll: ' + (body && body.error ? body.error : "Malformed response")); if (body && body.error && body.error == "Not Logged On") { @@ -181,29 +199,29 @@ SteamCommunity.prototype._chatPoll = function() { return; } - + self._chat.message = body.messagelast; - + (body.messages || []).forEach(function(message) { var sender = new SteamID(); sender.universe = SteamID.Universe.PUBLIC; sender.type = SteamID.Type.INDIVIDUAL; sender.instance = SteamID.Instance.DESKTOP; sender.accountid = message.accountid_from; - + switch(message.type) { case 'personastate': self._chatUpdatePersona(sender); break; - + case 'saytext': self.emit('chatMessage', sender, message.text); break; - + case 'typing': self.emit('chatTyping', sender); break; - + default: self.emit('debug', 'Unhandled chat message type: ' + message.type); } @@ -211,6 +229,9 @@ SteamCommunity.prototype._chatPoll = function() { }, "steamcommunity"); }; +/** + * @private + */ SteamCommunity.prototype._relogWebChat = function() { this.emit('debug', "Relogging web chat"); clearTimeout(this._chat.timer); @@ -218,6 +239,10 @@ SteamCommunity.prototype._relogWebChat = function() { this.chatLogon(this._chat.interval, this._chat.uiMode); }; +/** + * @param {SteamID} steamID + * @private + */ SteamCommunity.prototype._chatUpdatePersona = function(steamID) { if (!this.chatFriends || this.chatState == SteamCommunity.ChatState.Offline) { return; // we no longer care @@ -240,7 +265,7 @@ SteamCommunity.prototype._chatUpdatePersona = function(steamID) { }, 2000); return; } - + var persona = { "steamID": steamID, "personaName": body.m_strName, @@ -255,4 +280,4 @@ SteamCommunity.prototype._chatUpdatePersona = function(steamID) { self.emit('chatPersonaState', steamID, persona); self.chatFriends[steamID.getSteamID64()] = persona; }, "steamcommunity"); -}; \ No newline at end of file +}; diff --git a/components/webapi.js b/components/webapi.js index dc507fa..2a853d0 100644 --- a/components/webapi.js +++ b/components/webapi.js @@ -14,7 +14,7 @@ SteamCommunity.prototype.getWebApiKey = function(domain, callback) { if(body.match(/

Access Denied<\/h2>/)) { return callback(new Error("Access Denied")); } - + if(body.match(/You must have a validated email address to create a Steam Web API key./)) { return callback(new Error("You must have a validated email address to create a Steam Web API key.")); } @@ -44,6 +44,10 @@ SteamCommunity.prototype.getWebApiKey = function(domain, callback) { }, "steamcommunity"); }; +/** + * @deprecated No longer works if not logged in via mobile login. Will be removed in a future release. + * @param {function} callback + */ SteamCommunity.prototype.getWebApiOauthToken = function(callback) { var self = this; From 4710afa28b5cf5d064a30a17191f9c4badb02f77 Mon Sep 17 00:00:00 2001 From: Alex Corn Date: Wed, 13 Feb 2019 17:40:45 -0500 Subject: [PATCH 4/7] Added getClientLogonToken --- index.js | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index c7a2632..2409519 100644 --- a/index.js +++ b/index.js @@ -13,7 +13,7 @@ module.exports = SteamCommunity; SteamCommunity.SteamID = SteamID; SteamCommunity.ConfirmationType = require('./resources/EConfirmationType.js'); -SteamCommunity.EResult = require('./resources/EResult.js') +SteamCommunity.EResult = require('./resources/EResult.js'); function SteamCommunity(options) { @@ -249,6 +249,36 @@ SteamCommunity.prototype.oAuthLogin = function(steamguard, token, callback) { }, "steamcommunity"); }; +/** + * Get a token that can be used to log onto Steam using steam-user. + * @param {function} callback + */ +SteamCommunity.prototype.getClientLogonToken = function(callback) { + this.httpRequestGet({ + "uri": "https://steamcommunity.com/chat/clientjstoken", + "json": true + }, (err, res, body) => { + if (err || res.statusCode != 200) { + callback(err ? err : new Error('HTTP error ' + res.statusCode)); + return; + } + + if (!body.logged_in) { + let e = new Error('Not Logged In'); + callback(e); + this._notifySessionExpired(e); + return; + } + + if (!body.account_name || !body.token) { + callback(new Error('Malformed response')); + return; + } + + callback(null, body); + }); +}; + SteamCommunity.prototype._setCookie = function(cookie, secure) { var protocol = secure ? "https" : "http"; cookie.secure = !!secure; From cfd932dc72f78179021a9b7577de6dccc8a6922c Mon Sep 17 00:00:00 2001 From: Alex Corn Date: Wed, 13 Feb 2019 17:42:28 -0500 Subject: [PATCH 5/7] Changed output format of getClientLogonToken --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 2409519..cb811c5 100644 --- a/index.js +++ b/index.js @@ -275,7 +275,10 @@ SteamCommunity.prototype.getClientLogonToken = function(callback) { return; } - callback(null, body); + callback(null, { + "accountName": body.account_name, + "webLogonToken": body.token + }); }); }; From 22d34b1faf9b6775f87f5390c957642ed6ab8f20 Mon Sep 17 00:00:00 2001 From: Alex Corn Date: Wed, 13 Feb 2019 17:59:33 -0500 Subject: [PATCH 6/7] Added Steam ID to output of getClientLogonToken --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index cb811c5..df80436 100644 --- a/index.js +++ b/index.js @@ -270,12 +270,13 @@ SteamCommunity.prototype.getClientLogonToken = function(callback) { return; } - if (!body.account_name || !body.token) { + if (!body.steamid || !body.account_name || !body.token) { callback(new Error('Malformed response')); return; } callback(null, { + "steamID": new SteamID(body.steamid), "accountName": body.account_name, "webLogonToken": body.token }); From 224b7b85e01564195201188faf1adaab92e71510 Mon Sep 17 00:00:00 2001 From: Alex Corn Date: Wed, 13 Feb 2019 17:59:41 -0500 Subject: [PATCH 7/7] 3.39.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index eaa6106..8c12c1b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "steamcommunity", - "version": "3.38.0", + "version": "3.39.0", "description": "Provides an interface for logging into and interacting with the Steam Community website", "keywords": [ "steam",