* 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
* 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>
* 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>
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.
* 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
The `logger.info` makes Baileys' log verbose.
The flush is executed constantly and could be more useful during troubleshooting
sessions with log level = debug
* 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
**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>
```
* 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