xhyphersockets 1.4.3 → 2.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/LICENSE +1 -1
  2. package/README.MD +1295 -0
  3. package/WAProto/p.html +1 -0
  4. package/lib/Defaults/index.js +47 -35
  5. package/lib/Defaults/wileys-version.json +3 -0
  6. package/lib/Socket/chats.js +132 -125
  7. package/lib/Socket/messages-recv.js +1 -1
  8. package/lib/Socket/messages-send.js +1 -32
  9. package/lib/Socket/newsletter.js +71 -124
  10. package/lib/Socket/socket.js +1 -1
  11. package/lib/Store/make-in-memory-store.js +1 -1
  12. package/lib/Types/Newsletter.js +18 -38
  13. package/lib/Utils/browser-utils.js +35 -0
  14. package/lib/Utils/event-buffer.js +2 -2
  15. package/lib/Utils/generics.js +47 -8
  16. package/lib/Utils/index.js +3 -4
  17. package/lib/Utils/message-retry-manager.js +128 -0
  18. package/lib/Utils/messages-media.js +37 -45
  19. package/lib/Utils/messages.js +19 -0
  20. package/lib/Utils/process-message.js +19 -0
  21. package/lib/Utils/use-multi-file-auth-state.js +1 -1
  22. package/lib/Utils/validate-connection.js +77 -21
  23. package/lib/Utils/{baileys-event-stream.js → wileys-event-stream.js} +1 -1
  24. package/lib/WABinary/jid-utils.js +3 -1
  25. package/lib/index.js +12 -18
  26. package/package.json +28 -22
  27. package/README.md +0 -252
  28. package/WAProto/index.d.ts +0 -55057
  29. package/WAProto/index.ts.ts +0 -53473
  30. package/lib/Defaults/baileys-version.json +0 -3
  31. package/lib/Defaults/index.d.ts +0 -51
  32. package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
  33. package/lib/Signal/Group/group-session-builder.d.ts +0 -14
  34. package/lib/Signal/Group/group_cipher.d.ts +0 -17
  35. package/lib/Signal/Group/index.d.ts +0 -11
  36. package/lib/Signal/Group/keyhelper.d.ts +0 -10
  37. package/lib/Signal/Group/queue-job.d.ts +0 -1
  38. package/lib/Signal/Group/sender-chain-key.d.ts +0 -13
  39. package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
  40. package/lib/Signal/Group/sender-key-message.d.ts +0 -18
  41. package/lib/Signal/Group/sender-key-name.d.ts +0 -17
  42. package/lib/Signal/Group/sender-key-record.d.ts +0 -30
  43. package/lib/Signal/Group/sender-key-state.d.ts +0 -38
  44. package/lib/Signal/Group/sender-message-key.d.ts +0 -11
  45. package/lib/Signal/libsignal.d.ts +0 -3
  46. package/lib/Socket/Client/index.d.ts +0 -2
  47. package/lib/Socket/Client/types.d.ts +0 -16
  48. package/lib/Socket/Client/websocket.d.ts +0 -13
  49. package/lib/Socket/RHandler.d.ts +0 -416
  50. package/lib/Socket/RHandler.js +0 -530
  51. package/lib/Socket/business.d.ts +0 -172
  52. package/lib/Socket/chats.d.ts +0 -94
  53. package/lib/Socket/groups.d.ts +0 -124
  54. package/lib/Socket/index.d.ts +0 -172
  55. package/lib/Socket/messages-recv.d.ts +0 -161
  56. package/lib/Socket/messages-send.d.ts +0 -152
  57. package/lib/Socket/newsletter.d.ts +0 -136
  58. package/lib/Socket/socket.d.ts +0 -43
  59. package/lib/Socket/usync.d.ts +0 -36
  60. package/lib/Store/index.d.ts +0 -2
  61. package/lib/Store/make-in-memory-store.d.ts +0 -118
  62. package/lib/Store/make-ordered-dictionary.d.ts +0 -13
  63. package/lib/Store/object-repository.d.ts +0 -10
  64. package/lib/Types/Auth.d.ts +0 -103
  65. package/lib/Types/Call.d.ts +0 -13
  66. package/lib/Types/Chat.d.ts +0 -109
  67. package/lib/Types/Contact.d.ts +0 -23
  68. package/lib/Types/Events.d.ts +0 -199
  69. package/lib/Types/GroupMetadata.d.ts +0 -64
  70. package/lib/Types/Label.d.ts +0 -35
  71. package/lib/Types/LabelAssociation.d.ts +0 -29
  72. package/lib/Types/Message.d.ts +0 -402
  73. package/lib/Types/Newsletter.d.ts +0 -103
  74. package/lib/Types/Product.d.ts +0 -78
  75. package/lib/Types/Signal.d.ts +0 -57
  76. package/lib/Types/Socket.d.ts +0 -119
  77. package/lib/Types/State.d.ts +0 -27
  78. package/lib/Types/USync.d.ts +0 -25
  79. package/lib/Types/index.d.ts +0 -64
  80. package/lib/Utils/audioToBuffer.js +0 -29
  81. package/lib/Utils/auth-utils.d.ts +0 -18
  82. package/lib/Utils/baileys-event-stream.d.ts +0 -16
  83. package/lib/Utils/business.d.ts +0 -22
  84. package/lib/Utils/chat-utils.d.ts +0 -70
  85. package/lib/Utils/crypto.d.ts +0 -40
  86. package/lib/Utils/decode-wa-message.d.ts +0 -35
  87. package/lib/Utils/event-buffer.d.ts +0 -35
  88. package/lib/Utils/generics.d.ts +0 -89
  89. package/lib/Utils/history.d.ts +0 -19
  90. package/lib/Utils/index.d.ts +0 -19
  91. package/lib/Utils/link-preview.d.ts +0 -21
  92. package/lib/Utils/logger.d.ts +0 -11
  93. package/lib/Utils/lt-hash.d.ts +0 -12
  94. package/lib/Utils/make-mutex.d.ts +0 -7
  95. package/lib/Utils/messages-media.d.ts +0 -124
  96. package/lib/Utils/messages.d.ts +0 -75
  97. package/lib/Utils/noise-handler.d.ts +0 -19
  98. package/lib/Utils/process-message.d.ts +0 -42
  99. package/lib/Utils/signal.d.ts +0 -33
  100. package/lib/Utils/streamToBuffer.js +0 -15
  101. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -12
  102. package/lib/Utils/validate-connection.d.ts +0 -10
  103. package/lib/WABinary/constants.d.ts +0 -27
  104. package/lib/WABinary/decode.d.ts +0 -6
  105. package/lib/WABinary/encode.d.ts +0 -2
  106. package/lib/WABinary/generic-utils.d.ts +0 -14
  107. package/lib/WABinary/index.d.ts +0 -5
  108. package/lib/WABinary/jid-utils.d.ts +0 -36
  109. package/lib/WABinary/jid-utils.js.bak +0 -83
  110. package/lib/WABinary/types.d.ts +0 -18
  111. package/lib/WAM/BinaryInfo.d.ts +0 -8
  112. package/lib/WAM/constants.d.ts +0 -38
  113. package/lib/WAM/encode.d.ts +0 -2
  114. package/lib/WAM/index.d.ts +0 -3
  115. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
  116. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
  117. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
  118. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
  119. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
  120. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -8
  121. package/lib/WAUSync/Protocols/index.d.ts +0 -4
  122. package/lib/WAUSync/USyncQuery.d.ts +0 -28
  123. package/lib/WAUSync/USyncUser.d.ts +0 -12
  124. package/lib/WAUSync/index.d.ts +0 -3
  125. package/lib/index.d.ts +0 -16
