@utilix-tech/sdk 0.28.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 +8 -0
- package/README.md +28 -11
- package/dist/{chunk-2CJSLYWI.js → chunk-3TYWIX3B.js} +107 -1
- package/dist/{chunk-Y5OOP6WN.js → chunk-CSNTHZHF.js} +90 -1
- package/dist/{chunk-47DTCCQJ.js → chunk-L6V4W4SU.js} +112 -1
- package/dist/{chunk-WO3LJMVV.js → chunk-WVEKRKGU.js} +101 -1
- package/dist/{generators-BGtRGpJZ.d.cts → generators-Du8cBesn.d.cts} +45 -2
- package/dist/{generators-BGtRGpJZ.d.ts → generators-Du8cBesn.d.ts} +45 -2
- package/dist/index.cjs +406 -0
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/{json-DEVFIpsC.d.ts → json-Ta9JykSB.d.cts} +36 -2
- package/dist/{json-DEVFIpsC.d.cts → json-Ta9JykSB.d.ts} +36 -2
- package/dist/{media-cuxfzXxw.d.cts → media-fD8dJ5qR.d.cts} +29 -2
- package/dist/{media-cuxfzXxw.d.ts → media-fD8dJ5qR.d.ts} +29 -2
- package/dist/{network-BJOjJnmY.d.ts → network-D7Epuerc.d.cts} +23 -2
- package/dist/{network-BJOjJnmY.d.cts → network-D7Epuerc.d.ts} +23 -2
- package/dist/tools/generators.cjs +106 -0
- package/dist/tools/generators.d.cts +1 -1
- package/dist/tools/generators.d.ts +1 -1
- package/dist/tools/generators.js +1 -1
- package/dist/tools/json.cjs +100 -0
- package/dist/tools/json.d.cts +1 -1
- package/dist/tools/json.d.ts +1 -1
- package/dist/tools/json.js +1 -1
- package/dist/tools/media.cjs +111 -0
- package/dist/tools/media.d.cts +1 -1
- package/dist/tools/media.d.ts +1 -1
- package/dist/tools/media.js +1 -1
- package/dist/tools/network.cjs +89 -0
- package/dist/tools/network.d.cts +1 -1
- package/dist/tools/network.d.ts +1 -1
- package/dist/tools/network.js +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
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
|
|
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" },
|
|
@@ -8833,6 +9039,7 @@ __export(network_exports, {
|
|
|
8833
9039
|
parseDnsResponse: () => parseDnsResponse,
|
|
8834
9040
|
parseGeoResponse: () => parseGeoResponse,
|
|
8835
9041
|
parseHar: () => parseHar,
|
|
9042
|
+
parseIpv6Address: () => parseIpv6Address,
|
|
8836
9043
|
parseUserAgent: () => parseUserAgent,
|
|
8837
9044
|
searchHeaders: () => searchHeaders,
|
|
8838
9045
|
searchStatusCodes: () => searchStatusCodes,
|
|
@@ -10620,6 +10827,94 @@ function buildCacheControl(options = {}) {
|
|
|
10620
10827
|
const snippet = `Cache-Control: ${header}`;
|
|
10621
10828
|
return { header, headerName: "Cache-Control", snippet, directives, warnings };
|
|
10622
10829
|
}
|
|
10830
|
+
function isValidIpv6HexGroup(g) {
|
|
10831
|
+
return /^[0-9a-fA-F]{1,4}$/.test(g);
|
|
10832
|
+
}
|
|
10833
|
+
function isValidIpv6Ipv4Quad(quad) {
|
|
10834
|
+
const parts = quad.split(".");
|
|
10835
|
+
if (parts.length !== 4) return false;
|
|
10836
|
+
return parts.every((p) => /^\d{1,3}$/.test(p) && Number(p) <= 255);
|
|
10837
|
+
}
|
|
10838
|
+
function classifyIpv6(groups) {
|
|
10839
|
+
const first = parseInt(groups[0], 16);
|
|
10840
|
+
if (groups.every((g) => g === "0000")) return "unspecified";
|
|
10841
|
+
if (groups.slice(0, 7).every((g) => g === "0000") && groups[7] === "0001") return "loopback";
|
|
10842
|
+
if (groups.slice(0, 4).every((g) => g === "0000") && groups[4] === "0000" && groups[5] === "ffff") return "ipv4-mapped";
|
|
10843
|
+
if (groups[0] === "2001" && groups[1] === "0db8") return "documentation";
|
|
10844
|
+
if ((first & 65280) === 65280) return "multicast";
|
|
10845
|
+
if ((first & 65472) === 65152) return "link-local";
|
|
10846
|
+
if ((first & 65024) === 64512) return "unique-local";
|
|
10847
|
+
return "global-unicast";
|
|
10848
|
+
}
|
|
10849
|
+
function compressIpv6Groups(groups) {
|
|
10850
|
+
const short = groups.map((g) => g.replace(/^0+(?=.)/, ""));
|
|
10851
|
+
let bestStart = -1;
|
|
10852
|
+
let bestLen = 0;
|
|
10853
|
+
let curStart = -1;
|
|
10854
|
+
let curLen = 0;
|
|
10855
|
+
for (let i = 0; i < short.length; i++) {
|
|
10856
|
+
if (short[i] === "0") {
|
|
10857
|
+
if (curStart === -1) curStart = i;
|
|
10858
|
+
curLen++;
|
|
10859
|
+
if (curLen > bestLen) {
|
|
10860
|
+
bestLen = curLen;
|
|
10861
|
+
bestStart = curStart;
|
|
10862
|
+
}
|
|
10863
|
+
} else {
|
|
10864
|
+
curStart = -1;
|
|
10865
|
+
curLen = 0;
|
|
10866
|
+
}
|
|
10867
|
+
}
|
|
10868
|
+
if (bestLen < 2) return short.join(":");
|
|
10869
|
+
const before = short.slice(0, bestStart).join(":");
|
|
10870
|
+
const after = short.slice(bestStart + bestLen).join(":");
|
|
10871
|
+
return `${before}::${after}`;
|
|
10872
|
+
}
|
|
10873
|
+
function parseIpv6Address(input) {
|
|
10874
|
+
let s = input.trim();
|
|
10875
|
+
if (s.startsWith("[") && s.includes("]")) s = s.slice(1, s.indexOf("]"));
|
|
10876
|
+
let zoneId = null;
|
|
10877
|
+
const pctIdx = s.indexOf("%");
|
|
10878
|
+
if (pctIdx !== -1) {
|
|
10879
|
+
zoneId = s.slice(pctIdx + 1);
|
|
10880
|
+
s = s.slice(0, pctIdx);
|
|
10881
|
+
}
|
|
10882
|
+
if (!s) return { error: "Empty address" };
|
|
10883
|
+
const doubleColonCount = (s.match(/::/g) ?? []).length;
|
|
10884
|
+
if (doubleColonCount > 1) return { error: 'Address contains more than one "::"' };
|
|
10885
|
+
const ipv4Match = s.match(/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
|
|
10886
|
+
if (ipv4Match) {
|
|
10887
|
+
const quad = ipv4Match[1];
|
|
10888
|
+
if (!isValidIpv6Ipv4Quad(quad)) return { error: `Invalid embedded IPv4 address: ${quad}` };
|
|
10889
|
+
const parts = quad.split(".").map(Number);
|
|
10890
|
+
const hi = (parts[0] << 8 | parts[1]).toString(16);
|
|
10891
|
+
const lo = (parts[2] << 8 | parts[3]).toString(16);
|
|
10892
|
+
s = s.slice(0, s.length - quad.length) + `${hi}:${lo}`;
|
|
10893
|
+
}
|
|
10894
|
+
let groups;
|
|
10895
|
+
if (s.includes("::")) {
|
|
10896
|
+
const [left, right] = s.split("::");
|
|
10897
|
+
const leftGroups = left ? left.split(":") : [];
|
|
10898
|
+
const rightGroups = right ? right.split(":") : [];
|
|
10899
|
+
const missing = 8 - (leftGroups.length + rightGroups.length);
|
|
10900
|
+
if (missing < 1) return { error: 'The "::" shorthand must represent at least one group of zeros' };
|
|
10901
|
+
if (![...leftGroups, ...rightGroups].every(isValidIpv6HexGroup)) return { error: "Invalid hex group in address" };
|
|
10902
|
+
groups = [...leftGroups, ...Array(missing).fill("0"), ...rightGroups];
|
|
10903
|
+
} else {
|
|
10904
|
+
groups = s.split(":");
|
|
10905
|
+
if (groups.length !== 8) return { error: `Expected 8 groups, got ${groups.length}` };
|
|
10906
|
+
if (!groups.every(isValidIpv6HexGroup)) return { error: "Invalid hex group in address" };
|
|
10907
|
+
}
|
|
10908
|
+
const expandedGroups = groups.map((g) => g.padStart(4, "0").toLowerCase());
|
|
10909
|
+
const suffix = zoneId ? `%${zoneId}` : "";
|
|
10910
|
+
return {
|
|
10911
|
+
expanded: expandedGroups.join(":") + suffix,
|
|
10912
|
+
compressed: compressIpv6Groups(expandedGroups) + suffix,
|
|
10913
|
+
groups: expandedGroups,
|
|
10914
|
+
zoneId,
|
|
10915
|
+
addressType: classifyIpv6(expandedGroups)
|
|
10916
|
+
};
|
|
10917
|
+
}
|
|
10623
10918
|
|
|
10624
10919
|
// src/tools/api.ts
|
|
10625
10920
|
var api_exports = {};
|
|
@@ -19237,6 +19532,7 @@ __export(media_exports, {
|
|
|
19237
19532
|
readId3Tags: () => readId3Tags,
|
|
19238
19533
|
readImageInfo: () => readImageInfo,
|
|
19239
19534
|
readPdfMetadata: () => readPdfMetadata,
|
|
19535
|
+
readPdfPageDimensions: () => readPdfPageDimensions,
|
|
19240
19536
|
readVideoInfo: () => readVideoInfo,
|
|
19241
19537
|
readWavInfo: () => readWavInfo
|
|
19242
19538
|
});
|
|
@@ -19696,6 +19992,116 @@ function readPdfMetadata(bytes) {
|
|
|
19696
19992
|
encrypted
|
|
19697
19993
|
};
|
|
19698
19994
|
}
|
|
19995
|
+
var PDF_COMMON_PAPER_SIZES = [
|
|
19996
|
+
{ name: "Letter", widthPt: 612, heightPt: 792 },
|
|
19997
|
+
{ name: "Legal", widthPt: 612, heightPt: 1008 },
|
|
19998
|
+
{ name: "Tabloid", widthPt: 792, heightPt: 1224 },
|
|
19999
|
+
{ name: "A3", widthPt: 842, heightPt: 1191 },
|
|
20000
|
+
{ name: "A4", widthPt: 595, heightPt: 842 },
|
|
20001
|
+
{ name: "A5", widthPt: 420, heightPt: 595 },
|
|
20002
|
+
{ name: "B5", widthPt: 499, heightPt: 709 }
|
|
20003
|
+
];
|
|
20004
|
+
function matchPaperSize(widthPt, heightPt) {
|
|
20005
|
+
for (const size of PDF_COMMON_PAPER_SIZES) {
|
|
20006
|
+
const w = Math.abs(widthPt - size.widthPt) <= 1;
|
|
20007
|
+
const h = Math.abs(heightPt - size.heightPt) <= 1;
|
|
20008
|
+
const wSwapped = Math.abs(widthPt - size.heightPt) <= 1;
|
|
20009
|
+
const hSwapped = Math.abs(heightPt - size.widthPt) <= 1;
|
|
20010
|
+
if (w && h || wSwapped && hSwapped) return size.name;
|
|
20011
|
+
}
|
|
20012
|
+
return null;
|
|
20013
|
+
}
|
|
20014
|
+
function parsePdfMediaBox(dict) {
|
|
20015
|
+
const m = dict.match(/\/MediaBox\s*\[\s*(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)\s*\]/);
|
|
20016
|
+
if (!m) return null;
|
|
20017
|
+
return [Number(m[1]), Number(m[2]), Number(m[3]), Number(m[4])];
|
|
20018
|
+
}
|
|
20019
|
+
function parsePdfRotate(dict) {
|
|
20020
|
+
const m = dict.match(/\/Rotate\s+(-?\d+)/);
|
|
20021
|
+
return m ? Number(m[1]) : null;
|
|
20022
|
+
}
|
|
20023
|
+
function buildPdfPageDimension(pageNumber, mediaBox, rotate) {
|
|
20024
|
+
const rotation = (rotate % 360 + 360) % 360;
|
|
20025
|
+
if (!mediaBox) {
|
|
20026
|
+
return { pageNumber, widthPt: null, heightPt: null, widthIn: null, heightIn: null, rotation, orientation: null, paperSize: null };
|
|
20027
|
+
}
|
|
20028
|
+
const [llx, lly, urx, ury] = mediaBox;
|
|
20029
|
+
let widthPt = Math.abs(urx - llx);
|
|
20030
|
+
let heightPt = Math.abs(ury - lly);
|
|
20031
|
+
if (rotation === 90 || rotation === 270) [widthPt, heightPt] = [heightPt, widthPt];
|
|
20032
|
+
const orientation = widthPt === heightPt ? "square" : widthPt > heightPt ? "landscape" : "portrait";
|
|
20033
|
+
return {
|
|
20034
|
+
pageNumber,
|
|
20035
|
+
widthPt: round22(widthPt),
|
|
20036
|
+
heightPt: round22(heightPt),
|
|
20037
|
+
widthIn: round22(widthPt / 72),
|
|
20038
|
+
heightIn: round22(heightPt / 72),
|
|
20039
|
+
rotation,
|
|
20040
|
+
orientation,
|
|
20041
|
+
paperSize: matchPaperSize(widthPt, heightPt)
|
|
20042
|
+
};
|
|
20043
|
+
}
|
|
20044
|
+
function walkPdfPageTree(objMap, nodeBody, inherited, visited, nodeKey, out) {
|
|
20045
|
+
if (visited.has(nodeKey)) return;
|
|
20046
|
+
visited.add(nodeKey);
|
|
20047
|
+
const mediaBox = parsePdfMediaBox(nodeBody) ?? inherited.mediaBox;
|
|
20048
|
+
const rotateMatch = parsePdfRotate(nodeBody);
|
|
20049
|
+
const rotate = rotateMatch !== null ? rotateMatch : inherited.rotate;
|
|
20050
|
+
if (/\/Type\s*\/Page(?!s)\b/.test(nodeBody)) {
|
|
20051
|
+
out.push(buildPdfPageDimension(out.length + 1, mediaBox, rotate));
|
|
20052
|
+
return;
|
|
20053
|
+
}
|
|
20054
|
+
const kidsMatch = nodeBody.match(/\/Kids\s*\[([^\]]*)\]/);
|
|
20055
|
+
if (!kidsMatch) return;
|
|
20056
|
+
const kidRefs = [...kidsMatch[1].matchAll(/(\d+)\s+(\d+)\s+R/g)];
|
|
20057
|
+
for (const ref of kidRefs) {
|
|
20058
|
+
const key = `${ref[1]} ${ref[2]}`;
|
|
20059
|
+
const body = objMap.get(key);
|
|
20060
|
+
if (body) walkPdfPageTree(objMap, body, { mediaBox, rotate }, visited, key, out);
|
|
20061
|
+
}
|
|
20062
|
+
}
|
|
20063
|
+
function readPdfPageDimensions(bytes) {
|
|
20064
|
+
if (bytes.length < 8) return { error: "File too small to be a PDF" };
|
|
20065
|
+
const header = bytesToLatin1(bytes.subarray(0, 16));
|
|
20066
|
+
const versionMatch = header.match(/%PDF-(\d\.\d)/);
|
|
20067
|
+
if (!versionMatch) return { error: "Not a valid PDF file (missing %PDF header)" };
|
|
20068
|
+
const version2 = versionMatch[1];
|
|
20069
|
+
const text = bytesToLatin1(bytes);
|
|
20070
|
+
const objBlocks = [...text.matchAll(/(\d+)\s+(\d+)\s+obj([\s\S]*?)endobj/g)];
|
|
20071
|
+
const objMap = /* @__PURE__ */ new Map();
|
|
20072
|
+
for (const b of objBlocks) objMap.set(`${b[1]} ${b[2]}`, b[3]);
|
|
20073
|
+
const out = [];
|
|
20074
|
+
const visited = /* @__PURE__ */ new Set();
|
|
20075
|
+
let pagesRootBody = null;
|
|
20076
|
+
const trailerMatches = [...text.matchAll(/trailer\s*<<([\s\S]*?)>>/g)];
|
|
20077
|
+
if (trailerMatches.length > 0) {
|
|
20078
|
+
const trailer = trailerMatches[trailerMatches.length - 1][1];
|
|
20079
|
+
const rootRef = trailer.match(/\/Root\s+(\d+)\s+(\d+)\s+R/);
|
|
20080
|
+
if (rootRef) {
|
|
20081
|
+
const catalogBody = objMap.get(`${rootRef[1]} ${rootRef[2]}`);
|
|
20082
|
+
const pagesRef = catalogBody?.match(/\/Pages\s+(\d+)\s+(\d+)\s+R/);
|
|
20083
|
+
if (pagesRef) pagesRootBody = objMap.get(`${pagesRef[1]} ${pagesRef[2]}`) ?? null;
|
|
20084
|
+
}
|
|
20085
|
+
}
|
|
20086
|
+
if (!pagesRootBody) {
|
|
20087
|
+
for (const b of objBlocks) {
|
|
20088
|
+
if (/\/Type\s*\/Pages\b/.test(b[3]) && !/\/Parent\s+\d+\s+\d+\s+R/.test(b[3])) {
|
|
20089
|
+
pagesRootBody = b[3];
|
|
20090
|
+
break;
|
|
20091
|
+
}
|
|
20092
|
+
}
|
|
20093
|
+
}
|
|
20094
|
+
if (pagesRootBody) walkPdfPageTree(objMap, pagesRootBody, { mediaBox: null, rotate: 0 }, visited, "root", out);
|
|
20095
|
+
if (out.length === 0) {
|
|
20096
|
+
for (const b of objBlocks) {
|
|
20097
|
+
if (/\/Type\s*\/Page(?!s)\b/.test(b[3])) {
|
|
20098
|
+
out.push(buildPdfPageDimension(out.length + 1, parsePdfMediaBox(b[3]), parsePdfRotate(b[3]) ?? 0));
|
|
20099
|
+
}
|
|
20100
|
+
}
|
|
20101
|
+
}
|
|
20102
|
+
if (out.length === 0) return { error: "Could not locate any page objects in this PDF" };
|
|
20103
|
+
return { version: version2, pageCount: out.length, pages: out };
|
|
20104
|
+
}
|
|
19699
20105
|
var AUDIO_FORMAT_LABELS = {
|
|
19700
20106
|
1: "PCM",
|
|
19701
20107
|
3: "IEEE float",
|
package/dist/index.d.cts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export { j as json } from './json-
|
|
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-
|
|
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
|
-
export { n as network } from './network-
|
|
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';
|
|
12
12
|
export { c as color } from './color-tPwZCr9H.cjs';
|
|
13
13
|
export { c as css } from './css-Cf7AMGM-.cjs';
|
|
14
14
|
export { m as misc } from './misc-CA3N198T.cjs';
|
|
15
15
|
export { a as ai_agent } from './ai_agent-B-c59NXD.cjs';
|
|
16
|
-
export { m as media } from './media-
|
|
16
|
+
export { m as media } from './media-fD8dJ5qR.cjs';
|
|
17
17
|
|
|
18
18
|
declare const version = "0.1.0";
|
|
19
19
|
|