feat(email): add Message_Id_Util for RFC 5322 threading + signed Reply-To#31
Open
feat(email): add Message_Id_Util for RFC 5322 threading + signed Reply-To#31
Conversation
Ports the NestJS email/message-id.ts helpers to WordPress. Coexists
with the existing Email_Threading class during the migration window —
new outbound paths should prefer this util so inbound Reply-To
verification has something to check against.
API:
build_message_id(ticket_id, reply_id, domain)
parse_ticket_id_from_message_id(raw)
build_reply_to(ticket_id, secret, domain)
verify_reply_to(address, secret)
Uses hash_hmac('sha256', ...) + hash_equals for timing-safe verification.
Pure functions, no WP test harness — 13 unit tests covering round-trip,
tamper rejection, case-insensitive hex, malformed input, and the
local-part-only acceptance path.
This was referenced Apr 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports the NestJS
email/message-id.tshelpers to WordPress. Coexists with the existingEmail_Threadingclass during the migration window — new outbound paths should prefer this util so inbound Reply-To verification has something to check against.API
build_message_id(ticket_id, reply_id, domain)parse_ticket_id_from_message_id(raw)build_reply_to(ticket_id, secret, domain)verify_reply_to(address, secret)Uses
hash_hmac('sha256', ...)+hash_equalsfor timing-safe verification.Why signed Reply-To
The 8-char HMAC-SHA256 prefix on the Reply-To local part means even clients that strip our Message-ID / In-Reply-To headers still route replies back to the right ticket — the inbound provider webhook can verify the prefix before routing.
Design divergence note
The existing
Email_Threadingclass emits Message-IDs in a different shape:reply-{id}-ticket-{reference}@{domain}(usesreference, notid). This util uses the NestJS-compatible shape. Follow-up PR will migrateEmail_Threadingso inbound routing can use a single format.Test plan
test (8.1),test (8.2),lint