@pontalabs/baileys 1.0.6 → 1.0.7

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 (185) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +839 -267
  3. package/WAProto/GenerateStatics.sh +4 -3
  4. package/WAProto/WAProto.proto +511 -1215
  5. package/WAProto/index.d.ts +55 -14017
  6. package/WAProto/index.js +29 -97689
  7. package/lib/Defaults/index.d.ts +74 -72
  8. package/lib/Defaults/index.js +108 -94
  9. package/lib/Signal/Group/ciphertext-message.d.ts +7 -8
  10. package/lib/Signal/Group/ciphertext-message.js +16 -9
  11. package/lib/Signal/Group/group-session-builder.d.ts +13 -11
  12. package/lib/Signal/Group/group-session-builder.js +61 -19
  13. package/lib/Signal/Group/group_cipher.d.ts +16 -14
  14. package/lib/Signal/Group/group_cipher.js +70 -41
  15. package/lib/Signal/Group/index.d.ts +11 -12
  16. package/lib/Signal/Group/index.js +61 -12
  17. package/lib/Signal/Group/keyhelper.d.ts +14 -9
  18. package/lib/Signal/Group/keyhelper.js +58 -10
  19. package/lib/Signal/Group/sender-chain-key.d.ts +13 -13
  20. package/lib/Signal/Group/sender-chain-key.js +34 -13
  21. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -16
  22. package/lib/Signal/Group/sender-key-distribution-message.js +36 -28
  23. package/lib/Signal/Group/sender-key-message.d.ts +18 -18
  24. package/lib/Signal/Group/sender-key-message.js +45 -38
  25. package/lib/Signal/Group/sender-key-name.d.ts +15 -14
  26. package/lib/Signal/Group/sender-key-name.js +31 -20
  27. package/lib/Signal/Group/sender-key-record.d.ts +25 -24
  28. package/lib/Signal/Group/sender-key-record.js +35 -18
  29. package/lib/Signal/Group/sender-key-state.d.ts +34 -29
  30. package/lib/Signal/Group/sender-key-state.js +100 -37
  31. package/lib/Signal/Group/sender-message-key.d.ts +10 -11
  32. package/lib/Signal/Group/sender-message-key.js +22 -15
  33. package/lib/Signal/libsignal.d.ts +8 -5
  34. package/lib/Signal/libsignal.js +142 -288
  35. package/lib/Signal/lid-mapping.d.ts +28 -23
  36. package/lib/Signal/lid-mapping.js +184 -277
  37. package/lib/Socket/Client/index.d.ts +2 -3
  38. package/lib/Socket/Client/index.js +22 -3
  39. package/lib/Socket/Client/types.d.ts +15 -15
  40. package/lib/Socket/Client/types.js +15 -8
  41. package/lib/Socket/Client/websocket.d.ts +12 -12
  42. package/lib/Socket/Client/websocket.js +37 -29
  43. package/lib/Socket/business.d.ts +178 -208
  44. package/lib/Socket/business.js +127 -91
  45. package/lib/Socket/chats.d.ts +93 -120
  46. package/lib/Socket/chats.js +652 -727
  47. package/lib/Socket/community.js +10 -2
  48. package/lib/Socket/groups.d.ts +111 -143
  49. package/lib/Socket/groups.js +186 -165
  50. package/lib/Socket/index.d.ts +183 -252
  51. package/lib/Socket/index.js +18 -38
  52. package/lib/Socket/messages-recv.d.ts +167 -196
  53. package/lib/Socket/messages-recv.js +1567 -1443
  54. package/lib/Socket/messages-send.d.ts +158 -192
  55. package/lib/Socket/messages-send.js +1208 -1102
  56. package/lib/Socket/newsletter.d.ts +138 -163
  57. package/lib/Socket/newsletter.js +249 -153
  58. package/lib/Socket/socket.d.ts +36 -50
  59. package/lib/Socket/socket.js +820 -749
  60. package/lib/Store/index.d.ts +4 -4
  61. package/lib/Store/index.js +24 -4
  62. package/lib/Store/make-in-memory-store.d.ts +104 -44
  63. package/lib/Store/make-in-memory-store.js +213 -199
  64. package/lib/Store/make-ordered-dictionary.d.ts +12 -13
  65. package/lib/Store/make-ordered-dictionary.js +45 -38
  66. package/lib/Store/object-repository.d.ts +10 -11
  67. package/lib/Store/object-repository.js +16 -9
  68. package/lib/Types/Auth.d.ts +97 -93
  69. package/lib/Types/Auth.js +3 -2
  70. package/lib/Types/Bussines.js +3 -2
  71. package/lib/Types/Call.d.ts +13 -14
  72. package/lib/Types/Call.js +3 -2
  73. package/lib/Types/Chat.d.ts +97 -78
  74. package/lib/Types/Chat.js +9 -8
  75. package/lib/Types/Contact.d.ts +9 -12
  76. package/lib/Types/Contact.js +3 -2
  77. package/lib/Types/Events.d.ts +176 -206
  78. package/lib/Types/Events.js +3 -2
  79. package/lib/Types/GroupMetadata.d.ts +48 -53
  80. package/lib/Types/GroupMetadata.js +3 -2
  81. package/lib/Types/Label.d.ts +14 -13
  82. package/lib/Types/Label.js +30 -24
  83. package/lib/Types/LabelAssociation.d.ts +20 -15
  84. package/lib/Types/LabelAssociation.js +12 -6
  85. package/lib/Types/Message.d.ts +412 -248
  86. package/lib/Types/Message.js +19 -17
  87. package/lib/Types/Product.d.ts +71 -58
  88. package/lib/Types/Product.js +3 -2
  89. package/lib/Types/Signal.d.ts +82 -71
  90. package/lib/Types/Signal.js +3 -2
  91. package/lib/Types/Socket.d.ts +81 -76
  92. package/lib/Types/Socket.js +3 -3
  93. package/lib/Types/State.d.ts +19 -75
  94. package/lib/Types/State.js +14 -56
  95. package/lib/Types/USync.d.ts +8 -8
  96. package/lib/Types/USync.js +3 -2
  97. package/lib/Types/index.d.ts +62 -47
  98. package/lib/Types/index.js +50 -26
  99. package/lib/Utils/auth-utils.d.ts +10 -13
  100. package/lib/Utils/auth-utils.js +472 -213
  101. package/lib/Utils/business.d.ts +20 -14
  102. package/lib/Utils/business.js +134 -110
  103. package/lib/Utils/chat-utils.d.ts +70 -88
  104. package/lib/Utils/chat-utils.js +403 -466
  105. package/lib/Utils/crypto.d.ts +46 -27
  106. package/lib/Utils/crypto.js +188 -117
  107. package/lib/Utils/decode-wa-message.d.ts +45 -58
  108. package/lib/Utils/decode-wa-message.js +311 -212
  109. package/lib/Utils/event-buffer.d.ts +17 -14
  110. package/lib/Utils/event-buffer.js +296 -321
  111. package/lib/Utils/generics.d.ts +92 -66
  112. package/lib/Utils/generics.js +436 -270
  113. package/lib/Utils/history.d.ts +23 -24
  114. package/lib/Utils/history.js +76 -106
  115. package/lib/Utils/index.d.ts +21 -24
  116. package/lib/Utils/index.js +41 -24
  117. package/lib/Utils/link-preview.d.ts +14 -12
  118. package/lib/Utils/link-preview.js +75 -40
  119. package/lib/Utils/logger.d.ts +11 -10
  120. package/lib/Utils/logger.js +7 -3
  121. package/lib/Utils/lt-hash.d.ts +14 -8
  122. package/lib/Utils/lt-hash.js +53 -3
  123. package/lib/Utils/make-mutex.d.ts +7 -7
  124. package/lib/Utils/make-mutex.js +44 -28
  125. package/lib/Utils/message-retry-manager.d.ts +88 -115
  126. package/lib/Utils/message-retry-manager.js +160 -265
  127. package/lib/Utils/messages-media.d.ts +107 -105
  128. package/lib/Utils/messages-media.js +619 -548
  129. package/lib/Utils/messages.d.ts +66 -52
  130. package/lib/Utils/messages.js +1558 -1730
  131. package/lib/Utils/noise-handler.d.ts +18 -18
  132. package/lib/Utils/noise-handler.js +130 -176
  133. package/lib/Utils/process-message.d.ts +32 -43
  134. package/lib/Utils/process-message.js +282 -484
  135. package/lib/Utils/rich-message-utils.js +724 -1220
  136. package/lib/Utils/signal.d.ts +32 -37
  137. package/lib/Utils/signal.js +105 -140
  138. package/lib/Utils/use-multi-file-auth-state.d.ts +5 -5
  139. package/lib/Utils/use-multi-file-auth-state.js +120 -70
  140. package/lib/Utils/use-single-file-auth-state.d.ts +13 -11
  141. package/lib/Utils/use-single-file-auth-state.js +66 -92
  142. package/lib/Utils/validate-connection.d.ts +13 -11
  143. package/lib/Utils/validate-connection.js +113 -128
  144. package/lib/WABinary/constants.d.ts +27 -25
  145. package/lib/WABinary/constants.js +1292 -1451
  146. package/lib/WABinary/decode.d.ts +9 -7
  147. package/lib/WABinary/decode.js +189 -163
  148. package/lib/WABinary/encode.d.ts +3 -3
  149. package/lib/WABinary/encode.js +155 -110
  150. package/lib/WABinary/generic-utils.d.ts +27 -14
  151. package/lib/WABinary/generic-utils.js +105 -177
  152. package/lib/WABinary/index.d.ts +5 -6
  153. package/lib/WABinary/index.js +25 -6
  154. package/lib/WABinary/jid-utils.d.ts +54 -41
  155. package/lib/WABinary/jid-utils.js +152 -83
  156. package/lib/WABinary/types.d.ts +13 -10
  157. package/lib/WABinary/types.js +3 -2
  158. package/lib/WAM/BinaryInfo.d.ts +15 -8
  159. package/lib/WAM/BinaryInfo.js +14 -7
  160. package/lib/WAM/constants.d.ts +37 -30
  161. package/lib/WAM/constants.js +11983 -19465
  162. package/lib/WAM/encode.d.ts +3 -3
  163. package/lib/WAM/encode.js +109 -95
  164. package/lib/WAM/index.d.ts +3 -4
  165. package/lib/WAM/index.js +23 -4
  166. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -9
  167. package/lib/WAUSync/Protocols/USyncContactProtocol.js +21 -37
  168. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -19
  169. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +26 -18
  170. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -11
  171. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +20 -12
  172. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -11
  173. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +24 -16
  174. package/lib/WAUSync/Protocols/index.d.ts +6 -6
  175. package/lib/WAUSync/Protocols/index.js +26 -6
  176. package/lib/WAUSync/USyncQuery.d.ts +28 -27
  177. package/lib/WAUSync/USyncQuery.js +62 -68
  178. package/lib/WAUSync/USyncUser.d.ts +10 -15
  179. package/lib/WAUSync/USyncUser.js +19 -20
  180. package/lib/WAUSync/index.d.ts +3 -4
  181. package/lib/WAUSync/index.js +23 -4
  182. package/lib/index.d.ts +12 -11
  183. package/lib/index.js +39 -12
  184. package/package.json +42 -86
  185. package/engine-requirements.js +0 -10
