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.
@@ -1,16 +1,28 @@
1
1
  {
2
2
  "name": "domain-hound",
3
3
  "displayName": "Domain Hound",
4
- "version": "0.1.1",
5
- "description": "Check domains, compare registrar prices, and screen product names.",
6
- "author": { "name": "Lars Hvinden" },
4
+ "version": "0.1.3",
5
+ "description": "Check domain availability and prices, and screen product names, from your AI assistant.",
6
+ "author": {
7
+ "name": "Lars Hvinden"
8
+ },
7
9
  "homepage": "https://domainhound.dev",
8
10
  "license": "MIT",
9
- "keywords": ["mcp", "domains"],
11
+ "keywords": [
12
+ "mcp",
13
+ "domains"
14
+ ],
10
15
  "mcpServers": {
11
16
  "domain-hound": {
12
17
  "command": "npx",
13
- "args": ["-y", "domain-hound"]
18
+ "args": [
19
+ "-y",
20
+ "domain-hound"
21
+ ]
14
22
  }
15
- }
23
+ },
24
+ "icon": "./assets/icon-512.png",
25
+ "documentationUrl": "https://github.com/lars-hv/domain-hound#readme",
26
+ "supportUrl": "https://github.com/lars-hv/domain-hound/issues",
27
+ "privacyPolicyUrl": "https://domainhound.dev/privacy/"
16
28
  }
package/README.md CHANGED
@@ -6,18 +6,18 @@ Check whether domains are available, compare the first payment and renewal acros
6
6
 
7
7
  Requires Node.js 20 or later.
8
8
 
9
- ### Works now (from GitHub)
9
+ ### Install
10
10
 
11
11
  **Claude Code**
12
12
 
13
13
  ```sh
14
- claude mcp add domain-hound -- npx -y github:lars-hv/domain-hound
14
+ claude mcp add domain-hound -- npx -y domain-hound
15
15
  ```
16
16
 
17
17
  **Codex**
18
18
 
19
19
  ```sh
20
- codex mcp add domain-hound -- npx -y github:lars-hv/domain-hound
20
+ codex mcp add domain-hound -- npx -y domain-hound
21
21
  ```
22
22
 
23
23
  **Other MCP clients**
@@ -29,22 +29,15 @@ Add this to the client’s MCP configuration for a local stdio server.
29
29
  "mcpServers": {
30
30
  "domain-hound": {
31
31
  "command": "npx",
32
- "args": ["-y", "github:lars-hv/domain-hound"]
32
+ "args": ["-y", "domain-hound"]
33
33
  }
34
34
  }
35
35
  }
36
36
  ```
37
37
 
38
- ### From npm (the default once published)
38
+ 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
39
 
40
- ```sh
41
- claude mcp add domain-hound -- npx -y domain-hound
42
- codex mcp add domain-hound -- npx -y domain-hound
43
- ```
44
-
45
- For other MCP clients, use `"args": ["-y", "domain-hound"]` in the configuration above.
46
-
47
- For optional live shop quotes, run `npm install domain-hound playwright && npx playwright install chromium` in a project directory and start your MCP client there. The default install provides a **Check at shop** link for unconfirmed quotes.
40
+ 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.
48
41
 
49
42
  ## Tools
50
43
 
@@ -54,7 +47,11 @@ For optional live shop quotes, run `npm install domain-hound playwright && npx p
54
47
 
55
48
  ## Privacy
56
49
 
57
- The server has no Domain Hound account or hosted backend. Lookups send the relevant name or domain to public sources. Domain searches use IANA and registry RDAP/WHOIS, public DNS, and registrar pricing and search pages. Name screening may also query the USPTO, Apple App Store, Google Play, Google Search and Trends, Wikidata, public company and package registries, social platforms, Tranco, Common Crawl, and candidate websites. If you configure a search provider via environment variables, queries can also go to Brave Search or Serper. Results may be cached locally.
50
+ The server has no Domain Hound account or hosted backend. Lookups 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 and package registries, social platforms, Tranco, Common Crawl, and candidate websites. If you configure a search provider via environment variables, queries can also go to Brave Search or Serper. Results may be cached locally.
51
+
52
+ ## Daily checks
53
+
54
+ Run `node scripts/canary.mjs` to check live registries, the Spotify name screen, and the public Dynadot and Porkbun price lists. It prints JSON with the status of each source and exits with a failure when a required check breaks. The GitHub Actions workflow is scheduled for 06:17 UTC and opens or updates an issue for each failing source.
58
55
 
