Commit Graph

275 Commits

Author SHA1 Message Date
Renato Alcara 54b399dc2e feat(app-state): App State Sync Resilience (#208)
feat(app-state): App State Sync Resilience (#208)
2026-02-22 21:54:37 -03:00
Claude ca69786579 Update protobufjs to v8.0.0 and protobufjs-cli to v2.0.0
- Updated protobufjs from ^7.2.4 to ^8.0.0
- Updated protobufjs-cli from ^1.1.3 to ^2.0.0
- This resolves peer dependency conflicts
- Use --legacy-peer-deps flag when installing

https://claude.ai/code/session_015R3U3kiprQiNTTNNt31Sg6
2026-02-14 13:00:10 +00:00
Claude c6a93a1867 fix: revert @types/node to v20 to match production Node version
Production server (vmi2736502) uses Node v20.20.0, not v22.
@types/node must match the lowest Node version we support.

Changed:
- @types/node: ^22.12.5 → ^20.19.33

Local dev may use Node 22, but types must be compatible with
production Node 20 to avoid runtime errors from missing APIs.

https://claude.ai/code/session_015R3U3kiprQiNTTNNt31Sg6
2026-02-14 11:32:48 +00:00
Claude afc5448dc2 chore: update typescript and @types/node to latest compatible versions
- typescript: ^5.8.2 → ^5.9.3 (latest stable)
- @types/node: ^20.19.33 → ^22.12.5 (match Node 22.x runtime)

Not updated (incompatible or breaking changes):
- eslint/eslint-js: Requires ESLint 10.x (not supported by @typescript-eslint yet)
- protobufjs/protobufjs-cli: Major version bump (requires testing)

https://claude.ai/code/session_015R3U3kiprQiNTTNNt31Sg6
2026-02-14 11:28:29 +00:00
Claude 05fca1455c fix: remove duplicate dependencies in package.json
Removed duplicate entries that were causing yarn.lock inconsistencies:

dependencies:
- libsignal (kept github:whiskeysockets/libsignal-node)
- lru-cache (kept ^11.2.6, removed ^11.1.0)
- music-metadata (kept ^11.12.0, removed ^11.7.0)

devDependencies:
- link-preview-js (kept ^4.0.0, removed ^3.0.0)
- lru-cache (kept ^11.2.6, removed ^11.1.0)
- open (kept ^11.0.0, removed ^8.4.2)

JSON spec keeps the last occurrence of duplicate keys, which was
causing Yarn to try reverting to older versions during CI installs.

https://claude.ai/code/session_015R3U3kiprQiNTTNNt31Sg6
2026-02-14 11:21:06 +00:00
Renato Alcara 98e4840729 Merge branch 'master' into claude/evaluate-workflow-errors-PDDoJ 2026-02-14 08:12:09 -03:00
Claude 777c343b4b chore: update dev dependencies to latest versions
Updated packages:
- eslint: ^9 → ^9.39.2 (kept on v9 for typescript-eslint compatibility)
- prettier: ^3.5.3 → ^3.8.1
- lru-cache: ^11.1.0 → ^11.2.6 (both dependencies and devDependencies)
- music-metadata: ^11.7.0 → ^11.12.0
- @typescript-eslint/eslint-plugin: ^8 → ^8.55.0
- @typescript-eslint/parser: ^8 → ^8.55.0

Note: ESLint 10.0.0 is not yet supported by typescript-eslint,
so we keep ESLint on the latest v9.x release.

 All tests pass
 Lint passes with no errors

https://claude.ai/code/session_015R3U3kiprQiNTTNNt31Sg6
2026-02-14 11:03:16 +00:00
Claude 4607e32b46 chore: update safe dependencies to latest versions
Updated the following dependencies without breaking changes to proto or core functionality:

Dependencies:
- @cacheable/node-cache: ^1.4.0 → ^2.0.1 (improved caching)

Dev Dependencies:
- @types/node: ^20.9.0 → ^20.19.33 (latest v20 types)
- open: ^8.4.2 → ^11.0.0 (CLI utility for opening URLs)
- release-it: ^15.10.3 → ^19.2.4 (release automation)
- typedoc: ^0.27.9 → ^0.28.17 (documentation generator)
- typedoc-plugin-markdown: 4.4.2 → ^4.10.0 (markdown docs)

⚠️ NOT updated (too risky after recent proto3 fixes):
- protobufjs (kept at ^7.2.4, v8 would break proto3 compatibility)
- protobufjs-cli (kept at ^1.1.3, v2 could break proto generation)
- eslint packages (kept at v9, v10 might introduce new lint errors)

All workflows (build, lint, test) verified to pass with these updates.

https://claude.ai/code/session_015R3U3kiprQiNTTNNt31Sg6
2026-02-14 05:35:00 +00:00
Claude 439f87aa1d fix: change libsignal dependency from SSH to HTTPS
Changed libsignal dependency from "github:whiskeysockets/libsignal-node"
to "https://github.com/whiskeysockets/libsignal-node.git" to fix
GitHub Actions workflow failures.

The Yarn package manager was not respecting Git's global URL rewrite
configuration and was trying to use SSH (which failed with "Permission
denied (publickey)"). Using explicit HTTPS syntax ensures the dependency
is always fetched over HTTPS in CI environments.

https://claude.ai/code/session_015R3U3kiprQiNTTNNt31Sg6
2026-02-14 05:19:01 +00:00
Claude 4467762a09 chore: update dependencies to latest compatible versions
## Changes

### Production Dependencies
- @hapi/boom: ^9.1.3 → ^10.0.1
  - No API changes, only Node.js 20+ requirement
  - 100% backward compatible API
  - Security patches and improvements

- pino: ^9.6 → ^10.3.1
  - 100% backward compatible API
  - Performance improvements
  - Enhanced TypeScript types
  - Security patches

### Peer Dependencies
- audio-decode: ^2.1.3 → ^2.2.3
  - Bug fixes and improvements
  - Optional dependency

- link-preview-js: ^3.0.0 → ^4.0.0
  - Migrated to standard URL API
  - Better URL handling

### Dev Dependencies
- link-preview-js: ^3.0.0 → ^4.0.0
  - Modern URL parsing
  - Improved redirect handling

## Testing
 All tests passing (27 suites, 583 tests)
 Lint checks passing (0 errors, 239 warnings)
 TypeScript compilation successful
 Build successful

## Breaking Changes
None - all updates maintain 100% backward compatibility.

## NOT Updated (Intentional)
- protobufjs: Kept at ^7.2.4 (WhatsApp protocol compatibility)
- @types/node: Kept at ^20.x (LTS alignment, Node 25 not LTS)
- eslint: Kept at ^9.x (avoid config migration)
- @cacheable/node-cache: Kept at ^1.4.0 (breaking changes in 2.x)

## Motivation
- Security patches
- Performance improvements
- Bug fixes
- Maintain Node.js 20+ compatibility
- Prepare for future updates

https://claude.ai/code/session_015R3U3kiprQiNTTNNt31Sg6
2026-02-14 02:43:07 +00:00
Claude f60f5d978a fix: correct working directory for gen:protobuf script
Fixes GitHub Actions workflow "Update WAProto" failure.

Problem:
- GenerateStatics.sh was being executed from project root
- Script looks for ./WAProto.proto (relative to CWD)
- This resolves to <root>/WAProto.proto (doesn't exist)
- Should be <root>/WAProto/WAProto.proto

Error in CI:
```
Error: ENOENT: no such file or directory, open 'WAProto.proto'
Error: Cannot find module '.../fix-imports.js'
```

Solution:
Change script execution to run from WAProto/ directory:
- Before: "sh WAProto/GenerateStatics.sh" (runs from root)
- After: "cd WAProto && sh GenerateStatics.sh" (runs from WAProto/)

Now paths resolve correctly:
- ./WAProto.proto → <root>/WAProto/WAProto.proto 
- ./fix-imports.js → <root>/WAProto/fix-imports.js 

https://claude.ai/code/session_01TvSrN9JmHZDdKMZDFWEcUS
2026-02-12 21:57:15 +00:00
Claude 626d9ebf5d refactor: use GitHub shorthand for libsignal dependency
Changed from HTTPS URL to GitHub shorthand format for better reliability:
- Before: "https://github.com/whiskeysockets/libsignal-node.git"
- After: "github:whiskeysockets/libsignal-node"

Why this is better:
 Native Yarn/NPM support (optimized resolution)
 No protocol conversion issues
 Works consistently across all environments (CI, dev, prod)
 Shorter and cleaner syntax
 Official recommended format for GitHub dependencies

This format is equivalent to git+https:// but without SSH conversion bugs.
Tested and recommended by Yarn docs for GitHub repos.
2026-02-11 04:04:40 +00:00
Claude 8ac374c133 fix: use direct HTTPS URL for libsignal dependency
The root cause was simple: Yarn converts git+https:// to SSH.

Solution: Change package.json to use direct HTTPS URL
- Before: "git+https://github.com/whiskeysockets/libsignal-node"
- After: "https://github.com/whiskeysockets/libsignal-node.git"

This eliminates SSH conversion completely and works with all package managers.

Also simplified workflow by removing unnecessary workarounds:
- Removed temporary package.json patching step
- Removed retry logic
- Restored simple 'yarn install --immutable'

Clean, permanent solution. 🎯
2026-02-11 04:02:26 +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
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
João Lucas de Oliveira Lopes d4ef73aca5 feat: implement automated WhatsApp version update workflow and related scripts (#2130)
* feat: implement automated WhatsApp version update workflow and related scripts

* change cron to weekly

---------

Co-authored-by: Rajeh Taher <rajeh@reforward.dev>
2026-01-18 01:07:05 +02:00
github-actions[bot] cb8b3717aa chore(release): v7.0.0-rc.9 2025-11-21 15:38:40 +00:00
github-actions[bot] b371cac3a8 chore(release): v7.0.0-rc.8 2025-11-19 15:01:16 +00:00
github-actions[bot] b75caf6186 chore(release): v7.0.0-rc.7 2025-11-19 14:38:47 +00:00
github-actions[bot] 4599ff84bb chore(release): v7.0.0-rc.6 2025-10-19 22:37:38 +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
github-actions[bot] a9cb308c96 chore(release): v7.0.0-rc.5 2025-10-02 22:20:46 +00: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
github-actions[bot] 573ed2c427 chore(release): v7.0.0-rc.4 2025-09-26 08:55:34 +00:00
github-actions[bot] f6e1bb6150 chore(release): v7.0.0-rc.3 2025-09-14 19:57:18 +00:00
github-actions[bot] 7970a6e9af chore(release): v7.0.0-rc.2 2025-09-08 22:04:09 +00:00
github-actions[bot] f0a40e2856 chore(release): v7.0.0-rc.1 2025-09-08 21:02:04 +00: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
Paulo Victor Lund ae0cb89714 Session recreation and improved message retry (#1735)
* Add message retry manager for session recreation and caching

Introduces a MessageRetryManager to cache recent sent messages and manage automatic Signal session recreation for failed message retries. Adds new config options to enable these features, integrates retry manager into message send/receive logic, and provides periodic cache cleanup. Improves reliability of message delivery and retry handling.

* Add buffer timeout and cache limit to event-buffer

Introduces a buffer timeout to auto-flush events after 30 seconds and limits the history cache size to prevent memory bloat in event-buffer.ts.

* Add session validation to SignalRepository

Introduces a validateSession method to SignalRepository for checking session existence and state. Updates message retry logic to use the new validation, improving session recreation handling and retry management.

* Improve message retry management and tracking

Refactored message retry manager to use LRU caches for recent messages and session history, added retry counters and statistics tracking, and implemented phone request scheduling. Updated message receive and send logic to mark retry success and pass max retry count. Removed periodic cleanup logic in favor of cache TTLs for better resource management.

* lint fix

* Use validateSession for session checks in message send

Replaces direct session existence checks with the improved validateSession method, which also checks for session staleness. Adds debug logging for failed session validations to aid troubleshooting.

* Delete src/Utils/message-retry.ts

---------

Co-authored-by: Rajeh Taher <rajeh@reforward.dev>
2025-09-07 20:20:51 +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 d878f01efb new testing proposal (#1547)
* feat: new testing proposal

* chore: pr review
2025-09-07 14:11:17 +03:00
github-actions[bot] 73d0a5f969 chore(release): v6.7.19 2025-08-31 02:31:24 +00: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
fwidjaja94 d4a42d5217 Update package.json (#1660) 2025-07-31 18:29:14 -03:00
αѕтяσχ11 3ba5595d5b fix: build scripts for windows (#1616)
**Fix Windows path issue in `build` script**

**Issue**

The `build` script in `package.json` was written as:

```json
"build": "tsc -P tsconfig.build.json && tsc-esm-fix --tsconfig='tsconfig.build.json' --ext='.js'"
```

This works on Unix-based systems (macOS/Linux) but **breaks on Windows**, throwing an error:

```
Error: ENOENT: no such file or directory, open 'C:\path\to\project\'tsconfig.build.json''
```

> The single quotes `'` are treated **literally** on Windows CMD/PowerShell, resulting in a malformed path (e.g., `'tsconfig.build.json'` instead of `tsconfig.build.json`).

**Fixes**

Updated the script to remove single quotes around the `--tsconfig` and `--ext` arguments:

```json
"build": "tsc -P tsconfig.build.json && tsc-esm-fix --tsconfig=tsconfig.build.json --ext=.js"
```

**Result**

```
PS C:\Users\Astro\Documents\GitHub\Baileys> npm run build

> baileys@6.7.18 build
> tsc -P tsconfig.build.json && tsc-esm-fix --tsconfig=tsconfig.build.json --ext=.js

PS C:\Users\Astro\Documents\GitHub\Baileys>
```
2025-07-28 11:41:58 -03:00
Rajeh Taher b7876da2e5 package: make scripts npm-based 2025-07-20 12:51:17 +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 29f0ac83f8 tsc: fix builds & fix type errors 2025-07-19 17:16:07 +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
João Lucas de Oliveira Lopes 482db6edc5 refactor: migrate WASignalGroup to TypeScript and remove deprecated files (#1320)
* refactor: migrate WASignalGroup to TypeScript and remove deprecated files

* chore: remove WASignalGroup JavaScript files from package.json

* refactor: update SenderKeyStore and SenderKeyStateStructure interfaces to export and add deserialize method. Fix types

* chore: lint issue

* refactor: improve constructor type checking and getSeed method in SenderChainKey

* refactor: update key handling to use Buffer for improved consistency

* signal: consistent naming and dir structure + add some missing types

* fix: lint issues

---------

Co-authored-by: Rajeh Taher <rajeh@reforward.dev>
2025-06-21 18:02:15 +03:00