@@ -1,58 +1,69 @@
1
- import { getRawMediaUploadData } from '../Utils/index.js';
2
- import { parseCatalogNode, parseCollectionsNode, parseOrderDetailsNode, parseProductNode, toProductNode, uploadingNecessaryImagesOfProduct } from '../Utils/business.js';
3
- import { jidNormalizedUser, S_WHATSAPP_NET } from '../WABinary/index.js';
4
- import { getBinaryNodeChild } from '../WABinary/generic-utils.js';
5
- import { makeMessagesRecvSocket } from './messages-recv.js';
6
- export const makeBusinessSocket = (config) => {
7
- const sock = makeMessagesRecvSocket(config);
8
- const { authState, query, waUploadToServer } = sock;
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const Utils_1 = require("../Utils")
6
+ const WABinary_1 = require("../WABinary")
7
+ const business_1 = require("../Utils/business")
8
+ const generic_utils_1 = require("../WABinary/generic-utils")
9
+ const messages_recv_1 = require("./messages-recv")
10
+
11
+ const makeBusinessSocket = (config) => {
12
+ const sock = messages_recv_1.makeMessagesRecvSocket(config)
13
+ const { authState, query, waUploadToServer } = sock
14
+
9
15
  const updateBussinesProfile = async (args) => {
10
- const node = [];
11
- const simpleFields = ['address', 'email', 'description'];
16
+ const node = []
17
+ const simpleFields = ['address', 'email', 'description']
18
+
12
19
  node.push(...simpleFields
13
- .filter(key => args[key] !== undefined && args[key] !== null)
20
+ .filter(key => args[key])
14
21
  .map(key => ({
15
22
  tag: key,
16
23
  attrs: {},
17
24
  content: args[key]
18
- })));
19
- if (args.websites !== undefined) {
25
+ })))
26
+
27
+ if (args.websites) {
28
+
20
29
  node.push(...args.websites.map(website => ({
21
30
  tag: 'website',
22
31
  attrs: {},
23
32
  content: website
24
- })));
33
+ })))
25
34
  }
