@pontalabs/baileys 1.0.6 → 1.0.7
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 +1 -1
- package/README.md +839 -267
- package/WAProto/GenerateStatics.sh +4 -3
- package/WAProto/WAProto.proto +511 -1215
- package/WAProto/index.d.ts +55 -14017
- package/WAProto/index.js +29 -97689
- package/lib/Defaults/index.d.ts +74 -72
- package/lib/Defaults/index.js +108 -94
- package/lib/Signal/Group/ciphertext-message.d.ts +7 -8
- package/lib/Signal/Group/ciphertext-message.js +16 -9
- package/lib/Signal/Group/group-session-builder.d.ts +13 -11
- package/lib/Signal/Group/group-session-builder.js +61 -19
- package/lib/Signal/Group/group_cipher.d.ts +16 -14
- package/lib/Signal/Group/group_cipher.js +70 -41
- package/lib/Signal/Group/index.d.ts +11 -12
- package/lib/Signal/Group/index.js +61 -12
- package/lib/Signal/Group/keyhelper.d.ts +14 -9
- package/lib/Signal/Group/keyhelper.js +58 -10
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -13
- package/lib/Signal/Group/sender-chain-key.js +34 -13
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -16
- package/lib/Signal/Group/sender-key-distribution-message.js +36 -28
- package/lib/Signal/Group/sender-key-message.d.ts +18 -18
- package/lib/Signal/Group/sender-key-message.js +45 -38
- package/lib/Signal/Group/sender-key-name.d.ts +15 -14
- package/lib/Signal/Group/sender-key-name.js +31 -20
- package/lib/Signal/Group/sender-key-record.d.ts +25 -24
- package/lib/Signal/Group/sender-key-record.js +35 -18
- package/lib/Signal/Group/sender-key-state.d.ts +34 -29
- package/lib/Signal/Group/sender-key-state.js +100 -37
- package/lib/Signal/Group/sender-message-key.d.ts +10 -11
- package/lib/Signal/Group/sender-message-key.js +22 -15
- package/lib/Signal/libsignal.d.ts +8 -5
- package/lib/Signal/libsignal.js +142 -288
- package/lib/Signal/lid-mapping.d.ts +28 -23
- package/lib/Signal/lid-mapping.js +184 -277
- package/lib/Socket/Client/index.d.ts +2 -3
- package/lib/Socket/Client/index.js +22 -3
- package/lib/Socket/Client/types.d.ts +15 -15
- package/lib/Socket/Client/types.js +15 -8
- package/lib/Socket/Client/websocket.d.ts +12 -12
- package/lib/Socket/Client/websocket.js +37 -29
- package/lib/Socket/business.d.ts +178 -208
- package/lib/Socket/business.js +127 -91
- package/lib/Socket/chats.d.ts +93 -120
- package/lib/Socket/chats.js +652 -727
- package/lib/Socket/community.js +10 -2
- package/lib/Socket/groups.d.ts +111 -143
- package/lib/Socket/groups.js +186 -165
- package/lib/Socket/index.d.ts +183 -252
- package/lib/Socket/index.js +18 -38
- package/lib/Socket/messages-recv.d.ts +167 -196
- package/lib/Socket/messages-recv.js +1567 -1443
- package/lib/Socket/messages-send.d.ts +158 -192
- package/lib/Socket/messages-send.js +1208 -1102
- package/lib/Socket/newsletter.d.ts +138 -163
- package/lib/Socket/newsletter.js +249 -153
- package/lib/Socket/socket.d.ts +36 -50
- package/lib/Socket/socket.js +820 -749
- package/lib/Store/index.d.ts +4 -4
- package/lib/Store/index.js +24 -4
- package/lib/Store/make-in-memory-store.d.ts +104 -44
- package/lib/Store/make-in-memory-store.js +213 -199
- package/lib/Store/make-ordered-dictionary.d.ts +12 -13
- package/lib/Store/make-ordered-dictionary.js +45 -38
- package/lib/Store/object-repository.d.ts +10 -11
- package/lib/Store/object-repository.js +16 -9
- package/lib/Types/Auth.d.ts +97 -93
- package/lib/Types/Auth.js +3 -2
- package/lib/Types/Bussines.js +3 -2
- package/lib/Types/Call.d.ts +13 -14
- package/lib/Types/Call.js +3 -2
- package/lib/Types/Chat.d.ts +97 -78
- package/lib/Types/Chat.js +9 -8
- package/lib/Types/Contact.d.ts +9 -12
- package/lib/Types/Contact.js +3 -2
- package/lib/Types/Events.d.ts +176 -206
- package/lib/Types/Events.js +3 -2
- package/lib/Types/GroupMetadata.d.ts +48 -53
- package/lib/Types/GroupMetadata.js +3 -2
- package/lib/Types/Label.d.ts +14 -13
- package/lib/Types/Label.js +30 -24
- package/lib/Types/LabelAssociation.d.ts +20 -15
- package/lib/Types/LabelAssociation.js +12 -6
- package/lib/Types/Message.d.ts +412 -248
- package/lib/Types/Message.js +19 -17
- package/lib/Types/Product.d.ts +71 -58
- package/lib/Types/Product.js +3 -2
- package/lib/Types/Signal.d.ts +82 -71
- package/lib/Types/Signal.js +3 -2
- package/lib/Types/Socket.d.ts +81 -76
- package/lib/Types/Socket.js +3 -3
- package/lib/Types/State.d.ts +19 -75
- package/lib/Types/State.js +14 -56
- package/lib/Types/USync.d.ts +8 -8
- package/lib/Types/USync.js +3 -2
- package/lib/Types/index.d.ts +62 -47
- package/lib/Types/index.js +50 -26
- package/lib/Utils/auth-utils.d.ts +10 -13
- package/lib/Utils/auth-utils.js +472 -213
- package/lib/Utils/business.d.ts +20 -14
- package/lib/Utils/business.js +134 -110
- package/lib/Utils/chat-utils.d.ts +70 -88
- package/lib/Utils/chat-utils.js +403 -466
- package/lib/Utils/crypto.d.ts +46 -27
- package/lib/Utils/crypto.js +188 -117
- package/lib/Utils/decode-wa-message.d.ts +45 -58
- package/lib/Utils/decode-wa-message.js +311 -212
- package/lib/Utils/event-buffer.d.ts +17 -14
- package/lib/Utils/event-buffer.js +296 -321
- package/lib/Utils/generics.d.ts +92 -66
- package/lib/Utils/generics.js +436 -270
- package/lib/Utils/history.d.ts +23 -24
- package/lib/Utils/history.js +76 -106
- package/lib/Utils/index.d.ts +21 -24
- package/lib/Utils/index.js +41 -24
- package/lib/Utils/link-preview.d.ts +14 -12
- package/lib/Utils/link-preview.js +75 -40
- package/lib/Utils/logger.d.ts +11 -10
- package/lib/Utils/logger.js +7 -3
- package/lib/Utils/lt-hash.d.ts +14 -8
- package/lib/Utils/lt-hash.js +53 -3
- package/lib/Utils/make-mutex.d.ts +7 -7
- package/lib/Utils/make-mutex.js +44 -28
- package/lib/Utils/message-retry-manager.d.ts +88 -115
- package/lib/Utils/message-retry-manager.js +160 -265
- package/lib/Utils/messages-media.d.ts +107 -105
- package/lib/Utils/messages-media.js +619 -548
- package/lib/Utils/messages.d.ts +66 -52
- package/lib/Utils/messages.js +1558 -1730
- package/lib/Utils/noise-handler.d.ts +18 -18
- package/lib/Utils/noise-handler.js +130 -176
- package/lib/Utils/process-message.d.ts +32 -43
- package/lib/Utils/process-message.js +282 -484
- package/lib/Utils/rich-message-utils.js +724 -1220
- package/lib/Utils/signal.d.ts +32 -37
- package/lib/Utils/signal.js +105 -140
- package/lib/Utils/use-multi-file-auth-state.d.ts +5 -5
- package/lib/Utils/use-multi-file-auth-state.js +120 -70
- package/lib/Utils/use-single-file-auth-state.d.ts +13 -11
- package/lib/Utils/use-single-file-auth-state.js +66 -92
- package/lib/Utils/validate-connection.d.ts +13 -11
- package/lib/Utils/validate-connection.js +113 -128
- package/lib/WABinary/constants.d.ts +27 -25
- package/lib/WABinary/constants.js +1292 -1451
- package/lib/WABinary/decode.d.ts +9 -7
- package/lib/WABinary/decode.js +189 -163
- package/lib/WABinary/encode.d.ts +3 -3
- package/lib/WABinary/encode.js +155 -110
- package/lib/WABinary/generic-utils.d.ts +27 -14
- package/lib/WABinary/generic-utils.js +105 -177
- package/lib/WABinary/index.d.ts +5 -6
- package/lib/WABinary/index.js +25 -6
- package/lib/WABinary/jid-utils.d.ts +54 -41
- package/lib/WABinary/jid-utils.js +152 -83
- package/lib/WABinary/types.d.ts +13 -10
- package/lib/WABinary/types.js +3 -2
- package/lib/WAM/BinaryInfo.d.ts +15 -8
- package/lib/WAM/BinaryInfo.js +14 -7
- package/lib/WAM/constants.d.ts +37 -30
- package/lib/WAM/constants.js +11983 -19465
- package/lib/WAM/encode.d.ts +3 -3
- package/lib/WAM/encode.js +109 -95
- package/lib/WAM/index.d.ts +3 -4
- package/lib/WAM/index.js +23 -4
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -9
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +21 -37
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -19
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +26 -18
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -11
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +20 -12
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -11
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +24 -16
- package/lib/WAUSync/Protocols/index.d.ts +6 -6
- package/lib/WAUSync/Protocols/index.js +26 -6
- package/lib/WAUSync/USyncQuery.d.ts +28 -27
- package/lib/WAUSync/USyncQuery.js +62 -68
- package/lib/WAUSync/USyncUser.d.ts +10 -15
- package/lib/WAUSync/USyncUser.js +19 -20
- package/lib/WAUSync/index.d.ts +3 -4
- package/lib/WAUSync/index.js +23 -4
- package/lib/index.d.ts +12 -11
- package/lib/index.js +39 -12
- package/package.json +42 -86
- package/engine-requirements.js +0 -10
package/lib/Socket/business.js
CHANGED
|
@@ -1,58 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
+
|
|
5
|
+
const Utils_1 = require("../Utils")
|
|
6
|
+
const WABinary_1 = require("../WABinary")
|
|
7
|
+
const business_1 = require("../Utils/business")
|
|
8
|
+
const generic_utils_1 = require("../WABinary/generic-utils")
|
|
9
|
+
const messages_recv_1 = require("./messages-recv")
|
|
10
|
+
|
|
11
|
+
const makeBusinessSocket = (config) => {
|
|
12
|
+
const sock = messages_recv_1.makeMessagesRecvSocket(config)
|
|
13
|
+
const { authState, query, waUploadToServer } = sock
|
|
14
|
+
|
|
9
15
|
const updateBussinesProfile = async (args) => {
|
|
10
|
-
const node = []
|
|
11
|
-
const simpleFields = ['address', 'email', 'description']
|
|
16
|
+
const node = []
|
|
17
|
+
const simpleFields = ['address', 'email', 'description']
|
|
18
|
+
|
|
12
19
|
node.push(...simpleFields
|
|
13
|
-
.filter(key => args[key]
|
|
20
|
+
.filter(key => args[key])
|
|
14
21
|
.map(key => ({
|
|
15
22
|
tag: key,
|
|
16
23
|
attrs: {},
|
|
17
24
|
content: args[key]
|
|
18
|
-
})))
|
|
19
|
-
|
|
25
|
+
})))
|
|
26
|
+
|
|
27
|
+
if (args.websites) {
|
|
28
|
+
|
|
20
29
|
node.push(...args.websites.map(website => ({
|
|
21
30
|
tag: 'website',
|
|
22
31
|
attrs: {},
|
|
23
32
|
content: website
|
|
24
|
-
})))
|
|
33
|
+
})))
|
|
25
34
|
}
|
|
26
|
-
|
|
35
|
+
|
|
36
|
+
if (args.hours) {
|
|
37
|
+
|
|
27
38
|
node.push({
|
|
28
39
|
tag: 'business_hours',
|
|
29
40
|
attrs: { timezone: args.hours.timezone },
|
|
30
|
-
content: args.hours.days.map(
|
|
41
|
+
content: args.hours.days.map(config => {
|
|
31
42
|
const base = {
|
|
32
43
|
tag: 'business_hours_config',
|
|
33
|
-
attrs: {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
38
|
-
if (dayConfig.mode === 'specific_hours') {
|
|
44
|
+
attrs: { day_of_week: config.day, mode: config.mode }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (config.mode === 'specific_hours') {
|
|
39
48
|
return {
|
|
40
49
|
...base,
|
|
41
50
|
attrs: {
|
|
42
51
|
...base.attrs,
|
|
43
|
-
open_time:
|
|
44
|
-
close_time:
|
|
52
|
+
open_time: config.openTimeInMinutes,
|
|
53
|
+
close_time: config.closeTimeInMinutes
|
|
45
54
|
}
|
|
46
|
-
}
|
|
55
|
+
}
|
|
47
56
|
}
|
|
48
|
-
|
|
57
|
+
|
|
58
|
+
return base
|
|
49
59
|
})
|
|
50
|
-
})
|
|
60
|
+
})
|
|
51
61
|
}
|
|
62
|
+
|
|
52
63
|
const result = await query({
|
|
53
64
|
tag: 'iq',
|
|
54
65
|
attrs: {
|
|
55
|
-
to: S_WHATSAPP_NET,
|
|
66
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
56
67
|
type: 'set',
|
|
57
68
|
xmlns: 'w:biz'
|
|
58
69
|
},
|
|
@@ -66,20 +77,24 @@ export const makeBusinessSocket = (config) => {
|
|
|
66
77
|
content: node
|
|
67
78
|
}
|
|
68
79
|
]
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
return result
|
|
83
|
+
}
|
|
84
|
+
|
|
72
85
|
const updateCoverPhoto = async (photo) => {
|
|
73
|
-
const { fileSha256, filePath } = await getRawMediaUploadData(photo, 'biz-cover-photo')
|
|
74
|
-
const fileSha256B64 = fileSha256.toString('base64')
|
|
86
|
+
const { fileSha256, filePath } = await Utils_1.getRawMediaUploadData(photo, 'biz-cover-photo')
|
|
87
|
+
const fileSha256B64 = fileSha256.toString('base64')
|
|
88
|
+
|
|
75
89
|
const { meta_hmac, fbid, ts } = await waUploadToServer(filePath, {
|
|
76
90
|
fileEncSha256B64: fileSha256B64,
|
|
77
91
|
mediaType: 'biz-cover-photo'
|
|
78
|
-
})
|
|
92
|
+
})
|
|
93
|
+
|
|
79
94
|
await query({
|
|
80
95
|
tag: 'iq',
|
|
81
96
|
attrs: {
|
|
82
|
-
to: S_WHATSAPP_NET,
|
|
97
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
83
98
|
type: 'set',
|
|
84
99
|
xmlns: 'w:biz'
|
|
85
100
|
},
|
|
@@ -98,14 +113,16 @@ export const makeBusinessSocket = (config) => {
|
|
|
98
113
|
]
|
|
99
114
|
}
|
|
100
115
|
]
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
return fbid
|
|
119
|
+
}
|
|
120
|
+
|
|
104
121
|
const removeCoverPhoto = async (id) => {
|
|
105
122
|
return await query({
|
|
106
123
|
tag: 'iq',
|
|
107
124
|
attrs: {
|
|
108
|
-
to: S_WHATSAPP_NET,
|
|
125
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
109
126
|
type: 'set',
|
|
110
127
|
xmlns: 'w:biz'
|
|
111
128
|
},
|
|
@@ -124,11 +141,13 @@ export const makeBusinessSocket = (config) => {
|
|
|
124
141
|
]
|
|
125
142
|
}
|
|
126
143
|
]
|
|
127
|
-
})
|
|
128
|
-
}
|
|
144
|
+
})
|
|
145
|
+
}
|
|
146
|
+
|
|
129
147
|
const getCatalog = async ({ jid, limit, cursor }) => {
|
|
130
|
-
jid = jid || authState.creds.me?.id
|
|
131
|
-
jid = jidNormalizedUser(jid)
|
|
148
|
+
jid = jid || authState.creds.me?.id
|
|
149
|
+
jid = WABinary_1.jidNormalizedUser(jid)
|
|
150
|
+
|
|
132
151
|
const queryParamNodes = [
|
|
133
152
|
{
|
|
134
153
|
tag: 'limit',
|
|
@@ -144,19 +163,21 @@ export const makeBusinessSocket = (config) => {
|
|
|
144
163
|
tag: 'height',
|
|
145
164
|
attrs: {},
|
|
146
165
|
content: Buffer.from('100')
|
|
147
|
-
}
|
|
148
|
-
]
|
|
166
|
+
},
|
|
167
|
+
]
|
|
168
|
+
|
|
149
169
|
if (cursor) {
|
|
150
170
|
queryParamNodes.push({
|
|
151
171
|
tag: 'after',
|
|
152
172
|
attrs: {},
|
|
153
173
|
content: cursor
|
|
154
|
-
})
|
|
174
|
+
})
|
|
155
175
|
}
|
|
176
|
+
|
|
156
177
|
const result = await query({
|
|
157
178
|
tag: 'iq',
|
|
158
179
|
attrs: {
|
|
159
|
-
to: S_WHATSAPP_NET,
|
|
180
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
160
181
|
type: 'get',
|
|
161
182
|
xmlns: 'w:biz:catalog'
|
|
162
183
|
},
|
|
@@ -165,30 +186,33 @@ export const makeBusinessSocket = (config) => {
|
|
|
165
186
|
tag: 'product_catalog',
|
|
166
187
|
attrs: {
|
|
167
188
|
jid,
|
|
168
|
-
allow_shop_source: 'true'
|
|
189
|
+
'allow_shop_source': 'true'
|
|
169
190
|
},
|
|
170
191
|
content: queryParamNodes
|
|
171
192
|
}
|
|
172
193
|
]
|
|
173
|
-
})
|
|
174
|
-
|
|
175
|
-
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
return business_1.parseCatalogNode(result)
|
|
197
|
+
}
|
|
198
|
+
|
|
176
199
|
const getCollections = async (jid, limit = 51) => {
|
|
177
|
-
jid = jid || authState.creds.me?.id
|
|
178
|
-
jid = jidNormalizedUser(jid)
|
|
200
|
+
jid = jid || authState.creds.me?.id
|
|
201
|
+
jid = WABinary_1.jidNormalizedUser(jid)
|
|
202
|
+
|
|
179
203
|
const result = await query({
|
|
180
204
|
tag: 'iq',
|
|
181
205
|
attrs: {
|
|
182
|
-
to: S_WHATSAPP_NET,
|
|
206
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
183
207
|
type: 'get',
|
|
184
208
|
xmlns: 'w:biz:catalog',
|
|
185
|
-
smax_id: '35'
|
|
209
|
+
'smax_id': '35'
|
|
186
210
|
},
|
|
187
211
|
content: [
|
|
188
212
|
{
|
|
189
213
|
tag: 'collections',
|
|
190
214
|
attrs: {
|
|
191
|
-
biz_jid: jid
|
|
215
|
+
'biz_jid': jid,
|
|
192
216
|
},
|
|
193
217
|
content: [
|
|
194
218
|
{
|
|
@@ -214,17 +238,19 @@ export const makeBusinessSocket = (config) => {
|
|
|
214
238
|
]
|
|
215
239
|
}
|
|
216
240
|
]
|
|
217
|
-
})
|
|
218
|
-
|
|
219
|
-
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
return business_1.parseCollectionsNode(result)
|
|
244
|
+
}
|
|
245
|
+
|
|
220
246
|
const getOrderDetails = async (orderId, tokenBase64) => {
|
|
221
247
|
const result = await query({
|
|
222
248
|
tag: 'iq',
|
|
223
249
|
attrs: {
|
|
224
|
-
to: S_WHATSAPP_NET,
|
|
250
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
225
251
|
type: 'get',
|
|
226
252
|
xmlns: 'fb:thrift_iq',
|
|
227
|
-
smax_id: '5'
|
|
253
|
+
'smax_id': '5'
|
|
228
254
|
},
|
|
229
255
|
content: [
|
|
230
256
|
{
|
|
@@ -258,16 +284,19 @@ export const makeBusinessSocket = (config) => {
|
|
|
258
284
|
]
|
|
259
285
|
}
|
|
260
286
|
]
|
|
261
|
-
})
|
|
262
|
-
|
|
263
|
-
|
|
287
|
+
})
|
|
288
|
+
|
|
289
|
+
return business_1.parseOrderDetailsNode(result)
|
|
290
|
+
}
|
|
291
|
+
|
|
264
292
|
const productUpdate = async (productId, update) => {
|
|
265
|
-
update = await uploadingNecessaryImagesOfProduct(update, waUploadToServer)
|
|
266
|
-
const editNode = toProductNode(productId, update)
|
|
293
|
+
update = await business_1.uploadingNecessaryImagesOfProduct(update, waUploadToServer)
|
|
294
|
+
const editNode = business_1.toProductNode(productId, update)
|
|
295
|
+
|
|
267
296
|
const result = await query({
|
|
268
297
|
tag: 'iq',
|
|
269
298
|
attrs: {
|
|
270
|
-
to: S_WHATSAPP_NET,
|
|
299
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
271
300
|
type: 'set',
|
|
272
301
|
xmlns: 'w:biz:catalog'
|
|
273
302
|
},
|
|
@@ -290,20 +319,22 @@ export const makeBusinessSocket = (config) => {
|
|
|
290
319
|
]
|
|
291
320
|
}
|
|
292
321
|
]
|
|
293
|
-
})
|
|
294
|
-
const productCatalogEditNode = getBinaryNodeChild(result, 'product_catalog_edit')
|
|
295
|
-
const productNode = getBinaryNodeChild(productCatalogEditNode, 'product')
|
|
296
|
-
return parseProductNode(productNode)
|
|
297
|
-
}
|
|
322
|
+
})
|
|
323
|
+
const productCatalogEditNode = generic_utils_1.getBinaryNodeChild(result, 'product_catalog_edit')
|
|
324
|
+
const productNode = generic_utils_1.getBinaryNodeChild(productCatalogEditNode, 'product')
|
|
325
|
+
return business_1.parseProductNode(productNode)
|
|
326
|
+
}
|
|
327
|
+
|
|
298
328
|
const productCreate = async (create) => {
|
|
299
329
|
// ensure isHidden is defined
|
|
300
|
-
create.isHidden = !!create.isHidden
|
|
301
|
-
create = await uploadingNecessaryImagesOfProduct(create, waUploadToServer)
|
|
302
|
-
const createNode = toProductNode(undefined, create)
|
|
330
|
+
create.isHidden = !!create.isHidden
|
|
331
|
+
create = await business_1.uploadingNecessaryImagesOfProduct(create, waUploadToServer)
|
|
332
|
+
const createNode = business_1.toProductNode(undefined, create)
|
|
333
|
+
|
|
303
334
|
const result = await query({
|
|
304
335
|
tag: 'iq',
|
|
305
336
|
attrs: {
|
|
306
|
-
to: S_WHATSAPP_NET,
|
|
337
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
307
338
|
type: 'set',
|
|
308
339
|
xmlns: 'w:biz:catalog'
|
|
309
340
|
},
|
|
@@ -326,16 +357,18 @@ export const makeBusinessSocket = (config) => {
|
|
|
326
357
|
]
|
|
327
358
|
}
|
|
328
359
|
]
|
|
329
|
-
})
|
|
330
|
-
const productCatalogAddNode = getBinaryNodeChild(result, 'product_catalog_add')
|
|
331
|
-
const productNode = getBinaryNodeChild(productCatalogAddNode, 'product')
|
|
332
|
-
|
|
333
|
-
|
|
360
|
+
})
|
|
361
|
+
const productCatalogAddNode = generic_utils_1.getBinaryNodeChild(result, 'product_catalog_add')
|
|
362
|
+
const productNode = generic_utils_1.getBinaryNodeChild(productCatalogAddNode, 'product')
|
|
363
|
+
|
|
364
|
+
return business_1.parseProductNode(productNode)
|
|
365
|
+
}
|
|
366
|
+
|
|
334
367
|
const productDelete = async (productIds) => {
|
|
335
368
|
const result = await query({
|
|
336
369
|
tag: 'iq',
|
|
337
370
|
attrs: {
|
|
338
|
-
to: S_WHATSAPP_NET,
|
|
371
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
339
372
|
type: 'set',
|
|
340
373
|
xmlns: 'w:biz:catalog'
|
|
341
374
|
},
|
|
@@ -356,12 +389,12 @@ export const makeBusinessSocket = (config) => {
|
|
|
356
389
|
}))
|
|
357
390
|
}
|
|
358
391
|
]
|
|
359
|
-
})
|
|
360
|
-
const productCatalogDelNode = getBinaryNodeChild(result, 'product_catalog_delete')
|
|
392
|
+
})
|
|
393
|
+
const productCatalogDelNode = generic_utils_1.getBinaryNodeChild(result, 'product_catalog_delete')
|
|
361
394
|
return {
|
|
362
|
-
deleted: +(productCatalogDelNode?.attrs
|
|
363
|
-
}
|
|
364
|
-
}
|
|
395
|
+
deleted: +(productCatalogDelNode?.attrs?.deleted_count || 0)
|
|
396
|
+
}
|
|
397
|
+
}
|
|
365
398
|
return {
|
|
366
399
|
...sock,
|
|
367
400
|
logger: config.logger,
|
|
@@ -370,10 +403,13 @@ export const makeBusinessSocket = (config) => {
|
|
|
370
403
|
getCollections,
|
|
371
404
|
productCreate,
|
|
372
405
|
productDelete,
|
|
373
|
-
productUpdate,
|
|
406
|
+
productUpdate,
|
|
374
407
|
updateBussinesProfile,
|
|
375
408
|
updateCoverPhoto,
|
|
376
409
|
removeCoverPhoto
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
module.exports = {
|
|
414
|
+
makeBusinessSocket
|
|
415
|
+
}
|
package/lib/Socket/chats.d.ts
CHANGED
|
@@ -1,124 +1,97 @@
|
|
|
1
|
-
import { Boom } from '@hapi/boom'
|
|
2
|
-
import { proto } from '../../WAProto
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import { USyncQuery } from '../WAUSync
|
|
1
|
+
import { Boom } from '@hapi/boom'
|
|
2
|
+
import { proto } from '../../WAProto'
|
|
3
|
+
import { BotListInfo, ChatModification, ContactAction, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAPatchCreate, WAPresence, WAPrivacyCallValue, WAPrivacyGroupAddValue, WAPrivacyMessagesValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types'
|
|
4
|
+
import { LabelActionBody } from '../Types/Label'
|
|
5
|
+
import { QuickReplyAction } from '../Types/Bussines'
|
|
6
|
+
import { BinaryNode } from '../WABinary'
|
|
7
|
+
import { USyncQuery } from '../WAUSync'
|
|
8
|
+
|
|
8
9
|
export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/** AB prop 9666: gate tctoken on profile picture IQs. WA Web default: true. */
|
|
13
|
-
profilePicPrivacyToken: boolean;
|
|
14
|
-
/** AB prop 14303: issue tctokens to LID instead of PN. WA Web default: false. */
|
|
15
|
-
lidTrustedTokenIssueToLid: boolean;
|
|
16
|
-
};
|
|
17
|
-
createCallLink: (type: "audio" | "video", event?: {
|
|
18
|
-
startTime: number;
|
|
19
|
-
}, timeoutMs?: number) => Promise<string | undefined>;
|
|
20
|
-
getBotListV2: () => Promise<BotListInfo[]>;
|
|
21
|
-
messageMutex: {
|
|
22
|
-
mutex<T>(code: () => Promise<T> | T): Promise<T>;
|
|
23
|
-
};
|
|
24
|
-
receiptMutex: {
|
|
25
|
-
mutex<T>(code: () => Promise<T> | T): Promise<T>;
|
|
26
|
-
};
|
|
27
|
-
appStatePatchMutex: {
|
|
28
|
-
mutex<T>(code: () => Promise<T> | T): Promise<T>;
|
|
29
|
-
};
|
|
30
|
-
notificationMutex: {
|
|
31
|
-
mutex<T>(code: () => Promise<T> | T): Promise<T>;
|
|
32
|
-
};
|
|
10
|
+
processingMutex: {
|
|
11
|
+
mutex<T>(code: () => T | Promise<T>): Promise<T>
|
|
12
|
+
}
|
|
33
13
|
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
34
|
-
[_: string]: string
|
|
35
|
-
}
|
|
36
|
-
upsertMessage: (msg:
|
|
37
|
-
appPatch: (patchCreate: WAPatchCreate) => Promise<void
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
14
|
+
[_: string]: string
|
|
15
|
+
}>
|
|
16
|
+
upsertMessage: (msg: proto.IWebMessageInfo, type: MessageUpsertType) => Promise<void>
|
|
17
|
+
appPatch: (patchCreate: WAPatchCreate) => Promise<void>
|
|
18
|
+
createCallLink: (type: 'audio' | 'video', event?: number, timeoutMs?: number) => Promise<void>
|
|
19
|
+
sendPresenceUpdate: (type: WAPresence, toJid?: string) => Promise<void>
|
|
20
|
+
presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>
|
|
21
|
+
getBotListV2: () => Promise<BotListInfo[]>
|
|
22
|
+
getLidUser: (jid: string) => Promise<{
|
|
23
|
+
lid: string
|
|
24
|
+
id: string
|
|
25
|
+
}[] | undefined>
|
|
26
|
+
fetchBlocklist: () => Promise<string[]>
|
|
27
|
+
fetchStatus: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>
|
|
28
|
+
fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>
|
|
29
|
+
updateProfilePicture: (jid: string, content: WAMediaUpload) => Promise<void>
|
|
30
|
+
removeProfilePicture: (jid: string) => Promise<void>
|
|
31
|
+
updateProfileStatus: (status: string) => Promise<void>
|
|
32
|
+
updateProfileName: (name: string) => Promise<void>
|
|
33
|
+
updateBlockStatus: (jid: string, action: 'block' | 'unblock') => Promise<void>
|
|
34
|
+
updateCallPrivacy: (value: WAPrivacyCallValue) => Promise<void>
|
|
35
|
+
updateMessagesPrivacy: (value: WAPrivacyMessagesValue) => Promise<void>
|
|
36
|
+
updateLastSeenPrivacy: (value: WAPrivacyValue) => Promise<void>
|
|
37
|
+
updateOnlinePrivacy: (value: WAPrivacyOnlineValue) => Promise<void>
|
|
38
|
+
updateProfilePicturePrivacy: (value: WAPrivacyValue) => Promise<void>
|
|
39
|
+
updateStatusPrivacy: (value: WAPrivacyValue) => Promise<void>
|
|
40
|
+
updateReadReceiptsPrivacy: (value: WAReadReceiptsValue) => Promise<void>
|
|
41
|
+
updateGroupsAddPrivacy: (value: WAPrivacyGroupAddValue) => Promise<void>
|
|
42
|
+
updateDefaultDisappearingMode: (duration: number) => Promise<void>
|
|
43
|
+
updateDisableLinkPreviewsPrivacy: (isPreviewsDisabled: boolean) => Promise<void>
|
|
44
|
+
getBusinessProfile: (jid: string) => Promise<WABusinessProfile | void>
|
|
45
|
+
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>
|
|
46
|
+
chatModify: (mod: ChatModification, jid: string) => Promise<void>
|
|
47
|
+
cleanDirtyBits: (type: 'account_sync' | 'groups', fromTimestamp?: number | string) => Promise<void>
|
|
48
|
+
addLabel: (jid: string, labels: LabelActionBody) => Promise<void>
|
|
49
|
+
addChatLabel: (jid: string, labelId: string) => Promise<void>
|
|
50
|
+
removeChatLabel: (jid: string, labelId: string) => Promise<void>
|
|
51
|
+
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>
|
|
52
|
+
removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>
|
|
53
|
+
clearMessage: (jid: string, key: import("../Types").WAProto.IMessageKey, timeStamp: number | import("long").Long) => Promise<void>
|
|
74
54
|
star: (jid: string, messages: {
|
|
75
|
-
id: string
|
|
76
|
-
fromMe?: boolean
|
|
77
|
-
}[], star: boolean) => Promise<void
|
|
78
|
-
addOrEditQuickReply: (quickReply: QuickReplyAction) => Promise<void
|
|
79
|
-
removeQuickReply: (timestamp: string) => Promise<void
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
55
|
+
id: string
|
|
56
|
+
fromMe?: boolean
|
|
57
|
+
}[], star: boolean) => Promise<void>
|
|
58
|
+
addOrEditQuickReply: (quickReply: QuickReplyAction) => Promise<void>
|
|
59
|
+
removeQuickReply: (timestamp: string) => Promise<void>
|
|
60
|
+
addOrEditContact: (jid: string, contact: ContactAction) => Promise<void>
|
|
61
|
+
removeContact: (jid: string) => Promise<void>
|
|
62
|
+
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>
|
|
63
|
+
type: "md"
|
|
64
|
+
ws: import("./Client").WebSocketClient
|
|
65
|
+
ev: import("../Types").BaileysEventEmitter & {
|
|
66
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void
|
|
67
|
+
buffer(): void
|
|
68
|
+
createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>
|
|
69
|
+
flush(force?: boolean | undefined): boolean
|
|
70
|
+
isBuffering(): boolean
|
|
71
|
+
}
|
|
90
72
|
authState: {
|
|
91
|
-
creds: import("../Types
|
|
92
|
-
keys: import("../Types
|
|
93
|
-
}
|
|
94
|
-
signalRepository: import("../Types
|
|
95
|
-
user: import("../Types
|
|
96
|
-
generateMessageTag: () => string
|
|
97
|
-
query: (node: BinaryNode, timeoutMs?: number) => Promise<
|
|
98
|
-
waitForMessage: <
|
|
99
|
-
waitForSocketOpen: () => Promise<void
|
|
100
|
-
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void
|
|
101
|
-
sendNode: (frame: BinaryNode) => Promise<void
|
|
102
|
-
logout: (msg?: string) => Promise<void
|
|
103
|
-
end: (error: Error | undefined) =>
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync/index.js").USyncQueryResult | undefined>;
|
|
117
|
-
onWhatsApp: (...phoneNumber: string[]) => Promise<{
|
|
118
|
-
jid: string;
|
|
119
|
-
exists: boolean;
|
|
120
|
-
}[] | undefined>;
|
|
121
|
-
fetchAccountReachoutTimelock: () => Promise<import("../Types/index.js").ReachoutTimelockState>;
|
|
122
|
-
fetchNewChatMessageCap: () => Promise<import("../Types/index.js").NewChatMessageCapInfo>;
|
|
123
|
-
};
|
|
124
|
-
//# sourceMappingURL=chats.d.ts.map
|
|
73
|
+
creds: import("../Types").AuthenticationCreds
|
|
74
|
+
keys: import("../Types").SignalKeyStoreWithTransaction
|
|
75
|
+
}
|
|
76
|
+
signalRepository: import("../Types").SignalRepository
|
|
77
|
+
user: import("../Types").Contact | undefined
|
|
78
|
+
generateMessageTag: () => string
|
|
79
|
+
query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>
|
|
80
|
+
waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>
|
|
81
|
+
waitForSocketOpen: () => Promise<void>
|
|
82
|
+
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>
|
|
83
|
+
sendNode: (frame: BinaryNode) => Promise<void>
|
|
84
|
+
logout: (msg?: string | undefined) => Promise<void>
|
|
85
|
+
end: (error: Error | undefined) => void
|
|
86
|
+
onUnexpectedError: (err: Error | Boom<any>, msg: string) => void
|
|
87
|
+
uploadPreKeys: (count?: number) => Promise<void>
|
|
88
|
+
uploadPreKeysToServerIfRequired: () => Promise<void>
|
|
89
|
+
requestPairingCode: (phoneNumber: string, code?: string) => Promise<string>
|
|
90
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>
|
|
91
|
+
/**
|
|
92
|
+
* modify a chat -- mark unread, read etc.
|
|
93
|
+
* lastMessages must be sorted in reverse chronologically
|
|
94
|
+
* requires the last messages till the last message received required for archive & unread
|
|
95
|
+
*/
|
|
96
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>
|
|
97
|
+
}
|