@neelegirl/baileys 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +77 -0
  3. package/WAProto/GenerateStatics.sh +4 -0
  4. package/WAProto/WAProto.proto +4451 -0
  5. package/WAProto/index.d.ts +51459 -0
  6. package/WAProto/index.js +158781 -0
  7. package/WASignalGroup/GroupProtocol.js +1697 -0
  8. package/WASignalGroup/ciphertext_message.js +16 -0
  9. package/WASignalGroup/group_cipher.js +120 -0
  10. package/WASignalGroup/group_session_builder.js +46 -0
  11. package/WASignalGroup/index.js +5 -0
  12. package/WASignalGroup/keyhelper.js +21 -0
  13. package/WASignalGroup/protobufs.js +3 -0
  14. package/WASignalGroup/queue_job.js +69 -0
  15. package/WASignalGroup/sender_chain_key.js +50 -0
  16. package/WASignalGroup/sender_key_distribution_message.js +78 -0
  17. package/WASignalGroup/sender_key_message.js +92 -0
  18. package/WASignalGroup/sender_key_name.js +70 -0
  19. package/WASignalGroup/sender_key_record.js +56 -0
  20. package/WASignalGroup/sender_key_state.js +129 -0
  21. package/WASignalGroup/sender_message_key.js +39 -0
  22. package/package.json +88 -0
  23. package/src/Defaults/baileys-version.json +3 -0
  24. package/src/Defaults/index.d.ts +68 -0
  25. package/src/Defaults/index.js +131 -0
  26. package/src/Defaults/phonenumber-mcc.json +223 -0
  27. package/src/Signal/libsignal.d.ts +4 -0
  28. package/src/Signal/libsignal.js +162 -0
  29. package/src/Socket/Client/index.d.ts +2 -0
  30. package/src/Socket/Client/index.js +22 -0
  31. package/src/Socket/Client/types.d.ts +16 -0
  32. package/src/Socket/Client/types.js +18 -0
  33. package/src/Socket/Client/websocket.d.ts +13 -0
  34. package/src/Socket/Client/websocket.js +62 -0
  35. package/src/Socket/business.d.ts +182 -0
  36. package/src/Socket/business.js +268 -0
  37. package/src/Socket/chats.d.ts +96 -0
  38. package/src/Socket/chats.js +1278 -0
  39. package/src/Socket/groups.d.ts +130 -0
  40. package/src/Socket/groups.js +337 -0
  41. package/src/Socket/index.d.ts +185 -0
  42. package/src/Socket/index.js +14 -0
  43. package/src/Socket/messages-recv.d.ts +171 -0
  44. package/src/Socket/messages-recv.js +1182 -0
  45. package/src/Socket/messages-send.d.ts +162 -0
  46. package/src/Socket/messages-send.js +1086 -0
  47. package/src/Socket/newsletter.d.ts +142 -0
  48. package/src/Socket/newsletter.js +256 -0
  49. package/src/Socket/socket.d.ts +45 -0
  50. package/src/Socket/socket.js +749 -0
  51. package/src/Socket/usync.d.ts +37 -0
  52. package/src/Socket/usync.js +83 -0
  53. package/src/Store/index.d.ts +4 -0
  54. package/src/Store/index.js +24 -0
  55. package/src/Store/make-cache-manager-store.d.ts +14 -0
  56. package/src/Store/make-cache-manager-store.js +90 -0
  57. package/src/Store/make-in-memory-store.d.ts +123 -0
  58. package/src/Store/make-in-memory-store.js +429 -0
  59. package/src/Store/make-ordered-dictionary.d.ts +12 -0
  60. package/src/Store/make-ordered-dictionary.js +86 -0
  61. package/src/Store/object-repository.d.ts +10 -0
  62. package/src/Store/object-repository.js +31 -0
  63. package/src/Types/Auth.d.ts +120 -0
  64. package/src/Types/Auth.js +3 -0
  65. package/src/Types/Call.d.ts +14 -0
  66. package/src/Types/Call.js +3 -0
  67. package/src/Types/Chat.d.ts +134 -0
  68. package/src/Types/Chat.js +9 -0
  69. package/src/Types/Contact.d.ts +25 -0
  70. package/src/Types/Contact.js +3 -0
  71. package/src/Types/Events.d.ts +212 -0
  72. package/src/Types/Events.js +3 -0
  73. package/src/Types/GroupMetadata.d.ts +64 -0
  74. package/src/Types/GroupMetadata.js +3 -0
  75. package/src/Types/Label.d.ts +48 -0
  76. package/src/Types/Label.js +31 -0
  77. package/src/Types/LabelAssociation.d.ts +35 -0
  78. package/src/Types/LabelAssociation.js +13 -0
  79. package/src/Types/Message.d.ts +459 -0
  80. package/src/Types/Message.js +13 -0
  81. package/src/Types/Newsletter.d.ts +107 -0
  82. package/src/Types/Newsletter.js +38 -0
  83. package/src/Types/Product.d.ts +92 -0
  84. package/src/Types/Product.js +3 -0
  85. package/src/Types/Signal.d.ts +68 -0
  86. package/src/Types/Signal.js +3 -0
  87. package/src/Types/Socket.d.ts +120 -0
  88. package/src/Types/Socket.js +3 -0
  89. package/src/Types/State.d.ts +29 -0
  90. package/src/Types/State.js +3 -0
  91. package/src/Types/USync.d.ts +26 -0
  92. package/src/Types/USync.js +3 -0
  93. package/src/Types/index.d.ts +78 -0
  94. package/src/Types/index.js +47 -0
  95. package/src/Utils/auth-utils.d.ts +21 -0
  96. package/src/Utils/auth-utils.js +205 -0
  97. package/src/Utils/baileys-event-stream.d.ts +18 -0
  98. package/src/Utils/baileys-event-stream.js +70 -0
  99. package/src/Utils/business.d.ts +29 -0
  100. package/src/Utils/business.js +247 -0
  101. package/src/Utils/chat-utils.d.ts +82 -0
  102. package/src/Utils/chat-utils.js +774 -0
  103. package/src/Utils/crypto.d.ts +56 -0
  104. package/src/Utils/crypto.js +179 -0
  105. package/src/Utils/decode-wa-message.d.ts +41 -0
  106. package/src/Utils/decode-wa-message.js +236 -0
  107. package/src/Utils/event-buffer.d.ts +39 -0
  108. package/src/Utils/event-buffer.js +548 -0
  109. package/src/Utils/generics.d.ts +129 -0
  110. package/src/Utils/generics.js +584 -0
  111. package/src/Utils/history.d.ts +23 -0
  112. package/src/Utils/history.js +100 -0
  113. package/src/Utils/index.d.ts +19 -0
  114. package/src/Utils/index.js +39 -0
  115. package/src/Utils/link-preview.d.ts +23 -0
  116. package/src/Utils/link-preview.js +120 -0
  117. package/src/Utils/logger.d.ts +13 -0
  118. package/src/Utils/logger.js +7 -0
  119. package/src/Utils/lt-hash.d.ts +14 -0
  120. package/src/Utils/lt-hash.js +58 -0
  121. package/src/Utils/make-mutex.d.ts +9 -0
  122. package/src/Utils/make-mutex.js +49 -0
  123. package/src/Utils/messages-media.d.ts +129 -0
  124. package/src/Utils/messages-media.js +782 -0
  125. package/src/Utils/messages.d.ts +103 -0
  126. package/src/Utils/messages.js +1536 -0
  127. package/src/Utils/noise-handler.d.ts +20 -0
  128. package/src/Utils/noise-handler.js +155 -0
  129. package/src/Utils/process-message.d.ts +49 -0
  130. package/src/Utils/process-message.js +387 -0
  131. package/src/Utils/signal.d.ts +42 -0
  132. package/src/Utils/signal.js +166 -0
  133. package/src/Utils/use-mongo-file-auth-state.d.ts +6 -0
  134. package/src/Utils/use-mongo-file-auth-state.js +84 -0
  135. package/src/Utils/use-multi-file-auth-state.d.ts +13 -0
  136. package/src/Utils/use-multi-file-auth-state.js +131 -0
  137. package/src/Utils/use-single-file-auth-state.d.ts +13 -0
  138. package/src/Utils/use-single-file-auth-state.js +80 -0
  139. package/src/Utils/validate-connection.d.ts +13 -0
  140. package/src/Utils/validate-connection.js +186 -0
  141. package/src/WABinary/constants.d.ts +30 -0
  142. package/src/WABinary/constants.js +53 -0
  143. package/src/WABinary/decode.d.ts +9 -0
  144. package/src/WABinary/decode.js +288 -0
  145. package/src/WABinary/encode.d.ts +3 -0
  146. package/src/WABinary/encode.js +256 -0
  147. package/src/WABinary/generic-utils.d.ts +28 -0
  148. package/src/WABinary/generic-utils.js +149 -0
  149. package/src/WABinary/index.d.ts +5 -0
  150. package/src/WABinary/index.js +25 -0
  151. package/src/WABinary/jid-utils.d.ts +53 -0
  152. package/src/WABinary/jid-utils.js +92 -0
  153. package/src/WABinary/types.d.ts +22 -0
  154. package/src/WABinary/types.js +3 -0
  155. package/src/WAM/BinaryInfo.d.ts +16 -0
  156. package/src/WAM/BinaryInfo.js +17 -0
  157. package/src/WAM/constants.d.ts +47 -0
  158. package/src/WAM/constants.js +15371 -0
  159. package/src/WAM/encode.d.ts +3 -0
  160. package/src/WAM/encode.js +165 -0
  161. package/src/WAM/index.d.ts +3 -0
  162. package/src/WAM/index.js +23 -0
  163. package/src/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +28 -0
  164. package/src/WAUSync/Protocols/USyncBotProfileProtocol.js +69 -0
  165. package/src/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
  166. package/src/WAUSync/Protocols/USyncContactProtocol.js +36 -0
  167. package/src/WAUSync/Protocols/USyncDeviceProtocol.d.ts +26 -0
  168. package/src/WAUSync/Protocols/USyncDeviceProtocol.js +62 -0
  169. package/src/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +14 -0
  170. package/src/WAUSync/Protocols/USyncDisappearingModeProtocol.js +35 -0
  171. package/src/WAUSync/Protocols/USyncLIDProtocol.d.ts +9 -0
  172. package/src/WAUSync/Protocols/USyncLIDProtocol.js +30 -0
  173. package/src/WAUSync/Protocols/USyncStatusProtocol.d.ts +14 -0
  174. package/src/WAUSync/Protocols/USyncStatusProtocol.js +46 -0
  175. package/src/WAUSync/Protocols/index.d.ts +6 -0
  176. package/src/WAUSync/Protocols/index.js +26 -0
  177. package/src/WAUSync/USyncQuery.d.ts +31 -0
  178. package/src/WAUSync/USyncQuery.js +92 -0
  179. package/src/WAUSync/USyncUser.d.ts +12 -0
  180. package/src/WAUSync/USyncUser.js +30 -0
  181. package/src/WAUSync/index.d.ts +3 -0
  182. package/src/WAUSync/index.js +23 -0
  183. package/src/index.d.ts +13 -0
  184. package/src/index.js +33 -0