26
- if (args.hours !== undefined) {
35
+
36
+ if (args.hours) {
37
+
27
38
  node.push({
28
39
  tag: 'business_hours',
29
40
  attrs: { timezone: args.hours.timezone },
30
- content: args.hours.days.map(dayConfig => {
41
+ content: args.hours.days.map(config => {
31
42
  const base = {
32
43
  tag: 'business_hours_config',
33
- attrs: {
34
- day_of_week: dayConfig.day,
35
- mode: dayConfig.mode
36
- }
37
- };
38
- if (dayConfig.mode === 'specific_hours') {
44
+ attrs: { day_of_week: config.day, mode: config.mode }
45
+ }
46
+
47
+ if (config.mode === 'specific_hours') {
39
48
  return {
40
49
  ...base,
41
50
  attrs: {
42
51
  ...base.attrs,
43
- open_time: dayConfig.openTimeInMinutes,
44
- close_time: dayConfig.closeTimeInMinutes
52
+ open_time: config.openTimeInMinutes,
53
+ close_time: config.closeTimeInMinutes
45
54
  }
46
- };
55
+ }
47
56
  }
48
- return base;
57
+
58
+ return base
49
59
  })
50
- });
60
+ })
51
61
  }
62
+
52
63
  const result = await query({
53
64
  tag: 'iq',
54
65
  attrs: {
55
- to: S_WHATSAPP_NET,
66
+ to: WABinary_1.S_WHATSAPP_NET,
56
67
  type: 'set',
57
68
  xmlns: 'w:biz'
58
69
  },
@@ -66,20 +77,24 @@ export const makeBusinessSocket = (config) => {
66
77
  content: node
67
78
  }
68
79
  ]
69
- });
70
- return result;
71
- };
80
+ })
81
+
82
+ return result
83
+ }
84
+
72
85
  const updateCoverPhoto = async (photo) => {
73
- const { fileSha256, filePath } = await getRawMediaUploadData(photo, 'biz-cover-photo');
74
- const fileSha256B64 = fileSha256.toString('base64');
86
+ const { fileSha256, filePath } = await Utils_1.getRawMediaUploadData(photo, 'biz-cover-photo')
87
+ const fileSha256B64 = fileSha256.toString('base64')
88
+
75
89
  const { meta_hmac, fbid, ts } = await waUploadToServer(filePath, {
76
90
  fileEncSha256B64: fileSha256B64,
77
91
  mediaType: 'biz-cover-photo'
78
- });
92
+ })
93
+
79
94
  await query({
80
95
  tag: 'iq',
81
96
  attrs: {
82
- to: S_WHATSAPP_NET,
97
+ to: WABinary_1.S_WHATSAPP_NET,
83
98
  type: 'set',
84
99
  xmlns: 'w:biz'
85
100
  },
@@ -98,14 +113,16 @@ export const makeBusinessSocket = (config) => {
98
113
  ]
99
114
  }
100
115
  ]
