2864 Commits

Author SHA1 Message Date
Renato Alcara 2f31a85c9f fix(types): remove safe as any casts in messages.ts
fix(types): remove safe `as any` casts in messages.ts
2026-02-08 20:08:52 -03:00
Claude 92c51fa741 fix(types): remove 5 safe as any casts in messages.ts (zero runtime change)
- hasNonNullishProperty: `as any` → `as Record<PropertyKey, unknown>` (identical JS output)
- hasOptionalProperty: `as any` → `as Record<PropertyKey, unknown>` (identical JS output)
- error handling: `(error as any).stack` → `instanceof Error` check (safer, no message impact)
- eventResponse: `as any` → specific type assertion (identical JS output)

These changes only affect type guards and logging — no interactive message
construction code was modified (buttons, carousels, lists, templates untouched).

Remaining as-any count in messages.ts: 46 → 41

https://claude.ai/code/session_01E2cfX1N3sJgCJBTvzGazSG
2026-02-08 23:02:36 +00:00
Claude 686bce5d2c fix(security): replace exec() with execFile() in extractVideoThumb
Eliminates command injection vulnerability (CWE-78) by switching from
shell-based exec() to execFile() which passes arguments as an array
without spawning a shell. Behavior is identical — same ffmpeg args,
same output — but injection via crafted paths is now impossible.

https://claude.ai/code/session_01E2cfX1N3sJgCJBTvzGazSG
2026-02-08 22:23:09 +00:00
Renato Alcara 754056c9a3 Remove 'commits behind' upstream message
Remove 'commits behind' upstream message
2026-02-08 19:02:53 -03:00
Claude 2dc3a34d5e merge: acknowledge upstream commits while preserving our codebase
Merge upstream WhiskeySockets/Baileys master using 'ours' strategy.
This marks the 5 upstream commits as merged without changing any
files in our repository, removing the 'commits behind' message on GitHub.

