dcodeindra-baileyspro 2.3.9

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 (286) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2534 -0
  3. package/WAProto/Adv/Adv.d.ts +518 -0
  4. package/WAProto/Adv/Adv.js +1734 -0
  5. package/WAProto/Adv/Adv.proto +36 -0
  6. package/WAProto/BotMetadata/BotMetadata.d.ts +5745 -0
  7. package/WAProto/BotMetadata/BotMetadata.js +16291 -0
  8. package/WAProto/BotMetadata/BotMetadata.proto +463 -0
  9. package/WAProto/Cert/Cert.d.ts +497 -0
  10. package/WAProto/Cert/Cert.js +1503 -0
  11. package/WAProto/Cert/Cert.proto +28 -0
  12. package/WAProto/ChatLockSettings/ChatLockSettings.d.ts +391 -0
  13. package/WAProto/ChatLockSettings/ChatLockSettings.js +1155 -0
  14. package/WAProto/ChatLockSettings/ChatLockSettings.proto +7 -0
  15. package/WAProto/CompanionReg/CompanionReg.d.ts +1055 -0
  16. package/WAProto/CompanionReg/CompanionReg.js +3532 -0
  17. package/WAProto/CompanionReg/CompanionReg.proto +89 -0
  18. package/WAProto/DeviceCapabilities/DeviceCapabilities.d.ts +187 -0
  19. package/WAProto/DeviceCapabilities/DeviceCapabilities.js +520 -0
  20. package/WAProto/DeviceCapabilities/DeviceCapabilities.proto +14 -0
  21. package/WAProto/E2E/E2E.d.ts +28417 -0
  22. package/WAProto/E2E/E2E.js +98438 -0
  23. package/WAProto/E2E/E2E.proto +2289 -0
  24. package/WAProto/Ephemeral/Ephemeral.d.ts +95 -0
  25. package/WAProto/Ephemeral/Ephemeral.js +269 -0
  26. package/WAProto/Ephemeral/Ephemeral.proto +6 -0
  27. package/WAProto/HistorySync/HistorySync.d.ts +40728 -0
  28. package/WAProto/HistorySync/HistorySync.js +142980 -0
  29. package/WAProto/HistorySync/HistorySync.proto +207 -0
  30. package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.d.ts +189 -0
  31. package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.js +585 -0
  32. package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.proto +11 -0
  33. package/WAProto/MdStorageChatRowOpaqueData/MdStorageChatRowOpaqueData.d.ts +461 -0
  34. package/WAProto/MdStorageChatRowOpaqueData/MdStorageChatRowOpaqueData.js +1559 -0
  35. package/WAProto/MdStorageChatRowOpaqueData/MdStorageChatRowOpaqueData.proto +37 -0
  36. package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.d.ts +29294 -0
  37. package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.js +101732 -0
  38. package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.proto +76 -0
  39. package/WAProto/MmsRetry/MmsRetry.d.ts +200 -0
  40. package/WAProto/MmsRetry/MmsRetry.js +586 -0
  41. package/WAProto/MmsRetry/MmsRetry.proto +17 -0
  42. package/WAProto/Protocol/Protocol.d.ts +218 -0
  43. package/WAProto/Protocol/Protocol.js +701 -0
  44. package/WAProto/Protocol/Protocol.proto +20 -0
  45. package/WAProto/Reporting/Reporting.d.ts +301 -0
  46. package/WAProto/Reporting/Reporting.js +989 -0
  47. package/WAProto/Reporting/Reporting.proto +19 -0
  48. package/WAProto/ServerSync/ServerSync.d.ts +1050 -0
  49. package/WAProto/ServerSync/ServerSync.js +3176 -0
  50. package/WAProto/ServerSync/ServerSync.proto +59 -0
  51. package/WAProto/SignalLocalStorageProtocol/SignalLocalStorageProtocol.d.ts +1507 -0
  52. package/WAProto/SignalLocalStorageProtocol/SignalLocalStorageProtocol.js +4756 -0
  53. package/WAProto/SignalLocalStorageProtocol/SignalLocalStorageProtocol.proto +88 -0
  54. package/WAProto/SignalWhisperTextProtocol/SignalWhisperTextProtocol.d.ts +617 -0
  55. package/WAProto/SignalWhisperTextProtocol/SignalWhisperTextProtocol.js +1940 -0
  56. package/WAProto/SignalWhisperTextProtocol/SignalWhisperTextProtocol.proto +38 -0
  57. package/WAProto/StatusAttributions/StatusAttributions.d.ts +636 -0
  58. package/WAProto/StatusAttributions/StatusAttributions.js +2037 -0
  59. package/WAProto/StatusAttributions/StatusAttributions.proto +61 -0
  60. package/WAProto/SyncAction/SyncAction.d.ts +7227 -0
  61. package/WAProto/SyncAction/SyncAction.js +22271 -0
  62. package/WAProto/SyncAction/SyncAction.proto +423 -0
  63. package/WAProto/UserPassword/UserPassword.d.ts +298 -0
  64. package/WAProto/UserPassword/UserPassword.js +898 -0
  65. package/WAProto/UserPassword/UserPassword.proto +27 -0
  66. package/WAProto/VnameCert/VnameCert.d.ts +658 -0
  67. package/WAProto/VnameCert/VnameCert.js +2225 -0
  68. package/WAProto/VnameCert/VnameCert.proto +60 -0
  69. package/WAProto/Wa6/Wa6.d.ts +1613 -0
  70. package/WAProto/Wa6/Wa6.js +6299 -0
  71. package/WAProto/Wa6/Wa6.proto +229 -0
  72. package/WAProto/Web/Web.d.ts +31718 -0
  73. package/WAProto/Web/Web.js +113402 -0
  74. package/WAProto/Web/Web.proto +545 -0
  75. package/WAProto/index.d.ts +49 -0
  76. package/WAProto/index.js +28 -0
  77. package/WASignalGroup/GroupProtocol.js +1771 -0
  78. package/WASignalGroup/ciphertext_message.js +10 -0
  79. package/WASignalGroup/group_cipher.js +103 -0
  80. package/WASignalGroup/group_session_builder.js +39 -0
  81. package/WASignalGroup/index.js +5 -0
  82. package/WASignalGroup/keyhelper.js +17 -0
  83. package/WASignalGroup/protobufs.js +2 -0
  84. package/WASignalGroup/queue_job.js +64 -0
  85. package/WASignalGroup/sender_chain_key.js +38 -0
  86. package/WASignalGroup/sender_key_distribution_message.js +68 -0
  87. package/WASignalGroup/sender_key_message.js +79 -0
  88. package/WASignalGroup/sender_key_name.js +59 -0
  89. package/WASignalGroup/sender_key_record.js +47 -0
  90. package/WASignalGroup/sender_key_state.js +110 -0
  91. package/WASignalGroup/sender_message_key.js +30 -0
  92. package/check-node-version.js +10 -0
  93. package/lib/Defaults/baileys-version.json +3 -0
  94. package/lib/Defaults/index.d.ts +51 -0
  95. package/lib/Defaults/index.js +108 -0
  96. package/lib/Defaults/phonenumber-mcc.json +223 -0
  97. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  98. package/lib/Signal/Group/ciphertext-message.js +19 -0
  99. package/lib/Signal/Group/group-session-builder.d.ts +17 -0
  100. package/lib/Signal/Group/group-session-builder.js +72 -0
  101. package/lib/Signal/Group/group_cipher.d.ts +19 -0
  102. package/lib/Signal/Group/group_cipher.js +99 -0
  103. package/lib/Signal/Group/index.d.ts +11 -0
  104. package/lib/Signal/Group/index.js +61 -0
  105. package/lib/Signal/Group/keyhelper.d.ts +16 -0
  106. package/lib/Signal/Group/keyhelper.js +66 -0
  107. package/lib/Signal/Group/queue-job.d.ts +1 -0
  108. package/lib/Signal/Group/queue-job.js +64 -0
  109. package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
  110. package/lib/Signal/Group/sender-chain-key.js +39 -0
  111. package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
  112. package/lib/Signal/Group/sender-key-distribution-message.js +71 -0
  113. package/lib/Signal/Group/sender-key-message.d.ts +19 -0
  114. package/lib/Signal/Group/sender-key-message.js +73 -0
  115. package/lib/Signal/Group/sender-key-name.d.ts +19 -0
  116. package/lib/Signal/Group/sender-key-name.js +59 -0
  117. package/lib/Signal/Group/sender-key-record.d.ts +32 -0
  118. package/lib/Signal/Group/sender-key-record.js +53 -0
  119. package/lib/Signal/Group/sender-key-record.ts +77 -0
  120. package/lib/Signal/Group/sender-key-state.d.ts +44 -0
  121. package/lib/Signal/Group/sender-key-state.js +104 -0
  122. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  123. package/lib/Signal/Group/sender-message-key.js +33 -0
  124. package/lib/Signal/libsignal.d.ts +3 -0
  125. package/lib/Signal/libsignal.js +153 -0
  126. package/lib/Socket/Client/index.d.ts +2 -0
  127. package/lib/Socket/Client/index.js +18 -0
  128. package/lib/Socket/Client/types.d.ts +15 -0
  129. package/lib/Socket/Client/types.js +14 -0
  130. package/lib/Socket/Client/websocket.d.ts +12 -0
  131. package/lib/Socket/Client/websocket.js +57 -0
  132. package/lib/Socket/business.d.ts +181 -0
  133. package/lib/Socket/business.js +259 -0
  134. package/lib/Socket/chats.d.ts +95 -0
  135. package/lib/Socket/chats.js +906 -0
  136. package/lib/Socket/community.d.ts +131 -0
  137. package/lib/Socket/community.js +369 -0
  138. package/lib/Socket/groups.d.ts +122 -0
  139. package/lib/Socket/groups.js +360 -0
  140. package/lib/Socket/index.d.ts +183 -0
  141. package/lib/Socket/index.js +10 -0
  142. package/lib/Socket/messages-recv.d.ts +170 -0
  143. package/lib/Socket/messages-recv.js +1074 -0
  144. package/lib/Socket/messages-send.d.ts +161 -0
  145. package/lib/Socket/messages-send.js +982 -0
  146. package/lib/Socket/newsletter.d.ts +140 -0
  147. package/lib/Socket/newsletter.js +242 -0
  148. package/lib/Socket/socket.d.ts +43 -0
  149. package/lib/Socket/socket.js +749 -0
  150. package/lib/Socket/usync.d.ts +36 -0
  151. package/lib/Socket/usync.js +71 -0
  152. package/lib/Store/index.d.ts +4 -0
  153. package/lib/Store/index.js +20 -0
  154. package/lib/Store/make-cache-manager-store.d.ts +13 -0
  155. package/lib/Store/make-cache-manager-store.js +77 -0
  156. package/lib/Store/make-in-memory-store.d.ts +117 -0
  157. package/lib/Store/make-in-memory-store.js +420 -0
  158. package/lib/Store/make-ordered-dictionary.d.ts +12 -0
  159. package/lib/Store/make-ordered-dictionary.js +83 -0
  160. package/lib/Store/object-repository.d.ts +10 -0
  161. package/lib/Store/object-repository.js +28 -0
  162. package/lib/Types/Auth.d.ts +103 -0
  163. package/lib/Types/Auth.js +2 -0
  164. package/lib/Types/Call.d.ts +13 -0
  165. package/lib/Types/Call.js +2 -0
  166. package/lib/Types/Chat.d.ts +115 -0
  167. package/lib/Types/Chat.js +6 -0
  168. package/lib/Types/Contact.d.ts +35 -0
  169. package/lib/Types/Contact.js +2 -0
  170. package/lib/Types/Events.d.ts +208 -0
  171. package/lib/Types/Events.js +2 -0
  172. package/lib/Types/GroupMetadata.d.ts +81 -0
  173. package/lib/Types/GroupMetadata.js +2 -0
  174. package/lib/Types/Label.d.ts +46 -0
  175. package/lib/Types/Label.js +28 -0
  176. package/lib/Types/LabelAssociation.d.ts +29 -0
  177. package/lib/Types/LabelAssociation.js +10 -0
  178. package/lib/Types/Message.d.ts +480 -0
  179. package/lib/Types/Message.js +9 -0
  180. package/lib/Types/MexUpdates.d.ts +9 -0
  181. package/lib/Types/MexUpdates.js +18 -0
  182. package/lib/Types/Newsletter.d.ts +92 -0
  183. package/lib/Types/Newsletter.js +33 -0
  184. package/lib/Types/Product.d.ts +78 -0
  185. package/lib/Types/Product.js +2 -0
  186. package/lib/Types/Signal.d.ts +57 -0
  187. package/lib/Types/Signal.js +2 -0
  188. package/lib/Types/Socket.d.ts +116 -0
  189. package/lib/Types/Socket.js +2 -0
  190. package/lib/Types/State.d.ts +27 -0
  191. package/lib/Types/State.js +2 -0
  192. package/lib/Types/USync.d.ts +25 -0
  193. package/lib/Types/USync.js +2 -0
  194. package/lib/Types/index.d.ts +70 -0
  195. package/lib/Types/index.js +42 -0
  196. package/lib/Utils/auth-utils.d.ts +18 -0
  197. package/lib/Utils/auth-utils.js +198 -0
  198. package/lib/Utils/baileys-event-stream.d.ts +16 -0
  199. package/lib/Utils/baileys-event-stream.js +64 -0
  200. package/lib/Utils/business.d.ts +22 -0
  201. package/lib/Utils/business.js +243 -0
  202. package/lib/Utils/chat-utils.d.ts +72 -0
  203. package/lib/Utils/chat-utils.js +762 -0
  204. package/lib/Utils/crypto.d.ts +40 -0
  205. package/lib/Utils/crypto.js +150 -0
  206. package/lib/Utils/decode-wa-message.d.ts +252 -0
  207. package/lib/Utils/decode-wa-message.js +232 -0
  208. package/lib/Utils/event-buffer.d.ts +35 -0
  209. package/lib/Utils/event-buffer.js +539 -0
  210. package/lib/Utils/generics.d.ts +96 -0
  211. package/lib/Utils/generics.js +553 -0
  212. package/lib/Utils/history.d.ts +29 -0
  213. package/lib/Utils/history.js +109 -0
  214. package/lib/Utils/index.d.ts +19 -0
  215. package/lib/Utils/index.js +35 -0
  216. package/lib/Utils/link-preview.d.ts +21 -0
  217. package/lib/Utils/link-preview.js +112 -0
  218. package/lib/Utils/logger.d.ts +11 -0
  219. package/lib/Utils/logger.js +7 -0
  220. package/lib/Utils/lt-hash.d.ts +12 -0
  221. package/lib/Utils/lt-hash.js +53 -0
  222. package/lib/Utils/make-mutex.d.ts +7 -0
  223. package/lib/Utils/make-mutex.js +45 -0
  224. package/lib/Utils/messages-media.d.ts +104 -0
  225. package/lib/Utils/messages-media.js +751 -0
  226. package/lib/Utils/messages.d.ts +80 -0
  227. package/lib/Utils/messages.js +1741 -0
  228. package/lib/Utils/noise-handler.d.ts +19 -0
  229. package/lib/Utils/noise-handler.js +150 -0
  230. package/lib/Utils/process-message.d.ts +41 -0
  231. package/lib/Utils/process-message.js +391 -0
  232. package/lib/Utils/signal.d.ts +33 -0
  233. package/lib/Utils/signal.js +154 -0
  234. package/lib/Utils/use-mongo-file-auth-state.d.ts +5 -0
  235. package/lib/Utils/use-mongo-file-auth-state.js +75 -0
  236. package/lib/Utils/use-multi-file-auth-state.d.ts +12 -0
  237. package/lib/Utils/use-multi-file-auth-state.js +123 -0
  238. package/lib/Utils/use-single-file-auth-state.d.ts +12 -0
  239. package/lib/Utils/use-single-file-auth-state.js +75 -0
  240. package/lib/Utils/validate-connection.d.ts +10 -0
  241. package/lib/Utils/validate-connection.js +174 -0
  242. package/lib/WABinary/constants.d.ts +27 -0
  243. package/lib/WABinary/constants.js +45 -0
  244. package/lib/WABinary/decode.d.ts +6 -0
  245. package/lib/WABinary/decode.js +255 -0
  246. package/lib/WABinary/encode.d.ts +2 -0
  247. package/lib/WABinary/encode.js +243 -0
  248. package/lib/WABinary/generic-utils.d.ts +16 -0
  249. package/lib/WABinary/generic-utils.js +125 -0
  250. package/lib/WABinary/index.d.ts +5 -0
  251. package/lib/WABinary/index.js +21 -0
  252. package/lib/WABinary/jid-utils.d.ts +34 -0
  253. package/lib/WABinary/jid-utils.js +73 -0
  254. package/lib/WABinary/types.d.ts +18 -0
  255. package/lib/WABinary/types.js +2 -0
  256. package/lib/WAM/BinaryInfo.d.ts +16 -0
  257. package/lib/WAM/BinaryInfo.js +14 -0
  258. package/lib/WAM/constants.d.ts +39 -0
  259. package/lib/WAM/constants.js +15362 -0
  260. package/lib/WAM/encode.d.ts +2 -0
  261. package/lib/WAM/encode.js +156 -0
  262. package/lib/WAM/index.d.ts +3 -0
  263. package/lib/WAM/index.js +19 -0
  264. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +25 -0
  265. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +60 -0
  266. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
  267. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
  268. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
  269. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +58 -0
  270. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  271. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +31 -0
  272. package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +8 -0
  273. package/lib/WAUSync/Protocols/USyncLIDProtocol.js +26 -0
  274. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  275. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  276. package/lib/WAUSync/Protocols/index.d.ts +6 -0
  277. package/lib/WAUSync/Protocols/index.js +22 -0
  278. package/lib/WAUSync/USyncQuery.d.ts +28 -0
  279. package/lib/WAUSync/USyncQuery.js +88 -0
  280. package/lib/WAUSync/USyncUser.d.ts +12 -0
  281. package/lib/WAUSync/USyncUser.js +27 -0
  282. package/lib/WAUSync/index.d.ts +3 -0
  283. package/lib/WAUSync/index.js +19 -0
  284. package/lib/index.d.ts +13 -0
  285. package/lib/index.js +45 -0
  286. package/package.json +63 -0
