Feat/promo tracking send email - #43
Merged
Merged
Conversation
initiate parks `dest` on oauth_state beside ref and utm_*; the callback reads it
back and appends it to the `home` URL it already builds. A signed-out visitor
who clicks a campaign CTA and signs in with Google or Apple now lands where the
link named instead of on a bare desk.
THE DESTINATION GOES ON THE URL, not into storage. The visitor may land on a
different deploy slot from the one they clicked (measured on stage: clicked
/-/huan/, landed /-/), and a fragment could never have reached this server
anyway. ui-team's billing-deep-link consume() already reads a destination off
the URL when storage has none — so nothing changes over there, which was worth
verifying rather than assuming.
ALL THREE SUCCESSFUL EXITS carry it: existing sign-in, new account (the welcome
card's CTA) and 2FA (through the OTP screen). Missing one would make the feature
work for some users and silently not for others.
_sanitiseDest IS A SHAPE CHECK THAT REBUILDS, not an escaping pass: one path,
four params, each matched against its own anchored regex, and the string
assembled again from what survived — so a value can only ever be one this
function could have written. An unknown param is REFUSED rather than dropped,
because honouring half a link written against a contract we do not have is how a
destination becomes a wrong one rather than an absent one. Run at both ends: the
row is data, and the code that builds a template's input is the code that has to
have checked it.
AND THE TEMPLATES NO LONGER INTERPOLATE THAT URL RAW. lib/loby.js renders with
lodash, whose equals-delimiter is the RAW one — the reverse of EJS — so
location.replace('<url>') put request-derived text straight into a JS string
literal on the page that runs immediately after authentication. Both landing
templates now emit it through JSON.stringify, and the new-account CTA through
the escaping delimiter. The sanitiser refusing quotes and the template escaping
are independent; either alone is one edit away from an XSS.
The initiate INSERT now degrades one column-group at a time (dest → utm → ref →
bare) rather than falling straight to the bare row: a database without `dest`
must still keep the campaign. Signing in never depends on any of it.
Two guards in the sanitiser — the character check and the 255 cap — cannot
currently decide anything, verified by mutation: with the path fixed and every
param bounded, the longest value it can emit is 125 chars. They are kept as
defence in depth, and the suite pins the PREMISE instead (every param regex is
anchored and quote-free), so adding a free-text param fails loudly at the moment
those guards start doing real work.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
_sanitiseDest refuses any param it does not recognise — deliberately, so a link written against a contract this code does not have cannot be half-honoured. That makes an omission here worse than elsewhere: a destination carrying the campaign CTA's `for=<tag>` was rejected WHOLE, so the OAuth deep link stopped working entirely rather than merely losing its marker. Case-tolerant and normalised to lowercase on rebuild. The server only ever emits lowercase and the dashboard compares case-insensitively, so refusing an uppercased tag would kill an entire destination over something neither end cares about. An EMPTY `for=` reads as absent rather than malformed, like every other param: stripping a value is no easier than stripping the whole param, and the marker is a UX guard rather than a control either way. Stated as its own case because the first version of that test asserted the opposite — my expectation was wrong, not the code. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
Claude encountered an error after 0s —— View job I'll analyze this and get back to you. |
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.


No description provided.