101
- });
102
- return fbid;
103
- };
116
+ })
117
+
118
+ return fbid
119
+ }
120
+
104
121
  const removeCoverPhoto = async (id) => {
105
122
  return await query({
106
123
  tag: 'iq',
107
124
  attrs: {
108
- to: S_WHATSAPP_NET,
125
+ to: WABinary_1.S_WHATSAPP_NET,
109
126
  type: 'set',
110
127
  xmlns: 'w:biz'
111
128
  },
@@ -124,11 +141,13 @@ export const makeBusinessSocket = (config) => {
124
141
  ]
125
142
  }
126
143
  ]
127
- });
128
- };
144
+ })
145
+ }
146
+
129
147
  const getCatalog = async ({ jid, limit, cursor }) => {
130
- jid = jid || authState.creds.me?.id;
131
- jid = jidNormalizedUser(jid);
148
+ jid = jid || authState.creds.me?.id
149
+ jid = WABinary_1.jidNormalizedUser(jid)
150
+
132
151
  const queryParamNodes = [
133
152
  {
134
153
  tag: 'limit',
@@ -144,19 +163,21 @@ export const makeBusinessSocket = (config) => {
144
163
  tag: 'height',
145
164
  attrs: {},
146
165
  content: Buffer.from('100')
147
- }
148
- ];
166
+ },
167
+ ]
168
+
149
169
  if (cursor) {
150
170
  queryParamNodes.push({
151
171
  tag: 'after',
152
172
  attrs: {},
153
173
  content: cursor
154
- });
174
+ })
155
175
  }
