This commit is contained in:
2025-05-01 18:42:39 +02:00
parent 6ee1cd793f
commit 5657184b08
8 changed files with 1112 additions and 49 deletions

View File

@@ -1,18 +0,0 @@
const msmc = require("msmc")
const { Authenticator } = require("minecraft-launcher-core")
async function getMicrosoftAuth() {
const authManager = new msmc.Auth("select_account")
const xboxManager = await authManager.launch("raw")
const token = await xboxManager.getMinecraft()
return token.mclc()
}
function getMojangAuth(username, password) {
return Authenticator.getAuth(username, password)
}
module.exports = {
getMicrosoftAuth,
getMojangAuth
}

View File

@@ -4,6 +4,17 @@ const https = require("node:https")
const crypto = require("node:crypto")
const config = require("../config.json")
async function getRemoteFiles() {
try {
const response = await fetch(`${config.api.base}${config.api.endpoints.gameFiles}`)
console.log(response.url)
const json = await response.json()
return json
} catch (error) {
throw error
}
}
async function downloadFile(url, destination, hash) {
const file = fs.createWriteStream(destination)
const protocol = url.startsWith("https://") ? http : https
@@ -73,8 +84,21 @@ async function checkFilesHash(root) {
}
}
async function getRemoteFileHash(filePath) {
try {
const response = await fetch(`${config.api.base}${config.api.endpoints.fileHash}/${filePath}`)
const text = await response.text()
return text
} catch (error) {
throw error
}
}
module.exports = {
getFileHash,
downloadFile,
checkFileHash,
checkFilesHash
checkFilesHash,
getRemoteFiles,
getRemoteFileHash
}

0
modules/gameFiles.js Normal file
View File