@badzz88/baileys 8.5.2 → 8.5.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 +1 -1
- package/WAProto/WAProto.proto +1256 -75
- package/WAProto/index.d.ts +36042 -19649
- package/WAProto/index.js +181990 -135645
- package/engine-requirements.js +7 -15
- package/lib/Defaults/index.js +22 -17
- package/lib/Signal/Group/group_cipher.js +5 -5
- package/lib/Signal/Group/keyhelper.js +4 -4
- package/lib/Signal/Group/sender-chain-key.js +2 -2
- package/lib/Signal/Group/sender-key-distribution-message.js +1 -1
- package/lib/Signal/Group/sender-key-message.js +3 -3
- package/lib/Signal/Group/sender-key-record.js +1 -1
- package/lib/Signal/Group/sender-message-key.js +5 -5
- package/lib/Signal/libsignal.js +39 -59
- package/lib/Signal/lid-mapping.js +28 -10
- package/lib/Socket/aigroups.js +5 -5
- package/lib/Socket/business.js +3 -11
- package/lib/Socket/chats.js +668 -319
- package/lib/Socket/communities.js +85 -89
- package/lib/Socket/graphql.js +435 -228
- package/lib/Socket/groups.js +132 -211
- package/lib/Socket/index.js +9 -7
- package/lib/Socket/interactive-handler.js +117 -60
- package/lib/Socket/interop.js +56 -175
- package/lib/Socket/managed-account.js +79 -48
- package/lib/Socket/messages-recv.js +898 -340
- package/lib/Socket/messages-send.js +462 -160
- package/lib/Socket/mex.js +40 -53
- package/lib/Socket/newsletter.js +291 -291
- package/lib/Socket/privacy.js +77 -265
- package/lib/Socket/registration.js +164 -157
- package/lib/Socket/socket.js +181 -199
- package/lib/Socket/username.js +144 -227
- package/lib/Store/make-cache-manager-store.js +2 -2
- package/lib/Store/make-in-memory-store.js +25 -141
- package/lib/Types/Auth.js +3 -3
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Newsletter.js +96 -65
- package/lib/Types/State.js +4 -4
- package/lib/Types/index.js +1 -1
- package/lib/Utils/auth-utils.js +52 -57
- package/lib/Utils/browser-utils.js +1 -1
- package/lib/Utils/business.js +2 -6
- package/lib/Utils/chat-utils.js +102 -38
- package/lib/Utils/crypto.js +54 -84
- package/lib/Utils/decode-wa-message.js +316 -83
- package/lib/Utils/event-buffer.js +37 -61
- package/lib/Utils/generics.js +157 -103
- package/lib/Utils/group-history.js +3 -12
- package/lib/Utils/history.js +15 -15
- package/lib/Utils/index.js +1 -5
- package/lib/Utils/link-preview.js +3 -8
- package/lib/Utils/lt-hash.js +2 -35
- package/lib/Utils/make-mutex.js +1 -1
- package/lib/Utils/message-inspect.js +393 -0
- package/lib/Utils/message-retry-manager.js +27 -92
- package/lib/Utils/messages-media.js +159 -130
- package/lib/Utils/messages.js +144 -566
- package/lib/Utils/meta-ai-msmsg.js +62 -202
- package/lib/Utils/noise-handler.js +19 -21
- package/lib/Utils/offline-node-processor.js +3 -8
- package/lib/Utils/pre-key-manager.js +13 -23
- package/lib/Utils/process-message.js +197 -106
- package/lib/Utils/reporting-utils.js +2 -2
- package/lib/Utils/signal.js +28 -63
- package/lib/Utils/stanza-ack.js +39 -12
- package/lib/Utils/sync-action-utils.js +4 -7
- package/lib/Utils/tc-token-utils.js +20 -25
- package/lib/Utils/use-multi-file-auth-state.js +30 -14
- package/lib/Utils/validate-connection.js +59 -19
- package/lib/WABinary/decode.js +50 -16
- package/lib/WABinary/encode.js +54 -224
- package/lib/WABinary/generic-utils.js +7 -97
- package/lib/WABinary/jid-utils.js +27 -14
- package/lib/WAM/encode.js +7 -7
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +58 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +7 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +13 -5
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -4
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +20 -7
- package/lib/WAUSync/Protocols/USyncNewsletterProtocol.js +865 -0
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +7 -2
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +2 -1
- package/lib/WAUSync/Protocols/index.js +1 -0
- package/lib/WAUSync/USyncBackoff.js +26 -0
- package/lib/WAUSync/USyncQuery.js +77 -6
- package/lib/WAUSync/USyncUser.js +16 -8
- package/lib/WAUSync/index.js +1 -0
- package/lib/antiban.js +608 -854
- package/lib/index.js +3 -3
- package/package.json +16 -19
- package/lib/Socket/luxu.js +0 -387
- package/lib/Socket/text-router.js +0 -83
- package/lib/Store/keyed-db.js +0 -108
- package/lib/Types/Mex.js +0 -112
- package/lib/Utils/command-loader.d.ts +0 -31
- package/lib/Utils/command-loader.js +0 -100
- package/lib/Utils/companion-reg-client-utils.js +0 -42
- package/lib/Utils/curve25519-js.js +0 -275
- package/lib/Utils/native-bridge.js +0 -82
- package/lib/Utils/session-pool.d.ts +0 -16
- package/lib/Utils/session-pool.js +0 -94
- package/lib/Utils/sticker.d.ts +0 -17
- package/lib/Utils/sticker.js +0 -145
- package/lib/Utils/view-once-cache.d.ts +0 -9
- package/lib/Utils/view-once-cache.js +0 -79
|
@@ -15,10 +15,10 @@ const business_1 = require('./business')
|
|
|
15
15
|
const mex_1 = require('./mex')
|
|
16
16
|
|
|
17
17
|
const COMMUNITY_MEX_QUERY_IDS = {
|
|
18
|
-
QUERY_PARTICIPANT_COUNT: '31981537024824320',
|
|
19
|
-
QUERY_SUBGROUPS: '25554052094203120',
|
|
20
|
-
QUERY_SUBGROUP_PARTICIPANT_COUNT: '24784259781196780',
|
|
21
|
-
UPDATE_OWNER: '24781435194845316'
|
|
18
|
+
QUERY_PARTICIPANT_COUNT: '31981537024824320',
|
|
19
|
+
QUERY_SUBGROUPS: '25554052094203120',
|
|
20
|
+
QUERY_SUBGROUP_PARTICIPANT_COUNT: '24784259781196780',
|
|
21
|
+
UPDATE_OWNER: '24781435194845316'
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const makeCommunitiesSocket = config => {
|
|
@@ -205,16 +205,16 @@ const makeCommunitiesSocket = config => {
|
|
|
205
205
|
communityFetchLinkedGroups: async jid => {
|
|
206
206
|
let communityJid = jid
|
|
207
207
|
let isCommunity = false
|
|
208
|
-
|
|
208
|
+
|
|
209
209
|
const metadata = await sock.groupMetadata(jid)
|
|
210
210
|
if (metadata.linkedParent) {
|
|
211
|
-
|
|
211
|
+
|
|
212
212
|
communityJid = metadata.linkedParent
|
|
213
213
|
} else {
|
|
214
|
-
|
|
214
|
+
|
|
215
215
|
isCommunity = true
|
|
216
216
|
}
|
|
217
|
-
|
|
217
|
+
|
|
218
218
|
const result = await communityQuery(communityJid, 'get', [{ tag: 'sub_groups', attrs: {} }])
|
|
219
219
|
const linkedGroupsData = []
|
|
220
220
|
const subGroupsNode = (0, WABinary_1.getBinaryNodeChild)(result, 'sub_groups')
|
|
@@ -317,23 +317,14 @@ const makeCommunitiesSocket = config => {
|
|
|
317
317
|
const result = (0, WABinary_1.getBinaryNodeChild)(results, 'community')
|
|
318
318
|
return result?.attrs.jid
|
|
319
319
|
},
|
|
320
|
-
|
|
321
|
-
* revoke a v4 invite for someone
|
|
322
|
-
* @param communityJid community jid
|
|
323
|
-
* @param invitedJid jid of person you invited
|
|
324
|
-
* @returns true if successful
|
|
325
|
-
*/
|
|
320
|
+
|
|
326
321
|
communityRevokeInviteV4: async (communityJid, invitedJid) => {
|
|
327
322
|
const result = await communityQuery(communityJid, 'set', [
|
|
328
323
|
{ tag: 'revoke', attrs: {}, content: [{ tag: 'participant', attrs: { jid: invitedJid } }] }
|
|
329
324
|
])
|
|
330
325
|
return !!result
|
|
331
326
|
},
|
|
332
|
-
|
|
333
|
-
* accept a CommunityInviteMessage
|
|
334
|
-
* @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
|
|
335
|
-
* @param inviteMessage the message to accept
|
|
336
|
-
*/
|
|
327
|
+
|
|
337
328
|
communityAcceptInviteV4: ev.createBufferedFunction(async (key, inviteMessage) => {
|
|
338
329
|
key = typeof key === 'string' ? { remoteJid: key } : key
|
|
339
330
|
const results = await communityQuery(inviteMessage.groupJid, 'set', [
|
|
@@ -346,10 +337,10 @@ const makeCommunitiesSocket = config => {
|
|
|
346
337
|
}
|
|
347
338
|
}
|
|
348
339
|
])
|
|
349
|
-
|
|
350
|
-
|
|
340
|
+
|
|
341
|
+
|
|
351
342
|
if (key.id) {
|
|
352
|
-
|
|
343
|
+
|
|
353
344
|
inviteMessage = index_js_1.proto.Message.GroupInviteMessage.fromObject(inviteMessage)
|
|
354
345
|
inviteMessage.inviteExpiration = 0
|
|
355
346
|
inviteMessage.inviteCode = ''
|
|
@@ -364,14 +355,14 @@ const makeCommunitiesSocket = config => {
|
|
|
364
355
|
}
|
|
365
356
|
])
|
|
366
357
|
}
|
|
367
|
-
|
|
358
|
+
|
|
368
359
|
await upsertMessage(
|
|
369
360
|
{
|
|
370
361
|
key: {
|
|
371
362
|
remoteJid: inviteMessage.groupJid,
|
|
372
363
|
id: (0, Utils_1.generateMessageIDV2)(sock.user?.id),
|
|
373
364
|
fromMe: false,
|
|
374
|
-
participant: key.remoteJid
|
|
365
|
+
participant: key.remoteJid
|
|
375
366
|
},
|
|
376
367
|
messageStubType: Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD,
|
|
377
368
|
messageStubParameters: [JSON.stringify(authState.creds.me)],
|
|
@@ -382,30 +373,15 @@ const makeCommunitiesSocket = config => {
|
|
|
382
373
|
)
|
|
383
374
|
return results.attrs.from
|
|
384
375
|
}),
|
|
385
|
-
communityGetInviteInfo: async code => {
|
|
386
|
-
const results = await communityQuery('@g.us', 'get', [{ tag: 'invite', attrs: { code } }])
|
|
387
|
-
return (0, exports.extractCommunityMetadata)(results)
|
|
388
|
-
},
|
|
389
|
-
communityToggleEphemeral: async (jid, ephemeralExpiration) => {
|
|
390
|
-
const content = ephemeralExpiration
|
|
391
|
-
? { tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } }
|
|
392
|
-
: { tag: 'not_ephemeral', attrs: {} }
|
|
393
|
-
await communityQuery(jid, 'set', [content])
|
|
394
|
-
},
|
|
395
|
-
communitySettingUpdate: async (jid, setting) => {
|
|
396
|
-
await communityQuery(jid, 'set', [{ tag: setting, attrs: {} }])
|
|
397
|
-
},
|
|
398
376
|
communityMemberAddMode: async (jid, mode) => {
|
|
399
377
|
await communityQuery(jid, 'set', [{ tag: 'member_add_mode', attrs: {}, content: mode }])
|
|
400
378
|
},
|
|
401
379
|
communityJoinApprovalMode: async (jid, mode) => {
|
|
402
380
|
await communityQuery(jid, 'set', [
|
|
403
|
-
{ tag: 'membership_approval_mode', attrs: {}, content: [{ tag: '
|
|
381
|
+
{ tag: 'membership_approval_mode', attrs: {}, content: [{ tag: 'group_join', attrs: { state: mode } }] }
|
|
404
382
|
])
|
|
405
383
|
},
|
|
406
|
-
|
|
407
|
-
* Update community profile picture
|
|
408
|
-
*/
|
|
384
|
+
|
|
409
385
|
communityUpdatePicture: async (jid, content) => {
|
|
410
386
|
const { img } = await (0, Utils_1.generateProfilePicture)(content)
|
|
411
387
|
await communityQuery(jid, 'set', [
|
|
@@ -416,34 +392,24 @@ const makeCommunitiesSocket = config => {
|
|
|
416
392
|
}
|
|
417
393
|
])
|
|
418
394
|
},
|
|
419
|
-
|
|
420
|
-
* Remove community profile picture
|
|
421
|
-
*/
|
|
395
|
+
|
|
422
396
|
communityRemovePicture: async jid => {
|
|
423
397
|
await communityQuery(jid, 'set', [{ tag: 'picture', attrs: { type: 'delete' } }])
|
|
424
398
|
},
|
|
425
|
-
|
|
426
|
-
* Update community settings (announce-only, etc.)
|
|
427
|
-
*/
|
|
399
|
+
|
|
428
400
|
communitySettingUpdate: async (jid, setting) => {
|
|
429
401
|
await communityQuery(jid, 'set', [{ tag: setting, attrs: {} }])
|
|
430
402
|
},
|
|
431
|
-
|
|
432
|
-
* Deactivate/delete a community
|
|
433
|
-
*/
|
|
403
|
+
|
|
434
404
|
communityDeactivate: async jid => {
|
|
435
405
|
await communityQuery(jid, 'set', [{ tag: 'delete_parent', attrs: {} }])
|
|
436
406
|
},
|
|
437
|
-
|
|
438
|
-
* Get info about a community from an invite link code
|
|
439
|
-
*/
|
|
407
|
+
|
|
440
408
|
communityGetInviteInfo: async code => {
|
|
441
409
|
const results = await communityQuery('@g.us', 'get', [{ tag: 'invite', attrs: { code } }])
|
|
442
410
|
return (0, exports.extractCommunityMetadata)(results)
|
|
443
411
|
},
|
|
444
|
-
|
|
445
|
-
* Toggle ephemeral messages for the whole community
|
|
446
|
-
*/
|
|
412
|
+
|
|
447
413
|
communityToggleEphemeral: async (jid, ephemeralExpiration) => {
|
|
448
414
|
const content = ephemeralExpiration
|
|
449
415
|
? { tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } }
|
|
@@ -452,52 +418,50 @@ const makeCommunitiesSocket = config => {
|
|
|
452
418
|
},
|
|
453
419
|
communityFetchAllParticipating,
|
|
454
420
|
|
|
455
|
-
|
|
421
|
+
|
|
456
422
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
*/
|
|
461
|
-
communityParticipantCount: jid =>
|
|
462
|
-
mexQuery(
|
|
423
|
+
|
|
424
|
+
communityParticipantCount: async jid => {
|
|
425
|
+
const result = await mexQuery(
|
|
463
426
|
{ group_input: { group_id: jid } },
|
|
464
427
|
COMMUNITY_MEX_QUERY_IDS.QUERY_PARTICIPANT_COUNT,
|
|
465
428
|
'xwa2_group_query_by_id'
|
|
466
|
-
)
|
|
429
|
+
)
|
|
430
|
+
return result?.participant_count ?? result?.participantCount ?? result?.count ?? result
|
|
431
|
+
},
|
|
467
432
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
433
|
+
|
|
434
|
+
communitySubgroupsMex: async jid => {
|
|
435
|
+
const result = await mexQuery(
|
|
436
|
+
{ group_input: { group_id: jid } },
|
|
437
|
+
COMMUNITY_MEX_QUERY_IDS.QUERY_SUBGROUPS,
|
|
438
|
+
'xwa2_group_query_by_id'
|
|
439
|
+
)
|
|
440
|
+
return result?.subgroups ?? result?.linked_groups ?? result?.sub_groups ?? result
|
|
441
|
+
},
|
|
474
442
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
*/
|
|
479
|
-
communitySubgroupParticipantCount: subgroupJid =>
|
|
480
|
-
mexQuery(
|
|
443
|
+
|
|
444
|
+
communitySubgroupParticipantCount: async subgroupJid => {
|
|
445
|
+
const result = await mexQuery(
|
|
481
446
|
{ group_input: { group_id: subgroupJid } },
|
|
482
447
|
COMMUNITY_MEX_QUERY_IDS.QUERY_SUBGROUP_PARTICIPANT_COUNT,
|
|
483
448
|
'xwa2_group_query_by_id'
|
|
484
|
-
)
|
|
449
|
+
)
|
|
450
|
+
return result?.participant_count ?? result?.participantCount ?? result?.count ?? result
|
|
451
|
+
},
|
|
485
452
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
* @param {string} communityJid - Community JID
|
|
490
|
-
* @param {string} newOwnerJid - JID of the new owner
|
|
491
|
-
*/
|
|
492
|
-
communityTransferOwnershipMex: (communityJid, newOwnerJid) =>
|
|
493
|
-
mexQuery(
|
|
453
|
+
|
|
454
|
+
communityTransferOwnershipMex: async (communityJid, newOwnerJid) => {
|
|
455
|
+
const result = await mexQuery(
|
|
494
456
|
{
|
|
495
457
|
group_id: communityJid,
|
|
496
458
|
role_updates: [{ user_jid: newOwnerJid, new_role: 'SUPERADMIN_MEMBER' }]
|
|
497
459
|
},
|
|
498
460
|
COMMUNITY_MEX_QUERY_IDS.UPDATE_OWNER,
|
|
499
461
|
'xwa2_community_update_owner'
|
|
500
|
-
)
|
|
462
|
+
)
|
|
463
|
+
return result?.status === 'ok' || !!result?.success || !!result
|
|
464
|
+
},
|
|
501
465
|
|
|
502
466
|
COMMUNITY_MEX_QUERY_IDS
|
|
503
467
|
}
|
|
@@ -517,6 +481,12 @@ const extractCommunityMetadata = result => {
|
|
|
517
481
|
: (0, WABinary_1.jidEncode)(community.attrs.id || '', 'g.us')
|
|
518
482
|
const eph = (0, WABinary_1.getBinaryNodeChild)(community, 'ephemeral')?.attrs.expiration
|
|
519
483
|
const memberAddMode = (0, WABinary_1.getBinaryNodeChildString)(community, 'member_add_mode') === 'all_member_add'
|
|
484
|
+
const linkedGroupsNode = (0, WABinary_1.getBinaryNodeChild)(community, 'linked_groups')
|
|
485
|
+
const linkLimit = community.attrs.parent_group_link_limit
|
|
486
|
+
? +community.attrs.parent_group_link_limit
|
|
487
|
+
: linkedGroupsNode?.attrs?.parent_group_link_limit
|
|
488
|
+
? +linkedGroupsNode.attrs.parent_group_link_limit
|
|
489
|
+
: undefined
|
|
520
490
|
const metadata = {
|
|
521
491
|
id: communityId,
|
|
522
492
|
subject: community.attrs.subject || '',
|
|
@@ -536,13 +506,39 @@ const extractCommunityMetadata = result => {
|
|
|
536
506
|
memberAddMode,
|
|
537
507
|
participants: (0, WABinary_1.getBinaryNodeChildren)(community, 'participant').map(({ attrs }) => {
|
|
538
508
|
return {
|
|
539
|
-
// TODO: IMPLEMENT THE PN/LID FIELDS HERE!!
|
|
540
509
|
id: attrs.jid,
|
|
541
|
-
admin: attrs.type || null
|
|
510
|
+
admin: attrs.type || null,
|
|
511
|
+
...(attrs.lid ? { lid: attrs.lid } : {}),
|
|
512
|
+
...(attrs.pn ? { pn: attrs.pn } : {})
|
|
542
513
|
}
|
|
543
514
|
}),
|
|
544
515
|
ephemeralDuration: eph ? +eph : undefined,
|
|
545
|
-
addressingMode: (0, WABinary_1.getBinaryNodeChildString)(community, 'addressing_mode')
|
|
516
|
+
addressingMode: (0, WABinary_1.getBinaryNodeChildString)(community, 'addressing_mode'),
|
|
517
|
+
linkLimit,
|
|
518
|
+
suspendAppealStatus: community.attrs.suspend_appeal_status || community.attrs.appeal_status || undefined,
|
|
519
|
+
allowMemberSuggestM3:
|
|
520
|
+
community.attrs.parent_group_allow_member_suggest_existing_m3 === 'true'
|
|
521
|
+
? true
|
|
522
|
+
: community.attrs.parent_group_allow_member_suggest_existing_m3 === 'false'
|
|
523
|
+
? false
|
|
524
|
+
: undefined,
|
|
525
|
+
allowMemberSuggestM3ForAdmin:
|
|
526
|
+
community.attrs.parent_group_allow_member_suggest_existing_m3_for_admin === 'true'
|
|
527
|
+
? true
|
|
528
|
+
: community.attrs.parent_group_allow_member_suggest_existing_m3_for_admin === 'false'
|
|
529
|
+
? false
|
|
530
|
+
: undefined,
|
|
531
|
+
subgroupPollInterval: community.attrs.improve_subgroup_activation_subgroup_poll_interval
|
|
532
|
+
? Number(community.attrs.improve_subgroup_activation_subgroup_poll_interval)
|
|
533
|
+
: undefined,
|
|
534
|
+
isGeneralSubgroup:
|
|
535
|
+
community.attrs.general_subgroup != null
|
|
536
|
+
? community.attrs.general_subgroup === 'true' || community.attrs.general_subgroup === true
|
|
537
|
+
: undefined,
|
|
538
|
+
isHiddenSubgroup:
|
|
539
|
+
community.attrs.hidden_subgroup != null
|
|
540
|
+
? community.attrs.hidden_subgroup === 'true' || community.attrs.hidden_subgroup === true
|
|
541
|
+
: undefined
|
|
546
542
|
}
|
|
547
543
|
return metadata
|
|
548
544
|
}
|