domain-hound 0.1.4 → 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 +29 -7
- package/assets/readme-search.png +0 -0
- package/clis/domain-check/handles.mjs +337 -0
- package/clis/domain-check/index.mjs +12 -6
- package/clis/domain-check/name-search.mjs +13 -5
- 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 +2 -2
- package/clis/domain-check/triage-sources.mjs +13 -52
- package/clis/domain-check/triage.mjs +120 -42
- package/display.mjs +7 -4
- package/package.json +17 -4
- package/plugin.json +1 -1
- package/results.mjs +85 -21
- package/server.json +3 -3
- package/server.mjs +109 -18
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"checkedAt": "2026-11-
|
|
2
|
+
"checkedAt": "2026-11-25T09:07:26.876Z",
|
|
3
3
|
"catalogs": {
|
|
4
4
|
"spaceship": {
|
|
5
5
|
"checkedAt": "2026-11-24T18:15:47.403Z",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
"porkbun": {
|
|
58
|
-
"checkedAt": "2026-11-
|
|
58
|
+
"checkedAt": "2026-11-25T09:07:26.876Z",
|
|
59
59
|
"prices": {
|
|
60
60
|
"com": {
|
|
61
61
|
"shop": "Porkbun",
|
|
@@ -104,11 +104,77 @@
|
|
|
104
104
|
"firstYear": 19.95,
|
|
105
105
|
"renewal": 17.13,
|
|
106
106
|
"transfer": null
|
|
107
|
+
},
|
|
108
|
+
"net": {
|
|
109
|
+
"shop": "Porkbun",
|
|
110
|
+
"firstYear": 12.52,
|
|
111
|
+
"renewal": 12.52,
|
|
112
|
+
"transfer": 12.52
|
|
113
|
+
},
|
|
114
|
+
"org": {
|
|
115
|
+
"shop": "Porkbun",
|
|
116
|
+
"firstYear": 7.98,
|
|
117
|
+
"renewal": 11.84,
|
|
118
|
+
"transfer": 11.84
|
|
119
|
+
},
|
|
120
|
+
"xyz": {
|
|
121
|
+
"shop": "Porkbun",
|
|
122
|
+
"firstYear": 1.29,
|
|
123
|
+
"renewal": 14.21,
|
|
124
|
+
"transfer": 14.21
|
|
125
|
+
},
|
|
126
|
+
"tech": {
|
|
127
|
+
"shop": "Porkbun",
|
|
128
|
+
"firstYear": 6.99,
|
|
129
|
+
"renewal": 50.98,
|
|
130
|
+
"transfer": 50.98
|
|
131
|
+
},
|
|
132
|
+
"sh": {
|
|
133
|
+
"shop": "Porkbun",
|
|
134
|
+
"firstYear": 31.2,
|
|
135
|
+
"renewal": 46.65,
|
|
136
|
+
"transfer": 46.65
|
|
137
|
+
},
|
|
138
|
+
"gg": {
|
|
139
|
+
"shop": "Porkbun",
|
|
140
|
+
"firstYear": 51.8,
|
|
141
|
+
"renewal": 51.8,
|
|
142
|
+
"transfer": 51.8
|
|
143
|
+
},
|
|
144
|
+
"studio": {
|
|
145
|
+
"shop": "Porkbun",
|
|
146
|
+
"firstYear": 11.84,
|
|
147
|
+
"renewal": 41.71,
|
|
148
|
+
"transfer": 41.71
|
|
149
|
+
},
|
|
150
|
+
"de": {
|
|
151
|
+
"shop": "Porkbun",
|
|
152
|
+
"firstYear": 2.9,
|
|
153
|
+
"renewal": 4.07,
|
|
154
|
+
"transfer": 5.1
|
|
155
|
+
},
|
|
156
|
+
"uk": {
|
|
157
|
+
"shop": "Porkbun",
|
|
158
|
+
"firstYear": 5.66,
|
|
159
|
+
"renewal": 5.66,
|
|
160
|
+
"transfer": null
|
|
161
|
+
},
|
|
162
|
+
"co.uk": {
|
|
163
|
+
"shop": "Porkbun",
|
|
164
|
+
"firstYear": 5.66,
|
|
165
|
+
"renewal": 5.66,
|
|
166
|
+
"transfer": null
|
|
167
|
+
},
|
|
168
|
+
"eu": {
|
|
169
|
+
"shop": "Porkbun",
|
|
170
|
+
"firstYear": 5.88,
|
|
171
|
+
"renewal": 5.88,
|
|
172
|
+
"transfer": 5.88
|
|
107
173
|
}
|
|
108
174
|
}
|
|
109
175
|
},
|
|
110
176
|
"dynadot": {
|
|
111
|
-
"checkedAt": "2026-11-
|
|
177
|
+
"checkedAt": "2026-11-25T08:46:38.737Z",
|
|
112
178
|
"prices": {
|
|
113
179
|
"com": {
|
|
114
180
|
"shop": "Dynadot",
|
|
@@ -116,6 +182,18 @@
|
|
|
116
182
|
"renewal": 11.62,
|
|
117
183
|
"transfer": 11.62
|
|
118
184
|
},
|
|
185
|
+
"xyz": {
|
|
186
|
+
"shop": "Dynadot",
|
|
187
|
+
"firstYear": 1.5,
|
|
188
|
+
"renewal": 14.45,
|
|
189
|
+
"transfer": 14.45
|
|
190
|
+
},
|
|
191
|
+
"org": {
|
|
192
|
+
"shop": "Dynadot",
|
|
193
|
+
"firstYear": 7.99,
|
|
194
|
+
"renewal": 11.64,
|
|
195
|
+
"transfer": 11.64
|
|
196
|
+
},
|
|
119
197
|
"co": {
|
|
120
198
|
"shop": "Dynadot",
|
|
121
199
|
"firstYear": 15.5,
|
|
@@ -128,11 +206,41 @@
|
|
|
128
206
|
"renewal": 53.5,
|
|
129
207
|
"transfer": 53.5
|
|
130
208
|
},
|
|
209
|
+
"net": {
|
|
210
|
+
"shop": "Dynadot",
|
|
211
|
+
"firstYear": 7.49,
|
|
212
|
+
"renewal": 12.52,
|
|
213
|
+
"transfer": 12.52
|
|
214
|
+
},
|
|
131
215
|
"me": {
|
|
132
216
|
"shop": "Dynadot",
|
|
133
|
-
"firstYear": 9.
|
|
134
|
-
"renewal": 16.
|
|
135
|
-
"transfer": 16.
|
|
217
|
+
"firstYear": 9.21,
|
|
218
|
+
"renewal": 16.88,
|
|
219
|
+
"transfer": 16.88
|
|
220
|
+
},
|
|
221
|
+
"tech": {
|
|
222
|
+
"shop": "Dynadot",
|
|
223
|
+
"firstYear": 6.64,
|
|
224
|
+
"renewal": 52.65,
|
|
225
|
+
"transfer": 52.65
|
|
226
|
+
},
|
|
227
|
+
"eu": {
|
|
228
|
+
"shop": "Dynadot",
|
|
229
|
+
"firstYear": 4.21,
|
|
230
|
+
"renewal": 6.05,
|
|
231
|
+
"transfer": 6.05
|
|
232
|
+
},
|
|
233
|
+
"uk": {
|
|
234
|
+
"shop": "Dynadot",
|
|
235
|
+
"firstYear": 6.14,
|
|
236
|
+
"renewal": 6.14,
|
|
237
|
+
"transfer": null
|
|
238
|
+
},
|
|
239
|
+
"de": {
|
|
240
|
+
"shop": "Dynadot",
|
|
241
|
+
"firstYear": 3.84,
|
|
242
|
+
"renewal": 3.84,
|
|
243
|
+
"transfer": 3.84
|
|
136
244
|
},
|
|
137
245
|
"so": {
|
|
138
246
|
"shop": "Dynadot",
|
|
@@ -146,6 +254,18 @@
|
|
|
146
254
|
"renewal": 14.5,
|
|
147
255
|
"transfer": 13.99
|
|
148
256
|
},
|
|
257
|
+
"sh": {
|
|
258
|
+
"shop": "Dynadot",
|
|
259
|
+
"firstYear": 32.1,
|
|
260
|
+
"renewal": 48.15,
|
|
261
|
+
"transfer": 48.15
|
|
262
|
+
},
|
|
263
|
+
"studio": {
|
|
264
|
+
"shop": "Dynadot",
|
|
265
|
+
"firstYear": 11.99,
|
|
266
|
+
"renewal": 43.02,
|
|
267
|
+
"transfer": 43.02
|
|
268
|
+
},
|
|
149
269
|
"dev": {
|
|
150
270
|
"shop": "Dynadot",
|
|
151
271
|
"firstYear": 8,
|
|
@@ -158,16 +278,28 @@
|
|
|
158
278
|
"renewal": 85.6,
|
|
159
279
|
"transfer": 171.2
|
|
160
280
|
},
|
|
281
|
+
"gg": {
|
|
282
|
+
"shop": "Dynadot",
|
|
283
|
+
"firstYear": 53.5,
|
|
284
|
+
"renewal": 53.5,
|
|
285
|
+
"transfer": 53.5
|
|
286
|
+
},
|
|
287
|
+
"dk": {
|
|
288
|
+
"shop": "Dynadot",
|
|
289
|
+
"firstYear": 12.76,
|
|
290
|
+
"renewal": 12.76,
|
|
291
|
+
"transfer": 10.99
|
|
292
|
+
},
|
|
161
293
|
"si": {
|
|
162
294
|
"shop": "Dynadot",
|
|
163
|
-
"firstYear": 11.
|
|
164
|
-
"renewal": 11.
|
|
295
|
+
"firstYear": 11.29,
|
|
296
|
+
"renewal": 11.29,
|
|
165
297
|
"transfer": null
|
|
166
298
|
},
|
|
167
299
|
"no": {
|
|
168
300
|
"shop": "Dynadot",
|
|
169
|
-
"firstYear": 7.
|
|
170
|
-
"renewal": 7.
|
|
301
|
+
"firstYear": 7.97,
|
|
302
|
+
"renewal": 7.97,
|
|
171
303
|
"transfer": null
|
|
172
304
|
}
|
|
173
305
|
}
|
|
@@ -14,9 +14,95 @@ const rdapRateLimit = 'Registry RDAP returned HTTP 429';
|
|
|
14
14
|
// A rate-limited registry host is left alone for its Retry-After in this process and the next.
|
|
15
15
|
const legacyIdentityCooldown = 'rdap-identity-digital-cooldown.json';
|
|
16
16
|
const cooldownFile = origin => 'rdap-cooldown-' + new URL(origin).hostname + '.json';
|
|
17
|
+
|
|
18
|
+
export async function registryCooldown(origin, directory) {
|
|
19
|
+
const current = await readCache(directory, cooldownFile(origin));
|
|
20
|
+
const legacy = new URL(origin).origin === identityDigital ? await readCache(directory, legacyIdentityCooldown) : null;
|
|
21
|
+
return Math.max(current?.until || 0, legacy?.until || 0);
|
|
22
|
+
}
|
|
17
23
|
// The fallback steps (registry WHOIS, then DNS) keep this much of the lookup time.
|
|
18
24
|
const fallbackReserve = 800;
|
|
19
25
|
|
|
26
|
+
// Registry WHOIS servers as listed in the IANA Root Zone Database, so the fallback needs no whois.iana.org referral:
|
|
27
|
+
// https://www.iana.org/domains/root/db/ai.html, https://www.iana.org/domains/root/db/io.html and
|
|
28
|
+
// https://www.iana.org/domains/root/db/me.html (Identity Digital runs all three; checked 2026-11-25).
|
|
29
|
+
export const documentedWhois = new Map([
|
|
30
|
+
['ai', 'whois.nic.ai'],
|
|
31
|
+
['io', 'whois.nic.io'],
|
|
32
|
+
['me', 'whois.nic.me'],
|
|
33
|
+
]);
|
|
34
|
+
// Queries to one WHOIS host start at least this far apart. Identity Digital's hosts get the wider gap: they stand in
|
|
35
|
+
// for an RDAP service that is already rate limiting this machine.
|
|
36
|
+
export const whoisSpacing = { identity: 400, other: 150 };
|
|
37
|
+
// A WHOIS host that answers with a rate-limit notice is left alone this long, in this process and the next.
|
|
38
|
+
export const whoisCooldownMs = 15 * 60_000;
|
|
39
|
+
const whoisCooldownFile = host => 'whois-cooldown-' + host + '.json';
|
|
40
|
+
const whoisLimitWords = /\b(?:rate limit|limit exceeded|exceeded (?:the |your )?(?:query |request )?(?:limit|quota)|too many (?:queries|requests))\b/i;
|
|
41
|
+
const whoisTurns = new Map();
|
|
42
|
+
|
|
43
|
+
function whoisPacer(host) {
|
|
44
|
+
if (!whoisTurns.has(host)) whoisTurns.set(host, { nextStart: 0, limitedUntil: 0 });
|
|
45
|
+
return whoisTurns.get(host);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Run one registry query at a time per host, spacing starts on a monotonic clock.
|
|
49
|
+
async function queryRegistryWhois(host, domain, query, timeLeft, pause, directory) {
|
|
50
|
+
const pacer = whoisPacer(host);
|
|
51
|
+
if (!pacer.loaded) {
|
|
52
|
+
pacer.loaded = readCache(directory, whoisCooldownFile(host)).then(saved => {
|
|
53
|
+
pacer.limitedUntil = Math.max(pacer.limitedUntil, saved?.until || 0);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const previous = pacer.tail ?? Promise.resolve();
|
|
57
|
+
let release;
|
|
58
|
+
pacer.tail = new Promise(resolve => { release = resolve; });
|
|
59
|
+
try {
|
|
60
|
+
await Promise.all([pacer.loaded, previous]);
|
|
61
|
+
const spacing = [...documentedWhois.values()].includes(host) ? whoisSpacing.identity : whoisSpacing.other;
|
|
62
|
+
let waitForSlot = pause;
|
|
63
|
+
let timeout;
|
|
64
|
+
while (true) {
|
|
65
|
+
if (pacer.limitedUntil > Date.now()) return { reason: 'Registry WHOIS rate limit' };
|
|
66
|
+
const wait = Math.max(0, pacer.nextStart - performance.now());
|
|
67
|
+
const remaining = timeLeft();
|
|
68
|
+
// Leave at least 300 ms for the query itself, even after a late wake-up.
|
|
69
|
+
if (wait + 300 > remaining) return { reason: 'Registry WHOIS timed out' };
|
|
70
|
+
if (wait === 0) {
|
|
71
|
+
timeout = Math.min(1500, remaining);
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
await waitForSlot(Math.ceil(wait));
|
|
75
|
+
// An early wake-up still needs a timer until the slot opens.
|
|
76
|
+
waitForSlot = delay;
|
|
77
|
+
}
|
|
78
|
+
let response;
|
|
79
|
+
try {
|
|
80
|
+
response = query(host, domain, timeout);
|
|
81
|
+
} finally {
|
|
82
|
+
// Start the gap once the query has been dispatched, before waiting for its reply.
|
|
83
|
+
pacer.nextStart = performance.now() + spacing;
|
|
84
|
+
}
|
|
85
|
+
const reply = String(await response ?? '');
|
|
86
|
+
if (await whoisLimited(host, reply, directory)) return { reason: 'Registry WHOIS rate limit' };
|
|
87
|
+
return { reply };
|
|
88
|
+
} finally {
|
|
89
|
+
release();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async function whoisLimited(host, reply, directory) {
|
|
94
|
+
if (!whoisLimitWords.test(reply.split(/^\s*Terms of Use:/im, 1)[0])) return false;
|
|
95
|
+
const pacer = whoisPacer(host);
|
|
96
|
+
pacer.limitedUntil = Math.max(pacer.limitedUntil, Date.now() + whoisCooldownMs);
|
|
97
|
+
await writeCache(directory, whoisCooldownFile(host), { until: pacer.limitedUntil }).catch(() => {});
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// For tests: forget the pacing state of earlier lookups in this process.
|
|
102
|
+
export function resetWhoisPacing() {
|
|
103
|
+
whoisTurns.clear();
|
|
104
|
+
}
|
|
105
|
+
|
|
20
106
|
const overrides = new Map([
|
|
21
107
|
['co', 'https://rdap.registry.co/co/'],
|
|
22
108
|
['io', identityDigital + '/rdap/'],
|
|
@@ -26,6 +112,7 @@ const overrides = new Map([
|
|
|
26
112
|
]);
|
|
27
113
|
|
|
28
114
|
export function rdapBase(tld, services) {
|
|
115
|
+
if (tld === 'co.uk') tld = 'uk';
|
|
29
116
|
const urls = services?.find(([tlds]) => tlds.includes(tld))?.[1];
|
|
30
117
|
return overrides.get(tld) ?? urls?.find(url => url.startsWith('https://')) ?? urls?.[0];
|
|
31
118
|
}
|
|
@@ -170,23 +257,29 @@ export function systemQueryWhois(host, query, timeout) {
|
|
|
170
257
|
});
|
|
171
258
|
}
|
|
172
259
|
|
|
173
|
-
async function lookupWhois(domain, tld, query, timeLeft, referrals) {
|
|
174
|
-
if (
|
|
175
|
-
|
|
176
|
-
|
|
260
|
+
async function lookupWhois(domain, tld, query, timeLeft, referrals, { pause = delay, directory } = {}) {
|
|
261
|
+
if (tld === 'co.uk') tld = 'uk';
|
|
262
|
+
let host = documentedWhois.get(tld);
|
|
263
|
+
if (!host) {
|
|
264
|
+
if (!referrals.has(tld)) referrals.set(tld, query('whois.iana.org', tld, Math.min(1150, timeLeft())));
|
|
265
|
+
const iana = await referrals.get(tld);
|
|
266
|
+
host = iana.match(/^(?:refer|whois):[ \t]*([a-z\d.-]+)[ \t\r]*$/im)?.[1];
|
|
267
|
+
}
|
|
177
268
|
if (!host) return unknown('whois', 'IANA WHOIS has no registry referral');
|
|
178
|
-
const
|
|
179
|
-
if (
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
269
|
+
const { reply: result, reason } = await queryRegistryWhois(host, domain, query, timeLeft, pause, directory);
|
|
270
|
+
if (reason) return unknown('whois', reason);
|
|
271
|
+
const name = result.match(/^\s*Domain(?: Name)?:[ \t]*(\S+)/im)?.[1];
|
|
272
|
+
// DENIC and EURid echo the queried name on negative answers.
|
|
273
|
+
const statusFree = /^\s*Status:[ \t]*free\s*$/im.test(result)
|
|
274
|
+
|| tld === 'eu' && name?.toLowerCase() === domain && /^\s*Status:[ \t]*available\s*$/im.test(result);
|
|
275
|
+
if (name?.toLowerCase() === domain && !statusFree) {
|
|
183
276
|
const expiry = result.match(/^Registry Expiry Date:[ \t]*(\S+)/im)?.[1];
|
|
184
277
|
const expires = Number.isFinite(Date.parse(expiry)) ? new Date(expiry).toISOString() : null;
|
|
185
278
|
return { status: 'taken', source: 'whois', ...(expires && { expires }) };
|
|
186
279
|
}
|
|
187
280
|
const signal = registrySignal(result);
|
|
188
281
|
if (signal) return signalled('whois', signal);
|
|
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)) {
|
|
282
|
+
if (statusFree || /^\s*(?:(?:%|>>>|#)\s*)?(?:no (?:match|entries found|data found|object found)|(?:domain\s+)?not found|no such domain|the queried object does not exist|domain "[^"\s]+" not found)/im.test(result)) {
|
|
190
283
|
return { status: 'free', source: 'whois' };
|
|
191
284
|
}
|
|
192
285
|
return unknown('whois', 'Registry WHOIS returned no definitive answer');
|
|
@@ -343,9 +436,7 @@ export async function lookupRegistrations(candidates, {
|
|
|
343
436
|
const unsettled = [];
|
|
344
437
|
await Promise.all([...registries].map(async ([origin, registry]) => {
|
|
345
438
|
if (origin.startsWith('https:')) {
|
|
346
|
-
|
|
347
|
-
const legacy = origin === identityDigital ? await readCache(directory, legacyIdentityCooldown) : null;
|
|
348
|
-
registry.limitedUntil = Math.max(saved?.until || 0, legacy?.until || 0);
|
|
439
|
+
registry.limitedUntil = await registryCooldown(origin, directory);
|
|
349
440
|
}
|
|
350
441
|
return mapLimit(registry.jobs, registry.limit, async ({ base, entry }) => {
|
|
351
442
|
const row = await entry;
|
|
@@ -359,11 +450,13 @@ export async function lookupRegistrations(candidates, {
|
|
|
359
450
|
record(row, { ...cached.result, checkedAt: new Date(cached.at).toISOString() });
|
|
360
451
|
return;
|
|
361
452
|
}
|
|
362
|
-
const
|
|
363
|
-
|
|
453
|
+
const coolingDown = registry.identity && registry.limitedUntil > Date.now() && documentedWhois.has(tld) && fallbackWhois;
|
|
454
|
+
const result = coolingDown || !base && await services
|
|
455
|
+
? await lookupWhois(domain, tld, coolingDown ? fallbackWhois : whois, timeLeft, referrals, { pause, directory })
|
|
364
456
|
.catch(() => unknown('whois', 'Registry WHOIS did not respond'))
|
|
457
|
+
: base ? await lookupRdap(base, domain, fetcher, rdapLeft, readExpiry, pause, registry, rdapAttempts, directory)
|
|
365
458
|
: unknown('rdap', 'IANA RDAP bootstrap is unavailable');
|
|
366
|
-
if (result.status === 'unknown' && !result.signal) unsettled.push({ row, result, filename, viaWhois: !base });
|
|
459
|
+
if (result.status === 'unknown' && !result.signal) unsettled.push({ row, result, filename, viaWhois: !base || coolingDown });
|
|
367
460
|
else await finish(row, result, filename);
|
|
368
461
|
});
|
|
369
462
|
}));
|
|
@@ -375,7 +468,7 @@ export async function lookupRegistrations(candidates, {
|
|
|
375
468
|
const query = ['app', 'dev'].includes(tld) ? null : fallbackWhois;
|
|
376
469
|
const [answer, likely] = await Promise.all([
|
|
377
470
|
query && !viaWhois && timeLeft() > 600
|
|
378
|
-
? lookupWhois(domain, tld, query, () => timeLeft() - 300, referrals)
|
|
471
|
+
? lookupWhois(domain, tld, query, () => timeLeft() - 300, referrals, { pause, directory })
|
|
379
472
|
.catch(() => unknown('whois', 'Registry WHOIS did not respond')) : null,
|
|
380
473
|
dnsLikely(row),
|
|
381
474
|
]);
|
|
@@ -4,7 +4,7 @@ import { mkdir, open, readFile, rename, stat, unlink, writeFile } from 'node:fs/
|
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { inflateRawSync } from 'node:zlib';
|
|
6
6
|
import { cacheDir, mapLimit, readCache, writeCache } from './cache.mjs';
|
|
7
|
-
import { bootstrapUrl, rdapBase, rdapDomainUrl } from './registry.mjs';
|
|
7
|
+
import { bootstrapUrl, rdapBase, rdapDomainUrl, registryCooldown } from './registry.mjs';
|
|
8
8
|
import { compactText, day, letters, readJson, request } from './triage-sources.mjs';
|
|
9
9
|
|
|
10
10
|
// Every traction threshold lives in this table. Tuned with the strong, no-traction and some-traction
|
|
@@ -234,7 +234,7 @@ async function rdapServices(options) {
|
|
|
234
234
|
// The RDAP registration date, null when the registry gives none, or undefined when it did not answer.
|
|
235
235
|
export async function registeredOn(domain, options) {
|
|
236
236
|
const base = rdapBase(domain.split('.').at(-1), await rdapServices(options));
|
|
237
|
-
if (!base || options.timeLeft() < 300) return undefined;
|
|
237
|
+
if (!base || options.timeLeft() < 300 || await registryCooldown(base, options.directory) > Date.now()) return undefined;
|
|
238
238
|
try {
|
|
239
239
|
const response = await request(rdapDomainUrl(base, domain), options, {
|
|
240
240
|
timeout: Math.min(2500, options.timeLeft()), headers: { Accept: 'application/rdap+json, application/json' },
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { anySignal, cacheDir, readCache, writeCache } from './cache.mjs';
|
|
2
|
+
import { checkSocialHandles, handlePlatforms } from './handles.mjs';
|
|
2
3
|
|
|
3
4
|
const uspto = 'https://tmsearch.uspto.gov';
|
|
4
5
|
const githubState = 'triage-github-limit.json';
|
|
@@ -22,13 +23,8 @@ export const trademarkSearches = {
|
|
|
22
23
|
WIPO: 'https://branddb.wipo.int/',
|
|
23
24
|
Norway: 'https://search.patentstyret.no/',
|
|
24
25
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
npm: 'https://www.npmjs.com/package/{name}',
|
|
28
|
-
PyPI: 'https://pypi.org/project/{name}/',
|
|
29
|
-
X: 'https://x.com/{name}',
|
|
30
|
-
YouTube: 'https://www.youtube.com/@{name}',
|
|
31
|
-
};
|
|
26
|
+
// Handle pages in display order, with {name} for the handle.
|
|
27
|
+
export const handleSearches = Object.fromEntries(handlePlatforms.map(platform => [platform.id, platform.link('{name}')]));
|
|
32
28
|
|
|
33
29
|
// Latin letters for name matching: accents drop, and letters without a decomposition fold too (ø -> o, æ -> ae).
|
|
34
30
|
const folds = [[/æ/g, 'ae'], [/ø/g, 'o'], [/œ/g, 'oe'], [/ß/g, 'ss'], [/[đð]/g, 'd'], [/þ/g, 'th'], [/ł/g, 'l'], [/ı/g, 'i']];
|
|
@@ -225,13 +221,6 @@ async function fetchEntities(name, input, options) {
|
|
|
225
221
|
});
|
|
226
222
|
}
|
|
227
223
|
|
|
228
|
-
const handleUrls = {
|
|
229
|
-
npm: name => 'https://registry.npmjs.org/' + name,
|
|
230
|
-
PyPI: name => 'https://pypi.org/simple/' + name + '/',
|
|
231
|
-
X: name => 'https://x.com/' + name,
|
|
232
|
-
YouTube: name => 'https://www.youtube.com/@' + name,
|
|
233
|
-
};
|
|
234
|
-
|
|
235
224
|
async function searchGitHub(name, options) {
|
|
236
225
|
const { directory = cacheDir, now = new Date() } = options;
|
|
237
226
|
try {
|
|
@@ -269,16 +258,8 @@ async function searchGitHub(name, options) {
|
|
|
269
258
|
} catch { return { status: 'unknown' }; }
|
|
270
259
|
}
|
|
271
260
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
if (options.signal?.aborted) return 'unknown';
|
|
275
|
-
const response = await request(handleUrls[service](name), options, { redirect: 'manual', timeout: 2200 });
|
|
276
|
-
await response.body?.cancel();
|
|
277
|
-
if (response.status === 404) return 'free';
|
|
278
|
-
return response.status === 200 ? 'taken' : 'unknown';
|
|
279
|
-
} catch { return 'unknown'; }
|
|
280
|
-
}
|
|
281
|
-
|
|
261
|
+
// Same-name evidence from GitHub and npm: the account or package (GitHub users API, npm registry) and, for small
|
|
262
|
+
// screens, GitHub repositories with the name. options.social may carry this name's handle rows from a shared run.
|
|
282
263
|
export async function checkHandles(name, options = {}) {
|
|
283
264
|
const { directory = cacheDir, now = new Date() } = options;
|
|
284
265
|
const filename = 'triage-handles-' + name + '.json';
|
|
@@ -287,22 +268,11 @@ export async function checkHandles(name, options = {}) {
|
|
|
287
268
|
const age = now.getTime() - entry?.at;
|
|
288
269
|
return age >= 0 && age < day;
|
|
289
270
|
};
|
|
271
|
+
const social = options.social ? await options.social
|
|
272
|
+
: (await checkSocialHandles([{ name, platforms: ['GitHub', 'npm'], links: false }], options)).get(name);
|
|
273
|
+
const state = platform => social?.find(entry => entry.platform === platform)?.state ?? 'check';
|
|
290
274
|
const getGitHub = async () => {
|
|
291
|
-
|
|
292
|
-
if (!fresh(saved.githubProfile) || !['free', 'taken'].includes(status)) {
|
|
293
|
-
const profile = async () => {
|
|
294
|
-
try {
|
|
295
|
-
const response = await request(handleSearches.GitHub.replace('{name}', name), options, {
|
|
296
|
-
redirect: 'manual', timeout: 2200,
|
|
297
|
-
});
|
|
298
|
-
await response.body?.cancel();
|
|
299
|
-
return response.status === 200 ? 'taken' : response.status === 404 ? 'free' : 'unknown';
|
|
300
|
-
} catch { return 'unknown'; }
|
|
301
|
-
};
|
|
302
|
-
status = await profile();
|
|
303
|
-
if (status === 'unknown' && options.retryUnavailable && !options.signal?.aborted) status = await profile();
|
|
304
|
-
if (status !== 'unknown') saved.githubProfile = { status, at: now.getTime() };
|
|
305
|
-
}
|
|
275
|
+
const status = state('GitHub');
|
|
306
276
|
if (fresh(saved.githubSearch) && saved.githubSearch.result?.count !== undefined) {
|
|
307
277
|
return { ...saved.githubSearch.result, status };
|
|
308
278
|
}
|
|
@@ -311,18 +281,9 @@ export async function checkHandles(name, options = {}) {
|
|
|
311
281
|
githubTail = turn.catch(() => {});
|
|
312
282
|
const result = await turn;
|
|
313
283
|
if (result.count !== undefined) saved.githubSearch = { result, at: now.getTime() };
|
|
314
|
-
return { ...result, status: status === '
|
|
284
|
+
return { ...result, status: status === 'check' && result.status === 'taken' ? 'taken' : status };
|
|
315
285
|
};
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
let status = await checkHandle(service, name, options);
|
|
320
|
-
if (options.retryUnavailable && status === 'unknown' && !options.signal?.aborted) {
|
|
321
|
-
status = await checkHandle(service, name, options);
|
|
322
|
-
}
|
|
323
|
-
if (status === 'taken' || status === 'free') saved[service] = { status, at: now.getTime() };
|
|
324
|
-
return [service, status];
|
|
325
|
-
}))]);
|
|
326
|
-
await writeCache(directory, filename, saved).catch(() => {});
|
|
327
|
-
return { github, handles: { GitHub: github.status, ...Object.fromEntries(found) } };
|
|
286
|
+
const github = await getGitHub();
|
|
287
|
+
await writeCache(directory, filename, { githubSearch: saved.githubSearch }).catch(() => {});
|
|
288
|
+
return { github, handles: { GitHub: github.status, npm: state('npm') }, social };
|
|
328
289
|
}
|