@utilix-tech/sdk 0.29.0 → 0.30.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 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.30.0
6
+ - Add `jsonSchemaToTypescript` (json-schema-to-typescript): convert a JSON Schema document into TypeScript interfaces/types, reading `required`/`enum`/`oneOf`/`anyOf`/`allOf`/`$ref` directly instead of inferring from an example payload.
7
+ - Add `estimatePasswordEntropy` (password-entropy-estimator): bits of entropy from a password's character pool, a strength label, and crack-time estimates across four guess-rate scenarios.
8
+
5
9
  ## 0.29.0
6
10
  - Add `readPdfPageDimensions` (pdf-page-dimensions): each page's MediaBox width/height (points and inches), rotation, and orientation, walking the Root -> Pages -> Kids tree and inheriting from ancestor nodes, plus a common paper size match (Letter, A4, etc.).
7
11
  - Add `parseIpv6Address` (ipv6-compressor): expand an IPv6 address to its full 8-group form or compress it to its RFC 5952 canonical shortest form, classify its address type, and handle an embedded IPv4 suffix or zone ID.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @utilix-tech/sdk
2
2
 
3
- **581 developer utility functions for Node.js: runs locally, no API key required.**
3
+ **583 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)
@@ -65,7 +65,7 @@ const { formatJson } = require("@utilix-tech/sdk/json");
65
65
  ### `/json`: JSON Tools
66
66
 
67
67
  ```ts
68
- import { formatJson, minifyJson, diffJson, jsonToTypescript, validateJson,
68
+ import { formatJson, minifyJson, diffJson, jsonToTypescript, jsonSchemaToTypescript, validateJson,
69
69
  evaluateJsonPath, resolveJsonPointer, jsonToCsv, yamlToJson, jsonToYaml, getJsonStats } from "@utilix-tech/sdk/json";
70
70
 
71
71
  // Format with 2-space indent
@@ -77,6 +77,9 @@ diffJson(jsonA, jsonB);
77
77
  // Generate TypeScript interface from JSON
78
78
  jsonToTypescript('{"id":1,"name":"Alice"}', { rootName: "User" });
79
79
 
80
+ // Generate TypeScript interfaces from a JSON Schema (reads required/enum/$ref directly)
81
+ jsonSchemaToTypescript('{"type":"object","properties":{"name":{"type":"string"}},"required":["name"]}', { rootName: "User" });
82
+
80
83
  // Query with JSONPath
81
84
  evaluateJsonPath(obj, "$.users[*].name");
82
85
 
@@ -222,14 +225,17 @@ shiftSubtitles("1\n00:00:01,000 --> 00:00:04,000\nHi\n", -2.5);
222
225
 
223
226
  ```ts
224
227
  import { generateUuid, generateV4, generateV7, generateUlid,
225
- generatePassword, checkStrength, generateData } from "@utilix-tech/sdk/generators";
228
+ generatePassword, checkStrength, estimatePasswordEntropy, generateData } from "@utilix-tech/sdk/generators";
226
229
 
227
230
  generateUuid(); // "f47ac10b-58cc-4372-a567-0e02b2c3d479" (v4)
228
231
  generateV7(); // time-ordered UUID v7
229
232
  generateUlid(); // "01ARZ3NDEKTSV4RRFFQ69G5FAV"
230
233
 
231
234
  generatePassword({ length: 16, symbols: true, numbers: true });
232
- checkStrength("P@ssw0rd!"); // { score: 4, label: "Strong", entropy: 52.4 }
235
+ checkStrength("P@ssw0rd!"); // { score: 4, label: "Strong", color: "#16a34a" }
236
+
237
+ // Actual bits of entropy from the character pool, plus crack-time estimates
238
+ estimatePasswordEntropy("Tr0ub4dor&3xyzKL9!"); // { entropyBits: 118.26, strength: "strong", crackTimes: [...] }
233
239
 
234
240
  // Generate fake data rows