176
+
156
177
  const result = await query({
157
178
  tag: 'iq',
158
179
  attrs: {
159
- to: S_WHATSAPP_NET,
180
+ to: WABinary_1.S_WHATSAPP_NET,
160
181
  type: 'get',
161
182
  xmlns: 'w:biz:catalog'
162
183
  },
@@ -165,30 +186,33 @@ export const makeBusinessSocket = (config) => {
165
186
  tag: 'product_catalog',
166
187
  attrs: {
167
188
  jid,
168
- allow_shop_source: 'true'
189
+ 'allow_shop_source': 'true'
169
190
  },
170
191
  content: queryParamNodes
171
192
  }
172
193
  ]
173
- });
174
- return parseCatalogNode(result);
175
- };
194
+ })
195
+
196
+ return business_1.parseCatalogNode(result)
197
+ }
198
+
176
199
  const getCollections = async (jid, limit = 51) => {
177
- jid = jid || authState.creds.me?.id;
178
- jid = jidNormalizedUser(jid);
200
+ jid = jid || authState.creds.me?.id
201
+ jid = WABinary_1.jidNormalizedUser(jid)
202
+
179
203
  const result = await query({
180
204
  tag: 'iq',
181
205
  attrs: {
182
- to: S_WHATSAPP_NET,
206
+ to: WABinary_1.S_WHATSAPP_NET,
183
207
  type: 'get',
184
208
  xmlns: 'w:biz:catalog',
185
- smax_id: '35'
209
+ 'smax_id': '35'
186
210
  },
187
211
  content: [
188
212
  {
189
213
  tag: 'collections',
190
214
  attrs: {
191
- biz_jid: jid
215
+ 'biz_jid': jid,
192
216
  },
193
217
  content: [
194
218
  {
@@ -214,17 +238,19 @@ export const makeBusinessSocket = (config) => {
214
238
  ]
215
239
  }
216
240
  ]
217
- });
218
- return parseCollectionsNode(result);
219
- };
241
+ })
242
+
243
+ return business_1.parseCollectionsNode(result)
244
+ }
245
+
220
246
  const getOrderDetails = async (orderId, tokenBase64) => {
221
247
  const result = await query({
222
248
  tag: 'iq',
223
249
  attrs: {
224
- to: S_WHATSAPP_NET,
250
+ to: WABinary_1.S_WHATSAPP_NET,
225
251
  type: 'get',
226
252
  xmlns: 'fb:thrift_iq',
227
- smax_id: '5'
253
+ 'smax_id': '5'
228
254
  },
229
255
  content: [
230
256
  {
@@ -258,16 +284,19 @@ export const makeBusinessSocket = (config) => {
258
284
  ]
259
285
  }
260
286
  ]
261
- });
262
- return parseOrderDetailsNode(result);
263
- };
287
+ })
288
+
289
+ return business_1.parseOrderDetailsNode(result)
290
+ }
291
+
264
292
  const productUpdate = async (productId, update) => {
265
- update = await uploadingNecessaryImagesOfProduct(update, waUploadToServer);
266
- const editNode = toProductNode(productId, update);
293
+ update = await business_1.uploadingNecessaryImagesOfProduct(update, waUploadToServer)
294
+ const editNode = business_1.toProductNode(productId, update)
295
+
267
296
  const result = await query({
268
297
  tag: 'iq',
269
298
  attrs: {
270
- to: S_WHATSAPP_NET,
299
+ to: WABinary_1.S_WHATSAPP_NET,
271
300
  type: 'set',
272
301
  xmlns: 'w:biz:catalog'
273
302
  },
@@ -290,20 +319,22 @@ export const makeBusinessSocket = (config) => {
290
319
  ]
291
320
  }
292
321
  ]
293
- });
294
- const productCatalogEditNode = getBinaryNodeChild(result, 'product_catalog_edit');
295
- const productNode = getBinaryNodeChild(productCatalogEditNode, 'product');
296
- return parseProductNode(productNode);
297
- };
322
+ })
323
+ const productCatalogEditNode = generic_utils_1.getBinaryNodeChild(result, 'product_catalog_edit')
324
+ const productNode = generic_utils_1.getBinaryNodeChild(productCatalogEditNode, 'product')
325
+ return business_1.parseProductNode(productNode)
326
+ }
327
+
298
328
  const productCreate = async (create) => {
299
329
  // ensure isHidden is defined
300
- create.isHidden = !!create.isHidden;
301
- create = await uploadingNecessaryImagesOfProduct(create, waUploadToServer);
302
- const createNode = toProductNode(undefined, create);
330
+ create.isHidden = !!create.isHidden
331
+ create = await business_1.uploadingNecessaryImagesOfProduct(create, waUploadToServer)
332
+ const createNode = business_1.toProductNode(undefined, create)
333
+
303
334
  const result = await query({
304
335
  tag: 'iq',
305
336
  attrs: {
306
- to: S_WHATSAPP_NET,
337
+ to: WABinary_1.S_WHATSAPP_NET,
307
338
  type: 'set',
308
339
  xmlns: 'w:biz:catalog'
309
340
  },
@@ -326,16 +357,18 @@ export const makeBusinessSocket = (config) => {
326
357
  ]
327
358
  }
328
359
  ]
329
- });
330
- const productCatalogAddNode = getBinaryNodeChild(result, 'product_catalog_add');
331
- const productNode = getBinaryNodeChild(productCatalogAddNode, 'product');
332
- return parseProductNode(productNode);
333
- };
360
+ })
361
+ const productCatalogAddNode = generic_utils_1.getBinaryNodeChild(result, 'product_catalog_add')
362
+ const productNode = generic_utils_1.getBinaryNodeChild(productCatalogAddNode, 'product')
363
+
364
+ return business_1.parseProductNode(productNode)
365
+ }
366
+
334
367
  const productDelete = async (productIds) => {
335
368
  const result = await query({
336
369
  tag: 'iq',
337
370
  attrs: {
338
- to: S_WHATSAPP_NET,
371
+ to: WABinary_1.S_WHATSAPP_NET,
339
372
  type: 'set',
340
373
  xmlns: 'w:biz:catalog'
341
374
  },
@@ -356,12 +389,12 @@ export const makeBusinessSocket = (config) => {
356
389
  }))
357
390
  }
