Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
1de9fce504 | |||
73fb9464d2 | |||
5c819938c8 | |||
4f84dd3248 | |||
2fa6a9b3d5 | |||
258c01ccc7 | |||
d80d6dc889 | |||
7a8495d88a | |||
9ac75a309b | |||
8ef809be5c | |||
e6ccec3e93 | |||
7785ebec92 | |||
3edf2ce8a3 |
@@ -19,5 +19,14 @@ The Launcher is a "plug and play thing", download it, place it on the desktop an
|
|||||||
* [axios](https://www.npmjs.com/package/axios)
|
* [axios](https://www.npmjs.com/package/axios)
|
||||||
* [jquery](https://www.npmjs.com/package/jquery)
|
* [jquery](https://www.npmjs.com/package/jquery)
|
||||||
|
|
||||||
|
## Build from source
|
||||||
|
|
||||||
|
- clone repo
|
||||||
|
- cd into the repo
|
||||||
|
- use `yarn install` to install all dependencies
|
||||||
|
- (if node-gyp cant build the natives try clearing the cache at `%localappdata%\node-gyp\Cache\`)
|
||||||
|
- run `yarn rebuild` to rebuild the natives to the current `NODE_MODULE_VERSION`
|
||||||
|
- use the buildscript `pack-win` to build a executeable
|
||||||
|
|
||||||
## License
|
## License
|
||||||
[AGPL-3.0](https://choosealicense.com/licenses/agpl-3.0/)
|
[AGPL-3.0](https://choosealicense.com/licenses/agpl-3.0/)
|
79
app.js
79
app.js
@@ -2,6 +2,7 @@ const { app, BrowserWindow, ipcMain, dialog } = require('electron');
|
|||||||
const { setupTitlebar, attachTitlebarToWindow } = require('custom-electron-titlebar/main');
|
const { setupTitlebar, attachTitlebarToWindow } = require('custom-electron-titlebar/main');
|
||||||
const windowManager = require('./ui/windowManager');
|
const windowManager = require('./ui/windowManager');
|
||||||
const osuUtil = require('./osuUtil');
|
const osuUtil = require('./osuUtil');
|
||||||
|
const ezppUtil = require('./ezppUtil');
|
||||||
const config = require('./config');
|
const config = require('./config');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
@@ -21,6 +22,8 @@ const run = () => {
|
|||||||
|
|
||||||
mainWindow = createWindow();
|
mainWindow = createWindow();
|
||||||
mainWindow.on('show', async () => {
|
mainWindow.on('show', async () => {
|
||||||
|
await updateConfigVars(mainWindow);
|
||||||
|
await tryLogin(mainWindow);
|
||||||
await doUpdateCheck(mainWindow);
|
await doUpdateCheck(mainWindow);
|
||||||
})
|
})
|
||||||
app.on('activate', function () {
|
app.on('activate', function () {
|
||||||
@@ -30,6 +33,19 @@ const run = () => {
|
|||||||
app.quit()
|
app.quit()
|
||||||
})
|
})
|
||||||
ipcMain.handle('launch', async () => {
|
ipcMain.handle('launch', async () => {
|
||||||
|
const osuConfig = await osuUtil.getLatestConfig(tempOsuPath);
|
||||||
|
const username = await config.get('username');
|
||||||
|
const password = await config.get('password');
|
||||||
|
if (password && username) {
|
||||||
|
await osuUtil.setConfigValue(osuConfig.path, "SaveUsername", "1");
|
||||||
|
await osuUtil.setConfigValue(osuConfig.path, "SavePassword", "1");
|
||||||
|
await osuUtil.setConfigValue(osuConfig.path, "Username", username);
|
||||||
|
await osuUtil.setConfigValue(osuConfig.path, "Password", await osuUtil.decryptString(password));
|
||||||
|
await osuUtil.setConfigValue(osuConfig.path, "CredentialEndpoint", "ez-pp.farm");
|
||||||
|
} else {
|
||||||
|
await osuUtil.setConfigValue(osuConfig.path, "Username", "");
|
||||||
|
await osuUtil.setConfigValue(osuConfig.path, "Password", "");
|
||||||
|
}
|
||||||
const result = await osuUtil.startOsuWithDevServer(tempOsuPath, "ez-pp.farm", async () => {
|
const result = await osuUtil.startOsuWithDevServer(tempOsuPath, "ez-pp.farm", async () => {
|
||||||
await doUpdateCheck(mainWindow);
|
await doUpdateCheck(mainWindow);
|
||||||
});
|
});
|
||||||
@@ -66,6 +82,12 @@ const run = () => {
|
|||||||
type: "update-complete"
|
type: "update-complete"
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
downloadTask.on('error', () => {
|
||||||
|
mainWindow.webContents.send('status_update', {
|
||||||
|
type: "error",
|
||||||
|
message: "An error occured while updating."
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
} else
|
} else
|
||||||
mainWindow.webContents.send('status_update', {
|
mainWindow.webContents.send('status_update', {
|
||||||
@@ -84,15 +106,64 @@ const run = () => {
|
|||||||
|
|
||||||
if (validOsuDir) await config.set("osuPath", folderPath);
|
if (validOsuDir) await config.set("osuPath", folderPath);
|
||||||
|
|
||||||
return validOsuDir;
|
return { validOsuDir, folderPath };
|
||||||
|
})
|
||||||
|
ipcMain.handle('perform-login', async (event, data) => {
|
||||||
|
const { username, password } = data;
|
||||||
|
const loginData = await ezppUtil.performLogin(username, password);
|
||||||
|
if (loginData && loginData.code === 200) {
|
||||||
|
await config.set("username", username);
|
||||||
|
await config.set("password", await osuUtil.encryptString(password));
|
||||||
|
}
|
||||||
|
return loginData;
|
||||||
|
})
|
||||||
|
ipcMain.on('perform-logout', async (event) => {
|
||||||
|
await config.remove("username");
|
||||||
|
await config.remove("password");
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function doUpdateCheck(window) {
|
async function updateConfigVars(window) {
|
||||||
const osuPath = await config.get("osuPath", "");
|
const osuPath = await config.get("osuPath", "");
|
||||||
|
window.webContents.send('config_update', {
|
||||||
|
osuPath: osuPath
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function tryLogin(window) {
|
||||||
|
const username = await config.get("username", "");
|
||||||
|
const password = await config.get("password", "");
|
||||||
|
if ((username && username.length > 0) && (password && password.length > 0)) {
|
||||||
|
const passwordPlain = await osuUtil.decryptString(password);
|
||||||
|
const loginResponse = await ezppUtil.performLogin(username, passwordPlain);
|
||||||
|
if (loginResponse && loginResponse.code === 200) {
|
||||||
|
window.webContents.send('account_update', {
|
||||||
|
type: "loggedin",
|
||||||
|
user: loginResponse.user
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
window.webContents.send('account_update', {
|
||||||
|
type: "login-failed"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
window.webContents.send('account_update', {
|
||||||
|
type: "not-loggedin"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function doUpdateCheck(window) {
|
||||||
|
const osuPath = await config.get("osuPath");
|
||||||
|
if (!osuPath || osuPath.trim == "") {
|
||||||
|
window.webContents.send('status_update', {
|
||||||
|
type: "missing-folder"
|
||||||
|
})
|
||||||
|
return;
|
||||||
|
}
|
||||||
const isValid = await osuUtil.isValidOsuFolder(osuPath);
|
const isValid = await osuUtil.isValidOsuFolder(osuPath);
|
||||||
if (osuPath.trim == "" || !isValid) {
|
if (!isValid) {
|
||||||
window.webContents.send('status_update', {
|
window.webContents.send('status_update', {
|
||||||
type: "missing-folder"
|
type: "missing-folder"
|
||||||
})
|
})
|
||||||
@@ -121,7 +192,7 @@ async function doUpdateCheck(window) {
|
|||||||
|
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
const win = windowManager.createWindow(520, 350);
|
const win = windowManager.createWindow(700, 420);
|
||||||
|
|
||||||
win.loadFile('./html/index.html');
|
win.loadFile('./html/index.html');
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
const appName = "EZPPLauncher"
|
const appName = "EZPPLauncher"
|
||||||
const appVersion = "1.0.0";
|
const appVersion = "1.1.0";
|
||||||
|
|
||||||
module.exports = { appName, appVersion };
|
module.exports = { appName, appVersion };
|
305
assets/launcher.css
Normal file
305
assets/launcher.css
Normal file
@@ -0,0 +1,305 @@
|
|||||||
|
@import url('https://fonts.googleapis.com/css2?family=Exo+2:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--main-accent: 335deg;
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
font-family: 'Exo 2', 'Roboto' !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sections {
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-name {
|
||||||
|
font-size: 40px;
|
||||||
|
font-weight: 500;
|
||||||
|
text-shadow: 0 0 15px rgba(255, 255, 255, 0.37);
|
||||||
|
}
|
||||||
|
|
||||||
|
.launcher-window {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-section,
|
||||||
|
.login-section {
|
||||||
|
margin-top: 35px;
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-section {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-section {}
|
||||||
|
|
||||||
|
.loading-indicator {}
|
||||||
|
|
||||||
|
.loading-indicator-text {
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-section {
|
||||||
|
margin-top: 45px;
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
color: #aaa;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-action {
|
||||||
|
font-style: italic;
|
||||||
|
cursor: pointer;
|
||||||
|
width: fit-content;
|
||||||
|
line-height: .9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.launch-section {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn.btn-launch {
|
||||||
|
margin-top: 10px;
|
||||||
|
width: 300px;
|
||||||
|
font-size: 23px;
|
||||||
|
text-transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.account-section {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-info {
|
||||||
|
text-align: start;
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-content: center;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-info .welcome-text {
|
||||||
|
font-size: 31px;
|
||||||
|
letter-spacing: .02rem;
|
||||||
|
height: 30px;
|
||||||
|
line-height: .8;
|
||||||
|
text-shadow: 0 0 10px rgba(0, 0, 0, 0.349);
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-info .account-action {
|
||||||
|
font-size: 21px;
|
||||||
|
letter-spacing: .05rem;
|
||||||
|
font-weight: 500;
|
||||||
|
font-style: italic;
|
||||||
|
color: #aaa;
|
||||||
|
text-shadow: 0 0 10px rgba(0, 0, 0, 0.349);
|
||||||
|
cursor: pointer;
|
||||||
|
line-height: 1.2;
|
||||||
|
width: fit-content;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-image {
|
||||||
|
border: 5px solid white;
|
||||||
|
border-radius: 0.4rem;
|
||||||
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.349);
|
||||||
|
}
|
||||||
|
|
||||||
|
#user-img {
|
||||||
|
border-radius: .2rem;
|
||||||
|
width: 80px;
|
||||||
|
/* somehow its misplaced without that */
|
||||||
|
transform: translate(-0.25px, 0.25px) scale(1.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-outline .form-control:focus~.form-notch .form-notch-leading {
|
||||||
|
border-color: hsl(var(--main-accent), 93%, 48%);
|
||||||
|
box-shadow: -1px 0 0 0 hsl(var(--main-accent), 93%, 48%), 0 1px 0 0 hsl(var(--main-accent), 93%, 48%), 0 -1px 0 0 hsl(var(--main-accent), 93%, 48%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-outline .form-control:focus~.form-notch .form-notch-middle {
|
||||||
|
border-color: hsl(var(--main-accent), 93%, 48%);
|
||||||
|
box-shadow: 0 1px 0 0 hsl(var(--main-accent), 93%, 48%);
|
||||||
|
border-top: 1px solid transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-outline .form-control:focus~.form-notch .form-notch-trailing {
|
||||||
|
border-color: hsl(var(--main-accent), 93%, 48%);
|
||||||
|
box-shadow: 1px 0 0 0 hsl(var(--main-accent), 93%, 48%), 0 -1px 0 0 hsl(var(--main-accent), 93%, 48%), 0 1px 0 0 hsl(var(--main-accent), 93%, 48%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-outline .form-control:focus~.form-label {
|
||||||
|
color: hsl(var(--main-accent), 93%, 48%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-accent,
|
||||||
|
.btn-accent:active {
|
||||||
|
background: hsl(var(--main-accent), 93%, 48%);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-accent:hover {
|
||||||
|
background: hsl(var(--main-accent), 93%, 42%);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-grey,
|
||||||
|
.btn-grey:active {
|
||||||
|
background: #727272;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-grey:hover {
|
||||||
|
background: #626262;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-grouped {
|
||||||
|
display: flex;
|
||||||
|
gap: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clickable {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loader {
|
||||||
|
position: relative;
|
||||||
|
margin: 0px auto;
|
||||||
|
width: 200px;
|
||||||
|
height: 200px;
|
||||||
|
transform: scale(0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.loader:before {
|
||||||
|
content: '';
|
||||||
|
display: block;
|
||||||
|
padding-top: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.circular-loader {
|
||||||
|
-webkit-animation: rotate 2s linear infinite;
|
||||||
|
animation: rotate 2s linear infinite;
|
||||||
|
height: 100%;
|
||||||
|
-webkit-transform-origin: center center;
|
||||||
|
-ms-transform-origin: center center;
|
||||||
|
transform-origin: center center;
|
||||||
|
width: 100%;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loader-path {
|
||||||
|
stroke-dasharray: 150, 200;
|
||||||
|
stroke-dashoffset: -10;
|
||||||
|
-webkit-animation: dash 1.5s ease-in-out infinite, color 6s ease-in-out infinite;
|
||||||
|
animation: dash 1.5s ease-in-out infinite, color 6s ease-in-out infinite;
|
||||||
|
stroke-linecap: round;
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes rotate {
|
||||||
|
100% {
|
||||||
|
-webkit-transform: rotate(360deg);
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes rotate {
|
||||||
|
100% {
|
||||||
|
-webkit-transform: rotate(360deg);
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes dash {
|
||||||
|
0% {
|
||||||
|
stroke-dasharray: 1, 200;
|
||||||
|
stroke-dashoffset: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
50% {
|
||||||
|
stroke-dasharray: 89, 200;
|
||||||
|
stroke-dashoffset: -35;
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
stroke-dasharray: 89, 200;
|
||||||
|
stroke-dashoffset: -124;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes dash {
|
||||||
|
0% {
|
||||||
|
stroke-dasharray: 1, 200;
|
||||||
|
stroke-dashoffset: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
50% {
|
||||||
|
stroke-dasharray: 89, 200;
|
||||||
|
stroke-dashoffset: -35;
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
stroke-dasharray: 89, 200;
|
||||||
|
stroke-dashoffset: -124;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes color {
|
||||||
|
0% {
|
||||||
|
stroke: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
40% {
|
||||||
|
stroke: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
66% {
|
||||||
|
stroke: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
80%,
|
||||||
|
90% {
|
||||||
|
stroke: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes color {
|
||||||
|
0% {
|
||||||
|
stroke: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
40% {
|
||||||
|
stroke: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
66% {
|
||||||
|
stroke: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
80%,
|
||||||
|
90% {
|
||||||
|
stroke: #fff;
|
||||||
|
}
|
||||||
|
}
|
24
config.js
24
config.js
@@ -47,4 +47,26 @@ async function set(key, value) {
|
|||||||
await fs.promises.writeFile(configLocation, arr.join('\n'));
|
await fs.promises.writeFile(configLocation, arr.join('\n'));
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { get, set }
|
async function remove(key) {
|
||||||
|
const configValues = new Map();
|
||||||
|
const fileStream = await fs.promises.readFile(configLocation, "utf-8");
|
||||||
|
const lines = fileStream.split(/\r?\n/)
|
||||||
|
for (const line of lines) {
|
||||||
|
if (line.includes('=')) {
|
||||||
|
const argsPair = line.split('=', 2);
|
||||||
|
const keyname = argsPair[0]
|
||||||
|
const value = argsPair[1];
|
||||||
|
configValues.set(keyname, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const arr = [];
|
||||||
|
for (var [storkey, storvalue] of configValues.entries()) {
|
||||||
|
if (storkey != key)
|
||||||
|
arr.push(`${storkey}=${storvalue}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
await fs.promises.writeFile(configLocation, arr.join('\n'));
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { get, set, remove }
|
10
ezppUtil.js
Normal file
10
ezppUtil.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
const axios = require('axios').default;
|
||||||
|
|
||||||
|
const loginCheckEndpoint = 'https://new.ez-pp.farm/login/check';
|
||||||
|
|
||||||
|
const performLogin = async (username, password) => {
|
||||||
|
const result = await axios.post(loginCheckEndpoint, { username, password });
|
||||||
|
return result.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { performLogin };
|
102
html/index.html
102
html/index.html
@@ -7,6 +7,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<link rel="icon" type="image/png" href="../assets/logo.png" />
|
<link rel="icon" type="image/png" href="../assets/logo.png" />
|
||||||
<link href="../assets/mdb.min.css" rel="stylesheet" />
|
<link href="../assets/mdb.min.css" rel="stylesheet" />
|
||||||
|
<link href="../assets/launcher.css" rel="stylesheet" />
|
||||||
<style>
|
<style>
|
||||||
* {
|
* {
|
||||||
user-select: none;
|
user-select: none;
|
||||||
@@ -19,35 +20,86 @@
|
|||||||
oncontextmenu="return false;">
|
oncontextmenu="return false;">
|
||||||
<main>
|
<main>
|
||||||
<div class="noselect">
|
<div class="noselect">
|
||||||
<div class="position-relative overflow-hidden p-3 p-md-5 m-md-3 text-center text-lg-end d-flex align-items-center justify-content-center"
|
<div class="position-relative overflow-hidden p-1 w-100 text-center text-lg-end d-flex align-items-center justify-content-center"
|
||||||
style="border-radius: 0.5em;">
|
style="border-radius: 0.5em;">
|
||||||
<div class="position-relative overflow-hidden p-3 p-md-5 m-md-3">
|
<div class="launcher-window position-relative overflow-hidden">
|
||||||
<div class="container py-2 h-100">
|
<div class="container px-1 py-2 w-100 mw-100 h-100">
|
||||||
<div class="row d-flex justify-content-center align-items-center h-100">
|
<div class="row d-flex justify-content-center align-items-center h-100">
|
||||||
<div class="col col-xl-10">
|
<div id="loading-page" class="sections col col-xl-10" style="//display: none;">
|
||||||
<div class="card" style="border-radius: 1rem;">
|
<div class="launch-section flex-row">
|
||||||
<div class="row g-0">
|
<div class="server-logo">
|
||||||
<div class="card-body p-4 p-lg-5 text-black">
|
<img src="../assets/logo.png" height="120">
|
||||||
<div class="d-flex align-items-center mb-2 pb-1 text-white">
|
</div>
|
||||||
<span class="h1 fw-bold mb-0">EZPPLauncher</span>
|
<div class="app-name">EZPPLauncher</div>
|
||||||
</div>
|
</div>
|
||||||
<h5 class="fw-lighter fs-5 mb-3 pb-3 text-white text-start"
|
<div class="loading-section">
|
||||||
style="letter-spacing: 1px;">
|
<div class="loading-indicator">
|
||||||
Launch osu! with connection to the EZPPFarm server
|
<div class="loader">
|
||||||
</h5>
|
<svg class="circular-loader" viewBox="25 25 50 50">
|
||||||
<div class="pt-1 mb-4">
|
<circle class="loader-path" cx="50" cy="50" r="20" fill="none"
|
||||||
<button id="launch-btn" class="btn btn-primary btn-lg btn-block"
|
stroke="#fff" stroke-width="2" />
|
||||||
type="button" style="background-color:#d6016f" disabled>Looking for
|
</svg>
|
||||||
updates...</button>
|
|
||||||
</div>
|
|
||||||
<button class="btn btn-dark btn-sm float-start" id="account-btn" disabled>
|
|
||||||
set account
|
|
||||||
</button>
|
|
||||||
<button class="btn btn-dark btn-sm float-end" id="folder-btn">
|
|
||||||
set osu! directory
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="loading-indicator-text">Loading... Please wait</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="launch-page" class="sections col col-xl-10" style="display: none;">
|
||||||
|
<div class="account-section">
|
||||||
|
<div class="user-image">
|
||||||
|
<img id="user-img" src="https://a.ez-pp.farm/0">
|
||||||
|
</div>
|
||||||
|
<div class="user-info">
|
||||||
|
<div class="welcome-text" id="welcome-text">
|
||||||
|
Nice to see you!
|
||||||
|
</div>
|
||||||
|
<div class="account-action" id="account-action">
|
||||||
|
Click to login
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="launch-section">
|
||||||
|
<div class="server-logo">
|
||||||
|
<img src="../assets/logo.png" height="150">
|
||||||
|
</div>
|
||||||
|
<div class="launch-button">
|
||||||
|
<button class="btn btn-lg btn-launch btn-accent" id="launch-btn">Launch</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="folder-section">
|
||||||
|
<div class="folder-location">
|
||||||
|
Current osu! directory: <span id="currentOsuPath"></span>
|
||||||
|
</div>
|
||||||
|
<div class="folder-action" id="change-folder-btn">
|
||||||
|
Not right?
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="login-page" class="sections col col-xl-10" style="display: none;">
|
||||||
|
<div class="launch-section flex-row">
|
||||||
|
<div class="server-logo">
|
||||||
|
<img src="../assets/logo.png" height="120">
|
||||||
|
</div>
|
||||||
|
<div class="app-name">EZPPLauncher</div>
|
||||||
|
</div>
|
||||||
|
<div class="login-section">
|
||||||
|
<div class="form-outline mb-3 w-50">
|
||||||
|
<input type="text" id="login-username" class="form-control form-control-lg" />
|
||||||
|
<label class="form-label" for="login-username">Username</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-outline mb-3 w-50">
|
||||||
|
<input type="password" id="login-password" class="form-control form-control-lg" />
|
||||||
|
<label class="form-label" for="login-password">Password</label>
|
||||||
|
</div>
|
||||||
|
<div class="pt-1 mb-4">
|
||||||
|
<div class="btn-grouped">
|
||||||
|
<button id="action-cancel" class="btn btn-grey btn-lg"
|
||||||
|
type="button">Cancel</button>
|
||||||
|
<button id="action-login" class="btn btn-accent btn-lg"
|
||||||
|
type="button">Login</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p class="text-muted clickable" id="register">Don't have an account?</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
62
html/index_old.html
Normal file
62
html/index_old.html
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>EZPPLauncher</title>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<link rel="icon" type="image/png" href="../assets/logo.png" />
|
||||||
|
<link href="../assets/mdb.min.css" rel="stylesheet" />
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="fixed-sn mdb-skin-custom" data-spy="scroll" data-target="#scrollspy" data-offset="15"
|
||||||
|
oncontextmenu="return false;">
|
||||||
|
<main>
|
||||||
|
<div class="noselect">
|
||||||
|
<div class="position-relative overflow-hidden p-3 p-md-5 m-md-3 text-center text-lg-end d-flex align-items-center justify-content-center"
|
||||||
|
style="border-radius: 0.5em;">
|
||||||
|
<div class="position-relative overflow-hidden p-3 p-md-5 m-md-3">
|
||||||
|
<div class="container py-2 h-100">
|
||||||
|
<div class="row d-flex justify-content-center align-items-center h-100">
|
||||||
|
<div class="col col-xl-10">
|
||||||
|
<div class="card" style="border-radius: 1rem;">
|
||||||
|
<div class="row g-0">
|
||||||
|
<div class="card-body p-4 p-lg-5 text-black">
|
||||||
|
<div class="d-flex align-items-center mb-2 pb-1 text-white">
|
||||||
|
<span class="h1 fw-bold mb-0">EZPPLauncher</span>
|
||||||
|
</div>
|
||||||
|
<h5 class="fw-lighter fs-5 mb-3 pb-3 text-white text-start"
|
||||||
|
style="letter-spacing: 1px;">
|
||||||
|
Launch osu! with connection to the EZPPFarm server
|
||||||
|
</h5>
|
||||||
|
<div class="pt-1 mb-4">
|
||||||
|
<button id="launch-btn" class="btn btn-primary btn-lg btn-block"
|
||||||
|
type="button" style="background-color:#d6016f" disabled>Looking for
|
||||||
|
updates...</button>
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-dark btn-sm float-start" id="account-btn" disabled>
|
||||||
|
set account
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-dark btn-sm float-end" id="folder-btn">
|
||||||
|
set osu! directory
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
<script type="text/javascript" src="../assets/mdb.min.js"></script>
|
||||||
|
|
||||||
|
</html>
|
65
osuUtil.js
65
osuUtil.js
@@ -3,11 +3,13 @@ const fu = require('./fileUtil');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const axios = require('axios').default;
|
const axios = require('axios').default;
|
||||||
|
const dpapi = require('wincrypt');
|
||||||
const executeUtil = require('./executeUtil');
|
const executeUtil = require('./executeUtil');
|
||||||
const { EventEmitter } = require('events');
|
const { EventEmitter } = require('events');
|
||||||
const { DownloaderHelper } = require('node-downloader-helper');
|
const { DownloaderHelper } = require('node-downloader-helper');
|
||||||
|
|
||||||
const checkUpdateURL = "https://osu.ppy.sh/web/check-updates.php?action=check&stream=";
|
const checkUpdateURL = "https://osu.ppy.sh/web/check-updates.php?action=check&stream=";
|
||||||
|
const osuEncryptBuffer = Buffer.from('cu24180ncjeiu0ci1nwui', "utf-8")
|
||||||
const osuEntities = [
|
const osuEntities = [
|
||||||
'avcodec-51.dll',
|
'avcodec-51.dll',
|
||||||
'avformat-52.dll',
|
'avformat-52.dll',
|
||||||
@@ -47,12 +49,12 @@ async function isValidOsuFolder(path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getLatestConfig(osuPath) {
|
async function getLatestConfig(osuPath) {
|
||||||
const allFiles = await fs.promises.readdir(osuPath);
|
|
||||||
const configFileInfo = {
|
const configFileInfo = {
|
||||||
name: "",
|
name: "",
|
||||||
path: "",
|
path: "",
|
||||||
lastModified: 0,
|
|
||||||
get: async (key) => {
|
get: async (key) => {
|
||||||
|
if (!configFileInfo.path)
|
||||||
|
return "";
|
||||||
const fileStream = await fs.promises.readFile(configFileInfo.path, "utf-8");
|
const fileStream = await fs.promises.readFile(configFileInfo.path, "utf-8");
|
||||||
const lines = fileStream.split(/\r?\n/)
|
const lines = fileStream.split(/\r?\n/)
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
@@ -67,17 +69,10 @@ async function getLatestConfig(osuPath) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const file of allFiles) {
|
const userOsuConfig = path.join(osuPath, `osu!.${process.env['USERNAME']}.cfg`)
|
||||||
if (file.startsWith('osu!.') && file.endsWith('.cfg') && file !== "osu!.cfg") {
|
if (fs.existsSync(userOsuConfig)) {
|
||||||
const fullFilePath = path.join(osuPath, file);
|
configFileInfo.name = `osu!.${process.env['USERNAME']}.cfg`;
|
||||||
const fileStats = await fs.promises.stat(fullFilePath);
|
configFileInfo.path = userOsuConfig;
|
||||||
const lastModified = fileStats.mtimeMs;
|
|
||||||
if (lastModified > configFileInfo.lastModified) {
|
|
||||||
configFileInfo.name = file;
|
|
||||||
configFileInfo.path = fullFilePath;
|
|
||||||
configFileInfo.lastModified = lastModified;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return configFileInfo;
|
return configFileInfo;
|
||||||
}
|
}
|
||||||
@@ -103,14 +98,14 @@ async function filesThatNeedUpdate(osuPath, updateFiles) {
|
|||||||
fileName,
|
fileName,
|
||||||
fileURL
|
fileURL
|
||||||
})
|
})
|
||||||
// console.log("hashes are not matching", `(${existingFileMD5} - ${fileHash})`);
|
//console.log("hashes are not matching", `(${existingFileMD5} - ${fileHash})`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
filesToDownload.push({
|
filesToDownload.push({
|
||||||
fileName,
|
fileName,
|
||||||
fileURL
|
fileURL
|
||||||
});
|
});
|
||||||
// console.log("new file " + fileName);
|
//console.log("new file " + fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return filesToDownload;
|
return filesToDownload;
|
||||||
@@ -121,6 +116,7 @@ async function downloadUpdateFiles(osuPath, filesToUpdate) {
|
|||||||
let completedIndex = 0;
|
let completedIndex = 0;
|
||||||
filesToUpdate.forEach(async (fileToUpdate) => {
|
filesToUpdate.forEach(async (fileToUpdate) => {
|
||||||
const filePath = path.join(osuPath, fileToUpdate.fileName);
|
const filePath = path.join(osuPath, fileToUpdate.fileName);
|
||||||
|
console.log(filePath);
|
||||||
if (await fu.existsAsync(filePath))
|
if (await fu.existsAsync(filePath))
|
||||||
await fs.promises.rm(filePath);
|
await fs.promises.rm(filePath);
|
||||||
|
|
||||||
@@ -133,6 +129,10 @@ async function downloadUpdateFiles(osuPath, filesToUpdate) {
|
|||||||
if (completedIndex >= filesToUpdate.length)
|
if (completedIndex >= filesToUpdate.length)
|
||||||
eventEmitter.emit('completed');
|
eventEmitter.emit('completed');
|
||||||
});
|
});
|
||||||
|
fileDownload.on('error', (err) => {
|
||||||
|
console.log(err);
|
||||||
|
eventEmitter.emit('error');
|
||||||
|
});
|
||||||
|
|
||||||
fileDownload.start().catch(err => console.error(err));
|
fileDownload.start().catch(err => console.error(err));
|
||||||
});
|
});
|
||||||
@@ -147,4 +147,37 @@ async function startWithDevServer(osuPath, serverDomain, onExit) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { isValidOsuFolder, getLatestConfig, getUpdateFiles, filesThatNeedUpdate, downloadUpdateFiles, startOsuWithDevServer: startWithDevServer }
|
async function encryptString(value) {
|
||||||
|
return Buffer.from(await dpapi.protect(Buffer.from(value, 'utf-8'), osuEncryptBuffer, 'CurrentUser'), 'utf-8').toString('base64');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function decryptString(value) {
|
||||||
|
const decrypted = await dpapi.unprotect(Buffer.from(value, 'base64'), osuEncryptBuffer, 'CurrentUser');
|
||||||
|
return decrypted.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function setConfigValue(configPath, key, value) {
|
||||||
|
const configLines = new Array();
|
||||||
|
const fileStream = await fs.promises.readFile(configPath, "utf-8");
|
||||||
|
const lines = fileStream.split(/\r?\n/)
|
||||||
|
for (const line of lines) {
|
||||||
|
if (line.includes(' = ')) {
|
||||||
|
const argsPair = line.split(' = ', 2);
|
||||||
|
const keyname = argsPair[0].trim();
|
||||||
|
if (key == keyname) {
|
||||||
|
configLines.push(`${keyname} = ${value}`);
|
||||||
|
} else {
|
||||||
|
configLines.push(line);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
configLines.push(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await fs.promises.writeFile(configPath, configLines.join("\n"), 'utf-8');
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
isValidOsuFolder, getLatestConfig, getUpdateFiles, filesThatNeedUpdate,
|
||||||
|
downloadUpdateFiles, startOsuWithDevServer: startWithDevServer, setConfigValue,
|
||||||
|
encryptString, decryptString
|
||||||
|
}
|
12
package.json
12
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ezpplauncher",
|
"name": "ezpplauncher",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"main": "app.js",
|
"main": "app.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "HorizonCode",
|
"author": "HorizonCode",
|
||||||
@@ -32,6 +32,8 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "electron .",
|
"start": "electron .",
|
||||||
|
"test": "electron ./test/encrypt.js",
|
||||||
|
"rebuild": "electron-rebuild -f -w wincrypt",
|
||||||
"pack-win": "electron-builder --x64",
|
"pack-win": "electron-builder --x64",
|
||||||
"pack-win32": "electron-builder --ia32",
|
"pack-win32": "electron-builder --ia32",
|
||||||
"pack-winarm": "electron-builder --arm64",
|
"pack-winarm": "electron-builder --arm64",
|
||||||
@@ -40,15 +42,17 @@
|
|||||||
"dist": "electron-builder"
|
"dist": "electron-builder"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"electron": "^17.4.3",
|
"electron": "^21.1.1",
|
||||||
"electron-builder": "^23.0.3",
|
"electron-builder": "^23.0.3",
|
||||||
"electron-packager": "^15.5.1"
|
"electron-packager": "^15.5.1",
|
||||||
|
"electron-rebuild": "^3.2.9"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.27.2",
|
"axios": "^0.27.2",
|
||||||
"custom-electron-titlebar": "^4.1.1",
|
"custom-electron-titlebar": "^4.1.1",
|
||||||
"jquery": "^3.6.0",
|
"jquery": "^3.6.0",
|
||||||
"node-downloader-helper": "^2.1.4",
|
"node-downloader-helper": "^2.1.4",
|
||||||
"sweetalert2": "^11.5.2"
|
"sweetalert2": "^11.5.2",
|
||||||
|
"wincrypt": "^1.5.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,8 @@ const { ipcRenderer } = require('electron');
|
|||||||
const { Titlebar, Color } = require('custom-electron-titlebar');
|
const { Titlebar, Color } = require('custom-electron-titlebar');
|
||||||
const appInfo = require('../appInfo');
|
const appInfo = require('../appInfo');
|
||||||
let titlebar;
|
let titlebar;
|
||||||
|
let currentPage = "loading";
|
||||||
|
let loggedIn = false;
|
||||||
|
|
||||||
window.addEventListener('DOMContentLoaded', () => {
|
window.addEventListener('DOMContentLoaded', () => {
|
||||||
titlebar = new Titlebar({
|
titlebar = new Titlebar({
|
||||||
@@ -14,10 +16,34 @@ window.addEventListener('DOMContentLoaded', () => {
|
|||||||
titlebar.updateTitle(`${appInfo.appName} ${appInfo.appVersion}`);
|
titlebar.updateTitle(`${appInfo.appName} ${appInfo.appVersion}`);
|
||||||
|
|
||||||
const $ = require('jquery');
|
const $ = require('jquery');
|
||||||
|
const axios = require('axios').default;
|
||||||
const Swal = require('sweetalert2');
|
const Swal = require('sweetalert2');
|
||||||
|
|
||||||
let currentState;
|
$('#account-action').on('click', () => {
|
||||||
|
if (!loggedIn) {
|
||||||
|
changePage('login');
|
||||||
|
} else {
|
||||||
|
$('#welcome-text').text(`Nice to see you!`);
|
||||||
|
$('#account-action').text('Click to login');
|
||||||
|
$('#user-img').prop('src', `https://a.ez-pp.farm/0`)
|
||||||
|
loggedIn = false;
|
||||||
|
ipcRenderer.send("perform-logout");
|
||||||
|
Swal.fire({
|
||||||
|
title: 'See ya soon!',
|
||||||
|
text: "Successfully logged out!",
|
||||||
|
icon: 'success',
|
||||||
|
confirmButtonText: 'Okay'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#action-cancel').on('click', () => {
|
||||||
|
if (!loggedIn) {
|
||||||
|
changePage('launch');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let currentState;
|
||||||
$("#launch-btn").on('click', async () => {
|
$("#launch-btn").on('click', async () => {
|
||||||
switch (currentState) {
|
switch (currentState) {
|
||||||
case "up-to-date":
|
case "up-to-date":
|
||||||
@@ -46,17 +72,46 @@ window.addEventListener('DOMContentLoaded', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#folder-btn").on('click', async () => {
|
$("#action-login").on('click', async () => {
|
||||||
const success = await ipcRenderer.invoke('set-osu-dir');
|
const username = $('#login-username').val();
|
||||||
if (success == undefined)
|
const password = $('#login-password').val();
|
||||||
|
$("#action-login").attr('disabled', true);
|
||||||
|
$("#action-cancel").attr('disabled', true);
|
||||||
|
const responseData = await ipcRenderer.invoke('perform-login', { username, password });
|
||||||
|
$("#action-login").attr('disabled', false);
|
||||||
|
$("#action-cancel").attr('disabled', false);
|
||||||
|
if (!responseData)
|
||||||
return;
|
return;
|
||||||
if (success) {
|
if (responseData.code != 200) {
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Uh oh!',
|
||||||
|
text: responseData.message,
|
||||||
|
icon: 'error',
|
||||||
|
confirmButtonText: 'Oops.. my bad!'
|
||||||
|
})
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$('#login-username').val("");
|
||||||
|
$('#login-password').val("");
|
||||||
|
$('#welcome-text').text(`Welcome back, ${responseData.user.name}!`);
|
||||||
|
$('#account-action').text('Not you?');
|
||||||
|
$('#user-img').prop('src', `https://a.ez-pp.farm/${responseData.user.id}`);
|
||||||
|
loggedIn = true;
|
||||||
|
changePage('launch');
|
||||||
|
})
|
||||||
|
|
||||||
|
$("#change-folder-btn").on('click', async () => {
|
||||||
|
const responseData = await ipcRenderer.invoke('set-osu-dir');
|
||||||
|
if (!responseData)
|
||||||
|
return;
|
||||||
|
if (responseData.validOsuDir) {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: 'Success!',
|
title: 'Success!',
|
||||||
text: 'osu! folder set.',
|
text: 'osu! folder set.',
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
confirmButtonText: 'Cool'
|
confirmButtonText: 'Cool'
|
||||||
})
|
})
|
||||||
|
$('#currentOsuPath').text(responseData.folderPath);
|
||||||
ipcRenderer.send("do-update-check");
|
ipcRenderer.send("do-update-check");
|
||||||
} else {
|
} else {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
@@ -68,6 +123,27 @@ window.addEventListener('DOMContentLoaded', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('config_update', (event, data) => {
|
||||||
|
if (data.osuPath) {
|
||||||
|
$('#currentOsuPath').text(data.osuPath);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
ipcRenderer.on('account_update', (event, data) => {
|
||||||
|
switch (data.type) {
|
||||||
|
case "not-loggedin":
|
||||||
|
changePage("launch");
|
||||||
|
break;
|
||||||
|
case "loggedin":
|
||||||
|
changePage("launch");
|
||||||
|
$('#welcome-text').text(`Welcome back, ${data.user.name}!`);
|
||||||
|
$('#account-action').text('Not you?');
|
||||||
|
$('#user-img').prop('src', `https://a.ez-pp.farm/${data.user.id}`)
|
||||||
|
loggedIn = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
ipcRenderer.on('status_update', (event, status) => {
|
ipcRenderer.on('status_update', (event, status) => {
|
||||||
currentState = status.type;
|
currentState = status.type;
|
||||||
switch (status.type) {
|
switch (status.type) {
|
||||||
@@ -80,7 +156,8 @@ window.addEventListener('DOMContentLoaded', () => {
|
|||||||
$('#launch-btn').html('Update');
|
$('#launch-btn').html('Update');
|
||||||
break;
|
break;
|
||||||
case "missing-folder":
|
case "missing-folder":
|
||||||
$('#launch-btn').html('Please set your osu! folder');
|
$("#launch-btn").attr('disabled', true);
|
||||||
|
$('#launch-btn').html('set your osu! folder');
|
||||||
break;
|
break;
|
||||||
case "error":
|
case "error":
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
@@ -103,6 +180,13 @@ window.addEventListener('DOMContentLoaded', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function changePage(page) {
|
||||||
|
$(`#${currentPage}-page`).fadeOut(50, "swing", () => {
|
||||||
|
$(`#${page}-page`).fadeIn(350);
|
||||||
|
});
|
||||||
|
currentPage = page;
|
||||||
|
}
|
||||||
|
|
||||||
// workaround for the dark theme
|
// workaround for the dark theme
|
||||||
$('head').append($('<link href="../assets/sweetalert2.dark.css" rel="stylesheet" />'));
|
$('head').append($('<link href="../assets/sweetalert2.dark.css" rel="stylesheet" />'));
|
||||||
})
|
})
|
26
test/encrypt.js
Normal file
26
test/encrypt.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
const dpapi = require('wincrypt');
|
||||||
|
const entropyBuffer = Buffer.from('cu24180ncjeiu0ci1nwui', 'utf-8');
|
||||||
|
|
||||||
|
const run = async () => {
|
||||||
|
const stringToEncrypt = "Test123456!";
|
||||||
|
|
||||||
|
|
||||||
|
const encrypted = await encryptString(stringToEncrypt)
|
||||||
|
console.log(encrypted);
|
||||||
|
const decrypted = await decryptString(encrypted);
|
||||||
|
console.log(decrypted);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async function encryptString(value) {
|
||||||
|
const encryptedString = await dpapi.protect(Buffer.from(value, 'utf-8'), entropyBuffer, 'CurrentUser');
|
||||||
|
const encodedBase64 = Buffer.from(encryptedString, 'utf-8').toString('base64');
|
||||||
|
return encodedBase64;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function decryptString(value) {
|
||||||
|
const decrypted = await dpapi.unprotect(Buffer.from(value, 'base64'), entropyBuffer, 'CurrentUser');
|
||||||
|
return decrypted.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
run();
|
Reference in New Issue
Block a user