implement message reporting tokens (#1906)

* feat: implement message reporting tokens and privacy token handling

* feat: add support for privacy tokens in profile picture requests and history sync

* chore: pr feedback purpshell

* fix: improve privacy token handling and error messaging in socket configuration

* feat: enhance privacy token handling with improved sender mapping

* chore: removing tc token in favor of #2080

* chore: revert some unecessary changes

* feat(reporting): enhance reporting token extraction and compilation logic

* feat(reporting): add unit tests for reporting token utilities

* fix(reporting): streamline reporting token attachment logic in message sending

* fix: adjust reporting token inclusion logic to prevent retries

* chore: add return type to shouldIncludeReportingToken and improve getToken function type safety
This commit is contained in:
João Lucas de Oliveira Lopes
2026-01-08 16:50:49 -03:00
committed by GitHub
parent 4e681d3219
commit c9c3481817
4 changed files with 545 additions and 0 deletions
+8
View File
@@ -40,6 +40,7 @@ import {
getRawMediaUploadData,
type MediaDownloadOptions
} from './messages-media'
import { shouldIncludeReportingToken } from './reporting-utils'
type MediaUploadData = {
media: WAMediaUpload
@@ -617,6 +618,13 @@ export const generateWAMessageContent = async (
}
}
if (shouldIncludeReportingToken(m)) {
m.messageContextInfo = m.messageContextInfo || {}
if (!m.messageContextInfo.messageSecret) {
m.messageContextInfo.messageSecret = randomBytes(32)
}
}
return WAProto.Message.create(m)
}