@utilix-tech/sdk 0.3.1 → 0.5.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.
Files changed (37) hide show
  1. package/README.md +34 -12
  2. package/dist/{api-8aZtWhSj.d.cts → api-Xl7OzIgq.d.cts} +35 -2
  3. package/dist/{api-8aZtWhSj.d.ts → api-Xl7OzIgq.d.ts} +35 -2
  4. package/dist/{chunk-UC656APA.js → chunk-DNCOIO5N.js} +64 -1
  5. package/dist/{chunk-HFRTZE7T.js → chunk-Q3B3YWOA.js} +51 -1
  6. package/dist/{chunk-3BAHSW4C.js → chunk-V5JKVDBA.js} +60 -1
  7. package/dist/chunk-WWKPLYEP.js +277 -0
  8. package/dist/{data-rMjWNiOJ.d.cts → data-CakDxAcT.d.cts} +36 -2
  9. package/dist/{data-rMjWNiOJ.d.ts → data-CakDxAcT.d.ts} +36 -2
  10. package/dist/index.cjs +316 -1
  11. package/dist/index.d.cts +4 -4
  12. package/dist/index.d.ts +4 -4
  13. package/dist/index.js +4 -4
  14. package/dist/media-D-K5aZnq.d.cts +53 -0
  15. package/dist/media-D-K5aZnq.d.ts +53 -0
  16. package/dist/{network-CNtmrDeN.d.cts → network-DwyAjwJS.d.cts} +39 -2
  17. package/dist/{network-CNtmrDeN.d.ts → network-DwyAjwJS.d.ts} +39 -2
  18. package/dist/tools/api.cjs +50 -0
  19. package/dist/tools/api.d.cts +1 -1
  20. package/dist/tools/api.d.ts +1 -1
  21. package/dist/tools/api.js +1 -1
  22. package/dist/tools/data.cjs +63 -0
  23. package/dist/tools/data.d.cts +1 -1
  24. package/dist/tools/data.d.ts +1 -1
  25. package/dist/tools/data.js +1 -1
  26. package/dist/tools/media.cjs +143 -0
  27. package/dist/tools/media.d.cts +1 -1
  28. package/dist/tools/media.d.ts +1 -1
  29. package/dist/tools/media.js +1 -1
  30. package/dist/tools/network.cjs +59 -0
  31. package/dist/tools/network.d.cts +1 -1
  32. package/dist/tools/network.d.ts +1 -1
  33. package/dist/tools/network.js +1 -1
  34. package/package.json +1 -1
  35. package/dist/chunk-N7C52YGL.js +0 -134
  36. package/dist/media-DF2cx3pK.d.cts +0 -28
  37. package/dist/media-DF2cx3pK.d.ts +0 -28
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @utilix-tech/sdk
2
2
 
