domain-hound 0.1.3 → 0.1.5
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.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +34 -7
- package/assets/readme-search.png +0 -0
- package/clis/domain-check/company-search.mjs +1 -0
- package/clis/domain-check/handles.mjs +337 -0
- package/clis/domain-check/index.mjs +42 -11
- package/clis/domain-check/name-search.mjs +37 -11
- package/clis/domain-check/naming-method.mjs +3 -3
- package/clis/domain-check/price-catalog.mjs +20 -12
- package/clis/domain-check/price-snapshot.json +142 -10
- package/clis/domain-check/registry.mjs +110 -17
- package/clis/domain-check/traction.mjs +9 -6
- package/clis/domain-check/triage-sources.mjs +13 -52
- package/clis/domain-check/triage.mjs +134 -40
- package/display.mjs +7 -4
- package/package.json +21 -5
- package/plugin.json +2 -2
- package/results-style.mjs +62 -0
- package/results.mjs +447 -0
- package/server.json +3 -12
- package/server.mjs +149 -40
- package/watch.mjs +93 -0
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Find a startup name and a domain you can actually buy
|
|
2
2
|
|
|
3
|
-
|
|
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.
|
|
4
|
+
|
|
5
|
+

|
|
4
6
|
|
|
5
7
|
## Install
|
|
6
8
|
|
|
7
9
|
Requires Node.js 20 or later.
|
|
8
10
|
|
|
9
|
-
### Install
|
|
10
|
-
|
|
11
11
|
**Claude Code**
|
|
12
12
|
|
|
13
13
|
```sh
|
|
@@ -35,19 +35,44 @@ Add this to the client’s MCP configuration for a local stdio server.
|
|
|
35
35
|
}
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
Then ask, for example: “Is lanternbay.com available?”, “Find a name for my meeting-room booking app” or “Is the app name Quiet Otter taken?”
|
|
39
|
+
|
|
40
|
+
## What it checks
|
|
41
|
+
|
|
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
|
+
- **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.
|
|
45
|
+
- **Apps and rivals:** same-name iOS and Android apps, companies, Wikidata entities and live sites, weighed by their traction.
|
|
46
|
+
- **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
|
+
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
|
+
|
|
38
50
|
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.
|
|
39
51
|
|
|
52
|
+
GitHub allows 60 anonymous API requests an hour. To check GitHub handles more often, set `DOMAIN_HOUND_GITHUB_TOKEN` to a token with no scopes; Domain Hound sends it only to `api.github.com`.
|
|
53
|
+
|
|
40
54
|
For the optional browser fallback, run `npm install domain-hound playwright && npx playwright install chromium` in a project directory and start your MCP client there. Ask for a live shop check to set the `confirm` tool flag, or use `--confirm` with the CLI.
|
|
41
55
|
|
|
56
|
+
## Guides
|
|
57
|
+
|
|
58
|
+
- [Check domain availability](https://domainhound.dev/guides/how-to-check-domain-availability/)
|
|
59
|
+
- [Find an available startup name](https://domainhound.dev/guides/find-an-available-startup-name/)
|
|
60
|
+
- [Check whether an app name is taken](https://domainhound.dev/guides/is-my-app-name-available/)
|
|
61
|
+
|
|
42
62
|
## Tools
|
|
43
63
|
|
|
44
|
-
- `check_domains` checks one name or exact domain, or up to 20 at once. A bare name checks
|
|
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.
|
|
45
65
|
- `triage_names` screens names against public domain, trademark, app, company, and handle data.
|
|
46
66
|
- `naming_method` gives your assistant a recipe for generating and screening new names.
|
|
67
|
+
- `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
|
+
|
|
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.
|
|
47
70
|
|
|
48
71
|
## Privacy
|
|
49
72
|
|
|
50
|
-
|
|
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.
|
|
74
|
+
|
|
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.
|
|
51
76
|
|
|
52
77
|
## Daily checks
|
|
53
78
|
|
|
@@ -55,10 +80,12 @@ Run `node scripts/canary.mjs` to check live registries, the Spotify name screen,
|
|
|
55
80
|
|
|
56
81
|
## Releases
|
|
57
82
|
|
|
58
|
-
`.github/workflows/publish.yml` publishes a matching `v*` version tag to npm with Trusted Publishing and provenance. 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/)
|
|
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/)
|
|
59
84
|
|
|
60
85
|
To refresh the bundled list prices before a release, run `npm run snapshot-prices`. It copies only the local `prices.json` price list.
|
|
61
86
|
|
|
62
87
|
Run `npm run build-mcpb` on a build machine with Node.js, npm, and `zip`. It writes a standalone bundle to `dist/domain-hound-<version>.mcpb` and prints its SHA-256 for the MCPB entry in `server.json`.
|
|
63
88
|
|
|
89
|
+
Website: [domainhound.dev](https://domainhound.dev) · [Privacy](https://domainhound.dev/privacy/)
|
|
90
|
+
|
|
64
91
|
[MIT license](LICENSE)
|
|
Binary file
|
|
@@ -49,6 +49,7 @@ export async function searchNorwegianCompanies(name, input, options) {
|
|
|
49
49
|
const match = companyMatch(letters(name), row.navn);
|
|
50
50
|
if (match) matches.set(row.organisasjonsnummer, {
|
|
51
51
|
name: compactText(row.navn, 65), match, url: 'https://virksomhet.brreg.no/nb/oppslag/enheter/' + row.organisasjonsnummer,
|
|
52
|
+
...(Number.isSafeInteger(row.antallAnsatte) && row.antallAnsatte > 0 && { employees: row.antallAnsatte }),
|
|
52
53
|
});
|
|
53
54
|
}
|
|
54
55
|
}
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { randomInt } from 'node:crypto';
|
|
2
|
+
import { anySignal, cacheDir, readCache, writeCache } from './cache.mjs';
|
|
3
|
+
|
|
4
|
+
// Social handles. Three states only, never "free": a missing public profile does not mean the handle can be had.
|
|
5
|
+
export const handleStates = {
|
|
6
|
+
taken: 'Taken',
|
|
7
|
+
'not-found': 'No public profile found',
|
|
8
|
+
check: 'Check yourself',
|
|
9
|
+
};
|
|
10
|
+
const hour = 3_600_000;
|
|
11
|
+
// A taken handle is reused for a week, a missing one for an hour. "Check yourself" is never cached.
|
|
12
|
+
export const handleLifetime = { taken: 7 * 24 * hour, 'not-found': hour };
|
|
13
|
+
// One platform's whole run (its two controls, the exact handles and any variants) shares this budget.
|
|
14
|
+
export const platformBudgetMs = 2000;
|
|
15
|
+
export const handleVariants = name => ['get' + name, name + 'app', name + 'hq'];
|
|
16
|
+
const userAgent = 'DomainHound/0.1 (https://domainhound.dev)';
|
|
17
|
+
const githubHoldFile = 'handles-github-hold.json';
|
|
18
|
+
|
|
19
|
+
const label = value => /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(value);
|
|
20
|
+
const syntheticLabel = (length, pick = randomInt) => 'zq' + Array.from({ length }, () => String.fromCharCode(97 + pick(26))).join('');
|
|
21
|
+
|
|
22
|
+
async function readStrictJson(response) {
|
|
23
|
+
if (!/^application\/(?:[\w.+-]+\+)?json\b/i.test(response.headers.get('content-type') ?? '')) {
|
|
24
|
+
await response.body?.cancel().catch(() => {});
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const text = await response.text();
|
|
28
|
+
if (text.length > 512 * 1024) return null;
|
|
29
|
+
try { return JSON.parse(text); } catch { return null; }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Each automatic check uses a documented public API that needs no login. Anything the parser does not recognise is
|
|
33
|
+
// "check yourself".
|
|
34
|
+
const apis = {
|
|
35
|
+
// GitHub REST "Get a user" (users and organizations): https://docs.github.com/en/rest/users/users#get-a-user
|
|
36
|
+
GitHub: {
|
|
37
|
+
valid: handle => /^[a-z0-9](?:[a-z0-9]|-(?=[a-z0-9])){0,38}$/.test(handle),
|
|
38
|
+
url: handle => 'https://api.github.com/users/' + handle,
|
|
39
|
+
headers: { Accept: 'application/vnd.github+json', 'X-GitHub-Api-Version': '2022-11-28' },
|
|
40
|
+
read: async (response, handle) => {
|
|
41
|
+
const data = await readStrictJson(response);
|
|
42
|
+
if (response.status === 200) {
|
|
43
|
+
return typeof data?.login === 'string' && data.login.toLowerCase() === handle
|
|
44
|
+
&& ['User', 'Organization'].includes(data.type) ? 'taken' : 'check';
|
|
45
|
+
}
|
|
46
|
+
if (response.status === 404) return data?.message === 'Not Found' ? 'not-found' : 'check';
|
|
47
|
+
return 'check';
|
|
48
|
+
},
|
|
49
|
+
controls: () => ({ taken: 'github', missing: syntheticLabel(28) }),
|
|
50
|
+
},
|
|
51
|
+
// npm registry package document: https://github.com/npm/registry/blob/main/docs/REGISTRY-API.md#getpackage
|
|
52
|
+
npm: {
|
|
53
|
+
valid: handle => handle.length <= 214,
|
|
54
|
+
url: handle => 'https://registry.npmjs.org/' + handle,
|
|
55
|
+
headers: { Accept: 'application/vnd.npm.install-v1+json' },
|
|
56
|
+
read: async (response, handle) => {
|
|
57
|
+
const data = await readStrictJson(response);
|
|
58
|
+
if (response.status === 200) return data?.name === handle ? 'taken' : 'check';
|
|
59
|
+
if (response.status === 404) return typeof data?.error === 'string' && /^not found$/i.test(data.error) ? 'not-found' : 'check';
|
|
60
|
+
return 'check';
|
|
61
|
+
},
|
|
62
|
+
controls: () => ({ taken: 'lodash', missing: syntheticLabel(24) }),
|
|
63
|
+
},
|
|
64
|
+
// Bluesky public AppView, com.atproto.identity.resolveHandle:
|
|
65
|
+
// https://docs.bsky.app/docs/api/com-atproto-identity-resolve-handle
|
|
66
|
+
Bluesky: {
|
|
67
|
+
valid: handle => handle.length >= 3 && handle.length <= 18,
|
|
68
|
+
identifier: handle => handle + '.bsky.social',
|
|
69
|
+
url: identifier => 'https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle?handle=' + encodeURIComponent(identifier),
|
|
70
|
+
headers: { Accept: 'application/json' },
|
|
71
|
+
read: async response => {
|
|
72
|
+
const data = await readStrictJson(response);
|
|
73
|
+
if (response.status === 200) return typeof data?.did === 'string' && /^did:(?:plc|web):[a-z0-9._:%-]+$/i.test(data.did) ? 'taken' : 'check';
|
|
74
|
+
if (response.status === 400) {
|
|
75
|
+
return data?.error === 'InvalidRequest' && /^unable to resolve handle$/i.test(String(data.message ?? '').trim()) ? 'not-found' : 'check';
|
|
76
|
+
}
|
|
77
|
+
return 'check';
|
|
78
|
+
},
|
|
79
|
+
// bsky.app is Bluesky's own account.
|
|
80
|
+
controls: () => ({ taken: 'bsky.app', missing: syntheticLabel(14) + '.bsky.social' }),
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// Display order (Lars, 2026-11-25): YouTube, X, Instagram, TikTok, Facebook, LinkedIn, then GitHub, npm, PyPI, Bluesky.
|
|
85
|
+
// YouTube, X, Instagram, TikTok, Facebook and LinkedIn have no public no-login lookup their terms allow: link only.
|
|
86
|
+
// PyPI is link only by decision.
|
|
87
|
+
export const handlePlatforms = [
|
|
88
|
+
{ id: 'YouTube', link: handle => 'https://www.youtube.com/@' + handle },
|
|
89
|
+
{ id: 'X', link: handle => 'https://x.com/' + handle },
|
|
90
|
+
{ id: 'Instagram', link: handle => 'https://www.instagram.com/' + handle + '/' },
|
|
91
|
+
{ id: 'TikTok', link: handle => 'https://www.tiktok.com/@' + handle },
|
|
92
|
+
{ id: 'Facebook', link: handle => 'https://www.facebook.com/' + handle },
|
|
93
|
+
{ id: 'LinkedIn', link: handle => 'https://www.linkedin.com/company/' + handle + '/' },
|
|
94
|
+
{ id: 'GitHub', link: handle => 'https://github.com/' + handle, auto: true },
|
|
95
|
+
{ id: 'npm', link: handle => 'https://www.npmjs.com/package/' + handle, auto: true },
|
|
96
|
+
{ id: 'PyPI', link: handle => 'https://pypi.org/project/' + handle + '/' },
|
|
97
|
+
{ id: 'Bluesky', link: handle => 'https://bsky.app/profile/' + handle + '.bsky.social', auto: true },
|
|
98
|
+
];
|
|
99
|
+
// Shown only when the person asks for them; always check links.
|
|
100
|
+
export const requestPlatforms = [
|
|
101
|
+
{ id: 'Snapchat', link: handle => 'https://www.snapchat.com/add/' + handle },
|
|
102
|
+
{ id: 'Reddit', link: handle => 'https://www.reddit.com/user/' + handle + '/' },
|
|
103
|
+
{ id: 'Twitch', link: handle => 'https://www.twitch.tv/' + handle },
|
|
104
|
+
{ id: 'Threads', link: handle => 'https://www.threads.com/@' + handle },
|
|
105
|
+
{ id: 'Pinterest', link: handle => 'https://www.pinterest.com/' + handle + '/' },
|
|
106
|
+
{ id: 'Discord', link: () => 'https://support.discord.com/hc/en-us/articles/12620128861463-New-Usernames-Display-Names' },
|
|
107
|
+
];
|
|
108
|
+
export const autoPlatforms = handlePlatforms.filter(platform => platform.auto).map(platform => platform.id);
|
|
109
|
+
|
|
110
|
+
// In-flight lookups and control batches are shared inside one run (one process).
|
|
111
|
+
const inFlight = new Map();
|
|
112
|
+
const controlRuns = new Map();
|
|
113
|
+
// Every answer this run already has, "check yourself" included, so a later step never asks again.
|
|
114
|
+
const runAnswers = new Map();
|
|
115
|
+
export function resetHandleRuns() {
|
|
116
|
+
inFlight.clear();
|
|
117
|
+
controlRuns.clear();
|
|
118
|
+
runAnswers.clear();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async function githubHeld(directory, now) {
|
|
122
|
+
const hold = await readCache(directory, githubHoldFile);
|
|
123
|
+
return hold?.until > now.getTime();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// One request, and one retry inside the same budget when the platform fails (5xx or no response).
|
|
127
|
+
async function request(platform, identifier, { fetcher, signal, githubToken }, retry = true) {
|
|
128
|
+
const api = apis[platform];
|
|
129
|
+
let failed;
|
|
130
|
+
// An optional token lifts GitHub's 60 requests an hour for anonymous callers. It is sent only to api.github.com.
|
|
131
|
+
const auth = platform === 'GitHub' && githubToken ? { Authorization: 'Bearer ' + githubToken } : {};
|
|
132
|
+
try {
|
|
133
|
+
const response = await fetcher(api.url(identifier), {
|
|
134
|
+
redirect: 'error', signal, headers: { 'User-Agent': userAgent, ...api.headers, ...auth },
|
|
135
|
+
});
|
|
136
|
+
failed = response.status >= 500;
|
|
137
|
+
const state = await api.read(response, identifier);
|
|
138
|
+
const limited = platform === 'GitHub' && [403, 429].includes(response.status);
|
|
139
|
+
if (!failed) return { state, ...(limited && { limited: Number(response.headers.get('x-ratelimit-reset')) * 1000 || null }) };
|
|
140
|
+
} catch {
|
|
141
|
+
failed = true;
|
|
142
|
+
}
|
|
143
|
+
return retry && failed && !signal?.aborted ? request(platform, identifier, { fetcher, signal, githubToken }, false) : { state: 'check' };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// The run's two controls for one platform: a handle known to exist and a random one that cannot. When either comes
|
|
147
|
+
// back wrong, every answer from that platform in this run becomes "check yourself".
|
|
148
|
+
function controlsFor(platform, options) {
|
|
149
|
+
const key = platform + '|' + (options.directory?.href ?? '');
|
|
150
|
+
const runs = options.controlRuns ?? controlRuns;
|
|
151
|
+
if (!runs.has(key)) {
|
|
152
|
+
const { taken, missing } = options.controls?.[platform] ?? apis[platform].controls();
|
|
153
|
+
runs.set(key, Promise.all([request(platform, taken, options), request(platform, missing, options)])
|
|
154
|
+
.then(([known, absent]) => ({ ok: known.state === 'taken' && absent.state === 'not-found',
|
|
155
|
+
limited: known.limited ?? absent.limited })));
|
|
156
|
+
}
|
|
157
|
+
return runs.get(key);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function lookup(platform, identifier, options) {
|
|
161
|
+
const key = platform + '|' + identifier + '|' + (options.directory?.href ?? '');
|
|
162
|
+
if (!inFlight.has(key)) inFlight.set(key, request(platform, identifier, options).finally(() => inFlight.delete(key)));
|
|
163
|
+
return inFlight.get(key);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const cacheFile = (platform, identifier) => 'handle-' + platform.toLowerCase() + '-' + identifier + '.json';
|
|
167
|
+
|
|
168
|
+
async function cached(directory, platform, identifier, now) {
|
|
169
|
+
const saved = await readCache(directory, cacheFile(platform, identifier));
|
|
170
|
+
const age = now.getTime() - saved?.at;
|
|
171
|
+
return age >= 0 && age < (handleLifetime[saved?.state] ?? 0) ? saved : null;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Answer a list of handles on one platform inside one shared time budget. Cached answers need no request; any live
|
|
175
|
+
// request runs beside the platform's control batch, and only a passing control lets a live answer through.
|
|
176
|
+
async function platformBatch(platform, handles, options, deadline) {
|
|
177
|
+
const { directory, now } = options;
|
|
178
|
+
const api = apis[platform];
|
|
179
|
+
const runCache = options.runAnswers ?? runAnswers;
|
|
180
|
+
const answers = new Map();
|
|
181
|
+
const live = [];
|
|
182
|
+
for (const handle of new Set(handles)) {
|
|
183
|
+
if (!label(handle) || !api.valid(handle)) {
|
|
184
|
+
answers.set(handle, { state: 'check', why: 'cannot check this handle form' });
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
const identifier = api.identifier?.(handle) ?? handle;
|
|
188
|
+
const earlier = runCache.get(platform + '|' + identifier + '|' + (directory?.href ?? ''));
|
|
189
|
+
if (earlier) {
|
|
190
|
+
answers.set(handle, earlier);
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
const saved = await cached(directory, platform, identifier, now);
|
|
194
|
+
if (saved) answers.set(handle, { state: saved.state, checkedAt: new Date(saved.at).toISOString(), via: 'cache' });
|
|
195
|
+
else live.push([handle, identifier]);
|
|
196
|
+
}
|
|
197
|
+
if (!live.length && (!options.controlRuns || !answers.size)) return answers;
|
|
198
|
+
if (platform === 'GitHub' && await githubHeld(directory, now)) {
|
|
199
|
+
for (const handle of [...answers.keys(), ...live.map(([handle]) => handle)]) answers.set(handle, { state: 'check', why: 'rate limited' });
|
|
200
|
+
return answers;
|
|
201
|
+
}
|
|
202
|
+
const signal = options.signal ? anySignal([options.signal, deadline]) : deadline;
|
|
203
|
+
const run = { ...options, signal };
|
|
204
|
+
const [control, results] = await Promise.all([
|
|
205
|
+
controlsFor(platform, run),
|
|
206
|
+
Promise.all(live.map(([, identifier]) => lookup(platform, identifier, run))),
|
|
207
|
+
]);
|
|
208
|
+
const limited = control.limited ?? results.find(result => result.limited !== undefined)?.limited;
|
|
209
|
+
if (limited !== undefined) {
|
|
210
|
+
const until = limited > now.getTime() ? limited : now.getTime() + hour;
|
|
211
|
+
await writeCache(directory, githubHoldFile, { until }).catch(() => {});
|
|
212
|
+
}
|
|
213
|
+
if (!control.ok) {
|
|
214
|
+
for (const handle of [...answers.keys(), ...live.map(([handle]) => handle)]) {
|
|
215
|
+
answers.set(handle, { state: 'check', why: 'control check failed' });
|
|
216
|
+
}
|
|
217
|
+
return answers;
|
|
218
|
+
}
|
|
219
|
+
const checkedAt = now.toISOString();
|
|
220
|
+
for (const [index, [handle, identifier]] of live.entries()) {
|
|
221
|
+
const { state } = results[index];
|
|
222
|
+
const key = platform + '|' + identifier + '|' + (directory?.href ?? '');
|
|
223
|
+
if (state === 'check') {
|
|
224
|
+
const answer = { state: 'check', why: 'no clear answer in time' };
|
|
225
|
+
answers.set(handle, answer);
|
|
226
|
+
runCache.set(key, answer);
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
answers.set(handle, { state, checkedAt, via: 'api' });
|
|
230
|
+
runCache.set(key, { state, checkedAt, via: 'api' });
|
|
231
|
+
await writeCache(directory, cacheFile(platform, identifier), { at: now.getTime(), state }).catch(() => {});
|
|
232
|
+
}
|
|
233
|
+
return answers;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function linkRow(platform, handle, why = 'link only') {
|
|
237
|
+
return { platform: platform.id, handle, state: 'check', link: platform.link(handle), why };
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function selectedPlatforms(extra) {
|
|
241
|
+
return [...handlePlatforms, ...requestPlatforms.filter(platform => extra === true || Array.isArray(extra) && extra.includes(platform.id))];
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export function pendingHandleRows(name, extra) {
|
|
245
|
+
return selectedPlatforms(extra).map(platform => linkRow(platform, name, platform.auto ? 'still checking' : 'link only'));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export const handlePriorities = {
|
|
249
|
+
developer: ['GitHub', 'npm', 'X'],
|
|
250
|
+
consumer: ['Instagram', 'TikTok'],
|
|
251
|
+
b2b: ['LinkedIn', 'X'],
|
|
252
|
+
media: ['YouTube', 'TikTok'],
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
// rows: [{ name, platforms?: ['GitHub', 'npm', 'Bluesky'], variants?: boolean, links?: boolean }]
|
|
256
|
+
// Returns a Map from name to its handle rows in display order. Exact handle first; getNAME, NAMEapp and NAMEhq only
|
|
257
|
+
// when the exact handle is taken, inside the same per-platform budget.
|
|
258
|
+
export async function checkSocialHandles(rows, {
|
|
259
|
+
directory = cacheDir, now = new Date(), fetcher = globalThis.fetch, signal, budgetMs = platformBudgetMs,
|
|
260
|
+
controls, extraPlatforms = false, env = process.env, freshRun = false,
|
|
261
|
+
} = {}) {
|
|
262
|
+
const githubToken = typeof env?.DOMAIN_HOUND_GITHUB_TOKEN === 'string' && /^[\w-]{20,255}$/.test(env.DOMAIN_HOUND_GITHUB_TOKEN)
|
|
263
|
+
? env.DOMAIN_HOUND_GITHUB_TOKEN : null;
|
|
264
|
+
const options = { directory, now, fetcher, signal, controls, githubToken,
|
|
265
|
+
...(freshRun && { controlRuns: new Map(), runAnswers: new Map() }) };
|
|
266
|
+
const wanted = platform => rows.filter(row => (row.platforms ?? autoPlatforms).includes(platform));
|
|
267
|
+
const perPlatform = new Map(await Promise.all(autoPlatforms.map(async platform => {
|
|
268
|
+
const names = wanted(platform);
|
|
269
|
+
if (!names.length) return [platform, new Map()];
|
|
270
|
+
const started = performance.now();
|
|
271
|
+
const deadline = new AbortController();
|
|
272
|
+
// Keep Node alive until the platform answers or the deadline aborts its requests.
|
|
273
|
+
const timer = setTimeout(() => {
|
|
274
|
+
deadline.abort(new DOMException('The operation was aborted due to timeout', 'TimeoutError'));
|
|
275
|
+
}, budgetMs);
|
|
276
|
+
try {
|
|
277
|
+
const exact = await platformBatch(platform, names.map(row => row.name), options, deadline.signal);
|
|
278
|
+
const taken = names.filter(row => row.variants && exact.get(row.name)?.state === 'taken');
|
|
279
|
+
const left = budgetMs - (performance.now() - started);
|
|
280
|
+
const variants = taken.length && left >= 300
|
|
281
|
+
? await platformBatch(platform, taken.flatMap(row => handleVariants(row.name)), options, deadline.signal)
|
|
282
|
+
: new Map();
|
|
283
|
+
return [platform, { exact, variants, skipped: taken.length > 0 && left < 300 }];
|
|
284
|
+
} finally {
|
|
285
|
+
clearTimeout(timer);
|
|
286
|
+
}
|
|
287
|
+
})));
|
|
288
|
+
const result = new Map();
|
|
289
|
+
for (const row of rows) {
|
|
290
|
+
const platforms = selectedPlatforms(extraPlatforms);
|
|
291
|
+
const entries = [];
|
|
292
|
+
for (const platform of platforms) {
|
|
293
|
+
const checked = (row.platforms ?? autoPlatforms).includes(platform.id) ? perPlatform.get(platform.id) : null;
|
|
294
|
+
if (!platform.auto || !checked?.exact) {
|
|
295
|
+
if (row.links === false) continue;
|
|
296
|
+
entries.push(linkRow(platform, row.name, platform.auto ? 'not checked for this name' : 'link only'));
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
const answer = checked.exact.get(row.name) ?? { state: 'check', why: 'no clear answer in time' };
|
|
300
|
+
const entry = { platform: platform.id, handle: row.name, state: answer.state, link: platform.link(row.name),
|
|
301
|
+
...(answer.checkedAt && { checkedAt: answer.checkedAt }), ...(answer.why && { why: answer.why }) };
|
|
302
|
+
if (row.variants && answer.state === 'taken') {
|
|
303
|
+
entry.variants = handleVariants(row.name).map(handle => {
|
|
304
|
+
const variant = checked.variants.get(handle) ?? { state: 'check', why: 'no clear answer in time' };
|
|
305
|
+
return { handle, state: variant.state, link: platform.link(handle),
|
|
306
|
+
...(variant.checkedAt && { checkedAt: variant.checkedAt }) };
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
entries.push(entry);
|
|
310
|
+
}
|
|
311
|
+
result.set(row.name, entries);
|
|
312
|
+
}
|
|
313
|
+
return result;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// "GitHub taken · npm no public profile found · Bluesky taken; check yourself: YouTube, X, …".
|
|
317
|
+
export function handleSummary(entries, { limit = Infinity, manualLimit = Infinity, ordered = false } = {}) {
|
|
318
|
+
if (!Array.isArray(entries) || !entries.length) return null;
|
|
319
|
+
const checked = entries.filter(entry => entry.state !== 'check');
|
|
320
|
+
const open = entries.filter(entry => entry.state === 'check');
|
|
321
|
+
if (ordered) {
|
|
322
|
+
const shown = new Set([...entries.slice(0, 2), ...checked.slice(0, 2)]);
|
|
323
|
+
for (const entry of entries) {
|
|
324
|
+
if (shown.size === 4) break;
|
|
325
|
+
shown.add(entry);
|
|
326
|
+
}
|
|
327
|
+
const states = entries.filter(entry => shown.has(entry))
|
|
328
|
+
.map(entry => entry.platform + ' ' + handleStates[entry.state].toLowerCase()).join(', ');
|
|
329
|
+
const more = entries.length - shown.size;
|
|
330
|
+
return states + (more ? ' (' + more + ' more on the page)' : '');
|
|
331
|
+
}
|
|
332
|
+
const shown = checked.slice(0, limit).map(entry => entry.platform + ' ' + handleStates[entry.state].toLowerCase());
|
|
333
|
+
const manual = open.slice(0, manualLimit);
|
|
334
|
+
const more = checked.length - shown.length + open.length - manual.length;
|
|
335
|
+
return [shown.join(' · '), manual.length ? 'check yourself: ' + manual.map(entry => entry.platform).join(', ') : '',
|
|
336
|
+
more > 0 ? '(' + more + ' more on the page)' : ''].filter(Boolean).join('; ');
|
|
337
|
+
}
|
|
@@ -3,8 +3,9 @@ import { setTimeout as delay } from 'node:timers/promises';
|
|
|
3
3
|
import { pathToFileURL } from 'node:url';
|
|
4
4
|
import { promisify } from 'node:util';
|
|
5
5
|
import { apiShops, cachedSignals, confirmDomain, confirmingShops, lightConfirm } from './confirm.mjs';
|
|
6
|
+
import { checkDomainSite } from './com-site.mjs';
|
|
6
7
|
import { appStoreSearchLink, googleSearchLink, nameCheckLines, playSearchLink } from './google-search.mjs';
|
|
7
|
-
import { asciiDomain, canRecommend, defaultEndings, eligibilityNotes, listQuote, mergeQuote, nameCandidates, normalizeName, pickName,
|
|
8
|
+
import { applyLiveSite, asciiDomain, domainEnding, canRecommend, defaultEndings, eligibilityNotes, listQuote, mergeQuote, nameCandidates, normalizeName, pickName,
|
|
8
9
|
premiumRisk, rankName, registrationStatus, searchCandidates, searchName, termCosts, unicodeName, validEligibility, validEndings,
|
|
9
10
|
withPremiumRisk, withoutListPrice } from './name-search.mjs';
|
|
10
11
|
import { bundledCatalog, catalogOffers, datedListPrices, isListPriceUsable, loadCachedCatalog, refreshPrices } from './price-catalog.mjs';
|
|
@@ -75,7 +76,8 @@ export function normalize(input) {
|
|
|
75
76
|
const labels = domain.split('.');
|
|
76
77
|
const label = /^[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?$/;
|
|
77
78
|
const tld = /^(?:[a-z]{2,63}|xn--[a-z\d](?:[a-z\d-]{0,57}[a-z\d])?)$/;
|
|
78
|
-
return labels.length === 2 && labels.
|
|
79
|
+
return (labels.length === 2 || labels.length === 3 && labels.slice(1).join('.') === 'co.uk')
|
|
80
|
+
&& labels.every(part => label.test(part))
|
|
79
81
|
&& tld.test(labels.at(-1)) ? domain : null;
|
|
80
82
|
}
|
|
81
83
|
|
|
@@ -175,7 +177,7 @@ export async function checkDomain(input, {
|
|
|
175
177
|
} = {}) {
|
|
176
178
|
const domain = normalize(input);
|
|
177
179
|
if (!domain) return { error: 'Enter a domain such as example.com.' };
|
|
178
|
-
const tld = domain
|
|
180
|
+
const tld = domainEnding(domain);
|
|
179
181
|
const deadline = performance.now() + totalTimeout;
|
|
180
182
|
const timeout = () => Math.max(0, Math.min(maxTimeout, Math.floor(deadline - performance.now())));
|
|
181
183
|
const [registrations, catalog, pricing, dynadot, confirmed, nok, signals] = await Promise.all([
|
|
@@ -334,7 +336,7 @@ function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimit
|
|
|
334
336
|
let priceListDate;
|
|
335
337
|
let best;
|
|
336
338
|
for (const { name, results } of groups) {
|
|
337
|
-
const taken = [], resale = [], free = [], shop_check = [], likelyFree = [], likelyTaken = [];
|
|
339
|
+
const taken = [], resale = [], free = [], shop_check = [], reserved = [], likelyFree = [], likelyTaken = [];
|
|
338
340
|
for (const row of results) {
|
|
339
341
|
checkedEndings.add(row.tld);
|
|
340
342
|
const d = row.exact ? row.tld : row.domain;
|
|
@@ -368,6 +370,7 @@ function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimit
|
|
|
368
370
|
}
|
|
369
371
|
if (row.status === 'reserved') {
|
|
370
372
|
shop_check.push(d);
|
|
373
|
+
reserved.push(d);
|
|
371
374
|
shopCheckWhy[row.domain] = String(row.registryReason ?? 'Not offered for registration').slice(0, 80);
|
|
372
375
|
continue;
|
|
373
376
|
}
|
|
@@ -399,6 +402,7 @@ function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimit
|
|
|
399
402
|
const unicode = unicodeName(name);
|
|
400
403
|
byName.set(name, { name, ...(unicode && { unicode }), ...(taken.length && { taken }), ...(resale.length && { resale }),
|
|
401
404
|
...(free.length && { free }), ...(shop_check.length && { shop_check }),
|
|
405
|
+
...(reserved.length && { reserved }),
|
|
402
406
|
// Subsets of shop_check with a DNS likelihood; only a registry or shop settles them.
|
|
403
407
|
...(likelyFree.length && { likely_free: likelyFree }), ...(likelyTaken.length && { likely_taken: likelyTaken }) });
|
|
404
408
|
}
|
|
@@ -427,6 +431,11 @@ function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimit
|
|
|
427
431
|
s === 'nc' ? { d, s } : { d, s, ...price });
|
|
428
432
|
}
|
|
429
433
|
}
|
|
434
|
+
// Fourteen endings for twenty long names: an unconfirmed list-price row drops its s, as the display layer does.
|
|
435
|
+
if (batch && Buffer.byteLength(JSON.stringify(result)) >= 7900) {
|
|
436
|
+
for (const row of byName.values()) if (row.free) row.free = row.free.map(({ s, ...option }) => s === 'nc' ? option : { ...option, s });
|
|
437
|
+
result.legend = { ...result.legend, d: agentLegend.d + '; a free entry without s is nc' };
|
|
438
|
+
}
|
|
430
439
|
return result;
|
|
431
440
|
}
|
|
432
441
|
|
|
@@ -456,7 +465,7 @@ export async function agentResult(input, options = {}) {
|
|
|
456
465
|
if (names.includes(null)) return { error: 'Enter a valid name or exact domain.' };
|
|
457
466
|
const exact = new Set(domain ? [domain] : names.filter((name, index) => batch && exactDomain(input[index])));
|
|
458
467
|
const groups = [...new Set(names)].map(name => ({ name, candidates: exact.has(name)
|
|
459
|
-
? [{ domain: name, tld: name
|
|
468
|
+
? [{ domain: name, tld: domainEnding(name), exact: true }] : nameCandidates(name, { ...options, variants: !batch }) }));
|
|
460
469
|
const keyed = apiShops(options.env ?? process.env).length > 0;
|
|
461
470
|
const reserve = keyed ? 1800 : 0;
|
|
462
471
|
const searchOptions = { ...options, budgetMs: Math.max(0, Math.min(remaining() - reserve, batch ? 10_700 : 2700)),
|
|
@@ -476,7 +485,7 @@ export async function agentResult(input, options = {}) {
|
|
|
476
485
|
if (targets.length) {
|
|
477
486
|
options.onProgress?.({ stage: 'quotes' });
|
|
478
487
|
const catalog = await loadCachedCatalog(options.directory);
|
|
479
|
-
const listFor = (target, shop) => datedListPrices(catalog, target
|
|
488
|
+
const listFor = (target, shop) => datedListPrices(catalog, domainEnding(target), options.now ?? new Date(),
|
|
480
489
|
options.bundledCatalog === undefined ? bundledCatalog : options.bundledCatalog).find(row => row.id === shop) ?? null;
|
|
481
490
|
const light = options.lightConfirm ?? lightConfirm;
|
|
482
491
|
const found = await light(targets.map(row => row.domain), { env: options.env, fetcher: options.fetcher,
|
|
@@ -511,13 +520,18 @@ export async function agentResult(input, options = {}) {
|
|
|
511
520
|
complete = false;
|
|
512
521
|
}
|
|
513
522
|
const apply = row => quotes.has(row.domain) ? mergeQuote(row, quotes.get(row.domain)) : row;
|
|
514
|
-
const rankedGroups = fast.groups.map(
|
|
523
|
+
const rankedGroups = fast.groups.map(group => ({ ...group, results: rankName(group.results.map(apply)) }));
|
|
515
524
|
const checkedAt = options.now?.toISOString() ?? new Date().toISOString();
|
|
516
525
|
// An exact .com gets the standard list prices of the other endings as one benchmark line, with no extra lookups.
|
|
517
526
|
const exactCom = names.length === 1 && names[0].endsWith('.com') ? names[0] : null;
|
|
518
527
|
const otherEndings = exactCom ? await endingBenchmarks(exactCom, options) : null;
|
|
519
|
-
|
|
528
|
+
const result = compactAgentResult(rankedGroups, names, complete, checkedAt, batch, rateLimited,
|
|
520
529
|
options.browser ? liveCheckFor(candidate, quote) : null, { eligible: options.eligible, otherEndings });
|
|
530
|
+
if (options.receipt) result.receiptDetails = rankedGroups.map(({ results, sites }) => ({ endings: results.map(row => ({
|
|
531
|
+
domain: row.domain, source: row.source, checkedAt: row.checkedAt, priceAt: row.priceCheckedAt,
|
|
532
|
+
shop: row.shop, checkout: row.buyUrl, site: sites?.[row.tld], risk: row.premium === 'risk' || row.premiumRisk,
|
|
533
|
+
})) }));
|
|
534
|
+
return result;
|
|
521
535
|
}
|
|
522
536
|
|
|
523
537
|
// The cheapest standard list price of each other ending for this label, from the saved or bundled price list.
|
|
@@ -551,14 +565,29 @@ async function retryGoogle(fast, remaining, options) {
|
|
|
551
565
|
const until = performance.now() + budget;
|
|
552
566
|
const timeLeft = () => Math.max(0, Math.floor(until - performance.now()));
|
|
553
567
|
const answers = new Map();
|
|
568
|
+
const siteChecks = [];
|
|
569
|
+
const sites = new Map();
|
|
570
|
+
const verify = options.verifyFreeSite ?? options.comSite ?? checkDomainSite;
|
|
571
|
+
const checkNegative = options.fetcher === undefined || options.verifyFreeSite;
|
|
554
572
|
let timer;
|
|
555
573
|
await Promise.race([
|
|
556
574
|
lookupRegistrations([...pending.values()].map(({ domain, tld, exact }) => ({ domain, tld, exact })), {
|
|
557
575
|
directory: options.directory, fetcher: options.fetcher, pause: options.pause, now: options.now,
|
|
558
576
|
// DNS already showed no name servers for these rows.
|
|
559
577
|
resolveNs: async () => [], timeLeft, rdapAttempts: 1,
|
|
560
|
-
onResult: (
|
|
561
|
-
|
|
578
|
+
onResult: ({ domain }, registry) => {
|
|
579
|
+
if (!timeLeft()) return;
|
|
580
|
+
if (registry.status !== 'free' || !checkNegative) {
|
|
581
|
+
answers.set(domain, registry);
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
const wait = Math.min(1_200, timeLeft());
|
|
585
|
+
siteChecks.push(Promise.resolve().then(() => verify(domain, wait, true)).then(site => {
|
|
586
|
+
sites.set(domain, site);
|
|
587
|
+
answers.set(domain, applyLiveSite(registry, site));
|
|
588
|
+
}, () => { answers.set(domain, registry); }));
|
|
589
|
+
},
|
|
590
|
+
}).then(() => Promise.all(siteChecks)).catch(() => {}),
|
|
562
591
|
new Promise(resolve => { timer = setTimeout(resolve, budget + 100); }),
|
|
563
592
|
]);
|
|
564
593
|
clearTimeout(timer);
|
|
@@ -567,6 +596,7 @@ async function retryGoogle(fast, remaining, options) {
|
|
|
567
596
|
group.results = rankName(group.results.map(row => {
|
|
568
597
|
const answer = pending.has(row.domain) && answers.get(row.domain);
|
|
569
598
|
if (!answer) return row;
|
|
599
|
+
if (sites.has(row.domain)) group.sites[row.tld] = sites.get(row.domain);
|
|
570
600
|
const status = registrationStatus(answer);
|
|
571
601
|
if (status === 'check-at-shop') {
|
|
572
602
|
if (/HTTP 429/.test(answer.reason ?? '')) limited = true;
|
|
@@ -629,6 +659,7 @@ function lookupArgs(args) {
|
|
|
629
659
|
else if (arg === '--eligible' && !options.eligible) options.eligible = (args[++index] ?? '').split(',');
|
|
630
660
|
else if (arg === '--category' && !options.category) options.category = (args[++index] ?? '').slice(0, 100);
|
|
631
661
|
else if (arg === '--compact') options.compact = true;
|
|
662
|
+
else if (arg === '--receipt') options.receipt = true;
|
|
632
663
|
// The headless browser shop check runs only on this explicit flag.
|
|
633
664
|
else if (arg === '--confirm') options.browser = true;
|
|
634
665
|
else if (arg === '--geo' && options.geo === undefined) options.geo = readGeo(args[++index]);
|
|
@@ -666,7 +697,7 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
|
|
|
666
697
|
? await refreshTranco({ directory: process.env.DOMAIN_HOUND_TRANCO_CACHE ? pathToFileURL(process.env.DOMAIN_HOUND_TRANCO_CACHE.replace(/\/?$/, '/')) : undefined })
|
|
667
698
|
: args[0] === '--presence' && args.length === 2 ? await namePresence(args[1], { refreshTranco: true })
|
|
668
699
|
: args[0] === '--triage' ? await triageNames(positional.length === 1 ? positional[0].split(',') : null,
|
|
669
|
-
{ ...options, refreshTranco: true })
|
|
700
|
+
{ ...options, refreshTranco: true, deferHandles: process.env.DOMAIN_HOUND_DEFER_HANDLES === '1' })
|
|
670
701
|
: await checkDomain(args.length === 1 ? args[0] : undefined);
|
|
671
702
|
if (result.error) process.exitCode = 1;
|
|
672
703
|
if (args[0] === '--triage' && options.compact) {
|