import { zJoinRequest } from "../ws-api"; import { ZLobbyResp, ZPlayerResp, ZShopBuyReq, ZShopBuyResp, ZShopItemsResp } from "../api"; import Connection from "./Connection"; import { Endpoint } from "./endpoints"; import { SchemaInput } from "../computed-types-wrapper"; /** * The `Authentication` class represents an authenticated user. It provides methods that query the game for * information. */ export default class Authentication { /** * The JWT of the currently authenticated user. It's not recommended to use this manually, but you can if need be. */ readonly token: string; private _idCached; /** * The ID of the account, if the account is logged in as an account. */ get id(): string | undefined; /** * Determines if the token given is a guest token. */ get isGuest(): boolean; /** * Creates a new `Authentication`. If you don't have a token, call the `auth` method instead. * @param token The token to use for authenticating with Smiley Face Game */ constructor(token: string); /** * Attempts to join a world, given the join request. * @param joinRequest The request for the world to join. * @param endpoint An optional custom endpoint to use for connecting. * @param extraChecks Whether or not to perform additional checks on packets sent to/from the server. * @returns A promise that resolves to a `Connection`, which can be used to control your in game player. */ connect(joinRequest: SchemaInput, endpoint?: Endpoint, extraChecks?: boolean): Promise; /** * Attempts to list the lobby as it is visible to the current player. * @param endpoint An optional custom endpoint to use for making the request. * @returns A promise that resolves to the response of the API when making a lobby request. */ lobby(endpoint?: Endpoint): Promise; /** * Attempts to list information about the current player. * @param endpoint An optional custom endpoint to use for making the request. * @returns A promise that resolves to the response of the API when making a request for the current player. */ player(endpoint?: Endpoint): Promise; /** * Lists the items in the shop this player has. * @param endpoint An optional custom endpoint to use for making the request * @throws If the current account is a guest, this will throw an exception. * @returns A promise that resolves to the response of the API, a list of shop items. */ shopItems(endpoint?: Endpoint): Promise; /** * Spends energy in the shop. * @param item The item to buy. * @param endpoint An optional endpoint to use when making the request. * @returns A promise that resolves to the bought item response. */ buy(item: ZShopBuyReq, endpoint?: Endpoint): Promise; }