59
56
  ## Releases
60
57
 
@@ -62,4 +59,6 @@ The server has no Domain Hound account or hosted backend. Lookups send the relev
62
59
 
63
60
  To refresh the bundled list prices before a release, run `npm run snapshot-prices`. It copies only the local `prices.json` price list.
64
61
 
62
+ 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
+
65
64
  [MIT license](LICENSE)
Binary file
Binary file
@@ -0,0 +1,14 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120">
2
+ <title>Snarl</title>
3
+ <path fill="#f4c64f" stroke="#05070d" stroke-width="4" stroke-linejoin="round" d="M5 79Q8 62 13 44Q15 29 29 23Q42 13 58 16L71 19L79 18L84 24L79 26L86 32L95 33L101 37L112 37Q118 38 117 46L112 56L103 58L97 67L87 61L77 59L66 64L76 70L86 76L99 77L105 71L105 82Q101 91 91 92Q80 93 69 86L55 75L49 74Q43 89 30 97Q20 105 13 102Q6 100 7 89Z"/>
4
+ <g fill="#05070d">
5
+ <path d="M8 87Q13 67 21 48Q27 32 39 28Q30 37 26 53Q20 74 8 94Z"/>
6
+ <path d="M18 99Q30 90 36 72Q41 56 39 43Q48 50 44 67Q40 88 25 98Z"/>
7
+ <path d="M45 23Q56 18 71 23L59 23L52 26Z"/>
8
+ <path d="M47 38L58 37L73 31L84 32L76 37L72 44L62 46L55 42Z"/>
9
+ <path d="M79 43L84 36L92 36L86 38ZM85 47L93 40L99 41L94 43Z"/>
10
+ <path d="M98 45L104 40L116 40Q118 45 111 52L102 53Z"/>
11
+ <path d="M46 59Q53 61 59 57L71 50Q79 45 88 48L97 53L108 53L103 58L98 62L88 57Q78 51 73 56L65 62L63 67L76 75Q84 82 97 80Q88 88 77 82L61 70Z"/>
12
+ </g>
13
+ <path fill="#f4c64f" d="M59 40L71 36L67 41L62 42ZM77 54L84 54L80 62ZM87 55L97 58L89 72L89 64ZM99 58L104 56L100 64Z"/>
14
+ </svg>
@@ -1,13 +1,13 @@
1
1
  import { setTimeout as delay } from 'node:timers/promises';
2
2
  import { cacheDir, readCache, writeCache } from './cache.mjs';
3
3
  import { money, shops, shopSearchUrl } from './prices.mjs';
4
- import { watchSpaceshipFeed } from './spaceship-feed.mjs';
5
4
 
6
5
  const budget = 20_500;
7
6
  const shopBudget = 10_000;
8
7
  const cacheLifetime = 15 * 60_000;
9
8
  const userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0 Safari/537.36';
10
- const dollars = String.raw`\$\s*(?:\d{1,3}(?:,\d{3})+|\d+)\.\d{2}`;
9
+ // Shops write whole-dollar prices without cents too ("$8" at Dynadot).
10
+ const dollars = String.raw`\$\s*(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d{2})?`;
11
11
  const priceLine = new RegExp('^' + dollars + '$');
12
12
  const dynadotPrices = new RegExp('^(?:' + dollars + '){1,2}$');
13
13
  const lastPrice = new RegExp(dollars + '$');
@@ -17,7 +17,8 @@ const namecheapPrice = new RegExp('^(' + dollars + ')/yr$', 'i');
17
17
  const namecheapRenewal = new RegExp('^Renews at (' + dollars + ')/yr\\.?$', 'i');
18
18
  const cloudflareQuote = new RegExp('^Buy now: ([a-z0-9.-]+) for (' + dollars + ')\\. Renews at (' + dollars + ') per year\\.$', 'i');
19
19
  const taken = /^(?:Taken|Registered in \d{4})$/i;
20
- const premiumLabel = /^(?:Premium|Premium domain)$/i;
20
+ // "Premium", "Premium domain", and Dynadot's "Registry Premium" for a price the registry sets.
21
+ const premiumLabel = /^(?:Registry\s+)?Premium(?:\s+(?:domain|name))?$/i;
21
22
  const trackerRoots = [
22
23
  'google-analytics.com', 'googletagmanager.com', 'doubleclick.net', 'googlesyndication.com',
23
24
  'facebook.net', 'facebook.com', 'nr-data.net', 'newrelic.com', 'crazyegg.com',
@@ -178,18 +179,6 @@ export function cloudflareSettlement(domain) {
178
179
  };
179
180
  }
