feat: add TLD validation with real-time warnings

Implement comprehensive TLD validation that checks domain inputs against
the IANA TLD list and RDAP registry to provide context-aware error
messages and real-time UI warnings.

Key changes:
- Add tld-validation service that validates TLDs against IANA list and
  RDAP registry availability
- Show warning icons in LookupInput for invalid TLDs (error) and valid
  TLDs without RDAP support (warning) with explanatory tooltips
- Enhance error messages in getRegistryURL to differentiate between
  invalid TLDs, valid TLDs without RDAP, and malformed domains
- Add NotFoundError class for better 404 handling with context-specific
  messages per target type (domain, IP, ASN, entity, TLD)
- Make getRegistryURL async to support TLD validation in error path
- Add comprehensive test coverage for TLD validation and error messages
- Track TLD warning displays in telemetry

This improves UX by catching common mistakes (typos, non-existent TLDs,
reserved TLDs) before query execution and providing clear guidance.
This commit is contained in:
Ryan Walters
2025-11-06 15:40:28 -06:00
parent 71ddaadaa0
commit 13fc05226d
8 changed files with 536 additions and 25 deletions

View File

@@ -30,10 +30,16 @@ const Index: NextPage = () => {
[router]
);
const { error, target, setTarget, setTargetType, submit, currentType, manualType } = useLookup(
undefined,
handleUrlUpdate
);
const {
error,
target,
setTarget,
setTargetType,
submit,
currentType,
manualType,
tldValidation,
} = useLookup(undefined, handleUrlUpdate);
// Parse URL parameters on mount and auto-execute query if present
useEffect(() => {
@@ -143,6 +149,7 @@ const Index: NextPage = () => {
<LookupInput
isLoading={isLoading}
detectedType={currentType}
tldValidation={tldValidation}
shareableUrl={
response.isJust && target && typeof window !== "undefined"
? buildShareableUrl(window.location.origin, target, manualType)