@utilix-tech/sdk 0.29.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +25 -11
  3. package/dist/{chunk-2CJSLYWI.js → chunk-3TYWIX3B.js} +107 -1
  4. package/dist/{chunk-66QHV5KW.js → chunk-6FIB72KX.js} +66 -1
  5. package/dist/{chunk-I63BCOAG.js → chunk-GDIZWDBY.js} +57 -1
  6. package/dist/{chunk-WO3LJMVV.js → chunk-WVEKRKGU.js} +101 -1
  7. package/dist/{data-XRb0D7Zn.d.cts → data-C4lCByXw.d.cts} +24 -2
  8. package/dist/{data-XRb0D7Zn.d.ts → data-C4lCByXw.d.ts} +24 -2
  9. package/dist/{generators-BGtRGpJZ.d.ts → generators-Du8cBesn.d.cts} +45 -2
  10. package/dist/{generators-BGtRGpJZ.d.cts → generators-Du8cBesn.d.ts} +45 -2
  11. package/dist/index.cjs +327 -0
  12. package/dist/index.d.cts +4 -4
  13. package/dist/index.d.ts +4 -4
  14. package/dist/index.js +4 -4
  15. package/dist/{json-DEVFIpsC.d.cts → json-Ta9JykSB.d.cts} +36 -2
  16. package/dist/{json-DEVFIpsC.d.ts → json-Ta9JykSB.d.ts} +36 -2
  17. package/dist/tools/data.cjs +65 -0
  18. package/dist/tools/data.d.cts +1 -1
  19. package/dist/tools/data.d.ts +1 -1
  20. package/dist/tools/data.js +1 -1
  21. package/dist/tools/generators.cjs +106 -0
  22. package/dist/tools/generators.d.cts +1 -1
  23. package/dist/tools/generators.d.ts +1 -1
  24. package/dist/tools/generators.js +1 -1
  25. package/dist/tools/json.cjs +100 -0
  26. package/dist/tools/json.d.cts +1 -1
  27. package/dist/tools/json.d.ts +1 -1
  28. package/dist/tools/json.js +1 -1
  29. package/dist/tools/units.cjs +56 -0
  30. package/dist/tools/units.d.cts +1 -1
  31. package/dist/tools/units.d.ts +1 -1
  32. package/dist/tools/units.js +1 -1
  33. package/dist/{units-COt5uI20.d.cts → units-DQYLZd1n.d.cts} +33 -2
  34. package/dist/{units-COt5uI20.d.ts → units-DQYLZd1n.d.ts} +33 -2
  35. package/package.json +1 -1
@@ -13,6 +13,7 @@
13
13
  * - env-diff-checker: diffEnvExample
14
14
  * - ndjson-formatter: validateNdjson, minifyNdjson, formatNdjson, ndjsonToJsonArray, jsonArrayToNdjson
15
15
  * - subtitle-converter: parseSubtitleTimestamp, formatSubtitleTimestamp, detectSubtitleFormat, parseSubtitles, serializeSubtitles, convertSubtitles, shiftSubtitles
16
+ * - markdown-front-matter-parser: parseFrontMatter
16
17
  */
