@fanzxnothuman/baileys 2.0.17

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 (104) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +479 -0
  3. package/WAProto/index.js +204542 -0
  4. package/engine-requirements.js +10 -0
  5. package/lib/Defaults/baileys-version.json +3 -0
  6. package/lib/Defaults/index.js +158 -0
  7. package/lib/Defaults/phonenumber-mcc.json +223 -0
  8. package/lib/Function/Download/tiktok.js +19 -0
  9. package/lib/Function/Tools/bypass.js +19 -0
  10. package/lib/Function/index.js +13 -0
  11. package/lib/Signal/Group/ciphertext-message.js +15 -0
  12. package/lib/Signal/Group/group-session-builder.js +99 -0
  13. package/lib/Signal/Group/group_cipher.js +131 -0
  14. package/lib/Signal/Group/index.js +141 -0
  15. package/lib/Signal/Group/keyhelper.js +78 -0
  16. package/lib/Signal/Group/queue-job.js +54 -0
  17. package/lib/Signal/Group/sender-chain-key.js +39 -0
  18. package/lib/Signal/Group/sender-key-distribution-message.js +76 -0
  19. package/lib/Signal/Group/sender-key-message.js +86 -0
  20. package/lib/Signal/Group/sender-key-name.js +53 -0
  21. package/lib/Signal/Group/sender-key-record.js +71 -0
  22. package/lib/Signal/Group/sender-key-state.js +123 -0
  23. package/lib/Signal/Group/sender-message-key.js +33 -0
  24. package/lib/Signal/libsignal.js +223 -0
  25. package/lib/Socket/Client/abstract-socket-client.js +13 -0
  26. package/lib/Socket/Client/index.js +35 -0
  27. package/lib/Socket/Client/mobile-socket-client.js +96 -0
  28. package/lib/Socket/Client/web-socket-client.js +96 -0
  29. package/lib/Socket/business.js +289 -0
  30. package/lib/Socket/chats.js +1230 -0
  31. package/lib/Socket/dugong.js +689 -0
  32. package/lib/Socket/groups.js +401 -0
  33. package/lib/Socket/index.js +12 -0
  34. package/lib/Socket/messages-recv.js +1531 -0
  35. package/lib/Socket/messages-send.js +1011 -0
  36. package/lib/Socket/newsletter.js +526 -0
  37. package/lib/Socket/registration.js +212 -0
  38. package/lib/Socket/socket.js +842 -0
  39. package/lib/Socket/usync.js +67 -0
  40. package/lib/Store/index.js +16 -0
  41. package/lib/Store/make-cache-manager-store.js +90 -0
  42. package/lib/Store/make-in-memory-store.js +520 -0
  43. package/lib/Store/make-ordered-dictionary.js +78 -0
  44. package/lib/Store/object-repository.js +27 -0
  45. package/lib/Types/Auth.js +2 -0
  46. package/lib/Types/Call.js +2 -0
  47. package/lib/Types/Chat.js +10 -0
  48. package/lib/Types/Contact.js +2 -0
  49. package/lib/Types/Events.js +2 -0
  50. package/lib/Types/GroupMetadata.js +2 -0
  51. package/lib/Types/Label.js +27 -0
  52. package/lib/Types/LabelAssociation.js +12 -0
  53. package/lib/Types/Message.js +14 -0
  54. package/lib/Types/Newsletter.js +38 -0
  55. package/lib/Types/Product.js +2 -0
  56. package/lib/Types/Signal.js +2 -0
  57. package/lib/Types/Socket.js +2 -0
  58. package/lib/Types/State.js +2 -0
  59. package/lib/Types/USync.js +2 -0
  60. package/lib/Types/index.js +67 -0
  61. package/lib/Utils/auth-utils.js +223 -0
  62. package/lib/Utils/baileys-event-stream.js +67 -0
  63. package/lib/Utils/business.js +308 -0
  64. package/lib/Utils/chat-utils.js +1030 -0
  65. package/lib/Utils/crypto.js +210 -0
  66. package/lib/Utils/decode-wa-message.js +225 -0
  67. package/lib/Utils/event-buffer.js +559 -0
  68. package/lib/Utils/generics.js +599 -0
  69. package/lib/Utils/history.js +132 -0
  70. package/lib/Utils/index.js +49 -0
  71. package/lib/Utils/link-preview.js +112 -0
  72. package/lib/Utils/logger.js +11 -0
  73. package/lib/Utils/lt-hash.js +58 -0
  74. package/lib/Utils/make-mutex.js +41 -0
  75. package/lib/Utils/messages-media.js +978 -0
  76. package/lib/Utils/messages.js +1052 -0
  77. package/lib/Utils/noise-handler.js +185 -0
  78. package/lib/Utils/process-message.js +466 -0
  79. package/lib/Utils/signal.js +199 -0
  80. package/lib/Utils/use-multi-file-auth-state.js +129 -0
  81. package/lib/Utils/validate-connection.js +285 -0
  82. package/lib/WABinary/constants.js +1307 -0
  83. package/lib/WABinary/decode.js +287 -0
  84. package/lib/WABinary/encode.js +286 -0
  85. package/lib/WABinary/generic-utils.js +227 -0
  86. package/lib/WABinary/index.js +37 -0
  87. package/lib/WABinary/jid-utils.js +92 -0
  88. package/lib/WABinary/types.js +2 -0
  89. package/lib/WAM/BinaryInfo.js +13 -0
  90. package/lib/WAM/constants.js +15260 -0
  91. package/lib/WAM/encode.js +153 -0
  92. package/lib/WAM/index.js +35 -0
  93. package/lib/WAUSync/Protocols/USyncContactProtocol.js +37 -0
  94. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +78 -0
  95. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +35 -0
  96. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +53 -0
  97. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +76 -0
  98. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  99. package/lib/WAUSync/Protocols/index.js +36 -0
  100. package/lib/WAUSync/USyncQuery.js +105 -0
  101. package/lib/WAUSync/USyncUser.js +26 -0
  102. package/lib/WAUSync/index.js +35 -0
  103. package/lib/index.js +65 -0
  104. package/package.json +109 -0
