main
1declare module "@xmpp/client" {
2 export interface JID {
3 local: string;
4 domain: string;
5 resource?: string;
6 toString(): string;
7 }
8
9 export interface ClientOptions {
10 service: string;
11 username: string;
12 password: string;
13 }
14
15 export interface XMPPClient {
16 on(event: "error", handler: (err: Error) => void): void;
17 on(event: "offline", handler: () => void): void;
18 on(event: "online", handler: (address: JID) => Promise<void>): void;
19 on(event: "stanza", handler: (stanza: Element) => Promise<void>): void;
20 send(stanza: Element): Promise<void>;
21 start(): Promise<void>;
22 stop(): Promise<void>;
23 }
24
25 export interface Element {
26 is(name: string): boolean;
27 attrs: Record<string, string>;
28 getChildText(name: string): string | null;
29 }
30
31 export function client(options: ClientOptions): XMPPClient;
32 export function xml(name: string, attrs?: Record<string, unknown>, ...children: unknown[]): Element;
33 export function jid(jid: string): JID;
34}
35
36declare module "@xmpp/xml" {
37 export interface Element {
38 is(name: string): boolean;
39 attrs: Record<string, string>;
40 getChildText(name: string): string | null;
41 }
42}
43
44declare module "@xmpp/debug" {
45 import type { XMPPClient } from "@xmpp/client";
46 export default function debug(client: XMPPClient): void;
47}