235
241
  generateData([
@@ -637,12 +643,12 @@ readVideoInfo(new Uint8Array(videoBytes));
637
643
 
638
644
  | Import | What it does |
639
645
  |---|---|
640
- | `@utilix-tech/sdk/json` | Format, minify, diff, validate, JSONPath, CSV↔JSON, YAML↔JSON, TS types |
646
+ | `@utilix-tech/sdk/json` | Format, minify, diff, validate, JSONPath, CSV↔JSON, YAML↔JSON, TS types from data or from a JSON Schema |
641
647
  | `@utilix-tech/sdk/encoding` | Base64, URL, HTML entities, Base32/Base58/Base62 encode/decode |
642
648
  | `@utilix-tech/sdk/hashing` | MD5, SHA-1/256/512, bcrypt, HMAC, .htpasswd |
643
649
  | `@utilix-tech/sdk/text` | Case convert, slugify, word count, lorem ipsum, line ops, HTML→Markdown, Levenshtein/Damerau string distance |
644
650
  | `@utilix-tech/sdk/data` | CSV, YAML, TOML, XML, INI, NDJSON parse and convert, SRT/WebVTT subtitles |
645
- | `@utilix-tech/sdk/generators` | UUID v4/v7, ULID, passwords, strength check, fake data |
651
+ | `@utilix-tech/sdk/generators` | UUID v4/v7, ULID, passwords, strength check, entropy estimator, fake data |
646
652
  | `@utilix-tech/sdk/time` | Date diff, timezone convert, cron parse, relative time |
647
653
  | `@utilix-tech/sdk/units` | Bytes, CSS px/rem, number bases, currency format, credit card/IBAN/barcode/ISBN validation, loan calculator, compound/simple interest calculators, VAT/sales tax calculator, tip/bill split calculator, break-even point calculator, Rule of 72 calculator |
648
654
  | `@utilix-tech/sdk/network` | HTTP status codes, IP validation, country flags, geolocation URLs, HAR file parsing, User-Agent parsing, IPv6 address compress/expand |
@@ -12,6 +12,7 @@ __export(generators_exports, {
12
12
  SYMBOL_CHARS: () => SYMBOL_CHARS,
13
13
  ULID_REGEX: () => ULID_REGEX,
14
14
  checkStrength: () => checkStrength,
15
+ estimatePasswordEntropy: () => estimatePasswordEntropy,
15
16
  generateBulk: () => generateBulk,
16
17
  generateBulkPasswords: () => generateBulkPasswords,
17
18
  generateBulkUlids: () => generateBulkUlids,
@@ -228,6 +229,111 @@ function checkStrength(password) {
228
229
  color: levels[score].color
229
230
  };
230
231
  }
232
+ var _SYMBOL_POOL_CHARS = " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
233
+ var _SYMBOL_POOL_SET = new Set(_SYMBOL_POOL_CHARS.split(""));
234
+ function _hasSymbolChar(password) {
235
+ for (const ch of password) {
236
+ if (_SYMBOL_POOL_SET.has(ch)) return true;
237
+ }
238
+ return false;
239
+ }
240
+ function _hasSequentialRun(password, minRun) {
241
+ let ascRun = 1;
242
+ let descRun = 1;
243
+ for (let i = 1; i < password.length; i++) {
244
+ const prev = password.charCodeAt(i - 1);
245
+ const curr = password.charCodeAt(i);
246
+ if (curr === prev + 1) {
247
+ ascRun++;
248
+ descRun = 1;
249
+ } else if (curr === prev - 1) {
250
+ descRun++;
251
+ ascRun = 1;
252
+ } else {
253
+ ascRun = 1;
254
+ descRun = 1;
255
+ }
256
+ if (ascRun >= minRun || descRun >= minRun) return true;
257
+ }
258
+ return false;
259
+ }
260
+ function _formatCrackDuration(seconds) {
261
+ if (!isFinite(seconds)) return "effectively never";
262
+ if (seconds < 1) return "instantly";
263
+ const units = [
264
+ ["century", 315576e4],
265
+ ["year", 31557600],
266
+ ["month", 2629800],
267
+ ["day", 86400],
268
+ ["hour", 3600],
269
+ ["minute", 60],
270
+ ["second", 1]
271
+ ];
272
+ for (const [name, unitSeconds] of units) {
273
+ if (seconds >= unitSeconds) {
274
+ const value = seconds / unitSeconds;
275
+ if (name === "century" && value > 1e3) return "longer than the age of the universe";
276
+ const rounded = value >= 100 ? Math.round(value) : Math.round(value * 10) / 10;
277
+ const plural = name === "century" ? "centuries" : `${name}s`;
278
+ return `${rounded} ${rounded === 1 ? name : plural}`;
279
+ }
280
+ }
281
+ return "instantly";
282
+ }
283
+ function estimatePasswordEntropy(password) {
284
+ if (!password) return { error: "Password is required" };
285
+ const hasLowercase = /[a-z]/.test(password);
286
+ const hasUppercase = /[A-Z]/.test(password);
287
+ const hasDigits = /[0-9]/.test(password);
288
+ const hasSymbols = _hasSymbolChar(password);
289
+ const hasOther = /[^\x20-\x7e]/.test(password);
290
+ let poolSize = 0;
291
+ if (hasLowercase) poolSize += 26;
292
+ if (hasUppercase) poolSize += 26;
293
+ if (hasDigits) poolSize += 10;
294
+ if (hasSymbols) poolSize += _SYMBOL_POOL_CHARS.length;
295
+ if (hasOther) poolSize += 100;
296
+ const entropyBits = Math.round(password.length * Math.log2(poolSize) * 100) / 100;
297
+ let strength;
298
+ if (entropyBits < 28) strength = "very-weak";
299
+ else if (entropyBits < 36) strength = "weak";
300
+ else if (entropyBits < 60) strength = "fair";
301
+ else if (entropyBits < 128) strength = "strong";
302
+ else strength = "very-strong";
303
+ const averageGuesses = Math.pow(2, entropyBits) / 2;
304
+ const scenarios = [
305
+ { scenario: "Online, throttled (100 guesses/hour)", guessesPerSecond: 100 / 3600 },
306
+ { scenario: "Online, unthrottled (10 guesses/sec)", guessesPerSecond: 10 },
307
+ { scenario: "Offline, slow hash e.g. bcrypt (10k guesses/sec)", guessesPerSecond: 1e4 },
308
+ { scenario: "Offline, fast hash / GPU cluster (10B guesses/sec)", guessesPerSecond: 1e10 }
309
+ ];
310
+ const crackTimes = scenarios.map((s) => ({
311
+ scenario: s.scenario,
312
+ guessesPerSecond: s.guessesPerSecond,
313
+ humanReadable: _formatCrackDuration(averageGuesses / s.guessesPerSecond)
314
+ }));
315
+ const warnings = [];
316
+ if (password.length < 8) {
317
+ warnings.push("Shorter than 8 characters \u2014 most sites and cracking tools treat this as trivially weak regardless of entropy.");
318
+ }
319
+ if (/(.)\1{2,}/.test(password)) {
320
+ warnings.push('Contains a repeated character run (e.g. "aaa"), which is easier to guess than the entropy figure implies.');
321
+ }
322
+ if (_hasSequentialRun(password, 3)) {
323
+ warnings.push('Contains a sequential run (e.g. "abc" or "321"), which is easier to guess than the entropy figure implies.');
324
+ }
325
+ if (poolSize <= 26) {
326
+ warnings.push("Uses only one character class \u2014 mixing in uppercase, digits, or symbols raises the character pool and entropy.");
327
+ }
328
+ return {
329
+ length: password.length,
330
+ charset: { hasLowercase, hasUppercase, hasDigits, hasSymbols, hasOther, poolSize },
331
+ entropyBits,
332
+ strength,
333
+ crackTimes,
334
+ warnings
335
+ };
336
+ }
231
337
  var DATA_TYPES = [
232
338
  { value: "name", label: "Full Name", example: "John Smith" },
233
339
  { value: "email", label: "Email Address", example: "john.smith@gmail.com" },
@@ -517,4 +623,4 @@ async function generateQrDataUrl(text, options) {
517
623
  });
518
624
  }
519
625
 
520
- export { AMBIGUOUS_CHARS, DATA_TYPES, DEFAULT_OPTIONS, DEFAULT_QR_OPTIONS, SYMBOL_CHARS, ULID_REGEX, checkStrength, generateBulk, generateBulkPasswords, generateBulkUlids, generateData, generatePassword, generateQrDataUrl, generateQrSvg, generateSingle, generateUlid, generateUuid, generateV4, generateV7, generators_exports, isValidUlid, isValidUuid, parseUlid, parseUuidVersion };
626
+ export { AMBIGUOUS_CHARS, DATA_TYPES, DEFAULT_OPTIONS, DEFAULT_QR_OPTIONS, SYMBOL_CHARS, ULID_REGEX, checkStrength, estimatePasswordEntropy, generateBulk, generateBulkPasswords, generateBulkUlids, generateData, generatePassword, generateQrDataUrl, generateQrSvg, generateSingle, generateUlid, generateUuid, generateV4, generateV7, generators_exports, isValidUlid, isValidUuid, parseUlid, parseUuidVersion };
@@ -15,6 +15,7 @@ __export(json_exports, {
15
15
  inferGoType: () => inferGoType,
16
16
  inferPythonType: () => inferPythonType,
17
17
  inferType: () => inferType,
18
+ jsonSchemaToTypescript: () => jsonSchemaToTypescript,
18
19
  jsonToCsv: () => jsonToCsv,
19
20
  jsonToGo: () => jsonToGo,
20
21
  jsonToPython: () => jsonToPython,
@@ -1302,5 +1303,104 @@ function resolveJsonPointer(json, pointer) {
1302
1303
  }
1303
1304
  return { pointer, found: true, value: current, tokens };
1304
1305
  }
1306
+ function _schemaRefName(ref) {
1307
+ const parts = ref.split("/");
1308
+ return _capitalize(parts[parts.length - 1] || "Ref");
1309
+ }
1310
+ function _schemaLiteralType(value) {
1311
+ if (typeof value === "string") return JSON.stringify(value);
1312
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
1313
+ if (value === null) return "null";
1314
+ return JSON.stringify(value);
1315
+ }
1316
+ function _safePropertyKey(key) {
1317
+ return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : JSON.stringify(key);
1318
+ }
1319
+ function _schemaToTsType(schema, name, interfaces) {
1320
+ if (schema.$ref) return _schemaRefName(schema.$ref);
1321
+ if (schema.const !== void 0) return _schemaLiteralType(schema.const);
1322
+ if (schema.enum) return schema.enum.map(_schemaLiteralType).join(" | ");
1323
+ if (schema.oneOf) return schema.oneOf.map((s, i) => _schemaToTsType(s, `${name}Variant${i}`, interfaces)).join(" | ");
1324
+ if (schema.anyOf) return schema.anyOf.map((s, i) => _schemaToTsType(s, `${name}Variant${i}`, interfaces)).join(" | ");
1325
+ if (schema.allOf) return schema.allOf.map((s, i) => _schemaToTsType(s, `${name}Part${i}`, interfaces)).join(" & ");
1326
+ const types = Array.isArray(schema.type) ? schema.type : schema.type ? [schema.type] : [];
1327
+ const nullable = types.includes("null");
1328
+ const nonNullTypes = types.filter((t) => t !== "null");
1329
+ const primaryType = nonNullTypes[0] ?? (schema.properties || schema.additionalProperties !== void 0 ? "object" : void 0);
1330
+ let result;
1331
+ switch (primaryType) {
1332
+ case "string":
1333
+ result = "string";
1334
+ break;
1335
+ case "number":
1336
+ case "integer":
1337
+ result = "number";
1338
+ break;
1339
+ case "boolean":
1340
+ result = "boolean";
1341
+ break;
1342
+ case "array": {
1343
+ const itemsSchema = Array.isArray(schema.items) ? schema.items[0] : schema.items;
1344
+ const itemType = itemsSchema ? _schemaToTsType(itemsSchema, `${name}Item`, interfaces) : "unknown";
1345
+ result = `${itemType}[]`;
1346
+ break;
1347
+ }
1348
+ case "object": {
1349
+ _buildSchemaInterface(schema, name, interfaces);
1350
+ result = name;
1351
+ break;
1352
+ }
1353
+ default:
1354
+ result = "unknown";
1355
+ }
1356
+ return nullable ? `${result} | null` : result;
1357
+ }
1358
+ function _buildSchemaInterface(schema, name, interfaces) {
1359
+ if (interfaces.has(name)) return;
1360
+ const required = new Set(schema.required ?? []);
1361
+ const lines = [`interface ${name} {`];
1362
+ for (const [key, propSchema] of Object.entries(schema.properties ?? {})) {
1363
+ if (propSchema.description) lines.push(` /** ${propSchema.description} */`);
1364
+ const optional = required.has(key) ? "" : "?";
1365
+ const propType = _schemaToTsType(propSchema, _capitalize(key), interfaces);
1366
+ lines.push(` ${_safePropertyKey(key)}${optional}: ${propType};`);
1367
+ }
1368
+ if (schema.additionalProperties === true) {
1369
+ lines.push(" [key: string]: unknown;");
1370
+ } else if (schema.additionalProperties && typeof schema.additionalProperties === "object") {
1371
+ const addType = _schemaToTsType(schema.additionalProperties, `${name}Value`, interfaces);
1372
+ lines.push(` [key: string]: ${addType};`);
1373
+ }
1374
+ lines.push("}");
1375
+ interfaces.set(name, lines.join("\n"));
1376
+ }
1377
+ function jsonSchemaToTypescript(schemaJson, options) {
1378
+ let schema;
1379
+ try {
1380
+ schema = JSON.parse(schemaJson);
1381
+ } catch {
1382
+ return { error: "Invalid JSON input" };
1383
+ }
1384
+ if (typeof schema !== "object" || schema === null || Array.isArray(schema)) {
1385
+ return { error: "Schema must be a JSON object" };
1386
+ }
1387
+ const rootName = options?.rootName ?? "Root";
1388
+ const typedSchema = schema;
1389
+ const interfaces = /* @__PURE__ */ new Map();
1390
+ const defs = { ...typedSchema.$defs ?? {}, ...typedSchema.definitions ?? {} };
1391
+ for (const [defName, defSchema] of Object.entries(defs)) {
1392
+ const defTypeName = _capitalize(defName);
1393
+ const defType = _schemaToTsType(defSchema, defTypeName, interfaces);
1394
+ if (!interfaces.has(defTypeName)) {
1395
+ interfaces.set(defTypeName, `type ${defTypeName} = ${defType};`);
1396
+ }
1397
+ }
1398
+ const rootType = _schemaToTsType(typedSchema, rootName, interfaces);
1399
+ const parts = [...interfaces.values()];
1400
+ if (!interfaces.has(rootName)) {
1401
+ parts.push(`type ${rootName} = ${rootType};`);
1402
+ }
1403
+ return parts.join("\n\n");
1404
+ }
1305
1405
 
1306
- export { csvToJson, detectFormat, diffJson, evaluateJsonPath, formatDiffLine, formatJson, generateExample, getJsonStats, inferGoType, inferPythonType, inferType, jsonToCsv, jsonToGo, jsonToPython, jsonToTypescript, jsonToYaml, jsonToZod, json_exports, minifyJson, parseJson, parseStructs, resolveJsonPointer, toPascalCase, toSnakeCase, validateJson, validateJsonPath, validateJsonString, yamlToJson };
1406
+ export { csvToJson, detectFormat, diffJson, evaluateJsonPath, formatDiffLine, formatJson, generateExample, getJsonStats, inferGoType, inferPythonType, inferType, jsonSchemaToTypescript, jsonToCsv, jsonToGo, jsonToPython, jsonToTypescript, jsonToYaml, jsonToZod, json_exports, minifyJson, parseJson, parseStructs, resolveJsonPointer, toPascalCase, toSnakeCase, validateJson, validateJsonPath, validateJsonString, yamlToJson };
@@ -7,6 +7,7 @@
7
7
  * - uuid-generator : generateV4, generateV7, generateUuid, generateBulk, isValidUuid, parseUuidVersion
8
8
  * - ulid-generator : generateUlid, generateBulkUlids, parseUlid, isValidUlid
9
9
  * - password-generator : generatePassword, generateBulkPasswords, checkStrength
10
+ * - password-entropy-estimator : estimatePasswordEntropy
10
11
  * - random-data : generateSingle, generateData
11
12
  * - qr-code : generateQrSvg, generateQrDataUrl
12
13
  */
@@ -50,6 +51,43 @@ declare function checkStrength(password: string): {
50
51
  label: 'Very Weak' | 'Weak' | 'Fair' | 'Strong' | 'Very Strong';
51
52
  color: string;
52
53
  };
54
+ interface PasswordCharsetInfo {
55
+ hasLowercase: boolean;
56
+ hasUppercase: boolean;
57
+ hasDigits: boolean;
58
+ hasSymbols: boolean;
59
+ hasOther: boolean;
60
+ poolSize: number;
61
+ }
62
+ interface PasswordCrackTimeEstimate {
63
+ scenario: string;
64
+ guessesPerSecond: number;
65
+ humanReadable: string;
66
+ }
67
+ type PasswordEntropyStrength = 'very-weak' | 'weak' | 'fair' | 'strong' | 'very-strong';
68
+ interface PasswordEntropyResult {
69
+ length: number;
70
+ charset: PasswordCharsetInfo;
71
+ entropyBits: number;
72
+ strength: PasswordEntropyStrength;
73
+ crackTimes: PasswordCrackTimeEstimate[];
74
+ warnings: string[];
75
+ }
76
+ /**
77
+ * Estimate a password's entropy in bits from the character classes it
78
+ * actually draws from (lowercase, uppercase, digits, symbols, other/Unicode),
79
+ * then derive a strength label and crack-time estimates at a few realistic
80
+ * guess rates. This is the classic pool-size x length method, the same
81
+ * approach used by most public entropy calculators: it measures resistance
82
+ * to brute force over the theoretical character space, not real-world
83
+ * guessability against a breach-database or dictionary attack — a common
84
+ * word with substitutions can score high here while being easy to guess in
85
+ * practice, which is why the pattern-based warnings below exist alongside
86
+ * the raw entropy figure rather than folded into it.
87
+ */
88
+ declare function estimatePasswordEntropy(password: string): PasswordEntropyResult | {
89
+ error: string;
90
+ };
53
91
  type DataType = 'name' | 'email' | 'uuid' | 'phone' | 'date' | 'number' | 'boolean' | 'color' | 'url' | 'ipv4' | 'sentence' | 'paragraph';
54
92
  interface RandomConfig {
55
93
  type: DataType;
@@ -86,6 +124,10 @@ declare const generators_DEFAULT_OPTIONS: typeof DEFAULT_OPTIONS;
86
124
  declare const generators_DEFAULT_QR_OPTIONS: typeof DEFAULT_QR_OPTIONS;
87
125
  type generators_DataType = DataType;
88
126
  type generators_GeneratedUuid = GeneratedUuid;
127
+ type generators_PasswordCharsetInfo = PasswordCharsetInfo;
128
+ type generators_PasswordCrackTimeEstimate = PasswordCrackTimeEstimate;
129
+ type generators_PasswordEntropyResult = PasswordEntropyResult;
130
+ type generators_PasswordEntropyStrength = PasswordEntropyStrength;
89
131
  type generators_PasswordOptions = PasswordOptions;
90
132
  type generators_QrErrorLevel = QrErrorLevel;
91
133
  type generators_QrOptions = QrOptions;
@@ -95,6 +137,7 @@ declare const generators_SYMBOL_CHARS: typeof SYMBOL_CHARS;
95
137
  declare const generators_ULID_REGEX: typeof ULID_REGEX;
96
138
  type generators_UuidVersion = UuidVersion;
97
139
  declare const generators_checkStrength: typeof checkStrength;
140
+ declare const generators_estimatePasswordEntropy: typeof estimatePasswordEntropy;
98
141
  declare const generators_generateBulk: typeof generateBulk;
99
142
  declare const generators_generateBulkPasswords: typeof generateBulkPasswords;
100
143
  declare const generators_generateBulkUlids: typeof generateBulkUlids;
@@ -112,7 +155,7 @@ declare const generators_isValidUuid: typeof isValidUuid;
112
155
  declare const generators_parseUlid: typeof parseUlid;
113
156
  declare const generators_parseUuidVersion: typeof parseUuidVersion;
114
157
  declare namespace generators {
115
- export { generators_AMBIGUOUS_CHARS as AMBIGUOUS_CHARS, generators_DATA_TYPES as DATA_TYPES, generators_DEFAULT_OPTIONS as DEFAULT_OPTIONS, generators_DEFAULT_QR_OPTIONS as DEFAULT_QR_OPTIONS, type generators_DataType as DataType, type generators_GeneratedUuid as GeneratedUuid, type generators_PasswordOptions as PasswordOptions, type generators_QrErrorLevel as QrErrorLevel, type generators_QrOptions as QrOptions, type generators_QrOutputFormat as QrOutputFormat, type generators_RandomConfig as RandomConfig, generators_SYMBOL_CHARS as SYMBOL_CHARS, generators_ULID_REGEX as ULID_REGEX, type generators_UuidVersion as UuidVersion, generators_checkStrength as checkStrength, generators_generateBulk as generateBulk, generators_generateBulkPasswords as generateBulkPasswords, generators_generateBulkUlids as generateBulkUlids, generators_generateData as generateData, generators_generatePassword as generatePassword, generators_generateQrDataUrl as generateQrDataUrl, generators_generateQrSvg as generateQrSvg, generators_generateSingle as generateSingle, generators_generateUlid as generateUlid, generators_generateUuid as generateUuid, generators_generateV4 as generateV4, generators_generateV7 as generateV7, generators_isValidUlid as isValidUlid, generators_isValidUuid as isValidUuid, generators_parseUlid as parseUlid, generators_parseUuidVersion as parseUuidVersion };
158
+ export { generators_AMBIGUOUS_CHARS as AMBIGUOUS_CHARS, generators_DATA_TYPES as DATA_TYPES, generators_DEFAULT_OPTIONS as DEFAULT_OPTIONS, generators_DEFAULT_QR_OPTIONS as DEFAULT_QR_OPTIONS, type generators_DataType as DataType, type generators_GeneratedUuid as GeneratedUuid, type generators_PasswordCharsetInfo as PasswordCharsetInfo, type generators_PasswordCrackTimeEstimate as PasswordCrackTimeEstimate, type generators_PasswordEntropyResult as PasswordEntropyResult, type generators_PasswordEntropyStrength as PasswordEntropyStrength, type generators_PasswordOptions as PasswordOptions, type generators_QrErrorLevel as QrErrorLevel, type generators_QrOptions as QrOptions, type generators_QrOutputFormat as QrOutputFormat, type generators_RandomConfig as RandomConfig, generators_SYMBOL_CHARS as SYMBOL_CHARS, generators_ULID_REGEX as ULID_REGEX, type generators_UuidVersion as UuidVersion, generators_checkStrength as checkStrength, generators_estimatePasswordEntropy as estimatePasswordEntropy, generators_generateBulk as generateBulk, generators_generateBulkPasswords as generateBulkPasswords, generators_generateBulkUlids as generateBulkUlids, generators_generateData as generateData, generators_generatePassword as generatePassword, generators_generateQrDataUrl as generateQrDataUrl, generators_generateQrSvg as generateQrSvg, generators_generateSingle as generateSingle, generators_generateUlid as generateUlid, generators_generateUuid as generateUuid, generators_generateV4 as generateV4, generators_generateV7 as generateV7, generators_isValidUlid as isValidUlid, generators_isValidUuid as isValidUuid, generators_parseUlid as parseUlid, generators_parseUuidVersion as parseUuidVersion };
116
159
  }
117
160
 
118
- export { AMBIGUOUS_CHARS as A, DATA_TYPES as D, type GeneratedUuid as G, type PasswordOptions as P, type QrErrorLevel as Q, type RandomConfig as R, SYMBOL_CHARS as S, ULID_REGEX as U, DEFAULT_OPTIONS as a, DEFAULT_QR_OPTIONS as b, type DataType as c, type QrOptions as d, type QrOutputFormat as e, type UuidVersion as f, generators as g, checkStrength as h, generateBulk as i, generateBulkPasswords as j, generateBulkUlids as k, generateData as l, generatePassword as m, generateQrDataUrl as n, generateQrSvg as o, generateSingle as p, generateUlid as q, generateUuid as r, generateV4 as s, generateV7 as t, isValidUlid as u, isValidUuid as v, parseUlid as w, parseUuidVersion as x };
161
+ export { AMBIGUOUS_CHARS as A, isValidUuid as B, parseUlid as C, DATA_TYPES as D, parseUuidVersion as E, type GeneratedUuid as G, type PasswordCharsetInfo as P, type QrErrorLevel as Q, type RandomConfig as R, SYMBOL_CHARS as S, ULID_REGEX as U, DEFAULT_OPTIONS as a, DEFAULT_QR_OPTIONS as b, type DataType as c, type PasswordCrackTimeEstimate as d, type PasswordEntropyResult as e, type PasswordEntropyStrength as f, generators as g, type PasswordOptions as h, type QrOptions as i, type QrOutputFormat as j, type UuidVersion as k, checkStrength as l, estimatePasswordEntropy as m, generateBulk as n, generateBulkPasswords as o, generateBulkUlids as p, generateData as q, generatePassword as r, generateQrDataUrl as s, generateQrSvg as t, generateSingle as u, generateUlid as v, generateUuid as w, generateV4 as x, generateV7 as y, isValidUlid as z };
@@ -7,6 +7,7 @@
7
7
  * - uuid-generator : generateV4, generateV7, generateUuid, generateBulk, isValidUuid, parseUuidVersion
8
8
  * - ulid-generator : generateUlid, generateBulkUlids, parseUlid, isValidUlid
9
9
  * - password-generator : generatePassword, generateBulkPasswords, checkStrength
10
+ * - password-entropy-estimator : estimatePasswordEntropy
10
11
  * - random-data : generateSingle, generateData
11
12
  * - qr-code : generateQrSvg, generateQrDataUrl
12
13
  */
@@ -50,6 +51,43 @@ declare function checkStrength(password: string): {
50
51
  label: 'Very Weak' | 'Weak' | 'Fair' | 'Strong' | 'Very Strong';
51
52
  color: string;
52
53
  };
54
+ interface PasswordCharsetInfo {
55
+ hasLowercase: boolean;
56
+ hasUppercase: boolean;
57
+ hasDigits: boolean;
58
+ hasSymbols: boolean;
59
+ hasOther: boolean;
60
+ poolSize: number;
61
+ }
62
+ interface PasswordCrackTimeEstimate {
63
+ scenario: string;
64
+ guessesPerSecond: number;
65
+ humanReadable: string;
66
+ }
67
+ type PasswordEntropyStrength = 'very-weak' | 'weak' | 'fair' | 'strong' | 'very-strong';
68
+ interface PasswordEntropyResult {
69
+ length: number;
70
+ charset: PasswordCharsetInfo;
71
+ entropyBits: number;
72
+ strength: PasswordEntropyStrength;
73
+ crackTimes: PasswordCrackTimeEstimate[];
74
+ warnings: string[];
75
+ }
76
+ /**
77
+ * Estimate a password's entropy in bits from the character classes it
78
+ * actually draws from (lowercase, uppercase, digits, symbols, other/Unicode),
79
+ * then derive a strength label and crack-time estimates at a few realistic
80
+ * guess rates. This is the classic pool-size x length method, the same
81
+ * approach used by most public entropy calculators: it measures resistance
82
+ * to brute force over the theoretical character space, not real-world
83
+ * guessability against a breach-database or dictionary attack — a common
84
+ * word with substitutions can score high here while being easy to guess in
85
+ * practice, which is why the pattern-based warnings below exist alongside
86
+ * the raw entropy figure rather than folded into it.
87
+ */
88
+ declare function estimatePasswordEntropy(password: string): PasswordEntropyResult | {
89
+ error: string;
90
+ };
53
91
  type DataType = 'name' | 'email' | 'uuid' | 'phone' | 'date' | 'number' | 'boolean' | 'color' | 'url' | 'ipv4' | 'sentence' | 'paragraph';
54
92
  interface RandomConfig {
55
93
  type: DataType;
@@ -86,6 +124,10 @@ declare const generators_DEFAULT_OPTIONS: typeof DEFAULT_OPTIONS;
86
124
  declare const generators_DEFAULT_QR_OPTIONS: typeof DEFAULT_QR_OPTIONS;
87
125
  type generators_DataType = DataType;
88
126
  type generators_GeneratedUuid = GeneratedUuid;
127
+ type generators_PasswordCharsetInfo = PasswordCharsetInfo;
128
+ type generators_PasswordCrackTimeEstimate = PasswordCrackTimeEstimate;
129
+ type generators_PasswordEntropyResult = PasswordEntropyResult;
130
+ type generators_PasswordEntropyStrength = PasswordEntropyStrength;
89
131
  type generators_PasswordOptions = PasswordOptions;
90
132
  type generators_QrErrorLevel = QrErrorLevel;
91
133
  type generators_QrOptions = QrOptions;
@@ -95,6 +137,7 @@ declare const generators_SYMBOL_CHARS: typeof SYMBOL_CHARS;
95
137
  declare const generators_ULID_REGEX: typeof ULID_REGEX;
96
138
  type generators_UuidVersion = UuidVersion;
97
139
  declare const generators_checkStrength: typeof checkStrength;
140
+ declare const generators_estimatePasswordEntropy: typeof estimatePasswordEntropy;
98
141
  declare const generators_generateBulk: typeof generateBulk;
99
142
  declare const generators_generateBulkPasswords: typeof generateBulkPasswords;
100
143
  declare const generators_generateBulkUlids: typeof generateBulkUlids;
@@ -112,7 +155,7 @@ declare const generators_isValidUuid: typeof isValidUuid;
112
155
  declare const generators_parseUlid: typeof parseUlid;
113
156
  declare const generators_parseUuidVersion: typeof parseUuidVersion;
114
157
  declare namespace generators {
115
- export { generators_AMBIGUOUS_CHARS as AMBIGUOUS_CHARS, generators_DATA_TYPES as DATA_TYPES, generators_DEFAULT_OPTIONS as DEFAULT_OPTIONS, generators_DEFAULT_QR_OPTIONS as DEFAULT_QR_OPTIONS, type generators_DataType as DataType, type generators_GeneratedUuid as GeneratedUuid, type generators_PasswordOptions as PasswordOptions, type generators_QrErrorLevel as QrErrorLevel, type generators_QrOptions as QrOptions, type generators_QrOutputFormat as QrOutputFormat, type generators_RandomConfig as RandomConfig, generators_SYMBOL_CHARS as SYMBOL_CHARS, generators_ULID_REGEX as ULID_REGEX, type generators_UuidVersion as UuidVersion, generators_checkStrength as checkStrength, generators_generateBulk as generateBulk, generators_generateBulkPasswords as generateBulkPasswords, generators_generateBulkUlids as generateBulkUlids, generators_generateData as generateData, generators_generatePassword as generatePassword, generators_generateQrDataUrl as generateQrDataUrl, generators_generateQrSvg as generateQrSvg, generators_generateSingle as generateSingle, generators_generateUlid as generateUlid, generators_generateUuid as generateUuid, generators_generateV4 as generateV4, generators_generateV7 as generateV7, generators_isValidUlid as isValidUlid, generators_isValidUuid as isValidUuid, generators_parseUlid as parseUlid, generators_parseUuidVersion as parseUuidVersion };
158
+ export { generators_AMBIGUOUS_CHARS as AMBIGUOUS_CHARS, generators_DATA_TYPES as DATA_TYPES, generators_DEFAULT_OPTIONS as DEFAULT_OPTIONS, generators_DEFAULT_QR_OPTIONS as DEFAULT_QR_OPTIONS, type generators_DataType as DataType, type generators_GeneratedUuid as GeneratedUuid, type generators_PasswordCharsetInfo as PasswordCharsetInfo, type generators_PasswordCrackTimeEstimate as PasswordCrackTimeEstimate, type generators_PasswordEntropyResult as PasswordEntropyResult, type generators_PasswordEntropyStrength as PasswordEntropyStrength, type generators_PasswordOptions as PasswordOptions, type generators_QrErrorLevel as QrErrorLevel, type generators_QrOptions as QrOptions, type generators_QrOutputFormat as QrOutputFormat, type generators_RandomConfig as RandomConfig, generators_SYMBOL_CHARS as SYMBOL_CHARS, generators_ULID_REGEX as ULID_REGEX, type generators_UuidVersion as UuidVersion, generators_checkStrength as checkStrength, generators_estimatePasswordEntropy as estimatePasswordEntropy, generators_generateBulk as generateBulk, generators_generateBulkPasswords as generateBulkPasswords, generators_generateBulkUlids as generateBulkUlids, generators_generateData as generateData, generators_generatePassword as generatePassword, generators_generateQrDataUrl as generateQrDataUrl, generators_generateQrSvg as generateQrSvg, generators_generateSingle as generateSingle, generators_generateUlid as generateUlid, generators_generateUuid as generateUuid, generators_generateV4 as generateV4, generators_generateV7 as generateV7, generators_isValidUlid as isValidUlid, generators_isValidUuid as isValidUuid, generators_parseUlid as parseUlid, generators_parseUuidVersion as parseUuidVersion };
116
159
  }
117
160
 
118
- export { AMBIGUOUS_CHARS as A, DATA_TYPES as D, type GeneratedUuid as G, type PasswordOptions as P, type QrErrorLevel as Q, type RandomConfig as R, SYMBOL_CHARS as S, ULID_REGEX as U, DEFAULT_OPTIONS as a, DEFAULT_QR_OPTIONS as b, type DataType as c, type QrOptions as d, type QrOutputFormat as e, type UuidVersion as f, generators as g, checkStrength as h, generateBulk as i, generateBulkPasswords as j, generateBulkUlids as k, generateData as l, generatePassword as m, generateQrDataUrl as n, generateQrSvg as o, generateSingle as p, generateUlid as q, generateUuid as r, generateV4 as s, generateV7 as t, isValidUlid as u, isValidUuid as v, parseUlid as w, parseUuidVersion as x };
161
+ export { AMBIGUOUS_CHARS as A, isValidUuid as B, parseUlid as C, DATA_TYPES as D, parseUuidVersion as E, type GeneratedUuid as G, type PasswordCharsetInfo as P, type QrErrorLevel as Q, type RandomConfig as R, SYMBOL_CHARS as S, ULID_REGEX as U, DEFAULT_OPTIONS as a, DEFAULT_QR_OPTIONS as b, type DataType as c, type PasswordCrackTimeEstimate as d, type PasswordEntropyResult as e, type PasswordEntropyStrength as f, generators as g, type PasswordOptions as h, type QrOptions as i, type QrOutputFormat as j, type UuidVersion as k, checkStrength as l, estimatePasswordEntropy as m, generateBulk as n, generateBulkPasswords as o, generateBulkUlids as p, generateData as q, generatePassword as r, generateQrDataUrl as s, generateQrSvg as t, generateSingle as u, generateUlid as v, generateUuid as w, generateV4 as x, generateV7 as y, isValidUlid as z };
package/dist/index.cjs CHANGED
@@ -53,6 +53,7 @@ __export(json_exports, {
53
53
  inferGoType: () => inferGoType,
54
54
  inferPythonType: () => inferPythonType,
55
55
  inferType: () => inferType,
56
+ jsonSchemaToTypescript: () => jsonSchemaToTypescript,
56
57
  jsonToCsv: () => jsonToCsv,
57
58
  jsonToGo: () => jsonToGo,
58
59
  jsonToPython: () => jsonToPython,
@@ -1340,6 +1341,105 @@ function resolveJsonPointer(json, pointer) {
1340
1341
  }
1341
1342
  return { pointer, found: true, value: current, tokens };
1342
1343
  }
1344
+ function _schemaRefName(ref) {
1345
+ const parts = ref.split("/");
1346
+ return _capitalize(parts[parts.length - 1] || "Ref");
1347
+ }
1348
+ function _schemaLiteralType(value) {
1349
+ if (typeof value === "string") return JSON.stringify(value);
1350
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
1351
+ if (value === null) return "null";
1352
+ return JSON.stringify(value);
1353
+ }
1354
+ function _safePropertyKey(key) {
1355
+ return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : JSON.stringify(key);
1356
+ }
1357
+ function _schemaToTsType(schema, name, interfaces) {
1358
+ if (schema.$ref) return _schemaRefName(schema.$ref);
1359
+ if (schema.const !== void 0) return _schemaLiteralType(schema.const);
1360
+ if (schema.enum) return schema.enum.map(_schemaLiteralType).join(" | ");
1361
+ if (schema.oneOf) return schema.oneOf.map((s, i) => _schemaToTsType(s, `${name}Variant${i}`, interfaces)).join(" | ");
1362
+ if (schema.anyOf) return schema.anyOf.map((s, i) => _schemaToTsType(s, `${name}Variant${i}`, interfaces)).join(" | ");
1363
+ if (schema.allOf) return schema.allOf.map((s, i) => _schemaToTsType(s, `${name}Part${i}`, interfaces)).join(" & ");
1364
+ const types = Array.isArray(schema.type) ? schema.type : schema.type ? [schema.type] : [];
1365
+ const nullable = types.includes("null");
1366
+ const nonNullTypes = types.filter((t) => t !== "null");
1367
+ const primaryType = nonNullTypes[0] ?? (schema.properties || schema.additionalProperties !== void 0 ? "object" : void 0);
1368
+ let result;
1369
+ switch (primaryType) {
1370
+ case "string":
1371
+ result = "string";
1372
+ break;
1373
+ case "number":
1374
+ case "integer":
1375
+ result = "number";
1376
+ break;
1377
+ case "boolean":
1378
+ result = "boolean";
1379
+ break;
1380
+ case "array": {
1381
+ const itemsSchema = Array.isArray(schema.items) ? schema.items[0] : schema.items;
1382
+ const itemType = itemsSchema ? _schemaToTsType(itemsSchema, `${name}Item`, interfaces) : "unknown";
1383
+ result = `${itemType}[]`;
1384
+ break;
1385
+ }
1386
+ case "object": {
1387
+ _buildSchemaInterface(schema, name, interfaces);
1388
+ result = name;
1389
+ break;
1390
+ }
1391
+ default:
1392
+ result = "unknown";
1393
+ }
1394
+ return nullable ? `${result} | null` : result;
1395
+ }
1396
+ function _buildSchemaInterface(schema, name, interfaces) {
1397
+ if (interfaces.has(name)) return;
1398
+ const required = new Set(schema.required ?? []);
1399
+ const lines = [`interface ${name} {`];
1400
+ for (const [key, propSchema] of Object.entries(schema.properties ?? {})) {
1401
+ if (propSchema.description) lines.push(` /** ${propSchema.description} */`);
1402
+ const optional = required.has(key) ? "" : "?";
1403
+ const propType = _schemaToTsType(propSchema, _capitalize(key), interfaces);
1404
+ lines.push(` ${_safePropertyKey(key)}${optional}: ${propType};`);
1405
+ }
1406
+ if (schema.additionalProperties === true) {
1407
+ lines.push(" [key: string]: unknown;");
1408
+ } else if (schema.additionalProperties && typeof schema.additionalProperties === "object") {
1409
+ const addType = _schemaToTsType(schema.additionalProperties, `${name}Value`, interfaces);
1410
+ lines.push(` [key: string]: ${addType};`);
1411
+ }
1412
+ lines.push("}");
1413
+ interfaces.set(name, lines.join("\n"));
1414
+ }
1415
+ function jsonSchemaToTypescript(schemaJson, options) {
1416
+ let schema;
1417
+ try {
1418
+ schema = JSON.parse(schemaJson);
1419
+ } catch {
1420
+ return { error: "Invalid JSON input" };
1421
+ }
1422
+ if (typeof schema !== "object" || schema === null || Array.isArray(schema)) {
1423
+ return { error: "Schema must be a JSON object" };
1424
+ }
1425
+ const rootName = options?.rootName ?? "Root";
1426
+ const typedSchema = schema;
1427
+ const interfaces = /* @__PURE__ */ new Map();
1428
+ const defs = { ...typedSchema.$defs ?? {}, ...typedSchema.definitions ?? {} };
1429
+ for (const [defName, defSchema] of Object.entries(defs)) {
1430
+ const defTypeName = _capitalize(defName);
1431
+ const defType = _schemaToTsType(defSchema, defTypeName, interfaces);
1432
+ if (!interfaces.has(defTypeName)) {
1433
+ interfaces.set(defTypeName, `type ${defTypeName} = ${defType};`);
1434
+ }
1435
+ }
1436
+ const rootType = _schemaToTsType(typedSchema, rootName, interfaces);
1437
+ const parts = [...interfaces.values()];
1438
+ if (!interfaces.has(rootName)) {
1439
+ parts.push(`type ${rootName} = ${rootType};`);
1440
+ }
1441
+ return parts.join("\n\n");
1442
+ }
1343
1443
 
1344
1444
  // src/tools/encoding.ts
1345
1445
  var encoding_exports = {};
@@ -5849,6 +5949,7 @@ __export(generators_exports, {
5849
5949
  SYMBOL_CHARS: () => SYMBOL_CHARS,
5850
5950
  ULID_REGEX: () => ULID_REGEX,
5851
5951
  checkStrength: () => checkStrength,
5952
+ estimatePasswordEntropy: () => estimatePasswordEntropy,
5852
5953
  generateBulk: () => generateBulk,
5853
5954
  generateBulkPasswords: () => generateBulkPasswords,
5854
5955
  generateBulkUlids: () => generateBulkUlids,
@@ -6065,6 +6166,111 @@ function checkStrength(password) {
6065
6166
  color: levels[score].color
6066
6167
  };
6067
6168
  }
6169
+ var _SYMBOL_POOL_CHARS = " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
6170
+ var _SYMBOL_POOL_SET = new Set(_SYMBOL_POOL_CHARS.split(""));
6171
+ function _hasSymbolChar(password) {
6172
+ for (const ch of password) {
6173
+ if (_SYMBOL_POOL_SET.has(ch)) return true;
6174
+ }
6175
+ return false;
6176
+ }
6177
+ function _hasSequentialRun(password, minRun) {
6178
+ let ascRun = 1;
6179
+ let descRun = 1;
6180
+ for (let i = 1; i < password.length; i++) {
6181
+ const prev = password.charCodeAt(i - 1);
6182
+ const curr = password.charCodeAt(i);
6183
+ if (curr === prev + 1) {
6184
+ ascRun++;
6185
+ descRun = 1;
6186
+ } else if (curr === prev - 1) {
6187
+ descRun++;
6188
+ ascRun = 1;
6189
+ } else {
6190
+ ascRun = 1;
6191
+ descRun = 1;
6192
+ }
6193
+ if (ascRun >= minRun || descRun >= minRun) return true;
6194
+ }
6195
+ return false;
6196
+ }
6197
+ function _formatCrackDuration(seconds) {
6198
+ if (!isFinite(seconds)) return "effectively never";
6199
+ if (seconds < 1) return "instantly";
6200
+ const units = [
6201
+ ["century", 315576e4],
6202
+ ["year", 31557600],
6203
+ ["month", 2629800],
6204
+ ["day", 86400],
6205
+ ["hour", 3600],
6206
+ ["minute", 60],
6207
+ ["second", 1]
6208
+ ];
6209
+ for (const [name, unitSeconds] of units) {
6210
+ if (seconds >= unitSeconds) {
6211
+ const value = seconds / unitSeconds;
6212
+ if (name === "century" && value > 1e3) return "longer than the age of the universe";
6213
+ const rounded = value >= 100 ? Math.round(value) : Math.round(value * 10) / 10;
6214
+ const plural = name === "century" ? "centuries" : `${name}s`;
6215
+ return `${rounded} ${rounded === 1 ? name : plural}`;
6216
+ }
6217
+ }
6218
+ return "instantly";
6219
+ }
6220
+ function estimatePasswordEntropy(password) {
6221
+ if (!password) return { error: "Password is required" };
6222
+ const hasLowercase = /[a-z]/.test(password);
6223
+ const hasUppercase = /[A-Z]/.test(password);
6224
+ const hasDigits = /[0-9]/.test(password);
6225
+ const hasSymbols = _hasSymbolChar(password);
6226
+ const hasOther = /[^\x20-\x7e]/.test(password);
6227
+ let poolSize = 0;
6228
+ if (hasLowercase) poolSize += 26;
6229
+ if (hasUppercase) poolSize += 26;
6230
+ if (hasDigits) poolSize += 10;
6231
+ if (hasSymbols) poolSize += _SYMBOL_POOL_CHARS.length;
6232
+ if (hasOther) poolSize += 100;
6233
+ const entropyBits = Math.round(password.length * Math.log2(poolSize) * 100) / 100;
6234
+ let strength;
6235
+ if (entropyBits < 28) strength = "very-weak";
6236
+ else if (entropyBits < 36) strength = "weak";
6237
+ else if (entropyBits < 60) strength = "fair";
6238
+ else if (entropyBits < 128) strength = "strong";
6239
+ else strength = "very-strong";
6240
+ const averageGuesses = Math.pow(2, entropyBits) / 2;
6241
+ const scenarios = [
6242
+ { scenario: "Online, throttled (100 guesses/hour)", guessesPerSecond: 100 / 3600 },
6243
+ { scenario: "Online, unthrottled (10 guesses/sec)", guessesPerSecond: 10 },
6244
+ { scenario: "Offline, slow hash e.g. bcrypt (10k guesses/sec)", guessesPerSecond: 1e4 },
6245
+ { scenario: "Offline, fast hash / GPU cluster (10B guesses/sec)", guessesPerSecond: 1e10 }
6246
+ ];
6247
+ const crackTimes = scenarios.map((s) => ({
6248
+ scenario: s.scenario,
6249
+ guessesPerSecond: s.guessesPerSecond,
6250
+ humanReadable: _formatCrackDuration(averageGuesses / s.guessesPerSecond)
6251
+ }));
6252
+ const warnings = [];
6253
+ if (password.length < 8) {
6254
+ warnings.push("Shorter than 8 characters \u2014 most sites and cracking tools treat this as trivially weak regardless of entropy.");
6255
+ }
6256
+ if (/(.)\1{2,}/.test(password)) {
6257
+ warnings.push('Contains a repeated character run (e.g. "aaa"), which is easier to guess than the entropy figure implies.');
6258
+ }
6259
+ if (_hasSequentialRun(password, 3)) {
6260
+ warnings.push('Contains a sequential run (e.g. "abc" or "321"), which is easier to guess than the entropy figure implies.');
6261
+ }
6262
+ if (poolSize <= 26) {
6263
+ warnings.push("Uses only one character class \u2014 mixing in uppercase, digits, or symbols raises the character pool and entropy.");
6264
+ }
6265
+ return {
6266
+ length: password.length,
6267
+ charset: { hasLowercase, hasUppercase, hasDigits, hasSymbols, hasOther, poolSize },
6268
+ entropyBits,
6269
+ strength,
6270
+ crackTimes,
6271
+ warnings
6272
+ };
6273
+ }
6068
6274
  var DATA_TYPES = [
6069
6275
  { value: "name", label: "Full Name", example: "John Smith" },
6070
6276
  { value: "email", label: "Email Address", example: "john.smith@gmail.com" },
package/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
- export { j as json } from './json-DEVFIpsC.cjs';
1
+ export { j as json } from './json-Ta9JykSB.cjs';
2
2
  export { e as encoding } from './encoding-Dk3wpmb3.cjs';
3
3
  export { h as hashing } from './hashing-CnetQFD_.cjs';
4
4
  export { t as text } from './text-D1fySkCB.cjs';
5
5
  export { d as data } from './data-XRb0D7Zn.cjs';
6
- export { g as generators } from './generators-BGtRGpJZ.cjs';
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-COt5uI20.cjs';
9
9
  export { n as network } from './network-D7Epuerc.cjs';
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export { j as json } from './json-DEVFIpsC.js';
1
+ export { j as json } from './json-Ta9JykSB.js';
2
2
  export { e as encoding } from './encoding-Dk3wpmb3.js';
3
3
  export { h as hashing } from './hashing-CnetQFD_.js';
4
4
  export { t as text } from './text-D1fySkCB.js';
5
5
  export { d as data } from './data-XRb0D7Zn.js';
6
- export { g as generators } from './generators-BGtRGpJZ.js';
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-COt5uI20.js';
9
9
  export { n as network } from './network-D7Epuerc.js';
package/dist/index.js CHANGED
@@ -7,12 +7,12 @@ 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';
9
9
  export { ai_agent_exports as ai_agent } from './chunk-265NPGKH.js';
10
- export { json_exports as json } from './chunk-WO3LJMVV.js';
10
+ export { json_exports as json } from './chunk-WVEKRKGU.js';
11
11
  export { encoding_exports as encoding } from './chunk-DOWQZUTP.js';
12
12
  export { hashing_exports as hashing } from './chunk-GEFVMGZR.js';
13
13
  export { text_exports as text } from './chunk-AFEZ6N4A.js';
14
14
  export { data_exports as data } from './chunk-66QHV5KW.js';
15
- export { generators_exports as generators } from './chunk-2CJSLYWI.js';
15
+ export { generators_exports as generators } from './chunk-3TYWIX3B.js';
16
16
  export { time_exports as time } from './chunk-IEPWZERQ.js';
17
17
  import './chunk-MLKGABMK.js';
18
18
 
@@ -13,6 +13,7 @@
13
13
  * - json-to-go : jsonToGo, parseStructs, toPascalCase, inferGoType
14
14
  * - json-to-python : jsonToPython, toSnakeCase, inferPythonType
15
15
  * - json-to-zod : jsonToZod
16
+ * - json-schema-to-typescript : jsonSchemaToTypescript
16
17
  */
17
18
  type ParseStatus = 'idle' | 'valid' | 'error';
18
19
  interface JsonParseResult {
@@ -170,6 +171,36 @@ interface JsonPointerResult {
170
171
  * traversal, no external calls.
171
172
  */
172
173
  declare function resolveJsonPointer(json: string, pointer: string): JsonPointerResult;
174
+ interface JsonSchemaLike {
175
+ type?: string | string[];
176
+ properties?: Record<string, JsonSchemaLike>;
177
+ required?: string[];
178
+ items?: JsonSchemaLike | JsonSchemaLike[];
179
+ enum?: unknown[];
180
+ const?: unknown;
181
+ oneOf?: JsonSchemaLike[];
182
+ anyOf?: JsonSchemaLike[];
183
+ allOf?: JsonSchemaLike[];
184
+ $ref?: string;
185
+ additionalProperties?: boolean | JsonSchemaLike;
186
+ description?: string;
187
+ definitions?: Record<string, JsonSchemaLike>;
188
+ $defs?: Record<string, JsonSchemaLike>;
189
+ [key: string]: unknown;
190
+ }
191
+ interface JsonSchemaToTsOptions {
192
+ rootName?: string;
193
+ }
194
+ /**
195
+ * Convert a JSON Schema document into TypeScript interfaces/types. Unlike
196
+ * jsonToTypescript (which infers types from an example data payload), this
197
+ * reads the schema's declared `type`/`enum`/`required` keywords directly, so
198
+ * optional vs. required fields and enum/union types come through accurately
199
+ * instead of being guessed from a single example value.
200
+ */
201
+ declare function jsonSchemaToTypescript(schemaJson: string, options?: JsonSchemaToTsOptions): string | {
202
+ error: string;
203
+ };
173
204
 
174
205
  type json_ConvertOptions = ConvertOptions;
175
206
  type json_CsvOptions = CsvOptions;
@@ -181,6 +212,8 @@ type json_JsonDiffResult = JsonDiffResult;
181
212
  type json_JsonParseResult = JsonParseResult;
182
213
  type json_JsonPathResult = JsonPathResult;
183
214
  type json_JsonPointerResult = JsonPointerResult;
215
+ type json_JsonSchemaLike = JsonSchemaLike;
216
+ type json_JsonSchemaToTsOptions = JsonSchemaToTsOptions;
184
217
  type json_ParseStatus = ParseStatus;
185
218
  type json_PythonClass = PythonClass;
186
219
  type json_PythonField = PythonField;
@@ -199,6 +232,7 @@ declare const json_getJsonStats: typeof getJsonStats;
199
232
  declare const json_inferGoType: typeof inferGoType;
200
233
  declare const json_inferPythonType: typeof inferPythonType;
201
234
  declare const json_inferType: typeof inferType;
235
+ declare const json_jsonSchemaToTypescript: typeof jsonSchemaToTypescript;
202
236
  declare const json_jsonToCsv: typeof jsonToCsv;
203
237
  declare const json_jsonToGo: typeof jsonToGo;
204
238
  declare const json_jsonToPython: typeof jsonToPython;
@@ -216,7 +250,7 @@ declare const json_validateJsonPath: typeof validateJsonPath;
216
250
  declare const json_validateJsonString: typeof validateJsonString;
217
251
  declare const json_yamlToJson: typeof yamlToJson;
218
252
  declare namespace json {
219
- export { type json_ConvertOptions as ConvertOptions, type json_CsvOptions as CsvOptions, type json_DiffNode as DiffNode, type json_DiffType as DiffType, type json_GoField as GoField, type json_GoStruct as GoStruct, type json_JsonDiffResult as JsonDiffResult, type json_JsonParseResult as JsonParseResult, type json_JsonPathResult as JsonPathResult, type json_JsonPointerResult as JsonPointerResult, type json_ParseStatus as ParseStatus, type json_PythonClass as PythonClass, type json_PythonField as PythonField, type json_PythonMode as PythonMode, type json_ValidationError as ValidationError, type json_ValidationResult as ValidationResult, type json_ZodOptions as ZodOptions, json_csvToJson as csvToJson, json_detectFormat as detectFormat, json_diffJson as diffJson, json_evaluateJsonPath as evaluateJsonPath, json_formatDiffLine as formatDiffLine, json_formatJson as formatJson, json_generateExample as generateExample, json_getJsonStats as getJsonStats, json_inferGoType as inferGoType, json_inferPythonType as inferPythonType, json_inferType as inferType, json_jsonToCsv as jsonToCsv, json_jsonToGo as jsonToGo, json_jsonToPython as jsonToPython, json_jsonToTypescript as jsonToTypescript, json_jsonToYaml as jsonToYaml, json_jsonToZod as jsonToZod, json_minifyJson as minifyJson, json_parseJson as parseJson, json_parseStructs as parseStructs, json_resolveJsonPointer as resolveJsonPointer, json_toPascalCase as toPascalCase, json_toSnakeCase as toSnakeCase, json_validateJson as validateJson, json_validateJsonPath as validateJsonPath, json_validateJsonString as validateJsonString, json_yamlToJson as yamlToJson };
253
+ export { type json_ConvertOptions as ConvertOptions, type json_CsvOptions as CsvOptions, type json_DiffNode as DiffNode, type json_DiffType as DiffType, type json_GoField as GoField, type json_GoStruct as GoStruct, type json_JsonDiffResult as JsonDiffResult, type json_JsonParseResult as JsonParseResult, type json_JsonPathResult as JsonPathResult, type json_JsonPointerResult as JsonPointerResult, type json_JsonSchemaLike as JsonSchemaLike, type json_JsonSchemaToTsOptions as JsonSchemaToTsOptions, type json_ParseStatus as ParseStatus, type json_PythonClass as PythonClass, type json_PythonField as PythonField, type json_PythonMode as PythonMode, type json_ValidationError as ValidationError, type json_ValidationResult as ValidationResult, type json_ZodOptions as ZodOptions, json_csvToJson as csvToJson, json_detectFormat as detectFormat, json_diffJson as diffJson, json_evaluateJsonPath as evaluateJsonPath, json_formatDiffLine as formatDiffLine, json_formatJson as formatJson, json_generateExample as generateExample, json_getJsonStats as getJsonStats, json_inferGoType as inferGoType, json_inferPythonType as inferPythonType, json_inferType as inferType, json_jsonSchemaToTypescript as jsonSchemaToTypescript, json_jsonToCsv as jsonToCsv, json_jsonToGo as jsonToGo, json_jsonToPython as jsonToPython, json_jsonToTypescript as jsonToTypescript, json_jsonToYaml as jsonToYaml, json_jsonToZod as jsonToZod, json_minifyJson as minifyJson, json_parseJson as parseJson, json_parseStructs as parseStructs, json_resolveJsonPointer as resolveJsonPointer, json_toPascalCase as toPascalCase, json_toSnakeCase as toSnakeCase, json_validateJson as validateJson, json_validateJsonPath as validateJsonPath, json_validateJsonString as validateJsonString, json_yamlToJson as yamlToJson };
220
254
  }
221
255
 
222
- export { jsonToYaml as A, jsonToZod as B, type ConvertOptions as C, type DiffNode as D, minifyJson as E, parseJson as F, type GoField as G, parseStructs as H, resolveJsonPointer as I, type JsonDiffResult as J, toPascalCase as K, toSnakeCase as L, validateJson as M, validateJsonPath as N, validateJsonString as O, type ParseStatus as P, yamlToJson as Q, type ValidationError as V, type ZodOptions as Z, type CsvOptions as a, type DiffType as b, type GoStruct as c, type JsonParseResult as d, type JsonPathResult as e, type JsonPointerResult as f, type PythonClass as g, type PythonField as h, type PythonMode as i, json as j, type ValidationResult as k, csvToJson as l, detectFormat as m, diffJson as n, evaluateJsonPath as o, formatDiffLine as p, formatJson as q, generateExample as r, getJsonStats as s, inferGoType as t, inferPythonType as u, inferType as v, jsonToCsv as w, jsonToGo as x, jsonToPython as y, jsonToTypescript as z };
256
+ export { jsonToGo as A, jsonToPython as B, type ConvertOptions as C, type DiffNode as D, jsonToTypescript as E, jsonToYaml as F, type GoField as G, jsonToZod as H, minifyJson as I, type JsonDiffResult as J, parseJson as K, parseStructs as L, resolveJsonPointer as M, toPascalCase as N, toSnakeCase as O, type ParseStatus as P, validateJson as Q, validateJsonPath as R, validateJsonString as S, yamlToJson as T, type ValidationError as V, type ZodOptions as Z, type CsvOptions as a, type DiffType as b, type GoStruct as c, type JsonParseResult as d, type JsonPathResult as e, type JsonPointerResult as f, type JsonSchemaLike as g, type JsonSchemaToTsOptions as h, type PythonClass as i, json as j, type PythonField as k, type PythonMode as l, type ValidationResult as m, csvToJson as n, detectFormat as o, diffJson as p, evaluateJsonPath as q, formatDiffLine as r, formatJson as s, generateExample as t, getJsonStats as u, inferGoType as v, inferPythonType as w, inferType as x, jsonSchemaToTypescript as y, jsonToCsv as z };
@@ -13,6 +13,7 @@
13
13
  * - json-to-go : jsonToGo, parseStructs, toPascalCase, inferGoType
14
14
  * - json-to-python : jsonToPython, toSnakeCase, inferPythonType
15
15
  * - json-to-zod : jsonToZod
16
+ * - json-schema-to-typescript : jsonSchemaToTypescript
16
17
  */
17
18
  type ParseStatus = 'idle' | 'valid' | 'error';
18
19
  interface JsonParseResult {
@@ -170,6 +171,36 @@ interface JsonPointerResult {
170
171
  * traversal, no external calls.
171
172
  */
172
173
  declare function resolveJsonPointer(json: string, pointer: string): JsonPointerResult;
174
+ interface JsonSchemaLike {
175
+ type?: string | string[];
176
+ properties?: Record<string, JsonSchemaLike>;
177
+ required?: string[];
178
+ items?: JsonSchemaLike | JsonSchemaLike[];
179
+ enum?: unknown[];
180
+ const?: unknown;
181
+ oneOf?: JsonSchemaLike[];
182
+ anyOf?: JsonSchemaLike[];
183
+ allOf?: JsonSchemaLike[];
184
+ $ref?: string;
185
+ additionalProperties?: boolean | JsonSchemaLike;
186
+ description?: string;
187
+ definitions?: Record<string, JsonSchemaLike>;
188
+ $defs?: Record<string, JsonSchemaLike>;
189
+ [key: string]: unknown;
190
+ }
191
+ interface JsonSchemaToTsOptions {
192
+ rootName?: string;
193
+ }
194
+ /**
195
+ * Convert a JSON Schema document into TypeScript interfaces/types. Unlike
196
+ * jsonToTypescript (which infers types from an example data payload), this
197
+ * reads the schema's declared `type`/`enum`/`required` keywords directly, so
198
+ * optional vs. required fields and enum/union types come through accurately
199
+ * instead of being guessed from a single example value.
200
+ */
201
+ declare function jsonSchemaToTypescript(schemaJson: string, options?: JsonSchemaToTsOptions): string | {
202
+ error: string;
203
+ };
173
204
 
174
205
  type json_ConvertOptions = ConvertOptions;
175
206
  type json_CsvOptions = CsvOptions;
@@ -181,6 +212,8 @@ type json_JsonDiffResult = JsonDiffResult;
181
212
  type json_JsonParseResult = JsonParseResult;
182
213
  type json_JsonPathResult = JsonPathResult;
183
214
  type json_JsonPointerResult = JsonPointerResult;
215
+ type json_JsonSchemaLike = JsonSchemaLike;
216
+ type json_JsonSchemaToTsOptions = JsonSchemaToTsOptions;
184
217
  type json_ParseStatus = ParseStatus;
185
218
  type json_PythonClass = PythonClass;
186
219
  type json_PythonField = PythonField;
@@ -199,6 +232,7 @@ declare const json_getJsonStats: typeof getJsonStats;
199
232
  declare const json_inferGoType: typeof inferGoType;
200
233
  declare const json_inferPythonType: typeof inferPythonType;
201
234
  declare const json_inferType: typeof inferType;
235
+ declare const json_jsonSchemaToTypescript: typeof jsonSchemaToTypescript;
202
236
  declare const json_jsonToCsv: typeof jsonToCsv;
203
237
  declare const json_jsonToGo: typeof jsonToGo;
204
238
  declare const json_jsonToPython: typeof jsonToPython;
@@ -216,7 +250,7 @@ declare const json_validateJsonPath: typeof validateJsonPath;
216
250
  declare const json_validateJsonString: typeof validateJsonString;
217
251
  declare const json_yamlToJson: typeof yamlToJson;
218
252
  declare namespace json {
219
- export { type json_ConvertOptions as ConvertOptions, type json_CsvOptions as CsvOptions, type json_DiffNode as DiffNode, type json_DiffType as DiffType, type json_GoField as GoField, type json_GoStruct as GoStruct, type json_JsonDiffResult as JsonDiffResult, type json_JsonParseResult as JsonParseResult, type json_JsonPathResult as JsonPathResult, type json_JsonPointerResult as JsonPointerResult, type json_ParseStatus as ParseStatus, type json_PythonClass as PythonClass, type json_PythonField as PythonField, type json_PythonMode as PythonMode, type json_ValidationError as ValidationError, type json_ValidationResult as ValidationResult, type json_ZodOptions as ZodOptions, json_csvToJson as csvToJson, json_detectFormat as detectFormat, json_diffJson as diffJson, json_evaluateJsonPath as evaluateJsonPath, json_formatDiffLine as formatDiffLine, json_formatJson as formatJson, json_generateExample as generateExample, json_getJsonStats as getJsonStats, json_inferGoType as inferGoType, json_inferPythonType as inferPythonType, json_inferType as inferType, json_jsonToCsv as jsonToCsv, json_jsonToGo as jsonToGo, json_jsonToPython as jsonToPython, json_jsonToTypescript as jsonToTypescript, json_jsonToYaml as jsonToYaml, json_jsonToZod as jsonToZod, json_minifyJson as minifyJson, json_parseJson as parseJson, json_parseStructs as parseStructs, json_resolveJsonPointer as resolveJsonPointer, json_toPascalCase as toPascalCase, json_toSnakeCase as toSnakeCase, json_validateJson as validateJson, json_validateJsonPath as validateJsonPath, json_validateJsonString as validateJsonString, json_yamlToJson as yamlToJson };
253
+ export { type json_ConvertOptions as ConvertOptions, type json_CsvOptions as CsvOptions, type json_DiffNode as DiffNode, type json_DiffType as DiffType, type json_GoField as GoField, type json_GoStruct as GoStruct, type json_JsonDiffResult as JsonDiffResult, type json_JsonParseResult as JsonParseResult, type json_JsonPathResult as JsonPathResult, type json_JsonPointerResult as JsonPointerResult, type json_JsonSchemaLike as JsonSchemaLike, type json_JsonSchemaToTsOptions as JsonSchemaToTsOptions, type json_ParseStatus as ParseStatus, type json_PythonClass as PythonClass, type json_PythonField as PythonField, type json_PythonMode as PythonMode, type json_ValidationError as ValidationError, type json_ValidationResult as ValidationResult, type json_ZodOptions as ZodOptions, json_csvToJson as csvToJson, json_detectFormat as detectFormat, json_diffJson as diffJson, json_evaluateJsonPath as evaluateJsonPath, json_formatDiffLine as formatDiffLine, json_formatJson as formatJson, json_generateExample as generateExample, json_getJsonStats as getJsonStats, json_inferGoType as inferGoType, json_inferPythonType as inferPythonType, json_inferType as inferType, json_jsonSchemaToTypescript as jsonSchemaToTypescript, json_jsonToCsv as jsonToCsv, json_jsonToGo as jsonToGo, json_jsonToPython as jsonToPython, json_jsonToTypescript as jsonToTypescript, json_jsonToYaml as jsonToYaml, json_jsonToZod as jsonToZod, json_minifyJson as minifyJson, json_parseJson as parseJson, json_parseStructs as parseStructs, json_resolveJsonPointer as resolveJsonPointer, json_toPascalCase as toPascalCase, json_toSnakeCase as toSnakeCase, json_validateJson as validateJson, json_validateJsonPath as validateJsonPath, json_validateJsonString as validateJsonString, json_yamlToJson as yamlToJson };
220
254
  }
221
255
 
222
- export { jsonToYaml as A, jsonToZod as B, type ConvertOptions as C, type DiffNode as D, minifyJson as E, parseJson as F, type GoField as G, parseStructs as H, resolveJsonPointer as I, type JsonDiffResult as J, toPascalCase as K, toSnakeCase as L, validateJson as M, validateJsonPath as N, validateJsonString as O, type ParseStatus as P, yamlToJson as Q, type ValidationError as V, type ZodOptions as Z, type CsvOptions as a, type DiffType as b, type GoStruct as c, type JsonParseResult as d, type JsonPathResult as e, type JsonPointerResult as f, type PythonClass as g, type PythonField as h, type PythonMode as i, json as j, type ValidationResult as k, csvToJson as l, detectFormat as m, diffJson as n, evaluateJsonPath as o, formatDiffLine as p, formatJson as q, generateExample as r, getJsonStats as s, inferGoType as t, inferPythonType as u, inferType as v, jsonToCsv as w, jsonToGo as x, jsonToPython as y, jsonToTypescript as z };
256
+ export { jsonToGo as A, jsonToPython as B, type ConvertOptions as C, type DiffNode as D, jsonToTypescript as E, jsonToYaml as F, type GoField as G, jsonToZod as H, minifyJson as I, type JsonDiffResult as J, parseJson as K, parseStructs as L, resolveJsonPointer as M, toPascalCase as N, toSnakeCase as O, type ParseStatus as P, validateJson as Q, validateJsonPath as R, validateJsonString as S, yamlToJson as T, type ValidationError as V, type ZodOptions as Z, type CsvOptions as a, type DiffType as b, type GoStruct as c, type JsonParseResult as d, type JsonPathResult as e, type JsonPointerResult as f, type JsonSchemaLike as g, type JsonSchemaToTsOptions as h, type PythonClass as i, json as j, type PythonField as k, type PythonMode as l, type ValidationResult as m, csvToJson as n, detectFormat as o, diffJson as p, evaluateJsonPath as q, formatDiffLine as r, formatJson as s, generateExample as t, getJsonStats as u, inferGoType as v, inferPythonType as w, inferType as x, jsonSchemaToTypescript as y, jsonToCsv as z };
@@ -207,6 +207,111 @@ function checkStrength(password) {
207
207
  color: levels[score].color
208
208
  };
209
209
  }
210
+ var _SYMBOL_POOL_CHARS = " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
211
+ var _SYMBOL_POOL_SET = new Set(_SYMBOL_POOL_CHARS.split(""));
212
+ function _hasSymbolChar(password) {
213
+ for (const ch of password) {
214
+ if (_SYMBOL_POOL_SET.has(ch)) return true;
215
+ }
216
+ return false;
217
+ }
218
+ function _hasSequentialRun(password, minRun) {
219
+ let ascRun = 1;
220
+ let descRun = 1;
221
+ for (let i = 1; i < password.length; i++) {
222
+ const prev = password.charCodeAt(i - 1);
223
+ const curr = password.charCodeAt(i);
224
+ if (curr === prev + 1) {
225
+ ascRun++;
226
+ descRun = 1;
227
+ } else if (curr === prev - 1) {
228
+ descRun++;
229
+ ascRun = 1;
230
+ } else {
231
+ ascRun = 1;
232
+ descRun = 1;
233
+ }
234
+ if (ascRun >= minRun || descRun >= minRun) return true;
235
+ }
236
+ return false;
237
+ }
238
+ function _formatCrackDuration(seconds) {
239
+ if (!isFinite(seconds)) return "effectively never";
240
+ if (seconds < 1) return "instantly";
241
+ const units = [
242
+ ["century", 315576e4],
243
+ ["year", 31557600],
244
+ ["month", 2629800],
245
+ ["day", 86400],
246
+ ["hour", 3600],
247
+ ["minute", 60],
248
+ ["second", 1]
249
+ ];
250
+ for (const [name, unitSeconds] of units) {
251
+ if (seconds >= unitSeconds) {
252
+ const value = seconds / unitSeconds;
253
+ if (name === "century" && value > 1e3) return "longer than the age of the universe";
254
+ const rounded = value >= 100 ? Math.round(value) : Math.round(value * 10) / 10;
255
+ const plural = name === "century" ? "centuries" : `${name}s`;
256
+ return `${rounded} ${rounded === 1 ? name : plural}`;
257
+ }
258
+ }
259
+ return "instantly";
260
+ }
261
+ function estimatePasswordEntropy(password) {
262
+ if (!password) return { error: "Password is required" };
263
+ const hasLowercase = /[a-z]/.test(password);
264
+ const hasUppercase = /[A-Z]/.test(password);
265
+ const hasDigits = /[0-9]/.test(password);
266
+ const hasSymbols = _hasSymbolChar(password);
267
+ const hasOther = /[^\x20-\x7e]/.test(password);
268
+ let poolSize = 0;
269
+ if (hasLowercase) poolSize += 26;
270
+ if (hasUppercase) poolSize += 26;
271
+ if (hasDigits) poolSize += 10;
272
+ if (hasSymbols) poolSize += _SYMBOL_POOL_CHARS.length;
273
+ if (hasOther) poolSize += 100;
274
+ const entropyBits = Math.round(password.length * Math.log2(poolSize) * 100) / 100;
275
+ let strength;
276
+ if (entropyBits < 28) strength = "very-weak";
277
+ else if (entropyBits < 36) strength = "weak";
278
+ else if (entropyBits < 60) strength = "fair";
279
+ else if (entropyBits < 128) strength = "strong";
280
+ else strength = "very-strong";
281
+ const averageGuesses = Math.pow(2, entropyBits) / 2;
282
+ const scenarios = [
283
+ { scenario: "Online, throttled (100 guesses/hour)", guessesPerSecond: 100 / 3600 },
284
+ { scenario: "Online, unthrottled (10 guesses/sec)", guessesPerSecond: 10 },
285
+ { scenario: "Offline, slow hash e.g. bcrypt (10k guesses/sec)", guessesPerSecond: 1e4 },
286
+ { scenario: "Offline, fast hash / GPU cluster (10B guesses/sec)", guessesPerSecond: 1e10 }
287
+ ];
288
+ const crackTimes = scenarios.map((s) => ({
289
+ scenario: s.scenario,
290
+ guessesPerSecond: s.guessesPerSecond,
291
+ humanReadable: _formatCrackDuration(averageGuesses / s.guessesPerSecond)
292
+ }));
293
+ const warnings = [];
294
+ if (password.length < 8) {
295
+ warnings.push("Shorter than 8 characters \u2014 most sites and cracking tools treat this as trivially weak regardless of entropy.");
296
+ }
297
+ if (/(.)\1{2,}/.test(password)) {
298
+ warnings.push('Contains a repeated character run (e.g. "aaa"), which is easier to guess than the entropy figure implies.');
299
+ }
300
+ if (_hasSequentialRun(password, 3)) {
301
+ warnings.push('Contains a sequential run (e.g. "abc" or "321"), which is easier to guess than the entropy figure implies.');
302
+ }
303
+ if (poolSize <= 26) {
304
+ warnings.push("Uses only one character class \u2014 mixing in uppercase, digits, or symbols raises the character pool and entropy.");
305
+ }
306
+ return {
307
+ length: password.length,
308
+ charset: { hasLowercase, hasUppercase, hasDigits, hasSymbols, hasOther, poolSize },
309
+ entropyBits,
310
+ strength,
311
+ crackTimes,
312
+ warnings
313
+ };
314
+ }
210
315
  var DATA_TYPES = [
211
316
  { value: "name", label: "Full Name", example: "John Smith" },
212
317
  { value: "email", label: "Email Address", example: "john.smith@gmail.com" },
@@ -503,6 +608,7 @@ exports.DEFAULT_QR_OPTIONS = DEFAULT_QR_OPTIONS;
503
608
  exports.SYMBOL_CHARS = SYMBOL_CHARS;
504
609
  exports.ULID_REGEX = ULID_REGEX;
505
610
  exports.checkStrength = checkStrength;
611
+ exports.estimatePasswordEntropy = estimatePasswordEntropy;
506
612
  exports.generateBulk = generateBulk;
507
613
  exports.generateBulkPasswords = generateBulkPasswords;
508
614
  exports.generateBulkUlids = generateBulkUlids;
@@ -1 +1 @@
1
- export { A as AMBIGUOUS_CHARS, D as DATA_TYPES, a as DEFAULT_OPTIONS, b as DEFAULT_QR_OPTIONS, c as DataType, G as GeneratedUuid, P as PasswordOptions, Q as QrErrorLevel, d as QrOptions, e as QrOutputFormat, R as RandomConfig, S as SYMBOL_CHARS, U as ULID_REGEX, f as UuidVersion, h as checkStrength, i as generateBulk, j as generateBulkPasswords, k as generateBulkUlids, l as generateData, m as generatePassword, n as generateQrDataUrl, o as generateQrSvg, p as generateSingle, q as generateUlid, r as generateUuid, s as generateV4, t as generateV7, u as isValidUlid, v as isValidUuid, w as parseUlid, x as parseUuidVersion } from '../generators-BGtRGpJZ.cjs';
1
+ export { A as AMBIGUOUS_CHARS, D as DATA_TYPES, a as DEFAULT_OPTIONS, b as DEFAULT_QR_OPTIONS, c as DataType, G as GeneratedUuid, P as PasswordCharsetInfo, d as PasswordCrackTimeEstimate, e as PasswordEntropyResult, f as PasswordEntropyStrength, h as PasswordOptions, Q as QrErrorLevel, i as QrOptions, j as QrOutputFormat, R as RandomConfig, S as SYMBOL_CHARS, U as ULID_REGEX, k as UuidVersion, l as checkStrength, m as estimatePasswordEntropy, n as generateBulk, o as generateBulkPasswords, p as generateBulkUlids, q as generateData, r as generatePassword, s as generateQrDataUrl, t as generateQrSvg, u as generateSingle, v as generateUlid, w as generateUuid, x as generateV4, y as generateV7, z as isValidUlid, B as isValidUuid, C as parseUlid, E as parseUuidVersion } from '../generators-Du8cBesn.cjs';
@@ -1 +1 @@
1
- export { A as AMBIGUOUS_CHARS, D as DATA_TYPES, a as DEFAULT_OPTIONS, b as DEFAULT_QR_OPTIONS, c as DataType, G as GeneratedUuid, P as PasswordOptions, Q as QrErrorLevel, d as QrOptions, e as QrOutputFormat, R as RandomConfig, S as SYMBOL_CHARS, U as ULID_REGEX, f as UuidVersion, h as checkStrength, i as generateBulk, j as generateBulkPasswords, k as generateBulkUlids, l as generateData, m as generatePassword, n as generateQrDataUrl, o as generateQrSvg, p as generateSingle, q as generateUlid, r as generateUuid, s as generateV4, t as generateV7, u as isValidUlid, v as isValidUuid, w as parseUlid, x as parseUuidVersion } from '../generators-BGtRGpJZ.js';
1
+ export { A as AMBIGUOUS_CHARS, D as DATA_TYPES, a as DEFAULT_OPTIONS, b as DEFAULT_QR_OPTIONS, c as DataType, G as GeneratedUuid, P as PasswordCharsetInfo, d as PasswordCrackTimeEstimate, e as PasswordEntropyResult, f as PasswordEntropyStrength, h as PasswordOptions, Q as QrErrorLevel, i as QrOptions, j as QrOutputFormat, R as RandomConfig, S as SYMBOL_CHARS, U as ULID_REGEX, k as UuidVersion, l as checkStrength, m as estimatePasswordEntropy, n as generateBulk, o as generateBulkPasswords, p as generateBulkUlids, q as generateData, r as generatePassword, s as generateQrDataUrl, t as generateQrSvg, u as generateSingle, v as generateUlid, w as generateUuid, x as generateV4, y as generateV7, z as isValidUlid, B as isValidUuid, C as parseUlid, E as parseUuidVersion } from '../generators-Du8cBesn.js';
@@ -1,2 +1,2 @@
1
- export { AMBIGUOUS_CHARS, DATA_TYPES, DEFAULT_OPTIONS, DEFAULT_QR_OPTIONS, SYMBOL_CHARS, ULID_REGEX, checkStrength, generateBulk, generateBulkPasswords, generateBulkUlids, generateData, generatePassword, generateQrDataUrl, generateQrSvg, generateSingle, generateUlid, generateUuid, generateV4, generateV7, isValidUlid, isValidUuid, parseUlid, parseUuidVersion } from '../chunk-2CJSLYWI.js';
1
+ export { AMBIGUOUS_CHARS, DATA_TYPES, DEFAULT_OPTIONS, DEFAULT_QR_OPTIONS, SYMBOL_CHARS, ULID_REGEX, checkStrength, estimatePasswordEntropy, generateBulk, generateBulkPasswords, generateBulkUlids, generateData, generatePassword, generateQrDataUrl, generateQrSvg, generateSingle, generateUlid, generateUuid, generateV4, generateV7, isValidUlid, isValidUuid, parseUlid, parseUuidVersion } from '../chunk-3TYWIX3B.js';
2
2
  import '../chunk-MLKGABMK.js';
@@ -1293,6 +1293,105 @@ function resolveJsonPointer(json, pointer) {
1293
1293
  }
1294
1294
  return { pointer, found: true, value: current, tokens };
1295
1295
  }
1296
+ function _schemaRefName(ref) {
1297
+ const parts = ref.split("/");
1298
+ return _capitalize(parts[parts.length - 1] || "Ref");
1299
+ }
1300
+ function _schemaLiteralType(value) {
1301
+ if (typeof value === "string") return JSON.stringify(value);
1302
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
1303
+ if (value === null) return "null";
1304
+ return JSON.stringify(value);
1305
+ }
1306
+ function _safePropertyKey(key) {
1307
+ return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : JSON.stringify(key);
1308
+ }
1309
+ function _schemaToTsType(schema, name, interfaces) {
1310
+ if (schema.$ref) return _schemaRefName(schema.$ref);
1311
+ if (schema.const !== void 0) return _schemaLiteralType(schema.const);
1312
+ if (schema.enum) return schema.enum.map(_schemaLiteralType).join(" | ");
1313
+ if (schema.oneOf) return schema.oneOf.map((s, i) => _schemaToTsType(s, `${name}Variant${i}`, interfaces)).join(" | ");
1314
+ if (schema.anyOf) return schema.anyOf.map((s, i) => _schemaToTsType(s, `${name}Variant${i}`, interfaces)).join(" | ");
1315
+ if (schema.allOf) return schema.allOf.map((s, i) => _schemaToTsType(s, `${name}Part${i}`, interfaces)).join(" & ");
1316
+ const types = Array.isArray(schema.type) ? schema.type : schema.type ? [schema.type] : [];
1317
+ const nullable = types.includes("null");
1318
+ const nonNullTypes = types.filter((t) => t !== "null");
1319
+ const primaryType = nonNullTypes[0] ?? (schema.properties || schema.additionalProperties !== void 0 ? "object" : void 0);
1320
+ let result;
1321
+ switch (primaryType) {
1322
+ case "string":
1323
+ result = "string";
1324
+ break;
1325
+ case "number":
1326
+ case "integer":
1327
+ result = "number";
1328
+ break;
1329
+ case "boolean":
1330
+ result = "boolean";
1331
+ break;
1332
+ case "array": {
1333
+ const itemsSchema = Array.isArray(schema.items) ? schema.items[0] : schema.items;
1334
+ const itemType = itemsSchema ? _schemaToTsType(itemsSchema, `${name}Item`, interfaces) : "unknown";
1335
+ result = `${itemType}[]`;
1336
+ break;
1337
+ }
1338
+ case "object": {
1339
+ _buildSchemaInterface(schema, name, interfaces);
1340
+ result = name;
1341
+ break;
1342
+ }
1343
+ default:
1344
+ result = "unknown";
1345
+ }
1346
+ return nullable ? `${result} | null` : result;
1347
+ }
1348
+ function _buildSchemaInterface(schema, name, interfaces) {
1349
+ if (interfaces.has(name)) return;
1350
+ const required = new Set(schema.required ?? []);
1351
+ const lines = [`interface ${name} {`];
1352
+ for (const [key, propSchema] of Object.entries(schema.properties ?? {})) {
1353
+ if (propSchema.description) lines.push(` /** ${propSchema.description} */`);
1354
+ const optional = required.has(key) ? "" : "?";
1355
+ const propType = _schemaToTsType(propSchema, _capitalize(key), interfaces);
1356
+ lines.push(` ${_safePropertyKey(key)}${optional}: ${propType};`);
1357
+ }
1358
+ if (schema.additionalProperties === true) {
1359
+ lines.push(" [key: string]: unknown;");
1360
+ } else if (schema.additionalProperties && typeof schema.additionalProperties === "object") {
1361
+ const addType = _schemaToTsType(schema.additionalProperties, `${name}Value`, interfaces);
1362
+ lines.push(` [key: string]: ${addType};`);
1363
+ }
1364
+ lines.push("}");
1365
+ interfaces.set(name, lines.join("\n"));
1366
+ }
1367
+ function jsonSchemaToTypescript(schemaJson, options) {
1368
+ let schema;
1369
+ try {
1370
+ schema = JSON.parse(schemaJson);
1371
+ } catch {
1372
+ return { error: "Invalid JSON input" };
1373
+ }
1374
+ if (typeof schema !== "object" || schema === null || Array.isArray(schema)) {
1375
+ return { error: "Schema must be a JSON object" };
1376
+ }
1377
+ const rootName = options?.rootName ?? "Root";
1378
+ const typedSchema = schema;
1379
+ const interfaces = /* @__PURE__ */ new Map();
1380
+ const defs = { ...typedSchema.$defs ?? {}, ...typedSchema.definitions ?? {} };
1381
+ for (const [defName, defSchema] of Object.entries(defs)) {
1382
+ const defTypeName = _capitalize(defName);
1383
+ const defType = _schemaToTsType(defSchema, defTypeName, interfaces);
1384
+ if (!interfaces.has(defTypeName)) {
1385
+ interfaces.set(defTypeName, `type ${defTypeName} = ${defType};`);
1386
+ }
1387
+ }
1388
+ const rootType = _schemaToTsType(typedSchema, rootName, interfaces);
1389
+ const parts = [...interfaces.values()];
1390
+ if (!interfaces.has(rootName)) {
1391
+ parts.push(`type ${rootName} = ${rootType};`);
1392
+ }
1393
+ return parts.join("\n\n");
1394
+ }
1296
1395
 
1297
1396
  exports.csvToJson = csvToJson;
1298
1397
  exports.detectFormat = detectFormat;
@@ -1305,6 +1404,7 @@ exports.getJsonStats = getJsonStats;
1305
1404
  exports.inferGoType = inferGoType;
1306
1405
  exports.inferPythonType = inferPythonType;
1307
1406
  exports.inferType = inferType;
1407
+ exports.jsonSchemaToTypescript = jsonSchemaToTypescript;
1308
1408
  exports.jsonToCsv = jsonToCsv;
1309
1409
  exports.jsonToGo = jsonToGo;
1310
1410
  exports.jsonToPython = jsonToPython;
@@ -1 +1 @@
1
- export { C as ConvertOptions, a as CsvOptions, D as DiffNode, b as DiffType, G as GoField, c as GoStruct, J as JsonDiffResult, d as JsonParseResult, e as JsonPathResult, f as JsonPointerResult, P as ParseStatus, g as PythonClass, h as PythonField, i as PythonMode, V as ValidationError, k as ValidationResult, Z as ZodOptions, l as csvToJson, m as detectFormat, n as diffJson, o as evaluateJsonPath, p as formatDiffLine, q as formatJson, r as generateExample, s as getJsonStats, t as inferGoType, u as inferPythonType, v as inferType, w as jsonToCsv, x as jsonToGo, y as jsonToPython, z as jsonToTypescript, A as jsonToYaml, B as jsonToZod, E as minifyJson, F as parseJson, H as parseStructs, I as resolveJsonPointer, K as toPascalCase, L as toSnakeCase, M as validateJson, N as validateJsonPath, O as validateJsonString, Q as yamlToJson } from '../json-DEVFIpsC.cjs';
1
+ export { C as ConvertOptions, a as CsvOptions, D as DiffNode, b as DiffType, G as GoField, c as GoStruct, J as JsonDiffResult, d as JsonParseResult, e as JsonPathResult, f as JsonPointerResult, g as JsonSchemaLike, h as JsonSchemaToTsOptions, P as ParseStatus, i as PythonClass, k as PythonField, l as PythonMode, V as ValidationError, m as ValidationResult, Z as ZodOptions, n as csvToJson, o as detectFormat, p as diffJson, q as evaluateJsonPath, r as formatDiffLine, s as formatJson, t as generateExample, u as getJsonStats, v as inferGoType, w as inferPythonType, x as inferType, y as jsonSchemaToTypescript, z as jsonToCsv, A as jsonToGo, B as jsonToPython, E as jsonToTypescript, F as jsonToYaml, H as jsonToZod, I as minifyJson, K as parseJson, L as parseStructs, M as resolveJsonPointer, N as toPascalCase, O as toSnakeCase, Q as validateJson, R as validateJsonPath, S as validateJsonString, T as yamlToJson } from '../json-Ta9JykSB.cjs';
@@ -1 +1 @@
1
- export { C as ConvertOptions, a as CsvOptions, D as DiffNode, b as DiffType, G as GoField, c as GoStruct, J as JsonDiffResult, d as JsonParseResult, e as JsonPathResult, f as JsonPointerResult, P as ParseStatus, g as PythonClass, h as PythonField, i as PythonMode, V as ValidationError, k as ValidationResult, Z as ZodOptions, l as csvToJson, m as detectFormat, n as diffJson, o as evaluateJsonPath, p as formatDiffLine, q as formatJson, r as generateExample, s as getJsonStats, t as inferGoType, u as inferPythonType, v as inferType, w as jsonToCsv, x as jsonToGo, y as jsonToPython, z as jsonToTypescript, A as jsonToYaml, B as jsonToZod, E as minifyJson, F as parseJson, H as parseStructs, I as resolveJsonPointer, K as toPascalCase, L as toSnakeCase, M as validateJson, N as validateJsonPath, O as validateJsonString, Q as yamlToJson } from '../json-DEVFIpsC.js';
1
+ export { C as ConvertOptions, a as CsvOptions, D as DiffNode, b as DiffType, G as GoField, c as GoStruct, J as JsonDiffResult, d as JsonParseResult, e as JsonPathResult, f as JsonPointerResult, g as JsonSchemaLike, h as JsonSchemaToTsOptions, P as ParseStatus, i as PythonClass, k as PythonField, l as PythonMode, V as ValidationError, m as ValidationResult, Z as ZodOptions, n as csvToJson, o as detectFormat, p as diffJson, q as evaluateJsonPath, r as formatDiffLine, s as formatJson, t as generateExample, u as getJsonStats, v as inferGoType, w as inferPythonType, x as inferType, y as jsonSchemaToTypescript, z as jsonToCsv, A as jsonToGo, B as jsonToPython, E as jsonToTypescript, F as jsonToYaml, H as jsonToZod, I as minifyJson, K as parseJson, L as parseStructs, M as resolveJsonPointer, N as toPascalCase, O as toSnakeCase, Q as validateJson, R as validateJsonPath, S as validateJsonString, T as yamlToJson } from '../json-Ta9JykSB.js';
@@ -1,2 +1,2 @@
1
- export { csvToJson, detectFormat, diffJson, evaluateJsonPath, formatDiffLine, formatJson, generateExample, getJsonStats, inferGoType, inferPythonType, inferType, jsonToCsv, jsonToGo, jsonToPython, jsonToTypescript, jsonToYaml, jsonToZod, minifyJson, parseJson, parseStructs, resolveJsonPointer, toPascalCase, toSnakeCase, validateJson, validateJsonPath, validateJsonString, yamlToJson } from '../chunk-WO3LJMVV.js';
1
+ export { csvToJson, detectFormat, diffJson, evaluateJsonPath, formatDiffLine, formatJson, generateExample, getJsonStats, inferGoType, inferPythonType, inferType, jsonSchemaToTypescript, jsonToCsv, jsonToGo, jsonToPython, jsonToTypescript, jsonToYaml, jsonToZod, minifyJson, parseJson, parseStructs, resolveJsonPointer, toPascalCase, toSnakeCase, validateJson, validateJsonPath, validateJsonString, yamlToJson } from '../chunk-WVEKRKGU.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.29.0",
3
+ "version": "0.30.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",