mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix: include accountSignatureKey in retry requests
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
import { proto } from '../../WAProto'
|
import { proto } from '../../WAProto'
|
||||||
import { KEY_BUNDLE_TYPE, MIN_PREKEY_COUNT } from '../Defaults'
|
import { KEY_BUNDLE_TYPE, MIN_PREKEY_COUNT } from '../Defaults'
|
||||||
import { MessageReceiptType, MessageRelayOptions, MessageUserReceipt, SocketConfig, WACallEvent, WAMessageKey, WAMessageStubType, WAPatchName } from '../Types'
|
import { MessageReceiptType, MessageRelayOptions, MessageUserReceipt, SocketConfig, WACallEvent, WAMessageKey, WAMessageStubType, WAPatchName } from '../Types'
|
||||||
import { decodeMediaRetryNode, decodeMessageStanza, delay, encodeBigEndian, getCallStatusFromNode, getNextPreKeys, getStatusFromReceiptType, isHistoryMsg, unixTimestampSeconds, xmppPreKey, xmppSignedPreKey } from '../Utils'
|
import { decodeMediaRetryNode, decodeMessageStanza, delay, encodeBigEndian, encodeSignedDeviceIdentity, getCallStatusFromNode, getNextPreKeys, getStatusFromReceiptType, isHistoryMsg, unixTimestampSeconds, xmppPreKey, xmppSignedPreKey } from '../Utils'
|
||||||
import { makeMutex } from '../Utils/make-mutex'
|
import { makeMutex } from '../Utils/make-mutex'
|
||||||
import { cleanMessage } from '../Utils/process-message'
|
import { cleanMessage } from '../Utils/process-message'
|
||||||
import { areJidsSameUser, BinaryNode, getAllBinaryNodeChildren, getBinaryNodeChild, getBinaryNodeChildren, isJidGroup, isJidUser, jidDecode, jidNormalizedUser, S_WHATSAPP_NET } from '../WABinary'
|
import { areJidsSameUser, BinaryNode, getAllBinaryNodeChildren, getBinaryNodeChild, getBinaryNodeChildren, isJidGroup, isJidUser, jidDecode, jidNormalizedUser, S_WHATSAPP_NET } from '../WABinary'
|
||||||
@@ -80,10 +80,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
|||||||
|
|
||||||
const { account, signedPreKey, signedIdentityKey: identityKey } = authState.creds
|
const { account, signedPreKey, signedIdentityKey: identityKey } = authState.creds
|
||||||
|
|
||||||
const deviceIdentity = proto.ADVSignedDeviceIdentity.encode({
|
const deviceIdentity = encodeSignedDeviceIdentity(account!, true)
|
||||||
...account,
|
|
||||||
accountSignatureKey: undefined
|
|
||||||
}).finish()
|
|
||||||
await authState.keys.transaction(
|
await authState.keys.transaction(
|
||||||
async() => {
|
async() => {
|
||||||
const receipt: BinaryNode = {
|
const receipt: BinaryNode = {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import NodeCache from 'node-cache'
|
|||||||
import { proto } from '../../WAProto'
|
import { proto } from '../../WAProto'
|
||||||
import { WA_DEFAULT_EPHEMERAL } from '../Defaults'
|
import { WA_DEFAULT_EPHEMERAL } from '../Defaults'
|
||||||
import { AnyMessageContent, MediaConnInfo, MessageReceiptType, MessageRelayOptions, MiscMessageGenerationOptions, SocketConfig, WAMessageKey } from '../Types'
|
import { AnyMessageContent, MediaConnInfo, MessageReceiptType, MessageRelayOptions, MiscMessageGenerationOptions, SocketConfig, WAMessageKey } from '../Types'
|
||||||
import { aggregateMessageKeysNotFromMe, assertMediaContent, bindWaitForEvent, decryptMediaRetryData, encodeWAMessage, encryptMediaRetryRequest, encryptSenderKeyMsgSignalProto, encryptSignalProto, extractDeviceJids, generateMessageID, generateWAMessage, getStatusCodeForMediaRetry, getUrlFromDirectPath, getWAUploadToServer, jidToSignalProtocolAddress, parseAndInjectE2ESessions, patchMessageForMdIfRequired, unixTimestampSeconds } from '../Utils'
|
import { aggregateMessageKeysNotFromMe, assertMediaContent, bindWaitForEvent, decryptMediaRetryData, encodeSignedDeviceIdentity, encodeWAMessage, encryptMediaRetryRequest, encryptSenderKeyMsgSignalProto, encryptSignalProto, extractDeviceJids, generateMessageID, generateWAMessage, getStatusCodeForMediaRetry, getUrlFromDirectPath, getWAUploadToServer, jidToSignalProtocolAddress, parseAndInjectE2ESessions, patchMessageForMdIfRequired, unixTimestampSeconds } from '../Utils'
|
||||||
import { getUrlInfo } from '../Utils/link-preview'
|
import { getUrlInfo } from '../Utils/link-preview'
|
||||||
import { areJidsSameUser, BinaryNode, BinaryNodeAttributes, getBinaryNodeChild, getBinaryNodeChildren, isJidGroup, isJidUser, jidDecode, jidEncode, jidNormalizedUser, JidWithDevice, S_WHATSAPP_NET } from '../WABinary'
|
import { areJidsSameUser, BinaryNode, BinaryNodeAttributes, getBinaryNodeChild, getBinaryNodeChildren, isJidGroup, isJidUser, jidDecode, jidEncode, jidNormalizedUser, JidWithDevice, S_WHATSAPP_NET } from '../WABinary'
|
||||||
import { makeGroupsSocket } from './groups'
|
import { makeGroupsSocket } from './groups'
|
||||||
@@ -266,7 +266,9 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
attrs: {
|
attrs: {
|
||||||
v: '2',
|
v: '2',
|
||||||
type,
|
type,
|
||||||
...extraAttrs || {}
|
// do not send extra params
|
||||||
|
// causes retries to fail for some reason now
|
||||||
|
// ...extraAttrs || {}
|
||||||
},
|
},
|
||||||
content: ciphertext
|
content: ciphertext
|
||||||
}]
|
}]
|
||||||
@@ -473,7 +475,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
(stanza.content as BinaryNode[]).push({
|
(stanza.content as BinaryNode[]).push({
|
||||||
tag: 'device-identity',
|
tag: 'device-identity',
|
||||||
attrs: { },
|
attrs: { },
|
||||||
content: proto.ADVSignedDeviceIdentity.encode(authState.creds.account!).finish()
|
content: encodeSignedDeviceIdentity(authState.creds.account!, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
logger.debug({ jid }, 'adding device identity')
|
logger.debug({ jid }, 'adding device identity')
|
||||||
|
|||||||
@@ -148,13 +148,7 @@ export const configureSuccessfulPairing = (
|
|||||||
account.deviceSignature = Curve.sign(signedIdentityKey.private, deviceMsg)
|
account.deviceSignature = Curve.sign(signedIdentityKey.private, deviceMsg)
|
||||||
|
|
||||||
const identity = createSignalIdentity(jid, accountSignatureKey)
|
const identity = createSignalIdentity(jid, accountSignatureKey)
|
||||||
const accountEnc = proto.ADVSignedDeviceIdentity
|
const accountEnc = encodeSignedDeviceIdentity(account, false)
|
||||||
.encode({
|
|
||||||
...account,
|
|
||||||
// do not provide the "accountSignatureKey" back
|
|
||||||
accountSignatureKey: undefined
|
|
||||||
})
|
|
||||||
.finish()
|
|
||||||
|
|
||||||
const deviceIdentity = proto.ADVDeviceIdentity.decode(account.details)
|
const deviceIdentity = proto.ADVDeviceIdentity.decode(account.details)
|
||||||
|
|
||||||
@@ -195,3 +189,20 @@ export const configureSuccessfulPairing = (
|
|||||||
reply
|
reply
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const encodeSignedDeviceIdentity = (
|
||||||
|
account: proto.IADVSignedDeviceIdentity,
|
||||||
|
includeSignatureKey: boolean
|
||||||
|
) => {
|
||||||
|
account = { ...account }
|
||||||
|
// set to null if we are not to include the signature key
|
||||||
|
// or if we are including the signature key but it is empty
|
||||||
|
if(!includeSignatureKey || !account.accountSignatureKey?.length) {
|
||||||
|
account.accountSignatureKey = null
|
||||||
|
}
|
||||||
|
|
||||||
|
const accountEnc = proto.ADVSignedDeviceIdentity
|
||||||
|
.encode(account)
|
||||||
|
.finish()
|
||||||
|
return accountEnc
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user