@jkt48connect-corp/baileys 7.4.5 → 7.4.9
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/WAProto/CompanionReg/CompanionReg.d.ts +6 -0
- package/WAProto/CompanionReg/CompanionReg.js +36 -0
- package/WAProto/CompanionReg/CompanionReg.proto +1 -0
- package/WAProto/E2E/E2E.d.ts +434 -6
- package/WAProto/E2E/E2E.js +1427 -2
- package/WAProto/E2E/E2E.proto +33 -0
- package/WAProto/HistorySync/HistorySync.d.ts +434 -6
- package/WAProto/HistorySync/HistorySync.js +1427 -2
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.d.ts +434 -6
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.js +1427 -2
- package/WAProto/StatusAttributions/StatusAttributions.d.ts +95 -3
- package/WAProto/StatusAttributions/StatusAttributions.js +270 -2
- package/WAProto/StatusAttributions/StatusAttributions.proto +8 -0
- package/WAProto/Web/Web.d.ts +434 -6
- package/WAProto/Web/Web.js +1427 -2
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Socket/business.js +3 -3
- package/lib/Socket/chats.js +7 -7
- package/lib/Socket/groups.js +11 -9
- package/lib/Socket/messages-recv.js +12 -11
- package/lib/Socket/messages-send.js +981 -983
- package/lib/Socket/newsletter.js +3 -3
- package/lib/Socket/socket.js +13 -47
- package/lib/Socket/usync.js +3 -3
- package/lib/Store/make-cache-manager-store.js +9 -17
- package/lib/Store/make-in-memory-store.d.ts +2 -2
- package/lib/Store/make-in-memory-store.js +5 -5
- package/lib/Types/GroupMetadata.d.ts +2 -1
- package/lib/Utils/business.js +4 -0
- package/lib/Utils/decode-wa-message.js +4 -0
- package/lib/Utils/generics.js +10 -9
- package/lib/Utils/messages.js +1329 -1326
- package/lib/Utils/process-message.js +14 -1
- package/lib/index.js +1 -1
- package/package.json +5 -6
- package/WAProto/Adv/JKT48Connect - Valzyy +0 -0
- package/WAProto/Cert/JKT48Connect - Valzyy +0 -0
- package/WAProto/ChatLockSettings/JKT48Connect - Valzyy +0 -0
- package/WAProto/CompanionReg/JKT48Connect - Valzyy +0 -0
- package/WAProto/DeviceCapabilities/JKT48Connect - Valzyy +0 -0
- package/WAProto/E2E/JKT48Connect - Valzyy +0 -0
- package/WAProto/Ephemeral/JKT48Connect - Valzyy +0 -0
- package/WAProto/HistorySync/JKT48Connect - Valzyy +0 -0
- package/WAProto/JKT48Connect - Valzyy +0 -0
- package/WAProto/MdStorageChatRowOpaqueData/JKT48Connect - Valzyy +0 -0
- package/WAProto/MdStorageMsgRowOpaqueData/JKT48Connect - Valzyy +0 -0
- package/WAProto/MmsRetry/JKT48Connect - Valzyy +0 -0
- package/WAProto/Protocol/JKT48Connect - Valzyy +0 -0
- package/WAProto/Reporting/JKT48Connect - Valzyy +0 -0
- package/WAProto/ServerSync/JKT48Connect - Valzyy +0 -0
- package/WAProto/SignalLocalStorageProtocol/JKT48Connect - Valzyy +0 -0
- package/WAProto/SignalWhisperTextProtocol/JKT48Connect - Valzyy +0 -0
- package/WAProto/StatusAttributions/JKT48Connect - Valzyy +0 -0
- package/WAProto/SyncAction/JKT48Connect - Valzyy +0 -0
- package/WAProto/UserPassword/JKT48Connect - Valzyy +0 -0
- package/WAProto/VnameCert/JKT48Connect - Valzyy +0 -0
- package/WAProto/Wa6/JKT48Connect - Valzyy +0 -0
- package/WAProto/Web/JKT48Connect - Valzyy +0 -0
- package/lib/JKT48Connect - Valzyy +0 -0
package/lib/Socket/business.js
CHANGED
@@ -5,8 +5,8 @@ const WABinary_1 = require("../WABinary")
|
|
5
5
|
const generic_utils_1 = require("../WABinary/generic-utils")
|
6
6
|
const messages_recv_1 = require("./messages-recv")
|
7
7
|
const makeBusinessSocket = (config) => {
|
8
|
-
const
|
9
|
-
const { authState, query, waUploadToServer } =
|
8
|
+
const sock = messages_recv_1.makeMessagesRecvSocket(config)
|
9
|
+
const { authState, query, waUploadToServer } = sock
|
10
10
|
const getCatalog = async ({ jid, limit, cursor }) => {
|
11
11
|
jid = jid || authState.creds.me?.id
|
12
12
|
jid = WABinary_1.jidNormalizedUser(jid)
|
@@ -244,7 +244,7 @@ deleted: +(productCatalogDelNode?.attrs?.deleted_count || 0)
|
|
244
244
|
}
|
245
245
|
}
|
246
246
|
return {
|
247
|
-
...
|
247
|
+
...sock,
|
248
248
|
logger: config.logger,
|
249
249
|
getOrderDetails,
|
250
250
|
getCatalog,
|
package/lib/Socket/chats.js
CHANGED
@@ -16,8 +16,8 @@ const usync_1 = require("./usync")
|
|
16
16
|
const MAX_SYNC_ATTEMPTS = 2
|
17
17
|
const makeChatsSocket = (config) => {
|
18
18
|
const { logger, markOnlineOnConnect, fireInitQueries, appStateMacVerification, shouldIgnoreJid, shouldSyncHistoryMessage, } = config
|
19
|
-
const
|
20
|
-
const { ev, ws, authState, generateMessageTag, sendNode, query, onUnexpectedError, groupFetchAllParticipating } =
|
19
|
+
const sock = usync_1.makeUSyncSocket(config)
|
20
|
+
const { ev, ws, authState, generateMessageTag, sendNode, query, onUnexpectedError, groupFetchAllParticipating } = sock
|
21
21
|
let privacySettings
|
22
22
|
let needToFlushWithAppStateSync = false
|
23
23
|
let pendingAppStateSync = false
|
@@ -164,7 +164,7 @@ parser: (node) => node.attrs.val
|
|
164
164
|
usyncQuery.users.push({
|
165
165
|
id: targetJid
|
166
166
|
})
|
167
|
-
const result = await
|
167
|
+
const result = await sock.executeUSyncQuery(usyncQuery)
|
168
168
|
if (result) {
|
169
169
|
return result.list
|
170
170
|
}
|
@@ -175,7 +175,7 @@ for (const jid of jids) {
|
|
175
175
|
const phone = `+${jid.replace('+', '').split('@')[0].split(':')[0]}`
|
176
176
|
usyncQuery.withUser(new WAUSync_1.USyncUser().withPhone(phone))
|
177
177
|
}
|
178
|
-
const results = await
|
178
|
+
const results = await sock.executeUSyncQuery(usyncQuery)
|
179
179
|
if (results) {
|
180
180
|
return results.list.filter((a) => !!a.contact).map(({ contact, id, lid }) => ({ jid: id, exists: contact, lid }))
|
181
181
|
}
|
@@ -185,7 +185,7 @@ const usyncQuery = new WAUSync_1.USyncQuery().withStatusProtocol()
|
|
185
185
|
for (const jid of jids) {
|
186
186
|
usyncQuery.withUser(new WAUSync_1.USyncUser().withId(jid))
|
187
187
|
}
|
188
|
-
const result = await
|
188
|
+
const result = await sock.executeUSyncQuery(usyncQuery)
|
189
189
|
if (result) {
|
190
190
|
return result.list
|
191
191
|
}
|
@@ -195,7 +195,7 @@ const usyncQuery = new WAUSync_1.USyncQuery().withDisappearingModeProtocol()
|
|
195
195
|
for (const jid of jids) {
|
196
196
|
usyncQuery.withUser(new WAUSync_1.USyncUser().withId(jid))
|
197
197
|
}
|
198
|
-
const result = await
|
198
|
+
const result = await sock.executeUSyncQuery(usyncQuery)
|
199
199
|
if (result) {
|
200
200
|
return result.list
|
201
201
|
}
|
@@ -859,7 +859,7 @@ needToFlushWithAppStateSync = true
|
|
859
859
|
}
|
860
860
|
})
|
861
861
|
return {
|
862
|
-
...
|
862
|
+
...sock,
|
863
863
|
star,
|
864
864
|
addOrEditContact,
|
865
865
|
removeContact,
|
package/lib/Socket/groups.js
CHANGED
@@ -6,8 +6,8 @@ const Utils_1 = require("../Utils")
|
|
6
6
|
const WABinary_1 = require("../WABinary")
|
7
7
|
const chats_1 = require("./chats")
|
8
8
|
const makeGroupsSocket = (config) => {
|
9
|
-
const
|
10
|
-
const { authState, ev, query, upsertMessage } =
|
9
|
+
const sock = chats_1.makeChatsSocket(config)
|
10
|
+
const { authState, ev, query, upsertMessage } = sock
|
11
11
|
const groupQuery = async (jid, type, content) => (query({
|
12
12
|
tag: 'iq',
|
13
13
|
attrs: {
|
@@ -53,11 +53,11 @@ content: [groupNode]
|
|
53
53
|
data[meta.id] = meta
|
54
54
|
}
|
55
55
|
}
|
56
|
-
|
56
|
+
sock.ev.emit('groups.update', Object.values(data))
|
57
57
|
return data
|
58
58
|
}
|
59
59
|
return {
|
60
|
-
...
|
60
|
+
...sock,
|
61
61
|
groupQuery,
|
62
62
|
groupMetadata,
|
63
63
|
groupCreate: async (subject, participants) => {
|
@@ -269,18 +269,20 @@ if (descChild) {
|
|
269
269
|
desc = WABinary_1.getBinaryNodeChildString(descChild, 'body')
|
270
270
|
descId = descChild.attrs.id
|
271
271
|
}
|
272
|
+
const mode = group.attrs.addressing_mode
|
272
273
|
const groupId = group.attrs.id.includes('@') ? group.attrs.id : WABinary_1.jidEncode(group.attrs.id, 'g.us')
|
273
274
|
const eph = WABinary_1.getBinaryNodeChild(group, 'ephemeral')?.attrs.expiration
|
274
275
|
const memberAddMode = WABinary_1.getBinaryNodeChildString(group, 'member_add_mode') === 'all_member_add'
|
275
276
|
const metadata = {
|
276
277
|
id: groupId,
|
277
|
-
addressingMode:
|
278
|
+
addressingMode: mode,
|
278
279
|
subject: group.attrs.subject,
|
279
|
-
subjectOwner: group.attrs.s_o,
|
280
|
+
subjectOwner: mode === 'lid' ? group.attrs.s_o_pn : group.attrs.s_o,
|
280
281
|
subjectTime: +group.attrs.s_t,
|
281
282
|
size: WABinary_1.getBinaryNodeChildren(group, 'participant').length,
|
282
283
|
creation: +group.attrs.creation,
|
283
|
-
owner: group.attrs.creator ? WABinary_1.jidNormalizedUser(group.attrs.creator) : undefined,
|
284
|
+
owner: group.attrs.creator ? WABinary_1.jidNormalizedUser(mode === 'lid' ? group.attrs.creator_pn : group.attrs.creator) : undefined,
|
285
|
+
ownerCountry: group.attrs.creator_country_code,
|
284
286
|
desc,
|
285
287
|
descId,
|
286
288
|
linkedParent: WABinary_1.getBinaryNodeChild(group, 'linked_parent')?.attrs.jid || undefined,
|
@@ -292,8 +294,8 @@ joinApprovalMode: !!WABinary_1.getBinaryNodeChild(group, 'membership_approval_mo
|
|
292
294
|
memberAddMode,
|
293
295
|
participants: WABinary_1.getBinaryNodeChildren(group, 'participant').map(({ attrs }) => {
|
294
296
|
return {
|
295
|
-
id: attrs.jid,
|
296
|
-
lid: attrs.lid,
|
297
|
+
id: mode === 'lid' ? attrs.phone_number : attrs.jid,
|
298
|
+
lid: mode === 'lid' ? attrs.jid : attrs.lid,
|
297
299
|
admin: (attrs.type || null),
|
298
300
|
}
|
299
301
|
}),
|
@@ -16,8 +16,8 @@ const groups_1 = require("./groups")
|
|
16
16
|
const messages_send_1 = require("./messages-send")
|
17
17
|
const makeMessagesRecvSocket = (config) => {
|
18
18
|
const { logger, retryRequestDelayMs, maxMsgRetryCount, getMessage, shouldIgnoreJid } = config
|
19
|
-
const
|
20
|
-
const { ev, authState, ws, processingMutex, signalRepository, query, upsertMessage, resyncAppState, onUnexpectedError, assertSessions, sendNode, relayMessage, sendReceipt, uploadPreKeys, getUSyncDevices, createParticipantNodes, sendPeerDataOperationMessage } =
|
19
|
+
const sock = messages_send_1.makeMessagesSocket(config)
|
20
|
+
const { ev, authState, ws, processingMutex, signalRepository, query, upsertMessage, resyncAppState, onUnexpectedError, assertSessions, sendNode, relayMessage, sendReceipt, uploadPreKeys, getUSyncDevices, createParticipantNodes, sendPeerDataOperationMessage } = sock
|
21
21
|
/** this mutex ensures that each retryRequest will wait for the previous one to finish */
|
22
22
|
const retryMutex = make_mutex_1.makeMutex()
|
23
23
|
const msgRetryCache = config.msgRetryCounterCache || new node_cache_1.default({
|
@@ -227,8 +227,8 @@ logger.info({ node }, 'unknown encrypt notification')
|
|
227
227
|
}
|
228
228
|
}
|
229
229
|
}
|
230
|
-
const handleGroupNotification = (participant, child, msg) => {
|
231
|
-
const participantJid = WABinary_1.getBinaryNodeChild(child, 'participant')?.attrs?.jid || participant
|
230
|
+
const handleGroupNotification = (participant, child, msg, mode) => {
|
231
|
+
const participantJid = mode === 'lid' ? WABinary_1.getBinaryNodeChild(child, 'participant')?.attrs?.phone_number : WABinary_1.getBinaryNodeChild(child, 'participant')?.attrs?.jid || participant
|
232
232
|
switch (child.tag) {
|
233
233
|
case 'create':
|
234
234
|
const metadata = groups_1.extractGroupMetadata(child)
|
@@ -259,7 +259,7 @@ ephemeralExpiration: +(child.attrs.expiration || 0)
|
|
259
259
|
}
|
260
260
|
break
|
261
261
|
case 'modify':
|
262
|
-
const oldNumber = WABinary_1.getBinaryNodeChildren(child, 'participant').map(p => p.attrs.jid)
|
262
|
+
const oldNumber = mode === 'lid' ? WABinary_1.getBinaryNodeChildren(child, 'participant').map(p => p.attrs.phone_number) : WABinary_1.getBinaryNodeChildren(child, 'participant').map(p => p.attrs.jid)
|
263
263
|
msg.messageStubParameters = oldNumber || []
|
264
264
|
msg.messageStubType = Types_1.WAMessageStubType.GROUP_PARTICIPANT_CHANGE_NUMBER
|
265
265
|
break
|
@@ -273,7 +273,7 @@ if (child.attrs?.reason === 'linked_group_join') {
|
|
273
273
|
stubType = GROUP_PARTICIPANT_LINKED_GROUP_JOIN
|
274
274
|
}
|
275
275
|
msg.messageStubType = Types_1.WAMessageStubType[stubType]
|
276
|
-
const participants = WABinary_1.getBinaryNodeChildren(child, 'participant').map(p => p.attrs.jid)
|
276
|
+
const participants = mode === 'lid' ? WABinary_1.getBinaryNodeChildren(child, 'participant').map(p => p.attrs.phone_number) : WABinary_1.getBinaryNodeChildren(child, 'participant').map(p => p.attrs.jid)
|
277
277
|
if (participants.length === 1 &&
|
278
278
|
// if recv. "remove" message and sender removed themselves
|
279
279
|
// mark as left
|
@@ -285,7 +285,7 @@ msg.messageStubParameters = participants
|
|
285
285
|
break
|
286
286
|
case 'subject':
|
287
287
|
msg.messageStubType = Types_1.WAMessageStubType.GROUP_CHANGE_SUBJECT
|
288
|
-
msg.messageStubParameters = [child.attrs.subject]
|
288
|
+
msg.messageStubParameters = [participantJid, child.attrs.subject]
|
289
289
|
break
|
290
290
|
case 'description':
|
291
291
|
const description = WABinary_1.getBinaryNodeChild(child, 'body')?.content?.toString()
|
@@ -346,7 +346,7 @@ break
|
|
346
346
|
case 'linked_group_promote':
|
347
347
|
case 'linked_group_demote':
|
348
348
|
const stubtype = `COMMUNITY_PARTICIPANT_${child.tag.split('_')[2].toUpperCase()}`
|
349
|
-
const participantS = WABinary_1.getBinaryNodeChildren(child, 'participant').map(p => p.attrs.jid)
|
349
|
+
const participantS = mode === 'lid' ? WABinary_1.getBinaryNodeChildren(child, 'participant').map(p => p.attrs.phone_number) : WABinary_1.getBinaryNodeChildren(child, 'participant').map(p => p.attrs.jid)
|
350
350
|
msg.messageStubType = Types_1.WAMessageStubType[stubtype]
|
351
351
|
msg.messageStubParameters = participantS
|
352
352
|
break
|
@@ -452,7 +452,8 @@ logger.debug({ jid }, 'got privacy token update')
|
|
452
452
|
}
|
453
453
|
break
|
454
454
|
case 'w:gp2':
|
455
|
-
|
455
|
+
const mode = node.attrs.addressing_mode
|
456
|
+
handleGroupNotification(mode === 'lid' ? node.attrs.participant_pn : node.attrs.participant, child, result, mode)
|
456
457
|
break
|
457
458
|
case 'newsletter':
|
458
459
|
handleNewsletterNotification(node.attrs.from, child)
|
@@ -550,7 +551,7 @@ tag: 'iq',
|
|
550
551
|
attrs: {
|
551
552
|
to: WABinary_1.S_WHATSAPP_NET,
|
552
553
|
type: 'set',
|
553
|
-
id:
|
554
|
+
id: sock.generateMessageTag(),
|
554
555
|
xmlns: 'md'
|
555
556
|
},
|
556
557
|
content: [
|
@@ -1059,7 +1060,7 @@ logger.trace(`sendActiveReceipts set to "${sendActiveReceipts}"`)
|
|
1059
1060
|
}
|
1060
1061
|
})
|
1061
1062
|
return {
|
1062
|
-
...
|
1063
|
+
...sock,
|
1063
1064
|
sendMessageAck,
|
1064
1065
|
sendRetryRequest,
|
1065
1066
|
offerCall,
|