Commit Graph

139 Commits

Author SHA1 Message Date
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 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
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
Claude c7f6ef9b14 fix(ci): regenerate yarn.lock with Yarn 4 format
The old yarn.lock was in Yarn 1 format with SSH URLs.
Regenerated with Yarn 4 using HTTPS URLs for git dependencies.

https://claude.ai/code/session_01QPt4WssG6jjEciQKdVpFtK
2026-02-02 17:55:08 +00:00
Claude fd9fc3541b fix(ci): use HTTPS URL in yarn.lock for libsignal
The yarn.lock had SSH URL hardcoded which fails in CI without SSH keys.
Changed resolved URL from git+ssh:// to git+https:// for libsignal.

https://claude.ai/code/session_01QPt4WssG6jjEciQKdVpFtK
2026-02-02 17:42:16 +00:00
Claude 43ece09fe9 feat(metrics): integrate prom-client for native Prometheus support
- Add prom-client ^15.1.3 as production dependency
- Migrate Counter class to use prom-client internally
- Migrate Gauge class to use prom-client internally
- Migrate Histogram class to use prom-client internally
- Update getMetricsOutput() to use prom-client's native metrics()
- Update contentType() to use prom-client's contentType
- Enable collectDefaultMetrics() for Node.js system metrics
- Maintain backward compatibility with existing API

