Add public keys and blocked servers routes

Introduces two new routes: one for serving public keys from the certificates manager at /minecraftservices/publickeys, and another for listing blocked servers from the sessions service at /sessionsserver/blockedservers. These endpoints provide necessary data for authentication and server validation processes.
This commit is contained in:
Gilles Lazures 2025-12-24 19:08:38 +01:00
parent 3d0f5c54af
commit 10e4f3f038
2 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,18 @@
const express = require("express")
const router = express.Router()
const certificatesManager = require("../../modules/certificatesManager")
router.get("", (req, res) => {
const keys = certificatesManager.getKeys()
const publicKeys = {}
for (const key in keys) {
publicKeys[key] = [
{
publicKey: certificatesManager.extractKeyFromPem(keys[key].public)
}
]
}
res.status(200).json(publicKeys)
})
module.exports = router

View File

@ -0,0 +1,18 @@
const express = require("express")
const router = express.Router()
const sessionsService = require("../../services/sessionsService")
const { DefaultError } = require("../../errors/errors")
router.get("", async (req, res) => {
const serviceResult = await sessionsService.getBlockedServers()
if (serviceResult instanceof DefaultError) {
return res.status(200).send("")
}
const finalList = []
for (const server of serviceResult.blockedServers) {
finalList.push(server.sha1)
}
return res.status(200).send(finalList.join("\r\n"))
})
module.exports = router