Commit Graph

2026 Commits

Author SHA1 Message Date
Rajeh Taher 42c980778e send, usync: fix lid Usync (including onWhatsApp), and send phash 2025-09-14 21:35:13 +03:00
Martín Schere 8029446511 Async + Multi Cache (#1741)
* fix: handle invalid signatureKeyPublic types in sender-key-state

- added extra check to ensure signatureKeyPublic is either a base64 string or a Buffer
- fallback to empty buffer when unexpected object type is received
- prevents ERR_INVALID_ARG_TYPE error in Buffer.from

* adjusted based on  @jlucaso1 recommmendation

* fix: handle chain key objects for skmsg group message decryption

previously, some sender chain keys were stored or retrieved as plain objects
(e.g. { '0': 85, '1': 100, ... }) instead of Buffers. this caused
"ERR_INVALID_ARG_TYPE" during initial decryption of skmsg group messages.

this fixes any chain key object is converted to a proper Buffer
before being passed to SenderChainKey.

* fix: add more robust checks and fallbacks

* feat: async cache

feat: async caching

* fix: linting issues

* fix: mget logic

---------

Co-authored-by: αѕтяσχ11 <devastro0010@gmail.com>
2025-09-14 17:13:11 +03:00
suhwr f0cc173aa3 Correct group participant phoneNumber attribute name (#1775) 2025-09-14 17:06:17 +03:00
M Ilham Ari Fahmi c8ebdb9a0b fix: fallback addressing_mode detection by sender suffix (#1776)
* fix: fallback addressing_mode detection by sender suffix

This commit is required because `remoteJidAlt` was not appearing.
The issue happened since `addressing_mode` always defaulted to 'pn' when the ID was not a group, so the 'lid' path was never taken.

* lint fix
2025-09-14 17:05:48 +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 e305d4848e sender-key: credit original fix and fix key handling 2025-09-13 11:41:52 +03:00
αѕтяσχ11 f0dcc30e0f fix: handle invalid signatureKeyPublic types in sender-key-state AND fix handling chain key objects for skmsg group message decryption (#1760)
* fix: handle invalid signatureKeyPublic types in sender-key-state

- added extra check to ensure signatureKeyPublic is either a base64 string or a Buffer
- fallback to empty buffer when unexpected object type is received
- prevents ERR_INVALID_ARG_TYPE error in Buffer.from

* fix: lint

* adjusted based on  @jlucaso1 recommmendation

* fix: handle chain key objects for skmsg group message decryption

previously, some sender chain keys were stored or retrieved as plain objects
(e.g. { '0': 85, '1': 100, ... }) instead of Buffers. this caused
"ERR_INVALID_ARG_TYPE" during initial decryption of skmsg group messages.

this fixes any chain key object is converted to a proper Buffer
before being passed to SenderChainKey.

* fix: add more robust checks and fallbacks

* hacky fix(sender-key-state): normalize signing pubkey as Buffer with 0x05 prefix

a little hacky fix that ensures getSigningKeyPublic always returns a proper Buffer to satisfy libsignal.
adds a fallback to prepend 0x05 when only a 32-byte key is present, avoiding
"Invalid public key" errors and TS type issues around Uint8Array vs Buffer.
2025-09-13 11:04:26 +03:00
Rajeh Taher 88ec0c4db2 Merge remote-tracking branch 'origin/master' 2025-09-09 23:57:39 +03:00
Rajeh Taher 9aa356845d sender-key: Properly digest new uint8array format keys. THANKS @w3nder!! 2025-09-09 23:57:30 +03:00
github-actions[bot] 7970a6e9af chore(release): v7.0.0-rc.2 2025-09-08 22:04:09 +00:00
Rajeh Taher 2ebaaf35a4 handlemessage: change console based log 2025-09-09 00:59:08 +03:00
Rajeh Taher 8a9fba7a8a Merge remote-tracking branch 'origin/master' 2025-09-09 00:55:03 +03:00
Rajeh Taher 8204e57a40 socket: fix onWhatsApp 2025-09-09 00:54:59 +03:00
Rajeh Taher f770c4ebb7 Update breaking change notice to version 7.0.0 2025-09-09 00:46:10 +03:00
Rajeh Taher b558d67851 Revise breaking change notice in README 2025-09-09 00:45:54 +03:00
github-actions[bot] f0a40e2856 chore(release): v7.0.0-rc.1 2025-09-08 21:02:04 +00:00
Rajeh Taher 4a1a06bed5 socket: fix onWhatsApp for LIDs and map any new LID pairs 2025-09-08 23:58:25 +03:00
Rajeh Taher acd7b757ce messages-recv,decode-wa-message: stability 2025-09-08 23:27:07 +03:00
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