steamcommunity 3.46.1 → 3.47.1

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.
Files changed (51) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +22 -22
  3. package/classes/CConfirmation.js +37 -37
  4. package/classes/CEconItem.js +120 -120
  5. package/classes/CMarketItem.js +189 -189
  6. package/classes/CMarketSearchResult.js +89 -89
  7. package/classes/CSteamGroup.js +155 -155
  8. package/classes/CSteamUser.js +225 -217
  9. package/components/chat.js +283 -283
  10. package/components/confirmations.js +428 -428
  11. package/components/groups.js +798 -732
  12. package/components/help.js +64 -64
  13. package/components/helpers.js +128 -108
  14. package/components/http.js +150 -150
  15. package/components/inventoryhistory.js +173 -173
  16. package/components/login.js +110 -0
  17. package/components/market.js +387 -387
  18. package/components/profile.js +475 -475
  19. package/components/twofactor.js +152 -152
  20. package/components/users.js +831 -767
  21. package/components/webapi.js +118 -118
  22. package/examples/README.md +35 -35
  23. package/examples/accept_all_confirmations.js +173 -173
  24. package/examples/disable_twofactor.js +135 -135
  25. package/examples/edit-group-announcement.js +118 -118
  26. package/examples/enable_twofactor.js +182 -182
  27. package/index.js +13 -151
  28. package/package.json +11 -6
  29. package/resources/EChatState.js +14 -14
  30. package/resources/EConfirmationType.js +12 -12
  31. package/resources/EFriendRelationship.js +23 -23
  32. package/resources/EPersonaState.js +23 -23
  33. package/resources/EPersonaStateFlag.js +32 -32
  34. package/resources/EResult.js +254 -254
  35. package/.editorconfig +0 -13
  36. package/.github/FUNDING.yml +0 -2
  37. package/.idea/.name +0 -1
  38. package/.idea/codeStyleSettings.xml +0 -13
  39. package/.idea/codeStyles/Project.xml +0 -15
  40. package/.idea/codeStyles/codeStyleConfig.xml +0 -6
  41. package/.idea/copyright/profiles_settings.xml +0 -3
  42. package/.idea/encodings.xml +0 -6
  43. package/.idea/inspectionProfiles/Project_Default.xml +0 -11
  44. package/.idea/jsLibraryMappings.xml +0 -6
  45. package/.idea/misc.xml +0 -6
  46. package/.idea/modules.xml +0 -9
  47. package/.idea/node-steamcommunity.iml +0 -8
  48. package/.idea/steamcommunity.iml +0 -10
  49. package/.idea/vcs.xml +0 -7
  50. package/.idea/watcherTasks.xml +0 -4
  51. package/CONTRIBUTING.md +0 -36
@@ -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_time: Math.floor(Date.now() / 1000),
24
- authenticator_type: ETwoFactorTokenType.ValveMobileApp,
25
- device_identifier: SteamTotp.getDeviceID(this.steamID),
26
- sms_phone_id: '1'
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_time: Math.floor(Date.now() / 1000),
24
+ authenticator_type: ETwoFactorTokenType.ValveMobileApp,
25
+ device_identifier: SteamTotp.getDeviceID(this.steamID),
26
+ sms_phone_id: '1'
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
+ };