Skip to content

Accept hashed Email + Phone in requests - #65

Open
mosherBT wants to merge 5 commits into
masterfrom
feature/accept-hashed-identifiers
Open

Accept hashed Email + Phone in requests#65
mosherBT wants to merge 5 commits into
masterfrom
feature/accept-hashed-identifiers

Conversation

@mosherBT

Copy link
Copy Markdown
Contributor

Summary

Adds .hem for callers that already hold a SHA256 of an Email address, so a HEM can be passed to identify/targeting without the SDK hashing it again. Previously .emailAddress always hashed its input and there was no way in for HEM values. Also adding the same function for phone numbers.

Bug Fix

In the newsletter path there tryIdentifyFromURL(url) we were double hashing ex. SHA256(SHA256(email@test.com)) so any newsletter path was silently ignoring emails. The double hash would look normal but would never match HEM(email).

Introduced here due to OptableEncoder abstraction. Before (HEM into identify call) versus after where we apply the hash to the HEM, since it comes through with e: prefix

Adds an OptableIdentifier.raw case for identifiers that are already
type-prefixed and encoded, such as a hashed Email obtained from a backend
or a newsletter link. The value is sent as-is.

This also fixes tryIdentifyFromURL, which pulled the SHA256 oeid out of the
URL and then passed it through .emailAddress, hashing it a second time and
sending an EID that could never match. The Objective-C identifierWithString:
factory had the same problem.

Mirrors OptableIdentifier.Raw in the Android SDK.
Adds .hashedEmailAddress and .hashedPhoneNumber for callers that already
hold a SHA256 of the value, such as a HEM supplied by a backend or CRM.
The value is normalized (whitespace removed, lowercased) and prefixed, but
not hashed a second time.

Also fixes init?(extendedIdentifier:), which mapped an encoded 'e:'/'p:'
value back onto .emailAddress/.phoneNumber and therefore hashed it again.
This is what made tryIdentifyFromURL send sha256(sha256(email)) for the
oeid in newsletter links.
@mosherBT mosherBT self-assigned this Aug 13, 2026
@mosherBT
mosherBT requested review from a team as code owners August 13, 2026 17:50
@mosherBT mosherBT changed the title Feature/accept hashed identifiers Accept hashed Email + Phone in requests Aug 13, 2026
Swift imports all-caps NS_ENUM tokens verbatim, so
OptableSDKIdentifierType_HEM is .HEM, matching the existing .ID5 and
.UTIQ cases rather than the lowerCamelCase ones.
Comment thread Source/Public/ObjCSupport/OptableSDKIdentifier.h
Comment thread Source/Core/OptableIdentifierEncoder.swift Outdated
@mosherBT
mosherBT force-pushed the feature/accept-hashed-identifiers branch from dfb14ca to a961e07 Compare August 13, 2026 19:21
@mosherBT
mosherBT force-pushed the feature/accept-hashed-identifiers branch from 59e1854 to 6d7bcc2 Compare August 13, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants