@peacockproject/core
Version:
Type definitions for Peacock's core.
48 lines (47 loc) • 1.75 kB
TypeScript
import { AxiosResponse } from "axios";
import type { Request } from "express";
import type { GameVersion } from "./types/types";
/**
* Container for official server authentication tokens.
*/
export declare class OfficialServerAuth {
/**
* If this authentication container is ready for use.
*/
initialized?: boolean;
protected _usableToken?: string;
protected _refreshToken?: string;
protected _gameAuthToken?: string;
private readonly _headers;
/**
* Kick things off.
* @param gameVersion The game version.
* @param gameAuthToken The token for the 3rd party game provider (Steam or Epic).
*/
constructor(gameVersion: GameVersion, gameAuthToken: string);
/**
* Authenticates the client with the official service for the first time.
* @param req The initial client request.
*/
_initiallyAuthenticate(req: Request): Promise<void>;
/**
* Makes a request with the required context.
* @param url The URL to fetch.
* @param get If the request should be a GET (true), or POST (false).
* @param body The request's body (defaults to {}).
* @param headers The request's extra headers (defaults to {}).
* @returns The response data.
*/
_useService<Data = any>(url: string, get: boolean, body?: {}, headers?: {}): Promise<AxiosResponse<Data>>;
/**
* Gain a new authentication token.
*/
_doRefresh(): Promise<void>;
/**
* Authenticate for the first time.
* @param req The request from the Hitman client connecting to Peacock.
* @returns The token data fetched from the official servers.
*/
private _firstTimeObtainData;
}
export declare const userAuths: Map<string, OfficialServerAuth>;