violetics 7.0.1-alpha → 7.0.2-alpha
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.
- package/LICENSE +3 -2
- package/README.md +1001 -232
- package/WAProto/index.js +75379 -142631
- package/engine-requirements.js +11 -8
- package/lib/Defaults/index.js +132 -146
- package/lib/Signal/Group/ciphertext-message.js +2 -6
- package/lib/Signal/Group/group-session-builder.js +7 -42
- package/lib/Signal/Group/group_cipher.js +37 -52
- package/lib/Signal/Group/index.js +11 -57
- package/lib/Signal/Group/keyhelper.js +7 -45
- package/lib/Signal/Group/sender-chain-key.js +7 -16
- package/lib/Signal/Group/sender-key-distribution-message.js +8 -12
- package/lib/Signal/Group/sender-key-message.js +9 -13
- package/lib/Signal/Group/sender-key-name.js +2 -6
- package/lib/Signal/Group/sender-key-record.js +9 -22
- package/lib/Signal/Group/sender-key-state.js +27 -43
- package/lib/Signal/Group/sender-message-key.js +4 -8
- package/lib/Signal/libsignal.js +319 -94
- package/lib/Signal/lid-mapping.js +224 -139
- package/lib/Socket/Client/index.js +2 -19
- package/lib/Socket/Client/types.js +10 -0
- package/lib/Socket/Client/websocket.js +53 -0
- package/lib/Socket/business.js +162 -44
- package/lib/Socket/chats.js +477 -418
- package/lib/Socket/communities.js +430 -0
- package/lib/Socket/groups.js +110 -99
- package/lib/Socket/index.js +10 -10
- package/lib/Socket/messages-recv.js +884 -561
- package/lib/Socket/messages-send.js +859 -428
- package/lib/Socket/mex.js +41 -0
- package/lib/Socket/newsletter.js +195 -390
- package/lib/Socket/socket.js +465 -315
- package/lib/Store/index.js +3 -10
- package/lib/Store/make-in-memory-store.js +73 -79
- package/lib/Store/make-ordered-dictionary.js +4 -7
- package/lib/Store/object-repository.js +2 -6
- package/lib/Types/Auth.js +1 -2
- package/lib/Types/Bussines.js +1 -0
- package/lib/Types/Call.js +1 -2
- package/lib/Types/Chat.js +7 -4
- package/lib/Types/Contact.js +1 -2
- package/lib/Types/Events.js +1 -2
- package/lib/Types/GroupMetadata.js +1 -2
- package/lib/Types/Label.js +2 -5
- package/lib/Types/LabelAssociation.js +2 -5
- package/lib/Types/Message.js +17 -9
- package/lib/Types/Newsletter.js +33 -38
- package/lib/Types/Product.js +1 -2
- package/lib/Types/Signal.js +1 -2
- package/lib/Types/Socket.js +2 -2
- package/lib/Types/State.js +12 -2
- package/lib/Types/USync.js +1 -2
- package/lib/Types/index.js +14 -31
- package/lib/Utils/auth-utils.js +228 -152
- package/lib/Utils/browser-utils.js +28 -0
- package/lib/Utils/business.js +66 -70
- package/lib/Utils/chat-utils.js +331 -249
- package/lib/Utils/crypto.js +57 -91
- package/lib/Utils/decode-wa-message.js +168 -84
- package/lib/Utils/event-buffer.js +138 -80
- package/lib/Utils/generics.js +180 -297
- package/lib/Utils/history.js +83 -49
- package/lib/Utils/identity-change-handler.js +48 -0
- package/lib/Utils/index.js +19 -33
- package/lib/Utils/link-preview.js +14 -23
- package/lib/Utils/logger.js +2 -7
- package/lib/Utils/lt-hash.js +2 -46
- package/lib/Utils/make-mutex.js +24 -47
- package/lib/Utils/message-retry-manager.js +224 -0
- package/lib/Utils/messages-media.js +501 -496
- package/lib/Utils/messages.js +1428 -362
- package/lib/Utils/noise-handler.js +145 -100
- package/lib/Utils/pre-key-manager.js +105 -0
- package/lib/Utils/process-message.js +356 -150
- package/lib/Utils/reporting-utils.js +257 -0
- package/lib/Utils/signal.js +78 -73
- package/lib/Utils/sync-action-utils.js +47 -0
- package/lib/Utils/tc-token-utils.js +17 -0
- package/lib/Utils/use-multi-file-auth-state.js +35 -45
- package/lib/Utils/validate-connection.js +91 -107
- package/lib/WABinary/constants.js +1300 -1304
- package/lib/WABinary/decode.js +26 -48
- package/lib/WABinary/encode.js +109 -155
- package/lib/WABinary/generic-utils.js +161 -149
- package/lib/WABinary/index.js +5 -21
- package/lib/WABinary/jid-utils.js +73 -40
- package/lib/WABinary/types.js +1 -2
- package/lib/WAM/BinaryInfo.js +2 -6
- package/lib/WAM/constants.js +19070 -11568
- package/lib/WAM/encode.js +17 -23
- package/lib/WAM/index.js +3 -19
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +8 -12
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +11 -15
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +9 -13
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +9 -14
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +20 -23
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +13 -9
- package/lib/WAUSync/Protocols/index.js +4 -20
- package/lib/WAUSync/USyncQuery.js +40 -36
- package/lib/WAUSync/USyncUser.js +2 -6
- package/lib/WAUSync/index.js +3 -19
- package/lib/index.js +11 -44
- package/package.json +74 -107
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Signal/Group/queue-job.js +0 -57
- package/lib/Socket/Client/abstract-socket-client.js +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/Client/web-socket-client.js +0 -118
- package/lib/Socket/groupStatus.js +0 -637
- package/lib/Socket/registration.js +0 -166
- package/lib/Socket/usync.js +0 -70
- package/lib/Store/make-cache-manager-store.js +0 -83
- package/lib/Utils/baileys-event-stream.js +0 -63
package/lib/Socket/business.js
CHANGED
|
@@ -1,17 +1,134 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const makeBusinessSocket = (config) => {
|
|
9
|
-
const sock = (0, messages_recv_1.makeMessagesRecvSocket)(config);
|
|
1
|
+
import { getRawMediaUploadData } from '../Utils/index.js';
|
|
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
|
+
export const makeBusinessSocket = (config) => {
|
|
7
|
+
const sock = makeMessagesRecvSocket(config);
|
|
10
8
|
const { authState, query, waUploadToServer } = sock;
|
|
9
|
+
const updateBussinesProfile = async (args) => {
|
|
10
|
+
const node = [];
|
|
11
|
+
const simpleFields = ['address', 'email', 'description'];
|
|
12
|
+
node.push(...simpleFields
|
|
13
|
+
.filter(key => args[key] !== undefined && args[key] !== null)
|
|
14
|
+
.map(key => ({
|
|
15
|
+
tag: key,
|
|
16
|
+
attrs: {},
|
|
17
|
+
content: args[key]
|
|
18
|
+
})));
|
|
19
|
+
if (args.websites !== undefined) {
|
|
20
|
+
node.push(...args.websites.map(website => ({
|
|
21
|
+
tag: 'website',
|
|
22
|
+
attrs: {},
|
|
23
|
+
content: website
|
|
24
|
+
})));
|
|
25
|
+
}
|
|
26
|
+
if (args.hours !== undefined) {
|
|
27
|
+
node.push({
|
|
28
|
+
tag: 'business_hours',
|
|
29
|
+
attrs: { timezone: args.hours.timezone },
|
|
30
|
+
content: args.hours.days.map(dayConfig => {
|
|
31
|
+
const base = {
|
|
32
|
+
tag: 'business_hours_config',
|
|
33
|
+
attrs: {
|
|
34
|
+
day_of_week: dayConfig.day,
|
|
35
|
+
mode: dayConfig.mode
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
if (dayConfig.mode === 'specific_hours') {
|
|
39
|
+
return {
|
|
40
|
+
...base,
|
|
41
|
+
attrs: {
|
|
42
|
+
...base.attrs,
|
|
43
|
+
open_time: dayConfig.openTimeInMinutes,
|
|
44
|
+
close_time: dayConfig.closeTimeInMinutes
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return base;
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const result = await query({
|
|
53
|
+
tag: 'iq',
|
|
54
|
+
attrs: {
|
|
55
|
+
to: S_WHATSAPP_NET,
|
|
56
|
+
type: 'set',
|
|
57
|
+
xmlns: 'w:biz'
|
|
58
|
+
},
|
|
59
|
+
content: [
|
|
60
|
+
{
|
|
61
|
+
tag: 'business_profile',
|
|
62
|
+
attrs: {
|
|
63
|
+
v: '3',
|
|
64
|
+
mutation_type: 'delta'
|
|
65
|
+
},
|
|
66
|
+
content: node
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
});
|
|
70
|
+
return result;
|
|
71
|
+
};
|
|
72
|
+
const updateCoverPhoto = async (photo) => {
|
|
73
|
+
const { fileSha256, filePath } = await getRawMediaUploadData(photo, 'biz-cover-photo');
|
|
74
|
+
const fileSha256B64 = fileSha256.toString('base64');
|
|
75
|
+
const { meta_hmac, fbid, ts } = await waUploadToServer(filePath, {
|
|
76
|
+
fileEncSha256B64: fileSha256B64,
|
|
77
|
+
mediaType: 'biz-cover-photo'
|
|
78
|
+
});
|
|
79
|
+
await query({
|
|
80
|
+
tag: 'iq',
|
|
81
|
+
attrs: {
|
|
82
|
+
to: S_WHATSAPP_NET,
|
|
83
|
+
type: 'set',
|
|
84
|
+
xmlns: 'w:biz'
|
|
85
|
+
},
|
|
86
|
+
content: [
|
|
87
|
+
{
|
|
88
|
+
tag: 'business_profile',
|
|
89
|
+
attrs: {
|
|
90
|
+
v: '3',
|
|
91
|
+
mutation_type: 'delta'
|
|
92
|
+
},
|
|
93
|
+
content: [
|
|
94
|
+
{
|
|
95
|
+
tag: 'cover_photo',
|
|
96
|
+
attrs: { id: String(fbid), op: 'update', token: meta_hmac, ts: String(ts) }
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
});
|
|
102
|
+
return fbid;
|
|
103
|
+
};
|
|
104
|
+
const removeCoverPhoto = async (id) => {
|
|
105
|
+
return await query({
|
|
106
|
+
tag: 'iq',
|
|
107
|
+
attrs: {
|
|
108
|
+
to: S_WHATSAPP_NET,
|
|
109
|
+
type: 'set',
|
|
110
|
+
xmlns: 'w:biz'
|
|
111
|
+
},
|
|
112
|
+
content: [
|
|
113
|
+
{
|
|
114
|
+
tag: 'business_profile',
|
|
115
|
+
attrs: {
|
|
116
|
+
v: '3',
|
|
117
|
+
mutation_type: 'delta'
|
|
118
|
+
},
|
|
119
|
+
content: [
|
|
120
|
+
{
|
|
121
|
+
tag: 'cover_photo',
|
|
122
|
+
attrs: { op: 'delete', id }
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
});
|
|
128
|
+
};
|
|
11
129
|
const getCatalog = async ({ jid, limit, cursor }) => {
|
|
12
|
-
|
|
13
|
-
jid = jid
|
|
14
|
-
jid = (0, WABinary_1.jidNormalizedUser)(jid);
|
|
130
|
+
jid = jid || authState.creds.me?.id;
|
|
131
|
+
jid = jidNormalizedUser(jid);
|
|
15
132
|
const queryParamNodes = [
|
|
16
133
|
{
|
|
17
134
|
tag: 'limit',
|
|
@@ -27,7 +144,7 @@ const makeBusinessSocket = (config) => {
|
|
|
27
144
|
tag: 'height',
|
|
28
145
|
attrs: {},
|
|
29
146
|
content: Buffer.from('100')
|
|
30
|
-
}
|
|
147
|
+
}
|
|
31
148
|
];
|
|
32
149
|
if (cursor) {
|
|
33
150
|
queryParamNodes.push({
|
|
@@ -39,7 +156,7 @@ const makeBusinessSocket = (config) => {
|
|
|
39
156
|
const result = await query({
|
|
40
157
|
tag: 'iq',
|
|
41
158
|
attrs: {
|
|
42
|
-
to:
|
|
159
|
+
to: S_WHATSAPP_NET,
|
|
43
160
|
type: 'get',
|
|
44
161
|
xmlns: 'w:biz:catalog'
|
|
45
162
|
},
|
|
@@ -48,31 +165,30 @@ const makeBusinessSocket = (config) => {
|
|
|
48
165
|
tag: 'product_catalog',
|
|
49
166
|
attrs: {
|
|
50
167
|
jid,
|
|
51
|
-
|
|
168
|
+
allow_shop_source: 'true'
|
|
52
169
|
},
|
|
53
170
|
content: queryParamNodes
|
|
54
171
|
}
|
|
55
172
|
]
|
|
56
173
|
});
|
|
57
|
-
return
|
|
174
|
+
return parseCatalogNode(result);
|
|
58
175
|
};
|
|
59
176
|
const getCollections = async (jid, limit = 51) => {
|
|
60
|
-
|
|
61
|
-
jid = jid
|
|
62
|
-
jid = (0, WABinary_1.jidNormalizedUser)(jid);
|
|
177
|
+
jid = jid || authState.creds.me?.id;
|
|
178
|
+
jid = jidNormalizedUser(jid);
|
|
63
179
|
const result = await query({
|
|
64
180
|
tag: 'iq',
|
|
65
181
|
attrs: {
|
|
66
|
-
to:
|
|
182
|
+
to: S_WHATSAPP_NET,
|
|
67
183
|
type: 'get',
|
|
68
184
|
xmlns: 'w:biz:catalog',
|
|
69
|
-
|
|
185
|
+
smax_id: '35'
|
|
70
186
|
},
|
|
71
187
|
content: [
|
|
72
188
|
{
|
|
73
189
|
tag: 'collections',
|
|
74
190
|
attrs: {
|
|
75
|
-
|
|
191
|
+
biz_jid: jid
|
|
76
192
|
},
|
|
77
193
|
content: [
|
|
78
194
|
{
|
|
@@ -99,16 +215,16 @@ const makeBusinessSocket = (config) => {
|
|
|
99
215
|
}
|
|
100
216
|
]
|
|
101
217
|
});
|
|
102
|
-
return
|
|
218
|
+
return parseCollectionsNode(result);
|
|
103
219
|
};
|
|
104
220
|
const getOrderDetails = async (orderId, tokenBase64) => {
|
|
105
221
|
const result = await query({
|
|
106
222
|
tag: 'iq',
|
|
107
223
|
attrs: {
|
|
108
|
-
to:
|
|
224
|
+
to: S_WHATSAPP_NET,
|
|
109
225
|
type: 'get',
|
|
110
226
|
xmlns: 'fb:thrift_iq',
|
|
111
|
-
|
|
227
|
+
smax_id: '5'
|
|
112
228
|
},
|
|
113
229
|
content: [
|
|
114
230
|
{
|
|
@@ -143,15 +259,15 @@ const makeBusinessSocket = (config) => {
|
|
|
143
259
|
}
|
|
144
260
|
]
|
|
145
261
|
});
|
|
146
|
-
return
|
|
262
|
+
return parseOrderDetailsNode(result);
|
|
147
263
|
};
|
|
148
264
|
const productUpdate = async (productId, update) => {
|
|
149
|
-
update = await
|
|
150
|
-
const editNode =
|
|
265
|
+
update = await uploadingNecessaryImagesOfProduct(update, waUploadToServer);
|
|
266
|
+
const editNode = toProductNode(productId, update);
|
|
151
267
|
const result = await query({
|
|
152
268
|
tag: 'iq',
|
|
153
269
|
attrs: {
|
|
154
|
-
to:
|
|
270
|
+
to: S_WHATSAPP_NET,
|
|
155
271
|
type: 'set',
|
|
156
272
|
xmlns: 'w:biz:catalog'
|
|
157
273
|
},
|
|
@@ -175,19 +291,19 @@ const makeBusinessSocket = (config) => {
|
|
|
175
291
|
}
|
|
176
292
|
]
|
|
177
293
|
});
|
|
178
|
-
const productCatalogEditNode =
|
|
179
|
-
const productNode =
|
|
180
|
-
return
|
|
294
|
+
const productCatalogEditNode = getBinaryNodeChild(result, 'product_catalog_edit');
|
|
295
|
+
const productNode = getBinaryNodeChild(productCatalogEditNode, 'product');
|
|
296
|
+
return parseProductNode(productNode);
|
|
181
297
|
};
|
|
182
298
|
const productCreate = async (create) => {
|
|
183
299
|
// ensure isHidden is defined
|
|
184
300
|
create.isHidden = !!create.isHidden;
|
|
185
|
-
create = await
|
|
186
|
-
const createNode =
|
|
301
|
+
create = await uploadingNecessaryImagesOfProduct(create, waUploadToServer);
|
|
302
|
+
const createNode = toProductNode(undefined, create);
|
|
187
303
|
const result = await query({
|
|
188
304
|
tag: 'iq',
|
|
189
305
|
attrs: {
|
|
190
|
-
to:
|
|
306
|
+
to: S_WHATSAPP_NET,
|
|
191
307
|
type: 'set',
|
|
192
308
|
xmlns: 'w:biz:catalog'
|
|
193
309
|
},
|
|
@@ -211,15 +327,15 @@ const makeBusinessSocket = (config) => {
|
|
|
211
327
|
}
|
|
212
328
|
]
|
|
213
329
|
});
|
|
214
|
-
const productCatalogAddNode =
|
|
215
|
-
const productNode =
|
|
216
|
-
return
|
|
330
|
+
const productCatalogAddNode = getBinaryNodeChild(result, 'product_catalog_add');
|
|
331
|
+
const productNode = getBinaryNodeChild(productCatalogAddNode, 'product');
|
|
332
|
+
return parseProductNode(productNode);
|
|
217
333
|
};
|
|
218
334
|
const productDelete = async (productIds) => {
|
|
219
335
|
const result = await query({
|
|
220
336
|
tag: 'iq',
|
|
221
337
|
attrs: {
|
|
222
|
-
to:
|
|
338
|
+
to: S_WHATSAPP_NET,
|
|
223
339
|
type: 'set',
|
|
224
340
|
xmlns: 'w:biz:catalog'
|
|
225
341
|
},
|
|
@@ -241,9 +357,9 @@ const makeBusinessSocket = (config) => {
|
|
|
241
357
|
}
|
|
242
358
|
]
|
|
243
359
|
});
|
|
244
|
-
const productCatalogDelNode =
|
|
360
|
+
const productCatalogDelNode = getBinaryNodeChild(result, 'product_catalog_delete');
|
|
245
361
|
return {
|
|
246
|
-
deleted: +(
|
|
362
|
+
deleted: +(productCatalogDelNode?.attrs.deleted_count || 0)
|
|
247
363
|
};
|
|
248
364
|
};
|
|
249
365
|
return {
|
|
@@ -254,7 +370,9 @@ const makeBusinessSocket = (config) => {
|
|
|
254
370
|
getCollections,
|
|
255
371
|
productCreate,
|
|
256
372
|
productDelete,
|
|
257
|
-
productUpdate
|
|
373
|
+
productUpdate,
|
|
374
|
+
updateBussinesProfile,
|
|
375
|
+
updateCoverPhoto,
|
|
376
|
+
removeCoverPhoto
|
|
258
377
|
};
|
|
259
|
-
};
|
|
260
|
-
exports.makeBusinessSocket = makeBusinessSocket;
|
|
378
|
+
};
|