@@ -1,118 +0,0 @@
1
- import type KeyedDB from '@adiwajshing/keyed-db';
2
- import type { Comparable } from '@adiwajshing/keyed-db/lib/Types';
3
- import { proto } from '../../WAProto';
4
- import type makeMDSocket from '../Socket';
5
- import type { BaileysEventEmitter, Chat, ConnectionState, Contact, GroupMetadata, PresenceData, WAMessage, WAMessageCursor, WAMessageKey } from '../Types';
6
- import { Label } from '../Types/Label';
7
- import { LabelAssociation } from '../Types/LabelAssociation';
8
- import { ILogger } from '../Utils/logger';
9
- import { ObjectRepository } from './object-repository';
10
- type WASocket = ReturnType<typeof makeMDSocket>;
11
- export declare const waChatKey: (pin: boolean) => {
12
- key: (c: Chat) => string;
13
- compare: (k1: string, k2: string) => number;
14
- };
15
- export declare const waMessageID: (m: WAMessage) => string;
16
- export declare const waLabelAssociationKey: Comparable<LabelAssociation, string>;
17
- export type BaileysInMemoryStoreConfig = {
18
- chatKey?: Comparable<Chat, string>;
19
- labelAssociationKey?: Comparable<LabelAssociation, string>;
20
- logger?: ILogger;
21
- socket?: WASocket;
22
- };
23
- declare const _default: (config: BaileysInMemoryStoreConfig) => {
24
- chats: KeyedDB<Chat, string>;
25
- contacts: {
26
- [_: string]: Contact;
27
- };
28
- messages: {
29
- [_: string]: {
30
- array: WAMessage[];
31
- get: (id: string) => WAMessage | undefined;
32
- upsert: (item: WAMessage, mode: "append" | "prepend") => void;
33
- update: (item: WAMessage) => boolean;
34
- remove: (item: WAMessage) => boolean;
35
- updateAssign: (id: string, update: Partial<WAMessage>) => boolean;
36
- clear: () => void;
37
- filter: (contain: (item: WAMessage) => boolean) => void;
38
- toJSON: () => WAMessage[];
39
- fromJSON: (newItems: WAMessage[]) => void;
40
- };
41
- };
42
- groupMetadata: {
43
- [_: string]: GroupMetadata;
44
- };
45
- state: ConnectionState;
46
- presences: {
47
- [id: string]: {
48
- [participant: string]: PresenceData;
49
- };
50
- };
51
- labels: ObjectRepository<Label>;
52
- labelAssociations: KeyedDB<LabelAssociation, string>;
53
- bind: (ev: BaileysEventEmitter) => void;
54
- /** loads messages from the store, if not found -- uses the legacy connection */
55
- loadMessages: (jid: string, count: number, cursor: WAMessageCursor) => Promise<WAMessage[]>;
56
- /**
57
- * Get all available labels for profile
58
- *
59
- * Keep in mind that the list is formed from predefined tags and tags
60
- * that were "caught" during their editing.
61
- */
62
- getLabels: () => ObjectRepository<Label>;
63
- /**
64
- * Get labels for chat
65
- *
66
- * @returns Label IDs
67
- **/
68
- getChatLabels: (chatId: string) => LabelAssociation[];
69
- /**
70
- * Get labels for message
71
- *
72
- * @returns Label IDs
73
- **/
74
- getMessageLabels: (messageId: string) => string[];
75
- loadMessage: (jid: string, id: string) => Promise<WAMessage | undefined>;
76
- mostRecentMessage: (jid: string) => Promise<WAMessage>;
77
- fetchImageUrl: (jid: string, sock: WASocket | undefined) => Promise<string | null | undefined>;
78
- fetchGroupMetadata: (jid: string, sock: WASocket | undefined) => Promise<GroupMetadata>;
79
- fetchMessageReceipts: ({ remoteJid, id }: WAMessageKey) => Promise<proto.IUserReceipt[] | null | undefined>;
80
- toJSON: () => {
81
- chats: KeyedDB<Chat, string>;
82
- contacts: {
83
- [_: string]: Contact;
84
- };
85
- messages: {
86
- [_: string]: {
87
- array: WAMessage[];
88
- get: (id: string) => WAMessage | undefined;
89
- upsert: (item: WAMessage, mode: "append" | "prepend") => void;
90
- update: (item: WAMessage) => boolean;
91
- remove: (item: WAMessage) => boolean;
92
- updateAssign: (id: string, update: Partial<WAMessage>) => boolean;
93
- clear: () => void;
94
- filter: (contain: (item: WAMessage) => boolean) => void;
95
- toJSON: () => WAMessage[];
96
- fromJSON: (newItems: WAMessage[]) => void;
97
- };
98
- };
99
- labels: ObjectRepository<Label>;
100
- labelAssociations: KeyedDB<LabelAssociation, string>;
101
- };
102
- fromJSON: (json: {
103
- chats: Chat[];
104
- contacts: {
105
- [id: string]: Contact;
106
- };
107
- messages: {
108
- [id: string]: WAMessage[];
109
- };
110
- labels: {
111
- [labelId: string]: Label;
112
- };
113
- labelAssociations: LabelAssociation[];
114
- }) => void;
115
- writeToFile: (path: string) => void;
116
- readFromFile: (path: string) => void;
117
- };
118
- export default _default;
@@ -1,13 +0,0 @@
1
- declare function makeOrderedDictionary<T>(idGetter: (item: T) => string): {
2
- array: T[];
3
- get: (id: string) => T | undefined;
4
- upsert: (item: T, mode: "append" | "prepend") => void;
5
- update: (item: T) => boolean;
6
- remove: (item: T) => boolean;
7
- updateAssign: (id: string, update: Partial<T>) => boolean;
8
- clear: () => void;
9
- filter: (contain: (item: T) => boolean) => void;
10
- toJSON: () => T[];
11
- fromJSON: (newItems: T[]) => void;
12
- };
13
- export default makeOrderedDictionary;
@@ -1,10 +0,0 @@
1
- export declare class ObjectRepository<T extends object> {
2
- readonly entityMap: Map<string, T>;
3
- constructor(entities?: Record<string, T>);
4
- findById(id: string): T | undefined;
5
- findAll(): T[];
6
- upsertById(id: string, entity: T): Map<string, T>;
7
- deleteById(id: string): boolean;
8
- count(): number;
9
- toJSON(): T[];
10
- }
@@ -1,103 +0,0 @@
1
- import type { proto } from '../../WAProto';
2
- import type { Contact } from './Contact';
3
- import type { MinimalMessage } from './Message';
4
- export type KeyPair = {
5
- public: Uint8Array;
6
- private: Uint8Array;
7
- };
8
- export type SignedKeyPair = {
9
- keyPair: KeyPair;
10
- signature: Uint8Array;
11
- keyId: number;
12
- timestampS?: number;
13
- };
14
- export type ProtocolAddress = {
15
- name: string;
16
- deviceId: number;
17
- };
18
- export type SignalIdentity = {
19
- identifier: ProtocolAddress;
20
- identifierKey: Uint8Array;
21
- };
22
- export type LTHashState = {
23
- version: number;
24
- hash: Buffer;
25
- indexValueMap: {
26
- [indexMacBase64: string]: {
27
- valueMac: Uint8Array | Buffer;
28
- };
29
- };
30
- };
31
- export type SignalCreds = {
32
- readonly signedIdentityKey: KeyPair;
33
- readonly signedPreKey: SignedKeyPair;
34
- readonly registrationId: number;
35
- };
36
- export type AccountSettings = {
37
- /** unarchive chats when a new message is received */
38
- unarchiveChats: boolean;
39
- /** the default mode to start new conversations with */
40
- defaultDisappearingMode?: Pick<proto.IConversation, 'ephemeralExpiration' | 'ephemeralSettingTimestamp'>;
41
- };
42
- export type AuthenticationCreds = SignalCreds & {
43
- readonly noiseKey: KeyPair;
44
- readonly pairingEphemeralKeyPair: KeyPair;
45
- advSecretKey: string;
46
- me?: Contact;
47
- account?: proto.IADVSignedDeviceIdentity;
48
- signalIdentities?: SignalIdentity[];
49
- myAppStateKeyId?: string;
50
- firstUnuploadedPreKeyId: number;
51
- nextPreKeyId: number;
52
- lastAccountSyncTimestamp?: number;
53
- platform?: string;
54
- processedHistoryMessages: MinimalMessage[];
55
- /** number of times history & app state has been synced */
56
- accountSyncCounter: number;
57
- accountSettings: AccountSettings;
58
- registered: boolean;
59
- pairingCode: string | undefined;
60
- lastPropHash: string | undefined;
61
- routingInfo: Buffer | undefined;
62
- };
63
- export type SignalDataTypeMap = {
64
- 'pre-key': KeyPair;
65
- 'session': Uint8Array;
66
- 'sender-key': Uint8Array;
67
- 'sender-key-memory': {
68
- [jid: string]: boolean;
69
- };
70
- 'app-state-sync-key': proto.Message.IAppStateSyncKeyData;
71
- 'app-state-sync-version': LTHashState;
72
- };
73
- export type SignalDataSet = {
74
- [T in keyof SignalDataTypeMap]?: {
75
- [id: string]: SignalDataTypeMap[T] | null;
76
- };
77
- };
78
- type Awaitable<T> = T | Promise<T>;
79
- export type SignalKeyStore = {
80
- get<T extends keyof SignalDataTypeMap>(type: T, ids: string[]): Awaitable<{
81
- [id: string]: SignalDataTypeMap[T];
82
- }>;
83
- set(data: SignalDataSet): Awaitable<void>;
84
- /** clear all the data in the store */
85
- clear?(): Awaitable<void>;
86
- };
87
- export type SignalKeyStoreWithTransaction = SignalKeyStore & {
88
- isInTransaction: () => boolean;
89
- transaction<T>(exec: () => Promise<T>): Promise<T>;
90
- };
91
- export type TransactionCapabilityOptions = {
92
- maxCommitRetries: number;
93
- delayBetweenTriesMs: number;
94
- };
95
- export type SignalAuthState = {
96
- creds: SignalCreds;
97
- keys: SignalKeyStore | SignalKeyStoreWithTransaction;
98
- };
99
- export type AuthenticationState = {
100
- creds: AuthenticationCreds;
101
- keys: SignalKeyStore;
102
- };
103
- export {};
@@ -1,13 +0,0 @@
1
- export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept' | 'terminate';
2
- export type WACallEvent = {
3
- chatId: string;
4
- from: string;
5
- isGroup?: boolean;
6
- groupJid?: string;
7
- id: string;
8
- date: Date;
9
- isVideo?: boolean;
10
- status: WACallUpdateType;
11
- offline: boolean;
12
- latencyMs?: number;
13
- };
@@ -1,109 +0,0 @@
1
- import type { proto } from '../../WAProto';
2
- import type { AccountSettings } from './Auth';
3
- import type { BufferedEventData } from './Events';
4
- import type { ChatLabelAssociationActionBody } from './LabelAssociation';
5
- import type { MessageLabelAssociationActionBody } from './LabelAssociation';
6
- import type { MinimalMessage, WAMessageKey } from './Message';
7
- /** privacy settings in WhatsApp Web */
8
- export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none';
9
- export type WAPrivacyCallValue = 'all' | 'known';
10
- export type WAPrivacyMessagesValue = 'all' | 'contacts';
11
- export type WAPrivacyOnlineValue = 'all' | 'match_last_seen';
12
- export type WAPrivacyGroupAddValue = 'all' | 'contacts' | 'contact_blacklist';
13
- export type WAReadReceiptsValue = 'all' | 'none';
14
- /** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
15
- export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused';
16
- export declare const ALL_WA_PATCH_NAMES: readonly ["critical_block", "critical_unblock_low", "regular_high", "regular_low", "regular"];
17
- export type WAPatchName = typeof ALL_WA_PATCH_NAMES[number];
18
- export interface PresenceData {
19
- lastKnownPresence: WAPresence;
20
- lastSeen?: number;
21
- }
22
- export type BotListInfo = {
23
- jid: string;
24
- personaId: string;
25
- };
26
- export type ChatMutation = {
27
- syncAction: proto.ISyncActionData;
28
- index: string[];
29
- };
30
- export type WAPatchCreate = {
31
- syncAction: proto.ISyncActionValue;
32
- index: string[];
33
- type: WAPatchName;
34
- apiVersion: number;
35
- operation: proto.SyncdMutation.SyncdOperation;
36
- };
37
- export type Chat = proto.IConversation & {
38
- /** unix timestamp of when the last message was received in the chat */
39
- lastMessageRecvTimestamp?: number;
40
- };
41
- export type ChatUpdate = Partial<Chat & {
42
- /**
43
- * if specified in the update,
44
- * the EV buffer will check if the condition gets fulfilled before applying the update
45
- * Right now, used to determine when to release an app state sync event
46
- *
47
- * @returns true, if the update should be applied;
48
- * false if it can be discarded;
49
- * undefined if the condition is not yet fulfilled
50
- * */
51
- conditional: (bufferedData: BufferedEventData) => boolean | undefined;
52
- }>;
53
- /**
54
- * the last messages in a chat, sorted reverse-chronologically. That is, the latest message should be first in the chat
55
- * for MD modifications, the last message in the array (i.e. the earlist message) must be the last message recv in the chat
56
- * */
57
- export type LastMessageList = MinimalMessage[] | proto.SyncActionValue.ISyncActionMessageRange;
58
- export type ChatModification = {
59
- archive: boolean;
60
- lastMessages: LastMessageList;
61
- } | {
62
- pushNameSetting: string;
63
- } | {
64
- pin: boolean;
65
- } | {
66
- /** mute for duration, or provide timestamp of mute to remove*/
67
- mute: number | null;
68
- } | {
69
- clear: boolean;
70
- } | {
71
- deleteForMe: {
72
- deleteMedia: boolean;
73
- key: WAMessageKey;
74
- timestamp: number;
75
- };
76
- } | {
77
- star: {
78
- messages: {
79
- id: string;
80
- fromMe?: boolean;
81
- }[];
82
- star: boolean;
83
- };
84
- } | {
85
- markRead: boolean;
86
- lastMessages: LastMessageList;
87
- } | {
88
- delete: true;
89
- lastMessages: LastMessageList;
90
- } | {
91
- addChatLabel: ChatLabelAssociationActionBody;
92
- } | {
93
- removeChatLabel: ChatLabelAssociationActionBody;
94
- } | {
95
- addMessageLabel: MessageLabelAssociationActionBody;
96
- } | {
97
- removeMessageLabel: MessageLabelAssociationActionBody;
98
- };
99
- export type InitialReceivedChatsState = {
100
- [jid: string]: {
101
- /** the last message received from the other party */
102
- lastMsgRecvTimestamp?: number;
103
- /** the absolute last message in the chat */
104
- lastMsgTimestamp: number;
105
- };
106
- };
107
- export type InitialAppStateSyncOptions = {
108
- accountSettings: AccountSettings;
109
- };
@@ -1,23 +0,0 @@
1
- export interface Contact {
2
- /** ID either in lid or jid format **/
3
- id: string;
4
- /** ID in Lid (anonymous) format (@lid) **/
5
- lid?: string;
6
- /** ID in Phone Number format (@s.whatsapp.net) **/
7
- jid?: string;
8
- /** name of the contact, you have saved on your WA */
9
- name?: string;
10
- /** name of the contact, the contact has set on their own on WA */
11
- notify?: string;
12
- /** I have no idea */
13
- verifiedName?: string;
14
- /**
15
- * Url of the profile picture of the contact
16
- *
17
- * 'changed' => if the profile picture has changed
18
- * null => if the profile picture has not been set (default profile picture)
19
- * any other string => url of the profile picture
20
- */
21
- imgUrl?: string | null;
22
- status?: string;
23
- }
@@ -1,199 +0,0 @@
1
- import type { Boom } from '@hapi/boom';
2
- import { proto } from '../../WAProto';
3
- import { AuthenticationCreds } from './Auth';
4
- import { WACallEvent } from './Call';
5
- import { Chat, ChatUpdate, PresenceData } from './Chat';
6
- import { Contact } from './Contact';
7
- import { GroupMetadata, ParticipantAction, RequestJoinAction, RequestJoinMethod } from './GroupMetadata';
8
- import { Label } from './Label';
9
- import { LabelAssociation } from './LabelAssociation';
10
- import { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message';
11
- import { ConnectionState } from './State';
12
- import { NewsletterSettingsUpdate, SubscriberAction, NewsletterViewRole } from './Newsletter';
13
- export type BaileysEventMap = {
14
- /** connection state has been updated -- WS closed, opened, connecting etc. */
15
- 'connection.update': Partial<ConnectionState>;
16
- /** credentials updated -- some metadata, keys or something */
17
- 'creds.update': Partial<AuthenticationCreds>;
18
- /** set chats (history sync), everything is reverse chronologically sorted */
19
- 'messaging-history.set': {
20
- chats: Chat[];
21
- contacts: Contact[];
22
- messages: WAMessage[];
23
- isLatest?: boolean;
24
- progress?: number | null;
25
- syncType?: proto.HistorySync.HistorySyncType;
26
- peerDataRequestSessionId?: string | null;
27
- };
28
- /** upsert chats */
29
- 'chats.upsert': Chat[];
30
- /** update the given chats */
31
- 'chats.update': ChatUpdate[];
32
- 'chats.phoneNumberShare': {
33
- lid: string;
34
- jid: string;
35
- };
36
- /** delete chats with given ID */
37
- 'chats.delete': string[];
38
- /** presence of contact in a chat updated */
39
- 'presence.update': {
40
- id: string;
41
- presences: {
42
- [participant: string]: PresenceData;
43
- };
44
- };
45
- 'contacts.upsert': Contact[];
46
- 'contacts.update': Partial<Contact>[];
47
- 'messages.delete': {
48
- keys: WAMessageKey[];
49
- } | {
50
- jid: string;
51
- all: true;
52
- };
53
- 'messages.update': WAMessageUpdate[];
54
- 'messages.media-update': {
55
- key: WAMessageKey;
56
- media?: {
57
- ciphertext: Uint8Array;
58
- iv: Uint8Array;
59
- };
60
- error?: Boom;
61
- }[];
62
- /**
63
- * add/update the given messages. If they were received while the connection was online,
64
- * the update will have type: "notify"
65
- * if requestId is provided, then the messages was received from the phone due to it being unavailable
66
- * */
67
- 'messages.upsert': {
68
- messages: WAMessage[];
69
- type: MessageUpsertType;
70
- requestId?: string;
71
- };
72
- /** message was reacted to. If reaction was removed -- then "reaction.text" will be falsey */
73
- 'messages.reaction': {
74
- key: WAMessageKey;
75
- reaction: proto.IReaction;
76
- }[];
77
- 'message-receipt.update': MessageUserReceiptUpdate[];
78
- 'groups.upsert': GroupMetadata[];
79
- 'groups.update': Partial<GroupMetadata>[];
80
- /** apply an action to participants in a group */
81
- 'group-participants.update': {
82
- id: string;
83
- author: string;
84
- participants: string[];
85
- action: ParticipantAction;
86
- };
87
- 'group.join-request': {
88
- id: string;
89
- author: string;
90
- participant: string;
91
- action: RequestJoinAction;
92
- method: RequestJoinMethod;
93
- };
94
- 'newsletter.reaction': {
95
- id: string;
96
- server_id: string;
97
- reaction: {
98
- code?: string;
99
- count?: number;
100
- removed?: boolean;
101
- };
102
- };
103
- 'newsletter.view': {
104
- id: string;
105
- server_id: string;
106
- count: number;
107
- };
108
- /**don't handles subscribe/unsubscribe actions */
109
- 'newsletter-participants.update': {
110
- id: string;
111
- author: string;
112
- user: string;
113
- new_role: NewsletterViewRole;
114
- action: SubscriberAction;
115
- };
116
- 'newsletter-settings.update': {
117
- id: string;
118
- update: NewsletterSettingsUpdate;
119
- };
120
- 'blocklist.set': {
121
- blocklist: string[];
122
- };
123
- 'blocklist.update': {
124
- blocklist: string[];
125
- type: 'add' | 'remove';
126
- };
127
- /** Receive an update on a call, including when the call was received, rejected, accepted */
128
- 'call': WACallEvent[];
129
- 'labels.edit': Label;
130
- 'labels.association': {
131
- association: LabelAssociation;
132
- type: 'add' | 'remove';
133
- };
134
- };
135
- export type BufferedEventData = {
136
- historySets: {
137
- chats: {
138
- [jid: string]: Chat;
139
- };
140
- contacts: {
141
- [jid: string]: Contact;
142
- };
143
- messages: {
144
- [uqId: string]: WAMessage;
145
- };
146
- empty: boolean;
147
- isLatest: boolean;
148
- progress?: number | null;
149
- syncType?: proto.HistorySync.HistorySyncType;
150
- peerDataRequestSessionId?: string;
151
- };
152
- chatUpserts: {
153
- [jid: string]: Chat;
154
- };
155
- chatUpdates: {
156
- [jid: string]: ChatUpdate;
157
- };
158
- chatDeletes: Set<string>;
159
- contactUpserts: {
160
- [jid: string]: Contact;
161
- };
162
- contactUpdates: {
163
- [jid: string]: Partial<Contact>;
164
- };
165
- messageUpserts: {
166
- [key: string]: {
167
- type: MessageUpsertType;
168
- message: WAMessage;
169
- };
170
- };
171
- messageUpdates: {
172
- [key: string]: WAMessageUpdate;
173
- };
174
- messageDeletes: {
175
- [key: string]: WAMessageKey;
176
- };
177
- messageReactions: {
178
- [key: string]: {
179
- key: WAMessageKey;
180
- reactions: proto.IReaction[];
181
- };
182
- };
183
- messageReceipts: {
184
- [key: string]: {
185
- key: WAMessageKey;
186
- userReceipt: proto.IUserReceipt[];
187
- };
188
- };
189
- groupUpdates: {
190
- [jid: string]: Partial<GroupMetadata>;
191
- };
192
- };
193
- export type BaileysEvent = keyof BaileysEventMap;
194
- export interface BaileysEventEmitter {
195
- on<T extends keyof BaileysEventMap>(event: T, listener: (arg: BaileysEventMap[T]) => void): void;
196
- off<T extends keyof BaileysEventMap>(event: T, listener: (arg: BaileysEventMap[T]) => void): void;
197
- removeAllListeners<T extends keyof BaileysEventMap>(event: T): void;
198
- emit<T extends keyof BaileysEventMap>(event: T, arg: BaileysEventMap[T]): boolean;
199
- }
@@ -1,64 +0,0 @@
1
- import { Contact } from './Contact';
2
- export type GroupParticipant = (Contact & {
3
- isAdmin?: boolean;
4
- isSuperAdmin?: boolean;
5
- admin?: 'admin' | 'superadmin' | null;
6
- jid?: string;
7
- lid?: string;
8
- });
9
- export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote' | 'modify';
10
- export type RequestJoinAction = 'created' | 'revoked' | 'rejected';
11
- export type RequestJoinMethod = 'invite_link' | 'linked_group_join' | 'non_admin_add' | undefined;
12
- export interface GroupMetadata {
13
- id: string;
14
- /** group uses 'lid' or 'pn' to send messages */
15
- addressingMode: 'pn' | 'lid';
16
- owner: string | undefined;
17
- ownerLid?: string | undefined;
18
- subject: string;
19
- /** group subject owner */
20
- subjectOwner?: string;
21
- subjectOwnerLid?: string;
22
- /** group subject modification date */
23
- subjectTime?: number;
24
- creation?: number;
25
- desc?: string;
26
- descOwner?: string;
27
- descOwnerLid?: string;
28
- descId?: string;
29
- descTime?: number;
30
- /** if this group is part of a community, it returns the jid of the community to which it belongs */
31
- linkedParent?: string;
32
- /** is set when the group only allows admins to change group settings */
33
- restrict?: boolean;
34
- /** is set when the group only allows admins to write messages */
35
- announce?: boolean;
36
- /** is set when the group also allows members to add participants */
37
- memberAddMode?: boolean;
38
- /** Request approval to join the group */
39
- joinApprovalMode?: boolean;
40
- /** is this a community */
41
- isCommunity?: boolean;
42
- /** is this the announce of a community */
43
- isCommunityAnnounce?: boolean;
44
- /** number of group participants */
45
- size?: number;
46
- participants: GroupParticipant[];
47
- ephemeralDuration?: number;
48
- inviteCode?: string;
49
- /** the person who added you to group or changed some setting in group */
50
- author?: string;
51
- }
52
- export interface WAGroupCreateResponse {
53
- status: number;
54
- gid?: string;
55
- participants?: [{
56
- [key: string]: {};
57
- }];
58
- }
59
- export interface GroupModificationResponse {
60
- status: number;
61
- participants?: {
62
- [key: string]: {};
63
- };
64
- }
@@ -1,35 +0,0 @@
1
- export interface Label {
2
- /** Label uniq ID */
3
- id: string;
4
- /** Label name */
5
- name: string;
6
- /** Label color ID */
7
- color: number;
8
- /** Is label has been deleted */
9
- deleted: boolean;
10
- /** WhatsApp has 5 predefined labels (New customer, New order & etc) */
11
- predefinedId?: string;
12
- }
13
- /** WhatsApp has 20 predefined colors */
14
- export declare enum LabelColor {
15
- Color1 = 0,
16
- Color2 = 1,
17
- Color3 = 2,
18
- Color4 = 3,
19
- Color5 = 4,
20
- Color6 = 5,
21
- Color7 = 6,
22
- Color8 = 7,
23
- Color9 = 8,
24
- Color10 = 9,
25
- Color11 = 10,
26
- Color12 = 11,
27
- Color13 = 12,
28
- Color14 = 13,
29
- Color15 = 14,
30
- Color16 = 15,
31
- Color17 = 16,
32
- Color18 = 17,
33
- Color19 = 18,
34
- Color20 = 19
35
- }