Commit Graph

2208 Commits

Author SHA1 Message Date
Rajeh Taher a2e7e070fc general: remove console logs, linting 2025-09-08 23:11:32 +03:00
Rajeh Taher d0f8713247 example: no errors 2025-09-08 23:01:02 +03:00
Rajeh Taher b0c3486ab0 generics: update the fetch function to work, keep old for backwards comp 2025-09-08 23:01:02 +03:00
Rajeh Taher 5b6eae4523 socket: fix error 2025-09-08 23:01:02 +03:00
Rajeh Taher dc5bb11bb7 message-recv: fix logic 2025-09-08 23:01:02 +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 ca22ae5f9c Update README with breaking change notice and survey 2025-09-07 22:53:24 +03:00
Rajeh Taher b53ef17ba0 caution for upcoming release 2025-09-07 22:47:31 +03:00
Rajeh Taher 2a00d65e44 cleaning up after AI slop! 2025-09-07 20:34:19 +03:00
Paulo Victor Lund f83a1c2aff Add mutex-based transaction safety to Signal key store (re-reworked) (#1697)
* mutex reimplementation

* lint

* lint

* lint fix

* Add cleanup for expired sender key mutexes

Introduces a mechanism to periodically clean up unused sender key mutexes in addTransactionCapability, reducing memory usage by removing mutexes that have not been used for over an hour and are not locked. A timer is started when the first mutex is created, and cleanup runs every 30 minutes.

* Update auth-utils.ts

* Refactor Signal key transaction usage

Introduces a local variable for parsed Signal keys in libsignal.ts to avoid repeated type assertions and improve code clarity.

* Refactor transaction handling for key operations

Introduces per-entity mutexes and passes key identifiers to transaction calls for finer-grained concurrency control in Signal key storage and socket operations. Updates transaction signatures and usage across Signal, Socket, and Utils modules to improve atomicity and performance, especially for system and sync messages.

* Improve SignalKeyStore transaction handling

Refactored transaction logic in SignalKeyStore to add commit retries, cleanup of transaction state, and improved mutex management for sender keys. Enhanced validation and batching for pre-key deletions and updates, improving concurrency and reliability.

* Replace custom mutex cleanup with LRU cache

Switched from manual mutex cleanup logic to using the lru-cache package for managing mutexes in addTransactionCapability. This simplifies resource management and ensures expired mutexes are automatically purged. Added lru-cache as a dependency.

* Lint fix

* Update src/Signal/libsignal.ts

* Update libsignal.ts

---------

Co-authored-by: João Lucas <jlucaso@hotmail.com>
Co-authored-by: Rajeh Taher <rajeh@reforward.dev>
2025-09-07 20:22:47 +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 076daae89d types: fix circular import
closes #1746
2025-09-07 14:51:13 +03:00
Rajeh Taher 538d3e4da7 move to create instead of fromObject 2025-09-07 14:29:45 +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
Gustavo Quadri 8f21a67e4a fix: sync pre-keys on socket start and add specific pre-key error approach (#1663)
* fix: sync prekeys when storage mismatch

* fix: verify if current pre-key exists instead of matching

* add: pre-keys error specific approach

* fix: lint

* fix: lint
2025-09-07 14:11:50 +03:00
João Lucas de Oliveira Lopes 0fbce52fd3 fix(socket): Prevent crashes from timeouts and fix memory leak (#1627) 2025-09-07 14:11:32 +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
João Lucas de Oliveira Lopes 9573d5cbb7 Fix/signal group sender message keys init (#1731)
* fix(signal-group): initialize senderMessageKeys when deserializing SenderKeyState

* test(signal-group): add regression test for missing senderMessageKeys initialization
2025-09-07 14:10:56 +03:00
Matheus Filype d2adbaf3fc fix: message retries loop (#1641)
* fix: improve message resend logic by adding checks for message IDs

* Revert "fix: improve message resend logic by adding checks for message IDs"

This reverts commit c03f9d8e6fc6cbfbb9d1f8f67c169700e704213d.

* fix: enhance message resend logic by adding checks for message IDs

* fix: adjust message resend logic to allow maximum retry count
2025-09-07 14:10:39 +03:00
Samuel Rodrigues Almeida Costa 54a4548c1b Update decode-wa-message.ts (#1654)
When the cell phone connected to the instance (Baileys) sends a message to a contact (fromMe = true), the senderPn comes as undefined. This fix fixes this problem temporarily.
2025-09-07 14:08:41 +03:00
Lucas Fochesatto 2f2c1dc25e Feat: Allow creating, linking, and unlinking groups from a community (#1729)
* feat: create group inside a community

* feat: link and unlink groups to a community
2025-09-07 14:08:34 +03:00
vini 50fc83b008 feat(business): change profile/cover photo and manage quick replies (#1724) 2025-09-07 14:08:26 +03:00
vini 084761dc31 feat: eventMessage sending / call link creation (#1677) 2025-09-07 14:08:18 +03:00
João Lucas de Oliveira Lopes 4d4339dae6 feat(WAProto): Optimize protobuf generation for 80%+ bundle size reduction (#1665)
* chore: remove comments and veirfy from generated proto files (improve size)

* refactor: replace fromObject with create for proto message instantiation and flag no beautiful

* chore: lint issues
2025-09-07 14:08:11 +03:00
Rajeh Taher 9e04cce8d3 .github: Update GitHub sponsors list 2025-08-31 21:08:43 +03:00
github-actions[bot] 73d0a5f969 chore(release): v6.7.19 2025-08-31 02:31:24 +00:00
Rajeh Taher de821ecc52 readme.md: add survey info
Added a survey announcement for project users and updated README notes.
2025-08-31 05:29:39 +03:00
Rajeh Taher 0716469dd6 readme: Remove shield images
Removed shield images for NPM downloads, GitHub code size, and Discord.
2025-08-31 05:27:23 +03:00
Rajeh Taher 0feded6c9e readme: improve English grammar 2025-08-31 05:15:03 +03:00
Rajeh Taher 27bc0bb313 readme: Add user survey and update guide warnings 2025-08-31 05:11:22 +03:00
Gustavo Quadri 478b08bf79 Fix: prevent zero padding in writeRandomPadMax16 causing message delivery failures (#1706) 2025-08-26 06:11:58 -03:00
Rajeh Taher fb08f3cadd readme: update where to reach the old guide 2025-08-19 16:28:28 +03:00
Rajeh Taher feb8a50065 readme: update NPM badge 2025-08-19 16:25:22 +03:00
Rajeh Taher 6e2c52e1ab readme: Update discord ljnk 2025-08-19 16:24:01 +03:00
Zisa be3d869cae feat: event buffer should use logger.debug instead of logger.info (#1689)
The `logger.info` makes Baileys' log verbose.

The flush is executed constantly and could be more useful during troubleshooting
sessions with log level = debug
2025-08-11 08:25:37 -03:00
vini 162ebe1cc2 ci: build workflow (#1681) 2025-08-07 01:52:56 +03:00
vini aba3ecf969 feat: add enable/disable link preview privacy (#1675) 2025-08-07 01:50:24 +03:00
Renato Freitas 260311e6a2 Fix call offer from lid call (#1670)
* Fix call offer from lid call

* check prettier
2025-08-07 01:21:20 +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
M Ilham Ari Pahmi 1a721bb242 fix proto import (#1653) 2025-07-31 19:58:46 -03:00
fwidjaja94 d4a42d5217 Update package.json (#1660) 2025-07-31 18:29:14 -03:00
João Victor Souza 0c20166a45 feat: community support (#1157)
* feat: communities

* feat: update makeCommunitiesSocket

* chore(release): v6.7.10

* fix: ajust create communitie

* feat: update communities

* revert: package.json

* fix: Revert CHANGELOG.md

* fix: Revert CHANGELOG.md

* fix: Revert CHANGELOG.md

* fix: revert package-lock.json

* fix: revert package-lock.json

* fix: revert yarn.lock

* fix: remove comment

* restore yarn.lock

* fix: improve type imports and formatting in communities.ts

* fix: remove trailing semicolon in baileys-version.ts

* fix: Delete src/Defaults/baileys-version.ts

---------

Co-authored-by: João Lucas <jlucaso@hotmail.com>
2025-07-30 09:15:56 -03:00
João Lucas de Oliveira Lopes 8d2cdbcf98 Fix regression import attribute (#1642)
* Revert "Replace deprecated assert with import attributes syntax (#1619)"

This reverts commit f61221f73a.

* fix: update import syntax for bailey's version JSON
2025-07-29 10:20:02 -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
steflsd f61221f73a Replace deprecated assert with import attributes syntax (#1619)
* replace assert with

* assert with

* more ts way for version

* fix: remove JSON import assert syntax for Node.js compatibility

- Replace JSON imports with generated .js imports
- Fixes compatibility between Node.js versions (assert vs with syntax)
- Maintains same functionality while avoiding syntax issues
2025-07-27 00:59:54 +03:00
Nurutomo cdd2f0d53f fix: correcting if logic for contextInfo (#1628) (#1629)
* fix: correcting if logic for contextInfo

* fix: typing of the logic
[BUG] Can't mention number/someone
Fixes #1628

* lint: whitespace issues
2025-07-27 00:58:14 +03:00
Rajeh Taher b7876da2e5 package: make scripts npm-based 2025-07-20 12:51:17 +03:00