@@ -0,0 +1,70 @@
1
+ "use strict"
2
+
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod }
5
+ }
6
+
7
+ Object.defineProperty(exports, "__esModule", { value: true })
8
+
9
+ const events_1 = __importDefault(require("events"))
10
+ const fs_1 = require("fs")
11
+ const promises_1 = require("fs/promises")
12
+ const readline_1 = require("readline")
13
+ const generics_1 = require("./generics")
14
+ const make_mutex_1 = require("./make-mutex")
15
+
16
+ /**
17
+ * Captures events from a baileys event emitter & stores them in a file
18
+ * @param ev The event emitter to read events from
19
+ * @param filename File to save to
20
+ */
21
+ const captureEventStream = (ev, filename) => {
22
+ const oldEmit = ev.emit
23
+ // write mutex so data is appended in order
24
+ const writeMutex = make_mutex_1.makeMutex()
25
+ // monkey patch eventemitter to capture all events
26
+ ev.emit = function (...args) {
27
+ const content = JSON.stringify({ timestamp: Date.now(), event: args[0], data: args[1] }) + '\n'
28
+ const result = oldEmit.apply(ev, args)
29
+ writeMutex.mutex(async () => {
30
+ await promises_1.writeFile(filename, content, { flag: 'a' })
31
+ })
32
+ return result
33
+ }
34
+ }
35
+
36
+ /**
37
+ * Read event file and emit events from there
38
+ * @param filename filename containing event data
39
+ * @param delayIntervalMs delay between each event emit
40
+ */
41
+ const readAndEmitEventStream = (filename, delayIntervalMs = 0) => {
42
+ const ev = new events_1.default()
43
+ const fireEvents = async () => {
44
+ // from: https://stackoverflow.com/questions/6156501/read-a-file-one-line-at-a-time-in-node-js
45
+ const fileStream = fs_1.createReadStream(filename)
46
+ const rl = readline_1.createInterface({
47
+ input: fileStream,
48
+ crlfDelay: Infinity
49
+ })
50
+ // Note: we use the crlfDelay option to recognize all instances of CR LF
51
+ // ('\r\n') in input.txt as a single line break.
52
+ for await (const line of rl) {
53
+ if (line) {
54
+ const { event, data } = JSON.parse(line)
55
+ ev.emit(event, data)
56
+ delayIntervalMs && await generics_1.delay(delayIntervalMs)
57
+ }
58
+ }
59
+ fileStream.close()
60
+ }
61
+ return {
62
+ ev,
63
+ task: fireEvents()
64
+ }
65
+ }
66
+
67
+ module.exports = {
68
+ captureEventStream,
69
+ readAndEmitEventStream
70
+ }
@@ -0,0 +1,29 @@
1
+ import { CatalogCollection, OrderDetails, Product, ProductCreate, ProductUpdate, WAMediaUpload, WAMediaUploadFunction } from '../Types'
2
+ import { BinaryNode } from '../WABinary'
3
+
4
+ export declare const parseCatalogNode: (node: BinaryNode) => {
5
+ products: Product[]
6
+ nextPageCursor: string | undefined
7
+ }
8
+
9
+ export declare const parseCollectionsNode: (node: BinaryNode) => {
10
+ collections: CatalogCollection[]
11
+ }
12
+
13
+ export declare const parseOrderDetailsNode: (node: BinaryNode) => OrderDetails
14
+
15
+ export declare const toProductNode: (productId: string | undefined, product: ProductCreate | ProductUpdate) => BinaryNode
16
+
17
+ export declare const parseProductNode: (productNode: BinaryNode) => Product
18
+
19
+ /**
20
+ * Uploads images not already uploaded to WA's servers
21
+ */
22
+ export declare function uploadingNecessaryImagesOfProduct<T extends ProductUpdate | ProductCreate>(product: T, waUploadToServer: WAMediaUploadFunction, timeoutMs?: number): Promise<T>
23
+
24
+ /**
25
+ * Uploads images not already uploaded to WA's servers
26
+ */
27
+ export declare const uploadingNecessaryImages: (images: WAMediaUpload[], waUploadToServer: WAMediaUploadFunction, timeoutMs?: number) => Promise<{
28
+ url: string
29
+ }[]>
@@ -0,0 +1,247 @@
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const boom_1 = require("@hapi/boom")
6
+ const crypto_1 = require("crypto")
7
+ const WABinary_1 = require("../WABinary")
8
+ const messages_media_1 = require("./messages-media")
9
+
10
+ const parseCatalogNode = (node) => {
11
+ const catalogNode = WABinary_1.getBinaryNodeChild(node, 'product_catalog')
12
+ const products = WABinary_1.getBinaryNodeChildren(catalogNode, 'product').map(parseProductNode)
13
+ const paging = WABinary_1.getBinaryNodeChild(catalogNode, 'paging')
14
+ return {
15
+ products,
16
+ nextPageCursor: paging
17
+ ? WABinary_1.getBinaryNodeChildString(paging, 'after')
18
+ : undefined
19
+ }
20
+ }
21
+
22
+ const parseCollectionsNode = (node) => {
23
+ const collectionsNode = WABinary_1.getBinaryNodeChild(node, 'collections')
24
+ const collections = WABinary_1.getBinaryNodeChildren(collectionsNode, 'collection').map(collectionNode => {
25
+ const id = WABinary_1.getBinaryNodeChildString(collectionNode, 'id')
26
+ const name = WABinary_1.getBinaryNodeChildString(collectionNode, 'name')
27
+ const products = WABinary_1.getBinaryNodeChildren(collectionNode, 'product').map(parseProductNode)
28
+ return {
29
+ id,
30
+ name,
31
+ products,
32
+ status: parseStatusInfo(collectionNode)
33
+ }
34
+ })
35
+ return {
36
+ collections
37
+ }
38
+ }
39
+
40
+ const parseOrderDetailsNode = (node) => {
41
+ const orderNode = WABinary_1.getBinaryNodeChild(node, 'order')
42
+ const products = WABinary_1.getBinaryNodeChildren(orderNode, 'product').map(productNode => {
43
+ const imageNode = WABinary_1.getBinaryNodeChild(productNode, 'image')
44
+ return {
45
+ id: WABinary_1.getBinaryNodeChildString(productNode, 'id'),
46
+ name: WABinary_1.getBinaryNodeChildString(productNode, 'name'),
47
+ imageUrl: WABinary_1.getBinaryNodeChildString(imageNode, 'url'),
48
+ price: +WABinary_1.getBinaryNodeChildString(productNode, 'price'),
49
+ currency: WABinary_1.getBinaryNodeChildString(productNode, 'currency'),
50
+ quantity: +WABinary_1.getBinaryNodeChildString(productNode, 'quantity')
51
+ }
52
+ })
53
+ const priceNode = WABinary_1.getBinaryNodeChild(orderNode, 'price')
54
+ const orderDetails = {
55
+ price: {
56
+ total: +WABinary_1.getBinaryNodeChildString(priceNode, 'total'),
57
+ currency: WABinary_1.getBinaryNodeChildString(priceNode, 'currency'),
58
+ },
59
+ products
60
+ }
61
+ return orderDetails
62
+ }
63
+
64
+ const toProductNode = (productId, product) => {
65
+ const attrs = {}
66
+ const content = []
67
+ if (typeof productId !== 'undefined') {
68
+ content.push({
69
+ tag: 'id',
70
+ attrs: {},
71
+ content: Buffer.from(productId)
72
+ })
73
+ }
74
+ if (typeof product.name !== 'undefined') {
75
+ content.push({
76
+ tag: 'name',
77
+ attrs: {},
78
+ content: Buffer.from(product.name)
79
+ })
80
+ }
81
+ if (typeof product.description !== 'undefined') {
82
+ content.push({
83
+ tag: 'description',
84
+ attrs: {},
85
+ content: Buffer.from(product.description)
86
+ })
87
+ }
88
+ if (typeof product.retailerId !== 'undefined') {
89
+ content.push({
90
+ tag: 'retailer_id',
91
+ attrs: {},
92
+ content: Buffer.from(product.retailerId)
93
+ })
94
+ }
95
+ if (product.images.length) {
96
+ content.push({
97
+ tag: 'media',
98
+ attrs: {},
99
+ content: product.images.map(img => {
100
+ if (!('url' in img)) {
101
+ throw new boom_1.Boom('Expected img for product to already be uploaded', { statusCode: 400 })
102
+ }
103
+ return {
104
+ tag: 'image',
105
+ attrs: {},
106
+ content: [
107
+ {
108
+ tag: 'url',
109
+ attrs: {},
110
+ content: Buffer.from(img.url.toString())
111
+ }
112
+ ]
113
+ }
114
+ })
115
+ })
116
+ }
117
+ if (typeof product.price !== 'undefined') {
118
+ content.push({
119
+ tag: 'price',
120
+ attrs: {},
121
+ content: Buffer.from(product.price.toString())
122
+ })
123
+ }
124
+ if (typeof product.currency !== 'undefined') {
125
+ content.push({
126
+ tag: 'currency',
127
+ attrs: {},
128
+ content: Buffer.from(product.currency)
129
+ })
130
+ }
131
+ if ('originCountryCode' in product) {
132
+ if (typeof product.originCountryCode === 'undefined') {
133
+ attrs['compliance_category'] = 'COUNTRY_ORIGIN_EXEMPT'
134
+ }
135
+ else {
136
+ content.push({
137
+ tag: 'compliance_info',
138
+ attrs: {},
139
+ content: [
140
+ {
141
+ tag: 'country_code_origin',
142
+ attrs: {},
143
+ content: Buffer.from(product.originCountryCode)
144
+ }
145
+ ]
146
+ })
147
+ }
148
+ }
149
+ if (typeof product.isHidden !== 'undefined') {
150
+ attrs['is_hidden'] = product.isHidden.toString()
151
+ }
152
+ const node = {
153
+ tag: 'product',
154
+ attrs,
155
+ content
156
+ }
157
+ return node
158
+ }
159
+
160
+ const parseProductNode = (productNode) => {
161
+ const isHidden = productNode.attrs.is_hidden === 'true'
162
+ const id = WABinary_1.getBinaryNodeChildString(productNode, 'id')
163
+ const mediaNode = WABinary_1.getBinaryNodeChild(productNode, 'media')
164
+ const statusInfoNode = WABinary_1.getBinaryNodeChild(productNode, 'status_info')
165
+ const product = {
166
+ id,
167
+ imageUrls: parseImageUrls(mediaNode),
168
+ reviewStatus: {
169
+ whatsapp: WABinary_1.getBinaryNodeChildString(statusInfoNode, 'status'),
170
+ },
171
+ availability: 'in stock',
172
+ name: WABinary_1.getBinaryNodeChildString(productNode, 'name'),
173
+ retailerId: WABinary_1.getBinaryNodeChildString(productNode, 'retailer_id'),
174
+ url: WABinary_1.getBinaryNodeChildString(productNode, 'url'),
175
+ description: WABinary_1.getBinaryNodeChildString(productNode, 'description'),
176
+ price: +WABinary_1.getBinaryNodeChildString(productNode, 'price'),
177
+ currency: WABinary_1.getBinaryNodeChildString(productNode, 'currency'),
178
+ isHidden,
179
+ }
180
+ return product
181
+ }
182
+
183
+ /**
184
+ * Uploads images not already uploaded to WA's servers
185
+ */
186
+ async function uploadingNecessaryImagesOfProduct(product, waUploadToServer, timeoutMs = 30000) {
187
+ product = {
188
+ ...product,
189
+ images: product.images ? await uploadingNecessaryImages(product.images, waUploadToServer, timeoutMs) : product.images
190
+ }
191
+ return product
192
+ }
193
+
194
+ /**
195
+ * Uploads images not already uploaded to WA's servers
196
+ */
197
+ const uploadingNecessaryImages = async (images, waUploadToServer, timeoutMs = 30000) => {
198
+ const results = await Promise.all(images.map(async (img) => {
199
+ if ('url' in img) {
200
+ const url = img.url.toString()
201
+ if (url.includes('.whatsapp.net')) {
202
+ return { url }
203
+ }
204
+ }
205
+ const { stream } = await messages_media_1.getStream(img)
206
+ const hasher = crypto_1.createHash('sha256')
207
+ const contentBlocks = []
208
+ for await (const block of stream) {
209
+ hasher.update(block)
210
+ contentBlocks.push(block)
211
+ }
212
+ const sha = hasher.digest('base64')
213
+ const { directPath } = await waUploadToServer(messages_media_1.toReadable(Buffer.concat(contentBlocks)), {
214
+ mediaType: 'product-catalog-image',
215
+ fileEncSha256B64: sha,
216
+ timeoutMs
217
+ })
218
+ return { url: messages_media_1.getUrlFromDirectPath(directPath) }
219
+ }))
220
+ return results
221
+ }
222
+
223
+ const parseImageUrls = (mediaNode) => {
224
+ const imgNode = WABinary_1.getBinaryNodeChild(mediaNode, 'image')
225
+ return {
226
+ requested: WABinary_1.getBinaryNodeChildString(imgNode, 'request_image_url'),
227
+ original: WABinary_1.getBinaryNodeChildString(imgNode, 'original_image_url')
228
+ }
229
+ }
230
+
231
+ const parseStatusInfo = (mediaNode) => {
232
+ const node = WABinary_1.getBinaryNodeChild(mediaNode, 'status_info')
233
+ return {
234
+ status: WABinary_1.getBinaryNodeChildString(node, 'status'),
235
+ canAppeal: WABinary_1.getBinaryNodeChildString(node, 'can_appeal') === 'true',
236
+ }
237
+ }
238
+
239
+ module.exports = {
240
+ parseCatalogNode,
241
+ parseCollectionsNode,
242
+ parseOrderDetailsNode,
243
+ toProductNode,
244
+ parseProductNode,
245
+ uploadingNecessaryImagesOfProduct,
246
+ uploadingNecessaryImages
247
+ }
@@ -0,0 +1,82 @@
1
+ import { AxiosRequestConfig } from 'axios'
2
+ import { proto } from '../../WAProto'
3
+ import { BaileysEventEmitter, ChatModification, ChatMutation, Contact, InitialAppStateSyncOptions, LTHashState, WAPatchCreate, WAPatchName } from '../Types'
4
+ import { BinaryNode } from '../WABinary'
5
+ import { ILogger } from './logger'
6
+
7
+ type FetchAppStateSyncKey = (keyId: string) => Promise<proto.Message.IAppStateSyncKeyData | null | undefined>
8
+
9
+ export type ChatMutationMap = {
10
+ [index: string]: ChatMutation
11
+ }
12
+
13
+ export declare const newLTHashState: () => LTHashState
14
+
15
+ export declare const encodeSyncdPatch: ({ type, index, syncAction, apiVersion, operation }: WAPatchCreate, myAppStateKeyId: string, state: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey) => Promise<{
16
+ patch: proto.ISyncdPatch
17
+ state: LTHashState
18
+ }>
19
+
20
+ export declare const decodeSyncdMutations: (msgMutations: (proto.ISyncdMutation | proto.ISyncdRecord)[], initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
21
+ hash: Buffer
22
+ indexValueMap: {
23
+ [indexMacBase64: string]: {
24
+ valueMac: Uint8Array | Buffer
25
+ }
26
+ }
27
+ }>
28
+
29
+ export declare const decodeSyncdPatch: (msg: proto.ISyncdPatch, name: WAPatchName, initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
30
+ hash: Buffer
31
+ indexValueMap: {
32
+ [indexMacBase64: string]: {
33
+ valueMac: Uint8Array | Buffer
34
+ }
35
+ }
36
+ }>
37
+
38
+ export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosRequestConfig<{}>) => Promise<{
39
+ critical_block: {
40
+ patches: proto.ISyncdPatch[]
41
+ hasMorePatches: boolean
42
+ snapshot?: proto.ISyncdSnapshot | undefined
43
+ }
44
+ critical_unblock_low: {
45
+ patches: proto.ISyncdPatch[]
46
+ hasMorePatches: boolean
47
+ snapshot?: proto.ISyncdSnapshot | undefined
48
+ }
49
+ regular_high: {
50
+ patches: proto.ISyncdPatch[]
51
+ hasMorePatches: boolean
52
+ snapshot?: proto.ISyncdSnapshot | undefined
53
+ }
54
+ regular_low: {
55
+ patches: proto.ISyncdPatch[]
56
+ hasMorePatches: boolean
57
+ snapshot?: proto.ISyncdSnapshot | undefined
58
+ }
59
+ regular: {
60
+ patches: proto.ISyncdPatch[]
61
+ hasMorePatches: boolean
62
+ snapshot?: proto.ISyncdSnapshot | undefined
63
+ }
64
+ }>
65
+
66
+ export declare const downloadExternalBlob: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<{}>) => Promise<Buffer>
67
+ export declare const downloadExternalPatch: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<{}>) => Promise<proto.SyncdMutations>
68
+ export declare const decodeSyncdSnapshot: (name: WAPatchName, snapshot: proto.ISyncdSnapshot, getAppStateSyncKey: FetchAppStateSyncKey, minimumVersionNumber: number | undefined, validateMacs?: boolean) => Promise<{
69
+ state: LTHashState
70
+ mutationMap: ChatMutationMap
71
+ }>
72
+
73
+ export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatch[], initial: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, options: AxiosRequestConfig<{}>, minimumVersionNumber?: number, logger?: ILogger, validateMacs?: boolean) => Promise<{
74
+ state: LTHashState
75
+ mutationMap: ChatMutationMap
76
+ }>
77
+
78
+ export declare const chatModificationToAppPatch: (mod: ChatModification, jid: string) => WAPatchCreate
79
+
80
+ export declare const processSyncAction: (syncAction: ChatMutation, ev: BaileysEventEmitter, me: Contact, initialSyncOpts?: InitialAppStateSyncOptions, logger?: ILogger) => void
81
+
82
+ export {}