minecraft-core-master
Version:
Núcleo avanzado para launchers de Minecraft. Descarga, instala y ejecuta versiones de Minecraft, assets, librerías, Java y loaders de forma automática y eficiente.
124 lines (123 loc) • 3.51 kB
TypeScript
/**
* @description
* Tipo de cliente utilizado para iniciar sesión con Microsoft.
* ----
* Type of client used to authenticate with Microsoft.
*/
export type MicrosoftClientType = 'electron' | 'nwjs' | 'terminal';
/**
* @description
* Representa un skin o capa de Minecraft.
* ----
* Represents a Minecraft skin or cape.
*/
export interface MinecraftSkin {
id?: string;
state?: string;
url?: string;
variant?: string;
alias?: string;
base64?: string;
}
/**
* @description
* Datos del perfil del usuario de Minecraft.
* ----
* Minecraft user profile data.
*/
export interface MinecraftProfile {
id: string;
name: string;
skins?: MinecraftSkin[];
capes?: MinecraftSkin[];
}
/**
* @description
* Respuesta de error genérica usada por el módulo.
* ----
* Generic error response used by the module.
*/
export interface AuthError {
error: string;
errorType?: string;
[key: string]: any;
}
/**
* @description
* Respuesta completa de autenticación de Minecraft.
* ----
* Full Minecraft authentication response.
*/
export interface AuthResponse {
access_token: string;
client_token: string;
uuid: string;
name: string;
refresh_token: string;
user_properties: string;
meta: {
type: 'Xbox';
access_token_expires_in: number;
demo: boolean;
};
xboxAccount: {
xuid: string;
gamertag: string;
ageGroup: string;
};
profile: {
skins?: MinecraftSkin[];
capes?: MinecraftSkin[];
};
}
/**
* @description
* Clase principal para realizar la autenticación de Microsoft y Minecraft.
* Se encarga de toda la cadena: OAuth2 → Xbox Live → XSTS → Minecraft Login → Perfil.
* ----
* Main class for authenticating Microsoft + Minecraft accounts.
* Handles full chain: OAuth2 → Xbox Live → XSTS → Minecraft Login → Profile.
*/
export default class Microsoft {
client_id: string;
type: MicrosoftClientType;
constructor(client_id: string);
/**
* @description
* Inicia el proceso de login mostrando la UI correcta según el entorno.
* Devuelve el código de autorización que luego será intercambiado por un token.
* ----
* Starts login process using the correct UI (Electron/NW/Terminal).
* Returns the authorization code to exchange for token later.
*/
getAuth(type?: MicrosoftClientType, url?: string): Promise<AuthResponse | AuthError | false>;
/**
* @description
* Intercambia el código OAuth2 por tokens de inicio de sesión.
* ----
* Exchanges authorization code for OAuth2 login tokens.
*/
private exchangeCodeForToken;
/**
* @description
* Refresca el token si expiró, o actualiza el perfil si aún es válido.
* ----
* Refreshes the token if expired, or updates profile if still valid.
*/
refresh(acc: AuthResponse | any): Promise<AuthResponse | AuthError>;
/**
* @description
* Realiza toda la cadena de login: XBL → XSTS → Minecraft → Perfil.
* ----
* Performs full login chain: XBL → XSTS → Minecraft → Profile.
*/
private getAccount;
/**
* Obtiene el perfil de Minecraft del usuario, incluyendo skins y capas en base64.
* ----
* Fetches player's Minecraft profile including skins and capes converted to base64.
*/
getProfile(mcLogin: {
access_token: string;
}): Promise<MinecraftProfile | AuthError>;
}