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,181 @@
1
+ import { GetCatalogOptions, ProductCreate, ProductUpdate, SocketConfig } from '../Types'
2
+ import { BinaryNode } from '../WABinary'
3
+ export declare const makeBusinessSocket: (config: SocketConfig) => {
4
+ logger: import("../Utils/logger").ILogger
5
+ getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>
6
+ getCatalog: ({ jid, limit, cursor }: GetCatalogOptions) => Promise<{
7
+ products: import("../Types").Product[]
8
+ nextPageCursor: string | undefined
9
+ }>
10
+ getCollections: (jid?: string, limit?: number) => Promise<{
11
+ collections: import("../Types").CatalogCollection[]
12
+ }>
13
+ productCreate: (create: ProductCreate) => Promise<import("../Types").Product>
14
+ productDelete: (productIds: string[]) => Promise<{
15
+ deleted: number
16
+ }>
17
+ productUpdate: (productId: string, update: ProductUpdate) => Promise<import("../Types").Product>
18
+ sendMessageAck: ({ tag, attrs, content }: BinaryNode, errorCode?: number | undefined) => Promise<void>
19
+ sendRetryRequest: (node: BinaryNode, forceIncludeKeys?: boolean) => Promise<void>
20
+ offerCall: (toJid: string, isVideo?: boolean) => Promise<{
21
+ id: any
22
+ to: string
23
+ }>
24
+ rejectCall: (callId: string, callFrom: string) => Promise<void>
25
+ fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAProto.IMessageKey, oldestMsgTimestamp: number | import("long").Long) => Promise<string>
26
+ requestPlaceholderResend: (messageKey: import("../Types").WAProto.IMessageKey) => Promise<string | undefined>
27
+ getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>
28
+ assertSessions: (jids: string[], force: boolean) => Promise<boolean>
29
+ relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>
30
+ sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>
31
+ sendReceipts: (keys: import("../Types").WAProto.IMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>
32
+ readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>
33
+ refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>
34
+ waUploadToServer: import("../Types").WAMediaUploadFunction
35
+ fetchPrivacySettings: (force?: boolean) => Promise<{
36
+ [_: string]: string
37
+ }>
38
+ sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>
39
+ createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: {
40
+ [key: string]: string
41
+ } | undefined) => Promise<{
42
+ nodes: BinaryNode[]
43
+ shouldIncludeDeviceIdentity: boolean
44
+ }>
45
+ profilePictureUrl: (jid: string) => Promise<string>
46
+ getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>
47
+ updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>
48
+ sendStatusMentions: (content: import("../Types").WAProto.IMessage, jid: string, Private?: boolean) => Promise<string>
49
+ sendAlbumMessage: (jid: string, medias: import("../Types").WAProto.IMessage, options?: import("../Types").MiscMessageGenerationOptions) => Promise<string>
50
+ sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>
51
+ groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>
52
+ groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>
53
+ groupLeave: (id: string) => Promise<void>
54
+ groupUpdateSubject: (jid: string, subject: string) => Promise<void>
55
+ groupRequestParticipantsList: (jid: string) => Promise<{
56
+ [key: string]: string
57
+ }[]>
58
+ groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "reject" | "approve") => Promise<{
59
+ status: string
60
+ jid: string
61
+ }[]>
62
+ groupParticipantsUpdate: (jid: string, participants: string[], action: import("../Types").ParticipantAction) => Promise<{
63
+ status: string
64
+ jid: string
65
+ content: BinaryNode
66
+ }[]>
67
+ subscribeNewsletterUpdates: (jid: string) => Promise<{
68
+ duration: string
69
+ }>
70
+ newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>
71
+ newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>
72
+ newsletterUpdateName: (jid: string, name: string) => Promise<void>
73
+ newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>
74
+ newsletterRemovePicture: (jid: string) => Promise<void>
75
+ newsletterUnfollow: (jid: string) => Promise<void>
76
+ newsletterFollow: (jid: string) => Promise<void>
77
+ newsletterUnmute: (jid: string) => Promise<void>
78
+ newsletterMute: (jid: string) => Promise<void>
79
+ newsletterCreate: (name: string, description?: string, picture?: import("../Types").WAMediaUpload) => Promise<import("../Types").NewsletterMetadata>
80
+ newsletterQuery: (jid: string, type: string, content: BinaryNode) => Promise<BinaryNode>
81
+ newsletterWMexQuery: (jid?: string | undefined, query_id: number, content: BinaryNode) => Promise<BinaryNode>
82
+ newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>
83
+ newsletterAdminCount: (jid: string) => Promise<number>
84
+ newsletterChangeOwner: (jid: string, userLid: string) => Promise<void>
85
+ newsletterDemote: (jid: string, userLid: string) => Promise<void>
86
+ newsletterDelete: (jid: string) => Promise<void>
87
+ newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>
88
+ newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>
89
+ newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>
90
+ groupQuery: (jid: string, type: string, content: BinaryNode) => Promise<BinaryNode>
91
+ groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>
92
+ groupInviteCode: (jid: string) => Promise<string | undefined>
93
+ groupRevokeInvite: (jid: string) => Promise<string | undefined>
94
+ groupAcceptInvite: (code: string) => Promise<string | undefined>
95
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>
96
+ groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>
97
+ groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>
98
+ groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>
99
+ groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>
100
+ groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>
101
+ groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>
102
+ groupFetchAllParticipating: () => Promise<{
103
+ [_: string]: import("../Types").GroupMetadata
104
+ }>
105
+ processingMutex: {
106
+ mutex<T>(code: () => T | Promise<T>): Promise<T>
107
+ }
108
+ upsertMessage: (msg: import("../Types").WAProto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>
109
+ appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>
110
+ sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>
111
+ presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>
112
+ getBotListV2: () => Promise<BotListInfo[]>
113
+ getLidUser: (jid: string) => Promise<{
114
+ lid: string
115
+ id: string
116
+ }[] | undefined>
117
+ onWhatsApp: (...jids: string[]) => Promise<{
118
+ jid: string
119
+ exists: unknown
120
+ }[] | undefined>
121
+ fetchBlocklist: () => Promise<string[]>
122
+ fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>
123
+ fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>
124
+ updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>
125
+ removeProfilePicture: (jid: string) => Promise<void>
126
+ updateProfileStatus: (status: string) => Promise<void>
127
+ updateProfileName: (name: string) => Promise<void>
128
+ updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>
129
+ updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>
130
+ updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>
131
+ updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>
132
+ updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>
133
+ updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>
134
+ updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>
135
+ updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>
136
+ updateDefaultDisappearingMode: (duration: number) => Promise<void>
137
+ getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>
138
+ resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>
139
+ chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>
140
+ cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>
141
+ addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>
142
+ addChatLabel: (jid: string, labelId: string) => Promise<void>
143
+ removeChatLabel: (jid: string, labelId: string) => Promise<void>
144
+ addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>
145
+ removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>
146
+ clearMessage: (jid: string, key: import("../Types").WAProto.IMessageKey, timeStamp: number | import("long").Long) => Promise<void>
147
+ star: (jid: string, messages: {
148
+ id: string
149
+ fromMe?: boolean | undefined
150
+ }[], star: boolean) => Promise<void>
151
+ executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>
152
+ type: "md"
153
+ ws: import("./Client").WebSocketClient
154
+ ev: import("../Types").BaileysEventEmitter & {
155
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void
156
+ buffer(): void
157
+ createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>
158
+ flush(force?: boolean | undefined): boolean
159
+ isBuffering(): boolean
160
+ }
161
+ authState: {
162
+ creds: import("../Types").AuthenticationCreds
163
+ keys: import("../Types").SignalKeyStoreWithTransaction
164
+ }
165
+ signalRepository: import("../Types").SignalRepository
166
+ user: import("../Types").Contact | undefined
167
+ generateMessageTag: () => string
168
+ query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>
169
+ waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>
170
+ waitForSocketOpen: () => Promise<void>
171
+ sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>
172
+ sendNode: (frame: BinaryNode) => Promise<void>
173
+ logout: (msg?: string | undefined) => Promise<void>
174
+ end: (error: Error | undefined) => void
175
+ onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void
176
+ uploadPreKeys: (count?: number) => Promise<void>
177
+ uploadPreKeysToServerIfRequired: () => Promise<void>
178
+ requestPairingCode: (phoneNumber: string, code?: string) => Promise<string>
179
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>
180
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>
181
+ }
@@ -0,0 +1,259 @@
1
+ "use strict"
2
+ Object.defineProperty(exports, "__esModule", { value: true })
3
+ const business_1 = require("../Utils/business")
4
+ const WABinary_1 = require("../WABinary")
5
+ const generic_utils_1 = require("../WABinary/generic-utils")
6
+ const messages_recv_1 = require("./messages-recv")
7
+ const makeBusinessSocket = (config) => {
8
+ const sock = messages_recv_1.makeMessagesRecvSocket(config)
9
+ const { authState, query, waUploadToServer } = sock
10
+ const getCatalog = async ({ jid, limit, cursor }) => {
11
+ jid = jid || authState.creds.me?.id
12
+ jid = WABinary_1.jidNormalizedUser(jid)
13
+ const queryParamNodes = [
14
+ {
15
+ tag: 'limit',
16
+ attrs: {},
17
+ content: Buffer.from((limit || 10).toString())
18
+ },
19
+ {
20
+ tag: 'width',
21
+ attrs: {},
22
+ content: Buffer.from('100')
23
+ },
24
+ {
25
+ tag: 'height',
26
+ attrs: {},
27
+ content: Buffer.from('100')
28
+ },
29
+ ]
30
+ if (cursor) {
31
+ queryParamNodes.push({
32
+ tag: 'after',
33
+ attrs: {},
34
+ content: cursor
35
+ })
36
+ }
37
+ const result = await query({
38
+ tag: 'iq',
39
+ attrs: {
40
+ to: WABinary_1.S_WHATSAPP_NET,
41
+ type: 'get',
42
+ xmlns: 'w:biz:catalog'
43
+ },
44
+ content: [
45
+ {
46
+ tag: 'product_catalog',
47
+ attrs: {
48
+ jid,
49
+ 'allow_shop_source': 'true'
50
+ },
51
+ content: queryParamNodes
52
+ }
53
+ ]
54
+ })
55
+ return business_1.parseCatalogNode(result)
56
+ }
57
+ const getCollections = async (jid, limit = 51) => {
58
+ jid = jid || authState.creds.me?.id
59
+ jid = WABinary_1.jidNormalizedUser(jid)
60
+ const result = await query({
61
+ tag: 'iq',
62
+ attrs: {
63
+ to: WABinary_1.S_WHATSAPP_NET,
64
+ type: 'get',
65
+ xmlns: 'w:biz:catalog',
66
+ 'smax_id': '35'
67
+ },
68
+ content: [
69
+ {
70
+ tag: 'collections',
71
+ attrs: {
72
+ 'biz_jid': jid,
73
+ },
74
+ content: [
75
+ {
76
+ tag: 'collection_limit',
77
+ attrs: {},
78
+ content: Buffer.from(limit.toString())
79
+ },
80
+ {
81
+ tag: 'item_limit',
82
+ attrs: {},
83
+ content: Buffer.from(limit.toString())
84
+ },
85
+ {
86
+ tag: 'width',
87
+ attrs: {},
88
+ content: Buffer.from('100')
89
+ },
90
+ {
91
+ tag: 'height',
92
+ attrs: {},
93
+ content: Buffer.from('100')
94
+ }
95
+ ]
96
+ }
97
+ ]
98
+ })
99
+ return business_1.parseCollectionsNode(result)
100
+ }
101
+ const getOrderDetails = async (orderId, tokenBase64) => {
102
+ const result = await query({
103
+ tag: 'iq',
104
+ attrs: {
105
+ to: WABinary_1.S_WHATSAPP_NET,
106
+ type: 'get',
107
+ xmlns: 'fb:thrift_iq',
108
+ 'smax_id': '5'
109
+ },
110
+ content: [
111
+ {
112
+ tag: 'order',
113
+ attrs: {
114
+ op: 'get',
115
+ id: orderId
116
+ },
117
+ content: [
118
+ {
119
+ tag: 'image_dimensions',
120
+ attrs: {},
121
+ content: [
122
+ {
123
+ tag: 'width',
124
+ attrs: {},
125
+ content: Buffer.from('100')
126
+ },
127
+ {
128
+ tag: 'height',
129
+ attrs: {},
130
+ content: Buffer.from('100')
131
+ }
132
+ ]
133
+ },
134
+ {
135
+ tag: 'token',
136
+ attrs: {},
137
+ content: Buffer.from(tokenBase64)
138
+ }
139
+ ]
140
+ }
141
+ ]
142
+ })
143
+ return business_1.parseOrderDetailsNode(result)
144
+ }
145
+ const productUpdate = async (productId, update) => {
146
+ update = await business_1.uploadingNecessaryImagesOfProduct(update, waUploadToServer)
147
+ const editNode = business_1.toProductNode(productId, update)
148
+ const result = await query({
149
+ tag: 'iq',
150
+ attrs: {
151
+ to: WABinary_1.S_WHATSAPP_NET,
152
+ type: 'set',
153
+ xmlns: 'w:biz:catalog'
154
+ },
155
+ content: [
156
+ {
157
+ tag: 'product_catalog_edit',
158
+ attrs: { v: '1' },
159
+ content: [
160
+ editNode,
161
+ {
162
+ tag: 'width',
163
+ attrs: {},
164
+ content: '100'
165
+ },
166
+ {
167
+ tag: 'height',
168
+ attrs: {},
169
+ content: '100'
170
+ }
171
+ ]
172
+ }
173
+ ]
174
+ })
175
+ const productCatalogEditNode = generic_utils_1.getBinaryNodeChild(result, 'product_catalog_edit')
176
+ const productNode = generic_utils_1.getBinaryNodeChild(productCatalogEditNode, 'product')
177
+ return business_1.parseProductNode(productNode)
178
+ }
179
+ const productCreate = async (create) => {
180
+ // ensure isHidden is defined
181
+ create.isHidden = !!create.isHidden
182
+ create = await business_1.uploadingNecessaryImagesOfProduct(create, waUploadToServer)
183
+ const createNode = business_1.toProductNode(undefined, create)
184
+ const result = await query({
185
+ tag: 'iq',
186
+ attrs: {
187
+ to: WABinary_1.S_WHATSAPP_NET,
188
+ type: 'set',
189
+ xmlns: 'w:biz:catalog'
190
+ },
191
+ content: [
192
+ {
193
+ tag: 'product_catalog_add',
194
+ attrs: { v: '1' },
195
+ content: [
196
+ createNode,
197
+ {
198
+ tag: 'width',
199
+ attrs: {},
200
+ content: '100'
201
+ },
202
+ {
203
+ tag: 'height',
204
+ attrs: {},
205
+ content: '100'
206
+ }
207
+ ]
208
+ }
209
+ ]
210
+ })
211
+ const productCatalogAddNode = generic_utils_1.getBinaryNodeChild(result, 'product_catalog_add')
212
+ const productNode = generic_utils_1.getBinaryNodeChild(productCatalogAddNode, 'product')
213
+ return business_1.parseProductNode(productNode)
214
+ }
215
+ const productDelete = async (productIds) => {
216
+ const result = await query({
217
+ tag: 'iq',
218
+ attrs: {
219
+ to: WABinary_1.S_WHATSAPP_NET,
220
+ type: 'set',
221
+ xmlns: 'w:biz:catalog'
222
+ },
223
+ content: [
224
+ {
225
+ tag: 'product_catalog_delete',
226
+ attrs: { v: '1' },
227
+ content: productIds.map(id => ({
228
+ tag: 'product',
229
+ attrs: {},
230
+ content: [
231
+ {
232
+ tag: 'id',
233
+ attrs: {},
234
+ content: Buffer.from(id)
235
+ }
236
+ ]
237
+ }))
238
+ }
239
+ ]
240
+ })
241
+ const productCatalogDelNode = generic_utils_1.getBinaryNodeChild(result, 'product_catalog_delete')
242
+ return {
243
+ deleted: +(productCatalogDelNode?.attrs?.deleted_count || 0)
244
+ }
245
+ }
246
+ return {
247
+ ...sock,
248
+ logger: config.logger,
249
+ getOrderDetails,
250
+ getCatalog,
251
+ getCollections,
252
+ productCreate,
253
+ productDelete,
254
+ productUpdate
255
+ }
256
+ }
257
+ module.exports = {
258
+ makeBusinessSocket
259
+ }
@@ -0,0 +1,95 @@
1
+ import { Boom } from '@hapi/boom'
2
+ import { proto } from '../../WAProto'
3
+ import { BotListInfo, ChatModification, ContactAction, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAPatchCreate, WAPresence, WAPrivacyCallValue, WAPrivacyGroupAddValue, WAPrivacyMessagesValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types'
4
+ import { LabelActionBody } from '../Types/Label'
5
+ import { BinaryNode } from '../WABinary'
6
+ import { USyncQuery } from '../WAUSync'
7
+ export declare const makeChatsSocket: (config: SocketConfig) => {
8
+ processingMutex: {
9
+ mutex<T>(code: () => T | Promise<T>): Promise<T>
10
+ }
11
+ fetchPrivacySettings: (force?: boolean) => Promise<{
12
+ [_: string]: string
13
+ }>
14
+ upsertMessage: (msg: proto.IWebMessageInfo, type: MessageUpsertType) => Promise<void>
15
+ appPatch: (patchCreate: WAPatchCreate) => Promise<void>
16
+ sendPresenceUpdate: (type: WAPresence, toJid?: string) => Promise<void>
17
+ presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>
18
+ getBotListV2: () => Promise<BotListInfo[]>
19
+ getLidUser: (jid: string) => Promise<{
20
+ lid: string
21
+ id: string
22
+ }[] | undefined>
23
+ onWhatsApp: (...jids: string[]) => Promise<{
24
+ jid: string
25
+ exists: unknown
26
+ }[] | undefined>
27
+ fetchBlocklist: () => Promise<string[]>
28
+ fetchStatus: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>
29
+ fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>
30
+ updateProfilePicture: (jid: string, content: WAMediaUpload) => Promise<void>
31
+ removeProfilePicture: (jid: string) => Promise<void>
32
+ updateProfileStatus: (status: string) => Promise<void>
33
+ updateProfileName: (name: string) => Promise<void>
34
+ updateBlockStatus: (jid: string, action: 'block' | 'unblock') => Promise<void>
35
+ updateCallPrivacy: (value: WAPrivacyCallValue) => Promise<void>
36
+ updateMessagesPrivacy: (value: WAPrivacyMessagesValue) => Promise<void>
37
+ updateLastSeenPrivacy: (value: WAPrivacyValue) => Promise<void>
38
+ updateOnlinePrivacy: (value: WAPrivacyOnlineValue) => Promise<void>
39
+ updateProfilePicturePrivacy: (value: WAPrivacyValue) => Promise<void>
40
+ updateStatusPrivacy: (value: WAPrivacyValue) => Promise<void>
41
+ updateReadReceiptsPrivacy: (value: WAReadReceiptsValue) => Promise<void>
42
+ updateGroupsAddPrivacy: (value: WAPrivacyGroupAddValue) => Promise<void>
43
+ updateDefaultDisappearingMode: (duration: number) => Promise<void>
44
+ getBusinessProfile: (jid: string) => Promise<WABusinessProfile | void>
45
+ resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>
46
+ chatModify: (mod: ChatModification, jid: string) => Promise<void>
47
+ cleanDirtyBits: (type: 'account_sync' | 'groups', fromTimestamp?: number | string) => Promise<void>
48
+ addLabel: (jid: string, labels: LabelActionBody) => Promise<void>
49
+ addChatLabel: (jid: string, labelId: string) => Promise<void>
50
+ removeChatLabel: (jid: string, labelId: string) => Promise<void>
51
+ addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>
52
+ removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>
53
+ clearMessage: (jid: string, key: import("../Types").WAProto.IMessageKey, timeStamp: number | import("long").Long) => Promise<void>
54
+ star: (jid: string, messages: {
55
+ id: string
56
+ fromMe?: boolean
57
+ }[], star: boolean) => Promise<void>
58
+ addOrEditContact: (jid: string, contact: ContactAction) => Promise<void>
59
+ removeContact: (jid: string) => Promise<void>
60
+ executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>
61
+ type: "md"
62
+ ws: import("./Client").WebSocketClient
63
+ ev: import("../Types").BaileysEventEmitter & {
64
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void
65
+ buffer(): void
66
+ createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>
67
+ flush(force?: boolean | undefined): boolean
68
+ isBuffering(): boolean
69
+ }
70
+ authState: {
71
+ creds: import("../Types").AuthenticationCreds
72
+ keys: import("../Types").SignalKeyStoreWithTransaction
73
+ }
74
+ signalRepository: import("../Types").SignalRepository
75
+ user: import("../Types").Contact | undefined
76
+ generateMessageTag: () => string
77
+ query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>
78
+ waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>
79
+ waitForSocketOpen: () => Promise<void>
80
+ sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>
81
+ sendNode: (frame: BinaryNode) => Promise<void>
82
+ logout: (msg?: string | undefined) => Promise<void>
83
+ end: (error: Error | undefined) => void
84
+ onUnexpectedError: (err: Error | Boom<any>, msg: string) => void
85
+ uploadPreKeys: (count?: number) => Promise<void>
86
+ uploadPreKeysToServerIfRequired: () => Promise<void>
87
+ requestPairingCode: (phoneNumber: string, code?: string) => Promise<string>
88
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>
89
+ /**
90
+ * modify a chat -- mark unread, read etc.
91
+ * lastMessages must be sorted in reverse chronologically
92
+ * requires the last messages till the last message received required for archive & unread
93
+ */
94
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>
95
+ }