17
18
  interface ValidationResult {
18
19
  valid: boolean;
@@ -272,6 +273,24 @@ declare function convertSubtitles(input: string, target: SubtitleFormat, sourceF
272
273
  declare function shiftSubtitles(input: string, offsetSeconds: number, target?: SubtitleFormat): ConvertedSubtitles | {
273
274
  error: string;
274
275
  };
276
+ interface FrontMatterResult {
277
+ frontMatter: Record<string, unknown>;
278
+ body: string;
279
+ hasFrontMatter: boolean;
280
+ raw: string;
281
+ }
282
+ interface FrontMatterError {
283
+ error: string;
284
+ }
285
+ /**
286
+ * Split a Markdown document into its YAML front matter (delimited by --- lines
287
+ * at the top) and body content. Parses simple scalar values (strings, quoted
288
+ * strings, booleans, numbers, null), inline arrays (`tags: [a, b]`), and YAML
289
+ * block lists (`tags:\n - a\n - b`). Not a full YAML parser: nested mappings
290
+ * and multi-line block scalars are not supported. A document with no opening
291
+ * "---" delimiter is returned as-is with `hasFrontMatter: false`.
292
+ */
293
+ declare function parseFrontMatter(input: string): FrontMatterResult | FrontMatterError;
275
294
 
276
295
  type data_ConvertedSubtitles = ConvertedSubtitles;
277
296
  type data_CsvParseResult = CsvParseResult;
@@ -279,6 +298,8 @@ type data_EnvDiffError = EnvDiffError;
279
298
  type data_EnvDiffResult = EnvDiffResult;
280
299
  type data_EnvEntry = EnvEntry;
281
300
  type data_EnvParseResult = EnvParseResult;
301
+ type data_FrontMatterError = FrontMatterError;
302
+ type data_FrontMatterResult = FrontMatterResult;
282
303
  type data_IniSection = IniSection;
283
304
  type data_NdjsonLineResult = NdjsonLineResult;
284
305
  type data_NdjsonValidateResult = NdjsonValidateResult;
@@ -318,6 +339,7 @@ declare const data_minifyXml: typeof minifyXml;
318
339
  declare const data_ndjsonToJsonArray: typeof ndjsonToJsonArray;
319
340
  declare const data_parseCsv: typeof parseCsv;
320
341
  declare const data_parseEnv: typeof parseEnv;
342
+ declare const data_parseFrontMatter: typeof parseFrontMatter;
321
343
  declare const data_parseIni: typeof parseIni;
322
344
  declare const data_parseSubtitleTimestamp: typeof parseSubtitleTimestamp;
323
345
  declare const data_parseSubtitles: typeof parseSubtitles;
@@ -335,7 +357,7 @@ declare const data_validateXml: typeof validateXml;
335
357
  declare const data_validateYaml: typeof validateYaml;
336
358
  declare const data_xmlToJson: typeof xmlToJson;
337
359
  declare namespace data {
338
- export { type data_ConvertedSubtitles as ConvertedSubtitles, type data_CsvParseResult as CsvParseResult, type data_EnvDiffError as EnvDiffError, type data_EnvDiffResult as EnvDiffResult, type data_EnvEntry as EnvEntry, type data_EnvParseResult as EnvParseResult, type data_IniSection as IniSection, type data_NdjsonLineResult as NdjsonLineResult, type data_NdjsonValidateResult as NdjsonValidateResult, type data_ParseOptions as ParseOptions, type data_ParsedIni as ParsedIni, type data_ParsedSubtitles as ParsedSubtitles, type data_SubtitleCue as SubtitleCue, type data_SubtitleFormat as SubtitleFormat, type data_TomlFormatResult as TomlFormatResult, type data_ValidationResult as ValidationResult, type data_XmlFormatResult as XmlFormatResult, type data_XmlToJsonOptions as XmlToJsonOptions, data_convertSubtitles as convertSubtitles, data_csvToJson as csvToJson, data_detectDelimiter as detectDelimiter, data_detectSubtitleFormat as detectSubtitleFormat, data_diffEnvExample as diffEnvExample, data_envToExport as envToExport, data_envToJson as envToJson, data_formatNdjson as formatNdjson, data_formatSubtitleTimestamp as formatSubtitleTimestamp, data_formatToml as formatToml, data_formatXml as formatXml, data_getSection as getSection, data_getSectionNames as getSectionNames, data_getTomlStats as getTomlStats, data_getXmlStats as getXmlStats, data_getYamlStats as getYamlStats, data_iniToJson as iniToJson, data_jsonArrayToNdjson as jsonArrayToNdjson, data_jsonToIni as jsonToIni, data_jsonToToml as jsonToToml, data_jsonToXml as jsonToXml, data_minifyNdjson as minifyNdjson, data_minifyToml as minifyToml, data_minifyXml as minifyXml, data_ndjsonToJsonArray as ndjsonToJsonArray, data_parseCsv as parseCsv, data_parseEnv as parseEnv, data_parseIni as parseIni, data_parseSubtitleTimestamp as parseSubtitleTimestamp, data_parseSubtitles as parseSubtitles, data_parseXmlToObject as parseXmlToObject, data_serializeSubtitles as serializeSubtitles, data_shiftSubtitles as shiftSubtitles, data_stringifyIni as stringifyIni, data_toCsvString as toCsvString, data_tomlToJson as tomlToJson, data_validateEnvKey as validateEnvKey, data_validateIni as validateIni, data_validateNdjson as validateNdjson, data_validateToml as validateToml, data_validateXml as validateXml, data_validateYaml as validateYaml, data_xmlToJson as xmlToJson };
360
+ export { type data_ConvertedSubtitles as ConvertedSubtitles, type data_CsvParseResult as CsvParseResult, type data_EnvDiffError as EnvDiffError, type data_EnvDiffResult as EnvDiffResult, type data_EnvEntry as EnvEntry, type data_EnvParseResult as EnvParseResult, type data_FrontMatterError as FrontMatterError, type data_FrontMatterResult as FrontMatterResult, type data_IniSection as IniSection, type data_NdjsonLineResult as NdjsonLineResult, type data_NdjsonValidateResult as NdjsonValidateResult, type data_ParseOptions as ParseOptions, type data_ParsedIni as ParsedIni, type data_ParsedSubtitles as ParsedSubtitles, type data_SubtitleCue as SubtitleCue, type data_SubtitleFormat as SubtitleFormat, type data_TomlFormatResult as TomlFormatResult, type data_ValidationResult as ValidationResult, type data_XmlFormatResult as XmlFormatResult, type data_XmlToJsonOptions as XmlToJsonOptions, data_convertSubtitles as convertSubtitles, data_csvToJson as csvToJson, data_detectDelimiter as detectDelimiter, data_detectSubtitleFormat as detectSubtitleFormat, data_diffEnvExample as diffEnvExample, data_envToExport as envToExport, data_envToJson as envToJson, data_formatNdjson as formatNdjson, data_formatSubtitleTimestamp as formatSubtitleTimestamp, data_formatToml as formatToml, data_formatXml as formatXml, data_getSection as getSection, data_getSectionNames as getSectionNames, data_getTomlStats as getTomlStats, data_getXmlStats as getXmlStats, data_getYamlStats as getYamlStats, data_iniToJson as iniToJson, data_jsonArrayToNdjson as jsonArrayToNdjson, data_jsonToIni as jsonToIni, data_jsonToToml as jsonToToml, data_jsonToXml as jsonToXml, data_minifyNdjson as minifyNdjson, data_minifyToml as minifyToml, data_minifyXml as minifyXml, data_ndjsonToJsonArray as ndjsonToJsonArray, data_parseCsv as parseCsv, data_parseEnv as parseEnv, data_parseFrontMatter as parseFrontMatter, data_parseIni as parseIni, data_parseSubtitleTimestamp as parseSubtitleTimestamp, data_parseSubtitles as parseSubtitles, data_parseXmlToObject as parseXmlToObject, data_serializeSubtitles as serializeSubtitles, data_shiftSubtitles as shiftSubtitles, data_stringifyIni as stringifyIni, data_toCsvString as toCsvString, data_tomlToJson as tomlToJson, data_validateEnvKey as validateEnvKey, data_validateIni as validateIni, data_validateNdjson as validateNdjson, data_validateToml as validateToml, data_validateXml as validateXml, data_validateYaml as validateYaml, data_xmlToJson as xmlToJson };
339
361
  }
340
362
 
341
- export { toCsvString as $, iniToJson as A, jsonArrayToNdjson as B, type ConvertedSubtitles as C, jsonToIni as D, type EnvDiffError as E, jsonToToml as F, jsonToXml as G, minifyNdjson as H, type IniSection as I, minifyToml as J, minifyXml as K, ndjsonToJsonArray as L, parseCsv as M, type NdjsonLineResult as N, parseEnv as O, type ParseOptions as P, parseIni as Q, parseSubtitleTimestamp as R, type SubtitleCue as S, type TomlFormatResult as T, parseSubtitles as U, type ValidationResult as V, parseXmlToObject as W, type XmlFormatResult as X, serializeSubtitles as Y, shiftSubtitles as Z, stringifyIni as _, type CsvParseResult as a, tomlToJson as a0, validateEnvKey as a1, validateIni as a2, validateNdjson as a3, validateToml as a4, validateXml as a5, validateYaml as a6, xmlToJson as a7, type EnvDiffResult as b, type EnvEntry as c, data as d, type EnvParseResult as e, type NdjsonValidateResult as f, type ParsedIni as g, type ParsedSubtitles as h, type SubtitleFormat as i, type XmlToJsonOptions as j, convertSubtitles as k, csvToJson as l, detectDelimiter as m, detectSubtitleFormat as n, diffEnvExample as o, envToExport as p, envToJson as q, formatNdjson as r, formatSubtitleTimestamp as s, formatToml as t, formatXml as u, getSection as v, getSectionNames as w, getTomlStats as x, getXmlStats as y, getYamlStats as z };
363
+ export { serializeSubtitles as $, getYamlStats as A, iniToJson as B, type ConvertedSubtitles as C, jsonArrayToNdjson as D, type EnvDiffError as E, type FrontMatterError as F, jsonToIni as G, jsonToToml as H, type IniSection as I, jsonToXml as J, minifyNdjson as K, minifyToml as L, minifyXml as M, type NdjsonLineResult as N, ndjsonToJsonArray as O, type ParseOptions as P, parseCsv as Q, parseEnv as R, type SubtitleCue as S, type TomlFormatResult as T, parseFrontMatter as U, type ValidationResult as V, parseIni as W, type XmlFormatResult as X, parseSubtitleTimestamp as Y, parseSubtitles as Z, parseXmlToObject as _, type CsvParseResult as a, shiftSubtitles as a0, stringifyIni as a1, toCsvString as a2, tomlToJson as a3, validateEnvKey as a4, validateIni as a5, validateNdjson as a6, validateToml as a7, validateXml as a8, validateYaml as a9, xmlToJson as aa, type EnvDiffResult as b, type EnvEntry as c, data as d, type EnvParseResult as e, type FrontMatterResult as f, type NdjsonValidateResult as g, type ParsedIni as h, type ParsedSubtitles as i, type SubtitleFormat as j, type XmlToJsonOptions as k, convertSubtitles as l, csvToJson as m, detectDelimiter as n, detectSubtitleFormat as o, diffEnvExample as p, envToExport as q, envToJson as r, formatNdjson as s, formatSubtitleTimestamp as t, formatToml as u, formatXml as v, getSection as w, getSectionNames as x, getTomlStats as y, getXmlStats 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 };
@@ -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 = {};
@@ -4536,6 +4636,7 @@ __export(data_exports, {
4536
4636
  ndjsonToJsonArray: () => ndjsonToJsonArray,
4537
4637
  parseCsv: () => parseCsv,
4538
4638
  parseEnv: () => parseEnv,
4639
+ parseFrontMatter: () => parseFrontMatter,
4539
4640
  parseIni: () => parseIni,
4540
4641
  parseSubtitleTimestamp: () => parseSubtitleTimestamp,
4541
4642
  parseSubtitles: () => parseSubtitles,
@@ -5838,6 +5939,70 @@ function shiftSubtitles(input, offsetSeconds, target) {
5838
5939
  warnings
5839
5940
  };
5840
5941
  }
5942
+ function parseFrontMatterScalar(value) {
5943
+ if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
5944
+ return value.slice(1, -1);
5945
+ }
5946
+ if (value === "true") return true;
5947
+ if (value === "false") return false;
5948
+ if (value === "null" || value === "~") return null;
5949
+ if (value !== "" && !Number.isNaN(Number(value))) return Number(value);
5950
+ return value;
5951
+ }
5952
+ function parseFrontMatter(input) {
5953
+ if (typeof input !== "string" || input.length === 0) return { error: "input is required" };
5954
+ const normalized = input.replace(/\r\n/g, "\n");
5955
+ if (!normalized.startsWith("---\n") && normalized !== "---") {
5956
+ return { frontMatter: {}, body: input, hasFrontMatter: false, raw: "" };
5957
+ }
5958
+ const closingIdx = normalized.indexOf("\n---", 4);
5959
+ if (closingIdx === -1) {
5960
+ return { error: 'Front matter opening delimiter found but no closing "---" delimiter' };
5961
+ }
5962
+ const raw = normalized.slice(4, closingIdx);
5963
+ let afterClose = normalized.slice(closingIdx + 4);
5964
+ if (afterClose.startsWith("\n")) afterClose = afterClose.slice(1);
5965
+ const frontMatter = {};
5966
+ const rawLines = raw.split("\n");
5967
+ let i = 0;
5968
+ while (i < rawLines.length) {
5969
+ const line = rawLines[i];
5970
+ if (line.trim() === "" || line.trim().startsWith("#")) {
5971
+ i++;
5972
+ continue;
5973
+ }
5974
+ const colonIdx = line.indexOf(":");
5975
+ if (colonIdx === -1) return { error: `Invalid front matter line ${i + 1}: expected "key: value"` };
5976
+ const key = line.slice(0, colonIdx).trim();
5977
+ if (!key) return { error: `Invalid front matter line ${i + 1}: empty key` };
5978
+ const rest = line.slice(colonIdx + 1).trim();
5979
+ if (rest === "") {
5980
+ const listItems = [];
5981
+ let j = i + 1;
5982
+ while (j < rawLines.length && /^\s*-\s+/.test(rawLines[j])) {
5983
+ listItems.push(rawLines[j].replace(/^\s*-\s+/, "").trim());
5984
+ j++;
5985
+ }
5986
+ if (listItems.length > 0) {
5987
+ frontMatter[key] = listItems.map(parseFrontMatterScalar);
5988
+ i = j;
5989
+ continue;
5990
+ }
5991
+ frontMatter[key] = null;
5992
+ i++;
5993
+ continue;
5994
+ }
5995
+ if (rest.startsWith("[") && rest.endsWith("]")) {
5996
+ const inner = rest.slice(1, -1).trim();
5997
+ frontMatter[key] = inner === "" ? [] : inner.split(",").map((s) => parseFrontMatterScalar(s.trim()));
5998
+ i++;
5999
+ continue;
6000
+ }
6001
+ frontMatter[key] = parseFrontMatterScalar(rest);
6002
+ i++;
6003
+ }
6004
+ return { frontMatter, body: afterClose, hasFrontMatter: true, raw };
6005
+ }
5841
6006
 
5842
6007
  // src/tools/generators.ts
5843
6008
  var generators_exports = {};
@@ -5849,6 +6014,7 @@ __export(generators_exports, {
5849
6014
  SYMBOL_CHARS: () => SYMBOL_CHARS,
5850
6015
  ULID_REGEX: () => ULID_REGEX,
5851
6016
  checkStrength: () => checkStrength,
6017
+ estimatePasswordEntropy: () => estimatePasswordEntropy,
5852
6018
  generateBulk: () => generateBulk,
5853
6019
  generateBulkPasswords: () => generateBulkPasswords,
5854
6020
  generateBulkUlids: () => generateBulkUlids,
@@ -6065,6 +6231,111 @@ function checkStrength(password) {
6065
6231
  color: levels[score].color
6066
6232
  };
6067
6233
  }
6234
+ var _SYMBOL_POOL_CHARS = " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
6235
+ var _SYMBOL_POOL_SET = new Set(_SYMBOL_POOL_CHARS.split(""));
6236
+ function _hasSymbolChar(password) {
6237
+ for (const ch of password) {
6238
+ if (_SYMBOL_POOL_SET.has(ch)) return true;
6239
+ }
6240
+ return false;
6241
+ }
6242
+ function _hasSequentialRun(password, minRun) {
6243
+ let ascRun = 1;
6244
+ let descRun = 1;
6245
+ for (let i = 1; i < password.length; i++) {
6246
+ const prev = password.charCodeAt(i - 1);
6247
+ const curr = password.charCodeAt(i);
6248
+ if (curr === prev + 1) {
6249
+ ascRun++;
6250
+ descRun = 1;
6251
+ } else if (curr === prev - 1) {
6252
+ descRun++;
6253
+ ascRun = 1;
6254
+ } else {
6255
+ ascRun = 1;
6256
+ descRun = 1;
6257
+ }
6258
+ if (ascRun >= minRun || descRun >= minRun) return true;
6259
+ }
6260
+ return false;
6261
+ }
6262
+ function _formatCrackDuration(seconds) {
6263
+ if (!isFinite(seconds)) return "effectively never";
6264
+ if (seconds < 1) return "instantly";
6265
+ const units = [
6266
+ ["century", 315576e4],
6267
+ ["year", 31557600],
6268
+ ["month", 2629800],
6269
+ ["day", 86400],
6270
+ ["hour", 3600],
6271
+ ["minute", 60],
6272
+ ["second", 1]
6273
+ ];
6274
+ for (const [name, unitSeconds] of units) {
6275
+ if (seconds >= unitSeconds) {
6276
+ const value = seconds / unitSeconds;
6277
+ if (name === "century" && value > 1e3) return "longer than the age of the universe";
6278
+ const rounded = value >= 100 ? Math.round(value) : Math.round(value * 10) / 10;
6279
+ const plural = name === "century" ? "centuries" : `${name}s`;
6280
+ return `${rounded} ${rounded === 1 ? name : plural}`;
6281
+ }
6282
+ }
6283
+ return "instantly";
6284
+ }
6285
+ function estimatePasswordEntropy(password) {
6286
+ if (!password) return { error: "Password is required" };
6287
+ const hasLowercase = /[a-z]/.test(password);
6288
+ const hasUppercase = /[A-Z]/.test(password);
6289
+ const hasDigits = /[0-9]/.test(password);
6290
+ const hasSymbols = _hasSymbolChar(password);
6291
+ const hasOther = /[^\x20-\x7e]/.test(password);
6292
+ let poolSize = 0;
6293
+ if (hasLowercase) poolSize += 26;
6294
+ if (hasUppercase) poolSize += 26;
6295
+ if (hasDigits) poolSize += 10;
6296
+ if (hasSymbols) poolSize += _SYMBOL_POOL_CHARS.length;
6297
+ if (hasOther) poolSize += 100;
6298
+ const entropyBits = Math.round(password.length * Math.log2(poolSize) * 100) / 100;
6299
+ let strength;
6300
+ if (entropyBits < 28) strength = "very-weak";
6301
+ else if (entropyBits < 36) strength = "weak";
6302
+ else if (entropyBits < 60) strength = "fair";
6303
+ else if (entropyBits < 128) strength = "strong";
6304
+ else strength = "very-strong";
6305
+ const averageGuesses = Math.pow(2, entropyBits) / 2;
6306
+ const scenarios = [
6307
+ { scenario: "Online, throttled (100 guesses/hour)", guessesPerSecond: 100 / 3600 },
6308
+ { scenario: "Online, unthrottled (10 guesses/sec)", guessesPerSecond: 10 },
6309
+ { scenario: "Offline, slow hash e.g. bcrypt (10k guesses/sec)", guessesPerSecond: 1e4 },
6310
+ { scenario: "Offline, fast hash / GPU cluster (10B guesses/sec)", guessesPerSecond: 1e10 }
6311
+ ];
6312
+ const crackTimes = scenarios.map((s) => ({
6313
+ scenario: s.scenario,
6314
+ guessesPerSecond: s.guessesPerSecond,
6315
+ humanReadable: _formatCrackDuration(averageGuesses / s.guessesPerSecond)
6316
+ }));
6317
+ const warnings = [];
6318
+ if (password.length < 8) {
6319
+ warnings.push("Shorter than 8 characters \u2014 most sites and cracking tools treat this as trivially weak regardless of entropy.");
6320
+ }
6321
+ if (/(.)\1{2,}/.test(password)) {
6322
+ warnings.push('Contains a repeated character run (e.g. "aaa"), which is easier to guess than the entropy figure implies.');
6323
+ }
6324
+ if (_hasSequentialRun(password, 3)) {
6325
+ warnings.push('Contains a sequential run (e.g. "abc" or "321"), which is easier to guess than the entropy figure implies.');
6326
+ }
6327
+ if (poolSize <= 26) {
6328
+ warnings.push("Uses only one character class \u2014 mixing in uppercase, digits, or symbols raises the character pool and entropy.");
6329
+ }
6330
+ return {
6331
+ length: password.length,
6332
+ charset: { hasLowercase, hasUppercase, hasDigits, hasSymbols, hasOther, poolSize },
6333
+ entropyBits,
6334
+ strength,
6335
+ crackTimes,
6336
+ warnings
6337
+ };
6338
+ }
6068
6339
  var DATA_TYPES = [
6069
6340
  { value: "name", label: "Full Name", example: "John Smith" },
6070
6341
  { value: "email", label: "Email Address", example: "john.smith@gmail.com" },
@@ -7151,6 +7422,7 @@ __export(units_exports, {
7151
7422
  calculateBreakEven: () => calculateBreakEven,
7152
7423
  calculateCompoundInterest: () => calculateCompoundInterest,
7153
7424
  calculateDiscount: () => calculateDiscount,
7425
+ calculateEmi: () => calculateEmi,
7154
7426
  calculateLoan: () => calculateLoan,
7155
7427
  calculateMarginMarkup: () => calculateMarginMarkup,
7156
7428
  calculatePercentageChange: () => calculatePercentageChange,
@@ -8805,6 +9077,61 @@ function calculateRuleOf72(value, direction) {
8805
9077
  errorPercent: round4(errorPercent)
8806
9078
  };
8807
9079
  }
9080
+ function calculateEmi(principal, annualRatePercent, tenure, tenureUnit = "years") {
9081
+ if (!Number.isFinite(principal) || principal <= 0) return { error: "Principal must be a positive number" };
9082
+ if (!Number.isFinite(annualRatePercent) || annualRatePercent < 0) {
9083
+ return { error: "Annual interest rate must be zero or a positive number" };
9084
+ }
9085
+ if (tenureUnit !== "years" && tenureUnit !== "months") {
9086
+ return { error: 'tenureUnit must be "years" or "months"' };
9087
+ }
9088
+ if (!Number.isFinite(tenure) || tenure <= 0) return { error: "Tenure must be a positive number" };
9089
+ const tenureMonths = Math.round(tenureUnit === "years" ? tenure * 12 : tenure);
9090
+ if (tenureMonths <= 0) return { error: "Tenure must resolve to at least 1 month" };
9091
+ const monthlyRate = annualRatePercent / 100 / 12;
9092
+ let emi;
9093
+ if (monthlyRate === 0) {
9094
+ emi = principal / tenureMonths;
9095
+ } else {
9096
+ const factor = Math.pow(1 + monthlyRate, tenureMonths);
9097
+ emi = principal * monthlyRate * factor / (factor - 1);
9098
+ }
9099
+ const yearlyBreakdown = [];
9100
+ let balance = round2(principal);
9101
+ let totalPayment = 0;
9102
+ let yearPrincipal = 0;
9103
+ let yearInterest = 0;
9104
+ let year = 1;
9105
+ for (let month = 1; month <= tenureMonths; month++) {
9106
+ const interest = monthlyRate === 0 ? 0 : round2(balance * monthlyRate);
9107
+ let principalPortion = round2(emi) - interest;
9108
+ if (month === tenureMonths || principalPortion > balance) principalPortion = balance;
9109
+ const payment = round2(principalPortion + interest);
9110
+ balance = Math.max(round2(balance - principalPortion), 0);
9111
+ totalPayment += payment;
9112
+ yearPrincipal += principalPortion;
9113
+ yearInterest += interest;
9114
+ const isYearEnd = month % 12 === 0 || month === tenureMonths;
9115
+ if (isYearEnd) {
9116
+ yearlyBreakdown.push({
9117
+ year,
9118
+ principalPaid: round2(yearPrincipal),
9119
+ interestPaid: round2(yearInterest),
9120
+ balance
9121
+ });
9122
+ year += 1;
9123
+ yearPrincipal = 0;
9124
+ yearInterest = 0;
9125
+ }
9126
+ }
9127
+ return {
9128
+ emi: round2(emi),
9129
+ totalInterest: round2(totalPayment - principal),
9130
+ totalPayment: round2(totalPayment),
9131
+ tenureMonths,
9132
+ yearlyBreakdown
9133
+ };
9134
+ }
8808
9135
 
8809
9136
  // src/tools/network.ts
8810
9137
  var network_exports = {};
package/dist/index.d.cts CHANGED
@@ -1,11 +1,11 @@
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
- export { d as data } from './data-XRb0D7Zn.cjs';
6
- export { g as generators } from './generators-BGtRGpJZ.cjs';
5
+ export { d as data } from './data-C4lCByXw.cjs';
6
+ export { g as generators } from './generators-Du8cBesn.cjs';
7
7
  export { t as time } from './time-KqJjdqII.cjs';
8
- export { u as units } from './units-COt5uI20.cjs';
8
+ export { u as units } from './units-DQYLZd1n.cjs';
9
9
  export { n as network } from './network-D7Epuerc.cjs';
10
10
  export { a as api } from './api-DmTNE4c1.cjs';
11
11
  export { c as code } from './code-DaRvff2v.cjs';
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
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
- export { d as data } from './data-XRb0D7Zn.js';
6
- export { g as generators } from './generators-BGtRGpJZ.js';
5
+ export { d as data } from './data-C4lCByXw.js';
6
+ export { g as generators } from './generators-Du8cBesn.js';
7
7
  export { t as time } from './time-KqJjdqII.js';
8
- export { u as units } from './units-COt5uI20.js';
8
+ export { u as units } from './units-DQYLZd1n.js';
9
9
  export { n as network } from './network-D7Epuerc.js';
10
10
  export { a as api } from './api-DmTNE4c1.js';
11
11
  export { c as code } from './code-DaRvff2v.js';