Skip to content

bedrock-apis/carolina-authentication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README

Lightweight authentication utilities for validating Minecraft protocol login tokens.

The Authentication class provides JWT parsing, header/body extraction, and signature validation against OpenID configuration and JWK sets. AuthenticationType defines supported token modes: Online, SubClient, and OfflineSelfSigned. OpenConfiguration retrieves and caches OpenID metadata and keys used to verify incoming tokens. Use Authentication.authenticate() to validate a token and obtain a typed JWTBodyObject for downstream protocol handling.

Usage Example

const parsed = Authentication.parse(data.authentication);
const { AuthenticationType: type, Token } = parsed;

if (type !== AuthenticationType.Online) {
   // Prevent connections that are not authenticated
  player.connection.disconnect();
  return;
}

const userIdentity = await Authentication.authenticate(Token).catch(() => {
   // Authentication failed
  player.connection.disconnect();
  return null;
});

if (!userIdentity) return;

console.log("XUID:", userIdentity.xid);
console.log("CPK:", userIdentity.cpk);

About

fast, minimal dependency, modular package for minecraft JWT authentication

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published