import { CookieJar } from "tough-cookie"; import WebSocket from "ws"; import Client, { type Host } from "./Client"; import Message from "./Message"; import type Room from "./Room.js"; import User from "./User"; export interface IProfileData { id: number; name: string; about: string; isModerator: boolean; roomCount: number; messageCount: number; reputation: number; lastSeen: number; lastMessage: number; parentId?: number; parentHost?: Host; parentSite?: string; } export interface ITranscriptData { id: number; user: User; content: string; roomId: number; roomName: string; edited: boolean; parentMessageId?: number; } export interface IRoomSave { defaultAccess?: "read-only" | "read-write"; description: string; host: Host; name: string; tags?: string[]; } export declare enum DeleteMessageStatus { SUCCESS = 0, TOO_OLD = 1, DELETED = 2, UNKNOWN = 4 } /** * Used internally by {@link Client} to provide the low-level * interaction with SE servers. * * @class Browser * @property {boolean} loggedIn User logged in */ export declare class Browser { #private; loggedIn: boolean; constructor(client: Client); /** * @summary getter for login host domain name * @returns {string} * @memberof Browser# */ get loginHost(): Host; /** * @summary proxy getter for the chat host URL * @returns {string} * @memberof Browser# */ get root(): string; /** * @summary The chat key for use with ws-auth, and other authy endpoints * @returns {Promise} * @memberof Browser# */ get chatFKey(): Promise; /** * @summary The user id of the logged in user * @returns {Promise} * @memberof Browser# */ get userId(): Promise; /** * @summary The user name of the logged in user * @returns {Promise} * @memberof Browser# */ get userName(): Promise; /** * Attempts to login to stack exchange, using the provided * cookie jar string, which was retrieved from the {@Link Browser#login} * method. * * @param {string|CookieJar.Serialized} cookie A cookie jar string * @returns {Promise} A promise that completes with the user logs in * @memberof Browser# */ loginCookie(cookie: string | CookieJar.Serialized): Promise; /** * Attempts to login to stack exchange, using the provided * email and password. Returns a cookie jar string, which * you can pass back in to loginCookieJar for use with further * logins. * * @param {string} email Email * @param {string} password Password * @returns {Promise} A cookie jar containing account pertitent details. * @memberof Browser# */ login(email: string, password: string): Promise; /** * @summary attempts to logout from the Stack Exchange network * @returns {Promise} status of the logout attempt * @memberof Browser# */ logout(): Promise; /** * @summary attempts to create a {@link Room} * @param config room configuration options */ createRoom(config: IRoomSave): Promise; /** * @summary attempts to update a {@link Room} * @param roomId id of the room to update * @param config room configuration options */ updateRoom(roomId: number, config: IRoomSave): Promise; /** * @summary Joins a given room * @param room The room or room ID to join * @returns {Promise} A promise that resolves when the user has successfully joined the room * @memberof Browser# */ joinRoom(room: number | Room): Promise; /** * @summary Leaves a given room * @param room The room or room ID to leave * @returns {Promise} A promise that resolves when the user leaves the room * @memberof Browser# */ leaveRoom(room: number | Room): Promise; /** * @summary Leaves all rooms * @returns {Promise} A promise resolving when the user leaves all rooms * @memberof Browser# */ leaveAllRooms(): Promise; /** * @summary lists users in a given room * @param room The room or room ID */ listUsers(room: number | Room): Promise; /** * @summary Watch a room, and returns the websocket * @param room The room or room ID to join * @returns {Promise} The websocket of this room * @memberof Browser# */ watchRoom(room: number | Room): Promise; /** * @summary Fetches a given user's profile * @param user The user or user ID to fetch * @returns {Promise} The profile object * @memberof Browser# */ getProfile(user: number | User): Promise; /** * @summary Scrapes the transcript for a message, and returns the message metadata * @param message The message or message ID to scrape * @returns {Promise} * @memberof Browser# */ getTranscript(message: number | Message): Promise; /** * @summary Deletes a message * @param {number} messageId ID of the message to delete */ deleteMessage(messageId: number): Promise; /** * @summary Sends a message to a room * @param {number} roomId The room ID to send to * @param {string} text The message to send * @returns {Promise} A promise that resolves the message that was sent * @memberof Browser# */ sendMessage(roomId: number, text: string): Promise; } export default Browser;