Add session repository and profile signing utility

Introduces sessionRepository.js with functions for managing client and server sessions, blocked servers, skins, capes, and profile actions. Adds signProfileData to utils.js for signing profile data, and updates README project name.
This commit is contained in:
2025-12-23 16:17:40 +01:00
parent 0b1662d8ca
commit bdb6457d1d
3 changed files with 183 additions and 2 deletions

View File

@@ -1,6 +1,8 @@
const path = require("node:path")
const Logger = require("./logger")
const logger = Logger.createLogger(path.join(__dirname, ".."))
const certificatesManager = require("./certificatesManager")
const serverKeys = certificatesManager.getKeys()
async function getRegistrationCountryFromIp(ipAddress) {
const apiUrl = `https://ip-api.com/json/${ipAddress}?fields=countryCode`
@@ -24,6 +26,20 @@ async function getRegistrationCountryFromIp(ipAddress) {
}
}
function signProfileData(dataBase64) {
try {
const privateKey = serverKeys.playerCertificateKeys.private
const signer = crypto.createSign("SHA1")
signer.update(dataBase64)
signer.end()
return signer.sign(privateKey, "base64")
} catch (err) {
console.error("Signing failed:", err)
return null
}
}
module.exports = {
getRegistrationCountryFromIp
getRegistrationCountryFromIp,
signProfileData
}