@vinzsocket/baileys 2.8.9 → 2.8.20

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 (83) hide show
  1. package/lib/Defaults/index.js +75 -73
  2. package/lib/Signal/Group/ciphertext-message.js +9 -9
  3. package/lib/Signal/Group/group-session-builder.js +21 -21
  4. package/lib/Signal/Group/group_cipher.js +79 -81
  5. package/lib/Signal/Group/index.js +2 -2
  6. package/lib/Signal/Group/keyhelper.js +9 -9
  7. package/lib/Signal/Group/queue-job.js +43 -46
  8. package/lib/Signal/Group/sender-chain-key.js +24 -25
  9. package/lib/Signal/Group/sender-key-distribution-message.js +50 -58
  10. package/lib/Signal/Group/sender-key-message.js +55 -60
  11. package/lib/Signal/Group/sender-key-name.js +38 -39
  12. package/lib/Signal/Group/sender-key-record.js +39 -41
  13. package/lib/Signal/Group/sender-key-state.js +85 -89
  14. package/lib/Signal/Group/sender-message-key.js +22 -22
  15. package/lib/Signal/libsignal.js +387 -292
  16. package/lib/Signal/lid-mapping.js +98 -93
  17. package/lib/Socket/Client/types.js +6 -6
  18. package/lib/Socket/Client/websocket.js +44 -44
  19. package/lib/Socket/business.js +350 -365
  20. package/lib/Socket/chats.js +1019 -914
  21. package/lib/Socket/communities.js +454 -376
  22. package/lib/Socket/groups.js +378 -310
  23. package/lib/Socket/index.js +11 -11
  24. package/lib/Socket/messages-recv.js +1355 -1182
  25. package/lib/Socket/messages-send.js +1224 -1081
  26. package/lib/Socket/mex.js +40 -34
  27. package/lib/Socket/newsletter.js +212 -169
  28. package/lib/Socket/socket.js +896 -757
  29. package/lib/Store/index.js +1 -1
  30. package/lib/Store/make-cache-manager-store.js +75 -79
  31. package/lib/Store/make-in-memory-store.js +450 -389
  32. package/lib/Store/make-ordered-dictionary.js +73 -76
  33. package/lib/Store/object-repository.js +24 -22
  34. package/lib/Types/Chat.js +1 -7
  35. package/lib/Types/Label.js +20 -20
  36. package/lib/Types/LabelAssociation.js +2 -2
  37. package/lib/Types/Message.js +2 -2
  38. package/lib/Types/Newsletter.js +24 -24
  39. package/lib/Types/Socket.js +1 -1
  40. package/lib/Types/State.js +8 -8
  41. package/lib/Types/index.js +10 -10
  42. package/lib/Utils/auth-utils.js +408 -401
  43. package/lib/Utils/baileys-event-stream.js +44 -35
  44. package/lib/Utils/business.js +200 -197
  45. package/lib/Utils/chat-utils.js +775 -708
  46. package/lib/Utils/crypto.js +97 -85
  47. package/lib/Utils/decode-wa-message.js +240 -227
  48. package/lib/Utils/event-buffer.js +547 -518
  49. package/lib/Utils/extended-messages.js +250 -203
  50. package/lib/Utils/generics.js +300 -289
  51. package/lib/Utils/history.js +76 -69
  52. package/lib/Utils/lid-resolver.js +47 -42
  53. package/lib/Utils/link-preview.js +75 -65
  54. package/lib/Utils/logger.js +3 -1
  55. package/lib/Utils/lt-hash.js +38 -34
  56. package/lib/Utils/make-mutex.js +32 -34
  57. package/lib/Utils/mention.js +79 -86
  58. package/lib/Utils/message-retry-manager.js +148 -136
  59. package/lib/Utils/messages-media.js +652 -562
  60. package/lib/Utils/messages.js +753 -707
  61. package/lib/Utils/noise-handler.js +156 -135
  62. package/lib/Utils/process-message.js +404 -341
  63. package/lib/Utils/signal.js +180 -118
  64. package/lib/Utils/use-multi-file-auth-state.js +87 -91
  65. package/lib/Utils/validate-connection.js +167 -142
  66. package/lib/WABinary/constants.js +28 -1293
  67. package/lib/WABinary/decode.js +220 -218
  68. package/lib/WABinary/encode.js +199 -201
  69. package/lib/WABinary/generic-utils.js +80 -77
  70. package/lib/WABinary/jid-utils.js +41 -35
  71. package/lib/WAM/BinaryInfo.js +7 -7
  72. package/lib/WAM/constants.js +1 -15241
  73. package/lib/WAM/encode.js +124 -131
  74. package/lib/WAUSync/Protocols/USyncContactProtocol.js +23 -23
  75. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +51 -47
  76. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +22 -22
  77. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +30 -32
  78. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +19 -19
  79. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -43
  80. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +17 -17
  81. package/lib/WAUSync/USyncQuery.js +82 -84
  82. package/lib/WAUSync/USyncUser.js +20 -20
  83. package/package.json +4 -1
