domain-hound 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/.agents/plugins/marketplace.json +1 -0
  2. package/.claude-plugin/marketplace.json +1 -0
  3. package/.claude-plugin/plugin.json +1 -1
  4. package/README.md +84 -13
  5. package/assets/readme-search.png +0 -0
  6. package/clis/domain-check/broker-atom.mjs +78 -0
  7. package/clis/domain-check/com-site.mjs +64 -25
  8. package/clis/domain-check/confirm.mjs +10 -5
  9. package/clis/domain-check/dossier.mjs +603 -0
  10. package/clis/domain-check/google-play.mjs +24 -11
  11. package/clis/domain-check/index.mjs +75 -23
  12. package/clis/domain-check/marketplaces.mjs +107 -0
  13. package/clis/domain-check/meaning-words.LICENSE.txt +408 -0
  14. package/clis/domain-check/meaning-words.json +2397 -0
  15. package/clis/domain-check/meaning.mjs +77 -0
  16. package/clis/domain-check/name-search.mjs +91 -14
  17. package/clis/domain-check/naming-method.mjs +6 -4
  18. package/clis/domain-check/registry.mjs +2 -2
  19. package/clis/domain-check/safe-web.mjs +207 -0
  20. package/clis/domain-check/trademarks.mjs +372 -0
  21. package/clis/domain-check/triage-sources.mjs +39 -12
  22. package/clis/domain-check/triage.mjs +190 -63
  23. package/clis/spaceship/buy.mjs +327 -0
  24. package/clis/spaceship/client.mjs +170 -0
  25. package/clis/spaceship/dns.mjs +292 -0
  26. package/clis/spaceship/quote.mjs +123 -0
  27. package/clis/spaceship/setup.mjs +81 -0
  28. package/clis/spaceship/store.mjs +104 -0
  29. package/clis/spaceship/tools.mjs +258 -0
  30. package/display.mjs +57 -30
  31. package/dossier.mjs +185 -0
  32. package/package.json +20 -2
  33. package/plugin.json +4 -3
  34. package/results-style.mjs +10 -0
  35. package/results.mjs +258 -62
  36. package/server.json +2 -2
  37. package/server.mjs +223 -96
  38. package/share.mjs +43 -0
  39. package/site/r/share-format.mjs +125 -0
