@xmcl/user
Version:
Minecraft user related functions, including Yggdrasil authenticator, player skin fetcher, and Mojang security API
107 lines • 3.9 kB
TypeScript
export interface XBoxResponse {
IssueInstant: string;
NotAfter: string;
Token: string;
DisplayClaims: {
xui: [
{
/**
* gamer tag
*/
gtg: string;
/**
* user id
*/
xid: string;
uhs: string;
}
];
};
}
export interface XBoxGameProfileResponse {
profileUsers: [
{
id: string;
hostId: string | null;
settings: [
{
'id': 'Gamertag';
'value': string;
},
{
'id': 'PublicGamerpic';
'value': string;
}
];
isSponsoredUser: boolean;
}
];
}
export interface MinecraftAuthResponse {
username: string;
roles: [];
access_token: string;
token_type: 'Bearer';
expires_in: number;
}
export interface MicrosoftAuthenticatorOptions {
fetch?: typeof fetch;
}
/**
* The microsoft authenticator for Minecraft (Xbox) account.
*/
export declare class MicrosoftAuthenticator {
fetch: typeof fetch;
constructor(options: MicrosoftAuthenticatorOptions);
/**
* Authenticate with xbox live by ms oauth access token
* @param oauthAccessToken The oauth access token
*/
authenticateXboxLive(oauthAccessToken: string, signal?: AbortSignal): Promise<XBoxResponse>;
/**
* Authorize the xbox live. It will get the xsts token in response.
* @param xblResponseToken The {@link XBoxResponse.Token}
*/
authorizeXboxLive(xblResponseToken: string, relyingParty?: 'rp://api.minecraftservices.com/' | 'http://xboxlive.com', signal?: AbortSignal): Promise<XBoxResponse>;
/**
* Get xbox user profile, including **username** and **avatar**.
*
* You can find the parameters from the {@link XBoxResponse}.
*
* @param xuid The `xuid` in a {@link XBoxResponse.DisplayClaims}
* @param uhs The `uhs` in a {@link XBoxResponse.DisplayClaims}
* @param xstsToken The {@link XBoxResponse.Token}
* @returns The user game profile.
*/
getXboxGameProfile(xuid: string, uhs: string, xstsToken: string, signal?: AbortSignal): Promise<XBoxGameProfileResponse>;
/**
* Acquire both Minecraft and xbox token and xbox game profile.
* You can use the xbox token to login Minecraft by {@link loginMinecraftWithXBox}.
*
* This method is the composition of calling
* - {@link authenticateXboxLive}
* - {@link authorizeXboxLive} to `rp://api.minecraftservices.com/`
* - {@link authorizeXboxLive} to `http://xboxlive.com`
* - {@link getXboxGameProfile}
*
* You can call them individually if you want a more detailed control.
*
* @param oauthAccessToken The microsoft access token
* @param signal The abort signal
* @returns The object contain xstsResponse (minecraft xbox token) and xbox game profile
*/
acquireXBoxToken(oauthAccessToken: string, signal?: AbortSignal): Promise<{
minecraftXstsResponse: XBoxResponse;
liveXstsResponse: XBoxResponse;
}>;
/**
* This will return the response with Minecraft access token!
*
* This access token allows us to launch the game, but, we haven't actually checked if the account owns the game. Everything until here works with a normal Microsoft account!
*
* @param uhs uhs from {@link XBoxResponse} of {@link acquireXBoxToken}
* @param xstsToken You need to get this token from {@link acquireXBoxToken}
*/
loginMinecraftWithXBox(uhs: string, xstsToken: string, signal?: AbortSignal): Promise<MinecraftAuthResponse>;
}
//# sourceMappingURL=microsoft.d.ts.map