feat(verify): show clear, actionable error for invalid verification links (#299) - #471
Open
CodingBabe-1 wants to merge 3 commits into
Open
feat(verify): show clear, actionable error for invalid verification links (#299)#471CodingBabe-1 wants to merge 3 commits into
CodingBabe-1 wants to merge 3 commits into
Conversation
The /verify page consumed return_url, claim, and threshold params without validating them, so a malformed link (unknown claim type, bad threshold, missing return URL) silently proceeded, showed a blank page, or hung on a spinner. Add lib/verifyParams.ts to parse and validate every verification-link parameter and return a specific VerifyError (missing/bad return URL, bad claim, bad threshold, bad restricted list). The verify page now renders a dedicated VerifyLinkError screen naming exactly what is wrong and offering a way back instead of a dead end. Also give the Persona-resume path and the wallet-not-connected path clear states. Coverage: unit tests drive each malformed param through parseVerifyParams and assert the mapped error, plus a rendering test asserts the error UI for every error code. Adds a vitest setup for the frontend app. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@CodingBabe-1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
…fyParams (ToluLabs#299) The merge of main into feat/299-verify-invalid-link-errors corrupted three things: pnpm-workspace.yaml gained a duplicate `esbuild: true` key and the lockfile accumulated 584 duplicated entries (both breaking `pnpm install --frozen-lockfile`, which is what killed the frontend, a11y, and contract CI jobs), and the merged lib/verifyParams.ts silently kept main's validate* helpers while dropping the PR's parseVerifyParams/VerifyError API that the verify page, VerifyLinkError, and their tests import. Fix: - Remove the duplicate esbuild allowBuilds entry and restore main's lockfile (package.json is unchanged, so main's lockfile is the correct one). - Union both APIs in verifyParams.ts: keep main's validateVerifyParams helpers for inline field errors and re-add the PR's parseVerifyParams/VerifyError for the dedicated invalid-link screen. - Wire parseVerifyParams into page.tsx so linkError renders VerifyLinkError for malformed verification links (the ToluLabs#299 feature). - Raise the Verify route size budget 10 kB -> 11 kB for the new error screen component (977 B of genuine feature growth). Verified locally: tsc, next build, lint, 375 vitest tests (incl. the new verifyParams/VerifyLinkError tests), theme tests, issuer tests, bundle size, axe-core e2e, and all 89 contract tests pass. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
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.
What does this PR do?
Fixes #299: the
/verifypage now shows a clear, actionable error whenever a verification link's params are invalid, instead of a blank page, a stuck spinner, or a silent proceed.The verify page consumed
return_url,claim, and threshold /restrictedparams without validating them. A link with an unknownclaimtype silently dropped the lock and kept going, a malformed threshold could flow into issuance as garbage, and a missingreturn_urlwas silently accepted. This PR introduces a dedicatedlib/verifyParams.tsvalidation module that parses every verification-link parameter and, on failure, returns a specificVerifyErrordescribing exactly what is wrong. The page renders aVerifyLinkErrorscreen that names the problem and offers a clear way back.What changed
lib/verifyParams.ts(new) – Pure, testable parsing/validation of/verifyquery params. Distinguishes a plain self-service visit (nav/sidebar/CTA "Get verified", or a Persona?inquiry-idresume) from a protocol verification link, and validates the protocol-link case:return_url→missing_return_urlreturn_url→bad_return_urlclaimtype →bad_claimthreshold_years/threshold/min_threshold) →bad_thresholdrestrictedcountry-code list →bad_restrictedclaimParamsso only params that apply to the requested claim are carried into issuance.app/verify/page.tsx– CallsparseVerifyParamsup front; on any failure it renders the dedicated error screen and skips the form entirely (no silent proceed). Also enriches the wallet-not-connected state (tells the user which claim / returning domain is requested) and gives the Persona-resume path a clear "nothing to resume" state instead of a silent dead end.app/verify/VerifyLinkError.tsx(new) – Standalone invalid-link error component (title, detail, "Go to your credentials" + "Back home").lib/verifyParams.test.tsdrives each malformed param through the validator and asserts the mapped error;app/verify/VerifyLinkError.test.tsxrenders the error UI for every error code and asserts the exit points.vitestsetup (vitest.config.ts,test/setup.ts, and apnpm testscript) so the app suite can run; the standalone@stellarcred/issuerpackage keeps its own node-environment runner.Acceptance checklist
/verify(no params) behaves exactly as before.Type of change
Checklist
cargo testpasses (contracts) — no contract changespnpm tsc --noEmitpasses (frontend)pnpm buildpasses (frontend)pnpm testpasses (frontend – includes issuer suite)NEXT_PUBLIC_prefix on server-only env varsNotes for reviewers
/verifyvisit (sidebar, homepage CTAs, "Get a credential") is intentionally not treated as invalid — only links carrying verification params (return_url/claim/ thresholds /restricted) are validated strictly. Persona resume links (?inquiry-id=…) are also treated as self-service, as before.