-
Notifications
You must be signed in to change notification settings - Fork 0
/
two_factor.js
66 lines (57 loc) · 1.81 KB
/
two_factor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var SteamUser = require('steam-user');
var readlineSync = require('readline-sync');
var fs = require('fs');
var username, password;
var user = new SteamUser();
console.log('2fa enabling process beginning...');
logOn();
function startProcess(u,pw) {
username = u;
password = pw;
user.logOn({
'accountName': username,
'password': password
});
}
user.on('loggedOn', function(response) {
console.log('Logged onto Steam...');
console.log('Beginning 2fa authentication');
enableTwoFactor();
});
function enableTwoFactor() {
user.enableTwoFactor(function(err,response) {
if(err == null){
console.log(response);
var status = response.status;
if (status == 1) {
console.log('>> Successfully requested 2fa enabling.');
console.log('>> Saving valuable data to ' + username + '.maFile');
saveFile(response);
finalizeTwoFactor(response);
}else{
console.log('>> Erorr while enabling 2fa. Error code: ' + status);
process.exit(1);
}
}
});
}
function saveFile(response) {
fs.writeFileSync('accounts/'+ username + '.2fa', JSON.stringify(response));
}
function finalizeTwoFactor(response) {
console.log('>> Verifying 2fa activation.');
var code = readlineSync.question('Code sent by SMS: ');
try{
user.finalizeTwoFactor(response.shared_secret, code, function (err) {
if (err) {
console.log('>> Error while verifying 2fa. Error: ' + err.message);
} else {
console.log('>> Successfully verified 2fa authentication.');
console.log('>> Run test_login.js if you wish to test your login. (Do not remove .maFile file from the accounts directory)');
}
});
}catch{
}
}
// * Pass your steam account username and password to the startProcess function
startProcess("yourUsername","yourPassword");