@utilix-tech/sdk 0.36.0 → 0.37.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 +11 -3
- package/dist/{chunk-UTHAHRQ7.js → chunk-DBNTO3YO.js} +79 -1
- package/dist/{chunk-UUT5HNST.js → chunk-JL7YTXRB.js} +81 -1
- package/dist/{code-BK-x8hVx.d.cts → code-KXoRsHtl.d.cts} +21 -2
- package/dist/{code-BK-x8hVx.d.ts → code-KXoRsHtl.d.ts} +21 -2
- package/dist/index.cjs +158 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{network-X0EfH9Xq.d.cts → network-CnKUQT4g.d.cts} +36 -2
- package/dist/{network-X0EfH9Xq.d.ts → network-CnKUQT4g.d.ts} +36 -2
- package/dist/tools/code.cjs +80 -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/network.cjs +78 -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/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.37.0
|
|
6
|
+
- Add `checkSetCookieHeader` (same-site-cookie-checker): parse a Set-Cookie header value and validate its attribute combination, flagging SameSite=None missing Secure, __Host-/__Secure- prefix violations, a missing Secure attribute, and a Max-Age past 400 days.
|
|
7
|
+
- Add `testGitignorePatterns` (gitignore-tester): test a list of paths against a .gitignore file's patterns, following git's last-match-wins and negation rules, and report which pattern and line number decided each path's outcome.
|
|
8
|
+
|
|
5
9
|
## 0.36.0
|
|
6
10
|
- Add `buildLinkHeader` (link-header-builder): build an HTTP Link response header from URL/rel pairs (preload, preconnect, prefetch, canonical, pagination, etc.), including the as/type/crossorigin attributes preload needs, plus a plain-English explanation of each entry and warnings for common mistakes like a preload missing `as`.
|
|
7
11
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @utilix-tech/sdk
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**604 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)
|
|
@@ -404,7 +404,7 @@ calculateRoi({ initialValue: 1000, finalValue: 1610.51, years: 5 });
|
|
|
404
404
|
import { getStatusCode, isValidIp, isValidIpv4, isValidIpv6,
|
|
405
405
|
searchStatusCodes, buildGeoUrl, countryCodeToFlag,
|
|
406
406
|
parseHar, validateSitemap, validateRobotsTxt,
|
|
407
|
-
parseUserAgent, buildCacheControl, buildReferrerPolicy, parseIpv6Address, buildLinkHeader } from "@utilix-tech/sdk/network";
|
|
407
|
+
parseUserAgent, buildCacheControl, buildReferrerPolicy, parseIpv6Address, buildLinkHeader, checkSetCookieHeader } from "@utilix-tech/sdk/network";
|
|
408
408
|
|
|
409
409
|
getStatusCode(404);
|
|
410
410
|
// { code: 404, text: "Not Found", description: "...", category: "Client Error" }
|
|
@@ -451,6 +451,10 @@ parseIpv6Address("2001:db8::ff00:42:8329");
|
|
|
451
451
|
// Build an HTTP Link header from URL/rel pairs (preload, preconnect, canonical, pagination, etc.)
|
|
452
452
|
buildLinkHeader([{ url: "/fonts/inter.woff2", rel: "preload", as: "font", type: "font/woff2", crossorigin: true }]);
|
|
453
453
|
// { header: '</fonts/inter.woff2>; rel="preload"; as="font"; type="font/woff2"; crossorigin', links: [...], warnings: [] }
|
|
454
|
+
|
|
455
|
+
// Parse and validate a Set-Cookie header's attribute combination
|
|
456
|
+
checkSetCookieHeader("session=abc123; SameSite=None");
|
|
457
|
+
// { cookie: {...}, issues: ["SameSite=None requires the Secure attribute..."], warnings: [...], valid: false }
|
|
454
458
|
```
|
|
455
459
|
|
|
456
460
|
---
|
|
@@ -500,7 +504,7 @@ generateCspHeader({ "default-src": ["'self'"], "script-src": ["'self'", "cdn.exa
|
|
|
500
504
|
```ts
|
|
501
505
|
import { formatSql, minifySql, testRegex, formatHtml, formatGql,
|
|
502
506
|
detectDialect, splitStatements, lookupMime, parseGithubUrl,
|
|
503
|
-
detectRedos } from "@utilix-tech/sdk/code";
|
|
507
|
+
detectRedos, testGitignorePatterns } from "@utilix-tech/sdk/code";
|
|
504
508
|
|
|
505
509
|
// SQL
|
|
506
510
|
formatSql("SELECT id,name FROM users WHERE active=1 ORDER BY name");
|
|
@@ -536,6 +540,10 @@ parseGithubUrl("https://github.com/facebook/react/pull/1234");
|
|
|
536
540
|
// Regex ReDoS (catastrophic-backtracking) detection
|
|
537
541
|
detectRedos("(a+)+");
|
|
538
542
|
// { risk: "high", safe: false, findings: [{ type: "nested-quantifier", ... }] }
|
|
543
|
+
|
|
544
|
+
// Test paths against a .gitignore file's patterns
|
|
545
|
+
testGitignorePatterns("node_modules/\n*.log", ["node_modules/foo.js", "debug.log", "src/index.js"]);
|
|
546
|
+
// [{ path: "node_modules/foo.js", ignored: true, matchedPattern: "node_modules/", matchedLine: 1 }, ...]
|
|
539
547
|
```
|
|
540
548
|
|
|
541
549
|
---
|
|
@@ -14,6 +14,7 @@ __export(network_exports, {
|
|
|
14
14
|
buildLinkHeader: () => buildLinkHeader,
|
|
15
15
|
buildMapUrl: () => buildMapUrl,
|
|
16
16
|
buildReferrerPolicy: () => buildReferrerPolicy,
|
|
17
|
+
checkSetCookieHeader: () => checkSetCookieHeader,
|
|
17
18
|
countryCodeToFlag: () => countryCodeToFlag,
|
|
18
19
|
formatCoordinates: () => formatCoordinates,
|
|
19
20
|
formatTtl: () => formatTtl,
|
|
@@ -2052,5 +2053,82 @@ function parseIpv6Address(input) {
|
|
|
2052
2053
|
addressType: classifyIpv6(expandedGroups)
|
|
2053
2054
|
};
|
|
2054
2055
|
}
|
|
2056
|
+
var MAX_COOKIE_AGE_SECONDS = 400 * 24 * 60 * 60;
|
|
2057
|
+
function checkSetCookieHeader(header) {
|
|
2058
|
+
if (typeof header !== "string" || !header.trim()) {
|
|
2059
|
+
return { error: "A Set-Cookie header value is required" };
|
|
2060
|
+
}
|
|
2061
|
+
const parts = header.split(";").map((p) => p.trim()).filter(Boolean);
|
|
2062
|
+
const [nameValue, ...attrParts] = parts;
|
|
2063
|
+
const eqIdx = nameValue.indexOf("=");
|
|
2064
|
+
if (eqIdx === -1) return { error: "Missing name=value pair" };
|
|
2065
|
+
const name = nameValue.slice(0, eqIdx).trim();
|
|
2066
|
+
const value = nameValue.slice(eqIdx + 1).trim();
|
|
2067
|
+
if (!name) return { error: "Cookie name cannot be empty" };
|
|
2068
|
+
const cookie = {
|
|
2069
|
+
name,
|
|
2070
|
+
value,
|
|
2071
|
+
domain: null,
|
|
2072
|
+
path: null,
|
|
2073
|
+
expires: null,
|
|
2074
|
+
maxAge: null,
|
|
2075
|
+
secure: false,
|
|
2076
|
+
httpOnly: false,
|
|
2077
|
+
sameSite: null
|
|
2078
|
+
};
|
|
2079
|
+
for (const attr of attrParts) {
|
|
2080
|
+
const idx = attr.indexOf("=");
|
|
2081
|
+
const key = (idx === -1 ? attr : attr.slice(0, idx)).trim().toLowerCase();
|
|
2082
|
+
const val = idx === -1 ? "" : attr.slice(idx + 1).trim();
|
|
2083
|
+
switch (key) {
|
|
2084
|
+
case "domain":
|
|
2085
|
+
cookie.domain = val || null;
|
|
2086
|
+
break;
|
|
2087
|
+
case "path":
|
|
2088
|
+
cookie.path = val || null;
|
|
2089
|
+
break;
|
|
2090
|
+
case "expires":
|
|
2091
|
+
cookie.expires = val || null;
|
|
2092
|
+
break;
|
|
2093
|
+
case "max-age": {
|
|
2094
|
+
const n = Number(val);
|
|
2095
|
+
cookie.maxAge = Number.isFinite(n) ? n : null;
|
|
2096
|
+
break;
|
|
2097
|
+
}
|
|
2098
|
+
case "secure":
|
|
2099
|
+
cookie.secure = true;
|
|
2100
|
+
break;
|
|
2101
|
+
case "httponly":
|
|
2102
|
+
cookie.httpOnly = true;
|
|
2103
|
+
break;
|
|
2104
|
+
case "samesite": {
|
|
2105
|
+
const normalized = val.toLowerCase();
|
|
2106
|
+
if (normalized === "strict") cookie.sameSite = "Strict";
|
|
2107
|
+
else if (normalized === "lax") cookie.sameSite = "Lax";
|
|
2108
|
+
else if (normalized === "none") cookie.sameSite = "None";
|
|
2109
|
+
break;
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
const issues = [];
|
|
2114
|
+
const warnings = [];
|
|
2115
|
+
if (cookie.sameSite === "None" && !cookie.secure) {
|
|
2116
|
+
issues.push("SameSite=None requires the Secure attribute \u2014 modern browsers reject this cookie without it.");
|
|
2117
|
+
}
|
|
2118
|
+
if (name.startsWith("__Host-")) {
|
|
2119
|
+
if (!cookie.secure) issues.push("__Host- prefixed cookies require the Secure attribute.");
|
|
2120
|
+
if (cookie.domain) issues.push("__Host- prefixed cookies must not set a Domain attribute.");
|
|
2121
|
+
if (cookie.path !== "/") issues.push("__Host- prefixed cookies must set Path=/.");
|
|
2122
|
+
} else if (name.startsWith("__Secure-")) {
|
|
2123
|
+
if (!cookie.secure) issues.push("__Secure- prefixed cookies require the Secure attribute.");
|
|
2124
|
+
}
|
|
2125
|
+
if (!cookie.secure) {
|
|
2126
|
+
warnings.push("Missing Secure attribute \u2014 the cookie can be sent over a plain HTTP connection.");
|
|
2127
|
+
}
|
|
2128
|
+
if (cookie.maxAge !== null && cookie.maxAge > MAX_COOKIE_AGE_SECONDS) {
|
|
2129
|
+
warnings.push(`Max-Age (${cookie.maxAge}s) exceeds 400 days \u2014 Chromium-based browsers clamp cookie expiry to 400 days from when it's set, so this will be shortened.`);
|
|
2130
|
+
}
|
|
2131
|
+
return { cookie, issues, warnings, valid: issues.length === 0 };
|
|
2132
|
+
}
|
|
2055
2133
|
|
|
2056
|
-
export { DNS_RECORD_TYPES, HTTP_HEADERS, LINK_REL_VALUES, REFERRER_POLICY_VALUES, STATUS_CODES, buildCacheControl, buildDnsQueryUrl, buildGeoUrl, buildLinkHeader, buildMapUrl, buildReferrerPolicy, countryCodeToFlag, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, network_exports, parseDnsResponse, parseGeoResponse, parseHar, parseIpv6Address, parseUserAgent, searchHeaders, searchStatusCodes, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue, validateRobotsTxt, validateSitemap };
|
|
2134
|
+
export { DNS_RECORD_TYPES, HTTP_HEADERS, LINK_REL_VALUES, REFERRER_POLICY_VALUES, STATUS_CODES, buildCacheControl, buildDnsQueryUrl, buildGeoUrl, buildLinkHeader, buildMapUrl, buildReferrerPolicy, checkSetCookieHeader, countryCodeToFlag, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, network_exports, parseDnsResponse, parseGeoResponse, parseHar, parseIpv6Address, parseUserAgent, searchHeaders, searchStatusCodes, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue, validateRobotsTxt, validateSitemap };
|
|
@@ -52,6 +52,7 @@ __export(code_exports, {
|
|
|
52
52
|
searchCheatsheet: () => searchCheatsheet,
|
|
53
53
|
searchEndpoints: () => searchEndpoints,
|
|
54
54
|
splitStatements: () => splitStatements,
|
|
55
|
+
testGitignorePatterns: () => testGitignorePatterns,
|
|
55
56
|
testPattern: () => testPattern,
|
|
56
57
|
testRegex: () => testRegex,
|
|
57
58
|
validateEnvKey: () => validateEnvKey
|
|
@@ -2860,5 +2861,84 @@ function lintConventionalCommit(message, options = {}) {
|
|
|
2860
2861
|
const valid = !findings.some((f) => f.severity === "error");
|
|
2861
2862
|
return { message, valid, parsed, findings };
|
|
2862
2863
|
}
|
|
2864
|
+
function globSegmentToRegexSource(segment) {
|
|
2865
|
+
let out = "";
|
|
2866
|
+
for (let i = 0; i < segment.length; i++) {
|
|
2867
|
+
const c = segment[i];
|
|
2868
|
+
if (c === "*") {
|
|
2869
|
+
out += "[^/]*";
|
|
2870
|
+
} else if (c === "?") {
|
|
2871
|
+
out += "[^/]";
|
|
2872
|
+
} else if (c === "[") {
|
|
2873
|
+
const close = segment.indexOf("]", i + 1);
|
|
2874
|
+
if (close === -1) {
|
|
2875
|
+
out += "\\[";
|
|
2876
|
+
} else {
|
|
2877
|
+
let cls = segment.slice(i + 1, close);
|
|
2878
|
+
if (cls.startsWith("!")) cls = "^" + cls.slice(1);
|
|
2879
|
+
out += `[${cls}]`;
|
|
2880
|
+
i = close;
|
|
2881
|
+
}
|
|
2882
|
+
} else {
|
|
2883
|
+
out += c.replace(/[.+^${}()|\\]/g, "\\$&");
|
|
2884
|
+
}
|
|
2885
|
+
}
|
|
2886
|
+
return out;
|
|
2887
|
+
}
|
|
2888
|
+
function compileGitignorePattern(raw, line) {
|
|
2889
|
+
let pattern = raw.replace(/\s+$/, "");
|
|
2890
|
+
if (!pattern || pattern.startsWith("#")) return null;
|
|
2891
|
+
let negate = false;
|
|
2892
|
+
if (pattern.startsWith("!")) {
|
|
2893
|
+
negate = true;
|
|
2894
|
+
pattern = pattern.slice(1);
|
|
2895
|
+
}
|
|
2896
|
+
pattern = pattern.replace(/\\(.)/g, "$1");
|
|
2897
|
+
if (!pattern) return null;
|
|
2898
|
+
const dirOnly = pattern.endsWith("/") && !pattern.endsWith("\\/");
|
|
2899
|
+
if (dirOnly) pattern = pattern.slice(0, -1);
|
|
2900
|
+
const hasLeadingSlash = pattern.startsWith("/");
|
|
2901
|
+
if (hasLeadingSlash) pattern = pattern.slice(1);
|
|
2902
|
+
const anchored = hasLeadingSlash || pattern.includes("/");
|
|
2903
|
+
const segments = pattern.split("/");
|
|
2904
|
+
const regexParts = segments.map((seg) => {
|
|
2905
|
+
if (seg === "**") return "(?:.*)";
|
|
2906
|
+
return globSegmentToRegexSource(seg);
|
|
2907
|
+
});
|
|
2908
|
+
let body = regexParts.join("/");
|
|
2909
|
+
body = body.replace(/\(\?:\.\*\)\//g, "(?:.*/)?").replace(/\/\(\?:\.\*\)/g, "(?:/.*)?");
|
|
2910
|
+
const prefix = anchored ? "^" : "^(?:.*/)?";
|
|
2911
|
+
const suffix = "(?:/.*)?$";
|
|
2912
|
+
const regex = new RegExp(prefix + body + suffix);
|
|
2913
|
+
return { raw, line, negate, regex };
|
|
2914
|
+
}
|
|
2915
|
+
function testGitignorePatterns(gitignoreContent, paths) {
|
|
2916
|
+
if (typeof gitignoreContent !== "string" || !gitignoreContent.trim()) {
|
|
2917
|
+
return { error: "gitignore content is required" };
|
|
2918
|
+
}
|
|
2919
|
+
if (!Array.isArray(paths) || paths.length === 0) {
|
|
2920
|
+
return { error: "At least one path is required" };
|
|
2921
|
+
}
|
|
2922
|
+
const lines = gitignoreContent.split("\n");
|
|
2923
|
+
const patterns = [];
|
|
2924
|
+
lines.forEach((line, idx) => {
|
|
2925
|
+
const compiled = compileGitignorePattern(line, idx + 1);
|
|
2926
|
+
if (compiled) patterns.push(compiled);
|
|
2927
|
+
});
|
|
2928
|
+
return paths.map((rawPath) => {
|
|
2929
|
+
const path = rawPath.trim().replace(/^\.\//, "");
|
|
2930
|
+
let ignored = false;
|
|
2931
|
+
let matchedPattern = null;
|
|
2932
|
+
let matchedLine = null;
|
|
2933
|
+
for (const p of patterns) {
|
|
2934
|
+
if (p.regex.test(path)) {
|
|
2935
|
+
ignored = !p.negate;
|
|
2936
|
+
matchedPattern = p.raw.trim();
|
|
2937
|
+
matchedLine = p.line;
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
return { path, ignored, matchedPattern, matchedLine };
|
|
2941
|
+
});
|
|
2942
|
+
}
|
|
2863
2943
|
|
|
2864
|
-
export { ALL_FLAGS, CHEATSHEET, DEFAULT_COMMIT_TYPES, MIME_TABLE, OPERATIONS, SQL_DEFAULT_OPTIONS, buildDockerPull, buildDockerRun, buildGitCommand, code_exports, collapseHtmlWhitespace, collapseJsWhitespace, countProperties, countRules, detectDialect, detectOperationType, detectRedos, envToExport, envToJson, formatCss, formatGql, formatHtml, formatSql, getEndpointsByTag, getHtmlStats, getJsStats, getMethodColor, isValidTag, lintConventionalCommit, lookupMime, minifyCss, minifyGql, minifyHtml, minifyJs, minifySql, normalizeRef, parseDockerImage, parseEnv, parseGitCommand, parseGithubUrl, parseSpec, removeConsoleCalls, removeEmptyAttributes, removeHtmlComments, removeJsComments, removeRedundantAttributes, searchCheatsheet, searchEndpoints, splitStatements, testPattern, testRegex, validateEnvKey };
|
|
2944
|
+
export { ALL_FLAGS, CHEATSHEET, DEFAULT_COMMIT_TYPES, MIME_TABLE, OPERATIONS, SQL_DEFAULT_OPTIONS, buildDockerPull, buildDockerRun, buildGitCommand, code_exports, collapseHtmlWhitespace, collapseJsWhitespace, countProperties, countRules, detectDialect, detectOperationType, detectRedos, envToExport, envToJson, formatCss, formatGql, formatHtml, formatSql, getEndpointsByTag, getHtmlStats, getJsStats, getMethodColor, isValidTag, lintConventionalCommit, lookupMime, minifyCss, minifyGql, minifyHtml, minifyJs, minifySql, normalizeRef, parseDockerImage, parseEnv, parseGitCommand, parseGithubUrl, parseSpec, removeConsoleCalls, removeEmptyAttributes, removeHtmlComments, removeJsComments, removeRedundantAttributes, searchCheatsheet, searchEndpoints, splitStatements, testGitignorePatterns, testPattern, testRegex, validateEnvKey };
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* - github-url-parser (parseGithubUrl)
|
|
22
22
|
* - redos-detector (detectRedos)
|
|
23
23
|
* - conventional-commit-linter (lintConventionalCommit)
|
|
24
|
+
* - gitignore-tester (testGitignorePatterns)
|
|
24
25
|
*/
|
|
25
26
|
type RegexFlag = 'g' | 'i' | 'm' | 's' | 'u';
|
|
26
27
|
declare const ALL_FLAGS: RegexFlag[];
|
|
@@ -375,6 +376,22 @@ declare const DEFAULT_COMMIT_TYPES: string[];
|
|
|
375
376
|
declare function lintConventionalCommit(message: string, options?: ConventionalCommitOptions): ConventionalCommitResult | {
|
|
376
377
|
error: string;
|
|
377
378
|
};
|
|
379
|
+
interface GitignoreTestResult {
|
|
380
|
+
path: string;
|
|
381
|
+
ignored: boolean;
|
|
382
|
+
matchedPattern: string | null;
|
|
383
|
+
matchedLine: number | null;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Test a list of paths against a .gitignore file's contents. Returns, for
|
|
387
|
+
* each path, whether it would be ignored and which pattern (and line number)
|
|
388
|
+
* decided that outcome, following the "last matching pattern wins, negation
|
|
389
|
+
* flips it" rule git itself uses. Paths should be relative, forward-slash
|
|
390
|
+
* separated, and use a trailing `/` to mark a directory.
|
|
391
|
+
*/
|
|
392
|
+
declare function testGitignorePatterns(gitignoreContent: string, paths: string[]): GitignoreTestResult[] | {
|
|
393
|
+
error: string;
|
|
394
|
+
};
|
|
378
395
|
|
|
379
396
|
declare const code_ALL_FLAGS: typeof ALL_FLAGS;
|
|
380
397
|
type code_ApiEndpoint = ApiEndpoint;
|
|
@@ -397,6 +414,7 @@ type code_GitCommandResult = GitCommandResult;
|
|
|
397
414
|
type code_GitOperation = GitOperation;
|
|
398
415
|
type code_GithubUrlInfo = GithubUrlInfo;
|
|
399
416
|
type code_GithubUrlType = GithubUrlType;
|
|
417
|
+
type code_GitignoreTestResult = GitignoreTestResult;
|
|
400
418
|
type code_GqlFormatResult = GqlFormatResult;
|
|
401
419
|
type code_HtmlFormatResult = HtmlFormatResult;
|
|
402
420
|
type code_HtmlMinifyOptions = HtmlMinifyOptions;
|
|
@@ -465,11 +483,12 @@ declare const code_removeRedundantAttributes: typeof removeRedundantAttributes;
|
|
|
465
483
|
declare const code_searchCheatsheet: typeof searchCheatsheet;
|
|
466
484
|
declare const code_searchEndpoints: typeof searchEndpoints;
|
|
467
485
|
declare const code_splitStatements: typeof splitStatements;
|
|
486
|
+
declare const code_testGitignorePatterns: typeof testGitignorePatterns;
|
|
468
487
|
declare const code_testPattern: typeof testPattern;
|
|
469
488
|
declare const code_testRegex: typeof testRegex;
|
|
470
489
|
declare const code_validateEnvKey: typeof validateEnvKey;
|
|
471
490
|
declare namespace code {
|
|
472
|
-
export { code_ALL_FLAGS as ALL_FLAGS, type code_ApiEndpoint as ApiEndpoint, type code_ApiInfo as ApiInfo, code_CHEATSHEET as CHEATSHEET, type code_CheatsheetEntry as CheatsheetEntry, type code_ConventionalCommitFinding as ConventionalCommitFinding, type code_ConventionalCommitFooter as ConventionalCommitFooter, type code_ConventionalCommitOptions as ConventionalCommitOptions, type code_ConventionalCommitParsed as ConventionalCommitParsed, type code_ConventionalCommitResult as ConventionalCommitResult, type code_ConventionalCommitSeverity as ConventionalCommitSeverity, type code_CssResult as CssResult, code_DEFAULT_COMMIT_TYPES as DEFAULT_COMMIT_TYPES, type code_DockerImageRef as DockerImageRef, type code_EnvEntry as EnvEntry, type code_EnvParseResult as EnvParseResult, type code_GitCommandConfig as GitCommandConfig, type code_GitCommandResult as GitCommandResult, type code_GitOperation as GitOperation, type code_GithubUrlInfo as GithubUrlInfo, type code_GithubUrlType as GithubUrlType, type code_GqlFormatResult as GqlFormatResult, type code_HtmlFormatResult as HtmlFormatResult, type code_HtmlMinifyOptions as HtmlMinifyOptions, type code_HtmlMinifyResult as HtmlMinifyResult, type code_JsMinifyOptions as JsMinifyOptions, type code_JsMinifyResult as JsMinifyResult, code_MIME_TABLE as MIME_TABLE, type code_MatchResult as MatchResult, type code_MimeEntry as MimeEntry, type code_MimeLookupResult as MimeLookupResult, code_OPERATIONS as OPERATIONS, type code_ParsedSpec as ParsedSpec, type code_RedosFinding as RedosFinding, type code_RedosResult as RedosResult, type code_RedosSeverity as RedosSeverity, type code_RegexError as RegexError, type code_RegexFlag as RegexFlag, type code_RegexMatch as RegexMatch, type code_RegexResult as RegexResult, type code_RegexSuccess as RegexSuccess, code_SQL_DEFAULT_OPTIONS as SQL_DEFAULT_OPTIONS, type code_Segment as Segment, type code_SpecVersion as SpecVersion, type code_SqlDialect as SqlDialect, type code_SqlFormatOptions as SqlFormatOptions, type code_TestPatternResult as TestPatternResult, code_buildDockerPull as buildDockerPull, code_buildDockerRun as buildDockerRun, code_buildGitCommand as buildGitCommand, code_collapseHtmlWhitespace as collapseHtmlWhitespace, code_collapseJsWhitespace as collapseJsWhitespace, code_countProperties as countProperties, code_countRules as countRules, code_detectDialect as detectDialect, code_detectOperationType as detectOperationType, code_detectRedos as detectRedos, code_envToExport as envToExport, code_envToJson as envToJson, code_formatCss as formatCss, code_formatGql as formatGql, code_formatHtml as formatHtml, code_formatSql as formatSql, code_getEndpointsByTag as getEndpointsByTag, code_getHtmlStats as getHtmlStats, code_getJsStats as getJsStats, code_getMethodColor as getMethodColor, code_isValidTag as isValidTag, code_lintConventionalCommit as lintConventionalCommit, code_lookupMime as lookupMime, code_minifyCss as minifyCss, code_minifyGql as minifyGql, code_minifyHtml as minifyHtml, code_minifyJs as minifyJs, code_minifySql as minifySql, code_normalizeRef as normalizeRef, code_parseDockerImage as parseDockerImage, code_parseEnv as parseEnv, code_parseGitCommand as parseGitCommand, code_parseGithubUrl as parseGithubUrl, code_parseSpec as parseSpec, code_removeConsoleCalls as removeConsoleCalls, code_removeEmptyAttributes as removeEmptyAttributes, code_removeHtmlComments as removeHtmlComments, code_removeJsComments as removeJsComments, code_removeRedundantAttributes as removeRedundantAttributes, code_searchCheatsheet as searchCheatsheet, code_searchEndpoints as searchEndpoints, code_splitStatements as splitStatements, code_testPattern as testPattern, code_testRegex as testRegex, code_validateEnvKey as validateEnvKey };
|
|
491
|
+
export { code_ALL_FLAGS as ALL_FLAGS, type code_ApiEndpoint as ApiEndpoint, type code_ApiInfo as ApiInfo, code_CHEATSHEET as CHEATSHEET, type code_CheatsheetEntry as CheatsheetEntry, type code_ConventionalCommitFinding as ConventionalCommitFinding, type code_ConventionalCommitFooter as ConventionalCommitFooter, type code_ConventionalCommitOptions as ConventionalCommitOptions, type code_ConventionalCommitParsed as ConventionalCommitParsed, type code_ConventionalCommitResult as ConventionalCommitResult, type code_ConventionalCommitSeverity as ConventionalCommitSeverity, type code_CssResult as CssResult, code_DEFAULT_COMMIT_TYPES as DEFAULT_COMMIT_TYPES, type code_DockerImageRef as DockerImageRef, type code_EnvEntry as EnvEntry, type code_EnvParseResult as EnvParseResult, type code_GitCommandConfig as GitCommandConfig, type code_GitCommandResult as GitCommandResult, type code_GitOperation as GitOperation, type code_GithubUrlInfo as GithubUrlInfo, type code_GithubUrlType as GithubUrlType, type code_GitignoreTestResult as GitignoreTestResult, type code_GqlFormatResult as GqlFormatResult, type code_HtmlFormatResult as HtmlFormatResult, type code_HtmlMinifyOptions as HtmlMinifyOptions, type code_HtmlMinifyResult as HtmlMinifyResult, type code_JsMinifyOptions as JsMinifyOptions, type code_JsMinifyResult as JsMinifyResult, code_MIME_TABLE as MIME_TABLE, type code_MatchResult as MatchResult, type code_MimeEntry as MimeEntry, type code_MimeLookupResult as MimeLookupResult, code_OPERATIONS as OPERATIONS, type code_ParsedSpec as ParsedSpec, type code_RedosFinding as RedosFinding, type code_RedosResult as RedosResult, type code_RedosSeverity as RedosSeverity, type code_RegexError as RegexError, type code_RegexFlag as RegexFlag, type code_RegexMatch as RegexMatch, type code_RegexResult as RegexResult, type code_RegexSuccess as RegexSuccess, code_SQL_DEFAULT_OPTIONS as SQL_DEFAULT_OPTIONS, type code_Segment as Segment, type code_SpecVersion as SpecVersion, type code_SqlDialect as SqlDialect, type code_SqlFormatOptions as SqlFormatOptions, type code_TestPatternResult as TestPatternResult, code_buildDockerPull as buildDockerPull, code_buildDockerRun as buildDockerRun, code_buildGitCommand as buildGitCommand, code_collapseHtmlWhitespace as collapseHtmlWhitespace, code_collapseJsWhitespace as collapseJsWhitespace, code_countProperties as countProperties, code_countRules as countRules, code_detectDialect as detectDialect, code_detectOperationType as detectOperationType, code_detectRedos as detectRedos, code_envToExport as envToExport, code_envToJson as envToJson, code_formatCss as formatCss, code_formatGql as formatGql, code_formatHtml as formatHtml, code_formatSql as formatSql, code_getEndpointsByTag as getEndpointsByTag, code_getHtmlStats as getHtmlStats, code_getJsStats as getJsStats, code_getMethodColor as getMethodColor, code_isValidTag as isValidTag, code_lintConventionalCommit as lintConventionalCommit, code_lookupMime as lookupMime, code_minifyCss as minifyCss, code_minifyGql as minifyGql, code_minifyHtml as minifyHtml, code_minifyJs as minifyJs, code_minifySql as minifySql, code_normalizeRef as normalizeRef, code_parseDockerImage as parseDockerImage, code_parseEnv as parseEnv, code_parseGitCommand as parseGitCommand, code_parseGithubUrl as parseGithubUrl, code_parseSpec as parseSpec, code_removeConsoleCalls as removeConsoleCalls, code_removeEmptyAttributes as removeEmptyAttributes, code_removeHtmlComments as removeHtmlComments, code_removeJsComments as removeJsComments, code_removeRedundantAttributes as removeRedundantAttributes, code_searchCheatsheet as searchCheatsheet, code_searchEndpoints as searchEndpoints, code_splitStatements as splitStatements, code_testGitignorePatterns as testGitignorePatterns, code_testPattern as testPattern, code_testRegex as testRegex, code_validateEnvKey as validateEnvKey };
|
|
473
492
|
}
|
|
474
493
|
|
|
475
|
-
export {
|
|
494
|
+
export { collapseJsWhitespace as $, ALL_FLAGS as A, type RedosSeverity as B, CHEATSHEET as C, DEFAULT_COMMIT_TYPES as D, type EnvEntry as E, type RegexError as F, type GitCommandConfig as G, type HtmlFormatResult as H, type RegexFlag as I, type JsMinifyOptions as J, type RegexMatch as K, type RegexResult as L, MIME_TABLE as M, type RegexSuccess as N, OPERATIONS as O, type ParsedSpec as P, type Segment as Q, type RedosFinding as R, SQL_DEFAULT_OPTIONS as S, type SpecVersion as T, type SqlDialect as U, type SqlFormatOptions as V, type TestPatternResult as W, buildDockerPull as X, buildDockerRun as Y, buildGitCommand as Z, collapseHtmlWhitespace as _, type ApiEndpoint as a, countProperties as a0, countRules as a1, detectDialect as a2, detectOperationType as a3, detectRedos as a4, envToExport as a5, envToJson as a6, formatCss as a7, formatGql as a8, formatHtml as a9, splitStatements as aA, testGitignorePatterns as aB, testPattern as aC, testRegex as aD, validateEnvKey as aE, formatSql as aa, getEndpointsByTag as ab, getHtmlStats as ac, getJsStats as ad, getMethodColor as ae, isValidTag as af, lintConventionalCommit as ag, lookupMime as ah, minifyCss as ai, minifyGql as aj, minifyHtml as ak, minifyJs as al, minifySql as am, normalizeRef as an, parseDockerImage as ao, parseEnv as ap, parseGitCommand as aq, parseGithubUrl as ar, parseSpec as as, removeConsoleCalls as at, removeEmptyAttributes as au, removeHtmlComments as av, removeJsComments as aw, removeRedundantAttributes as ax, searchCheatsheet as ay, searchEndpoints as az, type ApiInfo as b, code as c, type CheatsheetEntry as d, type ConventionalCommitFinding as e, type ConventionalCommitFooter as f, type ConventionalCommitOptions as g, type ConventionalCommitParsed as h, type ConventionalCommitResult as i, type ConventionalCommitSeverity as j, type CssResult as k, type DockerImageRef as l, type EnvParseResult as m, type GitCommandResult as n, type GitOperation as o, type GithubUrlInfo as p, type GithubUrlType as q, type GitignoreTestResult as r, type GqlFormatResult as s, type HtmlMinifyOptions as t, type HtmlMinifyResult as u, type JsMinifyResult as v, type MatchResult as w, type MimeEntry as x, type MimeLookupResult as y, type RedosResult as z };
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* - github-url-parser (parseGithubUrl)
|
|
22
22
|
* - redos-detector (detectRedos)
|
|
23
23
|
* - conventional-commit-linter (lintConventionalCommit)
|
|
24
|
+
* - gitignore-tester (testGitignorePatterns)
|
|
24
25
|
*/
|
|
25
26
|
type RegexFlag = 'g' | 'i' | 'm' | 's' | 'u';
|
|
26
27
|
declare const ALL_FLAGS: RegexFlag[];
|
|
@@ -375,6 +376,22 @@ declare const DEFAULT_COMMIT_TYPES: string[];
|
|
|
375
376
|
declare function lintConventionalCommit(message: string, options?: ConventionalCommitOptions): ConventionalCommitResult | {
|
|
376
377
|
error: string;
|
|
377
378
|
};
|
|
379
|
+
interface GitignoreTestResult {
|
|
380
|
+
path: string;
|
|
381
|
+
ignored: boolean;
|
|
382
|
+
matchedPattern: string | null;
|
|
383
|
+
matchedLine: number | null;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Test a list of paths against a .gitignore file's contents. Returns, for
|
|
387
|
+
* each path, whether it would be ignored and which pattern (and line number)
|
|
388
|
+
* decided that outcome, following the "last matching pattern wins, negation
|
|
389
|
+
* flips it" rule git itself uses. Paths should be relative, forward-slash
|
|
390
|
+
* separated, and use a trailing `/` to mark a directory.
|
|
391
|
+
*/
|
|
392
|
+
declare function testGitignorePatterns(gitignoreContent: string, paths: string[]): GitignoreTestResult[] | {
|
|
393
|
+
error: string;
|
|
394
|
+
};
|
|
378
395
|
|
|
379
396
|
declare const code_ALL_FLAGS: typeof ALL_FLAGS;
|
|
380
397
|
type code_ApiEndpoint = ApiEndpoint;
|
|
@@ -397,6 +414,7 @@ type code_GitCommandResult = GitCommandResult;
|
|
|
397
414
|
type code_GitOperation = GitOperation;
|
|
398
415
|
type code_GithubUrlInfo = GithubUrlInfo;
|
|
399
416
|
type code_GithubUrlType = GithubUrlType;
|
|
417
|
+
type code_GitignoreTestResult = GitignoreTestResult;
|
|
400
418
|
type code_GqlFormatResult = GqlFormatResult;
|
|
401
419
|
type code_HtmlFormatResult = HtmlFormatResult;
|
|
402
420
|
type code_HtmlMinifyOptions = HtmlMinifyOptions;
|
|
@@ -465,11 +483,12 @@ declare const code_removeRedundantAttributes: typeof removeRedundantAttributes;
|
|
|
465
483
|
declare const code_searchCheatsheet: typeof searchCheatsheet;
|
|
466
484
|
declare const code_searchEndpoints: typeof searchEndpoints;
|
|
467
485
|
declare const code_splitStatements: typeof splitStatements;
|
|
486
|
+
declare const code_testGitignorePatterns: typeof testGitignorePatterns;
|
|
468
487
|
declare const code_testPattern: typeof testPattern;
|
|
469
488
|
declare const code_testRegex: typeof testRegex;
|
|
470
489
|
declare const code_validateEnvKey: typeof validateEnvKey;
|
|
471
490
|
declare namespace code {
|
|
472
|
-
export { code_ALL_FLAGS as ALL_FLAGS, type code_ApiEndpoint as ApiEndpoint, type code_ApiInfo as ApiInfo, code_CHEATSHEET as CHEATSHEET, type code_CheatsheetEntry as CheatsheetEntry, type code_ConventionalCommitFinding as ConventionalCommitFinding, type code_ConventionalCommitFooter as ConventionalCommitFooter, type code_ConventionalCommitOptions as ConventionalCommitOptions, type code_ConventionalCommitParsed as ConventionalCommitParsed, type code_ConventionalCommitResult as ConventionalCommitResult, type code_ConventionalCommitSeverity as ConventionalCommitSeverity, type code_CssResult as CssResult, code_DEFAULT_COMMIT_TYPES as DEFAULT_COMMIT_TYPES, type code_DockerImageRef as DockerImageRef, type code_EnvEntry as EnvEntry, type code_EnvParseResult as EnvParseResult, type code_GitCommandConfig as GitCommandConfig, type code_GitCommandResult as GitCommandResult, type code_GitOperation as GitOperation, type code_GithubUrlInfo as GithubUrlInfo, type code_GithubUrlType as GithubUrlType, type code_GqlFormatResult as GqlFormatResult, type code_HtmlFormatResult as HtmlFormatResult, type code_HtmlMinifyOptions as HtmlMinifyOptions, type code_HtmlMinifyResult as HtmlMinifyResult, type code_JsMinifyOptions as JsMinifyOptions, type code_JsMinifyResult as JsMinifyResult, code_MIME_TABLE as MIME_TABLE, type code_MatchResult as MatchResult, type code_MimeEntry as MimeEntry, type code_MimeLookupResult as MimeLookupResult, code_OPERATIONS as OPERATIONS, type code_ParsedSpec as ParsedSpec, type code_RedosFinding as RedosFinding, type code_RedosResult as RedosResult, type code_RedosSeverity as RedosSeverity, type code_RegexError as RegexError, type code_RegexFlag as RegexFlag, type code_RegexMatch as RegexMatch, type code_RegexResult as RegexResult, type code_RegexSuccess as RegexSuccess, code_SQL_DEFAULT_OPTIONS as SQL_DEFAULT_OPTIONS, type code_Segment as Segment, type code_SpecVersion as SpecVersion, type code_SqlDialect as SqlDialect, type code_SqlFormatOptions as SqlFormatOptions, type code_TestPatternResult as TestPatternResult, code_buildDockerPull as buildDockerPull, code_buildDockerRun as buildDockerRun, code_buildGitCommand as buildGitCommand, code_collapseHtmlWhitespace as collapseHtmlWhitespace, code_collapseJsWhitespace as collapseJsWhitespace, code_countProperties as countProperties, code_countRules as countRules, code_detectDialect as detectDialect, code_detectOperationType as detectOperationType, code_detectRedos as detectRedos, code_envToExport as envToExport, code_envToJson as envToJson, code_formatCss as formatCss, code_formatGql as formatGql, code_formatHtml as formatHtml, code_formatSql as formatSql, code_getEndpointsByTag as getEndpointsByTag, code_getHtmlStats as getHtmlStats, code_getJsStats as getJsStats, code_getMethodColor as getMethodColor, code_isValidTag as isValidTag, code_lintConventionalCommit as lintConventionalCommit, code_lookupMime as lookupMime, code_minifyCss as minifyCss, code_minifyGql as minifyGql, code_minifyHtml as minifyHtml, code_minifyJs as minifyJs, code_minifySql as minifySql, code_normalizeRef as normalizeRef, code_parseDockerImage as parseDockerImage, code_parseEnv as parseEnv, code_parseGitCommand as parseGitCommand, code_parseGithubUrl as parseGithubUrl, code_parseSpec as parseSpec, code_removeConsoleCalls as removeConsoleCalls, code_removeEmptyAttributes as removeEmptyAttributes, code_removeHtmlComments as removeHtmlComments, code_removeJsComments as removeJsComments, code_removeRedundantAttributes as removeRedundantAttributes, code_searchCheatsheet as searchCheatsheet, code_searchEndpoints as searchEndpoints, code_splitStatements as splitStatements, code_testPattern as testPattern, code_testRegex as testRegex, code_validateEnvKey as validateEnvKey };
|
|
491
|
+
export { code_ALL_FLAGS as ALL_FLAGS, type code_ApiEndpoint as ApiEndpoint, type code_ApiInfo as ApiInfo, code_CHEATSHEET as CHEATSHEET, type code_CheatsheetEntry as CheatsheetEntry, type code_ConventionalCommitFinding as ConventionalCommitFinding, type code_ConventionalCommitFooter as ConventionalCommitFooter, type code_ConventionalCommitOptions as ConventionalCommitOptions, type code_ConventionalCommitParsed as ConventionalCommitParsed, type code_ConventionalCommitResult as ConventionalCommitResult, type code_ConventionalCommitSeverity as ConventionalCommitSeverity, type code_CssResult as CssResult, code_DEFAULT_COMMIT_TYPES as DEFAULT_COMMIT_TYPES, type code_DockerImageRef as DockerImageRef, type code_EnvEntry as EnvEntry, type code_EnvParseResult as EnvParseResult, type code_GitCommandConfig as GitCommandConfig, type code_GitCommandResult as GitCommandResult, type code_GitOperation as GitOperation, type code_GithubUrlInfo as GithubUrlInfo, type code_GithubUrlType as GithubUrlType, type code_GitignoreTestResult as GitignoreTestResult, type code_GqlFormatResult as GqlFormatResult, type code_HtmlFormatResult as HtmlFormatResult, type code_HtmlMinifyOptions as HtmlMinifyOptions, type code_HtmlMinifyResult as HtmlMinifyResult, type code_JsMinifyOptions as JsMinifyOptions, type code_JsMinifyResult as JsMinifyResult, code_MIME_TABLE as MIME_TABLE, type code_MatchResult as MatchResult, type code_MimeEntry as MimeEntry, type code_MimeLookupResult as MimeLookupResult, code_OPERATIONS as OPERATIONS, type code_ParsedSpec as ParsedSpec, type code_RedosFinding as RedosFinding, type code_RedosResult as RedosResult, type code_RedosSeverity as RedosSeverity, type code_RegexError as RegexError, type code_RegexFlag as RegexFlag, type code_RegexMatch as RegexMatch, type code_RegexResult as RegexResult, type code_RegexSuccess as RegexSuccess, code_SQL_DEFAULT_OPTIONS as SQL_DEFAULT_OPTIONS, type code_Segment as Segment, type code_SpecVersion as SpecVersion, type code_SqlDialect as SqlDialect, type code_SqlFormatOptions as SqlFormatOptions, type code_TestPatternResult as TestPatternResult, code_buildDockerPull as buildDockerPull, code_buildDockerRun as buildDockerRun, code_buildGitCommand as buildGitCommand, code_collapseHtmlWhitespace as collapseHtmlWhitespace, code_collapseJsWhitespace as collapseJsWhitespace, code_countProperties as countProperties, code_countRules as countRules, code_detectDialect as detectDialect, code_detectOperationType as detectOperationType, code_detectRedos as detectRedos, code_envToExport as envToExport, code_envToJson as envToJson, code_formatCss as formatCss, code_formatGql as formatGql, code_formatHtml as formatHtml, code_formatSql as formatSql, code_getEndpointsByTag as getEndpointsByTag, code_getHtmlStats as getHtmlStats, code_getJsStats as getJsStats, code_getMethodColor as getMethodColor, code_isValidTag as isValidTag, code_lintConventionalCommit as lintConventionalCommit, code_lookupMime as lookupMime, code_minifyCss as minifyCss, code_minifyGql as minifyGql, code_minifyHtml as minifyHtml, code_minifyJs as minifyJs, code_minifySql as minifySql, code_normalizeRef as normalizeRef, code_parseDockerImage as parseDockerImage, code_parseEnv as parseEnv, code_parseGitCommand as parseGitCommand, code_parseGithubUrl as parseGithubUrl, code_parseSpec as parseSpec, code_removeConsoleCalls as removeConsoleCalls, code_removeEmptyAttributes as removeEmptyAttributes, code_removeHtmlComments as removeHtmlComments, code_removeJsComments as removeJsComments, code_removeRedundantAttributes as removeRedundantAttributes, code_searchCheatsheet as searchCheatsheet, code_searchEndpoints as searchEndpoints, code_splitStatements as splitStatements, code_testGitignorePatterns as testGitignorePatterns, code_testPattern as testPattern, code_testRegex as testRegex, code_validateEnvKey as validateEnvKey };
|
|
473
492
|
}
|
|
474
493
|
|
|
475
|
-
export {
|
|
494
|
+
export { collapseJsWhitespace as $, ALL_FLAGS as A, type RedosSeverity as B, CHEATSHEET as C, DEFAULT_COMMIT_TYPES as D, type EnvEntry as E, type RegexError as F, type GitCommandConfig as G, type HtmlFormatResult as H, type RegexFlag as I, type JsMinifyOptions as J, type RegexMatch as K, type RegexResult as L, MIME_TABLE as M, type RegexSuccess as N, OPERATIONS as O, type ParsedSpec as P, type Segment as Q, type RedosFinding as R, SQL_DEFAULT_OPTIONS as S, type SpecVersion as T, type SqlDialect as U, type SqlFormatOptions as V, type TestPatternResult as W, buildDockerPull as X, buildDockerRun as Y, buildGitCommand as Z, collapseHtmlWhitespace as _, type ApiEndpoint as a, countProperties as a0, countRules as a1, detectDialect as a2, detectOperationType as a3, detectRedos as a4, envToExport as a5, envToJson as a6, formatCss as a7, formatGql as a8, formatHtml as a9, splitStatements as aA, testGitignorePatterns as aB, testPattern as aC, testRegex as aD, validateEnvKey as aE, formatSql as aa, getEndpointsByTag as ab, getHtmlStats as ac, getJsStats as ad, getMethodColor as ae, isValidTag as af, lintConventionalCommit as ag, lookupMime as ah, minifyCss as ai, minifyGql as aj, minifyHtml as ak, minifyJs as al, minifySql as am, normalizeRef as an, parseDockerImage as ao, parseEnv as ap, parseGitCommand as aq, parseGithubUrl as ar, parseSpec as as, removeConsoleCalls as at, removeEmptyAttributes as au, removeHtmlComments as av, removeJsComments as aw, removeRedundantAttributes as ax, searchCheatsheet as ay, searchEndpoints as az, type ApiInfo as b, code as c, type CheatsheetEntry as d, type ConventionalCommitFinding as e, type ConventionalCommitFooter as f, type ConventionalCommitOptions as g, type ConventionalCommitParsed as h, type ConventionalCommitResult as i, type ConventionalCommitSeverity as j, type CssResult as k, type DockerImageRef as l, type EnvParseResult as m, type GitCommandResult as n, type GitOperation as o, type GithubUrlInfo as p, type GithubUrlType as q, type GitignoreTestResult as r, type GqlFormatResult as s, type HtmlMinifyOptions as t, type HtmlMinifyResult as u, type JsMinifyResult as v, type MatchResult as w, type MimeEntry as x, type MimeLookupResult as y, type RedosResult as z };
|
package/dist/index.cjs
CHANGED
|
@@ -9685,6 +9685,7 @@ __export(network_exports, {
|
|
|
9685
9685
|
buildLinkHeader: () => buildLinkHeader,
|
|
9686
9686
|
buildMapUrl: () => buildMapUrl,
|
|
9687
9687
|
buildReferrerPolicy: () => buildReferrerPolicy,
|
|
9688
|
+
checkSetCookieHeader: () => checkSetCookieHeader,
|
|
9688
9689
|
countryCodeToFlag: () => countryCodeToFlag,
|
|
9689
9690
|
formatCoordinates: () => formatCoordinates,
|
|
9690
9691
|
formatTtl: () => formatTtl,
|
|
@@ -11723,6 +11724,83 @@ function parseIpv6Address(input) {
|
|
|
11723
11724
|
addressType: classifyIpv6(expandedGroups)
|
|
11724
11725
|
};
|
|
11725
11726
|
}
|
|
11727
|
+
var MAX_COOKIE_AGE_SECONDS = 400 * 24 * 60 * 60;
|
|
11728
|
+
function checkSetCookieHeader(header) {
|
|
11729
|
+
if (typeof header !== "string" || !header.trim()) {
|
|
11730
|
+
return { error: "A Set-Cookie header value is required" };
|
|
11731
|
+
}
|
|
11732
|
+
const parts = header.split(";").map((p) => p.trim()).filter(Boolean);
|
|
11733
|
+
const [nameValue, ...attrParts] = parts;
|
|
11734
|
+
const eqIdx = nameValue.indexOf("=");
|
|
11735
|
+
if (eqIdx === -1) return { error: "Missing name=value pair" };
|
|
11736
|
+
const name = nameValue.slice(0, eqIdx).trim();
|
|
11737
|
+
const value = nameValue.slice(eqIdx + 1).trim();
|
|
11738
|
+
if (!name) return { error: "Cookie name cannot be empty" };
|
|
11739
|
+
const cookie = {
|
|
11740
|
+
name,
|
|
11741
|
+
value,
|
|
11742
|
+
domain: null,
|
|
11743
|
+
path: null,
|
|
11744
|
+
expires: null,
|
|
11745
|
+
maxAge: null,
|
|
11746
|
+
secure: false,
|
|
11747
|
+
httpOnly: false,
|
|
11748
|
+
sameSite: null
|
|
11749
|
+
};
|
|
11750
|
+
for (const attr of attrParts) {
|
|
11751
|
+
const idx = attr.indexOf("=");
|
|
11752
|
+
const key = (idx === -1 ? attr : attr.slice(0, idx)).trim().toLowerCase();
|
|
11753
|
+
const val = idx === -1 ? "" : attr.slice(idx + 1).trim();
|
|
11754
|
+
switch (key) {
|
|
11755
|
+
case "domain":
|
|
11756
|
+
cookie.domain = val || null;
|
|
11757
|
+
break;
|
|
11758
|
+
case "path":
|
|
11759
|
+
cookie.path = val || null;
|
|
11760
|
+
break;
|
|
11761
|
+
case "expires":
|
|
11762
|
+
cookie.expires = val || null;
|
|
11763
|
+
break;
|
|
11764
|
+
case "max-age": {
|
|
11765
|
+
const n = Number(val);
|
|
11766
|
+
cookie.maxAge = Number.isFinite(n) ? n : null;
|
|
11767
|
+
break;
|
|
11768
|
+
}
|
|
11769
|
+
case "secure":
|
|
11770
|
+
cookie.secure = true;
|
|
11771
|
+
break;
|
|
11772
|
+
case "httponly":
|
|
11773
|
+
cookie.httpOnly = true;
|
|
11774
|
+
break;
|
|
11775
|
+
case "samesite": {
|
|
11776
|
+
const normalized = val.toLowerCase();
|
|
11777
|
+
if (normalized === "strict") cookie.sameSite = "Strict";
|
|
11778
|
+
else if (normalized === "lax") cookie.sameSite = "Lax";
|
|
11779
|
+
else if (normalized === "none") cookie.sameSite = "None";
|
|
11780
|
+
break;
|
|
11781
|
+
}
|
|
11782
|
+
}
|
|
11783
|
+
}
|
|
11784
|
+
const issues = [];
|
|
11785
|
+
const warnings = [];
|
|
11786
|
+
if (cookie.sameSite === "None" && !cookie.secure) {
|
|
11787
|
+
issues.push("SameSite=None requires the Secure attribute \u2014 modern browsers reject this cookie without it.");
|
|
11788
|
+
}
|
|
11789
|
+
if (name.startsWith("__Host-")) {
|
|
11790
|
+
if (!cookie.secure) issues.push("__Host- prefixed cookies require the Secure attribute.");
|
|
11791
|
+
if (cookie.domain) issues.push("__Host- prefixed cookies must not set a Domain attribute.");
|
|
11792
|
+
if (cookie.path !== "/") issues.push("__Host- prefixed cookies must set Path=/.");
|
|
11793
|
+
} else if (name.startsWith("__Secure-")) {
|
|
11794
|
+
if (!cookie.secure) issues.push("__Secure- prefixed cookies require the Secure attribute.");
|
|
11795
|
+
}
|
|
11796
|
+
if (!cookie.secure) {
|
|
11797
|
+
warnings.push("Missing Secure attribute \u2014 the cookie can be sent over a plain HTTP connection.");
|
|
11798
|
+
}
|
|
11799
|
+
if (cookie.maxAge !== null && cookie.maxAge > MAX_COOKIE_AGE_SECONDS) {
|
|
11800
|
+
warnings.push(`Max-Age (${cookie.maxAge}s) exceeds 400 days \u2014 Chromium-based browsers clamp cookie expiry to 400 days from when it's set, so this will be shortened.`);
|
|
11801
|
+
}
|
|
11802
|
+
return { cookie, issues, warnings, valid: issues.length === 0 };
|
|
11803
|
+
}
|
|
11726
11804
|
|
|
11727
11805
|
// src/tools/api.ts
|
|
11728
11806
|
var api_exports = {};
|
|
@@ -13083,6 +13161,7 @@ __export(code_exports, {
|
|
|
13083
13161
|
searchCheatsheet: () => searchCheatsheet,
|
|
13084
13162
|
searchEndpoints: () => searchEndpoints,
|
|
13085
13163
|
splitStatements: () => splitStatements,
|
|
13164
|
+
testGitignorePatterns: () => testGitignorePatterns,
|
|
13086
13165
|
testPattern: () => testPattern,
|
|
13087
13166
|
testRegex: () => testRegex,
|
|
13088
13167
|
validateEnvKey: () => validateEnvKey2
|
|
@@ -15891,6 +15970,85 @@ function lintConventionalCommit(message, options = {}) {
|
|
|
15891
15970
|
const valid = !findings.some((f) => f.severity === "error");
|
|
15892
15971
|
return { message, valid, parsed, findings };
|
|
15893
15972
|
}
|
|
15973
|
+
function globSegmentToRegexSource(segment) {
|
|
15974
|
+
let out = "";
|
|
15975
|
+
for (let i = 0; i < segment.length; i++) {
|
|
15976
|
+
const c = segment[i];
|
|
15977
|
+
if (c === "*") {
|
|
15978
|
+
out += "[^/]*";
|
|
15979
|
+
} else if (c === "?") {
|
|
15980
|
+
out += "[^/]";
|
|
15981
|
+
} else if (c === "[") {
|
|
15982
|
+
const close = segment.indexOf("]", i + 1);
|
|
15983
|
+
if (close === -1) {
|
|
15984
|
+
out += "\\[";
|
|
15985
|
+
} else {
|
|
15986
|
+
let cls = segment.slice(i + 1, close);
|
|
15987
|
+
if (cls.startsWith("!")) cls = "^" + cls.slice(1);
|
|
15988
|
+
out += `[${cls}]`;
|
|
15989
|
+
i = close;
|
|
15990
|
+
}
|
|
15991
|
+
} else {
|
|
15992
|
+
out += c.replace(/[.+^${}()|\\]/g, "\\$&");
|
|
15993
|
+
}
|
|
15994
|
+
}
|
|
15995
|
+
return out;
|
|
15996
|
+
}
|
|
15997
|
+
function compileGitignorePattern(raw, line) {
|
|
15998
|
+
let pattern = raw.replace(/\s+$/, "");
|
|
15999
|
+
if (!pattern || pattern.startsWith("#")) return null;
|
|
16000
|
+
let negate = false;
|
|
16001
|
+
if (pattern.startsWith("!")) {
|
|
16002
|
+
negate = true;
|
|
16003
|
+
pattern = pattern.slice(1);
|
|
16004
|
+
}
|
|
16005
|
+
pattern = pattern.replace(/\\(.)/g, "$1");
|
|
16006
|
+
if (!pattern) return null;
|
|
16007
|
+
const dirOnly = pattern.endsWith("/") && !pattern.endsWith("\\/");
|
|
16008
|
+
if (dirOnly) pattern = pattern.slice(0, -1);
|
|
16009
|
+
const hasLeadingSlash = pattern.startsWith("/");
|
|
16010
|
+
if (hasLeadingSlash) pattern = pattern.slice(1);
|
|
16011
|
+
const anchored = hasLeadingSlash || pattern.includes("/");
|
|
16012
|
+
const segments = pattern.split("/");
|
|
16013
|
+
const regexParts = segments.map((seg) => {
|
|
16014
|
+
if (seg === "**") return "(?:.*)";
|
|
16015
|
+
return globSegmentToRegexSource(seg);
|
|
16016
|
+
});
|
|
16017
|
+
let body = regexParts.join("/");
|
|
16018
|
+
body = body.replace(/\(\?:\.\*\)\//g, "(?:.*/)?").replace(/\/\(\?:\.\*\)/g, "(?:/.*)?");
|
|
16019
|
+
const prefix = anchored ? "^" : "^(?:.*/)?";
|
|
16020
|
+
const suffix = "(?:/.*)?$";
|
|
16021
|
+
const regex = new RegExp(prefix + body + suffix);
|
|
16022
|
+
return { raw, line, negate, regex };
|
|
16023
|
+
}
|
|
16024
|
+
function testGitignorePatterns(gitignoreContent, paths) {
|
|
16025
|
+
if (typeof gitignoreContent !== "string" || !gitignoreContent.trim()) {
|
|
16026
|
+
return { error: "gitignore content is required" };
|
|
16027
|
+
}
|
|
16028
|
+
if (!Array.isArray(paths) || paths.length === 0) {
|
|
16029
|
+
return { error: "At least one path is required" };
|
|
16030
|
+
}
|
|
16031
|
+
const lines = gitignoreContent.split("\n");
|
|
16032
|
+
const patterns = [];
|
|
16033
|
+
lines.forEach((line, idx) => {
|
|
16034
|
+
const compiled = compileGitignorePattern(line, idx + 1);
|
|
16035
|
+
if (compiled) patterns.push(compiled);
|
|
16036
|
+
});
|
|
16037
|
+
return paths.map((rawPath) => {
|
|
16038
|
+
const path = rawPath.trim().replace(/^\.\//, "");
|
|
16039
|
+
let ignored = false;
|
|
16040
|
+
let matchedPattern = null;
|
|
16041
|
+
let matchedLine = null;
|
|
16042
|
+
for (const p of patterns) {
|
|
16043
|
+
if (p.regex.test(path)) {
|
|
16044
|
+
ignored = !p.negate;
|
|
16045
|
+
matchedPattern = p.raw.trim();
|
|
16046
|
+
matchedLine = p.line;
|
|
16047
|
+
}
|
|
16048
|
+
}
|
|
16049
|
+
return { path, ignored, matchedPattern, matchedLine };
|
|
16050
|
+
});
|
|
16051
|
+
}
|
|
15894
16052
|
|
|
15895
16053
|
// src/tools/color.ts
|
|
15896
16054
|
var color_exports = {};
|
package/dist/index.d.cts
CHANGED
|
@@ -6,9 +6,9 @@ export { d as data } from './data-CFeS9kes.cjs';
|
|
|
6
6
|
export { g as generators } from './generators-Du8cBesn.cjs';
|
|
7
7
|
export { t as time } from './time-KqJjdqII.cjs';
|
|
8
8
|
export { u as units } from './units-c90DW-OZ.cjs';
|
|
9
|
-
export { n as network } from './network-
|
|
9
|
+
export { n as network } from './network-CnKUQT4g.cjs';
|
|
10
10
|
export { a as api } from './api-DmTNE4c1.cjs';
|
|
11
|
-
export { c as code } from './code-
|
|
11
|
+
export { c as code } from './code-KXoRsHtl.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
|
@@ -6,9 +6,9 @@ export { d as data } from './data-CFeS9kes.js';
|
|
|
6
6
|
export { g as generators } from './generators-Du8cBesn.js';
|
|
7
7
|
export { t as time } from './time-KqJjdqII.js';
|
|
8
8
|
export { u as units } from './units-c90DW-OZ.js';
|
|
9
|
-
export { n as network } from './network-
|
|
9
|
+
export { n as network } from './network-CnKUQT4g.js';
|
|
10
10
|
export { a as api } from './api-DmTNE4c1.js';
|
|
11
|
-
export { c as code } from './code-
|
|
11
|
+
export { c as code } from './code-KXoRsHtl.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,8 +1,8 @@
|
|
|
1
1
|
export { media_exports as media } from './chunk-L6V4W4SU.js';
|
|
2
2
|
export { units_exports as units } from './chunk-7AJRK57W.js';
|
|
3
|
-
export { network_exports as network } from './chunk-
|
|
3
|
+
export { network_exports as network } from './chunk-DBNTO3YO.js';
|
|
4
4
|
export { api_exports as api } from './chunk-52ZDKSIX.js';
|
|
5
|
-
export { code_exports as code } from './chunk-
|
|
5
|
+
export { code_exports as code } from './chunk-JL7YTXRB.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';
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* - referrer-policy-builder: buildReferrerPolicy
|
|
16
16
|
* - ipv6-compressor: parseIpv6Address
|
|
17
17
|
* - link-header-builder: buildLinkHeader
|
|
18
|
+
* - same-site-cookie-checker: checkSetCookieHeader
|
|
18
19
|
*/
|
|
19
20
|
declare const DNS_RECORD_TYPES: readonly ["A", "AAAA", "CNAME", "MX", "TXT", "NS", "SOA", "PTR", "SRV", "CAA"];
|
|
20
21
|
type DnsRecordType = typeof DNS_RECORD_TYPES[number];
|
|
@@ -372,10 +373,41 @@ interface Ipv6ParseResult {
|
|
|
372
373
|
declare function parseIpv6Address(input: string): Ipv6ParseResult | {
|
|
373
374
|
error: string;
|
|
374
375
|
};
|
|
376
|
+
type SameSiteValue = 'Strict' | 'Lax' | 'None';
|
|
377
|
+
interface CookieAttributes {
|
|
378
|
+
name: string;
|
|
379
|
+
value: string;
|
|
380
|
+
domain: string | null;
|
|
381
|
+
path: string | null;
|
|
382
|
+
expires: string | null;
|
|
383
|
+
maxAge: number | null;
|
|
384
|
+
secure: boolean;
|
|
385
|
+
httpOnly: boolean;
|
|
386
|
+
sameSite: SameSiteValue | null;
|
|
387
|
+
}
|
|
388
|
+
interface CookieCheckResult {
|
|
389
|
+
cookie: CookieAttributes;
|
|
390
|
+
issues: string[];
|
|
391
|
+
warnings: string[];
|
|
392
|
+
valid: boolean;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Parse a `Set-Cookie` header value and validate its attribute combination:
|
|
396
|
+
* `SameSite=None` requires `Secure`, the `__Host-`/`__Secure-` name prefixes
|
|
397
|
+
* each require their own attributes (`__Host-` additionally forbids `Domain`
|
|
398
|
+
* and requires `Path=/`), a missing `Secure` attribute is flagged, and a
|
|
399
|
+
* `Max-Age` beyond 400 days is flagged since Chromium-based browsers clamp
|
|
400
|
+
* it to that cap regardless of what was sent.
|
|
401
|
+
*/
|
|
402
|
+
declare function checkSetCookieHeader(header: string): CookieCheckResult | {
|
|
403
|
+
error: string;
|
|
404
|
+
};
|
|
375
405
|
|
|
376
406
|
type network_CacheControlDirective = CacheControlDirective;
|
|
377
407
|
type network_CacheControlOptions = CacheControlOptions;
|
|
378
408
|
type network_CacheControlResult = CacheControlResult;
|
|
409
|
+
type network_CookieAttributes = CookieAttributes;
|
|
410
|
+
type network_CookieCheckResult = CookieCheckResult;
|
|
379
411
|
declare const network_DNS_RECORD_TYPES: typeof DNS_RECORD_TYPES;
|
|
380
412
|
type network_DnsRecord = DnsRecord;
|
|
381
413
|
type network_DnsRecordType = DnsRecordType;
|
|
@@ -405,6 +437,7 @@ type network_RobotsIssue = RobotsIssue;
|
|
|
405
437
|
type network_RobotsRule = RobotsRule;
|
|
406
438
|
type network_RobotsValidationResult = RobotsValidationResult;
|
|
407
439
|
declare const network_STATUS_CODES: typeof STATUS_CODES;
|
|
440
|
+
type network_SameSiteValue = SameSiteValue;
|
|
408
441
|
type network_SitemapIndexEntry = SitemapIndexEntry;
|
|
409
442
|
type network_SitemapIssue = SitemapIssue;
|
|
410
443
|
type network_SitemapUrlEntry = SitemapUrlEntry;
|
|
@@ -418,6 +451,7 @@ declare const network_buildGeoUrl: typeof buildGeoUrl;
|
|
|
418
451
|
declare const network_buildLinkHeader: typeof buildLinkHeader;
|
|
419
452
|
declare const network_buildMapUrl: typeof buildMapUrl;
|
|
420
453
|
declare const network_buildReferrerPolicy: typeof buildReferrerPolicy;
|
|
454
|
+
declare const network_checkSetCookieHeader: typeof checkSetCookieHeader;
|
|
421
455
|
declare const network_countryCodeToFlag: typeof countryCodeToFlag;
|
|
422
456
|
declare const network_formatCoordinates: typeof formatCoordinates;
|
|
423
457
|
declare const network_formatTtl: typeof formatTtl;
|
|
@@ -447,7 +481,7 @@ declare const network_validateHeaderValue: typeof validateHeaderValue;
|
|
|
447
481
|
declare const network_validateRobotsTxt: typeof validateRobotsTxt;
|
|
448
482
|
declare const network_validateSitemap: typeof validateSitemap;
|
|
449
483
|
declare namespace network {
|
|
450
|
-
export { type network_CacheControlDirective as CacheControlDirective, type network_CacheControlOptions as CacheControlOptions, type network_CacheControlResult as CacheControlResult, 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_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_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, network_REFERRER_POLICY_VALUES as REFERRER_POLICY_VALUES, 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_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_buildCacheControl as buildCacheControl, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildLinkHeader as buildLinkHeader, network_buildMapUrl as buildMapUrl, network_buildReferrerPolicy as buildReferrerPolicy, 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_parseIpv6Address as parseIpv6Address, 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 };
|
|
484
|
+
export { type network_CacheControlDirective as CacheControlDirective, type network_CacheControlOptions as CacheControlOptions, type network_CacheControlResult as CacheControlResult, 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_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_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, network_REFERRER_POLICY_VALUES as REFERRER_POLICY_VALUES, 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, network_buildCacheControl as buildCacheControl, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildLinkHeader as buildLinkHeader, network_buildMapUrl as buildMapUrl, network_buildReferrerPolicy as buildReferrerPolicy, 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_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_parseIpv6Address as parseIpv6Address, 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 };
|
|
451
485
|
}
|
|
452
486
|
|
|
453
|
-
export {
|
|
487
|
+
export { getByCategory as $, type SameSiteValue as A, type SitemapIndexEntry as B, type CacheControlDirective as C, DNS_RECORD_TYPES as D, type SitemapIssue as E, type SitemapUrlEntry as F, type GeoResult as G, HTTP_HEADERS as H, type Ipv6AddressType as I, type SitemapValidationResult as J, type StatusCode as K, LINK_REL_VALUES as L, type UserAgentInfo as M, buildCacheControl as N, buildDnsQueryUrl as O, type ParsedDnsResult as P, buildGeoUrl as Q, REFERRER_POLICY_VALUES as R, STATUS_CODES as S, buildLinkHeader as T, type UaDeviceType as U, buildMapUrl as V, buildReferrerPolicy as W, checkSetCookieHeader as X, countryCodeToFlag as Y, formatCoordinates as Z, formatTtl as _, type CacheControlOptions as a, getHeader as a0, getHeadersByCategory as a1, getStatusByCategory as a2, getStatusCode as a3, isClientError as a4, isServerError as a5, isSuccess as a6, isValidIp as a7, isValidIpv4 as a8, isValidIpv6 as a9, parseDnsResponse as aa, parseGeoResponse as ab, parseHar as ac, parseIpv6Address as ad, parseUserAgent as ae, searchHeaders as af, searchStatusCodes as ag, statusCodeToText as ah, typeNumberToLabel as ai, validateDomain as aj, validateHeaderName as ak, validateHeaderValue as al, validateRobotsTxt as am, validateSitemap as an, type CacheControlResult as b, type CookieAttributes as c, type CookieCheckResult as d, type DnsRecord as e, type DnsRecordType as f, type DnsResponse as g, type HarEntry as h, type HarParseResult as i, type HarSummary as j, type HeaderCategory as k, type HttpHeader as l, type Ipv6ParseResult as m, network as n, type LinkHeaderEntry as o, type LinkHeaderEntryInput as p, type LinkHeaderResult as q, type LinkRel as r, type ParsedGeoResult as s, type ReferrerPolicyEntry as t, type ReferrerPolicyResult as u, type ReferrerPolicyValue as v, type RobotsGroup as w, type RobotsIssue as x, type RobotsRule as y, type RobotsValidationResult as z };
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* - referrer-policy-builder: buildReferrerPolicy
|
|
16
16
|
* - ipv6-compressor: parseIpv6Address
|
|
17
17
|
* - link-header-builder: buildLinkHeader
|
|
18
|
+
* - same-site-cookie-checker: checkSetCookieHeader
|
|
18
19
|
*/
|
|
19
20
|
declare const DNS_RECORD_TYPES: readonly ["A", "AAAA", "CNAME", "MX", "TXT", "NS", "SOA", "PTR", "SRV", "CAA"];
|
|
20
21
|
type DnsRecordType = typeof DNS_RECORD_TYPES[number];
|
|
@@ -372,10 +373,41 @@ interface Ipv6ParseResult {
|
|
|
372
373
|
declare function parseIpv6Address(input: string): Ipv6ParseResult | {
|
|
373
374
|
error: string;
|
|
374
375
|
};
|
|
376
|
+
type SameSiteValue = 'Strict' | 'Lax' | 'None';
|
|
377
|
+
interface CookieAttributes {
|
|
378
|
+
name: string;
|
|
379
|
+
value: string;
|
|
380
|
+
domain: string | null;
|
|
381
|
+
path: string | null;
|
|
382
|
+
expires: string | null;
|
|
383
|
+
maxAge: number | null;
|
|
384
|
+
secure: boolean;
|
|
385
|
+
httpOnly: boolean;
|
|
386
|
+
sameSite: SameSiteValue | null;
|
|
387
|
+
}
|
|
388
|
+
interface CookieCheckResult {
|
|
389
|
+
cookie: CookieAttributes;
|
|
390
|
+
issues: string[];
|
|
391
|
+
warnings: string[];
|
|
392
|
+
valid: boolean;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Parse a `Set-Cookie` header value and validate its attribute combination:
|
|
396
|
+
* `SameSite=None` requires `Secure`, the `__Host-`/`__Secure-` name prefixes
|
|
397
|
+
* each require their own attributes (`__Host-` additionally forbids `Domain`
|
|
398
|
+
* and requires `Path=/`), a missing `Secure` attribute is flagged, and a
|
|
399
|
+
* `Max-Age` beyond 400 days is flagged since Chromium-based browsers clamp
|
|
400
|
+
* it to that cap regardless of what was sent.
|
|
401
|
+
*/
|
|
402
|
+
declare function checkSetCookieHeader(header: string): CookieCheckResult | {
|
|
403
|
+
error: string;
|
|
404
|
+
};
|
|
375
405
|
|
|
376
406
|
type network_CacheControlDirective = CacheControlDirective;
|
|
377
407
|
type network_CacheControlOptions = CacheControlOptions;
|
|
378
408
|
type network_CacheControlResult = CacheControlResult;
|
|
409
|
+
type network_CookieAttributes = CookieAttributes;
|
|
410
|
+
type network_CookieCheckResult = CookieCheckResult;
|
|
379
411
|
declare const network_DNS_RECORD_TYPES: typeof DNS_RECORD_TYPES;
|
|
380
412
|
type network_DnsRecord = DnsRecord;
|
|
381
413
|
type network_DnsRecordType = DnsRecordType;
|
|
@@ -405,6 +437,7 @@ type network_RobotsIssue = RobotsIssue;
|
|
|
405
437
|
type network_RobotsRule = RobotsRule;
|
|
406
438
|
type network_RobotsValidationResult = RobotsValidationResult;
|
|
407
439
|
declare const network_STATUS_CODES: typeof STATUS_CODES;
|
|
440
|
+
type network_SameSiteValue = SameSiteValue;
|
|
408
441
|
type network_SitemapIndexEntry = SitemapIndexEntry;
|
|
409
442
|
type network_SitemapIssue = SitemapIssue;
|
|
410
443
|
type network_SitemapUrlEntry = SitemapUrlEntry;
|
|
@@ -418,6 +451,7 @@ declare const network_buildGeoUrl: typeof buildGeoUrl;
|
|
|
418
451
|
declare const network_buildLinkHeader: typeof buildLinkHeader;
|
|
419
452
|
declare const network_buildMapUrl: typeof buildMapUrl;
|
|
420
453
|
declare const network_buildReferrerPolicy: typeof buildReferrerPolicy;
|
|
454
|
+
declare const network_checkSetCookieHeader: typeof checkSetCookieHeader;
|
|
421
455
|
declare const network_countryCodeToFlag: typeof countryCodeToFlag;
|
|
422
456
|
declare const network_formatCoordinates: typeof formatCoordinates;
|
|
423
457
|
declare const network_formatTtl: typeof formatTtl;
|
|
@@ -447,7 +481,7 @@ declare const network_validateHeaderValue: typeof validateHeaderValue;
|
|
|
447
481
|
declare const network_validateRobotsTxt: typeof validateRobotsTxt;
|
|
448
482
|
declare const network_validateSitemap: typeof validateSitemap;
|
|
449
483
|
declare namespace network {
|
|
450
|
-
export { type network_CacheControlDirective as CacheControlDirective, type network_CacheControlOptions as CacheControlOptions, type network_CacheControlResult as CacheControlResult, 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_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_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, network_REFERRER_POLICY_VALUES as REFERRER_POLICY_VALUES, 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_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_buildCacheControl as buildCacheControl, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildLinkHeader as buildLinkHeader, network_buildMapUrl as buildMapUrl, network_buildReferrerPolicy as buildReferrerPolicy, 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_parseIpv6Address as parseIpv6Address, 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 };
|
|
484
|
+
export { type network_CacheControlDirective as CacheControlDirective, type network_CacheControlOptions as CacheControlOptions, type network_CacheControlResult as CacheControlResult, 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_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_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, network_REFERRER_POLICY_VALUES as REFERRER_POLICY_VALUES, 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, network_buildCacheControl as buildCacheControl, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildLinkHeader as buildLinkHeader, network_buildMapUrl as buildMapUrl, network_buildReferrerPolicy as buildReferrerPolicy, 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_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_parseIpv6Address as parseIpv6Address, 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 };
|
|
451
485
|
}
|
|
452
486
|
|
|
453
|
-
export {
|
|
487
|
+
export { getByCategory as $, type SameSiteValue as A, type SitemapIndexEntry as B, type CacheControlDirective as C, DNS_RECORD_TYPES as D, type SitemapIssue as E, type SitemapUrlEntry as F, type GeoResult as G, HTTP_HEADERS as H, type Ipv6AddressType as I, type SitemapValidationResult as J, type StatusCode as K, LINK_REL_VALUES as L, type UserAgentInfo as M, buildCacheControl as N, buildDnsQueryUrl as O, type ParsedDnsResult as P, buildGeoUrl as Q, REFERRER_POLICY_VALUES as R, STATUS_CODES as S, buildLinkHeader as T, type UaDeviceType as U, buildMapUrl as V, buildReferrerPolicy as W, checkSetCookieHeader as X, countryCodeToFlag as Y, formatCoordinates as Z, formatTtl as _, type CacheControlOptions as a, getHeader as a0, getHeadersByCategory as a1, getStatusByCategory as a2, getStatusCode as a3, isClientError as a4, isServerError as a5, isSuccess as a6, isValidIp as a7, isValidIpv4 as a8, isValidIpv6 as a9, parseDnsResponse as aa, parseGeoResponse as ab, parseHar as ac, parseIpv6Address as ad, parseUserAgent as ae, searchHeaders as af, searchStatusCodes as ag, statusCodeToText as ah, typeNumberToLabel as ai, validateDomain as aj, validateHeaderName as ak, validateHeaderValue as al, validateRobotsTxt as am, validateSitemap as an, type CacheControlResult as b, type CookieAttributes as c, type CookieCheckResult as d, type DnsRecord as e, type DnsRecordType as f, type DnsResponse as g, type HarEntry as h, type HarParseResult as i, type HarSummary as j, type HeaderCategory as k, type HttpHeader as l, type Ipv6ParseResult as m, network as n, type LinkHeaderEntry as o, type LinkHeaderEntryInput as p, type LinkHeaderResult as q, type LinkRel as r, type ParsedGeoResult as s, type ReferrerPolicyEntry as t, type ReferrerPolicyResult as u, type ReferrerPolicyValue as v, type RobotsGroup as w, type RobotsIssue as x, type RobotsRule as y, type RobotsValidationResult as z };
|
package/dist/tools/code.cjs
CHANGED
|
@@ -2807,6 +2807,85 @@ function lintConventionalCommit(message, options = {}) {
|
|
|
2807
2807
|
const valid = !findings.some((f) => f.severity === "error");
|
|
2808
2808
|
return { message, valid, parsed, findings };
|
|
2809
2809
|
}
|
|
2810
|
+
function globSegmentToRegexSource(segment) {
|
|
2811
|
+
let out = "";
|
|
2812
|
+
for (let i = 0; i < segment.length; i++) {
|
|
2813
|
+
const c = segment[i];
|
|
2814
|
+
if (c === "*") {
|
|
2815
|
+
out += "[^/]*";
|
|
2816
|
+
} else if (c === "?") {
|
|
2817
|
+
out += "[^/]";
|
|
2818
|
+
} else if (c === "[") {
|
|
2819
|
+
const close = segment.indexOf("]", i + 1);
|
|
2820
|
+
if (close === -1) {
|
|
2821
|
+
out += "\\[";
|
|
2822
|
+
} else {
|
|
2823
|
+
let cls = segment.slice(i + 1, close);
|
|
2824
|
+
if (cls.startsWith("!")) cls = "^" + cls.slice(1);
|
|
2825
|
+
out += `[${cls}]`;
|
|
2826
|
+
i = close;
|
|
2827
|
+
}
|
|
2828
|
+
} else {
|
|
2829
|
+
out += c.replace(/[.+^${}()|\\]/g, "\\$&");
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2832
|
+
return out;
|
|
2833
|
+
}
|
|
2834
|
+
function compileGitignorePattern(raw, line) {
|
|
2835
|
+
let pattern = raw.replace(/\s+$/, "");
|
|
2836
|
+
if (!pattern || pattern.startsWith("#")) return null;
|
|
2837
|
+
let negate = false;
|
|
2838
|
+
if (pattern.startsWith("!")) {
|
|
2839
|
+
negate = true;
|
|
2840
|
+
pattern = pattern.slice(1);
|
|
2841
|
+
}
|
|
2842
|
+
pattern = pattern.replace(/\\(.)/g, "$1");
|
|
2843
|
+
if (!pattern) return null;
|
|
2844
|
+
const dirOnly = pattern.endsWith("/") && !pattern.endsWith("\\/");
|
|
2845
|
+
if (dirOnly) pattern = pattern.slice(0, -1);
|
|
2846
|
+
const hasLeadingSlash = pattern.startsWith("/");
|
|
2847
|
+
if (hasLeadingSlash) pattern = pattern.slice(1);
|
|
2848
|
+
const anchored = hasLeadingSlash || pattern.includes("/");
|
|
2849
|
+
const segments = pattern.split("/");
|
|
2850
|
+
const regexParts = segments.map((seg) => {
|
|
2851
|
+
if (seg === "**") return "(?:.*)";
|
|
2852
|
+
return globSegmentToRegexSource(seg);
|
|
2853
|
+
});
|
|
2854
|
+
let body = regexParts.join("/");
|
|
2855
|
+
body = body.replace(/\(\?:\.\*\)\//g, "(?:.*/)?").replace(/\/\(\?:\.\*\)/g, "(?:/.*)?");
|
|
2856
|
+
const prefix = anchored ? "^" : "^(?:.*/)?";
|
|
2857
|
+
const suffix = "(?:/.*)?$";
|
|
2858
|
+
const regex = new RegExp(prefix + body + suffix);
|
|
2859
|
+
return { raw, line, negate, regex };
|
|
2860
|
+
}
|
|
2861
|
+
function testGitignorePatterns(gitignoreContent, paths) {
|
|
2862
|
+
if (typeof gitignoreContent !== "string" || !gitignoreContent.trim()) {
|
|
2863
|
+
return { error: "gitignore content is required" };
|
|
2864
|
+
}
|
|
2865
|
+
if (!Array.isArray(paths) || paths.length === 0) {
|
|
2866
|
+
return { error: "At least one path is required" };
|
|
2867
|
+
}
|
|
2868
|
+
const lines = gitignoreContent.split("\n");
|
|
2869
|
+
const patterns = [];
|
|
2870
|
+
lines.forEach((line, idx) => {
|
|
2871
|
+
const compiled = compileGitignorePattern(line, idx + 1);
|
|
2872
|
+
if (compiled) patterns.push(compiled);
|
|
2873
|
+
});
|
|
2874
|
+
return paths.map((rawPath) => {
|
|
2875
|
+
const path = rawPath.trim().replace(/^\.\//, "");
|
|
2876
|
+
let ignored = false;
|
|
2877
|
+
let matchedPattern = null;
|
|
2878
|
+
let matchedLine = null;
|
|
2879
|
+
for (const p of patterns) {
|
|
2880
|
+
if (p.regex.test(path)) {
|
|
2881
|
+
ignored = !p.negate;
|
|
2882
|
+
matchedPattern = p.raw.trim();
|
|
2883
|
+
matchedLine = p.line;
|
|
2884
|
+
}
|
|
2885
|
+
}
|
|
2886
|
+
return { path, ignored, matchedPattern, matchedLine };
|
|
2887
|
+
});
|
|
2888
|
+
}
|
|
2810
2889
|
|
|
2811
2890
|
exports.ALL_FLAGS = ALL_FLAGS;
|
|
2812
2891
|
exports.CHEATSHEET = CHEATSHEET;
|
|
@@ -2856,6 +2935,7 @@ exports.removeRedundantAttributes = removeRedundantAttributes;
|
|
|
2856
2935
|
exports.searchCheatsheet = searchCheatsheet;
|
|
2857
2936
|
exports.searchEndpoints = searchEndpoints;
|
|
2858
2937
|
exports.splitStatements = splitStatements;
|
|
2938
|
+
exports.testGitignorePatterns = testGitignorePatterns;
|
|
2859
2939
|
exports.testPattern = testPattern;
|
|
2860
2940
|
exports.testRegex = testRegex;
|
|
2861
2941
|
exports.validateEnvKey = validateEnvKey;
|
package/dist/tools/code.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as ALL_FLAGS, a as ApiEndpoint, b as ApiInfo, C as CHEATSHEET, d as CheatsheetEntry, e as ConventionalCommitFinding, f as ConventionalCommitFooter, g as ConventionalCommitOptions, h as ConventionalCommitParsed, i as ConventionalCommitResult, j as ConventionalCommitSeverity, k as CssResult, D as DEFAULT_COMMIT_TYPES, l as DockerImageRef, E as EnvEntry, m as EnvParseResult, G as GitCommandConfig, n as GitCommandResult, o as GitOperation, p as GithubUrlInfo, q as GithubUrlType, r as GqlFormatResult, H as HtmlFormatResult,
|
|
1
|
+
export { A as ALL_FLAGS, a as ApiEndpoint, b as ApiInfo, C as CHEATSHEET, d as CheatsheetEntry, e as ConventionalCommitFinding, f as ConventionalCommitFooter, g as ConventionalCommitOptions, h as ConventionalCommitParsed, i as ConventionalCommitResult, j as ConventionalCommitSeverity, k as CssResult, D as DEFAULT_COMMIT_TYPES, l as DockerImageRef, E as EnvEntry, m as EnvParseResult, G as GitCommandConfig, n as GitCommandResult, o as GitOperation, p as GithubUrlInfo, q as GithubUrlType, r as GitignoreTestResult, s as GqlFormatResult, H as HtmlFormatResult, t as HtmlMinifyOptions, u as HtmlMinifyResult, J as JsMinifyOptions, v as JsMinifyResult, M as MIME_TABLE, w as MatchResult, x as MimeEntry, y as MimeLookupResult, O as OPERATIONS, P as ParsedSpec, R as RedosFinding, z as RedosResult, B as RedosSeverity, F as RegexError, I as RegexFlag, K as RegexMatch, L as RegexResult, N as RegexSuccess, S as SQL_DEFAULT_OPTIONS, Q as Segment, T as SpecVersion, U as SqlDialect, V as SqlFormatOptions, W as TestPatternResult, X as buildDockerPull, Y as buildDockerRun, Z as buildGitCommand, _ as collapseHtmlWhitespace, $ as collapseJsWhitespace, a0 as countProperties, a1 as countRules, a2 as detectDialect, a3 as detectOperationType, a4 as detectRedos, a5 as envToExport, a6 as envToJson, a7 as formatCss, a8 as formatGql, a9 as formatHtml, aa as formatSql, ab as getEndpointsByTag, ac as getHtmlStats, ad as getJsStats, ae as getMethodColor, af as isValidTag, ag as lintConventionalCommit, ah as lookupMime, ai as minifyCss, aj as minifyGql, ak as minifyHtml, al as minifyJs, am as minifySql, an as normalizeRef, ao as parseDockerImage, ap as parseEnv, aq as parseGitCommand, ar as parseGithubUrl, as as parseSpec, at as removeConsoleCalls, au as removeEmptyAttributes, av as removeHtmlComments, aw as removeJsComments, ax as removeRedundantAttributes, ay as searchCheatsheet, az as searchEndpoints, aA as splitStatements, aB as testGitignorePatterns, aC as testPattern, aD as testRegex, aE as validateEnvKey } from '../code-KXoRsHtl.cjs';
|
package/dist/tools/code.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as ALL_FLAGS, a as ApiEndpoint, b as ApiInfo, C as CHEATSHEET, d as CheatsheetEntry, e as ConventionalCommitFinding, f as ConventionalCommitFooter, g as ConventionalCommitOptions, h as ConventionalCommitParsed, i as ConventionalCommitResult, j as ConventionalCommitSeverity, k as CssResult, D as DEFAULT_COMMIT_TYPES, l as DockerImageRef, E as EnvEntry, m as EnvParseResult, G as GitCommandConfig, n as GitCommandResult, o as GitOperation, p as GithubUrlInfo, q as GithubUrlType, r as GqlFormatResult, H as HtmlFormatResult,
|
|
1
|
+
export { A as ALL_FLAGS, a as ApiEndpoint, b as ApiInfo, C as CHEATSHEET, d as CheatsheetEntry, e as ConventionalCommitFinding, f as ConventionalCommitFooter, g as ConventionalCommitOptions, h as ConventionalCommitParsed, i as ConventionalCommitResult, j as ConventionalCommitSeverity, k as CssResult, D as DEFAULT_COMMIT_TYPES, l as DockerImageRef, E as EnvEntry, m as EnvParseResult, G as GitCommandConfig, n as GitCommandResult, o as GitOperation, p as GithubUrlInfo, q as GithubUrlType, r as GitignoreTestResult, s as GqlFormatResult, H as HtmlFormatResult, t as HtmlMinifyOptions, u as HtmlMinifyResult, J as JsMinifyOptions, v as JsMinifyResult, M as MIME_TABLE, w as MatchResult, x as MimeEntry, y as MimeLookupResult, O as OPERATIONS, P as ParsedSpec, R as RedosFinding, z as RedosResult, B as RedosSeverity, F as RegexError, I as RegexFlag, K as RegexMatch, L as RegexResult, N as RegexSuccess, S as SQL_DEFAULT_OPTIONS, Q as Segment, T as SpecVersion, U as SqlDialect, V as SqlFormatOptions, W as TestPatternResult, X as buildDockerPull, Y as buildDockerRun, Z as buildGitCommand, _ as collapseHtmlWhitespace, $ as collapseJsWhitespace, a0 as countProperties, a1 as countRules, a2 as detectDialect, a3 as detectOperationType, a4 as detectRedos, a5 as envToExport, a6 as envToJson, a7 as formatCss, a8 as formatGql, a9 as formatHtml, aa as formatSql, ab as getEndpointsByTag, ac as getHtmlStats, ad as getJsStats, ae as getMethodColor, af as isValidTag, ag as lintConventionalCommit, ah as lookupMime, ai as minifyCss, aj as minifyGql, ak as minifyHtml, al as minifyJs, am as minifySql, an as normalizeRef, ao as parseDockerImage, ap as parseEnv, aq as parseGitCommand, ar as parseGithubUrl, as as parseSpec, at as removeConsoleCalls, au as removeEmptyAttributes, av as removeHtmlComments, aw as removeJsComments, ax as removeRedundantAttributes, ay as searchCheatsheet, az as searchEndpoints, aA as splitStatements, aB as testGitignorePatterns, aC as testPattern, aD as testRegex, aE as validateEnvKey } from '../code-KXoRsHtl.js';
|
package/dist/tools/code.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ALL_FLAGS, CHEATSHEET, DEFAULT_COMMIT_TYPES, MIME_TABLE, OPERATIONS, SQL_DEFAULT_OPTIONS, buildDockerPull, buildDockerRun, buildGitCommand, collapseHtmlWhitespace, collapseJsWhitespace, countProperties, countRules, detectDialect, detectOperationType, detectRedos, envToExport, envToJson, formatCss, formatGql, formatHtml, formatSql, getEndpointsByTag, getHtmlStats, getJsStats, getMethodColor, isValidTag, lintConventionalCommit, lookupMime, minifyCss, minifyGql, minifyHtml, minifyJs, minifySql, normalizeRef, parseDockerImage, parseEnv, parseGitCommand, parseGithubUrl, parseSpec, removeConsoleCalls, removeEmptyAttributes, removeHtmlComments, removeJsComments, removeRedundantAttributes, searchCheatsheet, searchEndpoints, splitStatements, testPattern, testRegex, validateEnvKey } from '../chunk-
|
|
1
|
+
export { ALL_FLAGS, CHEATSHEET, DEFAULT_COMMIT_TYPES, MIME_TABLE, OPERATIONS, SQL_DEFAULT_OPTIONS, buildDockerPull, buildDockerRun, buildGitCommand, collapseHtmlWhitespace, collapseJsWhitespace, countProperties, countRules, detectDialect, detectOperationType, detectRedos, envToExport, envToJson, formatCss, formatGql, formatHtml, formatSql, getEndpointsByTag, getHtmlStats, getJsStats, getMethodColor, isValidTag, lintConventionalCommit, lookupMime, minifyCss, minifyGql, minifyHtml, minifyJs, minifySql, normalizeRef, parseDockerImage, parseEnv, parseGitCommand, parseGithubUrl, parseSpec, removeConsoleCalls, removeEmptyAttributes, removeHtmlComments, removeJsComments, removeRedundantAttributes, searchCheatsheet, searchEndpoints, splitStatements, testGitignorePatterns, testPattern, testRegex, validateEnvKey } from '../chunk-JL7YTXRB.js';
|
|
2
2
|
import '../chunk-MLKGABMK.js';
|
package/dist/tools/network.cjs
CHANGED
|
@@ -2010,6 +2010,83 @@ function parseIpv6Address(input) {
|
|
|
2010
2010
|
addressType: classifyIpv6(expandedGroups)
|
|
2011
2011
|
};
|
|
2012
2012
|
}
|
|
2013
|
+
var MAX_COOKIE_AGE_SECONDS = 400 * 24 * 60 * 60;
|
|
2014
|
+
function checkSetCookieHeader(header) {
|
|
2015
|
+
if (typeof header !== "string" || !header.trim()) {
|
|
2016
|
+
return { error: "A Set-Cookie header value is required" };
|
|
2017
|
+
}
|
|
2018
|
+
const parts = header.split(";").map((p) => p.trim()).filter(Boolean);
|
|
2019
|
+
const [nameValue, ...attrParts] = parts;
|
|
2020
|
+
const eqIdx = nameValue.indexOf("=");
|
|
2021
|
+
if (eqIdx === -1) return { error: "Missing name=value pair" };
|
|
2022
|
+
const name = nameValue.slice(0, eqIdx).trim();
|
|
2023
|
+
const value = nameValue.slice(eqIdx + 1).trim();
|
|
2024
|
+
if (!name) return { error: "Cookie name cannot be empty" };
|
|
2025
|
+
const cookie = {
|
|
2026
|
+
name,
|
|
2027
|
+
value,
|
|
2028
|
+
domain: null,
|
|
2029
|
+
path: null,
|
|
2030
|
+
expires: null,
|
|
2031
|
+
maxAge: null,
|
|
2032
|
+
secure: false,
|
|
2033
|
+
httpOnly: false,
|
|
2034
|
+
sameSite: null
|
|
2035
|
+
};
|
|
2036
|
+
for (const attr of attrParts) {
|
|
2037
|
+
const idx = attr.indexOf("=");
|
|
2038
|
+
const key = (idx === -1 ? attr : attr.slice(0, idx)).trim().toLowerCase();
|
|
2039
|
+
const val = idx === -1 ? "" : attr.slice(idx + 1).trim();
|
|
2040
|
+
switch (key) {
|
|
2041
|
+
case "domain":
|
|
2042
|
+
cookie.domain = val || null;
|
|
2043
|
+
break;
|
|
2044
|
+
case "path":
|
|
2045
|
+
cookie.path = val || null;
|
|
2046
|
+
break;
|
|
2047
|
+
case "expires":
|
|
2048
|
+
cookie.expires = val || null;
|
|
2049
|
+
break;
|
|
2050
|
+
case "max-age": {
|
|
2051
|
+
const n = Number(val);
|
|
2052
|
+
cookie.maxAge = Number.isFinite(n) ? n : null;
|
|
2053
|
+
break;
|
|
2054
|
+
}
|
|
2055
|
+
case "secure":
|
|
2056
|
+
cookie.secure = true;
|
|
2057
|
+
break;
|
|
2058
|
+
case "httponly":
|
|
2059
|
+
cookie.httpOnly = true;
|
|
2060
|
+
break;
|
|
2061
|
+
case "samesite": {
|
|
2062
|
+
const normalized = val.toLowerCase();
|
|
2063
|
+
if (normalized === "strict") cookie.sameSite = "Strict";
|
|
2064
|
+
else if (normalized === "lax") cookie.sameSite = "Lax";
|
|
2065
|
+
else if (normalized === "none") cookie.sameSite = "None";
|
|
2066
|
+
break;
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
const issues = [];
|
|
2071
|
+
const warnings = [];
|
|
2072
|
+
if (cookie.sameSite === "None" && !cookie.secure) {
|
|
2073
|
+
issues.push("SameSite=None requires the Secure attribute \u2014 modern browsers reject this cookie without it.");
|
|
2074
|
+
}
|
|
2075
|
+
if (name.startsWith("__Host-")) {
|
|
2076
|
+
if (!cookie.secure) issues.push("__Host- prefixed cookies require the Secure attribute.");
|
|
2077
|
+
if (cookie.domain) issues.push("__Host- prefixed cookies must not set a Domain attribute.");
|
|
2078
|
+
if (cookie.path !== "/") issues.push("__Host- prefixed cookies must set Path=/.");
|
|
2079
|
+
} else if (name.startsWith("__Secure-")) {
|
|
2080
|
+
if (!cookie.secure) issues.push("__Secure- prefixed cookies require the Secure attribute.");
|
|
2081
|
+
}
|
|
2082
|
+
if (!cookie.secure) {
|
|
2083
|
+
warnings.push("Missing Secure attribute \u2014 the cookie can be sent over a plain HTTP connection.");
|
|
2084
|
+
}
|
|
2085
|
+
if (cookie.maxAge !== null && cookie.maxAge > MAX_COOKIE_AGE_SECONDS) {
|
|
2086
|
+
warnings.push(`Max-Age (${cookie.maxAge}s) exceeds 400 days \u2014 Chromium-based browsers clamp cookie expiry to 400 days from when it's set, so this will be shortened.`);
|
|
2087
|
+
}
|
|
2088
|
+
return { cookie, issues, warnings, valid: issues.length === 0 };
|
|
2089
|
+
}
|
|
2013
2090
|
|
|
2014
2091
|
exports.DNS_RECORD_TYPES = DNS_RECORD_TYPES;
|
|
2015
2092
|
exports.HTTP_HEADERS = HTTP_HEADERS;
|
|
@@ -2022,6 +2099,7 @@ exports.buildGeoUrl = buildGeoUrl;
|
|
|
2022
2099
|
exports.buildLinkHeader = buildLinkHeader;
|
|
2023
2100
|
exports.buildMapUrl = buildMapUrl;
|
|
2024
2101
|
exports.buildReferrerPolicy = buildReferrerPolicy;
|
|
2102
|
+
exports.checkSetCookieHeader = checkSetCookieHeader;
|
|
2025
2103
|
exports.countryCodeToFlag = countryCodeToFlag;
|
|
2026
2104
|
exports.formatCoordinates = formatCoordinates;
|
|
2027
2105
|
exports.formatTtl = formatTtl;
|
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,
|
|
1
|
+
export { C as CacheControlDirective, a as CacheControlOptions, b as CacheControlResult, c as CookieAttributes, d as CookieCheckResult, D as DNS_RECORD_TYPES, e as DnsRecord, f as DnsRecordType, g as DnsResponse, G as GeoResult, H as HTTP_HEADERS, h as HarEntry, i as HarParseResult, j as HarSummary, k as HeaderCategory, l as HttpHeader, I as Ipv6AddressType, m as Ipv6ParseResult, L as LINK_REL_VALUES, o as LinkHeaderEntry, p as LinkHeaderEntryInput, q as LinkHeaderResult, r as LinkRel, P as ParsedDnsResult, s as ParsedGeoResult, R as REFERRER_POLICY_VALUES, t as ReferrerPolicyEntry, u as ReferrerPolicyResult, v as ReferrerPolicyValue, w as RobotsGroup, x as RobotsIssue, y as RobotsRule, z as RobotsValidationResult, S as STATUS_CODES, A as SameSiteValue, B as SitemapIndexEntry, E as SitemapIssue, F as SitemapUrlEntry, J as SitemapValidationResult, K as StatusCode, U as UaDeviceType, M as UserAgentInfo, N as buildCacheControl, O as buildDnsQueryUrl, Q as buildGeoUrl, T as buildLinkHeader, V as buildMapUrl, W as buildReferrerPolicy, X as checkSetCookieHeader, Y as countryCodeToFlag, Z as formatCoordinates, _ as formatTtl, $ as getByCategory, a0 as getHeader, a1 as getHeadersByCategory, a2 as getStatusByCategory, a3 as getStatusCode, a4 as isClientError, a5 as isServerError, a6 as isSuccess, a7 as isValidIp, a8 as isValidIpv4, a9 as isValidIpv6, aa as parseDnsResponse, ab as parseGeoResponse, ac as parseHar, ad as parseIpv6Address, ae as parseUserAgent, af as searchHeaders, ag as searchStatusCodes, ah as statusCodeToText, ai as typeNumberToLabel, aj as validateDomain, ak as validateHeaderName, al as validateHeaderValue, am as validateRobotsTxt, an as validateSitemap } from '../network-CnKUQT4g.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,
|
|
1
|
+
export { C as CacheControlDirective, a as CacheControlOptions, b as CacheControlResult, c as CookieAttributes, d as CookieCheckResult, D as DNS_RECORD_TYPES, e as DnsRecord, f as DnsRecordType, g as DnsResponse, G as GeoResult, H as HTTP_HEADERS, h as HarEntry, i as HarParseResult, j as HarSummary, k as HeaderCategory, l as HttpHeader, I as Ipv6AddressType, m as Ipv6ParseResult, L as LINK_REL_VALUES, o as LinkHeaderEntry, p as LinkHeaderEntryInput, q as LinkHeaderResult, r as LinkRel, P as ParsedDnsResult, s as ParsedGeoResult, R as REFERRER_POLICY_VALUES, t as ReferrerPolicyEntry, u as ReferrerPolicyResult, v as ReferrerPolicyValue, w as RobotsGroup, x as RobotsIssue, y as RobotsRule, z as RobotsValidationResult, S as STATUS_CODES, A as SameSiteValue, B as SitemapIndexEntry, E as SitemapIssue, F as SitemapUrlEntry, J as SitemapValidationResult, K as StatusCode, U as UaDeviceType, M as UserAgentInfo, N as buildCacheControl, O as buildDnsQueryUrl, Q as buildGeoUrl, T as buildLinkHeader, V as buildMapUrl, W as buildReferrerPolicy, X as checkSetCookieHeader, Y as countryCodeToFlag, Z as formatCoordinates, _ as formatTtl, $ as getByCategory, a0 as getHeader, a1 as getHeadersByCategory, a2 as getStatusByCategory, a3 as getStatusCode, a4 as isClientError, a5 as isServerError, a6 as isSuccess, a7 as isValidIp, a8 as isValidIpv4, a9 as isValidIpv6, aa as parseDnsResponse, ab as parseGeoResponse, ac as parseHar, ad as parseIpv6Address, ae as parseUserAgent, af as searchHeaders, ag as searchStatusCodes, ah as statusCodeToText, ai as typeNumberToLabel, aj as validateDomain, ak as validateHeaderName, al as validateHeaderValue, am as validateRobotsTxt, an as validateSitemap } from '../network-CnKUQT4g.js';
|
package/dist/tools/network.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { DNS_RECORD_TYPES, HTTP_HEADERS, LINK_REL_VALUES, REFERRER_POLICY_VALUES, STATUS_CODES, buildCacheControl, buildDnsQueryUrl, buildGeoUrl, buildLinkHeader, buildMapUrl, buildReferrerPolicy, 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-
|
|
1
|
+
export { DNS_RECORD_TYPES, HTTP_HEADERS, LINK_REL_VALUES, REFERRER_POLICY_VALUES, STATUS_CODES, buildCacheControl, buildDnsQueryUrl, buildGeoUrl, buildLinkHeader, buildMapUrl, buildReferrerPolicy, checkSetCookieHeader, 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-DBNTO3YO.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.37.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",
|