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,125 @@
1
+ "use strict"
2
+ Object.defineProperty(exports, "__esModule", { value: true })
3
+ const boom_1 = require("@hapi/boom")
4
+ const WAProto_1 = require("../../WAProto")
5
+ // some extra useful utilities
6
+ const getBinaryNodeChildren = (node, childTag) => {
7
+ if (Array.isArray(node?.content)) {
8
+ return node.content.filter(item => item.tag === childTag)
9
+ }
10
+ return []
11
+ }
12
+ const getAllBinaryNodeChildren = ({ content }) => {
13
+ if (Array.isArray(content)) {
14
+ return content
15
+ }
16
+ return []
17
+ }
18
+ const getBinaryNodeChild = (node, childTag) => {
19
+ if (Array.isArray(node?.content)) {
20
+ return node?.content.find(item => item.tag === childTag)
21
+ }
22
+ }
23
+ const getBinaryNodeChildBuffer = (node, childTag) => {
24
+ const child = getBinaryNodeChild(node, childTag)?.content
25
+ if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
26
+ return child
27
+ }
28
+ }
29
+ const getBinaryNodeChildString = (node, childTag) => {
30
+ const child = getBinaryNodeChild(node, childTag)?.content
31
+ if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
32
+ return Buffer.from(child).toString('utf-8')
33
+ }
34
+ else if (typeof child === 'string') {
35
+ return child
36
+ }
37
+ }
38
+ const getBinaryNodeChildUInt = (node, childTag, length) => {
39
+ const buff = getBinaryNodeChildBuffer(node, childTag)
40
+ if (buff) {
41
+ return bufferToUInt(buff, length)
42
+ }
43
+ }
44
+ const assertNodeErrorFree = (node) => {
45
+ const errNode = getBinaryNodeChild(node, 'error')
46
+ if (errNode) {
47
+ throw new boom_1.Boom(errNode.attrs.text || 'Unknown error', { data: +errNode.attrs.code })
48
+ }
49
+ }
50
+ const reduceBinaryNodeToDictionary = (node, tag) => {
51
+ const nodes = getBinaryNodeChildren(node, tag)
52
+ const dict = nodes.reduce((dict, { attrs }) => {
53
+ dict[attrs.name || attrs.config_code] = attrs.value || attrs.config_value
54
+ return dict
55
+ }, {})
56
+ return dict
57
+ }
58
+ const getBinaryNodeMessages = ({ content }) => {
59
+ const msgs = []
60
+ if (Array.isArray(content)) {
61
+ for (const item of content) {
62
+ if (item.tag === 'message') {
63
+ msgs.push(WAProto_1.proto.WebMessageInfo.decode(item.content))
64
+ }
65
+ }
66
+ }
67
+ return msgs
68
+ }
69
+ const getBinaryFilteredButtons = (nodeContent) => {
70
+ if (!Array.isArray(nodeContent)) return false
71
+ return nodeContent.some(a =>
72
+ ['native_flow'].includes(a?.content?.[0]?.content?.[0]?.tag) ||
73
+ ['interactive', 'buttons', 'list'].includes(a?.content?.[0]?.tag) ||
74
+ ['hsm', 'biz'].includes(a?.tag)
75
+ )
76
+ }
77
+ const getBinaryFilteredBizBot = (nodeContent) => {
78
+ if (!Array.isArray(nodeContent)) return false
79
+ return nodeContent.some(b =>
80
+ ['bot'].includes(b?.tag) && b?.attrs?.biz_bot === '1'
81
+ )
82
+ }
83
+ function bufferToUInt(e, t) {
84
+ let a = 0
85
+ for (let i = 0; i < t; i++) {
86
+ a = 256 * a + e[i]
87
+ }
88
+ return a
89
+ }
90
+ const tabs = (n) => '\t'.repeat(n)
91
+ function binaryNodeToString(node, i = 0) {
92
+ if (!node) {
93
+ return node
94
+ }
95
+ if (typeof node === 'string') {
96
+ return tabs(i) + node
97
+ }
98
+ if (node instanceof Uint8Array) {
99
+ return tabs(i) + Buffer.from(node).toString('hex')
100
+ }
101
+ if (Array.isArray(node)) {
102
+ return node.map((x) => tabs(i + 1) + binaryNodeToString(x, i + 1)).join('\n')
103
+ }
104
+ const children = binaryNodeToString(node.content, i + 1)
105
+ const tag = `<${node.tag} ${Object.entries(node.attrs || {})
106
+ .filter(([, v]) => v !== undefined)
107
+ .map(([k, v]) => `${k}='${v}'`)
108
+ .join(' ')}`
109
+ const content = children ? `>\n${children}\n${tabs(i)}</${node.tag}>` : '/>'
110
+ return tag + content
111
+ }
112
+ module.exports = {
113
+ getBinaryNodeChildren,
114
+ getAllBinaryNodeChildren,
115
+ getBinaryNodeChild,
116
+ getBinaryNodeChildBuffer,
117
+ getBinaryNodeChildString,
118
+ getBinaryNodeChildUInt,
119
+ assertNodeErrorFree,
120
+ reduceBinaryNodeToDictionary,
121
+ getBinaryNodeMessages,
122
+ getBinaryFilteredButtons,
123
+ getBinaryFilteredBizBot,
124
+ binaryNodeToString
125
+ }
@@ -0,0 +1,5 @@
1
+ export * from './encode'
2
+ export * from './decode'
3
+ export * from './generic-utils'
4
+ export * from './jid-utils'
5
+ export * from './types'
@@ -0,0 +1,21 @@
1
+ "use strict"
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k
4
+ var desc = Object.getOwnPropertyDescriptor(m, k)
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k] } }
7
+ }
8
+ Object.defineProperty(o, k2, desc)
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k
11
+ o[k2] = m[k]
12
+ }))
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p)
15
+ }
16
+ Object.defineProperty(exports, "__esModule", { value: true })
17
+ __exportStar(require("./encode"), exports)
18
+ __exportStar(require("./decode"), exports)
19
+ __exportStar(require("./generic-utils"), exports)
20
+ __exportStar(require("./jid-utils"), exports)
21
+ __exportStar(require("./types"), exports)
@@ -0,0 +1,34 @@
1
+ export declare const S_WHATSAPP_NET = "@s.whatsapp.net"
2
+ export declare const OFFICIAL_BIZ_JID = "16505361212@c.us"
3
+ export declare const SERVER_JID = "server@c.us"
4
+ export declare const PSA_WID = "0@c.us"
5
+ export declare const STORIES_JID = "status@broadcast"
6
+ export declare const META_AI_JID = '13135550002@c.us'
7
+ export type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call' | 'lid' | 'newsletter' | 'bot'
8
+ export type JidWithDevice = {
9
+ user: string
10
+ device?: number
11
+ }
12
+ export type FullJid = JidWithDevice & {
13
+ server: JidServer
14
+ domainType?: number
15
+ }
16
+ export declare const jidEncode: (user: string | number | null, server: JidServer, device?: number, agent?: number) => string
17
+ export declare const jidDecode: (jid: string | undefined) => FullJid | undefined
18
+ /** is the jid a user */
19
+ export declare const areJidsSameUser: (jid1: string | undefined, jid2: string | undefined) => boolean
20
+ /** is the lid a user */
21
+ export declare const isJidUser: (jid: string | undefined) => boolean | undefined
22
+ /** is the jid a group */
23
+ export declare const isLidUser: (jid: string | undefined) => boolean | undefined
24
+ /** is the jid a broadcast */
25
+ export declare const isJidBroadcast: (jid: string | undefined) => boolean | undefined
26
+ /** is the jid a group */
27
+ export declare const isJidGroup: (jid: string | undefined) => boolean | undefined
28
+ /** is the jid the status broadcast */
29
+ export declare const isJidStatusBroadcast: (jid: string) => boolean
30
+ /** is the jid a newsletter */
31
+ export declare const isJidNewsletter: (jid: string | undefined) => boolean | undefined
32
+ /** is the jid a bot */
33
+ export declare const isJidBot: (jid: string | undefined) => boolean | undefined
34
+ export declare const jidNormalizedUser: (jid: string | undefined) => string
@@ -0,0 +1,73 @@
1
+ "use strict"
2
+ Object.defineProperty(exports, "__esModule", { value: true })
3
+ const S_WHATSAPP_NET = '@s.whatsapp.net'
4
+ const OFFICIAL_BIZ_JID = '16505361212@c.us'
5
+ const SERVER_JID = 'server@c.us'
6
+ const PSA_WID = '0@c.us'
7
+ const STORIES_JID = 'status@broadcast'
8
+ const META_AI_JID = '13135550002@c.us'
9
+ const jidEncode = (user, server, device, agent) => {
10
+ return `${user || ''}${!!agent ? `_${agent}` : ''}${!!device ? `:${device}` : ''}@${server}`
11
+ }
12
+ const jidDecode = (jid) => {
13
+ const sepIdx = typeof jid === 'string' ? jid.indexOf('@') : -1
14
+ if (sepIdx < 0) {
15
+ return undefined
16
+ }
17
+ const server = jid.slice(sepIdx + 1)
18
+ const userCombined = jid.slice(0, sepIdx)
19
+ const [userAgent, device] = userCombined.split(':')
20
+ const user = userAgent.split('_')[0]
21
+ return {
22
+ server: server,
23
+ user,
24
+ domainType: server === 'lid' ? 1 : 0,
25
+ device: device ? +device : undefined
26
+ }
27
+ }
28
+ /** is the jid a user */
29
+ const areJidsSameUser = (jid1, jid2) => {
30
+ return jidDecode(jid1)?.user === jidDecode(jid2)?.user
31
+ }
32
+ /** is the jid a user */
33
+ const isJidUser = (jid) => jid?.endsWith('@s.whatsapp.net')
34
+ /** is the lid a user */
35
+ const isLidUser = (jid) => jid?.endsWith('@lid')
36
+ /** is the jid a broadcast */
37
+ const isJidBroadcast = (jid) => jid?.endsWith('@broadcast')
38
+ /** is the jid a group */
39
+ const isJidGroup = (jid) => jid?.endsWith('@g.us')
40
+ /** is the jid the status broadcast */
41
+ const isJidStatusBroadcast = (jid) => jid === 'status@broadcast'
42
+ /** is the jid a newsletter */
43
+ const isJidNewsletter = (jid) => jid?.endsWith('@newsletter')
44
+ /** is the jid a bot */
45
+ const botRegexp = /^1313555\d{4}$|^131655500\d{2}$/
46
+ const isJidBot = (jid) => (jid && botRegexp.test(jid.split('@')[0]) && jid.endsWith('@c.us'))
47
+ const jidNormalizedUser = (jid) => {
48
+ const result = jidDecode(jid)
49
+ if (!result) {
50
+ return ''
51
+ }
52
+ const { user, server } = result
53
+ return jidEncode(user, server === 'c.us' ? 's.whatsapp.net' : server)
54
+ }
55
+ module.exports = {
56
+ S_WHATSAPP_NET,
57
+ OFFICIAL_BIZ_JID,
58
+ SERVER_JID,
59
+ PSA_WID,
60
+ STORIES_JID,
61
+ META_AI_JID,
62
+ jidEncode,
63
+ jidDecode,
64
+ areJidsSameUser,
65
+ isJidUser,
66
+ isLidUser,
67
+ isJidBroadcast,
68
+ isJidGroup,
69
+ isJidStatusBroadcast,
70
+ isJidNewsletter,
71
+ isJidBot,
72
+ jidNormalizedUser
73
+ }
@@ -0,0 +1,18 @@
1
+ import * as constants from './constants'
2
+ /**
3
+ * the binary node WA uses internally for communication
4
+ *
5
+ * this is manipulated soley as an object and it does not have any functions.
6
+ * This is done for easy serialization, to prevent running into issues with prototypes &
7
+ * to maintain functional code structure
8
+ * */
9
+ export type BinaryNode = {
10
+ tag: string
11
+ attrs: {
12
+ [key: string]: string
13
+ }
14
+ content?: BinaryNode[] | string | Uint8Array
15
+ }
16
+ export type BinaryNodeAttributes = BinaryNode['attrs']
17
+ export type BinaryNodeData = BinaryNode['content']
18
+ export type BinaryNodeCodingOptions = typeof constants
@@ -0,0 +1,2 @@
1
+ "use strict"
2
+ Object.defineProperty(exports, "__esModule", { value: true })
@@ -0,0 +1,16 @@
1
+ export declare class BinaryInfo {
2
+ protocolVersion: number
3
+ sequence: number
4
+ events: {
5
+ [x: string]: {
6
+ props: {
7
+ [x: string]: import("./constants").Value
8
+ }
9
+ globals: {
10
+ [x: string]: import("./constants").Value
11
+ }
12
+ }
13
+ }[]
14
+ buffer: Buffer[]
15
+ constructor(options?: Partial<BinaryInfo>)
16
+ }
@@ -0,0 +1,14 @@
1
+ "use strict"
2
+ Object.defineProperty(exports, "__esModule", { value: true })
3
+ class BinaryInfo {
4
+ constructor(options = {}) {
5
+ this.protocolVersion = 5
6
+ this.sequence = 0
7
+ this.events = []
8
+ this.buffer = []
9
+ Object.assign(this, options)
10
+ }
11
+ }
12
+ module.exports = {
13
+ BinaryInfo
14
+ }
@@ -0,0 +1,39 @@
1
+ export declare const WEB_EVENTS: Event[]
2
+ export declare const WEB_GLOBALS: Global[]
3
+ export declare const FLAG_BYTE = 8, FLAG_GLOBAL = 0, FLAG_EVENT = 1, FLAG_FIELD = 2, FLAG_EXTENDED = 4
4
+ export type Event = {
5
+ name: string
6
+ id: number
7
+ props: {
8
+ [key: string]: [number, string | {
9
+ [key: string]: number
10
+ }]
11
+ }
12
+ weight: number
13
+ wamChannel: string
14
+ privateStatsIdInt: number
15
+ }
16
+ export type Global = {
17
+ name: string
18
+ id: number
19
+ type: string | {
20
+ [key: string]: number
21
+ }
22
+ validator?: string
23
+ channels: string[]
24
+ }
25
+ type EventByName<T extends Event['name']> = Extract<Event, {
26
+ name: T
27
+ }>
28
+ export type EventInputType = {
29
+ [key in Event['name']]: {
30
+ props: {
31
+ [k in keyof EventByName<key>['props']]: Value
32
+ }
33
+ globals: {
34
+ [x: string]: Value
35
+ }
36
+ }
37
+ } & {}
38
+ export type Value = number | null | string
39
+ export {}