Skip to content

@loontail/minecraft-kit v0.8.14 / MojangSession

Type alias: MojangSession

ts
type MojangSession: {
  microsoft: {
     clientId: AzureClientId;
     refreshToken: MicrosoftRefreshToken;
    };
  minecraft: {
     accessToken: string;
     expiresAt: number;
     skins: ReadonlyArray<MojangProfileSkin>;
     username: string;
     uuid: PlayerUuid;
     xuid: string;
    };
};

Combined Microsoft + Minecraft session returned by kit.auth.authorizationCode.run and kit.auth.refresh.

The fields under minecraft are everything OnlineAuth needs plus the raw /minecraft/profile payload so callers do not have to re-fetch it for skin/cape UI. The fields under microsoft are needed only to refresh the session later — persist them to durable storage (encrypted) alongside the user's profile.

Example

ts
import { toOnlineAuth, type MojangSession } from "@loontail/minecraft-kit";

const session: MojangSession = await kit.auth.authorizationCode.run({ onOpenBrowser });
await secrets.save(session.microsoft.refreshToken);
await kit.launch.compose(target, { auth: toOnlineAuth(session) });

Type declaration

MemberTypeDescription
microsoft{
clientId: AzureClientId;
refreshToken: MicrosoftRefreshToken;
}-
microsoft.clientIdAzureClientIdAzure AD application id used to mint the session.
microsoft.refreshTokenMicrosoftRefreshTokenMicrosoft refresh token; used to obtain a fresh session without re-prompting.
minecraft{
accessToken: string;
expiresAt: number;
skins: ReadonlyArray<MojangProfileSkin>;
username: string;
uuid: PlayerUuid;
xuid: string;
}-
minecraft.accessTokenstringBearer token for api.minecraftservices.com and the game itself.
minecraft.expiresAtnumberWall-clock ms timestamp when accessToken expires.
minecraft.skinsReadonlyArray<MojangProfileSkin>Every skin slot Mojang has issued for the user (active + inactive).
minecraft.usernamestringPlayer display name.
minecraft.uuidPlayerUuidPlayer UUID, dashed (e.g. f81d4fae-7dec-11d0-a765-00a0c91e6bf6).
minecraft.xuidstringXbox User ID (XUID) as a numeric string.

Source

src/types/auth.ts:241

MIT License