lordceaser-baileys 2.0.11 → 2.0.13

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 (173) hide show
  1. package/package.json +2 -5
  2. package/lib/Defaults/baileys-version.json +0 -3
  3. package/lib/Defaults/index.d.ts +0 -284
  4. package/lib/Defaults/index.js +0 -121
  5. package/lib/Defaults/phonenumber-mcc.json +0 -223
  6. package/lib/Signal/libsignal.d.ts +0 -4
  7. package/lib/Signal/libsignal.js +0 -162
  8. package/lib/Socket/Client/abstract-socket-client.d.ts +0 -15
  9. package/lib/Socket/Client/abstract-socket-client.js +0 -13
  10. package/lib/Socket/Client/index.d.ts +0 -2
  11. package/lib/Socket/Client/index.js +0 -22
  12. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -12
  13. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  14. package/lib/Socket/Client/types.d.ts +0 -16
  15. package/lib/Socket/Client/types.js +0 -18
  16. package/lib/Socket/Client/web-socket-client.js +0 -62
  17. package/lib/Socket/Client/websocket.d.ts +0 -13
  18. package/lib/Socket/Client/websocket.js +0 -62
  19. package/lib/Socket/business.d.ts +0 -182
  20. package/lib/Socket/business.js +0 -268
  21. package/lib/Socket/chats.d.ts +0 -96
  22. package/lib/Socket/chats.js +0 -1026
  23. package/lib/Socket/groups.d.ts +0 -130
  24. package/lib/Socket/groups.js +0 -338
  25. package/lib/Socket/index.d.ts +0 -185
  26. package/lib/Socket/index.js +0 -14
  27. package/lib/Socket/messages-recv.d.ts +0 -171
  28. package/lib/Socket/messages-recv.js +0 -1182
  29. package/lib/Socket/messages-send.d.ts +0 -162
  30. package/lib/Socket/messages-send.js +0 -1006
  31. package/lib/Socket/newsletter.d.ts +0 -142
  32. package/lib/Socket/newsletter.js +0 -256
  33. package/lib/Socket/registration.d.ts +0 -264
  34. package/lib/Socket/registration.js +0 -166
  35. package/lib/Socket/socket.d.ts +0 -45
  36. package/lib/Socket/socket.js +0 -751
  37. package/lib/Socket/socket.js.bak +0 -751
  38. package/lib/Socket/usync.d.ts +0 -37
  39. package/lib/Socket/usync.js +0 -83
  40. package/lib/Store/index.d.ts +0 -4
  41. package/lib/Store/index.js +0 -24
  42. package/lib/Store/make-cache-manager-store.d.ts +0 -14
  43. package/lib/Store/make-cache-manager-store.js +0 -90
  44. package/lib/Store/make-in-memory-store.d.ts +0 -123
  45. package/lib/Store/make-in-memory-store.js +0 -429
  46. package/lib/Store/make-ordered-dictionary.d.ts +0 -12
  47. package/lib/Store/make-ordered-dictionary.js +0 -86
  48. package/lib/Store/object-repository.d.ts +0 -10
  49. package/lib/Store/object-repository.js +0 -31
  50. package/lib/Types/Auth.d.ts +0 -120
  51. package/lib/Types/Auth.js +0 -3
  52. package/lib/Types/Call.d.ts +0 -14
  53. package/lib/Types/Call.js +0 -3
  54. package/lib/Types/Chat.d.ts +0 -134
  55. package/lib/Types/Chat.js +0 -9
  56. package/lib/Types/Contact.d.ts +0 -25
  57. package/lib/Types/Contact.js +0 -3
  58. package/lib/Types/Events.d.ts +0 -212
  59. package/lib/Types/Events.js +0 -3
  60. package/lib/Types/GroupMetadata.d.ts +0 -64
  61. package/lib/Types/GroupMetadata.js +0 -3
  62. package/lib/Types/Label.d.ts +0 -48
  63. package/lib/Types/Label.js +0 -31
  64. package/lib/Types/LabelAssociation.d.ts +0 -35
  65. package/lib/Types/LabelAssociation.js +0 -13
  66. package/lib/Types/Message.d.ts +0 -459
  67. package/lib/Types/Message.js +0 -13
  68. package/lib/Types/Newsletter.d.ts +0 -107
  69. package/lib/Types/Newsletter.js +0 -38
  70. package/lib/Types/Product.d.ts +0 -92
  71. package/lib/Types/Product.js +0 -3
  72. package/lib/Types/Signal.d.ts +0 -68
  73. package/lib/Types/Signal.js +0 -3
  74. package/lib/Types/Socket.d.ts +0 -120
  75. package/lib/Types/Socket.js +0 -3
  76. package/lib/Types/State.d.ts +0 -29
  77. package/lib/Types/State.js +0 -3
  78. package/lib/Types/USync.d.ts +0 -26
  79. package/lib/Types/USync.js +0 -3
  80. package/lib/Types/index.d.ts +0 -78
  81. package/lib/Types/index.js +0 -47
  82. package/lib/Utils/auth-utils.d.ts +0 -21
  83. package/lib/Utils/auth-utils.js +0 -205
  84. package/lib/Utils/baileys-event-stream.d.ts +0 -18
  85. package/lib/Utils/baileys-event-stream.js +0 -70
  86. package/lib/Utils/business.d.ts +0 -29
  87. package/lib/Utils/business.js +0 -247
  88. package/lib/Utils/chat-utils.d.ts +0 -82
  89. package/lib/Utils/chat-utils.js +0 -774
  90. package/lib/Utils/crypto.d.ts +0 -56
  91. package/lib/Utils/crypto.js +0 -179
  92. package/lib/Utils/decode-wa-message.d.ts +0 -41
  93. package/lib/Utils/decode-wa-message.js +0 -236
  94. package/lib/Utils/event-buffer.d.ts +0 -39
  95. package/lib/Utils/event-buffer.js +0 -548
  96. package/lib/Utils/generics.d.ts +0 -129
  97. package/lib/Utils/generics.js +0 -485
  98. package/lib/Utils/history.d.ts +0 -23
  99. package/lib/Utils/history.js +0 -100
  100. package/lib/Utils/index.d.ts +0 -20
  101. package/lib/Utils/index.js +0 -40
  102. package/lib/Utils/link-preview.d.ts +0 -23
  103. package/lib/Utils/link-preview.js +0 -120
  104. package/lib/Utils/logger.d.ts +0 -13
  105. package/lib/Utils/logger.js +0 -7
  106. package/lib/Utils/lt-hash.d.ts +0 -14
  107. package/lib/Utils/lt-hash.js +0 -58
  108. package/lib/Utils/make-mutex.d.ts +0 -9
  109. package/lib/Utils/make-mutex.js +0 -49
  110. package/lib/Utils/messages-media.d.ts +0 -129
  111. package/lib/Utils/messages-media.js +0 -782
  112. package/lib/Utils/messages.d.ts +0 -103
  113. package/lib/Utils/messages.js +0 -1631
  114. package/lib/Utils/noise-handler.d.ts +0 -20
  115. package/lib/Utils/noise-handler.js +0 -155
  116. package/lib/Utils/process-message.d.ts +0 -49
  117. package/lib/Utils/process-message.js +0 -387
  118. package/lib/Utils/signal.d.ts +0 -42
  119. package/lib/Utils/signal.js +0 -166
  120. package/lib/Utils/use-mongo-file-auth-state.d.ts +0 -6
  121. package/lib/Utils/use-mongo-file-auth-state.js +0 -84
  122. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
  123. package/lib/Utils/use-multi-file-auth-state.js +0 -131
  124. package/lib/Utils/use-single-file-auth-state.d.ts +0 -13
  125. package/lib/Utils/use-single-file-auth-state.js +0 -80
  126. package/lib/Utils/use-sql-file-auth-state.d.ts +0 -6
  127. package/lib/Utils/use-sql-file-auth-state.js +0 -143
  128. package/lib/Utils/validate-connection.d.ts +0 -13
  129. package/lib/Utils/validate-connection.js +0 -186
  130. package/lib/WABinary/constants.d.ts +0 -30
  131. package/lib/WABinary/constants.js +0 -53
  132. package/lib/WABinary/decode.d.ts +0 -9
  133. package/lib/WABinary/decode.js +0 -288
  134. package/lib/WABinary/encode.d.ts +0 -3
  135. package/lib/WABinary/encode.js +0 -256
  136. package/lib/WABinary/generic-utils.d.ts +0 -28
  137. package/lib/WABinary/generic-utils.js +0 -150
  138. package/lib/WABinary/index.d.ts +0 -5
  139. package/lib/WABinary/index.js +0 -25
  140. package/lib/WABinary/jid-utils.d.ts +0 -53
  141. package/lib/WABinary/jid-utils.js +0 -92
  142. package/lib/WABinary/types.d.ts +0 -22
  143. package/lib/WABinary/types.js +0 -3
  144. package/lib/WAM/BinaryInfo.d.ts +0 -16
  145. package/lib/WAM/BinaryInfo.js +0 -17
  146. package/lib/WAM/constants.d.ts +0 -47
  147. package/lib/WAM/constants.js +0 -15371
  148. package/lib/WAM/encode.d.ts +0 -3
  149. package/lib/WAM/encode.js +0 -165
  150. package/lib/WAM/index.d.ts +0 -3
  151. package/lib/WAM/index.js +0 -23
  152. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +0 -28
  153. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +0 -69
  154. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -10
  155. package/lib/WAUSync/Protocols/USyncContactProtocol.js +0 -36
  156. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -26
  157. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +0 -62
  158. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -14
  159. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -35
  160. package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +0 -9
  161. package/lib/WAUSync/Protocols/USyncLIDProtocol.js +0 -30
  162. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -14
  163. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +0 -46
  164. package/lib/WAUSync/Protocols/index.d.ts +0 -6
  165. package/lib/WAUSync/Protocols/index.js +0 -26
  166. package/lib/WAUSync/USyncQuery.d.ts +0 -31
  167. package/lib/WAUSync/USyncQuery.js +0 -92
  168. package/lib/WAUSync/USyncUser.d.ts +0 -12
  169. package/lib/WAUSync/USyncUser.js +0 -30
  170. package/lib/WAUSync/index.d.ts +0 -3
  171. package/lib/WAUSync/index.js +0 -23
  172. package/lib/index.d.ts +0 -13
  173. package/lib/index.js +0 -33
@@ -1,70 +0,0 @@
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
- }
@@ -1,29 +0,0 @@
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
- }[]>
@@ -1,247 +0,0 @@
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
- }
@@ -1,82 +0,0 @@
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 {}