feat: replace async crypto with sync Rust WASM (port of Baileys b5c1741)
Surgically applies the changes from WhiskeySockets/Baileys commit b5c1741
("feat: replace async crypto with sync Rust WASM" by jlucaso1) while
preserving all custom modifications (interactive messages, carousels,
albums, sticker packs, native flow buttons, Prometheus metrics, etc).
Changes:
- Replace async hkdf/md5 (Web Crypto API) with sync re-exports from whatsapp-rust-bridge@0.5.2
- Replace LTHash class with LTHashAntiTampering from WASM
- Replace mutationKeys() with expandAppStateKeys() from WASM
- Remove ~25 unnecessary await keywords across crypto call chain
- Update Buffer→Uint8Array types for MediaDecryptionKeyInfo and internal crypto functions
- Make noise handshake, media retry encrypt/decrypt, and reporting token generation synchronous
Performance impact:
- Eliminates Promise overhead on every HKDF/LTHash operation
- Significant improvement during app state sync (hundreds of mutations per reconnection)
- Sync crypto reduces event loop pressure under high session load
Custom code preserved (zero conflicts):
- messages-send.ts: All interactive message, carousel, album, sticker pack logic intact
- Types/Message.ts: All custom types (NativeFlowButton, Carousel, Album, etc.) intact
- All Prometheus metrics, circuit breakers, session TTL logic intact
https://claude.ai/code/session_01Ffc5YrPuqv8N9SwEuSM8mr
This commit is contained in:
@@ -102,7 +102,7 @@ export const shouldIncludeReportingToken = (message: proto.IMessage): boolean =>
|
||||
!message.encEventResponseMessage &&
|
||||
!message.pollUpdateMessage
|
||||
|
||||
const generateMsgSecretKey = async (
|
||||
const generateMsgSecretKey = (
|
||||
modificationType: string,
|
||||
origMsgId: string,
|
||||
origMsgSender: string,
|
||||
@@ -321,7 +321,7 @@ export const getMessageReportingToken = async (
|
||||
const from = key.fromMe ? key.remoteJid! : key.participant || key.remoteJid!
|
||||
const to = key.fromMe ? key.participant || key.remoteJid! : key.remoteJid!
|
||||
|
||||
const reportingSecret = await generateMsgSecretKey(ENC_SECRET_REPORT_TOKEN, key.id, from, to, msgSecret)
|
||||
const reportingSecret = generateMsgSecretKey(ENC_SECRET_REPORT_TOKEN, key.id, from, to, msgSecret)
|
||||
|
||||
const content = extractReportingTokenContent(msgProtobuf, compiledReportingFields)
|
||||
if (!content || content.length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user