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:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user