@pontalabs/baileys 1.0.11 → 1.1.0

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