steamcommunity 3.47.1 → 3.48.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.
- package/LICENSE +21 -21
- package/README.md +22 -22
- package/classes/CConfirmation.js +37 -37
- package/classes/CEconItem.js +120 -120
- package/classes/CSteamSharedFile.js +221 -221
- package/classes/CSteamUser.js +225 -225
- package/components/confirmations.js +428 -428
- package/components/groups.js +798 -798
- package/components/help.js +64 -64
- package/components/helpers.js +128 -128
- package/components/http.js +150 -150
- package/components/inventoryhistory.js +173 -173
- package/components/login.js +110 -110
- package/components/market.js +387 -387
- package/components/profile.js +475 -475
- package/components/sharedfiles.js +158 -158
- package/components/twofactor.js +152 -152
- package/components/users.js +831 -831
- package/components/webapi.js +128 -25
- package/examples/README.md +35 -35
- package/examples/accept_all_confirmations.js +173 -173
- package/examples/disable_twofactor.js +98 -135
- package/examples/enable_twofactor.js +143 -182
- package/index.js +466 -462
- package/package.json +44 -44
- package/resources/EChatState.js +14 -14
- package/resources/EConfirmationType.js +12 -12
- package/resources/EFriendRelationship.js +23 -23
- package/resources/EPersonaState.js +23 -23
- package/resources/EPersonaStateFlag.js +32 -32
- package/resources/EResult.js +254 -254
- package/resources/ESharedFileType.js +13 -13
package/components/help.js
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
const SteamCommunity = require('../index.js');
|
|
2
|
-
|
|
3
|
-
const Helpers = require('./helpers.js');
|
|
4
|
-
|
|
5
|
-
const HELP_SITE_DOMAIN = 'https://help.steampowered.com';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Restore a previously removed steam package from your steam account.
|
|
9
|
-
* @param {int|string} packageID
|
|
10
|
-
* @param {function} callback
|
|
11
|
-
*/
|
|
12
|
-
SteamCommunity.prototype.restorePackage = function(packageID, callback) {
|
|
13
|
-
this.httpRequestPost({
|
|
14
|
-
uri: HELP_SITE_DOMAIN + '/wizard/AjaxDoPackageRestore',
|
|
15
|
-
form: {
|
|
16
|
-
packageid: packageID,
|
|
17
|
-
sessionid: this.getSessionID(HELP_SITE_DOMAIN),
|
|
18
|
-
wizard_ajax: 1
|
|
19
|
-
},
|
|
20
|
-
json: true
|
|
21
|
-
}, wizardAjaxHandler(callback));
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Remove a steam package from your steam account.
|
|
26
|
-
* @param {int|string} packageID
|
|
27
|
-
* @param {function} callback
|
|
28
|
-
*/
|
|
29
|
-
SteamCommunity.prototype.removePackage = function(packageID, callback) {
|
|
30
|
-
this.httpRequestPost({
|
|
31
|
-
uri: HELP_SITE_DOMAIN + '/wizard/AjaxDoPackageRemove',
|
|
32
|
-
form: {
|
|
33
|
-
packageid: packageID,
|
|
34
|
-
sessionid: this.getSessionID(HELP_SITE_DOMAIN),
|
|
35
|
-
wizard_ajax: 1
|
|
36
|
-
},
|
|
37
|
-
json: true
|
|
38
|
-
}, wizardAjaxHandler(callback));
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Returns a handler for wizard ajax HTTP requests.
|
|
43
|
-
* @param {function} callback
|
|
44
|
-
* @returns {(function(*=, *, *): void)|*}
|
|
45
|
-
*/
|
|
46
|
-
function wizardAjaxHandler(callback) {
|
|
47
|
-
return (err, res, body) => {
|
|
48
|
-
if (!callback) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (err) {
|
|
53
|
-
callback(err);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (!body.success) {
|
|
58
|
-
callback(body.errorMsg ? new Error(body.errorMsg) : Helpers.eresultError(body.success));
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
callback(null);
|
|
63
|
-
};
|
|
64
|
-
}
|
|
1
|
+
const SteamCommunity = require('../index.js');
|
|
2
|
+
|
|
3
|
+
const Helpers = require('./helpers.js');
|
|
4
|
+
|
|
5
|
+
const HELP_SITE_DOMAIN = 'https://help.steampowered.com';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Restore a previously removed steam package from your steam account.
|
|
9
|
+
* @param {int|string} packageID
|
|
10
|
+
* @param {function} callback
|
|
11
|
+
*/
|
|
12
|
+
SteamCommunity.prototype.restorePackage = function(packageID, callback) {
|
|
13
|
+
this.httpRequestPost({
|
|
14
|
+
uri: HELP_SITE_DOMAIN + '/wizard/AjaxDoPackageRestore',
|
|
15
|
+
form: {
|
|
16
|
+
packageid: packageID,
|
|
17
|
+
sessionid: this.getSessionID(HELP_SITE_DOMAIN),
|
|
18
|
+
wizard_ajax: 1
|
|
19
|
+
},
|
|
20
|
+
json: true
|
|
21
|
+
}, wizardAjaxHandler(callback));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Remove a steam package from your steam account.
|
|
26
|
+
* @param {int|string} packageID
|
|
27
|
+
* @param {function} callback
|
|
28
|
+
*/
|
|
29
|
+
SteamCommunity.prototype.removePackage = function(packageID, callback) {
|
|
30
|
+
this.httpRequestPost({
|
|
31
|
+
uri: HELP_SITE_DOMAIN + '/wizard/AjaxDoPackageRemove',
|
|
32
|
+
form: {
|
|
33
|
+
packageid: packageID,
|
|
34
|
+
sessionid: this.getSessionID(HELP_SITE_DOMAIN),
|
|
35
|
+
wizard_ajax: 1
|
|
36
|
+
},
|
|
37
|
+
json: true
|
|
38
|
+
}, wizardAjaxHandler(callback));
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Returns a handler for wizard ajax HTTP requests.
|
|
43
|
+
* @param {function} callback
|
|
44
|
+
* @returns {(function(*=, *, *): void)|*}
|
|
45
|
+
*/
|
|
46
|
+
function wizardAjaxHandler(callback) {
|
|
47
|
+
return (err, res, body) => {
|
|
48
|
+
if (!callback) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (err) {
|
|
53
|
+
callback(err);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!body.success) {
|
|
58
|
+
callback(body.errorMsg ? new Error(body.errorMsg) : Helpers.eresultError(body.success));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
callback(null);
|
|
63
|
+
};
|
|
64
|
+
}
|
package/components/helpers.js
CHANGED
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
const request = require('request');
|
|
2
|
-
const SteamID = require('steamid');
|
|
3
|
-
const xml2js = require('xml2js');
|
|
4
|
-
|
|
5
|
-
const EResult = require('../resources/EResult.js');
|
|
6
|
-
|
|
7
|
-
exports.isSteamID = function(input) {
|
|
8
|
-
var keys = Object.keys(input);
|
|
9
|
-
if (keys.length != 4) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// Make sure it has the keys we expect
|
|
14
|
-
keys = keys.filter(function(item) {
|
|
15
|
-
return ['universe', 'type', 'instance', 'accountid'].indexOf(item) != -1;
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
return keys.length == 4;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
exports.decodeSteamTime = function(time) {
|
|
22
|
-
var date = new Date();
|
|
23
|
-
|
|
24
|
-
if (time.includes("@")) {
|
|
25
|
-
var parts = time.split('@');
|
|
26
|
-
if (!parts[0].includes(",")) {
|
|
27
|
-
// no year, assume current year
|
|
28
|
-
parts[0] += ", " + date.getFullYear();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
date = new Date(parts.join('@').replace(/(am|pm)/, ' $1') + " UTC"); // add a space so JS can decode it
|
|
32
|
-
} else {
|
|
33
|
-
// Relative date
|
|
34
|
-
var amount = time.replace(/(\d) (minutes|hour|hours) ago/, "$1");
|
|
35
|
-
|
|
36
|
-
if(time.includes("minutes")) {
|
|
37
|
-
date.setMinutes(date.getMinutes() - amount);
|
|
38
|
-
} else if(time.match(/hour|hours/)) {
|
|
39
|
-
date.setHours(date.getHours() - amount);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return date;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Get an Error object for a particular EResult
|
|
48
|
-
* @param {int} eresult
|
|
49
|
-
* @returns {null|Error}
|
|
50
|
-
*/
|
|
51
|
-
exports.eresultError = function(eresult) {
|
|
52
|
-
if (eresult == EResult.OK) {
|
|
53
|
-
// no error
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
var err = new Error(EResult[eresult] || ("Error " + eresult));
|
|
58
|
-
err.eresult = eresult;
|
|
59
|
-
return err;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
exports.decodeJwt = function(jwt) {
|
|
63
|
-
let parts = jwt.split('.');
|
|
64
|
-
if (parts.length != 3) {
|
|
65
|
-
throw new Error('Invalid JWT');
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
let standardBase64 = parts[1].replace(/-/g, '+')
|
|
69
|
-
.replace(/_/g, '/');
|
|
70
|
-
|
|
71
|
-
return JSON.parse(Buffer.from(standardBase64, 'base64').toString('utf8'));
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Resolves a Steam profile URL to get steamID64 and vanityURL
|
|
76
|
-
* @param {String} url - Full steamcommunity profile URL or only the vanity part.
|
|
77
|
-
* @param {Object} callback - First argument is null/Error, second is object containing vanityURL (String) and steamID (String)
|
|
78
|
-
*/
|
|
79
|
-
exports.resolveVanityURL = function(url, callback) {
|
|
80
|
-
// Precede url param if only the vanity was provided
|
|
81
|
-
if (!url.includes("steamcommunity.com")) {
|
|
82
|
-
url = "https://steamcommunity.com/id/" + url;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Make request to get XML data
|
|
86
|
-
request(url + "/?xml=1", function(err, response, body) {
|
|
87
|
-
if (err) {
|
|
88
|
-
callback(err);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Parse XML data returned from Steam into an object
|
|
93
|
-
new xml2js.Parser().parseString(body, (err, parsed) => {
|
|
94
|
-
if (err) {
|
|
95
|
-
callback(new Error("Couldn't parse XML response"));
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (parsed.response && parsed.response.error) {
|
|
100
|
-
callback(new Error("Couldn't find Steam ID"));
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
let steamID64 = parsed.profile.steamID64[0];
|
|
105
|
-
let vanityURL = parsed.profile.customURL[0];
|
|
106
|
-
|
|
107
|
-
callback(null, {"vanityURL": vanityURL, "steamID": steamID64});
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Converts `input` into a SteamID object, if it's a parseable string.
|
|
114
|
-
* @param {SteamID|string} input
|
|
115
|
-
* @return {SteamID}
|
|
116
|
-
*/
|
|
117
|
-
exports.steamID = function(input) {
|
|
118
|
-
if (exports.isSteamID(input)) {
|
|
119
|
-
return input;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (typeof input != 'string') {
|
|
123
|
-
throw new Error(`Input SteamID value "${input}" is not a string`);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// This will throw if the input is not a well-formed SteamID
|
|
127
|
-
return new SteamID(input);
|
|
128
|
-
};
|
|
1
|
+
const request = require('request');
|
|
2
|
+
const SteamID = require('steamid');
|
|
3
|
+
const xml2js = require('xml2js');
|
|
4
|
+
|
|
5
|
+
const EResult = require('../resources/EResult.js');
|
|
6
|
+
|
|
7
|
+
exports.isSteamID = function(input) {
|
|
8
|
+
var keys = Object.keys(input);
|
|
9
|
+
if (keys.length != 4) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Make sure it has the keys we expect
|
|
14
|
+
keys = keys.filter(function(item) {
|
|
15
|
+
return ['universe', 'type', 'instance', 'accountid'].indexOf(item) != -1;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return keys.length == 4;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.decodeSteamTime = function(time) {
|
|
22
|
+
var date = new Date();
|
|
23
|
+
|
|
24
|
+
if (time.includes("@")) {
|
|
25
|
+
var parts = time.split('@');
|
|
26
|
+
if (!parts[0].includes(",")) {
|
|
27
|
+
// no year, assume current year
|
|
28
|
+
parts[0] += ", " + date.getFullYear();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
date = new Date(parts.join('@').replace(/(am|pm)/, ' $1') + " UTC"); // add a space so JS can decode it
|
|
32
|
+
} else {
|
|
33
|
+
// Relative date
|
|
34
|
+
var amount = time.replace(/(\d) (minutes|hour|hours) ago/, "$1");
|
|
35
|
+
|
|
36
|
+
if(time.includes("minutes")) {
|
|
37
|
+
date.setMinutes(date.getMinutes() - amount);
|
|
38
|
+
} else if(time.match(/hour|hours/)) {
|
|
39
|
+
date.setHours(date.getHours() - amount);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return date;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Get an Error object for a particular EResult
|
|
48
|
+
* @param {int} eresult
|
|
49
|
+
* @returns {null|Error}
|
|
50
|
+
*/
|
|
51
|
+
exports.eresultError = function(eresult) {
|
|
52
|
+
if (eresult == EResult.OK) {
|
|
53
|
+
// no error
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var err = new Error(EResult[eresult] || ("Error " + eresult));
|
|
58
|
+
err.eresult = eresult;
|
|
59
|
+
return err;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
exports.decodeJwt = function(jwt) {
|
|
63
|
+
let parts = jwt.split('.');
|
|
64
|
+
if (parts.length != 3) {
|
|
65
|
+
throw new Error('Invalid JWT');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
let standardBase64 = parts[1].replace(/-/g, '+')
|
|
69
|
+
.replace(/_/g, '/');
|
|
70
|
+
|
|
71
|
+
return JSON.parse(Buffer.from(standardBase64, 'base64').toString('utf8'));
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Resolves a Steam profile URL to get steamID64 and vanityURL
|
|
76
|
+
* @param {String} url - Full steamcommunity profile URL or only the vanity part.
|
|
77
|
+
* @param {Object} callback - First argument is null/Error, second is object containing vanityURL (String) and steamID (String)
|
|
78
|
+
*/
|
|
79
|
+
exports.resolveVanityURL = function(url, callback) {
|
|
80
|
+
// Precede url param if only the vanity was provided
|
|
81
|
+
if (!url.includes("steamcommunity.com")) {
|
|
82
|
+
url = "https://steamcommunity.com/id/" + url;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Make request to get XML data
|
|
86
|
+
request(url + "/?xml=1", function(err, response, body) {
|
|
87
|
+
if (err) {
|
|
88
|
+
callback(err);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Parse XML data returned from Steam into an object
|
|
93
|
+
new xml2js.Parser().parseString(body, (err, parsed) => {
|
|
94
|
+
if (err) {
|
|
95
|
+
callback(new Error("Couldn't parse XML response"));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (parsed.response && parsed.response.error) {
|
|
100
|
+
callback(new Error("Couldn't find Steam ID"));
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let steamID64 = parsed.profile.steamID64[0];
|
|
105
|
+
let vanityURL = parsed.profile.customURL[0];
|
|
106
|
+
|
|
107
|
+
callback(null, {"vanityURL": vanityURL, "steamID": steamID64});
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Converts `input` into a SteamID object, if it's a parseable string.
|
|
114
|
+
* @param {SteamID|string} input
|
|
115
|
+
* @return {SteamID}
|
|
116
|
+
*/
|
|
117
|
+
exports.steamID = function(input) {
|
|
118
|
+
if (exports.isSteamID(input)) {
|
|
119
|
+
return input;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (typeof input != 'string') {
|
|
123
|
+
throw new Error(`Input SteamID value "${input}" is not a string`);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// This will throw if the input is not a well-formed SteamID
|
|
127
|
+
return new SteamID(input);
|
|
128
|
+
};
|