@@ -4,6 +4,7 @@
4
4
  "plugins": [
5
5
  {
6
6
  "name": "domain-hound",
7
+ "version": "0.1.7",
7
8
  "source": { "source": "local", "path": "./" },
8
9
  "policy": { "installation": "AVAILABLE", "authentication": "ON_INSTALL" },
9
10
  "category": "Productivity"
@@ -5,6 +5,7 @@
5
5
  "plugins": [
6
6
  {
7
7
  "name": "domain-hound",
8
+ "version": "0.1.7",
8
9
  "source": "./",
9
10
  "description": "Check domains, compare registrar prices, and screen product names."
10
11
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "domain-hound",
3
3
  "displayName": "Domain Hound",
4
- "version": "0.1.5",
4
+ "version": "0.1.7",
5
5
  "description": "Check domain availability and prices, and screen product names, from your AI assistant.",
6
6
  "author": {
7
7
  "name": "Lars Hvinden"
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Find a startup name and a domain you can actually buy
2
2
 
3
- Domain Hound checks domain availability, first-year and renewal prices, app names, trademarks and social handles from Claude Code, Codex or any MCP client. It runs locally and leaves checkout to you.
3
+ Domain Hound checks domain availability, first-year and renewal prices, app names, trademarks and social handles from Claude Code, Codex or any MCP client. It runs locally. Connect your Spaceship account to quote a domain, buy it with your approval, and set up DNS.
4
4
 
5
- ![Live Domain Hound results with dated registration and renewal prices](assets/readme-search.png)
5
+ ![Live Domain Hound results with completed app checks and dated upfront and renewal prices](assets/readme-search.png)
6
6
 
7
7
  ## Install
8
8
 
@@ -41,11 +41,12 @@ Then ask, for example: “Is lanternbay.com available?”, “Find a name for my
41
41
 
42
42
  - **Domains:** registry RDAP or WHOIS for fourteen endings by default (.com, .ai, .io, .me, .co, .dev, .app, .si, .so, .no, .net, .org, .xyz, .tech) and, on request, .sh, .gg, .inc, .studio, .se, .dk, .de, .uk, .co.uk and .eu. A domain is never called free without a registry or shop answer.
43
43
  - **Prices:** first payment, renewal and three-year cost from first-party registrar price lists, each with its date and label; renewal jumps and premium risk are flagged.
44
- - **Trademarks:** live US marks (USPTO), with search links for the EU, WIPO and Norway.
44
+ - **Trademarks:** live US marks (USPTO). EU (EUIPO) and Norwegian (Patentstyret) marks too when you set their free keys; otherwise, and for WIPO, search links to check yourself. Exact and near-identical live marks in the relevant classes (9, 35 and 42 for software) count the same at every office.
45
+ - **Meaning:** names that are, contain or sound like a rude word in 14 languages get a note and Check first, never Avoid. Word lists: [LDNOOBW](https://github.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words), © Shutterstock, CC BY 4.0, adapted (see `clis/domain-check/meaning-words.LICENSE.txt`).
45
46
  - **Apps and rivals:** same-name iOS and Android apps, companies, Wikidata entities and live sites, weighed by their traction.
46
47
  - **Handles:** GitHub, npm and Bluesky through their public APIs; YouTube, X, Instagram, TikTok, Facebook, LinkedIn and PyPI as links to check yourself. Each handle reads Taken, No public profile found, or Check yourself.
47
48
 
48
- Registry answers and prices cover every name. Trademark, app and rival checks cover the first five names. Public handle checks start after the name screen for the top three. A repeat lookup can collect the completed checks.
49
+ Registry answers and prices cover every name. Trademark, app and rival checks cover the first five. Slow checks and public handles for the top three fill in the same results page after the first answer. A three-year savings line appears when the pick beats the middle price from at least three dated registrar lists.
49
50
 
50
51
  The default install checks the registry and shows dated list prices. For a confirmed price, set `DOMAIN_HOUND_SPACESHIP_KEY` and `DOMAIN_HOUND_SPACESHIP_SECRET` (Spaceship permission `domains:read`), or `DOMAIN_HOUND_DYNADOT_KEY` (a production API key). Dynadot gives its production key account-wide access. Domain Hound only uses it to search. It shows premium pricing when it has a quote and points you to the shop when it has a premium signal without a price.
51
52
 
@@ -59,20 +60,90 @@ For the optional browser fallback, run `npm install domain-hound playwright && n
59
60
  - [Find an available startup name](https://domainhound.dev/guides/find-an-available-startup-name/)
60
61
  - [Check whether an app name is taken](https://domainhound.dev/guides/is-my-app-name-available/)
61
62
 
62
- ## Tools
63
+ Use `check_domains` for one exact domain or up to 20 names or domains. Use `triage_names` to screen a short list or a name you already have. Ask for `naming_method` to see how a shortlist is generated.
63
64
 
64
- - `check_domains` checks one name or exact domain, or up to 20 at once. A bare name checks fourteen endings. The first lookup on a fresh install shows the list prices bundled with the package, labelled with their date, while the local price list refreshes in the background.
65
- - `triage_names` screens names against public domain, trademark, app, company, and handle data.
66
- - `naming_method` gives your assistant a recipe for generating and screening new names.
65
+ Completed lookups save an HTML page and a Markdown copy in `~/.domain-hound/results/`. The page lists prices, availability and sources for each ending checked. On macOS, naming and batch results open in the background. Windows and Wayland request a background open where the desktop supports it. Exact checks and watch results stay in chat with a file link. Set `DOMAIN_HOUND_OPEN=off` on the MCP server to keep every page closed.
66
+
67
+ ## Share
68
+
69
+ Use **Share** on the results page to send up to five names. The link carries the names, checked endings, verdicts, prices and check time after the `#`. The browser reads that part locally. Your brief and notes stay out of the link. Anyone with the full link can read the shortlist.
70
+
71
+ ## Taken names
72
+
73
+ - `taken_domain_dossier` checks the registry record, website and public Atom listings. It shows sources, up to three priced alternatives with a quick name screen, and an inquiry draft when useful. Other marketplaces have manual links. The draft stays in the result.
67
74
  - `watch_domain` checks the registry, expiry and website. To start a free watch, give your assistant the email it should use. Confirm the watch in your inbox. Optional news requires a separate choice in that confirmation.
68
75
 
69
- Completed lookups save an HTML page and a Markdown copy in `~/.domain-hound/results/`. The page lists prices, availability and sources for each ending checked. On macOS, naming and batch results open in the background. Windows and Wayland request a background open where the desktop supports it. Exact checks and watch results stay in chat with a file link. Set `DOMAIN_HOUND_OPEN=off` on the MCP server to keep every page closed.
76
+ ## Buy and set up
77
+
78
+ Get a Spaceship price, buy within your limits, and set up DNS in your own account.
79
+
80
+ Create a key in Spaceship's API Manager. Use `domains:read` for quotes. Add `dnsrecords:read` and `dnsrecords:write` for DNS. Store the key and secret in the macOS Keychain. Each command prompts for a value.
81
+
82
+ ```sh
83
+ security add-generic-password -U -s domain-hound -a spaceship-key -w
84
+ security add-generic-password -U -s domain-hound -a spaceship-secret -w
85
+ ```
86
+
87
+ Or set `DOMAIN_HOUND_SPACESHIP_KEY` and `DOMAIN_HOUND_SPACESHIP_SECRET` for the MCP server. Never paste the secret into chat.
88
+
89
+ - `quote_domain` reads the live price: the exact upfront amount for the shortest term (two years for .ai), the exact renewal amount, premium status and a fresh registry check. The quote expires in 10 minutes.
90
+ - `buy_domain` needs that quote and a max you agreed to. It checks the price again and stops on any change. It stops when the quote is above your max or above `DOMAIN_HOUND_MAX_USD` (default $30). Only you can raise that cap, in the server settings. These limits apply to the quote: Spaceship sets the actual charge and does not guarantee the quoted price.
91
+ - `setup_domain` with `verify: true` writes nothing. It counts a purchase once the registry lists the domain and your Spaceship account holds it.
92
+ - `setup_domain` points the domain at your site and mail. Website: GitHub Pages, Vercel, Netlify, Cloudflare Pages (www only), a plain IP or a CNAME. Mail: Google Workspace, Microsoft 365, Fastmail, Proton, iCloud, or forwarding only. It lists every record it will add or remove before it changes anything, removes nothing without `replace: true`, keeps one SPF and one DMARC record, adds new records before it removes the ones they replace wherever DNS allows both at once, and reads the result back, including any partial change. Account-specific values, like a Vercel IP or a DKIM record, come from your provider, never from a guess. It needs Spaceship's own nameservers and never changes them.
93
+
94
+ **Default: Spaceship's own MCP.** `buy_domain` orders nothing itself. It tells your agent to preview the order with Spaceship's `domain_register` (WHOIS privacy and auto-renew on), stop if the preview is above the quote, your max or the cap, and show you Spaceship's full confirmation with the price and payment method. Only after your yes does the agent accept that exact preview; a new preview needs a new yes. If the outcome is unclear, it stops and sends you to your Spaceship account. Once Domain Hound verifies the purchase, the agent offers DNS setup. Connect Spaceship's MCP once and sign in when asked ([Spaceship's guide](https://www.spaceship.com/knowledgebase/ai-apps-supported-by-spaceship-and-spacemail-mcp/)):
95
+
96
+ ```sh
97
+ claude mcp add --transport http spaceship https://mcp.spaceship.com/mcp
98
+ codex mcp add spaceship --url https://mcp.spaceship.com/mcp
99
+ ```
100
+
101
+ **Opt-in: direct purchase.** Set `DOMAIN_HOUND_DIRECT_PURCHASE=1` and `DOMAIN_HOUND_SPACESHIP_CONTACT_ID` (your owner contact ID from Spaceship, 27 to 32 letters and digits) in the MCP server settings. No tool can set either. The key then also needs `domains:billing` and `asyncoperations:read`. Direct mode buys standard-price domains only, for the registry minimum term (one year; two for .ai), after your yes (`confirm: true`); without it you get a dry run. Each domain gets one order at most. If the result is unclear, Domain Hound never retries and sends you to your Spaceship account. In direct mode the price is checked seconds before the order, but Spaceship does not guarantee it: the amounts in the answer and the local receipt are quoted estimates, and your Spaceship account shows the actual charge.
102
+
103
+ If Spaceship refuses the order with a documented error (say, insufficient funds or an invalid contact), no order exists: Domain Hound says why and frees the domain for a fresh quote. A timeout, a server error or an answer it cannot read counts as unclear.
104
+
105
+ Each direct order keeps a claim file in `claims/` in the purchase folder. Its status is `"checking"` during the last price check (nothing sent yet), `"sending"` from just before the order, `"sent"` once Spaceship accepted it, and `"uncertain"` when the outcome is unknown. Any claim blocks another order. While one is `"checking"`, other calls answer that another purchase of this domain is in progress and name the file. If Domain Hound stopped mid-check and no purchase is running, stop every Domain Hound instance that uses that purchase folder, check that the file's status is exactly `"checking"`, move the file out of the folder, and get a fresh quote. Any other status means an order may exist: leave the file and check your Spaceship account.
106
+
107
+ To find the contact ID, use Spaceship's `contacts_list` or read `contacts.registrant` for a domain that already uses your owner contact. [MCP tools](https://www.spaceship.com/knowledgebase/spaceship-mcp/) · [Domain info API](https://docs.spaceship.dev/#tag/Domain-Management/operation/getDomainInfo)
108
+
109
+ **Last resort: checkout.** After a valid quote, the answer ends with a Spaceship checkout link, for when Spaceship's MCP cannot be used and nothing was submitted. Check the same term, price limits, privacy and auto-renew before you pay, then ask Domain Hound to verify and set up the domain. After an unclear order there is no checkout link: check your Spaceship account first.
110
+
111
+ Quotes, DNS plans, order claims and receipts stay in `~/.domain-hound/purchases/`. `DOMAIN_HOUND_PURCHASE_DIR` moves them; a relative path is resolved once, when the server starts.
112
+
113
+ ## Privacy and lookup hosts
114
+
115
+ Domain Hound uses your brief locally. Availability queries use registries and DNS. The name screen shares candidate names with public evidence sources. Catalog downloads carry no candidate name. With shop keys configured, one pick per lookup goes to the shop for a quote by default. Set `DOMAIN_HOUND_SHOP_QUOTES=top4` to include up to three runners-up. Clicking a results link to a shop or search site sends the name in that link.
116
+
117
+ | Host or service | What the lookup sends |
118
+ | --- | --- |
119
+ | `data.iana.org`; `whois.iana.org` | RDAP routing table request with no name; WHOIS referral request with only the ending. |
120
+ | The DNS resolvers configured on your device, authoritative DNS servers, and the registry’s RDAP or WHOIS host. RDAP routes come from IANA or use `rdap.registry.co`, `rdap.identitydigital.services`, `rdap.norid.no` and `rdap.nic.so`. WHOIS for .ai, .io and .me goes to `whois.nic.ai`, `whois.nic.io` and `whois.nic.me`. | Candidate or rival domain. A DNS routing query can contain just an ending or a nameserver hostname. Registry referrals and redirects can select another registry host. |
121
+ | Candidate website and public hosts it redirects to | The domain in a homepage request; an onward request can include a URL provided by that website. |
122
+ | `tmsearch.uspto.gov` | Candidate name, spelling variants and relevant trademark class numbers. |
123
+ | `api.euipo.europa.eu` and `euipo.europa.eu` (sandbox: `api-sandbox.euipo.europa.eu` and `auth-sandbox.euipo.europa.eu`) | With EUIPO credentials, the token host gets the client ID and secret. The search host gets the client ID, access token and candidate spellings. |
124
+ | `api.patentstyret.no` | With a subscription key, the Norwegian office gets the key and candidate spellings. |
125
+ | `mcp.atom.com` | The taken domain for an exact listing lookup. The buyer's ceiling stays local. |
126
+ | `itunes.apple.com`, `play.google.com` | Candidate name for US store search; Google Play may also get the ID of a matched app. |
127
+ | `www.wikidata.org`, `www.google.com`, `trends.google.com`, `data.brreg.no` | Candidate name; Wikidata also gets entity or class IDs for matches. |
128
+ | `api.github.com`, `registry.npmjs.org`, `public.api.bsky.app` | Candidate name or handle, handle variants and public controls. With a GitHub token configured, it goes only to GitHub. |
129
+ | `www.sec.gov`, `tranco-list.eu` | Public company and site lists with no candidate name. |
130
+ | `index.commoncrawl.org` | Rival domain for a public crawl count. The index list request has no name. |
131
+ | `api.porkbun.com`, `www.dynadot.com`, `www.gandi.net` | Public price catalogs, sometimes filtered by ending. The standalone exact-price CLI may also ask `data.norges-bank.no` for USD/NOK with no name. |
132
+ | `spaceship.dev`, `api.dynadot.com`; `api.porkbun.com` for the standalone exact-price CLI | With configured credentials, the selected domain and the relevant shop credentials. The Spaceship API also gets quote and purchase details, the owner contact ID on a direct order, or DNS records for approved setup. |
133
+ | `mcp.spaceship.com` | When you use Spaceship's own MCP, your assistant passes the domain and the registration options to Spaceship. |
134
+ | `www.spaceship.com`, `www.namecheap.com`, `www.dynadot.com`, `www.cloudflare.com` | Optional live browser check sends only the selected domain. Storefront pages can load supporting assets. A manual Spaceship price refresh opens its public catalog without a candidate name. |
135
+ | `api.search.brave.com` or `google.serper.dev` | Candidate search when you configure a search provider. |
136
+
137
+ Results and caches are local. The share viewer receives its shortlist from the URL fragment in the browser. The site receives the page request without that fragment.
138
+
139
+ Submitting a watch sends the domain, supplied email, optional name and news choice to `domainhound-alerts.domainhound.workers.dev`. An agent’s yes highlights the news choice. The confirmation click records whether you want it. Result pages omit your supplied email and name.
70
140
 
71
- ## Privacy
141
+ ## Optional EU and Norwegian trademark keys
72
142
 
73
- Lookups need no Domain Hound account. They send the relevant name or domain to public sources. Domain searches use IANA and registry RDAP/WHOIS, public DNS, and public registrar pricing. When configured, the client sends selected domains to the Spaceship or Dynadot API for a quote. The optional browser check opens a registrar’s public search page. Name screening may also query the USPTO, Apple App Store, Google Play, Google Search and Trends, Wikidata, public company registries, the GitHub, npm and Bluesky public APIs, Tranco, Common Crawl, and candidate websites. Other social platforms are only linked, never queried. If you configure a search provider via environment variables, queries can also go to Brave Search or Serper. Results may be cached locally.
143
+ - **EUIPO.** Create an EUIPO account, register an app and subscribe to Trademark Search. Production access requires approval. Set `DOMAIN_HOUND_EUIPO_CLIENT_ID` and `DOMAIN_HOUND_EUIPO_CLIENT_SECRET` for the local CLI or MCP server. Set `DOMAIN_HOUND_EUIPO_SANDBOX=1` to use sandbox data. [EUIPO setup](https://dev.euipo.europa.eu/getting-started)
144
+ - **Patentstyret.** Create a developer account, subscribe to the open data product that includes the MCP endpoint, and set `DOMAIN_HOUND_PATENTSTYRET_KEY` for the local CLI or MCP server. [Patentstyret setup](https://developer.patentstyret.no/docs-get-access)
74
145
 
75
- Submitting a watch sends the domain, supplied email, optional name and news choice to the Domain Hound watch service. An agent’s yes highlights the news choice. The confirmation click records whether you want it. Result pages omit your supplied email and name.
146
+ Without keys, or when an office returns an incomplete answer, the results page links to the office's manual search. WIPO is always a manual link.
76
147
 
77
148
  ## Daily checks
78
149
 
@@ -80,7 +151,7 @@ Run `node scripts/canary.mjs` to check live registries, the Spotify name screen,
80
151
 
81
152
  ## Releases
82
153
 
83
- `.github/workflows/publish.yml` publishes a matching `v*` version tag to npm with Trusted Publishing and provenance. It then waits until the npm CDN serves the new tarball, runs `npx -y domain-hound@<version>` as a `tools/list` smoke test, and publishes `server.json` to the MCP Registry. The registry step needs the repository secret `MCP_REGISTRY_PRIVATE_KEY` (the hex Ed25519 private key whose public key is served at `https://domainhound.dev/.well-known/mcp-registry-auth`); without it the run ends with a notice and nothing else changes. Do not open the plain tarball URL before the workflow reports it live: the CDN caches a 404. After the first manual publish, open the package settings on npm and add GitHub Actions as a trusted publisher. Use owner `lars-hv`, repository `domain-hound`, workflow `publish.yml`, and allow `npm publish`. Use the workflow for the next unpublished version. [npm Trusted Publishing setup](https://docs.npmjs.com/trusted-publishers/)
154
+ `.github/workflows/publish.yml` publishes a matching `v*` version tag to npm with Trusted Publishing and provenance. It then waits until `npm view domain-hound@<version>`, run with a new empty npm cache each time, lists the version three times in a row (up to 15 minutes), runs `npx -y domain-hound@<version>` as a `tools/list` smoke test (retried with a fresh cache for up to 10 minutes while npx still reports ETARGET or E404, because npx can see staler package metadata than `npm view`), and publishes `server.json` to the MCP Registry only after that smoke passes. The registry step needs the repository secret `MCP_REGISTRY_PRIVATE_KEY` (the hex Ed25519 private key whose public key is served at `https://domainhound.dev/.well-known/mcp-registry-auth`); without it the run ends with a notice and nothing else changes. Do not open the plain tarball URL before the smoke test passes: the CDN caches a 404. After the first manual publish, open the package settings on npm and add GitHub Actions as a trusted publisher. Use owner `lars-hv`, repository `domain-hound`, workflow `publish.yml`, and allow `npm publish`. Use the workflow for the next unpublished version. [npm Trusted Publishing setup](https://docs.npmjs.com/trusted-publishers/)
84
155
 
85
156
  To refresh the bundled list prices before a release, run `npm run snapshot-prices`. It copies only the local `prices.json` price list.
86
157
 
Binary file
@@ -0,0 +1,78 @@
1
+ import { anySignal } from './cache.mjs';
2
+
3
+ export const atomSearchUrl = 'https://mcp.atom.com/mcp';
4
+ export const atomSearchDocs = 'https://www.atom.com/atom-mcp-server/docs';
5
+
6
+ // Atom documents this particular MCP tool as public and read-only.
7
+ const searchName = 'search_brandable_domains';
8
+ const maxResponseBytes = 96 * 1024;
9
+
10
+ async function readResult(response) {
11
+ if (!response.ok || !response.headers.get('content-type')?.includes('application/json')) {
12
+ await response.body?.cancel();
13
+ return null;
14
+ }
15
+ const reader = response.body?.getReader();
16
+ if (!reader) return null;
17
+ const decoder = new TextDecoder();
18
+ let bytes = 0;
19
+ let body = '';
20
+ try {
21
+ for (;;) {
22
+ const { done, value } = await reader.read();
23
+ if (done) break;
24
+ bytes += value.length;
25
+ if (bytes > maxResponseBytes) return null;
26
+ body += decoder.decode(value, { stream: true });
27
+ }
28
+ const reply = JSON.parse(body + decoder.decode());
29
+ if (reply.id !== 1 || reply.result?.isError) return null;
30
+ const result = reply.result?.structuredContent;
31
+ return result?.success === true && Array.isArray(result.results) ? result.results : null;
32
+ } finally {
33
+ await reader.cancel().catch(() => {});
34
+ }
35
+ }
36
+
37
+ export function exactAtomListingUrl(value, domain) {
38
+ if (typeof value !== 'string' || value.length > 320) return null;
39
+ let url;
40
+ try { url = new URL(value); } catch { return null; }
41
+ if (url.origin !== 'https://www.atom.com' || url.username || url.password || url.search || url.hash) return null;
42
+ const path = url.pathname.toLowerCase();
43
+ return path === '/name/' + domain || (domain.endsWith('.com') && path === '/name/' + domain.slice(0, -4))
44
+ ? url.href : null;
45
+ }
46
+
47
+ export async function lookupAtomListing(domain, {
48
+ fetcher = globalThis.fetch, timeoutMs = 8500, signal, now = () => new Date(),
49
+ } = {}) {
50
+ const result = (status, fields) => ({ status, url: atomSearchUrl, checkedAt: now().toISOString(), ...fields });
51
+ try {
52
+ const response = await fetcher(atomSearchUrl, {
53
+ method: 'POST',
54
+ redirect: 'error',
55
+ credentials: 'omit',
56
+ signal: anySignal([signal, AbortSignal.timeout(timeoutMs)].filter(Boolean)),
57
+ headers: { 'content-type': 'application/json', accept: 'application/json, text/event-stream' },
58
+ body: JSON.stringify({
59
+ jsonrpc: '2.0', id: 1, method: 'tools/call',
60
+ params: { name: searchName, arguments: { concept: domain, page_size: 10 } },
61
+ }),
62
+ });
63
+ const rows = await readResult(response);
64
+ if (!rows) return result('unavailable');
65
+ const matches = rows.filter(row => typeof row?.domain === 'string' && row.domain.toLowerCase() === domain);
66
+ for (const row of matches) {
67
+ const listingUrl = exactAtomListingUrl(row.url, domain);
68
+ if (!listingUrl) continue;
69
+ const price = Number.isFinite(row.price) && row.price > 0 && row.price <= Number.MAX_SAFE_INTEGER / 100
70
+ && typeof row.currency === 'string' && /^[A-Z]{3}$/.test(row.currency)
71
+ ? { amount: row.price, currency: row.currency } : null;
72
+ return result('listed', { listingUrl, price });
73
+ }
74
+ return result(matches.length ? 'unavailable' : 'no-exact-result');
75
+ } catch {
76
+ return result('unavailable');
77
+ }
78
+ }
@@ -2,6 +2,7 @@ import { Resolver } from 'node:dns/promises';
2
2
  import { get as httpGet } from 'node:http';
3
3
  import { get as httpsGet } from 'node:https';
4
4
  import { BlockList, isIP } from 'node:net';
5
+ import { setTimeout as delay } from 'node:timers/promises';
5
6
  import { anySignal } from './cache.mjs';
6
7
 
7
8
  const maxBytes = 200_000;
@@ -17,31 +18,50 @@ for (const [address, prefix] of [['2001::', 23], ['2001:db8::', 32], ['2002::',
17
18
  const globalIpv6 = new BlockList();
18
19
  globalIpv6.addSubnet('2000::', 3, 'ipv6');
19
20
 
20
- function publicAddress({ address, family }) {
21
+ export function publicAddress({ address, family }) {
21
22
  return family === 4 ? !restricted.check(address)
22
23
  : globalIpv6.check(address, 'ipv6') && !restricted.check(address, 'ipv6');
23
24
  }
24
25
 
25
- function lookupPublic(signal) {
26
+ const timeoutCodes = new Set(['ETIMEOUT', 'ETIMEDOUT', 'ECANCELLED', 'ABORT_ERR']);
27
+ // A check that ran out of time is unknown, never "no site": a slow server is not a missing one.
28
+ const unanswered = { state: 'unknown', why: 'no answer in time' };
29
+
30
+ export function lookupPublic(signal) {
31
+ const hosts = new Map();
26
32
  return (host, options, done) => {
27
33
  if (signal.aborted) return done(new Error('Site lookup timed out'));
28
- const resolver = new Resolver({ timeout: 950, tries: 1 });
29
- const cancel = () => resolver.cancel();
30
- signal.addEventListener('abort', cancel, { once: true });
31
- const families = options.family ? [options.family] : [4, 6];
32
- Promise.all(families.map(async family => {
33
- const addresses = await (family === 4 ? resolver.resolve4(host) : resolver.resolve6(host)).catch(() => []);
34
- return addresses.map(address => ({ address, family })).filter(publicAddress);
35
- })).then(results => {
36
- signal.removeEventListener('abort', cancel);
37
- const usable = results.flat();
38
- if (!usable.length) done(new Error('No public address'));
39
- else if (options.all) done(null, usable);
34
+ const key = host + ':' + (options.family || 0);
35
+ if (!hosts.has(key)) hosts.set(key, resolvePublic(host, options.family, signal));
36
+ hosts.get(key).then(usable => {
37
+ if (options.all) done(null, usable);
40
38
  else done(null, usable[0].address, usable[0].family);
41
- });
39
+ }, done);
42
40
  };
43
41
  }
44
42
 
43
+ async function resolvePublic(host, family, signal) {
44
+ const resolver = new Resolver({ timeout: 950, tries: 1 });
45
+ const cancel = () => resolver.cancel();
46
+ signal.addEventListener('abort', cancel, { once: true });
47
+ const families = family ? [family] : [4, 6];
48
+ const errors = [];
49
+ const results = await Promise.all(families.map(async family => {
50
+ const addresses = await (family === 4 ? resolver.resolve4(host) : resolver.resolve6(host)).catch(error => {
51
+ errors.push(error?.code);
52
+ return [];
53
+ });
54
+ return addresses.map(address => ({ address, family })).filter(publicAddress);
55
+ })).finally(() => signal.removeEventListener('abort', cancel));
56
+ const usable = results.flat();
57
+ if (usable.length) return usable;
58
+ // An NXDOMAIN applies to the hostname, even if the other address-family query did not answer.
59
+ if (!errors.includes('ENOTFOUND') && errors.some(code => timeoutCodes.has(code))) {
60
+ throw Object.assign(new Error('DNS lookup timed out'), { code: 'ETIMEOUT' });
61
+ }
62
+ throw new Error('No public address');
63
+ }
64
+
45
65
  const saleHosts = ['sedo.com', 'sedoparking.com', 'afternic.com', 'dan.com', 'hugedomains.com', 'atom.com', 'squadhelp.com'];
46
66
  const parkingHosts = ['parkingcrew.net', 'bodis.com', 'above.com', 'parklogic.com', 'parked.com', 'parking-page.net'];
47
67
  const hasHost = (host, choices) => choices.some(name => host === name || host.endsWith('.' + name));
@@ -95,10 +115,11 @@ export function classifyComSite({ url, status, contentType, lastModified, body =
95
115
  return { state: 'live', ...(title && { title }) };
96
116
  }
97
117
 
98
- function load(url, signal) {
118
+ function load(url, signal, lookup) {
99
119
  return new Promise((resolve, reject) => {
100
120
  const request = url.protocol === 'https:' ? httpsGet : httpGet;
101
- request(url, { lookup: lookupPublic(signal), signal, agent: false, headers: { accept: 'text/html, application/xhtml+xml' } }, response => {
121
+ request(url, { lookup, signal, agent: false, autoSelectFamilyAttemptTimeout: 700,
122
+ headers: { Accept: 'text/html, application/xhtml+xml', 'User-Agent': 'DomainHound/0.1 (+https://domainhound.dev)' } }, response => {
102
123
  const { statusCode: status, headers } = response;
103
124
  const contentType = headers['content-type'];
104
125
  const location = [301, 302, 303, 307, 308].includes(status) ? headers.location : null;
@@ -127,33 +148,51 @@ function load(url, signal) {
127
148
  });
128
149
  }
129
150
 
130
- async function visit(url, signal, detailed) {
151
+ async function visit(url, signal, detailed, lookup) {
131
152
  try {
132
153
  for (let hops = 0; hops <= 5; hops++) {
133
154
  if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password || url.port ||
134
155
  isIP(url.hostname) || url.hostname.startsWith('[') || !url.hostname.includes('.')) break;
135
- const response = await load(url, signal);
156
+ const obvious = classifyComSite({ url }, detailed);
157
+ if (obvious.state !== 'no-site') return obvious;
158
+ const response = await load(url, signal, lookup);
136
159
  if (!response.location) return classifyComSite({ url, ...response }, detailed);
137
160
  url = new URL(response.location, url);
138
161
  }
139
- } catch { /* The site did not respond within the public lookup. */ }
162
+ } catch (error) {
163
+ // The site did not respond within the public lookup. A refused or missing host is no site; a timeout is unknown.
164
+ if (signal.aborted || timeoutCodes.has(error?.code) || error?.name === 'AbortError') return { ...unanswered };
165
+ }
140
166
  return { state: 'no-site' };
141
167
  }
142
168
 
169
+ const settled = site => site.state !== 'no-site' && site.state !== 'unknown';
170
+
143
171
  export async function checkDomainSite(domain, timeout = 5000, detailed = false) {
144
- if (!/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.(?:com|ai|io|app|dev|me|si|co|no|so)$/.test(domain)) return { state: 'no-site' };
172
+ if (!/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.[a-z]{2,}(?:\.[a-z]{2,})?$/.test(domain)) return { state: 'no-site' };
173
+ const deadline = performance.now() + timeout;
174
+ const first = await probeSite(domain, Math.min(timeout, 4200), detailed);
175
+ if (first.state !== 'unknown' || timeout < 2000 || deadline - performance.now() < 700) return first;
176
+ await delay(300);
177
+ return probeSite(domain, Math.max(1, Math.floor(deadline - performance.now())), detailed);
178
+ }
179
+
180
+ async function probeSite(domain, timeout, detailed) {
145
181
  const controller = new AbortController();
146
182
  const signal = anySignal([controller.signal, AbortSignal.timeout(timeout)]);
147
- const https = visit(new URL('https://' + domain), signal, detailed);
183
+ const lookup = lookupPublic(signal);
184
+ const https = visit(new URL('https://' + domain), signal, detailed, lookup);
148
185
  if (/\.(?:app|dev)$/.test(domain)) return https;
149
- const http = visit(new URL('http://' + domain), signal, detailed);
186
+ const http = visit(new URL('http://' + domain), signal, detailed, lookup);
150
187
  const first = await Promise.race([http, https]);
151
- if (first.state !== 'no-site') {
188
+ if (settled(first)) {
152
189
  controller.abort();
153
190
  return first;
154
191
  }
155
192
  const [secure, plain] = await Promise.all([https, http]);
156
- return secure.state === 'no-site' ? plain : secure;
193
+ if (settled(secure)) return secure;
194
+ if (settled(plain)) return plain;
195
+ return secure.state === 'unknown' || plain.state === 'unknown' ? { ...unanswered } : { state: 'no-site' };
157
196
  }
158
197
 
159
198
  export const checkComSite = checkDomainSite;
@@ -401,7 +401,10 @@ export async function confirmDomain(shopValue, domain, options = {}) {
401
401
  const deadline = Math.min(options.deadline ?? Infinity, start + budget);
402
402
  const tld = domain.split('.').at(-1);
403
403
  const order = shopOrder(shop, tld, options.unsupported).slice(0, options.oneShop ? 1 : 2);
404
- const run = usePage => usePage(domain, check => confirmAtShops(domain, check, deadline, order));
404
+ const run = usePage => usePage(domain, check => confirmAtShops(domain, (id, until) => {
405
+ options.onShopQuery?.(id, domain);
406
+ return check(id, until);
407
+ }, deadline, order));
405
408
  const settled = options.usePage ? await run(options.usePage) : await withShopPages(deadline, run, options);
406
409
  const result = formatResult(start, domain, shop, settled.shop ?? shop, settled.result ?? settled, now);
407
410
  if (result.status === 'confirmed') await writeCache(directory, filename, result).catch(() => {});
@@ -520,8 +523,9 @@ async function postJson(fetcher, url, body, headers, timeout) {
520
523
  return response.json();
521
524
  }
522
525
 
523
- async function spaceshipQuotes(domains, { env, fetcher, timeout, now }) {
526
+ async function spaceshipQuotes(domains, { env, fetcher, timeout, now, onShopQuery }) {
524
527
  const headers = { 'X-API-Key': env.DOMAIN_HOUND_SPACESHIP_KEY.trim(), 'X-API-Secret': env.DOMAIN_HOUND_SPACESHIP_SECRET.trim() };
528
+ for (const domain of domains) onShopQuery?.('spaceship', domain);
525
529
  const [availability, pricing] = await Promise.all([
526
530
  postJson(fetcher, spaceshipApi + 'available', { domains }, headers, timeout),
527
531
  postJson(fetcher, spaceshipApi + 'pricing/query', { domains }, headers, timeout).catch(() => null),
@@ -529,7 +533,7 @@ async function spaceshipQuotes(domains, { env, fetcher, timeout, now }) {
529
533
  return parseSpaceshipApi(availability, pricing, domains, now);
530
534
  }
531
535
 
532
- async function dynadotQuotes(domains, { env, fetcher, timeout, now, listFor, deadline }) {
536
+ async function dynadotQuotes(domains, { env, fetcher, timeout, now, listFor, deadline, onShopQuery }) {
533
537
  const quotes = new Map();
534
538
  // A regular Dynadot account checks one domain per command and one request at a time.
535
539
  for (const domain of domains) {
@@ -538,6 +542,7 @@ async function dynadotQuotes(domains, { env, fetcher, timeout, now, listFor, dea
538
542
  const url = dynadotApi + '?' + new URLSearchParams({ key: env.DOMAIN_HOUND_DYNADOT_KEY.trim(), command: 'search',
539
543
  domain0: domain, show_price: '1', currency: 'USD' });
540
544
  try {
545
+ onShopQuery?.('dynadot', domain);
541
546
  const response = await fetcher(url, { redirect: 'error', signal: AbortSignal.timeout(wait), headers: { Accept: 'application/json' } });
542
547
  if (!response.ok) { await response.body?.cancel().catch(() => {}); continue; }
543
548
  const quote = parseDynadotSearch(await response.json(), domain, listFor(domain, 'dynadot'), now);
@@ -583,7 +588,7 @@ function combine(answers) {
583
588
 
584
589
  export async function lightConfirm(domains, {
585
590
  env = process.env, fetcher = globalThis.fetch, directory, now = new Date(), deadline = performance.now() + 3000,
586
- listFor = () => null,
591
+ listFor = () => null, onShopQuery,
587
592
  } = {}) {
588
593
  const folder = directory === undefined ? cacheDir : directory;
589
594
  const results = new Map();
@@ -597,7 +602,7 @@ export async function lightConfirm(domains, {
597
602
  const keyed = apiShops(env);
598
603
  const timeout = Math.min(apiTimeout, Math.floor(deadline - performance.now()));
599
604
  if (!pending.length || !keyed.length || timeout < 300) return results;
600
- const context = { env, fetcher, timeout, now, listFor, deadline };
605
+ const context = { env, fetcher, timeout, now, listFor, deadline, onShopQuery };
601
606
  const [spaceship, dynadot] = await Promise.all([
602
607
  keyed.includes('spaceship') ? spaceshipQuotes(pending, context).catch(() => new Map()) : new Map(),
603
608
  keyed.includes('dynadot') ? dynadotQuotes(pending, context) : new Map(),