Commit Graph

99 Commits

Author SHA1 Message Date
Claude 1c9fb86cc3 fix(types): remove non-null assertions in remaining 12 files
Files fixed:
- messages-media.ts: stream/buffer guards, file path validation
- decode-wa-message.ts: message field guards, optional chaining
- version-cache.ts: narrowing after null checks
- jid-utils.ts: split result guards, user fallbacks
- communities.ts: attrs fallbacks with ?? operator
- sticker-pack.ts: response guards
- business.ts: attrs guards
- socket.ts: onClose guard, pairingCode guard, creds.me guard
- event-buffer.ts: null guards
- signal.ts: null guards
- encode.ts (WAM): id null check with continue
- upstream history.ts: conversations/pushnames null guards

All 26 files across the project are now corrected.
Total: ~248 non-null assertions replaced with proper null guards.

https://claude.ai/code/session_01E2cfX1N3sJgCJBTvzGazSG
2026-02-09 00:32:04 +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
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 79b9c9f7da feat(sticker-pack): implement native sticker pack support (3-30 stickers)
Implementa suporte completo para envio de pacotes de stickers seguindo o
padrão oficial do WhatsApp (3-30 stickers por pack).

**Novos Recursos:**
- Tipos TypeScript: Sticker e StickerPack com documentação completa
- Função prepareStickerPackMessage() com criptografia AES-256-CBC + HMAC
- Conversão automática para WebP usando Sharp
- Detecção de stickers animados via VP8X header
- Deduplicação automática de stickers por hash SHA256
- Compressão ZIP usando fflate (level 0 para performance)
- Upload de thumbnail 252x252 JPEG com mesma mediaKey
- Validações conforme especificações oficiais WhatsApp

**Especificações Implementadas:**
- Mínimo 3, máximo 30 stickers (padrão oficial WhatsApp)
- Limite 1MB por sticker (hard limit)
- Recomendado: 100KB estático, 500KB animado
- Formato WebP obrigatório
- Tray icon 252x252 pixels
- Limite total pack: 30MB

**Arquivos Modificados:**
- src/Types/Message.ts: tipos Sticker e StickerPack
- src/Defaults/index.ts: media paths e HKDF keys
- src/Utils/sticker-pack.ts: implementação core (440 linhas)
- src/Utils/messages-media.ts: export getImageProcessingLibrary, mediaKey opcional
- src/Utils/messages.ts: integração com generateWAMessageContent
- src/Socket/messages-send.ts: detecção de tipo 'sticker_pack'
- package.json: dependência fflate@^0.8.2

**Segurança:**
- Criptografia AES-256-CBC com autenticação HMAC-SHA256
- HKDF key derivation para separação de chaves
- Reutilização intencional de mediaKey (protocolo WhatsApp)
- Validação de tamanhos e formatos

**Compatibilidade:**
-  Não impacta mensagens interativas existentes
-  Tipos completamente separados no union type
-  Sharp como peer dependency opcional
-  Graceful degradation se Sharp não instalado

