Repository navigation
fix: correct Stellar base32 regex from [A-Z0-9] to [A-Z2-7] - #208
Open
Unclebaffa wants to merge 1 commit into
Open
Unclebaffa wants to merge 1 commit into
Unclebaffa wants to merge 1 commit into
Conversation
The frontend looksLikeStellar helper in QueuePage used /^G[A-Z0-9]{55}$/
which accepted characters 0, 1, 8 and 9 -- all invalid in the Stellar
Strkey base32 alphabet (A-Z plus 2-7 only). A key containing these
characters would pass frontend validation, be submitted to the API, and
then fail Stellar SDK validation downstream with a confusing HTTP 400.
Changes:
- Add frontend/src/utils/stellar.ts with STELLAR_PUBLIC_KEY_RE constant
and isValidStellarAddress() helper using the correct /^G[A-Z2-7]{55}$/
regex, matching the backend validateStellarAddress middleware exactly
- Remove inline looksLikeStellar from QueuePage; import shared utility
- Add input validation to DashboardPage lookup() so invalid keys are
rejected before any fetch is fired
- Add frontend/src/utils/stellar.test.ts with 19 regression tests:
keys containing 0/1/8/9 now return false, valid A-Z2-7 keys pass,
edge cases (wrong length, wrong prefix, empty string) all covered
- Update accessibility.test.tsx: DashboardPage test now types a valid
key so the mocked network error path is exercised as intended
- Fix pre-existing QueuesPage test failure: add IntersectionObserver
no-op stub in setupTests.ts (jsdom does not implement this API)
- Fix pre-existing enrollment success test: use findAllByRole('status')
since QueuePage correctly renders two live regions simultaneously
All 59 tests pass (11 test files).
|
@Unclebaffa is attempting to deploy a commit to the Deejah Team on Vercel. A member of the Team first needs to authorize it. |
Collaborator
|
well done so far, but please resolve conflicts and ci |
This branch has not been deployed
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
Branch
fix/frontend-lookslikestellar-base32-regexThe Bug
QueuePage.tsxdefined an inline helper:The character class
[A-Z0-9]is wrong. Stellar public keys use Strkey encoding, which is base32 with the alphabetA–Zand digits2–7only. The digits0,1,8, and9do not exist in this alphabet. A key likeG000...000(56 chars) would pass this frontend check, get submitted to the API, and fail inside the Stellar SDK — producing a confusing HTTP 400 with no indication the problem was at the input.The backend middleware (
validateStellarAddress.ts) and the Zod schema (backend/src/schemas/stellar.ts) both already used the correct/^G[A-Z2-7]{55}$/. The frontend was silently diverging.What Was Changed
frontend/src/utils/stellar.ts— new fileA shared utility module that centralises the regex in one place so it can never drift again:
The regex is identical to the one in the backend middleware. Both the constant and the function are exported so tests can reference the pattern directly.
frontend/src/pages/QueuePage.tsx— bug fixlooksLikeStellarfunction (which carried the wrong regex).import { isValidStellarAddress } from '../utils/stellar'.handleEnrollguard now callsisValidStellarAddress(publicKey).Keys containing
0,1,8, or9now produce the inline input error "Enter a valid Stellar public key (starts with G, 56 characters)." before any network call is made.frontend/src/pages/DashboardPage.tsx— validation addedThe Dashboard had no key format validation at all — it would fire a
fetchfor any non-empty string. Added an early return inlookup():Invalid keys now get an immediate UI error instead of a round-trip to the API that was always going to fail.
frontend/src/utils/stellar.test.ts— new regression test file (19 tests)Covers three categories:
Also asserts that
STELLAR_PUBLIC_KEY_REis aRegExpinstance and produces identical results toisValidStellarAddressfor the same inputs.frontend/src/pages/accessibility.test.tsx— test correctionThe existing DashboardPage accessibility test typed
'GINVALID'and expected aNetwork error. Once the validation guard was in place,GINVALIDwas correctly caught before the fetch — so the test got the validation error message instead. Updated the test to type a well-formed key (G+ 55As) so it exercises the actual network-error path as originally intended.Pre-existing Test Failures Fixed
Two tests in
accessibility.test.tsxwere already failing onmainbefore this work:1. QueuesPage —
IntersectionObserver is not definedQueuesPageusesIntersectionObserverfor infinite scroll. jsdom (the test environment) does not implement this browser API, so the component crashed on mount. Fixed by adding a no-op stub insetupTests.ts:2. "announces successful enrollment" — multiple
role="status"elementsAfter a successful enrollment,
QueuePagerenders tworole="status"live regions simultaneously — the page-level"Content loaded"announcement and the enrollment success message. Both are correct and intentional for accessibility. The test was usingfindByRole('status')which throws when more than one match exists. Changed tofindAllByRole('status')with a check that at least one element contains'Enrolled successfully'.Final State
Closes #188