358
391
  ]
359
- });
360
- const productCatalogDelNode = getBinaryNodeChild(result, 'product_catalog_delete');
392
+ })
393
+ const productCatalogDelNode = generic_utils_1.getBinaryNodeChild(result, 'product_catalog_delete')
361
394
  return {
362
- deleted: +(productCatalogDelNode?.attrs.deleted_count || 0)
363
- };
364
- };
395
+ deleted: +(productCatalogDelNode?.attrs?.deleted_count || 0)
396
+ }
397
+ }
365
398
  return {
366
399
  ...sock,
367
400
  logger: config.logger,
@@ -370,10 +403,13 @@ export const makeBusinessSocket = (config) => {
370
403
  getCollections,
371
404
  productCreate,
372
405
  productDelete,
373
- productUpdate,
406
+ productUpdate,
374
407
  updateBussinesProfile,
375
408
  updateCoverPhoto,
376
409
  removeCoverPhoto
377
- };
378
- };
379
- //# sourceMappingURL=business.js.map
410
+ }
411
+ }
412
+
413
+ module.exports = {
414
+ makeBusinessSocket
415
+ }
@@ -1,124 +1,97 @@
1
- import { Boom } from '@hapi/boom';
2
- import { proto } from '../../WAProto/index.js';
3
- import type { BotListInfo, CacheStore, ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAMessage, WAPatchCreate, WAPresence, WAPrivacyCallValue, WAPrivacyGroupAddValue, WAPrivacyMessagesValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types/index.js';
4
- import type { QuickReplyAction } from '../Types/Bussines.js';
5
- import type { LabelActionBody } from '../Types/Label.js';
6
- import { type BinaryNode } from '../WABinary/index.js';
7
- import { USyncQuery } from '../WAUSync/index.js';
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 { QuickReplyAction } from '../Types/Bussines'
6
+ import { BinaryNode } from '../WABinary'
7
+ import { USyncQuery } from '../WAUSync'
8
+
8
9
  export declare const makeChatsSocket: (config: SocketConfig) => {
9
- serverProps: {
10
- /** AB prop 10518: gate tctoken on 1:1 messages. Default true (safe: avoids 463). */
11
- privacyTokenOn1to1: boolean;
12
- /** AB prop 9666: gate tctoken on profile picture IQs. WA Web default: true. */
13
- profilePicPrivacyToken: boolean;
14
- /** AB prop 14303: issue tctokens to LID instead of PN. WA Web default: false. */
15
- lidTrustedTokenIssueToLid: boolean;
16
- };
17
- createCallLink: (type: "audio" | "video", event?: {
18
- startTime: number;
19
- }, timeoutMs?: number) => Promise<string | undefined>;
20
- getBotListV2: () => Promise<BotListInfo[]>;
21
- messageMutex: {
22
- mutex<T>(code: () => Promise<T> | T): Promise<T>;
23
- };
24
- receiptMutex: {
25
- mutex<T>(code: () => Promise<T> | T): Promise<T>;
26
- };
27
- appStatePatchMutex: {
28
- mutex<T>(code: () => Promise<T> | T): Promise<T>;
29
- };
30
- notificationMutex: {
31
- mutex<T>(code: () => Promise<T> | T): Promise<T>;
32
- };
10
+ processingMutex: {
11
+ mutex<T>(code: () => T | Promise<T>): Promise<T>
12
+ }
33
13
  fetchPrivacySettings: (force?: boolean) => Promise<{
34
- [_: string]: string;
35
- }>;
36
- upsertMessage: (msg: WAMessage, type: MessageUpsertType) => Promise<void>;
37
- appPatch: (patchCreate: WAPatchCreate) => Promise<void>;
38
- sendPresenceUpdate: (type: WAPresence, toJid?: string) => Promise<void>;
39
- presenceSubscribe: (toJid: string) => Promise<void>;
40
- profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
41
- fetchBlocklist: () => Promise<(string | undefined)[]>;
42
- fetchStatus: (...jids: string[]) => Promise<import("../WAUSync/index.js").USyncQueryResultList[] | undefined>;
43
- fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync/index.js").USyncQueryResultList[] | undefined>;
44
- updateProfilePicture: (jid: string, content: WAMediaUpload, dimensions?: {
45
- width: number;
46
- height: number;
47
- }) => Promise<void>;
48
- removeProfilePicture: (jid: string) => Promise<void>;
49
- updateProfileStatus: (status: string) => Promise<void>;
50
- updateProfileName: (name: string) => Promise<void>;
51
- updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
52
- updateDisableLinkPreviewsPrivacy: (isPreviewsDisabled: boolean) => Promise<void>;
53
- updateCallPrivacy: (value: WAPrivacyCallValue) => Promise<void>;
54
- updateMessagesPrivacy: (value: WAPrivacyMessagesValue) => Promise<void>;
55
- updateLastSeenPrivacy: (value: WAPrivacyValue) => Promise<void>;
56
- updateOnlinePrivacy: (value: WAPrivacyOnlineValue) => Promise<void>;
57
- updateProfilePicturePrivacy: (value: WAPrivacyValue) => Promise<void>;
58
- updateStatusPrivacy: (value: WAPrivacyValue) => Promise<void>;
59
- updateReadReceiptsPrivacy: (value: WAReadReceiptsValue) => Promise<void>;
60
- updateGroupsAddPrivacy: (value: WAPrivacyGroupAddValue) => Promise<void>;
61
- updateDefaultDisappearingMode: (duration: number) => Promise<void>;
62
- getBusinessProfile: (jid: string) => Promise<WABusinessProfile | void>;
63
- resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
64
- chatModify: (mod: ChatModification, jid: string) => Promise<void>;
65
- cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
66
- addOrEditContact: (jid: string, contact: proto.SyncActionValue.IContactAction) => Promise<void>;
67
- removeContact: (jid: string) => Promise<void>;
68
- placeholderResendCache: CacheStore;
69
- addLabel: (jid: string, labels: LabelActionBody) => Promise<void>;
70
- addChatLabel: (jid: string, labelId: string) => Promise<void>;
71
- removeChatLabel: (jid: string, labelId: string) => Promise<void>;
72
- addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
73
- removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
14
+ [_: string]: string
15
+ }>
16
+ upsertMessage: (msg: proto.IWebMessageInfo, type: MessageUpsertType) => Promise<void>
17
+ appPatch: (patchCreate: WAPatchCreate) => Promise<void>
18
+ createCallLink: (type: 'audio' | 'video', event?: number, timeoutMs?: number) => Promise<void>
19
+ sendPresenceUpdate: (type: WAPresence, toJid?: string) => Promise<void>
20
+ presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>
21
+ getBotListV2: () => Promise<BotListInfo[]>
22
+ getLidUser: (jid: string) => Promise<{
23
+ lid: string
24
+ id: string
25
+ }[] | undefined>
26
+ fetchBlocklist: () => Promise<string[]>
27
+ fetchStatus: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>
28
+ fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>
29
+ updateProfilePicture: (jid: string, content: WAMediaUpload) => Promise<void>
30
+ removeProfilePicture: (jid: string) => Promise<void>
31
+ updateProfileStatus: (status: string) => Promise<void>
32
+ updateProfileName: (name: string) => Promise<void>
33
+ updateBlockStatus: (jid: string, action: 'block' | 'unblock') => Promise<void>
34
+ updateCallPrivacy: (value: WAPrivacyCallValue) => Promise<void>
35
+ updateMessagesPrivacy: (value: WAPrivacyMessagesValue) => Promise<void>
36
+ updateLastSeenPrivacy: (value: WAPrivacyValue) => Promise<void>
37
+ updateOnlinePrivacy: (value: WAPrivacyOnlineValue) => Promise<void>
38
+ updateProfilePicturePrivacy: (value: WAPrivacyValue) => Promise<void>
39
+ updateStatusPrivacy: (value: WAPrivacyValue) => Promise<void>
40
+ updateReadReceiptsPrivacy: (value: WAReadReceiptsValue) => Promise<void>
41
+ updateGroupsAddPrivacy: (value: WAPrivacyGroupAddValue) => Promise<void>
42
+ updateDefaultDisappearingMode: (duration: number) => Promise<void>
43
+ updateDisableLinkPreviewsPrivacy: (isPreviewsDisabled: boolean) => 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>
74
54
  star: (jid: string, messages: {
75
- id: string;
76
- fromMe?: boolean;
77
- }[], star: boolean) => Promise<void>;
78
- addOrEditQuickReply: (quickReply: QuickReplyAction) => Promise<void>;
79
- removeQuickReply: (timestamp: string) => Promise<void>;
80
- type: "md";
81
- ws: import("./Client/websocket.js").WebSocketClient;
82
- ev: import("../Types/index.js").BaileysEventEmitter & {
83
- process(handler: (events: Partial<import("../Types/index.js").BaileysEventMap>) => void | Promise<void>): () => void;
84
- buffer(): void;
85
- createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T>;
86
- flush(): boolean;
87
- isBuffering(): boolean;
88
- destroy(): void;
89
- };
55
+ id: string
56
+ fromMe?: boolean
57
+ }[], star: boolean) => Promise<void>
58
+ addOrEditQuickReply: (quickReply: QuickReplyAction) => Promise<void>
59
+ removeQuickReply: (timestamp: string) => Promise<void>
60
+ addOrEditContact: (jid: string, contact: ContactAction) => Promise<void>
61
+ removeContact: (jid: string) => Promise<void>
62
+ executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>
63
+ type: "md"
64
+ ws: import("./Client").WebSocketClient
65
+ ev: import("../Types").BaileysEventEmitter & {
66
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void
67
+ buffer(): void
68
+ createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>
69
+ flush(force?: boolean | undefined): boolean
70
+ isBuffering(): boolean
71
+ }
90
72
  authState: {
91
- creds: import("../Types/index.js").AuthenticationCreds;
92
- keys: import("../Types/index.js").SignalKeyStoreWithTransaction;
93
- };
94
- signalRepository: import("../Types/index.js").SignalRepositoryWithLIDStore;
95
- user: import("../Types/index.js").Contact | undefined;
96
- generateMessageTag: () => string;
97
- query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
98
- waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<T | undefined>;
99
- waitForSocketOpen: () => Promise<void>;
100
- sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
101
- sendNode: (frame: BinaryNode) => Promise<void>;
102
- logout: (msg?: string) => Promise<void>;
103
- end: (error: Error | undefined) => Promise<void>;
104
- registerSocketEndHandler: (handler: (error: Error | undefined) => void | Promise<void>) => void;
105
- onUnexpectedError: (err: Error | Boom, msg: string) => void;
106
- uploadPreKeys: (count?: number) => Promise<void>;
107
- uploadPreKeysToServerIfRequired: () => Promise<void>;
108
- digestKeyBundle: () => Promise<void>;
109
- rotateSignedPreKey: () => Promise<void>;
110
- requestPairingCode: (phoneNumber: string, customPairingCode?: string) => Promise<string>;
111
- updateServerTimeOffset: ({ attrs }: BinaryNode) => void;
112
- sendUnifiedSession: () => Promise<void>;
113
- wamBuffer: import("../index.js").BinaryInfo;
114
- waitForConnectionUpdate: (check: (u: Partial<import("../Types/index.js").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
115
- sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
116
- executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync/index.js").USyncQueryResult | undefined>;
117
- onWhatsApp: (...phoneNumber: string[]) => Promise<{
118
- jid: string;
119
- exists: boolean;
120
- }[] | undefined>;
121
- fetchAccountReachoutTimelock: () => Promise<import("../Types/index.js").ReachoutTimelockState>;
122
- fetchNewChatMessageCap: () => Promise<import("../Types/index.js").NewChatMessageCapInfo>;
123
- };
124
- //# sourceMappingURL=chats.d.ts.map
73
+ creds: import("../Types").AuthenticationCreds
74
+ keys: import("../Types").SignalKeyStoreWithTransaction
75
+ }
76
+ signalRepository: import("../Types").SignalRepository
77
+ user: import("../Types").Contact | undefined
78
+ generateMessageTag: () => string
79
+ query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>
80
+ waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>
81
+ waitForSocketOpen: () => Promise<void>
82
+ sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>
83
+ sendNode: (frame: BinaryNode) => Promise<void>
84
+ logout: (msg?: string | undefined) => Promise<void>
85
+ end: (error: Error | undefined) => void
86
+ onUnexpectedError: (err: Error | Boom<any>, msg: string) => void
87
+ uploadPreKeys: (count?: number) => Promise<void>
88
+ uploadPreKeysToServerIfRequired: () => Promise<void>
89
+ requestPairingCode: (phoneNumber: string, code?: string) => Promise<string>
90
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>
91
+ /**
92
+ * modify a chat -- mark unread, read etc.
93
+ * lastMessages must be sorted in reverse chronologically
94
+ * requires the last messages till the last message received required for archive & unread
95
+ */
96
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>
97
+ }