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