@hansaka02/baileys 1.0.0 → 7.3.2
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 +172 -172
- package/WAProto/AICommon/AICommon.d.ts +7102 -5380
- package/WAProto/AICommon/AICommon.js +13991 -9169
- package/WAProto/AICommon/AICommon.proto +110 -3
- package/WAProto/CompanionReg/CompanionReg.d.ts +27 -0
- package/WAProto/CompanionReg/CompanionReg.js +114 -0
- package/WAProto/CompanionReg/CompanionReg.proto +3 -0
- package/WAProto/DeviceCapabilities/DeviceCapabilities.d.ts +244 -0
- package/WAProto/DeviceCapabilities/DeviceCapabilities.js +652 -0
- package/WAProto/DeviceCapabilities/DeviceCapabilities.proto +19 -0
- package/WAProto/E2E/E2E.d.ts +7234 -1003
- package/WAProto/E2E/E2E.js +77193 -51248
- package/WAProto/E2E/E2E.proto +68 -12
- package/WAProto/HistorySync/HistorySync.d.ts +1195 -75
- package/WAProto/HistorySync/HistorySync.js +3375 -178
- package/WAProto/HistorySync/HistorySync.proto +3 -3
- package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.d.ts +18 -6
- package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.js +98 -49
- package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.proto +2 -2
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.d.ts +7468 -1051
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.js +75226 -48422
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.proto +6 -0
- package/WAProto/StatusAttributions/StatusAttributions.d.ts +5 -2
- package/WAProto/StatusAttributions/StatusAttributions.js +21 -0
- package/WAProto/StatusAttributions/StatusAttributions.proto +3 -0
- package/WAProto/SyncAction/SyncAction.d.ts +2271 -280
- package/WAProto/SyncAction/SyncAction.js +9423 -2023
- package/WAProto/SyncAction/SyncAction.proto +208 -15
- package/WAProto/Wa6/Wa6.d.ts +20 -1
- package/WAProto/Wa6/Wa6.js +83 -0
- package/WAProto/Wa6/Wa6.proto +3 -0
- package/WAProto/Web/Web.d.ts +8207 -1194
- package/WAProto/Web/Web.js +92664 -63403
- package/WAProto/Web/Web.proto +31 -13
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Socket/messages-recv.js +9 -1
- package/lib/Types/MexUpdates.js +1 -0
- package/lib/Utils/crypto.js +1 -1
- package/lib/Utils/decode-wa-message.js +14 -16
- package/lib/Utils/generics.js +63 -16
- package/lib/Utils/messages.js +40 -0
- package/lib/Utils/process-message.js +336 -24
- package/lib/Utils/validate-connection.js +51 -9
- package/package.json +19 -19
|
@@ -103,7 +103,111 @@ function decryptPollVote({ encPayload, encIv }, { pollCreatorJid, pollMsgId, pol
|
|
|
103
103
|
const decKey = crypto_1.hmacSign(sign, key0, 'sha256')
|
|
104
104
|
const aad = toBinary(`${pollMsgId}\u0000${voterJid}`)
|
|
105
105
|
const decrypted = crypto_1.aesDecryptGCM(encPayload, decKey, encIv, aad)
|
|
106
|
+
|
|
106
107
|
return WAProto_1.proto.Message.PollVoteMessage.decode(decrypted)
|
|
108
|
+
|
|
109
|
+
function toBinary(txt) {
|
|
110
|
+
return Buffer.from(txt)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Decrypt an event edit
|
|
116
|
+
* @param edit encrypted event edit
|
|
117
|
+
* @returns message
|
|
118
|
+
*/
|
|
119
|
+
function decryptEventEdit({ encPayload, encIv }, { eventCreatorJid, eventMsgId, eventEncKey, responderJid }) {
|
|
120
|
+
const sign = Buffer.concat([
|
|
121
|
+
toBinary(eventMsgId),
|
|
122
|
+
toBinary(eventCreatorJid),
|
|
123
|
+
toBinary(responderJid),
|
|
124
|
+
toBinary('Event Edit'),
|
|
125
|
+
new Uint8Array([1])
|
|
126
|
+
])
|
|
127
|
+
|
|
128
|
+
const key0 = crypto_1.hmacSign(eventEncKey, new Uint8Array(32), 'sha256')
|
|
129
|
+
const decKey = crypto_1.hmacSign(sign, key0, 'sha256')
|
|
130
|
+
const decrypted = crypto_1.aesDecryptGCM(encPayload, decKey, encIv, null)
|
|
131
|
+
|
|
132
|
+
return WAProto_1.proto.Message.decode(decrypted)
|
|
133
|
+
|
|
134
|
+
function toBinary(txt) {
|
|
135
|
+
return Buffer.from(txt)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Decrypt an event response
|
|
141
|
+
* @param response encrypted event response
|
|
142
|
+
* @param ctx additional info about the event required for decryption
|
|
143
|
+
* @returns event response message
|
|
144
|
+
*/
|
|
145
|
+
function decryptEventResponse({ encPayload, encIv }, { eventCreatorJid, eventMsgId, eventEncKey, responderJid }) {
|
|
146
|
+
const sign = Buffer.concat([
|
|
147
|
+
toBinary(eventMsgId),
|
|
148
|
+
toBinary(eventCreatorJid),
|
|
149
|
+
toBinary(responderJid),
|
|
150
|
+
toBinary('Event Response'),
|
|
151
|
+
new Uint8Array([1])
|
|
152
|
+
])
|
|
153
|
+
|
|
154
|
+
const key0 = crypto_1.hmacSign(eventEncKey, new Uint8Array(32), 'sha256')
|
|
155
|
+
const decKey = crypto_1.hmacSign(sign, key0, 'sha256')
|
|
156
|
+
const aad = toBinary(`${eventMsgId}\u0000${responderJid}`)
|
|
157
|
+
const decrypted = crypto_1.aesDecryptGCM(encPayload, decKey, encIv, aad)
|
|
158
|
+
|
|
159
|
+
return WAProto_1.proto.Message.EventResponseMessage.decode(decrypted)
|
|
160
|
+
|
|
161
|
+
function toBinary(txt) {
|
|
162
|
+
return Buffer.from(txt)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Decrypt an comment message
|
|
168
|
+
* @param comment encrypted comment message
|
|
169
|
+
* @returns message
|
|
170
|
+
*/
|
|
171
|
+
function decryptComment({ encPayload, encIv }, { commentCreatorJid, commentMsgId, commentEncKey, commentJid }) {
|
|
172
|
+
const sign = Buffer.concat([
|
|
173
|
+
toBinary(commentMsgId),
|
|
174
|
+
toBinary(commentCreatorJid),
|
|
175
|
+
toBinary(commentJid),
|
|
176
|
+
toBinary('Enc Comment'),
|
|
177
|
+
new Uint8Array([1])
|
|
178
|
+
])
|
|
179
|
+
|
|
180
|
+
const key0 = crypto_1.hmacSign(commentEncKey, new Uint8Array(32), 'sha256')
|
|
181
|
+
const decKey = crypto_1.hmacSign(sign, key0, 'sha256')
|
|
182
|
+
const decrypted = crypto_1.aesDecryptGCM(encPayload, decKey, encIv, null)
|
|
183
|
+
|
|
184
|
+
return WAProto_1.proto.Message.decode(decrypted)
|
|
185
|
+
|
|
186
|
+
function toBinary(txt) {
|
|
187
|
+
return Buffer.from(txt)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Decrypt an reaction
|
|
193
|
+
* @param reaction encrypted reaction
|
|
194
|
+
* @returns reaction message
|
|
195
|
+
*/
|
|
196
|
+
function decryptReaction({ encPayload, encIv }, { reactionCreatorJid, reactionMsgId, reactionEncKey, reactionJid }) {
|
|
197
|
+
const sign = Buffer.concat([
|
|
198
|
+
toBinary(reactionMsgId),
|
|
199
|
+
toBinary(reactionCreatorJid),
|
|
200
|
+
toBinary(reactionJid),
|
|
201
|
+
toBinary('Enc Reaction'),
|
|
202
|
+
new Uint8Array([1])
|
|
203
|
+
])
|
|
204
|
+
|
|
205
|
+
const key0 = crypto_1.hmacSign(reactionEncKey, new Uint8Array(32), 'sha256')
|
|
206
|
+
const decKey = crypto_1.hmacSign(sign, key0, 'sha256')
|
|
207
|
+
const decrypted = crypto_1.aesDecryptGCM(encPayload, decKey, encIv, null)
|
|
208
|
+
|
|
209
|
+
return WAProto_1.proto.Message.ReactionMessage.decode(decrypted)
|
|
210
|
+
|
|
107
211
|
function toBinary(txt) {
|
|
108
212
|
return Buffer.from(txt)
|
|
109
213
|
}
|
|
@@ -111,6 +215,7 @@ function decryptPollVote({ encPayload, encIv }, { pollCreatorJid, pollMsgId, pol
|
|
|
111
215
|
|
|
112
216
|
const processMessage = async (message, { shouldProcessHistoryMsg, placeholderResendCache, ev, creds, signalRepository, keyStore, logger, options, getMessage }) => {
|
|
113
217
|
const meId = creds.me.id
|
|
218
|
+
const meLid = creds.me.lid
|
|
114
219
|
const { accountSettings } = creds
|
|
115
220
|
const chat = { id: WABinary_1.jidNormalizedUser(getChatId(message.key)) }
|
|
116
221
|
const isRealMsg = isRealMessage(message, meId)
|
|
@@ -373,35 +478,50 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
373
478
|
}
|
|
374
479
|
}
|
|
375
480
|
else if (content?.pollUpdateMessage) {
|
|
376
|
-
const
|
|
481
|
+
const pollUpdate = content.pollUpdateMessage
|
|
482
|
+
const creationMsgKey = pollUpdate.pollCreationMessageKey
|
|
483
|
+
|
|
377
484
|
// we need to fetch the poll creation message to get the poll enc key
|
|
378
485
|
const pollMsg = await getMessage(creationMsgKey)
|
|
379
486
|
if (pollMsg) {
|
|
380
|
-
const meIdNormalised = WABinary_1.jidNormalizedUser(meId)
|
|
381
|
-
const pollCreatorJid = generics_1.getKeyAuthor(creationMsgKey, meIdNormalised)
|
|
382
|
-
const voterJid = generics_1.getKeyAuthor(message.key, meIdNormalised)
|
|
383
|
-
const pollEncKey = pollMsg.messageContextInfo?.messageSecret
|
|
384
487
|
try {
|
|
385
|
-
const
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
488
|
+
const meLidNormalised = WABinary_1.jidNormalizedUser(meLid)
|
|
489
|
+
const getDevice = messages_1.getDevice(creationMsgKey.id)
|
|
490
|
+
const pollCreationFromMe = getDevice === 'baileys' ? true : false
|
|
491
|
+
const pollEncKey = pollMsg.messageContextInfo?.messageSecret
|
|
492
|
+
const voterJid = generics_1.getKeyAuthor(message.key, meLidNormalised)
|
|
493
|
+
|
|
494
|
+
let pollCreatorJid = generics_1.getKeyAuthor(creationMsgKey, meLidNormalised)
|
|
495
|
+
|
|
496
|
+
if (pollCreationFromMe) {
|
|
497
|
+
pollCreatorJid = meLidNormalised
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
if (!pollEncKey) {
|
|
501
|
+
logger?.warn({ vote: pollUpdate.vote, creationMsgKey }, 'poll creation: missing messageSecret for decryption')
|
|
502
|
+
} else {
|
|
503
|
+
const voteMsg = decryptPollVote(pollUpdate.vote, {
|
|
504
|
+
pollEncKey,
|
|
505
|
+
pollCreatorJid,
|
|
506
|
+
pollMsgId: creationMsgKey.id,
|
|
507
|
+
voterJid
|
|
508
|
+
})
|
|
509
|
+
|
|
510
|
+
ev.emit('messages.update', [
|
|
511
|
+
{
|
|
512
|
+
key: creationMsgKey,
|
|
513
|
+
update: {
|
|
514
|
+
pollUpdates: [
|
|
515
|
+
{
|
|
516
|
+
pollUpdateMessageKey: message.key,
|
|
517
|
+
vote: voteMsg,
|
|
518
|
+
senderTimestampMs: content.pollUpdateMessage.senderTimestampMs.toNumber()
|
|
519
|
+
}
|
|
520
|
+
]
|
|
521
|
+
}
|
|
402
522
|
}
|
|
403
|
-
|
|
404
|
-
|
|
523
|
+
])
|
|
524
|
+
}
|
|
405
525
|
}
|
|
406
526
|
catch (err) {
|
|
407
527
|
logger?.warn({ err, creationMsgKey }, 'failed to decrypt poll vote')
|
|
@@ -411,6 +531,194 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
411
531
|
logger?.warn({ creationMsgKey }, 'poll creation message not found, cannot decrypt update')
|
|
412
532
|
}
|
|
413
533
|
}
|
|
534
|
+
else if (content?.secretEncryptedMessage) {
|
|
535
|
+
const encEventEdit = content.secretEncryptedMessage
|
|
536
|
+
const creationMsgKey = encEventEdit.targetMessageKey
|
|
537
|
+
|
|
538
|
+
if (WAProto_1.proto.Message.SecretEncryptedMessage.SecretEncType[encEventEdit.secretEncType] !== 'EVENT_EDIT') return
|
|
539
|
+
|
|
540
|
+
// we need to fetch the event creation message to get the event enc key
|
|
541
|
+
const eventMsg = await getMessage(creationMsgKey)
|
|
542
|
+
if (eventMsg) {
|
|
543
|
+
try {
|
|
544
|
+
const meLidNormalised = WABinary_1.jidNormalizedUser(meLid)
|
|
545
|
+
const eventCreatorJid = generics_1.getKeyAuthor(message.key, meLidNormalised)
|
|
546
|
+
const responderJid = generics_1.getKeyAuthor(message.key, meLidNormalised)
|
|
547
|
+
const eventEncKey = eventMsg.messageContextInfo?.messageSecret
|
|
548
|
+
|
|
549
|
+
if (!eventEncKey) {
|
|
550
|
+
logger?.warn({ encEventEdit, creationMsgKey }, 'event edit: missing messageSecret for decryption')
|
|
551
|
+
} else {
|
|
552
|
+
const responseMsg = decryptEventEdit(encEventEdit, {
|
|
553
|
+
eventEncKey,
|
|
554
|
+
eventCreatorJid,
|
|
555
|
+
eventMsgId: creationMsgKey.id,
|
|
556
|
+
responderJid
|
|
557
|
+
})
|
|
558
|
+
const content = messages_1.normalizeMessageContent(responseMsg)
|
|
559
|
+
const protocolMsg = content?.protocolMessage
|
|
560
|
+
|
|
561
|
+
ev.emit('messages.update', [
|
|
562
|
+
{
|
|
563
|
+
key: { ...message.key, id: protocolMsg.key?.id },
|
|
564
|
+
update: {
|
|
565
|
+
message: {
|
|
566
|
+
messageContextInfo: responseMsg.messageContextInfo,
|
|
567
|
+
editedMessage: {
|
|
568
|
+
message: protocolMsg.editedMessage
|
|
569
|
+
}
|
|
570
|
+
},
|
|
571
|
+
messageTimestamp: protocolMsg.timestampMs
|
|
572
|
+
? Math.floor(generics_1.toNumber(protocolMsg.timestampMs) / 1000)
|
|
573
|
+
: message.messageTimestamp
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
])
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
catch (err) {
|
|
580
|
+
logger?.warn({ err, creationMsgKey, encEventEdit }, 'failed to decrypt event edit')
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
else {
|
|
584
|
+
logger?.warn({ encEventEdit, creationMsgKey }, 'event creation message not found, cannot decrypt update')
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
else if (content?.encEventResponseMessage) {
|
|
588
|
+
const encEventResponse = content.encEventResponseMessage
|
|
589
|
+
const creationMsgKey = encEventResponse.eventCreationMessageKey
|
|
590
|
+
|
|
591
|
+
// we need to fetch the event creation message to get the event enc key
|
|
592
|
+
const eventMsg = await getMessage(creationMsgKey)
|
|
593
|
+
if (eventMsg) {
|
|
594
|
+
try {
|
|
595
|
+
const meLidNormalised = WABinary_1.jidNormalizedUser(meLid)
|
|
596
|
+
const eventCreatorJid = generics_1.getKeyAuthor(creationMsgKey, meLidNormalised)
|
|
597
|
+
const responderJid = generics_1.getKeyAuthor(message.key, meLidNormalised)
|
|
598
|
+
const eventEncKey = eventMsg.messageContextInfo?.messageSecret
|
|
599
|
+
|
|
600
|
+
if (!eventEncKey) {
|
|
601
|
+
logger?.warn({ encEventResponse, creationMsgKey }, 'event response: missing messageSecret for decryption')
|
|
602
|
+
} else {
|
|
603
|
+
const responseMsg = decryptEventResponse(encEventResponse, {
|
|
604
|
+
eventEncKey,
|
|
605
|
+
eventCreatorJid,
|
|
606
|
+
eventMsgId: creationMsgKey.id,
|
|
607
|
+
responderJid
|
|
608
|
+
})
|
|
609
|
+
|
|
610
|
+
const eventResponse = {
|
|
611
|
+
eventResponseMessageKey: message.key,
|
|
612
|
+
senderTimestampMs: responseMsg.timestampMs,
|
|
613
|
+
response: responseMsg
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
ev.emit('messages.update', [
|
|
617
|
+
{
|
|
618
|
+
key: creationMsgKey,
|
|
619
|
+
update: {
|
|
620
|
+
eventResponses: [eventResponse]
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
])
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
catch (err) {
|
|
627
|
+
logger?.warn({ err, creationMsgKey, encEventResponse }, 'failed to decrypt event response')
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
else {
|
|
631
|
+
logger?.warn({ encEventResponse, creationMsgKey }, 'event creation message not found, cannot decrypt update')
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
else if (content?.encCommentMessage) {
|
|
635
|
+
const encComment = content.encCommentMessage
|
|
636
|
+
const creationMsgKey = encComment.targetMessageKey
|
|
637
|
+
|
|
638
|
+
// we need to fetch the message to get the reaction enc key
|
|
639
|
+
const commentMsg = await getMessage(creationMsgKey)
|
|
640
|
+
if (commentMsg) {
|
|
641
|
+
try {
|
|
642
|
+
const meLidNormalised = WABinary_1.jidNormalizedUser(meLid)
|
|
643
|
+
const commentCreatorJid = creationMsgKey.participant ? creationMsgKey.participant : message.key?.participant ? message.key.participant : meLidNormalised
|
|
644
|
+
const commentJid = message.key?.participant ? message.key.participant : creationMsgKey.participant ? creationMsgKey.participant : meLidNormalised
|
|
645
|
+
const commentEncKey = commentMsg.messageContextInfo?.messageSecret
|
|
646
|
+
|
|
647
|
+
if (!commentEncKey) {
|
|
648
|
+
logger?.warn({ encComment, creationMsgKey }, 'comment message: missing messageSecret for decryption')
|
|
649
|
+
} else {
|
|
650
|
+
const responseMsg = decryptComment(encComment, {
|
|
651
|
+
commentEncKey,
|
|
652
|
+
commentCreatorJid,
|
|
653
|
+
commentMsgId: creationMsgKey.id,
|
|
654
|
+
commentJid
|
|
655
|
+
})
|
|
656
|
+
|
|
657
|
+
ev.emit('messages.upsert', {
|
|
658
|
+
messages: [{
|
|
659
|
+
key: message.key,
|
|
660
|
+
message: responseMsg
|
|
661
|
+
}],
|
|
662
|
+
type: 'append'
|
|
663
|
+
})
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
catch (err) {
|
|
667
|
+
logger?.warn({ err, creationMsgKey, encComment }, 'failed to decrypt comment message')
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
else {
|
|
671
|
+
logger?.warn({ encComment, creationMsgKey }, 'creation message not found, cannot decrypt')
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
else if (content?.encReactionMessage) {
|
|
675
|
+
const encReaction = content.encReactionMessage
|
|
676
|
+
const creationMsgKey = encReaction.targetMessageKey
|
|
677
|
+
|
|
678
|
+
// we need to fetch the message to get the reaction enc key
|
|
679
|
+
const reactMsg = await getMessage(creationMsgKey)
|
|
680
|
+
if (reactMsg) {
|
|
681
|
+
try {
|
|
682
|
+
const meLidNormalised = WABinary_1.jidNormalizedUser(meLid)
|
|
683
|
+
const reactionCreatorJid = creationMsgKey.participant ? creationMsgKey.participant : message.key?.participant ? message.key.participant : meLidNormalised
|
|
684
|
+
const reactionJid = message.key?.participant ? message.key.participant : creationMsgKey.participant ? creationMsgKey.participant : meLidNormalised
|
|
685
|
+
const reactionEncKey = reactMsg.messageContextInfo?.messageSecret
|
|
686
|
+
|
|
687
|
+
if (!reactionEncKey) {
|
|
688
|
+
logger?.warn({ encReaction, creationMsgKey }, 'reaction: missing messageSecret for decryption')
|
|
689
|
+
} else {
|
|
690
|
+
const responseMsg = decryptReaction(encReaction, {
|
|
691
|
+
reactionEncKey,
|
|
692
|
+
reactionCreatorJid,
|
|
693
|
+
reactionMsgId: creationMsgKey.id,
|
|
694
|
+
reactionJid
|
|
695
|
+
})
|
|
696
|
+
|
|
697
|
+
const Reaction = {
|
|
698
|
+
key: message.key,
|
|
699
|
+
message: {
|
|
700
|
+
reactionMessage: {
|
|
701
|
+
key: creationMsgKey,
|
|
702
|
+
text: responseMsg.text,
|
|
703
|
+
senderTimestampMs: responseMsg.senderTimestampMs
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
ev.emit('messages.upsert', {
|
|
709
|
+
messages: [Reaction],
|
|
710
|
+
type: 'append'
|
|
711
|
+
})
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
catch (err) {
|
|
715
|
+
logger?.warn({ err, creationMsgKey, encReaction }, 'failed to decrypt reaction')
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
else {
|
|
719
|
+
logger?.warn({ encReaction, creationMsgKey }, 'creation message not found, cannot decrypt')
|
|
720
|
+
}
|
|
721
|
+
}
|
|
414
722
|
if (Object.keys(chat).length > 1) {
|
|
415
723
|
ev.emit('chats.update', [chat])
|
|
416
724
|
}
|
|
@@ -422,5 +730,9 @@ module.exports = {
|
|
|
422
730
|
shouldIncrementChatUnread,
|
|
423
731
|
getChatId,
|
|
424
732
|
decryptPollVote,
|
|
733
|
+
decryptEventEdit,
|
|
734
|
+
decryptEventResponse,
|
|
735
|
+
decryptComment,
|
|
736
|
+
decryptReaction,
|
|
425
737
|
processMessage
|
|
426
738
|
}
|
|
@@ -77,12 +77,37 @@ const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentity
|
|
|
77
77
|
const appVersionBuf = crypto_1.createHash('md5')
|
|
78
78
|
.update(config.version.join('.')) // join as string
|
|
79
79
|
.digest()
|
|
80
|
+
|
|
80
81
|
const companion = {
|
|
81
82
|
os: config.browser[0],
|
|
82
83
|
platformType: getPlatformType(config.browser[1]),
|
|
83
84
|
requireFullSync: config.syncFullHistory,
|
|
85
|
+
historySyncConfig: {
|
|
86
|
+
storageQuotaMb: 10240,
|
|
87
|
+
inlineInitialPayloadInE2EeMsg: true,
|
|
88
|
+
recentSyncDaysLimit: undefined,
|
|
89
|
+
supportCallLogHistory: false,
|
|
90
|
+
supportBotUserAgentChatHistory: true,
|
|
91
|
+
supportCagReactionsAndPolls: true,
|
|
92
|
+
supportBizHostedMsg: true,
|
|
93
|
+
supportRecentSyncChunkMessageCountTuning: true,
|
|
94
|
+
supportHostedGroupMsg: true,
|
|
95
|
+
supportFbidBotChatHistory: true,
|
|
96
|
+
supportAddOnHistorySyncMigration: undefined,
|
|
97
|
+
supportMessageAssociation: true,
|
|
98
|
+
supportGroupHistory: false,
|
|
99
|
+
onDemandReady: undefined,
|
|
100
|
+
supportGuestChat: undefined
|
|
101
|
+
},
|
|
102
|
+
version: {
|
|
103
|
+
primary: 10,
|
|
104
|
+
secondary: 15,
|
|
105
|
+
tertiary: 7
|
|
106
|
+
}
|
|
84
107
|
}
|
|
108
|
+
|
|
85
109
|
const companionProto = WAProto_1.proto.DeviceProps.encode(companion).finish()
|
|
110
|
+
|
|
86
111
|
const registerPayload = {
|
|
87
112
|
...getClientPayload(config),
|
|
88
113
|
passive: false,
|
|
@@ -96,8 +121,9 @@ const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentity
|
|
|
96
121
|
eSkeyId: generics_1.encodeBigEndian(signedPreKey.keyId, 3),
|
|
97
122
|
eSkeyVal: signedPreKey.keyPair.public,
|
|
98
123
|
eSkeySig: signedPreKey.signature,
|
|
99
|
-
}
|
|
124
|
+
}
|
|
100
125
|
}
|
|
126
|
+
|
|
101
127
|
return WAProto_1.proto.ClientPayload.fromObject(registerPayload)
|
|
102
128
|
}
|
|
103
129
|
|
|
@@ -115,25 +141,41 @@ const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, s
|
|
|
115
141
|
const jid = deviceNode.attrs.jid
|
|
116
142
|
const lid = deviceNode.attrs.lid
|
|
117
143
|
const { details, hmac, accountType } = WAProto_1.proto.ADVSignedDeviceIdentityHMAC.decode(deviceIdentityNode.content)
|
|
118
|
-
|
|
119
|
-
|
|
144
|
+
|
|
145
|
+
let hmacPrefix = Buffer.from([])
|
|
146
|
+
if (accountType !== undefined && accountType === WAProto_1.proto.ADVEncryptionType.HOSTED) {
|
|
147
|
+
hmacPrefix = Buffer.from([6, 5])
|
|
148
|
+
}
|
|
149
|
+
|
|
120
150
|
const advSign = crypto_2.hmacSign(Buffer.concat([hmacPrefix, details]), Buffer.from(advSecretKey, 'base64'))
|
|
121
151
|
if (Buffer.compare(hmac, advSign) !== 0) {
|
|
122
152
|
throw new boom_1.Boom('Invalid account signature')
|
|
123
153
|
}
|
|
154
|
+
|
|
124
155
|
const account = WAProto_1.proto.ADVSignedDeviceIdentity.decode(details)
|
|
125
156
|
const { accountSignatureKey, accountSignature, details: deviceDetails } = account
|
|
126
|
-
|
|
157
|
+
|
|
158
|
+
const decodedDeviceIdentity = WAProto_1.proto.ADVDeviceIdentity.decode(deviceDetails)
|
|
159
|
+
|
|
160
|
+
const accountSignaturePrefix =
|
|
161
|
+
decodedDeviceIdentity.deviceType === WAProto_1.proto.ADVEncryptionType.HOSTED
|
|
162
|
+
? Buffer.from([6, 5])
|
|
163
|
+
: Buffer.from([6, 0])
|
|
164
|
+
const accountMsg = Buffer.concat([accountSignaturePrefix, deviceDetails, signedIdentityKey.public])
|
|
127
165
|
if (!crypto_2.Curve.verify(accountSignatureKey, accountMsg, accountSignature)) {
|
|
128
166
|
throw new boom_1.Boom('Failed to verify account signature')
|
|
129
167
|
}
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
168
|
+
|
|
169
|
+
const deviceMsg = Buffer.concat([
|
|
170
|
+
Buffer.from([6, 1]),
|
|
171
|
+
deviceDetails,
|
|
172
|
+
signedIdentityKey.public,
|
|
173
|
+
accountSignatureKey
|
|
174
|
+
])
|
|
133
175
|
account.deviceSignature = crypto_2.Curve.sign(signedIdentityKey.private, deviceMsg)
|
|
134
176
|
const identity = signal_1.createSignalIdentity(lid, accountSignatureKey)
|
|
135
177
|
const accountEnc = encodeSignedDeviceIdentity(account, false)
|
|
136
|
-
const
|
|
178
|
+
const deviceIdentityData = WAProto_1.proto.ADVDeviceIdentity.decode(account.details)
|
|
137
179
|
const reply = {
|
|
138
180
|
tag: 'iq',
|
|
139
181
|
attrs: {
|
|
@@ -148,7 +190,7 @@ const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, s
|
|
|
148
190
|
content: [
|
|
149
191
|
{
|
|
150
192
|
tag: 'device-identity',
|
|
151
|
-
attrs: { 'key-index':
|
|
193
|
+
attrs: { 'key-index': deviceIdentityData.keyIndex.toString() },
|
|
152
194
|
content: accountEnc
|
|
153
195
|
}
|
|
154
196
|
]
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hansaka02/baileys",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "WhatsApp API Modification By
|
|
3
|
+
"version": "7.3.2",
|
|
4
|
+
"description": "WhatsApp API Modification By Itsukiichan",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"whatsapp",
|
|
7
7
|
"js-whatsapp",
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
"automation",
|
|
13
13
|
"multi-device"
|
|
14
14
|
],
|
|
15
|
-
"homepage": "https://github.com/hansaka02/
|
|
16
|
-
"repository": {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
},
|
|
15
|
+
"homepage": "https://github.com/hansaka02/Baileys",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+ssh://git@github.com/hansaka02/Baileys.git"
|
|
19
|
+
},
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"author": "hansaka02",
|
|
22
22
|
"main": "lib/index.js",
|
|
@@ -42,23 +42,23 @@
|
|
|
42
42
|
"test": "jest"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@hapi/boom": "^9.1.3",
|
|
46
45
|
"@adiwajshing/keyed-db": "^0.2.4",
|
|
47
|
-
"@cacheable/node-cache": "1.5.3",
|
|
48
|
-
"@
|
|
49
|
-
"@itsukichan/
|
|
46
|
+
"@cacheable/node-cache": "1.5.3",
|
|
47
|
+
"@hapi/boom": "^9.1.3",
|
|
48
|
+
"@itsukichan/eslint-config": "^1.0.0",
|
|
49
|
+
"@itsukichan/libsignal-node": "^1.0.1",
|
|
50
50
|
"async-mutex": "^0.5.0",
|
|
51
|
+
"audio-decode": "^2.2.2",
|
|
51
52
|
"axios": "^1.12.1",
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
53
|
+
"cache-manager": "^5.7.6",
|
|
54
|
+
"fflate": "^0.8.2",
|
|
55
|
+
"link-preview-js": "^3.0.14",
|
|
55
56
|
"lodash": "^4.17.21",
|
|
56
|
-
"
|
|
57
|
-
"lru-cache": "^11.1.0",
|
|
57
|
+
"lru-cache": "^11.1.0",
|
|
58
58
|
"music-metadata": "^7.12.3",
|
|
59
59
|
"pino": "^9.6",
|
|
60
60
|
"protobufjs": "^7.2.4",
|
|
61
|
-
"qrcode-terminal": "^0.12.0",
|
|
61
|
+
"qrcode-terminal": "^0.12.0",
|
|
62
62
|
"ws": "^8.13.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"ts-node": "^10.8.1",
|
|
78
78
|
"typedoc": "^0.27.9",
|
|
79
79
|
"typedoc-plugin-markdown": "4.4.2",
|
|
80
|
-
"typescript": "^5.
|
|
80
|
+
"typescript": "^5.9.3"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"jimp": "^0.22.12"
|
|
@@ -95,6 +95,6 @@
|
|
|
95
95
|
"lib": "lib"
|
|
96
96
|
},
|
|
97
97
|
"bugs": {
|
|
98
|
-
"url": "https://github.com/
|
|
98
|
+
"url": "https://github.com/Itsukichann/Baileys/issues"
|
|
99
99
|
}
|
|
100
100
|
}
|