180
181
 
181
- function watchCloudflare(page, domain) {
182
- const settlement = cloudflareSettlement(domain);
183
- page.on('websocket', socket => {
184
- const { origin, pathname } = new URL(socket.url());
185
- if (origin !== 'wss://search.registrar.cloudflare.com' || pathname !== '/v1/ws') return;
186
- socket.on('framereceived', ({ payload }) => {
187
- try { settlement.receive(JSON.parse(payload)); } catch { /* Unknown payload stays unconfirmed. */ }
188
- });
189
- });
190
- return settlement;
191
- }
192
-
193
182
  const adapters = {
194
183
  spaceship: {
195
184
  rows: '[data-zid="instantSearchMainResult"], [data-zid="instantSearchDomainListItem"]',
@@ -260,29 +249,21 @@ async function checkShop(page, shop, domain, deadline) {
260
249
  const adapter = Object.hasOwn(adapters, shop) ? adapters[shop] : null;
261
250
  if (!adapter) return unknown('Shop has no supported exact-domain result.');
262
251
  if (performance.now() >= deadline) return unknown(timedOut);
263
- const settlement = shop === 'cloudflare' ? watchCloudflare(page, domain) : null;
264
- const feed = shop === 'spaceship' ? await watchSpaceshipFeed(page, domain) : null;
265
252
  try {
266
253
  const response = await page.goto(url, { waitUntil: 'commit', timeout: remaining() });
267
254
  if ([401, 403, 429].includes(response?.status())) return unknown('Shop blocked the check.');
268
255
  if (!response?.ok()) return unknown('Shop search is unavailable.');
269
256
  while (performance.now() < deadline) {
270
257
  if (new URL(page.url()).origin !== origin) return unknown('Shop redirected the check.');
271
- const quote = feed?.read();
272
- if (quote) return quote;
273
258
  const result = await readResult(page, adapter, domain, remaining());
274
259
  if (blocked.test(result.pageStatus)) return unknown('Shop blocked the check.');
275
260
  if (shop === 'spaceship') {
276
261
  const quote = parseSpaceshipRows(result.rows, [domain]).get(domain);
277
262
  if (quote) return quote;
278
263
  } else {
279
- const final = settlement?.read();
280
- if (!settlement || final) {
281
- for (const row of result.rows) {
282
- const parsed = adapter.parse(row.text, domain, final?.premium ?? row.premium, row.buyLabel);
283
- if (parsed && !(parsed.available && row.canBuy === false) &&
284
- (!settlement || parsed.available === final.available)) return parsed;
285
- }
264
+ for (const row of result.rows) {
265
+ const parsed = adapter.parse(row.text, domain, row.premium, row.buyLabel);
266
+ if (parsed && !(parsed.available && row.canBuy === false)) return parsed;
286
267
  }
287
268
  }
288
269
  await delay(Math.min(200, remaining()));
@@ -290,8 +271,6 @@ async function checkShop(page, shop, domain, deadline) {
290
271
  return unknown(timedOut);
291
272
  } catch (error) {
292
273
  return unknown(error?.name === 'TimeoutError' ? timedOut : 'Shop search is unavailable.');
293
- } finally {
294
- await feed?.close();
295
274
  }
296
275
  }
297
276
 
@@ -426,5 +405,210 @@ export async function confirmDomain(shopValue, domain, options = {}) {
426
405
  const settled = options.usePage ? await run(options.usePage) : await withShopPages(deadline, run, options);
427
406
  const result = formatResult(start, domain, shop, settled.shop ?? shop, settled.result ?? settled, now);
428
407
  if (result.status === 'confirmed') await writeCache(directory, filename, result).catch(() => {});
408
+ if (result.status === 'premium') await writeCache(directory, quoteFile(domain), result).catch(() => {});
429
409
  return result;
430
410
  }
411
+
412
+ // Light confirm uses documented read operations. Without a key, prices stay labelled as list prices.
413
+ // Spaceship: https://docs.spaceship.dev/ (domains:read) · Dynadot: https://www.dynadot.com/domain/api-commands (search).
414
+ const spaceshipApi = 'https://spaceship.dev/api/v1/domains/';
415
+ const dynadotApi = 'https://api.dynadot.com/api3.json';
416
+ const signalLifetime = 24 * 3_600_000;
417
+ const apiTimeout = 2500;
418
+
419
+ export function apiShops(env = process.env) {
420
+ return [
421
+ ...(env.DOMAIN_HOUND_SPACESHIP_KEY?.trim() && env.DOMAIN_HOUND_SPACESHIP_SECRET?.trim() ? ['spaceship'] : []),
422
+ ...(env.DOMAIN_HOUND_DYNADOT_KEY?.trim() ? ['dynadot'] : []),
423
+ ];
424
+ }
425
+
426
+ const cents = value => Math.round(value * 100) / 100;
427
+
428
+ // The yearly USD price of the shortest documented period.
429
+ function yearly(entries) {
430
+ const rows = (Array.isArray(entries) ? entries : []).map(row => {
431
+ const years = row?.period?.unit === 'y' && Number.isSafeInteger(row.period.value) && row.period.value > 0
432
+ ? row.period.value : null;
433
+ const final = row?.priceInDefaultCurrency?.finalPrice;
434
+ const amount = final?.currency === 'USD' && typeof final.amount === 'string' ? money(final.amount) : null;
435
+ return years && amount > 0 ? { years, amount } : null;
436
+ }).filter(Boolean).sort((a, b) => a.years - b.years);
437
+ return rows[0] ? cents(rows[0].amount / rows[0].years) : null;
438
+ }
439
+
440
+ function apiQuote(shop, domain, fields, now) {
441
+ return { shop, shopName: shops[shop].name, domain, buyUrl: shopSearchUrl(shop, domain), checkedAt: now.toISOString(),
442
+ source: 'api', price: null, renewal: null, ...fields };
443
+ }
444
+
445
+ // Availability: result and premiumPricing. Pricing: priceClass and the register and renew price lists.
446
+ // premiumPricing marks a premium name even when it carries no price.
447
+ export function parseSpaceshipApi(availability, pricing, domains, now = new Date()) {
448
+ const quotes = new Map();
449
+ const find = (body, domain) => (Array.isArray(body?.domains) ? body.domains : [])
450
+ .find(row => typeof row?.domain === 'string' && row.domain.toLowerCase() === domain);
451
+ for (const domain of domains) {
452
+ const open = find(availability, domain);
453
+ if (typeof open?.result !== 'string') continue;
454
+ if (open.result !== 'available') {
455
+ const status = ['reserved', 'taken'].includes(open.result) ? open.result : 'could-not-confirm';
456
+ quotes.set(domain, apiQuote('spaceship', domain, { status, available: status === 'could-not-confirm' ? null : false,
457
+ reason: 'Not offered for registration at Spaceship' }, now));
458
+ continue;
459
+ }
460
+ const priced = find(pricing, domain);
461
+ const marked = Array.isArray(open.premiumPricing) && open.premiumPricing.length > 0;
462
+ const premiumClass = priced?.priceClass === 'premium';
463
+ if (marked || premiumClass) {
464
+ const listed = marked ? money(open.premiumPricing.find(row => row?.operation === 'register' && row.currency === 'USD')?.price) : null;
465
+ // Availability does not specify a term. Price multi-year endings from the pricing endpoint only.
466
+ const price = (premiumClass ? yearly(priced.prices?.register) : null)
467
+ ?? (!domain.endsWith('.ai') && listed > 0 ? listed : null);
468
+ quotes.set(domain, apiQuote('spaceship', domain, { status: 'premium', available: true, premium: true, price,
469
+ renewal: price != null && premiumClass ? yearly(priced.prices?.renew) : null }, now));
470
+ continue;
471
+ }
472
+ const price = priced?.priceClass === 'standard' ? yearly(priced.prices?.register) : null;
473
+ const renewal = priced?.priceClass === 'standard' ? yearly(priced.prices?.renew) : null;
474
+ quotes.set(domain, price > 0 && renewal > 0
475
+ ? apiQuote('spaceship', domain, { status: 'confirmed', available: true, premium: false, standard: true, price, renewal }, now)
476
+ : apiQuote('spaceship', domain, { status: 'could-not-confirm', available: null, premium: false,
477
+ reason: 'Spaceship gave no explicit standard price' }, now));
478
+ }
479
+ return quotes;
480
+ }
481
+
482
+ // Dynadot search with show_price=1: "Price": "77.00 in USD", optionally "... and domain is not premium".
483
+ // Without a marker, a price that matches Dynadot's own list price is standard; any other price may be premium.
484
+ export function parseDynadotSearch(body, domain, list = null, now = new Date()) {
485
+ const response = body?.SearchResponse;
486
+ if (String(response?.ResponseCode) !== '0' || !Array.isArray(response.SearchResults)) return null;
487
+ const row = response.SearchResults.find(item => String(item?.DomainName ?? '').toLowerCase() === domain);
488
+ if (!row || row.Error) return null;
489
+ const available = String(row.Available ?? '').toLowerCase();
490
+ if (available === 'no') {
491
+ return apiQuote('dynadot', domain, { status: 'could-not-confirm', available: null,
492
+ reason: 'Not offered for registration at Dynadot' }, now);
493
+ }
494
+ if (available !== 'yes') return null;
495
+ const text = String(row.Price ?? '');
496
+ const price = money(text.match(/^\s*(\d[\d,]*(?:\.\d{1,2})?) in USD\b/i)?.[1]?.replace(/,/g, ''));
497
+ const twoYears = domain.endsWith('.ai');
498
+ const marker = /\bis not premium\b/i.test(text) ? false : /\bpremium\b/i.test(text) ? true : null;
499
+ if (marker) return apiQuote('dynadot', domain, { status: 'premium', available: true, premium: true,
500
+ price: !twoYears && price > 0 ? price : null }, now);
501
+ if (!(price > 0)) return null;
502
+ // The legacy response gives one amount with no term or renewal. A list match can disambiguate .ai.
503
+ const yearsMatch = list && (twoYears ? [1, 2] : [1]).find(years => Math.abs(price - cents(list.firstYear * years)) < 0.011);
504
+ if (yearsMatch || marker === false && !twoYears) {
505
+ const yearlyPrice = yearsMatch ? list.firstYear : price;
506
+ return apiQuote('dynadot', domain, { status: 'confirmed', available: true, premium: false, standard: marker === false || undefined,
507
+ price: yearlyPrice }, now);
508
+ }
509
+ return apiQuote('dynadot', domain, { status: 'premium', available: true, premium: 'possible',
510
+ price: twoYears ? null : price }, now);
511
+ }
512
+
513
+ async function postJson(fetcher, url, body, headers, timeout) {
514
+ const response = await fetcher(url, { method: 'POST', redirect: 'error', signal: AbortSignal.timeout(timeout),
515
+ headers: { 'Content-Type': 'application/json', Accept: 'application/json', ...headers }, body: JSON.stringify(body) });
516
+ if (!response.ok) {
517
+ await response.body?.cancel().catch(() => {});
518
+ throw new Error('HTTP ' + response.status);
519
+ }
520
+ return response.json();
521
+ }
522
+
523
+ async function spaceshipQuotes(domains, { env, fetcher, timeout, now }) {
524
+ const headers = { 'X-API-Key': env.DOMAIN_HOUND_SPACESHIP_KEY.trim(), 'X-API-Secret': env.DOMAIN_HOUND_SPACESHIP_SECRET.trim() };
525
+ const [availability, pricing] = await Promise.all([
526
+ postJson(fetcher, spaceshipApi + 'available', { domains }, headers, timeout),
527
+ postJson(fetcher, spaceshipApi + 'pricing/query', { domains }, headers, timeout).catch(() => null),
528
+ ]);
529
+ return parseSpaceshipApi(availability, pricing, domains, now);
530
+ }
531
+
532
+ async function dynadotQuotes(domains, { env, fetcher, timeout, now, listFor, deadline }) {
533
+ const quotes = new Map();
534
+ // A regular Dynadot account checks one domain per command and one request at a time.
535
+ for (const domain of domains) {
536
+ const wait = Math.min(timeout, Math.floor(deadline - performance.now()));
537
+ if (wait < 300) break;
538
+ const url = dynadotApi + '?' + new URLSearchParams({ key: env.DOMAIN_HOUND_DYNADOT_KEY.trim(), command: 'search',
539
+ domain0: domain, show_price: '1', currency: 'USD' });
540
+ try {
541
+ const response = await fetcher(url, { redirect: 'error', signal: AbortSignal.timeout(wait), headers: { Accept: 'application/json' } });
542
+ if (!response.ok) { await response.body?.cancel().catch(() => {}); continue; }
543
+ const quote = parseDynadotSearch(await response.json(), domain, listFor(domain, 'dynadot'), now);
544
+ if (quote) quotes.set(domain, quote);
545
+ } catch { /* One failed check leaves that domain at its list price. */ }
546
+ }
547
+ return quotes;
548
+ }
549
+
550
+ const quoteFile = domain => 'quote-' + domain + '.json';
551
+
552
+ // Premium and reserved answers are kept for a day; a standard quote for 15 minutes.
553
+ function usableQuote(saved, domain, now) {
554
+ const age = now - Date.parse(saved?.checkedAt);
555
+ if (saved?.domain !== domain || !(age >= 0)) return false;
556
+ if (['premium', 'reserved'].includes(saved.status)) return age < signalLifetime;
557
+ return saved.status === 'confirmed' && money(saved.price) > 0 && age < cacheLifetime;
558
+ }
559
+
560
+ export async function cachedSignals(domains, { directory, now = new Date() } = {}) {
561
+ const folder = directory === undefined ? cacheDir : directory;
562
+ const found = new Map();
563
+ if (!folder) return found;
564
+ await Promise.all(domains.map(async domain => {
565
+ const saved = await readCache(folder, quoteFile(domain));
566
+ if (usableQuote(saved, domain, now) && ['premium', 'reserved'].includes(saved.status)) found.set(domain, saved);
567
+ }));
568
+ return found;
569
+ }
570
+
571
+ // Combine the shops: any premium or reserved answer wins; otherwise the cheapest explicit standard quote.
572
+ function combine(answers) {
573
+ const known = answers.filter(Boolean);
574
+ const premium = known.filter(quote => quote.status === 'premium');
575
+ if (premium.length) {
576
+ const explicit = premium.filter(quote => quote.premium === true);
577
+ const pool = explicit.length ? explicit : premium;
578
+ return pool.find(quote => quote.price != null) ?? pool[0];
579
+ }
580
+ const confirmed = known.filter(quote => quote.status === 'confirmed').sort((a, b) => a.price - b.price);
581
+ return confirmed[0] ?? known.find(quote => ['taken', 'reserved'].includes(quote.status)) ?? known[0] ?? null;
582
+ }
583
+
584
+ export async function lightConfirm(domains, {
585
+ env = process.env, fetcher = globalThis.fetch, directory, now = new Date(), deadline = performance.now() + 3000,
586
+ listFor = () => null,
587
+ } = {}) {
588
+ const folder = directory === undefined ? cacheDir : directory;
589
+ const results = new Map();
590
+ const wanted = [...new Set(domains)].slice(0, 20);
591
+ const pending = [];
592
+ for (const domain of wanted) {
593
+ const saved = folder ? await readCache(folder, quoteFile(domain)) : null;
594
+ if (usableQuote(saved, domain, now)) results.set(domain, { ...saved, cached: true });
595
+ else pending.push(domain);
596
+ }
597
+ const keyed = apiShops(env);
598
+ const timeout = Math.min(apiTimeout, Math.floor(deadline - performance.now()));
599
+ if (!pending.length || !keyed.length || timeout < 300) return results;
600
+ const context = { env, fetcher, timeout, now, listFor, deadline };
601
+ const [spaceship, dynadot] = await Promise.all([
602
+ keyed.includes('spaceship') ? spaceshipQuotes(pending, context).catch(() => new Map()) : new Map(),
603
+ keyed.includes('dynadot') ? dynadotQuotes(pending, context) : new Map(),
604
+ ]);
605
+ for (const domain of pending) {
606
+ const quote = combine([spaceship.get(domain), dynadot.get(domain)]);
607
+ if (!quote) continue;
608
+ results.set(domain, quote);
609
+ if (folder && ['confirmed', 'premium', 'reserved'].includes(quote.status)) {
610
+ await writeCache(folder, quoteFile(domain), quote).catch(() => {});
611
+ }
612
+ }
613
+ return results;
614
+ }
@@ -175,7 +175,7 @@ export async function searchAndroidApps(names, options = {}) {
175
175
  finally { await source?.close?.(); }
176
176
  }
177
177
  });
178
- if (pending.length) {
178
+ if (pending.length && performance.now() < deadline) {
179
179
  let browserReady = false;
180
180
  let browserFailed = false;
181
181
  await withShopPages(deadline, async (_, openPage) => {