main
 1export interface XmppMessage {
 2  from: string;
 3  to: string;
 4  body: string;
 5  type: "chat" | "groupchat";
 6  id?: string;
 7}
 8
 9export interface XmppPresence {
10  from: string;
11  to: string;
12  type?: "available" | "unavailable" | "subscribe" | "subscribed";
13  show?: "away" | "chat" | "dnd" | "xa";
14  status?: string;
15}
16
17// Extract bare JID (without resource)
18export function bareJid(jid: string): string {
19  return jid.split("/")[0];
20}
21
22// Extract resource from JID
23export function resourceFromJid(jid: string): string | null {
24  const parts = jid.split("/");
25  return parts.length > 1 ? parts[1] : null;
26}
27
28// Extract local part (username) from JID
29export function localFromJid(jid: string): string {
30  return bareJid(jid).split("@")[0];
31}
32
33// Extract domain from JID
34export function domainFromJid(jid: string): string {
35  return bareJid(jid).split("@")[1];
36}