@utilix-tech/sdk 0.44.0 → 0.45.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 +4 -0
- package/README.md +17 -5
- package/dist/{chunk-GZBSKZ6F.js → chunk-7PEKYLRB.js} +104 -1
- package/dist/{chunk-WT3Q5LCN.js → chunk-DFLHX4NW.js} +40 -1
- package/dist/index.cjs +142 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{network-BlOVDE3Y.d.cts → network-Bzm1tjMA.d.cts} +60 -2
- package/dist/{network-BlOVDE3Y.d.ts → network-Bzm1tjMA.d.ts} +60 -2
- package/dist/tools/network.cjs +103 -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 +39 -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-WAgBQ7D7.d.cts → units-DWRmbS_a.d.cts} +29 -2
- package/dist/{units-WAgBQ7D7.d.ts → units-DWRmbS_a.d.ts} +29 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Full release notes for all Utilix surfaces (browser tools, REST API, SDKs, MCP server) live at [utilix.tech/changelog](https://utilix.tech/changelog). This file tracks just this package.
|
|
4
4
|
|
|
5
|
+
## 0.45.0
|
|
6
|
+
- Add `calculateCdMaturity` (cd-maturity-calculator): compute a certificate of deposit's maturity value and effective annual yield (APY) from a principal, nominal rate, term, and compounding frequency, plus the net payout if withdrawn early.
|
|
7
|
+
- Add `buildClientHints`, `parseClientHintHeaders` (client-hints-header-builder): build an `Accept-CH`/`Critical-CH` response header from a list of client hint names with a plain-English note per hint, or decode raw Client Hints request-header text into structured values.
|
|
8
|
+
|
|
5
9
|
## 0.44.0
|
|
6
10
|
- Add `buildPermissionsPolicy`, `parsePermissionsPolicy` (permissions-policy-builder): build a `Permissions-Policy` response header from browser features and their per-feature allowlist with a plain-English note per feature, or parse an existing one into the same shape.
|
|
7
11
|
- Add `calculatePaybackPeriod` (payback-period-calculator): compute the simple and discounted payback period from an initial investment and a series of periodic cash flows.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @utilix-tech/sdk
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**630 developer utility functions for Node.js: runs locally, no API key required.**
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@utilix-tech/sdk)
|
|
6
6
|
[](https://www.npmjs.com/package/@utilix-tech/sdk)
|
|
@@ -312,7 +312,7 @@ formatIso8601Duration(90061); // { iso: "P1DT1H1M1S", ... }
|
|
|
312
312
|
### `/units`: Conversions
|
|
313
313
|
|
|
314
314
|
```ts
|
|
315
|
-
import { convertBytes, pxToAll, convert, formatValue, validateCardNumber, validateIban, calculateLoan, validateBarcode, calculateTax, calculateCompoundInterest, validateIsbn, calculateTipSplit, calculateSimpleInterest, calculateTimeValue, calculatePercentageChange, convertAprApy, calculateMarginMarkup, calculateDiscount, applySuccessiveDiscounts, calculateBreakEven, calculateVideoBitrate, calculateRuleOf72, calculateEmi, calculateRoi, compareUnitPrices, calculatePaybackPeriod } from "@utilix-tech/sdk/units";
|
|
315
|
+
import { convertBytes, pxToAll, convert, formatValue, validateCardNumber, validateIban, calculateLoan, validateBarcode, calculateTax, calculateCompoundInterest, validateIsbn, calculateTipSplit, calculateSimpleInterest, calculateTimeValue, calculatePercentageChange, convertAprApy, calculateMarginMarkup, calculateDiscount, applySuccessiveDiscounts, calculateBreakEven, calculateVideoBitrate, calculateRuleOf72, calculateEmi, calculateRoi, compareUnitPrices, calculatePaybackPeriod, calculateCdMaturity } from "@utilix-tech/sdk/units";
|
|
316
316
|
|
|
317
317
|
// File sizes
|
|
318
318
|
convertBytes(1073741824, "GB"); // 1
|
|
@@ -426,6 +426,10 @@ calculateChange(4.65, 5.0, USD_DENOMINATIONS);
|
|
|
426
426
|
// Payback period: simple + discounted, from an initial investment and periodic cash flows
|
|
427
427
|
calculatePaybackPeriod({ initialInvestment: 1000, cashFlows: [400, 400, 400], discountRatePercent: 8 });
|
|
428
428
|
// { paybackPeriod: 2.5, paybackPeriodRounded: 3, recovered: true, discountedPaybackPeriod: 2.9029, ... }
|
|
429
|
+
|
|
430
|
+
// Certificate of deposit maturity value, APY, and net early-withdrawal payout
|
|
431
|
+
calculateCdMaturity(1000, 12, 12, 12, 3);
|
|
432
|
+
// { maturityValue: 1126.83, totalInterest: 126.83, apy: 12.6825, earlyWithdrawalPayout: 1096.83, ... }
|
|
429
433
|
```
|
|
430
434
|
|
|
431
435
|
---
|
|
@@ -438,7 +442,7 @@ import { getStatusCode, isValidIp, isValidIpv4, isValidIpv6,
|
|
|
438
442
|
parseHar, validateSitemap, validateRobotsTxt,
|
|
439
443
|
parseUserAgent, buildCacheControl, buildReferrerPolicy, parseIpv6Address, buildLinkHeader, checkSetCookieHeader, analyzeEmailHeaders,
|
|
440
444
|
buildRangeHeader, parseContentRangeHeader, buildVaryHeader, parseVaryHeader, validateManifest,
|
|
441
|
-
buildPermissionsPolicy, parsePermissionsPolicy } from "@utilix-tech/sdk/network";
|
|
445
|
+
buildPermissionsPolicy, parsePermissionsPolicy, buildClientHints, parseClientHintHeaders } from "@utilix-tech/sdk/network";
|
|
442
446
|
|
|
443
447
|
getStatusCode(404);
|
|
444
448
|
// { code: 404, text: "Not Found", description: "...", category: "Client Error" }
|
|
@@ -521,6 +525,14 @@ buildPermissionsPolicy([{ feature: "camera", allowlist: [] }, { feature: "geoloc
|
|
|
521
525
|
// Parse an existing Permissions-Policy header value into the same shape
|
|
522
526
|
parsePermissionsPolicy("camera=(), geolocation=(self)");
|
|
523
527
|
// { header: "Permissions-Policy: camera=(), geolocation=(self)", directives: [...], warnings: [] }
|
|
528
|
+
|
|
529
|
+
// Build an Accept-CH header from a list of client hint names, with a plain-English note per hint
|
|
530
|
+
buildClientHints(["Sec-CH-UA-Platform", "Sec-CH-DPR"]);
|
|
531
|
+
// { acceptCH: "Sec-CH-UA-Platform, Sec-CH-DPR", hints: [...] }
|
|
532
|
+
|
|
533
|
+
// Decode raw Client Hints request-header text into structured values
|
|
534
|
+
parseClientHintHeaders("Sec-CH-UA-Mobile: ?0");
|
|
535
|
+
// { hints: [{ name: "Sec-CH-UA-Mobile", value: false, ... }], unrecognized: [] }
|
|
524
536
|
```
|
|
525
537
|
|
|
526
538
|
---
|
|
@@ -758,8 +770,8 @@ readVideoInfo(new Uint8Array(videoBytes));
|
|
|
758
770
|
| `@utilix-tech/sdk/data` | CSV, YAML, TOML, XML, INI, NDJSON parse and convert, SRT/WebVTT subtitles, Markdown front matter parser |
|
|
759
771
|
| `@utilix-tech/sdk/generators` | UUID v4/v7, ULID, passwords, strength check, entropy estimator, fake data |
|
|
760
772
|
| `@utilix-tech/sdk/time` | Date diff, timezone convert, cron parse, relative time |
|
|
761
|
-
| `@utilix-tech/sdk/units` | Bytes, CSS px/rem, number bases, currency format, credit card/IBAN/barcode/ISBN validation, loan calculator, EMI calculator, compound/simple interest calculators, VAT/sales tax calculator, tip/bill split calculator, break-even point calculator, Rule of 72 calculator, savings goal calculator, ROI calculator, cash denomination/till calculator, payback period calculator |
|
|
762
|
-
| `@utilix-tech/sdk/network` | HTTP status codes, IP validation, country flags, geolocation URLs, HAR file parsing, User-Agent parsing, IPv6 address compress/expand, Permissions-Policy header builder |
|
|
773
|
+
| `@utilix-tech/sdk/units` | Bytes, CSS px/rem, number bases, currency format, credit card/IBAN/barcode/ISBN validation, loan calculator, EMI calculator, compound/simple interest calculators, VAT/sales tax calculator, tip/bill split calculator, break-even point calculator, Rule of 72 calculator, savings goal calculator, ROI calculator, cash denomination/till calculator, payback period calculator, CD maturity calculator |
|
|
774
|
+
| `@utilix-tech/sdk/network` | HTTP status codes, IP validation, country flags, geolocation URLs, HAR file parsing, User-Agent parsing, IPv6 address compress/expand, Permissions-Policy header builder, Client Hints header builder/parser |
|
|
763
775
|
| `@utilix-tech/sdk/api` | cURL build/parse, JWT decode/sign, JWKS parse, CORS headers, CSP header |
|
|
764
776
|
| `@utilix-tech/sdk/code` | SQL format/minify, HTML format/minify, regex tester, GraphQL format, MIME type lookup, GitHub URL parsing, regex ReDoS detector, Conventional Commits linter |
|
|
765
777
|
| `@utilix-tech/sdk/color` | Hex/RGB/HSL/HSV/CMYK convert, palette generation, contrast check |
|
|
@@ -3,6 +3,7 @@ import { __export } from './chunk-MLKGABMK.js';
|
|
|
3
3
|
// src/tools/network.ts
|
|
4
4
|
var network_exports = {};
|
|
5
5
|
__export(network_exports, {
|
|
6
|
+
CLIENT_HINTS: () => CLIENT_HINTS,
|
|
6
7
|
DNS_RECORD_TYPES: () => DNS_RECORD_TYPES,
|
|
7
8
|
HTTP_HEADERS: () => HTTP_HEADERS,
|
|
8
9
|
LINK_REL_VALUES: () => LINK_REL_VALUES,
|
|
@@ -11,6 +12,7 @@ __export(network_exports, {
|
|
|
11
12
|
STATUS_CODES: () => STATUS_CODES,
|
|
12
13
|
analyzeEmailHeaders: () => analyzeEmailHeaders,
|
|
13
14
|
buildCacheControl: () => buildCacheControl,
|
|
15
|
+
buildClientHints: () => buildClientHints,
|
|
14
16
|
buildDnsQueryUrl: () => buildDnsQueryUrl,
|
|
15
17
|
buildGeoUrl: () => buildGeoUrl,
|
|
16
18
|
buildLinkHeader: () => buildLinkHeader,
|
|
@@ -34,6 +36,7 @@ __export(network_exports, {
|
|
|
34
36
|
isValidIp: () => isValidIp,
|
|
35
37
|
isValidIpv4: () => isValidIpv4,
|
|
36
38
|
isValidIpv6: () => isValidIpv6,
|
|
39
|
+
parseClientHintHeaders: () => parseClientHintHeaders,
|
|
37
40
|
parseContentRangeHeader: () => parseContentRangeHeader,
|
|
38
41
|
parseDnsResponse: () => parseDnsResponse,
|
|
39
42
|
parseGeoResponse: () => parseGeoResponse,
|
|
@@ -2575,5 +2578,105 @@ function parsePermissionsPolicy(raw) {
|
|
|
2575
2578
|
if (features.length === 0) return { error: "No directives found" };
|
|
2576
2579
|
return buildPermissionsPolicy(features);
|
|
2577
2580
|
}
|
|
2581
|
+
var CLIENT_HINTS = [
|
|
2582
|
+
{ name: "Sec-CH-UA", description: "The browser's brand(s) and significant version, sent automatically on every request without an Accept-CH opt-in.", lowEntropy: true, valueType: "sf-list-brand" },
|
|
2583
|
+
{ name: "Sec-CH-UA-Mobile", description: "Whether the browser is running on a mobile device (?1) or not (?0).", lowEntropy: true, valueType: "boolean" },
|
|
2584
|
+
{ name: "Sec-CH-UA-Platform", description: 'The platform/OS the browser is running on, e.g. "Windows" or "Android".', lowEntropy: true, valueType: "string" },
|
|
2585
|
+
{ name: "Sec-CH-UA-Full-Version-List", description: "The full version number for each brand in the user agent, not just the significant version.", lowEntropy: false, valueType: "sf-list-brand" },
|
|
2586
|
+
{ name: "Sec-CH-UA-Platform-Version", description: 'The exact OS version, e.g. "15.0.0".', lowEntropy: false, valueType: "string" },
|
|
2587
|
+
{ name: "Sec-CH-UA-Arch", description: 'The underlying CPU architecture, e.g. "x86" or "arm".', lowEntropy: false, valueType: "string" },
|
|
2588
|
+
{ name: "Sec-CH-UA-Bitness", description: 'The CPU architecture bitness, e.g. "64".', lowEntropy: false, valueType: "string" },
|
|
2589
|
+
{ name: "Sec-CH-UA-Model", description: "The device model, mostly populated on mobile devices.", lowEntropy: false, valueType: "string" },
|
|
2590
|
+
{ name: "Sec-CH-UA-WoW64", description: "Whether a 32-bit browser is running on 64-bit Windows.", lowEntropy: false, valueType: "boolean" },
|
|
2591
|
+
{ name: "Sec-CH-UA-Form-Factor", description: `The device's form factor, e.g. "Desktop", "Mobile", "Tablet", or "XR".`, lowEntropy: false, valueType: "string" },
|
|
2592
|
+
{ name: "Sec-CH-Prefers-Color-Scheme", description: "The user's preferred color scheme, mirrors the prefers-color-scheme media feature.", lowEntropy: false, valueType: "string" },
|
|
2593
|
+
{ name: "Sec-CH-Prefers-Reduced-Motion", description: "Whether the user has requested reduced motion.", lowEntropy: false, valueType: "string" },
|
|
2594
|
+
{ name: "Sec-CH-Prefers-Reduced-Transparency", description: "Whether the user has requested reduced transparency.", lowEntropy: false, valueType: "string" },
|
|
2595
|
+
{ name: "Sec-CH-Viewport-Width", description: "The layout viewport width in CSS pixels.", lowEntropy: false, valueType: "number" },
|
|
2596
|
+
{ name: "Sec-CH-Viewport-Height", description: "The layout viewport height in CSS pixels.", lowEntropy: false, valueType: "number" },
|
|
2597
|
+
{ name: "Sec-CH-DPR", description: "The device pixel ratio.", lowEntropy: false, valueType: "number" },
|
|
2598
|
+
{ name: "Sec-CH-Width", description: "The intrinsic width of a requested image resource, set per-request via the image's `sizes` attribute.", lowEntropy: false, valueType: "number" },
|
|
2599
|
+
{ name: "Sec-CH-Device-Memory", description: "Approximate device RAM in GiB, rounded to the nearest power of two for privacy.", lowEntropy: false, valueType: "number" },
|
|
2600
|
+
{ name: "Save-Data", description: "Legacy hint signaling the user opted into a reduced-data mode; sent automatically like a low-entropy hint.", lowEntropy: true, valueType: "boolean" }
|
|
2601
|
+
];
|
|
2602
|
+
function _findClientHint(raw) {
|
|
2603
|
+
const normalized = raw.trim().toLowerCase();
|
|
2604
|
+
return CLIENT_HINTS.find((d) => d.name.toLowerCase() === normalized);
|
|
2605
|
+
}
|
|
2606
|
+
function buildClientHints(hintNames, criticalHintNames = []) {
|
|
2607
|
+
if (!Array.isArray(hintNames) || hintNames.length === 0) return { error: "At least one client hint is required" };
|
|
2608
|
+
const resolved = [];
|
|
2609
|
+
for (const raw of hintNames) {
|
|
2610
|
+
if (typeof raw !== "string" || raw.trim() === "") continue;
|
|
2611
|
+
const def = _findClientHint(raw);
|
|
2612
|
+
if (!def) return { error: `Unknown client hint: "${raw}"` };
|
|
2613
|
+
resolved.push(def);
|
|
2614
|
+
}
|
|
2615
|
+
if (resolved.length === 0) return { error: "At least one client hint is required" };
|
|
2616
|
+
const critical = [];
|
|
2617
|
+
if (Array.isArray(criticalHintNames)) {
|
|
2618
|
+
for (const raw of criticalHintNames) {
|
|
2619
|
+
if (typeof raw !== "string" || raw.trim() === "") continue;
|
|
2620
|
+
const def = _findClientHint(raw);
|
|
2621
|
+
if (!def) return { error: `Unknown client hint: "${raw}"` };
|
|
2622
|
+
if (!resolved.some((d) => d.name === def.name)) {
|
|
2623
|
+
return { error: `Critical hint "${def.name}" must also be included in hintNames` };
|
|
2624
|
+
}
|
|
2625
|
+
critical.push(def);
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
const uniqueNames = Array.from(new Set(resolved.map((d) => d.name)));
|
|
2629
|
+
const result = {
|
|
2630
|
+
acceptCH: uniqueNames.join(", "),
|
|
2631
|
+
hints: resolved.map((d) => ({ name: d.name, description: d.description, lowEntropy: d.lowEntropy }))
|
|
2632
|
+
};
|
|
2633
|
+
if (critical.length > 0) {
|
|
2634
|
+
result.criticalCH = Array.from(new Set(critical.map((d) => d.name))).join(", ");
|
|
2635
|
+
}
|
|
2636
|
+
return result;
|
|
2637
|
+
}
|
|
2638
|
+
function _decodeClientHintValue(valueType, rawValue) {
|
|
2639
|
+
switch (valueType) {
|
|
2640
|
+
case "boolean":
|
|
2641
|
+
if (rawValue === "?1") return true;
|
|
2642
|
+
if (rawValue === "?0") return false;
|
|
2643
|
+
return rawValue;
|
|
2644
|
+
case "string":
|
|
2645
|
+
return rawValue.replace(/^"|"$/g, "");
|
|
2646
|
+
case "number": {
|
|
2647
|
+
const n = Number(rawValue);
|
|
2648
|
+
return Number.isFinite(n) ? n : rawValue;
|
|
2649
|
+
}
|
|
2650
|
+
case "sf-list-brand":
|
|
2651
|
+
return rawValue.split(",").map((part) => {
|
|
2652
|
+
const m = part.trim().match(/^"([^"]*)";v="([^"]*)"$/);
|
|
2653
|
+
return m ? { brand: m[1], version: m[2] } : { raw: part.trim() };
|
|
2654
|
+
});
|
|
2655
|
+
default:
|
|
2656
|
+
return rawValue;
|
|
2657
|
+
}
|
|
2658
|
+
}
|
|
2659
|
+
function parseClientHintHeaders(rawHeaders) {
|
|
2660
|
+
if (typeof rawHeaders !== "string" || rawHeaders.trim() === "") return { error: "Provide one or more header lines to parse" };
|
|
2661
|
+
const lines = rawHeaders.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
|
|
2662
|
+
const hints = [];
|
|
2663
|
+
const unrecognized = [];
|
|
2664
|
+
for (const line of lines) {
|
|
2665
|
+
const idx = line.indexOf(":");
|
|
2666
|
+
if (idx === -1) continue;
|
|
2667
|
+
const name = line.slice(0, idx).trim();
|
|
2668
|
+
const rawValue = line.slice(idx + 1).trim();
|
|
2669
|
+
const def = _findClientHint(name);
|
|
2670
|
+
if (!def) {
|
|
2671
|
+
unrecognized.push({ name, rawValue });
|
|
2672
|
+
continue;
|
|
2673
|
+
}
|
|
2674
|
+
hints.push({ name: def.name, rawValue, description: def.description, value: _decodeClientHintValue(def.valueType, rawValue) });
|
|
2675
|
+
}
|
|
2676
|
+
if (hints.length === 0 && unrecognized.length === 0) {
|
|
2677
|
+
return { error: 'No parsable header lines found (expected "Header-Name: value" per line)' };
|
|
2678
|
+
}
|
|
2679
|
+
return { hints, unrecognized };
|
|
2680
|
+
}
|
|
2578
2681
|
|
|
2579
|
-
export { DNS_RECORD_TYPES, HTTP_HEADERS, LINK_REL_VALUES, PERMISSIONS_POLICY_FEATURES, REFERRER_POLICY_VALUES, STATUS_CODES, analyzeEmailHeaders, buildCacheControl, buildDnsQueryUrl, buildGeoUrl, buildLinkHeader, buildMapUrl, buildPermissionsPolicy, buildRangeHeader, buildReferrerPolicy, buildVaryHeader, checkSetCookieHeader, countryCodeToFlag, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, network_exports, parseContentRangeHeader, parseDnsResponse, parseGeoResponse, parseHar, parseIpv6Address, parsePermissionsPolicy, parseUserAgent, parseVaryHeader, searchHeaders, searchStatusCodes, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue, validateManifest, validateRobotsTxt, validateSitemap };
|
|
2682
|
+
export { CLIENT_HINTS, DNS_RECORD_TYPES, HTTP_HEADERS, LINK_REL_VALUES, PERMISSIONS_POLICY_FEATURES, REFERRER_POLICY_VALUES, STATUS_CODES, analyzeEmailHeaders, buildCacheControl, buildClientHints, buildDnsQueryUrl, buildGeoUrl, buildLinkHeader, buildMapUrl, buildPermissionsPolicy, buildRangeHeader, buildReferrerPolicy, buildVaryHeader, checkSetCookieHeader, countryCodeToFlag, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, network_exports, parseClientHintHeaders, parseContentRangeHeader, parseDnsResponse, parseGeoResponse, parseHar, parseIpv6Address, parsePermissionsPolicy, parseUserAgent, parseVaryHeader, searchHeaders, searchStatusCodes, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue, validateManifest, validateRobotsTxt, validateSitemap };
|
|
@@ -22,6 +22,7 @@ __export(units_exports, {
|
|
|
22
22
|
calcSubnet: () => calcSubnet,
|
|
23
23
|
calculateBreakEven: () => calculateBreakEven,
|
|
24
24
|
calculateCashBreakdown: () => calculateCashBreakdown,
|
|
25
|
+
calculateCdMaturity: () => calculateCdMaturity,
|
|
25
26
|
calculateChange: () => calculateChange,
|
|
26
27
|
calculateCompoundInterest: () => calculateCompoundInterest,
|
|
27
28
|
calculateDiscount: () => calculateDiscount,
|
|
@@ -1983,5 +1984,43 @@ function calculatePaybackPeriod(input) {
|
|
|
1983
1984
|
}
|
|
1984
1985
|
return result;
|
|
1985
1986
|
}
|
|
1987
|
+
function calculateCdMaturity(principal, annualRatePercent, termMonths, compoundsPerYear, earlyWithdrawalPenaltyMonths) {
|
|
1988
|
+
if (!Number.isFinite(principal) || principal <= 0) return { error: "Principal must be a finite number greater than zero" };
|
|
1989
|
+
if (!Number.isFinite(annualRatePercent) || annualRatePercent < 0) {
|
|
1990
|
+
return { error: "Annual interest rate must be zero or a positive number" };
|
|
1991
|
+
}
|
|
1992
|
+
if (!Number.isFinite(termMonths) || termMonths <= 0) return { error: "Term must be a positive number of months" };
|
|
1993
|
+
if (!Number.isInteger(compoundsPerYear) || compoundsPerYear <= 0) {
|
|
1994
|
+
return { error: "Compounding frequency must be a positive whole number of periods per year" };
|
|
1995
|
+
}
|
|
1996
|
+
if (earlyWithdrawalPenaltyMonths !== void 0 && (!Number.isFinite(earlyWithdrawalPenaltyMonths) || earlyWithdrawalPenaltyMonths < 0)) {
|
|
1997
|
+
return { error: "earlyWithdrawalPenaltyMonths must be zero or a positive number when provided" };
|
|
1998
|
+
}
|
|
1999
|
+
const round22 = (n) => Math.round(n * 100) / 100;
|
|
2000
|
+
const round4 = (n) => Math.round(n * 1e4) / 1e4;
|
|
2001
|
+
const ratePerPeriod = annualRatePercent / 100 / compoundsPerYear;
|
|
2002
|
+
const totalPeriods = compoundsPerYear * (termMonths / 12);
|
|
2003
|
+
const growth = ratePerPeriod === 0 ? 1 : Math.pow(1 + ratePerPeriod, totalPeriods);
|
|
2004
|
+
const maturityValue = principal * growth;
|
|
2005
|
+
const totalInterest = maturityValue - principal;
|
|
2006
|
+
const apy = ratePerPeriod === 0 ? 0 : (Math.pow(1 + ratePerPeriod, compoundsPerYear) - 1) * 100;
|
|
2007
|
+
const result = {
|
|
2008
|
+
principal: round22(principal),
|
|
2009
|
+
annualRatePercent: round4(annualRatePercent),
|
|
2010
|
+
termMonths,
|
|
2011
|
+
compoundsPerYear,
|
|
2012
|
+
maturityValue: round22(maturityValue),
|
|
2013
|
+
totalInterest: round22(totalInterest),
|
|
2014
|
+
apy: round4(apy)
|
|
2015
|
+
};
|
|
2016
|
+
if (earlyWithdrawalPenaltyMonths !== void 0) {
|
|
2017
|
+
const monthlyRate = annualRatePercent / 100 / 12;
|
|
2018
|
+
const forfeited = Math.min(principal * monthlyRate * earlyWithdrawalPenaltyMonths, Math.max(totalInterest, 0));
|
|
2019
|
+
result.earlyWithdrawalPenaltyMonths = earlyWithdrawalPenaltyMonths;
|
|
2020
|
+
result.earlyWithdrawalForfeitedInterest = round22(forfeited);
|
|
2021
|
+
result.earlyWithdrawalPayout = round22(maturityValue - forfeited);
|
|
2022
|
+
}
|
|
2023
|
+
return result;
|
|
2024
|
+
}
|
|
1986
2025
|
|
|
1987
|
-
export { BASE_LABELS, BASE_PREFIXES, BYTE_UNITS, COMMON_CURRENCIES, COMMON_LOCALES, COMMON_PERMISSIONS, COMMON_RATIOS, COMMON_SIZES, COMMON_TAX_RATES, COMMON_TIP_PERCENTAGES, COMMON_VIEWPORTS, USD_DENOMINATIONS, applySuccessiveDiscounts, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateBreakEven, calculateCashBreakdown, calculateChange, calculateCompoundInterest, calculateDiscount, calculateEmi, calculateLoan, calculateMarginMarkup, calculatePaybackPeriod, calculatePercentageChange, calculateRoi, calculateRuleOf72, calculateSavingsGoal, calculateSimpleInterest, calculateTax, calculateTimeValue, calculateTipSplit, calculateVideoBitrate, compareSemver, compareUnitPrices, convert, convertAprApy, convertBytes, convertIp, coverBox, decimalToIp, decimalToIpCidr, describePermissions, fitIntoBox, formatNumber, formatValue, formatVwValue, formatWithSeparator, gcd, ipFromBinary, ipFromDecimal, ipFromHex, ipToBinary, ipToDecimal, ipToDecimalCidr, ipToHex, ipToOctal, isValid, isValidCidr, isValidIp, isValidIpv4, marginToMarkup, markupToMargin, octalToPermissions, parseFileSize, parseInput, parseNumberString, parseSemver, permissionsToChmod, permissionsToOctal, permissionsToSymbolic, ptToPx, pxToAll, pxToViewport, remToPx, satisfiesRange, scaleByHeight, scaleByWidth, sortVersions, splitSubnet, symbolicToPermissions, units_exports, validateBarcode, validateCardNumber, validateIban, validateIsbn, viewportToPx };
|
|
2026
|
+
export { BASE_LABELS, BASE_PREFIXES, BYTE_UNITS, COMMON_CURRENCIES, COMMON_LOCALES, COMMON_PERMISSIONS, COMMON_RATIOS, COMMON_SIZES, COMMON_TAX_RATES, COMMON_TIP_PERCENTAGES, COMMON_VIEWPORTS, USD_DENOMINATIONS, applySuccessiveDiscounts, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateBreakEven, calculateCashBreakdown, calculateCdMaturity, calculateChange, calculateCompoundInterest, calculateDiscount, calculateEmi, calculateLoan, calculateMarginMarkup, calculatePaybackPeriod, calculatePercentageChange, calculateRoi, calculateRuleOf72, calculateSavingsGoal, calculateSimpleInterest, calculateTax, calculateTimeValue, calculateTipSplit, calculateVideoBitrate, compareSemver, compareUnitPrices, convert, convertAprApy, convertBytes, convertIp, coverBox, decimalToIp, decimalToIpCidr, describePermissions, fitIntoBox, formatNumber, formatValue, formatVwValue, formatWithSeparator, gcd, ipFromBinary, ipFromDecimal, ipFromHex, ipToBinary, ipToDecimal, ipToDecimalCidr, ipToHex, ipToOctal, isValid, isValidCidr, isValidIp, isValidIpv4, marginToMarkup, markupToMargin, octalToPermissions, parseFileSize, parseInput, parseNumberString, parseSemver, permissionsToChmod, permissionsToOctal, permissionsToSymbolic, ptToPx, pxToAll, pxToViewport, remToPx, satisfiesRange, scaleByHeight, scaleByWidth, sortVersions, splitSubnet, symbolicToPermissions, units_exports, validateBarcode, validateCardNumber, validateIban, validateIsbn, viewportToPx };
|
package/dist/index.cjs
CHANGED
|
@@ -7999,6 +7999,7 @@ __export(units_exports, {
|
|
|
7999
7999
|
calcSubnet: () => calcSubnet,
|
|
8000
8000
|
calculateBreakEven: () => calculateBreakEven,
|
|
8001
8001
|
calculateCashBreakdown: () => calculateCashBreakdown,
|
|
8002
|
+
calculateCdMaturity: () => calculateCdMaturity,
|
|
8002
8003
|
calculateChange: () => calculateChange,
|
|
8003
8004
|
calculateCompoundInterest: () => calculateCompoundInterest,
|
|
8004
8005
|
calculateDiscount: () => calculateDiscount,
|
|
@@ -9960,10 +9961,49 @@ function calculatePaybackPeriod(input) {
|
|
|
9960
9961
|
}
|
|
9961
9962
|
return result;
|
|
9962
9963
|
}
|
|
9964
|
+
function calculateCdMaturity(principal, annualRatePercent, termMonths, compoundsPerYear, earlyWithdrawalPenaltyMonths) {
|
|
9965
|
+
if (!Number.isFinite(principal) || principal <= 0) return { error: "Principal must be a finite number greater than zero" };
|
|
9966
|
+
if (!Number.isFinite(annualRatePercent) || annualRatePercent < 0) {
|
|
9967
|
+
return { error: "Annual interest rate must be zero or a positive number" };
|
|
9968
|
+
}
|
|
9969
|
+
if (!Number.isFinite(termMonths) || termMonths <= 0) return { error: "Term must be a positive number of months" };
|
|
9970
|
+
if (!Number.isInteger(compoundsPerYear) || compoundsPerYear <= 0) {
|
|
9971
|
+
return { error: "Compounding frequency must be a positive whole number of periods per year" };
|
|
9972
|
+
}
|
|
9973
|
+
if (earlyWithdrawalPenaltyMonths !== void 0 && (!Number.isFinite(earlyWithdrawalPenaltyMonths) || earlyWithdrawalPenaltyMonths < 0)) {
|
|
9974
|
+
return { error: "earlyWithdrawalPenaltyMonths must be zero or a positive number when provided" };
|
|
9975
|
+
}
|
|
9976
|
+
const round23 = (n) => Math.round(n * 100) / 100;
|
|
9977
|
+
const round4 = (n) => Math.round(n * 1e4) / 1e4;
|
|
9978
|
+
const ratePerPeriod = annualRatePercent / 100 / compoundsPerYear;
|
|
9979
|
+
const totalPeriods = compoundsPerYear * (termMonths / 12);
|
|
9980
|
+
const growth = ratePerPeriod === 0 ? 1 : Math.pow(1 + ratePerPeriod, totalPeriods);
|
|
9981
|
+
const maturityValue = principal * growth;
|
|
9982
|
+
const totalInterest = maturityValue - principal;
|
|
9983
|
+
const apy = ratePerPeriod === 0 ? 0 : (Math.pow(1 + ratePerPeriod, compoundsPerYear) - 1) * 100;
|
|
9984
|
+
const result = {
|
|
9985
|
+
principal: round23(principal),
|
|
9986
|
+
annualRatePercent: round4(annualRatePercent),
|
|
9987
|
+
termMonths,
|
|
9988
|
+
compoundsPerYear,
|
|
9989
|
+
maturityValue: round23(maturityValue),
|
|
9990
|
+
totalInterest: round23(totalInterest),
|
|
9991
|
+
apy: round4(apy)
|
|
9992
|
+
};
|
|
9993
|
+
if (earlyWithdrawalPenaltyMonths !== void 0) {
|
|
9994
|
+
const monthlyRate = annualRatePercent / 100 / 12;
|
|
9995
|
+
const forfeited = Math.min(principal * monthlyRate * earlyWithdrawalPenaltyMonths, Math.max(totalInterest, 0));
|
|
9996
|
+
result.earlyWithdrawalPenaltyMonths = earlyWithdrawalPenaltyMonths;
|
|
9997
|
+
result.earlyWithdrawalForfeitedInterest = round23(forfeited);
|
|
9998
|
+
result.earlyWithdrawalPayout = round23(maturityValue - forfeited);
|
|
9999
|
+
}
|
|
10000
|
+
return result;
|
|
10001
|
+
}
|
|
9963
10002
|
|
|
9964
10003
|
// src/tools/network.ts
|
|
9965
10004
|
var network_exports = {};
|
|
9966
10005
|
__export(network_exports, {
|
|
10006
|
+
CLIENT_HINTS: () => CLIENT_HINTS,
|
|
9967
10007
|
DNS_RECORD_TYPES: () => DNS_RECORD_TYPES,
|
|
9968
10008
|
HTTP_HEADERS: () => HTTP_HEADERS,
|
|
9969
10009
|
LINK_REL_VALUES: () => LINK_REL_VALUES,
|
|
@@ -9972,6 +10012,7 @@ __export(network_exports, {
|
|
|
9972
10012
|
STATUS_CODES: () => STATUS_CODES,
|
|
9973
10013
|
analyzeEmailHeaders: () => analyzeEmailHeaders,
|
|
9974
10014
|
buildCacheControl: () => buildCacheControl,
|
|
10015
|
+
buildClientHints: () => buildClientHints,
|
|
9975
10016
|
buildDnsQueryUrl: () => buildDnsQueryUrl,
|
|
9976
10017
|
buildGeoUrl: () => buildGeoUrl,
|
|
9977
10018
|
buildLinkHeader: () => buildLinkHeader,
|
|
@@ -9995,6 +10036,7 @@ __export(network_exports, {
|
|
|
9995
10036
|
isValidIp: () => isValidIp2,
|
|
9996
10037
|
isValidIpv4: () => isValidIpv42,
|
|
9997
10038
|
isValidIpv6: () => isValidIpv6,
|
|
10039
|
+
parseClientHintHeaders: () => parseClientHintHeaders,
|
|
9998
10040
|
parseContentRangeHeader: () => parseContentRangeHeader,
|
|
9999
10041
|
parseDnsResponse: () => parseDnsResponse,
|
|
10000
10042
|
parseGeoResponse: () => parseGeoResponse,
|
|
@@ -12536,6 +12578,106 @@ function parsePermissionsPolicy(raw) {
|
|
|
12536
12578
|
if (features.length === 0) return { error: "No directives found" };
|
|
12537
12579
|
return buildPermissionsPolicy(features);
|
|
12538
12580
|
}
|
|
12581
|
+
var CLIENT_HINTS = [
|
|
12582
|
+
{ name: "Sec-CH-UA", description: "The browser's brand(s) and significant version, sent automatically on every request without an Accept-CH opt-in.", lowEntropy: true, valueType: "sf-list-brand" },
|
|
12583
|
+
{ name: "Sec-CH-UA-Mobile", description: "Whether the browser is running on a mobile device (?1) or not (?0).", lowEntropy: true, valueType: "boolean" },
|
|
12584
|
+
{ name: "Sec-CH-UA-Platform", description: 'The platform/OS the browser is running on, e.g. "Windows" or "Android".', lowEntropy: true, valueType: "string" },
|
|
12585
|
+
{ name: "Sec-CH-UA-Full-Version-List", description: "The full version number for each brand in the user agent, not just the significant version.", lowEntropy: false, valueType: "sf-list-brand" },
|
|
12586
|
+
{ name: "Sec-CH-UA-Platform-Version", description: 'The exact OS version, e.g. "15.0.0".', lowEntropy: false, valueType: "string" },
|
|
12587
|
+
{ name: "Sec-CH-UA-Arch", description: 'The underlying CPU architecture, e.g. "x86" or "arm".', lowEntropy: false, valueType: "string" },
|
|
12588
|
+
{ name: "Sec-CH-UA-Bitness", description: 'The CPU architecture bitness, e.g. "64".', lowEntropy: false, valueType: "string" },
|
|
12589
|
+
{ name: "Sec-CH-UA-Model", description: "The device model, mostly populated on mobile devices.", lowEntropy: false, valueType: "string" },
|
|
12590
|
+
{ name: "Sec-CH-UA-WoW64", description: "Whether a 32-bit browser is running on 64-bit Windows.", lowEntropy: false, valueType: "boolean" },
|
|
12591
|
+
{ name: "Sec-CH-UA-Form-Factor", description: `The device's form factor, e.g. "Desktop", "Mobile", "Tablet", or "XR".`, lowEntropy: false, valueType: "string" },
|
|
12592
|
+
{ name: "Sec-CH-Prefers-Color-Scheme", description: "The user's preferred color scheme, mirrors the prefers-color-scheme media feature.", lowEntropy: false, valueType: "string" },
|
|
12593
|
+
{ name: "Sec-CH-Prefers-Reduced-Motion", description: "Whether the user has requested reduced motion.", lowEntropy: false, valueType: "string" },
|
|
12594
|
+
{ name: "Sec-CH-Prefers-Reduced-Transparency", description: "Whether the user has requested reduced transparency.", lowEntropy: false, valueType: "string" },
|
|
12595
|
+
{ name: "Sec-CH-Viewport-Width", description: "The layout viewport width in CSS pixels.", lowEntropy: false, valueType: "number" },
|
|
12596
|
+
{ name: "Sec-CH-Viewport-Height", description: "The layout viewport height in CSS pixels.", lowEntropy: false, valueType: "number" },
|
|
12597
|
+
{ name: "Sec-CH-DPR", description: "The device pixel ratio.", lowEntropy: false, valueType: "number" },
|
|
12598
|
+
{ name: "Sec-CH-Width", description: "The intrinsic width of a requested image resource, set per-request via the image's `sizes` attribute.", lowEntropy: false, valueType: "number" },
|
|
12599
|
+
{ name: "Sec-CH-Device-Memory", description: "Approximate device RAM in GiB, rounded to the nearest power of two for privacy.", lowEntropy: false, valueType: "number" },
|
|
12600
|
+
{ name: "Save-Data", description: "Legacy hint signaling the user opted into a reduced-data mode; sent automatically like a low-entropy hint.", lowEntropy: true, valueType: "boolean" }
|
|
12601
|
+
];
|
|
12602
|
+
function _findClientHint(raw) {
|
|
12603
|
+
const normalized = raw.trim().toLowerCase();
|
|
12604
|
+
return CLIENT_HINTS.find((d) => d.name.toLowerCase() === normalized);
|
|
12605
|
+
}
|
|
12606
|
+
function buildClientHints(hintNames, criticalHintNames = []) {
|
|
12607
|
+
if (!Array.isArray(hintNames) || hintNames.length === 0) return { error: "At least one client hint is required" };
|
|
12608
|
+
const resolved = [];
|
|
12609
|
+
for (const raw of hintNames) {
|
|
12610
|
+
if (typeof raw !== "string" || raw.trim() === "") continue;
|
|
12611
|
+
const def = _findClientHint(raw);
|
|
12612
|
+
if (!def) return { error: `Unknown client hint: "${raw}"` };
|
|
12613
|
+
resolved.push(def);
|
|
12614
|
+
}
|
|
12615
|
+
if (resolved.length === 0) return { error: "At least one client hint is required" };
|
|
12616
|
+
const critical = [];
|
|
12617
|
+
if (Array.isArray(criticalHintNames)) {
|
|
12618
|
+
for (const raw of criticalHintNames) {
|
|
12619
|
+
if (typeof raw !== "string" || raw.trim() === "") continue;
|
|
12620
|
+
const def = _findClientHint(raw);
|
|
12621
|
+
if (!def) return { error: `Unknown client hint: "${raw}"` };
|
|
12622
|
+
if (!resolved.some((d) => d.name === def.name)) {
|
|
12623
|
+
return { error: `Critical hint "${def.name}" must also be included in hintNames` };
|
|
12624
|
+
}
|
|
12625
|
+
critical.push(def);
|
|
12626
|
+
}
|
|
12627
|
+
}
|
|
12628
|
+
const uniqueNames = Array.from(new Set(resolved.map((d) => d.name)));
|
|
12629
|
+
const result = {
|
|
12630
|
+
acceptCH: uniqueNames.join(", "),
|
|
12631
|
+
hints: resolved.map((d) => ({ name: d.name, description: d.description, lowEntropy: d.lowEntropy }))
|
|
12632
|
+
};
|
|
12633
|
+
if (critical.length > 0) {
|
|
12634
|
+
result.criticalCH = Array.from(new Set(critical.map((d) => d.name))).join(", ");
|
|
12635
|
+
}
|
|
12636
|
+
return result;
|
|
12637
|
+
}
|
|
12638
|
+
function _decodeClientHintValue(valueType, rawValue) {
|
|
12639
|
+
switch (valueType) {
|
|
12640
|
+
case "boolean":
|
|
12641
|
+
if (rawValue === "?1") return true;
|
|
12642
|
+
if (rawValue === "?0") return false;
|
|
12643
|
+
return rawValue;
|
|
12644
|
+
case "string":
|
|
12645
|
+
return rawValue.replace(/^"|"$/g, "");
|
|
12646
|
+
case "number": {
|
|
12647
|
+
const n = Number(rawValue);
|
|
12648
|
+
return Number.isFinite(n) ? n : rawValue;
|
|
12649
|
+
}
|
|
12650
|
+
case "sf-list-brand":
|
|
12651
|
+
return rawValue.split(",").map((part) => {
|
|
12652
|
+
const m = part.trim().match(/^"([^"]*)";v="([^"]*)"$/);
|
|
12653
|
+
return m ? { brand: m[1], version: m[2] } : { raw: part.trim() };
|
|
12654
|
+
});
|
|
12655
|
+
default:
|
|
12656
|
+
return rawValue;
|
|
12657
|
+
}
|
|
12658
|
+
}
|
|
12659
|
+
function parseClientHintHeaders(rawHeaders) {
|
|
12660
|
+
if (typeof rawHeaders !== "string" || rawHeaders.trim() === "") return { error: "Provide one or more header lines to parse" };
|
|
12661
|
+
const lines = rawHeaders.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
|
|
12662
|
+
const hints = [];
|
|
12663
|
+
const unrecognized = [];
|
|
12664
|
+
for (const line of lines) {
|
|
12665
|
+
const idx = line.indexOf(":");
|
|
12666
|
+
if (idx === -1) continue;
|
|
12667
|
+
const name = line.slice(0, idx).trim();
|
|
12668
|
+
const rawValue = line.slice(idx + 1).trim();
|
|
12669
|
+
const def = _findClientHint(name);
|
|
12670
|
+
if (!def) {
|
|
12671
|
+
unrecognized.push({ name, rawValue });
|
|
12672
|
+
continue;
|
|
12673
|
+
}
|
|
12674
|
+
hints.push({ name: def.name, rawValue, description: def.description, value: _decodeClientHintValue(def.valueType, rawValue) });
|
|
12675
|
+
}
|
|
12676
|
+
if (hints.length === 0 && unrecognized.length === 0) {
|
|
12677
|
+
return { error: 'No parsable header lines found (expected "Header-Name: value" per line)' };
|
|
12678
|
+
}
|
|
12679
|
+
return { hints, unrecognized };
|
|
12680
|
+
}
|
|
12539
12681
|
|
|
12540
12682
|
// src/tools/api.ts
|
|
12541
12683
|
var api_exports = {};
|
package/dist/index.d.cts
CHANGED
|
@@ -5,8 +5,8 @@ export { t as text } from './text-kHkT9VtT.cjs';
|
|
|
5
5
|
export { d as data } from './data-BKpEOcOX.cjs';
|
|
6
6
|
export { g as generators } from './generators-Du8cBesn.cjs';
|
|
7
7
|
export { t as time } from './time-KqJjdqII.cjs';
|
|
8
|
-
export { u as units } from './units-
|
|
9
|
-
export { n as network } from './network-
|
|
8
|
+
export { u as units } from './units-DWRmbS_a.cjs';
|
|
9
|
+
export { n as network } from './network-Bzm1tjMA.cjs';
|
|
10
10
|
export { a as api } from './api-DmTNE4c1.cjs';
|
|
11
11
|
export { c as code } from './code-KXoRsHtl.cjs';
|
|
12
12
|
export { c as color } from './color-tPwZCr9H.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ export { t as text } from './text-kHkT9VtT.js';
|
|
|
5
5
|
export { d as data } from './data-BKpEOcOX.js';
|
|
6
6
|
export { g as generators } from './generators-Du8cBesn.js';
|
|
7
7
|
export { t as time } from './time-KqJjdqII.js';
|
|
8
|
-
export { u as units } from './units-
|
|
9
|
-
export { n as network } from './network-
|
|
8
|
+
export { u as units } from './units-DWRmbS_a.js';
|
|
9
|
+
export { n as network } from './network-Bzm1tjMA.js';
|
|
10
10
|
export { a as api } from './api-DmTNE4c1.js';
|
|
11
11
|
export { c as code } from './code-KXoRsHtl.js';
|
|
12
12
|
export { c as color } from './color-tPwZCr9H.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { media_exports as media } from './chunk-L6V4W4SU.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-DFLHX4NW.js';
|
|
3
|
+
export { network_exports as network } from './chunk-7PEKYLRB.js';
|
|
4
4
|
export { api_exports as api } from './chunk-52ZDKSIX.js';
|
|
5
5
|
export { code_exports as code } from './chunk-JL7YTXRB.js';
|
|
6
6
|
export { color_exports as color } from './chunk-BPVAB4P2.js';
|
|
@@ -593,12 +593,67 @@ declare function buildPermissionsPolicy(features: PermissionsPolicyFeatureInput[
|
|
|
593
593
|
declare function parsePermissionsPolicy(raw: string): PermissionsPolicyResult | {
|
|
594
594
|
error: string;
|
|
595
595
|
};
|
|
596
|
+
type ClientHintValueType = 'sf-list-brand' | 'boolean' | 'string' | 'number';
|
|
597
|
+
interface ClientHintDef {
|
|
598
|
+
name: string;
|
|
599
|
+
description: string;
|
|
600
|
+
lowEntropy: boolean;
|
|
601
|
+
valueType: ClientHintValueType;
|
|
602
|
+
}
|
|
603
|
+
declare const CLIENT_HINTS: ClientHintDef[];
|
|
604
|
+
interface ClientHintsBuildResult {
|
|
605
|
+
acceptCH: string;
|
|
606
|
+
criticalCH?: string;
|
|
607
|
+
hints: {
|
|
608
|
+
name: string;
|
|
609
|
+
description: string;
|
|
610
|
+
lowEntropy: boolean;
|
|
611
|
+
}[];
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Build an `Accept-CH` response-header value from a list of client hint
|
|
615
|
+
* names the server wants the browser to send on future requests, attaching
|
|
616
|
+
* a plain-English note on what each hint reveals. Pass a subset of those
|
|
617
|
+
* names as `criticalHintNames` to also build a `Critical-CH` header value,
|
|
618
|
+
* for hints the server needs on the very first request of a session.
|
|
619
|
+
*/
|
|
620
|
+
declare function buildClientHints(hintNames: string[], criticalHintNames?: string[]): ClientHintsBuildResult | {
|
|
621
|
+
error: string;
|
|
622
|
+
};
|
|
623
|
+
interface ParsedClientHint {
|
|
624
|
+
name: string;
|
|
625
|
+
rawValue: string;
|
|
626
|
+
description: string;
|
|
627
|
+
value: unknown;
|
|
628
|
+
}
|
|
629
|
+
interface ClientHintsParseResult {
|
|
630
|
+
hints: ParsedClientHint[];
|
|
631
|
+
unrecognized: {
|
|
632
|
+
name: string;
|
|
633
|
+
rawValue: string;
|
|
634
|
+
}[];
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Parse raw request-header text, one `Header-Name: value` per line, into
|
|
638
|
+
* decoded client hint values: brand/version pairs for Sec-CH-UA-style
|
|
639
|
+
* headers, booleans for `?1`/`?0` values, unquoted strings, and numbers.
|
|
640
|
+
* Lines whose header name isn't a recognized client hint are returned
|
|
641
|
+
* separately under `unrecognized` rather than dropped.
|
|
642
|
+
*/
|
|
643
|
+
declare function parseClientHintHeaders(rawHeaders: string): ClientHintsParseResult | {
|
|
644
|
+
error: string;
|
|
645
|
+
};
|
|
596
646
|
|
|
597
647
|
type network_AuthResultEntry = AuthResultEntry;
|
|
598
648
|
type network_BuildRangeHeaderOptions = BuildRangeHeaderOptions;
|
|
649
|
+
declare const network_CLIENT_HINTS: typeof CLIENT_HINTS;
|
|
599
650
|
type network_CacheControlDirective = CacheControlDirective;
|
|
600
651
|
type network_CacheControlOptions = CacheControlOptions;
|
|
601
652
|
type network_CacheControlResult = CacheControlResult;
|
|
653
|
+
type network_ClientHintDef = ClientHintDef;
|
|
654
|
+
type network_ClientHintValueType = ClientHintValueType;
|
|
655
|
+
type network_ClientHintsBuildResult = ClientHintsBuildResult;
|
|
656
|
+
type network_ClientHintsParseResult = ClientHintsParseResult;
|
|
602
657
|
type network_ContentRangeResult = ContentRangeResult;
|
|
603
658
|
type network_CookieAttributes = CookieAttributes;
|
|
604
659
|
type network_CookieCheckResult = CookieCheckResult;
|
|
@@ -626,6 +681,7 @@ type network_ManifestIconInfo = ManifestIconInfo;
|
|
|
626
681
|
type network_ManifestIssue = ManifestIssue;
|
|
627
682
|
type network_ManifestValidationResult = ManifestValidationResult;
|
|
628
683
|
declare const network_PERMISSIONS_POLICY_FEATURES: typeof PERMISSIONS_POLICY_FEATURES;
|
|
684
|
+
type network_ParsedClientHint = ParsedClientHint;
|
|
629
685
|
type network_ParsedDnsResult = ParsedDnsResult;
|
|
630
686
|
type network_ParsedGeoResult = ParsedGeoResult;
|
|
631
687
|
type network_PermissionsPolicyDirective = PermissionsPolicyDirective;
|
|
@@ -656,6 +712,7 @@ type network_VaryHeaderEntry = VaryHeaderEntry;
|
|
|
656
712
|
type network_VaryHeaderResult = VaryHeaderResult;
|
|
657
713
|
declare const network_analyzeEmailHeaders: typeof analyzeEmailHeaders;
|
|
658
714
|
declare const network_buildCacheControl: typeof buildCacheControl;
|
|
715
|
+
declare const network_buildClientHints: typeof buildClientHints;
|
|
659
716
|
declare const network_buildDnsQueryUrl: typeof buildDnsQueryUrl;
|
|
660
717
|
declare const network_buildGeoUrl: typeof buildGeoUrl;
|
|
661
718
|
declare const network_buildLinkHeader: typeof buildLinkHeader;
|
|
@@ -679,6 +736,7 @@ declare const network_isSuccess: typeof isSuccess;
|
|
|
679
736
|
declare const network_isValidIp: typeof isValidIp;
|
|
680
737
|
declare const network_isValidIpv4: typeof isValidIpv4;
|
|
681
738
|
declare const network_isValidIpv6: typeof isValidIpv6;
|
|
739
|
+
declare const network_parseClientHintHeaders: typeof parseClientHintHeaders;
|
|
682
740
|
declare const network_parseContentRangeHeader: typeof parseContentRangeHeader;
|
|
683
741
|
declare const network_parseDnsResponse: typeof parseDnsResponse;
|
|
684
742
|
declare const network_parseGeoResponse: typeof parseGeoResponse;
|
|
@@ -698,7 +756,7 @@ declare const network_validateManifest: typeof validateManifest;
|
|
|
698
756
|
declare const network_validateRobotsTxt: typeof validateRobotsTxt;
|
|
699
757
|
declare const network_validateSitemap: typeof validateSitemap;
|
|
700
758
|
declare namespace network {
|
|
701
|
-
export { type network_AuthResultEntry as AuthResultEntry, type network_BuildRangeHeaderOptions as BuildRangeHeaderOptions, type network_CacheControlDirective as CacheControlDirective, type network_CacheControlOptions as CacheControlOptions, type network_CacheControlResult as CacheControlResult, type network_ContentRangeResult as ContentRangeResult, type network_CookieAttributes as CookieAttributes, type network_CookieCheckResult as CookieCheckResult, 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_EmailHeaderAnalysis as EmailHeaderAnalysis, type network_EmailHeaderField as EmailHeaderField, 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_Ipv6AddressType as Ipv6AddressType, type network_Ipv6ParseResult as Ipv6ParseResult, network_LINK_REL_VALUES as LINK_REL_VALUES, type network_LinkHeaderEntry as LinkHeaderEntry, type network_LinkHeaderEntryInput as LinkHeaderEntryInput, type network_LinkHeaderResult as LinkHeaderResult, type network_LinkRel as LinkRel, type network_ManifestIconInfo as ManifestIconInfo, type network_ManifestIssue as ManifestIssue, type network_ManifestValidationResult as ManifestValidationResult, network_PERMISSIONS_POLICY_FEATURES as PERMISSIONS_POLICY_FEATURES, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, type network_PermissionsPolicyDirective as PermissionsPolicyDirective, type network_PermissionsPolicyFeatureInput as PermissionsPolicyFeatureInput, type network_PermissionsPolicyResult as PermissionsPolicyResult, network_REFERRER_POLICY_VALUES as REFERRER_POLICY_VALUES, type network_RangeEntry as RangeEntry, type network_RangeEntryInput as RangeEntryInput, type network_RangeHeaderResult as RangeHeaderResult, type network_ReceivedHop as ReceivedHop, type network_ReferrerPolicyEntry as ReferrerPolicyEntry, type network_ReferrerPolicyResult as ReferrerPolicyResult, type network_ReferrerPolicyValue as ReferrerPolicyValue, 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_SameSiteValue as SameSiteValue, 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, type network_VaryHeaderEntry as VaryHeaderEntry, type network_VaryHeaderResult as VaryHeaderResult, network_analyzeEmailHeaders as analyzeEmailHeaders, network_buildCacheControl as buildCacheControl, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildLinkHeader as buildLinkHeader, network_buildMapUrl as buildMapUrl, network_buildPermissionsPolicy as buildPermissionsPolicy, network_buildRangeHeader as buildRangeHeader, network_buildReferrerPolicy as buildReferrerPolicy, network_buildVaryHeader as buildVaryHeader, network_checkSetCookieHeader as checkSetCookieHeader, 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_parseContentRangeHeader as parseContentRangeHeader, network_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_parseIpv6Address as parseIpv6Address, network_parsePermissionsPolicy as parsePermissionsPolicy, network_parseUserAgent as parseUserAgent, network_parseVaryHeader as parseVaryHeader, 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_validateManifest as validateManifest, network_validateRobotsTxt as validateRobotsTxt, network_validateSitemap as validateSitemap };
|
|
759
|
+
export { type network_AuthResultEntry as AuthResultEntry, type network_BuildRangeHeaderOptions as BuildRangeHeaderOptions, network_CLIENT_HINTS as CLIENT_HINTS, type network_CacheControlDirective as CacheControlDirective, type network_CacheControlOptions as CacheControlOptions, type network_CacheControlResult as CacheControlResult, type network_ClientHintDef as ClientHintDef, type network_ClientHintValueType as ClientHintValueType, type network_ClientHintsBuildResult as ClientHintsBuildResult, type network_ClientHintsParseResult as ClientHintsParseResult, type network_ContentRangeResult as ContentRangeResult, type network_CookieAttributes as CookieAttributes, type network_CookieCheckResult as CookieCheckResult, 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_EmailHeaderAnalysis as EmailHeaderAnalysis, type network_EmailHeaderField as EmailHeaderField, 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_Ipv6AddressType as Ipv6AddressType, type network_Ipv6ParseResult as Ipv6ParseResult, network_LINK_REL_VALUES as LINK_REL_VALUES, type network_LinkHeaderEntry as LinkHeaderEntry, type network_LinkHeaderEntryInput as LinkHeaderEntryInput, type network_LinkHeaderResult as LinkHeaderResult, type network_LinkRel as LinkRel, type network_ManifestIconInfo as ManifestIconInfo, type network_ManifestIssue as ManifestIssue, type network_ManifestValidationResult as ManifestValidationResult, network_PERMISSIONS_POLICY_FEATURES as PERMISSIONS_POLICY_FEATURES, type network_ParsedClientHint as ParsedClientHint, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, type network_PermissionsPolicyDirective as PermissionsPolicyDirective, type network_PermissionsPolicyFeatureInput as PermissionsPolicyFeatureInput, type network_PermissionsPolicyResult as PermissionsPolicyResult, network_REFERRER_POLICY_VALUES as REFERRER_POLICY_VALUES, type network_RangeEntry as RangeEntry, type network_RangeEntryInput as RangeEntryInput, type network_RangeHeaderResult as RangeHeaderResult, type network_ReceivedHop as ReceivedHop, type network_ReferrerPolicyEntry as ReferrerPolicyEntry, type network_ReferrerPolicyResult as ReferrerPolicyResult, type network_ReferrerPolicyValue as ReferrerPolicyValue, 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_SameSiteValue as SameSiteValue, 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, type network_VaryHeaderEntry as VaryHeaderEntry, type network_VaryHeaderResult as VaryHeaderResult, network_analyzeEmailHeaders as analyzeEmailHeaders, network_buildCacheControl as buildCacheControl, network_buildClientHints as buildClientHints, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildLinkHeader as buildLinkHeader, network_buildMapUrl as buildMapUrl, network_buildPermissionsPolicy as buildPermissionsPolicy, network_buildRangeHeader as buildRangeHeader, network_buildReferrerPolicy as buildReferrerPolicy, network_buildVaryHeader as buildVaryHeader, network_checkSetCookieHeader as checkSetCookieHeader, 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_parseClientHintHeaders as parseClientHintHeaders, network_parseContentRangeHeader as parseContentRangeHeader, network_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_parseIpv6Address as parseIpv6Address, network_parsePermissionsPolicy as parsePermissionsPolicy, network_parseUserAgent as parseUserAgent, network_parseVaryHeader as parseVaryHeader, 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_validateManifest as validateManifest, network_validateRobotsTxt as validateRobotsTxt, network_validateSitemap as validateSitemap };
|
|
702
760
|
}
|
|
703
761
|
|
|
704
|
-
export { type
|
|
762
|
+
export { type RobotsIssue as $, type AuthResultEntry as A, type BuildRangeHeaderOptions as B, CLIENT_HINTS as C, DNS_RECORD_TYPES as D, type EmailHeaderAnalysis as E, type ManifestValidationResult as F, type GeoResult as G, HTTP_HEADERS as H, type Ipv6AddressType as I, type ParsedClientHint as J, type ParsedDnsResult as K, LINK_REL_VALUES as L, type ManifestIconInfo as M, type ParsedGeoResult as N, type PermissionsPolicyDirective as O, PERMISSIONS_POLICY_FEATURES as P, type PermissionsPolicyFeatureInput as Q, type PermissionsPolicyResult as R, REFERRER_POLICY_VALUES as S, type RangeEntry as T, type RangeEntryInput as U, type RangeHeaderResult as V, type ReceivedHop as W, type ReferrerPolicyEntry as X, type ReferrerPolicyResult as Y, type ReferrerPolicyValue as Z, type RobotsGroup as _, type CacheControlDirective as a, type RobotsRule as a0, type RobotsValidationResult as a1, STATUS_CODES as a2, type SameSiteValue as a3, type SitemapIndexEntry as a4, type SitemapIssue as a5, type SitemapUrlEntry as a6, type SitemapValidationResult as a7, type StatusCode as a8, type UaDeviceType as a9, isValidIp as aA, isValidIpv4 as aB, isValidIpv6 as aC, parseClientHintHeaders as aD, parseContentRangeHeader as aE, parseDnsResponse as aF, parseGeoResponse as aG, parseHar as aH, parseIpv6Address as aI, parsePermissionsPolicy as aJ, parseUserAgent as aK, parseVaryHeader as aL, searchHeaders as aM, searchStatusCodes as aN, statusCodeToText as aO, typeNumberToLabel as aP, validateDomain as aQ, validateHeaderName as aR, validateHeaderValue as aS, validateManifest as aT, validateRobotsTxt as aU, validateSitemap as aV, type UserAgentInfo as aa, type VaryHeaderEntry as ab, type VaryHeaderResult as ac, analyzeEmailHeaders as ad, buildCacheControl as ae, buildClientHints as af, buildDnsQueryUrl as ag, buildGeoUrl as ah, buildLinkHeader as ai, buildMapUrl as aj, buildPermissionsPolicy as ak, buildRangeHeader as al, buildReferrerPolicy as am, buildVaryHeader as an, checkSetCookieHeader as ao, countryCodeToFlag as ap, formatCoordinates as aq, formatTtl as ar, getByCategory as as, getHeader as at, getHeadersByCategory as au, getStatusByCategory as av, getStatusCode as aw, isClientError as ax, isServerError as ay, isSuccess as az, type CacheControlOptions as b, type CacheControlResult as c, type ClientHintDef as d, type ClientHintValueType as e, type ClientHintsBuildResult as f, type ClientHintsParseResult as g, type ContentRangeResult as h, type CookieAttributes as i, type CookieCheckResult as j, type DnsRecord as k, type DnsRecordType as l, type DnsResponse as m, network as n, type EmailHeaderField as o, type HarEntry as p, type HarParseResult as q, type HarSummary as r, type HeaderCategory as s, type HttpHeader as t, type Ipv6ParseResult as u, type LinkHeaderEntry as v, type LinkHeaderEntryInput as w, type LinkHeaderResult as x, type LinkRel as y, type ManifestIssue as z };
|