Benefits:
- Native OpenMetrics format export
- Proper histogram bucket handling
- Default Node.js metrics (memory, CPU, event loop, GC)
- Better integration with Grafana/Prometheus ecosystem
2026-01-20 12:37:17 +00:00
Claude f1bee96e68 chore: update lock files 2026-01-20 02:32:15 +00:00
Rajeh Taher 88c5377ec6 ci: fix changelog gen 2025-10-20 01:34:15 +03:00
Rajeh Taher f56293365f chore: avoid npm warnings (update conventional-changelog) 2025-10-08 19:46:39 +03:00
Rajeh Taher 1060f44bff auth-utils: Make a better addTransactionCapability function 2025-10-03 00:03:21 +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 421ca2eb92 refactor(types): Strengthen Type Safety in Signal Handling & Core Utilities (#1764)
* refactor(types): Strengthen Type Safety in Signal Handling & Core Utilities

* chore: revert typescript and move types to libsignal

* chore: update libsignal dependency resolution and checksum

* fix: a minor regression

* chore: update libsignal resolution and checksum
2025-09-13 15:24:57 +03:00
Rajeh Taher 04d58e76f6 example: multiplex logging 2025-09-08 23:01:02 +03:00
Rajeh Taher 20693a59d0 lid, wip: Support LIDs in Baileys (#1747)
* lid-mapping: get missing lid from usync

* lid-mapping, jid-utils: change to isPnUser and store multiple mappings

* process-message: parse protocolMsg mapping, and store from new msgs

* types: lid-mapping event, addressing enum, alt, contact, group types

* validate, decode: use lid for identity, better logic

* lid: final commit

* linting

* linting

* linting

* linting

* misc: fix testing and also remove version json

* lint: IDE fucking up lint

* lid-mapping: fix build error on NPM

* message-retry: fix proto import
2025-09-08 10:03:28 +03:00
Rajeh Taher f869317b0a package: update lru-cache to v11.1.0 2025-09-07 20:07:11 +03:00
Rajeh Taher 410c26fb82 package: update node type to 20+, and use NPM for eslint config 2025-09-07 14:23:47 +03:00
Gustavo Quadri 0043f8be21 Add: LID support with lid-map and migrations of sessions (#1694)
* fix: add lid-map logic

* fix: lint and simplified version

* fix: single device migration

* fix: lid map discovery

* fix: lint

* fix: lid migration in socket connection

* fix: lint

* fix: decode-wa-message consistency

* fix: yarn lock

* fix: lint

* fix: retry logic

* fix: logger level
2025-09-07 14:12:24 +03:00
João Lucas de Oliveira Lopes 812e53e4eb Refactor: Fix Event Buffer Deadlock with State Machine (#1633)
* feat: implement state machine for chat synchronization and buffer management

* test: Add Jest configuration and tests for connection deadlock handling

- Created a Jest configuration file to set up testing environment.
- Implemented utility functions for creating isolated authentication sessions and mocking WebSocket connections.
- Added a test case to ensure that the connection does not deadlock when history sync is disabled, verifying the correct handling of message events.

* feat: add GitHub Actions workflow for running tests

* chore: sort import lint

* fix: implement timeout handling for AwaitingInitialSync state in chat socket, maybe fix memory leak

* feat: enhance chat synchronization by refining AwaitingInitialSync handling and adding history sync checks
2025-08-07 01:15:41 +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
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
canove bd53572e37 chore: fix lint 2025-06-09 23:14:31 -03:00
canove ae0de94307 chore: fix format 2025-05-28 22:44:21 -03:00
canove 21e2fac339 chore: add temporary proto extract 2025-05-21 12:17:57 -03:00
João Lucas de Oliveira Lopes c2cf49cd68 refactor: remove unused dependencies and clean up type exports (#1319) 2025-04-09 02:51:33 +03:00
Rajeh Taher 2fdabb7f38 docs: downgrade markdown gen to prevent incompatibility 2025-03-18 00:57:23 +02:00
Rajeh Taher 8a54c81b94 Merge remote-tracking branch 'origin/master' 2025-03-18 00:54:13 +02:00
Rajeh Taher d202241a6f docs: generate markdown 2025-03-18 00:54:07 +02:00
João Lucas de Oliveira Lopes 88e9cfa4e3 refactor: replace async-lock with async-mutex (#1304)
Co-authored-by: Rajeh Taher <rajeh@reforward.dev>
2025-03-15 00:45:30 +02:00
Rajeh Taher 63cc75d78e docs: fix docs generation 2025-03-14 23:55:42 +02:00
Rajeh Taher 1c2af09b03 socket,config: deprecate printQRInTerminal option
This was done to reduce dependencies
2025-03-10 15:08:50 +02:00
Rajeh Taher 40b8cc5383 package: add async-mutex dep
This will allow us to clear Baileys of any race conditions on async workflows
2025-03-09 01:28:21 +02:00
Rajeh Taher bb291ca6ed package: update deps, audio-decode peer
Also removed libphonenumber-js library for efficiency
2025-03-08 23:55:01 +02: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
Claudemir Todo Bom e6f98c3902 update pino dependency - fix #1249 (#1250)
Co-authored-by: Rajeh Taher <rajeh@reforward.dev>
2025-03-01 18:31:30 +02:00
Jared Wray 588de6ce10 fix: migrating to @cacheable/node-cache as it is maintained (#1074) 2025-03-01 18:15:49 +02:00
Rajeh Taher 18ac07df8e lint: 0 warnings left 2024-10-14 05:15:10 +03:00
wduandy 9e4e211751 chore: update-cache-manager-dependency (#996)
* chore: update-cache-manager-dependency

* fix: Linting

---------

Co-authored-by: Eduardo <eduandy@gmail.com>
2024-09-22 14:43:17 +03:00
Rajeh Taher 188515791d Revert "Update module to latest version (#926)" (#947)
This reverts commit d6d72c6b3f.
2024-07-27 17:23:23 +03:00
Rizz2Dev d6d72c6b3f Update module to latest version (#926)
* Update package.json

Update the module to the latest

* Add files via upload
2024-07-27 16:11:20 +03:00
devlikeapro bd20fb631b Run repository.injectE2ESession in chunks (#881) 2024-06-30 06:06:42 +03:00
Rajeh Taher c8aab8d03f fix(master): yarn lock and axios error + move to WhiskeySockets libsignal 2024-06-16 17:11:17 +03:00
Rajeh Taher c964615cf9 fix(master): fix lockfile (after #847) 2024-06-13 00:44:36 +03:00
allburov 9065ab690f Lock file on save and read (#824)
Fix #794
2024-06-01 10:32:19 +03:00
Rajeh Taher 07927554a2 fix(master): fix lockfile 2024-04-28 11:51:59 +00:00
Rajeh Taher ab7db8de5f chore: fix yarn.lock 2024-01-19 20:06:03 +02:00
Ashary Vermaysha 56b2cb14f2 chore(package.json): update protobufjs dependency from version 6.11.3 to 7.2.4 for compatibility and potential bug fixes (#302)
Co-authored-by: Rajeh Taher <rajeh@reforward.dev>
2024-01-19 18:00:34 +02:00