Signal, messages-recv: Fix previous commit, fix log

This commit is contained in:
Rajeh Taher
2025-10-04 15:30:04 +03:00
parent 334977f983
commit 38e0f2c0e6
4 changed files with 17 additions and 8 deletions
@@ -4,8 +4,8 @@ import { CiphertextMessage } from './ciphertext-message'
interface SenderKeyDistributionMessageStructure {
id: number
iteration: number
chainKey: Uint8Array
signingKey: Uint8Array
chainKey: string | Uint8Array
signingKey: string | Uint8Array
}
export class SenderKeyDistributionMessage extends CiphertextMessage {
@@ -34,8 +34,14 @@ export class SenderKeyDistributionMessage extends CiphertextMessage {
this.serialized = serialized
this.id = distributionMessage.id
this.iteration = distributionMessage.iteration
this.chainKey = distributionMessage.chainKey
this.signatureKey = distributionMessage.signingKey
this.chainKey =
typeof distributionMessage.chainKey === 'string'
? Buffer.from(distributionMessage.chainKey, 'base64')
: distributionMessage.chainKey
this.signatureKey =
typeof distributionMessage.signingKey === 'string'
? Buffer.from(distributionMessage.signingKey, 'base64')
: distributionMessage.signingKey
} catch (e) {
throw new Error(String(e))
}
+4 -2
View File
@@ -5,7 +5,7 @@ import { CiphertextMessage } from './ciphertext-message'
interface SenderKeyMessageStructure {
id: number
iteration: number
ciphertext: Buffer
ciphertext: string | Buffer
}
export class SenderKeyMessage extends CiphertextMessage {
@@ -36,7 +36,9 @@ export class SenderKeyMessage extends CiphertextMessage {
this.messageVersion = (version & 0xff) >> 4
this.keyId = senderKeyMessage.id
this.iteration = senderKeyMessage.iteration
this.ciphertext = senderKeyMessage.ciphertext
this.ciphertext = typeof senderKeyMessage.ciphertext === 'string'
? Buffer.from(senderKeyMessage.ciphertext, 'base64')
: senderKeyMessage.ciphertext
this.signature = signature
} else {
const version = (((this.CURRENT_VERSION << 4) | this.CURRENT_VERSION) & 0xff) % 256
+1
View File
@@ -601,6 +601,7 @@ export const makeChatsSocket = (config: SocketConfig) => {
* type = "image for the high res picture"
*/
const profilePictureUrl = async (jid: string, type: 'preview' | 'image' = 'preview', timeoutMs?: number) => {
// TOOD: Add support for tctoken, existingID, and newsletter + group options
jid = jidNormalizedUser(jid)
const result = await query(
{
+2 -2
View File
@@ -447,8 +447,8 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
// Schedule phone request with delay (like whatsmeow)
messageRetryManager.schedulePhoneRequest(msgId, async () => {
try {
const msgId = await requestPlaceholderResend(msgKey)
logger.debug(`sendRetryRequest: requested placeholder resend for message ${msgId} (scheduled)`)
const requestId = await requestPlaceholderResend(msgKey)
logger.debug(`sendRetryRequest: requested placeholder resend (${requestId}) for message ${msgId} (scheduled)`)
} catch (error) {
logger.warn({ error, msgId }, 'failed to send scheduled phone request')
}