@neelegirly/baileys 2.2.16

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 (206) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +108 -0
  3. package/WAProto/WAProto.proto +5007 -0
  4. package/WAProto/index.d.ts +57712 -0
  5. package/WAProto/index.js +178969 -0
  6. package/lib/Defaults/baileys-version.json +1 -0
  7. package/lib/Defaults/index.d.ts +68 -0
  8. package/lib/Defaults/index.js +155 -0
  9. package/lib/Defaults/phonenumber-mcc.json +223 -0
  10. package/lib/Signal/WASignalGroup/GroupProtocol.js +1909 -0
  11. package/lib/Signal/WASignalGroup/ciphertext_message.js +16 -0
  12. package/lib/Signal/WASignalGroup/generate-proto.sh +1 -0
  13. package/lib/Signal/WASignalGroup/group.proto +42 -0
  14. package/lib/Signal/WASignalGroup/group_cipher.js +120 -0
  15. package/lib/Signal/WASignalGroup/group_session_builder.js +46 -0
  16. package/lib/Signal/WASignalGroup/index.js +6 -0
  17. package/lib/Signal/WASignalGroup/keyhelper.js +22 -0
  18. package/lib/Signal/WASignalGroup/protobufs.js +3 -0
  19. package/lib/Signal/WASignalGroup/queue_job.js +69 -0
  20. package/lib/Signal/WASignalGroup/readme.md +6 -0
  21. package/lib/Signal/WASignalGroup/sender_chain_key.js +50 -0
  22. package/lib/Signal/WASignalGroup/sender_key_distribution_message.js +78 -0
  23. package/lib/Signal/WASignalGroup/sender_key_message.js +92 -0
  24. package/lib/Signal/WASignalGroup/sender_key_name.js +70 -0
  25. package/lib/Signal/WASignalGroup/sender_key_record.js +56 -0
  26. package/lib/Signal/WASignalGroup/sender_key_state.js +129 -0
  27. package/lib/Signal/WASignalGroup/sender_message_key.js +39 -0
  28. package/lib/Signal/libsignal.d.ts +4 -0
  29. package/lib/Signal/libsignal.js +427 -0
  30. package/lib/Socket/Client/abstract-socket-client.d.ts +15 -0
  31. package/lib/Socket/Client/abstract-socket-client.js +13 -0
  32. package/lib/Socket/Client/index.d.ts +2 -0
  33. package/lib/Socket/Client/index.js +22 -0
  34. package/lib/Socket/Client/mobile-socket-client.d.ts +12 -0
  35. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  36. package/lib/Socket/Client/types.d.ts +16 -0
  37. package/lib/Socket/Client/types.js +18 -0
  38. package/lib/Socket/Client/websocket.d.ts +13 -0
  39. package/lib/Socket/Client/websocket.js +62 -0
  40. package/lib/Socket/business.d.ts +187 -0
  41. package/lib/Socket/business.js +268 -0
  42. package/lib/Socket/chats.d.ts +98 -0
  43. package/lib/Socket/chats.js +1133 -0
  44. package/lib/Socket/communities.d.ts +223 -0
  45. package/lib/Socket/communities.js +433 -0
  46. package/lib/Socket/groups.d.ts +131 -0
  47. package/lib/Socket/groups.js +352 -0
  48. package/lib/Socket/index.d.ts +191 -0
  49. package/lib/Socket/index.js +23 -0
  50. package/lib/Socket/messages-recv.d.ts +177 -0
  51. package/lib/Socket/messages-recv.js +1826 -0
  52. package/lib/Socket/messages-send.d.ts +168 -0
  53. package/lib/Socket/messages-send.js +1537 -0
  54. package/lib/Socket/mex.d.ts +2 -0
  55. package/lib/Socket/mex.js +47 -0
  56. package/lib/Socket/newsletter.d.ts +147 -0
  57. package/lib/Socket/newsletter.js +286 -0
  58. package/lib/Socket/registration.d.ts +266 -0
  59. package/lib/Socket/registration.js +166 -0
  60. package/lib/Socket/socket.d.ts +45 -0
  61. package/lib/Socket/socket.js +928 -0
  62. package/lib/Socket/usync.d.ts +37 -0
  63. package/lib/Socket/usync.js +83 -0
  64. package/lib/Store/index.d.ts +4 -0
  65. package/lib/Store/index.js +24 -0
  66. package/lib/Store/make-cache-manager-store.d.ts +14 -0
  67. package/lib/Store/make-cache-manager-store.js +90 -0
  68. package/lib/Store/make-in-memory-store.d.ts +123 -0
  69. package/lib/Store/make-in-memory-store.js +429 -0
  70. package/lib/Store/make-ordered-dictionary.d.ts +12 -0
  71. package/lib/Store/make-ordered-dictionary.js +86 -0
  72. package/lib/Store/object-repository.d.ts +10 -0
  73. package/lib/Store/object-repository.js +31 -0
  74. package/lib/Types/Auth.d.ts +120 -0
  75. package/lib/Types/Auth.js +3 -0
  76. package/lib/Types/Bussines.d.ts +20 -0
  77. package/lib/Types/Bussines.js +2 -0
  78. package/lib/Types/Call.d.ts +14 -0
  79. package/lib/Types/Call.js +3 -0
  80. package/lib/Types/Chat.d.ts +141 -0
  81. package/lib/Types/Chat.js +9 -0
  82. package/lib/Types/Contact.d.ts +20 -0
  83. package/lib/Types/Contact.js +3 -0
  84. package/lib/Types/Events.d.ts +237 -0
  85. package/lib/Types/Events.js +3 -0
  86. package/lib/Types/GroupMetadata.d.ts +66 -0
  87. package/lib/Types/GroupMetadata.js +3 -0
  88. package/lib/Types/Label.d.ts +48 -0
  89. package/lib/Types/Label.js +31 -0
  90. package/lib/Types/LabelAssociation.d.ts +35 -0
  91. package/lib/Types/LabelAssociation.js +13 -0
  92. package/lib/Types/Message.d.ts +473 -0
  93. package/lib/Types/Message.js +13 -0
  94. package/lib/Types/MexUpdates.d.ts +9 -0
  95. package/lib/Types/MexUpdates.js +18 -0
  96. package/lib/Types/Newsletter.d.ts +109 -0
  97. package/lib/Types/Newsletter.js +40 -0
  98. package/lib/Types/Product.d.ts +92 -0
  99. package/lib/Types/Product.js +3 -0
  100. package/lib/Types/Signal.d.ts +68 -0
  101. package/lib/Types/Signal.js +3 -0
  102. package/lib/Types/Socket.d.ts +122 -0
  103. package/lib/Types/Socket.js +3 -0
  104. package/lib/Types/State.d.ts +41 -0
  105. package/lib/Types/State.js +14 -0
  106. package/lib/Types/USync.d.ts +26 -0
  107. package/lib/Types/USync.js +3 -0
  108. package/lib/Types/index.d.ts +80 -0
  109. package/lib/Types/index.js +48 -0
  110. package/lib/Utils/auth-utils.d.ts +21 -0
  111. package/lib/Utils/auth-utils.js +205 -0
  112. package/lib/Utils/baileys-event-stream.d.ts +18 -0
  113. package/lib/Utils/baileys-event-stream.js +70 -0
  114. package/lib/Utils/branding.d.ts +24 -0
  115. package/lib/Utils/branding.js +209 -0
  116. package/lib/Utils/business.d.ts +29 -0
  117. package/lib/Utils/business.js +255 -0
  118. package/lib/Utils/chat-utils.d.ts +82 -0
  119. package/lib/Utils/chat-utils.js +798 -0
  120. package/lib/Utils/check-npm-version.d.ts +18 -0
  121. package/lib/Utils/check-npm-version.js +130 -0
  122. package/lib/Utils/crypto.d.ts +56 -0
  123. package/lib/Utils/crypto.js +179 -0
  124. package/lib/Utils/decode-wa-message.d.ts +41 -0
  125. package/lib/Utils/decode-wa-message.js +288 -0
  126. package/lib/Utils/event-buffer.d.ts +39 -0
  127. package/lib/Utils/event-buffer.js +565 -0
  128. package/lib/Utils/generics.d.ts +129 -0
  129. package/lib/Utils/generics.js +630 -0
  130. package/lib/Utils/history.d.ts +23 -0
  131. package/lib/Utils/history.js +110 -0
  132. package/lib/Utils/index.d.ts +22 -0
  133. package/lib/Utils/index.js +42 -0
  134. package/lib/Utils/link-preview.d.ts +23 -0
  135. package/lib/Utils/link-preview.js +120 -0
  136. package/lib/Utils/logger.d.ts +13 -0
  137. package/lib/Utils/logger.js +7 -0
  138. package/lib/Utils/lt-hash.d.ts +14 -0
  139. package/lib/Utils/lt-hash.js +58 -0
  140. package/lib/Utils/make-mutex.d.ts +9 -0
  141. package/lib/Utils/make-mutex.js +49 -0
  142. package/lib/Utils/message-retry-manager.d.ts +84 -0
  143. package/lib/Utils/message-retry-manager.js +179 -0
  144. package/lib/Utils/messages-media.d.ts +129 -0
  145. package/lib/Utils/messages-media.js +806 -0
  146. package/lib/Utils/messages.d.ts +103 -0
  147. package/lib/Utils/messages.js +1579 -0
  148. package/lib/Utils/noise-handler.d.ts +20 -0
  149. package/lib/Utils/noise-handler.js +155 -0
  150. package/lib/Utils/process-message.d.ts +49 -0
  151. package/lib/Utils/process-message.js +443 -0
  152. package/lib/Utils/signal.d.ts +42 -0
  153. package/lib/Utils/signal.js +168 -0
  154. package/lib/Utils/use-mongo-file-auth-state.d.ts +6 -0
  155. package/lib/Utils/use-mongo-file-auth-state.js +84 -0
  156. package/lib/Utils/use-multi-file-auth-state.d.ts +18 -0
  157. package/lib/Utils/use-multi-file-auth-state.js +249 -0
  158. package/lib/Utils/use-single-file-auth-state.d.ts +13 -0
  159. package/lib/Utils/use-single-file-auth-state.js +80 -0
  160. package/lib/Utils/validate-connection.d.ts +13 -0
  161. package/lib/Utils/validate-connection.js +218 -0
  162. package/lib/WABinary/constants.d.ts +30 -0
  163. package/lib/WABinary/constants.js +1316 -0
  164. package/lib/WABinary/decode.d.ts +9 -0
  165. package/lib/WABinary/decode.js +288 -0
  166. package/lib/WABinary/encode.d.ts +3 -0
  167. package/lib/WABinary/encode.js +265 -0
  168. package/lib/WABinary/generic-utils.d.ts +28 -0
  169. package/lib/WABinary/generic-utils.js +142 -0
  170. package/lib/WABinary/index.d.ts +5 -0
  171. package/lib/WABinary/index.js +25 -0
  172. package/lib/WABinary/jid-utils.d.ts +59 -0
  173. package/lib/WABinary/jid-utils.js +105 -0
  174. package/lib/WABinary/types.d.ts +22 -0
  175. package/lib/WABinary/types.js +3 -0
  176. package/lib/WAM/BinaryInfo.d.ts +16 -0
  177. package/lib/WAM/BinaryInfo.js +17 -0
  178. package/lib/WAM/constants.d.ts +47 -0
  179. package/lib/WAM/constants.js +15371 -0
  180. package/lib/WAM/encode.d.ts +3 -0
  181. package/lib/WAM/encode.js +165 -0
  182. package/lib/WAM/index.d.ts +3 -0
  183. package/lib/WAM/index.js +23 -0
  184. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +28 -0
  185. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +69 -0
  186. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
  187. package/lib/WAUSync/Protocols/USyncContactProtocol.js +36 -0
  188. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +26 -0
  189. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +62 -0
  190. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +14 -0
  191. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +35 -0
  192. package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +9 -0
  193. package/lib/WAUSync/Protocols/USyncLIDProtocol.js +30 -0
  194. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +14 -0
  195. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +46 -0
  196. package/lib/WAUSync/Protocols/index.d.ts +6 -0
  197. package/lib/WAUSync/Protocols/index.js +26 -0
  198. package/lib/WAUSync/USyncQuery.d.ts +31 -0
  199. package/lib/WAUSync/USyncQuery.js +82 -0
  200. package/lib/WAUSync/USyncUser.d.ts +12 -0
  201. package/lib/WAUSync/USyncUser.js +30 -0
  202. package/lib/WAUSync/index.d.ts +3 -0
  203. package/lib/WAUSync/index.js +23 -0
  204. package/lib/index.d.ts +13 -0
  205. package/lib/index.js +33 -0
  206. package/package.json +120 -0
