diff --git a/src/main.js b/src/main.js index e6f6d30..fb647ca 100644 --- a/src/main.js +++ b/src/main.js @@ -29,6 +29,14 @@ let plutoniumManifest = { "baseUrl": "https://cdn.plutonium.pw/updater/prod/files/", "files": [] }; +let userInfo = { + "token": "V3ryS3cr3t4uth3nt1c4t10nT0k3n", + "userId": -1, + "username": "AnonGuest", + "email": "guest@neverla.nd", + "emailVerified": false, + "avatar": "https://forum.plutonium.pw/assets/uploads/system/avatar-default.png" +}; function createMainWindow() { mainWindow = new electron.BrowserWindow({ @@ -142,6 +150,8 @@ electron.ipcMain.handle("login", function (event, username, password) { ...data }); + userInfo = data; + mainWindow.loadFile(path.join(__dirname, "src", "views", "games.html")); } catch (error) { reject(error); diff --git a/src/update.js b/src/update.js new file mode 100644 index 0000000..fe19fb4 --- /dev/null +++ b/src/update.js @@ -0,0 +1,39 @@ +const path = require("node:path"); +const fs = require("node:fs"); +const crypto = require("node:crypto"); + +function checkFileAgainstSHA1(baseDirectory, fileEntry) { + return new Promise(function (resolve, reject) { + let filePath = path.join(baseDirectory, fileEntry.name); + + if (!fs.existsSync(filePath)) { + return resolve({ + "entry": fileEntry, + "ok": false + }); + } + + let hash = crypto.createHash("sha1"); + hash.setEncoding("hex"); + + let fileInputStream = fs.createReadStream(filePath); + + hash.on("readable", function () { + let data = hash.read(); + if (data) { + resolve({ + "entry": fileEntry, + "ok": data == fileEntry.hash + }); + } + }); + + fileInputStream.pipe(hash); + }); +} + +module.exports = { + "checkFiles": function (manifest) { + + } +};