@icoretech/warden-mcp 0.2.72 → 0.2.73
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/node_modules/tldts-core/dist/cjs/index.js +160 -34
- package/node_modules/tldts-core/dist/cjs/index.js.map +1 -1
- package/node_modules/tldts-core/dist/cjs/src/domain.js +1 -0
- package/node_modules/tldts-core/dist/cjs/src/domain.js.map +1 -1
- package/node_modules/tldts-core/dist/cjs/src/extract-hostname.js +61 -29
- package/node_modules/tldts-core/dist/cjs/src/extract-hostname.js.map +1 -1
- package/node_modules/tldts-core/dist/cjs/src/factory.js +12 -3
- package/node_modules/tldts-core/dist/cjs/src/factory.js.map +1 -1
- package/node_modules/tldts-core/dist/cjs/src/lookup/extra-suffixes.js +87 -0
- package/node_modules/tldts-core/dist/cjs/src/lookup/extra-suffixes.js.map +1 -0
- package/node_modules/tldts-core/dist/cjs/src/lookup/fast-path.js +3 -1
- package/node_modules/tldts-core/dist/cjs/src/lookup/fast-path.js.map +1 -1
- package/node_modules/tldts-core/dist/cjs/src/options.js +2 -1
- package/node_modules/tldts-core/dist/cjs/src/options.js.map +1 -1
- package/node_modules/tldts-core/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/node_modules/tldts-core/dist/es6/src/domain.js +1 -1
- package/node_modules/tldts-core/dist/es6/src/domain.js.map +1 -1
- package/node_modules/tldts-core/dist/es6/src/extract-hostname.js +61 -29
- package/node_modules/tldts-core/dist/es6/src/extract-hostname.js.map +1 -1
- package/node_modules/tldts-core/dist/es6/src/factory.js +12 -3
- package/node_modules/tldts-core/dist/es6/src/factory.js.map +1 -1
- package/node_modules/tldts-core/dist/es6/src/lookup/extra-suffixes.js +84 -0
- package/node_modules/tldts-core/dist/es6/src/lookup/extra-suffixes.js.map +1 -0
- package/node_modules/tldts-core/dist/es6/src/lookup/fast-path.js +3 -1
- package/node_modules/tldts-core/dist/es6/src/lookup/fast-path.js.map +1 -1
- package/node_modules/tldts-core/dist/es6/src/options.js +2 -1
- package/node_modules/tldts-core/dist/es6/src/options.js.map +1 -1
- package/node_modules/tldts-core/dist/es6/tsconfig.bundle.tsbuildinfo +1 -1
- package/node_modules/tldts-core/dist/types/src/domain.d.ts +12 -0
- package/node_modules/tldts-core/dist/types/src/factory.d.ts +1 -1
- package/node_modules/tldts-core/dist/types/src/lookup/extra-suffixes.d.ts +10 -0
- package/node_modules/tldts-core/dist/types/src/options.d.ts +4 -0
- package/node_modules/tldts-core/package.json +2 -2
- package/node_modules/tldts-core/src/domain.ts +4 -1
- package/node_modules/tldts-core/src/extract-hostname.ts +68 -29
- package/node_modules/tldts-core/src/factory.ts +13 -4
- package/node_modules/tldts-core/src/lookup/extra-suffixes.ts +98 -0
- package/node_modules/tldts-core/src/lookup/fast-path.ts +5 -1
- package/node_modules/tldts-core/src/options.ts +7 -0
- package/node_modules/ws/README.md +2 -3
- package/node_modules/ws/lib/receiver.js +8 -0
- package/node_modules/ws/lib/websocket-server.js +3 -0
- package/node_modules/ws/lib/websocket.js +58 -13
- package/node_modules/ws/package.json +1 -1
- package/package.json +3 -3
|
@@ -190,35 +190,52 @@ function extractHostname(url, urlIsValidHostname, validate = false) {
|
|
|
190
190
|
let start = 0;
|
|
191
191
|
let end = url.length;
|
|
192
192
|
let hasUpper = false;
|
|
193
|
-
let isSpecial =
|
|
193
|
+
let isSpecial = true; // '\' ends the host, unless non-special "scheme://"
|
|
194
194
|
extractedHostnameValidated = false;
|
|
195
195
|
if (!urlIsValidHostname) {
|
|
196
|
-
// Data URLs never carry a host (and may be huge — short-circuit them).
|
|
197
|
-
if (url.startsWith('data:')) {
|
|
198
|
-
return null;
|
|
199
|
-
}
|
|
200
196
|
// WHATWG step 1: trim leading/trailing C0 control or space (<= U+0020).
|
|
201
197
|
// Tab/newline elsewhere are handled lazily below.
|
|
202
198
|
while (start < url.length && url.charCodeAt(start) <= 32) {
|
|
203
199
|
start += 1;
|
|
204
200
|
}
|
|
201
|
+
// "data:"/"javascript:" never reach a host (inline payload; data URLs may be
|
|
202
|
+
// huge). `| 32` lowercases letters only; tab/newline is re-parsed below.
|
|
203
|
+
if ((url.charCodeAt(start + 4) === 58 /* ':' */ &&
|
|
204
|
+
(url.charCodeAt(start) | 32) === 100 /* d */ &&
|
|
205
|
+
(url.charCodeAt(start + 1) | 32) === 97 /* a */ &&
|
|
206
|
+
(url.charCodeAt(start + 2) | 32) === 116 /* t */ &&
|
|
207
|
+
(url.charCodeAt(start + 3) | 32) === 97) /* a */ ||
|
|
208
|
+
(url.charCodeAt(start + 10) === 58 /* ':' */ &&
|
|
209
|
+
(url.charCodeAt(start) | 32) === 106 /* j */ &&
|
|
210
|
+
(url.charCodeAt(start + 1) | 32) === 97 /* a */ &&
|
|
211
|
+
(url.charCodeAt(start + 2) | 32) === 118 /* v */ &&
|
|
212
|
+
(url.charCodeAt(start + 3) | 32) === 97 /* a */ &&
|
|
213
|
+
(url.charCodeAt(start + 4) | 32) === 115 /* s */ &&
|
|
214
|
+
(url.charCodeAt(start + 5) | 32) === 99 /* c */ &&
|
|
215
|
+
(url.charCodeAt(start + 6) | 32) === 114 /* r */ &&
|
|
216
|
+
(url.charCodeAt(start + 7) | 32) === 105 /* i */ &&
|
|
217
|
+
(url.charCodeAt(start + 8) | 32) === 112 /* p */ &&
|
|
218
|
+
(url.charCodeAt(start + 9) | 32) === 116) /* t */) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
205
221
|
while (end > start + 1 && url.charCodeAt(end - 1) <= 32) {
|
|
206
222
|
end -= 1;
|
|
207
223
|
}
|
|
208
|
-
if (url.charCodeAt(start) === 47 /* '/' */
|
|
209
|
-
url.charCodeAt(start
|
|
224
|
+
if ((url.charCodeAt(start) === 47 /* '/' */ ||
|
|
225
|
+
url.charCodeAt(start) === 92) /* '\' */ &&
|
|
226
|
+
(url.charCodeAt(start + 1) === 47 /* '/' */ ||
|
|
227
|
+
url.charCodeAt(start + 1) === 92) /* '\' */) {
|
|
210
228
|
// Scheme-relative reference ("//host/path").
|
|
211
229
|
start += 2;
|
|
212
230
|
}
|
|
213
231
|
else {
|
|
214
|
-
|
|
232
|
+
let indexOfProtocol = url.indexOf(':/', start);
|
|
215
233
|
if (indexOfProtocol !== -1) {
|
|
216
234
|
// "scheme://…". Classify the scheme, then position `start` at the host.
|
|
217
235
|
const special = getSpecialScheme(url, start, indexOfProtocol);
|
|
218
236
|
if (special === 1) {
|
|
219
237
|
// Special scheme: skip the run of '/' and '\' after it
|
|
220
238
|
// (special-authority-(ignore-)slashes states; '\' acts as '/').
|
|
221
|
-
isSpecial = true;
|
|
222
239
|
start = indexOfProtocol + 2;
|
|
223
240
|
while (url.charCodeAt(start) === 47 /* '/' */ ||
|
|
224
241
|
url.charCodeAt(start) === 92 /* '\' */) {
|
|
@@ -228,7 +245,6 @@ function extractHostname(url, urlIsValidHostname, validate = false) {
|
|
|
228
245
|
else if (special === 2) {
|
|
229
246
|
// file: the host is only what sits between "//" and the next slash, so
|
|
230
247
|
// "file://h/x" => "h" but "file:///x" / "file:/x" => no host.
|
|
231
|
-
isSpecial = true;
|
|
232
248
|
start = indexOfProtocol + 1;
|
|
233
249
|
let slashes = 0;
|
|
234
250
|
while ((url.charCodeAt(start) === 47 || url.charCodeAt(start) === 92) &&
|
|
@@ -244,35 +260,52 @@ function extractHostname(url, urlIsValidHostname, validate = false) {
|
|
|
244
260
|
// Unknown scheme: validate the WHATWG scheme grammar [A-Za-z0-9+.-];
|
|
245
261
|
// a control char means it was split by a tab/newline (strip + re-parse).
|
|
246
262
|
for (let i = start; i < indexOfProtocol; i += 1) {
|
|
247
|
-
const code = url.charCodeAt(i)
|
|
248
|
-
if (!((code >= 97 && code <= 122) || // [a
|
|
263
|
+
const code = url.charCodeAt(i);
|
|
264
|
+
if (!(((code | 32) >= 97 && (code | 32) <= 122) || // [a-zA-Z] (fold letters only)
|
|
249
265
|
(code >= 48 && code <= 57) || // [0, 9]
|
|
250
266
|
code === 46 || // '.'
|
|
251
267
|
code === 45 || // '-'
|
|
252
268
|
code === 43 // '+'
|
|
253
269
|
)) {
|
|
254
|
-
|
|
255
|
-
|
|
270
|
+
if (code === 9 /* tab */ ||
|
|
271
|
+
code === 10 /* LF */ ||
|
|
272
|
+
code === 13 /* CR */) {
|
|
256
273
|
return extractHostname(url.replace(CONTROL_CHARS, ''), urlIsValidHostname, validate);
|
|
257
274
|
}
|
|
258
|
-
|
|
275
|
+
// A '/', '\', '?' or '#' first puts this ':/' in a path, query or
|
|
276
|
+
// fragment ("a.com/r?u=https://x"): re-read the input without it.
|
|
277
|
+
for (let j = i; j < indexOfProtocol; j += 1) {
|
|
278
|
+
const c = url.charCodeAt(j);
|
|
279
|
+
if (c === 47 || c === 92 || c === 63 || c === 35) {
|
|
280
|
+
indexOfProtocol = -1;
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (indexOfProtocol !== -1) {
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
break;
|
|
259
288
|
}
|
|
260
289
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
290
|
+
if (indexOfProtocol !== -1) {
|
|
291
|
+
// A non-special scheme has an authority only after "//" (else it is
|
|
292
|
+
// an opaque path with no host). `indexOf(':/')` already gave the
|
|
293
|
+
// first '/'.
|
|
294
|
+
if (url.charCodeAt(indexOfProtocol + 2) === 47 /* '/' */) {
|
|
295
|
+
isSpecial = false;
|
|
296
|
+
start = indexOfProtocol + 3;
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
268
301
|
}
|
|
269
302
|
}
|
|
270
303
|
}
|
|
271
|
-
|
|
272
|
-
// Cold path: no scheme
|
|
273
|
-
// ':' would otherwise look like a scheme separator; "[…]" falls
|
|
274
|
-
// to the ipv6 handling below). May be a bare host, a host:port,
|
|
275
|
-
// user@host, a slash-less special scheme ("https:host"), or an opaque
|
|
304
|
+
if (indexOfProtocol === -1 && url.charCodeAt(start) !== 91 /* '[' */) {
|
|
305
|
+
// Cold path: no "scheme://" prefix, and not a bare IPv6 literal (whose
|
|
306
|
+
// first ':' would otherwise look like a scheme separator; "[…]" falls
|
|
307
|
+
// through to the ipv6 handling below). May be a bare host, a host:port,
|
|
308
|
+
// a user@host, a slash-less special scheme ("https:host"), or an opaque
|
|
276
309
|
// URI ("mailto:", "tel:", "urn:…").
|
|
277
310
|
let indexOfColon = -1;
|
|
278
311
|
for (let i = start; i < end; i += 1) {
|
|
@@ -323,7 +356,7 @@ function extractHostname(url, urlIsValidHostname, validate = false) {
|
|
|
323
356
|
if (!allDigits) {
|
|
324
357
|
const special = getSpecialScheme(url, start, indexOfColon);
|
|
325
358
|
if (special === 0) {
|
|
326
|
-
// No "://"
|
|
359
|
+
// No "scheme://" on the cold path and not a special scheme.
|
|
327
360
|
// A second ':' before the host's end marks a bare, unbracketed
|
|
328
361
|
// IPv6 literal ("2a01:e35::1"): fall through and let the host
|
|
329
362
|
// loop + isIp classify it. Without one this is an opaque path
|
|
@@ -347,7 +380,6 @@ function extractHostname(url, urlIsValidHostname, validate = false) {
|
|
|
347
380
|
}
|
|
348
381
|
}
|
|
349
382
|
else {
|
|
350
|
-
isSpecial = true;
|
|
351
383
|
start = indexOfColon + 1;
|
|
352
384
|
if (special === 2) {
|
|
353
385
|
// file (e.g. "file:\\host"): host only between "//" and next slash.
|
|
@@ -740,12 +772,96 @@ function isValidHostname (hostname) {
|
|
|
740
772
|
lastCharCode !== 45);
|
|
741
773
|
}
|
|
742
774
|
|
|
743
|
-
|
|
775
|
+
/**
|
|
776
|
+
* Apply `options.extraSuffixes` to the built-in lookup result in `out`, as if
|
|
777
|
+
* they were part of the list (`isException`: the built-in winner is an
|
|
778
|
+
* exception rule). As in browsers, the longest match prevails and an exception
|
|
779
|
+
* beats a rule of the same length. Remaining ties go to the built-in match
|
|
780
|
+
* (unless it matched no rule: both flags falsy), then to `icann`.
|
|
781
|
+
*/
|
|
782
|
+
function extraSuffixLookup(hostname, options, isException, out) {
|
|
783
|
+
const suffix = out.publicSuffix;
|
|
784
|
+
if (suffix === null) {
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
// Best extra exception and rule, as start indices in `hostname` (smaller is
|
|
788
|
+
// longer; `none` if unmatched), and whether each is ICANN.
|
|
789
|
+
const none = hostname.length + 1;
|
|
790
|
+
let exception = none;
|
|
791
|
+
let exceptionIsIcann = false;
|
|
792
|
+
let rule = none;
|
|
793
|
+
let ruleIsIcann = false;
|
|
794
|
+
const extra = options.extraSuffixes;
|
|
795
|
+
for (let section = 0; section < 2; section += 1) {
|
|
796
|
+
const isIcann = section === 0;
|
|
797
|
+
const rules = isIcann
|
|
798
|
+
? options.allowIcannDomains && extra.icann
|
|
799
|
+
: options.allowPrivateDomains && extra.private;
|
|
800
|
+
if (!Array.isArray(rules)) {
|
|
801
|
+
continue;
|
|
802
|
+
}
|
|
803
|
+
for (const r of rules) {
|
|
804
|
+
// Sparse or untyped lists may hold non-strings.
|
|
805
|
+
if (typeof r !== 'string') {
|
|
806
|
+
continue;
|
|
807
|
+
}
|
|
808
|
+
const exceptionRule = r.startsWith('!');
|
|
809
|
+
const wildcard = r.startsWith('*.');
|
|
810
|
+
const body = exceptionRule ? r.slice(1) : wildcard ? r.slice(2) : r;
|
|
811
|
+
// Skip empty rules, and exceptions without a parent ('!p').
|
|
812
|
+
if (body === '' ||
|
|
813
|
+
(exceptionRule && !body.includes('.')) ||
|
|
814
|
+
!shareSameDomainSuffix(hostname, body)) {
|
|
815
|
+
continue;
|
|
816
|
+
}
|
|
817
|
+
let start = hostname.length - body.length;
|
|
818
|
+
// Strict `<`: on a tie, the first match (`icann` first) wins.
|
|
819
|
+
if (exceptionRule) {
|
|
820
|
+
if (start < exception) {
|
|
821
|
+
exception = start;
|
|
822
|
+
exceptionIsIcann = isIcann;
|
|
823
|
+
}
|
|
824
|
+
continue;
|
|
825
|
+
}
|
|
826
|
+
// `*.p` also matches `p`, else one more non-empty label.
|
|
827
|
+
if (wildcard && start > 1 && hostname.charCodeAt(start - 2) !== 46) {
|
|
828
|
+
start = hostname.lastIndexOf('.', start - 2) + 1;
|
|
829
|
+
}
|
|
830
|
+
if (start < rule) {
|
|
831
|
+
rule = start;
|
|
832
|
+
ruleIsIcann = isIcann;
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
// Start of the built-in match: an exception starts one label left of its
|
|
837
|
+
// suffix.
|
|
838
|
+
const suffixStart = hostname.length - suffix.length;
|
|
839
|
+
const builtin = isException
|
|
840
|
+
? hostname.lastIndexOf('.', suffixStart - 2) + 1
|
|
841
|
+
: suffixStart;
|
|
842
|
+
// An exception wins ties with rules; a built-in exception wins ties with
|
|
843
|
+
// an extra one.
|
|
844
|
+
if (exception <= rule &&
|
|
845
|
+
(isException ? exception < builtin : exception <= builtin)) {
|
|
846
|
+
out.publicSuffix = hostname.slice(hostname.indexOf('.', exception) + 1);
|
|
847
|
+
out.isIcann = exceptionIsIcann;
|
|
848
|
+
out.isPrivate = !exceptionIsIcann;
|
|
849
|
+
}
|
|
850
|
+
else if (rule < builtin ||
|
|
851
|
+
(rule === builtin && !out.isIcann && !out.isPrivate)) {
|
|
852
|
+
out.publicSuffix = hostname.slice(rule);
|
|
853
|
+
out.isIcann = ruleIsIcann;
|
|
854
|
+
out.isPrivate = !ruleIsIcann;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
function setDefaultsImpl({ allowIcannDomains = true, allowPrivateDomains = false, detectIp = true, detectSpecialUse = false, extraSuffixes = null, extractHostname = true, mixedInputs = true, validHosts = null, validateHostname = true, }) {
|
|
744
859
|
return {
|
|
745
860
|
allowIcannDomains,
|
|
746
861
|
allowPrivateDomains,
|
|
747
862
|
detectIp,
|
|
748
863
|
detectSpecialUse,
|
|
864
|
+
extraSuffixes,
|
|
749
865
|
extractHostname,
|
|
750
866
|
mixedInputs,
|
|
751
867
|
validHosts,
|
|
@@ -823,7 +939,12 @@ function parseImpl(url, step, suffixLookup, partialOptions, result) {
|
|
|
823
939
|
// extractHostname returned `url` unchanged (same reference).
|
|
824
940
|
let urlIsValid = false;
|
|
825
941
|
if (!options.extractHostname) {
|
|
826
|
-
|
|
942
|
+
// Trim trailing dots as extractHostname does (`new URL()` keeps them).
|
|
943
|
+
let end = url.length;
|
|
944
|
+
while (end > 1 && url.charCodeAt(end - 1) === 46 /* '.' */) {
|
|
945
|
+
end -= 1;
|
|
946
|
+
}
|
|
947
|
+
result.hostname = end === url.length ? url : url.slice(0, end);
|
|
827
948
|
}
|
|
828
949
|
else if (options.mixedInputs) {
|
|
829
950
|
urlIsValid = isValidHostname(url);
|
|
@@ -866,8 +987,11 @@ function parseImpl(url, step, suffixLookup, partialOptions, result) {
|
|
|
866
987
|
if (step === 5 /* FLAG.ALL */ && options.detectSpecialUse) {
|
|
867
988
|
result.isSpecialUse = isSpecialUse(result.hostname);
|
|
868
989
|
}
|
|
869
|
-
// Extract public suffix
|
|
870
|
-
suffixLookup(result.hostname, options, result);
|
|
990
|
+
// Extract public suffix (`isException`: the winner is an exception rule)
|
|
991
|
+
const isException = suffixLookup(result.hostname, options, result);
|
|
992
|
+
if (options.extraSuffixes !== null) {
|
|
993
|
+
extraSuffixLookup(result.hostname, options, isException === true, result);
|
|
994
|
+
}
|
|
871
995
|
if (step === 2 /* FLAG.PUBLIC_SUFFIX */ || result.publicSuffix === null) {
|
|
872
996
|
return result;
|
|
873
997
|
}
|
|
@@ -889,7 +1013,9 @@ function parseImpl(url, step, suffixLookup, partialOptions, result) {
|
|
|
889
1013
|
function fastPath (hostname, options, out) {
|
|
890
1014
|
// Fast path for very popular suffixes; this allows to by-pass lookup
|
|
891
1015
|
// completely as well as any extra allocation or string manipulation.
|
|
892
|
-
if (!options.allowPrivateDomains &&
|
|
1016
|
+
if (!options.allowPrivateDomains &&
|
|
1017
|
+
options.allowIcannDomains &&
|
|
1018
|
+
hostname.length > 3) {
|
|
893
1019
|
const last = hostname.length - 1;
|
|
894
1020
|
const c3 = hostname.charCodeAt(last);
|
|
895
1021
|
const c2 = hostname.charCodeAt(last - 1);
|