Skip to content

Conversation

@jlucaso1
Copy link
Collaborator

to match whatsmeow implementation of this elements

@whiskeysockets-bot
Copy link
Contributor

whiskeysockets-bot commented Oct 12, 2025

Thanks for opening this pull request and contributing to the project!

The next step is for the maintainers to review your changes. If everything looks good, it will be approved and merged into the main branch.

In the meantime, anyone in the community is encouraged to test this pull request and provide feedback.

✅ How to confirm it works

If you’ve tested this PR, please comment below with:

Tested and working ✅

This helps us speed up the review and merge process.

📦 To test this PR locally:

# NPM
npm install @whiskeysockets/baileys@WhiskeySockets/Baileys#reporting-tctoken-elements

# Yarn (v2+)
yarn add @whiskeysockets/baileys@WhiskeySockets/Baileys#reporting-tctoken-elements

# PNPM
pnpm add @whiskeysockets/baileys@WhiskeySockets/Baileys#reporting-tctoken-elements

If you encounter any issues or have feedback, feel free to comment as well.

@jlucaso1 jlucaso1 force-pushed the reporting-tctoken-elements branch 3 times, most recently from 34ac312 to 02f329b Compare October 13, 2025 02:39
@jlucaso1 jlucaso1 changed the title WIP: implement message reporting tokens and privacy token handling implement message reporting tokens and privacy token handling Oct 13, 2025
@jlucaso1 jlucaso1 force-pushed the reporting-tctoken-elements branch from 96f2b48 to a2330d2 Compare October 13, 2025 03:39

