Compare commits

...

28 Commits

Author SHA1 Message Date
Alex Corn
d9b6b55efc 3.41.7 2020-09-23 18:11:33 -04:00
Alex Corn
0fc62d2966 Merge pull request #257 from timi-owo/master
Fixed 'language' was missing from the 'CSteamUser.getInventoryContents'
2020-09-23 17:46:59 -04:00
timi-owo
5daf5f712a Fixed param 'language' was missing when calling 'CSteamUser.getInventoryContents' method 2020-09-24 01:44:32 +08:00
Alex Corn
737aa9dc41 Added comment 2020-07-01 00:52:15 -04:00
Alex Corn
07fb26047b 3.41.6 2020-06-30 22:36:48 -04:00
Alex Corn
2f9b24c447 Only attempt to delete this.currency if it actually exists 2020-06-30 22:24:04 -04:00
Alex Corn
211c625da0 3.41.5 2020-06-26 03:45:17 -04:00
Alex Corn
2e61a6ed70 Fixed editProfile and profileSettings for Steam update 2020-06-26 03:44:58 -04:00
Alex Corn
f0a3cb27f8 Merge pull request #250 from itsjfx/open-booster-pack-patch
Add openBoosterPack
2020-05-28 22:30:35 -04:00
Alex Corn
6ed33a100e 3.41.4 2020-05-28 00:15:39 -04:00
Alex Corn
d41a52638b Prevent timeOffset delete timeout from holding app open 2020-05-28 00:15:20 -04:00
jfx
58516d4ed1 Add openBoosterPack 2020-05-23 16:24:20 +10:00
Alex Corn
3f99c718d4 Modernized disable_twofactor example script 2020-04-04 21:53:34 -04:00
Alex Corn
b92c5d852d Modernized enable_twofactor example script 2020-04-04 21:53:32 -04:00
Alex Corn
f5da011cde Create FUNDING.yml 2020-03-10 03:51:16 -04:00
Alex Corn
3633ab032c 3.41.3 2019-11-08 03:33:06 -05:00
Alex Corn
76df74d724 Added hidden parameter to CSteamGroup#postAnnouncement 2019-11-08 03:33:00 -05:00
Alex Corn
8b5cd59021 v3.41.2 2019-11-08 03:27:57 -05:00
Alex Corn
25adcb101b 3.41.1 2019-11-08 03:24:42 -05:00
Alex Corn
d7ecad670d Merge pull request #237 from Heartz66/patch-1
Fix wrong date
2019-11-08 03:23:27 -05:00
Heartz66
8225ea5127 Fix wrong date
https://github.com/DoctorMcKay/node-steamcommunity/issues/236
2019-11-06 19:43:45 +01:00
Alex Corn
59bf4f1e92 Merge pull request #233 from Revadike/patch-1
Optional hidden parameter to postGroupAnnouncement
2019-10-15 01:13:03 +02:00
Revadike
a3468bf99b Optional hidden parameter to postGroupAnnouncement 2019-10-14 04:28:53 +02:00
Alex Corn
e299623452 Use different filenames for different images, similar to how Steam does it 2019-09-25 05:33:14 -04:00
Alex Corn
29b31009ce Merge remote-tracking branch 'origin/master' 2019-09-25 05:30:14 -04:00
Alex Corn
fbfff1398b Merge remote-tracking branch 'origin/master'
# Conflicts:
#	.idea/encodings.xml
2019-02-14 00:29:44 -05:00
Alex Corn
6cd06c3adf Updated module type 2019-02-06 19:54:04 -05:00
Alex Corn
d35e3c107c Make sure CConfirmation.{id, creator} are always strings 2019-02-06 19:36:01 -05:00
15 changed files with 218 additions and 138 deletions

2
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,2 @@
github: DoctorMcKay
custom: 'https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=N36YVAT42CZ4G&item_name=node%2dsteamcommunity&currency_code=USD'

View File

@@ -1,5 +1,5 @@
<component name="ProjectCodeStyleConfiguration"> <component name="ProjectCodeStyleConfiguration">
<state> <state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default (1)" /> <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state> </state>
</component> </component>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4"> <module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true"> <component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output /> <exclude-output />
<content url="file://$MODULE_DIR$" /> <content url="file://$MODULE_DIR$" />

View File

@@ -5,9 +5,9 @@ module.exports = CConfirmation;
function CConfirmation(community, data) { function CConfirmation(community, data) {
Object.defineProperty(this, "_community", {"value": community}); Object.defineProperty(this, "_community", {"value": community});
this.id = data.id; this.id = data.id.toString();
this.type = data.type; this.type = data.type;
this.creator = data.creator; this.creator = data.creator.toString();
this.key = data.key; this.key = data.key;
this.title = data.title; this.title = data.title;
this.receiving = data.receiving; this.receiving = data.receiving;

View File

@@ -86,7 +86,11 @@ function CEconItem(item, description, contextID) {
this.actions = []; this.actions = [];
} }
delete this.currency; // One wouldn't think that we need this if statement, but apparently v8 has a weird bug/quirk where deleting a
// property results in greatly increased memory usage. Because that makes sense.
if (this.currency) {
delete this.currency;
}
} }
CEconItem.prototype.getImageURL = function() { CEconItem.prototype.getImageURL = function() {

View File

@@ -78,8 +78,8 @@ CSteamGroup.prototype.getAllAnnouncements = function(time, callback) {
this._community.getAllGroupAnnouncements(this.steamID, time, callback); this._community.getAllGroupAnnouncements(this.steamID, time, callback);
}; };
CSteamGroup.prototype.postAnnouncement = function(headline, content, callback) { CSteamGroup.prototype.postAnnouncement = function(headline, content, hidden, callback) {
this._community.postGroupAnnouncement(this.steamID, headline, content, callback); this._community.postGroupAnnouncement(this.steamID, headline, content, hidden, callback);
}; };
CSteamGroup.prototype.editAnnouncement = function(annoucementID, headline, content, callback) { CSteamGroup.prototype.editAnnouncement = function(annoucementID, headline, content, callback) {

View File

@@ -69,7 +69,13 @@ function CSteamUser(community, userData, customurl) {
this.customURL = processItem('customURL', customurl); this.customURL = processItem('customURL', customurl);
if(this.visibilityState == 3) { if(this.visibilityState == 3) {
this.memberSince = new Date(processItem('memberSince', '0').replace(/(\d{1,2})(st|nd|th)/, "$1")); let memberSinceValue = processItem('memberSince', '0').replace(/(\d{1,2})(st|nd|th)/, "$1");
if (memberSinceValue.indexOf(',') === -1) {
memberSinceValue += ', ' + new Date().getFullYear();
}
this.memberSince = new Date(memberSinceValue);
this.location = processItem('location'); this.location = processItem('location');
this.realName = processItem('realname'); this.realName = processItem('realname');
this.summary = processItem('summary'); this.summary = processItem('summary');
@@ -177,10 +183,11 @@ CSteamUser.prototype.getInventory = function(appID, contextID, tradableOnly, cal
* @param {int} appID - The Steam application ID of the game for which you want an inventory * @param {int} appID - The Steam application ID of the game for which you want an inventory
* @param {int} contextID - The ID of the "context" within the game you want to retrieve * @param {int} contextID - The ID of the "context" within the game you want to retrieve
* @param {boolean} tradableOnly - true to get only tradable items and currencies * @param {boolean} tradableOnly - true to get only tradable items and currencies
* @param {string} [language] - The language of item descriptions to return. Omit for default (which may either be English or your account's chosen language)
* @param callback * @param callback
*/ */
CSteamUser.prototype.getInventoryContents = function(appID, contextID, tradableOnly, callback) { CSteamUser.prototype.getInventoryContents = function(appID, contextID, tradableOnly, language, callback) {
this._community.getUserInventoryContents(this.steamID, appID, contextID, tradableOnly, callback); this._community.getUserInventoryContents(this.steamID, appID, contextID, tradableOnly, language, callback);
}; };
/** /**

View File

@@ -172,7 +172,7 @@ SteamCommunity.prototype.acceptConfirmationForObject = function(identitySecret,
setTimeout(function() { setTimeout(function() {
// Delete the saved time offset after 12 hours because why not // Delete the saved time offset after 12 hours because why not
delete self._timeOffset; delete self._timeOffset;
}, 1000 * 60 * 60 * 12); }, 1000 * 60 * 60 * 12).unref();
}); });
} }

View File

@@ -156,22 +156,33 @@ SteamCommunity.prototype.getAllGroupAnnouncements = function(gid, time, callback
}, "steamcommunity"); }, "steamcommunity");
}; };
SteamCommunity.prototype.postGroupAnnouncement = function(gid, headline, content, callback) { SteamCommunity.prototype.postGroupAnnouncement = function(gid, headline, content, hidden, callback) {
if(typeof gid === 'string') { if(typeof gid === 'string') {
gid = new SteamID(gid); gid = new SteamID(gid);
} }
if(typeof hidden === 'function') {
callback = hidden;
hidden = false;
}
var self = this; var self = this;
var form = {
"sessionID": this.getSessionID(),
"action": "post",
"headline": headline,
"body": content,
"languages[0][headline]": headline,
"languages[0][body]": content
};
if(hidden) {
form.is_hidden = "is_hidden"
}
this.httpRequestPost({ this.httpRequestPost({
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/announcements", "uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/announcements",
"form": { form
"sessionID": this.getSessionID(),
"action": "post",
"headline": headline,
"body": content,
"languages[0][headline]": headline,
"languages[0][body]": content
}
}, function(err, response, body) { }, function(err, response, body) {
if(!callback) { if(!callback) {
return; return;

View File

@@ -109,6 +109,43 @@ SteamCommunity.prototype.turnItemIntoGems = function(appid, assetid, expectedGem
}) })
}; };
/**
* Open a booster pack.
* @param {int} appid
* @param {int|string} assetid
* @param {function} callback
*/
SteamCommunity.prototype.openBoosterPack = function(appid, assetid, callback) {
this._myProfile({
"endpoint": "ajaxunpackbooster/",
"json": true,
"checkHttpError": false
}, {
"appid": appid,
"communityitemid": assetid,
"sessionid": this.getSessionID()
}, (err, res, body) => {
if (err) {
callback(err);
return;
}
if (body.success && body.success != SteamCommunity.EResult.OK) {
let err = new Error(body.message || SteamCommunity.EResult[body.success]);
err.eresult = err.code = body.success;
callback(err);
return;
}
if (!body.rgItems) {
callback(new Error("Malformed response"));
return;
}
callback(null, body.rgItems);
})
};
/** /**
* Get details about a gift in your inventory. * Get details about a gift in your inventory.
* @param {string} giftID * @param {string} giftID

View File

@@ -34,31 +34,45 @@ SteamCommunity.prototype.setupProfile = function(callback) {
SteamCommunity.prototype.editProfile = function(settings, callback) { SteamCommunity.prototype.editProfile = function(settings, callback) {
var self = this; var self = this;
this._myProfile("edit", null, function(err, response, body) { this._myProfile('edit/info', null, function(err, response, body) {
if(err || response.statusCode != 200) { if (err || response.statusCode != 200) {
if(callback) { if (callback) {
callback(err || new Error("HTTP error " + response.statusCode)); callback(err || new Error('HTTP error ' + response.statusCode));
} }
return; return;
} }
var $ = Cheerio.load(body); var $ = Cheerio.load(body);
var form = $('#editForm'); var existingSettings = $('#profile_edit_config').data('profile-edit');
if(!form) { if (!existingSettings || !existingSettings.strPersonaName) {
if(callback) { if (callback) {
callback(new Error("Malformed response")); callback(new Error('Malformed response'));
} }
return; return;
} }
var values = {}; var values = {
form.serializeArray().forEach(function(item) { sessionID: self.getSessionID(),
values[item.name] = item.value; type: 'profileSave',
}); weblink_1_title: '',
weblink_1_url: '',
weblink_2_title: '',
weblink_2_url: '',
weblink_3_title: '',
weblink_3_url: '',
personaName: existingSettings.strPersonaName,
real_name: existingSettings.strRealName,
summary: existingSettings.strSummary,
country: existingSettings.LocationData.locCountryCode,
state: existingSettings.LocationData.locStateCode,
city: existingSettings.LocationData.locCityCode,
customURL: existingSettings.strCustomURL,
json: 1
};
for(var i in settings) { for (var i in settings) {
if(!settings.hasOwnProperty(i)) { if(!settings.hasOwnProperty(i)) {
continue; continue;
} }
@@ -92,6 +106,8 @@ SteamCommunity.prototype.editProfile = function(settings, callback) {
values.customURL = settings[i]; values.customURL = settings[i];
break; break;
// These don't work right now
/*
case 'background': case 'background':
// The assetid of our desired profile background // The assetid of our desired profile background
values.profile_background = settings[i]; values.profile_background = settings[i];
@@ -110,60 +126,55 @@ SteamCommunity.prototype.editProfile = function(settings, callback) {
} }
break; break;
*/
// TODO: profile showcases // TODO: profile showcases
} }
} }
self._myProfile("edit", values, function(err, response, body) { self._myProfile('edit', values, function(err, response, body) {
if (settings.customURL) { if (settings.customURL) {
delete self._profileURL; delete self._profileURL;
} }
if(err || response.statusCode != 200) { if (!callback) {
if(callback) {
callback(err || new Error("HTTP error " + response.statusCode));
}
return; return;
} }
// Check for an error if (err || response.statusCode != 200) {
var $ = Cheerio.load(body); callback(err || new Error('HTTP error ' + response.statusCode));
var error = $('#errorText .formRowFields'); return;
if(error) {
error = error.text().trim();
if(error) {
if(callback) {
callback(new Error(error));
}
return;
}
} }
if(callback) { try {
var json = JSON.parse(body);
if (!json.success || json.success != 1) {
callback(new Error(json.errmsg || 'Request was not successful'));
return;
}
callback(null); callback(null);
} catch (ex) {
callback(ex);
} }
}); });
}); });
}; };
SteamCommunity.prototype.profileSettings = function(settings, callback) { SteamCommunity.prototype.profileSettings = function(settings, callback) {
this._myProfile("edit/settings", null, (err, response, body) => { this._myProfile('edit/settings', null, (err, response, body) => {
if (err || response.statusCode != 200) { if (err || response.statusCode != 200) {
if (callback) { if (callback) {
callback(err || new Error("HTTP error " + response.statusCode)); callback(err || new Error('HTTP error ' + response.statusCode));
} }
return; return;
} }
var $ = Cheerio.load(body); var $ = Cheerio.load(body);
var existingSettings = $('.ProfileReactRoot[data-privacysettings]').data('privacysettings'); var existingSettings = $('#profile_edit_config').data('profile-edit');
if (!existingSettings) { if (!existingSettings || !existingSettings.Privacy) {
if(callback) { if (callback) {
callback(new Error("Malformed response")); callback(new Error('Malformed response'));
} }
return; return;
@@ -171,8 +182,8 @@ SteamCommunity.prototype.profileSettings = function(settings, callback) {
// PrivacySettings => {PrivacyProfile, PrivacyInventory, PrivacyInventoryGifts, PrivacyOwnedGames, PrivacyPlaytime} // PrivacySettings => {PrivacyProfile, PrivacyInventory, PrivacyInventoryGifts, PrivacyOwnedGames, PrivacyPlaytime}
// eCommentPermission // eCommentPermission
var privacy = existingSettings.PrivacySettings; var privacy = existingSettings.Privacy.PrivacySettings;
var commentPermission = existingSettings.eCommentPermission; var commentPermission = existingSettings.Privacy.eCommentPermission;
for (var i in settings) { for (var i in settings) {
if (!settings.hasOwnProperty(i)) { if (!settings.hasOwnProperty(i)) {
@@ -211,18 +222,18 @@ SteamCommunity.prototype.profileSettings = function(settings, callback) {
} }
this._myProfile({ this._myProfile({
"method": "POST", method: 'POST',
"endpoint": "ajaxsetprivacy/", endpoint: 'ajaxsetprivacy/',
"json": true, json: true,
"formData": { // it's multipart because lolvalve formData: { // it's multipart because lolvalve
"sessionid": this.getSessionID(), sessionid: this.getSessionID(),
"Privacy": JSON.stringify(privacy), Privacy: JSON.stringify(privacy),
"eCommentPermission": commentPermission eCommentPermission: commentPermission
} }
}, null, function(err, response, body) { }, null, function(err, response, body) {
if (err || response.statusCode != 200) { if (err || response.statusCode != 200) {
if (callback) { if (callback) {
callback(err || new Error("HTTP error " + response.statusCode)); callback(err || new Error('HTTP error ' + response.statusCode));
} }
return; return;
@@ -230,7 +241,7 @@ SteamCommunity.prototype.profileSettings = function(settings, callback) {
if (body.success != 1) { if (body.success != 1) {
if (callback) { if (callback) {
callback(new Error(body.success ? "Error " + body.success : "Request was not successful")); callback(new Error(body.success ? 'Error ' + body.success : 'Request was not successful'));
} }
return; return;

View File

@@ -552,6 +552,8 @@ SteamCommunity.prototype.sendImageToUser = function(userID, imageContentsBuffer,
imageHash.update(imageContentsBuffer); imageHash.update(imageContentsBuffer);
imageHash = imageHash.digest('hex'); imageHash = imageHash.digest('hex');
var filename = Date.now() + '_image.' + imageDetails.type;
this.httpRequestPost({ this.httpRequestPost({
uri: 'https://steamcommunity.com/chat/beginfileupload/?l=english', uri: 'https://steamcommunity.com/chat/beginfileupload/?l=english',
headers: { headers: {
@@ -561,7 +563,7 @@ SteamCommunity.prototype.sendImageToUser = function(userID, imageContentsBuffer,
sessionid: this.getSessionID(), sessionid: this.getSessionID(),
l: 'english', l: 'english',
file_size: imageContentsBuffer.length, file_size: imageContentsBuffer.length,
file_name: 'image.' + imageDetails.type, file_name: filename,
file_sha: imageHash, file_sha: imageHash,
file_image_width: imageDetails.width, file_image_width: imageDetails.width,
file_image_height: imageDetails.height, file_image_height: imageDetails.height,
@@ -623,7 +625,7 @@ SteamCommunity.prototype.sendImageToUser = function(userID, imageContentsBuffer,
formData: { // it's multipart again formData: { // it's multipart again
sessionid: this.getSessionID(), sessionid: this.getSessionID(),
l: 'english', l: 'english',
file_name: 'image.' + imageDetails.type, file_name: filename,
file_sha: imageHash, file_sha: imageHash,
success: '1', success: '1',
ugcid: startResult.ugcid, ugcid: startResult.ugcid,

View File

@@ -1,18 +1,19 @@
var SteamCommunity = require('../index.js'); // If you aren't running this script inside of the repository, replace the following line with:
var ReadLine = require('readline'); // const SteamCommunity = require('steamcommunity');
var fs = require('fs'); const SteamCommunity = require('../index.js');
const ReadLine = require('readline');
var community = new SteamCommunity(); let community = new SteamCommunity();
var rl = ReadLine.createInterface({ let rl = ReadLine.createInterface({
"input": process.stdin, input: process.stdin,
"output": process.stdout output: process.stdout
}); });
rl.question("Username: ", function(accountName) { rl.question('Username: ', (accountName) => {
rl.question("Password: ", function(password) { rl.question('Password: ', (password) => {
rl.question("Two-Factor Auth Code: ", function(authCode) { rl.question('Two-Factor Auth Code: ', (authCode) =>{
rl.question("Revocation Code: R", function(rCode) { rl.question('Revocation Code: R', (rCode) => {
doLogin(accountName, password, authCode, "", rCode); doLogin(accountName, password, authCode, '', rCode);
}); });
}); });
}); });
@@ -20,21 +21,21 @@ rl.question("Username: ", function(accountName) {
function doLogin(accountName, password, authCode, captcha, rCode) { function doLogin(accountName, password, authCode, captcha, rCode) {
community.login({ community.login({
"accountName": accountName, accountName: accountName,
"password": password, password: password,
"twoFactorCode": authCode, twoFactorCode: authCode,
"captcha": captcha captcha: captcha
}, function(err, sessionID, cookies, steamguard) { }, (err, sessionID, cookies, steamguard) => {
if(err) { if (err) {
if(err.message == 'SteamGuard') { if (err.message == 'SteamGuard') {
console.log("This account does not have two-factor authentication enabled."); console.log('This account does not have two-factor authentication enabled.');
process.exit(); process.exit();
return; return;
} }
if(err.message == 'CAPTCHA') { if (err.message == 'CAPTCHA') {
console.log(err.captchaurl); console.log(err.captchaurl);
rl.question("CAPTCHA: ", function(captchaInput) { rl.question('CAPTCHA: ', (captchaInput) => {
doLogin(accountName, password, authCode, captchaInput); doLogin(accountName, password, authCode, captchaInput);
}); });
@@ -46,15 +47,15 @@ function doLogin(accountName, password, authCode, captcha, rCode) {
return; return;
} }
console.log("Logged on!"); console.log('Logged on!');
community.disableTwoFactor("R" + rCode, function(err) { community.disableTwoFactor('R' + rCode, (err) => {
if(err) { if (err) {
console.log(err); console.log(err);
process.exit(); process.exit();
return; return;
} }
console.log("Two-factor authentication disabled!"); console.log('Two-factor authentication disabled!');
process.exit(); process.exit();
}); });
}); });

View File

@@ -1,45 +1,49 @@
var SteamCommunity = require('../index.js'); // If you aren't running this script inside of the repository, replace the following line with:
var ReadLine = require('readline'); // const SteamCommunity = require('steamcommunity');
var fs = require('fs'); const SteamCommunity = require('../index.js');
const ReadLine = require('readline');
const FS = require('fs');
var community = new SteamCommunity(); const EResult = SteamCommunity.EResult;
var rl = ReadLine.createInterface({
"input": process.stdin, let community = new SteamCommunity();
"output": process.stdout let rl = ReadLine.createInterface({
input: process.stdin,
output: process.stdout
}); });
rl.question("Username: ", function(accountName) { rl.question('Username: ', (accountName) => {
rl.question("Password: ", function(password) { rl.question('Password: ', (password) => {
doLogin(accountName, password); doLogin(accountName, password);
}); });
}); });
function doLogin(accountName, password, authCode, captcha) { function doLogin(accountName, password, authCode, captcha) {
community.login({ community.login({
"accountName": accountName, accountName: accountName,
"password": password, password: password,
"authCode": authCode, authCode: authCode,
"captcha": captcha captcha: captcha
}, function(err, sessionID, cookies, steamguard) { }, (err, sessionID, cookies, steamguard) => {
if(err) { if (err) {
if(err.message == 'SteamGuardMobile') { if (err.message == 'SteamGuardMobile') {
console.log("This account already has two-factor authentication enabled."); console.log('This account already has two-factor authentication enabled.');
process.exit(); process.exit();
return; return;
} }
if(err.message == 'SteamGuard') { if (err.message == 'SteamGuard') {
console.log("An email has been sent to your address at " + err.emaildomain); console.log(`An email has been sent to your address at ${err.emaildomain}`);
rl.question("Steam Guard Code: ", function (code) { rl.question('Steam Guard Code: ', (code) => {
doLogin(accountName, password, code); doLogin(accountName, password, code);
}); });
return; return;
} }
if(err.message == 'CAPTCHA') { if (err.message == 'CAPTCHA') {
console.log(err.captchaurl); console.log(err.captchaurl);
rl.question("CAPTCHA: ", function(captchaInput) { rl.question('CAPTCHA: ', (captchaInput) => {
doLogin(accountName, password, authCode, captchaInput); doLogin(accountName, password, authCode, captchaInput);
}); });
@@ -51,17 +55,17 @@ function doLogin(accountName, password, authCode, captcha) {
return; return;
} }
console.log("Logged on!"); console.log('Logged on!');
community.enableTwoFactor(function(err, response) { community.enableTwoFactor((err, response) => {
if(err) { if (err) {
if(err.eresult == 2) { if (err.eresult == EResult.Fail) {
console.log("Error: Failed to enable two-factor authentication. Do you have a phone number attached to your account?"); console.log('Error: Failed to enable two-factor authentication. Do you have a phone number attached to your account?');
process.exit(); process.exit();
return; return;
} }
if(err.eresult == 84) { if (err.eresult == EResult.RateLimitExceeded) {
console.log("Error: RateLimitExceeded. Try again later."); console.log('Error: RateLimitExceeded. Try again later.');
process.exit(); process.exit();
return; return;
} }
@@ -71,15 +75,16 @@ function doLogin(accountName, password, authCode, captcha) {
return; return;
} }
if(response.status != 1) { if (response.status != EResult.OK) {
console.log("Error: Status " + response.status); console.log(`Error: Status ${response.status}`);
process.exit(); process.exit();
return; return;
} }
console.log("Writing secrets to twofactor_" + community.steamID.getSteamID64() + ".json"); let filename = `twofactor_${community.steamID.getSteamID64()}.json`;
console.log("Revocation code: " + response.revocation_code); console.log(`Writing secrets to ${filename}`);
fs.writeFileSync("twofactor_" + community.steamID.getSteamID64() + ".json", JSON.stringify(response, null, "\t")); console.log(`Revocation code: ${response.revocation_code}`);
FS.writeFileSync(filename, JSON.stringify(response, null, '\t'));
promptActivationCode(response); promptActivationCode(response);
}); });
@@ -87,10 +92,10 @@ function doLogin(accountName, password, authCode, captcha) {
} }
function promptActivationCode(response) { function promptActivationCode(response) {
rl.question("SMS Code: ", function(smsCode) { rl.question('SMS Code: ', (smsCode) => {
community.finalizeTwoFactor(response.shared_secret, smsCode, function(err) { community.finalizeTwoFactor(response.shared_secret, smsCode, (err) => {
if(err) { if (err) {
if(err.message == "Invalid activation code") { if (err.message == 'Invalid activation code') {
console.log(err); console.log(err);
promptActivationCode(response); promptActivationCode(response);
return; return;
@@ -98,7 +103,7 @@ function promptActivationCode(response) {
console.log(err); console.log(err);
} else { } else {
console.log("Two-factor authentication enabled!"); console.log('Two-factor authentication enabled!');
} }
process.exit(); process.exit();

View File

@@ -1,6 +1,6 @@
{ {
"name": "steamcommunity", "name": "steamcommunity",
"version": "3.41.0", "version": "3.41.7",
"description": "Provides an interface for logging into and interacting with the Steam Community website", "description": "Provides an interface for logging into and interacting with the Steam Community website",
"keywords": [ "keywords": [
"steam", "steam",