domain-hound 0.1.1 → 0.1.3
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 +18 -6
- package/README.md +13 -14
- package/assets/icon-1024.png +0 -0
- package/assets/icon-512.png +0 -0
- package/assets/icon.svg +14 -0
- package/clis/domain-check/confirm.mjs +212 -28
- package/clis/domain-check/google-play.mjs +1 -1
- package/clis/domain-check/index.mjs +197 -47
- package/clis/domain-check/name-search.mjs +113 -17
- package/clis/domain-check/naming-method.mjs +6 -6
- package/clis/domain-check/price-catalog.mjs +7 -5
- package/clis/domain-check/prices.mjs +8 -2
- package/clis/domain-check/progress.mjs +14 -0
- package/clis/domain-check/registry.mjs +180 -39
- package/clis/domain-check/traction.mjs +2 -2
- package/clis/domain-check/triage-sources.mjs +8 -1
- package/clis/domain-check/triage.mjs +52 -26
- package/display.mjs +491 -149
- package/package.json +5 -3
- package/plugin.json +22 -4
- package/server.json +15 -4
- package/server.mjs +206 -64
- package/clis/domain-check/spaceship-feed.mjs +0 -72
|
@@ -5,11 +5,17 @@ import { saleSignal } from './parking.mjs';
|
|
|
5
5
|
import { cacheDir, mapLimit, readCache, writeCache } from './cache.mjs';
|
|
6
6
|
|
|
7
7
|
export const bootstrapUrl = 'https://data.iana.org/rdap/dns.json';
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
// A conclusive registry answer is reused: a registration for a day, an absence for an hour. DNS still runs first,
|
|
9
|
+
// so a name registered since then shows up through its name servers.
|
|
10
|
+
export const takenLifetime = 24 * 3_600_000;
|
|
11
|
+
export const freeLifetime = 3_600_000;
|
|
10
12
|
const identityDigital = 'https://rdap.identitydigital.services';
|
|
11
|
-
const identityDigitalCooldown = 'rdap-identity-digital-cooldown.json';
|
|
12
13
|
const rdapRateLimit = 'Registry RDAP returned HTTP 429';
|
|
14
|
+
// A rate-limited registry host is left alone for its Retry-After in this process and the next.
|
|
15
|
+
const legacyIdentityCooldown = 'rdap-identity-digital-cooldown.json';
|
|
16
|
+
const cooldownFile = origin => 'rdap-cooldown-' + new URL(origin).hostname + '.json';
|
|
17
|
+
// The fallback steps (registry WHOIS, then DNS) keep this much of the lookup time.
|
|
18
|
+
const fallbackReserve = 800;
|
|
13
19
|
|
|
14
20
|
const overrides = new Map([
|
|
15
21
|
['co', 'https://rdap.registry.co/co/'],
|
|
@@ -59,19 +65,90 @@ function unknown(source, reason) {
|
|
|
59
65
|
return { status: 'unknown', source, reason };
|
|
60
66
|
}
|
|
61
67
|
|
|
68
|
+
// A registry that exposes premium or reserved status says so in plain words. "All rights reserved" never counts.
|
|
69
|
+
const reservedWords = /\b(?:(?:domain|name) (?:is |has been )?reserved|reserved (?:domain|name)|reserved (?:by|for) (?:the )?registry|not available for registration)\b/i;
|
|
70
|
+
const premiumWords = /\bregistry premium\b|\bpremium (?:domain|name|price|pricing|tier)\b|\b(?:domain|name) is premium\b/i;
|
|
71
|
+
|
|
72
|
+
export function registrySignal(text) {
|
|
73
|
+
const value = String(text ?? '');
|
|
74
|
+
if (reservedWords.test(value)) return 'reserved';
|
|
75
|
+
return value.split('\n').some(line => premiumWords.test(line) && !/\b(?:not|non[- ]|no)\s*(?:an?\s+)?premium\b/i.test(line))
|
|
76
|
+
? 'premium' : null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Only the human-readable fields of an RDAP error document are read.
|
|
80
|
+
export function rdapSignal(body) {
|
|
81
|
+
let data;
|
|
82
|
+
try { data = JSON.parse(body); } catch { return null; }
|
|
83
|
+
const text = [data?.title, data?.description, ...(Array.isArray(data?.notices) ? data.notices : [])
|
|
84
|
+
.flatMap(notice => [notice?.title, notice?.description])].flat().filter(value => typeof value === 'string');
|
|
85
|
+
return registrySignal(text.join('\n'));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function signalled(source, signal) {
|
|
89
|
+
if (signal === 'reserved') return { status: 'unknown', source, signal, reason: 'Registry lists it as reserved' };
|
|
90
|
+
return { status: 'free', source, ...(signal && { signal }) };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// The recursive DNS answer: name servers mean registered; otherwise a reason and the DNS error code.
|
|
62
94
|
async function dnsStatus(domain, resolveNs) {
|
|
63
95
|
try {
|
|
64
96
|
const nameservers = await resolveNs(domain);
|
|
65
97
|
if (nameservers.length) return { status: 'taken', source: 'dns', nameservers, ...saleSignal(nameservers) };
|
|
66
|
-
return 'DNS returned no name servers';
|
|
98
|
+
return { reason: 'DNS returned no name servers', code: null };
|
|
99
|
+
} catch (error) {
|
|
100
|
+
const code = typeof error?.code === 'string' ? error.code : null;
|
|
101
|
+
if (['ENOTFOUND', 'ENODATA'].includes(code)) return { reason: 'DNS returned no name servers', code };
|
|
102
|
+
if (['ETIMEOUT', 'ECANCELLED'].includes(code)) return { reason: 'DNS timed out', code };
|
|
103
|
+
return { reason: 'DNS query failed', code };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Ask the ending's own authoritative name servers whether they delegate the name. NXDOMAIN means it is not in the
|
|
108
|
+
// zone (likely free, though a registered name without name servers looks the same); a referral or an answer means it
|
|
109
|
+
// is delegated (likely taken). Only a likelihood: a registry or shop still settles it.
|
|
110
|
+
const tldServers = new Map();
|
|
111
|
+
export async function systemAuthoritativeNs(domain, timeout) {
|
|
112
|
+
if (!(timeout >= 150)) return null;
|
|
113
|
+
const deadline = Date.now() + timeout;
|
|
114
|
+
const left = () => Math.max(1, deadline - Date.now());
|
|
115
|
+
const tld = domain.split('.').at(-1);
|
|
116
|
+
const lookup = new Resolver({ timeout: Math.min(800, timeout), tries: 1 });
|
|
117
|
+
const stop = setTimeout(() => lookup.cancel(), timeout);
|
|
118
|
+
let direct;
|
|
119
|
+
let stopDirect;
|
|
120
|
+
try {
|
|
121
|
+
if (!tldServers.has(tld)) {
|
|
122
|
+
tldServers.set(tld, lookup.resolveNs(tld).then(async hosts => (await Promise.all(hosts.slice(0, 3)
|
|
123
|
+
.map(host => lookup.resolve4(host).catch(() => [])))).flat().slice(0, 4)).catch(() => []));
|
|
124
|
+
}
|
|
125
|
+
const servers = await tldServers.get(tld);
|
|
126
|
+
if (!servers.length) {
|
|
127
|
+
tldServers.delete(tld);
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
direct = new Resolver({ timeout: left(), tries: 1 });
|
|
131
|
+
direct.setServers(servers);
|
|
132
|
+
stopDirect = setTimeout(() => direct.cancel(), left());
|
|
133
|
+
await direct.resolveSoa(domain);
|
|
134
|
+
return 'taken';
|
|
67
135
|
} catch (error) {
|
|
68
|
-
if (
|
|
69
|
-
if (
|
|
70
|
-
|
|
136
|
+
if (!direct) return null;
|
|
137
|
+
if (error?.code === 'ENOTFOUND') return 'free';
|
|
138
|
+
if (error?.code === 'ENODATA') return 'taken';
|
|
139
|
+
return null;
|
|
140
|
+
} finally {
|
|
141
|
+
clearTimeout(stop);
|
|
142
|
+
clearTimeout(stopDirect);
|
|
71
143
|
}
|
|
72
144
|
}
|
|
73
145
|
|
|
74
|
-
|
|
146
|
+
// The recursive answer as a likelihood, used when the authoritative check is not available.
|
|
147
|
+
function recursiveLikely(code) {
|
|
148
|
+
return code === 'ENOTFOUND' ? 'free' : null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function systemQueryWhois(host, query, timeout) {
|
|
75
152
|
if (timeout <= 0) return Promise.resolve('');
|
|
76
153
|
return new Promise(resolve => {
|
|
77
154
|
const socket = createConnection({ host, port: 43 });
|
|
@@ -107,21 +184,37 @@ async function lookupWhois(domain, tld, query, timeLeft, referrals) {
|
|
|
107
184
|
const expires = Number.isFinite(Date.parse(expiry)) ? new Date(expiry).toISOString() : null;
|
|
108
185
|
return { status: 'taken', source: 'whois', ...(expires && { expires }) };
|
|
109
186
|
}
|
|
187
|
+
const signal = registrySignal(result);
|
|
188
|
+
if (signal) return signalled('whois', signal);
|
|
110
189
|
if (/^\s*(?:(?:%|>>>|#)\s*)?(?:no (?:match|entries found|data found|object found)|(?:domain\s+)?not found|no such domain|the queried object does not exist)/im.test(result)) {
|
|
111
190
|
return { status: 'free', source: 'whois' };
|
|
112
191
|
}
|
|
113
192
|
return unknown('whois', 'Registry WHOIS returned no definitive answer');
|
|
114
193
|
}
|
|
115
194
|
|
|
195
|
+
// Retry-After as milliseconds from now: delta seconds ("120") or an HTTP date. Null when absent or unreadable.
|
|
196
|
+
export function retryAfterMs(value, now = Date.now()) {
|
|
197
|
+
const text = typeof value === 'string' ? value.trim() : '';
|
|
198
|
+
if (!text) return null;
|
|
199
|
+
if (/^\d+$/.test(text)) {
|
|
200
|
+
const duration = Number(text) * 1000;
|
|
201
|
+
return Number.isSafeInteger(now + duration) ? duration : null;
|
|
202
|
+
}
|
|
203
|
+
if (!/[a-z]/i.test(text)) return null;
|
|
204
|
+
const at = Date.parse(text);
|
|
205
|
+
return Number.isFinite(at) ? Math.max(0, at - now) : null;
|
|
206
|
+
}
|
|
207
|
+
|
|
116
208
|
function retryWait(value, attempt, limited = false) {
|
|
117
209
|
const backoff = (limited ? 650 : 150) * 2 ** attempt;
|
|
118
|
-
return Math.max(backoff,
|
|
210
|
+
return Math.max(backoff, retryAfterMs(value) ?? 0);
|
|
119
211
|
}
|
|
120
212
|
|
|
121
213
|
async function lookupRdap(base, domain, fetcher, timeLeft, readExpiry, pause, registry, attempts, directory) {
|
|
122
214
|
let last = unknown('rdap', 'Registry lookup timed out');
|
|
123
215
|
for (let attempt = 0; attempt < attempts && timeLeft() > 0; attempt++) {
|
|
124
216
|
const now = Date.now();
|
|
217
|
+
// A queued request never goes to a host that is cooling down.
|
|
125
218
|
if (registry.limitedUntil > now) return unknown('rdap', rdapRateLimit);
|
|
126
219
|
const startsAt = Math.max(registry.retryAt, registry.nextStart, now);
|
|
127
220
|
if (startsAt - now >= timeLeft()) return last;
|
|
@@ -132,6 +225,7 @@ async function lookupRdap(base, domain, fetcher, timeLeft, readExpiry, pause, re
|
|
|
132
225
|
if (wait >= timeLeft()) return last;
|
|
133
226
|
if (wait > 0) await pause(wait);
|
|
134
227
|
}
|
|
228
|
+
if (registry.limitedUntil > Date.now()) return unknown('rdap', rdapRateLimit);
|
|
135
229
|
if (timeLeft() <= 0) return last;
|
|
136
230
|
let wait = retryWait(null, attempt);
|
|
137
231
|
try {
|
|
@@ -150,19 +244,24 @@ async function lookupRdap(base, domain, fetcher, timeLeft, readExpiry, pause, re
|
|
|
150
244
|
...(Number.isFinite(Date.parse(expires)) && { expires }) };
|
|
151
245
|
}
|
|
152
246
|
if (status === 404) {
|
|
153
|
-
//
|
|
154
|
-
|
|
155
|
-
|
|
247
|
+
// A 404 says only that the name is not registered. It is not a standard-price signal; a registry
|
|
248
|
+
// that exposes premium or reserved status in the error document is read here.
|
|
249
|
+
const body = await response.text().catch(() => '');
|
|
250
|
+
return signalled('rdap', rdapSignal(body.slice(0, 16_384)));
|
|
156
251
|
}
|
|
157
252
|
await response.body?.cancel().catch(() => {});
|
|
158
253
|
last = unknown('rdap', 'Registry RDAP returned HTTP ' + status);
|
|
159
254
|
if (status !== 429 && status < 500) return last;
|
|
160
|
-
|
|
255
|
+
const header = response.headers?.get('retry-after');
|
|
256
|
+
wait = retryWait(header, attempt, status === 429);
|
|
161
257
|
if (status === 429 || status === 503) registry.retryAt = Math.max(registry.retryAt, Date.now() + wait);
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
258
|
+
// The host's cooldown holds for this process and, through the cache, for the next lookups too.
|
|
259
|
+
if (status === 429 || (status === 503 && retryAfterMs(header) != null)) {
|
|
260
|
+
const outlasts = wait >= timeLeft();
|
|
261
|
+
// Queued requests see the cooldown before the cache write finishes.
|
|
262
|
+
if (outlasts) registry.limitedUntil = Math.max(registry.limitedUntil, registry.retryAt);
|
|
263
|
+
await writeCache(directory, cooldownFile(base), { until: registry.retryAt }).catch(() => {});
|
|
264
|
+
if (outlasts) return last;
|
|
166
265
|
}
|
|
167
266
|
} catch {
|
|
168
267
|
last = unknown('rdap', 'Registry RDAP did not respond');
|
|
@@ -174,25 +273,53 @@ async function lookupRdap(base, domain, fetcher, timeLeft, readExpiry, pause, re
|
|
|
174
273
|
}
|
|
175
274
|
|
|
176
275
|
export async function lookupRegistrations(candidates, {
|
|
177
|
-
directory = cacheDir, fetcher = globalThis.fetch, resolveNs = systemResolveNs, queryWhois
|
|
276
|
+
directory = cacheDir, fetcher = globalThis.fetch, resolveNs = systemResolveNs, queryWhois, authoritativeNs,
|
|
178
277
|
now = new Date(), timeLeft = () => 8500, dnsFirst = true, readExpiry = false, pause = delay,
|
|
179
278
|
onResult = () => {}, concurrency = 4, rdapAttempts = 3,
|
|
180
279
|
} = {}) {
|
|
280
|
+
const whois = queryWhois ?? systemQueryWhois;
|
|
281
|
+
// The fallbacks use the system network only in live use: a caller that injects its own network gets no other.
|
|
282
|
+
const fallbackWhois = queryWhois ?? (fetcher === globalThis.fetch ? systemQueryWhois : null);
|
|
283
|
+
const dnsSignal = authoritativeNs ?? (resolveNs === systemResolveNs ? systemAuthoritativeNs : null);
|
|
284
|
+
const reserve = Math.min(fallbackReserve, Math.max(0, timeLeft() - 1500));
|
|
285
|
+
const rdapLeft = () => timeLeft() - reserve;
|
|
181
286
|
const services = candidates.some(({ tld }) => !rdapBase(tld))
|
|
182
287
|
? bootstrap(directory, fetcher, now, timeLeft) : null;
|
|
183
288
|
const referrals = new Map();
|
|
184
289
|
const pending = candidates.map(async (candidate, index) => {
|
|
185
|
-
const dns = dnsFirst ? await dnsStatus(candidate.domain, resolveNs) :
|
|
290
|
+
const dns = dnsFirst ? await dnsStatus(candidate.domain, resolveNs) : null;
|
|
186
291
|
return { candidate, index, dns };
|
|
187
292
|
});
|
|
188
293
|
const results = [];
|
|
189
294
|
function record({ candidate, index, dns }, registry) {
|
|
190
|
-
if (registry.status === 'unknown' && dns) registry.reason = dns + '; ' + registry.reason;
|
|
295
|
+
if (registry.status === 'unknown' && dns?.reason) registry.reason = dns.reason + '; ' + registry.reason;
|
|
191
296
|
results[index] = registry;
|
|
192
297
|
onResult(candidate, registry);
|
|
193
298
|
}
|
|
299
|
+
async function finish(row, result, filename) {
|
|
300
|
+
record(row, result);
|
|
301
|
+
if (filename && ['taken', 'free'].includes(result.status)) {
|
|
302
|
+
await writeCache(directory, filename, { at: now.getTime(), result }).catch(() => {});
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
// DNS as a likelihood when the registry stays silent: the ending's authoritative servers when available, else the
|
|
306
|
+
// recursive answer from the first DNS step. Never a free result.
|
|
307
|
+
async function dnsLikely(row) {
|
|
308
|
+
const wait = Math.min(900, Math.floor(timeLeft()));
|
|
309
|
+
if (dnsSignal && wait >= 150) {
|
|
310
|
+
// The deadline holds even if a resolver never answers.
|
|
311
|
+
let timer;
|
|
312
|
+
const answer = await Promise.race([
|
|
313
|
+
Promise.resolve().then(() => dnsSignal(row.candidate.domain, wait)).catch(() => null),
|
|
314
|
+
new Promise(resolve => { timer = setTimeout(resolve, wait + 50, null); }),
|
|
315
|
+
]);
|
|
316
|
+
clearTimeout(timer);
|
|
317
|
+
if (answer === 'free' || answer === 'taken') return answer;
|
|
318
|
+
}
|
|
319
|
+
return recursiveLikely(row.dns?.code);
|
|
320
|
+
}
|
|
194
321
|
const records = pending.map(entry => entry.then(row => {
|
|
195
|
-
if (
|
|
322
|
+
if (row.dns?.status === 'taken') {
|
|
196
323
|
record(row, row.dns);
|
|
197
324
|
return null;
|
|
198
325
|
}
|
|
@@ -212,35 +339,49 @@ export async function lookupRegistrations(candidates, {
|
|
|
212
339
|
}
|
|
213
340
|
registries.get(origin).jobs.push({ base, entry: records[index] });
|
|
214
341
|
}));
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
342
|
+
// Rows the registry left open, for the WHOIS and DNS fallbacks once every host has had its turn.
|
|
343
|
+
const unsettled = [];
|
|
344
|
+
await Promise.all([...registries].map(async ([origin, registry]) => {
|
|
345
|
+
if (origin.startsWith('https:')) {
|
|
346
|
+
const saved = await readCache(directory, cooldownFile(origin));
|
|
347
|
+
const legacy = origin === identityDigital ? await readCache(directory, legacyIdentityCooldown) : null;
|
|
348
|
+
registry.limitedUntil = Math.max(saved?.until || 0, legacy?.until || 0);
|
|
219
349
|
}
|
|
220
350
|
return mapLimit(registry.jobs, registry.limit, async ({ base, entry }) => {
|
|
221
351
|
const row = await entry;
|
|
222
352
|
if (!row) return;
|
|
223
353
|
const { domain, tld } = row.candidate;
|
|
224
|
-
const filename = dnsFirst
|
|
354
|
+
const filename = dnsFirst ? 'rdap-' + domain + '.json' : null;
|
|
225
355
|
const cached = filename && await readCache(directory, filename);
|
|
226
356
|
const age = now - cached?.at;
|
|
227
|
-
|
|
357
|
+
const lifetime = { taken: takenLifetime, free: freeLifetime }[cached?.result?.status] ?? 0;
|
|
358
|
+
if (age >= 0 && age < lifetime) {
|
|
228
359
|
record(row, { ...cached.result, checkedAt: new Date(cached.at).toISOString() });
|
|
229
360
|
return;
|
|
230
361
|
}
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if (
|
|
236
|
-
|
|
237
|
-
if (fallback.status !== 'unknown') result = fallback;
|
|
238
|
-
}
|
|
239
|
-
record(row, result);
|
|
240
|
-
if (filename && result.status !== 'unknown') {
|
|
241
|
-
await writeCache(directory, filename, { at: now.getTime(), result }).catch(() => {});
|
|
242
|
-
}
|
|
362
|
+
const result = base ? await lookupRdap(base, domain, fetcher, rdapLeft, readExpiry, pause, registry, rdapAttempts, directory)
|
|
363
|
+
: await services ? await lookupWhois(domain, tld, whois, timeLeft, referrals)
|
|
364
|
+
.catch(() => unknown('whois', 'Registry WHOIS did not respond'))
|
|
365
|
+
: unknown('rdap', 'IANA RDAP bootstrap is unavailable');
|
|
366
|
+
if (result.status === 'unknown' && !result.signal) unsettled.push({ row, result, filename, viaWhois: !base });
|
|
367
|
+
else await finish(row, result, filename);
|
|
243
368
|
});
|
|
244
369
|
}));
|
|
370
|
+
// Registry WHOIS (where IANA documents one for the ending) and the DNS likelihood run side by side per row, so a
|
|
371
|
+
// slow WHOIS server never uses up the time of the DNS step. A WHOIS answer settles the row; DNS only suggests.
|
|
372
|
+
await mapLimit(unsettled, 6, async ({ row, result, filename, viaWhois }) => {
|
|
373
|
+
const { domain, tld } = row.candidate;
|
|
374
|
+
// IANA lists RDAP as the sole registration service for Google's .app and .dev.
|
|
375
|
+
const query = ['app', 'dev'].includes(tld) ? null : fallbackWhois;
|
|
376
|
+
const [answer, likely] = await Promise.all([
|
|
377
|
+
query && !viaWhois && timeLeft() > 600
|
|
378
|
+
? lookupWhois(domain, tld, query, () => timeLeft() - 300, referrals)
|
|
379
|
+
.catch(() => unknown('whois', 'Registry WHOIS did not respond')) : null,
|
|
380
|
+
dnsLikely(row),
|
|
381
|
+
]);
|
|
382
|
+
const settled = answer && (answer.status !== 'unknown' || answer.signal) ? answer
|
|
383
|
+
: likely ? { ...result, likely, likelySource: 'dns' } : result;
|
|
384
|
+
await finish(row, settled, filename);
|
|
385
|
+
});
|
|
245
386
|
return results;
|
|
246
387
|
}
|
|
@@ -7,8 +7,8 @@ import { cacheDir, mapLimit, readCache, writeCache } from './cache.mjs';
|
|
|
7
7
|
import { bootstrapUrl, rdapBase, rdapDomainUrl } from './registry.mjs';
|
|
8
8
|
import { compactText, day, letters, readJson, request } from './triage-sources.mjs';
|
|
9
9
|
|
|
10
|
-
// Every traction threshold lives in this table. Tuned with the
|
|
11
|
-
//
|
|
10
|
+
// Every traction threshold lives in this table. Tuned with the strong, no-traction and some-traction
|
|
11
|
+
// fixtures in traction.test.mjs.
|
|
12
12
|
// strong: a Goliath. Any one signal is enough.
|
|
13
13
|
// some: real but small use. Domain age counts only with a live, current site.
|
|
14
14
|
// dormant: parked or for-sale pages, or stale live sites with a tiny crawl and no Tranco rank.
|
|
@@ -30,7 +30,14 @@ export const handleSearches = {
|
|
|
30
30
|
YouTube: 'https://www.youtube.com/@{name}',
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
// Latin letters for name matching: accents drop, and letters without a decomposition fold too (ø -> o, æ -> ae).
|
|
34
|
+
const folds = [[/æ/g, 'ae'], [/ø/g, 'o'], [/œ/g, 'oe'], [/ß/g, 'ss'], [/[đð]/g, 'd'], [/þ/g, 'th'], [/ł/g, 'l'], [/ı/g, 'i']];
|
|
35
|
+
export function foldLatin(value) {
|
|
36
|
+
let text = String(value ?? '').normalize('NFC').toLowerCase();
|
|
37
|
+
for (const [pattern, replacement] of folds) text = text.replace(pattern, replacement);
|
|
38
|
+
return text.normalize('NFKD').replace(/\p{M}/gu, '');
|
|
39
|
+
}
|
|
40
|
+
export const letters = value => foldLatin(value).replace(/[^a-z0-9]/g, '');
|
|
34
41
|
export const compactText = (value, limit) => String(value ?? '')
|
|
35
42
|
.replace(/[\p{Cc}\p{Cf}\s]+/gu, ' ').trim().slice(0, limit);
|
|
36
43
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { canRecommend, defaultEndings, eligibilityNotes, nameCandidates, normalizeName, searchCandidates,
|
|
1
|
+
import { canRecommend, defaultEndings, eligibilityNotes, nameCandidates, normalizeName, searchCandidates, searchKey,
|
|
2
2
|
validEligibility, validEndings } from './name-search.mjs';
|
|
3
|
+
import { shopSearchUrl } from './prices.mjs';
|
|
3
4
|
import { checkHandles, compactText, handleSearches, letters, searchApps, searchEntities, searchMarks, trademarkSearches } from './triage-sources.mjs';
|
|
4
5
|
import { loadEdgarCompanies, matchEdgarCompanies, searchNorwegianCompanies } from './company-search.mjs';
|
|
5
6
|
import { mapLimit } from './cache.mjs';
|
|
@@ -216,7 +217,7 @@ export async function namePresence(input, options = {}) {
|
|
|
216
217
|
// Same-name rivals with measured traction follow the traction rules first; evidence whose traction could not be
|
|
217
218
|
// measured keeps the earlier same-name checks. Trademark and availability guardrails stay in place.
|
|
218
219
|
function baseVerdict({ rival, overlap, sameName, activeApp, brand, app, entity, mark, site, best, available, marks, apps, android,
|
|
219
|
-
androidAnswered = android, com }) {
|
|
220
|
+
androidAnswered = android, com, premium = [] }) {
|
|
220
221
|
if (rival?.[0] === 'Avoid') return rival;
|
|
221
222
|
if (overlap) return ['Avoid', overlap.domain + ' is a live business in the same category'];
|
|
222
223
|
if (activeApp) return ['Avoid', activeApp.name + ' is an app in the same category with ' + activeApp.ratings + ' ' + activeApp.store + ' ratings'];
|
|
@@ -231,7 +232,10 @@ function baseVerdict({ rival, overlap, sameName, activeApp, brand, app, entity,
|
|
|
231
232
|
if (entity) return ['Check first', 'An exact-name Wikidata entity already exists'];
|
|
232
233
|
if (!marks || !apps || !androidAnswered || sameName.unchecked?.length) return ['Check first', 'A competition source did not answer'];
|
|
233
234
|
if (com?.status === 'check-at-shop') return ['Check first', 'The .com registry status is unresolved'];
|
|
234
|
-
if (!best)
|
|
235
|
+
if (!best) {
|
|
236
|
+
return ['Check first', available.length ? 'The free endings require buyer eligibility'
|
|
237
|
+
: premium.length ? 'The free endings may be premium, price at shop' : 'No domain was found free at the registry'];
|
|
238
|
+
}
|
|
235
239
|
return ['No conflict found', 'No close US mark, app or site overlap'];
|
|
236
240
|
}
|
|
237
241
|
|
|
@@ -244,10 +248,14 @@ export async function triageNames(inputs, options = {}) {
|
|
|
244
248
|
if (options.eligible !== undefined && !validEligibility(options.eligible)) return { error: 'Eligible endings must list supported restricted endings, such as no.' };
|
|
245
249
|
const endings = options.endings ?? defaultEndings;
|
|
246
250
|
const websiteEndings = [...new Set([...endings, ...coreWebsiteEndings])];
|
|
251
|
+
// Each name has its DNS label (punycode for æøå) for domains, and a Latin key for the rival, app and mark sources.
|
|
247
252
|
const names = new Map();
|
|
253
|
+
const keys = new Map();
|
|
248
254
|
for (const input of inputs) {
|
|
249
255
|
const name = normalizeName(input);
|
|
250
|
-
if (
|
|
256
|
+
if (names.has(name)) continue;
|
|
257
|
+
names.set(name, input.trim());
|
|
258
|
+
keys.set(name, searchKey(input));
|
|
251
259
|
}
|
|
252
260
|
const budgetMs = options.budgetMs ?? 13200;
|
|
253
261
|
const started = performance.now();
|
|
@@ -275,7 +283,7 @@ export async function triageNames(inputs, options = {}) {
|
|
|
275
283
|
const groups = [...names.keys()].map(name => ({
|
|
276
284
|
name, candidates: nameCandidates(name, { variants: false, endings: websiteEndings }),
|
|
277
285
|
}));
|
|
278
|
-
const entries = [...names].map(([name, input], index) => [name, input, index]);
|
|
286
|
+
const entries = [...names].map(([name, input], index) => [keys.get(name), input, index]);
|
|
279
287
|
const check = (concurrency, lookup, after = () => {}) => mapLimit(entries, concurrency, async ([name, input, index]) => {
|
|
280
288
|
const result = signal.aborted ? null : await retry(() => lookup(name, input, sources), found);
|
|
281
289
|
after(result, index);
|
|
@@ -295,14 +303,16 @@ export async function triageNames(inputs, options = {}) {
|
|
|
295
303
|
});
|
|
296
304
|
const [domains, marksByName, appsByName, entitiesByName, handlesByName, norwayByName, androidApps, edgar, googleByName] =
|
|
297
305
|
await Promise.all([
|
|
298
|
-
|
|
306
|
+
// A cold cache still gets the bundled, dated list prices, so free endings never all read "price at shop".
|
|
307
|
+
searchCandidates(groups, { ...options, budgetMs: Math.min(budgetMs, 11500),
|
|
299
308
|
siteEndings: websiteEndings, siteTimeout: 3000, siteDetails: true, onSite }),
|
|
300
309
|
check(6, searchMarks), check(8, searchApps, (result, index) => startHomes(entries[index][0],
|
|
301
310
|
(result ?? []).map(row => siteDomain(row.sellerUrl)).filter(domain => domain?.split('.')[0].includes(entries[index][0])))),
|
|
302
311
|
entityChecks,
|
|
303
312
|
Promise.all(entries.map(([name]) => checkHandles(name, sources))),
|
|
304
313
|
check(8, searchNorwegianCompanies),
|
|
305
|
-
searchAndroidApps(
|
|
314
|
+
searchAndroidApps(new Map(entries.map(([key, input]) => [key, input])),
|
|
315
|
+
{ ...sources, playBudgetMs: Math.min(12000, options.playBudgetMs ?? Infinity, budgetMs) }),
|
|
306
316
|
retry(() => loadEdgarCompanies(sources), found),
|
|
307
317
|
mapLimit(entries, 5, ([name, input, index]) => searchGoogle(name, input, {
|
|
308
318
|
...sources, timeoutMs: timeLeft(),
|
|
@@ -315,18 +325,20 @@ export async function triageNames(inputs, options = {}) {
|
|
|
315
325
|
const geoByName = new Map(Object.entries(options.geo ?? {}).map(([key, value]) => [normalizeName(key), parseGeo(value)]));
|
|
316
326
|
const storeAppsByName = domains.groups.map(({ name }, index) => [
|
|
317
327
|
...(appsByName[index] ?? []).map(row => ({ ...row, store: 'iOS', ref: row })),
|
|
318
|
-
...(androidApps.get(name) ?? []).map(row => ({ ...row, store: 'Android', ref: row })),
|
|
328
|
+
...(androidApps.get(keys.get(name)) ?? []).map(row => ({ ...row, store: 'Android', ref: row })),
|
|
319
329
|
]);
|
|
320
330
|
const rivalsByName = domains.groups.map(({ name, sites }, index) => {
|
|
321
331
|
const raw = googleByName[index].raw ?? {};
|
|
332
|
+
const key = keys.get(name);
|
|
322
333
|
const rivals = collectRivals({
|
|
323
|
-
name, input: names.get(name), sites, entities: entitiesByName[index], topics: raw.topics, suggestions: raw.suggestions,
|
|
334
|
+
name: key, input: names.get(name), sites, entities: entitiesByName[index], topics: raw.topics, suggestions: raw.suggestions,
|
|
324
335
|
apps: storeAppsByName[index], geo: geoByName.get(name),
|
|
325
|
-
sameBusiness: text => describedBusiness(
|
|
336
|
+
sameBusiness: text => describedBusiness(key, text, options.about, options.category),
|
|
326
337
|
});
|
|
327
338
|
startEvidence(traction, rivals);
|
|
328
339
|
return rivals;
|
|
329
340
|
});
|
|
341
|
+
options.onProgress?.({ stage: 'rivals' });
|
|
330
342
|
const evidence = await traction.settle();
|
|
331
343
|
const rows = domains.groups.map(({ name, results, sites }, index) => {
|
|
332
344
|
const marks = marksByName[index];
|
|
@@ -337,14 +349,15 @@ export async function triageNames(inputs, options = {}) {
|
|
|
337
349
|
const [app] = apps ?? [];
|
|
338
350
|
const brand = entities?.find(row => row.brand);
|
|
339
351
|
const entity = brand ?? entities?.[0];
|
|
340
|
-
const
|
|
352
|
+
const key = keys.get(name);
|
|
353
|
+
const android = androidApps.get(key);
|
|
341
354
|
const google = googleByName[index];
|
|
342
355
|
const judged = judgeRivals(rivalsByName[index], evidence, { now: (options.now ?? new Date()).getTime(),
|
|
343
356
|
answered: { wikidata: entities != null, apps: apps != null && android != null },
|
|
344
357
|
geo: geoByName.get(name), entities });
|
|
345
358
|
const { explained } = judged;
|
|
346
359
|
const storeApps = storeAppsByName[index];
|
|
347
|
-
const activeApp = storeApps.find(row => !explained.has(row.ref) && row.ratings >= 100 && describedBusiness(
|
|
360
|
+
const activeApp = storeApps.find(row => !explained.has(row.ref) && row.ratings >= 100 && describedBusiness(key,
|
|
348
361
|
[row.name, row.category, row.description].join(' '), options.about, options.category));
|
|
349
362
|
const mark = marks?.[0];
|
|
350
363
|
const others = marks?.filter(item => letters(item.name) !== letters(mark?.name)) ?? [];
|
|
@@ -359,29 +372,29 @@ export async function triageNames(inputs, options = {}) {
|
|
|
359
372
|
const live = Object.entries(sites).flatMap(([tld, site]) => {
|
|
360
373
|
const domain = name + '.' + tld;
|
|
361
374
|
if (site.state !== 'live' || (site.host && site.host !== domain && !site.host.endsWith('.' + domain)
|
|
362
|
-
&& !letters([site.title, site.description].join(' ')).includes(letters(
|
|
375
|
+
&& !letters([site.title, site.description].join(' ')).includes(letters(key)))) return [];
|
|
363
376
|
const business = siteCategories.find(([, pattern]) => pattern.test(site.title ?? ''))?.[0]
|
|
364
377
|
?? siteCategories.find(([, pattern]) => pattern.test(site.description ?? ''))?.[0] ?? 'unknown';
|
|
365
|
-
const sameBusiness = describedBusiness(
|
|
378
|
+
const sameBusiness = describedBusiness(key, [site.title, site.description].join(' '), options.about, options.category);
|
|
366
379
|
return [{ domain, title: compactText(site.title, 75), business, ...(sameBusiness && { sameBusiness }) }];
|
|
367
380
|
});
|
|
368
381
|
// Only same-name evidence whose traction could not be measured keeps the earlier checks.
|
|
369
382
|
const unmeasured = live.filter(row => !explained.has(row.domain));
|
|
370
383
|
const site = unmeasured[0];
|
|
371
384
|
const overlap = unmeasured.find(row => row.sameBusiness && /\.(com|ai)$/.test(row.domain));
|
|
372
|
-
const us = matchEdgarCompanies(
|
|
373
|
-
const sameName = sameNameEvidence({ name, live, norway, us, entities, entity, github, handles });
|
|
385
|
+
const us = matchEdgarCompanies(key, edgar);
|
|
386
|
+
const sameName = sameNameEvidence({ name: key, live, norway, us, entities, entity, github, handles });
|
|
374
387
|
const otherEntities = entities?.filter(row => !explained.has(row));
|
|
375
|
-
const legacy = sameNameEvidence({ name, live: unmeasured, norway, us, entities: otherEntities, entity, github, handles });
|
|
388
|
+
const legacy = sameNameEvidence({ name: key, live: unmeasured, norway, us, entities: otherEntities, entity, github, handles });
|
|
376
389
|
const silent = silentSources({ marks, apps, android, entities, norway, edgar, github, handles });
|
|
377
390
|
const otherEntity = otherEntities?.find(row => row.brand) ?? otherEntities?.[0];
|
|
378
391
|
const [decision, reason] = verdict({
|
|
379
392
|
rival: tractionVerdict(judged), overlap, sameName: legacy, activeApp,
|
|
380
393
|
brand: otherEntity?.brand ? otherEntity : undefined, app: apps?.find(row => !explained.has(row)), entity: otherEntity,
|
|
381
|
-
mark, otherMark, site, silent, best, available, marks, apps,
|
|
394
|
+
mark, otherMark, site, silent, best, available, marks, apps, premium: results.filter(row => row.status === 'premium'),
|
|
382
395
|
android: android?.filter(row => !explained.has(row)), androidAnswered: android, com: results.find(row => row.tld === 'com'),
|
|
383
396
|
});
|
|
384
|
-
const googleExplained = explainedGoogle(
|
|
397
|
+
const googleExplained = explainedGoogle(key, googleByName[index].raw, judged, entities);
|
|
385
398
|
const summary = tractionSummary(judged);
|
|
386
399
|
const answered = {
|
|
387
400
|
USPTO: marks, 'App Store': apps, 'Google Play': android, Google: google.google, Wikidata: entities,
|
|
@@ -406,10 +419,16 @@ export async function triageNames(inputs, options = {}) {
|
|
|
406
419
|
...(summary && { traction: summary }),
|
|
407
420
|
google: { ...(google.google ?? { result: 'not checked', why: google.unchecked }), link: googleSearchLink(names.get(name)) },
|
|
408
421
|
taken: requested.filter(row => row.status === 'taken').map(row => row.tld),
|
|
409
|
-
shop_check: requested.filter(row =>
|
|
410
|
-
|
|
422
|
+
shop_check: requested.filter(row => ['check-at-shop', 'reserved'].includes(row.status)).map(row => row.tld),
|
|
423
|
+
// Subsets of shop_check with a DNS likelihood; only a registry or shop settles them.
|
|
424
|
+
...likelyEndings(requested),
|
|
425
|
+
// Premium endings never carry a list price; the shop shows their price. A short name may be premium.
|
|
426
|
+
...(requested.some(row => row.status === 'premium') && {
|
|
427
|
+
premium: requested.filter(row => row.status === 'premium').map(row => row.tld) }),
|
|
428
|
+
// The checkout is the listed shop's search, or the confirming shop's search when no list price is known.
|
|
429
|
+
competition, buy: best ? best.buyUrl ?? shopSearchUrl(best.confirmShop, best.domain) : null,
|
|
411
430
|
details: {
|
|
412
|
-
memorable: memorability(
|
|
431
|
+
memorable: memorability(key, names.get(name)),
|
|
413
432
|
presence: Object.fromEntries(Object.entries(handles).map(([service, status]) =>
|
|
414
433
|
[service, status === 'unknown' ? null : status])),
|
|
415
434
|
sites: Object.fromEntries(seen), appName: appStatus(apps, android),
|
|
@@ -446,10 +465,17 @@ function priceEntry(row) {
|
|
|
446
465
|
};
|
|
447
466
|
}
|
|
448
467
|
|
|
468
|
+
function likelyEndings(rows) {
|
|
469
|
+
const open = rows.filter(row => row.status === 'check-at-shop');
|
|
470
|
+
const free = open.filter(row => row.likely === 'free').map(row => row.tld);
|
|
471
|
+
const taken = open.filter(row => row.likely === 'taken').map(row => row.tld);
|
|
472
|
+
return { ...(free.length && { likely_free: free }), ...(taken.length && { likely_taken: taken }) };
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
// Best value is the lowest total of the payments due in three years; the cheaper first payment breaks a tie.
|
|
449
476
|
function bestValue(options) {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
return value === options[0] ? undefined : value;
|
|
477
|
+
return options.filter(row => Number.isFinite(row.threeYear)).reduce((best, row) => !best || row.threeYear < best.threeYear
|
|
478
|
+
|| (row.threeYear === best.threeYear && row.firstPayment < best.firstPayment) ? row : best, undefined);
|
|
453
479
|
}
|
|
454
480
|
|
|
455
481
|
function rankedRows(rows) {
|
|
@@ -467,7 +493,7 @@ function topChoices(rows) {
|
|
|
467
493
|
name, verdict, reason, domain: best?.domain ?? null, ending: best?.tld ?? null,
|
|
468
494
|
now: best?.firstPayment ?? null, renew: best?.renewalPayment ?? null, term: best?.minimumYears ?? null,
|
|
469
495
|
...(value && { bestValue: { domain: value.domain, now: value.firstPayment,
|
|
470
|
-
renew: value.renewalPayment, term: value.minimumYears } }),
|
|
496
|
+
renew: value.renewalPayment, term: value.minimumYears, y3: value.threeYear } }),
|
|
471
497
|
};
|
|
472
498
|
});
|
|
473
499
|
}
|