36 private const TLS_KEY_ON_COMPLETION =
"completion";
38 public const MOJANG_AUDIENCE =
"api://auth-minecraft-services/multiplayer";
48 private ?
string $clientPublicKeyDer =
null;
55 private string $selfSignedKeyDer,
56 private string $clientDataJwt,
57 private bool $authRequired,
58 \Closure $onCompletion
60 $this->
storeLocal(self::TLS_KEY_ON_COMPLETION, $onCompletion);
65 $this->clientPublicKeyDer = $this->validateChain();
68 $disconnectMessage = $e->getDisconnectMessage();
73 private function validateChain() : string{
74 $claims = AuthJwtHelper::validateSelfSignedAuthToken($this->jwt, $this->selfSignedKeyDer, audience: self::MOJANG_AUDIENCE);
77 $clientDerKey = base64_decode($claims->cpk, strict:
true);
78 if($clientDerKey ===
false){
79 throw new VerifyLoginException(
"Invalid client public key: base64 error decoding");
82 AuthJwtHelper::validateSelfSignedToken($this->clientDataJwt, $clientDerKey);
92 $callback = $this->fetchLocal(self::TLS_KEY_ON_COMPLETION);
93 $callback(
false, $this->authRequired, $this->error instanceof
NonThreadSafeValue ? $this->error->
deserialize() : $this->error, $this->clientPublicKeyDer);