steamcommunity 3.48.2 → 3.48.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,158 +1,158 @@
1
- var SteamID = require('steamid');
2
-
3
- var SteamCommunity = require('../index.js');
4
-
5
-
6
- /**
7
- * Deletes a comment from a sharedfile's comment section
8
- * @param {SteamID | String} userID - ID of the user associated to this sharedfile
9
- * @param {String} sharedFileId - ID of the sharedfile
10
- * @param {String} cid - ID of the comment to delete
11
- * @param {function} callback - Takes only an Error object/null as the first argument
12
- */
13
- SteamCommunity.prototype.deleteSharedFileComment = function(userID, sharedFileId, cid, callback) {
14
- if (typeof userID === "string") {
15
- userID = new SteamID(userID);
16
- }
17
-
18
- this.httpRequestPost({
19
- "uri": `https://steamcommunity.com/comment/PublishedFile_Public/delete/${userID.toString()}/${sharedFileId}/`,
20
- "form": {
21
- "gidcomment": cid,
22
- "count": 10,
23
- "sessionid": this.getSessionID()
24
- }
25
- }, function(err, response, body) {
26
- if (!callback) {
27
- return;
28
- }
29
-
30
- callback(err);
31
- }, "steamcommunity");
32
- };
33
-
34
- /**
35
- * Favorites a sharedfile
36
- * @param {String} sharedFileId - ID of the sharedfile
37
- * @param {String} appid - ID of the app associated to this sharedfile
38
- * @param {function} callback - Takes only an Error object/null as the first argument
39
- */
40
- SteamCommunity.prototype.favoriteSharedFile = function(sharedFileId, appid, callback) {
41
- this.httpRequestPost({
42
- "uri": "https://steamcommunity.com/sharedfiles/favorite",
43
- "form": {
44
- "id": sharedFileId,
45
- "appid": appid,
46
- "sessionid": this.getSessionID()
47
- }
48
- }, function(err, response, body) {
49
- if (!callback) {
50
- return;
51
- }
52
-
53
- callback(err);
54
- }, "steamcommunity");
55
- };
56
-
57
- /**
58
- * Posts a comment to a sharedfile
59
- * @param {SteamID | String} userID - ID of the user associated to this sharedfile
60
- * @param {String} sharedFileId - ID of the sharedfile
61
- * @param {String} message - Content of the comment to post
62
- * @param {function} callback - Takes only an Error object/null as the first argument
63
- */
64
- SteamCommunity.prototype.postSharedFileComment = function(userID, sharedFileId, message, callback) {
65
- if (typeof userID === "string") {
66
- userID = new SteamID(userID);
67
- }
68
-
69
- this.httpRequestPost({
70
- "uri": `https://steamcommunity.com/comment/PublishedFile_Public/post/${userID.toString()}/${sharedFileId}/`,
71
- "form": {
72
- "comment": message,
73
- "count": 10,
74
- "sessionid": this.getSessionID()
75
- }
76
- }, function(err, response, body) {
77
- if (!callback) {
78
- return;
79
- }
80
-
81
- callback(err);
82
- }, "steamcommunity");
83
- };
84
-
85
- /**
86
- * Subscribes to a sharedfile's comment section. Note: Checkbox on webpage does not update
87
- * @param {SteamID | String} userID ID of the user associated to this sharedfile
88
- * @param {String} sharedFileId ID of the sharedfile
89
- * @param {function} callback - Takes only an Error object/null as the first argument
90
- */
91
- SteamCommunity.prototype.subscribeSharedFileComments = function(userID, sharedFileId, callback) {
92
- if (typeof userID === "string") {
93
- userID = new SteamID(userID);
94
- }
95
-
96
- this.httpRequestPost({
97
- "uri": `https://steamcommunity.com/comment/PublishedFile_Public/subscribe/${userID.toString()}/${sharedFileId}/`,
98
- "form": {
99
- "count": 10,
100
- "sessionid": this.getSessionID()
101
- }
102
- }, function(err, response, body) { // eslint-disable-line
103
- if (!callback) {
104
- return;
105
- }
106
-
107
- callback(err);
108
- }, "steamcommunity");
109
- };
110
-
111
- /**
112
- * Unfavorites a sharedfile
113
- * @param {String} sharedFileId - ID of the sharedfile
114
- * @param {String} appid - ID of the app associated to this sharedfile
115
- * @param {function} callback - Takes only an Error object/null as the first argument
116
- */
117
- SteamCommunity.prototype.unfavoriteSharedFile = function(sharedFileId, appid, callback) {
118
- this.httpRequestPost({
119
- "uri": "https://steamcommunity.com/sharedfiles/unfavorite",
120
- "form": {
121
- "id": sharedFileId,
122
- "appid": appid,
123
- "sessionid": this.getSessionID()
124
- }
125
- }, function(err, response, body) {
126
- if (!callback) {
127
- return;
128
- }
129
-
130
- callback(err);
131
- }, "steamcommunity");
132
- };
133
-
134
- /**
135
- * Unsubscribes from a sharedfile's comment section. Note: Checkbox on webpage does not update
136
- * @param {SteamID | String} userID - ID of the user associated to this sharedfile
137
- * @param {String} sharedFileId - ID of the sharedfile
138
- * @param {function} callback - Takes only an Error object/null as the first argument
139
- */
140
- SteamCommunity.prototype.unsubscribeSharedFileComments = function(userID, sharedFileId, callback) {
141
- if (typeof userID === "string") {
142
- userID = new SteamID(userID);
143
- }
144
-
145
- this.httpRequestPost({
146
- "uri": `https://steamcommunity.com/comment/PublishedFile_Public/unsubscribe/${userID.toString()}/${sharedFileId}/`,
147
- "form": {
148
- "count": 10,
149
- "sessionid": this.getSessionID()
150
- }
151
- }, function(err, response, body) { // eslint-disable-line
152
- if (!callback) {
153
- return;
154
- }
155
-
156
- callback(err);
157
- }, "steamcommunity");
158
- };
1
+ var SteamID = require('steamid');
2
+
3
+ var SteamCommunity = require('../index.js');
4
+
5
+
6
+ /**
7
+ * Deletes a comment from a sharedfile's comment section
8
+ * @param {SteamID | String} userID - ID of the user associated to this sharedfile
9
+ * @param {String} sharedFileId - ID of the sharedfile
10
+ * @param {String} cid - ID of the comment to delete
11
+ * @param {function} callback - Takes only an Error object/null as the first argument
12
+ */
13
+ SteamCommunity.prototype.deleteSharedFileComment = function(userID, sharedFileId, cid, callback) {
14
+ if (typeof userID === "string") {
15
+ userID = new SteamID(userID);
16
+ }
17
+
18
+ this.httpRequestPost({
19
+ "uri": `https://steamcommunity.com/comment/PublishedFile_Public/delete/${userID.toString()}/${sharedFileId}/`,
20
+ "form": {
21
+ "gidcomment": cid,
22
+ "count": 10,
23
+ "sessionid": this.getSessionID()
24
+ }
25
+ }, function(err, response, body) {
26
+ if (!callback) {
27
+ return;
28
+ }
29
+
30
+ callback(err);
31
+ }, "steamcommunity");
32
+ };
33
+
34
+ /**
35
+ * Favorites a sharedfile
36
+ * @param {String} sharedFileId - ID of the sharedfile
37
+ * @param {String} appid - ID of the app associated to this sharedfile
38
+ * @param {function} callback - Takes only an Error object/null as the first argument
39
+ */
40
+ SteamCommunity.prototype.favoriteSharedFile = function(sharedFileId, appid, callback) {
41
+ this.httpRequestPost({
42
+ "uri": "https://steamcommunity.com/sharedfiles/favorite",
43
+ "form": {
44
+ "id": sharedFileId,
45
+ "appid": appid,
46
+ "sessionid": this.getSessionID()
47
+ }
48
+ }, function(err, response, body) {
49
+ if (!callback) {
50
+ return;
51
+ }
52
+
53
+ callback(err);
54
+ }, "steamcommunity");
55
+ };
56
+
57
+ /**
58
+ * Posts a comment to a sharedfile
59
+ * @param {SteamID | String} userID - ID of the user associated to this sharedfile
60
+ * @param {String} sharedFileId - ID of the sharedfile
61
+ * @param {String} message - Content of the comment to post
62
+ * @param {function} callback - Takes only an Error object/null as the first argument
63
+ */
64
+ SteamCommunity.prototype.postSharedFileComment = function(userID, sharedFileId, message, callback) {
65
+ if (typeof userID === "string") {
66
+ userID = new SteamID(userID);
67
+ }
68
+
69
+ this.httpRequestPost({
70
+ "uri": `https://steamcommunity.com/comment/PublishedFile_Public/post/${userID.toString()}/${sharedFileId}/`,
71
+ "form": {
72
+ "comment": message,
73
+ "count": 10,
74
+ "sessionid": this.getSessionID()
75
+ }
76
+ }, function(err, response, body) {
77
+ if (!callback) {
78
+ return;
79
+ }
80
+
81
+ callback(err);
82
+ }, "steamcommunity");
83
+ };
84
+
85
+ /**
86
+ * Subscribes to a sharedfile's comment section. Note: Checkbox on webpage does not update
87
+ * @param {SteamID | String} userID ID of the user associated to this sharedfile
88
+ * @param {String} sharedFileId ID of the sharedfile
89
+ * @param {function} callback - Takes only an Error object/null as the first argument
90
+ */
91
+ SteamCommunity.prototype.subscribeSharedFileComments = function(userID, sharedFileId, callback) {
92
+ if (typeof userID === "string") {
93
+ userID = new SteamID(userID);
94
+ }
95
+
96
+ this.httpRequestPost({
97
+ "uri": `https://steamcommunity.com/comment/PublishedFile_Public/subscribe/${userID.toString()}/${sharedFileId}/`,
98
+ "form": {
99
+ "count": 10,
100
+ "sessionid": this.getSessionID()
101
+ }
102
+ }, function(err, response, body) { // eslint-disable-line
103
+ if (!callback) {
104
+ return;
105
+ }
106
+
107
+ callback(err);
108
+ }, "steamcommunity");
109
+ };
110
+
111
+ /**
112
+ * Unfavorites a sharedfile
113
+ * @param {String} sharedFileId - ID of the sharedfile
114
+ * @param {String} appid - ID of the app associated to this sharedfile
115
+ * @param {function} callback - Takes only an Error object/null as the first argument
116
+ */
117
+ SteamCommunity.prototype.unfavoriteSharedFile = function(sharedFileId, appid, callback) {
118
+ this.httpRequestPost({
119
+ "uri": "https://steamcommunity.com/sharedfiles/unfavorite",
120
+ "form": {
121
+ "id": sharedFileId,
122
+ "appid": appid,
123
+ "sessionid": this.getSessionID()
124
+ }
125
+ }, function(err, response, body) {
126
+ if (!callback) {
127
+ return;
128
+ }
129
+
130
+ callback(err);
131
+ }, "steamcommunity");
132
+ };
133
+
134
+ /**
135
+ * Unsubscribes from a sharedfile's comment section. Note: Checkbox on webpage does not update
136
+ * @param {SteamID | String} userID - ID of the user associated to this sharedfile
137
+ * @param {String} sharedFileId - ID of the sharedfile
138
+ * @param {function} callback - Takes only an Error object/null as the first argument
139
+ */
140
+ SteamCommunity.prototype.unsubscribeSharedFileComments = function(userID, sharedFileId, callback) {
141
+ if (typeof userID === "string") {
142
+ userID = new SteamID(userID);
143
+ }
144
+
145
+ this.httpRequestPost({
146
+ "uri": `https://steamcommunity.com/comment/PublishedFile_Public/unsubscribe/${userID.toString()}/${sharedFileId}/`,
147
+ "form": {
148
+ "count": 10,
149
+ "sessionid": this.getSessionID()
150
+ }
151
+ }, function(err, response, body) { // eslint-disable-line
152
+ if (!callback) {
153
+ return;
154
+ }
155
+
156
+ callback(err);
157
+ }, "steamcommunity");
158
+ };
@@ -1,152 +1,152 @@
1
- var SteamTotp = require('steam-totp');
2
- var SteamCommunity = require('../index.js');
3
-
4
- var ETwoFactorTokenType = {
5
- None: 0, // No token-based two-factor authentication
6
- ValveMobileApp: 1, // Tokens generated using Valve's special charset (5 digits, alphanumeric)
7
- ThirdParty: 2 // Tokens generated using literally everyone else's standard charset (6 digits, numeric). This is disabled.
8
- };
9
-
10
- SteamCommunity.prototype.enableTwoFactor = function(callback) {
11
- this._verifyMobileAccessToken();
12
-
13
- if (!this.mobileAccessToken) {
14
- callback(new Error('No mobile access token available. Provide one by calling setMobileAppAccessToken()'));
15
- return;
16
- }
17
-
18
- this.httpRequestPost({
19
- uri: "https://api.steampowered.com/ITwoFactorService/AddAuthenticator/v1/?access_token=" + this.mobileAccessToken,
20
- // TODO: Send this as protobuf to more closely mimic official app behavior
21
- form: {
22
- steamid: this.steamID.getSteamID64(),
23
- authenticator_type: ETwoFactorTokenType.ValveMobileApp,
24
- device_identifier: SteamTotp.getDeviceID(this.steamID),
25
- sms_phone_id: '1',
26
- version: 2
27
- },
28
- json: true
29
- }, (err, response, body) => {
30
- if (err) {
31
- callback(err);
32
- return;
33
- }
34
-
35
- if (!body.response) {
36
- callback(new Error('Malformed response'));
37
- return;
38
- }
39
-
40
- if (body.response.status != 1) {
41
- var error = new Error('Error ' + body.response.status);
42
- error.eresult = body.response.status;
43
- callback(error);
44
- return;
45
- }
46
-
47
- callback(null, body.response);
48
- }, 'steamcommunity');
49
- };
50
-
51
- SteamCommunity.prototype.finalizeTwoFactor = function(secret, activationCode, callback) {
52
- this._verifyMobileAccessToken();
53
-
54
- if (!this.mobileAccessToken) {
55
- callback(new Error('No mobile access token available. Provide one by calling setMobileAppAccessToken()'));
56
- return;
57
- }
58
-
59
- let attemptsLeft = 30;
60
- let diff = 0;
61
-
62
- let finalize = () => {
63
- let code = SteamTotp.generateAuthCode(secret, diff);
64
-
65
- this.httpRequestPost({
66
- uri: 'https://api.steampowered.com/ITwoFactorService/FinalizeAddAuthenticator/v1/?access_token=' + this.mobileAccessToken,
67
- form: {
68
- steamid: this.steamID.getSteamID64(),
69
- authenticator_code: code,
70
- authenticator_time: Math.floor(Date.now() / 1000),
71
- activation_code: activationCode
72
- },
73
- json: true
74
- }, function(err, response, body) {
75
- if (err) {
76
- callback(err);
77
- return;
78
- }
79
-
80
- if (!body.response) {
81
- callback(new Error('Malformed response'));
82
- return;
83
- }
84
-
85
- body = body.response;
86
-
87
- if (body.server_time) {
88
- diff = body.server_time - Math.floor(Date.now() / 1000);
89
- }
90
-
91
- if (body.status == 89) {
92
- callback(new Error('Invalid activation code'));
93
- } else if(body.want_more) {
94
- attemptsLeft--;
95
- diff += 30;
96
-
97
- finalize();
98
- } else if(!body.success) {
99
- callback(new Error('Error ' + body.status));
100
- } else {
101
- callback(null);
102
- }
103
- }, 'steamcommunity');
104
- }
105
-
106
- SteamTotp.getTimeOffset(function(err, offset, latency) {
107
- if (err) {
108
- callback(err);
109
- return;
110
- }
111
-
112
- diff = offset;
113
- finalize();
114
- });
115
- };
116
-
117
- SteamCommunity.prototype.disableTwoFactor = function(revocationCode, callback) {
118
- this._verifyMobileAccessToken();
119
-
120
- if (!this.mobileAccessToken) {
121
- callback(new Error('No mobile access token available. Provide one by calling setMobileAppAccessToken()'));
122
- return;
123
- }
124
-
125
- this.httpRequestPost({
126
- uri: 'https://api.steampowered.com/ITwoFactorService/RemoveAuthenticator/v1/?access_token=' + this.mobileAccessToken,
127
- form: {
128
- steamid: this.steamID.getSteamID64(),
129
- revocation_code: revocationCode,
130
- steamguard_scheme: 1
131
- },
132
- json: true
133
- }, function(err, response, body) {
134
- if (err) {
135
- callback(err);
136
- return;
137
- }
138
-
139
- if (!body.response) {
140
- callback(new Error('Malformed response'));
141
- return;
142
- }
143
-
144
- if (!body.response.success) {
145
- callback(new Error('Request failed'));
146
- return;
147
- }
148
-
149
- // success = true means it worked
150
- callback(null);
151
- }, 'steamcommunity');
152
- };
1
+ var SteamTotp = require('steam-totp');
2
+ var SteamCommunity = require('../index.js');
3
+
4
+ var ETwoFactorTokenType = {
5
+ None: 0, // No token-based two-factor authentication
6
+ ValveMobileApp: 1, // Tokens generated using Valve's special charset (5 digits, alphanumeric)
7
+ ThirdParty: 2 // Tokens generated using literally everyone else's standard charset (6 digits, numeric). This is disabled.
8
+ };
9
+
10
+ SteamCommunity.prototype.enableTwoFactor = function(callback) {
11
+ this._verifyMobileAccessToken();
12
+
13
+ if (!this.mobileAccessToken) {
14
+ callback(new Error('No mobile access token available. Provide one by calling setMobileAppAccessToken()'));
15
+ return;
16
+ }
17
+
18
+ this.httpRequestPost({
19
+ uri: "https://api.steampowered.com/ITwoFactorService/AddAuthenticator/v1/?access_token=" + this.mobileAccessToken,
20
+ // TODO: Send this as protobuf to more closely mimic official app behavior
21
+ form: {
22
+ steamid: this.steamID.getSteamID64(),
23
+ authenticator_type: ETwoFactorTokenType.ValveMobileApp,
24
+ device_identifier: SteamTotp.getDeviceID(this.steamID),
25
+ sms_phone_id: '1',
26
+ version: 2
27
+ },
28
+ json: true
29
+ }, (err, response, body) => {
30
+ if (err) {
31
+ callback(err);
32
+ return;
33
+ }
34
+
35
+ if (!body.response) {
36
+ callback(new Error('Malformed response'));
37
+ return;
38
+ }
39
+
40
+ if (body.response.status != 1) {
41
+ var error = new Error('Error ' + body.response.status);
42
+ error.eresult = body.response.status;
43
+ callback(error);
44
+ return;
45
+ }
46
+
47
+ callback(null, body.response);
48
+ }, 'steamcommunity');
49
+ };
50
+
51
+ SteamCommunity.prototype.finalizeTwoFactor = function(secret, activationCode, callback) {
52
+ this._verifyMobileAccessToken();
53
+
54
+ if (!this.mobileAccessToken) {
55
+ callback(new Error('No mobile access token available. Provide one by calling setMobileAppAccessToken()'));
56
+ return;
57
+ }
58
+
59
+ let attemptsLeft = 30;
60
+ let diff = 0;
61
+
62
+ let finalize = () => {
63
+ let code = SteamTotp.generateAuthCode(secret, diff);
64
+
65
+ this.httpRequestPost({
66
+ uri: 'https://api.steampowered.com/ITwoFactorService/FinalizeAddAuthenticator/v1/?access_token=' + this.mobileAccessToken,
67
+ form: {
68
+ steamid: this.steamID.getSteamID64(),
69
+ authenticator_code: code,
70
+ authenticator_time: Math.floor(Date.now() / 1000),
71
+ activation_code: activationCode
72
+ },
73
+ json: true
74
+ }, function(err, response, body) {
75
+ if (err) {
76
+ callback(err);
77
+ return;
78
+ }
79
+
80
+ if (!body.response) {
81
+ callback(new Error('Malformed response'));
82
+ return;
83
+ }
84
+
85
+ body = body.response;
86
+
87
+ if (body.server_time) {
88
+ diff = body.server_time - Math.floor(Date.now() / 1000);
89
+ }
90
+
91
+ if (body.status == 89) {
92
+ callback(new Error('Invalid activation code'));
93
+ } else if(body.want_more) {
94
+ attemptsLeft--;
95
+ diff += 30;
96
+
97
+ finalize();
98
+ } else if(!body.success) {
99
+ callback(new Error('Error ' + body.status));
100
+ } else {
101
+ callback(null);
102
+ }
103
+ }, 'steamcommunity');
104
+ }
105
+
106
+ SteamTotp.getTimeOffset(function(err, offset, latency) {
107
+ if (err) {
108
+ callback(err);
109
+ return;
110
+ }
111
+
112
+ diff = offset;
113
+ finalize();
114
+ });
115
+ };
116
+
117
+ SteamCommunity.prototype.disableTwoFactor = function(revocationCode, callback) {
118
+ this._verifyMobileAccessToken();
119
+
120
+ if (!this.mobileAccessToken) {
121
+ callback(new Error('No mobile access token available. Provide one by calling setMobileAppAccessToken()'));
122
+ return;
123
+ }
124
+
125
+ this.httpRequestPost({
126
+ uri: 'https://api.steampowered.com/ITwoFactorService/RemoveAuthenticator/v1/?access_token=' + this.mobileAccessToken,
127
+ form: {
128
+ steamid: this.steamID.getSteamID64(),
129
+ revocation_code: revocationCode,
130
+ steamguard_scheme: 1
131
+ },
132
+ json: true
133
+ }, function(err, response, body) {
134
+ if (err) {
135
+ callback(err);
136
+ return;
137
+ }
138
+
139
+ if (!body.response) {
140
+ callback(new Error('Malformed response'));
141
+ return;
142
+ }
143
+
144
+ if (!body.response.success) {
145
+ callback(new Error('Request failed'));
146
+ return;
147
+ }
148
+
149
+ // success = true means it worked
150
+ callback(null);
151
+ }, 'steamcommunity');
152
+ };