@utilix-tech/sdk 0.15.0 → 0.17.0
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/CHANGELOG.md +6 -0
- package/README.md +28 -9
- package/dist/{chunk-OB56VNKJ.js → chunk-3QMUUTBH.js} +107 -1
- package/dist/{chunk-IPR7FSX4.js → chunk-DOWQZUTP.js} +61 -1
- package/dist/{chunk-Y5X34JAC.js → chunk-L53LAVAD.js} +64 -1
- package/dist/{chunk-RJPYVCKQ.js → chunk-M4MMO6C6.js} +18 -1
- package/dist/{code-C4skwg3l.d.cts → code-Cn9uOIAh.d.cts} +27 -2
- package/dist/{code-C4skwg3l.d.ts → code-Cn9uOIAh.d.ts} +27 -2
- package/dist/{encoding-7gmq-vkV.d.cts → encoding-Dk3wpmb3.d.cts} +19 -2
- package/dist/{encoding-7gmq-vkV.d.ts → encoding-Dk3wpmb3.d.ts} +19 -2
- package/dist/index.cjs +246 -0
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/{network-DaNoZ5ER.d.ts → network-DZugNyAQ.d.cts} +35 -2
- package/dist/{network-DaNoZ5ER.d.cts → network-DZugNyAQ.d.ts} +35 -2
- package/dist/tools/code.cjs +63 -0
- package/dist/tools/code.d.cts +1 -1
- package/dist/tools/code.d.ts +1 -1
- package/dist/tools/code.js +1 -1
- package/dist/tools/encoding.cjs +60 -0
- package/dist/tools/encoding.d.cts +1 -1
- package/dist/tools/encoding.d.ts +1 -1
- package/dist/tools/encoding.js +1 -1
- package/dist/tools/network.cjs +106 -0
- package/dist/tools/network.d.cts +1 -1
- package/dist/tools/network.d.ts +1 -1
- package/dist/tools/network.js +1 -1
- package/dist/tools/units.cjs +17 -0
- package/dist/tools/units.d.cts +1 -1
- package/dist/tools/units.d.ts +1 -1
- package/dist/tools/units.js +1 -1
- package/dist/{units-CADUCiYZ.d.cts → units-CkV4kAIs.d.cts} +21 -2
- package/dist/{units-CADUCiYZ.d.ts → units-CkV4kAIs.d.ts} +21 -2
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* - url-encode: encodeUrl, decodeUrl, diffSegments
|
|
8
8
|
* - html-entities: encodeHtmlEntities, decodeHtmlEntities, encodeHtmlEntitiesAll
|
|
9
9
|
* - base32 : base32Encode, base32Decode, base32EncodeBytes, base32DecodeBytes, isValidBase32, ALPHABETS
|
|
10
|
+
* - base58-base62 : base58Encode, base58Decode, base62Encode, base62Decode
|
|
10
11
|
*/
|
|
11
12
|
type Base64Variant = 'standard' | 'urlsafe';
|
|
12
13
|
interface EncodeResult {
|
|
@@ -74,6 +75,18 @@ declare function base32Decode(input: string, alphabet?: Base32Alphabet): string
|
|
|
74
75
|
error: string;
|
|
75
76
|
};
|
|
76
77
|
declare function isValidBase32(input: string, alphabet?: Base32Alphabet): boolean;
|
|
78
|
+
/** Encode text as Base58 (Bitcoin-address style, no ambiguous 0/O/I/l characters). */
|
|
79
|
+
declare function base58Encode(input: string): string;
|
|
80
|
+
/** Decode a Base58 string back to text. */
|
|
81
|
+
declare function base58Decode(input: string): string | {
|
|
82
|
+
error: string;
|
|
83
|
+
};
|
|
84
|
+
/** Encode text as Base62 (alphanumeric, URL-safe, no punctuation). */
|
|
85
|
+
declare function base62Encode(input: string): string;
|
|
86
|
+
/** Decode a Base62 string back to text. */
|
|
87
|
+
declare function base62Decode(input: string): string | {
|
|
88
|
+
error: string;
|
|
89
|
+
};
|
|
77
90
|
|
|
78
91
|
declare const encoding_ALPHABETS: typeof ALPHABETS;
|
|
79
92
|
type encoding_Base32Alphabet = Base32Alphabet;
|
|
@@ -91,6 +104,10 @@ declare const encoding_base32Decode: typeof base32Decode;
|
|
|
91
104
|
declare const encoding_base32DecodeBytes: typeof base32DecodeBytes;
|
|
92
105
|
declare const encoding_base32Encode: typeof base32Encode;
|
|
93
106
|
declare const encoding_base32EncodeBytes: typeof base32EncodeBytes;
|
|
107
|
+
declare const encoding_base58Decode: typeof base58Decode;
|
|
108
|
+
declare const encoding_base58Encode: typeof base58Encode;
|
|
109
|
+
declare const encoding_base62Decode: typeof base62Decode;
|
|
110
|
+
declare const encoding_base62Encode: typeof base62Encode;
|
|
94
111
|
declare const encoding_decodeBase64: typeof decodeBase64;
|
|
95
112
|
declare const encoding_decodeHtmlEntities: typeof decodeHtmlEntities;
|
|
96
113
|
declare const encoding_decodeUrl: typeof decodeUrl;
|
|
@@ -102,7 +119,7 @@ type encoding_encodeMode = encodeMode;
|
|
|
102
119
|
declare const encoding_encodeUrl: typeof encodeUrl;
|
|
103
120
|
declare const encoding_isValidBase32: typeof isValidBase32;
|
|
104
121
|
declare namespace encoding {
|
|
105
|
-
export { encoding_ALPHABETS as ALPHABETS, type encoding_Base32Alphabet as Base32Alphabet, type encoding_Base64DecodeResult as Base64DecodeResult, type encoding_Base64EncodeResult as Base64EncodeResult, type encoding_Base64Error as Base64Error, type encoding_Base64Variant as Base64Variant, type encoding_DecodeResult as DecodeResult, type encoding_EncodeResult as EncodeResult, type encoding_UrlEncodeError as UrlEncodeError, type encoding_UrlEncodeMode as UrlEncodeMode, type encoding_UrlEncodeResult as UrlEncodeResult, type encoding_UrlResult as UrlResult, encoding_base32Decode as base32Decode, encoding_base32DecodeBytes as base32DecodeBytes, encoding_base32Encode as base32Encode, encoding_base32EncodeBytes as base32EncodeBytes, encoding_decodeBase64 as decodeBase64, encoding_decodeHtmlEntities as decodeHtmlEntities, encoding_decodeUrl as decodeUrl, encoding_diffSegments as diffSegments, encoding_encodeBase64 as encodeBase64, encoding_encodeHtmlEntities as encodeHtmlEntities, encoding_encodeHtmlEntitiesAll as encodeHtmlEntitiesAll, type encoding_encodeMode as encodeMode, encoding_encodeUrl as encodeUrl, encoding_isValidBase32 as isValidBase32 };
|
|
122
|
+
export { encoding_ALPHABETS as ALPHABETS, type encoding_Base32Alphabet as Base32Alphabet, type encoding_Base64DecodeResult as Base64DecodeResult, type encoding_Base64EncodeResult as Base64EncodeResult, type encoding_Base64Error as Base64Error, type encoding_Base64Variant as Base64Variant, type encoding_DecodeResult as DecodeResult, type encoding_EncodeResult as EncodeResult, type encoding_UrlEncodeError as UrlEncodeError, type encoding_UrlEncodeMode as UrlEncodeMode, type encoding_UrlEncodeResult as UrlEncodeResult, type encoding_UrlResult as UrlResult, encoding_base32Decode as base32Decode, encoding_base32DecodeBytes as base32DecodeBytes, encoding_base32Encode as base32Encode, encoding_base32EncodeBytes as base32EncodeBytes, encoding_base58Decode as base58Decode, encoding_base58Encode as base58Encode, encoding_base62Decode as base62Decode, encoding_base62Encode as base62Encode, encoding_decodeBase64 as decodeBase64, encoding_decodeHtmlEntities as decodeHtmlEntities, encoding_decodeUrl as decodeUrl, encoding_diffSegments as diffSegments, encoding_encodeBase64 as encodeBase64, encoding_encodeHtmlEntities as encodeHtmlEntities, encoding_encodeHtmlEntitiesAll as encodeHtmlEntitiesAll, type encoding_encodeMode as encodeMode, encoding_encodeUrl as encodeUrl, encoding_isValidBase32 as isValidBase32 };
|
|
106
123
|
}
|
|
107
124
|
|
|
108
|
-
export { ALPHABETS as A, type Base32Alphabet as B, type DecodeResult as D, type EncodeResult as E, type UrlEncodeError as U, type Base64DecodeResult as a, type Base64EncodeResult as b, type Base64Error as c, type Base64Variant as d, encoding as e, type UrlEncodeMode as f, type UrlEncodeResult as g, type UrlResult as h, base32Decode as i, base32DecodeBytes as j, base32Encode as k, base32EncodeBytes as l,
|
|
125
|
+
export { ALPHABETS as A, type Base32Alphabet as B, type DecodeResult as D, type EncodeResult as E, type UrlEncodeError as U, type Base64DecodeResult as a, type Base64EncodeResult as b, type Base64Error as c, type Base64Variant as d, encoding as e, type UrlEncodeMode as f, type UrlEncodeResult as g, type UrlResult as h, base32Decode as i, base32DecodeBytes as j, base32Encode as k, base32EncodeBytes as l, base58Decode as m, base58Encode as n, base62Decode as o, base62Encode as p, decodeBase64 as q, decodeHtmlEntities as r, decodeUrl as s, diffSegments as t, encodeBase64 as u, encodeHtmlEntities as v, encodeHtmlEntitiesAll as w, type encodeMode as x, encodeUrl as y, isValidBase32 as z };
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* - url-encode: encodeUrl, decodeUrl, diffSegments
|
|
8
8
|
* - html-entities: encodeHtmlEntities, decodeHtmlEntities, encodeHtmlEntitiesAll
|
|
9
9
|
* - base32 : base32Encode, base32Decode, base32EncodeBytes, base32DecodeBytes, isValidBase32, ALPHABETS
|
|
10
|
+
* - base58-base62 : base58Encode, base58Decode, base62Encode, base62Decode
|
|
10
11
|
*/
|
|
11
12
|
type Base64Variant = 'standard' | 'urlsafe';
|
|
12
13
|
interface EncodeResult {
|
|
@@ -74,6 +75,18 @@ declare function base32Decode(input: string, alphabet?: Base32Alphabet): string
|
|
|
74
75
|
error: string;
|
|
75
76
|
};
|
|
76
77
|
declare function isValidBase32(input: string, alphabet?: Base32Alphabet): boolean;
|
|
78
|
+
/** Encode text as Base58 (Bitcoin-address style, no ambiguous 0/O/I/l characters). */
|
|
79
|
+
declare function base58Encode(input: string): string;
|
|
80
|
+
/** Decode a Base58 string back to text. */
|
|
81
|
+
declare function base58Decode(input: string): string | {
|
|
82
|
+
error: string;
|
|
83
|
+
};
|
|
84
|
+
/** Encode text as Base62 (alphanumeric, URL-safe, no punctuation). */
|
|
85
|
+
declare function base62Encode(input: string): string;
|
|
86
|
+
/** Decode a Base62 string back to text. */
|
|
87
|
+
declare function base62Decode(input: string): string | {
|
|
88
|
+
error: string;
|
|
89
|
+
};
|
|
77
90
|
|
|
78
91
|
declare const encoding_ALPHABETS: typeof ALPHABETS;
|
|
79
92
|
type encoding_Base32Alphabet = Base32Alphabet;
|
|
@@ -91,6 +104,10 @@ declare const encoding_base32Decode: typeof base32Decode;
|
|
|
91
104
|
declare const encoding_base32DecodeBytes: typeof base32DecodeBytes;
|
|
92
105
|
declare const encoding_base32Encode: typeof base32Encode;
|
|
93
106
|
declare const encoding_base32EncodeBytes: typeof base32EncodeBytes;
|
|
107
|
+
declare const encoding_base58Decode: typeof base58Decode;
|
|
108
|
+
declare const encoding_base58Encode: typeof base58Encode;
|
|
109
|
+
declare const encoding_base62Decode: typeof base62Decode;
|
|
110
|
+
declare const encoding_base62Encode: typeof base62Encode;
|
|
94
111
|
declare const encoding_decodeBase64: typeof decodeBase64;
|
|
95
112
|
declare const encoding_decodeHtmlEntities: typeof decodeHtmlEntities;
|
|
96
113
|
declare const encoding_decodeUrl: typeof decodeUrl;
|
|
@@ -102,7 +119,7 @@ type encoding_encodeMode = encodeMode;
|
|
|
102
119
|
declare const encoding_encodeUrl: typeof encodeUrl;
|
|
103
120
|
declare const encoding_isValidBase32: typeof isValidBase32;
|
|
104
121
|
declare namespace encoding {
|
|
105
|
-
export { encoding_ALPHABETS as ALPHABETS, type encoding_Base32Alphabet as Base32Alphabet, type encoding_Base64DecodeResult as Base64DecodeResult, type encoding_Base64EncodeResult as Base64EncodeResult, type encoding_Base64Error as Base64Error, type encoding_Base64Variant as Base64Variant, type encoding_DecodeResult as DecodeResult, type encoding_EncodeResult as EncodeResult, type encoding_UrlEncodeError as UrlEncodeError, type encoding_UrlEncodeMode as UrlEncodeMode, type encoding_UrlEncodeResult as UrlEncodeResult, type encoding_UrlResult as UrlResult, encoding_base32Decode as base32Decode, encoding_base32DecodeBytes as base32DecodeBytes, encoding_base32Encode as base32Encode, encoding_base32EncodeBytes as base32EncodeBytes, encoding_decodeBase64 as decodeBase64, encoding_decodeHtmlEntities as decodeHtmlEntities, encoding_decodeUrl as decodeUrl, encoding_diffSegments as diffSegments, encoding_encodeBase64 as encodeBase64, encoding_encodeHtmlEntities as encodeHtmlEntities, encoding_encodeHtmlEntitiesAll as encodeHtmlEntitiesAll, type encoding_encodeMode as encodeMode, encoding_encodeUrl as encodeUrl, encoding_isValidBase32 as isValidBase32 };
|
|
122
|
+
export { encoding_ALPHABETS as ALPHABETS, type encoding_Base32Alphabet as Base32Alphabet, type encoding_Base64DecodeResult as Base64DecodeResult, type encoding_Base64EncodeResult as Base64EncodeResult, type encoding_Base64Error as Base64Error, type encoding_Base64Variant as Base64Variant, type encoding_DecodeResult as DecodeResult, type encoding_EncodeResult as EncodeResult, type encoding_UrlEncodeError as UrlEncodeError, type encoding_UrlEncodeMode as UrlEncodeMode, type encoding_UrlEncodeResult as UrlEncodeResult, type encoding_UrlResult as UrlResult, encoding_base32Decode as base32Decode, encoding_base32DecodeBytes as base32DecodeBytes, encoding_base32Encode as base32Encode, encoding_base32EncodeBytes as base32EncodeBytes, encoding_base58Decode as base58Decode, encoding_base58Encode as base58Encode, encoding_base62Decode as base62Decode, encoding_base62Encode as base62Encode, encoding_decodeBase64 as decodeBase64, encoding_decodeHtmlEntities as decodeHtmlEntities, encoding_decodeUrl as decodeUrl, encoding_diffSegments as diffSegments, encoding_encodeBase64 as encodeBase64, encoding_encodeHtmlEntities as encodeHtmlEntities, encoding_encodeHtmlEntitiesAll as encodeHtmlEntitiesAll, type encoding_encodeMode as encodeMode, encoding_encodeUrl as encodeUrl, encoding_isValidBase32 as isValidBase32 };
|
|
106
123
|
}
|
|
107
124
|
|
|
108
|
-
export { ALPHABETS as A, type Base32Alphabet as B, type DecodeResult as D, type EncodeResult as E, type UrlEncodeError as U, type Base64DecodeResult as a, type Base64EncodeResult as b, type Base64Error as c, type Base64Variant as d, encoding as e, type UrlEncodeMode as f, type UrlEncodeResult as g, type UrlResult as h, base32Decode as i, base32DecodeBytes as j, base32Encode as k, base32EncodeBytes as l,
|
|
125
|
+
export { ALPHABETS as A, type Base32Alphabet as B, type DecodeResult as D, type EncodeResult as E, type UrlEncodeError as U, type Base64DecodeResult as a, type Base64EncodeResult as b, type Base64Error as c, type Base64Variant as d, encoding as e, type UrlEncodeMode as f, type UrlEncodeResult as g, type UrlResult as h, base32Decode as i, base32DecodeBytes as j, base32Encode as k, base32EncodeBytes as l, base58Decode as m, base58Encode as n, base62Decode as o, base62Encode as p, decodeBase64 as q, decodeHtmlEntities as r, decodeUrl as s, diffSegments as t, encodeBase64 as u, encodeHtmlEntities as v, encodeHtmlEntitiesAll as w, type encodeMode as x, encodeUrl as y, isValidBase32 as z };
|
package/dist/index.cjs
CHANGED
|
@@ -1296,6 +1296,10 @@ __export(encoding_exports, {
|
|
|
1296
1296
|
base32DecodeBytes: () => base32DecodeBytes,
|
|
1297
1297
|
base32Encode: () => base32Encode,
|
|
1298
1298
|
base32EncodeBytes: () => base32EncodeBytes,
|
|
1299
|
+
base58Decode: () => base58Decode,
|
|
1300
|
+
base58Encode: () => base58Encode,
|
|
1301
|
+
base62Decode: () => base62Decode,
|
|
1302
|
+
base62Encode: () => base62Encode,
|
|
1299
1303
|
decodeBase64: () => decodeBase64,
|
|
1300
1304
|
decodeHtmlEntities: () => decodeHtmlEntities,
|
|
1301
1305
|
decodeUrl: () => decodeUrl,
|
|
@@ -1549,6 +1553,62 @@ function isValidBase32(input, alphabet = "standard") {
|
|
|
1549
1553
|
if (rem === 1 || rem === 3 || rem === 6) return false;
|
|
1550
1554
|
return true;
|
|
1551
1555
|
}
|
|
1556
|
+
var BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
1557
|
+
var BASE62_ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
1558
|
+
function encodeBytesToBase(bytes, alphabet) {
|
|
1559
|
+
const base = BigInt(alphabet.length);
|
|
1560
|
+
let num = 0n;
|
|
1561
|
+
for (const byte of bytes) num = num << 8n | BigInt(byte);
|
|
1562
|
+
let out = "";
|
|
1563
|
+
while (num > 0n) {
|
|
1564
|
+
out = alphabet[Number(num % base)] + out;
|
|
1565
|
+
num = num / base;
|
|
1566
|
+
}
|
|
1567
|
+
let leadingZeros = 0;
|
|
1568
|
+
for (const byte of bytes) {
|
|
1569
|
+
if (byte === 0) leadingZeros++;
|
|
1570
|
+
else break;
|
|
1571
|
+
}
|
|
1572
|
+
return alphabet[0].repeat(leadingZeros) + out;
|
|
1573
|
+
}
|
|
1574
|
+
function decodeBaseToBytes(input, alphabet) {
|
|
1575
|
+
const base = BigInt(alphabet.length);
|
|
1576
|
+
let num = 0n;
|
|
1577
|
+
for (const char of input) {
|
|
1578
|
+
const idx = alphabet.indexOf(char);
|
|
1579
|
+
if (idx === -1) return { error: `Invalid character '${char}' for this alphabet` };
|
|
1580
|
+
num = num * base + BigInt(idx);
|
|
1581
|
+
}
|
|
1582
|
+
const bytes = [];
|
|
1583
|
+
while (num > 0n) {
|
|
1584
|
+
bytes.unshift(Number(num % 256n));
|
|
1585
|
+
num = num / 256n;
|
|
1586
|
+
}
|
|
1587
|
+
let leadingZeros = 0;
|
|
1588
|
+
for (const char of input) {
|
|
1589
|
+
if (char === alphabet[0]) leadingZeros++;
|
|
1590
|
+
else break;
|
|
1591
|
+
}
|
|
1592
|
+
return new Uint8Array([...new Array(leadingZeros).fill(0), ...bytes]);
|
|
1593
|
+
}
|
|
1594
|
+
function base58Encode(input) {
|
|
1595
|
+
return encodeBytesToBase(stringToBytes(input), BASE58_ALPHABET);
|
|
1596
|
+
}
|
|
1597
|
+
function base58Decode(input) {
|
|
1598
|
+
if (!input) return { error: "No input provided" };
|
|
1599
|
+
const result = decodeBaseToBytes(input, BASE58_ALPHABET);
|
|
1600
|
+
if (!(result instanceof Uint8Array)) return result;
|
|
1601
|
+
return bytesToString(result);
|
|
1602
|
+
}
|
|
1603
|
+
function base62Encode(input) {
|
|
1604
|
+
return encodeBytesToBase(stringToBytes(input), BASE62_ALPHABET);
|
|
1605
|
+
}
|
|
1606
|
+
function base62Decode(input) {
|
|
1607
|
+
if (!input) return { error: "No input provided" };
|
|
1608
|
+
const result = decodeBaseToBytes(input, BASE62_ALPHABET);
|
|
1609
|
+
if (!(result instanceof Uint8Array)) return result;
|
|
1610
|
+
return bytesToString(result);
|
|
1611
|
+
}
|
|
1552
1612
|
|
|
1553
1613
|
// src/tools/hashing.ts
|
|
1554
1614
|
var hashing_exports = {};
|
|
@@ -6625,6 +6685,7 @@ __export(units_exports, {
|
|
|
6625
6685
|
calcSubnet: () => calcSubnet,
|
|
6626
6686
|
calculateCompoundInterest: () => calculateCompoundInterest,
|
|
6627
6687
|
calculateLoan: () => calculateLoan,
|
|
6688
|
+
calculateSimpleInterest: () => calculateSimpleInterest,
|
|
6628
6689
|
calculateTax: () => calculateTax,
|
|
6629
6690
|
calculateTipSplit: () => calculateTipSplit,
|
|
6630
6691
|
compareSemver: () => compareSemver,
|
|
@@ -7885,6 +7946,22 @@ function calculateTipSplit(billAmount, tipPercent, numPeople = 1) {
|
|
|
7885
7946
|
perPersonTotal: round23(totalAmount / numPeople)
|
|
7886
7947
|
};
|
|
7887
7948
|
}
|
|
7949
|
+
function calculateSimpleInterest(principal, annualRatePercent, years) {
|
|
7950
|
+
if (!Number.isFinite(principal) || principal < 0) return { error: "Principal must be zero or a positive number" };
|
|
7951
|
+
if (!Number.isFinite(annualRatePercent) || annualRatePercent < 0) {
|
|
7952
|
+
return { error: "Annual interest rate must be zero or a positive number" };
|
|
7953
|
+
}
|
|
7954
|
+
if (!Number.isFinite(years) || years <= 0) return { error: "Years must be a positive number" };
|
|
7955
|
+
const round23 = (n) => Math.round(n * 100) / 100;
|
|
7956
|
+
const interest = round23(principal * (annualRatePercent / 100) * years);
|
|
7957
|
+
return {
|
|
7958
|
+
principal: round23(principal),
|
|
7959
|
+
annualRatePercent,
|
|
7960
|
+
years,
|
|
7961
|
+
interest,
|
|
7962
|
+
totalPayoff: round23(principal + interest)
|
|
7963
|
+
};
|
|
7964
|
+
}
|
|
7888
7965
|
|
|
7889
7966
|
// src/tools/network.ts
|
|
7890
7967
|
var network_exports = {};
|
|
@@ -7912,6 +7989,7 @@ __export(network_exports, {
|
|
|
7912
7989
|
parseDnsResponse: () => parseDnsResponse,
|
|
7913
7990
|
parseGeoResponse: () => parseGeoResponse,
|
|
7914
7991
|
parseHar: () => parseHar,
|
|
7992
|
+
parseUserAgent: () => parseUserAgent,
|
|
7915
7993
|
searchHeaders: () => searchHeaders,
|
|
7916
7994
|
searchStatusCodes: () => searchStatusCodes,
|
|
7917
7995
|
statusCodeToText: () => statusCodeToText,
|
|
@@ -9501,6 +9579,111 @@ function validateRobotsTxt(text) {
|
|
|
9501
9579
|
const valid = !issues.some((i) => i.severity === "error");
|
|
9502
9580
|
return { groups, sitemaps, issues, valid };
|
|
9503
9581
|
}
|
|
9582
|
+
var UA_BOT_PATTERNS = [
|
|
9583
|
+
[/googlebot/i, "Googlebot"],
|
|
9584
|
+
[/bingbot/i, "Bingbot"],
|
|
9585
|
+
[/slurp/i, "Slurp"],
|
|
9586
|
+
[/duckduckbot/i, "DuckDuckBot"],
|
|
9587
|
+
[/baiduspider/i, "Baiduspider"],
|
|
9588
|
+
[/yandexbot/i, "YandexBot"],
|
|
9589
|
+
[/facebookexternalhit/i, "Facebot"],
|
|
9590
|
+
[/twitterbot/i, "Twitterbot"],
|
|
9591
|
+
[/applebot/i, "Applebot"],
|
|
9592
|
+
[/discordbot/i, "Discordbot"],
|
|
9593
|
+
[/slackbot/i, "Slackbot"],
|
|
9594
|
+
[/telegrambot/i, "TelegramBot"],
|
|
9595
|
+
[/whatsapp/i, "WhatsApp"],
|
|
9596
|
+
[/ahrefsbot/i, "AhrefsBot"],
|
|
9597
|
+
[/semrushbot/i, "SemrushBot"],
|
|
9598
|
+
[/crawler|spider|\bbot\b/i, "Bot"]
|
|
9599
|
+
];
|
|
9600
|
+
function _detectUaBrowser(s) {
|
|
9601
|
+
let m;
|
|
9602
|
+
if (m = s.match(/Edg(?:A|iOS)?\/([\d.]+)/)) return { name: "Edge", version: m[1] };
|
|
9603
|
+
if (m = s.match(/Edge\/([\d.]+)/)) return { name: "Edge (Legacy)", version: m[1] };
|
|
9604
|
+
if (m = s.match(/OPR\/([\d.]+)/)) return { name: "Opera", version: m[1] };
|
|
9605
|
+
if (m = s.match(/Opera\/([\d.]+)/)) return { name: "Opera", version: m[1] };
|
|
9606
|
+
if (m = s.match(/SamsungBrowser\/([\d.]+)/)) return { name: "Samsung Internet", version: m[1] };
|
|
9607
|
+
if (m = s.match(/FxiOS\/([\d.]+)/)) return { name: "Firefox", version: m[1] };
|
|
9608
|
+
if (m = s.match(/Firefox\/([\d.]+)/)) return { name: "Firefox", version: m[1] };
|
|
9609
|
+
if (m = s.match(/CriOS\/([\d.]+)/)) return { name: "Chrome", version: m[1] };
|
|
9610
|
+
if (m = s.match(/Chrome\/([\d.]+)/)) return { name: "Chrome", version: m[1] };
|
|
9611
|
+
if (m = s.match(/Version\/([\d.]+).*Safari\//)) return { name: "Safari", version: m[1] };
|
|
9612
|
+
if (/Safari\//.test(s)) return { name: "Safari", version: "" };
|
|
9613
|
+
if (m = s.match(/MSIE ([\d.]+)/)) return { name: "Internet Explorer", version: m[1] };
|
|
9614
|
+
if (m = s.match(/Trident\/.*rv:([\d.]+)/)) return { name: "Internet Explorer", version: m[1] };
|
|
9615
|
+
return { name: "Unknown", version: "" };
|
|
9616
|
+
}
|
|
9617
|
+
function _detectUaEngine(s, browserName) {
|
|
9618
|
+
let m;
|
|
9619
|
+
if (/Chrome\/|CriOS\/|Edg\/|OPR\/|SamsungBrowser\//.test(s)) {
|
|
9620
|
+
m = s.match(/Chrome\/([\d.]+)/) || s.match(/CriOS\/([\d.]+)/);
|
|
9621
|
+
return { name: "Blink", version: m ? m[1] : "" };
|
|
9622
|
+
}
|
|
9623
|
+
if (/Firefox\/|FxiOS\//.test(s)) {
|
|
9624
|
+
m = s.match(/rv:([\d.]+)/);
|
|
9625
|
+
return { name: "Gecko", version: m ? m[1] : "" };
|
|
9626
|
+
}
|
|
9627
|
+
if (m = s.match(/AppleWebKit\/([\d.]+)/)) return { name: "WebKit", version: m[1] };
|
|
9628
|
+
if (m = s.match(/Trident\/([\d.]+)/)) return { name: "Trident", version: m[1] };
|
|
9629
|
+
if (browserName === "Edge (Legacy)") return { name: "EdgeHTML", version: "" };
|
|
9630
|
+
return { name: "Unknown", version: "" };
|
|
9631
|
+
}
|
|
9632
|
+
var UA_WINDOWS_VERSIONS = {
|
|
9633
|
+
"10.0": "10",
|
|
9634
|
+
"6.3": "8.1",
|
|
9635
|
+
"6.2": "8",
|
|
9636
|
+
"6.1": "7",
|
|
9637
|
+
"6.0": "Vista",
|
|
9638
|
+
"5.1": "XP"
|
|
9639
|
+
};
|
|
9640
|
+
function _detectUaOs(s) {
|
|
9641
|
+
if (/Windows NT/.test(s)) return "Windows";
|
|
9642
|
+
if (/CrOS/.test(s)) return "ChromeOS";
|
|
9643
|
+
if (/Android/.test(s)) return "Android";
|
|
9644
|
+
if (/iPhone|iPad|iPod/.test(s)) return "iOS";
|
|
9645
|
+
if (/Mac OS X/.test(s)) return "macOS";
|
|
9646
|
+
if (/Linux/.test(s)) return "Linux";
|
|
9647
|
+
return "Unknown";
|
|
9648
|
+
}
|
|
9649
|
+
function _detectUaOsVersion(s) {
|
|
9650
|
+
let m;
|
|
9651
|
+
if (m = s.match(/Windows NT ([\d.]+)/)) return UA_WINDOWS_VERSIONS[m[1]] ?? m[1];
|
|
9652
|
+
if (/CrOS/.test(s) && (m = s.match(/CrOS \S+ ([\d.]+)/))) return m[1];
|
|
9653
|
+
if (m = s.match(/Android ([\d.]+)/)) return m[1];
|
|
9654
|
+
if (m = s.match(/(?:iPhone|CPU) OS ([\d_]+)/)) return m[1].replace(/_/g, ".");
|
|
9655
|
+
if (m = s.match(/Mac OS X ([\d_]+)/)) return m[1].replace(/_/g, ".");
|
|
9656
|
+
return "";
|
|
9657
|
+
}
|
|
9658
|
+
function _detectUaDeviceType(s) {
|
|
9659
|
+
if (/iPad/.test(s)) return "tablet";
|
|
9660
|
+
if (/Android/.test(s) && !/Mobile/.test(s)) return "tablet";
|
|
9661
|
+
if (/Mobile|iPhone|iPod|Android/.test(s)) return "mobile";
|
|
9662
|
+
return "desktop";
|
|
9663
|
+
}
|
|
9664
|
+
function parseUserAgent(ua) {
|
|
9665
|
+
if (!ua || typeof ua !== "string" || ua.trim() === "") {
|
|
9666
|
+
return { error: "Empty user-agent string" };
|
|
9667
|
+
}
|
|
9668
|
+
const s = ua.trim();
|
|
9669
|
+
for (const [re, name] of UA_BOT_PATTERNS) {
|
|
9670
|
+
if (re.test(s)) {
|
|
9671
|
+
const versionMatch = s.match(new RegExp(`${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\/([\\d.]+)`, "i"));
|
|
9672
|
+
return {
|
|
9673
|
+
browser: { name, version: versionMatch ? versionMatch[1] : "" },
|
|
9674
|
+
engine: { name: "Unknown", version: "" },
|
|
9675
|
+
os: { name: _detectUaOs(s), version: _detectUaOsVersion(s) },
|
|
9676
|
+
device: { type: "bot" },
|
|
9677
|
+
raw: s
|
|
9678
|
+
};
|
|
9679
|
+
}
|
|
9680
|
+
}
|
|
9681
|
+
const browser = _detectUaBrowser(s);
|
|
9682
|
+
const engine = _detectUaEngine(s, browser.name);
|
|
9683
|
+
const os = { name: _detectUaOs(s), version: _detectUaOsVersion(s) };
|
|
9684
|
+
const device = { type: _detectUaDeviceType(s) };
|
|
9685
|
+
return { browser, engine, os, device, raw: s };
|
|
9686
|
+
}
|
|
9504
9687
|
|
|
9505
9688
|
// src/tools/api.ts
|
|
9506
9689
|
var api_exports = {};
|
|
@@ -10805,6 +10988,7 @@ __export(code_exports, {
|
|
|
10805
10988
|
parseDockerImage: () => parseDockerImage,
|
|
10806
10989
|
parseEnv: () => parseEnv2,
|
|
10807
10990
|
parseGitCommand: () => parseGitCommand,
|
|
10991
|
+
parseGithubUrl: () => parseGithubUrl,
|
|
10808
10992
|
parseSpec: () => parseSpec,
|
|
10809
10993
|
removeConsoleCalls: () => removeConsoleCalls,
|
|
10810
10994
|
removeEmptyAttributes: () => removeEmptyAttributes,
|
|
@@ -13178,6 +13362,68 @@ function lookupMime(query) {
|
|
|
13178
13362
|
if (matches.length === 0) return { error: `No known MIME type for extension ".${ext}"` };
|
|
13179
13363
|
return { query: trimmed, kind: "extension", matches };
|
|
13180
13364
|
}
|
|
13365
|
+
function _parseGithubLineRange(hash) {
|
|
13366
|
+
const m = hash.match(/^#?L(\d+)(?:-L?(\d+))?$/i);
|
|
13367
|
+
if (!m) return {};
|
|
13368
|
+
const startLine = parseInt(m[1], 10);
|
|
13369
|
+
const endLine = m[2] ? parseInt(m[2], 10) : void 0;
|
|
13370
|
+
return endLine !== void 0 ? { startLine, endLine } : { startLine };
|
|
13371
|
+
}
|
|
13372
|
+
function parseGithubUrl(input) {
|
|
13373
|
+
if (!input || typeof input !== "string" || input.trim() === "") {
|
|
13374
|
+
return { error: "Empty URL" };
|
|
13375
|
+
}
|
|
13376
|
+
const trimmed = input.trim();
|
|
13377
|
+
const normalized = /^https?:\/\//i.test(trimmed) ? trimmed : `https://${trimmed}`;
|
|
13378
|
+
let url;
|
|
13379
|
+
try {
|
|
13380
|
+
url = new URL(normalized);
|
|
13381
|
+
} catch {
|
|
13382
|
+
return { error: "Invalid URL" };
|
|
13383
|
+
}
|
|
13384
|
+
if (!/^(www\.)?github\.com$/i.test(url.hostname)) {
|
|
13385
|
+
return { error: `Not a github.com URL (got host "${url.hostname}")` };
|
|
13386
|
+
}
|
|
13387
|
+
const segments = url.pathname.split("/").filter(Boolean);
|
|
13388
|
+
if (segments.length < 2) {
|
|
13389
|
+
return { error: "URL must include an owner and a repository" };
|
|
13390
|
+
}
|
|
13391
|
+
const [owner, repo, ...rest] = segments;
|
|
13392
|
+
if (rest.length === 0) {
|
|
13393
|
+
return { owner, repo, type: "repo" };
|
|
13394
|
+
}
|
|
13395
|
+
const kind = rest[0];
|
|
13396
|
+
if (kind === "pull" || kind === "issues") {
|
|
13397
|
+
const number = parseInt(rest[1], 10);
|
|
13398
|
+
if (!rest[1] || Number.isNaN(number)) {
|
|
13399
|
+
return { error: `Missing ${kind === "pull" ? "pull request" : "issue"} number` };
|
|
13400
|
+
}
|
|
13401
|
+
return { owner, repo, type: kind === "pull" ? "pull" : "issue", number };
|
|
13402
|
+
}
|
|
13403
|
+
if (kind === "commit") {
|
|
13404
|
+
if (!rest[1]) return { error: "Missing commit SHA" };
|
|
13405
|
+
return { owner, repo, type: "commit", ref: rest[1] };
|
|
13406
|
+
}
|
|
13407
|
+
if (kind === "blob") {
|
|
13408
|
+
const ref = rest[1];
|
|
13409
|
+
const path = rest.slice(2).join("/");
|
|
13410
|
+
if (!ref || !path) return { error: "File URL must include a ref and a file path (/blob/<ref>/<path>)" };
|
|
13411
|
+
return { owner, repo, type: "file", ref, path, ..._parseGithubLineRange(url.hash) };
|
|
13412
|
+
}
|
|
13413
|
+
if (kind === "tree") {
|
|
13414
|
+
const ref = rest[1];
|
|
13415
|
+
if (!ref) return { error: "Missing branch or tag ref (/tree/<ref>)" };
|
|
13416
|
+
const path = rest.slice(2).join("/");
|
|
13417
|
+
return { owner, repo, type: "tree", ref, ...path ? { path } : {} };
|
|
13418
|
+
}
|
|
13419
|
+
if (kind === "releases") {
|
|
13420
|
+
if (rest[1] !== "tag" || !rest[2]) {
|
|
13421
|
+
return { error: "Unsupported releases URL (expected /releases/tag/<name>)" };
|
|
13422
|
+
}
|
|
13423
|
+
return { owner, repo, type: "release", ref: rest[2] };
|
|
13424
|
+
}
|
|
13425
|
+
return { error: `Unsupported GitHub URL path: /${rest.join("/")}` };
|
|
13426
|
+
}
|
|
13181
13427
|
|
|
13182
13428
|
// src/tools/color.ts
|
|
13183
13429
|
var color_exports = {};
|
package/dist/index.d.cts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export { j as json } from './json-BjSoIS1h.cjs';
|
|
2
|
-
export { e as encoding } from './encoding-
|
|
2
|
+
export { e as encoding } from './encoding-Dk3wpmb3.cjs';
|
|
3
3
|
export { h as hashing } from './hashing-CnetQFD_.cjs';
|
|
4
4
|
export { t as text } from './text-Bbx-tZ43.cjs';
|
|
5
5
|
export { d as data } from './data-D8XTI7Du.cjs';
|
|
6
6
|
export { g as generators } from './generators-BGtRGpJZ.cjs';
|
|
7
7
|
export { t as time } from './time-DbT8fjaF.cjs';
|
|
8
|
-
export { u as units } from './units-
|
|
9
|
-
export { n as network } from './network-
|
|
8
|
+
export { u as units } from './units-CkV4kAIs.cjs';
|
|
9
|
+
export { n as network } from './network-DZugNyAQ.cjs';
|
|
10
10
|
export { a as api } from './api-Xl7OzIgq.cjs';
|
|
11
|
-
export { c as code } from './code-
|
|
11
|
+
export { c as code } from './code-Cn9uOIAh.cjs';
|
|
12
12
|
export { c as color } from './color-tPwZCr9H.cjs';
|
|
13
13
|
export { c as css } from './css-Cf7AMGM-.cjs';
|
|
14
14
|
export { m as misc } from './misc-CA3N198T.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export { j as json } from './json-BjSoIS1h.js';
|
|
2
|
-
export { e as encoding } from './encoding-
|
|
2
|
+
export { e as encoding } from './encoding-Dk3wpmb3.js';
|
|
3
3
|
export { h as hashing } from './hashing-CnetQFD_.js';
|
|
4
4
|
export { t as text } from './text-Bbx-tZ43.js';
|
|
5
5
|
export { d as data } from './data-D8XTI7Du.js';
|
|
6
6
|
export { g as generators } from './generators-BGtRGpJZ.js';
|
|
7
7
|
export { t as time } from './time-DbT8fjaF.js';
|
|
8
|
-
export { u as units } from './units-
|
|
9
|
-
export { n as network } from './network-
|
|
8
|
+
export { u as units } from './units-CkV4kAIs.js';
|
|
9
|
+
export { n as network } from './network-DZugNyAQ.js';
|
|
10
10
|
export { a as api } from './api-Xl7OzIgq.js';
|
|
11
|
-
export { c as code } from './code-
|
|
11
|
+
export { c as code } from './code-Cn9uOIAh.js';
|
|
12
12
|
export { c as color } from './color-tPwZCr9H.js';
|
|
13
13
|
export { c as css } from './css-Cf7AMGM-.js';
|
|
14
14
|
export { m as misc } from './misc-CA3N198T.js';
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export { media_exports as media } from './chunk-XMKJYVKB.js';
|
|
2
|
-
export { units_exports as units } from './chunk-
|
|
3
|
-
export { network_exports as network } from './chunk-
|
|
2
|
+
export { units_exports as units } from './chunk-M4MMO6C6.js';
|
|
3
|
+
export { network_exports as network } from './chunk-3QMUUTBH.js';
|
|
4
4
|
export { api_exports as api } from './chunk-Q3B3YWOA.js';
|
|
5
|
-
export { code_exports as code } from './chunk-
|
|
5
|
+
export { code_exports as code } from './chunk-L53LAVAD.js';
|
|
6
6
|
export { color_exports as color } from './chunk-BPVAB4P2.js';
|
|
7
7
|
export { css_exports as css } from './chunk-6YPV2AB5.js';
|
|
8
8
|
export { misc_exports as misc } from './chunk-GX7H6TAX.js';
|
|
9
9
|
export { ai_agent_exports as ai_agent } from './chunk-M35VJETW.js';
|
|
10
10
|
export { json_exports as json } from './chunk-TSAGO3XP.js';
|
|
11
|
-
export { encoding_exports as encoding } from './chunk-
|
|
11
|
+
export { encoding_exports as encoding } from './chunk-DOWQZUTP.js';
|
|
12
12
|
export { hashing_exports as hashing } from './chunk-GEFVMGZR.js';
|
|
13
13
|
export { text_exports as text } from './chunk-F57WMKZO.js';
|
|
14
14
|
export { data_exports as data } from './chunk-TINQFTLO.js';
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* - har-viewer : parseHar
|
|
11
11
|
* - sitemap-validator: validateSitemap
|
|
12
12
|
* - robots-txt-validator: validateRobotsTxt
|
|
13
|
+
* - user-agent-parser: parseUserAgent
|
|
13
14
|
*/
|
|
14
15
|
declare const DNS_RECORD_TYPES: readonly ["A", "AAAA", "CNAME", "MX", "TXT", "NS", "SOA", "PTR", "SRV", "CAA"];
|
|
15
16
|
type DnsRecordType = typeof DNS_RECORD_TYPES[number];
|
|
@@ -222,6 +223,35 @@ interface RobotsValidationResult {
|
|
|
222
223
|
declare function validateRobotsTxt(text: string): RobotsValidationResult | {
|
|
223
224
|
error: string;
|
|
224
225
|
};
|
|
226
|
+
type UaDeviceType = 'desktop' | 'mobile' | 'tablet' | 'bot';
|
|
227
|
+
interface UserAgentInfo {
|
|
228
|
+
browser: {
|
|
229
|
+
name: string;
|
|
230
|
+
version: string;
|
|
231
|
+
};
|
|
232
|
+
engine: {
|
|
233
|
+
name: string;
|
|
234
|
+
version: string;
|
|
235
|
+
};
|
|
236
|
+
os: {
|
|
237
|
+
name: string;
|
|
238
|
+
version: string;
|
|
239
|
+
};
|
|
240
|
+
device: {
|
|
241
|
+
type: UaDeviceType;
|
|
242
|
+
};
|
|
243
|
+
raw: string;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Parses a browser User-Agent string into browser, engine, OS, and device
|
|
247
|
+
* type via pattern matching against well-known UA token formats. Covers the
|
|
248
|
+
* major desktop/mobile browsers and common search-engine/social crawlers;
|
|
249
|
+
* it is not an exhaustive UA database and falls back to 'Unknown' fields
|
|
250
|
+
* for obscure or custom UA strings.
|
|
251
|
+
*/
|
|
252
|
+
declare function parseUserAgent(ua: string): UserAgentInfo | {
|
|
253
|
+
error: string;
|
|
254
|
+
};
|
|
225
255
|
|
|
226
256
|
declare const network_DNS_RECORD_TYPES: typeof DNS_RECORD_TYPES;
|
|
227
257
|
type network_DnsRecord = DnsRecord;
|
|
@@ -246,6 +276,8 @@ type network_SitemapIssue = SitemapIssue;
|
|
|
246
276
|
type network_SitemapUrlEntry = SitemapUrlEntry;
|
|
247
277
|
type network_SitemapValidationResult = SitemapValidationResult;
|
|
248
278
|
type network_StatusCode = StatusCode;
|
|
279
|
+
type network_UaDeviceType = UaDeviceType;
|
|
280
|
+
type network_UserAgentInfo = UserAgentInfo;
|
|
249
281
|
declare const network_buildDnsQueryUrl: typeof buildDnsQueryUrl;
|
|
250
282
|
declare const network_buildGeoUrl: typeof buildGeoUrl;
|
|
251
283
|
declare const network_buildMapUrl: typeof buildMapUrl;
|
|
@@ -266,6 +298,7 @@ declare const network_isValidIpv6: typeof isValidIpv6;
|
|
|
266
298
|
declare const network_parseDnsResponse: typeof parseDnsResponse;
|
|
267
299
|
declare const network_parseGeoResponse: typeof parseGeoResponse;
|
|
268
300
|
declare const network_parseHar: typeof parseHar;
|
|
301
|
+
declare const network_parseUserAgent: typeof parseUserAgent;
|
|
269
302
|
declare const network_searchHeaders: typeof searchHeaders;
|
|
270
303
|
declare const network_searchStatusCodes: typeof searchStatusCodes;
|
|
271
304
|
declare const network_statusCodeToText: typeof statusCodeToText;
|
|
@@ -276,7 +309,7 @@ declare const network_validateHeaderValue: typeof validateHeaderValue;
|
|
|
276
309
|
declare const network_validateRobotsTxt: typeof validateRobotsTxt;
|
|
277
310
|
declare const network_validateSitemap: typeof validateSitemap;
|
|
278
311
|
declare namespace network {
|
|
279
|
-
export { network_DNS_RECORD_TYPES as DNS_RECORD_TYPES, type network_DnsRecord as DnsRecord, type network_DnsRecordType as DnsRecordType, type network_DnsResponse as DnsResponse, type network_GeoResult as GeoResult, network_HTTP_HEADERS as HTTP_HEADERS, type network_HarEntry as HarEntry, type network_HarParseResult as HarParseResult, type network_HarSummary as HarSummary, type network_HeaderCategory as HeaderCategory, type network_HttpHeader as HttpHeader, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, type network_RobotsGroup as RobotsGroup, type network_RobotsIssue as RobotsIssue, type network_RobotsRule as RobotsRule, type network_RobotsValidationResult as RobotsValidationResult, network_STATUS_CODES as STATUS_CODES, type network_SitemapIndexEntry as SitemapIndexEntry, type network_SitemapIssue as SitemapIssue, type network_SitemapUrlEntry as SitemapUrlEntry, type network_SitemapValidationResult as SitemapValidationResult, type network_StatusCode as StatusCode, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildMapUrl as buildMapUrl, network_countryCodeToFlag as countryCodeToFlag, network_formatCoordinates as formatCoordinates, network_formatTtl as formatTtl, network_getByCategory as getByCategory, network_getHeader as getHeader, network_getHeadersByCategory as getHeadersByCategory, network_getStatusByCategory as getStatusByCategory, network_getStatusCode as getStatusCode, network_isClientError as isClientError, network_isServerError as isServerError, network_isSuccess as isSuccess, network_isValidIp as isValidIp, network_isValidIpv4 as isValidIpv4, network_isValidIpv6 as isValidIpv6, network_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_searchHeaders as searchHeaders, network_searchStatusCodes as searchStatusCodes, network_statusCodeToText as statusCodeToText, network_typeNumberToLabel as typeNumberToLabel, network_validateDomain as validateDomain, network_validateHeaderName as validateHeaderName, network_validateHeaderValue as validateHeaderValue, network_validateRobotsTxt as validateRobotsTxt, network_validateSitemap as validateSitemap };
|
|
312
|
+
export { network_DNS_RECORD_TYPES as DNS_RECORD_TYPES, type network_DnsRecord as DnsRecord, type network_DnsRecordType as DnsRecordType, type network_DnsResponse as DnsResponse, type network_GeoResult as GeoResult, network_HTTP_HEADERS as HTTP_HEADERS, type network_HarEntry as HarEntry, type network_HarParseResult as HarParseResult, type network_HarSummary as HarSummary, type network_HeaderCategory as HeaderCategory, type network_HttpHeader as HttpHeader, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, type network_RobotsGroup as RobotsGroup, type network_RobotsIssue as RobotsIssue, type network_RobotsRule as RobotsRule, type network_RobotsValidationResult as RobotsValidationResult, network_STATUS_CODES as STATUS_CODES, type network_SitemapIndexEntry as SitemapIndexEntry, type network_SitemapIssue as SitemapIssue, type network_SitemapUrlEntry as SitemapUrlEntry, type network_SitemapValidationResult as SitemapValidationResult, type network_StatusCode as StatusCode, type network_UaDeviceType as UaDeviceType, type network_UserAgentInfo as UserAgentInfo, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildMapUrl as buildMapUrl, network_countryCodeToFlag as countryCodeToFlag, network_formatCoordinates as formatCoordinates, network_formatTtl as formatTtl, network_getByCategory as getByCategory, network_getHeader as getHeader, network_getHeadersByCategory as getHeadersByCategory, network_getStatusByCategory as getStatusByCategory, network_getStatusCode as getStatusCode, network_isClientError as isClientError, network_isServerError as isServerError, network_isSuccess as isSuccess, network_isValidIp as isValidIp, network_isValidIpv4 as isValidIpv4, network_isValidIpv6 as isValidIpv6, network_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_parseUserAgent as parseUserAgent, network_searchHeaders as searchHeaders, network_searchStatusCodes as searchStatusCodes, network_statusCodeToText as statusCodeToText, network_typeNumberToLabel as typeNumberToLabel, network_validateDomain as validateDomain, network_validateHeaderName as validateHeaderName, network_validateHeaderValue as validateHeaderValue, network_validateRobotsTxt as validateRobotsTxt, network_validateSitemap as validateSitemap };
|
|
280
313
|
}
|
|
281
314
|
|
|
282
|
-
export {
|
|
315
|
+
export { validateHeaderValue as $, getHeader as A, getHeadersByCategory as B, getStatusByCategory as C, DNS_RECORD_TYPES as D, getStatusCode as E, isClientError as F, type GeoResult as G, HTTP_HEADERS as H, isServerError as I, isSuccess as J, isValidIp as K, isValidIpv4 as L, isValidIpv6 as M, parseDnsResponse as N, parseGeoResponse as O, type ParsedDnsResult as P, parseHar as Q, type RobotsGroup as R, STATUS_CODES as S, parseUserAgent as T, type UaDeviceType as U, searchHeaders as V, searchStatusCodes as W, statusCodeToText as X, typeNumberToLabel as Y, validateDomain as Z, validateHeaderName as _, type DnsRecord as a, validateRobotsTxt as a0, validateSitemap as a1, type DnsRecordType as b, type DnsResponse as c, type HarEntry as d, type HarParseResult as e, type HarSummary as f, type HeaderCategory as g, type HttpHeader as h, type ParsedGeoResult as i, type RobotsIssue as j, type RobotsRule as k, type RobotsValidationResult as l, type SitemapIndexEntry as m, network as n, type SitemapIssue as o, type SitemapUrlEntry as p, type SitemapValidationResult as q, type StatusCode as r, type UserAgentInfo as s, buildDnsQueryUrl as t, buildGeoUrl as u, buildMapUrl as v, countryCodeToFlag as w, formatCoordinates as x, formatTtl as y, getByCategory as z };
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* - har-viewer : parseHar
|
|
11
11
|
* - sitemap-validator: validateSitemap
|
|
12
12
|
* - robots-txt-validator: validateRobotsTxt
|
|
13
|
+
* - user-agent-parser: parseUserAgent
|
|
13
14
|
*/
|
|
14
15
|
declare const DNS_RECORD_TYPES: readonly ["A", "AAAA", "CNAME", "MX", "TXT", "NS", "SOA", "PTR", "SRV", "CAA"];
|
|
15
16
|
type DnsRecordType = typeof DNS_RECORD_TYPES[number];
|
|
@@ -222,6 +223,35 @@ interface RobotsValidationResult {
|
|
|
222
223
|
declare function validateRobotsTxt(text: string): RobotsValidationResult | {
|
|
223
224
|
error: string;
|
|
224
225
|
};
|
|
226
|
+
type UaDeviceType = 'desktop' | 'mobile' | 'tablet' | 'bot';
|
|
227
|
+
interface UserAgentInfo {
|
|
228
|
+
browser: {
|
|
229
|
+
name: string;
|
|
230
|
+
version: string;
|
|
231
|
+
};
|
|
232
|
+
engine: {
|
|
233
|
+
name: string;
|
|
234
|
+
version: string;
|
|
235
|
+
};
|
|
236
|
+
os: {
|
|
237
|
+
name: string;
|
|
238
|
+
version: string;
|
|
239
|
+
};
|
|
240
|
+
device: {
|
|
241
|
+
type: UaDeviceType;
|
|
242
|
+
};
|
|
243
|
+
raw: string;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Parses a browser User-Agent string into browser, engine, OS, and device
|
|
247
|
+
* type via pattern matching against well-known UA token formats. Covers the
|
|
248
|
+
* major desktop/mobile browsers and common search-engine/social crawlers;
|
|
249
|
+
* it is not an exhaustive UA database and falls back to 'Unknown' fields
|
|
250
|
+
* for obscure or custom UA strings.
|
|
251
|
+
*/
|
|
252
|
+
declare function parseUserAgent(ua: string): UserAgentInfo | {
|
|
253
|
+
error: string;
|
|
254
|
+
};
|
|
225
255
|
|
|
226
256
|
declare const network_DNS_RECORD_TYPES: typeof DNS_RECORD_TYPES;
|
|
227
257
|
type network_DnsRecord = DnsRecord;
|
|
@@ -246,6 +276,8 @@ type network_SitemapIssue = SitemapIssue;
|
|
|
246
276
|
type network_SitemapUrlEntry = SitemapUrlEntry;
|
|
247
277
|
type network_SitemapValidationResult = SitemapValidationResult;
|
|
248
278
|
type network_StatusCode = StatusCode;
|
|
279
|
+
type network_UaDeviceType = UaDeviceType;
|
|
280
|
+
type network_UserAgentInfo = UserAgentInfo;
|
|
249
281
|
declare const network_buildDnsQueryUrl: typeof buildDnsQueryUrl;
|
|
250
282
|
declare const network_buildGeoUrl: typeof buildGeoUrl;
|
|
251
283
|
declare const network_buildMapUrl: typeof buildMapUrl;
|
|
@@ -266,6 +298,7 @@ declare const network_isValidIpv6: typeof isValidIpv6;
|
|
|
266
298
|
declare const network_parseDnsResponse: typeof parseDnsResponse;
|
|
267
299
|
declare const network_parseGeoResponse: typeof parseGeoResponse;
|
|
268
300
|
declare const network_parseHar: typeof parseHar;
|
|
301
|
+
declare const network_parseUserAgent: typeof parseUserAgent;
|
|
269
302
|
declare const network_searchHeaders: typeof searchHeaders;
|
|
270
303
|
declare const network_searchStatusCodes: typeof searchStatusCodes;
|
|
271
304
|
declare const network_statusCodeToText: typeof statusCodeToText;
|
|
@@ -276,7 +309,7 @@ declare const network_validateHeaderValue: typeof validateHeaderValue;
|
|
|
276
309
|
declare const network_validateRobotsTxt: typeof validateRobotsTxt;
|
|
277
310
|
declare const network_validateSitemap: typeof validateSitemap;
|
|
278
311
|
declare namespace network {
|
|
279
|
-
export { network_DNS_RECORD_TYPES as DNS_RECORD_TYPES, type network_DnsRecord as DnsRecord, type network_DnsRecordType as DnsRecordType, type network_DnsResponse as DnsResponse, type network_GeoResult as GeoResult, network_HTTP_HEADERS as HTTP_HEADERS, type network_HarEntry as HarEntry, type network_HarParseResult as HarParseResult, type network_HarSummary as HarSummary, type network_HeaderCategory as HeaderCategory, type network_HttpHeader as HttpHeader, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, type network_RobotsGroup as RobotsGroup, type network_RobotsIssue as RobotsIssue, type network_RobotsRule as RobotsRule, type network_RobotsValidationResult as RobotsValidationResult, network_STATUS_CODES as STATUS_CODES, type network_SitemapIndexEntry as SitemapIndexEntry, type network_SitemapIssue as SitemapIssue, type network_SitemapUrlEntry as SitemapUrlEntry, type network_SitemapValidationResult as SitemapValidationResult, type network_StatusCode as StatusCode, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildMapUrl as buildMapUrl, network_countryCodeToFlag as countryCodeToFlag, network_formatCoordinates as formatCoordinates, network_formatTtl as formatTtl, network_getByCategory as getByCategory, network_getHeader as getHeader, network_getHeadersByCategory as getHeadersByCategory, network_getStatusByCategory as getStatusByCategory, network_getStatusCode as getStatusCode, network_isClientError as isClientError, network_isServerError as isServerError, network_isSuccess as isSuccess, network_isValidIp as isValidIp, network_isValidIpv4 as isValidIpv4, network_isValidIpv6 as isValidIpv6, network_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_searchHeaders as searchHeaders, network_searchStatusCodes as searchStatusCodes, network_statusCodeToText as statusCodeToText, network_typeNumberToLabel as typeNumberToLabel, network_validateDomain as validateDomain, network_validateHeaderName as validateHeaderName, network_validateHeaderValue as validateHeaderValue, network_validateRobotsTxt as validateRobotsTxt, network_validateSitemap as validateSitemap };
|
|
312
|
+
export { network_DNS_RECORD_TYPES as DNS_RECORD_TYPES, type network_DnsRecord as DnsRecord, type network_DnsRecordType as DnsRecordType, type network_DnsResponse as DnsResponse, type network_GeoResult as GeoResult, network_HTTP_HEADERS as HTTP_HEADERS, type network_HarEntry as HarEntry, type network_HarParseResult as HarParseResult, type network_HarSummary as HarSummary, type network_HeaderCategory as HeaderCategory, type network_HttpHeader as HttpHeader, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, type network_RobotsGroup as RobotsGroup, type network_RobotsIssue as RobotsIssue, type network_RobotsRule as RobotsRule, type network_RobotsValidationResult as RobotsValidationResult, network_STATUS_CODES as STATUS_CODES, type network_SitemapIndexEntry as SitemapIndexEntry, type network_SitemapIssue as SitemapIssue, type network_SitemapUrlEntry as SitemapUrlEntry, type network_SitemapValidationResult as SitemapValidationResult, type network_StatusCode as StatusCode, type network_UaDeviceType as UaDeviceType, type network_UserAgentInfo as UserAgentInfo, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildMapUrl as buildMapUrl, network_countryCodeToFlag as countryCodeToFlag, network_formatCoordinates as formatCoordinates, network_formatTtl as formatTtl, network_getByCategory as getByCategory, network_getHeader as getHeader, network_getHeadersByCategory as getHeadersByCategory, network_getStatusByCategory as getStatusByCategory, network_getStatusCode as getStatusCode, network_isClientError as isClientError, network_isServerError as isServerError, network_isSuccess as isSuccess, network_isValidIp as isValidIp, network_isValidIpv4 as isValidIpv4, network_isValidIpv6 as isValidIpv6, network_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_parseUserAgent as parseUserAgent, network_searchHeaders as searchHeaders, network_searchStatusCodes as searchStatusCodes, network_statusCodeToText as statusCodeToText, network_typeNumberToLabel as typeNumberToLabel, network_validateDomain as validateDomain, network_validateHeaderName as validateHeaderName, network_validateHeaderValue as validateHeaderValue, network_validateRobotsTxt as validateRobotsTxt, network_validateSitemap as validateSitemap };
|
|
280
313
|
}
|
|
281
314
|
|
|
282
|
-
export {
|
|
315
|
+
export { validateHeaderValue as $, getHeader as A, getHeadersByCategory as B, getStatusByCategory as C, DNS_RECORD_TYPES as D, getStatusCode as E, isClientError as F, type GeoResult as G, HTTP_HEADERS as H, isServerError as I, isSuccess as J, isValidIp as K, isValidIpv4 as L, isValidIpv6 as M, parseDnsResponse as N, parseGeoResponse as O, type ParsedDnsResult as P, parseHar as Q, type RobotsGroup as R, STATUS_CODES as S, parseUserAgent as T, type UaDeviceType as U, searchHeaders as V, searchStatusCodes as W, statusCodeToText as X, typeNumberToLabel as Y, validateDomain as Z, validateHeaderName as _, type DnsRecord as a, validateRobotsTxt as a0, validateSitemap as a1, type DnsRecordType as b, type DnsResponse as c, type HarEntry as d, type HarParseResult as e, type HarSummary as f, type HeaderCategory as g, type HttpHeader as h, type ParsedGeoResult as i, type RobotsIssue as j, type RobotsRule as k, type RobotsValidationResult as l, type SitemapIndexEntry as m, network as n, type SitemapIssue as o, type SitemapUrlEntry as p, type SitemapValidationResult as q, type StatusCode as r, type UserAgentInfo as s, buildDnsQueryUrl as t, buildGeoUrl as u, buildMapUrl as v, countryCodeToFlag as w, formatCoordinates as x, formatTtl as y, getByCategory as z };
|