Implement player certificate fetching for Mojang auth #1409
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
"Mojang auth" (now ironically named) is still in use today by custom authentication servers. We are grateful for node-minecraft-protocol's continued support for it! Some of these custom authentication servers [0][1] support player certificates just like Mojang's API servers do, at the
$servicesServer/player/certificates
endpoint (when using Mojang's servers,$servicesServer = https://api.minecraftservices.com
). The process for fetching player certificates is no different when using a Microsoft account or a Mojang/other account. It works like any other Mojang API route that requires an accessToken. But in node-minecraft-protocol, Microsoft authentication, including certificate fetching, is done in prismarine-auth and certificate fetching isn't implemented for third-party accounts.This PR copies the certificate fetching logic from prismarine-auth to
mojangAuth.js
in node-minecraft-protocol to make certificate fetching work with third-party accounts. Certificate fetching can be disabled by settingdisableChatSigning: true
just like with Microsoft accounts. If certificates fetching fails, a warning is printed and login continues.An alternative approach to copying would be to export
fetchCertificates
from prismarine-auth and somehow make it possible to override theservicesServer
there. But IMHO the cleaner option is to duplicate the code in node-minecraft-protocol, it's only ~20 lines.[0] https://github.com/unmojang/drasl
[1] https://ely.by/