import Base, { MaybeRaw } from "../../Base"; import { PaginatedResponse, SearchParams, Version } from "../../interfaces/global"; import { Agent, Stats, TargetAgent } from "../../interfaces/mothership"; type RecurrentInfo = Pick; type HelloInfo = RecurrentInfo & { nickname?: string; bundleVersion: string; installerVersion?: string; ip?: string; }; export default class MothershipService extends Base { /** * Requests the endpoint version * @returns Version object */ version(raw?: { raw: R; }): Promise>; /** * Say hello as an agent to the mothership * * @param uuid Agent's UUID * @param uuidSignature HMAC-SHA256 hash of the Agent's UUID using the Agent's secret as the key * @param info Information about the agent's uuid, hardware and nickname * @return an Agent object */ hello(uuid: string, uuidSignature: string, info: HelloInfo, raw?: { raw: R; }): Promise>; /** * Say hello again as an agent to the mothership. * * This call should only be made after an initial hello. * * The session token obtained in the hello endpoint must be used here. Use the setAuthToken method to do so. * * @param info Information about the agent's system resources. * @return an Agent object */ helloAgain(info: RecurrentInfo, raw?: { raw: R; }): Promise>; /** * Register an agent to the mothership. * * This call should only be made once per agent, not once per agent session. * * @param uuid UUID of the Agent * @param info Information about the agent's hardware and nickname. * @param publicKey the public key of the agent that will be used for cryptography. The agent should remember its private key. * @return an object holding a secret encrypted with the public key. The agent must decrypt it using its private key in order to use the /hello endpoint. */ register(uuid: string, info: Pick>, publicKey: string | Buffer, raw?: { raw: R; }): Promise>; /** * Connect to an organization. * * This call should only be made after an initial hello. * * The session token obtained in the hello endpoint must be used here. Use the setAuthToken method to do so. * * @param orgName Name of the organization * @param memberToken JWT assigned to a member of the organization * @param email Email of the user owner of the JWT */ connect(orgName: string, memberToken: string, email: string, raw?: { raw: R; }): Promise>; /** * Disconnect from an organization. * * This call should only be made after an initial hello. * * The session token obtained in the hello endpoint must be used here. Use the setAuthToken method to do so. * * @param orgName Name of the organization * @param email Email of the user */ disconnect(orgName: string, email: string, raw?: { raw: R; }): Promise>; /** * Disconnect as a target. * * This call should only be made after an initial hello. * * The session token obtained in the hello endpoint must be used here. Use the setAuthToken method to do so. * * @param email Email of the target */ disconnectTarget(email: string, raw?: { raw: R; }): Promise>; /** * Search among the available targets for a given organization. * * @param orgName Name of the organization * @returns Object containing an array of retrieved agents and the total number of available found in the database (independent of limit and page) */ searchAvailableTargets({ orgName, filters, sorting, limit, page }: SearchParams & { orgName: string; }, raw?: { raw: R; }): Promise>>; /** * Retrieves usage statistics for a specific organization. * @param orgName Name of the organization * @returns Statistics information */ getStats(orgName: string): Promise; protected getEndpoint(endpoint: string): string; } export {};