@@ -0,0 +1,140 @@
1
+ import { SocketConfig, WAMediaUpload, NewsletterMetadata, NewsletterReactionMode, NewsletterViewRole, NewsletterFetchedUpdate, ContactAction } from '../Types'
2
+ import { BinaryNode } from '../WABinary'
3
+ export declare const makeNewsletterSocket: (config: SocketConfig) => {
4
+ subscribeNewsletterUpdates: (jid: string) => Promise<{
5
+ duration: string
6
+ }>
7
+ newsletterReactionMode: (jid: string, mode: NewsletterReactionMode) => Promise<void>
8
+ newsletterUpdateDescription: (jid: string, description?: string) => Promise<void>
9
+ newsletterUpdateName: (jid: string, name: string) => Promise<void>
10
+ newsletterUpdatePicture: (jid: string, content: WAMediaUpload) => Promise<void>
11
+ newsletterRemovePicture: (jid: string) => Promise<void>
12
+ newsletterUnfollow: (jid: string) => Promise<void>
13
+ newsletterFollow: (jid: string) => Promise<void>
14
+ newsletterUnmute: (jid: string) => Promise<void>
15
+ newsletterMute: (jid: string) => Promise<void>
16
+ newsletterCreate: (name: string, description?: string, picture?: WAMediaUpload) => Promise<NewsletterMetadata>
17
+ newsletterQuery: (jid: string, type: string, content: BinaryNode) => Promise<BinaryNode>
18
+ newsletterWMexQuery: (jid?: string | undefined, query_id: number, content: BinaryNode) => Promise<BinaryNode>
19
+ newsletterMetadata: (type: 'invite' | 'jid', key: string, role?: NewsletterViewRole) => Promise<NewsletterMetadata>
20
+ newsletterAdminCount: (jid: string) => Promise<number>
21
+ newsletterChangeOwner: (jid: string, userLid: string) => Promise<void>
22
+ newsletterDemote: (jid: string, userLid: string) => Promise<void>
23
+ newsletterDelete: (jid: string) => Promise<void>
24
+ /**if code wasn't passed, the reaction will be removed (if is reacted) */
25
+ newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>
26
+ newsletterFetchMessages: (type: 'invite' | 'jid', key: string, count: number, after?: number) => Promise<NewsletterFetchedUpdate[]>
27
+ newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<NewsletterFetchedUpdate[]>
28
+ groupQuery: (jid: string, type: string, content: BinaryNode) => Promise<BinaryNode>
29
+ groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>
30
+ groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>
31
+ groupLeave: (id: string) => Promise<void>
32
+ groupUpdateSubject: (jid: string, subject: string) => Promise<void>
33
+ groupRequestParticipantsList: (jid: string) => Promise<{
34
+ [key: string]: string
35
+ }[]>
36
+ groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "reject" | "approve") => Promise<{
37
+ status: string
38
+ jid: string
39
+ }[]>
40
+ groupParticipantsUpdate: (jid: string, participants: string[], action: import("../Types").ParticipantAction) => Promise<{
41
+ status: string
42
+ jid: string
43
+ content: BinaryNode
44
+ }[]>
45
+ groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>
46
+ groupInviteCode: (jid: string) => Promise<string | undefined>
47
+ groupRevokeInvite: (jid: string) => Promise<string | undefined>
48
+ groupAcceptInvite: (code: string) => Promise<string | undefined>
49
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>
50
+ groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>
51
+ groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>
52
+ groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>
53
+ groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>
54
+ groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>
55
+ groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>
56
+ groupFetchAllParticipating: () => Promise<{
57
+ [_: string]: import("../Types").GroupMetadata
58
+ }>
59
+ processingMutex: {
60
+ mutex<T>(code: () => T | Promise<T>): Promise<T>
61
+ }
62
+ fetchPrivacySettings: (force?: boolean) => Promise<{
63
+ [_: string]: string
64
+ }>
65
+ upsertMessage: (msg: import("../Types").WAProto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>
66
+ appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>
67
+ sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>
68
+ presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>
69
+ getBotListV2: () => Promise<BotListInfo[]>
70
+ getLidUser: (jid: string) => Promise<{
71
+ lid: string
72
+ id: string
73
+ }[] | undefined>
74
+ onWhatsApp: (...jids: string[]) => Promise<{
75
+ jid: string
76
+ exists: unknown
77
+ }[] | undefined>
78
+ fetchBlocklist: () => Promise<string[]>
79
+ fetchDisappearingDuration: (...jids: string[]) => Promise<import("../index").USyncQueryResultList[] | undefined>
80
+ fetchStatus: (...jids: string[]) => Promise<import("../index").USyncQueryResultList[] | undefined>
81
+ updateProfilePicture: (jid: string, content: WAMediaUpload) => Promise<void>
82
+ removeProfilePicture: (jid: string) => Promise<void>
83
+ updateProfileStatus: (status: string) => Promise<void>
84
+ updateProfileName: (name: string) => Promise<void>
85
+ updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>
86
+ updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>
87
+ updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>
88
+ updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>
89
+ updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>
90
+ updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>
91
+ updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>
92
+ updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>
93
+ updateDefaultDisappearingMode: (duration: number) => Promise<void>
94
+ getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>
95
+ resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>
96
+ chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>
97
+ cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>
98
+ addChatLabel: (jid: string, labelId: string) => Promise<void>
99
+ removeChatLabel: (jid: string, labelId: string) => Promise<void>
100
+ addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>
101
+ removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>
102
+ clearMessage: (jid: string, key: import("../Types").WAProto.IMessageKey, timeStamp: number | import("long").Long) => Promise<void>
103
+ star: (jid: string, messages: {
104
+ id: string
105
+ fromMe?: boolean | undefined
106
+ }[], star: boolean) => Promise<void>
107
+ addOrEditContact: (jid: string, contact: ContactAction) => Promise<void>
108
+ removeContact: (jid: string) => Promise<void>
109
+ executeUSyncQuery: (usyncQuery: import("../index").USyncQuery) => Promise<import("../index").USyncQueryResult | undefined>
110
+ type: "md"
111
+ ws: any
112
+ ev: import("../Types").BaileysEventEmitter & {
113
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void
114
+ buffer(): void
115
+ createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>
116
+ flush(force?: boolean | undefined): boolean
117
+ isBuffering(): boolean
118
+ }
119
+ authState: {
120
+ creds: import("../Types").AuthenticationCreds
121
+ keys: import("../Types").SignalKeyStoreWithTransaction
122
+ }
123
+ signalRepository: import("../Types").SignalRepository
124
+ user: import("../Types").Contact | undefined
125
+ generateMessageTag: () => string
126
+ query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>
127
+ waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>
128
+ waitForSocketOpen: () => Promise<void>
129
+ sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>
130
+ sendNode: (frame: BinaryNode) => Promise<void>
131
+ logout: (msg?: string | undefined) => Promise<void>
132
+ end: (error: Error | undefined) => void
133
+ onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void
134
+ uploadPreKeys: (count?: number) => Promise<void>
135
+ uploadPreKeysToServerIfRequired: () => Promise<void>
136
+ requestPairingCode: (phoneNumber: string, code?: string) => Promise<string>
137
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>
138
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>
139
+ }
140
+ export declare const extractNewsletterMetadata: (node: BinaryNode, isCreate?: boolean) => NewsletterMetadata
@@ -0,0 +1,242 @@
1
+ "use strict"
2
+ Object.defineProperty(exports, "__esModule", { value: true })
3
+ const Types_1 = require("../Types")
4
+ const Utils_1 = require("../Utils")
5
+ const WABinary_1 = require("../WABinary")
6
+ const groups_1 = require("./groups")
7
+ const makeNewsletterSocket = (config) => {
8
+ const sock = groups_1.makeGroupsSocket(config)
9
+ const { authState, signalRepository, query, generateMessageTag } = sock
10
+ const encoder = new TextEncoder()
11
+ const newsletterQuery = async (jid, type, content) => (query({
12
+ tag: 'iq',
13
+ attrs: {
14
+ id: generateMessageTag(),
15
+ type,
16
+ xmlns: 'newsletter',
17
+ to: jid,
18
+ },
19
+ content
20
+ }))
21
+ const newsletterWMexQuery = async (jid, queryId, content) => (query({
22
+ tag: 'iq',
23
+ attrs: {
24
+ id: generateMessageTag(),
25
+ type: 'get',
26
+ xmlns: 'w:mex',
27
+ to: WABinary_1.S_WHATSAPP_NET,
28
+ },
29
+ content: [
30
+ {
31
+ tag: 'query',
32
+ attrs: { 'query_id': queryId },
33
+ content: encoder.encode(JSON.stringify({
34
+ variables: {
35
+ 'newsletter_id': jid,
36
+ ...content
37
+ }
38
+ }))
39
+ }
40
+ ]
41
+ }))
42
+ const parseFetchedUpdates = async (node, type) => {
43
+ let child
44
+ if (type === 'messages') {
45
+ child = WABinary_1.getBinaryNodeChild(node, 'messages')
46
+ }
47
+ else {
48
+ const parent = WABinary_1.getBinaryNodeChild(node, 'message_updates')
49
+ child = WABinary_1.getBinaryNodeChild(parent, 'messages')
50
+ }
51
+ return await Promise.all(WABinary_1.getAllBinaryNodeChildren(child).map(async (messageNode) => {
52
+ messageNode.attrs.from = child?.attrs.jid
53
+ const views = parseInt(WABinary_1.getBinaryNodeChild(messageNode, 'views_count')?.attrs?.count || '0')
54
+ const reactionNode = WABinary_1.getBinaryNodeChild(messageNode, 'reactions')
55
+ const reactions = WABinary_1.getBinaryNodeChildren(reactionNode, 'reaction')
56
+ .map(({ attrs }) => ({ count: +attrs.count, code: attrs.code }))
57
+ const data = {
58
+ 'server_id': messageNode.attrs.server_id,
59
+ views,
60
+ reactions
61
+ }
62
+ if (type === 'messages') {
63
+ const { fullMessage: message, decrypt } = await Utils_1.decryptMessageNode(messageNode, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, config.logger)
64
+ await decrypt()
65
+ data.message = message
66
+ }
67
+ return data
68
+ }))
69
+ }
70
+ return {
71
+ ...sock,
72
+ newsletterQuery,
73
+ newsletterWMexQuery,
74
+ subscribeNewsletterUpdates: async (jid) => {
75
+ const result = await newsletterQuery(jid, 'set', [{ tag: 'live_updates', attrs: {}, content: [] }])
76
+ return WABinary_1.getBinaryNodeChild(result, 'live_updates')?.attrs
77
+ },
78
+ newsletterReactionMode: async (jid, mode) => {
79
+ await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
80
+ updates: { settings: { 'reaction_codes': { value: mode } } }
81
+ })
82
+ },
83
+ newsletterUpdateDescription: async (jid, description) => {
84
+ await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
85
+ updates: { description: description || '', settings: null }
86
+ })
87
+ },
88
+ newsletterUpdateName: async (jid, name) => {
89
+ await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
90
+ updates: { name, settings: null }
91
+ })
92
+ },
93
+ newsletterUpdatePicture: async (jid, content) => {
94
+ const { img } = await Utils_1.generateProfilePicture(content)
95
+ await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
96
+ updates: { picture: img.toString('base64'), settings: null }
97
+ })
98
+ },
99
+ newsletterRemovePicture: async (jid) => {
100
+ await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
101
+ updates: { picture: '', settings: null }
102
+ })
103
+ },
104
+ newsletterUnfollow: async (jid) => {
105
+ await newsletterWMexQuery(jid, Types_1.QueryIds.UNFOLLOW)
106
+ },
107
+ newsletterFollow: async (jid) => {
108
+ await newsletterWMexQuery(jid, Types_1.QueryIds.FOLLOW)
109
+ },
110
+ newsletterUnmute: async (jid) => {
111
+ await newsletterWMexQuery(jid, Types_1.QueryIds.UNMUTE)
112
+ },
113
+ newsletterMute: async (jid) => {
114
+ await newsletterWMexQuery(jid, Types_1.QueryIds.MUTE)
115
+ },
116
+ newsletterAction: async (jid, type) => {
117
+ await newsletterWMexQuery(jid, Types_1.QueryIds[type.toUpperCase()])
118
+ },
119
+ newsletterCreate: async (name, description, picture) => {
120
+ //TODO: Implement TOS system wide for Meta AI, communities, and here etc.
121
+ /**tos query */
122
+ await query({
123
+ tag: 'iq',
124
+ attrs: {
125
+ to: WABinary_1.S_WHATSAPP_NET,
126
+ xmlns: 'tos',
127
+ id: generateMessageTag(),
128
+ type: 'set'
129
+ },
130
+ content: [
131
+ {
132
+ tag: 'notice',
133
+ attrs: {
134
+ id: '20601218',
135
+ stage: '5'
136
+ },
137
+ content: []
138
+ }
139
+ ]
140
+ })
141
+ const result = await newsletterWMexQuery(undefined, Types_1.QueryIds.CREATE, {
142
+ input: {
143
+ name,
144
+ description: description || null,
145
+ picture: picture ? (await Utils_1.generateProfilePicture(picture)).img.toString('base64') : null,
146
+ settings: {
147
+ reaction_codes: {
148
+ value: 'ALL'
149
+ }
150
+ }
151
+ }
152
+ })
153
+ return extractNewsletterMetadata(result, true)
154
+ },
155
+ newsletterMetadata: async (type, key, role) => {
156
+ const result = await newsletterWMexQuery(undefined, Types_1.QueryIds.METADATA, {
157
+ input: {
158
+ key,
159
+ type: type.toUpperCase(),
160
+ view_role: role || 'GUEST'
161
+ },
162
+ fetch_viewer_metadata: true,
163
+ fetch_full_image: true,
164
+ fetch_creation_time: true
165
+ })
166
+ return extractNewsletterMetadata(result)
167
+ },
168
+ newsletterAdminCount: async (jid) => {
169
+ const result = await newsletterWMexQuery(jid, QueryIds.ADMIN_COUNT)
170
+ const buff = WABinary_1.getBinaryNodeChild(result, 'result')?.content?.toString()
171
+ return JSON.parse(buff).data[Types_1.XWAPaths.ADMIN_COUNT].admin_count
172
+ },
173
+ newsletterChangeOwner: async (jid, userLid) => {
174
+ await newsletterWMexQuery(jid, Types_1.QueryIds.CHANGE_OWNER, {
175
+ user_id: userLid
176
+ })
177
+ },
178
+ newsletterDemote: async (jid, userLid) => {
179
+ await newsletterWMexQuery(jid, Types_1.QueryIds.DEMOTE, {
180
+ user_id: userLid
181
+ })
182
+ },
183
+ newsletterDelete: async (jid) => {
184
+ await newsletterWMexQuery(jid, Types_1.QueryIds.DELETE)
185
+ },
186
+ /**if code wasn't passed, the reaction will be removed (if is reacted) */
187
+ newsletterReactMessage: async (jid, serverId, code) => {
188
+ await query({
189
+ tag: 'message',
190
+ attrs: { to: jid, ...(!code ? { edit: '7' } : {}), type: 'reaction', server_id: serverId, id: Utils_1.generateMessageID() },
191
+ content: [{
192
+ tag: 'reaction',
193
+ attrs: code ? { code } : {}
194
+ }]
195
+ })
196
+ },
197
+ newsletterFetchMessages: async (type, key, count, after) => {
198
+ const result = await newsletterQuery(WABinary_1.S_WHATSAPP_NET, 'get', [
199
+ {
200
+ tag: 'messages',
201
+ attrs: { type, ...(type === 'invite' ? { key } : { jid: key }), count: count.toString(), after: after?.toString() || '100' }
202
+ }
203
+ ])
204
+ return await parseFetchedUpdates(result, 'messages')
205
+ },
206
+ newsletterFetchUpdates: async (jid, count, after, since) => {
207
+ const result = await newsletterQuery(jid, 'get', [
208
+ {
209
+ tag: 'message_updates',
210
+ attrs: { count: count.toString(), after: after?.toString() || '100', since: since?.toString() || '0' }
211
+ }
212
+ ])
213
+ return await parseFetchedUpdates(result, 'updates')
214
+ }
215
+ }
216
+ }
217
+ const extractNewsletterMetadata = (node, isCreate) => {
218
+ const result = WABinary_1.getBinaryNodeChild(node, 'result')?.content?.toString()
219
+ const metadataPath = JSON.parse(result).data[isCreate ? Types_1.XWAPaths.CREATE : Types_1.XWAPaths.NEWSLETTER]
220
+ const metadata = {
221
+ id: metadataPath.id,
222
+ state: metadataPath.state.type,
223
+ creation_time: +metadataPath.thread_metadata.creation_time,
224
+ name: metadataPath.thread_metadata.name.text,
225
+ nameTime: +metadataPath.thread_metadata.name.update_time,
226
+ description: metadataPath.thread_metadata.description.text,
227
+ descriptionTime: +metadataPath.thread_metadata.description.update_time,
228
+ invite: metadataPath.thread_metadata.invite,
229
+ handle: metadataPath.thread_metadata.handle,
230
+ picture: Utils_1.getUrlFromDirectPath(metadataPath.thread_metadata.picture?.direct_path || ''),
231
+ preview: Utils_1.getUrlFromDirectPath(metadataPath.thread_metadata.preview?.direct_path || ''),
232
+ reaction_codes: metadataPath.thread_metadata?.settings?.reaction_codes?.value,
233
+ subscribers: +metadataPath.thread_metadata.subscribers_count,
234
+ verification: metadataPath.thread_metadata.verification,
235
+ viewer_metadata: metadataPath.viewer_metadata
236
+ }
237
+ return metadata
238
+ }
239
+ module.exports = {
240
+ makeNewsletterSocket,
241
+ extractNewsletterMetadata
242
+ }
@@ -0,0 +1,43 @@
1
+ import { Boom } from '@hapi/boom'
2
+ import { SocketConfig } from '../Types'
3
+ import { BinaryNode } from '../WABinary'
4
+ import { WebSocketClient } from './Client'
5
+ /**
6
+ * Connects to WA servers and performs:
7
+ * - simple queries (no retry mechanism, wait for connection establishment)
8
+ * - listen to messages and emit events
9
+ * - query phone connection
10
+ */
11
+ export declare const makeSocket: (config: SocketConfig) => {
12
+ type: "md"
13
+ ws: WebSocketClient
14
+ ev: import("../Types").BaileysEventEmitter & {
15
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void
16
+ buffer(): void
17
+ createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T>
18
+ flush(force?: boolean | undefined): boolean
19
+ isBuffering(): boolean
20
+ }
21
+ authState: {
22
+ creds: import("../Types").AuthenticationCreds
23
+ keys: import("../Types").SignalKeyStoreWithTransaction
24
+ }
25
+ signalRepository: import("../Types").SignalRepository
26
+ readonly user: import("../Types").Contact | undefined
27
+ generateMessageTag: () => string
28
+ query: (node: BinaryNode, timeoutMs?: number) => Promise<BinaryNode>
29
+ waitForMessage: <T_1>(msgId: string, timeoutMs?: number | undefined) => Promise<T_1>
30
+ waitForSocketOpen: () => Promise<void>
31
+ sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>
32
+ sendNode: (frame: BinaryNode) => Promise<void>
33
+ logout: (msg?: string) => Promise<void>
34
+ end: (error: Error | undefined) => void
35
+ onUnexpectedError: (err: Error | Boom, msg: string) => void
36
+ uploadPreKeys: (count?: number) => Promise<void>
37
+ uploadPreKeysToServerIfRequired: () => Promise<void>
38
+ requestPairingCode: (phoneNumber: string, code?: string) => Promise<string>
39
+ /** Waits for the connection to WA to reach a state */
40
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>
41
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>
42
+ }
43
+ export type Socket = ReturnType<typeof makeSocket>