**Uso:**
\`\`\`typescript
await sock.sendMessage(jid, {
  stickerPack: {
    name: 'Meu Pack',
    publisher: 'Autor',
    cover: coverBuffer,
    stickers: [
      { data: sticker1, emojis: ['😀'] },
      { data: sticker2, emojis: ['😎'] }
    ]
  }
})
\`\`\`

https://claude.ai/code/session_01FaRqGuPecEyPx1qiuRV8Ye
2026-02-05 15:54:27 +00:00
João Lucas de Oliveira Lopes 43d1787532 fix: improve media upload handling and reduce memory pressure (#2128)
* fix: improve media upload handling and reduce memory pressure

* fix: enhance media upload functionality and add comprehensive tests
2025-12-06 03:06:24 +02:00
Anychat LLC 2779c9df08 Update messages-media.ts (#1988)
Fix of issue https://github.com/WhiskeySockets/Baileys/issues/1986
2025-11-19 15:19:56 +02:00
Muhammad Restu 0145e4c710 Fix jimp type check from 'object' to 'function' (#2034)
Fixes the error “No image processing library is available.” even when Jimp is installed.

In recent versions of Jimp, Jimp is now defined as a class instead of an object, which breaks the existing type check.



*Idk if this is useless/useful
2025-11-19 15:17:59 +02:00
Rajeh Taher 334977f983 general: revert #1665 2025-10-03 18:14:30 +03:00
Charlotte 9f6e1d954f fix: set duplex property when uploading media to server (#1837)
* fix: set duplex to half in getWAUploadToServer

* fix: add duplex to RequestInit interface
2025-10-01 07:55:50 +03:00
João Lucas de Oliveira Lopes fb12f6d9d3 refactor: replace axios with fetch API and update related types (#1666) 2025-09-28 05:52:43 +03:00
João Lucas de Oliveira Lopes 3b46d43beb fix: harden Protobuf Deserialization and Refactor Utilities (#1820)
* refactor: reorganize browser utility functions and improve buffer handling

* fix: harden protobuf deserialization and clean up code

* refactor: simplify data handling in GroupCipher and SenderKey classes

* fix: Ensure consistent Buffer hydration and remove redundant code

* refactor: update decodeAndHydrate calls to use proto types for improved type safety
2025-09-26 04:45:30 +03:00
Rajeh Taher 076daae89d types: fix circular import
closes #1746
2025-09-07 14:51:13 +03:00
vini 50fc83b008 feat(business): change profile/cover photo and manage quick replies (#1724) 2025-09-07 14:08:26 +03:00
Rajeh Taher 8dc852ee89 proto: fix proto generation, tsc: fix node imports of compiled code 2025-07-19 23:16:35 +03:00
Rajeh Taher 90781ce0f2 eslint: upgrade to version 9 + tests: remove tests 2025-07-18 22:30:50 +03:00
Borewit 241fe3e691 Update to music-metadata from version 11.3.0 to 11.7.0 (#1607)
Remove `with { 'resolution-mode': 'import' }` in type import.

Co-authored-by: Borewit <Borewit@users.noreply.github.com>
2025-07-17 15:20:38 +03:00
Borewit df303c8d43 Update to music-metadata from version 7.12.3 to 11.3.0 (#1355)
Co-authored-by: Borewit <borewit@users.noreply.github.com>
Co-authored-by: Rajeh Taher <rajeh@reforward.dev>
2025-07-17 14:25:28 +03:00
Rajeh Taher 787aed88b8 project: Move to ESM Modules 2025-07-17 13:54:17 +03:00
vini 31cb8d78a6 fix: remove static jimp import (#1592) 2025-07-09 11:50:52 -03:00
DevAstro 3cdb0f4dd9 Bump Jimp && Sharp (#1575)
* Bump Jimp && Sharp

Upgrade and use the latest version of jimp and sharp libraries

* lint
2025-07-05 23:58:57 +03:00
João Lucas de Oliveira Lopes 92b4c68de0 fix: Handle data: URIs in getStream to prevent server crash (#1524) 2025-07-04 19:25:19 -03:00
João Lucas de Oliveira Lopes 8391c02e0b [READY FOR MERGE] Implement newsletter (#1532)
* feat: implement basic newsletter functionality with socket integration and event handling

* feat: enhance media handling for newsletters with raw media upload support

* feat: working updatePicture, removePicure, adminCount, mute, Unmute

* fix: fetchMessages

* chore: cleanup

* fix: update newsletter metadata path and query ID for consistency. newsletterMetadata works now

* chore: enhance newsletter metadata parsing and error handling

* fix: correct DELETE QueryId value in Newsletter.ts

* chore: split mex stuffs to own file

* chore: remove as any
2025-06-30 23:22:09 -03:00
DevAstro a4b96ed37e [READY FOR MERGE] Add support for custom profile picture dimensions (#1563)
* Add support for custom profile picture dimensions

The updateProfilePicture and generateProfilePicture functions now accept an optional dimensions parameter, allowing custom width and height for profile pictures. This provides more flexibility for image resizing beyond the default 640x640 size.

* minor corrections

Replaces 'w' and 'h' with 'width' and 'height' in profile picture related functions for improved clarity and consistency.

* fix lint
2025-06-30 16:04:37 -03:00
João Lucas de Oliveira Lopes 591c98f3e6 fix: validate media URL before downloading content from message (#1560) 2025-06-30 16:02:40 -03:00
Borewit f404147736 Use parseFile for audio file paths instead of converting to stream (#1529)
When extracting duration from an audio file provided as a file path,
use music-metadata's parseFile method instead of manually creating a
read stream and using parseStream.

parseFile utilizes random access, which can significantly improve
performance over streaming in many cases. However, actual speed gains
depend on the file format and the structure of tag headers.

Co-authored-by: Borewit <Borewit@users.noreply.github.com>
2025-06-20 13:11:29 +03:00
canove ae0de94307 chore: fix format 2025-05-28 22:44:21 -03:00
canove eb6c6c8ba9 Merge branch 'master' of https://github.com/WhiskeySockets/Baileys into fix-eslint-prettier-editorconfig-rules 2025-05-28 22:42:28 -03:00
canove fb83e4799d chore: remove unused variables 2025-05-13 18:35:29 -03:00
canove fa706d0b50 chore: format everything 2025-05-06 12:10:19 -03:00
canove f58a38fde9 fix: allow media upload retries 2025-05-06 08:06:05 -03:00
canove 53c77dd11c chore: lint 2025-05-05 21:20:25 -03:00
canove bff86ed4c1 fix: memory blow on large files sending through URL 2025-05-05 21:11:40 -03:00
w3nder dfe8bb3283 refactor(messageId): update all remaining usages to v2 format consistently 2025-04-30 00:59:19 -03:00
João Lucas de Oliveira Lopes 8083754621 refactor: turn hkdf functions to async and remove extra deps (#1272)
* refactor: remove futoin-hkdf dependency and update hkdf implementation

* refactor: use crypto subtle and update functions to async

---------

Co-authored-by: Rajeh Taher <rajeh@reforward.dev>
2025-03-01 18:31:48 +02:00
contato.mateusfr@gmail.com 21f8431e61 Dependency Inversion for Logger (#1153)
* feat: interface "ILogger" created
feat: interface "ILogger" used instead of pino logger
feat: "PinoLoggerAdapter" created to implement "ILogger" interface

* feat: PinoLoggerAdapter removed
feat: ILogger mapping the features we're using from pino

* fix: sort imports

---------

Co-authored-by: Mateus Franchini de Freitas <contato.mateusfr@outlook.com>
Co-authored-by: Mateus Franchini de Freitas <mfranchini@domtec.com.br>
Co-authored-by: Rajeh Taher <rajeh@reforward.dev>
2025-03-01 18:30:51 +02:00
Rajeh Taher aeabecdf67 messages-media: fix waveform import 2025-02-16 18:36:59 +02:00
Rajeh Taher 18ac07df8e lint: 0 warnings left 2024-10-14 05:15:10 +03:00
Ericky Thierry abafce525c stream to buffer conversion for no apparent need 2024-07-12 20:54:22 -03:00
Rajeh Taher c8aab8d03f fix(master): yarn lock and axios error + move to WhiskeySockets libsignal 2024-06-16 17:11:17 +03:00
Timothy Dillan 5b02715fb0 chore: fix audio decode error due to passing spread argument 2024-01-21 13:28:10 +08:00
Davidson Gomes cba9827851 feat: Send Status (status@broadcast) {text, media, audio(with waveform)} (#249)
Co-authored-by: Davidson Gomes <contato@agenciadgcode.com>
2023-07-18 10:25:16 -03:00
Codeboss 2c76713565 feat: Add waveforms to voice messages (#180)
Co-authored-by: Edgard <edgardmessias@gmail.com>
2023-07-13 21:08:11 -03:00
Adhiraj Singh bd17f3742e fix: stream destroy 2023-03-03 12:41:37 +05:30
Adhiraj Singh 7e9b9b7f9a fix: stream errors not being handled 2023-03-03 12:28:16 +05:30
Adhiraj Singh cc1fc9a53c fix: delete tmp file if failed enc 2023-02-20 21:18:31 +05:30
Adhiraj Singh 4ba828320e feat: handle maxContentLength in downloading media 2023-02-18 13:03:58 +05:30
Adhiraj Singh ca24608dc8 chore: pass axios options to downloading remote media 2023-02-18 13:03:47 +05:30
Adhiraj Singh f013b61e35 chore: update axios 2023-02-18 12:34:04 +05:30
kaatt cd9441fd0e Update messages-media.ts 2022-11-14 16:26:23 +05:30
kaatt 5c950dac10 fix getImageProcessingLibrary usage 2022-11-14 16:26:23 +05:30