UNPKG

2.67 kBTypeScriptView Raw
1/// <reference types="node" />
2import Session from './types/Session';
3import Thread from './types/Thread';
4import User from './types/User';
5import { Readable } from 'stream';
6import Message, { MessageOptions } from './types/Message';
7import EventEmitter from 'events';
8import StrictEventEmitter from 'strict-event-emitter-types';
9import ClientEvents from './ClientEvents';
10import DeviceId from './types/DeviceId';
11export interface ClientOptions {
12 selfListen?: boolean;
13 session?: Session;
14 deviceId?: DeviceId;
15}
16declare const Client_base: new () => StrictEventEmitter<EventEmitter, ClientEvents, ClientEvents, "addEventListener" | "removeEventListener", "removeListener" | "on" | "addListener" | "once" | "emit">;
17/**
18 * Main client class
19 */
20export default class Client extends Client_base {
21 private mqttApi;
22 private httpApi;
23 private readonly session;
24 private seqId;
25 loggedIn: boolean;
26 private options;
27 constructor(options?: ClientOptions);
28 login(email: string, password: string): Promise<void>;
29 private doLogin;
30 getSession(): Session;
31 sendMessage(threadId: string, message: string, options?: MessageOptions): Promise<{
32 succeeded: boolean;
33 errStr?: string; /**
34 * Indicate that the user is currently present in the conversation.
35 * Only relevant for non-group conversations
36 */
37 }>;
38 /**
39 * Indicate that the user is currently present in the conversation.
40 * Only relevant for non-group conversations
41 */
42 sendPresenceState(recipientUserId: string, present: boolean): Promise<void>;
43 /**
44 * Send "User is typing" message.
45 * In a non-group conversation, sendPresenceState() must be called first.
46 */
47 sendTypingState(threadOrRecipientUserId: string, present: boolean): Promise<void>;
48 /**
49 * Mark a message as read.
50 */
51 sendReadReceipt(message: Message): Promise<void>;
52 getThreadList(count: number): Promise<Thread[]>;
53 sendAttachmentFile(threadId: string, attachmentPath: string, extension?: string): Promise<any>;
54 sendAttachmentStream(threadId: string, extension: string, attachment: Readable): Promise<any>;
55 getAttachmentURL(messageId: string, attachmentId: string): Promise<string>;
56 getAttachmentInfo(messageId: string, attachmentId: string): Promise<any>;
57 getStickerURL(stickerId: number): Promise<string>;
58 getThreadInfo(threadId: string): Promise<Thread>;
59 getUserInfo(userId: string): Promise<User>;
60 getMessages(threadId: string, count: number): Promise<Message>;
61 private createQueue;
62 private connectQueue;
63 private handleMS;
64 private handleMessage;
65}
66export {};