@@ -0,0 +1,20 @@
1
+ import type { proto } from '../../WAProto'
2
+
3
+ export type DayOfWeekBussines = 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat'
4
+
5
+ export type HoursDay =
6
+ | { day: DayOfWeekBussines; mode: 'specific_hours'; openTimeInMinutes: string; closeTimeInMinutes: string }
7
+ | { day: DayOfWeekBussines; mode: 'open_24h' | 'appointment_only' }
8
+
9
+ export type UpdateBussinesProfileProps = {
10
+ address?: string
11
+ websites?: string[]
12
+ email?: string
13
+ description?: string
14
+ hours?: {
15
+ timezone: string
16
+ days: HoursDay[]
17
+ }
18
+ }
19
+
20
+ export type QuickReplyAction = proto.SyncActionValue.IQuickReplyAction & { timestamp?: string }
@@ -0,0 +1,2 @@
1
+ "use strict"
2
+ Object.defineProperty(exports, "__esModule", { value: true })
@@ -0,0 +1,14 @@
1
+ export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept' | 'terminate'
2
+
3
+ export type WACallEvent = {
4
+ chatId: string
5
+ from: string
6
+ isGroup?: boolean
7
+ groupJid?: string
8
+ id: string
9
+ date: Date
10
+ isVideo?: boolean
11
+ status: WACallUpdateType
12
+ offline: boolean
13
+ latencyMs?: number
14
+ }
@@ -0,0 +1,3 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
@@ -0,0 +1,141 @@
1
+ import type { proto } from '../../WAProto'
2
+ import type { AccountSettings } from './Auth'
3
+ import type { ContactAction } from './Contact'
4
+ import type { BufferedEventData } from './Events'
5
+ import type { LabelActionBody } from './Label'
6
+ import type { ChatLabelAssociationActionBody } from './LabelAssociation'
7
+ import type { MessageLabelAssociationActionBody } from './LabelAssociation'
8
+ import type { MinimalMessage, WAMessageKey } from './Message'
9
+ import type { QuickReplyAction } from './Bussines'
10
+
11
+ /** privacy settings in WhatsApp Web */
12
+ export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none'
13
+
14
+ export type WAPrivacyOnlineValue = 'all' | 'match_last_seen'
15
+
16
+ export type WAPrivacyGroupAddValue = 'all' | 'contacts' | 'contact_blacklist'
17
+
18
+ export type WAReadReceiptsValue = 'all' | 'none'
19
+
20
+ export type WAPrivacyCallValue = 'all' | 'known'
21
+
22
+ export type WAPrivacyMessagesValue = 'all' | 'contacts'
23
+
24
+ /** set of statuses visible to other people see updatePresence() in WhatsAppWeb.Send */
25
+ export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused'
26
+
27
+ export declare const ALL_WA_PATCH_NAMES: readonly ["critical_block", "critical_unblock_low", "regular_high", "regular_low", "regular"]
28
+
29
+ export type WAPatchName = typeof ALL_WA_PATCH_NAMES[number]
30
+
31
+ export type BotListInfo = {
32
+ jid: string
33
+ personaId: string
34
+ }
35
+
36
+ export interface PresenceData {
37
+ lastKnownPresence: WAPresence
38
+ lastSeen?: number
39
+ }
40
+
41
+ export type ChatMutation = {
42
+ syncAction: proto.ISyncActionData
43
+ index: string[]
44
+ }
45
+
46
+ export type WAPatchCreate = {
47
+ syncAction: proto.ISyncActionValue
48
+ index: string[]
49
+ type: WAPatchName
50
+ apiVersion: number
51
+ operation: proto.SyncdMutation.SyncdOperation
52
+ }
53
+
54
+ export type Chat = proto.IConversation & {
55
+ /** unix timestamp of when the last message was received in the chat */
56
+ lastMessageRecvTimestamp?: number
57
+ }
58
+
59
+ export type ChatUpdate = Partial<Chat & {
60
+ /**
61
+ * if specified in the update,
62
+ * the EV buffer will check if the condition gets fulfilled before applying the update
63
+ * Right now, used to determine when to release an app state sync event
64
+ *
65
+ * @returns true, if the update should be applied
66
+ * false if it can be discarded
67
+ * undefined if the condition is not yet fulfilled
68
+ * */
69
+ conditional: (bufferedData: BufferedEventData) => boolean | undefined
70
+ }>
71
+
72
+ /**
73
+ * the last messages in a chat, sorted reverse-chronologically. That is, the latest message should be first in the chat
74
+ * for MD modifications, the last message in the array (i.e. the earlist message) must be the last message recv in the chat
75
+ * */
76
+ export type LastMessageList = MinimalMessage[] | proto.SyncActionValue.ISyncActionMessageRange
77
+
78
+ export type ChatModification = {
79
+ archive: boolean
80
+ lastMessages: LastMessageList
81
+ } | {
82
+ contact: ContactAction | null
83
+ } | {
84
+ pushNameSetting: string
85
+ } | {
86
+ pin: boolean
87
+ } | {
88
+ /** mute for duration, or provide timestamp of mute to remove*/
89
+ mute: number | null
90
+ } | {
91
+ clear: boolean
92
+ } | {
93
+ deleteForMe: {
94
+ deleteMedia: boolean
95
+ key: WAMessageKey
96
+ timestamp: number
97
+ }
98
+ } | {
99
+ star: {
100
+ messages: {
101
+ id: string
102
+ fromMe?: boolean
103
+ }[]
104
+ star: boolean
105
+ }
106
+ } | {
107
+ markRead: boolean
108
+ lastMessages: LastMessageList
109
+ } | {
110
+ delete: true
111
+ lastMessages: LastMessageList
112
+ } | {
113
+ contact: proto.SyncActionValue.IContactAction | null
114
+ } | {
115
+ disableLinkPreviews: proto.SyncActionValue.IPrivacySettingDisableLinkPreviewsAction
116
+ } | {
117
+ addLabel: LabelActionBody
118
+ } | {
119
+ addChatLabel: ChatLabelAssociationActionBody
120
+ } | {
121
+ removeChatLabel: ChatLabelAssociationActionBody
122
+ } | {
123
+ addMessageLabel: MessageLabelAssociationActionBody
124
+ } | {
125
+ removeMessageLabel: MessageLabelAssociationActionBody
126
+ } | {
127
+ quickReply: QuickReplyAction
128
+ }
129
+
130
+ export type InitialReceivedChatsState = {
131
+ [jid: string]: {
132
+ /** the last message received from the other party */
133
+ lastMsgRecvTimestamp?: number
134
+ /** the absolute last message in the chat */
135
+ lastMsgTimestamp: number
136
+ }
137
+ }
138
+
139
+ export type InitialAppStateSyncOptions = {
140
+ accountSettings: AccountSettings
141
+ }
@@ -0,0 +1,9 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const ALL_WA_PATCH_NAMES = ['critical_block', 'critical_unblock_low', 'regular_high', 'regular_low', 'regular']
6
+
7
+ module.exports = {
8
+ ALL_WA_PATCH_NAMES
9
+ }
@@ -0,0 +1,20 @@
1
+ export interface Contact {
2
+ id: string
3
+ lid?: string
4
+ jid?: string
5
+ /** name of the contact, you have saved on your WA */
6
+ name?: string
7
+ /** name of the contact, the contact has set on their own on WA */
8
+ notify?: string
9
+ /** I have no idea */
10
+ verifiedName?: string
11
+ /**
12
+ * Url of the profile picture of the contact
13
+ *
14
+ * 'changed' => if the profile picture has changed
15
+ * null => if the profile picture has not been set (default profile picture)
16
+ * any other string => url of the profile picture
17
+ */
18
+ imgUrl?: string | null
19
+ status?: string
20
+ }
@@ -0,0 +1,3 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
@@ -0,0 +1,237 @@
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 { NewsletterViewRole, SubscriberAction, NewsletterSettingsUpdate } from './Newsletter'
12
+ import { ConnectionState } from './State'
13
+
14
+ export type BaileysEventMap = {
15
+ /** connection state has been updated -- WS closed, opened, connecting etc. */
16
+ 'connection.update': Partial<ConnectionState>
17
+ /** credentials updated -- some metadata, keys or something */
18
+ 'creds.update': Partial<AuthenticationCreds>
19
+ /** set chats (history sync), everything is reverse chronologically sorted */
20
+ 'messaging-history.set': {
21
+ chats: Chat[]
22
+ contacts: Contact[]
23
+ messages: WAMessage[]
24
+ isLatest?: boolean
25
+ progress?: number | null
26
+ syncType?: proto.HistorySync.HistorySyncType
27
+ peerDataRequestSessionId?: string | null
28
+ }
29
+ /** upsert chats */
30
+ 'chats.upsert': Chat[]
31
+ /** update the given chats */
32
+ 'chats.update': ChatUpdate[]
33
+ 'chats.phoneNumberShare': {
34
+ lid: string
35
+ jid: string
36
+ }
37
+ /** delete chats with given ID */
38
+ 'chats.delete': string[]
39
+ /** presence of contact in a chat updated */
40
+ 'presence.update': {
41
+ id: string
42
+ presences: {
43
+ [participant: string]: PresenceData
44
+ }
45
+ }
46
+ 'contacts.upsert': Contact[]
47
+ 'contacts.update': Partial<Contact>[]
48
+ 'messages.delete': {
49
+ keys: WAMessageKey[]
50
+ } | {
51
+ jid: string
52
+ all: true
53
+ }
54
+ 'messages.update': WAMessageUpdate[]
55
+ 'messages.media-update': {
56
+ key: WAMessageKey
57
+ media?: {
58
+ ciphertext: Uint8Array
59
+ iv: Uint8Array
60
+ }
61
+ error?: Boom
62
+ }[]
63
+ /**
64
+ * add/update the given messages. If they were received while the connection was online,
65
+ * the update will have type: "notify"
66
+ * if requestId is provided, then the messages was received from the phone due to it being unavailable
67
+ * */
68
+ 'messages.upsert': {
69
+ messages: WAMessage[]
70
+ type: MessageUpsertType
71
+ requestId?: string
72
+ }
73
+ // 'messages.poll': {
74
+ // key: WAMessageKey
75
+ // pollUpdates: proto.IPollUpdateMessage
76
+ // }[]
77
+ /** message was reacted to. If reaction was removed -- then "reaction.text" will be falsey */
78
+ 'messages.reaction': {
79
+ key: WAMessageKey
80
+ reaction: proto.IReaction
81
+ }[]
82
+ 'message-receipt.update': MessageUserReceiptUpdate[]
83
+ 'groups.upsert': GroupMetadata[]
84
+ 'groups.update': Partial<GroupMetadata>[]
85
+ /** apply an action to participants in a group */
86
+ 'group-participants.update': {
87
+ id: string
88
+ author: string
89
+ participants: string[]
90
+ action: ParticipantAction
91
+ }
92
+ 'group.join-request': {
93
+ id: string
94
+ author: string
95
+ participant: string
96
+ action: RequestJoinAction
97
+ method: RequestJoinMethod
98
+ }
99
+ /* update the labels assigned to a group participant */
100
+ 'group.member-tag.update': {
101
+ groupId: string
102
+ participant: string
103
+ participantAlt?: string
104
+ label: string
105
+ messageTimestamp?: number
106
+ }
107
+ 'newsletter.reaction': {
108
+ id: string
109
+ newsletter_server_id: string
110
+ reaction: {
111
+ code?: string
112
+ count?: number
113
+ removed?: boolean
114
+ }
115
+ }
116
+ 'newsletter.view': {
117
+ id: string
118
+ newsletter_server_id: string
119
+ count: number
120
+ }
121
+ 'newsletter-participants.update': {
122
+ id: string
123
+ author: string
124
+ user: string
125
+ new_role: NewsletterViewRole
126
+ action: SubscriberAction
127
+ }
128
+ 'newsletter-settings.update': {
129
+ id: string
130
+ update: NewsletterSettingsUpdate
131
+ }
132
+ 'limit-sharing.update': {
133
+ id: string
134
+ author: string
135
+ action: 'on' | 'off'
136
+ trigger: proto.LimitSharing.TriggerType
137
+ update_time: number
138
+ }
139
+ 'community-owner.update': {
140
+ id: string
141
+ author: string
142
+ user: string
143
+ new_role: 'SUPERADMIN_MEMBER'
144
+ update_time: number
145
+ }
146
+ 'blocklist.set': {
147
+ blocklist: string[]
148
+ }
149
+ 'blocklist.update': {
150
+ blocklist: string[]
151
+ type: 'add' | 'remove'
152
+ }
153
+ /** Receive an update on a call, including when the call was received, rejected, accepted */
154
+ 'call': WACallEvent[]
155
+ 'labels.edit': Label
156
+ 'labels.association': {
157
+ association: LabelAssociation
158
+ type: 'add' | 'remove'
159
+ }
160
+ }
161
+
162
+ export type BufferedEventData = {
163
+ historySets: {
164
+ chats: {
165
+ [jid: string]: Chat
166
+ }
167
+ contacts: {
168
+ [jid: string]: Contact
169
+ }
170
+ messages: {
171
+ [uqId: string]: WAMessage
172
+ }
173
+ empty: boolean
174
+ isLatest: boolean
175
+ progress?: number | null
176
+ syncType?: proto.HistorySync.HistorySyncType
177
+ peerDataRequestSessionId?: string
178
+ }
179
+ chatUpserts: {
180
+ [jid: string]: Chat
181
+ }
182
+ chatUpdates: {
183
+ [jid: string]: ChatUpdate
184
+ }
185
+ chatDeletes: Set<string>
186
+ contactUpserts: {
187
+ [jid: string]: Contact
188
+ }
189
+ contactUpdates: {
190
+ [jid: string]: Partial<Contact>
191
+ }
192
+ messageUpserts: {
193
+ [key: string]: {
194
+ type: MessageUpsertType
195
+ message: WAMessage
196
+ }
197
+ }
198
+ messageUpdates: {
199
+ [key: string]: WAMessageUpdate
200
+ }
201
+ messageDeletes: {
202
+ [key: string]: WAMessageKey
203
+ }
204
+ // messagePollings: {
205
+ // [key: string]: {
206
+ // key: WAMessageKey
207
+ // pollUpdates: proto.IPollUpdateMessage[]
208
+ // }
209
+ // }
210
+ messageReactions: {
211
+ [key: string]: {
212
+ key: WAMessageKey
213
+ reactions: proto.IReaction[]
214
+ }
215
+ }
216
+ messageReceipts: {
217
+ [key: string]: {
218
+ key: WAMessageKey
219
+ userReceipt: proto.IUserReceipt[]
220
+ }
221
+ }
222
+ groupUpdates: {
223
+ [jid: string]: Partial<GroupMetadata>
224
+ }
225
+ communityUpdates: {
226
+ [jid: string]: Partial<GroupMetadata>
227
+ }
228
+ }
229
+
230
+ export type BaileysEvent = keyof BaileysEventMap
231
+
232
+ export interface BaileysEventEmitter {
233
+ on<T extends keyof BaileysEventMap>(event: T, listener: (arg: BaileysEventMap[T]) => void): void
234
+ off<T extends keyof BaileysEventMap>(event: T, listener: (arg: BaileysEventMap[T]) => void): void
235
+ removeAllListeners<T extends keyof BaileysEventMap>(event: T): void
236
+ emit<T extends keyof BaileysEventMap>(event: T, arg: BaileysEventMap[T]): boolean
237
+ }
@@ -0,0 +1,3 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
@@ -0,0 +1,66 @@
1
+ import { Contact } from './Contact'
2
+
3
+ export type GroupParticipant = (Contact & {
4
+ isAdmin?: boolean
5
+ isSuperAdmin?: boolean
6
+ admin?: 'admin' | 'superadmin' | null
7
+ })
8
+
9
+ export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote' | 'modify'
10
+
11
+ export type RequestJoinAction = 'created' | 'revoked' | 'rejected'
12
+
13
+ export type RequestJoinMethod = 'invite_link' | 'linked_group_join' | 'non_admin_add' | undefined
14
+
15
+ export interface GroupMetadata {
16
+ id: string
17
+ addressingMode: string
18
+ owner: string | undefined
19
+ ownerCountry: string,
20
+ subject: string
21
+ /** group subject owner */
22
+ subjectOwner?: string
23
+ /** group subject modification date */
24
+ subjectTime?: number
25
+ creation?: number
26
+ desc?: string
27
+ descOwner?: string
28
+ descId?: string
29
+ /** if this group is part of a community, it returns the jid of the community to which it belongs */
30
+ linkedParent?: string
31
+ /** is set when the group only allows admins to change group settings */
32
+ restrict?: boolean
33
+ /** is set when the group only allows admins to write messages */
34
+ announce?: boolean
35
+ /** is set when the group also allows members to add participants */
36
+ memberAddMode?: boolean
37
+ /** Request approval to join the group */
38
+ joinApprovalMode?: boolean
39
+ /** is this a community */
40
+ isCommunity?: boolean
41
+ /** is this the announce of a community */
42
+ isCommunityAnnounce?: boolean
43
+ /** number of group participants */
44
+ size?: number
45
+ participants: GroupParticipant[]
46
+ picture?: string
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
+
53
+ export interface WAGroupCreateResponse {
54
+ status: number
55
+ gid?: string
56
+ participants?: [{
57
+ [key: string]: {}
58
+ }]
59
+ }
60
+
61
+ export interface GroupModificationResponse {
62
+ status: number
63
+ participants?: {
64
+ [key: string]: {}
65
+ }
66
+ }
@@ -0,0 +1,3 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
@@ -0,0 +1,48 @@
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
+
14
+ export interface LabelActionBody {
15
+ id: string
16
+ /** Label name */
17
+ name?: string
18
+ /** Label color ID */
19
+ color?: number
20
+ /** Is label has been deleted */
21
+ deleted?: boolean
22
+ /** WhatsApp has 5 predefined labels (New customer, New order & etc) */
23
+ predefinedId?: number
24
+ }
25
+
26
+ /** WhatsApp has 20 predefined colors */
27
+ export declare const enum LabelColor {
28
+ Color1 = 0,
29
+ Color2 = 1,
30
+ Color3 = 2,
31
+ Color4 = 3,
32
+ Color5 = 4,
33
+ Color6 = 5,
34
+ Color7 = 6,
35
+ Color8 = 7,
36
+ Color9 = 8,
37
+ Color10 = 9,
38
+ Color11 = 10,
39
+ Color12 = 11,
40
+ Color13 = 12,
41
+ Color14 = 13,
42
+ Color15 = 14,
43
+ Color16 = 15,
44
+ Color17 = 16,
45
+ Color18 = 17,
46
+ Color19 = 18,
47
+ Color20 = 19
48
+ }
@@ -0,0 +1,31 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ /** WhatsApp has 20 predefined colors */
6
+ const LabelColor = {
7
+ Color1: 0,
8
+ Color2: 1,
9
+ Color3: 2,
10
+ Color4: 3,
11
+ Color5: 4,
12
+ Color6: 5,
13
+ Color7: 6,
14
+ Color8: 7,
15
+ Color9: 8,
16
+ Color10: 9,
17
+ Color11: 10,
18
+ Color12: 11,
19
+ Color13: 12,
20
+ Color14: 13,
21
+ Color15: 14,
22
+ Color16: 15,
23
+ Color17: 16,
24
+ Color18: 17,
25
+ Color19: 18,
26
+ Color20: 19
27
+ }
28
+
29
+ module.exports = {
30
+ LabelColor
31
+ }
@@ -0,0 +1,35 @@
1
+ /** Association type */
2
+ export declare const enum LabelAssociationType {
3
+ Chat = "label_jid",
4
+ Message = "label_message"
5
+ }
6
+
7
+ export type LabelAssociationTypes = LabelAssociationType
8
+
9
+ /** Association for chat */
10
+ export interface ChatLabelAssociation {
11
+ type: LabelAssociationType.Chat
12
+ chatId: string
13
+ labelId: string
14
+ }
15
+
16
+ /** Association for message */
17
+ export interface MessageLabelAssociation {
18
+ type: LabelAssociationType.Message
19
+ chatId: string
20
+ messageId: string
21
+ labelId: string
22
+ }
23
+
24
+ export type LabelAssociation = ChatLabelAssociation | MessageLabelAssociation
25
+
26
+ /** Body for add/remove chat label association action */
27
+ export interface ChatLabelAssociationActionBody {
28
+ labelId: string
29
+ }
30
+
31
+ /** body for add/remove message label association action */
32
+ export interface MessageLabelAssociationActionBody {
33
+ labelId: string
34
+ messageId: string
35
+ }
@@ -0,0 +1,13 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ /** Association type */
6
+ const LabelAssociationType = {
7
+ Chat: "label_jid",
8
+ Message: "label_message"
9
+ }
10
+
11
+ module.exports = {
12
+ LabelAssociationType
13
+ }