feat(nr-app): accept @username and trustroots.org addresses at setup#256
Open
leon-wbr wants to merge 4 commits into
Open
feat(nr-app): accept @username and trustroots.org addresses at setup#256leon-wbr wants to merge 4 commits into
leon-wbr wants to merge 4 commits into
Conversation
Users reach for whatever identifier they have to hand, so the setup field now takes the three shapes that resolve to a username without a lookup: alice, @alice and alice@trustroots.org. A non-Trustroots email is still rejected, with copy pointing at the username: mapping an arbitrary email to a username would need an email->username endpoint Trustroots does not expose, and exposing one invites user enumeration. See OVERVIEW.md. Refs #208
The rejection copy and comment claimed an arbitrary email could not be mapped to a username because Trustroots exposes no email->username endpoint. That is wrong: nr-bridge reads the Trustroots users collection directly, where email is a unique, lowercased field next to username. Rejecting email is a choice, not a limit. Usernames are already public, emails are not, so an email-keyed lookup would make request_token an oracle for whether someone has a Trustroots account at all. Say that in the comment, and give the user a short, friendly error instead. Refs #208
leon-wbr
force-pushed
the
feat/208-flexible-trustroots-identifier
branch
from
July 13, 2026 11:03
5378126 to
c9c38c6
Compare
Cover lowercase, uppercase and mixed-case input explicitly instead of asserting twice against a name that could belong to a real Trustroots user.
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.
Refs #208 (replaces #251, whose description carried an incorrect rationale for rejecting email)
What this does
The setup field asked for a "Trustroots Account" without saying what that meant, and accepted only a bare username. It now takes the three shapes that can be resolved to a username without a lookup:
alicealice@AlicealiceAlice@Trustroots.orgaliceThe code-entry fallback in
onboarding/trustroots.tsxnow goes through the same validator (it was doing a raw.trim().toLowerCase(), so@alicewould have been sent un-stripped). The accepted formats are handled silently rather than advertised under the field — the label still asks for a username, which is what we want people to type.Why an arbitrary email is still rejected
Not because we cannot resolve one — the earlier PR said that, and it was wrong. nr-bridge reads the Trustroots
userscollection directly, whereemailsits next tousernameas a unique, lowercased field, so an email→username lookup is entirely buildable.It is a deliberate choice. Usernames are already public; emails are not. An email-keyed lookup would turn
request_tokeninto an oracle for whether a given address has a Trustroots account at all — free user enumeration against a set of addresses an attacker already holds. So the input is rejected with a short, friendly error pointing at the username, and the code comment now states the real reason.#208 stays open: making email work is a product/privacy decision (and likely a rate-limited, authenticated endpoint), not a missing capability.
Tests
pnpm testinnr-app: 99 passing. Covers all three accepted shapes plus the rejected ones (foreign-domain email, multiple@, bare@).