@hansaka02/baileys 7.3.2 → 7.3.4
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/README.md +247 -203
- package/lib/Defaults/connection.js +51 -0
- package/lib/Defaults/constants.js +62 -0
- package/lib/Defaults/history.js +17 -0
- package/lib/Defaults/index.js +36 -142
- package/lib/Defaults/media.js +48 -0
- package/lib/Defaults/prefix.js +18 -0
- package/lib/Signal/Group/group-session-builder.js +10 -42
- package/lib/Signal/Group/group_cipher.js +9 -6
- package/lib/Signal/Group/index.js +39 -53
- package/lib/Signal/Group/keyhelper.js +8 -41
- package/lib/Signal/Group/sender-chain-key.js +4 -4
- package/lib/Signal/Group/sender-key-distribution-message.js +5 -5
- package/lib/Signal/Group/sender-key-message.js +12 -8
- package/lib/Signal/Group/sender-key-record.js +7 -7
- package/lib/Signal/Group/sender-key-state.js +4 -4
- package/lib/Signal/Group/sender-message-key.js +2 -2
- package/lib/Signal/libsignal.js +45 -69
- package/lib/Signal/lid-mapping.js +15 -11
- package/lib/Socket/Client/types.js +2 -2
- package/lib/Socket/Client/websocket.js +16 -14
- package/lib/Socket/business.js +41 -32
- package/lib/Socket/chats.js +123 -98
- package/lib/Socket/community.js +50 -40
- package/lib/Socket/groups.js +59 -47
- package/lib/Socket/index.js +4 -4
- package/lib/Socket/messages-recv.js +219 -172
- package/lib/Socket/messages-send.js +187 -143
- package/lib/Socket/newsletter.js +61 -47
- package/lib/Socket/socket.js +133 -90
- package/lib/Socket/usync.js +6 -6
- package/lib/Store/index.js +27 -11
- package/lib/Store/make-cache-manager-store.js +14 -15
- package/lib/Store/make-in-memory-store.js +28 -24
- package/lib/Types/LabelAssociation.js +2 -2
- package/lib/Types/Message.js +6 -6
- package/lib/Types/MexUpdates.js +5 -5
- package/lib/Types/State.js +4 -4
- package/lib/Types/index.js +28 -12
- package/lib/Utils/auth-utils.js +28 -26
- package/lib/Utils/baileys-event-stream.js +68 -69
- package/lib/Utils/business.js +63 -53
- package/lib/Utils/chat-utils.js +81 -71
- package/lib/Utils/crypto.js +25 -45
- package/lib/Utils/decode-wa-message.js +319 -311
- package/lib/Utils/event-buffer.js +21 -22
- package/lib/Utils/generics.js +65 -82
- package/lib/Utils/history.js +21 -21
- package/lib/Utils/index.js +27 -13
- package/lib/Utils/link-preview.js +7 -30
- package/lib/Utils/logger.js +5 -5
- package/lib/Utils/lt-hash.js +3 -3
- package/lib/Utils/message-retry-manager.js +4 -4
- package/lib/Utils/messages-media.js +104 -109
- package/lib/Utils/messages.js +203 -171
- package/lib/Utils/noise-handler.js +28 -19
- package/lib/Utils/process-message.js +111 -96
- package/lib/Utils/signal.js +36 -25
- package/lib/Utils/use-multi-file-auth-state.js +18 -22
- package/lib/Utils/validate-connection.js +52 -45
- package/lib/WABinary/decode.js +6 -32
- package/lib/WABinary/encode.js +3 -29
- package/lib/WABinary/generic-utils.js +4 -4
- package/lib/WABinary/index.js +27 -11
- package/lib/WAM/encode.js +16 -8
- package/lib/WAM/index.js +27 -11
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +20 -16
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +7 -4
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +0 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -2
- package/lib/WAUSync/Protocols/index.js +27 -11
- package/lib/WAUSync/USyncQuery.js +17 -10
- package/lib/WAUSync/index.js +27 -11
- package/lib/index.js +60 -31
- package/package.json +8 -14
- package/WAProto/AICommon/AICommon.d.ts +0 -11702
- package/WAProto/Adv/Adv.d.ts +0 -643
- package/WAProto/BotMetadata/BotMetadata.d.ts +0 -5654
- package/WAProto/Cert/Cert.d.ts +0 -613
- package/WAProto/ChatLockSettings/ChatLockSettings.d.ts +0 -476
- package/WAProto/CompanionReg/CompanionReg.d.ts +0 -1361
- package/WAProto/DeviceCapabilities/DeviceCapabilities.d.ts +0 -577
- package/WAProto/E2E/E2E.d.ts +0 -41724
- package/WAProto/Ephemeral/Ephemeral.d.ts +0 -114
- package/WAProto/HistorySync/HistorySync.d.ts +0 -51700
- package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.d.ts +0 -229
- package/WAProto/MdStorageChatRowOpaqueData/MdStorageChatRowOpaqueData.d.ts +0 -583
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.d.ts +0 -42897
- package/WAProto/MmsRetry/MmsRetry.d.ts +0 -243
- package/WAProto/Protocol/Protocol.d.ts +0 -270
- package/WAProto/Reporting/Reporting.d.ts +0 -371
- package/WAProto/ServerSync/ServerSync.d.ts +0 -1285
- package/WAProto/SignalLocalStorageProtocol/SignalLocalStorageProtocol.d.ts +0 -1868
- package/WAProto/SignalWhisperTextProtocol/SignalWhisperTextProtocol.d.ts +0 -767
- package/WAProto/StatusAttributions/StatusAttributions.d.ts +0 -1027
- package/WAProto/SyncAction/SyncAction.d.ts +0 -11193
- package/WAProto/UserPassword/UserPassword.d.ts +0 -363
- package/WAProto/VnameCert/VnameCert.d.ts +0 -821
- package/WAProto/Wa6/Wa6.d.ts +0 -2128
- package/WAProto/Web/Web.d.ts +0 -46383
- package/WAProto/index.d.ts +0 -55
- package/lib/Defaults/index.d.ts +0 -77
- package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
- package/lib/Signal/Group/group-session-builder.d.ts +0 -17
- package/lib/Signal/Group/group_cipher.d.ts +0 -19
- package/lib/Signal/Group/index.d.ts +0 -11
- package/lib/Signal/Group/keyhelper.d.ts +0 -16
- package/lib/Signal/Group/sender-chain-key.d.ts +0 -14
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -17
- package/lib/Signal/Group/sender-key-message.d.ts +0 -19
- package/lib/Signal/Group/sender-key-name.d.ts +0 -19
- package/lib/Signal/Group/sender-key-record.d.ts +0 -32
- package/lib/Signal/Group/sender-key-state.d.ts +0 -44
- package/lib/Signal/Group/sender-message-key.d.ts +0 -11
- package/lib/Signal/libsignal.d.ts +0 -8
- package/lib/Signal/lid-mapping.d.ts +0 -28
- package/lib/Socket/Client/index.d.ts +0 -2
- package/lib/Socket/Client/types.d.ts +0 -16
- package/lib/Socket/Client/websocket.d.ts +0 -13
- package/lib/Socket/business.d.ts +0 -187
- package/lib/Socket/chats.d.ts +0 -97
- package/lib/Socket/community.d.ts +0 -129
- package/lib/Socket/groups.d.ts +0 -129
- package/lib/Socket/index.d.ts +0 -191
- package/lib/Socket/messages-recv.d.ts +0 -174
- package/lib/Socket/messages-send.d.ts +0 -165
- package/lib/Socket/newsletter.d.ts +0 -145
- package/lib/Socket/socket.d.ts +0 -45
- package/lib/Socket/usync.d.ts +0 -37
- package/lib/Store/index.d.ts +0 -4
- package/lib/Store/make-cache-manager-store.d.ts +0 -14
- package/lib/Store/make-in-memory-store.d.ts +0 -123
- package/lib/Store/make-ordered-dictionary.d.ts +0 -12
- package/lib/Store/object-repository.d.ts +0 -10
- package/lib/Types/Auth.d.ts +0 -121
- package/lib/Types/Bussiness.d.ts +0 -28
- package/lib/Types/Call.d.ts +0 -14
- package/lib/Types/Chat.d.ts +0 -143
- package/lib/Types/Contact.d.ts +0 -23
- package/lib/Types/Events.d.ts +0 -226
- package/lib/Types/GroupMetadata.d.ts +0 -66
- package/lib/Types/Label.d.ts +0 -48
- package/lib/Types/LabelAssociation.d.ts +0 -35
- package/lib/Types/Message.d.ts +0 -484
- package/lib/Types/MexUpdates.d.ts +0 -9
- package/lib/Types/Newsletter.d.ts +0 -109
- package/lib/Types/Product.d.ts +0 -92
- package/lib/Types/Signal.d.ts +0 -98
- package/lib/Types/Socket.d.ts +0 -141
- package/lib/Types/State.d.ts +0 -41
- package/lib/Types/USync.d.ts +0 -26
- package/lib/Types/index.d.ts +0 -80
- package/lib/Utils/auth-utils.d.ts +0 -21
- package/lib/Utils/baileys-event-stream.d.ts +0 -18
- package/lib/Utils/business.d.ts +0 -29
- package/lib/Utils/chat-utils.d.ts +0 -82
- package/lib/Utils/crypto.d.ts +0 -56
- package/lib/Utils/decode-wa-message.d.ts +0 -53
- package/lib/Utils/event-buffer.d.ts +0 -39
- package/lib/Utils/generics.d.ts +0 -117
- package/lib/Utils/history.d.ts +0 -23
- package/lib/Utils/index.d.ts +0 -20
- package/lib/Utils/link-preview.d.ts +0 -23
- package/lib/Utils/logger.d.ts +0 -13
- package/lib/Utils/lt-hash.d.ts +0 -14
- package/lib/Utils/make-mutex.d.ts +0 -9
- package/lib/Utils/message-retry-manager.d.ts +0 -88
- package/lib/Utils/messages-media.d.ts +0 -135
- package/lib/Utils/messages.d.ts +0 -105
- package/lib/Utils/noise-handler.d.ts +0 -20
- package/lib/Utils/process-message.d.ts +0 -49
- package/lib/Utils/signal.d.ts +0 -42
- package/lib/Utils/use-mongo-file-auth-state.d.ts +0 -6
- package/lib/Utils/use-mongo-file-auth-state.js +0 -84
- package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
- package/lib/Utils/use-single-file-auth-state.d.ts +0 -13
- package/lib/Utils/use-single-file-auth-state.js +0 -80
- package/lib/Utils/validate-connection.d.ts +0 -13
- package/lib/WABinary/constants.d.ts +0 -30
- package/lib/WABinary/decode.d.ts +0 -9
- package/lib/WABinary/encode.d.ts +0 -3
- package/lib/WABinary/generic-utils.d.ts +0 -28
- package/lib/WABinary/index.d.ts +0 -5
- package/lib/WABinary/jid-utils.d.ts +0 -58
- package/lib/WABinary/types.d.ts +0 -22
- package/lib/WAM/BinaryInfo.d.ts +0 -16
- package/lib/WAM/constants.d.ts +0 -47
- package/lib/WAM/encode.d.ts +0 -3
- package/lib/WAM/index.d.ts +0 -3
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +0 -28
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -10
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -26
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -14
- package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +0 -10
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -14
- package/lib/WAUSync/Protocols/index.d.ts +0 -6
- package/lib/WAUSync/USyncQuery.d.ts +0 -31
- package/lib/WAUSync/USyncUser.d.ts +0 -12
- package/lib/WAUSync/index.d.ts +0 -3
- package/lib/index.d.ts +0 -13
package/lib/Socket/business.js
CHANGED
|
@@ -2,14 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const {
|
|
6
|
+
toProductNode,
|
|
7
|
+
parseCatalogNode,
|
|
8
|
+
parseCollectionsNode,
|
|
9
|
+
parseOrderDetailsNode,
|
|
10
|
+
getRawMediaUploadData,
|
|
11
|
+
uploadingNecessaryImagesOfProduct
|
|
12
|
+
} = require("../Utils")
|
|
13
|
+
const {
|
|
14
|
+
S_WHATSAPP_NET,
|
|
15
|
+
jidNormalizedUser,
|
|
16
|
+
getBinaryNodeChild
|
|
17
|
+
} = require("../WABinary")
|
|
18
|
+
const { makeMessagesRecvSocket } = require("./messages-recv")
|
|
10
19
|
|
|
11
20
|
const makeBusinessSocket = (config) => {
|
|
12
|
-
const suki =
|
|
21
|
+
const suki = makeMessagesRecvSocket(config)
|
|
13
22
|
const { authState, query, waUploadToServer } = suki
|
|
14
23
|
|
|
15
24
|
const updateBussinesProfile = async (args) => {
|
|
@@ -63,7 +72,7 @@ const makeBusinessSocket = (config) => {
|
|
|
63
72
|
const result = await query({
|
|
64
73
|
tag: 'iq',
|
|
65
74
|
attrs: {
|
|
66
|
-
to:
|
|
75
|
+
to: S_WHATSAPP_NET,
|
|
67
76
|
type: 'set',
|
|
68
77
|
xmlns: 'w:biz'
|
|
69
78
|
},
|
|
@@ -83,7 +92,7 @@ const makeBusinessSocket = (config) => {
|
|
|
83
92
|
}
|
|
84
93
|
|
|
85
94
|
const updateCoverPhoto = async (photo) => {
|
|
86
|
-
const { fileSha256, filePath } = await
|
|
95
|
+
const { fileSha256, filePath } = await getRawMediaUploadData(photo, 'biz-cover-photo')
|
|
87
96
|
const fileSha256B64 = fileSha256.toString('base64')
|
|
88
97
|
|
|
89
98
|
const { meta_hmac, fbid, ts } = await waUploadToServer(filePath, {
|
|
@@ -94,7 +103,7 @@ const makeBusinessSocket = (config) => {
|
|
|
94
103
|
await query({
|
|
95
104
|
tag: 'iq',
|
|
96
105
|
attrs: {
|
|
97
|
-
to:
|
|
106
|
+
to: S_WHATSAPP_NET,
|
|
98
107
|
type: 'set',
|
|
99
108
|
xmlns: 'w:biz'
|
|
100
109
|
},
|
|
@@ -122,7 +131,7 @@ const makeBusinessSocket = (config) => {
|
|
|
122
131
|
return await query({
|
|
123
132
|
tag: 'iq',
|
|
124
133
|
attrs: {
|
|
125
|
-
to:
|
|
134
|
+
to: S_WHATSAPP_NET,
|
|
126
135
|
type: 'set',
|
|
127
136
|
xmlns: 'w:biz'
|
|
128
137
|
},
|
|
@@ -146,7 +155,7 @@ const makeBusinessSocket = (config) => {
|
|
|
146
155
|
|
|
147
156
|
const getCatalog = async ({ jid, limit, cursor }) => {
|
|
148
157
|
jid = jid || authState.creds.me?.id
|
|
149
|
-
jid =
|
|
158
|
+
jid = jidNormalizedUser(jid)
|
|
150
159
|
|
|
151
160
|
const queryParamNodes = [
|
|
152
161
|
{
|
|
@@ -177,7 +186,7 @@ const makeBusinessSocket = (config) => {
|
|
|
177
186
|
const result = await query({
|
|
178
187
|
tag: 'iq',
|
|
179
188
|
attrs: {
|
|
180
|
-
to:
|
|
189
|
+
to: S_WHATSAPP_NET,
|
|
181
190
|
type: 'get',
|
|
182
191
|
xmlns: 'w:biz:catalog'
|
|
183
192
|
},
|
|
@@ -193,17 +202,17 @@ const makeBusinessSocket = (config) => {
|
|
|
193
202
|
]
|
|
194
203
|
})
|
|
195
204
|
|
|
196
|
-
return
|
|
205
|
+
return parseCatalogNode(result)
|
|
197
206
|
}
|
|
198
207
|
|
|
199
208
|
const getCollections = async (jid, limit = 51) => {
|
|
200
209
|
jid = jid || authState.creds.me?.id
|
|
201
|
-
jid =
|
|
210
|
+
jid = jidNormalizedUser(jid)
|
|
202
211
|
|
|
203
212
|
const result = await query({
|
|
204
213
|
tag: 'iq',
|
|
205
214
|
attrs: {
|
|
206
|
-
to:
|
|
215
|
+
to: S_WHATSAPP_NET,
|
|
207
216
|
type: 'get',
|
|
208
217
|
xmlns: 'w:biz:catalog',
|
|
209
218
|
'smax_id': '35'
|
|
@@ -240,14 +249,14 @@ const makeBusinessSocket = (config) => {
|
|
|
240
249
|
]
|
|
241
250
|
})
|
|
242
251
|
|
|
243
|
-
return
|
|
252
|
+
return parseCollectionsNode(result)
|
|
244
253
|
}
|
|
245
254
|
|
|
246
255
|
const getOrderDetails = async (orderId, tokenBase64) => {
|
|
247
256
|
const result = await query({
|
|
248
257
|
tag: 'iq',
|
|
249
258
|
attrs: {
|
|
250
|
-
to:
|
|
259
|
+
to: S_WHATSAPP_NET,
|
|
251
260
|
type: 'get',
|
|
252
261
|
xmlns: 'fb:thrift_iq',
|
|
253
262
|
'smax_id': '5'
|
|
@@ -286,17 +295,17 @@ const makeBusinessSocket = (config) => {
|
|
|
286
295
|
]
|
|
287
296
|
})
|
|
288
297
|
|
|
289
|
-
return
|
|
298
|
+
return parseOrderDetailsNode(result)
|
|
290
299
|
}
|
|
291
300
|
|
|
292
301
|
const productUpdate = async (productId, update) => {
|
|
293
|
-
update = await
|
|
294
|
-
const editNode =
|
|
302
|
+
update = await uploadingNecessaryImagesOfProduct(update, waUploadToServer)
|
|
303
|
+
const editNode = toProductNode(productId, update)
|
|
295
304
|
|
|
296
305
|
const result = await query({
|
|
297
306
|
tag: 'iq',
|
|
298
307
|
attrs: {
|
|
299
|
-
to:
|
|
308
|
+
to: S_WHATSAPP_NET,
|
|
300
309
|
type: 'set',
|
|
301
310
|
xmlns: 'w:biz:catalog'
|
|
302
311
|
},
|
|
@@ -320,21 +329,21 @@ const makeBusinessSocket = (config) => {
|
|
|
320
329
|
}
|
|
321
330
|
]
|
|
322
331
|
})
|
|
323
|
-
const productCatalogEditNode =
|
|
324
|
-
const productNode =
|
|
325
|
-
return
|
|
332
|
+
const productCatalogEditNode = getBinaryNodeChild(result, 'product_catalog_edit')
|
|
333
|
+
const productNode = getBinaryNodeChild(productCatalogEditNode, 'product')
|
|
334
|
+
return parseProductNode(productNode)
|
|
326
335
|
}
|
|
327
336
|
|
|
328
337
|
const productCreate = async (create) => {
|
|
329
338
|
// ensure isHidden is defined
|
|
330
339
|
create.isHidden = !!create.isHidden
|
|
331
|
-
create = await
|
|
332
|
-
const createNode =
|
|
340
|
+
create = await uploadingNecessaryImagesOfProduct(create, waUploadToServer)
|
|
341
|
+
const createNode = toProductNode(undefined, create)
|
|
333
342
|
|
|
334
343
|
const result = await query({
|
|
335
344
|
tag: 'iq',
|
|
336
345
|
attrs: {
|
|
337
|
-
to:
|
|
346
|
+
to: S_WHATSAPP_NET,
|
|
338
347
|
type: 'set',
|
|
339
348
|
xmlns: 'w:biz:catalog'
|
|
340
349
|
},
|
|
@@ -358,17 +367,17 @@ const makeBusinessSocket = (config) => {
|
|
|
358
367
|
}
|
|
359
368
|
]
|
|
360
369
|
})
|
|
361
|
-
const productCatalogAddNode =
|
|
362
|
-
const productNode =
|
|
370
|
+
const productCatalogAddNode = getBinaryNodeChild(result, 'product_catalog_add')
|
|
371
|
+
const productNode = getBinaryNodeChild(productCatalogAddNode, 'product')
|
|
363
372
|
|
|
364
|
-
return
|
|
373
|
+
return parseProductNode(productNode)
|
|
365
374
|
}
|
|
366
375
|
|
|
367
376
|
const productDelete = async (productIds) => {
|
|
368
377
|
const result = await query({
|
|
369
378
|
tag: 'iq',
|
|
370
379
|
attrs: {
|
|
371
|
-
to:
|
|
380
|
+
to: S_WHATSAPP_NET,
|
|
372
381
|
type: 'set',
|
|
373
382
|
xmlns: 'w:biz:catalog'
|
|
374
383
|
},
|
|
@@ -390,7 +399,7 @@ const makeBusinessSocket = (config) => {
|
|
|
390
399
|
}
|
|
391
400
|
]
|
|
392
401
|
})
|
|
393
|
-
const productCatalogDelNode =
|
|
402
|
+
const productCatalogDelNode = getBinaryNodeChild(result, 'product_catalog_delete')
|
|
394
403
|
return {
|
|
395
404
|
deleted: +(productCatalogDelNode?.attrs?.deleted_count || 0)
|
|
396
405
|
}
|