@@ -3,374 +3,359 @@ import { parseCatalogNode, parseCollectionsNode, parseOrderDetailsNode, parsePro
3
3
  import { jidNormalizedUser, S_WHATSAPP_NET } from '../WABinary/index.js';
4
4
  import { getBinaryNodeChild } from '../WABinary/generic-utils.js';
5
5
  import { makeMessagesRecvSocket } from './messages-recv.js';
6
- export const makeBusinessSocket = (config) => {
7
- const sock = makeMessagesRecvSocket(config);
8
- const { authState, query, waUploadToServer } = sock;
9
- const updateBussinesProfile = async (args) => {
10
- const node = [];
11
- const simpleFields = ['address', 'email', 'description'];
12
- node.push(...simpleFields
13
- .filter(key => args[key])
14
- .map(key => ({
15
- tag: key,
16
- attrs: {},
17
- content: args[key]
18
- })));
19
- if (args.websites) {
20
- node.push(...args.websites.map(website => ({
21
- tag: 'website',
22
- attrs: {},
23
- content: website
24
- })));
25
- }
26
- if (args.hours) {
27
- node.push({
28
- tag: 'business_hours',
29
- attrs: { timezone: args.hours.timezone },
30
- content: args.hours.days.map(config => {
31
- const base = {
32
- tag: 'business_hours_config',
33
- attrs: { day_of_week: config.day, mode: config.mode }
34
- };
35
- if (config.mode === 'specific_hours') {
36
- return {
37
- ...base,
38
- attrs: {
39
- ...base.attrs,
40
- open_time: config.openTimeInMinutes,
41
- close_time: config.closeTimeInMinutes
42
- }
43
- };
44
- }
45
- return base;
46
- })
47
- });
48
- }
49
- const result = await query({
50
- tag: 'iq',
51
- attrs: {
52
- to: S_WHATSAPP_NET,
53
- type: 'set',
54
- xmlns: 'w:biz'
55
- },
56
- content: [
57
- {
58
- tag: 'business_profile',
59
- attrs: {
60
- v: '3',
61
- mutation_type: 'delta'
62
- },
63
- content: node
64
- }
65
- ]
66
- });
67
- return result;
68
- };
69
- const updateCoverPhoto = async (photo) => {
70
- const { fileSha256, filePath } = await getRawMediaUploadData(photo, 'biz-cover-photo');
71
- const fileSha256B64 = fileSha256.toString('base64');
72
- const { meta_hmac, fbid, ts } = await waUploadToServer(filePath, {
73
- fileEncSha256B64: fileSha256B64,
74
- mediaType: 'biz-cover-photo'
75
- });
76
- await query({
77
- tag: 'iq',
6
+ export const makeBusinessSocket = config => {
7
+ const sock = makeMessagesRecvSocket(config);
8
+ const {
9
+ authState,
10
+ query,
11
+ waUploadToServer
12
+ } = sock;
13
+ const updateBussinesProfile = async args => {
14
+ const node = [];
15
+ const simpleFields = ['address', 'email', 'description'];
16
+ node.push(...simpleFields.filter(key => args[key]).map(key => ({
17
+ tag: key,
18
+ attrs: {},
19
+ content: args[key]
20
+ })));
21
+ if (args.websites) {
22
+ node.push(...args.websites.map(website => ({
23
+ tag: 'website',
24
+ attrs: {},
25
+ content: website
26
+ })));
27
+ }
28
+ if (args.hours) {
29
+ node.push({
30
+ tag: 'business_hours',
31
+ attrs: {
32
+ timezone: args.hours.timezone
33
+ },
34
+ content: args.hours.days.map(config => {
35
+ const base = {
36
+ tag: 'business_hours_config',
78
37
  attrs: {
79
- to: S_WHATSAPP_NET,
80
- type: 'set',
81
- xmlns: 'w:biz'
82
- },
83
- content: [
84
- {
85
- tag: 'business_profile',
86
- attrs: {
87
- v: '3',
88
- mutation_type: 'delta'
89
- },
90
- content: [
91
- {
92
- tag: 'cover_photo',
93
- attrs: { id: String(fbid), op: 'update', token: meta_hmac, ts: String(ts) }
94
- }
95
- ]
96
- }
97
- ]
98
- });
99
- return fbid;
100
- };
101
- const removeCoverPhoto = async (id) => {
102
- return await query({
103
- tag: 'iq',
104
- attrs: {
105
- to: S_WHATSAPP_NET,
106
- type: 'set',
107
- xmlns: 'w:biz'
108
- },
109
- content: [
110
- {
111
- tag: 'business_profile',
112
- attrs: {
113
- v: '3',
114
- mutation_type: 'delta'
115
- },
116
- content: [
117
- {
118
- tag: 'cover_photo',
119
- attrs: { op: 'delete', id }
120
- }
121
- ]
122
- }
123
- ]
124
- });
125
- };
126
- const getCatalog = async ({ jid, limit, cursor }) => {
127
- jid = jid || authState.creds.me?.id;
128
- jid = jidNormalizedUser(jid);
129
- const queryParamNodes = [
130
- {
131
- tag: 'limit',
132
- attrs: {},
133
- content: Buffer.from((limit || 10).toString())
134
- },
135
- {
136
- tag: 'width',
137
- attrs: {},
138
- content: Buffer.from('100')
139
- },
140
- {
141
- tag: 'height',
142
- attrs: {},
143
- content: Buffer.from('100')
38
+ day_of_week: config.day,
39
+ mode: config.mode
144
40
  }
145
- ];
146
- if (cursor) {
147
- queryParamNodes.push({
148
- tag: 'after',
149
- attrs: {},
150
- content: cursor
151
- });
152
- }
153
- const result = await query({
154
- tag: 'iq',
155
- attrs: {
156
- to: S_WHATSAPP_NET,
157
- type: 'get',
158
- xmlns: 'w:biz:catalog'
159
- },
160
- content: [
161
- {
162
- tag: 'product_catalog',
163
- attrs: {
164
- jid,
165
- allow_shop_source: 'true'
166
- },
167
- content: queryParamNodes
168
- }
169
- ]
170
- });
171
- return parseCatalogNode(result);
172
- };
173
- const getCollections = async (jid, limit = 51) => {
174
- jid = jid || authState.creds.me?.id;
175
- jid = jidNormalizedUser(jid);
176
- const result = await query({
177
- tag: 'iq',
178
- attrs: {
179
- to: S_WHATSAPP_NET,
180
- type: 'get',
181
- xmlns: 'w:biz:catalog',
182
- smax_id: '35'
183
- },
184
- content: [
185
- {
186
- tag: 'collections',
187
- attrs: {
188
- biz_jid: jid
189
- },
190
- content: [
191
- {
192
- tag: 'collection_limit',
193
- attrs: {},
194
- content: Buffer.from(limit.toString())
195
- },
196
- {
197
- tag: 'item_limit',
198
- attrs: {},
199
- content: Buffer.from(limit.toString())
200
- },
201
- {
202
- tag: 'width',
203
- attrs: {},
204
- content: Buffer.from('100')
205
- },
206
- {
207
- tag: 'height',
208
- attrs: {},
209
- content: Buffer.from('100')
210
- }
211
- ]
212
- }
213
- ]
214
- });
215
- return parseCollectionsNode(result);
216
- };
217
- const getOrderDetails = async (orderId, tokenBase64) => {
218
- const result = await query({
219
- tag: 'iq',
220
- attrs: {
221
- to: S_WHATSAPP_NET,
222
- type: 'get',
223
- xmlns: 'fb:thrift_iq',
224
- smax_id: '5'
225
- },
226
- content: [
227
- {
228
- tag: 'order',
229
- attrs: {
230
- op: 'get',
231
- id: orderId
232
- },
233
- content: [
234
- {
235
- tag: 'image_dimensions',
236
- attrs: {},
237
- content: [
238
- {
239
- tag: 'width',
240
- attrs: {},
241
- content: Buffer.from('100')
242
- },
243
- {
244
- tag: 'height',
245
- attrs: {},
246
- content: Buffer.from('100')
247
- }
248
- ]
249
- },
250
- {
251
- tag: 'token',
252
- attrs: {},
253
- content: Buffer.from(tokenBase64)
254
- }
255
- ]
256
- }
257
- ]
258
- });
259
- return parseOrderDetailsNode(result);
260
- };
261
- const productUpdate = async (productId, update) => {
262
- update = await uploadingNecessaryImagesOfProduct(update, waUploadToServer);
263
- const editNode = toProductNode(productId, update);
264
- const result = await query({
265
- tag: 'iq',
266
- attrs: {
267
- to: S_WHATSAPP_NET,
268
- type: 'set',
269
- xmlns: 'w:biz:catalog'
270
- },
271
- content: [
272
- {
273
- tag: 'product_catalog_edit',
274
- attrs: { v: '1' },
275
- content: [
276
- editNode,
277
- {
278
- tag: 'width',
279
- attrs: {},
280
- content: '100'
281
- },
282
- {
283
- tag: 'height',
284
- attrs: {},
285
- content: '100'
286
- }
287
- ]
288
- }
289
- ]
290
- });
291
- const productCatalogEditNode = getBinaryNodeChild(result, 'product_catalog_edit');
292
- const productNode = getBinaryNodeChild(productCatalogEditNode, 'product');
293
- return parseProductNode(productNode);
294
- };
295
- const productCreate = async (create) => {
296
- // ensure isHidden is defined
297
- create.isHidden = !!create.isHidden;
298
- create = await uploadingNecessaryImagesOfProduct(create, waUploadToServer);
299
- const createNode = toProductNode(undefined, create);
300
- const result = await query({
301
- tag: 'iq',
302
- attrs: {
303
- to: S_WHATSAPP_NET,
304
- type: 'set',
305
- xmlns: 'w:biz:catalog'
306
- },
307
- content: [
308
- {
309
- tag: 'product_catalog_add',
310
- attrs: { v: '1' },
311
- content: [
312
- createNode,
313
- {
314
- tag: 'width',
315
- attrs: {},
316
- content: '100'
317
- },
318
- {
319
- tag: 'height',
320
- attrs: {},
321
- content: '100'
322
- }
323
- ]
324
- }
325
- ]
326
- });
327
- const productCatalogAddNode = getBinaryNodeChild(result, 'product_catalog_add');
328
- const productNode = getBinaryNodeChild(productCatalogAddNode, 'product');
329
- return parseProductNode(productNode);
330
- };
331
- const productDelete = async (productIds) => {
332
- const result = await query({
333
- tag: 'iq',
334
- attrs: {
335
- to: S_WHATSAPP_NET,
336
- type: 'set',
337
- xmlns: 'w:biz:catalog'
338
- },
339
- content: [
340
- {
341
- tag: 'product_catalog_delete',
342
- attrs: { v: '1' },
343
- content: productIds.map(id => ({
344
- tag: 'product',
345
- attrs: {},
346
- content: [
347
- {
348
- tag: 'id',
349
- attrs: {},
350
- content: Buffer.from(id)
351
- }
352
- ]
353
- }))
354
- }
355
- ]
356
- });
357
- const productCatalogDelNode = getBinaryNodeChild(result, 'product_catalog_delete');
358
- return {
359
- deleted: +(productCatalogDelNode?.attrs.deleted_count || 0)
360
- };
361
- };
41
+ };
42
+ if (config.mode === 'specific_hours') {
43
+ return {
44
+ ...base,
45
+ attrs: {
46
+ ...base.attrs,
47
+ open_time: config.openTimeInMinutes,
48
+ close_time: config.closeTimeInMinutes
49
+ }
50
+ };
51
+ }
52
+ return base;
53
+ })
54
+ });
55
+ }
56
+ const result = await query({
57
+ tag: 'iq',
58
+ attrs: {
59
+ to: S_WHATSAPP_NET,
60
+ type: 'set',
61
+ xmlns: 'w:biz'
62
+ },
63
+ content: [{
64
+ tag: 'business_profile',
65
+ attrs: {
66
+ v: '3',
67
+ mutation_type: 'delta'
68
+ },
69
+ content: node
70
+ }]
71
+ });
72
+ return result;
73
+ };
74
+ const updateCoverPhoto = async photo => {
75
+ const {
76
+ fileSha256,
77
+ filePath
78
+ } = await getRawMediaUploadData(photo, 'biz-cover-photo');
79
+ const fileSha256B64 = fileSha256.toString('base64');
80
+ const {
81
+ meta_hmac,
82
+ fbid,
83
+ ts
84
+ } = await waUploadToServer(filePath, {
85
+ fileEncSha256B64: fileSha256B64,
86
+ mediaType: 'biz-cover-photo'
87
+ });
88
+ await query({
89
+ tag: 'iq',
90
+ attrs: {
91
+ to: S_WHATSAPP_NET,
92
+ type: 'set',
93
+ xmlns: 'w:biz'
94
+ },
95
+ content: [{
96
+ tag: 'business_profile',
97
+ attrs: {
98
+ v: '3',
99
+ mutation_type: 'delta'
100
+ },
101
+ content: [{
102
+ tag: 'cover_photo',
103
+ attrs: {
104
+ id: String(fbid),
105
+ op: 'update',
106
+ token: meta_hmac,
107
+ ts: String(ts)
108
+ }
109
+ }]
110
+ }]
111
+ });
112
+ return fbid;
113
+ };
114
+ const removeCoverPhoto = async id => {
115
+ return await query({
116
+ tag: 'iq',
117
+ attrs: {
118
+ to: S_WHATSAPP_NET,
119
+ type: 'set',
120
+ xmlns: 'w:biz'
121
+ },
122
+ content: [{
123
+ tag: 'business_profile',
124
+ attrs: {
125
+ v: '3',
126
+ mutation_type: 'delta'
127
+ },
128
+ content: [{
129
+ tag: 'cover_photo',
130
+ attrs: {
131
+ op: 'delete',
132
+ id
133
+ }
134
+ }]
135
+ }]
136
+ });
137
+ };
138
+ const getCatalog = async ({
139
+ jid,
140
+ limit,
141
+ cursor
142
+ }) => {
143
+ jid = jid || authState.creds.me?.id;
144
+ jid = jidNormalizedUser(jid);
145
+ const queryParamNodes = [{
146
+ tag: 'limit',
147
+ attrs: {},
148
+ content: Buffer.from((limit || 10).toString())
149
+ }, {
150
+ tag: 'width',
151
+ attrs: {},
152
+ content: Buffer.from('100')
153
+ }, {
154
+ tag: 'height',
155
+ attrs: {},
156
+ content: Buffer.from('100')
157
+ }];
158
+ if (cursor) {
159
+ queryParamNodes.push({
160
+ tag: 'after',
161
+ attrs: {},
162
+ content: cursor
163
+ });
164
+ }
165
+ const result = await query({
166
+ tag: 'iq',
167
+ attrs: {
168
+ to: S_WHATSAPP_NET,
169
+ type: 'get',
170
+ xmlns: 'w:biz:catalog'
171
+ },
172
+ content: [{
173
+ tag: 'product_catalog',
174
+ attrs: {
175
+ jid,
176
+ allow_shop_source: 'true'
177
+ },
178
+ content: queryParamNodes
179
+ }]
180
+ });
181
+ return parseCatalogNode(result);
182
+ };
183
+ const getCollections = async (jid, limit = 51) => {
184
+ jid = jid || authState.creds.me?.id;
185
+ jid = jidNormalizedUser(jid);
186
+ const result = await query({
187
+ tag: 'iq',
188
+ attrs: {
189
+ to: S_WHATSAPP_NET,
190
+ type: 'get',
191
+ xmlns: 'w:biz:catalog',
192
+ smax_id: '35'
193
+ },
194
+ content: [{
195
+ tag: 'collections',
196
+ attrs: {
197
+ biz_jid: jid
198
+ },
199
+ content: [{
200
+ tag: 'collection_limit',
201
+ attrs: {},
202
+ content: Buffer.from(limit.toString())
203
+ }, {
204
+ tag: 'item_limit',
205
+ attrs: {},
206
+ content: Buffer.from(limit.toString())
207
+ }, {
208
+ tag: 'width',
209
+ attrs: {},
210
+ content: Buffer.from('100')
211
+ }, {
212
+ tag: 'height',
213
+ attrs: {},
214
+ content: Buffer.from('100')
215
+ }]
216
+ }]
217
+ });
218
+ return parseCollectionsNode(result);
219
+ };
220
+ const getOrderDetails = async (orderId, tokenBase64) => {
221
+ const result = await query({
222
+ tag: 'iq',
223
+ attrs: {
224
+ to: S_WHATSAPP_NET,
225
+ type: 'get',
226
+ xmlns: 'fb:thrift_iq',
227
+ smax_id: '5'
228
+ },
229
+ content: [{
230
+ tag: 'order',
231
+ attrs: {
232
+ op: 'get',
233
+ id: orderId
234
+ },
235
+ content: [{
236
+ tag: 'image_dimensions',
237
+ attrs: {},
238
+ content: [{
239
+ tag: 'width',
240
+ attrs: {},
241
+ content: Buffer.from('100')
242
+ }, {
243
+ tag: 'height',
244
+ attrs: {},
245
+ content: Buffer.from('100')
246
+ }]
247
+ }, {
248
+ tag: 'token',
249
+ attrs: {},
250
+ content: Buffer.from(tokenBase64)
251
+ }]
252
+ }]
253
+ });
254
+ return parseOrderDetailsNode(result);
255
+ };
256
+ const productUpdate = async (productId, update) => {
257
+ update = await uploadingNecessaryImagesOfProduct(update, waUploadToServer);
258
+ const editNode = toProductNode(productId, update);
259
+ const result = await query({
260
+ tag: 'iq',
261
+ attrs: {
262
+ to: S_WHATSAPP_NET,
263
+ type: 'set',
264
+ xmlns: 'w:biz:catalog'
265
+ },
266
+ content: [{
267
+ tag: 'product_catalog_edit',
268
+ attrs: {
269
+ v: '1'
270
+ },
271
+ content: [editNode, {
272
+ tag: 'width',
273
+ attrs: {},
274
+ content: '100'
275
+ }, {
276
+ tag: 'height',
277
+ attrs: {},
278
+ content: '100'
279
+ }]
280
+ }]
281
+ });
282
+ const productCatalogEditNode = getBinaryNodeChild(result, 'product_catalog_edit');
283
+ const productNode = getBinaryNodeChild(productCatalogEditNode, 'product');
284
+ return parseProductNode(productNode);
285
+ };
286
+ const productCreate = async create => {
287
+ // ensure isHidden is defined
288
+ create.isHidden = !!create.isHidden;
289
+ create = await uploadingNecessaryImagesOfProduct(create, waUploadToServer);
290
+ const createNode = toProductNode(undefined, create);
291
+ const result = await query({
292
+ tag: 'iq',
293
+ attrs: {
294
+ to: S_WHATSAPP_NET,
295
+ type: 'set',
296
+ xmlns: 'w:biz:catalog'
297
+ },
298
+ content: [{
299
+ tag: 'product_catalog_add',
300
+ attrs: {
301
+ v: '1'
302
+ },
303
+ content: [createNode, {
304
+ tag: 'width',
305
+ attrs: {},
306
+ content: '100'
307
+ }, {
308
+ tag: 'height',
309
+ attrs: {},
310
+ content: '100'
311
+ }]
312
+ }]
313
+ });
314
+ const productCatalogAddNode = getBinaryNodeChild(result, 'product_catalog_add');
315
+ const productNode = getBinaryNodeChild(productCatalogAddNode, 'product');
316
+ return parseProductNode(productNode);
317
+ };
318
+ const productDelete = async productIds => {
319
+ const result = await query({
320
+ tag: 'iq',
321
+ attrs: {
322
+ to: S_WHATSAPP_NET,
323
+ type: 'set',
324
+ xmlns: 'w:biz:catalog'
325
+ },
326
+ content: [{
327
+ tag: 'product_catalog_delete',
328
+ attrs: {
329
+ v: '1'
330
+ },
331
+ content: productIds.map(id => ({
332
+ tag: 'product',
333
+ attrs: {},
334
+ content: [{
335
+ tag: 'id',
336
+ attrs: {},
337
+ content: Buffer.from(id)
338
+ }]
339
+ }))
340
+ }]
341
+ });
342
+ const productCatalogDelNode = getBinaryNodeChild(result, 'product_catalog_delete');
362
343
  return {
363
- ...sock,
364
- logger: config.logger,
365
- getOrderDetails,
366
- getCatalog,
367
- getCollections,
368
- productCreate,
369
- productDelete,
370
- productUpdate,
371
- updateBussinesProfile,
372
- updateCoverPhoto,
373
- removeCoverPhoto
344
+ deleted: +(productCatalogDelNode?.attrs.deleted_count || 0)
374
345
  };
346
+ };
347
+ return {
348
+ ...sock,
349
+ logger: config.logger,
350
+ getOrderDetails,
351
+ getCatalog,
352
+ getCollections,
353
+ productCreate,
354
+ productDelete,
355
+ productUpdate,
356
+ updateBussinesProfile,
357
+ updateCoverPhoto,
358
+ removeCoverPhoto
359
+ };
375
360
  };
376
361
  //# sourceMappingURL=business.js.map