@vanzxy/baileys 1.4.8 → 1.5.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.

Potentially problematic release.


This version of @vanzxy/baileys might be problematic. Click here for more details.

Files changed (113) hide show
  1. package/README.md +10 -0
  2. package/lib/Utils/MessageBuilder.js +56 -28
  3. package/package.json +3 -5
  4. package/cjs/WAProto/index.js +0 -106053
  5. package/cjs/lib/Defaults/index.js +0 -168
  6. package/cjs/lib/Signal/Group/ciphertext-message.js +0 -16
  7. package/cjs/lib/Signal/Group/group-session-builder.js +0 -67
  8. package/cjs/lib/Signal/Group/group_cipher.js +0 -86
  9. package/cjs/lib/Signal/Group/index.js +0 -58
  10. package/cjs/lib/Signal/Group/keyhelper.js +0 -56
  11. package/cjs/lib/Signal/Group/sender-chain-key.js +0 -30
  12. package/cjs/lib/Signal/Group/sender-key-distribution-message.js +0 -67
  13. package/cjs/lib/Signal/Group/sender-key-message.js +0 -70
  14. package/cjs/lib/Signal/Group/sender-key-name.js +0 -52
  15. package/cjs/lib/Signal/Group/sender-key-record.js +0 -45
  16. package/cjs/lib/Signal/Group/sender-key-state.js +0 -88
  17. package/cjs/lib/Signal/Group/sender-message-key.js +0 -30
  18. package/cjs/lib/Signal/libsignal.js +0 -467
  19. package/cjs/lib/Signal/lid-mapping.js +0 -281
  20. package/cjs/lib/Socket/Client/index.js +0 -19
  21. package/cjs/lib/Socket/Client/types.js +0 -15
  22. package/cjs/lib/Socket/Client/websocket.js +0 -61
  23. package/cjs/lib/Socket/business.js +0 -384
  24. package/cjs/lib/Socket/chats.js +0 -1257
  25. package/cjs/lib/Socket/communities.js +0 -442
  26. package/cjs/lib/Socket/dugong.js +0 -753
  27. package/cjs/lib/Socket/groups.js +0 -360
  28. package/cjs/lib/Socket/index.js +0 -30
  29. package/cjs/lib/Socket/messages-recv.js +0 -1790
  30. package/cjs/lib/Socket/messages-send.js +0 -1390
  31. package/cjs/lib/Socket/mex.js +0 -46
  32. package/cjs/lib/Socket/newsletter.js +0 -340
  33. package/cjs/lib/Socket/socket.js +0 -1007
  34. package/cjs/lib/Store/index.js +0 -20
  35. package/cjs/lib/Store/make-in-memory-store.js +0 -438
  36. package/cjs/lib/Store/make-ordered-dictionary.js +0 -82
  37. package/cjs/lib/Store/object-repository.js +0 -28
  38. package/cjs/lib/Types/Auth.js +0 -3
  39. package/cjs/lib/Types/Bussines.js +0 -3
  40. package/cjs/lib/Types/Call.js +0 -3
  41. package/cjs/lib/Types/Chat.js +0 -11
  42. package/cjs/lib/Types/Contact.js +0 -3
  43. package/cjs/lib/Types/Events.js +0 -4
  44. package/cjs/lib/Types/GroupMetadata.js +0 -3
  45. package/cjs/lib/Types/Label.js +0 -26
  46. package/cjs/lib/Types/LabelAssociation.js +0 -8
  47. package/cjs/lib/Types/Message.js +0 -19
  48. package/cjs/lib/Types/Mex.js +0 -40
  49. package/cjs/lib/Types/Product.js +0 -3
  50. package/cjs/lib/Types/RichType.js +0 -24
  51. package/cjs/lib/Types/Signal.js +0 -4
  52. package/cjs/lib/Types/Socket.js +0 -4
  53. package/cjs/lib/Types/State.js +0 -54
  54. package/cjs/lib/Types/USync.js +0 -4
  55. package/cjs/lib/Types/index.js +0 -42
  56. package/cjs/lib/Utils/MessageBuilder.js +0 -2684
  57. package/cjs/lib/Utils/auth-utils.js +0 -312
  58. package/cjs/lib/Utils/browser-utils.js +0 -32
  59. package/cjs/lib/Utils/business.js +0 -245
  60. package/cjs/lib/Utils/chat-utils.js +0 -940
  61. package/cjs/lib/Utils/companion-reg-client-utils.js +0 -45
  62. package/cjs/lib/Utils/crypto.js +0 -202
  63. package/cjs/lib/Utils/decode-wa-message.js +0 -324
  64. package/cjs/lib/Utils/event-buffer.js +0 -643
  65. package/cjs/lib/Utils/generics.js +0 -429
  66. package/cjs/lib/Utils/history.js +0 -151
  67. package/cjs/lib/Utils/identity-change-handler.js +0 -56
  68. package/cjs/lib/Utils/index.js +0 -42
  69. package/cjs/lib/Utils/link-preview.js +0 -122
  70. package/cjs/lib/Utils/logger.js +0 -8
  71. package/cjs/lib/Utils/lt-hash.js +0 -64
  72. package/cjs/lib/Utils/make-mutex.js +0 -38
  73. package/cjs/lib/Utils/message-retry-manager.js +0 -267
  74. package/cjs/lib/Utils/messages-media.js +0 -933
  75. package/cjs/lib/Utils/messages.js +0 -2180
  76. package/cjs/lib/Utils/noise-handler.js +0 -205
  77. package/cjs/lib/Utils/offline-node-processor.js +0 -43
  78. package/cjs/lib/Utils/pre-key-manager.js +0 -113
  79. package/cjs/lib/Utils/process-message.js +0 -772
  80. package/cjs/lib/Utils/reporting-utils.js +0 -263
  81. package/cjs/lib/Utils/rich-message-utils.js +0 -439
  82. package/cjs/lib/Utils/signal.js +0 -214
  83. package/cjs/lib/Utils/stanza-ack.js +0 -41
  84. package/cjs/lib/Utils/sync-action-utils.js +0 -54
  85. package/cjs/lib/Utils/tc-token-utils.js +0 -174
  86. package/cjs/lib/Utils/use-multi-file-auth-state.js +0 -125
  87. package/cjs/lib/Utils/use-single-file-auth-state.js +0 -121
  88. package/cjs/lib/Utils/use-sqlite-auth-state.js +0 -182
  89. package/cjs/lib/Utils/validate-connection.js +0 -210
  90. package/cjs/lib/WABinary/constants.js +0 -1470
  91. package/cjs/lib/WABinary/decode.js +0 -301
  92. package/cjs/lib/WABinary/encode.js +0 -257
  93. package/cjs/lib/WABinary/generic-utils.js +0 -275
  94. package/cjs/lib/WABinary/index.js +0 -22
  95. package/cjs/lib/WABinary/jid-utils.js +0 -114
  96. package/cjs/lib/WABinary/types.js +0 -37
  97. package/cjs/lib/WAM/BinaryInfo.js +0 -14
  98. package/cjs/lib/WAM/constants.js +0 -22856
  99. package/cjs/lib/WAM/encode.js +0 -154
  100. package/cjs/lib/WAM/index.js +0 -20
  101. package/cjs/lib/WAUSync/Protocols/USyncContactProtocol.js +0 -56
  102. package/cjs/lib/WAUSync/Protocols/USyncDeviceProtocol.js +0 -67
  103. package/cjs/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -31
  104. package/cjs/lib/WAUSync/Protocols/USyncStatusProtocol.js +0 -42
  105. package/cjs/lib/WAUSync/Protocols/USyncUsernameProtocol.js +0 -29
  106. package/cjs/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +0 -55
  107. package/cjs/lib/WAUSync/Protocols/UsyncLIDProtocol.js +0 -33
  108. package/cjs/lib/WAUSync/Protocols/index.js +0 -24
  109. package/cjs/lib/WAUSync/USyncQuery.js +0 -126
  110. package/cjs/lib/WAUSync/USyncUser.js +0 -35
  111. package/cjs/lib/WAUSync/index.js +0 -20
  112. package/cjs/lib/index.js +0 -34
  113. package/cjs/package.json +0 -1
@@ -1,384 +0,0 @@
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
- updateBusinessProfile: updateBussinesProfile,
379
- updateCoverPhoto,
380
- removeCoverPhoto
381
- };
382
- };
383
- exports.makeBusinessSocket = makeBusinessSocket;
384
- //# sourceMappingURL=business.js.map