if (chat.tcToken) {
privacyTokens.push({
jid: jidNormalizedUser(chat.id!),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to verify LID/PN discrepancy

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is the best way to handle that? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can handle same as #1912

@jlucaso1 jlucaso1 force-pushed the reporting-tctoken-elements branch from 9156372 to ae1c039 Compare October 13, 2025 14:33
@Salientekill
Copy link

Salientekill commented Oct 13, 2025

I got banned for adding the bot to a group with 514 members. If this solves it, it will be of great help. I look forward to this beautiful work.

@jlucaso1 jlucaso1 force-pushed the reporting-tctoken-elements branch from ae1c039 to 8dd1315 Compare October 13, 2025 22:00
@jlucaso1 jlucaso1 marked this pull request as ready for review October 13, 2025 22:02
@jlucaso1 jlucaso1 force-pushed the reporting-tctoken-elements branch from 51c7201 to 79f3938 Compare October 15, 2025 17:23
@Santosl2
Copy link
Contributor

up

Salientekill pushed a commit to Salientekill/Baileys that referenced this pull request Nov 3, 2025
- Add reporting token and privacy token handling
- Implement tcToken elements for message reporting
- Add support for reportingTokens in messages
- Update message processing for privacy tokens

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@jlucaso1
Copy link
Collaborator Author

Maybe we can get some inspirations here: canove/whaileys#51

Salientekill pushed a commit to Salientekill/Baileys that referenced this pull request Nov 17, 2025
…ns and privacy token handling

This PR adds support for message reporting tokens and privacy token handling.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@jlucaso1 jlucaso1 marked this pull request as draft November 18, 2025 00:13
Salientekill pushed a commit to Salientekill/Baileys that referenced this pull request Nov 19, 2025
…ets#1969 to latest Baileys

Applied PRs:
- WhiskeySockets#2067: libsignal wasm
- WhiskeySockets#2057: emit setting events
- WhiskeySockets#1969: improve retry logic

Note: PRs WhiskeySockets#1991, WhiskeySockets#1981, WhiskeySockets#1906, WhiskeySockets#1892 have conflicts with latest Baileys version and were skipped.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Salientekill pushed a commit to Salientekill/Baileys that referenced this pull request Nov 20, 2025
…ns and privacy token handling

Implements comprehensive privacy token and message reporting token handling
to match whatsmeow implementation.

New features:
- Message reporting token generation for eligible messages
- Privacy token storage and retrieval (in-memory by default)
- Trusted contact token (tcToken) support for profile pictures and messages
- LID (Local Identity) mapping support for privacy tokens

Files changed:
- NEW: src/Utils/reporting-utils.ts (262 lines)
- Modified: 11 files across Socket/, Types/, and Utils/ directories

Key improvements:
- Automatic message secret generation for reporting-eligible messages
- Privacy token handling in message send/receive
- Enhanced history sync with privacy token extraction
- Profile picture requests now support tcToken parameter

All conflicts resolved and build successful.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Salientekill pushed a commit to Salientekill/Baileys that referenced this pull request Nov 24, 2025
@github-actions github-actions bot removed the Stale label Dec 13, 2025
@purpshell
Copy link
Member

Any updates @jlucaso1

@jlucaso1 jlucaso1 changed the title implement message reporting tokens and privacy token handling implement message reporting tokens Dec 16, 2025
@jlucaso1 jlucaso1 requested a review from purpshell December 16, 2025 19:00
@jlucaso1 jlucaso1 marked this pull request as ready for review December 16, 2025 19:00
@jlucaso1
Copy link
Collaborator Author

Removed tctoken in favor of #2080
Now only reporting token in this pr

@jlucaso1 jlucaso1 requested review from canove and vinikjkkj December 16, 2025 19:01
@vinikjkkj
Copy link
Collaborator

is the changes in src/Utils/process-message.ts related to this PR?

@jlucaso1
Copy link
Collaborator Author

@vinikjkkj thank you. I didnt noticed that. Reverting.

@Santosl2
Copy link
Contributor

Tested and working ✅

@canove
Copy link
Contributor

canove commented Dec 19, 2025

@jlucaso1 left a few coments.

I asked Claude code to check and optimize reporting-utils, and, according to him, there was an improvement in performance.

The changes it made seem to make sense, mainly because it avoids the find inside the loop = O(n*m). I implemented the version with these adjustments in Whaileys (WIP), if you want to take a look.

https://github.com/canove/whaileys/pull/64/changes#diff-321487214369869e332b4749d527c6d9dadfe629700e8d1fdd9754c4354e9c39

@vinikjkkj
Copy link
Collaborator

instead of creating a "mini-protobuf" implementation (decode/encode varint), we cannot just use existent proto.ReportingTokenInfo?

@jlucaso1
Copy link
Collaborator Author

jlucaso1 commented Dec 20, 2025

instead of creating a "mini-protobuf" implementation (decode/encode varint), we cannot just use existent proto.ReportingTokenInfo?

I think is not simple like that. Check what waweb does (WABinary/WAWebReportingTokenProtobufUtils)

@jlucaso1
Copy link
Collaborator Author

@canove applied your suggestion, thank you!

extra: added some unit tests to evict regressions


if (!isNewsletter) {
if (
reportingMessage &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, you could put everything in a single if statement to avoid nesting; just add !isNewsletter to the inner if statement.

reportingMessage &&
shouldIncludeReportingToken(reportingMessage) &&
reportingMessage.messageContextInfo?.messageSecret &&
msgId
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this msgId here; it always exists.

One question: in which cases should we NOT send the reporting token?

Seems like we are not sending on retryResponses neither newsletter. Is that right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this msgId here; it always exists.

Nice catch, removed.

Yes, that's correct. Based on WhatsApp Web JS (isMsgTypeReportingTokenCompatible):

Should NOT send reporting token:

  • reactionMessage / encReactionMessage
  • pollUpdateMessage
  • encEventResponseMessage
  • Newsletters (different path, not E2E encrypted) (maybe we need to handle properly in the future, but need to check this logic deeper)
  • Retries (reportingMessage is only set when !isRetryResend)

Should send: All other regular content messages (text, image, video, audio, document, sticker, etc.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, we can put !isRetryResend inside de if statement to make it more explicit.

Also, remove the reportingMessage &&, since checking the reportingMessage?.messageContextInfo?.messageSecret does the trick.

@jlucaso1 jlucaso1 requested a review from canove December 20, 2025 13:10
Copy link
Contributor

@canove canove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just left a comment about adding the !isRetryResend on the if statement to make it more comprehensible. but not blocking.

lgtm

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

This PR is stale because it has been open for 14 days with no activity. Remove the stale label or comment or this will be closed in 14 days

@github-actions github-actions bot added the Stale label Jan 4, 2026
@purpshell purpshell merged commit c9c3481 into master Jan 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants