@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.
- package/README.md +34 -12
- package/dist/{api-8aZtWhSj.d.cts → api-Xl7OzIgq.d.cts} +35 -2
- package/dist/{api-8aZtWhSj.d.ts → api-Xl7OzIgq.d.ts} +35 -2
- package/dist/{chunk-UC656APA.js → chunk-DNCOIO5N.js} +64 -1
- package/dist/{chunk-HFRTZE7T.js → chunk-Q3B3YWOA.js} +51 -1
- package/dist/{chunk-3BAHSW4C.js → chunk-V5JKVDBA.js} +60 -1
- package/dist/chunk-WWKPLYEP.js +277 -0
- package/dist/{data-rMjWNiOJ.d.cts → data-CakDxAcT.d.cts} +36 -2
- package/dist/{data-rMjWNiOJ.d.ts → data-CakDxAcT.d.ts} +36 -2
- package/dist/index.cjs +316 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/media-D-K5aZnq.d.cts +53 -0
- package/dist/media-D-K5aZnq.d.ts +53 -0
- package/dist/{network-CNtmrDeN.d.cts → network-DwyAjwJS.d.cts} +39 -2
- package/dist/{network-CNtmrDeN.d.ts → network-DwyAjwJS.d.ts} +39 -2
- package/dist/tools/api.cjs +50 -0
- package/dist/tools/api.d.cts +1 -1
- package/dist/tools/api.d.ts +1 -1
- package/dist/tools/api.js +1 -1
- package/dist/tools/data.cjs +63 -0
- package/dist/tools/data.d.cts +1 -1
- package/dist/tools/data.d.ts +1 -1
- package/dist/tools/data.js +1 -1
- package/dist/tools/media.cjs +143 -0
- package/dist/tools/media.d.cts +1 -1
- package/dist/tools/media.d.ts +1 -1
- package/dist/tools/media.js +1 -1
- package/dist/tools/network.cjs +59 -0
- package/dist/tools/network.d.cts +1 -1
- package/dist/tools/network.d.ts +1 -1
- package/dist/tools/network.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-N7C52YGL.js +0 -134
- package/dist/media-DF2cx3pK.d.cts +0 -28
- package/dist/media-DF2cx3pK.d.ts +0 -28
package/dist/index.cjs
CHANGED
|
@@ -4197,6 +4197,7 @@ __export(data_exports, {
|
|
|
4197
4197
|
detectDelimiter: () => detectDelimiter2,
|
|
4198
4198
|
envToExport: () => envToExport,
|
|
4199
4199
|
envToJson: () => envToJson,
|
|
4200
|
+
formatNdjson: () => formatNdjson,
|
|
4200
4201
|
formatToml: () => formatToml,
|
|
4201
4202
|
formatXml: () => formatXml,
|
|
4202
4203
|
getSection: () => getSection,
|
|
@@ -4205,11 +4206,14 @@ __export(data_exports, {
|
|
|
4205
4206
|
getXmlStats: () => getXmlStats,
|
|
4206
4207
|
getYamlStats: () => getYamlStats,
|
|
4207
4208
|
iniToJson: () => iniToJson,
|
|
4209
|
+
jsonArrayToNdjson: () => jsonArrayToNdjson,
|
|
4208
4210
|
jsonToIni: () => jsonToIni,
|
|
4209
4211
|
jsonToToml: () => jsonToToml,
|
|
4210
4212
|
jsonToXml: () => jsonToXml,
|
|
4213
|
+
minifyNdjson: () => minifyNdjson,
|
|
4211
4214
|
minifyToml: () => minifyToml,
|
|
4212
4215
|
minifyXml: () => minifyXml,
|
|
4216
|
+
ndjsonToJsonArray: () => ndjsonToJsonArray,
|
|
4213
4217
|
parseCsv: () => parseCsv,
|
|
4214
4218
|
parseEnv: () => parseEnv,
|
|
4215
4219
|
parseIni: () => parseIni,
|
|
@@ -4219,6 +4223,7 @@ __export(data_exports, {
|
|
|
4219
4223
|
tomlToJson: () => tomlToJson,
|
|
4220
4224
|
validateEnvKey: () => validateEnvKey,
|
|
4221
4225
|
validateIni: () => validateIni,
|
|
4226
|
+
validateNdjson: () => validateNdjson,
|
|
4222
4227
|
validateToml: () => validateToml,
|
|
4223
4228
|
validateXml: () => validateXml,
|
|
4224
4229
|
validateYaml: () => validateYaml,
|
|
@@ -5264,6 +5269,64 @@ function envToExport(input) {
|
|
|
5264
5269
|
function validateEnvKey(key) {
|
|
5265
5270
|
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(key);
|
|
5266
5271
|
}
|
|
5272
|
+
function validateNdjson(input) {
|
|
5273
|
+
const rawLines = input.split("\n");
|
|
5274
|
+
const lines = [];
|
|
5275
|
+
let validCount = 0;
|
|
5276
|
+
rawLines.forEach((raw, idx) => {
|
|
5277
|
+
if (raw.trim() === "") return;
|
|
5278
|
+
const lineNum = idx + 1;
|
|
5279
|
+
try {
|
|
5280
|
+
JSON.parse(raw);
|
|
5281
|
+
lines.push({ line: lineNum, raw, valid: true });
|
|
5282
|
+
validCount++;
|
|
5283
|
+
} catch (e) {
|
|
5284
|
+
lines.push({
|
|
5285
|
+
line: lineNum,
|
|
5286
|
+
raw,
|
|
5287
|
+
valid: false,
|
|
5288
|
+
error: e instanceof Error ? e.message : String(e)
|
|
5289
|
+
});
|
|
5290
|
+
}
|
|
5291
|
+
});
|
|
5292
|
+
return {
|
|
5293
|
+
valid: lines.length > 0 && validCount === lines.length,
|
|
5294
|
+
totalLines: lines.length,
|
|
5295
|
+
validLines: validCount,
|
|
5296
|
+
invalidLines: lines.length - validCount,
|
|
5297
|
+
lines
|
|
5298
|
+
};
|
|
5299
|
+
}
|
|
5300
|
+
function _firstNdjsonError(result) {
|
|
5301
|
+
const firstError = result.lines.find((l) => !l.valid);
|
|
5302
|
+
return firstError ? `Line ${firstError.line}: ${firstError.error}` : "Invalid NDJSON";
|
|
5303
|
+
}
|
|
5304
|
+
function minifyNdjson(input) {
|
|
5305
|
+
const result = validateNdjson(input);
|
|
5306
|
+
if (!result.valid) return { error: _firstNdjsonError(result) };
|
|
5307
|
+
return result.lines.map((l) => JSON.stringify(JSON.parse(l.raw))).join("\n");
|
|
5308
|
+
}
|
|
5309
|
+
function formatNdjson(input, indent = 2) {
|
|
5310
|
+
const result = validateNdjson(input);
|
|
5311
|
+
if (!result.valid) return { error: _firstNdjsonError(result) };
|
|
5312
|
+
return result.lines.map((l) => JSON.stringify(JSON.parse(l.raw), null, indent)).join("\n");
|
|
5313
|
+
}
|
|
5314
|
+
function ndjsonToJsonArray(input) {
|
|
5315
|
+
const result = validateNdjson(input);
|
|
5316
|
+
if (!result.valid) return { error: _firstNdjsonError(result) };
|
|
5317
|
+
const values = result.lines.map((l) => JSON.parse(l.raw));
|
|
5318
|
+
return JSON.stringify(values, null, 2);
|
|
5319
|
+
}
|
|
5320
|
+
function jsonArrayToNdjson(input) {
|
|
5321
|
+
let parsed;
|
|
5322
|
+
try {
|
|
5323
|
+
parsed = JSON.parse(input);
|
|
5324
|
+
} catch (e) {
|
|
5325
|
+
return { error: `Invalid JSON: ${e instanceof Error ? e.message : String(e)}` };
|
|
5326
|
+
}
|
|
5327
|
+
if (!Array.isArray(parsed)) return { error: "Input must be a JSON array" };
|
|
5328
|
+
return parsed.map((item) => JSON.stringify(item)).join("\n");
|
|
5329
|
+
}
|
|
5267
5330
|
|
|
5268
5331
|
// src/tools/generators.ts
|
|
5269
5332
|
var generators_exports = {};
|
|
@@ -7380,6 +7443,7 @@ __export(network_exports, {
|
|
|
7380
7443
|
isValidIpv6: () => isValidIpv6,
|
|
7381
7444
|
parseDnsResponse: () => parseDnsResponse,
|
|
7382
7445
|
parseGeoResponse: () => parseGeoResponse,
|
|
7446
|
+
parseHar: () => parseHar,
|
|
7383
7447
|
searchHeaders: () => searchHeaders,
|
|
7384
7448
|
searchStatusCodes: () => searchStatusCodes,
|
|
7385
7449
|
statusCodeToText: () => statusCodeToText,
|
|
@@ -8736,6 +8800,64 @@ function validateHeaderValue(name, value) {
|
|
|
8736
8800
|
}
|
|
8737
8801
|
return { valid: true };
|
|
8738
8802
|
}
|
|
8803
|
+
function parseHar(input) {
|
|
8804
|
+
if (!input || !input.trim()) {
|
|
8805
|
+
return { error: "Input is empty" };
|
|
8806
|
+
}
|
|
8807
|
+
let data;
|
|
8808
|
+
try {
|
|
8809
|
+
data = JSON.parse(input);
|
|
8810
|
+
} catch (e) {
|
|
8811
|
+
return { error: `Invalid JSON: ${e instanceof Error ? e.message : String(e)}` };
|
|
8812
|
+
}
|
|
8813
|
+
if (typeof data !== "object" || data === null || !("log" in data)) {
|
|
8814
|
+
return { error: 'Not a valid HAR file: missing "log" property' };
|
|
8815
|
+
}
|
|
8816
|
+
const log = data.log;
|
|
8817
|
+
if (typeof log !== "object" || log === null || !Array.isArray(log.entries)) {
|
|
8818
|
+
return { error: 'Not a valid HAR file: "log.entries" must be an array' };
|
|
8819
|
+
}
|
|
8820
|
+
const logObj = log;
|
|
8821
|
+
const entries = [];
|
|
8822
|
+
const methods = {};
|
|
8823
|
+
const statusCodes = {};
|
|
8824
|
+
let totalSize = 0;
|
|
8825
|
+
let totalTime = 0;
|
|
8826
|
+
let failedRequests = 0;
|
|
8827
|
+
for (const raw of logObj.entries) {
|
|
8828
|
+
if (typeof raw !== "object" || raw === null) continue;
|
|
8829
|
+
const e = raw;
|
|
8830
|
+
const request = e.request ?? {};
|
|
8831
|
+
const response = e.response ?? {};
|
|
8832
|
+
const content = response.content ?? {};
|
|
8833
|
+
const method = typeof request.method === "string" ? request.method : "GET";
|
|
8834
|
+
const url = typeof request.url === "string" ? request.url : "";
|
|
8835
|
+
const status = typeof response.status === "number" ? response.status : 0;
|
|
8836
|
+
const statusText = typeof response.statusText === "string" ? response.statusText : "";
|
|
8837
|
+
const httpVersion = typeof response.httpVersion === "string" ? response.httpVersion : "";
|
|
8838
|
+
const mimeType = typeof content.mimeType === "string" ? content.mimeType : "";
|
|
8839
|
+
const size = typeof content.size === "number" && content.size > 0 ? content.size : 0;
|
|
8840
|
+
const time = typeof e.time === "number" ? e.time : 0;
|
|
8841
|
+
const startedDateTime = typeof e.startedDateTime === "string" ? e.startedDateTime : "";
|
|
8842
|
+
entries.push({ method, url, status, statusText, httpVersion, mimeType, size, time, startedDateTime });
|
|
8843
|
+
methods[method] = (methods[method] ?? 0) + 1;
|
|
8844
|
+
if (status > 0) statusCodes[String(status)] = (statusCodes[String(status)] ?? 0) + 1;
|
|
8845
|
+
totalSize += size;
|
|
8846
|
+
totalTime += time;
|
|
8847
|
+
if (status === 0 || status >= 400) failedRequests++;
|
|
8848
|
+
}
|
|
8849
|
+
const totalRequests = entries.length;
|
|
8850
|
+
const avgTime = totalRequests > 0 ? Math.round(totalTime / totalRequests * 100) / 100 : 0;
|
|
8851
|
+
return {
|
|
8852
|
+
version: typeof logObj.version === "string" ? logObj.version : "",
|
|
8853
|
+
creator: {
|
|
8854
|
+
name: typeof logObj.creator?.name === "string" ? logObj.creator.name : "",
|
|
8855
|
+
version: typeof logObj.creator?.version === "string" ? logObj.creator.version : ""
|
|
8856
|
+
},
|
|
8857
|
+
entries,
|
|
8858
|
+
summary: { totalRequests, totalSize, totalTime, avgTime, failedRequests, methods, statusCodes }
|
|
8859
|
+
};
|
|
8860
|
+
}
|
|
8739
8861
|
|
|
8740
8862
|
// src/tools/api.ts
|
|
8741
8863
|
var api_exports = {};
|
|
@@ -8772,6 +8894,7 @@ __export(api_exports, {
|
|
|
8772
8894
|
parseCspHeader: () => parseCspHeader,
|
|
8773
8895
|
parseCurl: () => parseCurl,
|
|
8774
8896
|
parseCurlCommand: () => parseCurlCommand,
|
|
8897
|
+
parseJwks: () => parseJwks,
|
|
8775
8898
|
parseMetaTags: () => parseMetaTags,
|
|
8776
8899
|
parseUrl: () => parseUrl,
|
|
8777
8900
|
removeParam: () => removeParam,
|
|
@@ -9221,6 +9344,55 @@ function decodeJwt(token) {
|
|
|
9221
9344
|
function formatJwtJson(obj) {
|
|
9222
9345
|
return JSON.stringify(obj, null, 2);
|
|
9223
9346
|
}
|
|
9347
|
+
function base64urlByteLength(s) {
|
|
9348
|
+
const clean = s.replace(/=+$/, "");
|
|
9349
|
+
return Math.floor(clean.length * 6 / 8);
|
|
9350
|
+
}
|
|
9351
|
+
function parseJwks(input) {
|
|
9352
|
+
const trimmed = input.trim();
|
|
9353
|
+
if (!trimmed) return { ok: false, error: "No input provided" };
|
|
9354
|
+
let data;
|
|
9355
|
+
try {
|
|
9356
|
+
data = JSON.parse(trimmed);
|
|
9357
|
+
} catch (e) {
|
|
9358
|
+
return { ok: false, error: `Invalid JSON: ${e instanceof Error ? e.message : String(e)}` };
|
|
9359
|
+
}
|
|
9360
|
+
let rawKeys;
|
|
9361
|
+
if (data && typeof data === "object" && Array.isArray(data.keys)) {
|
|
9362
|
+
rawKeys = data.keys;
|
|
9363
|
+
} else if (data && typeof data === "object" && typeof data.kty === "string") {
|
|
9364
|
+
rawKeys = [data];
|
|
9365
|
+
} else {
|
|
9366
|
+
return { ok: false, error: 'Input must be a JWKS object with a "keys" array, or a single JWK object with a "kty" field' };
|
|
9367
|
+
}
|
|
9368
|
+
const keys = rawKeys.map((k) => {
|
|
9369
|
+
const key = k ?? {};
|
|
9370
|
+
const kty = typeof key.kty === "string" ? key.kty : "unknown";
|
|
9371
|
+
let keySize = null;
|
|
9372
|
+
let curve;
|
|
9373
|
+
if (kty === "RSA" && typeof key.n === "string") {
|
|
9374
|
+
keySize = base64urlByteLength(key.n) * 8;
|
|
9375
|
+
} else if ((kty === "EC" || kty === "OKP") && typeof key.crv === "string") {
|
|
9376
|
+
curve = key.crv;
|
|
9377
|
+
} else if (kty === "oct" && typeof key.k === "string") {
|
|
9378
|
+
keySize = base64urlByteLength(key.k) * 8;
|
|
9379
|
+
}
|
|
9380
|
+
return {
|
|
9381
|
+
kty,
|
|
9382
|
+
use: typeof key.use === "string" ? key.use : void 0,
|
|
9383
|
+
keyOps: Array.isArray(key.key_ops) ? key.key_ops.filter((x) => typeof x === "string") : void 0,
|
|
9384
|
+
alg: typeof key.alg === "string" ? key.alg : void 0,
|
|
9385
|
+
kid: typeof key.kid === "string" ? key.kid : void 0,
|
|
9386
|
+
keySize,
|
|
9387
|
+
curve,
|
|
9388
|
+
raw: key
|
|
9389
|
+
};
|
|
9390
|
+
});
|
|
9391
|
+
const kidCounts = /* @__PURE__ */ new Map();
|
|
9392
|
+
for (const k of keys) if (k.kid) kidCounts.set(k.kid, (kidCounts.get(k.kid) ?? 0) + 1);
|
|
9393
|
+
const duplicateKids = [...kidCounts.entries()].filter(([, c]) => c > 1).map(([kid]) => kid);
|
|
9394
|
+
return { ok: true, keys, count: keys.length, duplicateKids };
|
|
9395
|
+
}
|
|
9224
9396
|
var ALG_TO_NODE_HASH = {
|
|
9225
9397
|
HS256: "sha256",
|
|
9226
9398
|
HS384: "sha384",
|
|
@@ -16762,7 +16934,8 @@ function summarizeForLlm(text, maxTokens = 200, strategy = "extractive") {
|
|
|
16762
16934
|
// src/tools/media.ts
|
|
16763
16935
|
var media_exports = {};
|
|
16764
16936
|
__export(media_exports, {
|
|
16765
|
-
readImageInfo: () => readImageInfo
|
|
16937
|
+
readImageInfo: () => readImageInfo,
|
|
16938
|
+
readPdfMetadata: () => readPdfMetadata
|
|
16766
16939
|
});
|
|
16767
16940
|
function readU32BE(bytes, offset) {
|
|
16768
16941
|
return (bytes[offset] << 24 | bytes[offset + 1] << 16 | bytes[offset + 2] << 8 | bytes[offset + 3]) >>> 0;
|
|
@@ -16889,6 +17062,148 @@ function readImageInfo(bytes) {
|
|
|
16889
17062
|
}
|
|
16890
17063
|
return { error: "Unrecognized image format. Supported formats: PNG, JPEG, GIF, WebP, BMP" };
|
|
16891
17064
|
}
|
|
17065
|
+
function bytesToLatin1(bytes) {
|
|
17066
|
+
let out = "";
|
|
17067
|
+
const CHUNK = 32768;
|
|
17068
|
+
for (let i = 0; i < bytes.length; i += CHUNK) {
|
|
17069
|
+
out += String.fromCharCode(...bytes.subarray(i, i + CHUNK));
|
|
17070
|
+
}
|
|
17071
|
+
return out;
|
|
17072
|
+
}
|
|
17073
|
+
function decodePdfString(raw, isHex) {
|
|
17074
|
+
const bytes = [];
|
|
17075
|
+
if (isHex) {
|
|
17076
|
+
const hex = raw.replace(/\s+/g, "");
|
|
17077
|
+
const padded = hex.length % 2 === 0 ? hex : hex + "0";
|
|
17078
|
+
for (let i = 0; i < padded.length; i += 2) bytes.push(parseInt(padded.slice(i, i + 2), 16));
|
|
17079
|
+
} else {
|
|
17080
|
+
const s = raw.replace(/\\\r\n|\\\r|\\\n/g, "");
|
|
17081
|
+
for (let i = 0; i < s.length; i++) {
|
|
17082
|
+
const ch = s[i];
|
|
17083
|
+
if (ch === "\\" && i + 1 < s.length) {
|
|
17084
|
+
const next = s[i + 1];
|
|
17085
|
+
if (next === "n") {
|
|
17086
|
+
bytes.push(10);
|
|
17087
|
+
i++;
|
|
17088
|
+
} else if (next === "r") {
|
|
17089
|
+
bytes.push(13);
|
|
17090
|
+
i++;
|
|
17091
|
+
} else if (next === "t") {
|
|
17092
|
+
bytes.push(9);
|
|
17093
|
+
i++;
|
|
17094
|
+
} else if (next === "b") {
|
|
17095
|
+
bytes.push(8);
|
|
17096
|
+
i++;
|
|
17097
|
+
} else if (next === "f") {
|
|
17098
|
+
bytes.push(12);
|
|
17099
|
+
i++;
|
|
17100
|
+
} else if (next === "(" || next === ")" || next === "\\") {
|
|
17101
|
+
bytes.push(next.charCodeAt(0));
|
|
17102
|
+
i++;
|
|
17103
|
+
} else if (/[0-7]/.test(next)) {
|
|
17104
|
+
let oct = next;
|
|
17105
|
+
i++;
|
|
17106
|
+
for (let k = 0; k < 2 && i + 1 < s.length && /[0-7]/.test(s[i + 1]); k++) {
|
|
17107
|
+
i++;
|
|
17108
|
+
oct += s[i];
|
|
17109
|
+
}
|
|
17110
|
+
bytes.push(parseInt(oct, 8) & 255);
|
|
17111
|
+
} else {
|
|
17112
|
+
bytes.push(next.charCodeAt(0));
|
|
17113
|
+
i++;
|
|
17114
|
+
}
|
|
17115
|
+
} else {
|
|
17116
|
+
bytes.push(ch.charCodeAt(0) & 255);
|
|
17117
|
+
}
|
|
17118
|
+
}
|
|
17119
|
+
}
|
|
17120
|
+
if (bytes.length >= 2 && bytes[0] === 254 && bytes[1] === 255) {
|
|
17121
|
+
let out = "";
|
|
17122
|
+
for (let i = 2; i + 1 < bytes.length; i += 2) out += String.fromCharCode(bytes[i] << 8 | bytes[i + 1]);
|
|
17123
|
+
return out;
|
|
17124
|
+
}
|
|
17125
|
+
return bytes.map((b) => String.fromCharCode(b)).join("");
|
|
17126
|
+
}
|
|
17127
|
+
function extractDictField(dict, key) {
|
|
17128
|
+
const litMatch = dict.match(new RegExp(`/${key}\\s*\\(((?:\\\\.|[^\\\\()])*)\\)`));
|
|
17129
|
+
if (litMatch) return decodePdfString(litMatch[1], false);
|
|
17130
|
+
const hexMatch = dict.match(new RegExp(`/${key}\\s*<([0-9A-Fa-f\\s]*)>`));
|
|
17131
|
+
if (hexMatch) return decodePdfString(hexMatch[1], true);
|
|
17132
|
+
return null;
|
|
17133
|
+
}
|
|
17134
|
+
function findObject(text, objNum, gen) {
|
|
17135
|
+
const m = text.match(new RegExp(`(?:^|[^0-9])${objNum}\\s+${gen}\\s+obj([\\s\\S]*?)endobj`));
|
|
17136
|
+
return m ? m[1] : null;
|
|
17137
|
+
}
|
|
17138
|
+
function parsePdfDate(raw) {
|
|
17139
|
+
const m = raw.match(/^D:(\d{4})(\d{2})?(\d{2})?(\d{2})?(\d{2})?(\d{2})?([Z+-])?(\d{2})?'?(\d{2})?'?/);
|
|
17140
|
+
if (!m) return null;
|
|
17141
|
+
const [, y, mo = "01", d = "01", h = "00", mi = "00", s = "00", tz, tzh, tzm] = m;
|
|
17142
|
+
let iso = `${y}-${mo}-${d}T${h}:${mi}:${s}`;
|
|
17143
|
+
if (tz === "Z") iso += "Z";
|
|
17144
|
+
else if (tz === "+" || tz === "-") iso += `${tz}${tzh ?? "00"}:${tzm ?? "00"}`;
|
|
17145
|
+
return iso;
|
|
17146
|
+
}
|
|
17147
|
+
function readPdfMetadata(bytes) {
|
|
17148
|
+
if (bytes.length < 8) return { error: "File too small to be a PDF" };
|
|
17149
|
+
const header = bytesToLatin1(bytes.subarray(0, 16));
|
|
17150
|
+
const versionMatch = header.match(/%PDF-(\d\.\d)/);
|
|
17151
|
+
if (!versionMatch) return { error: "Not a valid PDF file (missing %PDF header)" };
|
|
17152
|
+
const version2 = versionMatch[1];
|
|
17153
|
+
const text = bytesToLatin1(bytes);
|
|
17154
|
+
const trailerMatches = [...text.matchAll(/trailer\s*<<([\s\S]*?)>>/g)];
|
|
17155
|
+
let infoDict = null;
|
|
17156
|
+
let encrypted = false;
|
|
17157
|
+
if (trailerMatches.length > 0) {
|
|
17158
|
+
const trailer = trailerMatches[trailerMatches.length - 1][1];
|
|
17159
|
+
encrypted = /\/Encrypt\s+\d+\s+\d+\s+R/.test(trailer);
|
|
17160
|
+
const infoRef = trailer.match(/\/Info\s+(\d+)\s+(\d+)\s+R/);
|
|
17161
|
+
if (infoRef) infoDict = findObject(text, Number(infoRef[1]), Number(infoRef[2]));
|
|
17162
|
+
}
|
|
17163
|
+
const objBlocks = [...text.matchAll(/(\d+)\s+(\d+)\s+obj([\s\S]*?)endobj/g)];
|
|
17164
|
+
if (!infoDict) {
|
|
17165
|
+
for (const b of objBlocks) {
|
|
17166
|
+
if (/\/(Title|Author|Producer|Creator|CreationDate)\b/.test(b[3]) && !/\/Type\s*\/(Page|Pages|Catalog|Font)\b/.test(b[3])) {
|
|
17167
|
+
infoDict = b[3];
|
|
17168
|
+
break;
|
|
17169
|
+
}
|
|
17170
|
+
}
|
|
17171
|
+
}
|
|
17172
|
+
const title = infoDict ? extractDictField(infoDict, "Title") : null;
|
|
17173
|
+
const author = infoDict ? extractDictField(infoDict, "Author") : null;
|
|
17174
|
+
const subject = infoDict ? extractDictField(infoDict, "Subject") : null;
|
|
17175
|
+
const keywords = infoDict ? extractDictField(infoDict, "Keywords") : null;
|
|
17176
|
+
const creator = infoDict ? extractDictField(infoDict, "Creator") : null;
|
|
17177
|
+
const producer = infoDict ? extractDictField(infoDict, "Producer") : null;
|
|
17178
|
+
const creationDateRaw = infoDict ? extractDictField(infoDict, "CreationDate") : null;
|
|
17179
|
+
const modDateRaw = infoDict ? extractDictField(infoDict, "ModDate") : null;
|
|
17180
|
+
let pageCount = null;
|
|
17181
|
+
for (const b of objBlocks) {
|
|
17182
|
+
if (!/\/Type\s*\/Pages\b/.test(b[3])) continue;
|
|
17183
|
+
const countMatch = b[3].match(/\/Count\s+(\d+)/);
|
|
17184
|
+
if (countMatch) {
|
|
17185
|
+
const c = Number(countMatch[1]);
|
|
17186
|
+
if (pageCount === null || c > pageCount) pageCount = c;
|
|
17187
|
+
}
|
|
17188
|
+
}
|
|
17189
|
+
if (pageCount === null) {
|
|
17190
|
+
const pageMatches = text.match(/\/Type\s*\/Page(?!s)\b/g);
|
|
17191
|
+
if (pageMatches) pageCount = pageMatches.length;
|
|
17192
|
+
}
|
|
17193
|
+
return {
|
|
17194
|
+
version: version2,
|
|
17195
|
+
pageCount,
|
|
17196
|
+
title,
|
|
17197
|
+
author,
|
|
17198
|
+
subject,
|
|
17199
|
+
keywords,
|
|
17200
|
+
creator,
|
|
17201
|
+
producer,
|
|
17202
|
+
creationDate: creationDateRaw ? parsePdfDate(creationDateRaw) ?? creationDateRaw : null,
|
|
17203
|
+
modDate: modDateRaw ? parsePdfDate(modDateRaw) ?? modDateRaw : null,
|
|
17204
|
+
encrypted
|
|
17205
|
+
};
|
|
17206
|
+
}
|
|
16892
17207
|
|
|
16893
17208
|
// src/index.ts
|
|
16894
17209
|
var version = "0.1.0";
|
package/dist/index.d.cts
CHANGED
|
@@ -2,18 +2,18 @@ export { j as json } from './json-BjSoIS1h.cjs';
|
|
|
2
2
|
export { e as encoding } from './encoding-7gmq-vkV.cjs';
|
|
3
3
|
export { h as hashing } from './hashing-CnetQFD_.cjs';
|
|
4
4
|
export { t as text } from './text-CI7JAl7F.cjs';
|
|
5
|
-
export { d as data } from './data-
|
|
5
|
+
export { d as data } from './data-CakDxAcT.cjs';
|
|
6
6
|
export { g as generators } from './generators-BGtRGpJZ.cjs';
|
|
7
7
|
export { t as time } from './time-DbT8fjaF.cjs';
|
|
8
8
|
export { u as units } from './units-6lwDYBvX.cjs';
|
|
9
|
-
export { n as network } from './network-
|
|
10
|
-
export { a as api } from './api-
|
|
9
|
+
export { n as network } from './network-DwyAjwJS.cjs';
|
|
10
|
+
export { a as api } from './api-Xl7OzIgq.cjs';
|
|
11
11
|
export { c as code } from './code-BUqyaofO.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';
|
|
15
15
|
export { a as ai_agent } from './ai_agent-CcpkV2DR.cjs';
|
|
16
|
-
export { m as media } from './media-
|
|
16
|
+
export { m as media } from './media-D-K5aZnq.cjs';
|
|
17
17
|
|
|
18
18
|
declare const version = "0.1.0";
|
|
19
19
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2,18 +2,18 @@ export { j as json } from './json-BjSoIS1h.js';
|
|
|
2
2
|
export { e as encoding } from './encoding-7gmq-vkV.js';
|
|
3
3
|
export { h as hashing } from './hashing-CnetQFD_.js';
|
|
4
4
|
export { t as text } from './text-CI7JAl7F.js';
|
|
5
|
-
export { d as data } from './data-
|
|
5
|
+
export { d as data } from './data-CakDxAcT.js';
|
|
6
6
|
export { g as generators } from './generators-BGtRGpJZ.js';
|
|
7
7
|
export { t as time } from './time-DbT8fjaF.js';
|
|
8
8
|
export { u as units } from './units-6lwDYBvX.js';
|
|
9
|
-
export { n as network } from './network-
|
|
10
|
-
export { a as api } from './api-
|
|
9
|
+
export { n as network } from './network-DwyAjwJS.js';
|
|
10
|
+
export { a as api } from './api-Xl7OzIgq.js';
|
|
11
11
|
export { c as code } from './code-BUqyaofO.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';
|
|
15
15
|
export { a as ai_agent } from './ai_agent-CcpkV2DR.js';
|
|
16
|
-
export { m as media } from './media-
|
|
16
|
+
export { m as media } from './media-D-K5aZnq.js';
|
|
17
17
|
|
|
18
18
|
declare const version = "0.1.0";
|
|
19
19
|
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { media_exports as media } from './chunk-
|
|
1
|
+
export { media_exports as media } from './chunk-WWKPLYEP.js';
|
|
2
2
|
export { units_exports as units } from './chunk-QJE743LY.js';
|
|
3
|
-
export { network_exports as network } from './chunk-
|
|
4
|
-
export { api_exports as api } from './chunk-
|
|
3
|
+
export { network_exports as network } from './chunk-V5JKVDBA.js';
|
|
4
|
+
export { api_exports as api } from './chunk-Q3B3YWOA.js';
|
|
5
5
|
export { code_exports as code } from './chunk-V5S6OJ4A.js';
|
|
6
6
|
export { color_exports as color } from './chunk-BPVAB4P2.js';
|
|
7
7
|
export { css_exports as css } from './chunk-6YPV2AB5.js';
|
|
@@ -11,7 +11,7 @@ export { json_exports as json } from './chunk-TSAGO3XP.js';
|
|
|
11
11
|
export { encoding_exports as encoding } from './chunk-IPR7FSX4.js';
|
|
12
12
|
export { hashing_exports as hashing } from './chunk-FL53T24A.js';
|
|
13
13
|
export { text_exports as text } from './chunk-YBBYFAOV.js';
|
|
14
|
-
export { data_exports as data } from './chunk-
|
|
14
|
+
export { data_exports as data } from './chunk-DNCOIO5N.js';
|
|
15
15
|
export { generators_exports as generators } from './chunk-2CJSLYWI.js';
|
|
16
16
|
export { time_exports as time } from './chunk-ZPQZEIXP.js';
|
|
17
17
|
import './chunk-MLKGABMK.js';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
type ImageFormat = 'png' | 'jpeg' | 'gif' | 'webp' | 'bmp';
|
|
2
|
+
interface ImageInfo {
|
|
3
|
+
format: ImageFormat;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
bitDepth?: number;
|
|
7
|
+
colorType?: string;
|
|
8
|
+
hasAlpha?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface ImageInfoError {
|
|
11
|
+
error: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Read image format, dimensions, and basic color info straight from file
|
|
15
|
+
* bytes — no decoding, no image library, no canvas. Supports PNG, JPEG,
|
|
16
|
+
* GIF, WebP, and BMP.
|
|
17
|
+
*/
|
|
18
|
+
declare function readImageInfo(bytes: Uint8Array): ImageInfo | ImageInfoError;
|
|
19
|
+
interface PdfMetadata {
|
|
20
|
+
version: string | null;
|
|
21
|
+
pageCount: number | null;
|
|
22
|
+
title: string | null;
|
|
23
|
+
author: string | null;
|
|
24
|
+
subject: string | null;
|
|
25
|
+
keywords: string | null;
|
|
26
|
+
creator: string | null;
|
|
27
|
+
producer: string | null;
|
|
28
|
+
creationDate: string | null;
|
|
29
|
+
modDate: string | null;
|
|
30
|
+
encrypted: boolean;
|
|
31
|
+
}
|
|
32
|
+
interface PdfMetadataError {
|
|
33
|
+
error: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Read PDF metadata (title, author, dates, page count, encryption flag)
|
|
37
|
+
* straight from the file's trailer/Info dictionary and page tree — no
|
|
38
|
+
* pdf.js or other PDF rendering library required.
|
|
39
|
+
*/
|
|
40
|
+
declare function readPdfMetadata(bytes: Uint8Array): PdfMetadata | PdfMetadataError;
|
|
41
|
+
|
|
42
|
+
type media_ImageFormat = ImageFormat;
|
|
43
|
+
type media_ImageInfo = ImageInfo;
|
|
44
|
+
type media_ImageInfoError = ImageInfoError;
|
|
45
|
+
type media_PdfMetadata = PdfMetadata;
|
|
46
|
+
type media_PdfMetadataError = PdfMetadataError;
|
|
47
|
+
declare const media_readImageInfo: typeof readImageInfo;
|
|
48
|
+
declare const media_readPdfMetadata: typeof readPdfMetadata;
|
|
49
|
+
declare namespace media {
|
|
50
|
+
export { type media_ImageFormat as ImageFormat, type media_ImageInfo as ImageInfo, type media_ImageInfoError as ImageInfoError, type media_PdfMetadata as PdfMetadata, type media_PdfMetadataError as PdfMetadataError, media_readImageInfo as readImageInfo, media_readPdfMetadata as readPdfMetadata };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { type ImageFormat as I, type PdfMetadata as P, type ImageInfo as a, type ImageInfoError as b, type PdfMetadataError as c, readPdfMetadata as d, media as m, readImageInfo as r };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
type ImageFormat = 'png' | 'jpeg' | 'gif' | 'webp' | 'bmp';
|
|
2
|
+
interface ImageInfo {
|
|
3
|
+
format: ImageFormat;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
bitDepth?: number;
|
|
7
|
+
colorType?: string;
|
|
8
|
+
hasAlpha?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface ImageInfoError {
|
|
11
|
+
error: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Read image format, dimensions, and basic color info straight from file
|
|
15
|
+
* bytes — no decoding, no image library, no canvas. Supports PNG, JPEG,
|
|
16
|
+
* GIF, WebP, and BMP.
|
|
17
|
+
*/
|
|
18
|
+
declare function readImageInfo(bytes: Uint8Array): ImageInfo | ImageInfoError;
|
|
19
|
+
interface PdfMetadata {
|
|
20
|
+
version: string | null;
|
|
21
|
+
pageCount: number | null;
|
|
22
|
+
title: string | null;
|
|
23
|
+
author: string | null;
|
|
24
|
+
subject: string | null;
|
|
25
|
+
keywords: string | null;
|
|
26
|
+
creator: string | null;
|
|
27
|
+
producer: string | null;
|
|
28
|
+
creationDate: string | null;
|
|
29
|
+
modDate: string | null;
|
|
30
|
+
encrypted: boolean;
|
|
31
|
+
}
|
|
32
|
+
interface PdfMetadataError {
|
|
33
|
+
error: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Read PDF metadata (title, author, dates, page count, encryption flag)
|
|
37
|
+
* straight from the file's trailer/Info dictionary and page tree — no
|
|
38
|
+
* pdf.js or other PDF rendering library required.
|
|
39
|
+
*/
|
|
40
|
+
declare function readPdfMetadata(bytes: Uint8Array): PdfMetadata | PdfMetadataError;
|
|
41
|
+
|
|
42
|
+
type media_ImageFormat = ImageFormat;
|
|
43
|
+
type media_ImageInfo = ImageInfo;
|
|
44
|
+
type media_ImageInfoError = ImageInfoError;
|
|
45
|
+
type media_PdfMetadata = PdfMetadata;
|
|
46
|
+
type media_PdfMetadataError = PdfMetadataError;
|
|
47
|
+
declare const media_readImageInfo: typeof readImageInfo;
|
|
48
|
+
declare const media_readPdfMetadata: typeof readPdfMetadata;
|
|
49
|
+
declare namespace media {
|
|
50
|
+
export { type media_ImageFormat as ImageFormat, type media_ImageInfo as ImageInfo, type media_ImageInfoError as ImageInfoError, type media_PdfMetadata as PdfMetadata, type media_PdfMetadataError as PdfMetadataError, media_readImageInfo as readImageInfo, media_readPdfMetadata as readPdfMetadata };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { type ImageFormat as I, type PdfMetadata as P, type ImageInfo as a, type ImageInfoError as b, type PdfMetadataError as c, readPdfMetadata as d, media as m, readImageInfo as r };
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* - ip-geolocation: IP address geolocation via ip-api.com
|
|
8
8
|
* - http-status : HTTP status code lookup and search
|
|
9
9
|
* - http-headers : HTTP header reference lookup and validation
|
|
10
|
+
* - har-viewer : parseHar
|
|
10
11
|
*/
|
|
11
12
|
declare const DNS_RECORD_TYPES: readonly ["A", "AAAA", "CNAME", "MX", "TXT", "NS", "SOA", "PTR", "SRV", "CAA"];
|
|
12
13
|
type DnsRecordType = typeof DNS_RECORD_TYPES[number];
|
|
@@ -124,6 +125,38 @@ declare function validateHeaderValue(name: string, value: string): {
|
|
|
124
125
|
valid: boolean;
|
|
125
126
|
warning?: string;
|
|
126
127
|
};
|
|
128
|
+
interface HarEntry {
|
|
129
|
+
method: string;
|
|
130
|
+
url: string;
|
|
131
|
+
status: number;
|
|
132
|
+
statusText: string;
|
|
133
|
+
httpVersion: string;
|
|
134
|
+
mimeType: string;
|
|
135
|
+
size: number;
|
|
136
|
+
time: number;
|
|
137
|
+
startedDateTime: string;
|
|
138
|
+
}
|
|
139
|
+
interface HarSummary {
|
|
140
|
+
totalRequests: number;
|
|
141
|
+
totalSize: number;
|
|
142
|
+
totalTime: number;
|
|
143
|
+
avgTime: number;
|
|
144
|
+
failedRequests: number;
|
|
145
|
+
methods: Record<string, number>;
|
|
146
|
+
statusCodes: Record<string, number>;
|
|
147
|
+
}
|
|
148
|
+
interface HarParseResult {
|
|
149
|
+
version: string;
|
|
150
|
+
creator: {
|
|
151
|
+
name: string;
|
|
152
|
+
version: string;
|
|
153
|
+
};
|
|
154
|
+
entries: HarEntry[];
|
|
155
|
+
summary: HarSummary;
|
|
156
|
+
}
|
|
157
|
+
declare function parseHar(input: string): HarParseResult | {
|
|
158
|
+
error: string;
|
|
159
|
+
};
|
|
127
160
|
|
|
128
161
|
declare const network_DNS_RECORD_TYPES: typeof DNS_RECORD_TYPES;
|
|
129
162
|
type network_DnsRecord = DnsRecord;
|
|
@@ -131,6 +164,9 @@ type network_DnsRecordType = DnsRecordType;
|
|
|
131
164
|
type network_DnsResponse = DnsResponse;
|
|
132
165
|
type network_GeoResult = GeoResult;
|
|
133
166
|
declare const network_HTTP_HEADERS: typeof HTTP_HEADERS;
|
|
167
|
+
type network_HarEntry = HarEntry;
|
|
168
|
+
type network_HarParseResult = HarParseResult;
|
|
169
|
+
type network_HarSummary = HarSummary;
|
|
134
170
|
type network_HeaderCategory = HeaderCategory;
|
|
135
171
|
type network_HttpHeader = HttpHeader;
|
|
136
172
|
type network_ParsedDnsResult = ParsedDnsResult;
|
|
@@ -156,6 +192,7 @@ declare const network_isValidIpv4: typeof isValidIpv4;
|
|
|
156
192
|
declare const network_isValidIpv6: typeof isValidIpv6;
|
|
157
193
|
declare const network_parseDnsResponse: typeof parseDnsResponse;
|
|
158
194
|
declare const network_parseGeoResponse: typeof parseGeoResponse;
|
|
195
|
+
declare const network_parseHar: typeof parseHar;
|
|
159
196
|
declare const network_searchHeaders: typeof searchHeaders;
|
|
160
197
|
declare const network_searchStatusCodes: typeof searchStatusCodes;
|
|
161
198
|
declare const network_statusCodeToText: typeof statusCodeToText;
|
|
@@ -164,7 +201,7 @@ declare const network_validateDomain: typeof validateDomain;
|
|
|
164
201
|
declare const network_validateHeaderName: typeof validateHeaderName;
|
|
165
202
|
declare const network_validateHeaderValue: typeof validateHeaderValue;
|
|
166
203
|
declare namespace network {
|
|
167
|
-
export { network_DNS_RECORD_TYPES as DNS_RECORD_TYPES, type network_DnsRecord as DnsRecord, type network_DnsRecordType as DnsRecordType, type network_DnsResponse as DnsResponse, type network_GeoResult as GeoResult, network_HTTP_HEADERS as HTTP_HEADERS, type network_HeaderCategory as HeaderCategory, type network_HttpHeader as HttpHeader, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, network_STATUS_CODES as STATUS_CODES, type network_StatusCode as StatusCode, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildMapUrl as buildMapUrl, network_countryCodeToFlag as countryCodeToFlag, network_formatCoordinates as formatCoordinates, network_formatTtl as formatTtl, network_getByCategory as getByCategory, network_getHeader as getHeader, network_getHeadersByCategory as getHeadersByCategory, network_getStatusByCategory as getStatusByCategory, network_getStatusCode as getStatusCode, network_isClientError as isClientError, network_isServerError as isServerError, network_isSuccess as isSuccess, network_isValidIp as isValidIp, network_isValidIpv4 as isValidIpv4, network_isValidIpv6 as isValidIpv6, network_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_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 };
|
|
204
|
+
export { network_DNS_RECORD_TYPES as DNS_RECORD_TYPES, type network_DnsRecord as DnsRecord, type network_DnsRecordType as DnsRecordType, type network_DnsResponse as DnsResponse, type network_GeoResult as GeoResult, network_HTTP_HEADERS as HTTP_HEADERS, type network_HarEntry as HarEntry, type network_HarParseResult as HarParseResult, type network_HarSummary as HarSummary, type network_HeaderCategory as HeaderCategory, type network_HttpHeader as HttpHeader, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, network_STATUS_CODES as STATUS_CODES, type network_StatusCode as StatusCode, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildMapUrl as buildMapUrl, network_countryCodeToFlag as countryCodeToFlag, network_formatCoordinates as formatCoordinates, network_formatTtl as formatTtl, network_getByCategory as getByCategory, network_getHeader as getHeader, network_getHeadersByCategory as getHeadersByCategory, network_getStatusByCategory as getStatusByCategory, network_getStatusCode as getStatusCode, network_isClientError as isClientError, network_isServerError as isServerError, network_isSuccess as isSuccess, network_isValidIp as isValidIp, network_isValidIpv4 as isValidIpv4, network_isValidIpv6 as isValidIpv6, network_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_searchHeaders as searchHeaders, network_searchStatusCodes as searchStatusCodes, network_statusCodeToText as statusCodeToText, network_typeNumberToLabel as typeNumberToLabel, network_validateDomain as validateDomain, network_validateHeaderName as validateHeaderName, network_validateHeaderValue as validateHeaderValue };
|
|
168
205
|
}
|
|
169
206
|
|
|
170
|
-
export {
|
|
207
|
+
export { isValidIpv4 as A, isValidIpv6 as B, parseDnsResponse as C, DNS_RECORD_TYPES as D, parseGeoResponse as E, parseHar as F, type GeoResult as G, HTTP_HEADERS as H, searchHeaders as I, searchStatusCodes as J, statusCodeToText as K, typeNumberToLabel as L, validateDomain as M, validateHeaderName as N, validateHeaderValue as O, type ParsedDnsResult as P, STATUS_CODES as S, type DnsRecord as a, type DnsRecordType as b, type DnsResponse as c, type HarEntry as d, type HarParseResult as e, type HarSummary as f, type HeaderCategory as g, type HttpHeader as h, type ParsedGeoResult as i, type StatusCode as j, buildDnsQueryUrl as k, buildGeoUrl as l, buildMapUrl as m, network as n, countryCodeToFlag as o, formatCoordinates as p, formatTtl as q, getByCategory as r, getHeader as s, getHeadersByCategory as t, getStatusByCategory as u, getStatusCode as v, isClientError as w, isServerError as x, isSuccess as y, isValidIp as z };
|