3
- **140+ developer utility functions for Node.js: runs locally, no API key required.**
3
+ **523 developer utility functions for Node.js: runs locally, no API key required.**
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@utilix-tech/sdk?style=flat-square&color=cb3837)](https://www.npmjs.com/package/@utilix-tech/sdk)
6
6
  [![npm downloads](https://img.shields.io/npm/dm/@utilix-tech/sdk?style=flat-square)](https://www.npmjs.com/package/@utilix-tech/sdk)
@@ -152,11 +152,12 @@ detectPassiveVoice("The report was reviewed by the committee. They approved it."
152
152
 
153
153
  ---
154
154
 
155
- ### `/data`: CSV / YAML / TOML / XML / INI
155
+ ### `/data`: CSV / YAML / TOML / XML / INI / NDJSON
156
156
 
157
157
  ```ts
158
158
  import { parseCsv, csvToJson, validateYaml, tomlToJson, jsonToToml,
159
- formatXml, xmlToJson, jsonToXml, parseIni } from "@utilix-tech/sdk/data";
159
+ formatXml, xmlToJson, jsonToXml, parseIni,
160
+ validateNdjson, formatNdjson, ndjsonToJsonArray } from "@utilix-tech/sdk/data";
160
161
 
161
162
  // CSV
162
163
  const rows = parseCsv("name,age\nalice,30\nbob,25");
@@ -175,6 +176,11 @@ xmlToJson("<root><item>hello</item></root>");
175
176
 
176
177
  // INI
177
178
  parseIni("[db]\nhost=localhost\nport=5432");
179
+
180
+ // NDJSON (JSON Lines): one JSON value per line
181
+ validateNdjson('{"id":1}\n{"id":2}'); // { valid: true, totalLines: 2, ... }
182
+ formatNdjson('{"id":1}'); // '{\n "id": 1\n}'
183
+ ndjsonToJsonArray('{"id":1}\n{"id":2}'); // '[\n { "id": 1 },\n { "id": 2 }\n]'
178
184
  ```
179
185
 
180
186
  ---
@@ -250,11 +256,12 @@ formatValue(1234567.89, { locale: "en-US", currency: "USD" });
250
256
 
251
257
  ---
252
258
 
253
- ### `/network`: URLs, IPs, HTTP
259
+ ### `/network`: URLs, IPs, HTTP, HAR
254
260
 
255
261
  ```ts
256
262
  import { getStatusCode, isValidIp, isValidIpv4, isValidIpv6,
257
- searchStatusCodes, buildGeoUrl, countryCodeToFlag } from "@utilix-tech/sdk/network";
263
+ searchStatusCodes, buildGeoUrl, countryCodeToFlag,
264
+ parseHar } from "@utilix-tech/sdk/network";
258
265
 
259
266
  getStatusCode(404);
260
267
  // { code: 404, text: "Not Found", description: "...", category: "Client Error" }
@@ -266,6 +273,11 @@ isValidIpv6("::1"); // true
266
273
  isValidIp("256.0.0.1"); // false
267
274
 
268
275
  countryCodeToFlag("US"); // "🇺🇸"
276
+
277
+ // Parse a DevTools .har network export into entries + summary stats
278
+ const har = await fs.promises.readFile("network.har", "utf-8");
279
+ parseHar(har);
280
+ // { version: "1.2", entries: [...], summary: { totalRequests, totalSize, failedRequests, ... } }
269
281
  ```
270
282
 
271
283
  ---
@@ -273,7 +285,7 @@ countryCodeToFlag("US"); // "🇺🇸"
273
285
  ### `/api`: cURL, JWT, CORS, HTTP
274
286
 
275
287
  ```ts
276
- import { buildCurl, parseCurlCommand, decodeJwt, signJwt,
288
+ import { buildCurl, parseCurlCommand, decodeJwt, signJwt, parseJwks,
277
289
  generateCors, generateCspHeader } from "@utilix-tech/sdk/api";
278
290
 
279
291
  buildCurl({
@@ -293,6 +305,10 @@ parseCurlCommand('curl -X GET https://api.example.com -H "Authorization: Bearer
293
305
  decodeJwt("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...");
294
306
  // { header: {...}, payload: {...}, isExpired: false, expiresIn: "2h" }
295
307
 
308
+ // JWKS: parse a key set (or a single bare JWK) — inspection only, no verification
309
+ parseJwks('{"keys":[{"kty":"RSA","use":"sig","kid":"1","n":"...","e":"AQAB"}]}');
310
+ // { ok: true, keys: [{ kty: "RSA", kid: "1", keySize: 2048, ... }], count: 1, duplicateKids: [] }
311
+
296
312
  // Generate CORS headers
297
313
  generateCors({ origins: ["https://myapp.com"], methods: ["GET", "POST"] });
298
314
 
@@ -400,16 +416,22 @@ analyzeString("café"); // { length: 4, codePoints: [...], ... }
400
416
 
401
417
  ---
402
418
 
403
- ### `/media`: Image Header Parsing
419
+ ### `/media`: Image Header Parsing & PDF Metadata
404
420
 
405
421
  ```ts
406
- import { readImageInfo } from "@utilix-tech/sdk/media";
422
+ import { readImageInfo, readPdfMetadata } from "@utilix-tech/sdk/media";
407
423
 
408
424
  // Reads format, dimensions, bit depth, and alpha channel straight from
409
425
  // file bytes: no decoding, no canvas, no image library.
410
426
  const bytes = await fs.promises.readFile("photo.png");
411
427
  readImageInfo(new Uint8Array(bytes));
412
428
  // { format: "png", width: 1920, height: 1080, bitDepth: 8, colorType: "rgba", hasAlpha: true }
429
+
430
+ // Reads title, author, dates, page count, and encryption flag from a PDF's
431
+ // trailer/Info dictionary: no pdf.js or other PDF library required.
432
+ const pdfBytes = await fs.promises.readFile("report.pdf");
433
+ readPdfMetadata(new Uint8Array(pdfBytes));
434
+ // { version: "1.7", pageCount: 12, title: "Q3 Report", author: "Jane Doe", ... }
413
435
  ```
414
436
 
415
437
  Supports PNG, JPEG, GIF, WebP, and BMP.
@@ -424,18 +446,18 @@ Supports PNG, JPEG, GIF, WebP, and BMP.
424
446
  | `@utilix-tech/sdk/encoding` | Base64, URL, HTML entities, Base32 encode/decode |
425
447
  | `@utilix-tech/sdk/hashing` | MD5, SHA-1/256/512, bcrypt, HMAC, .htpasswd |
426
448
  | `@utilix-tech/sdk/text` | Case convert, slugify, word count, lorem ipsum, line ops, HTML→Markdown |
427
- | `@utilix-tech/sdk/data` | CSV, YAML, TOML, XML, INI parse and convert |
449
+ | `@utilix-tech/sdk/data` | CSV, YAML, TOML, XML, INI, NDJSON parse and convert |
428
450
  | `@utilix-tech/sdk/generators` | UUID v4/v7, ULID, passwords, strength check, fake data |
429
451
  | `@utilix-tech/sdk/time` | Date diff, timezone convert, cron parse, relative time |
430
452
  | `@utilix-tech/sdk/units` | Bytes, CSS px/rem, number bases, currency format |
431
- | `@utilix-tech/sdk/network` | HTTP status codes, IP validation, country flags, geolocation URLs |
432
- | `@utilix-tech/sdk/api` | cURL build/parse, JWT decode/sign, CORS headers, CSP header |
453
+ | `@utilix-tech/sdk/network` | HTTP status codes, IP validation, country flags, geolocation URLs, HAR file parsing |
454
+ | `@utilix-tech/sdk/api` | cURL build/parse, JWT decode/sign, JWKS parse, CORS headers, CSP header |
433
455
  | `@utilix-tech/sdk/code` | SQL format/minify, HTML format/minify, regex tester, GraphQL format |
434
456
  | `@utilix-tech/sdk/color` | Hex/RGB/HSL/HSV/CMYK convert, palette generation, contrast check |
435
457
  | `@utilix-tech/sdk/css` | CSS gradient, box-shadow, border-radius, keyframe animation generators |
436
458
  | `@utilix-tech/sdk/misc` | SVG optimize/sanitize, file size format, Unicode inspector |
437
459
  | `@utilix-tech/sdk/ai_agent` | Token estimate/trim, chunk text, extract URLs/JSON/keywords, sanitize HTML, flatten/merge JSON, dedupe lines, validate schema, PII/secret/injection detect |
438
- | `@utilix-tech/sdk/media` | Image format & dimension reading from raw bytes: PNG, JPEG, GIF, WebP, BMP |
460
+ | `@utilix-tech/sdk/media` | Image format & dimension reading from raw bytes (PNG, JPEG, GIF, WebP, BMP); PDF metadata reading |
439
461
 
440
462
  ---
441
463
 
@@ -4,6 +4,7 @@
4
4
  * - curl-builder : buildCurl, buildCurlMultiline, parseCurl
5
5
  * - curl-to-code : parseCurlCommand, convertToCode
6
6
  * - jwt-decoder : decodeJwt, formatJwtJson
7
+ * - jwk-viewer : parseJwks
7
8
  * - jwt-signer : base64urlEncode, base64urlDecode, signJwt
8
9
  * - cors-builder : validateCorsConfig, generateCors
9
10
  * - csp-builder : generateCspHeader, generateFullHeader, parseCspHeader, validateCspConfig
@@ -78,6 +79,33 @@ interface JwtDecodeError {
78
79
  type JwtResult = JwtDecodeResult | JwtDecodeError;
79
80
  declare function decodeJwt(token: string): JwtResult;
80
81
  declare function formatJwtJson(obj: Record<string, unknown>): string;
82
+ interface JwkSummary {
83
+ kty: string;
84
+ use?: string;
85
+ keyOps?: string[];
86
+ alg?: string;
87
+ kid?: string;
88
+ keySize: number | null;
89
+ curve?: string;
90
+ raw: Record<string, unknown>;
91
+ }
92
+ interface JwksResult {
93
+ ok: true;
94
+ keys: JwkSummary[];
95
+ count: number;
96
+ duplicateKids: string[];
97
+ }
98
+ interface JwksError {
99
+ ok: false;
100
+ error: string;
101
+ }
102
+ type JwksParseResult = JwksResult | JwksError;
103
+ /**
104
+ * Parse a JSON Web Key Set (or a single bare JWK) and summarize each key's
105
+ * type, use, algorithm, key ID, and approximate size. Does not verify or
106
+ * use the keys cryptographically: this is inspection only.
107
+ */
108
+ declare function parseJwks(input: string): JwksParseResult;
81
109
  type JwtAlgorithm = 'HS256' | 'HS384' | 'HS512';
82
110
  interface JwtSignOptions {
83
111
  algorithm?: JwtAlgorithm;
@@ -255,6 +283,10 @@ type api_FormatResult = FormatResult;
255
283
  declare const api_HTTP_METHODS: typeof HTTP_METHODS;
256
284
  type api_Header = Header;
257
285
  type api_HttpMethod = HttpMethod;
286
+ type api_JwkSummary = JwkSummary;
287
+ type api_JwksError = JwksError;
288
+ type api_JwksParseResult = JwksParseResult;
289
+ type api_JwksResult = JwksResult;
258
290
  type api_JwtAlgorithm = JwtAlgorithm;
259
291
  type api_JwtDecodeError = JwtDecodeError;
260
292
  type api_JwtDecodeResult = JwtDecodeResult;
@@ -294,6 +326,7 @@ declare const api_normalizeUrl: typeof normalizeUrl;
294
326
  declare const api_parseCspHeader: typeof parseCspHeader;
295
327
  declare const api_parseCurl: typeof parseCurl;
296
328
  declare const api_parseCurlCommand: typeof parseCurlCommand;
329
+ declare const api_parseJwks: typeof parseJwks;
297
330
  declare const api_parseMetaTags: typeof parseMetaTags;
298
331
  declare const api_parseUrl: typeof parseUrl;
299
332
  declare const api_removeParam: typeof removeParam;
@@ -302,7 +335,7 @@ declare const api_validateCorsConfig: typeof validateCorsConfig;
302
335
  declare const api_validateCspConfig: typeof validateCspConfig;
303
336
  declare const api_validateOgTags: typeof validateOgTags;
304
337
  declare namespace api {
305
- export { api_COMMON_HEADERS as COMMON_HEADERS, api_COMMON_PRESETS as COMMON_PRESETS, api_CORS_COMMON_HEADERS as CORS_COMMON_HEADERS, type api_CorsConfig as CorsConfig, type api_CorsOutput as CorsOutput, type api_CspConfig as CspConfig, type api_CspDirective as CspDirective, type api_CspSource as CspSource, type api_CurlCommand as CurlCommand, type api_CurlConfig as CurlConfig, api_DEFAULT_CORS_CONFIG as DEFAULT_CORS_CONFIG, api_DIRECTIVE_DESCRIPTIONS as DIRECTIVE_DESCRIPTIONS, type api_DirectiveConfig as DirectiveConfig, type api_FormatResult as FormatResult, api_HTTP_METHODS as HTTP_METHODS, type api_Header as Header, type api_HttpMethod as HttpMethod, type api_JwtAlgorithm as JwtAlgorithm, type api_JwtDecodeError as JwtDecodeError, type api_JwtDecodeResult as JwtDecodeResult, type api_JwtExpiry as JwtExpiry, type api_JwtPart as JwtPart, type api_JwtResult as JwtResult, type api_JwtSignOptions as JwtSignOptions, type api_MetaTags as MetaTags, type api_OgTags as OgTags, type api_ParsedUrl as ParsedUrl, type api_ResponseFormat as ResponseFormat, api_SUPPORTED_LANGUAGES as SUPPORTED_LANGUAGES, type api_TargetLanguage as TargetLanguage, type api_TwitterTags as TwitterTags, api_addParam as addParam, api_base64urlDecode as base64urlDecode, api_base64urlEncode as base64urlEncode, api_buildCurl as buildCurl, api_buildCurlMultiline as buildCurlMultiline, api_buildUrl as buildUrl, api_convertToCode as convertToCode, api_decodeJwt as decodeJwt, api_decodeUrlComponent as decodeUrlComponent, api_detectFormat as detectFormat, api_encodeUrlComponent as encodeUrlComponent, api_extractJsonPaths as extractJsonPaths, api_formatJwtJson as formatJwtJson, api_formatResponse as formatResponse, api_generateCors as generateCors, api_generateCspHeader as generateCspHeader, api_generateFullHeader as generateFullHeader, api_generateMetaHtml as generateMetaHtml, api_getParam as getParam, api_getStats as getStats, api_isValidUrl as isValidUrl, api_normalizeUrl as normalizeUrl, api_parseCspHeader as parseCspHeader, api_parseCurl as parseCurl, api_parseCurlCommand as parseCurlCommand, api_parseMetaTags as parseMetaTags, api_parseUrl as parseUrl, api_removeParam as removeParam, api_signJwt as signJwt, api_validateCorsConfig as validateCorsConfig, api_validateCspConfig as validateCspConfig, api_validateOgTags as validateOgTags };
338
+ export { api_COMMON_HEADERS as COMMON_HEADERS, api_COMMON_PRESETS as COMMON_PRESETS, api_CORS_COMMON_HEADERS as CORS_COMMON_HEADERS, type api_CorsConfig as CorsConfig, type api_CorsOutput as CorsOutput, type api_CspConfig as CspConfig, type api_CspDirective as CspDirective, type api_CspSource as CspSource, type api_CurlCommand as CurlCommand, type api_CurlConfig as CurlConfig, api_DEFAULT_CORS_CONFIG as DEFAULT_CORS_CONFIG, api_DIRECTIVE_DESCRIPTIONS as DIRECTIVE_DESCRIPTIONS, type api_DirectiveConfig as DirectiveConfig, type api_FormatResult as FormatResult, api_HTTP_METHODS as HTTP_METHODS, type api_Header as Header, type api_HttpMethod as HttpMethod, type api_JwkSummary as JwkSummary, type api_JwksError as JwksError, type api_JwksParseResult as JwksParseResult, type api_JwksResult as JwksResult, type api_JwtAlgorithm as JwtAlgorithm, type api_JwtDecodeError as JwtDecodeError, type api_JwtDecodeResult as JwtDecodeResult, type api_JwtExpiry as JwtExpiry, type api_JwtPart as JwtPart, type api_JwtResult as JwtResult, type api_JwtSignOptions as JwtSignOptions, type api_MetaTags as MetaTags, type api_OgTags as OgTags, type api_ParsedUrl as ParsedUrl, type api_ResponseFormat as ResponseFormat, api_SUPPORTED_LANGUAGES as SUPPORTED_LANGUAGES, type api_TargetLanguage as TargetLanguage, type api_TwitterTags as TwitterTags, api_addParam as addParam, api_base64urlDecode as base64urlDecode, api_base64urlEncode as base64urlEncode, api_buildCurl as buildCurl, api_buildCurlMultiline as buildCurlMultiline, api_buildUrl as buildUrl, api_convertToCode as convertToCode, api_decodeJwt as decodeJwt, api_decodeUrlComponent as decodeUrlComponent, api_detectFormat as detectFormat, api_encodeUrlComponent as encodeUrlComponent, api_extractJsonPaths as extractJsonPaths, api_formatJwtJson as formatJwtJson, api_formatResponse as formatResponse, api_generateCors as generateCors, api_generateCspHeader as generateCspHeader, api_generateFullHeader as generateFullHeader, api_generateMetaHtml as generateMetaHtml, api_getParam as getParam, api_getStats as getStats, api_isValidUrl as isValidUrl, api_normalizeUrl as normalizeUrl, api_parseCspHeader as parseCspHeader, api_parseCurl as parseCurl, api_parseCurlCommand as parseCurlCommand, api_parseJwks as parseJwks, api_parseMetaTags as parseMetaTags, api_parseUrl as parseUrl, api_removeParam as removeParam, api_signJwt as signJwt, api_validateCorsConfig as validateCorsConfig, api_validateCspConfig as validateCspConfig, api_validateOgTags as validateOgTags };
306
339
  }
307
340
 
308
- export { normalizeUrl as $, buildUrl as A, convertToCode as B, COMMON_HEADERS as C, DEFAULT_CORS_CONFIG as D, decodeJwt as E, type FormatResult as F, decodeUrlComponent as G, HTTP_METHODS as H, detectFormat as I, type JwtAlgorithm as J, encodeUrlComponent as K, extractJsonPaths as L, type MetaTags as M, formatJwtJson as N, type OgTags as O, type ParsedUrl as P, formatResponse as Q, type ResponseFormat as R, SUPPORTED_LANGUAGES as S, type TargetLanguage as T, generateCors as U, generateCspHeader as V, generateFullHeader as W, generateMetaHtml as X, getParam as Y, getStats as Z, isValidUrl as _, api as a, parseCspHeader as a0, parseCurl as a1, parseCurlCommand as a2, parseMetaTags as a3, parseUrl as a4, removeParam as a5, signJwt as a6, validateCorsConfig as a7, validateCspConfig as a8, validateOgTags as a9, COMMON_PRESETS as b, CORS_COMMON_HEADERS as c, type CorsConfig as d, type CorsOutput as e, type CspConfig as f, type CspDirective as g, type CspSource as h, type CurlCommand as i, type CurlConfig as j, DIRECTIVE_DESCRIPTIONS as k, type DirectiveConfig as l, type Header as m, type HttpMethod as n, type JwtDecodeError as o, type JwtDecodeResult as p, type JwtExpiry as q, type JwtPart as r, type JwtResult as s, type JwtSignOptions as t, type TwitterTags as u, addParam as v, base64urlDecode as w, base64urlEncode as x, buildCurl as y, buildCurlMultiline as z };
341
+ export { generateMetaHtml as $, base64urlDecode as A, base64urlEncode as B, COMMON_HEADERS as C, DEFAULT_CORS_CONFIG as D, buildCurl as E, type FormatResult as F, buildCurlMultiline as G, HTTP_METHODS as H, buildUrl as I, type JwkSummary as J, convertToCode as K, decodeJwt as L, type MetaTags as M, decodeUrlComponent as N, type OgTags as O, type ParsedUrl as P, detectFormat as Q, type ResponseFormat as R, SUPPORTED_LANGUAGES as S, type TargetLanguage as T, encodeUrlComponent as U, extractJsonPaths as V, formatJwtJson as W, formatResponse as X, generateCors as Y, generateCspHeader as Z, generateFullHeader as _, api as a, getParam as a0, getStats as a1, isValidUrl as a2, normalizeUrl as a3, parseCspHeader as a4, parseCurl as a5, parseCurlCommand as a6, parseJwks as a7, parseMetaTags as a8, parseUrl as a9, removeParam as aa, signJwt as ab, validateCorsConfig as ac, validateCspConfig as ad, validateOgTags as ae, COMMON_PRESETS as b, CORS_COMMON_HEADERS as c, type CorsConfig as d, type CorsOutput as e, type CspConfig as f, type CspDirective as g, type CspSource as h, type CurlCommand as i, type CurlConfig as j, DIRECTIVE_DESCRIPTIONS as k, type DirectiveConfig as l, type Header as m, type HttpMethod as n, type JwksError as o, type JwksParseResult as p, type JwksResult as q, type JwtAlgorithm as r, type JwtDecodeError as s, type JwtDecodeResult as t, type JwtExpiry as u, type JwtPart as v, type JwtResult as w, type JwtSignOptions as x, type TwitterTags as y, addParam as z };
@@ -4,6 +4,7 @@
4
4
  * - curl-builder : buildCurl, buildCurlMultiline, parseCurl
5
5
  * - curl-to-code : parseCurlCommand, convertToCode
6
6
  * - jwt-decoder : decodeJwt, formatJwtJson
7
+ * - jwk-viewer : parseJwks
7
8
  * - jwt-signer : base64urlEncode, base64urlDecode, signJwt
8
9
  * - cors-builder : validateCorsConfig, generateCors
9
10
  * - csp-builder : generateCspHeader, generateFullHeader, parseCspHeader, validateCspConfig
@@ -78,6 +79,33 @@ interface JwtDecodeError {
78
79
  type JwtResult = JwtDecodeResult | JwtDecodeError;
79
80
  declare function decodeJwt(token: string): JwtResult;
80
81
  declare function formatJwtJson(obj: Record<string, unknown>): string;
82
+ interface JwkSummary {
83
+ kty: string;
84
+ use?: string;
85
+ keyOps?: string[];
86
+ alg?: string;
87
+ kid?: string;
88
+ keySize: number | null;
89
+ curve?: string;
90
+ raw: Record<string, unknown>;
91
+ }
92
+ interface JwksResult {
93
+ ok: true;
94
+ keys: JwkSummary[];
95
+ count: number;
96
+ duplicateKids: string[];
97
+ }
98
+ interface JwksError {
99
+ ok: false;
100
+ error: string;
101
+ }
102
+ type JwksParseResult = JwksResult | JwksError;
103
+ /**
104
+ * Parse a JSON Web Key Set (or a single bare JWK) and summarize each key's
105
+ * type, use, algorithm, key ID, and approximate size. Does not verify or
106
+ * use the keys cryptographically: this is inspection only.
107
+ */
108
+ declare function parseJwks(input: string): JwksParseResult;
81
109
  type JwtAlgorithm = 'HS256' | 'HS384' | 'HS512';
82
110
  interface JwtSignOptions {
83
111
  algorithm?: JwtAlgorithm;
@@ -255,6 +283,10 @@ type api_FormatResult = FormatResult;
255
283
  declare const api_HTTP_METHODS: typeof HTTP_METHODS;
256
284
  type api_Header = Header;
257
285
  type api_HttpMethod = HttpMethod;
286
+ type api_JwkSummary = JwkSummary;
287
+ type api_JwksError = JwksError;
288
+ type api_JwksParseResult = JwksParseResult;
289
+ type api_JwksResult = JwksResult;
258
290
  type api_JwtAlgorithm = JwtAlgorithm;
259
291
  type api_JwtDecodeError = JwtDecodeError;
260
292
  type api_JwtDecodeResult = JwtDecodeResult;
@@ -294,6 +326,7 @@ declare const api_normalizeUrl: typeof normalizeUrl;
294
326
  declare const api_parseCspHeader: typeof parseCspHeader;
295
327
  declare const api_parseCurl: typeof parseCurl;
296
328
  declare const api_parseCurlCommand: typeof parseCurlCommand;
329
+ declare const api_parseJwks: typeof parseJwks;
297
330
  declare const api_parseMetaTags: typeof parseMetaTags;
298
331
  declare const api_parseUrl: typeof parseUrl;
299
332
  declare const api_removeParam: typeof removeParam;
@@ -302,7 +335,7 @@ declare const api_validateCorsConfig: typeof validateCorsConfig;
302
335
  declare const api_validateCspConfig: typeof validateCspConfig;
303
336
  declare const api_validateOgTags: typeof validateOgTags;
304
337
  declare namespace api {
305
- export { api_COMMON_HEADERS as COMMON_HEADERS, api_COMMON_PRESETS as COMMON_PRESETS, api_CORS_COMMON_HEADERS as CORS_COMMON_HEADERS, type api_CorsConfig as CorsConfig, type api_CorsOutput as CorsOutput, type api_CspConfig as CspConfig, type api_CspDirective as CspDirective, type api_CspSource as CspSource, type api_CurlCommand as CurlCommand, type api_CurlConfig as CurlConfig, api_DEFAULT_CORS_CONFIG as DEFAULT_CORS_CONFIG, api_DIRECTIVE_DESCRIPTIONS as DIRECTIVE_DESCRIPTIONS, type api_DirectiveConfig as DirectiveConfig, type api_FormatResult as FormatResult, api_HTTP_METHODS as HTTP_METHODS, type api_Header as Header, type api_HttpMethod as HttpMethod, type api_JwtAlgorithm as JwtAlgorithm, type api_JwtDecodeError as JwtDecodeError, type api_JwtDecodeResult as JwtDecodeResult, type api_JwtExpiry as JwtExpiry, type api_JwtPart as JwtPart, type api_JwtResult as JwtResult, type api_JwtSignOptions as JwtSignOptions, type api_MetaTags as MetaTags, type api_OgTags as OgTags, type api_ParsedUrl as ParsedUrl, type api_ResponseFormat as ResponseFormat, api_SUPPORTED_LANGUAGES as SUPPORTED_LANGUAGES, type api_TargetLanguage as TargetLanguage, type api_TwitterTags as TwitterTags, api_addParam as addParam, api_base64urlDecode as base64urlDecode, api_base64urlEncode as base64urlEncode, api_buildCurl as buildCurl, api_buildCurlMultiline as buildCurlMultiline, api_buildUrl as buildUrl, api_convertToCode as convertToCode, api_decodeJwt as decodeJwt, api_decodeUrlComponent as decodeUrlComponent, api_detectFormat as detectFormat, api_encodeUrlComponent as encodeUrlComponent, api_extractJsonPaths as extractJsonPaths, api_formatJwtJson as formatJwtJson, api_formatResponse as formatResponse, api_generateCors as generateCors, api_generateCspHeader as generateCspHeader, api_generateFullHeader as generateFullHeader, api_generateMetaHtml as generateMetaHtml, api_getParam as getParam, api_getStats as getStats, api_isValidUrl as isValidUrl, api_normalizeUrl as normalizeUrl, api_parseCspHeader as parseCspHeader, api_parseCurl as parseCurl, api_parseCurlCommand as parseCurlCommand, api_parseMetaTags as parseMetaTags, api_parseUrl as parseUrl, api_removeParam as removeParam, api_signJwt as signJwt, api_validateCorsConfig as validateCorsConfig, api_validateCspConfig as validateCspConfig, api_validateOgTags as validateOgTags };
338
+ export { api_COMMON_HEADERS as COMMON_HEADERS, api_COMMON_PRESETS as COMMON_PRESETS, api_CORS_COMMON_HEADERS as CORS_COMMON_HEADERS, type api_CorsConfig as CorsConfig, type api_CorsOutput as CorsOutput, type api_CspConfig as CspConfig, type api_CspDirective as CspDirective, type api_CspSource as CspSource, type api_CurlCommand as CurlCommand, type api_CurlConfig as CurlConfig, api_DEFAULT_CORS_CONFIG as DEFAULT_CORS_CONFIG, api_DIRECTIVE_DESCRIPTIONS as DIRECTIVE_DESCRIPTIONS, type api_DirectiveConfig as DirectiveConfig, type api_FormatResult as FormatResult, api_HTTP_METHODS as HTTP_METHODS, type api_Header as Header, type api_HttpMethod as HttpMethod, type api_JwkSummary as JwkSummary, type api_JwksError as JwksError, type api_JwksParseResult as JwksParseResult, type api_JwksResult as JwksResult, type api_JwtAlgorithm as JwtAlgorithm, type api_JwtDecodeError as JwtDecodeError, type api_JwtDecodeResult as JwtDecodeResult, type api_JwtExpiry as JwtExpiry, type api_JwtPart as JwtPart, type api_JwtResult as JwtResult, type api_JwtSignOptions as JwtSignOptions, type api_MetaTags as MetaTags, type api_OgTags as OgTags, type api_ParsedUrl as ParsedUrl, type api_ResponseFormat as ResponseFormat, api_SUPPORTED_LANGUAGES as SUPPORTED_LANGUAGES, type api_TargetLanguage as TargetLanguage, type api_TwitterTags as TwitterTags, api_addParam as addParam, api_base64urlDecode as base64urlDecode, api_base64urlEncode as base64urlEncode, api_buildCurl as buildCurl, api_buildCurlMultiline as buildCurlMultiline, api_buildUrl as buildUrl, api_convertToCode as convertToCode, api_decodeJwt as decodeJwt, api_decodeUrlComponent as decodeUrlComponent, api_detectFormat as detectFormat, api_encodeUrlComponent as encodeUrlComponent, api_extractJsonPaths as extractJsonPaths, api_formatJwtJson as formatJwtJson, api_formatResponse as formatResponse, api_generateCors as generateCors, api_generateCspHeader as generateCspHeader, api_generateFullHeader as generateFullHeader, api_generateMetaHtml as generateMetaHtml, api_getParam as getParam, api_getStats as getStats, api_isValidUrl as isValidUrl, api_normalizeUrl as normalizeUrl, api_parseCspHeader as parseCspHeader, api_parseCurl as parseCurl, api_parseCurlCommand as parseCurlCommand, api_parseJwks as parseJwks, api_parseMetaTags as parseMetaTags, api_parseUrl as parseUrl, api_removeParam as removeParam, api_signJwt as signJwt, api_validateCorsConfig as validateCorsConfig, api_validateCspConfig as validateCspConfig, api_validateOgTags as validateOgTags };
306
339
  }
307
340
 
308
- export { normalizeUrl as $, buildUrl as A, convertToCode as B, COMMON_HEADERS as C, DEFAULT_CORS_CONFIG as D, decodeJwt as E, type FormatResult as F, decodeUrlComponent as G, HTTP_METHODS as H, detectFormat as I, type JwtAlgorithm as J, encodeUrlComponent as K, extractJsonPaths as L, type MetaTags as M, formatJwtJson as N, type OgTags as O, type ParsedUrl as P, formatResponse as Q, type ResponseFormat as R, SUPPORTED_LANGUAGES as S, type TargetLanguage as T, generateCors as U, generateCspHeader as V, generateFullHeader as W, generateMetaHtml as X, getParam as Y, getStats as Z, isValidUrl as _, api as a, parseCspHeader as a0, parseCurl as a1, parseCurlCommand as a2, parseMetaTags as a3, parseUrl as a4, removeParam as a5, signJwt as a6, validateCorsConfig as a7, validateCspConfig as a8, validateOgTags as a9, COMMON_PRESETS as b, CORS_COMMON_HEADERS as c, type CorsConfig as d, type CorsOutput as e, type CspConfig as f, type CspDirective as g, type CspSource as h, type CurlCommand as i, type CurlConfig as j, DIRECTIVE_DESCRIPTIONS as k, type DirectiveConfig as l, type Header as m, type HttpMethod as n, type JwtDecodeError as o, type JwtDecodeResult as p, type JwtExpiry as q, type JwtPart as r, type JwtResult as s, type JwtSignOptions as t, type TwitterTags as u, addParam as v, base64urlDecode as w, base64urlEncode as x, buildCurl as y, buildCurlMultiline as z };
341
+ export { generateMetaHtml as $, base64urlDecode as A, base64urlEncode as B, COMMON_HEADERS as C, DEFAULT_CORS_CONFIG as D, buildCurl as E, type FormatResult as F, buildCurlMultiline as G, HTTP_METHODS as H, buildUrl as I, type JwkSummary as J, convertToCode as K, decodeJwt as L, type MetaTags as M, decodeUrlComponent as N, type OgTags as O, type ParsedUrl as P, detectFormat as Q, type ResponseFormat as R, SUPPORTED_LANGUAGES as S, type TargetLanguage as T, encodeUrlComponent as U, extractJsonPaths as V, formatJwtJson as W, formatResponse as X, generateCors as Y, generateCspHeader as Z, generateFullHeader as _, api as a, getParam as a0, getStats as a1, isValidUrl as a2, normalizeUrl as a3, parseCspHeader as a4, parseCurl as a5, parseCurlCommand as a6, parseJwks as a7, parseMetaTags as a8, parseUrl as a9, removeParam as aa, signJwt as ab, validateCorsConfig as ac, validateCspConfig as ad, validateOgTags as ae, COMMON_PRESETS as b, CORS_COMMON_HEADERS as c, type CorsConfig as d, type CorsOutput as e, type CspConfig as f, type CspDirective as g, type CspSource as h, type CurlCommand as i, type CurlConfig as j, DIRECTIVE_DESCRIPTIONS as k, type DirectiveConfig as l, type Header as m, type HttpMethod as n, type JwksError as o, type JwksParseResult as p, type JwksResult as q, type JwtAlgorithm as r, type JwtDecodeError as s, type JwtDecodeResult as t, type JwtExpiry as u, type JwtPart as v, type JwtResult as w, type JwtSignOptions as x, type TwitterTags as y, addParam as z };
@@ -9,6 +9,7 @@ __export(data_exports, {
9
9
  detectDelimiter: () => detectDelimiter,
10
10
  envToExport: () => envToExport,
11
11
  envToJson: () => envToJson,
12
+ formatNdjson: () => formatNdjson,
12
13
  formatToml: () => formatToml,
13
14
  formatXml: () => formatXml,
14
15
  getSection: () => getSection,
@@ -17,11 +18,14 @@ __export(data_exports, {
17
18
  getXmlStats: () => getXmlStats,
18
19
  getYamlStats: () => getYamlStats,
19
20
  iniToJson: () => iniToJson,
21
+ jsonArrayToNdjson: () => jsonArrayToNdjson,
20
22
  jsonToIni: () => jsonToIni,
21
23
  jsonToToml: () => jsonToToml,
22
24
  jsonToXml: () => jsonToXml,
25
+ minifyNdjson: () => minifyNdjson,
23
26
  minifyToml: () => minifyToml,
24
27
  minifyXml: () => minifyXml,
28
+ ndjsonToJsonArray: () => ndjsonToJsonArray,
25
29
  parseCsv: () => parseCsv,
26
30
  parseEnv: () => parseEnv,
27
31
  parseIni: () => parseIni,
@@ -31,6 +35,7 @@ __export(data_exports, {
31
35
  tomlToJson: () => tomlToJson,
32
36
  validateEnvKey: () => validateEnvKey,
33
37
  validateIni: () => validateIni,
38
+ validateNdjson: () => validateNdjson,
34
39
  validateToml: () => validateToml,
35
40
  validateXml: () => validateXml,
36
41
  validateYaml: () => validateYaml,
@@ -1076,5 +1081,63 @@ function envToExport(input) {
1076
1081
  function validateEnvKey(key) {
1077
1082
  return /^[A-Za-z_][A-Za-z0-9_]*$/.test(key);
1078
1083
  }
1084
+ function validateNdjson(input) {
1085
+ const rawLines = input.split("\n");
1086
+ const lines = [];
1087
+ let validCount = 0;
1088
+ rawLines.forEach((raw, idx) => {
1089
+ if (raw.trim() === "") return;
1090
+ const lineNum = idx + 1;
1091
+ try {
1092
+ JSON.parse(raw);
1093
+ lines.push({ line: lineNum, raw, valid: true });
1094
+ validCount++;
1095
+ } catch (e) {
1096
+ lines.push({
1097
+ line: lineNum,
1098
+ raw,
1099
+ valid: false,
1100
+ error: e instanceof Error ? e.message : String(e)
1101
+ });
1102
+ }
1103
+ });
1104
+ return {
1105
+ valid: lines.length > 0 && validCount === lines.length,
1106
+ totalLines: lines.length,
1107
+ validLines: validCount,
1108
+ invalidLines: lines.length - validCount,
1109
+ lines
1110
+ };
1111
+ }
1112
+ function _firstNdjsonError(result) {
1113
+ const firstError = result.lines.find((l) => !l.valid);
1114
+ return firstError ? `Line ${firstError.line}: ${firstError.error}` : "Invalid NDJSON";
1115
+ }
1116
+ function minifyNdjson(input) {
1117
+ const result = validateNdjson(input);
1118
+ if (!result.valid) return { error: _firstNdjsonError(result) };
1119
+ return result.lines.map((l) => JSON.stringify(JSON.parse(l.raw))).join("\n");
1120
+ }
1121
+ function formatNdjson(input, indent = 2) {
1122
+ const result = validateNdjson(input);
1123
+ if (!result.valid) return { error: _firstNdjsonError(result) };
1124
+ return result.lines.map((l) => JSON.stringify(JSON.parse(l.raw), null, indent)).join("\n");
1125
+ }
1126
+ function ndjsonToJsonArray(input) {
1127
+ const result = validateNdjson(input);
1128
+ if (!result.valid) return { error: _firstNdjsonError(result) };
1129
+ const values = result.lines.map((l) => JSON.parse(l.raw));
1130
+ return JSON.stringify(values, null, 2);
1131
+ }
1132
+ function jsonArrayToNdjson(input) {
1133
+ let parsed;
1134
+ try {
1135
+ parsed = JSON.parse(input);
1136
+ } catch (e) {
1137
+ return { error: `Invalid JSON: ${e instanceof Error ? e.message : String(e)}` };
1138
+ }
1139
+ if (!Array.isArray(parsed)) return { error: "Input must be a JSON array" };
1140
+ return parsed.map((item) => JSON.stringify(item)).join("\n");
1141
+ }
1079
1142
 
1080
- export { csvToJson, data_exports, detectDelimiter, envToExport, envToJson, formatToml, formatXml, getSection, getSectionNames, getTomlStats, getXmlStats, getYamlStats, iniToJson, jsonToIni, jsonToToml, jsonToXml, minifyToml, minifyXml, parseCsv, parseEnv, parseIni, parseXmlToObject, stringifyIni, toCsvString, tomlToJson, validateEnvKey, validateIni, validateToml, validateXml, validateYaml, xmlToJson };
1143
+ export { csvToJson, data_exports, detectDelimiter, envToExport, envToJson, formatNdjson, formatToml, formatXml, getSection, getSectionNames, getTomlStats, getXmlStats, getYamlStats, iniToJson, jsonArrayToNdjson, jsonToIni, jsonToToml, jsonToXml, minifyNdjson, minifyToml, minifyXml, ndjsonToJsonArray, parseCsv, parseEnv, parseIni, parseXmlToObject, stringifyIni, toCsvString, tomlToJson, validateEnvKey, validateIni, validateNdjson, validateToml, validateXml, validateYaml, xmlToJson };
@@ -36,6 +36,7 @@ __export(api_exports, {
36
36
  parseCspHeader: () => parseCspHeader,
37
37
  parseCurl: () => parseCurl,
38
38
  parseCurlCommand: () => parseCurlCommand,
39
+ parseJwks: () => parseJwks,
39
40
  parseMetaTags: () => parseMetaTags,
40
41
  parseUrl: () => parseUrl,
41
42
  removeParam: () => removeParam,
@@ -485,6 +486,55 @@ function decodeJwt(token) {
485
486
  function formatJwtJson(obj) {
486
487
  return JSON.stringify(obj, null, 2);
487
488
  }
489
+ function base64urlByteLength(s) {
490
+ const clean = s.replace(/=+$/, "");
491
+ return Math.floor(clean.length * 6 / 8);
492
+ }
493
+ function parseJwks(input) {
494
+ const trimmed = input.trim();
495
+ if (!trimmed) return { ok: false, error: "No input provided" };
496
+ let data;
497
+ try {
498
+ data = JSON.parse(trimmed);
499
+ } catch (e) {
500
+ return { ok: false, error: `Invalid JSON: ${e instanceof Error ? e.message : String(e)}` };
501
+ }
502
+ let rawKeys;
503
+ if (data && typeof data === "object" && Array.isArray(data.keys)) {
504
+ rawKeys = data.keys;
505
+ } else if (data && typeof data === "object" && typeof data.kty === "string") {
506
+ rawKeys = [data];
507
+ } else {
508
+ return { ok: false, error: 'Input must be a JWKS object with a "keys" array, or a single JWK object with a "kty" field' };
509
+ }
510
+ const keys = rawKeys.map((k) => {
511
+ const key = k ?? {};
512
+ const kty = typeof key.kty === "string" ? key.kty : "unknown";
513
+ let keySize = null;
514
+ let curve;
515
+ if (kty === "RSA" && typeof key.n === "string") {
516
+ keySize = base64urlByteLength(key.n) * 8;
517
+ } else if ((kty === "EC" || kty === "OKP") && typeof key.crv === "string") {
518
+ curve = key.crv;
519
+ } else if (kty === "oct" && typeof key.k === "string") {
520
+ keySize = base64urlByteLength(key.k) * 8;
521
+ }
522
+ return {
523
+ kty,
524
+ use: typeof key.use === "string" ? key.use : void 0,
525
+ keyOps: Array.isArray(key.key_ops) ? key.key_ops.filter((x) => typeof x === "string") : void 0,
526
+ alg: typeof key.alg === "string" ? key.alg : void 0,
527
+ kid: typeof key.kid === "string" ? key.kid : void 0,
528
+ keySize,
529
+ curve,
530
+ raw: key
531
+ };
532
+ });
533
+ const kidCounts = /* @__PURE__ */ new Map();
534
+ for (const k of keys) if (k.kid) kidCounts.set(k.kid, (kidCounts.get(k.kid) ?? 0) + 1);
535
+ const duplicateKids = [...kidCounts.entries()].filter(([, c]) => c > 1).map(([kid]) => kid);
536
+ return { ok: true, keys, count: keys.length, duplicateKids };
537
+ }
488
538
  var ALG_TO_NODE_HASH = {
489
539
  HS256: "sha256",
490
540
  HS384: "sha384",
@@ -1216,4 +1266,4 @@ function generateMetaHtml(tags) {
1216
1266
  return lines.join("\n");
1217
1267
  }
1218
1268
 
1219
- export { COMMON_HEADERS, COMMON_PRESETS, CORS_COMMON_HEADERS, DEFAULT_CORS_CONFIG, DIRECTIVE_DESCRIPTIONS, HTTP_METHODS, SUPPORTED_LANGUAGES, addParam, api_exports, base64urlDecode, base64urlEncode, buildCurl, buildCurlMultiline, buildUrl, convertToCode, decodeJwt, decodeUrlComponent, detectFormat, encodeUrlComponent, extractJsonPaths, formatJwtJson, formatResponse, generateCors, generateCspHeader, generateFullHeader, generateMetaHtml, getParam, getStats, isValidUrl, normalizeUrl, parseCspHeader, parseCurl, parseCurlCommand, parseMetaTags, parseUrl, removeParam, signJwt, validateCorsConfig, validateCspConfig, validateOgTags };
1269
+ export { COMMON_HEADERS, COMMON_PRESETS, CORS_COMMON_HEADERS, DEFAULT_CORS_CONFIG, DIRECTIVE_DESCRIPTIONS, HTTP_METHODS, SUPPORTED_LANGUAGES, addParam, api_exports, base64urlDecode, base64urlEncode, buildCurl, buildCurlMultiline, buildUrl, convertToCode, decodeJwt, decodeUrlComponent, detectFormat, encodeUrlComponent, extractJsonPaths, formatJwtJson, formatResponse, generateCors, generateCspHeader, generateFullHeader, generateMetaHtml, getParam, getStats, isValidUrl, normalizeUrl, parseCspHeader, parseCurl, parseCurlCommand, parseJwks, parseMetaTags, parseUrl, removeParam, signJwt, validateCorsConfig, validateCspConfig, validateOgTags };
@@ -25,6 +25,7 @@ __export(network_exports, {
25
25
  isValidIpv6: () => isValidIpv6,
26
26
  parseDnsResponse: () => parseDnsResponse,
27
27
  parseGeoResponse: () => parseGeoResponse,
28
+ parseHar: () => parseHar,
28
29
  searchHeaders: () => searchHeaders,
29
30
  searchStatusCodes: () => searchStatusCodes,
30
31
  statusCodeToText: () => statusCodeToText,
@@ -1381,5 +1382,63 @@ function validateHeaderValue(name, value) {
1381
1382
  }
1382
1383
  return { valid: true };
1383
1384
  }
1385
+ function parseHar(input) {
1386
+ if (!input || !input.trim()) {
1387
+ return { error: "Input is empty" };
1388
+ }
1389
+ let data;
1390
+ try {
1391
+ data = JSON.parse(input);
1392
+ } catch (e) {
1393
+ return { error: `Invalid JSON: ${e instanceof Error ? e.message : String(e)}` };
1394
+ }
1395
+ if (typeof data !== "object" || data === null || !("log" in data)) {
1396
+ return { error: 'Not a valid HAR file: missing "log" property' };
1397
+ }
1398
+ const log = data.log;
1399
+ if (typeof log !== "object" || log === null || !Array.isArray(log.entries)) {
1400
+ return { error: 'Not a valid HAR file: "log.entries" must be an array' };
1401
+ }
1402
+ const logObj = log;
1403
+ const entries = [];
1404
+ const methods = {};
1405
+ const statusCodes = {};
1406
+ let totalSize = 0;
1407
+ let totalTime = 0;
1408
+ let failedRequests = 0;
1409
+ for (const raw of logObj.entries) {
1410
+ if (typeof raw !== "object" || raw === null) continue;
1411
+ const e = raw;
1412
+ const request = e.request ?? {};
1413
+ const response = e.response ?? {};
1414
+ const content = response.content ?? {};
1415
+ const method = typeof request.method === "string" ? request.method : "GET";
1416
+ const url = typeof request.url === "string" ? request.url : "";
1417
+ const status = typeof response.status === "number" ? response.status : 0;
1418
+ const statusText = typeof response.statusText === "string" ? response.statusText : "";
1419
+ const httpVersion = typeof response.httpVersion === "string" ? response.httpVersion : "";
1420
+ const mimeType = typeof content.mimeType === "string" ? content.mimeType : "";
1421
+ const size = typeof content.size === "number" && content.size > 0 ? content.size : 0;
1422
+ const time = typeof e.time === "number" ? e.time : 0;
1423
+ const startedDateTime = typeof e.startedDateTime === "string" ? e.startedDateTime : "";
1424
+ entries.push({ method, url, status, statusText, httpVersion, mimeType, size, time, startedDateTime });
1425
+ methods[method] = (methods[method] ?? 0) + 1;
1426
+ if (status > 0) statusCodes[String(status)] = (statusCodes[String(status)] ?? 0) + 1;
1427
+ totalSize += size;
1428
+ totalTime += time;
1429
+ if (status === 0 || status >= 400) failedRequests++;
1430
+ }
1431
+ const totalRequests = entries.length;
1432
+ const avgTime = totalRequests > 0 ? Math.round(totalTime / totalRequests * 100) / 100 : 0;
1433
+ return {
1434
+ version: typeof logObj.version === "string" ? logObj.version : "",
1435
+ creator: {
1436
+ name: typeof logObj.creator?.name === "string" ? logObj.creator.name : "",
1437
+ version: typeof logObj.creator?.version === "string" ? logObj.creator.version : ""
1438
+ },
1439
+ entries,
1440
+ summary: { totalRequests, totalSize, totalTime, avgTime, failedRequests, methods, statusCodes }
1441
+ };
1442
+ }
1384
1443
 
1385
- export { DNS_RECORD_TYPES, HTTP_HEADERS, STATUS_CODES, buildDnsQueryUrl, buildGeoUrl, buildMapUrl, countryCodeToFlag, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, network_exports, parseDnsResponse, parseGeoResponse, searchHeaders, searchStatusCodes, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue };
1444
+ export { DNS_RECORD_TYPES, HTTP_HEADERS, STATUS_CODES, buildDnsQueryUrl, buildGeoUrl, buildMapUrl, countryCodeToFlag, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, network_exports, parseDnsResponse, parseGeoResponse, parseHar, searchHeaders, searchStatusCodes, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue };