Skip to content

Commit

Permalink
added steam guard support
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbasPL committed Mar 16, 2021
1 parent 76db3bd commit f5584fb
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 9 deletions.
46 changes: 45 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,26 @@ <h4 class="center black-text">Delete account?</h4>
<a href="#!" class="modal-close waves-effect waves-light btn red delete-btn" id="add-account">Delete</a>
</div>
</div>
<div id="modal3" class="modal">
<div class="modal-content">
<h4 class="center black-text">Steam guard for account <span id="guard-acc-name">ERROR</span></h4>
<div class="row">
<form class="col s12" id="guard-acc-form">
<div class="row">
<div class="input-field col s12">
<input id="guard-code" type="text" class="validate">
<label for="guard-code">Code</label>
</div>
</div>
</form>
</div>
</div>
<div class="modal-footer">
<a href="#!" class="modal-close waves-effect waves-light btn red" id="guard-submit">Submit</a>
<a href="#!" class="modal-close waves-effect waves-light btn red" id="guard-cancel">Cancel</a>

</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script>
M.AutoInit();
Expand Down Expand Up @@ -176,7 +196,10 @@ <h4 class="center black-text">Delete account?</h4>
a_refresh.addEventListener('click', async e => {
let promise = ipcRenderer.invoke('accounts:check', username);
updateAccounts();
await promise;
let ret = await promise;
if(ret.error) {
M.toast({html: username + ': ' + ret.error, classes: 'red'});
}
updateAccounts();
});
let a_delete = document.createElement('a');
Expand Down Expand Up @@ -272,6 +295,27 @@ <h4 class="center black-text">Delete account?</h4>
document.querySelector('#importtxt').addEventListener('click', async e => {
await ipcRenderer.invoke('accounts:import');
});
document.querySelector('#guard-submit').addEventListener('click', async e => {
let code = document.querySelector("#guard-code").value.trim();
if (code.length > 0) {
await ipcRenderer.send('steam:steamguard:response', code);
} else {
M.toast({html: 'Steam guard code can not be empty'});
}
})
document.querySelector('#guard-cancel').addEventListener('click', async e => {
await ipcRenderer.send('steam:steamguard:response', null);
})
M.Modal.init(document.querySelectorAll('#modal3'), {
dismissible: false
});
let modal3 = M.Modal.getInstance(document.querySelector('#modal3'));
ipcRenderer.on('steam:steamguard', (event, username) => {
document.querySelector('#guard-acc-name').innerText = username;
document.querySelector("#guard-code").value = '';
modal3.open();
})

</script>
</body>
</html>
41 changes: 33 additions & 8 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,30 @@ if(!fs.existsSync(app.getPath('userData'))){
fs.mkdirSync(app.getPath('userData')) //makes data on first run
}

let win = null

const db = new JSONdb(app.getPath('userData') + '/accounts.json');
db.sync(); //makes empty file on first run

var currently_checking = [];

function createWindow () {
const win = new BrowserWindow({
win = new BrowserWindow({
webPreferences: {
nodeIntegration: true,
},
});
win.removeMenu();
globalShortcut.register('CommandOrControl+Shift+I', () => {
win.webContents.openDevTools();
})
// globalShortcut.register('CommandOrControl+Shift+I', () => {
// win.webContents.openDevTools();
// })
win.loadFile('index.html');
win.webContents.on('before-input-event', (event, input) => {
if (input.control && input.shift && input.key.toLowerCase() === 'i') {
win.webContents.openDevTools();
event.preventDefault();
}
})
}

app.whenReady().then(createWindow)
Expand Down Expand Up @@ -207,8 +215,9 @@ function check_account(username, pass) {
let steamClient = new User();

steamClient.logOn({
"accountName": username,
"password": pass,
accountName: username,
password: pass,
rememberPassword: true,
});

steamClient.on('disconnected', (eresult, msg) => {
Expand All @@ -232,6 +241,10 @@ function check_account(username, pass) {
errorStr = `Rate Limit Exceeded`;
break;
}
case 65: {
errorStr = `steam guard is invalid`;
break;
}
default: {
errorStr = `Unknown: ${e.eresult}`;
break;
Expand All @@ -242,8 +255,20 @@ function check_account(username, pass) {
});

steamClient.on('steamGuard', (domain, callback) => {
currently_checking = currently_checking.filter(x => x !== username);
reject(`steam guard is enabled`);
if (!win) {
currently_checking = currently_checking.filter(x => x !== username);
reject(`steam guard is enabled`);
} else {
win.webContents.send('steam:steamguard', username);
ipcMain.once('steam:steamguard:response', async (event, code) => {
if (!code) {
currently_checking = currently_checking.filter(x => x !== username);
reject(`steam guard is enabled`);
} else {
callback(code);
}
});
}
});

// steamClient.on('vacBans', (numBans, appids) => {
Expand Down

0 comments on commit f5584fb

Please sign in to comment.