send, usync: fix lid Usync (including onWhatsApp), and send phash

This commit is contained in:
Rajeh Taher
2025-09-14 21:35:13 +03:00
parent 8029446511
commit 42c980778e
3 changed files with 30 additions and 8 deletions
+8
View File
@@ -14,6 +14,7 @@ import type {
} from '../Types'
import { DisconnectReason } from '../Types'
import { type BinaryNode, getAllBinaryNodeChildren, jidDecode } from '../WABinary'
import { sha256 } from './crypto'
const PLATFORM_MAP = {
aix: 'AIX',
@@ -88,6 +89,13 @@ export const unpadRandomMax16 = (e: Uint8Array | Buffer) => {
return new Uint8Array(t.buffer, t.byteOffset, t.length - r)
}
// code is inspired by whatsmeow
export const generateParticipantHashV2 = (participants: string[]): string => {
participants.sort()
const sha256Hash = sha256(Buffer.from(participants.join(''))).toString('base64')
return '2:' + sha256Hash.slice(0, 6)
}
export const encodeWAMessage = (message: proto.IMessage) => writeRandomPadMax16(proto.Message.encode(message).finish())
export const generateRegistrationId = (): number => {