Sync
This commit is contained in:
@@ -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
|
||||
}
|
||||
@@ -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
0
modules/gameFiles.js
Normal file
Reference in New Issue
Block a user