https://claude.ai/code/session_01E2cfX1N3sJgCJBTvzGazSG
2026-02-08 21:57:49 +00:00
Renato Alcara d73dd0c83a feat: replace async crypto with sync Rust WASM
feat: replace async crypto with sync Rust WASM
2026-02-08 18:32:36 -03:00
Claude 85cfb6a642 fix: address PR review - type consistency and runtime safety
- crypto.ts: widen aesEncrypWithIV params to Uint8Array for consistency
  with other AES helpers (Copilot review comment #1)
- noise-handler.ts: replace unsafe `as Buffer` type assertions with
  Buffer.from() for proper runtime conversion (Copilot review comment #2)

https://claude.ai/code/session_01Ffc5YrPuqv8N9SwEuSM8mr
2026-02-08 21:26:21 +00:00
Claude 2c18b734ee 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
2026-02-08 20:49:18 +00:00
Claude 395f3aace5 chore: add audit reports to gitignore
Prevent audit report files from being accidentally committed.

https://claude.ai/code/session_01Ffc5YrPuqv8N9SwEuSM8mr
2026-02-08 18:42:04 +00:00
Claude 24f09b7b1e chore: update lockfiles from dependency resolution
Lockfiles regenerated during structural audit of the repository.

https://claude.ai/code/session_01Ffc5YrPuqv8N9SwEuSM8mr
2026-02-08 18:29:38 +00:00
Renato Alcara e88c5d0e9f fix(carousel): re-add
fix(carousel): re-add
2026-02-07 00:21:30 -03:00
Claude 9a36602acf fix(carousel): match Pastorini's EXACT working structure
Pastorini's carousel renders on WhatsApp Web. Key differences found
by comparing logs and screenshot:

1. Direct interactiveMessage at root (NO viewOnceMessage wrapper)
   - messageKeys: ['interactiveMessage'] in Pastorini logs
   - Previous attempts with viewOnce V1/V2 all failed on Web

2. Root header WITH title + hasMediaAttachment: false (restored)

3. messageVersion: 1 in carouselMessage (restored)

4. tctoken included in stanza (was being skipped for carousel)
   - Pastorini stanza: ['participants','device-identity','tctoken','biz']

5. messageContextInfo at message root level (kept)

https://claude.ai/code/session_018DkDxsjWzM131jy3ivWjZp
2026-02-07 03:19:03 +00:00
Claude 4e7fb3fdce fix(carousel): re-add own device skip to prevent error 479
Carousel messages in DSM (deviceSentMessage) wrapper cause error 479
on sender's own linked devices. Re-add the skip that prevents sending
carousel to own devices.

https://claude.ai/code/session_018DkDxsjWzM131jy3ivWjZp
2026-02-07 03:09:08 +00:00
Renato Alcara 8c8e107036 fix(carousel): switch to viewOnceMessage V1
fix(carousel): switch to viewOnceMessage V1
2026-02-07 00:00:26 -03:00
Claude f9b084c9dc fix(carousel): remove root header + messageVersion to match ckptw
Compare with ckptw's working carousel implementation:
1. Remove root header from interactiveMessage - ckptw does NOT set
   a header on the root, only on individual cards. The root header
   was incorrectly believed to prevent error 479.
2. Remove messageVersion from carouselMessage - ckptw doesn't set it.

Structure now matches ckptw exactly:
  viewOnceMessage > message > {
    messageContextInfo,
    interactiveMessage: {
      body, footer,
      carouselMessage: { cards }  // no messageVersion
      // no header at root level
    }
  }

https://claude.ai/code/session_018DkDxsjWzM131jy3ivWjZp
2026-02-07 02:54:01 +00:00
Claude 200414c47e fix(carousel): switch to viewOnceMessage V1 + stop skipping own devices
1. Switch wrapper from viewOnceMessageV2 (field 55) to viewOnceMessage V1
   (field 37). V2 renders on mobile but NOT on WhatsApp Web/Desktop.
   V1 is what ckptw, Vkazee, and most working Baileys forks use.
   Previous error 479 with V1 was caused by missing root header and
   fromObject() corruption - both now fixed.

2. Stop skipping own linked devices for carousel messages. This was
   preventing the sender's WhatsApp Web from receiving the carousel.

3. Allow DSM (deviceSentMessage) wrapper for carousel - no longer
   skip it for own devices or retry paths.

https://claude.ai/code/session_018DkDxsjWzM131jy3ivWjZp
2026-02-07 02:50:20 +00:00
Renato Alcara 63ab171bd1 fix: suppress libsignal session logs + add carousel media warning
fix: suppress libsignal session logs + add carousel media warning
2026-02-06 23:43:39 -03:00
Claude 52b8e8b4ff fix: suppress libsignal session logs + add carousel media warning
1. Suppress verbose "Closing session: SessionEntry {...}" logs from
   libsignal that dump cryptographic keys/ratchets to console.log

2. Add warning when carousel cards don't have media attachments -
   WhatsApp Web requires every card to have hasMediaAttachment:true
   with actual image/video (per ckptw reference implementation)

3. Add carousel structure summary log for debugging card composition

https://claude.ai/code/session_018DkDxsjWzM131jy3ivWjZp
2026-02-07 02:40:43 +00:00
Renato Alcara 13f5b87862 cleanup: remove verbose carousel debug logs (base64 dumps)
cleanup: remove verbose carousel debug logs (base64 dumps)
2026-02-06 23:18:56 -03:00
Claude 479f53a8bc cleanup: remove verbose carousel debug logs (base64 dumps)
Remove per-device and relay-level carousel debug logging that dumped
full base64-encoded protobuf bytes and JSON structures to the logs.
These were temporary debugging aids that generated excessive output.

https://claude.ai/code/session_018DkDxsjWzM131jy3ivWjZp
2026-02-07 02:17:33 +00:00
Renato Alcara cacc4c361d fix(carousel): add messageContextInfo at outer Message level for mult…
fix(carousel): add messageContextInfo at outer Message level for mult…
2026-02-06 23:16:36 -03:00
Claude 6bcabb3678 fix(carousel): add messageContextInfo at outer Message level for multi-device
The messageContextInfo with deviceListMetadata was only inside the V2 wrapper.
relayMessage copies message.messageContextInfo to meMsg for sender's own
devices (DSM), so it needs to be at the outer level too.

https://claude.ai/code/session_018DkDxsjWzM131jy3ivWjZp
2026-02-07 02:14:36 +00:00
Renato Alcara bfd0b1114f fix(carousel): use viewOnceMessageV2 wrapper with messageContextInfo
fix(carousel): use viewOnceMessageV2 wrapper with messageContextInfo
2026-02-06 22:48:02 -03:00
Claude 2ed97e68df fix(carousel): use viewOnceMessageV2 wrapper with messageContextInfo
Switch carousel from direct interactiveMessage to viewOnceMessageV2
wrapper (field 55), confirmed by Z-API as the stable approach for
WhatsApp Web rendering from non-Cloud API accounts.

Key changes:
- Wrap carousel in viewOnceMessageV2 > message > interactiveMessage
  (V1 caused error 479, direct interactiveMessage didn't render on Web)
- Add messageContextInfo with deviceListMetadata and version 2 for
  multi-device rendering compatibility
- Update all helper functions (getButtonType, isCarouselMessage,
  isCatalogMessage, isListNativeFlow, getButtonArgs) to check V2 path
- Update per-device and biz node debug logging for V2 detection

https://claude.ai/code/session_018DkDxsjWzM131jy3ivWjZp
2026-02-07 01:44:47 +00:00
Renato Alcara 29bf71d9e0 fix(carousel): remove viewOnceMessage wrapper, send interactiveMessag…
fix(carousel): remove viewOnceMessage wrapper, send interactiveMessag…
2026-02-06 21:38:56 -03:00
Claude 7a89afb666 fix(carousel): remove viewOnceMessage wrapper, send interactiveMessage directly
Pastorini's working implementation confirms carousels must be sent as
direct interactiveMessage at the message root level, NOT wrapped in
viewOnceMessage. The viewOnce wrapper prevented rendering on WhatsApp
Web and delivery to Apple/iOS users.

https://claude.ai/code/session_018DkDxsjWzM131jy3ivWjZp
2026-02-07 00:35:10 +00:00
Renato Alcara 77c6fcdaa7 fix(carousel): bypass proto fromObject for carousel messages to fix
fix(carousel): bypass proto fromObject for carousel messages to fix
2026-02-06 21:05:28 -03:00
Claude 1589c82b0d fix(carousel): bypass proto fromObject for carousel messages to fix error 479
Three changes matching Pastorini's working implementation:

1. Always set root header in generateCarouselMessage - the root
   interactiveMessage header must always be present with title and
   hasMediaAttachment:false. Previously it was undefined when no text
   was provided, which violates WhatsApp MD protocol requirements.

2. Return plain JS object from generateWAMessageContent for carousel -
   skip WAProto.Message.fromObject() which can corrupt nested carousel
   structures by incorrectly handling oneOf fields in deeply nested
   InteractiveMessage cards. protobuf encode() handles plain objects
   correctly during serialization.

3. Pass plain JS object directly to relayMessage in sendMessage - call
   relayMessage(jid, msgContent) with the plain object instead of
   going through proto.WebMessageInfo.fromObject() first. This matches
   Pastorini's approach of relayMessage(jid, plainObject, opts).

https://claude.ai/code/session_018DkDxsjWzM131jy3ivWjZp
2026-02-06 22:11:54 +00:00
Renato Alcara 8cd62b964d fix(carousel): skip own linked devices to prevent error 479
fix(carousel): skip own linked devices to prevent error 479
2026-02-06 18:53:29 -03:00
Claude 5dac1a5f64 fix(carousel): skip own linked devices to prevent error 479
Debug logging revealed that error 479 comes exclusively from the
sender's own linked devices (WhatsApp Web/Desktop) when they receive
the carousel wrapped in deviceSentMessage (DSM). Recipient devices
receive the raw carousel (without DSM) and process it correctly.

The fix skips sending carousel to sender's own linked devices:
- Skip meRecipients (own devices) when message is carousel
- Skip DSM wrapper in createParticipantNodes for carousel
- Skip DSM in retry path for own devices when carousel

The carousel still renders correctly on:
- Sender's phone (initiator)
- All recipient devices (phone + Web/Desktop)

https://claude.ai/code/session_01EK9NpViRCtda1WAvFd8ptR
2026-02-06 21:50:36 +00:00
Renato Alcara a364993db0 fix(carousel): remove hasSubtitle proto field + add debug logging
fix(carousel): remove hasSubtitle proto field + add debug logging
2026-02-06 18:38:53 -03:00
Claude 879970fda8 fix(carousel): remove hasSubtitle proto field + add debug logging
- Remove hasSubtitle (field 10) from Header proto definition, index.js
  and index.d.ts - this field was adding extra bytes to encoded protobuf
  that working implementations don't send, potentially causing rejection
- Remove hasSubtitle from carousel card headers and root header
- Add [CAROUSEL DEBUG] logging in relayMessage to dump:
  - Encoded message bytes as base64 (for binary comparison)
  - Message structure as JSON
  - Per-device encoded bytes with DSM flag
- This enables byte-level comparison with working implementations

https://claude.ai/code/session_01EK9NpViRCtda1WAvFd8ptR
2026-02-06 21:27:40 +00:00
Renato Alcara ba2258834b fix(carousel): hasSubtitle + relayMessage direto + proto atualizado
fix(carousel): hasSubtitle + relayMessage direto + proto atualizado
2026-02-06 18:12:01 -03:00
Claude 3ac2c33d93 fix(carousel): hasSubtitle + relayMessage direto + proto atualizado
Implementação completa baseada na análise ponto-a-ponto de 5 diferenças:

1. hasSubtitle adicionado ao proto schema (field 10, bool em Header)
   - Adicionado ao WAProto.proto, index.js (encode/decode/fromObject/toObject)
   - Adicionado ao index.d.ts (IHeader, Header class)
   - Usado no root header e em cada card do carousel

2. relayMessage direto para carousel em sendMessage
   - Detecta nativeCarousel no content e bypassa generateWAMessage inteiro
   - Chama generateWAMessageContent (que usa fromObject) diretamente
   - Depois relayMessage sem passar por generateWAMessageFromContent
   - Elimina: segundo WAProto.Message.create(), contextInfo.expiration, etc.

3. Pipeline final do carousel agora:
   sendMessage → generateWAMessageContent(fromObject) → relayMessage
   Sem: generateWAMessageFromContent, WAProto.Message.create, ephemeral

Commits anteriores já incluem:
- viewOnceMessage wrapper
- fromObject no generateWAMessageContent
- Skip tctoken no stanza

https://claude.ai/code/session_01EK9NpViRCtda1WAvFd8ptR
2026-02-06 21:07:44 +00:00
Renato Alcara 16da60cb67 fix(carousel): skip segundo create() + tctoken
fix(carousel): skip segundo create() + tctoken
2026-02-06 18:01:25 -03:00
Claude dede2fa3c0 fix(carousel): skip segundo create() + tctoken + ephemeral para corrigir 479
Três correções para eliminar erro 479 em dispositivos vinculados:

1. Skip WAProto.Message.create() em generateWAMessageFromContent para carousel
   - O carousel já foi processado com fromObject() (conversão profunda)
   - O segundo create() faz cópia rasa que pode perder tipos protobuf nested
   - Preserva a estrutura deep: cards > headers > imageMessage > nativeFlowMessage

2. Skip tctoken no stanza para carousel
   - Implementações que funcionam não incluem tctoken para carousel
   - Pode causar rejeição 479 em dispositivos vinculados (Web/Desktop)

3. Skip contextInfo.expiration (ephemeral) para carousel
   - Se mensagens temporárias estão ativadas, contextInfo.expiration era
     adicionado ao interactiveMessage, o que pode causar 479
   - Implementações que funcionam não passam por generateWAMessageFromContent

https://claude.ai/code/session_01EK9NpViRCtda1WAvFd8ptR
2026-02-06 20:56:11 +00:00
Renato Alcara c2f3aed0c4 fix(carousel): usar fromObject + viewOnceMessage para compatibilidade…
fix(carousel): usar fromObject + viewOnceMessage para compatibilidade…
2026-02-06 17:32:43 -03:00
Claude 4037b3fcdd fix(carousel): usar fromObject + viewOnceMessage para compatibilidade Web/Desktop
Mudanças críticas para renderização do carousel em dispositivos vinculados:

1. Wrap carousel em viewOnceMessage para compatibilidade multi-device (MD)
2. Usar WAProto.Message.fromObject() ao invés de create() para conversão
   profunda das estruturas nested (header, cards, nativeFlowMessage)
3. Adicionar root header com título no interactiveMessage
4. Retorno antecipado do carousel (sem messageContextInfo/reportingToken)

A diferença entre fromObject e create:
- fromObject: converte recursivamente objetos JS para tipos protobuf
- create: cópia rasa que pode não codificar corretamente estruturas deep

https://claude.ai/code/session_01EK9NpViRCtda1WAvFd8ptR
2026-02-06 20:19:10 +00:00
Renato Alcara ffaab2c7b7 fix(carousel): remover messageContextInfo
fix(carousel): remover messageContextInfo
2026-02-06 15:43:14 -03:00
Claude 6406becee2 fix(carousel): remover messageContextInfo para evitar erro 479
sendMessage adiciona messageContextInfo.messageSecret ao proto da
mensagem (para reporting token). Isso nao existe quando relayMessage
e chamado diretamente. O messageContextInfo ao lado de
interactiveMessage.carouselMessage causa erro 479 nos dispositivos
vinculados (Web/Desktop).

Agora o carousel pula a adicao de messageContextInfo, resultando em
um proto limpo: { interactiveMessage: { carouselMessage: {...} } }

https://claude.ai/code/session_01EK9NpViRCtda1WAvFd8ptR
2026-02-06 18:40:15 +00:00
Renato Alcara f6d4bd594f fix(carousel)sem viewOnceMessage
fix(carousel)sem viewOnceMessage
2026-02-06 15:25:23 -03:00
Claude 5d5a973ffd fix(carousel): enviar interactiveMessage direto + biz node + sem viewOnceMessage
Ajuste na estrutura do carrossel para renderizar na Web:
1. Removido viewOnceMessage wrapper - carrossel usa interactiveMessage direto
2. Biz node habilitado com native_flow v=9 name=mixed
3. Removido subtitle vazio e header vazio do nível raiz
4. Sem bot node (já estava correto)

https://claude.ai/code/session_01EK9NpViRCtda1WAvFd8ptR
2026-02-06 18:23:47 +00:00
Renato Alcara 9cf6598931 fix(carousel): re-habilitar biz node para carrossel
fix(carousel): re-habilitar biz node para carrossel
2026-02-06 15:04:11 -03:00
Claude 7b4c9c8d4c fix(carousel): re-habilitar biz node para carrossel (Pastorini confirma necessario)
Comparação com Pastorini revelou que o biz node É NECESSÁRIO para
carrossel. Pastorini injeta exatamente:
  <biz><interactive type="native_flow" v="1">
    <native_flow v="9" name="mixed"/>
  </interactive></biz>

Sem biz node = error 479. Com biz node = mensagem entregue.

O erro 479 anterior era causado por messageContextInfo no viewOnceMessage,
não pelo biz node em si.

Estado atual: biz node (SIM) + viewOnceMessage sem messageContextInfo +
bot node (NÃO para carousel/native_flow)

https://claude.ai/code/session_01EK9NpViRCtda1WAvFd8ptR
2026-02-06 17:59:53 +00:00
Renato Alcara 7a530d51b7 fix(carousel): pular injeção do biz node para carrossel (causa erro 479)
fix(carousel): pular injeção do biz node para carrossel (causa erro 479)
2026-02-06 14:39:34 -03:00
Claude 4c56dacc81 fix(carousel): pular injeção do biz node para carrossel (causa erro 479)
O código experimental de injeção do biz node tentava extrair botões de
interactiveMessage.nativeFlowMessage.buttons (nível raiz), mas no
carrossel os botões estão em carouselMessage.cards[].nativeFlowMessage.

Resultado: biz node injetado com buttonNames:[] e dados vazios,
WhatsApp via erro 479 rejeitando a mensagem nos dispositivos vinculados.

Pastorini usa relayMessage direto sem injetar biz node no carrossel.
Agora o carrossel pula a injeção do biz node completamente.

https://claude.ai/code/session_01EK9NpViRCtda1WAvFd8ptR
2026-02-06 17:36:49 +00:00
Renato Alcara 71c468efd5 fix(carousel): viewOnceMessage wrapper sem messageContextInfo
fix(carousel): viewOnceMessage wrapper sem messageContextInfo
2026-02-06 14:26:04 -03:00
Claude 1ebf95b5d6 fix(carousel): viewOnceMessage wrapper sem messageContextInfo + estrutura Pastorini
Mudanças baseadas na comparação com Pastorini:

1. Adicionado viewOnceMessage wrapper MÍNIMO (sem messageContextInfo)
   - viewOnceMessage é obrigatório para Web/Desktop renderizar carousel
   - messageContextInfo pode ter causado o erro 479 anterior

2. Removido campos extras que Pastorini não usa:
   - Removido messageParamsJson dos cards
   - Removido messageVersion dos cards
   - Removido carouselCardType (Pastorini não define)
   - Removido header vazio no nível raiz (Pastorini não envia)

3. Estrutura final:
   viewOnceMessage.message.interactiveMessage.carouselMessage

https://claude.ai/code/session_01EK9NpViRCtda1WAvFd8ptR
2026-02-06 17:21:34 +00:00
Renato Alcara 3dc37d7fe6 fix(carousel): add carouselCardType HSCROLL_CARDS
fix(carousel): add carouselCardType HSCROLL_CARDS
2026-02-06 14:05:12 -03:00
Claude 0c39339e00 fix(carousel): add carouselCardType HSCROLL_CARDS and remove viewOnceMessage
Two changes to fix carousel rendering on WhatsApp Web/Desktop:

1. Added carouselCardType: 1 (HSCROLL_CARDS) to carouselMessage - this
   proto field tells the client how to render carousel cards. Without it,
   Web/Desktop doesn't know to render horizontal scrollable cards.

2. Removed viewOnceMessage wrapper - confirmed it causes error 479
   rejection from linked devices (Web/Desktop). Carousel works as
   direct interactiveMessage on phone; carouselCardType should fix Web.

https://claude.ai/code/session_01EK9NpViRCtda1WAvFd8ptR
2026-02-06 17:02:46 +00:00