@dappaoffc/baileys-mod 5.0.7 → 6.0.5

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.

Potentially problematic release.


This version of @dappaoffc/baileys-mod might be problematic. Click here for more details.

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