astrabail 1.0.6

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 (224) hide show
  1. package/WAProto/GenerateStatics.sh +3 -0
  2. package/WAProto/WAProto.proto +5479 -0
  3. package/WAProto/fix-imports.js +73 -0
  4. package/WAProto/index.d.ts +14017 -0
  5. package/WAProto/index.js +89351 -0
  6. package/WAProto/p.html +1 -0
  7. package/engine-requirements.js +7 -0
  8. package/lib/Defaults/astrabail-version.json +8 -0
  9. package/lib/Defaults/index.d.ts +74 -0
  10. package/lib/Defaults/index.js +166 -0
  11. package/lib/Defaults/phonenumber-mcc.json +223 -0
  12. package/lib/Defaults/update-wa-version.js +75 -0
  13. package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
  14. package/lib/Signal/Group/ciphertext-message.js +15 -0
  15. package/lib/Signal/Group/group-session-builder.d.ts +15 -0
  16. package/lib/Signal/Group/group-session-builder.js +66 -0
  17. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  18. package/lib/Signal/Group/group_cipher.js +85 -0
  19. package/lib/Signal/Group/index.d.ts +12 -0
  20. package/lib/Signal/Group/index.js +57 -0
  21. package/lib/Signal/Group/keyhelper.d.ts +11 -0
  22. package/lib/Signal/Group/keyhelper.js +55 -0
  23. package/lib/Signal/Group/queue-job.js +57 -0
  24. package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
  25. package/lib/Signal/Group/sender-chain-key.js +29 -0
  26. package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
  27. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  28. package/lib/Signal/Group/sender-key-message.d.ts +19 -0
  29. package/lib/Signal/Group/sender-key-message.js +69 -0
  30. package/lib/Signal/Group/sender-key-name.d.ts +18 -0
  31. package/lib/Signal/Group/sender-key-name.js +51 -0
  32. package/lib/Signal/Group/sender-key-record.d.ts +31 -0
  33. package/lib/Signal/Group/sender-key-record.js +44 -0
  34. package/lib/Signal/Group/sender-key-state.d.ts +39 -0
  35. package/lib/Signal/Group/sender-key-state.js +87 -0
  36. package/lib/Signal/Group/sender-message-key.d.ts +12 -0
  37. package/lib/Signal/Group/sender-message-key.js +29 -0
  38. package/lib/Signal/libsignal.d.ts +5 -0
  39. package/lib/Signal/libsignal.js +478 -0
  40. package/lib/Signal/lid-mapping.d.ts +19 -0
  41. package/lib/Signal/lid-mapping.js +274 -0
  42. package/lib/Socket/Client/index.d.ts +3 -0
  43. package/lib/Socket/Client/index.js +18 -0
  44. package/lib/Socket/Client/types.d.ts +16 -0
  45. package/lib/Socket/Client/types.js +14 -0
  46. package/lib/Socket/Client/websocket.d.ts +13 -0
  47. package/lib/Socket/Client/websocket.js +60 -0
  48. package/lib/Socket/business.d.ts +202 -0
  49. package/lib/Socket/business.js +382 -0
  50. package/lib/Socket/chats.d.ts +111 -0
  51. package/lib/Socket/chats.js +1155 -0
  52. package/lib/Socket/communities.d.ts +258 -0
  53. package/lib/Socket/communities.js +438 -0
  54. package/lib/Socket/community.js +333 -0
  55. package/lib/Socket/groups.d.ts +150 -0
  56. package/lib/Socket/groups.js +470 -0
  57. package/lib/Socket/index.d.ts +245 -0
  58. package/lib/Socket/index.js +13 -0
  59. package/lib/Socket/messages-recv.d.ts +187 -0
  60. package/lib/Socket/messages-recv.js +1708 -0
  61. package/lib/Socket/messages-send.d.ts +183 -0
  62. package/lib/Socket/messages-send.js +1692 -0
  63. package/lib/Socket/mex.d.ts +3 -0
  64. package/lib/Socket/mex.js +45 -0
  65. package/lib/Socket/newsletter.d.ts +160 -0
  66. package/lib/Socket/newsletter.js +293 -0
  67. package/lib/Socket/socket.d.ts +55 -0
  68. package/lib/Socket/socket.js +947 -0
  69. package/lib/Socket/usync.js +70 -0
  70. package/lib/Store/index.js +20 -0
  71. package/lib/Store/make-cache-manager-store.js +83 -0
  72. package/lib/Store/make-in-memory-store.js +398 -0
  73. package/lib/Store/make-ordered-dictionary.js +81 -0
  74. package/lib/Store/object-repository.js +27 -0
  75. package/lib/Types/Auth.d.ts +116 -0
  76. package/lib/Types/Auth.js +2 -0
  77. package/lib/Types/Bussines.d.ts +25 -0
  78. package/lib/Types/Bussines.js +2 -0
  79. package/lib/Types/Call.d.ts +15 -0
  80. package/lib/Types/Call.js +2 -0
  81. package/lib/Types/Chat.d.ts +123 -0
  82. package/lib/Types/Chat.js +10 -0
  83. package/lib/Types/Contact.d.ts +24 -0
  84. package/lib/Types/Contact.js +2 -0
  85. package/lib/Types/Events.d.ts +237 -0
  86. package/lib/Types/Events.js +3 -0
  87. package/lib/Types/GroupMetadata.d.ts +67 -0
  88. package/lib/Types/GroupMetadata.js +2 -0
  89. package/lib/Types/Label.d.ts +47 -0
  90. package/lib/Types/Label.js +25 -0
  91. package/lib/Types/LabelAssociation.d.ts +30 -0
  92. package/lib/Types/LabelAssociation.js +7 -0
  93. package/lib/Types/Message.d.ts +305 -0
  94. package/lib/Types/Message.js +11 -0
  95. package/lib/Types/MexUpdates.js +11 -0
  96. package/lib/Types/Newsletter.d.ts +135 -0
  97. package/lib/Types/Newsletter.js +43 -0
  98. package/lib/Types/Product.d.ts +79 -0
  99. package/lib/Types/Product.js +2 -0
  100. package/lib/Types/Signal.d.ts +76 -0
  101. package/lib/Types/Signal.js +3 -0
  102. package/lib/Types/Socket.d.ts +133 -0
  103. package/lib/Types/Socket.js +3 -0
  104. package/lib/Types/State.d.ts +39 -0
  105. package/lib/Types/State.js +14 -0
  106. package/lib/Types/USync.d.ts +26 -0
  107. package/lib/Types/USync.js +3 -0
  108. package/lib/Types/index.d.ts +65 -0
  109. package/lib/Types/index.js +42 -0
  110. package/lib/Utils/astrabail-event-stream.js +3 -0
  111. package/lib/Utils/audioToBuffer.js +31 -0
  112. package/lib/Utils/auth-utils.d.ts +19 -0
  113. package/lib/Utils/auth-utils.js +298 -0
  114. package/lib/Utils/baileys-event-stream.js +60 -0
  115. package/lib/Utils/bridge-runtime.d.ts +1 -0
  116. package/lib/Utils/bridge-runtime.js +14 -0
  117. package/lib/Utils/browser-utils.d.ts +4 -0
  118. package/lib/Utils/browser-utils.js +44 -0
  119. package/lib/Utils/business.d.ts +23 -0
  120. package/lib/Utils/business.js +240 -0
  121. package/lib/Utils/chat-utils.d.ts +70 -0
  122. package/lib/Utils/chat-utils.js +825 -0
  123. package/lib/Utils/crypto.d.ts +37 -0
  124. package/lib/Utils/crypto.js +168 -0
  125. package/lib/Utils/decode-wa-message.d.ts +48 -0
  126. package/lib/Utils/decode-wa-message.js +287 -0
  127. package/lib/Utils/event-buffer.d.ts +34 -0
  128. package/lib/Utils/event-buffer.js +580 -0
  129. package/lib/Utils/generics.d.ts +91 -0
  130. package/lib/Utils/generics.js +483 -0
  131. package/lib/Utils/history.d.ts +22 -0
  132. package/lib/Utils/history.js +137 -0
  133. package/lib/Utils/identity-change-handler.d.ts +37 -0
  134. package/lib/Utils/identity-change-handler.js +54 -0
  135. package/lib/Utils/index.d.ts +22 -0
  136. package/lib/Utils/index.js +48 -0
  137. package/lib/Utils/link-preview.d.ts +21 -0
  138. package/lib/Utils/link-preview.js +121 -0
  139. package/lib/Utils/logger.d.ts +13 -0
  140. package/lib/Utils/logger.js +7 -0
  141. package/lib/Utils/lt-hash.d.ts +8 -0
  142. package/lib/Utils/lt-hash.js +10 -0
  143. package/lib/Utils/make-mutex.d.ts +9 -0
  144. package/lib/Utils/make-mutex.js +37 -0
  145. package/lib/Utils/message-retry-manager.d.ts +110 -0
  146. package/lib/Utils/message-retry-manager.js +226 -0
  147. package/lib/Utils/messages-media.d.ts +130 -0
  148. package/lib/Utils/messages-media.js +887 -0
  149. package/lib/Utils/messages-newsletter.d.ts +84 -0
  150. package/lib/Utils/messages-newsletter.js +295 -0
  151. package/lib/Utils/messages.d.ts +92 -0
  152. package/lib/Utils/messages.js +1752 -0
  153. package/lib/Utils/noise-handler.d.ts +20 -0
  154. package/lib/Utils/noise-handler.js +204 -0
  155. package/lib/Utils/pre-key-manager.d.ts +28 -0
  156. package/lib/Utils/pre-key-manager.js +112 -0
  157. package/lib/Utils/process-message.d.ts +60 -0
  158. package/lib/Utils/process-message.js +536 -0
  159. package/lib/Utils/reporting-utils.d.ts +11 -0
  160. package/lib/Utils/reporting-utils.js +262 -0
  161. package/lib/Utils/resolve-jid.d.ts +43 -0
  162. package/lib/Utils/resolve-jid.js +95 -0
  163. package/lib/Utils/rust-bridge-shim.d.ts +22 -0
  164. package/lib/Utils/rust-bridge-shim.js +70 -0
  165. package/lib/Utils/serial-task-queue.js +29 -0
  166. package/lib/Utils/signal.d.ts +34 -0
  167. package/lib/Utils/signal.js +170 -0
  168. package/lib/Utils/streamToBuffer.js +17 -0
  169. package/lib/Utils/sync-action-utils.d.ts +19 -0
  170. package/lib/Utils/sync-action-utils.js +52 -0
  171. package/lib/Utils/tc-token-utils.d.ts +12 -0
  172. package/lib/Utils/tc-token-utils.js +20 -0
  173. package/lib/Utils/use-mongo-file-auth-state.js +71 -0
  174. package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
  175. package/lib/Utils/use-multi-file-auth-state.js +124 -0
  176. package/lib/Utils/use-single-file-auth-state.js +73 -0
  177. package/lib/Utils/validate-connection.d.ts +11 -0
  178. package/lib/Utils/validate-connection.js +206 -0
  179. package/lib/WABinary/constants.d.ts +28 -0
  180. package/lib/WABinary/constants.js +1303 -0
  181. package/lib/WABinary/decode.d.ts +7 -0
  182. package/lib/WABinary/decode.js +300 -0
  183. package/lib/WABinary/encode.d.ts +3 -0
  184. package/lib/WABinary/encode.js +256 -0
  185. package/lib/WABinary/generic-utils.d.ts +15 -0
  186. package/lib/WABinary/generic-utils.js +138 -0
  187. package/lib/WABinary/index.d.ts +6 -0
  188. package/lib/WABinary/index.js +25 -0
  189. package/lib/WABinary/jid-utils.d.ts +48 -0
  190. package/lib/WABinary/jid-utils.js +115 -0
  191. package/lib/WABinary/types.d.ts +19 -0
  192. package/lib/WABinary/types.js +36 -0
  193. package/lib/WAM/BinaryInfo.d.ts +9 -0
  194. package/lib/WAM/BinaryInfo.js +13 -0
  195. package/lib/WAM/constants.d.ts +40 -0
  196. package/lib/WAM/constants.js +22855 -0
  197. package/lib/WAM/encode.d.ts +3 -0
  198. package/lib/WAM/encode.js +153 -0
  199. package/lib/WAM/index.d.ts +4 -0
  200. package/lib/WAM/index.js +19 -0
  201. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
  202. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
  203. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
  204. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  205. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
  206. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  207. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
  208. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +41 -0
  209. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +26 -0
  210. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +54 -0
  211. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +10 -0
  212. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +32 -0
  213. package/lib/WAUSync/Protocols/index.d.ts +5 -0
  214. package/lib/WAUSync/Protocols/index.js +22 -0
  215. package/lib/WAUSync/USyncQuery.d.ts +29 -0
  216. package/lib/WAUSync/USyncQuery.js +97 -0
  217. package/lib/WAUSync/USyncUser.d.ts +13 -0
  218. package/lib/WAUSync/USyncUser.js +26 -0
  219. package/lib/WAUSync/index.d.ts +4 -0
  220. package/lib/WAUSync/index.js +19 -0
  221. package/lib/index.d.ts +12 -0
  222. package/lib/index.js +124 -0
  223. package/package.json +120 -0
  224. package/readme.md +1956 -0
