UNPKG

@xmcl/user

Version:

Minecraft user related functions, including Yggdrasil authenticator, player skin fetcher, and Mojang security API

197 lines 6.32 kB
/// <reference types="node" /> import { fetch } from 'undici'; /** * Users defined question when they register this account * * The question id, content mapping is: * * 1. What is your favorite pet's name? * 2. What is your favorite movie? * 3. What is your favorite author's last name? * 4. What is your favorite artist's last name? * 5. What is your favorite actor's last name? * 6. What is your favorite activity? * 7. What is your favorite restaurant? * 8. What is the name of your favorite cartoon? * 9. What is the name of the first school you attended? * 10. What is the last name of your favorite teacher? * 11. What is your best friend's first name? * 12. What is your favorite cousin's name? * 13. What was the first name of your first girl/boyfriend? * 14. What was the name of your first stuffed animal? * 15. What is your mother's middle name? * 16. What is your father's middle name? * 17. What is your oldest sibling's middle name? * 18. In what city did your parents meet? * 19. In what hospital were you born? * 20. What is your favorite team? * 21. How old were you when you got your first computer? * 22. How old were you when you got your first gaming console? * 23. What was your first video game? * 24. What is your favorite card game? * 25. What is your favorite board game? * 26. What was your first gaming console? * 27. What was the first book you ever read? * 28. Where did you go on your first holiday? * 29. In what city does your grandmother live? * 30. In what city does your grandfather live? * 31. What is your grandmother's first name? * 32. What is your grandfather's first name? * 33. What is your least favorite food? * 34. What is your favorite ice cream flavor? * 35. What is your favorite ice cream flavor? * 36. What is your favorite place to visit? * 37. What is your dream job? * 38. What color was your first pet? * 39. What is your lucky number?s * */ export interface MojangChallenge { readonly answer: { id: number; }; readonly question: { id: number; question: string; }; } export interface MojangChallengeResponse { id: number; answer: string; } export interface MinecraftProfileResponse { id: string; name: string; skins: [ { id: string; state: 'ACTIVE' | 'string'; url: string; variant: 'CLASSIC' | string; alias: 'STEVE' | string; } ]; capes: [ { id: string; state: 'ACTIVE' | string; url: string; } ]; } export interface MinecraftOwnershipResponse { /** * If the account doesn't own the game, the items array will be empty. */ items: Array<{ name: 'product_minecraft' | 'game_minecraft'; /** * jwt signature */ signature: string; }>; /** * jwt signature */ signature: string; keyId: string; } export interface MinecraftProfileErrorResponse { path: '/minecraft/profile'; errorType: 'NOT_FOUND' | string; error: string | 'NOT_FOUND'; errorMessage: string; developerMessage: string; } export interface MojangSkin { id: string; state: 'ACTIVE' | 'INACTIVE'; url: string; variant: 'SLIM' | 'CLASSIC'; } export interface MojangCape { id: string; state: 'ACTIVE' | 'INACTIVE'; url: string; /** * Capes name */ alias: string; } export interface MicrosoftMinecraftProfile { id: string; name: string; skins: MojangSkin[]; capes: MojangCape[]; } export interface NameChangeInformation { changedAt: string; createdAt: string; nameChangeAllowed: boolean; } export declare enum NameAvailability { DUPLICATE = "DUPLICATE", AVAILABLE = "AVAILABLE", NOT_ALLOWED = "NOT_ALLOWED" } export declare class SetNameError extends Error { path: string; errorType: string; error: string; details: object; errorMessage: string; developerMessage: string; constructor(message: string, err: any); } export declare class SetSkinError extends Error { path: string; errorType: string; error: string; details: object; errorMessage: string; developerMessage: string; constructor(message: string, err: any); } export declare class MojangError extends Error { path: string; errorMessage: string; developerMessage: string; constructor(err: any); } export declare class UnauthorizedError extends MojangError { name: string; constructor(err: any); } export declare class ProfileNotFoundError extends MojangError { name: string; constructor(err: any); } export interface MojangClientOptions { fetch?: typeof fetch; } /** * The mojang api client. Please referece https://wiki.vg/Mojang_API. * * All the apis need user to authenticate the access token from microsoft. * @see {@link MicrosoftAuthenticator} */ export declare class MojangClient { private fetch; constructor(options?: MojangClientOptions); setName(name: string, token: string, signal?: AbortSignal): Promise<MicrosoftMinecraftProfile>; getNameChangeInformation(token: string): Promise<NameChangeInformation>; checkNameAvailability(name: string, token: string, signal?: AbortSignal): Promise<NameAvailability>; getProfile(token: string, signal?: AbortSignal): Promise<MicrosoftMinecraftProfile>; setSkin(fileName: string, skin: string | Buffer, variant: 'slim' | 'classic', token: string, signal?: AbortSignal): Promise<MinecraftProfileResponse>; resetSkin(token: string, signal?: AbortSignal): Promise<void>; hideCape(token: string, signal?: AbortSignal): Promise<void>; showCape(capeId: string, token: string, signal?: AbortSignal): Promise<MicrosoftMinecraftProfile>; verifySecurityLocation(token: string, signal?: AbortSignal): Promise<boolean>; getSecurityChallenges(token: string): Promise<MojangChallenge[]>; submitSecurityChallenges(answers: MojangChallengeResponse[], token: string): Promise<void>; /** * Return the owner ship list of the player with those token. */ checkGameOwnership(token: string, signal?: AbortSignal): Promise<MinecraftOwnershipResponse>; } //# sourceMappingURL=mojang.d.ts.map