@utilix-tech/sdk 0.27.0 → 0.29.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 +7 -0
- package/README.md +25 -7
- package/dist/{chunk-Y5OOP6WN.js → chunk-CSNTHZHF.js} +90 -1
- package/dist/{chunk-Q3M23WNJ.js → chunk-L6V4W4SU.js} +361 -1
- package/dist/index.cjs +449 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{media-CN17a3MM.d.cts → media-fD8dJ5qR.d.cts} +51 -2
- package/dist/{media-CN17a3MM.d.ts → media-fD8dJ5qR.d.ts} +51 -2
- package/dist/{network-BJOjJnmY.d.cts → network-D7Epuerc.d.cts} +23 -2
- package/dist/{network-BJOjJnmY.d.ts → network-D7Epuerc.d.ts} +23 -2
- package/dist/tools/media.cjs +360 -0
- package/dist/tools/media.d.cts +1 -1
- package/dist/tools/media.d.ts +1 -1
- package/dist/tools/media.js +1 -1
- package/dist/tools/network.cjs +89 -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/package.json +1 -1
package/dist/tools/network.cjs
CHANGED
|
@@ -1777,6 +1777,94 @@ function buildCacheControl(options = {}) {
|
|
|
1777
1777
|
const snippet = `Cache-Control: ${header}`;
|
|
1778
1778
|
return { header, headerName: "Cache-Control", snippet, directives, warnings };
|
|
1779
1779
|
}
|
|
1780
|
+
function isValidIpv6HexGroup(g) {
|
|
1781
|
+
return /^[0-9a-fA-F]{1,4}$/.test(g);
|
|
1782
|
+
}
|
|
1783
|
+
function isValidIpv6Ipv4Quad(quad) {
|
|
1784
|
+
const parts = quad.split(".");
|
|
1785
|
+
if (parts.length !== 4) return false;
|
|
1786
|
+
return parts.every((p) => /^\d{1,3}$/.test(p) && Number(p) <= 255);
|
|
1787
|
+
}
|
|
1788
|
+
function classifyIpv6(groups) {
|
|
1789
|
+
const first = parseInt(groups[0], 16);
|
|
1790
|
+
if (groups.every((g) => g === "0000")) return "unspecified";
|
|
1791
|
+
if (groups.slice(0, 7).every((g) => g === "0000") && groups[7] === "0001") return "loopback";
|
|
1792
|
+
if (groups.slice(0, 4).every((g) => g === "0000") && groups[4] === "0000" && groups[5] === "ffff") return "ipv4-mapped";
|
|
1793
|
+
if (groups[0] === "2001" && groups[1] === "0db8") return "documentation";
|
|
1794
|
+
if ((first & 65280) === 65280) return "multicast";
|
|
1795
|
+
if ((first & 65472) === 65152) return "link-local";
|
|
1796
|
+
if ((first & 65024) === 64512) return "unique-local";
|
|
1797
|
+
return "global-unicast";
|
|
1798
|
+
}
|
|
1799
|
+
function compressIpv6Groups(groups) {
|
|
1800
|
+
const short = groups.map((g) => g.replace(/^0+(?=.)/, ""));
|
|
1801
|
+
let bestStart = -1;
|
|
1802
|
+
let bestLen = 0;
|
|
1803
|
+
let curStart = -1;
|
|
1804
|
+
let curLen = 0;
|
|
1805
|
+
for (let i = 0; i < short.length; i++) {
|
|
1806
|
+
if (short[i] === "0") {
|
|
1807
|
+
if (curStart === -1) curStart = i;
|
|
1808
|
+
curLen++;
|
|
1809
|
+
if (curLen > bestLen) {
|
|
1810
|
+
bestLen = curLen;
|
|
1811
|
+
bestStart = curStart;
|
|
1812
|
+
}
|
|
1813
|
+
} else {
|
|
1814
|
+
curStart = -1;
|
|
1815
|
+
curLen = 0;
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
if (bestLen < 2) return short.join(":");
|
|
1819
|
+
const before = short.slice(0, bestStart).join(":");
|
|
1820
|
+
const after = short.slice(bestStart + bestLen).join(":");
|
|
1821
|
+
return `${before}::${after}`;
|
|
1822
|
+
}
|
|
1823
|
+
function parseIpv6Address(input) {
|
|
1824
|
+
let s = input.trim();
|
|
1825
|
+
if (s.startsWith("[") && s.includes("]")) s = s.slice(1, s.indexOf("]"));
|
|
1826
|
+
let zoneId = null;
|
|
1827
|
+
const pctIdx = s.indexOf("%");
|
|
1828
|
+
if (pctIdx !== -1) {
|
|
1829
|
+
zoneId = s.slice(pctIdx + 1);
|
|
1830
|
+
s = s.slice(0, pctIdx);
|
|
1831
|
+
}
|
|
1832
|
+
if (!s) return { error: "Empty address" };
|
|
1833
|
+
const doubleColonCount = (s.match(/::/g) ?? []).length;
|
|
1834
|
+
if (doubleColonCount > 1) return { error: 'Address contains more than one "::"' };
|
|
1835
|
+
const ipv4Match = s.match(/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
|
|
1836
|
+
if (ipv4Match) {
|
|
1837
|
+
const quad = ipv4Match[1];
|
|
1838
|
+
if (!isValidIpv6Ipv4Quad(quad)) return { error: `Invalid embedded IPv4 address: ${quad}` };
|
|
1839
|
+
const parts = quad.split(".").map(Number);
|
|
1840
|
+
const hi = (parts[0] << 8 | parts[1]).toString(16);
|
|
1841
|
+
const lo = (parts[2] << 8 | parts[3]).toString(16);
|
|
1842
|
+
s = s.slice(0, s.length - quad.length) + `${hi}:${lo}`;
|
|
1843
|
+
}
|
|
1844
|
+
let groups;
|
|
1845
|
+
if (s.includes("::")) {
|
|
1846
|
+
const [left, right] = s.split("::");
|
|
1847
|
+
const leftGroups = left ? left.split(":") : [];
|
|
1848
|
+
const rightGroups = right ? right.split(":") : [];
|
|
1849
|
+
const missing = 8 - (leftGroups.length + rightGroups.length);
|
|
1850
|
+
if (missing < 1) return { error: 'The "::" shorthand must represent at least one group of zeros' };
|
|
1851
|
+
if (![...leftGroups, ...rightGroups].every(isValidIpv6HexGroup)) return { error: "Invalid hex group in address" };
|
|
1852
|
+
groups = [...leftGroups, ...Array(missing).fill("0"), ...rightGroups];
|
|
1853
|
+
} else {
|
|
1854
|
+
groups = s.split(":");
|
|
1855
|
+
if (groups.length !== 8) return { error: `Expected 8 groups, got ${groups.length}` };
|
|
1856
|
+
if (!groups.every(isValidIpv6HexGroup)) return { error: "Invalid hex group in address" };
|
|
1857
|
+
}
|
|
1858
|
+
const expandedGroups = groups.map((g) => g.padStart(4, "0").toLowerCase());
|
|
1859
|
+
const suffix = zoneId ? `%${zoneId}` : "";
|
|
1860
|
+
return {
|
|
1861
|
+
expanded: expandedGroups.join(":") + suffix,
|
|
1862
|
+
compressed: compressIpv6Groups(expandedGroups) + suffix,
|
|
1863
|
+
groups: expandedGroups,
|
|
1864
|
+
zoneId,
|
|
1865
|
+
addressType: classifyIpv6(expandedGroups)
|
|
1866
|
+
};
|
|
1867
|
+
}
|
|
1780
1868
|
|
|
1781
1869
|
exports.DNS_RECORD_TYPES = DNS_RECORD_TYPES;
|
|
1782
1870
|
exports.HTTP_HEADERS = HTTP_HEADERS;
|
|
@@ -1802,6 +1890,7 @@ exports.isValidIpv6 = isValidIpv6;
|
|
|
1802
1890
|
exports.parseDnsResponse = parseDnsResponse;
|
|
1803
1891
|
exports.parseGeoResponse = parseGeoResponse;
|
|
1804
1892
|
exports.parseHar = parseHar;
|
|
1893
|
+
exports.parseIpv6Address = parseIpv6Address;
|
|
1805
1894
|
exports.parseUserAgent = parseUserAgent;
|
|
1806
1895
|
exports.searchHeaders = searchHeaders;
|
|
1807
1896
|
exports.searchStatusCodes = searchStatusCodes;
|
package/dist/tools/network.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as CacheControlDirective, a as CacheControlOptions, b as CacheControlResult, D as DNS_RECORD_TYPES, c as DnsRecord, d as DnsRecordType, e as DnsResponse, G as GeoResult, H as HTTP_HEADERS, f as HarEntry, g as HarParseResult, h as HarSummary, i as HeaderCategory, j as HttpHeader, P as ParsedDnsResult,
|
|
1
|
+
export { C as CacheControlDirective, a as CacheControlOptions, b as CacheControlResult, D as DNS_RECORD_TYPES, c as DnsRecord, d as DnsRecordType, e as DnsResponse, G as GeoResult, H as HTTP_HEADERS, f as HarEntry, g as HarParseResult, h as HarSummary, i as HeaderCategory, j as HttpHeader, I as Ipv6AddressType, k as Ipv6ParseResult, P as ParsedDnsResult, l as ParsedGeoResult, R as RobotsGroup, m as RobotsIssue, o as RobotsRule, p as RobotsValidationResult, S as STATUS_CODES, q as SitemapIndexEntry, r as SitemapIssue, s as SitemapUrlEntry, t as SitemapValidationResult, u as StatusCode, U as UaDeviceType, v as UserAgentInfo, w as buildCacheControl, x as buildDnsQueryUrl, y as buildGeoUrl, z as buildMapUrl, A as countryCodeToFlag, B as formatCoordinates, E as formatTtl, F as getByCategory, J as getHeader, K as getHeadersByCategory, L as getStatusByCategory, M as getStatusCode, N as isClientError, O as isServerError, Q as isSuccess, T as isValidIp, V as isValidIpv4, W as isValidIpv6, X as parseDnsResponse, Y as parseGeoResponse, Z as parseHar, _ as parseIpv6Address, $ as parseUserAgent, a0 as searchHeaders, a1 as searchStatusCodes, a2 as statusCodeToText, a3 as typeNumberToLabel, a4 as validateDomain, a5 as validateHeaderName, a6 as validateHeaderValue, a7 as validateRobotsTxt, a8 as validateSitemap } from '../network-D7Epuerc.cjs';
|
package/dist/tools/network.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as CacheControlDirective, a as CacheControlOptions, b as CacheControlResult, D as DNS_RECORD_TYPES, c as DnsRecord, d as DnsRecordType, e as DnsResponse, G as GeoResult, H as HTTP_HEADERS, f as HarEntry, g as HarParseResult, h as HarSummary, i as HeaderCategory, j as HttpHeader, P as ParsedDnsResult,
|
|
1
|
+
export { C as CacheControlDirective, a as CacheControlOptions, b as CacheControlResult, D as DNS_RECORD_TYPES, c as DnsRecord, d as DnsRecordType, e as DnsResponse, G as GeoResult, H as HTTP_HEADERS, f as HarEntry, g as HarParseResult, h as HarSummary, i as HeaderCategory, j as HttpHeader, I as Ipv6AddressType, k as Ipv6ParseResult, P as ParsedDnsResult, l as ParsedGeoResult, R as RobotsGroup, m as RobotsIssue, o as RobotsRule, p as RobotsValidationResult, S as STATUS_CODES, q as SitemapIndexEntry, r as SitemapIssue, s as SitemapUrlEntry, t as SitemapValidationResult, u as StatusCode, U as UaDeviceType, v as UserAgentInfo, w as buildCacheControl, x as buildDnsQueryUrl, y as buildGeoUrl, z as buildMapUrl, A as countryCodeToFlag, B as formatCoordinates, E as formatTtl, F as getByCategory, J as getHeader, K as getHeadersByCategory, L as getStatusByCategory, M as getStatusCode, N as isClientError, O as isServerError, Q as isSuccess, T as isValidIp, V as isValidIpv4, W as isValidIpv6, X as parseDnsResponse, Y as parseGeoResponse, Z as parseHar, _ as parseIpv6Address, $ as parseUserAgent, a0 as searchHeaders, a1 as searchStatusCodes, a2 as statusCodeToText, a3 as typeNumberToLabel, a4 as validateDomain, a5 as validateHeaderName, a6 as validateHeaderValue, a7 as validateRobotsTxt, a8 as validateSitemap } from '../network-D7Epuerc.js';
|
package/dist/tools/network.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { DNS_RECORD_TYPES, HTTP_HEADERS, STATUS_CODES, buildCacheControl, buildDnsQueryUrl, buildGeoUrl, buildMapUrl, countryCodeToFlag, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, parseDnsResponse, parseGeoResponse, parseHar, parseUserAgent, searchHeaders, searchStatusCodes, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue, validateRobotsTxt, validateSitemap } from '../chunk-
|
|
1
|
+
export { DNS_RECORD_TYPES, HTTP_HEADERS, STATUS_CODES, buildCacheControl, buildDnsQueryUrl, buildGeoUrl, buildMapUrl, countryCodeToFlag, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, parseDnsResponse, parseGeoResponse, parseHar, parseIpv6Address, parseUserAgent, searchHeaders, searchStatusCodes, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue, validateRobotsTxt, validateSitemap } from '../chunk-CSNTHZHF.js';
|
|
2
2
|
import '../chunk-MLKGABMK.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utilix-tech/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"description": "154+ developer utility tools for Node.js: JSON, encoding, hashing, color, CSS, network and more. Runs locally, no API key required.",
|
|
5
5
|
"author": "Utilix <hello@utilix.tech>",
|
|
6
6
|
"license": "MIT",
|