@@ -0,0 +1,382 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeBusinessSocket = void 0;
4
+ const index_js_1 = require("../Utils/index.js");
5
+ const business_js_1 = require("../Utils/business.js");
6
+ const index_js_2 = require("../WABinary/index.js");
7
+ const generic_utils_js_1 = require("../WABinary/generic-utils.js");
8
+ const messages_recv_js_1 = require("./messages-recv.js");
9
+ const makeBusinessSocket = (config) => {
10
+ const sock = (0, messages_recv_js_1.makeMessagesRecvSocket)(config);
11
+ const { authState, query, waUploadToServer } = sock;
12
+ const updateBussinesProfile = async (args) => {
13
+ const node = [];
14
+ const simpleFields = ['address', 'email', 'description'];
15
+ node.push(...simpleFields
16
+ .filter(key => args[key] !== undefined && args[key] !== null)
17
+ .map(key => ({
18
+ tag: key,
19
+ attrs: {},
20
+ content: args[key]
21
+ })));
22
+ if (args.websites !== undefined) {
23
+ node.push(...args.websites.map(website => ({
24
+ tag: 'website',
25
+ attrs: {},
26
+ content: website
27
+ })));
28
+ }
29
+ if (args.hours !== undefined) {
30
+ node.push({
31
+ tag: 'business_hours',
32
+ attrs: { timezone: args.hours.timezone },
33
+ content: args.hours.days.map(dayConfig => {
34
+ const base = {
35
+ tag: 'business_hours_config',
36
+ attrs: {
37
+ day_of_week: dayConfig.day,
38
+ mode: dayConfig.mode
39
+ }
40
+ };
41
+ if (dayConfig.mode === 'specific_hours') {
42
+ return {
43
+ ...base,
44
+ attrs: {
45
+ ...base.attrs,
46
+ open_time: dayConfig.openTimeInMinutes,
47
+ close_time: dayConfig.closeTimeInMinutes
48
+ }
49
+ };
50
+ }
51
+ return base;
52
+ })
53
+ });
54
+ }
55
+ const result = await query({
56
+ tag: 'iq',
57
+ attrs: {
58
+ to: index_js_2.S_WHATSAPP_NET,
59
+ type: 'set',
60
+ xmlns: 'w:biz'
61
+ },
62
+ content: [
63
+ {
64
+ tag: 'business_profile',
65
+ attrs: {
66
+ v: '3',
67
+ mutation_type: 'delta'
68
+ },
69
+ content: node
70
+ }
71
+ ]
72
+ });
73
+ return result;
74
+ };
75
+ const updateCoverPhoto = async (photo) => {
76
+ const { fileSha256, filePath } = await (0, index_js_1.getRawMediaUploadData)(photo, 'biz-cover-photo');
77
+ const fileSha256B64 = fileSha256.toString('base64');
78
+ const { meta_hmac, fbid, ts } = await waUploadToServer(filePath, {
79
+ fileEncSha256B64: fileSha256B64,
80
+ mediaType: 'biz-cover-photo'
81
+ });
82
+ await query({
83
+ tag: 'iq',
84
+ attrs: {
85
+ to: index_js_2.S_WHATSAPP_NET,
86
+ type: 'set',
87
+ xmlns: 'w:biz'
88
+ },
89
+ content: [
90
+ {
91
+ tag: 'business_profile',
92
+ attrs: {
93
+ v: '3',
94
+ mutation_type: 'delta'
95
+ },
96
+ content: [
97
+ {
98
+ tag: 'cover_photo',
99
+ attrs: { id: String(fbid), op: 'update', token: meta_hmac, ts: String(ts) }
100
+ }
101
+ ]
102
+ }
103
+ ]
104
+ });
105
+ return fbid;
106
+ };
107
+ const removeCoverPhoto = async (id) => {
108
+ return await query({
109
+ tag: 'iq',
110
+ attrs: {
111
+ to: index_js_2.S_WHATSAPP_NET,
112
+ type: 'set',
113
+ xmlns: 'w:biz'
114
+ },
115
+ content: [
116
+ {
117
+ tag: 'business_profile',
118
+ attrs: {
119
+ v: '3',
120
+ mutation_type: 'delta'
121
+ },
122
+ content: [
123
+ {
124
+ tag: 'cover_photo',
125
+ attrs: { op: 'delete', id }
126
+ }
127
+ ]
128
+ }
129
+ ]
130
+ });
131
+ };
132
+ const getCatalog = async ({ jid, limit, cursor }) => {
133
+ jid = jid || authState.creds.me?.id;
134
+ jid = (0, index_js_2.jidNormalizedUser)(jid);
135
+ const queryParamNodes = [
136
+ {
137
+ tag: 'limit',
138
+ attrs: {},
139
+ content: Buffer.from((limit || 10).toString())
140
+ },
141
+ {
142
+ tag: 'width',
143
+ attrs: {},
144
+ content: Buffer.from('100')
145
+ },
146
+ {
147
+ tag: 'height',
148
+ attrs: {},
149
+ content: Buffer.from('100')
150
+ }
151
+ ];
152
+ if (cursor) {
153
+ queryParamNodes.push({
154
+ tag: 'after',
155
+ attrs: {},
156
+ content: cursor
157
+ });
158
+ }
159
+ const result = await query({
160
+ tag: 'iq',
161
+ attrs: {
162
+ to: index_js_2.S_WHATSAPP_NET,
163
+ type: 'get',
164
+ xmlns: 'w:biz:catalog'
165
+ },
166
+ content: [
167
+ {
168
+ tag: 'product_catalog',
169
+ attrs: {
170
+ jid,
171
+ allow_shop_source: 'true'
172
+ },
173
+ content: queryParamNodes
174
+ }
175
+ ]
176
+ });
177
+ return (0, business_js_1.parseCatalogNode)(result);
178
+ };
179
+ const getCollections = async (jid, limit = 51) => {
180
+ jid = jid || authState.creds.me?.id;
181
+ jid = (0, index_js_2.jidNormalizedUser)(jid);
182
+ const result = await query({
183
+ tag: 'iq',
184
+ attrs: {
185
+ to: index_js_2.S_WHATSAPP_NET,
186
+ type: 'get',
187
+ xmlns: 'w:biz:catalog',
188
+ smax_id: '35'
189
+ },
190
+ content: [
191
+ {
192
+ tag: 'collections',
193
+ attrs: {
194
+ biz_jid: jid
195
+ },
196
+ content: [
197
+ {
198
+ tag: 'collection_limit',
199
+ attrs: {},
200
+ content: Buffer.from(limit.toString())
201
+ },
202
+ {
203
+ tag: 'item_limit',
204
+ attrs: {},
205
+ content: Buffer.from(limit.toString())
206
+ },
207
+ {
208
+ tag: 'width',
209
+ attrs: {},
210
+ content: Buffer.from('100')
211
+ },
212
+ {
213
+ tag: 'height',
214
+ attrs: {},
215
+ content: Buffer.from('100')
216
+ }
217
+ ]
218
+ }
219
+ ]
220
+ });
221
+ return (0, business_js_1.parseCollectionsNode)(result);
222
+ };
223
+ const getOrderDetails = async (orderId, tokenBase64) => {
224
+ const result = await query({
225
+ tag: 'iq',
226
+ attrs: {
227
+ to: index_js_2.S_WHATSAPP_NET,
228
+ type: 'get',
229
+ xmlns: 'fb:thrift_iq',
230
+ smax_id: '5'
231
+ },
232
+ content: [
233
+ {
234
+ tag: 'order',
235
+ attrs: {
236
+ op: 'get',
237
+ id: orderId
238
+ },
239
+ content: [
240
+ {
241
+ tag: 'image_dimensions',
242
+ attrs: {},
243
+ content: [
244
+ {
245
+ tag: 'width',
246
+ attrs: {},
247
+ content: Buffer.from('100')
248
+ },
249
+ {
250
+ tag: 'height',
251
+ attrs: {},
252
+ content: Buffer.from('100')
253
+ }
254
+ ]
255
+ },
256
+ {
257
+ tag: 'token',
258
+ attrs: {},
259
+ content: Buffer.from(tokenBase64)
260
+ }
261
+ ]
262
+ }
263
+ ]
264
+ });
265
+ return (0, business_js_1.parseOrderDetailsNode)(result);
266
+ };
267
+ const productUpdate = async (productId, update) => {
268
+ update = await (0, business_js_1.uploadingNecessaryImagesOfProduct)(update, waUploadToServer);
269
+ const editNode = (0, business_js_1.toProductNode)(productId, update);
270
+ const result = await query({
271
+ tag: 'iq',
272
+ attrs: {
273
+ to: index_js_2.S_WHATSAPP_NET,
274
+ type: 'set',
275
+ xmlns: 'w:biz:catalog'
276
+ },
277
+ content: [
278
+ {
279
+ tag: 'product_catalog_edit',
280
+ attrs: { v: '1' },
281
+ content: [
282
+ editNode,
283
+ {
284
+ tag: 'width',
285
+ attrs: {},
286
+ content: '100'
287
+ },
288
+ {
289
+ tag: 'height',
290
+ attrs: {},
291
+ content: '100'
292
+ }
293
+ ]
294
+ }
295
+ ]
296
+ });
297
+ const productCatalogEditNode = (0, generic_utils_js_1.getBinaryNodeChild)(result, 'product_catalog_edit');
298
+ const productNode = (0, generic_utils_js_1.getBinaryNodeChild)(productCatalogEditNode, 'product');
299
+ return (0, business_js_1.parseProductNode)(productNode);
300
+ };
301
+ const productCreate = async (create) => {
302
+ // ensure isHidden is defined
303
+ create.isHidden = !!create.isHidden;
304
+ create = await (0, business_js_1.uploadingNecessaryImagesOfProduct)(create, waUploadToServer);
305
+ const createNode = (0, business_js_1.toProductNode)(undefined, create);
306
+ const result = await query({
307
+ tag: 'iq',
308
+ attrs: {
309
+ to: index_js_2.S_WHATSAPP_NET,
310
+ type: 'set',
311
+ xmlns: 'w:biz:catalog'
312
+ },
313
+ content: [
314
+ {
315
+ tag: 'product_catalog_add',
316
+ attrs: { v: '1' },
317
+ content: [
318
+ createNode,
319
+ {
320
+ tag: 'width',
321
+ attrs: {},
322
+ content: '100'
323
+ },
324
+ {
325
+ tag: 'height',
326
+ attrs: {},
327
+ content: '100'
328
+ }
329
+ ]
330
+ }
331
+ ]
332
+ });
333
+ const productCatalogAddNode = (0, generic_utils_js_1.getBinaryNodeChild)(result, 'product_catalog_add');
334
+ const productNode = (0, generic_utils_js_1.getBinaryNodeChild)(productCatalogAddNode, 'product');
335
+ return (0, business_js_1.parseProductNode)(productNode);
336
+ };
337
+ const productDelete = async (productIds) => {
338
+ const result = await query({
339
+ tag: 'iq',
340
+ attrs: {
341
+ to: index_js_2.S_WHATSAPP_NET,
342
+ type: 'set',
343
+ xmlns: 'w:biz:catalog'
344
+ },
345
+ content: [
346
+ {
347
+ tag: 'product_catalog_delete',
348
+ attrs: { v: '1' },
349
+ content: productIds.map(id => ({
350
+ tag: 'product',
351
+ attrs: {},
352
+ content: [
353
+ {
354
+ tag: 'id',
355
+ attrs: {},
356
+ content: Buffer.from(id)
357
+ }
358
+ ]
359
+ }))
360
+ }
361
+ ]
362
+ });
363
+ const productCatalogDelNode = (0, generic_utils_js_1.getBinaryNodeChild)(result, 'product_catalog_delete');
364
+ return {
365
+ deleted: +(productCatalogDelNode?.attrs.deleted_count || 0)
366
+ };
367
+ };
368
+ return {
369
+ ...sock,
370
+ logger: config.logger,
371
+ getOrderDetails,
372
+ getCatalog,
373
+ getCollections,
374
+ productCreate,
375
+ productDelete,
376
+ productUpdate,
377
+ updateBussinesProfile,
378
+ updateCoverPhoto,
379
+ removeCoverPhoto
380
+ };
381
+ };
382
+ exports.makeBusinessSocket = makeBusinessSocket;
@@ -0,0 +1,111 @@
1
+ import { Boom } from '@hapi/boom';
2
+ import { proto } from '../../WAProto/index.js';
3
+ import type { BotListInfo, 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';
8
+ export declare const makeChatsSocket: (config: SocketConfig) => {
9
+ createCallLink: (type: "audio" | "video", event?: {
10
+ startTime: number;
11
+ }, timeoutMs?: number) => Promise<string | undefined>;
12
+ getBotListV2: () => Promise<BotListInfo[]>;
13
+ messageMutex: {
14
+ mutex<T>(code: () => Promise<T> | T): Promise<T>;
15
+ };
16
+ receiptMutex: {
17
+ mutex<T>(code: () => Promise<T> | T): Promise<T>;
18
+ };
19
+ appStatePatchMutex: {
20
+ mutex<T>(code: () => Promise<T> | T): Promise<T>;
21
+ };
22
+ notificationMutex: {
23
+ mutex<T>(code: () => Promise<T> | T): Promise<T>;
24
+ };
25
+ fetchPrivacySettings: (force?: boolean) => Promise<{
26
+ [_: string]: string;
27
+ }>;
28
+ upsertMessage: (msg: WAMessage, type: MessageUpsertType) => Promise<void>;
29
+ appPatch: (patchCreate: WAPatchCreate) => Promise<void>;
30
+ sendPresenceUpdate: (type: WAPresence, toJid?: string) => Promise<void>;
31
+ presenceSubscribe: (toJid: string) => Promise<void>;
32
+ profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
33
+ fetchBlocklist: () => Promise<(string | undefined)[]>;
34
+ fetchStatus: (...jids: string[]) => Promise<import("../WAUSync/index.js").USyncQueryResultList[] | undefined>;
35
+ fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync/index.js").USyncQueryResultList[] | undefined>;
36
+ updateProfilePicture: (jid: string, content: WAMediaUpload, dimensions?: {
37
+ width: number;
38
+ height: number;
39
+ }) => Promise<void>;
40
+ removeProfilePicture: (jid: string) => Promise<void>;
41
+ updateProfileStatus: (status: string) => Promise<void>;
42
+ updateProfileName: (name: string) => Promise<void>;
43
+ updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
44
+ updateDisableLinkPreviewsPrivacy: (isPreviewsDisabled: boolean) => Promise<void>;
45
+ updateCallPrivacy: (value: WAPrivacyCallValue) => Promise<void>;
46
+ updateMessagesPrivacy: (value: WAPrivacyMessagesValue) => Promise<void>;
47
+ updateLastSeenPrivacy: (value: WAPrivacyValue) => Promise<void>;
48
+ updateOnlinePrivacy: (value: WAPrivacyOnlineValue) => Promise<void>;
49
+ updateProfilePicturePrivacy: (value: WAPrivacyValue) => Promise<void>;
50
+ updateStatusPrivacy: (value: WAPrivacyValue) => Promise<void>;
51
+ updateReadReceiptsPrivacy: (value: WAReadReceiptsValue) => Promise<void>;
52
+ updateGroupsAddPrivacy: (value: WAPrivacyGroupAddValue) => Promise<void>;
53
+ updateDefaultDisappearingMode: (duration: number) => Promise<void>;
54
+ getBusinessProfile: (jid: string) => Promise<WABusinessProfile | void>;
55
+ resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
56
+ chatModify: (mod: ChatModification, jid: string) => Promise<void>;
57
+ cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
58
+ addOrEditContact: (jid: string, contact: proto.SyncActionValue.IContactAction) => Promise<void>;
59
+ removeContact: (jid: string) => Promise<void>;
60
+ addLabel: (jid: string, labels: LabelActionBody) => Promise<void>;
61
+ addChatLabel: (jid: string, labelId: string) => Promise<void>;
62
+ removeChatLabel: (jid: string, labelId: string) => Promise<void>;
63
+ addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
64
+ removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
65
+ star: (jid: string, messages: {
66
+ id: string;
67
+ fromMe?: boolean;
68
+ }[], star: boolean) => Promise<void>;
69
+ addOrEditQuickReply: (quickReply: QuickReplyAction) => Promise<void>;
70
+ removeQuickReply: (timestamp: string) => Promise<void>;
71
+ type: "md";
72
+ ws: import("./Client/websocket.js").WebSocketClient;
73
+ ev: import("../Types/index.js").BaileysEventEmitter & {
74
+ process(handler: (events: Partial<import("../Types/index.js").BaileysEventMap>) => void | Promise<void>): () => void;
75
+ buffer(): void;
76
+ createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T>;
77
+ flush(): boolean;
78
+ isBuffering(): boolean;
79
+ };
80
+ authState: {
81
+ creds: import("../Types/index.js").AuthenticationCreds;
82
+ keys: import("../Types/index.js").SignalKeyStoreWithTransaction;
83
+ };
84
+ signalRepository: import("../Types/index.js").SignalRepositoryWithLIDStore;
85
+ user: import("../Types/index.js").Contact | undefined;
86
+ generateMessageTag: () => string;
87
+ query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
88
+ waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<T | undefined>;
89
+ waitForSocketOpen: () => Promise<void>;
90
+ sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
91
+ sendNode: (frame: BinaryNode) => Promise<void>;
92
+ logout: (msg?: string) => Promise<void>;
93
+ end: (error: Error | undefined) => Promise<void>;
94
+ onUnexpectedError: (err: Error | Boom, msg: string) => void;
95
+ uploadPreKeys: (count?: number, retryCount?: number) => Promise<void>;
96
+ uploadPreKeysToServerIfRequired: () => Promise<void>;
97
+ digestKeyBundle: () => Promise<void>;
98
+ rotateSignedPreKey: () => Promise<void>;
99
+ requestPairingCode: (phoneNumber: string, customPairingCode?: string) => Promise<string>;
100
+ updateServerTimeOffset: ({ attrs }: BinaryNode) => void;
101
+ sendUnifiedSession: () => Promise<void>;
102
+ wamBuffer: import("../index.js").BinaryInfo;
103
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types/index.js").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
104
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
105
+ executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync/index.js").USyncQueryResult | undefined>;
106
+ onWhatsApp: (...phoneNumber: string[]) => Promise<{
107
+ jid: string;
108
+ exists: boolean;
109
+ }[] | undefined>;
110
+ };
111
+ //# sourceMappingURL=chats.d.ts.map