@@ -0,0 +1,289 @@
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 =
14
+ jid ||
15
+ ((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.id);
16
+ jid = (0, WABinary_1.jidNormalizedUser)(jid);
17
+ const queryParamNodes = [
18
+ {
19
+ tag: "limit",
20
+ attrs: {},
21
+ content: Buffer.from((limit || 10).toString()),
22
+ },
23
+ {
24
+ tag: "width",
25
+ attrs: {},
26
+ content: Buffer.from("100"),
27
+ },
28
+ {
29
+ tag: "height",
30
+ attrs: {},
31
+ content: Buffer.from("100"),
32
+ },
33
+ ];
34
+ if (cursor) {
35
+ queryParamNodes.push({
36
+ tag: "after",
37
+ attrs: {},
38
+ content: cursor,
39
+ });
40
+ }
41
+ const result = await query({
42
+ tag: "iq",
43
+ attrs: {
44
+ to: WABinary_1.S_WHATSAPP_NET,
45
+ type: "get",
46
+ xmlns: "w:biz:catalog",
47
+ },
48
+ content: [
49
+ {
50
+ tag: "product_catalog",
51
+ attrs: {
52
+ jid,
53
+ allow_shop_source: "true",
54
+ },
55
+ content: queryParamNodes,
56
+ },
57
+ ],
58
+ });
59
+ return (0, business_1.parseCatalogNode)(result);
60
+ };
61
+ const getCollections = async (jid, limit = 51) => {
62
+ var _a;
63
+ jid =
64
+ jid ||
65
+ ((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.id);
66
+ jid = (0, WABinary_1.jidNormalizedUser)(jid);
67
+ const result = await query({
68
+ tag: "iq",
69
+ attrs: {
70
+ to: WABinary_1.S_WHATSAPP_NET,
71
+ type: "get",
72
+ xmlns: "w:biz:catalog",
73
+ smax_id: "35",
74
+ },
75
+ content: [
76
+ {
77
+ tag: "collections",
78
+ attrs: {
79
+ biz_jid: jid,
80
+ },
81
+ content: [
82
+ {
83
+ tag: "collection_limit",
84
+ attrs: {},
85
+ content: Buffer.from(limit.toString()),
86
+ },
87
+ {
88
+ tag: "item_limit",
89
+ attrs: {},
90
+ content: Buffer.from(limit.toString()),
91
+ },
92
+ {
93
+ tag: "width",
94
+ attrs: {},
95
+ content: Buffer.from("100"),
96
+ },
97
+ {
98
+ tag: "height",
99
+ attrs: {},
100
+ content: Buffer.from("100"),
101
+ },
102
+ ],
103
+ },
104
+ ],
105
+ });
106
+ return (0, business_1.parseCollectionsNode)(result);
107
+ };
108
+ const getOrderDetails = async (orderId, tokenBase64) => {
109
+ const result = await query({
110
+ tag: "iq",
111
+ attrs: {
112
+ to: WABinary_1.S_WHATSAPP_NET,
113
+ type: "get",
114
+ xmlns: "fb:thrift_iq",
115
+ smax_id: "5",
116
+ },
117
+ content: [
118
+ {
119
+ tag: "order",
120
+ attrs: {
121
+ op: "get",
122
+ id: orderId,
123
+ },
124
+ content: [
125
+ {
126
+ tag: "image_dimensions",
127
+ attrs: {},
128
+ content: [
129
+ {
130
+ tag: "width",
131
+ attrs: {},
132
+ content: Buffer.from("100"),
133
+ },
134
+ {
135
+ tag: "height",
136
+ attrs: {},
137
+ content: Buffer.from("100"),
138
+ },
139
+ ],
140
+ },
141
+ {
142
+ tag: "token",
143
+ attrs: {},
144
+ content: Buffer.from(tokenBase64),
145
+ },
146
+ ],
147
+ },
148
+ ],
149
+ });
150
+ return (0, business_1.parseOrderDetailsNode)(result);
151
+ };
152
+ const productUpdate = async (productId, update) => {
153
+ update = await (0, business_1.uploadingNecessaryImagesOfProduct)(
154
+ update,
155
+ waUploadToServer,
156
+ );
157
+ const editNode = (0, business_1.toProductNode)(productId, update);
158
+ const result = await query({
159
+ tag: "iq",
160
+ attrs: {
161
+ to: WABinary_1.S_WHATSAPP_NET,
162
+ type: "set",
163
+ xmlns: "w:biz:catalog",
164
+ },
165
+ content: [
166
+ {
167
+ tag: "product_catalog_edit",
168
+ attrs: { v: "1" },
169
+ content: [
170
+ editNode,
171
+ {
172
+ tag: "width",
173
+ attrs: {},
174
+ content: "100",
175
+ },
176
+ {
177
+ tag: "height",
178
+ attrs: {},
179
+ content: "100",
180
+ },
181
+ ],
182
+ },
183
+ ],
184
+ });
185
+ const productCatalogEditNode = (0, generic_utils_1.getBinaryNodeChild)(
186
+ result,
187
+ "product_catalog_edit",
188
+ );
189
+ const productNode = (0, generic_utils_1.getBinaryNodeChild)(
190
+ productCatalogEditNode,
191
+ "product",
192
+ );
193
+ return (0, business_1.parseProductNode)(productNode);
194
+ };
195
+ const productCreate = async (create) => {
196
+ // ensure isHidden is defined
197
+ create.isHidden = !!create.isHidden;
198
+ create = await (0, business_1.uploadingNecessaryImagesOfProduct)(
199
+ create,
200
+ waUploadToServer,
201
+ );
202
+ const createNode = (0, business_1.toProductNode)(undefined, create);
203
+ const result = await query({
204
+ tag: "iq",
205
+ attrs: {
206
+ to: WABinary_1.S_WHATSAPP_NET,
207
+ type: "set",
208
+ xmlns: "w:biz:catalog",
209
+ },
210
+ content: [
211
+ {
212
+ tag: "product_catalog_add",
213
+ attrs: { v: "1" },
214
+ content: [
215
+ createNode,
216
+ {
217
+ tag: "width",
218
+ attrs: {},
219
+ content: "100",
220
+ },
221
+ {
222
+ tag: "height",
223
+ attrs: {},
224
+ content: "100",
225
+ },
226
+ ],
227
+ },
228
+ ],
229
+ });
230
+ const productCatalogAddNode = (0, generic_utils_1.getBinaryNodeChild)(
231
+ result,
232
+ "product_catalog_add",
233
+ );
234
+ const productNode = (0, generic_utils_1.getBinaryNodeChild)(
235
+ productCatalogAddNode,
236
+ "product",
237
+ );
238
+ return (0, business_1.parseProductNode)(productNode);
239
+ };
240
+ const productDelete = async (productIds) => {
241
+ const result = await query({
242
+ tag: "iq",
243
+ attrs: {
244
+ to: WABinary_1.S_WHATSAPP_NET,
245
+ type: "set",
246
+ xmlns: "w:biz:catalog",
247
+ },
248
+ content: [
249
+ {
250
+ tag: "product_catalog_delete",
251
+ attrs: { v: "1" },
252
+ content: productIds.map((id) => ({
253
+ tag: "product",
254
+ attrs: {},
255
+ content: [
256
+ {
257
+ tag: "id",
258
+ attrs: {},
259
+ content: Buffer.from(id),
260
+ },
261
+ ],
262
+ })),
263
+ },
264
+ ],
265
+ });
266
+ const productCatalogDelNode = (0, generic_utils_1.getBinaryNodeChild)(
267
+ result,
268
+ "product_catalog_delete",
269
+ );
270
+ return {
271
+ deleted: +(
272
+ (productCatalogDelNode === null || productCatalogDelNode === void 0
273
+ ? void 0
274
+ : productCatalogDelNode.attrs.deleted_count) || 0
275
+ ),
276
+ };
277
+ };
278
+ return {
279
+ ...sock,
280
+ logger: config.logger,
281
+ getOrderDetails,
282
+ getCatalog,
283
+ getCollections,
284
+ productCreate,
285
+ productDelete,
286
+ productUpdate,
287
+ };
288
+ };
289
+ exports.makeBusinessSocket = makeBusinessSocket;